Essential Linux Commands You MUST Know With Cheat Sheet
So, you’re diving into the world of Linux, huh? Awesome! Whether you’re a budding system administrator, a curious developer, or just someone who wants to understand the magic behind the command line, this post is your ultimate guide to essential Linux commands.
- Essential Linux Commands You MUST Know With Cheat Sheet
- 📌 What is Linux?
- Why Learn Linux Commands?
- Getting Started with Linux Command Line
- File and Directory Operations
- File Permissions and Ownership
- Text Processing and Manipulation
- Networking Commands
- System Monitoring and Performance
- Package Management
- User Management
- Disk Management
- SSH and Remote Connections
- Advanced Commands
- Essential Linux Commands: A Quick Reference Table
- 🚀 Bonus: Download Your Free Linux Commands Cheat Sheet
- ❓Frequently Asked Questions (FAQs) About Linux Commands
- 🎯Conclusion
In this guide, we’ll cover 90+ essential Linux commands, categorized for easy reference. Plus, we’ve included a free downloadable cheat sheet to help you quickly look up commands whenever needed!
Get ready to level up your Linux skills!
📌 What is Linux?
Linux is an open-source, Unix-like operating system that powers everything from personal computers to servers and supercomputers. It is widely used for its security, stability, and flexibility. The Linux command line, also known as the terminal, allows users to execute powerful commands to interact with the system.
Why Learn Linux Commands?
Before we jump in, let’s talk about why learning Linux commands is so valuable. The command line, also known as the terminal or shell, is your direct line to the heart of the Linux operating system. It’s where the real power lies. While graphical interfaces are convenient, the command line offers unparalleled flexibility, control, and efficiency. Learning these commands will allow you to:
- Manage files like a pro: Create, delete, move, copy, and rename files with ease.
- Navigate the file system effortlessly: Jump between directories, explore different drives, and understand the Linux file structure.
- Control processes: Start, stop, and monitor running programs.
- Configure your system: Change settings, install software, and customize your Linux environment.
- Automate tasks: Write scripts to perform repetitive actions automatically.
- Troubleshoot problems: Diagnose and fix issues with your system.
Getting Started with Linux Command Line
Before we dive into the commands, here are some basics:
- Shell: The command line interpreter. Popular ones include Bash, Zsh, and Fish.
- Terminal Emulator: A program that opens a shell window. Examples: GNOME Terminal, Konsole, or xterm.
- Root User: The superuser with full system privileges. Use
sudo
to execute commands as root.
Pro Tip: Use the man
command to learn more about any command’s usage. For example, man ls
displays the manual for the ls
command.
Suggested Reading: 50+ Essential Git Commands (With Downloadable Cheat Sheet)
Linux commands are case-sensitive and generally follow this structure:
command [options] [arguments]
Example:
ls -l /home
Ready to level up your Linux skills? Let’s dive into the most useful Linux commands!
File and Directory Operations
ls
– List directory contents
ls # List files in the current directory
ls -l # Detailed listing with permissions and sizes
ls -a # Show hidden files
ls -lh # Human-readable file sizes
cd
– Change directory
cd /home/user # Go to /home/user
cd .. # Go up one directory level
cd ~ # Go to the home directory
pwd
– Print working directory
pwd # Displays the current directory path
mkdir
– Create a new directory
mkdir new_folder # Create a new folder
mkdir -p parent/child # Create nested directories
rmdir
– Remove an empty directory
rmdir empty_folder # Deletes an empty folder
rm
– Remove files or directories
rm file.txt # Delete a file
rm -r folder # Delete a directory and its contents
rm -f file.txt # Force delete without confirmation
rm -rf folder # Force delete directory and its contents
cp
– Copy files or directories
cp file1.txt file2.txt # Copy file1.txt to file2.txt
cp -r dir1 dir2 # Copy directory dir1 to dir2
mv
– Move or rename files or directories
mv old_name.txt new_name.txt # Rename a file
mv file.txt /new/location/ # Move file to another directory
touch
– Create an empty file or update the timestamp
touch newfile.txt # Create a new empty file
cat
– View the contents of a file
cat file.txt # Display contents of file.txt
more
andless
– View file contents page by page
more file.txt # View file contents with pagination
less file.txt # Similar to more but with better navigation
head
andtail
– View the beginning or end of a file
head -n 5 file.txt # Show first 5 lines of the file
tail -n 5 file.txt # Show last 5 lines of the file
tail -f logfile.txt # Monitor live updates to a log file
ln
– Create symbolic links
ln -s target linkname # Create a symbolic (soft) link
du
– Estimate file and directory space usage
du -sh * # Display folder sizes in the current directory
df
– Display disk space usage
df -h # Show disk space in human-readable format
find
– Locate files in the directory tree
find /home -name "*.txt" # Find all .txt files in /home
find /var -type f -size +10M # Find files larger than 10MB
locate
– Find files by name using an indexed database
locate filename # Locate file by name
stat
– Display file or file system status
stat file.txt # Display detailed information about a file
File Permissions and Ownership
chmod
– Change file permissions
chmod 755 script.sh # Give owner execute permission, readable by others
chmod u+x script.sh # Add execute permission for the owner
chown
– Change file owner and group
chown user:group file.txt # Change owner and group of file
chown -R user:group dir/ # Change ownership recursively
chgrp
– Change group ownership
chgrp group file.txt # Change group of the file
umask
– Default permission setting for new files
umask 022 # Sets default permission for new files
Text Processing and Manipulation
grep
– Search text using patterns
grep "pattern" file.txt # Search for 'pattern' in file
grep -i "pattern" file.txt # Case insensitive search
grep -r "pattern" /dir/ # Recursive search in a directory
ps –ef | grep process_name #Check whether a specific process is running
sed
– Stream editor for modifying text
sed 's/old/new/g' file.txt # Replace 'old' with 'new' in file
awk
– Pattern scanning and text processing
awk '{print $1}' file.txt # Print the first column of a file
sort
– Sort lines of text files
sort file.txt # Sort lines in ascending order
sort -r file.txt # Sort lines in descending order
uniq
– Report or omit repeated lines
uniq file.txt # Remove duplicate lines
diff
– Compare files line by line
diff file1.txt file2.txt # Show differences between files
wc
– Word, line, and byte count
wc file.txt # Display word, line, and byte count
wc -l file.txt # Line count only
cut
– Cut out selected portions of a file
cut -d':' -f1 /etc/passwd # Display first field using ':' delimiter
paste
– Merge lines of files
paste file1.txt file2.txt # Merge lines side by side
tr
– Translate or delete characters
tr 'a-z' 'A-Z' < file.txt # Convert lowercase to uppercase
split
– Split a file into pieces
split -b 10M largefile part_ # Split into 10MB pieces
Networking Commands
ping
– Check connectivity to a host
ping google.com # Check if Google is reachable
ping -c 4 google.com # Send 4 packets and stop
ifconfig
– Display network interfaces (Deprecated, useip
command)
ifconfig # Show all network interfaces
ip
– Show/manipulate routing, devices, policy routing, and tunnels
ip a # Display all network interfaces
ip link set eth0 up # Enable network interface
ip link set eth0 down # Disable network interface
hostname
– Display or set the system’s hostname
hostname # Show current hostname
hostnamectl set-hostname newname # Set a new hostname
wget
– Download files from the web
wget http://example.com/file.zip # Download a file
wget -c http://example.com/file.zip # Resume a download
curl
– Transfer data from or to a server
curl http://example.com # Fetch webpage content
curl -O http://example.com/file.zip # Download file
ssh
– Securely connect to a remote machine
ssh user@remote_host # SSH into a remote server
ssh -i keyfile.pem user@remote_host # Connect using an identity file
scp
– Securely copy files between hosts
scp file.txt user@remote_host:/path/to/destination
scp user@remote_host:/path/to/source/file.txt /local/destination
ftp
– File Transfer Protocol client
ftp ftp.example.com # Connect to FTP server
netstat
– Network statistics
netstat -tuln # Show all listening ports
netstat -pnltu # Display active connections
ss
– Display socket statistics (Replacement fornetstat
)
ss -tuln # Show listening ports
ss -s # Summarize network statistics
nslookup
– Query internet name servers interactively
nslookup google.com # Get DNS information for a domain
dig
– DNS lookup
dig google.com # Detailed DNS information
traceroute
– Trace the route packets take to a network host
traceroute google.com # Trace the route to a host
whois
– Get domain registration details
whois example.com # Get WHOIS info for a domain
nmcli
– NetworkManager command-line interface
nmcli device status # Show network device status
nmcli connection show # List all connections
System Monitoring and Performance
top
– Display real-time running processes
top # Display dynamic process info
htop
– Interactive process viewer (Enhanced version oftop
)
htop # Display real-time process viewer
ps
– Display snapshot of current processes
ps aux # Show all running processes
ps -ef # Detailed process listing
kill
– Send signal to a process
kill PID # Terminate a process by PID
kill -9 PID # Force kill a process
killall
– Kill processes by name
killall firefox # Kill all instances of Firefox
pkill
– Send signal to processes based on name or other attributes
pkill -u user # Kill all processes by user
jobs
– List background jobs
jobs # List active background jobs
bg
– Resume a job in the background
bg %1 # Continue job in background
fg
– Bring a job to the foreground
fg %1 # Bring background job to foreground
nice
– Start a process with a specific priority
nice -n 10 command # Start process with priority
renice
– Change running process priority
renice 15 PID # Adjust priority of running process
uptime
– Tell how long the system has been running
uptime # Show uptime and load average
free
– Display memory usage
free -h # Show memory in human-readable format
vmstat
– Report virtual memory statistics
vmstat 5 # Display CPU and memory stats every 5 seconds
iostat
– CPU and input/output statistics
iostat # Display CPU and I/O stats
dmesg
– Print kernel and driver messages
dmesg | tail # Show latest kernel messages
pgrep
– List processes by name
pgrep apache2 # Find process IDs by name
screen
– Terminal multiplexer for session management
screen -S session_name # Start a new screen session
Package Management
apt
– Package management (Debian/Ubuntu)
apt update # Refresh package list
apt upgrade # Upgrade all packages
apt install package_name # Install a package
apt remove package_name # Uninstall a package
apt search package_name # Search for a package
yum
– Package manager (CentOS/RHEL)
yum update # Update all packages
yum install package_name # Install a package
yum remove package_name # Remove a package
dnf
– Next-generation package manager (Fedora/RHEL/CentOS)
dnf install package_name # Install a package
dnf update # Update system
dnf remove package_name # Remove a package
User Management
useradd
– Create a new user
useradd newuser # Add a new user
usermod
– Modify user details
usermod -aG sudo newuser # Add user to sudo group
userdel
– Delete a user account
userdel newuser # Remove a user
passwd
– Change user password
passwd username # Change password for user
whoami
– Currently logged in user
whoami # See the currently logged in user
cat /etc/passwd
– Display a list of all users with additional info
cat /etc/passwd # List of all users with additional info
usermod -d
– Home directory of a user
usermod -d /home/test username # Change the home directory of a user
groupadd
– Create a new group
groupadd developers # Create a new group
groupdel
– Delete a group
groupdel developers # Delete a group
groups
– Show user’s groups
groups username # Display groups for user
su
– Switch user account
su - username # Switch to another user
sudo
– Execute commands as superuser
sudo apt update # Run command with root privileges
Disk Management
mount
– Mount file systems
mount /dev/sda1 /mnt # Mount a partition
umount
– Unmount file systems
umount /mnt # Unmount a partition
fsck
– File system consistency check
fsck /dev/sda1 # Check and repair filesystem
blkid
– Locate/print block device attributes
blkid # Display UUIDs of storage devices
lsblk
– List information about block devices
lsblk # Show all block devices
fdisk
– Partition table manipulator
fdisk -l # List all partitions
SSH and Remote Connections
ssh-keygen
– Generate SSH keys
ssh-keygen # Generate a new SSH key pair
ssh-copy-id
– Install SSH key on a remote server for passwordless login
ssh-copy-id user@remote_host # Copy public key to remote host
rsync
– Remote file sync
rsync -avz /local/dir user@remote:/remote/dir
Advanced Commands
tar
– Archive files
tar -cvf archive.tar /path/to/files
tar -xvf archive.tar # Extract files from archive
tar xf archive #Extract archive of any type
unzip archive.zip -d /directory_name #Unzip a zip archive to a specific directory
gzip filename #Compress a file and add the .gz extension to it. This will delete the original file
gzip -c filename > archive.gz #Create a new compressed .gz file, preserving the original
gzip
andgunzip
– Compress and decompress files
gzip file.txt # Compress file
gunzip file.txt.gz # Decompress file
chroot
– Change root directory
chroot /new/root # Change root directory
- tmux – Advanced terminal multiplexer
tmux new -s session_name # Create a new tmux session
Essential Linux Commands: A Quick Reference Table
Command | Description | Example |
---|---|---|
ls | List directory contents | ls -l (Detailed list) |
cd | Change directory | cd /var/www |
pwd | Print current working directory | pwd |
mkdir | Create a new directory | mkdir new_folder |
rmdir | Remove an empty directory | rmdir old_folder |
cp | Copy files or directories | cp file.txt /backup/ |
mv | Move or rename files | mv old.txt new.txt |
rm | Remove files or directories | rm file.txt |
cat | Concatenate and display file content | cat file.txt |
more | View file content page by page | more file.txt |
less | Similar to more , but faster | less file.txt |
head | View the first lines of a file | head -n 10 file.txt |
tail | View the last lines of a file | tail -n 10 file.txt |
touch | Create an empty file | touch newfile.txt |
find | Search for files and directories | find / -name "file.txt" |
grep | Search text using patterns | grep "error" logfile.txt |
locate | Find files by name | locate config.php |
echo | Display text or variables | echo "Hello World" |
chmod | Change file permissions | chmod 755 script.sh |
chown | Change file owner and group | chown user:group file.txt |
ln | Create links (hard and symbolic) | ln -s target linkname |
df | Display disk space usage | df -h (Human-readable) |
du | Show directory space usage | du -sh /var/log |
mount | Mount file systems | mount /dev/sda1 /mnt |
umount | Unmount file systems | umount /mnt |
ps | Display running processes | ps aux |
top | Real-time process monitoring | top |
htop | Interactive process viewer | htop |
kill | Terminate a process | kill 1234 (By PID) |
killall | Kill processes by name | killall firefox |
service | Manage system services | service apache2 restart |
systemctl | Control systemd services | systemctl status nginx |
crontab | Schedule recurring tasks | crontab -e (Edit tasks) |
uptime | Display system uptime | uptime |
who | Show who is logged in | who |
w | Display who is logged in and their activity | w |
ping | Check network connectivity | ping google.com |
ifconfig | Display network interfaces (Deprecated) | ifconfig |
ip | Network configuration | ip a (Show interfaces) |
hostname | Show or set hostname | hostnamectl set-hostname newname |
wget | Download files from the web | wget http://example.com/file.zip |
curl | Transfer data from/to server | curl http://example.com |
ssh | Secure remote login | ssh user@remote_host |
scp | Securely copy files | scp file.txt user@remote:/path/ |
ftp | File Transfer Protocol client | ftp ftp.example.com |
netstat | Network statistics | netstat -tuln |
ss | Display socket statistics | ss -tuln |
nslookup | DNS lookup | nslookup google.com |
dig | Advanced DNS query | dig google.com |
traceroute | Trace packet route | traceroute google.com |
whois | Domain registration details | whois example.com |
nmcli | NetworkManager CLI | nmcli device status |
free | Display memory usage | free -h |
vmstat | Virtual memory statistics | vmstat 5 |
iostat | CPU and I/O statistics | iostat |
dmesg | Kernel and driver messages | `dmesg |
apt | Package manager (Debian/Ubuntu) | apt install package_name |
yum | Package manager (CentOS/RHEL) | yum install package_name |
dnf | Next-gen package manager | dnf install package_name |
tar | Archive files | tar -cvf archive.tar /path/ |
gzip | Compress files | gzip file.txt |
gunzip | Decompress files | gunzip file.txt.gz |
zip | Create ZIP archive | zip archive.zip file1 file2 |
unzip | Extract ZIP archive | unzip archive.zip |
ssh-keygen | Generate SSH keys | ssh-keygen |
ssh-copy-id | Install SSH key on remote | ssh-copy-id user@remote_host |
rsync | Remote file sync | rsync -avz /src/ user@remote:/dest/ |
fsck | File system check and repair | fsck /dev/sda1 |
blkid | Block device attributes | blkid |
lsblk | List block devices | lsblk |
fdisk | Partition table manipulator | fdisk -l |
chroot | Change root directory | chroot /new/root |
alias | Create command shortcuts | alias ll='ls -la' |
history | Command history | history |
man | Display manual for commands | man ls |
help | Help for built-in commands | help cd |
exit | Logout or close terminal | exit |
🚀 Bonus: Download Your Free Linux Commands Cheat Sheet
To further support your Linux learning, we offer a complimentary downloadable cheat sheet summarizing the top essential Linux commands discussed.
![Top 90+ Essential Linux Commands Plus Cheat Sheet 1 Essential Linux Commands Cheat Sheet](https://www.aveshost.com/blog/wp-content/uploads/2025/02/Essential-Linux-Commands-Cheat-Sheet-1024x576.png)
Get the 2560×1440 wallpaper linux commands cheat sheet
Download The Linux Cheat Sheet❓Frequently Asked Questions (FAQs) About Linux Commands
Linux commands are text-based inputs that allow users to perform various tasks on a Linux operating system, such as file management, system administration, and network configuration. They are typically executed in the terminal or command line interface.
Learning Linux commands provides greater control and flexibility over system operations, enhances productivity, and is essential for system administration, programming, and cybersecurity tasks. It’s also highly valued in the tech industry.
Most basic Linux commands are the same across different distributions (like Ubuntu, CentOS, and Debian). However, certain commands, especially those related to package management and system configuration, can vary between distributions.
You can practice Linux commands safely using a virtual machine (VM), a cloud-based Linux server, or by installing Linux on a secondary computer. Online platforms like Linux terminal emulators and Docker containers are also great for practice.
1. sudo
allows a permitted user to run a command as the superuser or another user while maintaining their own session.
2. su
switches to the superuser or another user account entirely, requiring the target user’s password.
You can get help by using the following methods:
1. man <command>
– Opens the manual page for a command.
2. <command> --help
– Displays a brief help message.
3. info <command>
– Shows more detailed information.
Yes, you can create custom commands using shell scripts or by defining aliases in your shell configuration file (e.g., .bashrc
or .zshrc
). This allows you to automate repetitive tasks and enhance productivity.
Yes, Linux commands are case-sensitive. For example, ls
, LS
, and Ls
are interpreted as different commands. This applies to file and directory names as well, so it’s important to use the correct case when typing commands.
You can learn more from:
1. Official Linux documentation and man pages.
2. Online tutorials and courses on platforms like Udemy, Coursera, and YouTube.
3. Linux communities and forums like Stack Overflow and Reddit.
🎯Conclusion
There you have it—90+ essential Linux commands to help you navigate, manage, and master the terminal like a pro. Whether you’re managing files, networking, or troubleshooting system issues, knowing these commands will make your life easier. Bookmark this guide as a reference, and keep practicing to enhance your Linux skills!
Did we miss any important commands? Let us know in the comments! 🚀
Happy coding!
Suggested Reading:
- 50+ Essential Git Commands (With Downloadable Cheat Sheet)
- How to Buy cPanel Hosting for Your Website
- How to Deploy Laravel Project on cPanel
- How to Remove .html, .php, or Both from URLs
- How to Set Up a MySQL Database & User in cPanel (2 Easy Methods)
- How to Set Up a PostgreSQL Database and User in cPanel
- How to Upload Your Website (in 3 Simple Steps)
- How to Redirect HTTP to HTTPS: Ultimate Guide to Secure Site
- How To Transfer Your Domain: A Step-by-Step Guide