how to search search & delete line in vi editor

the below command in vi editor will remove the whole line that contains the word “search-keywords” on the entire file.

:g/search-keywords/d

installing postgresql 8.2 on Leopard with macports

postgresql! one of my favorite high performance open source db, of course i have it running on my mac. compiling postgresql with macports isn’t that hard, follow the step below will guide you through the installation;

first of all, make sure your macports is updated by running the command;

sudo port -v selfupdate
sudo port -v sync # some user prefer to run port sync, port selfupdate does the same thing.

installing postgresql, start it and create super user

sudo port -v install postgresql82-server # compile and install postgresql database from macports.

by default, macports will create postgresql database directory and initialize the db.

[ 149]$ ls -al /opt/local/var/db/postgresql82/
total 0
drwxr-xr-x 3 root admin 102B Nov 13 21:27 .
drwxr-xr-x 3 root admin 102B Nov 13 21:27 ..
drwx—— 16 postgres postgres 544B Mar 10 16:35 defaultdb

if the db directory is not created, follow the step below;

sudo mkdir -p /opt/local/var/db/postgresql82/defaultdb # make database directory
sudo chown postgres:postgres /opt/local/var/db/postgresql82/defaultdb # assign postgre user and group
sudo su postgres -c ‘/opt/local/lib/postgresql82/bin/initdb -D /opt/local/var/db/postgresql82/defaultdb’ # initialize default database

the default installation doesn’t include postgresql binary file into /opt/local/bin, add postgresql executable files into your shell environment

takizo@redarrows(~)
PATH=${PATH}:/opt/local/lib/postgresql82/bin

now, we will launch postgresql database and create super user and database

takizo@redarrows(~)

sudo /opt/local/etc/LaunchDaemons/org.macports.postgresql82-server/postgresql82-server.wrapper start
server starting # start postgresql database

sudo su – # switch to root user

sudo posrgres – # switch to postgres user

/opt/local/lib/postgresql82/bin/createuser -s -d -r -P

exit # quit as postgres user

exit # quit as root user

createdb -O takizo takizo # create database with takizo as privilege user

You are done, now you can logon to postgresql database with your username (mine is takizo)

psql82 -U takizo takizo

Since you have created super user, next time you can create new user with createuser command,

createuser -S -D -R -P -U takizo edward # create user edward with privilege account takizo
Enter password for new role: # password is hidden :p
Enter it again: # confirmed password is hidden too :)
CREATE ROLE # new user has been created

Happy playing with postgresql database!

Problem Upgrade Apache2 on MacPorts

I was trying to upgrade apache2 on my Macports but keep on getting these error messages which really annoy me;

Undefined symbols:
“_ap_ugly_hack”, referenced from:
_ap_ugly_hack$non_lazy_ptr in libmain.a(main.o)
“_ap_prelinked_module_symbols”, referenced from:
_ap_prelinked_module_symbols$non_lazy_ptr in libmain.a(core.o)
“_ap_prelinked_modules”, referenced from:
_ap_prelinked_modules$non_lazy_ptr in libmain.a(main.o)
_ap_prelinked_modules$non_lazy_ptr in libmain.a(config.o)
“_ap_http_input_filter_handle”, referenced from:
_ap_http_input_filter_handle$non_lazy_ptr in libmain.a(protocol.o)
“_ap_preloaded_modules”, referenced from:
_ap_preloaded_modules$non_lazy_ptr in libmain.a(config.o)

There are bug reports on MacPorts trac but it seem non of it giving the solution to solve the problem, so I have to do some workaround to make the upgrade works.

Try your luck to uninstall ncurses and ncursesw, re-install again, and also uninstall gawk from your macports. After that all have been done, do these

sudo port -v clean apache2 # clean apache2 port
sudo port -v install apache2 +darwin_9 # compile with darwin_9 variants

Post the comment and see what’s your outcome.

Troubleshoot Firefox – safe mode

 firefox2.png

Today, visited a website with flash and some how it just trash Firefox. I know this sounds like winbloze but starting Firefox in Safe Mode is a good way to troubleshoot. During the startup of Safe Mode, plungins, toolbars & controls, bookmarks, user preference and search engines can be disable. The command :

firefox -safemode

Happy troubleshooting !!!

lspci on FreeBSD?

By default, Linux come with lspci command to print PCI hardware on the machine. On FreeBSD, you can install pciutils in order to list pci hardware and make some tweaking on PCI IRQ/slots.

Installing pciutils on FreeBSD

To install pciutils, change directory to the directory and make install;


shell> cd /usr/ports/sysutils/pciutils
shell> make install clean

Print PCI Hardware Details

Print out PCI device details witht he command below


shell> lspci


00:00.0 Host bridge: Intel Corporation 82865G/PE/P DRAM Controller/Host-Hub Interface (rev 02)
00:02.0 VGA compatible controller: Intel Corporation 82865G Integrated Graphics Controller (rev 02)
00:1d.0 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #1 (rev 02)
00:1d.1 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #2 (rev 02)
00:1d.2 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #3 (rev 02)
00:1d.3 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB UHCI Controller #4 (rev 02)
00:1d.7 USB Controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) USB2 EHCI Controller (rev 02)
00:1e.0 PCI bridge: Intel Corporation 82801 PCI Bridge (rev c2)
00:1f.0 ISA bridge: Intel Corporation 82801EB/ER (ICH5/ICH5R) LPC Interface Bridge (rev 02)
00:1f.1 IDE interface: Intel Corporation 82801EB/ER (ICH5/ICH5R) IDE Controller (rev 02)
00:1f.3 SMBus: Intel Corporation 82801EB/ER (ICH5/ICH5R) SMBus Controller (rev 02)
00:1f.5 Multimedia audio controller: Intel Corporation 82801EB/ER (ICH5/ICH5R) AC'97 Audio Controller (rev 02)
01:02.0 Ethernet controller: 3Com Corporation 3c900 10Mbps Combo [Boomerang]
01:03.0 Non-VGA unclassified device: Unknown device 0001:0000
01:05.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)

If you would like to see more details, use lspci -vvv , for more information on lspci, do man lspci