Friday, October 8, 2010

Zimbra 6 on CentOS 5 Email and Calendars

Zimbra is a groupware system that provides email, calendaring, integrated antivirus and spam filtering, and more for multiple domains. Available in several editions, this guide will help you get the Open Source Edition installed on your CentOS 5

# yum install gmp compat-libstdc++-33 sysstat sudo libidn wget

Before proceeding, make sure your /etc/hosts file has valid entries. For reference, your file should resemble the following:
File: /etc/hosts
127.0.0.1     localhost.localdomain     localhost
10.30.56.8   mail.yeswedeal.com        mail

64 Bit OS
#wget http://files2.zimbra.com/downloads/6.0.8_GA/zcs-6.0.8_GA_2661.RHEL5_64.20100820052503.tgz

32 Bit OS
# wget http://files2.zimbra.com/downloads/6.0.8_GA/zcs-6.0.8_GA_2661.RHEL5.20100820051652.tgz

#tar -xzf zcs-6.0.8_GA_2661.RHEL5_64.20100820052503.tgz
#cd zcs-6.0.8_GA_2661.RHEL5_64.20100820052503
#./install.sh --platform-override
You appear to be installing packages on a platform different
than the platform for which they were built.

This platform is CentOS5
Packages found: RHEL5
This may or may not work.

Using packages for a platform in which they were not designed for
may result in an installation that is NOT usable. Your support
options may be limited if you choose to continue.


Install anyway? [N] Y 
 
You may receive a warning similar to the one shown below. Enter "Y" to proceed.
 
Before the install begins, you may receive a warning similar to the one shown below:
DNS ERROR resolving MX for archimedes.palegray.net It is suggested that the domain name have an MX record configured in DNS Change domain name? [Yes] No It is recommended (but not required) that the fully qualified domain name for your system (yeswedeal.com) have an MX record pointing to it. You may wish to visit your DNS control panel and add such a record now, or proceed if you won't be receiving mail for your FQDN on this system (for example, if you'll be receiving email for your base domain or others).
The install will continue, probably requiring a few minutes to perform various tasks. You'll be asked which components of the Zimbra package you'd like to install. For the purposes of this tutorial, choose the default values for each ("Y" or "N" depending on which letter is in the brackets).
Once the installation has completed, you'll be presented with an admin menu next.



Main menu

   1) Common Configuration:
   2) zimbra-ldap:                             Enabled
   3) zimbra-store:                            Enabled
        +Create Admin User:                    yes
        +Admin user to create:                 admin@yeswedeal.com
******* +Admin Password                        UNSET
        +Enable automated spam training:       yes
        +Spam training user:                   spam.abc@yeswedeal.com
        +Non-spam(Ham) training user:          ham.abcd@yeswedeal.com
        +Global Documents Account:             wiki@yeswedeal.com
        +SMTP host:                            yeswedeal.com 
        +Web server HTTP port:                 80
        +Web server HTTPS port:                443
        +Web server mode:                      http
        +IMAP server port:                     143
        +IMAP server SSL port:                 993
        +POP server port:                      110
        +POP server SSL port:                  995
        +Use spell check server:               yes
        +Spell server URL:                     http://yeswedeal.com:7780/aspell.php
        +Configure for use with mail proxy:    FALSE
        +Configure for use with web proxy:     FALSE

   4) zimbra-mta:                              Enabled
   5) zimbra-snmp:                             Enabled
   6) zimbra-logger:                           Enabled
   7) zimbra-spell:                            Enabled
   8) Default Class of Service Configuration:
   r) Start servers after configuration        yes
   s) Save config to file
   x) Expand menu
   q) Quit

Address unconfigured (**) items  (? - help) 3



Store configuration

   1) Status:                                  Enabled
   2) Create Admin User:                       yes
   3) Admin user to create:                    admin@yeswedeal.com
** 4) Admin Password                           UNSET
   5) Enable automated spam training:          yes
   6) Spam training user:                      spam.abc@yeswedeal.com
   7) Non-spam(Ham) training user:             ham.abcd@yeswedeal.com
   8) Global Documents Account:                wiki@yeswedeal.com
   9) SMTP host:                               yeswedeal.com
  10) Web server HTTP port:                    80
  11) Web server HTTPS port:                   443
  12) Web server mode:                         http
  13) IMAP server port:                        143
  14) IMAP server SSL port:                    993
  15) POP server port:                         110
  16) POP server SSL port:                     995
  17) Use spell check server:                  yes
  18) Spell server URL:                        http://yeswedeal.com:7780/aspell.php
  19) Configure for use with mail proxy:       FALSE
  20) Configure for use with web proxy:        FALSE

Select, or 'r' for previous menu [r] 4 
 

You can configure various options here; but, the most important option is the one for
setting the administrator password. Enter "4" to set it, choosing a strong password
comprised of letters, numbers, and non-alphanumeric characters. After setting the
admin password, enter "r" to return to the main menu. You will be asked to apply the
new configuration. Type "a" and press enter. You may then allow the
program to proceed with the remaining installation steps.
After installation has completed, you'll need to start zimbra with the following command:

#service zimbra start
To have Zimbra start on every boot, enter the following command:

#chkconfig zimbra on

you may wish to reboot your Linode to make sure everything comes back up properly. After doing so, visit the Zimbra admin URL in your browser. It will be in the form https://yeswedeal.com:7071/. You'll need to accept the SSL certificate presented to access the admin panel, which you may then use to continue configuring your new Zimbra server. Enjoy!


Monitor System Logs with Logwatch on Cent OS /RedHat /Fedora /Ubuntu

Logwatch is a utility used to monitor system logs and create reports. These reports include failed login attempts, successful login attempts, and storage space used/available.

For Fedora/CentOS/RedHat
#yum install logwatch
For Ubuntu
$sudo apt-get install logwatch


Configure Logwatch 

Once you have installed Logwatch, you will need to configure it to email you the reports it generates. You are encouraged to look through the entire configuration, but you may safely use Logwatch after editing the lines below.
File: /usr/share/logwatch/default.conf/logwatch.conf
Output = mail
Format = html
MailTo = rajat@yeswedeal.com
MailFrom = logwatch@yeswedeal.com
These directives tell Logwatch to email you reports in an HTML format. The MailTo and MailFrom directives should be valid email addresses.
Issue the following command to test your logwatch installation:
logwatch
Once you have issued this command, you will need to check your email to make sure that logwatch is working. Be sure to check your spam folder as these emails may be seen as spam.

Adding a Cron Job for Logwatch

You can add a cron job for Logwatch in order to receive daily emails of new reports. You can add a new entry to your crontab by running crontab -e. The following example cron job runs Logwatch at 1 AM each day, issuing you an email report of the daily activity:
# m h dom mon dow   command
0 1  * * *          /usr/sbin/logwatch
Congratulations! You can now monitor system logs with Logwatch!

Thursday, October 7, 2010

Biggest installed packages in Fedora

Quick tip to see which are the biggest currently installed packages on your Fedora box:
 

rpm -qa --queryformat '%10{size}-%{name}-%{version}\n' | sort -k1,1n

You might also be interested in fslint:
 
yum install fslint

It lists packages by size, and it will autoselect dependencies for packages you want to delete

Linux Files and File Permission


Linux files are setup so access to them is controlled. There are three types of access:
  1. read
  2. write
  3. execute
Each file belongs to a specific user and group. Access to the files is controlled by user, group, and what is called other. The term, other, is used to refer to someone who is not the user (owner) of the file, nor is the person a member of the group the file belongs to. When talking about setting permissions for "other" users to use, it is commonly referred to as setting the world execute, read, or write bit since anyone in the world will be able to perform the operation if the permission is set in the other category.

File names and permission characters

File names can be up to 256 characters long with "-", "_", and "." characters along with letters and numbers.
When a long file listing is done, there are 10 characters that are shown on the left that indicate type and permissions of the file. File permissions are shown according to the following syntax example: drwerwerwe
There are a total of 10 characters in this example, as in all Linux files. The first character indicates the type of file, and the next three indicate read, write, and execute permission for each of the three user types, user, group and other. Since there are three types of permission for three users, there are a total of nine permission bits. The table below shows the syntax:
1
2
3
4
5
6
7
8
9
10
File
User Permissions
Group Permissions
Other Permissions
Type
Read
Write
Execute
Read
Write
Execute
Read
Write
Execute
d
r
w
e
r
w
e
r
w
e


  • Character 1 is the type of file: - is ordinary, d is directory, l is link.
  • Characters 2-4 show owner permissions. Character 2 indicates read permission, character 3 indicates write permission, and character 4 indicates execute permission.
  • Characters 5-7 show group permissions. Character 5=read, 6=write, 7=execute
  • Characters 8-10 show permissions for all other users. Character 8=read, 9=write, 10=execute
There are 5 possible characters in the permission fields. They are:
  • r = read - This is only found in the read field.
  • w = write - This is only found in the write field.
  • x = execute - This is only found in the execute field.
  • s = setuid - This is only found in the execute field.
  • If there is a "-" in a particular location, there is no permission. This may be found in any field whether read, write, or execute field.

Examples

Type "ls -l" and a listing like the following is displayed:
total 10
drwxrwxrwx 4 rajat team 122 Dec 12 18:02 Projects
-rw-rw-rw- 1 rajat team 1873 Aug 23 08:34 test
-rw-rw-rw- 1 rajat team 1234 Sep 12 11:13 datafile
Which means the following:
Type and
# of Files's File's Size in Date of last Filename
Permission field
Links
Owner
Group
Bytes
modification
|
|
|
|
|
|
|
drwxrwxrwx
4
rajat
team
122
Dec 12 18:02
Projects
The fields are as follows:
  1. Type field: The first character in the field indicates a file type of one of the following:
    • d = directory
    • l = symbolic link
    • s = socket
    • p = named pipe
    • - = regular file
    • c= character (unbuffered) device file special
    • b=block (buffered) device file special
  2. Permissions are explained above.
  3. Links: The number of directory entries that refer to the file. In our example, there are four.
  4. The file's owner in our example is rajat.
  5. The group the file belongs to. In our example, the group is team.
  6. The size of the file in bytes
  7. The last modification date. If the file is recent, the date and time is shown. If the file is not in the current year, the year is shown rather than time.
  8. The name of the file.

Set User Identification Attribute

The file permissions bits include an execute permission bit for file owner, group and other. When the execute bit for the owner is set to "s" the set user ID bit is set. This causes any persons or processes that run the file to have access to system resources as though they are the owner of the file. When the execute bit for the group is set to "s", the set group ID bit is set and the user running the program is given access based on access permission for the group the file belongs to. The following command:
chmod +s myfile
sets the user ID bit on the file "myfile". The command:
chmod g+s myfile
sets the group ID bit on the file "myfile".
The listing below shows a listing of two files that have the group or user ID bit set.
-rws--x--x   1 root    root    14024 Sep  9 2010 donefile
-rwxr-sr-x   1 root   mail    12072 Aug 16 2010 lockfile
The files donefile and lockfile are located in the directory "/usr/bin". The "s" takes the place of the normal location of the execute bit in the file listings above. This special permission mode has no meaning unless the file has execute permission set for either the group or other as well. This means that in the case of the lockfile, if the other users (world execute) bit is not set with permission to execute, then the user ID bit set would be meaningless since only that same group could run the program anyhow. In both files, everyone can execute the binary. The first program, when run is executed as though the program is the root user. The second program is run as though the group "mail" is the user's group.

For system security reasons it is not a good idea to set many program's set user or group ID bits any more than necessary, since this can allow an unauthorized user privileges in sensitive system areas. If the program has a flaw that allows the user to break out of the intended use of the program, then the system can be compromised.

Directory Permissions

There are two special bits in the permissions field of directories. They are:
  • s - Set group ID
  • t - Save text attribute (sticky bit) - The user may delete or modify only those files in the directory that they own or have write permission for.

Save text attribute

The /tmp directory is typically world-writable and looks like this in a listing:
drwxrwxrwt   13 root     root         4096 Apr 15 08:05 tmp
Everyone can read, write, and access the directory. The "t'' indicates that only the user (and root, of course) that created a file in this directory can delete that file.

To set the sticky bit in a directory, do the following:
chmod +t data
This option should be used carefully. A possible alternative to this is
  1. Create a directory in the user's home directory to which he or she can write temporary files.
  2. Set the TMPDIR environment variable using each user's login script.
  3. Programs using the tempnam(3) function will look for the TMPDIR variable and use it, instead of writing to the /tmp directory.

Directory Set Group ID

If the setgid bit on a directory entry is set, files in that directory will have the group ownership as the directory, instead of than the group of the user that created the file.

This attribute is helpful when several users need access to certain files. If the users work in a directory with the setgid attribute set then any files created in the directory by any of the users will have the permission of the group. For example, the administrator can create a group called sample and add the users Tom and Jerry to the group sample. The directory sampledir can be created with the set GID bit set and Tom and Jerry although in different primary groups can work in the directory and have full access to all files in that directory, but still not be able to access files in each other's primary group.

The following command will set the GID bit on a directory:
chmod g+s sampledir
The directory listing of the directory "sampledir":
drwxrwsr-x 2 Tom sample 1674 Sep 17 1999 sampledir
The "s'' in place of the execute bit in the group permissions causes all files written to the directory "sampledir" to belong to the group "sample" .

Examples

Below are examples of making changes to permissions:
chmod u+x myfile Gives the user execute permission on myfile.
chmod +x myfile Gives everyone execute permission on myfile.
chmod ugo+x myfile Same as the above command, but specifically specifies user, group and other.
chmod 400 myfile Gives the user read permission, and removes all other permission. These permissions are specified in octal, the first char is for the user, second for the group and the third is for other. The high bit (4) is for read access, the middle bit (2) os for write access, and the low bit (1) is for execute access.
chmod 764 myfile Gives user full access, group read and write access, and other read access.
chmod 751 myfile Gives user full access, group read and execute permission, and other, execute permission.
chmod +s myfile Set the setuid bit.
chmod go=rx myfile Remove read and execute permissions for the group and other.

Below are examples of making changes to owner and group:
chown Jerry test1 Changes the owner of the file test1 to the user Jerry.
chgrp Jerry test1 Changes the file test1 to belong to the group "jerry".
Note: Linux files were displayed with a default tab value of 8 in older Linux versions. That means that file names longer than 8 may not be displayed fully if you are using an old Linux distribution. There is an option associated with the ls command that solves this problem. It is "-T". Ex: "ls al -T 30" to make the tab length 30.

Umask Settings

The umask command is used to set and determine the default file creation permissions on the system. It is the octal complement of the desired file mode for the specific file type. Default permissions are:
  • 777 - Executable files
  • 666 - Text files
These defaults are set allowing all users to execute an executable file and not to execute a text file. The defaults allow all users can read and write the file.

The permission for the creation of new executable files is calculated by subtracting the umask value from the default permission value for the file type being created. An example for a text file is shown below with a umask value of 022:
        666 Default Permission for text file
       -022 Minus the umask value
      -----
        644 Allowed Permissions
Therefore the umask value is an expression of the permissions the user, group and world will not have as a default with regard to reading, writing, or executing the file. The umask value here means the group the file belongs to and users other than the owner will not be able to write to the file. In this case, when a new text file is created it will have a file permission value of 644, which means the owner can read and write the file, but members of the group the file belongs to, and all others can only read the file. A long directory listing of a file with these permissions set is shown below.
-rw-r--r--   1 root     workgrp          14233 Apr  24 10:32 textfile.txt
A example command to set the umask is:
umask 022
The most common umask setting is 022. The /etc/profile script is where the umask command is usually set for all users.

Red Hat Linux has a user and group ID creation scheme where there is a group for each user and only that user belongs to that group. If you use this scheme consistently you only need to use 002 for your umask value with normal users.