Unix(-like) operative systems decouples the user name from its user identity, so you may safely change the first without changing the other. All permissions, files etc are tied to your identity (uid), not your username.
To manage every aspect of the user database, you use the
To change username:
usermod -l *new username* *old username*
This however, doesn't rename the home folder. To change home-folder, use
usermod -d /home/*new homedir* -m *new username* after you changed the username. It is probably best to do this without being logged in.
For instance, you could logout, drop to a console (Ctrl+Alt+F1), and
sudo su - to become true root (as opposed to
sudo -s, where $HOME is still /home/yourname.) Maybe you also have to kill some still running processes from this user first. To do so, enter
ps -u username, look for the matching PID and kill them by
Update: as arrange mentioned, some files may reference your old home directory. You can either keep a symlink for backward compatibility, e g
ln -s /home/newname /home/oldname or you can change the file contents with
sed -i.bak 's/*oldname*/*newname*/g' *list of files* It creates a backup for each file with a .bak extension.
Some additional information for not so experienced users like me:
As I only have ONE user account (administrator), it would not let me change the username ("you are already logged in" was the response in TTY1 (Ctrl+Alt+F1). I found some information to get around this:
Add a new user, e.g. "temporary". If you are still in TTY1:
sudo adduser temporary
set the password and just type enter
exit. This should bring you to the original login prompt, if not type
- Change the account type of your new temporary user to administrator:
In tty7 (Ctrl+Alt+F7, "normal" desktop) login in to your usual account. Change his privileges through the gui: System settings > users account. Click Unlock then change account type to "administrator".
- Log out again.
- Return to tty1: Login with the 'temporary' user account and password. Change your username and folder as mentioned above.
exit (until you get the login prompt)
- Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
Delete temporary user and folder:
sudo deluser temporary
sudo rm -r /home/temporary