2 min read · updated 18 Nov 2026
Linux Terminal Basics Cheat Sheet
Essential Linux command-line commands for navigation, file management, permissions, and searching
Navigation
| Command | What it does |
|---|---|
pwd | Prints the current working directory |
ls | Lists files in the current directory |
ls -l | Long listing with permissions and sizes |
ls -a | Includes hidden files (starting with .) |
ls -lh | Long listing with human-readable sizes |
cd <dir> | Changes into a directory |
cd .. | Goes up one directory level |
cd ~ | Goes to your home directory |
cd - | Goes back to the previous directory |
File and Directory Operations
| Command | What it does |
|---|---|
mkdir <name> | Creates a directory |
mkdir -p a/b/c | Creates nested directories |
touch <file> | Creates an empty file (or updates timestamp) |
cp <src> <dest> | Copies a file |
cp -r <src> <dest> | Copies a directory recursively |
mv <src> <dest> | Moves or renames a file or directory |
rm <file> | Deletes a file |
rm -r <dir> | Deletes a directory and its contents |
rmdir <dir> | Deletes an empty directory |
Viewing File Contents
| Command | What it does |
|---|---|
cat <file> | Prints entire file to the terminal |
less <file> | Opens file for scrolling (q to quit) |
head <file> | Shows first 10 lines |
head -n 20 <file> | Shows first 20 lines |
tail <file> | Shows last 10 lines |
tail -f <file> | Follows a file as it grows (useful for logs) |
Searching
| Command | What it does |
|---|---|
grep "text" <file> | Finds lines containing text in a file |
grep -r "text" <dir> | Searches recursively in a directory |
grep -i "text" <file> | Case-insensitive search |
grep -n "text" <file> | Shows line numbers with matches |
find <dir> -name "*.txt" | Finds files by name pattern |
find <dir> -type f | Finds only files (not directories) |
Permissions
| Command | What it does |
|---|---|
chmod +x <file> | Makes a file executable |
chmod 644 <file> | Owner read/write, others read-only |
chmod 755 <file> | Owner full access, others read/execute |
chown user:group <file> | Changes file owner and group |
Permission digits: 4=read, 2=write, 1=execute. Add them together: 7=rwx, 6=rw, 5=rx.
Processes
| Command | What it does |
|---|---|
ps aux | Lists all running processes |
top | Live view of processes (q to quit) |
kill <pid> | Sends SIGTERM to a process |
kill -9 <pid> | Force-kills a process |
<command> & | Runs command in the background |
Redirection and Pipes
| Syntax | What it does |
|---|---|
command > file | Redirects output to a file (overwrites) |
command >> file | Appends output to a file |
command < file | Uses file as input |
cmd1 | cmd2 | Pipes output of cmd1 into cmd2 |
# Count lines containing "error" in a log file
grep "error" app.log | wc -l
# Find all .py files and show their line counts
find . -name "*.py" | xargs wc -lOther Useful Commands
| Command | What it does |
|---|---|
echo "text" | Prints text to the terminal |
whoami | Prints your current username |
man <command> | Opens the manual page for a command |
history | Lists recent commands |
clear | Clears the terminal screen |
which <command> | Shows the path of a command |
More cheat sheets
Not sure your computer can run a model? Use the will-it-run checker.

