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?
1 Answer
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.
chroot
into the other system and use that system'spasswd
(orpasswd -R
), to be honest.