π Help#
man [command] # Shows the manual page for a command
help [built-in-command] # Shows the help page for a built-in command
[command] --help # Displays help options for a command
man -k [search_term] # Searches manual pages for matching keywords (like apropos)
man -k "multiple words" # Searches manual pages for matching keywords (like apropos)
appropos [search_term] # Searches manual pages for matching keywords
mandb # Updates manual pages
info [command] # Shows detailed GNU info documentation for a command
curl cheat.sh/[command] # Fetches command cheatsheet from cheat.sh
π Navigation#
pwd # Prints the current working directory (shows the full path)
ls # Lists current directory contents
ls -ld [directory] # Lists details (long format) of a specific directory without showing its contents
ls -l [file] # Lists detailed information of a file (permissions, owner, size, timestamp)
ls -R # Recursively lists subdirectories and their contents
tree # Displays directory structure in a tree-like format
tree -a # Includes hidden files and directories in the tree output
tree -h # Shows file sizes in a human-readable format (e.g., KB, MB)
tree -d # Displays only directories in tree view
tree -L 2 # Limits tree depth to 2 levels (change 2 as needed)
ls -la # Lists all files (including hidden files starting with .) in long format
ls -lh # Lists files in long format with human-readable sizes (e.g., 1K, 234M)
ls -lSh # Lists files in long format sorted by size (largest first)
ls -lSr # Lists files in long format sorted by size (smallest first)
ls -lt # Lists files sorted by modification time (newest first)
ls -ltr # Lists files sorted by modification time in reverse (oldest first)
ls -lr # Lists files in long format sorted by name in reverse (Z to A)
cd [directory] # Changes the current working directory to the specified one
cd - # Switches to the previous working directory
cd ~ # Changes to the current user's home directory
cd # Same as 'cd ~'; changes to home directory
cd .. # Moves up one directory level
cd ../../../ # Moves up three levels in the directory structure
π File and Directory Operations#
touch [filename] # Creates an empty file
cat [filename] # Displays file contents
nano [filename] # Opens file in Nano text editor
vim [filename] # Opens file in Vim text editor
less [filename] # Views file content page by page
head [filename] # Shows the first 10 lines of a file
tail [filename] # Shows the last 10 lines of a file
file [filename] # Determine file type
cp [source] [target] # Copies files or directories
mv [source] [target] # Moves or renames files or directories
rm [file] # Deletes files
rm -r [directory] # Deletes directories recursively
rm -rf [directory] # Force deletes directories recursively (dangerous!)
mkdir [directory] # Creates a new directory
mkdir dir1 dir2 dir3 # Creates multiple directories at once
mkdir -p a/b/c # Creates parent and nested directories recursively
rmdir [directory] # Removes an empty directory
rmdir -p a/b/c # Removes nested empty directories up the path
π¦ Package Management#
Debian/Ubuntu (APT)#
sudo apt update # Updates package lists
sudo apt upgrade # Upgrades all packages
sudo apt install [package] # Installs a package
sudo apt remove [package] # Removes a package
Red Hat/Fedora (DNF/YUM)#
sudo dnf install [package] # Installs a package
sudo dnf remove [package] # Removes a package
π Networking#
ip a # Displays IP address and interface info
ping [host] # Sends ICMP echo to a host
ifconfig # Shows network interfaces (legacy)
netstat -tuln # Lists open ports and listening services
curl [url] # Retrieves content from a URL
wget [url] # Downloads file from a URL
π€ User Management#
whoami # Prints the current user
passwd # Changes current userβs password
sudo [command] # Runs command with superuser privileges
adduser [username] # Adds a new user
deluser [username] # Deletes a user
chsh -s [shell_path] # Change current user's default shell
βοΈ Process Management#
ps aux # Lists running processes
top # Real-time view of system processes
htop # Interactive process viewer (needs installation)
kill [PID] # Terminates process by PID
killall [name] # Terminates all processes by name
π» System Info#
uname -a # Displays system information
df -h # Shows disk usage in human-readable format
free -h # Displays memory usage
uptime # Shows how long the system has been running
history # Shows previously used commands
clear # Clears the terminal screen