1

I log into a linux server, which is in an European time zone. How to make my account in an Asian time zone? And I don't have the super user permission.

The systems are centos 6.5 and ubuntu 12.10, two servers.

2
  • What distro are you using?
    – fixer1234
    Dec 25, 2014 at 4:43
  • centos 6.5 and ubuntu 12.10, two servers.
    – 宇宙人
    Dec 25, 2014 at 5:04

2 Answers 2

3

if you have read permissions to /usr/share/zoneinfo/ and its children (which you would normally), you can set the timezone in your ~/.bashrc or ~/.bash_profile, by executing this command:

export TZ="/usr/share/zoneinfo/{TIMEZONE-DIRECTORY}/{TIMEZONE_FILE}"

with the correct Timezone dir and Timezone file within /usr/share/zoneinfo/.

http://www.cyberciti.biz/faq/howto-linux-set-time-zone-per-user-basis/

11
  • this works, but I meet something really weird. It seems the server is set wrong. After I set TZ as Asia/Shanghai, and then call date, it gives me another wrong time. The real time is 13:22, but it shows 21:27.(before the setting, it shows 08:27)
    – 宇宙人
    Dec 25, 2014 at 5:24
  • did you close the shell and reopen it after making the change? that may help. Dec 25, 2014 at 5:27
  • I did. the real time is 13:22, before close the shell it shows 08:27, after reopen the shell, it shows 21:27. Both are wrong. Is it a problem with the system?
    – 宇宙人
    Dec 25, 2014 at 5:34
  • well, nothing in that command can affect the server itself,so don't worry that you've broken anything for anyone else. try running export -p to confirm that the TZ variable has been correctly set, and everything is spelled correctly. the server clock may be off. use date -u to check the UTC time, and verify it against worldtimeserver.com/current_time_in_UTC.aspx Dec 25, 2014 at 6:45
  • date -u gives me right time, but date still not. does that mean the server clock is off? how to make it on?
    – 宇宙人
    Dec 25, 2014 at 7:09
0

You can change the time zone by executing the below command.

mv /etc/localtime /etc/localtime.bak

ln -s /usr/share/zoneinfo/Asia/xxxx /etc/localtime

Replace Asia/xxxx according to your time zone.

2
  • 1
    "And I don't have the super user permission." yet you give him 2 commands that start with sudo.
    – Tyson
    Dec 25, 2014 at 5:27
  • 1
    those commands won't work correctly without admin, on most systems with default permissions on \etc\ Dec 25, 2014 at 6:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .