homebrew installation osx permission denied - macos

I'm following link to set up openCV on my mac
https://jjyap.wordpress.com/2014/05/24/installing-opencv-2-4-9-on-mac-osx-with-python-support/
and got following permission denied
I'm quite new to mac command line and openCV. So please do not skip some explanation
yun-MacBook-Pro:~ sangwoneum$ cd /Library/Python/2.7/site-packages/
yun-MacBook-Pro:site-packages sangwoneum$
yun-MacBook-Pro:site-packages sangwoneum$
yun-MacBook-Pro:site-packages sangwoneum$ ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
ln: cv.py: Permission denied

I wouldn't put a symbolic link into /Library/.
This is much better solved setting your PYTHONPATH:
export PYTHONPATH=/usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/
This will work only in your current session though, so let's make that setting permanent:
Open up your .bashrc in your home directory with your favourite text editor (TextEdit can work, but be sure to use plain text (cmd-shift-T).
At the end of the file:
export PYTHONPATH=${PYTHONPATH}:/usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/
(it's a bit different than above, in case there is already a PYTHONPATH defined).
Save, exit and source the file:
source $HOME/.bashrc
If you open up a new Terminal session/window/tab, this sourcing will happen automatically, and your path is correct.
Note that this solution only works if you're running Python from the command line. If you run it in another way, it may or may not work, and you might have to find another way to set your PYTHONPATH.

Related

I have accidentally set up my path environment variable incorrectly using the .bash_profile on macbook. How do I reset it?

-bash: export: /Users/deboadebayo/Desktop/Coding/:/opt/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.8/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin':
not a valid identifier
The above message is the error message I receive every time I open my terminal. I did create a backup of my bash profile. But essentially now I can no longer navigate anywhere I want to go using command line requests.
Any help would be much appreciated
If you have a backup, use an absolute path to the mv and cp commands to rename your broken file and restore the backup, both without depending on path lookup.
/bin/mv .bash_profile .bash_profile.broken
/bin/cp .bash_profile.backup .bash_profile
Close the current terminal window and open a new one, which should use your working, original .bash_profile to initialize PATH. Now you try to make the correct modification to your PATH.
oops. The easiest way to fix it would be to launch an editor with an absolute path. $PATH only specifies the locations in which the shell will search if told to execute a program relative (or no) path specified. The which program can search the path and shows the first executable found:
$ which vim
/usr/bin/vim
So if you're a vim user, you should be able to run /usr/bin/vim at the command line, and the path won't be relevant. Then you can fix your file in the editor. Looks like my osx machine also has nano if you'd prefer that editor. I don't think I installed it so it probably came shipped with osx I'm guessing:
$ which nano
/usr/bin/nano
If you want to revert to your backup, use cp, but specify it from its absolute position, /bin/cp:
$ /bin/cp first.txt second.txt
Obviously you'll want to change the file names on that one for it to work for you.

can't access .bash_profile

So I was adding a path to my bash profile, and I accidentally started it with 'myname 1' instead of 'myname1'. I think the space has messed something up.
When I open my terminal now, I get:
-bash: export: `1/Documents/android-sdk-macosx/platform-tools:/Users/XXXX/Library/PreferencePanes/MMPane.prefPane/Contents/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/mysql/bin': not a valid identifier
-bash: dirname: command not found
-bash: /Users/bin/git-prompt.sh: No such file or directory
I know the '1/ is super messed up, but now when I try to edit the profile again nothing works. I can't access it with nano or anything. I don't even think it can find my profile anymore.
Does anyone know how I can access that old profile to fix the edit I made?
It's likely that your PATH environment variable has now been set to myname, and so trying to run a command foo will now only work if an executable named myname/foo exists. The way around this is to give the absolute path of any program you want to execute. For example, nano most likely resides in your /usr/bin directory, and so you should be able to run it to edit your .bash_profile by typing:
/usr/bin/nano ~/.bash_profile
If that's not the correct path, other likely locations for nano include /usr/local/bin/nano and /usr/pkg/bin/nano; the correct answer depends on your operating system and distribution thereof.
Type the full path to the editor.
I assume the following will work:
/bin/vi .bash_profile

-bash: /Users/myname/.bash_profile: Permission denied

I installed rvm (ruby version manager) and it was success, but I got
WARNING: You have '~/.profile' file, you might want to load it, to do
that add the following line to '/Users/myname/.bash_profile': source
~/.profile
I am new to developing, terminals and all that jazz! But better late than never?!
I entered into terminal:
'/Users/myname/.bash_profile'
and got back the following line
-bash: /Users/myname/.bash_profile: Permission denied
myname-MacBook-Pro:~ myname$
And that is where I am stuck! I need vrm for Drupal (Omega development) and want to make sure that everything is working fine. Thanks for your help.
Enter the .bash_profile file by running this in your terminal:
vim ~/.bash_profile
If you still get permission denied, run sudo before the vim command
sudo vim ~/.bash_profile
From there , press insert button . then add the text source ~/.profile to .bash_profileand press esc and then hit :x on your keyboard to save and close the file. Opening a new terminal window should remove the error.
Entering a filename will try to execute it. Instead, you want to edit it.
Open TextEdit (or your favorite editor) and open the file /Users/myname/.bash_profile in it.
You can do this entirely through the UI, but if you want, you can start an editor from the terminal:
open -a TextEdit /Users/myname/.bash_profile
You can then add the line source ~/.profile to the file and save it.
Close the terminal and open it again to apply the changes.
In my issue when I try with ssh on server, I get this error :
-bash: /home/user/.bash_logout: Permission denied
for resolved your user home directory must has a execute permission.
chmod +x <user_home_directory>
you must relogin next. If you add .profile
export PATH+=:$HOME/bin
without .bash_profile as I do all time you'll insert ~/bin search dir not the end of PATH and in middle. So .profile call before local profile formed and some others system dirs will be added after. It's bad so priority for you home binaries will higher then some system one. And may change undesired behavior with same names. So you need to add PATH in .bash_profile, not to .profile It's guarantee to add your home bin dir at the end of PATH. But don't delete ~/.profile at all. It's need to add some other data. This file call once at first login and .bash_profile call every time when second login with su without -l and then return back. If don't bother You will get two home bin dirs in PATH, next tree and so on. It's not well. So you must correct like that:
p=:$HOME/bin && test `expr $PATH : '.*'"$p"` -gt 0 || export PATH+=$p || true
It's grantee that home bin dir will add only one independent how many times you login after change effective user with su and then return back.
true at end better write so if on some unpredictable reasons error occurs in
command export PATH+=$p(sometimes such occurs) your profile load stops and you can't login at all. It's grantee that this line will run with any error generate.

.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.

Trying to connect Terminal to recognize "mate" command for TextMate

Couldn't Create Link
Creating the link “/usr/bin/mate” failed with the following reason: Operation not permitted
I am getting this error when I attempt to link the terminal usage with TextMate.
I did this by going Help >> Terminal Usage...
And I tried to create a link in /usr/bin.
I think the problem is something to do with permission issue.
I am wondering if there is a way to work around this problem by changing bash file directly or something and make terminal recognize "mate" as a command.
Thank you for any suggestion.
Assuming Textmate is installed in /Applications the following command in the terminal should manually create the link for you:
$ sudo ln -s /Applications/TextMate.app/Contents/SharedSupport/Support/bin/mate /usr/bin
The command will ask you for your user account's password so it has the permissions necessary to create the link in /usr/bin/
There should be an option to create it in /usr/local/bin. Create it there. Make sure /usr/local/bin is in your $PATH.

Resources