Newsletter: Credit repair organization act Interest only home equity loan Best consolidation loan student Credit card debt elimination Bank of america credit card services Credit repair yourself Union plus credit card Countrywide home loan customer service Credit card counseling services Credit card uk high risk Free payday loan Business card credit prepaid Trans union credit report agency No security deposit credit card Student loan for people with bad credit Bad credit gas card Texas construction home loan Canada consolidation debt loan loan student Canada payday loan online Second debt consolidation mortgage Credit repair form Bad credit equity loan Bad credit score Quick personal loan Free credit score online Credit card merchant account Credit rating uk Apply for capital one credit card Greendot prepaid credit card Direct merchant credit card bank na Guaranteed business credit card Letter to credit card company Calculator consolidation debt loan student Citibank student loan 1000 cash loan payday advance Christian consolidation debt services Shell gasoline credit card Card college credit debt in student Excessive credit card debt Maryland home improvement loan Loan nz personal Mortgage broker home loan refinance Bad credit payday loan Well fargo home equity loan Low interest rate credit card Credit free report state Guaranteed loan personal unsecured Self help credit repair Chase credit card and circuit city Credit repair information Card consolidate credit loan student Credit equifax from report Card compare credit from offer visa Michigan debt consolidation loan Credit card for people with no credit history Mortgage calculator home loan refinance Offshore credit card processing Online credit card processing service Credit repair law Unsecured personal loan with poor credit Phone credit card processing Cash loan payday Gasoline company credit card Arizona bad car credit loan Consumer report credit card Credit card terminal Instant payday loan Maryland debt consolidation Consumer coop credit union Card credit number online Credit repair agency Credit counseling seattle Credit experian report score Debt consolidation Countrywide equity home loan Equity florida home loan refinancing Advance bad cash credit loan Used credit card machine 0 apr card credit transfer Bakersfield california home loan Guaranteed no fax payday loan California home loan mortgage refinance Trans union credit report rating Qualify fha home loan Second mortgage versus home equity loan Washington mutual home loan center Guaranteed bad credit personal loan Ten dollar payday loan Credit card debt consolodation Advance cash loan payday software Bad credit loan mortgage refinancing Wal mart credit card canada Check credit score Bad credit government home loan Bad credit home improvement loan No teletrack check payday loan Report credit card fraud Free annual credit report government Credit repair services Loan payday quick Us bank credit card Manufactured home refinance loan Card credit payment process Best credit card for bad credit 0 percent apr credit card Home home improvement loan rate California home mortgage loan rate Credit card reward program Card counseling credit service Debt consolidation mortgage loan Bad credit personal signature loan Personal loan Credit card rate uk Instant bad credit loan Aspire credit card customer service Card credit hsbc nv Online debt consolidation 1000 advance loan payday Credit counseling services of alberta Card consolidation credit debt help Credit free jersey new report Private lender for personal loan Chase credit card customer service Government loan for first time home buyer First consumer debt consolidation Online credit card payment California home loan services Bad consolidation credit debt mortgage Home owner loan corporation Bad credit mortgage financing First horizon home loan Direct merchant bank credit card application Prepaid virtual credit card Bad credit credit card Instant credit card Payday loan application Credit card debt help Delaware debt consolidation Best debt consolidation loan Guaranteed loan personal Business card credit start up California home loan refinance Credit repair program Home loan owner personal secured Best card credit low rate Company credit card policy Card consolidation credit debt online South carolina bad credit mortgage Home loan mortgage refinance Bad credit loan mortgage Increase credit score Mortgage application bad credit Brunswick home loan new Free credit repair help Home equity loan interest rate Capital one student credit card Credit card for online shop Free credit report online free Student loan consolidation center Card credit offer unsecured Current home loan interest rate One hour payday loan Consumer credit law California christian debt consolidation Consolidation debt mortgage uk Best card consolidation credit deal Beneficial personal loan Free online credit card processing Country wide home loan Card credit fixed low rate Home equity loan lowest rate Card credit mbna payment Bad credit loan mortgage need 0 balance card credit student transfer Cheap payday loan Card credit online payment After bankruptcy home loan New hampshire home equity loan Alternative student loan for bad credit Guaranteed instant loan personal unsecured Bad card credit debt uk Instant credit repair Capital one credit card services Unsecured visa card bad credit Bad credit mortgage wisconsin Nevada bad credit mortgage 1st financial bank usa credit card Free credit card debt consolidation Home loan albany new york Card consolidation counseling credit debt Annual free credit report and score Low cost payday loan Construction financing home loan new Free credit counseling Credit information report Chase credit card offer Instant business credit card Credit counseling detroit Unsecured personal loan Refinance home equity loan Royal bank of scotland credit card Consolidations loan student Free bad credit personal loan Household credit card Free credit report credit card Guaranteed online personal loan Card chase credit disney visa Building business credit Check credit free report Auto bad bankruptcy credit loan Compare credit card reward Consolidation direct federal loan student Mortgage vs home equity loan Guaranteed personal loan Capital one credit card login Bad consolidation credit debt mortgage Best california equity home loan California equity home loan rate Credit card for people with bad Small business credit card processing Card card credit jc master penney reward Bad credit guaranteed home loan Bad debt consolidation loan Bad credit car loan new york Equifax credit rating Card counseling credit debt services Uk unsecured personal loan Apply bad canada card credit credit in Florida mortgage loan debt consolidation Sallie mae student loan services Bad credit high limit credit card Credit card free balance transfer Compare home loan mortgage new quote Credit counseling ontario Great lake loan student Credit repair guide American express small business credit card Well fargo secured credit card Business card compare credit offer small Fraud credit card company Free credit card processing Alaska home improvement loan National foundation for consumer credit Bad credit personal auto loan Good credit rating score Consolidation loan rate student Credit score interest rate Internet credit card fraud Credit repair software Household bank credit card Card credit machine nurit wireless Non profit debt consolidation loan Bad credit lender No limit credit card Credit score canada No credit check business loan Center loan national service student Credit card cash back offer Bryant card credit lane payment Card consolidation credit debt loan New york debt consolidation loan Bad bankruptcy credit home loan Lexington law credit repair Low interest business credit card Credit free massachusetts report Countrywide home loan servicing Secured credit card company Bad credit home loan va Providian visa credit card Business card consolidation credit debt California free credit report Bank federal home indianapolis loan Mbna secured credit card Consumer credit counseling of maryland Credit free report score Christian counseling credit family Credit card merchant online Carolina corporation loan south student Bad credit car loan canada No credit card needed Secret credit report repair Christian consolidation counseling credit debt Government debt consolidation Consolidation debt information Best rated credit card Fixed home equity loan American express credit card offer Bad credit home mortgage refinance Find best credit card rate Corp loan sc student Consolidation consumer credit Loan for non home owner Consolidation credit debt loan Consolidation debt loan online uk Credit counseling Annual credit report trans union Compare credit card company After bankruptcy equity home loan Bad card credit credit visa Balance card credit transfer uk Loan national student Instant credit card processing Faxless loan payday quick Business credit financing small Credit free online report totally Business accept credit card Bad credit home loan mortgage services Credit card consolidation best deal Credit score Best student credit card Bankruptcy credit repair Chase visa credit card Consumer counseling credit debt management Unsecured personal loan bank Cfs loan student Citibank credit card offer Business card credit gm Consolidation loan debt loan Fha va home loan Calculator loan student Texas va home loan Bad card credit master visa 0 interest credit card application Bank one credit card Federal home loan bank rate Accredited card credit secured Free lesbian porn no credit card No credit card web cam Capital one personal loan Credit card machine merchant account Equity home interest loan only Sunoco gas credit card Bank card credit secured us Credit card fraud protection Credit repair letter Card company consolidation credit Guaranteed payday loan 1000 loan payday Canada credit free online report Federal stafford student loan Cash back credit card application Instant payday loan completely online Online va home loan Corporation finance loan student Bad credit down home loan money no Texas credit repair Fixed rate home loan Bad card credit credit credit no Free credit repair Top debt consolidation loan Free music no credit card Bad credit credit card guaranteed approval where Calculator card credit payment Bank federal finance home loan office Credit card deal uk Free phone no credit card required Sears credit card canada Bad credit personal loan lender Article credit card debt Card credit fixed interest low rate Home improvement grants loan Credit credit free report score Credit line report Consolidation loan student travel Consolidation credit Personal finance loan Bad bankruptcy credit loan mortgage Consumer credit counseling agency Credit card debt management uk 3 bureau credit online report Card credit interest low rate Secured credit card Online gambling credit card Credit card balance transfer offer Consolidation debt defaulted loan student Shell credit card account Capital card com credit one Citibank student loan consolidation Bad credit mortgage virginia Credit card terminal repair Credit free ny report Juniper bank credit card Canadian credit report Apply for a business credit card Christian credit card counseling Georgia home improvement loan Loan for people with bad credit Instant credit card number Cell phone no credit card required Equity home loan mortgage refinance No credit check unsecured credit card Guaranteed credit card for bad credit Credit report trw experian Bad credit mortgage canada Accept credit card hardware Home equity loan orange county california Copy credit free report Credit card balance transfer uk Card chase commercial credit Business card company credit small Credit card debt management Consolidate credit card bill Business gas credit card Personal debt consolidation loan Free debt consolidation help Rid of credit card debt Online credit card service Personal credit report Federal government free credit report Company consolidation loan student Payday loan no faxing required Bad credit financing Chase credit card online banking Delaware debt consolidation loan Home loan for people with bad credit Payday advance loan illinois Credit debt help Hsbc credit card payment Citi financial credit card Com credit free report Chase credit card home Bad card credit gas people Buyer first home loan time How to read an experian credit report Card credit payment Government student loan consolidation Student loan debt consolidation calculator First horizon home loan corp Mobile credit card processing Free porn video no credit card needed Home loan mortgage refinance mortgage Free experian credit score Credit report help Providian credit card services Continental airline credit card Federal direct student loan program 3rd party credit card processing Credit government report Bad credit debt consolidation mortgage Free annual credit report law Fha home improvement loan Stop credit card offer Free debt consolidation company First time mortgage bad credit Debt management consolidation credit card Card credit unsecured visa Best home loan rate High school student credit card Bad credit home loan mortgage wisconsin Bank home equity loan rate North carolina debt consolidation Loan for bad credit rating Credit and debit card processing Federal home loan bank Clean credit report up Advance cash fast loan payday Wamu home loan Debt consolidation mortgage Credit card processing without a merchant account Guaranteed loan student texas Bad balance card credit credit transfer Free credit repair letter Bad credit fix Hawaiian airline credit card American express credit card company Free credit rating score Bad credit home mortgage lender Do it yourself credit repair kit Bad credit 2nd mortgage refinance Online credit card services Interest free credit card Moodys credit rating Gas credit card for bad credit Online instantly credit report free Credit card merchant Buy prepaid credit card Bad credit new car loan Citi credit card Government debt consolidation loan Michigan home equity loan Bad credit student personal loan Home equity loan tennessee Card chase credit na Credit report score Loan student subsidized Free credit bureau report Card college credit offer student Commerce bank credit card Free credit report and free credit score Babyphat prepaid credit card Free sex web cam with no credit card Citibank credit card login Business loan poor credit Debt management consolidation credit card 0 fixed apr credit card Credit score calculator Poor credit home improvement loan Advice consolidation loan student Free credit report check score online Debt consolidation defaulted student loan Low interest rate student credit card Cic credit report Bad credit loan credit card Consolidate government loan student Credit counseling of america Consolidate private student loan Mortgage with bad credit chicago Credit card processing low rate Credit card terminal system Accept business card credit small Credit equifax report Alternative loan student Debt consolidation counseling services Bad credit easy personnel loan Debt consolidation loan for home owner Uk credit card Bad college credit loan student Missouri payday loan Bad business card credit credit Loan mae salli student Cell phone no credit card Wachovia secured credit card Free credit report with 3 score Payday loan oregon Copy credit free instant report Bad credit loan uk Free download porn no credit card Home loan equity mortgage rate Buyer california first home loan time Partially secured credit card Tesco personal loan Bad credit houston mortgage texas Alberta loan student Consolidation credit debt repair Alaska airline credit card Free instant credit score Debt consolidation credit counseling Business credit card with no personal guarantee Direct loan student Free online debt consolidation Air card credit mile uk Best refinance home mortgage loan rate Online credit card processing Credit repair mortgage Compare business credit card Canada consolidation debt free Highest credit score Card credit credit free report without 125 home equity loan Bad construction credit home loan Best travel reward credit card Student loan consolidation rule Experian credit report bureau Consolidation debt free non profit Bad credit loan online personal Apply card credit egg uk Personal loan unsecured loan Best consolidation loan rate student Credit repair report service Completely credit free report Apply card credit virgin Secured debt consolidation Mortgage loan refinance and debt consolidation How to get a business credit card Credit history report online Auto bad credit loan military Consolidation debt loan personal unsecured Card credit payment processing Consolidation debt link suggest Card credit interest low uk Debt consolidation service uk Payday loan cash advance loan Prepaid credit card deal Canyon card christy credit free no video Consumer credit services Maryland debt consolidation loan Bad credit history credit card Credit report service Lower credit card debt Loan pay payday quick Credit free line report Home equity loan massachusetts Loan private student Credit equifax free report score Self credit repair 3bureau online credit report Credit debt management Bad card credit credit get unsecured Auto bad bankruptcy credit credit loan no Credit card counseling Merchant credit card processing 0 balance card credit life transfer American express black credit card Annual credit equifax report Instant approval credit card application

Linux technical support, Technical Blogs, Cheap dedicated server support, Cheap linux dedicated server support, Cheap windows dedicated server, Dedicated server support, Data center Operation, System Administration, Bash and perl scripts for server maintainance

Perl + regular expression and pattern matching

Pattern Matching and Regular Expressions

If you were paying attention, you noticed a huge loophole in the programs above: there’s nothing to prevent you from typing in a string variable when you’re supposed to be typing in a number. You can type in “dog” and “cat”, and the program will try to add “dog” and “cat” (which, if you’re curious, gives a result of zero.) You need some way to check to make sure that the person actually typed in numbers; then, if they didn’t, you can ask them again (with a looping control structure), until they get it right.

Welcome to the concepts of pattern matching and regular expressions, two of Perl’s powerful text-processing tools. Let’s start with a simple pattern first: one letter. If you want to test a variable to see if it contains the (lower-case) letter “z”, use this syntax:

if ($x =~ /z/) {
print “$x has a z in it!\n”;
}

Let’s take that apart: if is just like while, except it only checks once (that is, it won’t loop around again and again.) Like while, it will execute every command inside the curly brackets if the statement inside the parentheses is true.

The statement inside the parentheses works like this: =~ makes a comparison between $x and whatever’s inbetween the two slashes; in this case, if there’s a z anywhere inside $x, then the statement is true.

Let’s up the ante, and match only if $x begins with the letter z:

if ($x =~ /^z/) {
print “$x begins with a z!\n”;
}

^z is a regular expression; the carat (^) stands for the beginning of the string. Thus, the matching statement has to find a z immediately following the beginning of the string in order to be true.

How about words that begin with z and end with e? Use the regexp

/^z.*e$/

The $ stands for the end of the string; the period stands for “any character whatsoever”; combined with the asterisk, it means “zero or more characters.” Without the asterisk,

/^z.e$/

would mean “z followed by one character followed by e.”

There’s a lot of different regular expressions. For instance,

/^z.+e$/

means “z followed by at least one character, followed by e.”

/^z\w*e$/

means “z followed by zero or more word characters followed by e”–that is, “z!e” wouldn’t match.

So to make sure that somebody’s typing in numbers in our adding program, and not words, make the subroutine getnumber look like this:

sub getnumber {
$number = “blah”;
while($number =~ /\D/){
print “Enter a number “;
$number = <>;
chop($number);
}
$number;
}

“\D” is the regular expression for non-digits; if any character in $number is not 0-9, the expression won’t match, and you’ll get asked to enter a number again.

Note how we had to set $number to include a non-digit ($number = “blah”) to get inside the loop the first time around.

Perl File Handeling

Filehandles
You can write to a file as easily as you can write to the terminal. The first step (almost the only step) is to open the file with the open command. Here’s an example:

open(DOG,”>/home/scotty/data/dogs”);

DOG is the “filehandle”–the name by which you’ll refer to the open file from now on. It’s customary to use all caps for filehandles. The other thing inside the parens is the full pathname of the file; it’s prefixed with a > so you can write to it. (Without the > you could only read from it–we’ll talk about that in a second.)

Now to write a line of text to the file, just do it like this:

print DOG “This line goes into the
file and not to the screen.\n”;

Pretty easy, huh? I love Perl.

Since failure to successfully open a file can cause your program to go batty, it’s a good idea to have the program exit gracefully if it fails to open the file. To do that, use this syntax for the open command:

open(DOG,”>/home/scotty/data/dogs”)
|| die “Couldn’t open DOG.\n”;

Now it will either open the file, or quit the program with an explanation why.

To read from a file, open it without the >:

open(DOG,”/home/scotty/data/dogs”)
|| die “Couldn’t open DOG.\n”;

(If the file doesn’t exist, the program will quit.) Once the file is open, there are two common ways to get the information out. You can do it one line at a time, with lines like this:

$x = ;

That copies the first line from DOG (or the next line, if you’ve already taken some lines out) and assigns it to $x. The syntax is just like the <> we used earlier to get input from the keyboard; sticking DOG in there just tells Perl to get the input from the open file instead.

You can also do it in a loop. This program prints out all the contents of DOG:

#!/usr/bin/perl
open(DOG,”/home/scotty/data/dogs”) ||
die “Couldn’t open DOG.\n”;
while() {
print;
}

Notice how we didn’t specify a variable to store each line from DOG in, and we didn’t specify anything for the print command to print? This is a really important concept I should have introduced earlier: Perl features a default variable called $_. Basically, if you don’t specify which variable you want to use, or if you use a command like print by itself, Perl assumes you want to use $_.

Some other common commands that can assume you’re talking about $_:

s/dog/cat/g;

That’s a valid line all by itself; it means “substitute all occurences of ‘dog’ in the variable $_ with ‘cat’.” Another popular type of construction is

print if (/dog/);

That means “print $_ if $_ has ‘dog’ in it.”

$_ shows up everywhere in Perl, just to make your life easier. For instance, foreach will store its elements in $_ if you’re too lazy to name a variable yourself:

foreach (@array) {
print if (/Tonight/);
}

You can assign from $_ or manipulate it just like any other variable, with commands like

$_++;
$x = $_;

You just have to do it before the next time you overwrite $_ with a command like

–it’s a very temporary storage space.

When you’re done with a file, don’t forget to close it with the close command:

close(DOG);

Filename Globbing
Perl can read all the filenames in a directory (/home/scotty/bin in the following example) with this syntax:

while($x = ) {

}

One obvious and powerful use of this “filename globbing” is a loop like this:

while($x = ) {
open(FILE,”$x”) ||
die “Couldn’t open $x for reading.\n”;

}

Thus, the following simple program will print all lines containing the word “dog” (along with the names of the files they came from) in the /home/scotty/bin directory:

#!/usr/bin/perl
while($x = ) {
open(FILE,”$x”) || die “Couldn’t open $x for reading.\n”;
while(){
if(/dog/) {
print “$x: $_”;
}
}
}

Command and system information on different UNIX flavors (Solaris 8, HP-UX 10.x 11.x, FreeBSD, Linux, AIX)

Miscellaneous


System Administration Tools

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/ucb/whoami

/usr/bin/whoami

/usr/bin/whoami /usr/bin/whoami
/usr/bin/dos2unix /usr/bin/dos2ux cd /usr/ports/converters/unix2dos
/usr/bin/eject /usr/bin/tcio -r

/usr/bin/fdformat

/usr/bin/mediainit -f /usr/sbin/fdformat /usr/bin/fdformat
/usr/bin/makedev /usr/sbin/mknod /sbin/mknod /bin/mknod
/usr/bin/mpstat /opt/perf/bin/glance,

/opt/perf/bin/gpm
/usr/bin/pagesize /opt/perf/bin/glance,

/opt/perf/bin/gpm
/usr/bin/pagesize
/usr/bin/setfacl

/usr/bin/chacl

/usr/bin/showrev /usr/bin/uname -a

/usr/bin/tip

/usr/bin/cu
/usr/bin/unix2dos /usr/bin/ux2dos
/usr/sbin/add_drv /usr/sbin/mknod,

/usr/sbin/insf,

/usr/sbin/mksf
/usr/sbin/cfgadm

/usr/sbin/ioscan

/usr/sbin/devfsadm /usr/sbin/mknod,

/usr/sbin/insf,

/usr/sbin/mksf
/usr/sbin/dhcpconfig

/sbin/auto_parms

/usr/sbin/dhtadm /usr/sbin/dhcptools

/usr/sbin/disks

/usr/sbin/mknod,

/usr/sbin/insf,

/usr/sbin/mksf
/usr/sbin/fdisk /usr/sbin/lvlnboot,

/usr/sbin/lvcreate
/usr/sbin/growfs /usr/sbin/extendfs,

/usr/sbin/fsadm,

/usr/sbin/lvextend
/usr/sbin/installboot /usr/sbin/lvlnboot
/usr/sbin/metaparam

/usr/sbin/lvchange,

/usr/sbin/vgchange

/usr/sbin/metastat

/usr/sbin/lvdisplay,

/usr/sbin/pvdisplay,

/usr/sbin/vgdisplay
/usr/sbin/metasync /usr/sbin/lvsync,

/usr/sbin/vgsyncr
/usr/sbin/nslookup

/usr/bin/nslookup

/usr/sbin/nslookup /usr/bin/nslookup
/usr/sbin/poweroff /usr/sbin/shutdown /sbin/shutdown -h now shutdown -h now

/usr/sbin/prtconf

/usr/bin/getconf
/usr/sbin/prtconf | grep -i memory /usr/sbin/swapinfo
/usr/sbin/rem_drv /usr/sbin/rmsf
/usr/sbin/strace /usr/bin/strace /usr/bin/strace [!]
/usr/sbin/strclean

/usr/bin/strclean

/usr/sbin/strerr /usr/bin/strerr

/usr/sbin/sysdef

/usr/sbin/ioscan,

/usr/sbin/sysdef
lsdev
/usr/sbin/tapes

/usr/sbin/mknod,

/usr/sbin/insf,

/usr/sbin/mksf

/usr/ucb/fasthalt /usr/sbin/reboot -q,

/usr/sbin/shutdown

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/bin/admintool /usr/sbin/sam /stand/sysinstall /bin/linuxconf /usr/bin/smit (GUI),

/usr/bin/smitty

Disk Space and Information

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX

/usr/sbin/df

/usr/bin/df /bin/df /bin/df /usr/bin/df
/usr/sbin/df -k /usr/bin/bdf /bin/df /bin/df /usr/bin/df -k
/usr/sbin/mount,

umount
/sbin/mount,

umount
/sbin/mount,

umount

/bin/mount,

umount

/sbin/mount,

umount
/usr/sbin/devinfo /usr/sbin/diskinfo

/dev/rdsk/device_file
Kernel Configuration

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/etc/system /stand/system /usr/src/sys /usr/src/linux chdev -l sys0 -a
Processes

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/bin/ps -ef /usr/bin/ps -ef /bin/ps -axj /bin/ps -ef
/bin/truss tusc /usr/bin/truss /usr/bin/strace syscalls
/usr/bin/iostat /usr/bin/iostat /usr/sbin/iostat /usr/bin/iostat
/usr/ucb/users /usr/bin/users /usr/bin/users /usr/bin/users /usr/bin/users
/usr/bin/prstat /usr/bin/top /usr/bin/top /usr/bin/top /usr/bin/top
Physical Memory

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/sbin/dmesg | grep mem

/usr/sbin/prtconf | grep Memory

/etc/dmesg | grep -i phys /sbin/dmesg | grep “real mem” grep MemTotal /proc/meminfo bootinfo -r
Hardware Status/Information

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
dmesg dmesg dmesg dmesg errpt -a
/usr/bin/arch -k /usr/bin/model /bin/arch /usr/bin/uname -m /usr/bin/uname -m
“Unique” ID

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/sbin/dmesg | grep Ether /usr/sbin/lanscan
/usr/bin/hostid /usr/sbin/lanscan,

/usr/bin/uname -i
/usr/bin/hostid /usr/sbin/hostid
Swap

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/sbin/swap -a /usr/sbin/swapon -a /sbin/swapon -a /sbin/swapon -a swapon -a
/usr/sbin/swap -l /usr/sbin/swapinfo /usr/sbin/swapinfo /usr/bin/free lsps -a
vmstat vmstat vmstat vmstat vmstat
System Files

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/etc/rc#.d /sbin/rc#.d /etc/rc* /etc/rc#.d/
/etc/rc#.d /sbin/init.d /etc/init.d/
/etc/vfstab /etc/fstab /etc/fstab /etc/fstab /etc/filesystems
/etc/inet/hosts /etc/hosts /etc/hosts /etc/hosts
/etc/shadow /etc/passwd /etc/master.passwd /etc/shadow /etc/security/passwd

/etc/group

/etc/group,

/etc/logingroup
/etc/group /etc/group

/etc/format.dat

/etc/disktab /etc/disktab
The X Window System

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/openwin/bin/xterm /usr/bin/X11/xterm /usr/X11R6/bin/xterm /usr/X11R6/bin/xterm
/usr/openwin/bin/xhost /usr/bin/X11/xhost /usr/X11R6/bin/xhost /usr/X11R6/bin/xhost
Hostname

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/bin/hostname /usr/bin/hostname /bin/hostname /bin/hostname
/etc/inet/hosts /etc/hosts /etc/hosts /etc/hosts
/usr/bin/uname -a /usr/bin/uname -ae /usr/bin/uname -a /bin/uname -a
Networking

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/sbin/showmount /usr/sbin/showmount /usr/bin/showmount /sbin/showmount /usr/bin/showmount
/etc/dfs/dfstab /etc/exports /etc/exports /etc/exports /etc/exports
/usr/sbin/share /usr/sbin/exportfss
/usr/lib/netsvc/yp/ypbind /usr/lib/netsvc/yp/ypbind /usr/sbin/ypbind
/usr/sbin/route /usr/sbin/route /sbin/route /sbin/route /usr/sbin/route
/usr/sbin/in.routed /usr/sbin/gated /sbin/routed /usr/sbin/gated
/usr/bin/netstat /usr/bin/netstat /bin/netstat /usr/bin/netstat /usr/sbin/netstat
/usr/bin/rsh /usr/bin/remsh /usr/bin/rsh /usr/bin/rsh
Tape Copies

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/bin/cpio /usr/bin/cpio /usr/bin/cpio /bin/cpio
/usr/sbin/tar /usr/bin/tar /usr/bin/tar /bin/tar
tar cvf /dev/rmt/0m

tar cvf /dev/rmt/0m

tar cvf /dev/rmt/0m file tar cvf /dev/rmt/0m file
tar xvf /dev/rmt/0m tar xvf /dev/rmt/0m
Tape Devices

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/vol/dev/dsk/cXtXdX (CD-ROM) /dev/dsk/c0tXd0

(”X” is address)
/dev/rmt/0m (tape) /dev/rmt/0m
/usr/bin/eject /usr/bin/tcio -r
Software

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/usr/sbin/pkgadd /usr/sbin/swinstall /usr/sbin/pkg_add rpm -i[U]vh installp -a
/usr/sbin/pkginfo /usr/sbin/swlist /usr/sbin/pkg_info rpm -qa lslpp -L
/usr/sbin/pkgrm /usr/sbin/swremove /usr/sbin/pkg_delete rpm -e installp [-r|-u]
/usr/bin/showrev -p /usr/sbin/swlist | grep PH instfix -ia
/usr/sbin/patchadd /usr/sbin/swinstall instfix
/usr/sbin/patchrm /usr/sbin/swremove installp -r
/usr/sbin/pkgchk /usr/sbin/swverify lppchk
/usr/sbin/swmtool /usr/sbin/swinstall,

/usr/sbin/swremove
/usr/bin/pkgmk

/usr/sbin/swpackage

Daemons

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/bin/cron

/usr/bin/cron

/usr/sbin/cron /usr/sbin/cron
/usr/bin/atq /usr/bin/at -q /usr/bin/atq /usr/bin/atq
/usr/bin/atrm

/usr/bin/at -r

/usr/bin/atrm /usr/bin/atrm
Backup/Restore

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/sbin/ufsdump /usr/sbin/fbackup,

dump,

rdump
/sbin/dump backup
/usr/sbin/ufsrestore /usr/sbin/frecover,

restore,

rrestore

/sbin/restore restore
Core Files

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/bin/savecore

/sbin/savecrash

/sbin/savecore
/usr/sbin/crash /usr/sbin/crashutil
/usr/bin/coreadm /etc/rc.config.d/savecrash
Disk Formatting

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/sbin/format /usr/bin/mediainit /sbin/disklabel [?] /sbin/mke2fs [?]
Disk Partitioning

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/sbin/format /usr/sbin/pvcreate,

vgcreate,

lvcreate
/sbin/fdisk /sbin/fdisk
Disk Maintenance

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux
/usr/sbin/format /usr/sbin/pvremove,

vgremove, lvremove,

vgreduce, lvreduce,

vgextend, lvextend,

pvdisplay, vgdisplay,

lvdisplay

Printer/Plotter

Solaris 8 HP-UX 10.x 11.x FreeBSD Linux AIX
/etc/printers.conf

/usr/lib/lp/model

/usr/bin/lpstat /usr/bin/lpstat /usr/bin/lpstat
/usr/bin/lp /usr/bin/lp
/usr/bin/cancel /usr/bin/cancel qcan
/usr/spool/lp/model /usr/lib/lp/model

Important default port list

11/TCP,UDP SYSTAT protocol Official
13/TCP,UDP DAYTIME protocol (RFC 867) Official
15/TCP,UDP NETSTAT protocol Deprecated
20/TCP FTP—data Official
21/TCP FTP—control (command) Official
22/TCP,UDP Secure Shell (SSH)—used for secure logins, file transfers (scp, sftp) and port forwarding Official
23/TCP,UDP Telnet protocol—unencrypted text communications Official
25/TCP,UDP Simple Mail Transfer Protocol (SMTP)—used for e-mail routing between mail servers Official
43/TCP WHOIS protocol Official
53/TCP,UDP Domain Name System (DNS) Official
80/TCP Hypertext Transfer Protocol (HTTP) Official
110/TCP Post Office Protocol 3 (POP3) Official
143/TCP,UDP Internet Message Access Protocol (IMAP)—used for retrieving, organizing, and synchronizing e-mail messages Official
156/TCP,UDP SQL Service Official
443/TCP Hypertext Transfer Protocol over TLS/SSL (HTTPS)
465/TCP SMTP over SSL Unofficial
587/TCP e-mail message submission[10] (SMTP) Official
636/TCP,UDP Lightweight Directory Access Protocol over TLS/SSL (LDAPS) Official
694/UDP Linux-HA High availability Heartbeat Unofficial
873/TCP rsync file synchronisation protocol Official
991/TCP,UDP NAS (Netnews Administration System)
992/TCP,UDP TELNET protocol over TLS/SSL Official
993/TCP Internet Message Access Protocol over SSL (IMAPS) Official
995/TCP Post Office Protocol 3 over TLS/SSL (POP3S)

8080/TCP Apache Tomcat Unofficial
8118/TCP Privoxy—advertisement-filtering Web proxy Official

how to check 32 bit or 64 bit processor in Linux/ unix/ solaris

/proc/cpuinfo can give you little bit idea but you will get the exact answer from following command

# getconf LONG_BIT

also of you do

[root@server apache1]# ls -la /lib
lib/ lib64/
[root@cihcispweb220 apache1]# ls -la /usr/lib

If you see lib64 folder there then its 64bit processor else its 32 bit. :)

rpm corrupt + rebuild rpm database

You can do that from
#rm -f /var/lib/rpm/__db*
# rpm –rebuilddb

Server monitoring softwares.

You can use this software for server monitoring..Its good as compared to Nagios..
http://sourceforge.net/projects/hobbitmon/

Script to monitor too many instance of processes

Hello,

If your server have too many processes running for a single application here is the script that you can set in cron.

#!/usr/local/bin/perl
my $cmd=”ps -aef | grep -i java | grep -v grep | wc -l”;
$thread_count = `$cmd`;
chomp($thread_count);
$thread_count=~s/ //g;
$hostname=`hostname`;
print “thread count is $thread_count\n”;
if ($thread_count > 100){
print “inside the first 1f\n”;
for($flag = 0; $flag <=3;$flag++){
$mail =0;
$thread_count = `$cmd`;
chomp($thread_count);
$thread_count=~s/ //g;
print "thread count is $thread_count\n";
if ($thread_count > 100){
$mail = 1;
`sleep 180`;
}
}
}
print “Subject: Java Thread count high on $hostname\n”;
if ($mail == 1){
print “sending mail \n”;
open(MAIL, “|/usr/lib/sendmail -t”);
print MAIL “From: email\@domain.com\n”;
print MAIL “To: receiver\@domain.com,Nextreceiver\@domain.com\n”;
print MAIL “Subject: java Thread count high on $hostname\n”;
print MAIL “Open Deploy Thread count on $hostname value is $thread_count.\n\n”;
foreach (@output) {
chomp($_);
print MAIL “$_\n”;
}

close MAIL;
}

0,30 * * * * /script/process_moniter.sh

Optimizing Apache/PHP/MySQL for low memory use

System-wide resources

* Run services under inetd/xinetd - Services such as SSH, SMTP servers, FTP servers, and almost any other service can be spawned by inetd/xinetd. In this case they only use memory when they are actually being used.

* Reduce the number of ttys started in your /etc/inittab:

#comment out lines like this
1:2345:respawn:/sbin/getty 38400 tty1
#2:2345:respawn:/sbin/getty 38400 tty2
#3:2345:respawn:/sbin/getty 38400 tty3

With Xen you can access only one real tty (tty1). Additional ttys like tty2, tty3 and so on are a waste of resources.

* Use ash or dash instead of bash. Be cautious! These alternative shells can break some scripts. Test all your scripts with the new shell before starting using it instead of bash.

[edit] MySQL

* Tune MySQL to use less memory for cache. The best is to use the my-small.cnf sample config as /etc/my.cnf. Below is an example of what to put in /etc/my.cnf.

[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
set-variable = key_buffer=16K
set-variable = max_allowed_packet=1M
set-variable = thread_stack=64K
set-variable = table_cache=4
set-variable = sort_buffer=64K
set-variable = net_buffer_length=2K

* MySQL uses 10MBs of RAM for InnoDB tables. Remove support for InnoDB tables if you do not use them. To remove support for InnoDB, put the following lines in /etc/my.cnf

[mysqld]
skip-innodb

[edit] Apache/PHP

* Tune Apache to only have a small number of spare children running. An example of the Apache configuration section:

StartServers 1
MinSpareServers 1
MaxSpareServers 5
ServerLimit 64
MaxClients 64
MaxRequestsPerChild 4000

Also, only load the modules you require. If you do do not use PHP, mod_perl, etc then do not install them.

* Install a PHP Cache such as Alternative PHP Cache. The PHP cache will store compiled PHP scripts so that they can be reused without the overhead of compiling and processing them for each request.

Port for Oracle Database connection 1521

Oracle SQL*Net Listener

Allows Oracle client connections to the database over Oracle’s SQL*Net protocol. You can configure it during installation. To reconfigure this port, use Net Configuration Assistant.
1521

Next Article »