Monday 13 June 2016

How to install clamAV on Centos 6

Install EPEL repo:
Before we can do proceed, you must ensure that you have the EPEL yum repository enabled. To do this,


CentOS 6.x

#rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

CentOS 5.x
#rpm -Uvh http://mirror.pnl.gov/epel/5/x86_64/epel-release-5-4.noarch.rpm

Install clamAV
# yum -y install clamav clamd
# chkconfig clamd on

Update the clamav virus database
# /usr/bin/freshclam

Error:

# /usr/bin/freshclam
ERROR: Please edit the example config file /etc/freshclam.conf
ERROR: Can't open/parse the config file /etc/freshclam.conf

To fix this above  error Comment out the Line with “Example”
#vim  /etc/freshclam.conf
##
## Example config file for freshclam
## Please read the freshclam.conf(5) manual before editing this file.
##
# Comment or remove the line below.

Example


Change to

#vim /etc/freshclam.conf
##
## Example config file for freshclam
## Please read the freshclam.conf(5) manual before editing this file.
##
# Comment or remove the line below.

# Example


Run freshclam again
# /usr/bin/freshclam

Start Clamav
# service clamd start

 Starting Clam AntiVirus Daemon: ERROR: Please edit the example config file /etc/clamd.conf
ERROR: Can't open/parse the config file /etc/clamd.conf
 [FAILED]

Edit the config file, comment out “Example”

##
## Example config file for the Clam AV daemon
## Please read the clamd.conf(5) manual before editing this file.
##
# Comment or remove the line below.

#Example



"ERROR: Please define server type (local and/or TCP)"
You may need to uncomment the "TCPSocket" line in clamd.conf.


Set Clamav to run a daily scan

#vim /etc/cron.daily/clamscan

#!/bin/bash

# setup the scan location and scan log

CLAM_SCAN_DIR="/var/www/vhosts"

CLAM_LOG_FILE="/var/log/clamav/dailyscan.log"

# update the virus database

/usr/bin/freshclam

# run the scan

/usr/bin/clamscan -i -r $CLAM_SCAN_DIR >> $CLAM_LOG_FILE

MAILTO=user@domain.com


or

#clamscan -i -r --log=/var/log/clamscan-date.txt /var/www/vhosts/*

Set the cron file as an executible
#chmod 555 /etc/cron.daily/clamscan

Test your installation and cron job
 #/etc/cron.daily/clamscan


Try to scan.
[root@mail ~]# clamscan --infected --remove --recursive /home          #/home is your scan folder
----------- SCAN SUMMARY -----------
Known viruses: 3509099
Engine version: 0.98.4
Scanned directories: 94
Scanned files: 109
Infected files: 0
Data scanned: 0.95 MB
Data read: 0.89 MB (ratio 1.07:1)
Time: 8.485 sec (0 m 8 s)

# Download trial virus
[root@amir ~]# wget http://www.eicar.org/download/eicar.com
[root@amir ~]# clamscan --infected --remove --recursive .

./eicar.com: Eicar-Test-Signature FOUND
./eicar.com: Removed. # just detected

----------- SCAN SUMMARY -----------
Known viruses: 3509099
Engine version: 0.98.4
Scanned directories: 110
Scanned files: 147
Infected files: 1
Data scanned: 0.78 MB
Data read: 0.64 MB (ratio 1.21:1)
Time: 7.982 sec (0 m 7 s)

Tuesday 31 May 2016

How to Fix “Configuration of pmadb… not OK” in phpMyAdmin or phpmyadmin configuration storage is not completely.

To fix this you have to import/create the phpmyadmin database with it’s tables. An SQL script called create_tables.sql should be in the scripts, examples or sql folder of your phpMyAdmin installation.
To find out create_tables.sql run this below command

#find / -name create_tables.sql
Sample Output should be like this...
Go to create_table.sql directory
#mysql -u root -p < create_tables.sql  
Give your mysql root password ********
# mysql -u root –p
Give your mysql root password ********
>CREATE USER 'pma'@'localhost' IDENTIFIED BY 'pmapass';
>GRANT ALL PRIVILEGES ON `phpmyadmin`.* TO 'pma'@'localhost' WITH GRANT OPTION;
>FLUSH PRIVILEGES;
>exit


Now edit /etc/phpMyAdmin/config.inc.php and configure/uncomment those lines:

#vim /etc/phpMyAdmin/config.inc.php

/*
 * phpMyAdmin configuration storage settings.
 */

/* User used to manipulate with storage */
$cfg['Servers'][$i]['controlhost'] = 'localhost';
// $cfg['Servers'][$i]['controlport'] = '';
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapass';

/* Storage database and tables */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma__bookmark';
$cfg['Servers'][$i]['relation'] = 'pma__relation';
$cfg['Servers'][$i]['table_info'] = 'pma__table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma__table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma__pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma__column_info';
$cfg['Servers'][$i]['history'] = 'pma__history';
$cfg['Servers'][$i]['table_uiprefs'] = 'pma__table_uiprefs';
$cfg['Servers'][$i]['tracking'] = 'pma__tracking';
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['favorite'] = 'pma__favorite';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
$cfg['Servers'][$i]['savedsearches'] = 'pma__savedsearches';
$cfg['Servers'][$i]['central_columns'] = 'pma__central_columns';
$cfg['Servers'][$i]['designer_settings'] = 'pma__designer_settings';
$cfg['Servers'][$i]['export_templates'] = 'pma__export_templates';

Finally logout and login again to phpMyadmin.

Wednesday 25 May 2016

MySql database administration in Linux

  • How to set MySQL Root password?
                 #mysqladmin -u root password YOURNEWPASSWORD
  • How to Change MySQL Root password?
                 #mysqladmin -u root -p oldpassword password 'newpassword'
 
  • How to check MySQL Server is running?
               # mysqladmin -u root -p ping
                 Enter password:
                 mysqld is alive

  • How to Check which MySQL version
               # mysqladmin -u root -p version

  • How to Find current Status of MySQL server?
               # mysqladmin -u root -ptmppassword status

  • How to check & see MySQL Server Variable’s and value’s?
               # mysqladmin -u root -p extended-status
               #mysqladmin  -u root -p variables

  • How to check all the running Process of MySQL server?
              # mysqladmin -u root -p processlist

  • How to create a Database?
               # mysqladmin -u root -p create databasename

  • How to delete a Database?
               # mysqladmin -u root -p drop databasename

  • How to reload/refresh MySQL Privileges?
               # mysqladmin -u root -p reload;
               # mysqladmin -u root -p refresh

  • How to shutdown MySQL server Safely?
               #mysqladmin -u root -p shutdown

MySQL Flush commands
  • flush-hosts: Flush all host information from host cache.
               # mysqladmin -u root -p flush-hosts

  • flush-tables: Flush all tables.
                # mysqladmin -u root -p flush-tables

  • flush-threads: Flush all threads cache.
                # mysqladmin -u root -p flush-threads

  • flush-logs: Flush all information logs.
                # mysqladmin -u root -p flush-logs

  • flush-privileges: Reload the grant tables (same as reload).
                # mysqladmin -u root -p flush-privileges

  • flush-status: Clear status variables.
                # mysqladmin -u root -p flush-status

  • How to Connect remote mysql server
                # mysqladmin  -h 172.16.25.126 -u root –p

  • How to store MySQL server Debug Information to logs?
                # mysqladmin  -u root -p debug

Monday 28 March 2016

How to reset/recover/break linux Grub Boot Loader Password




Step 1:  Get the CentOS/Red Hat bootable CD/DVD/USB media.And insert the media into system. 

Step 2:  On booting you will see some options on screen.Use any one method given below:
Select “Rescue installed system” and hit enter.

Alternatively, you can also press TAB key and add the word “linux rescue” and hit enter.

Do not worry, after this all steps are same.

Now please see this video Recover Linux Grub Password


Here my OS version is centos 6.7. If you have an query please feel free to comment below. Thanks....


Related Video: How to Protect GRUB with Password in Linux


Sunday 20 December 2015

How to redirect domain in apache server


Add following code to your .htaccess or httpd.conf (directory directive) file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]
If you added directives to httpd.conf, restart Apache:

# service httpd restart
#chkconfig httpd on

How to increase upload file limit from 2MB to 10MB under Apache 2 UNIX / Linux web server?

php installation putting limits on upload file size. The default will restrict you to a max 2 MB upload file size. You need to set the following two configuration options:



Method # 1: Edit php.ini
Edit your php.ini file (usually stored in /etc/php.ini or /etc/php.d/cgi/php.ini or /usr/local/etc/php.ini):

# vi /etc/php.ini
Sample outputs:
memory_limit = 32M
upload_max_filesize = 10M
post_max_size = 20M

Save and close the file. Restart apache or httpd web server:
# service httpd restart
#chkconfig httpd on

Method #2: Edit .htaccess
Edit .htaccess file in your root directory. This is useful when you do not have access to php.ini file. In this example, /home/httpd/html is considered as root directory (you can also create .htaccess file locally and than upload it using ftp / sftp / scp client):

# vi /home/httpd/html/.htaccess
Append / modify setting as follows:
php_value upload_max_filesize 10M
php_value post_max_size 20M
php_value memory_limit 32M


Save and close the file.

Monday 30 November 2015

How to create nic channel bonding in redhat/centos/fedora linux.

Step 1: Creating Bonding Channel


As a root, create a new file name bonding.conf in the /etc/modprobe.d/ directory.
#cd  /etc/modprobe.d/
#vim bonding.conf

alias bond0 bonding
options bond0 mode=1 miimon=100

Save & exit

For each configured channel bonding interface, there must be a corresponding entry in your new /etc/modprobe.d/bonding.conf file.

Step 2: Creating Channle Bonding Interface
# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
IPADDR=192.168.1.8
NETMASK=255.255.255.0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no

Step 3: Configuring Channel Bonding Interface
For eth0

# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none

For eth1

# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none


Step 4: Restarting Network Service

Restart the network service and see the output of ifconfig.

# service network restart
[root@amir network-scripts]# ifconfig

bond0     Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          inet addr:192.168.1.8  Bcast:172.16.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe69:31c4/64 Scope:Link
          UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1                                RX packets:19676 errors:0 dropped:0 overruns:0 frame:0
          TX packets:342 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1623240 (1.5 MiB)  TX bytes:42250 (41.2 KiB)

eth0      Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
          RX packets:10057 errors:0 dropped:0 overruns:0 frame:0
          TX packets:171 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:832257 (812.7 KiB)  TX bytes:22751 (22.2 KiB)
          Interrupt:19 Base address:0x2000

eth1      Link encap:Ethernet  HWaddr 00:0C:21:60:30:C4
          UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1
          RX packets:9620 errors:0 dropped:0 overruns:0 frame:0
          TX packets:173 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:791043 (772.5 KiB)  TX bytes:20207 (19.7 KiB)
          Interrupt:19 Base address:0x2080

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0

          RX bytes:104 (104.0 b)  TX bytes:104 (104.0 b)

How to install clamAV on Centos 6

  Install EPEL repo: Before we can do proceed, you must ensure that you have the EPEL yum repository enabled. To do this, CentO...