Linux Current Directory

Understanding your current working directory and how to navigate the Linux filesystem is fundamental for any command-line user. This guide covers the essential commands pwd and cd.

pwd Command (Print Working Directory)

The pwd command is used to print the full pathname of the current working directory. It's a simple command with no arguments that immediately tells you where you are in the filesystem hierarchy.

Syntax

pwd [OPTION]...

Examples

Print current directory

pwd
# Example Output: /home/user/documents

Displays the absolute path of your current location.

cd Command (Change Directory)

The cd command is used to change the current working directory. It's one of the most frequently used commands for navigating the Linux filesystem.

Syntax

cd [DIRECTORY]

Examples

Change to a specific directory

cd /var/log

Changes the current directory to /var/log.

Move up one directory

cd ..

Changes to the parent directory of the current working directory.

Go to home directory

cd ~
# Or simply:
cd

Navigates to the user's home directory.

Go to previous directory

cd -

Switches back to the directory you were in immediately before the current one.

Change to a subdirectory

cd myfolder

Changes to a subdirectory named myfolder within the current directory.

See also