Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: sudo command PATH problem

  1. #1
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default sudo command PATH problem

    Hey,

    My sudo command doesn't see all of my path. Is this a normal behaviour. If not how do I fix this?

    For example:

    Code:
    sudo service ***** start
    gives me a command not found

    Code:
    su
    service ***** start
    This works.

    And this is not the only example of this.
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  2. #2
    Join Date
    Nov 2010
    Location
    Youngstown, OH
    Posts
    155

    Default Re: sudo command PATH problem

    Code:
    sudo /sbin/service **** start
    Lenovo: OpenSUSE 11.4/32 | Xfce 4.8.1 | Intel Core2 Duo T7200 | Intel 945GM/GMS | 4G RAM | Firefox 8.0 | Thunderbird 3.1.16

  3. #3
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: sudo command PATH problem

    That is more typing. Is this really necessary? Security concern maybe?
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  4. #4
    Join Date
    Nov 2010
    Location
    Youngstown, OH
    Posts
    155

    Default Re: sudo command PATH problem

    Quote Originally Posted by yasar11732 View Post
    Security concern maybe?
    Since I think sbin is for System Binaries, my first guess is YES, it's a Security Concern.
    Lenovo: OpenSUSE 11.4/32 | Xfce 4.8.1 | Intel Core2 Duo T7200 | Intel 945GM/GMS | 4G RAM | Firefox 8.0 | Thunderbird 3.1.16

  5. #5
    Join Date
    Jul 2008
    Location
    Seattle, WA
    Posts
    17,043

    Default Re: sudo command PATH problem

    On Fri, 18 Mar 2011 03:06:02 +0000, yasar11732 wrote:

    > My sudo command doesn't see all of my path. Is this a normal behaviour.
    > If not how do I fix this?


    IIRC, sudo uses the path defined by the current user rather than the root
    user (or the user you're switching to.

    Try:

    sudo echo $PATH

    and see what comes back.

    Then compare that to:

    su
    echo $PATH

    and

    su -
    echo $PATH

    (The latter is what is generally recommended)

    Jim
    --
    Jim Henderson
    openSUSE Forums Administrator
    Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

  6. #6
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: sudo command PATH problem

    sudo -i ...

  7. #7
    Join Date
    Dec 2010
    Location
    Ankara, Turkey
    Posts
    250

    Default Re: sudo command PATH problem

    Quote Originally Posted by ken_yap View Post
    sudo -i ...
    What does this do?
    The only problem with troubleshooting is that sometimes trouble shoots back.
    My blog (in Turkish): http://yasar.serveblog.net

  8. #8
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: sudo command PATH problem

    man sudo

  9. #9
    Join Date
    Nov 2009
    Location
    West Virginia Sector 13
    Posts
    15,646

    Default Re: sudo command PATH problem

    From
    man sudo
    -i [command]
    The -i (simulate initial login) option runs the shell specified in the passwd(5) entry of
    the target user as a login shell. This means that login-specific resource files such as
    .profile or .login will be read by the shell. If a command is specified, it is passed to
    the shell for execution. Otherwise, an interactive shell is executed. sudo attempts to
    change to that user's home directory before running the shell. It also initializes the
    environment, leaving DISPLAY and TERM unchanged, setting HOME, SHELL, USER, LOGNAME, and
    PATH, as well as the contents of /etc/environment on Linux and AIX systems. All other
    environment variables are removed.

  10. #10
    Join Date
    Jun 2008
    Location
    Earth - Denmark
    Posts
    10,730

    Default Re: sudo command PATH problem

    On 03/18/2011 04:06 AM, yasar11732 wrote:
    >
    > My sudo command doesn't see all of my path. Is this a normal behaviour.
    > If not how do I fix this?


    security is the reason [sudo here is different from sudo in (say)
    Ubuntu or others]...try

    su -c 'service ***** start'

    which is 3 strokes longer..

    some 'repair' the sudo path, i'd rather have the extra strokes..

    hmmmmmm, i've not thought about how to alias it..
    just now i has s ='su -'
    i guess maybe sc could be 'su -c' and then

    sc 'service ***** start'

    would be the same strokes as your sudo string..

    lots of cats to skin.

    --
    DenverD
    CAVEAT: http://is.gd/bpoMD
    [NNTP posted w/openSUSE 11.3, KDE4.5.5, Thunderbird3.1.8, nVidia
    173.14.28 3D, Athlon 64 3000+]
    "It is far easier to read, understand and follow the instructions than
    to undo the problems caused by not." DD 23 Jan 11

Page 1 of 2 12 LastLast

Posting Permissions

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