InfoCenter

  1. System Configuration

·         Dual booting method

·         DHCP server

·         A simple firewall

·         Firewall Addons

·         Port Forwarding

·         Vsftpd configuration

·         Samba configuration

·         Nfs configuration

·         Cups configuration

·         VNC configuration

·         Compiling FC4 kernel

 

  1. Utilities

·         cdrecord

·         Backing up only specific files from a directory structure

·         Virtual CD "drive" equivalent in Linux

·         Linux video encoding (mencoder)

·         Encoding to rm formats

·         What is Jigdo ?

 

  1. Tricky Stuff

·         Pacenet

·         Find your ‘encrypted’ password

·         Trick Sify

 

  1. Tips

·         Playing rmvb files in Linux

·         Lower CPU usage for audio

·         Service command for Gentoo

·         Shutdown down monitor

·         Services status for Gentoo

·         Drive optimizations

·         Straight from the Gentoo docs

 

  1. Get Comics

·         Ginger Meggs

·         Garfield

·         Calvin and Hobbes


  1. Misc

·         Installing tiger-x86


Download Everything (zip file)

 

 

System Configuration

Information Center: Dual Booting instructions

Install WinXP/Win2K

Install Linux with seperate /boot partition
Install GRUB to first sector of this /boot partition . NOT the MBR

Boot using this GRUB floppy or using any live/rescue disc.
Get the partition listing using fdisk -l. Say you have /dev/hda2 as your /boot partition
Run dd if=/dev/hda2 of=grub.bin bs=512 count=1
Copy this grub.bin to C:\.

Append boot.ini as C:\grub.bin="Linux"
Later you can set your /boot partition as the active one if you want the grub menu directly.

Information Center: DHCP server

This is the simplest possible guide for getting a DHCP sever up and running in say....3 mins.
1> Install the DHCP server package for your distro. emerge dhcp in Gentoo
2> /etc/dhcp/dhcpd.conf should contain the following lines. I've used 192.168.0.0/24 .

#basic configuration
option domain-name "internal";
 # dns servers
option domain-name-servers 202.63.164.17, 202.63.164.18;
#default gateway
option routers 192.168.0.1;
#do not update dns
ddns-update-style none;

#lease time
default-lease-time 600;
max-lease-time 7200;

#range of IPs to use
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.1 192.168.0.5;
}

#assigning particular IP to a given MAC address
host mndar2
{ hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.0.2;
option routers 192.168.0.1;
}
3> You'll have to configure the client to acquire the IP address using DHCP. In RH/FC , you have to put BOOTPROTO=DHCP in /etc/sysconfig/network-scripts/ifcfg-eth0
In Gentoo, you have to put iface_eth0="dhcp" in /etc/conf.d/net
It can't get any easier than this !!

Information Center: a simple firewall

For the longest time, I have been using firestarter. It offers a nice, easy interface for the beginner. However, I have moved on. With firestarter lacking the feature to firewall multiple ppp interfaces, I had to write my own iptables script. This version is the simples one but provides a good start. Each line has been commented to give you an explanation.This script is based on the tutorial here
This script accomplishes the following
1>Allows all outbound connections on eth0,ppp0 and ppp1. Web-browsing, chatting ,ftp etc. will work.
2>Allows you to ping other hosts. Doesn't allow them to ping you
3>Opens port 49200 on ppp0 and ppp1. I use it for bittorrent


#initialize
iptables -F
iptables --flush
iptables -t nat --flush
iptables -t mangle --flush
iptables --delete-chain
iptables -t nat --delete-chain
iptables -t mangle --delete-chain

#default -drop everything
iptables --policy INPUT DROP
iptables --policy OUTPUT DROP
iptables --policy FORWARD DROP

#allow all in loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

#DNS
iptables -A OUTPUT -p udp -o eth0 --dport 53 --sport 1024:65535 -j ACCEPT
iptables -A INPUT -p udp -i eth0 --sport 53 --dport 1024:65535 -j ACCEPT

iptables -A INPUT -p udp -i ppp0 --sport 53 --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -p udp -o ppp0 --dport 53 --sport 1024:65535 -j ACCEPT

iptables -A INPUT -p udp -i ppp1 --sport 53 --dport 1024:65535 -j ACCEPT
iptables -A OUTPUT -p udp -o ppp1 --dport 53 --sport 1024:65535 -j ACCEPT

#outbound connections
iptables -A OUTPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -o eth0 -p tcp
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -i eth0 -p tcp

iptables -A OUTPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -o ppp0 -p tcp
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -i ppp0 -p tcp

iptables -A OUTPUT -j ACCEPT -m state --state NEW,ESTABLISHED,RELATED -o ppp1 -p tcp
iptables -A INPUT -j ACCEPT -m state --state ESTABLISHED,RELATED -i ppp1 -p tcp

#pong replies, ping requests
iptables -A INPUT -p icmp --icmp-type 0 -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type 8 -j ACCEPT

#misc rules
iptables -A INPUT -p tcp -i ppp0 --dport 49200 --sport 1024:65535 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -i ppp1 --dport 49200 --sport 1024:65535 -m state --state NEW -j ACCEPT

You'll want to add your rules to the misc section incase you wanna run a ftp server or a webserver. The syntax is pretty simple . Just change the dport

Next Step: MAC address filetering and access restrictions

Information Center: firewall addons

Just a quick note about the additions in my iptables script

#access to port 80 . restrict by MAC address
iptables -A INPUT -p tcp -i eth1 --dport 80 --sport 1024:65535 -m mac --mac-source 00:01:02:02:01:00 -j ACCEPT

#access to port 21 . restrict by IP address range
iptables -A INPUT -p tcp -i eth1 --dport 21 --sport 1024:65535 -m iprange --src-range 192.168.0.1-192.168.0.2 -j ACCEPT

For NAT on your home network. change ppp0 to eth0 or whatever is applicable
#NAT
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -s ! 192.168.0.0/24 -j DROP

echo 1 >/proc/sys/net/ipv4/ip_forward
sysctl -p

The entire script that I use, is here

Information Center: Port Forwarding

External Interface: eth1 , 10.1.11.111
Internal Interface: eth0 , 192.168.0.1
LAN computer: 192.168.0.2
Client computer: 10.1.11.72

On the router(linux box). enable NAT .

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
iptables -A FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -d 192.168.0.0/24 -j ACCEPT
iptables -A FORWARD -s ! 192.168.0.0/24 -j DROP

#for webserver, apache
iptables -t nat -A PREROUTING -p tcp -i eth1 -d 10.1.11.111 --dport 80 -j DNAT --to 192.168.0.2:80
iptables -A FORWARD -p tcp -i eth1 -d 192.168.0.2 --dport 80 -j ACCEPT

#for vsftpd
iptables -t nat -A PREROUTING -p tcp -i eth1 -d 10.1.11.111 --dport 21 -j DNAT --to 192.168.0.2:80
iptables -A FORWARD -p tcp -i eth1 -d 192.168.0.2 --dport 21 -j ACCEPT

On the LAN computer. Set the gateway as the router(linux box)
Open port 80 for web server. For vsftpd 20,21 and pasv port 10000:11000
source IP: IP of the external interface on router
source mac: that of internal interface of the router


From the outside computer. Access

Information Center: vsftpd configuration

Anonymous ftp
Add the following to /etc/vsftpd/vsftpd.conf
anonymous_enable=yes
anon_root=/path/to/dir


#Letting local users login
local_enable=YES
write_enable=YES
#chroot users into their home directory
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list

Add the list of users to /etc/vsftpd.chroot_list
iptables
Apart from port 20(ftp-data) and 21(ftp), other ports are used for ftp transfer. These are higher ports. You need to open these in your firewall. The only problem is that by default these is no specific range in which vsftpd takes these ports. To fix this, add the following lines to /etc/vsftpd/vsftpd.conf
Changes required from the default config
#pasv settings
pasv_enable=yes
pasv_min_port
=9000
pasv_max_port=10000
pasv_address=ip_address


Now vsftpd will take ports in the range of 9000 to 10000

TO punch holes in the firewall
iptables -A INPUT -p tcp -i eth0 --dport 20 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --dport 21 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --dport 9000:10000 -m mac --mac-source mac-address -j ACCEPT

Information Center: samba configuration

Edit /etc/samba/smb.conf
[global]
netbios name=name
workgroup=some-workgroup
local master=yes
security=user
printing = cups

printcap name = /etc/printcap
load printers = yes

[folder]

path=/path/to/dir
guest ok=no
valid users=some-user
read only=no

[printers]
path=/var/spool/samba
printable=yes
guest ok = yes

This will share the specified directory and all your printers. Only the user some-user will be allowed access to the folder. Remove read only=no is you want it to be read only.
Add some-user and password for some-user
smbpasswd -a some-user

On the Client
For windows, its better to use Windows Explorer->Tools->Map Network Drive . The location will be \\ip-address\share-name .
For the printer , its \\ip-address\printer-name
For Mac OS X. Open Finder. Click Go->Connect to Server . Enter the location as smb://ip-address . It will prompt you to mount list of shares. Choose one, enter the username and password
For Linux,
mount -t smbfs -o username=username,password=password //ip-address/share-name /some/mount/point

Printing:
From Linux: Use IPP Period
From MAC OS X: Use IPP. If you must use Samba, this is a Windows shared printer. Good Luck finding it !
From Windows: If you get errors like "The data area passed was too small", create a Samba printer on the server that prints in loopback to your real printer. Now use this newly created printer to print from Windows!

Information Center: nfs configuration

Edit /etc/exports
/path/to/dir 192.168.0.1(rw,sync) 192.168.0.2(rw,sync)
Edit /etc/hosts.deny
ALL:ALL
Edit /etc/hosts.allow
portmap: 192.168.0.1 192.168.0.2
statd: 192.168.0.1 192.168.0.2
lockd: 192.168.0.1 192.168.0.2
rquotad: 192.168.0.1 192.168.0.2
mountd: 192.168.0.1 192.168.0.2

Set the ports for statd, rquotad, mountd
Edit /etc/conf.d/nfs
RPCQUOTADOPTS="-p 32764"
RPCSTATDOPTS="-p 32765 -o 32766"
RPCMOUNTDOPTS="-p 32767"

Add as kernel argument
lockd.nlm_udpport=4001 lockd.nlm_tcpport=4001

Open these ports

iptables -A INPUT -i eth0 -p tcp --dport 111 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 2049 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 4001 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 32764:32767 -m mac --mac-source mac-address -j ACCEPT


iptables -A INPUT -i eth0 -p udp --dport 111 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 2049 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 4001 -m mac --mac-source mac-address -j ACCEPT
iptables -A INPUT -i eth0 -p udp --dport 32764:32767 -m mac --mac-source mac-address -j ACCEPT


To mount you need portmap running on the client
mount ip-address:/path/to/dir /mount/point

Unlike samba, user permissions are respected in nfs. So, if you want people to write to the shared directories, set the permission accordingly.

Information Center: cups configuration

For Gentoo
emerge gimp-print

In the KDE Control Center->Peripherals->Printers
Add the required printer, select driver. Check linuxprinting.org for which driver to use. For my printer the -ijs one worked well.

Now, to allow other computers on your network to print to this printer.
Edit /etc/cups/cupsd.conf . Search of the section
Below Allow From 127.0.0.1 , add Allow From ip-address

If you have problems printing , check if the file /etc/cups/mime.convs
Uncomment the line
application/octet-stream application/vnd.cups-raw 0 -
In /etc/cups/mime.types
Uncomment the line
application/octet-stream
Open port 631
iptables -A INPUT -i eth0 -p tcp --dport 631 --sport 1024:65535 -m mac --mac-source mac-address -j ACCEPT

On the Client
First check the URI on the server. You can find this in the KDE Control Center. The URI will be ipp://hostname:631/printers/printer-name
For Linux, the printer should be a Network Printer(IPP/HTTP) . Enter the uri that you found on the server. Make sure you enter the ip-address instead of hostname unless you have a DNS server running on the network. Choose the necessary driver and you are done

For Windows
Choose to add a network printer and the URI will use http:// instead of ipp://
http://ip-address:631/printers/printer-name

For Mac OS X
Choose to add the IPP printer, the address will be ip-address:631
and the queue name will be
printers/printer-name
Choose the correct driver.

FYI: You'll get the fonts as they are seen on the Client, the Server fonts are not used.
You are likely to have problems when printing from Windows if you are using this method. You'll have to use Samba if this happens.

Information Center: VNC

On Server
vncserver :64 -geometry 1024x768 -depth 16
vncpasswd
to set the password
In /etc/hosts.allow
Xvnc : 192.168.0.2

Ports: 5864,5964,6064

At Client
vncviewer 192.168.0.1:64
You can also use krdc

Information Center: Compiling FC4 kernels

I was so bent up upon compiling the vanilla kernel that I never attempted to compile the kernel supplied with FC . Anyway it requires a small command and the location of the sources is different
Install the kernel source
rpm -ivh /root/kernel-2.6.11-1.1369_FC4.src.rpm

The command for FC4 is
rpmbuild -bp --target=noarch /usr/src/redhat/SPECS/kernel-2.6.spec

If --target=noarch , doesn't work, replace it with your supported architecture like --target=i686 . You can find the supported architecture using uname -a

After this, the kernel sources will be loacted in /usr/src/redhat/BUILD/kernel-2.6.11/linux-2.6.11

Compiling Instructions
make bzImage
make modules
make modules_install
make install

Happy Compiling !

Instead of the make install step, I prefer doing it manually, gives you more control

cp arch//boot/bzImage /boot/kernel-2.6.xxx
mkinitrd /boot/initrd-2.6.xxx.img kernel-version

Then modify your grub.conf

FYI: Compiling a vanilla kernel in FC is a pain in the ass. Unless you want to display your machoism, you are better off using the kernels from Red Hat

Utilities

Information Center: cdrecord


To create an ISO image for use on Linux and Windows computers
mkisofs -R -J -v -o myiso.iso /path/to/dir
To burn this ISO
cdrecord dev=/dev/hdX -v -eject speed=16 driveropts=burnfree myiso.iso

If you have a fast computer, you can pipe the output of mkisofs to cdrecord in the following manner
mkisofs -R -J /path/to/dir | cdrecord dev=/dev/hdX -v -eject speed=16 driveropts=burnfree -

Take note of the "-" at the end of the command. That tells cdrecord to take input from stdin

I prefer to keep the speed at 16. According to my calculation thats the most efficient when it comes to better burning at slower speeds and time required to burn the disc.

Information Center: Backing up only specific files from a directory structure


A guy on fedoraforums asked a question that made me rethink about a porblem I had solved months ago. Here is the gist of the question
How do I backup a particular file type from a directory structure and restore all those files to another place while preserving the directory structure?
This should make it clearer
The pic on the left shows the original structute and the one on the right shows the new one


When I had a similar problem a few months back I wrote a script that did the following things.
1>find all files *.xyz in the directory structure and put this list in a file
2>create all the required directories in the new location
3>copy over the files to the new location in the appropriate directories.

While this seems to be pretty straight forward, it isn't that easy to write a script. Moreover, give my knowledge of shell scripts, I needed a simple C program to find the directories to be created.
Time went by and I was happy with the way the script worked as I had checked it a few hundred times! But the script was flawed at the base as it was not completely a script. Moreover, it was messy and not easy to explain it to everyone.

While browsing through the man pages I found two brilliant methods , they involve using zip and tar archives
1> zip

find /path/to/dir -name "*.xyz" |zip xyz.zip -@
unzip xyz.xip -d /path/to/newdir

2> tar
tar -cvf pngs.tar -C /path/to/dir `find /path/to/dir -name "*.png"`
tar -xvf pngs.tar -C /path/to/newdir

The tar method is preferable as it does not compress . Therefore is faster. Both these methods however require you to have some disk space. The method used in my script however doesn't require such space. I guess, thats the only advantage of using it! I am still working on how to pipe the output of the tar -cvf command to tar -xvf command. I am not sure if that is possible.
Note that in the tar command, find.. is enclose in the character on the ~ key, its not a single quote!

You can download the script here

Usage :
go into the directory containing the file alex
edit the file alex. instructions are there in this file
./alex /path/to/sourcedir /path/to/destinationdir

 alex.sh 
 #the first parameter is the path to the source directory and the second one is the path to the destination directory 
 #do not provide the trailing / while specifying the source and destination directory 
 #edit the find line, replacing *.png with the file extension you wish to backup 
 #!/bin/bash 
 find $1 -name "*.png" > filelist 
 ./newdirlist 
 printf "Creating directory structure" 
 LINES="`cat dirlist|wc -l`" 
 for i in `seq 1 $LINES`; 
 do 
 export X="sed -n `echo $i`p dirlist" 
 export DIR="`$X`" 
 mkdir -p $2/$DIR 
 printf "."; 
 done 
 echo "done!" 
 printf "Copying files" 
 LINES="`cat filelist|wc -l`" 
 for i in `seq 1 $LINES`; 
 do 
 export Y="sed -n `echo $i`p filelist" 
 export FILE="`$Y`" 
 cp $FILE $2/$FILE 
 printf "."; 
 done 
 echo "done!" 
   
 newdirlist.c 
   
 #include<stdio.h> 
 int main() 
 { 
 FILE *fp1,*fp2; 
 char file[100],directory[100]; 
 int i,j,len; 
 fp1=fopen("filelist","r"); 
 fp2=fopen("dirlist","w"); 
 while(!feof(fp1)) 
 { 
 fscanf(fp1,"%s",file); 
 len=strlen(file); 
 for(i=len-1;i>=0;i--) 
 if(file[i]=='/') break; 
 strncpy(directory,file,i); 
 directory[i]='\0'; 
 fprintf(fp2,"%s\n",directory); 
 } 
 fcloseall(); 

}

Information Center: Virtual CD "drive" equivalent in Linux

When you mount an ISO in Linux using a command like
mount -o loop /path/to/iso /media/iso
the data can be accessed in the /media/iso directory
The loopback device is used in this case. If its the first ISO that is mounted, this device is /dev/loop/0 . This is important if you wanna rip DVDs or, extract the boot information from the ISO. You can consider this device like the F:, G: drive in Windows created by the Virtual CD software like Farstone , Daemon tools etc.
I have yet to do some experiments like ripping DVDs and importing bootable info, but this is the device.

Information Center: get it!, rip it! Linux video encoding demystified

Here is the simplest procedure EVER to encode a movie or rip a DVD. A 2-pass encoding hasn't been considered for the sake of simplicity

1>First the video source.
If its a file, its just the filename
If its a DVD, its given in the format dvd://(title)
If its a VCD, its given in the format vcd://(track)
If you have the ISO , mount it using

mount -o loop image /some/mount/point

The virtual device for this mount is /dev/loop/0 . Change the symlink /dev/dvd to point to this

rm /dev/dvd
ln -s /dev/loop/0 /dev/dvd

Thats it, you are done. Now the rest of the instructions remain the same.

2> You have to decide the audio and video bitrate. I enncode video using XviD because its open source and use mp3 for audio since mencoder doesn't support ogg as yet .Values of bitrate are limited by the final size of the movie you want. You have a Java Calc here www.videohelp.com/calc.htm . Its got a formula at the bottom which can be further simplified as

Size = (VideoBitrate + AudioBitrate) * Length

Size is in kiloBytes . VideoBitrate and AudioBitrate are in kiloBytes/sec and Length is in secs

You have to choose either the VideoBitrate or AudioBitrate . Choosing the AudioBitrate is easier as we know the quality of sound. Choose it anything but don't go below 128kbps else sound effects will be replaced by noise! Remember, you have to enter the Bitrate in the formula in kiloBytes/sec . Here is an example
You want to rip a 2 hour DVD so that it fits to a CD. Choosing the AudioBitrate as 224kbps, the formula would be

695*1024=(VideoBitrate+ 224/8)*2*60*60
We take the size as 695MB , leaving 5MB for the ISO data

Now VideoBitrate=70.84kiloBytes/sec, thats 566kbps

3>Next you need to decide if you want to crop any section of the screen. You should do this if the movie has blackbars.

Note:The blackbars you see while viewing the movie in full screen may not be present in the movie itself. You must be seeing them because the aspect ratio of your monitor doesn't match that of the movie. You have to view the movie in windowed mode to find if it has black bars.
You can autodetect the section to be cropped using

mplayer dvd://(title) -vf cropdetect

Check the console window, you'll have something like -vf crop=704:416:10:4 . These are the crop values required. However, I have found that this is quite error prone.

Doing it manually is a pain in the ass right now but anyway, the crop syntax is -vf crop=w:h:x:y . x:y make life even worse so we stay away from it right now. They are not necessary.

w is the width and h is height of the encoded movie in pixels


The following diagram will make it clear. Make note of the cropped area. This is the area we do not want in the encoded movie. The axis lines pass through the center.


Check if you have the correct values by playing the movie as follows

mplayer dvd://(title) -vf crop=w:h

4>Armed with the above information we issue the final command which will be

mencoder dvd://(title) -o encoded_file -ovc xvid -xvidencopts bitrate=video_bitrate -oac mp3lame -lameopts abr:br=audio_bitrate -vop crop=w:h

Have a drink, have 2..WTH, get Drunk !! and enjoy

Information Center: Encoding to rm formats

Encoding to rm formats

Tutorials on how to encode to rm formats aren't eaisly available atleast through google. I have succeeded in converting video files to rm ones. Here are the steps


1>Install mplayer,mencoder and Real Producer. Real Producer can be found here http://www.realnetworks.com/product...ucer/basic.html

2>Using mencoder convert a mpg to raw format
mencoder input_file -o output_file -ovc raw -oac pcm
This takes a lot of disk space. A 35MB mpg decompresses to about 800MB!!

3>Then encode the video with producer
producer -i raw_file -o rm_file

A 38MB mpg was converted to a 6.2MB rm with no noticeable quality loss!
FYI: The raw file should be less than 2 Gigs. Producer is not able to handle files over 2 Gigs as yet

Information Center: Jigdo http://atterer.net/jigdo/

Many must have used Jigdo(Jigsaw-download) to get the latest versions of Debian I used it to fix a corrupt downloaded ISO of Slackware10.0. Its a really interesting concept which I am sure will gain popularity in the near future. Some of you might ponder, what happened to Bittorrent. Well, I agree Bittorrent is a brilliant idea, I use it and will be using it for a long time. It provides quick way of distributing files anonymously. Exeem seems to be promising too. Its not available for linux, so I havn't got the chance to use it much.
Anyway, Bittorrent even though it has the ability to distribute a file quickly, wastes bandwidth if you consider the bandwidth utilized by your computer. I am not talking about bandwidth utilized for Upload, just the download. In my tests the efficiency was about 85%. In simple terms for 100MB for data your computer downloads, Bittorrent utilizes only 85MB. All said and done, Bittorrent still rules because it makes full use of the peers for distributing files. Such a quality is not present or rather technologically impossible with other p2p protocols.
Getting back to Jigdo.

Jigdo isn't like any other download manager which splits up a file and downloads it from different mirrors simultaneously. It just downloads the changed files in the ISO/tar/zip archive. It can be used along with rsync too which just downloads the change in each of the files!
Jigdo downloads consists of a .jigdo file and a .template file. The .jigdo file consists links to the individual files in the archive while the template file consists of the the checksums of those individual file. Visit the website mentioned above for a complete How-To. Its pretty easy to understand. I'll be posting many of short info notes in the next few days. Even though I am doing this mainly to get rid of the hundreds of notes I have in store with Knotes, I hope it is useful to someone out there.
Jigdo advantage over download-managers.
1> It can be used to upgrade a directory tree or large file like an ISO,tar or zip. This is not possible with download managers which just break the files into pieces and download it from different mirrors.

Tricky stuff

Information Center: Pacenet

Pacenet demystified


Pacenet provides you with a dialer that works only under Windows and you are forced to use it. To use their connection under Linux, you have to apply for a linux id which is userid@linuxuser. Using this ID you can connect to Pacenet with the regular windows broadband pppoe dialer too. Under linux you connect using rp-pppoe.
I didn't like the idea of having two UserIDs. So I found a little trick
Pacenet 'encrypts' the password which works as follows. Take notice of the word encrypt.

1> Each character of your password is represented for 4 digits.
2> The first three digits divided by the fourth gives the ASCII value of the character
Thats it, its as simple as that. Suppose your password is 123 then


Therefore your 'encrypted' password will be 049110021533

This is just one example. You can use any fourth digit upto 5(thats what pacenet does)
Anyway, a simple C program can be used to calculate a 'encrypted' password
The password isn't time dependent. The password generated once can be used anytime. Therefore the 'encryption' doesn't make much sense

You can now use this password under Linux with your original UserId! You can also use this password with the standard windows dialer

Information Center: Finding your 'encrypted' password, Pacenet

Here is the code for finding your 'encrypted' password to the Pacenet account. The program randomply selects the 4th digit(Refer Pacenet demistyfied). Therefore, the program will return a different `encrypted' password everytime you run it. As mentioned earlier , password generated once can be used anytime. This program will be valid until Pacenet changes its client. The encryption algorith is hard coded into the dialer.
Bear with me for not following the 3:1 commenting scheme.
You can download it here

#include <stdio.h>

#include <time.h>

 

int main(int argc,char *argv[])

{

int i,multiplier,value;

char pass[21],encrypted[81]="",temp[5];

   

strcpy(pass,argv[1]);

srand(time( NULL ) );

for(i=0;i<strlen(pass);i++)

 { multiplier=rand()%6;

   if(multiplier==0) multiplier++;

   value=(int)pass[i]*multiplier;

   if(value<100) sprintf(temp,"0%d%d",value,multiplier);

   else sprintf(temp,"%d%d",value,multiplier);

  //printf("%s ",temp);

   strcat(encrypted,temp);

  

 }

  printf("%s\n",encrypted);

    return 0;

}

 

//program to be run as root since /etc/ppp/pap-secrets is to be adjusted

//get username and pass

//calculate pass for this session

//adjust the user value in /etc/ppp/pppoe.conf

//backup /etc/ppp/pap-secrets. write new pap-secrets file.

//run adsl-start

//remove pap-secrets file, restore the backup file

//connect to their server and obtain account info and display it

//disconnect if the information says so

 

//don't know what would happen if the multiplier is set to zero. will the router crash ?

I had also written a simple code to find details of ANY Pacenet account. You have to be logged in with your Pacenet Account to find these details. Its not atall necessary. I just wrote this code for the fun of it. I havn't run it in a looong time. So, I am not sure what all info it shows. I think it gives you the ,,,,
Once again, my apologies for not following the 3:1 commenting scheme
You can download it here

#include<stdio.h>

#include<sys/types.h>

#include<sys/socket.h>

#include<netinet/in.h>

 

#define SIZE 4096

void getinfo(char *,char *);

int main(int argc,char *argv[])

{

int sockfd,yes=1,i;

char buf[SIZE],*info[5]={"<PACKNAME>","<EXPIRYDATE>","<BURSTRATE>","<DISCONNECT>","<MSG>"};

struct sockaddr_in serv_addr;

if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)

{printf("Socket error\n");

 exit(1);

}

setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,&yes,sizeof(int));

 

serv_addr.sin_family=AF_INET;

serv_addr.sin_addr.s_addr=inet_addr("203.115.71.69");

serv_addr.sin_port=htons(7001);

 

if(connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr))<0)

{printf("Error connecting");

 exit(1);

}

 

sprintf(buf,"GET /mydomainWebApp/UserInfo?user=%s\n\n",argv[1]);

send(sockfd,buf,SIZE,0);

//printf("reached here\n");

recv(sockfd,buf,SIZE,0);

//printf("%s\n",buf);

recv(sockfd,buf,SIZE,0);

//printf("%s\n",buf);

 

for(i=0;i<5;i++)

     getinfo(buf,info[i]);

 

close(sockfd);

}

 

void getinfo(char *buf,char *info)

{ char *loc1,*loc2,n,data[20];

   loc1=strstr(buf,info)+strlen(info);

   loc2=strstr(loc1,"<");

   n=strlen(loc1)-strlen(loc2);

   strncpy(data,loc1,n);

   data[n]='\0';

   printf("%s: %s\n",info,data);

  

}

Information Center: Trick Sify

This is information already present in the Sify document. I hate redundancy but this is an exception. The reason being carelessness on my part while writing that document. It isn't well organised Its just a lump of text, if thats the correct usage. Anyway, this is one small usable info out of it.
This concerns those who hate being tied down by sify to use some f&(*ed up Anti-virus or want to use one of their choice .

1>If you havn't installed the Sify Dialer skip step 2. Do step 3 and then install the dialer

2>If you have already installed the antivirus bundled with sify dialer, uninstall it. Don't start the Sify Dialer now.

3> Go to the registry and Add key Mcafee.com,in HKEY_LOCAL_MACHINE\SOFTWARE\ .
In Mcafee.com , create another key called Agent. You are done!

PS: Don't be scared to modify the registry and add the Mcafee.com key . Mcafee stores its information under HKEY_LOCAL_MACHINE\SOFTWARE\McAfee , not Mcafee.com. Mcafee.com is used only by the Sify dialer.

Tips

Information Center: Playing rmvb files in linux

I had a lot of trouble in getting rmvb files to play in Linux but finally I cracked it! xine with xine-lib version 1.0_rc8-r1 played 'em but the processor usage was pretty high, 70% for a 700MB divx file. The newer version of xine-lib plays rmvb files but with the default video driver the colour isn't proper. You'll have to experiment with the video driver settings. Anyway, processor usage is quite high. You can try opengl but occasionally Kaffeine crashed when I set it to opengl. I don't know if it was my graphics card or something else. glxinfo|grep render gives the following output
direct rendering: Yes
OpenGL renderer string: Mesa DRI Intel(R) 865G 20040919 x86/MMX/SSE2
I was reluctant to use mplayer in the past because of lower quality of video.
Then I gave mplayer -vo help to list the available options. Also it had the same problem as the newer version of xine.
I used the following options and now it works, the processor usage is less than that of xine and the quality/contrast is a little better. I used the x11 output device. With this I found that the quality is better and the processor usage is quite less, less than that with gl or gl2. I thought gl and gl2 will give better quality but with my Intel865 , I would rate them below x11. Of course x11 not being graphics accelerated, you can't do color correction.
If you really have to you can use xv (has lower CPU usage) or gl/gl2 (quite high CPU usage). xv howevr doesn't play rmvb well and the image isn't very sharp,the contrast isn't good.

mplayer foo.avi -vo x11
mplayer foo.avi -vo gl
mplayer foo.avi -vo gl2
If you are satisfied with x11, you can make the change permanant by adding the following line to ~/.mplayer/config
vo=x11

Information Center: Lower CPU usage for audio

I never thought , but the xine engine in amarok uses lesser cpu than the gstreamer engine! I have shifted completely to Gentoo (infact I have 2 Gentoo installations just incase I mess up one of them!), but I guess FC and other distros should give similar results. My USE flags are as follows

root@mndar[~]# ACCEPT_KEYWORDS="~x86" emerge -pv amarok

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild R ] media-sound/amarok-1.3.2 -arts -debug -flac +gstreamer -kde -kdeenablefinal +mp3 -musicbrainz -mysql -noamazon -opengl -postgres -visualization +vorbis +xine -xinerama -xmms 0 kB

xmms, visualization,opengl were just fancy things, so I removed 'em. I kept gstreamer since I had to compare the results.
There are many xmms fans out there who will argue that amarok takes up lot of memory and I totally agree with them. Its 8-10MB as compared to 2MB by xmms. I have just 2 words for them, 'media library' . Anyone who has used amarok, loves its media library. It also gives you the lyrics and artist info from wiki. I accept that I don't use the last 2 features much but the media library is something I cannot live without. The day xmms comes with a media library plugin as good as that of amarok, I am gonna join the xmms bandwagon! However, I don't think its memory usage will be less than that of amarok if it adds all those features.
xmms still has one advantage though. Its got a plugin, xmmplayer which allows you to play videos using mplayer from within xmms. This still seems to be under development since it doesn't support full screen playback and it takes up little more resources than mplayer used from the command line. Therefore for a person like me, using xmms doesn't seem to be the right option.

Information Center: ...service <service-name> start|stop|restart in Gentoo

Gentoo doesn't have the the service feature. You have to give /etc/init.d/ I have added a simple script to /usr/local/bin called service, the contents of which are as follows

/etc/init.d/$1 $2

Information Center: ...shutting down monitor

To switch off the monitor, give the following command
xset dpms force off
I have assigned this to a button on my PCTV remote so that I can switch off the monitor while lying on the couch. I had to add the command to a script which I call from IRKick. For some reason, the monitor doesn't switch off if I just assign the command to the button.

Information Center: services.sh

Fedora has the service --status-all command. Its missing from Gentoo. Not sure about other distros.
This one is for listing / finding the services that are currently running/not running on your box. Should work with any distro

#filename services.sh
ls /etc/init.d | sed '/.sh/d' > servicelist
LINE="`cat servicelist | wc -l`"

for i in `seq 1 $LINE`;
do
export NAME="sed -n `echo $i`p servicelist"
export SERVICE="`$NAME`"
printf "$SERVICE "
/etc/init.d/$SERVICE status;
done
rm -f servicelist


One important thing to note here is that the script ignores those which end with '.sh' . All the .sh scripts are for system startup / shutdown. I learned this the hard way. After a couple of unfortunate shutdowns, I figured it out. This is actually version 2 of the script. Never was able to complete version 1.
To get the list of started services, you can use grep. For Gentoo its
services.sh |grep started
services.sh|grep stopped
To find out what to use for your distro run the script once, you'll understand what to use.

Information Center: few more optimizations

Found some drive optimizations. Havn't had a chance to evaluate them yet but I use it anyway.
For Hard drives
hdparm -d1c1u1m16 /dev/hdX
and For optical drives
hdparm -d1c1u1 /dev/hdX

I have to use
hdparm -d0c1u1 -X udma0 /dev/hdX
for my Samsung DVD-ROM to be able to use it with minimal processor usage.

Information Center: Straight from the Gentoo docs

The portage package suit tools provide a query tool that allows you to grab some information from your installed packages. Let's see some usages of the equery utility.
Install it
emerge app-portage/gentoolkit
For example to see all the files owned by a given package type:
equery files package_name
Another example: show me the package that owns the top command.
equery belongs `which top`
Now tell me the USE flags for MySQL.
equery uses mysql
Show me the dependency tree for php.
equery depgraph php
For more information simply type...
equery -h

2> Add the names of the modules you wish to load automatically to /etc/modules.autoload.d/kernel-2.6

3> /etc/conf.d/local.start is the script thats run right after the boot process

4>To do that, simply inject the desired package, so emerge thinks that it is already installed.
emerge -i dev-perl/Digest-MD
ir add the full package name to /etc/portage/profile/package.provided . I do it while installing KDE because I don't want kdegames,kdeedu to be installed

5> As a security measure, the default configuration for Gentoo Linux requires a user to be a member of the wheel group to be allowed to execute the su command to become root.

6> If you try to stop a service such as apache and get a message like...

* WARNING: "apache" has already been started.

For some reason apache has stopped or crashed or maybe the pid file is still there after stopping it.
To avoid these situations you could type...
/etc/init.d/apache zap
and you'll get
* Manually resetting apache to stopped state.
This will reset your apache.

7> to make portage 'behave' while you do your work
PORTAGE_NICENESS="15" in /etc/make.conf
nice value ranges from -19(very high priority) to 19(very low). 0 is normal

8> To see more tricks to make portage faster
http://gentoo-wiki.com/TIP_speed_up_portage_with_cdb

Get Comics

Information Center: Ginger Meggs

Found another nice comics strip while browsing the ucomics website Ginger Meggs . Its about a nasty little Australian boy. So, I modified the garfield strip to get the Ginger Maggs one. Here is the script

#!/bin/bash
COUNT="0"
DONE="0"
while true
do
export DATE="`date +%y%m%d -d "-$COUNT days"`"
export FYEAR="`date +%Y -d "-$COUNT days"`"
if [ -e $1/$FYEAR/gin$DATE.gif ]
then
break

else
if [ $DATE == `date +%y%m%d` ] && [ `date +%H` -lt 12 ]
then
echo "Today's GingerMeggs comic strip not released yet. Pleae try after 0730GMT"
else

mkdir $1/$FYEAR
cd $1/$FYEAR
wget "http://images.ucomics.com/comics/gin/$FYEAR/gin$DATE.gif"
kuickshow $1/$FYEAR/gin$DATE.gif&
fi
COUNT=$[$COUNT+1]

fi
done
if [ $COUNT == 0 ]
then
echo "You have all the GingerMeggs comic strips!"
fi

As usual you'll have to download the first comics strip thats http://images.ucomics.com/comics/gin/2005/gin051003.gif else the script will never stop!
Actually thats the oldest one available for free as of today. ucomics.com has changed it policy. Archives older than 30 days are not accessible for free.
Next script, Calvin & Hobbes

Information Center: Garfield

I am a lazy person, probably best at it. But unlike many people, I have learned how to use this quality to my advantage. I like to make my life easier, more comfortable and for this I put in lot of effort. Whats this doing on an Info Blog? Well, read on.
I love Garfield. May be because his attitude is similar to mine. I like to view the Comic strip everyday but I don't like to visit the website or to subscribe to their newsletter becasue it contains unnecessary ads and graphics.
The garfield comic strip is released everyday at 0730 hrs GMT. here is a little script I wrote to dowload the strip for me everytime.

#!/bin/bash
COUNT="0"
DONE="0"
while true
do
export DATE="`date +%y%m%d -d "-$COUNT days"`"
export FYEAR="`date +%Y -d "-$COUNT days"`"
if [ -e $1/$FYEAR/ga$DATE.gif ]
then
break
else
if [ $DATE == `date +%y%m%d` ] && [ `date +%H` -lt 12 ]
then
echo "Today's strip not released yet. Pleae try after 0730GMT"
else

mkdir $1/$FYEAR
cd $1/$FYEAR
wget "http://images.ucomics.com/comics/ga/$FYEAR/ga$DATE.gif"
kuickshow $1/$FYEAR/ga$DATE.gif&
fi
COUNT=$[$COUNT+1]

fi
done
if [ $COUNT == 0 ]
then
echo "You have all the garfield comic strips!"
fi
You have to specify the download directory
This script does the following
1> If I have missed the strip in the last few days, actually last n days, it downloads all those strips and opens up the each strip with kuickshow.
2>If you don't have any of the garfield strip. This script will download all the strips for you and place them in appropriate folders! Pretty cool, isn't it?
However if you are doing so, please download the June 19 1978 strip(thats when Garfiel started) here ]http://images.ucomics.com/comics/ga/1978/ga780619.gif]and place it in a directory 1978. This is because the script doesn't know when to stop. I didn't add this feature becase I wanted to keep it simple and also because I didn't need it.
3>It stops at the last strip that you have. Again, done for simplicity
4>Please specify a proper destination forder. You will be in real trouble if you don't do so.
5> If you have all the strips, it displays the message accordingly
6>If you have all the strips until yesterday and you run the script before 0730hrs GMT, it displays the message accordingly

I have added this script to the one I use to connect to my ISP.
FYI, I lost the formatting when I pasted the script here. Paste it into Kwrite or gedit . Naa, you won't get the spacing the actual script. Anyway, if you want the proper one, just leave a comment, I'll mail it to you
If you have any ideas/suggestions how to make the script better/faster please post a comment

Information Center: Calvin & Hobbes

Done! Man, I am fast. Something happened yesterday, something wonderful that I cannot explain. This adds one more to the list of un-explained events.

This one is a little different since the strip started on 18th Nov 1985 and ended on 31st Dec 1995.
For the strips they are showing right now, the difference is exactly 11 years. The final strip will be shown on 31st Dec 2006.
After this they should start the strip all over again from 18th Nov 1985. In this case the difference will be 21years and 44 days. or 7714 days. This should continue until 12th Feb 2007. All this is assuming , ucomics displays the strips all over again. Else, we'll have to find other sources to get the remainder of the strips.
They no longer allow access to their archives older than 30 days hence the concern whether tehy will show the strips all over again.
Anyway, here is the script that will work until 31st Dec 2006. Little changes will be required after that.
Here too download the file http://images.ucomics.com/comics/ch/1994/ch941003.gif and put it into a directory 1994 inside your calvin&hobbes directory.
Usage for all the scripts is ./scriptname /path/to/dir . Plz do not put a trailing /.

************Sorry, slight modification 06:26hrs 2nd Nov 2005*********
#!/bin/bash
COUNT="0"
DONE="0"
while true
do
export DATE="`date +%y%m%d -d "-11 years -$COUNT days"`"
export FYEAR="`date +%Y -d "-$COUNT days"`"
FYEAR=$[$FYEAR-11]
if [ -e $1/$FYEAR/ch$DATE.gif ]
then
break
else
if [ $DATE == `date +%y%m%d -d "-11 years"` ] && [ `date +%H` -lt 12 ]
then
echo "Today's Calvin&Hobbes strip not released yet. Pleae try after 0730GMT"
else

mkdir $1/$FYEAR
cd $1/$FYEAR
wget "http://images.ucomics.com/comics/ch/$FYEAR/ch$DATE.gif"
kuickshow $1/$FYEAR/ch$DATE.gif&
fi
COUNT=$[$COUNT+1]

fi
done
if [ $COUNT == 0 ]
then
echo "You have all the Calvin&Hobbes comic strips!"
fi

Misc

Information Center: tiger-x86 install instructions

Installing tiger-x86 on an Intel865
Writing the Image

dd if=tiger-x86.img of=/dev/hda3 bs=32256 skip=1

On first boot. Use option -s

mount -o rw /
rm -f /System/Library/Extensions/AppleTPMACPI.kext
rm -f /System/Library/Extentions/AppleIntel830.kext

deadmoo password : bovinity
root password: NOT SET. set it using sudo passwd root

Running SSE3 based code on a non-SSE3 processor
Install the Maxxuss patch: http://www.maxxuss.hotbox.ru


1