如何从命令行获取八进制文件权限?

安华

有一个chmod命令来设置文件许可权,但是我可以从命令行以八进制模式(例如755)获得文件许可权吗?

乔克迪诺

你可以试试

stat -c "%a %n" *

替换*为相关目录或您要检查的确切文件名。

stat手册页中

-c  --format=FORMAT
          use  the  specified  FORMAT instead of the default; output a newline after
          each use of FORMAT
%a     Access rights in octal
%n     File name

用法:

  • 带有文件:

    $ stat -c "%a %n" ./Documents/Udev.html 
    664 ./Documents/Udev.html
    
  • 带文件夹:

    $ stat -c "%a %n" ./Documents/
    755 ./Documents/
    

(参考)

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章