July 12, 2025

Essential Ubuntu Commands for Server Maintenance

Maintaining a Ubuntu server efficiently requires some familiarity with key terminal commands. Whether you’re monitoring disk usage, checking CPU load, viewing RAM stats, or analyzing server traffic, Ubuntu provides robust built-in tools for system admins and DevOps engineers.

Here’s a handy list of essential Ubuntu commands to help you keep your server healthy and responsive.

πŸ”Ή1. Quick overview (recommended)

Open Terminal and run:

neofetch

If it’s not installed:

sudo apt install neofetch
neofetch

This displays OS, kernel, CPU, RAM, GPU, and more in a single view.

πŸ“ 1.1 Check Disk Usage

Command:

df -h
  • -h stands for human-readable.
  • Shows how much space is used and available on all mounted filesystems.

Alternative (Detailed per directory):

du -sh /var/*

  • Summarizes disk usage of directories β€” useful for spotting logs or uploads consuming space.

🧠 2. Monitor RAM Usage

Command:

free -h
  • Shows total, used, and free memory (RAM and swap).
  • -h for human-readable format.

Better tool:

htop
  • Requires installation (sudo apt install htop)
  • Real-time, interactive overview of memory, CPU, tasks, and processes.

πŸ”₯ 3. Check CPU Usage

Command:

top
  • Provides a real-time look at CPU load and processes.

Alternative:

mpstat -P ALL 1
  • Part of sysstat package (sudo apt install sysstat)
  • Shows per-core CPU usage.

πŸ“Š 4. Monitor Server Load

Command:

uptime

Output example:

16:34:20 up 5 days,  3:27,  2 users,  load average: 0.05, 0.10, 0.12

  • Load average shows CPU demand over 1, 5, and 15 minutes.

🌐 5. Monitor Network Traffic

Command:

iftop
  • Real-time traffic analysis between source and destination IPs.
  • Install with:
sudo apt install iftop
sudo iftop -i eth0

Basic alternative:

ip -s link

  • Shows RX/TX stats per network interface.

πŸ” 6. View System Logs

Command:

journalctl
  • View logs from systemd services.
  • Tail the latest logs:
journalctl -xe

For specific services:

journalctl -u nginx

πŸ“„ 7. Check Open Ports & Listening Services

Command:

ss -tuln
  • Displays all open TCP/UDP ports and their status.

πŸ” 8. Restart a Service

Command:

sudo systemctl restart nginx

Replace nginx with your service name (like mysql, pm2, php-fpm, etc.)

⏱️ 9. Reboot or Shutdown the Server

Reboot:

sudo reboot

Shutdown:

sudo shutdown now

🧰 10. Update Your System

Update package index:

sudo apt update

Upgrade installed packages:

sudo apt upgrade

Upgrade OS (with caution):

sudo do-release-upgrade

πŸ“€ 11. Upload files from local β†’ VPS

Upload a single file

scp /local/path/file.conf user@VPS_IP:/remote/path/

Example:

scp /Users/feroz/dev/cardiast/backup/sites-available/prismmyadmin.conf \
root@159.198.00.000:/etc/nginx/sites-available/

Upload a folder

scp -r /local/path/folder user@VPS_IP:/remote/path/

Example:

scp -r /Users/feroz/dev/cardiast/backup/sites-available \
root@159.198.00.000:/etc/nginx/

πŸ“₯ 12. Download files from VPS β†’ local

Download a single file

scp user@VPS_IP:/remote/path/file /local/path/

Example:

scp root@159.198.00.000:/etc/nginx/nginx.conf ~/Downloads/

Download a folder

scp -r user@VPS_IP:/remote/path/folder /local/path/

🌐 12.1 Download a File from a URL (Ubuntu Terminal)

You can download files directly from the internet using the terminal. The most commonly used tools are wget and curl.

⬇️ Download a File Using wget

wget It is simple and widely available on Ubuntu.

wget URL

Example:

wget https://example.com/prismadmin.conf

This downloads the file into the current directory.

πŸ“‚ Download and Save with a Custom File Name

wget -O new_filename URL

Example:

wget -O prismadmin.conf https://example.com/prismmyadmin.conf

πŸ“ Download a File to a Specific Folder

wget -P /path/to/folder URL

Example:

wget -P /etc/prismadmin https://example.com/prismadmin.conf

πŸ“ Download a File VPS to local

From your local machine:

scp -r user@VPS_IP:/path/to/remote/folder /path/to/local/destination

Example:

scp -r root@192.168.1.100:/var/www/myfolder ~/Downloads/

To download the folder into your current directory, just use . (dot) as the destination.

scp -r user@VPS_IP:/path/to/remote/folder .

Example

scp -r root@192.168.1.100:/var/www/myfolder .

This will create:

./myfolder

in whatever directory you are currently in.

πŸ” 13. Copy files from another server/VPS β†’ current VPS

Copy a single file

scp user@SOURCE_IP:/remote/file /destination/path/

Example:

scp root@198.199.00.000:/var/www/html/index.html /var/www/html/

Copy a folder

scp -r user@SOURCE_IP:/remote/folder /destination/path/

Example:

scp -r root@198.199.00.000:/etc/letsencrypt/live /etc/letsencrypt/

πŸ“‚ 14. Copy folder/files (same VPS)

Copy file

cp source_file destination_file

Copy folder

cp -r source_folder destination_folder

Example:

cp -r /etc/nginx/sites-available /etc/nginx/backup-sites

πŸ”€ 15. Move folder/files (same VPS)

Move file

mv source_file destination_path/

Move folder

mv source_folder destination_path/

Example:

mv /var/www/html/test /var/www/html/old-test

✏️ 16. Rename folder/files

Rename file

mv oldname.conf newname.conf

Rename folder

mv old_folder new_folder

Example:

mv prismmyadmin.conf prismadmin.conf

πŸ“ 17. Create Files and Folders Using Terminal (Ubuntu)

You can easily create new files and folders directly from the Ubuntu terminal using simple commands.

πŸ“„ Create a File

To create an empty file, use the touch command:

touch filename.txt

Example:

touch prismadmin.conf

This creates an empty file named prismadmin.conf in the current directory.

πŸ“‚ Create a Folder (Directory)

To create a new folder, use the mkdir command:

mkdir folder_name

Example:

mkdir prismadmin

This creates a folder named prismadmin.

πŸ“‚ Create Multiple Folders at Once

mkdir folder1 folder2 folder3

Example:

mkdir logs config backups

πŸ—‚οΈ Create Nested Folders

Use the -p option to create parent and child folders at the same time:

mkdir -p parent_folder/child_folder

Example:

mkdir -p prismadmin/config

πŸ“ Create a File Inside a Folder

touch folder_name/filename

Example:

touch prismadmin/config/prismadmin.conf

πŸ—‘οΈ 18. Delete folder/files

Delete file

rm filename

Delete folder

rm -r foldername

Force delete (⚠️ dangerous)

rm -rf foldername

πŸ“¦ 19. ZIP (Compress)

Zip a folder

zip -r archive_name.zip folder_name

Example:

zip -r sites-available.zip /etc/nginx/sites-available

Zip multiple files/folders

zip -r backup.zip file1.conf file2.conf folder1

Zip a single file

zip file.zip filename

Example:

zip nginx.conf.zip /etc/nginx/nginx.conf

Install zip (if missing)

sudo apt install zip -y

πŸ“‚ 20. UNZIP (Extract)

Unzip to the current directory

unzip archive_name.zip

Unzip to a specific directory

unzip archive_name.zip -d /destination/path/

Example:

unzip sites-available.zip -d /etc/nginx/

View zip contents (without extracting)

unzip -l archive_name.zip

Overwrite files without prompt

unzip -o archive_name.zip

Install unzip (if missing)

sudo apt install unzip -y

πŸ”’ Bonus: Monitor Logged-In Users & SSH Sessions

Check active users:

who

Monitor SSH logins:

last -a | grep 'ssh'

πŸ‘¨β€πŸ’» Final Thoughts

Keeping your Ubuntu server healthy doesn’t require magic β€” just the right commands and regular check-ins. Whether you’re managing a personal project or handling client deployments for Prism ICT, these tools help ensure your systems stay clean, fast, and under control.

πŸ’‘ Pro tip: Automate routine checks with shell scripts or cron jobs to get notified when your server hits critical usage levels.