w3resource

User management

User management

  • Managing users is a critical aspect of server management.
  • In Ubuntu, the root user is disabled for safety.
  • Management tasks requiring root access can be completed by using the sudo command by a user who is in the “admin” group.
  • When you create a user during installation, that user is added automatically to the admin group.

Adding and deleting users

To add a user:

sudo adduser username
adduser username

The image below shows the next part of the command.

adduser newuser

To delete a user (will retain the home directory):

Install the package:

sudo apt-get install unattended-upgrades
install-unattended-upgrades

To disable a user:

sudo passwd -l username

disable a user

To enable a user:

sudo passwd -u username

enable a user

Creating and deleting groups

To create a group:

sudo addgroup groupname

addgroup

To delete a group:

sudo delgroup groupname

delete a group

To add a user to a group:

sudo adduser username groupname

adduser-in-a-group

User profiles

By default, all new home directories can be accessed by everyone. You can enforce non-default access rights to new home directories by editing /etc/ adduser.conf:

Change “DIRMODE=0755”to “DIRMODE=0750”

The contents of this directory are modelled after the contents of /etc/skel.

Password policy

You can enforce strong user passwords by editing the password policy file /etc/pam.d/common-password.

For example, if you want to enforce a password with minimum 8 characters and maximum 14 characters, edit the password line to look like this:

password required pam_unix.so nullok obscure min=8 max=14 md5

Password expiration

To see the password expiry value for a user, use the “chage” command:

The chage tool is for changing password expiration date.

sudo chage -l username

chage-l

To make changes:

sudo chage username

change-username

Previous: Upgrade Ubuntu Linux server with do-release-upgrade
Next: File system



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/linux-system-administration/user-management.php