Skip to main content

Module 7: System Information & Monitoring

Lesson 69: cal Command

In this lesson, you'll learn how to use the cal command to display calendars in the terminal for the current month, any specific month, any year past or future, and in several display formats useful for scripting and date planning.

The cal command is part of the util-linux package and comes pre-installed on almost all Linux distributions.

It reads the system date from the kernel and renders formatted calendars directly in the terminal, no GUI, no browser, no internet connection required.

While it may seem simple at first glance, cal has several options that make it genuinely useful for sysadmins scheduling maintenance windows, developers checking date ranges, and anyone working heavily in the terminal who needs a quick calendar reference.

Installation

If cal is not available on your system, install it with:

sudo apt install ncal        # Debian/Ubuntu

Or:

sudo dnf install util-linux  # RHEL/CentOS/Fedora

Syntax

cal [OPTIONS] [[MONTH] YEAR]
cal [OPTIONS] [TIMESTAMP|MONTHNAME]

Options

Option Description
-1 Show only the current month (default)
-3 Show the previous, current, and next month
-n <N> Show N months starting from the current month
-S Display weeks starting from Sunday (default)
-M Display weeks starting from Monday
-m <month> Specify month by name or number
-y Show the full calendar for the current year
-Y Show the full calendar for the next year
-j Show Julian day numbers (day of year, 1–366)
-w Show week numbers
-h Suppress highlighting of today's date
-V Display version information and exit

1. Display the Current Month Calendar

cal
    January 2025
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

Running cal without any arguments displays the current month with today's date highlighted. The week starts on Sunday by default.

πŸ’‘
Note: The highlighting of today's date uses terminal color codes. If you are piping cal output into a script or log file, use the -h flag to suppress it otherwise the color escape sequences will appear as garbage characters in the output.

2. Display a Specific Month and Year

cal 02 1835
   February 1835
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

Pass the month number and year as arguments to display any calendar β€” past or future. The cal command handles the full Gregorian calendar range.

cal 07 2145
     July 2145
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

Note: Always pass the month before the year β€” cal 02 2025 shows February 2025. Passing just a number like cal 2025 shows the entire year 2025, not January 2025.

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’