Tuesday, January 12, 2010

Removing orphaned packages with GTKOrphan

The gtk orphan package present in the repositories of ubuntu can be conveniently used to clean up your system. It allows you to graphically select and remove packages that are no longer used.

On Ubuntu 9.10.Install gtkorphan as below.

$sudo apt-get install gtkorphan

A new menu entry will show up as System-Administration->Remove Orphaned packages.

Click on it.I got the following screen

.

Select the orphaned package you want to remove and click ok.



Finally, you will get the following screen.


Sunday, January 10, 2010

Openshot video editor on Ubuntu 9.10

Open shot is a non linear video editor for linux built around python , GTK and MLT frame work. Open shot 1.0 was recently released. This tutorial explains how to install it on Ubuntu 9.10.

On your Ubuntu computer, open System > Administration > Software Sources. .

Click the Other Software tab and then Click the Add button.

Type in the following line and Click on add source button.

deb http://ppa.launchpad.net/jonoomph/openshot-edge/ubuntu karmic main



When prompted, reload the software sources information. You may see a warning about unverified software sources; we're going to fix that next.

Open your terminal and enter the following commands.

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EDFBD1F9


The above command will import the apt key .
Next update the software sources

$ sudo apt-get update
Finally install open shot

$ sudo apt-get install openshot


Openshot will show up at Applications->Sound and Video->Openshot.

You can try editing a video.





Friday, January 8, 2010

Google Chrome and SRWare Iron

The chrome browser from google is a fantastic product. It is fast , reliable and multi platform. However, privacy advocates are concerned about some data that chrome sends to google while we are browsing. SRware, a German company has recently released a recompiled version of chrome named Iron to address the privacy concerns. The important differences between iron and chrome are listed here.
You can try out Iron on Ubuntu. Click here for down loading the tar.gz file.
Unzip the file like this.

$ tar -xzvf iron-linux.tar.gz

The file will be unzipped to a folder name iron-linux . You can click on the iron binary inside this folder to launch iron. Or you can add the folder to the PATH environment variable and launch iron from the command line.

Wednesday, January 6, 2010

Setting up an ad-hoc wireless network between 2 Ubuntu machines

You can create an ad-hoc wireless network between 2 linux hosts as shown below. Let us assume that we have two machine A and B both running ubuntu. We will assign 192.168.1.1 to A and 192.168.1.2 to B. I am also assuming that the drivers for the wireless card ( wlan0 here) are loaded already.
Run the following commands:
On machine A.

 ifconfig wlan0 down

iwconfig wlan0 channel 4

iwconfig wlan0 mode ad-hoc

iwconfig wlan0 essid 'fermilevel'

iwconfig wlan0 key 1234567890

ifconfig wlan0 192.168.1.1
On machine B

 ifconfig wlan0 down

iwconfig wlan0 channel 4

iwconfig wlan0 mode ad-hoc

iwconfig wlan0 essid 'fermilevel'

iwconfig wlan0 key 1234567890

ifconfig wlan0 192.168.1.2
Please note that essid and key must be same on both machines. You can change the given values.

Monday, January 4, 2010

Command Aliases in Terminal

All most all unix/linux shells support a feature called aliasing. Using this feature you can shorten a complicated command with several options to a handy one.

For example open a terminal and type in the following.

$ alias l='ls -l'
 Now typing l at the $ prompt will execute the  command ls -l .

Similarly you can alias any command.

If you want the alias to persist across reboots, add them to .bashrc





Copying Remote Files with scp

If you have ssh server running on a machine ,you can transfer files to/from it to any other machine connected over a network to it. The open-ssh server suite provides a utility named scp. Here are some examples of useful scp usage

Copy myfile to server
( ubg is my username on server1. You can replace server1 with an IP address or domain name. If the user names on the local machine and the remote server are the same you can omit it. See examples below.)

$ scp myfile ubg@server1:/tmp/
Password: ******

Copy remote myfile to local working dir
$ scp server1:/tmp/myfile /home/ubg/myfile
Password: ******

Use the -p option to preserve permissions and timestamps on the copied files:
$ scp -p myfile server1:/tmp/

If the SSH service is configured to listen on a port other than the default port 22, use
-P to indicate that port on the scp command line:
$ scp -P 12345 myfile server1:/tmp/

To do recursive copies, from a particular point in the remote file system, use the
-r option:

$ scp -r mydir ubg@server1:/tmp/

The above command will copy all mydir to remote /tmp

Sunday, January 3, 2010

Quick package install wth apt

On ubuntu , you can install a package quickly using apt as shown below.
Let us install mutt , the email client. The package name of mutt in the ubuntu repository is "mutt". ( You have to find out the package name somehow)

Press ALT+F2

The following pop will come.


Type apt:mutt in the window as shown.


Click on run.

The following pop up will come. You can press install and the rest of the procedure is same as package install from synaptic.

Thursday, December 31, 2009

Disabling splash screen in ubuntu 9.10

The splash screen is shown when you boot up ubuntu. You can stop showing it and display lot of details about your boot process as below.
Run gedit in su mode and edit the file /etc/default/grub
 sudo gedit /etc/default/grub
Locate the line that shows the floolwing
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Remove quiet and splash
GRUB_CMDLINE_LINUX_DEFAULT=""
Then save and close out of your editor

Run the following command to update grub.
Code:
sudo update-grub
This may take a couple of minutes with out any visible feedback. You will come back to bash prompt eventually.
After the previous command is finished you should be able to reboot and when you boot up you will have a verbose boot with out a splash screen. You can experiment with "splash" alone removed from the config file.



Sunday, December 13, 2009

Mounting Remote Directories with SSHFS

Recently, I was demonstrating ssh tunneling to some of my students. One of them asked me how they access remote directories in GUI. This can be achieved in several ways. Let us try mounting via ssh.

Install the sshfs package on the machine you want to mount the remote directory.

$ sudo apt-get instlall sshfs

You need ssh server running on the remote machine and you must have a valid username and password on that machine.
In the example below, I am assuming that you have an account named ubg on a remote_server . Replace remote_server with its IP address. /home/ubg/remote is the local folder into which the remote folder will be mapped. Now let us mount the remote directory.

$ sudo sshfs ubg@remote_server: /hume/ubg/remote

This will mount the home folder of the user ubg on remote_server to the folder /home/ubg/remote on the local machine. You can mount any folder on which you have read permission to the local machine. See this example.

$ sudo sshfs ubg@remote_server:/usr/share/doc /hume/ubg/remote

Now, you can access the remote folder via nautilus like a local folder.

You can unmount the remote folder with

$ sudo fusermount -u /hume/ubg/remote

Tuesday, December 1, 2009

Some wget tricks

The wget is a command line utility that can download files from web servers and FTP servers.
For example , you can download the DVD image of Karmic Koala using the following command.

$ wget http://cdimage.ubuntu.com/releases/9.10/release/ubuntu-9.10-dvd-i386.iso

If an FTP server requires a login and password, you can enter that information on
the wget command line in the following form.

$ wget ftp://user:password@ftp.example.com/path/to/file

You can use wget to download a single web page as follows:

$ wget http://unixlab.blogspot.com

A file named index.html will be created in your current directory

If you open this index.html in a web browser , you will find some of the links broken especially images. . To download all the images and other elements required to render the page properly, -p option can be used.

$ wget -p http://unixlab.blogspot.com

This will create a folder named unixlab.blogspot.com with index.html in it.

But if you open the resulting index.html in your browser, chances are you will still
have all the broken links even though all the images were downloaded. That’s because
the links need to be translated to point to your local files. So instead, do this:

$ wget -pk http://unixlab.blogspot.com

Sometimes an HTML file you download does not have an.html extension, but ends
in .php or .cgi instead. . If you wget files from such a site , your browser will complain when you try to open the file. To solve the problem , you can ask wget to append .html to such files using the -E option:

$ wget -E http://unixlab.blogspot.com

I use the following command line to keep a usable copy of the website on my hard disk.

$ wget -mEkK http://unixlab.blogspot.com

Saturday, November 28, 2009

Moving a MySQL Database To Another Server

Here is a simple command line tip for moving a mysql database from one server to another.


 mysqldump  [mysqldump_options] |
gzip -c | ssh user@remotehost "gunzip -c > mysql [mysql_options]"

Thursday, November 12, 2009

Installing Google's Go Language on Ubuntu

GO language promoted by google is a new system programming language said to be expressive, concurrent, garbage-collected. The language is still very young and there is no ready made package available for ubuntu. You can install it and try out the features from the version control repository of go .

Let us see how you can do this. I did it on ubuntu 9.04.

1) Install Pre-requisites on ubuntu.

You need gcc and some supporting software like bison to compile go. Install the following.
 $ sudo apt-get install bison gcc libc6-dev ed.

The go repository uses mercurial version controls system .
Install mercurial with the following command.

$ apt-get install mercurial

2 Set up the environment variables.

I am assuming that you are planning to install go under a folder
named go in your home directory.

In my case it is /home/fermi/go

Create it with
$mkdir go

Now create another direcory inside go .

$ mkdir go/bin

The above directory will contain your go compiler.
Next, you have to set u several variables.

$ export  GOROOT=/home/fermi/go/hg
$ export GOOS=linux

$ export GOARCH=386
$ export GOBIN=/home/fermi/go/bin

( Note: You need not create the folder hg. You can also add the above
four lines along with the PATH variable below to the .bashrc file
if you are planning to use go regularly.)

Update your PATH variable .

$ export PATH=$PATH:$GOBIN

Check the environment variables with.
 $ env | grep '^GO'

I got like this.

GOBIN=/home/fermi/go/bin/
GOARCH=386
GOROOT=/home/fermi/go/hg
GOOS=linux

3) Grab the source code from mercurial

$hg clone -r release https://go.googlecode.com/hg/ $GOROOT 

It created
/home/fermi/go/hg and downloaded several files to it.
To build the Go distribution run.

4) Compile Go

$ cd $GOROOT/src
$ ./all.bash

Now wait for some time. The compilations will proceed and will be
completed with the following message

--- cd ../test
N known bugs; 0 unexpected bugs

5) Test go
Your go language system is ready to go.:D
Now let us write a hello world program and test it.

Create the following program in your favourite editor and save it as hello.go

package main

import "fmt"

func main() {
fmt.Printf("hello, world\n")
}

To compile hello.go run.
 $ 8g hello.go

The above command produced and intermediate file hello.8.
Next you have to link it.
$ 8l hello.8

The executable is placed as 8.out. Finally run the executable.
$./8.out

Enhancing terminals with byobu on Ubuntu 9.10

Byobu is a Japanese term for decorative screens . A Japanese byobu screen looks as below.



You can achieve similar decorative effects on your gnome terminal or xterm , or Konsole with Byobu software available from ubuntu launchpad. Infact, the new ubuntu 9.10 ships it by default. On earlier versions of ubuntu you can install byobu from the PPA here.

On my jaunty box , I added the following to /etc/sources.list and imported the key form the PPA and installed it via apt,

For trying out byobu , open a terminal and type

$ byobu

your terminal will immediately change to the following screen.



The bottom line on the above picture indicates the present status of your system. It displays several useful parameters. Byobu can be customised to display several other informatiin.

Infact ,byobu is an enhancement to GNU/Screen. So, all commands applicable to GNU/ screen will work with byobu. If you are not familiar with screen look at this page for some additional information

Most of the settings of byobu are stored in a hidden directory named .byobu under your home folder. Most ot these settings can be modified from byobu itself. For customising byubu, press F9 . You will get the following screen.


You can change the look and feel of your terminal as shown in the screen-shots below.




For me the status notifications on the last line is very useful For adding additional parameters Press F9 and select status notifications , you will get the following screens. Choose whatever parameter you want to display as your default status line.





To start byobu automatically when ever you launch a terminal on Karmic Koala desktop, select
the last option as shown below. ( Be careful as screen sessions can become background processes. I suggest you GNU/screen documentation )


and press enter.


Now click on edit->> Profile Preferences-> Title and Command on your gnome-terminal and tick Run command as login shell.


Byobu will be launched automatically next time when you start a terminal.