例如需要查看sshd服务的配置文件所在位置

grep -rn “sshd_config” /etc

/etc: 表示/etc目录所有文件,也可以是某个文件名

-r 是递归查找

-n 是显示行号

-R 查找所有文件包含子目录

-i 忽略大小写

[root@localhost 桌面]# grep -rni "sshd_config" /etc
/etc/ssh/sshd_config:1:#    $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $
/etc/ssh/sshd_config:4:# sshd_config(5) for more information.
/etc/ssh/sshd_config:8:# The strategy used for options in the default sshd_config shipped with
/etc/redhat_security/security.conf:48:101@m@/etc/ssh/sshd_config@Protocol @2
/etc/redhat_security/security.conf:50:102@m@/etc/ssh/sshd_config@SyslogFacility @AUTH
/etc/redhat_security/security.conf:51:102@m@/etc/ssh/sshd_config@LogLevel @VERBOSE
/etc/redhat_security/security.conf:53:103@m@/etc/ssh/sshd_config@X11Forwarding @no
/etc/redhat_security/security.conf:55:105@m@/etc/ssh/sshd_config@PubkeyAuthentication @yes
/etc/redhat_security/security.conf:56:105@m@/etc/ssh/sshd_config@RSAAuthentication @yes
/etc/redhat_security/security.conf:58:105@m@/etc/ssh/sshd_config@IgnoreRhosts @yes
/etc/redhat_security/security.conf:59:105@m@/etc/ssh/sshd_config@RhostsRSAAuthentication @no
/etc/redhat_security/security.conf:62:106@m@/etc/ssh/sshd_config@HostbasedAuthentication @no
/etc/redhat_security/security.conf:64:108@m@/etc/ssh/sshd_config@PermitEmptyPasswords @no
/etc/redhat_security/security.conf:66:109@m@/etc/ssh/sshd_config@PermitUserEnvironment @no
/etc/redhat_security/security.conf:69:110@m@/etc/ssh/sshd_config@Ciphers @aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@@openssh.com,aes256-gcm@@openssh.com,chacha20-poly1305@@openssh.com
/etc/redhat_security/security.conf:71:111@m@/etc/ssh/sshd_config@ClientAliveCountMax @0
/etc/redhat_security/security.conf:74:112@m@/etc/ssh/sshd_config@Banner @/etc/issue.net
/etc/redhat_security/security.conf:77:113@m@/etc/ssh/sshd_config@MACs @hmac-sha2-512,hmac-sha2-512-etm@@openssh.com,hmac-sha2-256,hmac-sha2-256-etm@@openssh.com,hmac-sha1,hmac-sha1-etm@@openssh.com
/etc/redhat_security/security.conf:80:114@m@/etc/ssh/sshd_config@StrictModes @yes
/etc/redhat_security/security.conf:83:115@m@/etc/ssh/sshd_config@UsePAM @yes
/etc/redhat_security/security.conf:86:116@m@/etc/ssh/sshd_config@AllowTcpForwarding @no
/etc/redhat_security/security.conf:89:117@m@/etc/ssh/sshd_config@Subsystem sftp @/usr/libexec/openssh/sftp-server -l INFO -f AUTH
/etc/redhat_security/security.conf:91:118@m@/etc/ssh/sshd_config@AllowAgentForwarding @no
/etc/redhat_security/security.conf:93:119@m@/etc/ssh/sshd_config@GatewayPorts @no
/etc/redhat_security/security.conf:95:120@m@/etc/ssh/sshd_config@PermitTunnel @no
/etc/redhat_security/security.conf:98:121@m@/etc/ssh/sshd_config@KexAlgorithms@ curve25519-sha256,curve25519-sha256@@libssh.org,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256

可以查到名为sshd_config的配置文件在/etc/ssh目录下

基本上所有服务的配置文件中都有该服务同名的介绍信息,例如/etc/ssh/sshd_config:1:# $OpenBSD:
sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $
表示/etc/ssh/sshd_config文件的第一行含有带sshd_config关键字的信息

另外,在生产环境中,我们经常会碰到一个报错或者知道端口 但是却不知道配置文件的路径在哪里,这时候用grep -rni就能轻松解决,例如查找使用8080端口的服务配置文件在哪里

[root@localhost 桌面]# grep -rni "port 8080" /etc
/etc/tomcat/server.xml:67:         Define a non-SSL/TLS HTTP/1.1 Connector on port 8080

可以看到某软件服务使用8080端口的配置文件写在/etc/tomcat/目录下的server.xml中,判断该8080端口被tomcat服务所使用

grep -rn搜索服务配置文件信息、log字段信息相关推荐

  1. Sql Server获取数据库名,表信息,字段信息,主键信息等

    --Sql Server获取数据库名,表信息,字段信息,主键信息等--获取所有数据库名: SELECT name FROM master..sysdatabases WHERE name NOT IN ...

  2. 批量获取指定数据库的表信息和字段信息

    当前使用的mysql数据库和-Navicat Premium数据库视图软件 原理:在mysql数据库中存在两个常用的表,记录了我们创建的表名和各个不同的表中有的字段. 记录表名的表: 记录到字段的表: ...

  3. grep 显示搜索的关键字相关的行信息

    通过grep命令可以查找到所需的关键字所在行数的信息,但如果想看到所在行上下几行的信息应该怎么操作? grep -A 5 "xxx" file 显示xxx及后5行 grep -B ...

  4. oracle查看所有表信息和字段信息以及注释信息等

    1.获取表: select table_name from user_tables; //当前用户拥有的表select table_name from all_tables; //所有用户的表sele ...

  5. 详解MySQL information_schema数据库常用的表信息以及各表对应的字段信息;以及如何登录mysql和创建视图

    详解information_schema数据库 登录mysql 查询information_schema信息 information_schema常用数据表 TABLES 查询tables table ...

  6. SAP 自定义信息类型-字段搜索帮助方法

    一.涉及引用标准字段的搜索帮助 例:自定义一个信息类型,对应储备岗位要做搜索帮助,效果如下图 方法:在2000屏逻辑流中代码处理 module  values_plans * 生成者 TNIT-LTT ...

  7. 【项目介绍】ElasticSearch7+Spark 构建高相关性搜索服务千人千面推荐系统

    我做的项目是在慕课网买的 项目介绍 项目需求背景:模仿大众点评应用提供用户线下搜索推荐服务门店的需求 技术选型:后端业务:SpringBoot:后端存储:MySQL.mybatis接入:搜索系统:El ...

  8. 分布式全文搜索服务Elasticsearch

    1.ElasticSearch简介 1.1 什么是ElasticSearch Elasticsearch,简称为es,是一款开源的高扩展的分布式全文搜索服务,它可以近乎实时的检索数据:本身扩展性很好, ...

  9. 华为开发者大会HDC.Cloud技术探秘:云搜索服务技术实践

    搜索是一个古老的技术,从互联网发展的第一天开始,搜索技术就绽放出了惊人的社会和经济价值.随着信息社会快速发展,数据呈爆炸式增长,搜索技术通过数据收集与处理,满足信息共享与快速检索的需求.基于搜索技术, ...

最新文章

  1. 小程序点击图片自动播放视频,停止上一个视频播放
  2. Office Tab免费版:标签化浏览和编辑Office文档
  3. vue-preview动态获取图片宽高并增加旋转功能
  4. [渝粤教育] 西南科技大学 电器设备及维修 在线考试复习资料
  5. ASP.NET Callback 回调实用讲解
  6. (三)SpringMVC实现
  7. %3cphp和%3c php_phpcmsv9后台登录绕过
  8. 【caffe-windows】 caffe-master 之 卷积核可视化(利用matlab)
  9. javascript oo实现
  10. Xcode8上传app一直显示正在处理
  11. 【手写数字识别】基于matlab RBF手写数字识别【含Matlab源码 471期】
  12. TCP/IP、HTTP、HTTPS
  13. R语言实战——单个总体均值的区间估计
  14. Google OpenThread 技术研讨会
  15. 中国男人到底配不配得上中国…
  16. [附源码]计算机毕业设计小太阳幼儿园学生管理系统Springboot程序
  17. 关于浏览器的深入解析都在这31张图里!
  18. vmware 下ubuntu共享主机文件
  19. 【自动控制原理仿真实验】 稳定性及稳态误差实验(实验三)
  20. 混沌图像---蔡氏电路的漩涡

热门文章

  1. python中drop用法_Python drop方法删除列之inplace参数实例
  2. 论文:预测原子距离进行构象预测(VAE)
  3. Qt线程错误记录registered using qRegisterMetaType()
  4. 怎样快速上手深度学习?谷歌官方推荐的 TensorFlow 2 “豹书”来了!
  5. eclipse与tomcat7配置
  6. elastic-job入门(二)
  7. 最新版akamai2.0逆向分析爬虫破盾风控绕过tls指纹
  8. semantic-ui基础使用
  9. [原创]个人收集有关计算机视觉和模式识别相关的网址
  10. mysql第五章 在线测试_PHP+MySQL实现在线测试答题示例