Linux Commands Cheatsheet
Common Linux commands cheatsheet, categorized browsing by scenario.
File Operations 14
ls -laList all files (hidden)cd <dir>Change directorypwdShow current pathcp -r <src> <dest>Recursively replicate directoriesmv <src> <dest>Move/Rename Filesrm -rf <dir>Force recursive deletion of directoriesmkdir -p <path>Recursively create directoriestouch <file>Create an empty fileln -s <target> <link>Create softlinkfind <dir> -name "<pattern>"Find files by namelocate <pattern>Quickly locate file pathstree -L 2Tree Display Catalog Structuredu -sh <dir>View Catalog Sizedf -hView Disk UsageText Processing 12
cat <file>View File Contentshead -n 20 <file>View first 20 rowstail -f <file>Real-Time Tracking End of Filegrep -rn "<pattern>" <dir>Recursive Search Textsed -i "s/old/new/g" <file>Replace text in placeawk '{print $1}' <file>Extract first columnsort -u <file>Sort and Deduplicateuniq -c <file>Statistical duplicate rowswc -l <file>Number of statistical rowsdiff <f1> <f2>Compare file differencescut -d"," -f1 <file>Extract columns by separatortr "a-z" "A-Z" < <file>Toggle caseProcess Management 9
ps auxView all processestopReal-time process monitoringhtopEnhanced Process Monitoringkill -9 <pid>Force termination processkillall <name>Terminate process by namebg / fgBackend/Frontend Switchingnohup <cmd> &The background does not hang uplsof -i :<port>View Port Occupancy Processnice -n 10 <cmd>Renice ProcessNetwork Tools 11
ping <host>Test network connectivitycurl -O <url>Download filewget <url>Download filessh user@hostSSH Remote Loginscp <file> user@host:<path>Remote copy of filesnetstat -tlnpView Listening Portss -tlnpView Listening Ports (New Version)nslookup <domain>DNS querydig <domain>DNS Detail Queryifconfig / ip aView Network Interfacetraceroute <host>TraceroutePermission Management 6
chmod 755 <file>Modify file permissionschmod +x <file>Add Execution Permissionchown user:group <file>Modify Document Ownerumask 022Set Default Permission Masksudo <cmd>Execute as Adminsu - <user>Switch userPackage Management 6
apt install <pkg>Install package (Debian/Ubuntu)apt update && apt upgradeUpdate all packagesyum install <pkg>Installation Kit (CentOS/RHEL)dnf install <pkg>Install Package (Fedora)pacman -S <pkg>Install Package (Arch)brew install <pkg>Install package (macOS)Compression/Decompression 8
tar -czf <a>.tar.gz <dir>Compress to tar.gztar -xzf <a>.tar.gzUnzip tar.gztar -cjf <a>.tar.bz2 <dir>Compressed to tar.bz2tar -xjf <a>.tar.bz2Unzip tar.bz2zip -r <a>.zip <dir>Archive Zipunzip <a>.zipUnzip zipgzip <file>Compress to gzgunzip <file>.gzUnzip gzSystem Info 8
uname -aView System InformationuptimeView Uptimefree -hView Memory Usagecat /proc/cpuinfoView CPU InformationlsblkView Block Devicesmount / umountMounting & & Unmountingsystemctl status <service>View service statusjournalctl -u <service>View Service Log