Connect with us!
Basic LINUX & Terminal Commands for Beginners
To learn how to use the LINUX terminal for your projects this article will guide you through the basic commands commonly used and with the examples, you will be able to use the terminal and do necessary operations easily.
Why Learn these Command?
Knowing the command line gives you full control over the machine. You can use these commands to change permissions, create directories, view hidden files, manage processes, etc.
By Learning these commands you can perform tasks much faster than using a GUI.
You could automate many tasks like creating 1000 files with unique names, searching for a string and replacing it and so on.
These commands are platform-independent. You can run these commands on LINUX, MAC and on Windows machines.
For MAC users already have LINUX so just go to the terminal and start typing these commands.
whoami
whomi
command is to print the user name of currently logged in to the terminal :
man
man <command>
means manual, it helps you to find how to use a command and gives a brief description about it:
You can then press q
to quit the window that will open which displays the manual page.
Clear
clear
command clears all the previous written commands on the terminal screen. You could give an option with the clear command say clear -x
, this command does not clear your scroll history.
If you don’t like to type this command there is a shortcut you can use to clear control+l
pwd
This command stands for Print Working Directory, it prints the current folder pat you are in. Default is your home directory, now I am inside the documents folder.
ls
This command lists all the files inside the folder. If you add a folder name or path to this command, it will print the contents inside that folder. ls -l
option -l
gives the file size and permission.
cd
This command stands for Change Directory. If you have a folder you can move into it using the cd
command. To use this command invoke it specifying a folder to move into. You can specify the folder name or and entire path.
The cd
command is used to navigate into any folder you want, initally, I typed in ls
command which lists all the folders and when I wanted to navigate to Desktop, give cd Desktop
and by typing pwd
command now I have navigated from home folder to my Desktop folder.
To go back type in ..cd
, by using ..
a special path that refers to the parent directory. If you want to go to your user name folder directly use cd ~
mkdir
This command is used to create a folder. mkdir <folder name>
eg: mkdir Test
We can create multiple folders mkdir <folder name1> <folder name2>
eg: mkdir Sample1 Sample2
We can create multiple nested folders by adding the option -p : mkidr -p Sample1/Eggs
touch
This command creates an empty file using touch <file name>
eg: touch Scripts
In this example initially, there were no files inside the Documents folder, once I give touch scripts
and then ls
we could see that the scripts file is created inside the documents folder.
If the file already exists, it opens the file in write mode.
rmdir
The rmdir
command will delete the folder created, but the folder should be empty. You can specify the folder name or pathname rmdir <folder name>
or rmdir <path name >
eg : rmdir Test
rm
This command removes the files inside the folder. rm <file name>
eg: rm test.txt
Thank you for reading. Hope this article was helpful. Good luck and happy coding!