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 :

2011-01-28

FreeBSD - How to make changes to sendmail, FreeBSD styled

Sendmail is the default MTA in FreeBSD. FreeBSD has its own way in managing sendmail's configuration files. Instead of making changes to sendmail.mc, changes should be made to $(hostname).mc. Similarly for submit.mc, changes should be $(hostname).submit.mc.

Here's how :

2011-01-24

FreeBSD - How to test newsyslog for systax error

Platform :
FreeBSD

Purpose :
Syntax checking after creating a new logrotate in "newsyslog"

Command :
newsyslog


Installation :
The "newsyslog" log rotation program comes with the base installation.

Useful switches :
-n == DO NOT actually do the logrotate. Instead, show what will be perform
-vv == verbose on what newsyslog is doing

Example :

2011-01-21

BIND - Error "loading from master file managed-keys.bind failed: file not found"

Platform :
FreeBSD

Error message :
Every time restarting the BIND DNS server, the log file will have this entry :
general: error: managed-keys-zone ./IN: loading from master file managed-keys.bind failed: file not found
BIND DNS continue to work though.

Solution :
Create a empty file in /var/named/etc/namedb, name "managed-keys.bind":
touch /var/named/etc/namedb/managed-keys.bind

Why :
The file "managed-keys.bind" is used for managing keys in DNSSEC. By default, BIND is looking for it. Even though you might not be using this feature, creating the file in empty will make the error message go away.


Sayonara !!!

2011-01-17

FreeBSD - How to get information on hardware details

Platform :
FreeBSD

Purpose :
Print out information about hardware, e.g. CPU, memory, network card & etc

2011-01-14

OSX - How to maximize window using keyboard shortcut

By default, OSX does not comes with a shortcut, though there's a function for it. To make use of it, we'll need to assign a keyboard shortcut key to maximize or un-maximize window.








Here's how to do it :
  1. Open the "System Preferences"
  2. Under the "Hardware" section, click on "Keyboard"
  3. Next, click on "Keyboard Shortcuts" then "Application Shortcuts" (on the left hand box)
  4. Add a shortcut key by clicking on "+" symbol, on the bottom of the right hand box
  5. At the next dialog box, choose "All Applications" for "Application:"
  6. In the "Menu Title :" column, type in "Zoom"
  7. Click on the next column, "Keyboard Shortcut:", then press your preferred keyboard shortcut.
    E.g. Control + Option + Command + m (you didn't read wrongly, is 4 keys there :p)

    *** Avoid popular shortcut key, e.g. Command + v

Now, open an application and try the new keyboard shortcut key. Press the first time for maximized and the second time to return the previous size.

Nemaste !!!

2011-01-10

FreeBSD - portupgrade php5 got hiccups with security/php5-filter

During the routing upgrading of ports, caught a hiccups while upgrading php5 related packages.

One of the port failed to upgrade after issuing "portupgrade -vr php5*".







The errors :
===>  Building for php5-filter-5.3.4
/bin/sh /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/libtool --mode=compile cc  -I. -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -DPHP_ATOM_INC -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/include -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/main -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -DHAVE_CONFIG_H  -O2 -fno-strict-aliasing -pipe   -c /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c -o logical_filters.lo
 cc -I. -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -DPHP_ATOM_INC -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/include -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/main -I/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -DHAVE_CONFIG_H -O2 -fno-strict-aliasing -pipe -c /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c  -fPIC -DPIC -o .libs/logical_filters.o
In file included from /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:25:
/usr/local/include/php/ext/pcre/php_pcre.h:29:18: error: pcre.h: No such file or directory
In file included from /usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:25:
/usr/local/include/php/ext/pcre/php_pcre.h:37: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/local/include/php/ext/pcre/php_pcre.h:38: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
/usr/local/include/php/ext/pcre/php_pcre.h:44: error: expected specifier-qualifier-list before 'pcre'
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c: In function 'php_filter_validate_regexp':
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: 'pcre' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: (Each undeclared identifier is reported only once
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: for each function it appears in.)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:411: error: 're' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:412: error: 'pcre_extra' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c: In function 'php_filter_validate_email':
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:527: error: 'pcre' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:527: error: 're' undeclared (first use in this function)
/usr/ports/security/php5-filter/work/php-5.3.4/ext/filter/logical_filters.c:528: error: 'pcre_extra' undeclared (first use in this function)
*** Error code 1
1 error
*** Error code 1

Stop in /usr/ports/security/php5-filter.
** Command failed [exit code 1]: /usr/bin/script -qa /tmp/portupgrade20101224-47314-9ktu04-0 env UPGRADE_TOOL=portupgrade UPGRADE_PORT=php5-filter-5.2.11_1 UPGRADE_PORT_VER=5.2.11_1 make
** Fix the problem and try again.
--->  Build of security/php5-filter ended at: Fri, 24 Dec 2010 09:36:27 +0800 (consumed 00:00:43)
--->  Upgrade of security/php5-filter ended at: Fri, 24 Dec 2010 09:36:27 +0800 (consumed 00:00:43)
--->  ** Upgrade tasks 1: 0 done, 0 ignored, 0

Checking out /usr/ports/UPDATING and /usr/ports/MOVED doesn't seems to give a hint. Next try on Forum.FreeBSD.org shed light on this :

2011-01-07

Bash - How to check the exit status of pipe command


Piping in bash commands are common.
Checking exit status of a command in bash scripting is essential.
How about checking exit status of the commands in a pipe?





Example:

2011-01-03

FreeBSD - Port p5-Encode-Detect error

While patching one of the FreeBSD box, a perl module port, converters/p5-Encode-Detect-1.01, failed to compile. This is the abstract of the error message :







===>  Extracting for p5-Encode-Detect-1.01
=> SHA256 Checksum OK for Encode-Detect-1.01.tar.gz.
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/bin/perl5.8.9 - found
===>  Patching for p5-Encode-Detect-1.01
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/bin/perl5.8.9 - found
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/lib/perl5/site_perl/5.8.9/ExtUtils/CBuilder.pm - found
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/lib/perl5/site_perl/5.8.9/Module/Build.pm - found
===>   p5-Encode-Detect-1.01 depends on file: /usr/local/bin/perl5.8.9 - found
===>  Configuring for p5-Encode-Detect-1.01
Warning: ExtUtils::CBuilder not installed or no compiler detected
Proceeding with configuration, but compilation may fail during Build

Creating new 'MYMETA.yml' with configuration results
Creating new 'Build' script for 'Encode-Detect' version '1.01'
===>  Building for p5-Encode-Detect-1.01
Building Encode-Detect
Error: no compiler detected to compile 'src/LangBulgarianModel.cpp'.  Aborting
*** Error code 2

Stop in /usr/ports/converters/p5-Encode-Detect.

It seems like the port devel/p5-ExtUtils-CBuilder didn't quite compile it's option and installed properly. Reinstalling devel/p5-ExtUtils-CBuilder didn't help. Re-compile all of the dependency of converters/p5-Encode-Detect & devel/p5-ExtUtils-CBuilder also didn't work as well.

The error message does strongly suggest that there's problem with devel/p5-ExtUtils-CBuilder. It's time to get my hands dirty, by manually compiling the port devel/p5-ExtUtils-CBuilder :

2010-12-29

FreeBSD Foundation - Still short of 1 quarter

Another few more days and it'll be the end of this year.

FreeBSD have done much for you. Is time to show you've done something for FreeBSD (both the great community & OS).

A quote from the FreeBSD Foundation Announcements :

End-of-Year Fundraising Campaign

Dear FreeBSD Community,

As the year is winding down I'm writing this note to remind you of the motivation behind the FreeBSD Foundation's work, its benefits to you, and to ask for your financial assistance in making our work possible.

Ten years ago, I created the FreeBSD Foundation to repay a debt I owe to the FreeBSD project. While working on FreeBSD I learned the fundamentals of sound software design, how to successfully manage a large code base, and experienced the challenges of release engineering. Beyond the benefits of this education, FreeBSD has provided a robust platform that has allowed me to build several successful commercial products while being well paid to work on an operating system I love. Today, through my volunteer work with the FreeBSD Foundation, I'm still paying down this debt.

This year, despite the slow pace of the economic recovery, the FreeBSD Foundation has an impressive list of accomplishments:

* Provided $100,000 in grants for projects that improve FreeBSD in the areas of:
o DTrace support
o High availability storage
o Enhanced SNMP reporting
o Virtualization and resource partitioning
o Embedded device support
o Networking stack improvements
* Allocated $50,000 for equipment to enhance FreeBSD project infrastrutture.
* Sponsored 8 FreeBSD related conferences.
* Funded 16 travel grants giving increased community and developer access to conferences.
* Provided legal support to the FreeBSD project.

How do our activities benefit you? If you are a company using FreeBSD, our work to strengthen the FreeBSD community ensures the continued viability of FreeBSD and a large pool of developers to tap into. If you are an end user, our work brings you new features and access to conferences. And if you are a FreeBSD developer, the FreeBSD Foundation is providing the resources needed to make your next innovation possible.

The FreeBSD project thrives through the hard work of our community, but it also requires financial backing. This year we set a fund-raising goal of $350,000. We are pleased to report that we are half way there, but we need your help to reach our goal. Every donation, no matter its size, helps to make our work possible. As a non-profit with very low overhead, your donation is the best way to invest in FreeBSD. Please make that investment today.

You can make a donation (including recurring subscriptions) by going to:

http://www.freebsdfoundation.org/donate/

To find out more about The FreeBSD Foundation, please visit:

http://www.freebsdfoundation.org

Thank You,

Justin T. Gibbs Founder and President The FreeBSD Foundation

What are you waiting for?

Click here to donate ...

and a Happy New Year 2011 !!!

2010-12-24

FreeBSD Foundation - Is the seasons of giving

Is Christmas time !!!

Everyone gets to enjoy a feast with present, one or two.





Why not give some to the FreeBSD Foundation at this happy season as well? After all, the FreeBSD community did help you to get a job and probably earn a bonus.

It won't have to be a hefty sum that tip your budget off for the season. A minor few tens of bucks is good enough. Of cause, if anyone can spend a few hundred bucks on FreeBSD Foundation is definitely a merit.

What's more, you get to own the right to brag; brag about "I got my name on FreeBSD Foundation donor list" !!! :)

Merry Christmas & A Happy New Year !!!