Home » Questions » Computers [ Ask a new question ]

Figure out what non-symlink path would be?

Figure out what non-symlink path would be?

On Linux, if I've cd'd around and am now in a directory, is there a way to figure out what the real path to that directory is if I had not used a symbolic link to get there?

Asked by: Guest | Views: 33
Total answers/comments: 2
Guest [Entry]

"For use with cd, use pwd -P:

$ pwd
$ mkdir -p 1/2/3/4/5
$ ln -s 1/2/3/4/5 5
$ cd 5
$ pwd
$ pwd -P

For generic symbolic links, use readlink:

$ cd ..
$ readlink 5

Or ls -l (with -d for directories):

$ ls -ld 5
lrwxr-xr-x 1 dave staff 9 Jul 24 10:10 5 -> 1/2/3/4/5"
Guest [Entry]

"An alternative method I used,

cd to the symlink
Ctrl+Shift+T #To open a new tab

New tab pwd, gives the symlink. ;)"