0% found this document useful (0 votes)
12 views

Linux Cheatsheet

Linux Cheatsheet

Uploaded by

Woody Woodpecker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Linux Cheatsheet

Linux Cheatsheet

Uploaded by

Woody Woodpecker
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

LINUX CHEATSHEET

YOUR GO-TO LINUX COMMAND REFERENCE FOR NAVIGATING AND MANAGING LINUX SYSTEMS
Navigating directories
pwd - Prints the current working directory
ls -l, -a, -h Lists files in a directory (-i: detailed, -a: all files, -h: human-readable)
cd .., /path/to/dir Changes the current directory
mkdir -p Creates a new directory (-p: parent directories)
rmdir - Removes an empty directory
find -name, -type Searches for files or directories by name or type

File operations
cp -r, -i Copies files or directories (-r: recursive, -i: prompt)
mv -i, -f, -n, -b Moves or renames files (-i: prompt, -f: force, -n: no-clobber, -b: backup)
rm -r, -f, -v Deletes files or directories (-r: recursive, -f: force, -v: verbose)
touch - Creates an empty file or updates the timestamp
cat - Displays the content of a file
head -n Displays first few lines of a file (-n: lines)
tail -n, -f Displays last few lines of a file (-n: lines, -f: follow)
nano - Open file for editing with nano
vim - Open file for editing with vim man [command] or
[command] --help provide
additional info about options
System information
uname -a Displays system information (-a: all details)
df -h, -a, -l Shows disk space usage (-h: human-readable, -a: all file systems, -l: local only)
du -h, -s, -a Displays directory size (-h: human-readable, -s: summary, -a: all directories)
top - Displays real-time system processes (press q to exit)
htop - Interactive version of top
ps -ef, aux Lists running processes (-ef and aux: detailed view)
free -h, -t Shows memory usage (-h: human-readable, -t: display total)
uptime - Displays how long the system has been running since the last reboot

Package management (distro dependent) *apt is newer and user-friendlier, apt-get has better scriptability
apt(-get) update* - Updates the list of available packages (Debian/Ubuntu)
apt(-get) upgrade* - Upgrades installed packages to the latest available version (Debian/Ubuntu)
apt(-get) install* -y Installs a package (-y: automatic yes) (Debian/Ubuntu)
apt(-get) remove* -y Uninstalls a package (-y: automatic yes) (Debian/Ubuntu)
yum makecache - Updates the package cache (Red Hat-based systems)
yum update - Updates installed packages to the latest available version (Red Hat-based systems)
yum install - Installs a package (Red Hat-based systems)
yum remove - Uninstalls a package (Red Hat-based systems)
snap install - Installs a snap package (any Linux distribution that supports snapd)

Symbols and numeric value Permissions


r 4 Read sudo - Runs a command with administrative privileges
w 2 Modify chmod +x, -R Changes file permissions (+x: executable, -R: recursive)
x 1 Execute chown -R Changes ownership of a file or directory (-R: recursive)
- 0 No access umask -S Displays or sets default permission values (-S: symbols)

Others
echo -e Prints text to the terminal (-e: enable interpretation of escape characters)
history -c Displays command history (-c: clear history)
alias alias_name='cmd' Creates shortcuts for commands
kill -9 Terminates a process (-9: force)
ln -s, -f Creates a hard or symbolic link to a file or directory (-s: symbolic, -f: force)
wget -o, -b, -i Downloads files from the web (-o: logfile, -b: background, -i: read URLs from file)
curl -o, -O, -x Transfers data to/from a server (HTTP, FTP, etc) (-o/-O: save file, -x: proxy)
grep -c, -l, -w Searches for specific pattern in file (-c: count only, -l: list files, -w: whole word)

You might also like