Wednesday, May 30, 2012

Understanding UNIX Shell Scripts


Special characters that can be used to manipulate commands in the command line include

1.    Backslash (\)
2.    Greater than (>)
3.    Less than (<)
4.    Pipe (|)
5.    Ampersand (&)


Backslash:
Character prevents the shell from treating another character as a special character through a process called backslash escaping.
This allows us to split a command statement across multiple lines. When we place the backslash at the end of a line and then press Enter, we can continue the statement on the next line. The backslash prevents the shell from treating the Enter keystroke – or new line character – as a special character.

For Example:
$echo Long pieces of test may not always fit onto to a single \
Line of the command line interface, so it becomes \
Necessary to split them across multiple lines using \
Backslashes.



Greater than (>):
Allows us to direct the standard output of a command to a file or a device such as a printer instead of to the terminal screen.

For Eample:
$ ls –l /usr/home > userdirs



Less than (<):
Allows us to send the contents of a file to a command as its standard output.

For Eg:
$ sort –d < list




Pipe line (|):
Direct the output of one command to the input of another command.

For Example:
$ cat good | grep ‘India’



Ampersand(&):
Character at the end of a command statement allows us to run commands in the background.

For Eg:
$ find / -name che &
[1]  48748
$ che




NOTE:
If we want to use special character in command line text without the shell recognizing them as special characters, we have to enclose them with a backslash (\).

For Example:
$echo Tours \& Accommodation
Tours & Accommodation

This eg shows an ‘echo’ command in which the ‘echo’ text contains an ampersand. There’s backslash
In front of the ampersand, which prevents the shell from treating it as a special character.

Sunday, May 27, 2012

What is …..? Part : 1




What is Mile Stone?
A mile stone is a special type of service that is made up of a defined set of other services.
A mile stone can be regarded as a system state to be reached.  This system state requires a defined set of services to be running.  These services depend on other services being available.  Therefore, there is a hierarchy of dependency relationships.  This is one of the core features managed by SMF.
  

What is Min Free Space?
File system minfree space:
1. The portion of a file system that is reserved and held back from users.
2. On large file systems, the minfree is automatically determined so that disk space is not wasted.
3. A thumb rule is to use default 10% minfree value for file systems upto 1GB and then adjust the minfree value so that your minfree area is no larger than 100MB.
4. Note: As for performance, applications do not complain about the lower minfree value.
5. Purpose:
When the file system is full, the free space can only be accessed by the root user. It can act as an emergency overflow.

To view the minfree value of a slice:
# fstyp -v /dev/dsk/c0t12d0s0 | grep -i min
minfree 10% maxbpg 2048 optim time


To change the minfree value:
# tunefs -m 1 /dev/dsk/c0t12d0s0
minimum percentage of free space changes from 10% to 1%
In the same way, the minfree space can be increased.

 
Note:  By default, the newfs utility calculates the minimum free space based on volume size (64Mbytes /volume size * 100), rounded down to the nearest integer. The default value is limited to between 1 percent and 10 percent.


Journaling:
The recording of Unix File System (UFS) updates in a log before the updates are applied to Unix File System.  This allows for increased data recovery in the event of a catastrophic system failure.  Also called logging.

What is logging?
Logging is a process of storing transactions (changes that make up a complete UFS operation) in a log before the transactions are applied to the file system.  After a transaction is stored, it can be applied to the file system.  This process prevents file system from becoming inconsistent, therefore eliminating the need to run the fsck command.  Because the fsck command can be bypassed, logging reduces the time required to reboot a system if it crashed or after an unclean halt. 

The default behavior prior to Solaris 10 OS is nologging. But remember, UFS logging is enabled by default for all file systems in the Solaris 10 OS. The default behavior can be overwritten by specifying the nologging option on the file system mount.

The log is allocated from free blocks in the file system, and it is sized at approximately 1Mbytem per 1 Gbyte of file system space, up to a maximum of 64Mbytes.  Logging can be enabled on any UFS file system, including root (/). 
The log created by UFS logging continually flushes as it fills up. 
The log is totally flushed when the file system is unmounted or when the lockfs –f command is used.



Private Region:
Private region is used for configuration information. Adding the disk to disk group, the media name, disk access name, the disk name and the disk configurations all are written to the private region.

Starting with VxVM 5.0 , the default size of the private region was increased to 32 Mbytes, which is large enough to store the records of several thousand VxVM objects.

Will be created at the time of initialization of disk to VxVM control.


Holds current host ownership of the disk drive.


Private Region Configuration Database:

Is similar to metadb or replica or state database in Solaris Volume Manager Software.

Contains information about the configuration of a particular disk group.  By default, VxVM keeps 4 copies of the configuration database per disk group to avoid any possibility of losing the disk group information.  Each copy of the configuration database contains the following information –

 dgname – Disk group name is assigned by the administrator.

dgid – Disk group ID is a 64-byte universally unique identifier that is assigned by VxVM to a disk group when the disk group is created.  This identifier is in addition to the disk group name

Records – VxVM virtual structure information for the disk group.


Kernel Log:
The kernel log is kept in the private region on the disk drive and is written by VxVM kernel. The kernel log contains –
Records describing certain types of actions, such as transaction commits, plex detaches resulting from I/O failures, dirty-region log failures, first write to a volume, and volume close information.

The kernel log is used after a crash or clean reboot to recover the state of the disk group just prior to the crash or reboot.


In nut shell, Private Region contains the following –
1.    Current host ownership: host id/host name.
2.    Disk identifier
3.    Configuration database
4.    Kernel log