Sequence of scripts sourced upon login
up vote
35
down vote
favorite
I would like to concentrate all my login config in my ~/.bash_profile
. There was a ~/.bashrc
there by default but I replaced it with a ~/.bash_profile
.
However, when I log in, something before my ~/.bash_profile
gets sourced and displays the following:
Linux ubnt10-dev1 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
System information as of Fri May 9 12:17:39 EDT 2014
System load: 0.01 Processes: 74
Usage of /: 5.5% of 18.58GB Users logged in: 0
Memory usage: 4% IP address for eth0: 123.x.x.x
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Fri May 9 12:11:52 2014 from 123.x.x.x
I would like to remove that so that only my own splash greeting defined in my ~/.bash_profile
gets displays but I am not sure about the logic/sequence of scripts sourced/executed when a user logs in. Can you enlighten me?
As a bonus, I would also like to know the sequence of automated sourcings/execs when the system starts, not just when a user starts a session by logging in, albeit this is a concern of lesser importance to me right now.
bash login bashrc .profile
add a comment |
up vote
35
down vote
favorite
I would like to concentrate all my login config in my ~/.bash_profile
. There was a ~/.bashrc
there by default but I replaced it with a ~/.bash_profile
.
However, when I log in, something before my ~/.bash_profile
gets sourced and displays the following:
Linux ubnt10-dev1 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
System information as of Fri May 9 12:17:39 EDT 2014
System load: 0.01 Processes: 74
Usage of /: 5.5% of 18.58GB Users logged in: 0
Memory usage: 4% IP address for eth0: 123.x.x.x
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Fri May 9 12:11:52 2014 from 123.x.x.x
I would like to remove that so that only my own splash greeting defined in my ~/.bash_profile
gets displays but I am not sure about the logic/sequence of scripts sourced/executed when a user logs in. Can you enlighten me?
As a bonus, I would also like to know the sequence of automated sourcings/execs when the system starts, not just when a user starts a session by logging in, albeit this is a concern of lesser importance to me right now.
bash login bashrc .profile
add a comment |
up vote
35
down vote
favorite
up vote
35
down vote
favorite
I would like to concentrate all my login config in my ~/.bash_profile
. There was a ~/.bashrc
there by default but I replaced it with a ~/.bash_profile
.
However, when I log in, something before my ~/.bash_profile
gets sourced and displays the following:
Linux ubnt10-dev1 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
System information as of Fri May 9 12:17:39 EDT 2014
System load: 0.01 Processes: 74
Usage of /: 5.5% of 18.58GB Users logged in: 0
Memory usage: 4% IP address for eth0: 123.x.x.x
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Fri May 9 12:11:52 2014 from 123.x.x.x
I would like to remove that so that only my own splash greeting defined in my ~/.bash_profile
gets displays but I am not sure about the logic/sequence of scripts sourced/executed when a user logs in. Can you enlighten me?
As a bonus, I would also like to know the sequence of automated sourcings/execs when the system starts, not just when a user starts a session by logging in, albeit this is a concern of lesser importance to me right now.
bash login bashrc .profile
I would like to concentrate all my login config in my ~/.bash_profile
. There was a ~/.bashrc
there by default but I replaced it with a ~/.bash_profile
.
However, when I log in, something before my ~/.bash_profile
gets sourced and displays the following:
Linux ubnt10-dev1 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux
Ubuntu 10.04.4 LTS
Welcome to the Ubuntu Server!
* Documentation: http://www.ubuntu.com/server/doc
System information as of Fri May 9 12:17:39 EDT 2014
System load: 0.01 Processes: 74
Usage of /: 5.5% of 18.58GB Users logged in: 0
Memory usage: 4% IP address for eth0: 123.x.x.x
Swap usage: 0%
Graph this data and manage this system at https://landscape.canonical.com/
New release 'precise' available.
Run 'do-release-upgrade' to upgrade to it.
Last login: Fri May 9 12:11:52 2014 from 123.x.x.x
I would like to remove that so that only my own splash greeting defined in my ~/.bash_profile
gets displays but I am not sure about the logic/sequence of scripts sourced/executed when a user logs in. Can you enlighten me?
As a bonus, I would also like to know the sequence of automated sourcings/execs when the system starts, not just when a user starts a session by logging in, albeit this is a concern of lesser importance to me right now.
bash login bashrc .profile
bash login bashrc .profile
edited May 9 '14 at 21:01
Community♦
1
1
asked May 9 '14 at 16:23
amphibient
5573718
5573718
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
49
down vote
accepted
This is kind of complex. First of all, the details depend on what kind of shell you are running. To plagiarize myself:
When you open a terminal emulator (
gnome-terminal
for example), you are executing what is known as an interactive, non-login shell.When you log into your machine from the command line, or run a command such as
su - username
, you are running an interactive login shell.When you log in graphically, you are running something completely different. The details will depend on your system and graphical environment but in general, it is the graphical shell that deals with your login. While many graphical shells (including the Ubuntu default) will read
/etc/profile
and~/.profile
not all of them do.Finally, when you run a shell script, it is run in a non-interactive, non-login shell.
The files that bash will read when launched depend on the type of shell it is running as. The following is an excerpt of the INVOCATION section of man bash
(emphasis mine):
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. The --noprofile option may be used when the
shell is started to inhibit this behavior.
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. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.
Those are the initialization files. You also have /etc/environment
where you can set global environmental variables but that's read rather than sourced (commands inside it are not executed but variable definitions are set).
Now, the greeting you see is something else again. That is set in /etc/motd
and is displayed through pam_motd
. As explained in man motd
:
The contents of /etc/motd are displayed by pam_motd(8) after a
successful login but just before it executes the login shell.
The abbreviation "motd" stands for "message of the day", and this
file has been traditionally used for exactly that (it requires
much less disk space than mail to all users).
On Debian GNU/Linux, the content of /run/motd.dynamic is also
displayed. This file is generated by /etc/init.d/motd at boot.
To remove the message just empty the /etc/motd
file and make sure that nothing is being generated by /etc/init.d/motd
if present.
Anyway, based on the output you show, you seem to be logging in via ssh
which means you're running an interactive login shell, see above for what that means.
So, in summary, the things you care about that are sourced when you log in are (and in this order):
- The SSH daemon, via the
pam_motd
module of the PAM library, displays the contents of/etc/motd
. Via thepam_env
module, it sets the environment variables from/etc/environment
and~/.pam_environment
. - A login shell is started, and the following files are read in order:
/etc/profile
/etc/bash.bashrc
(the default Ubuntu/etc/profile
sources/etc/bash.bashrc
).
~/.bash_profile
. The other files that could have been read here (~/.profile
and~/.bash_login
) are ignored because~/.bash_profile
exists.
4
A nice trick to self-discover this things is putting sentinel variables around. I mean, I putexport SET_IN_ETC_PROFILE=yes
in/etc/profile
,export SET_IN_HOME_ZSHRC=yes
in~/.zhshrc
(I am a zsh user), etc... Then reboot and a niceenv|grep SET_IN
will tell you all the story. To see which variables are seen by the desktop applications (the ones you launch from the dash or the WM, without using a terminal), see askubuntu.com/a/356973/16395
– Rmano
May 9 '14 at 19:19
1
so when you ssh, that would be an interactive shell, correct?
– amphibient
May 9 '14 at 21:11
@amphibient an interactive login shell, yes. When you open a terminal on tour local machine, it's an interactive, non login shell.
– terdon♦
May 10 '14 at 15:48
@Rmano I upvoted your comments. But moments later found the order inenv
has no relationship with the order of execution.
– Penghe Geng
Mar 2 '15 at 16:16
1
@xiaobai of course not, the point is thatSET_IN
will show you which files have been read, not in which order they have been read. The order is standard, it is what is shown in the man page excerpts I have in my answer.
– terdon♦
Mar 2 '15 at 16:21
|
show 1 more comment
up vote
1
down vote
The info you are seeing when you login via ssh is created before /etc/profile is ever even looked at. Take a look at the sequence of files in /etc/update-motd.d. That will show you where the messages you are seeing are generated by various scripts.
1
This is already covered in the top answer, but I appreciate your brevity. +1 :)
– wjandrea
Feb 24 at 0:14
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f463462%2fsequence-of-scripts-sourced-upon-login%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
49
down vote
accepted
This is kind of complex. First of all, the details depend on what kind of shell you are running. To plagiarize myself:
When you open a terminal emulator (
gnome-terminal
for example), you are executing what is known as an interactive, non-login shell.When you log into your machine from the command line, or run a command such as
su - username
, you are running an interactive login shell.When you log in graphically, you are running something completely different. The details will depend on your system and graphical environment but in general, it is the graphical shell that deals with your login. While many graphical shells (including the Ubuntu default) will read
/etc/profile
and~/.profile
not all of them do.Finally, when you run a shell script, it is run in a non-interactive, non-login shell.
The files that bash will read when launched depend on the type of shell it is running as. The following is an excerpt of the INVOCATION section of man bash
(emphasis mine):
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. The --noprofile option may be used when the
shell is started to inhibit this behavior.
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. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.
Those are the initialization files. You also have /etc/environment
where you can set global environmental variables but that's read rather than sourced (commands inside it are not executed but variable definitions are set).
Now, the greeting you see is something else again. That is set in /etc/motd
and is displayed through pam_motd
. As explained in man motd
:
The contents of /etc/motd are displayed by pam_motd(8) after a
successful login but just before it executes the login shell.
The abbreviation "motd" stands for "message of the day", and this
file has been traditionally used for exactly that (it requires
much less disk space than mail to all users).
On Debian GNU/Linux, the content of /run/motd.dynamic is also
displayed. This file is generated by /etc/init.d/motd at boot.
To remove the message just empty the /etc/motd
file and make sure that nothing is being generated by /etc/init.d/motd
if present.
Anyway, based on the output you show, you seem to be logging in via ssh
which means you're running an interactive login shell, see above for what that means.
So, in summary, the things you care about that are sourced when you log in are (and in this order):
- The SSH daemon, via the
pam_motd
module of the PAM library, displays the contents of/etc/motd
. Via thepam_env
module, it sets the environment variables from/etc/environment
and~/.pam_environment
. - A login shell is started, and the following files are read in order:
/etc/profile
/etc/bash.bashrc
(the default Ubuntu/etc/profile
sources/etc/bash.bashrc
).
~/.bash_profile
. The other files that could have been read here (~/.profile
and~/.bash_login
) are ignored because~/.bash_profile
exists.
4
A nice trick to self-discover this things is putting sentinel variables around. I mean, I putexport SET_IN_ETC_PROFILE=yes
in/etc/profile
,export SET_IN_HOME_ZSHRC=yes
in~/.zhshrc
(I am a zsh user), etc... Then reboot and a niceenv|grep SET_IN
will tell you all the story. To see which variables are seen by the desktop applications (the ones you launch from the dash or the WM, without using a terminal), see askubuntu.com/a/356973/16395
– Rmano
May 9 '14 at 19:19
1
so when you ssh, that would be an interactive shell, correct?
– amphibient
May 9 '14 at 21:11
@amphibient an interactive login shell, yes. When you open a terminal on tour local machine, it's an interactive, non login shell.
– terdon♦
May 10 '14 at 15:48
@Rmano I upvoted your comments. But moments later found the order inenv
has no relationship with the order of execution.
– Penghe Geng
Mar 2 '15 at 16:16
1
@xiaobai of course not, the point is thatSET_IN
will show you which files have been read, not in which order they have been read. The order is standard, it is what is shown in the man page excerpts I have in my answer.
– terdon♦
Mar 2 '15 at 16:21
|
show 1 more comment
up vote
49
down vote
accepted
This is kind of complex. First of all, the details depend on what kind of shell you are running. To plagiarize myself:
When you open a terminal emulator (
gnome-terminal
for example), you are executing what is known as an interactive, non-login shell.When you log into your machine from the command line, or run a command such as
su - username
, you are running an interactive login shell.When you log in graphically, you are running something completely different. The details will depend on your system and graphical environment but in general, it is the graphical shell that deals with your login. While many graphical shells (including the Ubuntu default) will read
/etc/profile
and~/.profile
not all of them do.Finally, when you run a shell script, it is run in a non-interactive, non-login shell.
The files that bash will read when launched depend on the type of shell it is running as. The following is an excerpt of the INVOCATION section of man bash
(emphasis mine):
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. The --noprofile option may be used when the
shell is started to inhibit this behavior.
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. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.
Those are the initialization files. You also have /etc/environment
where you can set global environmental variables but that's read rather than sourced (commands inside it are not executed but variable definitions are set).
Now, the greeting you see is something else again. That is set in /etc/motd
and is displayed through pam_motd
. As explained in man motd
:
The contents of /etc/motd are displayed by pam_motd(8) after a
successful login but just before it executes the login shell.
The abbreviation "motd" stands for "message of the day", and this
file has been traditionally used for exactly that (it requires
much less disk space than mail to all users).
On Debian GNU/Linux, the content of /run/motd.dynamic is also
displayed. This file is generated by /etc/init.d/motd at boot.
To remove the message just empty the /etc/motd
file and make sure that nothing is being generated by /etc/init.d/motd
if present.
Anyway, based on the output you show, you seem to be logging in via ssh
which means you're running an interactive login shell, see above for what that means.
So, in summary, the things you care about that are sourced when you log in are (and in this order):
- The SSH daemon, via the
pam_motd
module of the PAM library, displays the contents of/etc/motd
. Via thepam_env
module, it sets the environment variables from/etc/environment
and~/.pam_environment
. - A login shell is started, and the following files are read in order:
/etc/profile
/etc/bash.bashrc
(the default Ubuntu/etc/profile
sources/etc/bash.bashrc
).
~/.bash_profile
. The other files that could have been read here (~/.profile
and~/.bash_login
) are ignored because~/.bash_profile
exists.
4
A nice trick to self-discover this things is putting sentinel variables around. I mean, I putexport SET_IN_ETC_PROFILE=yes
in/etc/profile
,export SET_IN_HOME_ZSHRC=yes
in~/.zhshrc
(I am a zsh user), etc... Then reboot and a niceenv|grep SET_IN
will tell you all the story. To see which variables are seen by the desktop applications (the ones you launch from the dash or the WM, without using a terminal), see askubuntu.com/a/356973/16395
– Rmano
May 9 '14 at 19:19
1
so when you ssh, that would be an interactive shell, correct?
– amphibient
May 9 '14 at 21:11
@amphibient an interactive login shell, yes. When you open a terminal on tour local machine, it's an interactive, non login shell.
– terdon♦
May 10 '14 at 15:48
@Rmano I upvoted your comments. But moments later found the order inenv
has no relationship with the order of execution.
– Penghe Geng
Mar 2 '15 at 16:16
1
@xiaobai of course not, the point is thatSET_IN
will show you which files have been read, not in which order they have been read. The order is standard, it is what is shown in the man page excerpts I have in my answer.
– terdon♦
Mar 2 '15 at 16:21
|
show 1 more comment
up vote
49
down vote
accepted
up vote
49
down vote
accepted
This is kind of complex. First of all, the details depend on what kind of shell you are running. To plagiarize myself:
When you open a terminal emulator (
gnome-terminal
for example), you are executing what is known as an interactive, non-login shell.When you log into your machine from the command line, or run a command such as
su - username
, you are running an interactive login shell.When you log in graphically, you are running something completely different. The details will depend on your system and graphical environment but in general, it is the graphical shell that deals with your login. While many graphical shells (including the Ubuntu default) will read
/etc/profile
and~/.profile
not all of them do.Finally, when you run a shell script, it is run in a non-interactive, non-login shell.
The files that bash will read when launched depend on the type of shell it is running as. The following is an excerpt of the INVOCATION section of man bash
(emphasis mine):
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. The --noprofile option may be used when the
shell is started to inhibit this behavior.
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. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.
Those are the initialization files. You also have /etc/environment
where you can set global environmental variables but that's read rather than sourced (commands inside it are not executed but variable definitions are set).
Now, the greeting you see is something else again. That is set in /etc/motd
and is displayed through pam_motd
. As explained in man motd
:
The contents of /etc/motd are displayed by pam_motd(8) after a
successful login but just before it executes the login shell.
The abbreviation "motd" stands for "message of the day", and this
file has been traditionally used for exactly that (it requires
much less disk space than mail to all users).
On Debian GNU/Linux, the content of /run/motd.dynamic is also
displayed. This file is generated by /etc/init.d/motd at boot.
To remove the message just empty the /etc/motd
file and make sure that nothing is being generated by /etc/init.d/motd
if present.
Anyway, based on the output you show, you seem to be logging in via ssh
which means you're running an interactive login shell, see above for what that means.
So, in summary, the things you care about that are sourced when you log in are (and in this order):
- The SSH daemon, via the
pam_motd
module of the PAM library, displays the contents of/etc/motd
. Via thepam_env
module, it sets the environment variables from/etc/environment
and~/.pam_environment
. - A login shell is started, and the following files are read in order:
/etc/profile
/etc/bash.bashrc
(the default Ubuntu/etc/profile
sources/etc/bash.bashrc
).
~/.bash_profile
. The other files that could have been read here (~/.profile
and~/.bash_login
) are ignored because~/.bash_profile
exists.
This is kind of complex. First of all, the details depend on what kind of shell you are running. To plagiarize myself:
When you open a terminal emulator (
gnome-terminal
for example), you are executing what is known as an interactive, non-login shell.When you log into your machine from the command line, or run a command such as
su - username
, you are running an interactive login shell.When you log in graphically, you are running something completely different. The details will depend on your system and graphical environment but in general, it is the graphical shell that deals with your login. While many graphical shells (including the Ubuntu default) will read
/etc/profile
and~/.profile
not all of them do.Finally, when you run a shell script, it is run in a non-interactive, non-login shell.
The files that bash will read when launched depend on the type of shell it is running as. The following is an excerpt of the INVOCATION section of man bash
(emphasis mine):
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. The --noprofile option may be used when the
shell is started to inhibit this behavior.
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. This may be inhibited by using the --norc option.
The --rcfile file option will force bash to read and execute commands
from file instead of /etc/bash.bashrc and ~/.bashrc.
Those are the initialization files. You also have /etc/environment
where you can set global environmental variables but that's read rather than sourced (commands inside it are not executed but variable definitions are set).
Now, the greeting you see is something else again. That is set in /etc/motd
and is displayed through pam_motd
. As explained in man motd
:
The contents of /etc/motd are displayed by pam_motd(8) after a
successful login but just before it executes the login shell.
The abbreviation "motd" stands for "message of the day", and this
file has been traditionally used for exactly that (it requires
much less disk space than mail to all users).
On Debian GNU/Linux, the content of /run/motd.dynamic is also
displayed. This file is generated by /etc/init.d/motd at boot.
To remove the message just empty the /etc/motd
file and make sure that nothing is being generated by /etc/init.d/motd
if present.
Anyway, based on the output you show, you seem to be logging in via ssh
which means you're running an interactive login shell, see above for what that means.
So, in summary, the things you care about that are sourced when you log in are (and in this order):
- The SSH daemon, via the
pam_motd
module of the PAM library, displays the contents of/etc/motd
. Via thepam_env
module, it sets the environment variables from/etc/environment
and~/.pam_environment
. - A login shell is started, and the following files are read in order:
/etc/profile
/etc/bash.bashrc
(the default Ubuntu/etc/profile
sources/etc/bash.bashrc
).
~/.bash_profile
. The other files that could have been read here (~/.profile
and~/.bash_login
) are ignored because~/.bash_profile
exists.
edited Dec 10 at 22:59
answered May 9 '14 at 16:54
terdon♦
63.9k12135212
63.9k12135212
4
A nice trick to self-discover this things is putting sentinel variables around. I mean, I putexport SET_IN_ETC_PROFILE=yes
in/etc/profile
,export SET_IN_HOME_ZSHRC=yes
in~/.zhshrc
(I am a zsh user), etc... Then reboot and a niceenv|grep SET_IN
will tell you all the story. To see which variables are seen by the desktop applications (the ones you launch from the dash or the WM, without using a terminal), see askubuntu.com/a/356973/16395
– Rmano
May 9 '14 at 19:19
1
so when you ssh, that would be an interactive shell, correct?
– amphibient
May 9 '14 at 21:11
@amphibient an interactive login shell, yes. When you open a terminal on tour local machine, it's an interactive, non login shell.
– terdon♦
May 10 '14 at 15:48
@Rmano I upvoted your comments. But moments later found the order inenv
has no relationship with the order of execution.
– Penghe Geng
Mar 2 '15 at 16:16
1
@xiaobai of course not, the point is thatSET_IN
will show you which files have been read, not in which order they have been read. The order is standard, it is what is shown in the man page excerpts I have in my answer.
– terdon♦
Mar 2 '15 at 16:21
|
show 1 more comment
4
A nice trick to self-discover this things is putting sentinel variables around. I mean, I putexport SET_IN_ETC_PROFILE=yes
in/etc/profile
,export SET_IN_HOME_ZSHRC=yes
in~/.zhshrc
(I am a zsh user), etc... Then reboot and a niceenv|grep SET_IN
will tell you all the story. To see which variables are seen by the desktop applications (the ones you launch from the dash or the WM, without using a terminal), see askubuntu.com/a/356973/16395
– Rmano
May 9 '14 at 19:19
1
so when you ssh, that would be an interactive shell, correct?
– amphibient
May 9 '14 at 21:11
@amphibient an interactive login shell, yes. When you open a terminal on tour local machine, it's an interactive, non login shell.
– terdon♦
May 10 '14 at 15:48
@Rmano I upvoted your comments. But moments later found the order inenv
has no relationship with the order of execution.
– Penghe Geng
Mar 2 '15 at 16:16
1
@xiaobai of course not, the point is thatSET_IN
will show you which files have been read, not in which order they have been read. The order is standard, it is what is shown in the man page excerpts I have in my answer.
– terdon♦
Mar 2 '15 at 16:21
4
4
A nice trick to self-discover this things is putting sentinel variables around. I mean, I put
export SET_IN_ETC_PROFILE=yes
in /etc/profile
, export SET_IN_HOME_ZSHRC=yes
in ~/.zhshrc
(I am a zsh user), etc... Then reboot and a nice env|grep SET_IN
will tell you all the story. To see which variables are seen by the desktop applications (the ones you launch from the dash or the WM, without using a terminal), see askubuntu.com/a/356973/16395– Rmano
May 9 '14 at 19:19
A nice trick to self-discover this things is putting sentinel variables around. I mean, I put
export SET_IN_ETC_PROFILE=yes
in /etc/profile
, export SET_IN_HOME_ZSHRC=yes
in ~/.zhshrc
(I am a zsh user), etc... Then reboot and a nice env|grep SET_IN
will tell you all the story. To see which variables are seen by the desktop applications (the ones you launch from the dash or the WM, without using a terminal), see askubuntu.com/a/356973/16395– Rmano
May 9 '14 at 19:19
1
1
so when you ssh, that would be an interactive shell, correct?
– amphibient
May 9 '14 at 21:11
so when you ssh, that would be an interactive shell, correct?
– amphibient
May 9 '14 at 21:11
@amphibient an interactive login shell, yes. When you open a terminal on tour local machine, it's an interactive, non login shell.
– terdon♦
May 10 '14 at 15:48
@amphibient an interactive login shell, yes. When you open a terminal on tour local machine, it's an interactive, non login shell.
– terdon♦
May 10 '14 at 15:48
@Rmano I upvoted your comments. But moments later found the order in
env
has no relationship with the order of execution.– Penghe Geng
Mar 2 '15 at 16:16
@Rmano I upvoted your comments. But moments later found the order in
env
has no relationship with the order of execution.– Penghe Geng
Mar 2 '15 at 16:16
1
1
@xiaobai of course not, the point is that
SET_IN
will show you which files have been read, not in which order they have been read. The order is standard, it is what is shown in the man page excerpts I have in my answer.– terdon♦
Mar 2 '15 at 16:21
@xiaobai of course not, the point is that
SET_IN
will show you which files have been read, not in which order they have been read. The order is standard, it is what is shown in the man page excerpts I have in my answer.– terdon♦
Mar 2 '15 at 16:21
|
show 1 more comment
up vote
1
down vote
The info you are seeing when you login via ssh is created before /etc/profile is ever even looked at. Take a look at the sequence of files in /etc/update-motd.d. That will show you where the messages you are seeing are generated by various scripts.
1
This is already covered in the top answer, but I appreciate your brevity. +1 :)
– wjandrea
Feb 24 at 0:14
add a comment |
up vote
1
down vote
The info you are seeing when you login via ssh is created before /etc/profile is ever even looked at. Take a look at the sequence of files in /etc/update-motd.d. That will show you where the messages you are seeing are generated by various scripts.
1
This is already covered in the top answer, but I appreciate your brevity. +1 :)
– wjandrea
Feb 24 at 0:14
add a comment |
up vote
1
down vote
up vote
1
down vote
The info you are seeing when you login via ssh is created before /etc/profile is ever even looked at. Take a look at the sequence of files in /etc/update-motd.d. That will show you where the messages you are seeing are generated by various scripts.
The info you are seeing when you login via ssh is created before /etc/profile is ever even looked at. Take a look at the sequence of files in /etc/update-motd.d. That will show you where the messages you are seeing are generated by various scripts.
answered Feb 23 at 22:13
Reese
112
112
1
This is already covered in the top answer, but I appreciate your brevity. +1 :)
– wjandrea
Feb 24 at 0:14
add a comment |
1
This is already covered in the top answer, but I appreciate your brevity. +1 :)
– wjandrea
Feb 24 at 0:14
1
1
This is already covered in the top answer, but I appreciate your brevity. +1 :)
– wjandrea
Feb 24 at 0:14
This is already covered in the top answer, but I appreciate your brevity. +1 :)
– wjandrea
Feb 24 at 0:14
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f463462%2fsequence-of-scripts-sourced-upon-login%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown