LINUX CHEAT SHEET

Essential Linux Commands & Operations
v1.0
File Operations
  • ls -laList all files detailed
  • cp src destCopy file
  • mv src destMove/rename file
  • rm fileRemove file
  • rm -rf dirRemove dir recursive
  • touch fileCreate empty file
  • cat fileDisplay file contents
Directory Operations
  • pwdPrint working directory
  • cd dirChange directory
  • cd ..Go up one level
  • cd ~Go to home
  • cd -Previous directory
  • mkdir dirCreate directory
  • mkdir -p a/b/cCreate nested dirs
Permissions
  • chmod 755 filerwxr-xr-x
  • chmod 644 filerw-r--r--
  • chmod +x fileAdd execute
  • chown user fileChange owner
  • chown user:grp fileChange owner/group
  • chgrp group fileChange group
Process Management
  • ps auxList all processes
  • topInteractive process viewer
  • htopEnhanced top
  • kill PIDKill process by ID
  • kill -9 PIDForce kill
  • pkill nameKill by name
  • bg / fgBackground/foreground
Network
  • ip addrShow IP addresses
  • ifconfigNetwork interfaces
  • ping hostPing host
  • curl urlFetch URL
  • wget urlDownload file
  • netstat -tulpnList ports
  • ss -tulpnSocket stats
Disk & Storage
  • df -hDisk space usage
  • du -sh dirDirectory size
  • du -sh *Size of each item
  • mountShow mounted filesystems
  • lsblkList block devices
  • fdisk -lList partitions
  • find . -name "*.txt"Find files by name
  • find . -type dFind directories
  • grep "text" fileSearch in file
  • grep -r "text" .Recursive search
  • grep -i "text"Case insensitive
  • which cmdLocate command
  • locate fileFind file fast
Archives & Compression
  • tar -cvf a.tar dirCreate tar
  • tar -xvf a.tarExtract tar
  • tar -czvf a.tar.gzCreate gzipped
  • tar -xzvf a.tar.gzExtract gzipped
  • zip -r a.zip dirCreate zip
  • unzip a.zipExtract zip
System Info
  • uname -aSystem info
  • hostnameHostname
  • uptimeSystem uptime
  • free -hMemory usage
  • lscpuCPU info
  • cat /etc/os-releaseOS version
Text Processing
  • head -n 10 fileFirst 10 lines
  • tail -n 10 fileLast 10 lines
  • tail -f fileFollow file
  • wc -l fileCount lines
  • sort fileSort lines
  • uniqUnique lines
  • cut -d: -f1Cut columns
User Management
  • whoamiCurrent user
  • idUser ID info
  • sudo cmdRun as root
  • su - userSwitch user
  • passwdChange password
  • useradd userAdd user
  • usermod -aG grp usrAdd to group
Package Management
Debian/Ubuntu (apt)
  • apt updateUpdate package list
  • apt upgradeUpgrade packages
  • apt install pkgInstall package
  • apt remove pkgRemove package
  • apt search pkgSearch packages
RHEL/Fedora (dnf/yum)
  • dnf check-updateCheck for updates
  • dnf upgradeUpgrade packages
  • dnf install pkgInstall package
  • dnf remove pkgRemove package
  • dnf search pkgSearch packages