⑴ 请问linux的history指令如何显示全部的历史记录
方法步骤如下:
1、首先打开linux客户端。
⑵ Linux中history命令怎么用
调用linux history,你需要使用!历史编码
用法:
1.你在shell中输入history
或者你查找特定的历史记录 history | grep '关键词'
2.查看你要重复执行的命令,记下它前面的编码。例如 350 ps -aux | more
3.!350 调用ps -aux | more 命令
⑶ linux怎么清除history记录
1、history -a将当前shell会话的历史命令追加到命令历史文件中,命令历史文件是保存历史命令的配置文件。
⑷ 如何查看linux上的历史执行命令
1>History命令语法: [test@linux]# history [n] [test@linux]# history [-c] [test@linux]# history [-raw] histfiles 参数: n :数字,要列出最近的 n 笔命令列表 -c :将目前的shell中的所有 history 内容全部消除 -
⑸ 如何使用history的命令
在家目录内的 .bash_history 里! 不过,需要留意的是,~/.bash_history 记录的是前一次登陆以前所运行过的命令,而至于这一次登陆所运行的命令都被缓存在内存中,当你成功的注销系统后,该命令记忆才会记录到 .bash_history 当中!
三、调用历史命令
接下来学习history历史命令的用法。
代码如下:
history 〔n〕
〔root@jb51 Desktop〕#history 〔-c〕
〔root@jb51 Desktop〕#history 〔-raw〕 histfiles
选项与参数:
n :数字,意思是要列出最近的 n 条命令行表的意思!
-c :将目前的 shell 中的所有 history 内容全部消除
-a :将目前新增的 history 命令新增入 histfiles 中,若没有加 histfiles ,
则默认写入 ~/.bash_history
-r :将 histfiles 的内容读到目前这个 shell 的 history 记忆中;
-w :将目前的 history 记忆内容写入 histfiles 中!
例1,列出目前内存内的所有 history 历史记录
代码如下:
〔root@jb51 Desktop〕#history
# 前面省略
1017 man bash
1018 ll
1019 history
1020 history
列出的信息当中,共分两栏,第一栏为该命令在这个 shell 当中的代码, 另一个则是命令本身的内容!至于会显示多少条命令记录,则与 HISTSIZE 有关!
例2,列出目前最近的 3 条数据
代码如下:
〔root@jb51 Desktop〕#history 3
1019 history
1020 history
1021 history 3
例3,立刻将目前的数据写入 histfile 当中
代码如下:
〔root@jb51 Desktop〕#history -w
# 在默认的情况下,会将历史纪录写入 ~/.bash_history 当中!
〔root@jb51 Desktop〕#echo $HISTSIZE
1000
四、历史使用的窍门
1、!的使用
⑴!!重复前一个命令
⑵!字符 重复前一个以“字符”开头的命令
⑶!num 按照history命令输出中的序号来重复对应命令
⑷!?abc 重复前一个包含abc的命令
⑸!-n 重复n个命令之前的那个命令
2、按键组合
⑴使用up和down键来上下浏览之前执行的命令
⑵键入ctr+r来在命令历史中搜索命令
代码如下:
〔root@jb51 Desktop〕#
(reverse-i-search)`‘:
(reverse-i-search)`h’: cat /etc/shadow
按回车键执行该命令
⑶要重新调用前一个命令中的参数
Esc + 。(点击Esc键,然后点击。键)
注意:
History保存在每个用户自己的历史记录中,位于用户的家目录中。
用户登录后,执行命令存放在内存中,只有登录后才能看到。
五、如何保证每次推出登录时情况history
在需要的用户主目录下,编辑~/.bash.logout添加一句history -c保存退出就可以了。
⑹ linux 怎么执行history命令
linux
怎么执行history命令
调用linux
history,你需要使用!历史编码
用法:
1.你在shell中输入history
或者你查找特定的历史记录
history
|
grep
'关键词'
2.查看你要重复执行的命令,记下它前面的编码。例如
350
ps
-aux
|
more
3.!350
调用ps
-aux
|
more
命令
你可以搜索history
!
⑺ linux history可以查看到历史执行过的命令,如何查看命令执行时间
答:linux的bash内部命令history就可以显示命令行的命令历史,默认环境执行 history
命令后,通常只会显示已执行命令的序号和命令本身。
如果想要查看命令历史的时间戳,那么可以执行:
# export HISTTIMEFORMAT='%F %T '
# history | more
1 2008-08-05 19:02:39 service network restart
2 2008-08-05 19:02:39 exit
3 2008-08-05 19:02:39 id
这样显示的格式就变成,序号 - 时间 - 命令行。
history的其他的一些基本功能:
1、使用 HISTSIZE 控制历史命令记录的总行数
将下面两行内容追加到 .bash_profile 文件并重新登录 bash shell,命令历史的记录数将变成 450
⑻ linux 查看当前系统默认可以记住用户多少个历史命令用什么命令
可以使用History命令,主要用于显示历史指令记录内容, 下达历史纪录中的指令 。
1、History命令语法:
[test@linux]# history [n]
[test@linux]# history [-c]
[test@linux]# history [-raw] histfiles
参数:
n:数字,要列出最近的 n 笔命令列表
-c:将目前的shell中的所有 history 内容全部消除
-a:将目前新增的history 指令新增入 histfiles 中,若没有加 histfiles ,
则预设写入 ~/.bash_history
-r:将 histfiles 的内容读到目前这个 shell 的 history 记忆中
-w:将目前的 history 记忆内容写入 histfiles
Linux系统在shell(控制台)中输入并执行命令时,shell会自动把命令记录到历史列表中,一般保存在用户目录下的.bash_history文件中。默认保存1000条,也可以更改这个值。
如果键入history, history会显示所使用的前1000个历史命令,并且编了号,会看到一个用数字编号的列表快速从屏幕上卷过。可能不需要查看1000个命令中的所有项目, 当然也可以加入数字来列出最近的 n 笔命令列表。
linux中history命令不仅仅可以查询历史命令而已. 还可以利用相关的功能来帮执行命令。
2、运行特定的历史命令
history会列出bash保存的所有历史命令,并且编了号,可以使用“叹号接编号”的方式运行特定的历史命令.
语法说明:
[test@linux]# [!number] [!command] [!!]
参数说明:
number :第几个指令的意思;
command:指令的开头几个字母
! :上一个指令的意思!
3、History命令实战
列出所有的历史记录:
[test@linux] # history
只列出最近10条记录:
[test@linux] # history 10 (注,history和10中间有空格)
使用命令记录号码执行命令,执行历史清单中的第99条命令
[test@linux] #!99 (!和99中间没有空格)
重复执行上一个命令
[test@linux] #!!
执行最后一次以rpm开头的命令(!? ?代表的是字符串,这个String可以随便输,Shell会从最后一条历史命令向前搜索,最先匹配的一条命令将会得到执行。)
[test@linux] #!rpm
逐屏列出所有的历史记录:
[test@linux]# history | more
立即清空history当前所有历史命令的记录
[test@linux] #history -c
除了使用history命令,在 shell 或 GUI 终端提示下,也可以使用上下方向键来翻阅命令历史(向下箭头会向前翻阅),直到找到所需命令为止。这可以很方便地编辑前面的某一条命令,而不用重复输入类似的命令。
⑼ 如何让history命令显示日期和时间
Linux下可输入“history”查看已执行命令历史。
⑽ 显示历史命令表的所有内容的命令
linux查看历史命令history
来源:yonggang7的专栏|2014-11-03
1. history作用
linux的history命令的作用是,记录执行过的命令。 用法: history [n] n为数字,列出最近的n条命令 -c 将目前shell中的所有history命令消除 history [-raw] histfiles -a 将目前新增的命令写入histfiles, 默认写入~/.bash_history -r 将histfiles内容读入到目前shell的history记忆中 -w 将目前history记忆的内容写入到histfiles
shell > history 34 14-10-28 16:19:24 ll 35 14-10-28 16:19:26 vim test 36 14-10-28 16:19:33 ll 37 14-10-28 16:19:34 ll
展示3行
shell > history 3 1032 14-11-02 16:10:41 history 1033 14-11-02 16:10:46 history |more 1034 14-11-02 16:11:15 history 3
使用! 执行历史命令。 ! number 执行第几条命令 ! command 从最近的命令查到以command开头的命令执行 !! 执行上一条
shell > !1046 history 3 1045 14-11-02 16:22:38 head ~/.bash_history 1046 14-11-02 16:35:37 history 3 1047 14-11-02 16:35:48 history 3 shell > !! history 3 1046 14-11-02 16:35:37 history 3 1047 14-11-02 16:35:48 history 3 1048 14-11-02 16:35:52 history 3 shell > !head head ~/.bash_history #1414484377 cd update/ #1414484377
2. history配置修改
history记录的行数
shell > echo $HISTSIZE 1000 shell >
默认记录1000行 配置文件在/etc/profile中修改
HISTSIZE=1000 export HISTSIZE
历史命令文件记录在 ~/.bash_history中
想要让linux的history命令显示时间,history是默认不带时间, 在/etc/profile 中增加
export HISTTIMEFORMAT="%y-%m-%d %H:%M:%S "
查看.bash_history
shell > head ~/.bash_history #1414484377 cd update/ #1414484377 ll #1414484388 vim address #1414484439 ll #1414484440 ll shell >
3. 同一账号同时多次登录写入history
普通情况下, 当以bash登录系统时,系统会从~/.bash_history读取以前运行的命令 当注销时,把最新的1000(HISTSIZE)条命令更新到~/.bash_history文件中。 也可以使用history -w强制立刻写入,仅保留最新的。
当同一账号,同时登录多个bash时,只有最后一个退出的会写入bash_history,其他的都被覆盖了。
4. Ctrl+r 反向查询历史命令
使用Ctrl+r反向查询历史命令,将匹配的最新一条显示出来 如果还想继续向上查询,继续按Ctrl+r
shell > history 3 1048 14-11-02 16:35:52 history 3 1049 14-11-02 16:36:11 head ~/.bash_history 1050 14-11-02 16:41:05 history 3 (reverse-i-search)`his': head ~/.bash_history
地址:http://blog.csdn.net/yonggang7/article/details/40710623