Confirm command to change user nme

I have an Acer Aspire 3 laptop model A315-21-38HE which had the Endless operating system already installed in it when I bought it in January 2018. After opening it for the first time I followed the instructions to create my user. Rather than allow me to pick the name of my home directory the Endless software chose one for me – my first name ‘kenneth’.

That name was fine at the beginning. Now however I want to synchronize this laptop with a desk­top parts of which date from December 2013. The laptop operating system is now Debian Buster. Since then the name of my home directory on the desktop has always been ‘ken’. Now, in the interests of synchronization I want to change my user name in the laptop from ‘kenneth’ to ‘ken’.

I have three questions:

Will the command ‘sudo usermod -d ken -l ken -m kenneth’ do what I want done: change my user name to ‘ken’; create home directory ‘ken’ and transfer everything from the old home directory ‘kenneth’ to the new one ‘ken’?

Is my understanding correct that this command will change nothing else, including my uid number, the groups I belongs to, and my password?

As my user – now renamed to ‘ken’ – was the first user created on the laptop in 2018, and is still the only user, will ‘ken’ still be the system administrator and consequently able to open the ‘root’ user with the command ‘sudo i’?

[x-special/nautilus-clipboard copy file:///root/eos-diagnostic-201106_120515_UTC+0700.txt](x-special/nautilus-clipboard copy file:///root/eos-diagnostic-201106_120515_UTC+0700.txt)

Hello and welcome, @kenswimmer

Since you need to be logged out in order to perform the username and homedir changing,
you may want to create a new account, from the Settings app > Users > (Unlock) > Add User > (with Administrator type)

Then log in with that admin-user,

Change the username,

$ sudo usermod kenneth --login ken

Migrate user’s home directory,

$ sudo usermod --home /home/ken --move-home ken

These commands will do the work.

I followed your instructions to the extent I understood them. I created a new account called simply ‘ken’ when I opened it the terminal bang was ken@endless$. Running sudo -i in the terminal produced the root bang, root@endless#.
Running the command ‘sudo usermod kenneth – login ken’ returned a message to the effect that ‘ken’ already exists.
The last command, 'sudo usermod --home /home/ken – move-home ken returned the following: ‘user ken is currently used by process 5001’.
My files were not moved to /home/ken; they are still in /home/kenneth.
So what do I do now?
Ken

Hi Ken,

The temporary account should not be the same username that you want to change to.

As it looks like this now:

  • old account: kenneth
  • newly created temporary account: ken

My original idea would be,

  1. Login to kenneth
  2. Create a temp-admin account (with Admin permission)
  3. Logout kenneth
  4. Login temp-admin
  5. Run usermod commands

Now, not to further complicate the situation,

  1. Login to kenneth
  2. Delete account ken
  3. Create a temp-admin account
  4. Logout kenneth
  5. Login temp-admin
  6. Run usermod commands

Please let us know how this works for you.


A note(also to myself) on why we need to go through this hassle on command line,
Username and home directory are two different “values” store in /etc/passwd
We can easily change Username from the system Settings app > Users, but unfortuenly it won’t change the home directory.
Also, when you are logged in, the user will occupied the home directory, therefore migrating user home directory must be performed by other user on the same machine.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.