0
0
Linux-cliHow-ToBeginner · 3 min read

How to Use cal Command in Linux: Syntax and Examples

The cal command in Linux shows a calendar in the terminal. You can run cal alone to see the current month or add a year or month and year to see other calendars, like cal 2024 or cal 12 2024.
📐

Syntax

The basic syntax of the cal command is:

  • cal - shows the current month's calendar.
  • cal [year] - shows the calendar for the entire year.
  • cal [month] [year] - shows the calendar for a specific month and year.

Here, month is a number from 1 to 12, and year is a four-digit number like 2024.

bash
cal
cal 2024
cal 12 2024
💻

Example

This example shows how to display the calendar for December 2024 using cal. It prints the full month with days aligned under weekdays.

bash
cal 12 2024
Output
December 2024 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
⚠️

Common Pitfalls

Common mistakes when using cal include:

  • Entering the month and year in the wrong order (month must come before year).
  • Using invalid month numbers (must be 1 to 12).
  • Expecting cal to show events or holidays (it only shows dates).

For example, cal 2024 12 is wrong; the correct command is cal 12 2024.

bash
cal 2024 12
cal 13 2024
Output
cal: invalid month cal: invalid month
📊

Quick Reference

CommandDescription
calShow current month's calendar
cal 2024Show calendar for the year 2024
cal 12 2024Show calendar for December 2024
cal -3Show calendar for 3 months before current month
cal -m 5Show calendar for May of current year

Key Takeaways

Use cal alone to see the current month's calendar quickly.
Specify month and year as cal [month] [year] to see any month.
Always put the month number before the year number.
Month must be between 1 and 12; invalid inputs cause errors.
cal only shows dates, not events or holidays.