Record Linux Terminal Commands

#Introduction

This tutorial, How to Record Linux Terminal Commands use script command. It’s records and replay activity in your terminal.
the script commands are helpful when you want to create a tutorial for all the commands.

Record Linux Terminal Commands

The script command can be run without any arguments

script

A new capturing session will start. your terminal session is saved to ./typescipt in your working directory.
When you’re done, press Ctrl+D or type exit command to drop out of the sub-shell.

The output terminal is as follows

[vagrant@localhost ~]$ script

Script started, file is typescript
[vagrant@localhost ~]$ ls
share  typescript
[vagrant@localhost ~]$ whoami
vagrant
[vagrant@localhost ~]$ exit
exit
Script done, file is typescript
[vagrant@localhost ~]$
[vagrant@localhost ~]$ cat typescript
Script started on Sat 18 Sep 2021 08:59:49 PM +07
[vagrant@localhost ~]$ ls
share  typescript
[vagrant@localhost ~]$ whoami
vagrant
[vagrant@localhost ~]$ exit
exit

Script done on Sat 18 Sep 2021 09:00:09 PM +07
[vagrant@localhost ~]$

You can specify a different file with script command an argument:

script session_`hostname`_`whoami`

The output terminal is as follows:

[vagrant@localhost ~]$ script session_`hostname`_`whoami`
Script started, file is session_localhost.localdomain_vagrant
[vagrant@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[vagrant@localhost ~]$ exit
Script done, file is session_localhost.localdomain_vagrant
[vagrant@localhost ~]$

Appending to an Existing File

Use -a flag to append your commands.

script -a session_`hostname`_`whoami`

Conclusion

You have Record Linux Terminal Commands. I hope will this your helpful. Thank you for reading the DevopsRoles page!

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

4 thoughts on “Record Linux Terminal Commands

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

This site uses Akismet to reduce spam. Learn how your comment data is processed.