Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 16 down vote accepted

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
share|improve this answer

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.