Linux用户权限命令

91 阅读1分钟

t.zoukankan.com/nm666-p-108…

完成某些用户可操作同一文件夹下的内容

  1. 创建用户,文件夹
    [root@localhost ~]# useradd u3 [root@localhost ~]# useradd u4
    [root@localhost home]# passwd u3 更改用户 u3 的密码 。 新的 密码: 重新输入新的 密码: passwd:所有的身份验证令牌已经成功更新。
    可以查看到创建用户成功 [root@localhost ~]# cd /home/ [root@localhost home]# ls u u1 u2
    [root@localhost /]# mkdir files
  2. 创建组,将用户加到组中,用户属组是share
    [root@localhost /]# groupadd two
    [root@localhost /]# usermod -G two u4将用户加到组中usermod -G 组名 用户名
    可以查看将用户加入组成功
    [root@localhost /]# id u3 uid=1008(u3) gid=1009(u3) 组=1009(u3),1011(two)
  3. 将组织与文件夹关联 文件夹属主是share
    [root@localhost /]# ll drwxr-xr-x. 2 root root 6 11月 12 10:18 files
    第一个root代表属主(谁创建的),第二个root代表属组,要将第二个root改成two
    [root@localhost /]# chown root:two /files [root@localhost /]# ll drwxr-xr-x. 2 root two 6 11月 12 10:18 files
  4. 给文件夹的权限rws
    [root@localhost /]# chmod g+w files [root@localhost /]# chmod o-r /files [root@localhost /]# chmod o-x /files [root@localhost /]# ll drwxrwx---. 2 root two 6 11月 12 10:18 files

sudo

管理员切换用户不用输入密码,普通用户切换用户要输入密码
[root@localhost /]# su u3 [u3@localhost /]$ su u4 密码: [u4@localhost /]$

chmod