Search code examples
linuxuser-accounts

user_id and group_id always starts from a unique value


When i used useradd command in linux, the user_id and group_id for the account is automatically chosen as 500. Now if i delete the account and create it again, then also the user_id and group_id is 500. From where is this default value chosen ?

I used this command :

$ useradd ping
password:

and then looked into the following file

$ cat /etc/group /etc/passwd 

root::0:root
tty::5:
disk:x:100:
floppy:x:101:
uucp:x:102:
utmp:x:103:
lp:x:104:
kmem:x:105:
vcsa:x:106:
sshd:x:74:
ping:x:500:

root:x:0:0:root:/root:/bin/bash
nobody:x:99:99:Nobody:/:/sbin/nologin
vcsa:x:106:106:vcsa privsep:/var/empty:/sbin/false
sshd:x:74:74:sshd privsep:/var/empty:/sbin/false
ping:x:500:500::/home/ping:/bin/bash

Solution

  • The defaults are dependent upon the linux distribution you're running.

    My debian box has UID_MIN 1000 set in the /etc/login.defs file.

    If your goal is to use a different UID, then you need to use the -u | --uid option for useradd.