Most useful unix commands for beginners
Unix is one of the most popular and powerful OS of all time. Unlike Windows, you can use most of the tricky tasks with Unix commands from the Unix CLI.
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 tasks. 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.
Unix is a multitasking and multiuser operating system. It developed in the early 1970s 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 has 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 it.
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
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
It's used to display the contents of the current directory. Quite as same as dir command of windows.
ls
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.
tree
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. It's 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 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 the 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 the 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 the 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.
Comments
Lara
Great help. Thank you
Arya
Noted all of them. Can you add a bit more commands?
Khan Saab
Really helpful