示例: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: -