touch를 이용하여 파일 수정일자 변경하기

파일의 내용이 변경되거나 touch 명령을 사용했을때, 파일의 최종 수정 일자가 변경되게 된다.

아래와 같이 특정 파일의 최종 수정일자를 원하는대로 변경 할 수 있다.

[root@localhost root]# ls -l /etc/hosts
-rw-r–r–    1 root     root          350 10월 23  2007 /etc/hosts       <— 파일 수정일자가 2007년 10월 23일로 설정되어 있음.
[root@localhost root]# touch /etc/hosts
[root@localhost root]# ls -l /etc/hosts
-rw-r–r–    1 root     root          350  5월 28 09:59 /etc/hosts        <— touch 명령으로 입력한 후 파일 수정일자가 현재 날짜로 변경됨.
[root@localhost root]# touch -acm -t 200710241312.11 /etc/hosts
[root@localhost root]# ls -l /etc/hosts
-rw-r–r–    1 root     root          350 10월 24  2007 /etc/hosts       <— touch 에 옵션을 추가하여 2007년 10월 24일로 변경
[root@localhost root]#