Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

1 votes
1 answers
2134 views
Why I cannot find (using which) usermod as a regular user in RHEL7
Any ideas why the `which` command is unable to find the `usermod` command in rhel 7. Here is what I did (and corresponding output) [ec2-user@ip-10-0-4-109 ~]$ echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin [ec2-user@ip-10-0-4-109 ~]$ which u...
Any ideas why the which command is unable to find the usermod command in rhel 7. Here is what I did (and corresponding output) [ec2-user@ip-10-0-4-109 ~]$ echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin [ec2-user@ip-10-0-4-109 ~]$ which usermod /usr/bin/which: no usermod in (/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/ec2-user/.local/bin:/home/ec2-user/bin) [ec2-user@ip-10-0-4-109 ~]$ sudo su [root@ip-10-0-4-109 ec2-user]# which usermod /sbin/usermod [root@ip-10-0-4-109 ec2-user]# readlink -f /sbin/ /usr/sbin So the gist of the issue is that usermod is physically located in /usr/sbin/usermod. This directory /usr/sbin is in ec2-user search path. But for some reason which command is not returning it when I run it as ec2-user. Any ideas why this is happening on RHEL 7? I also have Ubuntu 14.04 and it works as expected (both root and regular user can see usermod in /usr/sbin). After initial post here is what else I found out: +++++++++++++++++++++++++++++++++++++++++ I found some addition information and I think this may have something to do with this: On RHEL 7 the permission bits for usermod -rwxr-x---. 1 root root 113800 Jun 28 2016 /usr/sbin/usermod On Ubuntu 14.04 the permission bits for usermod -rwxr-xr-x 1 root root 110296 May 16 19:37 /usr/sbin/usermod So I am guessing not having read permission for regular user on usermod maybe causing this?
sshekhar1980 (541 rep)
May 28, 2017, 02:09 PM • Last activity: Jul 11, 2025, 11:02 AM
506 votes
6 answers
98589 views
Why not use "which"? What to use then?
When looking for the path to an executable or checking what would happen if you enter a command name in a Unix shell, there's a plethora of different utilities (`which`, `type`, `command`, `whence`, `where`, `whereis`, `whatis`, `hash`, etc). We often hear that `which` should be avoided. Why? What s...
When looking for the path to an executable or checking what would happen if you enter a command name in a Unix shell, there's a plethora of different utilities (which, type, command, whence, where, whereis, whatis, hash, etc). We often hear that which should be avoided. Why? What should we use instead?
Stéphane Chazelas (579282 rep)
Aug 1, 2013, 10:58 PM • Last activity: Feb 7, 2025, 04:19 AM
13 votes
2 answers
65035 views
xdg-open is installed yet also is not installed
$ xdg-open The program 'xdg-open' is currently not installed. You can install it by typing: sudo apt-get install xdg-utils $ sudo apt-get install xdg-utils Reading package lists... Done Building dependency tree Reading state information... Done xdg-utils is already the newest version. 0 upgraded, 0...
$ xdg-open The program 'xdg-open' is currently not installed. You can install it by typing: sudo apt-get install xdg-utils $ sudo apt-get install xdg-utils Reading package lists... Done Building dependency tree Reading state information... Done xdg-utils is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 89 not upgraded. $ whereis xdg-open xdg-open: /usr/bin/xdg-open /usr/bin/X11/xdg-open /usr/share/man/man1/xdg-open.1.gz $ which xdg-open $ xdg-open The program 'xdg-open' is currently not installed. You can install it by typing: sudo apt-get install xdg-utils No, I didn't mean "recursion". I'm on Linux Mint 15 MATE, but instead of MATE I'm using the i3 window manager. **Edit taking @slm's advice** $ type -a xdg-open type: xdg-open not found But it's in /usr/bin/xdg-open. I checked. $ dpkg -S /usr/bin/xdg-open xdg-utils: /usr/bin/xdg-open The next one was even more interesting. $ dpkg -S xdg-open git-annex: /usr/share/doc/git-annex/html/bugs/Fix_for_opening_a_browser_on_a_mac___40__or_xdg-open_on_linux__47__bsd__63____41__.html xdg-utils: /usr/bin/xdg-open xdg-utils: /usr/share/man/man1/xdg-open.1.gz The bug-fix is just a mail archive of a patch for an OSX problem. Anyway, I guess I could try using the full path: $ /usr/bin/xdg-open /usr/bin/xdg-open: No such file or directory
nacnudus (273 rep)
Nov 16, 2013, 03:49 AM • Last activity: Nov 25, 2024, 10:19 AM
0 votes
1 answers
44 views
which node returns path to node, but not if I run in su - user -s /bin/bash -c 'which node'
When I run `which node` the command works, but if I run `su - username -s /bin/bash -c 'which node'` it returns empty. I have tried everything under the sun and can not get it to work. I even tried `su - username -s /bin/bash -c 'source ~/.bashrc ; which node'` ```lang-shellsession root@vps-151c25b9...
When I run which node the command works, but if I run su - username -s /bin/bash -c 'which node' it returns empty. I have tried everything under the sun and can not get it to work. I even tried su - username -s /bin/bash -c 'source ~/.bashrc ; which node'
-shellsession
root@vps-151c25b9:~# which node
/root/.nvm/versions/node/v20.18.0/bin/node
root@vps-151c25b9:~# su - username -s /bin/bash -c 'which node'
root@vps-151c25b9:~#
root@vps-151c25b9:~# su - username -s /bin/bash
username@vps-151c25b9:~$ which node
/home/username/.nvm/versions/node/v20.18.0/bin/node
username@vps-151c25b9:~$
What am I doing wrong? Why doesn't node show up when run with su ? **Edit:** I just noticed, when I run
-sh
su - username -s /bin/bash -c "echo $PATH"
I get the path of root, not of the user *username*. Although root also has nvm & node and it doesn't find that either. **Edit 2:** I tried single quotes , so it doesn't expand $PATH and got my correct path including nvm dir:
-sh
su username -c 'echo $PATH'
but when I try
-sh
su username -c 'source ~/.bashrc ; which node'
it still is empty. **Edit 3:** I tried
-sh
su username -c '. ~/.profile ; which which'
(lol) and it returned
/usr/bin/which
, so the command works, just not for node. **Answer:** I ran the following and it worked! I had to load NVM manually.
-shellsession
root@vps-151c25b9:~# su - username -c 'export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" ; [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" ; which node'
/home/username/.nvm/versions/node/v20.18.0/bin/node
Thank you everyone for your help :)
tehnutz (1 rep)
Nov 6, 2024, 09:24 AM • Last activity: Nov 10, 2024, 05:59 AM
-2 votes
1 answers
115 views
How to trim directory from which output without basename?
For a shell script I need to call an executable by name, regardless of the path leading there; thus far I know this code reports the right name: ``` tmpprog=`which program` prog=${tmpprog%%*/} if $prog="" then echo >&2 "Main Program not found" else echo >&2 "$prog" fi ``` How can I cut the code so t...
For a shell script I need to call an executable by name, regardless of the path leading there; thus far I know this code reports the right name:
tmpprog=which program
prog=${tmpprog%%*/}
if $prog=""
then
  echo >&2 "Main Program not found"
else
  echo >&2 "$prog"
fi
How can I cut the code so that I may trim the path to keep the executable name and remove the path in a one liner? Beware: basename won't do it, since I may be working on a hybrid environment (cygwin/busybox on windoze), and sometimes the paths have spaces.
jarnowy (200 rep)
Jan 16, 2024, 02:14 AM • Last activity: Apr 5, 2024, 08:31 AM
4 votes
2 answers
1020 views
Does any implementation of `which` output "no" when executable cannot be found?
I am reading the [source code of the Maven wrapper written for the Bourne shell](https://github.com/apache/maven-wrapper/blob/102d7b50cd756b0ac922ef07378c1fe3c9686473/maven-wrapper-distribution/src/resources/mvnw#L103). I came across these lines: ```sh if [ -z "$JAVA_HOME" ]; then javaExecutable="$(...
I am reading the [source code of the Maven wrapper written for the Bourne shell](https://github.com/apache/maven-wrapper/blob/102d7b50cd756b0ac922ef07378c1fe3c9686473/maven-wrapper-distribution/src/resources/mvnw#L103) . I came across these lines:
if [ -z "$JAVA_HOME" ]; then
    javaExecutable="$(which javac)"
    if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then
# snip
expr when used with arg1 and arg2 and a : matches arg1 against the regex arg2. Normally, the result would be the amount of matching characters, e.g.:
$ expr foobar : foo
3
However, when using capturing parentheses (\( and \)), it returns the content of the first capturing parentheses:
$ expr foobar : '\(foo\)'
foo
So far, so good. If I evaluate the expression from the source quoted above on my machine, I get:
$ javaExecutable=$(which javac)
$ expr "$javaExecutable" : '\([^ ]*\)'
/usr/bin/javac
For a non-existing executable:
$ nonExistingExecutable=$(which sjdkfjkdsjfs)
$ expr "$nonExistingExecutable" : '\([^ ]*\)'
Which means that for a non-existing executable the output is a empty string with newline. What's puzzling me in the source is how the output of which javac (arg1 to expr) ever returns the string no? Is there some version of which which, instead of returning nothing, returns no when no executable can be found? If not, this statement always evaluates to true and that would be weird.
Stefan van den Akker (352 rep)
Feb 14, 2024, 11:50 AM • Last activity: Feb 16, 2024, 02:42 PM
2 votes
0 answers
380 views
command to find out what package manager installed this executable/file
I am looking for a script that would tell me what exactly installed a binary (or other asset) on a (Debianish) Linux system. Nowadays there are so many package managers (snap, flatpak, pip, npm, composer, conda, brew, clib, cargo) besides apt*/rpm/manual that its a real hassle to find out what exact...
I am looking for a script that would tell me what exactly installed a binary (or other asset) on a (Debianish) Linux system. Nowadays there are so many package managers (snap, flatpak, pip, npm, composer, conda, brew, clib, cargo) besides apt*/rpm/manual that its a real hassle to find out what exactly installed what and more importantly: what package manager is supposed to keep it up to date. ### Use cases - These days its vital to distinguish between an app installed by the apt mechanism and something installed by snap - When installing an app, one would prefer to find out if and what installed it before.
allanlaal (852 rep)
Oct 19, 2022, 12:06 AM • Last activity: Dec 14, 2023, 05:32 AM
23 votes
2 answers
12005 views
What is the difference between which and where
What is the difference between `where` and `which` shell commands? Here are some examples ~ where cc /usr/bin/cc /usr/bin/cc ~ which cc /usr/bin/cc and ~ which which which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' /usr/bin/which ~ which where /usr/bin/which: no where i...
What is the difference between where and which shell commands? Here are some examples ~ where cc /usr/bin/cc /usr/bin/cc ~ which cc /usr/bin/cc and ~ which which which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' /usr/bin/which ~ which where /usr/bin/which: no where in (/usr/local/bin:/bin:/usr/bin:/home/bnikhil/bin:/bin) also ~ where which which: aliased to alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde which: shell built-in command /usr/bin/which /usr/bin/which ~ where where where: shell built-in command To me it seems that they do the same thing one being a shell builtin, not quite sure how that is different from a command?
nikhil (1062 rep)
Feb 5, 2013, 12:30 PM • Last activity: Oct 4, 2023, 05:19 PM
2 votes
0 answers
70 views
'which' behaves inconsistently on different machines - Why the difference?
My company has multiple servers that were setup to be identical. After using dev32 for several weeks, `which` stopped functioning. I go to dev35 and get similar behavior -- works for several weeks then one day it stops. dev36 is ok for now, but following this pattern I'll eventually run out of syste...
My company has multiple servers that were setup to be identical. After using dev32 for several weeks, which stopped functioning. I go to dev35 and get similar behavior -- works for several weeks then one day it stops. dev36 is ok for now, but following this pattern I'll eventually run out of systems to use. Any thoughts on what could be causing this behavior?
dev32 ~> which python3
python3: Command not found.
dev35 ~> which python3
python3: Command not found.
dev36 ~> which python3
/bin/python3

dev32 ~> ls -al /bin/python*
lrwxrwxrwx. 1 root root     9 Jan 17 10:18 /bin/python3 -> python3.6
-rwxr-x---. 2 root root 11328 Nov 16  2020 /bin/python3.6
-rwxr-x---. 2 root root 11328 Nov 16  2020 /bin/python3.6m
dev32 ~> echo $PATH
.:/bin:/sbin:/usr/bin:/usr/bin/X11:/usr/bsd:/usr/sbin:/home//bin:/usr/local/bin:/usr/local/etc:/usr/local/sbin:/etc:/usr/etc:/usr/gnu/bin

dev35 ~> ls -al /bin/python3*
lrwxrwxrwx. 1 root root     9 Jan 17 10:11 /bin/python3 -> python3.6
-rwxr-x---. 2 root root 11328 Nov 16  2020 /bin/python3.6
-rwxr-x---. 2 root root 11328 Nov 16  2020 /bin/python3.6m
dev35 ~> echo $PATH
.:/bin:/sbin:/usr/bin:/usr/bin/X11:/usr/bsd:/usr/sbin:/home//bin:/usr/local/bin:/usr/local/etc:/usr/local/sbin:/etc:/usr/etc:/usr/gnu/bin

dev36 ~> ls -al /bin/python*
lrwxrwxrwx. 1 root root     9 Jan 17 10:18 /bin/python3 -> python3.6
-rwxr-x---. 3 root root 11328 Nov 16  2020 /bin/python3.6
-rwxr-x---. 2 root root 11328 Nov 16  2020 /bin/python3.6m
dev36 ~> echo $PATH
.:/bin:/sbin:/usr/bin:/usr/bin/X11:/usr/bsd:/usr/sbin:/home//bin:/usr/local/bin:/usr/local/etc:/usr/local/sbin:/etc:/usr/etc:/usr/gnu/bin
Even after cd /bin, which cannot find python3 Other knowns: - All servers are CentOS 7.9, uname -a matches - Ran rpm -qa | sort > $HOSTNAME.txt on each server and compared. results are identical - bash v4.2.26, tcsh v6.18.01 (same across all systems) - Behavior confirmed by multiple users; tcsh & bash yield same results. One user's shell uses system defaults (no ~/.bashrc, ~/.tcshrc or ~/.login), I customize mine. - IT says they haven't changed anything beyond standard monthly patching that is applied consistently to all servers. - Problem persists across reboots Please let me know if more information is needed.
JB Looney (21 rep)
May 17, 2023, 02:27 PM • Last activity: May 18, 2023, 01:47 PM
0 votes
1 answers
46 views
What a linux command take the result of "which" command as an argument and list the configuration file paths related to the command we gave to which?
I can't recall that command and I can't even find it in Google. It's just killing me. The usage of the command is like: `which bash` The output looks like: /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc Took bush just for example of course. It may be any command. Upd: I use the Red...
I can't recall that command and I can't even find it in Google. It's just killing me. The usage of the command is like: which bash The output looks like: /etc/skel/.bash_logout /etc/skel/.bash_profile /etc/skel/.bashrc Took bush just for example of course. It may be any command. Upd: I use the Redhat based OS.
Maksim Orlov (1 rep)
Apr 28, 2023, 06:01 AM • Last activity: Apr 28, 2023, 06:15 PM
4 votes
2 answers
14571 views
sh: which: line 1: syntax error: unexpected end of file; sh: error importing function definition for `which'
We are running: Red Hat Enterprise Linux release 8.5 (Ootpa). We allow the server to update weekly using "yum -y update". We recently began receiving the following errors when executing shell commands: - sh: which: line 1: syntax error: unexpected end of file - sh: error importing function definitio...
We are running: Red Hat Enterprise Linux release 8.5 (Ootpa). We allow the server to update weekly using "yum -y update". We recently began receiving the following errors when executing shell commands: - sh: which: line 1: syntax error: unexpected end of file - sh: error importing function definition for `which' I am not aware of anything we changed that could cause this error -- this why I am pointing to the yum system update. Much of our code is written in php where we use passthru() to run shell commands. When we rarely write a shell script we generally use bash. I have the ability to prevent these errors using "unset which" prior to running a php script that uses passthru(). We run many shell commands from many scripts. Updating each of these scripts is not an effective solution -- time consuming and potentially introduces defects. It is interesting to note that the following code Does Not cause an error:
#!/bin/sh
echo hello
Is there a way to 'unset which' once at the system or user level so it would be executed each time we run the shell? Perhaps there is a shell profile that I can change or something similar. **Update 1** I found the following in /etc/profile.d/which2.sh
# shellcheck shell=sh
# Initialization script for bash, sh, mksh and ksh

which_declare="declare -f"
which_opt="-f"
which_shell="$(cat /proc/$$/comm)"

if [ "$which_shell" = "ksh" ] || [ "$which_shell" = "mksh" ] || [ "$which_shell" = "zsh" ] ; then
  which_declare="typeset -f"
  which_opt=""
fi
 
which ()
{
(alias; eval ${which_declare}) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot "$@"
}

export which_declare
export ${which_opt} which
The syntax looks correct here. I can tell that it exports 'which' -- but I'm not sure why. If I knew what this is doing, I could evaluate the risk of
which
. **Update 2** Created a small php script:
#!/usr/bin/php
This Does create the error.
Greg Sims (211 rep)
Dec 14, 2021, 08:49 PM • Last activity: Mar 28, 2023, 02:00 PM
0 votes
0 answers
214 views
which wget returns error: /usr/bin/env: «node»: No such file or directory
I uninstalled nodejs the other day and now for some reason when I access it I get the error that node is not found. The argument of the which command can be anything. ``` > which wget /usr/bin/env: «node»: No such file or directory ``` However, if I install the node again, everything is fi...
I uninstalled nodejs the other day and now for some reason when I access it I get the error that node is not found. The argument of the which command can be anything.
> which wget                                                                                                                                                                        
/usr/bin/env: «node»: No such file or directory
However, if I install the node again, everything is fine:
> sudo pacman -S nodejs
...

> which wget                                                                                                                                                              
/usr/bin/wget
Daniil Screpchenko (163 rep)
Feb 2, 2023, 09:31 AM
3 votes
2 answers
3279 views
$PATH environment variable does not seem to be recognized
I've made a fresh install of Debian Wheezy, and installed zsh to it. Few days after, I've done a vanilla installation of TeX Live 2014, so I added the necessary binary paths to my $PATH. Now I started writing little scripts so I would like to put them somewhere easily accessible, that is `~/bin`. My...
I've made a fresh install of Debian Wheezy, and installed zsh to it. Few days after, I've done a vanilla installation of TeX Live 2014, so I added the necessary binary paths to my $PATH. Now I started writing little scripts so I would like to put them somewhere easily accessible, that is ~/bin. My path looks like this: ~/bin:/opt/texbin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games Now, if I wanted to run something from TeX Live, it's easy: % which pdflatex /opt/texbin/pdflatex No problem. But when I try running something from ~/bin, ... % which hello_world hello_world not found So I double-checked: % ls -l ~/bin total 18 -rwxr-xr-x 1 bozbalci bozbalci 5382 Sep 8 00:28 hello_world And it shows that hello_world is doing fine in ~/bin with its execution permissions set. I've tried rehash, but it didn't work. Help?
Berk Özbalcı (145 rep)
Sep 7, 2014, 09:42 PM • Last activity: Jan 10, 2023, 06:24 PM
0 votes
1 answers
347 views
Why isn't `which ls | file` working?
I would like to use the result of `which ls` and see the file type using `file`. However, when I type in `which ls | file` it doesn't work. When I try to do `file < which ls`, that doesn't work either. Any pointers would be appreciated.
I would like to use the result of which ls and see the file type using file. However, when I type in which ls | file it doesn't work. When I try to do file < which ls, that doesn't work either. Any pointers would be appreciated.
Grateful (113 rep)
Dec 19, 2022, 07:18 AM • Last activity: Dec 19, 2022, 07:39 AM
5 votes
1 answers
633 views
'which' is unable to find command even though it is definitely installed
I have recently installed the ```cryptsetup```. I've double checked with ```sudo apt-get install cryptsetup```. ``` Reading package lists... Done Building dependency tree... Done Reading state information... Done cryptsetup is already the newest version (2:2.3.7-1+deb11u1). 0 upgraded, 0 newly insta...
I have recently installed the
. I've double checked with
apt-get install cryptsetup
.
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
cryptsetup is already the newest version (2:2.3.7-1+deb11u1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
However when I try to use the command it does not recognize it.
bash: cryptsetup: command not found
Then I tried to find the location of the command using
.
cryptsetup
However the command does not return anything.
cryptsetup
says that
indeed is the right command name. What is wrong here?
rful7877 (51 rep)
Dec 16, 2022, 09:38 AM • Last activity: Dec 16, 2022, 09:44 AM
1 votes
1 answers
350 views
which command returning undocumented things
I am trying to locate which `conda` executable I am using. For this, I want to use `which` command. As per man pages, it should return the path of the executable. Instead it returns some bash function (base) ➜ ~ which conda conda () { \local cmd="${1-__missing__}" case "$cmd" in (activate | deactiva...
I am trying to locate which conda executable I am using. For this, I want to use which command. As per man pages, it should return the path of the executable. Instead it returns some bash function (base) ➜ ~ which conda conda () { \local cmd="${1-__missing__}" case "$cmd" in (activate | deactivate) __conda_activate "$@" ;; (install | update | upgrade | remove | uninstall) __conda_exe "$@" || \return __conda_reactivate ;; (*) __conda_exe "$@" ;; esac } If I try to see the location of __conda_exe, again I get another function: __conda_exe () { ( __add_sys_prefix_to_path "$CONDA_EXE" $_CE_M $_CE_CONDA "$@" ) } where is the conda function I am using?
asdf (111 rep)
Jul 1, 2022, 08:00 AM • Last activity: Jul 2, 2022, 01:55 PM
0 votes
0 answers
15 views
I have a situation in which "which -a python" is not showing execution order when run on CentOS 6 with Python 3.7
Does anyone know where to begin with debugging this? [chuck@vmlnx-tacx32 openssl-1.1.0h]$ which -a python /usr/local/bin/python /usr/bin/python [chuck@vmlnx-tacx32 openssl-1.1.0h]$ /usr/local/bin/python Python 3.7.6 (default, Feb 23 2022, 13:10:48) [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux Ty...
Does anyone know where to begin with debugging this? [chuck@vmlnx-tacx32 openssl-1.1.0h]$ which -a python /usr/local/bin/python /usr/bin/python [chuck@vmlnx-tacx32 openssl-1.1.0h]$ /usr/local/bin/python Python 3.7.6 (default, Feb 23 2022, 13:10:48) [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> exit() [chuck@vmlnx-tacx32 openssl-1.1.0h]$ python Python 2.6.6 (r266:84292, Jul 23 2015, 14:41:34) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> exit()
seanmus (141 rep)
Feb 23, 2022, 09:43 PM
0 votes
1 answers
93 views
Where is the executable?
I have this command that I run. Let's call it `foo`. I can execute `foo` without specify the full path to `foo` like so: ``` $ foo missing args ``` I suspect `foo` is a bash script so I want to look at the source code in `foo`, but when I do `which foo` I get the standard error message: ``` which: n...
I have this command that I run. Let's call it foo. I can execute foo without specify the full path to foo like so:
$ foo
missing args
I suspect foo is a bash script so I want to look at the source code in foo, but when I do which foo I get the standard error message:
which: no foo in (/usr/local/bin ...removed for brevity ...)
What gives?
Red Cricket (2233 rep)
Nov 2, 2021, 07:37 PM • Last activity: Nov 2, 2021, 07:57 PM
0 votes
1 answers
248 views
What is which command output ordering?
In bash I see `which` returns the paths in order, but in zsh it has different ordering. I now primarily use zsh, how can I get proper output ordering of `which` in zsh? Why is it different? I expected the ordering to match my path. My path is: `/usr/local/bin:/usr/bin` ``` bash$ which -a git /usr/lo...
In bash I see which returns the paths in order, but in zsh it has different ordering. I now primarily use zsh, how can I get proper output ordering of which in zsh? Why is it different? I expected the ordering to match my path. My path is: /usr/local/bin:/usr/bin
bash$ which -a git
/usr/local/bin/git
/usr/bin/git
zsh$ which -a git
/usr/bin/git
/usr/local/bin/git -> ../Cellar/git/2.32.0/bin/git
Michael Ozeryansky (143 rep)
Oct 23, 2021, 08:19 AM • Last activity: Oct 23, 2021, 11:47 AM
25 votes
2 answers
12813 views
how is whence different than which?
I read https://unix.stackexchange.com/questions/9683/which-but-all/ but I cannot really get the difference. I am running zsh 5.4.2 on 64-bit debian-buster. Both which and whence are shell-builtins . Can people point out where whence would be more appropriate than which and vice-versa ? /home/shirish...
I read https://unix.stackexchange.com/questions/9683/which-but-all/ but I cannot really get the difference. I am running zsh 5.4.2 on 64-bit debian-buster. Both which and whence are shell-builtins . Can people point out where whence would be more appropriate than which and vice-versa ? /home/shirish> zsh --version zsh 5.4.2 (x86_64-debian-linux-gnu) /home/shirish> type -a which which is a shell builtin which is /usr/bin/which which is /bin/which /home/shirish> type -a whence whence is a shell builtin
shirish (12954 rep)
Jan 28, 2018, 01:56 PM • Last activity: Oct 13, 2021, 03:24 PM
Showing page 1 of 20 total questions