Sitemap

Learn the basic Linux commands

4 min readMay 29, 2023

--

Knowledge of the terminal commands drastically increases the efficiency of work in a computer system allowing quick execution and access to the services along with the automation of repetitive tasks.

For those of you who are just starting out with Linux, I will document some of the most common Linux commands that can get you started right away with Linux and the bash shell.

So, open up the Terminal and let’s get started.

Common Linux Commands

The commands, their usage and results are provided below:

  • hostname:- This command will display the hostname of the system.
  • whoami :- This command prints the username on a given host.
  • pwd:- This command will output the path of the present working directory.
  • mkdir:- You can make/create a directory, followed by the directory name, with the help of this command
  • cd:- This command lets you to change the directory
  • touch:- You are able to create multiple files with the help of this command.
  • ls :- This command lets you list the items within a directory. With the use of several options we can enforce changes on the outcome of the ls command.
Press enter or click to view image in full size
  • rm:- This command removes the file and directory. Here, I will show you how to remove a file name file1.txt from the directory name directory and also list the results thereafter using the ls command.
Press enter or click to view image in full size
  • mv:- You can move a file from one location to another location.
Press enter or click to view image in full size

As you can see here, file2.txt was previously in the directory folder but after using the mv command, the file was moved from previous location(directory folder) to new location files directory.

Get Rupak Bhandari’s stories in your inbox

Join Medium for free to get updates from this writer.

cp:- This is the copy command which lets us create additional copy of existing file in a new location.

Additionally, we can use the find command to find a specific file or a file that matches a certain pattern. Here, we command the terminal to find out all the files present in the current directory with the extensions .txt

Additional Basic Linux Commands

Now let’s go a step further and add some more commands to our Linux command knowledge base. Here, you will be introduced with the additional Linux commands that you can add to your new found knowledge of basic Linux commands. You can kick-start with the basic Linux commands if you haven’t started with the Linux terminal as if yet.

So, without any dilly-dally, let me cut to the chase straight away.

Some More of Linux Commands

Here are some additional commands for you to learn.

  • uptime
Press enter or click to view image in full size
Execution of uptime command

The uptime command displays the running time of the device since the last boot.

  • echo
Execution of echo command

This command lets you print the value that follows this command. You can enclose the value-to-be-printed within the inverted commas or leave it as it is.

  • history

This command lists the previously entered commands( the entire history of the commands that you entered) on the bash shell.

Press enter or click to view image in full size
Result of the history command

The commands are logged in the .bash_history file located inside the home folder and it is this file that gets invoked when we use the history command in the bash shell.

Press enter or click to view image in full size

Try these commands and play around with them for a better understanding of how these commands work inside a terminal.

--

--

Rupak Bhandari
Rupak Bhandari

Written by Rupak Bhandari

AWS Cloud Practitioner venturing in the exploration of the domain of Information Security, Python and Linux System Administration