can't see command history in linux

I have a oracle db server set up with a user called "oracle". when I run "history" command it gives me nothing. Is there a way to enable history for this user?

[oracle@palmdale:/home/oracle]history
1       history | grep OSWatcher
2       history
3       ls -alth
[oracle@palmdale:/home/oracle]cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
Jason YuAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason YuAuthor Commented:
the shell this user uses is ksh.


[oracle@palmdale:/home/oracle]cat /etc/passwd | grep oracle
oracle:x:500:500::/home/oracle:/bin/ksh
[oracle@palmdale:/home/oracle]
0
jmcgOwnerCommented:
History is normally kept just for interactive sessions. Are you expecting to be able to see the commands executed on this account across all invocations? There are other tools you might be able to use to trace activity on this account.
0
omarfaridCommented:
It seems that you are not showing the oracle user in /etc/passwd. Are you sure about the oracle user and the login shell?

Any way, you need to make sure that env variable HISTSIZE is set:

echo $HISTSIZE

if not set, then add below line to oracle's user .profile file in home dir:

HISTSIZE=100 ; export HISTSIZE

If you are looking for reusing or knowing the commands used in previous login sessions then the file .sh_history should be there in the oracle's user home dir.

To recall  / edit previous commands, you set env variable EDITOR or VISUAL :

EDITOR=vi ; export EDITOR
VISUAL=vi ; export VISUAL

Alternatively, run

set -o vi

Add above to .profile or  .kshrc files

Then from command prompt you can use the vi commands to scroll / edit previous commands after pressing ESC key to be in vi command mode.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jason YuAuthor Commented:
I don't have .profile under the oracle home folder:

$ ls -alth
total 24K
-rw-------  1 oracle oinstall   44 May 19 20:06 .sh_history
drwx------. 2 oracle oinstall 4.0K May 19 20:03 .
drwxr-xr-x. 5 root   root     4.0K May 14 23:49 ..
-rw-r--r--. 1 oracle oinstall   18 Jul  9  2013 .bash_logout
-rw-r--r--. 1 oracle oinstall  176 Jul  9  2013 .bash_profile
-rw-r--r--. 1 oracle oinstall  124 Jul  9  2013 .bashrc
$
0
omarfaridCommented:
You can create the .profile file yourself. But are you sure that login shell is ksh? from the listing above it indicates that login shell could be bash
0
Jason YuAuthor Commented:
In fact, the oracle user has two profile files. One is .bash_profile, the otehr is .profile. what is the difference between these two files?

[oracle@palmdale:/home/oracle]ls -alth | grep profile
-rw-r--r--   1 oracle oinstall   222 Sep 18  2014 .bash_profile
-rw-r--r--   1 oracle oinstall  1.5K Jan 30  2007 .profile
[oracle@palmdale:/home/oracle]cat /etc/passwd | grep oracle
oracle:x:500:500::/home/oracle:/bin/ksh
[oracle@palmdale:/home/oracle]
0
Jason YuAuthor Commented:
Here is the content of the .profile.

export PATH LIBPATH ORACLE_HOME
PS1='[$LOGNAME@$PWD]'
if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.

set history 100
if [ -t 0 ]; then
   stty intr ^C
fi
if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.
if [ -z "$REMOTEHOST" ]
then
DISPLAY=`hostname`:0.0; export DISPLAY
else
DISPLAY="$REMOTEHOST":0.0; export DISPLAY
fi
#DISPLAY=localhost:1; export DISPLAY
#xhost + localhost

ORACLE_BASE=/usr/orasw; export ORACLE_BASE
export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1
export NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"
#ORACLE_TERM=xterm; export ORACLE_TERM
LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
#LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/network/lib:$ORACLE_HOME/jdbc/lib:/usr/local/lib
export LD_LIBRARY_PATH
export TERM=vt100
. /home/oracle/.db102
#. /home/oracle/.db10103
PATH=/usr/bin:/bin:/usr/ccs/bin:/usr/ucb:/usr/local/bin:$ORACLE_HOME/bin:/usr/X11R6/bin:/usr/bin/X11:$HOME/bin:/usr/java/j2sdk1.4.2_06/bin:.
export PATH
alias l='ls -atl | more'
alias h=history
alias greenwin='xterm -sb -bg aquamarine&'
alias bluewin='xterm -sb -bg lightblue&'
alias print_small='qprt -z1 -s lineprinter -p17 -P5SI_OPS_1'
#alias sid='echo $ORACLE_SID'
stty erase ^?
set -o vi
umask 022
export ORACLE_TERM=xterm
export CVUQDISK_GRP=oinstall
export TEMP=/tmp
export TMPDIR=/home/tmpdir
~

Open in new window

0
omarfaridCommented:
Please add

HISTSIZE=100 ; export HISTSIZE

to .profile at the end of the file

To answer your question about .profile and .bash_profile, basically .profile is used by sh , ksh and bash when the user login to system.

 .bash_profile is used by bash only at login only, but since bash is not the login shell then it will not be used.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.