Linux Command Cheat Sheet ๐Ÿง

Here's a Linux Command Cheat Sheet for quick reference! ๐Ÿš€


๐Ÿ”น File & Directory Management

CommandDescription
lsList files in a directory
ls -lList files in long format
ls -aShow hidden files
pwdPrint current working directory
cd <dir>Change directory
cd ..Move up one directory
mkdir <dir>Create a new directory
rmdir <dir>Remove an empty directory
rm <file>Delete a file
rm -r <dir>Remove a directory and its contents
cp <source> <dest>Copy a file
mv <source> <dest>Move or rename a file
touch <file>Create a new empty file
find <dir> -name <filename>Search for a file
treeDisplay directory structure

๐Ÿ”น File Permissions

CommandDescription
chmod 755 <file>Change file permissions (owner: rwx, group: r-x, others: r-x)
chown user:group <file>Change file owner and group
ls -lView file permissions
umask 022Default permissions for new files

๐Ÿ”น File Content & Editing

CommandDescription
cat <file>View file contents
tac <file>View file in reverse
less <file>View file one page at a time
head -n <num> <file>View first N lines of a file
tail -n <num> <file>View last N lines of a file
nano <file>Open file in Nano editor
vim <file>Open file in Vim editor
echo "text" > <file>Write text to a file (overwrite)
echo "text" >> <file>Append text to a file
grep "text" <file>Search for text in a file
wc -l <file>Count number of lines in a file
diff <file1> <file2>Compare two files
sort <file>Sort lines in a file

๐Ÿ”น User Management

CommandDescription
whoamiShow current user
whoShow logged-in users
idShow user ID and group ID
adduser <user>Add a new user
passwd <user>Change user password
deluser <user>Delete a user
groupadd <group>Create a new group
usermod -aG <group> <user>Add user to a group

๐Ÿ”น Process Management

CommandDescription
ps auxShow all running processes
topDisplay active processes in real-time
htopInteractive process viewer (if installed)
kill <PID>Kill a process by PID
killall <process>Kill all processes by name
pkill <process>Kill process by name
nohup <command> &Run command in background (ignore hangups)

๐Ÿ”น Networking

CommandDescription
ping <host>Check connectivity to a host
curl <URL>Fetch content from a URL
wget <URL>Download a file from a URL
ifconfigShow network interfaces (deprecated)
ip addr showShow network interfaces (modern alternative)
netstat -tulnpList open ports
ss -tulnpAlternative to netstat for open ports
scp <file> user@host:/pathCopy files over SSH
rsync -avz <source> <dest>Sync files/directories
hostname -IShow local IP address

๐Ÿ”น Disk & Storage

CommandDescription
df -hShow disk space usage
du -sh <dir>Show size of a directory
lsblkShow block devices (partitions)
mount /dev/sdX /mntMount a disk partition
umount /mntUnmount a partition
fdisk -lShow partition table

๐Ÿ”น System Monitoring

CommandDescription
uptimeShow system uptime
free -hShow memory usage
vmstatShow system performance
iostatShow CPU & disk stats
dmesgShow boot log messages

๐Ÿ”น Package Management

๐Ÿ”น Debian/Ubuntu (apt)

CommandDescription
sudo apt updateUpdate package list
sudo apt upgradeUpgrade installed packages
sudo apt install <package>Install a package
sudo apt remove <package>Remove a package
dpkg -lList installed packages

๐Ÿ”น Red Hat/CentOS (yum or dnf)

CommandDescription
sudo yum install <package>Install a package
sudo yum remove <package>Remove a package
sudo yum updateUpdate system

๐Ÿ”น Arch (pacman)

CommandDescription
sudo pacman -S <package>Install a package
sudo pacman -R <package>Remove a package

๐Ÿ”น Compression & Archiving

CommandDescription
tar -cvf archive.tar <files>Create a tar archive
tar -xvf archive.tarExtract a tar archive
tar -czvf archive.tar.gz <files>Create a gzip-compressed tar archive
tar -xzvf archive.tar.gzExtract a gzip-compressed tar archive
zip archive.zip <files>Create a zip archive
unzip archive.zipExtract a zip file

๐Ÿ”น Permissions & Ownership

CommandDescription
chmod 755 <file>Change file permissions (rwx for owner, rx for others)
chmod +x <file>Make file executable
chown user:group <file>Change file owner/group
sudoExecute command as root

๐Ÿ”น Shortcuts & Misc

CommandDescription
clearClear terminal screen
historyShow command history
alias ll='ls -la'Create a shortcut for a command
unalias llRemove an alias
!!Repeat the last command
CTRL + CStop a running process
CTRL + ZSuspend a process
bgResume a suspended process in background
fgResume a process in foreground

๐Ÿ“ฅ Grab your free PDF here of this cheat sheet

Visit my website

Did you find this article valuable?

Support Rudraksh.tech by becoming a sponsor. Any amount is appreciated!

ย