Can't run any commands at shell

MarcMonteiro

New Member
Joined
Jan 8, 2020
Messages
2
Reaction score
0
Credits
0
Hi all,
I installed OpenJDK 13 the I did the global shell start-up file.
# vi /etc/environment
Added:
Export JAVA_HOME=/opt/jdk-13/
Export PATH=$PATH:/opt/jdk-13/bin
Then ran the following command to active it.
# source /etc/environment
Then after that when I log in to the server again, it gave me this.
-bash: tty: command not found
-bash: ls: command not found
/usr/libexec/grepconf.sh: line 5: grep: command not found
-bash-4.2$
Now I can’t run any commands. How should I recover this?

$ sudo su
-bash: sudo: command not found
$ yum update
-bash: yum: command not found
$ vi /etc/hosts
-bash: vim: command not found
$ cd /etc/
$ ls
-bash: ls: command not found



thanks.
 


With all of the error messages about missing commands - I think you might have borked $PATH.

Perhaps try editing /etc/environment using:
/usr/bin/vi /etc/environment
And then perhaps either comment out or remove the modifications you made. Save the file and quit vi - Then log out and log back in again and see if that has fixed it for you!
Or perhaps make the changes to the file, reboot the server and then log-in.
 
With all of the error messages about missing commands - I think you might have borked $PATH.

Perhaps try editing /etc/environment using:
/usr/bin/vi /etc/environment
And then perhaps either comment out or remove the modifications you made. Save the file and quit vi - Then log out and log back in again and see if that has fixed it for you!
Or perhaps make the changes to the file, reboot the server and then log-in.

Hi JasKinasis, thanks for you replay.

I followed your suggestions and I can open file "environment". But I can't save then after edition. I think that I can do this only as root user or using sudo command (not work). And now I have other problem. after reboot server, I can login only as a common user, the root account don't have permission to login though terminal.
 
What distro? I assume it's redhat/centos/fedora since you are using yum.

Can you "echo $PATH" do you see output from this?
Some of the newer redhat/fedora distro's disable root ssh, but you can re-enable it.
Also if you know the root password, simply ssh as standard user, then "su -"
(It will ask for root password).
If your commands work as root, then it's either $PATH (as JasK mentioned) or permissions.
 
Ah - of course! I forgot about that! You need to be root in order to edit /etc/environment. Oops!
In which case - you'll have to work out where the sudo executable is and use the fully qualified path to sudo. e.g. /usr/bin/sudo, or /bin/sudo - wherever sudo is!
And then use that.
e.g.
/usr/bin/sudo /usr/bin/vi /etc/environment
or /bin/sudo, or whatever the actual path to sudo is!
if your user is in the sudoers file - you should be able to edit the file as root.

Don't worry too much about root login ATM - what you need for now is to get your environment back to how it should be, so you can run normal commands.
I've never seen or experienced this problem myself. I'm just spit-balling some ideas to try to help fix things.
 

Members online


Latest posts

Top