How to record the session of commands in a Linux

How to start the recording session?

First of all,  we will start the session that will record or store every commands we will type on the Terminal. Go to terminal and type:

script recordfile.txt
1
script recordfile.txt

After you hit enter the script has been started.

recording session

Here, recordfile.txt is the file name where our sessions is going to be stored. You can type the filename whatever you want.

The recording has begun. Whatever you type, it is stored in recordfile.txt.

How to stop the session?

To stop the session or the script hit Ctrl+D in your keyboard.

Now, you can see you textfile and find out the commands that has been recorded.

To view the text file:

cat recordfile.txt

How to append the session in the same file?

You have stopped the session, now what if you want to continue the session in that same text file. It’s easy go to terminal and type

script -a recordfile.txt
1
script -a recordfile.txt

To stop and view the file, follow the same step.

Advertisements