Linux Top 50 Most Used Commands!
--
In this article, I’m going to share linux most used commands based on my experience. I’m going too list down the most used commands in unix terminal that I often use it.
Commands name would be listed in this article with its meaning, use case, example and syntax each.
- ls
- Meaning: List files and directories.
- Uses: Display the contents of a directory.
- Example:
ls /home/user/documents
- Syntax:
ls [options] [directory]
2. cd
- Meaning: Change the current working directory.
- Uses: Move between directories.
- Example:
cd /var/log
- Syntax:
cd [directory]
3. pwd
- Meaning: Print the current working directory.
- Uses: Display the path of the current directory.
- Example:
pwd
- Syntax:
pwd
4. mkdir
- Meaning: Make a new directory.
- Uses: Create a new directory in the current location.
- Example:
mkdir new_directory
- Syntax:
mkdir [directory_name]
5. rmdir
- Meaning: Remove an empty directory.
- Uses: Delete a directory that is empty.
- Example:
rmdir empty_directory
- Syntax:
rmdir [directory_name]
6. cp
- Meaning: Copy files or directories.
- Uses: Duplicate files or move them to a different location.
- Example:
cp file.txt /destination
- Syntax:
cp [source] [destination]
7. mv
- Meaning: Move or rename files or directories.
- Uses: Move files to a different location or rename them.
- Example:
mv file.txt new_file.txt
- Syntax:
mv [source] [destination]
8. rm
- Meaning: Remove files or directories.
- Uses: Delete files or directories permanently.
- Example:
rm file.txt
- Syntax:
rm [file]
9. cat
- Meaning: Concatenate and display file content.
- Uses: Display the contents of a file.
- Example:
cat file.txt
- Syntax:
cat [file]
10. more
- Meaning: View file content page by page.
- Uses: Display large file contents interactively.
- Example:
more big_file.txt
- Syntax:
more [file]
11. less
- Meaning: View file content with backward navigation.
- Uses: Display file contents with interactive scrolling and search capabilities.
- Example:
less long_log_file.txt
- Syntax:
less [file]
12. head
- Meaning: Display the beginning lines of a file.
- Uses: Show the first few lines of a file.
- Example:
head -n 5 file.txt
- Syntax:
head [options] [file]
13. tail
- Meaning: Display the last lines of a file.
- Uses: Show the last few lines of a file (e.g., log files).
- Example:
tail -n 10 log.txt
- Syntax:
tail [options] [file]
14. grep
- Meaning: Search for patterns in files.
- Uses: Find specific text patterns in files.
- Example:
grep "error" log.txt
- Syntax:
grep [options] "pattern" [file]
15. find
- Meaning: Search for files and directories.
- Uses: Locate files based on various criteria (e.g., name, size, type).
- Example:
find /path/to/search -name "*.txt"
- Syntax:
find [starting_directory] [options] [expression]
16. chmod
- Meaning: Change file permissions.
- Uses: Modify file permissions (read, write, execute) for users and groups.
- Example:
chmod 644 file.txt
- Syntax:
chmod [permission] [file]
17. chown
- Meaning: Change file ownership.
- Uses: Change the owner and group of a file.
- Example:
chown user:group file.txt
- Syntax:
chown [user]:[group] [file]
18. ps
- Meaning: Display information about running processes.
- Uses: Show a list of active processes.
- Example:
ps -ef
- Syntax:
ps [options]
19. top
- Meaning: Monitor system processes in real-time.
- Uses: View dynamic process information and system resource usage.
- Example:
top
- Syntax:
top
20. kill
- Meaning: Terminate a process.
- Uses: End a running process by sending a signal.
- Example:
kill PID
- Syntax:
kill [signal] [PID]
21. ping
- Meaning: Test network connectivity to a host.
- Uses: Check if a remote host is reachable.
- Example:
ping google.com
- Syntax:
ping [host]
22. ifconfig
- Meaning: Configure network interfaces (deprecated in some systems).
- Uses: Display and configure network interface settings.
- Example:
ifconfig eth0 up
- Syntax:
ifconfig [interface] [options]
23. ip
- Meaning: Configure network interfaces (modern replacement for ifconfig).
- Uses: Manage and display network interface information.
- Example:
ip addr show
- Syntax:
ip [options] [object] [command]
24. ssh
- Meaning: Securely connect to a remote server.
- Uses: Establish a secure shell connection to a remote host.
- Example:
ssh user@remote_host
- Syntax:
ssh [user]@[host]
25. scp
- Meaning: Securely copy files between local and remote hosts.
- Uses: Transfer files securely between two hosts.
- Example:
scp file.txt user@remote_host:/path
- Syntax:
scp [options] [source] [user]@[host]:[destination]
26. tar
- Meaning: Archive files into a tarball.
- Uses: Compress multiple files and directories into a single archive file.
- Example:
tar -cvzf archive.tar.gz files/
- Syntax:
tar [options] [archive_file] [files/directories]
27. untar
- Meaning: Extract files from a tarball.
- Uses: Decompress and extract files from a tarball archive.
- Example:
tar -xvzf archive.tar.gz
- Syntax:
tar [options] [archive_file]
28. zip
- Meaning: Create a zip archive.
- Uses: Compress files and directories into a zip file.
- Example:
zip archive.zip files/
- Syntax:
zip [options] [archive_name] [files/directories]
29. unzip
- Meaning: Extract files from a zip archive.
- Uses: Decompress and extract files from a zip archive.
- Example:
unzip archive.zip
- Syntax:
unzip [options] [archive_file]
30. df
- Meaning: Display disk space usage of file systems.
- Uses: Show the disk space usage of all mounted file systems.
- Example:
df -h
- Syntax:
df [options]
31. du
- Meaning: Estimate file and directory space usage.
- Uses: Calculate the size of files and directories.
- Example:
du -sh directory/
- Syntax:
du [options] [file/directory]
32. free
- Meaning: Display system memory usage.
- Uses: Show the system’s free and used memory.
- Example:
free -h
- Syntax:
free [options]
33. uptime
- Meaning: Display the system’s uptime.
- Uses: Show how long the system has been running.
- Example:
uptime
- Syntax:
uptime
34. date
- Meaning: Display or set the system date and time.
- Uses: View or set the current date and time.
- Example:
date
- Syntax:
date [options]
35. cal
- Meaning: Display the calendar.
- Uses: Show the current month’s calendar.
- Example:
cal
- Syntax:
cal [options]
36. history
- Meaning: Display command history.
- Uses: Show a list of previously executed commands.
- Example:
history
- Syntax:
history [options]
37. man
- Meaning: Display the manual page for a command.
- Uses: Get detailed documentation for a command.
- Example:
man ls
- Syntax:
man [command]
38. alias
- Meaning: Create a custom command alias.
- Uses: Set a shortcut for frequently used commands.
- Example:
alias ll='ls -l'
- Syntax:
alias [alias_name]='[command_with_options]'
39. echo
- Meaning: Display a message.
- Uses: Output a message or variable value.
- Example:
echo "Hello, World!"
- Syntax:
echo [message]
40. wc
- Meaning: Count lines, words, and characters in a file.
- Uses: Calculate the number of lines, words, and characters in a file.
- Example:
wc file.txt
- Syntax:
wc [options] [file]
41. cut
- Meaning: Remove sections from each line of a file.
- Uses: Extract specific columns from a file.
- Example:
cut -d',' -f2 file.csv
- Syntax:
cut [options] [file]
42. sort
- Meaning: Sort lines of text files.
- Uses: Arrange lines in alphabetical or numerical order.
- Example:
sort file.txt
- Syntax:
sort [options] [file]
43. grep
- Meaning: Search for patterns in files.
- Uses: Find specific text patterns in files.
- Example:
grep "error" log.txt
- Syntax:
grep [options] "pattern" [file]
44. find
- Meaning: Search for files and directories.
- Uses: Locate files based on various criteria (e.g., name, size, type).
- Example:
find /path/to/search -name "*.txt"
- Syntax:
find [starting_directory] [options] [expression]
45. wc
- Meaning: Count lines, words, and characters in a file.
- Uses: Calculate the number of lines, words, and characters in a file.
- Example:
wc file.txt
- Syntax:
wc [options] [file]
46. grep
- Meaning: Search for patterns in files.
- Uses: Find specific text patterns in files.
- Example:
grep "error" log.txt
- Syntax:
grep [options] "pattern" [file]
47. find
- Meaning: Search for files and directories.
- Uses: Locate files based on various criteria (e.g., name, size, type).
- Example:
find /path/to/search -name "*.txt"
- Syntax:
find [starting_directory] [options] [expression]
48. chmod
- Meaning: Change file permissions.
- Uses: Modify file permissions (read, write, execute) for users and groups.
- Example:
chmod 644 file.txt
- Syntax:
chmod [permission] [file]
49. chown
- Meaning: Change file ownership.
- Uses: Change the owner and group of a file.
- Example:
chown user:group file.txt
- Syntax:
chown [user]:[group] [file]
50. ps
- Meaning: Display information about running processes.
- Uses: Show a list of active processes.
- Example:
ps -ef
- Syntax:
ps [options]
Thank You For Reading!
By Shubham Dhungana
Cyber Security Researcher