linux中清除和导入到出历史命令
来源:互联网 发布:网络尖兵防御是什么 编辑:程序博客网 时间:2024/05/25 19:57
1、建立一个文件来存储常用命令,例如/root/history.txt,把常用命令当成文本写进去,每个命令占一行
2、在终端运行history -c,清除杂乱的历史记录
3、运行history -r /root/history.txt,把命令读进来作为当前bash的历史记录
4、运行history,就得到一个整洁的命令列表了,例如:
[root@localhost windata]# history -c [root@localhost windata]# history -r /root/history.txt [root@localhost windata]# history 1 history -r /root/history.txt 2 mount -t msdos -o iocharset=gb2312 /dev/sda1 /mnt/usb 3 mount -t vfat -o iocharset-gb2312 /dev/hda5 /mnt/windata 4 umount /mnt/windata 5 mount -t vfat -o iocharset-gb2312 /dev/hda5 /mnt/windata 6 cd /mnt/windata 7 history [root@localhost windata]#
5、以后命令乱了,重复1-4的步骤,又可以使命令很清晰了。
1、清除登陆系统成功的记录,也就是last命令看到的记录
[root@linuxzgf ~]echo > /var/log/wtmp 此文件默认打开时乱码的,里面可以看到ip等等信息
验证过程
[root@linuxzgf ~]#last
root pts/0 10.5.10.51 Thu Sep 2 00:59 still logged in
root pts/2 10.5.10.60 Wed Sep 1 16:11 - 17:47 (01:35)
root pts/2 10.5.10.60 Wed Sep 1 16:08 - 16:10 (00:02)
root pts/0 10.5.10.61 Wed Sep 1 14:16 - 23:02 (08:46)
root pts/3 10.5.10.59 Wed Sep 1 11:28 - 19:38 (08:10)
root pts/2 10.5.10.60 Wed Sep 1 11:18 - 16:07 (04:49)
root pts/1 10.5.10.191 Wed Sep 1 11:17 - 19:12 (07:55)
。。。。。。。。。。。。。。。。。。。。。。。
[root@linuxzgf ~]#echo >/var/log/wtmp
[root@linuxzgf ~]#last
wtmp begins Thu Sep 2 01:04:34 2010
[root@linuxzgf ~]#
此时即看不到用户登录信息
2、清除登陆系统失败的记录,也就是lastb命令看到的记录
[root@linuxzgf ~]echo > /var/log/btmp 此文件默认打开时乱码的
验证方法
在执行命令前执行lastb如下
[root@linuxzgf ~]#lastb
root ssh:notty 10.5.10.60 Wed Sep 1 16:11 - 16:11 (00:00)
tty6 Mon Aug 30 22:53 - 22:53 (00:00)
tty6 Mon Aug 30 18:52 - 18:52 (00:00)
tty6 Mon Aug 30 18:52 - 18:52 (00:00)
++++++ tty6 Mon Aug 30 18:52 - 18:52 (00:00)
linuxzgf ssh:notty 10.5.10.60 Mon Aug 30 11:21 - 11:21 (00:00)
linuxzgf ssh:notty 10.5.10.60 Mon Aug 30 09:37 - 09:37 (00:00)
。。。。。。。。。
然后执行
[root@linuxzgf ~]#echo > /var/log/btmp
[root@linuxzgf ~]#lastb
btmp begins Thu Sep 2 01:01:06 2010
此时就没有结果输出了
是不是很爽
3、清除历史执行命令
[root@linuxzgf ~]history -c
或者
清空用户目录下的这个文件即可
[root@linuxzgf ~]> ~/.bash_history
- linux中清除和导入到出历史命令
- Linux清除用户登录记录和命令历史方法
- Linux清除用户登录记录和命令历史方法
- Linux清除用户登录记录和命令历史方法
- Linux环境下查看历史操作命令及清除方法
- CentOS清除用户登录记录和命令历史方法
- Linux快速查询到历史输入命令
- oracle数据库的导入和到出
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Linux中history历史命令使用方法详解
- Excle导入到出。。。
- linux历史和基础命令----宋轶聪
- Linux学习---快捷键和历史命令
- Linux的管道符和历史命令
- 在线自适应训练算法
- windows 下通过adb shell进入data目录,Permission denied 权限被拒绝
- Http Get & Post总结
- 一个简单的c程序,提取gem5运行benchmark产生的stats.txt中的l2cache的总不命中率
- VB APP对象属性一览表+灵活使用VB的APP对象
- linux中清除和导入到出历史命令
- android 开发感触
- AIX日常运维管理需要做哪些工作
- POSIX正则表达式规则
- posix多线程和boost多线程学习笔记
- myeclipse快捷键
- windows下androidNDK环境配置
- 让你的MyEclipse具有jquery自动提示
- Google Breakpad之六,mac平台crash