Linux 系统 history 命令详解
来源:互联网 发布:2017nba总决赛欧文数据 编辑:程序博客网 时间:2024/05/22 11:50
转自 http://blog.csdn.net/ichuzhen/article/details/30479435
history 命令在 Linux 系统中可以说是为我们提供了很大的便利,详细了解其用法可以有效提高工作效率。
在默认环境下,系统(以Centos 6.2为例)中默认 history 命令执行的效果是:
以上是截取的部分结果,下面来详细说说其用法:
1.命令的用法及参数usage: history [-c] [-d offset] [n] or history -anrw [filename] or history -ps arg [arg...]
参数:
n :数字,要列出最近的若干命令列表
-c :将目前的 shell 中的所有 history 内容全部消除
-a :将目前新增的 history 指令新增入 histfiles 中,若没有加 histfiles ,则预设写入 ~/.bash_history
-r :将 histfiles 的内容读到目前这个 shell 的 history 记忆中
-w :将目前的 history 记忆内容写入 histfiles
重复以前的指令:
history 命令的用途确实很大,但需要小心安全的问题,尤其是 root 的历史纪录档案,因为这将很多的重要资料在执行的过程中会被纪录在 ~/.bash_history 当中,需要使用过程中恰当的管理。
2.使用 HISTTIMEFORMAT 显示时间戳在 /etc/bashrc 中编辑:
这个功能只能用在当 HISTTIMEFORMAT 这个环境变量被设置之后,之后的那些新执行的 bash 命令才会被打上正确的时间戳。在此之前的所有命令,都将会显示成设置 HISTTIMEFORMAT 变量的时间。
3.使用 HISTSIZE 控制历史命令记录的总行数
在 /etc/bashrc 中编辑:
如果你想禁用 history,可以将 HISTSIZE 设置为 0。
4.使用 HISTFILE 更改历史文件名称
默认情况下,命令历史存储在 ~/.bash_history 文件中。
在 /etc/bashrc 中编辑:
5.使用 HISTCONTROL 从命令历史中剔除连续重复的条目
在 /etc/bashrc 中编辑:
6.使用 HISTCONTROL 强制 history 不记住特定的命令
在 /etc/bashrc 中编辑:
- Linux 系统 history 命令详解
- Linux 系统 history 命令详解
- linux history 命令详解
- linux history 命令详解
- 【linux】history命令详解
- Linux下history命令详解
- Linux下history命令详解
- [Linux]history命令用法详解
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux下history命令详解---转载
- Linux中history历史命令使用方法详解
- linux历史命令详解(history)----shell学习
- Linux中history历史命令使用方法详解
- linux history 命令 禁用history
- 设置linux系统history相关变量,命令时间、保存history条数,多session共享history
- tcp/ip学习笔记--第7章ping、8章traceroute
- 验证
- C++软件开发中“时间”相关操作全攻略
- 腾讯云 Ubuntu 安装并远程访问 MySQL
- 20171031
- Linux 系统 history 命令详解
- Jsp的九大对象,七大动作,三大指令
- 2017-10-31
- word转出图片(使用免费插件)02
- 学习php单利模式
- 复杂度分析之斐波那契数列
- Python 相关环境配置-Android,Python等
- idea Maven运行报错:-Dmaven.multiModuleProjectDirectory system propery is not set.
- Primes or Palindromes? CodeForces