Table of Contents[Hide][Show]
Top 50 Linux Commands You Need to Know+−
- 1. ls – List Directories and Files
- 2. pwd – Print Working Directory
- 3. cd – Change Directory
- 4. mkdir – Create Directories
- 5. mv – Move or Rename Files
- 6. cp – Copy Files and Directories
- 7. rm – Remove Files and Directories
- 8. touch – Create Empty Files
- 9. ln – Create Symbolic Links
- 10. clear – Clear Terminal Display
- 11. whoami – Get the Active Username
- 12. tar – Extract and Compress Files
- 13. grep – Search for a String in an Output
- 14. head – Display the First Few Lines of a File
- 15. tail – Display the Last Few Lines of a File
- 16. cat – Display File Contents on the Terminal
- 17. echo – Print Text in the Terminal
- 18. less – View Large Files Page by Page
- 19. man – Access Linux Manual Pages
- 20. uname – Get System Information
- 21. diff – Find the Difference Between Two Files
- 22. cmp – Check If Two Files Are Identical
- 23. comm – Compare Sorted Files Line by Line
- 24. sort – Sort File Contents Alphabetically or Numerically
- 25. export – Set and Export Environment Variables
- 26. zip – Compress Files into a Zip Archive
- 27. unzip – Extract Zip Files in Linux
- 28. ssh – Secure Shell for Remote Access
- 29. service – Start, Stop, and Manage System Services
- 30. ps – Display Active Processes
- 31. kill and killall – Terminate Processes by ID or Name
- 32. df – Display Disk Filesystem Information
- 33. mount – Mount File Systems in Linux
- 34. chmod – Change File Permissions
- 35. chown – Change File and Directory Ownership
- 36. ifconfig – Display Network Interfaces and IP Addresses
- 37. traceroute – Trace Network Hops to a Destination
- 38. wget – Directly Download Files from the Internet
- 39. ufw – Simple Firewall Management in Linux
- 40. iptables – Advanced Firewall Management
- 41. apt, pacman, yum, rpm – Package Managers Based on Distribution
- 42. sudo – Execute Commands as a Superuser
- 43. cal – View a Command-Line Calendar
- 44. alias – Create Shortcuts for Commands
- 45. dd – Create Bootable USBs and Clone Disks
- 46. whereis – Locate Command Binaries, Source, and Manuals
- 47. whatis – Find What a Command is Used For
- 48. top – Monitor Active Processes in Real-Time
- 49. useradd and usermod – Add or Modify Users
- 50. passwd – Change User Passwords
- Conclusion
Linux is a powerful operating system that offers unmatched control and flexibility. Whether you’re a beginner or an experienced user, mastering essential Linux commands can significantly improve your efficiency.
In this guide, we will explore the Top 50 Linux Commands that every user should know. These commands cover file management, process control, networking, and system monitoring, helping you navigate the Linux environment with ease.
By understanding these fundamental commands, you can optimize your workflow and perform complex tasks efficiently. Let’s dive into the Top 50 Linux Commands that will enhance your command-line experience.
Top 50 Linux Commands You Need to Know
1. ls
– List Directories and Files
The ls
command is one of the most frequently used Linux commands, allowing users to list files and directories within a given location. By default, running ls
in the terminal displays the contents of the current directory. However, it can be combined with options to provide more detailed information.
ls -l
→ Displays a long format listing with details such as permissions, ownership, size, and modification date.ls -a
→ Lists all files, including hidden ones (those starting with.
).ls -lh
→ Shows file sizes in a human-readable format (e.g., MB, GB).
Using ls
effectively helps users navigate the filesystem and quickly locate files. It is a fundamental command that enhances productivity and system awareness.
2. pwd
– Print Working Directory
The pwd
(Print Working Directory) command is used to display the absolute path of the current working directory. This is particularly useful when working in deep directory structures or when managing files from the command line.
Example usage:
pwd
This will return an output like this:
/home/user/Documents
pwd -L
→ Displays the logical path, including symbolic links.pwd -P
→ Shows the physical path, resolving symbolic links.
Knowing your current location in the filesystem is essential for navigating effectively, making pwd
a crucial command for Linux users.
3. cd
– Change Directory
The cd
(Change Directory) command allows users to navigate through directories in the Linux filesystem. It is one of the most basic yet essential commands for file management.
Basic usage examples:
cd Documents/
→ Moves into the “Documents” directory.cd ..
→ Moves up one level (to the parent directory).cd ~
orcd
→ Moves to the home directory.cd /var/www/html/
→ Navigates directly to an absolute path.
Using cd
efficiently helps users switch between directories quickly, improving workflow and command-line navigation.
4. mkdir
– Create Directories
The mkdir
(Make Directory) command allows users to create new directories in Linux. It is widely used for organizing files and structuring data efficiently.
Example usage:
mkdir new_folder
This creates a directory named new_folder
in the current location.
Additional options:
mkdir -p parent/child
→ Creates a directory structure, including parent directories if they don’t exist.mkdir -m 755 secure_folder
→ Creates a directory with specific permissions (755 in this case).
By using mkdir
, users can manage file organization effectively and automate directory creation in scripts.
5. mv
– Move or Rename Files
The mv
(Move) command is used to move or rename files and directories in Linux. Unlike cp
, which copies files, mv
transfers them from one location to another without duplication.
Examples:
mv file1.txt /home/user/Documents/
→ Movesfile1.txt
to the Documents directory.mv oldname.txt newname.txt
→ Renamesoldname.txt
tonewname.txt
.mv * /backup/
→ Moves all files from the current directory to/backup/
.
mv
is an essential tool for organizing files, renaming them efficiently, and maintaining an orderly filesystem.
6. cp
– Copy Files and Directories
The cp
(Copy) command in Linux allows users to duplicate files and directories. Unlike mv
, which moves files, cp
creates a separate copy while keeping the original intact. This command is essential for backing up files or creating duplicates for modifications.
Basic usage examples:
cp file1.txt backup/
This copies file1.txt
into the backup
directory.
Additional options:
cp -r directory1/ directory2/
→ Copies a directory and all its contents.cp -i file.txt backup/
→ Prompts before overwriting an existing file.cp -u file.txt backup/
→ Copies only if the file is newer than the destination version.
Using cp
ensures safe duplication and backup of important data.
7. rm
– Remove Files and Directories
The rm
(Remove) command permanently deletes files and directories. It is a powerful command that should be used cautiously, as deleted files cannot be recovered easily.
Example usage:
rm file.txt
This deletes file.txt
from the current directory.
Additional options:
rm -r folder_name/
→ Recursively deletes a directory and its contents.rm -f file.txt
→ Forces deletion without confirmation.rm -i file.txt
→ Prompts for confirmation before deleting.
Accidental deletions can be prevented by using -i
for confirmation. For safety, users can enable a “trash” mechanism instead of direct deletion.
8. touch
– Create Empty Files
The touch
command is used to create new, empty files or update the timestamps of existing ones. It is especially useful for quickly generating placeholder files in a directory.
Example usage:
touch newfile.txt
This creates an empty file named newfile.txt
.
Additional options:
touch file1 file2 file3
→ Creates multiple files at once.touch -c file.txt
→ Prevents creation if the file doesn’t exist but updates its timestamp if it does.touch -t YYYYMMDDhhmm file.txt
→ Sets a custom timestamp for a file.
touch
is commonly used in scripting and automation to prepare files for editing or ensure they exist before processing.
9. ln
– Create Symbolic Links
The ln
command creates links between files, with symbolic (soft) links being the most common. These links act as shortcuts, pointing to another file or directory.
Example usage:
ln -s /home/user/documents/file.txt shortcut.txt
This creates a symbolic link (shortcut.txt
) pointing to file.txt
.
Types of links:
- Hard link (
ln file1 file2
) → Creates a second reference to the same file, sharing storage space. - Symbolic link (
ln -s target link
) → Creates a pointer to the original file but does not duplicate content.
Symbolic links are useful for organizing files, reducing redundancy, and improving accessibility across directories.
10. clear
– Clear Terminal Display
The clear
command is used to clear the terminal screen, making it easier to focus on new outputs. It does not delete anything but removes previous command history from view.
Example usage:
clear
This immediately refreshes the terminal window.
Alternative methods:
- Ctrl + L → Moves the prompt to a new line, similar to
clear
. - reset → Resets the terminal entirely, clearing all settings and outputs.
The clear
command enhances readability and keeps the workspace uncluttered, making it especially useful during long command-line sessions.
11. whoami
– Get the Active Username
The whoami
command is a simple but useful tool that displays the currently logged-in user on a Linux system. It is especially helpful in multi-user environments where different users may access the system.
Example usage:
whoami
If the logged-in user is john
, the output will be:
john
This command is useful when working with remote servers or switching between multiple user accounts using su
(switch user). It helps verify whether the user has the correct privileges to perform certain operations.
Alternative commands:
id -un
→ Also displays the current username.who
→ Lists all logged-in users.echo $USER
→ Prints the username from environment variables.
Using whoami
ensures that commands are executed with the correct user privileges, preventing permission-related issues.
12. tar
– Extract and Compress Files
The tar
(Tape Archive) command is used for compressing and extracting files in Linux. It is one of the most commonly used commands for managing backups and packaging multiple files into a single archive.
Basic usage:
tar -cvf archive.tar file1 file2 directory/
-c
→ Creates an archive.-v
→ Shows verbose output (lists files being archived).-f
→ Specifies the archive file name.
To extract files from a .tar
archive:
tar -xvf archive.tar
-x
→ Extracts files.
For compressed archives (.tar.gz
or .tgz
):
tar -czvf archive.tar.gz file1 file2
tar -xzvf archive.tar.gz
The tar
command is essential for data backup, file sharing, and efficient storage management.
13. grep
– Search for a String in an Output
The grep
(Global Regular Expression Print) command searches for a specific pattern within text files or command outputs. It is commonly used for filtering logs, configuration files, and large datasets.
Example usage:
grep "error" logfile.txt
This searches for the word “error” in logfile.txt
and prints matching lines.
Common options:
grep -i "warning" logfile.txt
→ Case-insensitive search.grep -r "keyword" /var/log/
→ Searches recursively in a directory.grep -n "failed" logfile.txt
→ Shows line numbers with matches.
grep
is a powerful tool for quickly locating information, making it invaluable for troubleshooting and data analysis.
14. head
– Display the First Few Lines of a File
The head
command prints the first few lines of a file, making it useful for previewing large text files without opening them entirely.
Example usage:
head filename.txt
By default, it shows the first 10 lines. To specify a different number of lines:
head -n 5 filename.txt
This displays the first 5 lines.
head
is often used alongside commands like grep
and tail
to analyze logs, configuration files, and reports efficiently.
15. tail
– Display the Last Few Lines of a File
The tail
command is similar to head
but retrieves lines from the end of a file. It is especially useful for monitoring log files in real-time.
Example usage:
tail filename.txt
By default, it shows the last 10 lines. To display a different number of lines:
tail -n 20 filename.txt
For real-time monitoring (e.g., server logs):
tail -f /var/log/syslog
The -f
flag allows continuous monitoring as new lines are added, making tail
essential for debugging and system administration.
16. cat
– Display File Contents on the Terminal
The cat
(concatenate) command is used to view, create, and combine files in Linux. It is one of the most frequently used commands for quickly displaying file contents directly in the terminal.
Basic usage:
cat filename.txt
This prints the contents of filename.txt
on the terminal.
Additional options:
cat file1.txt file2.txt > merged.txt
→ Merges two files into one.cat -n filename.txt
→ Displays line numbers along with file content.cat > newfile.txt
→ Creates a new file (Ctrl+D to save).
While cat
is useful for small files, it is not ideal for large ones. In such cases, less
or more
is preferred.
17. echo
– Print Text in the Terminal
The echo
command prints text or variables to the terminal. It is often used in scripts to display messages or manipulate environment variables.
Basic usage:
echo "Hello, World!"
This outputs:
Hello, World!
Other applications:
echo $USER
→ Prints the current username.echo "PATH variable is: $PATH"
→ Displays environment variables.echo "Hello" > file.txt
→ Writes text to a file (overwrites existing content).
echo
is widely used in shell scripting for automation and debugging.
18. less
– View Large Files Page by Page
The less
command is used to view large files one screen at a time, making it more efficient than cat
for lengthy content. Unlike cat
, less
allows scrolling both forward and backward.
Example usage:
less largefile.txt
Useful navigation commands within less
:
- Arrow keys / Page Up / Page Down → Scroll through the file.
- q → Quit
less
. - /keyword → Search for a word inside the file.
Compared to more
, less
provides more flexibility by allowing backward navigation, making it a preferred choice for reading log files and long documents.
19. man
– Access Linux Manual Pages
The man
(manual) command provides detailed documentation for Linux commands, explaining their usage, options, and examples.
Basic usage:
man ls
This opens the manual page for the ls
command.
Useful options:
man -k keyword
→ Searches for commands related to a keyword.man 5 passwd
→ Displays manual section 5 (configuration files) forpasswd
.
Each manual entry is divided into sections (e.g., user commands, system calls, configuration files). Using man
is essential for understanding complex commands and troubleshooting.
20. uname
– Get System Information
The uname
command provides basic details about the operating system, including kernel version and system architecture.
Basic usage:
uname
This prints the system name (e.g., Linux).
Additional options:
uname -a
→ Displays all available system information.uname -r
→ Shows the kernel version.uname -m
→ Prints the system’s architecture (e.g., x86_64).
uname
is useful for system diagnostics and verifying OS details, especially when managing multiple Linux distributions.
21. diff
– Find the Difference Between Two Files
The diff
(difference) command compares two files line by line and highlights differences. It is commonly used by developers to track code changes and by system administrators to compare configuration files.
Basic usage:
diff file1.txt file2.txt
This displays the differences between file1.txt
and file2.txt
.
Useful options:
diff -y file1.txt file2.txt
→ Displays differences side by side.diff -u file1.txt file2.txt
→ Shows differences in a unified format, useful for patching.diff -r dir1/ dir2/
→ Compares two directories recursively.
The diff
command is essential for version control, debugging, and file synchronization tasks.
22. cmp
– Check If Two Files Are Identical
The cmp
(compare) command checks whether two files are identical and, if not, reports the first difference. Unlike diff
, cmp
does not display line-by-line variations but instead reports the byte where the files diverge.
Basic usage:
cmp file1.txt file2.txt
If the files are identical, there will be no output. If they differ, cmp
will display something like:
file1.txt file2.txt differ: byte 15, line 3
Useful options:
cmp -l file1.txt file2.txt
→ Lists all differing bytes.cmp -s file1.txt file2.txt
→ Silent mode (returns exit status only).
cmp
is useful when checking binary files, verifying backups, or ensuring file integrity.
23. comm
– Compare Sorted Files Line by Line
The comm
command combines aspects of both diff
and cmp
but requires sorted input. It compares two files and outputs three columns:
- Unique lines from the first file.
- Unique lines from the second file.
- Common lines found in both.
Basic usage:
comm file1.txt file2.txt
Useful options:
comm -1 file1.txt file2.txt
→ Suppresses unique lines from the first file.comm -2 file1.txt file2.txt
→ Suppresses unique lines from the second file.comm -3 file1.txt file2.txt
→ Shows only differences, ignoring common lines.
comm
is useful for analyzing datasets, filtering log files, and comparing sorted lists.
24. sort
– Sort File Contents Alphabetically or Numerically
The sort
command organizes file contents in ascending or descending order, making data easier to analyze.
Basic usage:
sort filename.txt
This sorts the file alphabetically.
Useful options:
sort -r filename.txt
→ Sorts in reverse order.sort -n numbers.txt
→ Sorts numbers correctly (instead of lexicographically).sort -u filename.txt
→ Removes duplicates while sorting.
The sort
command is widely used in data processing, database management, and scripting.
25. export
– Set and Export Environment Variables
The export
command in Linux is used to define and share environment variables with child processes. It is essential for configuring system settings and software environments.
Basic usage:
export VAR_NAME="Hello, Linux!"
This sets the variable VAR_NAME
, making it available to all processes in the session.
Useful options:
export -p
→ Lists all exported variables.export PATH=$PATH:/new/directory
→ Appends a new directory to the systemPATH
.unset VAR_NAME
→ Removes an exported variable.
The export
command is crucial for managing shell configurations, setting up development environments, and running scripts with predefined variables.
26. zip
– Compress Files into a Zip Archive
The zip
command is used to compress files and directories into a .zip
archive, reducing file size and making data easier to share or store. It is widely used for backups and file transfers.
Basic usage:
zip archive.zip file1.txt file2.txt
This creates archive.zip
containing file1.txt
and file2.txt
.
Useful options:
zip -r archive.zip directory/
→ Recursively zips a directory.zip -e secure.zip file.txt
→ Creates an encrypted zip file.zip -9 archive.zip file.txt
→ Uses maximum compression.
The zip
command is essential for managing and distributing files efficiently.
27. unzip
– Extract Zip Files in Linux
The unzip
command extracts .zip
archives, restoring files to their original form.
Basic usage:
unzip archive.zip
This extracts all contents into the current directory.
Useful options:
unzip -d /path/to/folder archive.zip
→ Extracts to a specific directory.unzip -l archive.zip
→ Lists files inside a zip archive.unzip -o archive.zip
→ Overwrites existing files without confirmation.
The unzip
command is crucial for handling compressed files downloaded from the internet or received via email.
28. ssh
– Secure Shell for Remote Access
The ssh
(Secure Shell) command allows users to securely connect to remote Linux servers over a network, enabling remote administration and file transfers.
Basic usage:
ssh user@remote-server
This logs into remote-server
as user
.
Useful options:
ssh -p 2222 user@remote-server
→ Connects using a custom port.ssh -i key.pem user@remote-server
→ Connects using an SSH key instead of a password.ssh -X user@remote-server
→ Enables remote GUI applications.
ssh
is widely used in system administration, cloud computing, and DevOps workflows.
29. service
– Start, Stop, and Manage System Services
The service
command allows users to start, stop, restart, and check the status of system services in Linux. It is commonly used to manage background processes such as web servers, databases, and networking services.
Basic usage:
service apache2 start
This starts the Apache web server.
Useful options:
service apache2 stop
→ Stops the service.service apache2 restart
→ Restarts the service.service apache2 status
→ Checks the service status.
While service
works on older Linux distributions, modern systems often use systemctl
instead.
30. ps
– Display Active Processes
The ps
(Process Status) command lists currently running processes, helping users monitor system activity and troubleshoot performance issues.
Basic usage:
ps
This shows active processes for the current session.
Useful options:
ps aux
→ Displays all running processes with details.ps -ef
→ Shows a detailed process tree.ps aux | grep apache
→ Searches for a specific process (e.g., Apache).
The ps
command is essential for system monitoring, troubleshooting, and managing resource-intensive processes.
31. kill
and killall
– Terminate Processes by ID or Name
The kill
and killall
commands are used to stop running processes in Linux. The kill
command terminates a process by its Process ID (PID), while killall
stops all processes with a given name.
Basic usage:
kill 1234
This terminates the process with PID 1234.
killall firefox
This stops all firefox
processes.
Useful options:
kill -9 1234
→ Forcefully kills a process (SIGKILL).killall -9 chrome
→ Kills allchrome
processes.kill -l
→ Lists all available signal types.
These commands are essential for stopping unresponsive applications or managing system resources.
32. df
– Display Disk Filesystem Information
The df
(disk free) command provides information about disk usage, showing available and used space on mounted file systems.
Basic usage:
df -h
This displays disk usage in a human-readable format (e.g., GB, MB).
Useful options:
df -T
→ Shows file system types.df -i
→ Displays inode usage.
The df
command is useful for monitoring disk space and preventing storage issues.
33. mount
– Mount File Systems in Linux
The mount
command attaches a file system to a specified directory, allowing access to external drives, network shares, and ISO images.
Basic usage:
sudo mount /dev/sdb1 /mnt/usb
This mounts a USB drive (/dev/sdb1
) to /mnt/usb
.
Useful options:
mount -t ext4 /dev/sda1 /mnt/disk
→ Mounts an ext4 file system.mount -o ro /dev/cdrom /mnt/cd
→ Mounts as read-only.umount /mnt/usb
→ Unmounts the device.
The mount
command is critical for managing external storage and network file systems.
34. chmod
– Change File Permissions
The chmod
(change mode) command modifies file and directory permissions, controlling read, write, and execute access.
Basic usage:
chmod 755 script.sh
This grants the owner full permissions and read-execute rights to others.
Useful options:
chmod +x script.sh
→ Makes a file executable.chmod -R 777 folder/
→ Grants full access to a directory and its contents.chmod u=rwx, g=rx, o=r file.txt
→ Uses symbolic notation to set permissions.
chmod
is crucial for security and access control in multi-user environments.
35. chown
– Change File and Directory Ownership
The chown
(change owner) command assigns ownership of files and directories to specific users or groups.
Basic usage:
sudo chown user:group file.txt
This assigns user
and group
as the new owners of file.txt
.
Useful options:
sudo chown -R user:group directory/
→ Changes ownership recursively.chown :group file.txt
→ Changes only the group ownership.ls -l file.txt
→ Verifies ownership changes.
chown
is essential for managing user permissions and ensuring proper access control.
36. ifconfig
– Display Network Interfaces and IP Addresses
The ifconfig
(interface configuration) command is used to display and configure network interfaces in Linux. It shows essential network details such as IP addresses, MAC addresses, and interface status.
Basic usage:
ifconfig
This lists all active network interfaces along with their assigned IP addresses.
Useful options:
ifconfig eth0
→ Displays details for theeth0
network interface.ifconfig eth0 up
→ Activates the interface.ifconfig eth0 down
→ Disables the interface.
While ifconfig
is still available in some Linux distributions, it has been replaced by the ip
command in modern systems (ip addr show
).
37. traceroute
– Trace Network Hops to a Destination
The traceroute
command maps the path packets take from your system to a specified destination, helping diagnose network issues.
Basic usage:
traceroute google.com
This displays the network hops between your system and google.com
, showing response times for each.
Useful options:
traceroute -n google.com
→ Displays numerical IP addresses instead of resolving hostnames.traceroute -m 15 google.com
→ Limits the number of hops to 15.
traceroute
is useful for detecting latency issues and troubleshooting slow network connections.
38. wget
– Directly Download Files from the Internet
The wget
command downloads files from the internet via HTTP, HTTPS, or FTP, making it useful for automation and bulk downloads.
Basic usage:
wget https://example.com/file.zip
This downloads file.zip
from the given URL.
Useful options:
wget -c https://example.com/file.zip
→ Resumes an interrupted download.wget -r https://example.com/folder/
→ Recursively downloads an entire directory.wget --limit-rate=500k https://example.com/file.zip
→ Limits download speed to 500 KB/s.
wget
is essential for script-based file retrieval, software installations, and data mirroring.
39. ufw
– Simple Firewall Management in Linux
The ufw
(Uncomplicated Firewall) command is a user-friendly tool for managing firewall rules in Linux, providing an easy interface for controlling network traffic.
Basic usage:
sudo ufw enable
This enables the firewall.
Useful options:
sudo ufw status
→ Checks firewall rules and status.sudo ufw allow 22/tcp
→ Allows SSH (port 22) traffic.sudo ufw deny 80
→ Blocks traffic on port 80.
ufw
is widely used in Ubuntu-based systems for securing servers and managing network access.
40. iptables
– Advanced Firewall Management
The iptables
command provides a powerful firewall for controlling incoming and outgoing traffic on Linux systems. It is the foundation for many firewall tools, including ufw
.
Basic usage:
sudo iptables -L
This lists existing firewall rules.
Useful options:
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
→ Allows SSH traffic.sudo iptables -A INPUT -p tcp --dport 80 -j DROP
→ Blocks HTTP traffic.sudo iptables -F
→ Flushes (removes) all rules.
While powerful, iptables
requires careful rule management, making tools like ufw
more beginner-friendly.
41. apt
, pacman
, yum
, rpm
– Package Managers Based on Distribution
Linux distributions use different package managers to install, update, and remove software:
apt
(Advanced Package Tool) → Used in Debian-based distros like Ubuntu.sudo apt update && sudo apt upgrade
Updates and upgrades all installed packages.pacman
→ The package manager for Arch Linux.sudo pacman -Syu
Syncs and updates packages.yum
(Yellowdog Updater, Modified) → Used in older Red Hat-based systems like CentOS 7.sudo yum install package-name
Installs a package.rpm
(Red Hat Package Manager) → Handles.rpm
packages.sudo rpm -ivh package.rpm
Installs an RPM package.
Each package manager simplifies software management based on the Linux distribution.
42. sudo
– Execute Commands as a Superuser
The sudo
(superuser do) command allows users to run commands with elevated privileges, essential for system administration.
Basic usage:
sudo apt update
Runs apt update
with root privileges.
Useful options:
sudo !!
→ Repeats the last command with sudo.sudo -s
→ Starts a root shell session.sudo visudo
→ Edits the sudoers file for user permissions.
Using sudo
ensures secure system modifications while preventing unauthorized changes.
43. cal
– View a Command-Line Calendar
The cal
command displays a calendar in the terminal, showing the current month by default.
Basic usage:
cal
Displays the current month’s calendar.
Useful options:
cal 2025
→ Shows the calendar for 2025.cal -3
→ Displays the previous, current, and next month.ncal -w
→ Shows a week-based calendar format.
The cal
command is handy for checking dates without opening a GUI application.
44. alias
– Create Shortcuts for Commands
The alias
command defines custom shortcuts for frequently used commands, improving efficiency.
Basic usage:
alias ll='ls -lah'
Creates an alias ll
for listing files in long format with hidden files.
Useful options:
alias update='sudo apt update && sudo apt upgrade -y'
→ Automates system updates.unalias ll
→ Removes an alias.alias
→ Lists all active aliases.
alias
is excellent for simplifying complex or repetitive commands.
45. dd
– Create Bootable USBs and Clone Disks
The dd
command is a powerful tool for copying and converting data, often used to create bootable USB drives.
Basic usage:
sudo dd if=ubuntu.iso of=/dev/sdb bs=4M status=progress
Writes the ubuntu.iso
image to a USB drive (/dev/sdb
).
Useful options:
dd if=/dev/sda of=backup.img
→ Creates a disk backup.dd if=/dev/zero of=file.img bs=1M count=100
→ Creates a 100MB empty file.dd if=file.img of=/dev/sdb
→ Restores a disk image.
Caution: dd
is destructive—incorrect usage can erase disks permanently.
46. whereis
– Locate Command Binaries, Source, and Manuals
The whereis
command helps locate executables, source code, and manual pages for installed programs.
Basic usage:
whereis ls
Displays the locations of ls
binaries and manuals.
Useful options:
whereis -b python
→ Shows only the binary path.whereis -m man
→ Displays only the manual path.whereis -s gcc
→ Shows only source files.
whereis
is useful for finding command locations and debugging missing packages.
47. whatis
– Find What a Command is Used For
The whatis
command provides a brief description of a given command, making it a quick reference tool for Linux users.
Basic Usage:
whatis ls
This returns:
ls (1) - list directory contents
Useful Options:
whatis -l chmod
→ Displays long descriptions for commands.whatis -w grep
→ Matches partial words in descriptions.
This Linux command is helpful when exploring new commands or verifying their purpose before execution.
48. top
– Monitor Active Processes in Real-Time
The top
command provides a live view of running processes, CPU/memory usage, and system performance.
Basic Usage:
top
This displays a constantly updating list of active processes.
Useful Options:
- Press
q
→ Exitstop
. - Press
k
→ Prompts to kill a process by PID. top -o %MEM
→ Sorts processes by memory usage.top -n 1 -b > output.txt
→ Saves a snapshot to a file.
top
is crucial for diagnosing system slowdowns and managing resource-intensive applications.
49. useradd
and usermod
– Add or Modify Users
The useradd
command creates new users, while usermod
modifies existing user accounts.
Basic Usage:
sudo useradd newuser
Creates a user named newuser
.
sudo usermod -aG sudo newuser
Adds newuser
to the sudo
group, granting admin privileges.
Useful Options:
sudo useradd -m -s /bin/bash username
→ Creates a home directory with a default shell.sudo usermod -l newname oldname
→ Renames a user.sudo usermod -d /new/home username
→ Changes the user’s home directory.
These Linux commands are vital for managing multi-user Linux environments.
50. passwd
– Change User Passwords
The passwd
command allows users to set or update passwords for themselves or others (if run by root
).
Basic Usage:
passwd
Prompts the current user to change their password.
sudo passwd username
Changes the password for another user.
Useful Options:
passwd -l username
→ Locks a user’s password.passwd -u username
→ Unlocks a user’s password.passwd -S username
→ Checks password status (active, locked, expired).
These Linux command is essential for maintaining account security and access control.
Conclusion
Mastering Linux commands is essential for navigating, managing, and optimizing a Linux system efficiently. From basic file operations (ls
, cp
, mv
) to process management (top
, kill
, ps
) and system administration (sudo
, useradd
, passwd
), each Linux command plays a crucial role in daily tasks. Understanding package managers like apt
, yum
, pacman
, and rpm
helps in software installation and maintenance, while networking commands such as ifconfig
and traceroute
ensure seamless connectivity.
Whether you are a beginner or an advanced user, these top 50 Linux commands will enhance your productivity and problem-solving skills. The more you practice, the more intuitive these Linux commands will become, making Linux a powerful and flexible operating system for both personal and professional use. Keep exploring, experimenting, and refining your command-line skills to unlock the full potential of Linux!