Renaming a user account

… on my relative recently installed “laptop”- (“mobile workstation”-)system.

That’s no surprise.
I had set up a second (“administrator”-)user and called it inconsiderately “test” to see that I can set its DE to a real Vanilla-Gnome.
The next day, after the DE indeed showed a true Vanilla-Gnome, I realized that I should have called it “vanilla” and decided to just rename it via the “manjaro-settings-manager”, aware of the pending adjustments in directory ownership & permissions, links, and scripts ….
I’ve had such fumbles occasionally in the my 25 years with Linux, but until a few years ago I was confident to do the first step by just editing /etc/passwd(-) and /etc/group(-) directly¹⁾ & reboot. … and that worked - apparently without further side effects.
¹) Believing that these are the prime source (the “root”) for any related processing (along the lines of Linux’ “everything is a file”).

Now that I’ve lost the confidence in my command of Linux a few years ago, I hesitate to follow that route without consulting our experts here.
If you need the content of those files and the intended edits, I’ll append that, of course.

Hi @nitja,

Perhaps this helps:

https://wiki.archlinux.org/title/Users_and_groups#Change_a_user’s_login_name_or_home_directory

Changing a username is safe and easy when done properly, just use the usermod command. If the user is associated to a group with the same name, you can rename this with the groupmod command.

Alternatively, the /etc/passwd file can be edited directly, see #User database for an introduction to its format.

Also keep in mind the following notes:

  • If you are using sudo make sure you update your /etc/sudoers to reflect the new username(s) (via the visudo command as root).
  • Personal crontabs need to be adjusted by renaming the user’s file in /var/spool/cron from the old to the new name, and then opening crontab -e to change any relevant paths and have it adjust the file permissions accordingly.
  • Wine’s personal directories/files’ contents in ~/.wine/drive_c/users, ~/.local/share/applications/wine/Programs and possibly more need to be manually renamed/edited.
  • Certain Thunderbird addons, like Enigmail, may need to be reinstalled.
  • Anything on your system (desktop shortcuts, shell scripts, etc.) that uses an absolute path to your home dir (i.e. /home/oldname) will need to be changed to reflect your new name. To avoid these problems in shell scripts, simply use the ~ or $HOME variables for home directories.
  • Also do not forget to edit accordingly the configuration files in /etc/ that relies on your absolute path (e.g. Samba, CUPS, so on). A nice way to learn what files you need to update involves using the grep command this way: grep -r old_user *

However, I’ve always just created a new user and moved my home directory’s contents there.

Thank you. That’s about what I think to remember from those earlier occasions.
Anyway, good to have a fresh check list.

… which then has a different UID with a new group having a new GID. … which won’t match those on my other (the “desktop”-)system. (At least that’s been the drawback I think to remember from before 2021.)

Ah well - … and the changed title of the topic doesn’t make sense with its opening post anymore.

If I where you - and from what I understand what you intended to do vs. what you ended up with -
I’d edit /etc/passwd /etc/group /etc/gshadow /etc/shadow
and remove any artifacts of what you did.

After that I’d remove the new /home/user directory of the affected user - also by hand.

Then I’d simply start over with your creation of a new user.

/etc/passwd- /etc/group- /etc/gshadow- /etc/shadow-
are all “backup” files - they contain the previous values after a (one) change with the system tools
but you edited those as well, so you can’t simply use them to revert your changes,
which you could have done.

You don’t need to edit those - they are just “backups” with the previous values.

Oh well, absolutely. I confused “-” and “shadow”. The latter was what I’d intended to write.

Sorry for the delay. It’s actually been basically sorted out 18½ hours ago.
Took ~ 15 Minutes and 5 reboots - significantly shorter than rebooting the (“desktop”-)system up to the point from which I’m writing here.

Even so, I ‘managed’ to let a (smaller) error creep into the directory hierarchy - which is a good occasion to optimize the disk layout and dir structure further (what I intended to do, anyway).
But that is another topic - maybe for the forum or for a mail to @Aragorn, who somewhere mentioned that he achieves exactly what I want with his ‘convoluted’ structure …