“Like every information service or lookup protocol, NIS has an array of commands. These commands help with setup or configuration and accomplish a variety of actions. Thus, it is crucial to master the commands for efficient and effective use of the NIS information lookup framework.
This article provides you with information on the basic Linux NIS commands. And besides giving a brief explanation, we will also provide you with a synopsis of each of them and examples where possible.”
Common Linux NIS Commands
The following are some of the common Linux NIS commands that you should know;
yppasswd Command
The Linux NIS yppasswd command comes in handy in changing or installing your network password. It will automatically associate this password with the UserName parameter specified for the network. Notably, you can only alter or create a password using this command if you are the password owner.
Ideally, your NIS password can be different from your machine’s password. Again, while root users on NIS servers have the privilege to use this utility, root users on NIS clients lack this privilege.
The synopsis for this command is;
The synopsis above has two notable flags, and their significance are as follows;
- -f [Name]– Changes the gecos information (often stored in /etc/passwd file) for the User Name in the NIS maps.
- -s [ Name [ ShellProg ]]– Changes the login shell for the Name in the NIS maps
An example of how you can change the user’s NIS password is in the below command;
The above command will help you modify the NIS password for your system user named Ken. It will prompt you to enter your old password. Once done, you must enter a new password and confirm your update.
ypinit Command
This command sets NIS maps on your NIS master server or slave/worker server. The tool is only useable by users with root user authority. Moreover, it uses the ASCII files as input files by default.
The syntax entries for the command are;
The first syntax command line sets up NIS maps on NIS master servers, while the second command line sets up NIS maps on worker servers. Overall, the flags for this command, as shown in the syntax, are as follows;
- -o- Permits overwriting of current maps for the NIS domain in use
- -n- The ypnit command will not stop even when it finds errors.
- -q- This flag indicates that the command will get arguments rather than a prompt for input.
- -m [WorkerName…]- This indicates that your local host should be your NIS master server. The –m flag often precedes the names of the machines holding the worker servers whenever the –q flag is used.
- -s MasterName- The flag will copy NIS maps from any server workstations you specify. Of course, these can only happen in the MasterName parameter.
Notable ypinit command examples include;
Using ypinit to set up a master server that will function as the masters for all maps in your NIS system is illustrated below. The command invokes the make procedure, which will follow the instructions in your /var/yp/Makefilefile.
Using ypinit to set up a master server. You will not get an input prompt if you use this command;
Using ypinit to set up a NIS worker server. This command will copy NIS maps from your server to your workstation and, in the process, make your workstation a worker server. For this illustration, we will use linhint as our server.
ypset Command
this NIS command will direct a particular machine to a specified server. It works by directing the ypbind daemon in your client to the ypserv daemon on your server. You will have to select the server to which your ypbind daemon will go to obtain the necessary services from the ypserv daemon.
Its syntax is as follows;
The ypset command has the following flags;
- -V1- Comes in handy in binding the specified server to match the version 1 (old) NIS protocol.
- -d Domain- Used for specifying the domain
- -h Host- Used for setting the binding for the daemon on your specified host and not the local host. You can specify the host using a name or using an IP address.
The below example illustrates how you can use the ypset command to set a server for intended binding on a host within a given domain;
ypxfr Command
Another interesting Linux NIS command is the ypxfr command. It comes in handy in transferring NIS maps from servers to local hosts. It does this by creating a temporary map in the /var/yp/Domain, fetching the map entries from your server before filling the entries in the specified map on the server. It will then load your map parameters, delete the old map version, and finally move the temporary map to the designated map name.
The example below illustrates how you can use the ypxfr command to move a map from a host machine to a different domain;
ypwhich Command
This Linux NIS command identifies the server supplying the NIS services and the server, which acts as the master server for a given map. Of course, this will depend on how you invoke the ypwhich command. It will display the server’s Name for a given local machine if invoked without argument.
The following examples will help you understand the command;
Using ypwhich to find the server that serves your system clients who still run old the version NIS protocol;
Using the ypwhich command to find the map with the name passwd. This command does not find the map nicknamed passwd. The command will display the server bane for the map with the name passwd.
Using the ypwhich command to find the master server for any given map. The below command will display the server name of the passwd map.
yppoll Command
The purpose of the yppoll command is to help display the ID number of the NIS map being used on the NIS server. It uses the ypserv daemon to display the order numbers of maps you may specify in the MapName parameter. Order numbers for maps are their ID numbers. This command can run on NIS systems with version 1 (old) and version 2 (new) protocols.
The command has the following syntax;
Notable examples include;
Using yppoll to search a map on a specified domain. The command will display the ID number for the hosts.byname map from the kenhint domain.
Use the yppoll command to search for a map in a given host. The command will display the order number for netgroups.byuser map located the lhint host.
Conclusion
The commands discussed above are some of the most popular Linux NIS commands you can interact with daily. Mastering their use will make your system administration work easier and faultless.