Ubuntu Tutorial

Calendar : cal and ncal commands are used to display calendar on Terminal. it display the current month with highlighted date(today). the difference between cal and ncal command is the format to display output, see Example 1. to get more information use man or info with cal or ncal

syntax : cal option

syntax : ncal option

Image
cal and ncal command

use cal command for following option.

Option Description
-m month Display specified month(month can be number or string(full or half)
half string can be first 3 character of month)
year
or
-y year
Display all months of specified year
month year Display month of specified year
-3 Display previous, current and next month.
-j Display Julian days (day number from January 1)

use ncal command for following option.

Option Description
-w Display month with the number of the week, below each week column.
-S Display month and week will start on Sunday.
-M Display month and week will start on Monday.

Date and Time : to print or update date and time, we use date command. it will print day of week, month, day, time, and year. to get more information use man or info with date command.

syntax : date options

image
date command

u can set new time by using date -s "datetime" where datetime is given as string Example. "11/20/2013 12:48:00"

Option Description Output
"+ %a" print short weekday name Fri
"+ %A" print full weekday name Friday
"+ %b" print half month name Sep
"+ %B" print month name September
"+ %c" print date and time Friday 20 September 2019 01:52:16 PM IST
"+ %d" print day of month 20
"+ %D" print date as m/d/y 09/20/19
"+ %F" print date as Y-m-d 2019-09-20
"+ %j" print day of year 263
"+ %H" print Hours in 24 hours format 14
"+ %I" print Hours in 12 hours format 02
"+ %M" print minute 02
"+ %S" print seconds 01
"+ %r" print time in 12 hours format 02:17:56 PM IST
"+ %T" print time as H:M:S 14:29:20
"+ %R" print time in 24 hours format(H/M) 14:18

following are the some examples.

Command Output
date "+%d-%m-%y" 20-09-19
date "+Date : %d-%m-%y %nTime : %H:%M:%S" Date : 20-09-19
Time : 15:23:15