What is the maximum username length on current GNU/Linux systems

Solution 1:

The current limit is 32 characters (according to useradd man page).

Solution 2:

The answer varies somewhat.

useradd(1) references a limit of 32 characters. This is based AFAIU on libc6.

Some utilities or systems may impose shorter names or behave inconsistently when presented with longer names, including top, ps, w/who, finger, NFS, and various multi-platform directory systems (NIS/NIS+, SMB, CIFS, Kerberos), potentially based on limitations of other/remote platforms. Many of the various psutil commands will display a UID rather than username if the latter exceeds 8 characters.

Some utilities and applications may impose their own arbitrary limitations. E.g.: IBM's DB2 apparently won't allow logins from users with usernames exceeding 8 characters: http://database.ittoolbox.com/groups/technical-functional/db2-l/length-of-username-permitted-on-db2-95-aix-6-3248147

8 characters is a generally sane limit, and saves typing.


Solution 3:

As other answers have explained, longer usernames are possible, but another practical reason to try to limit to 8 chars maximum is that ps(1) reports numeric uids instead of usernames beyond 8 chars.

Tags:

Linux