Consider a single user(with a root user) where the user doesn't know the password of the root user which disables him from using su root
and who was in sudoers file but he himself removed him from the sudoers group with the commandsudo adduser foo sudo
.
Now, How does the user foo will access root privileges?
1 Answer
Sounds like you've locked yourself out of sudo
privileges. You are going to need to boot to Grub recovery mode and access root shell.
Go to Grub menu by pressing
shift
key upon startup.Select
Ubuntu recovery mode
and thenroot shell prompt
Type in:
mount -o rw,remount /
and in the next line
usermod -aG sudo username
where username is your username.
Exit and restart.
Check the
/etc/group
file. Your username should now be in thesudo
group.
As long as your user is in the sudo
group, Sudoers
file may be modified to give privileges to access root with sudo su
command, providing that you know user's password.