Displaying Your Correct Local Time in Shell
Displaying Your Correct Local Time in Shell
One of the first things you will notice when you log into your shell is that the time displayed will more than likely not reflect your local time where you are. Being a shared server with users everywhere in the world, it is not possible to have the system time reflect your exact location, however, you can make your shell display the correct time in reference to where you are.
To do this, we first need to find the correct time zone for you. To find this out, have a look in /usr/share/zoneinfo with:
~$ ls /usr/share/zoneinfo
This will list all the time zone groups available such as Canada, America, Africa, Europe, etc. To find out exactly which one you need, check inside the directory of the group you are apart of, for example, for Europe, do:
~$ ls /usr/share/zoneinfo/Europe
This will list a bunch of cities in Europe, choose which one that is in your time zone.
Next, we will need to add the TZ environment variable to your shell so when you log in, your time will be reflected by your timezone. To do this, enter the following:
~$ echo "export TZ=\"Europe/Warsaw\"" >> ~/.profile ~$ source ~/.profile
Obviously you would replace "Europe/Warsaw" with your local settings, BE SURE to enter the commands in exactly as above, only changing your actual zone info, for example, the ">>" is very important. Now, execute a command to see if your time shows up correctly:
~$ ls -l
For some reason, the Time Zone isn't reflected until you issue a command for the first time in your shell session. This is fine.
If you have any further questions, please ask in #shellium