How to change an existing username?

Hello all. I recently installed OpenSUSE Leap 15 with plasma desktop and I’m very happy with it.
But… I regret the username I selected.
Is it possible to change the username?
I already tried the following:

I changed runlevel to 3, logged in an a console as root and executed the following commands:

usermod -l login-name old-name

mv /home/userdir_old /home/userdir_new

init 6

… but no luck. KDE is not able to login…

is there a (simple) way to accomplish this without creating a new account?

I assume you are already doing correct things. But asking first and doing after getting suggestions might have been better.

There is a similar thread here (few months old) and the OP there succeeded. So let me search for it (you can of course also try to find it).

And you can of course provide information, like

cat /etc/passwd
ls -l /home

So you and we can see what the situation is.

Easy to find. Read this one:
https://forums.opensuse.org/showthread.php/533390-Change-the-name-of-a-local-user?highlight=change+username

On 10/22/2018 12:46 PM, Teuniz wrote:
>
> I changed runlevel to 3, logged in an a console as root and executed the
> following commands:
>
>
> Code:
> --------------------
> usermod -l login-name old-name
>
> mv /home/userdir_old /home/userdir_new
>
> init 6
> --------------------

A good start, but you did not change your pointer to the home directory,
but rather just renamed the directory itself. That’s not valid, as the
pointer is not using the username as a variable or anything.

> … but no luck. KDE is not able to login…
>
> is there a (simple) way to accomplish this without creating a new
> account?

Fix your home directory pointer:


sudo /usr/sbin/usermod --home /home/userdir_new login-name


Good luck.

If you find this post helpful and are logged into the web interface,
show your appreciation and click on the star below.

If you want to send me a private message, please let me know in the
forum as I do not use the web interface often.

Thank you! (both of you)

Regards,

Teuniz

That all seems unnecessarily complicated.
YaST allows the usernames to be edited. It changes the passwd, shadow and group entries ad prompts whether to change the home directory.

YaST > Security and Users > User and Group Administration > Users
Select the user and then Edit.

There is one downside: some configs f.e. akonadi, contain pointers to /tmp-username-hash, of your username in a path. Bad practice, I know, but I know from experience. The YaST way is by far the best route, a do-it-all-in-one-strike method.

Yes, by far the easiest and best way to do it.