The pwd
command stands for “print working directory.” It is used in Bash and other Unix-like operating systems to display the current directory you are in within the terminal. This command is particularly useful for confirming your location in the filesystem.
The basic syntax of the pwd
command is as follows:
pwd [options] [arguments]
-L
: Use the logical current working directory. This option shows the path as it is set by the shell, which may include symbolic links.-P
: Use the physical current working directory. This option resolves all symbolic links and shows the actual path.Here are some practical examples of using the pwd
command:
pwd
to display the current directory.
pwd
pwd -L
pwd -P
pwd
in a script to store the current directory in a variable.
current_dir=$(pwd)
echo "You are currently in: $current_dir"
pwd
frequently to keep track of your current location in the filesystem, especially when navigating through multiple directories.pwd
with other commands in scripts to create dynamic paths based on the current working directory.pwd
can be affected by the options you choose, so select -L
or -P
based on your needs.