V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
yanzhiling2001
V2EX  ›  云计算

有什么办法记录下 Linux 执行过的 history 命令

  •  1
     
  •   yanzhiling2001 · 2021-04-12 21:23:42 +08:00 · 3131 次点击
    这是一个创建于 1080 天前的主题,其中的信息可能已经有所发展或是发生改变。
    记录下来 history,避免 history -c 或者其他命令清空执行历史
    17 条回复    2021-04-27 17:50:51 +08:00
    zhoudaiyu
        1
    zhoudaiyu  
       2021-04-12 21:29:22 +08:00
    使用 JumpServer 管理服务器(自带录屏和历史命令查询)
    Rico
        2
    Rico  
       2021-04-12 21:36:16 +08:00
    history > history.txt ?
    hei1000
        3
    hei1000  
       2021-04-12 21:48:39 +08:00
    什么 shell ? bash 的话有~/.bash_history, fish 的话有~/.local/share/fish/fish_history 啊
    yanzhiling2001
        4
    yanzhiling2001  
    OP
       2021-04-12 22:02:58 +08:00
    @hei1000 #3 这个不错啊,厉害厉害,解决问题了。直接读取这个文件就可以了,history -c 清空了也能看到
    raaaaaar
        5
    raaaaaar  
       2021-04-12 22:29:17 +08:00
    记录下来?我在用 zsh 有个历史插件,不知道有没有用
    24bit
        6
    24bit  
       2021-04-12 22:36:46 +08:00   ❤️ 3
    export PROMPT_COMMAND='{ msg=$(history 1 | { read x y; echo $y; });echo $(date +"%Y-%m-%d %H:%M:%S") [$(whoami)@$SSH_USER$LOGIN_IP `pwd` ]" $msg" >> /var/log/.history; }'
    Skmgo
        7
    Skmgo  
       2021-04-13 01:41:58 +08:00
    /etc/profile history 从 1000 改为 0,这是我拿到每个新机器第一件要做的事情。
    PMR
        8
    PMR  
       2021-04-13 07:59:29 +08:00 via Android
    Auditd forward remote rsyslog
    css3
        9
    css3  
       2021-04-13 09:14:06 +08:00
    ctrl + r
    dengshen
        10
    dengshen  
       2021-04-13 10:24:13 +08:00 via iPhone
    @Skmgo 这样做的意义是什么呢?不太懂
    yanzhiling2001
        11
    yanzhiling2001  
    OP
       2021-04-13 10:27:03 +08:00
    @dengshen #10 避免追踪。好多云都有监控。
    dengshen
        12
    dengshen  
       2021-04-13 10:30:20 +08:00 via iPhone
    @yanzhiling2001 GitHub 有个针对腾讯云监控的卸载脚步。执行以后面板就看不到 CPU 状态了
    yanzhiling2001
        13
    yanzhiling2001  
    OP
       2021-04-13 10:37:18 +08:00
    @dengshen #12 我直接 DD 新系统。肯定还有其他的内部监控手段。不如换个新的。
    dengshen
        14
    dengshen  
       2021-04-13 10:59:52 +08:00 via iPhone
    @yanzhiling2001 谢谢。还没试过 dd 这个操作
    tomychen
        15
    tomychen  
       2021-04-13 22:26:02 +08:00
    webs
        16
    webs  
       2021-04-19 13:27:33 +08:00
    Tengwait
        17
    Tengwait  
       2021-04-27 17:50:51 +08:00
    @tomychen 这个会有个问题,如果用户空按回车的时候,会获取到上一个 history 命令的内容,造成了不必要的浪费,这个问题可以解决吗
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3080 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 1036ms · UTC 12:44 · PVG 20:44 · LAX 05:44 · JFK 08:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.