在 Debian 系统中,替换(修改)时区设置有多种方法,下面按推荐程度由高到低介绍。
timedatectl(推荐,systemd 系统)大多数现代 Debian(8 及以后)都使用 systemd。
timedatectl
timedatectl list-timezones
sudo timedatectl set-timezone Asia/Shanghai
date
dpkg-reconfigure适合不熟悉命令行的用户。
sudo dpkg-reconfigure tzdata
/etc/localtime(传统方式)sudo rm -f /etc/localtime
sudo ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
/etc/timezoneecho "Asia/Shanghai" | sudo tee /etc/timezone
| 地区 | 时区 |
|---|---|
| 中国 | Asia/Shanghai |
| 香港 | Asia/Hong_Kong |
| 东京 | Asia/Tokyo |
| 纽约 | America/New_York |
| UTC | UTC |
date
ls -l /etc/localtime
如果你是在 Docker / 容器 / 无 systemd 环境,可以告诉我,我可以给你更合适的方案。