Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-23-2004, 12:57 AM   #1
Registered: Dec 2004
Posts: 32

Rep: Reputation: 15
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
Old 12-23-2004, 01:24 AM   #2
Senior Member
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Yes, usermod -l should do what you want. besure to change home directory's to be in sync with the new user name.
Old 12-23-2004, 03:09 AM   #3
Registered: Aug 2004
Location: The Netherlands
Distribution: RedHat 2, 3, 4, 5, Fedora, SuSE, Gentoo
Posts: 372

Rep: Reputation: 42
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'.

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.
This would fix a lot.

PS using samba? don't forget to change the user over there as well.

Last edited by rhoekstra; 12-23-2004 at 03:13 AM.
Old 12-23-2004, 12:18 PM   #4
Senior Member
Registered: Jul 2004
Location: Netherlands
Distribution: Slackware
Posts: 2,721

Rep: Reputation: 52
..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.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I change my username? ssobeht LQ Suggestions & Feedback 19 10-14-2005 10:03 AM
username change...... roshu Linux - Software 2 03-10-2005 04:31 AM
Change username? theonebeyond LQ Suggestions & Feedback 3 12-05-2004 01:32 PM
change username thelight1 LQ Suggestions & Feedback 2 05-19-2004 11:24 PM
username change nakkaya Linux - General 3 02-28-2003 03:10 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration