Essential Linux Commands: Top 50 with Examples
Linux, renowned for its power and versatility, empowers users through its extensive array of commands. In this guide, we’ll explore 50 of the most frequently used Linux commands along with practical examples. Whether you’re a beginner or a seasoned user, these commands will enhance your Linux experience and give you greater control over your system.
1. ls — List Directory Contents
The `ls` command lists files and directories in the current location.
Example:
ls
ls -l
ls -a
2. cd — Change Directory
The `cd` command changes the current directory.
Example:
cd /path/to/directory
cd ..
3. pwd — Print Working Directory
The `pwd` command displays the current working directory.
Example:
pwd
4. cp — Copy Files and Directories
The `cp` command copies files and directories.
Example:
cp file.txt /path/to/destination/
cp -r directory/ /path/to/destination/
5. mv — Move/ Rename Files and Directories
The `mv` command moves files and directories or renames them.
Example:
mv file.txt newfile.txt
mv file.txt /path/to/new/location/
6. rm — Remove Files and Directories
The `rm` command deletes files and directories.
Example:
rm file.txt
rm -r directory/
7. mkdir — Create Directories
The `mkdir` command creates new directories.
Example:
mkdir new_directory
8. touch — Create Empty Files or Update Timestamps
The `touch` command creates empty files or updates timestamps.
Example:
touch file.txt
9. cat — Concatenate and Display File Contents
The `cat` command displays the contents of a file.
Example:
cat file.txt
10. grep — Search for Text Patterns
The `grep` command searches for patterns in files.
Example:
grep “pattern” file.txt
11. chmod — Change File Permissions
The `chmod` command changes file permissions.
Example:
chmod u+rw file.txt
12. chown — Change File Ownership
The `chown` command changes the owner and group of a file.
Example:
chown newowner file.txt
13. ps — Display Process Status
The `ps` command displays information about running processes.
Example:
ps
ps aux | grep “process_name”
14. top — Monitor System Processes in Real-Time
The `top` command provides real-time insights into system processes.
Example:
top
15. df — Display Disk Space Usage
The `df` command shows disk space usage information.
Example:
df -h
16. du — Estimate File and Directory Space Usage
The `du` command estimates disk space usage by files and directories.
Example:
du -sh /path/to/directory
17. ifconfig — Configure Network Interfaces
The `ifconfig` command configures network interfaces.
Example:
ifconfig
18. ping — Send ICMP Echo Requests
The `ping` command tests network connectivity using ICMP echo requests.
Example:
ping google.com
19. ssh — Securely Access Remote Systems
The `ssh` command securely accesses remote systems.
Example:
ssh username@remote_host
20. apt-get — Package Management on Debian-based Systems
The `apt-get` command manages software packages on Debian-based systems.
Example:
sudo apt-get update
21. yum — Package Management on Red Hat-based Systems
The `yum` command manages software packages on Red Hat-based systems.
Example:
sudo yum install package_name
22. tar — Archive and Extract Files
The `tar` command archives and extracts files.
Example:
tar -cvf archive.tar files/
tar -xvf archive.tar
23. unzip — Extract Zip Archives
The `unzip` command extracts files from zip archives.
Example:
unzip archive.zip
24. uname — Display System Information
The `uname` command displays system information.
Example:
uname -a
25. history — Display Command History
The `history` command displays command history.
Example:
history
26. echo — Print Text to the Terminal
The `echo` command prints text to the terminal.
Example:
echo “Hello, Linux!”
27. date — Display or Set System Date and Time
The `date` command displays or sets system date and time.
Example:
date
28. whoami — Display Current User
The `whoami` command displays the current user.
Example:
whoami
29. file — Determine File Type
The `file` command determines the type of a file.
Example:
file file.txt
30. wget — Download Files from the Web
The `wget` command downloads files from the web.
Example:
wget https://example.com/file.txt
31. find — Search for Files and Directories
The `find` command searches for files and directories.
Example:
find /path/to/search -name “pattern”
32. diff — Compare Files Line by Line
The `diff` command compares files line by line.
Example:
diff file1.txt file2.txt
33. history — Display Command History
The `history` command displays command history.
Example:
history
34. man — Display Manual Pages
The `man` command displays manual pages for commands.
Example:
man ls
35. kill — Terminate Processes
The `kill` command terminates processes by sending signals.
Example:
kill -9 process_id
36. cp — Copy Files and Directories
The `cp` command copies files and directories.
Example:
cp file.txt /path/to/destination/
cp -r directory/ /path/to/destination/
37. mv — Move/ Rename Files and Directories
The `mv` command moves files and directories or renames them.
Example:
mv file.txt newfile.txt
mv file.txt /path/to/new/location/
38. rm — Remove Files and Directories
The `rm` command deletes files and directories.
Example:
rm file.txt
rm -r directory/
39. mkdir — Create Directories
The `mkdir` command creates new directories.
Example:
mkdir new_directory
40. chmod — Change File Permissions
The `chmod` command changes file permissions.
Example:
chmod u+rw file.txt
41. chown — Change File Ownership
The `chown` command changes the owner and group of a file.
Example:
chown newowner file.txt
42. ps — Display Process Status
The `ps` command displays information about running processes.
Example:
ps
ps aux | grep “process_name”
43. top — Monitor System Processes in Real-Time
The `top` command provides real-time insights into system processes.
Example:
top
44. df — Display Disk Space Usage
The `df` command shows disk space usage information.
Example:
df -h
45. du — Estimate File and Directory Space Usage
The `du` command estimates disk space usage by files and directories.
Example:
du -sh /path/to/directory
46. ifconfig — Configure Network Interfaces
The `ifconfig` command configures network interfaces.
Example:
ifconfig
47. ping — Send ICMP Echo Requests
The `ping` command tests network connectivity using ICMP echo requests.
Example:
ping google.com
48. ssh — Securely Access Remote Systems
The `ssh` command securely accesses remote systems.
Example:
ssh username@remote_host
49. apt-get — Package Management on Debian-based Systems
The `apt-get` command manages software packages on Debian-based systems.
Example:
sudo apt-get update
50. yum — Package Management on Red Hat-based Systems
The `yum` command manages software packages on Red Hat-based systems.
Example:
sudo yum install package_name
These 50 Linux commands provide a solid foundation for navigating and managing your Linux system. As you become more comfortable with these commands, you’ll find that your efficiency and control over your system will greatly improve. Keep exploring and experimenting with these commands to unlock the full potential of the Linux operating system.
Do follow me for more such content related to DevOps world!