前提:
需要为管理员权限
linux环境
1、创建普通用户
useradd test #创建test用户
passwd test #给test用户设置密码
2、提权
方法一:
a、修改/etc/sudoers文件,将#去掉
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
b、然后修改用户,使其属于root组
usermod -g root test
c、使用test账号登录,su -切回root,再切回test即为root权限
方法二:
a、修改/etc/sudoers文件,找到root并添加
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
test ALL=(ALL) ALL
b、使用test账号登录,即可使用sudo权限操作
如:sudo ls
方法三:
a、修改/etc/passwd文件,找到添加用户,并修改用户ID为0
test:x:0:1000::/home/test:/bin/sh
b、切换至test用户,输入test密码即可登陆至root账户
3、删除用户
userdel -r test #删除用户及其主目录
注!非交互式shell修改密码
echo "test:123" | chpasswd
echo "123" | passwd --stdin "test"
Windows环境
1、创建普通用户
net user test 123456 /add #添加test用户,密码为12356
net user test$ 123456 /add #添加隐藏test用户,密码为12356
2、添加用户至管理员组
net localgroup administrators test /add #添加test用户至管理员组
查看管理员组成员
net localgroup administrators #查看管理员组成员
删除用户
net localgroup administrators test /del #删除用户
禁用用户/启用用户
net user test /active:no #禁用test用户
net user test /active:yes #启用test用户