Some Basic Linux Commands I Have Used During My Linux Journey – Part 4

My linux journey has been great so far. I have learned so many commands that I feel a bit of a little ninja sometimes, but to be honest I am far from that. The more I use linux the more I understand that I don’t know much stuff about it.

You might want to check the previous parts of this series.

Many of you guys are interested in learning new commands and becoming more practical when it comes to the commandline, are you ready for some other commands?

The tail command

The tail command is very easy to use as the only thing you will need while using this utility is the name of the filename you want to output on the standard output, but in difference from cat it does not display the entire file, only the last parts of it.

The following example shows how to use the tail utility.

tail text.txt

The above command is going to print the last ten lines of the test.txt file on the standard output. Thee are also many other options that you can use with the tail utility such as the -c option which can be used to speficy the last K bytes you want to print to stdout, –retry to keep trying in case opening a file fails, -n to output the last K lines etc.

The nc command

nc is a great commandline utility which is being referred as the TCP/IP swiss army knife. It has been in the field for more than 20 years I think but its power has made it last so far. I find this small utility very useful when I want to debug stuff I code.

nc can be used both as a server and as a client. To do that you have to put the nc on the mode you want to use it.

For example if you would like to create a listener on your machine at a specific port you have to specify the port and the mode which in this case is listening.

The nc -l command puts nectat in listen mode.Run this command on your machine’s console and see what happens. If you want to learn new stuff you should keep trying and experimenting.

The following command puts netcat on listening mode and tell it to listen on port 13. Port numbers can be individual or ranges.

nc -l -p 13

You can also hex dump of traffic by using the -o option followed by the file where you want to do it. Do you like to create a simple chat with netcat? I am very sure it will make learning more interesting for you.

Lets do it.

Run netcat with the ‘-l’ option in order to operate in listening mode. You should also specify the listening port, I prefer 1300.

nc -l -p 1300

Then, run another ‘netcat’ which will initiate the connection by connecting to the server.

nc localhost 1300

Start chatting now by typing text in both parts. I mean in the netcat client and netcat server.

Be careful when using netcat. Do not allow people that can do malicious stuff to your machine. A very dangerous option that is supported by netcat is the -c option which is being used to specify specify shell commands in string format to exec after connection has taken place.

The apt-get install command

This command is debian specific. Ubuntu users use this command all the time to install new packages on their computers. For example to install nmap on my machine I just run the following command.

sudo apt-get install nmap

The apt-get install command takes care of the package dependencies for me, so the only thing I have to do while installing software with it is just type y when needed and drink some coffee while software downloads.

The apt-get autoremove command

The apt-get autoremove command is used to remove packages that were installed on your machine and are no longer required. Everything is done automatically, no need to specify the packages you want to remove as this is the purpose of this command.

sudo apt-get autoremove

Running the above command on my Ubuntu machine gives me the following output on the console.

 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following packages will be REMOVED:
 radiance-materials tcsh
 0 upgraded, 0 newly installed, 2 to remove and 379 not upgraded.
 After this operation, 14.4 MB disk space will be freed.
 Do you want to continue [Y/n]?

As you guys can see the above command reads the packages list, builds the dependency tree and informs the user about the packages that will be removed. If you want to continue just type the Y and hit return on your keyboard.

The cd ..

This command is very useful when you want to go back on directory. For example If I am working on the projects/pyproject/base and want to cd back to the pyproject I just run the following command inside the current working directory.

cd ..

The cd ../ command

There will be cases when you want to navigate back on your directories, but not just one so the cd .. comand is not useful in this case.

To do that use the cd ../ command. Let me show you guys a very simple example in order to make things practical for you.

First let me run the pwd command to print the current working directory on my console.


I get the following output.


To go to the home directory I do the following.

cd ../../

Doing pwd command again prints the following.


The whereis command

The whereis command can be used to locate the binary, source, and manual page files for a command. The usage is as simple as running the above command.

whereis ls

The above command locates binaries and manual pages for the ls command. Let me run it on my terminal and show you guys the output of this command.

After running the above command I get the following standard output on my console.

ls: /bin/ls /usr/share/man/man1/ls.1.gz

What does the above output mean? It is easy to understand if you know the location of the linux commands such as ls, pwd etc. It tells the user that the ls command binary is located in /bin/ls and the manual page is located in /usr/share/man/man1/ls.1.gz.

Why don’t you try it yourself now?

whereis pwd

Then try this.

whereis whereis

Then the following,

whereis cd

When running the above command I get the following output.

whereis: /usr/bin/whereis /usr/bin/X11/whereis /usr/share/man/man1/whereis.1.gz

Rename files with mv command

The mv command becomes very useful when you want to rename files. For example see the command shown below.

mv test.txt test13.txt

The above command changes the name of the test.txt file to test13.txt. You can also use the mv command to move files in different directories.

The more command

The more command helps to view the contents of a file by paging through text one screenful at a time. And to make it more practical to you guys try the following command.

more /etc/profile

The man command

The man command is a great tool that helps the user to learn about different commands, their options, different examples and how to use them. A manual page consists of the following sections:

  • NAME
  • BUGS

Every time I want to learn about a new command i reference to its manual page, to do that use the following syntax.

man command-name-here

You can also lookup the manual pages referenced by an item and print out the short descriptions of any found. If you want to do this use the following syntax.

man -f ls

The above command prints the following output.

ls (1) - list directory contents

And last but not least, use the following command to read more about the man command.

man man


You have learned many linux commands so  far. Do you know how to list files? Do you know how to ssh to a server? Do you know how to create a directory with the mkdir command? Do you know how to print the current working directory? Do you know how to copy files? If yes then good for you!