Showing posts with label Red Hat Linux. Show all posts
Showing posts with label Red Hat Linux. Show all posts

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

Saturday 24 June 2017

How to disable the SELinux in Linux operating system machine

Security-enhanced Linux (SELINUX): SELinux is know as Security enhanced linux system which is the security feature of the Linux kernel system. It is define the security Policy which makes system proctative agaginst the misconfiguration of the daemons. SELinux running in 3 modes which is disabled, enabled and permissive. We will explain these mode in configuration steps.

Here, you can find the all the steps which is required to enable or disable the SELinux configuration.

How to disable SELinux on Linux operating system:

➤ In the first step you can check the current status of SELinux. To do this please run the below command.

[root@localhost]# getenforce
Enabled

"getenforce" command is used for checking the current status of SELinux.

➤ As you see on my machine when I run the above command my SElinux is enabled, So in this step we will change the SELinux mode.

[root@localhost]# vi /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

Normally selinux configuration file you can found on the above location. You can edit the SELINUX entry to disabled. All the command is run by super user "root" only.

➤ Once you change the entry in SELinux configuration file then for permanent effect you need to take a reboot of the system.

[root@localhost]# init 6

Once you reboot the server all the configuration files changes has been done.

➤ In the last step you will run the "getenforce" command again to verify the new status of SELinux.

[root@localhost]# getenforce
Disabled

If you comparison the both step 1 and this step output you can found that SELinux policy is not disabled on the Linux operating system.

Monday 29 May 2017

How to shrink or reduce MySQL ibdata size in Red Hat Linux server

MySQL database is widely use database server, but sometimes you are facing an ibdata size issue on the database server.

Normally this ibdata size error occur while you are trying to start the MySQL database services. So to resolve such type of error this post is very useful. Here, I would explain to you how to shrink MySQL ibdata size in Red Hat Linux operating system.

➦ Before doing anything in database I would suggest to you take a backup of existing database so in case of any issue, we will restore the previous backup.

Please find the below command using which you need to take a backup of MySQL database. You must remember you need to take full backup which consist triggers, routines and all tables.

[root@localhost]# mysqldump --lock-all-tables --triggers --routines -u user_name -p -h server_name database_name > /home/backup.sql

Using above command you can take a complete MySQL backup on your linux machine.

➦ Now you need to drop all database on the server except default MySQL schema.

➦ Once you drop all existing database, stop the MySQL service and make it disable permanent. Please find the below command to stop the MySQL services on server.


[root@localhost]# /etc/init.d/mysql stop
[root@localhost]# chkconfig mysql off

For RHEL7 you need to use "systemctl" command to stop the MySQL running service. The above example command are valid in lower version on RHEL7.

➦ You need to change the configuration setting in MySQL configuration file, which is generally located in /etc directory.

[root@localhost]# vi /etc/my.cnf

[mysqld]
Innodb_file_per_table
Innodb_flush_method=0_DIRECT
Innodb_log_file_size=1G
Note: Whatever you’re set for innodb_buffer_pool_size, make sure innodb_log_file_size is 25% of innodb_buffer_pool_size.

➦ Please delete the ibdata1, ib_logfile0 and ib_logfile1 from the MySQL library location. At this point, there should only be the MySQL schema in /var/lib/mysql

Now take a restart of MySQL service again and recreated the ibdata1 and ib_logfile0 again and restore the MySQL backup again.

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.

Sunday 14 May 2017

How to configure YUM Server in Red Hat Linux 7 Operating System

This is my first post, hope you are like my blog content. I am trying to provide you the simple and straight forward solution on this post.

In this post, I will guide to you, how to configure YUM server in Red Hat Linux 7 operating system. Yum tends for Yellowdog Updater Modified utility which used for package management system on Linux environment. In the below post, you can find the step by step method of configuration and installation of YUM.

Step by Step Method of Installation & Configuration of YUM:

➤ If you have Red Hat Linux 7 operating system image or cd, then please mount this iso or cd on cdrom device of operating system.

[root@localhost]# mount -o loop /dev/cdrom /mnt

In above command syntax, you can able to see we have mount the our Red Hat Linux 7 operating system image on /mnt file system. Normally /mnt file system are used for mounting purpose only but its depends upon every user understanding.

➤ Please create a directory where you want to copy the all packages files for configuration of YUM server.

[root@localhost]# mkdir /"Directory Name"

In linux operating system mkdir command are used for creating a directory. In my case I normally use "/yumserver" name for YUM configuration. When you create a directory please change your directory name.

➤  Please copy the all files from "/mnt" directory to /"Directory Name".

[root@localhost]# cp -rvf /mnt/* /"Directory Name"

Using this command all the packages files are copied on the other place, you need to keep save this directory otherwise your YUM configuration is not works.

➤ In this step, we will go the the packages directory and install the required rpm packages which are required for installation of YUM server.

[root@localhost]# cd /yumserver/Packages

You can use your directory name to reach the packages folder. Now once we reached in this directory then we will install the required rpm packages one by one in below sequence.

[root@localhost]# rpm -ivh deltarpm-3.6-3.el7.x86_64.rpm
[root@localhost]# rpm -ivh python-deltarpm-3.6-3.el7.x86_64.rpm
[root@localhost]# rpm -ivh createrepo-0.9.9-23.el7.noarch.rpm

If you are trying to install the above rpm packages and not follow the above installation of rpm's in same sequence then you are definitely getting an dependency error.

➤ For creating a repo packages, you need to createrepo of all the packages, for this please run the below command on your terminal window.

[root@localhost]# createrepo  –v /yumserve/Packages

Please change the yum directory name which you used in above steps. Using this command all the packages repo has been created on the yum directory.

➤ Create a repo file on the below directory location. Please used the valid name while creating a repo file.

[root@localhost]# cd /etc/yum.repos.d/
[root@localhost]# vi yumserver.repo

You can change the repo file name according to your feasibility. Now please write the below entry inside this file.
#########################
[Packages]
baseurl=file:///yumserver/Packages 
gpgcheck=0
enable=1
########################

This is the main file content, so please more careful while doing the entry in this file. You can change the baseurl location as per your YUM packages directory location. After saving the file go for final step.

➤  In final step, as you configured the YUM configuration file, now you need to clean your yum repo and used it for installation the packages.

[root@localhost]# yum clean all

When you run this command , some space from /var file system get free, actually during packages installation /var file system get increase sometimes.

[root@localhost]# yum list

above command show you all the yum repo which exist on this server. In our case you can find the yumserver repo.

To test the yum server is configured properly or not then please run the below command to installed the any packages on the server using yum commands.

[root@localhost]# yum install samba*

When you run this command, if all the packages related to yum are installed that's means your YUM server installation and configuration are successful. If you are see any error then please check the above all steps configuration one by one.