Showing posts with label OS. Show all posts
Showing posts with label OS. Show all posts

Monday, November 2, 2009

Build an Email Server

Setting up an email server is remarkably straightforward, but there are a couple of things to be very careful of so it doesn't end up being a haven for spammers.
An email server consists of several components: an SMTP (Simple Mail Transport Protocol) server to handle mail transfer between hosts, POP and IMAP servers to give users access to mailboxes from their desktop mail clients, and often some kind of mail-filtering system for reducing spam and viruses passing through the system.

Postfix SMTP Server

There are many SMTP servers available in Ubuntu, and many administrators have their own personal preference, but the Postfix SMTP server is a good general-purpose choice that is fast, secure, and extensible:

$ sudo apt-get install postfix


The installation process will ask some questions about how the system will operate. Select Internet Site as the operation mode and set Mail Name to your domain.
Once the package has been installed, open /etc/postfix/main.cf in an editor and find a line like:

mynetworks = 127.0.0.0/8

To allow computers on your network to send outgoing email through the server, you need to add your network range to the mynetworks value. For example, if your network is the 192.168.0.0 class-C range, you would edit the line to read:
mynetworks = 127.0.0.0/8 192.168.0.0/24

This setting is critical to preventing your mail server being used as a relay by spammers, so only add network ranges that you trust.
When mail is delivered to a local user, it can be stored in several different ways. The older and most common approach is the mbox format, which stores all mail in a single file for each user, but the performance of the mbox format falls off dramatically with large mail volumes. Most newer mail systems use the maildir format, which stores messages in individual files nested inside directories. Postfix can handle either format equally well. Add this line to main.cf to use the maildir format:

home_mailbox = Maildir/

The Maildir/ value is appended to the home directory path of the recipient, and the trailing slash indicates to use the maildir format for storage.
Finally, look for a line that starts with mydestination =. Mail for all domains listed in this line will be accepted by your mail server, and local delivery will be attempted, so if you will host mail for multiple domains, add them here.
Restart Postfix to make your changes take effect:

$ sudo /etc/init.d/postfix restart

If you will be using your mail server only as an outbound mail gateway, that's all you need to do. Configure your email client to use your mail server for outbound mail and try sending a message to an external email account.
If the message doesn't come through, try "putting a tail" on the Postfix logfile to see what went wrong, and adjust your configuration as necessary:

$ sudo tail -f /var/log/mail.log

Reduce Spam with Greylisting

There are a variety of methods to protect your users from spam, but unfortunately there is no magic solution that causes absolutely no false positives or negatives. Greylisting is one approach that requires very little ongoing maintenance but has a very high success rate with very few false positives in which valid email is mistakenly rejected.

Greylisting works on the premise that valid mail servers will attempt redelivery of mail if they receive a "temporarily unavailable" error from the destination server, while spam hosts and viruses will typically attempt delivery only once and then move on to the next target. This means legitimate mail from a remote system will be delayed, but afterwards your mail server will remember that the sender is valid and let the mail straight through. The delay on the first message can be inconvenient, but on the whole, greylisting is one of the most successful spam-mitigation techniques currently available. To take advantage of greylisting, install Postgrey:

$ sudo apt-get install postgrey


Postgrey runs as a daemon on your mail server on port 60000, so configure Postfix to use it as a delivery policy service. Open /etc/postfix/main.cf and add an entry for the service:

smtpd_recipient_restrictions =
reject_unauth_destination,
check_policy_service inet:127.0.0.1:60000

Then restart Postfix and put a tail on the Postfix logfile before sending a test message to the system from an external mail server. On the first delivery attempt, you will see the message rejected with a nonfatal error, and then after five minutes your mail server will allow the message to be delivered. Subsequent messages from the same remote system will be delivered immediately.
Activity Reporting
To see how much traffic your mail server is handling, install the mailgraph package and start it up:

$ sudo apt-get install mailgraph
$ sudo /etc/init.d/mailgraph start


Mailgraph watches mail-server activity and logs it in an extremely efficient database, and then builds graphs that you can access through a web browser at http:// yourhost /cgi-bin/mailgraph.cgi. By default, the graphs are accessible from anywhere, so if you prefer to keep them secret, you may wish to restrict access to them using an Apache .htaccess file or with explicit access control in the Apache configuration.
POP and IMAP Services
To allow users to collect mail from the server, you need to run IMAP and/or POP services. Once again, there is a variety of alternatives, each of which have advantages and disadvantages, but the Courier suite provides very simple setup and natively supports maildir format:

$ sudo apt-get install courier-imap courier-imap-ssl \\
courier-pop courier-pop-ssl


If you configured Postfix to use maildirs, as described above, you don't need to make any changes to the Courier configuration: it will automatically detect the maildirs, and everything should just work.

source tutorial-hemlet.blogspot.com
Continue Reading...

Friday, September 25, 2009

Install Ubuntu on an External Drive

You can, in fact, install, boot, and run Ubuntu completely from a FireWire, USB, or other external drive, but it does require some special steps. This hack walks you through the process from start to finish.
In the process of working on this book, we realized one disadvantage to using a laptop as a primary computer: it is much more difficult to swap out hard drives for test systems. We wanted to set up an Ubuntu system so that we could test various hacks on a vanilla install, but we didn't necessarily want to repartition and install on the main laptop hard drive if we didn't have to. The solution was to install and run Ubuntu from an external USB drive we had; that way, the regular system stayed intact but we could boot Ubuntu whenever we wanted.

Unfortunately, this sort of install does not automatically work without some tweaking due to a few different reasons:
• By default, the initrd (initial ram disk) file that Ubuntu uses does not contain all of the drivers you need to boot from a removable drive. Your BIOS will find the drive fine (provided it supports booting from removable drives), but once the kernel loads, Linux won't be able to see or mount the drive to continue the boot process.
• Even if the initrd has the appropriate drivers, it takes a few seconds for the kernel to load these modules and detect your removable drive before it tries to use it. During this time, the system will likely try to boot and will not be able to find the removable drive because it hasn't finished configuring.
• The Ubuntu installer is very handy in that it tries to detect other OSes you might have installed on the system and will provide GRUB menu entries for each OS. Unfortunately, this means that it will set up any OS you have on the internal hard drive as being on the first BIOS drive, with the removable drive being second (or third or fourth if you have other drives on the system). When the BIOS boots from the removable drive, it will configure it as the first drive on the system, which will confuse GRUB.
In this hack, we discuss how to fix each of these problems so that you can install and boot Ubuntu from a removable drive.
Set Up the Partitions
The first step is to start the Ubuntu install process as you would with any other system, so read through until you get to the section about partitioning a drive. When Ubuntu gets to the disk-partitioning tool, note that by default it will probably pick any internal IDE or SCSI drive currently in the system. If your system uses an IDE drive, you can choose your external drive by selecting the SCSI drive the system has detected. The line will probably refer to a disk called "SCSI (0,0,0) (sda)." If you already have a SCSI hard drive in the system, it will be a bit more difficult to locate the USB drive, but chances are it will be the last SCSI drive on the system.
Be absolutely sure you pick the correct drive in this phase, because Ubuntu will format and repartition the drive you choose and wipe out any data that might have been there. If you are uncertain which drive is the appropriate one, boot from the Ubuntu Live CD and confirm which device names (sda, sdb, etc.) it assigns the different drives on your system.
Install GRUB
Once you choose the correct drive to format, continue with the Ubuntu installation process until it gets to the GRUB bootloader stage. Here, you will be asked whether you want to load GRUB to the MBR of the internal hard drive. You don't want to do this because it will overwrite any bootloader you are currently using on the system. Instead, say no and then specify /dev/sda (or whatever Linux device was assigned to your removable drive) in the next screen that appears in order to install GRUB directly on the removable drive.
Use chroot
Next, complete the Ubuntu installation up until when it prompts you to select Continue to reboot the system. Before you reboot, you will need to make some tweaks to the system. The Ubuntu installer actually provides a basic console you can use to run a few limited commands on the system. Hit Alt-F2 to switch to this console, and then hit Enter to activate it.
Now you need to prepare the removable disk so that you can chroot into it and change some files. The removable drive will actually be mounted under the /target directory, and the first step is to mount the special /proc filesystem within that drive:
# mount -t proc /target/proc


Now you can use the chroot tool to turn the /target directory into the effective / partition on the system. This way, you can run commands as though you had booted off of that drive:
# chroot /target



Tweak initrd
Once inside the chroot environment, the first thing to do is to add the modules Linux uses to make your removable drive accessible to the initrd. The /etc/mkinitramfs/modules file lets you configure extra modules to add to an initrd, so use your preferred console text editor to edit this file. If you don't have a preferred console text editor, just use vim (if you are unfamiliar with vim, check out "Edit Configuration Files" (on next blog) for a vim primer:
# vim /etc/mkinitramfs/modules


Once this file is opened, move to the very bottom of the file and add the following lines and then save and close the file:
ehci-hcd
usb-storage
scsi_mod
sd_mod
If your removable drive is connected via IEEE1394, also add the following lines:
ieee1394ohci1394sbp2

and for any other devices, simply add the modules they need to this file.
With the correct modules configured, the next step is to set up a initrd so that it will wait a number of seconds before continuing to boot. That way, Linux has time to detect and configure the removable drive. Open /etc/mkinitramfs/initramfs.conf in a text editor:
# vim /etc/mkinitramfs/initramfs.conf


Now add a new configuration option to the very top of the file so that Linux will wait for a few seconds before finishing the boot process:
WAIT=10

In our experience, 10 seconds is enough time for Linux to load a USB drive, but feel free to change this to a longer or shorter value if you need to. Save your changes and close the file.
Now you are ready to re-create an initrd file that incorporates the new settings using the mkinitramfs tool:
# mkinitramfs -o /boot/initrd.img-

2.6.15-16-386

/lib/modules/

2.6.15-16-386



Change the initrd.img and /lib/modules paths to match the kernel version included in your Ubuntu install CD.
Update GRUB
The final step is to change a few settings in the GRUB configuration file. The Ubuntu installer sets up the external device as (hd1) (or second BIOS drive), but you need to change that to (hd0) because the drive will be the first BIOS drive in the system when the BIOS boots from it. Open the GRUB menu.lst file with a text editor:
# vim /boot/grub/menu.lst


and find the lines that refer to the GRUB root device. They will look something like the following:
## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd1,0)

Change the last line to refer to hd0 instead:
## default grub root device
## e.g. groot=(hd0,0)
# groot=(hd0,0)


Next, find the section in the file that refers to different Ubuntu kernels. It should look something like the following:
title Ubuntu, kernel 2.6.15-16-386
root (hd1,0)
kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.15-16-386
boot

title Ubuntu, kernel 2.6.15-16-386 (recovery mode)
root (hd1,0)
kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.15-16-386
boot

title Ubuntu, memtest86+
root (hd1,0)
kernel /boot/memtest86+.bin
boot

Now change all of the references to hd1 to hd0:
title Ubuntu, kernel 2.6.15-16-386
root (hd0,0)
kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro quiet splash
initrd /boot/initrd.img-2.6.15-16-386
boot

title Ubuntu, kernel 2.6.15-16-386 (recovery mode)
root (hd0,0)
kernel /boot/vmlinuz-2.6.15-16-386 root=/dev/sda1 ro single
initrd /boot/initrd.img-2.6.15-16-386
boot

title Ubuntu, memtest86+
root (hd0,0)
kernel /boot/memtest86+.bin
boot

If Ubuntu has detected and configured other OSes and you want to be able to choose them as well, simply repeat the same changes to the root config option for each OSonly change hd0 to hd1. Then save your changes and close the file.
Now you can leave the chroot environment, so type exit in the console and then hit Alt-F1 to return to the main Ubuntu install console. Now you can select Continue to reboot the machine into your new install.
Keep in mind that most computers won't boot from a removable drive by default if a CD-ROM or other hard drive is present. Some BIOSes let you configure which device to boot from via a special key at boot time (such as F12). In other BIOSes, you may have to hit Esc, F2, or Del to enter the BIOS and configure the boot device order.


Continue Reading...

Sunday, April 5, 2009

Search Your Computer

Have Beagle find and fetch your information faster than you thought possible.
One of Linux's weaker points as a desktop OS has been the lack of a search feature. Nautilus has had a "find this file" function for quite some time, but it's really not much more sophisticated than a GUI wrapper around the command-line find command. Both Nautilus and the find command do similar things: they'll look at each and every file in the directory structure, trying to find a match for the criteria you've given them.
There is a better way to search a filesystem. It involves creating an index of all the files on that filesystem, which enables you to search the index much like you would a database. This is what Windows and Mac OS X do for their file-search capabilities, and now Linux has it too in the form of Beagle, a modular search engine that's written in Mono. It's easy to add Beagle to Ubuntu, and the usability benefits are tremendous.
Installing Beagle
In this hack, you'll be installing Beagle and a very cool search frontend known as deskbar-applet. deskbar-applet sits in your GNOME panel and enables all manner of search goodness for you. As with many optional goodies, you'll need to have the universe repository enabled to install both of these packages. Now, open up a terminal and install beagle and deskbar-applet:

:~$ sudo aptitude install beagle deskbar-applet

Starting beagled
Once you've got beagle and deskbar-applet installed, you'll need to start beagled (the main engine and database) manually. From a terminal, you'll simply run beagled. It should start and detach from your terminal, and run in the background:

:~$ beagled

It will then begin the process of indexing your hard disk(s). This will take a while, depending on the amount and type of data you have. We have seen beagled take up to three hours to fully index a disk. If you're running beagled on a laptop, you may want to make sure it's plugged into AC power, because the high I/O from beagled's initial indexing could drain your battery. While beagled is indexing, you can set up your GNOME desktop to automatically start beagled when you log in. Simply click on the System Menu, and select Preferences and then Sessions. Add beagled to your Startup Programs, and it will be ready to fetch stuff for you on your next login.

Using Beagle and deskbar-applet
Now that the Beagle daemon is running, it's time to add deskbar-applet to the mix. The deskbar applet is a GNOME applet, so add it to one of the GNOME panels by right-clicking on the panel and selecting "Add to Panel." Select Deskbar, click Add, and then close the window. You'll see the deskbar in your panel now.
At this point, you can put criteria into the deskbar applet and go ahead and search for something If you put your search criteria in the applet and click the little magnifying glass, you can tell the deskbar applet to search any one of a number of databases, including Beagle, which is not enabled by default. (The default search can be changed in the preferences for deskbar-applet; simply right-click on the applet and select Preferences to adjust it.)
Once you click on "Search for...using Beagle," Beagle takes over, digging through its index and fetching the proper results. By default, Beagle will search the files in your home directory, as well as metadata like email archives, instant messages, and blog posts. It doesn't matter where the data is; Beagle will fetch it for you


Continue Reading...
 

Gadget Copyright © 2009 WoodMag is Designed by Ipietoon for Free Blogger Template