How to Navigate Linux Directories

How to Navigate Linux Directories

By: ZebraHost

What is great about Linux is that it can be navigated without the need for a Graphical User Interface (GUI). this allows you to dedicate more resources to your programs which maximizes the performance of your app or website.

To Navigate your system, you will need to use the terminal. This can be intimidating at first, and there are many commands to learn. But here are three basic commands to get you familiar with navigating your system.

CD

This is the primary command used to enter and exit directories on Linux. Simply place CD in front of the directory you want to enter.

cd /home/zebrahost

Example:

We are going to enter a directory with CD using the terminal. In an OS such as CentOS there will be no GUI but for demonstration purposes One will be used alongside the terminal. The demonstration is running Ubuntu 20.0.4 within VirtualBox.

When you first open your system, your terminal will look like this:

image

This is our home directory and every Linux system branches from this directory. To display that we are in the home directory as reflected by the GUI to the left I will type ls which is going to show the contents of this directory. As you can see folders like Documents, Downloads, Music, and more are all present.

In this example I am going to CD to the Documents folder.

type cd Documents in the terminal.

image

We are now within the documents folder where we can view and modify files.

But lets say we want to go back home. To do, this, you can type cd .. which will take you back to the previous directory in the branch. Simply use this command until you are where you want to be within your system.

image

LS

When navigating your system via the terminal, it is helpful to know which files exist within directories. When typing ls, you see a list of all files that exist within your directory.

in the directory you want to see the contents of, type ls in the terminal.

image

PWD

PWD is useful for finding where you are within the system. It will display where the current directory is within the system so that you can navigate back to another directory or copy file paths.

To use PWD, type PWD in the terminal. You will then see a directory path displayed in relation to where you are.

image

The “PWD” command is universal across all Linux systems and will work with popular distros such as Ubuntu, Debian, etc.