liunx 命令的历史记录清除

        在linux系统里一旦操作了任何命令,都会被记录下来,可以通过history命令来查看历史命令,查看手册可知history -c 便是清除历史命令,但是重新进入系统查看历史命令时,历史信息依然会存在,那么history -c 只是清除当前shell的历史纪录,因为系统一般会把信息保存在一个文件中,只要文件中内容没有改变,那么信息也不会变。linux中存放历史命令的文件是.bash_history,清空该文件(echo > /root/.bash_history),那些历史命令就会被清空了。

        注意如果是在shell脚本中调用history -c清空当前shell的历史命令,是不会成功的,因为bash执行命令时默认是会产生一个子进程来执行该命令,在子进程中执行history -c不是清除你当前shell的历史命令了。可以使用source来执行脚本(source ./脚本),source 指在当前bash环境下执行命令
 

保存和执行常用的linux命令,经常需要编辑的目录很深的文件,或教长的编译命令等等。使用方法:把该Q可执行文件考备份到linux上任何目录,第一次执行会被加到系统目录,以后每次执行都可以像使用系统命令一样。 1.查看保存好的命令 [root@localhost ~]# q 1_____clear 2_____tar -xzvf 3_____tar -czvf 4_____rpm -ivh 5_____lsnrctl status 6_____lsnrctl start 7_____lsnrctl stop 8_____vi /home/oracle/ora/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 9_____/opt/lampp/lampp start 10_____/opt/lampp/lampp restart 11_____/opt/lampp/lampp stop 2.执行保存好的命令 [root@localhost ~]# q 10 Stopping XAMPP for Linux 1.8.1... XAMPP: Stopping Apache with SSL... XAMPP: Stopping MySQL... XAMPP: XAMPP-ProFTPD is not running. XAMPP stopped. 3.添加新命令 [root@localhost ~]# q -a "sqlplus /sys as dba" 1_____clear 2_____tar -xzvf 3_____tar -czvf 4_____rpm -ivh 5_____lsnrctl status 6_____lsnrctl start 7_____lsnrctl stop 8_____vi /home/oracle/ora/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 9_____/opt/lampp/lampp start 10_____/opt/lampp/lampp restart 11_____/opt/lampp/lampp stop 12_____sqlplus /sys as dba 4.删除保存过的命令 [root@localhost ~]# q -d 12 1_____clear 2_____tar -xzvf 3_____tar -czvf 4_____rpm -ivh 5_____lsnrctl status 6_____lsnrctl start 7_____lsnrctl stop 8_____vi /home/oracle/ora/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 9_____/opt/lampp/lampp start 10_____/opt/lampp/lampp restart 11_____/opt/lampp/lampp stop
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值