Wednesday, January 12, 2011

Setting up github ssh access behind proxy servers

At work to access/update public repo of Marss I finally setup a rather complicated proxy setting for Git which finally worked :).

I followed the steps from this tutorial and it worked without a glitch. The only change I did is instead of using 'connect.c' file provided I used standard 'nc' for basic proxy support. So my 'socks-gw' file looks like following:

#!/bin/sh
# File ~/bin/socks-gw
# Connect a SOCKS 5 proxy using 'nc'
nc -X 5 -x proxy.server:1080 $@

Monday, January 3, 2011

Good Introductory Book on Issues of Parallel Programming

Found out a link of this book from Reddit Programming, called a 'Is Parallel Programming Hard, And, If So, What Can You Do About It?'.

I skimmed through this book and trust me if you are into system programming you'll get hooked. I liked the way Paul (author of this book) has explained key obstacles of hardware in parallel programming. Its not too detailed but he has explained the basic issues in a very simple language.

Here is a link to author's official announcement of this book.

Thursday, December 23, 2010

Resizing/Moving Extended Partition in GPartEd

Yesterday I was trying to setup my old laptop as NAS server and I was trying to setup my old laptop hard-drive (which I was using as portable USB drive) for NAS storage. That old drive still contained multiple partitions including one for Windows installation. I decided to delete windows partition and use it as root partition to install Ubuntu and use rest of the drive as /home for storage. So I created a bootable USB disk of GPartEd and boot my laptop from USB.

The issue came up when I was trying to move and resize my extended partition. One of the partition had lot of data that I didn't want to loose so formatting the whole disk was not an option for me. For some reason gparted was failing on moving my extended partition and it said that can not move/resize it. I googled for some help in various linux forums and found this post in Ubuntu forums about someone had similar issue. He/She tried 'swapoff' option on 'swap' partition and it worked for him. But for me, 'swap' was already in 'swapoff' mode. So no luck there.

Then I tried something new based on that, I deleted the 'swap' partition that was in 'extended' partition, applied all the changes. Then I tried to resize and move my extended partition and it worked!!

Once again, thanks Ubuntu Forums.

Monday, December 20, 2010

Using launchpad PPA behind proxy

I was trying to setup my Ubuntu VM in work machine and I was trying to install Chromium-daily build ppa from launchpad. I have global proxy setup in my account but when I tried to setup the PPA it was not working. So standard method

sudo apt-add-repository ppa:your-ppa


was not working. The alternative was to manually set repository and authenticate the repo via 'apt-key' as shown below:

Step 1: Add the repository via 'apt-add-repository' without authenticating its GPG key.

sudo apt-add-repository 'deb http://ppa.launchpad.net/gwibber-daily/ppa/ubuntu jaunty main'


Here replace the repository info.

Step 2: Authenticate the repository using 'apt-key'. First get the PPA key info from its web page. For Chromium-daily build the key is 4E5E17B5. Use following command to authenticate using http-proxy settings of your machine.

sudo apt-key adv --keyserver keyserver.ubuntu.com --keyserver-options http-proxy="http://your.proxy.server" --recv-keys 4E5E17B5


If things goes well then you will see a message from gpg saying 'Total number processed: 1' and you should be able to install your software from either Synaptic or Ubuntu-Software-Center.

Tuesday, October 30, 2007

Check your hard-drive's remaining life

Its always a horrible scenario when your hard-drive crashes - and adds more ghosts to it when you have important data into it.

It would always be nice to have some tool that can be used to find out the approximate life period remaining of your hard-drive. Well in newer SATA hard-drives they are using a Load/Unload mechanism for separating the disk and head. (detail explaination: http://www.linux-hero.com/rant/explanation-ubuntu-hard-drive-wear-and-tear).

In linux machines you can install 'smartmontools' to find out some interesting information about your hard-drive. This tool uses S.M.A.R.T (Self-Monitoring, Analysis and Reporting Technology) technology available in new hard-drives. This gives a specific count of Load/Unload done on your hard-disk. Normal hard-disk has 600,000 of Load/Unload cycles. Following is the method to find out the remaining life time of your hard-disk.

If you are a ubunbtu user like me simply give the following command:

sudo apt-get install smartmontools


It will install 'smartmontools' to your system. After than give the following command

sudo smartctl -d ata -a /dev/sda | grep '193'


It will show output something like this:

193 Load_Cycle_Count        0x0012   097   097   000    Old_age   Always       -       30385


Here in the last the number is 30,385 which is load/unload cycle count of my hard-drive. Well my drive is only 1.5 months old and it has already used 30,385 cycles.

Tuesday, July 31, 2007

Magic Audio & Video tricks using SSH and X

Think of this: Your friend is working on your Linux desktop machine, and you are working on another Linux machine either at home or office. Your friend is editing some files and BOOM - speakers start making horrifying sounds, some horror video starts playing as full-screen mode... And if you have access to your home's electricity connection from that computer then your friend is going to have the worst experience with ghost!!!

I will let you think of more horrifying tricks later on after you know how to setup environment like this. All you need is SSH daemon running on destination machine and access to that machine using internet. Of course you must have access to user account that has all the permissions to running X server, a root access will grow two horns on your head !!!

If you are new to SSH, you should see this tutorial on SSH.
Setting up the SSH daemon in server machine is simple, install 'sshd' package and as root give following command:
root@servername# sshd

It will start a ssh daemon and you are all set to login from remote machine.

Login using SSH with -Y option:
user@localname$ ssh -Y username@servername

Using -Y you can securely forward all X11 connections to your local machine. So now fire-up your loved MP3 music player (i prefer amarok, great player with great interface) and your familiar window will greet you. So when you start playing music, it will use server machine's speakers, not local machine's !!! You can download some horrifying sounds and set up a script to play them one by one to be prepared for horror attack...

Now as you can see that we can open almost any GUI window in local machine, lets start playing some video using vlc or mplayer. But whats this, the video is played in local machine... Well to play the video in server's monitor screen, which is screen no 0 (or in pure X term display :0.0 ). To make sure that your video plays on server's monitor not in local, change your DISPLAY environment variable from localhost:10.0 (somthing like that) to :0.0 .

Check your DISPLAY variable value in your ssh session:
user@servername$ echo $DISPLAY
If its not set to :0 simply change it using following commands:
user@servername$ export $DISPLAY=:0.0
or if you are using 'csh':
user@servername$ setenv $DISPLAY :0

To make sure that the X display number is :0.0 , give the following command in your ssh session:
user@servername$ ps -ax | grep 'X'
It will show something like this:
user@servername$ 3744 tty7 Ss+ 2:01 /usr/bin/X :0 -audit 0 -br -auth /var/lib/gdm/:0.Xauth vt7

Here, the value after '/usr/bin/X' is ':0' so your display number is 0. If there are more than one display running than you may have to do trial and error to find the display number.

Now you are set to play videos in server machine's monitor. Use vlc with following options:
user@servername$ vlc -f videoname.avi
or if you like mplayer:
user@servername$ mplayer -fs videoname.avi

Now you have learn the dark side tricks of SSH go and practice it to be master of it. And when you successfully execute this mission don't forget to tell me your friend's reaction!!!

NOTE: If you try to use firefox over SSH, when we give normal 'firefox' command it runs locally not remotely, so music will be played in local machine. To fix this problem start the firefox with following options:
user@servername$ firefox -no-remote

This will start the firefox in remote machine so any music played in it will play in remote machine's speakers.... enjoy.

- Avadh Patel