
我想知道有什麼論點使它pgrep
只對當前用戶起作用。-u
讓我提供名稱,我不知道目前使用者的名稱,我只知道我只需要當前使用者。
謝謝
答案1
您可以使用 UID或者一個名稱,如您所見man pgrep
:
-u euid,...
Only match processes whose effective user ID is listed. Either the
numerical or symbolical value may be used.
-U uid,...
Only match processes whose real user ID is listed. Either the
numerical or symbolical value may be used.
如果您也不知道,只需使用命令替換:
pgrep -u "$(whoami)"