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. No Image 09Jun
    by 처누
    2004/06/09 by 처누
    Views 16696 

    CC 및 GCC 컴파일러 설치와 환경 설정

  2. No Image 03Jan
    by JaeSoo
    2006/01/03 by JaeSoo
    Views 36369 

    리눅스 rawrite 유틸리티 사용하기

  3. No Image 03Jan
    by JaeSoo
    2006/01/03 by JaeSoo
    Views 15258 

    리눅스 외부 드라이버 로딩을 위한 dd 명령어 사용하기

  4. No Image 15Apr
    by JaeSoo
    2007/04/15 by JaeSoo
    Views 8892 

    Linux서버에 오라클10g 설치하기

  5. No Image 08Jun
    by JaeSoo
    2007/06/08 by JaeSoo
    Views 7592 

    Tomcat을 버젼별로 실행하기

  6. No Image 08Feb
    by JaeSoo
    2010/02/08 by JaeSoo
    Views 10952 

    리눅스 파일 시스템에서 숨김 속성 적용 방법

  7. 페도라12 yum(rpm)으로 APM 설치 (수호신패치 포함)

  8. Micosoft Windows에서 리눅스를 coLinux!!

  9. No Image 06Dec
    by JaeSoo
    2012/12/06 by JaeSoo
    Views 65157 

    SULinux 2.0 설치 가이드

  10. No Image 06Dec
    by JaeSoo
    2012/12/06 by JaeSoo
    Views 5576 

    SULinux 2.0 APM 인스톨 툴

  11. No Image 08Mar
    by JaeSoo
    2013/03/08 by JaeSoo
    Views 5915 

    Apache/FastCGI

  12. No Image 01Apr
    by JaeSoo
    2013/04/01 by JaeSoo
    Views 6941 

    nobody 디렉토리 삭제가 안될 때

  13. No Image 25Mar
    by JaeSoo
    2014/03/25 by JaeSoo
    Views 1326 

    리눅스 tar, gz 압축 및 해제

  14. No Image 25Mar
    by JaeSoo
    2014/03/25 by JaeSoo
    Views 1288 

    Linux FTP 설정, vsftpd 설정

  15. No Image 25Mar
    by JaeSoo
    2014/03/25 by JaeSoo
    Views 870 

    vsftpd 실행하기

  16. No Image 25Mar
    by JaeSoo
    2014/03/25 by JaeSoo
    Views 1098 

    vsFTP ftp로 root 계정 접속

  17. No Image 27Mar
    by JaeSoo
    2014/03/27 by JaeSoo
    Views 1068 

    레드햇,우분투 리눅스(Linux) 다운로드

  18. No Image 29Apr
    by JAESOO
    2014/04/29 by JAESOO
    Views 1371 

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

  19. No Image 29Apr
    by JAESOO
    2014/04/29 by JAESOO
    Views 1369 

    vsftp root로 접속하기

  20. No Image 09May
    by JAESOO
    2014/05/09 by JAESOO
    Views 1414 

    스트러츠와 스프링의 비교

Board Pagination Prev 1 2 3 4 5 6 7 8 9 Next
/ 9

PageViews   Today : 6243 Yesterday : 5037 Total : 21962295  /  Counter Status   Today : 6036 Yesterday : 4602 Total : 1188759

Edited by JAESOO

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


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

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

설치 취소