Linux CLI Basics: How to Use the cal Command

In the Linux Crash Course series, you’ll learn a valuable Linux-related command or skill – one video at a time. In this video, we explore the cal command.

YouTube player

Basic Usage

Alright, so let’s get started.

First, we need to make sure we have the cal command available to us.

command -v cal

If we don’t have the command available, we’ll need to install it.

For Debian, Ubuntu, and other systems with the APT package manager, we can install ncal:

sudo apt update
sudo apt install ncal

If you’re using Arch, Fedora, or Enterprise Linux, the package you’re looking for is util-linux.

Once you have it installed, the most basic usage of the cal command is to simply enter it without any options, and what that will do is display the calendar for the current month.

cal

If you’d like to see the calendar for the entire year, you can use the -y option:

cal -y

If you’d like to see the calendar for a different year, simply add the year you’re curious about after the cal command, like this:

cal 1982

In addition to that, if you’d like to look up a spefici specific month of a specific year:

cal 8 1982

Another trick you can use with the cal command is to view three months at a time. You can do that with the -3 option:

cal -3

Also, you can use the -1 option to view a single month:

cal -1

But that option is relatively useless since you’d get the same output if you omitted it altogether:

cal

https://www.tutorialspoint.com/unix_commands/cal.htm