Sun N1 System Manager 1.3 Discovery and Administration Guide

Accessing the N1 System Manager Through the Command Line

You can access the N1 System Manager using the n1sh command. The default method is to use the n1sh shell, which uses an N1–ok> prompt. The shell mode provides a tab completion feature to navigate through all the command options. See the n1sh man page for details. Type man n1sh from a console in the management server. You don't need to be in the n1sh shell to read the n1sh man page.

The n1sh command provides two other ways to issue management commands. The n1sh -e option, or UNIX® command mode, enables you to type management commands one at a time within a UNIX shell. The n1sh -f option enables you to specify a custom script of management commands to run. See the n1sh man page for details. Type man n1sh from a console in the management server. You don't need to be in the n1sh shell to read the n1sh man page.

For information about command line syntax, keywords, special characters, and general syntax, see Command Line Interface Tips in Sun N1 System Manager 1.3 Command Line Reference Manual.

ProcedureTo Access the N1 System Manager Command Line

The following procedure describes how to access the N1 System Manager command line (the n1sh shell) as a valid user from a remote system. You can also access the command line directly on the management server.

Before You Begin

During management server configuration, the superuser (root) account is set up with all the system default roles added to it (Admin, ReadOnly, and SecurityAdmin). If you want to log in as a valid user other than the superuser account, see To Add an N1 System Manager User.

Steps
  1. Log in to the management server from a remote system.


    $ ssh -l user-name management-server
    

    Where user-name is a valid N1 System Manager user, and management-server is the host name or IP address of the management server.

    You are prompted for a password.

  2. Type a password for the user account.

    The N1–ok> prompt is displayed and you are logged in with your default N1 System Manager role, unless you use the -r option to specify a role for login.

  3. If the N1–ok> prompt does not display, type the following command to access the command line:


    # /opt/sun/n1gc/bin/n1sh [-r role-name]

    The superuser (root) user account typically does not have its login configured to automatically log in to the n1sh shell.

  4. (Optional) To switch to a different N1 System Manager role that has been added to your user account, type the following command:


    N1-ok> set session role role
    

    See set session in Sun N1 System Manager 1.3 Command Line Reference Manual for details.

ProcedureTo Show Your Current Session Role

Your role might affect your ability to access certain features of the N1 System Manager. By default, you are logged into the N1 System Manager with your default role.

See Managing Roles for more details about roles.

Steps
  1. Log in to the N1 System Manager.

    See To Access the N1 System Manager Command Line for details.

  2. Show your current session role.


    N1-ok> show session
    

ProcedureTo Switch Your Session Role

If you have more than one role, you can switch between multiple roles to perform tasks that require specific privileges.

See Managing Roles for more details about roles and privileges.

Steps
  1. Log in to the N1 System Manager.

    See To Access the N1 System Manager Command Line for details.

  2. Switch to a different session role.


    N1-ok> set session role role
    

    See set session in Sun N1 System Manager 1.3 Command Line Reference Manual for details.

ProcedureTo Exit the N1 System Manager Command Line

Step

    Exit the N1 System Manager command line.


    N1-ok> exit
    

    The n1sh shell is terminated.

ProcedureTo Run a Script of N1 System Manager Commands

The following procedure describes how to run a custom script of N1 System Manager commands that are saved in a file. Return codes are returned for each command. Also, you can specify a comment character (#) at the beginning of the line to indicate that the rest of the line should be ignored.

Steps
  1. Log in to the N1 System Manager.

    See To Access the N1 System Manager Command Line for details.

    If the n1sh shell is your default login shell on the management server, you must change this configuration. Otherwise, you won't be able to run the n1sh command and use the script option.

  2. Run a custom script that contains the N1 System Manager commands.


    # /opt/sun/n1gc/bin/n1sh -f filename
    

    where filename is a fully qualified path to the custom script file.


Example 1–1 n1sh Custom Script File

The following example shows an n1sh script file, which can be run with the n1sh -f command.

# n1sh custom script

show group all 

create group RACK1   
create group RACK2   
create group RACK3   
create group RACK4   
create group RACK5   


add group RACK1 server SERVER1  
add group RACK1 server SERVER2  

add group RACK2 server SERVER3  
add group RACK2 server SERVER4  


add group RACK3 server SERVER5  
add group RACK3 server SERVER6  

add group RACK4 server SERVER7  
add group RACK4 server SERVER8  

add group RACK4 server SERVER9  
add group RACK4 server SERVER10  

add group RACK5 server SERVER11  
add group RACK5 server SERVER12  

show group all