RHCE学习笔记3

这篇博客介绍了Linux系统中的一些基本文件管理命令,包括`touch`用于修改时间戳,`stat`显示文件状态,`file`判断文件类型,`rm`删除文件,`mv`移动或重命名文件,`nano`进行文件编辑,`cp`复制文件,`cat`、`tac`、`more`和`less`查看文件内容,`tail`显示文件末尾,`tr`字符替换,`cut`删除文件部分,`wc`统计文件信息,`sort`和`uniq`进行文件排序和去除重复行。这些都是Linux日常操作中的常用命令。
摘要由CSDN通过智能技术生成

系列文章目录


一、基本命令

文件管理

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
           };

访问时间

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值