【CentOS 7筆記13】,find用法和文件傳輸#171025

hellopasswdphp


一. find

1. 跟find類似的命令

which ls    #從環境變量$PATH中查找

whereis ls    #在事前準備好的庫中查找,但必須提早更新

locate
[root@localhost ~]# yum install -y mlocate
updatedb	#手動更新
locate ls
find /etc/ -name "network-scripts"
find /etc/ -name "network*"

[root@localhost ~]# find /etc/ -type d -name "network*"	#指定目錄
[root@localhost ~]# find /etc/ -type f -name "network*"	#目錄或文件
[root@localhost ~]# find /bin/ -type l -name "system*"	#軟連接文件
[root@localhost ~]# find /dev/ -type b -name "tty*"	#塊設備文件
[root@localhost ~]# find /dev/ -type c -name "vcsa*"

[root@localhost ~]# stat 2.txt	#查看文件的具體信息
    mtime	#最近更改信息	Modify
    ctime	#Change
    atime	#Access

[root@localhost ~]# echo "123" >> 2.txt
[root@localhost ~]# start 2.txt
	#Modify變化了
	#Change變化了
[root@localhost ~]# cat 2.txt
[root@localhost ~]# stat 2.txt
	#Access

[root@localhost ~]# find / -type f -mtime -1    #一天之內
[root@localhost ~]# find / -type f -mtime +1    #大於一天

[root@localhost ~]# find /etc/ -type f -mtime -1 -name "*.conf"	#時間一天之內而且後綴爲.conf的文件或目錄

[root@localhost ~]# find /etc/ -type f -o -mtime -1 -o -name "*.conf"	#-o或者,時間一天之內或者後綴爲.conf的文件或目錄
硬連接查找方式
[root@localhost ~]# find / -inum (inode號)
硬連接查找實驗
[root@localhost ~]# ln /home/1.txt /tmp/2.txt
[root@localhost ~]# ls -i /home/1.txt
[root@localhost ~]# find / -inum (inode號)
[root@localhost ~]# find /root/ -type f -mmin -60    #60分鐘,一個小時


[root@localhost ~]# find /root/ -type f -mmin -60 -exec ls -l {} \;


[root@localhost ~]# find /root/ -type f -mmin -60 -exec mv {}{}.bak \;
[root@localhost ~]# find /root/ -type f -mmin -60


[root@localhost ~]# find /root/ -size +10K    #大於
[root@localhost ~]# find /root/ -size -10K    #小於
[root@localhost ~]# find /root/ -type f -size -10K -exec ls -lh {} \;
[root@localhost ~]# find /root/ -type f -size +10M -exec ls -lh {} \;

二. 常見文件名後綴

*.php    #php文件
*.so    #庫文件
*.bz2    #bzip2壓縮文件
*.gz    #gzip壓縮文件
*.tar    #tar打包文件
*.tbz    #tar打包並用bzip壓縮
*.tgz    #tar打包並用gzip壓縮
*.txt    #純文本
*.conf    #配置文件
*.lock    #用於判斷一個文件或設備是否被使用
*.rpm    #軟件包
*.c    #c語言源程序代碼文件
*.cpp    #c++源程序代碼文件
*.h    #c\c++程序頭文件
*.o    #程序目標文件
*.java    #java源程序代碼文件
*.class    #java編譯文件
*.py    #python源程序代碼文件
*.pl    #perl腳本文件

三. 使用宿主機和虛擬機傳輸文件

使用xshell或者secure CRT
[root@localhost ~]# yum install -y lrzsz    #安裝包

[root@localhost ~]# sz file	#linux傳輸到windows

[root@localhost ~]# rz	#windows傳輸到linux

適用於SecureCRT和XShelljava


【CentOS 7基礎筆記11】,目錄權限,全部者與全部組,隱藏權限
【CentOS 7基礎筆記12】,幾種特殊權限與軟硬連接
【CentOS 7基礎筆記13】,find用法和文件傳輸
【CentOS 7基礎筆記14】,其餘
【CentOS 7基礎筆記15】,用戶與用戶組node

修改於171025python

相關文章
相關標籤/搜索