[root@vultr ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
whereis ##where 是有一个库
[root@vultr ~]# which ls
alias ls='ls --color=auto'
/usr/bin/ls
2.23 find 上
先介绍一下几个可以搜索的命令:
locate
安装方法:
[root@vultr ~]# yum install mlocate -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ewr.edge.kernel.org
* epel: epel.mirror.constant.com
* extras: mirror.es.its.nyu.edu
* updates: repo1.ash.innoscale.net
Resolving Dependencies
--> Running transaction check
---> Package mlocate.x86_64 0:0.26-8.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================
Installing:
mlocate x86_64 0.26-8.el7 base 113 k
Transaction Summary
==========================================================================================================================
Install 1 Package
Total download size: 113 k
Installed size: 379 k
Downloading packages:
mlocate-0.26-8.el7.x86_64.rpm | 113 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mlocate-0.26-8.el7.x86_64 1/1
Verifying : mlocate-0.26-8.el7.x86_64 1/1
Installed:
mlocate.x86_64 0:0.26-8.el7
Complete!
ctrl +L 清屏
ctrl +d 退出一个终端命令
ctrl +c 补执行这条命令
ctrl +u 能够让你的光标删除前面的东西
$? 这条命令可以查看前面一条命令是否执行成功,也可以用来检验,你yum安装一个工具是否成功
Ctrl +a ctrl e ctrl u
1、find 的一些基本用法
[root@vultr ~]# find /etc/ -name "ssh"
/etc/ssh
[root@vultr ~]# find /etc/ -name "ssh*"
/etc/ssh
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ecdsa_key.pub
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_ed25519_key
/etc/ssh/ssh_config
/etc/ssh/ssh_host_ed25519_key.pub
/etc/ssh/sshd_config
/etc/sysconfig/sshd
/etc/systemd/system/multi-user.target.wants/sshd.service
/etc/pam.d/sshd
搜索目录带ssh的
[root@vultr ~]# find /etc/ -type d -name "ssh*"
/etc/ssh
搜索文件带ssh的
[root@vultr ~]# find /etc/ -type f -name "ssh*"
/etc/ssh/ssh_host_ecdsa_key
/etc/ssh/ssh_host_ecdsa_key.pub
/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_rsa_key
/etc/ssh/ssh_host_ed25519_key
/etc/ssh/ssh_config
/etc/ssh/ssh_host_ed25519_key.pub
/etc/ssh/sshd_config
/etc/sysconfig/sshd
/etc/pam.d/sshd
d f (-) l s c b 各种文件类型
2.24 find 中
1、三个time参数的理解:
atime 访问时间 cat
mtime 改了文件内容 vi >>
ctime 改动了权限 比如: chmod
[root@vultr ~]# stat 11.txt
File: ‘11.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 29555 Links: 2
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-06-07 05:32:17.756623732 +0000##最近访问
Modify: 2018-06-07 05:32:17.756623732 +0000 ##最近更改,改了内容
Change: 2018-06-07 05:55:04.467072349 +0000 ##最近改动 ,只要有命令操作过这个文件就会改动它的时间属性,inode的先关信息,权限,文件名,时间等等
Birth: -
[root@vultr ~]# chmod 700 11.txt
[root@vultr ~]# stat 11.txt
File: ‘11.txt’
Size: 0 Blocks: 0 IO Block: 4096 regular empty file
Device: fd01h/64769d Inode: 29555 Links: 2
Access: (0700/-rwx------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-06-07 05:32:17.756623732 +0000
Modify: 2018-06-07 05:32:17.756623732 +0000
Change: 2018-06-10 00:58:05.701330784 +0000
修改 Mtime
[root@vultr ~]# echo "1121212" >> 11.txt
[root@vultr ~]# stat 11.txt
File: '11.txt'
Size: 8 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 29555 Links: 2
Access: (0700/-rwx------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-06-07 05:32:17.756623732 +0000
Modify: 2018-06-10 01:01:13.826894660 +0000
Change: 2018-06-10 01:01:13.826894660 +0000
修改 atime
[root@vultr ~]# cat 11.txt
1121212
[root@vultr ~]# stat 11.txt
File: '11.txt'
Size: 8 Blocks: 8 IO Block: 4096 regular file
Device: fd01h/64769d Inode: 29555 Links: 2
Access: (0700/-rwx------) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-06-10 01:05:20.116560396 +0000
Modify: 2018-06-10 01:01:13.826894660 +0000
Change: 2018-06-10 01:01:13.826894660 +0000
2、利用三个time参数来查找文件
[root@vultr ~]# find /etc/ -type f -mtime -1 ##查找一天以内更改过的文件
/etc/gshadow
/etc/group
[root@vultr ~]# find /etc/ -type f -o -mtime -1 -o -name "*.config"
/etc/
/etc/gshadow
/etc/vconsole.conf
/etc/ntp.conf
/etc/krb5.conf
/etc/dbus-1/system.d/org.freedesktop.timedate1.conf
/etc/dbus-1/system.d/org.freedesktop.PolicyKit1.conf
2.24 find 下
find /-inum inode号
[root@vultr ~]# find /root/ -type f -mmin -60
[root@vultr ~]# touch a.txt
[root@vultr ~]# find /root/ -type f -mmin -60
/root/a.txt
-exec
[root@vultr ~]# find /root/ -type f -mmin -60
/root/.bash_history
/root/a.txt
[root@vultr ~]# find /root/ -type f -mmin -60 -exec ls -l {} \;
-rw------- 1 root root 3333 Jun 10 03:00 /root/.bash_history
-rw-r--r-- 1 root root 0 Jun 10 02:53 /root/a.txt
[root@vultr ~]# find /root/ -size +10k
[root@vultr ~]# find /root/ -type f -size -10k
/root/
/root/13.txt
/root/.bash_logout
/root/.cshrc
/root/.pki
/root/.pki/nssdb
/root/.viminfo
/root/dir1
/root/.bashrc
/root/12.txt
/root/.bash_history
/root/.bash_profile
/root/.tcshrc
/root/11.txt
/root/anaconda-ks.cfg.1
/root/a.txt
[root@vultr ~]# find /root/ -type f -size -10k -exec ls -lh {} \;
-rwx------ 3 root root 8 Jun 10 01:01 /root/13.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
-rw------- 1 root root 639 May 28 09:25 /root/.viminfo
-rw-r--r-- 1 root root 176 Dec 29 2013 /root/.bashrc
-rw------- 1 root root 3.3K Jun 10 03:00 /root/.bash_history
-rw-r--r-- 1 root root 176 Dec 29 2013 /root/.bash_profile
-rw-r--r-- 1 root root 129 Dec 29 2013 /root/.tcshrc
-rwx------ 3 root root 8 Jun 10 01:01 /root/11.txt
-rwx------ 1 root root 7.8K Jun 5 05:04 /root/anaconda-ks.cfg.1
-rw-r--r-- 1 root root 0 Jun 10 02:53 /root/a.txt
find -type -mtime -mmin -size -o -exec -name
2.26文件名后缀
1、linux区分大小写
2、文件名后缀(不代表文件的类型)
3、显示中文和英文