zoukankan      html  css  js  c++  java
  • Linux中历史命令

    历史命令,即之前登录session会话中的在命令行键入的命令。

    在Linux中可以有两种方式查询历史命令

    • history命令
    • 当前用户目录中的隐藏文件.bash_history

    一.history

    作用域

    1. 当前登录用户
    2. 之前登录会话和当前登录会话

    意思即: history查询的是当前登录用户在当前会话session和之前登录会话中所键入的命令。

    history工作原理
    Linux维护一份历史命令内存缓存,当前session键入的命令写入这份缓存中,当前用户登录的时候,将.bash_history中记录的历史命令载入缓存。

    [lxy@localhost ~]$ history
    1  su - root
    2  ps -aux|grep tserver
    3  cd /opt/server/tserver
    4  cd Bin/
    5  cd tserver
    6  tail -f log/hplugin/tserver_plugin_hik.log 
    7  tail -f log/cluster.log
    8  less log/cluster.log
    9  cd ..
    

    history有很多参数,这里只介绍下-c参数。 -c:用于清除history的内存缓存,但是并不删除.bash_history中历史命令。

    二.查看.bash_history

    [hik@HikvisionOS ~]$ cat ~/.bash_history
    su - root
    ps -aux|grep tda
    cd /opt/hikserver/tda
    cd Bin/
    cd tda
    tail -f log/hplugin/tda_plugin_hik.log 
    tail -f log/cluster.log
    less log/cluster.log
    cd ..
    

    配置记录历史命令条数

    在“/etc/profile”配置文件中可以配置是否记录历史操作命令。
    vi /etc/profile

    HOSTNAME=`/usr/bin/hostname 2>/dev/null`
    HISTSIZE=1000
    

    修改其中HISTSIZE大小,即可改变记录历史命令的大小。如果改成0,则表示不记录历史命令。默认是1000条

  • 相关阅读:
    需求分析的方法与实践
    系统架构分析与设计方法论
    装修-3
    装修-2
    装修-1
    daikuan
    JAVA容器全面总结
    超图8C iserver启动成功,访问不了网站localhost:8090/iserver/manager,显示404
    Arcgis中给字段添加属性域
    arcgis for server搭建集群环境
  • 原文地址:https://www.cnblogs.com/lxyit/p/9149612.html
Copyright © 2011-2022 走看看