After install Nginx on my Ubuntu the system is crashed.

0

After install Nginx on my ubuntu the system send me the message "Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting." and crash, I can't enter any command on the terminal. I using the MTPuTTY to connect via SSH if I open another connection the result is that "Command 'lesspipe' is available in the following places

  • /bin/lesspipe
  • /usr/bin/lesspipe The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable. lesspipe: command not found Command 'dircolors' is available in the following places
  • /bin/dircolors
  • /usr/bin/dircolors The command could not be located because '/usr/bin:/bin' is not included in the PATH environment variable. dircolors: command not found". In my instance I choiced "Reboot Instance" in instance state button but not happen. Image of system crashed: image of system crashed Image of terminal where all commands is refused: image of terminal where all commands is refused Thanks and best regards.
asked 8 months ago177 views
4 Answers
0
Accepted Answer

Hello,

If you can enter the console, I would suggest to enter recovery mode and check logs. If NGINX is throwing something bad at the OS try to catch it.

Try also to purge current installation (Via recovery mode) and reinstall fresh.

profile picture
EXPERT
answered 8 months ago
profile picture
EXPERT
reviewed 7 months ago
0

Hi Giovanni, as you can see in the second image when the another terminal is opened he don't permit to type any linux command, so far the only solution I've seen is to delete and recreate my instance again, this time I won't install Nginx. Thanks by contact.

answered 8 months ago
0

Hello, I don't know if have a problem between ec2 and ubuntu system or the problem is my installation of the packages, because after delete my instance and recreate the instance the only thing that I did was install the java and intiated the installation of mysql , after some hours when I opened a ssh terminal to terminate the installation I receive again: "Command 'lesspipe' is available in the following places

  • /bin/lesspipe
  • /usr/bin/lesspipe The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable. lesspipe: command not found Command 'dircolors' is available in the following places
  • /bin/dircolors
  • /usr/bin/dircolors The command could not be located because '/bin:/usr/bin' is not included in the PATH environment variable. dircolors: command not found ubuntu@ip-172-31-86-198:~$ ls /etc/ Command 'ls' is available in the following places
  • /bin/ls
  • /usr/bin/ls" this isn't normal, unfortunity I don't have my /etc/environment file to show you the PATH in the file, after nstall java I alter the /etc/environment to include java path, I doing: export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 export PATH="$PATH:${JAVA_HOME}/bin" Thanks.
answered 8 months ago
0

Greeting

Hi Cezar,

Thanks for reaching out! I understand how frustrating it must be to run into system crashes and command issues, especially when managing an AWS EC2 instance. Let’s tackle this together to get your Ubuntu instance back on track. 😊🚀


Clarifying the Issue

From your explanation, it sounds like your AWS EC2 instance running Ubuntu has encountered three major problems:

  1. The system crashed after installing NGINX and displayed the message:
    "Restarting the system to load the new kernel will not be handled automatically, so you should consider rebooting."
  2. After rebooting, the system is unable to recognize critical commands like ls, lesspipe, and dircolors.
  3. You mentioned modifying /etc/environment to add a Java path (JAVA_HOME), which might have overwritten your PATH variable, leading to the loss of access to essential directories like /usr/bin and /bin.

This combination of system instability, reboot issues, and environment misconfigurations can be frustrating. Let’s break it down and resolve these issues step by step.


Why This Matters

When your PATH variable is misconfigured, the system cannot locate standard commands, essentially rendering the terminal useless. On an AWS EC2 instance, this can be a show-stopper because you depend on SSH access for all management tasks. Fixing this is essential to restore functionality without needing to recreate the instance every time, saving effort and preserving your data.


Key Terms

  • PATH Variable: A system environment variable that tells the shell where to look for executables like ls and dircolors.
  • /etc/environment: A configuration file used to define environment variables globally on an Ubuntu system.
  • SSH (Secure Shell): The protocol you are using (via MTPuTTY) to manage your AWS EC2 instance.
  • Recovery Mode: A safe boot mode for troubleshooting and repairing system-level issues.

The Solution (Our Recipe)

Steps at a Glance:

  1. Use the EC2 console to access the instance via the Systems Manager Session Manager or EC2 Serial Console.
  2. Temporarily fix the PATH variable to restore critical commands.
  3. Correct the /etc/environment file to avoid future issues.
  4. Reboot the instance and verify the solution.

Step-by-Step Guide:

  1. Access the Instance via the EC2 Console:
    If you cannot SSH into your instance due to the missing PATH, use the AWS Management Console:

    • Go to EC2 Instances in the AWS Console.
    • Use Systems Manager Session Manager (if configured) or the EC2 Serial Console (if enabled) to access the instance.

    Example:

    aws ssm start-session --target instance-id

  1. Temporarily Fix the PATH Variable:
    Once you have access, manually set a temporary PATH to restore basic commands:
    export PATH=/usr/bin:/bin:/usr/sbin:/sbin
    Now, commands like ls and vi should work again.

  1. Fix the /etc/environment File:
    Open the /etc/environment file to inspect and correct it. Ensure the PATH includes all critical directories:
    sudo vi /etc/environment
    Replace or add the following line to fix the PATH:
    PATH="/usr/bin:/bin:/usr/sbin:/sbin:$JAVA_HOME/bin"
    Save the file and exit.

  1. Reboot the Instance and Verify:
    Reboot your instance to ensure the changes are applied correctly:
    sudo reboot
    After rebooting, SSH into the instance and confirm the PATH variable is correctly configured:
    echo $PATH
    It should now include /usr/bin, /bin, and any other required directories.

Closing Thoughts

By fixing your PATH and ensuring the /etc/environment file is properly configured, your instance should be stable and functional again. Going forward, always append new paths (like Java’s) to the existing PATH variable rather than overwriting it.

For further reading, here are some helpful links:


Farewell

I hope this resolves your issue, Cezar! Let me know if you need additional help or clarification. Best of luck with your AWS and Ubuntu journey! 😊🚀


Cheers,

Aaron 😊

profile picture
answered 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions