cal Command in RHEL 10: A Complete Guide with Examples
cal command
is used to view the calendar directly from the terminal. This is a very
important command to verify dates quickly in RHEL 10 operating system
without any graphical user interface and without any application.
With the help of cal command you can display the calendar of the current
month, a particular month or the entire year in an easy-to-read format.
This topic applies to system administrators, developers, and end users working
on RHEL 10 systems via terminal or SSH who need to view or create calendars.
Syntax of cal command:
cal [options] [[[day] month] year]
When you run cal command without any option
it prints the calendar of the current month and highlights the current date on
terminal
Practical Example of the “cal” Command in RHEL 10
Here I will show you some practical Example
of the cal command.
Example1: Display Current Full Year
Calendar with highlighted present date:
With the help of “option -y” you can
display full year Calendar with highlighted present date, use the following
command: # cal -y
Example2: Display Specific Full Year
Calendar:
If you want to display specific full year calendar,
then type specific year number along with cal command
# cal 2026
If you want to print specific month of the
year, provide the numeric value [1 to 12] followed by year. Suppose I want to
see the calendar of December 2019 then I will run below command:
# cal 12 2019
Example4: Display Previous, Current,
and Next Month calendar:
With the help of “option -3” you can view
past, present and future month altogether, use the following command: # cal -3
Example5: Start Week on Monday:
Using “option -m” we can display Monday as
the first day of the week, use following command: # cal -m
Example6: Start Week on Sunday:
Using “option -s” we can display Sunday as
the first day of the week, use following command: # cal -s
Example7: Show Week Numbers:
using “option -w” along with cal
command we can display week number in the calendar, use the following
command: # cal -w
When we want to print the days of the year
we can use “option -j” with cal command to see the number of days in the year. Use day-of-year numbering for all calendars.
These are also called ordinal days. Ordinal days range from 1 to 366.
I am using “option -3” in the following command
to demonstrate a clear understanding: # cal -j -3
Example9: Highlight Specific Date in
calendar
If you want to highlight specific date in the
calendar, use the following command:
# cal 2025-09-02
Or
# cal 02 09 2025
Example10: Display the calendar in
Vertical layout:
If you want to display the calendar in
Vertical format, use the following command:
# cal -v
Example11: Display the calendar for
the next twelve months:
Using “option -Y” we can display the calendar
for the next twelve months with the help of cal command. Use the following
command:
# cal -Y
Example12: Display the number of
months:
With the help of “option -n” we can display
the specific number of months in the calendar. Use the following command: # cal -n 5
That’s it, we have covered everything you need to know about the cal command.
Download the PDF on this Topic:
Post a Comment