- Newest
- Most votes
- Most comments
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.
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.
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.
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:
- 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." - After rebooting, the system is unable to recognize critical commands like
ls
,lesspipe
, anddircolors
. - You mentioned modifying
/etc/environment
to add a Java path (JAVA_HOME
), which might have overwritten yourPATH
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 likels
anddircolors
./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:
- Use the EC2 console to access the instance via the Systems Manager Session Manager or EC2 Serial Console.
- Temporarily fix the
PATH
variable to restore critical commands. - Correct the
/etc/environment
file to avoid future issues. - Reboot the instance and verify the solution.
Step-by-Step Guide:
-
Access the Instance via the EC2 Console:
If you cannot SSH into your instance due to the missingPATH
, 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
- Temporarily Fix the
PATH
Variable:
Once you have access, manually set a temporaryPATH
to restore basic commands:
Now, commands likeexport PATH=/usr/bin:/bin:/usr/sbin:/sbin
ls
andvi
should work again.
- Fix the
/etc/environment
File:
Open the/etc/environment
file to inspect and correct it. Ensure thePATH
includes all critical directories:
Replace or add the following line to fix thesudo vi /etc/environment
PATH
:
Save the file and exit.PATH="/usr/bin:/bin:/usr/sbin:/sbin:$JAVA_HOME/bin"
- Reboot the Instance and Verify:
Reboot your instance to ensure the changes are applied correctly:
After rebooting, SSH into the instance and confirm thesudo reboot
PATH
variable is correctly configured:
It should now includeecho $PATH
/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:
- AWS EC2 User Guide
- Setting Environment Variables in Linux
- Using EC2 Serial Console for Troubleshooting
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 😊
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 2 years ago