Changing the user name

Laszlo Papp lpapp at kde.org
Wed May 14 09:56:16 UTC 2014


On Wed, May 14, 2014 at 9:18 AM, Tito <farmatito at tiscali.it> wrote:
> On Wednesday 14 May 2014 08:28:59 Ralf Friedl wrote:
>> Laszlo Papp wrote:
>> > is this possible? I am looking for something like "usermod -l" on desktop.
>> >
>> > Alternatively, I have to look into the get/setpwent syscalls?
>> You can also use sed to change /etc/passwd
>>
>> sed -i -e /s^olduser:/newuser:/ /etc/passwd
>
> Hi,
> I think this is not enough. You have to:
>
> 1) change the user name in /etc/passwd
> 2) change the user name in /etc/shadow (if shadow passwords are used)
> 3) change the group name of the user if a group with the same name as user name was created in /etc/group
> 4) change the group name of the user if a group with the same name as user name was created in /etc/gshadow  (if shadow passwords are used)
> 5) change user name if member of other groups in /etc/group
> 6) change user name if member of other groups in in /etc/gshadow  (if shadow passwords are used)
> 7) eventually change user's homedir in  in /etc/passwd to reflect the new username
> 8) rename users home dir accordingly if needed
> 9) rename users mail spool accordingly if needed
>
> Using sed if it is a multiuser system is not a good idea as there is no file
> locking and backup mechanism and if a user decides to change his password
> the same time you change a username file corruption could be possible.

Good observation.


More information about the busybox mailing list