FactorPad
Faster Learning Tutorials

Linux cal command summary with examples

cal allows you to display a calendar.
  1. Purpose - Learn what cal is for and how to find help.
  2. Options - Review a few common options and arguments.
  3. Examples - Walk through code examples with cal.
  4. A tip - Finish off with one more insight.
Paul Alan Davis, CFA, October 23, 2016
Updated: August 1, 2018
In this tutorial, 42 of 100, below find a 3-4 minute introductory video, a text-based tutorial and all of the code examples from the video.

Outline Back Next

~/ home  / tech  / linux essentials  / cal command


The Linux cal command

Beginner

Learn to display a monthly or yearly calendar at the Linux command line.

Video Tutorial

Linux cal command summary with examples (2:59)

Videos can also be accessed from the YouTube Playlist.

Video Script

The Command and Why You Need It

Our forty-second word, or command to memorize is cal from our category System.

cal allows you to display a calendar.

Recall from the previous video, we used the calendar command to display reminders and send updates, now with cal, we have an easy command offering a calendar view.

Before we start, it helps to think of commands as mini programs and most follow this structure: command -option(s) argument(s).

The cal command has 6 options and no arguments.

Unlike most commands, help isn't available with double-dash --help, so I suggest using the man cal command for documentation. The default is the current month, and with -3 view three months, and for the whole year use the -y option.

You can also customize this and get more granular, but I figure you'll use your phone, email program or wall calendar for that.

So why is cal an important command? Well, if you're completely focused on the terminal and don't want to turn your attention away from the screen, cal offers a quick way to remember what the heck day it is. And now you know how to do that.

Demonstration

Okay, the best way to embed this in your memory is by typing in your own terminal window.

Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.

Here we go. Let's do a cal without options for the current month.

$ cal October 2016 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

Next, we'll do a cal with the minus or -3 option to add the surrounding two months.

$ cal -3 September 2016 October 2016 November 2016 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 1 2 3 4 5 4 5 6 7 8 9 10 2 3 4 5 6 7 8 6 7 8 9 10 11 12 11 12 13 14 15 16 17 9 10 11 12 13 14 15 13 14 15 16 17 18 19 18 19 20 21 22 23 24 16 17 18 19 20 21 22 20 21 22 23 24 25 26 25 26 27 28 29 30 23 24 25 26 27 28 29 27 28 29 30 30 31 $ clear

And last, let's throw in a -y option for the whole year.

$ cal -y 2016 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 1 2 3 4 5 6 1 2 3 4 5 3 4 5 6 7 8 9 7 8 9 10 11 12 13 6 7 8 9 10 11 12 10 11 12 13 14 15 16 14 15 16 17 18 19 20 13 14 15 16 17 18 19 17 18 19 20 21 22 23 21 22 23 24 25 26 27 20 21 22 23 24 25 26 24 25 26 27 28 29 30 28 29 27 28 29 30 31 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 7 1 2 3 4 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11 10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18 17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25 24 25 26 27 28 29 30 29 30 31 26 27 28 29 30 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 1 2 3 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10 10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17 17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24 24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30 31 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 1 2 3 4 5 1 2 3 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17 16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24 23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31 30 31

A Final Tip

Okay now you know how to use cal. And you know the syntax for commands, options and arguments.

One last tip about the cal command. So again, I think cal is best for a quick look at a recent month, or few months, but check out the -m option in the man cal page to review other months, or years.

Okay, thanks for visiting today. I hope this was a helpful introduction to the cal command.


Learn More About The Series

For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:


What's Next?

If you learned something today, please consider subscribing. Every bit helps.

  • For the Outline to all 100 tutorials, click Outline.
  • to go back to the calendar command, hit Back.
  • To stick with the timing theme and cover the sleep command, click Next.

Outline Back Next

~/ home  / tech  / linux essentials  / cal command


 
Keywords:
linux cal command
cal linux
unix cal
linux calendar
linux cal examples
linux calendar
linux cal tutorial
open source calendar
cal calendar
linux cal syntax
linux monthly calendar
view calendar linux