zoukankan      html  css  js  c++  java
  • 查看sudo的history:配置sudolog

    sudo 权力很大,但责任更重大!

    We trust you have received the usual lecture from the local System
    Administrator. It usually boils down to these three things:
    
    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.
    

    今天发现无法查看历史的sudo命令,故有此一文
    参考配置sudo记录日志-客Ren

    以下操作请使用sudo或在root权限下小心进行!

    • 编辑/etc/rsyslog.conf文件

    vim /etc/rsyslog.conf
    #在文件底部添加一行
    local2.debug                           /var/log/sudo.log
    

    在这里插入图片描述

    • 编辑visudo

    visudo
    #添加3行
    Defaults logfile=/var/log/sudo.log
    Defaults loglinelen=0
    Defaults !syslog
    

    在这里插入图片描述

    • 创建上述所说的sudo.log

    touch  /var/log/sudo.log
    
    • 重启rsyslog服务

    systemctl restart rsyslog
    
    • 测试一下看看效果

    在这里插入图片描述
    有效!

    • 建立一个方便查看的alias

    vim ~/.bashrc
    #在底下加一行
    alias sudolog='cat /var/log/sudo.log'
    #使其生效
    source ~/.bashrc
    

    以后就可以使用sudolog来查看用sudo都执行过什么了
    在这里插入图片描述

    • 清空sudolog

    #切换至root账户
    sudo su - root
    #执行
    echo '' > /var/log/sudo.log
    

    呃,这里不明白的是为什么有sudo权限的账户执行echo '' > /var/log/sudo.log会提示权限不够 : /var/log/sudo.log
    希望有知道的大佬指教一下

  • 相关阅读:
    UI5 Databind
    the meaning of myconputer environment path
    Linux查看日志常用命令
    fw: IP bonding in Linux.
    FW:expect tcl install
    install ET underlinux
    转expect 文一篇。
    linux 集萃
    try expect and autoexpect
    linux 压缩种类
  • 原文地址:https://www.cnblogs.com/syisyuan/p/12811601.html
Copyright © 2011-2022 走看看