jump to navigation

Create DVDs with All of Ubuntu’s Packages December 11, 2006

Posted by Carthik in guides, packages.
11 comments

For those looking to install Ubuntu without a high speed internet connection, a set of DVDs with the entire contents of the repositories would be a great tool. The idea being that armed with the DVDs, you really don’t need a net connection for retrieving any packages, since between the DVDs you have every package that is present in the software repositories.

Though there is no “official” set of DVDs, one can find such DVD sets for sale at some shops online. The catch is, of course, that the DVD sets are expensive. Why pay for something that is free? Ubuntu is 100% free, and we like it that way.

I just ran across some detailed instructions to create a set of Ubuntu DVDs. In fact, it is one better than a set of detailed instructions – it is script that you can use to create such DVDs. A few months ago I had started on writing a bunch of commands in python that would do the job – but never got done. The “How-To Make Ubuntu DVDs Including Main, the Universe and Everything” article seems to use some Ruby scripts. I know little about Ruby, but as long as the task is completed, the programming language matters little.

The script promises to generate 4 DVD images (.iso files), and might require as much as 30 GB of hard disk space. I usually try out the tips I post here first – but this time, since I don’t have 30 GB of hard disk space to spare, I have not been able to try this technique. I have a tight budget – with a laptop, I really can’t have all the HDD space I want πŸ™‚ So it would be great if some of you could try this one out, and let me know how it goes.

SSH Tunnel + SOCKS Proxy Forwarding = Secure Browsing December 8, 2006

Posted by Carthik in applications, commands, guides, servers, ubuntu.
218 comments

When you are at the coffee shop, or at a conference, and you are not sure that you want to send all your data over the wi-fi network in plaintext, you want a secure tunnel to browse. This happened to me recently and I stumbled across a neat feature of openssh (the ssh client on everyone’s computer). The wonders of ssh never cease to amaze me!

You can use the “-D” flag of openssh to create a SOCKS proxy.

The command first:
$ssh -D 9999 username@ip-address-of-ssh-server

This of course connects you to the server specified by “ip-address-of-ssh-server”. Needless to say, you (username) must have an ssh account on the server. In addition, this will create a SOCKS proxy on port “9999” of your computer. This is a tunnel to the server. Now all you have to do is set the preference in Firefox to use a SOCKS proxy. The proxy is, of course, “localhost”, with the port 9999.

Now when you browse, all the connections you make to websites will seem to originate from the server to which you SSH-ed. In addition, all outgoing and incoming data for the browsing session will be encrypted since it passes through the SSH connection.

Other applications (like email clients) may also support SOCKS proxies. If any of them, you can look into using proxychains(there’s an Ubuntu package).

You can misuse this technology to circumvent paranoid browsing firewalls, even to pretend you are wherever your ssh server is located – so you can work around country-based blocks etc. I use it for the very unromantic reason that I don’t want some aspiring cracker to sneak up on me when I am in public.

Updates:

Searching Ubuntu Mailing List Archives December 6, 2006

Posted by Carthik in guides, ubuntu, Ubuntu Sites.
7 comments

Almost all of the tips I post here are either things I stumble upon myself or things that I read at the Ubuntu-users mailing list. Seeing as how useful this mailing list is, I thought there should be a fast, efficient way to search it. Mailman, the software that the list runs on does not provide a good search functionality. Don’t give up hope yet, though.

You can use Gmane’s search functionality at http://news.gmane.org/gmane.linux.ubuntu.user. Similar searchable archives can be found at gmane for the other Ubuntu lists.

But wait, it gets even better. Nabble provides interfaces to:

  1. Search ALL Ubuntu related mailing lists
  2. Specific Ubuntu mailing lists – eg. Ubuntu-users

To compare performance let us search for “searching mailing list archives” using both these websites. Here’s the Gmane result, and the Nabble result. To Nabble’s credit, it finds more results. You are free to look at the results and decide which one is better.

I rather prefer Nabble since it is neat and clean, and since threads are returned in results, sometimes reducing the total number of results. This is a case where less is more, since, most of the time, I can eliminate a few threads just by looking at the subject of the thread. Nabble also provides a short excerpt from each result showing me what matched. The ability to search across all the Ubuntu lists is a definite plus, too. I hope Nabble stays along for a long time. Much as I like Gmane, I think I am falling in love with Nabble’s search.

Share Music in a Network using Avahi (DAAP) September 22, 2006

Posted by Carthik in applications, guides, music, packages, ubuntu.
40 comments

Okay, so I have a desktop with around 50 Gigs of music. I also have a laptop on which I work most of the time, from various places in and around the house. I did not want to (and don’t have the space to) copy the songs onto the Laptop. So I went looking for a simple way to share my music over the Network.

I found that rhythmbox supports DAAP, the same technology that Apple uses with iTunes to enable sharing.

To enable sharing, install the avahi daemon on the desktop using:
$sudo apt-get install avahi-daemon

Now, in Rhythmbox, go to Edit->Preferences->Sharing(which is a tab) and select “Share my music”.

Avahi is the name of the project that brings DAAP (aka rendezvous or zeroconf) to Linux.

You’re all set! Now when you use Rhtyhmbox on the laptop, or any other system in your network, the music collection on the desktop should appear when you start it up in the “Source” pane on the left! Og’s post was one of the many pages I hit when I was searching for a solution. He even has a screenshot showing how the shared directory shows up.

If you want to share music using Banshee, install the banshee-daap package which provides a plugin for DAAP music sharing.

The only caveat is, even when you use this, Rhythmbox has to be running on your desktop for the files to show up elsewhere. If that bothers you, then see how Tangerine can help you. From the website, we get the following description:

Tangerine is an application that allows you to publish music over the local network, using DAAP. It runs on both Linux and Windows. There are several clients that you can then use to connect to it, such as Apple’s iTunes, Banshee, and Rhythmbox.

Music files can be specified either by a directory, or can be automatically discovered using Beagle or Google Desktop. Recently you can also specify which music player you use and share the songs in it’s collection. For typical configurations, a graphical tool is included (see below).

As far as I know, the stable version of Amarok, my favorite music manager, does not have any support for DAAP, either as a server(for the desktop) or as a client(for other computers to access shared stuff).

Disable Touchpad Temporarily When Typing September 20, 2006

Posted by Carthik in commands, guides, looks and feel, ubuntu.
64 comments

Earlier, I wrote about how to enable/disable your touchpad using the synclient command.

Recently, I faced a different problem. When typing on the new laptop that I got, my thumb often accidentally brushes the touchpad, and this leads to me continuing to type things in entirely a different place. This is because the thumb moves the mouse pointer to a different spot that where the typing cursor is, and then there is an accidental click. Argh! very annoying.

The good news is, I figured out how to fix this using syndaemon!

syndaemon watches activity on the keyboard and can disable your synaptics touchpad for a variable period after it detects activity on the keyboard. Here’s how I use it:

First, I edited the /etc/X11/xorg.conf file and added the Option “SHMConfig” “on” line to the section called “Input Device” for the Synaptic Touchpad input device.

Then I restarted X (by using the ctrl+alt+backspace key combination).
Once I was logged in, I used syndaemon as $syndaemon -t -d

The -t option specifies that only the tapping and scrolling actions are to be disabled, I can still move the cursor around while typing on the keyboard.
The -d option asks syndaemon to run in the background as a daemon, so I don’t have to keep the terminal open after executing the command.

You can disable the touchpad entirely by not using the -t option.

By default, syndaemon disables the touchpad for 2 seconds after the last keyboard activity. You can change this by specifying the idle-time using the -i option. Read the manual for all details: $man syndaemon.

To make syndaemon start up by default each time you login, add it to the list of Startup Programs in System->Preferences->Sessions. I have the following command added there now: syndaemon -t -d. Log out and log back in to see if its working for you.

Send Email from Nautilus using Thunderbird September 15, 2006

Posted by Carthik in applications, guides, ubuntu.
16 comments

Right clicking on a file on your desktop, or from anywhere in nautilus gives you a “Send To…” option. This enables you to send the file via email using Evolution.

If you use Thunderbird as your mail app, then you certainly want the file to be sent using Thunderbird, but making this change is not so easy. Changing the default email reader in System -> Preferences -> Preferred Applications to Thunderbird should fix this, but since we don’t yet live in an ideal world, it doesn’t.

It looks like nautilus’ preference for Evolution as the mail client to use for the right-click-send-to comes hard-coded in the nautilus send-to plugin, and this plugin is installed on your Ubuntu computer. This nautilus send-to bug has already been noted.

To choose Thunderbird as the app to be used for “Send to…” you will need to use the instructions at Thunderbird support for nautilus send-to.

As a bonus, here’s the page listing all of Thunderbird’s command line options – for when you want to send a file from a command prompt.

(Though I had to solve the above problem with Thunderbird recently for a friend, I am a recent sylpheed-claws-gtk convert. It is absolutely the fastest and best email client I have come across till date.)

Normalize the Gain (Playback Volume) of your MP3s September 11, 2006

Posted by Carthik in applications, commands, guides, packages, ubuntu.
50 comments

I confess to the grave sin of storing part of my music collection in the mp3 format – mostly music I have had around for ages. There, now that that is out of the way, let’s move on to making that collection friendlier.

I have the habit of going to sleep while listening to a little light music. Some of the songs in my collection would sound louder than the others. So when I have a couple of classical music tracks lined up with Paul McCartney and Guns ‘N Roses, I sometimes get jolted awake by the difference in the playback volume. So off I went looking for solutions.

My main concerns when I started my research were:

  1. My mp3s should not be irretrievably changed into something I end up hating
  2. I did not want all songs sounding as loud as the loudest song
  3. The algorithm or method used should be free of the application used for music playback

Then came the choices. In the end it all came down to two apps: Normalize and mp3gain. Now how do I decide which one’s the one for me without learning DSP? Simple, search some more.

Fortunately, besides the websites for the applications, I ran into this thread at jwz’s livejournal. Thank god for geeks-who-start-nightclubs and their friends! I also followed most of the replaygain technical outline, since mp3gain is an implementation of the replaygain idea.

Normalize is simple, perhaps a little too simple.

mp3gain works by figuring out how loud the music actually sounds to the human ear, and then figuring out how much positive or negative gain to apply to the mp3 file to “fix” it. I was happy to note that it does not use the peak volume in a file as a benchmark for normalization. It applies changes by modifying the mp3 file in some fashion, but I read that the change is reversible since mp3gain writes some tags (not ID3 tags) to the mp3s for possible later undoing. This fact also means that one you use mp3gain on a file, if you try doing it again, it takes a lot less time – almost no time. So in the future if I add files to the collection, and I don’t remember what files I added, I can run mp3gain on the entire collection, and it will complete much faster than the first time.

To cut to the chase, I decided to go with mp3gain. I installed the mp3gain package (using $sudo apt-get install mp3gain), and set out to normalize my entire music collection. (For those of you who also have .oggs, check out vorbisgain).

Edit: for an alternative command, with explanation, and a way to use album-gain for songs from albums, visit porges
The following command, executed from the directory where I store my music normalized all the files in my collection:
$find . -type f -iname '*.mp3' -print0 | xargs -0 mp3gain -r -k

What it does is, it finds all files (type -f) in the present directory (.) with a name that ends in “.mp3” and creates a list of the same. The output of this find command is then piped to the mp3gain program. The options that I ended up using for mp3gain, -r and -k dictate that the calculated track gain will be applied automatically to normalize the volume, and that files should be protected against “clipping” by lowering the applied gain if the required gain seems likely to clip the sound. Concoct your own recipe by referring to the man page for mp3gain.

After around 16 hours of processing on my old PIII desktop, my massive 50 GB music collection now agrees on what is an acceptable volume. Needless to say, I sleep in peace.

Local DNS Cache for Faster Browsing August 2, 2006

Posted by Carthik in administration, guides, packages, ubuntu.
325 comments

A DNS server resolves domain names into IP addresses. So when you request “google.com” for example, the DNS server finds out the address for the domain, and sends your request the right way.

You can run a DNS cache on your computer. This will speed up the process of looking up domain names when browsing. The difference is about 30-60 ms for me. Multiply that difference by the number of websites you visit a day for an approximate estimate of the speed improvement. Of course, all this would be worth it if it weren’t for the fact that setting this up is way too easy.

The following instructions are for someone with a cable (broadband) internet connection, where the computer gets it’s local IP address using DHCP from the router in your house/office:

The package we will be using for caching nameserver lookups is called dnsmasq. So first, install it using:
$sudo apt-get install dnsmasq
(If you can’t find then, then you probably haven’t added the Universe repository to your list of repositories.)

No uncomment the following line (that is edit the line to NOT have a “#” in the beginning) in the file /etc/dnsmasq.conf:
listen-address=127.0.0.1

Now edit /etc/dhcp3/dhclient.conf and make sure the section below exactly like this, especially the line that says “prepend domain-name-servers 127.0.0.1;”

#supersede domain-name "fugue.com home.vix.com";
prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, host-name,
netbios-name-servers, netbios-scope;

Explanation for the above change: In the normal case, when you get a new dhcp lease, the dhcp3 client (tool) on your computer gets a new lease, and updates the /etc/resolv.conf file on your computer with the right values for the DNS servers to use (usually some machine in the network of your hosting provider). Adding the “prepend” option as we did above ensures that “127.0.0.1” will appear on the top of the list of DNS servers. That magic number refers to your own computer. So in the future, whenever your computer needs to resolve a domain name, it will forward that request to dnsmasq (which is running at 127.0.0.1 – your computer). If the details for the domain name are already in you cache, well and good, dnsmasq will serve it up and make the process real fast. If it is not in the cache, then dnsmasq will look at the /etc/resolv.conf file and use the nameservers listed below the “127.0.0.1”. I hope that explains things.

Now open the file /etc/resolv.conf in your text editor. It probably looks like:

search yourisp.com
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

The 127.0.0.1 is missing right now since you haven’t renewed your lease after you edited the /etc/dhcp3/dhclient.conf file. So, let us add that in manually this one time. After you do, your /etc/resolv.conf file will look like the following:

search yourisp.com
nameserver 127.0.0.1
nameserver 217.54.170.023
nameserver 217.54.170.024
nameserver 217.54.170.026

Don’t worry if the numbers are different – if they are not, then hey – we must be neighbours πŸ˜‰

Okay. We are almost done here. All we have to do now is to restart dnsmasq so that the changes we made to the configuration file take effect. You can do that using the command:
$sudo /etc/init.d/dnsmasq restart.

Now you are running a local DNS cache. If you want to measure your speed improvement, type the command:
$dig google.com
You will see something like “;; Query time: 38 msec” there.
Now type the command again, and you should see something like:”;; Query time: 2 msec”

See, the first time, since google.com’s details were not in your cache (you are using it for the first time), the query took 38 ms. The second time, the cache speeds up the lookup. I have been using this for over a month now, and haven’t had a problem.

The following is ONLY for dsl customers
Note: If you have a dsl connection, the following may work:
Basically, the differences are in how the “conf” files are edited and used.
Copy the /etc/resolv.conf file to /etc/resolv.dnsmasq.conf
Then, edit the /etc/dnsmasq.conf file as follows:

# Change this line if you want dns to get its upstream servers from
# somewhere other that /etc/resolv.conf
resolv-file=/etc/resolv.dnsmasq.conf

You also have to uncomment the line that says listen-address=127.0.0.1
Now, edit /etc/resolv.conf to have ONLY the following line in it:
nameserver 127.0.0.1
Next, edit /etc/ppp/peers/dsl-provider and change the line:
usepeerdns to
#usepeerdns
(that is, comment out that line)
The ppp client does not allow you to prepend the 127.0.0.1 entry to your /etc/resolv.conf file. So what we did in the above was to create a copy of your previous resolv.conf for dnsmasq to use for lookups, update the file to use a local cache, and then prevent the ppp client from overwriting the resolv.conf file the next time. Now you can restart the dnsmasq service as I explained above, and start enjoying faster name resolution.
I don’t have a dsl connection, and so all the above is to the best of my knowledge.

To those of you still on dial-up – THANK YOU for visiting my blog! (I’m too ignorant to know how to change things to get dnsmasq to work on dial-up πŸ™‚ )

Installing Packages on Computers with Slow Connections Redux July 8, 2006

Posted by Carthik in administration, commands, guides, maintenance, ubuntu.
15 comments

Earlier, I had written about using apt-zip to upgrade computers on slow internet connections by using a faster machine to do the downloads. However, since that involves understanding how apt-zip works, and a small learning curve, here is a hack that should work pretty well, in spite of it’s hackish nature.

The tip here will let you install new packages (and their dependencies) or upgrade a system by using a faster internet connection to do the downloading. First we get the URIs for the pacakges to be downloaded, then we download the packages and transport them to the computer with the slower connection. Thanks to Ewan for this tip posted to the ubuntu-users list a long time ago.
The steps:
1) On the computer you wish to install something new on (or upgrade), do a $sudo apt-get update

2) Then use apt-get to generate a list of the packages it needs to download, in order to install the package that you need, but not download them:
$sudo apt-get -qq --print-uris install name-of-package | cut -d\' -f 2 > urilist
this gives you a file ‘urilist’ in the same directory as the one in which you ran the previous command, with a list of files to download.

3) Take your list to a machine with a fast internet connection and download the packages using wget:
$wget -i < urilist

4) Take your newly downloaded debs home and copy them into the
/var/cache/apt/archives/ directory

5) Rerun the same apt-get command, but without any special parameters:
$ sudo apt-get install name-of-package

apt-get should tell you the quantity of packages that it will install,
and how much it will download. The download amount should be zero since
the packages are already downloaded.

How to Create a Screencast in Ubuntu June 8, 2006

Posted by Carthik in applications, guides, ubuntu.
124 comments

…In which we (finally!) figure out how to create screencasts in Ubuntu using a patched ffmpeg…

This is something I have wanted to do for a long time now. Screencasting can be very useful for explaining new concepts, demonstrating beta products, and heck, maybe even for filing better bug reports!

The screencasting method I present here is not something I came up with. I saw it first at Quim Gil’s blog. A commenter mentioned how there was an article at clemens.endorphin.org explaining the process, and even posted instructions on how to be able to do this. So, as usual, my job is to publicize what is already known to a few.

You will need to patch, compile, and use ffmpeg to generate the screencasts. Let me try and make it very easy to do:

Open a terminal, and create a new directory called “software” in your home directory. This is optional, you don’t have to do it, but I do this to keep things organized on my computer:
$mkdir software
$cd software

So now you are in the newly created “software” directory.

Get the source for ffmpeg:
$wget http://un.sh.nu/screencasts/ffmpeg-0.4.9-p20051216.tar.bz2

Extract it:
$tar xjfv ffmpeg-0.4.9-p20051216.tar.bz2

Change to the newly extracted directory:
$cd ffmpeg-0.4.9-p20051216

Download the patch:
$wget http://un.sh.nu/screencasts/ffmpeg-0.4.9-p20051216.diff

Apply the patch:
$patch -Np1 -i ffmpeg-0.4.9-p20051216.diff

Now before we start compiling the source, you will need a couple of packages installed on your computer. The “build-essential” package will give you the compiler and other tools needed to compile packages, and the “xlibs-dev” package will be required to compile ffmpeg successfully. Let’s install both of these:
$sudo apt-get install build-essential xlibs-dev

Let’s get started now, configure the beast:
$./configure --extra-ldflags=-L/usr/X11R6/lib --enable-x11grab --enable-gpl

…and then “make” it:
$make

That’s it! Now you have an executable called “ffmpeg” in the directory you are in (~/software/ffmpeg-0.4.9-p20051216/)

You can use this to create your screencasts.

I find the following command good for my purposes:
$./ffmpeg -vcodec mpeg4 -b 1000 -r 10 -g 300 -vd x11:0,0 -s 1024x768 ~/test.avi
..where:
-vd x11:0,0 says that the offset to use for recording is x=0 and y=0
and
-s 1024×768 says that the size of the video to be captured is 1024×768.
The video file “test.avi” will be created in your home folder.

You can change these and the other options (refer to the documentation for ffmpeg).

If you want to create a screencast of only one application window, or a specific portion of your desktop, you can do that by specifying the offsets (always calculated from the top-left of the desktop) and the size of the area to be captured.

I find the “xwininfo” command to be pretty useful to find these parameters.
$xwininfo -frame will give you the geometry of a window, including the window decorations (the title-bar, scrollbar etc).

You can resize the screencasts by using, (…surprise!…) ffmpeg. For example the following command will create a 800×600 video from the 1024×768 video:
./ffmpeg -vcodec mpeg4 -b 1000 -r 10 -g 300 -i ~/test.avi -s 800×600 ~/test-800-600.avi

I created a small screencast to show how all this works out. However, the video quality at youtube and google videos leaves much to be desired. The original is much, much better — you can actually read the text in the screencast.

YouTube-hosted Screencast – A demo of the method where I learn to use xwininfo:

The same video/screencast is also on Google videos, andI really can’t decide which is worse, google, or youtube! I have posted the original .avi file here (test-small.avi) – which shows the quality of the screencast before it was uploaded to youtube.

Creating a screencast, even with an easy-to-use tool, is hard. I had to do this one over and over till I was marginally happy with one. Unlike with writing an article, you can’t go back and change things — you have to start re-recording from scratch! Besides that, there are issues like accents. (Question – can you place me geographically just by my accent? – let’s see how close, and specific, you can get πŸ™‚ )

So I’ve done my teeny-weeny bit. Now someone please write us a small, stable GUI app that does the same thing. There’s no need for too many bells and whistles, a start/stop button, a method to select an area of the desktop to record, and a “save to…” field will do nicely.

So what do you folks think we can use this new tech for? I can’t think of too many screencasts to create, now that I have a method of creating them.