List of most commonly used Linux commands
1. pwd (Print Working Directory)
• Explanation: Displays the current directory path.
• Syntax: pwd
• Example:
code:
$ pwd /home/user/documents
2. ls (List)
• Explanation: Lists files and directories in the current directory.
• Syntax: ls [OPTION] [FILE]
• Example:
code:
$ ls -l total 24 -rw-r--r-- 1 user user 4534 Oct 1 14:25 file.txt drwxr-xr-x 2 user user
4096 Oct 1 14:20 directory
3. cd (Change Directory)
• Explanation: Changes the current directory.
• Syntax: cd [DIRECTORY]
• Example:
code:
$ cd /path/to/directory
4. touch
• Explanation: Creates an empty file.
• Syntax: touch [FILENAME]
• Example:
code:
$ touch newfile.txt
5. mkdir (Make Directory)
• Explanation: Creates a new directory.
• Syntax: mkdir [OPTION] [DIRECTORY]
• Example:
code:
$ mkdir my_directory
6. rm (Remove)
• Explanation: Removes files or directories.
• Syntax: rm [OPTION] [FILE]
• Example:
code:
$ rm file.txt
7. cp (Copy)
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Explanation: Copies files or directories.
• Syntax: cp [OPTION] [SOURCE] [DESTINATION]
• Example:
code:
$ cp file.txt backup/
8. mv (Move)
• Explanation: Moves or renames files or directories.
• Syntax: mv [OPTION] [SOURCE] [DESTINATION]
• Example:
code:
$ mv oldfile.txt newfile.txt
9. cat (Concatenate)
• Explanation: Displays the contents of a file.
• Syntax: cat [OPTION] [FILE]
• Example:
code:
$ cat file.txt
10. less/more
• Explanation: Allows you to view a file one screen at a time.
• Syntax (less): less [FILE]
• Syntax (more): more [FILE]
• Example (less):
code:
$ less largefile.txt
11. head/tail
• Explanation: Displays the beginning or end of a file.
• Syntax (head): head [OPTION] [FILE]
• Syntax (tail): tail [OPTION] [FILE]
• Example (head):
code:
$ head -n 10 file.txt
12. grep (Global Regular Expression Print)
• Explanation: Searches for patterns in files.
• Syntax: grep [OPTION] "PATTERN" [FILE]
• Example:
code:
$ grep -i "search" file.txt
13. find
• Explanation: Searches for files and directories.
• Syntax: find [PATH] [OPTION] [PATTERN]
• Example:
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
code:
$ find /path/to/search -name "file*"
14. chmod (Change Mode)
• Explanation: Changes file permissions.
• Syntax: chmod [OPTION] [MODE] [FILE]
• Example:
code:
$ chmod 755 file.txt
15. chown (Change Owner)
• Explanation: Changes file owner and group.
• Syntax: chown [OPTION] [USER]:[GROUP] [FILE]
• Example:
code:
$ chown user:group file.txt
16. ps (Process Status)
• Explanation: Displays information about running processes.
• Syntax: ps [OPTION]
• Example:
code:
$ ps aux
17. kill
• Explanation: Terminates processes.
• Syntax: kill [OPTION] [PROCESS_ID]
• Example:
code:
$ kill -9 1234
18. top/htop
• Explanation: Monitors system processes and resource usage.
19. df (Disk Free)
• Explanation: Displays disk space usage.
• Syntax: df [OPTION]
• Example:
code:
$ df -h
20. du (Disk Usage)
• Explanation: Displays disk usage of files and directories.
• Syntax: du [OPTION] [DIRECTORY]
• Example:
code:
$ du -h /path/to/directory
21. date
• Explanation: Displays the current date and time.
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Syntax: date [OPTION] [+FORMAT]
• Example:
code:
$ date '+%Y-%m-%d %H:%M:%S'
22. cal (Calendar)
• Explanation: Displays a calendar.
• Syntax: cal [OPTION]
• Example:
code:
$ cal
23. wget
• Explanation: Downloads files from the internet.
• Syntax: wget [OPTION] [URL]
• Example:
code:
$ wget http://example.com/file.txt
24. tar (Tape Archive)
• Explanation: Archives files.
• Syntax (create): tar -cvzf [ARCHIVE_NAME] [FILES/DIRECTORIES]
• Syntax (extract): tar -xvzf [ARCHIVE_NAME]
• Example (create):
code:
$ tar -cvzf archive.tar.gz /path/to/files
25. zip/unzip
• Explanation: Compresses and decompresses files.
26. ssh (Secure Shell)
• Explanation: Securely logs into a remote server.
• Syntax: ssh [USER]@[HOSTNAME]
• Example:
code:
$ ssh user@hostname
27. scp (Secure Copy)
• Explanation: Securely copies files between local and remote hosts.
• Syntax (from local to remote): scp [FILE]
[USER]@[HOSTNAME]:[DESTINATION]
• Syntax (from remote to local): scp [USER]@[HOSTNAME]:[FILE]
[DESTINATION]
• Example:
code:
$ scp file.txt user@hostname:/path/to/destination/
28. sed (Stream Editor)
• Explanation: Performs text manipulation.
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Syntax: sed [OPTION] 's/OLD/NEW/' [FILE]
• Example:
code:
$ sed 's/old/new/' file.txt
29. awk
• Explanation: Text processing tool for data extraction.
• Syntax: awk '{print $1}' [FILE]
• Example:
code:
$ awk '{print $1}' file.txt
30. sort
• Explanation: Sorts lines of text files.
• Syntax: sort [OPTION] [FILE]
• Example:
code:
$ sort -n file.txt
31. cut
• Explanation: Removes sections from lines of files.
• Syntax: cut [OPTION] [DELIMITER] -f [FIELD] [FILE]
• Example:
code:
$ cut -d ',' -f1 file.csv
32. tee
• Explanation: Redirects output to multiple files.
• Syntax: command | tee [FILE1] [FILE2] ...
• Example:
code:
$ echo "Hello, World" | tee file1.txt file2.txt
33. df (Disk Free)
• Explanation: Displays disk space usage.
• Syntax: df [OPTION]
• Example:
code:
$ df -h
34. who
• Explanation: Shows who is logged on.
• Syntax: who
• Example:
code:
$ who
35. whatis
• Explanation: Displays one-line descriptions of command functions.
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Syntax: whatis [COMMAND]
• Example:
code:
$ whatis ls
36. alias
• Explanation: Creates a command alias.
• Syntax: alias [ALIAS_NAME]='[COMMAND] [OPTIONS]'
• Example:
code:
$ alias ll= 'ls -l'
37. jobs
• Explanation: Lists background jobs.
• Syntax: jobs
• Example:
code:
$ jobs
38. ping
• Explanation: Sends ICMP echo requests to a host.
• Syntax: ping [OPTION] [HOST]
• Example:
code:
$ ping google.com
39. ifconfig
• Explanation: Configures network interfaces.
• Syntax: ifconfig [INTERFACE] [OPTION]
• Example:
code:
$ ifconfig eth0
40. route
• Explanation: Views and manipulates the IP routing table.
• Syntax: route [OPTION]
• Example:
code:
$ route -n
41. netstat
• Explanation: Displays network statistics.
• Syntax: netstat [OPTION]
• Example:
code:
$ netstat -tuln
42. shutdown
• Explanation: Shuts down or reboots the system.
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Syntax: shutdown [OPTION] [TIME]
• Example:
code:
$ shutdown -h now
43. reboot
• Explanation: Reboots the system.
• Syntax: reboot
• Example:
code:
$ reboot
44. crontab
• Explanation: Schedules tasks to run at specified times.
• Syntax: crontab [OPTION]
• Example:
code:
$ crontab -e
45. at
• Explanation: Schedules a one-time task.
• Syntax: at [TIME] [OPTION]
• Example:
code:
$ at now + 1 hour
46. touch
• Explanation: Changes file timestamps.
• Syntax: touch -t [YYYYMMDDHHMM.SS] [FILE]
• Example:
code:
$ touch -t 202210201200.00 file.txt
47. lsof (List Open Files)
• Explanation: Lists open files and processes.
• Syntax: lsof [OPTION] [FILE]
• Example:
code:
$ lsof /path/to/file
48. nc (Netcat)
• Explanation: Network utility for reading/writing network connections.
• Syntax: nc [OPTION] [HOST] [PORT]
• Example:
code:
$ nc -l -p 1234
49. scp (Secure Copy)
• Explanation: Securely copies files between local and remote hosts.
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Syntax (from local to remote): scp [FILE]
[USER]@[HOSTNAME]:[DESTINATION]
• Syntax (from remote to local): scp [USER]@[HOSTNAME]:[FILE]
[DESTINATION]
• Example (from local to remote):
code:
$ scp file.txt user@hostname:/path/to/destination/
List of commonly used Linux commands for user account.
1. useradd
• Explanation: Creates a new user account on the system.
• Syntax: useradd [OPTIONS] USERNAME
• Example:
code:
sudo useradd john
2. passwd
• Explanation: Sets or changes the password for a user account.
• Syntax: passwd [USERNAME]
• Example:
code:
sudo passwd john
3. userdel
• Explanation: Deletes a user account from the system.
• Syntax: userdel [OPTIONS] USERNAME
• Example:
code:
sudo userdel -r john
4. usermod
• Explanation: Modifies user account properties, such as the username
and home directory.
• Syntax: usermod [OPTIONS] USERNAME
• Example:
code:
sudo usermod -l newname oldname
5. groups
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Explanation: Lists the groups a user belongs to.
• Syntax: groups [USERNAME]
• Example:
code:
groups john
6. newgrp
• Explanation: Changes the group of the current shell session.
• Syntax: newgrp [GROUPNAME]
• Example:
code:
newgrp staff
7. su (Switch User)
• Explanation: Switches to another user account or the superuser.
• Syntax: su [OPTIONS] [USERNAME]
• Example:
code:
su - john
8. sudo
• Explanation: Executes a command with superuser privileges.
• Syntax: sudo [OPTIONS] COMMAND
• Example:
code:
sudo apt-get update
9. chown (Change Owner)
• Explanation: Changes the ownership of files or directories.
• Syntax: chown [OPTIONS] [OWNER]:[GROUP] FILE
• Example:
code:
sudo chown john: users file.txt
10. chmod (Change Mode)
• Explanation: Modifies file or directory permissions.
• Syntax: chmod [OPTIONS] PERMISSIONS FILE
• Example:
code:
chmod 644 file.txt
11. adduser
• Explanation: Interactive command for adding a new user.
• Syntax: adduser [OPTIONS] USERNAME
• Example:
code:
sudo adduser jane
12. deluser
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
• Explanation: Deletes a user account, along with their home directory
and mail spool.
• Syntax: deluser [OPTIONS] USERNAME
• Example:
code:
sudo deluser --remove-home jane
13. passwd
• Explanation: Changes the user's password.
• Syntax: passwd [USERNAME]
• Example:
code:
passwd jane
14. gpasswd
• Explanation: Manages group password files.
• Syntax: gpasswd [OPTIONS] GROUP
• Example:
code:
sudo gpasswd -a john sudo
15. usermod
• Explanation: Modifies a user account.
• Syntax: usermod [OPTIONS] USERNAME
• Example:
code:
sudo usermod -aG admin john
16. id
• Explanation: Displays user and group information for the current user
or a specified user.
• Syntax: id [USERNAME]
• Example:
code:
id john
17. finger
• Explanation: Displays information about a user.
• Syntax: finger [USERNAME]
• Example:
code:
finger john
18. who
• Explanation: Lists the users currently logged into the system.
• Syntax: who
• Example:
code:
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach
who
19. w
• Explanation: Shows information about currently logged-in users and
their activities.
• Syntax: w
• Example:
code:
w
20. groups
• Explanation: Lists the groups a user belongs to.
• Syntax: groups [USERNAME]
• Example:
code:
groups john
Compiled
by
Dr. Amar Panchal
@amarthecodelifecoach