There is only one user on my system. How can I change its user ID from the default of 1000?
If there are additional steps that would be required in order to avoid breaking the login process on a typical desktop installation, those should be included as part of the answer.
You can change it in
/etc/passwd
,/etc/group
and/etc/shadow
or you use one of the preferred possibilties above. But - most important - you have to change the ownership of all files belonging to the user.For instance, if the old user id is 1000 and the new one is 5000:
And the same for the group id (if you change it as well).
The problem is that, like you mentioned, you cannot change your user's UID when it is logged in a session. You have to use another user account to proceed.
But you don't have to create a new user account, promote it to admin, log out, log in to the new admin account, change your primary account's UID, log out, log in to your primary account then delete the new admin user just change your UID. ;)
You can boot into recovery mode (it's an option that appears when you start up your computer, or hold shift right after the BIOS messages complete; Use ESC on Dell machines running OEM-Ubuntu). This will log you in a root session. Being logged in root and not your usual user account, you will be able to modify your UID.
Because the recovery mode only works in command line interface, once logged into a root session, you will have to:
Use BubbaJ's instructions to remount the root file system in read-write mode:
mount -o remount,rw /
.Use Luis Alvarado's command:
usermod -u NEW_UID your_username
.reboot
), so you can boot in normal mode.Complete solution based on @AlexandreP. and @ddeimeke + official documentation. No reboot necessary.
The Debian/Ubuntu policy is that if there is a user
jim
with user ID1001
, there is also a groupjim
with group ID1001
. This solution also updates those group IDs.Enable the root account:
Log in as root and run this with the user name and old/new UID supplied:
$username
Disable the root account:
If you go to console and type:
usermod --help
you will get one of the parameters saying:-u, --uid UID new UID for the user account
so if you want to change the UID for user cyrex then do:
usermod -u 1000 cyrex
that would change the uid for cyrex from whatever value it had before to 1000
If you want to do it visually then do this:
Go to
Select yourself from the list and click on ADVANCED SETTINGS
UID is at the end of that window.
With KDE: In the Change Advanced User Settings Menu:
Changing from another user does not work for 1000 which is the default user.
you have to do that manually - my experience
First you need to login as root, at least for a while, so let us make this possible:
Reboot, ctrl + alt + f1 to switch to the console, login as root, do the following (ownership in home dir will be taken care of automatically):
For your files in places other than your home dir, to this:
Delete and lock the passwd of root, if you want. (I tend to keep it):
I followed ddeimeke's instructions with the following changes:
sudo su
/etc/shadow
I have seen it mentioned in the other answers that you should either boot to recovery or login as
root
. Mine was a fresh Ubuntu 14 install so I was willing to test whether it would work without logging in asroot
. Also I was doing this on an EC2 instance over SSH.This is summed up, what at least since Ubuntu 20.04 is needed (for keeping to be able using Automounting, the change in Extended ACL permissions is needed):
I wanted to change a user id and group id for example from default (uid=) 1000 (and gid=1000) to (uid=) 5000 (and gid=5000), so access to mobile drives formatted with ext4 or similar capable systems with uid & gid) are no problem, if the files and archives have the same user id or group id 5000, no matter if another computer or operating system writes data to this (this enables sharing files easily between computers if all the own users have the same uid and gid).
First I created an additional user, logged as new user, changed in terminal with
sudo su -
to the root and then I used the commandsfor changing user id and
for changing group ID. (Take care: This changes the rights on all mounted devices. If not wanted, unmount all not desired or narrow the commands in the part
find /
tofind /home/<user>
or else.)In Fedora this worked but not in Ubuntu totally. For example Automounting did not work. Then I read one has to fix also the extended ACL permissions, otherwise things like Automounting breaks (perhaps problem because of ACL permissions do not appear if no user had this UID & GID already but in my case this was the problem). The change of the Extended ACL permissions seems to be required since Ubuntu 14.04 and 14.10.
These are the commands which gave the possibility of Automounting back again:
, which sets UID permissions to the own folder in 'media' and
, which deletes permissions to the own user folder for the old UID (yes, this command is not needed for getting Automounting work again, but it ensures another user with the old UID has not access to the media, too).
BTW: A user says, usermod already changes all permissions in home folder since Ubuntu 18.04, but for Automounting at least until Ubuntu 20.04.4 this seems not to be enough yet.
source of information from where I got it and practically tested it since about a month: Answers contain all I explain but a bit chaotically and only one advices to fix the Extended ACL permissions for keeping to be able of Automounting.
PS: If someone asks why I did not post this as a question with the solution, the I have to say, I do not have enough "karma" in this sites for doing this. So please vote this answer up.