Tuesday Tiny Techie Tip
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"
% 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")
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
% ypcat -k aliases | grep 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...)
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
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
% ypcat hosts | grep hugo
18.104.22.168 centauri # (SW) SS2 Bob Jones old hugo
22.214.171.124 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.
There are over 1000 records in our passwd database, so be
sure to limit the output somehow.
% ypcat passwd | grep jeffy
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.