{"id":6052,"date":"2024-12-16T18:04:51","date_gmt":"2024-12-16T12:34:51","guid":{"rendered":"https:\/\/www.veeble.com\/kb\/?p=6052"},"modified":"2025-04-03T15:27:09","modified_gmt":"2025-04-03T09:57:09","slug":"how-to-fix-username-is-not-in-the-sudoers-file-error-in-ubuntu","status":"publish","type":"post","link":"https:\/\/www.veeble.com\/kb\/how-to-fix-username-is-not-in-the-sudoers-file-error-in-ubuntu\/","title":{"rendered":"How to Fix &#8220;username is not in the sudoers file&#8221; Error in Ubuntu"},"content":{"rendered":"\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-163552-1.png\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1682\" height=\"254\" data-id=\"6094\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-163552-1.png\" alt=\"username is not in the sudoers file. this incident will be reported\" class=\"wp-image-6094\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-163552-1.png 1682w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-163552-1-300x45.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-163552-1-1024x155.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-163552-1-768x116.png 768w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-163552-1-1536x232.png 1536w\" sizes=\"(max-width: 1682px) 100vw, 1682px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p>If you&#8217;ve encountered an error message: &#8220;<strong>Username is not in the sudoers file. This incident will be reported.&#8221;<\/strong> Similar to the image above, please do not be concerned; this guide will provide you with a step-by-step solution to address the issue. Follow along to regain access to <a href=\"https:\/\/en.wikipedia.org\/wiki\/Sudo\" target=\"_blank\" rel=\"noopener\">administrative privileges<\/a> on your Ubuntu system.<\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-1-verify-your-username\">Step 1: Verify Your Username<\/h4>\n\n\n<p>Before making any changes, confirm the username you&#8217;re currently using. Open the terminal and type the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>whoami<\/code><\/pre>\n\n\n\n<p>This will display your username. Make a note of it!<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-164016.png\"><img decoding=\"async\" width=\"934\" height=\"61\" data-id=\"6081\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-164016.png\" alt=\"execute the command: &quot;whoami&quot; to know your username before solving the error: Username is not in the sudoers file error.\" class=\"wp-image-6081\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-164016.png 934w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-164016-300x20.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-164016-768x50.png 768w\" sizes=\"(max-width: 934px) 100vw, 934px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-2-switch-to-the-root-user\">Step 2: Switch to the Root User<\/h4>\n\n\n<p>There is a chance that your user account lacks sudo privileges therefore you must switch to the root user. This step requires prior setup if you don\u2019t know the root password. Log in as the root user with command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>su<\/code><\/pre>\n\n\n\n<p>Enter the root password when prompted.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-3 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-165357.png\"><img decoding=\"async\" width=\"1316\" height=\"93\" data-id=\"6083\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-165357.png\" alt=\"Switch to the root user by executing the command: &quot;su&quot; in the command prompt. This way we can access the sudoers file later and resolve the error: username is not in the sudoers file.\" class=\"wp-image-6083\" srcset=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-165357.png 1316w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-165357-300x21.png 300w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-165357-1024x72.png 1024w, https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Screenshot-2024-12-13-165357-768x54.png 768w\" sizes=\"(max-width: 1316px) 100vw, 1316px\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<p>You&#8217;re now switched to the root user!<\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-3-open-the-sudoers-file\">Step 3: Open the Sudoers File<\/h4>\n\n\n<p>The <a href=\"https:\/\/www.veeble.com\/kb\/how-to-configure-sudoers-without-password\/\">sudoers file<\/a> controls, all users&#8217; administrative privileges. Open it using the <code>visudo<\/code> command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>visudo<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-4 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/visudo.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"1900\" height=\"604\" data-id=\"6085\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/visudo.gif\" alt=\"exexuting the command: &quot;visudo&quot;, we can access the sudoers file and resolve the error: username is not in the sudoers file by editing with correct entry.\" class=\"wp-image-6085\"\/><\/a><\/figure>\n<\/figure>\n\n\n\n<p>Editing this file by altering values can resolve the issue you face: username is not in the sudoers file.<\/p>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-4-add-your-username-to-the-file\">Step 4: Add Your Username to the File<\/h4>\n\n\n<p>Scroll down to find the section that lists users and groups with sudo privileges in the opened file. Add a line for your username in the following format:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>your_username ALL=(ALL:ALL) ALL<\/code><\/pre>\n\n\n\n<p>Replace <code>your_username<\/code> with the actual username you verified earlier.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-5 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/visudo-1.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"1900\" height=\"604\" data-id=\"6087\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/visudo-1.gif\" alt=\"add the username in the sudoers file which we opened by the command visudo in the format: &quot;your_username ALL=(ALL:ALL) ALL&quot;\" class=\"wp-image-6087\"\/><\/a><\/figure>\n<\/figure>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-5-save-and-exit\">Step 5: Save and Exit<\/h4>\n\n\n<p>To save your changes, press <strong>Ctrl + X<\/strong>, then press <strong>Y<\/strong>, and finally, hit <strong>Enter<\/strong> to confirm the changes.<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-6 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/save-and-exit-visudo.gif\"><img loading=\"lazy\" decoding=\"async\" width=\"1900\" height=\"604\" data-id=\"6090\" src=\"https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/save-and-exit-visudo.gif\" alt=\"\" class=\"wp-image-6090\"\/><\/a><\/figure>\n<\/figure>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-6-exit-the-root-user-account\">Step 6: Exit the Root User Account<\/h4>\n\n\n<p>After saving the changes, exit the root account:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>exit<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"step-7-verify-the-fix\">Step 7: Verify the Fix<\/h4>\n\n\n<p>Now, try running a command that requires sudo privileges, such as updating the system or the command you faced issue earlier:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<p>If everything is configured correctly, the error should no longer appear now.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-verse\"><strong><span style=\"text-decoration: underline\">Why Use a VPS for Ubuntu?<\/span><\/strong><br>Managing permissions and user privileges is easier when working in a reliable hosting environment. If you're using Ubuntu for a project, consider using a <a href=\"https:\/\/www.veeble.com\/vps-hosting\/\">Veeble Unmetered Bandwidth Linux VPS<\/a>. It offers a secure and customizable environment for running your applications seamlessly.<\/pre>\n\n\n\n<div class=\"wp-block-uagb-separator uagb-block-12866070\"><div class=\"wp-block-uagb-separator__inner\" style=\"--my-background-image:\"><\/div><\/div>\n\n\n\n<p>With these steps, you can successfully resolve the &#8220;<strong>Username is not in the sudoers file<\/strong>&#8221; error. <\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-uagb-call-to-action uagb-block-f8e0c2eb wp-block-button\"><div class=\"uagb-cta__wrap\"><h3 class=\"uagb-cta__title\">Boost Your WooCommerce Speed!<\/h3><p class=\"uagb-cta__desc\">Get ultra-fast WooCommerce hosting for higher conversions. Optimized servers for peak performance.<\/p><\/div><div class=\"uagb-cta__buttons\"><a href=\"https:\/\/www.veeble.com\/woocommerce-hosting\/\" class=\"uagb-cta__button-link-wrapper wp-block-button__link\" target=\"_blank\" rel=\"noopener noreferrer\">View Plans.<svg xmlns=\"https:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\"><path d=\"M504.3 273.6l-112.1 104c-6.992 6.484-17.18 8.218-25.94 4.406c-8.758-3.812-14.42-12.45-14.42-21.1L351.9 288H32C14.33 288 .0002 273.7 .0002 255.1S14.33 224 32 224h319.9l0-72c0-9.547 5.66-18.19 14.42-22c8.754-3.809 18.95-2.075 25.94 4.41l112.1 104C514.6 247.9 514.6 264.1 504.3 273.6z\"><\/path><\/svg><\/a><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to fix the error: &#8220;username is not in the sudoers file&#8221; easily with this step-by-step tutorial with screenshots.<\/p>\n","protected":false},"author":7,"featured_media":8447,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"footnotes":""},"categories":[5],"tags":[],"class_list":["post-6052","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"uagb_featured_image_src":{"full":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Fixing-the-Entry-Point-Not-Found-Error-in-Dynamic-Link-Library-1.jpg",1366,768,false],"thumbnail":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Fixing-the-Entry-Point-Not-Found-Error-in-Dynamic-Link-Library-1-150x150.jpg",150,150,true],"medium":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Fixing-the-Entry-Point-Not-Found-Error-in-Dynamic-Link-Library-1-300x169.jpg",300,169,true],"medium_large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Fixing-the-Entry-Point-Not-Found-Error-in-Dynamic-Link-Library-1-768x432.jpg",768,432,true],"large":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Fixing-the-Entry-Point-Not-Found-Error-in-Dynamic-Link-Library-1-1024x576.jpg",1024,576,true],"1536x1536":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Fixing-the-Entry-Point-Not-Found-Error-in-Dynamic-Link-Library-1.jpg",1366,768,false],"2048x2048":["https:\/\/www.veeble.com\/kb\/wp-content\/uploads\/2024\/12\/Fixing-the-Entry-Point-Not-Found-Error-in-Dynamic-Link-Library-1.jpg",1366,768,false]},"uagb_author_info":{"display_name":"Adrian Antony","author_link":"https:\/\/www.veeble.com\/kb\/author\/adrian\/"},"uagb_comment_info":0,"uagb_excerpt":"Learn how to fix the error: \"username is not in the sudoers file\" easily with this step-by-step tutorial with screenshots.","_links":{"self":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/6052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/comments?post=6052"}],"version-history":[{"count":12,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/6052\/revisions"}],"predecessor-version":[{"id":8463,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/posts\/6052\/revisions\/8463"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media\/8447"}],"wp:attachment":[{"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/media?parent=6052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/categories?post=6052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.veeble.com\/kb\/wp-json\/wp\/v2\/tags?post=6052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}