1

I have seen sometimes people launch a xterm from a normal terminal

xterm&

But I don't understand the intention behind, does xterm inherit all the environment settings from the current terminal?

  • What do you mean by normal terminal? – sjsam Aug 3 '16 at 21:06
  • What's the alternative? Clicking around in the GUI? Sometimes launching it from an existing shell is faster. Also, yes, it will be launched with whatever environment that shell has -- and may possibly be running as different user. It may even be on another server entirely, as this was historically what X11 and xterms were actually for. – alzee Aug 3 '16 at 21:08
1

xterm inherits (like any other process) the environment variables which are in your shell. But it sets several environment variables. That's documented in the ENVIRONMENT section of the manual page.

By the way, xterm is considered by most to be a "normal terminal".

As for why someone might do this:

  • if I've ssh'd into a remote machine, I may run multiple copies of xterm rather than put up with VNC's performance
  • if my current terminal is running screen, I'll run xterm to get the behavior without screen.

Other people will have other reasons.

  • and will export sth in the xterm affect the parent shell? – lorniper Aug 4 '16 at 6:00
  • no. xterm is running as a subprocess, and variables exported from a subprocess aren't exported to the parent process. – Thomas Dickey Aug 4 '16 at 7:53
0

They do inherit the exported values, one useful thing to do with

#export needed variables &  functions
xterm&

is to do a cleanup, this opens a detached process and from the xterm thus launched do

killall gnome-terminal
#you still have the variables and functions exported

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.