how to list current path mode?
Solution 1:
To see the permissions of the current directory, whatever it is, use:
ls -lid .
How it works:
-l
asksls
for a long directory listing.-i
asksls
for inode information (optional).-d
tellsls
to report on the directory itself, not what is in it..
refers, as is conventional for Unix, to the current directory.
Because POSIX ls
supports the -l
, -i
, and -d
options, this method is portable.
Solution 2:
Don't use ls
at all. It is generally a bad idea to try and parse ls
output and there are other tools that are specifically designed for the job. In this case, you can use stat
:
$ stat -c '%G %U %y' .
terdon terdon 2015-03-03 19:37:48.007033824 +0200
Explanation
-c --format=FORMAT
use the specified FORMAT instead of the default; output a new‐
line after each use of FORMAT
%G group name of owner
%U user name of owner
%y time of last modification, human-readable
So, the command above will print the user (%U
), group (%G
) and modification time (%y
) of .
, the current directory. It can also print other pieces of information, pretty much anything you will ever need. See man stat
for more.