码迷,mamicode.com
首页 > 其他好文 > 详细

CentOS 显示历史执行过的命令以及用户历史命令缓存

时间:2019-01-05 22:46:40      阅读:404      评论:0      收藏:0      [点我收藏+]

标签:free   历史记录   数字   swap   pre   profile   linux   nio   sbin   

1、history命令用于显示历史执行过的命令

执行 history命令能显示出当前用户在本地计算机中执行过的最近 1000 条命令记录。

如果觉得 1000 不够用,还可以自定义/etc/profile 文件中的HISTSIZE 变量值。

在使用 history 命令时,如果使用-c 参数则会清空所有的命令历史记录。

[root@bigdata-senior01 /]# history
   36  cat ~/.bash_history
   37  history
   38  cat ~/.bash_history
   39  cat ~/.bash_history | less
   40  history
   41  ls
   42  free -h
   43  history

2、使用“!编码数字”的方式来重复执行某一次的命令。

 

[root@bigdata-senior01 /]# !42
free -h
              total        used        free      shared  buff/cache   available
Mem:           1.8G        156M        1.5G        8.5M        178M        1.5G
Swap:          2.0G          0B        2.0G

 

3、历史命令会被保存到用户家目录中的.bash_history 文件中。Linux 系统中以点(.)开头的文件均代表隐藏文件,这些文件大多数为系统服务文件,可以用 cat 命令查看其文件内容。

查看自己的home下的用户目录的历史命令记录
“~”波浪线,表示用户家目录
[root@bigdata-senior01 /]# cat ~/.bash_history
~”波浪线:
[root@bigdata-senior01 ~]# su - es 上一次登录:六 1月 5 21:48:54 CST 2019pts/0 上 [es@bigdata-senior01 ~]$ pwd /home/es [es@bigdata-senior01 ~]$ cd / [es@bigdata-senior01 /]$ ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var [es@bigdata-senior01 /]$ pwd / [es@bigdata-senior01 /]$ cd ~ [es@bigdata-senior01 ~]$ pwd /home/es

 

CentOS 显示历史执行过的命令以及用户历史命令缓存

标签:free   历史记录   数字   swap   pre   profile   linux   nio   sbin   

原文地址:https://www.cnblogs.com/asker009/p/10226440.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!