Skip to content

Navigating the Filesystem

Navigating the filesystem is a fundamental skill when working with the command line. Here are some basic commands to help you move around directories and view their contents.


pwd

pwd is used to print the current working directory (the directory you are currently in).

Example of pwd command

My current working directory is /home/clesucre/doc_tutorial.


ls

ls will list the contents of a directory. By default, it lists the files and directories in the current directory.

Example of ls command

As you can see, I have 2 files and 1 directory in my current working directory.

Flag Description
--help Display help information.
-l List files in long format.
-a List all files, including hidden files.
-h Print file sizes in human-readable format.
-t Sort files by modification time.
-S Sort files by size.
-r Reverse the order of the sort.
-R List subdirectories recursively.

cd

cd will allow you to change directories. You can specify the directory you want to move to as an argument.

Example of cd command

In this example, I used cd to move to the dir_1 directory.

Shortcuts

Here are some useful shortcuts you can use with cd:

Shortcut Description
cd .. Move up one directory.
cd ~ Move to the home directory.
cd - Move to the previous directory.
cd / Move to the root directory.
cd /path/to/directory Move to a specific directory.

Next Step

Now that you know how to navigate the filesystem, check out the next section on File Operations to learn how to create, copy, move, and delete files and directories.

Previous | Next