Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
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:
Also, check your ~/.bash_profile to see if .bashrc is called there. If not, add this:
if [ -f ~/.bashrc ]; then
This will make sure you always have your specialized path loaded (as long as you use bash as your default shell but you most likely do).
Then pop your executables in ~/bin and you can execute them from anywhere on your system.
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
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.
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?
[gabriel@localhost gabriel]$ echo$PATH
bash: echo/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/govtspyagent30/Mozilla/: No such file or directory
Last edited by Laptop2250; 11-14-2003 at 10:42 PM.
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 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?