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!

Jul 092011
 

Turn off magic_quotes_gpc in PHP

Answer:

magic_quotes_gpc is a legacy PHP function that no longer be supported in PHP 6.0. So you should disable them to make sure your application not break in the future version of PHP.

To disable it, edit the php.ini

vi /etc/php.ini

Locate and set

magic_quotes_gpc = off;

Remember to restart web server such as Apache if needed.

Jul 072011
 

Stage new and modified files in Git

Answer:

To stage new and modified files so that they will be committed in the future, you can use the simple command:

# git add .

So all the newly created and modified files will be staged.

Jul 052011
 

Auto remove expired binary log in MySQL

Answer:

If you have enabled the binary log in your MySQL server, you need to be aware that the log will use up the space of your local disk space. Old binary logs are generally not needed and you can auto remove expired entries from the binary log.

To do so, edit the MySQL configurations, e.g. /etc/my.cnf

..
expire_logs_days        = 60
..

The above configuration will auto remove entries in the binary old if they are older than 60 days.

Don't forget to restart MySQL to take effect.

# /sbin/service mysqld restart

Jul 032011
 

Sort numerical value using the sort command

Answer:

Assume you have a text file contains the following content:

1
2
3
10

When you use the sort command to sort them, it will give the following output:

# sort test.txt
1
10
2
3

So you need to sort them according to the numerical values?

Try with the n flag:

# sort -n test.txt
1
2
3
10
Jul 012011
 

List of remote gems on rubyforge.org

Answer:

To list all the available gems on rubyforge.org, use this command:

# gem list --remote

For example, to search for all rails related gems, use

# gem list --remote | grep "\-rails"