The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   sudo: command not found (http://hintsforums.macworld.com/showthread.php?t=20781)

tas 02-16-2004 06:55 AM

sudo: command not found
 
I just set up my wife's computer (PB G4 12" running 10.3.2). She switched from Windoze, so I'm very anxious for everything to work. There's one hitch that I can't figure out: running ANY command in Terminal with sudo will produce a "command not found" error. All commands will work as expected when I give the full path, and all commands work when logged in as a normal user. Must be an environment thing, I suppose, but where do I set it? I'm not aware of having done anything differently from my G5 where this work normally. Pleaze help, this is about peace in our marriage...

yellow 02-16-2004 07:57 AM

Which shell: bash or tcsh? Sounds like your paths are misconfigured.

tas 02-16-2004 08:26 AM

zsh, in fact. But even if I switch to bash, I get the same result. But that's my problem: how can paths be different when I do "sudo something" instead of "something"?

hayne 02-16-2004 09:11 AM

Maybe it is the 'sudo' command that is not being found?
What do you get from the command:

which sudo

(It should give: /usr/bin/sudo)

Show us the results of the following command:

echo $PATH

tas 02-16-2004 09:31 AM

No, sudo is found (since, e.g., sudo /usr/local/bin/rsync works, while sudo rsync doesn't). Here's the output:
Code:

% which sudo
/usr/bin/sudo
% echo $PATH
/sw/bin:/sw/sbin:/Users/bzm/bin:/usr/local/bin:/Developer/Tools:/usr/bin:/bin:/usr/sbin:/sbin
% sudo -s
# echo $PATH
/Users/bzm/bin:/usr/local/bin:/Developer/Tools:/usr/bin:/bin

So I see that for a shell invoked with sudo the PATH isn't quite the same (because it's a bash shell?), but still, /usr/local/bin is in the path, so rsync should be found. Clueless...

yellow 02-16-2004 09:56 AM

I think that's why.. your fink directories are first.. They should be last. Something along the lines of:
Code:

yellow% echo $PATH
/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/tripwire/bin:/sw/bin:/sw/sbin:/usr/X11R6/bin


hayne 02-16-2004 10:03 AM

zsh seems to have the 'rehash' builtin command, so maybe you need to use it - did you add the rsync command to the /usr/local/bin directory after you started the shell?

And you started off by saying that you had a problem with "ANY" command - is that true or is it only certain commands?
E.g. can you do:
sudo ls
?

sao 02-16-2004 10:09 AM

Quote:

yellow wrote:
your fink directories are first.. They should be last.
Not necessarily. I have them first and have no problems with sudo. Note that /usr/bin comes inmediately after /sw/bin and /sw/sbin. I'm also using zsh.
Code:

[pm @ Sao: ~] % echo $PATH
/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/pm:/Users/pm/bin:
/usr/X11R6/bin:/Developer/Tools


tas 02-16-2004 10:13 AM

Nope, I tried appending the paths, that doesn't change the behavior:
Code:

% echo $PATH
/Users/bzm/bin:/usr/local/bin:/Developer/Tools:/usr/bin:/bin:/usr/sbin:/sbin:/sw/bin:/sw/sbin
% sudo rsync -V
sudo: rsync: command not found

(And isn't sw supposed to be first in your path so the fink-installed tools like tar, gzip, ls etc. will replace the vanilla versions that come with Panther?)

tas 02-16-2004 10:15 AM

Sorry, yellow, missed your last post (and thanks, btw, i appreciate your efforts). Yes, NO command works with sudo, not even ls or anything.

sao 02-16-2004 10:16 AM

tas,

In my ~/.zshrc I have:
Code:

#
## ~/.zshrc
##

#print ~/.zshrc

## add ~/bin to path
path=($path ~/bin)

## fink init file
[ -f /sw/bin/init.sh ] && source /sw/bin/init.sh

## Add display env var
export DISPLAY=:0.0

## add Developer Tools to path
path=($path /Developer/Tools)
               
## Get rid of dups in paths
typeset -U path cdpath manpath fpath
               
## cd : dirs in home and one dir up
#cdpath=(~ ..)
.........................
etc.etc.etc.
.........................


tas 02-16-2004 10:18 AM

Sorry, yellow, missed your last post (and thanks, btw, i appreciate your efforts). Yes, NO command works with sudo, not even ls or anything.

Edit: Arrgh, that was hayne's post. Excuse me, but I'm grateful to both of you.

blb 02-16-2004 04:42 PM

What is the result of
Code:

sudo /usr/bin/env |grep PATH
that way we can find out what path is being used in sudo.

tas 02-16-2004 05:03 PM

Code:

% sudo /usr/bin/env | grep PATH
MANPATH=/sw/share/man:/Users/bzm/man:/usr/share/man:/usr/local/man:/usr/local/share/man:/usr/local/teTeX/man
INFOPATH=/sw/share/info:/sw/info:/usr/share/info
PATH=/usr/bin:/bin

Why is the path in sudo so truncated? I have no idea. And what's most bizarre: even commands in /usr/bin and /bin don't work:
Code:

% sudo ls
sudo: ls: command not found

Will I have to reinstall? Would be horrible. Maybe I could do it while my wife's away and hope everything will be smooth, so she won't realize...

blb 02-16-2004 05:06 PM

Is SECURE_PATH set in your environment?

tas 02-16-2004 05:08 PM

I don't think so, echo $SECURE_PATH returns a blank line.

blb 02-16-2004 05:13 PM

It was a shot in the dark, based on the manpage text
Code:

        PATH                  Set to a sane value if SECURE_PATH is set
Are there any lines in /etc/sudoers besides comments and the default
Code:

root    ALL=(ALL) ALL
%admin  ALL=(ALL) ALL

?

hayne 02-16-2004 05:14 PM

Please show us the lines in your "dot" files that set up the PATH.

tas 02-16-2004 05:27 PM

No, nothing in /etc/sudoers besides the standard lines. As for my dot-files: I have .zprofile, which contains
Code:

source /sw/bin/init.sh
Then we have .zshenv, which contains
Code:

typeset -U path
path=(~/bin /usr/local/bin /Developer/Tools $path)
typeset -U manpath
manpath=(~/man /usr/share/man /usr/local/man /usr/local/share/man /usr/local/teTeX/man $manpath)
export LC_ALL=C

And finally, there's .zshrc, which contains just my aliases and points to the HISTFILE.

hayne 02-16-2004 10:08 PM

One possibility is that the permissions on the standard directories are screwed up.
What do you get from:

ls -ld /bin

(It should be something like:
drwxr-xr-x 35 root wheel 1190 15 Nov 01:21 /bin )

And what do you get from:

id

(It should show that user as belonging to the group 'admin' among others)

sao 02-17-2004 12:56 AM

tas,

--Did you by chance deselect the "BSD Subsystem" item of the custom install screen when installing OS X?

--It could also be permission problems or your shell startup scripts are not configured correctly.

Please, what gives:

echo $SHELL
echo $0



PS: If you missed installing the BSD Subsystem, just insert your Panther CD and find the Welcome to Mac OS X/Optional Installs/BSD Subsystem file and double-click it.

tas 02-17-2004 04:14 AM

Hayne: here's what I get:
Code:

% ls -ld /bin
drwxr-xr-x  35 root  wheel  1190 15 Nov 07:21 /bin
% id
uid=501(bzm) gid=501(bzm) groups=501(bzm), 79(appserverusr), 80(admin), 81(appserveradm)

Everything looks correct, right.

Sao: if I had forgotten to install the BSD subsystem, the commands wouldn't work at all. Everything works fine, except under sudo.
Code:

% echo $SHELL
/bin/zsh
% echo $0
-zsh


hayne 02-17-2004 10:24 AM

I'm running out of ideas.
I would suggest re-installing 'sudo' and associated files by using the third-party "Pacifist" utility to extract them from the Install CD.

The only other idea I have is to try making a fresh new user account, leaving this account with the default shell (bash), make this account be an administrator as well, then see if sudo works with this new account.

yellow 02-17-2004 10:27 AM

Possibly mine is a hold-over from Jaguar?
Code:

yellow% id
uid=501(yellow) gid=80(admin) groups=80(admin), 0(wheel)


tas 02-17-2004 10:43 AM

Hayne, I thought of something similar. i just copied over the version of "sudo" from my G5 (where it works) to the Powerbook, but nada. Do you have any idea what the "associated files" would be?

hayne 02-17-2004 11:02 AM

tas: The only associated file I know of is the sudoers file. But do try creating a new user as I suggested above - that is more likely to lead us to a solution.

yellow: Yes, I think your user account is the same as it was under Jaguar since you kept your users when you installed Panther. If you do a fresh install or if you create a new user, it will get the new Panther features.

sao 02-17-2004 11:25 AM

Code:

[pm @ Sao: ~] % grepbom sudo
...................../private/etc/pam.d/sudo    281    Sat Sep 13 08:06:12 2003
./private/etc/sudoers  341    Sat Sep 13 12:29:01 2003
./usr/bin/sudo  96,540  Wed Sep 24 14:48:17 2003
./usr/sbin/visudo      69,592  Wed Sep 24 14:48:17 2003
./usr/share/man/man5/sudoers.5  45,390  Sat Sep 13 12:29:02 2003
./usr/share/man/man8/sudo.8    19,387  Sat Sep 13 12:29:01 2003
./usr/share/man/man8/visudo.8  10,001  Sat Sep 13 12:29:02 2003
./usr/share/zsh/4.1.1/functions/_sudo  650    Sat Sep 13 09:51:06 2003
  ====> /Library/Receipts/Essentials.pkg/Contents/Archive.bom


...................................................................


tas 02-17-2004 12:16 PM

OK, problem solved. And thanks to everybody, you were amazingly helpful!! Hayne, you were right, I should have done that right away. I created a new user, and lo and behold: sudo worked. I then moved all my .z-files to another directory and copied them back in one by one. The offending party was .zshenv. I had copied it over from my own computer and forgotten that it contained a reference to the teTeX manpath that isn't installed on my wife's computer. Apparently, zsh choked on it to such an extent that sudo wouldn't work. As soon as I deleted the line about manpath, it worked normally. Why a reference to manpath shoud affect sudo (and apparently nothing else) is beyond me; I'll put this down under "UNIX voodoo." Best part: I could do most of it remotely, so my wife hasn't realized, and now she has a Mac that'll hopefully work flawlessly. Phew...


All times are GMT -5. The time now is 05:48 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.