English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

My references only say that I should save it using :w! but I keep getting the message "Cant open file for writing".

2006-08-07 05:31:52 · 5 answers · asked by ongraiden 3 in Computers & Internet Programming & Design

Its a permissions issue but I am able to open the file and read it.

2006-08-07 06:29:08 · update #1

5 answers

its a permissions issue. If you can't open the file you don't even have read access for it.

You should be able to run "ls -la filename" which will list the file as well as a lot of other data. At the beginning of the line will be something like "-rw-r----- {owner} {group}..." the way this is set up is:
- -> type of file, usually you will see a d for directory, there are a number of other types

rw- -> owner permissions r for read w for write - for not executable (could also be x)

ditto on the next two sets of three (r-- for read only group and --- for no permissions global)

If you aren't the owner and aren't in the same group (run "whoami" to find your group) you have the global permissions.

if you can read it, either copy it to your home directory, or a directory where you have permissions to write, and edit it there or while editing type ":w ~/filename"

2006-08-07 05:55:07 · answer #1 · answered by John J 6 · 0 0

It's not a vi issue, it'll be a permissions issue. Make sure you have write permissions on the file before editing it.

For example, if you're a normal user editing something in /etc/, you shouldn't be able to save that file. For that, you'd need to be root.

2006-08-07 12:35:38 · answer #2 · answered by mike_w40 3 · 0 0

The file may be open by another process and my not allow writing. You can do the following

Make a copy of the original and edit the copy.
Identify and close the program that hold the original file and copy over the new file to old one

2006-08-07 12:36:52 · answer #3 · answered by moviedhamaka 2 · 0 0

Try changing the permissions of the file. If you do not own the file, do a chown to make you the owner (have to be root to do this) Or the file could just be a read only file so you have to chmod it to a level that can be modified. Always make a backup of the file before you try to edit it.

2006-08-07 12:38:27 · answer #4 · answered by Anonymous · 0 0

You probably don't have the right permissions to overwrite the file. You may need to be root to overwrite the file. Try saving the file somewhere else, by doing:

:w ~/filename.txt

and then become root or use sudo to copy the new file over the old file.

2006-08-07 12:37:02 · answer #5 · answered by Bryan A 5 · 0 0

fedest.com, questions and answers