查看命令位置,查找命令
which命令 查看命令的位置
[root@VM-12-15-opencloudos ~]# which cd
/usr/bin/cd
[root@VM-12-15-opencloudos ~]# which java
/usr/local/java/jdk1.8.0_261/bin/java
[root@VM-12-15-opencloudos ~]# which pwd
/usr/bin/pwd
find查找文件
find 起始路径 -name "被查找的文件名"
被查找的文件名支持*来做模糊查询
find /usr -name "*test*"
find 起始路径 -size +|-n[KMG]
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/e5133c89d48c48f2bd3044e0f97e3e4f.png
find / -size +1G
grep命令
grep [-n] 关键字 文件路径
-n可选参数,可以在文件中显示行号
[root@VM-12-15-opencloudos usr]# grep -n 127 /usr/local/nginx/conf/nginx.conf
41: proxy_pass http://127.0.0.1:8089;
67: # proxy_pass http://127.0.0.1:8089/user;
wc命令统计文件行数,单词数量等
wc [-c -m -l -w] 文件路径
[root@VM-12-15-opencloudos usr]# wc -cmlw /usr/local/nginx/conf/nginx.conf
112 210 2318 2496 /usr/local/nginx/conf/nginx.conf
管道符 |
[root@VM-12-15-opencloudos usr]# cat /usr/local/nginx/conf/nginx.conf | grep 127
proxy_pass http://127.0.0.1:8089;
# proxy_pass http://127.0.0.1:8089/user;
作用是将左边的结果作为右边的输入
更多示例
[root@VM-12-15-opencloudos usr]# ll -h /usr/bin|grep cd
-rwxr-xr-x. 1 root root 26 Jul 25 2022 cd
lrwxrwxrwx. 1 root root 6 Jul 25 2022 mcd -> mtools
echo 命令
在命令行输出指定内容,可以使用反引号,输出其中的命令的内容
[root@VM-12-15-opencloudos usr]# echo "hello world"
hello world
[root@VM-12-15-opencloudos usr]# echo `pwd`
/usr
[root@VM-12-15-opencloudos usr]# echo `1+1`
-bash: 1+1: command not found
重定向符 > 和 >>
>:将左侧命令的结果,覆盖写入到符号右侧指定的文件中
>>:将左侧命令的结果,追加写入到符号右侧指定的文件中
[root@VM-12-15-opencloudos usr]# ll > text.txt
[root@VM-12-15-opencloudos usr]# cat text.txt
total 140
dr-xr-xr-x. 2 root root 36864 Jan 30 16:43 bin
drwxr-xr-x. 2 root root 4096 Jan 30 2023 config
drwxr-xr-x. 2 root root 4096 May 26 2022 games
drwxr-xr-x. 50 root root 4096 Oct 25 13:38 include
dr-xr-xr-x. 36 root root 4096 Oct 25 13:37 lib
dr-xr-xr-x. 61 root root 45056 Oct 25 13:38 lib64
drwxr-xr-x. 32 root root 4096 Jul 7 2023 libexec
drwxr-xr-x. 27 root root 4096 Oct 25 15:28 local
dr-xr-xr-x. 2 root root 20480 Mar 18 17:49 sbin
drwxr-xr-x. 116 root root 4096 Jul 7 2023 share
drwxr-xr-x. 5 root root 4096 Jan 30 2023 src
-rw-r--r-- 1 root root 0 Mar 31 14:36 text.txt
lrwxrwxrwx. 1 root root 10 May 26 2022 tmp -> ../var/tmp
tail命令
查看文件尾部内容,跟踪文件的最新修改
tail [-f -num] linux路径