Linux命令:history命令历史的管理及用
bash可以保存的过去曾经执行过的命令。当某个用户登录到shell中,会读取该用户家目录中的~/.bash_history文件,并将历史命令列表保存到内存中。当用户退出当前shell时,会将内存中的历史命令列表覆盖至~/.bash_history文件。 我们可以通过# histroy 来查看历史命令。history是bash的内部命令。通过# help history获取帮助。 一、history的常见选项 # history 。。。 # 省略前面 994 man poweroff 995 poweroff --reboot 996 man poweroff 997 man shutdown 998 shutdown +2 "Goodbye SB" 999 shutdown -c 1000 man rm 1001 info rm 1002 man history 1003 enable 1004 enable | grep history 1005 help history 1006 history 1007 history -d 1000 1008 history 1009 echo $HISTORYSIZE 1010 history # history -c 清空命令历史记录 # history -d N N为整数,删除历史中序号是N的命令 # history N