$ linux-cheatsheet
$ cd 02-filesystem-and-commands

Linux Command
Cheat Sheet

Every standalone command from the Filesystem & Commands module, in one searchable page, what it does, how to type it, and a real example.

# Instructor: Abderrahmane Yahiaoui
Companion to: Introduction To Linux
62commands
11types
0scripting required
bash
you@machine:~$ whoami learner, day one you@machine:~$ cat cheatsheet.md # Linux Command Line 62 commands. 11 categories. 1 page. you@machine:~$
Looking for variables, loops, or conditionals? Those live in Module 03: Bash Scripting. Everything below is a standalone command you type straight at the prompt, no script file required.

Directory Commands

Moving around and managing folders in the filesystem.

6 commands
pwd
pwd
$pwd

Prints the full path of the folder you're currently in, the fastest way to answer "where am I?"

cd
cd path
$cd ~/Documents

Moves you into another folder. cd .. goes up one level, cd ~ or cd alone jumps home, cd - returns to where you just were.

ls
ls [options] [path]
$ls -la

Lists what's inside a folder. Add -l for a detailed view (permissions, size, date) and -a to reveal hidden files too.

mkdir
mkdir [options] name
$mkdir -p projects/2026

Creates a new folder. The -p flag also creates any missing parent folders along the way, in one go.

rmdir
rmdir name
$rmdir empty_folder

Deletes a folder, but only if it's completely empty. For a folder with files inside, use rm -r instead.

tree
tree [path]
$tree -L 2

Draws the folder structure as a visual branching tree instead of a flat list, the fastest way to see how everything connects.

File Commands

Creating, copying, moving, deleting, and reading individual files.

9 commands
touch
touch filename
$touch notes.txt

Creates a new, empty file instantly, or just refreshes its "last modified" timestamp if it already exists.

cp
cp [options] source destination
$cp -r project/ project-backup/

Copies a file to a new location. Add -r to copy an entire folder, including everything inside it.

mv
mv source destination
$mv draft.txt final.txt

Moves a file or folder to a new location, and it's also how you rename something, by "moving" it to a new name in the same place.

rm
rm [options] target
$rm -i old_notes.txt

Deletes a file permanently, there's no recycle bin. Add -r for folders, and -i to be asked "are you sure?" first.

ln
ln -s target link_name
$ln -s /opt/tool/run.sh run

Creates a symbolic link: a shortcut that points to another file or folder, without duplicating it.

cat
cat filename
$cat notes.txt

Prints an entire file straight to the screen in one shot. Best for short files you want to see all at once.

less
less filename
$less /var/log/syslog

Opens a long file for comfortable scrolling, one screen at a time. Use the arrow keys to move and q to quit.

head
head -n number filename
$head -n 10 access.log

Shows just the first lines of a file, 10 lines by default if you don't ask for a specific number.

tail
tail -n number filename / tail -f filename
$tail -f /var/log/auth.log

Shows the last lines of a file. The -f flag "follows" it live, printing new lines the instant they're written, great for watching a log in real time.

General Commands

The everyday, absolute-basics commands you'll reach for constantly.

8 commands
clear
clear
$clear

Wipes everything off the screen so you're looking at a fresh, empty prompt. Nothing is actually deleted.

echo
echo "text"
$echo "Hello, world!"

Prints text back to the screen. Useful for quick checks, confirming a value, or leaving a message before a command runs.

date
date
$date

Shows the current date and time according to the system clock.

exit
exit
$exit

Closes the current terminal window, or logs you out of a remote machine you connected to with SSH.

history
history
$history | tail -20

Lists the commands you've run recently, so you can reuse a long one or double-check what you did earlier.

man
man command
$man ls

Opens the full manual page for a command, including every option it supports. Press q to close it.

whoami
whoami
$whoami

Prints the username you're currently logged in as.

id
id [username]
$id

Shows your user ID, your group ID, and every group you belong to.

Text Processing Commands

Shaping raw text and logs into something useful.

6 commands
cut
cut -d"delimiter" -f field file
$cut -d',' -f2 users.csv

Pulls out one column from delimited text, like a single field from a CSV file.

sort
sort [options] file
$sort -nr scores.txt

Puts lines of text in order. -n sorts numerically instead of alphabetically, and -r reverses the result.

uniq
uniq file
$sort logins.txt | uniq -c

Collapses repeated, side-by-side lines into one. Almost always paired after sort, since it only catches duplicates that are next to each other.

wc
wc [options] file
$wc -l access.log

Counts things in a file: -l for lines, -w for words, -c for characters.

sed
sed 's/old/new/g' file
$sed 's/error/ERROR/g' log.txt

Finds and replaces text across a file, line by line, without ever opening an editor.

awk
awk '{print $column}' file
$awk '{print $1}' access.log

Pulls out specific columns ("fields") from structured text, like grabbing just the IP address from every line of a log.

Permission Commands

Who can read, write, or run a file, and who's allowed to act as who.

6 commands
chmod
chmod mode file
$chmod 755 scan.sh

Changes who can read, write, or run a file. Use numbers (755) or letters (u+x adds execute for the owner).

chown
chown user:group file
$sudo chown sara:sara report.txt

Changes which user and group own a file, useful after copying a file between accounts.

sudo
sudo command
$sudo apt update

Runs just that one command with administrator (root) privileges. It asks for your own password, not root's.

su
su [username]
$su -

Switches you to another user account, root by default, for the rest of the session, until you type exit.

passwd
passwd [username]
$passwd

Changes the password for your own account, or another account if you're running it as root.

adduser
sudo adduser username
$sudo adduser trainee

Creates a brand-new user account, walking you through setting a password and basic details.

Reading -rwxr-x---

r
owner read
w
owner write
x
owner exec
r
group read
-
group write
x
group exec
-
other read
-
other write
-
other exec
Security angle: world-writable files and overly permissive scripts are one of the most common findings in a real pentest. Grant the least access that still works.

Process Commands

Seeing what's running, and stopping or backgrounding it.

4 commands
ps
ps aux
$ps aux | grep nginx

Takes a snapshot of every process currently running on the machine, with its process ID (PID), owner, and resource usage.

top
top
$top

Opens a live, constantly refreshing view of CPU and memory usage per process. htop is a friendlier, color alternative if it's installed. Press q to quit.

kill
kill PID
$kill -9 4821

Stops a running process using its ID number. Plain kill asks it nicely to stop; -9 forces it to stop immediately.

jobs / fg / bg
jobs / fg %job / bg %job
$jobs

Manage commands running in the background (started by adding & after them). jobs lists them, fg brings one back to the foreground, bg resumes a paused one.

System Commands

Checking what you're working with: hardware, disk, and memory.

6 commands
uname
uname -a
$uname -a

Prints kernel version and system architecture details, useful for confirming exactly what you're running.

df
df -h
$df -h

Shows how much disk space is used and free on each mounted filesystem, in easy-to-read sizes like GB and MB.

du
du -sh path
$du -sh /var/log

Shows how much disk space one specific file or folder is taking up.

free
free -h
$free -h

Shows how much RAM and swap memory is currently used versus available.

hostname
hostname
$hostname

Prints the name of the machine you're currently logged into.

uptime
uptime
$uptime -p

Shows how long the system has been running since it was last rebooted.

Package Commands

Installing, updating, and removing software on Debian-based systems.

4 commands
apt update
sudo apt update
$sudo apt update

Refreshes the local list of available packages and their latest versions. Always run this first, before installing anything.

apt upgrade
sudo apt upgrade
$sudo apt upgrade

Installs newer versions of any packages that already have an update waiting.

apt install
sudo apt install package
$sudo apt install nmap

Installs a new tool or program by name, downloading everything it needs.

apt remove
sudo apt remove package
$sudo apt remove nmap

Uninstalls a package. On other distros, the equivalents are dnf/yum (Fedora, RHEL) and pacman (Arch).

Network Commands

Checking connectivity and moving data to and from other machines.

6 commands
ip a
ip a
$ip a

Lists every network interface on the machine and the IP address assigned to each one.

ping
ping host
$ping 8.8.8.8

Checks whether another machine is reachable by sending it small test packets and timing the replies. Stop it with Ctrl+C.

curl / wget
curl url
$curl -O https://example.com/file.txt

Downloads or fetches a web resource straight from the terminal, no browser needed.

ssh
ssh user@host
$ssh sara@10.0.0.5

Opens a secure remote login session on another machine over the network.

scp
scp file user@host:path
$scp report.txt sara@10.0.0.5:~/

Copies files to or from a remote machine, using the same secure connection as SSH.

ss
ss -tuln
$ss -tuln

Lists which network ports are currently open and listening on your machine.

Archive Commands

Bundling files together, and verifying they weren't tampered with.

3 commands
tar
tar -czvf out.tar.gz folder/
$tar -xzvf backup.tar.gz

Bundles a folder into a single archive (-c create, -x extract, -z gzip compression, -v show progress, -f filename).

zip / unzip
unzip file.zip
$unzip tools.zip

Extracts (or, with zip -r, creates) a .zip archive, the same format most operating systems use natively.

sha256sum
sha256sum file
$sha256sum ubuntu.iso

Generates a unique fingerprint for a file, so you can confirm a download hasn't been altered or corrupted in transit.

Shell Operators: not commands, just punctuation

You'll type these constantly, but they aren't programs, you can't man them or find them on disk. They're symbols the shell itself understands, so they're kept separate from the searchable command list above.

& command &, runs a command in the background, freeing up your prompt.
> command > file, sends output into a file, overwriting anything already there.
>> command >> file, appends output to the end of a file instead of overwriting it.
< command < file, feeds a file in as input, instead of typing it by hand.
| cmd1 | cmd2, sends one command's output straight into the next as its input.

No commands match your search. Try a different word, like copy, permissions, or network.