mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-23 21:20:42 +08:00
translated
This commit is contained in:
parent
dee31d01f8
commit
db7cc7757f
@ -1,103 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to freeze and lock your Linux system (and why you would want to))
|
||||
[#]: via: (https://www.networkworld.com/article/3438818/how-to-freeze-and-lock-your-linux-system-and-why-you-would-want-to.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
How to freeze and lock your Linux system (and why you would want to)
|
||||
======
|
||||
What it means to freeze a terminal window and lock a screen -- and how to manage these activities on your Linux system.
|
||||
Sandra Henry-Stocker
|
||||
|
||||
How you freeze and "thaw out" a screen on a Linux system depends a lot on what you mean by these terms. Sometimes “freezing a screen” might mean freezing a terminal window so that activity within that window comes to a halt. Sometimes it means locking your screen so that no one can walk up to your system when you're fetching another cup of coffee and type commands on your behalf.
|
||||
|
||||
In this post, we'll examine how you can use and control these actions.
|
||||
|
||||
**[ Two-Minute Linux Tips: [Learn how to master a host of Linux commands in these 2-minute video tutorials][1] ]**
|
||||
|
||||
### How to freeze a terminal window on Linux
|
||||
|
||||
You can freeze a terminal window on a Linux system by typing **Ctrl+S** (hold control key and press "s"). Think of the "s" as meaning "start the freeze". If you continue typing commands after doing this, you won't see the commands you type or the output you would expect to see. In fact, the commands will pile up in a queue and will be run only when you reverse the freeze by typing **Ctrl+Q**. Think of this as "quit the freeze".
|
||||
|
||||
One easy way to view how this works is to use the date command and then type **Ctrl+S**. Then type the date command again and wait a few minutes before typing **Ctrl+Q**. You'll see something like this:
|
||||
|
||||
```
|
||||
$ date
|
||||
Mon 16 Sep 2019 06:47:34 PM EDT
|
||||
$ date
|
||||
Mon 16 Sep 2019 06:49:49 PM EDT
|
||||
```
|
||||
|
||||
The gap between the two times shown will indicate that the second date command wasn't run until you unfroze your window.
|
||||
|
||||
Terminal windows can be frozen and unfrozen whether you're sitting at the computer screen or running remotely using a tool such as PuTTY.
|
||||
|
||||
And here's a little trick that can come in handy. If you see that a terminal window appears to be inactive, one possibility is that you or someone else inadvertently typed **Ctrl+S**. In any case, entering **Ctrl+Q** just in case this resolves the problem is not a bad idea.
|
||||
|
||||
### How to lock your screen
|
||||
|
||||
To lock your screen before you leave your desk, either **Ctrl+Alt+L** or **Super+L** (i.e., holding down the Windows key and pressing L) should work. Once your screen is locked, you will have to enter your password to log back in.
|
||||
|
||||
### Automatic screen locking on Linux systems
|
||||
|
||||
While best practice suggests that you lock your screen whenever you are about to leave your desk, Linux systems usually automatically lock after a period of no activity. The timing for "blanking" a screen (making it go dark) and actually locking the screen (requiring a login to use it again) depend on settings that you can set to your personal preferences.
|
||||
|
||||
To change how long it takes for your screen to go dark when using GNOME screensaver, open your settings window and select **Power** and then **Blank screen**. You can choose times between 1 and 15 minutes or never. To select how long after the blanking the screen locks, go to settings, select **Privacy** and then **Blank screen.** Settings should include 1, 2, 3, 5 and 30 minutes or one hour.
|
||||
|
||||
### How to lock your screen from the command line
|
||||
|
||||
If you are using Gnome screensaver, you can also lock the screen from the command line using this command:
|
||||
|
||||
```
|
||||
gnome-screensaver-command -l
|
||||
```
|
||||
|
||||
That's a lowercase L for "lock".
|
||||
|
||||
### How to check your lockscreen state
|
||||
|
||||
You can also use the gnome screensaver command to check whether your screen is locked,. With the **\--query** option, the command tells you whether screen is currently locked (i.e., active). With the --time option, it tells you how long the lock has been in effect. Here's an sample sctipt:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
gnome-screensaver-command --query
|
||||
gnome-screensaver-command --time
|
||||
```
|
||||
|
||||
Running the script will show output like this:
|
||||
|
||||
```
|
||||
$ ./check_lockscreen
|
||||
The screensaver is active
|
||||
The screensaver has been active for 1013 seconds.
|
||||
```
|
||||
|
||||
#### Wrap-up
|
||||
|
||||
Freezing your terminal window is easy if you remember the proper control sequences. For screen locking, how well it works depends on the controls you put in place for yourself or whether you're comfortable working with the defaults.
|
||||
|
||||
**[ Also see: [Invaluable tips and tricks for troubleshooting Linux][2] ]**
|
||||
|
||||
Join the Network World communities on [Facebook][3] and [LinkedIn][4] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3438818/how-to-freeze-and-lock-your-linux-system-and-why-you-would-want-to.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua
|
||||
[2]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html
|
||||
[3]: https://www.facebook.com/NetworkWorld/
|
||||
[4]: https://www.linkedin.com/company/network-world
|
@ -0,0 +1,96 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to freeze and lock your Linux system (and why you would want to))
|
||||
[#]: via: (https://www.networkworld.com/article/3438818/how-to-freeze-and-lock-your-linux-system-and-why-you-would-want-to.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
如何冻结和锁定你的 Linux 系统(以及为何你会希望做)
|
||||
======
|
||||
冻结终端窗口并锁定屏幕意味着什么 - 以及如何在 Linux 系统上管理这些活动。
|
||||
|
||||
如何在 Linux 系统上冻结和“解冻”屏幕,很大程度上取决于这些术语的含义。有时“冻结屏幕”可能意味着冻结终端窗口,以便该窗口内的活动停止。有时它意味着锁定屏幕,这样就没人可以在你去拿一杯咖啡时,走到你的系统旁边代替你输入命令了。
|
||||
|
||||
在这篇文章中,我们将研究如何使用和控制这些操作。
|
||||
|
||||
### 如何在 Linux 上冻结终端窗口
|
||||
|
||||
你可以输入 **Ctrl+S**(按住 Ctrl 键和 “s” 键)冻结 Linux 系统上的终端窗口。把 “s” 想象成“开始冻结” (start the freeze)。如果在此操作后继续输入命令,那么你不会看到输入的命令或你希望看到的输出。实际上,命令将堆积在一个队列中,并且只有在通过输入 **Ctrl+Q** 解冻时才会运行。把它想象成“退出冻结” (quit the freeze)。
|
||||
|
||||
查看其工作的一种简单方式是使用 date 命令,然后输入 **Ctrl+S**。接着再次输入 date 命令并等待几分钟后再次输入 **Ctrl+Q**。你会看到这样的情景:
|
||||
|
||||
```
|
||||
$ date
|
||||
Mon 16 Sep 2019 06:47:34 PM EDT
|
||||
$ date
|
||||
Mon 16 Sep 2019 06:49:49 PM EDT
|
||||
```
|
||||
|
||||
这两次时间显示的差距表示第二次的 date 命令直到你解冻窗口时才运行。
|
||||
|
||||
无论你是坐在计算机屏幕前还是使用 PuTTY 等工具远程运行,终端窗口都可以冻结和解冻。
|
||||
|
||||
这有一个可以派上用场的小技巧。如果你发现终端窗口似乎处于非活动状态,那么可能是你或其他人无意中输入了 **Ctrl+S**。无论如何,输入 **Ctrl+Q** 来尝试解决不妨是个不错的办法。
|
||||
|
||||
### 如何锁定屏幕
|
||||
|
||||
要在离开办公桌前锁定屏幕,请按住 **Ctrl+Alt+L** 或 **Super+L**(即按住 Windows 键和 L 键)。屏幕锁定后,你必须输入密码才能重新登录。
|
||||
|
||||
### Linux 系统上的自动屏幕锁定
|
||||
|
||||
虽然最佳做法建议你在即将离开办公桌时锁定屏幕,但 Linux 系统通常会在一段时间没有活动后自动锁定。 “消隐”屏幕(使其变暗)并实际锁定屏幕(需要登录才能再次使用)的时间取决于你个人首选项中的设置。
|
||||
|
||||
要更改使用 GNOME 屏幕保护程序时屏幕变暗所需的时间,请打开设置窗口并选择 **Power** 然后 **Blank screen**。你可以选择 1 到 15 分钟或从不变暗。要选择屏幕变暗后锁定所需时间,请进入设置,选择 **Privacy**,然后选择**Blank screen**。设置应包括 1、2、3、5 和 30 分钟或一小时。
|
||||
|
||||
### 如何在命令行锁定屏幕
|
||||
|
||||
如果你使用的是 Gnome 屏幕保护程序,你还可以使用以下命令从命令行锁定屏幕:
|
||||
|
||||
```
|
||||
gnome-screensaver-command -l
|
||||
```
|
||||
|
||||
这里是小写的 L,代表“锁定”。
|
||||
|
||||
### 如何检查锁屏状态
|
||||
|
||||
你还可以使用 gnome-screensaver 命令检查屏幕是否已锁定。使用 **\--query** 选项,该命令会告诉你屏幕当前是否已锁定(即处于活动状态)。使用 --time 选项,它会告诉你锁定生效的时间。这是一个示例脚本:
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
gnome-screensaver-command --query
|
||||
gnome-screensaver-command --time
|
||||
```
|
||||
|
||||
运行脚本将会输出:
|
||||
|
||||
```
|
||||
$ ./check_lockscreen
|
||||
The screensaver is active
|
||||
The screensaver has been active for 1013 seconds.
|
||||
```
|
||||
|
||||
#### 总结
|
||||
|
||||
如果你记住了正确的控制方式,那么锁定终端窗口是很简单的。对于屏幕锁定,它的效果取决于你自己的设置,或者你是否习惯使用默认设置。
|
||||
|
||||
在 [Facebook][3] 和 [LinkedIn][4] 上加入 Network World 社区,来评论最新主题。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3438818/how-to-freeze-and-lock-your-linux-system-and-why-you-would-want-to.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[3]: https://www.facebook.com/NetworkWorld/
|
||||
[4]: https://www.linkedin.com/company/network-world
|
Loading…
Reference in New Issue
Block a user