示例:node
[root@centos001 ~]# ls 111 22.txt 2.txt aling anaconda-ks.cfg.1 ls2 //随便选择一个文件 123 234 3.txt aminglinux dir3 yum.log [root@centos001 ~]# stat 2.txt //用stat列出其文件属性 文件:"2.txt" 大小:0 块:0 IO 块:4096 普通空文件 设备:fd00h/64768d Inode:33575023 硬连接:1 权限:(0664/-rw-rw-r--) Uid:( 0/ root) Gid:( 0/ root) 环境:unconfined_u:object_r:admin_home_t:s0 最近访问:2018-06-8 10:18:17.839439736 +0800 //这里能够看到文件的信息 atime 最近更改:2018-06-8 09:58:25.036568990 +0800 //ctime 最近改动:2018-06-8 10:17:57.282645569 +0800 //mtime 建立时间:-
CTRL+C //结束(终止)当前命令 CTRL+D //退出当前终端 CTRL+Z //暂停当前进程 CTRL+L //清屏 CTRL+A //移动光标到最前 CTRL+E //移动光标到最后 CTRL+U //删除光标前的字符
-name filename:直接查找该文件名的文件linux
示例:centos
[root@centos001 ~]# find /etc/ -name "sshd_config" //在etc目录下搜索一个已知名字的文件 /etc/ssh/sshd_config [root@centos001 ~]# find /etc/ -name "sshd*" //模糊搜索 用“*”代替不知道的名称 /etc/ssh/sshd_config /etc/systemd/system/multi-user.target.wants/sshd.service /etc/sysconfig/sshd /etc/pam.d/sshd
-type filetype:经过文件类型(如:f.b.c.d.l.s等)查找文件ssh
示例:code
[root@centos001 ~]# find /etc/ -type l //查找一个软连接文件 [root@centos001 ~]# ls -l /etc/rc1.d/ //选择一个路径查看其文件类型 总用量 0 lrwxrwxrwx. 1 root root 20 4月 29 18:55 K50netconsole -> ../init.d/netconsole lrwxrwxrwx. 1 root root 17 4月 29 18:55 K90network -> ../init.d/network
示例:进程
[root@centos001 ~]# find /etc/ -type f -ctime -1 //查找一个在一天内更改过inode属性的文件 /etc/resolv.conf /etc/sysconfig/network-scripts/.ifcfg-en.swp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/tuned/active_profile
示例:ip
[root@centos001 ~]# find /etc/ -type f -mtime -1 //在目录etc下查找写入时间在一天内的文件 切时间前只能用用加减号 /etc/resolv.conf /etc/sysconfig/network-scripts/.ifcfg-en.swp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/tuned/active_profile
示例:get
[root@centos001 ~]# find /etc/ -type f -o -mtime -1 -o -name “*.conf” //查找一个 etc目录下一天之内或者叫有conf结尾的文件
示例:it
[root@centos001 ~]# ln ls2 /tmp/5.txt.bak //建立一个文件ls2的硬连接 [root@centos001 ~]# ls -l ls2 //查看文件属性 -rw-r--r--. 2 root root 0 5月 25 02:55 ls2 //用户前面的2表示 硬连接已经建立成功 [root@centos001 ~]# ls -i ls2 //查看文件的inode号 33574978 ls2 [root@centos001 ~]# find / -inum 33574978 //查询有这个inode号的文件 。就能找到一个文件的硬连接位置 /root/ls2 /tmp/5.txt.bak
示例:console
[root@centos001 ~]# find /etc/ -type f -mmin -300 //查找5小时内的文件 /etc/resolv.conf
示例:
[root@centos001 ~]# find /etc/ -type f -mmin -300 -exec ls -l {} \; //查找一个小于300分钟内的文件并列出 -rw-r--r--. 1 root root 84 5月 27 22:03 /etc/resolv.conf
示例:
[root@centos001 ~]# find /root/ -type f -size +10k -exec ls -l {} \; //查找一个大于10k的文件并列出 -rw-r--r--. 1 root root 12288 5月 31 14:02 /root/.ssh/.authorized_keys.swp
示例:
[root@centos001 ~]# LANG=en //将系统语言改为英语 [root@centos001 ~]# echo $LANG //查看系统语言 en [root@centos001 ~]# stat 2.txt File: '2.txt' Size: 0 Blocks: 0 IO Block: 4096 regular empty file Device: fd00h/64768d Inode: 33575023 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 0/ root) Gid: ( 0/ root) Context: unconfined_u:object_r:admin_home_t:s0 Access: 2018-05-26 10:18:17.839439736 +0800 //先在就比中文更好区分了 Modify: 2018-05-26 09:58:25.036568990 +0800 Change: 2018-05-26 10:17:57.282645569 +0800 Birth: -