Showing posts with label Putty. Show all posts
Showing posts with label Putty. Show all posts

Monday, 23 September 2013

How to configure phpMyAdmin to access multiple servers from phpmyadmin?

Hi Guys,

Open the following URL in editor:

vim /etc/phpmyadmin/config.inc.php

Now,

   $i++;

    $cfg['Servers'][$i]['auth_type'] = 'cookie';
    /* Server parameters */
    //if (empty($dbserver))
    $dbserver = 'servername';
    $cfg['Servers'][$i]['host'] = $dbserver;

    if (!empty($dbport)) {
        $cfg['Servers'][$i]['connect_type'] = 'tcp';
        $cfg['Servers'][$i]['port'] = $dbport;
    }
    //$cfg['Servers'][$i]['compress'] = false;
    /* Select mysqli if your server has it */
    $cfg['Servers'][$i]['extension'] = 'mysqli';
   
Cheers!!!

Monday, 16 September 2013

How to count files and line recursively using ubuntu?

Hellos,


How to count number of files recursively?

find . -type f | wc -l


How to count number of lines in files recursively?

wc -l `find  -name '*.php' -o -name '*.html' -o -name '*.xls' -type f`;

Cheers!!!









Friday, 12 July 2013

How to send mail from shell scirpt?


Hi All,

First of all we will create a sh file and write script see example below:

vim notificationFailedCron.sh

Write down the following code in the above file:

#!/bin/bash
dt=`date +%F`
echo $dt
passwd="pwd"
count=`mysql -uipay_read -p$passwd -h localhost -D database_name -B --skip-column-names -e "select count(*) from tablename where last_execution_status = 'notexecuted' AND date(created_at) = '$dt';"`
if [ $count -ge 5 ]; then

echo $count;
mail   -s "$count Payment notifications are getting failed."  abc@abc.com  <<< 'There are $count notifications are pending due to cron job failure'
fi


Now setting cronjob which will run every minute:

* * * * * /path/to/file/ipay4me_cronJob/notificationFailedCron.sh /usr/bin/php Asia/Calcutta >/dev/null 2>&1



Cheers!

Thursday, 16 May 2013

How to open crontab in VI editor?

Hi  All,

Please write the following command to see crontab in Vi editor:

VISUAL=vi crontab -e

Cheers!!

Wednesday, 30 January 2013

How to change extension from upper to lower case in ubuntu?

Dear All,


rename 's/\.JPG$/\.jpg/' *.JPG

The above command will convert all JPG to jpg.


Cheers!


Wednesday, 23 May 2012

How to fetch data in excel/csv format using mysql query?

Dear All,

Suppose you have a query given below:
SELECT ud.email FROM user_detail ud group by ud.email having count(ud.email) > 1;

The above query return all email addresses which are duplicate in the system.

Now go to server and type following:

## Fetching duplicate email address and saving them into file...   
mysql -uuser_name -p -hhost_name -A -Ddatabase_name -B --skip-column-names -e "SELECT ud.user_id, ud.email FROM user_detail ud group by ud.email having count(ud.email) > 1;">  /var/www/duplicateEmail

"/var/www/" is a path where you want to save file.
"duplicateEmail" is a file name.


Cheers!

Wednesday, 25 April 2012

How to find how many processes are running in linux?

Hi Folks,

ps -ef | grep 'ipay4me_new'



here ipay4me_new is a text which is using in process url

Thanks

Friday, 13 January 2012

How to delete files periodically usign cron.

Hi All,

Please use the following line to delete files:

find /var/www/archive/dbbackup/ -type f -name '*.sql.gz' -mtime +1 -exec rm {} \;

-mtime +1 means all files older more then 1 day.

Thanks
Cheers!

Thursday, 13 October 2011

How to find text recursively in file using linux commad?

Folks,

Please use the following command:

find <folderpath> -type f | xargs grep -l "131848637983654"

Here "131848637983654" has to find in <folderpath>

Cheers!

Thursday, 29 September 2011

How to automatically backup mysql database using cron?

Hi All,

Open crontab in linux server or window server and write the following line. this will backup database each mint.

$crontab -e

press enter and crontab will be opened and write following line:

* * * * * mysqldump -uroot -proot  ipay4me | gzip -9 > /var/www/archive/dbbackup/ipay4me.sql.gz


OR


$vim /var/www/archive/dumpdatabase

Write down following lines into that file:

#!/bin/bash
clear
mysqldump -uroot -hlocalhost -proot ipay4me | gzip -9 > /var/www/archive/dbbackup/ipay4me_$(date +"%d-%m-%Y-%H-%I-%S").sql.gz
exit 0


Set crontab:

50 11 * * * /var/www/archive/dumpdatabase /usr/bin/php Asia/Calcutta >/dev/null 2>&1

This cron will run daily at 11:50 PM



Cheers!

Tuesday, 27 September 2011

How to import a compressed mysql file .sql.gz using linux?

Hellos,

Please do the following to do the same.

zcat /newsites/urdutahzeeb/urdutahzeeb.net/dbbackup/urdujoom.sql.gz | mysql -u naughty -p urdujoom

Cheers!


Friday, 29 July 2011

How to enable error log in php?

Hi Folks,

Go to vim etc/php5/apache2/php.ini where you will find log_errors = Off

change Off to On. save file and exit.

Now restart apache server with the following line:

sudo etc/init.d/apache2 restart

Now,

To see what is coming into log, do the following task:

create php file and wirte some code with errors.

and run the following command:
tail -f var/log/apache2/error.log


Cheers!

Monday, 18 July 2011

How to dump database using linux command?

Hellos,

Suppose

host = localhost
user = root
password = root
database = payforme

Then

Type the following command:
$ mkdir mysqldumpfolder;
$ cd mysqldumpfolder;
mysqldumpfolder $ mysqldump -u root  -h localhost -p  payforme | gzip -9 > payforme.sql.gz;

After enter it will ask you to enter password.
give mysql password and mysql start dumping your database to mysqldumpfolder folder.

Tuesday, 28 June 2011

How to check where our database files located in linux?

Go to mysql using command line.

> mysql -u root -p
mysql> SHOW VARIABLES LIKE 'datadir';
+---------------+-----------------+
| Variable_name | Value           |
+---------------+-----------------+
| datadir       | /var/lib/mysql/ |
+---------------+-----------------+

Now

exit from mysql and do the follwoing

> cd /var/lib/mysql

Here you will see all the database exist in this folder.

Cheers!

Wednesday, 11 May 2011

How to get difference between two folder using linux command?

Hi

Use the following syntax to get difference b/w folders:

 diff  /home/ashwanik/public_www/openid_old /home/ashwanik/public_www/openid_new  |sort


To check recursively go down subdirectories, add -r.

diff -qr <first folder> <second folder>  |sort


Cheers!

Wednesday, 27 April 2011

How to read last 10 line in a file using linux command?

tail -10 filename

also,

tail -f filename

Cheers!

How to go start and end of the file open fron VI?

For Beginning press esc then :0
For Ending press esc :$ OR shift+g

Cheers!

Tuesday, 26 April 2011

How to remove .svn folder using linux command?

Go to that folder and run the following command:

find ./ -name ".svn" | xargs rm -Rf


Cheers!

Thursday, 27 January 2011

How to remove ^M from VI editor ?

Hellos


To remove this, open your file in vi editor and type
:%s/(ctrl-v)(ctrl-m)//g

OR

:%s/^M//g


Here %s is search and replace command in VI
^M is need to replace
Enter text between // which you want there
and 
finally g is using for all occurrences.




Cheers!

Friday, 21 January 2011

How to run php commands in command line on ubuntu?

Use the following example to run php command in command line:

$ php -a
php > echo 'aswani kumar';
ashwani kumar
php >


Cheers!