SCRIPT(1)

๐Ÿ’– SCRIPT(1) โ€” or, how to record literally everything your terminal does ๐Ÿ’–

okay bestie, welcome to script(1) from the User Commands corner of the manual. she's a little chaotic, she's a little powerful, and she's about to make a full-on movie of your terminal session. no cap. ๐ŸŽฌโœจ


โœจ NAME โœจ

script โ€” make a typescript of your terminal session. like, the whole thing. every keystroke, every glow-up, every typo. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

script [options] [file] [-- command [argument...]]

that's it. that's the whole vibe. options, maybe a file, maybe a command after the --. periodt. ๐Ÿ‘‘


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so script makes a typescript of everything that happens on your terminal session. not a summary, not a highlight reel โ€” everything. ๐Ÿ˜ญ

the terminal data gets stored in raw form in the log file, and the info about timing goes into a different, optional, structured log file. that timing log file is not just decoration, bestie โ€” you need it if you wanna replay the session later with scriptreplay(1), and it's also where extra session info gets stashed. ๐Ÿซถ

since version 2.35, script supports multiple streams and lets you log input and output to separate files or all in one file. iconic behavior honestly. this version also has a new timing file that records additional information โ€” and then scriptreplay --summary serves you the whole tea. โ˜•โœจ

if you pass the argument file, or you use the option --log-out file, then script saves the dialogue into that file. if you give her no filename at all, the dialogue lands in a file called typescript. that's just her default name, she's not being mysterious. ๐ŸŽ€

โš ๏ธ real talk, listen up: logging input with --log-in or --log-io can record security-sensitive information, because the log file will contain all terminal session input โ€” yes, including passwords โ€” and it does not care whether the terminal echo flag is on or off. it logs it anyway. be careful, bestie. fr fr. ๐Ÿ’€

๐Ÿ’… OPTIONS ๐Ÿ’…

first, a lil public service announcement about sizes, because it applies below:

the size argument may be followed by the multiplicative suffixes KiB (=1024), MiB (=1024*1024), and so on for GiB, TiB, PiB, EiB, ZiB and YiB โ€” and the "iB" part is optional, so for example "K" means exactly the same thing as "KiB". โœจ or you can go with the suffixes KB (=1000), MB (=1000*1000), and so on for GB, TB, PB, EB, ZB and YB. yes the 1000 vs 1024 thing is real and yes you should care. ๐ŸŒˆ

  • -a, --append โ€” append the output to file or to typescript, and keep all the prior contents. nothing gets deleted, nothing gets overwritten, she just keeps adding. ๐Ÿงš
  • -c, --command command โ€” run command instead of an interactive shell. this is lowkey the move when a script needs to capture the output of a program that acts different when its stdout isn't a tty. and heads up: instead of using the option -c, you can also just put the command after a double dash (--). same energy. ๐Ÿซถ
  • -E, --echo when โ€” this one 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 that case, ECHO is enabled for the pseudoterminal slave; if the current standard input is a terminal, ECHO gets disabled for it so you don't get double echo; and if the current standard input is not a terminal (for example pipe: echo date | script) then keeping ECHO enabled for the pseudoterminal slave means the standard input data can be viewed on screen while it's being recorded to the session log at the same time. multitasking queen. โœจ
    • and ngl, 'never' mode does affect the content of the session output log, because the user's input is not repeated on the output. so like. just know that. ๐Ÿ˜ญ
  • -e, --return โ€” return the exit status of the child process. it uses the same format as bash termination on signal termination (i.e., exit status is 128 + the signal number). and btw the exit status of the child process is always stored in the type script file too. so you get it either way. ๐Ÿ’–
  • -f, --flush โ€” flush output after every single write. this is chef's kiss for telecooperation: one person runs mkfifo foo; script -f foo, and another person can supervise in real-time what's being done using cat foo. adorable. but also โ€” flush has an impact on performance, so don't forget that. good news though: it's possible to use SIGUSR1 to flush logs on demand. ๐Ÿ”ฅ
  • --force โ€” allow the default output file typescript to be a hard or symbolic link. and yes, the command will follow a symbolic link. ๐Ÿฆ‹
  • -B, --log-io file โ€” log input and output to the same file. but listen: this option only makes sense if --log-timing is also specified, otherwise it's literally impossible to separate the output and input streams from the log file. iykyk. ๐Ÿ’€
  • -I, --log-in file โ€” log input to file. and just so you know, the log output gets disabled if only --log-in is specified. ๐ŸŽ€
    • > use this logging functionality carefully, bestie, because it logs all input, including input from when the terminal has the echo flag disabled โ€” you know, like password inputs. ๐Ÿ™ˆ
  • -O, --log-out file โ€” log output to file. the default is to log output to the file named typescript if neither the option --log-out nor --log-in is given. and the log output gets disabled if only --log-in is specified. (yeah, same rule as above, they're besties.) ๐Ÿ’œ
  • -T, --log-timing file โ€” log timing information to file. there are two timing file formats supported right now: the classic format is used when only one stream (input or output) logging is enabled, and the multi-stream format is used on --log-io or when --log-in and --log-out are used together. see also --logging-format. โœจ
  • -m, --logging-format format โ€” force use of the advanced or classic timing log 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 timing 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. simple. clean. cute.
    • Advanced (multi-stream) format
      • the first field is an entry type identifier ('I'nput, 'O'utput, 'H'eader, 'S'ignal). the second field is how much time elapsed since the previous entry, and the rest of the entry is type-specific data. ๐ŸŒˆ
  • -o, --output-limit size โ€” limit the size of the typescript and timing files to size, and stop the child process after this size is exceeded. important detail: the calculated file size does not include the start and done messages that the script command prepends and appends to the child process output. and because of buffering, the resulting output file might actually be larger than the value you specified. she tried her best. ๐Ÿ˜ญ
  • -q, --quiet โ€” be quiet, bestie. meaning: do not write start and done messages to standard output. ๐Ÿคซ
  • -t[file], --timing[=file] โ€” 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. she's retired, let her rest. ๐Ÿ’…
  • -h, --help โ€” display help text and exit. the classic. ๐Ÿซถ
  • -V, --version โ€” display version and exit. also the classic. โญ

๐ŸŒˆ SIGNALS ๐ŸŒˆ

upon receiving SIGUSR1, script immediately flushes the output files. that's it. that's the whole section. she heard you. ๐Ÿ””


๐Ÿงš ENVIRONMENT ๐Ÿงš

the following environment variable is utilized by script:

  • SHELL โ€” if the variable SHELL exists, the shell forked by script will be that shell. if SHELL is not set, the Bourne shell is assumed. (and most shells set this variable automatically, so like, no stress.) ๐Ÿ’–

๐ŸŽ€ NOTES ๐ŸŽ€

  • the script ends when the forked shell exits โ€” that's a control-D for the Bourne shell (sh(1p)), and exit, logout or control-d (if ignoreeof is not set) for the C-shell, csh(1). ๐Ÿ‘‹
  • certain interactive commands, such as vi(1), create garbage in the typescript file. ๐Ÿ˜ญ script works best with commands that do not manipulate the screen โ€” the results are meant to emulate a hardcopy terminal. vintage vibes only. ๐Ÿ–จ๏ธ
  • it is not recommended to run script in non-interactive shells. the inner shell of script is always interactive, and this could lead to unexpected results. and if you use script in the shell initialization file, you have to avoid entering an infinite loop. you can use, for example, the .profile file, which is read by login shells only:
if test -t 0 ; then
    script
    exit
fi
  • you should also avoid use of script in command pipes, because script can read more input than you would expect. she's greedy like that. ๐Ÿ™ˆ

โญ HISTORY โญ

the script command appeared in 3.0BSD. she's an elder, respect her. ๐Ÿ‘‘


๐Ÿ’€ BUGS ๐Ÿ’€

  • script places everything in the log file, including linefeeds and backspaces. this is not what the naive user expects. surprise! ๐ŸŽ‰
  • script is primarily designed for interactive terminal sessions. when stdin is not a terminal (for example: echo foo | script), then the session can hang, because the interactive shell within the script session misses EOF and script has no clue when to close the session. see the NOTES section for more information. ๐Ÿ’…

๐Ÿซถ SEE ALSO ๐Ÿซถ

csh(1) (for the history mechanism), scriptreplay(1), scriptlive(1)


๐Ÿ› REPORTING BUGS ๐Ÿ›

for bug reports, use the issue tracker <https://github.com/util-linux/util-linux/issues>.


๐ŸŒธ AVAILABILITY ๐ŸŒธ

the script command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.


and that's the whole page, bestie!! ๐ŸŽ‰ this lil masterpiece is brought to you by util-linux version 2.42.4, dated 2026-09-21, and it's the SCRIPT(1) page โ€” go forth and record your terminal like the main character you are. ๐Ÿ’–โœจ๐Ÿ‘‘๐Ÿฆ‹๐Ÿ’…

๐Ÿ“ฆ where this page comes from
  • arch rolling: util-linux 2.42.4-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4-Clause-UC AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND ISC AND LGPL-2.1-or-later AND LicenseRef-PublicDomain
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms