• 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 test
    New 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 anywhere
    root ALL=(ALL) ALL
    test 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帐号的权限。
    
  • 相关阅读:
    ubuntu网速慢解决方法
    SQL优化指南
    Java 并发:volatile 关键字解析
    java集成WebSocket向所有用户发送消息
    java集成WebSocket向指定用户发送消息
    windows下使用批处理脚本实现多个版本的JDK切换
    String.format()格式化日期(2)
    String.format(2)
    String.format()用法
    获得这两个时间的所有天数及其周几
  • 原文地址:https://www.cnblogs.com/someone9/p/10554906.html
Copyright © 2020-2023  润新知