Sudo, or superuser do
is a very powerful command in Linux. It essentially allows you to run the command as root, the highest level of user in the Linux hierarchy, and analogous to administrator user account in Windows.
Root users can execute very sensitive commands, such as formatting a hard drive and installing new hardware drivers.
Therefore, the usage of the root account and sudo command is limited to prevent damage to your system. However, there are times when you cannot access sudo command or root shell in Ubuntu Linux.
This could prove to be frustrating for you, especially if you need to do routine system maintenance like updating installed software in your system. Fortunately, the permission issue is easy to fix and only requires a few commands in the terminal.
First of all, you need to open a terminal window, and type
$ chmod 755 /
$ chmod 755 /bin
$ chmod 755 /lib
The command will reset the permission of the file system and only needs to be run once to fix the sudo issue. Permission problem might affect your ability to run superuser command and is common to Ubuntu Linux.
After running all three commands, retry using the sudo command. By then, you should be able to run root-only commands through sudo.
However, sometimes the commands above do not solve sudo permission issues. If the problem persists, it might be possible that your account is not authorized to use sudo. In Ubuntu Linux and Linux in general, accounts that can use sudo is kept in the “sudoers” group.
Users that are not listed in this group will not be able to use sudo, and a new user needs to be created. This is designed to prevent malicious users to gain full access to the system through a compromised user account.
To get started, you will need access to the root account or another user account that is able to run sudo command.
Log in with the desired user’s credential and issue this following command:
#adduser newuser
Change the username to anything you desire, and enter a password for the new user. Make sure that you enter a secure password, and retype your password to continue the user creation process.
You might be prompted to enter additional information about the new user, which you can skip by pressing Enter. After the user has been created, enter the following command to enroll the user into the sudo group. Replace the “newuser” name with your newly created username:
#usermod -aG sudo newuser
Verify that the user is now enrolled to the sudo group by using this following command:
#groups newuser
The system will list the groups of new user. Ensure that “sudo” group is listed, and then you can proceed to use su with the new user’s credentials. Switch users in the terminal by using this following command, and don’t forget to replace “newuser” with the username you created:
$ su - newuser
If you find this guide useful, don’t forget to bookmark this page. You might also want to read other tutorials from us such as this one on how to restart your Ubuntu X window server right from the command line.
We are a bunch of people who are still continue to learn Linux servers. Only high passion keeps pushing us to learn everything.