troubleshooting Question

POSIX file checking semantics

Avatar of perlperl
perlperl asked on
LinuxUnix OSC
6 Comments4 Solutions548 ViewsLast Modified:
I am trying to understand why does POSIX behaves in this wierd manner.

1) I created two users "user_a" and "user_b" and both belongs to same "group"

2) sudo "user_a".
   a) Created a Dir /home/users/dir_1.  The owner is "user_a" and permission is 777.    
   b) Created a file /home/user/dir_1/file.txt with permission 644 and owner is "user_a"

3) sudo "user_b"
    a) cd /home/user/dir_1
    b) echo "test" >> file.txt     fails with "Permission Denied" as expected.
    c) vi file.txt opens the file warns its a "Read Only" mode. Then I write at the end of file and close vi with !wq.  BOOM, the write succeeded and I verified using cat that the write got commited to the disk.

Why on earth Unix allows to write using 3.c but fails during 3.b.
 3.c should have failed with "permission denied" but it does not
lab engineer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 4 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros