Search This Blog

Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Tuesday, March 27, 2012

Making a mysql back up every day midnight using cron

This is a simple way to back up your database everyday Go to ubuntu command line and log in as root user, type following command to open crontab file

 >crontab -e

 type the following command in the file

 0 0 * * * mysqldump -uYOURUSER -pYOURPASSWORD YOURDBNAME > /home/tommy/my_back_up/mydb_`date +\%y-\%m-\%d`.sql

 you can restart cron by typing

 >restart cron

 OR

 >/etc/init.d/cron restart

This will create a sql dump file everyday midnight
file name would be mydb_2012-04-21.sql

Tuesday, February 21, 2012

list all cron jobs for all users

for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done

Thursday, December 1, 2011

Setting Up Name Based Virtual Hosting In Ubuntu

1. Append the following line to your /etc/apache2/apache2.conf .
     NameVirtualHost 127.0.0.2:80
2 . Create unique files for each of my domains within the /etc/apache2/sites-available/ folder.Create a fie called mysitename.com

<VirtualHost 127.0.0.2:80>
ServerName 
mysitename.com
ServerAlias www.
mysitename.com
ServerAdmin me@ubuntu.com
DocumentRoot /var/www/mysitename/html
</VirtualHost>


3. Enable it by creating a symbolic link from one folder to the next ( etc/apache2/sites-enabled/)

sudo a2ensite mysitename.com ( to diable it anytime sudo a2dissite  mysitename.com)  

harder way to create the symbolic link 

cd /etc/apache2/sites-enabled/
ln -s ../sites-available/
mysitename.com .


4. Editing the /etc/hosts by adding the following line

127.0.0.2:80 mysitename.com 

5. Restart apache sudo /etc/init.d/apache2 restart

****

To enable mod_rewrite in Ubuntu, you just need to write this command in terminal

sudo a2enmod rewrite

Monday, May 2, 2011

Setting up phpunit in ubuntu



  1. Install PEAR . Issue the command sudo apt-get install php-pear.
  2. Make sure PEAR is up to date. Issue the command sudo pear channel-update pear.php.net. 
  3. Upgrade the PEAR elements. Issue the command sudo pear upgrade-all.
  4. Tell PEAR where to find the PHPUnit code. Issue the command sudo pear channel-discover pear.phpunit.de
  5. Install PHPUnit. Issue the command sudo pear install -a phpunit/PHPUnit. The -a makes sure all dependency packages are also installed.
  6. Issue the command phpunit --version. You should have version 3.3.17 or newer installed.
  7. Install XDebug. Issue the command sudo apt-get install php5-xdebug. This is needed if you want the HTML based coverage reports. 
  8. Restart the web server after installing this package. (sudo /etc/init.d/apache restart ).
reference 

Saturday, April 30, 2011

Get terminal in right click context menu in ubuntu

If you want to get the open a folder in terminal by just right clicking on a folder run this command as the super user.
sudo apt-get install nautilus-open-terminal

Sunday, January 30, 2011

Command To Show the enabled modules in apache

sudo apache2ctl -l

Enable mode rewrite in apache2 ubuntu

This command works fine in ubuntu ,login as the root and type the following command to enable mode_rewrite.

sudo gedit /etc/apache2/sites-available/default


In the following section change AllowOverride None to AllowOverride All.


 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 allow from all
 # Uncomment this directive is you want to see apache2's
 # default start page (in /apache2-default) when you go to /
 #RedirectMatch ^/$ /apache2-default/



use rewrite rules

sudo a2enmod rewrite



Restart Apache


sudo /etc/init.d/apache2 restart

Monday, November 8, 2010

How to Uninstall Netbeans

root@user:/usr/local/netbeans-6.9# ./uninstall.sh

Wednesday, October 27, 2010

Ubuntu command to get the System hardware configurations

Run this command as the super user to get the complete hardware configurations
>lshw

Tuesday, October 26, 2010

How to run a single PHP Unit Test

How to run a single PHP Unit Test

phpunit --filter EmpSalaryReportTest AllTests.php

// Get unit test coverage report

phpunit --coverage-html ./report BankAccountTest

phpunit --coverage-html AllTests AllTests.php

Friday, October 15, 2010

How to create a new svn project and upload files

First create a new directory by issuing this command in the terminal
>svn mkdir -m "message" 
http://svnserver.com/repos/abc

now go to your working directory

abc>svn import -m "message" 
http://svnserver.com/repos/abc 
-m  has the comment you can write anything inside

Install Bisigi theam in ubuntu

sudo add-apt-repository ppa:bisigi/ppa && sudo apt-get update

sudo apt-get install bisigi-themes

Thursday, October 14, 2010

How to restore accidentally deleted crontab file

If you have accidentally deleted crontab file, probably using -r instead of -e. It happens because the keys are at the same place :-) , this is could be the rescue. Try to find the file inside Tmp folder.

go to /tmp

ls -ltr cron*

This will show a history of files. Choose the most reason one.

Monday, October 11, 2010

Command to list the disk partitions in Ubuntu

Command to list the disk partitions in Ubuntu . Login as the admin type this in command line

>fdisk -l

Tuesday, October 5, 2010

How to find the history of the commands given in Ubuntu

Type this command in the ubuntu console

>history

If you need a specific set of commands

>history|grep svn