1.查看用户用户组信息,(id -un是获得当前登陆的用户名称)
[root@adx /home/wm/diad]# id -un
root
[root@adx /home/wm/diad]# id wm
uid=512(wm) gid=512(wm) groups=512(wm)
You have new mail in /var/spool/mail/root
[root@adx /home/wm/diad]# groups wm
wm : wm
[root@adx /home/wm/diad]# cat /etc/group | grep "^wm"
wm:x:512:www
2.su和su-区别
su不更改环境变量,只获取root权限。
su - 更改环境变量,切换到root并获取root环境变量和执行权限。
3.useradd使用遇到的问题解决
[root@adx /home/wm/miad]# useradd -m wn
bash: useradd: command not found
[root@adx /home/wm/miad]# adduser wn
bash: adduser: command not found
[root@adx /home/wm/miad]# su -
[root@adx ~]# useradd -m wn
[root@adx ~]# passwd wn
passwd: symbol lookup error: /usr/local/lib/libgobject-2.0.so.0: undefined symbol: g_regex_unref
[root@adx ~]# echo 'wn:123456' | chpasswd
You have new mail in /var/spool/mail/root
[root@adx ~]# echo "123456" | passwd --stdin wm
5.删除用户
[root@adx ~]# userdel -r wm
6.添加sudo权限
有时候,linux下面运行sudo命令,会提示类似: xxxis not in the sudoers file. This incident will be reported. 这里,xxx是用户名称,然后导致无法执行sudo命令,这时候,如下解决:
[wm@adx ~]$ su -
Password:
[root@adx ~]# chmod u+w /etc/sudoers //添加文件的写权限
[root@adx ~]# vim /etc/sudoers
进入编辑模式,查找/root,找到这一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),然后保存退出。
76 root ALL=(ALL) ALL
77 wm ALL=(ALL) ALL
撤销文件的写权限
[root@adx ~]# chmod u-w /etc/sudoers