Loading...

Lab 53: Terminal Commands (clear, exit, script)

Record a terminal session to a log file so troubleshooting work can be reviewed or shared without relying on memory. Use a clean workflow: reset the screen, capture the session, run a command for evidence, exit correctly, then review the transcript.

troubleshooting core

Scenario

You are troubleshooting a legacy system and must document exactly what was typed and what the system returned. Clear the screen to reduce noise, record the session to a log file, capture a hostname check as evidence, then end the session cleanly and review the transcript.

Operator context

Session transcripts support peer review, change records, and escalations. Logging your steps also protects you when diagnosing systems with inconsistent behavior.

Objective

  • Clear the terminal screen before starting.
  • Record a troubleshooting session using script.
  • Run hostname during the recorded session.
  • Exit the recording session properly.
  • Review the captured transcript.

Concepts

  • Screen reset using clear to reduce noise before capturing evidence.
  • Session logging using script with an explicit output filename.
  • Collecting a simple host identity artifact with hostname.
  • Cleanly terminating a recorded session using exit.
  • Viewing transcripts using cat or less.

Walkthrough

Step 1 : Clear the terminal screen before starting.
Command
clear

Clearing the screen removes unrelated output and produces a cleaner transcript. It does not erase shell history; it only redraws the terminal view.

Step 2 : Begin recording a terminal session to a file.
Command
script lab53.log

script records everything printed to the terminal during the session and writes it to the specified file. This produces a shareable transcript of the troubleshooting process.

Step 3 : Capture the hostname as evidence.
Command
hostname

Running hostname inside the recorded session provides a simple identity artifact showing which system the transcript applies to.

termhost.localdomain
Step 4 : End the script session properly.
Command
exit

When script is running, you are inside a subshell created for the recording session. Exiting cleanly stops the recording and writes the closing footer to the log.

Step 5 : View the session log.
Command
cat lab53.log
# OR
less lab53.log

Use cat for quick output or less for paging through longer transcripts. This confirms the recording completed successfully.

Script started on ...
hostname
termhost.localdomain
Script done on ...

Common breakpoints

Transcript file is empty or missing

The recording session may not have been exited properly. Ensure you run exit from inside the script subshell.

Wrong file reviewed

Confirm the filename passed to script. If no name was provided, the default typescript file may have been created instead.

Unexpected commands in transcript

Clear the screen before starting and avoid running unrelated commands during the recorded session.

Cleanup checklist

Remove the session log if it is no longer needed. This lab does not modify system configuration.

Commands
rm -f lab53.log
Success signal

The transcript file is removed and no artifacts remain from the session.

Reference

  • clear : Clears the terminal display.
  • script <file> : Records a terminal session and writes the transcript to a file.
  • hostname : Prints the system hostname.
  • exit : Ends the current shell session.
  • cat <file> : Outputs a file to standard output.
  • less <file> : Views a file interactively with paging.