The history command, which is a command typed at the command line before the login session.
There are two ways to query history commands in Linux
- History command
- Hidden files in the current user directory. Bash_history
I. History
Scope
- Currently logged in user
- Previous logon session and current logon session
This means: History queries the commands that are typed by the current logged-on user during the current session and before the logon session.
How history works
Linux maintains a history command memory cache, the command currently typed by the session is written to this cache, and the history command recorded in the. Bash_history is loaded into the cache when the current user logs in.
[[email protected] ~]$ history1 su - root2 ps -aux|grep tserver3 cd /opt/server/tserver4 cd Bin/5 cd tserver6 tail -f log/hplugin/tserver_plugin_hik.log 7 tail -f log/cluster.log8 less log/cluster.log9 cd ..
History has a lot of parameters, here only the next-c parameter. -C: Used to clear the memory cache of history, but does not delete the. bash_history historical command.
Two. View. bash_history
[[email protected] ~]$ cat ~/.bash_historysu - rootps -aux|grep tdacd /opt/hikserver/tdacd Bin/cd tdatail -f log/hplugin/tda_plugin_hik.log tail -f log/cluster.logless log/cluster.logcd ..
Configure record History command bar number
In the "/etc/profile" configuration file, you can configure whether the historical Operations command is logged.
Vi/etc/profile
HOSTNAME=`/usr/bin/hostname 2>/dev/null`HISTSIZE=1000
You can change the size of the record History command by modifying the size of the histsize. If you change to 0, the history command is not recorded. Default is 1000 bar
History commands in Linux