Quick Reference
Your command-line cheatsheet. Bookmark this page for quick lookup.
⌨️ Keyboard Shortcuts
Ctrl + CInterrupt/cancel current command
Ctrl + ZSuspend current process
Ctrl + DExit shell / EOF
Ctrl + LClear screen
Ctrl + RReverse search history
Ctrl + AMove cursor to line start
Ctrl + EMove cursor to line end
Ctrl + UClear line before cursor
Ctrl + KClear line after cursor
TabAuto-complete
!!Repeat last command
!$Last argument of previous command
File Operations
ls -laList all files with detailsls -lhList with human-readable sizescd -Go to previous directorymkdir -p dir/sub/dirCreate nested directoriescp -r src/ dest/Copy directory recursivelymv old newRename or move filerm -rf dir/Remove directory forcefullyln -s target linkCreate symbolic linkText Processing
grep -r "pattern" .Search recursively in current dirgrep -i "text" fileCase-insensitive searchsed 's/old/new/g' fileReplace all occurrencessed -i "" 's/a/b/g' fileIn-place edit (macOS)awk '{print $1}' filePrint first columnawk -F: '{print $1}' /etc/passwdCustom delimitersort -u fileSort and remove duplicateswc -l fileCount linesFile Permissions
chmod 755 filerwxr-xr-x (executable)chmod 644 filerw-r--r-- (readable)chmod +x script.shAdd execute permissionchmod -R 755 dir/Recursive permission changechown user:group fileChange owner and groupchown -R user dir/Recursive ownership changeArchives & Compression
tar -czf archive.tar.gz dir/Create tar.gz archivetar -xzf archive.tar.gzExtract tar.gz archivetar -tvf archive.tar.gzList archive contentszip -r archive.zip dir/Create zip archiveunzip archive.zipExtract zip archivegzip fileCompress file (replaces original)gunzip file.gzDecompress gzip fileProcess Management
ps auxList all running processesps aux | grep nodeFind specific processtop -o cpuSort by CPU usagekill -9 PIDForce kill processkillall processnameKill all by namenohup cmd &Run in background (survives logout)jobsList background jobsfg %1Bring job 1 to foregroundNetworking
curl -I urlFetch headers onlycurl -o file urlDownload to filecurl -X POST -d "data" urlPOST requestwget -c urlDownload with resumessh user@hostSSH connectionscp file user@host:pathSecure copy to remoteping -c 5 hostPing 5 timesnetstat -tulnShow listening portsSystem Information
df -hDisk usage (human-readable)du -sh dir/Directory sizedu -h --max-depth=1Size of subdirectoriesfree -hMemory usageuname -aSystem informationuptimeSystem uptime and loadwhoamiCurrent usernamehostnameMachine hostnameGit Essentials
git statusCheck working tree statusgit diffShow unstaged changesgit log --oneline -10Last 10 commits, compactgit branch -aList all branchesgit checkout -b branchCreate and switch branchgit stashStash changesgit stash popApply stashed changesgit reset --hard HEAD~1Undo last commit📄 Need a Printable Version?
Use your browser's print function (Ctrl/Cmd + P) to save this as a PDF.
Press Ctrl+P (Windows) or Cmd+P (Mac)