No User Modification That Changed The Games Checksum
In Linux (currently using ext4 filesystem), how can one check quickly if the contents of a file has been modified without reading any of its contents?
Fastest way to check if InnoDB table has changed. Ask Question 19. There are live checksums that are precalculated on table modification and are VERY fast. However, there is no such thing in InnoDB. So, CHECKSUM TABLE is VERY slow. I've hoped to be able to check the last update time of the table, Unfortunately, this is not available in.
Is the stat
command a recommended approach? I currently do
and later I can check if the same command yields the same output. If it does, I conclude that hello.txt has not changed.
My feeling is that one wants to throw in more parameters to be even more sure. For example, would adding the file size, file name, etc, provide an even better 'fingerprint' of the file?
On this topic, I recall that a TrueCrypt volume I once had was always ignored by my incremental backup program, possibly because TrueCrypt made sure to leave no meta data changes behind. I suppose it is indeed possible to change all the data returned by stat
, hence it cannot be guaranteed to pick up on every possible modification of the file?
3 Answers
If you want to detect whether a file has been modified through normal means (editing it in some application, checking out a new version from a revision control systems, rebuilding it, etc.), check whether its modification time (mtime) has changed from the last check. That's what stat -c %Y
reports.
The modification time can be set by the touch
command. If you want to detect whether the file has changed in any way (including the use of touch
, extracting an archive, etc.), check whether its inode change time (ctime) has changed from the last check. That's what stat -c %Z
reports. The ctime cannot be spoofed except by the system administrator (and even then, only through indirect means: by changing the system clock, or by accessing the disk directly, bypassing the filesystem).
Ck2 Beta
GillesGillesCk2 Changes
The stat command only has a resolution of a second. So if the file was modified twice in the same second you could miss a modification. Newer filesystems like ext4 provide higher resolution timestamps in nanoseconds, but some of the old tools haven't caught up yet.
Also, it's possible for other programs to set an arbitrary modification time. You can see how this can happen via the touch command.
If you're concerned about either of those two possibilities it wouldn't be a bad idea to look at the file size as well. This is what rsync does when it's looking for modified files.
My feeling is that one wants to throw in more parameters to be even more sure.
What you have is the correct method. The only reason for that to fail would be if the filesystem is not updating properly -- in which case you will end up with a whole bunch of more serious problems.
Of course, I presume someone with the right knowledge and root access to a system where the partition is accessible might be able to alter the information to make it look as if the file hasn't been changed. However, in this case they would surely have made sure to do the same with the size, etc.
goldilocksgoldilocksNot the answer you're looking for? Browse other questions tagged filestimestampsstat or ask your own question.
I would like git to give me a list of all the files modified by one user, across all commits.
My particular use case is that I've been involved in the i18n of a ruby on rails project, and we want to know what files have already been done and what files still need to be done. The users in question have only done work on the i18n, not on the rest of the code base. So the information should all be in git, but I'm not sure how to get it out.
Thomas W3 Answers
This isn't the only way, but it works:
Or, as one line:
Steve PrenticeSteve PrenticeThis will give you a simple list of files, nothing else:
Switch --author for --committer as necessary.
Ian KellingTry git log --stat --committer=<user>
. Just put the user's name on the --committer=
option (or use --author=
as appropriate).
This will spit out all the files per commit, so there will likely be some duplication.
Robert S.Robert S.