What is Command Prompt in Linux? [Commands & Navigation]

There are many ways to execute commands in Linux or any operating system. The oldest and the most flexible method of performing commands is through the command line interface. To do that, we use a program called terminal or command prompt in Linux. Command prompt is the go-to method for developers as it provides the best functionality of the operating system.

What is Command Prompt?

Command prompt is a program with a text-based interface that takes input as text and sends it to the operating system to perform operations. In Linux, it’s just a window with a blinking cursor where we can write our command.

Command Prompt window

The command line interface is the interconnect between the application and the kernel. Any command needs to go through the command line. So, the command prompt lets us interact with the operating system’s kernel. Extensive knowledge of command prompts in Linux will help you apply complex commands that are otherwise impossible through the GUI.Command Prompt structure

How to Open a Command Prompt?

There are many ways to open the command prompt in Linux. Here are 3 methods to open the command prompt in Linux.

Method 1: Using GUI

This is the easiest method and is suitable for beginners. This method relies on the GUI (Graphical User Interface). Here are the steps to open Command Prompt using GUI.

Steps to Follow >

❶ Press the Bottom Left icon to Show Application. All the applications installed in the machine will appear.

Command Prompt opening using Desktop Open Applications

❷ In the search box, type Terminal. An application named Terminal will appear.

Command Prompt search for terminal

❸ Click on Terminal. Then a window will appear. This window is the command prompt where you can type your command and see it run in the window.

Command Prompt

Method 2: Opening Command Prompt Inside a Directory.

You can open the command prompt inside a directory without typing commands to go inside.

Steps to Follow >

❶ From the Desktop, click on the Files icon from the left sidebar. The left sidebar is also called the Vertical Task Management Panel.

Command Prompt pressing on Files

❷ A new window will appear. This is the Home directory inside Linux. Let’s say you want to go inside the Documents folder. Use Left Double Click to go inside the Documents folder.

Command Prompt double clicking Documents

❸ Now you’re inside the Documents folder. Let’s say you want to open the command prompt inside the Document folder. Right Click anywhere inside the folder except on a file. Then Click on Open in Terminal.

Command Prompt clicking on Open in Terminal

 Command prompt or Terminal will open. If you look at the prompt, it will show that it is in the Documents folder.

Command Prompt opened in Document Folder

Method 3: Using Shortcut

This is the easiest method of opening the command prompt. On the keyboard, type CTRL + ALT + T and the command prompt will appear. If you look at the prompt, you’ll see a ~ symbol and a $ symbol. The ~ symbol means the Home directory and $ indicates the end of the path. That means you’re currently inside the Home directory.

Command Prompt Using Shortcuts

Commands for Navigation Inside the Command Prompt

Generally, we use the GUI to navigate through the command prompt. But in this section, you’ll learn to navigate using the command prompt. You can use this method for more professional use, like automation.

The cd command

The cd (change directory) command will let you change the current directory. Using this command, we can navigate inside or outside a directory.

The ls command

The ls (list) command is generally used to list the available files inside a directory. This command helps us understand what files or folders are inside a directory.

The pwd command

You can use pwd (print working directory) command to print the Absolute path of the current directory. This way, you can also keep track of your current directory without losing your way, even if the directory structure is quite complex.

Navigation Using the Command Prompt

Suppose you have a directory folder structure like the following image.

Command Prompt folder structure

You want to navigate in this folder structure using the command prompt. First of all, you need to remember that when you open the command prompt, the current directory is set as the Home directory by default. We have a folder named LinuxSimply on the Desktop.

Command Prompt opened in Home directory

Now you can follow the following two methods.

Method 1: Using Relative Path

Relative path means file path relative to the current directory. Using the following steps, you can use the Relative path in the cd command.

Steps to Follow >

❶ Open the command prompt. By default, it is opened in the Home directory. On the Desktop, you can see the LinuxSimply folder.

❷ To get inside that LinuxSimply, at first, we need to go inside the Desktop. Type the following command

cd Desktop/

Then press ENTER. You can also type TAB for auto-completion. Just type cd Des and type TAB. The prompt will autocomplete the rest of the command.

❸ You can type ls command to see the files or folders inside.

ls

Then press ENTER. You’ll see the files inside your Desktop. In this case, only the LinuxSimply folder is shown because that’s the only folder in the Desktop directory.

Output >

Command Prompt inside desktop folder

❹ If you want to go inside LinuxSimply, just type

cd LinusSimply

ls

Then press ENTER. Again. Using ls command, you can view that Folder_1 and Folder_2 are inside LinuxSimply folder.

Output >

Command Prompt path navigation using Relative path

Method 2: Absolute Path

Using this method, you can access any path using the cd command. But you have to write the whole path or the Absolute Path after the cd command. The Absolute path is the path that starts from the Home Directory and ends in the current directory. Let’s say you want to get inside the LinuxSimply folder, then Folder_2, and then FF3. You also want to view the file name inside the directory.

Type cd Absolute_File_path then press Enter.

cd Desktop/LinuxSimply/Folder_2/FF3

ls

As we can see, there’s a file name ‘Moby Dick.txt’

You can use pwd command to see the actual absolute path of the current directory.

pwd

Output >

Command prompt path navigation using Absolute path

Conclusion

In this article, you learned about the command prompt in Linux, its use, and how we can use it to navigate inside folders. You learned about the cd, ls, and pwd commands. You also learned about the Relative path and absolute path and how to use them in the cd command. These are some of the most essential commands that you’ll probably use. So, I recommend you memorize them or bookmark this page if you need to review them.


Similar Readings

Rate this post
Md. Rafsan Zani

Hello, I’m Md. Rafsan Zani. I have recently completed my Undergraduate from the Bangladesh University of Engineering and Technology (BUET). Currently, I’m pursuing higher studies abroad. I’m really interested in computer science and would like to learn a lot about the wonderful world of computers. Currently, I’m working as a Linux Content Developer Executive and find Linux really interesting. I certainly would like to learn more about Linux and implement them in my future studies. Read Full Bio

Leave a Comment