Tanti Technology

My photo
Bangalore, karnataka, India
Multi-platform UNIX systems consultant and administrator in mutualized and virtualized environments I have 4.5+ years experience in AIX system Administration field. This site will be helpful for system administrator in their day to day activities.Your comments on posts are welcome.This blog is all about IBM AIX Unix flavour. This blog will be used by System admins who will be using AIX in their work life. It can also be used for those newbies who want to get certifications in AIX Administration. This blog will be updated frequently to help the system admins and other new learners. DISCLAIMER: Please note that blog owner takes no responsibility of any kind for any type of data loss or damage by trying any of the command/method mentioned in this blog. You may use the commands/method/scripts on your own responsibility. If you find something useful, a comment would be appreciated to let other viewers also know that the solution/method work(ed) for you.

Saturday 22 February 2014

List STALE partitions across Volume Groups for each Logical Volume in AIX


I wrote a tiny script that can report the number of stale partitions across multiple Volume Groups. If invoked with the -a flag the script will list LPs, PPs and Stale partitions for all Logical Volumes in all active Volume Groups. Using the -v flag only information for the specified Volume Group will be displayed.
Usage:
stale.sh -v rootvg
stale.sh -a
Sample output:
VG: rootvg   LV: hd5     LPs: 1      PPs: 2         STALE 0
VG: rootvg   LV: hd4     LPs: 6      PPs: 12        STALE 0
VG: rootvg   LV: hd2     LPs: 29     PPs: 58        STALE 0
VG: rootvg   LV: hd3     LPs: 4      PPs: 8         STALE 0
VG: rootvg   LV: hd1     LPs: 2      PPs: 4         STALE 0

The script is here:
#!/bin/ksh
#
# OS: AIX
# stale.sh
# Created by: aixdoc.wordpress.com
# THERE IS NO WARRANTY FOR THIS SCTIPT
############################################################################################
# This script if invoked with the -a flag will print for all Logical Volumes in all active #
# Volume Groups the number of LPs, PPs and stale partitions for each Logical Volume.       #
# Using the flag -v [ VG Name ] only information for the specified Volume Group will be    #
# displayed.             #
############################################################################################
# Sample output:             #
# ...                     #
# VG: rootvg           LV: hd6           LPs: 16         PPs: 32        STALE 0            #
# VG: rootvg           LV: hd8           LPs: 1          PPs: 2         STALE 0            #
# VG: rootvg           LV: hd5           LPs: 1          PPs: 2         STALE 0            #
# VG: rootvg           LV: hd4           LPs: 6          PPs: 12        STALE 0            #
# VG: rootvg           LV: hd2           LPs: 29         PPs: 58        STALE 0            #
# ...              #
############################################################################################ 

# Check if we run on AIX

if [[ `uname -s` != AIX  ]]
then print 'This script is designed for AIX only'
exit 1
fi

# Check if tmp file exists, if yes delete the file.

if [[ -a  /tmp/lslv_stale.out ]]
  then
 rm /tmp/lslv_stale.out
fi

# If no command line argument is specified, print usage

if [[ $# -eq 0 ]]; then
 print 'Usage: stale.sh [-a] List all LVs in all open VGs [-v VG_Name] List LVs in the specified VG'
  exit
fi

# If the -a flag is specified, get the list of all LVs from all active VGs. 

while [[ $1 = -* ]]; do
 case $1 in
 -a )

for vg in `lsvg -o`
 do
   lsvg -l $vg | awk 'NR>2 { print $1 }' >> /tmp/lslv_stale.out
     done

# Now run lslv against each Logical Volume and format the output as required.

for list_lv in `cat /tmp/lslv_stale.out`
  do
    lslv $list_lv |  awk -vORS=' ' 'NR==1 { printf "%-20s %-40s", "VG: " $6, "LV: " $3 } NR==7 {  printf "%-15s %-15s", "LPs: " $2, "PPs: " $4} NR==8 { printf "%-5s %-5s\n",  $1, $3 }'
            done;;

# Using the -v flag report only information for the specified VG
 -v )

lsvg -l $2 | awk 'NR>2 { print $1 }' >> /tmp/lslv_stale.out
for list_lv in `cat /tmp/lslv_stale.out`
  do
    lslv $list_lv |  awk -vORS=' ' 'NR==1 { printf "%-20s %-40s", "VG: " $6, "LV: " $3 } NR==7 {  printf "%-15s %-15s", "LPs: " $2, "PPs: " $4} NR==8 { printf "%-5s %-5s\n",  $1, $3 }'
 done;;

         *) print 'Usage: stale.sh [-a] List all LVs in all open VGs [-v VG_Name] List LVs in the specified VG'
return 1
esac
shift
done

# Delete temporary file

rm /tmp/lslv_stale.out

Installing the Network Installation Manger (NIM) master server


This post will describe the steps nesessery to setup a basic NIM master server.
Assuming the installation source will be the AIX Volume 1 installation media, in my case mounted in the /mnt/iso directory.
 
# installp -agXd /mnt/iso bos.sysmgt.nim.master
...
# lslpp -l | grep gt.nim
  bos.sysmgt.nim.client      6.1.5.1  COMMITTED  Network Install Manager -
  bos.sysmgt.nim.master      6.1.5.1  COMMITTED  Network Install Manager -
  bos.sysmgt.nim.client      6.1.5.1  COMMITTED  Network Install Manager -
Now we configure our mashine as a NIM Master.
smitty nimconfig
The following screen appears
                                                Configure Network Installation Management Master Fileset

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

                                                        [Entry Fields]
* Network Name                                       [NET_EN0] 
* Primary Network Install Interface                  [en0]                                                                                             +

  Allow Machines to Register Themselves as Clients?  [yes]                                                                                             +
  Alternate Port Numbers for Network Communications   
       (reserved values will be used if left blank)
    Client Registration                              []                                                                                                 #
    Client Communications                            []                                                                                                 #

F1=Help                               F2=Refresh                             F3=Cancel                             F4=List
F5=Reset                              F6=Command                             F7=Edit                               F8=Image
F9=Shell                              F10=Exit                               Enter=Do
The highlighted values are mandatory.
Now check the NIM server status using the lsnim command
# lsnim
master         machines        master
boot           resources       boot
nim_script     resources       nim_script
EN0_NET        networks        ent

# lsnim -l master
master:
   class               = machines
   type                = master
   max_nimesis_threads = 20
   comments            = machine which controls the NIM environment
   platform            = chrp
   netboot_kernel      = 64
   if1                 = EN0_NET  
   cable_type1         = N/A
   Cstate              = ready for a NIM operation
   prev_state          =
   Mstate              = currently running
   serves              = boot
   serves              = nim_script
   master_port         = 1058
   registration_port   = 1059
   reserved            = yes



 # lsnim -l EN0_NET
EN0_NET:
   class      = networks
   type       = ent
   Nstate     = ready for use
   prev_state = information is missing from this object's definition
   net_addr   = 192.168.2.0
   snm        = 255.255.255.0
   routing1   = default 192.168.2.1
Next we define the lpp_source running “smitty nim_mkres” and selecting “lpp_source”
Type or select values in entry fields.
Press Enter AFTER making all desired changes.

                                                        [Entry Fields]
* Resource Name                                      [LPP_61_ML5]
* Resource Type                                       lpp_source
* Server of Resource                                 [master]                                                                      +
* Location of Resource                               [/nim/aix61ml5/lppsource]                                                     /
  NFS Client Security Method                         []                                                                            +
  NFS Version Access                                 []                                                                            +
  Architecture of Resource                           []                                                                            +
  Source of Install Images                           [/mnt/iso]                                                                    +/
  Names of Option Packages                           []
  Show Progress                                      [yes]                                                                         +
  Comments                                           []














F1=Help                               F2=Refresh                             F3=Cancel                             F4=List
F5=Reset                              F6=Command                             F7=Edit                               F8=Image
F9=Shell                              F10=Exit                               Enter=Do                              



                                 

Now verify the LPP source status
 # lsnim -l LPP_61_ML5
LPP_61_ML5:
   class       = resources
   type        = lpp_source
   arch        = power
   Rstate      = ready for use
   prev_state  = unavailable for use
   location    = /nim/aix61ml5/lppsource
   simages     = yes
   alloc_count = 0
   server      = master
Next we create the SPOT using “smitty nim_mkres” and selecting SPOT
                                           Define a Resource

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

                                                        [Entry Fields]
* Resource Name                                      [SPOT_61_ML5]
* Resource Type                                       spot
* Server of Resource                                 [master]                  +
  Source of Install Images                           [LPP_61_ML5]              +
* Location of Resource                               [/nim/aix61ml5]           /
  NFS Client Security Method                         []                        +
  NFS Version Access                                 []                        +
  Expand file systems if space needed?                yes                      +
  Comments                                           []

  installp Flags
  PREVIEW only? (install operation will NOT occur)    no                       +
  COMMIT software updates?                            no                       +
  SAVE replaced files?                                yes                      +
  AUTOMATICALLY install requisite software?           yes                      +
  OVERWRITE same or newer versions?                   no                       +
  VERIFY install and check file sizes?                no                       +


The process may take some time, after it is finished we can see the new SPOT resource:
# lsnim -l SPOT_61_ML5
SPOT_61_ML5:
   class         = resources
   type          = spot
   plat_defined  = chrp
   arch          = power
   bos_license   = yes
   Rstate        = ready for use
   prev_state    = verification is being performed
   location      = /nim/aix61ml5/SPOT_61_ML5/usr
   version       = 6
   release       = 1
   mod           = 5
   oslevel_r     = 6100-05
   alloc_count   = 0
   server        = master
   Rstate_result = success
   mk_netboot    = yes
   mk_netboot    = yes
Now we will define a NIM client using the fastpath smitty nim_mkmac
                                                        Define a Machine

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

[TOP]                                                   [Entry Fields]
* NIM Machine Name                                   [power2]
* Machine Type                                       [standalone]                      +
* Hardware Platform Type                             [chrp]                            +
  Kernel to use for Network Boot                     [64]                              +
  Communication Protocol used by client              [nimsh]                           +
  Primary Network Install Interface                   
*   Cable Type                                        tp                               +
    Network Speed Setting                            []                                +
    Network Duplex Setting                           []                                +
*   NIM Network                                       EN0_NET                                                                     
*   Host Name                                         power2                                                                      
    Network Adapter Hardware Address                 [0]                                                                          
    Network Adapter Logical Device Name              []                                                                           
  IPL ROM Emulation Device                           []                                +/
  CPU Id                                             []                                                                         
  Machine Group                                      []                                +
  
  Managing System Information
  WPAR Options
    Managing System                                  []
    -OR- 

Again, verify the state of the created resource:
# lsnim -l power2
power2:
   class          = machines
   type           = standalone
   connect        = nimsh
   platform       = chrp
   netboot_kernel = 64
   if1            = EN0_NET power2 0
   cable_type1    = tp
   Cstate         = ready for a NIM operation
   prev_state     = ready for a NIM operation
   Mstate         = currently running
The lsnim command show the summary of all the defined resources.
lsnim
master          machines        master
boot            resources       boot
nim_script      resources       nim_script
EN0_NET         networks        ent
LPP_61_ML5      resources       lpp_source
SPOT_61_ML5     resources       spot
power2          machines        standalone

AIX-Encrypted File System


This post will in short describe how to setup an Encrypted Filesystem on AIX 6.1.
EFS offers 2 modes of operation:
Root Admin mode
This is the default mode. Root can reset user and group keystore passwords.
Root Guard mode
Root doeas not have access to user’s encrypted files and cannot change their passwords.
Note: NFS exports of EFS filesystems are not supported.
1. Prerequisites:
RBAC has to be enabled. Should be by default on AIX 6.1. If not use chdev to enable it.
# lsattr -El sys0 | grep RBAC
enhanced_RBAC   true         Enhanced RBAC Mode        True
CryptoLite needs to be installed
# lslpp -l | grep clic       
  clic.rte.kernext           4.7.0.1  COMMITTED  CryptoLite for C Kernel
  clic.rte.lib               4.7.0.1  COMMITTED  CryptoLite for C Library
  clic.rte.kernext           4.7.0.1  COMMITTED  CryptoLite for C Kernel
2. EFS Commands:
efsenable – Enables EFS on a given system. This is run only once
efskeymgr – Encryption Key Management tool
efsmgr – File encryption and decryption

3. Setup:
To enable EFS on the system use:
# efsenable -a
Enter password to protect your initial keystore:
Enter the same password again:
If your password for EFS will be identical with your login password the EFS Kernel extention will be loaded automatically into the kernel. Thus
you will be able to access the encrypted files without having to provide a password.
Otherwise `efskeymgr -o ksh` has tto be executed in order to load the key’s.
In order to have the ability to encrypt files, the filesystem that will hold this files needs to be EFS enabled (efs=yes) and Extended Attribute V2 has to be activated.
This can be verified using lsfs -q
# lsfs -q /archive
Name            Nodename   Mount Pt               VFS   Size    Options    Auto Accounting
/dev/fslv12     --         /archive               jfs2  262144  rw         yes  no 
  (lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes, inline log: no, inline log size: 0, EAformat: v1, Quota: no, DMAPI: no, VIX: yes, EFS: no, ISNAPSHOT: no, MAXEXT: 0, MountGuard: no)

# chfs -a efs=yes /archive

# lsfs -q /archive
Name            Nodename   Mount Pt               VFS   Size    Options    Auto Accounting
/dev/fslv12     --         /archive               jfs2  262144  rw         yes  no 
  (lv size: 262144, fs size: 262144, block size: 4096, sparse files: yes, inline log: no, inline log size: 0, EAformat: v2, Quota: no, DMAPI: no, VIX: yes, EFS: yes, ISNAPSHOT: no, MAXEXT: 0, MountGuard: no)
Now we will have a look at the keys associated  with the current shell.
# efskeymgr -V
List of keys loaded in the current process:
 Key #0:
                           Kind ..................... User key
                           Id   (uid / gid) ......... 0
                           Type ..................... Private key
                           Algorithm ................ RSA_1024
                           Validity ................. Key is valid
                           Fingerprint .............. 00f06152:be7cae83:a02379a0:82e30ab8:f6295ea1
 Key #1:
                           Kind ..................... Group key
                           Id   (uid / gid) ......... 7
                           Type ..................... Private key
                           Algorithm ................ RSA_1024
                           Validity ................. Key is valid
                           Fingerprint .............. 4a09752d:e19078be:354e4268:268c7d56:18928ecb
 Key #2:
                           Kind ..................... Admin key
                           Id   (uid / gid) ......... 0
                           Type ..................... Private key
                           Algorithm ................ RSA_1024
                           Validity ................. Key is valid
                           Fingerprint .............. 6f6e40e3:89c418ac:2e555ac4:60fdb6b5:630201f9
4. Encrypt file
Now we will create a file, try to encrypt it, have a problem with umask and finally encrypt the file.
# echo "I like black tee with milk." > secret.txt
# ls -U
total 8
-rw-r------    1 root     system           30 Jul 17 10:08 secret.txt
drwxr-xr-x-    2 root     system          256 Jan 27 19:01 tmp

        Encrypt file
          |        
# efsmgr -e secret.txt
./.efs.LZacya: Security authentication is denied.

# umask 077

# efsmgr -e secret.txt
# ls -U
total 16
drwxr-xr-x-    2 root     system          256 Jul 17 10:01 lost+found
-rw-r-----e    1 root     system           30 Jul 17 11:17 secret.txt
          |
          Indicates that this file is encrypted
Display file encryption information:
# efsmgr -l secret.txt
EFS File information:
 Algorithm: AES_128_CBC
List of keys that can open the file:
 Key #1:
  Algorithm       : RSA_1024
  Who             : uid 0
  Key fingerprint : 00f06152:be7cae83:a02379a0:82e30ab8:f6295ea1
Now I set the file permission’s to 644 and try to read the file as another user.
# chmod 644 secret.txt
# ls -la
-rw-r--r--    1 root     system          145 Jul 17 11:23 secret.txt

user1 # file secret.txt
secret.txt: 0653-902 Cannot open the specified file for reading.
user1 # cat secret.txt
cat: 0652-050 Cannot open secret.txt.
As root we will list the inode number of the file, get the block pointer and read directly from the filesystem using fsdb to see if the file is stored  encrypted.
      Display inode no.
      |
# ls -iU
total 32
    3 drwxr-xr-x-    2 root     system          256 Jul 17 10:01 lost+found
    5 -rw-r--r--e    1 root     system          145 Jul 17 11:23 secret.txt

# istat 5 /dev/fslv12
Inode 5 on device 10/27 File
Protection: rw-r--r--   
Owner: 0(root)          Group: 0(system)
Link count:   1         Length 145 bytes

Last updated:   Tue Jul 17 13:23:52 GMT+02:00 2012
Last modified:  Tue Jul 17 13:23:52 GMT+02:00 2012
Last accessed:  Tue Jul 17 13:23:52 GMT+02:00 2012

Block pointers (hexadecimal):
29        
# fsdb /dev/fslv12
Filesystem /dev/fslv12 is mounted.  Modification is not permitted.

File System:                    /dev/fslv12

File System Size:               261728  (512 byte blocks)
Aggregate Block Size:           4096
Allocation Group Size:          8192    (aggregate blocks)

> display 0x29
Block: 41     Real Address 0x29000
00000000:  119CB74E 637C6FE0 C0BF2DCD 36B775BB   |...Nc|o...-.6.u.|
00000010:  569B5A6C 43476ED3 F4BFE938 7C662A3B   |V.ZlCGn....8|f*;|
00000020:  B5D89C51 FA2BE7B6 CEAF2D3E 555EAA06   |...Q.+....->U^..|
00000030:  4FF23413 B11D1170 982690B3 5F1BCA9A   |O.4....p.&.._...|
00000040:  4AD3CEA5 A3CBFAD9 C730EE00 9BD1F409   |J........0......|
00000050:  71203B85 A51320C6 04A97DA4 43002DA7   |q ;... ...}.C.-.|
00000060:  994CC67B A1AC31DF 2C8201AD 3E5B50F7   |.L.{..1.,...>[P.|
00000070:  6BA7B01D EC5CB918 17E13F46 2935FA98   |k....\....?F)5..|
00000080:  718DF155 D6E69A41 EF592B60 EA5F7B24   |q..U...A.Y+`._{$|
00000090:  32521FE2 7AD8EC61 1A94413D A8338A26   |2R..z..a..A=.3.&|
000000a0:  62E4A319 D6251A66 F19D4739 2FC7E83A   |b....%.f..G9/..:|
000000b0:  DE0F878A 1F95AB89 5C7F3520 C65B7896   |........\.5 .[x.|
000000c0:  915A7655 EC269DFF 68E2B08A 871114A9   |.ZvU.&..h.......|
000000d0:  E30B195F 280F7DCD 4F8BE094 4B5603D8   |..._(.}.O...KV..|
000000e0:  962303B0 D957A2A5 24A2A3A5 6260EA5E   |.#...W..$...b`.^|
000000f0:  A4C62B7D FB9B1841 893D253F 72E61065   |..+}...A.=%?r..e|
-hit enter for more-
00000100:  01A150FD AD54677D A856E9B1 320257E1   |..P..Tg}.V..2.W.|
00000110:  5F023AA3 0191E0D6 4B64583B D9F2A4C7   |_.:.....KdX;....|
00000120:  F988937A E0117EB2 26E61976 E4860D7D   |...z..~.&..v...}|
00000130:  0C724A4E 50616226 BDE06FEB 10A19564   |.rJNPab&..o....d|
00000140:  17C90BB7 774338B3 8525ED90 5EADFD8B   |....wC8..%..^...|
00000150:  636FC1AF D46C2E64 6AC37082 3B0168BE   |co...l.dj.p.;.h.|
00000160:  24C0CD2E D8587254 F6DBC1BA 93BE6AD6   |$....XrT......j.|
00000170:  E89EEFF9 08000B07 E3827C10 AE0FD7DB   |..........|.....|
00000180:  162D0E6D EF94D85A 3F09CD85 A19A31FF   |.-.m...Z?.....1.|
00000190:  49E13BFC 5328F670 E0B50878 942CC4BB   |I.;.S(.p...x.,..|
000001a0:  BF1D6C4F 9DA72F3D 8DC90691 328A7053   |..lO../=....2.pS|
000001b0:  99C31EEB 1CD2208A CBF609C1 4DB86819   |...... .....M.h.|
000001c0:  E2746288 5E152ECA 0E2BD9DF D1D1D210   |.tb.^....+......|
000001d0:  7ADDF0EC 522E93E2 CAA0A36F B3CBFB05   |z...R......o....|
000001e0:  4EA56F3C ECBA1A0C AA132269 2024E065   |N.o<......"i $.e|
000001f0:  00BC51B0 88BBCD8A 9C644F66 6A16DBC8   |..Q......dOfj...|
Above we see that the file on the disk is encrypted.
5. Decrypting a file
Decrypt file
          |
# efsmgr -d secret.txt
# ls -U
total 24
drwxr-xr-x-    2 root     system          256 Jul 17 10:01 lost+found
-rw-r--r---    1 root     system          145 Jul 17 12:07 secret.txt
6. Encryption Inheritance
If you enable Encryption Inheritance on a directory all newly created files in that directory will be automatically encrypted.
To enable Encryption inheritance use:
# efsmgr -E /archive

# ls -U / | grep archive
drwxr-xr-xe    3 root     system          256 Jul 17 12:09 archive

# touch next.txt

# ls -U 
total 32
drwxr-xr-x-    2 root     system          256 Jul 17 10:01 lost+found
-rw-------e    1 root     system            0 Jul 17 12:09 next.txt
-rw-r--r---    1 root     system          145 Jul 17 12:07 secret.txt
7. Grant access to another user
Say we are  user1 and want to have a look at who has EFS access to the file.
user1 $ efsmgr -l secret.txt
EFS File information:
 Algorithm: AES_128_CBC
List of keys that can open the file:
 Key #1:
  Algorithm       : RSA_1024
  Who             : uid 0
  Key fingerprint : 00f06152:be7cae83:a02379a0:82e30ab8:f6295ea1
To grant access to a user use:
Add access to the specified file to a user or group(u/g)   
          |
# efsmgr -a secret.txt -u user1
                        |
                        Add user to EFS access list        

user1 $ cat secret.txt
I like black tee with milk.
EFS Docmentation can be found in the following Redbooks:
AIX 6.1 Diffrence Guide SG24-7559-00 Page 40
AIX V6 Advanced Security Features SG24-7430-00 Page 59

AIX-Creating a Volume Group


This post will describe how to:
1. Create a Volume Group
2. Create a Logical Volume within the VG containing a JFS2 filesystem that will be automatically mounted during boot.
3. Add a disk to the VG and mirror the data across 2 disks
4. Display LP>PP mappig and LVCB
1. Create a VG
 # mkvg -y vg0 -s64 -V99 hdisk3
vg0
-y VG name
-s PP size
-V VG Major Number
Now lets’ display which PV belongs to which VG and their status
# lspv
hdisk0          00c0e90dce6c290a                    rootvg          active
hdisk1          00cf405ea5c630a9                    rootvg          active
hdisk3          00cf405ea25a9e70                    vg0             active
hdisk4          00cf405ea25a9f84                    None
hdisk5          00cf405ea5ce7f72                    None
hdisk6          00cf405ea5ce8085                    None
2. Create a Logical Volume with a JFS2 Filesystem that will be automatically mounted on the /store mountpoint.
# crfs -v jfs2 -A yes -g vg0 -m /store -a size=1G
File system created successfully.
1048340 kilobytes total disk space.
New File System size is 2097152
-v Filesystem type
-A Automount at boot
-g VG in which the LV will reside
-m mount point
# mount /store
# df -g /store
Filesystem    GB blocks      Free %Used    Iused %Iused Mounted on
/dev/fslv07        1.00      1.00    1%        4     1% /store
3. Add a disk to the VG and mirror the data
# extendvg vg0 hdisk4

# mirrorvg -m vg0 hdisk4
0516-1804 chvg: The quorum change takes effect immediately.
-m Exact mapping of PP’s on both PV’s
# lslv fslv07 | grep LP
MAX LPs:            512                    PP SIZE:        64 megabyte(s)
LPs:                16                     PPs:            32
EACH LP COPY ON A SEPARATE PV ?: yes
The lslv command shows that we have 16 Logical Partitions stored on 32 Physical Partitions.
4. LP > PP mapping
# lsvg -M vg0

vg0
hdisk3:1-7
hdisk3:8        loglv01:1:1
hdisk3:9        fslv07:1:1
hdisk3:10       fslv07:2:1
hdisk3:11       fslv07:3:1
hdisk3:12       fslv07:4:1
hdisk3:13       fslv07:5:1
hdisk3:14       fslv07:6:1
hdisk3:15       fslv07:7:1
hdisk3:16       fslv07:8:1
hdisk3:17       fslv07:9:1
hdisk3:18       fslv07:10:1
hdisk3:19       fslv07:11:1
hdisk3:20       fslv07:12:1
hdisk3:21       fslv07:13:1
hdisk3:22       fslv07:14:1
hdisk3:23       fslv07:15:1
hdisk3:24       fslv07:16:1
hdisk3:25-31
hdisk4:1-7
hdisk4:8        loglv01:1:2
hdisk4:9        fslv07:1:2
hdisk4:10       fslv07:2:2
hdisk4:11       fslv07:3:2
hdisk4:12       fslv07:4:2
hdisk4:13       fslv07:5:2
hdisk4:14       fslv07:6:2
hdisk4:15       fslv07:7:2
hdisk4:16       fslv07:8:2
hdisk4:17       fslv07:9:2
hdisk4:18       fslv07:10:2
hdisk4:19       fslv07:11:2
hdisk4:20       fslv07:12:2
hdisk4:21       fslv07:13:2
hdisk4:22       fslv07:14:2
hdisk4:23       fslv07:15:2
hdisk4:24       fslv07:16:2
hdisk4:25-31
The lsvg command shows the mapping (-M) of the hdisk’s Physical Partitions to the Logical Partition’s of the Logical Volume fslv07 in the following format.
Disk Name.          LV Name
hdisk4:9            fslv07:1:2 -- Logical Partition copy Number 2
       |                   |
   Physical Partition 9    |
                           Logical Partition 1
So we can see from this line, that the second copy of the Logical Partition no. 1 of the Logical Volume fslv07 resides on the Physical Partition no. 9 of hdisk4.
Another possibility is to display the mapping on a LV level using the lslv command.
# lslv -m fslv07
fslv07:/store
LP    PP1  PV1               PP2  PV2               PP3  PV3
0001  0009 hdisk3            0009 hdisk4            
0002  0010 hdisk3            0010 hdisk4            
0003  0011 hdisk3            0011 hdisk4            
0004  0012 hdisk3            0012 hdisk4            
0005  0013 hdisk3            0013 hdisk4            
0006  0014 hdisk3            0014 hdisk4            
0007  0015 hdisk3            0015 hdisk4            
0008  0016 hdisk3            0016 hdisk4            
0009  0017 hdisk3            0017 hdisk4            
0010  0018 hdisk3            0018 hdisk4            
0011  0019 hdisk3            0019 hdisk4            
0012  0020 hdisk3            0020 hdisk4            
0013  0021 hdisk3            0021 hdisk4            
0014  0022 hdisk3            0022 hdisk4            
0015  0023 hdisk3            0023 hdisk4            
0016  0024 hdisk3            0024 hdisk4      
To display the Logical Volume Control Block of the specified LV type:
# getlvcb -AT fslv07
         AIX LVCB
         intrapolicy = m 
         copies = 2 
         interpolicy = m 
         lvid = 00cf405e00004c0000000135e3e508e9.2 
         lvname = fslv07 
         label = /store 
         machine id = xxxxxxxxx 
         number lps = 16 
         relocatable = y 
         strict = y 
         stripe width = 0 
         stripe size in exponent = 0 
         type = jfs2 
         upperbound = 32 
         fs = vfs=jfs2:log=/dev/loglv01:mount=true:account=false 
         time created  = Mon Mar  5 17:30:29 2012
         time modified = Mon Mar  5 17:42:04 2012

Linux Basics

Unix

Linux-Interview-Questions

1. What is ldd?

List dynamic dependencies – print shared library dependencies.
2. What is the command to uninstall processes in Linux?
rpm –e servicenmae
yum remover servicename
3. What is the command for finding the highest memory occupied file in Linux?
du –ah / | sort –n –r | head –n 1
du – estimate file space usage
-a – write counts for all files, not just directories
-h – print sizes in human readable format (eg. 1K 234M 2G)
sort – sort lines of text files
-n – compare according to string numerical value
-r – reverse the result of comparisons
head – output the first part of files
-n – number of lines
4. What are the Linux boot files?
1./boot/grub/grub.conf: contains boot disk parameters
2./etc/fstab: contains File systems which need to mount at boot time
3./etc/initab: Contains default run level
4./etc/init.d/rc.d/rcN.d: This is a dir it contains
5. Difference between swap partition and swap file?
Swap partition is maintained as a separate partition. Same swap partition can be used for two OS within single machine.
Suppose if the system crashes, there is a chance to recover or it may not  corrupt the partition.
Less fragmented.
Where as swap file takes very less space. We can increase the space very easily, compared to swap partition. Swap file system fragmented.
If  the system crashes then there is a huge chance to lost the swap file system.
6. A file which is not deleted by normal user and also root (using rm), for that type of file how we delete it?
Using chattr command, we need to change the attributes and then we remove using rm command.
Eg: – chattr -iIu example
rm -rf example
7. Difference between nfs soft and hard mounting points?
Hard mount option: – If the client fails to access the server, then the connection hangs and once the system is up then it will again access the server.
Soft: – If the client failed to connect the server, it immediately gives the error report and closes the connection.
8. If we transfer 100 files by ftp to remote server, how to know the files are successfully transfer or some file are not transferred?
ftp>mput 1 2 3 …. 100
ftp> ls –l
9. I know ssh, telnet, dns,apache all are worked on TCP/UDP but i want to know any one service which are working on UDP only?
snmptrap 162/udp
snmptrap – simple network management protocol trap
snmptrapd is an SNMP application that receives and logs
10. I want to built a fire wall using iptables. My condition is ” inbound to 192.168.0.2 with a port of 80 from 172.168.0.1 should accept”
iptables –A INPUT –p tcp –dport 80 –s 172.168.0.1 –d 192.168.0.2 –j ACCEPT
11. I want to see how many interfaces (Ethernet cards) are working using single command?
ifconfig
12. What is the status code 403,404 represented in apache server?
403 represent forbidden error, means if a file misses some selinux security context.
404 represent that there is a cgi script missing or web pages missing.
13. How to monitor ports in a linux machine, with single command?
nmap localhost
14. In my linux machine, i lost /etc/passwd file and /etc/shadow file, then how can i recover it?
Normally in linux we must have backup by default for /etc/passwd and /etc/shadow files
/etc/passwd —> /etc/passwd-
/etc/shadow —> /etc/shadow-
from there we can copy or restore. If both are not available. Then follow below steps:
1. reboot
2. Single user mode [ single init=/bin/bash ]
3. pwconv
4. check /etc/passwd and /etc/shadow files are there
5. sync
6. init 3 or reboot with init 3

15. what r the different command to check ram,process and hdd of linux machine
To check ram in your system:
#free

To check process
#ps
#top
To check hdd
#fdisk
#sfdisk -l
16.If i run ls command it will show me the junk output what is problem and how to resolve it
Set your terminal setting by stty and before that, export ls command to PATH variable
17. WHAT IS THE MEANING OF AIX
AIX (Advanced Interactive eXecutive) is an open operating system from IBM which is based on a version of UNIX. AIX/ESA was designed for IBM’s System/390 or large server hardware platform. AIX/6000 is an operating system that runs on IBM’s workstation platform, the RISC System/6000.
18. Why ls -F dev/log file output indicate as = sign at end of the file name?
Standard output
19. What is nis server?
NIS is a service that provides any user on a network with the same working environment irrespective of the system on that network, which has been used for login purpose.
For example if NIS server is set up in a single system and configured to hold user accounts and their passwords and access information. Then any user on that network can login to his/her account from any system (with nis client running) on that configured network. This gives a look and feel that the user is logged into his/her own system. But actually it’s the account on the NIS server that is mounted on the local sytem user login.
20. What command can you use to review boot messages?
Dmesg
21. Who invented unix?
Unix was created in 1969 by Ken Thompson and Dennis Ritchie at Bell Laboratories.
22. Write a cron entry for the following scenario:- At 10:30 AM for every Sunday of every 1st month of a quarter.
30 10 * 1-12/3 7
23. What is the difference between RHEL4 & RHEL5?
RHEL4: No yum server, Selinux, secure, no cd key
RHEL5: yum server, advanced selinux, more secure, virtualization
24. What is the command to make a process to run in the foreground from background?
When the process is running, press “control+Z”. Now at the command prompt, type “bg”
25. What are the init levels in Linux?
7 level