编译bash通过Rsyslog记录执行命令日志,并将日志发送到Elastic Stack,实现history审计

此前考虑通过PROMPT_COMMAND环境变量实现history审计,后来发现存在各种问题,就如使用su切换用户时,前后执行的命令不能被准确记录。

看了许多文章,最终找到一种相对完善的处理方法,就是通过编译bash,由Rsyslog记录执行命令日志。之后配置实时将日志数据输出到Elastic Stack,在Kibana上可以监控终端上执行的每一条命令,或对日志数据作分析和审计。

继续阅读“编译bash通过Rsyslog记录执行命令日志,并将日志发送到Elastic Stack,实现history审计”

使用pip查找指定python程序包的所有可安装版本

系统版本:

[root@centos76d77 14:56 ~]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810 (Core) 
[root@centos76d77 14:56 ~]# uname -r
3.10.0-957.el7.x86_64

 

[root@centos76d77 14:56 ~]# python3.4
Python 3.4.10 (default, Apr  8 2019, 02:17:36) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

[root@centos76d77 17:59 ~]# pip3.4 search ipython
....
ipython (7.5.0) - IPython: Productive Interactive Computing

本机使用的python版本较老(3.4),最高仅能支持ipython 6.x,而pip中默认提供的ipython版本为7.5.0

继续阅读“使用pip查找指定python程序包的所有可安装版本”

Vim的全局命令g

全局命令:g在Vim中有着意想不到强大的功能。当想要在整个文件中对于匹配的行或者非匹配行进行一些操作时,应该第一时间想到这个:g命令

:[range]global[!]/{pattern}/{command}

可以简写为

:[range]g/pattern/command
  • [range]指定文本范围,默认为整个文档
  • pattern在范围range内的行如果匹配pattern,则执行command
  • !表示取反,也就是不匹配的行,也可以使用vglobal
  • command默认是打印文本

继续阅读“Vim的全局命令g”

LVM的基本操作

系统版本:

[root@centos71d1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
[root@centos71d1 ~]# uname -r
3.10.0-229.el7.x86_64

 
以下演示LVM的基本操作:
1. PV的创建、查看、移除
2. VG的创建、查看、扩展、缩减
3. LV的创建、查看、扩展、缩减、快照、移除
继续阅读“LVM的基本操作”

Linux基础练习题(二)

系统版本:

[root@centos67d1 ~]# cat /etc/redhat-release 
CentOS release 6.7 (Final)
[root@centos67d1 ~]# uname -r
2.6.32-573.el6.x86_64
[root@centos71d1 ~]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
[root@centos71d1 ~]# uname -r
3.10.0-229.el7.x86_64

 

1. 复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限

继续阅读“Linux基础练习题(二)”