linux使用者賦予root許可權

2021-08-14 04:47:46 字數 1096 閱讀 1354

1、新增使用者,首先用adduser命令新增乙個普通使用者,命令如下:

#adduser tommy 

//新增乙個名為tommy的使用者

#passwd tommy //修改密碼

changing password for user tommy. 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 tommy

修改完畢,現在可以用tommy帳號登入,然後用命令 su - ,即可獲得root許可權進行操作。

方法二: 修改 /etc/sudoers 檔案,找到下面一行,在root下面新增一行,如下所示:

## allow root to run any commands anywhere

root all=(all) all tommy all=(all) all

修改完畢,現在可以用tommy帳號登入,然後用命令 su - ,即可獲得root許可權進行操作。

方法三: 修改 /etc/passwd 檔案,找到如下行,把使用者id修改為 0 ,如下所示:

tommy:x:500:500:tommy:/home/tommy:/bin/bash 

修改後如下

tommy:x:0:500:tommy:/home/tommy:/bin/bash 

儲存,用tommy賬戶登入後,直接獲取的就是root帳號的許可權。

linux賦予使用者root許可權

linux裡面管理員 sudo 和root許可權還是不一樣的,root是最高許可權了。賦予root許可權 方法一 修改 etc sudoers 檔案,找到下面一行,把前面的注釋 去掉 allows people in group wheel to run all commands wheel all...

Linux建立使用者並賦予Root許可權

新增普通使用者 root server useradd test 新增乙個名為test的使用者 root server passwd test 修改密碼 changing password for user test.new unix password 在這裡輸入新密碼 retype new uni...

Linux新增使用者並賦予root許可權

建立乙個名為qiang,其家目錄位於 usr qiang的使用者 adduser d usr qiang m qiang或直接這樣,則使用者的家目錄會預設為 home 目錄 adduser qiangpasswd qiang修改檔案 etc passwd,將使用者名為qiang的使用者id修改為0即...