Find a user or group entry
$ getent passwd rene
rene:x:1000:1000:,,,:/home/rene:/bin/bash
The previous command returned the entire line of the /etc/passwd
database.
In order to get a specific field, for example the
home directory which is the sixth, the output of
getent
can be piped into
cut
:
$ getent passwd rene | cut -d: -f6
/home/rene
Similary, an entry in
/etc/group
can be found like so
getent group sudo
Apparently, this also works with pam/nss and user/groups that are not in the standard /etc/passwd
and /etc/group
files.