Why would `sudo cp src dst` ignore no clobber rule in /etc? [duplicate]

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











up vote
0
down vote

favorite













This question already has an answer here:



  • Why does sudo ignore aliases?

    4 answers



My global preferences, alias cp='cp -iv', is ignored by sudo while using zsh.



I'm setting up a new system, and I'm trying out zsh for my user account. The root user still has bash. In /etc I have:



/etc/bash.bashrc
/etc/zsh/zshenv


Both of these have the above alias, alias cp='cp -iv'.



In the user's directories, neither of these contains the commands in the /etc global configs.



~/.zshenv
/root/.bashrc


If I switch to the root user su - and try to clobber a file with copy, I get the correct prompt, cp: overwrite 'fruits/apple.txt?'. The same for the home user. However, if I sudo the copy command for the home user while in zsh, the file is overwritten! Using bash, I've not experienced this problem before, so I don't have a clue where else to look.







share|improve this question














marked as duplicate by Jeff Schaller, Community♦ Nov 19 '17 at 17:43


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    0
    down vote

    favorite













    This question already has an answer here:



    • Why does sudo ignore aliases?

      4 answers



    My global preferences, alias cp='cp -iv', is ignored by sudo while using zsh.



    I'm setting up a new system, and I'm trying out zsh for my user account. The root user still has bash. In /etc I have:



    /etc/bash.bashrc
    /etc/zsh/zshenv


    Both of these have the above alias, alias cp='cp -iv'.



    In the user's directories, neither of these contains the commands in the /etc global configs.



    ~/.zshenv
    /root/.bashrc


    If I switch to the root user su - and try to clobber a file with copy, I get the correct prompt, cp: overwrite 'fruits/apple.txt?'. The same for the home user. However, if I sudo the copy command for the home user while in zsh, the file is overwritten! Using bash, I've not experienced this problem before, so I don't have a clue where else to look.







    share|improve this question














    marked as duplicate by Jeff Schaller, Community♦ Nov 19 '17 at 17:43


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:



      • Why does sudo ignore aliases?

        4 answers



      My global preferences, alias cp='cp -iv', is ignored by sudo while using zsh.



      I'm setting up a new system, and I'm trying out zsh for my user account. The root user still has bash. In /etc I have:



      /etc/bash.bashrc
      /etc/zsh/zshenv


      Both of these have the above alias, alias cp='cp -iv'.



      In the user's directories, neither of these contains the commands in the /etc global configs.



      ~/.zshenv
      /root/.bashrc


      If I switch to the root user su - and try to clobber a file with copy, I get the correct prompt, cp: overwrite 'fruits/apple.txt?'. The same for the home user. However, if I sudo the copy command for the home user while in zsh, the file is overwritten! Using bash, I've not experienced this problem before, so I don't have a clue where else to look.







      share|improve this question















      This question already has an answer here:



      • Why does sudo ignore aliases?

        4 answers



      My global preferences, alias cp='cp -iv', is ignored by sudo while using zsh.



      I'm setting up a new system, and I'm trying out zsh for my user account. The root user still has bash. In /etc I have:



      /etc/bash.bashrc
      /etc/zsh/zshenv


      Both of these have the above alias, alias cp='cp -iv'.



      In the user's directories, neither of these contains the commands in the /etc global configs.



      ~/.zshenv
      /root/.bashrc


      If I switch to the root user su - and try to clobber a file with copy, I get the correct prompt, cp: overwrite 'fruits/apple.txt?'. The same for the home user. However, if I sudo the copy command for the home user while in zsh, the file is overwritten! Using bash, I've not experienced this problem before, so I don't have a clue where else to look.





      This question already has an answer here:



      • Why does sudo ignore aliases?

        4 answers









      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '17 at 17:21









      Jeff Schaller

      32.1k849109




      32.1k849109










      asked Nov 19 '17 at 16:51









      xtian

      275210




      275210




      marked as duplicate by Jeff Schaller, Community♦ Nov 19 '17 at 17:43


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Jeff Schaller, Community♦ Nov 19 '17 at 17:43


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Workaround for sudo to work with your aliases, e.g. sudo cp ...



          alias sudo='sudo '





          share|improve this answer




















          • That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv.
            – xtian
            Nov 19 '17 at 17:50

















          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote



          accepted










          Workaround for sudo to work with your aliases, e.g. sudo cp ...



          alias sudo='sudo '





          share|improve this answer




















          • That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv.
            – xtian
            Nov 19 '17 at 17:50














          up vote
          0
          down vote



          accepted










          Workaround for sudo to work with your aliases, e.g. sudo cp ...



          alias sudo='sudo '





          share|improve this answer




















          • That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv.
            – xtian
            Nov 19 '17 at 17:50












          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          Workaround for sudo to work with your aliases, e.g. sudo cp ...



          alias sudo='sudo '





          share|improve this answer












          Workaround for sudo to work with your aliases, e.g. sudo cp ...



          alias sudo='sudo '






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '17 at 17:35









          Vlastimil

          6,4361147119




          6,4361147119











          • That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv.
            – xtian
            Nov 19 '17 at 17:50
















          • That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv.
            – xtian
            Nov 19 '17 at 17:50















          That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv.
          – xtian
          Nov 19 '17 at 17:50




          That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv.
          – xtian
          Nov 19 '17 at 17:50


          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