| |

Linux CLI 72 🐧 The Complete Cheatsheet

⏱️ Estimated read: 5 min | |

A reference sheet for every command, operator, and concept covered in the Linux CLI series, organized by category and cross-referenced by chapter number.


Filesystem Navigation

CommandPurposeChapter
pwdPrint working directory2
cd /pathChange directory2
cd ..Parent directory2
cd ~Home directory2
cd -Previous directory2
lsList directory contents3
ls -lLong format3
ls -aInclude hidden files3
ls -hHuman-readable sizes3
ls -RRecursive listing3
file nameIdentify file type3
less filePage through file3

File Operations

CommandPurposeChapter
mkdir dirCreate directory6
mkdir -p a/b/cCreate nested directories6
cp src dstCopy file6
cp -r src dstCopy recursively6
mv src dstMove or rename6
rm fileDelete file6
rm -r dirDelete directory recursively6
rm -fForce delete6
touch fileCreate empty file / update timestamp36
ln -s target linkSymbolic link4
ln target linkHard link4

Wildcards

PatternMatchesChapter
*Any string5
?Single character5
[abc]One of a, b, c5
[a-z]Range5
[!abc]Not a, b, c5

Help and Documentation

CommandPurposeChapter
type cmdShow command type7
which cmdLocate executable7
help builtinShell builtin help8
cmd --helpBrief usage8
man cmdManual page8
whatis cmdOne-line description9
apropos keywordSearch man pages9
info cmdGNU info page9

Aliases and Shortcuts

CommandPurposeChapter
alias name='cmd'Create alias10
unalias nameRemove alias10
Ctrl+CCancel current command15
Ctrl+ZSuspend current process15
Ctrl+DEOF / logout15
Ctrl+LClear screen15
Ctrl+ABeginning of line15
Ctrl+EEnd of line15
Ctrl+RReverse search history15
!!Last command16
!nCommand number n16
historyCommand history16

I/O Redirection and Pipes

OperatorPurposeChapter
>Redirect stdout (overwrite)11
>>Redirect stdout (append)11
<Redirect stdin11
2>Redirect stderr11
2>&1stderr to stdout11
|Pipe stdout to stdin12
tee fileWrite to file and stdout13

Text Processing

CommandPurposeChapter
cat fileDisplay file12
grep pattern fileSearch lines12
grep -iCase-insensitive12
grep -rRecursive12
grep -vInvert match12
wc fileCount lines, words, bytes12
uniqRemove adjacent duplicates13
sort fileSort lines42
sort -nNumeric sort42
sort -rReverse sort42
head -n NFirst N lines13
tail -n NLast N lines13
tail -fFollow file13
echo textPrint text14
echo -nNo trailing newline14
echo -eInterpret escapes14
cut -d: -f1Extract fields43
paste file1 file2Merge lines43
join file1 file2Join on common field43
comm file1 file2Compare sorted files44
diff file1 file2Show differences44
patch file < diffApply patch45
tr 'a-z' 'A-Z'Translate characters45
sed 's/old/new/g'Stream edit46
nl fileNumber lines48
fold -w NWrap lines48
fmt -w NReformat paragraphs48
pr filePaginate49
printf fmt argsFormatted output49

Permissions and Ownership

CommandPurposeChapter
idUser and group IDs18
chmod 755 fileSet permissions (octal)18
chmod u+x fileAdd execute (symbolic)18
chmod -RRecursive18
umaskDefault permission mask18
su - userSwitch user19
sudo cmdRun as root19
chgrp group fileChange group20
chown user:group fileChange owner and group20
passwdChange password20

Process Management

CommandPurposeChapter
ps auxList all processes21
ps -efList all processes (BSD)21
topLive process view21
kill PIDSend SIGTERM21
kill -9 PIDSend SIGKILL21
killall nameKill by name21
pkill patternKill by pattern21
cmd &Run in background22
jobsList background jobs22
fgBring job to foreground22
bgResume job in background22
rebootRestart system22
shutdown -h nowPower off22

Environment Variables

CommandPurposeChapter
printenvShow environment23
echo $VARPrint variable23
export VAR=valSet and export23
unset VARRemove variable23

Editors and Prompt

CommandPurposeChapter
nano fileOpen in nano24
PS1='...'Set primary prompt25
PS2='...'Set secondary prompt25

Storage and Mounting

CommandPurposeChapter
mount /dev/sdb1 /mntMount filesystem27
umount /mntUnmount27
mountList mounts27
fdisk -lList partitions28
fdisk /dev/sdbEdit partition table28
fsck /dev/sdb1Check filesystem29
mkfs.ext4 /dev/sdb1Create filesystem29
dd if=src of=dst bs=1MBlock copy29

Networking

CommandPurposeChapter
ping hostTest reachability30
traceroute hostTrace path30
ip addrShow addresses31
ip routeShow routes31
netstat -tulnListening ports31
ftp hostFTP client32
wget URLDownload file32
ssh user@hostRemote shell33
scp file user@host:/pathSecure copy34
sftp user@hostSecure FTP34

Search

CommandPurposeChapter
locate nameFast file search (database)35
updatedbUpdate locate database35
find /path -name '*.txt'Search filesystem35
find -type fOnly files35
find -type dOnly directories35
find -mtime -7Modified in last 7 days35
xargs cmdBuild command from stdin36

File Metadata

CommandPurposeChapter
stat fileFile metadata37
stat -c '%i' fileInode number37
df -hDisk usage37
du -sh dirDirectory size37

Compression and Archives

CommandPurposeChapter
gzip fileCompress to .gz38
gunzip file.gzDecompress38
bzip2 fileCompress to .bz238
bunzip2 file.bz2Decompress38
tar -cvf arch.tar dirCreate tar39
tar -xvf arch.tarExtract tar39
tar -czvf arch.tar.gz dirCreate gzip tar39
tar -xzvf arch.tar.gzExtract gzip tar39
zip -r arch.zip dirCreate zip39
unzip arch.zipExtract zip39
rsync -av src/ dst/Synchronize40

Regular Expressions

PatternMatchesChapter
^Start of line41
$End of line41
.Any character41
*Zero or more41
+One or more41
?Zero or one41
[abc]Character class41
[^abc]Negated class41
|Alternation41
()Grouping41
\{n\}Exactly n41

Formatting and Printing

CommandPurposeChapter
aspell check fileSpell check47
groff -ms fileFormat document50
pr filePaginate51
lpr filePrint file51
lp filePrint file51
lpstat -pPrinter status52
lpqPrint queue52
lprm jobRemove print job52

Shell Scripting

SyntaxPurposeChapter
#!/bin/bashShebang53
VAR=valueAssign variable54
echo "$VAR"Print variable55
read VARRead input56
read -p "prompt" VARPrompt for input56
func() { ... }Define function57
local VARLocal variable58
if [ cond ]; thenConditional59
elif, else, fiCondition branches59
[ -f file ]File exists60
[ -d dir ]Directory exists60
[ -z "$s" ]String empty60
[ "$a" = "$b" ]String equality60
[ "$a" -eq "$b" ]Numeric equality60
(( a > b ))Arithmetic test61
while [ cond ]; doWhile loop62
until [ cond ]; doUntil loop62
case "$x" inCase statement63
for i in list; doFor loop64
for ((i=0; i<n; i++))C-style for64
${VAR:-default}Default value65
${VAR#prefix}Strip prefix65
${VAR%suffix}Strip suffix65
${#VAR}String length65
${VAR^^}Uppercase66
${VAR,,}Lowercase66
$((16#FF))Hex to decimal67
$((10#08))Force decimal67
$(( 2**10 ))Exponent68
echo "scale=2; 10/3" | bcbc calculation69
arr=(a b c)Array definition70
${arr[0]}Array element70
${arr[@]}All elements70
${#arr[@]}Array length70

Quick Decision Table

I want to…Command
Find a file by namefind / -name 'x' 2>/dev/null
Find text in filesgrep -r 'text' dir/
See disk usagedf -h
See directory sizedu -sh dir/
Check open portsss -tuln
Kill a process by namepkill -f name
Download a filewget URL
Copy to remotescp file user@host:/path
Archive a directorytar -czvf a.tar.gz dir/
Extract a tarballtar -xzvf a.tar.gz
Sync directoriesrsync -av src/ dst/
Change permissionschmod 755 file
Change ownerchown user:group file
Run as rootsudo cmd
Check logstail -f /var/log/syslog
Count lineswc -l file
Sort and uniquesort file | uniq
Replace in filesed -i 's/old/new/g' file
Extract columnscut -d: -f1 file

Keywords

Was this helpful?


Stop using slow, ad-bloated tool sites! 🤮

🔎 Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)

⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free

🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!