find的命令的使用和文件名的后缀
find的命令的使用和文件名的后綴
除了find ?還有其他的搜索命令,不過沒有find功能強大,了解即可 !
root@alex ~]# which pwd
/usr/bin/pwd
[root@alex ~]# whereis pwd
pwd: /usr/bin/pwd /usr/include/pwd.h /usr/share/man/man1/pwd.1.g
[root@alex ~]# yum install -y locatl ? ? locatl ?安裝這個包 ?
[root@alex ~]# updatedb ? ?需要更新數(shù)據(jù)庫 ? 才能查看 ??
[root@alex ~]# ls ? ? ? ? ? ? ?locate ?遍歷整個目錄 ?去搜索?
2.txt??3.txt??c??m??nb??p??zx
[root@alex ~]# locate zx
/root/zx
/root/zx/1.txt ?
find ?
ctrl +l清屏的快捷方式 ? ctrl+c結(jié)束一個命令 ? ctrl+ u ?把前面的東西全部刪除 ??
ctrl+e ?把光標快速移動到后面 ? ctrl+a光標移動最開始 ? ?ctrl+d快速退出一個終端 ?
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? find搜索加上-name ?
[root@alex ~]# find /etc/ -name "sshd_config"
/etc/ssh/sshd_config
[root@alex ~]# find /etc/ -name "sshd*" ? ? ?模糊搜索 ? ?
/etc/pam.d/sshd
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?find前面跟路徑后面跟條件 ?
[root@alex ~]# find /etc/ -type d -name "sshd*" ? ? ? ? ?-d是指定目錄 ? ?type是類型 ??
[root@alex ~]# find /etc/ -type f -name "sshd*" ? ? ? ? ? -f ?是指定文件 ? ?type是類型 ? ?
/etc/pam.d/sshd
/etc/sysconfig/sshd
/etc/ssh/sshd_config
d,f,p,s,l,b,c ?都可以跟 ??
find除了這些還有其他的 ?mtime ?ctine ?aitime ? ?
[root@alex ~]# stat 2.txt
??File: ‘2.txt’
??Size: 0?????????????Blocks: 0??????????IO Block: 4096???regular empty file
Device: fd01h/64769d????Inode: 657747??????Links: 1
Access: (0644/-rw-r--r--)??Uid: (????0/????root)???Gid: (????0/????root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2017-10-26 09:22:01.701999759 +0800
Modify: 2017-10-26 09:22:01.701999759 +0800
Change: 2017-10-26 09:38:42.230549940 +0800
Birth: -
?
[root@alex ~]# chmod 700 2.txt ? ? 更改文件的權(quán)限 ?ctime跟著改變 ??
[root@alex ~]# stat 2.txt
??File: ‘2.txt’
??Size: 0?????????????Blocks: 0??????????IO Block: 4096???regular empty file
Device: fd01h/64769d????Inode: 657747??????Links: 1
Access: (0700/-rwx------)??Uid: (????0/????root)???Gid: (????0/????root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2017-10-26 09:22:01.701999759 +0800
Modify: 2017-10-26 09:22:01.701999759 +0800
Change: 2017-10-28 09:14:22.073579116 +0800
Birth: -
[root@alex ~]# echo “232323” >> 2.txt ? ? ? 更改了文件的內(nèi)容 ,mtime,ctime 都會改變?
ctime是記錄文件的大小 ?文件的時間 權(quán)限所有者
[root@alex ~]# stat??2.txt
??File: ‘2.txt’
??Size: 13????????????Blocks: 8??????????IO Block: 4096???regular file
Device: fd01h/64769d????Inode: 657747??????Links: 1
Access: (0700/-rwx------)??Uid: (????0/????root)???Gid: (????0/????root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2017-10-26 09:22:01.701999759 +0800
Modify: 2017-10-28 09:17:43.810493592 +0800
Change: 2017-10-28 09:17:43.810493592 +0800
Birth: -
[root@alex ~]# cat 2.txt ? ? ? ? 訪問2.txt ??
“232323”
[root@alex ~]# stat 2.txt
??File: ‘2.txt’
??Size: 13????????????Blocks: 8??????????IO Block: 4096???regular file
Device: fd01h/64769d????Inode: 657747??????Links: 1
Access: (0700/-rwx------)??Uid: (????0/????root)???Gid: (????0/????root)
Context: unconfined_u:object_r:admin_home_t:s0
Access: 2017-10-28 09:21:37.432551257 +0800 ? ? atime 時間跟著改變 ??
Modify: 2017-10-28 09:17:43.810493592 +0800
Change: 2017-10-28 09:17:43.810493592 +0800
Birth: -
atime ?最近訪問時間 ? mtime ?最近更改時間 ?ctime ?最近改動時間 ?
[root@alex ~]# find / -type??f -mtime -1 ? ?查看更改權(quán)限內(nèi)容 -1 ?一天以內(nèi)的 ? +7是七天以內(nèi)?
[root@alex ~]# find /etc/ -type f -mtime -1 ? ?etc下一天以內(nèi)更改的?
/etc/group
/etc/gshadow ? ?
[root@alex ~]# find /etc/ -type f -mtime +1 ?是一天以前的 ? ??
/etc/group
/etc/gshadow
[root@alex ~]# find /etc/ -type f -atime +1 ?一天一前訪問etc下文件的?
[root@alex ~]# find /etc/ -type f -ctime +1 ? ? 一天一前更改etc下權(quán)限的 文件 ? ? ??
[root@alex ~]# find /etc/ -type f -atime -1??-name??"*.conf" ? ?
/etc/nsswitch.conf
/etc/security/access.conf
/etc/security/limits.conf
/etc/security/limits.d/20-nproc.conf
[root@alex ~]# find /etc/ -type f -o -atime -1??-o -name??"*.conf" ?或者的意思 ? -o
-type ?-name -o ? -mtime ?
find 查找硬鏈接 ?文件 ??
??
首先查找 inum ? 號 ? ?
然后find ?/ -inum 2344221 ? 就可以查找 ?
find查找 root下60分鐘以內(nèi)文件 ??
[root@alex ~]# find /root/??-type f -mmin??-60
/root/2.txt
[root@alex ~]# find /root/??-type f -mmin??-120
[root@alex ~]# find /root/ -type f -mmin -120 -exec ls -l {} \; ? ??
-rwx------. 1 root root 13 Oct 28 09:17 /root/2.txt
[root@alex ~]# find /root/ -type f -mmin -150 -exec mv {} {}.bak \; ? ?
[root@alex ~]# find /root/ -type f -mmin -150
/root/2.txt.bak
[root@alex ~]# find /root/ -size -10k ? ? ? ?小于10k的 ??
/root/
[root@alex ~]# find /root/ -type f -size -10k -exec ls -lh {} \;
-rw-r--r--. 1 root root 69 Aug 17 07:47 /root/.cache/pip/selfcheck.json
-rw-r--r--. 1 root root 64 Aug 17 07:48 /root/.pydistutils.cfg
-rw-r--r--. 1 root root 129 Dec 29??2013 /root/.tcshrc
-rw-r--r--. 1 root root 0 Oct 24 09:34 /root/zx/1.txt
-rw-r--r--. 1 root root 18 Dec 29??2013 /root/.bash_logout ?
[root@alex ~]# find /root/ -type f -size -10M -exec ls -lh {} \;
-rw-r--r--. 1 root root 129 Dec 29??2013 /root/.tcshrc
-rw-r--r--. 1 root root 0 Oct 24 09:34 /root/zx/1.txt
-rw-r--r--. 1 root root 18 Dec 29??2013 /root/.bash_logout
-rw-r--r--. 1 root root 100 Dec 29??2013 /root/.cshrc
[root@alex ~]# echo $LANG ? ?這個是寫法 ?表示英文 ?
en_US.UTF-8
linux下不是所有文件以什么結(jié)尾就是什么文件 ?具體要查看 ??
Linux文件類型常見的有:普通文件、目錄、字符設(shè)備文件、塊設(shè)備文件、符號鏈接文件等。
轉(zhuǎn)載于:https://blog.51cto.com/11335852/1976968
總結(jié)
以上是生活随笔為你收集整理的find的命令的使用和文件名的后缀的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: session无法传值解决方案!
- 下一篇: JDBC接口