X
    Categories: Linux

5 Simple Linux user modification methods on linux with /etc/passwd file.

User modification methods on linux

Normally user creation is an easy task in Linux. Once the user is added to the Linux system there are multiple files that get updated where, users all information get stored. Out of which “/etc/passwd” is the one of the most important file where user information resides.

This file has following 7 fields that kept the user information. As below

  1. User name
  2. Shadowing status for user
  3. UID
  4. GID
  5. Finger field
  6. Home dir
  7. Shell

So let’s take control these fields to play around with the user.

For demo purpose I have created uxtechno user. The respective entry in “/etc/passwd” is as below:

[root@kalwa1 ~]# cat /etc/passwd|grep -i uxtechno
uxtechno:x:500:500::/home/uxtechno:/bin/bash
[root@kalwa1 ~]#

1. Put comment in “/etc/passwd” for the entry of uxtechno.

[root@kalwa1 ~]# cat /etc/passwd|grep -i uxtechno
#uxtechno:x:500:500::/home/uxtechno:/bin/bash
[root@kalwa1 ~]#

This change makes the user uxtechno unable to login with the system. System will simple say user does not exit.

[root@kalwa1 ~]# su - uxtechno
su: user uxtechno does not exist
[root@kalwa1 ~]#

2. Now put the “*” in the second field in the “/etc/passwd”. i.e. change “x” with “*”.

[root@kalwa1 ~]# cat /etc/passwd|grep -i uxtechno
uxtechno:*:500:500::/home/uxtechno:/bin/bash
[root@kalwa1 ~]#

This change makes the user uxtechno unable to login with the system. System will simple say access denied.

login as: uxtechno
uxtechno@192.168.216.130's password:
Access denied

3. Now let’s play with shell. Change the shell field in “/etc/passwd” with “/sbin/nologin” for the user uxtechno.

[root@kalwa1 ~]# cat /etc/passwd|grep -i uxtechno
uxtechno:*:500:500::/home/uxtechno:/sbin/nologin

Now if you try to login with new session. The session will disappears as system does not have the proper shell and if you try to switch user it will prompt with “This account is currently not available.”

[root@kalwa1 ~]# su - uxtechno
This account is currently not available.
[root@kalwa1 ~]#

4. Now make the second field blank.

[root@kalwa1 ~]# cat /etc/passwd|grep -i uxtechno
uxtechno::500:500::/home/uxtechno:/bin/bash
[root@kalwa1 ~]#

This time the user uxtechno able to login to system without password!!!!

 

5. Create the blank file “/etc/nologin”

[root@kalwa1 ~]# touch /etc/nologin
[root@kalwa1 ~]#

This makes the entire users unable to connect with the system except the root user.

View Comments (1)

  • I need to to thank you for this great read!!
    I definitely enjoyed every little bit of it. I've got you book
    marked to check out new stuff you post…

Related Post