[email protected]Support 24/7 · Billing 09:00 – 00:00LinkedInXFacebook
NexonHost
Netherlands Dedicated ServersAmsterdam · Equinix AM6Germany Dedicated ServersFrankfurt · Equinix FR4Romania Dedicated ServersBucharest · VoxilityAustria Dedicated ServersVienna · Interxion VIEBulgaria Dedicated ServersSofia · TelepointFrance Dedicated ServersParis · Interxion PAR — Marseille · Digital Realty MRS3Ireland Dedicated ServersDublin · Equinix DB2Italy Dedicated ServersMilan · Irideos AvalonPoland Dedicated ServersWarsawSpain Dedicated ServersMadrid · Equinix MD2United States Dedicated ServersAshburn · Equinix DC
All articles
Getting startedSeptember 13, 2023

How to use cal command in Linux.

What is cal command?

Sometimes, you might want to have a peek at the year’s calendar or even narrow it down to a month’s calendar. The Linux cal command is an excellent built-in tool that displays a calendar of a given year or month depending on the options passed.

 

How Does cal Command Work?

In Linux and Unix-like systems, the “cal” is a command-line utility that prints the calendars on the terminal. “Cal” is an abbreviated form of Calendar. It is a pretty simple command and doesn’t contain many options. There are a few options to display – year, month, or date – on the console.

 

How to Install the Cal Utility on Ubuntu 20.04

To install the “cal” command on Linux operating system, launch the terminal and type the following command:

$ sudo apt install ncal

 

How to Use the cal Command

The cal command takes the following command syntax:

$ cal [month] [year]

In its basic format, the cal command prints out the current month and highlights the present day. For instance, by the time I’m writing this, the date is December 17, 2022.

$ cal

 

Example 1: Print a Month of the Year

To print a specific month of the year, provide the numeric value of the month [ 1 – 12 ] followed by the year.

For example, to display the first month of 2023, run the following command:

$ cal 1 2023

This prints out the calendar dates for the first month (January) only.

Alternatively, you can invoke the -m option followed by the month of the year. If the year is not provided as an argument, the month of the current year is printed instead.

$ cal -m June

 

Example 2: Print the Previous, Current, and the Next Months

Let’s try out something more ambitious. The cal command also allows you to print the previous, current, and the next month. Simply pass the -3 option at the end.

$ cal -3

 

Example 3: Print the Entire Calendar of the Current Year

To print the entire traditional calendar for the current year, run the following command:

$ cal -y

 

Example 4: Print the Calendar of Specified Year

To view the calendar of a different year, for example 2024, specify the year after the cal command as shown in the following:

$ cal  2024

 

Bonus

These are some of the commonly used cal commands. However, if curiosity gets the better of you, find more command options by visiting the cal man pages using the following command:

$ man cal

 

Conclusion

The “cal” command is a quite helpful command that is used to display a calendar on the terminal in Linux and Unix- like systems. The Linux cal command displays a simple calendar that allows you to view the current month of the year, the entire current year, or other months or years, depending on your command arguments.

Keep reading
How to Mount and Unmount File Systems.
June 28, 2023

How to Mount and Unmount File Systems.

How To Mount And Unmount File Systems. In this tutorial, we will go over the basics of attaching and detaching various file systems using the mount and umount commands. How to List Mounted File Systems When used without any argument, the mount command will display all currently attached file…

Read article
How to use tail command.
June 28, 2023

How to use tail command.

How To Use Tail Command. In this tutorial, we will show you how to use the Linux tail command through practical examples and detailed explanations of the most common tail options.Tail Command Syntax Before going into how to use the tail command, let’s start by reviewing the basic syntax. The tail…

Read article
How to transfer file with stfp command.
June 28, 2023

How to transfer file with stfp command.

How To Transfer File With Stfp Command. In this tutorial, we will show you how to use the Linux sftp command. What is SFTP: SFTP (SSH File Transfer Protocol) is a secure file protocol that is used to access, manage, and transfer files over an encrypted SSH transport. Before you Begin. To be…

Read article
Get in Touch

Together, Let’s Build a Faster, Safer Internet.

Build scalable infrastructure with NexonHost — high-performance dedicated servers, VPS hosting, cloud hosting, and DDoS protection across Europe.

Get Started →Contact Us
[email protected]Support 24/7 · Billing 09:00 – 00:00