[solved] Change my username on cloned system

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Pepper-Mint-Patty
Level 4
Level 4
Posts: 370
Joined: Fri Dec 20, 2019 4:54 pm

[solved] Change my username on cloned system

Post by Pepper-Mint-Patty »

Not sure how it is called user/ root/ admin name? The one that shows up in terminal with @ in between.
Anyhow this one i want to change on device 2.
I foxcloned the system on device 1 to device 2. This went smoothly! But now i am stuck with 2 same admin names on the 2 devices.
So how can i change the name ( and get rid of the previous) on the new ssd with keeping access to everything as under the cloned name?
Last edited by Pepper-Mint-Patty on Fri Oct 23, 2020 5:17 pm, edited 1 time in total.
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3
User avatar
Reorx
Level 12
Level 12
Posts: 4032
Joined: Tue Jul 07, 2009 7:14 pm
Location: SE Florida, USA

Re: Change my username on cloned system

Post by Reorx »

Why do you want a different admin name? I have 6 laptops with the same admin name. The computer name for each is unique however. My terminal prompt on this machine is reorx@freedom-20. I also have a user named reorx on computers named freedom-19 and freedom-18. The number in the computer's name is the year in which it was purchased... I also have reorx as a user on laptops named freedom-12, freedom-13, and freedom-14 (all still working by the way! :mrgreen: ).
Full time Linux Mint user since 2011 - Currently running mostly LM19C and a little LM20C.

Image Image Image
User avatar
all41
Level 16
Level 16
Posts: 6464
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Change my username on cloned system

Post by all41 »

The terminal will display username@hostname where hostname is the name given to the computer ex:office, laptop, etc.
If you want to change the hostname then in a terminal:
sudo hostnamectl set-hostname *******
Substitute the asterisks with the desired name. Note there is a space
between the asterisks and the rest of the instruction
example:

sudo hostnamectl set-hostname office
Light travels faster than sound. That's why some people appear smart until you hear what they are saying.
You will seldom see a grey-beard wearing a tinfoil hat.
Pepper-Mint-Patty
Level 4
Level 4
Posts: 370
Joined: Fri Dec 20, 2019 4:54 pm

Re: Change my username on cloned system

Post by Pepper-Mint-Patty »

thanx, all41. And how change the username?
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3
User avatar
all41
Level 16
Level 16
Posts: 6464
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Change my username on cloned system

Post by all41 »

As pbear is showing changing the actual username is more involved because of groups
and home ownership.
Much easier to just create a new user using Users and Groups from your menu. Give that new user explicit permissions.
Then copy/paste your current /home directory to the new user. Be sure to include the hidden directories and files
beginning with decimal point.
Light travels faster than sound. That's why some people appear smart until you hear what they are saying.
You will seldom see a grey-beard wearing a tinfoil hat.
Pepper-Mint-Patty
Level 4
Level 4
Posts: 370
Joined: Fri Dec 20, 2019 4:54 pm

Re: Change my username on cloned system

Post by Pepper-Mint-Patty »

all41 wrote:
Sun Oct 11, 2020 1:28 am
Be sure to include the hidden directories and files beginning with decimal point.
How can you ever be sure of that??? :?
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3
User avatar
AndyMH
Level 13
Level 13
Posts: 4759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Change my username on cloned system

Post by AndyMH »

Glad foxclone worked for you :)
I use the same username/pwd on all my PCs = less to forget, and only change the hostname when I clone from one PC to another, e.g. my thinkpad hostnames are T430, T431 and T432.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
Pepper-Mint-Patty
Level 4
Level 4
Posts: 370
Joined: Fri Dec 20, 2019 4:54 pm

Re: Change my username on cloned system

Post by Pepper-Mint-Patty »

Its nice that some people are happy with their equal usernames on different devices.
Can we now get back to the last question? It looks i am almost there... :wink:
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3
User avatar
Reorx
Level 12
Level 12
Posts: 4032
Joined: Tue Jul 07, 2009 7:14 pm
Location: SE Florida, USA

Re: Change my username on cloned system

Post by Reorx »

Pepper-Mint-Patty wrote:
Sun Oct 11, 2020 8:03 am
Its nice that some people are happy with their equal usernames on different devices.
Can we now get back to the last question? It looks i am almost there... :wink:
I have never changed a users name so I am not completely sure it can be done safely and effectively. If I were trying to do this, I would first create another admin user and log in to that user. I would open the admin Users and Groups tool to see if I could find a way to rename the original admin user. If that didn't work, I would create an admin user of the name that you desire. I would then log in to that user and delete the other admin users (if you didn't want extraneous users hanging around). The delete routine will (probably) ask what you would like to do with the files in the specified user's home folder - choose appropriately. If you don't trust the delete routine, copy those files to a USB stick before deleting. Then restore them with the new admin user.
Full time Linux Mint user since 2011 - Currently running mostly LM19C and a little LM20C.

Image Image Image
pbear
Level 15
Level 15
Posts: 5664
Joined: Wed Jun 21, 2017 12:25 pm
Location: San Francisco

Re: Change my username on cloned system

Post by pbear »

Reorx wrote:
Sun Oct 11, 2020 11:33 am
I would open the admin Users and Groups tool to see if I could find a way to rename the original admin user.
FYI, the name you can change in the GUI isn't the system username. For that, you need to go "under the hood," as per the links I gave above.
User avatar
AndyMH
Level 13
Level 13
Posts: 4759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Change my username on cloned system

Post by AndyMH »

Pepper-Mint-Patty wrote:
Sat Oct 10, 2020 8:35 am
I foxcloned the system on device 1 to device 2. This went smoothly! But now i am stuck with 2 same admin names on the 2 devices.
Are you intending to run your system with both drives connected? The reason I ask is that the partitions on both drives will have identical UUIDs which might confuse BIOS on boot. Normally you would be using clone to switch smaller drive for larger drive or HDD to SSD and when done, format and re-purpose the old drive.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
Pepper-Mint-Patty
Level 4
Level 4
Posts: 370
Joined: Fri Dec 20, 2019 4:54 pm

Re: Change my username on cloned system

Post by Pepper-Mint-Patty »

@Reorx, I like this: 'The delete routine will (probably) ask ' :)

@pbear thnx for reminding! somehow i have overseen the link you sent.

@AndyMH The clone is running on a different machine. But it is good to hear whenever i would want to connect the clone to machine-1 i should do it after boot.

I am afraid i should make a bu of all my files first... How risky would the whole procedure be? Scale 1- 10 being 10 the highest risk
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3
User avatar
Reorx
Level 12
Level 12
Posts: 4032
Joined: Tue Jul 07, 2009 7:14 pm
Location: SE Florida, USA

Re: Change my username on cloned system

Post by Reorx »

Pepper-Mint-Patty wrote:
Sun Oct 11, 2020 6:34 pm
@Reorx, I like this: 'The delete routine will (probably) ask ' :)
Well, it did ask the last time I deleted a user... but that was several years and several versions ago... :mrgreen:
pbear wrote:
Sun Oct 11, 2020 12:00 pm
Reorx wrote:
Sun Oct 11, 2020 11:33 am
I would open the admin Users and Groups tool to see if I could find a way to rename the original admin user.
FYI, the name you can change in the GUI isn't the system username. For that, you need to go "under the hood," as per the links I gave above.
Not surprising... thanx pbear!
Full time Linux Mint user since 2011 - Currently running mostly LM19C and a little LM20C.

Image Image Image
hayden
Level 2
Level 2
Posts: 72
Joined: Thu Apr 07, 2011 7:59 am
Location: Texas, USA

Re: Change my username on cloned system

Post by hayden »

Hello, this is how to change your username.

The user I want to change the name of is test2. I want to change to test3. Below shows the test2 home dir.

Code: Select all

erik@ipa:~$ cd /home && ls
erik  jasmine  test2  vicky
Use your favorite editor. I like vim. You can use nano if more comfortable with it.

Code: Select all

erik@ipa:home$ sudo vim /etc/passwd
sudo password for erik: *******
near the bottom of the file you'll find the below line. Change any instance of test2 to test3

Code: Select all

test2:x:1004:1004:test2,,,:/home/test2:/bin/bash
should look like this:

Code: Select all

test3:x:1004:1004:test3,,,:/home/test3:/bin/bash
Then edit group file.

Code: Select all

erik@ipa:home$ sudo vim /etc/group
Find the line that says test2 and change it to test3

Code: Select all

test2:x:1004:
then edit the shadow file and do same as above, find test2 and change to test3.

Code: Select all

erik@ipa:home$ sudo vim /etc/shadow
after that the user and ownship part is done. See below how test2 folder is owned by test3 user and group. Last thing to do is to change the name of the test2 directory

Code: Select all

erik@ipa:home$ ls -la
total 24
drwxr-xr-x  6 root    root    4096 Oct 11 19:43 .
drwxr-xr-x 24 root    root    4096 Jul 20 16:30 ..
drwxr-xr-x 29 erik    erik    4096 Oct 11 19:41 erik
drwxr-xr-x 20 jasmine jasmine 4096 Oct  8 07:40 jasmine
drwxr-xr-x 16 test3   test3   4096 Oct 11 19:43 test2
drwxr-xr-x 17 vicky   vicky   4096 Sep  4 07:11 vicky

Code: Select all

erik@ipa:home$ sudo mv test2 test3
erik@ipa:home$ ls -la
total 24
drwxr-xr-x  6 root    root    4096 Oct 11 20:22 .
drwxr-xr-x 24 root    root    4096 Jul 20 16:30 ..
drwxr-xr-x 29 erik    erik    4096 Oct 11 19:41 erik
drwxr-xr-x 20 jasmine jasmine 4096 Oct  8 07:40 jasmine
drwxr-xr-x 16 test3   test3   4096 Oct 11 19:43 test3
drwxr-xr-x 17 vicky   vicky   4096 Sep  4 07:11 vicky
Done. Now you can log in with the new username.

Let me know if you have any questions.
User avatar
all41
Level 16
Level 16
Posts: 6464
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: Change my username on cloned system

Post by all41 »

hayden wrote:
Sun Oct 11, 2020 9:24 pm
Hello, this is how to change your username.

The user I want to change the name of is test2. I want to change to test3. Below shows the test2 home dir.

Code: Select all

erik@ipa:~$ cd /home && ls
erik  jasmine  test2  vicky
Use your favorite editor. I like vim. You can use nano if more comfortable with it.

Code: Select all

erik@ipa:home$ sudo vim /etc/passwd
sudo password for erik: *******
near the bottom of the file you'll find the below line. Change any instance of test2 to test3

Code: Select all

test2:x:1004:1004:test2,,,:/home/test2:/bin/bash
should look like this:

Code: Select all

test3:x:1004:1004:test3,,,:/home/test3:/bin/bash
Then edit group file.

Code: Select all

erik@ipa:home$ sudo vim /etc/group
Find the line that says test2 and change it to test3

Code: Select all

test2:x:1004:
then edit the shadow file and do same as above, find test2 and change to test3.

Code: Select all

erik@ipa:home$ sudo vim /etc/shadow
after that the user and ownship part is done. See below how test2 folder is owned by test3 user and group. Last thing to do is to change the name of the test2 directory

Code: Select all

erik@ipa:home$ ls -la
total 24
drwxr-xr-x  6 root    root    4096 Oct 11 19:43 .
drwxr-xr-x 24 root    root    4096 Jul 20 16:30 ..
drwxr-xr-x 29 erik    erik    4096 Oct 11 19:41 erik
drwxr-xr-x 20 jasmine jasmine 4096 Oct  8 07:40 jasmine
drwxr-xr-x 16 test3   test3   4096 Oct 11 19:43 test2
drwxr-xr-x 17 vicky   vicky   4096 Sep  4 07:11 vicky

Code: Select all

erik@ipa:home$ sudo mv test2 test3
erik@ipa:home$ ls -la
total 24
drwxr-xr-x  6 root    root    4096 Oct 11 20:22 .
drwxr-xr-x 24 root    root    4096 Jul 20 16:30 ..
drwxr-xr-x 29 erik    erik    4096 Oct 11 19:41 erik
drwxr-xr-x 20 jasmine jasmine 4096 Oct  8 07:40 jasmine
drwxr-xr-x 16 test3   test3   4096 Oct 11 19:43 test3
drwxr-xr-x 17 vicky   vicky   4096 Sep  4 07:11 vicky
Done. Now you can log in with the new username.

Let me know if you have any questions.
@reorx said
I have never changed a users name so I am not completely sure it can be done safely and effectively.
@hayden method seems concise and what I have used from root shell. Confused somewhat regarding the shadow file changes
though. Is the shadow file written at boot?
Light travels faster than sound. That's why some people appear smart until you hear what they are saying.
You will seldom see a grey-beard wearing a tinfoil hat.
User avatar
AndyMH
Level 13
Level 13
Posts: 4759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Change my username on cloned system

Post by AndyMH »

Thanks hayden, that's the most concise method I've seen, no messing around copying files from old user to new user.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
Pepper-Mint-Patty
Level 4
Level 4
Posts: 370
Joined: Fri Dec 20, 2019 4:54 pm

Re: Change my username on cloned system

Post by Pepper-Mint-Patty »

@hayden, appreciate the work. But feel a bit anxious to execute.
I use Xed, quess thats ok?!
all41 seems to have an important question about shadow file?
@AndyMH appreciate you gave your opinion on hayden's work.


Now lets see how to take on... :?

There is only 1 user on that machine. So i first need to make a 2nd user with the intended name.
Last edited by Pepper-Mint-Patty on Mon Oct 12, 2020 7:19 am, edited 1 time in total.
Language is a virus _ . _ . _ . _ . _ . _ . _ . _ . _ . _ 19.2 Cinn + 4.15-91 + Nemo 4.2.3
hayden
Level 2
Level 2
Posts: 72
Joined: Thu Apr 07, 2011 7:59 am
Location: Texas, USA

Re: Change my username on cloned system

Post by hayden »

AndyMH wrote:
Mon Oct 12, 2020 4:03 am
Thanks hayden, that's the most concise method I've seen, no messing around copying files from old user to new user.
You're welcome. I didn't copy any files, though.
hayden
Level 2
Level 2
Posts: 72
Joined: Thu Apr 07, 2011 7:59 am
Location: Texas, USA

Re: Change my username on cloned system

Post by hayden »

Pepper-Mint-Patty wrote:
Mon Oct 12, 2020 6:57 am
@hayden, appreciate the work. But feel a bit anxious to execute.
I use Xed, quess thats ok?!
all41 seems to have an important question about shadow file?
@AndyMH appreciate you gave your opinion on hayden's work.


Now lets see how to take on... :?
Yes you can use Xed if you are more comfortable with a GUI tool.

Something I forgot to mention, you need to do my method as another user (not logged in to the user you want to change the username). or when at the log in sceen, press Ctrl + Alt + F1. This will change to a virtual console where you can log in to a different user that has sudo privileges or just log in as root. To change back to the normal log in screen, you would press Ctr + Alt + F7
Last edited by hayden on Mon Oct 12, 2020 7:33 am, edited 1 time in total.
Post Reply

Return to “Newbie Questions”