Linux 使用者資訊主要存放在 /etc/passwd,密碼與帳號期限資訊在 /etc/shadow,群組資訊在 /etc/group,家目錄通常位於 /home/username。
id id -u id -g id -Gn
useradd useradd -u 1001 -g group1 -G group2 -d /home/test -s /bin/bash test userdel -r test
usermod -aG group1 test usermod -L test usermod -U test usermod -l newname oldname
groupadd group1 groupdel group1
可使用 visudo 編輯 /etc/sudoers,格式為:
授權目標用戶 主機名稱=(切換身分) 授權命令
例如:
test localhost=(root) /usr/sbin/useradd test localhost=(root) NOPASSWD:/usr/sbin/useradd
可用 chage 管理密碼與帳號期限:
chage -d 0 test chage -M 90 -W 7 test chage -E 2026-12-31 test