5

I am new to linux, when I typed "vi FILE1" I was able to open VI editor. I added some data and I want to save the file and I tried :w but it threw me an error.

"file1" E212: Can't open file for writing Press ENTER or type command to continue

why I am not able to save it?

The directory in which I am creating file has following permissions:

drwxr-xr-x 4 pentaho pentaho 4096 Mar 12  2013 master

I am logging using root user and password.

Output of mount command :

/dev/sda1 on / type ext4 (rw)

    proc on /proc type proc (rw)
    sysfs on /sys type sysfs (rw)
    devpts on /dev/pts type devpts (rw,gid=5,mode=620)
    tmpfs on /dev/shm type tmpfs (rw)
    /dev/sdb1 on /etl type ext4 (rw)
    /dev/sdc1 on /oracle type ext4 (rw)
    /dev/sdd1 on /export type ext4 (rw)
    none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
    sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
Megha Sharma
  • 2,235
  • 8
  • 27
  • 31
  • 1
    check your file permission. – nunu Apr 30 '14 at 02:56
  • I have updated the question. kindly help me in that . I am creating the file in master directory which has permission stated above. – Megha Sharma Apr 30 '14 at 02:57
  • 4
    There are a few possibilities. You were in a directory on a read-only mounted file-system. The file belongs to a user other than root, and is in a gvfs directory, the file is on an nfs mounted file-system, and root_squash is turned on, the file doesn't have write-permissions set ... the list goes on and on ... – tink Apr 30 '14 at 02:58
  • how to check all this. kindlyhelp me resolving this issue. – Megha Sharma Apr 30 '14 at 03:02
  • file-system full? what does df says? – Laurent Parenteau Aug 29 '16 at 20:31

3 Answers3

5

You can also get this error if the directory you are trying to save to does not exist. Even the root user will get this error.

Walker Rowe
  • 953
  • 1
  • 12
  • 24
3

When you log in linux with your common user, you are logged with the user you created, but you are not superuser (you do not have all permissions). To execute a program with root priviliges (and therefore have all permissions), you have to add the command sudo. So you should run: $> sudo vi FILE1. This will ask you for the password and then you use vi normally

Troveldom
  • 356
  • 1
  • 10
0

If you are facing issue in vi, try to create directory manually and edit the file. May be you don't have access to create directory/file.