how do i edit my echo$PATH
How do I edit my echo$PATH?
Code:
pathmunge () { Code:
pathmunge () { |
That's pretty much what you did. Do a source /etc/profile.
But heads up! You shouldn't be entering a user's directory in /etc/profile. Even if you're the only one using the computer it's considered a bad habit. Also, you shouldn't have executables in your home directory. Create a bin directory in your home directory and edit your ~/.bashrc. If you have any PATH statements there you can use those, if not, type this in your .bashrc: Code:
PATH=$PATH:/home/user1/bin Code:
if [ -f ~/.bashrc ]; then Then pop your executables in ~/bin and you can execute them from anywhere on your system. Håkan |
What you have there is a function that takes an argument ($1) of a path to add to the PATH environment variable. First it looks to see if $1 is already in the path, and if it's not then it adds it to PATH: either at the front or end of the list, depending on whether a second argument of "after" was given. To do anything with this, you'd need to separate it off into a script file and call that from profile.
For most simple situations, it is sufficient to have a line such as Code:
export PATH=$PATH:/my/added/path/ In your case, it appears that you are adding a user's home directory to the path. Since this will only be accessible to the user in question, it would be far wiser to set this change to PATH for the user alone. This may be done by editing /home/user1/.bash_profile instead of /etc/profile. For instance: Code:
jcspray@slate:~$ cat ~/.bash_profile |
ok i get it.. i had to restart the X system and it magically worked, w/e.. :)
Also, could I just take all the scripts and put them in /usr/local/bin/ and edit the PATH again to look for "exe's" in the /usr/local/bin/ folder so that the PATH file could look neater, would this cause problems? [code[ [gabriel@localhost gabriel]$ echo$PATH bash: echo/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/govtspyagent30/Mozilla/: No such file or directory [/code] |
>all the scripts and put them in /usr/local/bin/
I assume that you mean scripts which you've currently got in ~/bin? Certainly you could just stick them all in /usr/local/bin, but that's not necessarily a good idea. If it's something that all users on the system would find useful then fine, but there's not a lot of point going root and writing outside of your home directory just to make your $PATH variable shorter - I mean, how often do you look at it? Also, as you've posted it the reason it looks so ugly is that your command is malformed. "echo $PATH" is correct, "echo$PATH" is not. >edit the PATH again to look for "exe's" in the /usr/local/bin/ folder Doesn't look like it would need any editing - /usr/local/bin is already on there at the start if you notice. /usr/local/bin comes first, by the way, so that you can have a /usr/bin/myprogram and then create a /usr/local/bin/myprogram which overrides it. >look for "exe's" Bash never looks at non-executable files in $PATH, for obvious reasons. |
echo $PATH does make it look neater, but the other reason I wanted to put everything in one folder in the PATH is because that way I know where the exe is, and I wouldn't have to guess which folder it is in (or search for it). But if I collected all the exe's from my current PATH and placed them in one random folder (whichever folder would make placing them there the most problem free) wouldn't that work? Or if I were to log on as root, would I have problems accessing anything? I'm a :newbie: so I am just trying to figure out the easiest way to keep track of my files, folders, etc.
|
Anything you put in /usr/local/bin is going to get shuffled in with any random programs that you install from source. The best way to keep track of anything is not to let it wander out of your home directory.
>if I collected all the exe's from my current PATH Are you serious? You mean taking everything from /usr/bin, /usr/local/bin, /bin and putting it all in one directory? That's nuts. Where something is tells you something about it - things in /bin are pretty system-level, things in /usr/bin came from your distro's packaging system, things in /usr/local/bin came from source installations (generally). Just what kind of situation are you thinking of where it would be advantageous to have every binary on the system in one folder? As for knowing where a given binary is, "whereis" and "locate" are you friends. But situations in which you'll care are rareish. >I were to log on as root, would I have problems accessing anything No, that's the whole point of being root :-) But seriously, anything in ~/bin is generally just a convenience of some kind. I mean, what kind of stuff is it that you're worrying about where to keep? |
All times are GMT -5. The time now is 06:00 AM. |