Saturday, October 25, 2008

Thursday, October 23, 2008

 Linux games DVD


A collection of games should be shown to directly run from a Bootable DVD without the user in need to know about Linux or care about his system.This distribution based on ArchLinux. It is designed for intel x86 architecturewith 512 MB memory. It Includes including Glest, BzFLag, Nexuiz, Sauerbraten, Enemy Territory, Torcs, Tremulous, Warsow, True Combat, Elite and World of Padman. Now The linuX-gamers.net live DVD 0.9.4 released. The linuX-gamers live DVD image is available for download via BitTorrent:lg-live-0.9.4.iso (3,118MB).visit the project's home page for more details.

Some Useful Linux commands for System Administrators

Kernel Ring Buffer: dmesg

#dmesg |more

[ 0.000000] Linux version 2.6.24-16-generic (buildd@palmer) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Thu Apr 10 13:23:42 UTC 2008 (Ubuntu 2.6.24-16.30-generic)
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: 0000000000000000 - 000000000009e000 (usable)
[ 0.000000] BIOS-e820: 000000007edf4000 - 000000007edff000 (ACPI data)
[ 0.000000] 1134MB HIGHMEM available.
[ 0.000000] 896MB LOWMEM available.
[ 0.000000] found SMP MP-table at 000fe200
[ 0.000000] Entering add_active_range(0, 0, 519680) 0 entries of 256 used
[ 0.000000] Zone PFN ranges:
[ 0.000000] DMA 0 -> 4096
[ 0.000000] Normal 4096 -> 229376
[ 0.000000] HighMem 229376 -> 519680

List of Open Files: lsof
To view a list of all the files open for a particular process

# psof -p 6685 6685 is the process ID for a process (ps -u username will give process ID)

Process Tree: pstree

This will give the list of process in a tree format

# pstree

Interprocess Communication: ipcs
This will produces a list of the IPC resources currently in use:

# ipc

User Accessing Files: fuser
This command is useful to find what processes or users are currently accessing a particular files. Example, suppose you want to unmount a file system mounted at /cdrom. umount gives “device is busy.” The fuser command can help you to find which processes are accessing the device:

vishnu@vishnu-desktop:~$ fuser -v /home/vishnu
USER PID ACCESS COMMAND
/home/vishnu: vishnu 6383 ..c.. gnome-session
vishnu 6445 ..c.. gnome-settings-
vishnu 6499 ..c.. nautilus
vishnu 6575 ..c.. update-notifier
vishnu 6585 ..c.. python
vishnu 6814 ..c.. bash
vishnu 6904 ..c.. bash

Processes List: top
Command for “table of processes,” displays a list of processes that is refreshed every two seconds.

$top

Tasks: 134 total, 1 running, 133 sleeping, 0 stopped, 0 zombie
Cpu(s): 4.8%us, 0.3%sy, 0.0%ni, 93.8%id, 1.1%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2056640k total, 1642608k used, 414032k free, 24620k buffers
Swap: 3951948k total, 0k used, 3951948k free, 629144k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 
6685 vishnu 20 0 764m 652m 23m S 4 32.5 4:15.57 firefox 
1 root 20 0 2844 1660 520 S 0 0.1 0:01.02 init 
2 root 15 -5 0 0 0 S 0 0.0 0:00.00 kthreadd 
3 root RT -5 0 0 0 S 0 0.0 0:00.00 migration/0 
4 root 15 -5 0 0 0 S 0 0.0 0:00.02 ksoftirqd/0 

Who Is Doing What: w

This will find out who is logged onto the system and what he is doing.

#w


How to change  MAC address in Ubuntu Linux

Type the following in a terminal with root permission

# ifconfig eth0 down
# ifconfig eth0 hw ether 1b:2a:4c:4d:8e:9f ( this is only for example)
# ifconfig etho up

Check your new MAC address by using

# ifconfig

Here is How to install/uninstall .deb file using dpkg on a debian or ubuntu linux

1. Howto install a .deb file

sudo dpkg -i package_file.deb

2. Hoto uninstall a .deb file

sudo dpkg -r package_name

3 Howto find version of a package installed

dpkg -l packagename

4. Howto List all installed files with version

dpkg -l

5 Howto convert .rpm files to .deb files

sudo alien package_file.rpm

Sunday, October 12, 2008

How to Make your own Distributable Ubuntu 

Make Your Own Ubuntu Live CD using Remastersys tool

Remastersys

Remastersys is a tool that can be used to make ubuntu livecd and also it can make a full system backup including personal data to a live cd or dvd that you can use anywhere and and it can install at any time. It can make your own distributable copy with all the softwares installed in your system (eg:java,flashplayer, codecs, fonts, mysql, apache,php etc) can share with your friends. This will not have any of your personal user data in it.

Add the following line to your /etc/apt/sources.list

deb http://www.remastersys.klikit-linux.com/repository remastersys/

sudo apt-get update

sudo apt-get install remastersys

run remastersys-gui and make your live cd
http://www.remastersys.klikit-linux.com/


Friday, October 10, 2008

How to Boot and run Linux from a USB flash memory stick(Collector's Item)

Here is a way to Carry Linux On your Pendrive

Carry a portable Linux version with you on a USB flash pen drive. Easily bring your portable desktop with you wherever you go.

Portable USB Linux Desktop Screenshot with CompizUSB Linux installation enables you to install a portable Linux operating system on a flash drive or USB key no larger than your thumb (thumbdrive). This portable Linux operating system can then be run from any computer that can boot from a flash device, allowing you to bring your operating system, desktop, applications, files, email, personal settings, favorites, games and more with you. It’s your own personal operating system you can carry in your pocket. On Pendrivelinux.com, we provide many simplified portable Linux flash drive installation tutorials. Making is easy for anyone to install, boot and run Linux portably from a Pen drive!

Linux flash USB installation tutorials

Note: Please perform the USB Boot Compatibility Test to ensure that your Computer is capable of booting from a Portable USB device.

Protect your Linux Ssytem from Hackers by Disabling Ping Response in ubuntu Linux

Ping is used to check if a machine is up or to find whether it can accept packet datas , Most of the hackers uses ping for finding the hackable machine. The hacking chances can be reduced by blocking ping.


in ubuntu ping can be disable by adding following line to /etc/init.d/networking (network init script)
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all

to re-enable

echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all

You can Control Your Network Traffic with Wondershaper in Linux


Suppose If you are a Network Administrator with little knowledge in Network Protocols and IPtables, don't worry, you can  control your network traffic with a simple tool named wondershaper.

sudo apt-get install wondershaper

official site : http://lartc.org/wondershaper/

Readme files in /usr/share/doc/wondershaper

$ifconfig this will help you to find the network interface (eth0, eth1 or wifi0 etc..)

Now
$sudo wondershaper eth0 downspeed upspeed
eg: sudo wonderspeed 128 64

To Disable this settings

$sudo wondershaper clear eth0

make these connection settings permanent by editing /etc/network/interfaces file :

$ sudo gedit /etc/network/interfaces and add the following lines

up /sbin/wondershaper eth0 downspeed upspeed
down /sbin/wondershaper clear eth0

Sony Play Station


About Sony playstation the concept began 22 years ago on 1986.The SOny Play Station (abbreviated  as PS,PSone,PS1,PSX) is a 32 bit fifth generation video game console was released by Sony Computer Entertainment in December 1994.
                                                                                                                                                                                                                                                                                                                                                                                                                                                               

PLAYSTATION®3 Manuals

Access online and downloadable guides for the PLAYSTATION®3 computer entertainment system.

PLAYSTATION®3 System Software User's Guide

An online guide with detailed information about the PLAYSTATION 3 system software and how to use it. The guide is updated as new system software is released and can be used for PLAYSTATION 3 systems with current system software.
Get it now.

Safety and Support

A downloadable guide (PDF) with PLAYSTATION 3 safety, troubleshooting, specifications and other information.

Quick Reference

A downloadable guide (PDF) with information on setting up the PLAYSTATION 3 system, preparing for use and basic hardware operations.

 

PlayStation® Manuals

Access online and downloadable guides for the PlayStation® game console.

PlayStation® Game Console

Compatible Peripherals

You can use these Windows Software Alternatives for Ubuntu Linux 

Windows Software Linux Alternative 
Adobe Acrobat Pro
 - PDFedit
Adobe Acrobat Reader - Adobe readerevinceKPDFocular
Adobe Photoshop GimpGimpshopKritaCinepaint
Adobe Pagemaker - Scribus
Yahoo Messenger Pidgin
AVI Cutter avidemuxCinelerra
Download ManageGWGETKget
Internet Explorer - firefox, opera, konqueror
Microsoft Access - Mysql, 
Microsoft excel - openoffice.org spreadsheet, Gnumeric 
Microsoft word - openoffice.org wordprocessor, Kword, Abiword
Microsoft One Note - Tomboy

Microsoft Powerpoint - openoffice.org impress Kpresenter
Nero Burning Rom - Brasero, K3b, Nero Linux
Windows Media Player - Mplayer, VLC Player
Omni page and AbbyFine Reader - kooka, Chandler

Fork bomb


We run our college lab on LTSP built on Debian Etch. Today, one of our students inadvertently ran a fork bomb and the entire lab was stuck. We had to reboot the system. On examining the code , it was found that he put fork system call in an infinite loop.

fork bomb is a process that ‘explodes’ by recursively spawning copies of itself. It will eventually eat up all your computing resources .

On Linux systems  you can set the maximum number of processes that a  user can run.

You can explore your current limits via the ulimit  command. This is what I got on my debian etch installation at home.

aneesh@debian:~$ ulimit -a core file size          (blocks, -c) 0 data seg size           (kbytes, -d) unlimited max nice                        (-e) 0 file size               (blocks, -f) unlimited pending signals                 (-i) 4031 max locked memory       (kbytes, -l) 32 max memory size         (kbytes, -m) unlimited open files                      (-n) 1024 pipe size            (512 bytes, -p) 8 POSIX message queues     (bytes, -q) 819200 max rt priority                 (-r) 0 stack size              (kbytes, -s) 8192 cpu time               (seconds, -t) unlimited max user processes              (-u) virtual memory          (kbytes, -v) unlimited file locks                      (-x) unlimited

On my ubuntu desktop I got this.

 sunil@Ubuntu-Hardy:~$ ulimit -a core file size          (blocks, -c) 0 data seg size           (kbytes, -d) unlimited scheduling priority             (-e) 0 file size               (blocks, -f) unlimited pending signals                 (-i) 16312 max locked memory       (kbytes, -l) 32 max memory size         (kbytes, -m) unlimited open files                      (-n) 1024 pipe size            (512 bytes, -p) 8 POSIX message queues     (bytes, -q) 819200 real-time priority              (-r) 0 stack size              (kbytes, -s) 8192 cpu time               (seconds, -t) unlimited max user processes              (-u) virtual memory          (kbytes, -v) unlimited file locks                      (-x) unlimited

On debian the maximum user processes is 4031 and on ubuntu it is 16312.

ulimit settings can be controlled by /etc/security/limits.conf . The file is commented and self explanatory. Each line in the file is organized like this.

Where:

*   can be:
o a user name
o a group name, with @group syntax
o the wildcard *, for default entry
o the wildcard %, can be also used with %group syntax, for maxlogin limit

 can have the two values:
o “soft” for enforcing the soft limits

o “hard” for enforcing hard limits
 can be one of the following:
o core - limits the core file size (KB)
o data - max data size (KB)
o fsize - maximum filesize (KB)
o memlock - max locked-in-memory address space (KB)
o nofile - max number of open files
o rss - max resident set size (KB)
o stack - max stack size (KB)
o cpu - max CPU time (MIN)
o nproc - max number of processes
o as - address space limit
o maxlogins - max number of logins for this user
o maxsyslogins - max number of logins on the system
o priority - the priority to run user process with
o locks - max number of file locks the user can hold
o sigpending - max number of pending signals

o msgqueue - max memory used by POSIX message queues (bytes)

o nice - max nice priority allowed to raise to

o rtprio - max realtime priority
o chroot - change root to directory (Debian-specific)

Typical entries  in  /etc/security/limit.conf can be

*                      soft    core                  0
*                      hard    rss                   10000
@student        hard    nproc             20
@faculty         soft    nproc               20
#@faculty         hard    nproc           50

There are soft limits and hard limits. Soft limits are default values. However hard limits are  enforced via kernel. So a user can change his soft limit up to the hard limit   using the ulimit command. For details ,RTFM ulimit.

This wikipedia article is very informative and a must read for all sysadmins. There are lot of  example bombs you can try :D.

My knoppix remastering howto


HOW I BUILT A CUSTOM DEBIAN CD FROM KNOPPIX


Update:May 2008- This is an old document and one of the first documents on remastering. I lost interest in maintaining it long back. The original document was hosted at http://gnubox.dyndns.org:8080/~sunil/knoppix.php. Now that, I got a new domain , I am putting it back on net. I hope I will be able to rewrite it for current Knoppix .

The original document was last updated on 10th January 2003.
Introduction

Knoppix is a live cd distribution based on debian GNU/Linux.It contains a large number of applications which can come in handy even on minimal hardware.Knoppix supports a large number of graphics cards sound cards scsi and USB devices.It can be used as a Linux demo, educational cd, rescue system or adapted and used as a platform for commercial product demo. It is not necessary to install anything to hard disk There is an installation program which can install the entire cd to a hard disk, if you like. It means that you have a full fledged debian installation in 20 minutes. This document describes how I built a custom live cd from knoppix. My primary motivation to build this cd was to include some of my favorite applications which are missing from stock knoppix CD. If you find any errors in this document please drop me a mail here
Requirements
a) Software

To start with you have to download knoppix image from knoppix site. There is a release every one or two week. There are 2 images: German and English. I did my setup based on 31-10-2002-EN release.

If you already have an image you can try to rsync it to the most recent version as below. However don’t expect much bandwidth saving since the knoppix image is compressed. If you have a knoppix cdrom create an image by #dd if=/dev/cdrom of=knoppix.iso)

Rename the Knoppix iso image to reflect the current release name.
Example
I have downloaded KNOPPIX_V3.1-23-10-2002-EN.iso
I want to update it to KNOPPIX_V3.1-31-10-2002-EN.iso
Rename KNOPPIX_V3.1-23-10-2002-EN.iso to KNOPPIX_V3.1-31-10-2002-EN.iso
Then
rsync -P –stats ftp.leo.org::Knoppix/KNOPPIX_V3.1-31-10-2002-EN.iso .
( you can use any other rsync site of knoppix. Always check the site for latest release)
b) Hardware

A Computer with tons of free hard disk space and memory. I did this on a Pentium 3 950MHZ machine with 128 mb RAM.
Initial setup

Make a lot of disk space free You need a lot of real estate for re-mastering KNOPPIX CD
I made two fresh partitions on my 20 GB Hard disk
hda2 with 2GB for swap
hda3 with 5 GB for re-mastering work ( you can also use an existing Linux partition if it has sufficient free space)

Now boot the machine with Knoppix cd ( You can also do the re-mastering after a hard disk install of knoppix . A how to for hard disk install can be found here )

At boot prompt press enter. Knoppix now boots into GUI. The default is KDE . You can change it at boot prompt if you want . I did re-mastering while booted to KDE. It is assumed that you are somewhat familiar with Knoppix. Read Knoppix cheat codes on the CD for more information on booting.
a) Configure networking from the KDE menu
Click on
K/Knoppix/network-Internet/Network-card-configuration

I am connected to a Lan and I configured IP address, netmask, name server and gateway This step is very important since you have to get the custom stuff to be installed from else where
b) Setup partitions

Open a root shell from KDE menu (K/Knoppix/Root-shell) You will get # prompt

Run cfdisk

Next you have to make the necessary partitions . I created two partitions hda2 with 2 GB and hda3 with 5 GB

Make the 2GB partitions type as swap ( /hda2 in my case)

Make the 5 GB partitions type as Linux native( ext2) (hda3 here)
Save the modified partition information

Quit cfdisk

For creating compressed file system we need a lot of swap space . I created the swap with
# mkswap /dev/hda2
# swapon /dev/hda2
( it is also possible to use a swap file )

Create an ext2 file system on the 5GB partition
# mke2fs /dev/hda3

Mount the 5GB partition to the Knoppix file system
# mount /dev/hda3 /mnt/hda3

The basic setup for re-mastering is ready
Installing and Removing Software

The knoppix CD is organized somewhat like the figure below ( Correct me if I am wrong. it may look different when you look at it from windows or another Linux distro)

/–demos
|–talks
|–index.html
|–autorun.bat
|–autorun.inf
|–knoppix.ico
|–KNOPPIX
|–KNOPPIX
|–boot.img
|–background.gif
|- (Some more files here)

The file KNOPPIX in /KNOPPIX directory on the cd is approxiamtley 700MB. The file contains a compressed image of the file system. We have to modify this file alone and can leave the rest of the cd intact (unless you want to modify boot image startup files etc).
a) Copy Knoppix file system to hard disk
When Knoppix CD is booted compressed image file is mounted at /KNOPPIX You have to copy it to your target partition.I did a
# cp -Rp /KNOPPIX /mnt/hda3/
( -R option is for recursive copying -p is for preserving ownership time stamp etc) This places all the files you need to make a custom cd on your hard disk at /mnt/hda3/KNOPPIX/ directory . Take a look at it

b) Chroot

You have to install/uninstall software under this tree ( if you don’t have networking copy your sources to (say) /mnt/hda3/KNOPPIX/root/ and if you have debs copy them to /mnt/hda3/KNOPPIX/var/cache/apt/archives)
Now we are going to change the root of the file system to /mn/hda3/KNOPPIX
#chroot /mnt/hda3/KNOPPIX

you will get back # prompt ( If you get /dev/null permission denied message here just press control C)
You are at / ( chrooted to /mnt/hda3/KNOPPIX)

Next mount the proc file system
#mount -t proc /proc proc
c) Setup networking
Add to /etc/resolv.conf
nameserver ip-of-ur-nameserver

( I had a curious problem /etc/resolv.conf was a symlink to /etc/dhcp/resolv.conf. Ping did not work. I removed the symlink and created a /etc/resolv.conf afresh and it worked. Make sure that you restore the symlink once you are finished)

Verify your ip address now with ifconfig. (It should be same as what you have out side chroot) Then try ping google.com. If you can ping google.com your network setup is ok under chroot.Do an apt get update
d) Install/Uninstall

You can install /uninstall whatever software you need using apt. Since the original Cd has a lot of software installed it may not be an easy task.The following is a partial list of packages I removed
Games
falconseye-data
rocks-n-diamonds
amor
nethack-x11
gnome-games-locale
xboard
gnocatan-client
imaze
kmahjongg
gnome-gnibbles
freeciv-gtk
ktuberling
gnocatan-help
ksirtet
gnome-gnobots2
jumpnbump
ksnake
xgalaga
lskat
katomic
kshisen
konquest
chromium
ktux
moon-buggy
kmoon
ksame
gnuchess
ktron
frozen-bubblekjumpingcube
fortune-mod
kodo
gnocatan-ai
gnocatan-server-console
gnocatan-server-data
nethack
821
fortunes
searchandrescue
xbill
kspaceduel
libkdegames
tipptrainer-data-dexconq
gcompris
gnome-chess
tuxracer-data
abuse-frabs
gnome-gnotski
frotz
kblackbox
gnome-games
gnome-gtali
gnome-iagno
gnome-stones
gnocatan-server-gtk
lxdoom-x11
maelstrom
kabalone
gnome-gnotravex
fortunes-min
chromium-data
kdegames
pingus-data
task-kde-games
stax
gnome-card-games
xtris
xtux
kjezz
lxdoom
Non -free
x3270
xanim festlex-oald
netscape-java-477
j2re1.3
3270-common
tgif
giflib-bin
frotz xfractint
giflib3g communicator-smotif-477
netscape-base-477
maelstrom communicator-base-477
gimp1.2-nonfree
acroread
lha
unarj
xsnow
Misc
tetex-base
tetex-extra
j2re1.3
lyx
acroread
qcad
rocks-n-diamonds
kde-i18n-da
kde-i18n-it
kde-i18n-de
kde-i18n-fr
kde-i18n-ru
kde-i18n-nl
kde-i18n-ja
kde-i18n-es
kde-i18n-cs
kde-i18n-pl
kde-i18n-tr
xfonts-intl-chinese
kword
kpresenter
abiword-gtk
karbon
kchart
kformula
kivio
koffice-libs
kontour
koshell
kspread

I copied the above list to a file ( say kicklist) then did
#dpkg -P `cat kicklist`
It removed all files listed (notice the back quote above )

If you are looking for big installed packages
# dpkg-awk “Status: .* installed$” — Package Installed-Size| awk ‘{print $2}’ | egrep -v ‘^$’ | xargs -n2 echo | perl -pe ’s/(\S+)\s(\S+)/$2 $1/’ | sort -rg
will list the packages with size in descending order.

Finally run deborphan to check if there are any orphaned packages
#deborphan > /tmp/orphanlist
#dpkg -P `cat /tmp/orphanlist`
# rm /tmp/orphanlist

An alternate method is to use synaptic and add/remove packages from GUI. Synaptic is good graphical front end to apt

For this do
# apt-get install synaptic
You have to export DISPLAY environment variable for synaptic to work properly
#DISPLAY=myip:0.0 ( replace my ip with your actual IP)
#export DISPLAY
#synaptic

It will start synaptic
Enjoy apt through synaptic

Once you are finished with synaptic you can re master the cd. If you are working from a hard disk install of knoppix and want synaptic to work, look in/etc/X11/xinit/xserverrc and see that -nolisten tcp is removed.Also do xhost + as a non root user)

Unmount proc ( This is very important)
#umount /proc

Press control D to leave chrooted environment

Further Customization
1 Installing applications compiled from source

Download the software source inside chroot environment. Compile and install as usual . If it is an X11 application export display before you test
I use checkininstall to install and maintain home brew debs
Remember to remove the sources once you are finished (it will take up space on your CD).
2) Changing user settings

It is possible to set password for users. Just set it under chrooted environment
3) Changing backgrounds

/usr/local/lib/knoppix.gif is the default background image in X
4) Modifying Boot Screen

The Knoppix Cd uses syslinux to boot. If you want to change the boot screen/messages do the following. Make a temporary directory on your hard disk (I did mkdir /mnt/hda3/image)
Copy the boot.img file from Knoppix directory of your knoppix cd
#cp /KNOPPIX/boot.img /mnt/hda3
Mount the image as follows
# mount -t msdos -o loop /mnt/hda3/boot.img /mnt/hda3/image
Now look in the image directory you created. There are a number of interesting files in this directory
a) Boot logo
logo.16 is the image displayed on boot screen. It is encoded in a special format. For replacing it grab a 640*400 16 color image. I downloaded an image from gnu.org. Convert the image to a png file ( call it logo.png)

#pngtopnm logo.pnm

#ppmtolss16 logo.16

# cp logo.16 /mnt/hda3/image/logo.16

(Keep the size of the final log.16 around 50 k). Unmount image directory. Copy the boot.img to a floppy
#dd if=boot.img of=/dev/fd0
Boot the machine from the floppy you have made. If it boots up properly you are done
b) syslinux.cfg
By modifying syslinux.cfg you can change a number of parameters passwd on to the kernel. Read the man pages of syslinux for more details
5)Modifying kernel ( ****Untested ****)

Make a new custom kernel using kernel package . Keep the kernel size small. Copy the kernel to and modules to boot.img file. replace /lib/modules/2.4.19-xfs with modules of your new kernel
Replace files in /boot
6)Changing default GUI to Gnome/ icewm
Changing default gui to something else is quite easy
Under the chrooted environment open the file
/etc/init.d/knoppix-autoconfig

Look for the following lines
—————————————

#Also read desired desktop, if any

DESKTOP=”$(getbootparam desktop 2>/dev/null)”

# Allow only supported window managers

case “$DESKTOP” in gnome|kde|larswm|xfce|windowmaker|wmaker|icewm|fluxbox|twm) ;; *)

DESKTOP=”KDE”; ;; esac
——– ^^ ————————————–

Change the KDE above to gnome and that is all
7) Remove any temporary files
a) Look in /root for hidden files such as .bash_history .viminfo
b) Nuke all deb files in /var/cache/apt/archives
c) Run the knoppix.clean script ( Be careful and run it only from chrooted environmant)

(* link to the script goes here*)
Re mastering the CD
a)Make an ISO image

1) Make a new directory on /mnt/hda3
I called it NewCd
Copy Everything except Compressed image file(KNOPPIX) from knoppix cd (look at /cdrom). You can safely delete the directories demos and talks
2) Create the compressed Image
#mkisofs -R /mnt/hda3/KNOPPIX | create_compressed_fs - 65536 > /mnt/hda3/NewCD/KNOPPIX/KNOPPIX

3) Recreate the bootable CD
#cd /mnt/hda3

#mkisofs -r -J -b KNOPPIX/boot.img -c KNOPPIX/boot.cat -o myknoppix.iso NewCd
b)Testing the image

Create a boot floppy
# dd if=/mnt/hda3/KNOPPIX/boot.img of=/dev/fd0
Copy the compressed file you created to a directory /KNOPPIX on any partition. The boot floppy i will look for /KNOPPIX/KNOPPIX on hard disk partitions.This makes your testing easy. Once you are satisfied with your image burn itto a CD
FAQ

1) How do I stop konquerer at startup
To stop konquerers you have to modify
/etc/X11/Xsession.d/45xsession
Look for the following lines

——————————————-
if [ -e "$INDEXFILE" ]; then
cat >> $HOME/Desktop/KNOPPIX.desktop <
[Desktop Entry]
Name=KNOPPIX
Exec=kfmclient openProfile webbrowsing $INDEXFILE
Type=Application
Icon=html
Terminal=0
EOF
ln $HOME/Desktop/KNOPPIX.desktop $HOME/.kde/Autostart/showindex.desktop
fi
—————————————–

It makes an autostart file. Comment it out

2) I have booted knoppix cd and mounted a hard disk how do i copy something via scp to the hard disk
Open a shell
set a password for user knoppix
start ssh (/etc/init.d/ssh start)
Then copy with scp

3 I am at $ prompt I want to su
Do sudo passwd
set a root password
then su

4) default text mode boots up in frame buffer and characters are very small how do I fix it
Mount boot.img
look for syslinux.cfg
under Default vmlinuz
change VGA=791 to VGA=normal

5 )My keyboard lay out is German. How do i change it to English
Open KDE control center select system ->keyboard and change it to US English
References
I have adapted lot of material from the following links. Also #knoppix on irc.freenode.net is a good source of information
1)Tech2k home page
Ken Burk helped me a lot on irc to improve this document . His site has excellent information which you can always rely on. His kix remastering page is also very good
2) Knoppix.net
The unofficial knoppix site is a great source of information. Lots of new stuff regarding re-mastering appear there regularly
3) Knoppix forum at linuxtag
This site mixture of German and English . Very good source on Knoppix


FRIDAY, OCTOBER 10, 2008

Lab exam question no.3

/*
Three process p1,p2 & p3.
p1 is to create a named pipe & to send a string through that pipe,
p1 should read the msg thrgh keyboard.
p2 is to read msg frm named pipe and to reverse string.
now create a pipe and send the reversed string to the pipe
process p3 read the reversed string from the pipe
ok this is the question??
*/


#include
#include
#include
#include
#include

int main()
{
int pid,fd[2],fdo,i,len;
char msg[20],temp;
mkfifo("fifo",0777); // creating a named pipe
fdo = open("fifo",O_RDWR); // opening the named pipe.
pipe(fd); // creating a pipe.


printf("In Process 1.\n\tEnter a message : ");
scanf("%s",msg);
len = strlen(msg); // length of the message 

/* write the message to the named pipe */ 
printf("\tWriting %s to a named pipe\n",msg);
write(fdo,msg,len);

pid=fork();
if(pid == 0)
{

printf("\nIn Process 2\n\tReading from named pipe.\n"); 
read(fdo,msg,len);
printf( "\tMessage read : %s\n", msg);

for(i=0;i{
temp = msg[i];
msg[i] = msg[len-1-i];
msg[len-1-i] = temp;
}
printf("\tWriting %s to a pipe.\n",msg);
write(fd[1],msg,len);

}


else if(pid>0)
{

pid = fork();

if(pid == 0)
{
printf("\nIn Process 3\n\tReading from the pipe.\n");
read(fd[0],msg,len); 
printf("\tMessage read from pipe : %s\n",msg);
}
printf("\n");
}
}



/*
A sample output. 

dipin@dipin-desktop:~/programs$ ./a.out
In Process 1.
Enter a message : aneesh
Writing aneesh to a named pipe

In Process 2
Reading from named pipe.
Message read : aneesh
Writing hseena to a pipe.

In Process 3
Reading from the pipe.
Message read from pipe : hseena


aneesh@aneesh-desktop:~/programs$ 

*/


Lab exam question no.2

/*
Three process p1,p2 & p3.
p1 should read the msg thrgh keyboard and send it to a message queue.
p2 is to read msg frm the message queue and to reverse string.
now create a pipe and send the reversed string to the pipe
process p3 read the reversed string from the pipe
ok this is the question
*/

#include

#include

#include

#include

#include

#include

#define MSGSZ 128

/*

* Declare the message structure.

*/

typedef struct msgbuf {

long mtype;

char mtext[MSGSZ];

} message_buf;

main()

{

int pid;

int msqid; // Used to store the message queue id.

int msgflg = IPC_CREAT | 0666;

key_t key;

/* pointers to send and recieve message buffer.*/
message_buf sbuf,rbuf; 

size_t buf_length;

int fd[2],i;

char msg[20],temp;

/*

* Get the message queue id for the

* "name" 1234, which was created by

* the server.

*/

key = 1234; // A default key is used.

printf("In process 1\n\tEnter the message : ");
scanf("%s",sbuf.mtext);

/* Creating a message queue. */

printf("\n\tmsgget: Calling msgget(%#lx,\%#o)\n",key, msgflg);

if ((msqid = msgget(key, msgflg )) < 0) 
{

perror("\tmsgget");
exit(1);

}

else

printf("\tmsgget: msgget succeeded: msqid = %d\n", msqid);

/*

* We'll send message type 1

*/

sbuf.mtype = 1;

buf_length = strlen(sbuf.mtext) + 1 ;

/*

* Send a message.

*/

if (msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT) < 0) 
{

printf ("\n\t%d, %d, %s, %d\n", msqid, sbuf.mtype, sbuf.mtext, buf_length);
perror("\tmsgsnd");
exit(1);

}

else

printf("\n\tMessage: \"%s\" Sent\n", sbuf.mtext);

pipe(fd);

pid = fork(); // Create the process p2.

if(pid==0)
{

printf("\nIn process 2.\n");
/*

* Receive an answer of message type 1.

*/

if (msgrcv(msqid, &rbuf, MSGSZ, 1, 0) < 0) 
{

perror("\tmsgrcv");

exit(1);

}

/*

* Print the answer.

*/

printf("\tMessage recieved : %s\n", rbuf.mtext);

buf_length=buf_length-1; 

/* Reverse the message */

for(i=0;i{
temp = rbuf.mtext[i];
rbuf.mtext[i] = rbuf.mtext[buf_length-1-i];
rbuf.mtext[buf_length-1-i] = temp;
}
printf("\tWriting %s to a pipe.\n",rbuf.mtext);
write(fd[1],rbuf.mtext,buf_length);
}



if(pid > 0)
{
pid = fork(); // Create the process p3.

if(pid == 0)
{

printf("\nIn process 3.");

/*
Read from the pipe.
*/
read(fd[0],msg,buf_length-1);
msg[buf_length-1]='\0';
printf("\n\tMessage read from the pipe : %s\n",msg);
}
}


}



/*
A sample ouput.

aneesh@aneesh-desktop:~/programs$ ./a.out
In process 1
Enter the message : aneesh

msgget: Calling msgget(0x4d2,01666)
msgget: msgget succeeded: msqid = 0

Message: "aneesh" Sent

In process 2.
Message recieved : aneesh
Writing hseena to a pipe.

In process 3.
Message read from the pipe : hseena
aneesh@aneesh-desktop:~/programs$ 
*/