Version: Sep 18, 2025

⌨️ Keyboard Shortcuts

# Kill process running in the terminalCtrl + C
# Stop the current process (resume with fg or bg)Ctrl + Z
# Cut one word before the cursor and add it to the clipboardCtrl + W
# Cut part of the line before the cursor and add it to the clipboardCtrl + U
# Cut part of the line after the cursor and add it to the clipboardCtrl + K
# Paste from clipboardCtrl + Y
# Recall the last command that matches the provided charactersCtrl + R
# Run the previously recalled commandCtrl + O
# Exit command history without running a commandCtrl + G
# Clear the terminal screenclear
# Run the last command again!!
# Log out of the current sessionexit

πŸ’Ύ Disk Usage

# Check available and used disk space on all mounted file systems (human-readable format).df -h
# Show free and used inodes on mounted file systems.df -i
# List all disk partitions, sizes, and types.fdisk -l
# Show disk usage for every file and folder (recursively).du -ah
# Show total disk usage of the current directory.du -sh
# List all currently mounted file systems.mount
# Display all file systems with their mount points in a tree view.findmnt
# Mount a device to a directory (mount point).mount device_path mount_point

πŸ”‘ User & Permissions

# Switch usersu - username
# Add new usersudo adduser newuser
# Add user to sudoerssudo usermod -aG sudo newuser
# Change permissionschmod 755 file.sh
# Change ownershipchown user:group file.txt
# How to enter into root shellsudo -i

πŸ‘₯ Users & Groups

# Show details about the current user and groupsid
# Show the last system loginslast
# Display who is currently logged inwho
# Show users logged in and their activityw
# Show information about a specific userfinger username
# Create a new user accountsudo useradd username
# Alternative: add user via interactive scriptsudo adduser username
# Delete a user accountsudo userdel username
# Add user to a groupsudo usermod -aG groupname username
# Change the current user's passwordpasswd
# Change another user's passwordsudo passwd username
# Create a new groupsudo groupadd groupname
# Delete a groupsudo groupdel groupname
# Rename a groupsudo groupmod -n newname oldname
# Temporarily run a command as superusersudo command
# Switch to another user (or root if none specified)su - username
# Change file or directory groupchgrp groupname file_or_directory

πŸ“‚ File & Directory Management

# List all files and directories in the current directory (long format, hidden files)ls -la
# List all files and directories in the current directory (shows hidden files).ls -a
# Show the directory you are currently working in.pwd
# Move back one directorycd ..
# Change to the previous Directorycd -
# Change directorycd /path/to/dir
# Make a new directorymkdir new_folder
# Remove directory (empty)rmdir old_folder
# Copy filecp file1.txt /path/to/dir/
# Move or rename filemv oldname.txt newname.txt
# Remove filerm file.txt
# Find files by namefind /path -name "*.log"

πŸ”„ Permissions & Ownership

# Give read, write and execute permission to owner and give read and execute permission to group and others (rwxr-xr-x)chmod 755 file.sh
# Give read, write and execute permission to owner and read/write permission to group and others (rwxrw-rw-)chmod 766 file.sh
# Allow read, write and execute file permission to everyone (rwxrwxrwx)chmod 777 file.sh
# Add execute permissionchmod +x script.sh
# Change file ownerchown user file.txt
# Change file owner and group ownerchown user:group file.txt

πŸ“ File Viewing & Editing

# View file contentscat file.txt
# View with paginationless file.txt
# Edit with nanonano file.txt
# Edit with vimvim file.txt
# Show first 10 lineshead file.txt
# Show last 10 linestail file.txt
# Follow file updatestail -f logfile.log

πŸ“„ File Operations

# Create a new filetouch filename
# Create a symbolic linkln -s /path/to/file linkname
# Append contents of one file to anothercat source_file >> destination_file
# Show the first 10 lines of a filehead filename
# Show the last 10 lines of a filetail filename
# Display contents page by pagemore filename
# Display contents with navigationless filename
# Count words, lines, and bytes in a filewc -w filename
# Count lines/words/chars in multiple filesls | xargs wc
# Cut sections of a file using a delimitercut -d: -f1 filename
# Cut sections from piped dataecho "one:two:three" | cut -d: -f2
# Overwrite a file to securely delete itshred -u filename
# Compare two files and show differencesdiff file1 file2
# Execute file content in the current shellsource filename
# Store command output in a file (and still show in terminal)command | tee output.txt

πŸ“¦ Package Management (General)

# Install software from source codetar zxvf [file_name.tar.gz]
cd [extracted_directory]
./configure
make
sudo make install

πŸ“¦ Package Management (Ubuntu/Debian)

# Update package listssudo apt update
# Upgrade installed packagessudo apt upgrade
# Install a packagesudo apt install package-name
# Remove a packagesudo apt remove package-name
# Search for a packageapt search package-name

πŸ“¦ Package Management (Red Hat / CentOS / Fedora)

# Install a packagesudo dnf install [package_name]
# Remove a packagesudo dnf remove [package_name]
# Search for a package in repositoriesdnf search [keyword]
# List installed packagesdnf list installed
# Show information about a packagednf info [package_name]
# Install a local RPM packagesudo rpm -i [package_name.rpm]
# (Legacy) Older systems may use YUM:sudo yum install [package_name]

πŸ“¦ Package Management (Arch with Pacman)

# Update package database and upgrade all packagessudo pacman -Syu
# Install a packagesudo pacman -S [package_name]
# Remove a packagesudo pacman -R [package_name]
# Search for a packagepacman -Ss [keyword]
# List installed packagespacman -Qe

πŸ“¦ Package Management (Snap)

# Install a Snap packagesudo snap install [package_name]
# Search for a Snap packagesudo snap find [keyword]
# List installed Snap packagessudo snap list

πŸ“¦ Package Management (Flatpak)

# Install a Flatpak packageflatpak install [package_name]
# Search for a Flatpak applicationflatpak search [keyword]
# List installed Flatpak packagesflatpak list

βš™οΈ System Information

# Show current userwhoami
# Show system infouname -a
# Show disk usagedf -h
# Show memory usagefree -h
# Show running processesps aux
# Show real-time processestop

🌐 Networking

# Show IP addressip addr show
# Ping a hostping -c 4 google.com
# Show listening portssudo netstat -tuln
# Test open port (e.g., port 22)nc -zv localhost 22
# Download file with wgetwget http://example.com/file.zip

πŸ” SSH

# Connect to a remote systemssh user@host
# Use a specific private key for loginssh -i ~/.ssh/id_rsa user@host
# Connect using a custom port (default is 22)ssh -p 2222 user@host
# Generate a new SSH key pairssh-keygen
# Start the SSH server (on systems with systemd)sudo systemctl start sshd
# Copy a file from local to remotescp file.txt user@host:/remote/path/
# Copy a file from remote to localscp user@host:/remote/path/file.txt ./
# Securely transfer files interactively with SFTPsftp user@host
# (Legacy) Connect via Telnet on port 23telnet host

πŸ–₯️ Process Management

# List running jobsjobs
# Kill process by PIDkill -9 1234
# Kill process by namepkill -f process_name
# Run in backgroundcommand &
# Bring job to foregroundfg %1

πŸ” Searching

# Find files and directories by namefind /path -name "pattern"
# Find files larger than a specified size (e.g., 100MB)find /path -size +100M
# Search for a text pattern inside a filegrep "pattern" file.txt
# Recursively search for a pattern inside a directorygrep -r "pattern" /path/to/dir
# Locate files in the system’s database (faster than find)locate filename
# Show the full path of a command (from $PATH)which command
# Show source, binary, and man page for a commandwhereis command
# Print all lines in a file matching a pattern (awk)awk '/pattern/ {print $0}' file.txt
# Find and replace text in a filesed 's/old/new/' file.txt