Friday, August 28, 2009

Deluge: A cross platform bittorrent client

Deluge is a full-featured BitTorrent client for Linux, OS X, Unix and Windows. It has been designed using the client server model with a daemon process that handles all the bittorrent activity. The Deluge daemon is able to run on headless machines with the user-interfaces being able to connect remotely from any platform. Deluge features a rich plugin collection; in fact, most of Deluge's functionality is available in the form of plugins.
Installation on Ubuntu
As already mentioned , Deluge is available on a wide variety of platforms. For Ubuntu,Deluge is available in the universe repository. Cutting edge versions of Deluge is also available as a PPA via launchpad.
For installation from PPA, add the following lines to /etc/apt/sources.list
deb http://ppa.launchpad.net/deluge-team/ppa/ubuntu jaunty main
Import the key from the PPA site.
https://launchpad.net/~deluge-team/+archive/ppa
Install deluge
$ sudo apt-get install deluge

Screen shots.



Tuesday, August 25, 2009

command-not-found in Ubuntu 9.04 and 9.10

command-not-found is a special package in ubuntu that give you some extra information when you type a command that is not installed on the command line. It will look inside the package database and suggest a possible package to install so that the command can be run. command-not-found is installed automatically when you install ubuntu 9.04.

For example , I got this when I typed jed.
$ jed
The program 'jed' is currently not installed. You can install it by typing:
sudo apt-get install jed
bash: jed: command not found

However when I type

$ jid
bash: jid: command not found

The command -not-found hook neatly searches the package database and suggest a possible package for installation. The upcoming release of Ubuntu ( 9.10 aka Karmic Koala) will have spell checking incorporated into the command -not-found feature . It will suggest a list of possible packages even if you make a spelling mistake. See the following screen shot of my Karmic Koala Alpha 3.

Controlling Services from Command line

Before learning how to start, stop, and disable services from the command line, it's important to understand Ubuntu's startup process and how Ubuntu determines which programs to run when it starts.

Ubuntu uses System V style init scripts. The init scripts are located in a special directory named /etc/init.d. Even though there may be several init scripts present in /etc/init.d , not all of them are run at boot time. Ubuntu organizes which scripts to run for different circumstances into runlevels; most Linux systems have seven runlevels, ranging from 0 to 6.

A some of these runlevels are set aside for special states in a Linux system:
Runlevel 0 Halts the system.
Runlevel 1 Sets up single-user mode.
Runlevels 2-5 Set up different multi user modes. Although, typically, only one or two of these are used by a distribution.
Runlevel 6 Reboots the system.

Each runlevel has a directory that stores symlinks to certain init scripts in /etc/init.d, which are started when that runlevel is selected and stopped when it is exited. Ubuntu puts these symlinks under /etc/rc.d for example, all runlevel 2 scripts are located in /etc/rc2.d/.

If you look in one of these runlevel directories, you'll notice that many of the symlinks to scripts in /etc/init.d have odd names that begin with an S, K, or D; then a number; and finally the name of the script. Ubuntu defaults to runlevel 2, so here is a partial sample of my /etc/rc2.d directory:

lrwxrwxrwx 1 root root 19 2009-05-13 09:58 S01policykit -> ../init.d/policykit
lrwxrwxrwx 1 root root 15 2009-05-13 09:58 S10acpid -> ../init.d/acpid
lrwxrwxrwx 1 root root 14 2009-05-13 09:58 S10apmd -> ../init.d/apmd
lrwxrwxrwx 1 root root 18 2009-05-13 09:58 S99ondemand -> ../init.d/ondemand
lrwxrwxrwx 1 root root 18 2009-05-13 09:58 S99rc.local -> ../init.d/rc.local
lrwxrwxrwx 1 root root 19 2009-05-13 09:58 S99rmnologin -> ../init.d/rmnologin
lrwxrwxrwx 1 root root 24 2009-05-13 09:58 S99stop-readahead -> ../init.d/stop-readahead

As you can see, this directory is full of symlinks that point to a script in the init.d directory.
The letter at the beginning of each filename tells init when to execute this script. If the script begins with an S, then init starts the script when it goes through the runlevel. If the script begins with a K, then init stops (or kills) the script when it changes to a different runlevel. If the script begins with a D, then that script is disabled for the time being, and init ignores it. init runs the scripts in numerical order, so the numbers in each script let you know in which order they are to be run. This is useful to ensure that dependent services start after the service they are dependent on.
Ubuntu 9.04 uses upstart daemon to manage init scripts. The configuration files for upstart are located in /etc/event.d/ . ( On earlier systems, the start up was managed from /etc/inittab. You will not find this config file in new ubuntu releases.). When ubuntu boots up the default runlevel is determined by a small script in /etc/event.d/rc-default.
Next, upstart loads any system scripts from a special system runlevel directory at /etc/rcS.d. These scripts load daemons and services that are vital to the boot process. Lastly, upstart runs any startup scripts for the default runlevel in alphabetical order. Scripts in /etc/rcS.d are run in runlevels 1 through 5, so you should generally leave them alone unless you know what you are doing. If you accidentally disable a crucial service, you may have to resort to a rescue disc to undo the mistake.

Change the Runlevel

You can change the runlevel yourself on the command line with the init command. To switch to single-user mode from the command line, type:
$ sudo init 1

If you're running X11 when you issue this command, beware, since it will kill X and your desktop environment! This command runs all of the shutdown scripts for your current runlevel and then any start up scripts for single-user mode. To change back to the default multi-user runlevel for Ubuntu, type:

$ sudo init 2

You can also use init to halt or reboot a machine: just change to runlevel 0 and runlevel 6, respectively.

Manually Start and Stop Services

You can start and stop scripts manually by running the script with the start or stop argument. For example, to stop the CUPS service from the command line, type:

$ sudo /etc/init.d/cupsys stop

To start the service back up, type:
$ sudo /etc/init.d/cupsys start

Most scripts also support a restart argument that will run stop, then start for you. Most init scripts are also configured to output the list of arguments they support when you execute them without any options:
~$ sudo /etc/init.d/cups
Password:
Usage: /etc/init.d/cups {start|stop|restart|force-reload|status}

Disable Scripts from Starting

To disable a script, you must know your default runlevel. On Ubuntu, the default runlevel is usually set to 2, but you may want to double-check your default runlevel before you start disabling services.

You can find out your current runlevel with

~$ runlevel
N 2

As you can see, in this example, the default runlevel is in fact 2. Now change to the directory containing all of the scripts for that runlevel (/etc/rc2.d) and find the script you want to disable. To disable a service, just rename its script by changing the S to a D. For example, to disable the cupsys service, type:

~$ cd /etc/rc2.d
/etc/rc2.d$ sudo mv S50cups D50cups

To enable it again, rename it back by changing the D to an S:
~$ cd /etc/rc2.d
/etc/rc2.d$ sudo mv D50cupsys S50cups

You'll still need to stop the service as shown earlier if you want to shut it down right away, but renaming it will control whether it's started the next time you reboot (or change runlevels).

Alternately, you can use the update-rc.d command to manipulate the starting /stopping of init scripts.

Monday, August 24, 2009

How to Control Startup Services on ubuntu

As Ubuntu boots up , if you press Cntrl+alt+F8, you might notice text scrolling by, detailing all of the different things Ubuntu is doing. See the screen shot below.



Apart from loading the kernel and starting the system, a number of services such as cron , gdm, cups etc are started at this time. If you have installed additional services on your system, such as a web server, they will also be started at boot. Sometimes, you may want to either stop or temporarily disable these services, and Ubuntu provides a number of ways to do this, both graphically and through the command line.
Services Administration Tool
The graphical tool to start/stop services is localted at
System->Administration->Services

You can also start it by typing the following command from a terminal.

$ sudo services-admin



Press unlock and enter your password. The screen will change to the one given below.



To disable a service, just deselect its checkbox and click Close. In Jaunty, this application supports changing only whether a service starts at boot. If you want to manually start, stop, or restart a service at a given point of time during your system usage, you need to refer to the command-line method.




Sunday, August 23, 2009

GeexBox : a 20MB wonder

Today , I was playing with geexbox , a 20MB distro specifically built for converting your PC into a powerful multimedia centre. GeeXBoX is based on Debian, it works very well on any x86 PC. Addional images are available for 64 bit architectures and PowerPC. It recognizes a large number of hardware and supports almost any audio / video or images, as well as we can playback CDs, DVDs etc.

Here are some screen shots .


The start-up screen


There are scripts to remaster the image with your own video/audio embeded with in the cd. I am yet to try them out.

Saturday, August 22, 2009

Reset a forgotten root password with a live CD

If you have forgotten the root password of a system, you can very easily reset it with a live CD
Any live Linux cd from standard Linux distros such a ubuntu , knoppix etc can be used.

Boot the system with the live CD
Open a terminal and use dmesg command to find out the hard disk.
The ide hard disk are generally named as hda, hdb etc. SATA and SCSI disks are named sda sdb etc. My SATA hard disk is detected as below.

[ 3.206832] sda: sda1 sda2 sda3 sda4 <>
[ 3.266679] sd 0:0:0:0: [sda] Attached SCSI disk

The above hard disk has several partitions. sda2 , sda2 ,sda3 are primary partitions , sda4 is divided into several logical partitions. You have to find out where your root partitions is mounted.
You can use cfdisk to find out the partitions.
$sudo cfdisk /dev/sda

I am getting the following screen .





You can examine the screen and find out the Linux partitions . If you have multiple installations , this can be tricky. You can quit from cfdisk and return to terminal. Now, try to mount the desired partition into some directory. ( Assuming that you Linux partition is /dev/sda2 , the following commands are described.)

Aquire root powers on the terminal with ( in the case of ubuntu live cd which I use)

$sudo su
 # mount /dev/sda2  /mnt/  
Now, chroot to /mnt
  #  chroot /mnt
Change the password

# passwd

Next unmount the partition and enjoy .

# umount /mnt

Friday, August 21, 2009

Cracking zip passwords with fcrackzip

Fcrackzip is a small utility that can become a handy tool when you want to look for lost zip password.
Fcracksip i a available in the ubuntu repository and you can install it as
$ sudo apt-get install fcrackzip

To see the available options with fcrackzip , try the following.

$ fcrackzip --help

You can look for a password like this.

$ fcrackzip -c a -p aaaaaa sample.zip

The above cimmand will check the encrypted files in sample.zip for all lowercase 6 character passwords (aaaaaa ... abaaba ... ghfgrg ... zzzzzz).

fcrackzip supports brute force mode as well as dictionary mode. The man page has some more interesting options you can try.

Wednesday, August 19, 2009

Replacing the default screen shot utility on ubuntu with shutter

Shutter, according to its website is a feature full screen shot program. As a tech blogger experimenting with GNU/Linux and its derivatives, it offers me a number of handy features. In fact, I have replaced it as my default screen shot tool. When I press Print Screen on my keyboard,shutter pops up and does a nice job.

Installation.

The shutter website hosts a step by step installation tutorial for graphical installation on Ubuntu. If you are oriented towards command line, follow these steps

1) Import the GPG key
$ sudo wget -q http://shutter-project.org/shutter-ppa.key -O- | sudo apt-key add -
2) Add the PPA repository--- to /etc/apt/sources.list
deb http://ppa.launchpad.net/shutter/ppa/ubuntu jaunty main

( Replace jaunty with your version of ubuntu)

3) Install shutter
$ sudo apt-get update
$ sudo apt-get install shutter

Features

Shutter offers lot of features for a blogger. Some of them are,
  • take a screen shot of your complete desktop, a rectangular area or capture a website
  • take screen shot directly or with a specified delay time
  • save the screen shots to a specified directory and name them in a convenient way (using special wild-cards)
  • Shutter is fully integrated into the Gnome Desktop (TrayIcon etc.)
  • generate thumbnails directly when you are taking a screenshot and set a size level in %
  • Shutter session collection
    • keep track of all screenshots during session
    • copy screeners to clipboard
    • print screenshots
    • delete screenshots
    • rename your file
  • upload your files directly to Image-Hosters (e.g. http://ubuntu-pics.de), retrieve all the needed links and share them with others
  • edit your screenshots directly using the embedded drawing tool

Making shutter the default screen shot tool on Ubuntu.
Assuming that you are using Genome desktop on ubuntu, you can set Print Screen and Alt-Print Screen can be
configured to launch shutter as below.
a) Open shutter
b) Select Edit->preferences from the menu
c) Click on behavior tab . See the screen shot below.




d) Enable Gnome Key binding by ticking the check boxes.

Monday, August 17, 2009

Using multiple window managers with nested Xserver

I use gnome as my default desktop at home and at office. However, my machines have alternate desktop environment such as kde or xfce installed. I use it to test out features of these environment. The normal way to switch to a different desktop is to log out from the current desktop , select a new session from the gdm login window and login again. However, it is possible to open a new desktop environment in a virtual console using xnest nested xserver.

Installation

$ sudo apt-get install xnest

Using Xnest to run another window manager.

Method 1
Xnest server can be started from a terminal as below


Xnest :1 -ac &


See the screen shot below. The :1 above indicates virtual X display numbered 1. You can also try other numbers.



Now on the terminal , Type the following command.
export DISPLAY=:1

The above line exports the variable DISPLAY to :1. Now you can open a terminal in the Xnest window by typing xterm & in the terminal. See the screen shot below.



Now try to start up a window manager such as icewm by typing icewm inside the xterm.


I could start icewm and fluxbox and kde like this. However, trying to start gnome-session resulted in some error. I am yet to find out the reason .


Method 2
This method uses gdmflexiserver . gdmflexiserver is a part of gdm and it is used to run gdm session on demand on a virtual terminal.

You can start it to give a gdm login prompt as below.

$ gdmflexiserver -n


You will get a new virtual X with a gdm login screen. See the picture below.




You can log in as a different user using a different session from the above screen. ( All the screen shots were taken on ubuntu 8.10)

Friday, August 14, 2009

Importing a remote desktop session via ssh tunnel

At home I have, 2 machines, one running Ubuntu 9.04 (Jaunty) and the other running Ubuntu 8.04 (Hardy). The Hardy machine is used by my family members and I use Jaunty for my experiments. Some times, I would like to test some thing on Hardy also. But most of the times that machine is not free. I use ssh to login to the hardy box and use an ssh tunnel to export the GUI session back to my Jaunty box.

The steps I took are detailed below.

On Hardy box

1) Install open ssh server

$sudo apt-get install openssh-server

On Jaunty Box

2) I switch to a text terminal by pressing Control+ALT+ F2. (any thing from F1 to F6 will work)

3) Login to the text terminal

4) Start a new session on Virtual Terminal 8 and launch xterm on it.

$ xinit /usr/bin/xterm -- :1

( :1 above represents the virtual graphical display , you can also use :2 )

5) A gray screen with xterm will appear on virtual terminal 8. If it is not appearing you can switch to it by

$ chvt 8

Or by pressing Control+Alt+f8

6) Now ssh to the Hardy box with tunneling.

$ ssh -Y fermi@192.168.0.2

Give your credentials and login (The IP address above is that of my Hardy box, you can replace it with your user name and IP). You are now logged to Hardy. The GUI of any program launched on Hardy ( in this terminal) will be tunneled back to Jaunty via ssh.

7) Start a gnome session on Hardy by typing the following command in the xterm terminal.

$ gnome-session

You can start other desktop sessions like kde or xfce , if they are installed.

Thursday, August 13, 2009

Tweaking dhcp client configuration to change the default DNS servers to Open DNS

The DNS servers of my ISP is always behaving erratically. The DNS look up times are abysmally large and some times I get an address not found error while browsing. On ubuntu/debian systems the DNS servers are specified in /etc/resolv.conf. I tried to edit /etc/resolv.conf and put open dns servers as default DNS servers. But, my ISP supplies their DNS server address along with IP address for the system via DHCP. Every time my system renews its DHCP lease. my /etc/resolv.conf is also rewritten with their DNS address.

My /etc/resolv.conf ( supplied by ISP) looks like this.

$ cat /etc/resolv.conf
domain asianetindia.com
search asianetindia.com
nameserver 202.88.238.3
nameserver 202.88.238.5
nameserver 202.88.231.2

There is a trick I used to make Open DNS servers as my default DNS server.

Edit /etc/dhcp3/dhclient.conf and look for the line.
#prepend domain-name-servers 127.0.0.1;
Add the following line immediately below the above line.

prepend domain-name-servers 208.67.222.222;
prepend domain-name-servers 208.67.220.220;


You can also put any other DNS servers.

Now renew the lease with

$ sudo dhclient eth0

The new /etc/resolve.conf looks like this.
$ cat /etc/resolv.conf
domain asianetindia.com
search asianetindia.com
nameserver 208.67.220.220
nameserver 208.67.222.222
nameserver 202.88.238.3
nameserver 202.88.238.5
nameserver 202.88.231.2

DNS look up is made from open dns.

Tuesday, August 11, 2009

How to install LTSP on ubuntu 9.04

LTSP was available as an install option in Ubuntu 8.04 and 8.10 from the alternate install CD . However I am unable to find it on the Jaunty CD. So, here is a quick how to on installing LTSP on ubuntu 9.04.

1) Install Ubuntu 9.04 desktop
You can follow the default documentation on Ubuntu site.

2) Set up a static IP on the system
You can refer to this post for setting up static IP on Jaunty.

3) Install dhcp3 server

$ sudo apt-get install dhcp3-server

You may also refer to this post for some more details on dhcp3 installation on Ubuntu 9.04.

4) Install open ssh server

$ sudo apt-get install open-sshserver

Ltsp uses ssh to tunnel X to the client machines.

5) Install ltsp

$ sudo apt-get install ltsp-server-standalone

This will download all the package needed for building LTSP.

6) Edit /etc/ltsp/dhcpd.conf to suit your IP requirement

The default dhcp3-server configuration file is in /etc/dhcp3/dhcpd.conf. However when ltsp was installed it created a new config file for dhcp3 under /etc/ltsp/dhcp3.conf. You have to edit this dhcp3.conf to suit your IP requirements.

My dhcpd.conf looks like this. You can use this as a starting point.

Code:
 # Default LTSP dhcpd.conf config file.

#



authoritative;



subnet 192.168.0.0 netmask 255.255.255.0 {

range 192.168.0.20 192.168.0.250;

option domain-name "example.com";

option domain-name-servers 192.168.0.1;

option broadcast-address 192.168.0.255;

option routers 192.168.0.1;

# next-server 192.168.0.1;

# get-lease-hostnames true;

option subnet-mask 255.255.255.0;

option root-path "/opt/ltsp/i386";

if substring( option vendor-class-identifier, 0, 9 ) = "PXEClient" {

filename "/ltsp/i386/pxelinux.0";

} else {

filename "/ltsp/i386/nbi.img";

}

}


7) Run LTSP build client

$ sudo ltsp-build-client

This command will build the ltsp environment under /opt/ltsp and build the squashfs image for clients.

8) Enable pxe boot on a client machine and test the set-up.

Trouble shooting

1) If your client boots up and says "You are not authorised to connect to server" , run the following.
$sudo ltsp-update-sshkeys
$sudo ltsp-update-image

2) If you change the IP address of the server, run the same commands again, ie

$sudo ltsp-update-sshkeys
$sudo ltsp-update-image

Monday, August 10, 2009

Five gui hex editors for ubuntu

This evening, I was looking at some microcontroller files and I needed a hex editor to tweak the machine code. That led me to search for a good hex editor for my ubuntu desktop. I downloaded several programs (GUI as well as console) and poked around a bit with each. Here are five gui hex editors you can use on ubuntu 9.04.

1) Ghex

Home http://live.gnome.org/Ghex
Ghex is hex editor for GNOME. GHex allows the user to load data from any file, view and edit it in either hex or ascii.
On ubuntu 9.04 , ghex is available in universe repository.

$ sudo apt-get install ghex




2) Khexedit

I could not locate the current home page of khexedit on internet. It is good editor based on kde 3.5. Unfortunaltley , khexedit is missing in the Jaunty repository. I downloaded khexedit form the hardy repository, and nstalled the package with

$ sudo dpkg -i khexedit_3.5.9-0ubuntu3_i386.deb

The screen shot looks like below.




3) Okteta

Home http://utils.kde.org/projects/okteta/
Okteta is a KDE utility. It is included in the new KDE 4.3 also. The data is displayed in two variants: as the numeric values of the bytes and as the characters assigned to the values. Values and characters can be shown either in two columns (the traditional display in hex editors) or in rows with the value on top of the character. Editing can be done both for the values and for the characters. Besides the usual editing capabilities Okteta also brings a small set of tools, like a table listing decodings into common simple data types, a table listing all possible bytes with its' character and value equivalents, a info view with a statistic, a checksum calculator and a filter tool. All modifications to the data loaded can be endlessly undone or redone.

On ubuntu 9.04 you can install okteta with

$ sudo apt-get install okteta

Octeta looks like this screen shot.





4 ) Wxhexeditor

Home http://wxhexeditor.sourceforge.net/

wxHexEditor is another Hex Editor useful for editing large files. Debian/Ubuntu package is not available now. However, you can download it in source or get a binary from here. It is still in alpha but looks very promising.





5 lfhex

Home http://stoopidsimple.com/

lfhex is an application for viewing and editing files in hex, octal, binary, or ascii text. The main strength of lfhex is it's ability to work with files much larger than system memory.
The interface is not very impressive. It can be installed with

$ sudo apt-get install lfhex

See the screen shot below.



Among the five editors mentioned above, ghex is my favorite as it is stable and userfriendly.


Sunday, August 9, 2009

Howto setup Second IP address or Virtual IP address to your Networkcard in ubuntu

If you are a Network Administrator some time you need to assign more than ONE ip address (second ipaddress) to your network card of Ubuntu machine. For this you need to edit the /etc/network/interfaces file by adding the following lines .

See this how to from Shibu Varkala for details.

Exploring Ubuntu Recovery Mode

Today, I did a fresh installation of Ubuntu 9.04 inside virtual box. My original idea was to play with sudoers and sudo command. I edited /etc/sudoers and logged out. Next time I tried to sudo , I go some parse error in /etc/sudoers. I was stuck . I needed sudo for modifying the file. But sudo was preventing me because of the error.

Then, I remembered about the recovery mode. Rebooted the machine and I pressed escape to get the standard grub screen as shown below.


Selecting recovery mode showed the following screens. ( The second figure below shows the remaining part of the recovery screen which is hidden from the first screen.)




I selected drop to a root shell. It allowed me to enter root account with out a password. I fixed my /etc/sudoers and my problem was gone.

Later I rebooted again and re-entered the recovery mode again to find out what capabilities it offers.

The recovery screen offers you the following menu entries on ubuntu 9.04 .

a) Try to make free space - this is useful if your machine is stuck for the want of free disk space.
b) Dpkg - If you select this option you can repair broken packages. Very useful ,if the system is stuck after a package installation.
c) fsck - if the system is stuck with file system error you can try this option.
d) grub - You can update the grub boot loader from this option.
e) netroot - Your TCP/IP network settings will be enabled and system will drop to a root shell.
This option is useful if you are trouble shooting network related issues.
f) root- Plain old root shell . Suitable for editing config files.
g) xfix - This option will try to reconfigure your X window system

Friday, August 7, 2009

Setting up automatic login in ubuntu

I was installing Ubuntu at a friends computer today. He wanted to use the computer with out the login/password prompt as it was a home PC . I did the following steps to achieve this.
Click on System ->Administration-Login Window.

You will get a screen like this.



Click on security and check the enable automatic login check box.


Select the user name a automatic log in.

The login preferences window offers several other options. For example, you can setup timed logins. This will allow you to login using user name and password with in a specified time.If you don't do this the user name specified will be automatically logged.

Also, if you are enabling the system administrator account "root" , you can allow him to login to the GUI by ticking the appropriate option.

Monday, August 3, 2009

Download and convert Youtube videos with Elltube

Youtube is one of the most popular video sharing sites on Internet. There are several applications that let you download and store on your hard disk. Elltube is one such application which works both on Linux and windows.

You can download Eltube from here. I installed the deb package for ubuntu on intrrepid with

$ sudo dpkg -i elltube_0.3-1_all.deb

It showed up under Application->internet

The screen shot of eltube is as below.



Now you can download any youtube video by pasting the url of the video to the Elltube window. Locate the video you want to download and copy its URL. On my ubuntu desktop, when I copied the URL, it automatically appeared in ELtube.



You can set the desired location to download the file and specify the out put format. Click on download and enjoy the video.

Enhancing contextual menus on Ubuntu Desktop

Ubuntu desktop uses Gnome and its default desktop. You can add several interesting features to your contextual menus. ( You get a contextual menu when you right click on an object.). Let us see how we can add a simple script to the contextual menu.
There is a special directory ( .gnome2/nautilus-scripts/ ) inside your home folder into which you can put your custom scripts. Any script you place in that location can be accessed by right-clicking on a file or window and selecting it from the Scripts sub menu. (The Scripts menu item will be visible only if you have some valid scripts installed.

Let us try to open a terminal from the contextual menu. Change to the scripts directory. ( Note that .gnome is a hidden directory, try control -h in nautilus to see hidden files. )

$ cd ~/.gnome2/nautilus-scripts/

Create the following script

Code:
 #!/bin/sh
gnome-terminal
Save the file as myterminal
Change the permission of the file and make it executable

$ chmod u+x myterminal

Now right click on the contextual menu. You should get it as below.





When you execute a contextual menu script , a number of environment variables are passed to the script from nautilus. For example, if you select some files and then right click and select a script , the list of selected files will be passed to the script as an environment variable . You can use this variable inside the script for further processing.

Some of the variables passed are.

NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
Newline-delimited paths for selected files if they are local
NAUTILUS_SCRIPT_SELECTED_URIS
Newline-delimited URIs for selected files
NAUTILUS_SCRIPT_CURRENT_URI
URI for current location
NAUTILUS_SCRIPT_WINDOW_GEOMETRY
Position and size of the current window

Here is a bare minimum example with which you can try out the use of environment variable.

Suppose you want to open a terminal and change to a particular directory, you can put the following code in nautilus-scripts directory. ( There is no error checking).

Code:
 #!/bin/sh

mydir=$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
if [ -d $mydir ]; then
cd $mydir
gnome-terminal
exit
fi

Now right click and select the script. Your terminal will open with the selected directory as the working directory.

There are a number of nautilus scripts available on the internet. In the ubuntu 9.04 repository, the following script collections are available.
nautilus-script-audio-convert - A nautilus audio converter script
nautilus-script-collection-svn - Nautilus subversion management scripts

You can also get lot of useful scripts from http://g-scripts.sourceforge.net/.

Adding Document templates to Nautilus right click menu

Ubuntu distribution uses nautilus as the default file manager. You can tweak nautilus to increase your productivity. Here is one hack which I discovered recently. When you right click on the desktop or inside your file manager you get a menu as shown in the screen shot below.


It allows you to create an empty document in your current location. The file created will be a text file. It is possible to create other kinds of file by a simple hack. Suppose you want to add an invoice template to the menu. Create an invoice template file in your favourite application ,say in open office spread sheet. Let us call the file as invoice.odt.

Copy invoice.odt to ~/Templates directory . ( Templates directory will be automatically created under your home folder in Ubuntu)
$ cp invoice.odt ~/Templates

Now see the right click menu. It will look like the screen below.




You can add as many templates as you like . Also, it is possible to group together templates by creating folders under ~/Templates directory. See the figure below. I have some groupings inside my template directory.


Sunday, August 2, 2009

Yakuake : A pull down terminal for your desktop

If you are addicted to doing things on terminal, yakuake is your friend. Yakuake is a KDE application and it takes the standard KDE Konsole and changes it to a drop-down, on-demand terminal over your desktop and applications. This is a very handy little application. ( It resembles the classic game quake in showing the console screen on your desktop.)

To install, simply use

$ sudo apt-get to install both konsole and yakuake

If yuo are on Ubuntu open up a terminal and run yakuake from the terminal.
It will prompt you with the following screen .



Yakuake is prompting you to set a short cut key .The default is F12 . However on my Ubuntu desktop F12 is bound to search. So I clicked on the button and changed the default key to F10.
Press ok and save the configuration.
Now if you press your short cut key , yakuake terminal will pop up. If you press it again , it will hide itself. The appearance and behaviour of yakuake can be controlled. from its menus. You can access the menu by clicking on the down arrow symbol on the bottom right corner of yakuake window. Yakuake recognises almost all settings of konsole the KDE terminal.

Saturday, August 1, 2009

Making PDF documents in Ubuntu 9.04 with CUPS-PDF

Yesterday , I wanted to send some web pages to a friend . I decided that I will make a PDF document and send the pdf. I looked around on internet for information about a pdf printer. Several sources pointed to cups-pdf.
I installed cups-pdf with,
$ sudo apt-get install cups-pdf
Under System->Administration ->printing a new entry came along with my HP 1007. See the screen shot below.


I tried to print my webpage. I got the following screen from firefox.


It seems cups-pdf is failing. I tried to print, but nothing turned out. I then looked at /etc/cups/cups-pdf.conf
Under path setting it is saying


### Key: Out
## CUPS-PDF output directory
## special qualifiers:
## ${HOME} will be expanded to the user's home directory
## ${USER} will be expanded to the user name
## in case it is an NFS export make sure it is exported without
## root_squash!
### Default: /var/spool/cups-pdf/${USER}

Out ${HOME}/PDF


So, the pdfs are supposed to appear under PDF directory in my home folder.
I looked for PDF directory. It was not there. I created it manually and tried printing again.
The ubuntu 9.04 notifier said " Print job completed". I looked at PDF folder and the printout was there. :)

So, if you are trying to make PDF documents with cups-pdf don't forget to create an output directory (named PDF ) in your home folder.

See the screen shot below. It shows the screen when printing to a working pdf printer.

Some keyboard shortcuts for your Ubuntu ( Gnome) Desktop




Ubuntu uses Gnome as its default desktop environment. Here are some keyboard short cuts that can make your life easy.

Alt + F1

Opens the Applications Menu .

Alt + F2

Displays the Run Application dialog.

Print Screen

Takes a screenshot.

Alt + Print Screen

Takes a screenshot of the window that has focus.

Ctrl + Alt + right arrow

Switches to the workspace to the right of the current workspace.

Ctrl + Alt + left arrow

Switches to the workspace to the left of the current workspace.

Ctrl + Alt + d

Minimizes all windows, and gives focus to the desktop.

F1

Starts the on line help browser, and displays appropriate online Help.


Alt + Tab

Switches between windows. When you use these short cut keys, a list of windows that you can select is displayed. Release the keys to select a window.

Alt + Esc

Switches between windows in reverse order. Release the keys to select a window.

F10

Opens the first menu on the left side of the menu bar.

Alt + spacebar

Opens the Window Menu .




Also try ALT F10 and Cntl+F10 on the desktop.