Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to send a command from the console, say tty1, to the terminal currently occupied with X (in my case tty7 as I use Debian), to tell for example mplayer to play a movie?

Edit - made a shorthand function with the commands I learned in the answer below:

function movie () {
  chvt 7
  DISPLAY=":0" mplayer -fs $1 > /dev/null 2> /dev/null
  chvt $ORIG_TTY
share|improve this question
up vote 6 down vote accepted

I'm exactly sure about what you are looking for. But to launch a new application inside a running X server you can use for example:

DISPLAY=":0" mplayer -fs video.ogg

You can choose the id of the X server, and you may add an optional screen identifier like :0.1 to launch the application in screen number 1.

share|improve this answer
Yes, that's the thing I looked for. Do you also happen to know how to incorporate the focus shift into that command (i.e., to emulate the Alt-F7 keypress to get the X display)? But your answer is correct. – Emanuel Berg Aug 20 '12 at 11:44
Try with chvt. (It was hard to remember the name of this command, I don't use it everyday…) – Stéphane Gimenez Aug 20 '12 at 11:46
Yes, chvt 7 does it. – Emanuel Berg Aug 20 '12 at 11:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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