- Как установить или изменить часовой пояс в Linux
- Проверка текущего часового пояса
- Изменение часового пояса в Linux
- Изменение часового пояса путем создания символической ссылки
- Выводы
- Set Time/Date/Timezone in Ubuntu Linux
- Check Current Time
- Using the date command
- Using timedatectl command
- Changing Time
- using date command
- Change Date
- Create custom date format
- List/Change time zone
- Set the Local-rtc
- Check/Change CMOS Time
- Conclusion
- How To Set/Change Time, Date And Timezone In Linux?
- 1) How To Check Current Date, Time And Timezone Information In Linux?
- 2) How To Set/Change Date And Time In SysVinit Systems?
- 3) How To Set/Change Date And Time In systemd Systems?
- 4) How To Change The TimeZone In systemd Systems?
- 5) How To Change The TimeZone In RHEL 6/CentOS 6 Systems?
- 6) How To Automatically Adjust Your Linux System Clock?
- How to Set or Change Timezone in Ubuntu Linux [Beginner’s Tip]
- How to change Timezone in Ubuntu and other Linux distributions
- Method 1: Change Ubuntu timezone via terminal
- Method 2: Change Ubuntu timezone via GUI
- How to edit the TimeZone of your Linux system ?
- How to change the TimeZone on systemd system in Linux?
- What is timedatectl?
- How to change the TimeZone in systemd Systems?
- How to change the TimeZone in RHEL 6/CentOS 6 Systems?
Как установить или изменить часовой пояс в Linux
Часовой пояс — это географический регион с одинаковым стандартным временем. Обычно часовой пояс задается во время установки операционной системы, но его можно легко изменить позже.
Использование правильного часового пояса необходимо для многих системных задач и процессов. Например, демон cron использует часовой пояс системы для выполнения заданий cron. Часовой пояс также используется для отметок времени журналов.
В этом руководстве описаны действия, необходимые для установки или изменения часового пояса в Linux.
Проверка текущего часового пояса
timedatectl — это timedatectl программа командной строки, которая позволяет просматривать и изменять системное время и дату. Он доступен во всех современных системах Linux на базе systemd.
Чтобы просмотреть текущий часовой пояс, вызовите команду timedatectl без каких-либо параметров или аргументов:
Приведенный выше вывод показывает, что часовой пояс системы установлен на UTC.
Системный часовой пояс настраивается путем символьной привязки файла /etc/localtime к идентификатору двоичного часового пояса в каталоге /usr/share/zoneinfo .
Другой способ проверить часовой пояс — просмотреть путь, на который указывает символическая ссылка, с помощью команды ls :
Изменение часового пояса в Linux
Перед изменением часового пояса вам нужно узнать длинное название часового пояса, который вы хотите использовать. В соглашении об именах часовых поясов обычно используется формат «Регион / Город».
Чтобы просмотреть все доступные часовые пояса, используйте команду timedatectl или перечислите файлы в каталоге /usr/share/zoneinfo :
Как только вы определите, какой часовой пояс соответствует вашему местоположению, выполните следующую команду от имени пользователя root или sudo :
Например, чтобы изменить часовой пояс системы на America/New_York , введите:
Чтобы проверить изменение, снова вызовите команду timedatectl :
Миссия выполнена! Вы успешно изменили часовой пояс вашей системы.
Изменение часового пояса путем создания символической ссылки
Если вы используете более старый дистрибутив Linux и утилита timedatectl отсутствует в вашей системе, вы можете изменить часовой пояс, установив символическую ссылку /etc/localtime на часовой пояс в каталоге /usr/share/zoneinfo .
Определите часовой пояс, который вы хотите настроить, и создайте символическую ссылку :
Проверьте это, перечислив файл /etc/localtime или вызвав команду date :
Выходные данные включают часовой пояс, в данном примере это «EST».
Выводы
Чтобы изменить часовой пояс в системах Linux, используйте команду sudo timedatectl set-timezone за которой следует длинное имя часового пояса, который вы хотите установить.
Не стесняйтесь оставлять комментарии, если у вас есть вопросы.
Источник
Set Time/Date/Timezone in Ubuntu Linux
Time is an important aspect in Linux systems especially in critical services such as cron jobs. Having the correct time on the server ensures that the server operates in a healthy environment that consists of distributed systems and maintains accuracy in the workplace.
In this tutorial, we will focus on how to set time/date/time zone and to synchronize the server clock with your Ubuntu Linux machine.
Check Current Time
You can verify the current time and date using the date and the timedatectl commands. These linux commands can be executed straight from the terminal as a regular user or as a superuser. The commands are handy usefulness of the two commands is seen when you want to correct a wrong time from the command line.
Using the date command
Log in as a root user and use the command as follows
Output
You can also use the same command to check a date 2 days ago
Output
Using timedatectl command
Checking on the status of the time on your system as well as the present time settings, use the command timedatectl as shown
Changing Time
We use the timedatectl to change system time using the format HH:MM: SS. HH stands for the hour in 24-hour format, MM stands for minutes and SS for seconds.
Setting the time to 09:08:07 use the command as follows (using the timedatectl)
using date command
Changing time means all the system processes are running on the same clock putting the desktop and server at the same time. From the command line, use date command as follows
Where,
• 10: Hour (hh)
• 13: Minute (mm)
• 13: Second (ss)
To change the locale to either AM or PM use the %p in the following format.
Change Date
Generally, you want your system date and time is set automatically. If for some reason you have to change it manually using date command, we can use this command :
It will set your current date and time of your system into ‘January 25, 2014′ and ’09:17:00 AM’. Please note, that you must have root privilege to do this.
You can use timedatectl to set the time and the date respectively. The accepted format is ‘YYYY-MM-DD’, ‘YYYY’ represents the year, ‘MM’ the month in two digits and ‘DD’ for the day in two digits.
Changing the date to ’15 January 2019′, you should use the following command:
Create custom date format
To create custom date format, use a plus sign (+)
%D format follows Year/Month/Day format.
You can also put the day name if you want. Here are some examples :
List/Change time zone
Changing the time zone is crucial when you want to ensure that everything synchronizes with the Network Time Protocol. The first thing to do is to list all the region’s time zones using the list-time zones option or grep to make the command easy to understand
The above command will present a scrollable format.
Recommended timezone for servers is UTC as it doesn’t have daylight savings. If you know, the specific time zones set it using the name using the following command
To display timezone execute
Set the Local-rtc
The Real-time clock (RTC) which is also referred to as the hardware clock is independent of the operating system and continues to run even when the server is shut down.
Use the following command
In addition, the following command for the local time
Check/Change CMOS Time
The computer CMOS battery will automatically synchronize time with system clock as long as the CMOS is working correctly.
Use the hwclock command to check the CMOS date as follows
To synchronize the CMOS date with system date use the following format
Conclusion
To have the correct time for your Linux environment is critical because many operations depend on it. Such operations include logging events and cron jobs as well.
If you have any questions or feedback, feel free to leave a comment.
Источник
How To Set/Change Time, Date And Timezone In Linux?
If you missed to set the proper timezone, date and time while installing the OS. Don’t worry it can be changed at any point of time.
If we bought the server from some providers and they might have set the timezone based on their location.
Say for example, if you buy a server from USA then they will build a system based on their GEO location.
If so, don’t worry you can simply change the timezone and date formats as per your requirement using the below commands on your Linux Box.
In this article, i have covered all the possible methods with all Major Linux Distribution such as CentOS, Redhat (RHEL), Fedora, Ubuntu, Debian, Mint & openSUSE systems.
Also, we have updated the information based on the system manager such as SysVinit and systemd. Timezone is controlled by /etc/localtime file.
The below files are belongs to timezone on Linux.
- /usr/share/zoneinfo: This directory contains timezone files.
- /etc/localtime: This file is symlink with timezone file.
- /etc/timezone: This file is holding timezone name on debian based systems.
- /etc/sysconfig/clock: This file is holding timezone name on RHEL based systems.
1) How To Check Current Date, Time And Timezone Information In Linux?
Use the following commands to check the current date, time and timezone information in Linux systems.
To check current system date and time.
To display current system date and time with UTC format.
Run the following command to display Hardware Clock (RTC).
To check the timezone on SysVinit systems.
We can sell all the details together in the single command for systemd systems. See the details below.
2) How To Set/Change Date And Time In SysVinit Systems?
Use the following commands to set or change the time and date as you wish in Linux SysVinit systems. If you requires locale’s then you can set accordingly.
Common Syntax:
To set new date and time in one shot, use the following format.
You can double confirm this by running date command once again.
To set only time, use the following format.
To set only date, use the following format.
To Set time with locale’s.
To set the hardware clock to local time.
To set the hardware clock to UTC time.
3) How To Set/Change Date And Time In systemd Systems?
Use the following commands to set or change the time and date as you wish in Linux systemd systems.
Common Syntax:
To change the new date and time in one shot, use the following format.
To set only time, use the following format.
To set only date, use the following format.
Use the following format to set RTC time.
4) How To Change The TimeZone In systemd Systems?
For systemd system, use the timedatectl command to change the timezone. Navigate to the following url to change the timezone in Linux.
If you would like to restart the timedatectl service, use the following command.
Run the following command to verify the new timezone.
5) How To Change The TimeZone In RHEL 6/CentOS 6 Systems?
For RHEL/CentOS systems, use the following command to change the timezone.
Run the following command to check the new timezone in RHEL/CentOS systems.
6) How To Automatically Adjust Your Linux System Clock?
If you would like to sync your Linux system clock to remote NTP server then you have configure it.
To do so, navigate the following urls because we had written an detailed articles about these in the past.
Источник
How to Set or Change Timezone in Ubuntu Linux [Beginner’s Tip]
Last updated September 6, 2021 By Abhishek Prakash 1 Comment
When you install Ubuntu, it asks you to set timezone. If you chose a wrong timezone or if you have moved to some other part of the world, you can easily change it later.
How to change Timezone in Ubuntu and other Linux distributions
There are two ways to change the timezone in Ubuntu. You can use the graphical settings or use the timedatectl command in the terminal. You may also change the /etc/timezone file directly but I won’t advise that.
I’ll show you both graphical and terminal way in this beginner’s tutorial:
Method 1: Change Ubuntu timezone via terminal
Ubuntu or any other distributions using systemd can use the timedatectl command to set timezone in Linux terminal.
You can check the current date and timezone setting using timedatectl command without any option:
As you can see in the output above, my system uses Asia/Kolkata. It also tells me that it is 5:30 hours ahead of GMT.
To set a timezone in Linux, you need to know the exact timezone. You must use the correct format of the timezone (which is Continent/City).
To get the timezone list, use the list-timezones option of timedatectl command:
It will show you a huge list of the available time zones.
Timezones In Ubuntu
You can use the up and down arrow or PgUp and PgDown key to move between the pages.
You may also grep the output and search for your timezone. For example, if you are looking for time zones in Europe, you may use:
Let’s say you want to set the timezone to Paris. The timezone value to be used here is Europe/Paris:
It won’t show any success message but the timezone is changed instantly. You don’t need to restart or log out.
Keep in mind that though you don’t need to become root user and use sudo with the command but your account still need to have admin rights in order to change the timezone.
You can verify the changed time and timezone by using the date command:
Method 2: Change Ubuntu timezone via GUI
Press the super key (Windows key) and search for Settings:
Scroll down a little and look for Details in the left sidebar:
In Details, you’ll fine Date & Time in the left sidebar. Here, you should turn off Automatic Time Zone option (if it is enabled) and then click on the Time Zone:
When you click the Time Zone, it will open an interactive map and you can click on the geographical location of your choice or type the city name. Once you have selected the correct timezone, close the window.
Change Timezone In Ubuntu 2
You don’t have to do anything other than closing this map after selecting the new timezone. No need to logout or shutdown Ubuntu.
I hope this quick tutorial helped you to change timezone in Ubuntu and other Linux distributions. If you have questions or suggestions, please let me know.
Like what you read? Please share it with others.
Источник
How to edit the TimeZone of your Linux system ?
Time zone setup has been done usually while performing the OS installation.If you missed to setup the proper timezone in that point, don’t worry we can setup that later by using simple steps.
Sometimes we may need to change the timezone of systems for various reasons.
Say for example, If you buy a server from third party, they might have set the timezone based on their location.
If so, use the following procedures based on your distributions to change it.
If you are looking for related articles then navigate to the following URLs.
How to change the TimeZone on systemd system in Linux?
systemd is such a wonderful system manager of Linux system, that comes with many handy tools. It help users to perform many actions easily in Linux system.
It offers a tool called timdedatectl for updating the timezone in systemd system.
- /usr/share/zoneinfo: This directory contains timezone files.
- /etc/localtime: This file is symlink with timezone file.
- /etc/timezone: This file is holding timezone name on debian based systems.
- /etc/sysconfig/clock: This file is holding timezone name on RHEL based systems.
What is timedatectl?
The timedatectl command is control the system time and date. It may be used to query and change the system clock and its settings.
Use one of the following command to view the current timezone.
Check the current timezone using date command.
Check the current timezone using /etc/localtime file.
Use the following command to check the current timezone on systemd system.
If you would like to change the timezone. First we need to get the desired timezone information by running one of the below command.
Use the following command irrespective of the Linux distributions to find the desired timezone.
Please select a country.
Please select one of the following time zone regions.
For systemd systems, use the following command to check the desired timezone information.
If you got the desired timezone information then go ahead and change it.
How to change the TimeZone in systemd Systems?
For systemd system, use the timedatectl command to change the timezone.
If you would like to restart the timedatectl service, use the following command.
Run the following command to verify the new timezone.
How to change the TimeZone in RHEL 6/CentOS 6 Systems?
For RHEL/CentOS systems, use the following command to change the timezone.
Run the following command to check the new timezone in RHEL/CentOS systems.
Источник