First, a hint: did you look at the /etc/sudoers file?
If you do, and search for the string 'path', you'll see a comment that explains exactly what you are asking. It's actually an option, so you can modify the behaviour there.
Otherwise, you could do this, too:
Code:
$ echo $PATH
$ sudo echo $PATH
If those two values are the same, then naturally `sudo` has no effect on what directories your shell looks in for an arbitrary command you give it.
You can find out where `slackpkg` is located in the location that Slackware records anything that gets installed with `installpkg`:
Code:
$ grep slackpkg /var/log/packages/slackpkg*
So if `slackpkg` is in a location NOT in your user's or sudo's $PATH, then as far as your computer knows, `slackpkg` does not exist.
Which brings us back to your question. And the answer, as I've said, is in /etc/sudoers.
On line 59 or so:
Code:
## Uncomment to use a hard-coded PATH instead of the user's to find commands
# Defaults secure_path="blah blah blah"
So open sudoers in visudo and edit it, uncommenting that line. In so doing, you open up the PATH locations previously reserved for root, and now when you use `sudo`, you'll have the same PATH as root.
Hope that helps.