Taking Your Calendar to the Command Line

6 June, 2022

Here’s the latest in an irregular series of short posts that introduce a few Linux terminal tricks.

Where, on your computer, do you go to check a date? Probably the calendar on the toolbar of your desktop or in a calendar app or widget.

That’s one way to do it. You can also check dates at the Linux command line. How? Using the cal command. There’s nothing extra you need to install or configure, either — cal comes as standard kit with every distribution.

Let’s take a quick look at the basics of using the cal command.

Getting Started

Open a terminal window, type cal, and press Enter. The calendar for this month displays.

cal run without options

You’ll notice that today’s date is also highlighted.

You can type cal -y to see each month for the current year (again, with today’s date highlighted).

Viewing the full year with cal

Depending on the size of the font you use in your terminal, you might have to scroll a bit to see everything.

To view a specific month in the current year, type cal -m [month] (replacing [month] with the name or number of the month). Let’s say you want to view the calendar for December of this year. Type either cal -m 12 or cal december (the case doesn’t matter).

Viewing a month in the current year with cal

Zooming in a Bit More

That’s all well and good, but what if you want to view the calendar for a specific year? Do that by typing cal [year], where you replace [year] with a year. To view the calendar for 2032, type cal 2032.

Looking to a year in the future with cal

You can also zoom in on a specific month in a specific year. To do that, type cal followed by the name or number of the month, followed by the year. So, to view the calendar for May, 2045, type cal 5 2045

Looking at a month and a year in the future with cal

Scott Nesbitt