Skip to main content
added 150 characters in body
Source Link
prado
  • 970
  • 1
  • 12
  • 35

I have a file named file.txt with some contents located in /home/myuser directory and I change the permissions of that file to root.root and 644.

-rw-r--r-- 1 root root 1.4K Jan 15 07:09 file.txt 

Then I switched to myuser and opened it with vim(without sudo) and tried to edit and save it :wq! and I got output like:

"file.txt" E949: File changed while writing Press ENTER or type command to continue 

Then I hit enter and then again :wq! and the output was :

WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)? 

I hit y, the file got saved and exit from vim.

The question is why a file with ROOT privileges and read-only access for a user changed by the way?

PS: 1. myuser is a sudo user.

  1. The user permissions after saving the file changed to myuser.myuser as well.

    -rw-r--r-- 1 myuser myuser 1.4K Jun 27 18:57 file.txt

I have a file named file.txt with some contents located in /home/myuser directory and I change the permissions of that file to root.root and 644.

-rw-r--r-- 1 root root 1.4K Jan 15 07:09 file.txt 

Then I switched to myuser and opened it with vim(without sudo) and tried to edit and save it :wq! and I got output like:

"file.txt" E949: File changed while writing Press ENTER or type command to continue 

Then I hit enter and then again :wq! and the output was :

WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)? 

I hit y, the file got saved and exit from vim.

The question is why a file with ROOT privileges and read-only access for a user changed by the way?

PS: myuser is a sudo user.

I have a file named file.txt with some contents located in /home/myuser directory and I change the permissions of that file to root.root and 644.

-rw-r--r-- 1 root root 1.4K Jan 15 07:09 file.txt 

Then I switched to myuser and opened it with vim(without sudo) and tried to edit and save it :wq! and I got output like:

"file.txt" E949: File changed while writing Press ENTER or type command to continue 

Then I hit enter and then again :wq! and the output was :

WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)? 

I hit y, the file got saved and exit from vim.

The question is why a file with ROOT privileges and read-only access for a user changed by the way?

PS: 1. myuser is a sudo user.

  1. The user permissions after saving the file changed to myuser.myuser as well.

    -rw-r--r-- 1 myuser myuser 1.4K Jun 27 18:57 file.txt

Source Link
prado
  • 970
  • 1
  • 12
  • 35

User is able to edit a file using vim

I have a file named file.txt with some contents located in /home/myuser directory and I change the permissions of that file to root.root and 644.

-rw-r--r-- 1 root root 1.4K Jan 15 07:09 file.txt 

Then I switched to myuser and opened it with vim(without sudo) and tried to edit and save it :wq! and I got output like:

"file.txt" E949: File changed while writing Press ENTER or type command to continue 

Then I hit enter and then again :wq! and the output was :

WARNING: The file has been changed since reading it!!! Do you really want to write to it (y/n)? 

I hit y, the file got saved and exit from vim.

The question is why a file with ROOT privileges and read-only access for a user changed by the way?

PS: myuser is a sudo user.