Learn 14 Basic Unix Commands.
Master these Unix Commands as you read along & learn how to use them. The top 14 Unix Commands every developer should know.
Maybe the first question that arises in your head is why should we learn the Unix Command line?
At the end of the day, what it all boils down to is about greater control & in your journey of becoming a better developer, you'll need to understand & exert more power over your tools that's the Computer hardware. As you use these commands on a day-to-day basis you'll find out that it's actually easier & faster to do a lot of really common things.
There's a fair chance you'll have to interact with the bash terminal at some point in your programming career, so it's wise to get familiar with it at an early stage to gain a competitive edge over other developers who don't.
By the end of this blog, you'll have a strong command/grasp of these 14 basic commands which are extensively used in the bash terminal.
Before you proceed further, take a look at the list of the commands you'll be exploring in this blog.
- ls
- ls -a
- cd
- cd ~
- cd ..
- mkdir
- touch
- start
- rm
- rm *
- rm -r
- mkdir .
- pwd
- clear
Basic Unix Commands
- ls:
The 'ls' command in Unix expands to 'List' which gives a fair hint as to what the command does. Yes, it is used to Lists the names of files inside a particular directory.
Syntax:
ls
Just type the 'ls' & hit enter and it'll show all the files of the current directory in which you are working.
- ls -a:
This command will show the hidden folder inside the current directory.
Syntax:
ls -a
This command shows the hidden folder which is inside the intro-to-node directory.
-cd:
It stands for "change directory" as the name suggests, it's used to change the current working directory to a specified folder inside the terminal.
Syntax:
cd directory_name
Tip: Instead of typing the entire directory name just type half of it & hit the "tab" key.
- cd ~:
It also stands for "change directory" but as you notice there's a tilde sign so what does it do? It'll take you back to the root directory.
Syntax:
cd ~
- cd ..:
This command is used to navigate to the parent directory of the current directory.
Syntax:
cd ..
Here, Documents is the parent directory of the Music Folder.
- mkdir:
It stands for "Make Directory". so we use this command to create a folder inside the current working directory.
Syntax:
mkdir directory_name
Here, we created a Music directory inside the Documents directory.
- touch:
Used to create a text file.
Syntax:
touch file_name.Extension
As you can see we just created a "Text.txt" file in the Music folder.
- start:
Used to open a file.
Syntax:
start file_name
This command opens the "Text.txt" file in the Notepad Application.
- To open in an Atom application:-
Syntax:
start Atom file_name.Extension
This command opens the "Text.txt" file in the Atom Application.
- To open in a vs code application:-
Syntax:
start code file_name.Extension
This command opens the "index.html" file in vs code Application.
- rm:
Used to delete the file from inside the working directory.
Syntax:
rm file_name
- rm *:
Used to delete all the files inside the current directory.
Syntax:
rm *
This command deletes all the files inside the "Music" directory.
- rm -r:
Used to delete directory.
Syntax:
rm -r directory_name
This Command deletes the "Music" directory which is inside the "Documents" directory.
- mkdir .:
Used to create a secret directory/folder.
Syntax:
mkdir .file_name
- pwd:
It stands for "Print Working Directory" & used to displays the full path of the current working directory you're in.
Syntax:
pwd
- clear:
This command is used to clear the console. It'll delete all the previous commands.
Syntax:
clear
Here're some tricks that might be very useful:
⭐ If you want to go to the beginning of the command line then you can simply hold down to
ctrl + a
⭐ If you want to go to the end of the command line then you can simply hold down to
ctrl + e
⭐ You can simply go through your previous commands by using :
Up 🔼 & down 🔽 key
⭐ To clear the command line without executing it
ctrl + u
Found this article interesting? Show your love for this article.
Any awesome UNIX command you wish to share with us? Drop it in the comments below. Also, if you enjoyed reading this article, don't forget to share it with your friends!