Skip to content
Log In Sign Up info@muvcloud.com

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

CommandWhat it does
pwdShows the current folder.
ls -lahLists all files with sizes.
cd /var/wwwChanges folder.
mkdir -p a/bCreates folders and parents.
cp -a src dstCopies, keeping owners and times.
mv old newMoves or renames.
rm fileDeletes 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

CommandWhat it does
cat filePrints a file.
less filePages through a file; q quits.
head -n 20 fileShows the first 20 lines.
tail -f app.logFollows a log as it grows.
grep -i error app.logFinds matching lines.
grep -rn listen /etc/nginxSearches a whole folder.
wc -l fileCounts 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

CommandWhat it does
ls -lShows owner, group, and mode.
chmod 644 fileOwner writes, others read.
chmod 755 dirOwner writes, others read and enter.
chmod +x run.shMakes a script executable.
chown deploy:deploy fileChanges owner and group.
chown -R deploy:deploy dirChanges 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

CommandWhat it does
ps auxLists all processes.
topLive CPU and memory view.
pgrep -a nginxFinds processes by name.
kill PIDAsks a process to stop.
systemctl status nginxShows a service's state.
systemctl restart nginxRestarts a service.
systemctl enable nginxStarts a service at boot.
journalctl -u nginxShows 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

CommandWhat it does
ip aShows addresses per interface.
ip rShows the routing table.
ss -tlnpLists listening TCP ports.
ping -c 4 example.comTests reachability.
curl -I https://example.comFetches response headers.
dig example.comLooks 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

TaskDebian, UbuntuAlmaLinux, Rocky
Refresh listsapt updatednf check-update
Upgrade allapt upgradednf upgrade
Installapt install nginxdnf install nginx
Removeapt remove nginxdnf remove nginx
Searchapt search nginxdnf search nginx
Is it installed?dpkg -l nginxrpm -q nginx

Users and Groups

CommandWhat it does
whoamiShows your user name.
id deployShows a user's groups.
adduser deployCreates a user (Debian, Ubuntu).
useradd -m -s /bin/bash deployCreates a user with a home folder and Bash.
passwd deploySets a password.
usermod -aG sudo deployGrants sudo (Debian, Ubuntu).
usermod -aG wheel deployGrants sudo (AlmaLinux, Rocky).
whoLists 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

CommandWhat it does
df -hFree space per filesystem.
du -sh /var/logSize of a folder.
lsblkDisks and partitions.
findmntMounted filesystems as a tree.
free -hMemory and swap in use.
uptimeLoad averages and uptime.

For cleanups, see how to check disk space in Linux.

Archives and Compression

CommandWhat it does
tar -czf site.tar.gz sitePacks and compresses a folder.
tar -xzf site.tar.gzUnpacks into the current folder.
tar -tzf site.tar.gzLists contents only.
gzip fileCompresses one file.
zip -r site.zip siteCreates a zip archive.
unzip site.zipExtracts 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.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

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.

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