Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Saturday, 3 November 2018

Wifi (internet) not working after upgrade from ubuntu 16.04 to ubuntu 18.04?

Hello All,

Do the following on terminal to overcome this issue:

#sudo /etc/resolv.conf

Added nameserver 8.8.8.8

and then

#sudo /etc/init.d/networking restart


Done!!!


How to upgrade ubuntu 14.04 to 18.04

Follow the following steps:

#do-release-upgrade
#lsb_release -a
#apt update
#apt upgrade
#apt dist-upgrade
#apt install update-manager-core
#do-release-upgrade


Thanks

Thursday, 14 June 2018

How to upgrade nodejs and npm version in ubuntu 14.04

Hello,

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

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, 4 July 2013

How to create cron in symfony?


Hi All,

First of all create task using the below command:

 
php symfony generate:task [your task] 



for example:

php symfony generate:task notificationFailed

After executing above command you will see that following file has been created.

Creating "/var/www/archive/ipay4me_zen/lib/task /notificationFailedTask.class.php" task file


Now,

change the following variable in above created file:

$this->namespace        = 'project';
$this->name             = '[name-for-your-task]';
$this->briefDescription = '[some short explanation of what your task does]';


You will see another method called execute() given below:

protected function execute($arguments = array(), $options = array())
{
 // initialize the database connection
 $databaseManager = new sfDatabaseManager($this->configuration);
 $connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();

 // add your code here

 echo "I just did nothing at all, but at least I did it successfully!\n\n";
}


Let’s give it a test run. Open your command line and enter

php symfony project:[your task]


if everything is fine then you will see "I just did nothing at all, but at least I did it successfully!" otherwise correct error and run again.

If you see the expected output you’re then ready to go to the next step.


Note: if you want to access your app.yml variable here then you have to write following line:

$this->createConfiguration('frontend', 'prod')

or

$this->createConfiguration('frontend', 'dev')

Cron Setup:

* * * * * cd [YOUR SF APP DIR] && /usr/bin/symfony project:[YOUR TASK] >>[YOUR SF APP DIR]/log/crontab.log
e.g,

* * * * * cd /var/www/archive/ipay4me_new && /usr/bin/php symfony project:notificationFailed >>/var/www/archive/ipay4me_new/log/crontab.log


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!