• 编辑passwd文件
    sudo vim /etc/passwd
  • 找到你想提权的用户(比如test),将用户名后面的数字改成0
    test:x:1000:1000::/home/test
  • 修改权限
    test:x:0:0::/home/test
    也可以改得和root一样 只要第一个不b变
  • 重启电脑,登录test账户。reboot

设置后 可能无法登陆ssh 需要设置

  • vi /etc/ssh/sshd_config
    找到 并编辑为
    # Authentication:
    LoginGraceTime 120
    #PermitRootLogin without-password
    PermitRootLogin yes
    StrictModes yes
    保存后重启服务
    /etc/init.d/ssh restart 
    或者
    service ssh restart