day09 文本的搜素与查询

day09 文本的搜素与查询

了解网站的部署

1.nginx 练一练

yum install nginx 


2.简单了解,给你的机器,配置一个软件仓库(360软件大师,点点点,下载各种工具,它的软件,还携带了一堆广告



无须任何处理
[root@linux-yzk ~]# systemctl start nginx
命令是 ,仅仅查看这个机器上的 nginx进程信息,是否存在
[root@linux-yzk ~]# ps -ef |grep nginx
root       6875      1  0 16:15 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx      6876   6875  0 16:15 ?        00:00:00 nginx: worker process
nginx      6877   6875  0 16:15 ?        00:00:00 nginx: worker process
nginx      6878   6875  0 16:15 ?        00:00:00 nginx: worker process
nginx      6879   6875  0 16:15 ?        00:00:00 nginx: worker process
root       6881   6778  0 16:15 pts/1    00:00:00 grep --color=auto nginx
[root@linux-yzk ~]# 

6. 一个网站的运行,默认端口是 http的80端口
用你的客户端,浏览器去访问, 
10.96.0.134:80即可


7.注意关闭服务器的防火墙
执行命令
[root@localhost opt]# iptables -F


8.停止这个网站服务,思路是?
停用80端口,也就是,停止这个软件的运行
[root@localhost opt]# systemctl stop nginx

再次重新运行,命令是
systemctl restart nginx

前面是让我们大概了解一下接下来才是本文主旨

cat 命令

1.cat 适合读取小文件,不能读取大文件,一次性将文件内容全部读取到内存中,且输出到屏幕上

查看nginx软件的配置文件(前提是你安装了该软件,linux默认安装的软件,配置文件会自动写到/etc目录下)

[root@linux-yzk ~]# cat /etc/nginx/nginx.conf
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

-查看系统的用户信息

cat /etc/passwd

-显示行号

cat -n

- 从定向符号的使用
    >   重定向覆盖输出符  ,数据从左边,覆盖写入到右边 
    <   重定向覆盖输入符,数据从右边,覆盖写入到左边
    >>  重定向追加输出符, ,数据从左边,追加写入到右边 
    <<  重定向覆盖输入符,数据从右边,追加写入到左边



[root@localhost opt]# echo 春晓 > 春晓.txt
[root@localhost opt]# echo 春眠不觉晓 > 春晓.txt
[root@localhost opt]# 
[root@localhost opt]# 
[root@localhost opt]# echo 春晓 > 春晓.txt
[root@localhost opt]# 
[root@localhost opt]# 
[root@localhost opt]# echo 春眠不觉晓 >> 春晓.txt
[root@localhost opt]# echo 处处蚊子咬>> 春晓.txt
[root@localhost opt]# echo 越来讽喻诗>> 春晓.txt
[root@localhost opt]# 
[root@localhost opt]# echo 滑落至多为>> 春晓.txt
[root@localhost opt]# 
[root@localhost opt]# 
[root@localhost opt]# cat 春晓.txt 
春晓
春眠不觉晓
处处蚊子咬
越来讽喻诗
滑落至多为



cat >> 古诗2.txt <<EOF
你的数据在这里写。。。
EOF

EOF是一个关键字,end of file  ,文件的结束

[root@localhost opt]# cat  >>古诗2.txt <<EOF
> 嗯嗯嗯
> 呃呃呃,曲项向天歌
> 白毛浮绿水
> 红掌拨清波
> EOF
[root@localhost opt]# 
[root@localhost opt]# 
[root@localhost opt]# cat 古诗2.txt 
嗯嗯嗯
呃呃呃,曲项向天歌
白毛浮绿水
红掌拨清波

tac 命令

将文件从后往前看,到着看

[root@localhost opt]# cat  -n hehe.txt 
     1	yuchao
     2	yejingyang
     3	chenliangliang
[root@localhost opt]# 
[root@localhost opt]# 
[root@localhost opt]# tac hehe.txt 
chenliangliang
yejingyang
yuchao

ls 和 sl的区别

安装sl这个命令

yum install sl 

这是一个小火车

more和 less 命令

more和cat都是一次性读取所有内容到内存,不适合读取大文件,占资源

less命令是显示多少文本,消耗多少内存,省资源。

head 和tail (重点)

head 看前5行

tail 看后5行

head 脑袋

查看文件的默认前10行
[root@localhost opt]# head  doupo.txt 



head -5  文件   # 查看文件的前5行




tail 命令
查看文件的后默认10行
tail -5  文件  #表示查看文件的后5行


tail有一个重点命令,叫做实时刷新文件内容

-f  跟踪文件内容变化,但是需要文件正常退出后,可见,最常用的也就是小写的f,检测程序的日志变化(程序代码,追加新内容到文件中的)

find找文件

windows下的强大搜索工具

everything工具

linux的工具是谁?---find命令。

find是递归查找

学习一个命令,先学语法

find   从哪找   -name  "你要找什么"

# 从机器上,找到doupo.txt文本

find  /  -name 'doupo.txt'

[root@localhost ~]# find  /  -name 'doupo.txt'
/opt/doupo.txt
[root@localhost ~]# 
[root@localhost ~]# 

缩小搜索范围,从/opt开始找
[root@localhost ~]# 


[root@localhost ~]# find  /opt  -name 'doupo.txt'
/opt/doupo.txt




如果文件名是写死的,找不到,那就是这个/opt目录下没有该文件
[root@localhost ~]# find  /opt  -name 'doupo.txt1'
[root@localhost ~]# 
[root@localhost ~]# 

最大范围,全系统搜索
[root@localhost ~]# find  /  -name 'doupo.txt1'



# 找到机器上所有的 doupo.txt

[root@localhost ~]# # 找出机器上所有的 doupo.txt
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# find  /  -name 'doupo.txt'
/etc/doupo.txt
/tmp/doupo.txt
/usr/local/doupo.txt
/home/doupo.txt
/opt/doupo.txt
[root@localhost ~]# 



# 模糊查找,找出/var下所有的log文件  nginx.log  mysql.log   yuchao.log    *.log 
[root@localhost ~]# # 模糊查找,找出/var下所有的log文件
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# find /var  -name '*.log'


# 找出机器上,所有的png图片
[root@localhost ~]# find / -name '*.png'




# -type  f   找到文本类型的数据 
# -type  d    找到文件夹类型的数据


# 找出机器上所有的 doupo.txt 【文件,文本文件,可以被cat的文件】
# 严格注意命令的语法细节!!
# 严格注意命令的语法细节!!
# 严格注意命令的语法细节!!

find /    -type f     -name   'doupo.txt' 









posted @ 2025-02-28 16:59  国家一级冲浪yzk  阅读(26)  评论(0)    收藏  举报