pwd Linux Command
Prints the current working directory (full path from root).
What does pwd do?
Prints the current working directory (full path from root).
Syntax
pwd [options]Practical example
pwdQuestions about pwd
What does pwd stand for?
pwd stands for 'print working directory'. It shows the full path of the directory you are currently in.
How do I find my current directory in Linux?
Simply run the `pwd` command in your terminal. It will print the absolute path of your current location in the filesystem.
What is the difference between pwd and pwd -P?
The `-P` option prints the physical directory path, resolving any symbolic links. Without it, `pwd` may show the logical path including symlinks.
How do I copy the current directory path?
Run `pwd | xclip -selection clipboard` to copy the path to your clipboard, or `pwd | pbcopy` on macOS.
Can I use pwd in a script?
Yes, `pwd` is commonly used in shell scripts to get the current directory. You can store it in a variable like `DIR=$(pwd)`.
Why does pwd show /home/user instead of just ~?
pwd always shows the full absolute path. The ~ is a shell shorthand for your home directory, but pwd expands it to the actual path.
What is the difference between pwd and echo $PWD?
Both show the current directory. `pwd` is a command, while `$PWD` is a shell variable that stores the same value. They usually produce identical output.
Related Navigation Commands
dirsDisplays the directory stack (list of directories saved with pushd).
lsLists files and directories in the current directory.
popdReturns to the directory saved by the last pushd command.
cdChanges the current working directory to the specified path.
pushdSaves the current directory and then changes to the specified directory.
cd ..Moves up one directory level (to the parent directory).