# script

## Introduction

`script` command makes a typescript of everything on your terminal session. The terminal data are stored in raw form to the log file and information about timing to another (optional) structured log file.

***

## Syntax

`script [options] [file]`

***

## Important Flags

| Flag                   | Description                                     |
| ---------------------- | ----------------------------------------------- |
| `-I, --log-in`         | log stdin to file                               |
| `-O, --log-out`        | log stdout to file (default)                    |
| `-B, --log-io`         | log stdin and stdout to file                    |
| `-T, --log-timing`     | log timing information to file                  |
| `-t[], --timing[=]`    | deprecated alias to -T (default file is stderr) |
| `-m, --logging-format` | force to 'classic' or 'advanced' format         |
| `-a, --append`         | append to the log file                          |
| `-c, --command`        | run command rather than interactive shell       |
| `-e, --return`         | return exit code of the child process           |
| `-f, --flush`          | run flush after each write                      |
| `--force`              | use output file even when it is a link          |
| `-E, --echo`           | echo input in session (auto, always or never)   |
| `-o, --output-limit`   | terminate if output files exceed size           |
| `-q, --quiet`          | be quiet                                        |
| `-h, --help`           | display this help                               |
| `-V, --version`        | display version                                 |

***

## Examples

<table><thead><tr><th>Command</th><th>Description</th></tr></thead><tbody><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script
</code></pre></td><td>To start a typescript without any argument. If no filename is given as argument, script will automatically create a file namely typescript in the home directory to save the recorded information.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script mysession.log
</code></pre></td><td>This command starts a new recording session, with the output stored in the 'mysession.log' file.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script $(date '+%d-%m-%Y')_session.log
</code></pre></td><td>This command records the terminal session and saves the output into a file with the current date as part of the name.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">exit
</code></pre></td><td>In order to stop the typescript, we just need to execute exit command and script will stop the capturing process.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -a -f filename.txt
</code></pre></td><td>To start the typescript, run any random command and save it in a text file, let’s say filename.txt.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -c "cal"
</code></pre></td><td>To get the typescript of cal command.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -c 'ls -la' directory_listing.log
</code></pre></td><td>This command runs 'ls -la' and records its output into 'directory_listing.log' file.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -c 'ls -la' | tee file.log
</code></pre></td><td>This command runs 'ls -la', displays its output and simultaneously saves it into 'file.log'.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -f
</code></pre></td><td>This option is used to run flush output after each write.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script --force
</code></pre></td><td>This option allows default output file i.e. typescript to be hard or symbolic link.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -h
</code></pre></td><td>Display this help and exit.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -q
</code></pre></td><td>This option does not display the notification stating that the script has started and quietly execute and exit the script command.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -t timing_file.txt
</code></pre></td><td>This option allows user to capture the terminal activity step by step and appears like a video when the recorded file is executed with the help of scriptreplay command.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">scriptreplay --timing=time_log geeksforgeeks1
</code></pre></td><td>To replay the captured terminal activity.</td></tr><tr><td><pre class="language-bash" data-overflow="wrap"><code class="lang-bash">script -V
</code></pre></td><td>Output version information and exit.</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://thamizhiniyancs.gitbook.io/cheatsheets/linux/knowing-about-files-commands/script.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
