Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Safest way to change a username/login name

New to Debian (Or Linux in general)? Ask your questions here!
Post Reply
Message
Author
anonova
Posts: 2
Joined: 2010-04-06 01:17

Safest way to change a username/login name

#1 Post by anonova »

I would like to change my username (or login name) and am wondering what the safest route to do so is. The install is on a headless server, which I just use ssh.

There's a) using usermod -l newname oldname. The line in the usermod man that says that changing the login name doesn't change anything else, which makes me think that something else is bound to break.

I've also considered b) creating a new user, moving the contents of my home directory to the new user, and deleting the old user. This is kind of cumbersome, but would this be the recommended way to ensure everything goes well (considering I still have to redo some config files).

refracta
Posts: 1234
Joined: 2008-10-26 01:46

Re: Safest way to change a username/login name

#2 Post by refracta »

safest? safe for what?

if I recall correctly, if you just change the username home will still be the same as the old username...kind of weird....at least to me...


if it was me I would create new user, copy files over to new home, delete old user

anonova
Posts: 2
Joined: 2010-04-06 01:17

Re: Safest way to change a username/login name

#3 Post by anonova »

refracta wrote:safest? safe for what?
Safe as in the least collateral damage if I end up completely obliterating anything else on the system.

Edit: Also, does deleting a user leave any residue that needs to be cleaned up after?

cynwulf

Re: Safest way to change a username/login name

#4 Post by cynwulf »

anonova wrote:
refracta wrote:safest? safe for what?
Safe as in the least collateral damage if I end up completely obliterating anything else on the system.

Edit: Also, does deleting a user leave any residue that needs to be cleaned up after?
Try "man userdel" at the terminal.

From memory, userdel removes the user, "userdel -r" clears the home directory as well.

thewanderer
Posts: 416
Joined: 2007-03-19 18:11
Location: my desk, Warsaw, Poland

Re: Safest way to change a username/login name

#5 Post by thewanderer »

How I change local login names:
1. Edit /etc/passwd, find the line that corresponds to your user, and change the login name - also home directory if you want to
2. Edit /etc/shadow and do the same
3. In case you changed the home directory, move the home directory to the new place
4. Either fix all set paths that the user had (for instance, KDE has a bad habit of using absolute paths to the wallpaper in your home directory) or make a symbolic link: ln -s /home/newusername /home/oldusername
[url=irc://irc.freenode.net/debian]Find me on #debian at irc.freenode.net[/url] | Linux permission HOWTO | Shorewall firewall | Virtual web hosting

refracta
Posts: 1234
Joined: 2008-10-26 01:46

Re: Safest way to change a username/login name

#6 Post by refracta »

anonova wrote:
Edit: Also, does deleting a user leave any residue that needs to be cleaned up after?
depends on how you remove the user....but it is nothing that is going to cause a nuclear meltdown or anything...

I suggest you man deluser

I usually use deluser --remove-home --remove-all-files username

Post Reply