5

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?

3
  • 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". Sep 20, 2012 at 22:06
  • Changed to Linux. Thanks for pointing this out. Sep 20, 2012 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, 2012 at 22:21

2 Answers 2

7

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.

1
  • 1
    @allquixotic (and others) From the OP's response this was not a duplicate of the previous question!
    – StarNamer
    Sep 21, 2012 at 0:46
2

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.

7
  • Sorry, I had a typo in the above question. I meant that 'svr' is not shown under root. Sep 20, 2012 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). Sep 20, 2012 at 22:13
  • # shell. What's the difference between # and $ shell as root? Sep 20, 2012 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. Sep 20, 2012 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. Sep 20, 2012 at 22:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .