RadarURL
Skip to content
조회 수 1371 추천 수 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. CC 및 GCC 컴파일러 설치와 환경 설정

    Date2004.06.09 By처누 Views16696
    Read More
  2. 리눅스 rawrite 유틸리티 사용하기

    Date2006.01.03 ByJaeSoo Views36369
    Read More
  3. 리눅스 외부 드라이버 로딩을 위한 dd 명령어 사용하기

    Date2006.01.03 ByJaeSoo Views15258
    Read More
  4. Linux서버에 오라클10g 설치하기

    Date2007.04.15 ByJaeSoo Views8892
    Read More
  5. Tomcat을 버젼별로 실행하기

    Date2007.06.08 ByJaeSoo Views7592
    Read More
  6. 리눅스 파일 시스템에서 숨김 속성 적용 방법

    Date2010.02.08 ByJaeSoo Views10952
    Read More
  7. 페도라12 yum(rpm)으로 APM 설치 (수호신패치 포함)

    Date2011.06.08 ByJaeSoo Views12310
    Read More
  8. Micosoft Windows에서 리눅스를 coLinux!!

    Date2012.11.30 ByJaeSoo Views5544
    Read More
  9. SULinux 2.0 설치 가이드

    Date2012.12.06 ByJaeSoo Views65157
    Read More
  10. SULinux 2.0 APM 인스톨 툴

    Date2012.12.06 ByJaeSoo Views5579
    Read More
  11. Apache/FastCGI

    Date2013.03.08 ByJaeSoo Views5915
    Read More
  12. nobody 디렉토리 삭제가 안될 때

    Date2013.04.01 ByJaeSoo Views6941
    Read More
  13. 리눅스 tar, gz 압축 및 해제

    Date2014.03.25 ByJaeSoo Views1326
    Read More
  14. Linux FTP 설정, vsftpd 설정

    Date2014.03.25 ByJaeSoo Views1288
    Read More
  15. vsftpd 실행하기

    Date2014.03.25 ByJaeSoo Views870
    Read More
  16. vsFTP ftp로 root 계정 접속

    Date2014.03.25 ByJaeSoo Views1098
    Read More
  17. 레드햇,우분투 리눅스(Linux) 다운로드

    Date2014.03.27 ByJaeSoo Views1068
    Read More
  18. touch (파일의 날짜시간정보를 변경)

    Date2014.04.29 ByJAESOO Views1371
    Read More
  19. vsftp root로 접속하기

    Date2014.04.29 ByJAESOO Views1369
    Read More
  20. 스트러츠와 스프링의 비교

    Date2014.05.09 ByJAESOO Views1414
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 Next
/ 9

PageViews   Today : 11435 Yesterday : 5037 Total : 21967487  /  Counter Status   Today : 11065 Yesterday : 4602 Total : 1193788

Edited by JAESOO

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소