Category Archives: Linux

Linux being one of the most widely used system now a days we shared tips here which user may find useful
The commands and tricks being shared are already implemented on production servers
which you can use without any worries.

FTP issue Error: Failed to retrieve directory listing

Getting error while doing ftp in cpanel server

“Failed to retrieve directory listing”

 

Status: Connecting to 199.162.171.19:21…
Status: Connection established, waiting for welcome message…
Status: Initializing TLS…
Status: Verifying certificate…
Status: TLS connection established.
Status: Server does not support non-ASCII characters.
Status: Connected
Status: Retrieving directory listing…
Command: PWD
Response: 257 “/” is the current directory
Command: TYPE I
Response: 200 Type set to I
Command: PASV
Response: 227 Entering Passive Mode (199,162,171,19,200,207).
Command: MLSD
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
Status: Disconnected from server

 

The issue is due to IPtables

Fix for this is

Open the iptables config file

root@server [~]# vi /etc/sysconfig/iptables

Comment the below 2 lines

#-A INPUT -j REJECT –reject-with icmp-host-prohibited

#-A FORWARD -j REJECT –reject-with icmp-host-prohibited

and restart iptables

root@server [~]# /etc/init.d/iptables restart
iptables: Applying firewall rules: [ OK ]

Now FTP works fine

Status: Connecting to 197.162.171.19:21…
Status: Connection established, waiting for welcome message…
Status: Initializing TLS…
Status: Verifying certificate…
Status: TLS connection established.
Status: Server does not support non-ASCII characters.
Status: Connected
Status: Retrieving directory listing…
Command: PWD
Response: 257 “/” is your current location
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Response: 227 Entering Passive Mode (197,162,171,19,139,185)
Command: MLSD
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
Status: Disconnected from server
Status: Connecting to 199.162.171.19:21…
Status: Connection established, waiting for welcome message…
Status: Initializing TLS…
Status: Verifying certificate…
Status: TLS connection established.
Status: Server does not support non-ASCII characters.
Status: Connected
Status: Retrieving directory listing…
Command: PWD
Response: 257 “/” is your current location
Command: TYPE I
Response: 200 TYPE is now 8-bit binary
Command: PASV
Response: 227 Entering Passive Mode (199,162,171,19,40,98)
Command: MLSD
Error: Connection timed out after 20 seconds of inactivity
Error: Failed to retrieve directory listing
Status: Disconnected from server
Status: Connecting to 199.162.171.19:21…
Status: Connection established, waiting for welcome message…
Status: Initializing TLS…
Status: Verifying certificate…
Status: TLS connection established.
Status: Server does not support non-ASCII characters.
Status: Connected
Status: Retrieving directory listing…
Status: Directory listing of “/” successful

Install ZendGuard on cPanel server

To install ZendGuard on cpanel server follow below steps

SSH to server as root user and run below script

root@online  [~]# /scripts/installzendopt

Updating digest list Fetching http://httpupdate.cpanel.net/cpanelsync/easy/targz.yaml (connected:0)…….(request attempt 1/12)…Using dns cache file /root/.HttpRequest/httpupdate.cpanel.net……searching for mirrors (mirror search attempt 1/3)……loaded mirror speeds from cache……mirror search success……connecting to 67.222.0.10…@67.222.0.10……connected……receiving…100%……request success……Done Downloading tarball for Zendopt Fetching http://httpupdate.cpanel.net/cpanelsync/easy/targz/Cpanel/Easy/Zendopt.pm.tar.gz.linux-generic-64 (connected:0)…….(request attempt 1/12)……connecting to 67.222.0.10…@67.222.0.10……connected……receiving…2%…5%…8%…10%…13%…16%…18%…21%…24%…26%…29%…32%…34%…37%…40%…42%…45%…48%…50%…53%…56%…58%…61%…64%…66%…69%…72%…74%…77%…80%…82%…85%…88%…90%…93%…96%…98%…100%……request success……Done Installing Zendopt Skipping install to /usr/local/php4, missing php.ini Determining PHP version Installing Zend Guard/Optimizer 6.0 for PHP 5.4 Activated Zend Guard/Optimizer

 

Now restart apache using below command to complete the process

root@hostonline [~]# service httpd restart

Innodb recovery

We were getting below error on checking

#  /etc/init.d/mysqld status

ERROR! MySQL is running but PID file could not be found

On trying to restart were getting below error

root@alpha [~]# /scripts/restartsrv_mysql
Waiting for “mysql” to restart …………
…failed.

Service Error
The “mysql” service failed to start.

Startup Log
Starting MySQL………… SUCCESS!

Log Messages
150627 23:53:37 mysqld_safe mysqld restarted
150627 23:53:37 mysqld_safe Number of processes running now: 0
150627 23:53:37 mysqld_safe mysqld restarted
150627 23:53:37 mysqld_safe mysqld restarted
150627 23:53:37 mysqld_safe Number of processes running now: 1
150627 23:53:37 mysqld_safe mysqld process hanging, pid 16496 – killed
150627 23:53:37 mysqld_safe mysqld process hanging, pid 16501 – killed
150627 23:53:37 mysqld_safe Number of processes running now: 2
/usr/sbin/mysqld[0x84cbc2]
/usr/sbin/mysqld[0x857c7a]
/usr/sbin/mysqld[0x91b362]
/usr/sbin/mysqld[0x9267d2]
/usr/sbin/mysqld[0x85942b]
/usr/sbin/mysqld[0x858f82]
150627 23:53:36 mysqld_safe mysqld restarted

mysql has failed. Contact your system administrator if the service does not automagically recover.

The error was due to corruption in innodb in server

We found the below fix successful to fix this issue

First make backup of my.cnf file as backup.my.cnf

Open the mysql configuration file  my.cnf which is in

root@alpha [~]# vi /etc/my.cnf

Add below entry in it

[mysqld]
innodb_force_recovery = 1

restart Mysql using below command in cpanel server

root@alpha [~]# /scripts/restartsrv_mysql

Waiting for “mysql” to restart ……waiting for “mysql” to initialize ……
…finished.

Service Status
mysql (/usr/sbin/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –user=mysql –log-error=/var/lib/mysql/alpha.redlogic.com.err –open-files-limit=100000 –pid-file=/var/lib/mysql/alpha.redlogic.com.pid) is running as mysql with PID 28440 (pidfile check method).

Startup Log
Starting MySQL.. SUCCESS!

Log Messages
150628  0:03:54 [Note] /usr/sbin/mysqld: ready for connections.
150628 00:03:53 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
150628 00:03:53 mysqld_safe mysqld from pid file /var/lib/mysql/alpha.redlogic.com.pid ended
150628  0:03:53 [Note] /usr/sbin/mysqld: Shutdown complete
150628  0:03:52 [Warning] /usr/sbin/mysqld: Forcing close of thread 119  user: ‘eximstats’
150628  0:03:50 [Note] /usr/sbin/mysqld: Normal shutdown
150627 23:56:34 [Note] /usr/sbin/mysqld: ready for connections.
150627 23:56:33 mysqld_safe mysqld from pid file /var/lib/mysql/alpha.redlogic.com.pid ended
150627 23:56:33 [Note] /usr/sbin/mysqld: Shutdown complete
150627 23:56:29 [Warning] /usr/sbin/mysqld: Forcing close of thread 1  user: ‘eximstats’
150627 23:56:29 [Warning] /usr/sbin/mysqld: Forcing close of thread 5  user: ”
150627 23:56:27 [Note] /usr/sbin/mysqld: Normal shutdown

mysql restarted successfully.

root@alpha [~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.5.42-cll MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> quit
Bye
root@alpha [~]#

Mysql was up and running now

innodb_force_recovery=1
skip-grant-tables

lvremove to remove logical volume from LVG

How to create spare Logical volume partition in linux server

We had a default install of

 

Screenshot from 2015-06-25 22:06:22

[root@SRV-01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_srv01-lv_root
50G 2.6G 45G 6% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 477M 67M 385M 15% /boot
/dev/mapper/vg_srv01-lv_home
860G 72M 816G 1% /home

As KVM virtualization need spare LVM to create vps on we had to free /home partition which has no data in it

So the process starts

#Using vgdisplay check the VG present

[root@SRV-01 ~]# vgdisplay
— Volume group —
VG Name vg_srv01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 931.02 GiB
PE Size 4.00 MiB
Total PE 238341
Alloc PE / Size 238341 / 931.02 GiB
Free PE / Size 0 / 0
VG UUID tBHSEL-UIHM-OMbu-9KWk-ZTW9-97j5-UzwQDl
#lvscan to check the LVM name

[root@SRV-01 ~]# lvscan
ACTIVE ‘/dev/vg_srv01/lv_root’ [50.00 GiB] inherit
ACTIVE ‘/dev/vg_srv01/lv_home’ [873.17 GiB] inherit
ACTIVE ‘/dev/vg_srv01/lv_swap’ [7.85 GiB] inherit

Before removing the Logical volume partition need to unmount it  else you get below error

[root@SRV-01 ~]# lvremove /dev/vg_srv01/lv_home
Logical volume vg_srv01/lv_home contains a filesystem in use.

 

So unmounted /home which has  /dev/vg_srv01/lv_home

[root@SRV-01 ~]# umount /home/

 

Now removed the logical volume using lvremove

[root@SRV-01 ~]# lvremove /dev/vg_srv01/lv_home
Do you really want to remove active logical volume lv_home? [y/n]: y
Logical volume “lv_home” successfully removed

Now /home  alias  /dev/vg_srv01/lv_home is free to create  VM on it

[root@SRV-01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_srv01-lv_root
50G 2.6G 45G 6% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 477M 67M 385M 15% /boot

upcp cpanel error

While running a upcp –force in cPanel server got below error
[2015-06-20 13:48:48 -0400] see http://go.cpanel.net/rpmcheckfailed for more information
[2015-06-20 13:48:48 -0400] The Administrator will be notified to review this output when this script completes
=> Log closed Sat Jun 20 13:48:48 2015
[2015-06-20 13:49:13 -0400] 17% complete
[2015-06-20 13:49:13 -0400] E Running `/usr/local/cpanel/scripts/updatenow –upcp –log=/var/cpanel/updatelogs/update.1434820770.log` failed, exited with code 1 (signal = 0)
=> Log closed Sat Jun 20 13:49:24 2015

Screenshot - Saturday 20 June 2015 - 11:42:31  IST

The issue is due to duplicate rpm in server

cPanel has a auto script to fix this issue

You need to use command /scripts/autorepair fix_duplicate_cpanel_rpms to remove duplicate rpm in server

root@server1 [/usr/local/apache]# /scripts/autorepair fix_duplicate_cpanel_rpms

This fixed the issue for me and now upcp is working fine.

 

kernel panic not syncing attempt to kill init

error

Creating a New Initial RAM Disk

If you have changed a motherboard or moved a disk to a different system it may fail to boot due to the lack of appropriate drivers in the initial RAM disk image (initramfs for CentOS 6, initrd for CentOS 5).

Boot in Rescue Mode
1.Boot from a CentOS installation disc (for example, CD #1 or DVD).

2.Type “linux rescue” at the “boot:” prompt.

3.Mount all filesystems in read-write mode.

Create the New Initramfs or Initrd

Change root to real root (‘/’) on your hard disk and make the new initramfs or initrd.
mount –bind /proc /mnt/sysimage/proc
mount –bind /dev /mnt/sysimage/dev
mount –bind /sys /mnt/sysimage/sys
chroot /mnt/sysimage
For CentOS 6:

Create a backup copy of the current initramfs:
cp -p /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak

Now create the initramfs for the current kernel:
dracut -f

If you need to build it for a specific kernel version (replace the version appropriately):
dracut -f /boot/initramfs-2.6.32-358.el6.x86_64.img 2.6.32-358.el6.x86_64

One useful option you might want to add is -H (–hostonly). With this option dracut installs only what is needed for booting your system. Otherwise dracut by default adds many drivers to the initramfs making its size larger than necessary. Many other options may be exercised. Please see man dracut, man dracut.conf and the upstream Deployment Guide.
For CentOS 5:

Create a backup copy of the current initrd:
cp -p /boot/initrd-$(uname -r).img /boot/initrd-$(uname -r).img.bak

Now create the initrd for the current kernel:
mkinitrd -f -v /boot/initrd-$(uname -r).img $(uname -r)

If you need to build it for a specific kernel version (replace the version appropriately):
mkinitrd -f -v /boot/initrd-2.6.18-371.el5.img 2.6.18-371.el5

If you are migrating a physical machine to a virtual one using the Xen hypervisor, replace the last command above with:
mkinitrd –with-xenblk initrd-2.6.18-371.el5xen.img 2.6.18-371.el5xen

Many other options may be exercised, such as adding non-loaded modules manually. See man mkinitrd for details. It may be necessary to modify /boot/grub/grub.conf and/or /etc/fstab depending on the details of your installation. This depends on your use of LABEL and/or UUID versus physical devices in the files, and is too complex an issue to get into in any detail in a TipsAndTricks article.
Reboot
cd /
sync
telinit 6

 

source http://wiki.centos.org/TipsAndTricks/CreateNewInitrd

 

SVNManager error in Softaculous

SVNManager in Softaculous give erros while installing

Came across this in a support request

The following errors were found :

– The SVN config directory does not exist.

– The SVN password file does not exist.

– The SVN access file does not exist.The solution is before installing svnmanager run:

su – username

svnadmin create ~/repos

As the user you want to install it as. Then rerun the installer. Make sure the repo path is /path/to/user/repos

This fixed the issue

WordPress login brute force

Facing issues with bruteforce on wp-login page in wordpress ?

You can stop it using below method,

copy paste the below code in httpd.conf and restart httpd

xx.xx.xx.xx is the IP address where you can add your own IP address to be able to access wp-login

<FilesMatch wp-login.php>
Order Allow,Deny
Allow from xx.xx.xx.xx
Deny from all
</FilesMatch>

Disable directory browsing linux

To disable the directory browsing in account you need to do the below steps

# cd to the directory you want to disable directory browsing

in my case it was

#cd  /home/online/public_html/images

create a new file .htaccess

# vi .htaccess

paste the below code in .htaccess

Options -Indexes

save file and exit

Now directory browsing is disabled

 

Amazon SES Request Expired, it must be within 300secs/of server time.

While using Amazon Simple Email Service, sometimes we encounter this error message:

 

” AWS Error Code: RequestExpired, AWS Error Message: Request timestamp: Sun, 13 Mar 2011 06:10:27 GMT expired. It must be within 300 secs/ of server time.”

This error probably means that Amazon SES time differs from your system clock time. If you’re using the command-line tools then you may need to adjust your system clock to match Amazon SES’s clock, which is synchronized with UTC.

If you’re using a linux system try this:

 

[root@hostonlinesupport4u.in ~]# yum install ntpdate
#  /usr/sbin/ntpdate 0.north-america.pool.ntp.org 1.north-america.pool.ntp.org 2.north-america.pool.ntp.org 3.north-america.pool.ntp.org

 

Fixed!!

 

Now you can easily send emails using SES.