簡體   English   中英

“ sudo”命令如何工作?

[英]How “sudo” command works?

我的理解是sudo使用root特權執行給定的命令 ,但是我體驗到在終端中使用sudo輸入命令會緩存授權。 它實際上如何運作?

例如

sudo fdisk -l
[sudo] password for xxxxx:

(一旦我輸入密碼授權,連續的sudo命令不會提示輸入密碼)

sudo fdisk -l

(不提示輸入密碼)

sudo mount -t vfat /dev/sda1 /media/test

sudo是否真的是su (替代/切換用戶)的包裝器?

man sudo會告訴:

   Security policies may support credential caching to allow the user to
   run sudo again for a period of time without requiring authentication.
   The sudoers policy caches credentials for 15 minutes, unless overridden
   in sudoers(5).  By running sudo with the -v option, a user can update
   the cached credentials without running a command.

它還說:

   -k [command]
               When used alone, the -k (kill) option to sudo invalidates
               the user's cached credentials.  The next time sudo is run a
               password will be required.  This option does not require a
               password and was added to allow a user to revoke sudo
               permissions from a .logout file.  Not all security policies
               support credential caching.

               When used in conjunction with a command or an option that
               may require a password, the -k option will cause sudo to
               ignore the user's cached credentials.  As a result, sudo
               will prompt for a password (if one is required by the
               security policy) and will not update the user's cached
               credentials.

這里有適合您的詳細信息:
是的sudo和su命令有點不同:
1.)當我們觸發su命令時,它將充當純管理員(我們可以在該會話時間內永久不變)
2.)鑒於sudo命令是擁有或分配管理員權限的角色(我們只能說該會話是臨時的)

另一個例子:
在Windows系統中,希望您已選中右鍵單擊屬性,例如“以管理員身份運行”,這與sudo相同。
而且,如果我們將用戶登錄或切換為Admin,則它純粹是充當所有程序的管理員。

希望你理解我的榜樣,這對我來說是最好的

在/ etc / sudoers中,您可以編輯sudo配置。

沒有默認的授權超時。

您甚至可以使用sudo分配一些用戶,而無需輸入密碼。 或者某些用戶一旦獲得授權,則在您注銷系統之前不需要密碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM