I. /etc/profile
And the directory for scripts:
/etc/profile.d/*.sh
I could add something like: "export PATH=$PATH:/whatever"
in /etc/profile file using, for instance, pico program.
This file should be running all the .sh files in /etc/profile.d/
And it seems that includes /etc/bash.bashrc
II. /etc/bash.bashrc
# System-wide .bashrc file for interactive bash(1) shells.
III. ~/.profile
Lets take a look at the file ~/.profile:
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
It seems that includes ~/.bashrc
and adds ~/bin if it exists.
But no words about /etc/profile.d
IV. ~/bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
We can add lines to the end of the file like:
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/usr/games:$PATH
---------------------------------------------------------------------------------------------------
From bash man page:
"When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists.
After reading that file, it looks for (~/.bash_profile, ~/.bash_login and ~/.profile) in that order, and reads and executes commands from the first one that exists and is readable.
[...]
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.
[...]
From http://askubuntu.com:
edit
.bashrc
in your home directory and add the following line:export PATH=/path/to/dir:$PATH
A path set in .bash_profile will only be set in a bash login shell (
bash -l
). If you put your path in .profile
it will be available to your complete desktop session. That means even metacity will use it.
For example
~/.profile
:if [ -d "$HOME/bin" ] ; then
PATH="$PATH:$HOME/bin"
fi
Btw, you can check the PATH variable of a process by looking at its environment in
Further explanations:
http://stefaanlippens.net/bashrc_and_others
http://www.linux-migration.org/ch02s03.html
http://www.admon.org/difference-between-login-shell-and-non-login-shell/
/proc/[pid]/environ
. (replace [pid] with the number from ps axf
)Further explanations:
http://stefaanlippens.net/bashrc_and_others
http://www.linux-migration.org/ch02s03.html
http://www.admon.org/difference-between-login-shell-and-non-login-shell/
------------------------------------------------------------
So, IMO, I should change /etc files when I have an application installed for all the system. When my application is installed at /home I should instead use the ~/.profile (for login shells) or ~/.bashrc (for non-login shells).
The question then is What the heck are login and non-login shells? As far as I know, a non-login shell is when I open my shell from Ubuntu using the icon in the X-Windows system. But I need more deep on this topic.
Finally, a good patient friend told me to think it this way: what I want to have in my /home in case I am moving to another place? Well, I want to have my clothes, my personal stuff but as I want to save money I want the heating to be central. As everybody in the building needs the heating, I can change the /etc files. As only I want to manage my clothes, photos, etc. this will be on ~/. files. At last, if I want to get everything since I log in, I will change "profile" files. If I just want to use somethings from a bash shell, I change "bashrc" files.
coda: the question that remains for me is Why when I changed the /etc/profile.d/ adding a *.sh file with something like "export PATH=$PATH:/kakakakakakak" didn't seem to work? I will continue researching on this later.
O.,o
No hay comentarios:
Publicar un comentario