AWS re/Start Lab · Linux

Linux Command Line

This lab introduces essential Linux commands for gathering system information, managing dates and calendars, and improving workflow efficiency through bash history and reverse search.

Lab Summary

Connected to the EC2 instance via PuTTY (as described in Lab 225). Ran system information commands like whoami, hostname, uptime, and who. Explored timezone-aware date display, Julian calendars, and bash history features including reverse search (CTRL+R) and command reuse (!!).

SSH Connection

Connected via PuTTY following the standard process established in Lab 225.

System Commands

Ran commands to identify the user, hostname, uptime, logged-in users, timezones, and calendar formats.

History & Search

Learned to review, search, and reuse previously executed commands from the bash history log.

Step-by-Step Walkthrough

Detailed record of each task performed during the lab.

01

SSH Connection

  • Connected to the EC2 instance via PuTTY following the process described in Lab 225.
02

Run Familiar Commands

  • Typed whoa and pressed Tab to trigger autocomplete, which expanded it to whoami. Pressed Enter to display the current username: ec2-user.
  • Ran hostname -s to display a shortened version of the host name.
  • Ran uptime -p to display how long the system has been running in a readable format.
  • Ran who -H -a to display information about all logged-in users, including headers for Name, Line, Time, Idle, PID, Comment, and Exit.
  • Ran TZ=America/New_York date and TZ=America/Los_Angeles date to display the current date and time in different timezones.
  • Ran cal -j to display the current month's calendar using the Julian date format, where days are numbered consecutively from the start of the year rather than restarting each month.
  • Ran cal -s and cal -m to see alternate calendar views: Sunday-start and Monday-start weeks respectively.
  • Ran id ec2-user to display the unique user ID (UID), group ID (GID), and group memberships for the current user.
03

Improve Workflow Through History and Search

  • Ran history to display the full log of all commands executed in the current session, numbered sequentially.
  • Pressed CTRL+R to open the reverse history search feature. Typed TZ and pressed Tab to autocomplete and recall the previous timezone command. This allowed editing and re-running old commands without retyping them.
  • Ran date to display the current system date and time. Then ran !! to immediately re-execute the last command (date) without retyping it.

Command Reference

Quick reference of all commands used in this lab and their options.

cmd

whoami

Displays the username of the current user.

cmd

hostname

Displays the system's host name.

  • -s : Show only the short hostname (without domain)
cmd

uptime

Shows how long the system has been running.

  • -p : Pretty format, human-readable output (e.g., "up 6 minutes")
cmd

who

Shows who is currently logged into the system.

  • -H : Print column headers (Name, Line, Time, etc.)
  • -a : Show all available information (login, idle, PID, exit)
cmd

date

Displays the current date and time.

  • TZ=America/New_York date : Show date/time in a specific timezone
  • TZ=America/Los_Angeles date : Same for another timezone
cmd

cal

Displays a calendar.

  • -j : Julian date format (days numbered from 1 to 365 across the year)
  • -s : Week starts on Sunday
  • -m : Week starts on Monday
cmd

id

Displays user identity information.

  • id <username> : Shows UID, GID, and group memberships for a specific user
cmd

history

Displays the list of previously executed commands, numbered sequentially.

  • CTRL+R : Open reverse history search to find and reuse old commands
  • !! : Re-execute the last command

Key Learnings

What Was Actually Learned

How to identify the current user, hostname, and system uptime from the terminal.
How to display date and time across different timezones using the TZ variable.
The difference between Gregorian and Julian date formats using cal.
How to use Tab autocomplete to speed up command typing.
How to review, reverse-search (CTRL+R), and rerun (!!) commands from bash history.

Technical Conclusion

This lab reinforced the value of knowing basic system information commands. Commands like whoami, hostname, and uptime are often the first steps in troubleshooting a remote server, and knowing how to quickly identify who you are, where you are, and how long the system has been running is essential.

The history features (history, CTRL+R, !!) are workflow accelerators that reduce repetitive typing. In real-world scenarios, reverse search is particularly useful when recalling complex commands with long arguments that were executed earlier in a session.