Do terminal tabs correspond to different shells? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Where can I find documentation on the /etc/environment file format?How do I add environment variables?Difference between launching an application from a keyboard shortcut vs the terminal?Ensuring .profile gets executed when using nXEditing the environment variableCall shell script “inline” in another shell scriptIs “export” only useful for temporary effects?User defined variables, which is actually a better practice?Can't properly reset environment variablesReading system varibles in script
How can I fade player when goes inside or outside of the area?
Is there a documented rationale why the House Ways and Means chairman can demand tax info?
Do I really need recursive chmod to restrict access to a folder?
What LEGO pieces have "real-world" functionality?
What causes the vertical darker bands in my photo?
Why did the IBM 650 use bi-quinary?
How do I mention the quality of my school without bragging
How to find all the available tools in macOS terminal?
Should I discuss the type of campaign with my players?
What is a Meta algorithm?
Right-skewed distribution with mean equals to mode?
What are the pros and cons of Aerospike nosecones?
Models of set theory where not every set can be linearly ordered
If 'B is more likely given A', then 'A is more likely given B'
What happens to sewage if there is no river near by?
Why is "Consequences inflicted." not a sentence?
Are my PIs rude or am I just being too sensitive?
When is phishing education going too far?
How to do this path/lattice with tikz
Is there a concise way to say "all of the X, one of each"?
What's the purpose of writing one's academic bio in 3rd person?
What is the longest distance a 13th-level monk can jump while attacking on the same turn?
How to deal with a team lead who never gives me credit?
Why aren't air breathing engines used as small first stages
Do terminal tabs correspond to different shells?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Where can I find documentation on the /etc/environment file format?How do I add environment variables?Difference between launching an application from a keyboard shortcut vs the terminal?Ensuring .profile gets executed when using nXEditing the environment variableCall shell script “inline” in another shell scriptIs “export” only useful for temporary effects?User defined variables, which is actually a better practice?Can't properly reset environment variablesReading system varibles in script
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I've been using Environment variables for ages but only just read about Environment variables vs. Shell variables. According to the definition:
- Environment variables are "system-wide" and inherited by child shells and processes
- Shell variables are only valid in the shell in which they are set
The book I'm reading goes on to state that using export takes a variable in your current environment (bash shell) and makes it available in any every environment until you change it again.
But if I change an Environment variable (HISTSIZE, for example) by calling export HISTZISE=999
, and then check the value in a different terminal tab (echo $HISTSIZE
), the change isn't visible. Why is this if the change is supposed to be system-wide? Personally I'm used to always setting my Environment variables when opening a new terminal tab, and I had taken it for granted that exporting values wouldn't affect other tabs (shells?).
So my question is: Are different terminal tabs considered different shell environments? And what does "system-wide" then mean?
Thanks for the help!
command-line bash environment-variables
New contributor
add a comment |
I've been using Environment variables for ages but only just read about Environment variables vs. Shell variables. According to the definition:
- Environment variables are "system-wide" and inherited by child shells and processes
- Shell variables are only valid in the shell in which they are set
The book I'm reading goes on to state that using export takes a variable in your current environment (bash shell) and makes it available in any every environment until you change it again.
But if I change an Environment variable (HISTSIZE, for example) by calling export HISTZISE=999
, and then check the value in a different terminal tab (echo $HISTSIZE
), the change isn't visible. Why is this if the change is supposed to be system-wide? Personally I'm used to always setting my Environment variables when opening a new terminal tab, and I had taken it for granted that exporting values wouldn't affect other tabs (shells?).
So my question is: Are different terminal tabs considered different shell environments? And what does "system-wide" then mean?
Thanks for the help!
command-line bash environment-variables
New contributor
echo $$
shows you process identifier of the current shell. You can check that the value is different in different tabs.
– Nykakin
yesterday
add a comment |
I've been using Environment variables for ages but only just read about Environment variables vs. Shell variables. According to the definition:
- Environment variables are "system-wide" and inherited by child shells and processes
- Shell variables are only valid in the shell in which they are set
The book I'm reading goes on to state that using export takes a variable in your current environment (bash shell) and makes it available in any every environment until you change it again.
But if I change an Environment variable (HISTSIZE, for example) by calling export HISTZISE=999
, and then check the value in a different terminal tab (echo $HISTSIZE
), the change isn't visible. Why is this if the change is supposed to be system-wide? Personally I'm used to always setting my Environment variables when opening a new terminal tab, and I had taken it for granted that exporting values wouldn't affect other tabs (shells?).
So my question is: Are different terminal tabs considered different shell environments? And what does "system-wide" then mean?
Thanks for the help!
command-line bash environment-variables
New contributor
I've been using Environment variables for ages but only just read about Environment variables vs. Shell variables. According to the definition:
- Environment variables are "system-wide" and inherited by child shells and processes
- Shell variables are only valid in the shell in which they are set
The book I'm reading goes on to state that using export takes a variable in your current environment (bash shell) and makes it available in any every environment until you change it again.
But if I change an Environment variable (HISTSIZE, for example) by calling export HISTZISE=999
, and then check the value in a different terminal tab (echo $HISTSIZE
), the change isn't visible. Why is this if the change is supposed to be system-wide? Personally I'm used to always setting my Environment variables when opening a new terminal tab, and I had taken it for granted that exporting values wouldn't affect other tabs (shells?).
So my question is: Are different terminal tabs considered different shell environments? And what does "system-wide" then mean?
Thanks for the help!
command-line bash environment-variables
command-line bash environment-variables
New contributor
New contributor
New contributor
asked yesterday
KirjainKirjain
233
233
New contributor
New contributor
echo $$
shows you process identifier of the current shell. You can check that the value is different in different tabs.
– Nykakin
yesterday
add a comment |
echo $$
shows you process identifier of the current shell. You can check that the value is different in different tabs.
– Nykakin
yesterday
echo $$
shows you process identifier of the current shell. You can check that the value is different in different tabs.– Nykakin
yesterday
echo $$
shows you process identifier of the current shell. You can check that the value is different in different tabs.– Nykakin
yesterday
add a comment |
1 Answer
1
active
oldest
votes
export
exports a variable to all children of the current shell.
So if you do
somevariable=somevalue
export somevariable
bash
echo $somevariable
you'll see the value of $somevariable in this new shell.
However shells in other terminal tabs are not children of the shell in the first tab, so they won't inherit the exported variables.
The shells in terminal tabs are all children of the gnome process that opened the terminal, so they are "brothers and sisters". You can verify this by calling ps -f
in two terminal tabs and looking at the column PPID (parent process ID) of the bash line. In my example both have the parent 5319 which is the gnome terminal process.
tab 1:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5329 5319 0 10:36 pts/0 00:00:00 bash
jean 5359 5329 0 10:37 pts/0 00:00:00 ps -f
tab 2:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5363 5319 0 10:37 pts/1 00:00:00 bash
jean 5372 5363 0 10:37 pts/1 00:00:00 ps -f
$ ps -f -p5319
UID PID PPID C STIME TTY TIME CMD
jean 5319 2299 0 10:36 ? 00:00:02 /usr/lib/gnome-terminal/gnome-t
So it sounds like there's no way to "export" a variable to any other sibling or parent processes?
– Xen2050
yesterday
Correct. Alternatively you can set them in a script and then source this script in both tabs (. /path/to/script
).
– muclux
yesterday
Perfect answer, thank you!
– Kirjain
18 hours ago
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
);
);
Kirjain is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1133741%2fdo-terminal-tabs-correspond-to-different-shells%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
export
exports a variable to all children of the current shell.
So if you do
somevariable=somevalue
export somevariable
bash
echo $somevariable
you'll see the value of $somevariable in this new shell.
However shells in other terminal tabs are not children of the shell in the first tab, so they won't inherit the exported variables.
The shells in terminal tabs are all children of the gnome process that opened the terminal, so they are "brothers and sisters". You can verify this by calling ps -f
in two terminal tabs and looking at the column PPID (parent process ID) of the bash line. In my example both have the parent 5319 which is the gnome terminal process.
tab 1:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5329 5319 0 10:36 pts/0 00:00:00 bash
jean 5359 5329 0 10:37 pts/0 00:00:00 ps -f
tab 2:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5363 5319 0 10:37 pts/1 00:00:00 bash
jean 5372 5363 0 10:37 pts/1 00:00:00 ps -f
$ ps -f -p5319
UID PID PPID C STIME TTY TIME CMD
jean 5319 2299 0 10:36 ? 00:00:02 /usr/lib/gnome-terminal/gnome-t
So it sounds like there's no way to "export" a variable to any other sibling or parent processes?
– Xen2050
yesterday
Correct. Alternatively you can set them in a script and then source this script in both tabs (. /path/to/script
).
– muclux
yesterday
Perfect answer, thank you!
– Kirjain
18 hours ago
add a comment |
export
exports a variable to all children of the current shell.
So if you do
somevariable=somevalue
export somevariable
bash
echo $somevariable
you'll see the value of $somevariable in this new shell.
However shells in other terminal tabs are not children of the shell in the first tab, so they won't inherit the exported variables.
The shells in terminal tabs are all children of the gnome process that opened the terminal, so they are "brothers and sisters". You can verify this by calling ps -f
in two terminal tabs and looking at the column PPID (parent process ID) of the bash line. In my example both have the parent 5319 which is the gnome terminal process.
tab 1:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5329 5319 0 10:36 pts/0 00:00:00 bash
jean 5359 5329 0 10:37 pts/0 00:00:00 ps -f
tab 2:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5363 5319 0 10:37 pts/1 00:00:00 bash
jean 5372 5363 0 10:37 pts/1 00:00:00 ps -f
$ ps -f -p5319
UID PID PPID C STIME TTY TIME CMD
jean 5319 2299 0 10:36 ? 00:00:02 /usr/lib/gnome-terminal/gnome-t
So it sounds like there's no way to "export" a variable to any other sibling or parent processes?
– Xen2050
yesterday
Correct. Alternatively you can set them in a script and then source this script in both tabs (. /path/to/script
).
– muclux
yesterday
Perfect answer, thank you!
– Kirjain
18 hours ago
add a comment |
export
exports a variable to all children of the current shell.
So if you do
somevariable=somevalue
export somevariable
bash
echo $somevariable
you'll see the value of $somevariable in this new shell.
However shells in other terminal tabs are not children of the shell in the first tab, so they won't inherit the exported variables.
The shells in terminal tabs are all children of the gnome process that opened the terminal, so they are "brothers and sisters". You can verify this by calling ps -f
in two terminal tabs and looking at the column PPID (parent process ID) of the bash line. In my example both have the parent 5319 which is the gnome terminal process.
tab 1:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5329 5319 0 10:36 pts/0 00:00:00 bash
jean 5359 5329 0 10:37 pts/0 00:00:00 ps -f
tab 2:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5363 5319 0 10:37 pts/1 00:00:00 bash
jean 5372 5363 0 10:37 pts/1 00:00:00 ps -f
$ ps -f -p5319
UID PID PPID C STIME TTY TIME CMD
jean 5319 2299 0 10:36 ? 00:00:02 /usr/lib/gnome-terminal/gnome-t
export
exports a variable to all children of the current shell.
So if you do
somevariable=somevalue
export somevariable
bash
echo $somevariable
you'll see the value of $somevariable in this new shell.
However shells in other terminal tabs are not children of the shell in the first tab, so they won't inherit the exported variables.
The shells in terminal tabs are all children of the gnome process that opened the terminal, so they are "brothers and sisters". You can verify this by calling ps -f
in two terminal tabs and looking at the column PPID (parent process ID) of the bash line. In my example both have the parent 5319 which is the gnome terminal process.
tab 1:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5329 5319 0 10:36 pts/0 00:00:00 bash
jean 5359 5329 0 10:37 pts/0 00:00:00 ps -f
tab 2:
$ ps -f
UID PID PPID C STIME TTY TIME CMD
jean 5363 5319 0 10:37 pts/1 00:00:00 bash
jean 5372 5363 0 10:37 pts/1 00:00:00 ps -f
$ ps -f -p5319
UID PID PPID C STIME TTY TIME CMD
jean 5319 2299 0 10:36 ? 00:00:02 /usr/lib/gnome-terminal/gnome-t
edited yesterday
answered yesterday
mucluxmuclux
3,70011131
3,70011131
So it sounds like there's no way to "export" a variable to any other sibling or parent processes?
– Xen2050
yesterday
Correct. Alternatively you can set them in a script and then source this script in both tabs (. /path/to/script
).
– muclux
yesterday
Perfect answer, thank you!
– Kirjain
18 hours ago
add a comment |
So it sounds like there's no way to "export" a variable to any other sibling or parent processes?
– Xen2050
yesterday
Correct. Alternatively you can set them in a script and then source this script in both tabs (. /path/to/script
).
– muclux
yesterday
Perfect answer, thank you!
– Kirjain
18 hours ago
So it sounds like there's no way to "export" a variable to any other sibling or parent processes?
– Xen2050
yesterday
So it sounds like there's no way to "export" a variable to any other sibling or parent processes?
– Xen2050
yesterday
Correct. Alternatively you can set them in a script and then source this script in both tabs (
. /path/to/script
).– muclux
yesterday
Correct. Alternatively you can set them in a script and then source this script in both tabs (
. /path/to/script
).– muclux
yesterday
Perfect answer, thank you!
– Kirjain
18 hours ago
Perfect answer, thank you!
– Kirjain
18 hours ago
add a comment |
Kirjain is a new contributor. Be nice, and check out our Code of Conduct.
Kirjain is a new contributor. Be nice, and check out our Code of Conduct.
Kirjain is a new contributor. Be nice, and check out our Code of Conduct.
Kirjain is a new contributor. Be nice, and check out our Code of Conduct.
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%2f1133741%2fdo-terminal-tabs-correspond-to-different-shells%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
echo $$
shows you process identifier of the current shell. You can check that the value is different in different tabs.– Nykakin
yesterday