Skip to main content
eLearner.app
Module 1 · Lesson 1 of 21/11 in the course~10 min
Module lessons (1/2)

Where am I? (pwd and ls)

The Linux command line (or terminal) is an extremely powerful tool that lets you interact with the operating system by typing text commands instead of using a graphical user interface.

All files and folders in Linux are organized in an inverted tree structure starting from a common root directory, represented by a single forward slash / (referred to as root). Every user has their own personal folder inside /home, for example, /home/user. This is known as the home directory.


Knowing Where You Are: pwd

In the terminal, you are always positioned inside a specific folder, called the current working directory.

To find out which folder you are currently in, you can use the command:

Bash
pwd

This command stands for Print Working Directory. If you run it right after opening the terminal, you will typically see the path to your home folder, for example:

Bash
/home/user

Listing Contents: ls

To see what files and folders are present inside your current directory, use the command:

Bash
ls

This command stands for List. It will show the names of all visible files and folders in your current location.

Useful Options for ls

Linux commands can be customized using options (also called flags or arguments), prefixed with a hyphen -:

  • ls -a: Lists all files, including hidden files that start with a dot (like .bashrc or .git).
  • ls -l: Displays the listing in long format, including details such as file permissions, owner, file size, and the date/time of last modification.
  • You can combine these flags by writing ls -la or ls -al to see all files in a detailed list.

For example, running ls -la in a sample folder might display a structured output like this:

Bash
drwxr-xr-x 2 user user 4096 May 22 12:00 .
drwxr-xr-x 3 user user 4096 May 22 12:00 ..
-rw-r--r-- 1 user user  220 May 22 12:00 .bashrc
-rw-r--r-- 1 user user   18 May 22 12:00 info.txt
drwxr-xr-x 2 user user 4096 May 22 12:00 documents

In this output:

  • Lines starting with d (e.g. drwxr-xr-x) represent directories (folders).
  • Lines starting with - (e.g. -rw-r--r--) represent regular files.
  • . and .. are special shortcuts linking to the current and parent directories.
  • .bashrc is a hidden file, recognized by its leading dot.

Try it yourself

Exercise 1: Find your position

Exercise#linux.m1.l1.e1
Attempts: 0Loading…

Write the command to find the current working directory you are in.

Loading editor…
Show hint

Use the command that prints the absolute path of the current directory.

Solution available after 3 attempts

Exercise 2: List files

Exercise#linux.m1.l1.e2
Attempts: 0Loading…

List the files in the current folder to see what resources are available.

Loading editor…
Show hint

Use the fundamental command for listing contents.

Solution available after 3 attempts

Exercise 3: Show hidden files

Exercise#linux.m1.l1.e3
Attempts: 0Loading…

Use the ls command with the appropriate flag to display all files in the current directory, including hidden files starting with a dot.

Loading editor…
Show hint

Use ls combined with the -a option.

Solution available after 3 attempts