第 7 章 使用命令行助手调试或排除系统问题


使用命令行助手请求故障排除系统上问题的信息。

要对您的系统进行故障排除,请使用以下语法询问问题: c + " <question>"。例如:

  • $ c "how to troubleshoot network error"
  • $ c "I cannot access my server with SSH.Can you give me a list of things to troubleshoot?"
  • $ c "I am failing to start sssd process"
  • $ c "I need to boot into a different kernel"
  • $ c "how to troubleshoot SSHD failure to start"
  • $ c "how do I find all the files in the /etc that have been modified in the last hour"
  • $ c "I am failing to start sssd process"

您可以使用命令行助手对无法启动的 SSHD 服务进行故障排除。

您可以使用这些命令行助手功能:

  • 命令行助手包括一个可选的命令行捕获功能,可用于引用之前命令的输出。
  • 您可以使用助手在命令行助手中传送数据。

先决条件

  • 您已启用了命令行助手。
  • 您有对系统的 root 访问权限。

流程

  1. 检查 SSHD 状态并重启它。

    $ sudo systemctl status ssh
    $ sudo systemctl restart ssh
  2. 启用可选的命令行助手命令行捕获功能:

    $ c shell --enable-capture
  3. 使用 -w 1 "your_question" 选项指定包含运行的最后一个命令的输出。

    $ c -w 1 "what_is_this"
    • 如果您指定了数字 2,它将引用 second-to-last 命令的输出。对于其他数字,这也适用。
    • 您还可以使用命令指定运行提示,并询问"帮助我了解输出",并在出错时引用输出,以便命令行助手了解您需要了解错误的详情。

      命令行助手处理请求并提供多个可能的解决方案。在示例中,您可以使用建议运行 journalctl -xeu sshd.service 命令来检查日志文件。

  4. 运行 journalctl 命令并检查日志文件,以识别潜在的问题。

    $ journalctl -xeu sshd.service
  5. 让命令行助手生成一个有关如何修复此输入错误的命令。

    $ c "what is the command that I can use to change 'Porrt' to 'Port' in the /etc/ssh/sshd_config file?"
  6. 以 sudo 用户身份运行命令行助手所推荐的命令。例如:

    $ sudo sed -i s/Porrt/Port/g /etc/ssh/sshd_config

验证

  • 重新启动 SSHD 服务,并检查 SSHD 的状态。

    $ sudo systemctl restart sshd
    $ sudo systemctl status sshd
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部