`
xitong
  • 浏览: 6177139 次
文章分类
社区版块
存档分类
最新评论

关于Unix/Linux下查看命令行历史记录(history/.bash_history)

 
阅读更多

1.vi .bash_history

关于.bash_history的配置

export HISTCONTROL=ignoreboth

Don’t save duplicates

export HISTSIZE=10000

这个是针对history命令的设置,The number of commands to remember in the command history. The default value is 500.

export HISTFILESIZE=10000

这个是针对history文件(.bash_history)的设置,The maximum number of lines contained in the history file. When this variable is assigned a value, the his-tory file is truncated, if necessary, by removing the oldest entries, to contain no more than that number of lines. The default value is 500. The history file is also truncated to this size after writing it when an interactive shell exits.
export HISTIGNORE='ls'

A colon-separated list of patterns used to decide which command lines should be saved on the history list.Each pattern is anchored at the beginning of the line and must match the complete line

以上的关于history的说明都可以使用man bash查的到,如果想要让你的配置永久生效,可以把export命令写到.bash_profile或者全局配置文件/etc/profile里

2.history

模糊查询,history | grep -i "xxx"

[oracle@bej301441 ~]$ history | grep -i "FND"
34 2012-07-04 01:29:15 history | grep -i "FND"
35 2012-07-04 01:29:30 FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct PT_CUSTOM_FUC.ldt FND_FORM_CUSTOM_RULES function_name="INV_INVTOMAI"
36 2012-07-04 01:29:33 history | grep -i "FND"
[oracle@bej301441 ~]$

如何让history可以有时间戳显示

# export HISTTIMEFORMAT='%F %T '

....

1027 2012-07-04 01:12:53 ls /etc/bash*
1028 2012-07-04 01:13:17 vi /etc/bashrc
1029 2012-07-04 01:16:04 history
[oracle@bej301441 ~]$

清除history记录

[oracle@bej301441 ~]$ history -c
[oracle@bej301441 ~]$ history
32 2012-07-04 01:20:40 history
[oracle@bej301441 ~]$
注:清除history之后,.bash_history里仍会有历史记录

如何不让系统记录历史命令

# export HISTSIZE=0
# history
# [Note that history did not display anything]

3.使用Control+R来搜索命令

命令行中输入Control+R,然后输入过往命令的key word,你就很容易找到以前执行过的命令了

(reverse-i-search)`FND': FNDLOAD apps/apps 0 Y DOWNLOAD $FND_TOP/patch/115/import/affrmcus.lct PT_CUSTOM_FUC.ldt FND_FORM_CUSTOM_RULES function_name="INV_INVTOMAI"


转载请注明出处:http://blog.csdn.net/pan_tian/article/details/7715436

======EOF======


分享到:
评论

相关推荐

    Pro.Bash.Programming.Scripting.the.GNULinux.Shell.2nd.Edition

    This book is perfect for all beginning Linux and Unix system administrators who want to be in full control of their systems, and really get to grips with Bash programming. What youll learn Use the...

    Shell.Programming.in.Unix.Linux.and.OS.X.4th.Ed

    Shell Programming in Unix, Linux and OS X is a thoroughly updated revision of Kochan and Wood’s classic Unix Shell Programming tutorial. Following the methodology of the original text, the book ...

    Linux高级bash编程

    高级bash编程 高级Bash脚本编程指南(一) 目录 ++++ 第一部分. 热身 1. 为什么使用shell编程 2. 带着一个Sha-Bang出发(Sha-Bang指的是#!) 2.1. 调用一个脚本 2.2. 初步的练习 第二部分. 基本 3. 特殊...

    Advanced Bash-Scripting Guide <>

    manview: 查看格式化的man 页 12-27. 使用 cpio 来拷贝一个目录树 12-28. 解包一个 rpm 归档文件 12-29. 从 C 文件中去掉注释 12-30. Exploring /usr/X11R6/bin 12-31. 一个"改进过"的 strings 命令 12-32. 在一个...

    unix power tools

    1.1 What's Special About UNIX?............................................................................................................2 ...............................................................

    linux常用命令

    linux网络服务(dns,dhcp,ftp,samba,nfs,apache,mail....) ldap,samba windows--vmware workstation(hyper-v)--centos 6.4--putty,vnc ibm--aix==&gt;ibm p/z/i ... .bash_history .bashrc install.log.syslog .ssh

    shell基础

    将wins下的.sh格式转换成linux可以执行的脚本:dos2unix 文件名 历史命令:history [选项] [历史命令保存文件]。;-c 清空历史命令。;-w 把缓存中历史命令写入到历史命令保存文件 ~/.bash_history 历史命令默认保存...

    SimIt-ARM-3.0 ARM指令模拟器

    SimIt-ARM-3.0 给予命令行ARM指令模拟器,短小精悍,是研究ARM处理器的好工具,该模拟器既可以运行用户级别的ELF程序,又可以模拟运行Linux操作系统;提供了简单易用的调试命令,可以逐条跟踪指令的执行。 SimIt-...

    cmd操作命令和linux命令大全收集

    CMD命令:开始-&gt;运行-&gt;键入cmd或command(在命令行里可以看到系统版本、文件系统版本) 命令大全 1. gpedit.msc-----组策略 2. sndrec32-------录音机 3. Nslookup-------IP地址侦测器 ,是一个 监测网络中 DNS...

    Pro Bash Programming 2015

    The bash shell is a complete programming language, not merely a glue to combine external Linux commands. By taking full advantage of shell internals, shell programs can perform as snappily as ...

    glob:Glob for C ++ 17

    Unix样式的路径名模式扩展目录快速开始该库有两种版本: 两个文件版本: glob.h和glob.cpp single_include/单个头文件版本没有外部依赖-仅是标准库需要C ++ 17 ...)) { // e.g., .bash_history, .bashrc // do somethi

    Pro Bash Programming

    The bash shell is a complete programming language, not merely a glue to combine external Linux commands. By taking full advantage of shell internals, shell programs can perform as snappily as ...

    Bash Pocket Reference(O'Reilly,2ed,2016)

    It’s simple: if you want to interact deeply with Mac OS X, Linux, and other Unix-like systems, you need to know how to work with the Bash shell. This concise little book puts all of the essential ...

    你需要知道的linux基础编程(一)

    history 查看历史命令 ctrl + p 在历史的命令记录里向上滚动 ctrl + n 在历史的命令记录里向下滚动 ctrl + b 光标向前移动 ctrl + f 光标向后移动 ctrl + a 光标直接到命令行首 ctrl + e 光标直接到命令行末 ...

    2009 达内Unix学习笔记

    集合了 所有的 Unix命令大全 登陆服务器时输入 公帐号 openlab-open123 telnet 192.168.0.23 自己帐号 sd08077-you0 ftp工具 192.168.0.202 tools-toolss 老师测评网址 http://172.16.0.198:8080/poll/ 各个 ...

    replicant:Android 调试桥 (ADB) 的 REPL

    replicant需要 Ruby 1.9 或更新版本以及兼容 UNIX/Linux 的 shell,例如bash或zsh 。 为了获得最佳体验,我强烈建议安装来获取命令历史记录和制表符全,尽管这不是必需的。 replicant集成了rlwrap自动; 只需安装它就...

    bash袖珍参考手册

    If you're a user or programmer of any Unix variant, or if you're using bash on Windows, you'll find this pocket reference indispensable. This book covers: Invoking the Shell Syntax Functions ...

    shell程序实验详解

     熟悉使用Linux下的软件开发工具,例如gcc、gdb和make。  在编写系统应用程序时熟练使用man帮助手册。  学习使用POSIX/UNIX系统调用、对进程进行管理和完成进程之间的通信,例如使用信号和管道进行进程间通信...

    covermyass:用于覆盖UNIX系统上的曲目的Shell脚本。 设计用于在退出受感染的服务器之前进行笔测试“覆盖轨道”阶段。 或者,永久禁用系统日志以进行后期开发

    covermyass:用于覆盖UNIX系统上的曲目的Shell脚本。 设计用于在退出受感染的服务器之前进行笔测试“覆盖轨道”阶段。 或者,永久禁用系统日志以进行后期开发

Global site tag (gtag.js) - Google Analytics