I have set the date & time but once I logout, it sets time back to old time slot.
How can I set the time permanently? I have used the
tzselect command & then export localtime.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
If systemd based system, here you are ↴
$ timedatectl set-time 'YYYY-MM-DD HH:MM:SS'
And if you want to change the date or time only:
$ timedatectl set-time HH:MM:SS /*for time only*/ $ timedatectl set-time YYYY-MM-DD /*for date only*/
To verify the change:
To print the system date and time:
You can use
timedatectl as shown below to list the available timezones
$ timedatectl list-timezones
To select one:
$ timedatectl set-timezone 'yourNewTimeZone'
N.B. And if you want to use
tzselect, be aware that for the change to be permanent, you need to add your export-line - for instance
TZ='yourNewTimeZone'; export TZ in
$HOME/.bashrc. BTW, be aware that
tzselect command does not actually change the timezone for you.