Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, April 25, 2011

Bad Address Syntax in Postfix

This summary is not available. Please click here to view the post.

Sunday, April 24, 2011

How to auto restart services when linux reboots

Use chkconfig command.

To list services:
chkconfig --list [service]

To add service:
chkconfig --add {service}

To remove service:
chkconfig --del {service}

To change level of service:
chkconfig [--level {level}] {service} {on|off|reset|resetpriorities}

Sendmail start-up error

Problem:
451 4.0.0 /etc/mail/sendmail.cf: line 91: fileclass: cannot open '/etc/mail/local-host-names': World writable directory
451 4.0.0 /etc/mail/sendmail.cf: line 588: fileclass: cannot open '/etc/mail/trusted-users': World writable directory


This means that somewhere between the path of "/" to "/etc/mail/" is a World writable directory or a 777. In my case it was "/etc".

Change the permission to 755:
[root@linux]# chmod 0755 /etc

Start sendmail:
[root@linux]# service sendmail start

Tuesday, March 25, 2008

Apache updating wrong log files

When renaming apache log files, restart apache server.

If apache is not restarted, there is a possibility that the old log file even though renamed/moved will still be updated because apache is still accessing its file descriptor.

Monday, July 10, 2006

Linux: Cron

Cron is the Linux equivalent of Window's Task Scheduler.

Jobs are executed from /etc/crontab

1. Create a PHP script file.

2. Edit the crontab

# crontab –e

This is the file syntax:

minutes hours day_of_month month day_of_week command

where:

minutes: 0-59
hours: 0-23
day_of_month: 1-31
month: 1-12
weekday: 0-6
command: Any shell command or web document

Wildcard: * (Allow any value)

I will use wget because PHP files need to be parsed by Apache, we need to execute it via wget command using the URL to the page. To check if your box has wget:

# wget --help

To run the script every Wednesday morning at 9:30 AM, the cronjob file will contain the following in single line:

30 9 * * 3 wget http://www.domain.com/file.php

Save the file and add to crontab

# crontab samplecronjob

Wednesday, June 28, 2006

Linux: Setting the Hostname

This is useful when your linux box is used for sending emails. If hostname is incorrect, it will be detected by http://cbl.abuseat.org and will be blocked from sending emails.

Example of a computer's hostname: mybox.mydomain.com

Replace example hostname to your computer's hostname.

In Linux, to check the hostname if it is similar to this example:

[root@mybox ~]# uname -n
mybox.mydomain.com
[root@mybox ~]# hostname -s
mybox
[root@mybox ~]# hostname -d
mydomain.com
[root@mybox ~]# hostname -f
mybox.mydomain.com
[root@mybox ~]# hostname
mybox.mydomain.com

If it returns localhost.localdomain then it's wrong. If not then your linux box is ok. (Very big hint for me was that before, the command prompt was [root@localhost ~]#)

For a static IP Address, /etc/hosts is configured as follows:
127.0.0.1 localhost.localdomain localhost
192.168.0.xxx mybox.mydomain.com mybox


Change 192.168.0.xxx to your static IP Address.

Set hostname:
[root@localhost ~]# hostname mybox.mydomain.com

Check /etc/sysconfig/network file. Must have be like this:
NETWORKING=yes
HOSTNAME="mybox.mydomain.com"

For further reference:
http://www.cpqlinux.com/hostname.html

* Using Fedora Core 3

Thursday, June 22, 2006

Linux: Accept Local SSH only

Linux Firewall must be running.

In /etc/sysconfig/iptables

find the following line

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

and change to

-A RH-Firewall-1-INPUT -s xxx.xxx.xxx.0/24 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

replace xxx.xxx.xxx.0 with local IP range.

restart firewall

[root@localhost ~]# service iptables restart

(Thanks to Sasi)

Thursday, May 04, 2006

Linux: Sendmail

Linux must have direct internet access.

Sendmail is located in /etc/mail
The editable configuration file is sendmail.mc.
The default settings are ok if you don't like to edit the file.
After editing, type the following command:
[root@localhost ~]# make -C /etc/mail

If sendmail-cf is not installed this will generate an error. So install sendmail-cf.
[root@localhost ~]# yum install sendmail-cf

After installation of sendmail-cf, make again. When OK, restart sendmail.
[root@localhost ~]# service sendmail restart

* Using Fedora Core 3