Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change userland to my own username and group name. #2062

Open
khenty opened this issue Oct 19, 2024 · 1 comment
Open

Change userland to my own username and group name. #2062

khenty opened this issue Oct 19, 2024 · 1 comment

Comments

@khenty
Copy link

khenty commented Oct 19, 2024

How to use this template:
Any line that begins with '#' is a header. Please leave the headers in as is, and fill in the information they suggest
below them. These templates are here to help us resolve your issue as quickly as possible. Leaving requested information out
of your issue will cause our issue template bot to request that your post be reformatted. If a header doesn't seem relevant
to your issue, either write 'N/A' or something similar below the header or consider using a different template.

Describe the issue you are having.

This started when I tried to add my username with the command "sudo adduser my_username". Although I could add a user, I couldn't start a Debian Desktop session where I logged in with that username. So then I hit on changing the userland username and group name to my own username and group name. I ran "sudo usermod -l my_username" followed by "sudo groupmod -n my_group". After that, "echo $USER" and "echo $GROUP" produced "my_username" and "my_group". The new username and group appeared correct in /etc/passwd and /etc/group, respectively. My home directory was still /home/userland, but when I checked the ownership of the home directory, it showed that the directory was owned by my_username and my_group.

Everything looked okay until I exited UserLAnd. When I restarted UserLAnd and attempt to restart the Debian session, it hung with a circling session start icon and never let me start up the desktop. So then I reinstalled Debian and repeated the above process, but this time I renamed the home directory to /home/my_username and made sure the directory was correct in /etc/passwd. Again I exited and again I attempted to restart Debian. Again the session hung.

Describe how your task behaves in a regular Linux environment

I am running xfce 4.16 on Debian 11 (bullseye) and UserLAnd 24.04.04 on the latest update of Android 14. I am on a Lenovo P12 Pro Tablet with keyboard pack. If I do not change the username or group name, the Debian Desktop starts up normally.

@MNLierman
Copy link

MNLierman commented Nov 2, 2024

If you didn't already find your solution, here you are.

You need to change the files in the following locations manually after using the command you specified:

/etc/shadow, /etc/gshadow, /etc/group, /etc/passwd

Quick Warning
Do not rename the root username or the root group name at the top of the files. A lot of core system apps and services use the name root, so I wouldn't risk it. Some may say that this is not the case anymore, I wouldn't risk it, I've found out the hard way with stuff like that.

In /etc/group,
Make sure your username is added to your new group. By default it is not, and this can cause issues if you change your group name. To add it, put your username at the end of your group line. Ie. it should look like: “my_groupname:x:2000:my_username:my_username” your name should be twice because the 4th field is group admins, 5th field is group members. (This could be unnecessary with newer Debian versions, but I'm OCD and like to be sure of things.) You can also put your username at the end of the root group name at the top of you want to bypass sudo.

In regards to your home dir,
This is probably why it's now not booting. After you rename your home dir, you have to change your login location in passwd. If you look, there will be a spot where it says /home/userland, you need to correct that path to whatever you renamed it to. That path will be at the top for root and for userland, change both paths, but again, do not rename root.

Finally,
Any time I edit these files, and I would suggest doing this as well, I personally have made it a habit to check the first number after “my_username:hashNgo3uv8Jsig9Nwief” is not a zero. After your password hash, there is a bunch of numbers like “:1858224:0:7:7:0:1” or whatever it says for you, but the field immediately after the hash, make sure it is not a zero. I say this because in some chroots and older BusyBox images, that first number was mistakenly a zero, and zero for the first number after the hash has a special meaning. That meaning is “password has expired and user must change the password immediately.” If you have a zero there then you likely will not be able to log in because your password has expired. You likely do not have a zero there, but I would double check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants