• 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 Use sed to Find and Replace String in Files

    How to Use sed to Find and Replace String in Files

    December 18, 2020
  • Linux Head Command

    Linux Head Command

    December 16, 2020
  • Rename Files and Directories in Linux

    How to Rename Files and Directories in Linux

    December 15, 2020

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on Debian 10
    How to Install Python 3.9 on Debian 10 December 25, 2020
  • How to Install Php 8 on Debian 10
    How to Install PHP 8 on Debian 10 January 2, 2021
  • How to Install Python 3.9 on CentOS 8
    How to Install Python 3.9 on CentOS 8 December 31, 2020
  • How to Install Php 8 on Ubuntu 20.04
    How to Install PHP 8 on Ubuntu 20.04 December 28, 2020
  • How to Install GIMP on Debian 10
    How to Install GIMP 2.10 on Debian 10 December 27, 2020
© 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