Safest way to change a username/login name

New to Debian (Or Linux in general)? Ask your questions here!

Safest way to change a username/login name

Postby anonova » 2010-04-06 01:30

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).
anonova
 
Posts: 2
Joined: 2010-04-06 01:17

Re: Safest way to change a username/login name

Postby refracta » 2010-04-06 01:40

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
refracta
 
Posts: 1235
Joined: 2008-10-26 01:46

Re: Safest way to change a username/login name

Postby anonova » 2010-04-06 02:16

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?
anonova
 
Posts: 2
Joined: 2010-04-06 01:17

Re: Safest way to change a username/login name

Postby cynwulf » 2010-04-06 08:23

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.
cynwulf
 
Posts: 2396
Joined: 2008-09-25 08:49

Re: Safest way to change a username/login name

Postby thewanderer » 2010-04-06 09:31

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
thewanderer
 
Posts: 416
Joined: 2007-03-19 18:11
Location: my desk, Warsaw, Poland

Re: Safest way to change a username/login name

Postby refracta » 2010-04-06 10:09

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
refracta
 
Posts: 1235
Joined: 2008-10-26 01:46


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 11 guests

fashionable