Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Useradd creates lock files in /etc/ directory. Is it possible make it create them somewhere else?

share|improve this question

AFAIK that's not possible without modifying the source code.

Why is /etc problem for you? Do you want to keep it read-only or...?

EDIT: OK, so your /etc is a read-only directory. Would it be possible to you to write a wrapper around useradd? A small script like

mount -o remount,rw /etc (or whatever mount point contains your /etc, maybe just /)
useradd here_be_some_parameter_handling
mount -o remount,ro /etc

would temporarily remount the disk as read-write and then back as read-only.

share|improve this answer
That's right /etc/ is a read-only directory. I tried changing the path directly in the binary, but the only string I thought could be the lockfile path apparently is something else cause changing it does nothing, so I will probably have to write some code. – user58292 Nov 10 '10 at 8:47
Edited my reply a bit. – Janne Pikkarainen Nov 10 '10 at 9:19
That's impossible on the embedded platform I'm working on unfortunately. The passwd. group and shadow files are links to a rw partition and I'll probably just use chroot to run adduser from there. Thanks anyway! – user58292 Nov 10 '10 at 10:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.