Giter VIP home page Giter VIP logo

linux_command_record's Introduction

linux_command_record

**期间,有小伙伴想实现linux命令的实时记录功能,花了1小时时间,查阅了些资料,对Linux做少许改动,便可实现对Linux的命令实时记录,并配置syslog可以做到对操作命令的集中收集。

下面时配置步骤:

1、在/etc/profile下增加如下代码

# cat << EOF >>/etc/profile

export HISTTIMEFORMAT="`echo ${SSH_CONNECTION}`|#|`whoami`|#|%F %T|#|"

export PROMPT_COMMAND="history -a; history -c; history -r;"'echo $(history 1) >>/var/log/command.log'

EOF

2、创建/var/log/command.log文件,并将文件权限设置为662

# chmod 662 /var/log/command.log

3、开启syslog,实时将command内容发送到远程服务器。

linux_command_record's People

Contributors

j4ckzh0u avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.