Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Jan 092011
 

Import a CSV file into MySQL database

Answer:

To import a CSV file into the MySQL database, you can use the mysqlimport command.

# mysqlimport mytable.csv test.mytable

The above command import the CSV file into the table named `mytable` in the database `test`

Jan 042011
 

Cannot start VirtualBox when installed KVM

Answer:

When you have installed the KVM module, it will conflict with your VirtualBox. To solve it in order to use the VirtualBox, execute the following command below:

1. For Intel CPU

# sudo rmmod kvm-intel

2. For AMD CPU

# sudo rmmod kvm-amd

Then you can start VirtualBox instance normally.

Jan 022011
 

Multi-line string in Perl

Answer:

To assign a multi-line string to a variable in Perl, is easy with the following trick:

my $html = <<END;
<p>
    This is HTML content.
</p>

END

print $html;
Dec 312010
 

Block request by user agent in Apache

Answer:

If you want to block request to your web site, by user agent string, you can change by editing the Apache's configuration.

Add the following lines to the Apache configuration (httpd.conf)

RewriteCond %{HTTP_USER_AGENT} googlebot
RewriteRule . - [F,L]

The above config block all requests from Google's Bot. (Make sure mod_rewrite is installed and enabled)

Also, remember to restart Apache to take effect

# apachectl -k graceful