mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
29beb01bd4
@ -1,108 +0,0 @@
|
||||
translating---geekpi
|
||||
|
||||
How To Switch Between TTYs Without Using Function Keys In Linux
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/08/Switch-Between-TTYs-720x340.png)
|
||||
|
||||
This brief guide describes how to switch between TTYs without function keys in Unix-like operating systems. Before going further, we will see what TTY is. As mentioned in an [**answer**][1] in AskUbuntu forum, the word **TTY** came from **T** ele **TY** pewriter. Back in the early days of Unix, the user terminals connected to computers were electromechanical teleprinters or teletypewriters( tty in short). Since then, the name TTY has continued to be used for text-only consoles. Nowadays, all text consoles represents virtual consoles, not physical consoles. The TTY command prints the file name of the terminal connected to standard input.
|
||||
|
||||
### Switch Between TTYs In Linux
|
||||
|
||||
By default, there are 7 ttys in Linux. They are known as tty1, tty2….. tty7. The 1 to 6 ttys are command line only. The 7th tty is GUI (your X desktop session). You can switch between different TTYs by using **CTRL+ALT+Fn** keys. For example to switch to tty1, we type CTRL+ALT+F1. This is how tty1 looks in Ubuntu 18.04 LTS server.
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/08/tty1.png)
|
||||
|
||||
If your system has no X session,
|
||||
|
||||
In some Linux editions (Eg. from Ubuntu 17.10 onwards), the login screen now uses virtual console 1 . So, you need to press CTRL+ALT+F3 up to CTRL+ALT+F6 for accessing the virtual consoles. To go back to desktop environment, press CTRL+ALT+F2 or CTRL+ALT+F7 on Ubuntu 17.10 and later.
|
||||
|
||||
What we have seen so far is we can easily switch between TTYs using CTRL+ALT+Function_Key(F1-F7). However, if you don’t want to use the functions keys for any reason, there is a simple command named **“chvt”** in Linux.
|
||||
|
||||
The “chvt N” command allows you to switch to foreground terminal N, the same as pressing CTRL+ALT+Fn. The corresponding screen is created if it did not exist yet.
|
||||
|
||||
Let us see print the current tty:
|
||||
```
|
||||
$ tty
|
||||
|
||||
```
|
||||
|
||||
Sample output from my Ubuntu 18.04 LTS server.
|
||||
|
||||
Now let us switch to tty2. To do so, type:
|
||||
```
|
||||
$ sudo chvt 2
|
||||
|
||||
```
|
||||
|
||||
Remember you need to use “sudo” with chvt command.
|
||||
|
||||
Now, check the current tty using command:
|
||||
```
|
||||
$ tty
|
||||
|
||||
```
|
||||
|
||||
You will see that the tty has changed now.
|
||||
|
||||
Similarly, you can switch to tty3 using “sudo chvt 3”, tty4 using “sudo chvt 4” and so on.
|
||||
|
||||
Chvt command can be useful when any one of your function keys doesn’t work.
|
||||
|
||||
To view the total number of active virtual consoles, run:
|
||||
```
|
||||
$ fgconsole
|
||||
2
|
||||
|
||||
```
|
||||
|
||||
As you can see, there are two active VTs in my system.
|
||||
|
||||
You can see the next unallocated virtual terminal using command:
|
||||
```
|
||||
$ fgconsole --next-available
|
||||
3
|
||||
|
||||
```
|
||||
|
||||
A virtual console is unused if it is not the foreground console, and no process has it open for reading or writing, and no text has been selected on its screen.
|
||||
|
||||
To get rid of unused VTs, just type:
|
||||
```
|
||||
$ deallocvt
|
||||
|
||||
```
|
||||
|
||||
The above command deallocates kernel memory and data structures for all unused virtual consoles. To put this simply, this command will free all resources connected to the unused virtual consoles.
|
||||
|
||||
For more details, refer the respective command’s man pages.
|
||||
```
|
||||
$ man tty
|
||||
|
||||
$ man chvt
|
||||
|
||||
$ man fgconsole
|
||||
|
||||
$ man deallocvt
|
||||
|
||||
```
|
||||
|
||||
And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned!
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:https://askubuntu.com/questions/481906/what-does-tty-stand-for
|
@ -1,3 +1,5 @@
|
||||
translating---geekpi
|
||||
|
||||
How to Update Firmware on Ubuntu 18.04
|
||||
======
|
||||
Usually, the default software center in Ubuntu and other Linux handle the update of the firmware of your system. But if you encounter errors with it, you can use fwupd command line tool for updating the firmware of your system.
|
||||
|
@ -0,0 +1,106 @@
|
||||
如何在 Linux 中不使用功能键在 TTY 之间切换
|
||||
======
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/08/Switch-Between-TTYs-720x340.png)
|
||||
|
||||
本简要指南介绍了在类 Unix 操作系统中如何在不使用功能键的情况下切换 TTY。在进一步讨论之前,我们将了解 TTY 是什么。正如在 AskUbuntu 论坛的一个[**答案**][1]中所提到的,**TTY**这个词来自 **T**ele **TY** pewriter。在 Unix 的早期,连接到计算机的用户终端就是机电电传机或电传打字机(简称 tty)。从那时起,TTY 这个名称继续用于纯文本控制台。如今,所有文本控制台都代表虚拟控制台,而不是物理控制台。TTY 命令打印连接到标准输入的终端的文件名。
|
||||
|
||||
### 在 Linux 中切换 TTY
|
||||
|
||||
默认情况下,Linux 中有 7 个 tty。它们被称为 tty1、tty2。。。tty7。1 到 6 tty 只是命令行。第 7 个 tty 是 GUI(你的 X 桌面会话)。你可以使用 **CTRL+ALT+Fn** 键在不同的 TTY 之间切换。例如,要切换到 tty1,我们按下 CTRL+ALT+F1。这就是 tty1 在 Ubuntu 18.04 LTS 服务器中的样子。
|
||||
|
||||
![](https://www.ostechnix.com/wp-content/uploads/2018/08/tty1.png)
|
||||
|
||||
如果你的系统没有 X 会话,
|
||||
|
||||
在某些 Linux 版本中(例如,从 Ubuntu 17.10 开始),登录页面开始使用虚拟控制台 1。因此,你需要按 CTRL+ALT+F3 到 CTRL+ALT+F6 来访问虚拟控制台。要返回桌面环境,请在 Ubuntu 17.10 及更高版本上按下 CTRL+ALT+F2 或 CTRL+ALT+F7。
|
||||
|
||||
目前为止我们看到我们可以使用 CTRL+ALT+功能键(F1-F7)在 TTY 之间轻松切换。但是,如果出于任何原因你不想使用功能键,那么在 Linux 中有一个名为 **“chvt”** 的简单命令。
|
||||
|
||||
“chvt N” 命令让你切换到前台终端 N,这与按 CTRL+ALT+Fn 相同。如果它不存在,则创建相应的屏幕。
|
||||
|
||||
让我们试试打印当前的 tty:
|
||||
```
|
||||
$ tty
|
||||
|
||||
```
|
||||
|
||||
我的 Ubuntu 18.04 LTS 服务器的示例输出。
|
||||
|
||||
现在让我们切换到 tty2。为此,请输入:
|
||||
```
|
||||
$ sudo chvt 2
|
||||
|
||||
```
|
||||
|
||||
记住你需要在 chvt 命令中使用 “sudo”。
|
||||
|
||||
现在,使用命令检查当前的 tty:
|
||||
```
|
||||
$ tty
|
||||
|
||||
```
|
||||
|
||||
你会看到 tty 现在已经改变了。
|
||||
|
||||
同样,你可以使用 “sudo chvt 3” 切换到 tty3,使用 “sudo chvt 4” 切换到 tty4 等等。
|
||||
|
||||
当任何一个功能键不起作用时,chvt 命令会很有用。
|
||||
|
||||
要查看活动虚拟控制台的总数,请运行:
|
||||
```
|
||||
$ fgconsole
|
||||
2
|
||||
|
||||
```
|
||||
|
||||
如你所见,我的系统中有两个活动的 VT。
|
||||
|
||||
你可以使用以下命令查看下一个未分配的虚拟终端:
|
||||
```
|
||||
$ fgconsole --next-available
|
||||
3
|
||||
|
||||
```
|
||||
|
||||
如果虚拟控制台不是前台控制台,并且它没有打开任何进程来读取或写入,并且未在其屏幕上选择任何文本,则它是未使用的。
|
||||
|
||||
要移除未使用的 VT,只需键入:
|
||||
```
|
||||
$ deallocvt
|
||||
|
||||
```
|
||||
|
||||
上面的命令为所有未使用的虚拟控制台释放内核内存和数据结构。简单地说,此命令将释放连接到未使用的虚拟控制台的所有资源。
|
||||
|
||||
有关更多详细信息,请参阅相应命令的手册页。
|
||||
```
|
||||
$ man tty
|
||||
|
||||
$ man chvt
|
||||
|
||||
$ man fgconsole
|
||||
|
||||
$ man deallocvt
|
||||
|
||||
```
|
||||
|
||||
就是这些了。希望这很有用。还有更多的好东西。敬请关注!
|
||||
|
||||
干杯!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:https://askubuntu.com/questions/481906/what-does-tty-stand-for
|
Loading…
Reference in New Issue
Block a user