您好,欢迎访问一九零五行业门户网

linux查看历史命令

linux查看历史命令
linux中,bash输入的历史记录,会存在.bash_history文件中。 history 命令主要用于显示历史指令记录内容, 下达历史纪录中的指令 。
使用:首先打开terminal(终端);然后输入history,敲回车;屏幕将展示1000条历史命令。
推荐:【linux视频教程】
命令语法:
history [n]history [-c]history [-raw] histfiles
参数:
n :数字,要列出最近的 n 笔命令列表-c :将目前的shell中的所有 history 内容全部消除-a :将目前新增的history 指令新增入 histfiles 中,若没有加 histfiles,则预设写入 ~/.bash_history-r :将 histfiles 的内容读到目前这个 shell 的 history 记忆中-w :将目前的 history 记忆内容写入 histfiles。
常用命令:
history n 显示最近的n条命令,例如history 5 history -d n 删除第n条命令,这个n就是前面的编号,例如history -d 990 history -c 清空命令历史 history -a 将当前会话中的命令历史写入指定文件 echo $histfile 使用此命令查看环境变量# echo $histfile /root/.bash_historyecho $histfilesize 查看最大保存数目 export histtimeformat=’%f %t ’ 让history可以有时间戳显示
以上就是linux查看历史命令的详细内容。
其它类似信息

推荐信息