Is there a fast way to switch System time zone from the command line?
-
29-09-2020 - |
题
I usually do it through the System Preference panel for Date & Time, but I'd like a quicker way to do this if there is one.
解决方案
Use the following Terminal command:
sudo systemsetup -settimezone timezone
For a list of valid timezone
values, use sudo systemsetup -listtimezones
.
To get the current timezone, use:
sudo systemsetup -gettimezone
其他提示
Additionally:
Printing a random timezone:
ruby -e "puts `sudo systemsetup -listtimezones`.lines.sample.strip"
Setting a random timezone:
sudo systemsetup -settimezone (ruby -e "puts `sudo systemsetup -listtimezones`.lines.sample.strip")
Finding a timezone (e.g. containing "Los" in this case):
sudo printf ''; sudo systemsetup -listtimezones | grep Los
不隶属于 apple.stackexchange