0

I know i can set read , write and execute permission to a file with chmod but can i take away the permission to delete, write and execute?

0

Removing is done by setting only the parts you want. For example, to remove write, and execute you would set the permission to 4 for that category of user. So to make only the owner have read, write, and execute and everyone else only read on a file you would use:

chmod 0744 ./target_file

Delete is done using write and execute on the directory that holds the file. In this example you could only allow the owner of the directory to delete files with:

chmod 0755 .
2
  • if a folder doest allow write can i still write inside a file if that file has the permission ? – hatmaster1qa Oct 19 '20 at 18:01
  • Yes, the directory permissions will control the files that can be added or removed from the directory, but not if the file itself can change. – user1794469 Oct 19 '20 at 20:25
0

The "delete" permission is not connected to the file. To delete a file, one requires "write" access to the file's parent directory.

Unsetting the write or execute permissions requires reading man chmod, but is easy.

2
  • if a folder doest allow write can i still write inside a file if that file has the permission ? – hatmaster1qa Oct 19 '20 at 18:01
  • Yes, you can. Write permission on a directory only controls the ability to create new files in that directory, or delete existing files from it. – patbarron Oct 19 '20 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.