Back to Blog

Introduction to Linux Terminal - Your First Commands | whoami, hostname, date, cal

Sandy LaneSandy Lane

Video: Introduction to Linux Terminal - Your First Commands | whoami, hostname, date, cal by Taught by Celeste AI - AI Coding Coach

Watch full page →

Introduction to Linux Terminal - Your First Commands

The Linux terminal is a powerful text-based interface that lets you interact directly with your computer by typing commands. This introduction covers the basics of the terminal prompt and essential commands like whoami, hostname, date, and cal to help you get started with system information and time management.

Code

# Show the current username
whoami

# Display the computer's hostname
hostname

# Show the current date and time
date

# Show the current date and time with custom formatting (Year-Month-Day Hour:Minute:Second)
date '+%Y-%m-%d %H:%M:%S'

# Display the calendar for the current month
cal

# Display the calendar for the entire year 2024
cal 2024

Key Points

  • The terminal prompt typically shows your username, hostname, and current directory, ending with a $ or # symbol.
  • whoami reveals the current logged-in username, helping you confirm your user identity.
  • hostname displays your computer’s network name, useful for identifying your machine.
  • date shows the current date and time, and can be customized with format strings for precise output.
  • cal displays a calendar; without arguments it shows the current month, or you can specify a year to see the full calendar.