RadarURL

유닉스/리눅스
2014.04.29 17:23

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

조회 수 1566 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

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과 동일하게 변경하였다.

저작권 : 수퍼유저코리아 (www.superuser.co.kr), 무단 재배포및 복사를 금합니다

 

출처 : https://www.linux.co.kr/home/lecture/index.php?cateNo=&secNo=&theNo=&leccode=241

?

공부 게시판

공부에 도움되는 글을 올려주세요.

  1. [공지] 공부 게시판 입니다.

    Date2003.08.18 By처누 Views933239
    read more
  2. 성적 취향에 대하여...

    Date2025.12.09 Category연애 ByJaeSoo Views1
    Read More
  3. fwb(Friends with Benefits)에 대해

    Date2025.12.09 Category연애 ByJaeSoo Views1
    Read More
  4. 자위가 잠자는 데 도움이됩니까? 알아봅시다!

    Date2025.12.09 Category건강 ByJaeSoo Views1
    Read More
  5. 야동 실태보고서

    Date2025.12.09 Category건강 ByJaeSoo Views1
    Read More
  6. 불면증 해결을 위한 자위 활용

    Date2025.12.09 Category건강 ByJaeSoo Views1
    Read More
  7. 변호사가 보아온 상간남들의 공통점

    Date2025.11.25 Category연애 ByJaeSoo Views146
    Read More
  8. 윈도우11 비밀번호 분실시 설정 변경방법 (Windows10 포함)

    Date2025.11.06 Category윈도우즈 ByJaeSoo Views113
    Read More
  9. 홍콩 보내주다를 뜻하는 영어 표현 한가지를 노래를 통해 배워보자

    Date2025.10.28 Category연애 ByJaeSoo Views183
    Read More
  10. 향수 잔향 기간별 구분

    Date2025.10.28 Category생활 ByJaeSoo Views136
    Read More
  11. Question about Korean - What does 홍콩을 보내다 mean?

    Date2025.10.28 Category생활 ByJaeSoo Views169
    Read More
  12. 리눅스 서버 설치 중 에러 "Failed to find a suitable stage1 device"

    Date2025.10.03 Category유닉스/리눅스 ByJaeSoo Views176
    Read More
  13. Linux 11 . Linux 설치 시 lvm 수동설정

    Date2025.10.03 Category유닉스/리눅스 ByJaeSoo Views148
    Read More
  14. [Rocky Linux] 누구나 쉽게 따라하는 Rocky Linux 9.0 OS 다운로드 및 설치 방법~!!

    Date2025.10.03 Category유닉스/리눅스 ByJaeSoo Views180
    Read More
  15. Linux/Rocky Linux Rocky Linux : Composer 설치

    Date2025.09.29 Category유닉스/리눅스 ByJaeSoo Views184
    Read More
  16. [Rocky Linux] 록키 리눅스 최신 업데이트 적용 방법

    Date2025.09.29 Category유닉스/리눅스 ByJaeSoo Views187
    Read More
  17. rocky linux 커널 업데이트

    Date2025.09.29 Category유닉스/리눅스 ByJaeSoo Views211
    Read More
  18. [Windows] OWASP ZAP 사용법

    Date2025.09.29 Category웹서버,WAS ByJaeSoo Views170
    Read More
  19. [웹 취약점] 웹서버 디렉토리 리스팅 방지

    Date2025.09.29 Category웹서버,WAS ByJaeSoo Views168
    Read More
  20. Clonezilla(클론질라) 백업파일 하드디스크로 복구 방법

    Date2025.09.28 Category유닉스/리눅스 ByJaeSoo Views182
    Read More
  21. 클론질라 사용 방법 - OS 이미지 백업 CloneZilla

    Date2025.09.28 Category유닉스/리눅스 ByJaeSoo Views226
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 126 Next
/ 126


즐겨찾기 (가족)

JAESOO's HOMEPAGE


YOUNGAE's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

숭실대 컴퓨터 통신연구실 (서창진)

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

아스가르드 좋은사람/나쁜사람

JServer.kr

제이서버 메타블로그

재수 티스토리


즐겨찾기 (강의, 커뮤니티)

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너