Useful Commands

Changing Password


Restarting Mysql daemon

cd /root/sbin
service mysqld start
/usr/sbin/httpd -k restart

Search and Replace

for i in `ls -1 |grep shoes`; do perl $i; done
Replace "shoes" with pattern in file names. source:
#!/usr/bin/perl $myfile=@ARGV[0]; #$searchs='cellspacing="0" align="left"'; #$replaces='cellspacing="2"'; open(FIN,"<".$myfile) or die "Search and Replace"; $template=""; $count=1; $searchquery=""; while(<FIN>) { # $searchquery=$1; # } $myline=$_; # $myline =~ s/\t/;/gi; # if ($myline =~ m/Comparison shop ([a-zA-Z\ ]+) at:/) { # $searchquery=$1; # } # $myline =~ s/Comparison shop/<img src="http:\/\/\/image-" height="1" width="1"><SCRIPT LANGUAGE="Javascript" SRC="http:\/\/\/sb\/bs.jsp?Req=prof&Brand=xxxxxxxx&Page=1&col=4&row=4&sort=-POPULAR&pid=12345&aid=56789&newWin=1&price=1&fst=1&cssType=default"><\/SCRIPT><br\/><br\>Comparison shop/g; $myline =~ s/<h1><b>What is /<h1><b>/g; #$myline = "swimandshoes-200406_".$myline; $template=$template.$myline; #$count=$count+1; } #$template =~ s/xxxxxxxx/$searchquery/; #$template =~ s/bgcolor=([a-z]+)/bgcolor="$1"/ig; #} #print $searchname; #$template =~ s/<\/head>/<\/object><\/head>/; close(FIN); open(FOUT,">".$myfile); print FOUT $template; close(FOUT);



General Error
SQL ERROR [ mysql4 ]

Too many connections [1040]

An sql error occurred while fetching this page. Please contact an administrator if this problem persists.


Restart MySQL:
ps aux | grep mysql

/etc/init.d/mysqld start

Restart Webserver:
/usr/sbin/httpd -k restart

Mac OS X Tips

Sneaky Launch Locations

List All Directories

find . -type d -ls

Repair SQL database

SQL ERROR [ mysql ]
Got error 134 from table handler [1030]
An sql error occurred while fetching this page.


mysqlcheck --repair --all-databases


editing sendmail

m4 /etc/mail/ > /etc/mail/

Restarting sendmail
/etc/rc.d/init.d/sendmail stop
/etc/rc.d/init.d/sendmail start

define(`confTO_CONNECT', `1m')dnl
define(`confTO_IDENT', `0')dnl
define(`confTO_COMMAND', `2m')dnl

These set the timeouts for the initial connection and in between commands to be 1 and 2 minutes respectively. It also disables checking for ident information by setting it to zero. This can easily bog down a server as it takes awhile for the ident check to timeout and most servers aren't running it these days.

If you receive a lot of E-mail on a regular basis or get hit with sudden floods of it, you may want to explore using the following options:

define(`confMAX_DAEMON_CHILDREN', 20)dnl
define(`confQUEUE_LA', `18')dnl
define(`confREFUSE_LA', `24')dnl

The first setting instructs Sendmail to have at most 20 processes running at any one time. The next two determine at what system load levels Sendmail only queues up E-mail for later processing (confQUEUE_LA) and at what load level it rejects E-mail entirely. These two are useful in preventing a flood of spam from bringing your server to its knees.

Kill multiple processes

killall -9 PATTERN


Disable Netbios

sudo launchctl unload -w /System/Library/LaunchDaemons/

OSX Software Installed Directories

lsbom -lsf /private/var/db/receipts/ | cut -d'/' -f-5 | uniq

Return to Po-Han Lin's Depot