cal Linux Command | Explained

In Linux, the “cal” (calendar) command displays the calendar on the terminal. This command shows the calendar of the current or specific month of the year. The “cal” command’s usage can be customized per the user’s requirement. In this post, the purpose, working, and usage of the cal command are described in detail. The outline of this guide is defined below:

 Let’s start with today’s guide.

Prerequisites: Install ncal Utility

The “cal” commands can not directly execute in the Linux operating system without the “ncal” utility.

First, install the “ncal” utility in the Linux system. To do so, run the following apt command in the terminal:

$ sudo apt install ncal

Once done, you can use the “cal” command in Linux.

How Does cal Command Work in Linux?

The main objective of the “cal” (calendar) command is to show the current month calendar of the current or the specific month/year. The working of the “cal” command depends on the syntax given below:


$ cal [options] [month] [year]

The “cal” is the main keyword in the command, whereas the “options” can also be used to get the desired format/output of the calendar. The other square brackets show the “month” and “year”.

The supported options of the “cal” command are listed in the following table:


cal -jIt displays the current/specific month calendar in the “Julian Calendar Format” instead of the default “Gregorian Calendar Format ”.
cal -3Shows the calendar of the current, previous, and last month.
cal -1Represents the same output as the “cal” command(calendar of the current month).
cal -yDenotes the calendar of the current or specific year i.e. “cal -y 1998” displays the calendar of 1999.
cal -A numIt displays the calendar of the upcoming months from the current month.
cal -B numShows the calendar of the previous months from the current month.
cal mm- yyyyIt displays the calendar of the current/specific month and year.
cal -m monthRepresents the calendar of the specific month.

Manual Page of cal Command:

To get the complete information about the “cal” command, use the following “man cal” command in the terminal:

$ man cal

The output provides a detailed view of the “cal” command and its options or arguments. The user can enter the “h” key to get help otherwise, enter “q” to quit the manual page.

Let’s head over to its usage.

How to Use cal Command in Linux?

Generally, the “cal” command only shows the current month or the whole year calendar. But if we use some arguments or options with the “cal” command, it can give some specific output. This section comprises various examples of different options that can be utilized to get the particular output according to the requirements.

Example 1: Show the Julian Calendar

The default calendar shown in the output of the “cal” command is in the “Gregorian” format. The “Gregorian” format adjusts the current month’s starting date from 1 and ends with the 31st or 30th.

But if we use the “cal -j” command, it displays the calendar in “Julian” format in which the date of the new month does not start with 1. The output of the “cal -j” command is given below:

$ cal -j

The output shows which year day (count) comes on each day of the current month.

Example 2: Display Previous, Current, and Upcoming Month Calendar

The “cal -3” command is used to show the calendar of three months, including current, previous, and the upcoming month:

$ cal -3

Example 3: Show the Current and Previous Month’s Calendar

The “cal -B num” command is used to show the previous month’s calendar. The “num” in the “cal -B num” command displays the particular months. Suppose the “cal -B 2” command displays the calendar of the previous two months:

$ cal -B 2

Example 4: Show the Current Month Only

The “cal -1” command is used to show the calendar of the current month same as the “cal” command:

$ cal -1

Example 5: Display the Specific Year Calendar

The “cal -y year” command is used to get the calendar of the specific year. For instance, the command provided below will print the calendar of the year “1999”:

$ cal -y 1999

Example 6: Show the Upcoming Months

The “cal -A num” command shows the calendar of the upcoming months. In this command, the “num” defines any number. Suppose the “cal -A 5 ” command displays the calendar of the upcoming five months and the current month as well:

$ cal -A 5

Example 7: Display the Specific Month’s Calendar

The “cal -m month” command shows the specific month calendar. The “month” in this command is added to the particular months (1-12). Suppose the “cal -m 8” command displays the calendar of “August” (8th month of the current year ):

$ cal -m 8

Example 8: Show the Particular Month of the Particular Year

The “cal mm yyyy” command is used to display the specific month and year calendar. In this command, the “mm” means month, and the “yyyy” means year. Suppose the “cal 09 1998 ” command displays the September 1998 calendar:

$ cal 09 1998

Bonus Tip: Alternative of cal Command

In Linux, there is a “ncal” command that can be used in place of the “cal” command. The “ncal” provides the same output as the “cal” command, but there is little difference between them. The “ncal” highlights the current date of the month, while the “cal” command does not highlight the current date.

$ ncal


The “cal”(calendar) command displays the current/specific month and year calendar. The “$ cal” command shows the calendar quickly in Linux. To execute this command, install the “ncal” package on your system. The “cal” command has various options such as “cal -3”, “cal -1”, “cal -j”, and many others. These options perform different tasks, such as displaying the previous/next month’s calendar, specific month/ year calendar, etc. This post has briefly demonstrated all the details about the “cal” command in Linux.