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. Practice 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 need to document exactly what was typed and what the system returned. You will 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 are useful for peer review, change records, and escalation. Logging your steps also protects you when diagnosing a system 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.

What You’ll Practice

  • 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 is a simple way to remove unrelated output and make it easier to capture a clean transcript. It does not delete 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 file you provide. This is a lightweight way to generate a shareable transcript of what happened.

Step 3 : Capture the hostname as evidence.
Command
hostname

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

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

When script is running, the shell you are using is a subshell created for the recording session. Exiting cleanly ends 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 validates the recording completed successfully and captured expected content.

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

Reference

  • clear : Clears the terminal display to reduce on-screen clutter.
  • script <file> : Records a terminal session and writes the transcript to a file.
    • Providing an explicit filename (for example lab53.log) makes the output predictable.
  • hostname : Prints the system hostname.
  • exit : Ends the current shell session. When used inside a script session, it stops recording and closes the transcript.
  • cat <file> : Outputs a file to standard output.
  • less <file> : Views a file interactively with paging and search.