-bash-3.2$ getent --help
Usage: getent [OPTION...] database [key ...]
Get entries from administrative database.
-s, --service=CONFIG Service configuration to be used
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
Supported databases (支持的数据库):
ahosts ahostsv4 ahostsv6 aliases ethers group hosts netgroup networks
passwd protocols rpc services shadow
Usage: getent [OPTION...] database [key ...]
Get entries from administrative database.
-s, --service=CONFIG Service configuration to be used
-?, --help Give this help list
--usage Give a short usage message
-V, --version Print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.
Supported databases (支持的数据库):
ahosts ahostsv4 ahostsv6 aliases ethers group hosts netgroup networks
passwd protocols rpc services shadow
比如查看某用户是否存在. 假设用户为appUser
if getent passwd appUser > /dev/null 2>&1
then
echo "Yes, the user appUser exists"
else
echo "No, the user appUser does not exist. please create it"
echo "appUser:x:319:250::/home/appUser:/usr/bin/bash" >> /etc/passwd
mkdir -p /home/appUser
chown -R appUser:${appGroup} /home/appUser
fi