Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Thursday, 26 April 2018

How to update and upgrade ESXi host

Please find the below steps and command to update and upgrade the ESX host.

You need to understand first, the update and upgrade both are different thing in case of ESX.

Update means you have update the VMware release build.

Upgrade means you have upgrade the VMware version like 5.0 to 6.0 

Please find the below command to update the VMware release build:

# esxcli software vib update -d /vmfs/volumes/updates/VMware-ESXi-5.1.0-Update3-2323236-HPE-510.9.5.0.30-Apr2016-depot.zip

It is asking for reboot please press true and reboot the esx host gracefully, once the host reboot successfully check the new release build. 

Please find the below steps to upgrade the ESX host:

Now we need to upgrade the ESX host from 5.1.0 to 5.5.0 , to perform this task please follow the below steps

Take a remote console of this ESX host from ILO.

Copy the VMware-ESXi-5.5U1-Rollup_2ISO.iso

attached the iso with remote console

boot the ESX host with attached iso VMware-ESXi-5.5U1-Rollup_2ISO.iso

When esx boot this iso during upgrade process it is asking for you 3 option, please select the below option.

Upgrade the ESX host with keeping existing datastore.

Once the upgrade will be successfully, please login on the esx host and check the latest version and all service will working fine.

Please let me know if you have any question regarding this upgrade issue.

Tuesday, 24 April 2018

How to add linux host in Active Directory (AD) domain

Before performed such work, please collect the below information:-

Host: Server name which need to be add in AD
DA account: .da account which used to add server to domain
Domain name

Please find the below process step by step to add a server in to AD:-

[root@localhost ~]# hostname localhost.redhat.com

[root@localhost ~]# adinfo

Not joined to any domain
Licensed Features: Enabled

[root@localhost ~]#  adjoin -u xyz.da --name localhost -a localhost.redhat.com -w redhat.com

xyz.da@REDHAT.COM's password:
Using domain controller: redhat01.redhat.com writable=true
Join to domain:redhat.com, zone:Auto Zone successful
Centrify DirectControl started.
Loading domains and trusts information
........................

Note: .da account required to add server in domain

Tuesday, 16 January 2018

How to Flush Memory Cache and Buffer Cache on Linux Server

When you run the "free -m" command and get the below output, then you observe free memory section will be low value but comparatively buffers+cache value would be higher.

Now this is not a bad thing actually since your OS has reserved this memory to speed up your most used process by keeping them in the cache. But in case any new process is executed and your system is low on memory then these cache would be automatically released to make space for memory reservation of new processes.

[root@localhost]# free -m
             total       used       free     shared    buffers     cached
Mem:          2345       1234        1145          0         24        400
-/+ buffers/cache:        664        345
Swap:         4032          0       4032

if you want to clear or free cache/buffer memory then you need to run the below command.

[root@localhost]# echo 3 > /proc/sys/vm/drop_caches

These are the different values which you can use with the above command

echo 1 is clearing only page cache

[root@localhost]# echo 1 > /proc/sys/vm/drop_caches

echo 2 is to clear free dentries and inodes

[root@localhost]# echo 2 > /proc/sys/vm/drop_caches

echo 3 is clearing page cache, dentries and inodes

[root@localhost]# echo 3 > /proc/sys/vm/drop_caches

Thursday, 11 January 2018

SSH login without password in linux

If you want to connect one Linux host to other Linux host through SSH with password-less connection then you need to perform below steps.

Lets suppose you need password-less login from host "server01" / user "redhat" to host "server02" / user "centos".

1. First login in on "server01"as user "redhat" and generate a pair of authentication keys.

[redhat@server01]# ssh-keygen -t rsa

Generating public/private rsa key pair.
Enter file in which to save the key (/home/redhat/.ssh/id_rsa):
Created directory '/home/redhat/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/redhat/.ssh/id_rsa.
Your public key has been saved in /home/redhat/.ssh/id_rsa.pub.
The key fingerprint is:
1e:4f:05:79:3a:9f:96:7c:2b:ad:e9:58:37:sc:37:e4 redhat@server01

Note: Do not enter a passphrase.

2. Now you use ssh to create a directory ~/.ssh as user "centos" on server02.

Note: If directory already exist, you do not create it again.

[redhat@server01]# ssh centos@server02 mkdir -p .ssh

centos@server02's password:

Finally append redhat's new public key to centos@server02:.ssh/authorized_keys and enter centos's password one last time:

3. Now copy the rsa key to server 02 ssh authorized_keys file

[redhat@server01]# cat .ssh/id_rsa.pub | ssh centos@server02 'cat >> .ssh/authorized_keys'

centos@server02's password:

Now you can log into server02 as "centos" from server01 as "redhat"a without password.

4. Now you can test the password less connection.

[redhat@server01]# ssh centos@server02

You are successfully login on the server02 without any password.

Note:  In case of any permission issue you need to set "700" permission on .ssh folder on server02.

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

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.

Thursday, 13 July 2017

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.

Wednesday, 24 May 2017

Best Practical examples of RPM commands in linux

Basically Red Hat Package Manager (RPM) are a package management utility which are used for install, update , uninstall, query and verify of packages in Linux system like (RHEL,CentOS and Fedora).

Please find the below practical examples of rpm commands in Linux operating system.

➤ How to install an RPM packages.

To install the packages on Linux operating machine, please use the -i option for install. Please find the below example for installing the rpm.

[root@localhost]# rpm -ivh jdk-6u37-linux-amd64.rpm

Using above command you can install the rpm on linux operating machine. In the above command, -h print the has mark stat that package is archived and -v used as a verbose for better display.

➤ How to install an RPM packages without dependencies.

To install the packages on linux machine, please use --nodeps option. Please find the below example for installing the rpm without dependencies.

[root@localhost]# rpm -ivh --nodeps ftp-2.7.9-5.el6.2.i686.rpm

In above example, all the dependencies for installing the ftp server has been ignored.

➤ How to check a RPM signature.

To check the PGP signature of any rpm , please use the below command. This signature process is used for verification of the origin of rpm.

[root@localhost]# rpm --checksig jdk-6u37-linux-amd64.rpm

Using above command you can verify that the origin of installing rpm is valid. Normally this command is used before installing the rpm.

➤ How to check all installed rpm on Linux server.

To check the all installed rpm's on the linux machine, please use -q option. Please check the below example for checking all list.

[root@localhost]# rpm -q samba

Using above command you can find the all installed rpm related to packages.

➤ How to check recently installed RPM.

 To check the recently installed rpm, please use the -qa (query all) option. Please find the below example to check the recently installed rpm.

[root@localhost]# rpm -qa --last

The above command show you the list of all recently rpm in sequence of installation order. 

➤ How to list all installed RPM.

To check and print the list of all installed rpm on linux machine, use the below command.

[root@localhost]# rpm -qa

Command output show you the list of all installed packages on the linux machine.

➤ How to Upgrade a RPM Package.

If you want to upgrade already installed rpm on the linux machine, please check the command which is used in below example.

[root@localhost]# rpm -Uvh ftp-2.7.9-5.el6.2.i686.rpm

Here, -U option is used for upgrading the rpm packages which are installed on the linux machine.

➤ How to Remove a RPM Package.

To remove the package from linux server, you can use the -e option. Please find the below command with an example to remove the packages.

[root@localhost]# rpm -e ftp-2.7.9-5.el6.2.i686.rpm

You can use the below command syntax as well for removing the package from the linux machine.

 [root@localhost]# rpm -ev ftp

In last example, all the package dependencies are also removed with this command syntax.

➤ How to Remove a RPM Package without dependencies.

Please use the below command to remove a rpm package without removing any dependencies.

[root@localhost]# rpm -ev--nodeps samba

here, -nodeps command used for removing the package without any dependencies.

➤ How to query a information of Installed RPM package.

If you want to get all information regarding the installed rpm package, please use the -qi option. Please find the below example to query the information of installed rpm.

[root@localhost]# rpm -qi samba

Above command display all the information related to samba packages.

➤ How to verify a RPM package.

To verify a rpm package, please use the -Vp (Verify Package) option. Please check the below example to verify the package.

[root@localhost]# rpm -Vp ftp-2.7.9-5.el6.2.i686.rpm

Using this command you can verify the package.

Please let me know, if you have any concern regarding this topic.

Saturday, 20 May 2017

How to add a fake dummy null printer in linux machine

Their are several way to configure the printer in linux operating system like Red Hat Linux, CentOS etc. You can configure normal local printer with any of these operating system very easily but if some one asked you to configure the fake dummy null printer with linux system, then its goes tricky.

Here, you can find the step by step simple solution of tricky issue. To configure the null printer in linux not much complex but you have to knowledge about the basic command of how to add a printer.

Before moving the main topic we need to know about the package installation system on linux servers. Generally YUM utility and rpm package manager are used for installation of required package of printer.

You can check my below link , how to configure YUM server on linux operating system.

https://unixforsolutions.blogspot.in/2017/05/how-to-configure-yum-server-in-red-hat_14.html

Once you go with my above link you can get an idea about how yum server is configure. So now we will go to main topic.

➤ Initially you need to install the required packages to configure the null printer. Please refer the below command to install the rpm.

[root@localhost]# yum install system-config-printer*

Cups is also required for printer configuration , so please use the below command to install cups services package.

[root@localhost]# yum install cups*

➤ Once the printer packages are installed then start the cup services on the server. Please use the below command to start the cup service.

[root@localhost]# systemctl start cups

You can check the status of cups services using below command.

[root@localhost]# systemctl status cups
cups.service - CUPS Printing Service
Loaded: loaded (/usr/lib/systemd/system/cups.service; enabled; vendor preset: enabled)
Active: active (running) since SAT 2017-05-20 14:34:11 IST; 4s ago

➤ Also you need to changed the entry in printer configuration file. "/etc/cups/cupsd.conf is configuration file in linux machine. Open the configuration file and change the parameter FileDevice to yes.

➤ Now, please run the below command to add a printer on the server.

[root@localhost]# lpadmin -p myprinter -E -v file:///dev/null

above command is used for adding a null printer in linux machine, if you want to check the status of printer, then please use the below command.

[root@localhost]# lpstat -s
no system default destination
device for myprinter: ///dev/null

You can find the above output if you are successfully configured the printer. Using this you can check the current device printer status.

Please comment on the post, if you have any query regarding this null printer installation topic.

Step by Step method to Configure Proxy in Linux Terminal

Mostly Squid proxy wpad.dat file are used for configuring the browser on Linux operating system. If you required to configure the proxy on linux terminal then you need to use either DNS name of proxy internet or IP address with port.

Normally user facing such issue while they are working on Linux environment and trying to download files on Linux terminal but they are facing a download error. This is because terminal never accept the browser settings. So you need to set the parameter of proxy manually on linux terminal window.

Here, we will discuss several ways using which we can configure the proxy on linux terminal window. Using this method you can configure the proxy on any linux environment like CentOS, Ubuntu etc.

Step by Step method to configure the proxy in Linux:

In mostly companies when you work on linux server, and trying to download files you will get an error " proxy behind the firewall" that's means you need to configure the proxy on terminal so that when you run your application or command to download the data such error not occur.

➤ Let's suppose your Proxy IP address is 10.13.2.34 and port is 8080, then you need to run the below command into the linux terminal.

[root@localhost]# export http_proxy=http://10.13.2.34:8080

and if your proxy server is secure then you can used https tag with export settings. Please find the below command syntax to use proxy with https.

[root@localhost]# export https_proxy=https://10.13.2.34:8080

➤ Let's suppose your Proxy IP address resolve a particular domain name then in this case you can change the IP address name with dns name as given in below example.

[root@localhost]# export http_proxy=http://squid.proxy.com:8080

[root@localhost]# export https_proxy=https://squid.proxy.com:8080

Please change your dns name as per your proxy configuration, in my case i just take a dummy dns name.

➤ Let's suppose you want to make the export settings permanently for all Unix system users, so any user if login on the Linux server they can able to access internet through terminal. In this situation, you need to make a export entries permanently in /etc/profile file. 

[root@localhost]# vi /etc/profile

on the bottom of this profile file paste the below two entry and save the file.

export http_proxy=http://10.13.2.34:8080
export https_proxy=https://10.13.2.34:8080

[root@localhost]# source /etc/profile

The above source command are used to make a entry permanently without taking a reboot of server.

➤ Let's suppose you want to allow internet only specific user then in this case you need to make the above export http & https entry in user bash profile. 

Please post the comment on this blog, if you have any query regarding this proxy topic.