Ruby On Rails a beginner tutorial

in Categories News last updated February 28, 2006

The Ruby on Rails web application framework got lots of buzz in last year. Apple has just posted very nice and easy to follow tutorial on Ruby On Rails for web development on Mac OS X.

According to apple it is no surprise that Mac OS X is a favored platform for Rails development. Rails and its supporting cast of web servers and databases thrive on the rich Mac OS X environment.

* This tutorial covers
* Installing Rails
* Creating a New Rails Application
* Jump-Starting the Application
* Creating the Database Schema
* And other related stuff etc

Overall an excellent tutorial and highly recommend for all newbie’s out there.

User management: command line vs GUI tools

in Categories News last updated February 27, 2006

Almost all Linux distribution comes with its own set of GUI tools to manage users and groups. For example:
* Red Hat comes with redhat-config-user
* Suse comes with Yast
* Debian Linux and other distro come with users-admin GUI tool set
* FreeBSD with sysinstall
* Solaris comes with Solaris Management Centre (SMC)

However, I recommend managing user accounts from command line. It offers following benefits over GUI tools:

  • Using commands from command line is faster
  • Automation is possible as per your requirements (use of Perl or shell scripting)
  • If you are going to use LDAP or NIS then command line provides best solution as compare to GUI tools

What is the best way to edit /etc/passwd, shadow, and group files?

in Categories News last updated February 27, 2006

The best way to edit /etc/passwd, or shadow or group file is to use vipw command. Traditionally (under UNIX and Linux) if you use vi to edit /etc/passwd file and same time a user try to change a password while root editing file, then the user’s change will not entered into file. To avoid this problem and to put a lock while editing file, use vipw and vigr command which will edit the files /etc/passwd and /etc/group respectively. If you pass -s option to these command, then they will edit the shadow versions of those files i.e. /etc/shadow and /etc/gshadow, respectively.

The main purpose of locks is to prevent file corruption. Do not use vi or other text editor to edit password file. Syntax:

  • vipw -s : Edit /etc/passwd file
  • vigr -s : Edit /etc/group file


  • -s : Secure file editing

An example

Login as a root user:

# vipw -s

On other terminal login as normal user (for example vivek) and issue command passwd to change vivek’s password:

$ passwd

(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: Authentication token lock busy

As you see it returned with an error “passwd: Authentication token lock busy”

This will avoid /etc/shadow file corruption.

How to: Allow Any User To Shutdown a Linux Server

in Categories CentOS, Debian Linux, FreeBSD, Gentoo Linux, Howto, Linux, RedHat/Fedora Linux, Sys admin, Tips, Ubuntu Linux last updated February 23, 2006

You need to use the sudo command to grant a permission to other users to shutdown your server. The sudo command allows a permitted user to execute a command as the superuser or another user, as specified in the /etc/sudoers file. Login as a root user and type the visudo command to edit the sudoers file.

Testing Oracle 10g installation on Red Hat Linux AS 4.0

in Categories Howto, Linux last updated February 22, 2006

One of my friend installed Oracle first time. After installation, he just wants to make sure everything is working fine so he called me. If you are installing oracle for Unix/Linux oses first time then it will confuse you. He wanted to know how to start oracle service and test it. He emailed me the following error:
ORA-27101: shared memory realm does not exist
ORA-01034: ORACLE not available

You need to add following line to oracle user’s .bash_profile file for testing purpose (once it is tested, you can give control to Oracle DBA) (login as a oracle user):
$ cd;vi .bash_profile
Append following lines:
export ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
export ORACLE_SID=orcl

Save file. Just load the above settings:
$ . .bash_profile
Start oracle Net listing service:
$ lsnrctl start
ALTERNATIVELY use full path:
$ /home/oracle/oracle/product/10.2.0/db_1/bin/lsnrctl start
Start oracle database:
$ dbstart
ALTERNATIVELY, use full path:
$ /home/oracle/oracle/product/10.2.0/db_1/bin/dbstart
Connect to Oracle database with sqlplus client (test it with scott username):
$ sqlplus "scott/tiger"
sql> select * from tab;

To shutdown Oracle database:
$ lsnrctl stop
$ dbshut

Further readings:

If you are new to Oracle try out Oracle Database 10g Documentation library, especially 2 Day DBA is fantastic document. Do not forget check out John Smiley’s “Installing Oracle Database 10g Release 2 on Linux x86” article. It will teach you the basics of installing Oracle Database 10g Release 2 on Red Hat Enterprise Linux or Novell SUSE Enterprise Linux, from the bare metal up.

HowTo: Recovering Linux Grub Boot Loader Password

in Categories CentOS, Debian Linux, Howto, Linux, RedHat/Fedora Linux, Suse Linux, Sys admin, Tips, Troubleshooting, Ubuntu Linux last updated February 20, 2006

If you have, a password protected grub boot loader and you forgot both root and grub password, then you can recover grub-boot loader password using the following method/procedure:

* Use Knoppix cd
* Remove the password from Grub configuration file
* Reboot the system
* Change the root password
* Setup new Grub password if required (optional)

Setup VMWARE Host as router for Solaris, Linux, FreeBSD, and Windows XP Guest OS

in Categories Linux, Networking, Tips last updated February 20, 2006

VMware Workstation allows the creation and execution of multiple x86 virtual computers simultaneously. Setting up VMWARE workstation host computer can be tricky. Official VMWARE workstation document recommend of creating vmnet1 and vmnet2. However, you can use eth0 and vmnet1 to route all traffic from guest operating systems via Linux host. This is quite useful:

* If you don’t want setup firewall for each operating system inside VMWARE
* Ease of IP accounting etc


VMWARE Workstation Running on P4 system with 4 GB RAM
OS: Red Hat Enterprise Linux 4.0

  • eth0:
  • vmnet1: (hostonly networking)

Step # 1: Stop vmware and service

Shutdown all VM’s and stop vmware service: # /etc/init.d/vmware stop

Force Linux to act as a router:
echo 1 > /proc/sys/net/ipv4/ip_forward

Open /etc/sysctl.conf file and
# vi /etc/sysctl.conf
Make sure IP packet forwarding is set:
net.ipv4.ip_forward = 1

Save and close the file. Above line ensures that Linux as a router after rebooting system.

Step # 2: Configure hostonly networking

You need to configure interfaces on Linux Vmware host:

  • eth0 (Bridge) : Static IP
  • vmnet1 (hostonly) : Static IP

Type following command to configure vmware:
# /usr/bin/
At networking screen, add hostonly networking for vmnet1 Keep eth0 (bridge) as it is. Assign IP to vmnet1.

Step # 3: Configure Linux Host to route traffic

Just add following IPtables rules to your iptables script so that you can route traffic between eth0 (Linux host) and vmnet1 (Guest OS):
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface vmnet1 -j ACCEPT
iptables -A INPUT -i vmnet1 -s -d -j ACCEPT

Step # 4 Configure Guest OS

  1. Start Vmware application.
  2. Select Virtual machine
  3. Click on VM
  4. Select Settings
  5. Select Ethernet1
  6. Select Network Connection: “Host-only: A private network shared with the host”
  7. Click ok to save

Power on virtual system and point router IP address to, here is sample FreeBSD rc.conf file:defaultrouter=""
ifconfig_lnc0="inet netmask"
Please note that you need to add appropriate iptables rules to allow incoming traffic to Guest os. Just add your rules to Linux host.
See also:

Why back up UNIX or Linux (or windows) systems?

in Categories News last updated February 17, 2006

This is one of main responsibilities of a system administrator. It is his/her job to safeguard data stored on the system. Data is lost by (according to IBM white paper):

  1. Hardware or System Malfunction (44%) such as Hardware equipment failures
  2. Human Error (32%) such as Accidental removal of files
  3. Software Malfunction (14%) such as Software failures or crash or File system corruption
  4. Viruses (7%)
  5. Natural Disasters (3%) such as Fire
  6. Others such as Crackers/Hackers, Unskilled employees or Dissatisfied employees

How much data can you afford to lose?
The cost of recovering data and time both are very high for example:
To recover sales and marketing data 50M data it could take 15+ business days and cost running over USD $15,000+.

Therefore, to minimize the chance of data loss you should do regular backups: Regular backups result into:

  • Minimize data loss
  • Stability
  • Keep your users happy

The exact backup procedure is different for each organization; it depends upon factors such as:

  • Number of users
  • Amount of activity

Book review: RT Essentials and The Definitive Guide to Apache mod_rewrite

in Categories News last updated February 16, 2006

RT Essentials and The Definitive “I work with a guy named Todd who suggested our department start using RT. We were already using a simple ticketing system and no one really saw a need to replace it. Even so, he kept pushing and set up his own RT server. Finally, everyone agreed to try it out. It was clumsy at first, but after a week or so, I started to get the hang of it. Six months later, I think RT is one of the best tools I\u2019ve used in my career…” Read complete review online.

The Definitive Guide to Apache mod_rewrite “The wonderful folks over at Apress sent me a preview copy of The Definitive Guide to Apache mod_rewrite. Before reading this book, I knew the very basics about mod_rewrite and only used it once or twice to mangle a URL. However, after reading, I’m amazed at everything this single module can accomplish….” Read complete review online.