When updating a large table with a file or map whose contents are not greatly different from those of the table, the merge option can spare the server a great many operations. Because the merge option deletes only the entries that are not duplicated in the source (the replace option deletes all entries, indiscriminately), it saves one delete and one add operation for every duplicate entry.
If you are loading information into the tables for the first time, you must have create rights to the table object. If you are overwriting information in the tables, you must have modify rights to the tables.
Syntax
To load information from text files, use:
/usr/lib/nis/nisaddent -f filename table-type\[domain] /usr/lib/nis/nisaddent -f filename \ -t tablename table-type [domain] |
To load information from NIS maps, use:
/usr/lib/nis/nisaddent -y NISdomain table-type\ [domain] /usr/lib/nis/nisaddent -y NISdomain -t tablename table-type [domain] /usr/lib/nis/nisaddent -Y map table-type [domain] /usr/lib/nis/nisaddent -Y map -t tablename table-type [domain] |
To dump information from an NIS+ table to a file, use:
/usr/lib/nis/nisaddent -d [-t tablename tabletype] \ > filename |
Loading Information From a File
You can transfer the contents of a file into an NIS+ table in several different ways:
The -f option with no other option replaces the contents of table-type in the local domain with the contents of filename.
nisaddent -f filename table-type |
With the -a option, -f appends the contents of filename to table-type.
nisaddent -a -f filename table-type |
With the -m option, -f merges the contents of filename into the contents of table-type.
nisaddent -m -f filename table-type |
The following two examples load the contents of a text file named /etc/passwd.xfr into the NIS+ Passwd table. The first is into a table in the local domain, the second into a table in another domain:
rootmaster# /usr/lib/nis/nisaddent -f /etc/passwd.xfr passwd rootmaster# /usr/lib/nis/nisaddent -f /etc/shadow.xfr shadow rootmaster# /usr/lib/nis/nisaddent -f /etc/passwd.xfr passwd sales.doc.com. rootmaster# /usr/lib/nis/nisaddent -f /etc/shadow.xfr shadow sales.doc.com. |
Note - When creating an NIS+ passwd table from /etc files, you must run nisaddent twice; once on the /etc/passwd file and once on the /etc/shadow file.
To merge entries from the /etc/inet/ipnodes file (IPv6 addresses) into the ipnodes.org_dir table, use the -v and -f options.
rootmaster# /usr/lib/nis/nisaddent -m -f /etc/inet/ipnodes ipnodes |
Another way is to use stdin as the source. However, you cannot use the -m option with stdin. You can use redirect (->) or pipe (-|), but you cannot pipe into another domain.
Task | Command |
---|---|
Redirect | cat filename > nisaddent table-type |
Redirect with append option | cat filename > nisaddent -a table-type |
Redirect with append into another domain | cat filename > nisaddent -a table-type NIS+ domain |
Pipe | cat filename | nisaddent table-type |
Pipe with append option | cat filename | nisaddent -a table-type |
If the NIS+ table is an automounter table or a nonstandard table, add the -t option and the complete name of the NIS+ table.
master# nisaddent -f /etc/auto_home.xfr \ -t auto_home.org_dir.doc.com.key-value master# nisaddent -f /etc/auto_home.xfr \ -t auto_home.org_dir.doc.com. key-value sales.doc.com. |
Loading Data From an NIS Map
You can transfer information from an NIS map in two different ways; either by specifying the NIS domain or by specifying the actual NIS map. If you specify the domain, NIS+ will figure out which map file in /var/yp/nisdomain to use as the source, based on the table-type. Note that /var/yp/nisdomain must be local files.
NIS+ Table Type | NIS Map Name |
---|---|
Hosts | hosts.byaddr |
Nodes | ipnodes.byaddr |
Passwd | passwd.byname |
Group | group.byaddr |
Ethers | ethers.byname |
Netmasks | netmasks.byaddr |
Networks | networks.byname |
Protocols | protocols.byname |
RPC | rpc.bynumber |
Services | services.byname |
To transfer by specifying the NIS domain, use the -y (lowercase) option and provide the NIS domain in addition to the NIS+ table type.
Table replacement
nisaddent -y nisdomain table-type |
Table append
nisaddent -a -y nisdomain table-type |
Table merge
nisaddent -m -y nisdomain table-type |
By default, nisaddent replaces the contents of the NIS+ table with the contents of the NIS map. Use the -a and -m options to append or merge. Here is an example that loads the NIS+ passwd table from its corresponding NIS map (passwd.byname) in the old-doc domain:
rootmaster# /usr/lib/nis/nisaddent -y old-doc passwd |
This example does the same thing, but for the sales.doc.com. domain instead of the local domain, doc.com.
rootmaster# /usr/lib/nis/nisaddent -y old-doc passwd sales.doc.com. |
If the NIS+ table is an automounter table or a nonstandard table, add the -t option and the complete name of the NIS table, just as you would if the source were a file.
rootmaster# nisaddent -y old-doc \ -t auto_home.org_dir.doc.com. key-value rootmaster# nisaddent -y old-doc \ -t auto_home.org_dir.doc.com. key-value sales.doc.com. |
If instead of using the map files for a domain, you prefer to specify a particular NIS map, use the -Y (uppercase) option and specify the map name.
rootmaster# nisaddent -Y hosts.byname hosts rootmaster# nisaddent -Y hosts.byname hosts sales.doc.com. |
If the NIS map is an automounter map or a non standard map, combine the -Y option with the -t option:
rootmaster# nisaddent -Y auto_home -t auto_home.org_dir.doc.com. key-value rootmaster# nisaddent -Y auto_home -t auto_home.org_dir.doc.com. key-value sales.doc.com. |
Dumping the Contents of an NIS+ Table to a File
To dump the contents of an NIS+ table into a file, use the - d and -t options. The -d options tells the command to dump, and the -t option specifies the NIS+ table:
rootmaster# nisaddent -d auto_home -t auto_home.org_dir.doc.com. key-value rootmaster# nisaddent -d auto_home -t auto_home.org_dir.doc.com. key-value sales.doc.com. |