知乎專欄 | 多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者” |
目錄
支持資料庫
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