Check If A User Exists

We can check if a user exists on Linux System by id command.

id - print real and effective user and group IDs

Example

$ id -u jungle
1000

If a user does not exists on system, it throws an error. For example -

$ id -u unknown
id: ‘unknown’: no such user

Source: StackOverFlow

Last updated