普通用戶如何執(zhí)行root權(quán)限命令?
- sudo:super user do,以超級用戶的方式執(zhí)行命令。指令格式為:
sudo 指令
當(dāng)前用戶的密碼
sudo是一種權(quán)限管理機(jī)制,其權(quán)限管理記錄在/etc/sudoers文件中,約定普通用戶可以以管理員的身份執(zhí)行命令。
基本運(yùn)行機(jī)制為:普通用戶執(zhí)行sudo命令時(shí),查找/etc/sudoers文件以確定該用戶是否具有執(zhí)行權(quán)限;若有,則提示用戶輸入自己的密碼,密碼正確則執(zhí)行sudo對應(yīng)的命令。
root@linux:/etc# cat sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaultsenv_reset
Defaultsmail_badpass
Defaultssecure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
rootALL=(ALL:ALL) ALL
linuxALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudoALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
- su:switch user,切換用戶
如切換到root用戶下,可執(zhí)行命令:
su root
輸入root密碼
執(zhí)行完操作后,也可以退出root用戶
root@linux:/etc# exit
exit
事實(shí)上,還有另外一種格式:
su -l root(-l)
su的兩種格式區(qū)別在于:-l為login的首字母,登錄后使用全新的環(huán)境變量。
-
管理
+關(guān)注
關(guān)注
2文章
384瀏覽量
26439 -
ETC
+關(guān)注
關(guān)注
0文章
188瀏覽量
28228 -
執(zhí)行
+關(guān)注
關(guān)注
0文章
16瀏覽量
12636
發(fā)布評論請先 登錄
相關(guān)推薦
![](https://file1.elecfans.com/web2/M00/83/61/wKgaomRl2faAHjcsAACKHZFeZ8I975.png)
Linux學(xué)習(xí)之路46_用戶修改與組管理 #linux #linux學(xué)習(xí) #linux嵌入式開發(fā) #硬聲創(chuàng)作季
![](https://file1.elecfans.com/web2/M00/83/62/wKgZomRl2faAY7PyAACKDB6SFB4390.png)
Linux學(xué)習(xí)之路47_用戶管理_su與sudo #linux #linux嵌入式開發(fā) #硬聲創(chuàng)作季
LINUX修改文件權(quán)限
零基礎(chǔ)如何進(jìn)行linux學(xué)習(xí)
linux的權(quán)限和指令
【4412開發(fā)板】理解和掌握linux用戶、用戶組、權(quán)限等方法
Linux 中文件權(quán)限管理的探討
淺談Linux權(quán)限管理的ACL權(quán)限
Linux進(jìn)程權(quán)限的分析說明
Linux系統(tǒng)如何修改文件屬性與權(quán)限
![<b class='flag-5'>Linux</b>系統(tǒng)如何修改文件屬性與<b class='flag-5'>權(quán)限</b>](https://file1.elecfans.com/web2/M00/82/B6/wKgaomRd6myAYWtuAAEskNFm_Dw231.jpg)
linux文件訪問權(quán)限怎么設(shè)置
Linux把目錄權(quán)限給指定用戶
Linux用戶身份與進(jìn)程權(quán)限詳解
![<b class='flag-5'>Linux</b><b class='flag-5'>用戶</b>身份與進(jìn)程<b class='flag-5'>權(quán)限</b>詳解](https://file1.elecfans.com/web2/M00/0A/EE/wKgaomcYcOeAOFTIAAAlR6hIpxM398.png)
評論