Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
19.  Administering NIS+ Tables The nismatch and nisgrep Commands  Previous   Contents   Next 
   
 

About Regular Expressions

Regular expressions are combinations of text and symbols that you can use to search for special configurations of column values. For example, the regular expression `Hello' searches for a value that begins with Hello. When using a regular expression in the command line, be sure to enclose it in quotes, since many of the regular expression symbols have special meaning to the Bourne and C shells. For example:

rootmaster% nisgrep -h greeting='Hello' phrases.doc.com.

The regular expression symbols are summarized in Table 19-7, below.

Table 19-7 Regular Expression Symbols

Symbol

Description

^string

Find a value that begins with string.

string $

Find a value that ends with string.

.

Find a value that has a number characters equal to the number of periods.

[chars]

Find a value that contains any of the characters in the brackets.

*expr

Find a value that has zero or more matches of the expr.

+

Find something that appears one or more times.

?

Find any value.

\'s-char'

Find a special character, such as ? or $.

x | y

Find a character that is either x or y.

Syntax

To search through the first column, use:

nismatch string tablename  
nisgrep reg-exp tablename

To search through a particular column, use:

nismatch column=string tablename
nisgrep column=reg-exp tablename 

To search through multiple columns, use:

nismatch column=string tablename ...\
nismatch [column=string,...],tablename
nisgrep column=reg-exp ... \
   tablename

Table 19-8 nismatch and nisgrep Options

Option

Description

-c

Count. Instead of the entries themselves, displays a count of the entries that matched the search criteria.

-h

Header. Displays a header line above the entries, listing the name of each column.

-M

Master. Displays only the entries of the table stored on the master server. This ensures you get the most up-to-date information and should be used only for debugging.

Searching the First Column

To search for a particular value in the first column of a table, simply enter the first column value and a tablename. In nismatch, the value must be a string. In nisgrep, the value must be a regular expression.

nismatch [-h] string tablename
nisgrep [-h] reg-expression tablename

This example searches through the depts table for all the entries whose first column has a value of R&D:

rootmaster% nismatch -h `R&D' depts.doc.com.
rootmaster% nisgrep -h `R&D' depts.doc.com.

Note - Quotes are used in the 'R&D' expression above to prevent the shell from interpreting the ampersand (&) as a metacharacter.


Searching a Particular Column

To search through a particular column other than the first, use the following syntax:

nismatch column=string tablename
nisgrep column=reg-expression tablename

This example searches through the depts table for all the entries whose second column has a value of SanFran:

rootmaster% nismatch -h Site=SanFran depts.doc.com.
rootmaster% nisgrep -h Site=SanFran depts.doc.com.

Searching Multiple Columns

To search for entries with matches in two or more columns, use the following syntax:

nismatch [-h] [column=string, ... \
 column=string,...],tablename
nisgrep [-h] column=reg-exp ... \
 tablename

This example searches for entries whose second column has a value of SanFran and whose third column has a value of jhill:

rootmaster% nismatch -h [Site=SanFran,Name=jhill], depts.doc.com.
rootmaster% nisgrep -h Site=SanFran Name=jhill depts.doc.com.

The nisln Command

The nisln command creates symbolic links between NIS+ objects such as tables and directories. All NIS+ administration commands accept the -L flag, which directs them to follow links between NIS+ objects.


Note - Do not link table entries. Tables may be linked to other tables, but do not link an entry in one table to an entry in another table.


To create a link to another object (table or directory), you must have modify rights to the source object; that is, the one that will point to the other object or entry.


Caution - Never link a cred table. Each org_dir directory should have its own cred table. Do not use a link to some other org_dir cred table.


Syntax

To create a link, use:

nisln source target

Table 19-9 nisln Options

Option

Description

-L

Follow links. If the source is itself a link, the new link will not be linked to it, but to that link's original source.

-D

Defaults. Specify a different set of defaults for the linked object. Defaults are described in "Specifying Nondefault Security Values at Creation Time".

Creating a Link

To create a link between objects such as tables and directories, specify both object names: first the source, and then the target. Do not link table entries.

nisln source-object target-object

The nissetup Command

The nissetup command expands an existing NIS+ directory object into a domain by creating the org_dir and groups_dir directories, and a full set of NIS+ tables. It does not, however, populate the tables with data. For that, you will need the nisaddent command, described in "The nisaddent Command". Expanding a directory into a domain is part of the process of setting up a domain.


Note - When setting up a new NIS+ domain, the nisserverscript is easier to use than the nissetup command. See"Setting Up NIS+ Root Servers" for a full description of using nisserver.


The nissetup command can expand a directory into a domain that supports NIS clients as well.

To use nissetup, you must have modify rights to the directory under which you'll store the tables.

Expanding a Directory Into an NIS+ Domain

You can use the nissetup command with or without a directory name. If you don't supply the directory name, it uses the default directory. Each object that is added is listed in the output.

rootmaster# /usr/lib/nis/nissetup doc.com.
org_dir.doc.com. created
groups_dir.doc.com. created
auto_master.org_dir.doc.com. created
auto_home.org_dir.doc.com. created
bootparams.org_dir.doc.com. created
cred.org_dir.doc.com. created
ethers.org_dir.doc.com. created
group.org_dir.doc.com. created
hosts.org_dir.doc.com. created
mail_aliases.org_dir.doc.com. created
sendmailvars.org_dir.doc.com. created
netmasks.org_dir.doc.com. created
netgroup.org_dir.doc.com. created
networks.org_dir.doc.com. created
passwd.org_dir.doc.com. created
protocols.org_dir.doc.com. created
rpc.org_dir.doc.com. created
services.org_dir.doc.com. created
timezone.org_dir.doc.com. created

Expanding a Directory Into an NIS-Compatible Domain

To expand a directory into a domain that supports NIS+ and NIS client requests, use the -Y flag. The tables are created with read rights for the nobody class so that NIS clients requests can access them.

rootmaster# /usr/lib/nis/nissetup -Y Test.doc.com.

The nisaddent Command

The nisaddent command loads information from text files or NIS maps into NIS+ tables. It can also dump the contents of NIS+ tables back into text files. If you are populating NIS+ tables for the first time, see the instructions in . It describes all the prerequisites and related tasks.

You can use nisaddent to transfer information from one NIS+ table to another (for example, to the same type of table in another domain), but not directly. First, you need to dump the contents of the table into a file, and then load the file into the other table. Be sure, though, that the information in the file is formatted properly. Chapter 10, NIS+ Tables and Informationdescribes the format required for each table.

When you load information into a table, you can use any of three options: replace, append, or merge. The append option simply adds the source entries to the NIS+ table. With the replace option, NIS+ first deletes all existing entries in the table and then adds the entries from the source. In a large table, this adds a large set of entries into the table's .log file (one set for removing the existing entries, another for adding the new ones), taking up space in /var/nis and making propagation to replicas time consuming.

The merge option produces the same result as the replace option but uses a different process, one that can greatly reduce the number of operations that must be sent to the replicas. With the merge option, NIS+ handles three types of entries differently:

  • Entries that exist only in the source are added to the table

  • Entries that exist in both the source and the table are updated in the table

  • Entries that exist only in the NIS+ table are deleted from the table

 
 
 
  Previous   Contents   Next