CentOS6创建用户并授权--桌面版

1.登录root用户

右键打开终端:
CentOS6创建用户并授权--桌面版

2.创建新用户

[[email protected] Desktop]# adduser Linging

并设置密码:

[[email protected] Desktop]# passwd Linging
Changing password for user Linging.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.

提示密码太简单,不管它,继续输入(密码是不可见的,直接输入)。

3.授权

个人用户的权限只可以在本home下有完整权限,其他目录需要授权。
而经常需要root用户的权限,这时候sudo可以化身为root来操作。
sudo命令的授权管理是在sudoers文件里的。

可以看看sudoers在什么位置:

[[email protected] Desktop]# whereis sudoers
sudoers: /etc/sudoers.d /etc/sudoers /usr/libexec/sudoers.so /usr/share /man /man5/sudoers.5.gz

然后再查看这个文件的操作权限:

[[email protected] Desktop]# ls -l /etc/sudoers
-r–r-----. 1 root root 3729 Dec 8 2015 /etc/sudoers

可以看到只有读权限,下面就添加写权限:

[[email protected] Desktop]# chmod -v u+w /etc/sudoers
mode of `/etc/sudoers’ changed to 0640 (rw-r-----)

接下来添加内容:

[[email protected] Desktop]# vim /etc/sudoers

回车,并找到如下的位置,并添加:
CentOS6创建用户并授权--桌面版
然后按Esc键,输入 :wq,保存并退出。

最后把写权限收回:

[[email protected] Desktop]# chmod -v u-w /etc/sudoers
mode of `/etc/sudoers’ changed to 0440 (r–r-----)

最后我们可以查看用户:
CentOS6创建用户并授权--桌面版
CentOS6创建用户并授权--桌面版