opscape

System and users

cal

Print a calendar for a month, a few months, or a whole year.

cal [-3hjy] [-A N] [-B N] [[MONTH] YEAR]

13 of 13 examples run in Debian 13.7 on 2026-10-31 · manual: cal(1)

cal prints a small calendar: the current month by default, any month with cal MONTH YEAR, or a year with cal YEAR. It is the quickest way to answer "what weekday is the 14th?" or "how many days does that month have?" without leaving the terminal. When the output goes to a terminal, today is highlighted; when it is piped, as here, no highlighting is added.

There are two different cal programs in the Linux world. Debian and Ubuntu install the BSD one from the ncal package, which also provides ncal, a sideways layout with weeks as columns. Fedora, Arch and most others ship the cal from util-linux. They agree on the basics shown first below and disagree on some letters (notably -m), as the notes at the end explain. The examples run on Debian.

For date arithmetic or formatting, use date; cal only draws calendars.

Examples

Show the current month

cal
explain
output
    October 2026      
Su Mo Tu We Th Fr Sa  
             1  2  3  
 4  5  6  7  8  9 10  
11 12 13 14 15 16 17  
18 19 20 21 22 23 24  
25 26 27 28 29 30 31  
                      

The current month with weeks starting on Sunday. The output depends on the day the site was built.

Show a specific month

cal 2 2026
explain
output
   February 2026      
Su Mo Tu We Th Fr Sa  
 1  2  3  4  5  6  7  
 8  9 10 11 12 13 14  
15 16 17 18 19 20 21  
22 23 24 25 26 27 28  
                      
                      

Month then year. February 2026 starts on a Sunday and has exactly four weeks. The year must be given in full: cal 2 26 is February of the year 26.

Show last, this and next month

cal -3
explain
output
   September 2026         October 2026         November 2026      
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
       1  2  3  4  5               1  2  3   1  2  3  4  5  6  7  
 6  7  8  9 10 11 12   4  5  6  7  8  9 10   8  9 10 11 12 13 14  
13 14 15 16 17 18 19  11 12 13 14 15 16 17  15 16 17 18 19 20 21  
20 21 22 23 24 25 26  18 19 20 21 22 23 24  22 23 24 25 26 27 28  
27 28 29 30           25 26 27 28 29 30 31  29 30                 
                                                                  

-3 prints the previous, current and following month side by side, handy when planning across a month boundary.

Show a range of months around a date

cal -B 1 -A 1 3 2026
explain
output
   February 2026           March 2026            April 2026       
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
 1  2  3  4  5  6  7   1  2  3  4  5  6  7            1  2  3  4  
 8  9 10 11 12 13 14   8  9 10 11 12 13 14   5  6  7  8  9 10 11  
15 16 17 18 19 20 21  15 16 17 18 19 20 21  12 13 14 15 16 17 18  
22 23 24 25 26 27 28  22 23 24 25 26 27 28  19 20 21 22 23 24 25  
                      29 30 31              26 27 28 29 30        
                                                                  

-B N adds N months before the chosen month and -A N adds N after, so this shows February to April 2026.

Pick a month of the current year

cal -m 12
explain
output
   December 2026      
Su Mo Tu We Th Fr Sa  
       1  2  3  4  5  
 6  7  8  9 10 11 12  
13 14 15 16 17 18 19  
20 21 22 23 24 25 26  
27 28 29 30 31        
                      

In this (BSD) cal, -m MONTH selects a month of the current year. In util-linux cal, -m means "start weeks on Monday" instead.

Show the first quarter of a year

cal 2026 | head -9
explain
output
                            2026
      January               February               March          
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
             1  2  3   1  2  3  4  5  6  7   1  2  3  4  5  6  7  
 4  5  6  7  8  9 10   8  9 10 11 12 13 14   8  9 10 11 12 13 14  
11 12 13 14 15 16 17  15 16 17 18 19 20 21  15 16 17 18 19 20 21  
18 19 20 21 22 23 24  22 23 24 25 26 27 28  22 23 24 25 26 27 28  
25 26 27 28 29 30 31                        29 30 31              
                                                                  

A single number is a year: all twelve months, three across. head trims it to the first row of months here.

Start weeks on Monday

ncal -bM 2 2026
explain
output
   February 2026      
Mo Tu We Th Fr Sa Su  
                   1  
 2  3  4  5  6  7  8  
 9 10 11 12 13 14 15  
16 17 18 19 20 21 22  
23 24 25 26 27 28     
                      

With the Debian/BSD tools, Monday-first weeks come from ncal -M; -b keeps the familiar horizontal layout. (util-linux cal spells this cal -m.)

Show weekdays as rows

ncal 2 2026
explain
output
    February 2026     
Su  1  8 15 22      
Mo  2  9 16 23      
Tu  3 10 17 24      
We  4 11 18 25      
Th  5 12 19 26      
Fr  6 13 20 27      
Sa  7 14 21 28      

ncal without -b turns the calendar sideways: one row per weekday, one column per week. This makes "every Tuesday in February" easy to read off.

Show ISO week numbers

ncal -wM 2 2026
explain
output
    February 2026     
Mo     2  9 16 23   
Tu     3 10 17 24   
We     4 11 18 25   
Th     5 12 19 26   
Fr     6 13 20 27   
Sa     7 14 21 28   
Su  1  8 15 22      
    5  6  7  8  9   

-w adds the week number under each column. With -M each column is a Monday-to-Sunday week, so the numbers are ISO 8601 weeks, the same ones date +%V prints. February 1 is a Sunday and so closes week 5.

Show day-of-year numbers

cal -j 3 2026
explain
output
        March 2026           
 Su  Mo  Tu  We  Th  Fr  Sa  
 60  61  62  63  64  65  66  
 67  68  69  70  71  72  73  
 74  75  76  77  78  79  80  
 81  82  83  84  85  86  87  
 88  89  90                  
                             

-j numbers days from January 1 instead of from the first of the month. March 1, 2026 is day 60 because 2026 is not a leap year.

Find the date of Easter

ncal -e 2026
ncal -o 2026
output
04/05/26
04/12/26

-e prints Western Easter and -o Orthodox Easter for a year: April 5 and April 12 in 2026. The dates use the locale's short format, MM/DD/YY in the C locale.

See the Gregorian calendar switch

cal 9 1752
explain
output
   September 1752     
Su Mo Tu We Th Fr Sa  
       1  2 14 15 16  
17 18 19 20 21 22 23  
24 25 26 27 28 29 30  
                      
                      
                      

September 2 is followed by September 14: Britain and its colonies dropped eleven days in 1752 when they changed calendars, and cal follows that date by default. Other countries switched on other dates, which is why ncal -s lets you choose a country code.

Ask for a month that does not exist

cal 13 2026
explain
outputexit 64
cal: 13 is neither a month number (1..12) nor a name

An invalid month is rejected with exit status 64, the BSD convention (EX_USAGE) for a command-line usage error. Test for non-zero rather than for 1.

Common pitfalls

  • Typing cal 26 and getting the year 26 AD. Years are always taken literally; write cal 2026.

  • Using -m from a tutorial written for Fedora or Arch: on Debian/Ubuntu it selects a month instead of starting weeks on Monday. Use ncal -bM there.

  • Parsing cal output in scripts to find weekdays or month lengths. date -d 2026-02-01 +%A and date -d '2026-03-01 -1 day' +%d answer those questions directly.

GNU vs BSD and macOS

The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).

  • macOS ships the same BSD cal/ncal family as Debian, so the examples above work there too.

  • util-linux cal (Fedora, Arch, RHEL) uses -m for Monday-first weeks, -s for Sunday-first, -w for week numbers and -n N for the number of months; it has no ncal companion and no -e.

Options worth knowing

A selection, described in our own words. For the full list, see cal(1) or cal --help.

OptionWhat it does
-3Show the previous, current and next month.
-A NAlso show N months after the selected one.
-B NAlso show N months before the selected one.
-m MONTHShow MONTH of the current year (BSD/Debian cal).
-yShow the whole current year.
-jNumber days from January 1 (day of year).
-hTurn off highlighting of today.
-MStart weeks on Monday (ncal).
-SStart weeks on Sunday (ncal).
-bUse the horizontal cal layout (ncal).
-wPrint ISO week numbers (ncal).
-ePrint the date of Western Easter (ncal).
-oPrint the date of Orthodox Easter (ncal).
-s CCUse the calendar reform date of country code CC (ncal).
-pList the country codes and their reform dates (ncal).

Related