Skip to main content

tyler@zealousOS: ~/courses/linux/navigation-basics/003-what-is-around-me$

What Is Around Me

Seeing What’s Nearby

In the previous lesson, we learned how to answer the question:

Where am I on the filesystem?

We did that by using the pwd command to print our working directory.

In this lesson, we are going to answer the next natural question:

What is around me?

To do that, we will learn a new command called ls.

A Familiar Idea

If you have ever opened Finder on macOS or File Explorer on Windows, you have already used this concept.

When you open a folder, your computer shows you what exists inside of it:

The ls command does the same thing—but in a Command Line Interface.

Time to Use a New Command

To keep things clean, let’s run the clear command again.

After that, let’s practice what we learned in the previous lesson by using pwd to print the working directory.

Lastly, let’s type out our new command ls and execute it.

Taking a Look at the Result

If all went well, you should see something similar to the following:

Output of the LS Command

Understanding the first couple lines should feel familiar, as they are exactly what we saw in the previous lesson.

What interests us now are Lines 3 and 4.

1
2
3
4
5
localhost:~# pwd
/root
localhost:~# ls # <-- This is Line 3
bench.py    hello.c    hello.js    readme.txt # <-- This is Line 4
localhost:~#

Line 3

As we have seen before, as we type commands into our terminal emulator, they remain on the screen unless we use a command like clear.

This line is once again showing the prompt followed by the command we previously executed.

Line 4

Now this is where things get interesting.

As we saw earlier, the current working directory is /root.

On Line 4, we see the output of the ls command, which is a list of the contents that are found within the current working directory.

In our JSLinux filesystem, we now know that there are four files inside of the /root directory!

Learning about Our New Command: ls

If you haven’t guessed it already, ls is short for list directory contents.

We have only covered the most basic usage of this command.

ls can reveal a lot of interesting information about the files and directories in a directory.

Don’t worry—we will dive into these details in the next lesson. But here’s a small spoiler:

There are actually some hidden files in this directory.

Wrapping Up

The previous lesson introduced a lot of new concepts, so we took it easy in this one.

Even though this lesson was short, we covered a lot of ground.

In this lesson, you learned:

In the next lesson, we are going to learn how to list hidden contents and explore some basic theory around file naming conventions in Linux.