Linux Basic Commands | Linux for Beginners

linux basic commands

This article will cover Linux fundamentals, including the most commonly used commands in a day-to-day job. I’m sure you will feel comfortable at the end of the article and Linux will look easier.

All the best, let’s start.

Open up the terminal. You will see vboxuser, at the rate sign, linuxmint, and $ sign.

Vbox is the currently logged in user, linuxmint is a hostname. $ sign shows vboxuser is a normal user and not admin. # identify the admin or root user.

1. hostname

You can check the host name using hostname command. Host name uniquely identifies the machine on the network.

hostname

2. whoami

Who is currently logged in? We can use whoami command. You can see from the screenshot, vboxuser is logged in.

whoami

3. ip addr

We see now how can we check own IP address on Linux. It is an important task because you are connected to some network. We use ip addr command on the terminal.

ip addr

4. pwd

The next is pwd command. Uptil now, we have executed some commands but we do not know the location where we are. Pwd is the command that displays the current working directory.

pwd

5. ls

Every user has its own directory in the /home folder. So we are in /vboxuser directory which is in /home directory.

Now we see what are the contents of /vboxuser directory. We will use ls command. Ls shows all the files and folders present in your directory.

ls

6. mkdir

You will some of the folders in your home directory. They are by default and are created when you install the Linux system. How about creating your own folders or directories? We use mkdir command.

mkdir folder-name

As you can see from the screenshot, an additional folder has been created.

7. cd

In Windows, whenever we want to go inside a folder we double-click it. In Linux, we use cd command.

cd folder-name

Cd is short for change directory. Linux supports auto-completion of commands. Type some of the characters and press the tab key.

cd myfolder

We have learned how to go inside a folder but if we want to come out from folder we will use:

cd ..

We have come one step back. If we want to come back one step, we will use cd again..

8. find

Now, there is one thing if you have hundred or thousand of folders and you want to search a specific folder, we will use find command.

find specific-folder-or-path-to-search -name folder-name

Suppose we want to search myfolder inside our home directory. We will run:

find /home/vboxuser -name myfolder

9. tar

How can we compress and uncompress file or folders? In windows you use zip so that the large files can be transferred easily over the network. In Linux, you can do the same. Let’s see, how.

We can use the tar command to package files in a single folder.

tar cvf file-name.tar file1 file2

Our command will look like when we want to package files file1 and file 2 inside files.tar

tar cvf files.tar file1 file2

10. Gzip

Once we have packaged the files, let us compress them by using gzip command.

gzip files.tar

Once you ls, you will notice the existence of additional file files.tar.gz in your current directory.

11. gunzip

To uncompress the file, we can use gunzip command.

gunzip file-name

The complete command will look like,

gunzip files.tar.gz

You will notice the tar file after the completion of a command.

Now, untar the file files.tar and you will notice the existence of two files file1 and file2 in your folder.

tar xvf files.tar

12. Conclusion

I hope you liked the article. If this was your first visit, do follow and subscribe Linux World.