How do you change username?

For privacy reason i would like to change my Linux username (including /home/username directory name etc.), in the general Linux article i have found this comment.

User need to make sure that is NOT logged in as the user whose name you are about to change. Possibly reboot and then login as root.

:::Following are commands that i have tried and which broken numerous things, so i suggest not to try, it, just for information: ::

sudo killall -u OLD
id OLD # not needed? just shows IDs
usermod -l NEW -m -d /home/NEW OLD
shows still some process? i have killed it by "kill -9 number" and then repeat previous command
groupmod -n NEW OLD
usermod -c "New Real Name" NEW
sed -i "s|OLD|NEW|g" /etc/lightdm/lightdm.conf

I do not suggest running following 2 find commands as it may break various things, backup is a MUST:

find /home/NEW /etc /usr -type f -exec sed -i -e 's/\/OLD\//\/NEW\//g' {} +

time find /home/NEW/ /etc /usr -type f -exec grep -I -q . {} \; -print0|xargs -0 sed -i 's|/OLD/|/NEW/|g'

in the Arch wiki I have found: Users and groups - ArchWiki

They mention bunch of other possible things that may need to be tweaked.
I was trying to search some bash script that handles everything needed, but not found.

The list of commands i have mentioned is safe to try and should not break the OS/XFCE? Or do you suggest any other or know about the tutorial or script? Thanks

— sidenotes —

  • change autologin-user in /etc/lightdm/lightdm.conf
  • possibly try: grep -Ri olduser /home/newuser /etc /usr
  • example command to replace old user home path by new one in home: cd /home/newuser && find ./ -type f -readable -writable -exec sed -i "s/\/home\/olduser/\/home\/newuser/g" {} \;
  • actually there is at least 962 files outside of /home that possibly needs changing ownership: find /etc /usr /var /tmp -user OLDUSER -print0 2>/dev/null|xargs -0 chown -h NEWUSER
  • dead links?
    A) find /home/newuser -xtype l
    B) find /home/hp -xtype l -exec stat {} ;
  • if SSH fails to work: sudo chmod g-w /home/$NEWLOGIN

this tutorial was posted not long ago:


The best way is to create a new user.

Login with the new user.

Use sudo to move files from the old user to the new user (also remember to change owner and permission)

Nuke the old user (userdel -rf) including the user’s home folder.


OP here, I have failed changing username

I have tried the steps described in the first post of this topic, yet it failed, the default file manager Dolphin was not working (core dumps, while under root worked), somehow possibly all e-mail in Thunderbird was duplicated and when clicked e-mail it shown source code instead of normal text. Some file links was dead + likely many other tiny issues. So i have decided to do the process again going from new to old username. After that, my firefox profile was broken(it was likely broken after first/initial username changing process), Thunderbird duplicate e-mails, had to restore both from external backup ~/.mozilla, and ~/.thunderbird
Some journalctl issues here after all this is finished

So in my opinion there is no good tutorial on how to change username.

Without any tutorial i can also try to create new user, migrate data (question is how) + various .config, .cache etc. files will still contain old usernames which MAY be problematic, or i will skip many such files which will need me to reconfigure various things. So again there i am not aware about tutorial which would describe what to copy, which commands to run.

→ changing username is not possible - not documented for noob user (unless i have missed some tutorial)

huh … I will either flesh-out something more or add something to transfuse or … give me some time.