Cal Command in Linux

Written by: Bobbin Zachariah   |   Last updated: November 11, 2022

Have you wondered how to show calendar in Linux? Then in this tutorial, we learn about cal command in Linux and its options.

Linux cal command

Cal is a terminal command used in Linux to print a calendar. Simply type cal to display the current month calendar.

Syntax:

cal [options] [[[day] month] year]

If no arguments are provided the cal command displays the current month calendar with the current date highlighted.

cal command with no arguments

Install cal in Linux

Cal is available preinstalled in almost all Linux distributions. In case you are getting command not found error when running cal or from a bash script, possible because ncal is not available.

On Ubuntu/Debian new ncal replaced cal, which comes under bsdmainutils package. You can get cal working by installing ncal.

sudo apt install ncal

Once it's installed cal works as it had a symbolic link to ncal.

How to use cal command

Let's take a look at cal command usage with examples.

Note: The output format may vary slightly depending on the Linux distributions you use. Here we are using Ubuntu

1. To show the calendar of a specific month of the year - for example, "November 2022".

cal 11 2022
display calendar for a specific month of a year

2. To show calendar for the current whole year with the current date highlighted:

cal -y
display whole calendar for the current year

Note: There is some bug preventing cal not to highlight the current date in some Distro, use ncal instead.

3. You can display the whole calendar for a specific year, type:

cal 2022
display whole calendar for a specific year

4. You can display the calendar of previous, current (along with current date highlighted) and next month, type:

cal -3
display calendar of previous, current and next month

5. If you wish to display the calendar for the current month and next two months, type

cal -A 2
display calendar for current and next two months

You may use cal -A 12 to display the calendar for the next 12 months.

vice versa, to display the current month and the previous n months.

cal -B 2
display calendar for current and previous two months

6. To display the current month in the Julian calendar use -j option. Also, it highlights the current Julian date.

cal -j
display Julian calendar current month

cal command options

Few available options of cal command:

OptionsDescription
defaultThe current month is displayed.
-yThe same default.
-3Shows the calendar of previous, current, and next month.
-jShow Julian the calendar current month.
-A nShow the current month and next n months.
-B nShow the current month and the previous n months.

About The Author

Bobbin Zachariah

Bobbin Zachariah

Bobbin Zachariah is an experienced Linux engineer who has been supporting infrastructure for many companies. He specializes in Shell scripting, AWS Cloud, JavaScript, and Nodejs. He has qualified Master’s degree in computer science. He holds Red Hat Certified Engineer (RHCE) certification and RedHat Enable Sysadmin.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment