Thursday, 27 February 2014

Watch videos in linux terminal

To install Livestreamer on Fedora, CentOS or RHEL:

 yum install python-pip
  pip install livestreamer 

Run livestreamer command with the URL:


You can also adjust the quality,

livestreamer 360p

Also with specific palyer,

livestreamer --player=mplayer

Wednesday, 26 February 2014

script to create tar files within specific size

If you want to take backup tar of public_html folder with tar files have specific size.
Please use below command.

tar -cv public_html/* | split -b 25000K --suffix-length=4 --numeric-suffix - sara.tar.

It creates many tar files with size of 25MB.

If you place this files under same directory and execute the below command to extract it.

cat falooka.tar.* | tar xvf -

it provides the public_html folder.

I already tested this script. Use it.

Tuesday, 25 February 2014

search and remove specific content in files.

f above command gives you correct output, execute following command to perform actual cleaning:

grep -lr --include=*.php "eval(base64_decode" /path/to/webroot | xargs sed -i.bak 's/<?php eval(base64_decode[^;]*;/<?php\n/g'

Executing above will remove eval(*) codes.  Above command will also generate a backup version of files it will modify. For example, if it removes code from index.php, you will find a new file index.php.bak in same directory with original content of index.php

Missing <?php tag in the beginning:
To add “<?php: tag in the beginning of index.php files, in case if you remove it accidentally use following command:

find /var/www/ -name "index.php" | grep "/htdocs/index.php" | xargs grep -L "<?php" | xargs sed -i "1s/^/<?php \n/"

Don’t worry. If you already have a “<?php ” tag in the beginning, it won’t be added again.
Extra Newlines at the top!
If you find after cleanup, extra newlines at the top of your code, then use following command to remove trailing newlines. Extra newlines creates problem for blog feeds.

find . -name '*.php' -exec sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' '{}' \;

Saturday, 22 February 2014

Redirect the request from Apache to tomcat using mod_proxy

If you want to redirect the apache request to tomcat[8080],use mod_proxy module.


You want access with this url

Please go to virtual host entry for in httpd.conf,

DocumentRoot /var/www/
ScriptAlias /cgi-bin/ /var/www/
#Options +Indexes
<Directory /var/www/>
AddHandler cgi-script .cgi .pl
ProxyPass /support/
RewriteEngine On
RewriteOptions Inherit

Also if you want to redirect some specific url's to another port use below method,

ProxyPassReverse / http://%{HTTP_HOST}:8080/
RewriteEngine on
RewriteCond  %{REQUEST_URI} .*\.(flv|mp4|mp3)$
RewriteRule ^/(.*) http://%{HTTP_HOST}:8080/$1 [P]

In this above example, requests for flv,mp4 & mp3 are redirected to port 8080 and then remaining ports are handled on regular port 80.

Thursday, 20 February 2014

copy some rules from a file to all .htaccess files

find /home/*/public_html -name ".htaccess" -exec cp {} "{}_$(date "+%F")_bak" \;

for i in `cat htsearch.txt`; do echo $i; rsync -avzr --append /htaccess $i; sleep 1; done;

Thursday, 13 February 2014

Remote smtp setup in exim

 - Copied default exim.conf from other cpanel server and added the below entries as client updated and restarted exim. Mails started working fine.

In exim.conf:
begin authenticators
driver = plaintext
public_name = LOGIN
client_send = : APIKey : APISecret [ Corrsponding key values here ]

* Only include the begin authenticators if it does not exist already, if it does just paste the rest below it.

2) Add a route in the Router Configuration:
driver = manualroute
domains = ! +local_domains
transport = mailjet_smtp
route_list = "* byname"
host_find_failed = defer

3) Add a transport to the Transport Configuration:
driver = smtp
hosts =
hosts_require_auth =
hosts_require_tls =

Saturday, 8 February 2014

Trouble shoot Apache segmentation fault issues

Server restarted gracefully.

Graceful restart requested, doing restart

[Thu Apr 26 02:17:26 2012] [notice] seg fault or similar nasty error detected in the parent process

We found the problem by using strace to watch httpd activity during failure. I had found that a /etc/init.d/httpd stop and /etc/init.d/httpd start worked fine, but /etc/init.d/httpd graceful or apachectl graceful brought the system down.

we find the parent process to all other httpd processes, the one with ‘1’ as the parent process, and strace it to watch activity using ps,

ps -aef | grep httpd

Go to screen & run,

strace -aef -p 8021 2>&1 | tee /tmp/strace.out

issue the command apachectl graceful

-Watch the file strace.out,
We see access for, which succeeds with a file handle (20), and access for an module, which fails with ENOENT (-1). The process then logs to the error log, and a segfault occurs.

Commenting out the line (insert a semicolon at the beginning of the line) and re-running the test gave another seg fault, but this time on So, out that goes too, comment that out and start httpd and gracefully restart it and… no error! The server stays up, strace output continues and operation is uninterrupted.