0

I downloaded python but when checking if pip was installed, the terminal displayed 'no module named pip' So I found that you can download it using the command prompt 'sudo apt install python3-pip', but then I ran into the issue of my username not being in the sudoers file. Did some digging and apparently I can fix this by utilizing the root terminal and/or utilizing some sudo commands. However, whenever I run any sudo commands, I run into the same issue of my username not being in the sudoers file. Any tips on fixing any of these issues?

chaej
  • 9

2 Answers2

0

If you have access to "the root terminal" (and you shouldn't, Linux moved away from root logins years ago), you could:

userid="your userid"
adduser "$userid" sudo

This will add your userid to the sudo group, the %sudo entry in /etc/sudoers.

Then, have your userid log out (all the way out), and log in again. Groups are set up at login time.

Check with sudo id.

waltinator
  • 37,856
0

By default on Ubuntu, any user who is in the sudo group will be able to use the sudo xxx command to escalate their user priviliges (i.e. become root). The first user created as part of the Ubuntu install would usually be in the sudo group. To check to see if your user has this access:

groups

If sudo is in this output, you have sudo access. If sudo is not in the output, you need to find an accout with sudo access. To do this (possible as a normal user), you can examine the /etc/group file:

grep '^sudo:' /etc/group

THe output will include a list of users at the end of the line who are members of the sudo group.

If you can get access to one of these logins, you can add new users (e.g. newsudousername) to the sudo group with the command @waltinator describes:

sudo adduser newsudousername sudo

This will add the user newsudousername to the sudo group but needs to be run as a user who has sudo access already.

If you've lost access to all sudo users, you could boot in single user mode and edit the /etc/group file to include a username that you do have access to.

The other thing that might cause your error but is less likely is that your /etc/sudoers file has been changed and no longer contains the sudo group. You would need to fix this in single user mode but be very careful as it is easy to make worse.

The following guide might be useful for a better understanding: https://www.howtoforge.com/sudo-beginners-guide/

moo
  • 966