Showing posts with label basic unix commands. Show all posts
Showing posts with label basic unix commands. Show all posts

Sunday, February 7, 2010

Solaris Shutdown commands


# init S To shut down the system to single-user mode, use either run level S or 1.

# init 0 To shut down the system to stop the Solaris OS and display the ok prompt, perform the command.

# init 5 To shut down the system and turn its power off, perform the command:

# init 6 To shut down the system and then reboot to multiuser mode, perform the command:

The command format for the shutdown command is:

shutdown -y -g grace-period -i init-state


Performing System Shutdown Procedures

The -y option pre-answers the final shutdown confirmation question so that the command runs without your intervention.

The -g grace-period allows you to change the number of seconds from the 60-second default.

The -i init-state specifies the run level that the system is to attain. By default, system state S is used.

# shutdown To shut down the system to single-user mode, enter the shutdown command without options.

# shutdown -i0 To shut down the system to stop the Solaris OS, and display the ok prompt, perform the command:

# shutdown -i5 To shut down the system and turn off its power automatically, perform the command.

# shutdown -i6 To shut down the system and then reboot to multiuser mode, perform the command.

The -i option can be used with other command options. For example, to shut down the system and then reboot to multiuser mode, answer yes to the questions presented, provide a grace period of two minutes, and provide a message to the users, perform the command:

# shutdown -y -g120 -i6 “The system is being rebooted”


“Ungraceful” Shutdown Commands

The following commands perform an immediate system shutdown. They do not execute the rc0 kill scripts. They do not notify logged-in users, and there is no grace period.

# halt

# poweroff

# reboot

Saturday, February 6, 2010

Cron-job Entry in Unix

Using the crontab Command
The crontab command enables the user to view, edit, or remove a crontab file.

Viewing a crontab File
To view the contents of the root crontab file, run the crontab –l command as the root user.

# crontab -l

#ident "@(#)root 1.21 04/03/23 SMI"

# The root crontab should be used to perform accounting data collection.

10 3 * * * /usr/sbin/logadm

15 3 * * 0 /usr/lib/fs/nfs/nfsfind

30 3 * * * [ -x /usr/lib/gss/gsscred_clean ] && /usr/lib/gss/gsscred_clean


As the root user, you can view the contents of any regular user’s crontab file by performing the command:

# crontab -l username

Editing a crontab File
Caution – If you accidentally enter the crontab command on the command line without an option (-l, -e, -r), press the interrupt keys Control-C to exit. Do not press Control-D, this action overwrites the existing crontab file with an empty file.

To create or edit a crontab file, follow these steps:

1. Check that the EDITOR variable is set to the editor you want to use. This instructs the cron utility which editor to use to open the file.

# EDITOR=vi

# export EDITOR

2. Run the following crontab command to open your crontab file, and add the appropriate entry.

# crontab -e

30 17 * * 5 /usr/bin/banner "Time to go!" > /dev/console

:wq

Note – If the users do not redirect the standard output and standard error of their commands in the crontab file, any generated output or errors are mailed electronically to the user.

Removing a crontab File
The correct way to remove a crontab file is to invoke the command:

# crontab -r username

Typical users can remove only their own crontab file. The root user can delete any user’s crontab file.

Thursday, February 4, 2010

TERMINALS / DISPLAYS

tty Displays what the tty/pty number of the terminal is.


termdef reports the termtype setup in smit for the tty port that termdef is run on.


chdev -l (device eg tty1) -a term=vt100 Sets tty to a vt100 terminal type


penable tty0 adds getty line into /etc/inittab for tty0 and starts getty


pdisable tty0 disables the getty line and disables getty


stty erase ^? Set backspace key for vt100 terminals


stty erase ^H Set backspace key for wyse50 terminals


lscons Displays the console device


chcons -a login=enable (device eg /dev/tty1) Changes the console device


lsdisp Display adapter device information


chdisp Change default display used by LFT subsystem


portmir -t /dev/tty0 Mirror current terminal onto /dev/tty0


portmir -o Turns off port mirroring