I want to keep a log of all commands I run in a separate log file (other than history) along with other description. To achieve this I need to know how can I fetch current run command and store it in a file.
Scenario: Currently, Whenever I run sudo command it asks for reason, which I provide. And the reason is stored in log file in my directory. But now I want to store the command run along with the reason and I am not able to find the way to do this.
$ sudo touch file Reason for sudo: creating new file test [sudo] password for root:
Like in above, I want to store the command
sudo touch file along with reason provided in a file every time I run a command.