- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: enabling history file for root
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
Discussions
Discussions
Forums
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
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
тАО10-23-2010 12:33 PM
тАО10-23-2010 12:33 PM
enabling history file for root
I enabled history variable.But i can't see previous command.Help to enable history.
- Tags:
- history
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2010 02:17 PM
тАО10-23-2010 02:17 PM
Re: enabling history file for root
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2010 02:45 PM
тАО10-23-2010 02:45 PM
Re: enabling history file for root
export HISTSIZE=100
i have exported. How i can get back the previous command.Wat key combination should use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2010 03:09 PM
тАО10-23-2010 03:09 PM
Re: enabling history file for root
You also have to select vi or emacs editing with "set -o vi".
For vi, you use Esc k.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2010 08:34 PM
тАО10-23-2010 08:34 PM
Re: enabling history file for root
you can use vi keys to get and edit the commands
Esc
k - go up ==> previous command
j= go down
you may use #history to get last 10 command list
#history -20 will show you last 20 commands
Regards,
Sooraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2010 09:17 AM
тАО10-24-2010 09:17 AM
Re: enabling history file for root
Why I dont know.
I have exported both the variable.This is for root only.For all other users its working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2010 12:50 PM
тАО10-24-2010 12:50 PM
Re: enabling history file for root
> export HISTSIZE=100
First, this command should be stored on /etc/profile so all users have the benefit of a working history. However, never use /.sh_history. Instead, you specify the HOME directory so it works for all users:
export HISTFILE=$HOME/.sh_history
Second, the HISTSIZE should be much, much larger, especially for root. Set it to 5000 or 10000 so you can see what was done several weeks or months ago.
As a side note, / is the worst possible directory for root's $HOME. This is the most important directory in Unix and if you make a mistake like cd'ing to a misspelled directory, miss the error message and then issue rm -r or chmod -R or chown -R, you will destroy the ENTIRE system.
If root's HOME is /, create a directory called /root, chmod 755 /root and then move all the root files to /root. Now change root's HOME in /etc/passwd -- use vipw as a good habit for editing the passwd file.
> set -o vi
Include this in /etc/profile so all users have a consistent setting for command line recall and editing. Individual users can change this in their local .profile files.
> Esc K is not working. More over .sh_history file is not updated. It always shows zero bytes.
After you move root's $HOME and add the above 3 lines to /etc/profile, you need to logout and log back in, at which point the shell history will work. NOTE: this assumes that you have not broken the root shell by changing it to something other than /sbin/sh. If you have, IMMEDIATELY change it back to /sbin/sh using:
chsh root /sbin/sh
If you use some other shell (/bin/ksh, /usr/local/bin/bash, etc), root will be unable to do anything with the system in single user mode, not a good situation.
Bill Hassell, sysadmin