LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 02-28-2012, 11:01 PM   #1
ankgup87
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Rep: Reputation: Disabled
Question sudo giving permission denied on Linux


I have a RHEL 5 machine on which I'm trying to run sudo.

I have created a test-eng user and added it in the sudoers file. The sudoers file have the correct permissions 0440. The output of sudoers file is :

User_Alias FULLTIME=test-eng
FULLTIME ALL=(ALL) NOPASSWD: ALL

I have given the correct setuid permissions to sudo as well. But when i run sudo after logging in from the test-eng user I get permission denied. Have tried almost everything but it doesn't work.

/usr/bin/sudo: Permission denied.

Also the same thing worked for me on a 64 bit machine and this one is a 32 bit machine. So I'm wondering whether this might be a 32/64 bit issue. Please help.
 
Old 02-28-2012, 11:43 PM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
The error you report sounds like a basic file permission problem--that user "test-eng" is denied read permission, execute permission, or both for the sudo command.

So, what are the permissions on the actual sudo file? On my Ubuntu 10.04 system:
Code:
user@localhost$ ls -l `which sudo`
-rwsr-xr-x 2 root root 148024 2011-01-19 12:01 /usr/bin/sudo
 
Old 02-28-2012, 11:49 PM   #3
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 666

Rep: Reputation: 133Reputation: 133
what
Code:
ls -l /usr/bin/sudo
shows?
 
Old 02-29-2012, 12:03 AM   #4
ankgup87
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Dark_Helmet View Post
The error you report sounds like a basic file permission problem--that user "test-eng" is denied read permission, execute permission, or both for the sudo command.

So, what are the permissions on the actual sudo file? On my Ubuntu 10.04 system:
Code:
user@localhost$ ls -l `which sudo`
-rwsr-xr-x 2 root root 148024 2011-01-19 12:01 /usr/bin/sudo
ls -l sudo shows the following output

-r--r----- 1 root root 98840 Feb 29 13:25 sudo

---------- Post added 02-29-12 at 01:04 AM ----------

Quote:
Originally Posted by Valery Reznic View Post
what
Code:
ls -l /usr/bin/sudo
shows?
ls -l sudo shows the following output

-r--r----- 1 root root 98840 Feb 29 13:25 sudo
 
Old 02-29-2012, 12:07 AM   #5
ankgup87
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Dark_Helmet View Post
The error you report sounds like a basic file permission problem--that user "test-eng" is denied read permission, execute permission, or both for the sudo command.

So, what are the permissions on the actual sudo file? On my Ubuntu 10.04 system:
Code:
user@localhost$ ls -l `which sudo`
-rwsr-xr-x 2 root root 148024 2011-01-19 12:01 /usr/bin/sudo
One thing I notice is that "which sudo" is not giving the correct output:

/usr/bin/which: no sudo in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
 
Old 02-29-2012, 12:09 AM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by ankgup87
-r--r----- 1 root root 98840 Feb 29 13:25 sudo
The permissions do not allow anyone to execute the sudo program. That is not correct.

run this command (copy-paste it if necessary), as root:
Code:
chmod 4755 `which sudo`
Then try using sudo as the "test-eng" user again.

EDIT:
Quote:
Originally Posted by ankgup87
One thing I notice is that "which sudo" is not giving the correct output:

/usr/bin/which: no sudo in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
Then what directory contains sudo? Specifically. Give the full path to the file.

EDIT2:
Perhaps more appropriately, how did you install sudo? From a package manager, from a source code tarball, or some other option?

Last edited by Dark_Helmet; 02-29-2012 at 12:13 AM.
 
1 members found this post helpful.
Old 02-29-2012, 12:13 AM   #7
ankgup87
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Dark_Helmet View Post
The permissions do not allow anyone to execute the sudo program. That is not correct.

run this command (copy-paste it if necessary), as root:
Code:
chmod 4755 `which sudo`
Then try using sudo as the "test-eng" user again.

EDIT:

Then what directory contains sudo? Specifically. Give the full path to the file.
On changing the permissions to 4755, I'm getting the following error while running sudo from test-eng user:

/usr/bin/sudo: Exec format error. Wrong Architecture.

I think sudo has to have 4111 permissions to have the other users use root uid. This is what I read on some other posts.

EDIT:

I copied it from another machine on which it was working fine

EDIT2:
Currently sudo is in /usr/bin/sudo

I changed the permissions with the following command

chmod 4755 /usr/bin/sudo

Last edited by ankgup87; 02-29-2012 at 12:17 AM.
 
Old 02-29-2012, 12:22 AM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by ankgup87
I copied it from another machine on which it was working fine
No, no... don't do that Install it using the RHEL package manager. It's probably something like:
Code:
yum install sudo
Otherwise, download, compile, and install a source code version:
Sudo download page

Do not copy an executable from one machine to another unless the machines are identical. Even then, you probably would miss some support files (e.g. visudo which you must use to configure sudo properly).

Quote:
Originally Posted by ankgup87
I think sudo has to have 4111 permissions to have the other users use root uid.
You can change the permissions to whatever you like. All I will say is that the permissions I provided are the exact permissions on my sudo command for my Ubuntu box. My sudo works fine on that machine. RHEL might be different.

EDIT:
Quote:
Originally Posted by ankgup87
/usr/bin/sudo: Exec format error. Wrong Architecture.
That's a clear indication that the problem is an inconsistency between the source machine and the destination machine. It could be 32/64 bit incompatibility, it could be that one machine is Intel/AMD and the other is ARM/PowerPC, etc.

Last edited by Dark_Helmet; 02-29-2012 at 12:28 AM.
 
1 members found this post helpful.
Old 02-29-2012, 12:25 AM   #9
ozanbaba
Member
 
Registered: May 2003
Location: Tengiz
Distribution: Slackware64 14.1
Posts: 671

Rep: Reputation: 94
What does "file /usr/bin/sudo" says. Because "/usr/bin/sudo: Exec format error. Wrong Architecture." error points an architectural mismatch. (Like trying to run 64-bit sudo on 32-bit system).
 
Old 02-29-2012, 12:29 AM   #10
ankgup87
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ozanbaba View Post
What does "file /usr/bin/sudo" says. Because "/usr/bin/sudo: Exec format error. Wrong Architecture." error points an architectural mismatch. (Like trying to run 64-bit sudo on 32-bit system).
file /usr/bin/sudo says:


/usr/bin/sudo: setuid ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), for GNU/Linux 2.4.0, stripped

And this is a 32 bit machine. I think that is the problem. Right?
 
Old 02-29-2012, 12:30 AM   #11
ankgup87
LQ Newbie
 
Registered: Feb 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Smile

Quote:
Originally Posted by Dark_Helmet View Post
No, no... don't do that Install it using the RHEL package manager. It's probably something like:
Code:
yum install sudo
Otherwise, download, compile, and install a source code version:
Sudo download page

Do not copy an executable from one machine to another unless the machines are identical. Even then, you probably would miss some support files (e.g. visudo which you must use to configure sudo properly).


You can change the permissions to whatever you like. All I will say is that the permissions I provided are the exact permissions on my sudo command for my Ubuntu box. My sudo works fine on that machine. RHEL might be different.

EDIT:

That's a clear indication that the problem is an inconsistency between the source machine and the destination machine. It could be 32/64 bit incompatibility, it could be that one machine is Intel/AMD and the other is ARM/PowerPC, etc.
Thanks. I will try to install a fresh sudo and will update the results


EDIT:

I downloaded a new sudo for 32 bit and it worked.
I will make sure I don't copy it from another machine of a different configuration.
Thanks for your help Dark Helmet. Marking this thread as RESOLVED.

Last edited by ankgup87; 02-29-2012 at 12:45 AM.
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
su cvs is giving .bashrc permission denied error prasad_ark Linux - Software 1 07-02-2008 05:13 AM
sudo and >>: permission denied mcd Linux - Software 2 06-25-2008 03:30 PM
sudo - permission denied! yogaboy Linux - Newbie 5 12-28-2006 11:58 PM
sudo permission denied Swift&Smart Slackware 5 07-13-2006 01:05 AM
Uploading files using PHP giving Permission Denied error MatthewG Programming 4 05-27-2004 03:38 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration