Saturday, 26 July 2008

Bit-Copy a Hard Disk Over A Network

This method creates a disk image file for the backup using dd and nc (netcat). See also rsync

On the server (destination of the image file)
nc -l 5000 | of=disk.dd.gz

On the PC (disk to be backed up)
dd if=/dev/sda | gzip -9 | nc -q 5 hostname 5000

5000 is the listen port, you can choose any unused port you like

To restore the disk;

On the receiver (where the physical disk is)
nc -l 5000 | gunzip | dd of=/dev/sda

On the server (where the disk image is)
dd if=disk.dd.gz | nc -q 5 hostname 5000

Thursday, 10 July 2008

Creating an ISO image from a directory

If you want to create an ISO image from the files contained inside a directory you can use mkisofs;

mkisofs -J -r -o filename.iso path/to/files

If you get an error that the file will be bigger than 4GiB-1 then use this command;

mkisofs -allow-limited-size -udf -J -r -o filename.iso path/to/files

Tuesday, 8 July 2008

Switching between versions of Java

If you install Sun Java you may end up with two versions of java on your system. To select which one is active use this command;

sudo update-alternatives --config java

Thursday, 3 July 2008

Converting an RPM to a DEB

Sometimes the software you want to install is not available in the Ubuntu repo's and when you find it on the web you discover that "oh noes, it's only available as a Red Hat "rpm"

Never fear, it is usually possible to convert the rpm to a deb using alien. This should be done as a last resort however, it's always better to use a native deb package wherever possible.

The alien package is available from the multiverse repository. If you need to enable this repo see this post here

Install alien;

sudo apt-get install alien

To convert an rpm;

alien --to-deb --scripts package-xyz.rpm

As always, you should change package-xyz to the name of your package,

Thursday, 26 June 2008

Adding repositories

Ubuntu ships pre-configured to connect to the standard repositories.

A lot of extra packages are available from the "universe" and "multiverse" repositories.

You can add these by editing the file /etc/apt/sources.list (backup the original file first!)

gksu cp /etc/apt/sources.list /etc/apt/sources.list.bak
gksu gedit /etc/apt/sources.list

The sources.list file can look a bit daunting to the novice. Essentially there are four "sections" in each repository, they are;

hardy
hardy-updates
hardy-backports
hardy-security

Note: If you are using another release, replace "hardy" with the name of your release.

There are also four primary repositories;

main
restricted
universe
multiverse

The default sources.list file uses a seperate line for each repository and section. Most of the extra lines you require are already included but are commented out. You can uncomment them by removing the # from the beginning of each line that starts with "deb"

It is also possible to neaten things up by just adding all the repositories to a single set of four lines and simply removing everything else from the file (assuming you did the backup above!)

A simple sources.list using the repository at the main ubuntu site (http://archive.ubuntu.com) would be;

deb http://archive.ubuntu.com/ubuntu/ hardy main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ hardy-security main restricted universe multiverse

After you have made the changes and saved the file you need to tell the system to update the repository information;

sudo apt-get update

Now you have access to a whole lotta extra software goodness!

Tuesday, 6 May 2008

Packages

Traditionally on Linux systems, if you wanted to install a software package, you were required to obtain the source code and compile it using the compiler that was included in your system. This is still possible today, and hardcore geeks will still tell you it is the best way to maintain your system.

This may be true, but it is also more difficult for novice users and less convenient, especially when you need to update a package.

Fortunately, most modern linux distributions include software systems known as "package managers" which allows you to install pre-compiled binaries and avoid all that mucking about.

Ubuntu, being based on the debian distribution uses "deb" packages for installing binary packages.

While it is possible to download a deb file from the internet and install it (like installing an exe under that other OS), it is much better wherever possible to use your distributions online repositories to avoid being plunged into "dependency hell

In ubuntu, the easiest way to install software packages is by using "Add/Remove" on the "Applications" menu.

A lightly more advanced way is by using "Synaptic Package Manager" which can be found under "System>Administration"

On the command line you can use the apt-cache command to search for a package or apt-get to install and remove packages.

To search for a package using a text string;

apt-cache search | grep search_text

To install a package named "package"

sudo apt-get install package


Next we will look at adding extra software repositories.