[bash] .bashrc: Permission denied

I try to work with a project in vagrant. I have made the command vagrant ssh, and connected to VM. Now I need to edit .bashrc file to set path to the source code. But first I couldn't find that file. So I googled and find that the way is call command ~/.bashrc. But doing this I get message, that I have no access to it:

[vagrant@nupic-vagrant:~]$ ~/.bashrc
-bash: /home/vagrant/.bashrc: Permission denied

So what to do now?

UPD. I can't find the .bashrc file. When I try to make command ls -a I get following:

[vagrant@nupic-vagrant:~]$ ls -a
.              .bash_logout   cleanup.sh   sshd.sh        .veewee_params
..             .bash_profile  minimize.sh  vagrant.sh     .veewee_version
.bash_history  .bashrc        .ssh         .vbox_version  .zsh_profile
[vagrant@nupic-vagrant:~]$ locate .bashrc
/etc/skel/.bashrc
/home/vagrant/.bashrc
/var/chef/backup/etc/skel/.bashrc.chef-20130614181911
/var/chef/backup/home/vagrant/.bashrc.chef-20130614181912
[vagrant@nupic-vagrant:~]$

But only the place where I can find some of those files is the directory where cygwin is installed. Pls, see illustrations, they reflect relations between directories vagrant and cygwin. enter image description here

This question is related to bash ssh vagrant permission-denied nupic

The answer is


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

. ~/.bashrc

Cheers!


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 

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


The .bashrc file is in your user home directory (~/.bashrc or ~vagrant/.bashrc both resolve to the same path), inside the VM's filesystem. This file is invisible on the host machine, so you can't use any Windows editors to edit it directly.

You have two simple choices:

  1. Learn how to use a console-based text editor. My favourite is vi (or vim), which takes 15 minutes to learn the basics and is much quicker for simple edits than anything else.

    vi .bashrc

  2. Copy .bashrc out to /vagrant (which is a shared directory) and edit it using your Windows editors. Make sure not to save it back with any extensions.

    cp .bashrc /vagrant ... edit using your host machine ... cp /vagrant/.bashrc .

I'd recommend getting to know the command-line based editors. Once you're working inside the VM, it's best to stay there as otherwise you might just get confused.

You (the vagrant user) are the owner of your home .bashrc so you do have permissions to edit it.

Once edited, you can execute it by typing source .bashrc I prefer to logout and in again (there may be more than one file executed on login).


Examples related to bash

Comparing a variable with a string python not working when redirecting from bash script Zipping a file in bash fails How do I prevent Conda from activating the base environment by default? Get first line of a shell command's output Fixing a systemd service 203/EXEC failure (no such file or directory) /bin/sh: apt-get: not found VSCode Change Default Terminal Run bash command on jenkins pipeline How to check if the docker engine and a docker container are running? How to switch Python versions in Terminal?

Examples related to ssh

Starting ssh-agent on Windows 10 fails: "unable to start ssh-agent service, error :1058" How to solve "sign_and_send_pubkey: signing failed: agent refused operation"? key_load_public: invalid format ssh connection refused on Raspberry Pi Getting permission denied (public key) on gitlab Verify host key with pysftp Can't connect to Postgresql on port 5432 Checkout Jenkins Pipeline Git SCM with credentials? How to open remote files in sublime text 3 how to setup ssh keys for jenkins to publish via ssh

Examples related to vagrant

vagrant primary box defined but commands still run against all boxes Psql could not connect to server: No such file or directory, 5432 error? Failed to open/create the internal network Vagrant on Windows10 Is there a default password to connect to vagrant when using `homestead ssh` for the first time? vagrant login as root by default How can I kill whatever process is using port 8080 so that I can vagrant up? Using Laravel Homestead: 'no input file specified' Error when trying vagrant up Vagrant ssh authentication failure Vagrant error : Failed to mount folders in Linux guest

Examples related to permission-denied

Error: EACCES: permission denied, access '/usr/local/lib/node_modules' PermissionError: [Errno 13] Permission denied Github permission denied: ssh add agent has no identities WinSCP: Permission denied. Error code: 3 Error message from server: Permission denied Permission denied on accessing host directory in Docker .bashrc: Permission denied C compile error: Id returned 1 exit status Executing a shell script from a PHP script Permission denied on CopyFile in VBS Node.js EACCES error when listening on most ports

Examples related to nupic

.bashrc: Permission denied