4

I have run into more problems than I can bother to count by changing my UID. I'm so frustrated that I'm just going to format and start all over again. This time, I want my installation to make the first user use, let's say UID 1200. I don't want to install Ubuntu and then create all the problems by changing my UID. I don't know how to fix all those problems & it's the reason why I'm formatting. I certainly am not going to be ever doing that mistake ever again on Ubuntu. I just want Ubuntu to install using a specific UID. How do I do it?

1 Answer 1

10

Method 1 - If you just want to create a user with a given UID

  1. Install Ubuntu normally
  2. Log into Ubuntu
  3. Open a Terminal
  4. Create a new user with the ID 1200 sudo adduser -u 1200 <username>
  5. Confirm that the user was created with the desired id awk -F: '/\/home/ {printf "%s:%s\n",$1,$3}' /etc/passwd
  6. Add the newly created user to the sudoers group sudo adduser <username> sudo
  7. Logout
  8. Login with the newly created user
  9. (optional) Delete the old user

Method 2 - Automated Ubuntu installation using preseeding

In order to be able to define a UID range at installation time, you need to automate the Ubuntu installation using preseeding, which is basically

a way to to set answers to questions asked during the installation process, without having to manually enter the answers while the installation is running. This makes it possible to fully automate most types of installation and even offers some features not available during normal installations.

Using this method, which is way to extensive to be posted as part of this post, you can (amongst many other things) setup the account which will created at installation time. Example:

# Skip creation of a root account (normal user account will be able to
# use sudo). The default is false; preseed this to true if you want to set
# a root password.
#d-i passwd/root-login boolean false
# Alternatively, to skip creation of a normal user account.
#d-i passwd/make-user boolean false

# Root password, either in clear text
#d-i passwd/root-password password r00tme
#d-i passwd/root-password-again password r00tme
# or encrypted using an MD5 hash.
#d-i passwd/root-password-crypted password [MD5 hash]

# To create a normal user account.
#d-i passwd/user-fullname string Ubuntu User
#d-i passwd/username string ubuntu
# Normal user's password, either in clear text
#d-i passwd/user-password password insecure
#d-i passwd/user-password-again password insecure
# or encrypted using an MD5 hash.
#d-i passwd/user-password-crypted password [MD5 hash]
# Create the first user with the specified UID instead of the default.
#d-i passwd/user-uid string 1010
# The installer will warn about weak passwords. If you are sure you know
# what you're doing and want to override it, uncomment this.
#d-i user-setup/allow-password-weak boolean true

# The user account will be added to some standard initial groups. To
# override that, use this.
#d-i passwd/user-default-groups string audio cdrom video

# Set to true if you want to encrypt the first user's home directory.
d-i user-setup/encrypt-home boolean false

Notice the line:

# Create the first user with the specified UID instead of the default.
d-i passwd/user-uid string 1010

If you want to learn more about automated installations there are several sources of useful information in the Internet. This is the official documentation currently:

https://help.ubuntu.com/lts/installation-guide/armhf/apbs01.html

4
  • 2
    No, it doesn't helps. I'm quoting : ... I want my installation to make the first user use, let's say UID 1200. I don't want to install Ubuntu and then create all the problems by changing my UID.
    – A.B.
    Nov 17, 2015 at 21:04
  • I feel your frustration x) May I ask why would you like to install ubuntu that way? Nov 17, 2015 at 21:06
  • By the way, note I'm not suggesting to change your UID but creating a new user with the desired UID and with sudo privileges. I cant imagine what kind of problems would that cause. Nov 17, 2015 at 21:09
  • 1
    There you go. I edited the answer as 2 different methods, being the second the one you are looking for. I hope it helps NOW ;) Nov 17, 2015 at 21:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .