When managing your Ubuntu VPS hosting environment, knowing the right commands can greatly improve your productivity and system management capabilities. While many Linux users are familiar with basic commands like 'cd' and 'ls', there are many lesser-known but very powerful commands that can enhance your VPS management experience.
Prerequisites
A VPS with sufficient storage and memory to install all the commands. In this article, we will be using Ubuntu; however, you can use these commands on most Linux distributions. See how to perform the initial setup on your Ubuntu VPS.
Essential Yet Underutilized Linux Commands
2. comm - The File Comparison Wizard
3. watch - The Real-Time Monitor
4. traceroute - The Network Path Explorer
7. netstat with Specific Options
8. alias - The Command Customizer
9. systemctl - The Service Manager
10. curl with Advanced Options
11. fail2ban-client - The Intrusion Prevention Controller
12. nmap - The Network Scanner
13. journalctl - The Log Explorer
14. nice and renice - The Priority Controllers
16. ncdu - The Disk Usage Analyzer
17. ss - The Socket Statistics Tool
18. sysdig - The System Visibility Tool
19. nload - The Network Load Monitor
21. awk - The Text Processing Powerhouse
22. lsof - The Open File Lister
23. find with -exec - The Powerful File Searcher
24. inotifywait - The File Change Monitor
25. dd with Progress - The Disk Cloner
1. tee - The Output Splitter
The tee command may seem simple, but it's a powerful tool for system administrators working with Ubuntu Virtual Private Servers (VPS). This command allows you to read from standard input and write to both standard output and files simultaneously. It displays and allows you to save output to a file simultaneously.
ping 8.8.8.8 | tee -a network_diagnostics.log
Press Ctrl + C to stop the continuous output of the above command.
This command not only displays the ping results in your terminal but also saves them to a log file for future reference, perfect for troubleshooting network connectivity issues on your VPS.
To see what log the tee command has stored in the file, use the tail command:
tail -n 20 network_diagnostics.log
2. comm - The File Comparison Wizard
When managing configuration files across multiple VPS instances, the comm command becomes invaluable. It combines the functionality of both diff and cmp, allowing you to compare two sorted files line by line.
comm -12 file1.txt file2.txt
This displays only the lines standard to both files - beneficial when syncing configurations between development and production environments.
3. watch - The Real-Time Monitor
Monitoring system changes in real-time can be critical. The watch command executes a program periodically, showing output fullscreen with highlighted differences.
watch -d -n 5 df -h
This refreshes your disk space usage every 5 seconds, highlighting changes - perfect for monitoring resources during high-traffic periods.
4. traceroute - The Network Path Explorer
When troubleshooting connectivity issues on your VPS, understanding the network path is crucial. The traceroute command maps the path packets take across the Internet.
traceroute -n -w 3 yourdomain.com
Or
traceroute -T -p 80 yourdomain.com
This reveals potential bottlenecks or failures in the connection path, helping you diagnose whether the issue lies with your VPS or within the network infrastructure.
5. man - The Built-in Manual
The man command is your detailed guide to virtually every command available on your server.
For targeted help, you can specify manual sections:
man 5 passwd
This displays information about the passwd file format (section 5) - helps when troubleshooting configuration issues on your VPS.
Advanced Command Techniques for VPS Management
6. sed - The Stream Editor
When managing configuration files on your hosting environment, batch editing becomes essential. The sed command allows you to perform powerful text transformations without opening files.
sed -i 's/old-domain.com/new-domain.com/g' /var/www/html/config.php
This command replaces all instances of "old-domain.com" with "new-domain.com" in your configuration file - invaluable when migrating websites.
7. netstat with Specific Options
Understanding network connections is crucial for security and performance optimization. The netstat command, when used with specific options, provides detailed insights.
netstat -tuln
-t: Show TCP connections.
-u: Show UDP connections.
-l: Show only listening sockets.
-n: Show numerical addresses (faster and clear output).
This displays all active TCP and UDP connections listening on your VPS, enabling you to identify potential security vulnerabilities or resource usage issues.
8. alias - The Command Customizer
Enhance your VPS hosting management efficiency by creating aliases for frequently used commands.
alias backup='rsync -avz --delete /var/www/ /backup/www/'
After setting this alias, simply typing 'backup' will execute the full rsync command, saving time and reducing typing errors.
To remove the alias, use ‘unalias’:
unalias backup
9. systemctl - The Service Manager
Modern server systems use systemd for service management. The systemctl command provides complete control over services.
systemctl status apache2
Or
systemctl status nginx
This displays the current status, recent logs, and configuration information for the Apache and Nginx web servers, which is essential for troubleshooting service issues.
10. curl with Advanced Options
When testing web applications or APIs, curl offers powerful capabilities beyond basic requests.
curl -X POST -H "Content-Type: application/json" -d '{"key": "value"}' https://api.example.com/endpoint
This sends a POST request with JSON data and custom headers - perfect for testing and debugging APIs.
Security-Focused Commands for Protection
11. fail2ban-client - The Intrusion Prevention Controller
Protect your hosting from brute force attacks with fail2ban-client, which provides an interface to the Fail2ban service.
fail2ban-client status sshd
This displays the current status of SSH protection, including banned IP addresses and failed attempts, which is crucial for monitoring potential security breaches.
12. nmap - The Network Scanner
Securing your VPS requires understanding open ports and services. The nmap command provides comprehensive network scanning capabilities.
nmap -sV -p 1-1000 localhost
This scans the first 1000 ports on your VPS and attempts to identify service versions - crucial for security audits.
13. journalctl - The Log Explorer
The journalctl command provides powerful filtering capabilities.
journalctl -u nginx --since today
This displays all Nginx-related log entries from the current day - helping you quickly identify recent errors without wading through extensive log files.
Performance Optimization Commands
14. nice and renice - The Priority Controllers
When running resource-intensive tasks on your virtual server, controlling process priorities is crucial to maintaining system responsiveness.
nice -n 19 tar -czf backup.tar.gz /var/www/
This runs the compression process at the lowest priority, ensuring it doesn't impact other critical services during execution.
15. iotop - The I/O Monitor
Disk I/O often becomes a bottleneck in virtual private server (VPS) performance. The iotop command helps identify which processes are causing disk usage spikes.
iotop -o
This displays only processes that are actively performing I/O operations, allowing you to quickly identify potential performance issues.
16. ncdu - The Disk Usage Analyzer
When managing storage, identifying space-consuming directories is crucial. The ncdu (NCurses Disk Usage) command provides an interactive interface for this purpose.
ncdu /var
This scans and displays a navigable list of directories under /var sorted by size, making it easy to find and manage large files that might be consuming valuable VPS storage.
17. ss - The Socket Statistics Tool
Modern systems benefit from ss, a more powerful replacement for netstat that displays detailed socket information.
ss -tuln
This shows TCP and UDP listening sockets with numeric addresses, providing critical information about services running on your VPS without the overhead of the older netstat command.
18. sysdig - The System Visibility Tool
For comprehensive monitoring of your hosting environment, sysdig provides deep visibility into system activity.
sysdig -c topprocs_cpu
This displays the top processes consuming CPU, but sysdig can monitor virtually any aspect of your system with the right filters - from file access to network connections.
19. nload - The Network Load Monitor
Monitoring bandwidth usage on your network is essential to ensure optimal performance. The nload command provides real-time visualization of network usage.
nload eth0
eth = Ethernet
0 = the index (first interface)
This displays graphs of incoming and outgoing traffic for your primary network interface, helping you understand network patterns and identify potential bandwidth issues.
File and Text Processing Commands
20. jq - The JSON Processor
When working with API responses or configuration files on your hosting environment, processing JSON data becomes essential. The jq command provides powerful JSON parsing capabilities.
curl https://api.example.com/data | jq '.items[] | select(.status=="active")'
This fetches data from an API and filters only active items, making it perfect for automated monitoring scripts on your VPS.
21. awk - The Text Processing Powerhouse
For complex text processing, awk offers unparalleled capabilities beyond simple filtering.
awk '{sum+=$1} END {print "Average: " sum/NR}' server_response_times.log
This calculates the average of values in the first column of a log file, which is useful for analyzing performance metrics over time.
22. lsof - The Open File Lister
When troubleshooting file access issues, knowing which processes have files open is crucial.
lsof -i :80
This shows all processes that have opened TCP port 80, helping you identify which application might be conflicting with your web server.
23. find with -exec - The Powerful File Searcher
Combining find with execution parameters creates powerful automation capabilities.
find /var/log -name "*.log" -size +100M -exec truncate -s 0 {} \;
This finds all log files larger than 100MB and truncates them to prevent disk space issues - perfect for automated maintenance.
24. inotifywait - The File Change Monitor
For real-time file monitoring on your VPS, inotifywait provides efficient event-based notifications.
inotifywait -m -e modify,create,delete /var/www/html
This continuously monitors your web directory for any changes - useful for security auditing or triggering automatic deployments.
Backup and Recovery Commands
25. dd with Progress - The Disk Cloner
When creating disk images or backups on your VPS hosting environment, monitoring progress is essential.
dd if=/dev/sda of=/backup/disk.img bs=4M status=progress
This creates a complete disk image while displaying transfer progress, which is critical for monitoring large backup operations.
26. tmux - The Terminal Multiplexer
When running long operations on your VPS, maintaining sessions despite disconnections is vital.
tmux new -s backup
This creates a persistent terminal session named "backup" that will continue running even if your SSH connection drops - perfect for long backups or updates.
27. pv - The Pipe Viewer
When transferring large amounts of data between commands on your VPS, monitoring progress becomes essential.
dd if=/dev/sda | pv -s 500G | dd of=/backup/disk.img
This shows a progress bar during the disk backup process, providing visual feedback for long-running operations.
28. inxi - The System Information Tool
For comprehensive hardware and system information about your hosting environment, inxi offers detailed reports.
inxi -Fxz
This displays complete system information, including CPU, memory, disk, and network details - useful for documentation or support requests.
Mastering these unique Linux commands will improve your ability to manage and secure VPS. By using these commands into your administrative workflow, you'll gain deeper insights into your system's operation, troubleshoot issues more efficiently, and maintain optimal performance for your hosted applications.