ls,sudo commands not found (shell commands) - bash

I tried to install laravel Framework in my mac OSX 10 .And I ended modifying my ~/.bash_profile to add the laravel command. laravel command seems to work normally .But another problem came out . ls ,sudo ...and other shell commands does not work .
-bash: ls: command not found
My bash.profile file contains the two links
export PATH="/Applications/MAMP/bin/php/php5.6/bin"
export PATH="$PATH:$HOME/.composer/vendor/bin"

check in ~/.bash_profile if this PATHs exist
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
your complete line should looks like this
export PATH=/Applications/MAMP/bin/php/php5.6/bin:$HOME/.composer/vendor/bin:/opt/local/bin:/opt/local/sbin:$PATH
reboot needed.

The binaries for the above mentioned utilities for debian distribution are usually in /bin or /usr/bin directory. Of course exporting path won't help if the binaries are not there.
There could be one simple approach to it -
Check for the location of binaries and then export the path in the bash_profile or .bashrc.
Run the bashrc script (. ~/.bashrc) following you may not require a reboot.

Related

Command can't be found in zsh on windows

I'm trying to complete configuration of zsh. When I run commands in git-bash, it's OK. However, the error "zsh: command not fount" is reported when I run these commands in zsh itself. Then I check the file ".zshrc" and find the path exported may get wrong.
export PATH=$HOME/bin:/usr/local/bin:$PATH
These files are located in another directory but not in "$HOME". But I don't know how to alter the line.

Terminal is not working as usual mac after trying to install CakePHP

I was downloading the CakePHP framework for a project. Below the steps:
Installation
1) Install PHP 5.6 from: http://php-osx.liip.ch/
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
2) add the updated PHP version to our path. So we edit .profile file
nano ~/.profile
Add into the file
export PATH= /usr/local/php5/bin:$PATH
Then hit Control + O to write out the file
Then hit Control + X to save the file
exit
Restart the Terminal
Now the terminal doesn't work as usually. I've tried to understand the shell concept and apply different solutions, but I can't even find the .profile file again.
I obtain errors like:
enter code here-bash: ls: command not found
Anybody can explain me what's wrong and the shell concept to properly understand shell (-bash)?
The problem is this:
export PATH= /usr/local/php5/bin:$PATH
You killed your PATH variable. You need to find a way to edit .profile file, and change that line to:
export PATH=$PATH:/usr/local/php5/bin
You could try editing with the following command (using vim):
/usr/bin/vim /Users/yourname/.profile
Or (using nano):
/usr/bin/nano /Users/yourname/.profile
Or just remove .profile file completely by doing /bin/rm /Users/yourname/.profile. Of course, in any case, you need to restart your terminal once you're done.

How does one locate a .zshrc file?

I used Homebrew to install Z shell (zsh) 5.0.7 on my Mac.
For the life of me, .zshrc is nowhere to be found. It is not in ~. Is is not in /etc or /etc/zshrc as they suggest here: http://zshwiki.org/home/config/files
Am I supposed to create it myself?
Sure. If it's not there already, create it yourself.
$ touch ~/.zshrc
You can run the helper script zsh-newuser-install from the prompt, and it will walk you through the process to create an initial .zshrc in your home directory.
As kyranjamie mentioned, you can create it using following command
$ touch ~/.zshrc
Example content of .zshrc file:
PATH=$PATH:/your_path_goes_here
In order to find any file on a Unix-based system, you can try the command:
$ locate filename
It should list all the paths where the corresponding file exists.
In Unix based systems, touch command followed by name will create an empty file in the present directory.
the modification and access time of each file is also updated with the use of touch command.
In your case, to create .zshrc file, you can use the touch command as :
$ touch ~/.zshrc

mysqldump: command not found XAMPP

I'm trying to use a script in grunt and node to dump a database.
When I run It return me this error:
/bin/sh: mysqldump: command not found
I have already contacted the creator of the script and we have understand that the problem is the configuration of my localhost.
I'm using XAMPP 1.8.2-3 in OSX
How can I use correctly mysqldump
Thanks
Try:
export PATH=$PATH:/Applications/XAMPP/bin
Then run your script.
So you don't have to do this in the future, check your .profile file in your home directory. There should be a line that starts with export PATH, something like (only an example):
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
Just add your XAMPP path to it:
export PATH=/opt/local/bin:/opt/local/sbin:/Applications/XAMPP/bin:$PATH
The different directories are separated by colons only, don't add any whitespace.

.bashrc: Permission denied

I try to work with a project in vagrant.
I have made the command vagrant ssh, and connected to VM. Now I need to edit .bashrc file to set path to the source code. But first I couldn't find that file. So I googled and find that the way is call command ~/.bashrc. But doing this I get message, that I have no access to it:
[vagrant#nupic-vagrant:~]$ ~/.bashrc
-bash: /home/vagrant/.bashrc: Permission denied
So what to do now?
UPD.
I can't find the .bashrc file.
When I try to make command ls -a I get following:
[vagrant#nupic-vagrant:~]$ ls -a
. .bash_logout cleanup.sh sshd.sh .veewee_params
.. .bash_profile minimize.sh vagrant.sh .veewee_version
.bash_history .bashrc .ssh .vbox_version .zsh_profile
[vagrant#nupic-vagrant:~]$ locate .bashrc
/etc/skel/.bashrc
/home/vagrant/.bashrc
/var/chef/backup/etc/skel/.bashrc.chef-20130614181911
/var/chef/backup/home/vagrant/.bashrc.chef-20130614181912
[vagrant#nupic-vagrant:~]$
But only the place where I can find some of those files is the directory where cygwin is installed. Pls, see illustrations, they reflect relations between directories vagrant and cygwin.
.bashrc is not meant to be executed but sourced. Try this instead:
. ~/.bashrc
or, equivalently
source ~/.bashrc
See the reference about the . (aka source) builtin.
Note that if what you're looking for is to restart your Bash session after modifying your ~/.bashrc file, you might as well use:
exec bash
That will replace your current Bash session (thanks to exec) by a new session.
If you want to edit that file (or any file in generally), you can't edit it simply writing its name in terminal. You must to use a command to a text editor to do this. For example:
nano ~/.bashrc
or
gedit ~/.bashrc
And in general, for any type of file:
xdg-open ~/.bashrc
Writing only ~/.bashrc in terminal, this will try to execute that file, but .bashrc file is not meant to be an executable file. If you want to execute the code inside of it, you can source it like follow:
source ~/.bashrc
or simple:
. ~/.bashrc
If you can't access the file and your os is any linux distro or mac os x then either of these commands should work:
sudo nano .bashrc
chmod 777 .bashrc
it is worthless
The .bashrc file is in your user home directory (~/.bashrc or ~vagrant/.bashrc both resolve to the same path), inside the VM's filesystem. This file is invisible on the host machine, so you can't use any Windows editors to edit it directly.
You have two simple choices:
Learn how to use a console-based text editor. My favourite is vi (or vim), which takes 15 minutes to learn the basics and is much quicker for simple edits than anything else.
vi .bashrc
Copy .bashrc out to /vagrant (which is a shared directory) and edit it using your Windows editors. Make sure not to save it back with any extensions.
cp .bashrc /vagrant
... edit using your host machine ...
cp /vagrant/.bashrc .
I'd recommend getting to know the command-line based editors. Once you're working inside the VM, it's best to stay there as otherwise you might just get confused.
You (the vagrant user) are the owner of your home .bashrc so you do have permissions to edit it.
Once edited, you can execute it by typing
source .bashrc
I prefer to logout and in again (there may be more than one file executed on login).
Please find the step to fix bash restricted error on Linux servers.
If you are getting below restricted message while try to login to the server by using your credentials , then it might be an issue with lack of directory permissions in the server.
Because of this permission issue we were unable to navigate to required directories and getting error “bash: cd: restricted”
Fix : To release bash restriction error use the highlighted command in Linux server -bash -f
As same if wants to restrict the permission use the highlighted command - bash -r
Once you executed the bash -f command the restrictions will be released from the directories and we can able to proceed with patch scripts.

Resources