2
The command getent
should work in this case.
getent passwd <usuario>
The command getent
displays database entries supported by Service Switch, which are configured in the file /etc/nsswitch.conf
.
Another alternative that may work in this case is to check whether the ID user is valid through the command id
, using with the option -u
:
if id -u "usuario" > /dev/null 2>&1; then
echo "Utilizador existe"
else
echo "O utilizador especificado não existe"
fi
I ended up solving the problem with the command
id
which already seems to be compatible with multiple user management systems.– Zuul