Pwd #pwd Command In Hindi | Linux Directory Command | Linux Command | Class #4

pwd-command-in-Hindi

See all GNU/Linux related FAQ



=> Find the full path to the current directory.

=> Store the full path to the current directory in the shell variable.

=> Verify the absolute path.

=> Verify the physical path i.e exclude symbolic links.

The current directory

The current directory is nothing but the directory in which you are currently operating while using bash or ksh or zsh or tcsh/csh shell. You need to open a terminal (GUI) or login on a console to use a command line.

See all UNIX related articles/faq

Syntax

The syntax is:

pwd
pwd [options]
var=$(pwd)
echo "The current working directory $var."

Examples

To print current working directory, enter:
$ pwd
Sample outputs:

/home/vivek

In this example, /home/vivek is your current directory. The full path of any directory under Unix like operating systems always stats with a forward slash. In short:

  1. / – Forward slash – The root directory on your system or the file system.
  2. home – Sub-directory
  3. vivek – Sub-directory

To store current directory in a shell variable called x, enter:

x=$(pwd)

To print the current directory either use printf command or echo command:

echo "The current working directory : $x"

OR

printf "The current working directory : %s" $x

A typical Linux/Unix shell session with pwd

Most Unix users use the pwd command along with ls and cd commands:

## Where am I?
pwd
 
## List the contents of the current directory
ls
ls -l
 
# Change the current directory to Videos
cd Videos
pwd


Please Share this course

It Looks like you have completed your course!! We have created Online series based on the above content. You can give a test and check your skill.




Be a Part of CollegeSpike by giving your precious comment here and help us in improving our content.