GNU/Linux
How to Speed up Booting Into GNOME – A Gentoo Wiki Tip
8While there are several ways to cut down the time it takes for a GNU/Linux system to boot up completely, the most popular way is to prevent any unnecessary services from being started at the boot time(if you don’t host web pages from your machine, for example, then disabling the apache server from starting at boot time will save some precious CPU cycles). There are several HOWTOs littered around the internet describing how to identify and disable the services that are not needed by a user. You can go to Desktop -> Administration -> Services in GNOME to have a look at the most important services; the commands ‘rc-status boot’ and ‘rc-status default’ will give you a complete list. Make sure that you understand what a service does before trying to disable them.
Gentoo Wiki has another trick to speed up the boot process of Gentoo OS: start loading GDM at boot time by adding ‘xdm’ to the boot runlevel instead of the default runlevel. I am reproducing the procedure here mainly because the boot time for my Gentoo system got reduced roughly by 40% after I implemented this tip, which by no means is insignificant.
Follow these steps.
- Using your favourite editor, modify one line of code in the file /etc/init.d/xdm:
sh# emacs -nw /etc/init.d/xdm
Substitute the following line:
/sbin/telinit a &> /dev/null
with this line:
/etc/X11/startDM.sh &> /dev/null
(All the above names are case-sensitive.)
- Now run the following two commands:
sh# rc-update del xdm
sh# rc-update add xdm boot
That’s it. To immediately try it out, you can run ‘/etc/init.d/xdm restart’ command, or preferably, can do a full system reboot. The major gain for me after making this modification has been that the system no more gets stuck at the boot time for more than 10 seconds when it can’t find a DHCP server.
NOTE: This tip is meant only for the desktop machines. It’s not advisable for server machines for obvious reasons.
More information on Gentoo Wiki:
Moving A GNU/Linux Installation To A Different Partition
17When I had first installed the Gentoo GNU/Linux operating system, my initial plan was to use it just for a couple of weeks before overwriting it by installing some other new distribution from Distrowatch. But I started to like it so much in less than a month’s time that I replaced Debian Sid with Gentoo as the primary operating system on my personal desktop(the server still runs Debian Sarge). Almost an year now, I haven’t regretted the decision ever. What I did regret a few days ago, though, was the amount of disk space that I had allotted for Gentoo during its installation – a meagre 11GB partition! Mortals like me lack the foresight required in such situations.
I had never considered ‘moving’ an installed operating system to a different location until then – I thought it to be such a lousy way to lose the oppurtunity for a fresh installation of the OS from the scratch(avoiding the mistakes that were committed the last time). But installing a Gentoo system from the sratch! Heavens forbid. It had taken 3 days for me to get the a bare minimum Gentoo system up and running, nothing more than the GNOME desktop manager. Another 4-5 days to install the most basic applications. I was not prepared at all to go through similar 1 week of downloading, compiling and installing the packages again by starting from the scratch. I decided to move my existing Gentoo system to a new, bigger partition. Not just the data but the entire bootable operating system.
None of my reservations regarding moving an installed system to a new location turned out to be true after a quick google search about them: all one needs to accomplish this task is a new, empty partition and atleast a GNU/Linux Live CD to run the basic unix commands. I confirmed that this is indeed correct information and won’t result in an unusable system by getting help from folks on the linux IRC channels. I had only two things to confirm:
- If there is a way to ‘cp’ files which preserves the file permissions for the copied files, right? Yes. ‘cp -a’
- If /proc kind of directories which store special, non-data files will be re-created at the boot time and won’t create any problems while they are copied(or if they are skipped from the copy operation)? Yes.
Thanks to the folks on the IRC channels, both my doubts were clarified to my satisfaction(one must appreciate the level of depth that they are ready to go to explain such stuff, I got more than what I had asked for :) ) and I was well set to finally begin the process of moving my Gentoo system from the 11GB partition(/dev/hdc7) to a 40GB one(/dev/hdc6, which I had earlier formatted with ext3 filesystem).
- I could have tried to use GParted Live CD to resize the Gentoo partition if there were any free space available *after* my Gentoo partition. Unfortunately, /dev/hdc6 was the last partition on my third hard disk.
- Another way to accomplish the same task would be to use the dd command. But remember that it copies the empty(non-data) space also and hence would be very inefficient if you have very less occupied space on the partition. This was not the case with me, but I still thought that cp is a better bet for my case.
I booted into my Kubuntu system(can be done from any Live CD) and followed the procedure listed below to complete the process of moving my Gentoo Installation from /dev/hdc7 to /dev/hdc6:
- Unmounted /dev/hdc7 from /media/gentoo and re-mounted it with read-only option, just to be on the safe side(those who are attempting to do something like this *must* take a complete backup of their entire partition before beginning).
sh# sudo umount /media/gentoo
sh# sudo mount /dev/hdc7 /media/gentoo -o ro - Mounted the partition to which I want to move the Gentoo system.
sh# sudo mkdir /media/newgentoo
sh# sudo mount /dev/hdc6 /media/newgentoo - Copied the files from the old partition to the new one.
sh# sudo cp -a /media/gentoo/* /media/newgentoo/
The ‘-a’ option tries to preserve as much structure of the filesystem as possible(ownerships, permissions, symbolic links etc). Consider if ‘-x’ is also required in your case.
- Did one modification to the /etc/fstab file in /media/newgentoo(/ should now be /dev/hdc6).
sh# sudo emacs -nw /media/newgentoo/etc/fstab
Earlier:
/dev/hdc7 / ext3 noatime 0 1
Now:
/dev/hdc6 / ext3 noatime 0 1
- Modified the GRUB configuration file to add an entry for the new Gentoo partition. Did not remove the entry of the old Gentoo system for now and decided to remove it once my new system boots correctly.
NOTE: The grub installed on my MBR belongs to my Kubuntu installation. All the other GNU/Linux systems and the Windows operating systems have their boot loaders on their respective partitions whose entries I have added to the grub configuration file present in Kubuntu.sh# sudo emacs -nw /boot/grub/menu.lst
title Gentoo GNU/Linux(New)
root (hd0,7)
kernel /boot/kernel-genkernel-x86-2.6.14-gentoo-r5 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/hdc6 udev
initrd /boot/initramfs-genkernel-x86-2.6.14-gentoo-r5
savedefault
bootI actually made a copy of my previous entry and just changed the value of ‘real_root’ field from ‘/dev/hdc7 udev’ to ‘/dev/hdc6 udev’. The strange looking values of the rest of the fields owe to the fact that I have my kernel and initramfs images copied in /boot directory of my Ubuntu system(and hence needed no modifications). The Grub boot loader reads these files from there and then mounts /dev/hdc6 as the ‘real root’ device.
That’s it. I booted into the new Gentoo system by selecting its entry from the boot-loader menu, and soon the all familiar Gentoo desktop I had gotten used to for the past one year was ready to go. No hiccups, no troubleshooting and no tweaking was required. The only observable difference from my old Gentoo system was that I had a lot more free disk space now! I will continue to use the old system for some more time to do couple of testings(which I was afraid to do earlier) before erasing it to install another GNU/Linux operating system over it. With RC5 already available, Slackware 11.0 seems to be just around the corner ;)
For those who don’t have another GNU/Linux OS installed on their computers or don’t have the luxury to boot from a Live CD(for remote systems, for example) to perform the copying operations, the copying can be done from the running system(the OS you want to move) too – with a litttle more caution. A lot of information on this can be extracted from the Gentoo wiki pages(applies to all distributions, not just Gentoo) – Google search should take you there.
Develop Ruby Applications Using Vim 7.0 Editor
14I know that the geeks amongst you would like to believe that only one text editor program exists in this world. Depending on which of the two groups you fall into, its either Emacs or Vi. Its a cool life for such people: they don’t need to bother checking out the greatest and the latest of the development environments getting released in the market every day. Emacs and Vi always grow up to become the greatest editors soon after every technological innovation that takes place in the software world. They are stable, powerful, feature-rich, modular, customisable, extendable, ubiquitous and available in multiple flavours to suit the slightly different tastes even by the geek standards. The only downside of these two evergreen editors is the steep learning curve associated with them. But as with all great things, it more than pays off by the end.

In this article, we’ll witness the support for the Ruby language present in the latest version of the Vim editor – Vim 7. If the latest version of Vim is not available on your preferred distribution(through its package manager, for example), then you can build it from the source, and install it in the user home directory if you don’t want to mess up with the file organization of your package manager. Here is the procedure to install Vim 7.0 from the sources in the user’s home directory. If you already have it installed, then skip to the next section.
- Download the source package for Vim 7.0 editor.
- Extract it in the home directory and ‘cd’ into it:
sh# tar xvjf vim-7.0.tar.bz2
sh# cd vim70 - Install using the usual method for building from the source:
sh# mkdir $HOME/vim7
sh# ./configure –prefix=$HOME/vim7 –enable-rubyinterp
sh# make && make installMake sure that you run the above commands as an unprivileged user(non-root) so that the generated files get proper file ownerships. (Run the above commands as root and drop the ‘–prefix’ option to install it in system directories and make it available to all the users.)
-
Now you can run the editor by running the command ‘./vim’ from the ~/vim7/bin directory. The procedure to run the vi editor can be simplified using one of the following techniques:
- Add the ‘bin’ directory of Vim installation(~/vim70/bin in our case) to $PATH variable in the user’s profile(~/.bash_profile).
- As root user, create links to all the executables present in ~/vim7/bin directory into the /usr/bin directory under different names(vim7, vimdiff7 etc so as not to conflict with the files from a possibly already existing Vim installation) and then run them from anywhere using these new names.
- If you have installed it in the system directories, then of course you don’t have to worry about all these settings and can directly run the editor using the ‘vim’ command from any directory.
Configuring Vim 7.0 For Ruby Support
The first step that we had taken to get Ruby support in the Vim editor was to compile it using the ‘–enable-rubyinterp’ configure option. To get complete support for the Ruby programming language in the Vim editor, we need to add the following lines to the Vim configuration file .vimrc present in the home directory.
[Create it if it's not already there; an easy way to do this is to make a copy the sample vimrc file that comes with Vim 7.0, i.e.
Then add the following lines at the bottom of the .vimrc file]
set nocompatible
syntax on
filetype on
filetype indent on
filetype plugin on
Creating & Running Ruby Programs Using Vim 7.0
Now you are set to create your first Ruby program in the Vim editor.
sh# mkdir -p ~/progs/ruby
sh# ./vim ~/progs/ruby/first.rb
Type the following program in the editor.
[ruby]
class Greeting
def say(name)
puts “Hello, #{name}”
end
def shout(name)
puts “HELLOOOOOOO, #{name}”
def
end
greet = Greeting.new
greet.say(“Marc”)
[/ruby]
The editor should now look like this:

Apart from the neat syntax colouring that is visible in the picture, the Vim editor also does automatic code indentation and helps in code completion too. You can even run the programs from within the editor. Let us see how to access these features in Vim.
Add one more method(optional) to the ‘Greeting’ class that we had created earlier and name it something starting with ‘s’. I have added a function called ‘stash()’. Go to the end of the Ruby program and type ‘greet.s’ and stop – don’t complete the function name. If you press the key combination Ctrl-X Ctrl-O at this stage, Vim will pop-up a list of possible completions of the code that you have typed until now and lets you select one of those options. Below is a picture demonstrating the same.

To run the Ruby program from the Vim editor, let’s first introduce a small mistake in it: change the code from ‘Greeting.new’ to ‘Greeting.ne’ and issue the following command in the vi command mode(presss the escape key and type the following line):
:rubyf ~/progs/ruby/greet.rb


You should see the following error message displayed at the bottom of the Vim screen.

Now go back to the program and remove the error that we had introduced and re-execute the program. You should see the output of the program as shown below.

For more help on the Ruby support in the Vim editor, issue the “:help ruby” command and scroll through the information displayed.
End Notes
The biggest advantage of developing Ruby programs using the Vim editor is that one gets all the powerful features of the vi editor which we have been using for years and have completely gotten used to. If you are searching for an easy to learn and easy to use programming editor, then perhaps you need to search elsewhere(see links below for some options) but if you are primarily a vi user, or don’t mind investing some time initially to get used to this powerful editor, then the Ruby support available in it should make it an ideal choice for developing Ruby programs.
7-Zip Compression Format Support on GNU/Linux Using p7zip
27-Zip was hitherto a part only of my Windows tools arsenal; the compression tools available on GNU/Linux were so well integrated into the operating system that one hardly has to think about installing a separate compression tool. But even on Windows I had used 7-Zip to compress only to the gzip or similar popular compression formats and never to the native compression format of 7-Zip. It was only when by mistake I compressed a folder to the 7-Zip format(.7z) that couple of surprises were in store for me.
One is that, 7-Zip is lot more efficient at achieving high compression rates than most of the other popular compression tools(including gzip and bzip2). The difference in the sizes of compressed files was not trivial: .7z files were atleast 25% smaller than the .zip files created using WinZip(popular compression tool for Windows). Go to the home page of 7-Zip for some benchmarks of the different compression tools. As an example, consider the following statistics(from this source):
XAMPP Windows 1.5.4 28 MB Selfextracting 7-ZIP archive
XAMPP Lite 1.5.4 43 MB ZIP archive
XAMPP Lite 1.5.4 16 MB Selfextracting 7-ZIP archive
Even the compression and decompression times are not that high for 7-Zip.
The second surprise was that none of my GNU/Linux systems understood the .7z format ‘out-of-the-box’. Alas, the format of the most popular Free compression tool for Windows is not even recognised by the most popular Free software on the planet. A quick Google-search resulted in the port of the 7-zip package for the GNU/Linux platform – p7zip – hosted on sourceforge.net website. Below are the simple commands that will get it installed on Gentoo, Ubuntu and Debian systems. RPMs should be available for Fedora, SUSE, Mandriva etc distributions also or I think one can install it through their respective packaging systems too.
Installing p7zip:
7zip on Gentoo:
7zip on Debian/Ubuntu:
(Don’t forget to add ‘sudo’ in front of the command on Ubuntu systems).
How to use p7zip on GNU/Linux:
To create an archive of all the files present in a directory:
To extract the contents of an archive:
Use ‘-t’ switch to specify the compression format to be used(zip, 7z etc). For more help on number of available command line switches, type:
The software can be built from the sources too; download the source code from here.
More information about p7zip is available on the Sourceforge website. RPMs for Fedora and Mandriva distributions are provided on the same page.
Develop Ruby Applications Using JEdit Editor
2The JEdit editor today is among the most widely used programming editors. The editor has a very strong and committed developer & user community around it, which means an ever increasing number of features and its constantly improving stability. Today, it has enough number of features to compete with some of the best programming IDEs around. As is expected of a popular editor like JEdit, it has support for multiple programming languages(100+; eg: C++, Java, PHP, Ruby etc) and works on Windows, Mac OSX and GNU/Linux platforms. In this part of the “IDEs for Ruby Development” series, I discuss how to use JEdit editor to develop Ruby programs.
(Screenshots are taken in the GNU/Linux OS; same features are available on other platforms too.)
Download And Install JEdit Editor
Download the appropriate version of the JEdit package from the JEdit Download Page(the page also contains links to JEdit User Manual and JEdit Source Code).
JEdit depends on the Java Runtime Environment(JRE) to execute – make sure that Java is installed on your system before installing JEdit. Its straigh-forward to install JEdit on Windows and Mac OSX operating systems.
If you are a Gentoo user, the following command should download and install the latest version of JEdit available in the Gentoo portage tree:
On a Debian/Ubuntu system, add the following line to the ‘/etc/apt/sources.list’ file:
deb http://dl.sourceforge.net/sourceforge/jedit ./
Now running the following two commands will install the JEdit package:
sh# apt-get install jedit
(Use ‘sudo’ in front of all the commands if you are an Ubuntu user.)
You can use similar software package management tools to install JEdit on other GNU/Linux distributions(yum for Fedora, yast for SUSE etc) or install it using the RPM files. The application can be installed by building it from the source too.
Once the JEdit package is installed on your system, its time to install the plugin for the Ruby language.
Installing Ruby plugin for JEdit
Since the 0.8 version of the Ruby plugin for JEdit, it can be installed right from the JEdit editor. To install the plugin, start the JEdit editor, go to Plugins -> Plugin Manager menu, and click on the “Install” tab of the displayed dialog box. Wait for the dialog to fetch a list of all the plugins available for download and installation(you can view the list of plugins available for JEdit once it is downloaded and displayed in the dialog box, or you can also view a partial list of the plugins at the JEdit Quick Start page).

Once the table in the dialog box is filled with the available plugins, scroll down and search for the “RubyPlugin” entry and select it when found. Click “Install” to begin the download and installation process.

Develop Ruby Applications With JEdit
Once the plugin is installed, you are set to create Ruby applications in the JEdit editor environment. Some of the important feature that the Ruby plugin adds to the JEdit are code completion for methods, syntax error highlighting, automatic code indentation and integrated Ruby documentation. The plugin also adds the support to popup a window in which the user can browse the entire file structure of the Ruby program. The plugin is a work in progress and many more helpful features can be expected in the near future. RubyJedit.org website contains screenshots demonstrating some of the above mentioned features. Some more screenshots(related to integrated Ruby documentation in JEdit) follow.



JEdit is an excellent editor for editing programming code even without the Ruby plugin(Splitting and Docking Windows; Expanding and Collapsing Code Blocks); the plugin then adds sufficient Ruby specific functionality on top of it to make it one of the most feature-rich programming environments available today. For more ways to enhance the functionality of the JEdit editor, look at the other plugins available for installation in the Plugin Manager. The only downside of this editor is its sluggish behaviour especially when a lot of plugins are installed for it. Its load times become long and the general response afterwards won’t be too fast either. But with limited number of plugins, its an excellent choice to develop Ruby applications.
In the next and the last part of this “IDEs for Ruby Development” series, I will discuss using the ever popular Emacs and Vim editors to develop Ruby applications.
Recent Comments