pwd Command in Linux with Example

Posted in

pwd Command in Linux with Example

Vinay Khatri
Last updated on November 14, 2022

    The pwd command (print working directory) in Unix-like and other operating systems prints the entire pathname of the current working directory to standard output. The directory in which the user is working at the moment is referred to as the current working directory. You operate within a directory every time you interact with the command prompt (in Windows) or terminal (in macOS and Linux). When you connect to your Linux system , the current working directory is set to your home directory by default. pwd is a utility that is included in most contemporary shells, including bash and zsh . It behaves differently from the standalone /bin/pwd program.

    pwd Command in Linux Terminal

    You may obtain the instructional page of the pwd command by using one single command. It's always recommended to have a look at the manual of every command so that you get familiar with the options and other utilities that particular command provides. The following command will list all the details regarding the pwd command in your terminal:

    $ man pwd

    Once you run the command, you will be able to get an output like this below:

    How to Use PWD Command?

    Below are the two implementations of this command. The -L option with the pwd command will print the symbolic path of the current working directory while the -P option will print the actual path. If both -L and -P options are specified in the pwd command, the last one shall apply. If neither -L nor -P is specified, the pwd shall behave as if -L had been specified. Here is an illustration of how you can use the pwd command with -L and -P options:

    $ pwd -L: #symbolic path.
    $ pwd -P: #Prints the actual path.

    pwd Command Examples

    1. Print the working directory from the environment even if it contains symlinks:

    $ /bin/pwd -L

    You will get an output like the one shown below: 2. Print the version of pwd in the terminal:

    /bin/pwd --version

    The output you will get after executing the above-specified pwd command will be like the output shown below:

    3. Print all the locations containing an executable named pwd:

    $ type -a pwd

    The above command will give the following output:


    In this article, we discussed the pwd command in Linux. This command gives you the present working directory as the output. You can provide multiple options with the command like -L or -P to print present working directory in multiple forms. You may need the present working directory in many cases. For instance, while running a docker container, you will need to concatenate pwd command with the docker run command .

    People are also reading:

    Leave a Comment on this Post