Top 90+ Essential Linux Commands Plus Cheat Sheet

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.

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

  1. 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
  1. cd – Change directory
cd /home/user       # Go to /home/user
cd ..               # Go up one directory level
cd ~                # Go to the home directory
  1. pwd – Print working directory
pwd                # Displays the current directory path
  1. mkdir – Create a new directory
mkdir new_folder         # Create a new folder
mkdir -p parent/child    # Create nested directories
  1. rmdir – Remove an empty directory
rmdir empty_folder  # Deletes an empty folder
  1. 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
  1. 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
  1. 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
  1. touch – Create an empty file or update the timestamp
touch newfile.txt     # Create a new empty file
  1. cat – View the contents of a file
cat file.txt          # Display contents of file.txt
  1. more and less – View file contents page by page
more file.txt         # View file contents with pagination
less file.txt         # Similar to more but with better navigation
  1. head and tail – 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
  1. ln – Create symbolic links
ln -s target linkname  # Create a symbolic (soft) link
  1. du – Estimate file and directory space usage
du -sh *              # Display folder sizes in the current directory
  1. df – Display disk space usage
df -h                 # Show disk space in human-readable format
  1. 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
  1. locate – Find files by name using an indexed database
locate filename         # Locate file by name
  1. stat – Display file or file system status
stat file.txt          # Display detailed information about a file

File Permissions and Ownership

  1. 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
  1. 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
  1. chgrp – Change group ownership
chgrp group file.txt   # Change group of the file
  1. umask – Default permission setting for new files
umask 022              # Sets default permission for new files

Text Processing and Manipulation

  1. 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
  1. sed – Stream editor for modifying text
sed 's/old/new/g' file.txt   # Replace 'old' with 'new' in file
  1. awk – Pattern scanning and text processing
awk '{print $1}' file.txt    # Print the first column of a file
  1. sort – Sort lines of text files
sort file.txt               # Sort lines in ascending order
sort -r file.txt            # Sort lines in descending order
  1. uniq – Report or omit repeated lines
uniq file.txt               # Remove duplicate lines
  1. diff – Compare files line by line
diff file1.txt file2.txt    # Show differences between files
  1. wc – Word, line, and byte count
wc file.txt                 # Display word, line, and byte count
wc -l file.txt              # Line count only
  1. cut – Cut out selected portions of a file
cut -d':' -f1 /etc/passwd   # Display first field using ':' delimiter
  1. paste – Merge lines of files
paste file1.txt file2.txt   # Merge lines side by side
  1. tr – Translate or delete characters
tr 'a-z' 'A-Z' < file.txt   # Convert lowercase to uppercase
  1. split – Split a file into pieces
split -b 10M largefile part_  # Split into 10MB pieces

Networking Commands

  1. ping – Check connectivity to a host
ping google.com            # Check if Google is reachable
ping -c 4 google.com       # Send 4 packets and stop
  1. ifconfig – Display network interfaces (Deprecated, use ip command)
ifconfig                   # Show all network interfaces
  1. 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
  1. hostname – Display or set the system’s hostname
hostname                   # Show current hostname
hostnamectl set-hostname newname  # Set a new hostname
  1. 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
  1. curl – Transfer data from or to a server
curl http://example.com          # Fetch webpage content
curl -O http://example.com/file.zip # Download file
  1. 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
  1. 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
  1. ftp – File Transfer Protocol client
ftp ftp.example.com               # Connect to FTP server
  1. netstat – Network statistics
netstat -tuln                     # Show all listening ports
netstat -pnltu                    # Display active connections
  1. ss – Display socket statistics (Replacement for netstat)
ss -tuln                         # Show listening ports
ss -s                            # Summarize network statistics
  1. nslookup – Query internet name servers interactively
nslookup google.com               # Get DNS information for a domain
  1. dig – DNS lookup
dig google.com                    # Detailed DNS information
  1. traceroute – Trace the route packets take to a network host
traceroute google.com             # Trace the route to a host
  1. whois – Get domain registration details
whois example.com                 # Get WHOIS info for a domain
  1. nmcli – NetworkManager command-line interface
nmcli device status               # Show network device status
nmcli connection show             # List all connections

System Monitoring and Performance

  1. top – Display real-time running processes
top                              # Display dynamic process info
  1. htop – Interactive process viewer (Enhanced version of top)
htop                             # Display real-time process viewer
  1. ps – Display snapshot of current processes
ps aux                           # Show all running processes
ps -ef                           # Detailed process listing
  1. kill – Send signal to a process
kill PID                         # Terminate a process by PID
kill -9 PID                      # Force kill a process
  1. killall – Kill processes by name
killall firefox                  # Kill all instances of Firefox
  1. pkill – Send signal to processes based on name or other attributes
pkill -u user                    # Kill all processes by user
  1. jobs – List background jobs
jobs                             # List active background jobs
  1. bg – Resume a job in the background
bg %1                            # Continue job in background
  1. fg – Bring a job to the foreground
fg %1                            # Bring background job to foreground
  1. nice – Start a process with a specific priority
nice -n 10 command                # Start process with priority
  1. renice – Change running process priority
renice 15 PID                    # Adjust priority of running process
  1. uptime – Tell how long the system has been running
uptime                           # Show uptime and load average
  1. free – Display memory usage
free -h                          # Show memory in human-readable format
  1. vmstat – Report virtual memory statistics
vmstat 5                         # Display CPU and memory stats every 5 seconds
  1. iostat – CPU and input/output statistics
iostat                           # Display CPU and I/O stats
  1. dmesg – Print kernel and driver messages
dmesg | tail                     # Show latest kernel messages
  1. pgrep – List processes by name
pgrep apache2                    # Find process IDs by name
  1. screen – Terminal multiplexer for session management
screen -S session_name            # Start a new screen session

Package Management

  1. 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
  1. yum – Package manager (CentOS/RHEL)
yum update                        # Update all packages
yum install package_name          # Install a package
yum remove package_name           # Remove a package
  1. 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

  1. useradd – Create a new user
useradd newuser                 # Add a new user
  1. usermod – Modify user details
usermod -aG sudo newuser         # Add user to sudo group
  1. userdel – Delete a user account
userdel newuser                 # Remove a user
  1. passwd – Change user password
passwd username                 # Change password for user
  1. whoami – Currently logged in user
whoami                            # See the currently logged in user
  1. cat /etc/passwd – Display a list of all users with additional info
cat /etc/passwd           # List of all users with additional info
  1. usermod -d – Home directory of a user
usermod -d /home/test username         # Change the home directory of a user
  1. groupadd – Create a new group
groupadd developers              # Create a new group
  1. groupdel – Delete a group
groupdel developers              # Delete a group
  1. groups – Show user’s groups
groups username                  # Display groups for user
  1. su – Switch user account
su - username                    # Switch to another user
  1. sudo – Execute commands as superuser
sudo apt update                  # Run command with root privileges

Disk Management

  1. mount – Mount file systems
mount /dev/sda1 /mnt              # Mount a partition
  1. umount – Unmount file systems
umount /mnt                      # Unmount a partition
  1. fsck – File system consistency check
fsck /dev/sda1                   # Check and repair filesystem
  1. blkid – Locate/print block device attributes
blkid                            # Display UUIDs of storage devices
  1. lsblk – List information about block devices
lsblk                            # Show all block devices
  1. fdisk – Partition table manipulator
fdisk -l                         # List all partitions

SSH and Remote Connections

  1. ssh-keygen – Generate SSH keys
ssh-keygen                       # Generate a new SSH key pair
  1. 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
  1. rsync – Remote file sync
rsync -avz /local/dir user@remote:/remote/dir

Advanced Commands

  1. 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
  1. gzip and gunzip – Compress and decompress files
gzip file.txt                    # Compress file
gunzip file.txt.gz               # Decompress file
  1. chroot – Change root directory
chroot /new/root                 # Change root directory
  1. tmux – Advanced terminal multiplexer
tmux new -s session_name          # Create a new tmux session

Essential Linux Commands: A Quick Reference Table

CommandDescriptionExample
lsList directory contentsls -l (Detailed list)
cdChange directorycd /var/www
pwdPrint current working directorypwd
mkdirCreate a new directorymkdir new_folder
rmdirRemove an empty directoryrmdir old_folder
cpCopy files or directoriescp file.txt /backup/
mvMove or rename filesmv old.txt new.txt
rmRemove files or directoriesrm file.txt
catConcatenate and display file contentcat file.txt
moreView file content page by pagemore file.txt
lessSimilar to more, but fasterless file.txt
headView the first lines of a filehead -n 10 file.txt
tailView the last lines of a filetail -n 10 file.txt
touchCreate an empty filetouch newfile.txt
findSearch for files and directoriesfind / -name "file.txt"
grepSearch text using patternsgrep "error" logfile.txt
locateFind files by namelocate config.php
echoDisplay text or variablesecho "Hello World"
chmodChange file permissionschmod 755 script.sh
chownChange file owner and groupchown user:group file.txt
lnCreate links (hard and symbolic)ln -s target linkname
dfDisplay disk space usagedf -h (Human-readable)
duShow directory space usagedu -sh /var/log
mountMount file systemsmount /dev/sda1 /mnt
umountUnmount file systemsumount /mnt
psDisplay running processesps aux
topReal-time process monitoringtop
htopInteractive process viewerhtop
killTerminate a processkill 1234 (By PID)
killallKill processes by namekillall firefox
serviceManage system servicesservice apache2 restart
systemctlControl systemd servicessystemctl status nginx
crontabSchedule recurring taskscrontab -e (Edit tasks)
uptimeDisplay system uptimeuptime
whoShow who is logged inwho
wDisplay who is logged in and their activityw
pingCheck network connectivityping google.com
ifconfigDisplay network interfaces (Deprecated)ifconfig
ipNetwork configurationip a (Show interfaces)
hostnameShow or set hostnamehostnamectl set-hostname newname
wgetDownload files from the webwget http://example.com/file.zip
curlTransfer data from/to servercurl http://example.com
sshSecure remote loginssh user@remote_host
scpSecurely copy filesscp file.txt user@remote:/path/
ftpFile Transfer Protocol clientftp ftp.example.com
netstatNetwork statisticsnetstat -tuln
ssDisplay socket statisticsss -tuln
nslookupDNS lookupnslookup google.com
digAdvanced DNS querydig google.com
tracerouteTrace packet routetraceroute google.com
whoisDomain registration detailswhois example.com
nmcliNetworkManager CLInmcli device status
freeDisplay memory usagefree -h
vmstatVirtual memory statisticsvmstat 5
iostatCPU and I/O statisticsiostat
dmesgKernel and driver messages`dmesg
aptPackage manager (Debian/Ubuntu)apt install package_name
yumPackage manager (CentOS/RHEL)yum install package_name
dnfNext-gen package managerdnf install package_name
tarArchive filestar -cvf archive.tar /path/
gzipCompress filesgzip file.txt
gunzipDecompress filesgunzip file.txt.gz
zipCreate ZIP archivezip archive.zip file1 file2
unzipExtract ZIP archiveunzip archive.zip
ssh-keygenGenerate SSH keysssh-keygen
ssh-copy-idInstall SSH key on remotessh-copy-id user@remote_host
rsyncRemote file syncrsync -avz /src/ user@remote:/dest/
fsckFile system check and repairfsck /dev/sda1
blkidBlock device attributesblkid
lsblkList block deviceslsblk
fdiskPartition table manipulatorfdisk -l
chrootChange root directorychroot /new/root
aliasCreate command shortcutsalias ll='ls -la'
historyCommand historyhistory
manDisplay manual for commandsman ls
helpHelp for built-in commandshelp cd
exitLogout or close terminalexit

🚀 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.

Essential Linux Commands Cheat Sheet

Get the 2560×1440 wallpaper linux commands cheat sheet

Download The Linux Cheat Sheet

❓Frequently Asked Questions (FAQs) About Linux Commands

🎯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:

Picture of James Wilson

James Wilson

For over 10 years, James has been working in the tech industry. He's an expert in areas like software development, cybersecurity, and cloud computing. He understands the challenges and opportunities that new tech companies face, and he's known for coming up with creative solutions to help them succeed.

Leave a Reply

Enjoy 20% Off Your First Order!

Use promo code WELCOME at checkout to claim your exclusive discount.

Get 20% OFF on your first order

Oh hi there! It’s nice to meet you.

Please Kindly, sign up to receive awesome content in your inbox, every month.