≡ Menu

Shell Scripting: Read entries from administrative database

While scripting it is necessary to gather entries from administrative database such as passwd, group files or services, protocols or networks etc. Traditionally grep is choice of all UNIX administrators but recently I found GNU getent command. The command is quick, saves time:

The getent program gathers entries from the specified administrative database using the specified search keys. For example:

$ getent passwd vivek
$ getnet group admins
$ getent protocols vrrp
$ getent services www

Overall, it supports following databases:

  • ahosts
  • ahostsv4
  • ahostsv6
  • aliases
  • ethers
  • group
  • hosts
  • netgroup
  • networks
  • passwd
  • protocols
  • rpc services
  • shadow
Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 1 comment… add one }

Leave a Comment