What does chown 999 mean?

I know what chmod (change mode) and what chown (change owner) do.

I also understand what the numbers mean after chmod do.

I was going through a docker tutorial and I saw chown 999 being used.

What does it mean and do?

2

3 Answers

who is the user 999? Is it just custom to him or a code used universally?

In Ubuntu and the Ubuntu family flavours, the numeric user ID in live sessions is 999. (The literal user ID is ubuntu, kubuntu, lubuntu ... xubuntu but in all these cases the numeric user ID is 999.)

When you boot from a USB drive, 'Try Ubuntu', you boot into a live session.

You can check with the command

grep 999 /etc/group

and you will find the user if you run a live session. Otherwise you will probably not find anything via that command.

The operating system used for the Docker tutorial is probably an installed system. And there seems to be a user ID with the numeric 999. It is possible to create such a user ID, but in an installed Ubuntu system there is no standard user with that numeric user ID.

As specify in chown man

chown - change file owner and group

This manual page documents the GNU version of chown. chown changes the user and/or group ownership of each given file. If only an owner (a user name or numeric user ID) is given, that user is made the owner of each given file, and the files' group is not changed.

It seems like at the example in the video, the instructor change the owner of the folder to be user-id 999

For example, in my machine, using gdm user-id is 130 and user logstash user-id is 999

gdm:x:130:135:Gnome Display Manager:/var/lib/gdm3:/bin/false

logstash:x:999:999:LogStash Service User:/usr/share/logstash:/usr/sbin/nologin

root# mkdir /tmp/a1
root# ll /tmp/a1
total 44
drwxr-xr-x 2 root root 4096 Jan 15 09:54 ./
drwxrwxrwt 27 root root 36864 Jan 15 09:54 ../
root# chown 130 /tmp/a1
root# ll /tmp/a1
total 44
drwxr-xr-x 2 gdm root 4096 Jan 15 09:54 ./
drwxrwxrwt 27 root root 36864 Jan 15 09:54 ../
# grep 999 /etc/passwd
logstash:x:999:999:LogStash Service User:/usr/share/logstash:/usr/sbin/nologin
root# chown 999 /tmp/a1
root# ll /tmp/a1
total 44
drwxr-xr-x 2 logstash root 4096 Jan 15 09:54 ./
drwxrwxrwt 27 root root 36864 Jan 15 09:54 ../
4

At first, he copies this file into each running mongo container:

The official mongo image (which he uses in the video for creating multiple mongo nodes) has a default user called mongodb and its UID is 999

If you simply run the below command:

docker exec mongo_node_name bash -c "grep 999 /etc/passwd"

you will get the following result: mongodb:x:999:999::/home/mongodb:/bin/sh

So he is giving the the mongodb user the ownership of auth key file.

999 is not special in linux just a created user happens that it has an id of 999

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like