cal command in linux allows you to display a calendar in the terminal. There are many flags you can use with the cal command to get the desired output
cal command in linux with flags | Examples
![]() |
cal command in linux |
Hello, guys Today I'm going to show how you can use "cal command" in Linux.
"cal" command can be used to display a conventionally formatted calendar on your command line.
Let's see how you can use the "cal" command,
cal command
![]() |
cal command |
$cal
So to use the "cal" command you can just use "cal" and then press ENTER. It's going to show you the calendar kind of output.
This "cal" command is going to show you the current month. date and the year.
Flags
There are some flags that you can use with this "cal" command. They are,
To show months of Year
![]() |
cal command with a year flag |
$cal year
The first flag which you can use with the "cal" command is the year. So whatever here you want to see you can just enter the year number.
For example, I want to see "2020" and then press ENTER. It's going to show all the months in the 2020 year in formatted form.
To print a specific month
![]() |
To print a specific month |
$cal [month] [year]
If you want to view a particular month in a particular year. Then you have to use this flag with the "cal" command.
For example, I want to see the "February of 2020". So I just write "cal 2 2020" and press ENTER.
It's just going to show that month which you have entered here not the whole calendar.
To display previous and next months
![]() |
To show previous, current and next month |
$cal -3
If you want to see the previous and next month you can use "cal -3" and press ENTER.
It's going to give you the current, previous and the next month.
Note:
When you give "cal" command by default this number is "-1".
HAVE A NICE DAY💝
see also,