How do I add myself back as a sudo user?

1

If you should be a sudoer in ubuntu but somehow the system is broken and you can no longer make administrative changes, follow the procedure below to re-enter the sudoers list.

$ sudo ls
[sudo] password for stephane:
stephane is not in the sudoers file. This incident will be reported.

During boot, press and hold the left Shift key, and you should see the GRUB menu.
Select the entry containing (recovery mode) and wait.
You should now be presented with a menu. Select:
remount Remount / read/write and mount all other file systems

If this option doesn't appear or won't work, you can instead choose the root option and use the following command to mount the system partition:


mount -o remount /

or

mount -o rw,remount /

After applying this variation, adding a user to the admin (11.10 and ealrier) or sudo (12.04 and later) group is done like:
adduser username admin # 11.10 and earlier
adduser...

0 0
2

I know the threads How do I add myself back as a sudo user?, Mounting encrypted LUKS partition from Live CD, … This thread is about how to add a sudo user back without root and other strict security policies in place in encrypted environment: whole-media encryption, home-folder encryption and empty-space overwrite, but you know the password of the encryption. Still, the mounting of such an encrypted device is not that straight-forward. This is not duplicate!

My whole disk is encrypted. It contains Ubuntu 16.04.
I know the thread How do I add myself back as a sudo user? but it is not for whole disk encryption.
I did sudo usermod -G staff masi by accident (missed option -a there) and logged out.
It removed me from all other groups than staff.
To get back to defaults, I should run

sudo usermod -a -G adm cdrom sudo dip plugdev lpadmin sambashare masi

However, I am not anymore a part of sudo group, so I cannot run it.
You cannot go Ubuntu’s Grub >...

0 0
3


Question:

I clean-installed Ubuntu 11.10 today, and then installed VirtualBox. This required me to add myself to the vboxusers group, and since 11.10 seems to no longer have a graphical app to add users to a group, I ran the following command:

sudo usermod -G vboxusers stephane

This is a problem. I now see what I should have run instead is:

sudo usermod -aG vboxusers stephane

The end result is I'm no longer in the groups I should be in. Including whatever group is required to run "sudo". When I run any command as sudo now, I get the following:

$ sudo ls [sudo] password for stephane: stephane is not in the sudoers file. This incident will be reported.

Is there a way to fix this, or do I need to re-install from scratch again?


Solution:1

During boot, press and hold the left Shift key, and you should see the GRUB menu.

Select the entry containing (recovery mode) and wait.

You should now be...

0 0
4

I clean-installed Ubuntu 11.10 today, and then installed VirtualBox. This required me to add myself to the vboxusers group, and since 11.10 seems to no longer have a graphical app to add users to a group, I ran the following command:

sudo usermod -G vboxusers stephane

This is a problem. I now see what I should have run instead is:

sudo usermod -aG vboxusers stephane

The end result is I'm no longer in the groups I should be in. Including whatever group is required to run "sudo". When I run any command as sudo now, I get the following:

$ sudo ls [sudo] password for stephane: stephane is not in the sudoers file. This incident will be reported.

Is there a way to fix this, or do I need to re-install from scratch again?

During boot, press and hold the left Shift key, and you should see the GRUB menu.

Select the entry containing (recovery mode) and wait.

You should now be presented with a menu. Select:

remount Remount / read/write and mount...
0 0
5

Command Syntax:

sudo adduser sudo

Change with your actual username. Above command creates a new user and add it in group named sudo. This group already have sudo privileges defined in /etc/sudoers files.

Example:

The following command will create a new user jack and add it to sudo group. If user already exist, it will simply add them to sudo group.

$ sudo adduser jack sudo

Add Existing User in sudo Group

You can also use the following command to add existing users to group sudo, where it will get full sudo privileges.

$ sudo usermod -aG sudo

Remove Existing User from sudo Group

The following command will remove user from group sudo. This will not remove user from system.

$ sudo gpasswd -d...
0 0
6

The sudo command is used to elevate your permissions for a single Linux command.

You can use the sudo command to run a command as any other user although it is commonly used to run a command as the root user.

Note: In Linux the root user is the same as an administrator

If you have multiple users on your computer then you probably don't want all of the users to be administrators because administrators can do things like install and uninstall software and change key system settings.

To show you an example of the sudo command in use open a terminal window and run the following command:

apt-get install cowsay

A fairly cryptic message will be returned:

E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

The key points to note are the words "Permission denied" and "Are you root?".

Now try the same command again but...

0 0
7

The /etc/sudoers file is as confusing as the termcap file, but start by

remembering one critical rule.

CRITICAL RULE:

ONLY edit the /etc/sudoers file using /etc/visudo. NEVER USE ANY OTHER
EDITOR!

LOOK at this URL:

http://www.gratisoft.us/sudo/sudo.html

A few notes:

/etc/sudoers - file

Since the sudoers file is parsed in a single pass, order is important. In
general, you should structure sudoers such that the Host_Alias, User_Alias,
and Cmnd_Alias specifications come first, followed by any Default_Entry
lines, and finally the Runas_Alias and user specifications. The basic rule
of thumb is you cannot reference an Alias that has not already been defined.

Below are example sudoers entries. Admittedly, some of these are a bit
contrived. First, we define our aliases:

User_Alias FULLTIMERS = millert, mikef, dowdy User_Alias PARTTIMERS
= bostley, jwfox,...

0 0
8

I am a trainee programmer and I have sometimes my head in the clouds..

My collegues were messing with my professional computer with ssh connections. One of them told me that the best way to prevent it was to secure my computer. In order to do this, I accidentally change the permissions on the /usr directory. What I did just for testing was :

sudo chmod 644 /usr

Now I can't use my computer anymore! I can't change the permission back since I am not sudo anymore. On my desktop all my applications shutdown. Is there a way to revert a chmod 644 on /usr?

There is some important work related stuff on this computer and my internship will probably be terminated if I can't recover the access to important files.

Please help...

0 0
9

Linux has a robust permissions system. This is a very good thing, as it enables a clear separation of roles among users, especially between the root user and your average user. Sometimes, though, you might want your average user to have some or all of root’s privileges. In Linux, this is accomplished with sudo.

Just How Would I Use sudo Anyway?

In most cases, one simply adds “sudo” in front of a command that needs root privileges. For example, a normal user (here called “example”) is not ordinarily able to restart services from the command line:

example@example.com [~]# /etc/init.d/httpd restart
/etc/init.d/httpd: line 15: ulimit: open files: cannot modify limit: Operation not permitted
/etc/init.d/httpd: line 16: ulimit: open files: cannot modify limit: Operation not permitted
/etc/init.d/httpd: line 17: ulimit: open files: cannot modify limit: Operation not permitted
httpd: Could not open configuration file...

0 0
10

kartheekmanthena2 wrote:

Hi Guys,

I have created a user and tried to make it as sudo. I have accessed /etc/sudoers file but it read-only file.

I have changed the basic file permissions on the file and added a user giving full permissions and saved the file. And I have logged in as user and tried to add a user but got error as /usr/sbin/useradd permission denied . Below are the syntaxes i have used

#useradd and # sudo useradd

can you please suggest me on this.

It is difficult to understand your issue.

Were you able to successfully create a user with "useradd"?

Are you trying to give this newly created user admin access via "sudo" ?

Or are you trying to create a new user via "sudo" ?

Are you using "visudo" to access /etc/sudoers ?

What file did you change permissions on? If it was /etc/sudoers, change it back.

If a normal has permission to run /usr/sbin/userad, that user should not be...

0 0
11
...
0 0
12

---January 13, 2005

You mignt want to have a look at what "Tidy for FreeBSD" has done to the title of the page, though, 'cos it don't look too tidy, to me!

---January 28, 2005

My fault.. been doing a lot of cleaning up with tidy, but apparently a little too quick and didn't check the errors closely enough.

--TonyLawrence

Fri Mar 25 05:07:33 2005: 233 anonymous

I find this article to be very useful as i always used to think whether is the principle sudo possible and now it became possible ...:). It wud be better if the Security part regarding environmental variables part is more elaborated.... Anyway, thanks for the article as it was useful for me, beginner...

Tue Mar 29 02:39:07 2005: 241 anonymous

Is it possible to specify the list of commands that are not allowed.

Tue Mar 29 10:02:16 2005: 243 TonyLawrence


Yes, it's POSSIBLE to say "these are the commands that you can't run", but it's not a good idea...

0 0