Replaying Linux CLI commands with history
Very handy little snippet I discovered today, mostly here for my own reference in future. It’s handy to be able to re-play/re-submit commands that you’ve typed into the CLI before on your Linux box, to do this you can use the history command. Let’s take a look at my webserver hosting the site, just as an example: root@web:~# history 781 nano /etc/cron.hourly/.placeholder sess_ 782 crontab 783 crontab -e 784 nano /etc/cron.d/php5 785 sudo bash 786 exit 787 sudo bash 788 service php5-fpm restart 789 service nginx restart 790 service varnish restart If I want to look for particular entries I can just grep the output: ...