Can vi able to modify readonly file ?

Solution Unverified - Updated -

Issue

A directory has these permissions:

dr-xrwxr-x 2 UA listener 4096 Dec 19 14:13 risk/

A file in it has:

-r--rw-r-- 1 UA listener 5 Dec 19 14:42 something

listener:x:65858:mutt,jeff

Now, as user UA:

-bash-3.2$ cat risk/something  
junk

-bash-3.2$ rm risk/something  
rm: remove write-protected regular file `risk/something'? y  
rm: cannot remove `risk/something': Permission denied

as expected.

-bash-3.2$ vi risk/something

treasure  
~  
~  
~  
~  
~  
~  
"risk/something" \[Modified\]\[readonly\] line 1 of 1 --100%-- col 8

w!

"risk/something" 1L, 9C written
-bash-3.2$ cat risk/something  
treasure

vi is not a setuid program

-bash-3.2$ ls -l \`which vi\`  
-rwxr-xr-x 1 root root 632912 Jun 12  2009 /bin/vi

The filesystem is a logical volume:

/dev/mapper/sysvg-rootlv

Environment

  • RHEL(all versions)
  • vim

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content