Login and non-login shell defined as:
su - $USER # will give you a login shell
bash # will give you a non-login shell
/etc/profile is not invoked for non-login shells, such as when you start konsole (kde). /etc/profile is only invoked for login shells.
Why is that? Please explain, because I like to understand the rationale of this.
I have been looking at /etc/profile. bash.bashrc to see how they are run, and notice that some are executed by non-login shells, some work with interactive shells etc.
What are the differences in this type of shells, ie interactive & non-interactive, login & non-login etc?
The question may be pretty basic,but it seems I need to ask what a shell is, first and foremost.
I have been looking at /etc/profile. bash.bashrc to see how they are run, and notice that some are executed by non-login shells, some work with interactive shells etc.
What are the differences in this type of shells, ie interactive & non-interactive, login & non-login etc?
The question may be pretty basic,but it seems I need to ask what a shell is, first and foremost.
The bash man page says:
"When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, "
I can see that bash.bashrc is executed because I put echo in it, but .bashrc is not.
On my home desktop I want to use Ubuntu Unity sometimes and just the bash shell (without any GUI) other times.
Is it possible to set up a login option where I can choose between using the Unity GUI or just the shell? For example, on the Ubuntu login screen I can choose among Unity, Gnome Shell, XFCE, etc.
I understand the basic difference between an interactive shell and a non-interactive shell. But what exactly differentiates a login shell from a non-login shell?
Can you give examples for uses of a non-login interactive shell?
I know there is an elaborate sequence of config files that BASH reads sequentially (or alternatively skipping if a particular one is present), however I have for the most part adopted ZSH as my default shell. I have tended to mainly edit my ~/.zshrc for everything but am wondering if I should be editing other files as well.
I install some programs in /opt/my-program/bin, I want to add /opt/my-program/bin to system $PATH for all users's non-login shell and login shell. What should I do?
Change /etc/environment is OK for non-login shell, but does not work for login shell because Debian's /etc/profile (which will be sourced by login shell) will override the $PATH specified in /etc/environment.
So I think i got this down but i just wanted to make sure.
OK:
Login shell creates Bash shell.