Showing posts with label User Management in Linux. Show all posts
Showing posts with label User Management in Linux. Show all posts

Thursday, November 5, 2020

User Management in Linux

 How to add user and group in Linux -


1. To add a group in Linux server - (Suppose I have to add admin named group)

[root@amiteshjsk home]# groupadd admin

 Verify group name which you added recently -

[root@amiteshjsk home]# cat /etc/group | grep -i admin
admin:x:1001:

where group id is - 1001

group name is admin

2. Now we can add user in this group -

[root@amiteshjsk home]# useradd -m -g admin, -c "Amitesh Sharma amiteshjsk@hotmail.com UNIX Team" -s /bin/bash amiteshjsk

where-

-m creating home directory
-g to assign to a group
-c to define values in captions
-s to define shell

Now we can set a password-

[root@amiteshjsk home]# passwd amiteshjsk
Changing password for user amiteshjsk.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@amiteshjsk home]#

For Non-expiry password-

#passwd -x 99999 amiteshjsk

To check password or details-

#chage -l amiteshjsk

To reset the password in first login -

#chage -d 0 amiteshjsk

Check entry in /etc/passwd -

[root@amiteshjsk home]# cat /etc/passwd | grep -i amiteshjsk
amiteshjsk:x:1001:1002:Amitesh Sharma amiteshjsk@hotmail.com UNIX Team:/home/amiteshjsk:/bin/bash


Now we can check user details -

[root@amiteshjsk home]# id amiteshjsk
uid=1001(amiteshjsk) gid=1001(admin) groups=1001(admin)

3. If you want to change group of user -

[root@amiteshjsk home]# usermod -g unix amiteshjsk
[root@amiteshjsk home]# id amiteshjsk
uid=1001(amiteshjsk) gid=1002(unix) groups=1002(unix)
[root@amiteshjsk home]#

Now If you want to add it in other group like admin but primary group will unix then -

[root@amiteshjsk home]# usermod -a -G admin amiteshjsk
[root@amiteshjsk home]# id amiteshjsk
uid=1001(amiteshjsk) gid=1002(unix) groups=1002(unix),1001(admin)
[root@amiteshjsk home]#








Introduction to Linux Part 1

Introduction to Linux Part 1

Introduction to Linux Linux is an operating system that works just like Windows and Mac OS X. As an operating system, Linux is a very h...