paint-brush
Commencing Your Linux Journey: 8 Commands You Should Knowby@infinity
1,726 reads
1,726 reads

Commencing Your Linux Journey: 8 Commands You Should Know

by Rishabh AgarwalJune 7th, 2022
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Command Line Interface (CLI) provides a developer with much-needed speed and control over his or her job. Mastering command-line interface is critical for any prospective coder. Listing files using the ls command is one of the most popular commands in Linux. Use the touch command to create a new file in the current directory. Read a command’s manual using the man command. Print the content of a file using the cat command to print the contents of the file to the standard output sequence.

Company Mentioned

Mention Thumbnail
featured image - Commencing Your Linux Journey: 8 Commands You Should Know
Rishabh Agarwal HackerNoon profile picture

But why Command Line Interface (CLI)?


I asked this question to the computer professor at my university when he was trying to introduce Linux CLI or Command Line Interface to the class. Like most of the students in my class, almost all of the interaction that I have had with computers was using Windows OS. Accustomed to using ‘My Computer’ in Windows, utilizing weird-looking commands to do simple tasks such as listing files felt an overkill to me.


However, it turns out that the precision, power, and resilience of a CLI tool are significantly more than those of a GUI application. A command-line interface (CLI) provides a developer with much-needed speed and control over his or her job. As a result, mastering CLI tools is critical for any prospective coder.


In this article, we will see some of the most commonly used commands which every beginner should know.


1. List files using the ls command

The ls command is one of the most used commands in Linux. This command has a very simple utility and is used to list all files in a directory. Using combinations of options, the granularity and details of the file shown can be controlled. Here are some examples.


When used without any argument, the ls command lists the files and folders in the current directory.

$ ls


When a path is provided to this command, this commands lists file and folders in the provided directory.

$ ls path/to/my/directory


Users can also use various flags to display hidden files and folders.


2. Change directory using the cd command

Right next in popularity to the ls command is the cd command. Use this command to change the current directory. Consider it similar to double-clicking on a certain folder in Windows to enter it. The difference is that you can open any arbitrary folder as long as you know the path to that folder or directory.


$ cd /home/desktop/my_folder


When no path is specified, the directory is changed to the path - /home.


3. Create new files using the touch command

Use the touch command to create a new file in the current directory. Though simple, this command is very popular among CLI users. Consider it similar to creating a new text document by right-clicking in Windows. But with touch you can create all sorts of files, not just restricted to text files.


$ touch main.py


4. To know your current working directory, use pwd command

While some shells display the current working directory at the start of the cursor, we can use the pwd command to get the path to the current working directory. With a very simple usage, you will find it very useful when working on several shells at once. Consider this command as looking at the top bar in Window’s file explorer to see the path of the current folder.


$ pwd


5. Read a command’s manual using the man command

One of the greatest Linux commands is man. This command is also known as the manual command. The man command is only a help system for Linux commands. It enables users to search the reference manuals for authorities and other utilities used in the interface. The man page contains a description of the command, relevant arguments, variables, pictures, and other useful information (brief for handbook page). Use it in the following manner -


$ man pwd


6. Print the content of a file using the cat command

The cat Linux command is an abbreviation for concatenate. This command's duty is to print the contents of a file to the standard output sequence. It displays file information in the Linux terminal window. This is far more efficient than opening the file in an editor. Enter the following command to read the data from main.py.


$ cat main.py


7. Create a new directory using mkdir command

To create a new folder in Windows you would right-click and select a new folder. This is followed by giving a name to the new folder. All this process is performed by a single command called mkdir. Pass in the name of the folder/directory you want to be created and it will be created in the present directory. Here is an example.


$ mkdir New_Folder


8. Clear the content of the Terminal screen using the clear command

One of the simplest yet one of the most used commands. This command clears the content on the terminal screen. The usage of this command is as follows -


$ clear




This concludes with a list of some of the most used commands. Learning these commands lays the foundation for learning advanced and more complex commands.


Hit the like button to let Hackernoon know you are enjoying the blogs. Follow me on Twitter for more on Tech.