can't open file for editing

I've created a user and would like to an an alias to the .bashrc file, however when I use vi and write to the file the following is displayed:

".bashrc" E212: Can't open file for writing. Hit ENTER or type command to continue.

Entry within /etc/passwd for this user reads:
maqui:x:513:516::/home//maqui::/bin/bash
:confused:

which os?

how did u create a user ? did u create your home directory manually ? do u have enough permission to write into file ?

  • nilesh.

Thanks for the hint :slight_smile: I created .bashrc manually and now it seems to work. So basically:

  1. I created user using adduser
  2. Updated alias within the home directory i.e. /home/<user>
  3. Updated permissions on the source file using chmod 755, so that the user can execute the file.

Did I "allow too much" in step 3?

What do you mean by "alias"? A symbolic link to /etc/skel/.bashrc? Doesn't adduser automatically copy in a fresh .bashrc for you?

If you are editing .bashrc and it's a symbolic link, you need write permission to the target of the symbolic link. But instead, you should have a separate file owned by the user, usually a copy of /etc/skel/.bashrc

If you are editing a file owned by a different user, you need to be root, or the file's permissions need to be relaxed enough to allow you to overwrite the file (and, the way editors often work, probably write access to the directory). This is of course not really a good idea in any event.

.bashrc doesn't need execute permission, it's sourced (not executed) by bash.