• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

Current Working Directory (Pwd Command in Linux)

Written by Admin, Updated On December 20, 2019
bash, terminal
current-working-directory

Generally, new linux users confused for directory navigation using command-line. In this article, we explains how you can determine your current working directory using the pwd command.

Current Working Directory#

A directory where currently you are working in is know as Current Working Directory. By default, when you log in to your system, your current working directory is home directory. You can use simple cd command to navigate to directory.

For example, if you would like to navigate to /var directory, just type:

cd /var

pwd Command#

The pwd command is one of the most basic and frequently used commands in Linux. This command prints the complete path of the current working directory.

pwd is a shell builtin in most modern shells such as bash and zsh. Its behavior is slightly different than the standalone /bin/pwd executable. To view all locations containing pwd use the type command:

type -a pwd

It will show output as below:

pwd is a shell builtin
pwd is /bin/pwd

Find your Current Working Directory#

You can find currently in which directory you are. Type pwd command in your terminal as below:

pwd

It will look like below:

/home/tecnstuff

You can also show by printing environment variable.

echo $PWD

It will give same output as pwd.

/home/tecnstuff

You can pass two arguments along with pwd command:

  • -L (–logical) – It don’t resolve symlinks.
  • -P (–physical) – It will display the physical directory not any symbolic links.

By default, pwd command used without any arguments and it will behave as -L option.

For example, there is a directory /home/tecnstuff/test and symlink /tmp/testsymlink points to that directory.

Now once you navigate to the /tmp/testsymlink directory and you type pwd in your terminal:

pwd

It will show output that your current directory is /tmp/testsymlink:

/tmp/testsymlink

But if you will execute same command with -P argument, It will show print the directory to which the symlink points:

pwd -P
/home/tecnstuff/test

Conclusion#

In this article, we explain how you can determine the current directory using pwd command in Linux systems.

If you have any questions or feedback, feel free to leave a comment.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Uninstall Software Packages on Ubuntu
Next Article   Cd Command in Linux

Related Posts

  • How to Install SSH Keys on Ubuntu 22.04

    How to Set up SSH Keys on Ubuntu 22.04

    January 7, 2023
  • How to Install Fail2ban on Ubuntu 22.04

    How to Install and Configure Fail2ban on Ubuntu 22.04

    December 5, 2022
  • How to Enable SSH on Ubuntu 22.04

    How to Enable SSH on Ubuntu 22.04

    December 1, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
  • How to Install MariaDB on Debian 11 Bullseye
    How to Install MariaDB on Debian 11 Bullseye March 8, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook