Thursday 21 December 2017

Multipath command with an examples

In linux operating system device mapping through multipath is widely used. Here, we can give you some example how we will use the multipath commands in Linux server

➤ Normally multipath device has a Word Wide Identifier (WWID), which is globally unique and unchanging.

➤ When new devices are brought under the control of DM-Multipath, the new devices may be seen in three different places under the /dev directory: /dev/mapper/mpathn, /dev/mpath/mpathn, and /dev/dm-n

➤ The devices in /dev/mapper are created early in the boot process. Use these devices to access the multipathed devices, for example when creating logical volumes.
The devices in /dev/mpath are provided as a convenience so that all multipathed devices can be seen in one directory. These devices are created by the udev device manager and may not be available on startup when the system needs to access them.

Note: Do not use these devices for creating logical volumes or filesystems

➤ Any devices of the form /dev/dm-n are for internal use only and should never be used.

Please find the multipath syntax which we used in the Linux operating system.


l    -> Display the current multipath configuration gathered from sysfs and the device mapper.
ll  -> Display the current multipath configuration gathered from sysfs, the device mapper, and all other available components on the system.
f    -> Remove the named multipath device.
F   -> Remove all unused multipath devices.
v   ->  Verbosity level
          . 0 no output
          . 1 print created devmap names only
          . 2 default verbosity
          . 3 print debug information
d   -> Dry run, do not create or update devmaps
r    -> Force devmap reload

⧪ How to display the current multipath configuration with all information.

[root@localhost~]# multipath -ll
Dec 21 11:27:17 | multipath.conf line 35, invalid keyword: selector
mpathf (3600c0ff00019e9e9dc94c25801000000) dm-6 HP,MSA 2040 SAN
size=466G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=70 status=active
  |- 1:0:0:4 sdg 8:96 active ready running
  |- 2:0:0:4 sdj 8:144 active ready running
  |- 1:0:1:4 sdq 65:0 active ready running
  `- 2:0:1:4 sdt 65:48 active ready running

⧪ How to remove multipath devices with multipath Command

[root@localhost~]# multipath -f mpathf

Note: if we use -F option then it is remove all unused devices.

⧪ How to Force reload device map with multipath Command

[root@localhost~]# multipath -r

Solaris Server process Monitoring tool- prstat

We have different type of tools and command which are used in Solaris or other Unix system to monitor the system process. But if we are talking about only Sun Solaris server then we have very good process tool which is called "prstat".

In this post, we will find that how prstat is work on the Solaris platform.

   !-[solaris]# prstat

When you run the above command on the command line you will get the below output on the CLI screen which are refreshing in every few seconds and sorting all the information regarding the system resource.

  PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP

 21322 root      11M 3236K cpu0    59    0   0:00:00 0.0% prstat/1

 21323 root      18M 4788K sleep   59    0   0:00:00 0.0% sshd/1

 22345 root      10M 2188K sleep   59    0   0:00:00 0.0% bash/1

   584 root       13M 3832K sleep   59    0   0:01:59 0.0% nscd/51

   154 root       13M 2068K sleep   59    0   0:00:00 0.0% syseventd/18

   183 root     1772K  776K sleep   59    0   0:00:13 0.0% utmpd/1

   538 root       11M 2572K sleep   59    0   0:00:00 0.0% picld/4

Total: 12 processes, 31 lwps, load averages: 0.00, 0.00, 0.00


This is a quick view of the prstat command but if you wanted to get a different view of the same info, like a summary of what users own these CPU consuming processes

   !-[solaris]# prstat -a

If you run prstat with the -a option (prstat -a) you will get an output similar to the default one, but the last few lines of it will be used for providing a really useful report of the users consuming top system resources.


  PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP

 21322 root      11M 3236K cpu0    59    0   0:00:00 0.0% prstat/1

 21323 root      18M 4788K sleep   59    0   0:00:00 0.0% sshd/1

 22345 root      10M 2188K sleep   59    0   0:00:00 0.0% bash/1


 NPROC USERNAME  SWAP   RSS MEMORY      TIME  CPU

     5 root      52M   13M   1.3%   0:00:00 0.0%

    50 root      841M  571M    56%   0:22:22 0.0%

     2 daemon     17M 4520K   0.4%   0:00:04 0.0%

Total: 12 processes, 31 lwps, load averages: 0.00, 0.00, 0.00

We have different type of syntax which we can used to monitor the Solaris server process which are listed below.

!-[solaris]# prstat -L  -> This shows thread per line instead of one process per line
!-[solaris]# prstat -s -> prstat output can be sorted using set of sub-options .sub options are                  cpu,pri,rss,size,time 
!-[solaris]# prstat -t  -> It provides complete users resource utilization.
!-[solaris]# prstat -Z  -> It provides summary per local zone.

Sunday 10 December 2017

How to check number of CPU and processor in linux operating system

In this post, we will find all the command using which we can find that how many CPU and processor are used in Linux operating system.

⇾ This command are applicable in both RedHat & CentOS operating machine.

➤ How to check number of processor on operating system.

      cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l

   Using above command it show you the number of processor which are currently used on server.

➤ How to check number of cores on Linux operating system.

     cat /proc/cpuinfo | grep "core id" | sort -u | wc -l

➤ You can used other command as well like "lscpu" to check number of processor and core per socket.

➤ Please find the other command which are also used to check the number of processor and cores in  Linux operating system.

    cat /proc/cpuinfo | grep 'model name' | uniq
   cat /proc/cpuinfo | grep "physical id" | sort -u | wc -l
   cat /proc/cpuinfo | grep "core id" | sort -u | wc -l

Monday 30 October 2017

How to change a disk in SVM Solaris volume manager

In this post, I will take my sparc server machine. My Sun Sparc server consist 2 hard disk, let us assume the server has 2 hard disk: c0t0d0 and c0t1d0. We will assume c0t0d0 failed and need to be replaced.

Step by Step Method as described below:

1. In the initial step, we will find that which hard disk is down or faulty. To check this we will used "format" command.

!-[solaris]## format
       0. c0t0d0 <__drive type unknown__>
          /pci@0,600000/pci@0/pci@8/pci@0/scsi@1/sd@0,0
       1. c0t1d0 <SUN146G cyl 14087 alt 2 hd 24 sec 848>
          /pci@0,600000/pci@0/pci@8/pci@0/scsi@1/sd@1,0

If you see the "format" command output, we have two disk "c0t0d0,c0t1d0". Disk "c0t0d0" is in faulty state and it's down, You can see the drive type is in unknown state.

2. If you are running the "metastat" command you can see the status of hard disk which is show status in "need maintenance".

!-[solaris]## metastat    # will show status in "need maintenance"

        flags           first blk       block count
     a        u         16              8192            /dev/dsk/c0t0d0s7
     a        u         8208            8192            /dev/dsk/c0t0d0s7
     a    p  luo        16              8192            /dev/dsk/c0t1d0s7
     a    p  luo        8208            8192            /dev/dsk/c0t1d0s7

!-[solaris]## metadb -d c0t0d0s7
!-[solaris]## metadb

Using above command we delete metadb on failing disk and check that metadb on the other disk.

4. Now, we will unconfigure the corresponding disk which is down right now. This is the main step of this post so you can more careful while running the command which is given below.

!-[solaris]## cfgadm -al
!-[solaris]## cfgadm -f -c unconfigure c0::dsk/c0t0d0
!-[solaris]## cfgadm -al

Using cfgadm command we will unconfigure the c0t0d0 faulty hard disk so that we will replace the down hard disk in next step.

5. Now you can change the faulty disk to new one and reconfigure it again with same name.

!-[solaris]## cfgadm -c configure c0::dsk/c0t0d0
!-[solaris]## cfgadm -al

6. In this steo we will duplicate partitionning schema of first disk to the second and create metadb.

!-[solaris]## prtvtoc /dev/rdsk/c0t1d0s2 | fmthard -s - /dev/rdsk/c0t0d0s2
!-[solaris]## metadb -a -f -c2 /dev/dsk/c0t0d0s7

7. In second last step you will run all the below command for replacement of the failinf SVM partition.

!-[solaris]## metastat
!-[solaris]## metareplace -ef d4 c0t0d0s4
!-[solaris]## metareplace -ef d3 c0t0d0s3
!-[solaris]## metareplace -ef d1 c0t0d0s1
!-[solaris]## metareplace -ef d0 c0t0d0s0
!-[solaris]## metareplace -ef d5 c0t0d0s5
!-[solaris]## metareplace -ef d6 c0t0d0s6
!-[solaris]## metasync d0
!-[solaris]## metasync d1
!-[solaris]## metasync d3
!-[solaris]## metasync d4
!-[solaris]## metasync d5
!-[solaris]## metasync d6
!-[solaris]## metasync d7

8. In final step you need to make the disk bootable so that operating system will be boot on the mirror disk.

!-[solaris]## installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c0t0d0s0

Using this step you can make a disk bootable. I hope this post is useful for you. You are requested to please comment on the post if you have any issue, I will try to back you with my answer.

Thursday 26 October 2017

Useful SQL command for MySQL database on Linux Operating System

This post related to MySQL database SQL command which is used in daily database work by database administrator.

Please find the below points which is very useful to database admin on Linux operating system.

How to create new database:

 CREATE DATABASE <DATABASENAME>;

 e.g. CREATE DATABASE XYZ;

In this example I have created the "XYZ" named database, you can replace database name according to your choice.

How to create mater user with all level access to all available databases:

 GRANT ALL ON *.* TO <USERNAME> IDENTIFIED BY '<PASSWORD>';
 e.g.  GRANT ALL ON *.* TO TESTDBUSER IDENTIFIED BY 'TESTDBUSER';

In this example I used "testdbuser" MySQL user on the server.

How to take backup (dump) of a database:

For this command you need not to login into the database. Once you login on the database please run the below command to take a dump of server.

 mysqldump --lock-all-tables -u <USERNAME> -p -h <DATABASESERVERNAME/IP ADDRESS> <DATABASENAME> > <NEWDUMPFILENAME>.sql

 e.g. mysqldump --lock-all-tables -u ABC -p -h MACHINE1 XYZ > XYZ_16022017.sql

After this command you have to provide DB password only and dump will be done in the folder in which u are working currently.

How to take backup (dump) of a table's:

For this command you need not to login into the database.

 mysqldump -u <USERNAME> -p <DATABASENAME> <TABLENAME> > <NEWDUMPFILENAME>.sql

 e.g. mysqldump -u testdbuser -p testdb test_book > test.sql

After this command you have to provide DB password only and dump will be done in the folder in which u are working currently. for dumping multiple table use space between the table names.

How to run a database dump to another machine:

Go to the folder in which sql dump file is placed and then connect with your Database in which you want to run dump and then run below command.

 source <FILENAME>.sql;

 e.g source XYZ_16022017.sql;

How to take dump only triggers and procedure from database:

 mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt -u <USERNAME> -p <DATABASENAME> > <NEWDUMPFILENAME>.sql

 e.g. mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt -u TESTDBSUER -p XYZ > XYZ_16022017.sql

After this command you have to provide DB password only and dump will be done in the folder in which u are working currently.

How to show procedure/function code:

 SHOW CREATE PROCEDURE <STORED PROCEDURE/FUNCTION NAME>\G

 e.g. SHOW CREATE PROCEDURE FLIGHT_INVOICETOSAP\G;

How to increase filed width of a table attribute:

 ALTER TABLE <TABLENAME> CHANGE <EXISTING_FIELD_NAME> <NEW_FIELD_NAME> <DATATYPE>(<NEW_FIELD_WIDTH>);

 e.g. ALTER TABLE TRILOK CHANGE PASSENGER_NO PASSENGER_NUMBER VARCHAR(30);

field name and data type change is not recommended.

How to display all existing databases:

 SHOW DATABASES;

Using this command you can show all the created database list on the Linux server.

How to display all existing tables:

 SHOW TABLES;
 SHOW TABLES LIKE '<CHARACTERS>%';

Using this command you can check all the tables which is created on the database.

How to recover a MySQL root password:

This is one of the best way to recover the MySQL root password if you forget. I always used below method to reset the root password.
Stop the MySQL server process.

  # /etc/init.d/mysql stop
Start again with no grant tables.

  # mysqld_safe --skip-grant-tables &
Login to MySQL as root. Set new password.

  # mysql -u root
  mysql> use mysql;
  mysql> update user set password=PASSWORD("newrootpassword") where User='root';
  mysql> flush privileges;
  mysql> quit
Exit MySQL and restart MySQL server.

  # /etc/init.d/mysql stop
  # /etc/init.d/mysql start
Set a root password if there is on root password.

  # mysqladmin -u root password newpassword
Update a root password.

  # mysqladmin -u root -p oldpassword newpassword

How to grant privileges to a user:

If we need to provide the privileges to user we will use below two method. I will describe the step by step method for this one.

METHOD 1

Allow the user "bob" to connect to the server from localhost using the password "passwd". Login as root. Switch to the MySQL db. Give privs. Update privs.

  # mysql -u root -p
  mysql> use mysql;
  mysql> grant usage on *.* to bob@localhost identified by 'passwd';
  mysql> flush privileges;

Give user privileges for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs.

  # mysql -u root -p
  mysql> use mysql;
  mysql>INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES ('%','databasename','username','Y','Y','Y','Y','Y','N');
  mysql> flush privileges;

METHOD 2

  mysql> grant all privileges on databasename.* to username@localhost;
  mysql> flush privileges;

To update info already in a table.

Load a CSV file into a table:

 mysql> LOAD DATA INFILE '/tmp/filename.csv' replace INTO TABLE [table name] FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (field1,field2,field3);

Dump all databases for backup:

Backup file is SQL commands to recreate all databases.

  # [mysql dir]/bin/mysqldump -u root -ppassword --opt >/tmp/alldatabases.sql

Dump one database for backup.

  # [mysql dir]/bin/mysqldump -u username -p password --databases databasename >/tmp/databasename.sql

Dump a table from a database.

  # [mysql dir]/bin/mysqldump -c -u username -p password databasename tablename > /tmp/databasename.tablename.sql

Restore database (or database table) from backup.

  # [mysql dir]/bin/mysql -u username -p password databasename < /tmp/databasename.sql
  Create Table Example 1.

Using above method we can take database back very fast. I hope through this post you can easily able to create MySQL database, MySQL dump, table creation etc work.

Friday 20 October 2017

Solaris zone: error: net0: failed to create VNIC: operation not supported

In this post, I will discuss with you one of the most interesting error which I am facing when I boot the local zone on Solaris 11.3. The description of this interesting issue as describe below.

Description of error:

!-[solaris]# zoneadm -z sun01 boot

zone 'sun01': error: net0: failed to create VNIC: operation not supported

zoneadm: zone sun01: call to zoneadmd(1M) failed: zoneadmd(1M

I have try to create and configure the  VNIC on Solaris 11.3 operating server but it get failed with the same error.

!-[solaris]#dladm create-vnic -l net0 vnic01

dladm: vnic creation failed: operation not supported

If you are also facing a such error while booting the local zone on solaris 11 server, then please use the below solution to resolve such issues.

Solution of error:

➥ This error "failed to create VNIC: operation not supported" would normally come when there are not enough mac addresses to assign to the zone. So now we need to add alternate mac addresses to the network interface.So before adding the new mac address we will stop LDM.

!-[solaris]#ldm list-domain

NAME            STATE     FLAGS  CONS   VCPU MEMORY  UTIL NORM UPTIME

primary         active    -n-cv- UART   8    8G      2.0% 2.0% 41d 20h 14m

0004fb0000060000ff1d3d8336112f6f active    -n---- 5001   50   64G     0.1% 0.1% 18h 23m

➥ Now log in to the Solaris global zone and check if net0 have additional MAC addresses or not. Please use the below command to check the status.

!-[solaris]# dladm show-phys -m

LINK               SLOT    ADDRESS           INUSE CLIENT

net0               primary 0:21:f6:d6:d3:e5  yes  net0

                   1       0:14:4f:f9:6d:8d  no   --

                   2       0:14:4f:fb:10:2b  no   --

                   3       0:14:4f:f9:41:d6  no   --

                   4       0:14:4f:f8:dd:c8  no   --

net1               primary 0:21:f6:51:be:4d  yes  net1

➥ Now zone will start without any issue, as we have assigned the new mac address to this zone.

!-[solaris]# zoneadm -z sun01 start

Please let me know if you are facing any issue regarding this error.

How to mount CIFS file system on Linux Operating Server

Step by Step method for Mount CIFS on Linux Server:

➤ In the initial step we will gather all rpm's or packages information which is required for CIFS file system.

[root@localhost]# rpm -qa | grep cifs 
cifs-utils-4.8.1-20.el6.x86_64

if you see the above output, this packages is required for CIFS file system on Linux system. So you can install this rpm using rpm command if you have rpm packages on the server otherwise you will install the packages using YUM utility.

[root@localhost]#rpm -ivh cifs-utils-4.8.1-20.el6.x86_64.rpm

if you are using YUM, then please install the packages using below command.

[root@localhost]#yum install cifs-utils*

it is installed all required dependency related to CIFS file system.

➤ In this step, we will create the mount point on the server where we need to mount the CIFS file system.

[root@localhost]# mkdir -p /backup/cifs

We will create the above mount directory where i will mount the file system.

➤ Now, we will create a CIFS user and assign a password so the user can access mount folder.

[root@localhost]# touch /etc/cifspasswd
[root@localhost]# chmod 600 /etc/cifspasswd

[root@localhost]#vi /etc/cifspasswd

user=castwebsvc
password=*******

➤ In this step we need to make a permanent entry of mounted file system so once we reboot the machine mounted file system not umount.

[root@localhost]# vi /etc/fstab

ADD fstab entry :

//WindowsServer/share /mount/point cifs rw,mand,user=USER,password=PASS 0 0

Example :
//192.168.0.1/CAST_data4/AICCodeUpload  /backup/cifs cifs   rw,mand,credentials=/etc/cifspasswd         0 0

You can take an example for your system. Please change the mount point as per your requirement.

➤ In the final step you need to mount the file system using below command.

[root@localhost]# mount /backup/cifs
[root@localhost]# mount -a

Using above command the CIFS file system has been mounted successfully.

How to configure NTP server and client on Solaris 10 and Solaris 11

As you know NTP ( Network time Protocol) is one of the oldest internet protocol still in use and it allows the synchronization of computer clocks distributing UTC (Coordinated Universal Time) over the network.

NTP Service on Solaris 10 and Solaris 11:

Solaris 10 used the SMF utility (Service Management Facility) and the NTP service is now managed by SMF (Service Management Facility). NTP daemon configured using Service management facility (svc:/network/ntp:default) and a bunch of sample ntp.conf files to quickly configure a machine as a client or as a server. On Solaris 11 only ships with NTP v. 4, the NTP v. 4 service is identified by the name ntp4. You can check the ntp status using below command.

!-[solaris]# svcs status ntp

STATE  STIME   FMRI
online 10:14:23 svc:/network/ntp:default

If you see the above command output it is shown that network time protocol services is enable and online on the server.

Steps for Configuring a NTP client:

Suppose your machine is just a client machine, then you can just take the /etc/inet/ntp.client file and copy it to /etc/inet/ntp.conf.

multicastclient 127.0.0.1

If you see the configuration it's a passive configuration for a Server host which listens for NTP server putting packets on the NTP multicast network, 127.0.0.1. If your machine is on LAN without NTP server then in that case we are not recveied any packet and for this we need to use Public NTP server for host.

In my case, I'm using the Indian pool in.pool.ntp.org and my configuration file contains:

server 2.in.pool.ntp.org
server 1.asia.pool.ntp.org
server 3.asia.pool.ntp.org

Normally NTP requires a poll period to elapse before starting synchronizing your clock. If you want NTP to start immediately, which you most probably will if you're configuring a desktop environment, you can take advantage of iburst keyword, introduced in NTP v. 4: it instructs NTP to start the synchronization almost right away.

server 2.in.pool.ntp.org ibrust
server 1.asia.pool.ntp.org ibrust
server 3.asia.pool.ntp.org ibrust

You must make sure you're configuring NTP implementation corresponding to the syntax you're using.

Setting up the drift file:

The last thing which is remaining for NTP server setup in the client machine is to set up  drift file location. On my machine it is 

driftfile /var/ntp/ntp.drift

After setup the drift file configuration we will start the NTP servivce again 

!-[solaris]# svcadm restart svc:/network/ntp:default
!-[solaris]# svcs status svc:/network/ntp:default
STATE  STIME   FMRI
online 12:20:12 svc:/network/ntp:default 

Once the service is running, you can check which server you're using with ntpq, Please run the below command to check the ntpq.

!-[solaris]# ntpq -p

Setting up an NTP server:

Now in above step you see the NTP service has been started successfully, so now, you'll probably want to setup all of your machines.

If you're in a LAN, you can setup an internal NTP server which will provide data to other clients on your LAN. As before, you can take inspiration from the server configuration file shipped with Solaris 10 or Solaris 11, /etc/inet/ntp.server.

After setting up the drift file and the clients you're going to use, you can examine the other options and fine-tune them at your taste. Let's give a quick look at it.

server 127.127.XType.0

Now you have configured the NTP server properly. Please comment on the post if you have any suggestion.

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.

Thursday 13 July 2017

How to mount CIFS file system on Linux Operating server machine

Generally on linux or Unix operating system servers when we are mounting the any other linux machine folder is quite easiy in comparision to mount the window shared folder on linux machine.

Step by Step method for Mount CIFS on Linux Server:
 
➤ In the initial step we will gather all rpm's or packages information which is required for CIFS file system.

[root@localhost]# rpm -qa | grep cifs
cifs-utils-4.8.1-20.el6.x86_64

if you see the above output, this packages is required for CIFS file system on Linux system. So you can install this rpm using rpm command if you have rpm packages on the server otherwise you will install the packages using YUM utility.

[root@localhost]# rpm -ivh cifs-utils-4.8.1-20.el6.x86_64.rpm

if you are using YUM, then please install the packages using below command.

[root@localhost]# yum install cifs-utils*

it is installed all required dependency related to CIFS file system.
 
➤ In this step, we will create the mount point on the server where we need to mount the CIFS file system.

[root@localhost]# mkdir -p /backup/cifs

We will create the above mount directory where i will mount the file system.
 
➤ Now, we will create a CIFS user and assign a password so the user can access mount folder.

[root@localhost]# touch /etc/cifspasswd
[root@localhost]# chmod 600 /etc/cifspasswd

[root@localhost]# vi /etc/cifspasswd

user=castwebsvc
password=*******
 
➤ In this step we need to make a permanent entry of mounted file system so once we reboot the machine mounted file system not umount.

[root@localhost]# vi /etc/fstab

ADD fstab entry :

//WindowsServer/share /mount/point cifs rw,mand,user=USER,password=PASS 0 0

Example :
//192.168.0.1/CAST_data4/AICCodeUpload  /backup/cifs cifs   rw,mand,credentials=/etc/cifspasswd         0 0

You can take an example for your system. Please change the mount point as per your requirement.
 
➤ In the final step you need to mount the file system using below command.

[root@localhost]# mount /backup/cifs
[root@localhost]# mount -a

Using above command the CIFS file system has been mounted successfully

How To Fix “Device eth0 does not seem to be present, delaying initialization” Error

This Ethernet card error is normally occur on Linux operating system like CentOS, Red Hat Linux etc. When you try to up the Ethernet card it is showing you the above topic error.

So in this post, we will provide you the step by step solutions and troubleshoot all the issue related this error.

In the initial step, you will check which Ethernet card is down , for this you can run the "ifconfig -a" command. Using this command you can check how many internet card is present on the server and on which Ethernet card used IP address.

Let's suppose you are using eth0 on your machine, and if this Ethernet card not taking any ip address and now show on your device that means it is down right now, so please try to start Eth0 device as given below command.

[root@localhost]# ifup eth0
Device eth0 does not seem to be present, delaying initialization

If your internet card show such issue that means you have an issue with MAC address. So in this post I would explain you how to resolve such issue.

1. In this step, please check the MAC Addresses are set correctly or not. For checking this you need to go the network card directory "/etc/sysconfig/network-scripts"

[root@localhost]# cd /etc/sysconfig/network-scripts

[root@localhost]# cat ifcfg-eth0

HWADDR=”00:15:5D:00:91:91”

In the configuration file, you can see the current hardware address of eth0 card, I have show you only HWADDR entry of my eth0 file. In this directory you can see if other Ethernet card is present or not. In my Linux machine i have two Ethernet card , please find the below second Ethernet card MAC address.

[root@localhost]# cat ifcfg-eth1

HWADDR=”00:15:5D:00:91:90”

2. Now we will see which link is present on the system currently and which is not active, for this you can use the below command to check the status.

[root@localhost]# ip -o link

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN \    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000\    link/ether 00:15:5D:00:91:90 brd ff:ff:ff:ff:ff:ff

3: eth2: mtu 1500 qdisc   pfifo_fast state UP qlen 1000\ link/ether 00:15:5D:00:91:91 brd ff:ff:ff:ff:ff:ff

Here, no eth1 but there is an eth2 present on the system, so might be problem is that the eth0 is renamed to eth2 but we will confirm with below command.

[root@localhost]# dmesg | grep eth0

udev: renamed network interface eth0 to eth2
udev: renamed network interface rename3 to eth0

From this command it shows that udev rename the network interface, so in the next step we will remove the wrong entry and configure the Ethernet card 

3. Now please open the network rules file to confirm the mac address. Please open this file "/etc/udev/rules.d/70-persistent-net.rules" 

[root@localhost]# cat /etc/udev/rules.d/70-persistent-net.rules

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:5d:00:91:90", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:5d:00:91:91", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:15:5d:00:91:91", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Looks like there are multiple entries for the same MAC address. Removed the incorrect entry and restart the interface using below command.

[root@localhost]# ifup eth0

Now you eth0 card is up and if you are running "ifconfig -a" command you can see the eth0 card with mac address.