sudo don't work with any command

Hello all, i’m new to opensuse and i’m having some problems starting with it.

When i try to run some commands with sudo (visudo, modinfo, nstat…) it always says me “command not found” and i don’t know whats happen. I think my sudoers file is right.

And i don’t know if it is related, but i can’t mount any ntfs drive i have. It says me that i have to review the permissions configuration.

Any one have any idea about what can i do to fix this? I’ve found this and this post here, but none of these help me.

This is my sudoers file:

sudoers file.

This file MUST be edited with the ‘visudo’ command as root.

Failure to use ‘visudo’ may result in syntax or file permission errors

that prevent sudo from running.

See the sudoers man page for the details on how to write a sudoers file.

Host alias specification

User alias specification

Cmnd alias specification

Defaults specification

Prevent environment variables from influencing programs in an

unexpected or harmful way (CVE-2005-2959, CVE-2005-4158, CVE-2006-0151)

Defaults always_set_home
Defaults env_reset

Change env_reset to !env_reset in previous line to keep all environment variables

Following list will no longer be necessary after this change

Defaults env_keep = "LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER Defaults env_keep = “LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE”

Comment out the preceding line and uncomment the following one if you need

to use special input methods. This may allow users to compromise the root

account if they are allowed to run commands without authentication.

#Defaults env_keep = “LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS XDG_SESSION_COOKIE XMODIFIERS GTK_IM_MODULE QT_IM_MODULE QT_IM_SWITCHER”

In the default (unconfigured) configuration, sudo asks for the root password.

This allows use of an ordinary user account for administration of a freshly

installed system. When configuring sudo, delete the two

following lines:

#Defaults targetpw
#Runas_Alias ROOT = root

Runas alias specification

User privilege specification

ALL ALL = (ALL) ALL
root ALL = (ALL) ALL
myusername ALL = (ALL) ALL

Try sudo -i command

Hi there,

for the first user you set up via the installation dialog sudo definitly should work,
could you please post such an sudo dialog you do, i mean the whole terminal dialog like:

johest@linux-ahw9:~> sudo python --version
root’s password:
Python 2.6.5
johest@linux-ahw9:~>

Hi,

It may be that the commands you are trying to run are not in your $PATH.
From your /etc/sudoers, it is obvious that you have modified it a great
deal, any reason why?

From what I can tell you have said anyone can use sudo with their own
password; possibly a slight security risk.
As you have ‘ALL ALL=(ALL) ALL’, ‘myusername ALL=(ALL) ALL’ isn’t
doing anything.

I would uncomment ‘Defaults targetpw’
and comment out ‘myusername ALL=(ALL) ALL’
Then check if it is simply a $PATH issue.

Regards,
Barry.

On 07/22/2010 04:59 PM, Barry Nichols wrote:
> Hi,
>
> It may be that the commands you are trying to run are not in your $PATH.
> From your /etc/sudoers, it is obvious that you have modified it a great
> deal, any reason why?
>
> From what I can tell you have said anyone can use sudo with their own
> password; possibly a slight security risk.
> As you have ‘ALL ALL=(ALL) ALL’, ‘myusername ALL=(ALL) ALL’ isn’t
> doing anything.
>
> I would uncomment ‘Defaults targetpw’
> and comment out ‘myusername ALL=(ALL) ALL’
> Then check if it is simply a $PATH issue.

On openSUSE, an unprivileged user does not have /sbin or /usr/sbin in their path
for reasons of security. Thus you need to do “sudo /sbin/modprobe”, etc.

Hello all and thanks for the answers.

ken_yap: when i use sudo -i command it works…

johest: this is my terminal dialog with this command:

myusername@viskovitz:~> sudo python --version
myusername’s password:
Python 2.6.5
myusername@viskovitz:~>

Barry_Nichols: the changes in sudoers are tests trying to fix the problem. If I restore it uncommenting “Defaults targetpw” and commenting out “myusername ALL=(ALL) ALL” I still have the same message:

myusername@viskovitz:~> sudo visudo
root’s password:
sudo: visudo: command not found
myusername@viskovitz:~>

Any idea…?

The difference I see between mine and yours:

#Defaults targetpw
# ALL ALL = (ALL) ALL

Runas_Alias ROOT = root

Runas alias specification

User privilege specification

root ALL = (ALL) ALL
myusername ALL = (ALL) ALL

Hello, I tried that tararpharazon, but it didn’t work…

Maybe it is a clue, but my path is:

myusername@viskovitz:~$ echo $PATH
/home/raul/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib64/jvm/jre/bin
myusername@viskovitz:~$

and if I add ‘/usr/sbin’ and ‘/sbin’ to the path sudo works fine and when I try to run any of the commands in these folders (without sudo) it ask me for superuser privileges:

myusername@viskovitz:~> modinfo
Absolute path to ‘modinfo’ is ‘/sbin/modinfo’, so running it may require superuser privileges (eg. root).
myusername@viskovitz:~>

My question is if is safe to do this in the path of a normal user?

Hi,

As you mentioned sudo -i <command> works, what’s the problem?

Regards,
Barry

Those programs will not let you do root operations if you are not really root. Unix/Linux is not that flimsy to rely on “hiding” programs in directories so that normal users won’t “find” them. However some of them are still useful to non-root users, e.g. modinfo can still show normal users information about a module, ifconfig can show normal users details about network interfaces. So the only danger really is yourself, do you trust yourself not to accidentally run a program as root under sudo and change something you didn’t intend to?

[/QUOTE]
As you mentioned sudo -i <command> works, what’s the problem?
[/QUOTE]

So (someone please correct me if iam wrong),
well, waht suso only does is executing a script/programm as the super user, it does not change your path to the programms only root should use (such as /usr/sbin/visudo), while sudo with the -i option makes you root, so it does something like the same su does before, it makes you roote, i think the -s option should work the same way. So with this -i (interactive i guess) option you first become root and than executes a script.

I agree with ken_yap, there’s a number of commands hidden behind /usr/sbin/ and /sbin/ usually not available to normal users for security reasons.

AFAIK an inheritance from the UNIX multiuser operating system the original model for the Linux operating system. Original UNIX had a Root administering for all user accounts, etc. Linux Desktop tends to be more single user system with less emphasis on root administrators, server and multiuser systems excluded. With desktop Linux, anyone accessing your PC, has access to root commands in /sbin/ and /usr/sbin/ because these are in your path.

AFAIK, unless you are root, use “su”, “su -l”, “su -c command” or “sudo command” you shouldn’t be allowed to execute commands in /sbin/ or /usr/sbin/.
I’m fairly sure, that’s why you saw the message

myusername@viskovitz:~> modinfo
Absolute path to 'modinfo' is '/sbin/modinfo', so running it may require superuser privileges (eg. root).
myusername@viskovitz:~>

In that same message it’s telling you the path to the command was /sbin/modinfo

I code /sbin/ and /usr/sbin/ in my userid path statement.

Ok, I think I understand your explanations. I’ll try to work this way in a time, (with /usr/sbin and /sbib out of my userid path). I come from ubuntu and I’ve work in other way before…

Thank you everyone for your help.

For some commands that may be useful for a normal to run without needing root privilege, e.g. ifconfig and modinfo, what I do is symlink it to my ~/bin and then it’s available to me without sudo.

So just because the command not found message says that a command is in /usr/sbin and may require root permission to run, doesn’t mean it has to be run as root. You can just run it without root privilege.