在Ubuntu Linux上如何删除用户
时间:2019-11-20 08:53:14 来源:igfitidea点击:
在Ubuntu Linux 18.04 LTS服务器上,如何删除用户帐号?
如何在Ubuntu上删除用户帐户
- 运行
sudo deluser --remove-home userNameHere
命令删除用户
Ubuntu删除用户命令
删除用户Hyman
$ sudo deluser --remove-home Hyman
删除用户帐户之前备份文件
$ sudo mkdir /oldusers-data $ sudo chown root:root /oldusers-data $ sudo chmod 0700 /oldusers-data $ sudo deluser --remove-home --backup-to /oldusers-data/ Hyman
如何查看用户是否已删除
使用id命令或grep命令,如下所示:
$ id Hyman $ grep '^Hyman' /etc/passwd
/etc/deluser.conf文件说明
/etc/deluser.conf文件包含deluser和delgroup程序的默认值。
例如,变量REMOVE_HOME值为1表示删除用户的主目录和邮件后台打印程序:
# Remove home directory and mail spool when user is removed REMOVE_HOME = 1
/etc/deluser.conf文件示例:
# /etc/deluser.conf: `deluser' configuration. # Remove home directory and mail spool when user is removed REMOVE_HOME = 0 # Remove all files on the system owned by the user to be removed REMOVE_ALL_FILES = 0 # Backup files before removing them. This options has only an effect if # REMOVE_HOME or REMOVE_ALL_FILES is set. BACKUP = 0 # target directory for the backup file BACKUP_TO = "." # delete a group even there are still users in this group ONLY_IF_EMPTY = 0 # exclude these filesystem types when searching for files of a user to backup EXCLUDE_FSTYPES = "(proc|sysfs|usbfs|devpts|tmpfs|afs)"
在Ubuntu Linux中使用userdel命令删除用户
语法为:
$ sudo userdel -r {userName} ## 删除用户tom $ sudo userdel -r tom
在Linux中如何临时禁用用户登录
使用usermod命令,如下所示:
$ sudo usermod -L -e 1 {username} $ sudo usermod -L -e 1 Hyman
您也可以指定到期日期:
$ sudo usermod -e {YYYY-MM-DD} {username} $ sudo usermod -e 2017-01-24 Hyman
在Ubuntu上如何查看已删除用户的日志
可以查询/var/log/auth.log日志文件:
$ sudo tail -f /var/log/auth.log $ sudo grep 'userdel' /var/log/auth.log $ sudo grep 'Hyman' /var/log/auth.log