deluser
命令在 CentOS(和其他類 Unix 系統)中用于刪除用戶賬戶
以下是 deluser
命令的基本語法:
deluser [選項] 用戶名
一些常用的選項包括:
-f
或 --force
:強制刪除用戶,即使該用戶有登錄會話或正在運行的過程。-r
或 --remove
:刪除用戶的主目錄及其內容。-s
或 --shell
:將用戶的默認 shell 更改為系統默認的 shell。以下是一些使用 deluser
命令的示例:
exampleuser
的用戶,并刪除其主目錄:deluser exampleuser -r
exampleuser
的用戶,即使該用戶有登錄會話:deluser -f exampleuser
exampleuser
的用戶,并將其默認 shell 更改為 /bin/nologin
:deluser -s /bin/nologin exampleuser
在使用 deluser
命令時,請務必謹慎,因為刪除用戶賬戶將導致與該用戶相關的所有數據丟失。在執行此操作之前,最好先備份相關數據。