linux命令

2021/8/25 7:06:10

本文主要是介绍linux命令,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

locate 命令

# yum install mlocate -y
建立文件和目录结构对饮关系,便于检索
# updatedb
# ls -l /var/lib/mlocate/mlocate.db 
-rw-r----- 1 root slocate 744380 Aug 11 18:58 /var/lib/mlocate/mlocate.db

find命令语法

​ find 找寻的路径范围 -type 类型信息 -name "文件名称"

# find /etc -type d -name network-scripts
# find /etc/ -type f -name "ifc*6"

精确查找:

  find 路径信息 -type 文件类型 -name "文件名"

​ 模糊查找:

    find 路径信息 -type 文件类型 -name "文件名*"
    find 路径信息 -type 文件类型 -name "*文件名"	
	find 路径信息 -type 文件类型 -name "文*件名"

​ 忽略大小写查找:

	find 路径信息 -type 文件类型 -iname "文件名*"

​ 根据数据大小查找数据:

find /kang -type f -size +100   --- 找出大于100K的文件
find /kang -type f -size -100
find /kang -type f -size +1M    --- 找出大于1M的文件
  `b'    for 512-byte blocks (this is the default if no suffix is used)
    `c'    for bytes   (推荐)
    `w'    for two-byte words
    `k'    for Kilobytes (units of 1024 bytes) (推荐)
    `M'    for Megabytes (units of 1048576 bytes) (推荐)
    `G'    for Gigabytes (units of 1073741824 bytes)

find 根据目录指定层级进行查找数据(进行递归查找)

根据目录,指定层级查找

find /kang -maxdepth 2 -type f -name "yunjisuan*"

删除文件

find /kang/ -type f -name "*.txt" -delete
find /kang/ -type f -name "*.txt" -exec rm -rf {} \;

tree命令

显示结构目录信息

yum install tree -y

指定层级 -L

[root@mall mnt]# tree -L 2
.
└── cd
    ├── CentOS_BuildTag
    ├── EFI
    ├── EULA
    ├── GPL
    ├── images
    ├── isolinux
    ├── LiveOS
    ├── Packages
    ├── repodata
    ├── RPM-GPG-KEY-CentOS-7
    ├── RPM-GPG-KEY-CentOS-Testing-7
    └── TRANS.TBL

显示目录中所有结构信息 -d

[root@mall mnt]# tree -d
.
└── cd
    ├── EFI
    │   └── BOOT
    │       └── fonts
    ├── images
    │   └── pxeboot
    ├── isolinux
    ├── LiveOS
    ├── Packages
    └── repodata

压缩的命令 tar

​ 压缩命令语法:
​ tar zcvf /root/kang/kang.tar.gz 指定要压缩的数据文件
​ z 压缩的方式 为zip
​ c 创建压缩包文件
​ v 显示压缩的过程
​ f 指定压缩包文件路径信息
​ 压缩数据方法:

# tar zcvf kang/kang.tar.gz gpmall-repo/
[root@mall kang]# tar xvf kang.tar.gz 

在不解压的情况下查看压缩包里面的数据

# tar tf kang.tar.gz 


这篇关于linux命令的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程