11

What is the command with which you can directly view the permission bits of a directory?

1 Answer 1

22

There's a couple ways. stat is used to show information about files and directories, so it's probably the best way. It takes a format parameter to control what it outputs; %a will show the octal values for the permissions, while %A will show the human-readable form:

$ stat -c %a /
755
$ stat -c %A /
drwxr-xr-x
$ stat -c %a /tmp
1777
$ stat -c %A /tmp
drwxrwxrwt

Another (probably more common) way is to use ls. -l will make it use the long listing format (whose first entry is the human-readable form of the permissions), and -d will make it show the entry for the specified directory instead of its contents:

$ ls -ld /
drwxr-xr-x 22 root root 4.0K Apr 28 20:32 /
$ ls -ld /tmp
drwxrwxrwt 7 root root 12K Sep 25 22:31 /tmp

You must log in to answer this question.

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