LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-10-2012, 01:18 AM   #1
scandalist
Member
 
Registered: Apr 2011
Posts: 31

Rep: Reputation: 1
Messed up sudo in Ubuntu


Greetings,

I just installed Ubuntu on an old laptop and began the process of creating a user account for me and my girlfriend. Apparently Ubuntu doesn't come with a root password and ships instead with one standard account with sudo privileges.

I needed sudo privileges for my account as well so I edited /etc/group and added my username to the admin group. I fudged the line and left out the trailing colon that should be at the end of the entries - This has rendered the system useless when trying to do anything privileged because neither accounts have access to sudo anymore...lol.

Is there a way to fix this?? Thank you!
 
Old 05-10-2012, 01:38 AM   #2
yars
Member
 
Registered: Apr 2012
Location: Russia
Distribution: Slackware64-current
Posts: 241

Rep: Reputation: 24
Hi, I think it is following steps:
Boot any LiveCD/DVD/FlashDrive, then:
Code:
# mkdir -pv /mnt/ubuntu
# mount /dev/sda5 /mnt/ubuntu
# nano /mnt/ubuntu/etc/group
# nano /mnt/ubuntu/etc/sudoers
Where are /dev/sda5 is a partition with your rootfs.
 
Old 05-10-2012, 06:45 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,131
Blog Entries: 2

Rep: Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833
Like yars said. For future use, if you use commands like usermod and visudo you don't have to edit the configuration files manually and can't mess up the system with typos.
 
Old 05-10-2012, 07:08 AM   #4
TroN-0074
Senior Member
 
Registered: Dec 2011
Location: Michigan USA
Distribution: OpenSUSE 13.2 64bit-Gnome on ASUS U52F
Posts: 1,444

Rep: Reputation: 340Reputation: 340Reputation: 340Reputation: 340
you can type a combinations of commands and that would work too.
something like
Code:
sudo su
Or you can use the users and group tool on the GUI

Good luck to you!
 
Old 05-10-2012, 09:35 AM   #5
yars
Member
 
Registered: Apr 2012
Location: Russia
Distribution: Slackware64-current
Posts: 241

Rep: Reputation: 24
Quote:
Originally Posted by TobiSGD View Post
Like yars said. For future use, if you use commands like usermod and visudo you don't have to edit the configuration files manually and can't mess up the system with typos.
+1. In addition, it is as far as I know, blocking access to files at the time of your experiences with them, that positively affects your safety.
 
Old 05-10-2012, 05:15 PM   #6
Erfankam
Member
 
Registered: Jun 2011
Location: Tehran, Islamic Repulic of, Iran
Distribution: Ubuntu, Arch, Suse
Posts: 32

Rep: Reputation: 13
Yah. You are right. By default, your account has not sufficient privilege to execute administrative command like that.
In first step we can activate root account by setting up a password:
Code:
sudo passwd root
If you cant do this, we can edit suduers file at "sudo vi /etc/sudoers" location:
Code:
<your_username>    ALL=(ALL:ALL) ALL
after adding this line and save file,
again execute this:
Code:
sudo passwd root
after setting password up, you can use su to login as a root user to do what you would.
If not, Just add your username like up to sudoers file to be able execute any command(ALL) by sudo in your normal user.

Last edited by Erfankam; 05-10-2012 at 05:45 PM.
 
Old 05-10-2012, 05:59 PM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,131
Blog Entries: 2

Rep: Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833
Quote:
Originally Posted by Erfankam View Post
Yah. You are right. By default, your account has not sufficient privilege to execute administrative command like that.
In first step we can activate root account by setting up a password:
Code:
sudo passwd root
If you cant do this, we can edit suduers file at "sudo vi /etc/sudoers" location:
Code:
<your_username>    ALL=(ALL:ALL) ALL
If the user can't run sudo su the he will also not be able to run sudo vi, which is by the way not the recommended way to edit /etc/sudoers, the recommended way is to use visudo.
 
Old 05-10-2012, 06:11 PM   #8
Erfankam
Member
 
Registered: Jun 2011
Location: Tehran, Islamic Repulic of, Iran
Distribution: Ubuntu, Arch, Suse
Posts: 32

Rep: Reputation: 13
Cool

Quote:
Originally Posted by TobiSGD View Post
If the user can't run sudo su the he will also not be able to run sudo vi, which is by the way not the recommended way to edit /etc/sudoers, the recommended way is to use visudo.
TobiSGD, Thanks for your notation.
Yah, But sometimes just some of commands in sudoers file is restricted. I think one of them was passwd.
Ok, If Tobi is right and you dont have any access to sudo commands, use a live distro to boot up and edit sudoers file by that to add all commands to it like up.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Ultimate Sudo FAQ To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 02:36 AM
Ubuntu 10.11 sound messed up? way3000 Linux - Newbie 3 10-21-2011 09:51 PM
[SOLVED] Fedora messed up Ubuntu vedi Linux - Newbie 5 07-10-2011 01:32 PM
Can't use sudo, only account that's not root is not a sudo'ers [Ubuntu 9.10] randyriver10 Linux - Desktop 1 01-09-2010 08:56 PM
aftr sudo cmd and pswd i get this E: Type 'http://archive.ubuntu.com/ubuntu' is not k turoblaztr Linux - General 1 01-14-2007 11:29 AM


All times are GMT -5. The time now is 08:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration