{"id":224961,"date":"2021-04-12T16:00:59","date_gmt":"2021-04-12T13:00:59","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc-cloudsavvy-it\/"},"modified":"2021-04-12T16:00:59","modified_gmt":"2021-04-12T13:00:59","slug":"how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc-cloudsavvy-it\/","title":{"rendered":"#How to Set a User Timezone in Ubuntu and Mint Using .bashrc \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2fcf2ecdfea\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2fcf2ecdfea\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc-cloudsavvy-it\/#What_Is_bashrc\" >What Is .bashrc?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc-cloudsavvy-it\/#Changing_the_User_Timezone_in_Bash\" >Changing the User Timezone in Bash<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc-cloudsavvy-it\/#Configuring_a_User_Timezone_from_bashrc\" >Configuring a User Timezone from .bashrc<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc-cloudsavvy-it\/#Wrapping_up\" >Wrapping up<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#How to Set a User Timezone in Ubuntu and Mint Using .bashrc \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4038\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png?width=1200&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Bash Shell\" width=\"1400\" height=\"600\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Whilst many Desktop enabled Ubuntu computers have a handy GUI configuration cool, this does not help when configuring headless (i.e. screenless) instances like servers. Find out how to setup a timezone from the terminal, using .bashrc.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Is_bashrc\"><\/span>What Is <i>.bashrc<\/i>?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The <code>.bashrc<\/code> file is a hidden Bash-shell specific file sitting in the root of you home directory, i.e. it\u2019s location is <code>~\/.bashrc<\/code>. The <code>~<\/code> (tilde) is a shortcut to your home directory, which has a longer path, like for example <code>\/home\/roel<\/code>. When using <code>~<\/code>, Bash will automatically replace the tilde with your home directory (i.e. including the user name).<\/p>\n<p>You can edit this file by using a text editor like <code>vim<\/code> or <code>nano<\/code>. If you would like to learn more about using <code>vim<\/code>, have a look at our Define a Great Vim Profile Using .vimrc article which also described basic <code>vim<\/code> usage.<\/p>\n<p>If you are not experienced with <code>vim<\/code> yet, or an in a hurry, you can use the <code>nano<\/code> editor instead. Simply execute <code>nano ~\/.bashrc<\/code> to get started with editing your <code>.bashrc<\/code>. If you get an error that <code>nano<\/code> was not found on your system, simply install the same by using <code>sudo apt install nano<\/code>.<\/p>\n<p>The <code>.bashrc<\/code> file contains per-user system configuration implementations. In other words, if you would like to pre-configure something (like for example, an command alias, or a timezone) to be available in your Bash terminal session every time you start one, the <code>.bashrc<\/code> file is the place to do so!<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Changing_the_User_Timezone_in_Bash\"><\/span>Changing the User Timezone in Bash<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Changing the user timezone in Bash is easy; simply set the <code>TZ<\/code> variable (by exporting it) to your desired timezone. For example:<\/p>\n<pre>export TZ=Australia\/Perth&#13;\ndate&#13;\nexport TZ=Australia\/Darwin&#13;\ndate&#13;\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10300\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/03\/35b521e3.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Setting a timezone by exporting the TZ variable in Bash\" width=\"305\" height=\"119\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Note the difference in time between the two locations, as well as the different timezone abbreviation.<\/p>\n<p>To get a list of time zones, simply execute <code>timedatectl list-timezones | grep your_country<\/code> where <code>your_country<\/code> is replaced by your actual country, or the country you want to use for your shell time setting\/configuration.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10301\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/03\/6b7886c2.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"\" width=\"388\" height=\"223\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Armed with this information, it will now be easy to update our <code>.bashrc<\/code> file to match our desired setup.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Configuring_a_User_Timezone_from_bashrc\"><\/span>Configuring a User Timezone from .bashrc<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To setup a timezone from your <code>~\/.bashrc<\/code> file, first open the file using a text editor (as described above), and subsequently add the following line to the end of the file, changing the timezone to your preferred setting:<\/p>\n<pre>export TZ=Australia\/Sydney&#13;\n<\/pre>\n<p>Now simply exit your current Bash session and re-open it. When you now execute the <code>date<\/code> command, you should find that your timezone has change to the value exported to the <code>TZ<\/code> variable in your <code>~\/.bashrc<\/code> file. You can also type <code>timedatectl<\/code> without any options to see a fuller overview. For example, using the <code>TZ<\/code> setting of <code>Australia\/Sydney<\/code>, we see:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10302\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2021\/03\/aa1a8e6e.png?trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"The informative output of timedatectl\" width=\"494\" height=\"135\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Wrapping_up\"><\/span>Wrapping up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this article, we reviewed how to setup a timezone in Ubuntu or Linux Mint by using the <code>.bashrc<\/code> file. We also looked at how to edit this file and what the file does. Being able to set a timezone from the command line is especially handy when you are working on a headless (i.e. screenless) system, like is the case with servers. <strong>Enjoy the correct time, every time!<\/strong>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/10299\/how-to-set-a-user-timezone-in-ubuntu-and-mint-using-bashrc\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#How to Set a User Timezone in Ubuntu and Mint Using .bashrc \u2013 CloudSavvy IT&#8221; Whilst many Desktop enabled Ubuntu computers have a handy GUI configuration cool, this does not help when configuring headless (i.e. screenless) instances like servers. Find out how to setup a timezone from the terminal, using .bashrc. What Is .bashrc? The&#8230;<\/p>\n","protected":false},"author":1,"featured_media":224962,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2017\/07\/add8ac45.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-224961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/224961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=224961"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/224961\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/224962"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=224961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=224961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=224961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}