×


"cal" Command in Linux Mint 20 - How to use it ?

The "cal" command is basically used to print the calendar on the terminal. 

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Linux system configuration queries.

In this context, we shall look into different ways in which the "cal" command can be used on a Linux Mint 20 system.


What is the syntax for "cal" command ?

It is given below:

cal [month] [year] [-m month] [-y year] [-h] [-3] [-1] [-A num] [-B num] [-d YYYY-MM] [-j] [-N]

Options: cal

The following options are available only in cal:

  • -j: Display a Julian calendar, instead of the default Gregorian calendar. All days are numbered from January 1, rather than from the beginning of the month.
  • -N: Behave as if you ran ncal, using its options and display output.


Different ways on using "cal" command can be used on a Linux Mint 

To know more about the usage of the "cal" command in Linux Mint 20, you will need to examine the below examples examples.


1. How to display the Calendar for the Current Month

You can display the calendar for the current month by using the "cal" command without any options by running the below command:

$ cal

The calendar for the current month with the current date highlighted will be displayed in the terminal window.


2. Another way to display the Calendar for the Current Month

There is another way of displaying the calendar for the current month. For example, if you use the command below:

$ cal 11 2021

The calendar for the current month with the current date highlighted will be displayed.


3. How to display the Calendar for the Current Year ?

You can also display the whole calendar for the current year i.e. the calendar for all the months of the ongoing year at once. For that, you will have to execute the below command:

$ cal 2021

The calendar for the year 2021 i.e. the current year will be displayed on the terminal window.


4. How to display the Calendar for any Specific Year ?

You can also display the whole calendar for any specific year whether it is previous, next, or current with the help of the "cal" command by running the below command:

$ cal 2014

This will display the whole calendar for the year 2014.


5.  How to display the Calendar for the Previous, Current, and Next Month ?

If you just want to display the calendar for the previous, current, and next month of the current year i.e. the calendar for the month of October, November, and December in this case, then you will have to use the below "cal" command:

$ cal -3

This will show you the calendar for the previous, current, and next month with the current date highlighted.


6. How to display the Julian Calendar for the Current Month ?

You can even display the Julian calendar for the current month by running the "cal" command. Julian calendar is the one in which the dates start from 001 and go up till 365 (for the normal years) and 366 (for the leap year). This can be done with the below "cal" command:

$ cal –j

This will show you the Julian calendar for the current month with the current date highlighted.


[Need help in fixing Linux Software configuration issues ? We can help you. ]


Conclusion

This article covers the different ways in which the "cal" command can be used on a Linux Mint 20 system. In fact, the cal command is a command line utility for displaying a calendar in the terminal. It can be used to print a single month, many months or an entire year. It supports starting the week on a Monday or a Sunday, showing Julian dates and showing calendars for arbitrary dates passed as arguments.


Examples of using Linux "cal" command

1. To Display the calendar for this month, with today highlighted:

$ cal

2. To show the calendar for this month, but do not highlight today:

$ cal -h

3. To Display last month, this month, and next month:

$ cal -3

4. To Display this entire year's calendar:

$ cal -y

5. To Display the entire year 2000 calendar:

$ cal -y 2000

OR

$ cal 2000

6. To Display the calendar for December of this year:

$ cal -m December

OR

$ cal -m Dec