Day 8 - User and Group Management in Linux

The manage user and groups account is the core part of Linux operating system. Each user has distinct login credentials in operating system to manage customize privileges in to user and group account. Each user and group got default unique ID’s add the time of creation, After installation of the operating system, the ID 0 is assigned to the root user and the IDs 1 to 999 (both inclusive) are assigned to the system users and hence the ids for local user begins from 1000 onwards.

we can manage various permission ton basis of user and group for access any file, directory or commands it important to understand the user and group account management.

Type of User:

System User –

  • It is created by OS automatically.

  • System user account by default have user id between 0 – 999.

    Example –

  • Root user account automatically created at the time of Linux OS Installation.

  • Administrator user account automatically created at the time of windows OS installation.

Normal User –

  • It is created by privilege/Administrator user

  • Normal user account by default got id 1000+

    Example –

    • jethalal, param, avtar

To manage user account use following commands –

useradd – use to add user account

usermod – use to modify existing user account

userdel – use to delete user account

passwd – use to create or change user account password

All user account database by default stored in following file –

  • User account Properties – /etc/passwd

  • User Password Properties – /etc/shadow

  • Group database - /etc/group

  • Group password Properties - /etc/gshadow

Manage User Account step by step:

For Create user account:

For check user account properties:

Here total 7 filed available each filed separated by : (colon).

For Create/change user account password:

Type here password which want to we set, need to re-enter password for the confirmation.

-e, –expire: This option immediately expires the account password and forces the user to change password on their next login.

-l, –lock: Lock the password of user:

u –unlock: Unlock the password of an account:

-S, –status: Shows the password status:

The first field is the user’s login name. The second field indicates if the user account has a locked password (L), has no Password (NP), or has a usable password (P). The third field gives the date of the last password change. The next four fields are the minimum age, maximum age, warning period, and inactivity period for the password. These ages are expressed in days.

For check user password properties:

User password properties store in following format, each filed is separated by : (colon)

For switch one user account to another user account –

For logout from currently login user account enter exit

or

press “ctrl+d” shortcut key for logout.

For delete user account –

Option

Description

-r

user’s home directory will be removed along with the files in it.

-f

user gets deleted irrespective of the login status.

For add comment :

set custom uid:

Set Home Directory. -d : option creates a home directory with a name and path of your choice.

If we want user not to be able to login:

Creating admin users:

Suppose we want to provide some user with sudo privileges on the system. First we need to make sure that user have a home directory defined. Now here is the demonstration to equip a user with admin / sudo privileges.

The second sudo used in the command is actually a group, so in essence we are adding the jethalal user to a sudo group, thus it is able to gain admin privileges.

Conclusion

So that brings us to the end of this blog post. I hope you got the clear picture of how to create, modify and delete users on Linux, set passwords & expiry date for accounts and provide a user with admin privileges. Don't feel as though you have to, but if you feel like it, give an upvote and share with friends.

Thanks for reading to the end; I hope you gained some knowledge.❤️🙌

PARAMVEER SINGH