Permission denied when I try to change a file’s access and modification times
I can't change a file’s access and modification times. When I enter touch t- CCYYMMDDhhmm.SS file.example
, I get "permission denied". It works for other files. I tried to use chmod +x file.example
but I am not sure I am using it correctly. What should I write, please ?
Solution 1:
The command should be touch -t (date) file.example
chmod +x
just makes the file executable – it should not affect the date - but if you still want to use it, you can do it like this:
chmod +x file.example
touch -t 0401200 file.example
Also, check that you have write permissions on the file by running ls -l file.example
(or right-click on the file in Finder and choose Get Info, then look at 'Sharing & Permissions').