要確認 CentOS 用戶是否已被刪除,可以通過以下方法進行檢查:
id 命令登錄到 CentOS 系統: 使用 SSH 或者直接登錄到 CentOS 服務器。
運行 id 命令:
輸入以下命令來查看用戶的詳細信息:
id username
將 username 替換為你想要檢查的用戶名。
分析輸出結果:
uid=1001(username) gid=1001(username) groups=1001(username)
id: username: no such user
getent 命令登錄到 CentOS 系統。
運行 getent 命令:
輸入以下命令來查詢用戶信息:
getent passwd username
將 username 替換為你想要檢查的用戶名。
分析輸出結果:
username:x:1001:1001::/home/username:/bin/bash
getent passwd 命令仍然可能顯示用戶的最后信息,因為這些信息可能被緩存。為了確保準確性,可以嘗試清除緩存:sudo systemctl restart nscd
或者重啟系統。/etc/passwd 文件登錄到 CentOS 系統。
查看 /etc/passwd 文件:
輸入以下命令來查看所有用戶的信息:
cat /etc/passwd
將 username 替換為你想要檢查的用戶名。
分析輸出結果:
/etc/shadow 文件登錄到 CentOS 系統。
查看 /etc/shadow 文件:
輸入以下命令來查看所有用戶的加密密碼信息:
cat /etc/shadow
將 username 替換為你想要檢查的用戶名。
分析輸出結果:
通過以上方法,你可以確認 CentOS 用戶是否已被刪除。