zoukankan      html  css  js  c++  java
  • Linux ->> Chmod命令改变文件/文件夹属性

    简介

    chmod命令用于改变linux系统文件或目录的访问权限,控制用户/用户组对文件或目录的访问权限。

    用法:

    两种用法:1)用字母r(读)、w(写)、x(执行)表示权限类型;2)用数字表示,4代表读,2表示写,1代表执行。

    文件/文件夹的权限属性的面相的用户群体分owner(所有者)、owner group(所有者所在用户组的成员)、others(其他用户)。所以chmod 760 test_foler/等于chmod u=rwx,g=rw test_foler/。

    除了显示赋安全权限外,还可以添加删减权限。比如chmod a-x test_foler的意思是把文件夹三种安全实体的执行权限移除。 a=all,也就是全部的意思;u=user,也就是owner;g=group,owner所在用户组的意思;o就是others啦。

    jerry@ubuntu:/tmp$ chmod a-x test_foler/
    jerry@ubuntu:/tmp$ ll
    total 48
    drwxrwxrwt 10 root  root  4096 Dec 13 00:37 ./
    drwxr-xr-x 23 root  root  4096 Dec  5 07:40 ../
    -rw-------  1 jerry jerry    0 Dec  8 05:07 config-err-QQX6ND
    drwxr-xr-x  2 jerry jerry 4096 Dec  8 08:50 hsperfdata_jerry/
    drwxrwxrwt  2 root  root  4096 Dec  8 05:07 .ICE-unix/
    drwxrwxr-x  3 jerry jerry 4096 Dec  8 09:17 jdk/
    drw-rw-rw-  2 jerry jerry 4096 Dec 13 00:32 test_foler/
    -rw-rw-r--  1 jerry jerry    0 Dec  8 05:07 unity_support_test.0
    -rw-r--r--  1 root  root  1839 Dec  8 05:07 vgauthsvclog.txt.0
    drwxrwxrwt  2 root  root  4096 Dec  8 05:07 VMwareDnD/
    drwx------  2 jerry jerry 4096 Dec  8 05:07 vmware-jerry/
    drwx------  2 root  root  4096 Dec  8 05:07 vmware-root/
    -r--r--r--  1 root  root    11 Dec  8 05:07 .X0-lock
    drwxrwxrwt  2 root  root  4096 Dec  8 05:07 .X11-unix/
    jerry@ubuntu:/tmp$ 

    用chmod a+x test_foler/又加回去了

    参数R应用到子文件和文件夹上,比如chmod -R a+x test_foler/

    jerry@ubuntu:/tmp/test_foler$ mkdir 666 sub_folder
    jerry@ubuntu:/tmp/test_foler$ ll
    total 16
    drwxrwxrwx  4 jerry jerry 4096 Dec 13 00:43 ./
    drwxrwxrwt 10 root  root  4096 Dec 13 00:42 ../
    drwxrwxr-x  2 jerry jerry 4096 Dec 13 00:43 666/
    drwxrwxr-x  2 jerry jerry 4096 Dec 13 00:43 sub_folder/
    jerry@ubuntu:/tmp/test_foler$ chmod -R a+x /tmp/test_foler/
    jerry@ubuntu:/tmp/test_foler$ ll
    total 16
    drwxrwxrwx  4 jerry jerry 4096 Dec 13 00:43 ./
    drwxrwxrwt 10 root  root  4096 Dec 13 00:43 ../
    drwxrwxr-x  2 jerry jerry 4096 Dec 13 00:43 666/
    drwxrwxr-x  2 jerry jerry 4096 Dec 13 00:43 sub_folder/
    jerry@ubuntu:/tmp/test_foler$ cd sub_folder/
    jerry@ubuntu:/tmp/test_foler/sub_folder$ touch a
    jerry@ubuntu:/tmp/test_foler/sub_folder$ ll
    total 8
    drwxrwxr-x 2 jerry jerry 4096 Dec 13 00:44 ./
    drwxrwxrwx 4 jerry jerry 4096 Dec 13 00:43 ../
    -rw-rw-r-- 1 jerry jerry    0 Dec 13 00:44 a
    jerry@ubuntu:/tmp/test_foler/sub_folder$ chmod -R a+x /tmp/test_foler/
    jerry@ubuntu:/tmp/test_foler/sub_folder$ ll
    total 8
    drwxrwxr-x 2 jerry jerry 4096 Dec 13 00:44 ./
    drwxrwxrwx 4 jerry jerry 4096 Dec 13 00:43 ../
    -rwxrwxr-x 1 jerry jerry    0 Dec 13 00:44 a*
    jerry@ubuntu:/tmp/test_foler/sub_folder$ 
  • 相关阅读:
    PS常用美化处理方法大全
    FastReport.Net使用:[32]对话框使用2
    FastReport.Net使用:[31]使用带参查询及存储
    FastReport.Net使用:[30]对话框使用
    FastReport.Net使用:[29]调用存储过程1
    FastReport.Net使用:[28]数据合并
    FastReport.Net使用:[27]样式使用
    FastReport.Net使用:[26]数字格式
    FastReport.Net使用:[25]除数0处理方法
    FastReport.Net使用:[24]其他控件(邮政编码(Zip Code),网格文本(Cellular Text)以及线性刻度尺(Linear Gauge))
  • 原文地址:https://www.cnblogs.com/jenrrychen/p/5043051.html
Copyright © 2011-2022 走看看