Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Ubuntu Server Cookbook

You're reading from   Ubuntu Server Cookbook Arm yourself to make the most of the versatile, powerful Ubuntu Server with over 100 hands-on recipes

Arrow left icon
Product type Paperback
Published in Jun 2016
Publisher Packt
ISBN-13 9781785883064
Length 456 pages
Edition 1st Edition
Concepts
Arrow right icon
Author (1):
Arrow left icon
Uday Sawant Uday Sawant
Author Profile Icon Uday Sawant
Uday Sawant
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Managing Users and Groups FREE CHAPTER 2. Networking 3. Working with Web Servers 4. Working with Mail Servers 5. Handling Databases 6. Network Storage 7. Cloud Computing 8. Working with Containers 9. Streaming with Ampache 10. Communication Server with XMPP 11. Git Hosting 12. Collaboration Tools 13. Performance Monitoring 14. Centralized Authentication Service Index

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 to do it...

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
You have been reading a chapter from
Ubuntu Server Cookbook
Published in: Jun 2016
Publisher: Packt
ISBN-13: 9781785883064
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image