← Back to Terminal Guide

Linux Commands Cheat Sheet

Complete reference for the most useful terminal commands

📄 File Operations

🏠 Create
mkdir nameCreate a directory
touch fileCreate empty file
cp file newCopy file
cp -r dir newdirCopy directory recursively
🔄 Move & Rename
mv file dir/Move file to directory
mv old newRename file/directory
mv -i file dir/Move with confirmation
🗑️ Delete (Careful!)
rm fileDelete file (no undo!)
rm -r dirDelete directory + contents
rm -i fileDelete with confirmation
rmdir empty-folderDelete an empty directory
👁️ View Files
cat fileDisplay entire file
less fileView with pagination (q to quit)
head fileShow first 10 lines
tail fileShow last 10 lines
tail -f fileWatch file in real-time
nano fileOpen a simple text editor
wc -l fileCount the lines in a file

📦 Installing Software

CommandWhat It Does
sudo apt updateRefresh the package list before installing things
sudo apt upgradeInstall available updates
sudo apt install packageInstall a program
sudo apt remove packageUninstall a program
sudo apt autoremoveClean up packages you no longer need
apt search packageSearch for a package by name
apt show packageSee details about a package

⚙️ System Commands

CommandWhat It Does
dateShow current date and time
calShow calendar
whoamiShow current username
uname -aShow system information
df -hShow disk space (human readable)
du -sh */Show directory sizes
free -hShow memory and swap usage
topLive view of running processes
htopInteractive process viewer
ps auxList running processes
uptimeShow how long the machine has been running
lsb_release -aShow Ubuntu version details
historyShow command history
man commandShow manual for command
command --helpQuick help for command

🌐 Networking

🔌 Connection Basics
ip aShow IP addresses and network interfaces
ping hostTest whether you can reach a host
curl urlFetch a web page or API response
wget urlDownload a file from the web
🖥️ Remote Access
ssh user@hostConnect to another machine
scp file user@host:/pathCopy a file to another machine
which programShow where a command lives
nslookup domainLook up a domain's IP address

🔐 File Permissions

Understanding ls -la Output

-rwxr-xr-- 1 user group 1234 Jan 15 10:30 script.sh

Position 1: File Type

  • - = Regular file
  • d = Directory
  • l = Link

Positions 2-10: Permissions

  • r = Read
  • w = Write
  • x = Execute
  • - = No permission

Permission Groups

  • 2-4: Owner
  • 5-7: Group
  • 8-10: Others
CommandDescription
chmod +x fileMake file executable
chmod 755 fileOwner: rwx, Group: r-x, Others: r-x
chmod 644 fileOwner: rw-, Group: r--, Others: r--
chown user fileChange file owner

⌨️ Keyboard Shortcuts & Handy Patterns

⌨️ Shortcuts
TabAuto-complete a command or filename
Ctrl + CStop the current command
Ctrl + LClear the screen
Ctrl + RSearch command history
↑ / ↓Scroll through previous commands
🔗 Pipes & Redirects
cmd | lessScroll through long output
cmd | grep wordFilter output for a word
cmd > fileSave output to a file
cmd >> fileAppend output to a file
cmd1 && cmd2Run the second command only if the first succeeds

Quick Reference Card

Navigation

  • pwd — Where am I?
  • ls — List files
  • cd dir — Change directory
  • cd .. — Go up
  • cd ~ — Home

Files

  • mkdir — Create folder
  • touch — Create file
  • cp — Copy
  • mv — Move/Rename
  • rm — Delete

View

  • cat — Show file
  • less — Page through
  • head — First 10 lines
  • tail — Last 10 lines
  • grep — Search

🎯 Need Help?

Stuck on a command? Not sure what to do next? The fastest way to get unstuck is to ask Claude. Just describe what you're trying to do or paste the error.

Example 1: Paste an error
"I got this error: [paste error message] What does it mean?"
Example 2: Screenshot
"This isn't working as expected [attach screenshot]"
Example 3: Plain language
"I need to find all files modified in the last 24 hours"

No shame in asking. Claude can see your screen, understand context, and give you the exact command you need.