Skip to content

Linux Basics Cheatsheet

This guide covers the most common Linux commands and concepts for beginners. Perfect for self-hosting and server management!

CommandWhat it doesExample Output
pwdShow current directory/home/yourname
lsList files/foldersfile.txt folder/
ls -lLong listing (details)-rw-r--r-- 1 user ... file.txt
cd /path/to/dirChange directory(no output, just changes dir)
cd ~Go to home directory(no output, just changes dir)
cd ..Go up one directory(no output, just changes dir)

File Operations

CommandWhat it doesExample Output
touch file.txtCreate empty file(no output, creates file)
mkdir myfolderMake new directory(no output, creates folder)
cp file1.txt file2.txtCopy file(no output, copies file)
mv old.txt new.txtRename or move file(no output, renames/moves)
rm file.txtDelete file(no output, deletes file)
rm -r myfolderDelete folder/contents(no output, deletes folder)
cat file.txtShow file contentsHello world!
nano file.txtEdit file in nano(opens nano editor)

System Info & Management

CommandWhat it doesExample Output
whoamiShow your usernameyourname
uname -aShow system infoLinux host 5.15.0 ... x86_64
topShow running processes(interactive process list)
htopNicer process viewer(interactive process list)
df -hShow disk usage/dev/sda1 20G 5G 15G ...
free -hShow memory usageMem: 1.9G 1.2G 700M ...
uptimeShow system uptime10:00:00 up 2 days, ...

Package Management (Debian/Ubuntu)

CommandWhat it doesExample Output
sudo apt updateUpdate package listHit:1 http://...
sudo apt upgradeUpgrade installed packagesReading package lists...
sudo apt install packagenameInstall a packageSetting up packagename ...
sudo apt remove packagenameRemove a packageRemoving packagename ...

Permissions

CommandWhat it doesExample Output
ls -lShow file permissions-rwxr-xr-x 1 user ...
chmod +x script.shMake script executable(no output, sets permission)
sudoRun as admin/root(prompts for password)

Networking

CommandWhat it doesExample Output
ip aShow IP addressesinet 192.168.1.100/24 ...
ping 1.1.1.1Test network connection64 bytes from 1.1.1.1 ...
curl example.comFetch a web page<!doctype html>...
ssh user@hostConnect to another machineuser@host's password:

Tips

  • Use Tab to auto-complete commands and filenames.
  • Use the up/down arrows to scroll through command history.
  • man <command> shows the manual for a command (e.g., man ls).
  • Use Ctrl+C to stop a running command.
  • Use Ctrl+L to clear the terminal screen.

For more, check out The Linux Command Line Book (free) or your distro’s documentation.

Released under Creative Commons Zero v1.0 Universal License.