Linux Commands Cheat Sheet for Server Admins

The Linux commands you use most on a web server or VPS, grouped by task: files, permissions, processes, services, disk, network, packages and archives.

These are the Linux commands you use most when looking after a web server or VPS, grouped by task. They work on Ubuntu, Debian, AlmaLinux and Rocky Linux unless a note says otherwise; we checked them on Ubuntu 24.04, Debian 13 and AlmaLinux 9. Commands that change the system need sudo or the root user.

Terminal showing uname, df, free, ss and ps commands on an AlmaLinux 9 server
A few commands from this cheat sheet, run on an AlmaLinux 9 VPS.

Moving around

pwd                      # where am I?
ls -la                   # list files, including hidden ones, with details
cd /var/www              # go to a folder
cd ..                    # one level up
cd ~                     # home folder
cd -                     # previous folder

Files and folders

mkdir -p backups/2026    # create folders (and parents)
cp -r site site-copy     # copy a folder
mv old.txt new.txt       # rename or move
rm file.txt              # delete a file
rm -r old-folder         # delete a folder and its contents
ln -s /var/www/app current   # symbolic link
touch file.txt           # create an empty file or update its time

Guides: rename files, remove folders, links.

Viewing and editing files

cat file.txt             # print a short file
less /var/log/syslog     # scroll a long file (q quits)
head -20 file.txt        # first 20 lines
tail -f /var/log/nginx/error.log   # follow a log live
nano /etc/hosts          # simple editor (Ctrl+O save, Ctrl+X exit)

Searching

find /var/www -name "wp-config.php"   # files by name
find . -mtime -1                      # changed in the last day
grep -rn "DB_NAME" /var/www/html      # text inside files
which php                             # where a command lives

Permissions and ownership

chmod 644 file.php       # owner read/write, others read
chmod 755 script.sh      # owner can run it
chown -R www-data:www-data /var/www/site   # owner (apache on AlmaLinux)
ls -l                    # check permissions

Users and passwords

whoami                   # current user
sudo adduser alice       # Ubuntu, Debian (useradd -m alice on AlmaLinux)
sudo passwd alice        # set a password
getent passwd            # all accounts
id alice                 # user ID and groups

More: change a user password.

Processes and services

top                      # live CPU and memory (htop is friendlier)
ps aux --sort=-%mem | head   # biggest memory users
pgrep -a nginx           # find a process
kill 1234                # stop process 1234
sudo systemctl status nginx     # service status
sudo systemctl restart nginx    # restart a service
sudo systemctl enable nginx     # start at boot
journalctl -u nginx -n 50       # its recent log lines

More: list running processes.

Disk and memory

df -h                    # free space per disk
du -sh /var/www/*        # size of each folder
du -h --max-depth=1 / -x | sort -rh | head   # what fills the disk
free -h                  # memory and swap
uptime                   # load and time since boot

Network

ip -4 addr               # IP addresses
ss -ltnp                 # which programs listen on which ports
ping -c 4 example.com    # is it reachable?
curl -I https://example.com   # HTTP status and headers
dig +short example.com A      # DNS lookup
nc -zv example.com 443        # is a port open?

Packages

# Ubuntu, Debian
sudo apt update && sudo apt upgrade
sudo apt install nginx
apt list --installed

# AlmaLinux, Rocky Linux
sudo dnf upgrade
sudo dnf install nginx
dnf list installed

Archives and transfers

tar -czf site.tar.gz site/          # create
tar -xzf site.tar.gz -C /restore    # extract into a folder
zip -r site.zip site/ ; unzip site.zip -d /restore
scp -r site user@server:/var/www/   # copy over SSH
rsync -avz site/ user@server:/var/www/site/   # sync, only changes
wget -P /tmp https://example.com/file.tar.gz  # download

Scheduling and system

crontab -l               # your cron jobs
crontab -e               # edit them
systemctl list-timers    # systemd timers
cat /etc/os-release      # distribution and version
hostnamectl              # host name, OS and kernel
sudo reboot              # restart

More: list cron jobs and read crontab syntax.

Tips that save time

  • Press Tab to complete names, and the up arrow (or Ctrl+R) to find earlier commands.
  • Add --help to most commands, or read the manual with man command.
  • Before a risky change, copy the file: cp nginx.conf nginx.conf.bak.
  • Use tmux for long jobs, so they keep running if your SSH connection drops.

New to SSH? Start with how to connect to your server with PuTTY. Need a server to practise on? A KVM VPS gives you full root access from $10 a month, with Free Basic Managed Support included.

Ithal P R
Ithal P R

Hi, I'm Ithal! I write tech and hosting blogs at Ucartz.com, where I share insights, tips, and the latest updates from the world of web hosting and technology. Whether it's about server setups, control panels, or tools to power your online presence, I break things down in a way that's easy to understand, even if you're just starting out.