How can I record Linux commands?

Seems to me like you want script(1).

It allows you to record and replay terminal sessions.

On the other hand, if you are trying to automate setups, consider configuration management, like puppet.


Two ways I can think of off the top of my head:

  • Use the builtin command history

  • Do everything in a screen session and enable logging


Bash records commands in a file called ~/.bash_history. This works if you do everything via a command line, and in one command window.

Be warned though, it limits the size of that file to the most recent 1000(by default) commands.