Linux is famous for its command line. Everything can be done with the help of commands, which makes it very easy to automate things by writing a script that combines these commands to carry out multiple actions. This makes linux very essential for developers, security analysts, data analysts or anyone in technology field. So in this article we will learn the basics of linux command line. To continue with this you will need to access to a unix system. These commands work on macos terminals, Windows Subsystem Linux terminals and any linux distribution terminals. So Let's get started.
Let's start by going through some of the basic commands that you can use in unix terminal.
The cal command is used to display the calendar of the current month in your terminal. It displays the calendar of the current month highlighting the current date.
The date command is used to display the current date and time details.
The pwd or (print working directory) command is used to print name of the present working directory active in the command line.
The man command gives the manual of the any command specified after it.
This command will give us the manual of the pwd command. Which has few options
The cd or change directory is used to change the directory in command line. When we know where we are using pwd command we can go to other directory using cd command.
Here, we changed to /home directory and when we used pwd command, we could see that /home was our current directory. Wherever we go, we can use the pwd command to check where we are in the command line.
The exit command is used to terminate the terminal session. It is always a good practice to end the session once you are done using the terminal.
You can use the UP and DOWN arrow keys to navigate the command line history.
You can use LEFT and RIGHT arrow keys to navigate withing the current command to modify it as required
The echo command is used to print message in the terminal. It prints any string passed to it
The mkdir command is used to create directories
This will create a new src directory in the current directory. We can use the -v option to get the message that the directory was created.
The ls command is used to list the files and directories in the current directory
We can also verify that mkdir command successfully created new directory by using ls command. We can also pass a path as argument to the ls command to list the contents of any directory
This will display the contents of /home/dl instead of current directory.
Note: To learn more about any command you can use the man command we discussed above
The less command is used to view the contents of a text file.
This will display the contents of the text file. If the content doesn't fit on the terminal screen, we can use the space to move forward and b to move backwards. We can then use the q key to exit the less and get back to the terminal. We can also use -N flag to enable the display of line numbers while viewing the text file.
In this article we learned the basics of Linux command line. We will have more articles to cover more on Linux and linux command line. I hope you enjoyed this article. Thank you 🙏