Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify 'last status change' (ctime) property of a file in Unix?

Tags:

unix

ctime

I know there's a way to modify both 'modification' (mtime) and 'last access' (atime) time properties of a given file in Unix System by using "touch" command. But I'm wondering whether there exists a way to modify "Last status change" (ctime) property, as well?

like image 449
Emil Avatar asked Dec 01 '11 19:12

Emil


People also ask

How do I change a ctime file in Linux?

atime and mtime timestamps can be easily changed using touch command, but there is no a standard way to set a different ctime timestamp. As a possible workaround you can set the system time to the ctime you want to impose, then touch the file and then restore the system time.

How do I change the date modified on a file in Unix?

You can change both access and modification time of a file using the option -a and -m together.

What is ctime of a file?

ctime refers to the last time when a file's metadata. For example, if permission settings of a file were modified, ctime will indicate it. To see the changed timestamp, we can use -lc option with the ls command as follows: Syntax: ls -lc [filename]


1 Answers

ctime is the time the file's inode was last changed. mtime is the last time the file's CONTENTS were changed. To modify ctime, you'll have to do something to the inode, such as doing a chmod or chown on the file.

Changing the file's contents will necessarily also update ctime, as the atime/mtime/ctime values are stored in the inode. Modifying mtime means ctime also gets updated.

like image 185
Marc B Avatar answered Sep 21 '22 20:09

Marc B