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

Print a month of the year with cal command

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.

the linux cal command The Linux Cal Command 1622770021 948 The Linux Cal Command

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.

the linux cal command The Linux Cal Command 1622770022 757 The Linux Cal Command

Print  current month alongside previous & following month

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

the linux cal command The Linux Cal Command 1622770022 677 The Linux Cal Command

Print  the entire  calendar of the current year

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

the linux cal command The Linux Cal Command 1622770023 745 The Linux Cal Command

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

the linux cal command The Linux Cal Command 1622770024 190 The Linux Cal Command

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.

the linux cal command The Linux Cal Command 1622770025 60 The Linux Cal Command

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