hellopasswd
一. 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和XShell
【CentOS 7基础笔记11】,目录权限,所有者与所有组,隐藏权限
【CentOS 7基础笔记12】,几种特殊权限与软硬链接
【CentOS 7基础笔记13】,find用法和文件传输
【CentOS 7基础笔记14】,其他
【CentOS 7基础笔记15】,用户与用户组
修改于171025
来源:oschina
链接:https://my.oschina.net/u/3708209/blog/1556274