15 ‘pwd’ (Print Working Directory) Command Examples in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

13 Responses

  1. David Ecklein says:

    I want to print the filenames in my current directory.

    “pwd” doesn’t seem to print anything.

    what do I do to make it actually print the working directory?

    • Ravi Saive says:

      @David,

      Do you mean you want to list filenames? then use ls -l command. The pwd only print the current/present working directory location…I hope you get it now.

  2. prasad says:

    Write a shell script for printing all the files related information pwd( eg:size ,permissions

  3. teancum144 says:

    Great tutorial! Above, you make the following comment:
    “If no option is specified at the prompt, pwd will avoid all symlinks, i.e., take option ‘-P‘ into account.”
    However, in Fedora 20, pwd without options defaults to pwd -L.

    • Avishek Kumar says:

      Dear teancum144,
      I would surely like to go through my Fedora 20 Local server to confirm. This is quiet possible. Thanks for your feedback.

  4. Minecraft says:

    Your pwd article could contain so much.
    Thanks for a good article.

  5. Geoff says:

    A few corrections…

    If -L and -P are both used, -L does not have priority; they each override the other (last one wins). Also, for coreutils pwd the default depends on an environment setting. From “info coreutils”:

    “If `-L’ and `-P’ are both given, the last one takes precedence. If
    neither option is given, then this implementation uses `-P’ as the
    default unless the `POSIXLY_CORRECT’ environment variable is set.”

    As far as I know the shell built-in versions of pwd in all the POSIX-type shells (bash, dash, ksh, etc.) follow the POSIX requirement of defaulting to -L.

    The /usr/include/pwd.h header is unrelated – it provides the API for accessing /etc/passwd (or network equivalents).

    • Avishek Kumar says:

      Yeah Geoff!

      avi@tecmint:~/htm$ /bin/pwd
      /var/www/html

      avi@tecmint:~/htm$ /bin/pwd -L
      /home/avi/htm

      avi@tecmint:~/htm$ /bin/pwd -P
      /var/www/html

      avi@tecmint:~/htm$ /bin/pwd -P -L
      /home/avi/htm

      avi@tecmint:~/htm$ /bin/pwd -L -P
      /var/www/html

      we need to correct the write-up. Thanks for pointing that out.

  6. djf says:

    Never thought your pwd article could contain so much – especially liked the tie in with the “type” command – which I should have known but did not.

    Thanks for a surprisingly good article.

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *

Join Over 300K+ Linux Users
  1. 177,942
  2. 8,310
  3. 37,548

Are you subscribed?