Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux sudo 權限配置教學:編輯 sudoers 允許指定用戶免密執行特定指令

編輯:關於 Linux

sudo 預設給予 root 權限,但實際運作受 /etc/sudoers 控管。本文示範如何配置讓用戶 kk 免密執行 mount.cifs。

配置步驟

  1. 使用專用編輯器(避免語法錯誤):visudo
  2. 加入授權規則:
# 允許 kk 執行所有 sudo 指令
kk ALL=(ALL) ALL

# 允許 kk 免密執行 mount.cifs
kk ALL=(ALL) NOPASSWD: /sbin/mount.cifs
  • NOPASSWD: 免輸入密碼
  • 指令請使用絕對路徑(which mount.cifs 確認)

儲存離開即生效。切勿直接用 vim 編輯 sudoers,語法錯誤會導致所有 sudo 失效。

Copyright © Windows教程網 All Rights Reserved