Skip to content

Changing the Crostini Username

ChromeOS currently prompts the user for their desired username when setting up your initial Linux container (penguin); however, the setup tool does not prompt users to set their username when setting up additional containers. Instead, ChromeOS uses the prefix of the primary email address used to sign in to your device. It is possible to change your username via the ChromeOS Shell (not the Linux Terminal).

Perform a backup of your Linux Container before proceeding

Following the steps in this guide should be considered a high-risk change and we strongly advise that you perform a backup of the impacted container before proceeding.

This is best done on a freshly setup container instead of a container that has been used for some time. It is still possible, but the data migration is still possible.

Launch the ChromeOS Shell (CroSH) and run the following to gain access to the Termina virtual machine.

vmc start termina
If you do not know the names of your active containers, run the following command in the ChromeOS Shell (CroSH).

lxc list

You will see the following output

(termina) chronos@localhost ~ $ lxc list
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
|  NAME   |  STATE  |         IPV4          |                     IPV6                      |   TYPE    | SNAPSHOTS |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| guide   | RUNNING | 100.115.92.202 (eth0) | fde5:a35a:1372:9e1b:216:3eff:fed1:b22f (eth0) | CONTAINER | 0         |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+
| penguin | RUNNING | 172.17.0.1 (docker0)  | fde5:a35a:1372:9e1b:216:3eff:fe8b:1404 (eth0) | CONTAINER | 0         |
|         |         | 100.115.92.197 (eth0) |                                               |           |           |
+---------+---------+-----------------------+-----------------------------------------------+-----------+-----------+

You will need to ensure the state of the target container is "RUNNING" if not, you can start it with the following command (Replace "ContainerName" with the name of the container.

lxc start ContainerName

Placeholder Use

In this tutorial, we will be using the name "guide" as the container name and "olduser", "newuser" respectively as a placeholder for the old and new.

Next, we will enter the container that we wish to change the username on by running the following on the ChromeOS Shell (CroSH)

lxc exec guide /bin/bash

We will need to kill all processes that were being used by the old user account.

killall --user olduser
loginctl disable-linger olduser

Next we will change the ownership of all files owned by the old user as well as the Group ID. This is important because when a container is launched from the ChromeOS terminal, it selects the user with the id of 1000. This ID is also important as this is how ChromeOS selects the home directory to mount in the ChromeOS file manager.

usermod -u 1002 olduser
groupmod -g 1002 olduser

find / -group 1000 -exec chgrp -h olduser {} \;
find / -user 1000 -exec chown -h olduser {} \;

Next, we will need to add the new user account and set the userid and group

adduser --uid 1000 newuser

Finally we will need to add the user to the linger service by running the following

loginctl enable-linger newuser

Finally restart your container for this change to take effect.

If you wish to access any files owned by the old user, you should run the following in a terminal

sudo chown newuser:newuser -R /home/olduser/
mkdir ~/olduser
mv /home/olduser /home/newuser/olduser