What is a TTY and how can I enable it on Ubuntu?

穿精又带淫゛_ 提交于 2019-12-10 19:24:08

问题


I'm currently setting up a node.js server and I'm using the debug module here https://github.com/visionmedia/debug.

I'm trying to enable it so I can get the colored debugging information in my output, however my terminal looks like the last terminal screen at the bottom after it says:

When stdout is not a TTY, Date#toUTCString() is used, making it more useful for logging the debug information as shown below:

Can anyone shed some light on this? Thanks.


回答1:


tty is one of those funky Unix commands that prints (or, displays) to standard output the name of the terminal connected to standard input.

These are commonly used as a way to get access to the computer to fix things, without actually logging into a possibly b0rked desktop.

Related: What is tty7 in the commandline?

By default Ubuntu has 7 tty's.

1-6 are command line only, 7 runs your X session (your normal desktop).

To access them, use this keyboard shortcut:

Ctrl + Alt + F1

(changing F1 to F1-F6 to access the terminal that you need)

To get back to your X session (the normal desktop),

Ctrl + Alt + F7




回答2:


The TTY is the terminal or command prompt itself.

The screenshots are demonstrating the different results when stdout is directed to the terminal/TTY (with colors and time diffs) vs. when it's redirected elsewhere, such as to a file (via > out and with timestamps).

It determines which format to use with tty.isatty.

Note that not all terminals support the ANSI escape codes it's using to display colors.



来源:https://stackoverflow.com/questions/13388704/what-is-a-tty-and-how-can-i-enable-it-on-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!