Tuesday Tiny Techie Tip

ypcat(1)

ypcat is a tool for examining a Network Information Service (NIS) database (called a map). You can see what maps are available for examination with the "-x" option:
% ypcat -x
Use "passwd" for map "passwd.byname"
Use "group" for map "group.byname"
Use "networks" for map "networks.byaddr"
Use "hosts" for map "hosts.byaddr"
Use "protocols" for map "protocols.bynumber"
Use "services" for map "services.byname"
Use "aliases" for map "mail.aliases"
Use "ethers" for map "ethers.byname"

The most useful and interesting ones are aliases, group, hosts, and passwd. The format returned by ypcat is the same as the files by the same names found in /etc. See the man pages in section 5 of the manual for detailed descriptions of the formats (e.g., passwd(5) "man 5 passwd")
aliases
The most useful of the NIS maps, aliases, contains our local email aliases. Since the alias name itself isn't part of the data, you need to include the "-k" flag so that ypcat will report the key as well as the value:
% ypcat -k aliases | grep sw_all
sw_all all_sw
% ypcat -k aliases | grep all_sw
all_r&d mci-here,all_hw,qualeng,id,all_sw,allsys,transducers,adv_dev,program
all_q5000 all_sw,all_hw,researchers,marketing,program,systems,probes,adv_dev,ultra,pcb,engser,transducers,cadmec,id,frontend,qualeng
sw_all all_sw
se all_sw,diag
all_sw sw_staff,sw_sde
all-sw all_sw

As you can see, the values of the aliases are multiple levels deep, so you may have to look up several values to figure out all the people who would get email if you sent to "se" (se expands to all_sw and diag, all_sw expands to sw_staff and sw_sde, sw_staff expands to sw_mgr and sw_pmr, etc...)

group
The group map shows which users are associated with which UNIX groups. However, the map does not contain the whole story since each user's principal group is noted not in the group map, but in the passwd map as the 4th field. (Actually, a user's principal group can be listed in the group database, but usually isn't)
% ypcat group | grep jeffy
se:*:30:bob,mary,mark,chuck,jeffy,fred,harry,homer,lena
pubsrc:*:161:jeffy,jrand,lgur
web:*:270:webmaster,jeffy,peteg,sally
dicom:*:315:ram,jeffy,david
shareadm:*:136:sysad,pcadmin,bill,share,root,jeffy
vxsrc:*:105:charlie,chuck,jeffy,steve,sam,vobadm,rick,lee

hosts
The hosts database is a list of all of the host names registered in our network. The ip address is stored along with the hostname and (sometimes) a (usually out of date) comment. This is a backdoor way of getting the ip address of a given host. The preferred way is to use nslookup(8)
% ypcat hosts | grep hugo
163.242.144.176	centauri  # (SW) SS2 Bob Jones old hugo
163.242.144.25	hugo      # SS1 Jeff Youngstrom

You can see what I mean about the comments in that Bob Jones hasn't worked here in a long long time, and hugo is actually a sparc 10, not a sparc 1.

passwd
There are over 1000 records in our passwd database, so be sure to limit the output somehow.
% ypcat passwd | grep jeffy
jeffy:*:1143:30:Jeff Youngstrom:/home/jeffy:/bin/csh


Tuesday Tiny Techie Tip -- 1 April 1997
Forward to (04/08/97)
Back to (03/25/97)
Written by Jeff Youngstrom

Up to the TTTT index

Tuesday Tiny Techie Tips are all © Copyright 1996-1997 by Jeff Youngstrom. Please ask permission before reproducing any of this material.