Linux之history历史指令查看

Linux之history历史指令查看

history命令用来查看曾经输出过的命令。
命令格式

history [选项]

选项

n  显示最近条记录
-c 清除历史记录,但是此项清除只是清除当前shell,从新连接还是有历史记录

显示命令时间设置

命令history显示时间戳。此命令只是临时的,系统重启就失效
export HISTTIMEFORMAT='%F %T '
export HISTTIMEFORMAT="%F %T "
export HISTTIMEFORMAT="[%Y-%m-%d %H:%M:%S] "
如果需要永久使用,需要在系统环境变量文件(/etc/profile)的末尾追加上
export HISTTIMEFORMAT="%F %T "

例子

[root@localhost opt]# history
    1  ls
    2  cd /
    3  ls
    4  ls -l
    ......
[root@localhost opt]# export HISTTIMEFORMAT='%F %T '
[root@localhost opt]# history
    1  2024-06-12 21:18:38 ls
    2  2024-06-12 21:18:38 cd /
    3  2024-06-12 21:18:38 ls
    4  2024-06-12 21:18:38 ls -l
[root@localhost ~]# history -c
[root@localhost ~]# history
    1  history
[root@localhost ~]# history 5
  991  history -10
  992  history 10
  993  history +10
  994  history 10
  995  history 5

相关推荐

  1. Linuxhistory历史指令查看

    2024-06-14 19:52:03       34 阅读
  2. Linux查看命令历史

    2024-06-14 19:52:03       41 阅读
  3. Linux查询指令

    2024-06-14 19:52:03       54 阅读
  4. Linuxhistory命令详解

    2024-06-14 19:52:03       55 阅读
  5. linux netstat 查看指定端口

    2024-06-14 19:52:03       33 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-14 19:52:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-14 19:52:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-06-14 19:52:03       82 阅读
  4. Python语言-面向对象

    2024-06-14 19:52:03       91 阅读

热门阅读

  1. Leetcode:合并两个有序链表

    2024-06-14 19:52:03       30 阅读
  2. ubuntu20.04 minio 安装为服务

    2024-06-14 19:52:03       26 阅读
  3. 查看ubuntu中的分区是什么类型的

    2024-06-14 19:52:03       29 阅读
  4. 矩阵的运算:加减乘除与转置#matlab

    2024-06-14 19:52:03       29 阅读
  5. 数仓SQL如何做code review?

    2024-06-14 19:52:03       27 阅读
  6. 基于大模型的Code Review

    2024-06-14 19:52:03       26 阅读
  7. 力扣第197题:上升的温度

    2024-06-14 19:52:03       31 阅读
  8. Jupyter部署和使用教程

    2024-06-14 19:52:03       31 阅读
  9. 深度学习的点云分类

    2024-06-14 19:52:03       30 阅读