Saturday, July 31, 2010

What is pbrun command?

pbrun

Usage: pbrun [-v][-n][-p][-d option] [-h hostname]
          [-u username] command [args ...]


The pbrun command is used to request that an application or command be run in a controlled account. The user simply adds pbrun to the beginning of the command line, for example:
    pbrun backup /usr /dev/dat
pbrun then checks the /etc/pb.settings file to determine the master daemon to which it should send the request. Once it has contacted a master daemon, it sends a request to the daemon to run the application specified. As with the rlogin command, you can type ~^Z to suspend pbrun, or ~. to terminate it. Both must be typed at the beginning of a new line. pbrun has several options:
-d option
This outputs debugging information.
When option is connect this displays debugging information regarding connections between clients and masters. TCP/IP socket information and machine name lookup statistics can be useful for solving DNS and NIS problems. For example:
    pbrun -d connect ls
when option is time or ttime displays debugging information regarding the timing or total time of each subsection of the pbrun command. It is useful for isolating performance bottlenecks between networked machines and solving obscure timing problems.
    pbrun -d time ls
-h hostname
allows the user to request a particular execution host that will run the request. If present, the
-h hostname must come before the command being requested.
-n
redirects the input of
pbrun to /dev/null. You sometimes need this option to avoid unfortunate interactions between pbrun and the shell that invokes it. For example, if you are running pbrun and start a pbrun in the background without redirecting its input away from the terminal, it will block even if no reads are posted by the remote command. -n prevents this.
-p
puts
pbrun into "pipe mode," in which all interactions with the user's terminal are done without changing any of the terminal parameters. Normally, pbrun puts the terminal into raw mode, so that programs such as text editors, which require raw mode, can run properly under pbrun. Pipe mode is useful when several pbrun commands must be piped together, for example:
    pbrun -p ls /etc/secure | pbrun -p dbadd listing
-u
username
sets the requesting user to be username.
-v
displays the current version number of
pbrun.

Reference:
Chapter 20: Reference - Programs
http://www.uiweb.uidaho.edu/pb/pb27-20.htm

Chapter 15: Executing Programs within PowerBroker
http://www.uiweb.uidaho.edu/pb/pb27-15.htm

Friday, July 30, 2010

Background Commands with ampersand - &

To background a command simply add an ampersand (&) on the end.

Reference:
UNIX for beginners
http://people.cryst.bbk.ac.uk/~tickle/notes/unix-beg.html

If a command is terminated by the control operator ampersand (&), the shell executes the command asynchronously -- that is, the shell does not wait for the command to finish before executing the next command.
The format for running a command in background is:
command1 & [command2 & ...]
If the shell is not interactive, the standard input of an asynchronous command is set to /dev/null

Reference:
Linux / Unix Command: ash
http://linux.about.com/library/cmd/blcmdl1_ash.htm

Thursday, July 29, 2010

How to shutdown Solaris box

You can shut down the system in a number of ways, using various Unix commands. With Solaris, taking down the operating system in an orderly fashion is important. When the sys tem boots, several processes are started; they must be shut down before you power off the system. In addition, information that has been cached in memory and has not yet been written to disk will be lost if it is not flushed from memory and saved to disk. The process of shutting down Solaris involves shutting down processes, flushing data from memory to the disk, and unmounting file systems.


Shutting down a system improperly can result in loss of data and the risk of corrupting the file systems.


Commands to Shut Down the System

/usr/sbin/shutdown
/sbin/init
/usr/sbin/halt
/usr/sbin/reboot
/usr/sbin/poweroff
Stop+A or L1+A
    Using the Stop+A key sequence (or L1+A) abruptly breaks execution of the operating system and should be used only as a last resort to restart the system.

    The first three commands

    /usr/sbin/shutdown
    /sbin/init
    /usr/sbin/halt 
    • initiate shutdown procedures,
    • kill all running processes, 
    • write data to disk, and 
    • shut down the system software to the appropriate run level. 
    The /usr/sbin/reboot command does all these tasks as well, and it then boots the system back to the state defined as initdefault in /etc/inittab.
    The /usr/sbin/poweroff command is equivalent to init state 5.

    STEP BY STEP
    3.6 Shutting Down a System
    1. As superuser, type the following to find out if users are logged in to the system:

    # who

    2. A list of all logged-in users is displayed. You might want to send an email message or broadcast a message to let users know that the system is being shut down.
    3. Shut down the system by using the shutdown command:


    # shutdown -i -g -y

    Table 3.27 describes the options available for the shutdown command.

    Table 3.27 Options for the shutdown Command

    Option
    Description
    -i<init-state>
    Brings the system to an init state that is different from the default, S. The choices are 0S125, and 6.
    -g<grace-period>
    Indicates a time (in seconds) before the system is shut down. The default is 60 seconds.
    -y
    Continues to shut down the system without intervention; otherwise, you are prompted to continue the shutdown process after 60 seconds. If you use the shutdown -ycommand, you are not prompted to continue; otherwise, you get the message Do you want to continue? (y or n).
    The /sbin/init Command
    You use the init command to shut down a single-user system or to change its run level. The syntax is as follows:

    init

    <run-level> is any run level described in Table 3.21. In addition, <run-level> can be ab, or c, which tells the system to process only /etc/inittab entries that have the ab, or c run level set. These are pseudo-states, which can be defined to run certain commands but which do not cause the current run level to change. <run-level> can also be the keyword Q or q, which tells the system to reexamine the /etc/inittab file.
    You can use init to place the system in power-down state (init state 5) or in single-user state (init state 1). For example, to bring the system down to run level 1 from the current run level, you type the following:

    init 1

    The system responds with this:


    svc.startd: Changing to state 1.
    svc.startd: Killing user processes: done.
    svc.startd: The system is ready for administration.
    Requesting System Maintenance Mode
    (See /lib/svc/share/README for more information.)


    Root password for system maintenance (control-d to bypass):
    single-user privilege assigned to /dev/console.
    Entering System Maintenance Mode


    Aug 4 09:18:13 su: ‘su root’ succeeded for root on /dev/console
    Sun Microsystems Inc. SunOS 5.10  Generic January 2005

    The /usr/sbin/halt Command

    You use the halt command when the system must be stopped immediately and it is acceptable not to warn current users. The halt command shuts down the system without delay and does not warn other users on the system of the shutdown.

    The /usr/sbin/reboot Command

    You use the reboot command to shut down a single-user system and bring it into multi-user state.reboot does not warn other users on the system of the shutdown.
    The Solaris rebootpoweroff, and halt commands stop the processor and synchronize the disks, but they perform unconditional shutdown of system processes. These commands are not recommended because they do not shut down any services and unmount any remaining file systems. They will, however, attempt to kill active processes with a SIGTERM, but the services will not be shut down cleanly. Stopping the services without doing a clean shutdown should only be done in an emergency or if most of the services are already stopped.
    The speed of such a reboot is useful in certain circumstances, such as when you’re rebooting from the single-user run state. Also, the capability to pass arguments to OpenBoot via the rebootcommand is useful. For example, this command reboots the system into run level s and reconfigures the device tables:

    reboot -- -rs

    The /usr/sbin/poweroff Command

    The poweroff command is equivalent to the init 5 command. As with the reboot and haltcommands, the poweroff command synchronizes the disks and immediately shuts down the system, without properly shutting down services and unmounting all file systems. Users are not notified of the shutdown. If the hardware supports it, the poweroff command also turns off power.
    Stopping the System for Recovery Purposes
    Occasionally, a system might not respond to the init commands described earlier in this chapter. A system that doesn’t respond to anything, including reboot or halt, is called a "crashed" or "hung" system. If you try to use the commands discussed in the preceding sections but get no response, on non-USB style keyboards, you can press Stop+A or L1+A to get back to the boot PROM. (The specific Stop key sequence depends on your keyboard type.) On terminals connected to the serial port, you can press the Break key, as described in the section "Accessing the OpenBoot Environment," earlier in this chapter.
    Some OpenBoot systems provide the capability of commanding OpenBoot by means of pressing a combination of keys on the system’s keyboard, referred to as a keyboard chord or keycombination. These keyboard chords are described in Table 3.28. When issuing any of these commands, you press the keys immediately after turning on the power to your system, and you hold down the keys for a few seconds until the keyboard light-emitting diodes (LEDs) flash. It should be noted, however, that these keyboard chords only work on non-USB keyboards and not USB style keyboards.

    Table 3.28 Keyboard Chords

    Command
    Description
    Stop
    Bypasses the POST. This command does not depend on the security mode. (Note that some systems bypass the POST as a default; in such cases, you use Stop+D to start the POST.)
    Stop+A
    Interrupts any program currently running and puts the system at the OpenBoot prompt, ready to accept OpenBoot PROM commands.
    Stop+D
    Enters diagnostic mode (sets the diag-switch? variable to true).
    Stop+F
    Enters Forth on the ttya port instead of probing. Uses fexit to continue with the initialization sequence. This chord is useful if hardware is broken.
    Stop+N
    Resets the contents of NVRAM to the default values.
    To change the default abort sequence on the keyboard, you need to edit the /etc/default/ kbdfile. In that file, you can enable and disable keyboard abort sequences, and change the keyboard abort sequence. After modifying this file, you issue the kbd -i command to update the keyboard defaults.
    The process of breaking out of a hung system is described in Step by Step 3.7.

    TIP
    STEP BY STEP
    3.7 Breaking Out of a Hung System
    1. Use the abort key sequence for your system (Stop+A or L1+A).
    2. The monitor displays the ok PROM prompt.
    3. Type the sync command to manually synchronize the file systems:
    ok sync

      The sync procedure synchronizes the file systems and is necessary to prevent corruption. During the sync process, the system will panic, synchronize the file systems, perform a crash dump by dumping the contents of kernel memory to disk, and finally perform a system reset to start the boot process.
    1. After you receive the login: message, log in and type the following to verify that the system is booted to the specified run level:

    # who -r

      2. The system responds with the following:


        run-level 3 Jun 9 09:19 3 0 S


        Turning Off the Power to the Hardware

        Only after shutting down the file systems should you turn off the power to the hardware. You turn off power to all devices after the system is shut down. If necessary, you should also unplug the power cables. When power can be restored, you use the process described in Step by Step 3.8 to turn on the system and devices.
        STEP BY STEP
        3.8 Turning Off the Power
        1. Plug in the power cables.
        2. Turn on all peripheral devices, such as disk drives, tape drives, and printers.
        3. Turn on the CPU and monitor.
        Reference:
        How to Perform System Boot and Shutdown Procedures for Solaris 10
        http://www.informit.com/articles/article.aspx?p=440286&seqNum=15

        GNU is not Unix and Linux is not Unix.

        Reference:
        Chapter 1. Linux is not Unix (20)
        http://kernelbook.sourceforge.net/pdf/ch-intro.pdf