Script

#!/bin/bash
H=`hostname`
cpu=`nproc`
GB=1024
echo -e “—————————————————————————————————————————-”
echo -e “\t Hardware Resource and Model”
echo -e “—————————————————————————————————————————-”
echo -e “CPU Resources Allocated = $cpu core”
M=`dmidecode -t 17 | grep -w MB | awk ‘{ SUM += $2} END { print SUM }’`
res=$(echo “scale=3;$M/$GB” | bc)
echo -e “Memory Resoruces Allocated = $res GB”
P=`dmidecode -t processor | grep -i intel | grep -i version | head -1 | cut -d’:’ -f2`
echo -e “Processor Model = $P”
TH=`fdisk -l | grep -i sd | grep -i gb |wc -l`
echo -e “Total Number Disk connected = $TH”
TSH=`fdisk -l | grep -i sd | grep -i gb | awk ‘{ SUM += $3} END { print SUM }’`
dkres=$(echo “scale=3;$TSH/$GB” |bc)
echo -e “Total Size of all Disk = $dkres TB”
NN=`lspci | grep -i ethernet | cut -d ‘:’ -f3 | head -1`
echo -e “Network Interface card Model = $NN”
TN=`lspci | grep -i ethernet | wc -l`
echo -e “Total Number of NIC Connected = $TN”
NS=`ethtool eth0 | grep -i speed |awk ‘{print $2,$3}’`
echo -e “Network Interface Speed = $NS”
echo -e “—————————————————————————————————————————-”

Output:-
[root@VM ~]# ./test.sh
————————————————————————————-
Hardware Resource and Model
————————————————————————————-
CPU Resources Allocated = 16 core
Memory Resoruces Allocated = 32.000 GB
Processor Model = Intel(R) Xeon(R) CPU E5-2680 v3 @ 2.50GHz
Total Number Disk connected = 8
Total Size of all Disk = 7.891 TB
Network Interface card Model = VMware VMXNET3 Ethernet Controller (rev 01)
Total Number of NIC Connected = 1
Network Interface Speed = 10000Mb/s
————————————————————————————-


Command to find out when (Time & Date) i connected HDD or added HDD in Linux Box

[root@vm1 ~]# ll /dev/sd*
brw-rw—- 1 root disk 8,  0 Mar  8 11:03 /dev/sda
brw-rw—- 1 root disk 8,  1 Mar  8 11:03 /dev/sda1
brw-rw—- 1 root disk 8,  2 Mar  8 11:03 /dev/sda2
brw-rw—- 1 root disk 8, 16 Mar 13 07:42 /dev/sdb


screenshot_2

 

Fix

while doing pxe boot of any VM or server we will give mac address under this path /tftpboot/linux-install/pxelinux.cfg that time if u gave Upper mac address as below  it will fail

lrwxrwxrwx 1 root root  10 Feb 20 07:32 01-00-50-A6-9C-CE-E7 -> vm68
lrwxrwxrwx 1 root root  10 Feb 20 07:32 01-00-50-A6-9C-C1-C7 -> vm19

change as below it work 🙂 🙂 🙂

lrwxrwxrwx 1 root root  10 Feb 20 07:32 01-00-50-a6-9c-ce-e7 -> vm68
lrwxrwxrwx 1 root root  10 Feb 20 07:32 01-00-50-a6-9c-c1-c7 -> vm19


[root@nagios ~]# pvcreate /dev/sdb3
Device /dev/sdb3 not found (or ignored by filtering).

Fix : kernel partition table  not  synced /dev/sdb3 partition so you got a above error

#init 6 (not recommended)

#partx -av /dev/sdb


[root@localhost ~]# vim /etc/fstab
[root@localhost ~]# mount -a
mount: mount point /data does not exist
mount: mount point /data2 does not exist

Fix : fstab newly added partition information /data /data2 directory is not yet created

#mkdir /data /data2

#mount -a


SSH Key concept in Linux

 SSH – secure shell

              It is used to connect Linux server remote using command line. Also ssh mentioned as secure shell. So what secure technical way followed? So for that ssh introduced concept is called ssh keys as private and public key authentication method to access your server.

For server-client model method some known user also access your server and some unknown attacker also access your server that case you have authenticate whom want access your server securely, For that thing used as ssh-key concept.

screenshot_1

ssh-key

SSH keys are used for secure connections across a network. They come in pairs, so you have a public key and a private key.

ssh-keygen

[root@Master ~]# ls -al

total 20

dr-xr-x—. 2 root root 4096 Nov 10 00:38 .

dr-xr-xr-x. 23 root root 4096 Nov 9 21:51 ..

-rw——-. 1 root root 2335 Nov 8 08:03 anaconda-ks.cfg

-rw-r–r–. 1 root root   18 May 20 2009 .bash_logout

-rw-r–r–. 1 root root 176 Sep 22 2004 .bashrc

[root@Master ~]# ssh-keygen (command to generate private and public key)

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Created directory ‘/root/.ssh’.

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

41:90:31:1a:17:a5:05:5f:75:69:9d:a8:0a:7b:e0:76 root@Master.Au-Tel.com

The key’s randomart image is:

+–[ RSA 2048]—-+

|   . BB+ … oo.|

|     +.* .   oo..|

|   . . o   ..   |

|       o . .     |

|     . S .     |

|       + E       |

|     . o       |

|                 |

|                 |

+—————–+

 

After running key gen command it will generate two key file under /root/.ssh directory

[root@Master .ssh]# pwd

/root/.ssh

[root@Master .ssh]# ls -l

total 8

-rw——- 1 root root 1675 Nov 10 01:20 id_rsa

-rw-r–r– 1 root root 404 Nov 10 01:20 id_rsa.pub

 

Private and public keys

[root@Master .ssh]# pwd

/root/.ssh

[root@Master .ssh]# ls -l

total 8

-rw——- 1 root root 1675 Nov 10 01:20 id_rsa (private key)

-rw-r–r– 1 root root 404 Nov 10 01:20 id_rsa.pub (public key)

Private key

[root@Master .ssh]# cat id_rsa

—–BEGIN RSA PRIVATE KEY—–

MIIEowIBAAKCAQEAuZv3TUN2+QnLTJ8rCK/QhNqi2Ce1BV2YtRfgprxjaXpeP9Mv

pju4Qf1rJ21sIfdUe4s2zheDZ514y9o5nP70bfHYMtR2yKbb5f8//k6f26B7LPF1

hB4/POX1mssoWGsRKFlVb+TtXFhwpCT/Eiaz4NhSts3ZPBOLVCPlIrFx5WMC3B4o

xlvz7tg7MrPhqE5YkA+s6wl+bhvPSC7QsmJIfpetKqc36T6CoJdq3NfQ+AbSFre9

FkZHhePFBlsm4yBtIZKCOkot1mLF/bqx6CuRdz8Xc1RhJY/rDk/IdVyn5gUj7xBY

P/UyIIfUL8aS9SQvzGfizF4Xa+HhmcL0wSv7ZQIBIwKCAQEAmcpfMWPI+jtQrTNs

zK7umfb79O2zPvXHq/3XZZTHZgZOF6Bark69Pf3ccSAmZUlF//cBhjC9Vdo/hFW6

tUhG3sESOL6rkE+9hA4B0rYsrqmKoZTdtpy4DeMb9Uk+r6kreTQT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kuask9EuGHeWMkOmfljJ/IpRSJbPoGwTTpLhA

—–END RSA PRIVATE KEY—–

Public key

[root@Master .ssh]# cat id_rsa.pub

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuZv3TUN2+QnLTJ8rCK/QhNqi2Ce1BV2YtRfgprxjaXpeP9Mvpju4Qf1rJ21sIfdUe4s2zheDZ514y9o5nP70bfHYMtR2yKbb5f8//k6f26B7LPF1hB4/POX1mssoWGsRKFlVb+TtXFhwpCT/Eiaz4NhSts3ZPBOLVCPlIrFx5WMC3B4oxlvz7tg7MrPhqE5YkA+s6wl+bhvPSC7QsmJIfpetKqc36T6CoJdq3NfQ+AbSFre9fkZHhePFBlsm4yBtIZKCOkot1mLF/bqx6CuRdz8Xc1RhJY/rDk/IdVyn5gUj7xBYP/UyIIfUL8aS9SQvzGfizF4Xa+HhmcL0wSv7ZQ== root@Master.Au-Tel.com

SSH Key Authentication

 Run ssh-copy id command in Master server side:-

[root@Master .ssh]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@slave.autel.com

root@192.168.50.133’s password:

Now try logging into the machine, with “ssh ‘root@ slave.autel.com “, and check in:

.ssh/authorized_keys

to make sure we haven’t added extra keys that you weren’t expecting.

Check authorized keys is available in Slave Server: –

[root@Slave .ssh]# cat authorized_keys

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAuZv3TUN2+QnLTJ8rCK/QhNqi2Ce1BV2YtRfgprxjaXpeP9Mvpju4Qf1rJ21sIfdUe4s2zheDZ514y9o5nP70bfHYMtR2yKbb5f8//k6f26B7LPF1hB4/POX1mssoWGsRKFlVb+TtXFhwpCT/Eiaz4NhSts3ZPBOLVCPlIrFx5WMC3B4oxlvz7tg7MrPhqE5YkA+s6wl+bhvPSC7QsmJIfpetKqc36T6CoJdq3NfQ+AbSFre9fkZHhePFBlsm4yBtIZKCOkot1mLF/bqx6CuRdz8Xc1RhJY/rDk/IdVyn5gUj7xBYP/UyIIfUL8aS9SQvzGfizF4Xa+HhmcL0wSv7ZQ== root@Master.Au-Tel.com

I am authorized server for slave server next it will not ask password connect

no-passwd

ssh-know host

Very first time if you are trying to access Linux server 3via SSH it will ask yes or no for connecting you have type yes. Because I don’t know about new Linux server it will ask yes or not for connecting yes. From next time it will not ask yes or not it will store information about you in ssh-known-host file

screenshot_2

Before connecting server run below command

[root@Master .ssh]# pwd

/root/.ssh

[root@Master .ssh]# ls -a

. .. id_rsa id_rsa.pub

 

From Server side

[root@Master .ssh]# ssh root@192.168.50.133

The authenticity of host ‘192.168.50.133 (192.168.50.133)’ can’t be established.

RSA key fingerprint is 7b:05:1a:c6:51:b5:0b:71:2e:41:d1: ed:d0:bb:3f:26.

Are you sure you want to continue connecting (yes/no)?yes

[ root@Master .ssh]# ls -a

. .. id_rsa id_rsa.pub known_hosts

 [root@Master .ssh]# cat known_hosts

192.168.50.133 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwQozTZRbhKZYYlx9SjR6LKJTkz6mk4nxGl20XVLQJhTwNvCTvpIX3k5dBBN/5hAHizgtSP7G2/b1lG1jVtgaLzQ07/if0R5k4EtCFJyObg+pcX8+Ainzz0rEqE8WZcrqqo9o/J9BSjH2lvNUUUlwmKvpXqjnkjHJO2io3eo9P5DXYcc1UIk53xjTl8VYYe3l26DmaitW8tfolO08ESfbg3R6cT22gpzybWZ12k1SqB8S4InHACW+cQXsswEMIXpjgCG9y4Acsf1n4tK5vruNi5BZ2pgOWYAG6GpviiN6n1DGr84ZWCzBjua65ZtgC+8KHMcZ5qxMGttpF3LvOVCjqw==

Next try it will not ask yes / no because you know about the server. It is stored server ip with public key in “/root/.ssh/knownhosts”

[root@Master .ssh]# ssh root@192.168.50.133

root@192.168.50.133’s password:

RHEL6 vs RHEL7

Posted: November 7, 2016 in RHEL 7, rhel6 vs rhel7

[1]ON THE BASIS OF RELEASE DATE.

RELEASE DATE OF RHEL6 IS 10th NOV 2010.

RELEASE DATE OF RHEL7 IS 10TH JUNE 2014.

[2]DIFFERENCE ON THE BASIS OF OPERATING SYSTEM NAMES

If you want to see this use this command

#cat /etc/redhat-release

RHEL6 : REDHAT ENTERPRISE LINUX (SANTIGO)

RHEL7: REDHAT ENTERPRISE LINUX (MAIPO)

[3]KERNEL VERSION

RHEL6: 2.6.32

RHEL7:  3.0.10

[4] OS BOOT TIME

RHEL6: 40 sec

RHEL7: 20 sec

[5]MAXIMUM SIZE OF SINGLE PARTITION

RHEL6: 50TB(EXT4)

RHEL7: 500TB(XFS)

[6] BOOT LOADER

RHEL6:  /boot/grub/grub.conf

RHEL7: /boot/grupb2/grub.cfg

[7]PROCESSOR ARCHITECTURE

RHEL6: It support 32bit & 64bit  both

RHEL7: It only support 64bit

[8]HOW TO FORMAT OR ASSIGN A FILE SYSTEM IN

RHEL6:      #mkfs.ext4   /dev/sda6

RHEL7:       #mkfs.xfs   /dev/sda6

[9]HOW TO REPAIR A FILE SYSTEM IN

RHEL6:  #fsck -y /dev/hda6

RHEL7:  #xfs_repair /dev/hda6

[10]COMMAND TO MANAGE NETWORK IN RHEL6 AND RHEL7

RHEL6:  #setup

RHEL7:  #nmtui

[11]HOSTNAME CONFIGURATION FILE

RHEL6:    /etc/sysconfig/network

RHEL7:    /etc/hostname

[12]DEFAULT ISO IMAGE MOUNT PATH

RHEL6: /media

RHEL7: /run/media/root

[13]FILE SYSTEM CHECK

RHEL6:   e2fsck

RHEL7:   xfs_repair

[14]RESIZE A FILE SYSTEM

RHEL6:   #resize2fs  -p /dev/vg00/lv1

RHEL7:    #xfs_growfs  /dev/vg00/lv1

[15]TUNE A FILE SYSTEM

RHEL6: tune2fs

RHEL7: xfs_admin

[16]IPTABLES AND FIREWALL

RHEL6: iptables

RHEL7: firewalld

[17]COMMUNICATION BETWEEN TCP AND UDP IN BACK END

RHEL6: netcat

RHEL7: ncat

[18]INTERFACE NAME

RHEL6: eth0

RHEL7: ens198(N)

[19]COMBINING NIC

RHEL6: Network Bonding

RHEL7: Team Driver

[20]NSF Server Version

RHEL6:  NFSv2

RHEL7:  NFSV4

 [21]DATABASE USED

RHEL6: Mysql

RHEL7: mariaDB

[22]MANAGING SERVICES

RHEL6:

#service sshd restart

#chkconfig sshd on

RHEL7:

#systemctl restart sshd

#systemctl enable sshd