1、which 命令
查找命令
语法:which 要查找的命令
无需选项,只需要参数表示查找哪个命令
[shui@xiaored ~]$ which ll
alias ll='ls -l --color=auto'
/bin/ls
[shui@xiaored ~]$ which cd
/bin/cd
[shui@xiaored ~]$
2、find 命令
用于查找文件
按文件名查找:
语法:find 起始路径 -name "被查找文件名"
支持通配符,星号:*,匹配任意内容(包括空),可以用作模糊查询。
相对路径
[shui@xiaored ~]$ find -name "demo.txt"
./demo.txt
绝对路径
[shui@xiaored ~]$ find /home/shui/ -name "newfile"
/home/shui/newfile
使用通配符 *
相对路径
[shui@xiaored ~]$ find -name "demo*"
./demo.txt
./demo01.txt
[shui@xiaored ~]$
绝对路径
[shui@xiaored ~]$ find /home/shui/ -name "demo*"
/home/shui/demo.txt
/home/shui/demo01.txt
按文件大小查找文件
语法:find 起始路径 -size +/-n[kMG]
+、- 表示大于和小于
n 表示大小数字
kMG表示大小单位,k(小写字母)表示KB,M表示MB,G表示GB;
不写起始路径,就查找当前路径下的文件;查到默认包含隐藏文件;
[shui@xiaored ~]$ ll -lh
总用量 16M
-rw-rw-r--. 1 shui shui 16M 8月 29 14:56 demo01.txt
-rw-rw-r--. 1 shui shui 1.6K 8月 24 17:36 demo.txt
drwxrwxr-x. 2 shui shui 6 8月 21 15:34 newfile
[shui@xiaored ~]$ find -size +10M
./demo01.txt
[shui@xiaored ~]$
[shui@xiaored ~]$ find -size -10M
.
./.mozilla
./.mozilla/extensions
./.mozilla/plugins
./.bash_logout
./.bash_profile
./.bashrc
./newfile
./demo.txt
./.bash_history
./.viminfo
[shui@xiaored ~]$ ll -lh
总用量 16M
-rw-rw-r--. 1 shui shui 16M 8月 29 14:56 demo01.txt
-rw-rw-r--. 1 shui shui 1.6K 8月 24 17:36 demo.txt
drwxrwxr-x. 2 shui shui 6 8月 21 15:34 newfile
[shui@xiaored ~]$
账户、权限需要注意;