18

Is there a way to check the permissions of the root folder, /? I mean the folder's permissions, not its content's (/var, /usr, etc.) permissions? Running ls /.. shows the content's permissions.

trysis
  • 333
  • Have you tried the -l option:
     `ls -l /`
    
    – slackmart Mar 25 '14 at 00:59
  • 2
    Yes, it shows the contents; I wanted the contents of the outer folder, which doesn't technically exist. The question is already answered anyway. – trysis Mar 25 '14 at 01:22
  • Can you please edit your title to not include the text "/root", because web searched for "/root " come here and that doesn't make any sense. Perhaps you could just say (/), and then lower down in the text clarify that you are not referring to /root. Thanks – Elliptical view Oct 19 '16 at 21:02
  • If I did that, people would come here looking for /root folder permissions, which also does not make sense. I'll be damned if I do, damned if I don't. – trysis Oct 19 '16 at 22:20
  • -1 Because you have not yet changed the title to simply /, I came here looking for permission of /root (because that's how google works.) – Elliptical view Mar 24 '18 at 01:06

3 Answers3

63

You can also use the -d switch of ls:

$ ls -ld /
drwxr-xr-x 28 root root 126976 Mar 20 17:11 /

From man ls:

   -l     use a long listing format
   -d, --directory
          list  directory entries instead of contents, and do not derefer‐
          ence symbolic links
terdon
  • 242,166
24

stat -c "%a %n" /

It will give you the permissions.

Ramesh
  • 39,297
16

Use the -a switch of ls to include hidden files as well as . and .. in the listing and the -l switch for a "long" listing (which includes the permissions, among other information):

ls -la /

The line with a single . in the last column will contain information about the listed directory itself, i.e. /:

drwxr-xr-x 26 root root 4096 Mar 10 15:57 .

However if you only need information about / itself, terdon's answer (using the -d switch) will probably be handier.

n.st
  • 8,128
  • 1
    @trysis I routinely use ls -blah. It has everything you could possibly want to know about a file or directory. – n.st Mar 25 '14 at 01:06
  • Yeah, I've switched to -A because . and .. are there anyway, but if I had stayed with -a I wouldn't have needed to ask this question. – trysis Mar 25 '14 at 01:08
  • 2
    This is not really a very good solution, it will list all files under / when all the OP wanted was / itself. See stat or ls -ld in the answers below. – terdon Mar 25 '14 at 02:08
  • @terdon I wanted to stick with ls as the OP seemed familiar with it. You are definitely right about -d though; I didn't know about that one (and didn't notice it in the manpage either). – n.st Mar 25 '14 at 03:13
  • 1
    @trysis You might want to accept terdon's answer instead since it's closer to what you originally wanted to achieve. – n.st Mar 25 '14 at 03:14
  • 1
    Fair enough, the comment was not so much directed at you as to future users who might see this as the accepted answer and assume it is the Best Way® to do it. – terdon Mar 25 '14 at 03:15
  • 2
    . is not necessarily first. The list is sorted lexically. There are several characters that sort before . in many locales. – Stéphane Chazelas Mar 25 '14 at 12:12
  • 1
    @StephaneChazelas I have yet to encounter that problem, but you could use -U (unsorted) to have . and .. as the first entries. – n.st Mar 25 '14 at 12:31
  • 1
    There's no reason for . or .. to come first with -U (and in my test, they don't: ls -a gives %test% . .. foo and ls -Ua gives %test% . foo ..) – Stéphane Chazelas Mar 25 '14 at 12:35
  • @StephaneChazelas You're right, that was nonsense. – n.st Mar 25 '14 at 13:14