第 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"
7.1. 使用命令行助手来对 SSHD 服务进行故障排除 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
您可以使用命令行助手对无法启动的 SSHD 服务进行故障排除。
您可以使用这些命令行助手功能:
- 命令行助手包括一个可选的命令行捕获功能,可用于引用之前命令的输出。
- 您可以使用助手在命令行助手中传送数据。
先决条件
- 您已启用了命令行助手。
- 您有对系统的 root 访问权限。
流程
检查 SSHD 状态并重启它。
$ sudo systemctl status ssh $ sudo systemctl restart ssh启用可选的命令行助手命令行捕获功能:
$ c shell --enable-capture使用
-w 1 "your_question"选项指定包含运行的最后一个命令的输出。$ c -w 1 "what_is_this"- 如果您指定了数字 2,它将引用 second-to-last 命令的输出。对于其他数字,这也适用。
您还可以使用命令指定运行提示,并询问"帮助我了解输出",并在出错时引用输出,以便命令行助手了解您需要了解错误的详情。
命令行助手处理请求并提供多个可能的解决方案。在示例中,您可以使用建议运行
journalctl -xeu sshd.service命令来检查日志文件。
运行
journalctl命令并检查日志文件,以识别潜在的问题。$ journalctl -xeu sshd.service让命令行助手生成一个有关如何修复此输入错误的命令。
$ c "what is the command that I can use to change 'Porrt' to 'Port' in the /etc/ssh/sshd_config file?"以 sudo 用户身份运行命令行助手所推荐的命令。例如:
$ sudo sed -i s/Porrt/Port/g /etc/ssh/sshd_config
验证
重新启动 SSHD 服务,并检查 SSHD 的状态。
$ sudo systemctl restart sshd $ sudo systemctl status sshd