Unix is one of the most popular and powerful operating systems of all time. Unlike windows, we can use various Unix commands to accomplish some complex task. In this post, I will explain the most useful commands of Unix. Its specially for beginners as well as I will show you the alternate commands for windows also.

About Unix

about unixUnix is a multitasking and multiuser operating system. Its developed at early 1970’s and Dennis Ritchie (Inventor of C language) was one of the developers. At the early stage, it wasn’t a beginner friendly OS. First of all, Unix was specially developed for programmers. But after it starts to spread at the early 1980’s it gains much popularity among everyone. There is a huge list of commands Unix have but in this post, I will explain the top 10. However, if you want to read more about Unix you can check it at Wikipedia.

Most people get confused between Unix and Linux. Actually, they both support the POSIX expression now. So you can use the following commands on both of them.

Most useful Unix commands

touch command

Touch is one of the most useful commands. It helps to create an empty file of any extension.

$touch index.html

The above command will create an HTML file called index into the current directory.

cat command

The cat command is similar to touch except that it will create the file first as well you can put some stuff inside it and save.

$cat > hello.txt

If you enter the above command it will create the file hello.txt into that directory. After that, it will give you an interface to write something for that file. Whatever you have written in that area will be automatically saved to the file.

mkdir command

This command can create an empty directory inside the current directory. It is really a handy command which helps in faster development.

$mkdir codes

The above command will create a directory called codes into the current directory.

rmdir command

It’s the opposite of mkdir command. Basically its short for remove directory. Let’s remove the codes folder which we have created at last example.

$rmdir codes

Try to run the above command from the same directory where you have created it. Finally, you will see it will remove the folder called codes.

ls command

Its used to display the contents of the current directory. Quite as same as dir command of windows.


Run the above command inside any directory and it will show you the contents list. Unix has another command for this purpose so let’s check out that one.

tree command

It’s one of the powerful commands of Unix. It outputs each and every content inside of that parent directory in a tree structure.


Go forward and check the above command wherever you like.

sh command

If you are a programmer someone likes shell programming this command is for you. Just create a file with sh extension then write the code and save. Now open the shell and move to that directory and follow the command below.

$sh program.sh

The above command will execute the code inside of the program.sh file.

Bash command

Bash is another powerful alternate of sh command. Just like the sh command, you can execute shell scripts with bash.

$bash program.sh

Bash supports many new features of the shell so it’s far better to use bash.

rm command

This command is used to remove files. Its another superb feature of Unix. Seems like you can do anything from the shell. Let’s check out how to use this rm command

Unline others rm supports additional arguments. I am explaining one by one each of them.

-i argument

It removes the file interactively. That is it will ask for permission before removing the file. You can use it as follows.

$rm -i simple.txt

The above command will remove simple.txt file once you confirm the deletion.

-r argument

It removes the contents of the specified file first before removing the file. It’s a time-consuming process and not advised to use.

$rm -r simple.txt

-f argument

It one of the most powerful features of rm command. It can remove the file forcefully.

$rm -f simple.txt

mv command

mv command is used to move or rename a file(s) or directory. So let’s check out how to use it.

Rename files

$mv one.txt two.txt

The above command will rename the file one.txt to two.txt.

Move files

$mv one.txt path

The above code will move the file two.txt to the folder called path. The limitation of this command, you can’t move from one drive to another.

Finally, we have learned some most useful Unix commands. Hope you guy’s have liked this post on Unix commands. So don’t forget to share with your friends and let them also fall in love with Unix.


Subham Mitra

Subham Mitra is a full-stack developer as well as an aspiring entrepreneur who is pursuing MCA and providing brilliant stuff for a great range of people's through Coders Diaries.



Dimple Sharma · November 7, 2017 at 11:20 am

Thanks for sharing this information about unix commands. These are very basic and useful commands in Unix.


Aliyah · November 9, 2017 at 10:50 pm

Very helpful information. Thanks for sharing.


Aliyah · November 9, 2017 at 10:52 pm

i have found it really helpful


Bob Sanderson · February 26, 2019 at 4:41 pm

Thanks for sharing this list of commands. It is really helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.