- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- re: root shell history
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 02:53 AM
06-09-2005 02:53 AM
how do I enable the shell history for the root user?
setting up a new HPUX RP3440 server and can't seem to figure this one out.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 02:56 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 02:57 AM
06-09-2005 02:57 AM
Re: re: root shell history
# echo $SHELL
/sbin/sh
# set -o vi
add this to your root .profile
EDITOR=vi
PS1="$(hostname):\$PWD\# "
HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`
HISTSIZE=1000
export EDITOR HISTFILE PS1 HISTSIZE
Regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 02:58 AM
06-09-2005 02:58 AM
Re: re: root shell history
HISTSIZE=500
HISTFILE=$HOME/.sh_history
export HISTFILE HISTSIZE
Do it in /etc/profile
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 02:58 AM
06-09-2005 02:58 AM
Re: re: root shell history
Just add these two lines in root's .profile.
export HISTFILE="/Path_to_file/$LOGNAME"
export HISTSIZE=1000
Remove hash from last line in .dtprofile file lying in root's home directory for xterm.
DTSOURCEPROFILE=true
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 03:19 AM
06-09-2005 03:19 AM
Re: re: root shell history
after the previous modifications in the .profile:
touch /.sh_history
exit from the system and relog in it
Enrico
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 05:36 AM
06-09-2005 05:36 AM
Re: re: root shell history
HST=`hostname`
USR=`who -um | awk '{print $1}'`
NAME=`whoami`# Set History File
HISTFILE=/home/root/.sh_history_"${HST}"_"${USR}"-as-"${NAME}"_`date +%y%m%d.%
H%M%S_$$`
export HISTFILE
As this example shows, each history file has the $USER name associated with it plus they are time/date stamped.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 05:40 AM
06-09-2005 05:40 AM
Re: re: root shell history
# Set up logging
HISTFILE=${HOME}/.sh_history_`who am i|awk '{ print $1}'`
export HISTFILE
print -s "### login at `/usr/bin/date` ###"
#date >>$HISTFILE
HISTSIZE=50000
export HISTSIZE
As well, testing timestamping of all commands:
#trap to timestamp all commands
trap 'date "+# %c" | read -s' debug
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 05:47 AM
06-09-2005 05:47 AM
Re: re: root shell history
export PS1="$LOGNAME@`hostname`:\$PWD# "
export HISTFILE=.sh_history
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 08:55 PM
06-09-2005 08:55 PM
Re: re: root shell history
Then, specially for root, donnot change the shell to a binary that is not in the root-filesystem. This shell is used in the single-user mode, where only the root-filesystem is available. Hence, donnot change this shell to something that needs libraries outside the root-filesystem...
(this is based on experience, it ruins your day if single-user does not work once you need it.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 09:21 PM
06-09-2005 09:21 PM
Re: re: root shell history
obviously don't touch the sh!!!
just insert in the .profile
export HISTFILE=.sh_history
export HISTSIZE=400
export EDITOR=vi
save the file, loguot and login again:
you will have a history file called .sh_history that takes 400 command in history
and you can you also the esc+k command to recall the commands
Regds
LF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 09:57 PM
06-09-2005 09:57 PM
Re: re: root shell history
set -o $EDITOR
HISTFILE="/root/.sh_history
HISTSIZE=1000
Put this in /etc/profile file and login in new terminal. It will get effect.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 10:53 PM
06-09-2005 10:53 PM
Re: re: root shell history
but esc-k still does not work...
i have stripped the down the .profile in /home/root to this
export HISTFILE=.sh_history
export HISTSIZE=400
export EDITOR=vi
any other reason(s) it doesn't work?
I'm using terminal emulation software - SmarTerm Essential v9.0, could this be causing a problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 11:02 PM
06-09-2005 11:02 PM
Re: re: root shell history
Possibally there is one of the case.
1. define full path to .sh_history & ensure you can write that file as that user.
2. If your this session uses Graphical display then check .dtprofile in that user's home directory & uncomment last line.
3. Your Shell is not posix as it works only in Posix Shell. Confirm by "cat /etc/passwd |grep your_user". The shall displayed should be /usr/bin/sh in the end of the line.
HTH,
Devender
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 11:03 PM
06-09-2005 11:03 PM
Re: re: root shell history
Check if the last line is uncommented in the $HOME/.dtprofile
DTSOURCEPROFILE=true
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 11:07 PM
06-09-2005 11:07 PM
Re: re: root shell history
set -o vi
so that esc+k will get effect.
Add, just close that session and restart the new session. It will get effect.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 11:16 PM
06-09-2005 11:16 PM
Re: re: root shell history
#ksh -o vi is not required here. Allthough works.
You can check wheather your two veriales are set by & home of root is generally / not /home/root in HP.
#set |grep -i hist
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 11:40 PM
06-09-2005 11:40 PM
Re: re: root shell history
export HISTFILE=$HOME/.sh_history
As has been mentioned several times in the HP-UX forums, / is a very, very bnad place to have root's $HOME directory. And if HISTFILE=.sh_history, it will only work when you are in the $HOME directory...some root profiles may cd somewhere else...
And you might as well setup a size and an editor:
export HISTSIZE=500
export EDITOR=/usr/bin/vi
Put these lines in /etc/profile and everyone will have .sh_history setup. NOTE: root is unique in that if $HOME/.sh_history does NOT already exist, it will not be created (other users will have .sh_history created though). Just do this as root:
touch $HOME/.sh_history
Now, everything will work--UNLESS you are using Xwindows. Unfortunately, Xwindows defaults to NO /eetc/profile and NO .profile execution for local terminal emulators such as xterm, hpterm and dtterm. To fix this:
echo "*loginShell:true" >> $HOME/.Xdefaults
This solves the rather crazy CDE method of specifying DTSOURCEPROFILE which is only half correct (never sources /etc/profile, only .profile). The loginShell setting makes the terminal emulators work like all classic telnet or ssh logins.
Note also that just typing these variables on the command line won't enable the shell history. It has to be set during /etc/profile or .profile execution.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2005 11:49 PM
06-09-2005 11:49 PM
Re: re: root shell history
You NEVER EVER put the "root" login directory in any place than UNDER / as a regular directory. You can put it in a directorty called /root or /potato, but you NEVER put root under any OTHER MOUNTED directory. PERIOD!
POST the output from the following to VERIFY where the root login directory is:
grep root /etc/passwd
In /etc/profile, I have this at the end:
export HISTFILE=~/.sh_history_`logname`
export HISTSIZE=500000
export PS1="[`logname`@`hostname` "'${PWD}]# '
export EDITOR=vi
set -o vi
As for wether or not your SmarTerm-less software is screwing with "ESC K", try openning a command prompt in WINDOZE and telnet'ing to your box without the use of SmarTerm-less.
If it doesn't work, then please post the output of:
env
stty -a
set
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 12:02 AM
06-10-2005 12:02 AM
Re: re: root shell history
running the set | grep -i hist returns nothing...
really puzzeled, I even copied the /etc/profile and /home/root/.profile scripts from out live servers and they don't work either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 12:21 AM
06-10-2005 12:21 AM
Re: re: root shell history
env
set
grep root /etc/passwd
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 12:26 AM
06-10-2005 12:26 AM
Re: re: root shell history
root:3W6KOwzzuMvzg:0:3::/:/sbin/sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 12:27 AM
06-10-2005 12:27 AM
Re: re: root shell history
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 12:31 AM
06-10-2005 12:31 AM
Re: re: root shell history
Your parameters are not exported. I still insist to check all these.
1. define full path to .sh_history & ensure you can write that file as that user.
2. If your this session uses Graphical display then check .dtprofile in that user's home directory & uncomment last line.
3. Your Shell is not posix as it works only in Posix Shell. Confirm by "cat /etc/passwd |grep root". The shall displayed should be /usr/bin/sh in the end of the line.
HTH,
Devender
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 12:32 AM
06-10-2005 12:32 AM
Re: re: root shell history
live free or die
harry d brown jr