0
点赞
收藏
分享

微信扫一扫

Linu命令(history,du,cat,touch,date,stat)

Sky飞羽 2022-04-13 阅读 112
linux运维

history 执行历史命令

[root@host lianxi]# history

history -c

! 123

[root@host lianxi]# !100
#执行之前执行过的第一百条命令

!ls

#!接字符串执行最近的以字符串开头的命令
[root@host lianxi]# !mkdir
mkdir china/{guangdong/guangzhou,zhejiang/huangzhou} -p

du 内存占用统计

用途:统计目录及文件的空间占用情况

常用命令选项:

  • du -a :统计时包括所有的文件,而不仅仅只统计目录

  • -h :以更易读的字节为单位

  • -s:只统计每个参数所占用空间总的大小

[root@host /]# du -sh etc
32M etc

du -sh 和ll -h 的区别

du -sh查看文件夹的大小

ll -h 只能查看文件的大小

ls -l -h 会打开这个文件系统统计这个文件里有多少个字符

一个英文字母占一个字节

一个汉字占三个字节

du 是统计一个文件占用了多少块(block)

一个块的大小是4K

cat -n 查看文件内容,并且显示行号

touch 新建空文件

  1. 新建空文件

  2. 如果文件存在就更新文件的创建时间,默认更新时间为当前时间

[root@host /]# ll -h wangchen.txt 
-rw-r--r--. 1 root root 0 2月  25 20:49 wangchen.txt
[root@host /]# touch wangchen.txt
[root@host /]# ll -h wangchen.txt 
-rw-r--r--. 1 root root 0 2月  25 20:49 wangchen.txt
[root@host /]# touch wangchen.txt
[root@host /]# ll -h wangchen.txt 
-rw-r--r--. 1 root root 0 2月  25 20:50 wangchen.txt

date 查看当前时间

stat 查看文件的详细信息

[root@host /]# stat wangchen.txt 
  文件:"wangchen.txt"
  大小:0          块:0          IO 块:4096   普通空文件
设备:fd00h/64768d Inode:654552      硬链接:1
权限:(0644/-rw-r--r--)  Uid:(    0/    root)   Gid:(    0/    root)
环境:unconfined_u:object_r:etc_runtime_t:s0
最近访问:2022-02-25 20:47:34.161026325 +0800
最近更改:2022-02-25 20:47:34.161026325 +0800
最近改动:2022-02-25 20:47:34.161026325 +0800
创建时间:-
​
[root@host /]# LANG=en_US.UTF-8
#更改语言为英语,中文就是zh_CN.UTF-8
[root@host /]# stat wangchen.txt 
  File: ‘wangchen.txt’
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: fd00h/64768d    Inode: 654552      Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: unconfined_u:object_r:etc_runtime_t:s0
Access: 2022-02-25 20:50:10.986650491 +0800
Modify: 2022-02-25 20:50:10.986650491 +0800
Change: 2022-02-25 20:50:10.986650491 +0800
 Birth: -
时间有三个时间:
1.访问时间:access time  看一下文件内容就会更改,如cat,vim
2.修改时间:Modify time   动了文件里的内容如vim新增、删除内容
3.更改时间 : change time 修改了文件的拥有者、时间、权限、大小   文件的属性
举报

相关推荐

0 条评论