Users Online

· Guests Online: 49

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

pwd - Command Usage Examples in Linux

“pwd” Command Usage Examples in Linux

This tutorial explains Linux “pwd” command, options and its usage with examples.

pwd- print working directory.

 

DESCRIPTION

The pwd command is considered as one of the most frequently used commands on Linux, AIX, HP-UX, *BSD, and other UNIX like operating systems along with the ls, and cd commands. It can be used for the following purposes under Apple OS X or UNIX or Linux operating systems:

1. Find the full path to the current directory.
2. Store the full path to the current directory in the shell variable.
3. Verify the absolute path.
4. Verify the physical path i.e exclude symbolic links.

SYNOPSIS

pwd [OPTION]…

OPTIONS :

-L, –logical
use PWD from environment, even if it contains symlinks.
-P, –physical
avoid all symlinks.

EXAMPLES

1. Simple usage of pwd(self explanatory)

$ pwd
/usr/local/bin
$ cd ..
$ pwd
/usr/local

2. To display the logical current working directory, enter

$ pwd -L

The -L option cause pwd to use $PWD from environment, even if it contains symlinks. If the contents of the environment variable PWD provide an absolute name of the current directory with no . or .. components, but possibly with symbolic links, then output those contents.

3. Display the physical current working directory (all symbolic links resolved)

For example, ~/bin/ is symbolic link:

$ pwd
$ ls -l ~/bin/

Sample outputs:

lrwxrwxrwx 1 abc abc 35 May 13  2012 /home/abc/bin -> /home/abc/realdata/scripts/utils/

cd to ~/bin/ and verify the current working directory with pwd:

$ cd ~/bin/
$ pwd

Sample output:

/home/abc/bin

To see actual physical current working directory and avoid avoid all symlink called /home/abc/bin, enter:

$ pwd -P

Sample outputs:

/home/abc/realdata/scripts/utils

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.96 seconds
10,817,898 unique visits