Linux / Ubuntu

Add and Delete Users in Ubuntu

In Ubuntu and other Debian based distributions, “adduser” package is used for account management.

  1. To add a user account, use the following syntax, and follow the prompts to give the account a password and identifiable characteristics such as a full name, phone number, etc.
    sudo adduser username
  2. To delete a user account and its primary group, use the following syntax:
    sudo deluser username

    Deleting an account doesn’t remove the home folder for that account. If an  account with same username( UID/GID) is created later, that account owner will now have access to this folder if you have not taken the necessary precautions.

    You can remove that folder or move to different folder (relocate) to prevent this unnecessary data access and conflicts.

    For relocating follow the command (recommended),

    sudo chown -R root:root /home/username/
    sudo mkdir /home/archived_users/
    sudo mv /home/username /home/archived_users/

    For removing that folder follow the command (not recommended, take extra care on remove,it cannot be undone),

    sudo rm -r /home/username/
  3. To temporarily lock or unlock a user account, use the following syntax, respectively:
    sudo passwd -l username
    sudo passwd -u username
  4. To add or delete a personalized group, use the following syntax, respectively:
    sudo addgroup groupname
    sudo delgroup groupname
  5. To add a user to a group, use the following syntax:
    sudo adduser username groupname

 

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s