Actual Directory Location

Ok, here is a fairly easy question question that may have different answers depending on the expert.

A directory is actually a link, for example /var/test links to /opt/somedirectory/another/another/test

In unix, in this case Solaris, a user cds to the link using "cd /var/test"
While in that directory the user does a "pwd" and the output shows /var/test  

What simple command would you tell the user to use to find their actual location in the file system?
LVL 14
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

df .
arthurjbAuthor Commented:
df .
is an easy command, but (at least in my version) only shows the mount point of the top of the current file system.

for example, in this case if the filesystem was mounted at /opt/somedirectory a df . while in /opt/somedirectory/another/another/test    only shows    /opt/somedirectory

Good try.
/bin/pwd works for me ;) (instead shell internal command pwd)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

As ravenpl says, the stock /bin/pwd on most Unices will return the current directory after dereferencing symlinks.  If for some reason you can't access that, you can figure it out fairly easily by doing an "ls -ld $PWD"; if you need to have something that actually returns just the string representing the dereferenced path, then you'd probably have to parse the output of that using awk or perl.  Also, it's worth noting that most shells do have options to tell the shell to "chase" the link when cd-ing into a symlink, so that a pwd will return the dereferenced path; in ksh/bash, it's -P (option PHYSICAL), and zsh uses "-w" (option CHASE_LINKS).
which path would you like to see?
a) just the physical partition
b) the physical partition/mount point including full path on that partition/mount point
c) the complete path reach by using some a ptah which contains symlinks

according your question:
> What simple command would you tell the user to use to find their actual location in the file system?
the answers are:
a) df .
b) pwd # or /bin/pwd
c) echo $cwd; echo $PWD   # depends on your shell
anything else need a bit shell programming
ls -l $PWD
arthurjbAuthor Commented:

Good answers from all, but ravenpl hit the easy answer, and got it first.

the ls -l $PWD does not work, at least on Solaris 10  all it does is list the files in the current directory, it does not list the name of the current directory.

usually You need: ls -ld $PWD # or: ls -ld `pwd`
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.