当前位置:网站首页>The history command adds time to the history
The history command adds time to the history
2022-07-24 06:32:00 【Step on the path of the pit】
Linux Under the system, it can pass history Command to view all the historical operation records of the user , But by default ,history The command can only view the user's historical operation records , It doesn't distinguish between users and operation time , It is not convenient for audit analysis .
Of course , Some bad operating habits may also leak sensitive information through command history .
Add time to command history
By setting export HISTTIMEFORMAT=’\%F \%T ‘, Bring command execution time to history .
This configuration can be written in /etc/profile in , Of course, if you want to configure the specified user , This configuration can be written in /home/\$USER/.bash_profile in .
unset i
unset -f pathmunge
export HISTTIMEFORMAT='%F %T 'For the configuration to take effect immediately, execute source /etc/profile, Check it again history Record , You can see the command execution time in the record .
1012 2021-03-22 13:59:10 vim /etc/profile
1013 2021-03-22 13:59:18 source /etc/profile
1014 2021-03-22 13:59:22 historyIf you want to achieve more detailed records , For example, users who have logged into the system 、IP Address 、 Operation command and operation time correspond one by one , It can be done by /etc/profile Add the following code to achieve .
export HISTTIMEFORMAT="%F %T `who -u 2>/dev/null | awk '{print $NF}'|sed 's/[()]//g'` `whoami` "modify /etc/profile And after loading ,history Record the following , Time 、IP、 The users and the commands they execute all correspond one by one
1042 2021-03-22 14:20:39 124.193.98.180 root vim /etc/profile
1043 2021-03-22 14:20:52 124.193.98.180 root source /etc/profile
1044 2021-03-22 14:20:53 124.193.98.180 root historyThrough the above configuration , We can basically meet the daily audit work , But it should be easy for people who know the system to see , This method just sets the environment variables , The attacker unset Drop this environment variable , Or just delete the command history , For safety emergency , This is undoubtedly a disaster .
In response to such questions , We should revise it bash Source code , Give Way history The record passed syslog Send to remote logserver in , Greatly increased the attacker's ability to history The difficulty of recording integrity damage .
边栏推荐
- Flink restart policy
- Data set and pre training model
- RAID5和LVM组合使用
- jz47 礼物的最大价值(动态规划思路)
- 使用自定义zabbix包(4.0.5版本)安装agent和proxy
- MySQL从基础到入门到高可用
- go的环境搭建和起步
- Quickly and simply set up FTP server, and achieve public network access through intranet [no need for public IP]
- [301] grotesque behavior - predictable irrationality
- 【301】怪诞行为学-可预测的非理性
猜你喜欢

PXE技术网络装机

Leetcode refers to the duplicate number in the offer jz3 array
![Configure a fixed remote desktop address [intranet penetration, no need for public IP]](/img/17/4e119be86189d80b100eb000254a86.png)
Configure a fixed remote desktop address [intranet penetration, no need for public IP]

Crud of MySQL

Server hardware and RAID configuration practice

LuckyFrameWeb测试平台(一款支持接口自动化、WEB UI自动化、APP自动化,并且支持分布式测试的全纬度免费开源测试平台)

Leetcode does not add, subtract, multiply, divide, and calculate the number of 1 in binary

Tensorflow GPU installation -- 056

IP job (1)

leetcode剑指offer JZ3 数组中重复的数字
随机推荐
【222】内存溢出及定位
Solutions to the failure of wechat TBS online kernel installation
Interview questions for Test Manager / test team leader / Test Supervisor
Flink function (2): checkpointedfunction
IP job (6)
Metersphere one stop open source continuous testing platform
leetcode 不用加减乘除算加法 || 二进制中1的个数
IP notes (6)
Do not rent servers, build your own personal business website (4)
Jenkins automated unattended operation (up / down)
Leetcode does not add, subtract, multiply, divide, and calculate the number of 1 in binary
一个测试经理/测试主管/测试总监的工作总结
Li Kou 986. Intersection of interval lists
数据集和预训练模型
自定义zabbix agent rpm包
IP lesson summary (3)
Do not rent servers, build your own personal business website (2)
Unable to boot after permanent mounting
一批面试题及答案_20180403最新整理
【218】CS架构和BS架构以及数据放在服务端和客户端的利与弊?