Questo contenuto non è disponibile nella lingua selezionata.
Chapter 7. Using the command-line assistant to debug or troubleshoot system issues
Use the command-line assistant powered by RHEL Lightspeed to request troubleshoot information for issues on your system.
To troubleshoot your system, ask a question by using the following syntax: c + "<question>". For example:
-
$ c "how to troubleshoot network errors" -
$ 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 failing 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. Using the command-line assistant to troubleshoot the SSHD service failing to start Copia collegamentoCollegamento copiato negli appunti!
You can use the command-line assistant powered by RHEL Lightspeed to troubleshoot an SSHD service that fails to start.
You can use these command-line assistant features:
- The command-line assistant includes an optional terminal capture feature to reference the output of previous commands.
- You can use the assistant for piping data into the command-line assistant.
Prerequisites
- You have enabled the command-line assistant.
- You have root access to your system.
Procedure
Check the SSHD status and restart it.
$ sudo systemctl status ssh $ sudo systemctl restart sshEnable the optional command-line assistant terminal capture feature:
$ c shell --enable-captureUse the
-w 1 "your_question"option to specify to include the output from the last command that was run.$ c -w 1 "what_is_this"- If you specify the number 2, that references the output from the second-to-last command. This is also true for the additional numbers.
You can also specify a prompt to run with the command and ask "help me understand the output", and reference the output with the error, so that the command-line assistant understands that you are asking for more details on what the error is.
The command-line assistant processes the request and provides several possible solutions. In the example, you can use the suggestion to run the
journalctl -xeu sshd.servicecommand to check the log files.
Run that
journalctlcommand and check the log files to identify potential issues.$ journalctl -xeu sshd.serviceAsk the command-line assistant to generate a command on how to fix this typing error.
$ c "what is the command that I can use to change 'Porrt' to 'Port' in the /etc/ssh/sshd_config file?"Run the command suggested by the command-line assistant as a sudo user. For example:
$ sudo sed -i s/Porrt/Port/g /etc/ssh/sshd_config
Verification
Restart the SSHD service and check the status of the SSHD.
$ sudo systemctl restart sshd $ sudo systemctl status sshd
7.2. Using the command-line assistant to troubleshoot SELinux issues Copia collegamentoCollegamento copiato negli appunti!
You can troubleshoot SELinux issues by using the command-line assistant. The example troubleshooting process demonstrates the diagnostic capabilities of the command-line assistant.
Prerequisites
- You have enabled the command-line assistant.
- You have root access to your system.
Procedure
Check the
httpdpackage version and identify the ports on which the web server accepts incoming requests:$ sudo rpm -qa httpdhttpd-2.4.62-2.fc40.x86_64$ cat /etc/httpd/conf/httpd.conf | grep ListenListen 80Restart the
httpdservice and check for errors:$ systemctl restart httpd $ sudo journalctl -xeu httpd.serviceJob for httpd. Service failed because the control process exited with error code.Use the command-line assistant to troubleshoot the service failure and check SELinux status:
$ c "why did httpd fail to start" $ c "selinux httpd port" $ sudo sestatusCheck the SELinux context for
httpdand ask the command-line assistant for guidance:$ sudo cat /usr/share/selinux/targeted/contexts/httpd_var_run_tNo such file or directory$ c "i don't have a httpd_var_run_t contexts"Set the SELinux context and configure the port as suggested by the command-line assistant:
$ sudo chcon -R -t httpd_var_run_t $ c "selinux won't let httpd listen on port 12345" $ sudo semanage port -a -t httpd_port_t -p tcp 12345If you receive a
ValueError, ask the command-line assistant and apply the suggested fix:$ c "how do I fix ValueError: Type httpd_port_t is invalid, must be a port type" $ sudo ls -Z /usr/sbin/httpd $ chcon -t httpd_exec_t /usr/sbin/httpd $ sudo setenforce 1Restart
httpdand enable network connections if the service still fails:$ sudo systemctl restart httpd $ c "how do I enable httpd to listen on port 12345 selinux" $ sudo setsebool -P httpd_can_network_connect=1If the service fails again, check the journal and search for SELinux denials:
$ journalctl -xeu httpd $ c "An ExecStart= process belonging to unit httpd.service has exited." $ sudo ausearch -m AVC,USER_AVC -ts recentEnter the AVC denial output to the command-line assistant for analysis:
$ c "avc: denied {name_bind} for pid=7184 comm="httpd" src=12345 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:unreserved_port_t:s0 tclass=tcp_socket permissive=0"Add the port to the correct SELinux type to resolve the binding error:
$ sudo semanage port -a -t http_port_t -p tcp 12345
Verification
Restart the httpd service and check the status of
httpd.service:$ sudo systemctl restart httpd$ No error$ sudo systemctl status httpd.serviceThe server is configured, up and running, and listening on
port 443,port 12345.