Skip to content
AI Stack Nest
2 min read · updated 18 Nov 2026

Linux Terminal Basics Cheat Sheet

Essential Linux command-line commands for navigation, file management, permissions, and searching

CommandWhat it does
pwdPrints the current working directory
lsLists files in the current directory
ls -lLong listing with permissions and sizes
ls -aIncludes hidden files (starting with .)
ls -lhLong 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

CommandWhat it does
mkdir <name>Creates a directory
mkdir -p a/b/cCreates 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

CommandWhat 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

CommandWhat 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 fFinds only files (not directories)

Permissions

CommandWhat 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

CommandWhat it does
ps auxLists all running processes
topLive 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

SyntaxWhat it does
command > fileRedirects output to a file (overwrites)
command >> fileAppends output to a file
command < fileUses file as input
cmd1 | cmd2Pipes 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 -l

Other Useful Commands

CommandWhat it does
echo "text"Prints text to the terminal
whoamiPrints your current username
man <command>Opens the manual page for a command
historyLists recent commands
clearClears 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.