系列文章目录
RHCE学习笔记3
一、基本命令
文件管理
touch
touch是用来修改时间戳的命令。
当touch一个不存在的文件,自动创建该文件,并将时间戳设置为创建时候的时间。
当touch一个存在的文件
touch -a 存在的文件名 #修改访问时间
touch -m 存在的文件名 #修改修改时间
touch 存在的文件名 #修改访问,修改,改变时间
stat
stat用来显示文件或文件系统状态。
root@ubuntu-VirtualBox:/home/ubuntu# stat test.cap
File: 'test.cap'
Size: 28623 Blocks: 56 IO Block: 4096 通常ファイル
Device: 803h/2051d Inode: 655381 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-01-05 13:00:30.560000000 +0800
Modify: 2021-01-05 13:02:04.164000000 +0800
Change: 2021-04-02 10:46:24.875160538 +0800
Birth: -
执行命令返回的struct如下
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for filesystem I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
/* Since Linux 2.6, the kernel supports nanosecond
precision for the following timestamp fields.
For the details before Linux 2.6, see NOTES. */
struct timespec st_atim; /* time of last access */
struct timespec st_mtim; /* time of last modification */
struct timespec st_ctim; /* time of last status change */
#define st_atime st_atim.tv_sec /* Backward compatibility */
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
};
访问时间