{"id":3253,"date":"2012-05-30T22:47:13","date_gmt":"2012-05-30T14:47:13","guid":{"rendered":"https:\/\/webhostinggeeks.com\/howto\/?p=3253"},"modified":"2023-06-28T11:59:16","modified_gmt":"2023-06-28T11:59:16","slug":"change-date-and-time-linux","status":"publish","type":"post","link":"https:\/\/webhostinggeeks.com\/howto\/change-date-and-time-linux\/","title":{"rendered":"How to Change Date and Time Linux on RHEL 6\/7 and CentOS 6\/7"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone wp-image-6841 size-full lazyload\" data-src=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2012\/05\/How-to-Change-Date-and-Time-Linux-on-RHEL.jpg\" alt=\"Change Date and Time\" width=\"2560\" height=\"1440\" data-srcset=\"https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2012\/05\/How-to-Change-Date-and-Time-Linux-on-RHEL.jpg 2560w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2012\/05\/How-to-Change-Date-and-Time-Linux-on-RHEL-300x169.jpg 300w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2012\/05\/How-to-Change-Date-and-Time-Linux-on-RHEL-768x432.jpg 768w, https:\/\/webhostinggeeks.com\/howto\/wp-content\/uploads\/2012\/05\/How-to-Change-Date-and-Time-Linux-on-RHEL-1024x576.jpg 1024w\" data-sizes=\"(max-width: 2560px) 100vw, 2560px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 2560px; --smush-placeholder-aspect-ratio: 2560\/1440;\" \/><\/p>\n<p>In web server administration, understanding how to manage the date and time settings on your server is crucial.<\/p>\n<p>This tutorial is designed for those using Red Hat Enterprise Linux 6 (RHEL 6) or CentOS 6\/7, and it assumes that your system does not have Date\/Time Properties installed. We will guide you through the process of changing the date and time from the command line.<\/p>\n<p>Please note that you need to be logged in as root to perform the actions described in this tutorial. <\/p>\n<h2>Changing the Current Date<\/h2>\n<p>To change the current date, you can use the following command:<\/p>\n<pre>\r\n# date +%D -s YYYY-MM-DD\r\n<\/pre>\n<p>In this command, YYYY stands for a four-digit year, MM for a two-digit month, and DD for a two-digit day of the month. For example, to set the date to May 30, 2012, you would use:<\/p>\n<pre>\r\n# date +%D -s 2012-05-30\r\n<\/pre>\n<p>After running this command, the system will display the new date in the format MM\/DD\/YY.<\/p>\n<pre># date +%D -s 2012-05-30\r\n05\/30\/12\r\n<\/pre>\n<h2>Changing the Current Time<\/h2>\n<p>To change the current time, you can use the following command:<\/p>\n<pre>\r\n# date +%T -s HH:MM:SS\r\n<\/pre>\n<p>In this command, HH stands for an hour, MM is a minute, and SS is a second. If your system clock is set to use UTC (Coordinated Universal Time), add the following option:<\/p>\n<pre>\r\n# date +%T -s HH:MM:SS -u\r\n<\/pre>\n<p>For example, to set the time to 22:30:00, you would use:<\/p>\n<pre>\r\n# date +%T -s 22:30:00\r\n<\/pre>\n<p>or, if using UTC:<\/p>\n<pre>\r\n# date +%T -s 22:30:00 -u\r\n<\/pre>\n<p>After running this command, the system will display the new time.<\/p>\n<pre>[root@rhel6 ~]# date +%T -s 22:30:00\r\n22:30:00\r\n<\/pre>\n<p>or<\/p>\n<pre>[root@rhel6 ~]# date +%T -s 22:30:00 -u\r\n22:30:00\r\n<\/pre>\n<h2>Displaying the Current Date and Time<\/h2>\n<p>To display the current date and time, simply use the date command:<\/p>\n<pre>\r\n# date\r\n<\/pre>\n<p>This will display the current date and time in the format Day Month Date Time TimeZone Year.<\/p>\n<pre>[root@rhel6 ~]# date\r\nWed May 30 22:30:04 MYT 2012\r\n<\/pre>\n<h2>Commands Mentioned<\/h2>\n<ul>\n<li><span class=\"fw-bold\">date +%D -s YYYY-MM-DD<\/span> \u2013 Changes the current date<\/li>\n<li><span class=\"fw-bold\">date +%T -s HH:MM:SS<\/span> \u2013 Changes the current time<\/li>\n<li><span class=\"fw-bold\">date +%T -s HH:MM:SS -u<\/span> \u2013 Changes the current time in UTC<\/li>\n<li><span class=\"fw-bold\">date<\/span> \u2013 Displays the current date and time<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In conclusion, as a web server administrator, gaining proficiency in adjusting and displaying the date and time on your Linux server, specifically Red Hat Enterprise Linux 6 (RHEL 6) or CentOS 6\/7, is crucial. This tutorial has provided you with the essential commands to perform these tasks.<\/p>\n<p>However, it&#8217;s important to remember that these operations necessitate root privileges. Therefore, it&#8217;s imperative to exercise due diligence and caution when executing these changes to ensure the smooth operation of your server.<\/p>\n<h2>FAQ<\/h2>\n<ol itemscope itemtype=\"https:\/\/schema.org\/FAQPage\">\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Whatdoes the command &#8216;date +%D -s YYYY-MM-DD&#8217; do?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">This command is used to change the current date on your Linux system. In the command, &#8216;YYYY-MM-DD&#8217; should be replaced with the desired date. For example, &#8216;date +%D -s 2022-12-31&#8217; would set the date to December 31, 2022.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How can I change the time on my Linux system?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">You can change the time on your Linux system using the command &#8216;date +%T -s HH:MM:SS&#8217;, where &#8216;HH:MM:SS&#8217; should be replaced with the desired time. For example, &#8216;date +%T -s 13:30:00&#8217; would set the time to 1:30 PM.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">What does the &#8216;-u&#8217; option do in the &#8216;date&#8217; command?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">The &#8216;-u&#8217; option in the &#8216;date&#8217; command is used when your system clock is set to use Coordinated Universal Time (UTC). When this option is used, the time you set with the &#8216;date&#8217; command will be in UTC.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">How can I display the current date and time on my Linux system?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">You can display the current date and time on your Linux system by using the &#8216;date&#8217; command. Simply type &#8216;date&#8217; into the command line and press enter, and the current date and time will be displayed.<\/span>\n            <\/p>\n<\/li>\n<li itemscope itemprop=\"mainEntity\" itemtype=\"https:\/\/schema.org\/Question\">\n<p class=\"fw-bold\" itemprop=\"name\">Why do I need to be logged in as root to change the date and time?<\/p>\n<p itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n                <span itemprop=\"text\">Changing the system&#8217;s date and time is a system-level operation that can affect all users and processes on the system. Therefore, it requires root privileges to ensure that the person making the change has the necessary permissions to perform such a significant operation.<\/span>\n            <\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>In web server administration, understanding how to manage the date and time settings on your server is crucial. This tutorial is designed for those using Red Hat Enterprise Linux 6&#8230;<\/p>\n","protected":false},"author":6,"featured_media":6841,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wds_primary_category":0,"footnotes":""},"categories":[2055,2058],"tags":[1258,1546,1713,1715,1717],"class_list":["post-3253","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-rhel","tag-centos-7","tag-linux-utilities","tag-rhel","tag-rhel-6","tag-rhel-7"],"_links":{"self":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/comments?post=3253"}],"version-history":[{"count":0,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/posts\/3253\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media\/6841"}],"wp:attachment":[{"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/media?parent=3253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/categories?post=3253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webhostinggeeks.com\/howto\/wp-json\/wp\/v2\/tags?post=3253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}