Windows与linux添加用户命令

Windows

查看当前存在用户:

net user

查看当前用户组:

net localgroup

添加用户(以添加用户test密码test1234为例):

net user test test1234 /add

添加用户到组(以添加ls用户到Administrators组为例):

net localgroup Administrators test /add

Linux

1、添加用户,首先用useradd命令添加一个普通用户,命令如下:

#useradd test//添加一个名为test的用户#passwd test//修改密码Changing password for user testNew UNIX password: //在这里输入新密码Retype new UNIX password: //再次输入新密码passwd: all authentication tokens updated successfully.

2、赋予root权限

方法一: 
修改 /etc/sudoers 文件,找到下面一行,把前面的注释(#)去掉## Allows people in group wheel to run all commands%wheel ALL=(ALL) ALL然后修改用户,使其属于root组(wheel),命令如下:#usermod -g root test修改完毕,现在可以用test帐号登录,然后用命令 su - ,即可获得root权限进行操作。 

方法二:

修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示:## Allow root to run any commands anywhereroot ALL=(ALL) ALLtest ALL=(ALL) ALL修改完毕,现在可以用test帐号登录,然后用命令 su - ,即可获得root权限进行操作。 

方法三:

修改 /etc/passwd 文件,找到如下行,把用户ID修改为 0 ,如下所示:tommy:x:500:500:test:/home/tommy:/bin/bash修改后如下tommy:x:0:500:test:/home/tommy:/bin/bash保存,用tommy账户登录后,直接获取的就是root帐号的权限。

 

相关文章