Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

If I log in and then head to my superuser root via:

sudo su -

I'm now in the root directory. I can display a list of files and directories via ls. However quite a few directories don't seem to be there. For example, I can:

cd /svr/www

and end up in the directory www. The svr directory is not shown when I type the ls command from root, nor does it appear to be under any of the directories that are shown.

What am I missing?

share|improve this question
    
What specific flavor of "Unix" is this? Is this the real System V from the 1970s, or are you using some derivative like, oh I don't know, Linux or BSD? Please call it by what it really is and not some generalized term like "Unix". –  allquixotic Sep 20 '12 at 22:06
    
Changed to Linux. Thanks for pointing this out. –  UnixNewbie2012 Sep 20 '12 at 22:09
    
After you sudo su - do you cd to any other directory or is the first command you are typing ls ? –  Lipongo Sep 20 '12 at 22:21

2 Answers 2

After the command sudo su - I think you will find you are in root's home directory /root not in the root directory /. Hence ls will not show /srv. I suggest you use pwd to check which folder you are in.

share|improve this answer
    
Ah ha! That's exactly it. Thank you. –  UnixNewbie2012 Sep 20 '12 at 23:33
1  
@allquixotic (and others) From the OP's response this was not a duplicate of the previous question! –  StarNamer Sep 21 '12 at 0:46

If you are in the / directory and type ls, you will not see "recursive" subdirectories. You will only see directories that are direct children of the current directory. So in order to see /srv/www you would have to first cd /srv and then ls.

There's a such thing as recursive ls; however, if you need the full paths, find is a better alternative.

See this StackOverflow question which has treated the subject matter of recursive file/directory listing already.

share|improve this answer
    
Sorry, I had a typo in the above question. I meant that 'svr' is not shown under root. –  UnixNewbie2012 Sep 20 '12 at 22:10
    
Are you not seeing it from the # (root) shell, or from the $ shell? Permissions could be set such that only the root user can see the directory... for example, chmod o-x / could do this (if / is not executable). –  allquixotic Sep 20 '12 at 22:13
    
# shell. What's the difference between # and $ shell as root? –  UnixNewbie2012 Sep 20 '12 at 22:15
    
# is the root shell. If you are "logged in" as root, your shell will be #. If you are logged in as a regular user, your shell will be $. Root shouldn't suffer from any discretionary access control permission limitations whatsoever, which means that chmod and chown and similar permissions on directories/files should be ignored, and should not be a cause of seeing behavior like this. –  allquixotic Sep 20 '12 at 22:16
    
One additional thing you can try is ls -la -- the additional command line options will show e.g. hidden files as well... although normally the only hidden files are those that begin with a dot . character; those are always hidden from the regular ls command. –  allquixotic Sep 20 '12 at 22:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.