linux 查看ip、用户、时间对应执行的命令
这个需要使用到history命令。可以加数字,返回最近执行的几条命令。如果不加数字会返回所有的历史命令。
[root@localhost ~]# history 20
1015 rm stdin.log
1016 ll
1017 rm yy
1018 ll
1019 echo 'hello' 1>> echo.log
1020 ll
1021 cat echo.log
1022 echo 'world' 1>> echo.log
1023 cat echo.log
1024 echo 'world' 1> echo.log
1025 cat echo.log
1026 ll
1027 rm echo.log
1028 last
1029 history
1030 who am i
1031 clear
1032 history
1033*
1034 history 20
如果需要查看用户、ip和时间,需要配置linux的变量。
编辑
vim /etc/profile
后面添加变量:
export HISTTIMEFORMAT="%F %T `who am i` "
然后使之生效:
source /etc/profile
[root@localhost etc]# history 20
1022 2020-02-02 17:03:16 root pts/1 2020-02-02 13:31 (192.168.190.14) echo 'world' 1>> echo.log
1023 2020-02-02 17:03:20 root pts/1 2020-02-02 13:31 (192.168.190.14) cat echo.log
1024 2020-02-02 17:03:28 root pts/1 2020-02-02 13:31 (192.168.190.14) echo 'world' 1> echo.log
1025 2020-02-02 17:03:31 root pts/1 2020-02-02 13:31 (192.168.190.14) cat echo.log
1026 2020-02-02 17:09:05 root pts/1 2020-02-02 13:31 (192.168.190.14) ll
1027 2020-02-02 17:09:11 root pts/1 2020-02-02 13:31 (192.168.190.14) rm echo.log
1028 2020-02-02 17:12:58 root pts/1 2020-02-02 13:31 (192.168.190.14) last
1029 2020-02-02 17:14:15 root pts/1 2020-02-02 13:31 (192.168.190.14) history
1030 2020-02-02 17:47:12 root pts/1 2020-02-02 13:31 (192.168.190.14) who am i
1031 2020-02-02 17:53:15 root pts/1 2020-02-02 13:31 (192.168.190.14) clear
1032 2020-02-02 17:53:21 root pts/1 2020-02-02 13:31 (192.168.190.14) history
1033* 2020-02-02 17:53:29 root pts/1 2020-02-02 13:31 (192.168.190.14)
1034 2020-02-02 17:53:40 root pts/1 2020-02-02 13:31 (192.168.190.14) history 20
1035 2020-02-02 17:55:12 root pts/1 2020-02-02 13:31 (192.168.190.14) last
1036 2020-02-02 17:58:23 root pts/1 2020-02-02 13:31 (192.168.190.14) cd /etc
1037 2020-02-02 17:58:25 root pts/1 2020-02-02 13:31 (192.168.190.14) ll
1038 2020-02-02 17:58:33 root pts/1 2020-02-02 13:31 (192.168.190.14) vim profile
1039 2020-02-02 18:01:54 root pts/1 2020-02-02 13:31 (192.168.190.14) source /etc/profile
1040 2020-02-02 18:02:03 root pts/1 2020-02-02 13:31 (192.168.190.14) histoty 20
1041 2020-02-02 18:02:10 root pts/1 2020-02-02 13:31 (192.168.190.14) history 20
可以看到多出了,操作时间,用户,以及操作的ip。
who am i 比较容易理解,就是输出登入的用户名,登入时间,以及ip啥的。
那%F %T啥的,其实就是一种格式。这种格式是strftime函数。可以搜索了解下strftime。
linux 查看ip、用户、时间对应执行的命令的更多相关文章
- linux查看ssh用户登录日志与操作日志
linux查看ssh用户登录日志与操作日志 2013-11-01转载 ssh用户登录日志 linux下登录日志在下面的目录里: 代码如下 复制代码 cd /var/log 查看ssh用户的登录日 ...
- linux查看当前用户登陆信息
@(Linux基础)[linux查看当前用户登陆信息] linux查看当前用户登陆信息 作为系统管理员,你可能经常会(在某个时候)需要查看系统中有哪些用户正在活动.有些时候,你甚至需要知道他(她)们正 ...
- Linux 查看登录用户信息 who & whoami
Linux 查看登录用户信息 who & whoami 在一台服务器上,同一时间往往会有很难多人同时登录. who 命令可以查看当前系统中有哪些人登录,以及他们都工作在哪个控制台上. 这样可以 ...
- Linux 查看某个用户的进程
Linux 查看某个用户的进程 To view only the processes owned by a specific user, use the following command: top ...
- linux查看在线用户并踢出用户
linux查看在线用户并踢出用户 1.查看在线用户 w [root@dbserver01 ~]# w 16:45:04 up 16 days, 8:48, 1 user, load average: ...
- linux 查看系统当前时间,修改时间
linux 查看系统当前时间,修改时间1. 查看时间和日期命令 : "date"2.设置时间和日期例如:将系统日期设定成2018年6月8日的命令命令 : "date -s ...
- Linux下的crontab定时、执行任务命令详解 oracle 自动备份
在LINUX中,周期执行的任务一般由cron这个守护进程来处理[ps -ef|grep cron].cron读取一个或多个配置文件,这些配置文件中包含了命令行及其调用时间.cron的配置文件称为&qu ...
- linux 中更改用户权限和用户组的命令chmod,chgrp实例
linux 中更改用户权限和用户组的命令实例; 增加权限给当前用户 chmod +wx filename chmod -R 777 /upload 用户组 chgrp -R foldname zdz ...
- 在SQL中有时候我们需要查看现在正在SQL Server执行的命令
在SQL中有时候我们需要查看现在正在SQL Server执行的命令.在分析管理器或者Microsoft SQL Server Management Studio中,我们可以在"管理-SQL ...
- linux查看是否有某个运行的进程命令
linux查看是否有某个运行的进程命令:例如,查询是否包含 “my_post” 关键字的进程 ps aux | grep my_post ps aux | grep my_post | grep - ...
随机推荐
- 对于使用javaweb技术制作简单管理系统的学习
近期在老师的引导下我们学习了利用Javaweb技术制作简单的管理系统,其中涉及到的技术很多,由于大多都是自学 对这些技术的理解还太浅显但能实现一些相关功能的雏形. (一).登录功能 在登陆功能中通过与 ...
- PAT T1002 Business
背包问题,把任务按截止日期排序,再按背包问题处理~ #include<bits/stdc++.h> using namespace std; ; struct node { int c; ...
- ubuntu13.10设置永久静态IP重启不失效
步骤: 1.vi打开/etc/network/interfaces 2.手动添加static ip address 3.:wq保存退出 4.重启网络 service network-manager r ...
- Sonic_cli常用命令
用户名:admin 密码:YourPaSsWoRd //change password1>admin@sonic:~$ passwdChanging password for admin.(cu ...
- Java基础知识笔记第四章:类和对象
编程语言的几个发展阶段 面向机器语言 面向过程语言 面向对象语言:封装.继承.多态 类 类声明 class Person{ ....... } class 植物{ ....... } 类体 类使用 ...
- FormsAuthentication.HashPasswordForStoringInConfigFile方法再.net core中的替代代码
FormsAuthentication.HashPasswordForStoringInConfigFile()这个加密方法再.net core中不存在了,可以用下面的方式达到一样的加密效果 usin ...
- Caffe2 玩玩回归(Toy Regression)[5]
前言 这一节将讲述如何使用Caffe2的特征进行简单的线性回归学习.主要分为以下几步: - 生成随机数据作为模型的输入 - 用这些数据创建网络 - 自动训练模型 - 查看梯度递减的结果和学习过程中网络 ...
- 【转】python装饰器
什么是装饰器? python装饰器(fuctional decorators)就是用于拓展原来函数功能的一种函数,目的是在不改变原函数名(或类名)的情况下,给函数增加新的功能. 这个函数的特殊之处在于 ...
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2)E(多重集维护)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;long long ans[1000007]; ...
- 图片切换.----so屌
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...