Linux and Unix Cal command tutorial with examples

Command “cal” stands for calendar.
This command is used to see the calendar of a specific month/ year or both.
The basic syntax of command “cal”.

      cal  [month]  [year]

[month]- is used for specify month
[year] – is used for specify year

cal command to display calendar of current month

type “cal” command on terminal and press enter and output will be calendar of the current month

           $ cal              [ type  “cal” on terminal and press enter]

Output:

 January 2018 		
 Mo  Tu   Th   We   Fr   Sa   So 
 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   25   27   28   
 29  30   31

To see the calendar of specific month/Year [for example May 2021]

type below command in terminal.

  
         $ cal  05  2021      [ press enter]

Output:

              
 May 2021      
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        

To see the calendar of the specific year (all 12 months)


To see the calendar of the year 2012. Type “cal” command and attach desired year as shown below

  
         $ cal   2021              [ press enter]

Output

In output calendar of 2012(all 12 months) will display in the terminal.

cal command to  display the days of the year
Fig: Calendar for the year 2021

Display the calander for current year

  
         $ cal   -y              [ press enter]

Q: Display the previous, current and next month calendar of the year 1987 August

  
         $ cal  -3 8 1987          [ press enter]
cal command to show  previous, current and next month calendar

Q: write a command to display the previous, current and next month calendar of the year 2015 december.

  
         $ cal  -3   12 2015         [ press enter]

Q: What is the command to display the days of the year 2016

  
         $ cal   2016              [ press enter]

Read More

Linux and Unix rm command tutorial with examples
Linux and Unix mv command tutorial with examples
Linux and Unix tail command tutorial with examples

Reference

cal(1) – Linux man page
cal(1) — Linux manual page