Monday 11 September 2017

Solaris – Add/remove network interface to a running zone (dynamic Change)

This will describe how to add a network interface to a running non-global zone, without having to reboot the zone. The new interface will persist between reboots.

First you add the entry to the zone configuration. This is the part that lets it persist between reboots. This is done from the global zone:

!-[solaris]# zonecfg -z sunz01
zonecfg:slabsunz01> add net
zonecfg:slabsunz01:net> set address=XXX.XXX.XX.XXX
zonecfg:slabsunz01:net> set physical=bge0
zonecfg:slabsunz01:net> end
zonecfg:slabsunz01> verify
zonecfg:slabsunz01> commit
zonecfg:slabsunz01> exit

Now we have to manually add a new interface to the running zone. Do this from the global zone as well

!-[solaris]# ifconfig bge0 addif XXX.XXX.XX.XXX netmask XXX.XXX.X.X zone sunz01 up

Created new logical interface bge0:3

Note: The ‘addif’ tells ifconfig to create a logical interface using the next available.

!-[solaris]# ifconfig -a
lo0:1: flags=2001000849 mtu 8232 index 1 inet 127.0.0.1 netmask ff000000
bge0:1: flags=1000843 mtu 1500 index 2 inet XXX.XXX.XX.XXX netmask ffffff00 broadcast XXX.XXX.XX.XXX
bge0:3: flags=1000843 mtu 1500 index 2 inet XXX.XXX.XX.XXX netmask ffffff00 broadcast XXX.XXX.XX.XXX

That's it! you're done.

In case you want to remove the interface -

To remove the interface from a running zone. From the global zone, remove the interface. You must first determine which logical interface [alias] you wish to remove.

!-[solaris]# ifconfig bge0:3 down
!-[solaris]# ifconfig bge0:3 unplumb
!-[solaris]# zonecfg -z sunz01
zonecfg:slabsunz01> remove net address=XXX.XXX.XX.XXX
zonecfg:slabsunz01> commit
zonecfg:slabsunz01> exit

Thursday 31 August 2017

Remotely shutdown Linux & windows machine using shell script

Please find the below script for shutdown the Unix & Windows server remotely.

#!/bin/bash

 SSH=/usr/bin/ssh
 POWERCMD="/sbin/shutdown -h now"
 HOSTS="server1 server2 server3"

 # Shutdown remote machines
 for i in $HOSTS;
 do
   $SSH -l root $i $POWERCMD;
 done

  telnet=/usr/bin/telnet
  POWER="C:\Windows\System32\shutdown.exe \s"
  IP="server1 server2 server3"

  # Shutdown window machine
  for i in $IP;
  do
        $telnet -l administrator $i $POWER;
  done

 # Shutdown ourself
 /sbin/shutdown -h now

ifconfig command not found in centos 7 minimal installation

By default in Centos 7 minimal installation , ifconfig command is not found, so for obtaining this command , first you need to check which packages yum provide for this.

[root@localhost]# yum provides ifconfig

Loaded plugins: fastestmirror
Repository 'Packages' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
Packages/filelists_db                                                                                                                              
No matches found

Note: here no packages is installed on the system.

So, using yum we will install the net-tool rpm which is required for ifconfig command

[root@localhost]# yum install net-tools*

Loaded plugins: fastestmirror
Repository 'Packages' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

 Package                  Arch           Version                                   Repository                    Size

Installing:
 net-tools                x86_64         2.0-0.17.20131004git.el7         Packages                        304 k

Transaction Summary
========================================================================
Install  1 Package

Total download size: 304 k
Installed size: 917 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.17.20131004git.el7.x86_64                                                                     1/1
Verifying  : net-tools-2.0-0.17.20131004git.el7.x86_64                                                                    1/1

Installed:
net-tools.x86_64 0:2.0-0.17.20131004git.el7

Complete!

Now run the ifconfig command after successfully installed the packages.

[root@localhost]# ifconfig -a
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.26.12.1  netmask 255.255.0.0  broadcast 192.26.255.255
        inet6 fe80::250:56ff:febf:f6  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:bf:00:f6  txqueuelen 1000  (Ethernet)
        RX packets 18939  bytes 1251073 (1.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 433  bytes 63109 (61.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost]# yum provides ifconfig

Loaded plugins: fastestmirror
Repository 'Packages' is missing name in configuration, using id
Loading mirror speeds from cached hostfile
net-tools-2.0-0.17.20131004git.el7.x86_64 : Basic networking tools
Repo: @Packages
Matched from:
Filename: /usr/sbin/ifconfig

Monday 24 July 2017

How to reset or change root password in AIX Operating System

If you forgotten the root password on AIX server, then please follow the below step by step method to recover or reset the root password.
 
➥ You need to insert the operating system same version media disk on cd/dvd rom and power on the AIX machine.
 
➥ When the screen of icons appears, or you hear a double beep sound from hardware of AIX, please press the F1 key repeatedly until the System Management Services menu appears.
 
➥ Select Multi boot option from the SMS (System Management Services) menu
 
➥ Select Install From option from multi boot screen.
 
➥ Select the device (CD rom) that keep the AIX operating system image and then select Install.
 
➥ Select the AIX version icon from the screen menu.
 
➥ Please describe your current system as the system console by pressing the F1 key and then press Enter.
 
➥ In this step you need to select the number of your preferred language and press Enter. In my case I use global language "English".
 
➥ Once you select the language in this step you need to select Start Maintenance Mode for System Recovery by typing 3 and press Enter.
 
➥ In the second last step you can ignore the messages like that "select Access a Root Volume Group".

A message displays explaining that you will not be able to return to the Installation menus without rebooting if you change the root volume group at this point.
 
➥ Please Type 0 and press Enter.

Type the number of the appropriate volume group from the list and press Enter.

Select Access this Volume Group and start a shell by typing 1 and press Enter.

At the # (number sign) prompt, type the passwd command at the command line prompt to reset the root password.

# passwd
Changing password for "root"
root's New password:
Enter the new password again:
 
➥ In the final step , you need to write everything from the buffer to the hard disk and reboot the system.

sync;sync;sync;reboot

When the login screen appears, the password you set in above step 11 should now permit access to root privileges.

Tuesday 18 July 2017

How to use zoneadm command in Solaris Servers

Please find the "zoneadm" commands with an example as describe below.
 
How to Verify a Solaris zone:

To verify the local solaris zone you need to run the below command with syntax.

!-[solaris]#zoneadm -z <zone> verify

Example: !-[solaris]#zoneadm -z sunz01 verify

In this example once you run the above command, if your zone is installed properly without any error then this is not showing you any output, that's means it is verified. After running the command if it is showing a message then you need to check the configuration of this zone.

How to Installing a Solaris zone:

To install the local Solaris zone you need to run the below command with syntax.

!-[solaris]#zoneadm -z <zone> install

Example: !-[solaris]#zoneadm -z sunz01 install

In this example when you run the above command then your local zone has been started for installation. It is installed the local zone using the Solaris repostiory or flar images which you are kept at server location.

How to Ready a Solaris zone:

To move the local zone in ready or maintainance state you need to run the below command.

!-[solaris]#zoneadm -z <zone> ready

Example: !-[solaris]#zoneadm -z sunz01 ready

In this example, when we run the above command then your local zone moved in to ready or maintianance state.

How to Boot a Solaris zone:

To boot the solaris zone on global system, you need to run the below command with syantx.

!-[solaris]#zoneadm -z <zone> boot

Example: !-[solaris]#zoneadm -z sunz01 boot

After running the above command your local solaris zone has been boot successfully if it is not showing any error during boot time. If you see any message during the boot time then please check where is the issue.

How to Reboot a Solaris zone:

To reboot or restart the solaris zone on Solaris server, you need to perform the below command on global zone.

!-[solaris]#zoneadm -z <zone> reboot

Example: !-[solaris]#zoneadm -z sunz01 reboot

Using this command the local zone "sunz01" has been restart again successfully. You need to run this command from global zone only.

➤ How to Shutdown/Halt a Solaris zone:

If you want to shutdown or halt your local zone without login it, then you need to run the below command from global zone.

!-[solaris]#zoneadm -z <zone> halt

Example: !-[solaris]#zoneadm -z sunz01 halt

After running this command local solaris zone state change from running to installed state that's means your server is shutdown now.

How to Uninstall a Solaris zone:

If you want to uninstall any solaris zone then you need to run the below command for uninstall the zone.

!-[solaris]#zoneadm -z <zone> uninstall -F

Example: !-[solaris]#zoneadm -z sunz01 uninstall -F

"-F" syntax is used to uninstall the zone forcefully.

How to Viewing a Solaris zone:

if you want to local zone current status and any other display information you need to run the below command.

!-[solaris]#zoneadm list -icv

 ID NAME       STATUS      PATH               BRAND   IP
   0 global         running        /                        solaris      shared
   1 sunz01        running       /zones/sunz01   solaris      excl
   2 sunz02        running       /zones/sunz02   solaris      excl

Using above command you can check the current status of all installed zones on Solaris server. It is show you the zone path and zone information. All the above command you need to run from Global zone with root privileges

Solaris Package administration in Solaris 10 Operating System

In this article, we will provide all the commands with an example which describe as below.

pkginfo- It displays all software package information.
pkgadd- It installs all software packages to the system.
pkgrm- It removes a package from the system.
pkgchk- It checks package installation state.
pkgtrans- It translates packages from one server format to another.

Commands & Syntax for checking a package information:

For checking a packages information on Solaris 10 operating system we will used the "pkginfo" command. You can find the all command and syntax related to "pkginfo" is listed below.

Please use the below command to display information about installed software packages.

!-[solaris]# pkginfo | more

Please use the below command to view additional information.

!-[solaris]# pkginfo -l | more

Please use the below command to view information of a specific package.

!-[solaris]# pkginfo -l SUNWman

Please use the below command to find how many packages are currently installed.

!-[solaris]# pkginfo | wc -l

To list all installed software packages, please use the below command.

!-[solaris]# more /var/sadm/install/contents

These above commands with their syntax are daily used on Solaris 10 platform.

Commands & Syntax for checking a package installation:

For checking an information about packages are installed or not on the server , we need to use "pkgchk"  command. Please find the below example as describe below.

Please use the below command to check the contents & attributes of a currently installed package.

!-[solaris]# pkgchk SUNWpkgs

Please use the below command to list the all files contained in a software package.

!-[solaris]# pkgchk -v SUNWpkgs

Please use the below commands to find if the contents & attributes of a file have changed since it was installed with its software package.

!-[solaris]# pkgchk -p /etc/shadow 

Please use the below commands to list information about selected files that make up a package.

!-[solaris]# pkgchk -l -p /usr/bin/showrev

If the packages is installed already then in that case "pkgchk" command don't show any output that clear meaning is that packages is already installed on the server.

Commands & Syntax for adding a package software:

For adding a packages on the server, we will used the "pkgadd" command. Please find the below commands and their syntax which is daily used on Solaris operating system.

Please use the below command to add a software packages from DVD. For this you need to move on dvd directory where all the packages are listed.

!-[solaris]# pkgadd -d . SUNWpkgs

Using above command you can add the packages from DVD.

Commands & Syntax for removing a package software:

For removing the packages from the server, we will used "pkgrm" command. Please find the below commands and their syntax as listed below.

Please use the below command to remove the software packages.

!-[solaris]# pkgrm SUNWpkgs

Please use the below command to remove a package from the spool directory.

!-[solaris]# pkgrm -s /export/pkg SUNWldam

Commands & Syntax for translating a packages format:

For translating a packages format from one format to another , we will used the "pkgtrans" command for the same.

Please use the below command to translate a package from file system format in /var/tmp to data stream format.

!-[solaris]# pkgtrans /var/tmp /tmp/SUNWpkgs.pkg SUNWpkgs

Please use the below command to create a data streamed package.

!-[solaris]# pkgtrans -s Product /var/tmp/stream.pkg SUNWpkgg SUNWpkgs

NFS mount on Solaris 11 Non-Global zones systems

In this article, we would learn how we mount folder from one Non-Global zone to another zone on Solaris 11 operating system using network file sharing.

For an example, we can use take a two local zone "sunz01" & "sunz02". We will mount one folder named "/export/backup" from "sunz01" local zone to another zone "sunz02" on "/project/export/data" location.

Step by Step method of NFS mount on Solaris 11:
 
➦ In the first step we will create the directory on "sunz02" zone where we want to mount the folder.

sunz02#mkdir /project/export/data
 
➦ In second step, we will make a configuration for this process. So for this work you need to login on global zone with root access and make an entry on the dfstb configuration file.

sun#vi /etc/dfs/dfstab

share -F nfs -o rw=sunz02 /zones/sunz01/root/export

If you see the above entry, we have provided the read/write access to directory on sunz02 server where we mount the folder from sunz01 local zone.
 
➦ In next step you need to login on sunz02 server and mount the shared folder using below command.

sunz02#mount sun:/zones/sunz01/root/export/backup /project/export/data
 
➦ Once you run the above command the folder is mount from one local zone to another zone temporarily. You can go to the directory and verify that the data which is listed on /export/backup folder is show on sunz02 directory.
 
➦ In the last step you need to restart the NFS service on the global zone so the configuration files and other changes makes affect. But these configuration are available until we are not taking reboot of the zone.

If you have any query regarding this topic, please post your comment here, we will get back to you shortly.