Change file time (touch)

I would like to be able to change the file modification date for use in a web application. While I'm testing this directly on the command line. Works fine on my mac, but when I do this on a Linux server, get an error.

Command: / bin / touch -m -t 200906041200 / foo / bar / file.whatever

Error: / bin / touch: installation time `/foo/bar/file.whatever ': operation not allowed

This file is 777.

+4
source share
3 answers

On Linux, you must be the owner of the file (or root) to change the modification time to a time other than the current one. There are other limitations. man utime for complete details.

+6
source

Despite the fact that file permissions can be read / written for the owner, group and others, I believe that you really need to have a file to change the atime for the file in question.

+1
source

Do you use noatime ? This may explain the problem.

0
source

Source: https://habr.com/ru/post/1285775/


All Articles