20090828

Unix: Old dog, new tricks part 2

Say you want to add a '.old' to every file in your current directory. At the end of each expression ($) a '.old' will be set:

rename 's/$/.old' *

Or you want to make the filenames lowercase:

rename 'tr/A-Z/a-z/' *

Or you want to remove all double characters:

rename 'tr/a-zA-Z//s' *

Or you have many JPEG files that look like "img0000154.jpg" but you want the first five zeros removed as you don't need them:

rename 's/img00000/img/' *.jpg

rename will accept any regex and any perl operator

git stuff

Setting up gitweb with lighttpd
git Quick Reference Guide
git by Example
git Magic (Great intro)

20090724

Installing Movable Type 4.261

Had to setup a new MovableType 4 (MT4) to test out the new Social Networking thingy called Motion. Got stuck with "mt-static" not found even though I've supplied the correct url, path and even reconfigured apache thinking it was the problem. Finally, a damn fine solution that's not even in MT's documentation site:

1. cp mt-config.cgi-original mt-config.cgi
2. Supply the correct path/url to CGIPath and StaticWebPath
3. Supply the information under DATABASE SETTINGS
4. If you haven't done it yet, create your database

Open http://domain/cgi-bin/mt/mt.cgi or http://domain/mt/mt.cgi depending on how you're setup.

It should ask you for your account details, password, and shit.

20090422

Yahoo! Mail not enough storage?

Here's something you don't see everyday:
Apr 22 14:43:11 list sm-que[9833]: n3M0BfGw009757: ...
relay=b.mx.mail.yahoo.com. [66.196.97.250], dsn=4.3.1,
stat=Deferred: 452 Requested action not taken: insufficient system storage

MKDIR child folders


mkdir -p parent/{child1,child2,child3}

GREPing for two or more patterns


grep -e "patern1|patern2|patern3" filename

20090209

Passwordless SCP, SSH, RSYNC


host_src$ ssh-keygen -t rsa
host_src$ scp .ssh/id_rsa.pub user@host_dest
host_src$ ssh user@host_dest
host_dest$ mv id_rsa.pub .ssh/authorized_keys
host_dest$ chmod 700 .ssh/authorized_keys

20081229

What does men with power want? More power!

"What the fuck is this world", sings Eddie Vedder. Indeed, WTF? Having read this blog post about a political dynasty wreaking havoc among the people who they're to supposed to serve just gives you enough heat to boil not just an egg, but basket fulls.

You're a public official, elected by the people and yet you rule like you're god and that the people should fear you. FUCK YOU.

What's worse is that the management of the prestigious (NOT!) Valley Gold and Country Club is not cooperating with authorities. WTF?

We should all visit: http://www.valleygolf.com.ph/temp/feedback.asp and give them a piece of our minds.

20080715

Bypassing portaudit

If you're stuck building a port even if you're already upgraded using portmanager, set the environment variable DISABLE_VULNERABILITIES:

setenv DISABLE_VULNERABILITIES 1

and start make install clean again. Reference here.

20080714

FreeBSD Package management

To search for packages in ports:

make search name="blahblah"

To search packages related to something:

make search key=id

To search for installed packages

pkg_info -ac

To search for a particular package

pkg_info -xc packagename

To list files installed by a package

pkg_info -xL packagename

To check dependencies of a package

pkg_info -R packagename

20080712

4-Step FreeBSD essentials for new installs

1. Update the ports tree
pkg_add -r portsnap
portsnap fetch
portsnap extract
portsnap update

2. Install portaudit & portmanager

pkg_add -r portaudit portmanager

3. Run portaudit to check for vulnerabilities:

portaudit -Fda

4. Upgrade the installed packages

portmanager -u

Notes: to use a proxy & save bandwidth:

setenv FTP_PROXY xxx.xxx.xxx.xxx:yyyy

To check for outdated packages:

pkg_version -vIL=

or

pkg_version -vIL'<'

20080707

Tools of the trade dept: Network Monitoring

http://www.zabbix.com/ (++)
http://www.jffnms.org/
http://www.zenoss.com/
http://www.hyperic.com/
http://www.cacti.net/

20080706

Tools of the trade dept: wireshark and ratproxy

http://www.wireshark.org/ - network protocol analyzer
http://code.google.com/p/ratproxy/ - semi automated passive security audit tool (that's a mouthful)

20080623

Disable some PHP functions

Disable some uneeded functions. Add these to your php.ini

disable_functions: escapeshellarg, escapeshellcmd, exec, passthru, proc_close, proc_get_status, proc_nice, proc_open, proc_terminate, shell_exec, system, pcntl_exec, pcntl_fork, popen, phpinfo

Edit: Those who managed to gain access to a web server will look for these process when you have PHP installed. If you won't use it, disable it.

20080620

Sendmail premature EOM: unexpected close

Been geeting some errors on our sendmail server with:

premature EOM: unexpected close

at the sending server, the error was:

Deferred: Operation timed out with

and mails can't get in even if their really small. It turns out one of the RBLs I've configured is not responding anymore. I've commented out till I find out which one.

Look for:

FEATURE(`dnsbl',blah blah...

and comment them out:

dnl FEATURE(`dnsbl',blah blah...

run make or rebuild sendmail.mc then restart/reload sendmail.