Ubuntu – sudo: source: command not found

bashcommand linesudo

I've been updating some of the default profile for bash, and saw from the tutorials I was following that I could reload the new profile with the new environment settings by using:

source /etc/bash.bashrc

The only thing is – the new environment variables were only available to my current user – and were ignored when I used sudo. They only became available to sudo when I closed my terminal session and rejoined.

When I try to use:

sudo source /etc/bash.bashrc

I get the error:

sudo: source: command not found

Is there a simple way to load in the new bash profile settings for sudo without having to close the terminal and restart?


Initially, I was using some installer scripts which referenced the variables. I found that while they could access the variables when I called the scripts directly (although, this would cause a later problem with creating directories as I needed to be root), calling the install scripts using sudo wouldn't.

I proved this by testing with these simple commands:

echo $ENV_VARIABLE
sudo echo $ENV_VARIABLE

The first would output the variable's value, but the second wouldn't output anything.

Best Answer

The problem is that source is a bash build-in command (not a program - like ls or grep). I think one approach is to login as root and then execute the source command.

sudo -s
source /etc/bash.bashrc
Related Question