touch (파일의 날짜시간정보를 변경)

touch

touch는 파일의 날짜시간정보를 변경하는 명령어이다.
즉 아무런 옵션이 없다면 파일의 최근에 사용한 시간과 최근에 변경된 시간을 서버의 현재시간으로 변경한다.
만약 지정된 명령어가 존재하지 않는다면 파일의 크기가 0인 빈 파일을 생성한다.

-t라는 옵션을 사용하면 서버의 현재시간이 아닌 지정된 시간으로 파일의 날짜시간정보를 변경한다.


명령어 사용형식

touch [-acfm] [-r file] [-t MMDDhhmm[[CC]YY][.ss]] [-d time]
[--time={atime,access,use,mtime,modify}] [--date=time] [--reference=file] [--no-create]
[--help] [--version] file...


사용예 #1

먼저 첫번째 예로서 아무런 옵션없이 파일이름만 지정하면 서버의 현재시간을 가진 비어있는 파일을 생성한다.

[root@host1 commmand]# touch file1
[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 9월 10 13:05 file1
[root@host1 commmand]#

위의 예에서 file1이라는 파일이 서버의 현재 날짜시간으로 크기가 0인 파일이 생성이 되었다.

그러나 -c 옵션을 사용한다면 존재하지 않은 파일일 경우에는 파일을 생성하지 않는다.

[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 9월 10 13:05 file1
[root@host1 commmand]#
[root@host1 commmand]# touch -c file2
[root@host1 commmand]#
[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 9월 10 13:05 file1
[root@host1 commmand]#

위와 같이 -c옵션을 사용하였을 경우에는 지정된 파일(file2)가 존재하지 않는다면 새로 생성하지 않는다.




사용예 #2

다음은 특정 파일의 날짜시간을 지정된 날짜시간정보로 변경하는 예이다.

[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 9월 10 13:05 file1
[root@host1 commmand]#
[root@host1 commmand]# touch -t 09100111 file1
[root@host1 commmand]#
[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 9월 10 01:11 file1
[root@host1 commmand]#

file1이라는 파일의 시간정보는 처음 생성되었던 정보인 "9월 10일 13시 5분"이였다.
그런데 "touch -t 09100111 file1"라는 명령어로 시간정보를 "9월 10일 01시 11분"으로 변경하였다.
위와 같이 -t옵션을 사용하여 특정한 날짜시간으로 파일의 정보를 변경할때에는 "MMDDhhmm[[CC]YY][.ss]"의 형식을 사용한다.


다음은 현재 날짜보다 이전날짜로 file1의 날짜를 변경하였을때의 예이다.

[root@host1 commmand]# touch -t 03050111 file1
[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 3월 5 2003 file1
[root@host1 commmand]#

file1의 날짜시간정보를 "3월5일 01시 11분"으로 변경한 것이다.

만약 아무런 이유없이 특정파일(특히 관리자용 명령어)의 시간정보가 변경이 되었다면 해킹을 의심해 보아야한다.
따라서 서버관리자는 파일의 시간정보및 퍼미션정보등이 변경되었는가를 주기적으로 점검하여 해야한다.


사용예 #3

이번에는 특정파일의 날짜시간정보를 이용하여 지정된 파일의 날짜시간정보를 변경하는 예이다.

[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 3월 5 2003 file1
-rw-r--r-- 1 root root 0 9월 10 13:05 file2
[root@host1 commmand]#
[root@host1 commmand]# touch -r file1 file2
[root@host1 commmand]# ls -l
합계 0
-rw-r--r-- 1 root root 0 3월 5 2003 file1
-rw-r--r-- 1 root root 0 3월 5 2003 file2
[root@host1 commmand]#

위에서 -r 옵션을 사용하여 file2의 날짜시간정보를 file1과 동일하게 변경하였다.

크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2004/03/05 09:57 2004/03/05 09:57
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/178

Trackback URL : http://tcbs17.cafe24.com/tc/trackback/178

« Previous : 1 : ... 6126 : 6127 : 6128 : 6129 : 6130 : 6131 : 6132 : 6133 : 6134 : ... 6391 : Next »

블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2024/05   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Statistics Graph

Site Stats

Total hits:
186091
Today:
349
Yesterday:
745