bash linux服务器上保存命令历史的所有位置在哪里
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39877237/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where are all the locations where command history is saved on linux server
提问by Colin
I know that the history can be seen by just running the command 'history' but I am wondering where else commands may be stored.
我知道只需运行命令“history”就可以看到历史记录,但我想知道其他命令可能存储在哪里。
回答by mrks
You can check the location of the (only) history file of your shell using echo $HISTFILE
. Most likely, this is what you are looking for.
您可以使用echo $HISTFILE
. 最有可能的是,这就是您正在寻找的。
Single commands may store additional information. For example, sudo
may store the commands executed as root in the system log. If you run the mysql CLI, it would store its history (by default) in ~/.mysql_history
.
单个命令可以存储附加信息。例如,sudo
可以将作为 root 执行的命令存储在系统日志中。如果您运行 mysql CLI,它会将其历史记录(默认情况下)存储在~/.mysql_history
.
回答by chepner
Command history is a shell-specific feature stored on a per-user basis. The history
command displays what the current instance has in memory.
命令历史是基于每个用户存储的特定于 shell 的功能。该history
命令显示当前实例在内存中的内容。
The history
command takes options -r
, -w
, and -a
to read from, write to, or append to (respectively) a default history file, which is ~/.bash_history
or the name stored in the HISTFILE
variable.
该history
命令采用 options -r
、-w
和-a
来读取、写入或附加到(分别)默认历史文件,该文件是~/.bash_history
或 存储在HISTFILE
变量中的名称。
Generally speaking, though, the shell could be configured to read and write history to an arbitrary file; there's no way to know where history could be stored without being familiar with a particular user's shell configuration files or scripts.
不过,一般来说,shell 可以配置为读取和写入任意文件的历史记录;如果不熟悉特定用户的 shell 配置文件或脚本,就无法知道历史记录的存储位置。
回答by Chim Chimz
By default it's stored in ~/.bash_history
默认情况下它存储在 ~/.bash_history