BLU Discuss list archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss] What the use of .bashrc
- Subject: [Discuss] What the use of .bashrc
- From: gaf at blu.org (Jerry Feldman)
- Date: Tue, 30 Oct 2012 08:11:27 -0400
- In-reply-to: <2A3E80A1-303B-43C2-A773-F3AE429A720B@mac.com>
- References: <2A3E80A1-303B-43C2-A773-F3AE429A720B@mac.com>
On 10/30/2012 07:50 AM, Glenn Hoffman wrote: > I'm teaching an Introduction to Linux/Unix class at UMass/Boston. I've just told the class about the different type of shells (login, interactive non-login in, non-interactive) and the startup files for each. I've never been able to give a class a good reason for the existence of .bashrc, since I have never used it myself. What's the reason for a separate startup file for a non-login interactive shell? > I use the .bashrc all the time. Basically, the ~/.profile is only executed by the login shell, and not by X. So if you bring up a window under X (eg Gnome/KDE) it will not execute .profile. the .bashrc file is executed every time a new shell starts up. Most people I know don't bother with .profile. Also, you will notice that the standard .profile has 3 lines: if [ -f /etc/profile ]; then . /etc/profile fi And the ~/.bashrc has: if [ -f /etc/bashrc ]; then . /etc/bashrc fi In both cases, they test for the existence of the /etc/{profile || bashrc}, and then they source it. It is important to know the difference between sourcing a script and executing a script. When you execute a script, a subshell is created, but when the execution is done it goes away. The environment is passed from parent to child, but never from child to parent. When you source a shell, the shell is interpreted in the same environment so any environment changes you make are preserved. Note that in BASH, the source command is a dot (.) where in the seasick shells, the source command is 'source'. -- Jerry Feldman <gaf at blu.org> Boston Linux and Unix PGP key id:3BC1EB90 PGP Key fingerprint: 49E2 C52A FC5A A31F 8D66 C0AF 7CEA 30FC 3BC1 EB90
- References:
- [Discuss] What the use of .bashrc
- From: glennhoffman at mac.com (Glenn Hoffman)
- [Discuss] What the use of .bashrc
- Prev by Date: [Discuss] What the use of .bashrc
- Next by Date: [Discuss] TrueCrypt on a network Drive
- Previous by thread: [Discuss] What the use of .bashrc
- Next by thread: [Discuss] What the use of .bashrc
- Index(es):