None of the commands are working in ec2 machine.
-bash: id: command not found
-bash: id: command not found
-bash: id: command not found
-bash: tty: command not found
-bash: mktemp: command not found
-bash: $TMP: ambiguous redirect
-bash: rm: command not found
-bash: vim: command not found
I guess I did some changes in /etc/environment for setting PATH of java and after some time I am not able to run any of the commands in the next login.
Anyone please help, what should I do in order to run these commands perfectly again?
I screwed up by appending the PATH by using export PATH=$PATH:
in /etc/environment file, as was not aware that $PATH does not work there in /etc/environment.
How i found my problem ?
A- I used command "which ls" then it showed me ls command location and which is /usr/bin and it also shows that PATH does not contain this.
How I solved my problem ?
A- As none of the command is working not even vi command so there was only option left was to do this :
PATH=$PATH:/usr/bin
export PATH
And after doing this , now i am able to sudo on my machine.
I hope ,it can be helpful for any other person who mistakenly screwed his/her environment.
Related
I get the following error (error.message) when I run the following shell script (myscript.sh).
myscript.sh
#!/bin/bash
cd /path/to/ && node app.js
error.message
/path/to/myscript.sh: line 1: #!/bin/bash: No such file or directory
/path/to/myscript.sh: line 2: node: command not found
I have already run the following command line instructions.
command-line
chmod u+x /path/to/myscript.sh
chmod u+x /path/to/app.js
Also, I know I have node installed because when I run:
node -v
I get back:
v5.5.1
I execute myscript.sh via the following AppleScript:
MyApp.applescript
do shell script "bash /path/to/myscript.sh"
Also: which bash returns /bin/bash
What could be causing this error and how can I fix it?
I fixed the first error:
/path/to/myscript.sh: line 1: #!/bin/bash: No such file or directory
By copying a working .sh file I had on my machine and copy/pasting the code from the old file to the new file.
I'm guessing somehow there was a filetype issue or discrepancy despite the fact that I used a .sh extension in the file name.
In the future, I will double check the file type in my Finder utility (Max OS X v10.10.1).
However, I am still seeing the second error:
/path/to/myscript.sh: line 2: node: command not found
Credit goes to #HeadCode and #mh-cbon for helping me figure this out with their comments.
I solved the second problem by running:
myshell.sh
#!/bin/bash
path/to/node path/to/app.js
where path/to/node was found by running
command-line
which node
and path/to/app.js is the actual file tree path to app.js. (In other words, different from path/to/node.)
Consider the following Makefile.
install:
sudo rpi-install.py /dev/ttyUSB0 foo.bin
Note that I have deliberately not hardcoded a path to rpi-install.py because it is not in the same location on other people's machines, but I expect it to be in the PATH of everyone who uses my code.
Unfortunately, when I type make install, I get the following output.
sudo rpi-install.py /dev/ttyUSB0 larson.bin
sudo: rpi-install.py: command not found
make: *** [install] Error 1
When I type the exact same command on my shell, it works exactly as expected.
Additionally, when I remove the sudo from the Makefile, it successfully finds the binary and gets a permission denied error due to lack of root privileges.
How can I allow make to discover the programs that are in my PATH when they must be run with sudo?
For the sake of reproducibility, assume that the following contents are in rpi-install.py, and that it lives in the directory $HOME/bin. Additionally assume that PATH includes $HOME/bin.
#!/usr/bin/env python
print "Hello World!"
There was a combination of two fixes that resolved this problem.
I needed to set PATH in .profile instead of .bashrc because the default shell /bin/sh used by make did not pick up the correct path from .bashrc.
I needed to set the environment for the sudo command inside the makefile explicitly to be the external PATH, based on this answer to this question.
sudo env "PATH=$(PATH)" rpi-install.py /dev/ttyUSB0 larson.bin
I have problem with sudo command when i changed $PATH
Problem:
-bash: id: command not found
-bash: tty: command not found
-bash: uname: command not found
[root#ol6 ~]# sudo
-bash: sudo: command not found
And echo $PATH
[root#ol6 ~]# echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:$PATH:/opt/jdk1.8.0_66/bin:/opt/jdk1.8.0_66/jre/bin
Could you tell me solve this problem.
thanks sm.
sudo is located in /usr/bin on RedHat, but I think your real problem is that you single-quoted $PATH when you altered your PATH and got a literal $PATH in it instead of what you intended!
You somehow got the literal string $PATH in your PATH variable, when you probably meant to add some stuff before and after it. I imagine you did this by using single quotes when assigning:
PATH='/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:$PATH:/opt/jdk1.8.0_66/bin:/opt/jdk1.8.0_66/jre/bin'
when you should have used double quotes
PATH="/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:$PATH:/opt/jdk1.8.0_66/bin:/opt/jdk1.8.0_66/jre/bin"
so the $PATH would expand to its current value (though it's too late for that in your current shell).
Anyway, for me, sudo is in /usr/bin so if you don't have that in your path you won't be able to run it without specifying the full path.
I just installed cygwin and zsh from the cygwin installer.
I launch C:\cygwin\bin\zsh.exe from the file explorer.
When zsh is launch for the first time, a small configutation is prompted.
I choose the minimal config by choosing : "Exit, creating the file ~/.zshrc containing just a comment. That will prevent this function being run again."
Now trying to use zsh, but I always have the "command not found" error
$ ls
zsh: command not found: ls
I don't understand why zsh can't do anything directly after the first launch.
How configure zsh to use all the cygwin bin commands located in the same folder C:\cygwin\bin ?
You need to invoke zsh as a login shell, by passing the --login or -l option. This tells it to source /etc/zprofile, which is where the search PATH is configured. You can do that by creating an Explorer shortcut to zsh.exe and adding the option to the target field.
This might be a noob question, but I need help. I screwed up my terminal by trying to alter my path variable using the following command:
$ sudo nano .profile
Before I did that, if I were to type:
$ echo $PATH
I would get: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
When I opened .profile in nano it told me that the file didn't exist. I figured that made sense, since I had never edited this file before. I proceeded to enter a path to a directory I was using for a php framework and saved the file.
After I saved the file, I noticed that none of my bash commands are working. Now I can't do anything from the terminal. I can't even edit .profile in nano because it says -bash: nano: command not found
I'm clearly new to working with the terminal. I feel completely lost. Please provide some guidance on how to restore the terminal to working condition.
Use absolute paths.
$ /usr/bin/sudo /usr/bin/nano .profile
If you add something to a path, never just do
PATH=/path/to/something
instead do
PATH=$PATH:/path/to/something
By the way, you shouldn't/don't have to use sudo to edit your own file, such as .profile. Use sudo only when you need to edit the file which doesn't to belong to your account.
I had the same problem!
The way I solved was writing the follow command in the terminal:
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/local/bin:/usr/local/git/bin:/usr/X11/bin
Hope it can be useful for you