0

So, I'm writing a script that needs to modify the such a file but from the partition of a non booted OS (for example from a livCD to a OS installed on another drive) and I was wondering if, given I mount the Drive correctly, I will always find it in /path/to/mounted/drive/etc/passwd or if it is possible/common to have it somewhere else. Moreover, if it is possible, do I have a quicker way to find it than to use the find bash command?

2
  • That sounds like a XY problem. How do you want to modify that file? Usually, one would chroot into the other system and use that system's passwd (or passwd -R), to be honest.
    – Zeta
    Commented Oct 18, 2018 at 19:21
  • @Zeta I know I know, the idea is more of a proof of concept for a python script, so I want to go there and read and modify it for reasons but I'd like to know if I can "shot at it" at the usual path or if I should keep in mind some other positions or even use a search in the whole partition. Commented Oct 18, 2018 at 19:27

1 Answer 1

0

In file /etc/libuser.conf there are two sections:

[files]
Configures the files module, which manages /etc/group and /etc/passwd. The configuration variables are probably useful only for libuser development.
    directory - The directory containing the group and passwd files.  Default value is /etc.
    nonroot - Allow module initialization when not invoked as the root user if the value is yes.

[shadow]
Configures the files module, which manages /etc/gshadow and /etc/shadow. The configuration variables are probably useful only for libuser development.
    directory - The directory containing the gshadow and shadow files.  Default value is /etc.
    nonroot - Allow module initialization when not invoked as the root user if the value is yes.

So to answer your question: yes, the location of passwd file can be changed.

You should also be aware that modifying passwords from outside the system can be tricky if SELinux is enabled.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .