Skip to main content
edited tags
Link
Gilles 'SO- stop being evil'
  • 865.9k
  • 205
  • 1.8k
  • 2.3k
Minor corrections
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

Why does chmod succeedssucceed on a file when the user does not have write permission on parent directory?

I am trying to understand file/dir permissions in linuxLinux. A user can list the files in a directory using

cd test ls -l 

Even if the user issuing above commandcommands does not have read,write write or execute permission on any of the files inside the test directory, still he can list them because he/she has read permissions on the test directory.

Then why in the following scenario user B can change permissions of a file he owns but does not have write permissions of the parent directory  ?

User A  , makemakes a test directory and gives other users ability to write in it:

mkdir test chmod o+w test 

User B  , creates a file in test folder.

cd test touch b.txt 

User A ,removesremoves write permission of others from the directory

chmod o-w test 

User B  , can successfully change permissions, even though permissions are part of directory and this user does not have write permission on the parent directory of the file he owns

chmod g-r b.txt 

why does chmod does chmod not fail aftersince the user can notcannot modify the directory which has the file information - permissions etc ??

Why chmod succeeds on a file when user does not have write permission on parent directory?

I am trying to understand file/dir permissions in linux. A user can list the files in a directory using

cd test ls -l 

Even if the user issuing above command does not have read,write or execute permission on any of the files inside the test directory, still he can list them because he/she has read permissions on the test directory.

Then why in the following scenario user B can change permissions of a file he owns but does not have write permissions of the parent directory  ?

User A  , make a test directory and gives other users ability to write in it

mkdir test chmod o+w test 

User B  , creates a file in test folder.

cd test touch b.txt 

User A ,removes write permission of others from the directory

chmod o-w test 

User B  , can successfully change permissions, even though permissions are part of directory and this user does not have write permission on the parent directory of the file he owns

chmod g-r b.txt 

why does chmod does not fail after user can not modify the directory which has the file information - permissions etc ??

Why does chmod succeed on a file when the user does not have write permission on parent directory?

I am trying to understand file/dir permissions in Linux. A user can list the files in a directory using

cd test ls -l 

Even if the user issuing above commands does not have read, write or execute permission on any of the files inside the test directory, still he can list them because he/she has read permissions on the test directory.

Then why in the following scenario user B can change permissions of a file he owns but does not have write permissions of the parent directory?

User A, makes a test directory and gives other users ability to write in it:

mkdir test chmod o+w test 

User B, creates a file in test folder.

cd test touch b.txt 

User A removes write permission of others from the directory

chmod o-w test 

User B, can successfully change permissions, even though permissions are part of directory and this user does not have write permission on the parent directory of the file he owns

chmod g-r b.txt 

why does chmod not fail since the user cannot modify the directory which has the file information - permissions etc?

edited title
Link
Ahmed
  • 227
  • 2
  • 10

Why chmod succeeds on a file when user does not have write permission on parent directory?

Source Link
Ahmed
  • 227
  • 2
  • 10
Loading