Hi,
I'm running CentOS 5 and running into a strange situation with symbolic links that I have never seen or noticed before.
If I create the following symbolic link: [eric@eric-laptop ~]$ pwd /home/eric [eric@eric-laptop ~]$ ls Mail draft inbox queue sent trash [eric@eric-laptop ~]$ ln -s Mail/inbox test [eric@eric-laptop ~]$ ls test 1 2 3 4 5 [eric@eric-laptop ~]$ cd test [eric@eric-laptop test]$ pwd /home/eric/test [eric@eric-laptop test]$ ls 1 2 3 4 5 [eric@eric-laptop test]$ ls .. draft inbox queue sent trash
The strange behaviour here is when listing the parent directory (..). In this case, ls .. is listing the contents of Mail/ directory - not /home/eric.
In the past, I always recall being able to use the parent identified (..) to move up one level in the directory structure whether in a symlink or not. In this case, I would have expected ls .. to list the contents of /home/eric - not /home/eric/Mail.
Am I wrong? Am I seeing strange behaviour here? If so, is there a way to enable the behaviour I expect?
Thanks!
Eric
On 7/5/11, Eric B. ebenze@hotmail.com wrote:
The strange behaviour here is when listing the parent directory (..). In this case, ls .. is listing the contents of Mail/ directory - not /home/eric.
In the past, I always recall being able to use the parent identified (..) to move up one level in the directory structure whether in a symlink or not. In this case, I would have expected ls .. to list the contents of /home/eric - not /home/eric/Mail.
I believe it's normal. If I'm not mistaken, cd works based on the working path i.e. /home/eric/test so cd .. goes to /home/eric
However ls works by reading the .. inode of the directory you're in, which will always point to the real parent /home/eric/Mail no matter how you got to that directory.
On Tue, Jul 5, 2011 at 2:21 AM, Emmanuel Noobadmin centos.admin@gmail.comwrote:
On 7/5/11, Eric B. ebenze@hotmail.com wrote:
The strange behaviour here is when listing the parent directory (..). In this case, ls .. is listing the contents of Mail/ directory - not /home/eric.
In the past, I always recall being able to use the parent identified (..) to move up one level in the directory structure whether in a symlink or not. In this case, I would have expected ls .. to list the contents of /home/eric - not /home/eric/Mail.
I believe it's normal. If I'm not mistaken, cd works based on the working path i.e. /home/eric/test so cd .. goes to /home/eric
However ls works by reading the .. inode of the directory you're in, which will always point to the real parent /home/eric/Mail no matter how you got to that directory.
That's correct and it's the behavior most people seem to prefer.
To change it use `set -o physical` in Bash.
On Tue, Jul 05, 2011 at 06:52:47AM -0300, Giovanni Tirloni wrote:
On Tue, Jul 5, 2011 at 2:21 AM, Emmanuel Noobadmin centos.admin@gmail.comwrote:
On 7/5/11, Eric B. ebenze@hotmail.com wrote:
The strange behaviour here is when listing the parent directory (..). In this case, ls .. is listing the contents of Mail/ directory - not /home/eric.
In the past, I always recall being able to use the parent identified (..) to move up one level in the directory structure whether in a symlink or not. In this case, I would have expected ls .. to list the contents of /home/eric - not /home/eric/Mail.
I believe it's normal. If I'm not mistaken, cd works based on the working path i.e. /home/eric/test so cd .. goes to /home/eric
However ls works by reading the .. inode of the directory you're in, which will always point to the real parent /home/eric/Mail no matter how you got to that directory.
That's correct and it's the behavior most people seem to prefer.
To change it use `set -o physical` in Bash.
For completeness: "pwd -P" can be a help when navigating.