How can I display the current time configuration, like the time zone, in Ubuntu?
Asked
Active
Viewed 5.8e+01k times
171
-
What does the CentOS output for `cat /etc/sysconfig/clock` look like ? – belacqua Feb 22 '11 at 17:25
-
like this [root@SUPA9611 ~]# cat /etc/sysconfig/clock ZONE="Europe/Amsterdam" UTC=true ARC=false – usef_ksa Feb 22 '11 at 18:24
7 Answers
175
I don't know of a single file, but this may give you the info needed:
cat /etc/timezone
grep UTC /etc/default/rcS
date
# hardware clock
sudo hwclock --show
arrange
- 14,727
- 4
- 42
- 32
-
I didn't spot the `hwclock` bit at first - but that was actually what I was looking for – icc97 Jan 07 '16 at 20:06
120
Best example (IMHO) using timedatectl (in command-line/terminal):
$ timedatectl
Local time: Thu 2014-07-24 19:51:23 IST
Universal time: Thu 2014-07-24 14:21:23 UTC
Timezone: Asia/Kolkata (IST, +0530)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
Visit the manpage for more settings and further information.
-
If your system is missing `timedatectl`: http://askubuntu.com/q/622721/132098 – Abdull Dec 18 '15 at 11:25
-
1Additional info that may also be useful: to change time zone do "sudo timedatectl set-timezone America/Los_Angeles" (use your own time zone instead of America/Los_Angeles. Timezones can be found with timedatectl list-timezones) – mberna Dec 14 '21 at 20:03
2
For the time zone, you can use geolocation:
$ curl https://ipapi.co/timezone
America/Chicago
Or:
$ curl http://ip-api.com/line?fields=timezone
America/Chicago
Zombo
- 1
- 21
- 21
1
If you need a formatted area and time zone, you can use:
$ grep `date +%Z` /etc/timezone
Etc/UTC
Peter Mortensen
- 933
- 2
- 11
- 17
Aimon Bustardo
- 11
- 1
0
If you have PowerShell installed:
PS> Get-TimeZone
Id : Europe/Vilnius
DisplayName : (UTC+02:00) Eastern European Standard Time
StandardName : Eastern European Standard Time
DaylightName : Eastern European Summer Time
BaseUtcOffset : 02:00:00
SupportsDaylightSavingTime : True
I suspect this won't be popular answer in a Linux community, but I really like the verb-noun convention. It makes it easier for me to remember commands, and it will also work on all distributions with PowerShell installed :)
Eliah Kagan
- 116,445
- 54
- 318
- 493