Wednesday, July 23, 2008

Installing PostgreSQL

This is a quick guide to installing PostgreSQL on a Linux based system. We need to get this up and running before we can write PHP scripts to talk to the database. We need to install PostgreSQL before we can install PHP (since we need the PostgreSQL header files).



This is a little more complicated than installing Apache.



The best bet is to install from packages since this will make things easier, both now and for upgrades.



If you decide to install from source code, you'll need to create a user and compile the source.



Create a PostgreSQL user (you'll need root access). This is who owns the system. I use the "postgres" user and group, you can use something different but it's best to keep it related to the package.



See your system documentation on how to do this (hint - man useradd). Give the user a home directory of /usr/local/pgsql as this is where PostgreSQL defaults to when it installs.



Once all that is done, untar the source:



$ tar -zxf postgresql-.tar.gz (if you got the gzipp'ed version);

or

$ tar -xjf postgresql-.tar.bz2



Jump into the directory:



$ cd postgresql-



(replace with the version you downloaded from the website).



Again, configure has a lot of help:



$ ./configure --help



We'll just install into /usr/local/pgsql and leave the rest as-is:



$ ./configure --prefix=/usr/local/pgsql



Next we have to make it (this will take a while, it takes longer than Apache):



$ make



You will get a line:

All of PostgreSQL successfully made. Ready to install.



when everything is finished.



You'll need to log in as root to do the rest:



$ su -



Go back to the postgresql directory and do:



# make install



PostgreSQL doesn't allow root to start up the server for security reasons, so next you'll have to change the owner of the files:



# chown -R postgres:postgres /usr/local/pgsql



Change to the postgres user:



# su - postgres



Then, change to /usr/local/pgsql:



$ cd /usr/local/pgsql



We need to initialize a database cluster:



$ bin/initdb -D ./data



This will create a /usr/local/pgsql/data directory and initialize it ready for startup and use.



As usual, you can view options by using the --help switch:



$ bin/initdb --help



Then you can start:



$ bin/pg_ctl -D ./data -l data/logfile start



Now that postgresql is started, we need to create a database and another user before we go any further.



You should use a separate database for each of our projects, it's not essential though - it just makes things a little cleaner and easier to understand.



You should also use separate users for each database. This keeps everything separate and 'project a' won't be able to modify any of 'project b's data.



To create a new user in postgresql, it's pretty simple:



$ /usr/local/pgsql/bin/createuser



and follow the prompts - pretty simple :)



The new user should not be able to create new databases or create new users.





To create a database, it's a little different.



$ /usr/local/pgsql/bin/createdb --owner=username databasename



We have to set the owner of the database when we create it, otherwise the 'postgres' user owns it and then we have to grant access to allow our new user to access it.





Now that that's all done, log out of the postgres user, so we're back as root. In the postgres directory, the contrib/start-scripts/ directory has a few system start up scripts.



Follow the instructions in the relevant one to install a start-up script so postgres will start when your system does.



More detailed installation instructions are in the INSTALL file or by going to the PostgreSQL website http://www.postgresql.org/docs/ and going to the right version for you.

Tuesday, July 22, 2008

Use Notepad to Create a Log File

SUMMARY

Microsoft Notepad is a word processing tool included with Windows and is installed by default under the Accessories program group. You can use it to create a log-type file that adds the current date and time each time the Notepad file is opened. This article describes how to create a log file with Notepad.

MORE INFORMATION

To create a log file in Notepad:
1.Click Start, point to Programs, point to Accessories, and then click Notepad.
2.Type .LOG on the first line, and then press ENTER to move to the next line.
3.On the File menu, click Save As, type a descriptive name for your file in the File name box, and then click OK. When you next open the file, note that the date and time have been appended to the end of the log, immediately preceding the place where new text can be added. You can use this functionality to automatically add the current date and time to each log entry.

Thursday, July 17, 2008

How to Disable Security Center Alerts

If you're running Windows XP Service Pack 2 (SP2) Windows Security Center should tell you the status of your antivirus software, firewall, and automatic updates. Security Center will alert you if your antivirus is out of date or turned off, firewall is turned off, or if Automatic Update is not turned on.

If you have received multiple alerts and would like to turn notifications off, you can disable the antivirus, firewall, or automatic update alerts.

Note You should only disable these alerts if you are an expert user. If you are in the process of updating or installing software you may also want to temporarily disable alerts, but please be sure to turn alerts back on so Windows can keep your status up to date.

To turn off Security Center alerts

1.

Click Start and then click Control Panel.

2.

Double-click Security Center.

3.

In the Security Center, under Resources, click Change the way Security Center alerts me.

4.

In the Alert Settings dialog box, clear the Firewall, Automatic Updates, or Virus Protection check boxes, and then click OK.

When you use this procedure, the Security Center still displays your status, but does not send you alerts.

Note If your computer is part of a domain (a group of computers on a network), your security settings are typically managed by your network administrator. In this case, the Security Center does not display your security status or send alerts.

Sunday, July 6, 2008

Mount partition with ntfs file system

Introduction

Purpose of this article is to provide to reader step by step guide, how to mount partition with NTFS file system on Linux operating system. This article consist of two parts:

  • mount NTFS file system read only access
  • mount NTFS file system with read write access

Mount NTFS file system with read only access

NTFS kernel support

Majority of current Linux distributions support NTFS file system out of the box. To be more specific, support for NTFS file system is more feature of Linux kernel modules rather then Linux distributions. Lets check if we have NTFS modules installed.

ls /lib/modules/2.6.18-5-686/kernel/fs/ | grep ntfs

root@ensit~# ls /lib/modules/2.6.18-5-686/kernel/fs/ | grep ntfs
ntfs
root@ensit~#


NTFS module is presented. Lets identify NTFS partition.

Identifying partition with NTFS file system

One simple way to identify NTFS partition is:

fdisk -l | grep NTFS

root@ensit~#fdisk -l | grep NTFS
/dev/sdb1 * 1 261 210456 7 HPFS/NTFS
root@ensit~#

There it is: /dev/sdb1

Mount NTFS partition

First create mount point:

mkdir /mnt/ntfs

Then simply use mount command to mount it:

mount -t ntfs /dev/sdb1 /mnt/ntfs

root@ensit~#mkdir /mnt/ntfs
root@ensit~#mount /dev/sdb1 /mnt/ntfs
root@ensit~#cd /mnt/ntfs
root@ensit~#ls
test
root@ensit~#


Now we can access NTFS partition and its files with read write access.

Mount NTFS file system with read write access

Mounting NTFS file system with read write access permissions is a bit more complicated. This involves installation of addition software such as fuse and ntfs-3g. In both cases you probably need to use you package management tool such as yum, apt-get, synaptic etc.. and install it from your standard distribution repository. Check for packages ntfs-3g and fuse.

We take the other path which consists of manual compilation and installation fuse and ntfs-3g from source code.

Install addition software

Fuse Install

Download source code from: http://fuse.sourceforge.net/

wget http://easynews.dl.sourceforge.net/sourceforge/fuse/fuse-2.7.1.tar.gz

Compile and install fuse source code:

Extract source file:

tar -xzvf fuse-2.7.1.tar.gz

Compile and install

cd fuse-2.7.1
./configure --exec-prefix=/; make; make install
root@ensit~#ls
fuse-2.7.1.tar.gz
root@ensit~#tar -xzvf fuse-2.7.1.tar.gz
root@ensit~#cd fuse-2.7.1
root@ensit~#./configure --exec-prefix=/; make; make install

ntfs-3g install

Download source code from: http://www.ntfs-3g.org/index.html#download

wget http://www.ntfs-3g.org/ntfs-3g-1.1120.tgz

Extract source file:

tar -xzvf ntfs-3g-1.1120.tgz

Compile and install ntfs-3g source code

NOTE: Make sure that you have pkg-config package installed, otherwise you get this error message:

checking for pkg-config... no
checking for FUSE_MODULE... configure: error: FUSE >= 2.6.0 was not found. Either it's not fully 
installed (e.g. fuse, fuse-utils, libfuse, libfuse2, libfuse-dev, etc packages) or files from an old
version are still present. See FUSE at http://fuse.sf.net/
cd ntfs-3g-1.1120
./configure; make; make install
root@ensit~#ls
fuse-2.7.1 fuse-2.7.1.tar.gz ntfs-3g-1.1120.tar.gz
root@ensit~#tar -xzvf ntfs-3g-1.1120.tar.gz
root@ensit~#cd ntfs-3g-1.1120
root@ensit~#./configure --exec-prefix=/; make; make install

Mount ntfs partition with read write access

mount -t ntfs-3g /dev/sdb1 /mnt/ntfs/

NOTE: ntfs-3g recommends to have at least kernel version 2.6.20 and higher.

root@ensit~# mount -t ntfs-3g /dev/sdb1 /mnt/ntfs/
WARNING: Deficient Linux kernel detected. Some driver features are
         not available (swap file on NTFS, boot from NTFS by LILO), and
         unmount is not safe unless it's made sure the ntfs-3g process
         naturally terminates after calling 'umount'. If you wish this
         message to disappear then you should upgrade to at least kernel
         version 2.6.20, or request help from your distribution to fix
         the kernel problem. The below web page has more information:
         http://ntfs-3g.org/support.html#fuse26

Thursday, June 26, 2008

Change your Network Card MAC Address on Ubuntu


There are a lot of reasons you might want to manually set your MAC address for your network card. I won't ask you what your reason is.

To change this setting, we'll need to edit the /etc/network/interfaces file. You can choose to use a different editor if you'd like.

gedit /etc/network/interfaces

You should see the line for your network interface, which is usually eth0. If you have dhcp enabled, it will look like this:

auto eth0
iface eth0 inet dhcp

Just add another line below it to make it look something like this:

auto eth0
iface eth0 inet dhcp
hwaddress ether 01:02:03:04:05:06

Obviously you would want to choose something else for the MAC address, but it needs to be in the same format.

/etc/init.d/networking restart

You will need to restart networking or reboot to take effect.

Tuesday, June 24, 2008

Password Recovery Procedure for the Cisco

Applyed 2000, 2500, 3000, 4000, AccessPro, and 7000

Description
Step-by-Step Procedure
Example of Password Recovery on a Cisco 2500

Description

This document describes the password recovery procedure for the following Cisco products:

  • Cisco 2000
  • Cisco 2500
  • Cisco 3000
  • Cisco 4000
  • Cisco AccessPro
  • Cisco 7000 (RP)
  • Cisco AGS
  • Cisco IGS
  • Cisco STS-10x

Step-by-Step Procedure

Attach a terminal or PC with terminal emulation to the console port of the router. Use the following terminal settings:

9600 baud rate
No parity
8 data bits
1 stop bit
No flow control

  1. Type show version and record the setting of the configuration register. Click here to see output of a show version command.

The configuration register setting is usually 0x2102 or 0x102.

  1. Using the switch, turn off the router and then turn it on.
  2. Press Break on the terminal keyboard within 60 seconds of the powerup to put the router into ROMMON.

If the break sequence doesn't work, try CTRL+BREAK or use the terminal program to send the break as an ascii code.

  1. Type o/r 0x2142 at the > prompt to boot from Flash without loading the configuration.
  2. Type i at the > prompt.

The router reboots but ignores its saved configuration.

  1. Type no after each setup question or press Ctrl-C to skip the initial setup procedure.
  2. Type enable at the Router> prompt.

You'll be in enable mode and see the Router# prompt.

  1. Important Type config mem or copy start running to copy the nonvolatile RAM (NVRAM) into memory. Do not type config term.
  2. Type wr term or show running.

The show running and wr term commands show the configuration of the router. In this configuration you see under all the interfaces the shutdown command, which means all interfaces are currently shutdown. Also, you can see the passwords either in encrypted or unencrypted format.

  1. Type config term and make the changes.

The prompt is now hostname(config)#.

  1. Type enable secret <password>.
  2. Issue the no shutdown command on every interface that is used. If you issue a show ip interface brief command, every interface that you want to use should be "up up".
  3. Type config-register 0x2102, or the value you recorded in step 2.
  4. Press Ctrl-z to leave the configuration mode.

The prompt is now hostname#.

  1. Type write mem or copy running startup to commit the changes.

Example of Password Recovery on a Cisco 2500

The example shown here is password recovery on a Cisco 2500.

Router>en
Password:
Password:
Password:
% Bad secrets
 
Router>show version
Cisco Internetwork Operating System Software
IOS (tm) 2500 Software (C2500-JS-L), Version 12.0(7)T,  RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Mon 06-Dec-99 17:10 by phanguye
Image text-base: 0x0306C4E0, data-base: 0x00001000
 
ROM: System Bootstrap, Version 5.2(8a), RELEASE SOFTWARE
BOOTFLASH: 3000 Bootstrap Software (IGS-RXBOOT), Version 10.2(8a), RELEASE SOFTWARE (fc1)
 
Router uptime is 5 minutes
System returned to ROM by power-on
System image file is "flash:/c2500-js-l.120-7.T"
 
cisco 2500 (68030) processor (revision D) with 8192K/2048K bytes of memory.
Processor board ID 02315272, with hardware revision 00000000
Bridging software.
X.25 software, Version 3.0.0.
SuperLAT software (copyright 1990 by Meridian Technology Corp).
TN3270 Emulation software.
1 Ethernet/IEEE 802.3 interface(s)
1 Token Ring/IEEE 802.5 interface(s)
2 Serial network interface(s)
32K bytes of non-volatile configuration memory.
16384K bytes of processor board System flash (Read ONLY)
 
Configuration register is 0x2102
Router>
 
!--- The router was just powercycled and during bootup a
!--- break sequence was sent to the router.
!
 
Abort at 0x10EA83C (PC)
>o/r 0x2142
>i
 
System Bootstrap, Version 5.2(8a), RELEASE SOFTWARE
Copyright (c) 1986-1995 by cisco Systems
2500 processor with 8192 Kbytes of main memory
 
F3: 13626872+197596+780568 at 0x3000060
 
             Restricted Rights Legend
 
Use, duplication, or disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c) of the Commercial Computer Software - Restricted
Rights clause at FAR sec. 52.227-19 and subparagraph
(c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.
 
            cisco Systems, Inc.
            170 West Tasman Drive
            San Jose, California 95134-1706
 
Cisco Internetwork Operating System Software
IOS (tm) 2500 Software (C2500-JS-L), Version 12.0(7)T,  RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Mon 06-Dec-99 17:10 by phanguye
Image text-base: 0x0306C4E0, data-base: 0x00001000
 
cisco 2500 (68030) processor (revision D) with 8192K/2048K bytes of memory.
Processor board ID 02315272, with hardware revision 00000000
Bridging software.
X.25 software, Version 3.0.0.
SuperLAT software (copyright 1990 by Meridian Technology Corp).
TN3270 Emulation software.
1 Ethernet/IEEE 802.3 interface(s)
1 Token Ring/IEEE 802.5 interface(s)
2 Serial network interface(s)
32K bytes of non-volatile configuration memory.
16384K bytes of processor board System flash (Read ONLY)
 
        --- System Configuration Dialog ---
 
Would you like to enter the initial configuration dialog? [yes/no]: 
!--- Ctrl-C pressed
!
 
Press RETURN to get started!
 
00:00:08: %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
00:00:08: %LINK-3-UPDOWN: Interface Serial0, changed state to up
00:00:08: %LINK-3-UPDOWN: Interface Serial1, changed state to up
00:00:09: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
00:00:09: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to up
00:01:29: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up
00:01:29: %LINK-3-UPDOWN: Interface Ethernet0Translating "Router"...domain server (255.255.255.255)
, changed state to up
00:01:30: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to up
00:01:31: %SYS-5-RESTART: System restarted --
Cisco Internetwork Operating System Software 
IOS (tm) 2500 Software (C2500-JS-L), Version 12.0(7)T,  RELEASE SOFTWARE (fc2)
Copyright (c) 1986-1999 by cisco Systems, Inc.
Compiled Mon 06-Dec-99 17:10 by phanguye
00:01:32: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down
00:01:33: %LINK-5-CHANGED: Interface Ethernet0, changed state to administratively down
00:01:33: %LINK-5-CHANGED: Interface Serial0, changed state to administratively down
00:01:33: %LINK-5-CHANGED: Interface Serial1, changed state to administratively down
00:01:33: %LINK-5-CHANGED: Interface TokenRing0, changed state to administratively down
00:01:34: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to down
00:01:34: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to down
00:01:34: %LINEPROTO-5-UPDOWN: Line protocol on Interface TokenRing0, changed state to down
Router>en
Router#copy start run
Destination filename [running-config]? 
 
1278 bytes copied in 10.448 secs (127 bytes/sec)
 
Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#enable secret Cisco
Router(config)#int e0
Router(config-if)#no shut 
*Mar  1 00:04:12.863: %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
*Mar  1 00:04:13.947: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up
Router(config-if)#int s0
Router(config-if)#no shut
*Mar  1 00:04:18.107: %LINK-3-UPDOWN: Interface Serial0, changed state to up
*Mar  1 00:04:19.167: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
Router(config-if)#int s1
Router(config-if)#no shut
Router(config-if)#
*Mar  1 00:04:27.055: %LINK-3-UPDOWN: Interface Serial1, changed state to up
*Mar  1 00:04:28.071: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to up
Router(config-if)#exit
Router(config)#config-register 0x2102
Router(config)#^Z
Router#wr mem
*Mar  1 00:05:09.035: %SYS-5-CONFIG_I: Configured from console by console
Building configuration...
[OK]
Router#
Router#

Cisco Router Configuration Commands


Requirement

Cisco Command

Set a console password to cisco

Router(config)#line con 0
Router(config-line)#login
Router(config-line)#password cisco

Set a telnet password

Router(config)#line vty 0 4
Router(config-line)#login
Router(config-line)#password cisco

Stop console timing out

Router(config)#line con 0
Router(config-line)#exec-timeout 0 0

Set the enable password to cisco

Router(config)#enable password cisco

Set the enable secret password to peter.

This password overrides the enable password and is encypted within the config file

Router(config)#enable secret peter

Enable an interface

Router(config-if)#no shutdown

To disable an interface

Router(config-if)#shutdown

Set the clock rate for a router with a DCE cable to 64K

Router(config-if)clock rate 64000

Set a logical bandwidth assignment of 64K to the serial interface

Router(config-if)bandwidth 64
Note that the zeroes are not missing

To add an IP address to a interface

Router(config-if)#ip addr 10.1.1.1 255.255.255.0

To enable RIP on all 172.16.x.y interfaces

Router(config)#router rip
Router(config-router)#network 172.16.0.0

Disable RIP

Router(config)#no router rip

To enable IRGP with a AS of 200, to all interfaces

Router(config)#router igrp 200
Router(config-router)#network 172.16.0.0

Disable IGRP

Router(config)#no router igrp 200

Static route the remote network is 172.16.1.0, with a mask of 255.255.255.0, the next hop is 172.16.2.1, at a cost of 5 hops

Router(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.1 5

Disable CDP for the whole router

Router(config)#no cdp run

Enable CDP for he whole router

Router(config)#cdp run

Disable CDP on an interface

Router(config-if)#no cdp enable

Cisco Router Show Commands

Requirement

Cisco Command

View version information

show version

View current configuration (DRAM)

show running-config

View startup configuration (NVRAM)

show startup-config

Show IOS file and flash space

show flash

Shows all logs that the router has in its memory

show log

View the interface status of interface e0

show interface e0

Overview all interfaces on the router

show ip interfaces brief

View type of serial cable on s0

show controllers 0 (note the space between the 's' and the '0')

Display a summary of connected cdp devices

show cdp neighbor

Display detailed information on all devices

show cdp entry *

Display current routing protocols

show ip protocols

Display IP routing table

show ip route

Display access lists, this includes the number of displayed matches

show access-lists

Check the router can see the ISDN switch

show isdn status

Check a Frame Relay PVC connections

show frame-relay pvc

show lmi traffic stats

show frame-relay lmi

Display the frame inverse ARP table

show frame-relay map

Cisco Router Basic Operations

Requirement

Cisco Command

Enable

Enter privileged mode

Return to user mode from privileged

disable

Exit Router

Logout or exit or quit

Recall last command

up arrow or

Recall next command

down arrow or

Suspend or abort

and and 6 then x

Refresh screen output


Compleat Command

TAB

Cisco Router Copy Commands

Requirement

Cisco Command

Save the current configuration from DRAM to NVRAM

copy running-config startup-config

Merge NVRAM configuration to DRAM

copy startup-config running-config

Copy DRAM configuration to a TFTP server

copy runing-config tftp

Merge TFTP configuration with current router configuration held in DRAM

copy tftp runing-config

Backup the IOS onto a TFTP server

copy flash tftp

Upgrade the router IOS from a TFTP server

copy tftp flash

Cisco Router Debug Commands

Requirement

Cisco Command

Enable debug for RIP

debug ip rip

Enable summary IGRP debug information

debug ip igrp events

Enable detailed IGRP debug information

debug ip igrp transactions

Debug IPX RIP

debug ipx routing activity

Debug IPX SAP

debug IPX SAP

Enable debug for CHAP or PAP

debug ppp authentication

Switch all debugging off

no debug all

undebug all