zl程序教程

您现在的位置是:首页 >  系统

当前栏目

Linux 命令(254)—— tty 命令

2023-06-13 09:17:10 时间

文章目录

1.命令简介

tty(teletypewriter)显示出连接到当前标准输入的终端设备文件名。

2.命令格式

tty [OPTION]...

3.选项说明

-s, --silent, --quiet
	什么也不显示,只返回退出状态值。
--help
	显示帮助信息。
--version
	显示版本信息。

4.返回值

当使用 -s, --silent, --quiet 时,返回码为 0 表示标准输入是终端,返回码为 1 表示标准输入不是终端,返回码为 2 表示选项错误,返回码为 3 表示有写错误发生。

5.常用示例

(1)显示当前终端设备文件名。

tty
/dev/pts/1

(2)什么也不显示,只返回退出状态值。

tty -s

echo $?
0

(3)显示帮助信息。

tty --help
Usage: tty [OPTION]...
Print the file name of the terminal connected to standard input.

  -s, --silent, --quiet   print nothing, only return an exit status
      --help     display this help and exit
      --version  output version information and exit

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'tty invocation'