How to Use This Cheat Sheet
Each table lists a command as you type it in an SSH session, and what it does. Commands that change the system need sudo unless you are root. man command opens the full manual. Where Debian and Ubuntu (apt) differ from AlmaLinux and Rocky Linux (dnf), the table says so.
Files and Folders
| Command | What it does |
|---|---|
pwd | Shows the current folder. |
ls -lah | Lists all files with sizes. |
cd /var/ | Changes folder. |
mkdir -p a/ | Creates folders and parents. |
cp -a src dst | Copies, keeping owners and times. |
mv old new | Moves or renames. |
rm file | Deletes a file. |
find /etc -name "*.conf" | Finds files by name. |
There is no trash on a server: rm deletes at once, and rm -r deletes a folder with everything in it. Check the path with ls first. To move files between your computer and the server, see how to use SCP.
Viewing and Searching Files
| Command | What it does |
|---|---|
cat file | Prints a file. |
less file | Pages through a file; q quits. |
head -n 20 file | Shows the first 20 lines. |
tail -f app.log | Follows a log as it grows. |
grep -i error app.log | Finds matching lines. |
grep -rn listen /etc/ | Searches a whole folder. |
wc -l file | Counts lines. |
To edit a file in the terminal, use nano or Vim; for Vim, see how to save and quit in Vim and how to search in Vim.
Permissions and Ownership
| Command | What it does |
|---|---|
ls -l | Shows owner, group, and mode. |
chmod 644 file | Owner writes, others read. |
chmod 755 dir | Owner writes, others read and enter. |
chmod +x run.sh | Makes a script executable. |
chown deploy:deploy file | Changes owner and group. |
chown -R deploy:deploy dir | Changes them for a whole tree. |
Do not fix a permission error by making files writable for every user. Find out which user the program runs as and give that user access.
Processes and Services
| Command | What it does |
|---|---|
ps aux | Lists all processes. |
top | Live CPU and memory view. |
pgrep -a nginx | Finds processes by name. |
kill PID | Asks a process to stop. |
systemctl status nginx | Shows a service's state. |
systemctl restart nginx | Restarts a service. |
systemctl enable nginx | Starts a service at boot. |
journalctl -u nginx | Shows a service's log. |
kill sends a polite stop signal so the program can clean up. Stop services with systemctl rather than kill, and use a forced kill only when a process ignores the normal one. Restarting the whole machine is covered in how to reboot a Linux server.
Network
| Command | What it does |
|---|---|
ip a | Shows addresses per interface. |
ip r | Shows the routing table. |
ss -tlnp | Lists listening TCP ports. |
ping -c 4 example.com | Tests reachability. |
curl -I https://example. | Fetches response headers. |
dig example.com | Looks up DNS records. |
dig comes from the bind9-dnsutils package on Debian and Ubuntu (apt install dnsutils also installs it) and from bind-utils on AlmaLinux and Rocky Linux. Moving SSH to another port is described in how to change the SSH port.
Packages
| Task | Debian, Ubuntu | AlmaLinux, Rocky |
|---|---|---|
| Refresh lists | apt update | dnf check- |
| Upgrade all | apt upgrade | dnf upgrade |
| Install | apt install nginx | dnf install nginx |
| Remove | apt remove nginx | dnf remove nginx |
| Search | apt search nginx | dnf search nginx |
| Is it installed? | dpkg -l nginx | rpm -q nginx |
Users and Groups
| Command | What it does |
|---|---|
whoami | Shows your user name. |
id deploy | Shows a user's groups. |
adduser deploy | Creates a user (Debian, Ubuntu). |
useradd -m -s /bin/ | Creates a user with a home folder and Bash. |
passwd deploy | Sets a password. |
usermod -aG sudo deploy | Grants sudo (Debian, Ubuntu). |
usermod -aG wheel deploy | Grants sudo (AlmaLinux, Rocky). |
who | Lists logged-in users. |
Keep the -a in usermod -aG: without it, the user is removed from every group not named in the command.
Disks and Memory
| Command | What it does |
|---|---|
df -h | Free space per filesystem. |
du -sh /var/ | Size of a folder. |
lsblk | Disks and partitions. |
findmnt | Mounted filesystems as a tree. |
free -h | Memory and swap in use. |
uptime | Load averages and uptime. |
For cleanups, see how to check disk space in Linux.
Archives and Compression
| Command | What it does |
|---|---|
tar -czf site.tar.gz site | Packs and compresses a folder. |
tar -xzf site.tar.gz | Unpacks into the current folder. |
tar -tzf site.tar.gz | Lists contents only. |
gzip file | Compresses one file. |
zip -r site.zip site | Creates a zip archive. |
unzip site.zip | Extracts a zip archive. |
zip and unzip may need to be installed first. An archive on the same disk is not a backup; see snapshot vs backup. To save typing, put the commands you use most in aliases, as shown in what .bashrc is and how to edit it.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations