Linux Commands
This is a list of the most commonly used Linux commands and their usage.
1. ls
Syntax : ls [options] [directory]
Usage : ls is used to list the contents of a directory. It can be used to list the contents of the current directory or any other directory.
Commands Used:
ls # list the contents of the current directory
ls -l # list the contents of the current directory in long format
ls -a # list the contents of the current directory including hidden files
ls -la # list the contents of the current directory in long format including hidden files2. cd
Syntax : cd [directory]
Usage : cd is used to change the current working directory. It can be used to change the current working directory to the home directory or any other directory.
Commands Used:
cd # change the current working directory to the home directory
cd / # change the current working directory to the root directory
cd /home # change the current working directory to the home directory
cd Documents # change the current working directory to the Documents directory of the user
cd .. # change the current working directory to the parent directory
cd ../.. # change the current working directory to the grandparent directory3. grep
Syntax : grep [options] pattern [file]
Usage : grep is used to search for a pattern in a file. It can be used to search for a pattern in a file or in the output of a command.
Commands Used:
=> replace pattern like: "abc" and file like: note.txt
4. su/ sudo
Syntax : su [options] [username] or sudo [options] command
Usage : su is used to switch to another user. It can be used to switch to the root user or any other user.
sudo is used to execute a command as another user. It can be used to execute a command as the root user or any other user.
replace username like: sam
5. pwd
Syntax : pwd
Usage: pwd is used to print the current working directory.
Commands Used:
6. mv
Syntax : mv [options] source destination
Usage : mv is used to move or rename a file or directory. It can be used to move or rename a file or directory in the same directory or in a different directory.
Commands Used:
7. cp
Syntax : cp [options] source destination
Usage : cp is used to copy a file or directory. It can be used to copy a file or directory in the same directory or in a different directory.
Commands Used:
8. rm
Syntax : rm [options] file
Usage : rm is used to remove a file or directory. It can be used to remove a file or directory in the same directory or in a different directory.
Commands Used:
9. mkdir
Syntax : mkdir [options] directory
Usage : mkdir is used to create a directory.
Commands Used:
10. rmdir
Syntax : rmdir [options] directory
Usage : rmdir is used to remove a directory.
Commands Used:
11. chmod
Syntax : chmod [options] permissions file
Usage : chmod is used to change the permissions of a file or directory.
Commands Used:
12. cat
Syntax : cat [options] file1 file2
Usage : cat is used to concatenate files and print on the standard output.
Commands Used:
13. chown
Syntax : chown [options] username file
Usage : chown is used to change the owner of a file or directory.
Commands Used:
14. echo
Syntax : echo [options] string
Usage : echo is used to display a line of text/string.
Commands Used:
15. wc
Syntax : wc [options] file
Usage : wc is used to count the number of lines, words, and bytes in a file.
Commands Used:
16. man
Syntax : man [options] command
Usage : man is used to display the user manual of any command that we can run on the terminal.
Commands Used:
It provides a detailed view of the command which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, EXIT STATUS, RETURN VALUES, ERRORS, FILES, VERSIONS, EXAMPLES, AUTHORS and SEE ALSO.
17. history
Syntax : history [options]
Usage : history is used to print the history of commands.
Commands Used:
18. clear
Syntax : clear
Usage : clear is used to clear the terminal screen.
Commands Used:
19. touch
Syntax : touch [options] file
Usage : touch is used to create a file.
Commands Used:
20. locate
Syntax : locate [options] file
Usage : locate is used to find the location of a file or directory.
Commands Used:
21. netstat
Syntax : netstat [options]
Usage : netstat is used to display network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
Commands Used:
22. df
Syntax : df [options]
Usage : df is used to display the amount of disk space available on the file system.
Commands Used:
23. du
Syntax : du [options]
Usage : du is used to estimate file space usage.
Commands Used:
24. uname
Syntax : uname [options]
Usage : uname is used to print certain system information.
Commands Used:
25. passwd
Syntax : passwd [options]
Usage : passwd is used to change the password of a user.
Commands Used:
26. useradd
Syntax : useradd [options] username
Usage : useradd is used to add a new user to the system.
Commands Used:
27. userdel
Syntax : userdel [options] username
Usage : userdel is used to delete a user from the system.
Commands Used:
28. apt-get
Syntax : apt-get [options]
Usage : apt-get is used to install, remove, and update software packages on Debian based systems.
Commands Used:
=> replace "package" with the name of the package you want to install, remove, or update
eg: "vim", "git"
Note: You may need to add sudo before the commands.
29. ping
Syntax : ping [options] hostname
Usage : ping is used to test the reachability of a host on an Internet Protocol (IP) network.
Commands Used:
hostname is the name of the host to be pinged eg: "www.google.com"
30. find
Syntax : find [options] path
Usage : find is used to search for files in a directory hierarchy.
Commands Used:
31. head
Syntax : head [options] file
Usage : head is used to output the first part of files.
Commands Used:
32. rename
Syntax : rename [options]
Usage : rename is used to rename multiple files.
Commands Used:
33. tail
Syntax : tail [options] file
Usage : tail is used to output the last part of files.
Commands Used:
34. tac
Syntax : tac [options] file
Usage : tac is used to concatenate and print files in reverse.
Commands Used:
35. comm
Syntax : comm [options] file1 file2
Usage : comm is used to compare two sorted files line by line.
Commands Used:
36. cut
Syntax : cut [options] file
Usage : cut is used to remove sections from each line of files.
Commands Used:
37. sort
Syntax : sort [options] file
Usage : sort is used to sort lines of text files.
Commands Used:
38. date
Syntax : date [options]
Usage : date is used to display or set the system date and time.
Commands Used:
39. cal
Syntax : cal [options]
Usage : cal is used to display a calendar and the date of Easter.
Commands Used:
40. time
Syntax : time [options] command
Usage : time is used to execute a command and display the time it took to run.
Commands Used:
41. host
Syntax : host [options] hostname
Usage : host is used to look up the IP address of a host.
Commands Used:
42. wget
Syntax : wget [options] url
Usage : wget is used to download files from the web.
Commands Used:
43. id
Syntax : id [options]
Usage : id is used to print real and effective user and group IDs.
Commands Used:
44. ps
Syntax : ps [options]
Usage : ps is used to report a snapshot of the current processes.
Commands Used:
45. top
Syntax : top [options]
Usage : top is used to display Linux processes.
Commands Used:
46. kill
Syntax : kill [options] pid
Usage : kill is used to send a signal to a process.
Commands Used:
47. pkill
Syntax : pkill [options] process
Usage : pkill is used to send a signal to a process.
Commands Used:
48. killall
Syntax : killall [options] process
Usage : killall is used to send a signal to a process.
Commands Used:
49. bg
Syntax : bg [options]
Usage : bg is used to resume suspended jobs in the background.
Commands Used:
50. fg
Syntax : fg [options]
Usage : fg is used to resume suspended jobs in the foreground.
Commands Used:
51. tar
Syntax : tar [options] file
Usage : tar is used to create, extract, or list files from a tar archive.
Commands Used:
52. gzip
Syntax : gzip [options] file
Usage : gzip is used to compress or expand files.
Commands Used:
Last updated
Was this helpful?