Linux

7 Mins Read

Unlocking the Command Line: 100 Essential Linux Commands for Every User

Voiced by Amazon Polly

Welcome to the world of Linux, where the command line is your best friend! Did you know that Linux powers over 70% of the world’s servers? Whether you’re just starting or looking to sharpen your skills, mastering these commands will significantly enhance your productivity. Below is a curated list of 100 essential Linux commands, organized by category, to help you navigate the command line like a pro.

Transform Your Career with AWS Certifications

  • Advanced Skills
  • AWS Official Curriculum
  • 10+ Hand-on Labs
Enroll Now

1. File Management Commands (20 commands)

Command Description Usage Example Pro Tip
ls Lists files and directories. ls -l Use ls -a to show hidden files.
cd Changes the current directory. cd /path/to/directory Use cd .. to go up one directory.
pwd Prints the current working directory. pwd Combine with ls for a clear view of your location.
mkdir Creates a new directory. mkdir new_folder Use -p to create parent directories.
rmdir Removes an empty directory. rmdir empty_folder Use rm -r to remove non-empty directories.
rm Removes files or directories. rm file.txt Use -i for interactive deletion.
cp Copies files or directories. cp source.txt destination.txt Use -r to copy directories recursively.
mv Moves or renames files or directories. mv oldname.txt newname.txt Use -i to prevent overwriting files.
touch Creates an empty file or updates the timestamp. touch newfile.txt Use -a to change access time only.
cat Concatenates and displays file content. cat file.txt Use -n to number output lines.
head Outputs the first part of files. head -n 10 file.txt Use -c to specify the number of bytes.
tail Outputs the last part of files. tail -n 10 file.txt Use -f to follow file changes in real-time.
find Searches for files in a directory hierarchy. find /path -name “file.txt” Combine with -exec to perform actions on found items.
du Displays disk usage of files and directories. du -h Use -s for summary of total usage.
df Displays disk space usage. df -h Use -T to show filesystem type.
ln Creates hard and symbolic links. ln -s file.txt symlink.txt Use -f to force link creation.
file Determines the file type. file filename Use it on scripts to check if they are executable.
stat Displays detailed information about a file or directory. stat file.txt Useful for checking last access and modification times.
tar Archives files. tar -cvf archive.tar folder/ Use -xvf to extract files from an archive.
zip Compresses files into a ZIP archive. zip archive.zip file.txt Use -r to zip directories recursively.
unzip Extracts files from a ZIP archive. unzip archive.zip Use -d to specify a target directory for extraction.

2. System Information Commands (10 commands)

Command Description Usage Example Pro Tip
uname Prints system information. uname -a Use -r for kernel release version.
top Displays real-time system information. top Press M to sort by memory usage.
htop An interactive process viewer. htop Use F10 to quit and F6 to sort by different columns.
free Displays memory usage. free -h Use -s to update continuously every few seconds.
lscpu Displays CPU architecture information. lscpu Great for checking CPU details at a glance.
lsblk Lists block devices. lsblk Use -f to see filesystem types and labels.
uptime Shows how long the system has been running. uptime Combine with -p for a pretty format.
who Displays who is logged in. who Use -b to show last boot time.
last Shows the last logged in users. last Combine with -n to limit the number of entries shown.
dmesg Prints kernel ring buffer messages. dmesg less

3. Networking Commands (10 commands)

Command Description Usage Example Pro Tip
ping Tests connectivity to a host. ping google.com Use -c to limit the number of pings.
curl Transfers data from or to a server. curl http://example.com Use -O to save files with the same name as the remote file.
wget Downloads files from the web. wget http://example.com/file.zip Use -c to continue incomplete downloads.
ssh Securely connects to a remote machine. ssh user@host Use -i to specify a private key for authentication.
scp Securely copies files between hosts. scp file.txt user@host:/path Use -r for recursive copy of directories.
ftp Transfers files over FTP protocol. ftp example.com Use mget to download multiple files at once.
ifconfig Displays network interface configuration. ifconfig Deprecated; use ip addr instead.
ip Displays/manipulates routing and devices. ip addr show Use ip link to manage network interfaces.
traceroute Traces the route to a network host. traceroute google.com Useful for diagnosing network issues.
netstat Displays network connections and statistics. netstat -tuln Combine with -p to show which processes are using the ports.

4. Process Management Commands (10 commands)

Command Description Usage Example Pro Tip
ps Displays currently running processes. ps aux Use -ef for a full-format listing.
top Displays real-time system processes. top Press k to kill a process directly from top.
htop An interactive process viewer. htop Use F9 to kill processes and F3 to search.
kill Terminates a process by its PID. kill 1234 Use -9 for a forceful kill.
pkill Kills processes by name. pkill firefox Use -f to match against the full command line.
jobs Lists active jobs. jobs Useful for managing background tasks.
bg Resumes a suspended job in the background. bg %1 Use fg to bring it back to the foreground.
fg Brings a background job to the foreground. fg %1 Useful for tasks you’ve suspended.
nice Runs a command with modified scheduling priority. nice -n 10 command Use with -n to set priority between -20 (highest) and 19 (lowest).
renice Alters the priority of running processes. renice 10 -p 1234 Use it to lower or raise the priority of an existing process.

5. User Management Commands (10 commands)

Command Description Usage Example Pro Tip
useradd Creates a new user. useradd newuser Use -m to create a home directory.
usermod Modifies an existing user. usermod -aG group user Use -L to lock a user account.
userdel Deletes a user account. userdel username Use -r to remove the user’s home directory.
passwd Changes a user’s password. passwd username Use passwd -l to lock the account.
groups Displays group memberships for users. groups username Use it to quickly check group assignments.
id Displays user and group IDs. id username Useful for scripting user checks.
su Switches to another user account. su – username Use – to load the target user’s environment.
sudo Executes commands with superuser privileges. sudo command Use visudo to safely edit the sudoers file.
whoami Displays the current logged-in user. whoami Combine with sudo to check current privileges.
chown Changes file ownership. chown user:group file.txt Use -R for recursive changes.

6. Disk Management Commands (10 commands)

Command Description Usage Example Pro Tip
df Displays disk space usage. df -h Use -T to show filesystem types.
du Displays directory size. du -sh /path/to/dir Use -c for a total of all listed directories.
mount Mounts a filesystem. mount /dev/sdb1 /mnt Use -a to mount all filesystems in /etc/fstab.
umount Unmounts a filesystem. umount /mnt Ensure all processes using the mount point are stopped.
fsck Checks and repairs a filesystem. fsck /dev/sdb1 Use -y to automatically answer yes to prompts.
fdisk Manipulates disk partition tables. fdisk -l Use m for help while inside fdisk.
parted Manages disk partitions. parted /dev/sda Use print to view partition layout.
mkfs Creates a filesystem on a partition. mkfs.ext4 /dev/sdb1 Use -L to label the filesystem.
df Displays disk space usage. df -h Combine with -i to check inode usage.
lsblk Lists block devices. lsblk Use -f to see filesystem types and labels.

7. Text Processing Commands (10 commands)

Command Description Usage Example Pro Tip
grep Searches for patterns in text. grep “text” file.txt Use -r to search recursively in directories.
sed Stream editor for filtering and transforming text. sed ‘s/old/new/g’ file.txt Use -i to edit files in-place.
awk A programming language for pattern scanning and processing. awk ‘{print $1}’ file.txt Great for processing structured text files.
sort Sorts lines of text files. sort file.txt Use -n to sort numerically.
uniq Removes duplicate lines from sorted files. uniq file.txt Combine with -c to count occurrences.
cut Removes sections from each line of files. cut -d’:’ -f1 /etc/passwd Use -c to cut by character position.
paste Merges lines of files. paste file1.txt file2.txt Use -d to specify a delimiter.
wc Counts lines, words, and characters. wc file.txt Use -l to count only lines.
diff Compares files line by line. diff file1.txt file2.txt Use -u for a unified format.
tr Translates or deletes characters. tr ‘a-z’ ‘A-Z’ < file.txt Use -d to delete characters.

8. System Monitoring Commands (10 commands)

Command Description Usage Example Pro Tip
top Displays real-time system performance. top Press 1 to view CPU usage per core.
htop An interactive process viewer. htop Use F3 to search for processes.
vmstat Reports virtual memory statistics. vmstat 2 Use it for monitoring system performance over time.
iostat Reports CPU and I/O statistics. iostat -x 2 Use -c to see only CPU stats.
mpstat Reports CPU statistics. mpstat -P ALL Great for monitoring multi-core systems.
sar Collects, reports, or saves system activity information. sar -u 1 3 Useful for historical performance analysis.
free Displays memory usage. free -h Use -s to monitor memory usage over time.
netstat Displays network connections and statistics. netstat -tuln Combine with -p to show the process associated with each connection.
uptime Shows how long the system has been running. uptime Use -p for a human-readable format.
watch Executes a program periodically. watch -n 5 free -h Great for monitoring changes over time.

9. Package Management Commands (10 commands)

Command Description Usage Example Pro Tip
apt Package management for Debian-based systems. sudo apt update Use install to add packages and remove to uninstall.
yum Package manager for Red Hat-based systems. sudo yum install package Use list to see available packages.
dnf Next-generation package manager for Fedora. sudo dnf update Offers improved performance over yum.
pacman Package manager for Arch Linux. sudo pacman -S package Use -R to remove a package.
zypper Package manager for openSUSE. sudo zypper install package Use search to find available packages.
pip Package manager for Python. pip install package Use pip freeze to list installed packages.
gem Package manager for Ruby. gem install package Use list to see installed gems.
npm Package manager for Node.js. npm install package Use update to update installed packages.
snap Package management for snap applications. sudo snap install package Use list to see installed snap packages.
flatpak Package manager for flatpak applications. flatpak install package Use remote-list to see available flatpaks from remotes.

Bonus Round! 🎉 Here are 10 extra commands to supercharge your Linux skills even further!

10. Miscellaneous Commands (10 commands)

Command Description Usage Example Pro Tip
man Displays the manual for commands. man ls Use man -k keyword to search for commands.
history Displays command history. history Use !n to execute the nth command from history.
alias Creates shortcuts for commands. alias ll=’ls -la’ Add aliases to .bashrc for persistence.
echo Displays a line of text. echo “Hello, World!” Use -e to enable interpretation of backslash escapes.
date Displays or sets the system date and time. date Use +%Y-%m-%d to format the output.
clear Clears the terminal screen. clear Combine with Ctrl + L for a quick clear.
shutdown Shuts down the system. shutdown now Use -h for halt and -r for reboot.
reboot Reboots the system. reboot Use -f to force reboot without shutdown.
logout Logs out of the current shell session. logout Use exit to leave any terminal session.
sudo Executes commands with superuser privileges. sudo command Use visudo to edit the sudoers file safely.

Conclusion

Mastering these 100 essential Linux commands will empower you to navigate and control your system efficiently. Whether you’re a beginner or a seasoned pro, these commands will help you manage files, monitor system performance, and configure your Linux environment to your liking.

Feel free to bookmark this guide for quick reference and share it with your fellow Linux enthusiasts!

Earn Multiple AWS Certifications for the Price of Two

  • AWS Authorized Instructor led Sessions
  • AWS Official Curriculum
Get Started Now

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAWS GenAI Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery Partner AWS Microsoft Workload PartnersAmazon EC2 Service Delivery PartnerAmazon ECS Service Delivery PartnerAWS Glue Service Delivery PartnerAmazon Redshift Service Delivery PartnerAWS Control Tower Service Delivery PartnerAWS WAF Service Delivery PartnerAmazon CloudFrontAmazon OpenSearchAWS DMSAWS Systems ManagerAmazon RDS, and many more.

WRITTEN BY Mehar Nafis

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!