Changing user account name in #Linux-based operating systems is not hard, but can at least be inconvenient dance to do for various reasons. Just to give an example, sometimes root account needs to be enabled for password login temporarily so that home directory name can be changed without issues.
It would be super nice if this could be done similarly as with TPM chips and machine over keys (aka MOK managed with mokutil
). I.e. there would be a way to set out a request for username change for logged in local account and upon next reboot there would be a query for new account name, and this process would be taken care of renaming username, group and home directory.
User name and group name are trivial because they don’t really change any identifiers associated with the user but AFAIK usermod completely denies home directory name change for a logged in account.
@jarkko my apologies, I wasn't very clear. What I meant was that the functionality you are proposing seems like it would fit best within systemd, or as a systemd unit file.