Skip to content

cal Command: Displaying Calendars in the Terminal

Summary

The cal command is a simple yet useful utility in Linux for displaying a calendar in the terminal. It provides a quick way to view the current month, a specific month, or even the entire year.

Introduction

The cal command, short for "calendar," is a standard Unix utility that displays a calendar in the terminal. It's incredibly straightforward to use and doesn't require any special configuration. It's a quick and easy way to check dates without needing a graphical calendar application. The default display is a textual representation of the current month. It is pre-installed in the majority of Linux distributions.

Use case and Examples

Display the current month's calendar

cal
Displays the calendar for the current month.

Display a specific month's calendar

cal 10 2023
Displays the calendar for October 2023. The first argument is the month (1-12), and the second is the year.

Display the calendar for an entire year

cal 2024
Displays the calendar for the entire year 2024.

Display the calendar in Julian format

cal -j
Displays the current month's calendar with Julian dates (day of the year).

Commonly used flags

Flag Description Example
-1 Display single month output. (This is default behaviour) cal -1
-3 Display three months spanning the date, one previous, current and next cal -3
-s Display Sunday as first day of the week cal -s
-m Display Monday as first day of the week cal -m
-j Display Julian dates (day of the year) cal -j
-y Display the calendar for the current year. cal -y
-V Display version information and exit cal -V


Share on Share on

Comments