Finding out what is going on in your system

Boot

dmesg Log Boot Messages

Processor

cat /proc/version Version of the Linux kernel.
cat /proc/cpuinfo Information about the processor.
cat /proc/ioports Information about the i/o ports.
cat /proc/dma List of the used DMA-channels.
cat /proc/devices List of the importand driver.
cat /proc/interrupts Information about the interrupts.
cat /proc/pci List of the found devices on the PCI bus.
pciprobe PCI check.
cat /proc/stat List of general statistics of the system.

System

ps -auxw Current processes.
cat /proc/meminfo Information about memory.
cat /proc/loadavg Averages load of the system in the last minutes.
cat /proc/uptime Time and idle since the system start in seconds.
cat /proc/scsi/scsi Information about SCSI devices.
fdisk -l Display the detected partitions of hard disks.
lsmod Information about loaded modules. Modules extended the kernel.
cat /dev/sndstat Information about the sound device.
cat /etc/inittab Display the file /etc/inittab. This file contains the start procedures.
ls -R /bin /usr/bin Display the content of the directories /bin and /usr/bin. Here are the general Unix commands. ls -R display the sub directories too.

FileSystem

cat /proc/filesystems List of the supported filesystems.
mount Display the mounted file systems.
df Display the free space of the mounted file systems.

Network

ifconfig Display the network interfaces, for example loopback (lo), network cards (eth).
route -n Display every route
ipfwadm -l -I Display the incoming filter rules
ipfwadm -l -O Display the outgoing filter rules
ipfwadm -l -F Display the forwarding rules
ipfwadm -l -A Display the accounting rules
hostname Display the hostname
cat /etc/hosts Display the file /etc/hosts.
cat /etc/resolv.conf Display the file /etc/resolv.conf (Nameserver)
cat /etc/services Display the file /etc/services (Services).

Cleaning up (Redirecting) output

Sometimes you cannot see the information you want because of all the error messages swamping the screen, or you want to manipulate the output in some way. So what to do? The answer is to redirect the output away from the screen to either the bit bucket or a file.

In Linux, there are three standard devices for input and output – Standard Input (STDIN), Standard Output (STDOUT), and Standard Error (STDERR). These can be referred to as 0, 1 and 2 respectively, so to redirect the output for STDERR to /dev/null (the bit bucket) you would type 2>/dev/null at the end of your command line.

For example find / -name fred 2>/dev/null results in any errors being discarded, leaving you with the list of files called fred displayed on the screen.

If you wanted to, you could redirect the output for STDERR to the same place as STDOUT by typing 2>&1. Note the & – if you don’t put that there, then the output for STDERR would be redirected to a file called 1.  By default, if you don’t name or number your redirection explicitly, then you’re talking about STDOUT, so find / -name fred > somefile.txt redirects the output for STDOUT to somefile.txt

The final alternative is to redirect the output streams to different places. For example find / -name fred >foundfiles.txt 2>/dev/null would send the list of files called fred to foundfiles.txt while discarding any errors reported by find.

You can, of course, redirect the standard output to the bit bucket and keep the errors if that’s what you really want to do!

Reducing Spam

These are the recommendations that I have found elsewhere on the web

Adding the RBL

There appear to be three copies of sendmail.cf on a Westhost system. These are located at /usr/share/sendmail/sendmail.cf, /etc/sendmail.cf and /etc/mail/sendmail.cf.  However the first two are symbolic links – the one in /etc/mail is the one we are interested in. The file /etc/mail/sendmail.mc is a complete set of m4 macros needed to generate a fresh /etc/mail/sendmail.cf – backup your existing sendmail.cf file before making any changes! (Use the command cp -p to /etc/mail/sendmail.cf /etc/mail/sendmail.bak to preserve the modification date and ownerships).  Then open sendmail.mc in your favourite text editor and add this to the end of the file.


FEATURE(`dnsbl',`sbl-xbl.spamhaus.org',`"554 Rejected " $&{client_addr} " found in sbl-xbl.spamhaus.org"')dnl
FEATURE(`dnsbl',`bl.spamcop.net',`"554 Rejected " $&{client_addr} " found in bl.spamcop.net"')dnl
FEATURE(`dnsbl',`dnsbl.njabl.org',`"554 Rejected " $&{client_addr} " found in dnsbl.njabl.org"')dnl

You will also need to enable Delay_Check by removing the first dnl from


dnl FEATURE(delay_checks)dnl

so that it becomes


FEATURE(delay_checks)dnl

Anything to the right of dnl is a comment in sendmail.mc (BEWARE! Macros will be expanded so don’t include them). 

I have given three examples, however there are other lists which you could use.
Strictly speaking, only one list is required.  In fact more then one will cause a performance hit but will catch more spam so it is up to you as to what your needs are. You could even include more – MAPS maintains 3 different lists plus a fourth that includes all three but they now charge for access if your site is in any way commercial.

After adding those lines to your sendmail.mc file all you need to do is execute the following command from the /etc/mail dir.

m4 sendmail.mc > ./sendmail.cf

After running the m4 command restart your VPS and you are done. If you have set up your mail server to use sbl.spamhaus.org, you can test to see if the SBL blocking is working by sending an email (any email) to nelson-sbl-test@crynwr.com. (You must send the email from the mail server which you wish to test). The Crynwr system robot will answer you to tell you if your server is correctly blocking SBL-listed IPs or not. If you have done everything right then you will get the reply

Testing your SBL block. See http://www.crynwr.com/spam/ for more info.
Please note that this test will not tell you if your server is open for
relaying. Instead, it tests to see if your server blocks email from IP
addresses listed in various blocking lists; in this case, the SBL list.

Here’s how the conversation looked from sbl.crynwr.com.
Note that some sites don’t apply the SBL block to postmaster, so
I use your envelope sender as the To: address.

I connected to xxx.xxx.xxx.xxx and here’s the conversation I had:

220 yourdomain.com ESMTP Sendmail 8.11.6/8.11.6; Tue, 17 Oct 2006 05:23:36 -0600
helo sbl.crynwr.com
250 yourdomain.com Hello sbl.crynwr.com [192.203.178.107], pleased to meet you
mail from:<>
250 2.1.0 <>… Sender ok
rcpt to:
554 5.7.1 Rejected 192.203.178.107 found in sbl-xbl.spamhaus.org
Terminating conversation

You can always change the LogLevel in your sendmail.cf from 0 to 9 to help troubleshoot. This creates the log file /var/log/maillog. Remember to reset the LogLevel to 0 (zero) once you have fixed the problem

Setting up an EMail Auto Responder

There are two stages to setting up the autoresponder
1. Installation
- Log in to your site manager
- Click on Site Applications
- Click on Auto Responder 1.0 (First item under EMail)
- Accept terms and conditions
- Click on Finish

2. Configure on a per user basis
- Login to Site or User manager (mydomain.com/manager or mydomain.com/users)
- Click on EMail/FTP Management
- Click on Users (in left hand column) if using the Site Manager
- Click on the desired user name if using the Site Manager
- Click on EMail/FTP Management in the new window if using the Site Manager
- Click on AutoResponder in left hand column
- Click on Edit
- Ensure Auto Responder is enabled
- Enter a Subject and Message. The $ character is not allowed.
- Click on Finish

NOTE: The Auto responder will only reply once per email address it receives each day; some older installations will only reply once per email address. If you want to change this behaviour, you will have to edit the hidden file /etc/virt_users/username/.autoreplay.sh using your favourite editor.
To reply to every email, remove the line echo $SrcMailAdd >> $UserListFile (or just comment it out by putting a # at the start of the line)
To reply once per day, ensure that the definition for UserListFile is

  1. cur_date=`date +%d%m%y`
  2. UserListFile=$Directory"/.userslist"$cur_date

To disable the Autoresponder, clear the check box against “Enable Service”

Proxying Port 25

WARNING: Following this procedure will turn port 9925 into an open relay for your server and so is NOT recommended


Some ISPs block access to port 25 so that you have to send email using their SMTP server. This can be a real pain, so what do we do? The simple answer is to set up a proxy on your web server so that you access a different port. Your web server will forward the conversation to port 25. All we need is a piece of software to do this relaying. One is available from Gavin Stewart. Here is how to implement it so that you access your SMTP server via port 9925 instead of port 25.

  • Login to site using PuTTY
  • Create a directory to install to. I chose mkdir /var/www/myapps
  • Change to required directory (cd /var/www/myapps)
  • Download Gavin’s code (wget http://www.stewart.com.au/ip_relay/ip_relay-0.71.tgz)
  • Unzip the contents (gunzip -c ip_relay-0.71.tgz | tar -xv)
  • Edit the start up file (pico /etc/rc.d/inet.d/ip_relay)
  • Add line /usr/bin/perl /var/www/myapps/ip_relay-0.71/ip_relay.pl -d 9925:<yourdomain.com>:25
  • Exit editor (Control-X)
  • Create symlink (ln -s /etc/rc.d/init.d/ip_relay /etc/rc.d/rc2.d/S90ip_relay)
  • Change access rights for ip_relay (chmod 755 /etc/rc.d/init.d/ip_relay)
  • Restart rc daemon (restart). You should see something like

Killing mysqld with pid nnnnn
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
Resolving address (yourdomain.com)…..
…. determined as: xxx.xxx.xxx.xxx
Useing command line parameters:
local_port 9925
remote_addrs xxx.xxx.xxx.xxx
remote_port 25
bandwidth 0
forwarder 99 set.

ip_relay.pl Version: 0.71
Copyright (C) 1999,2000 Gavin Stewart

ip_relay 0.71 runs as a daemon and therefore allows restarting through the site manager.

All you now need to do is edit your Email client (Outlook, Thunderbird or whatever you use) to use port 9925 instead of 25. This is probably under advanced settings. If you want to check that this is working, just type telnet yourdomain.com 9925, in a command window on your pc. If you get connect failed, then you have made a mistake.