Fedora 系统中有多种历史记录,这里为您分别介绍:
自动开启 - 默认已启用,可查看/配置:
# 查看历史记录
history
history | grep "关键词" # 搜索历史命令
# 查看历史记录文件
cat ~/.bash_history # Bash
cat ~/.zsh_history # Zsh
# 配置历史记录(编辑 ~/.bashrc 或 ~/.zshrc)
export HISTSIZE=10000 # 内存中保存数量
export HISTFILESIZE=20000 # 文件中保存数量
export HISTTIMEFORMAT="%F %T " # 添加时间戳
Ctrl+R
Super(Win) 键# 查看系统日志(需要root权限)
sudo journalctl -xe # 查看完整日志
sudo journalctl -f # 实时跟踪日志
# 特定服务的日志
sudo journalctl -u nginx.service
# 查看系统登录记录
last
lastlog
# 查看认证日志
sudo cat /var/log/secure
sudo cat /var/log/auth.log
~/.local/share/recently-used.xbelrm ~/.local/share/recently-used.xbel# 查看 DNF 操作历史
sudo dnf history
sudo dnf history info [ID号] # 查看特定操作详情
sudo dnf history undo [ID号] # 撤销某次操作
# 查看软件包安装日期
rpm -qa --last | head -20
# 编辑 ~/.bashrc,添加:
shopt -s histappend # 追加而不是覆盖历史文件
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
journalctl 配置)需要查看特定类型的历史记录,请告诉我具体需求!