Install and setup mysql centos redhat

How to install MySQL

  1. Install MySQL
    yum install mysql-server mysql php-mysql

How to configure MySQL

  1. Set the MySQL service to start on boot
    chkconfig –levels 235 mysqld on
  2. Start the MySQL service
    service mysqld start
  3. Log into MySQL
    mysql -u root
  4. Set the root user password for all local domains
    SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘new-password‘);
    SET PASSWORD FOR ‘root’@’localhost.localdomain’ = PASSWORD(‘new-password‘);
    SET PASSWORD FOR ‘root’@’127.0.0.1’ = PASSWORD(‘new-password‘);
  5. Drop the Any user
    DROP USER ”@’localhost’;
    DROP USER ”@’localhost.localdomain’;
  6. Exit MySQL
    exit

Teach spamAssasin – amavis that a message is SPAM

Spamassassin is a powerful antispam tool. However, it consumes a lot of processing power, so a good idea is to install amavis. This is a lightweight Perl script that pre-scans emails and rejects many of them based on rules that you set up within the Amaviz configuration file.

NOTEThis page won’t attempt to teach you how to install and configure Spamassassin or Amavis. Other tutorials exist online. This tutorial is here to give you tips that you may not find elsewhere.

Spamassassin uses bayesian filters (think of this as a form of artificial intelligence) that can learn about what sort of emails are spam (bad) and what sort are ham (good). The key to this is a tool calledsa-learn which you run against mailbox files that either contain only ham or only spam emails. This allows Spamassassin to learn which emails you think are spam. Spamassassin uses several files to store this information, kept in a hidden directory (.spamassassin) for each mail user.

To teach Spamassassin about spam, you pass the –-spam paramter to sa-learn. For ham, the parameter is –-ham.

In the examples below we will assume that Spamassassin is running under the user account spamd and that a mailbox file (in the mbox format common with IMAP servers) that contains only sample spam emails is called Junk and is in the /tmp directory.

Tip 1: Spamassassin with amavis uses the .spamassassin directory in the Amavis working directory (usually /var/spool/amavis). Therefore when you are teaching Spamassassin called by Amavis, you need to use the –dbpath parameter. E.g.:

sa-learn –dbpath /var/spool/amavis/.spamassassin –mbox –spam -u spamd /tmp/Junk

sa-learn will look at the emails and will teach Spamassassin that the emails are spam. However, Spamassassin needs to be told to reload its bayesian knowledge files in order to gain this new-found knowledge.

Tip 2: After running sa-learn, issue a kill -HUP to the spamd parent process to force a reload of the bayesian knowledge base. E.g.:

kill -HUP `cat /var/run/spamd.pid`

In very active system the spam flies in quickly filling the Junk file. This can slow down the sa-learn processing dramatically so a good idea is to clear it down. A common way in Linux to truncate a file is to issue a command such as:

> /tmp/Junk

However, for some IMAP servers, this can produce some nasty lockups in client email software when the mail user tries to add spam emails to the folder.

Tip 3: Clear down the Junk file(s) in an IMAP-friendly way. This means moving the file somewhere else for processing and recreating the user file rather than truncating it (note that we mv and recreate first before running sa-learn to ensure that the IMAP “folder” has only disappeared for a fraction of a second rather than waiting for a potentially very long sa-learn run to finish before recreating the file):

mv /home/username/mail/Junk /tmp/Junk

touch /home/username/mail/Junk

chown brad /home/username/mail/Junk

chmod 700 /home/username/mail/Junk

sa-learn –dbpath /var/spool/amavis/.spamassassin –mbox –spam -u spamd /tmp/Junk

Spammers use automated tools to harvest email addresses. Publishing an email address online is a magnet for spam. This can be to your advantage if you want Spamassassin to learn about new spam messages before they arrive at your legitimate email addresses. The trick is to make spammers send spam to honeypot email addresses first:

Tip 4: Create honeypot email addresses that route all email received at those addresses into a spam email file. This can then be used to teach Spamassassin about new forms of spam before the spammers send to your legitimate email addresses. Seed the spam email addresses on the Internet. Put them into web pages where email address harvesting software will find them but ensure that humans will not send legitimate email to them by putting up suitable messages around the email addresses.

Of course, you want Spamassassin to learn about spam automatically. This means that you will want sa-learn to run periodically.

Tip 5: Create a cron job to run sa-learn periodically, letting it learn what is spam from the honeypot email addresses as well as the Junk folders maintained by your email users. To do this, you need a suitable cron script. Below is a template for you to use. You will need to adjust the paths to the executables and files applicable on your system. In the example below, we have called the file where the emails from the honeypots are stored honeypot which we store in /var/spool/mail.

We have assumed that users move spam that they receive into (an IMAP) file on the server called Junk. In the example we show two techniques for processing this Junk user file. For username we truncate the file in an IMAP friendly manner by moving it and recreating the user file before sa-learn processes the moved file. For usernameX we don’t truncate the file. This means that the file will continue to grow in size until it’s truncated by some other means. Sa-learn will ignore spam emails that it has already learned about so it is safe to not truncate a file provided that it doesn’t grow to a point that sa-learn takes a long time to process it. If in doubt, truncate.

Also in the example below, we show how sa-learn can simply take a list of filenames on the command line which is handy if you have more than one file building up a store of spam emails:

#!/bin/bash

 

/bin/mv /home/username/mail/Junk /tmp/Junk

/bin/touch /home/username/mail/Junk

/bin/chown brad /home/username/mail/Junk

/bin/chmod 700 /home/username/mail/Junk

 

/usr/bin/sa-learn –dbpath /var/spool/amavis/.spamassassin –mbox –spam -u spamd /tmp/Junk /home/usernameX/mail/Junk /var/spool/mail/honeypot >/tmp/sa-learn.log 2>&1

 

# Truncate the honeypot file

> /var/spool/mail/honeypot

 

rm -f /tmp/Junk

 

/bin/kill -HUP `/bin/cat /var/run/spamd.pid`

 

DD command examples

Example 1. Backup Entire Harddisk

To backup an entire copy of a hard disk to another hard disk connected to the same system, execute the dd command as shown below. In this dd command example, the UNIX device name of the source hard disk is /dev/hda, and device name of the target hard disk is /dev/hdb.

# dd if=/dev/sda of=/dev/sdb
  • “if” represents inputfile, and “of” represents output file. So the exact copy of /dev/sda will be available in /dev/sdb.
  • If there are any errors, the above command will fail. If you give the parameter “conv=noerror” then it will continue to copy if there are read errors.
  • Input file and output file should be mentioned very carefully, if you mention source device in the target and vice versa, you might loss all your data.

In the copy of hard drive to hard drive using dd command given below, sync option allows you to copy everything using synchronized I/O.

# dd if=/dev/sda of=/dev/sdb conv=noerror,sync

Example 2. Create an Image of a Hard Disk

Instead of taking a backup of the hard disk, you can create an image file of the hard disk and save it in other storage devices.There are many advantages to backing up your data to a disk image, one being the ease of use. This method is typically faster than other types of backups, enabling you to quickly restore data following an unexpected catastrophe.

# dd if=/dev/hda of=~/hdadisk.img

The above creates the image of a harddisk /dev/hda. Refer our earlier article How to view initrd.image for more details.

Example 3. Restore using Hard Disk Image

To restore a hard disk with the image file of an another hard disk, use the following dd command example.

# dd if=hdadisk.img of=/dev/hdb

The image file hdadisk.img file, is the image of a /dev/hda, so the above command will restore the image of /dev/hda to /dev/hdb.

Example 4. Creating a Floppy Image

Using dd command, you can create a copy of the floppy image very quickly. In input file, give the floppy device location, and in the output file, give the name of your floppy image file as shown below.

# dd if=/dev/fd0 of=myfloppy.img

Example 5. Backup a Partition

You can use the device name of a partition in the input file, and in the output either you can specify your target path or image file as shown in the dd command example below.

# dd if=/dev/hda1 of=~/partition1.img

Example 6. CDROM Backup

dd command allows you to create an iso file from a source file. So we can insert the CD and enter dd command to create an iso file of a CD content.

# dd if=/dev/cdrom of=tgsservice.iso bs=2048

dd command reads one block of input and process it and writes it into an output file. You can specify the block size for input and output file. In the above dd command example, the parameter “bs” specifies the block size for the both the input and output file. So dd uses 2048bytes as a block size in the above command.

Note: If CD is auto mounted, before creating an iso image using dd command, its always good if you unmount the CD device to avoid any unnecessary access to the CD ROM.

 

Courtesy:  http://www.thegeekstuff.com/2010/10/dd-command-examples/

Resize partition in Centos

Resizing a Partition

Warning

Do not attempt to resize a partition on a device that is in use.

Before resizing a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).

Start parted, where /dev/sda is the device on which to resize the partition:

parted /dev/sda

View the current partition table to determine the minor number of the partition to resize as well as the start and end points for the partition:

print

To resize the partition, use the resize command followed by the minor number for the partition, the starting place in megabytes, and the end place in megabytes. For example:

resize 3 1024 2048

Warning

A partition cannot be made larger than the space available on the device

After resizing the partition, use the print command to confirm that the partition has been resized correctly, is the correct partition type, and is the correct file system type.

After rebooting the system into normal mode, use the command df to make sure the partition was mounted and is recognized with the new size.

WP Twitter Auto Publish Powered By : XYZScripts.com