Viewing system console messages in GUI

17,706

Solution 1

You can see the current contents of the text console /dev/tty1 in the file /dev/vcs1 (where 1 is the number in Ctrl+Alt+F1). (If you try to read from /dev/tty1, you'll compete with the program running there for keyboard input.) The vcs devices are normally only readable by root. You get a snapshot; there's no convenient way to get content as it comes.

The ttysnoop program allows you to watch the traffic on a console from another terminal (including an X terminal). But this is something you have to set up in advance.


Instead of trying to catch the messages when they've been output on the text console, arrange to have the messages directed to a different location. Most such console output will end up in the system logs, in files under /var/log. Under X (i.e. in graphical mode), you can catch these messages with xconsole, which is part of the standard X distribution.

If xconsole doesn't show the messages you want, edit your question to mention where these messages are coming from.

If you can't get xconsole to show any message, edit your question to include your exact operating system, any configuration steps you've taken, and any error message you saw.


If the messages are not coming from the system logging facility, but from a program you started in the text mode console, you'll be better served by using redirection. Arrange to start the program like this:

mv ~/.myprogram.log ~/.myprogram.log.old
myprogram --with arguments 2>&1 >~/.myprogram.log

Then you can read the output from the program from anywhere by looking in the file ~/.myprogram.log. In particular, to watch the file grow in real time, run

tail -n +1 -f ~/.myprogram.log

If the program is started by your X startup scripts, it would be better to redirect the output from the whole X startup sequence to a file. In fact many distributions do this automatically. If you're using a .xinitrc or .xsession file, put the following line near the beginning of the file to redirect the output from subsequent programs:

exec >"$HOME/.xsession-$DISPLAY.log" 2>&

Solution 2

You can use xconsole for this. From its description:

The xconsole program displays messages which are usually sent to /dev/console.

Depending on the configuration your distribution chose you might have to start it as root (i.e. with sudo xconsole respectively su -c xconsole),

Solution 3

Have you tried xterm -C? It works on Ubuntu 17.04.

Share:
17,706

Related videos on Youtube

Jay
Author by

Jay

Easy

Updated on September 17, 2022

Comments

  • Jay
    Jay over 1 year

    Under Linux, is it possible to view error messages that show up on the text mode terminal while in GUI mode, instead of having to press Ctrl+Alt+F1 or Ctrl+Alt+F2 to view the messages every time and then switching back to GUI mode by pressing Ctrl+Alt+F7?

    Thank you.

    • Uri Cohen
      Uri Cohen over 13 years
      I clarified the subject of the question. Bash is only one of many different shells for Linux. The messages are send to the entity in which (e.g.) bash is running, not the shell itself.
    • vfbsilva
      vfbsilva about 9 years
      Can't you just access /var/log/"blah" and read the respective log? Assuming it is on the boot process you might look at /var/log/boot.log
  • Jay
    Jay over 13 years
    thank you. But is there a way to view the messages that are already there on the console after i've started X? like for example, in my situation.. I've written a python script to randomly change the wallpaper. And i've set it up so that whenever I start X, the script gets called. But the script does not work the way i want it to and i get a few error messages on the console. When i start xconsole after i get into X, i can only see messages that are sent to the console from that point on. The man page for xconsole doesn't say anything about viewing messages that are already there on the console
  • Uri Cohen
    Uri Cohen over 13 years
    You can in any terminal window (e.g. xterm) display the messages printed during bootup with the command dmesg.
  • Jay
    Jay over 13 years
    Thank you. I simply did su -c "cat /dev/vcs1" and it worked. ANd like you mentioned, it was a simple snapshot of the messages on the console but that was all i needed.
  • Jay
    Jay over 13 years
    dmesg only shows the messages that appear during bootup. I do not think that it shows the messages that appear on the console after i boot up and login and do "startx" for example..
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' over 13 years
    @Jay: now that I've seen your comments, I have a different answer, which is that you should use redirection in your X startup scripts. I'm leaving the other possibilities because they may be useful to other people browsing the question archive.
  • terdon
    terdon about 9 years
    The OP wants to see the messages after having loaded the GUI. This will simply make the system wait for a minute before loading so it's not a solution.
  • Jeff Schaller
    Jeff Schaller over 6 years
    It sounds comment-worthy, but if Erik would add some context, it seems a plausible / possible answer: "-C This option indicates that this window should receive console output. This is not supported on all systems. ...."
  • Erik Bennett
    Erik Bennett over 6 years
    Fair points. Next time I'll make it a comment. Sorry for any conenvenience.