2011-04-07

AboutBSD.net - 20110406 not accessible

AboutBSD.net, a BSD news planet maintain by me is currently unavailable due to some hardware issue. Please check back later.

2011-04-04

Bash - How to debug shell script

Although Bash will spit out the errors onto the screen whenever it hits one, but some times, we want to know what exactly was being done every single command it executed.

This is how to do it :
Before running the bash script, do a :
set -x
then run the script and it'll be tell every action that it performs.

This is especially useful when debugging logic.

After finding out what's wrong, this is how to turn it off :
set +x

Alternatively, to debug only when running this script, put the below line in the start of the script :
set -x
Arrivederci !!!

2011-04-01

FreeBSD - Behold, The Great Committer

Please don't scroll pass this post. This urgent & definitely needs your attention :
FreeBSD has always been something of a meritocracy, where the respect given to committers is directly proportional to the amount and quality of code they commit. This is tracked in the commit statistics. For many years, Poul-Henning Kamp (phk@) was the undisputed leader, but in 2010 his total was exceeded by relative newcomer John Baldwin (jhb@). Baldwin’s commits show no sign of slowing, and if he continues at this pace, he will soon overtake the combined totals of Foundation President Robert Watson and embedded emeritus Warner Losh.

Oh ya, make sure you have a mattress or you're stepping on a soft ground before you get hurt. Read on more here !!!

Ciao !!!

Perl - How to DOS your processor

Here's a way to maximize the CPU processor,

2011-03-28

Sendmail - How to test sending email, verbosely using Sendmail




Mail Server :

Sendmail

Purpose :

To verbosely test sending of email using sendmail

Here how :

Prepare a file with name "mail.txt". This will be the email header & contents that we wanna include when test sending this email. The contents of the file should look like below :

2011-03-25

PC-BSD - Error when restarting pf firewall or within Ports Jail

Trigger :

When pf service is restarted







Error messages :

# /etc/rc.d/pf restart
Disabling pf
pf disabled
.
Enabling pf
no IP address found for lo1:network
/etc/pf.conf:4: could not parse host specification
no IP address found for lo1:network
/etc/pf.conf:5: could not parse host specification
pfctl: Syntax error in config file: pf rules not loaded
pf enabled
.

Side Effect :

When running "Ports Jail" terminal with portsnap or installation, it will failed because there's not internet connection present.

Why :

The interface "lo1:network" is missing due to abnormal shutdown of "portjail" service.

2011-03-18

RFC 2606 - Domain names for testing

In this blog, often the output or the example used needed to be masked before posting. To protect the original server/identity. But when it comes to domain names, we can't simple quote some random name, it might be an active domain (in the future, if not now).


Also, for documentation or presentation, we tend to use mock up domain, server or host name. How to make sure that server, domain or host name is not in used?

In RFC 2606, there are domain names that serve this purpose :

2011-03-11

RFC 2142 - Mailbox Names for Common Services, Roles and Functions

RFC stands for Request For Comments. Not all RFC documents end up as standards. But it is indeed a good read to find out how standards works. For example, RFC 2142 list emails that should be reserve for its purpose :

2011-03-07

2011-03-04

FreeBSD - How to change time zone

Platform :
FreeBSD

Objective :
Change the FreeBSD system clock time zone

Command :
tzsetup

2011-02-28

Perl - How to uninstall / delete Perl module

Installing Perl modules can use the cpanm utility, but how about removing Perl modules? App::pmuninstall module is the answer!

Installation :

$ cpanm App::pmuninstall
--> Working on App::pmuninstall
Fetching http://search.cpan.org/CPAN/authors/id/X/XA/XAICRON/App-
pmuninstall-0.16.tar.gz ... OK
Configuring App-pmuninstall-0.16 ... OK
Building and testing App-pmuninstall-0.16 ... OK
Successfully installed App-pmuninstall-0.16

Usage :

2011-02-25

vim - How to stop vim creating "tilde" backup files

Vim, aka the Programmer's Editor, by default creates backup files (ends with a tilde character) whenever editing file. E.g. myfile~, another_file~, yet_another_file~ and etc.

After some time, this generates too many backup laying around the file system. Too messy. This is how to stop vim create these backup files :

2011-02-21

Perl - How to find out what Core Modules installed

Perl comes with a set of core modules. Perl core modules comes with default installation.
E.g. :
- Env
- File::Spec
- File::Basename
- Time::localtime

These are just some of the gems to a system administrator. So, how to find out what core modules are included with your perl installation?




Here's how :

2011-02-18

FreeBSD - How to change screen to use BASH

Purpose :
Make screen, the virtual terminal program, changes the user's default shell from tcsh to BASH when starting.

Command :

2011-02-11

Bash - How to output all (stdout & stderr) into log file in Bash

Purpose :
When scripting Bash scripts, often we'll need to output all stdout & stderr of a particular command into a log file, for logging purposes or diagnostic purposes.






Command :

2011-02-07

FreeBSD - How to check device or CPU performance

Platform :
FreeBSD

Purpose :
Monitoring disk read/write activity.

Command :
iostat


Installation :
The "iostat" command comes with the base installation.

Useful switches :
-w == update frequency, in seconds
-d == only show devices, hdd related
-C == show CPU activity only

Example :

2011-02-04

ssh - How to pipe output from local to remote server

In Bash, with pipe (the "|" symbol) and ssh makes a good combination of server administration tool, securely. Some examples :

2011-01-31

FreeBSD - How to reduce TIME_WAIT connections

Routinely, I did a "netstat -an" on a FreeBSD box, a DNS server. The screen then shower with hundreds of "TIME_WAIT" connections. Seems like some malware infected clients are querying the server and causes the terminated TCP socket waiting to be shutdown, but not fast enough, to be efficient. Fortunately, the numbers of TIME_WAIT sockets accumulated are insignificant.

In order to reduce the number of socket waiting, tune the system value :