{"id":13879,"date":"2019-04-06T13:19:21","date_gmt":"2019-04-06T13:19:21","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13879"},"modified":"2019-04-06T13:19:21","modified_gmt":"2019-04-06T13:19:21","slug":"how-to-fix-username-is-not-in-the-sudoers-file-this-incident-will-be-reported-in-ubuntu","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-fix-username-is-not-in-the-sudoers-file-this-incident-will-be-reported-in-ubuntu\/","title":{"rendered":"How to Fix \u201cUsername is not in the sudoers file. This incident will be reported\u201d in Ubuntu"},"content":{"rendered":"<p>In Unix\/Linux systems, the\u00a0<code>root<\/code>\u00a0user account is the super user account, and it can therefore be used to do anything and everything achievable on the system.<\/p>\n<p>However, this can be very dangerous in so many ways \u2013 one could be that the\u00a0<strong>root<\/strong>\u00a0user might enter a wrong command and breaks the whole system or an attacker gets access to root user account and takes control of the whole system and who knows what he\/she can possibly do.<\/p>\n<p>Based upon this background, in\u00a0<strong>Ubuntu<\/strong>\u00a0and its derivatives, the\u00a0<strong>root<\/strong>\u00a0user account is locked by default, regular users (system administrators or not) can only gain super user privileges by using the\u00a0<code>sudo<\/code>\u00a0command.<\/p>\n<p>And one of the worst things that can happen to a Ubuntu System admin is losing privileges to use the\u00a0<strong>sudo<\/strong>command, a situation commonly referred to as \u201c<strong>broken sudo<\/strong>\u201d. This can be absolutely devastating.<\/p>\n<p>A broken\u00a0<strong>sudo<\/strong>\u00a0may be caused by any of the following:<\/p>\n<ol>\n<li>A user should not have been removed from the\u00a0<strong>sudo<\/strong>\u00a0or\u00a0<strong>admin<\/strong>\u00a0group.<\/li>\n<li>The\u00a0<strong>\/etc\/sudoers<\/strong>\u00a0file was altered to prevent users in\u00a0<strong>sudo<\/strong>\u00a0or\u00a0<strong>admin<\/strong>\u00a0group from elevating their privileges to that of\u00a0<strong>root<\/strong>\u00a0using\u00a0<strong>sudo<\/strong>\u00a0command.<\/li>\n<li>The permission on\u00a0<strong>\/etc\/sudoers<\/strong>\u00a0file is not set to\u00a0<strong>0440<\/strong>.<\/li>\n<\/ol>\n<p>In order to perform crucial tasks on your system such as viewing or altering important system files, or updating the system, you need the\u00a0<strong>sudo<\/strong>\u00a0command to gain super user privileges. What if you are denied usage of\u00a0<strong>sudo<\/strong>due one or more of the reasons we mentioned above.<\/p>\n<p>Below is an image showing a case in which the default system user is being prevented from running\u00a0<strong>sudo<\/strong>command:<\/p>\n<pre><strong>tecmint@TecMint ~ $<\/strong> sudo visudo\r\n[ sudo ] password for aaronkilik:\r\naaronkilik is not in the sudoers file.   This incident will be reported.\r\n\r\n<strong>tecmint@TecMint ~ $<\/strong> sudo apt install vim\r\n[ sudo ] password for aaronkilik:\r\naaronkilik is not in the sudoers file.   This incident will be reported.\r\n<\/pre>\n<h3>How To Fix Broken sudo Command in Ubuntu<\/h3>\n<p>If you happen to be running only\u00a0<strong>Ubuntu<\/strong>\u00a0on your machine, after powering it, press the\u00a0<code>Shift<\/code>\u00a0key for a few seconds to get the\u00a0<strong>Grub<\/strong>\u00a0boot menu. On the other hand, if you are running a dual-boot (<a href=\"https:\/\/www.tecmint.com\/install-ubuntu-16-04-alongside-with-windows-10-or-8-in-dual-boot\/\" target=\"_blank\" rel=\"noopener\">Ubuntu alongside Windows<\/a>\u00a0or\u00a0<strong>Mac OS X<\/strong>), then you should see the Grub boot menu by default.<\/p>\n<p>Using the\u00a0<code>Down Arrow<\/code>, select \u201c<strong>Advanced options for Ubuntu<\/strong>\u201d and press\u00a0<strong>Enter<\/strong>.<\/p>\n<div id=\"attachment_22824\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Grub-Menu.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22824\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Grub-Menu.png\" alt=\"Ubuntu Grub Menu\" width=\"689\" height=\"462\" aria-describedby=\"caption-attachment-22824\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22824\" class=\"wp-caption-text\">Ubuntu Grub Menu<\/p>\n<\/div>\n<p>You will be at the interface below, select the kernel with \u201c<strong>recovery mode<\/strong>\u201d option as below and press\u00a0<strong>Enter<\/strong>\u00a0to advance to the \u201c<strong>Recovery menu<\/strong>\u201d.<\/p>\n<div id=\"attachment_22825\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Recovery-Mode.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22825\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Recovery-Mode.png\" alt=\"Ubuntu Recovery Mode\" width=\"689\" height=\"462\" aria-describedby=\"caption-attachment-22825\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22825\" class=\"wp-caption-text\">Ubuntu Recovery Mode<\/p>\n<\/div>\n<p>Below is the \u201c<strong>Recovery menu<\/strong>\u201d, indicating that the root filesystem is mounted as read-only. Move over to the line \u201c<strong>root Drop to root shell prompt<\/strong>\u201d, then hit\u00a0<strong>Enter<\/strong>.<\/p>\n<div id=\"attachment_22826\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/select-drop-to-root-shell.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22826\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/select-drop-to-root-shell.png\" alt=\"Ubuntu Recovery Menu - Drop to root Shell Prompt\" width=\"689\" height=\"462\" aria-describedby=\"caption-attachment-22826\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22826\" class=\"wp-caption-text\">Ubuntu Recovery Menu \u2013 Drop to root Shell Prompt<\/p>\n<\/div>\n<p>Next, press\u00a0<strong>Enter<\/strong>\u00a0for maintenance:<\/p>\n<div id=\"attachment_22827\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Maintenance.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22827\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Maintenance.png\" alt=\"Ubuntu Maintenance\" width=\"689\" height=\"462\" aria-describedby=\"caption-attachment-22827\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22827\" class=\"wp-caption-text\">Ubuntu Maintenance<\/p>\n<\/div>\n<p>At this point, you should be at the\u00a0<strong>root<\/strong>\u00a0shell prompt. As we had seen before, the filesystem is mounted as read-only, therefore, to make changes to the system we need to remount is as read\/write by running the command below:<\/p>\n<pre># mount -o rw,remount \/\r\n<\/pre>\n<h4>Solving Case #1 \u2013 Add User to sudo or admin Group<\/h4>\n<p>Assuming that a user has been removed from the sudo group, to add user back to sudo group issue the command below:<\/p>\n<pre># adduser username sudo\r\n<\/pre>\n<p><strong>Note<\/strong>: Remember to use the actual username on the system, for my case, it is\u00a0<strong>aaronkilik<\/strong>.<\/p>\n<p>Or else, under the condition that a user has been removed from the admin group, run the following command:<\/p>\n<pre># adduser username admin\r\n<\/pre>\n<h4>Solving Case #2 \u2013 Granting sudo Privileges to Users<\/h4>\n<p>On the assumption that the\u00a0<code>\/etc\/sudoers<\/code>\u00a0file was altered to prevent users in\u00a0<strong>sudo<\/strong>\u00a0or\u00a0<strong>admin<\/strong>\u00a0group from elevating their privileges to that of a super user, then make a backup of the\u00a0<strong>sudoers<\/strong>\u00a0files as follows:<\/p>\n<pre># cp \/etc\/sudoers \/etc\/sudoers.orginal\r\n<\/pre>\n<p>Subsequently, open the\u00a0<strong>sudoers<\/strong>\u00a0file.<\/p>\n<pre># visudo\r\n<\/pre>\n<p>and add the content below:<\/p>\n<pre>#\r\n# This file MUST be edited with the 'visudo' command as root.\r\n#\r\n# Please consider adding local content in \/etc\/sudoers.d\/ instead of\r\n# directly modifying this file.\r\n#\r\n# See the man page for details on how to write a sudoers file.\r\n#\r\nDefaults        env_reset\r\nDefaults        mail_badpass\r\nDefaults        secure_path=\"\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbi$\r\n\r\n# Host alias specification\r\n\r\n# User alias specification\r\n\r\n# Cmnd alias specification\r\n\r\n# User privilege specification\r\nroot    ALL=(ALL:ALL) ALL\r\n\r\n# Members of the admin group may gain root privileges\r\n%admin ALL=(ALL) ALL\r\n\r\n# Allow members of group sudo to execute any command\r\n%sudo   ALL=(ALL:ALL) ALL\r\n\r\n# See sudoers(5) for more information on \"#include\" directives:\r\n\r\n#includedir \/etc\/sudoers.d\r\n<\/pre>\n<h4>Solving Case #3 \u2013 Setting Correct Permission on sudoers File<\/h4>\n<p>Supposing that the permission on\u00a0<strong>\/etc\/sudoers<\/strong>\u00a0file is not set to\u00a0<strong>0440<\/strong>, then run following command to make it right:<\/p>\n<pre># chmod  0440  \/etc\/sudoers\r\n<\/pre>\n<p>Last but not least, after running all the necessary commands, type the\u00a0<code>exit<\/code>\u00a0command to go back to the \u201c<strong>Recovery menu<\/strong>\u201d:<\/p>\n<pre># exit \r\n<\/pre>\n<p>Use the\u00a0<code>Right Arrow<\/code>\u00a0to select\u00a0<code>&lt;Ok&gt;<\/code>\u00a0and hit\u00a0<strong>Enter<\/strong>:<\/p>\n<div id=\"attachment_22828\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Recovery-Menu-Resume-Normal-Boot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22828\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Ubuntu-Recovery-Menu-Resume-Normal-Boot.png\" alt=\"Ubuntu Recovery Menu - Resume Normal Boot\" width=\"645\" height=\"506\" aria-describedby=\"caption-attachment-22828\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22828\" class=\"wp-caption-text\">Ubuntu Recovery Menu \u2013 Resume Normal Boot<\/p>\n<\/div>\n<p>Press\u00a0<code>&lt;Ok&gt;<\/code>\u00a0to continue with normal boot sequence:<\/p>\n<div id=\"attachment_22829\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Confirm-Ubuntu-Normal-Boot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-22829\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2016\/09\/Confirm-Ubuntu-Normal-Boot.png\" alt=\"Confirm Ubuntu Normal Boot\" width=\"645\" height=\"506\" aria-describedby=\"caption-attachment-22829\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-22829\" class=\"wp-caption-text\">Confirm Ubuntu Normal Boot<\/p>\n<\/div>\n<h3>Summary<\/h3>\n<p>This method should work just fine especially when it is an administrative user account involved, where there is no other option but to use the recovery mode.<\/p>\n<p>However, if it fails to work for you, try to get back to us by expressing your experience via the feedback section below. You can as well offer any suggestions or other possible ways to solve the issue at hand or improve this guide altogether.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/fix-user-is-not-in-the-sudoers-file-the-incident-will-be-reported-ubuntu\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Unix\/Linux systems, the\u00a0root\u00a0user account is the super user account, and it can therefore be used to do anything and everything achievable on the system. However, this can be very dangerous in so many ways \u2013 one could be that the\u00a0root\u00a0user might enter a wrong command and breaks the whole system or an attacker gets &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/06\/how-to-fix-username-is-not-in-the-sudoers-file-this-incident-will-be-reported-in-ubuntu\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Fix \u201cUsername is not in the sudoers file. This incident will be reported\u201d in Ubuntu&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13879","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13879","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13879"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13879\/revisions"}],"predecessor-version":[{"id":13880,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13879\/revisions\/13880"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13879"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13879"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13879"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}