Linux Command-Line Quick Reference

Command ↕ Description ↕ Example ↕
aliasCreate shortcut names for long commandsalias ll='ls -l'
aptDebian/Ubuntu package managersudo apt update && sudo apt upgrade
awkPattern scanning and processing languageawk '{print $1}' file
catConcatenate/display file contentcat /etc/passwd
cdChange directorycd /var/log
chmodChange file permissionschmod 755 script.sh
chownChange file owner/groupchown user:group file
cpCopy files/directoriescp -r src/ dest/
cronSchedule periodic jobscrontab -e
curlTransfer data from/to URLscurl -O https://example.com/file
cutRemove sections from linescut -d: -f1 /etc/passwd
dfShow disk usagedf -h
diffCompare files line-by-linediff file1 file2
duShow directory space usagedu -sh *
echoDisplay text/variablesecho "Hello $USER"
exportSet environment variablesexport PATH=$PATH:/opt/bin
findSearch for files/directoriesfind /var -name "*.log"
freeShow memory usagefree -m
grepSearch text patternsgrep -i error /var/log/syslog
gzipCompress filesgzip large.txt
headShow first lines of a filehead -n 20 file
historyList command historyhistory | grep docker
htopInteractive process viewerhtop
idShow user/group IDsid
ifconfigConfigure network interfaces (deprecated)ifconfig eth0
ipModern network configurationip addr show
jobsList active jobsjobs -l
killTerminate processeskill -9 PID
lessView file page-by-pageless /var/log/syslog
lnCreate linksln -s /path/to/file linkname
lsList directory contentsls -al
lsofList open fileslsof -i :80
manShow manual pagesman tar
mkdirCreate directoriesmkdir -p /tmp/backup/$(date +%F)
moreView file (basic pager)more README
mountMount filesystemsmount /dev/sdb1 /mnt
mvMove/rename filesmv old new
netstatShow network connectionsnetstat -tulpn
niceRun program with modified prioritynice -n 19 ./longtask
nohupKeep command running after logoutnohup ./script &
passwdChange user passwordpasswd
pgrepFind process IDs by namepgrep -f nginx
pingTest network reachabilityping 8.8.8.8
psShow running processesps aux
pwdShow current directorypwd
rmRemove files/directoriesrm -rf node_modules
rmdirRemove empty directoriesrmdir olddir
rsyncFast file copying/synchronizationrsync -avz local/ remote:/backup/
scpSecure copy over SSHscp file user@host:/path
sedStream editorsed 's/foo/bar/g' file
serviceManage system servicessudo service apache2 restart
shredSecurely delete filesshred -vz -n 3 file
shutdownShutdown or reboot systemsudo shutdown -h now
sleepDelay executionsleep 30 && echo "Done"
sortSort lines of textsort -k2 -n file
sshSecure shell remote loginssh user@host
statShow file statusstat /etc/hosts
suSwitch usersu - username
sudoExecute command as superusersudo apt install git
tailShow last lines of a filetail -f /var/log/nginx/access.log
tarArchive/extract filestar czf backup.tar.gz folder/
teeWrite stdout to file and screenecho "test" | tee file
topDynamic process viewertop
touchCreate empty file/update timestamptouch newfile
trTranslate/delete charactersecho "abc" | tr 'a-z' 'A-Z'
umaskSet default file permissionsumask 022
unaliasRemove aliasesunalias ll
unameShow system informationuname -a
uniqRemove duplicate linessort file | uniq
unzipExtract ZIP archivesunzip archive.zip
uptimeShow system uptimeuptime
useraddCreate new usersudo useradd -m alice
usermodModify user accountsudo usermod -aG sudo alice
vi/vimText editorvim file
wShow logged-in users and activityw
wcCount lines/words/byteswc -l file
wgetDownload files from webwget https://example.com/file
whichShow full path of commandwhich python3
whoShow logged-in userswho
whoamiShow current userwhoami
xargsBuild and execute commands from stdinfind . -name "*.bak" | xargs rm
yum/dnfRHEL/CentOS package managersudo dnf install nginx
zipCreate ZIP archiveszip -r archive.zip folder/