I've learned that documentation is a huge part of an admin's daily routine. Most processes are documented—ranging from server configurations and network setups to software installations, user accounts, and troubleshooting procedures. I've even been told that as much as 70% of the job involves documentation.
I've written this post to share a simple Linux command that I've found especially helpful for my own documentation and note-taking: the script command.
Here are the steps for using the script command:
Run the following command to start recording your session:
script record_session.txt (file name is up to you)Begin working as usual. All input and output during the session will be saved to the file specified in step 1
When you're finished, type exit or ctrl-d to quit the script command.
At this point, I usually run cat on the file to review its contents, then copy and paste it into a new document where I can add notes or additional context as needed.
Note: The created file may contain some binary or control characters, so if you open it with less or vi, you might see a lot of non-human-readable output.
Using less -fr will print the file clearly.
Below is a brief terminal example:
[sorad@dev9 ~]$ script record_cli.txt
Script started, output log file is 'record_cli.txt'.
[sorad@dev9 ~]$ w
12:34:10 up 5 days, 20:54, 1 user, load average: 0.00, 0.00, 0.00
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
sorad pts/0 11:30 2.00s 0.05s 0.00s script record_cli.txt
[sorad@dev9 ~]$ mkdir testy/testerson
mkdir: cannot create directory ‘testy/testerson’: No such file or directory
[sorad@dev9 ~]$ mkdir -pv testy/testerson
mkdir: created directory 'testy'
mkdir: created directory 'testy/testerson'
[sorad@dev9 ~]$ exit
exit
Script done.
File contents of record_cli.txt:
[sorad@dev9 ~]$ cat record_cli.txt
Script started on 2025-05-20 12:33:56-04:00 [TERM="xterm-256color" TTY="/dev/pts/0" COLUMNS="80" LINES="24"]
[sorad@dev9 ~]$ w
12:34:10 up 5 days, 20:54, 1 user, load average: 0.00, 0.00, 0.00
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
sorad pts/0 11:30 2.00s 0.05s 0.00s script record_cli.txt
[sorad@dev9 ~]$ mkdir testy/testerson
mkdir: cannot create directory ‘testy/testerson’: No such file or directory
[sorad@dev9 ~]$ mkdir -pv testy/testerson
mkdir: created directory 'testy'
mkdir: created directory 'testy/testerson'
[sorad@dev9 ~]$ exit
exit
Script done on 2025-05-20 12:34:52-04:00 [COMMAND_EXIT_CODE="0"]
Let me know if you found this helpful. Thank you for reading.
Top comments (0)