Wednesday, April 23, 2008

Offline Package Repository in Debian

If you are not connected to internet, then still you can install packages
from Debian Installer DVDs. (Many thanks to my friend P. A. Venkatesh,
for inspiring me to use Debian).

1. Configuration for /etc/apt/sources.list. Just put these 3 lines in it.

deb file:///mnt/debian/disk1/ etch main contrib

deb file:///mnt/debian/disk2/ etch main contrib

deb file:///mnt/debian/disk3/ etch main contrib


2. Create directories.

# mkdir -p /mnt/debian/disk1
# mkdir /mnt/debian/disk2
# mkdir /mnt/debian/disk3

3. Mount *.iso (ISO images) file to to above directories.

# mount -o loop /debian-40r1-amd64-DVD-1.iso /mnt/debian/disk1
# mount -o loop /debian-40r1-amd64-DVD-2.iso /mnt/debian/disk2
# mount -o loop /debian-40r1-amd64-DVD-3.iso /mnt/debian/disk3

4. Now start synaptic package manager and click reload button. And Viola!
you will be able to see packages. Now you can install any package you want. :)

Wednesday, April 16, 2008

Group By Counts in a File (Generally csv files)

You can use following snippet to get GROUP BY - COUNT as in SQL
query. Like

If you want number of students in a department:

SELECT department, COUNT(*) FROM Student GROUP BY department;

Suppose that this file contains:

Mitesh Singh Jat,CSA
Mahesh Singh Sonal,CSA
Paneendra B A,SSA
Shrikant Joshi,SERC
Rupesh Bajaj,CSA
Chandrakant,SSA

1 #!/bin/bash
2
3 if [[ $# <> 4 ]]
4 then
5 echo "Usage: $0 file delim field_pos
6 exit
7 fi
8
9 CMD=`echo $1 | sed 's/.*\.gz/zcat/'`
10
11 if [[ $CMD != "zcat" ]]
12 then
13 CMD="cat"
14 fi
15
16 echo "========================"
17 echo "Buckets for $1"
18 echo "========================"
19 echo "Bucket_id Count"
20 echo "------------------------"
21 $CMD $1 | cut -d$2 -f$3 | awk '{sum[$1]++} END {for (x in sum) {out+=sum[x]; print x" \t"sum[x];} print "========================"; print "Total records : " out;}'
22 echo "========================"

$ ./group_by_count.sh Student , 2
========================
Buckets for Student
========================
Bucket_id Count
------------------------
SSA 2
SERC 1
CSA 3
========================
Total records: 6
========================


Friday, April 4, 2008

Prevent Yourself from Disaster

Edit your .bashrc file
$ vi ~/.bashrc

# prevent overwriting to existing file, while using redirection
set -o noclobber

# useful aliases
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'

Tuesday, April 1, 2008

Making Fedora 8 Usable

1. Make YUM faster by using faster and nearer repositories.
# yum install yum-fastestmirror

2. Installing Non-Free Softwares

a. Install livna repository for non-free softwares.
# rpm -Uvh http://rpm.livna.org/livna-release-8.rpm

b. Install most used audio-video support
# yum install xine-lib-extras.i386 amarok-extras-nonfree.i386 amarok-konqueror.i386 amarokFS.i386 moodbar.i386

c. Install Adobe flash player
# rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
# yum -y install flash-plugin

d. Making Adobe Acrobat Reader 7 work on Fedora 8
# vi /usr/local/Adobe/Acrobat7.0/bin/acroread
Change line number 644 from
check_gtk_ver_and_set_lib_path "$MIN_GTK_VERSION" ### returns 0 if found gtk >= 2.4
to
#check_gtk_ver_and_set_lib_path "$MIN_GTK_VERSION" ### returns 0 if found gtk >= 2.4

PS. If you find any other good Non-free software, do let me know. Thanks in Advance.