The Linux Cal Command

21

Sometimes, you might want to have a peek at the year’s calendar or even narrow it down to a month’s calendar. The Linux cal command is an excellent built-in tool that displays a calendar of a given year or month depending on the options passed.

In this brief guide, we explore a few example sages of the Linux cal command.

Basic syntax

The cal command takes the following command syntax:

Linux cal command without arguments

In its basic format, the cal command prints out the current month and highlights the present day. For instance, by the time I’m writing this, the date is  18th May 2021

To print a specific month of the year, provide the numeric value of the month  [ 1 – 12 ] followed by the year.

For example, to display the 10th month of 2021, run the command:

This prints out the calendar dates for the 10th month ( October )  only.

Alternatively, you can invoke the -m  option followed by the month of the year. If the year is not provided as an argument, then the month of the current year is printed instead.

Let’s try out something more ambitious. The cal command also allows you to print the previous, current, and the next month. Simply pass the -3 option at the end

To print the entire traditional calendar for the current year run:

For instance, to view the calendar of a different year, for example, 2022, specify the year after the cal command as shown.

These are some of the commonly used cal command examples. However, if curiosity gets the better of you, find more command options by visiting the cal man pages as shown.

Summary

The  Linux cal command displays a simple calendar that allows you to view the current month of the year, the entire current year, or other months or years, depending on your command arguments.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More