There is a shell function add_book
in my .zshrc
. I need to invoke this function with sudo permission. But when I invoke sudo add_book
I get the following error:
sudo: add_book: command not found
What can I do?
You can run the program by getting root permission in advanced with this command:
sudo -i
Then run your command when it turns into root@hostname#
# cat /tmp/moo
function moo { echo moo; }
# unset moo
# type moo
-bash: type: moo: not found
# sudo -u root bash -c 'source /tmp/moo; moo'
moo