如何在Linux系統中查詢給定使用者的所屬組?
我們知道,可以使用名為**compgen**的Linux實用程式命令列印Linux系統中存在的所有使用者。
**compgen**命令是一個Linux實用程式命令,用於列出可以在Linux終端中執行的所有命令,當與**-u**標誌一起使用時,我們可以簡單地列印Linux系統中存在的所有使用者。
請參考以下命令:
compgen -u
輸出
root daemon bin sys sync games man lp mail news uucp proxy www-data backup . . .
現在,如果我們想列印Linux作業系統中存在的全部組,我們可以使用**groups**命令。
groups命令用於列印Linux核心中存在的所有組。
語法
groups [options]
通常,上述命令中的選項會被特定使用者替換,以便我們檢查該使用者屬於多少個組。
讓我們來看幾個groups命令的例子。
命令
groups
輸出
sh-3.2# groups wheel daemon kmem sys tty operator procview procmod everyone staff certusers localaccounts admin com.apple.sharepoint.group.1 _appstore _lpadmin _lpoperator _developer _analyticsusers com.apple.access_ftp com.apple.access_screensharing com.apple.access_ssh com.apple.access_remote_ae
如果要檢查特定使用者的組,請執行以下命令。
命令
groups immukul
輸出
sh-3.2# groups immukul staff everyone localaccounts _appserverusr admin _appserveradm _lpadmin com.apple.sharepoint.group.1 _appstore _lpoperator _developer _analyticsusers com.apple.access_ftp com.apple.access_screensharing com.apple.access_ssh com.apple.access_remote_ae
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP