basic Unix command not found - shell

I've installed mysql on my laptop.
Now when I launch a terminal window and a unix command like grep, I get this message:
-bash: grep: command not found
-bash: cat: command not found
...
What's happen ? Do you have skills or any ideas to retrieve my precious unix functions ?

I'd like to put this in a comment, but I don't have enough reputation, sorry!
Basic Unix commands like grep or cat are most likely in this folder:
/usr/bin
In order for them to work, you need to have the correct set up of your PATH variable. You might have changed it unknowingly during the installation of mysql.
You can fix this temporarily by trying something like:
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
This will add whatever you have on your PATH at the moment, all the "normal" routes to your precious unix functions. Try the commands again after executing this line in your terminal, and let us know :)

Related

Windows PATH seems broken in Git Bash

I installed MySQL and wanted to see if it worked well, testing it on Git Bash (the course told me to do so). The code I had to write was the following one: export PATH=/c/Program Files/MySQL/MySQL Server 8.0/bin/:$PATH.
The main issue is that every time I open again Git Bash there are several lines saying not a valid identifier. I can't provide an image as I'm new, but one of the examples might be:
bash: export: `Corporation/NVIDIA': not a valid identifier
Although I deleted Git Bash and reinstalled again, the problem persists. Does anyone know how to fix that on Windows?
Thanks in advance!
Because the path contains spaces, it needs to be quoted:
export PATH="/c/Program Files/MySQL/MySQL Server 8.0/bin/:$PATH"
You need to change this in whatever file you originally wrote this line in; it's probably named .bashrc or .bash_profile and can be found in your home directory (typically c:\Users\YourUsername).

Terminal commands can not be found OSX

A majority of terminal commands don't work, for example .
ls
sudo
vi
with the error -bash: ls: command not found my path is echo $PATH
β€œ/Users/username/usr/local/bin I get the feeling that β€œ should not be there but not sure how edit it.
What should the path be and how do I get the path to stay the same?
You need to add more paths to your $PATH variable. Try running whereis ls and check where is the binary of the command.
You can add more paths like this: export PATH=$PATH:NEW_PATH
I had a similar experience recently where a lot of my terminal commands were not being found despite being clearly saved in my bash_profile. After lengthy process of elimination I realised that the issue was caused when I tried to export a new path. The error that I had made was putting a space in the command. So I had to change
export SOMETHING = /path/to/something.apk to
export SOMETHING=/path/to/something.apk
So I would recommend you check all your path declarations to ensure you don't have any white spaces. Also don't forget to source your bash_profile or what ever type of command line shell you use.

unix commands not working

I wanted to start developing in ruby on rails, so I followed few tutorials how to set everything needed. However, I have problem now, because basic commands in terminal window dont work. For example if I type: whoami, ls, etc... error appears saying: -bash: whomami: command not found
when I type: $PATH, this appears: -bash: /Library/Ruby/Gems/2.0.0: is a directory
did I make a mistake while setting up rails environment or it's another problem? If you have similar experiences, please help me to solve this.
Thanks
Try the following command.
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Better you use this command in you .bashrc file.

Ubuntu Shellscript Path Variable

I have the following Shellscript that I call from my crontab, which works fine until it calls php code that involves shell commands like wget or find.
#!/bin/sh
PATH=/opt/server/php/bin:/usr/bin/wget:/bin/egrep:/usr/bin/find
cd /opt/server/apache2/htdocs/webapp/
php oil refine job:handler
For each Command I did a which command to look up the path, then I added it to the Path Variable. Nevertheless it does not find the commands and I get messages like these:
sh: wget: not found
sh: find: not found
How would I fix this? I know that this is a common problem, but I didn't find a good explanation for this here on stackoverflow. Also: I know that calling the script from bash versus crontab might result in different enviroment settings, but eitherway I get these Errors.
Good sir, the PATH is a string that describes the directories that contain executables, not the executables themselves.
Perhaps use something like this
PATH=/opt/server/php/bin:/usr/bin:/bin

In Mac OSX 10.5, it can't find my Terminal commands sudo, find, etc

I don't know what has happened, but in my Terminal on Mac OSX 10.5 it can no longer find my sudo command, or find command, etc. They are there because if I put /usr/bin/sudo or /usr/bin/find it works fine...
My .bash_login file looks like this:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
My .bash_profile file looks like this:
export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.5/site-packages/django_trunk/django/bin:/usr/local/mysql/bin:/usr/bin/sudo$PATH"
I'll say now, I don't really know what I'm doing with the Terminal. I'm just a beginner to it all, and I must of done something for the environment variables (is that what they're called?) to be lost. I presumed I'd just have to make sure the /usr/bin/ path is in my bash files, but they are, and it doesn't seem to work. Please help!
Also, when I do use the /usr/bin/find command, it says "Permission denied" to me, even though I am logged into Mac OSX as the System Administrator account. I don't understand.
Any help would be grand. Thank you - James
It looks like both of your PATH exports are malformed:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin$PATH"
The end bit there won't work. It should be:
export PATH=/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/bin:$PATH
Notice the colon before '$PATH'? It's important ;)
Also, the double quotes are not necessary.
If this doesn't work, we will need more information. It is possible that something else is modifying your path even after your shell configurations are loaded.
Can you post the results of:
$ echo $PATH
Configuration files are not always a good indication of the current environment variables, since they are modified by many programs and files, all across your system. To see all of your environment variables, you can run:
$ env
This should fix the problem completely and permanently.
first, export environment paths by using below command in the terminal.
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bβ€Œβ€‹in
now you have the commands you want. (eg. try ls. You'll see the command is working). But this is only for the current session. If you close the terminal and open a new one, you will have the previous issue. To make this change permanent, use below command,
go to home directory
cd ~
open .bash_profile file in nano / vim (I'm using nano here)
nano .bash_profile
This will open up nano editor. In a new line, paste the following;
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:$PATH
press 'control'+'o' to save (WriteOut) and 'control'+'x' to exit nano.
All done ! Now try the commands.
Check out --- http://www.sweeting.org/mark/blog/2008/05/26/mac-os-x-tip-setting-path-environment-variables
I went trough the same issue and here is how I solved it.
First of all I reverted the file to its original doing this way
/usr/bin/nano ~/.bash_profile
In my case I was not able to make work any command alias. Even vi or vim didnt work without specifying the full path of that command.
If nano is not installed just replace nano in the command by the editor installed
After that just restart the computer. In my case as I said bellow I could not use any command. When trying to do /usr/bin/source ~/.bash_profile
that command failed. So I had to restart the OS and it worked

Resources