How to set date in Ubuntu using terminal?

Getting your system date from an Ubuntu terminal

First, to get your current Date, use the date command

date +%Y%m%d

For example, printing the Date:

[email protected]:~$ date +%Y%m%d

Setting the system date from commandline

Now, Setting the date and time using the -s switch

date +%Y%m%d -s 20201201


Let us test it:

[email protected]:~$ date
Tuesday 05 January 2021 07:00:05 AM IST

[email protected]:~$ sudo date +%Y%m%d -s 20201201

[email protected]:~$ date
Tuesday 01 December 2020 12:00:03 AM IST

Note: This is tested on Ubuntu 20.04. Date command is common across all Linux distributions, will work on Any Linux / Debian distros.