- Newest
- Most votes
- Most comments
I think the following methods can solve the problem.
The "source" command will cause an error if it is executed with "sudo".
So I think changing to the root user and then running it will solve the problem.
https://askubuntu.com/a/20955
source and . are shell built-in commands. They execute the command you want within the context of the current process. So trying to run them using sudo which will create a new process doesn't make much sense.
Also, you can't execute multiple commands with a wildcard. With *.rc the shell will expand that to first.rc second.rc third.rc which means "execute first.rc with second.rc and third.rc as parameters".
What I think you're trying to do is run a bunch of commands in a directory as the root user. There are probably a thousand ways to do that but you might try:
for command in /patch/*.rc
do
sudo ${command}
done
.... create a new process doesn't make much sense.
For instance, how to reload /etc/mail.rc if not using sudo?
The commands in my answer will do that for you.
as a sum up
Instead of running "sudo source /path/*.rc", you can use one of the following alternatives
sudo bash -c "source /path/*.rc"
source <(sudo cat /path/*.rc)
sudo su
source /path/*.rc
Relevant content
asked 3 years ago
asked 10 months ago
- AWS OFFICIALUpdated 8 months ago

[root@ip-xxx-xxx-xxx-xxx ec2-user]# source /etc/mail.rc bash: ignore: command not found bash: ignore: command not found bash: fwdretain: command not found
The "ignore" and "fwdretain" commands are said to be missing. Do you have the path settings listed in the "/etc/mail.rc" file? Also, are the commands "ignore" and "fwdretain" installed on Amazon Linux 2023? You can check the path with the following command.
After checking, make sure that the path is in "/etc/mail.rc".