Do it your self hobby code

User Group Management — Ubuntu

Show All User

cut -d: -f1 /etc/passwd

Add User

To add username kyle, enter the following:

sudo adduser kyle

or

sudo useradd kyle

To add the user home directory automatically, please use -m option, this will creates a home directory

sudo useradd -m kyle

Giving Sudo permission

usermod -aG sudo kyle

To remove/delete a user:

sudo userdel kyle

Please be careful of using the following commands. This will delete all the users data

If you want to deleted users directory, do this:

sudo rm -r /home/kyle

Changing the username:

sudo usermod -l kyle42 kyle

To change the password for a user:

sudo passwd kyle

*it will prompt  you the Enter new UNIX password:

MANAGING GROUPS

List Groups

List all groups of which the current user is a member.

groups

List all groups including the groups that are used by the system

cat /etc/group

List users on a group

Example: list users on sudo group

getent group sudo

Add group

sudo addgroup readers
sudo addgroup editors

Adding user to a group

sudousermod -a -G readers sarah
sudo usermod -a -G editors kyle

Remove Group

groupdel groupname

Leave a Comment

Your email address will not be published.