Back to Blog

50 Linux Commands for Server Administration

50 Linux Commands for Server Administration
Command of the Day
htop

What it does: An interactive, real-time process viewer and process manager for Unix systems offering intuitive color-coded resource metrics.

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.

  1. htop: Interactive, real-time CPU, memory, and thread monitor.
    htop
    
  2. uptime: Shows how long the server has been running, current active users, and load averages (1, 5, 15 min).
    uptime -p
    
  3. vmstat: Reports virtual memory statistics, paging, CPU activity, and I/O traps.
    vmstat 2 5
    
  4. iostat: Delivers storage input/output statistics for devices and partitions.
    iostat -xz 1 3
    
  5. free: Displays total, used, and available physical memory and swap.
    free -h
    
  6. df: Summarizes disk space usage per filesystem.
    df -hT
    
  7. du: Evaluates disk usage of files and directories.
    du -sh /var/log/* | sort -rh | head -n 10
    
  8. lsof: Lists open files and the processes that opened them.
    lsof -i :80
    
  9. sar: Collects, reports, and saves system activity information (part of sysstat).
  10. mpstat: Examines individual CPU core utilization.

2. User & Permission Management

Security begins with proper access controls.

  1. useradd / adduser: Creates a new system user account.
    sudo adduser rivinuser
    
  2. usermod: Modifies existing user parameters (groups, shell, directory).
    sudo usermod -aG sudo rivinuser
    
  3. userdel: Removes a user account and optionally deletes their home directory.
  4. passwd: Changes passwords for users.
  5. chown: Changes file owner and group.
    sudo chown -R www-data:www-data /var/www/html
    
  6. chmod: Modifies file permissions using octal or symbolic modes.
    chmod 755 /var/www/html
    
  7. id: Prints real and effective user and group IDs.
  8. who / w: Displays who is currently logged into the server and what they are doing.
  9. last: Displays a log of recently logged-in users and reboots.
  10. sudo: Executes commands with elevated root privileges.

3. Networking & Connectivity

Diagnosing connectivity bottlenecks and verifying service listeners.

  1. ss: Modern socket statistics tool replacing netstat.
    ss -tulpn
    
  2. ip: Manages network interfaces, routing tables, and IP assignments.
    ip addr show
    
  3. ping: Sends ICMP ECHO_REQUEST packets to network hosts.
  4. traceroute / tracepath: Traces the hop-by-hop packet path to a remote host.
  5. dig: DNS lookup utility for querying DNS name servers.
    dig +short A rivincloud.in
    
  6. nslookup: Queries Internet domain name servers interactively.
  7. curl: Transfers data with URLs (HTTP, HTTPS, FTP).
    curl -I https://rivincloud.in
    
  8. wget: Non-interactive network downloader.
  9. mtr: Combines the functionality of traceroute and ping into a live diagnostic tool.
  10. tcpdump: Powerful command-line packet analyzer.

4. Service & Process Management

  1. systemctl: Central systemd utility for controlling services.
    sudo systemctl status nginx
    
  2. journalctl: Queries and queries systemd service logs.
    journalctl -u nginx.service -n 50 --no-pager
    
  3. ps: Reports a snapshot of the current active processes.
    ps aux --sort=-%cpu | head -n 10
    
  4. kill: Sends signals to terminate processes by PID.
    kill -15 1234
    
  5. killall: Kills processes by executable name.
  6. pkill: Signals processes based on name matching.
  7. pgrep: Finds or signals processes by name.
  8. nohup: Runs a command immune to hangups.
  9. nice: Launches a program with a modified scheduling priority.
  10. renice: Alters the scheduling priority of running processes.

5. File Operations & Archival

  1. tar: Creates and extracts archive files.
    tar -czvf backup.tar.gz /var/www/
    
  2. rsync: Fast, versatile remote and local file-copying tool.
    rsync -avz /local/dir user@remote:/remote/dir
    
  3. scp: Copies files securely over SSH.
  4. find: Searches for files in a directory hierarchy.
    find /var/log -type f -name "*.log" -mtime +30
    
  5. grep: Searches plain-text datasets for lines that match a regular expression.
    grep -rn "error" /var/log/nginx/
    
  6. sed: Stream editor for filtering and transforming text.
  7. awk: Pattern scanning and processing language.
  8. tail: Outputs the last part of files; ideal for live logs (tail -f).
  9. head: Outputs the first part of files.
  10. 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 sudo to prevent accidental destructive operations.
  • Forgetting -h (human-readable) flag: Commands like free, df, and ls -l default to raw byte blocks without human-friendly conversion.
  • Using kill -9 prematurely: Always attempt kill -15 (SIGTERM) first so programs can flush caches and close open sockets gracefully.

Troubleshooting

If a command fails or hangs:

  1. Verify permissions: Run with sudo if the operation accesses /etc or hardware stats.
  2. Check standard error: Append 2>&1 or examine logs in /var/log/syslog.
  3. Check path environment: Ensure the binary directory exists in $PATH (which <command>).

Best Practices

[!TIP] Create aliases in your ~/.bashrc file for complex diagnostic commands like ps aux --sort=-%mem | head -n 10 (e.g., alias topmem='ps aux --sort=-%mem | head -n 10').

  • Always use journalctl -xe immediately after a systemctl unit 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!