banjo Posted August 3, 2004 Report Share Posted August 3, 2004 I have created a user account on my Mandy 9.1 and now I am unhappy with the name. Just another tragic mouse accident! I would like to change the name of the user to something else. Is it possible to change the name of an existing user account without mucking up the whole thing.? Other than renaming the home directory and correcting /etc/passwd, what else needs to be done? Can the control panel do this for me? (I am not sitting at my Linux box right at the moment or I would look that one up). The only thing wrong with the account is the name, so I would rather not have to start all over again creating a new user and deleting the old one. Thanks in advance Banjo (_)=='=~ Quote Link to comment Share on other sites More sharing options...
pmpatrick Posted August 3, 2004 Report Share Posted August 3, 2004 How about, create a new user with name you like. Then as root, copy over the old user's entire home directory to the new user's home directory and allow overwritng on all files. If you do that in konqueror as root, make sure you select View>Show hidden files so you get everything over to your new user's home. Most of the user's config files are hidden files in his home directory so it's importantant to copy those. Then test the new user and make sure everything works OK. Once your satisfied, delete the old user. Quote Link to comment Share on other sites More sharing options...
banjo Posted August 3, 2004 Author Report Share Posted August 3, 2004 Hmm. I hadn't thought of that. I guess that is the fastest way to do it. I would probably use the CLI instead of Konqueror to do the copy. I come from the old Unix days of iron men and wooden boats, so it just feels right to do those operations with a command. But I am gettin' kinda lazy with all this GUI stuff. This Linux ain't yer granpa's Unix no siree. Thanks for the hint. Banjo (_)=='=~ Quote Link to comment Share on other sites More sharing options...
SwiftDeath Posted August 3, 2004 Report Share Posted August 3, 2004 Yep sounds good. and for the newbs reading this here is the command you would do to copy the files and delete your old directory. cp /home/olduser /home/newuser && rmdir /home/olduser Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted August 4, 2004 Report Share Posted August 4, 2004 (edited) And just to be sure: # chown -R newuser /home/newuser # grep -ril olduser /home/newuser If this last command finds some files, then try and locate where your old user name appears in each file. Correct if needed. SwiftDeath, are you sure the command you give is good enough? I mean, does it behave correctly in presence of links, or other non-regular files? Me, I'd rather do that: # (cd /home/olduser && tar cf - .) | (cd /home/newuser && tar xpf -) And for deleting the user, there is IIRC a command for deleting a user, that takes care of both the home-directory, and the /etc/* files. Yves. Edited August 4, 2004 by theYinYeti Quote Link to comment Share on other sites More sharing options...
Gowator Posted August 4, 2004 Report Share Posted August 4, 2004 Changing the username is simple enough... just edit in /etc/shadow and /etc/passwd but then you need to change ownership of the old files to the new owner and if the group name was the same as the username /etc/group for the home directory its pretty simple chown -R newuser:newgroup /home/<newuser> the other part though is finding other stuff scattered about... you can make a recursive find from / and presume if you dont have access then you dont have any files in the dirctory...using a -uid = (uid) you can use the -exec {chown .... } (Im at work on windows now) to change ownership but in the meantime it doesnt matter, even though the owner is written to the inode when created if it has the same uid it will inherit the correct permissions (this is the advantage over making a new user where this isnt the case unless the uid and gid are the same) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.