LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-18-2012, 10:35 AM   #1
kedarp
Member
 
Registered: Jul 2012
Distribution: Ubuntu
Posts: 198
Blog Entries: 3

Rep: Reputation: 23
Problem with sudo


I changed the permissions of the sudoers file to
640 to write to the file.
But now I am unable to use the sudo command on my machine. Whenever I try to use sudo, I get the following o/p-
the permissions of sudoers file are 0640, should be 0440.
Please help.

Last edited by kedarp; 08-18-2012 at 11:27 PM.
 
Old 08-18-2012, 10:38 AM   #2
byannoni
Member
 
Registered: Aug 2012
Location: /home/byannoni
Distribution: Arch
Posts: 128

Rep: Reputation: 36
Do you have a live CD or USB? If so, you can chroot into your installation and change the permissions.
 
Old 08-18-2012, 10:53 AM   #3
Reokie
LQ Newbie
 
Registered: Aug 2012
Posts: 2

Rep: Reputation: Disabled
If you know the root password for your system, you can escalate to root via 'su -' and change permissions that way.

Otherwise, I think an easier solution would be for you to boot into the server via single-user-mode by passing the option to GRUB at start-up (google it), dropping you into the shell as root, and you can go on from there:
 
Old 08-18-2012, 11:09 AM   #4
byannoni
Member
 
Registered: Aug 2012
Location: /home/byannoni
Distribution: Arch
Posts: 128

Rep: Reputation: 36
Quote:
Originally Posted by Reokie View Post
boot into the server via single-user-mode by passing the option to GRUB at start-up
At the grub boot screen:
  1. Press e to edit an entry
  2. Select the line starting with the word kernel
  3. Press e to edit the line
  4. Append the number 1 to the end of the line
  5. Press the [Enter] key
  6. Press b to boot
 
Old 08-18-2012, 02:23 PM   #5
honeybadger
Member
 
Registered: Aug 2007
Location: India
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855

Rep: Reputation: Disabled
Log in as root (i.e username root).
 
Old 08-18-2012, 10:06 PM   #6
guyonearth
Member
 
Registered: Jun 2012
Location: USA
Distribution: Ubuntu
Posts: 424

Rep: Reputation: 83
You should always state what Linux version you are using. Different distros have different rules for root and sudo behavior.
 
Old 08-19-2012, 12:30 AM   #7
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
Quote:
Originally Posted by byannoni View Post
At the grub boot screen:
  1. Press e to edit an entry
  2. Select the line starting with the word kernel
  3. Press e to edit the line
  4. Append the number 1 to the end of the line
  5. Press the [Enter] key
  6. Press b to boot
You can skip all of that by selecting the recovery mode entry.

And to the OP, you should use visudo to edit your sudoers file.
 
Old 08-19-2012, 12:49 AM   #8
kedarp
Member
 
Registered: Jul 2012
Distribution: Ubuntu
Posts: 198

Original Poster
Blog Entries: 3

Rep: Reputation: 23
I am using Ubuntu 9.10. So I cannot login as root. There is no root account.
I also cannot su to root. I get "Authentication failure"

Quote:
At the grub boot screen:

1. Press e to edit an entry
2. Select the line starting with the word kernel
3. Press e to edit the line
4. Append the number 1 to the end of the line
5. Press the [Enter] key
6. Press b to boot
What happens? I see the login screen. I have to again login using my normal account.

Quote:
you should use visudo to edit your sudoers file
I checked the man page of visudo. visudo is for editing the sudoers file.
How can I change the permissions of the file to 0440.
 
Old 08-19-2012, 01:11 AM   #9
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
Quote:
Originally Posted by kedarp View Post
I am using Ubuntu 9.10. So I cannot login as root. There is no root account.
I also cannot su to root. I get "Authentication failure
There is ALWAYS a root account.

Quote:
Originally Posted by kedarp View Post
I checked the man page of visudo. visudo is for editing the sudoers file.
Isn't that what you wanted to do as you mentioned:
Quote:
I changed the permissions of the sudoers file to 640 to write to the file.
Why else would you want to write to the sudoer's file, if you did not intend to edit it?

Quote:
Originally Posted by kedarp View Post
How can I change the permissions of the file to 0440.
First, from the GRUB boot menu, there will be two entries for a specific kernel release. There's the first entry that boots directly into multi-user mode and directly beneath it, there's the recovery mode entry that boots into recovery mode or runlevel 1.

So for instance, if your kernel release is: 2.6.27.4, your GRUB menu will have:
Code:
Ubuntu, with Linux 2.6.27.4 on /dev/sda1
Ubuntu, with Linux 2.6.27.4 (recovery mode)
Select the second entry (recovery mode). This will automatically log you in as root and take you directly into the command-line. Note that Ubuntu does not set the root password by default, so entering runlevel 1 or recovery mode will never ask for root's passwords.

Now change the permission of your sudoer's file to 0440:
Code:
chmod 0440 /etc/sudoer
And reboot:
Code:
reboot
Hope this explains it a little better.
 
Old 08-19-2012, 09:18 AM   #10
byannoni
Member
 
Registered: Aug 2012
Location: /home/byannoni
Distribution: Arch
Posts: 128

Rep: Reputation: 36
Quote:
Originally Posted by towheedm View Post
You can skip all of that by selecting the recovery mode entry.
Oh, forgot about that. I'm used to having "fallback mode" instead.

Quote:
Originally Posted by kedarp View Post
What happens? I see the login screen. I have to again login using my normal account.
Is the login screen a virtual terminal or graphical?
 
Old 08-19-2012, 12:09 PM   #11
towheedm
Member
 
Registered: Sep 2011
Location: Trinidad & Tobago
Distribution: Debian Stretch
Posts: 612

Rep: Reputation: 125Reputation: 125
Quote:
Originally Posted by byannoni View Post
Oh, forgot about that. I'm used to having "fallback mode" instead.
Fallback and recovery modes are just different names for the same thing. They both start the sytem in single-user mode or runlevel 1.
 
Old 08-19-2012, 01:20 PM   #12
byannoni
Member
 
Registered: Aug 2012
Location: /home/byannoni
Distribution: Arch
Posts: 128

Rep: Reputation: 36
Quote:
Originally Posted by towheedm View Post
Fallback and recovery modes are just different names for the same thing. They both start the sytem in single-user mode or runlevel 1.
On Arch, fallback just uses a different ramfs image. It doesn't change the runlevel.
 
Old 08-19-2012, 02:55 PM   #13
TKH
Member
 
Registered: Jul 2011
Location: Milky Way
Distribution: Ubuntu, LFS, Slackware, Fedora
Posts: 223

Rep: Reputation: 20
Login as root and run "chmod 0440 /etc/sudoers"
 
Old 08-19-2012, 07:05 PM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,415

Rep: Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785Reputation: 2785
Quote:
There is ALWAYS a root account.
True, but the default install of Ubuntu is to disable it and automatically give the first registered user full rights via sudo instead... sigh ..
 
Old 08-20-2012, 01:16 AM   #15
kedarp
Member
 
Registered: Jul 2012
Distribution: Ubuntu
Posts: 198

Original Poster
Blog Entries: 3

Rep: Reputation: 23
I did it from the recovery mode. Could change the permissions of the sudoers file as root.
But isn't it unsecure to get the access to root account from the recovery mode without a password?
But Thanks all for the help.
 
  


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
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
Problem with SUDO : sudo: pam_authenticate: Module is unknown cristoph_ Linux - Software 2 03-02-2009 08:12 PM
Slackware 12.0: boot problem & sudo / wifi-radar problem War_Ensemble Slackware 7 01-15-2008 10:49 AM
Restricting Editing in Sudo (Advanced Sudo Question) LinuxGeek Linux - Software 4 11-04-2006 04:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:34 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
Open Source Consulting | Domain Registration