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

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.

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.

homebrew installation osx permission denied

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.

sudo open -e ~/.bash_profile Permission denied mac

I am trying to edit bash_profile file to add path to my sdk through the following command on my mac machine.
sudo touch ~/.bash_profile; open -e ~/.bash_profile
It opens the file in TextEdit but does not allow me to edit it. Though i have given super-user permission and password while running the above command. It is giving me following message when i try to edit it.
"You don’t own the file “.bash_profile” and don’t have permission to write to it.
You can duplicate this document and edit the duplicate. Only the duplicate will include your changes."
I am new to mac. So please elaborate your answers.
The problem is that the file isn't owned by your user, but by root. You need to change the owner of the file to your user, then you can open and edit the file without the use of sudo:
sudo chown farheen ~/.bash_profile
This will, as the super-user, change the owner of the file back to you.
For Mac User Catalina,
.bash_profile not open, they need grant permission to edit this file. You can achieve by below steps
1) Open the terminal and enter below command ex: sudo chown iMac ~/.bash_profile
sudo chown {your username} ~/.bash_profile
2) Open editor in the terminal, here i used nano
nano .bash_profile
3) Edit your text you want.
4) To save the changes you've made, press Ctrl + O
5) To exit nano, press Ctrl + X
6) And finally to load your changes, enter below command
source .bash_profile
OR
You can give permission and make it executable file using like below:
That error likely means that 'bash_profile' isn't executable. If it's in the current directory, you can make it executable with chmod +x bash_profile.

/Users/DylanRichards/.profile:source:2: no such file or directory: QSTK/local.sh

I'm going to open this up again. I installed this thing called QSTK for some financial calculations. Now every time I open my terminal, I get this error:
/Users/DylanRichards/.profile:source:2: no such file or directory: QSTK/local.sh
Because of this error, I am unable to run programs in Sublime Text as well.
How the heck do I get rid of this?
Latest
After trying KEYSER's suggestion, here are the contents of the .profile file:
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
source QSTK/local.sh
PATH=$PATH:/Applications/Darwine/Wine.bundle/Contents/bin/
QSTK seems to have injected some line into your profile file, which is loaded by the terminal at startup. That line is trying to run a script which doesn't exist.
To get rid of the error remove line 2 in .profile (and possibly surrounding, related, lines).
It's a hidden file, so you can e.g. open it from a terminal. for example:
open -a "/Applications/Sublime Text.app/" ~/.profile
if that's the name of your sublime app (tab to autocomplete)
How do I find and edit ~/.profile?
In Terminal:
$ cd ~
$ touch .profile
$ open -e .profile
This will open the .profile file in TextEdit for your editing enjoyment.
Once you have completed your editing, save the file in TextEdit and then, in Terminal:
$ source .profile
This should avoid the need for a system restart but always a good idea to do a restart anyway when playing with fundamentals like .____ files.

.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