Solution 1:

.bashrc is not meant to be executed but sourced. Try this instead:

. ~/.bashrc

or, equivalently

source ~/.bashrc

See the reference about the . (aka source) builtin.


Note that if what you're looking for is to restart your Bash session after modifying your ~/.bashrc file, you might as well use:

exec bash

That will replace your current Bash session (thanks to exec) by a new session.

Solution 2:

If you want to edit that file (or any file in generally), you can't edit it simply writing its name in terminal. You must to use a command to a text editor to do this. For example:

nano ~/.bashrc

or

gedit ~/.bashrc

And in general, for any type of file:

xdg-open ~/.bashrc

Writing only ~/.bashrc in terminal, this will try to execute that file, but .bashrc file is not meant to be an executable file. If you want to execute the code inside of it, you can source it like follow:

source ~/.bashrc

or simple:

. ~/.bashrc 

Solution 3:

If you can't access the file and your os is any linux distro or mac os x then either of these commands should work:

sudo nano .bashrc

chmod 777 .bashrc 

it is worthless