What is a .bashrc file and what does it do?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I can't seem to find any clear information on what the .bashrc
file is and what it does exactly.
Thanks for all the help so far. It seems that this script does everything from coloring, completion, aliases and shell history, etc. Is there anything that does not seem useful?
bash bashrc
add a comment |
I can't seem to find any clear information on what the .bashrc
file is and what it does exactly.
Thanks for all the help so far. It seems that this script does everything from coloring, completion, aliases and shell history, etc. Is there anything that does not seem useful?
bash bashrc
4
.bashrc
is one of the many bash conmfiguration files. See the official documentation on Bash Startup Files.
– muru
Oct 24 '14 at 5:00
add a comment |
I can't seem to find any clear information on what the .bashrc
file is and what it does exactly.
Thanks for all the help so far. It seems that this script does everything from coloring, completion, aliases and shell history, etc. Is there anything that does not seem useful?
bash bashrc
I can't seem to find any clear information on what the .bashrc
file is and what it does exactly.
Thanks for all the help so far. It seems that this script does everything from coloring, completion, aliases and shell history, etc. Is there anything that does not seem useful?
bash bashrc
bash bashrc
edited 37 mins ago
codeforester
1157
1157
asked Oct 23 '14 at 18:08
JustinJustin
59651129
59651129
4
.bashrc
is one of the many bash conmfiguration files. See the official documentation on Bash Startup Files.
– muru
Oct 24 '14 at 5:00
add a comment |
4
.bashrc
is one of the many bash conmfiguration files. See the official documentation on Bash Startup Files.
– muru
Oct 24 '14 at 5:00
4
4
.bashrc
is one of the many bash conmfiguration files. See the official documentation on Bash Startup Files.– muru
Oct 24 '14 at 5:00
.bashrc
is one of the many bash conmfiguration files. See the official documentation on Bash Startup Files.– muru
Oct 24 '14 at 5:00
add a comment |
2 Answers
2
active
oldest
votes
The .bashrc
file is a script that is executed whenever a new terminal session is started in interactive mode. This is what happens when you open a new terminal window by pressing Ctrl+Alt+T, or just open a new terminal tab.
By contrast a terminal session in login mode will ask you for user name and password and execute the ~/.bash_profile
script. This is what takes place, for instance, when you log on to a remote system through SSH.
The .bashrc
file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, the shell history, command aliases and more. The .bashrc
file distributed with Ubuntu is well commented and you will be able to understand most of what it does just by reading it.
You can tweak .bashrc
to your liking. Here you can get an example with many extra features.
The link is broken.
– rab
Jun 5 '16 at 8:16
1
The link is working.
– Luís de Sousa
Jun 5 '16 at 8:28
In that page download file is not working.
– rab
Jun 5 '16 at 8:56
1
Both the link and the download work fine
– M. Becerra
Feb 22 '17 at 20:09
add a comment |
Question on superuser -What is the .bashrc
file? by @pineapple and answered by @DigitalRoss
Actually, it's
bash
specifically that reads.bashrc
(and
/etc/bash.bashrc
). There are lots of different shells.
The bash man page (by Brian Fox and
Chet Ramey; also info page "Bash Startup
Files")
is the authoritative reference:
When an interactive shell that is not
a login shell is started, bash reads
and executes commands from~/.bashrc
,
if that file exists. 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~/.bashrc
.
When bash is started
non-interactively, to run a shell
script, for example, it looks for the
variableBASH_ENV
in the environment,
expands its value if it appears there,
and uses the expanded value as the
name of a file to read and execute.
Bash behaves as if the following
command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the
PATH
variable is not used to search
for the file name.
The file is just shell commands. It is typically used to change
prompts, set environment variables, and define shell procedures.
Traditionally, the file.profile
is used for this purpose, but
bash
has so many extensions that it needs its own startup file for
users that want to put bashisms
in startup files.
"Not a login shell" means things like script launches and usually
terminal windows started by window managers. Sometimes I set up *nix
systems to have.bashrc
andBASH_ENV
just source.profile
. As
long as you don't stray outside of POSIX shell commands then you will
get the same initialization in any shell.
It's particularly valuable when
sh
is reallybash
, which sometimes
happens. To do this use:
. .profile
One reason this is all so complex is because sometimes people put
things that produce output into shell startup files, or they
unconditionally set prompts. This causes lots of problems when running
shell programs and backtick commands within languages, not to mention
system(3)
from C programs. The waybash
starts up is designed, I
think, to have one file where output and prompt setting is OK and one
file where it isn't. Traditionally, a run-time test would be done to
distinguish interactivity, for example, checking to see if the prompt
is set.
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',
autoActivateHeartbeat: false,
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%2f540683%2fwhat-is-a-bashrc-file-and-what-does-it-do%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
The .bashrc
file is a script that is executed whenever a new terminal session is started in interactive mode. This is what happens when you open a new terminal window by pressing Ctrl+Alt+T, or just open a new terminal tab.
By contrast a terminal session in login mode will ask you for user name and password and execute the ~/.bash_profile
script. This is what takes place, for instance, when you log on to a remote system through SSH.
The .bashrc
file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, the shell history, command aliases and more. The .bashrc
file distributed with Ubuntu is well commented and you will be able to understand most of what it does just by reading it.
You can tweak .bashrc
to your liking. Here you can get an example with many extra features.
The link is broken.
– rab
Jun 5 '16 at 8:16
1
The link is working.
– Luís de Sousa
Jun 5 '16 at 8:28
In that page download file is not working.
– rab
Jun 5 '16 at 8:56
1
Both the link and the download work fine
– M. Becerra
Feb 22 '17 at 20:09
add a comment |
The .bashrc
file is a script that is executed whenever a new terminal session is started in interactive mode. This is what happens when you open a new terminal window by pressing Ctrl+Alt+T, or just open a new terminal tab.
By contrast a terminal session in login mode will ask you for user name and password and execute the ~/.bash_profile
script. This is what takes place, for instance, when you log on to a remote system through SSH.
The .bashrc
file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, the shell history, command aliases and more. The .bashrc
file distributed with Ubuntu is well commented and you will be able to understand most of what it does just by reading it.
You can tweak .bashrc
to your liking. Here you can get an example with many extra features.
The link is broken.
– rab
Jun 5 '16 at 8:16
1
The link is working.
– Luís de Sousa
Jun 5 '16 at 8:28
In that page download file is not working.
– rab
Jun 5 '16 at 8:56
1
Both the link and the download work fine
– M. Becerra
Feb 22 '17 at 20:09
add a comment |
The .bashrc
file is a script that is executed whenever a new terminal session is started in interactive mode. This is what happens when you open a new terminal window by pressing Ctrl+Alt+T, or just open a new terminal tab.
By contrast a terminal session in login mode will ask you for user name and password and execute the ~/.bash_profile
script. This is what takes place, for instance, when you log on to a remote system through SSH.
The .bashrc
file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, the shell history, command aliases and more. The .bashrc
file distributed with Ubuntu is well commented and you will be able to understand most of what it does just by reading it.
You can tweak .bashrc
to your liking. Here you can get an example with many extra features.
The .bashrc
file is a script that is executed whenever a new terminal session is started in interactive mode. This is what happens when you open a new terminal window by pressing Ctrl+Alt+T, or just open a new terminal tab.
By contrast a terminal session in login mode will ask you for user name and password and execute the ~/.bash_profile
script. This is what takes place, for instance, when you log on to a remote system through SSH.
The .bashrc
file itself contains a series of configurations for the terminal session. This includes setting up or enabling: colouring, completion, the shell history, command aliases and more. The .bashrc
file distributed with Ubuntu is well commented and you will be able to understand most of what it does just by reading it.
You can tweak .bashrc
to your liking. Here you can get an example with many extra features.
edited Oct 24 '14 at 5:51
answered Oct 23 '14 at 18:30
Luís de SousaLuís de Sousa
9,3051752104
9,3051752104
The link is broken.
– rab
Jun 5 '16 at 8:16
1
The link is working.
– Luís de Sousa
Jun 5 '16 at 8:28
In that page download file is not working.
– rab
Jun 5 '16 at 8:56
1
Both the link and the download work fine
– M. Becerra
Feb 22 '17 at 20:09
add a comment |
The link is broken.
– rab
Jun 5 '16 at 8:16
1
The link is working.
– Luís de Sousa
Jun 5 '16 at 8:28
In that page download file is not working.
– rab
Jun 5 '16 at 8:56
1
Both the link and the download work fine
– M. Becerra
Feb 22 '17 at 20:09
The link is broken.
– rab
Jun 5 '16 at 8:16
The link is broken.
– rab
Jun 5 '16 at 8:16
1
1
The link is working.
– Luís de Sousa
Jun 5 '16 at 8:28
The link is working.
– Luís de Sousa
Jun 5 '16 at 8:28
In that page download file is not working.
– rab
Jun 5 '16 at 8:56
In that page download file is not working.
– rab
Jun 5 '16 at 8:56
1
1
Both the link and the download work fine
– M. Becerra
Feb 22 '17 at 20:09
Both the link and the download work fine
– M. Becerra
Feb 22 '17 at 20:09
add a comment |
Question on superuser -What is the .bashrc
file? by @pineapple and answered by @DigitalRoss
Actually, it's
bash
specifically that reads.bashrc
(and
/etc/bash.bashrc
). There are lots of different shells.
The bash man page (by Brian Fox and
Chet Ramey; also info page "Bash Startup
Files")
is the authoritative reference:
When an interactive shell that is not
a login shell is started, bash reads
and executes commands from~/.bashrc
,
if that file exists. 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~/.bashrc
.
When bash is started
non-interactively, to run a shell
script, for example, it looks for the
variableBASH_ENV
in the environment,
expands its value if it appears there,
and uses the expanded value as the
name of a file to read and execute.
Bash behaves as if the following
command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the
PATH
variable is not used to search
for the file name.
The file is just shell commands. It is typically used to change
prompts, set environment variables, and define shell procedures.
Traditionally, the file.profile
is used for this purpose, but
bash
has so many extensions that it needs its own startup file for
users that want to put bashisms
in startup files.
"Not a login shell" means things like script launches and usually
terminal windows started by window managers. Sometimes I set up *nix
systems to have.bashrc
andBASH_ENV
just source.profile
. As
long as you don't stray outside of POSIX shell commands then you will
get the same initialization in any shell.
It's particularly valuable when
sh
is reallybash
, which sometimes
happens. To do this use:
. .profile
One reason this is all so complex is because sometimes people put
things that produce output into shell startup files, or they
unconditionally set prompts. This causes lots of problems when running
shell programs and backtick commands within languages, not to mention
system(3)
from C programs. The waybash
starts up is designed, I
think, to have one file where output and prompt setting is OK and one
file where it isn't. Traditionally, a run-time test would be done to
distinguish interactivity, for example, checking to see if the prompt
is set.
add a comment |
Question on superuser -What is the .bashrc
file? by @pineapple and answered by @DigitalRoss
Actually, it's
bash
specifically that reads.bashrc
(and
/etc/bash.bashrc
). There are lots of different shells.
The bash man page (by Brian Fox and
Chet Ramey; also info page "Bash Startup
Files")
is the authoritative reference:
When an interactive shell that is not
a login shell is started, bash reads
and executes commands from~/.bashrc
,
if that file exists. 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~/.bashrc
.
When bash is started
non-interactively, to run a shell
script, for example, it looks for the
variableBASH_ENV
in the environment,
expands its value if it appears there,
and uses the expanded value as the
name of a file to read and execute.
Bash behaves as if the following
command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the
PATH
variable is not used to search
for the file name.
The file is just shell commands. It is typically used to change
prompts, set environment variables, and define shell procedures.
Traditionally, the file.profile
is used for this purpose, but
bash
has so many extensions that it needs its own startup file for
users that want to put bashisms
in startup files.
"Not a login shell" means things like script launches and usually
terminal windows started by window managers. Sometimes I set up *nix
systems to have.bashrc
andBASH_ENV
just source.profile
. As
long as you don't stray outside of POSIX shell commands then you will
get the same initialization in any shell.
It's particularly valuable when
sh
is reallybash
, which sometimes
happens. To do this use:
. .profile
One reason this is all so complex is because sometimes people put
things that produce output into shell startup files, or they
unconditionally set prompts. This causes lots of problems when running
shell programs and backtick commands within languages, not to mention
system(3)
from C programs. The waybash
starts up is designed, I
think, to have one file where output and prompt setting is OK and one
file where it isn't. Traditionally, a run-time test would be done to
distinguish interactivity, for example, checking to see if the prompt
is set.
add a comment |
Question on superuser -What is the .bashrc
file? by @pineapple and answered by @DigitalRoss
Actually, it's
bash
specifically that reads.bashrc
(and
/etc/bash.bashrc
). There are lots of different shells.
The bash man page (by Brian Fox and
Chet Ramey; also info page "Bash Startup
Files")
is the authoritative reference:
When an interactive shell that is not
a login shell is started, bash reads
and executes commands from~/.bashrc
,
if that file exists. 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~/.bashrc
.
When bash is started
non-interactively, to run a shell
script, for example, it looks for the
variableBASH_ENV
in the environment,
expands its value if it appears there,
and uses the expanded value as the
name of a file to read and execute.
Bash behaves as if the following
command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the
PATH
variable is not used to search
for the file name.
The file is just shell commands. It is typically used to change
prompts, set environment variables, and define shell procedures.
Traditionally, the file.profile
is used for this purpose, but
bash
has so many extensions that it needs its own startup file for
users that want to put bashisms
in startup files.
"Not a login shell" means things like script launches and usually
terminal windows started by window managers. Sometimes I set up *nix
systems to have.bashrc
andBASH_ENV
just source.profile
. As
long as you don't stray outside of POSIX shell commands then you will
get the same initialization in any shell.
It's particularly valuable when
sh
is reallybash
, which sometimes
happens. To do this use:
. .profile
One reason this is all so complex is because sometimes people put
things that produce output into shell startup files, or they
unconditionally set prompts. This causes lots of problems when running
shell programs and backtick commands within languages, not to mention
system(3)
from C programs. The waybash
starts up is designed, I
think, to have one file where output and prompt setting is OK and one
file where it isn't. Traditionally, a run-time test would be done to
distinguish interactivity, for example, checking to see if the prompt
is set.
Question on superuser -What is the .bashrc
file? by @pineapple and answered by @DigitalRoss
Actually, it's
bash
specifically that reads.bashrc
(and
/etc/bash.bashrc
). There are lots of different shells.
The bash man page (by Brian Fox and
Chet Ramey; also info page "Bash Startup
Files")
is the authoritative reference:
When an interactive shell that is not
a login shell is started, bash reads
and executes commands from~/.bashrc
,
if that file exists. 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~/.bashrc
.
When bash is started
non-interactively, to run a shell
script, for example, it looks for the
variableBASH_ENV
in the environment,
expands its value if it appears there,
and uses the expanded value as the
name of a file to read and execute.
Bash behaves as if the following
command were executed:
if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi
but the value of the
PATH
variable is not used to search
for the file name.
The file is just shell commands. It is typically used to change
prompts, set environment variables, and define shell procedures.
Traditionally, the file.profile
is used for this purpose, but
bash
has so many extensions that it needs its own startup file for
users that want to put bashisms
in startup files.
"Not a login shell" means things like script launches and usually
terminal windows started by window managers. Sometimes I set up *nix
systems to have.bashrc
andBASH_ENV
just source.profile
. As
long as you don't stray outside of POSIX shell commands then you will
get the same initialization in any shell.
It's particularly valuable when
sh
is reallybash
, which sometimes
happens. To do this use:
. .profile
One reason this is all so complex is because sometimes people put
things that produce output into shell startup files, or they
unconditionally set prompts. This causes lots of problems when running
shell programs and backtick commands within languages, not to mention
system(3)
from C programs. The waybash
starts up is designed, I
think, to have one file where output and prompt setting is OK and one
file where it isn't. Traditionally, a run-time test would be done to
distinguish interactivity, for example, checking to see if the prompt
is set.
edited Mar 20 '17 at 10:18
Community♦
1
1
answered Oct 23 '14 at 18:19
αғsнιηαғsнιη
25k23100162
25k23100162
add a comment |
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.
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%2f540683%2fwhat-is-a-bashrc-file-and-what-does-it-do%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
4
.bashrc
is one of the many bash conmfiguration files. See the official documentation on Bash Startup Files.– muru
Oct 24 '14 at 5:00