0

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.

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
xtian
  • 583

1 Answers1

0

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

alias sudo='sudo '