Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  fschmitt Oct 14 '10 at 20:15
add comment

2 Answers 2

up vote 4 down vote accepted

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>&
share|improve this answer
    
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 Oct 14 '10 at 20:49
    
@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. –  Gilles Oct 14 '10 at 21:19
add comment

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),

share|improve this answer
    
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 –  Jay Oct 14 '10 at 20:21
    
You can in any terminal window (e.g. xterm) display the messages printed during bootup with the command dmesg. –  fschmitt Oct 14 '10 at 20:29
    
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.. –  Jay Oct 14 '10 at 20:51
add comment

Your Answer

 
discard

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.