The Ultimate Linux Commands Cheat Sheet: 100+ Essential Commands for Beginners and Pros

Essential Linux Commands: A Comprehensive Guide

Table of Contents

  1. Introduction
  2. File Navigation
  3. File Operations
  4. System Information
  5. User Management
  6. File Permissions
  7. Process Management
  8. Network Commands
  9. Package Management
  10. Text Processing
  11. Advanced Commands
  12. Useful Shortcuts

Introduction

Linux commands are text-based instructions used to interact with your operating system. This guide covers the most essential commands that every Linux user should know, from basic navigation to advanced system administration.

File Navigation

CommandDescriptionExample
pwdPrint Working Directory – shows current directorypwd
lsList files and directoriesls -la (shows all files including hidden ones with details)
cdChange Directorycd /home/user/Documents
cd ..Move up one directorycd ..
cd ~Go to home directorycd ~
findSearch for filesfind /home -name "*.txt"
locateFind files by name (requires updatedb)locate filename
whichShow the full path of shell commandswhich python

File Operations

CommandDescriptionExample
cpCopy files or directoriescp file.txt /home/user/Documents
mvMove or rename files or directoriesmv file.txt newname.txt
rmRemove files or directoriesrm file.txt or rm -r directory
mkdirCreate a new directorymkdir new_directory
rmdirRemove an empty directoryrmdir empty_directory
touchCreate an empty file or update timestamptouch newfile.txt
duDisk usage – show file/directory sizedu -h file.txt (human-readable format)
dfDisplay free disk spacedf -h (human-readable format)
tarArchive filestar -cvf archive.tar files/
zip/unzipCompress/decompress fileszip archive.zip files/

System Information

CommandDescriptionExample
unameDisplay system informationuname -a (all information)
cat /etc/os-releaseShow OS informationcat /etc/os-release
lsb_releaseDisplay distribution-specific informationlsb_release -a
uptimeShow how long the system has been runninguptime
freeDisplay memory usagefree -h (human-readable)
lscpuDisplay CPU informationlscpu
lsblkList block deviceslsblk
dmesgPrint kernel messagesdmesg | less
lshwList hardwaresudo lshw

User Management

CommandDescriptionExample
whoamiDisplay current userwhoami
idDisplay user identityid
useraddCreate a new usersudo useradd username
usermodModify user accountsudo usermod -aG group username
userdelDelete a usersudo userdel username
passwdChange passwordpasswd or sudo passwd username
suSwitch usersu - username
sudoExecute command as another user (typically root)sudo command
whoShow who is logged onwho

File Permissions

CommandDescriptionExample
chmodChange file permissionschmod 755 file.txt or chmod u+x file.sh
chownChange file ownersudo chown user:group file.txt
chgrpChange group ownershipsudo chgrp group file.txt
umaskSet default permissionsumask 022

Permission values:

  • 4: read (r)
  • 2: write (w)
  • 1: execute (x)

Common permission combinations:

  • 755: rwxr-xr-x (owner can read/write/execute, others can read/execute)
  • 644: rw-r–r– (owner can read/write, others can read)
  • 700: rwx—— (owner can read/write/execute, others have no permissions)

Process Management

CommandDescriptionExample
psDisplay running processesps aux
topDynamic real-time view of processestop
htopInteractive process viewer (may need installation)htop
killTerminate a processkill PID or kill -9 PID (force kill)
pkillKill processes by namepkill process_name
killallKill all processes by namekillall process_name
niceRun a command with modified prioritynice -n 10 command
reniceAlter priority of running processrenice +10 -p PID
bgResume suspended jobs in backgroundbg
fgBring background process to foregroundfg
jobsList background jobsjobs
nohupRun command immune to hangupsnohup command &

Network Commands

CommandDescriptionExample
ifconfigConfigure network interface (deprecated in some distributions)ifconfig
ipShow/manipulate routing, devices, tunnelsip addr show
pingTest network connectivityping google.com
tracerouteDisplay route packets to network hosttraceroute google.com
netstatNetwork statisticsnetstat -tuln
ssSocket statistics (similar to netstat)ss -tuln
digDNS lookupdig google.com
nslookupQuery DNS recordsnslookup google.com
wgetDownload files from the webwget https://example.com/file.zip
curlTransfer data from/to a servercurl https://example.com
sshSecure shell remote loginssh user@hostname
scpSecurely copy files between hostsscp file.txt user@host:/path
rsyncRemote file synchronizationrsync -av source/ destination/

Package Management

Debian/Ubuntu (APT)

CommandDescriptionExample
apt updateUpdate package listssudo apt update
apt upgradeUpgrade installed packagessudo apt upgrade
apt installInstall a packagesudo apt install package_name
apt removeRemove a packagesudo apt remove package_name
apt searchSearch for a packageapt search keyword
apt listList packagesapt list --installed

Red Hat/Fedora (DNF/YUM)

CommandDescriptionExample
dnf check-updateCheck for updatessudo dnf check-update
dnf upgradeUpgrade installed packagessudo dnf upgrade
dnf installInstall a packagesudo dnf install package_name
dnf removeRemove a packagesudo dnf remove package_name
dnf searchSearch for a packagednf search keyword
dnf listList packagesdnf list installed

Arch Linux (Pacman)

CommandDescriptionExample
pacman -SySynchronize package databasessudo pacman -Sy
pacman -SyuUpdate systemsudo pacman -Syu
pacman -SInstall packagesudo pacman -S package_name
pacman -RRemove packagesudo pacman -R package_name
pacman -SsSearch for packagepacman -Ss keyword
pacman -QList installed packagespacman -Q

Text Processing

CommandDescriptionExample
catDisplay file contentscat file.txt
lessView file contents with paginationless file.txt
moreView file contents page by pagemore file.txt
headDisplay first lines of a filehead -n 10 file.txt
tailDisplay last lines of a filetail -n 10 file.txt or tail -f logfile (follow)
grepSearch text using patternsgrep "pattern" file.txt
sedStream editor for filtering and transforming textsed 's/old/new/g' file.txt
awkPattern scanning and processing languageawk '{print $1}' file.txt
sortSort lines of text filessort file.txt
uniqReport or omit repeated linesuniq file.txt
wcCount lines, words, and characterswc -l file.txt (line count)
cutRemove sections from each linecut -d ',' -f 1 file.csv (get first column)
diffCompare files line by linediff file1.txt file2.txt

Advanced Commands

CommandDescriptionExample
cronSchedule periodic taskscrontab -e (edit current user’s crontab)
atSchedule one-time tasksat 10:00 AM
systemctlControl the systemd system and service managersystemctl status service_name
journalctlQuery the systemd journaljournalctl -u service_name
ddConvert and copy a filedd if=/dev/zero of=file bs=1M count=10
lsofList open fileslsof -i :80 (show processes using port 80)
straceTrace system calls and signalsstrace command
aliasCreate command shortcutsalias ll='ls -la'
historyShow command historyhistory
screenTerminal multiplexerscreen
tmuxTerminal multiplexer (alternative to screen)tmux
xargsBuild and execute commands from standard inputfind . -name "*.txt" | xargs grep "pattern"
teeRead from stdin and write to stdout and filescommand | tee output.txt

Useful Shortcuts

ShortcutDescription
Ctrl+CInterrupt (kill) current process
Ctrl+ZSuspend current process
Ctrl+DExit shell or current session
Ctrl+LClear screen
Ctrl+AGo to beginning of line
Ctrl+EGo to end of line
Ctrl+UClear line before cursor
Ctrl+KClear line after cursor
Ctrl+WDelete word before cursor
Ctrl+RSearch command history
TabAuto-complete commands or filenames
↑/↓Navigate through command history

Conclusion

This guide covers the most essential Linux commands for everyday use. Remember that most commands have numerous options that can be discovered by reading their man pages (man command_name). Linux commands can be combined using pipes (|) and redirects (>, >>, <) to create powerful command chains.

For more detailed information about any command, use:

man command_name

or

command_name --help

As you become more familiar with these commands, your productivity and ability to manage Linux systems will greatly improve.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top