Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: "which" cannot find command in /usr/local/bin in su or sudo

  1. #1
    Join Date
    Jan 2016
    Location
    Manchester, UK
    Posts
    279

    Default "which" cannot find command in /usr/local/bin in su or sudo

    Hello everyone,

    I am using Tumbleweed but I am not upgrading it very often this days because of daily load is very high. Recently, I found commands in /usr/local/bin, where my custom installed apps locate, cannot be used in su or sudo environment unless I give it the full path, such as /usr/loca/bin/dislocker.

    This problem might occur in the last 2 months. It used to work fine.

    Anyone know what is the problem? Any solution to this?

    TIA
    Haoxian
    openSUSE Tumbleweed (usually the latest snapshot) w/ KDE Plasma 5

  2. #2
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,631
    Blog Entries
    3

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    What's the output from:
    Code:
    echo $PATH
    sudo echo $PATH
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  3. #3
    Join Date
    Jan 2016
    Location
    Manchester, UK
    Posts
    279

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    Quote Originally Posted by nrickert View Post
    What's the output from:
    Code:
    echo $PATH
    sudo echo $PATH
    Thank you, nrickert,

    The outputs are,
    Code:
    cnzhx@ot:~> echo $PATH
    /home/cnzhx/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/sbin:/home/cnzhx/anaconda3/bin:/home/cnzhx/anaconda3/bin
    cnzhx@ot:~> sudo echo $PATH
    [sudo] password for root:
    /home/cnzhx/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/sbin:/home/cnzhx/anaconda3/bin:/home/cnzhx/anaconda3/bin/
    And I do not remember I have done anything related to she $PATH.
    Last edited by cnzhx; 16-May-2018 at 01:19. Reason: FORMAT
    openSUSE Tumbleweed (usually the latest snapshot) w/ KDE Plasma 5

  4. #4
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,631
    Blog Entries
    3

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    With those PATH settings, it should be working.

    If you try:
    Code:
    su -
    echo $PATH
    exit
    you may get a different path. With the "-" argument to "su" the path is reset. Perhaps that's where you are having issues.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  5. #5
    Join Date
    Jan 2016
    Location
    Manchester, UK
    Posts
    279

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    Quote Originally Posted by nrickert View Post
    With those PATH settings, it should be working.
    Yes, it should work. But it did not. So I am confused.

    Quote Originally Posted by nrickert View Post
    If you try:
    Code:
    su -
    echo $PATH
    exit
    you may get a different path. With the "-" argument to "su" the path is reset. Perhaps that's where you are having issues.
    I seldom use `su -`. Here is the output,
    Code:
    cnzhx@ot:~> su -
    Password:
    ot:~ # echo $PATH
    /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/sbin
    ot:~ # which dislocker
    /usr/local/bin/dislocker
    ot:~ # exit
    logout
    It looks like the `/usr/local/bin` is still in this environment. But this time, the `which` can find `dislocker`.

    So the problem is, `/usr/local/bin` is also in `su`'s $PATH, why does `which` not find `dislocker` there?

    Am I the only one who get this weird problem? If that is it, maybe I have touched something I do not know. Actually, I am too busy to perform such actions during this period. But I am not so sure. Any idea how to get it right?
    openSUSE Tumbleweed (usually the latest snapshot) w/ KDE Plasma 5

  6. #6

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    On 05/16/2018 10:16 AM, cnzhx wrote:
    >
    > nrickert;2865622 Wrote:
    >> With those PATH settings, it should be working.

    >
    > Yes, it should work. But it did not. So I am confused.
    >
    > nrickert;2865622 Wrote:
    >>
    >> If you try:
    >>>

    > Code:
    > --------------------
    > > >

    > > su -
    > > echo $PATH
    > > exit
    > >

    > --------------------
    >>>

    >> you may get a different path. With the "-" argument to "su" the path
    >> is reset. Perhaps that's where you are having issues.

    > I seldom use `su -`. Here is the output,
    >
    > Code:
    > --------------------
    > cnzhx@ot:~> su -
    > Password:
    > ot:~ # echo $PATH
    > /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/lib/mit/sbin
    > ot:~ # which dislocker
    > /usr/local/bin/dislocker
    > ot:~ # exit
    > logout
    > --------------------
    >
    > It looks like the `/usr/local/bin` is still in this environment. But
    > this time, the `which` can find `dislocker`.
    >
    > So the problem is, `/usr/local/bin` is also in `su`'s $PATH, why does
    > `which` not find `dislocker` there?
    >
    > Am I the only one who get this weird problem? If that is it, maybe I
    > have touched something I do not know. Actually, I am too busy to perform
    > such actions during this period. But I am not so sure. Any idea how to
    > get it right?
    >
    >


    Does 'dislocker' have the execute bit set?

    --
    Ken
    linux since 1984
    S.u.S.E./openSUSE since 1996

  7. #7
    Join Date
    Jan 2016
    Location
    Manchester, UK
    Posts
    279

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    Quote Originally Posted by kensch View Post
    Does 'dislocker' have the execute bit set?

    --
    Ken
    linux since 1984
    S.u.S.E./openSUSE since 1996
    Thank you, Ken. The `dislocker` has execute bit set, I think,
    Code:
    # ls -al /usr/local/bin/dislocker
    lrwxrwxrwx 1 root root 14 May  6 00:09 /usr/local/bin/dislocker -> dislocker-fuse
    I just upgraded from 20180429 to 20180515 snapshot. The problem is still there.
    openSUSE Tumbleweed (usually the latest snapshot) w/ KDE Plasma 5

  8. #8
    Join Date
    Aug 2010
    Location
    Chicago suburbs
    Posts
    12,631
    Blog Entries
    3

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    Quote Originally Posted by cnzhx View Post
    Thank you, Ken. The `dislocker` has execute bit set, I think,
    Code:
    # ls -al /usr/local/bin/dislocker
    lrwxrwxrwx 1 root root 14 May  6 00:09 /usr/local/bin/dislocker -> dislocker-fuse
    Try:
    Code:
    ls -alL /usr/bin/dislocker
    The '-L' tells "ls" to follow the symbolic link.
    openSUSE Leap 15.1; KDE Plasma 5;
    testing Leap 15.2Alpha

  9. #9

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    The symlink permissions are not the ones that count; what ownership
    permissions do you have on the target file?

    Code:
    ls -l /usr/local/bin/dislocker*
    As a note while verifying/testing this, if your symlink is broken it will
    also not show up in 'which' output, which is what you would expect.
    Symlinks always have all bits set, even though they do not necessarily get
    accessed by everybody.

    If your dislocker-fuse executable is user-owned by 'root', and then that
    user does not have execute rights, but the group-owner and/or other users
    have execute, then that would explain what you are seeing. Also note that
    FACLs could come into play. We'll see what the output above shows, though.

    --
    Good luck.

    If you find this post helpful and are logged into the web interface,
    show your appreciation and click on the star below.

    If you want to send me a private message, please let me know in the
    forum as I do not use the web interface often.

  10. #10
    Join Date
    Jan 2016
    Location
    Manchester, UK
    Posts
    279

    Default Re: "which" cannot find command in /usr/local/bin in su or sudo

    Quote Originally Posted by nrickert View Post
    Try:
    Code:
    ls -alL /usr/bin/dislocker
    The '-L' tells "ls" to follow the symbolic link.
    Quote Originally Posted by ab View Post
    The symlink permissions are not the ones that count; what ownership
    permissions do you have on the target file?

    Code:
    ls -l /usr/local/bin/dislocker*
    As a note while verifying/testing this, if your symlink is broken it will
    also not show up in 'which' output, which is what you would expect.
    Symlinks always have all bits set, even though they do not necessarily get
    accessed by everybody.

    If your dislocker-fuse executable is user-owned by 'root', and then that
    user does not have execute rights, but the group-owner and/or other users
    have execute, then that would explain what you are seeing. Also note that
    FACLs could come into play. We'll see what the output above shows, though.
    Think you both. I really didn't know that

    Here is the new output,
    Code:
    # ls -alL /usr/local/bin/dislocker
    -rwxr-xr-x 1 root root 22016 May  6 00:09 /usr/local/bin/dislocker
    Is there anything wrong with this then?
    openSUSE Tumbleweed (usually the latest snapshot) w/ KDE Plasma 5

Page 1 of 3 123 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •