Linux CentOS7 VMware find命令、文件名后缀

摘要:
它可以根据不同的条件查找文件,例如权限、所有者、修改日期/时间、文件大小等。在本文中,我们将学习如何使用find命令及其提供的选项来查找文件。

一、find命令

Linux系统中的 find 命令在查找文件时非常有用而且方便。它可以根据不同的条件来查找文件,例如权限、拥有者、修改日期/时间、文件大小等等。在这篇文章中,我们将学习如何使用 find 命令以及它所提供的选项来查找文件。

列出当前目录和子目录下的所有文件

[root@davery ~]# find
.
./.bash_logout
./.bash_profile
./.bashrc
./.cshrc
./.tcshrc
./.ssh

搜索所有文件、目录:find /etc/ -name "xxx*"

root@davery ~]# find /etc/ -name "ssh*"
/etc/ssh
/etc/ssh/sshd_config
/etc/ssh/ssh_config
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ecdsa_key.pub
[root@davery ~]#

搜索目录,例子:find /etc/ -type d -name "xxx"

[root@davery ~]# find /etc/ -type d -name "ssh"
/etc/ssh
/etc/selinux/targeted/active/modules/100/ssh
[root@davery ~]#

搜索文件,例子:find /etc/ -type f -name "xxx"

[root@davery ~]# find -type f -name "*"
./.bash_logout
./.bash_profile
./.bashrc
./.cshrc
./.tcshrc
./.ssh/known_hosts
./.bash_history
./anaconda-ks.cfg.01
./anaconda-ks.cfg.1

根据文件类型搜索文件

[root@davery ~]# find /etc/ -type l

[root@davery ~]# find /etc/ -type d

[root@davery ~]# find /etc/ -type b

[root@davery ~]# find /etc/ -type c

查看文件具体信息,stat 1.txt

[root@davery ~]# ls
1.txt anaconda-ks.cfg.01 anaconda-ks.cfg.1 davery make uear1 user1
[root@davery ~]#
[root@davery ~]#
[root@davery ~]# stat 1.txt
文件:"1.txt"
大小:6 块:0 IO 块:4096 目录
设备:803h/2051d Inode:652696 硬链接:2
权限:(0755/drwxr-xr-x) Uid:( 0/ root) Gid:( 0/ root)
环境:unconfined_u:object_r:admin_home_t:s0
最近访问:2018-03-30 21:57:22.470173086 +0800     Access: -atime
最近更改:2018-03-29 00:12:37.656441521 +0800      Modify: -mtime
最近改动:2018-03-29 00:17:05.797933042 +0800      Change:-ctime
创建时间:-                                                                     Birth
[root@davery ~]# 

查看/etc里面1天内更改的信息

[root@davery ~]# find /etc/ type f -mtime -1
/etc/
/etc/resolv.conf
/etc/cron.daily
/etc/group
/etc/gshadow
[root@davery ~]#

查看/etc里面60分钟内更改的信息

[root@davery ~]# find /etc/ -type f -mmin -60
/etc/resolv.conf
/etc/group
/etc/gshadow
[root@davery ~]#

查找大于1000k文件

[root@davery ~]# [root@davery ~]# find /etc/ -type f -size +1000k
/etc/udev/hwdb.bin
/etc/selinux/targeted/active/policy.kern
/etc/selinux/targeted/contexts/files/file_contexts.bin
/etc/selinux/targeted/policy/policy.30
[root@davery ~]#

查找大于1000k文件并显示大小

[root@davery ~]# find /etc/ -type f -size +1000k -exec ls -lh {} \;
-r--r--r--. 1 root root 7.2M 3月 23 06:09 /etc/udev/hwdb.bin
-rw-r--r--. 1 root root 3.6M 8月 6 2017 /etc/selinux/targeted/active/policy.kern
-rw-r--r--. 1 root root 1.4M 8月 6 2017 /etc/selinux/targeted/contexts/files/file_contexts.bin
-rw-r--r--. 1 root root 3.6M 8月 6 2017 /etc/selinux/targeted/policy/policy.30
[root@davery ~]#

二、文件名后缀

需要区分大小写

[root@davery ~]# ls
1.txt anaconda-ks.cfg.01 anaconda-ks.cfg.1 davery make uear1 user1
[root@davery ~]#
[root@davery ~]# Ls
-bash: Ls: 未找到命令
[root@davery ~]#

 

免责声明:文章转载自《Linux CentOS7 VMware find命令、文件名后缀》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇H5测试区别与PC端测试关注点最值得购买的四大名著版本推荐(一家之言)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

20、Linux实操篇——磁盘分区、挂载

1、磁盘分区介绍 (1)分区基础知识 分区方式 ①mbr分区最多有四个主分区系统只能装在主分区拓展区要占一个主分区MBR最大只支持2TB,但拥有最好的兼容性②gtp分区支持无限多个分区(但可能受系统限制,比如Windows下最多128个分区)最大支持18EB的大容量(1EB=1024PB)Windows7 64位以后支持gtp分区 2、Linux分区 (1...

Linux软件开发常用的软件包(持续更新中)

下面是Linux开发常用的软件包: 软件包的名称 作用描述 安装方式 build-essential   sudo apt-get install build-essential policycoreutils audit2allow工具 sudo apt-get install policycoreutils vim   sudo ap...

修改linux主机名与配置ssh通过主机名进行远程登录

具体步骤如下所示: 1、 vi /etc/hosts 2、vi /etc/hostname 3、vi /etc/sysconfig/network 4、需要重启服务器 reboot 5、分别在要连接的linux服务器上设置ip和hostname的映射 6、进入.ssh目录 ssh-keygen -t rsa ssh-copy-id centos@ce...

Linux C/C++编程之(十七)进程间通信

文章目录 一、概述 二、进程间通信概念及方法 1. 管道的概念 2. pipe 3. 管道的读写行为 4. 管道缓冲区大小 5. 管道优劣 6. FIFO 7. 共享存储映射 8. mmap函数 9. munmap函数 10. mmap九问 11. mmap父子进程间通信 12. 匿名映射 13. mmap无血缘关系进程间通信 3. 练习...

嵌入式linux GUI--DirectFB + GTK至尊秘笈

1 前言 数年前,曾经开发过一个嵌入式的产品,如今市场依然存在,但由于电子产品的升级换代很快,许多元器件都采购不到了,为了延续产品的生命周期,计划在linux平台上开发新的版本。而在linux上的GUI上成了大问题,最开始有用Minigui的打算,也同飞漫公司联系过,但费用我这里无法承受。(Minigui作为国产优秀的嵌入式GUI,如果不是费...

Linux Shellcode

Linux Shellcode 本篇主要是以x64系统为例对系统调用中一些功能性函数的解读和实际运用。目前网络上流传的通用shellcode,均使用系统调用实现,在记录整个学习过程的同时分享给大家一起学习探讨。 0x01 Shellcode 简介 0x1 shellcode Shellcode 是一段可以执行特定功能的特殊汇编代码,在设备漏洞利用过程...