Where Am I? The pwd Command

When you open a terminal, you are always "standing" inside a directory on your file system. Before you start moving around, it helps to know exactly where you are. That is what pwd (print working directory) does.

pwd

The output will look something like:

/home/john

This tells you the full, absolute path of the directory you are currently in. On Linux, every user has a home directory located at /home/username. When you first open a terminal, this is where you start.

💡
Absolute vs. Relative Paths

An absolute path starts from the root of the file system (/) and describes the complete location, like /home/john/Documents. A relative path describes a location relative to where you currently are, like Documents (no leading slash). Both are valid ways to refer to files and directories.

Moving Around with cd

The cd (change directory) command is how you move from one directory to another. It is the most frequently used navigation command and the foundation of terminal workflow.

Basic Usage

To move into a directory, type cd followed by the directory name or path:

# Move into the Documents folder
cd Documents

# Verify you moved
pwd
/home/john/Documents

Going Up with ..

Two dots (..) represent the parent directory -- the directory one level above your current location. You can chain them together to go up multiple levels.

# Go up one level
cd ..

# Go up two levels
cd ../..

# Go up one level and into a sibling directory
cd ../Downloads

Handy cd Shortcuts

cd ~ Go to your home directory from anywhere. You can also just type cd with no arguments.
cd - Go back to the previous directory you were in. Very useful for toggling between two locations.
cd / Go to the root of the entire file system.
# Jump home from anywhere
cd ~

# Or simply
cd

# Toggle between two directories
cd /var/log
cd /etc/nginx
cd -
# You are now back in /var/log

Listing Files with ls

Once you have navigated to a directory, you need to see what is inside it. The ls command lists the contents of a directory.

Basic ls

ls

This shows the names of files and folders in your current directory. However, it hides files that start with a dot (hidden files) and does not show much detail.

Useful ls Flags

ls -l Long format. Shows permissions, owner, group, size, date, and name.
ls -a Show all files, including hidden ones (those starting with a dot).
ls -la Combine long format and show all. This is the most commonly used form.
ls -lh Long format with human-readable file sizes (KB, MB, GB instead of bytes).
ls -lt Long format sorted by modification time, newest first.
# List everything with details
ls -la

total 32
drwxr-xr-x  5 john john 4096 Mar  1 10:30 .
drwxr-xr-x  3 root root 4096 Feb 15 08:00 ..
-rw-------  1 john john 1200 Mar  1 09:15 .bash_history
-rw-r--r--  1 john john  220 Feb 15 08:00 .bashrc
drwxr-xr-x  2 john john 4096 Feb 20 14:00 Documents
drwxr-xr-x  2 john john 4096 Feb 22 11:30 Downloads
-rw-r--r--  1 john john  675 Feb 15 08:00 .profile

You can also list the contents of a specific directory without navigating into it:

# List contents of /etc without moving there
ls -l /etc

Tab Completion for Faster Navigation

One of the most powerful features of the Linux terminal is tab completion. Instead of typing out long directory or file names in full, you can type the first few characters and press Tab.

1
Type the beginning of a name: cd Doc
2
Press Tab -- the shell completes it to cd Documents/
3
If multiple matches exist, press Tab twice to see all options. Then type more characters to narrow it down.
💡
Tab completion prevents typos.

Get into the habit of using Tab after every few characters. It is faster than typing full names, and if nothing completes, it tells you the path does not exist -- catching mistakes before you run the command.

Understanding the Linux Directory Tree

Linux organizes everything into a single directory tree starting at the root (/). Unlike Windows which uses drive letters (C:\, D:\), Linux mounts everything under this one tree. Here are the most important directories you will encounter:

/ The root directory. Everything starts here.
/home Contains personal directories for each user. Your files live here.
/etc System configuration files. Most services are configured here.
/var Variable data like logs (/var/log) and web files (/var/www).
/tmp Temporary files. Cleared on reboot.
/usr User programs and utilities. Most installed software lives under /usr/bin.
⚠️
Stay out of system directories as a beginner.

Directories like /etc, /usr, and /var contain files that your system needs to run. Browse them freely with ls, but do not modify anything there unless you know what you are doing.

Summary

In this tutorial, you learned the three core navigation commands:

  • pwd -- Print your current working directory
  • cd -- Change to a different directory (with shortcuts like ~, .., and -)
  • ls -- List directory contents (with flags like -la and -lh)
  • The difference between absolute and relative paths
  • How to use Tab completion to navigate faster
  • The basic layout of the Linux directory tree
🎉
Great progress!

You can now move around the Linux file system with confidence. In the next tutorial, you will learn how to create, copy, move, and delete files and directories.