1752451 Members
6641 Online
108788 Solutions
New Discussion юеВ

Re: History command

 
SOLVED
Go to solution
Torsten.
Acclaimed Contributor

Re: History command

Again, if you set it to be in directory /root


this directory

/root

must exist!



Does it???

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
R.O.
Esteemed Contributor

Re: History command

...apart from the fact that directory "/root" must exist, if you don't set the variables in your ".profile", when you logout you lost the changes in the variables. Put these lines in your .profile:

export HISTFILE=/.sh_history (if your home is "/"; is it is /root and it exists, put /root/.sh_history)
export HISTFILE=5000

Then, try again by logout/login.

Regards,
"When you look into an abyss, the abyss also looks into you"
Pete Randall
Outstanding Contributor

Re: History command

What shell are you using?


Pete

Pete
Bill Hassell
Honored Contributor
Solution

Re: History command

There is a dumb bug in root's shell that will not create the history file automatically. Ordinary users are fine but just in case, the commands (which I put in /etc/profile so everyone gets a history file) are:

umask 022
touch $HOME/.sh_history
export HISTORY=$HOME/.sh_history
export HISTFILE=5000




>> $HOME=/

A very bad default location for root's $HOME. Create a separate /root directory and move all of root's files to /root, then change /etc/passwd so the $HOME directory is /root and not /, like this:

root:*:0:3:root user:/root:/sbin/sh

If you move root's $HOME on every Unix platform you have, you may avoid a total disaster in joining the rm -r * club.


Bill Hassell, sysadmin
Torsten.
Acclaimed Contributor

Re: History command

I agree, it is IMHO a good practice to change root's home from / to something like /root.

If you simply export these variables and then logout, the change is gone. You need to write it to .profile to make it permanent and working.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
DKC
Advisor

Re: History command

Hi,

# history
sh: fc: Cannot access or open the history file.
# pwd
/
#
#

after exporting HISTFILE AND HISTSIZE logout than login same problem. You tell me from my side what infomation required, so history command work.

Dev
Torsten.
Acclaimed Contributor

Re: History command

Meanwhile many people wrote the very same several times - just follow the advises.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
DKC
Advisor

Re: History command

Hi,

# echo $SHELL
/sbin/sh
m using shell.

Regards,
Dev
R.O.
Esteemed Contributor

Re: History command

"after exporting HISTFILE AND HISTSIZE logout than login same problem"

If you do not put these in root's ".profile" you will lose the variables each time you log out of the system......

Regards,
"When you look into an abyss, the abyss also looks into you"
Torsten.
Acclaimed Contributor

Re: History command

As said, add

export HISTFILE=/root/.sh_history
export HISTSIZE=5000

to your .profile and do

# mkdir /root

logout and back in.


To change root's home, modify /etc/passwd.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!