Introduction
Another error as in the title of this article appears upon switching from a normal user to super user account in Ubuntu Linux 18.04 operating system. The problem starts when accidentally executing the following command :
usermod user -G apache
The result of the above command is positive. It works well where the user is now currently the member of group apache. Unfortunately the command above have a critical impact on the user. The account with the name ‘user’ cannot switch again normally to root account using the ‘sudo’ command.
It seems the previous command somehow remove the ‘user’ account from the group ‘sudo’. Since recovering the account itself by adding to the group ‘sudo’ so that it can switch to root account again cannot be done using the normal ‘user’ account, there must be another solution to achieve it.
One of the most effective solution for solving the problem is through the recovery mode. The following are steps for performing it :
1. Restart the device either it is a PC, laptop or a server.
2. In the boot process, get in to the boot option menu.
3. Choose the recovery mode of the Linux Ubuntu 18.04 as in the following image below :
4. After that, choose the menu ‘root Drop to root shell prompt’ as the following image :
Click the Ok button.
5. After that, the following command line will appear :
Press enter for maintenance (or Press Ctrl-D to continue):
6. Just type Ctrl-D and the following command line will appear. Just type the following command to mount the root partition :
mount -o rw,remount /
7. Since the problem is in the user account is for not having the privilege to switch to the ‘root’ or super admin account, don’t forget to backup the sudo configuration file by typing :
cp /etc/sudoers /etc/sudoers.original
8. After the remounting of the root partition in read and write mode is a success, type the following command to restore the user privilege which is having the ability to switch to ‘root’ or superuser account.
usermod user -G sudo
9. Check the status of the user account again by typing the following command :
id user
Type the above command and the following output will appear :
root@hostname:~# id user uid=1000(user) gid=1000(user) groups=1000(user),27(sudo) root@localhost:~#
9. Don’t forget to change the permission of the file by typing the following command :
chmod 0440 /etc/sudoers
10. Last but not least, restart the operating system by typing ‘exit’ command.
11. Finally, try to execute the command again for switching to root and super admin account. If the command execution is a success, then the above solution is a suitable one.