ABHIONLINUX
Site useful for linux administration and web hosting

2009/11/28

CPanel EXIM error – remote_smtp defer (111): Connection refused

On a cPanel dedicated server, exim was unable to deliver emails and all the emails were stuck in mail queue. Here what we found in the exim_mainlog

2009-03-22 03:46:04 H=localhost (Server-IP) [127.0.0.1] Warning:
Sender rate 0.0 / 1h
2009-03-22 03:46:04 1LlJJk-0003cX-HY <= test@somedomain.com H=localhost (Server-IP) [127.0.0.1] P=esmtpa A=fixed_login:test@somedomain.com S=798 id=1853.17.23.12.34.1237711564.squirrel@Server-IP
2009-03-22 03:46:07 1LlJJk-0003cX-HY alt3.gmail-smtp-in.l.google.com [209.85.218.31] Connection refused
2009-03-22 03:46:10 1LlJJk-0003cX-HY alt4.gmail-smtp-in.l.google.com [209.85.221.10] Connection refused
2009-03-22 03:46:10 1LlJJk-0003cX-HY == ourtestmail@gmail.com R=lookuphost T=remote_smtp defer (111): Connection refused

While troubleshooting the issue, we found the following:

root@server [~]# iptables -nL

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 0.0.0.0/0 127.0.0.1 tcp dpt:25
REJECT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:25
reject-with icmp-port-unreachable

You have to remove this two iptables rules.

root@server [~]# iptables -D OUTPUT 2
root@server [~]# iptables -D OUTPUT 1

You then have to save iptables and restart.

root@server [~]# /etc/init.d/iptables save
root@server [~]# /etc/init.d/iptables restart

Now, check your mails and you will see all the mails getting delivered.

MySQL Commands:

1.login mysql from GNU/Linux shell.
$mysql -h hostname -u root -p

2.Creating a database.
mysql> create database [Database_Name];

3.List all databases.
mysql> show databases;

4.List all the tables in a database.
mysql> show tables;

5.For Switching to a particular database.
mysql> use [Database_Name];

6.List database field formats in a table.
mysql> describe [Table_Name];

7.Delete a database.
mysql> drop database [Database_Name];

8.Delete a table.
mysql> drop table [Table_Name];

9.List all data in a table.
mysql> SELECT * FROM [Table_Name];

10. Show unique records.
SELECT DISTINCT [column name] FROM [table name];

11. Change a users password.(from unix shell).
mysqladmin -u root -h hostname.blah.org -p password 'new-password'

12. Change a users password.(from MySQL prompt).
SET PASSWORD FOR 'user'@'hostname' = PASSWORD('passwordhere');

13. Allow the user "sree" to connect to the server from localhost using the password "mypass"
grant usage on *.* to 'sree'@'localhost' identified by 'mypass';

14. Update database permissions/privilages.
FLUSH PRIVILEGES;

15. Dump all databases for backup. Backup file is sql commands to recreate all db's.
mysqldump -u root -p password --opt >/tmp/alldatabases.sql

16. Dump one database for backup.
mysqldump -u username -ppassword --databases databasename >/tmp/databasename.sql

17. Dump a table from a database.
mysqldump -c -u username -ppassword databasename tablename > /tmp/databasename.tablename.sql

18. Restore database (or database table) from backup.
mysql -u username -ppassword databasename < /tmp/databasename.sql

or

# mysql database_name < database.sql

Important Files and Commands in Linux

#
Used to make comments in a shell script or tells witch shell to use as an interpreter for the script.

.
Reads commands from a script and execute them in your current environment.

/etc/hosts
Configures names and aliases of IP-addresses. Fields should be separated with Tab or white space.

/etc/inittab
Controls process dispatching. Used by init.

/etc/lilo.conf
Is the configuration file used by the Linux Loader while booting.

/etc/modules.conf
Loads modules specific options at startup.

/etc/nologin
Is a text file that, if it exists in /etc/, will prevent non-root users from logging in. If a user attempts to login, it will be shown the contents of the file, and then be disconnected.

/etc/nsswitch.conf
Specifies how the lookup for different databases are performed and in what order. Lookups are done left to right.

/etc/printcap
Describes printers and allows dynamic addition and deletion of printers by the spooling system.

/etc/resolv.conf
Configures DNS name servers to use for hostname lookups.

/etc/sysconfig/network
Configures the system's network. Specifies hostname and gateway.

/etc/xinetd.conf
Contains the configuration for the extended internet services started by the xinetd command.

a2p
Transforms awk scripts to perl scripts, and shows the result on STDOUT.

ab
Benchmarks your Apache server by sending requests to it.

access
Checks whether if a file can be accessed. Exits successfully if the file can be accessed with the specified mode.

actctrl
Configures the IBM Active 2000 ISDN device driver and downloads firmware into the ISDN card.

addftinfo
Reads troff font file and adds font metric information that is used by the groff system.

addr
Shows information about network addresses. Will show you the hexadecimal format of the IP address.

addr2line
Shows file names and line numbers for a specified program addresses.

adsl-connect
Is a user-space PPPoE client. It manages an ADSL connection and reestablishes a dropped connection.

adsl-setup
Is a PPPoE client configuration script. It is used for the adsl-start, adsl-stop and adsl-connect scripts.

adsl-start
Starts the Roaring Penguin user-space PPPoE client.

adsl-status
Shows status of the PPPoE link that was established by the Roaring Penguin user-space PPPoE client.

adsl-stop
Stops the Roaring Penguin user-space PPPoE client.

afm2tfm
Used to convert an Adobe font metric file to TeX font metric format.

ali
Shows addresses for mail aliases.

alias
Creates an alias for a command. If options aren't specified it will show all aliases.

allneeded
Forces the calculation of all fonts that are needed to preview a set of dvi files.

alloc
Shows how much memory is used and free.

anacron
Runs commands periodically

answer
Is a utility that secretaries can use for easily creating emails while recieving a phone call.

apm
Shows power status and can configure the server in standby or suspend mode.

apmd
Is a monitor daemon and works together with the APM BIOS driver in the OS kernel.

apmsleep
Sets the computer in suspend or sleep mode.

appres
Shows how much resources are used by a specific application.

apropos
Shows all manual pages that contain the specified keywords, including the section number and a short description.

ar
Creates and updates library files. It combines files into a single archive file.

arch
Shows the hardware architecture of the current host.

arp
Shows and alters the ARP table which is used to map MAC addresses to their assigned IP addresses.

arping
Ppings the destination address using arp packets on the specified interface.

arpsnmp
Saves the Ethernet/IP address pairings. Logs the activity to syslog and sends a report of the changes by e-mail.

arpwatch
Saves the Ethernet/IP address pairs. Logs the activity to syslog and sends a report of the changes by e-mail

as
Is an assembler that will create object files using assembly language source files as input.

as86
Assembles code for the 8086 to 80386 processors.

ascii-xfr
Sends or receives files in ASCII mode.

ash, bsh
Is a shell similar to sh with similar features as system V shell.

askrunlevel
Allows selection of the operation mode at boot time.

aspell
Checks for misspelled words. It has filter for e-mail, sgml, and TeX.

aspell (2)
More options

at
Schedules commands to be executed at a later time.

atd
Runs jobs that are queued by at.

atq
Shows any queued at jobs for the current user or for a specified user.

atrm
Removes jobs from the at or batch queues.

atrun
Runs jobs that are queued by the at command to run later. It is used for backward compatibility.

authconfig
Configures /etc/sysconfig/network to support NIS.

autoexpect
Inspects your actions in a command and creates an expect script that recreates your interactions.

avmcapictrl
Configures active AVM ISA cards.

avmcapictrl(2)
Loads the firmware to an active AVM ISA card.

badblocks
Searches a device for bad blocks.

banner
Shows the specified strings in large letters on STDOUT.

basename
Removes the prefix and suffix from a string and shows the output to STDOUT.

bash, sh
Is a free version of Bourne-shell with many features from C- TC- and Korn shell.

bashbug
Creates and sends bug reports about the bash shell to the address specified.

batch
Executes commands at a future time when the system load level permits. The commands is read from STDIN.

bc
Reads a file or STDIN and uses a C-like arithmetic language. Acts as a pre-processor for the command dc.

bcc
It is the Bruce's C compiler. A simple C compile that use K&R C syntax.

bdftopcf
Compiles a font for the X server and the font server. It converts BDF-fonts into PCF-fonts.

[b]bg
Places the specified job in the background.

bind
Shows or binds key sequence to readline function or macro.

bindkey
Binds keys to an edit command. All bindings will be shown if no options is specified.

[b]bison
Generates a parser program for specified grammar file.

bltin
Runs the internal command in the shell.

break
Exits from a for, foreach, while, select or until loop.

builtin
Forces the use of a shell that builtin commands.

builtins
Shows all built-in commands in tcsh.

bunzip2
Decompresses bzip2 files.

burst
Allows a message to be split into several new messages.

bzcat
Decompresses a bzip2 file to STDOUT.

bzip2
Compresses, decompresses or tests bzip2 files.

bzip2recover
Recovers data from a damaged bzip2 compressed file.

c++
Is a complete compiler for C, C++, and assembler.

c++filt
Organizes the C++ symbols.

cal
Shows the calendar for a selected month in the year, or the entire year.

cancel
Terminates a printer job.

captoinfo
Searches file for termcap descriptions and shows the equivalent terminfo description with any comments.

cardctl
Administers and controls the state of PCMCIA sockets.

cardmgr
Manages and monitors PCMCIA card sockets and does automatic installation/uninstallation.

case
Matches each pattern successively against the word and run the commands when the first match is found.

cat
Shows files and can also combine several files into one file.

cc
Is the C and C++ Compiler for Linux. See gcc or g++ for complete information.

cd, chdir
Changes the working directory. If no directory is specified $HOME is used.

cdecl
Encodes or decodes C or C++ type declarations.

cdp, cdplay
Controls and plays audio CDs interactively or non interactively.

cdparanoia
Reads audio tracks from a CD-ROM drive that is CDDA compatible.

cdrecord
Records data or audio to a CD-ROM with the specified CD recorder.

cfdisk
Controls and alters partitions on hard disk drives by use of interactive menus.

chage
Alters or shows the user password expiry information for the specified user.

charset
Changes one of the two slots for character sets.

chat
Controls a conversation automatically between two computers over a modem connection.

chattr
Alters the file attributes on a Linux second extended file system.

checkalias
Shows information about mail aliases.

checkpc
Administers information about entries in the printcap database.

chfn
Changes your finger information.

chgrp
Sets or changes the group ID for the file or files specified.

chkconfig
Administers runlevel information for system services.

chkfontpath
Configures the directories in the X font server path.

chmod
Alters or assigns permissions to a file.

chown
Alters the ownership ID of files and also sets the group ID if it is specified.

chpasswd
Updates the passwords for a group of users with name and password pairs from STDIN.

chroot
Alters the root directory for a command.

chsh
Changes your login shell.

chvt
Changes foreground virtual screen.

ci
Stores revisions in the specified revision control system files.

cjpeg
Creates a JPEG/JFIF image from a specified image file or from STDIN.

cksum
Calculates the checksum (CRC) and number of octets for each input file.

clear
Clears the screen of all information if not disabled by your terminal environment.

clockdiff
Measures clock difference between computers with the resolution of 1 msec.

cmp
Compares two files of any type and shows the line number and byte where the files differ.

co
Checks out a revision from a RCS file and stores it in the corresponding working file.

codepage
Extracts code pages from a file.

col
Converts spaces to Tabs or Tabs to spaces in text files to create or modify columns.

colcrt
Removes underlines or shows them on new lines filtering the nroff file for a CRT preview.

colrm
Deletes selected columns from a file reading from STDIN to STDOUT.

column
Formats input into multiple columns.

combine
Combines images together with new image.

comm
Compares two files and shows you the unique and common lines from both files.

command
Executes the command and will disable lookup functions in the current shell. Can also give information on how the command will be interpreted by the shell.

comp
Creates a mail message with a preconfigured form.

compgen
Generates possible completion matches for the specified word according to the option.

complete
Declares how a command should be completed. Use the Tab key to perform the completion on the command line.

compress
Compresses the size of a file and replaces the old file with a new file with the extension .Z. The new file will inherit the same permissions and modification times from the original file

conflict
Reports conflicts between nmh and the mail transport system.

consolechars
Changes console screen font, screenfont map, and / or application-charset map.

consolehelper
Authenticates users via PAM and runs the program specified including any options the command may have.

consoletype
Shows the screen (console) type that is currently connected to STDIN.

continue
Doesn't run the remaining commands in the loop and continue to the next iteration. Can be used in the commands for, while, until, select and foreach.

convert
Converts image formats, colors, sizes, creates filter effects, rotations, sequences, and more.

cp
Copies files and directories to a new destination.

cpio
Copies files into and out of a cpio archive. It operates in three different modes.

cpp
Is a C language preprocessor that insert include files in the source code of the source file creating a single file.

cproto
Creates C function prototypes and converts function definitions.

createdb
Creates databases on a postgres server.

createlang
Adds new programming languages to the specified postgres database.

createuser
Creates users in a postgres database.

cron, crond
Starts the cron daemon used to execute commands at scheduled dates and times specified in the crontab file.

crontab
Views, creates, deletes, or edits the crontab file which contains a list of jobs including the time and date they will execute. If option isn't given read from STDIN.

csplit
Splits whole or parts of a file into new files.

ctags, etags
Inserts tags into programming source code files f that can act as markers making it easier to find section headings quickly and edit them using ex or vi.

ctrlaltdel
Sets the function of the Ctrl+Alt+Del buttons used when rebooting a computer.

cut
Selects fields or columns from a text file or a table and shows the result to STDOUT.

cvs
Is a version control and logging system for files or directory tree structures including any versionable files.

cvsbug
Sends a CVS problem report to a central support site that runs GNATS.

cytune
Configures the interruption threshold for the Cyclades driver.

date
Shows current date and time or sets the date and time on your computer.

dbmmanage
Manages DBM files with user names and passwords to authenticate HTTP users.

dc
Is a calculator that use reverse-polish notation. It use a stack to performs calculations.

dd
Copies and converts an input file to an output file.

ddate
Shows the date in the discordian date format.

deallocvt
Disconnects the specified virtual terminal or terminals.

debugfs
Debugs the ext2 file system specified.

depmod
Controls dependency descriptions for loadable kernel modules.

df
Shows used and free disk space for all file system or the one specified.

dga
Tests video modes for X-window by filling the screen with different colors each time a key is pressed.

dhcpcd
Manages requests for an IP address from a DHCP server.

dhcrelay
Forwards BOOTP and DHCP requests from one subnet to another subnet.

dialog
Shows boxes containing questions or messages from the shell.

diff
Compares two text files in every line.

diff3
Compares the difference between three files.

diffstat
Creates statistic histograms from diff output.

dig
Gathers information from the DNS servers in interactive or batch mode.

dip
Controls dial-up or dial-in PPP connections. It dials using a specified dial-up script.

diplogin
Specifies the user name to login to the dial-in server that exists in the file /etc/diphosts.

[b]dir
Shows files in the current directory or a specified directory.

dircolors
Shows or sets LS_COLORS environment variable.

dirname
Shows everything up to the last level of the given path name.

dirs
Shows the directory stack with the most recent one to the left.

dislocate
Disconnects a session without logging off to enable you to reconnect to the same session from another location.

disown
Removes the specified job from the active job list.

display
Shows images on the screen in X-window. Multiple images can be shown.

djpeg
Decompresses the JPEG file specified and creates an image file on the STDOUT.

dmesg
Examines and controls the kernel ring buffer

dnsdomainname
Shows the domain that you are in.

dnskeygen
Creates and maintains public, private, and shared secret keys for DNS servers.

dnsquery
Shows information about nameservers through BIND resolver library calls.

doexec
Runs a specified command showing it with another name passing the arguments provided.

domainname
Sets or shows the domain your system is configured for.

dosfsck, fsck.msdos
Checks a DOS file system; can also be used to fix damaged DOS file systems.

dp
Converts dates fitting the ARPA Internet standard (822 format).

dropdb
Removes a postgres database specified from the system.

droplang
Connects to a postgres database and removes a selected programming language.

dropuser
Connects to a postgres database and removes the specified user.

du
Shows disk usage for a directory and its subdirectories.

dump, rdump
Is a backup program that examines files in an ext2 file system and determines if the files need to be backed up.

dumpe2fs
Shows the super block and blocks group information of a file system present on a device.

dumpkeys
Shows the contents of the keyboard translation tables on STDOUT.

e2fsck, fsck.ext2
Checks Linux second extended file systems.

e2label
Shows or changes the label of an ext2 filesystem.

echo
Copies the written string to the screen. Exist as internal in all shells.

echotc
Exercises the terminal capabilities arguments.

ecpg
Is a preprocessor for embedded SQL code within C and Postgres programs.

ed
Is a line based editor. It is often used to edit files automatically in a script.

edquota
Manages user quotas for a ufs file system.

egrep
Shows lines form the file that matches the given pattern using full regular expressions.

eiconctrl
Configures active Eicon ISDN cards.

eject
Ejects floppies and CDs from their drives. Works for VM managed devices and devices without eject buttons.

elksemu
Emulates 8086 ELKS programs on an i386.

elm
Is an interactive mailer program that takes the place of mail and mailx.

elmalias
Shows information on specified elm aliases.

emacs
Edits text files, read and send mail, perform outline edits, compiles and run subshells.

enable
Enables or disables internal commands.

env
Alters the current environment and invokes a utility or shows the current environment.

eqn, geqn
Preprocesses files for troff which contain mathematics equations.

eval
Reads the argument as input to the shell and runs the resulting commands.

ex, e
Is a line base text editor. It is able to work on several files at the same time.

exec
Runs a command in place of the current shell. Usually another shell.

exit
Exits a shell or shell script with an exit status

expand
Replaces Tabs with spaces in text files. If no input files are specified STDIN will be used.

expect
Is used to automatically control interactive programs. It acts by reading commands from a file.

expectk
Is used to automatically control interactive programs. Is the same as expect, With Tk support.

export
Exports a shell variable to environment.

exportfs
Controls the exported file system table for NFS.

expr
Evaluates an expression and show the result to STDOUT.

extcompose
Creates a file containing a reference to external files on the computer.

factor
Finds the prime factor of a number. Also shows if the number is a prime factor.

faillog
Manages the summary of failures in /var/log/faillog.

false
Provides a false value in scripts, does nothing but always exits with a non zero-value.

fastmail
Sends e-mails fast in a batch to a large group of receivers.

fc
Reruns, edits or lists commands that have recently been used. With no options, edits and runs the last command.

fdformat
Formats new diskettes.

fdisk
Handles partiton tables. If no arguments is specified, an interactive prompt will be used.

fetchmail
Retrieves mail from POP, IMAP, or ETRN servers and forwards it to your local mail agent.

fg
Resumes the execution of a stopped job in the foreground. Without an argument the current job is used.

fgconsole
Shows you the number of the active virtual terminal.

fgrep
Shows lines form the file that matches the given pattern.

file
Performs tests on each file that you have specified to determine what file type it is.

filetest
Tests a file for different things.

find
Finds files in the specified directories and subdirectories using the Boolean expression from the input line.

findsmb
Shows information about computers on the network running MS Windows operating systems.

finger, safe_finger
Shows information about logged in users.

flex, flex++, lex
Creates a scanner program that recognizes lexical patterns in a text.

fmt
Is a text formatter. It will take the text from the file and produce output lines that are joined in the correct way.

fold
Breaks lines in text files to the specified width.

folder, folders
Shows the current folder and information about the messages in it.

for
Is used to go trough each word in the list, assign the value to variable and run the commands.

foreach
Is used to go trough each word in the list, assign the value to variable and run the commands.

fortune
Shows an interesting or funny phrase from various people randomly each time you execute it.

free
Shows the amount of free and used memory in the system.

fsck
Checks file systems for inconsistencies and repair them.

fsck.minix
Checks the minix file system for consistency.

fsinfo
Shows information including the capabilities about X font servers on the network.

fslsfonts
Shows the fonts on the font server that match the pattern specified. Wildcards (*) can be used.

fstobdf
Creates BDF fonts from an X font server. Debugs font and re-create BDF files.

ftl_check
Shows bookkeeping information for a Flash Translation Layer partition.

ftl_format
Formats a Flash Translation Layer partition on a flash memory device.

ftp
Transfers files from a remote network. It uses the File Transfer Protocol.

ftpcount
Shows current number of users using the FTP server.

ftprestart
Automatically restarts shutdown FTP servers.

ftpshut
Is an automatic shutdown procedure that notifies FTP users when the server is shutting down.

ftpwho
Shows information about the current processes for each FTP user.

function
Defines function in a shell.

funzip
Extracts the first file from a zip archive within a pipe to the standard, or specified, input.

fuser
Shows all processes that are using the specified files or file systems.

g++
Is the C++ compiler version of gcc. It assumes that the preprocessed files .i are in C++.

g77, f77
Is the GNU Fortran compiler. This can also be started using f77.

gawk, awk
Is a processing language from GNU built from awk and supports all of the options found in awk.

gcc
Is the GNU C/C++ compiler. It assumes that the preprocessed .i files are C based.

gdb
Is the GNU debugger program. This can start a specified program and modify its behavior.

gendiff
Generates a diff file that contains the differences between two directories.

genksyms
Creates a file with version information by first running gcc -E on it.

getconf
Retrieves current configuration values and show them to STDOUT.

getent
Retrieves entries using keywords that must already exist from a system configuration file.

getfilename
Uses a file in the specified format, then creates a copy of it using the specified file name.

getkeycodes
Shows kernel scan-code to key-code mapping table. Can be used to define functions of special keys.

getopt
Cleans up and checks options given to a shell script. It split option given together and place each option in its own variable. Any additional arguments is placed after --

getopts
Will retrieve or set environment options and process them from the command line. The values specified by name and the index of the next arguments are placed into the shell variable OPTIND.

gettext
Gets the domain name variable from a message object made by msgfmt.

gif2tiff
Creates a TIFF image file from a GIF image file.

glob
Performs file name expansion on the words. The result is separated by a NULL-character.

goto
Jumps to label in a shell script.

gpasswd
Administers the /etc/group and /etc/gshadow files.

gpg
Is the main security program for the GNUPG system and can check, sign, encrypt and decrypt.

gphoto
Administers picture handling with digital cameras. Can also be used with Web cameras and in scripts.

gpm
Enables the mouse in screen mode and sets various attributes such as baud rate and mouse type.

gpm-root
Allows Control-Mouse events to be able to draw menus during screen mode.

gprof
Shows an execution (call-graph) profile of a program. It can also create files containing portions of this information.

grep
Shows lines form the file that matches the given pattern.

grodvi
Is a groff driver that creates TeX dvi files that can then be printed out.

groff
Is the front end to the document formatting system used by groff.

grog
Guesses which groff option is required for printing a specific file and sends this answer to STDOUT..

grolj4
Is a groff driver that is used for creating output that can be printed onto an HP LaserJet 4 type printer.

grops
Translates GNU troff output into PostScript.

grotty
Translates GNU troff output into a simple printer format.

groupadd
Creates a new group definition on the system.

groupdel
Deletes a specified group definition in the system.

groupmod
Alter's a specific group definition on the system.

groups
Shows the groups that a user is a member of.

grpck
Checks the integrity of the /etc/group and /etc/gshadow files.

grpconv
Updates the /etc/gshadow if the /etc/group file has been changed manually.

grpunconv
Creates the /etc/group file from the /etc/gshadow file, then removes the /etc/gshadow file.

gs
Starts Ghostscript and reads Adobe Systems PostScript and PDF files.

gtbl
Compiles descriptions of any tables that are embedded inside troff files.

gunzip
Extracts files created by gzip, zip, compress or pack.

gv[/b]
Allows you to view PostScript and PDF documents.

gzexe
Compresses executable files into a self extracting archive.

gzip
Compresses files with Lempel Ziv-coding.

h2ph
Converts the specified C header files into Perl header file format.

h2xs
Creates Perl extensions from C header files.

halt
Writes any remaining data in memory to the disks and then stops the computer.

hash
Shows or changes information in the internal hash table that stores information about executed commands.

hashstat
Show information about how effective the internal hash table is.

hdparm
Sets or retrieves hard drive parameters.

head
Show lines from the beginning of each file on the screen.

help
Shows help information about internal commands.

hexdump
Dumps a file in hexadecimal format on the screen.

hisaxctrl
Setups the HiSax-ISDN device driver, if you are using the HiSax driver.

history
Shows a list of previously used commands, and can optionally execute them again.

host
Looks up hostnames or IP-addresses using name servers.

hostid
Shows na identifier for the current host in hexadecimal format.

hostname
Sets or shows the hostname for the computer.

hpftodit
Uses an HP tagged font metric file and creates a font file for use with groff -Tlj4.

htdigest
Manages HTTP user authentication files.

htpasswd
Manages HTTP user authentication.

httpd
Is the Apache internet Web server.

hup
Allows a command to catch a hangup signal. This is the opposite of nohup.

hwclock, clock
Shows and configures the hardware clock.

ibench
Shows how many connections the daemon can manage during a specified time. Will also identify users.

iceauth
Modifies or shows authorization information to connect with ICE.

id
Shows the userID and groupID of the user that you specify.

ident
Searches for RCS keyword strings in files.

if
Makes a decision inside a shell script. If the first expr is true run the first commands. If not check the next expr and so on. If no expr was true run commands after then.

ifcfg
Configures the Ethernet interfaces.

ifconfig
Configures network interface parameters or show the status for network interface.

ifdown
Deactivates a network interface.

ifport
Set or views the transceiver type for the network interface.

ifup
Activates a network interface.

ifuser
Shows whether any of the specified hosts are routed through the specified interface.

igawk
Adds the ability to have include files in gawk. It accepts all gawk options. Gawk also includes additional options from Bell Labs and GNU specific options.

imon
Monitors your ISDN activities.

imontty
Shows the status of all ISDN lines.

import
Captures some or all of an X server screen and saves it to a file.

in.fingerd, fingerd
Is the daemon the manages the finger protocol.

in.ftpd, ftpd
Is the Internet FTP daemon that manage FTP services. It is only started by the inetd daemon when requested.

in.identd, identd
Returns user information about the owner of a connection to a remote computer.

in.rexecd, rexecd
Is a daemon that services remote execution requests and uses use rname and password authentication. inetd will automatically start the daemon when needed.

in.rlogind, rlogind
Is the server for the rlogin command. The server looks at client's source port. If port is not in the range 0-1023, the server will abort the connection.

in.rshd, rshd
Is the server for rsh (remote shell) and allows clients to execute commands from remote clients. The server accepts connections from the client on any port lower the 1024.

in.telnetd, telnetd
Used to process incoming requests on the telnet port. Started by the Internet Server (inetd).

in.tftpd, tftpd
Is a server that gives you TFTP functionality, it uses the UDP protocol instead of TCP.

indent
Inserts or erases whitespace in C code to make it easier to read. Converts from one C style to another.

indxbib
Creates an index for a database file in inverted form. It can be read by the commands lookbib and refer. Is an executable in Linux, BSD and a script in AIX, Solaris.

info
Reads hypertext info nodes. Info nodes fill the same function on as man pages.

infocmp
Shows terminal information or compare descriptions between two or more terminals.

infotocap
Reads the specified file and converts found terminfo descriptions to termcap descriptions. The converted descriptions is shown on STDOUT.

init, telinit
Changes run levels for the system. Shuts down or restart the computer in different modes.

initdb
Creates a new Postgres database system.

initlocation
Creates another Postgres secondary database storage area.

initlog
Sends log messages to the system logging facility.

insmod
Installs loadable kernel modules (device drivers) in the running kernel.

install
Manages the installation of files to a specific location or creates directories in a file system.

install-info
Installs or erases menu entries in info directory files.

install-mh
Creates the initial setup for a first-time nmh user.

iostat
Shows input and output statistics for disks, terminals and tapes.

ipcalc
Calculates IP address information.

ipcclean
Cleans up shared memory and semaphores from aborted backends.

ipchains
Manages IP firewall rules in the Linux 2.2 kernel.

ipchains-restore
Restores IP firewall chains from STDIN.

ipchains-save
Shows the firewall chains on the screen.

ipcrm
Releases shared memory by removing identifiers from message queues, semaphores, and shared memory segments that programs or services have left behind.

ipcs
Shows information about inter-process communications currently active in the system, such as shared memory segments, semaphores and message queues.

ipppd
Is a modified pppd that provides synchronous PPP support for ISDN connections.

ipppstats
Shows PPP-related statistics.

iprofd
Creates the modem register of the ISDN-ttys AT-emulator permanent.

iptables[/b]
Manages IP firewall rules in the Linux 2.4 kernel.

iptunnel
Configures various types of IP tunnels.

ipx_cmd
Is a bridge between local IPX network and Novell's SCMD driver.

ipx_configure
Queries or configures IPX behavior with respect to automatic IPX interface detection.

ipx_interface
Manages IPX interfaces.

ipx_internal_net
Adds or removes the IPX internal network.

ipx_route
Adds or removes an IPX route.

isapnp
Reads the configuration file to configure ISA PnP cards.

isdnconf
Manipulates or reads ISDN phone number config files.

isdnctrl
Configures ISDN device information.

isdnlog
Shows decoded information from the ISDN card.

isdnrate
Shows telephone rates and various info from rate files.

isdnrep
Shows ISDN activity.

isoinfo
Does directory-like listings of iso9660 images.

isovfy
Checks an iso9660 image for errors.

ispell
Is a compatibility script for the aspell spell checker.

jobid
Shows the process id for the job or for the current job if not given.

jobs
jobs is used to report all jobs that are stopped or executing in the background.

join
Compares two files and joins them together where the fields are identical and show the result to STDOUT.

jpegtran
Converts JPEG from one compression to another.

kbdconfig
Configures the keyboard.

kbdrate
Changes keyboard configurations.

kbd_mode
Changes the keyboard translation mode. Useful when a program don't restore the translation mode.

kernelversion
Shows the major version of the kernel.

kibitz
Allows multiple interactions to one shell.

kill
Stops a process or sends a signal to a processes.

killall
Kills all processes running the specified commands.

killall5
Kills all processes but the ones in it's own session. Same as the System V killall command.

klogd
Is a daemon that is used to log kernel messages.

ksymoops
Decodes Linux kernel Oops.

ksyms
Shows kernel symbols that have been exported.

kudzu
Checks the hardware. If there are some changes in the system, it gives the opportunity to configure the hardware.

LANG=language
Change the regional setting and language translation.

last
Shows login information about users, hosts, and terminals.

lastb
Shows all bad login attempts.

lastlog
Shows the contents of the last login log. The information includes login name, port, and last login time.

lbxproxy
Is an X proxy that uses the low bandwidth extension to X (LBX). Some optimizations is made to the connections that increases speed over slow connections.

lc
Runs the last function specified by function or the last command entered

ld
Is a linker for object files used to link executables or shared libraries. Ld operates in two modes, static or dynamic.

ld86[/b]
Links object files produced by the as86 assembler into I&D executables.

ldconfig
It is used to configure run time bindings for the dynamic linker.

ldd
Shows a list of executable files and their dynamic dependencies or shared objects

less
Is a text pager for UNIX system, used to show ASCII files.

lesskey
Manages key bindings for less.

let
Performs arithmetic calculations using the arguments specified, can be used in advanced shell scripts.

let
Will evaluate the arguments and if the result is zero the exit status is 1 otherwise 0.

lex
Creates C programs to be used in lexical processing of character input. That can be used as an interface to yacc.

lilo
Allows you to have several operating systems installed and boot into any of them at startup.

limit
Set limitations on the system resources available to the current shell.

links
Is a simple command-line URL browser.

linuxconf
Is an interactive menu configuration program.

listalias
Shows user and system mail aliases in the system. This is one part of the elm mailer.

listres
Creates a list of widget's names and classes.

lkbib
Finds references in the bibliographic database that contain the specified keyword.

ln
Creates a link between the specified source and destination files.

lndir
Makes a shadow directory tree from fromdir with symbolic links.

loadkeys
Reads and modifies the keyboard translation tables.

local
Creates a local variable within a function and set variable's attribute.

locale
Shows locale-specific information.

localedef
Compiles or creates locale specifications.

lockfile
Creates semaphore files used to limit the access so that only one program is allowed to access the file or files.

logger
Adds messages to the system log from the command line.

login
Lets you sign on to the system.

logname
Shows your login name.

logout
Exits a login shell form in Bash, C, TC and Z-Shell (bash, csh, tcsh, zsh).

logresolve
Resolves IP addresses in Apache's access log files. This is to reduce the impact for the name server.

logrotate
Administrates log files by rotating, compressing, removing, and mailing the log files.

look
Will find words in the system dictionary and show all lines that begins with the specified string.

lookbib, glookbib
Finds references in a bibliographic database and recover records containing the keywords entered at the prompt.

loopctrl
Configures the isdnloop ISDN driver.

losetup
Administers and controls loop devices.

lp
Sends print request to a printer or printer queue.

lpbanner
Show a banner on a fixed-size font printer.

lpc
Used by the system administrator to control the operation of the line printer system.

lpd
Starts the printer server.

lpf
Is used as a general printer filter. It is often used in the printcap file as a filter.

lpq
Shows the content of a print queue.

lpr
Sends print requests to a printer. Will use STDIN if no file is specified.

lpraccnt
Is a printer accounting program template. It opens a specified TCP port for to send information

lprm
Removes print requests from the print queue and report the file's name of removed request.

lpstat
Shows status information on a printer or printer queue.

lpunlock
Unlocks a printer that is waiting for lock.

ls
Lists the contents of a specified directory and supports wildcards.

ls-F
Lists files like ls -F. It's much faster than ls.

lsattr
Shows the file attributes on a Linux second extended file system.

lsmod
Shows information about the loaded modules.

lsof
Shows a listing of open files.

lspci
Shows information about all PCI buses in the system and all devices connected to them.

ltrace
Traces library calls of a given program.

lynx
Is a fully featured, text only WWW browser. Shows HTML documents with links to files on the local system and for remote hosts running HTTP, FTP, NNTP, WAIS, and Gopher.

m4
Is a front end macro processor that is used for programming languages like C and assembler.

mail, Mail, mailx
Reads and sends mail.

mailq
Shows the mail queue. Shows first line for each mail massage, host for the massage, size the date and time.

mailstats
Shows the statistics collected by the program sendmail.

mailto
Sends multimedia mail in MIME format. It can only be used to send mail.

make, gmake
Updates a target file and all of its dependencies or repairs missing or invalid target dependency trees.

makedbm
Creates a DBM file or converts a DBM file to a text file.

makedepend
Reads each specified source file in the given sequence and then parses it.

MAKEDEV
Creates device entries in the /dev directory.

makeg
Makes an executable file that can be used for debug operations.

makeinfo
Converts Texinfo files to plain text, HTML or info files for online reading.

makemap
Uses the keyed map lookups in sendmail and creates the database map by reading from STDIN.

makepsres
Creates an PostScript language database file that contains the resources in the specified path names.

makestrs
Creates string table C source files and headers and outputs them on STDOUT.

makewhatis
Updates the whatis database.

make_smbcodepage
Creates a codepage for use with Samba.

man
Shows the manual page of the specified command.

man2html
Converts manual pages to HTML format.

manpath
Shows search paths for man pages.

mattrib
Changes file attributes for MS-DOS files

mbadblocks
Tests a floppy disk for bad blocks and marks them in the file allocation table.

mc
Is a file manager used to browse directories and files.

mcat
Copies a disk image to or from a floppy disk.

mcd
Changes directory in a MS-DOS directory structure.

mcedit
Edits file. It starts Midnight Commander (mc) in edit mode.

mcookie
Creates a magic cookie that works with the command xauth.

mcopy
Copies MS-DOS files to or from a UNIX system.

md5sum
Verifies MD5 checksums.

mdel
Deletes a file in an MSDOS file system..

mdeltree
Deletes a directory from an MSDOS file system.

mdir
Shows files in an MSDOS directory.

mdu
Shows disk usage for a specific file or files on an MS-DOS file system.

merge
Merges three files together. It merges the changes between input file 2 and 3 into input file number 1.

mesg
Allows or disallows messages to be sent to your terminal.

messages
Shows how many messages you have in your mailbox or folder.

metamail
Manages how to show mails that are non text-based.

metasend
Sends non text mails.

mformat
Formats MS-DOS floppy disks.

mhl
Shows and filters text messages in New Messages Handling System (NMH).

mhmail
Reads or sends mail.

mhpath
Shows pathnames to folders and mailboxes.

mikmod
Plays modules on a UNIX system.

mimencode
Converts or deconverts any standard mail-encoding formats defined by MIME.

mingetty
Is a smaller getty that works with virtual consoles.

minicom
Is a text-based window serial communication program.

mkbootdisk
Creates a boot floppy for the running system.

mkdep
Creates makefile dependency lines for a specified source file.

mkdir
Ccreates directories.

mkdirhier
Creates the specified directories including any unspecified parent directories as well.

mkdosfs, mkfs.msdos
Creates an MS-DOS file system in Linux.

mke2fs, mkfs.ext2
Creates a second extended file system.

mkfifo
Creates the FIFO special files specified by the paths and filenames on the command line.

mkfontdir
Creates an index file from any X font files found in a directory. It typically looks for .pcf, .snf and .bdf fonts and then creates the file fonts.dir in the same specified directory.

mkfs
Creates a Linux file system on the specified device.

mkfs.minix
Creates a minix file system.

mkinitrd
Create a ramdisk to preload modules to gain access to the root file system.

mkisofs
Creates an ISO9660, Joliet, or HFS file system that is used on CDs and handles Rock Ridge attributes.

mklost+found
Creates a lost+found directory.

mkmanifest
Creates a shell script that restores UNIX file names that has been shortened by MS-DOS file systems.

mknetid
Creates the NIS netid map called netid.byname using the contents of the hosts, passwd, group and netid files.

mknod
Creates a directory entry for a specified special file.

mkpasswd
Generates a new password and assigns it to a user if you specify one.

mkraid
Manages RAID arrays.

mkswap
Creates a swap area in Linux.

mktemp
Creates a temporary file name using another file name as a template.

mktexlsr
Manages ls-R databases.

mkxauth
Manages .Xauthority files.

mlabel
Creates a volume label on MS-DOS file systems.

mmd
Create directories on MS-DOS file systems.

mmount
Mounts a MS-DOS file system in Linux.

mmove
Moves files on MS-DOS file systems.

modinfo
Shows information about the specified kernel module.

modprobe
Probes for modules in Linux.

mogrify
Modifies images by scaling, rotating, twisting and cropping. It also converts image files.

more
Shows a textfile one page at a time. Continues reading files specified on the command line.

mount
Mounts a file system or shows a file system that is already mounted. The file system can be local or remote.

mountd, rpc.mountd
Answers file system mount requests and NFS access information checks.

mouseconfig
Manages mouse configuration.

mpage
Prints several pages on one sheet of paper. The input files can be either plain text or PostScript.

mpartition
Partitions an MS-DOS hard disk, to create an MS-DOS file system.

mpg123
Reads files or URLs and plays them on the audio device or outputs them to STDOUT.

mrd
Deletes an MS-DOS directory.

mren
Renames or moves MS-DOS files.

msgchk
Checks maildrops for new incoming mail messages.

msgfmt
Creates message object files from portable object files. It doesn't change the portable object files.

msh
Reads a usual mail message file or a message file compressed with packf.

mshowfat
Shows file allocation table entries for an MS-DOS file.

mt
Sends commands to a tape device.

mtools
Shows all the programs in the mtools package which are used for accessing DOS FAT volumes.

mtype
Shows the content of an MS-DOS file.

mutt
Manages mail boxes. Sends and reads e-mails.

mv
Moves or renames files and directories.

mzip
Sends commands to an Iomega ZIP drive.

named, in.named
Is the domain name server that answers DNS request and resolves host names and finds their assigned IP address.

named-xfer
Handles inbound zone transfer. Is used by named and should not be used directly.

namei
Shows which kind of file each part of a pathname is. Follows symbolic links until they stop in a proper file.

ncftp
Is a browser program for the Internet FTP service.

ncftpbatch
Processes FTP requests added by the ncftp program.

ncftpget
Transfers files from the command line or shell scripts instead of using interactive FTP programs.

ncftpls
Creates remote directories listings without using interactive FTP programs.

ncftpput
Transfers files from the command line or shell scripts instead of using interactive FTP programs.

ncopy
Copies files over the NetWare network.

ncpmount
Mounts volumes on a NetWare file server.

ncpumount
Unmounts a NetWare file system that was previously mounted with the ncpmount.

ndc
Administers and manages the operations of a name server.

neqn
Is a preprocessor for the command nroff and is used to help out in equations.

netconf
Is an interactive user interface that allows configuration of a TCP/IP network.

netconfig
Configures the network on the command line or in interactive mode.

netreport
Requests network management scripts send a SIGIO signal when network interface changes occur.

netscape
Is a graphic based web browser.

netstat
Shows statistics and other network information, based on options selected.

newalias
Installs new elm aliases for system and/or user.

newaliases
Rebuilds the mail aliases file.

newer
Compares modification times of two files and exits successfully if file1 is at least as old as file2.

newgrp
Changes a user's real and effective group ID to the specified group.

newusers
Updates and creates new users in batch. User information is taken from the specified file.

nfsd, rpc.nfsd
Manages NFS file system requests for clients.

nfsstat
Shows NFS and RPC statistics.

nhfsstone
Benchmarks Network File System (NFS).

nice
Starts commands to be run in a different priority.

nisdomainname
Shows or sets system's NIS domain name.

nl
Reads lines from STDIN or a file, adds line numbers, and shows the result to STDOUT.

nm
Shows a table of the symbol names used for the specified ELF object file.

nmbd
Is a server that replies to NetBIOS over IP name service requests from a Windows client.

nmblookup
Requests NetBIOS names and maps them to IP addresses.

nohup
Is a way to run a command which will be immune to any hang up signals.

notify
Will notify a user asynchronous when the status of a job is changed. If job is not given, the current job is used.

nprint
Prints files to print queues located on a NetWare file server.

nroff
Processes a text file and formats the output for use with a letter quality printer or line printer.

nsend
Sends messages to NetWare users or user groups.

nslookup
Contacts and sends queries to DNS servers interactively or non-interactively.

nsupdate
Updates DNS name servers interactively or non-interactively.

ntsysv
Configures run levels to set what services that should be started or stopped.

nwauth
Logs into a NetWare server. If no arguments are given, the user's .nvclient file is used.

nwbocreate
Creates a NetWare bindery object.

How to set php safe_mode for a particular domain.

safe_mode is a feature of php. It is always prefferable to keep it ON due to security resaons. But for the working of some scripts it need to be turned off , in that case also dont turn it off server wide as it is a potential vulnerability.

How to turn off safe_mode for a particular domain.
---------------------------------------------------------

First thing we need to check is whether php is compiled as modular or cgi
If modular then we can do it via .htaccess in his public_html
If cgi then we can do it via php.ini in his publichtml

Via .htaccess
---------------

Add the following line


php_value safe_mode 0ff

or

php_flag safe_mode Off

If it is php 5 then add it inside the if module like


php_flag safe_mode off


via php.ini
------------

Just make a file called php.ini in his public_html then just add the line

safe_mode Off

Via hhtpd.conf
----------------

Add the following line and use ifmodule if needed

php_admin_flag safe_mode Off

2009/11/24

How to set quota on /tmp/eaccelerator

You may have tmpwatch on your system. The cron for that is run daily:

vi /etc/cron.daily/tmpwatch

In there, you can set the max amount of hours for keeping an old file. Lowering this, will clear out all your old cache files.

Another way, is to run a command like below in the tmp folder:

find eaccelerator -mtime +30 -exec rm {} \;

It will clear out any eacceletator files older than 30 days. Use that command carefully though

---------------------------------

Then write yourself a script and run it hourly from cron.

#!shell
#
check disk usage of directory
if (usage > a number)
delete files
fi
------------------------------
tmpwatch --mtime --all 336 /tmp/eaccelerator

What is eAccelerator?

eAccelerator is a further development from mmcache PHP Accelerator & Encoder. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated.

Installing eAcceleration in Debian

First you need to download php4-dev package which we need to compile eAccelerator

#apt-get install php4-dev

Download eAccelerator source package from here to /root folder and extract it

#tar jxvf eaccelerator-0.9.4.tar.bz2

#cd eaccelerator-0.9.4

Running phpize creates config file which is needed in make.

#/usr/bin/phpize

#./configure --enable-eaccelerator=shared --with-php-config=/usr/bin/php-config

#make

#make install

After this installation completed.

Edit file /etc/php4/apache2/php.ini and add following lines:

extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

Create temporary folder to eAccelerator

#mkdir /tmp/eaccelerator

#chmod 0777 /tmp/eaccelerator

Restart apache and you're finished with the eAccelerator configuration

#/etc/init.d/apache2 restart

Testing Your installation

Create test.php file with following lines on it:



If you have eAccelerator info shown on that page, accelerator is working

Increasing the maximum file size phpMyAdmin

If the limitation you are running into is a limit on the size of file uploads on your system, you may be able to increase this limit. By default it's usually 2M or 8M. To increase it you need to change PHP settings. You can change these settings either system-wide (if you have permission) or locally. The settings to change (with their typical defaults are):

post_max_size = 8M
upload_max_filesize = 2M

You must ensure that post_max_size is the same or larger than upload_max_filesize.

* These settings can be changed globally by changing them in your php.ini file (its location varies depending on your system). After changing the settings, remember to restart your web server.

* You may be able to change these settings locally if you're using Apache by putting a ".htaccess" file in phpMyAdmin's directory. The contents of the file should be:

php_value post_max_size 20M
php_value upload_max_filesize 20M

Change '20M' to however large you want it to be. You shouldn't need to restart the web server for these changes to take effect, but if you start getting Internal Server Errors (500) then this probably means your host does not allow you to change these settings and you need to remove those settings.


//For kloxo: php.ini location for phpmyadmin is
/usr/local/lxlabs/ext/php/etc/php.ini

2009/11/23

Core files in Linux

A core file created when ever a program terminates unexpectedly and its also useful for determining what caused the termination. In many Linux server by default they do not produce core files when programs crash or terminates unexpectedly.

On most of the Linux server core file size limitation is set to 0.You can check the core file size limit set in server by using following command.

root@gunjan [~]# ulimit -c
1000000

In above command core file size limit is 1000000 if output occur empty then it means core file size limit haven’t set on server and you can set it as

root@gunjan [~]# ulimit -c 1000000

or

root@gunjan [~]# ulimit -c unlimited

If you want to test core file limit is working on your server or not? then run following command

kill -s SIGSEGV $$

This above command will crashes your shell and produces core file in the current directory. as core.*

If core file is taking lots of disk space on server and you want to disable it then follow the steps one by one.

root@gunjan [~]#which httpd

/usr/sbin/httpd

root@gunjan [~]#pico /usr/sbin/httpd

And following line in /usr/sbin/httpd

ulimit -c 0

And then restart the Apache server

2009/11/22

Make PHP to work in your HTML files with .htacess

By default most web servers across the internet are configured to treat as PHP files only files that end with .php. In case you need to have your HTML files parsed as PHP (e.g .html) or even if you want to take it further and make your PHP files look like ASP, you can do the following:

For web servers using PHP as apache module:

AddType application/x-httpd-php .html .htm

For web servers running PHP as CGI:

AddHandler application/x-httpd-php .html .htm

In case you wish to do the ASP mimick:

For PHP as module:

AddType application/x-httpd-php .asp

OR

For PHP as CGI:

AddHandler application/x-httpd-php .asp

2009/11/16

Installing nagios in the server

Installing Nagios:



1. Download tar ball from www.nagios.org extract it
2. Go to the extracted directory and give following commands:

# ./configure --prefix=/usr/local/nagios

# make all

##### create nagios user and group###

# groupadd nagios

# adduser -g nagios nagios

# passwd nagios -------> set passwd to nagios

##### Give following cmds ###

# make install

# make install-init

# make install-commandmode

# make install-config

3. Create dir nagios in your documentroot of http server. For example: your docroot
is /var/www/html then create diirectory

mkdir /var/www/html/nagios

4. Change owner and group to nagios:nagios

chown nagios:nagios

5. cp -ap /usr/local/nagios/share/* /var/www/html/nagios

6. Now check in your browser http://localhost/nagios

7. remove "sample" from filenames of all configuration files which are under /usr/local/nagios/etc/

8. open /usr/local/nagios/etc/cgi.cfg and replace following line

physical_html_path=/usr/local/nagios/share ----------> to -------->

physical_html_path=/var/www/html/nagios

use_authentication=1 -------> to ---------> use-authentication=0


9. mkdir /var/www/html/nagios/cgi-bin

10. chown nagios:nagios /var/www/html/nagios/cgi-bin

11. cp -ap /usr/local/nagios/sbin/* /var/www/html/nagios/cgi-bin

12. in httpd.conf add following line:

ScriptAlias /nagios/cgi-bin/ "/var/www/html/nagios/cgi-bin/" ------> PLEASE DO NOT
FORGET to GIVE "/" in the END.

13. Restart Apache

14. Start nagios deamon

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg ------> For testing conf

/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg -d &

15. Check nagios is started or not

ps -ef|grep nagios

16. Check again in your browser http://localhost/nagios and try clicking on different "menus in side
bar." It shuld show you some status.

17. Installing nagios plugins -->

18. untar nagios-plugins tarball.

19. go to that directory and execute following commands:

./configure --prefix=/usr/local/nagios/

make

make install

20. It will install nagios-plugins in following dir : /usr/local/nagios/libexec/

21. For refreshing nagios deamon:

killall -HUP /usr/local/nagios/bin/nagios

How to install FFMPEG in the server

Following are the steps to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source. It should work on most systems, however may need some tweaking from system to sytem.

cd /usr/local/src

Download source tarballs:

wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
wget http://www4.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2

Extract the tarballs:

tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
tar zxvf flvtool2_1.0.5_rc6.tgz
tar jxvf essential-20061022.tar.bz2
tar jxvf ffmpeg-php-0.5.0.tbz2
tar zxvf flvtool2_1.0.5_rc6.tgz


Make a directory to store all the codecs:

mkdir /usr/local/lib/codecs/


Install any necessary packages:

yum install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++ gcc4-gfortran
yum install subversion ruby ncurses-devel

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer
svn update
cd /usr/local/src

Copy codecs for mplayer:

mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/

If you are using secure tmp:

mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp

Installing Lame:

cd /usr/local/src/lame-3.97
./configure
make && make install

Installing Libogg:

cd /usr/local/src/libogg-1.1.3
./configure && make && make install

Installing libvorbis:

cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install

Installing flvtool2:

cd /usr/local/src/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install

cd /usr/local/src/mplayer
./configure && make && make install

Installing ffmpeg:

cd /usr/local/src/ffmpeg/
./configure --enable-libmp3lame --enable-libogg --enable-libvorbis --disable-mmx --enable-shared
make && make install

ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51

Installing ffmpeg-php:

cd /usr/local/src/ffmpeg-php-0.5.0/
phpize
./configure
make
make install

Note: Make sure this is the correct php.ini for this server.

echo 'extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so' >> /usr/local/Zend/etc/php.ini

Restart apache:

service httpd restart

You should be ready to go now!

Note: up2date can be used if you don't have yum installed.

Optimizing MySQL

Optimizing MySQL
mysql_fix_privilege_tables
mysqlcheck -o –all-databases

Open /etc/my.cnf
[mysqld]
max_connections=500
safe-show-database
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
key_buffer_size=256M
table_cache=150
thread_cache_size=200
datadir = /var/lib/mysql
socket = /var/lib/mysql/mysql.sock

[mysql.server]
user = mysql
basedir = /var/lib

[safe_mysqld]
err-log = /var/log/mysqld.log
pid-file = /var/run/mysqld/mysqld.pid

Below are notes on some of the important variables, I took down while tuning the config file.

1. QUERY CACHE
query_cache_size:
* MySQL 4 provides one feature that can prove very handy - a query cache. In a situation where the database has
to repeatedly run the same queries on the same data set, returning the same results each time, MySQL can cache the result
set, avoiding the overhead of running through the data over and over and is extremely helpful on busy servers.

query_cache_limit : a total size of memory that server utilizes for caching results of queries

query_cache_type : 0 - Off
1 - Cache all query results except for those that begin with SELECT SQL_NO_CACHE
2 - Cache results only for queries that begin with SELECT SQL_CACHE.

2. key_buffer_size:
* The value of key_buffer_size is the size of the buffer used with indexes. The larger the buffer, the faster
the SQL command will finish and a result will be returned. Ideally, it will be large enough to contain
all the indexes (the total size of all .MYI files on the server).
Using a value that is 25% of total memory on a machine that mainly runs MySQL is quite common.

The Key_reads/Key_read_requests ratio < 0.01
The Key_writes/Key_write_requests ratio ~ 1

SHOW STATUS;

3. LOG
log : Whether logging of all statements to the general query log is enabled. See Section 5.3.2, “The General Query Log”.
log_error : The location of the error log. This variable was added in MySQL 4.0.10.
log_slow_queries : Whether slow queries should be logged. “Slow” is determined by the value of the long_query_time
variable.

4. table_cache:
* The default is 64. Each time MySQL accesses a table, it places it in the cache. If the system accesses many
tables, it is faster to have these in the cache. MySQL, being multi-threaded, may be running many queries on the table at
one time, and each of these will open a table. Examine the value of open_tables at peak times. If you find it stays at the
same value as your table_cache value, and then the number of opened_tables starts rapidly increasing, you should increase
the table_cache if you have enough memory.

check for Open_tables
SHOW STATUS;

5. sort_buffer_size: Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster
ORDER BY or GROUP BY operations.

6. read_rnd_buffer_size:
* The read_rnd_buffer_size is used after a sort, when reading rows in sorted order. If you use many queries with
ORDER BY, upping this can improve performance. Remember that, unlike key_buffer_size and table_cache, this buffer is
allocated for each thread. This variable was renamed from record_rnd_buffer in MySQL 4.0.3. It defaults to the same size as
the read_buffer_size. A rule-of-thumb is to allocate 1KB for each 1MB of memory on the server, for example 1MB on a machine
with 1GB memory.

7. thread_cache_size:
* If you have a busy server that’s getting a lot of quick connections, set your thread cache high enough that the
Threads_created value in SHOW STATUS stops increasing. This should take some of the load off of the CPU.

8. tmp_table_size:
* “Created_tmp_disk_tables” are the number of implicit temporary tables on disk created while executing statements
and “created_tmp_tables” are memory-based. Obviously it is bad if you have to go to disk instead of memory all the time.

Increase the value of tmp_table_size if you do many advanced GROUP BY queries and you have lots of memory.
This variable does not apply to user-created MEMORY tables.

9. innodb_buffer_pool_size
While the key_buffer_size is the variable to target for MyISAM tables, for InnoDB tables, it is innodb_buffer_pool_size.
Again, you want this as high as possible to minimize slow disk usage. On a dedicated MySQL server running InnoDB tables,
you can set this up to 80% of the total available memory.

10. innodb_additional_mem_pool_size
This variable stores the internal data structure. Make sure it is big enough to store data about all your InnoDB tables
(you will see warnings in the error log if the server is using OS memory instead).

11. max_connections

12. wait_timeout=500
This variable determines the timeout in seconds before mysql will dump a connection. If set to low
you will likely receive mySQL server has gone away errors in your log, which in vBulletins case is quite common.

13. max_allowed_packet
The maximum size of one packet or any generated/intermediate string.
Again if set to low (the default is 8M) users will likely experience errors. 16M has always
worked fine for my production environments.

You can grab a mySQL performance script from the guys at hackmysql.com( http://hackmysql.com/mysqlreport ). I use it to
tell me how the database is performing under load. You can run this from any shell when you are loaded with traffic.
Nothing fancy but should give you an idea.

==================================
http://dev.mysql.com/doc/refman/4.1/en/server-system-variables.html
http://dev.mysql.com/doc/refman/4.1/en/server-status-variables.html

Mysql database connection testing

Please put the following code in a php file in the server and access it through a browser to view the result.

Change the username of database user from "root" to your "database-user", followed by the password of the database user from "testuser" to your "database-access-password".

If the connection was successful the page will display Success. Other wise it will display Could not select DB.

Code:

php
$con=mysql_connect("localhost","root","testuser") or die("Could not connect");
$db=mysql_select_db("test",$con) or die("Could not select DB");
echo "Success";

Reset password for mysql

Error:
--------------
connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
mysql has failed, please contact the sysadmin (result was "mysql has failed").

Please follow the steps to reseset password for mysql.

Try the below steps :-
1) Set the passwd for mysql in /root/.my.cnf
2) killall mysqld
3) Restart mysqld with the --skip-grant-tables option as below :-
/usr/bin/safe_mysqld --skip-grant-tables &
4) Connect to Mysql :- Just type 'mysql' at the prompt without those quotes.
5) Update passwd for root user with the below command :-
> update user set Password = Password('pass') where User ='root';
6) exit

How to create the MySQL database and CREATE and GRANT Privileges.

HOW TO CREATE THE MySQL DATABASE

This step is only necessary if you don't already have a database set-up . In the following examples, 'username' is an example MySQL user which has the CREATE and GRANT privileges. Use the appropriate user name for your system.

First, you must create a new database for your site (here, 'databasename' is the name of the new database):

mysqladmin -u username -p create databasename

MySQL will prompt for the 'username' database password and then create the initial database files. Next you must login and set the access database rights:

mysql -u username -p

Again, you will be asked for the 'username' database password. At the MySQL prompt, enter following command:

GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES
ON databasename.* TO 'username'@'localhost' IDENTIFIED BY 'password';

where

'databasename' is the name of your database
'username@localhost' is the username of your MySQL account
'password' is the password required for that username

Note: Unless your database user has all of the privileges listed above, you will not be able to run site on that database.

If successful, MySQL will reply with:

Query OK, 0 rows affected

To activate the new permissions, enter the following command:

FLUSH PRIVILEGES;

How to connect mysql from remote server

mysql -u root -p -h

where remote server = remote server ip address
To enable MySQL to listen to remote connections, you must find your my.cnf file.

find / -name 'my.cnf'

(the global 'my.cnf is' likely to be /etc but it may be found in other places)

Open the file, and put a # in front of skip-networking or bind-address=127.0.0.1

Example of end result:

1. skip-networking

or

1. bind-address = 127.0.0.1


Also check for any firewall stopping port 3306

Restart MySQL and everything should work fine.

Don't forget to grant users access from remote hosts.

How to install yum in fedora

Try the following steps,

wget http://linux.duke.edu/projects/yum/download/2.0/yum-2.0.7.tar.gz
tar -xvzf yum-2.0.7.tar.gz
cd yum-2.0.7

./configure
make
make install


MAKE SURE TO DOWNLOAD THE CORRECT YUM VERSION:

* yum 3.0.1 - Stable Release, Python 2.4+ and rpm 4.3+ systems only. Requires repomd repositories. Works under FC5, FC6 and rawhide.
* yum-metadata-parser 1.0.2 - C-based metadata parser to quickly parse xml metadata into sqlite databases.
* yum 2.6.X - Stable Release, Python 2.3+ and rpm 4.1.1+ systems requires repomd repositories: 2.6.1 latest known to work with some FC3, FC4, FC5, RHEL4 and compatible distributions
* yum 2.4.X - Stable Release, Python 2.3+ and rpm 4.1.1+ systems requires repomd repositories: 2.4.2 latest known to work with: FC3, FC4, RHEL4 and compatible distributions
* yum 2.0.X - for python 2.1+ and rpm 4.1.1-4.3.1 systems: 2.0.8 latest
* yum 1.0.X - for python 1.5.2+ and rpm 4.0.4 systems: 1.0.3 latest - considered obsolete

if you are not sure what version of python you have installed, send the following command to see your installed phython version:

python

2009/11/14

How to add apache status in http.conf

Include this in httpd.conf


SetHandler server-status
Order deny,allow
Deny from all
Allow from 127.0.0.1


then check command:
lynx http://localhost//whm-server-status
lynx http://localhost//whm-server-status grep uptime to see the apache uptime

How to open ports using iptables

# iptables -I INPUT -p tcp --dport 32 -j ACCEPT

To open a range of ports

iptables -A INPUT -p tcp --destination-port 6881:6999 -j ACCEPT
iptables -A OUTPUT -p tcp --source-port 6881:6999 -j ACCEPT

2009/11/12

phpmail()

$to = "test@test.com";
$from = "stest@test.com";
$sub = "Test Email";
$msg = "Please ignore this";
mail($to, $sub, $msg, "From: $from");


php
$to = "test@test.com";
$subject = "test mail from support";
$body = "Please ignroe this mail";
if (mail($to, $subject, $body)) {
echo("


Message successfully sent!

");
} else {
echo("

Message delivery failed...

");
}

How to get custom php.ini working on php-cgi

1, Copy the servers default php.ini to your home directory

2, Make the following directory in home and chown to user:user
cgi-bin

3, Create a file php.cgi in cgi-bin with the following content
#!/bin/sh
exec /usr/local/cpanel/cgi-sys/php5 -c /home/user/public_html/

4, Chmod +x php.cgi and chown the file to user:user.

5, Add the following in the .htaccess.

Action application/x-httpd-php5 /cgi-bin/php.cgi

2009/11/01

Linux Interview Questions

How to change the modification time of a file use the following command:
touch -m

What is the default link count for files and directories in Linux?
The default link count:
files - 1
directory - 2

How to find only the number of lines in a files?
$ cat > f1

$ wc -l f1
4 f1

What is the difference between echo "$SHELL" and echo '$SHELL'?

$ echo "$SHELL"
/bin/bash


Code:
$ echo '$SHELL'
$SHELL

To check/list the attribute set for a file use the " lsattr " command.
# chattr +i my-file
# lsattr my-file
----i-------- my-file

How to set an append only attribute to a file in linux?
#chattr +a

How to lock the password for a user in linux?
# passwd -l
Password changed.


How to check the kernel version in linux?
$ uname -r
2.6.27-7-generic


How to check the used and free memory in linux?
$ free -m
total used free shared buffers cached
Mem: 1769 757 1011 0 20 302
-/+ buffers/cache: 434 1334
Swap: 7632 0 7632

How to set an immutable attribute to a file in linux?
#chattr +i

How to compare 2 files in linux?
Code:
#cmp

The -l option gives the detailed list of byte number.
Code:
#cmp -l


How to sort a file?
The command "sort" is used for alphabetically or numerically sort a file.

For eg: see the content of the file test
$ cat test
z
a
w
l
c

Inorder to sort the file we can use he sort command

$ sort test
a
c
l
w
z

One more ex: for a file containing numbers:

$ cat num
9
3
6
4

$ sort num
3
4
6
9
_________________



How to read the contents of a zip file without unzipping it?

Code:
zcat < file.gz >


How to suspend a running job and place it in the background?

Key combination " ctrl + z " will suspend a job and put it in the background.

Code:
ctrl+z


How to determine which shell you are using?

The name and path to the shell you are using is saved to the SHELL environment variable. You can then use the echo command to print out the value of any variable by preceding the variable's name with $. Therefore, typing echo $SHELL will display the name of your shell.

Code:
echo $SHELL


What are the process states in Linux?

As a process executes it changes state according to its circumstances.
Linux processes have the following states:

Running : The process is either running or it is ready to run .
Waiting : The process is waiting for an event or for a resource.
Stopped : The process has been stopped, usually by receiving a signal.
Zombie : The process is dead but have not been removed from the process table.



Which command is used to check and repair the file system?

fsck is used to check the file system and repair damaged files.

Code:
# /etc/fsck /dev/file-system



What is LILO?

LILO - Linux Loader

Definition:
The first- and second-stage boot loaders combined are called Linux Loader (LILO). It loads the kernel into the memory and helps the system to boot.


What is a PID?

PID - Process Indentification number

Definition:
It is a number used by Unix/Linux kernels to identify a process.

Use ps command to see PID.


What is a zombie process?

Zombies are dead processes. You cannot kill the Zombie process as they are already dead. A process state becomes zombie when the child process dies before the parent process. The only way to remove all the zombie process is by killing its parent process.


How to list/display the last 5 lines of a file " myfile.txt "?

Lets create a file " myfile.txt "

Example:
Code:
:~/test$ cat > myfile.txt
1
2
3
4
5
6
7
8
9
Ctrl+d

To list the last 5 lines, use the following command.
tail -5 myfile.txt

The tail utility displays the end of a file. The -5 option tells the tail command to display the last 5 lines.

Example:
Code:
:~/test$ tail -5 myfile.txt
5
6
7
8
9



How to delete a file which starts with " - "? Eg: -foo

Let try creating a new file " -foo ".

Example:
Code:
:~/test$ echo "Testing" > -foo
:~/test$ ls -l
-rw-r--r-- 1 telson telson 8 2009-05-21 22:28 -foo


In the above example we create a new file " -foo ".
Now lets try deleting it.

Code:
:~/test$ rm -foo
rm: invalid option -- 'o'
Try `rm --help' for more information.


It seems we are unable to remove the file " -foo ", with the above given command.

How to remove the file " -foo "?

There is 2 ways to remove this file.

rm ./-foo
rm -- -foo

You may use any of the above commands.

Example:
Code:
:~/test$ rm -- -foo
:~/test$ ls -l
total 0


What is the difference between Hard Link and Soft Link in Linux?

Hard Link is a mirror copy of the original file. Hard links share the same inode.
Any changes made to the original or Hard linked file will reflect the other.
Even if you delete any one of the files, nothing will happen to the other.
Hard links can't cross file systems.

Soft Link is a symbolic link to the original file. Soft Links will have a different Inode value.
A soft link points to the original file. If you delete the original file, the soft link fails. If you delete the soft link, nothing will happen.
Soft links can cross file systems.



What is the difference between Telnet and SSH?

Both Telnet and SSH is used for remote Log-In and to trasnfer data.

Telnet -> Telecommunication network
It is not secure and anyone can use it. It uses ASCII format.
Information sent and received can be easily read by anyone (Hackers) in that network.

SSH -> Secure Shell
It is highly secure.
Information passed accross the network is encrypted.
Hackers will not be able to read your data.

So its highly recommended to use SSH to transafer data's securly.



What is Raid? What are the different Raid types and different Raid Levels?

RAID stands for Redundant Array of Independent (or Inexpensive) Disks. It is a set of Technology standards to improve Performence and Fault tolerance.
There are two types of raid :
Software Raid
Hardware Raid

Hardware Raid is most commenly used.

Raid Levels:
Raid 0 - stripping
Raid 1 - Mirroring
Raid 2 - Stripping and Mirroring
Raid 3 - Officially Not Defined
Raid 4 - Striping with Differential Parity
Raid 5 - Striping with Distributional Parity
Raid 10 - A mix of RAID 1 and RAID 0