Running a reliable server requires a firm grasp of Linux command-line utilities. Whether you are maintaining a production web server, hosting game instances, or orchestrating microservices on a RivinCloud VPS, knowing which tool to use can turn a multi-hour troubleshooting ordeal into a two-minute fix.
In this guide, we break down 50 essential Linux commands grouped by administrative focus.
1. System Monitoring & Performance
Understanding hardware utilization prevents silent performance degradation.
htop: Interactive, real-time CPU, memory, and thread monitor.htopuptime: Shows how long the server has been running, current active users, and load averages (1, 5, 15 min).uptime -pvmstat: Reports virtual memory statistics, paging, CPU activity, and I/O traps.vmstat 2 5iostat: Delivers storage input/output statistics for devices and partitions.iostat -xz 1 3free: Displays total, used, and available physical memory and swap.free -hdf: Summarizes disk space usage per filesystem.df -hTdu: Evaluates disk usage of files and directories.du -sh /var/log/* | sort -rh | head -n 10lsof: Lists open files and the processes that opened them.lsof -i :80sar: Collects, reports, and saves system activity information (part ofsysstat).mpstat: Examines individual CPU core utilization.
2. User & Permission Management
Security begins with proper access controls.
useradd/adduser: Creates a new system user account.sudo adduser rivinuserusermod: Modifies existing user parameters (groups, shell, directory).sudo usermod -aG sudo rivinuseruserdel: Removes a user account and optionally deletes their home directory.passwd: Changes passwords for users.chown: Changes file owner and group.sudo chown -R www-data:www-data /var/www/htmlchmod: Modifies file permissions using octal or symbolic modes.chmod 755 /var/www/htmlid: Prints real and effective user and group IDs.who/w: Displays who is currently logged into the server and what they are doing.last: Displays a log of recently logged-in users and reboots.sudo: Executes commands with elevated root privileges.
3. Networking & Connectivity
Diagnosing connectivity bottlenecks and verifying service listeners.
ss: Modern socket statistics tool replacing netstat.ss -tulpnip: Manages network interfaces, routing tables, and IP assignments.ip addr showping: Sends ICMP ECHO_REQUEST packets to network hosts.traceroute/tracepath: Traces the hop-by-hop packet path to a remote host.dig: DNS lookup utility for querying DNS name servers.dig +short A rivincloud.innslookup: Queries Internet domain name servers interactively.curl: Transfers data with URLs (HTTP, HTTPS, FTP).curl -I https://rivincloud.inwget: Non-interactive network downloader.mtr: Combines the functionality oftracerouteandpinginto a live diagnostic tool.tcpdump: Powerful command-line packet analyzer.
4. Service & Process Management
systemctl: Central systemd utility for controlling services.sudo systemctl status nginxjournalctl: Queries and queries systemd service logs.journalctl -u nginx.service -n 50 --no-pagerps: Reports a snapshot of the current active processes.ps aux --sort=-%cpu | head -n 10kill: Sends signals to terminate processes by PID.kill -15 1234killall: Kills processes by executable name.pkill: Signals processes based on name matching.pgrep: Finds or signals processes by name.nohup: Runs a command immune to hangups.nice: Launches a program with a modified scheduling priority.renice: Alters the scheduling priority of running processes.
5. File Operations & Archival
tar: Creates and extracts archive files.tar -czvf backup.tar.gz /var/www/rsync: Fast, versatile remote and local file-copying tool.rsync -avz /local/dir user@remote:/remote/dirscp: Copies files securely over SSH.find: Searches for files in a directory hierarchy.find /var/log -type f -name "*.log" -mtime +30grep: Searches plain-text datasets for lines that match a regular expression.grep -rn "error" /var/log/nginx/sed: Stream editor for filtering and transforming text.awk: Pattern scanning and processing language.tail: Outputs the last part of files; ideal for live logs (tail -f).head: Outputs the first part of files.ln: Creates hard and symbolic links between files.ln -s /etc/nginx/sites-available/app /etc/nginx/sites-enabled/
Common Mistakes
- Running everything as root directly: Always use a non-root administrative user with
sudoto prevent accidental destructive operations. - Forgetting
-h(human-readable) flag: Commands likefree,df, andls -ldefault to raw byte blocks without human-friendly conversion. - Using
kill -9prematurely: Always attemptkill -15(SIGTERM) first so programs can flush caches and close open sockets gracefully.
Troubleshooting
If a command fails or hangs:
- Verify permissions: Run with
sudoif the operation accesses/etcor hardware stats. - Check standard error: Append
2>&1or examine logs in/var/log/syslog. - Check path environment: Ensure the binary directory exists in
$PATH(which <command>).
Best Practices
[!TIP] Create aliases in your
~/.bashrcfile for complex diagnostic commands likeps aux --sort=-%mem | head -n 10(e.g.,alias topmem='ps aux --sort=-%mem | head -n 10').
- Always use
journalctl -xeimmediately after asystemctlunit fails to start. - Test firewall and network commands in a detached screen or tmux session to avoid self-lockouts.
Frequently Asked Questions
Which command is best for checking total available RAM on Linux?
free -h is the standard tool. Look at the available column rather than free, because Linux actively utilizes spare RAM for disk caching.
What is the difference between ss and netstat?
ss communicates directly with kernel socket tables (netlink) and is significantly faster and more accurate than legacy netstat.
Conclusion
Mastering these 50 commands provides the fundamental operational toolkit required to run performant, secure servers. Practice them inside your RivinCloud Linux VPS to build muscle memory for day-to-day administration!
