Linux Commands

101 Linux Commands Every User Should Know

Every User Should Know

Linux distributions offer you a “shell,” an interface used for accessing the system services. The majority of the Linux distros utilize their Graphical User Interface (GUI) as “shell”, primarily for user convenience. However, it is recommended to use the Command Line Interface (CLI) as it is more effective and powerful. Also, the tasks that are performed through multi-steps in the Linux GUI process can be completed in seconds through the CLI or Linux terminal.

Mastering the basic Linux commands can help you a lot if you consider using Linux on your system. We have provided an e-book comprising the 101 Linux commands that every Linux user should know. Whether you are a newbie, a developer, an average Linux user, or a system administrator, this e-book will undoubtedly assist in navigating through Linux.

In this eBook, we will cover the following 101 commands:

  1. pwd command
  2. ls command
  3. clear command
  4. cd command
  5. cat command
  6. touch command
  7. head command
  8. tail command
  9. echo command
  10. sudo command
  11. cal command
  12. df command
  13. bc command
  14. help command
  15. uname command
  16. factor command
  17. whatis command
  18. mkdir command
  19. who command
  20. gzip command
  21. free command
  22. finger command
  23. man command
  24. group command
  25. w command
  26. passwd command
  27. History command
  28. Whoami command
  29. cp command
  30. Lscpu command
  31. top command
  32. mvcommand
  33. env command
  34. printenv command
  35. ps command
  36. hostname command
  37. rm command
  38. nano command
  39. ip command
  40. ifconfig command
  41. curl command
  42. wget command
  43. last command
  44. yes command
  45. iostat command
  46. locate command
  47. shutdown command
  48. reboot command
  49. dir command
  50. apt command
  51. exitcommand
  52. paste command
  53. sort command
  54. tar command
  55. gunzip command
  56. zip command
  57. unzip command
  58. diff command
  59. hostnamectl command
  60. lsof command
  61. netstat command
  62. iptables command
  63. service command
  64. mpstatcommand
  65. vmstatcommand
  66. uniqcommand
  67. ncdu command
  68. stat command
  69. sleep command
  70. split command
  71. ping command
  72. du command
  73. useradd command
  74. usermod command
  75. userdel command
  76. awk command
  77. dig command
  78. whereis command
  79. pstree command
  80. tree command
  81. printf command
  82. find command
  83. sed command
  84. rmdir command
  85. chown command
  86. lsblk command
  87. screen command
  88. chmod command
  89. grep command
  90. basename command
  91. which command
  92. wc command
  93. fdisk command
  94. datecommand
  95. tr command
  96. fold command
  97. zcat command
  98. parted command
  99. tac command
  100. Neofetch Command
  101. xeyes command

So, let’s start!

  1. pwd command

pwd is an acronym for “Print Working Directory”. This Linux command is utilized to print out the current working directory of your system.

Syntax:

$ pwd [Option]

Now, execute the below-given “pwd” command in your Linux terminal:

$ pwd

From the output, you can see that “/home/linuxhint” is our current working directory:

Other options of pwd command:

Option Description
-P The “-P” option is utilized in the “pwd” command for printing the current directory’s fully resolved name, except for the symbolic links.
-L The “-L” option is utilized in the “pwd” command for printing the absolute name of the current working directory with no “..” or “.” components, and it also outputs symbolic links. The “pwd” command with the “-L” option is also considered the default behavior of the pwd Linux command.
  1. ls command

“ls” is an acronym for “List”. The ls command permits the Linux users to check the directories and files present inside the specified directory, and alphabetical order is followed while listing the content of a directory.

Syntax:

$  ls  [Option]  [Directory_path]

In your Linux terminal, execute the “ls” command to check the files and directories present inside your current working directory.

$  ls

Here, you can see the content of our “/home/linuxhint” directory:

To print out the list in long format, add the “-l” option in your “ls” command:

$ ls -l

To get to know about all of the directory content, including the “hidden files”, utilize the “-a” option in the “ls” command:

$ ls -a

You can also combine two or more options to perform the specified operation simultaneously. For instance, we have added “-al” options in our “ls” command.

$ ls -al

Now the execution of the above-given “ls” command will help us to view the content, including the hidden files, in the long format:

Other options of ls command:

Option Description
-S The “-S” option is utilized with the “ls” command for sorting the file size.
-d The “-d” option is utilized with the “ls” command to show the details related to the directories.
-A The “-A” option is utilized with the “ls” command to view all files except the parent and the current working directory.
-t The “-t” option is utilized with the “ls” command for sorting the output by the modification time.
-F The “-F” option is utilized with the “ls” command to append an indicator at the end of each directory name.
-r The “-r” option is utilized with the “ls” command for showing files and directories in descending alphabetical order.
-h The “-h” option is utilized with the “ls” command to display the file size in human-readable units, not bytes.
  1. Clear command

The clear command is used to clear the screen of the Linux terminal.

Syntax:

$ clear

For instance, we want to remove all previous commands and their outputs from the terminal. For this purpose, we will execute the “clear” command:

$ clear

After executing the “clear” command, the terminal screen will be cleared:

  1. cd command

“cd” is an acronym for “Change Directory”. In the Linux terminal, you can use the “cd” command for changing the current working directory.

Syntax:

$ cd [Options] [Directory]

For instance, to make “Downloads” our current working directory, we will execute the command:

$ cd [Downloads]

Now, we will move back one directory by adding “..” with the “cd” command:

$ cd ..

You can also set your home directory as the current working directory by executing simple “cd” command:

$ cd

The “cd -” command will let you move to the previous directory:

$ cd-

Other options of cd command:

Option Description
-L The “-L” option is utilized with the “cd” command to follow the symbolic link, and it is also considered as the default behavior of the “cd” command.
-P The “-P” option is utilized to restrict the “cd” command to follow the symbolic links.
  1. cat command

“cat” is an acronym for “Concatenate”. The “cat” command permits the Linux users to check out the content of a file, redirect the output to files or terminals, and concentrate files.

Syntax:

$ cat [Option] [File]

To output the content of a file in your Linux terminal, execute the cat command and specify the name of your selected file with it in the following way:

$ cat testfile1.txt

The output of the above-given command will display the “testfile1.txt” content in our terminal:

By using the “cat” command, you can also view the content of multiple files in the terminal. In the following example, we will try to display the content of “testfile1.txt” and “testfile2.txt” with the help of the “cat” command:

$ cat testfile1.txt testfile2.txt

Other options of cat command:

Option Description
-n The “-n” option is utilized with the “cat” command to number the output lines.
-b The “-b” option is utilized with the “cat” command to number the nonempty output lines.
-E The “-E” option is utilized with the “cat” command for displaying the file with the line numbers.
-T The “-T” option is utilized with the “cat” command for displaying tab-separated lines in a file.
  1. Touch command

In the Linux terminal, you can write out the “touch” command to modify a file’s timestamp. In case the file you specified in the “touch” command does not exist, an empty file with the same name will be created in the current directory.

Syntax:

$  touch  [Option]  [File]

For instance, to match the timestamp of the “myFile.txt” with the current system time, we will execute the following command:

$ touch myFile1.txt

If the “myFile1.txt” does not exist on our system, the “touch” command will create an empty “myFile.txt”:

What if you only want to change the timestamp of the specified file, rather than creating one if it does not exist?  In such case, you can add the “-c” option in your “touch” command:

$  touch  -c  myFile2.txt

Other options of touch command:

Option Description
-d The “-d” option is utilized in the “touch” command to set the specified file’s access time and modification time.
-a The”-a” option is utilized in the “touch” command only to change the specified file’s access time.
  1. Head Command

The head command is used for printing the starting lines of the selected file.

Syntax:

$ head [Option] [File]

By default, the head command prints out the first ten lines of the specified file, which is “testfile1.txt” in our case:

$  head  testfile1.txt

In the head command, you can add the “-n” option with the number of lines that you want to display from the selected file:

$  head  -n  5  testfile1.txt

The execution of the above-given command will print out the first five lines of the “testfile1.txt” file:

Other options of head command:

Option Description
-v The “-v” option is utilized in the “head” command for printing the file’s headers.
-q The “-q” option is utilized in the “head” command to restrict it to print file headers.
-c The “-c” option is utilized in the “head” command for printing the first “n” bytes of the specified file. With the “-c” option, you must add a number “n” representing the bytes.
  1. Tail Command

The tail command is used for printing the last lines of the selected file.

Syntax:

$ tail [Option] [Filename]

By default, the tail command prints out the last ten lines of the specified file, which is “testfile1.txt” in our case:

$ tail testfile1.txt

In the tail command, you can add the “-n” option with the number of lines that you want to display from the selected file:

$  tail  -n  5  testfile1.txt

The execution of the above given “tail” command will display the last five lines from the “testfile1.txt”:

  1. Echo Command

The “echo” command is used for printing out the string or text that is passed as an argument with it.

Syntax:

$ echo [Option] [String]

Here, we added “101 Linux Commands” as a string in the echo command:

$ echo 101 Linux Commands

The execution of the above command will print out “101 Linux Commands” on the terminal:

You can also add text to a file with the help of the “echo” command. For instance, the below-given “echo” command will add the “101 Linux commands” text to the “myFile.txt” file:

$  echo  "101  Linux  commands"  >  myFile.txt

To view the content added into the “myFile.txt”, specify the filename in the “cat” command and execute it:

$ cat myFile.txt

  1. Sudo Command

“sudo” is an acronym for “Super User Do”. The “sudo” command allocates permissions to a user, which allows them to execute the commands that superusers do. It assigns root privileges to the current user’s account.

Syntax:

$ sudo [Option] [ Command]

For instance, to reboot the Linux system, the user requires “sudo” privileges:

$ sudo reboot

Other option of sudo command:

Option Description
-V The “-V” option is utilized in the “sudo” command for printing the version number.
-h The “-h” option is utilized in the “sudo” command for printing a usage message and exit.
-K The”-K” option is utilized in the “sudo” command to remove the user’s timestamp.
  1. Cal Command

“cal” is an acronym for “Calendar”. It is used to display a formatted calendar in the Linux terminal. If you do not add any options in the “cal” command, it will print out the current month.

Syntax:

 

First of all, we will execute the simple “cal” command to view the calendar of the current month:

$ sudo reboot

To print out the calendar of a specific year, you have to add the “-Y” option in the cal command. For instance, the following command will output the entire calendar of the year 1998:

$ cal -y 1998

Other options of cal command:

Option Description
-m The “-m” option is utilized in the “cal” command to display a specific month’s calendar.
-h The “-h” option is utilized in the “-h” command for displaying the current month calendar without highlighting today.
  1. df Command

“df” is an acronym for “Disk Free”, and the “df” helps to retrieve the details related to your disk usage.

Syntax:

$ df [Option] [File]

The simple “df” command will print out the available disk space in bytes:

$ df

Other options of df command:

Option Description
-T The “-T” option is utilized in the “df” command for excluding a specified file system from the output.
-h The “-h” option is utilized in the “df” command for displaying available disk space for a specific file system.
-i The “-i” option is utilized in the “df” command for displaying the file system type.
  1. bc Command

“bc” is an acronym for “Basic Calculator”, and it is used to perform various mathematical calculation operations in the Linux terminal.

Syntax:

$ bc [Option] [File]

In the following example, the “bc” command will calculate “9+6,” and the “echo” command will show its result on your terminal screen:

$ echo "9+6" | bc

Other options of bc command:

Option Description
-w The “-w” option is utilized in the “bc” command to show a warning if non- standard constructed are added.
-s The “-s” option is utilized in the “bc” command for treating the non-standard bc constructs as errors
-i The “-i” option is utilized in the “bc” command for forcing the interactive mode.
-q The “-q” option is utilized in the “bc” command for restricting bc to printing the header in interactive mode.
-l The “-l” command is utilized in the “bc” command for using the predefined mat routines.
  1. Help Command

The “help” command is used for displaying the information related to the built-in Linux commands.

Syntax:

$ help [Option]

Now, execute the “help” command in your terminal and check out its output:

$ help

Other options of help command:

Option Description
-s The “-s” option is utilized in the “help” command for displaying a short usage synopsis.
-m The “-m” option is utilized in the “help” command for displaying the usage in pseudo- manpage format.
-d The “-d” option is utilized in the “help” command for displaying the short description for each topic.
  1. Uname Command

In the Linux terminal, the “uname” command displays the kernel and system-related information.

Syntax:

$ uname [Option]

Now, execute the following command to get your kernel version in the terminal:

$ uname -v

The “-a” option is added in the “uname” command to print out the system information:

Other option for uname command:

Option Description
-o The “-o” option is utilized in the “uname” command for displaying the operating system name.
-s The “-s” option is utilized in the “uname” command for displaying the kernel name.
-i The “-i” option is utilized in the “uname” command for displaying the information related to the hardware platform.
-r The “-r” option is utilized in the “uname” command for displaying the kernel release.
-p The “p” option is utilized in the “uname” command for displaying the processor type.
-m The “-m” option is utilized in the “uname” command for displaying the machine hardware name.
-n The “-n” option is utilized in the “uname” command to display the network node’s hostname.
  1. Factor Command

The “factor” command shows the prime factors of the specified integer.

Syntax:

$ factor [Option or Number]

For instance, to print out the prime factors of “60”, we will write out the “factor” command in the following way:

$ factor 60

Other options of factor command:

Option Description
–version The “–version” option is utilized to print out the version information.
–help The “–help” option is utilized to print out a help message.
  1. Whatis Command

If you want to print a one-line manual page description for the specified command, then go for the execution of the “whatis” command in your Linux terminal. It is used to display a short introduction of the added command.

Syntax:

$ whatis [Option] [Keyword]

For instance, the execution of the below-given command will show a one-line description of the “clear” command:

$ whatis clear

Other options of whatis command:

Option Description
-r The “-r” option is utilized in the “whatis” command for interpreting each keyword as a regex.
-d The “-d” option is utilized in the “whatis” command for displaying the debugging messages.
-w The “-w” option is utilized in the “whatis” command when the specified keyword contains wildcards.
  1. mkdir Command

“mkdir” stands for “Make Directory”. In Linux-based systems, the mkdir command is used for creating a directory.

Syntax:

$ mkdir [Option] [Syntax]

Now, we will try to create a “myFolder” directory with the help of the mkdir command:

$ mkdir myFolder

Next, confirm the existence of the created “myFolder” directory in pwd:

  1. Who Command

The “who” command is used for printing the time of the last system boot, the current system level, and the list of logged-in users.

Syntax:

$ who [Option] [File]

If you only want to know about the users who are currently logged in to the system, then add the “-a” option in the “who” command:

$ who -a

Other option of who command:

Option Description
-b The “-b” option is utilized in the “who” command for printing the last system boot time.
-r The “-r” option is utilized in the “who” command for printing the current run level.
-h The “-h” option is utilized in the “who” command for printing the heading of the displayed columns.
-q The “-q” option is utilized in the “who” command for printing the total number of logged-in users and their log-in names.
-d The “-d” option is utilized in the “who” command for printing the information related to the dead processes.
  1. gzip Command

“gzip” stands for “GNU Zip”. In Linux-based systems, gzip command is used for compressing and decompressing data files.

Syntax:

$ gzip [Option] [Filename]

For instance, to compress the “testfile1.txt” file, we will execute the following command:

$ gzip testfile1.txt

As you can see, the compressed file of “testfile1.tar.gz” is now created in our home directory:

Now, add the “-d” option to decompress the “testfile1.txt.gz” file:

$  gzip  -d  testfile1.txt.gz

After executing the above-given command, the “testfile1.txt.gz” will be decompressed:

  1. Free Command

In the Linux terminal, you can write out the “free” command to show the memory-related information.

Syntax:

$  free  [Option]

Now, execute the “free” command to get to know about memory usage details such as total memory, used and free memory space, shared, available, and buff/cache memory:

$  free

Other options of free command:

Option Description
-h The “-h” option is utilized in the “free” command to output the values in the “GB/MB” (human-readable) form.
  1. Finger Command

The “finger” command is used for displaying the information related to system users.

Syntax:

$ finger [Option] [username]

Before using it, you have to install the finger package on your Linux system. To do so, write out the following command:

$ sudo apt install finger

After completing the installation, execute the “finger” command and add the username to view its details:

$ finger linuxhint

Other options of finger command:

Option Description
-l The “-l” option is utilized in the “finger” command to force the long output format.
-s The “-s” option is utilized in the “finger” command to force the short output format.
-m The “-m” is utilized in the “finger” command for matching the arguments only on the username.
  1. Man Command

In Linux, “man” is an acronym for “Manual”. The “man” command is used to print out the manual of the specified command on the Linux terminal.

Syntax:

$ man [Option] [Command]

To check out the manual page of the “clear” command, we will type out the following “man” command:

$ man clear

Other options of man command:

Option Description
-I The “-l” option is utilized in the “man” command for searching the command manual (case sensitive).
-w The “-w” option is utilized in the “man” command to return the location of the specified command man page.
-k The “-k” option is utilized in the “man” command to search out the specified command with “RegEx” in all man pages.
-a The “-a” option is utilized in the “man” command to display the specified command’s manual pages.
  1. Groups Command

The “groups” command is used for printing the name of the primary and supplementary groups of the specified user.

Syntax:

$ groups [username]

For instance, to check out  the “linuxhint” user groups on the system, we will write out this command:

$ groups linuxhint

  1. w Command

The “w” command shows the information about the active users and their respective processes on the system.

Syntax:

$  w  [Option]  [Username]

To check out the active processes of “linuxhint” users, we will write out the below-given command in the Linux terminal:

$ w linuxhint

Other options of w command:

Option Description
-o The “-o” option is utilized in the “w” command for printing out a blank space for idle time.
-h The “-h” option is utilized in the “w” command to restrict it from printing the header.
-s The “-s” option is utilized in the “w” command for displaying the abbreviated output.
-V The “-v” option is utilized in the “w” command for displaying the version information.
-u The”-u” option is utilized in the “w” command to display all current processes and CPU times.
  1. passwd Command

“passwd” is an acronym for “Password”. The “passwd” command is used in Linux-based systems to change the current user password.

Syntax:

$ passwd [Option]

For instance, we want to change the password of our current user, which is “linuxhint”. For this purpose, we will execute the “passwd” command in the Linux terminal:

$ passwd

Here, we will type out the current password, new password for the user, and lastly, retype it for the authentication:

Other options of passwd command:

Option Description
-S The “-S” option is utilized in the “passwd” command for displaying the account status information.
-e The “-e” option is utilized in the “passwd” command to expire the current account password immediately.
-d The “-d” option is utilized in the “passwd” command to delete a user’s password.
-r The “-r” option is utilized in the “passwd” command to change the repository password.
-l The “-l” option is utilized in the “passwd” command for locking the user account’s password.
  1. History Command

With the help of the “history” command, you can view the list of the last five hundred executed commands in your terminal.

Syntax:

$ history

Now, execute the simple “history” command and check out the command list:

$ history

You can also specify the number of commands you want to retrieve from the whole list. For instance, to view the last five executed commands, we will write the “history” command in the following way:

$ history 5

  1. Whoami Command

The “whoami” command is used for displaying the username of the currently logged-in user.

Syntax:

$ whoami

Now, execute the “whoami” command in your terminal to view your current username.

$ whoami

  1. cp Command

“cp” is an acronym for “Copy”. In Linux, the “cp” command is used to copy single or multiple files while creating an exact copy with a different name.

Syntax:

To copy source file to the Destination file:

$cp [Option] [Source_File] [Destination_File]

To copy source file to the Destination directory:

$cp [Option] [Source_File] [Destination_Directory]

To copy multiple source files to the Destination directory:

$cp [Option] [Source_File1] [Source_File2] [Source_File3] [Destination Directory]

Now, we will execute the following “cp” command for copying the content of the “testfile1.txt” to the “testfile2.txt”:

$ cp testfile1.txt testfile2.txt

View the content of the “testfile2.txt” to confirm the copy operation which is performed:

$ cat testfile2.txt

Other options of cp command:

Option Destination
-b The “-b” option is utilized in the “cp” command to create a backup of the destination file with a different name and format in the same directory.
-f The “-f” option is utilized in the “cp” command to force the removal of the existing destination file.
-r The “-r” option is utilized in the “cp” command to recursively copy the whole directory structure.
-i The “-i” option is utilized in the “cp” command for prompting before overwriting the destination file.
  1. lscpu Command

In Linux-based systems, the “lscpu” command shows the CPU architecture information.

Syntax:

$ lscpu [Option]

For instance, executing the simple “lscpu” command will display the CPU details such as CPU op-mode, Address sizes, CPU MHz, Sockets, Vendor ID, CPU family, Virtualization type, and Flags:

$ lscpu

  1. Top Command

“top” command stands “Table of Processes”. It is used to display the CPU-consuming processes and RAM usage information.

Syntax:

$ top [Option]

Execute the simple “top” command for viewing the dynamic real-time information about the active processes:

$ top

Other option of top command:

Option Description
-b The “-b” option is utilized in the “top” command for activating batch mode operation.
-a The “-a” option is utilized in the “top” command for sorting the processes by memory usage.
-h The “-h” option is utilized in the “top” command for only displaying the processes owned by the current user.
  1. mv Command

“mv” stands for “move”. In Linux, the “mv” command is used for moving single or multiple files or directories from one directory to another. You can also rename a file or a directory with the help of the “mv” command.

Syntax:

$ mv [Option] [ Source_File] [Destination_Directory]

To move a file to a directory:

$ mv [Option] [ Old_Filename] [New_Filename]

To rename a file:

$ mv myFile.txt Downloads

Now, we will try to move the “myFile.txt” text file to the “Downloads” folder by executing the following “mv” command:

$ mv myFile.txt Downloads

You can confirm the performed operation by listing out the content of the directory where you have moved your file:

$ ls Downloads

From the below-given image, you can see that “myFile.txt” is successfully moved to our “Downloads” directory:

Other options of mv command:

Option Description
-b The “-b” option is utilized in the “mv” command for creating a backup of the existing destination file.
-f The “-f” option is utilized in the “mv” command to move by overwriting the destination file forcefully.
-u The “-u” option is utilized in the “mv” command for moving the source file if it is newer than the destination file.
-i The “-I” option is utilized in the “mv” command to enable an interactive prompt before overwriting a file.
  1. env command

“env” is an acronym for “Environment”. The “env” command is used for printing out the list of current environment variables in your Linux system.

Syntax:

$ env [Option] [Variable_name]

Now, we will execute the following command for getting the list of our current environment variables:

$ env

Other options for env command:

Option Description
-u The “-u” option is utilized in the “env” command for removing an environment variable.
-C The “-C” option is utilized in the “env” command for changing the working directory.
-i The “-i” option is utilized in the “env” command for starting with an empty environment.
  1. printenv Command

In the Linux terminal, the “printenv” command is used to display the value of the specified environment variable.

Syntax:

$ printenv [Option] [Variable_name]

For instance, we will execute the below-given command for displaying the home directory of the current user:

$ printenv HOME

You can also get a list of all environment variables by using the “printenv” command:

Other options of the “printenv” command:

Option Description
-0 The “-0” option is utilized in the “printenv” command to end each output line with a “0” byte.
  1. ps command

“ps” is an acronym for “Process Status”. In the Linux terminal, you can use the “ps” command to check the active processes and programs and their consumed resources.

Syntax:

$ ps [Option]

You can add the “-A” option with the “ps” command to view all running processes of the system:

$  ps  -A

Other options of ps command:

Option Description
-r The “-r” option is utilized in the “ps” command for restricting it only to select the running processes.
-e The “-e” option is utilized in the “ps” command for listing all processes.
-d The “-d” option is utilized in the “ps” command for selecting all processes except the session headers.
  1. Hostname Command

The “hostname” command is used for viewing or setting the hostname and the system DNS name.

Syntax:

$ hostname [Option]

Now, let’s check out the result of executing the simple “hostname” command in the terminal: Our hostname is “linuxhint-VB,” which can see in the following image:

$ hostname

  1. rm Command

“rm” is an acronym for “Remove”. The “rm” command is used for deleting or removing the specified file or directory from the system.

Syntax:

To remove file:

$ rm [Option] [File]

To remove a directory:

$ rm [Option] [Directory]

For instance, to remove the “myFile1.txt” from our Linux system, we will write out the “rm” command in this form:

$ rm myFile1.txt

The error-free output signifies that the specified file is successfully removed:

  1. Nano Command

The “nano” command is used to create and edit the text files in the GNU nano editor. Before editing files in nano editor, you have to install it on your system, if you do not have nano editor already:

$ sudo apt install nano

Now, after completing the “nano” installation process, move ahead and create a sample text file named “newFile” by executing the following nano command:

$ nano newFile

Once the file is created and opened in the nano editor, you can easily add some content to it:

Shortcuts of the nano editor:

Shortcut Description
CTRL+O The “CTRL+O” shortcut is utilized in the nano editor for writing out the current file content.
CTRL+U The “CTRL+U” shortcut is utilized in the nano editor to paste the content of the cut buffer.
CTRL+S The “CTRL+S” shortcut is utilized in the nano editor for saving the current file.
ALT+6 The “ALT+6” shortcut is utilized in the nano editor for copying the current line into the cut buffer.
CTRL+K The “CTRL+K” shortcut is utilized in the nano editor to cut the current line into a cut buffer.
ALT+E The “ALT+E” shortcut is utilized in the nano editor to redo the last undone operation.
CTRL+U The “CTRL+U” shortcut is utilized in the nano editor to paste the cut buffer content.
ALT+U The “ALT+U” shortcut is utilized in the nano editor to undo the last operation.
  1. ip Command

“ip” is an acronym for “Internet Protocol”. The “ip” command is used to perform various network- related operations such as listing IP addresses, configuring the routing table, and setting up IP routes and IP addresses.

Syntax:

$ ip [Option] [Object] [Command]

The“ip”command can also show you the detailed information of the network interfaces, such as their MAC Address and IP address information:

$ ip addr show

Other options of ip command:

Option Description
-f The “-f” option is utilized in the “ip” command for specifying the protocol family to use.
-a The “-a” option is utilized in the “ip” command for displaying and configuring the IP addresses.
-n The “-n” option is utilized in the “ip” command for displaying the changing the neighbor objects.
-l The “-l” option is utilized in the “ip” command for displaying and configuring the network interfaces.
-r The “-r” option is utilized in the “ip” command for displaying and changing the routing table.
-c The “-c” option is utilized in the “ip” command for configuring the color output.
  1. ifconfig Command

“ifconfig” is an acronym for “Interface Configuration”. The “ifconfig” Linux command is used for configuring the kernel-resident network interfaces. It also shows you the list of the active interfaces on your system.

Syntax:

$ ifconfig [Option]

Or

$ ifconfig [Interface] [Option]

Now, execute the following “ifconfig” command to view the currently active interfaces:

$ ifconfig

Other options of ifconfig command:

Option Description
-v The “-v” option is utilized in the ifconfig command for displaying the error conditions.
-a The “-a” option is utilized in the ifconfig command for showing all network interfaces.
-s The “-s” option is utilized in the ifconfig command for showing a shortlist.
  1. Curl Command

“curl” is an acronym for “Client URL”. It is a command-line utility used to transfer data to or from a server by utilizing its supported protocol.

If you do not have “curl” on your Linux-based system, then first install it by writing out the following command:

$ sudo apt install curl

Syntax:

$ curl [Option] [URL]

To print out the source code of any website such as “google.com”, execute the curl command and specify the URL in the following way:

$ curl google.com

Other options of curl command:

Option Description
-a The “-a” option is utilized in the “curl” command for appending the target file instead of overwriting it.
-K The “-K” option is utilized in the “curl” command for specifying a text for reading the curl argument.
-C The “-C” option is utilized in the “curl” command for resuming a file transfer at the given offset.
-b The “-b” option is utilized in the “curl” command for passing the data to the HTTP server in Cookie Header.
-d The “-d” option is utilized in the “curl” command to send the specified data in a POST request to the HTTP server.
-I The “-I” option is utilized only in the “curl” command for fetching the header.
  1. wget Command

“wget” is an acronym for “Web Get”. The “wget” command is used in the terminal to download the specified file from the internet using different protocols such as FTP, HTTP, and HTTPS.

Syntax:

$ wget [Option] [URL]

Before using “wget”, you have to install it first on your system:

$ sudo apt install wget

The above-given error-free output indicates that “wget” is now successfully installed on your system. Now, specify the file link which you want to download in the “wget” command and execute it:

$  wget  latest-hugo.zip  https://github.com/gohugoio/hugo/archive/master.zip

Other options of wget command:

Option Description
-c The “-c” option is utilized in the “wget” command for resuming a partially downloaded file.
-v The “-v” option is utilized in the “wget” command for printing the wget version available on your system.
-t The “-t” option is utilized in the “wget” command to specify the number of retries.
-b The “-b” option is utilized in the “wget” command for sending a process to the background when it starts.
  1. Last Command

The “last” command displays the list of currently logged users. You can also specify some parameters to enhance the functionality of the “last” command.

Syntax:

$ last [Option]

For instance, you can add the “-2” to the “last” command for checking the last 2 logs:

$ last -2

Other options of the last command:

Option Description
-F The “-F” option is utilized in the “last” command for checking the date, login, and log-out time.
  1. Yes Command

The “yes” command is used in Linux-based systems to print a continuous stream of the added text or String.

Syntax:

$ yes [String]

For instance, we will execute the below-given command for printing the String “101 Linux commands” infinitely in our Linux terminal:

$ yes 101 linux commands

  1. iostate Command

“iostate” is an acronym for “Input/Output Statistics”. The “iostate” command monitors the statistics of the input/output devices and partitions. It also tracks system input/output by looking at how long devices are turned on in proportion to their average transfer rates.

To use “iostate” command in your Linux terminal, firstly install the “sysstat” package with the help of following command:

$ sudo apt install sysstat

The “sysstat” package comprises various monitoring tools including the “iostate”:

$ iostat

Other options of iostat command:

Option Description
-p The “-p” option is utilized in the “iostate” command to display the blocked devices’ statistics.
-x The “-x” option is utilized in the “iostate” command for retrieving more extensive statistics information.
-k The “-k” option is utilized in the “iostate” command for capturing the statistics in kilobytes or megabytes.
-d The “-d” option is utilized in the “iostate” command for displaying only the device report.
-c The “-c” option is utilized in the “iostate” command for showing only the CPU statistics.
  1. Locate Command

The “locate” command is used for searching a specific file or directories in the file system.

Syntax:

$ locate [Option] [Pattern]

For instance, to find out the location of “testfile1.txt”, we will execute the following time:

$ locate testfile1.txt

From the output, you can see that “testfile1.txt” is located in our “/home/linuxhint” directory:

Other option of locate command:

Option Description
-i The “-i” option is utilized in the “locate” command to ignore the specified patterns’ case sensitivity.
-c The “-c” option is utilized in the “locate” command for writing the number of matched entries.
-b The “-b” option is utilized in the “locate” command for matching only the base name.
-A The “-A” is utilized in the “locate” command to display only entries matched with the specified pattern.
  1. Shutdown Command

The “shutdown” command is used to shut down the system in a secure way, and it also permits to specify a time for bringing your system down.

Note: To run the “shutdown” command, you must be root or have “sudo” Privileges.

Syntax:

$ shutdown [Option] [Time] [ Message]

To immediately shut down your system, type out the following “shutdown” command:

$ sudo shutdown now

In the next “shutdown” command, we have added the option to turn the system down after “20” minutes:

$ sudo shutdown +20

You can also write out a message in the shutdown command:

$  sudo  shutdown  +30  “Your  system  will  be  down  in  30  minutes”

Other options of shutdown command:

Option Description
-c The “-c” option is utilized in the “shutdown” command for canceling the scheduled shutdown process.
-r The “-r” option is utilized in the “shutdown” command for rebooting the system.
  1. Reboot Command

The “reboot” command is used for rebooting the Linux-based system. This command also needs “sudo” privileges to execute.

Syntax:

$ reboot [Option]

Here is the basic command for the system reboot:

$ sudo reboot

Other options of the reboot command:

Option Description
-halt The “-halt” option is utilized in the “reboot” command for stopping the machine.
-w The “-w” option is utilized in the “reboot” command for only writing the shutdown entry. It does not make the system halt, power off, or reboot.
  1. dir Command

“dir” is an acronym for “Directory”. In a Linux-based system, the “dir” command is used to list a directory’s content. Its listing format differs from the “ls” command, and it vertically sorts the files and directories in columns.

Syntax:

$ dir [Option] [File]

By default, the simple “dir” command lists out the directory of the current working directory:

$ dir

You can also add the “-l” option to list out the directory content with their detailed information:

$ dir -l

Other options of dir command:

Option Description
-S The “-S” option is utilized in the “dir” command for sorting the size of the file (descending order).
-s The “-s” option is utilized in the “dir” command for printing the allocated file size.
-v The “-v” option is utilized in the “dir” command for printing the source and the destination files.
-a The “-a” option is utilized in the “dir” command for displaying all hidden files.
  1. Apt Command

“apt” is an acronym for “Advanced Package Tool”. In Linux-based systems such as Ubuntu, the “apt” command is used to install, update, delete, and perform various other actions.

Syntax:

To install a package:

$ sudo apt install [Package_name]

To remove a package:

$ sudo apt remove [Package_name]

To search a package:

$ sudo apt search [Package_name]

To remove all unused packages:

$ sudo apt autoremove

To update all system packages:

$ sudo apt update

To upgrade all system packages:

$ sudo apt upgrade

To upgrade a package:

$ sudo apt upgrade [Package_name]

For instance, to install the “flameshot” package on our system, we will execute the command:

$ sudo apt install flameshot

The error-free output indicates that now we have flameshot installed on the Ubuntu system:

To remove the “flameshot” package from our system, we will write out the following command:

$ sudo apt remove flameshot

  1. Exit Command

The “exit” command is used for terminating the active shell session of the Linux terminal.

Syntax:

$ exit

Now, we will execute the “exit” command to end up the current terminal session:

$ exit

You can also press “CTRL+D” for performing the same function:

  1. Paste Command

The “paste” command is used for merging lines of the specified file horizontally.

Syntax:

$ paste [Option] [File1_name] [File2_name]

Now, we will join the lines or content of “testfile1.txt” and “testfile2.txt” by executing the below-given “paste” command:

$ paste testfile1.txt testfile2.txt

The “paste” will show the result in your Linux terminal:

Other option of paste command:

Option Description
-z The “-z” option is utilized in the “paste” command for setting lines delimiter to NULL.
-s The “-s” option is utilized in the “paste” command for pasting one file at a time instead of parallel merging.
-d The “-d” option is utilized in the “paste” to use TAB as a delimiter.
  1. Sort Command

The “sort” command is used for sorting the file in a specific order.

Syntax:

$ sort [File_name]

To sort out the content of “file1.txt”, we will type the following command: The “file1.txt” content is alphabetically sorted out on the terminal:

$ sort file1.txt

  1. Tar Command

“tar” is an acronym for “Tape Archive”. The “tar” command is used for creating an archive file, and this command also offers you the functionality to extract the archive files.

Syntax:

$ tar [Option] [Archive_file] [File_name]

For instance, to create a “file.tar” file of the “/home/linuxhint/Downloads” directory, we will execute the below-given command:

$  tar  -cvf  file.tar  /home/linuxhint/Downloads/

As you can see that “file.tar” is successfully created with the help of the tar command:

Now, to extract or un-tar the “file.tar” in the present working directory, write out the following command in your Linux terminal:

$  tar  -xvf  file.tar

Other options of tar command:

Option Description
-x The “-x” option is utilized in the “tar” command for extracting the archive file.
-c The “-c” option is utilized in the “tar” command for creating the archive file.
-v The “-v” option is utilized in the “tar” command for displaying the verbose information.
-t The “-t” option is utilized in the “tar” command for listing the files in an archived file.
-f The “-f” option is utilized in the “tar” command for creating an archive with the specified file name.
  1. gunzip Command

“gunzip” is an acronym for “GNU unzip”. The “gunzip” command is used to decompress the compressed file with the “gzip” command.

Syntax:

$ gunzip [Option] [File_Name]

Firstly, we will compress the “file1.txt” using the following gzip command:

$  gzip  file1.txt

After doing so, we will execute the below-given “gunzip” command to uncompress the “file1.txt.gz” file:

$ gunzip file1.txt.gz

Other options of gunzip command:

Option Description
-k The “-k” option is utilized in the “gunzip” command for keeping the input files.
-r The “-r” option is utilized in the “gunzip” command for recursively compressing directories.
-t The”-t” option is utilized in the “gunzip” command to test the compressed file’s integrity.
-l The “-l” option is utilized in the “gunzip” command for listing the content of the compressed file.
-S The “-S” option is utilized in the “gunzip” command for using suffixes on compressed files.
  1. Zip Command

The “zip” command compresses the specified files while reducing their size. This command stores compressed files in different segments or multiple files.

Syntax:

$ zip [Option] [Zip_Filename] [Files_List]

Here, we are zipping “file1.txt” by using the following command:

$ zip zippedFile.zip file1.txt

The zipped file of the “file1.txt” will be saved as a “zipped File.zip” file in the present working directory:

Other options of zip command:

Option Description
-x The “-x” option is utilized in the “zip” command for excluding some specific files while creating the zip.
-m The “-m” option is utilized in the “zip” command for deleting the original files after zipping.
-d The “-d” option is utilized in the “zip” command for removing the file from the zip archive.
-r The “-r” option is utilized in the “zip” command for zipping the directory recursively.
-u The “-u” option is utilized in the “zip” command for adding new files to the existing zipped file.
  1. Unzip Command

The “unzip” command is used for extracting the files from the zipped archive.

Syntax:

$ unzip [zipped_Filename] [Option] [Parameter]

To unzip the “zippedFile.zip,” which we have already created in the previous section, we will execute the below-given command:

$  unzip  zippedFile.zip

Other option of Unzip command:

Option Parameter Description
-x Filename(s) The “-x” option is utilized in the “unzip” command to exclude the specified files while archiving.
-o The “-o” option is utilized in the “unzip” command for overwriting the files.
-l The “-l” option is utilized in the “unzip” command to list the archive file contents.
-d /path/to/directory The “-d” option is utilized in the “unzip” command for unzipping an archive to a different directory.
-n The “-n” option is utilized in the “unzip” command for restricting it to overwrite existing files.
  1. Diff Command

“diff” is an acronym for “Difference”. The diff command is used for displaying the line-by-line difference between the specified files.

Syntax:

$ diff [Option] [File1] [File2]

For instance, to check out the difference between “file1.txt” and “file2.txt” files, we will execute the following diff command:

$  diff  file1.txt  file2.txt

Other options of diff command:

Option Description
-i The “-i” option is utilized in the “diff” command for making the command case insensitive.
-u The “-u” option is utilized in the “diff” command showing the difference in unified mode.
-c The “-c” option is utilized in the “diff” command for viewing the difference in context mode.
  1. hostnamectl Command

The “hostnamectl” command is used to view and change the system hostname.

Syntax:

$  hostnamectl  [Option]  [Command]

If you want to check out the current hostname, execute the following command: Here, the “status” command is added to view the settings of the current hostname:

$ hostnamectl status

Other options of hostnamectl command:

Option Description
–static The “–static” option is utilized in the “hostnamectl” command for changing the static hostname to the specified one.
–transient The “–transient” option is utilized in the “hostnamectl” command for changing the transient hostname.
  1. lsof Command

“lsof” is an acronym for “List Open Files”. The “lsof” command is used for displaying the information related to the opened files.

Syntax:

$ lsof [Option] [Username]

If you want to view the files opened by the active processes of the current user, then execute the simple “lsof” command in your Linux terminal:

$ ls

Other options of lsof command:

Option Description
-c The “-c” option is utilized in the “lsof” command to list the specified process files.
-i The “-i” option is utilized in the “lsof” command for listing all network connections.
-p The “-p” option is utilized in the “lsof” command for listing the opened files by a particular process id.
  1. Netstat Command

“netstat” is an acronym for “Network Statistics”. The netstat command is used for displaying the statistics related to networking protocols, network connections, and other interfaces.

Syntax:

$ netstat [Option]

To use netstat on your Linux system, you have to install the “net-tool” first:

$  sudo  apt  install  net-tools

Now, execute the simple “netstat” command and view the network statistics of your system:

$ netstat

Other options of netstat command:

Option Description
-l The “-l” option is utilized in the “netstat” command for showing the list of all active connections.
-i The “-i” option is utilized in the “netstat” command for showing the statistics of currently configured network interfaces.
-u The “-u” option is utilized in the “netstat” command to display the UDP port connections list.
-t The”-t” option is utilized in the “netstat” command to display the TCP port connections list.
  1. iptables Command

The “iptables” command is used for setting up the Netfilter firewall for IPv4.

Syntax:

$  iptables  [Option]  [Table]  [Chain]  [Parameter]

For instance, the execution of the below-given command will drop all the upcoming traffic on any port:

$  sudo  iptables  -t  filter  --append  INPUT  -j  DROP

Other options of iptables command:

Option Description
-A The “-A” option is utilized in the “iptables” command for appending the chain which is provided chain.
-C The “-C” option is utilized in the “iptables” command for checking if a rule exists in the chain or not.
  1. Service Command

The “service” command operates a System V init script that can be used for starting, stopping, restarting, or checking the status of the services.

Syntax:

$  service  [Script_name]  [Command]

Now, we will execute the following “service” command for checking the status of currently active services:

$ service --status-all

Other options of service command:

Option Description
stop The “stop” option is utilized in the “service” command for stopping service.
start The “start” option is utilized in the “service” command for starting a service.
restart The “restart” option is utilized in the “service” command for restarting a service.
  1. mpstat Command

“mpstat” is an acronym for “Multiprocessor Statistics”. The “mpstat” command is used for reporting the statistics related to the processor, CPU usage, and its performance.

Syntax:

$ mpstat [Option]

Now, we will execute the below-given command for displaying the CPU and processor statistics:

$ mpstat

Other options of mpstat command:

Option Description
-u The “-u” option is utilized in the “mpstat” command for displaying the CPU utilization report.
-A The “-A” option is utilized in the “mpstat” command to display detailed statistics.
-I The “-I” option is utilized in the “mpstat” command for displaying the interrupts statistics.
-T The “-T” option is utilized in the “mpstat” command for displaying the topology elements.
-o The “-o” option is utilized in the “mpstat” command for displaying the statistics in the JSON format.
  1. vmstat Command

“vmstat” is an acronym for “Virtual Memory Statistics”. The “vmstat” command is used for displaying the information related to disk, memory, processes, paging, CPU scheduling, and the block IO.

Syntax:

$ vmstat [Option]

Now, execute the “vmstat” command in your Linux terminal and check out the output:

$ vmstat

Other options of vmstat command:

Option Description
-d The “-d” option is utilized in the “vmstat” command for showing the disk statistics.
-a The “-a” option is utilized in the “vmstat” command to show your system’s active and inactive memory.
  1. uniq Command

“uniq” is an acronym for “Unique”. The unique command filters the repeated line in the specified file.

Syntax:

$ uniq [Option]

In the following “uniq” command, we have added the “-c” option for printing out the number of repeated lines on the terminal:

$  uniq  -c  file1.txt

The “uniq” command identified “ubuntu linux” is repeated three times in the “file1.txt”:

Other options of uniq command:

Option Description
-d The “-d” option is utilized in the“uniq” command for only printing out the repeated lines.
-u The “-u” option is utilized in the “uniq” command for only printing the unique lines.
-w The “-w” option is utilized in the “uniq” command for only comparing the “n” characters in a line.
  1. ncdu Command

“ncdu” is an acronym for “NCurses Disk Usage”. The “ncdu” command is used to check out the amount of disk consumed by the directories.

Syntax:

$ ncdu [Option]

Now, install “ncdu” on your Linux system with the help of the following command:

$ sudo apt install ncdu

In the below-given “ncdu” command, we have added the “-q” option for running it in quiet mode:

$ ncdu -q

Other options of ncdu command:

Option Description
-x The “-x” option is utilized in the “ncdu” command for omitting the mounted directories usage.
  1. Stat Command

“stat” is an acronym for “Status”. In Linux-based systems, the “stat” command is used to display a file system status.

Syntax:

$ stat [Option] [File]

For instance, the status of our “testfile1.txt”, we will execute the command:

$ stat testfile1.txt

Other options of stat command:

Option Description
-f The “-f” option is utilized in the “stat” command for displaying the file system status.
-t The “-t” option is utilized in the “stat” command for printing out the information in the terse form.
-L The “-L” option is utilized in the “stat” command for following the links.
-c The “-c” option is utilized in the “stat” command for specifying the format.
  1. Sleep Command

The “sleep” command is used for creating a dummy job that assists in delaying the execution in a system.

Syntax:

$ sleep [Number_Suffix]

For instance, to make the system sleep for thirty seconds, we will write out the “sleep” command:

$ sleep 30s

  1. Split Command

In the Linux terminal, the “split” command is used for splitting a single file into smaller files or segments.

Syntax:

$ split [Option] [filename] [Prefix]

We will split up the “testfile1.txt” into “5″ segments in the following example. The name of each segment will start with “what”, which is added as a prefix in the “split” command:

$  split  -l  5  testfile1.txt  what

From the below-given image, you can see that the five segments of our “testfile1.txt” are saved having the names: whataa, whatab, whatac, whatad, and whatae:

  1. Ping Command

“ping” is an acronym for “Packet Internet Groper”. The “ping” command checks the network between the server/host and host. You have to adda specific IP address as an input, and then the ping command sends a data packet. After getting the response from the host or server, the time is recorded, which is known as latency, and it is displayed in the output:

Syntax:

$ ping [Option] [IP_address] or [Hostname]

In the following example, we will check that the “yahoo.com” remote server is up or not:

$ ping yahoo.com

Other options of ping command:

Option Description
-i The “-i” option is utilized in the “ping” command for changing the interval time.
-s The “-s” option is utilized in the “ping” command for specifying the number of pings.
  1. Du Command

“du” is an acronym for “Disk Usage”. The “du” command retrieves the disk usage information in a particular directory.

Syntax:

$ du [Option] [File]

Now, execute the simple “du” command for showing the estimated size of the sub-directories in the present directory:

$ du

Other options of du command:

Option Description
-s The “-s” option is utilized in the “du” command for displaying only the total file size.
-a The “-a” option is utilized in the “du” command for displaying the information related to files and directories.
-h The “-h” option is utilized in the “du” command for displaying the file size in human-readable units.
-c The “-c” option is utilized in the “du” command for displaying the total file size at the end.
  1. Useradd Command

In a Linux-based system, the “useradd” command is used to add a new user account.

Syntax:

$ useradd [Option] [Username]

Now, we will create a new “linuxuser” in our system with the help of the following “useradd” command:

$ sudo useradd linuxuser

Confirm the existence of the newly created “linuxuser” user through the “/etc/passwd” file content:

$ cat /etc/passwd

Other options of the useradd command:

Option Description
-p The “-p” option is utilized in the “useradd” command for setting an unencrypted password.
-u The “-u” option is utilized in the “useradd” command for assigning the numerical value to the user ID.
-c The “-c” option is utilized in the “useradd” command for creating a user with a comment.
-e The “-e” option is utilized in the “useradd” command for creating a user with an expiry date.
  1. Usermod Command

The “usermod” command is used to change an existing user’s properties through the terminal.

Syntax:

$  usermod  [Option]  [Username]

Here, we will write a description for our “linuxuser” by adding the “-c” option in the usermod command:

$  sudo  usermod  -c  "This  is  a  linux  user  account"  linuxuser

Other options of usermod command:

Option Description
-u The “-u” option is utilized in the “usermod” command for changing the user ID.
-U The “-U” option is utilized in the “usermod” command for unlocking the user.
-L The “-L” option is utilized in the “usermod” command for locking the user.
-g The “-g” option is utilized in the “usermod” command for changing the user group.
-e The “-e” option is utilized in the “usermod” command to change the user’s expiry date.
  1. Userdel Command

The “userdel” command is used in a Linux system for deleting a specific user account and its related files.

Syntax:

$ userdel [Option] [Username]

For instance, to delete the “linuxuser” which we have created in the previous section, we will run the following “userdel” command:

$  sudo  userdel  linuxuser

Now, check out the content of the “/etc/passwd” to confirm the “linuxuser” account deletion:

$ cat /etc/passwd

Other options of userdel command:

Option Description
-Z The “-Z” option is utilized in the “userdel” command for removing the SELinux mapping of the specified user.
-r The “-r” option is utilized in the “userdel” command to remove the user account files, home directory, and the user’s mail spool.
-f The “-f” option is utilized in the “userdel” command for forcefully removing the specified user.
  1. awk Command

“awk” is an acronym for “Aho, Weinberger, and Kernighan”. “awk” is used as an analysis and reporting tool for advanced text processing in Linux-based systems:

Syntax:

$  awk  [Option]  [selection  _criteria  {action}  [Source_file]  > [Destination_file]

We will use the “awk” command to operate text processing on the”file.txt” file. Before moving ahead, let us show you the content of “file1.txt” by executing the following “cat” command:

$  cat  file1.txt

Next, we will define “OS” as a pattern in our “awk” command and execute it:

$  awk  '/OS/  {print}'  file1.txt

The above-given “awk” command will look for each line that gets matched with the added pattern. After searching, it will print them out in our Linux terminal:

  1. Dig Command

“dig” is an acronym for “Domain Information Groper”. The “dig” command is used to extract the information related to Domain Name servers.

Syntax:

$ dig [Server_name]

Now, we will query the Yahoo name servers (DNS) by executing the following command:

$ dig yahoo.com

  1. Whereis Command

The “whereis” command is used for searching the location of a command’s source or binary files.

Syntax:

$ whereis [Option] [Filename]

For instance, to locate the manual or binary file of the “netstat” command, we will write out the “whereis” command in the following format:

$ whereis netstat

Other options of the whereis command:

Option Description
-f The “-f” option is utilized in the “whereis” command for terminating the last directory list.
-b The “-b” option is utilized in the “whereis” command for only searching for binary files.
-S The “-S” option is utilized in the “whereis” command to limit or change places where it searches for the files.
  1. pstree Command

The “pstree” command lists out the active processes in the form of a tree.

Syntax:

$ pstree [Option] [User or PID]

You can execute the following command to display the currently running processes’ hierarchical tree structure:

$ pstree

Other options of the pstree command:

Option Description
-T The “-T” option is utilized in the “pstree” command for hiding the threads in the output.
-h The “-h” option is utilized in the “pstree” command to highlight the current processes and ancestors.
-n The “-n” option is utilized in the “pstree” command for sorting the output by the process ID (PID).
-p The “-p” option is utilized in the “pstree” command for showing process IDs.
-t The “-t” option is utilized in the “pstree” command for showing the full thread names.
  1. Tree Command

The “tree” command is used for recursively listing the directories in the tree structures.

Syntax:

$ tree [Option]

The execution of the following command will display a tree of the current directory in the Linux terminal:

$ tree

Other options of tree command:

Option Description
-d The “-d” option is utilized in the “tree” command only listing directories.
-l The “-l” option is utilized in the “tree” command for following the symbolic links into directories.
-a The “-a” option is utilized in the “tree” command to print the hidden files and others.
  1. printf Command

“printf” is an acronym for “Print Formatted”. In Linux-based systems, the “printf” command is used to show the variable value formatted by defining some rules.

Syntax:

$  printf  [-v  Variable  name]  [Format]  [Arguments]

In the below-given example, we have three arguments “50”, “smaller than”, and “100”. The “printf” command will interpret these variables from the left to right side with the given strings: %f,%d, and %s:

$  printf  "The  number  %f  is  %s  %d"  50  "smaller  than"  100

The above-given command will show the following output:

Other attributes of the printf command:

Attribute Description
%b The “%b” attribute is utilized in the “printf” command for expanding backslash escape sequences.
%u The “%u” attribute is utilized in the “printf” command for printing in the unsigned decimal integers format.
%o The “%o” attribute is utilized in the “printf” command for printing in the octal integers format.
%s The “%s” attribute is utilized in the “printf” command for printing arguments as strings.
  1. Find Command

The “find” command is used for searching for a specific file in the directory hierarchy.

Syntax:

$ find [Option] [Path] [Expression]

For instance, we will execute the below-given command for searching the “myFile.txt” in the “./Downloads” directory:

$  find  ./Downloads  -name  myFile.txt

Other options of find command:

Option Description
-p The “-p” option is utilized in the “find” command for printing the current file name.
-d The “-d” option is utilized in the “find” command for specifying a directory.
-f The “-f” option is utilized in the “find” command for specifying a file.
  1. Sed Command

“sed” is an acronym for “Stream Editor”. The “sed” command is used for performing the basic text transformation operations on the input stream.

Syntax:

$  sed  [Option]  {add_available  _script}  [Filename]

We will use the “sed” command to find and replace a string. For this purpose, firstly view the content of the “file1.txt” file:

$ cat file1.txt

The below-given “sed” command will find the “ubuntu” in the “file1.txt” and replace it with “MAC”:

$  sed  -i  's/ubuntu/MAC/g'  file1.txt

After executing the “sed” command, again check the content of the “file1.txt”:

$ cat file1.txt

As you can see, the “Ubuntu” string is now replaced with “MAC” in over the “file.txt” file:

  1. rmdir Command

“rmdir” is an acronym for “Remove Directory”. The “rmdir” command is used for removing the empty directory from your file system.

Syntax:

$ rmdir [Option] [Directory]

Let’s have a look at the list of the directories present inside our home directory: Here, “Folder1” is an empty directory:

$ ls

Now, to delete the “Folder1” directory, we will execute the following “rmdir” command:

$ rmdir Folder1

Other options of the rmdir command:

Option Description
-d The “-d” option is utilized in the “rmdir” command for using DELIM ads a field delimiter instead of TAB.
-p The “-p” option is utilized in the “rmdir” command for removing the specified directory and its ancestors.
  1. Chown Command

“chown” is an acronym for “Change Owner”. In Linux-based systems, the “chown” command is used for changing the file owner or the ownership of a directory.

Syntax:

$ chown [Option] [Directory]

Below-given “chown” command will change the owner to the “file1.txt” to “linuxhint”:

$ sudo chown linuxhint file1.txt

Syntax for changing the filegroup:

$ chown :group filename

Syntax for changing the user and group at once:

$  chown  user:group  filename
  1. lsblk Command

In the Linux system, the “lsblk” command is used to display the loop and block devices.

Syntax:

$ lsblk [Option]

Now, execute the “lsblk” command and check out the output in the terminal:

$ lsblk

Other options of the “lsblk” command:

Option Description
-d The “-d” option is utilized in the “lsblk” command for skipping the entries for slaves.
-m The “-m” option is utilized in the “lsblk” command for displaying the information related to owner, mode, and group.
-i The “-i” option is utilized in the “lsblk” command for using the ASCII characters for tree formatting.
-z The “-z” option is utilized in the “lsblk” command for printing the zone model for each device.
-b The “-b” option is utilized in the “lsblk” command for printing the size information in bytes.
-a The “-a” option is utilized in the “lsblk” command to display the empty devices.
  1. Screen Command

The “screen” command is used for creating and using multiple shell sessions from the opened session. This command is useful for executing scripts that run very long.

Firstly, install the screen on your Linux system if you do not have it already:

$ sudo apt install screen

To create a screen session, type out the screen in the terminal, press “CTRL+a” and then c. This specified action will open up a new window:

$ screen

You can execute the screen command with the “-ls” options to list the current screen sessions of the system:

$ screen -ls

Other screen commands:

Command Description
Ctrl+a + A The “Ctrl+a + A” command is executed to rename the current window.
Ctrl+a + “ The “Ctrl+a + ” ” command is executed to list all windows.
Ctrl+a + X The “Ctrl+a + X” command is executed to close the current region.
Ctrl+a + 0 The “Ctrl+a + 0” command is executed for switching the screen session 0.
Ctrl+a + tab The “Ctrl+a + tab” command switches the input focus to the next region.
  1. chmod Command

“chmod” is an acronym for “Change Mode”. In the Linux system, the “chmod” command permits the users to change the file permissions using the numeric or symbolic mode.

In numeric mode:

  • “-0” represents “no permission”
  • “-1” represents “execute”
  • “-2” represents “write”
  • “-4” represents “read”

In symbolic mode:

  • “u” represents “user”
  • “g” represents “group”
  • “o” represents “other”
  • “r”  represents “read”
  • “w” represents “write”
  • “x” represents “execute”

Syntax:

$ chmod [Options] [Permissions] [Filename]

Now, we will execute the below-given “chmod” command for changing the permission of the “Folder1” directory:

$  chmod  -R  754  Folder1

This command will assign the “read, write, and execute” permissions to the user and “read” permission to both group and others:

List out the directories in the long format and check out the file permissions of the “Folder1”:

$ ls -l

  1. grep Command

“grep” is an acronym for “Global Regular Expression Print”. The “grep” command is used to search a specified pattern in a file and then output the lines that comprise the pattern.

Syntax:

$ grep [Option] [Pattern] [File]

In the below-given example, we will execute the “grep” command for finding the “MAC” pattern in the “file1.txt” file:

$  grep  -i  "MAC"  file1.txt

Other options of grep command:

Option Description
-l The “-l” option is utilized in the “grep” command to display the filenames list.
-c The “-c” option is utilized in the “grep” command for printing the matched line count.
-v The “-v” option is utilized in the “grep” command for displaying the unmatched lines.
-h The “-h” option is utilized in the “grep” command for only displaying the matched lines.
-w The “-w” option is utilized in the “grep” command for matching the whole word.
  1. Basename Command

The “basename” command is used in cases when you want to extract the file names. It displays the last element of the specified file path in the Linux terminal.

Syntax:

$ basename [Name] [Suffix]

Now, we will execute the below-given “basename” command for printing the filename while removing the leading directories:

$ basename /Downloads/myFile.txt

  1. Which Command

The “which” command is used for identifying the executable binary file that launches when we issue any command in the Linux terminal.

Syntax:

$ which [Filename]

For instance, you can execute the following command for displaying the paths of “rmdir” executable files:

$ which rmdir

Other options of which command:

Option Description
-s The “-s” option is utilized in the “which” command for restricting it to only return 0 or 1: 1 if the executable files are not found and 0 if the executable file exists on the system.
-a The “-a” option is utilized in the “which” command for listing all instances of the executable files.
  1. wc Command

“wc” is an acronym for “Word Count”. In a Linux-based system, the “wc” command is used for counting and printing out the number of lines, words, and characters of the specified file in the terminal.

Syntax:

$ wc [Option] [Filename]

Now, we will execute the below-given “wc” command for counting the number of words, lines, and characters in the “file1.txt” file:

$ wc file1.txt

Other options of the wc command:

Option Description
-w The “-w” option is utilized in the “wc” command for printing the word count.
-m The “-m” option is utilized in the “wc” command for printing the character counts.
-c The “-c” option is utilized in the “wc” command for printing the byte counts.
-l The “-l” option is utilized in the “wc” command for printing newline counts.
-L The “-L” option is utilized in the “wc” command for printing the maximum display width.
  1. fdisk Command

“fdisk” is an acronym for “Fixed Disk Editor”. The “fdisk” command is used to view and change the entries in the disk partition table. It also permits Linux users to move data into new partitions, modify old drives, manage space for new drives or partitions.

Syntax:

$ fdisk [Option] [Device]

Now, execute the following command for checking out the basic details of your system partitions:

$ sudo fdisk -l

Other options of the fdisk command:

Option Description
-s The “-s” option is utilized in the “fdisk” command for showing the partition size.
-h The “-h” option is utilized in the “fdisk” command to view the help message and other options of the fdisk command.
  1. Date Command

The “date” command is used for printing or setting the current date and time of the Linux system.

Syntax:

$  date  [Option]  [Format]

For displaying the date and time in the UTC format, you can type out the following command:

$ date -u

Other options of date command:

Option Description
-s The “-s” option is utilized in the “date” command for setting the time according to the specified string.
-d The “-d” option is utilized in the “date” command for converting the specified string into a formatted date.
  1. tr command

“tr” is an acronym for “Translate”. The “tr” command is used for various text transformation options such as converting lowercase to uppercase, deleting the specified characters, and finding and replacing strings.

Syntax:

$ tr [Option] [String1] [String2]

Now, we will demonstrate the procedure of using the “tr” command for converting all of the text of “file1.txt”. For this purpose, firstly, we will check out the content of “file1.txt” with the help of the “cat” command:

$ cat file1.txt

Executing the following “tar” command will convert the lowercase text of “file1.txt” to uppercase:

$  tr  a-z  A-Z  <  file1.txt

Other options of tr command:

Option Description
-s The “-s” option is utilized in the “tr” command for combining the sequences of characters specified in the String1.
-d The “-d” option is utilized in the “tr” command for deleting the specified string from the file.
-c The “-c” option is utilized in the “tr” command for complementing the characters in String1.
  1. Fold Command

The “fold” command is used for wrapping each line of the specified file according to the added width.

Syntax:

$ fold [Option] [File]

For instance, we will execute the following “fold” command for wrapping the lines of “testfile1.txt” to the width of “30” columns:

$  fold  -w30  testfile1.txt

Other options of fold command:

Option Description
-s The “-s” option is utilized in the “fold” command for breaking the lines into spaces.
-b The “-b” option is utilized in the “fold” command for limiting the width in terms of bytes rather than columns.
  1. zcat Command

“zcat” command permits you to look into the compressed file content.

Syntax:

$ zcat [File]

For viewing the content of the “file1.txt.gz” file, we will execute the following command:

$ cat file1.txt.gz

  1. Parted Command

The “parted” command is used for managing the partitions of your Linux hard drive, and it also permits you to add, shrink, delete, or extend the partitions.

Syntax:

$  parted  [Option]  [Device]  [Command]

For displaying the partition layout of all block devices of your system, execute the “parted” command with the “-l” option:

$ sudo parted -l

Other options of parted command:

Option Description
-m The”-m” option is utilized in the “fold” command for displaying the parse able machine output.
-a The “-a” option is utilized in the “fold” command to set the alignment type for the newly created partition.
  1. Tac Command

“tac” command is used for reversing the order of the file content.

Syntax:

$ tac [Option] [File]

Now, before reversing the content order of the “file.txt”, check out its original order:

$ cat file1.txt

Next, we will execute the below-given “tac” command:

$  tac  file1.txt

From the output, you can see that the content order of “file1.txt” is reversed:

Other options of the tac command:

Option Description
-s The “-s” option is utilized in the “tac” command for using the specified string as a separator.
-r The “-r” option is utilized in the “tac” command for interpreting the separator as a regular expression.
-b The “-b” option is utilized in the “tac” command for attaching the separator before instead of after.
  1. Neofetch Command

Neofetch is a command-line utility used to display the system-related information such as shell, hardware, and kernel version.

To install neofetch on your system, type out the following command:

$ sudo apt install neofetch

After completing its installation, execute “neofetch” command in your Linux terminal and check the output:

$ neofetch

  1. xeyes Command

“xeyes” is a GUI program that permits you to follow the mouse pointer which sometimes becomes hard to locate. It is mainly utilized in the multi-headed system where the monitors are at a distance from each other.

Type out “xeyes” in your Linux terminal for creating an eye set on your Desktop:

$ xeyes

Conclusion

Basic Linux commands permit users to complete their system-related tasks efficiently and quickly. Knowing and mastering these Linux commands will undoubtedly be advantageous to you. However, it is not easy to remember many Linux commands and tools. Our eBook has carefully compiled the best 101 Linux commands that every Linux user should know. Practice them in your terminal to better understand Linux core principles. Good Luck!

About the author

Talha Saif Malik

Talha is a contributor at Linux Hint with a vision to bring value and do useful things for the world. He loves to read, write and speak about Linux, Data, Computers and Technology.