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?

2 Answers 2

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 ? Oct 19, 2020 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. Oct 19, 2020 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 ? Oct 19, 2020 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, 2020 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .