We all know how greatly useful the graphical Calendar application on our Debian system is. However, if you are more Terminal-savvy, you can use the powerful command-line utilities like cal and ncal in order to customize the way you want to view calendars for a specific month or year.

In this article, we will explain how you can display standard and customized calendars in the Debian Terminal. We have run the commands and procedures mentioned in this article on a Debian 10 Buster system.

We will be using the Linux Terminal in order to view customized calendars. You can open it through the Application Launcher search as follows:

Linux Terminal

The Application Launcher can be accessed by hitting the Super/Windows key on your keyboard.

Using the cal Command

The Linux cal utility displays the calendar in the traditional horizontal format. The following simple cal command is used to view the calendar for the current month with the current date highlighted:

$ cal

Debian cal command

Cal Command Options

You can view the calendar according to the following syntax, based on the options explained below:

$ cal [-m [month]] [-y [year]] [-3] [-1] [-A [number]] [-B [number]] [-d [YYYY-MM]] [-j]

Option Use
-m [month] Use this option to display the calendar for the specified month. You can specify the entire month name such as “January” or the three letter abbreviated form such as “Jan”. Alternatively, you can also specify the month number with this option. This switch also gives you the option for viewing calendar for a month of the next year; in that case, you can add the letter f after the month number such as -m 1f
-y [year] Use this option in order to view the calendar for a specified year. For example ‘-y 2019’ will display all months for the year 2019
-1 Use this option to view the calendar of only one month. Since this is the default setting, you can avoid using this switch unless necessary.
-3 Use this option in order to view calendars for three months; these include the current month, the previous month, and the coming month.
-A [number] Use this option when you want to view an X number of coming months along with the calendar you have already set for viewing.

Example 1: cal -3 -A 1 (this command will display the calendar for the current, previous and next month, and also 1 more month after the next month)

Example 2: cal -y 2019 -A 1 (this command will display the calendar for the year 2019 along with one more month i.e. January for 2020

-B [number] Use this option when you want to view an X number of previous months along with the calendar you have already set for viewing.

Example 1: cal -3 -B 1 (this command will display the calendar for the current, previous and next month, and also 1 more month before the previous month)

Example 2: cal -y 2019 -B 1 (this command will display the calendar for the year 2019 along with one month of the previous year i.e. Dec for 2018

-d [YYYY-MM] You can view the calendar of a specific month of the specific year by mentioning that year and month in YYYY-MM format with -d option.
-j You can use this option to view the calendar in Julian format rather than the default Gregorian format.

Cal Command Example

The following command will display the entire calendar for the current year:

$ cal -y

Command-line calendar application

The following command will display the calendar for Feb 2018 as it is specified in the YYYY-MM format in the command:

$ cal -d 2018-02

Show calendar date

Using the ncal Command

The ncal command is more powerful than the Linux cal command. It displays the calendar in a vertical format with some more advanced options. These include displaying the date of Easter, viewing calendar with Monday or Sunday as starting days and much more.

The following simple ncal command is used to view the calendar in vertical format for the current month with the current date highlighted:

$ ncal

Debian ncal command

Ncal Command Options

You can view the calendar according to the following ncal syntax, based on the options explained below:

$ ncal [-m [month]] [-y [year]] [-h] [-3] [-1] [-A [number]] [-B [number]] [-d [YYYY-MM]] [-C] [-e] [-o] [-p] [-w] [-M] [-S] [-b]

Note: The options already explained for the cal command can be used in the same manner for the ncal command.

Options Use
-h By default, the cal command highlights today’s date. However, if you use the -h option, it will not highlight the date.
-e Use this option to view the date of Easter for western calendars.
-o Use this option to view the date of the Orthodox Easter.
-p Use this option to view country codes and switching days that are used for switching from Julian to Gregorian calendars for that country.
-w When you use this option, ncal will print the week number under each week.
-C By using this option, you can use all the options of the cal command with the ncal command.
-M Use this option to view calendars with Monday as the first day of the week.
-S Use this option to view calendars with Sunday as the first day of the week.
-b When you use this option, ncal will display the calendar horizontally as it is displayed through the cal command

Ncal Command Examples

The following command will display the calendar for the current month without highlighting today’s date:

$ ncal -h

ncal -h command

The following command will display the calendar of the current month Monday as the first day of the week.

$ ncal -M

Ncal M

Through this article, you have learned to view calendars according to the many options available for the cal and ncal commands. By using these options you can customize the way you want to view calendars instead of the usual way calendars are displayed in Debian.

How to show a Calendar in the Debian Terminal
Avatar

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.