官术网_书友最值得收藏!

Deleting a user account

If you no longer need a user account, it is good idea to delete that account.

Getting ready

You will need super user or root privileges to delete a group from the Ubuntu server.

How to do it...

Follow these steps to delete the user account:

  1. Enter the following command to delete a user account:
    $ sudo deluser --remove-home john
    
  2. Enter your password to complete addgroup with root privileges:

How it works…

Here, we used the deluser command with the option --remove-home. This will delete the user account named john and also remove the home and mail spool directories associated with john. By default, the deluser command will delete the user without deleting the home directory.

It is a good idea to keep a backup of user files before removing the home directory and any other files. This can be done with an additional flag along with the deluser command:

$ deluser --backup --remove-home john

This will create a backup file with the name john.tar.gz in the current working directory, and then the user account and the home directory will removed.

There's more…

When called with the --group option, the deluser command will remove the group. Similarly, when called with two non-option arguments, the deluser command will try to remove a user from a specific group:

$ deluser john guest # this will remove user john from group guest
$ deluser --group guest # this will remove a group

If you want to disable the user account rather than delete it, you can do it with the following commands:

$ sudo usermod --expiredate 1 john # disable the user account john
$ sudo usermod --expiredate "" john # re-enable user account john
$ sudo usermod -e YYYY-MM-DD john # specify expiry date

See also

  • Refer to the manual page for deluser with man deluser
主站蜘蛛池模板: 腾冲县| 益阳市| 邵武市| 泾源县| 新兴县| 汝城县| 濉溪县| 长岭县| 行唐县| 灵台县| 田东县| 永春县| 保德县| 绥中县| 临沭县| 正安县| 治多县| 琼海市| 喀什市| 萝北县| 大荔县| 科尔| 西藏| 凤台县| 神池县| 日照市| 阳泉市| 新龙县| 娄底市| 长兴县| 大石桥市| 敖汉旗| 张家港市| 阜阳市| 库伦旗| 定陶县| 五寨县| 太和县| 长岭县| 迭部县| 高阳县|