Command not found when run as sudo

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I'm running centos7. I installed puppet. if I write puppet as a user, I get a proper output. If I write sudo puppet I get command not found.



The really weird thing is, if I do sudo su - and become root, then write puppet, I get the normal output that I get when I run it with the normal user...



[unu@centosmaster puppet]$ puppet
See 'puppet help' for help on available puppet subcommands
[unu@centosmaster puppet]$ sudo puppet
sudo: puppet: command not found
[unu@centosmaster puppet]$ sudo su -
Last login: Wed Sep 19 08:41:20 EDT 2018 on pts/0
[root@centosmaster ~]# puppet
See 'puppet help' for help on available puppet subcommands


This, to me, makes absolutely no sense...



The $PATH variable is the same for root and normal user.










share|improve this question





















  • There's no point in using sudo su -. Either just use su - or, if you don't have the root password, use sudo -i.
    – terdon♦
    Sep 19 at 14:38














up vote
2
down vote

favorite












I'm running centos7. I installed puppet. if I write puppet as a user, I get a proper output. If I write sudo puppet I get command not found.



The really weird thing is, if I do sudo su - and become root, then write puppet, I get the normal output that I get when I run it with the normal user...



[unu@centosmaster puppet]$ puppet
See 'puppet help' for help on available puppet subcommands
[unu@centosmaster puppet]$ sudo puppet
sudo: puppet: command not found
[unu@centosmaster puppet]$ sudo su -
Last login: Wed Sep 19 08:41:20 EDT 2018 on pts/0
[root@centosmaster ~]# puppet
See 'puppet help' for help on available puppet subcommands


This, to me, makes absolutely no sense...



The $PATH variable is the same for root and normal user.










share|improve this question





















  • There's no point in using sudo su -. Either just use su - or, if you don't have the root password, use sudo -i.
    – terdon♦
    Sep 19 at 14:38












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm running centos7. I installed puppet. if I write puppet as a user, I get a proper output. If I write sudo puppet I get command not found.



The really weird thing is, if I do sudo su - and become root, then write puppet, I get the normal output that I get when I run it with the normal user...



[unu@centosmaster puppet]$ puppet
See 'puppet help' for help on available puppet subcommands
[unu@centosmaster puppet]$ sudo puppet
sudo: puppet: command not found
[unu@centosmaster puppet]$ sudo su -
Last login: Wed Sep 19 08:41:20 EDT 2018 on pts/0
[root@centosmaster ~]# puppet
See 'puppet help' for help on available puppet subcommands


This, to me, makes absolutely no sense...



The $PATH variable is the same for root and normal user.










share|improve this question













I'm running centos7. I installed puppet. if I write puppet as a user, I get a proper output. If I write sudo puppet I get command not found.



The really weird thing is, if I do sudo su - and become root, then write puppet, I get the normal output that I get when I run it with the normal user...



[unu@centosmaster puppet]$ puppet
See 'puppet help' for help on available puppet subcommands
[unu@centosmaster puppet]$ sudo puppet
sudo: puppet: command not found
[unu@centosmaster puppet]$ sudo su -
Last login: Wed Sep 19 08:41:20 EDT 2018 on pts/0
[root@centosmaster ~]# puppet
See 'puppet help' for help on available puppet subcommands


This, to me, makes absolutely no sense...



The $PATH variable is the same for root and normal user.







sudo path puppet






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Sep 19 at 13:19









iamAguest

985




985











  • There's no point in using sudo su -. Either just use su - or, if you don't have the root password, use sudo -i.
    – terdon♦
    Sep 19 at 14:38
















  • There's no point in using sudo su -. Either just use su - or, if you don't have the root password, use sudo -i.
    – terdon♦
    Sep 19 at 14:38















There's no point in using sudo su -. Either just use su - or, if you don't have the root password, use sudo -i.
– terdon♦
Sep 19 at 14:38




There's no point in using sudo su -. Either just use su - or, if you don't have the root password, use sudo -i.
– terdon♦
Sep 19 at 14:38










1 Answer
1






active

oldest

votes

















up vote
2
down vote



accepted










According to this question on Super User site, CentOS sanitizes the enviromnent to a sane default.



That's why some commands won't work with sudo.



Looks like you should check in /etc/sudoers (edit it with visudo !!) for these options:



Defaults env_reset 
Defaults env_keep += "SOME_VARIABLE_NAME" # There should be one or more of these


This line:



Defaults secure_path = "some path"


specifically overrides your user's $PATH with a predetermined one which
evidently differs from what you're expecting.



You might want to modify secure_path to your needs, or just comment the whole line if you feel your standard user's $PATH should be used even with sudo [command].






share|improve this answer




















    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470015%2fcommand-not-found-when-run-as-sudo%23new-answer', 'question_page');

    );

    Post as a guest






























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote



    accepted










    According to this question on Super User site, CentOS sanitizes the enviromnent to a sane default.



    That's why some commands won't work with sudo.



    Looks like you should check in /etc/sudoers (edit it with visudo !!) for these options:



    Defaults env_reset 
    Defaults env_keep += "SOME_VARIABLE_NAME" # There should be one or more of these


    This line:



    Defaults secure_path = "some path"


    specifically overrides your user's $PATH with a predetermined one which
    evidently differs from what you're expecting.



    You might want to modify secure_path to your needs, or just comment the whole line if you feel your standard user's $PATH should be used even with sudo [command].






    share|improve this answer
























      up vote
      2
      down vote



      accepted










      According to this question on Super User site, CentOS sanitizes the enviromnent to a sane default.



      That's why some commands won't work with sudo.



      Looks like you should check in /etc/sudoers (edit it with visudo !!) for these options:



      Defaults env_reset 
      Defaults env_keep += "SOME_VARIABLE_NAME" # There should be one or more of these


      This line:



      Defaults secure_path = "some path"


      specifically overrides your user's $PATH with a predetermined one which
      evidently differs from what you're expecting.



      You might want to modify secure_path to your needs, or just comment the whole line if you feel your standard user's $PATH should be used even with sudo [command].






      share|improve this answer






















        up vote
        2
        down vote



        accepted







        up vote
        2
        down vote



        accepted






        According to this question on Super User site, CentOS sanitizes the enviromnent to a sane default.



        That's why some commands won't work with sudo.



        Looks like you should check in /etc/sudoers (edit it with visudo !!) for these options:



        Defaults env_reset 
        Defaults env_keep += "SOME_VARIABLE_NAME" # There should be one or more of these


        This line:



        Defaults secure_path = "some path"


        specifically overrides your user's $PATH with a predetermined one which
        evidently differs from what you're expecting.



        You might want to modify secure_path to your needs, or just comment the whole line if you feel your standard user's $PATH should be used even with sudo [command].






        share|improve this answer












        According to this question on Super User site, CentOS sanitizes the enviromnent to a sane default.



        That's why some commands won't work with sudo.



        Looks like you should check in /etc/sudoers (edit it with visudo !!) for these options:



        Defaults env_reset 
        Defaults env_keep += "SOME_VARIABLE_NAME" # There should be one or more of these


        This line:



        Defaults secure_path = "some path"


        specifically overrides your user's $PATH with a predetermined one which
        evidently differs from what you're expecting.



        You might want to modify secure_path to your needs, or just comment the whole line if you feel your standard user's $PATH should be used even with sudo [command].







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Sep 19 at 13:28









        Mr Shunz

        2,76811720




        2,76811720



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470015%2fcommand-not-found-when-run-as-sudo%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay