您的位置:首页 > 运维架构 > Linux

find命令--Linux命令应用大词典729个命令解读

2016-12-09 16:52 387 查看
内容来源于人民邮电出版社《Linux命令应用大词典》


讲述729个命令,1935个例子

学习Linux系统的参考书、案头书,遇到不懂的命令或命令选项一查即可

争取每天都发布内容

本文出自 “airfish2000
博客,更多命令查看博客:
http://airfish2000.blog.51cto.com/10829608/1871361

find命令

使用find命令可以将文件系统内符合条件的文件列出来,可以指定文件的名称、类别、时间、大小以及权限等不同信息的组合,只有完全相符的文件才会被列出来。

命令语法:

find [路径] [选项]


命令中各选项的含义如表所示。

表                                   find命令选项含义
选项

含义

-name <文件名>

按照文件名来查找文件

-perm <权限>

按照文件的权限来查找文件

-user <用户名>

按照文件的用户所有者来查找文件

-group <组名>

按照文件的组群所有者来查找文件

-atime n

在过去n天内被访问过(atime)的文件,n代表数字

-amin n

在过去n分钟内被访问过(atime)的文件,n代表数字

-ctime n

在过去n天内被更改过(ctime)的文件,n代表数字

-cmin n

在过去n分钟内被更改过(ctime)的文件,n代表数字

-mtime n

在过去n天内被修改过(mtime)的文件,n代表数字

-mmin n

在过去n分钟内被修改过(mtime)的文件,n代表数字

-size n[ckMG]

查找大小为n的文件,n代表数字,c代表字节,k代表KB,M代表MB,G代表GB

-empty

查找空文件,可以是普通的文件或目录。

-type <文件类型>

按照文件类型来查找文件

-fstype <文件系统类型>

按照指定文件系统类型来查找文件

-nogroup

没有组群的文件

-nouser

没有用户的文件

-uid <用户UID>

按照文件的用户所有者的UID来查找文件

-gid <组群GID>

按照文件的组群所有者的GID来查找文件

-inum n

按照文件的inode号码来查找文件

-readable

匹配只读文件

-samefile <文件名>

查找和指定文件相同inode的文件

-writable

匹配可写文件

-links n

按照文件链接数来查找文件,n代表数字

 

在查找文件时可以定义不同的文件类型,如表所示。

表                                  查找时定义的文件类型

字符

含义

b

块设备文件

d

目录

c

字符设备文件

p

管道文件

l

符号链接文件

f

普通文件

s

socket文件

 
例:查找/boot目录下的启动菜单配置文件grub.conf。

[root@rhel~]# find /boot -name grub.conf
/boot/grub/grub.conf
//可以看到文件grub.conf在/boot/grub目录下

例:查找“/”目录下所有以“.conf”为扩展名的文件。

[root@rhel ~]# find / -name '*.conf'

/usr/share/sssd/sssd.api.d/sssd-ad.conf
/usr/share/sssd/sssd.api.d/sssd-ldap.conf
/usr/share/sssd/sssd.api.d/sssd-ipa.conf
/usr/share/sssd/sssd.api.d/sssd-local.conf
/usr/share/sssd/sssd.api.d/sssd-simple.conf
/usr/share/sssd/sssd.api.d/sssd-krb5.conf
/usr/share/sssd/sssd.api.d/sssd-proxy.conf
/usr/share/sssd/sssd.api.conf
........................(省略)

例:列出当前目录及其子目录下所有最近20天内更改过的文件。

[root@rhel~]# find . -ctime -20

.

./.gnupg

./.gnupg/pubring.gpg

./.gnupg/trustdb.gpg

./.gnupg/gpg.conf
./.gnupg/secring.gpg

./.ICEauthority

./.config

./.config/ibus
./.config/ibus/bus
./.config/ibus/bus/ee9d9211a0bdcd4d9f8591260000002a-unix-0

./.config/user-dirs.locale

./.config/user-dirs.dirs
./.config/gnome-disk-utility

./.config/gnome-disk-utility/ata-smart-ignore

./.config/gnome-session

........................(省略)

例:查找/root目录中为空的文件或者子目录。

[root@rhel ~]# find /root -empty
/root/.gnupg/pubring.gpg

/root/.gnupg/secring.gpg

/root/.config/gnome-disk-utility/ata-smart-ignore

/root/.config/gnome-session/saved-session

/root/桌面

/root/.gconf/apps/%gconf.xml
/root/.gconf/apps/brasero/%gconf.xml
/root/.gconf/apps/gnome-terminal/profiles/%gconf.xml
/root/.gconf/apps/gnome-terminal/%gconf.xml
/root/.gconf/apps/panel/%gconf.xml
/root/.gconf/apps/panel/applets/clock/%gconf.xml
/root/.gconf/apps/panel/applets/%gconf.xml
/root/.gconf/apps/panel/applets/workspace_switcher/%gconf.xml
/root/.gconf/apps/panel/applets/window_list/%gconf.xml
/root/.gconf/apps/nautilus/desktop-metadata/%gconf.xml
/root/.gconf/apps/nautilus/%gconf.xml
/root/.gconf/apps/gnome-session/%gconf.xml
/root/.gconf/desktop/ibus/engine/%gconf.xml
/root/.gconf/desktop/ibus/%gconf.xml
/root/.gconf/desktop/%gconf.xml
/root/.gconf/desktop/gnome/%gconf.xml
/root/.gconf/desktop/gnome/accessibility/%gconf.xml
/root/音乐

/root/下载

/root/图片

/root/.nautilus
/root/视频

/root/.abrt/applet_dirlist

/root/.gnome2/panel2.d/default/launchers
/root/.gnome2/nautilus-scripts
/root/.local/share/.converted-launchers
/root/文档

/root/模板

/root/.gnote/addins
/root/.ssh

/root/.gvfs
/root/公共的

例:在/boot目录中查找文件类型为目录的文件。

[root@rhel~]# find /boot -type d
/boot

/boot/lost+found
/boot/efi

/boot/efi/EFI

/boot/efi/EFI/redhat

/boot/grub
例:查找/home目录下用户所有者UID为500的文件。

[root@rhel~]# find /home -uid 500

/home/zhangsan

/home/zhangsan/.gnome2

/home/zhangsan/.bashrc
/home/zhangsan/.bash_logout

/home/zhangsan/.bash_profile

/home/zhangsan/.mozilla

/home/zhangsan/.mozilla/plugins
/home/zhangsan/.mozilla/extensions
/home/zhangsan/.bash_history

例:查找inode号码是6029314的文件。

[root@rhel~]# find /root -inum 6029314

/root/install.log
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息