LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Sudo Problem (https://www.linuxquestions.org/questions/linux-general-1/sudo-problem-507766/)

Mithic 12-05-2006 06:52 PM

Sudo Problem
 
I uncommented
Code:

%wheel        ALL=(ALL)        ALL
in the sudoers file and added my user to the "wheel" group and when i try
Code:

sudo dhcpcd eth1
it says
Code:

sudo: /etc/sudoers is mode 0644, should be 0440
What should i do to fix that?

matthewg42 12-05-2006 07:00 PM

How did you edit the file? The proper way is with the visudo command. Editing this file manually is not a good idea. If you don't like the editor which visudo uses, you can set the EDITOR environment variable. For example, if it uses vi, and you like nano, you might enter this command (as root):
Code:

# EDITOR=nano visudo
You can fix the sudoers file permissions like this:
Code:

# chmod 440 /etc/sudoers

Mithic 12-05-2006 07:14 PM

Quote:

Originally Posted by matthewg42
How did you edit the file?

I logged in as root and edited it with kwrite.
I tried what you said,
Code:

# chmod 440 /etc/sudoers
and when i try to do a command (i.e)
Code:

$ sudo "modprobe psmouse"
sudo: modprobe psmouse: command not found
$


matthewg42 12-05-2006 07:34 PM

Quote:

Originally Posted by Mithic
I logged in as root and edited it with kwrite.
I tried what you said,
Code:

# chmod 440 /etc/sudoers
and when i try to do a command (i.e)
Code:

$ sudo "modprobe psmouse"
sudo: modprobe psmouse: command not found
$


Now sudo appears to be functioning correctly, but your modprobe command is failing. To verify sudo's success, sudo a command which should surely succeed:
Code:

sudo echo hello world ; echo $?
If you see 0 after the hello world, sudo if fixed.

As for the psmouse module, my debian install has this built into the kernel - it is not a loadable module. You can check if this is the case with your installation with this command:
Code:

grep PSMOUSE /boot/config*
If you see "CONFIG_PSMOUSE=y", PSMOUSE is built into the kernel, not a module.

Mithic 12-05-2006 07:46 PM

Quote:

Originally Posted by matthewg42
To verify sudo's success, sudo a command which should surely succeed:
Code:

sudo echo hello world ; echo $?
If you see 0 after the hello world, sudo if fixed.

I tried that and it worked.

Quote:

As for the psmouse module, my debian install has this built into the kernel - it is not a loadable module. You can check if this is the case with your installation with this command:
Code:

grep PSMOUSE /boot/config*
If you see "CONFIG_PSMOUSE=y", PSMOUSE is built into the kernel, not a module.
The "CONFIG_PSMOUSE=y" came up, when i did that.

I run "modprobe psmouse" all the time as root so that my touchpad works and it does work as root.

matthewg42 12-05-2006 07:54 PM

Quote:

Originally Posted by Mithic
I run "modprobe psmouse" all the time as root so that my touchpad works and it does work as root.

And it works as root? On this machine? In the same installation of debain? In my debian installation typing modprobe psmouse as root gives the same error message as you see when you run it with sudo. I can think of no reason why it would work as root, but not with sudo.

Mithic 12-05-2006 08:00 PM

Quote:

Originally Posted by matthewg42
And it works as root? On this machine? In the same installation of debain?

I'm running Slackware 11.

zetabill 12-05-2006 08:09 PM

Try:
Code:

sudo /sbin/modprobe psmouse
Sudo works in the user's environment by default, so if /sbin isn't in your user's $PATH then sudo won't be able to find it even though it's executing the program with root priviledges. I've run into this problem before and this should hopefully be your fix.

Mithic 12-05-2006 08:21 PM

Quote:

Originally Posted by zetabill
Try:
Code:

sudo /sbin/modprobe psmouse
Sudo works in the user's environment by default, so if /sbin isn't in your user's $PATH then sudo won't be able to find it even though it's executing the program with root priviledges. I've run into this problem before and this should hopefully be your fix.

That worked, now my question is how do i add /sbin to my $PATH?
I'm pretty new to slackware and still dont know what that is exactly.
And thanks alot for the help, both of you.

matthewg42 12-05-2006 09:43 PM

Quote:

Originally Posted by Mithic
I'm running Slackware 11.

I beg your pardon. I think I must have been cross posting in my mind Too many threads, too few braincells. :)

sn68 12-05-2006 10:30 PM

Quote:

Originally Posted by Mithic
That worked, now my question is how do i add /sbin to my $PATH?
I'm pretty new to slackware and still dont know what that is exactly.
And thanks alot for the help, both of you.

Add following line to .bashrc
PATH = $PATH:/sbin

to edit .bashrc open terminal in home directory
>gedit .bashrc

matthewg42 12-05-2006 10:47 PM

It should be
Code:

export PATH="$PATH:/sbin:/usr/sbin"
Note that you should not have any relative paths in your path, the most commonly found one is "." - the current working directory. This is security risk - if some program creates a file which has the same name as a utility which is often run as root in the current directory, you don't want a risk to run it accidentally. Now you are doing admin stuff from this user, you should check your PATH is safe.

sn68 12-05-2006 10:57 PM

Amended (thanks matthewg42)

Add following line to .bashrc
PATH = $PATH:/sbin
export PATH

matthewg42 12-05-2006 11:09 PM

Quote:

Originally Posted by sn68
Amended (thanks matthewg42)

Add following line to .bashrc
PATH = $PATH:/sbin
export PATH

This is something I've seen many times - setting PATH first, then exporting it. Is there some advantage to doing this over having it all in one command, "export PATH=..."?

Mithic 12-05-2006 11:14 PM

It says .bashrc doesnt exist.

matthewg42 12-05-2006 11:20 PM

Ah, one thing - are you using bash? do
Code:

echo $SHELL
to find out.

Mithic 12-05-2006 11:33 PM

Yes, it says im using bash.

matthewg42 12-05-2006 11:37 PM

You can just create the .bashrc file in your home directory then. You could just edit it, or this command will create it:
Code:

echo 'export PATH="$PATH:/sbin:/usr/sbin"' >> ~/.bashrc

Mithic 12-06-2006 12:23 AM

Quote:

Originally Posted by matthewg42
You can just create the .bashrc file in your home directory then. You could just edit it, or this command will create it:
Code:

echo 'export PATH="$PATH:/sbin:/usr/sbin"' >> ~/.bashrc

I did this and didnt get any complaints. However, it still does the samething.
Code:

$ sudo dhcpcd eth1 
sudo: dhcpcd: command not found
$ sudo /sbin/dhcpcd eth1
$


sn68 12-06-2006 03:01 AM

After creating .bashrc, exit terminal and open a new terminal and try
If it doesn't work, do ctrl H in home directory and see if .bash_profile is there
if it is there, put the same code there & retry opening a new terminal

nx5000 12-06-2006 04:40 AM

This has nothing to do in bashrc, it has to be in a profile file
~/.profile
~/.bash_profile
/etc/profile

man bash for explanation

matthewg42 12-06-2006 08:16 AM

Quote:

Originally Posted by sn68
After creating .bashrc, exit terminal and open a new terminal and try
If it doesn't work, do ctrl H in home directory and see if .bash_profile is there
if it is there, put the same code there & retry opening a new terminal

You're creating it in your $HOME directory? It certainly should get used. From the bash manual page:
Quote:

~/.bashrc
The individual per-interactive-shell startup file
nx5000 is sort of right though, ~/.bash_profile is probably a better place to put it, although it you put it there, to see the change you'll have to log out of X (to GUI login screen) and back in, or if you use startx, log out of X, log out of console and then log in again. This is because the .bash_profile is only read on the initial login shell.

Mithic 12-06-2006 12:10 PM

There wasnt a .bash_profile so i created one and added that code and now it works great. Thanks alot for all the help everyone, I really appreciate it.


All times are GMT -5. The time now is 06:46 AM.