본문 바로가기
조회 수 5637 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
MAC times in Linux (atime, mtime, ctime, crtime, touch)

atime - 파일 접근시간(읽기)
mtime - 파일 내용 변경시간
ctime - 파일 속성 변경시간

############################
# Find MAC times with stat
############################

[root@centos6 temp]# stat test.txt 
  File: `test.txt'
  Size: 4         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d Inode: 274836      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-01-13 09:08:41.663695869 +0000 <--------- the last time the file was read
Modify: 2015-01-13 09:08:49.403695067 +0000 <--------- the last time the file was modified (content has been modified)
Change: 2015-01-13 09:08:49.403695067 +0000 <--------- the last time meta data of the file was changed (e.g. permissions)

###########################################
# Find MAC times + creation time debugfs 
###########################################

[root@centos6 temp]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       18G  6.9G  9.6G  42% /
tmpfs                 1.9G     0  1.9G   0% /dev/shm
/dev/sda1             485M   62M  398M  14% /boot

[root@centos6 temp]# ls -i test.txt 
274836 test.txt

[root@centos6 temp]# debugfs -R 'stat <274836>' /dev/mapper/VolGroup-lv_root
debugfs 1.41.12 (17-May-2010)
Inode: 274836   Type: regular    Mode:  0644   Flags: 0x80000
Generation: 319784155    Version: 0x00000000:00000001
User:     0   Group:     0   Size: 4
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 8
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x54b4e0a1:603f976c -- Tue Jan 13 09:08:49 2015
 atime: 0x54b4e099:9e3cc7f4 -- Tue Jan 13 09:08:41 2015
 mtime: 0x54b4e0a1:603f976c -- Tue Jan 13 09:08:49 2015
crtime: 0x54b4e099:9e3cc7f4 -- Tue Jan 13 09:08:41 2015 <-------------- actual file creation time (파일 생성 시간)
Size of extra inode fields: 28
Extended attributes stored in inode body: 
  selinux = "unconfined_u:object_r:admin_home_t:s0\000" (38)
EXTENTS:
(0): 1112092

#########
# TEST
#########

** file read (cat test.txt)

[root@centos6 temp]# stat test.txt
  File: `test.txt'
  Size: 4         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d Inode: 274836      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-01-13 09:11:14.807695361 +0000 <---------------- atime 변경됨
Modify: 2015-01-13 09:08:49.403695067 +0000
Change: 2015-01-13 09:08:49.403695067 +0000

** file permission change (chmod 755 test.txt)

[root@centos6 temp]# stat test.txt
  File: `test.txt'
  Size: 4         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d Inode: 274836      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-01-13 09:12:45.667695389 +0000
Modify: 2015-01-13 09:12:45.667695389 +0000
Change: 2015-01-13 09:16:37.705696756 +0000 <----------- ctime 변경됨 (속성변경시 변경)

** file content change (echo 'A' >> test.txt)

[root@centos6 temp]# stat test.txt
  File: `test.txt'
  Size: 6         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d Inode: 274836      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-01-13 09:12:45.667695389 +0000
Modify: 2015-01-13 09:18:03.540698285 +0000 <-------------- mtime 변경됨 (파일내용 변경시 변경)
Change: 2015-01-13 09:18:03.540698285 +0000 <-------------- ctime도 변경됨 (어떤 파일 속성이 변경??)

###################
# TEST with touch
###################

** file touch (touch test.txt) - MAC 모두 변경됨. 파일 생성시간은 변경되지 않음

[root@centos6 temp]# stat test.txt
  File: `test.txt'
  Size: 4         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d Inode: 274836      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-01-13 09:12:45.667695389 +0000 <----------------- MAC 모두 변경됨
Modify: 2015-01-13 09:12:45.667695389 +0000 <----------------- MAC 모두 변경됨
Change: 2015-01-13 09:12:45.667695389 +0000 <----------------- MAC 모두 변경됨

[root@centos6 temp]# debugfs -R 'stat <274836>' /dev/mapper/VolGroup-lv_root
debugfs 1.41.12 (17-May-2010)
Inode: 274836   Type: regular    Mode:  0644   Flags: 0x80000
Generation: 319784155    Version: 0x00000000:00000001
User:     0   Group:     0   Size: 4
File ACL: 0    Directory ACL: 0
Links: 1   Blockcount: 8
Fragment:  Address: 0    Number: 0    Size: 0
 ctime: 0x54b4e18d:9f30e474 -- Tue Jan 13 09:12:45 2015 <----------------- MAC 모두 변경됨
 atime: 0x54b4e18d:9f30e474 -- Tue Jan 13 09:12:45 2015 <----------------- MAC 모두 변경됨
 mtime: 0x54b4e18d:9f30e474 -- Tue Jan 13 09:12:45 2015 <----------------- MAC 모두 변경됨
crtime: 0x54b4e099:9e3cc7f4 -- Tue Jan 13 09:08:41 2015 <----------------- 파일 생성시간은 변경되지 않음
Size of extra inode fields: 28
Extended attributes stored in inode body: 
  selinux = "unconfined_u:object_r:admin_home_t:s0\000" (38)
EXTENTS:
(0): 1112092

** touch (atime 변경 - 파일 접근시간) - ctime도 자동으로 변경됨

touch test.txt
touch -a test.txt
stat test.txt

[root@centos6 temp]# stat test.txt
  File: `test.txt'
  Size: 6         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d Inode: 274838      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (   99/  nobody)   Gid: (   99/  nobody)
Access: 2015-01-13 09:27:03.920695998 +0000 <------------------- atime 변경됨
Modify: 2015-01-13 09:27:00.423696102 +0000
Change: 2015-01-13 09:27:03.920695998 +0000 <------------------- ctime 변경됨

** touch (mtime 변경 - 파일내용 변경시간) - ctime도 자동으로 변경됨

touch test.txt
touch -m test.txt
stat test.txt

[root@centos6 temp]# stat test.txt
  File: `test.txt'
  Size: 6         Blocks: 8          IO Block: 4096   regular file
Device: fd00h/64768d Inode: 274838      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (   99/  nobody)   Gid: (   99/  nobody)
Access: 2015-01-13 09:27:51.742695815 +0000
Modify: 2015-01-13 09:28:16.324695934 +0000 <------------------- mtime 변경됨
Change: 2015-01-13 09:28:16.324695934 +0000 <------------------- ctime 변경됨


Title
List of Articles
번호 제목 글쓴이 날짜 조회 수
448 How to install Java on linux with no Internet connectivity (using local repository) Hojung 2015.12.22 4057
447 How to install tcpreplay on CentOS 6.5 Hojung 2015.08.21 9119
446 Install et131x network interface driver in CentOS 6 (LW25-BDUO3) file Hojung 2015.07.03 5172
445 How to find CentOS and kernel version Hojung 2015.04.30 4486
444 MD5 Test Hojung 2015.04.01 4665
» MAC times in Linux (atime, mtime, ctime, crtime, touch, stat, debugfs) Hojung 2015.01.13 5637
442 How to generate a key with passphrase Hojung 2014.11.22 5783
441 Most Common OpenSSL Commands Hojung 2014.11.21 6314
440 How to use screen command Hojung 2014.11.17 4691
439 snorby (on testing) Hojung 2014.11.17 7490
438 APM (Apache + PHP + MySQL) with phpmyadmin in CentOS VM Hojung 2014.11.16 5646
437 10 Ways to Generate a Random Password from the Command Line Hojung 2014.11.16 4906
436 How to increase the size of a Linux LVM by adding a new disk file Hojung 2014.11.14 5149
435 Configuring logrotate for Rails logs file Hojung 2014.11.13 5573
434 Installing Splunk on CentOS file Hojung 2014.10.31 7467
433 Web performance test with ab (ruby web, dd, ab) file Hojung 2014.10.01 6409
432 Web performance test with Pylot (ruby web, dd, pylot) file Hojung 2014.10.01 5989
431 Install and Configure NTP to Synchronize The System Clock (ntpd, ntpdate) Hojung 2014.09.17 5468
430 How to disable IPv6 in CentOS 6 Hojung 2014.09.04 5637
429 IDS with snort in CentOS (Snort, Barnyard2) Hojung 2014.08.19 9045
Board Pagination ‹ Prev 1 2 3 4 5 6 7 8 9 10 ... 23 Next ›
/ 23

Designed by sketchbooks.co.kr / sketchbook5 board skin

나눔글꼴 설치 안내


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

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

설치 취소

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5