What are the famous UIDs?

According to the useradd manpage, UIDs below 1000 are usually reserved for system accounts.

I am developing a service that will work as its own user. I know that well-known ports can be found in /etc/services .

Is there a place where I can find out what famous UIDs are? I would like to avoid crashes with a different UID.

+4
source share
4 answers

getpwent(3) through the password database (usually /etc/passwd , but not necessary, for example, the system can be in the NIS domain). Any UID known to the system must be represented there.

To demonstrate, the following shell fragment and C code must both print all known UIDs on the system.

  $ getent passwd |  cut -d: -f3
 #include <pwd.h> #include <stdio.h> int main() { struct passwd *pw; while ((pw = getpwent())) printf("%d\n", pw->pw_uid); } 

UID 0 is always root and usually UID 65534 is nobody , but you should not count on it, and nothing else. The UIDs used depend on the OS, distribution, and even the system — for example, many Gentoo system services allocate UIDs as they are installed. The central UID database is not used.

In addition, /etc/login.defs defines what the "system UID" is. On my desktop, it is configured so that UIDs 100-999 are treated as system accounts, and UIDS 1000-60000 are user accounts, but this is easy to change.

If you are writing a service, I would suggest that the installation of the package should be written to accommodate the UID as needed, and that your software can be configured to use any UID / username.

+7
source

I know this is an old post, but since I'm here in 2017 still trying to answer a similar question, I thought this additional information was important for someone else in the same position.

The concept of "well-known UIDs" dates back to the early days of unix, before many distributions and unix variants appeared. The "well-known" UIDs were considered as those for system users such as adm, daemon, lp, sync, operator, news, mail, etc., and were standard for all different systems to avoid collisions with uid. These users are still present on modern UNIX-like operating systems.

Standardizing uid in an organization is the key to preventing these problems. As noted above, these days, any uid you choose is likely to be used "somewhere", so it’s best to use a system administrator to ensure that the uid is standard on all the systems they support, and then highlighting the new uid for the application becomes simple.

To this end, over the years I have found the link below, invaluable, and, unfortunately, there are not many similar posts on this topic, and it’s hard to find.

UNIX / Linux: User / Group Conflict Analysis UID / GID

If you are viewing this blog under the "uid" tag, there are other relevant posts, including a script, to automate the uid standardization process for multiple Linux hosts.

This User ID Definition is also an invaluable resource.

The short answer is that it really doesn't matter which uid you use if they are unique and standardized in your organization to avoid collisions.

+4
source

I am not sure that such a list exists. How easy is it to note that the UID is used with the / etc / passwd file , the / etc / shadow file , and the global NIS user list, noting which ones are used? Then use one that is not!

0
source

On Linux, which is configured in /etc/login.defs . Sometimes, when I install a system based on Debian, I change the "uid start" parameter (I forgot its name, I'm not on Linux now) from 1000 to 500 for consistency with other Red Hat-y machines.

man login.defs should provide you with all the necessary information.

0
source

Source: https://habr.com/ru/post/1286423/


All Articles