VPS & Máy chủ chuyên dụng (Trung tâm kiểm soát dịch vụ lưu trữ) Trợ giúp

How to delete a user on Ubuntu

Ubuntu is a Linux operating system based on the Debian distribution. It currently defaults to the Unity desktop environment (DE), although previous versions of Ubuntu used the Gnome DE. Ubuntu primarily consists of open-source software that's distributed under the GNU General Public License at no charge. As with all other operating systems, maintaining user accounts is a routine task for Ubuntu system administrators. The essential steps for removing a user in Ubuntu include deleting the account and then deleting that user's home directory.
DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
RELATED PRODUCTS Linux-based VPS or dedicated servers

Here is a quick tutorial on how to delete a user on Ubuntu.

Remove the user's account

Open a terminal window and enter the following command:

# sudo userdel testuser

The above line uses the userdel command to remove the account for testuser. The use of sudo ensures that this command has the required superuser privileges.

Delete the user's home directory

Enter the following command to delete the user's home directory:

# sudo rm -rf /home/testuser

This command removes the directory with the rm command. The r option removes the directory recursively, meaning that the subdirectories of /home/testuser are also removed. The f option forces the command, meaning that it will assume default responses without prompting you.

Verify the user account has been deleted

su testuser

You should receive an error saying this user does not exist

Bài này có hữu ích không?
Thanks for your feedback. To speak with a customer service representative, please use the support phone number or chat option above.
Rất vui vì chúng tôi đã giúp được bạn! Chúng tôi có thể làm gì thêm cho bạn?
Rất tiếc về điều đó. Tell us what was confusing or why the solution didn’t solve your problem.