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!
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
sudo vim ( or whatever text editor you perfer ) /etc/bash.bashrc
look for a line like this
PATH=/usr/local/sbin:/usr/lib:/usr/lib64:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/home/user/Scripts:/opt/java/jre
add the directory where your script is. Seperate the previous entry with :
The same method for ~user/.bashrc
So yeah - I don't see a ~user/.bashrc in my work directory
or a /etc/.bashrc
casper@casperbox /home/casper $ ls -ltr /.bashrc
ls: /.bashrc: No such file or directory
my bash seems to work just fine without it.
So I could just create a file /home/casper/.bashrc
add the example that you wrote, and it wont effect other users.
this is a work host - so I really can't screw around.
The path (location of bashrc) is relative to where you are.
If you are in /home/user then .bashrc (dot is default to hide filesa)
If you are not in your home directory then /home/usr/.bashrc
Modifications to your bashrc in your home directory will only impact you and nobody else so you should be safe. If you don't like the changes you can always modify.
While you're in the process, you should probably move my_program out of your base home directory and into a subdir that will only contain other programs you've written. You don't want to just add your entire home directory to your PATH or things can get ugly. Make a new folder such as ~/bin, move my_program into there, and then add that directory to your PATH in ~/.bashrc
So yeah - I don't see a ~user/.bashrc in my work directory
That's because it's not ~user/.bashrc. Maybe it was a typo in jv2112's post, not sure, but ~user/ isn't even a valid location. The file is located in either /home/user/.bashrc or ~/.bashrc (~ is a shortcut to /home/user).
Quote:
Originally Posted by casperdaghost
casper@casperbox /home/casper $ ls -ltr /.bashrc
ls: /.bashrc: No such file or directory
That's because you put a slash in front of it. "/.bashrc" is referencing a .bashrc file located in /, which doesn't exist. If you want to look in your current directory then leave the leading slash off: "ls -ltr .bashrc"
~usr/.bashrc is a valid location. I mean usr as in jim , larry , jane et cettera. ~ shortcut for /home/Name_of_usr/.bashrc......
It is not, as ~ already contains the username part of the home path.
~usr, issued by the hypothetical user usr, would expand as /home/usrusr, not as the valid location /home/usr.
Last edited by 414N; 06-25-2012 at 03:04 AM.
Reason: Wrong assumption
blah blah blah ...... splitting hairs.... That is what the user would type.............
Beg your pardon if I had the "arrogance" of pointing out that the notation you previously used was technically wrong, but I think one should strive to be as correct as possible especially in this section of the forum, where new users come seeking answers to their first Linux questions and would be additionally confused by wrong answers.
Last edited by 414N; 06-25-2012 at 03:05 AM.
Reason: Wrong
blah blah blah ...... splitting hairs.... That is what the user would type.............
I just tested this, and you're right, you can use that syntax, I didn't realize that. I don't know why anybody would, since it's much faster to just use ~, but I suppose if you really wanted to you could.
~/.bashrc, and
~usr/.bashrc
will end up going to the same place.
Learn something new every day.
Last edited by suicidaleggroll; 06-24-2012 at 10:24 AM.
Very interesting. I've never encountered this syntax so I thought it was wrong.
My sincere apologies to jv2112.
For completeness, here's the relevant portion of the bash manpage:
Code:
Tilde Expansion
If a word begins with an unquoted tilde character (`~'), all of the characters pre‐
ceding the first unquoted slash (or all characters, if there is no unquoted slash)
are considered a tilde-prefix. If none of the characters in the tilde-prefix are
quoted, the characters in the tilde-prefix following the tilde are treated as a pos‐
sible login name. If this login name is the null string, the tilde is replaced with
the value of the shell parameter HOME. If HOME is unset, the home directory of the
user executing the shell is substituted instead. Otherwise, the tilde-prefix is
replaced with the home directory associated with the specified login name.
I don't know why anybody would, since it's much faster to just use ~,
Because *nix is a multiuser system and ~foo and ~bar can be used to reference the home dir of different users. Just using ~ is good when you are referencing your own home dir, but ~foo and ~bar can be used for others home dirs.
In addition to this there is no requirement that a users home directory has the same name as the user it self. For example the user foo, could have the home directory "/home2/foobar", and ~foo would still reference /home2/foobar". Generally the location of the users home directory is set in /etc/passwd and it is only convention that it is usually /home/username
Everything evo2 said; seen it, broke it !
I've even seen a system where all users had the one shared home dir that was also the 'home'/install dir of the APP they used ...
Needless to say, someone managed to delete it ... that was a fun morning...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.