Home     Blog

How to Capture a Unix Terminal Session

One of the best methods to capture a Unix terminal session is to use the `script` command.

In this example we start a script session, run a couple of commands, and then use the `exit` command to stop capturing the terminal session:

$ script
Script started, output file is typescript
$ pwd
/home/will
$ ps
 PID TT STAT TIME COMMAND
11909 p0 Ss 0:00.05 -bash (bash)
25622 p0 S+ 0:00.01 script
25623 p1 Ss 0:00.01 /usr/local/bin/bash -i
25624 p1 R+ 0:00.00 ps
$ exit
Script done, output file is typescript

We have now captured our terminal session into the file "typescript".

We can use the `cat` command to view the contents of the "typescript" file: How to Capture a Unix Terminal Session

$ cat typescript
Script started on Tue Jul 26 21:28:50 2005
$ pwd
/home/will
$ ps
 PID TT STAT TIME COMMAND
11909 p0 Ss 0:00.05 -bash (bash)
25622 p0 S+ 0:00.01 script
25623 p1 Ss 0:00.01 /usr/local/bin/bash -i
25624 p1 R+ 0:00.00 ps
$ exit
Script done on Tue Jul 26 21:29:13 2005
VN:F [1.9.17_1161]
Rating: 0.0/10 (0 votes cast)
Follow Will.Spencer on

Comments (2)

 

  1. MrBCut says:

    Thank you so much! Compact, clear and concise! I learned. :)

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)
  2. Raj says:

    Thank you exactly what I was looking for

    VA:F [1.9.17_1161]
    Rating: 0.0/5 (0 votes cast)

Leave a Reply

Related Posts

  • Unix Scripts

    A Unix script is a program which is written in a programming language built into one of the Unix shells. If you can type commands into the Unix shell, you can write a shell script. A shell script can be as simple as a text file containing a list of commands. Let’s say that you [...]...


  • How to Use the Unix Grep Command

    The Unix grep command is a search command built into a variety of Unix based operating systems. This command line utility, whose name stems from the original Unix term which means “search globally for lines matching the regular expression, and print them,” can be accessed using the command line or terminal from anywhere in the [...]...


  • Securing Application and Terminal Servers

    Application and Terminal Servers Security Issues Organizations use Application servers to make data available on the network. For instance, the application server role makes Web applications and distributed applications available to users. A Web server usually contains a copy of a World Wide Web site and can also host Web based applications. Application servers can [...]...


  • How Unix Timestamps Work

    Unix stores two times for every file, the last modification time of the file and the last access time of the file. `ls -lT` displays the last modification time of files. bash-2.05a$ ls -lT timestamp.shtml -rw-r–r– 1 will staff 885 Mar 5 01:50:53 2004 timestamp.shtml `ls -lTu` displays the last access time of files. bash-2.05a$ [...]...


  • How to Take a Screen Capture

    Screen captures are, literally, ‘captures’ of the images on a computer’s screen. This is necessary when one needs troubleshooting help for an unexpected system error, in which case it would help if an image of the error message can be procured and sent to the technical support personnel. It can also be used to capture [...]...