How to get the numeric form of a directory or file's permissions via stat

man stat for help.

-c --format=FORMAT use the specified FORMAT instead of the default; output a new line after each use of FORMAT

Common parameters are as follows:

% a Access rights in octal hexadecimal display access rights, 0644

%A Access rights in human readable form output in human readable form, drwxrwxr-t

%F File type type of file

%g Group ID of owner The gid number of the group to which the owner belongs

%G Group name of owner The name of the group to which the owner belongs

%h Number of hard links

linux-zpycfm: ~ # stat / var / run / libalarm
  File: ‘/var/run/libalarm’
  Size: 80              Blocks: 0          IO Block: 4096   directory
Device: 12h/18d Inode: 159827066   Links: 2
Access: (1775/drwxrwxr-t)  Uid: (    0/    root)   Gid: ( 1001/uvpalarm)
Access: 2018-05-03 18:09:31.883333421 +0800
Modify: 2018-05-03 17:57:24.997312107 +0800
Change: 2018-05-03 17:57:24.997312107 +0800
linux-zpycfm: ~ # stat -c% a / var / run / libalarm /
 1775 
linux -zpycfm: ~ # stat -c% A / var / run / libalarm / 
drwxrwxr -t

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325612427&siteId=291194637