Sunday 27 August 2017

linux - Why does "ls -a" hide some existing directory from the root user?


Today I found something really interesting (at least to me) on one of our test servers:


I can change into an existing directory from my actual working directory using a relative path, but that very same directory is not listed when using ls -a.


Here is the shell session (as root):


$ pwd
/you/are/here
$ ls -a
. .. <-- Note: "somedir" is not shown to root
$ echo $CDPATH

$ cd somedir <-- But still: "cd" works fine
$ pwd
/you/are/here/somedir
$ cd ..
$ pwd
/you/are/here
$ ls -a
. ..

Could someone tell me, how is this possible at all? I have checked: ls is from /bin/ls, and pwd is /bin/pwd, both from their original package (I mean: not hacked).


/you is a mounted EMC disk (ext3). And somedir exists as I can list the contents of it (there are several subdirs, files). Its name does not start with a dot.


Some more shell session, with more info about the commands and the ls output:


root@U-TEST@AT$/bin/ls -ali
total 4
16515074 drwxrwxr-x 2 U8000966 test 2048 Sep 1 07:39 .
16515073 drwxrwxr-x 3 U8000966 test 2048 Apr 27 2006 ..
root@U-TEST@AT$ls -ali somewhere | head -5
total 182
16515075 drwxrwxr-x 43 U8000966 test 2048 Sep 1 07:39 .
16515074 drwxrwxr-x 2 U8000966 test 2048 Sep 1 07:39 ..
16519169 drwxrwxrwx 4 U8000966 test 2048 Jul 25 2007 AAA
16515124 drwxrwxr-x 3 U8000966 test 2048 May 12 2006 BBB
root@U-TEST@AT$type ls
ls is aliased to `/bin/ls $LS_OPTIONS'
root@U-TEST@AT$type pwd
pwd is a shell builtin
root@U-TEST@AT$/bin/pwd
/you/are/here
root@U-TEST@AT$cd somewhere
root@U-TEST@AT$/bin/pwd
/you/are/here/somewhere
root@U-TEST@AT$type cd
cd is a shell builtin

Please note the Total 4 after the first ls -ali. (I don't know if it's relevant...)


Some more tests:


root@UR-TEST@AT$ls
. ..
root@U-TEST@AT$touch somewhere/testfile
root@U-TEST@AT$ls
. ..
root@U-TEST@AT$cp somewhere/testfile ./
root@U-TEST@AT$ls
. .. testfile
root@U-TEST@AT$du .
2 .
root@URBIS-TEST@AT$

And EMC is: http://www.emc.com/products/family/disk-library-family.htm , but they are only a disk provider in this case, with hard disks, formatted as ext3.


UPDATE


(Sorry, but yesterday I had to leave)


I did check echo *, and its output is: . ... Here are the LS_OPTIONS: -a -N --color=tty -T 0.


I had checked the automount thing mentioned by Gilles, but as I had changed to somewhere and issued a mount|grep somewhere there were no output.


Here is the lsattr and strace output as suggested: http://gist.github.com/566947



Answer



Zsolt, please try these three steps:


    1. cd /
    2. exec bash
    3. /usr/bin/find /you/are/here -ls

It's probably time for fsck... :-(


But before that, you could try (after backing up anything inside somedir):
cd /you/are/here && mkdir somedir.
cd /you/are/here && ln somedir newdir (as root).


Also check mount | egrep -e 'somedir|you|are|here' for any oddities.


No comments:

Post a Comment

Where does Skype save my contact&#39;s avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...