CentOS賦予乙個普通使用者root許可權

2021-09-30 11:27:02 字數 1287 閱讀 9450

linux的普通使用者在安裝一些東西或者執行一些命令的時候,終端會提示許可權不夠。那麼怎麼才能給使用者賦予root許可權呢?當然,就算賦予了root許可權,也和root使用者還是有區別的,因為只能執行root規定好的一些操作命令。

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 檔案,找到%wheel一行,把前面的注釋(#)去掉

## allows people

ingroup wheel to run all commands

%wheel all=(all) all

然後修改使用者,使其屬於root組(wheel),命令如下:

#usermod -g root tommy

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

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

## allow root to run any commands anywhere

root all=(all) all

tommy all=(all) all

修改完畢,現在可以用tommy帳號登入,然後用命令 sudo 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帳號的許可權。

建議使用方法二,不要輕易使用方法三。

CentOS賦予乙個普通使用者root許可權

linux的普通使用者在安裝一些東西或者執行一些命令的時候,終端會提示許可權不夠。那麼怎麼才能給使用者賦予root許可權呢?當然,就算賦予了root許可權,也和root使用者還是有區別的,因為只能執行root規定好的一些操作命令。1 新增使用者,首先用adduser命令新增乙個普通使用者,命令如下 ...

CentOS賦予乙個普通使用者root許可權

linux的普通使用者在安裝一些東西或者執行一些命令的時候,終端會提示許可權不夠。那麼怎麼才能給使用者賦予root許可權呢?當然,就算賦予了root許可權,也和root使用者還是有區別的,因為只能執行root規定好的一些操作命令。1 新增使用者,首先用adduser命令新增乙個普通使用者,命令如下 ...

賦予普通使用者root許可權

1 新增使用者,首先用adduser命令新增乙個普通使用者,命令如下 adduser tom 新增乙個名為tom的使用者 passwd tom 修改密碼 changing password for user tom.new unix password 在這裡輸入新密碼 retype new unix...