linux給用戶添加root權(quán)限方法總結(jié)
1、添加用戶,首先用adduser命令添加一個(gè)普通用戶,命令如下:
#adduser tommy
//添加一個(gè)名為tommy的用戶
#passwd tommy //修改密碼
Changing password for user tommy.
New UNIX password: //在這里輸入新密碼
Retype new UNIX password: //再次輸入新密碼
passwd: all authentication tokens updated successfully.
2、賦予root權(quán)限
方法一: 修改 /etc/sudoers 文件,找到下面一行,把前面的注釋(#)去掉
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
然后修改用戶,使其屬于root組(wheel),命令如下:
#usermod -g root tommy
修改完畢,現(xiàn)在可以用tommy帳號登錄,然后用命令 su - ,即可獲得root權(quán)限進(jìn)行操作。
方法二: 修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示:
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
tommy ALL=(ALL) ALL
修改完畢,現(xiàn)在可以用tommy帳號登錄,然后用命令 su - ,即可獲得root權(quán)限進(jìn)行操作。
方法三: 修改 /etc/passwd 文件,找到如下行,把用戶ID修改為 0 ,如下所示:
tommy:x:500:500:tommy:/home/tommy:/bin/bash
修改后如下
tommy:x:0:500:tommy:/home/tommy:/bin/bash
保存,用tommy賬戶登錄后,直接獲取的就是root帳號的權(quán)限。
友情提醒:雖然方法三看上去簡單方便,但一般不推薦使用,推薦使用方法二。
linux如何為用戶添加root權(quán)限
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
tommy ALL=(ALL) ALL
修改完畢后,現(xiàn)在可以用tommy賬號登錄。
然后用命令 su ,即可獲得root權(quán)限進(jìn)行操作。
以上就是本次介紹的全部相關(guān)知識(shí)點(diǎn),感謝大家的學(xué)習(xí)和對本站的支持。
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。