码迷,mamicode.com
首页 > 其他好文 > 详细

34.权限管理命令

时间:2019-02-23 20:37:37      阅读:229      评论:0      收藏:0      [点我收藏+]

标签:--   https   进制   file   基础   shadow   extra   tps   term   

权限管理命令:
chmod命令:
三类用户:
u:属主
g:属组
o:其他
a:所有


    1. 赋权、授权表示法*

                                  u、g、o、a分别代表:属主、属组、其他人、所有人
      
                                +:在原来权限的基础上增加权限
      
               -:在原来权限的基础上去除权限
      
                                   =:直接定义权限
      
                                   r、w、x:读、写、执行
      
                          实例:
      
                          [root@itxuezhe tmp]# ll fstab 
                          -rw-r--r--. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod g=rw fstab 
      
                          [root@itxuezhe tmp]# ll fstab 
                          -rw-rw-r--. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod ug=r fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          -r--r--r--. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod u=rwx,g=rw,o= fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          -rwxrw----. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod u=rwx,g=rw,o= fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          -rwxrw----. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod u-x fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          -rw-rw----. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod o+r fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          -rw-rw-r--. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod ug+x fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          -rwxrwxr--. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod g-wx fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          -rwxr--r--. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# ll fstab 
                          -rw-r--r--. 1 root root 541 2月  23 19:00 fstab
                          [root@itxuezhe tmp]# chmod -r fstab 
                      [root@itxuezhe tmp]# ll fstab
                          --w-------. 1 root root 541 2月  23 19:00 fstab
      
                          [root@itxuezhe tmp]# chmod u+x,g+w fstab 
                          [root@itxuezhe tmp]# ll fstab 
                          --wx-w----. 1 root root 541 2月  23 19:00 fstab

2.八进制表示法:

技术图片

    实例:

                    [root@itxuezhe tmp]# chmod 666 fstab 
                    [root@itxuezhe tmp]# ll fstab 
                    -rw-rw-rw-. 1 root root 541 2月  23 19:00 fstab

                [root@itxuezhe tmp]# chmod 644 fstab 
                [root@itxuezhe tmp]# ll fstab 
                -rw-r--r--. 1 root root 541 2月  23 19:00 fstab

  1. chmod –reperence=文件1 文件2 // 以文件1的权限为标准修改文件2的权限

        实例:
    
        [root@itxuezhe tmp]# ls -l /var/log/messages 
        -rw-------. 1 root root 1116015 2月  23 19:20 /var/log/messages
    
        [root@itxuezhe tmp]# ll fstab 
        -rwxrw-rw-. 1 root root 541 2月  23 19:00 fstab
    
        **参考/var/log/messages 的权限去修改/tmp/fstab**    
    
      [root@itxuezhe tmp]# ll fstab 
        -rwxrw-rw-. 1 root root 541 2月  23 19:00 fstab
    
        [root@itxuezhe tmp]# chmod --reference=/var/log/messages fstab 
        [root@itxuezhe tmp]# ll fstab 
        -rw-------. 1 root root 541 2月  23 19:00 fstab

                选项:
                    -R:递归修改;

                    [root@itxuezhe tmp]# chmod 700 skel/ -R
                    [root@itxuezhe tmp]# ll skel/ -a 
                    总用量 16
                    drwx------.  3 root root   78 2月  23 19:57 .
                    drwxrwxrwt. 21 root root 4096 2月  23 19:59 ..
                    -rwx------.  1 root root   18 2月  23 19:57 .bash_logout
                    -rwx------.  1 root root  193 2月  23 19:57 .bash_profile
                    -rwx------.  1 root root  231 2月  23 19:57 .bashrc
                    drwx------.  4 root root   39 2月  23 19:57 .mozilla

    从属关系管理命令:chown, chgrp

                chown命令:

                            选项:
                                -R:     

                实例:

                                [root@itxuezhe tmp]# ll fstab 
                                -rw-------. 1 itxuezhe itxuezhe 541 2月  23 19:00 fstab

                                [root@itxuezhe tmp]# chown -R root:root fstab 
                                [root@itxuezhe tmp]# ll fstab 
                                -rw-------. 1 root root 541 2月  23 19:00 fstab

                                [root@itxuezhe tmp]# chown -R itxuezhe.itxuezhe fstab 
                                [root@itxuezhe tmp]# ll fstab 
                                -rw-------. 1 itxuezhe itxuezhe 541 2月  23 19:00 fstab

        **  参考/tmp/tracker-extract-files.1000的属主和属组权限修改/tmp/skel/目录下的文件文件**

        [root@itxuezhe tmp]# ll -d tracker-extract-files.1000/
        drwx------. 2 itxuezhe itxuezhe 6 2月  19 19:01 tracker-extract-files.1000/

        [root@itxuezhe tmp]# chown -R --reference=/tmp/tracker-extract-files.1000/ /tmp/skel/

        [root@itxuezhe tmp]# ll -a skel/
        总用量 16
        drwx------.  3 itxuezhe itxuezhe   78 2月  23 19:57 .
        drwxrwxrwt. 21 root     root     4096 2月  23 20:13 ..
        -rwx------.  1 itxuezhe itxuezhe   18 2月  23 19:57 .bash_logout
        -rwx------.  1 itxuezhe itxuezhe  193 2月  23 19:57 .bash_profile
        -rwx------.  1 itxuezhe itxuezhe  231 2月  23 19:57 .bashrc
        drwx------.  4 itxuezhe itxuezhe   39 2月  23 19:57 .mozilla

34.权限管理命令

标签:--   https   进制   file   基础   shadow   extra   tps   term   

原文地址:https://blog.51cto.com/itxuezhe/2353961

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!