Does anyone know of an easy way to change login handles?

For example, let's say my current login handle on my Ubuntu machine is
foo and I want to change that to bar.  My current method is the
following:

1) check for user foo and bar in /etc/passwd, /etc/shadow, /etc/group
$ sudo grep -H -i foo /etc/passwd /etc/shadow /etc/group
/etc/passwd:foo:x:1009:1009::/home/foo:/bin/bash
/etc/shadow:foo:$1$QEieajCC$NDHtD.yMokaMoYsvuRYU1/:14364:0:99999:7:::
/etc/group:foo:x:1009:

$ sudo grep -H -i bar /etc/passwd /etc/shadow /etc/group

2) change from user foo to user bar in /etc/passwd, /etc/shadow, /etc/group
$ sudo sed -i -e 's/foo/bar/' /etc/passwd /etc/shadow /etc/group

$ sudo grep -H -i foo /etc/passwd /etc/shadow /etc/group
/etc/passwd:bar:x:1009:1009::/home/foo:/bin/bash

$ sudo grep -H -i bar /etc/passwd /etc/shadow /etc/group
/etc/passwd:bar:x:1009:1009::/home/foo:/bin/bash
/etc/shadow:bar:$1$QEieajCC$NDHtD.yMokaMoYsvuRYU1/:14364:0:99999:7:::
/etc/group:bar:x:1009:

3) change home folder
$ sudo mv /home/foo /home/bar

4) update user bar's info
$ sudo usermod -d /home/bar bar


That's a lot of work, is error prone, and does not address all the
other places where a user's handle may need to be changed, e.g.
/etc/ssh/sshd_config or /etc/sudoers.  Anyone know a better way?

Regards,
- Robert

--~--~---------~--~----~------------~-------~--~----~
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: [email protected]
To subscribe: [email protected]
To unsubscribe: [email protected]
More options: http://groups.google.com/group/cwelug
-~----------~----~----~----~------~----~------~--~---

Reply via email to