linux之用户和权限管理

用户
    1.新建用户
    adduser     用户名
    $ adduser user1
    2.新建组
    addgroup  组名  创建组
        $ addgroup team
    3.修改用户信息
    usermod     [opitons]    
    修改用户信息
        $ usermod --gid 1008  user1
        将用户user1切换到组id为1008组
    4.删除组
    groupdel     删除组
        -r   删除所有文件夹
        $ groupdel user1
    5.用户信息
        用户身份信息: $ id
        用户账户信息:$ cd /etc/passwd
        用户组信息: $ cd /etc/group  
    6.启动文件
        /etc/profile              应用于所有用户的全局配置脚本
        ~/.bash_profile            用户私人的启动文件。可以用来扩展或重写全局配置脚本中的设置
        ~/.bash_login             如果文件~/.bash_profile没有找到,bash会尝试读取这个
        ~/.profile                 如果~/.bash_profile或文件~/.bash_login都没找到会试图读取这个文件
        /etc/.bash.bashrc         应用于所有用户的全局配置文件
        ~/.bashrc                 用户私有的启动文件.可以用来扩展或重写全局配置脚本中的设置    
    激活配置文件的修改
        $ source .bashrc        
权限管理
    用户角色
        user      拥有者  u
        group   同组人  g
        other    其他人  0
    文件权限

        read   读   r
        wirte   写  w
        execute 执行  x
        1)chmod g+w  index.html
        为index.html 添加同组人写权限
        2)chomd 766  index.html
            user  7  rwx
            group 6  rw-
            other 6  rw-

          ---    000    0
          --x   001    1
          -w-   010    2
          -wx    011       3
          r--   100    4
          r-x   101    5
          rw-   110    6
          rwx   111    7
    
    更改用户所有者和用户组
        chown
        $ sudo chown :music /user/local/share/Music
        给/user/share/Music 赋予music组

猜你喜欢

转载自blog.csdn.net/qq_37674616/article/details/81979664