Is there a way to record the Linux commands I use and reuse them on another machine or in case I want to reinstall the machine?

In example record how I set up NginX, PHP and permissions in my lab environment and then repeat the exact commands on my deploy machine?


Solution 1:

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.

Solution 2:

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