Kubuntu Hacks



Google

Welcome

This is a collection of hacks for Linux that are intended to make life on the command-line a little easier.  All will work on Kubuntu 6.06 Dapper Drake; in fact, this page has been especially written for new Kubuntu users who would like to learn more about Linux's CLI (Command Line Interface).  These hacks should also work on Ubuntu and Xubuntu.  The title of the page was inspired by Ubuntu Hacks, a book I highly recommend; however, it's important to note that this page is not a rehash of the book.  In fact, its authors and I disagree from time to time!


If you have any questions, can't make something work, or find a bug (!!!), email me:  proteus71 at gmail dot com.



Using the Command Line Interface

To access the CLI, you will need a console program.  There are a number of good console programs available for Linux.  One of the most powerful and flexible is Konsole.  To activate it, click on "K Menu" (the lower left part of your screen), then choose "System" and finally "Konsole". 


List Files on your Drive

Download showme and type the following:


sudo mv showme /usr/bin
sudo ln -s /usr/bin/showme /usr/bin/s


You can now type merely:

s

to see everything in your current working directory.  Now type:

s -h

You'll see something like:

showme v0.6
usage: showme OPTIONS
       (default) show contents of current dir
       -a        show all
       -d        disk information
       -h        help
       -q        quick list
       -s        summary
       -v        version


Try:

s -sd

and you'll not only have your directory contents but also it's total size and the size of every drive on your computer.


Modify the List of Package Repositories

Download sources.list.  This is the list of repositories I use.  It strikes a balance between the stable K/Ubuntu packages and the latest, greatest, bug-prone applications.  After you've downloaded it, type the following in Konsole:

nano sources.list

If you live outside of the US, change every instance of "us.archives" to "XX.archives", where XX is the two-letter country code of your own or a nearby country (de=Germany, it=Italy, fi=Finland, etc.)  After saving your results, do the following:

sudo chown root.root sources.list
sudo mv /etc/apt/sources.lst /etc/apt/sources.list-original
sudo mv sources.list /etc/apt/
sudo apt-get update
sudo apt-get upgrade

Now you will be able to download applications not included in Kubuntu's original installation.

Build packages from scratch

The best way to get the most out of any application is to build it from its source code.  apt-build is an easy way to do this in Kubuntu.  (WARNING:  do not recompile the kernel, gcc, libc, or any other system files unless you know what you're doing!)  To install, type:

sudo apt-get install apt-build

You will have a little configuring to do.  First, you'll see:
Apt-Build 1/3


Choose "Strong", as it will give you the best performance time.  Then you'll see:

Apt-Build 2/3


Choose "Yes".  The following line will be added automatically to the top of /etc/apt/sources.list:

deb file:/var/cache/apt-build/repository apt-build main

Finally, you'll see:
Apt-Build 3/3

Choose your processor's architecture.  If you're not sure what that is, consult your owner's guide.

Now you're ready to use apt-build!  Try:

sudo apt-build install lame

lame is a command-line application to convert WAV files to MP3's.  By using apt-build, you've compiled it from source, so it runs faster than if you had installed it with apt-get.

Watch DVD's and videos

I prefer VLC to Kaffeine because VLC has the capacity to play DVD's with any region-code.  VLC can play just about any video file as well.  To install VLC:

sudo apt-get install vlc mozilla-plugin-vlc vlc-plugin-alsa wxvlc w32codecs

If it's legal for you to circumvent the Content Scrambling System on the DVD's you own, continue with:

sudo apt-get install libdvdread3
sudo /usr/share/doc/libdvdread3/examples/install-css.sh

Now you can buy DVD's from anywhere in the world and play them on Kubuntu!
 


amaroK Fix

amaroK, as installed, does not play MP3 files. To fix this, type:

sudo apt-get install libxine-extracodecs


Rip DVD's to AVI files

Download dvd2avi.sh and do the following:

sudo mv dvd2avi.sh /usr/bin/

You will also need MPlayer and MEncoder:

sudo apt-get install mplayer mencoder

Once all three programs have been installed, type in the command-line:

dvd2avi.sh -h

You'll see something like:

dvd2avi.sh 0.6 (2006-08-04)

options:
-h     [Help]
-d     /full/path/to/alternate/dvd-device
-c     [Chapter option]
-f     [Output framerate]
-s     [Sleep option for hot processors]
-a     [Aspect]  Examples:
-a 1   [NTSC Std 4:3 100%]
-a 1p  [PAL  Std 4:3 100%]
-a 2   [NTSC Std 4:3 75%]
-a 2p  [PAL  Std 4:3 75%]
-a 3   [NTSC Std 4:3 50%]
-a 3p  [PAL  Std 4:3 50%]
-a 4   [NTSC Std 4:3 33%]
-a 4p  [PAL  Std 4:3 33%]
-a 5   [NTSC Wide 16:9 100%]
-a 5p  [PAL  Wide 16:9 100%]
-a 6   [NTSC Wide 16:9 75%]
-a 6p  [PAL  Wide 16:9 75%]
-a 7   [NTSC Wide 16:9 50%]
-a 7p  [PAL  Wide 16:9 50%]
-a 8   [NTSC Wide 16:9 33%]
-a 8p  [PAL  Wide 16:9 33%]
-a 0   [Custom]

A lot of options.  Let's walk through a typical example.  Put a DVD in your DVD-drive and allow Kubuntu to open it.  Close the navigation window.  The DVD should be mounted automatically to /media/cdrom0.  What tracks on the DVD would you like to rip?  To find out what tracks are available, type:

mplayer dvd://1

to see what's on the first track.  Continue with:

mplayer dvd://2

and so on until you've determined what you'd like to rip.

Let's say that you want to rip chapters 2-4 of track 5 of a DVD produced in North America, and you want them ripped at 50% of their original size.  The track is in 16/9 format (widescreen).  You also use a laptop that can overheat itself easily.  Type:

dvd2avi.sh -d /media/cdrom0 -c -s -a 7

You will see the output:

Rip from track:

Type:

5

and enter.  You will then see:

To track:

Type: 

5

This will ensure that track 5 and only track 5 is ripped.  You'll then see:

Starting chapter:

Type:

2

and enter.  You'll then see:

Ending chapter: 

Type:

4

and enter.  The process should start automatically.

Now let's say that the DVD produced was produced in the UK.  We would then type:

dvd2avi.sh -d /media/cdrom0 -c -s -a 7p

The only difference between this command and the previous is that we typed "-a 7p" instead of "-a 7".  


Rip DVD's to MP3's

Download dvd2mp3.sh and do the following:

sudo mv dvd2mp3.sh /usr/bin/

You will also need MPlayer, sox and lame:

sudo apt-get install mplayer sox lame

Once all three programs have been installed, type in the command-line:

dvd2mp3.sh -h

You'll see something like:

dvd2mp3.sh 0.2 (2006-08-06)
options:
-h [Help]
-d /full/path/to/dvd/folder
-b [bitrate: any positive multiple of 8, DEFAULT=128]
-m [mode: s, j, f, d, m  See 'man lame' for details]
-s [sleep mode for hot processors]

Let's try an example.  Put a DVD in your DVD-drive and allow Kubuntu to open it.  Close the navigation window.  The DVD should be mounted automatically to /media/cdrom0.  What tracks on the DVD would you like to rip?  To find out what tracks are available, type:

mplayer dvd://1

to see what's on the first track.  Continue with:

mplayer dvd://2

and so on until you've determined what you'd like to rip.

Let's say that you want to rip tracks 2 and 3 at 192 kBits compression.  Type:

dvd2avi.sh -d /media/cdrom0 -b 192

You will see the output:

Rip from track:

Type:

2

and enter.  You will then see:

To track:

Type: 

3

After a few minutes, your MP3 files are complete.

Boot fix (Kubuntu hangs and doesn't start the GUI)

A Thinkpad T-21 had this problem with Kubuntu:  it would go through the graphical boot process and just before switching to the login screen, it would hang there with a cursor in the upper left-hand corner.  There it would sit.  To get around this, do:

sudo nano /boot/grub/menu.lst

and locate the default kernel.  As an example:

title           Ubuntu, kernel 2.6.15-23-686
root            (hd0,5)
kernel          /boot/vmlinuz-2.6.15-23-686 root=/dev/hdc6 ro quiet splash
initrd          /boot/initrd.img-2.6.15-23-686
savedefault
boot

Modify the "kernel" line to remove the "splash" boot option:

kernel          /boot/vmlinuz-2.6.15-23-686 root=/dev/hdc6 ro quiet

The boot sequence will no longer be graphical, but the computer shouldn't get hung up anymore.

To make this change permanent, it's necessary to remove the "splash" boot option from all of the Linux kernels.  Then locate the following:

## additional options to use with the default boot option, but not with the
## alternatives
## e.g. defoptions=vga=791 resume=/dev/hda5
# defoptions=quiet splash

The defoptions line should be modified to:

# defoptions=quiet

Testing other Operating Systems

VMPlayer is an interesting program that allows you to test-drive another operating system (OS) without having to burn an ISO image to a CD and rebooting.   To do so, install the following:

sudo apt-get install vmware-player vmware-player-kernel-modules qemu 

vmware-player and vmware-player-kernel-modules will install vmplayer.  You will have to OK their license, which details the terms under which the different parts of their software are distributed.  (Quick summary:  unless you are a software developer, don't worry.) 

The qemu package installs just qemu, which we'll use to create the disk image that VMplayer will in turn use to run the operating system images you download.  Select a partition with at least 4GB of space available and type:

qemu-img create -f vmdk hd.vmdk 4G

Notice that the resulting file, hd.vmdk, is not 4GB in size.  Where should it be stored?  VMplayer will create the folder "vmware" in your home directory by default to store a number of files, so it will be simplest to create the folder ahead of time and put hd.vmdk there:

mkdir ~/vmware
mv hd.vmdk ~/vmware

Now we need a CD image of an operating system to play with.  Just a few options of many include:

Download an ISO image into the vmware folder in your home directory.  Next, download the sample.vmx file and place that in the vmware folder as well.  Then we'll need to copy and customize it for each CD image that you download.

As an example, let's say that you've downloaded an ISO image of Damn Small Linux.  These are the steps we'd take to prepare it for VMplayer:

mv dsl-n-01RC3.iso ~/vmware
mv sample.vmx ~/vmware
cd ~/vmware
cp sample.vmx dsl.vmx
nano dsl.vmx

Inside dsl.vmx, look for the following:

ide1:0.fileName = "NAME_OF_THE_ISO.ISO"
displayName = "Name of the Operating System"


We'll need to change that to:

ide1:0.fileName = "dsl-n-01RC3.iso"
displayName = "DSL Linux"


Now we're ready to run VMplayer!  Click on K Menu --> System --> VMware Player.  Open the vmware folder and choose dsl.vmx  Now you're running another operating system from within Kubuntu.

Note that VMplayer will "play" any ISO image for any OS that will run on your processor.  This includes any versions of Linux, BSD Unix, and Windows.  
For more options, see "Ubuntu Hacks" for information on installing the VMware server.
HACKS

LINKS
The Ubuntu Counter Project - user number # 4869©2006 Daniel Callahan.  All rights reserved except for code: code released under GNU General Public License 2.0