linux history command

2019-04-17 08:00发布

If I type history command, I can view only 1000 lines. I want to view more than that. It will be nice If I can view all commands typed between certain dates or months.

Is this possible? If so, how to do this?

标签: linux shell
2条回答
Emotional °昔
2楼-- · 2019-04-17 08:27

add some commands to .bash_logout to organize your history files

e.g.

today=`date +%y%m%d`
cp .bash_history >.bash_history_$today
echo >.bash_history  # to clear out file

However, one problem: .bash_logout doesn't seem to run in a lot of X-based environments. On a ssh account, such as with a virtual server, it works fine.

查看更多
放荡不羁爱自由
3楼-- · 2019-04-17 08:30

You want to set the bash variables HISTSIZE and HISTFILESIZE in your .bashrc.

HISTSIZE determines how many comands are retained in history. HISTFILESIZE determines how many lines of history are stored in the file in which they are persisted, usually .bash_history.

查看更多
登录 后发表回答