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.

0

1 Answer 1

0

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

alias sudo='sudo ' 
1
  • That's the answer--alias expansion of sudo was required in /etc/zsh/zshenv. Commented Nov 19, 2017 at 17:50

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.