Friday, February 09, 2007

Replace Contents of a NIS+ Table

If you want to make a change to a NIS+ table, dump the table to a file. Then you can make changes to the file by using your favorite text editor (emacs, vi, nedit, etc). Personally, I like using the ubiquitous vi.

Here is an example (you can use relative or absolute path for dumping and replacement).
# cd /var/nis/backup (for relative path)

If C shell
# setenv PATH $PATH:/usr/lib/nis

If Bourne or Korn Shell
# PATH=$PATH:/usr/lib/nis; export PATH

Dump the NIS+ table to file
# nisaddent -d hosts > /var/nis/backup/hosts

Edit the file
# vi hosts
... myaddedhost
:wq! (saves and quits vi)

Replace and populate the contents of hosts to the NIS+ hosts table.
# nisaddent -rv -f /var/nis/backup/hosts hosts

Here is another example
# nisaddent -d passwd > /var/nis/backup/passwd
# vi /var/nis/backup/passwd
# nisaddent -rv -f /var/nis/backup/passwd passwd

No comments: