Permission to my ~/.bashrc denied

Solution 1:

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

. ~/.bashrc

To edit the file run nano .bashrc

Hope it helps

Solution 2:

If what you are trying to do is open the .bashrc file for editing, you need to open it with any text editor, such as nano, vi, or gedit. If you are trying to update after altering it in any way, you could use source .bashrc command.

For instance,

# Open the file with nano text editor and make changes you want
$ nano ~/.bashrc
# Run source command to apply changes
$ source ~/.bashrc
foobar@ubuntu:$ 

See also:

  • What is the difference between executing a Bash script vs sourcing it?

  • How can I add a directory to PATH in a script so that it affects the calling shell and the rest of the session?

Solution 3:

~/.bashrc isn't supposed to be executed. You're supposed to run something like gedit ~/.bashrc

You're getting that error because the execute bit isn't set, but it shouldn't be.

You can also source it to edit by running nano .bashrc when you're in the root.