Centralizing user shell history files (.sh_history)

Centralizing user shell history files (.sh_history) and enabling Date/Time Stamp on user shell history.

Detail Description of change:

1. Add the following entry to /etc/profile to save all users history file in a central location.
mkdir /var/adm/hist/; chmod 1777 /var/adm/hist/;
export HISTFILE=/etc/hist/.hist-$LOGNAME

#User shell history centralization – [14092011-150500]

export HISTSIZE=10000
export HISTFILE=/var/adm/hist/.hist-$LOGNAME
typeset -r HISTSIZE
typeset -r HISTFILE

Note:- Use of “typeset” to make those env. variables read-only and to stop being overridden by the users shell startup files.

2. Adding the following entry to /etc/environment to enable Data/Time Stamp on shell history.

How This Works
Each unix user’s shell history file will be created under “/var/adm/hist/”.

To view any user’s command history:
#su – <username> -c fc -t
For bash, the EXTENDED_HISTORY variable is not supported, so you will have to set the HISTTIMEFORMAT variable to something as follows:

# HISTTIMEFORMAT=”%h/%m – %H:%M:%S ”

Now, when you run the history command, you will have the timestamp in bash.
Example:- export EXTENDED_HISTORY=ON; history; fc -t



Following shell session will demonstrate the operation.
root@nim01:/>cd /var/adm/hist/
root@nim01:/var/adm/hist>ls -a
.              ..             .hist-ibmuser  .hist-root     .hist-sp2280
root@nim01:/var/adm/hist>ls -l .hist-*
-rw——-    1 ibmuser  staff           284 Dec 15 10:06 .hist-ibmuser
-rw——-    1 root     system        60488 Dec 15 10:06 .hist-root
-rw——-    1 sp2280   staff           270 Dec 14 13:05 .hist-sp2280
root@nim01:/var/adm/hist>cd ~
root@nim01:/>su – sp2280 -c fc -t
1       2011/12/14 13:04:23 :: alias
2       2011/12/14 13:04:32 :: echo $HISTFILE
3       2011/12/14 13:04:37 :: bash
4       ? :: ifconfig -a
5       2011/12/14 13:04:43 :: df -g
6       2011/12/14 13:04:50 :: cd /var/adm/hist
7       2011/12/14 13:04:55 :: ls -a
8       2011/12/14 13:05:03 :: cat .hist-sp2280
9       2011/12/14 13:05:09 :: cd ~
10      2011/12/14 13:05:13 :: exit

NOTE:- This has been tested under IBM AIX environment, but should be able to applied to rest of the UNIX flavors including Linux with little or no change at all.

Categories: Uncategorized

Mayonnaise jar and 2 cups of coffee

When things in your life seem almost too much to handle and When 24 hours in a day is not enough;
Remember the mayonnaise jar and 2 cups of coffee.

A professor stood before his philosophy class and had some items in front of him. When the class began, wordlessly, he picked up a very large and empty mayonnaise jar and started to fill it with golf balls.

He then asked the students if the jar was full.. They all agreed that it was.

The professor then picked up a box of pebbles and poured it into the jar. He shook the jar lightly. The pebbles rolled into the open areas between the golf balls.

He then asked the students again if the jar was full. They agreed it was.

The professor next picked up a box of sand and poured it into the jar. Of course, the sand filled up everything else.
He asked once more if the jar was full. The students responded with a unanimous ‘yes.’

The professor then produced two cups of coffee from under the table and poured the entire contents into the jar, effectively filling the empty space between the sand. The students laughed.

‘Now,’ said the professor, as the laughter subsided, ‘I want you to recognize that this jar represents your life.

The golf balls are the important things – God, family, children, health, friends, and favorite passions. Things that if everything else was lost and only they remained, your life would still be full.

The pebbles are the things that matter like your job, house, and car.

The sand is everything else — The small stuff.

‘If you put the sand into the jar first,’ he continued, ‘there is no room for the pebbles or the golf balls. The same goes for life.

If you spend all your time and energy on the small stuff, You will never have room for the things that are important to you.


Pay attention to the things that are critical to your happiness. Play with your children. Take time to get medical checkups. Take your partner out to dinner.

There will always be time to clean the house and fix the dripping tap.

‘Take care of the golf balls first — The things that really matter. Set your priorities. The rest is just sand.’

One of the students raised her hand and inquired what the coffee represented.

The professor smiled. ‘I’m glad you asked’.

It just goes to show you that no matter how full your life may seem, there’s always room for a couple of cups of coffee with a friend.’

Categories: Like

signal 11 caught by ps | segmentation fault

November 15, 2009 1 comment

If you ever came across “segmentation fault” message in linux [in my case CentOS/RHEL], you know how annoying it can be. Basically it throws every time you invoke “ps | top | killall” – i.e any process related command.
Googleing gave me couple of tips. cyberciti, took my attention.

Since “ps” started to gave me the trouble, i decided to upgrade the “ps”

“ps” comes under a package, so fist i had to locate the package name which provide “ps”.
For that again i had to locate the “ps” executable :-
[root@server1 ~]# whereis ps
ps: /bin/ps /opt/mandriva_root/bin/ps /usr/share/man/man1p/ps.1p.gz

Then i locate the package name :-
[root@server1 ~]# rpm -qf /bin/ps

The procps package contains a set of system utilities that provide system information.

To update “procps” :-
[root@server1 ~]# yum update procps

“procps” update did the trick for me.


Categories: Linux

Little help on Perl

September 28, 2009 Leave a comment

What is Perl?

From the Perl documentation:

Perl is a high-level programming language with an eclectic heritage written by Larry Wall and a cast of thousands. It derives from the ubiquitous C programming language and to a lesser extent from sed, awk, the Unix shell, and at least a dozen other tools and languages. Perl’s process, file, and text manipulation facilities make it particularly well-suited for tasks involving quick prototyping, system utilities, software tools, system management tasks, database access, graphical programming, networking, and world wide web programming. These strengths make it especially popular with system administrators and CGI script authors, but mathematicians, geneticists, journalists, and even managers also use Perl. Maybe you should, too.

  • Get the Perl manual.
    • [root@goliath ~]# man perl
  • View Perl documentation.
    • [root@goliath ~]# man perldoc
  • Perl introduction for beginners.
    • [root@goliath ~]# perldoc perlintro
  • Perl OO tutorial for beginners.
    • [root@goliath ~]# perldoc perlboot
  • Perl OO tutorial, part 1.
    • [root@goliath ~]# perldoc perltoot
  • Perl OO tutorial, part 2.
    • [root@goliath ~]# perldoc perltooc
  • Perl OO tricks and examples.
    • [root@goliath ~]# perldoc perlbot
  • Perl regular expressions quick start.
    • [root@goliath ~]# perldoc perlrequick
  • Perl regular expressions tutorial.
    • [root@goliath ~]# perldoc perlretut
  • List the modules that come pre-installed with the standard Perl package.
    • [root@goliath ~]# perldoc perlmodlib
  • Lists the optional modules that are installed in your system that don’t come with Perl by default.
    • [root@goliath ~]# perldoc perllocal
  • Check if a module is installed
    • [root@goliath ~]# perl -MTie::Hash -e 1
  • Get a list of installed modules – Using a script
    • [root@goliath ~]# perl -MFile::Find=find -MFile::Spec::Functions -Tlw -e ‘find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => 1 }, @INC’

CPAN is the Comprehensive Perl Archive Network, a large collection of Perl software and documentation. Note that CPAN is also the name of a Perl module, CPAN.pm, which is used to download and install Perl software from the CPAN archive.
Reference – http://www.cpan.org/

  • Automatic installation using the CPAN module
    • [root@goliath ~]# perl -MCPAN -e ‘install Net::DNS’
  • Installing cpan modules manually
    • unzip
    • perl Makefile.PL
    • make
    • make test
    • make install

Hope thses tip’s will help you to get on with perl.

Categories: Linux

Some book’s i value most

Here’s some of the books .. i simply can’t live with out …

  • Red Hat Certified Engineer Linux Study Guide – Michael Jang
  • Linux Administration Handbook – Evi Nemeth , Garth Snyder , Trent R. Hein
  • Open Source Web Development with LAMP – James Lee , Brent Ware
  • Using Unix – Peter Kuo
  • Beginning PHP5,Apache and MySQL Web Development – Elizabeth Naramore , Jason Gerner , Yann Le Scouarnec , Jeremy Stolz , Michael K. Glass
Categories: Linux

Vote for OrangeHRM here !

Love this application. It’s FREE and It’s open source.

Categories: Linux

Create RHEL/CentOS Boot Disk

Floppies no longer supported in RHEL/CentOS-5. So you need to create boot CD/DVD.

  • Put the RHEL/CentOS-5 DVD/first CD to CDROM/DVDROM -> mount the device.

IF you CD/DVD not get automount ->

  • First find the device -> dmesg | grep -i dvdrom -> then
  • mount the device -> mount /dev/device /mnt/destination

Locate the <images> directory from the CD/DVD contents. Get burn <boot.iso> image to CD/DVD. You can use either k3b OR cdrecord to get this done.


Categories: Linux