知乎专栏 |
支持数据库
ahosts ahostsv4 ahostsv6 aliases ethers group gshadow hosts initgroups netgroup networks passwd protocols rpc services shadow
查找主机名
[root@localhost ~]# getent hosts localhost ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 [root@localhost ~]# getent hosts localhost.localdomain ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
查看用户
[root@localhost ~]# getent passwd halt halt:x:7:0:halt:/sbin:/sbin/halt [root@localhost ~]# getent passwd `whoami` root:x:0:0:root:/root:/bin/bash
通过UID查看用户信息
[root@localhost ~]# getent passwd 65534 nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
判定用户组test是否存在:如果存在就退出,不存在就创建
[root@localhost ~]# getent group test || groupadd test [root@localhost ~]# getent group zabbix > /dev/null || groupadd -r zabbix [root@localhost ~]# getent passwd zabbix > /dev/null || useradd -r -g zabbix -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
[root@localhost ~]# getent services 22 ssh 22/tcp [root@localhost ~]# getent services 80 http 80/tcp www www-http [root@localhost ~]# getent services 443 https 443/tcp