Skip to content

Change ctime crtime of file

Goal: set changes time (ctime) and creation/birthday time (crtime) of file based on other file

ext4 Tested FS: ext4

touch /home/user/test.file
FF='/home/user/test.file'
ETALON='/bin/bash'
DT=$(stat -c '%W' $ETALON | awk '{print $1}')
FS=$(df $FF | tail -n 1 | awk '{print $1}')
NEWDT=$(date -d @$DT +%Y%m%d%H%M%S)
#
PAR1="-w -R 'set_inode_field $FF ctime $NEWDT' $FS"
echo ""
echo "RUN for ctime:"
echo sudo debugfs $PAR1
#
PAR1="-w -R 'set_inode_field $FF crtime $NEWDT' $FS"
echo ""
echo "RUN for ctime:"
echo sudo debugfs $PAR1
echo ""
echo "RUN as root: echo 2 > /proc/sys/vm/drop_caches"