Change the username
Hello All,
Is it possible to change the usernames on Linux? I have a Linux box with 10 users (username = firstname). As the number of users are growing I want to change the username convention to include the last names also (username = firstname_lastname). So is it possible to change the existing usernames without changing their profile? Thanks in advance, // Rahul |
Yes, usermod -l should do what you want. besure to change home directory's to be in sync with the new user name.
|
A few pitfalls:
Some distros create a group with the same name as the user, so user john gets the group john. 'usermod -l john_smith john' will change the username from john to john_smith, but not his group. he will be john_smith in group john. use 'groupmod -n john_smith john' to change the groupname accordingly to get the group changed. Again, IF your distro does such. indeed, the home directory... using 'usermod -l john_smith john' does change the username, but not his home directory!.. use 'usermod -l john_smith -d /home/john_smith john' instead, to make the homedir change as well.. Don't forget to rename his homedirectory with 'mv /home/john /home/john_smith'. Finally: the mail spool file.. I don't know if distros fix that automagically. User john has his own mail spool file, in most cases '/var/spool/mail/john'. You'll have to rename the file to fit the new username with 'mv /var/spool/mail/john /var/spool/mail/john_smith'. <disclaimer> Oh, I based the given commands on my distro, Fedora. I can't tell how your version would react. Mostly they're alike, just to be sure: 'man usermod', 'man groupmod' to verify correctness. </disclaimer> This would fix a lot. PS using samba? don't forget to change the user over there as well. |
..or, just " #mv /home/john /home/john_smith
and then " #adduser < add the user j_s > ; you'll be prompted to change ownership of the dir. and as said, check the group-file. egag |
All times are GMT -5. The time now is 04:36 PM. |