LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2007, 05:15 PM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 443

Rep: Reputation: 33
Question WHICH Command


I'm running SuSE 10.2.

I can execute the which command only if I'm logged in as the root user or I su into root.

How can I enable things so as to allow all users to use the which command?

Thanks.
 
Old 08-06-2007, 05:26 PM   #2
jimmy512
Member
 
Registered: Oct 2006
Location: London
Distribution: Arch
Posts: 183

Rep: Reputation: 31
I wouldn't recommend it, but you need to log in as root, and then change the permissions of the which executable. Something along the lines of:

Code:
chmod u+x /bin/which
(Note: which may be in a different directory)

I don't recommend this as you will be giving all users access to this command.
 
Old 08-06-2007, 06:07 PM   #3
jay73
LQ Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
I guess you could create a which group and include any users in it that are allowed to make use of that command.
 
Old 08-07-2007, 09:25 AM   #4
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,814

Rep: Reputation: 608Reputation: 608Reputation: 608Reputation: 608Reputation: 608Reputation: 608
.. what's so dangerous about which .. ?

Quote:
Originally Posted by man which
NAME
which - locate a command
...
DESCRIPTION
which returns the pathnames of the files which would be executed in the current environâint all matching pathnames of each argument
It comes -rwxr-xr-x on my Debian Etch systems..
 
Old 08-07-2007, 10:21 AM   #5
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
Code:
cat <<EOF >>~/.profile
function which { 
   IFS=:; for x in \$PATH; do
      if [ -x \$x/\$1 ]; then echo \$x/\$1; return 0;fi
   done
   echo "\$1 not fount in \$PATH"
   return 1
}
EOF

Last edited by Agrouf; 08-07-2007 at 10:28 AM.
 
Old 08-07-2007, 10:30 AM   #6
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit LOL), USA
Distribution: Centos 6.7 Under VMware in Win7
Posts: 443

Original Poster
Rep: Reputation: 33
Thanks everyone. Personnely I like the group idea best.
 
Old 08-07-2007, 02:42 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
You never elaborated on what happens when you run which
as a normal user, or how the failure manifests itself.



Cheers,
Tink
 
Old 08-08-2007, 03:20 PM   #8
jimmy512
Member
 
Registered: Oct 2006
Location: London
Distribution: Arch
Posts: 183

Rep: Reputation: 31
Quote:
.. what's so dangerous about which .. ?
I don't know. But if it is set to root only by default I would have thought it would be done so for a reason. Perhaps not.
 
Old 08-08-2007, 03:51 PM   #9
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
Check if the which command is in /usr/bin/. It may not be installed.

On my system, which is aliased to _which. _which is a function, so you may not have the alias or function defined.

Su to root and look at "type which". If it is an alias, try using "type <the alias>", as in "type _which" in my example.
Then investigate why the alias or function and the binary don't exist for a regular user.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 08:19 PM
Require Linux/Perl equivalent command for windows Command alix123 Programming 7 08-19-2005 03:23 AM
Redirecting output to a command-line argument of another command madiyaan Linux - Newbie 1 02-19-2005 05:35 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 08:14 PM
Where is Command line utility for Cups and command tutorial mossy Linux - Software 8 01-16-2004 01:24 AM


All times are GMT -5. The time now is 10:02 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration