🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now β†’
Menu

Categories

Basic Linux Commands Cheat Sheet: 100+ Essential Commands for Beginners (2026)

Basic Linux Commands Cheat Sheet: 100+ Essential Commands for Beginners (2026)

Whether you are a complete beginner stepping into the Linux world or a developer who needs a quick reference, having a comprehensive basic Linux commands cheat sheet is invaluable. Linux powers over 96% of the world's top web servers, dominates cloud infrastructure, and runs the majority of IoT devices β€” making command-line proficiency an essential skill in 2026.

This guide organizes 100+ essential Linux commands into logical categories with clear explanations, practical examples, and pro tips. Bookmark this page or download the free PDF cheat sheet to keep it handy.

1. File and Directory Management

File and directory operations are the foundation of everything you do on Linux. These commands let you navigate the filesystem, create and delete files, copy, move, and organize your data.

Navigation

# Print current working directory
pwd

# List files and directories
ls              # Basic listing
ls -la          # Long format with hidden files
ls -lh          # Human-readable file sizes
ls -lt          # Sort by modification time
ls -lS          # Sort by file size
ls -R           # Recursive listing

# Change directory
cd /var/log     # Go to absolute path
cd ..           # Go up one level
cd ~            # Go to home directory
cd -            # Go to previous directory

# Show directory tree
tree -L 2       # Show 2 levels deep
tree -d         # Directories only

Creating Files and Directories

# Create empty file
touch newfile.txt

# Create file with content
echo "Hello World" > greeting.txt

# Create multiple files
touch file1.txt file2.txt file3.txt

# Create directory
mkdir projects

# Create nested directories
mkdir -p projects/web/frontend/src

# Create file with heredoc
cat > config.yaml << EOF
server:
  port: 8080
  host: 0.0.0.0
EOF

Copying, Moving, and Deleting

# Copy file
cp source.txt destination.txt

# Copy directory recursively
cp -r /var/www/html /backup/html-backup

# Copy preserving attributes
cp -a /source /destination

# Move / rename file
mv oldname.txt newname.txt

# Move file to directory
mv report.pdf ~/Documents/

# Delete file
rm unwanted.txt

# Delete file (force, no prompt)
rm -f temp.log

# Delete directory recursively
rm -rf old-project/

# Delete empty directory
rmdir empty-folder/

# Interactive delete (confirm each file)
rm -i important-files/*

Finding Files

# Find files by name
find / -name "*.conf" -type f

# Find files modified in last 24 hours
find /var/log -mtime -1

# Find files larger than 100MB
find / -size +100M -type f

# Find and execute command
find /tmp -name "*.tmp" -exec rm {} \;

# Locate file (uses database, faster)
locate nginx.conf
updatedb          # Update locate database

# Which command location
which python3
whereis nginx

2. File Content and Text Processing

Linux excels at text processing. These commands let you view, search, filter, and transform text data β€” essential skills for log analysis, configuration management, and data processing.

# View entire file
cat /etc/hostname

# View with line numbers
cat -n /etc/passwd

# View first/last lines
head -20 /var/log/syslog      # First 20 lines
tail -50 /var/log/auth.log    # Last 50 lines
tail -f /var/log/syslog       # Follow (real-time)

# Page through large files
less /var/log/syslog           # Scroll with arrows, q to quit
more /var/log/messages         # Simple pager

# Search text in files
grep "error" /var/log/syslog
grep -i "warning" *.log        # Case insensitive
grep -r "TODO" /var/www/       # Recursive search
grep -n "function" script.py   # Show line numbers
grep -c "404" access.log       # Count matches
grep -v "DEBUG" app.log        # Invert match (exclude)

# Word/line/char count
wc -l /etc/passwd              # Line count
wc -w document.txt             # Word count

# Sort and unique
sort names.txt                 # Sort alphabetically
sort -n numbers.txt            # Numeric sort
sort -r data.txt               # Reverse sort
sort file.txt | uniq           # Remove duplicates
sort file.txt | uniq -c        # Count duplicates

# Cut columns from data
cut -d: -f1 /etc/passwd        # Extract usernames
cut -d, -f2,3 data.csv         # CSV columns 2 and 3

# Stream editor (sed)
sed "s/old/new/g" file.txt     # Replace all occurrences
sed -i "s/http/https/g" *.html # In-place edit
sed -n "10,20p" file.txt       # Print lines 10-20

# AWK text processing
awk "{print $1, $3}" data.txt  # Print columns 1 and 3
awk -F: "{print $1}" /etc/passwd   # Custom delimiter
awk "NR>=10 && NR<=20" file.txt    # Lines 10-20

# Compare files
diff file1.txt file2.txt       # Show differences
diff -u old.conf new.conf      # Unified format (patch-ready)

3. File Permissions and Ownership

Linux permissions control who can read, write, and execute files. Understanding permissions is critical for security and proper system administration.

# View permissions
ls -la /var/www/

# Permission format: -rwxrwxrwx
# Owner-Group-Others: read(4) write(2) execute(1)

# Change permissions (numeric)
chmod 755 script.sh           # rwxr-xr-x
chmod 644 config.txt          # rw-r--r--
chmod 600 private.key         # rw-------
chmod 700 ~/bin/              # rwx------

# Change permissions (symbolic)
chmod u+x script.sh           # Add execute for owner
chmod g-w file.txt            # Remove write for group
chmod o-rwx secret.doc        # Remove all for others
chmod a+r public.html         # Add read for all

# Recursive permissions
chmod -R 755 /var/www/html/

# Change ownership
chown www-data:www-data /var/www/html
chown -R deploy:deploy /opt/app/

# Change group only
chgrp developers project/

# Special permissions
chmod u+s /usr/bin/passwd     # SUID bit
chmod g+s /shared/            # SGID bit
chmod +t /tmp/                # Sticky bit

# Default permissions
umask 022                     # New files: 644, dirs: 755
umask 077                     # New files: 600, dirs: 700

4. User and Group Management

Managing users and groups is fundamental to Linux system administration and security. These commands handle creating accounts, setting passwords, and managing access.

# Current user info
whoami                        # Current username
id                            # User ID, group ID, groups
groups                        # List groups you belong to

# Add new user
sudo useradd -m -s /bin/bash john
sudo useradd -m -G sudo,docker john  # With groups

# Set/change password
sudo passwd john

# Modify user
sudo usermod -aG docker john   # Add to group
sudo usermod -s /bin/zsh john  # Change shell
sudo usermod -L john           # Lock account
sudo usermod -U john           # Unlock account

# Delete user
sudo userdel john              # Keep home directory
sudo userdel -r john           # Remove home directory too

# Group management
sudo groupadd developers
sudo groupdel oldgroup
sudo gpasswd -a john developers   # Add user to group
sudo gpasswd -d john developers   # Remove from group

# View users/groups
cat /etc/passwd                # All users
cat /etc/group                 # All groups
getent passwd john             # Specific user info
last                           # Login history
lastlog                        # Last login for all users
w                              # Who is logged in

5. Process Management

Understanding process management lets you monitor system activity, control running programs, and troubleshoot performance issues.

# View running processes
ps aux                         # All processes (BSD style)
ps -ef                         # All processes (System V style)
ps aux --sort=-%mem | head     # Top memory consumers
ps aux --sort=-%cpu | head     # Top CPU consumers

# Interactive process viewer
top                            # Real-time process monitor
htop                           # Enhanced (if installed)

# Find process by name
pgrep nginx                    # Get PID of nginx
pgrep -a python                # PID + full command
pidof sshd                     # PID of service

# Kill processes
kill 1234                      # Send SIGTERM to PID
kill -9 1234                   # Force kill (SIGKILL)
killall nginx                  # Kill by name
pkill -f "python server.py"   # Kill by pattern

# Background and foreground
./script.sh &                  # Run in background
nohup ./server.sh &            # Run, persist after logout
jobs                           # List background jobs
fg %1                          # Bring job 1 to foreground
bg %1                          # Resume job 1 in background
Ctrl+Z                         # Suspend current process
Ctrl+C                         # Terminate current process

# System resources
free -h                        # Memory usage
uptime                         # System uptime & load
vmstat 1 5                     # Virtual memory stats
iostat 1 5                     # I/O statistics

6. Networking Commands

Networking commands are essential for troubleshooting connections, checking server status, and managing network configuration.

# IP configuration
ip addr show                   # Show all interfaces
ip addr show eth0              # Specific interface
hostname -I                    # Quick IP address

# Connectivity testing
ping -c 4 google.com           # Ping 4 times
ping6 ::1                      # IPv6 ping
traceroute google.com          # Trace route to host
mtr google.com                 # Combined ping/traceroute

# DNS
nslookup example.com           # DNS lookup
dig example.com                # Detailed DNS query
dig +short example.com A       # Quick A record
host example.com               # Simple DNS lookup

# Ports and connections
ss -tuln                       # Listening ports
ss -tunap                      # All connections with PID
netstat -tlnp                  # Listening TCP ports (legacy)
lsof -i :80                   # What is using port 80

# Download files
wget https://example.com/file.tar.gz
wget -O output.zip https://example.com/archive.zip
curl -O https://example.com/file.tar.gz
curl -s https://api.example.com/data | jq .

# Transfer files
scp file.txt user@server:/path/
scp -r folder/ user@server:/backup/
rsync -avz /local/ user@server:/remote/

# Firewall (UFW)
sudo ufw status
sudo ufw allow 22/tcp
sudo ufw allow 80,443/tcp
sudo ufw deny 3306
sudo ufw enable

7. Disk and Storage

Monitor disk usage, manage partitions, and keep your storage organized with these essential commands.

# Disk usage overview
df -h                          # Filesystem usage
df -h /                        # Specific mount point
du -sh /var/log/               # Directory size
du -sh * | sort -h             # Sizes sorted
du -ah --max-depth=1 /var/     # One level deep

# Find large files
find / -type f -size +100M -exec ls -lh {} \;
du -a / | sort -rn | head -20

# Mount/unmount
mount /dev/sdb1 /mnt/usb       # Mount drive
umount /mnt/usb                # Unmount
mount | column -t              # Show all mounts

# Disk info
lsblk                          # Block devices
fdisk -l                       # Partition table
blkid                          # Block device attributes

8. Compression and Archives

Working with compressed files and archives is a daily task for any Linux user.

# tar archives
tar -czf archive.tar.gz folder/    # Create gzip archive
tar -cjf archive.tar.bz2 folder/  # Create bzip2 archive
tar -xzf archive.tar.gz           # Extract gzip
tar -xjf archive.tar.bz2          # Extract bzip2
tar -xzf archive.tar.gz -C /dest/ # Extract to directory
tar -tzf archive.tar.gz           # List contents

# zip
zip -r archive.zip folder/        # Create zip
unzip archive.zip                  # Extract zip
unzip -l archive.zip              # List contents
unzip archive.zip -d /dest/       # Extract to directory

# gzip individual files
gzip largefile.log                 # Compress (replaces original)
gunzip largefile.log.gz            # Decompress
gzip -k file.txt                   # Keep original

9. System Information

These commands help you understand your system hardware, kernel version, and overall configuration.

# System info
uname -a                       # Kernel & OS info
uname -r                       # Kernel version only
cat /etc/os-release            # Distribution info
hostnamectl                    # Hostname & OS details
lscpu                          # CPU information
lsmem                          # Memory information
lspci                          # PCI devices
lsusb                          # USB devices

# Date and time
date                           # Current date/time
date +"%Y-%m-%d %H:%M:%S"     # Formatted date
timedatectl                    # Time zone info
cal                            # Calendar

# Environment
env                            # All environment variables
echo $PATH                     # PATH variable
echo $HOME                     # Home directory
printenv USER                  # Specific variable

10. Package Management

Installing, updating, and removing software packages varies by distribution, but the concepts are the same.

# Debian/Ubuntu (apt)
sudo apt update                # Update package list
sudo apt upgrade               # Upgrade all packages
sudo apt install nginx         # Install package
sudo apt remove nginx          # Remove package
sudo apt autoremove            # Remove unused dependencies
apt search keyword             # Search packages
apt show nginx                 # Package details

# Red Hat/CentOS (dnf/yum)
sudo dnf update                # Update all
sudo dnf install httpd         # Install
sudo dnf remove httpd          # Remove
dnf search keyword             # Search
dnf info httpd                 # Details

# Arch Linux (pacman)
sudo pacman -Syu               # Update all
sudo pacman -S nginx           # Install
sudo pacman -R nginx           # Remove
pacman -Ss keyword             # Search

11. Service Management (systemd)

Modern Linux distributions use systemd to manage services. These commands are essential for server administration.

# Service control
sudo systemctl start nginx     # Start service
sudo systemctl stop nginx      # Stop service
sudo systemctl restart nginx   # Restart service
sudo systemctl reload nginx    # Reload config (no downtime)
sudo systemctl status nginx    # Check status

# Enable/disable on boot
sudo systemctl enable nginx    # Start on boot
sudo systemctl disable nginx   # Don't start on boot
sudo systemctl is-enabled nginx

# List services
systemctl list-units --type=service                # Running
systemctl list-unit-files --type=service --state=enabled  # Enabled

# Logs (journalctl)
journalctl -u nginx            # Logs for service
journalctl -u nginx --since today
journalctl -u nginx -f         # Follow logs
journalctl -p err              # Error-level only
journalctl --disk-usage        # Log storage used

12. Essential Shortcuts and Tips

# Command history
history                        # Show command history
history | grep ssh             # Search history
!!                             # Repeat last command
!ssh                           # Repeat last ssh command
Ctrl+R                         # Reverse search history

# I/O redirection
command > file.txt             # Redirect stdout (overwrite)
command >> file.txt            # Redirect stdout (append)
command 2> error.log           # Redirect stderr
command &> all.log             # Redirect stdout + stderr
command1 | command2            # Pipe output to next command

# Useful combinations
ls -la | grep ".conf"          # Filter listings
cat log.txt | sort | uniq -c | sort -rn  # Frequency analysis
ps aux | grep nginx | grep -v grep       # Find process

# Aliases (add to ~/.bashrc)
alias ll="ls -la"
alias update="sudo apt update && sudo apt upgrade -y"
alias myip="curl -s ifconfig.me"

# Wildcards
ls *.txt                       # All .txt files
ls file?.txt                   # file1.txt, file2.txt, etc.
ls {*.jpg,*.png}               # Multiple patterns
cp /etc/*.conf ~/backup/       # Copy all .conf files

Master Linux from the Ground Up

Take your Linux skills to the next level with these comprehensive eBooks:

Conclusion

This basic Linux commands cheat sheet covers the essential commands every Linux user needs to know in 2026. From navigating the filesystem and managing files to controlling processes, networking, and administering services β€” these commands form the foundation of Linux proficiency.

The key to mastery is practice. Start with the basics (navigation, file operations, permissions), then gradually work your way through networking, process management, and system administration commands. Set up a virtual machine or use a cloud server to practice without risk.

Download our comprehensive Basic Linux Commands Complete Cheat Sheet β€” a 10+ page printable PDF covering all the commands from this article in a clean, organized reference format.

Related Cheat Sheets You Might Like

Share this article:
Dorian Thorne
About the Author

Dorian Thorne

Cloud Infrastructure, Cloud Architecture, Infrastructure Automation, Technical Documentation

Dorian Thorne is a cloud infrastructure specialist and technical author focused on the design, deployment, and operation of scalable cloud-based systems.

He has extensive experience working with cloud platforms and modern infrastructure practices, including virtualized environments, cloud networking, identity and acces...

Cloud Computing Cloud Networking Identity and Access Management Infrastructure as Code System Reliability

Stay Updated

Subscribe to our newsletter for the latest tutorials, tips, and exclusive offers.