Tuesday, November 25, 2014

MEMORY LEAK

MEMORY LEAK

A memory leak is like a virtual oil leak in your computer. It slowly drains the available memory, reducing the amount of free memory the system can use. Most memory leaks are caused by aprogram that unintentionally uses up increasing amounts of memory while it is running. This is typically a gradual process that gets worse as the program remains open. If the leak is bad enough, it can cause the program to crash or even make the whole computer freeze.
The most common reason programs have memory leaks is due to a programming error where unused memory is not allocated back to the system. This means the amount of RAM the program uses is always growing. Therefore, the program is constantly "leaking" memory. A memory leak may also be caused by a program that requests new memory too frequently, instead of using available memory. This means each time more memory is requested, the program takes up additional RAM instead of using memory that has already been made available to the program.
Fortunately, memory leaks are not as messy as oil leaks and can be more easily fixed. Software development applications often include debuggers that can check programs for memory leaks. Once the source of the leak is found, the programmer can modify the code so that the program uses memory more efficiently. If you are using a program that has a memory leak, you can temporarily fix the problem by simply quitting the program and opening it again. Once the program has been quit, the memory is automatically allocated back to the system. Of course, if the leak continues to be a problem, the best solution is to let the developer know about the issue so it can be fixed.

Wednesday, November 19, 2014

Upgrade to Ubuntu 14.04 LTS from Ubuntu 13.04


Upgrading from point release is very easy. However, if you are skipping one or two releases and upgrading to Ubuntu 14.04 it may not be very straight forward if you go the traditional way. 
But, a simple 5 step command line approach can help you overcome that problem. Below are the steps to upgrade from Ubuntu 13.04 (Raring Ringtail) to Ubuntu 14.04(Trusty Tahr).

Before you start, please remember back up all your documents and all other data that you consider important. 

Disclaimer: Please follow the instructions at your own risk. I assume you have some knowledge of Linux and can troubleshoot. I am not responsible if your laptop/desktop goes up in flames!

  1. sudo sed -i 's/raring/trusty/g' /etc/apt/sources.list
  2. Disable third party ppas (optional, see note)
  3. sudo apt-get update && sudo apt-get dist-upgrade
  4. sudo apt-get install --reinstall ubuntu-desktop
  5. sudo update-grub
  6. sudo update-initramfs -u

Note: If you have third party ppas installed, you need to disable them. To do that run the following commands before you run the update command
cd /etc/apt/sources.list.d
sudo rename 's/(.*)/$1.bak/' *
sudo find . -type f -name "*" -print | xargs sed -i 's/raring/trusty/g'

Once all have been completed, reboot the system to login to the new Ubuntu 14.04 release.

If you want to enable the 3rd party ppas, just remove the .bak extension. To do that 

cd /etc/apt/sources.list.d
find . -type f -name "*.bak"  -exec rename 's/.bak//' {} \;

Tuesday, November 18, 2014

10 Yum Exclude Examples to Skip Packages for Linux Yum Update (How to Yum Exclude Kernel Updates)


Yum ExcludeWhen you perform yum update, it will download the latest version of all the packages that are installed on your system, and upgrade them to the latest version.
You may be in situation where you might not want yum to automatically update one (or more) specific package.
In those situations, use the yum exclude option as shown in the examples below.

1. Exclude a Single Package using option -x

For example, on this system, we are using PHP 5.1, and the custom php application running on this system is not tested with any other new versions of PHP yet.
# rpm -q php
php-5.1.0-27.el6_5.x86_64
So, in this case when we do a update, we want to exclude only one specific package, which is php. As we see below, the following indicates that php package will be updated to ver 5.3.3 when we perform the ‘yum update’ command.
# yum check-update php
php.x86_64    5.3.3-40.el6_6      updates
The following will exclude only one package (php) during the yum update.
# yum -x php update

2. Exclude Multiple Packages using option -x

You can exclude multiple packages by specifying multiple -x options as shown below:
yum -x php -x httpd update
You can also exclude more than one package by specifying the list of packages separated by comma. The following will behave exactly same as above.
yum -x php,httpd update

3. Exclude Multiple Packages (e.g. Kernel packages) using Wildcard

In most situations you might not want yum update to automatically upgrade the kernel.
Before you do the real yum update, you can perform yum check-update, which will display all the packages that it will upgrade during the yum update.
As you see below, in this example, there are three kernel related packages that will be upgraded by yum update.
# yum check-update | grep -i kernel
kernel.x86_64            2.6.32-504.1.3.el6  updates
kernel-firmware.noarch   2.6.32-504.1.3.el6  updates
kernel-headers.x86_64    2.6.32-504.1.3.el6  updates
Instead of specifying all the individual package names in the -x exclude list, we can simply use the shell glob wildcards as shown below. The following will exclude all kernel related packages form begin upgraded during the yum update.
yum -x kernel* update

4. Multiple Wildcard Lists in the -x Option

You can also specify multiple wildcard lists in the -x option.
As you see below, the following indicates that there are multiple php packages that will be upgraded during next yum update.
# yum check-update | grep -i php
php.x86_64         5.3.3-40.el6_6   updates
php-cli.x86_64     5.3.3-40.el6_6   updates
php-common.x86_64  5.3.3-40.el6_6   updates
php-xml.x86_64     5.3.3-40.el6_6   updates
If you want to exclude all php and kernel related packages during the next yum update, you can use the following. Please note that you should use ‘ ‘ in this example.
yum -x 'php*' -x 'kernel*' update

5. Using –exclude instead of -x

You can also use –exclude instead of -x as shown below:
yum --exclude php update
yum --exclude httpd update
yum --exclude kernel update

yum -exclude php*,httpd*,kernel* update

6. Exclude Packages Using yum.conf File

Instead of specifying the packages to be excluded in the command line, you can specify them in the /etc/yum.conf file.
For example, to exclude all the php, httpd and kernel packages to be excluded from the yum update, add the following line:
exclude=php* httpd* kernel*
Or, execute the following command:
echo "exclude=php* httpd* kernel*" >> /etc/yum.conf

7. Use Comma Separated List

You can also exclude more than one package by specifying the list of wildcard packages separated by comma. The following will behave exactly same as above.
yum -x php*,kernel* update
To be consistent with the way how we showed the other examples using the -x option above, you can also use comma (instead of just space) to separate the multiple packages as shown below:
# vi /etc/yum.conf
exclude=php*,httpd*,kernel*

8. Exclude Parameter inside Custom Repo File

Instead of specifying the exclude parameter in the main yum.conf file, you can also specify it in the individual repository file.
For example, if you’ave installed mongodb, you’ll have mongodb.repo under /etc/yum.repos.d directory. You can specify the exclude package list for the mongodb repository inside this mongodb.repo file.
# vi /etc/yum.repos.d/mongodb.repo
exclude=mongo*

9. Simulate Yum Exclude Check using check-update (Dry-run -x)

You can specify the -x option along with check-update also. This helps to you check whether the -x option you’ve specified either in the command line or in the yum.conf file is working as expected.
For example, the following indicates that the kernel will be upgraded during yum update.
# yum check-update | grep -i kernel
kernel.x86_64                        2.6.32-504.1.3.el6                  updates
kernel-firmware.noarch               2.6.32-504.1.3.el6                  updates
kernel-headers.x86_64                2.6.32-504.1.3.el6                  updates
The following indicates that the -x flag will work as expected as it didn’t return anything in the result.
# yum -x kernel* check-update | grep -i kernel
For example, let us say the following exclude line in present in the yum.conf file.
# grep exclude /etc/yum.conf
exclude=php*,httpd*,kernel*
Then, the following indicates that the exclude list specified in the above /etc/yum.conf will work as expected as check-update didn’t show those packages (including kernel) in the following output.
# yum check-update | egrep 'php|httpd|kernel'

10. Ignore the Exclude from yum.conf File

If you like to disable the excludes mentioned in the yum.conf file. i.e If you don’t want yum update to consider the exclude list that is specified in the yum.conf file, you can use the –disableexcludes option from the command line.
In our previous example, we’ve excluded php, httpd and kernel packages to be updated by the yum update.
But, if you want yum to ignore that exclude list (i.e disable the exclude) and continue to upgrade the php, httpd and kernel as part of the regular yum update command, execute the following:
yum --disableexcludes=all update
The following are the three possible values that you can specify to the disableexcludes
  • all Disable all excludes
  • main Disable excludes specified in the main section of the yum.conf file
  • repoid Disable excludes specified for the given repo id
If you want to disable the excludes only for a specific custom repository, you can specify the repo id (which is the 1st column in the yum repolist command as shown below).
# yum repolist
repo id   repo name           status
mongodb   MongoDB Repository    240
base      CentOS-6 - Base     6,518
extras    CentOS-6 - Extras      35
updates   CentOS-6 - Updates    315
The following will disable (ignore) the exclude list specified in the mongodb.repo file under /etc/yum.repos.d directory.
yum --disableexcludes=mongodb update