This simple tutorial is going to show Ubuntu beginners how to display and change date and time on Ubuntu Linux both Server and Desktop.
UPDATE: The commands in this tutorial are tested and also works in Ubuntu 24.04.
To display data and time, use date command:
date
Sample output:
Wed Jul 3 20:59:28 CST 2013
To display calendar, use cal command:
cal
If the command not found, run sudo apt install ncal
to install it.
Sample output:
July 2013
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 change date and time, use command:
sudo date -s "4 June 2020 18:00:00"
NOTE: your Ubuntu server may enabled network time synchronization. The command above will NOT work until you disable it by using command:
sudo timedatectl set-ntp no
To re-enable network time synchronization, run command:
sudo timedatectl set-ntp yes