{
    "mode": "man",
    "parameter": "SCRIPT",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/SCRIPT/1/json",
    "generated": "2026-06-13T22:56:09Z",
    "synopsis": "script [options] [file]",
    "sections": {
        "NAME": {
            "content": "script - make typescript of terminal session\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "script [options] [file]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "script makes a typescript of everything on your terminal session. The terminal data are\nstored in raw form to the log file and information about timing to another (optional)\nstructured log file. The timing log file is necessary to replay the session later by\nscriptreplay(1) and to store additional information about the session.\n\nSince version 2.35, script supports multiple streams and allows the logging of input and\noutput to separate files or all the one file. This version also supports new timing file\nwhich records additional information. The command scriptreplay --summary then provides all\nthe information.\n\nIf the argument file or option --log-out file is given, script saves the dialogue in this\nfile. If no filename is given, the dialogue is saved in the file typescript.\n\nNote that logging input using --log-in or --log-io may record security-sensitive information\nas the log file contains all terminal session input (e.g., passwords) independently of the\nterminal echo flag setting.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "Below, the size argument may be followed by the multiplicative suffixes KiB (=1024), MiB\n(=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB (the \"iB\" is optional, e.g., \"K\"\nhas the same meaning as \"KiB\"), or the suffixes KB (=1000), MB (=1000*1000), and so on for\nGB, TB, PB, EB, ZB and YB.\n",
            "subsections": [
                {
                    "name": "-a --append",
                    "content": "Append the output to file or to typescript, retaining the prior contents.\n",
                    "flag": "-a",
                    "long": "--append"
                },
                {
                    "name": "-c --command",
                    "content": "Run the command rather than an interactive shell. This makes it easy for a script to\ncapture the output of a program that behaves differently when its stdout is not a tty.\n",
                    "flag": "-c",
                    "long": "--command"
                },
                {
                    "name": "-E --echo",
                    "content": "This option controls the ECHO flag for the slave end of the session’s pseudoterminal. The\nsupported modes are always, never, or auto.\n\nThe default is auto — in this case, ECHO enabled for the pseudoterminal slave; if the\ncurrent standard input is a terminal, ECHO is disabled for it to prevent double echo; if\nthe current standard input is not a terminal (for example pipe: echo date | script) then\nkeeping ECHO enabled for the pseudoterminal slave enables the standard input data to be\nviewed on screen while being recorded to session log simultaneously.\n\nNote that 'never' mode affects content of the session output log, because users input is\nnot repeated on output.\n",
                    "flag": "-E",
                    "long": "--echo"
                },
                {
                    "name": "-e --return",
                    "content": "Return the exit status of the child process. Uses the same format as bash termination on\nsignal termination (i.e., exit status is 128 + the signal number). The exit status of the\nchild process is always stored in the type script file too.\n",
                    "flag": "-e",
                    "long": "--return"
                },
                {
                    "name": "-f --flush",
                    "content": "Flush output after each write. This is nice for telecooperation: one person does mkfifo\nfoo; script -f foo, and another can supervise in real-time what is being done using cat\nfoo. Note that flush has an impact on performance; it’s possible to use SIGUSR1 to flush\nlogs on demand.\n",
                    "flag": "-f",
                    "long": "--flush"
                },
                {
                    "name": "--force",
                    "content": "Allow the default output file typescript to be a hard or symbolic link. The command will\nfollow a symbolic link.\n",
                    "long": "--force"
                },
                {
                    "name": "-B --log-io",
                    "content": "Log input and output to the same file. Note, this option makes sense only if --log-timing\nis also specified, otherwise it’s impossible to separate output and input streams from\nthe log file.\n",
                    "flag": "-B",
                    "long": "--log-io"
                },
                {
                    "name": "-I --log-in",
                    "content": "Log input to the file. The log output is disabled if only --log-in specified.\n\nUse this logging functionality carefully as it logs all input, including input when\nterminal has disabled echo flag (for example, password inputs).\n",
                    "flag": "-I",
                    "long": "--log-in"
                },
                {
                    "name": "-O --log-out",
                    "content": "Log output to the file. The default is to log output to the file with name typescript if\nthe option --log-out or --log-in is not given. The log output is disabled if only\n--log-in specified.\n",
                    "flag": "-O",
                    "long": "--log-out"
                },
                {
                    "name": "-T --log-timing",
                    "content": "Log timing information to the file. Two timing file formats are supported now. The\nclassic format is used when only one stream (input or output) logging is enabled. The\nmulti-stream format is used on --log-io or when --log-in and --log-out are used together.\nSee also --logging-format.\n",
                    "flag": "-T",
                    "long": "--log-timing"
                },
                {
                    "name": "-m --logging-format",
                    "content": "Force use of advanced or classic format. The default is the classic format to log only\noutput and the advanced format when input as well as output logging is requested.\n\nClassic format\nThe log contains two fields, separated by a space. The first field indicates how much\ntime elapsed since the previous output. The second field indicates how many\ncharacters were output this time.\n\nAdvanced (multi-stream) format\nThe first field is an entry type identifier ('I’nput, 'O’utput, 'H’eader, 'S’ignal).\nThe socond field is how much time elapsed since the previous entry, and the rest of\nthe entry is type-specific data.\n",
                    "flag": "-m",
                    "long": "--logging-format"
                },
                {
                    "name": "-o --output-limit",
                    "content": "Limit the size of the typescript and timing files to size and stop the child process\nafter this size is exceeded. The calculated file size does not include the start and done\nmessages that the script command prepends and appends to the child process output. Due to\nbuffering, the resulting output file might be larger than the specified value.\n",
                    "flag": "-o",
                    "long": "--output-limit"
                },
                {
                    "name": "-q --quiet",
                    "content": "Be quiet (do not write start and done messages to standard output).\n",
                    "flag": "-q",
                    "long": "--quiet"
                },
                {
                    "name": "-t --timing",
                    "content": "Output timing data to standard error, or to file when given. This option is deprecated in\nfavour of --log-timing where the file argument is not optional.\n",
                    "flag": "-t",
                    "long": "--timing"
                },
                {
                    "name": "-V --version",
                    "content": "Display version information and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-h --help",
                    "content": "Display help text and exit.\n",
                    "flag": "-h",
                    "long": "--help"
                }
            ]
        },
        "SIGNALS": {
            "content": "Upon receiving SIGUSR1, script immediately flushes the output files.\n",
            "subsections": []
        },
        "ENVIRONMENT": {
            "content": "The following environment variable is utilized by script:\n\nSHELL\nIf the variable SHELL exists, the shell forked by script will be that shell. If SHELL is\nnot set, the Bourne shell is assumed. (Most shells set this variable automatically).\n",
            "subsections": []
        },
        "NOTES": {
            "content": "The script ends when the forked shell exits (a control-D for the Bourne shell (sh(1p)), and\nexit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1)).\n\nCertain interactive commands, such as vi(1), create garbage in the typescript file. script\nworks best with commands that do not manipulate the screen, the results are meant to emulate\na hardcopy terminal.\n\nIt is not recommended to run script in non-interactive shells. The inner shell of script is\nalways interactive, and this could lead to unexpected results. If you use script in the shell\ninitialization file, you have to avoid entering an infinite loop. You can use for example the\n.profile file, which is read by login shells only:\n\nif test -t 0 ; then\nscript\nexit\nfi\n\nYou should also avoid use of script in command pipes, as script can read more input than you\nwould expect.\n",
            "subsections": []
        },
        "HISTORY": {
            "content": "The script command appeared in 3.0BSD.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "script places everything in the log file, including linefeeds and backspaces. This is not\nwhat the naive user expects.\n\nscript is primarily designed for interactive terminal sessions. When stdin is not a terminal\n(for example: echo foo | script), then the session can hang, because the interactive shell\nwithin the script session misses EOF and script has no clue when to close the session. See\nthe NOTES section for more information.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "csh(1) (for the history mechanism), scriptreplay(1), scriptlive(1)\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "The script command is part of the util-linux package which can be downloaded from Linux\nKernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\n\n\nutil-linux 2.37.2                            2021-06-02                                    SCRIPT(1)",
            "subsections": []
        }
    },
    "summary": "script - make typescript of terminal session",
    "flags": [
        {
            "flag": "-a",
            "long": "--append",
            "arg": null,
            "description": "Append the output to file or to typescript, retaining the prior contents."
        },
        {
            "flag": "-c",
            "long": "--command",
            "arg": null,
            "description": "Run the command rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty."
        },
        {
            "flag": "-E",
            "long": "--echo",
            "arg": null,
            "description": "This option controls the ECHO flag for the slave end of the session’s pseudoterminal. The supported modes are always, never, or auto. The default is auto — in this case, ECHO enabled for the pseudoterminal slave; if the current standard input is a terminal, ECHO is disabled for it to prevent double echo; if the current standard input is not a terminal (for example pipe: echo date | script) then keeping ECHO enabled for the pseudoterminal slave enables the standard input data to be viewed on screen while being recorded to session log simultaneously. Note that 'never' mode affects content of the session output log, because users input is not repeated on output."
        },
        {
            "flag": "-e",
            "long": "--return",
            "arg": null,
            "description": "Return the exit status of the child process. Uses the same format as bash termination on signal termination (i.e., exit status is 128 + the signal number). The exit status of the child process is always stored in the type script file too."
        },
        {
            "flag": "-f",
            "long": "--flush",
            "arg": null,
            "description": "Flush output after each write. This is nice for telecooperation: one person does mkfifo foo; script -f foo, and another can supervise in real-time what is being done using cat foo. Note that flush has an impact on performance; it’s possible to use SIGUSR1 to flush logs on demand."
        },
        {
            "flag": "",
            "long": "--force",
            "arg": null,
            "description": "Allow the default output file typescript to be a hard or symbolic link. The command will follow a symbolic link."
        },
        {
            "flag": "-B",
            "long": "--log-io",
            "arg": null,
            "description": "Log input and output to the same file. Note, this option makes sense only if --log-timing is also specified, otherwise it’s impossible to separate output and input streams from the log file."
        },
        {
            "flag": "-I",
            "long": "--log-in",
            "arg": null,
            "description": "Log input to the file. The log output is disabled if only --log-in specified. Use this logging functionality carefully as it logs all input, including input when terminal has disabled echo flag (for example, password inputs)."
        },
        {
            "flag": "-O",
            "long": "--log-out",
            "arg": null,
            "description": "Log output to the file. The default is to log output to the file with name typescript if the option --log-out or --log-in is not given. The log output is disabled if only --log-in specified."
        },
        {
            "flag": "-T",
            "long": "--log-timing",
            "arg": null,
            "description": "Log timing information to the file. Two timing file formats are supported now. The classic format is used when only one stream (input or output) logging is enabled. The multi-stream format is used on --log-io or when --log-in and --log-out are used together. See also --logging-format."
        },
        {
            "flag": "-m",
            "long": "--logging-format",
            "arg": null,
            "description": "Force use of advanced or classic format. The default is the classic format to log only output and the advanced format when input as well as output logging is requested. Classic format The log contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. Advanced (multi-stream) format The first field is an entry type identifier ('I’nput, 'O’utput, 'H’eader, 'S’ignal). The socond field is how much time elapsed since the previous entry, and the rest of the entry is type-specific data."
        },
        {
            "flag": "-o",
            "long": "--output-limit",
            "arg": null,
            "description": "Limit the size of the typescript and timing files to size and stop the child process after this size is exceeded. The calculated file size does not include the start and done messages that the script command prepends and appends to the child process output. Due to buffering, the resulting output file might be larger than the specified value."
        },
        {
            "flag": "-q",
            "long": "--quiet",
            "arg": null,
            "description": "Be quiet (do not write start and done messages to standard output)."
        },
        {
            "flag": "-t",
            "long": "--timing",
            "arg": null,
            "description": "Output timing data to standard error, or to file when given. This option is deprecated in favour of --log-timing where the file argument is not optional."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Display version information and exit."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Display help text and exit."
        }
    ],
    "examples": [],
    "see_also": [
        {
            "name": "csh",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/csh/1/json"
        },
        {
            "name": "scriptreplay",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/scriptreplay/1/json"
        },
        {
            "name": "scriptlive",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/scriptlive/1/json"
        }
    ],
    "tldr": {
        "source": "official",
        "description": "Record all terminal output to a typescript file.",
        "examples": [
            {
                "description": "Record a new session to a file named `typescript` in the current directory",
                "command": "script"
            },
            {
                "description": "Stop recording",
                "command": "exit"
            },
            {
                "description": "Record a new session to a custom filepath",
                "command": "script {{path/to/session.out}}"
            },
            {
                "description": "Append to an existing file",
                "command": "script {{-a|--append}} {{logfile.log}}"
            },
            {
                "description": "Record timing information (data is outputted to `stderr`)",
                "command": "script {{-t|--timing}} 2> {{path/to/timing_file}}"
            },
            {
                "description": "Write out data as soon as it happens",
                "command": "script {{-f|--flush}} {{path/to/file}}"
            },
            {
                "description": "Execute quietly without start and done messages",
                "command": "script {{-q|--quiet}} {{logfile.log}}"
            },
            {
                "description": "Display help",
                "command": "script {{-h|--help}}"
            }
        ]
    }
}