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
Examples
Print current directory
# 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
Examples
Change to a specific directory
Changes the current directory to /var/log.
Move up one directory
Changes to the parent directory of the current working directory.
Go to home directory
# Or simply:
cd
Navigates to the user's home directory.
Go to previous directory
Switches back to the directory you were in immediately before the current one.
Change to a subdirectory
Changes to a subdirectory named myfolder within the current directory.