{"id":3331,"date":"2024-06-17T10:00:22","date_gmt":"2024-06-17T10:00:22","guid":{"rendered":"https:\/\/draculaservers.com\/tutorials\/?p=3331"},"modified":"2024-07-17T14:44:01","modified_gmt":"2024-07-17T14:44:01","slug":"how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu","status":"publish","type":"post","link":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/","title":{"rendered":"How to Fix: Error Writing \/Etc\/hosts &#8211; Permission Denied in Ubuntu?"},"content":{"rendered":"<p>Are you trying to make changes in your Ubuntu Operating System\u2019s \u201chosts\u201d file but cannot save those changes?<\/p>\n<p>The \u201chosts\u201d file contains the different IPs and their respective host names and addresses, and its main job is to convert or translate hostnames to their respective IP addresses. There are various scenarios where the user would want to change this file. However, this file has severe access restrictions, as any unwanted change to this file can lead to various vulnerabilities.<\/p>\n<p>This guide will explain why a user can get the \u201cError Writing &#8211; Permission Denied\u201d prompt when saving the changes inside the \u201chosts\u201d file and its solution.<\/p>\n\n<h2 id=\"how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\">How to Fix: Error Writing \/Etc\/hosts &#8211; Permission Denied in Ubuntu?<\/h2>\n<p>The system administrators can only access the \u201chosts\u201d files, known as the Root users or sudo users in Ubuntu.\u00a0 However, reading the file can be done by a normal user as well.<\/p>\n<p>To access and make changes to the \u201cHosts\u201d file located at \u201c\/etc\/hosts\u201d in Ubuntu, you require root user or sudo privileges. Therefore, remember to open the \u201chosts\u201d file using the \u201csudo\u201d keyword at the start of the command or by using the sudo shell. However, you can choose any editor to make changes.<\/p>\n<h3 id=\"use-the-sudo-keyword-in-command\">Use the \u201csudo\u201d Keyword in Command<\/h3>\n<p>As mentioned, you need root user access rights to save the \u201chosts\u201d file changes. Otherwise, any changes you make will be temporary, and you will get an error prompt \u201cError Writing &#8211; Permission Denied.\u201d<\/p>\n<p>To demonstrate this, you can use the nano editor to open the \u201chosts\u201d file placed inside the \u201cetc\u201d directory by running the following command inside the terminal.<\/p>\n<pre>nano \/etc\/hosts<\/pre>\n<p>Once you execute the command, you will observe that the nano editor shows the following prompt, even before trying to write changes to the file.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3333\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"970\" height=\"669\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-1.png 970w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-1-300x207.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/1-1-768x530.png 768w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n<p>Make any changes to the file and then press the key combination, \u201cCTRL + O,\u201d to save the save changes, and you will get the following error.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3334\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"976\" height=\"166\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2-1.png 976w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2-1-300x51.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/2-1-768x131.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/a><\/p>\n<p>To avoid this, exit the nano editor by pressing the \u201cCTRL + X.\u201d Then, use the \u201csudo\u201d keyword at the start of the command to open the nano editor with sudo rights.<\/p>\n<pre>sudo nano \/etc\/hosts<\/pre>\n<p>However, you will be prompted by the terminal to provide the password for the sudo user. Type in the password and press the \u201cEnter\u201d key to continue.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3335\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"969\" height=\"120\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3-1.png 969w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3-1-300x37.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/3-1-768x95.png 768w\" sizes=\"auto, (max-width: 969px) 100vw, 969px\" \/><\/a><\/p>\n<p>Once you do that, you can open the \u201chosts\u201d file in the nano editor without the warning prompt.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3336\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"965\" height=\"666\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4-1.png 965w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4-1-300x207.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/4-1-768x530.png 768w\" sizes=\"auto, (max-width: 965px) 100vw, 965px\" \/><\/a><\/p>\n<p>Add the lines that you want to define the hostnames and their IP addresses, and press \u201cCTRL + O\u201d to save the file. You will also see a progress prompt.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3337\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"974\" height=\"164\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5-1.png 974w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5-1-300x51.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/5-1-768x129.png 768w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><\/a><\/p>\n<p>Lastly, you can close the file by pressing \u201cCTRL + X.\u201d<\/p>\n<div class=\"cl-preview-section\">\n<h3 id=\"affordable-vps-hosting-with-dracula-servers\"><span style=\"color: #ff2600;\">Affordable VPS Hosting With Dracula Servers<\/span><\/h3>\n<\/div>\n<div class=\"cl-preview-section\">\n<p>Looking for reliable and budget-friendly Virtual Private Server (VPS) hosting? Look no further than\u00a0<a href=\"https:\/\/draculaservers.com\/\">Dracula Servers<\/a>. Dracula Servers offers a range of VPS hosting plans tailored to meet diverse needs. With competitive pricing, robust performance, and a user-friendly interface, it\u2019s an excellent choice for individuals and businesses alike.<\/p>\n<\/div>\n<div class=\"cl-preview-section\">\n<p>Explore the\u00a0<a href=\"https:\/\/draculaservers.com\/\">Dracula Servers website<\/a> to discover hosting solutions that align with your requirements and take your online presence to new heights with their affordable and efficient VPS hosting services.<\/p>\n<\/div>\n<div class=\"cl-preview-section\">\n<p><a href=\"https:\/\/draculaservers.com\/\"><strong>Visit Dracula Servers<\/strong><\/a>\u00a0and experience reliable VPS hosting without breaking the bank.<\/p>\n<\/div>\n<h3 id=\"use-the-sudo-shell-root-shell\">Use the Sudo Shell (Root Shell)<\/h3>\n<p>Another method of changing the host file without encountering the permission denied error is using the sudo or root shell. The root shell executes every command with sudo privileges even when the keyword \u201csudo\u201d has not been explicitly used in the command.<\/p>\n<p>To use the root shell, open up a new terminal session on your Ubuntu system and execute the following command.<\/p>\n<pre>sudo -i<\/pre>\n<p>After that, you will be prompted to provide the password for the root user. Therefore, type in the password and continue. Once you do that, you will see that the user\u2019s name changes to \u201croot\u201d in the terminal.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3338\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"972\" height=\"158\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6-1.png 972w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6-1-300x49.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/6-1-768x125.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/a><\/p>\n<p>Next, open the \u201c\/etc\/hosts\u201d files with the nano editor by running the following command inside your root shell.<\/p>\n<pre>nano \/etc\/hosts<\/pre>\n<p>Your \u201chosts\u201d files will be readable in the nano editor and will not show warning prompts because the command was executed as the root user. Make the changes, and press \u201cCTRL + O\u201d to write the changes in the file.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3339\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"920\" height=\"408\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7-1.png 920w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7-1-300x133.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/7-1-768x341.png 768w\" sizes=\"auto, (max-width: 920px) 100vw, 920px\" \/><\/a><\/p>\n<p><strong>Note:<\/strong> Whenever you use the root shell (sudo shell), each command is executed with the highest privileges, so you will not get any warning or prompts while executing the commands. Therefore, you can run commands that can crash your system files.<\/p>\n<h3 id=\"change-the-file-permissions-of-the-hosts-file\">Change the File Permissions of the \u201chosts\u201d File<\/h3>\n<p>The reason that you get the permission denied error when you try to access the \u201chosts\u201d file is that the file permissions for the normal users are set to \u201cRead\u201d only. If you want to access the hosts file as a normal user regularly and make changes to it, then you can change this file permission.<\/p>\n<p>To do this, open up a new terminal and then type in the following command to change the \u201cpwd\u201d to the \u201cetc\u201d directory.<\/p>\n<pre>cd \/etc\/<\/pre>\n<p>Once you are inside the \u201cetc\u201d directory, you can view the file permissions of all the files by running the following command.<\/p>\n<pre>ls -al<\/pre>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3340\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"973\" height=\"488\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8-1.png 973w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8-1-300x150.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/8-1-768x385.png 768w\" sizes=\"auto, (max-width: 973px) 100vw, 973px\" \/><\/a><\/p>\n<p>As you can see, the list is quite long. You can easily filter out to display the file permissions of only the \u201chosts\u201d file by running the following command.<\/p>\n<pre>ls -al hosts<\/pre>\n<p>&nbsp;<\/p>\n<p>The output shows that the file permissions are set to \u201crw\u201d for root and only \u201cr\u201d for normal users. Next, run the following command to grant the users write access over the \u201chosts\u201d file.<\/p>\n<pre>sudo chmod 666 hosts<\/pre>\n<p>After that, verify that the permissions are changed by running the \u201cls -al hosts\u201d command again.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3341\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9-1.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"964\" height=\"244\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9-1.png 964w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9-1-300x76.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/9-1-768x194.png 768w\" sizes=\"auto, (max-width: 964px) 100vw, 964px\" \/><\/a><\/p>\n<p>Once you are done, open up a new terminal session to ensure the terminal has no access to the sudo password. Open the host file in the nano editor and observe that you will no longer get the warning prompt.<\/p>\n<p><a href=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-3342\" src=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/10.png\" alt=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?\" width=\"966\" height=\"668\" srcset=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/10.png 966w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/10-300x207.png 300w, https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/10-768x531.png 768w\" sizes=\"auto, (max-width: 966px) 100vw, 966px\" \/><\/a><\/p>\n<p>Now, you can add the hostnames and their respective IP addresses and write the changes into the file system without encountering the permission denied error.<\/p>\n<p><strong>Note:<\/strong> Changing the File permissions of the system files is not very good practice as it makes the system files vulnerable. Therefore, it is advised that you use the \u201csudo\u201d keyword whenever you want to make permanent changes to the hosts file.<\/p>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>Changing the \u201chosts\u201d can be necessary in many scenarios, but it would require you to have the root privileges. The \u201chosts\u201d file is in the \u201cetc\u201d directory, which contains multiple system files that configure various aspects of the Ubuntu File system.<\/p>\n<p>If you want to view the \u201chosts\u201d file, then you can use the nano editor or the cat command, and you will not encounter any errors. But, if you make some changes in the \u201chosts\u201d file and then try to save those changes permanently, you will get the permission denied error due to not having adequate access rights.<\/p>\n<p>To fix this, use the keyword \u201csudo\u201d at the start of the command to run the command as a root user. Otherwise, you can shift over to the root shell or the sudo shell which will execute every command as the root user.<\/p>\n<p>Lastly, you can change the file permission of the hosts files, but be careful with this method as it will leave the hosts file vulnerable.<\/p>\n<p>Check out More Linux Tutorials <a href=\"https:\/\/draculaservers.com\/tutorials\/\" target=\"_blank\" rel=\"noopener\">Here!<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you trying to make changes in your Ubuntu Operating System\u2019s \u201chosts\u201d file but cannot save those changes? The \u201chosts\u201d file contains the different IPs and their respective host names and addresses, and its main job is to convert or translate hostnames to their respective IP addresses. There are various scenarios where the user would [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":3343,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,22],"tags":[503,504,502,505],"class_list":["post-3331","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-basics","category-ubuntu","tag-cannot-change-hosts","tag-fix-hosts-unwriteable-error","tag-hosts-file-ubuntu","tag-hosts-file-warning-error"],"blocksy_meta":[],"featured_image_urls_v2":{"full":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png",1280,720,false],"thumbnail":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16-150x150.png",150,150,true],"medium":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16-300x169.png",300,169,true],"medium_large":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16-768x432.png",768,432,true],"large":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16-1024x576.png",1024,576,true],"1536x1536":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png",1280,720,false],"2048x2048":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png",1280,720,false],"pk-small":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16-80x80.png",80,80,true],"pk-thumbnail":["https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16-300x225.png",300,225,true]},"post_excerpt_stackable_v2":"<p>Are you trying to make changes in your Ubuntu Operating System\u2019s \u201chosts\u201d file but cannot save those changes? The \u201chosts\u201d file contains the different IPs and their respective host names and addresses, and its main job is to convert or translate hostnames to their respective IP addresses. There are various scenarios where the user would want to change this file. However, this file has severe access restrictions, as any unwanted change to this file can lead to various vulnerabilities. This guide will explain why a user can get the \u201cError Writing &#8211; Permission Denied\u201d prompt when saving the changes inside&hellip;<\/p>\n","category_list_v2":"<a href=\"https:\/\/draculaservers.com\/tutorials\/category\/linux-basics\/\" rel=\"category tag\">Linux Basics<\/a>, <a href=\"https:\/\/draculaservers.com\/tutorials\/category\/ubuntu\/\" rel=\"category tag\">Ubuntu<\/a>","author_info_v2":{"name":"Abdul Mannan","url":"https:\/\/draculaservers.com\/tutorials\/author\/abdul-mannan-tbgmail-com\/"},"comments_num_v2":"0 comments","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu? - Dracula Servers Tutorials<\/title>\n<meta name=\"description\" content=\"Use the sudo command to open the hosts file or use the chmod command to change its permissions and then change and edit the hosts file!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu? - Dracula Servers Tutorials\" \/>\n<meta property=\"og:description\" content=\"Use the sudo command to open the hosts file or use the chmod command to change its permissions and then change and edit the hosts file!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/\" \/>\n<meta property=\"og:site_name\" content=\"Dracula Servers Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-17T10:00:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-17T14:44:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abdul Mannan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abdul Mannan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/\"},\"author\":{\"name\":\"Abdul Mannan\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ac89d0281f4fb596bfaa0bc1e746c8a6\"},\"headline\":\"How to Fix: Error Writing \\\/Etc\\\/hosts &#8211; Permission Denied in Ubuntu?\",\"datePublished\":\"2024-06-17T10:00:22+00:00\",\"dateModified\":\"2024-07-17T14:44:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/\"},\"wordCount\":1232,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-16.png\",\"keywords\":[\"Cannot change hosts\",\"Fix hosts unwriteable error\",\"Hosts file Ubuntu\",\"Hosts file warning error\"],\"articleSection\":[\"Linux Basics\",\"Ubuntu\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/\",\"name\":\"How to Fix: Error Writing \\\/Etc\\\/hosts - Permission Denied in Ubuntu? - Dracula Servers Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-16.png\",\"datePublished\":\"2024-06-17T10:00:22+00:00\",\"dateModified\":\"2024-07-17T14:44:01+00:00\",\"description\":\"Use the sudo command to open the hosts file or use the chmod command to change its permissions and then change and edit the hosts file!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#primaryimage\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-16.png\",\"contentUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2024\\\/06\\\/Dracula-Servers-Thumbnail-16.png\",\"width\":1280,\"height\":720,\"caption\":\"How to Fix: Error Writing \\\/Etc\\\/hosts - Permission Denied in Ubuntu?\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Fix: Error Writing \\\/Etc\\\/hosts &#8211; Permission Denied in Ubuntu?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#website\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\",\"name\":\"Dracula Servers Tutorials\",\"description\":\"Dedicated Servers\",\"publisher\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#organization\",\"name\":\"Dracula Servers\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/06\\\/dracula_full_logo_smaller.png\",\"contentUrl\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/wp-content\\\/uploads\\\/2016\\\/06\\\/dracula_full_logo_smaller.png\",\"width\":1625,\"height\":200,\"caption\":\"Dracula Servers\"},\"image\":{\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/draculaservers.com\\\/tutorials\\\/#\\\/schema\\\/person\\\/ac89d0281f4fb596bfaa0bc1e746c8a6\",\"name\":\"Abdul Mannan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g\",\"caption\":\"Abdul Mannan\"},\"description\":\"An individual trying to decipher the enigmas of technology by the sheer driving force of curiosity. Interested in learning new skills and being better at those skills than the lot.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu? - Dracula Servers Tutorials","description":"Use the sudo command to open the hosts file or use the chmod command to change its permissions and then change and edit the hosts file!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/","og_locale":"en_US","og_type":"article","og_title":"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu? - Dracula Servers Tutorials","og_description":"Use the sudo command to open the hosts file or use the chmod command to change its permissions and then change and edit the hosts file!","og_url":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/","og_site_name":"Dracula Servers Tutorials","article_published_time":"2024-06-17T10:00:22+00:00","article_modified_time":"2024-07-17T14:44:01+00:00","og_image":[{"width":1280,"height":720,"url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png","type":"image\/png"}],"author":"Abdul Mannan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Abdul Mannan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#article","isPartOf":{"@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/"},"author":{"name":"Abdul Mannan","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/person\/ac89d0281f4fb596bfaa0bc1e746c8a6"},"headline":"How to Fix: Error Writing \/Etc\/hosts &#8211; Permission Denied in Ubuntu?","datePublished":"2024-06-17T10:00:22+00:00","dateModified":"2024-07-17T14:44:01+00:00","mainEntityOfPage":{"@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/"},"wordCount":1232,"commentCount":0,"publisher":{"@id":"https:\/\/draculaservers.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png","keywords":["Cannot change hosts","Fix hosts unwriteable error","Hosts file Ubuntu","Hosts file warning error"],"articleSection":["Linux Basics","Ubuntu"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/","url":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/","name":"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu? - Dracula Servers Tutorials","isPartOf":{"@id":"https:\/\/draculaservers.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#primaryimage"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#primaryimage"},"thumbnailUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png","datePublished":"2024-06-17T10:00:22+00:00","dateModified":"2024-07-17T14:44:01+00:00","description":"Use the sudo command to open the hosts file or use the chmod command to change its permissions and then change and edit the hosts file!","breadcrumb":{"@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#primaryimage","url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png","contentUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2024\/06\/Dracula-Servers-Thumbnail-16.png","width":1280,"height":720,"caption":"How to Fix: Error Writing \/Etc\/hosts - Permission Denied in Ubuntu?"},{"@type":"BreadcrumbList","@id":"https:\/\/draculaservers.com\/tutorials\/how-to-fix-error-writing-etc-hosts-permission-denied-in-ubuntu\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/draculaservers.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"How to Fix: Error Writing \/Etc\/hosts &#8211; Permission Denied in Ubuntu?"}]},{"@type":"WebSite","@id":"https:\/\/draculaservers.com\/tutorials\/#website","url":"https:\/\/draculaservers.com\/tutorials\/","name":"Dracula Servers Tutorials","description":"Dedicated Servers","publisher":{"@id":"https:\/\/draculaservers.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/draculaservers.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/draculaservers.com\/tutorials\/#organization","name":"Dracula Servers","url":"https:\/\/draculaservers.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2016\/06\/dracula_full_logo_smaller.png","contentUrl":"https:\/\/draculaservers.com\/tutorials\/wp-content\/uploads\/2016\/06\/dracula_full_logo_smaller.png","width":1625,"height":200,"caption":"Dracula Servers"},"image":{"@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/draculaservers.com\/tutorials\/#\/schema\/person\/ac89d0281f4fb596bfaa0bc1e746c8a6","name":"Abdul Mannan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2809442d44177cab4f90e1d9b3295560462063881ca1374b6d597d8f0b48fc21?s=96&d=mm&r=g","caption":"Abdul Mannan"},"description":"An individual trying to decipher the enigmas of technology by the sheer driving force of curiosity. Interested in learning new skills and being better at those skills than the lot."}]}},"_links":{"self":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/3331","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/comments?post=3331"}],"version-history":[{"count":2,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/3331\/revisions"}],"predecessor-version":[{"id":3344,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/posts\/3331\/revisions\/3344"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/media\/3343"}],"wp:attachment":[{"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/media?parent=3331"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/categories?post=3331"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/draculaservers.com\/tutorials\/wp-json\/wp\/v2\/tags?post=3331"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}