Adding a path variable
Hi,
I am trying to compile something and need to add a path variable to my .profile file I think. Underneath PATH="$HOME/bin:$PATH" I added PATH="$home/rich/X/Development/Android/android-ndk-r8/ndk-build" which is where ndk-build is located. I want to be able to run this from any location by simply typing ndk-build. I have saved this but when I type ndk-build it tells me that the command is not found. Does anyone know where I am going wrong here? Richard |
Quote:
Code:
PATH=$HOME/X/Development/Android/android-ndk-r8/ndk-buil:${PATH} |
Thanks for your respone :-)
I changed the path to that posted above but it still isn't working. From what I read on the site I think it should be ok to add it into the .profile file. Any ideas why it still isnt working? Cheers! |
Add this in your .profile:
Quote:
|
Quote:
Quote:
Quote:
Moreover, on many linux distributions the $HOME/.bash_profile contains some lines of code that check for the existence of $HOME/.bashrc and if it exists it's sourced, making a login shell read .bashrc as well. In conclusion, the right place could be $HOME/.bashrc and/or $HOME/.bash_profile, but I would prefer the former for the reason explained above. On the other hand if you want to apply these changes/additions on a system basis (that is available to all users) you can put them in /etc/bash.bashrc or /etc/profile. For the sake of completeness, what is a login shell? It is that one you start by entering your credentials, that is
Code:
$ echo $0 |
Thanks for the amazing and very thorough response! I always find it incredible that people on here are so helpful and I can't thank you enough. Once I understand enough I'm looking forward to being able to share my knowledge too.
Ok. The trouble I am having now is that I cant change the bash.bashrc file as it is read only and the user is ROOT. When I try to log in using sudo it asks for a password and ........well .....I can't log in. Is there anyway that I can change the read/write privileges otherwise? |
Quote:
Quote:
BTW, just to clarify, is this a multi-user system or is it your personal machine? It makes the difference: if it is a multi-user system and the software installed in a non-conventional location must be shared among the users, then /etc/bash.bashrc can be the choice, or even better a newly created file in /etc/profile.d (this is another story, still not mentioned above). If it is your system or the software has to be used by... you, then your personal $HOME/.bashrc is the file to edit. |
It is my personal machine. I'm not sure why I can't log into sudo as the password could only be a certain number of things and none of them work. Would it definitley be a password that I have chosen at somepoint?
I only really need to be able to edit the bash.bashrc file by any means really, or more accurately add a path variable by some means to something so that I can compile something from anywhere (That sounds very ambigous I know) :-) |
If you're running Ubuntu, there is no root's password so you should be able to use your user's password, unless your system does an automatic login and you forgot it completely! ;) This problem can be addressed in one way or another and there are plenty of tutorials on how to reset a lost password (you can try the LQ search engine as well).
Regarding the original topic, since it is your personal machine I'd suggest to edit $HOME/.bashrc and leave /etc/bash.bashrc alone, unless you need to change it for other reasons not covered here. |
Thanks again! Ok, I am around the password problem.
I have added Code:
PATH="$HOME/rich/X/Development/Android/android-ndk-r8/ndk-build:$HOME/bin:$PATH" Cheers! |
Heyyy,
I am still stuck on this. Does anyone know if there is somewhere specific in the /.bashrc file that I need to add my PATH variable to? Also, does it need to point to the thing that to point to the directory that contains the file I want to link to or to the actual file itself. Your help on this would be most appreciated as I can't move forwards at the moment. Thanks! |
can you tell me what is that file? you can simply execute: file $home/rich/X/Development/Android/android-ndk-r8/ndk-build
If it was a text file (probably a shell script) what is in the first line? Have you checked the permissions on that file? What about the execute flag? |
First open a new terminal and check if the environment variable PATH has been correctly setup:
Code:
echo $PATH Code:
ls -l $HOME/rich/X/Development/Android/android-ndk-r8/ndk-build |
The PATH needs to point to the directory, not the file itself
If ndk-build is the only thing in that directory that you need, you could also just create an alias for it without changing your PATH at all, by adding the following into your $HOME/.bashrc Code:
alias ndk-build="$HOME/rich/X/Development/Android/android-ndk-r8/ndk-build" Also, are you sure $HOME/rich is where you mean to look? Assuming rich is the user, the location would be either: /home/rich/ OR $HOME Since $HOME is an environment variable that points to the user's home directory. Unless of course "rich" is a directory inside your user's home directory, in which case you have it right. |
Thanks people! :-)
Quote:
Code:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games Quote:
Thanks suicidaleggroll, you made me realise this too. I consequently changed the PATH to Code:
PATH="$HOME/X/Development/Android/android-ndk-r8:$HOME/bin:$PATH" Code:
alias ndk-build="$HOME/rich/X/Development/Android/android-ndk-r8" @pan64 It is a text file, a shell script. The first line reads; Code:
#!/bin/sh bamboozled. |
All times are GMT -5. The time now is 07:47 AM. |