Skip to main content

Linux Commands Cheatsheet

By Dejan Panovski Updated on Download PDF

Quick reference for essential Linux commands

A comprehensive quick reference guide covering the most commonly used Linux commands. From file management and text processing to networking and system administration, this cheatsheet helps you find the right command fast. Click on any command to read the full tutorial.

File Listing

View directory contents and file details.

CommandDescription
lsList directory contents
ls -laList all with details
ls -lhHuman readable sizes
ls -RList recursively

Move between directories in the filesystem.

CommandDescription
cdChange directory
cd ..Go up one level
cd ~Go to home
cd -Go to previous dir
pwdPrint working directory
pushd/popdDirectory stack

Create & Delete

Create and remove files and directories.

CommandDescription
mkdirCreate directory
mkdir -p a/b/cCreate nested dirs
touchCreate empty file
rmRemove file
rm -rf dirRemove dir recursively
rmdir dirRemove empty dir

Copy & Move

Copy, move, and link files.

CommandDescription
cpCopy file
cp -r src destCopy directory
mvMove or rename
ln -sCreate symlink

File Viewing

Display and browse file contents.

CommandDescription
catDisplay contents
lessView with pagination
headFirst N lines
tailLast N lines
tail -f fileFollow changes

Find files by name, type, or date.

CommandDescription
findFind files by criteria
find . -name "*.txt"Find by name
find . -type dFind directories
locateQuick search (db)

Search for patterns inside files.

CommandDescription
grepSearch in file
grep -r "text" dirSearch recursively
grep -i "text"Case insensitive
grep -n "text"Show line numbers
grep -v "text"Invert match

File Info

Get information about files and commands.

CommandDescription
fileDetermine file type
statDisplay file status
typeShow command type
whichLocate a command
whereisLocate binary/source
basenameStrip directory path

Permissions

Manage file permissions and ownership.

CommandDescription
chmodChange permissions
chmod 755 fileSet rwxr-xr-x
chmod +x fileAdd execute
chownChange owner
chgrpChange group
chattrChange attributes
umaskSet default perms

User Info

Display information about users.

CommandDescription
whoamiCurrent username
idUser ID and groups
whoLogged in users
wWho + what they do
lastLogin history

User Management

Create, modify, and delete users.

CommandDescription
useraddCreate user
userdelDelete user
passwd userChange password
usermodModify user
suSwitch user
sudoRun as root

Group Management

Create and delete user groups.

CommandDescription
groupaddCreate group
groupdelDelete group

Process Viewing

Monitor running processes.

CommandDescription
psList processes
ps auxAll processes
topInteractive viewer
htopBetter viewer
pgrepFind by name
pidofFind PID by name
pstreeProcess tree

Process Control

Terminate and manage processes.

CommandDescription
killTerminate process
kill -9 PIDForce kill
pkillKill by name
killall nameKill all by name
timeoutRun with time limit

Background Jobs

Run and manage background processes.

CommandDescription
cmd &Run in background
bgBackground current
fgForeground current
jobsList jobs
nohupImmune to hangups
atSchedule command

Disk Usage

Check disk space and filesystem health.

CommandDescription
dfDisk space
duDirectory size
du -h --max-depth=1Subdir sizes
[free](/post/free-comma, “http”, “networking"nd-in-linux/)Memory usage
fdiskPartition table
fsckCheck filesystem

Network

Configure and test network connections.

CommandDescription
ip aShow IP addresses
ifconfigNetwork interfaces
pingTest connectivity
curlTransfer data
wgetDownload file
digDNS lookup

SSH & Transfer

Secure remote access and file transfer.

CommandDescription
sshSSH connection
ssh -p 22 user@hostCustom port
scpSecure copy
rsyncSync files
sftpSecure FTP
ftpFTP transfer

Network Tools

Advanced network diagnostics and scanning.

CommandDescription
ss -tulpnListening ports
netstat -tulpnListening ports
lsof -i :80What uses port 80
nmapNetwork scanner
ncNetcat utility
tcpdumpPacket capture

Archives

Create and extract compressed archives.

CommandDescription
tarArchive files
tar -czvf a.tar.gz dirCreate tar.gz
tar -xzvf a.tar.gzExtract tar.gz
gzipCompress file
gunzipDecompress file
zip -r a.zip dirCreate zip
unzip a.zipExtract zip

Text Processing

Transform and manipulate text data.

CommandDescription
sort fileSort lines
uniq fileRemove duplicates
wcCount lines/words
cutCut columns
trTranslate chars
pasteMerge lines

Sed & Awk

Stream editing and pattern processing.

CommandDescription
sed 's/old/new/g'Find & replace
sed -i 's/old/new/g'In-place replace
awkPattern processing
awk '{print $1}'Print 1st field
awk -F: '{print $1}'Custom delimiter

Pipes & Redirection

Connect commands and redirect output.

CommandDescription
teeRead and write
xargsBuild arguments
diffCompare files
cmd > fileRedirect output
cmd >> fileAppend output
cmd 2>&1Stderr to stdout

System Info

Display system and hardware information.

CommandDescription
uname -aSystem info
hostnameShow hostname
uptimeSystem uptime
dateCurrent date/time
dmesgKernel messages
historyCommand history

Timing & Scheduling

Schedule and time command execution.

CommandDescription
timeMeasure runtime
watchRun repeatedly
[sleep](/post/how-to-us, “http”, “networking"e-linux-sleep-command-to-pause-a-bash-script/)Delay execution
atSchedule once
crontab -eSchedule recurring

System Control

Manage system power and settings.

CommandDescription
shutdownShutdown system
rebootRestart system
sysctlKernel parameters
wallBroadcast message
exportSet env variable

Package Management

Install and manage software packages.

CommandDescription
aptDebian packages
apt install pkgInstall package
apt updateUpdate package list
rpmRPM packages
yum install pkgRHEL/CentOS install
dnf install pkgFedora install

Kernel Modules

Load and manage kernel modules.

CommandDescription
lsmodList modules
modprobeLoad module
rmmodRemove module

Bash Built-ins

Common shell built-in commands.

CommandDescription
echoPrint text
sourceExecute script
readRead input
printfFormat output
exitExit shell
waitWait for process

File Operations

Rename, delete, and edit files.

CommandDescription
renameBatch rename
unlinkRemove link
nanoText editor