Linux Commands Cheat Sheet

Move around

CommandWhat it does
pwdShows the current folder
ls -laLists files with details, including hidden ones
cd <folder>Enters a folder
cd ..Goes up one level
cd ~Goes to your home folder

Files and folders

CommandWhat it does
mkdir <name>Creates a folder
touch <file>Creates an empty file
cp <from> <to>Copies a file (-r for folders)
mv <from> <to>Moves or renames
rm <file>Deletes a file permanently
rm -r <folder>Deletes a folder and its contents. Double-check the path
CommandWhat it does
cat <file>Prints a file
less <file>Scrolls through a file (press q to quit)
head -n 20 <file>Shows the first 20 lines
tail -f <file>Follows new lines as they are written
grep "text" <file>Finds lines that contain text
grep -r "text" .Searches every file in the folder
find . -name "*.png"Finds files by name

Permissions

CommandWhat it does
chmod 644 <file>Sets permissions by number
chmod +x <file>Makes a file executable
chown user:group <file>Changes the owner
sudo <command>Runs a command as an administrator

Processes and system

CommandWhat it does
ps auxLists running processes
topLive view of resource use
kill <pid>Asks a process to stop
df -hShows disk space
du -sh <folder>Shows a folder’s size

Network

CommandWhat it does
ping <host>Tests whether a host responds
curl <url>Fetches a URL
ssh user@hostOpens a remote shell

Pipes and redirects

ls -la | grep ".md"      # send one command's output into another
echo "hello" > out.txt   # write to a file (replaces it)
echo "more" >> out.txt   # append to a file

Press Tab to autocomplete and the up arrow to bring back earlier commands. Use man <command> to read the manual.

↑ ↓ navigateEnter openEsc close