I'm running Ubuntu 14.04 32-bit and I'm trying to understand how to see files' permisions and ownership.
6 Answers
Via stat
stat file_name
or via getfacl
getfacl file_name
From man getfacl
For each file, getfacl displays the file name, owner, the group, and the Access
Control List (ACL). If a directory has a default ACL, getfacl also displays the
default ACL. Non-directories cannot have default ACLs.
From man stat
Display file or file system status.
-
2This should be the accepted answer in my opinion.
stat
does exactly what the question is asking for, other ways to see files' / directories' permissions only show those incidentally.– kosOct 15, 2015 at 17:17
A good way to do this is to do
ls -l
Additionally to see hidden files as well
ls -al
One thing that I have in my .bashrc
is
alias ll="ls -al"
To get only the desired output i.e. the permissions and ownership info of a file you can use appropriate options of stat
:
stat -c '%A %U:%G %n' file.txt
For example:
$ stat -c '%A %U:%G %n' file.txt
-rw-rw-r-- foobar:spamegg file.txt
With the -c
or --format
option of stat
:
%A
will get us the permissions%U
will get us the owner%G
will give us owner group%n
will give us the file name.
As well as those ways, in the GUI, (Nautilus, Thunar or whatever), you can change the columns setting on the 'View' menu to include the permissions, as well as many other pieces of interest.