- How to Fix “Username is not in the sudoers file. This incident will be reported” in Ubuntu
- How To Fix Broken sudo Command in Ubuntu
- Solving Case #1 – Add User to sudo or admin Group
- Solving Case #2 – Granting sudo Privileges to Users
- Solving Case #3 – Setting Correct Permission on sudoers File
- Summary
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Исправление ошибки «user is not in the sudoers file. This incident will be reported» в Ubuntu
- В случае если вы испортили файл /etc/sudoers, выполните следующие действия:
- Также рекомендую прочитать:
- 11 Комментариев
- Оставить комментарий Отменить ответ
How to Fix “Username is not in the sudoers file. This incident will be reported” in Ubuntu
In Unix/Linux systems, the root user 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 – one could be that the root user 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.
Based upon this background, in Ubuntu and its derivatives, the root user account is locked by default, regular users (system administrators or not) can only gain super user privileges by using the sudo command.
And one of the worst things that can happen to a Ubuntu System admin is losing privileges to use the sudo command, a situation commonly referred to as “broken sudo”. This can be absolutely devastating.
A broken sudo may be caused by any of the following:
- A user should not have been removed from the sudo or admin group.
- The /etc/sudoers file was altered to prevent users in sudo or admin group from elevating their privileges to that of root using sudo command.
- The permission on /etc/sudoers file is not set to 0440.
In order to perform crucial tasks on your system such as viewing or altering important system files, or updating the system, you need the sudo command to gain super user privileges. What if you are denied usage of sudo due one or more of the reasons we mentioned above.
Below is an image showing a case in which the default system user is being prevented from running sudo command:
How To Fix Broken sudo Command in Ubuntu
If you happen to be running only Ubuntu on your machine, after powering it, press the Shift key for a few seconds to get the Grub boot menu. On the other hand, if you are running a dual-boot (Ubuntu alongside Windows or Mac OS X), then you should see the Grub boot menu by default.
Using the Down Arrow , select “Advanced options for Ubuntu” and press Enter.
Ubuntu Grub Menu
You will be at the interface below, select the kernel with “recovery mode” option as below and press Enter to advance to the “Recovery menu”.
Ubuntu Recovery Mode
Below is the “Recovery menu”, indicating that the root filesystem is mounted as read-only. Move over to the line “root Drop to root shell prompt”, then hit Enter.
Ubuntu Recovery Menu – Drop to root Shell Prompt
Next, press Enter for maintenance:
Ubuntu Maintenance
At this point, you should be at the root shell 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:
Solving Case #1 – Add User to sudo or admin Group
Assuming that a user has been removed from the sudo group, to add user back to sudo group issue the command below:
Note: Remember to use the actual username on the system, for my case, it is aaronkilik.
Or else, under the condition that a user has been removed from the admin group, run the following command:
Solving Case #2 – Granting sudo Privileges to Users
On the assumption that the /etc/sudoers file was altered to prevent users in sudo or admin group from elevating their privileges to that of a super user, then make a backup of the sudoers files as follows:
Subsequently, open the sudoers file.
and add the content below:
Solving Case #3 – Setting Correct Permission on sudoers File
Supposing that the permission on /etc/sudoers file is not set to 0440, then run following command to make it right:
Last but not least, after running all the necessary commands, type the exit command to go back to the “Recovery menu”:
Use the Right Arrow to select and hit Enter:
Ubuntu Recovery Menu – Resume Normal Boot
Press to continue with normal boot sequence:
Confirm Ubuntu Normal Boot
Summary
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.
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.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Исправление ошибки «user is not in the sudoers file. This incident will be reported» в Ubuntu
OSmaster.org.ua > Linux > Ubuntu > Исправление ошибки «user is not in the sudoers file. This incident will be reported» в Ubuntu
По умолчанию в Ubuntu, первая учетная запись которую вы создали в процессе установки, имеет права администратора системы. С помощью этой учетной записью, вы можете выполнять административные задачи с использованием команды «sudo». Команда «sudo» относится к группе Super User (Супер пользователей), все пользователи в этой группе имеют права администратора для управления системой. Однако, если вы случайно удалили себя из «sudo» группы, вы не сможете ничего сделать. Вместо этого, единственное, что вы увидите, это сообщение: «user is not in the sudoers file. This incident will be reported»
Как исправить эту ошибку:
1. Перезагрузите компьютер. Если Ubuntu является вашей основной и единственной операционной системой, то при загрузке системы нажмите кнопку «Shift». На вашем мониторе должен появиться загрузчик Grub. Выберите режим восстановления и нажмите Enter.
2. В следующем диалоговом сообщении выберите «Check all file system (will exit read only mode)» («Проверить все файловые системы ( режим только для чтения)»).
Когда увидите сообщение «Finished, press Enter», нажмите Enter.
3. Затем выберите «Drop to root shell prompt».
4. Запуститься командная строка. Введите:
Замените имя пользователя «username» на ваше имя пользователя.
5. Вот и все. Теперь введите «exit» и перезагрузите систему.
В случае если вы испортили файл /etc/sudoers, выполните следующие действия:
Выше описанные шаги предполагают, что ваш etc/sudoers файл не изменялся и не поврежден. Если у вас неправильный файл /etc/sudoers. Вот что вам нужно сделать:
1. Выполните вышеупомянутые первые 3-и шага.
2. В командной строке введите:
Введите следующие строки в файл
Нажмите «Ctrl + O», чтобы сохранить файл и «Ctrl + X», чтобы выйти.
3. Далее, установите права для файла sudoers:
4. Наконец, добавьте себя в Sudo группу:
5. Перезагрузите систему.
Теперь вы сможете выполнять задачи в режиме «sudo».
Также рекомендую прочитать:
11 Комментариев
Статья хорошая у Вас получилась, и мне как раз подошла бы. Только вот при попытке зайти в safemode виртуалка с линуксом ложится почему-то.
Эх, как обычно снесу сейчас всё, и по новой поставлю.
Понять бы ещё когда я умудрился себя из админов удалить. Доэкспериментировался.
в 12.04 после fsck картинка остается прежней, мол файлсистем «read-only», но войдя в root “Drop to root shell prompt”. я выполнял все команды без sudo и все супер. ))), у меня был испорчен файл /etc/sudoers. всем удачи)))
Короче, если кто-то наткнется на ошибку: «admin group does not exist», вот вам две команды:
mount -o remount,rw /
sudo addgroup your-username sudo
(your-username надо изменить)…
Можно добавить в пост)
Gimli, спасибо огромное.
Ты спас меня!!)))
после первой команды «mount -o remount,rw /» пишет: «admin group does not exist»
после второй команды «sudo addgroup your-username sudo» пишет «addgroup: The user `my-username’ does not exist»
Что делать дальше?
Список всех пользователей в системе можно получить с помощью команды: cat /etc/passwd, убедитесь что ваш пользователь есть в списке. Команда добавления группы в систему выглядит так: sudo groupadd «имя_группы».
Присоединяюсь к Павлу, большое спасибо Gimli))
4. Наконец, добавьте себя в Sudo группу:
usermod -a -G admin username
после этого пишет: «usermod: group ‘admin’ does not exist»
Убедитесь что в вашей системе существует такая группа: admin. Это можно выполнить с помощью команды: cat /etc/group
Интересно, а суперпользователю доступ закрыли из внутри. можно ли удаленно перегрузить систему обычным пользователем?
Если система Ubuntu, то через sudo, в остальных через su.
Оставить комментарий Отменить ответ
- Как удалить все стандартные сторонние приложения из Windows 8 (Windows RT)
(10,00 из 10)
- Как уменьшить уровень почти полной разрядки батареи до 1% в настройках Windows 7
(10,00 из 10)
- Список новых функций в Windows 8.1
(10,00 из 10)
- Сравнение программ для восстановления информации
(10,00 из 10)
- Как ограничить количество попыток ввода пароля при входе в Windows
(10,00 из 10)
- Как восстановить потерянные лицензионные ключи Windows и программ с нерабочего компьютера
(10,00 из 10)
- Удобный плагин для навигации по файлам и папкам в Notepad++
(10,00 из 10)
- Создание ярлыка и горячих клавиш для отключения монитора
(10,00 из 10)
- Кросс-платформенный аудио редактор Ocenaudio
(10,00 из 10)
- Как удалить системный файл в Windows 7 или Vista
(10,00 из 10)
Источник