LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-26-2017, 07:34 PM   #1
deretsigernu
Member
 
Registered: May 2007
Distribution: Slackware 14.2/-current
Posts: 185

Rep: Reputation: 13
sudo and slackpkg


I am a novice with linux. I am trying to figure out my way with maintaining packages. I know that generally, we should avoid using the su command and then running the other commands that need elevated privileges. Except when I try to run sudo, I seem to have a problem:

Code:
bash-4.2$ sudo slackpkg info seamonkey
Password: 
sudo: slackpkg: command not found
bash-4.2$
Why isn't slackpkg recognized with sudo? If I use su, I can use the slackpkg command.

Code:
bash-4.2$ su
Password: 
bash-4.2# slackpkg info seamonkey

PACKAGE NAME:  seamonkey-2.46-x86_64-3_slack14.1.txz
PACKAGE LOCATION:  ./patches/packages
PAC
 
Old 02-26-2017, 07:57 PM   #2
montagdude
Senior Member
 
Registered: Apr 2016
Distribution: Slackware
Posts: 2,011

Rep: Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619Reputation: 1619
It's because slackpkg is in /usr/sbin, which is not in your regular user's PATH. sudo will not modify your PATH or other environment variables, whereas su -l will give you essentially a true root shell.
 
1 members found this post helpful.
Old 02-26-2017, 08:03 PM   #3
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,221

Rep: Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943Reputation: 943
Quote:
Originally Posted by deretsigernu View Post
I know that generally, we should avoid using the su command and then running the other commands that need elevated privileges. Except when I try to run sudo, I seem to have a problem:

Code:
bash-4.2$ sudo slackpkg info seamonkey
Password: 
sudo: slackpkg: command not found
bash-4.2$
You are free to use su or sudo, but your issue is the same as in this thread.
 
1 members found this post helpful.
Old 02-26-2017, 08:10 PM   #4
notKlaatu
Senior Member
 
Registered: Sep 2010
Location: Lawrence, New Zealand
Distribution: Slackware
Posts: 1,077

Rep: Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732Reputation: 732
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.
 
2 members found this post helpful.
Old 02-26-2017, 08:19 PM   #5
deretsigernu
Member
 
Registered: May 2007
Distribution: Slackware 14.2/-current
Posts: 185

Original Poster
Rep: Reputation: 13
Thanks for the helpful replies, everyone.
 
1 members found this post helpful.
Old 02-27-2017, 07:57 AM   #6
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by deretsigernu View Post
I know that generally, we should avoid using the su command and then running the other commands that need elevated privileges.
This is not true. Generally, you should not be logging in as root as your primary user (especially if you intend to use a WM/DE). But when root is needed, like to run administrative tools like slackpkg, su is a perfectly acceptable approach and doesn't need to be avoided. sudo can be used in place if you set it up, but sudo was designed more for the administrator to give certain users the ability to run certain programs with root permissions, not to replace the administrator from using su (although, it can certainly be used that way, but I don't think it was the original intent behind the development of the program).

Have a look at sudo's introduction page for a more in-depth look at the program.

https://www.sudo.ws/intro.html

But, as others have pointed out, your problem is quickly solved with a modification to your /etc/sudoers file
 
5 members found this post helpful.
  


Reply

Tags
slackpkg, sudo



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
having trouble after upgrading 14.1 slackware using slackpkg and slackpkg+ [solved] slackartist Slackware 1 12-28-2015 07:28 AM
[SOLVED] Slackpkg, Slackpkg Plus, Slackware 14.1 x86_64 install.log delay or slow to write bamunds Slackware 7 04-22-2014 11:12 AM
sudo slackpkg = command not found gabrielmagno Slackware 10 06-22-2013 05:41 AM
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
[SOLVED] typos in latest /etc/slackpkg/mirrors(.new) [slackpkg-2.82.0-noarch-8.tgz] wailingwailer Slackware 4 09-22-2012 04:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:10 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration