Finding your way on a Linux System part 2

Using Directories and Listing Files

Files and Directories

In this article, we will explore directories and the listing of files in Linux systems. Files contain data used by the computer system. Directories are used to create organization within a file system. Directories can contain files and other directories.

For example, we can use this command to check the directories and files you have.

$ tree

If you are on Ubuntu you can install the tree with the following command:

$ sudo apt install tree

$ sudo snap install tree
Sample output
├── --background
├── cockroach-data [error opening dir]
├── cockroach-latest.linux-amd64.tgz
├── cockroach-v21.1.11
│   └── src
│       └──
│           └── cockroachdb
│               └── cockroach
│                   ├── AUTHORS
│                   ├── _bazel
│                   │   ├── bin
│                   │   ├── cockroach
│                   │   ├── out
│                   │   └── testlogs
│                   ├── build
│                   │   ├── archive
│                   │   │   ├── contents
│                   │   │   │   ├── Makefile
│                   │   │   │   └── README
│                   │   │   └──
│                   │   ├── bazelbuilder
│                   │   │   ├──
│                   │   │   ├──
│                   │   │   └── Dockerfile
│                   │   ├── bazelutil
│                   │   │   └──

From the above, we have 492 directories and 2847 files.

File and Directory Names

In Linux, It is not advisable to use special characters or use spaces when naming files or directories. Spaces for example need escape character \ to be entered correctly. For example

$ cd Report \ schedule

Take note of the escape character \.

Navigating the Filesystem

Getting current location

In the Linux command line menu, we use pwd to know the current location. For example

$ pwd

Let’s say we are in the Documents directory and inside documents, we have a WordPress subdirectory. We can know where we are by using pwd command.

The relationship of directories is represented with a forward slash (/). WordPress is a subdirectory of documents which is a subdirectory of sang which is located in a directory called home which has a parent directory root.

Listing Directory content

Listing contents of the current directory is done with the ls command. The ls command only sees the content of the current directory.

$ ls

Changing Current Directory

Navigation in Linux is done with the changes directory command (cd).

We can still use cd to go back to the home directory.


We have learned how to go about Linux by using special commands such as ls, cd, and pwd. Make sure you understand how to use it because it’s necessary when navigating through Linux. Next, we will explore Creating, moving, and deleting files in Linux.

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

Your email address will not be published. Required fields are marked *