Linux Server Commands
Server Management

The 50 Most Used Commands for Linux Server Management

The 50 most used Linux commands for VDS and dedicated server management: files, users, permissions, processes, disks, networking and packages, with examples.

  • MerkezHost Technical Team
  • 7 min read
  • Level: Starter
  • Updated:

You've got your first VDS server and you're alone with a black terminal screen. Don't worry: most Linux server management is done with a few dozen commands. In this guide we cover the 50 commands most used in day-to-day server management, grouped by topic and with real examples.

How to use this guide

Bookmark this page. Most commands work the same on Ubuntu, Debian, AlmaLinux and Rocky Linux; where they differ, we've noted it. To see the details of any command, type man komut or komut --help (replacing "komut" with the command name).

Connecting to the server

ssh root@SUNUCU_IP              # 1. Connect to the server
ssh -p 2222 kullanici@SUNUCU_IP  # Connect on a different port
exit                             # 2. Close the session

For a secure connection, see our guide to SSH key login.

pwd                 # 3. Show the current directory
ls -lah             # 4. Detailed list including hidden files, with human-readable sizes
cd /var/www         # 5. Change to a directory
cd ..               # Go up one directory
cd ~                # Return to the home directory
tree -L 2           # 6. Show the directory tree (apt install tree)

File and folder operations

mkdir -p /var/www/site/public   # 7. Create a folder (including intermediate folders)
touch dosya.txt                 # 8. Create an empty file
cp dosya.txt yedek.txt          # 9. Copy
cp -r klasor/ klasor-yedek/     # Copy a folder
mv eski.txt yeni.txt            # 10. Move / rename
rm dosya.txt                    # 11. Delete a file
rm -r klasor/                   # Delete a folder with its contents
ln -s /hedef /kisayol           # 12. Create a symbolic link
rm -rf warning

rm -rf deletes files permanently, without asking for confirmation and without a recycle bin. Especially with paths containing variables (rm -rf $KLASOR/), you can delete the root directory if the variable is empty. Double-check the path before running it.

Viewing and editing file contents

cat dosya.txt          # 13. Print the entire contents
less /var/log/syslog   # 14. Read page by page (q to quit, / to search)
head -n 20 dosya.txt   # 15. First 20 lines
tail -n 50 dosya.txt   # 16. Last 50 lines
tail -f /var/log/nginx/error.log   # Follow a log live
nano dosya.txt         # 17. Simple text editor (Ctrl+O to save, Ctrl+X to exit)

Searching

grep "hata" dosya.log              # 18. Search for text in a file
grep -rn "DB_PASSWORD" /var/www    # Search a folder, with line numbers
find /var/www -name "*.php" -mtime -1   # 19. PHP files changed in the last 24 hours
find / -size +500M 2>/dev/null      # Files larger than 500 MB
which nginx                         # 20. Find a command's path

Users and permissions

whoami                        # 21. Which user am I?
adduser yonetici              # 22. Create a user (Ubuntu/Debian)
usermod -aG sudo yonetici     # 23. Add to a group (on AlmaLinux: wheel)
passwd yonetici               # 24. Change a password
sudo komut                    # 25. Run with administrator privileges
chmod 644 dosya.php           # 26. Set file permissions
chmod 755 klasor/
chown -R www-data:www-data /var/www/site   # 27. Change ownership
PermissionMeaningTypical use
644Owner reads/writes, others readWeb files
755Owner has full access, others read/executeFolders, scripts
600Only the owner reads/writesPassword and key files
Don't use 777

chmod 777 gives everyone write permission and leaves your site open to attacks. Solve permission problems with the correct ownership (chown) instead.

System information and resource usage

uname -a          # 28. Kernel and system information
cat /etc/os-release   # Distribution version
uptime            # 29. Uptime and load average
free -h           # 30. RAM usage
df -h             # 31. Disk usage
du -sh /var/www/* # 32. Folder sizes
nproc             # 33. Number of CPU cores
htop              # 34. Live process and resource monitoring (apt install htop)

Process management

ps aux | grep php        # 35. Filter running processes
kill 1234                # 36. Terminate a process (by PID)
kill -9 1234             # Force kill (last resort)
pkill -f "node app.js"   # Terminate by name
nohup komut &            # 37. Keep running even after the session closes
screen -S isim           # 38. Detachable terminal session (detach with Ctrl+A, D)
screen -r isim           # Reattach to the session

Service management (systemd)

systemctl status nginx       # 39. Service status
systemctl restart nginx      # 40. Restart
systemctl reload nginx       # Reload the configuration without dropping connections
systemctl enable --now nginx # Start at boot and run now
journalctl -u nginx -n 100   # 41. Last 100 log lines of the service
journalctl -f                # Follow all system logs live

Networking

ip a                         # 42. Show IP addresses
ss -tulpn                    # 43. Which service is listening on which port?
ping -c 4 google.com         # 44. Test connectivity
curl -I https://alanadiniz.com   # 45. Fetch HTTP headers
dig alanadiniz.com +short    # 46. Query DNS (apt install dnsutils)
wget https://ornek.com/dosya.zip # 47. Download a file

Package management

# Ubuntu / Debian
apt update && apt upgrade -y    # 48. Update the package list and upgrade
apt install nginx -y            # Install a package
apt remove nginx                # Remove a package

# AlmaLinux / Rocky Linux
dnf update -y
dnf install nginx -y

Archiving and file transfer

tar -czf yedek.tar.gz /var/www/site   # 49. Compress a folder
tar -xzf yedek.tar.gz -C /hedef       # Extract an archive
rsync -avz /var/www/ kullanici@YEDEK_IP:/backup/www/   # 50. Sync changed files
scp dosya.zip kullanici@SUNUCU_IP:/root/              # Copy a single file

To build an automatic backup system with these commands, see our Linux automatic backup guide.

Life-saving shortcuts

ShortcutFunction
TabAuto-complete command and file names
↑ / ↓Browse previous commands
Ctrl + RSearch the command history
Ctrl + CStop the running command
Ctrl + LClear the screen
!!Run the last command again (sudo !!)

Conclusion

These 50 commands cover most of the day-to-day management of a Linux server. The best way to learn through practice is to try them on your own server: you can get started right away by choosing Ubuntu or AlmaLinux on our NVMe SSD VDS servers. As a next step, we recommend our firewall setup guide.

Frequently Asked Questions

Do these commands work on all Linux distributions?

Almost all file, process and network commands are the same on every distribution. Package management differs: Ubuntu/Debian use apt, while AlmaLinux/Rocky use dnf.

How do I find out what a command does?

You can add --help after the command, or type man command-name to read its detailed manual.

Why is the rm -rf command dangerous?

It deletes files permanently, without asking for confirmation and without moving them to a recycle bin. If run in the wrong directory, you can lose all your data.

  • #linux commands
  • #ssh
  • #ubuntu
  • #terminal
  • #server management
Share:
Read More

Related Guides