Archive for the ‘All about Linux’ Category

Rails Requires RubyGems >= 1.3.2 (You Have 1.3.1)

You might have faced this issue during the installation of a well known software called Redmine. I followed the installation steps of redmine from this link, but when I run the following command, I see this error message:

rake db:migrate RAILS_ENV=”production”

The fix to this problem is very simple, RubyGems is one of the core depency of Redmine, so you have an old version of RubyGem which is no longer workable. Now upgrade your RubyGems to the required i.e. 1.3.2 version by the following three simple steps:

Download latest (1.3.2) version.

wget http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz

Once download is complete run the following command to unzip the downloaded file.

tar -xvf rubygems-1.3.2.tgz

Install it by typing the following command in the terminal window.

ruby setup.rb

That’s it you should be done with the installation within minutes, Now proceed with further installation steps of Redmine. Cheers!

CaC – Download And Convert Videos From Youtube, Google Video In Ubuntu Linux

Youtube and Google Videos are considered as giants when we talk about streaming sites over the internet. These sites claim to entertain millions of users per hour and users are crazily downloading videos from such sites. You may find hundreds of such tools which download and convert videos from such sites to different famous formats, but you could have a limited number of choice of such tools on Linux. Search should be over now, CaC (Catch and Convert) is a wonderful utility which runs on Ubuntu and lets you download and convert videos from such sites.

Installation

Installation process is extremely easy for even a novice Linux user. Download .deb file from the link specified at the end of the post. Once download is completed, double click the downloaded file and follow the onscreen installation wizards. Or alternatively, open the terminal, go to the downloaded location and run the following command:

./cac_0232_linux_beta.deb

Once the installation is over, you will see a nice, user-friendly and eye candy interface. Download and convert videos to any format you wish.

Download CaC

BigDump – Restore Large MySQL Dump Files

BigDump is one of the commonly used php scripts which comes in handy if you are to import a larg .sql file. The conditions unders which it proves to be useful are:

  • You dont have access to server’s shell (command prompt).
  • You dont have PhpMyadmin available.
  • Your webserver and php configuration dont allow the upload of max file sizes.

Running this script is pretty easy. simply download it, unzip it, ftp into your website and upload this bidump.php file. Once upload is complete, open it and set the DB Name, Username and Password of your mysql server and the database you are going to import it. Once done, save this file and open it in web browser as http://yourdomain.com/bigdump.php (offcourse you will need to replace yourdomain.com with the name of your domain).  Here you will be presented with an interface to upload .sql file and import it.

Okay, That’s it, now you can upload and restore large database dump file without any worry. Cheers! :)


What Is Runaway Process, How To Identify And Kill It In Linux

Sometimes a process stops responding to system and keeps running, this process tries to take a big share of CPU and thus causes the overall system performance to slow. Such a process is called Runaway (Orphan) Process. You should get rid of such processes to avoid degradation in system performance.

How To Identify Runaway (Orphan) Process

Its not a big deal, simply run ps or top command and you will have an idea of the culprit. I would recommned running top command, once you run top command you will get full list of all running processes, here find out the process which you no longer need and it is running, then the second last parameter of the top command is Time, Note the time of such process, it must be running from hours. Another easy way to figure it out is that such processes dont have their parent ID processes active any more.

How To Kill Runway Process

Once you have identified such process, you have its ID. Run the following command you will get rid of the process.

kill pid

where replace pid with the actual ID of the process, if process refuses to die in such way then kill it forcefully.

kill -9 pid

That’s it, cheers!

Skip_Name_Resolve, Do We Really Need It In /etc/my.cnf ? [Understanding IP And DNS Logins In MySQL]

If you are willing to restrict mysql users based on the host names then this parameter must be there in /etc/my.cnf for the successful establishment of remote connection, otherwise its just fine. The purpose of this parameter is the use of DNS lookup service for authentication. I was browsing over the internet and found that so many people over the internet are having problem due to this parameter.

Lets just understand what exactly this parameter does. If you are running mysql on a high end production machine the you should set this parameter to on. If this parameter is setup then when a new IP address tries to connect to mysql then mysql takes the IP address and resolves it to a host name and after that it takes the host name and resolves it back to the IP address and in this way it  compares to ensure its original IP address. if you keep this parameter disabled then you can use only IP address in the MySQL grant tables.

For newbies or those who are not running mysql in not very production environment, setting this parameter can put them in trouble. Lets have a small example to clarify the point.

Lets see that your client system is named as  “test.linuxchunks.com”  and it is assigned some IP address say 58.58.73.22. You have turned DNS lookup feature of mysql to on, then you will grant privileges for your client machine as :

grant select on dbname.* to user@test.linuxchunks.com identified by ‘mypassword’

But when establishing connection from test.linuxchunks.com, you might get the error message  “Host 58.58.73.22” is not allowed to connect to this MySQL server”

This is because a reverse lookup of 58.58.73.22 may in fact return a fully qualified domain name other than the one specified. Like it may return FQDN as 58.58.73.22.dsl.net.pk ,rather test.linuxchunks.com.

I would also recommend having a look at another cool post on same topic here. Cheer!

PHP-mysqlnd Is Native MySQL Driver For PHP

Lets see how PHP and MySQL works together. Here is the list of three extensions which PHP uses to connect to MySQL.

mysql
mysqli
pdo mysql

All of the above mentioned extensions are rely on MySQL’s client library libmysql. Mysqlnd is an another and  alternative way of connecting  PHP 5 and PHP 6 to the MySQL Server. Now the question arises why use Mysqlnd instead of other extensions ?

Here is the list of advantages of Mysqlnd library over other mentioned extensions.

  • It is very easy to compile, it does not have any dependencies issues with mysql client programming support.
  • It performs much better then libmysql in certain cases.
  • It provides persistent connections for mysqli.
  • It key feature is that it uses PHP memory management and it supports PHP memory limit.
  • It is famous for reducing memory footprint because it stores every row only once in memory while in the case of libmysql  it  is saved twice in memory.

Cheer!

Awstats Not Visible In CPanel [How To Fix]

Those using cPanel based hosting services will be quite familiar with Awstats ( Advanced Web Statistics). Awstats is a well known log analyzer which creates advanced web, ftp, mail and streaming logs.Most of cPanel users rely on it to get updates about their web and ftp/mail activity.

One of the common bug with this is that sometimes it stops gathering statistics and when you click Awstats links from cPanel -> Logs > Awstats

all you see is a blank page.In order to fix the problem, log into the server via the root password and run the following native cpanel script to get it fixed.

/scripts/runweblogs [username]

Where replace [username] with the username of the domain having problem in loading Awstats page.

It will take some time during the processing, once completed, you must see your Awstats page back. Cheer!

10 Most Dangerous Linux Commands You Should Avoid

Many newbies in Linux do blunders and in fact a simple looking command sometimes turns the table. Linux gives full control over the system if you are logged in as root user, and running anyone of the following commands without clear understanding of them would lead to a disaster situation.

rm -rf permanently removes anything in the current directory. Make sure that you are in the desired directory otherwise running this command in any wrong directory will erase your crucial data. A little more secure command is rm-rf dirname/* where dirname is the name of directory which you wish to empty. See consquences of this command here.

Don\’t Run rm -rf

dd if=/dev/zero of=/dev/sda formates hard disk back to the factory settings.

mkfs.ext3 /dev/sda will format all data from the device specified after the mkfs command.

mv ~ /dev/null will erase everything from your root directory.  Basically /dev/null does not exists and anyting written to it is actually discarded from the system.

dd if=/dev/random of=/dev/port run this command if you are eager to freez your Linux system.

:( ){:|:&};: is a forkbomb command, once you run it, it will let you system freez and you will have no other way except to have it hard reboot ( Please dont run this command if you are feeling curiosity, consequences can be bitter :( )

rsync -r –delete /home/backup such commands has a delete switch  that can be used to destroy parts of the file system.

shutdown -h now shuts your system down and you will have to hard reboot it, dont run this command if you are hosting your servers in any data center or colocation. run shutdown -r now instead.

Feel free to pitch in here if you think I have missed any deadly command, cheers!

How To Optimize Apache Memory Usage In cPanel

cPanel is one of the well-known control panel with respect to web hosting domain. cPanel offers great easy to administer your server and domains along with other brilliant features. Apache is a world renowned web server which runs flawlessly on cPanel. In many cases the default settings of web server does not suffice your needs particularly if your domain has killer web traffic or processor intensive queries.  Apache can cause your website to load slow if its memory usage settings are not properly optimized. cPanel offers great feature to optimize memory usage consumption so that you should be on the track. lets see how we can use Apache’s memory usage feature from cPanel.

Launch your WHM and browse to Service Configurations > Apache Configuration.

Once you are there, you will see a list of options under Apache configuration, choose Memory Usage Restrictions. This option lets you limits based upon past memory usage. The new memory limits will be updated in the Apache configuration.

That’s it, you are on the final step now, click proceed and you are done, the appropriate memory settings will be adjusted in apache configuration.

That’s it, Cheers!

What Is SYN Attack ? How To Control It In Linux And CPanel Servers

What is SYN Attack

SYN is the most common type of DoS(Denial of Services) attack. In this sort of attacks, hackers use a large number of spoofed IP addresses to send TCP SYN packets to the target machines. Once target machine starts accepting such connections, it goes out of resources and system becomes unresponsive to real requests.

How To Check System Is Under SYN Attack

If you doubt that your system is under SYN attack, then run the following command to verify it.

netstat -an |grep :80 |more

You must see a list of SYN Packets if you are under attack, otherwise the output will be normal. A SYN effected system shows out as below:

tcp        0      0 56.34.53.58:80        211.48.6.244:1048       SYN_RECV
tcp        0      0 12.04.46.88:80        128.223.93.135:1167     SYN_RECV
tcp        0      0 49.44.58.78:80        194.15.197.170:1192     SYN_RECV
tcp        0      0 88.34.89.66:80        199.155.53.109:1039     SYN_RECV
tcp        0      0 88.43.44.32:80        4.168.188.28:1048       SYN_RECV

How To control SYN Attack

Make sure that you have firewall propely setup and the best way is to limit the total number of  TCP connections on your system. Following command can help you in this matter.

iptables -N syn_flood
iptables -A INPUT -p tcp --syn -j syn_flood
iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
iptables -A syn_flood -j DROP

On a cPanel based servers, it is also recommended that you should have latest kernel version for your operating system. Cheers!

« Older Entries