本文摘自PHP中文网,作者angryTom,侵删。

linux查看历史命令
Linux中,bash输入的历史记录,会存在.bash_history文件中。 history 命令主要用于显示历史指令记录内容, 下达历史纪录中的指令 。
使用:首先打开Terminal(终端);然后输入history,敲回车;屏幕将展示1000条历史命令。
推荐:【Linux视频教程】
命令语法:
1 2 3 | history [n]
history [-c]
history [-raw] histfiles
|
参数:
1 2 3 4 5 | n :数字,要列出最近的 n 笔命令列表
-c :将目前的shell中的所有 history 内容全部消除
-a :将目前新增的history 指令新增入 histfiles 中,若没有加 histfiles,则预设写入 ~/.bash_history
-r :将 histfiles 的内容读到目前这个 shell 的 history 记忆中
-w :将目前的 history 记忆内容写入 histfiles。
|
常用命令:
1 2 3 4 5 6 7 8 9 10 11 12 | history N 显示最近的N条命令,例如history 5
history -d N 删除第N条命令,这个N就是前面的编号,例如history -d 990
history -c 清空命令历史
history -a 将当前会话中的命令历史写入指定文件
echo $HISTFILE 使用此命令查看环境变量
# echo $HISTFILE
/root/.bash_history
echo $HISTFILESIZE 查看最大保存数目
export HISTTIMEFORMAT=’%F %T ’ 让history可以有时间戳显示
|
以上就是linux查看历史命令的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
如何使用bandwidthpackageitemtype共享带宽包描述信息
Linux中用户和用户组的详细介绍
压缩tar.gz命令是什么
无法远程连接Linux服务器的解决方法
Linux环境下如何编译和执行c程序?(详解)
如何在Linux环境下安装docker
Linux如何联网
Linux无法输入中文
如何授权、撤销安全组规则以及加入、离开安全组
mac和Linux的区别是什么?
更多相关阅读请进入《Linux》频道 >>
转载请注明出处:木庄网络博客 » linux查看历史命令