In the context of Java programming language, if you are getting the issue of “chmod operation not permitted” then it could be due to that users don’t have the required permissions to change the mode of the file.
Here are the steps given for how you can solve this particular issue:-
File ownership
First, check the ownership of the file by using the 1s- 1 command. If you are not the owner of a file then you would not be able to change the file. However, you can use the “chown” command to change the ownership of the file if needed.
File system permission
Ensure that your file system is not mounted as read only. Remount the file system with writing permission “mount-o remount,rw”/path/to/filesystem”
Elevated Privileges
You can use the “sudo” if you have not the required administrative access.
Access control lists(ACLs)
Check if there are any ACLs set on the file which can restrict your permission. You can use the “getfacl” for viewing the ACLs and “setfacl” for modifying them.
Here is the example given by using the Bash:-
#!/bin/bash
# Change file ownership
Sudo chown new_owner:new_group file
# Remount file system with write permissions
Sudo mount -o remount,rw /path/to/filesystem