Ubuntu « Intelligrape Groovy & Grails Blogs

Posts Tagged ‘ Ubuntu ’

Speeding up Ubuntu

Posted by manoj on December 6th, 2011

Of-late my laptop has been highly responsive …. as responsive as a sloth can be… :P
I mean you wouldn’t be expecting an Intel i5 Processor with 4GB Ram and 500GB hard disk making you go for a coffee break every time you had to build or compile your code.
I am sure many of you must have experienced some form of lag with your Ubuntu (I am using 11.10… But I did experience some form of lag with 10x series also).

So in this blog post I’ll be discussing some ways that you can follow to speed up your Ubuntu

1). Disable StartUp Apps the Smarter Way

Now when I started up StartUp Applications on a my Ubuntu 11.10 installation, all you can see are a mere 5-6 apps. Mine Actually had a whole lot more that were run at start up but are simply not shown like Yakuake, Gwibber, Desktop Sharing Sevrer, Bluetooth Manager etc. Ubuntu 11.04 was somewhat better where you could see most apps but still not all that would be let loose at startup. Using the following commands, I was able to enable all apps running at startup to be shown here.

cd /etc/xdg/autostart
sudo sed --in-place 's/NoDisplay=true/NoDisplay=false/g' *.desktop

Once that was done, restarting Startup Applications now showed all the apps that were running at startup. Just read the description once and decide whether you want to keep it at startup or not.

Startup Applications shown Initially

Startup Applications Now Showing Full List

Startup Applications Now Showing Full List

rcconf is another tool that can be used but I found this method much more comprehensive and user friendly.

2). Swappiness is inversely proportional to Happiness :D

Swappiness is a property for the Linux Kernel that decides on how often to use the swap space. Most of the laptops today are equipped with 3-4 GB of Ram. So the principle of having double the swap space w.r.t to your memory size seems a bit outdated to me. Even though there was plenty of Ram available, my OS insisted on using the swap space, which in turn decreased responsiveness.
So I then moved on to change the swappiness value(Range:0-100, Default: 60)
Since I had a decent amount of RAM that could handle almost anything that was thrown at it, I decreased the swappiness quotient to 20.
To check the current swappiness value just type the following..

 cat /proc/sys/vm/swappiness 

Next to adjust the value swappiness value open

 sudo vim /etc/sysctl.conf 

Search for vm.swappiness and to change it to a desired value.If it is not present just add it to the end of the file. 10 is the figure that is mentioned on many forums, but I decided to play a bit safe and kept it a 20. Simply restart your system for the changes to take effect.

3). Reload Swap contents to Memory

Although I felt that decreasing the swappiness quotient did work for my computer, it is still possible that your computer swaps. This can hurt the multitasking performance of your system.
I found this script that you can use to to get the swap manually back into RAM.

err="not enough RAM to write swap back, nothing done"
mem=`free|grep Mem:|awk '{print $4}'`
swap=`free|grep Swap:|awk '{print $3}'`
test $mem -lt $swap && echo -e $err && exit 1
swapoff -a && swapon -a &&
exit 0

And place it at somwehere like

  /usr/local/sbin/swap2ram.sh 

Once you execute the script, it will transfer all your swap contents back to Memory, and free up your swap space. What it essentially does is turn off  swap space forcing everything back into RAM and turning it back on.

There are many more things that you can do to tweak up the speed of your computer, though I felt these 3 steps helped me a lot.
Hope this Helps :D

Manoj Mohan
manoj(at)intelligrape(dot)com
  • Share/Bookmark
Tags: , ,
Posted in Linux, System

Creating a Perfect System in few minutes.

Posted by Hitesh Bhatia on October 22nd, 2011

There might come up a case where you need to install same kind of OS and other Softwares( which are required for daily use) on multiple systems. One of the ways to do it is follow the same procedure on each of the machines, which is obviously a pain. Here’s a easy way to do it by using Clonezilla.

Now with clonezilla you will have to setup one system only, this this would obviously take time. But once the first system is done, you can just setup rest on other machines in few minutes.

Here are the steps, that I used to follow to create system with both Windows 7 and Ubuntu in under 10 minutes. With all softwares installed which included Counter strike on windows, Couple of IDE’s on Ubuntu and Git , mySql , Java and more on Ubuntu.

  1. Setup a perfect system. Install OS and other software that are required. Once the system is ready we need to download few softwares.
    1. 7zip ( p7zip-full_9.04~dfsg.1-1_i386.deb).
    2. Tuxboot (Tuxboot-linux-8 ).
    3. Clonezilla (clonezilla-live-1.2.6-40-i686.iso).All three of these are freely available.
    4. And we would also need a USB drive preferably with space more than 16GB , as windows 7 installation takes 15 GB approx and Ubuntu 11.10 will take around 6GB and little extra for other softwares. Clonezilla uses very effective compression technique will reduce size to approx half. So 16GB USB drive would work just fine.
  2. Install CloneZilla on USB drive.
  3. Once Clonezilla is installed , its time to make image of Perfect System.
  4. After image is done, we are ready to clone out perfect system, to other machines.
  5. Making Clone of Existing image, Process to make clone are pretty much same as process described in step-3. Except Step-11 of “making image” . Just select restore disk, this will create clone of image on disk. And ALL EXISTING DATA FROM DISK WILL BE ERASED. Following  are the links of images depicting step 5.  Image 1,Image 2,Image 3,Image 4,Image 5,Image 6,Image 7,Image 8,Image 9. There images are taken from a camera, hence please don’t mind  their quality.
  6. This is it , your next system is ready within few minutes. Now this process can be repeated again and again, to create clone of existing systems.

_________________________________
Hitesh Bhatia
Mail,LinkedIn,Facebook,Twitter
_________________________________
  • Share/Bookmark
Posted in Grails

Installing CloneZilla on USB drive using Ubuntu.

Posted by Hitesh Bhatia on October 22nd, 2011

Clonezilla is a software that allows you to do bare metal backup and recovery.

To install Clonezilla we would need following Softwares, all of which are available freely.

  1. 7zip ( p7zip-full_9.04~dfsg.1-1_i386.deb)
  2. Tuxboot (tuxboot-linux-8 )
  3. Clonezilla (clonezilla-live-1.2.6-40-i686.iso)

Here are the steps to install CloneZilla

  1. Install 7zip required to install Tuxboot
    1. sudo dpkg -i p7zip-full_9.04~dfsg.1-1_i386.deb
    2. It would show something like
    3. (Reading database … 168886 files and directories currently installed.)
    4. Preparing to replace p7zip-full 9.04~dfsg.1-1 (using p7zip-full_9.04~dfsg.1-1_i386.deb) …
    5. Unpacking replacement p7zip-full …
    6. Setting up p7zip-full (9.04~dfsg.1-1) …
    7. Processing triggers for man-db …
    8. And Step 1 is done. 7Zip is Installed.

2. Run tuxboot

    1. By default tuxboot is not executable , change it permission to make it.
    2. chmod +x tuxboot-linux-8
    3. Run tuxboot with sudo permission
    4. sudo ./tuxboot-linux-8
    5. Set the values as shown in image

    Step 5 - Installing Clonezilla

    5.1. Select Diskimage – then in adjacent dropdown select iso
    5.2. And then select the clonezilla image ( the one you downloaded)
    5.3. Type – usb drive
    5.4. Press “OK” . And let it complete. It will ask to reboot afterwards , but you can also reboot later

3. And your clonezilla usb is ready now. You may now use it to clone systems.

_________________________________
Hitesh Bhatia
Mail,LinkedIn,Facebook,Twitter
_________________________________
  • Share/Bookmark
Posted in Linux, System

Organizing “.bashrc”

Posted by Himanshu Seth on August 17th, 2011

I have been working on Linux for almost 3 years now and have grown to love it a lot.

As with every linux user, the .bashrc file becomes cumbersome and difficult to maintain over a period of time, since there are a lot of project specific aliases, paths, etc

So after working on a couple of projects, I started maintaining separate files for my environment settings. So I just had to create a separate project setting file:

~/.myProjectSettings
alias myAlias1='cd /to/project/dir'
alias projectqa='ssh to@qa'
alias projectDb='mysql -u<username> -p<password> <project_db_name>'

So, everytime I had to add more project specific settings or separate my settings, I had to create a new settings file and then source it in my .bashrc by adding this line

. ~/.myProjectSettings

As you can guess, after doing this a couple of times, even this was becoming very tedious.

So, I tried to follow the golden rule of convention over configuration.

In my .bashrc, I added the following function :

function sourceAllMySettings(){
	FOLDER_TO_BE_SOURCED=~/.mySettings/
	for i in `find $FOLDER_TO_BE_SOURCED -type f`;
	do
		. $i
	done;
}
##don't forget to execute the function
sourceAllMySettings

and placed all my setting files into the folder :

~/.mySettings/

So, now if I have to add more settings to my .bashrc, I just create a new executable file in this folder and it gets automatically sourced.

Goodbye messy .bashrc, welcome organized (segregated) settings :)

Regards
~~Himanshu Seth~~

http://www.IntelliGrape.com

  • Share/Bookmark
Tags: ,
Posted in Linux

Mounting an EBS Volume to an Instance and Soft Linking a Growing Directory to it

Posted by Vivek Krishna on May 5th, 2011

We were having a crisis on our project the other day. The VPS on which we were running our application had some issues with kernel and Tomcat, for that matter, any java process was running unpredictably. Tomcat would explode the WAR file once in a while and even if it did, it would just pause at “Deploying app.war” forever. After spending some time troubleshooting (we didn’t know that it was an issue with the kernel), we decided to move our infrastructure to Amazon EC2. We picked up an EBS based large instance, running Ubuntu and copied the setup from our production server to this new machine. The setup was a breeze, thanks to the scripts we already had in place for migrating our production setup to our QA machines for testing purposes.

However, we realized that Image Magick, which was being used from our application was not working as expected. In fact, it wasn’t working at all. We noticed that we were able to perform it as root, but not as any other user. The error which showed up was that there was lack of disk space. Static documents generated by our application were stored on the file system and it was meant to be an ever expanding directory. The EBS instance we had chosen had a capacity of just 8GB and about 6 GB of that was being occupied by the OS and the rest of our infrastructure. We decided to move this particular directory to a new EBS volume.

This could be accomplished smoothly, thanks to the ease of attaching a new EBS volume to an instance. We added a new volume and then, performed the following steps to move this particular expanding directory.


mke2fs -F -j /dev/sdh #This is to create an ext3 file system for the device attached at /dev/sdh

mkdir /path_to_new_file_system

mount /dev/sdh /path_to_new_file_system #mount the new file system at this directory

cp -r static_documents_location /path_to_new_file_system #Copy the files from the existing directory to the new directory

mv static_documents_location static_documents_location_backup #Backup the existing documents, just in case anything goes wrong

ln -s /path_to_new_file_system/static_documents_location static_documents_location #Create a soft link to refer to the new file location with the same name as the previous one

With these steps, we were good to go on the Amazon machine without even requiring a Server restart. We were expecting a downtime of at least 10 minutes but this happened so flawlessly.

Hope this helps someone.

  • Share/Bookmark
Posted in Database, Linux, System

byobu: screen sessions in Linux

Posted by Salil on April 13th, 2011

This post is just to talk about Screen Sessions in Linux (esp. ubuntu) using command “byobu”.

 

What is Byobu?
Byobu is a Japanese term for decorative, multi-panel screens. As an open source project, Byobu is an elegant enhancement of plain GNU Screen.

 

Where can it be used?
You SSH to some remote machine and Run some commands (application, service, etc). Now you want to logout of ssh session. But want your screen turned-on, so that you just resume it, the next time you access the machine.

 

How to use it?
It’s as simple as 2 steps process.

Step 1: Enter command "byobu"
Step 2: Press F2 (to create a new screen)

here you go!

 

Now you are in a detachable screen session. Enter your commands. And once you done –

Press F6 (to detach the screen)

If you are already logged-into some remote machine (using ssh), now you can logout. And your screen will remain there.
Then, when you come back — you can resume your screen back by following commmand

$ screen -r

It’s good to read about other options (like, screen -x)

 

Your comments are always Welcome. Please post if you have any!

 

Cheers!
Salil Kalia
Salil [at] IntelliGrape [dot] com
Twitter LinkedIn

  • Share/Bookmark
Tags: , , ,
Posted in Linux, System

Startup Script Using XdoTool

Posted by Hitesh Bhatia on November 13th, 2010

(Xdotool is a tool that simulates user key movements.)


Usually when we start to work , we usually require some apps to be running. In my case I have to run a grails app, sql , subversion and IDE in different tabs of same terminal.


Normally it would take almost 1-2 minutes if I do it manually.So I created a shell script using Xdotool .And it does all my work in almost 2 seconds. And All the tabs are opened in same terminal).Best part with xdotool is since it simulates key all your aliases work.


And it works perfectly on Ubuntu 10.10. (Tried and Tested)

Here is a snippet of script that I created.

xdotool key alt+t space;
xdotool type "etc";
xdotool key Return;
xdotool key ctrl+t alt+t space;
xdotool type "grails";
xdotool key Return ;
.
.
.
xdotool key ctrl+t alt+t space;
xdotool type "sql";
xdotool key Return;
xdotool type "mysql";
xdotool key Return

This opens new tab of same terminal.

1)xdotool key alt+t space;
The “key” keyword” tells xdotool that next inputs are treated as keys. So it opens “set title” pop up.(As Alt+t and space would do)


2)xdotool type “etc”;
xdotool key Return;

The “type” keyword tells that the next inputs are treated as text.And then enter key is simulated
Hence naming my tab “etc”


3)xdotool key ctrl+t alt+t space;
Opens new tab (I made ctrl+t shortcut for opening new tab in same terminal) and opens “set title” pop up


4)xdotool type “grails”;
And the tab is named as grails. And So on..


This helps me save time. hope it helps you too.

_________________________________
Hitesh Bhatia

Mail

LinkedIn,Facebook,Twitter

_________________________________

  • Share/Bookmark
Posted in Linux, System

Changing Location of MySql DataStore

Posted by Vivek Krishna on June 7th, 2010

On one of our projects, we had to store the MySql Data at a location different from the default location. This was needed because the server was on an instance-store Amazon instance which meant that the data would get lost if the instance had to be rebooted for some reason. After going through the tutorials and articles on AWS, we came across this excellent piece on how to setup MySql Data store on an EBS volume.

Later on, I tried out the steps on the local machine and see if we could move the MySql data store to some other location on our system. As it turned out, we could and here are the steps I followed.

Stop mysql server running on your system with the command

sudo /etc/init.d/mysql stop

Now, create folders named etc, lib and log at any location where you wish to save your mysql data. Let us keep them inside a folder called “/mysqldata”

mkdir etc lib log

Now, back-up your mysql data by copying the contents of /etc/mysql, /var/lib/mysql and /var/log/mysql to another location. Then, move the folders /etc/mysql, /var/lib/mysql and /var/log/mysql to the “/mysqldata”

mv /etc/mysql /mysqldata/etc
mv /var/lib/mysql /mysqldata/lib
mv /var/log/mysql /mysqldata/log

Let us now create new folders /etc/mysql, /var/lib/mysql, /var/log/mysql

mkdir /etc/mysql
mkdir /var/lib/mysql
mkdir /var/log/mysql

Now these new directories need to be mapped with the ones we moved to “/mysqldata”
This is done by setting the mount point for each of these directories to the ones which we created.
To do so, appending the following entries to “/etc/fstab”

mkdir /etc/mysql
/mysqldata/etc/mysql /etc/mysql none bind
/mysqldata/lib/mysql /var/lib/mysql none bind
/mysqldata/log/mysql /var/log/mysql none bind

With this done, let us mount all the entries by issuing the command

mount -a

MySql data store is now at another location.

Hope this helps

  • Share/Bookmark
Tags: , ,
Posted in Database, Linux

Web Testing using Selenium – fix for error “java.lang.NullPointerException: sessionId should not be null; has this session been started yet?”

Posted by admin on May 7th, 2008

I have a big fan of Selenium and have been using Selenium for quite some time for testing of web-applications.

Recently, I upgraded my machine to Ubuntu Hardy Heron and the next day, I found that all the selenium tests started failling on my machine. On digging through the logs, I found the following information in the Selenium Server logs:

java.lang.RuntimeException: File was a script file, not a real executable: /usr/bin/firefox-bin

Before actually spotting this line, I was mis-led by other log messages; but I will not talk about them in this post.

The reason for the failing tests was that Selenium Server thought that the default executable found in the path (/usr/bin/firefox) was a script file and not an executable application for the browser. I am not sure why Selenium Server checks whether the path to the browser should not be a script.

The cause of the problem is that because of  Ubuntu Hardy Heron upgrade, my firefox also got upgraded from 2.x to 3.x. The firefox browser executable in 2.x is a binary file; whereas for firefox 3.x, it is a script (.sh) file. As a result of this change, the check done by  Selenium Server was failing.

I resolved this problem by providing explicit path to the Firefox 2 executable file in the java code. (I also tried providing explicit path to the Firefox 3 executable but that is no help).

So, the code for the Java Selenium test-case looks like this :

selenium = new DefaultSelenium("localhost", 4444, "*firefox /usr/lib/firefox/firefox-2-bin", url);

This is not a solution, if you want to test your app with Firefox 3. I haven’t figured out the solution for making it work with Firefox 3; but for the time being, I am happy with testing my application with Firefox 2.

If somebody has a solution for making it work with Firefox 3, please post the solution as a comment to the blog.

-Deepak

  • Share/Bookmark
Posted in Java tools

Installing IEs4Linux on Ubuntu Gutsy Gibbon

Posted by admin on April 23rd, 2008

There are certain sites and applications which work only with Internet Explorer. One such application that I am currently working on is EMC Documentum Webtop.

After getting fed-up of the warning message thrown by Webtop about unsupported browser and some weird behavior sometimes, I finally decided to install IE on my Ubuntu machine.

I followed the following steps to install IE on my Ubuntu machine

  • modified /etc/apt/sources file to add/un-comment the following 2 lines

deb http://in.archive.ubuntu.com/ubuntu gutsy universe
deb-src http://in.archive.ubuntu.com/ubuntu gutsy universe
deb http://wine.budgetdedicated.com/apt gutsy main
deb-src http://wine.budgetdedicated.com/apt gutsy main

  • sudo apt-get update
  • sudo apt-get install wine cabextract
  • wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
  • tar xzvf ies4linux-2.0.5.tar.gz
  • cd ies4linux-2.0.5
  • ./ies4linux (make sure you are not root here)

When running the installer (the last step), I got the following error

ui/pygtk/python-gtk.sh: line 6: 15717 Segmentation fault (core dumped) python "$IES4LINUX"/ui/pygtk/ies4linux-gtk.py

After googling around to find a solution to the problem, I had a look at the ies4linux-gtk.py file mentioned in the error message. The line 6 looks like this

import gtk, gobject, pango, sys, os

Somehow, I suspected that there are some unmet dependencies, so looked for packages by the name gobject

apt-cache search gobject

and I found this:

gob2 – GTK+ Object Builder

I installed the gob2 package

sudo apt-get install gob2

and after that I ran the installer again and this time the installation succeeded without any problems.

Hope this helps somebody.

  • Share/Bookmark
Posted in Java tools, Linux