Thursday, October 10, 2013

How to configure Veritas Volume Manager VxVM 6.0.2

The disks should be discovered by OS before it can be added to Veritas Volume Manager.


1. List the disks detected by VxVM.

# vxdisk -o alldgs list


Eg :

[root@rhel61 ~]# vxdisk -o alldgs list
DEVICE       TYPE            DISK         GROUP        STATUS
sda          auto:none       -            -            online invalid
sdb          auto:none       -            -            online invalid
sdc          auto:cdsdisk    mydg01       mydg         online
sdd          auto:cdsdisk    mydg02       mydg         online
[root@rhel61 ~]#

sda and sbd are not configured / initialized for VxVM; where as sdc and sdd are initialized and added to a disk group.


2. Initialize disks.

vxdisksetup -i [attributes]

# vxdisksetup -i sdc
# vxdisksetup -i emc0_dd1

Initializing a disk will create Privae and Public regions in the disks, Meta data is stored in private region and public reagion is available for general purpose data usage. 32 MB is reserved for private region.

Friday, July 5, 2013

Configure DNS Client in Solaris 11.1

Solaris 11.1 saw a lot of changes. A number of configurations has been moved from config files to Service Management Framework , SMF.

To enable DNS client you should be come an Administrator.

1. List the current DNS Client configuration.

root@solaris11.1:~# svccfg -s network/dns/client listprop config
config                      application
config/value_authorization astring     solaris.smf.value.name-service.dns.client
config/domain              astring     Home
config/nameserver          net_address
root@solaris11.1:~#


2. Update the SMF repository with the DNS server name. Let 192.168.1.1 and 192.168.1.2 be the primary and secondary DNS server.

root@solaris11.1:~# svccfg -s network/dns/client setprop config/nameserver = net_address: "(192.168.1.1 192.168.1.2)"
root@solaris11.1:~#

3. change the Domain name.
root@solaris11.1:~# svccfg -s network/dns/client setprop config/domain = astring: '("solaris.local")'
root@solaris11.1:~#

4. Change the search domains.
root@solaris11.1:~# svccfg -s network/dns/client setprop config/search = astring: '("solaris.local" test.solaris.local)'
root@solaris11.1:~#

5. Update the Name resolution order.
root@solaris11.1:~# svccfg -s name-service/switch setprop config/host = astring: '("files dns mdns")'
root@solaris11.1:~#

6. Review the modified DNS client configuration
root@solaris11.1:~# svccfg -s network/dns/client listprop config
config                      application
config/value_authorization astring     solaris.smf.value.name-service.dns.client
config/domain              astring     solaris.local test.solaris.local
config/nameserver          net_address 192.168.1.1 192.168.1.2
root@solaris11.1:~#

root@sol1:~# svccfg -s name-service/switch listprop config
config                      application
config/default             astring     files
config/value_authorization astring     solaris.smf.value.name-service.switch
config/host                astring     "files dns mdns"
config/printer             astring     "user files"
root@sol1:~#

Jayakrishnan

Wednesday, June 12, 2013

Cut command reference

Cut is a simpler alternative to the sed command. Cut is also very efficient and flexible..

The examples specified below is from Solaris 11.1 and  RedHat Enterprise Linux 6.4, however most of the Linux / Unix distributions supports the cut command.

We shall use the below file for our examples.

root@sol1:~/jk# cat testfile.txt
This is a test file to demonstrate "cut" command.
Cut can be used for line filtering.
Cut is simpler than awk and sed commands.
root@sol1:~/jk#


1. Select a field from a file.
You can combine -f and -d to print required field. -f specifies the field and -d specified the delimiter to be used to find the filed.

root@sol1:~/jk# cut -d':' -f1 /etc/passwd | head -5
root
daemon
bin
sys
adm
root@sol1:~/jk#


2. Select multiple fields from a file.
To select multiple fields use comma separated numbers with -f.

root@sol1:~/jk# cut -d' ' -f 1,5 testfile.txt
This file
Cut for
Cut awk
root@sol1:~/jk#
Here 'space' is the delimiter.


3. Select Column of characters.
To print selected column or character from a file use -c option.

root@sol1:~/jk# cut -c2 testfile.txt
h
u
u
root@sol1:~/jk#
 
As you can see, h,u,u are the 2nd character on each line.


4.  Select column of characters using range.
 
To print from 3rd character to the end :

root@sol1:~/jk# cut -c3- testfile.txt
is is a test file to demonstrate "cut" command.
t can be used for line filtering.
t is simpler than awk and sed commands.
root@sol1:~/jk#

To print till 5th character :

root@sol1:~/jk# cut -c-5 testfile.txt
This
Cut c
Cut i
root@sol1:~/jk#

To print from 5th character to 10th character.
 
root@sol1:~/jk# cut -c5-10 testfile.txt
 is a
can be
is sim
root@sol1:~/jk#

Whole lines will be print if no number is specified before or after '-'.

root@sol1:~/jk# cut -c- testfile.txt
This is a test file to demonstrate "cut" command.
Cut can be used for line filtering.
Cut is simpler than awk and sed commands.
root@sol1:~/jk#

5. Print fields only when the delimiter specified is present.

If the delimiter specified is not present in the file, cut will print the whole lines.

root@sol1:~/jk# cut -d'|' -f1 /etc/passwd | head -5
root:x:0:0:Super-User:/root:/usr/bin/bash
daemon:x:1:1::/:
bin:x:2:2::/usr/bin:
sys:x:3:3::/:
adm:x:4:4:Admin:/var/adm:
root@sol1:~/jk#

Use '-s' to prevent this behaviour.

root@sol1:~/jk# cut -d'|' -s -f1 /etc/passwd | head -5
root@sol1:~/jk#

6. To select all fields except the ones specified.
Use --complement to invert cut's behavior. Note '--complement' is not available in Solaris.

root@sol1:~/jk# cut -d' ' --complement -f1,3 testfile.txt
is test file to demonstrate "cut" command.
can used for line filtering.
is than awk and sed commands.
root@sol1:~/jk#


7. Change output delimiter for ease of reading.
You can use '--output-delimiter' to custom specify the delimiter to print. Note : --output-delimiter is not available in Solaris.

root@rhel:~/jk# grep "/bin/bash" /etc/passwd | cut -d':'  -s -f1,6,7 --output-delimiter='#'
root#/root#/usr/bin/bash
root@rhel:~/jk#

You can also use the escape characters as follows. For changing the delimiter to "new line":

root@sol1:~/jk# grep "/bin/bash" /etc/passwd | cut -d':'  -s -f1,6,7 --output-delimiter=$'\n'
root
/root
/usr/bin/bash
root@sol1:~/jk#

Remember to use "$" as the escape character.

Cut is a very cool and simple utility. Master it !!

JK.

Thursday, April 25, 2013

Set Setuid, Setgid and Sticky bit in Linux

Special permissions on files and directories in linux are : SetUID, SetGID and Sticky bit.

With the help of “chmod” command  we can implement the special permissions on file and directories.

SUID / Set User ID : A program is executed with the file owner's permissions (rather than with the permissions of the user who executes it).

SGID / Set Group ID : Files created in the directory inherit its GID, i.e When a directory is shared between the users , and sgid is implemented on that shared directory , when these users creates  directory, then the created directory has the same gid or group owner of its parent directory.

Sticky Bit :  It is used mainly used on folders in order to avoid deletion of a folder and its content by other user though he/she is having write permissions. If Sticky bit is enabled on a folder, the folder is deleted by only owner of the folder and super user(root). This is a security measure to suppress deletion of critical folders where it is having full permissions by others.

Assign IP Address and Gateway in Linux from Command Line

if config command is used to assign the ip address to a lan card from the command or from the terminal.

Syntax :

 # ifconfig [-v] [-a] [-s]  [interface]

Options :
  • -a :    display all interfaces which are currently available, even if down
  • -s :    display a short list (like netstat -i)
  • -v :   be more verbose for some error conditions
interface : The name of the interface.  This is usually a driver name followed by a unit number, for example eth0 for  the  first Ethernet interface. If your kernel supports alias interfaces, you can specify them with eth0:0 for the first alias of eth0. One can use them to assign a second address. To delete an alias interface use ifconfig eth0:0 down.

Sunday, February 10, 2013

Grub Re-install for SUSE Linux


The below steps can be used to fix un-bootable SUSE Linux OS due to Grub corruption or any damage to GRUB boot loader.

Boot to the SLED or SLES 11 DVD (the SP1 DVD is also fine), select "Rescue System" and login as root.  At the command line enter "grub" and follow this example:

******************
linux:~ # grub

    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)
 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]

grub> find /boot/grub/stage1
 (hd0,0)

grub> root (hd0,0)
 Filesystem type is reiserfs, partition type 0xfd

grub> setup (hd0)
 Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/reiserfs_stage1_5" exists... yes
 Running "embed /boot/grub/reiserfs_stage1_5 (hd0)"...  18 sectors are embedded.
succeeded
 Running "install /boot/grub/stage1 (hd0) (hd0)1+18 p (hd0,0)/boot/grub/stage2 /boot/
grub/menu.lst"... succeeded
Done.

grub> quit
******************

In this example the root partition is (hd0,0) as returned by the "find /boot/grub/stage1" command.  Use the correct root partition for your system as indicated by this command for the two commands that follow the first one.

Reboot the system and GRUB should come up appropriately.

This Doc is for SUSE Linux Enterprise Server 11 or SUSE Linux Enterprise Desktop 11 but it should work for all SLES and OpenSUSE editons with little and obvious modifications. 





Wednesday, January 16, 2013

Network Bonding / NIC Teaming in Linux


Network Bonding :- NIC teaming or network bonding is nothing but combining or aggregating multiple network connections in parallel. This is done to increase throughput, and to provide redundancy in case one of the links fails or Ethernet card fails. The Linux kernel comes with the bounding driver for aggregating multiple network interfaces into a single logical interface called bond0.

Bonding is nothing but Linux kernel feature that allows to aggregate multiple like interfaces (such as eth0, eth1) into a single virtual link such as bond0. The idea is pretty simple get higher data rates and as well as link failover. Steps To Configure Bonding in Linux



Step #1: Create a Bond0 Configuration File:
CentOS stores network configuration in /etc/sysconfig/network-scripts/ directory. First, we need to create a bond0 config file as follows:

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
Append the following lines:
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes

You need to replace IP address with your actual setup. Save and close the file.