Linuxの管理権限とファイル/ディレクトリの所有権詳細

まず、ファイルのアクセス権と所有権の概要

1.アクセス

  • 読むrは:あなたがリストファイル、ディレクトリの内容を表示することができます。

  • 書き込みW:新しいディレクトリ、移動、削除ファイルやサブディレクトリを許可する、あなたはファイルの内容を変更することができます。

  • 実行可能ファイルのx:プログラムを実行することができ、変更ディレクトリ

図2に示すように、所有権(所有権)

  • 所有者:ファイルやディレクトリのアカウントを所有しているユーザー。

  • グループは、次のとおりです。アカウントファイルやディレクトリを所有するグループ。

3、ビューファイルのアクセス権と所有権

Linuxの管理権限と簡潔に、ファイル/ディレクトリの所有権

4、設定されたファイルのパーミッションにはchmod

次のように基本的な構文のchmodコマンドは次のとおりです。
Linuxの管理権限と簡潔に、ファイル/ディレクトリの所有権

アプリケーション例:

[root@01 ~]# touch 1.txt     <!--创建1.txt文件-->
[root@centos01 ~]# ll 
总用量 8
-rw-r--r--  1 root root    0 1月  11 22:27 1.txt
-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg
[root@centos01 ~]# chmod u+x ./1.txt  <!--属主用户添加执行权限-->
[root@centos01 ~]# ll
总用量 8
-rwxr--r--  1 root root    0 1月  11 22:27 1.txt
-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg
[root@centos01 ~]# chmod u-x,g+x,o+w 1.txt   
<!--属主用户取消执行权限,组添加执行权限,其他用户添加写入权限-->
[root@centos01 ~]# ll
总用量 8
-rw-r-xrw-  1 root root    0 1月  11 22:27 1.txt
-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg
[root@centos01 ~]# chmod 755 1.txt  <!--添加755权限(rwxr-xr-x)-->
[root@centos01 ~]# ll
总用量 8
-rwxr-xr-x  1 root root    0 1月  17 02:36 1.txt
-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

5、設定ファイルの所有権をchown

次のように基本的な構文のchownコマンドは次のとおりです。
Linuxの管理権限と簡潔に、ファイル/ディレクトリの所有権

アプリケーション例:

[root@centos01 ~]# chown bob 1.txt  <!--1.txt设置属主-->
[root@centos01 ~]# ll
总用量 8
-rwxr-xr-x  1 bob  root    0 1月  17 02:36 1.txt
-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg
[root@centos01 ~]# chown :benet 1.txt  <!--1.txt设置属组-->
[root@centos01 ~]# ll
总用量 8
-rwxr-xr-x  1 bob  benet    0 1月  17 02:36 1.txt
-rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg
[root@centos01 ~]# chown bob:benet 1.txt  <!--1.txt设置属主和属组-->
[root@centos01 ~]# ll
总用量 8
-rwxr-xr-x  1 bob  benet    0 1月  17 02:36 1.txt
-rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg
<!---->

第二に、ディレクトリのアクセス権と所有権

1.アクセス

Linuxの管理権限と簡潔に、ファイル/ディレクトリの所有権

図2に示すように、所有権(所有権)

  • 所有者:アカウントのディレクトリを所有するユーザー。

  • グループは、次のとおりです。アカウントのディレクトリを所有するグループ。

3、セットディレクトリのパーミッションにはchmod

次のようにディレクトリのパーミッション基本的な書式を設定するのchmodコマンドは次のとおりです。
Linuxの管理権限と簡潔に、ファイル/ディレクトリの所有権

アプリケーション例:

[root@centos01 ~]# chmod -R 755 benet/   
          <!--循环设置benet目录下的文件或者目录权限为755-->
[root@centos01 ~]# ll
总用量 8
-rw-r-xrw-  1 root root    0 1月  11 22:27 1.txt
-rw-------. 1 root root 1572 10月 23 22:37 anaconda-ks.cfg
drwxr-xr-x  3 root root   18 1月  11 22:39 benet
-rw-r--r--. 1 root root 1603 10月 23 23:36 initial-setup-ks.cfg

4、chownコマンドを設定ホームディレクトリ

次のように基本的なフォーマットのホームディレクトリを設定するには、chownコマンドは次のようになります。
Linuxの管理権限と簡潔に、ファイル/ディレクトリの所有権

アプリケーション例:

[root@centos01 ~]# chown -R bob:benet benet/   
   <!--循环设置benet目录中所属用户为bob,所属组为benet-->
[root@centos01 ~]# ll
总用量 8
-rw-r-xrw-  1 root root     0 1月  11 22:27 1.txt
-rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg
drwxr-xr-x  3 bob  benet   18 1月  11 22:39 benet
-rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg

第三に、許可マスクのumask

1、umask的作用

ファイルやディレクトリのパーミッションのumask許可の新しい制御権限は、新しいファイルやディレクトリその既定のアクセス許可を削除します。

2、umask値を設定します

umask 022

3、umaskを見ます

umask

4.アプリケーション例:

[root@centos01 ~]# umask  <!--查看umask-->
0022
[root@centos01 ~]# umask 000  <!--设置umask为000-->
[root@centos01 ~]# umask   <!--验证是否设置成功-->
0000
[root@centos01 ~]# touch 2.txt   <!--创建新文件-->
[root@centos01 ~]# ll
总用量 8
-rwxr-xr-x  1 bob  benet    0 1月  17 03:48 1.txt
-rw-rw-rw-  1 root root     0 1月  17 03:48 2.txt    <!--查看权限-->
-rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg
[root@centos01 ~]# umask 022       <!--设置umask为022-->
[root@centos01 ~]# umask           <!--查看umask-->
0022
[root@centos01 ~]# touch 3.txt        <!--再次创建新文件-->
[root@centos01 ~]# ll
总用量 8
-rwxr-xr-x  1 bob  benet    0 1月  17 03:48 1.txt
-rw-rw-rw-  1 root root     0 1月  17 03:48 2.txt
-rw-r--r--  1 root root     0 1月  17 03:49 3.txt <!--查看权限,明显不一样-->
-rw-------. 1 root root  1572 10月 23 22:37 anaconda-ks.cfg
-rw-r--r--. 1 root root  1603 10月 23 23:36 initial-setup-ks.cfg

おすすめ

転載: www.linuxidc.com/Linux/2020-01/162121.htm