From 2890262c95ae4d609974376a74541ac3ebf06ac2 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 27 May 2020 23:40:47 +0800 Subject: [PATCH 1/9] PRF @geekpi --- ...w to Handle Automatic Updates in Ubuntu.md | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/translated/tech/20200501 How to Handle Automatic Updates in Ubuntu.md b/translated/tech/20200501 How to Handle Automatic Updates in Ubuntu.md index f86886d82c..5339f1df60 100644 --- a/translated/tech/20200501 How to Handle Automatic Updates in Ubuntu.md +++ b/translated/tech/20200501 How to Handle Automatic Updates in Ubuntu.md @@ -1,44 +1,48 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (How to Handle Automatic Updates in Ubuntu) [#]: via: (https://itsfoss.com/auto-updates-ubuntu/) [#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) -如何在 Ubuntu 中处理自动更新 +如何在 Ubuntu 中处理自动的无人值守升级 ====== -_**简介:本教程教你如何处理无人值守的升级,即 Ubuntu Linux 的自动系统更新。**_ +> 本教程教你如何处理无人值守的升级,即 Ubuntu Linux 的自动系统更新。 + +![](https://img.linux.net.cn/data/attachment/album/202005/27/234040fxb0nkc53pk0nxvx.jpg) 有时,当你尝试[关闭 Ubuntu 系统][1]时,可能看到这个阻止你关闭的页面: -**关机正在进行无人值守升级,请不要关闭计算机。** +> 关机过程中正在进行无人值守升级,请不要关闭计算机。 ![Unattended Upgrade In Progress In Ubuntu][2] -你可能想知道什么是“无人值守的升级”,以及它是如何在你不知情的情况下运行的。 +你可能会问这个“无人值守升级”是什么,怎么会在你不知情的情况下运行呢? -因为 [Ubuntu][3] 非常重视系统的安全性。默认情况下,它会每天自动检查系统更新,如果发现任何安全更新,那么会下载这些更新并自行安装。对于正常的系统和应用更新,它会通过软件更新程序通知你。 +原因是 [Ubuntu][3] 非常重视系统的安全性。默认情况下,它会每天自动检查系统更新,如果发现安全更新,它会下载这些更新并自行安装。对于正常的系统和应用更新,它会通过软件更新程序通知你。 -由于所有这些都是在后台发生的,因此你会直到关机或者尝试自己安装应用时才会意识到。 +由于所有这些都是在后台发生的,所以在你尝试关闭系统或尝试自行安装应用程序之前,你甚至不会意识到这一点。 -在进行这些无人值守的升级时尝试安装新软件会发生[无法获得锁的错误][4]。 +在这些无人值守的升级过程中,尝试安装新软件,会导致著名的[无法获得锁定的错误][4]。 ![][5] 如你所见,自动更新带来了一些小麻烦。你可以选择禁用自动更新,但这意味着你必须一直手动检查并[更新你的 Ubuntu 系统][6]。 -你真的需要禁用自动更新吗? +> **你真的需要禁用自动更新吗?** +> +> 请注意,这是一项安全功能。Linux 实际上允许你禁用系统中的所有功能,甚至禁用这些安全功能。 +> +> 但是我认为,作为普通用户,**你不应该禁用自动更新**。毕竟,它可以确保你的系统安全。 +> +> 为了确保系统的安全性,你可以忍受自动更新所带来的小麻烦。 -请注意,这是一项安全功能。Linux 实际上允许你禁用系统中的所有功能,甚至禁用这些安全功能。 -但是我认为,作为普通用户,_**你不应禁用自动更新**_。毕竟,它可以确保你的系统安全。 -为了确保系统的安全性,你可以忍受自动更新所带来的小麻烦。 +现在,你已经收到警告,还是觉得承担手动更新系统的额外任务更好,那么让我们看看如何处理自动更新。 -现在,你已经收到警告,并认为最好承担手动更新系统的额外任务,让我们看看如何处理自动更新。 - -与往常一样,有两种方法可以做到:GUI 和命令行。 我将向您=你展示两种方法。 +与往常一样,有两种方法可以做到:GUI 和命令行。 我将向你展示两种方法。 我在这里使用 Ubuntu 20.04,但是这些步骤对 Ubuntu 18.04 和任何其他 Ubuntu 版本均有效。 @@ -50,7 +54,7 @@ _**简介:本教程教你如何处理无人值守的升级,即 Ubuntu Linux 在此处,进入“更新”选项卡。查找“自动检查更新”。默认情况下,它设置为“每日”。 -你可以将其更改为“从不”,你的系统将永远不会检查更新。如果不检查更新,它将不会找到要安装的新更新。 +你可以将其更改为“从不”,你的系统将永远不会检查更新。如果不检查更新,它就不会找到要安装的新的更新。 ![Disable Auto Updates in Ubuntu Completely][8] @@ -58,13 +62,13 @@ _**简介:本教程教你如何处理无人值守的升级,即 Ubuntu Linux #### 在 Ubuntu 中处理自动更新的更好方法 -就个人而言,我建议让它自己检查更新。如果你不希望它自动安装更新,那么可以更改该行为以通知有关安全更新的可用性。 +就个人而言,我建议让它自己检查更新。如果你不希望它自动安装更新,那么可以更改该行为,以通知有关安全更新的可用性。 保持“自动检查更新”为“每日”,然后将“有安全更新时”选项更改为“立即显示”,而不是“自动下载并安装”。 ![Get notified for security updates instead of automatically installing them][9] -这样,它会检查是否有更新,而不是在后台自动安装更新,软件更新程序会通知你更新可用于系统。你的系统已经完成正常的系统和软件更新。 +这样,它会检查是否有更新,而不是在后台自动安装更新,软件更新程序会通知你有可用于系统的更新。而你的系统已经完成正常的系统和软件更新。 ![Get notified about security updates][10] @@ -76,13 +80,13 @@ _**简介:本教程教你如何处理无人值守的升级,即 Ubuntu Linux ### 如何在 Ubuntu 中使用命令行禁用自动更新 -你可以在 **/etc/apt/apt.conf.d/20auto-upgrades** 中找到自动升级设置。Ubuntu 终端中的默认文本编辑器是 Nano,因此你可以使用以下命令来编辑此文件: +你可以在 `/etc/apt/apt.conf.d/20auto-upgrades` 中找到自动升级设置。Ubuntu 终端中的默认文本编辑器是 Nano,因此你可以使用以下命令来编辑此文件: ``` sudo nano /etc/apt/apt.conf.d/20auto-upgrades ``` -现在,如果你不希望系统自动检查更新,那么可以将 APT::Periodic::Update-Package-Lists 的值更改为 0。 +现在,如果你不希望系统自动检查更新,那么可以将 `APT::Periodic::Update-Package-Lists` 的值更改为 `"0"`。 ``` APT::Periodic::Update-Package-Lists "0"; @@ -96,9 +100,9 @@ APT::Periodic::Update-Package-Lists "1"; APT::Periodic::Unattended-Upgrade "0"; ``` -**最后** +### 最后 -由于某种原因,启用了自动安全更新,建议你保持这种状态。小的烦恼实际上并不值得冒险损害系统安全性。你怎么看? +由于某种原因,启用了自动安全更新,建议你保持这种状态。这个小烦恼实际上并不值得冒险损害系统安全性。你怎么看? -------------------------------------------------------------------------------- @@ -107,7 +111,7 @@ via: https://itsfoss.com/auto-updates-ubuntu/ 作者:[Abhishek Prakash][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 5c164d055899445559c2bed98b92b3cd457cfaff Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Wed, 27 May 2020 23:46:20 +0800 Subject: [PATCH 2/9] PUB @geekpi https://linux.cn/article-12257-1.html --- .../20200501 How to Handle Automatic Updates in Ubuntu.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20200501 How to Handle Automatic Updates in Ubuntu.md (98%) diff --git a/translated/tech/20200501 How to Handle Automatic Updates in Ubuntu.md b/published/20200501 How to Handle Automatic Updates in Ubuntu.md similarity index 98% rename from translated/tech/20200501 How to Handle Automatic Updates in Ubuntu.md rename to published/20200501 How to Handle Automatic Updates in Ubuntu.md index 5339f1df60..4339c22494 100644 --- a/translated/tech/20200501 How to Handle Automatic Updates in Ubuntu.md +++ b/published/20200501 How to Handle Automatic Updates in Ubuntu.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12257-1.html) [#]: subject: (How to Handle Automatic Updates in Ubuntu) [#]: via: (https://itsfoss.com/auto-updates-ubuntu/) [#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) From 2507e47c89adf94a7865152385be7f3fd19b7dc1 Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 28 May 2020 01:10:47 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020200528=20Open=20Sou?= =?UTF-8?q?rce=20YouTube=20Alternative=20PeerTube=20Needs=20Your=20Support?= =?UTF-8?q?=20to=20Launch=20Version=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20200528 Open Source YouTube Alternative PeerTube Needs Your Support to Launch Version 3.md --- ... Needs Your Support to Launch Version 3.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sources/tech/20200528 Open Source YouTube Alternative PeerTube Needs Your Support to Launch Version 3.md diff --git a/sources/tech/20200528 Open Source YouTube Alternative PeerTube Needs Your Support to Launch Version 3.md b/sources/tech/20200528 Open Source YouTube Alternative PeerTube Needs Your Support to Launch Version 3.md new file mode 100644 index 0000000000..ec7ab97e21 --- /dev/null +++ b/sources/tech/20200528 Open Source YouTube Alternative PeerTube Needs Your Support to Launch Version 3.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Open Source YouTube Alternative PeerTube Needs Your Support to Launch Version 3) +[#]: via: (https://itsfoss.com/peertube-v3-campaign/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Open Source YouTube Alternative PeerTube Needs Your Support to Launch Version 3 +====== + +[PeerTube][1] (developed by [Framasoft][2]) is a free and open-source decentralized alternative to YouTube somewhat like [LBRY][3]. As the name suggests, it relies on [peer-to-peer connections][4] to operate the video hosting services. + +You can also choose to self-host your instance and also have access to videos from other instances (a federated network, just like [Mastodon][5]). + +It is being actively developed for a few years now. And, to take it up a notch, they have decided to launch a crowdfunding campaign for the next major release. + +The funding campaign will help them develop v3.0 of PeerTube with some amazing key features planned for the release this fall. + +![PeerTube Instance Example][6] + +### PeerTube: Brief Overview + +In addition to what I just mentioned above, PeerTube is a fully-functional peer to peer video platform. The best thing about it is — it’s open-source and free. So, you can check them out on [GitHub][7] if you want. + +You can watch their official video here: + +**Note:** You need to be cautious about your IP address if you have concerns about that on PeerTube (try using one of the [best VPNs available][8]). + +### PeerTube’s Crowdfunding Campaign For v3 Launch + +You’ll be excited to know that the crowdfunding campaign of **€60,000** already managed to **get 10,000 Euros on Day 1** (at the time of writing this). + +Now, coming to the details. The campaign aims to focus on gathering **funds for the next 6 months of development for a v3 release planned for November 2020.** It looks like a lot of work for a single full-time developer — but no matter whether they reach the funding goal, they intend to release the v3 with the existing funds they have. + +In their [announcement post][9], PeerTube team mentioned: + +> We feel like we need to develop it, that we have to. Imposing a condition stating « if we do not get our 60,000€, then there will not be a v3 » here, would be a lie, marketing manipulation : this is not the kind of relation we want to maintain with you. + +Next, let’s talk about the new features they’ve planned to introduced in the next 6 months: + + * Upon reaching the **€10,000 goal,** they plan to work on introducing a globalized video index to make it easier to search for videos across multiple instances. + * With **€**20,000 goal, PeerTube will dedicate one month on improving the moderation tools to make the best out of it. + * With 40,000 goal, they would work on the UX/UI of playlists. So, it will look better when you try to embed a playlist. In addition to this, the plugin system will be improved to make it easier to contribute to PeerTube’s code. + * With the end of the campaign reaching 60,000 goal, PeerTube’s live-streaming feature will be introduced. + + + +You can also find the details of their [roadmap on their site][10]. + +### Wrapping Up + +The ability to have a global inter-connected video index among multiple instances is something that was needed and it will also allow you to configure your own index. + +The content moderation tool improvement is also a huge deal because it’s not that easy to manage a decentralized network of video hosting services. While they aim to prevent censorship, a strict moderation is required to make PeerTube a comfortable place to watch videos. + +Even though I’m not sure about how useful PeerTube’s live-streaming feature will be, at launch. It is going to be something exciting to keep an eye out for. + +We at It’s FOSS made a token donation of 25 Euro. I would also encourage you to donate and help this open source achieve their financial goal for version 3 development. + +[Support PeerTube][11] + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/peertube-v3-campaign/ + +作者:[Ankush Das][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://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://joinpeertube.org +[2]: https://framasoft.org/en/ +[3]: https://itsfoss.com/lbry/ +[4]: https://en.wikipedia.org/wiki/Peer-to-peer +[5]: https://itsfoss.com/mastodon-open-source-alternative-twitter/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/peertube-instance-screenshot.jpg?ssl=1 +[7]: https://github.com/Chocobozzz/PeerTube +[8]: https://itsfoss.com/best-vpn-linux/ +[9]: https://framablog.org/2020/05/26/our-plans-for-peertube-v3-progressive-fundraising-live-streaming-coming-next-fall/ +[10]: https://joinpeertube.org/roadmap +[11]: https://joinpeertube.org/roadmap#support From ab227080a1d3e48e9cec3297088864782f4141ef Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 28 May 2020 01:11:04 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020200528=20Getting=20?= =?UTF-8?q?Started=20With=20Nano=20Text=20Editor=20[Beginner=E2=80=99s=20G?= =?UTF-8?q?uide]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20200528 Getting Started With Nano Text Editor -Beginner-s Guide.md --- ...With Nano Text Editor -Beginner-s Guide.md | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 sources/tech/20200528 Getting Started With Nano Text Editor -Beginner-s Guide.md diff --git a/sources/tech/20200528 Getting Started With Nano Text Editor -Beginner-s Guide.md b/sources/tech/20200528 Getting Started With Nano Text Editor -Beginner-s Guide.md new file mode 100644 index 0000000000..90874df3e9 --- /dev/null +++ b/sources/tech/20200528 Getting Started With Nano Text Editor -Beginner-s Guide.md @@ -0,0 +1,246 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Getting Started With Nano Text Editor [Beginner’s Guide]) +[#]: via: (https://itsfoss.com/nano-editor-guide/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Getting Started With Nano Text Editor [Beginner’s Guide] +====== + +[Nano][1] is the default [terminal-based text editor][2] in Ubuntu and many other Linux distributions. Though it is less complicated to use than the likes of [Vim][3] and [Emacs][4], it doesn’t mean Nano cannot be overwhelming to use. + +In this beginner’s guide, I’ll show you how to use the Nano text editor. I am also going to include a downloadable PDF cheat sheet at the end of the article so that you can refer to it for practicing and mastering Nano editor commands. + +If you are just interested in a quick summary of Nano keyboard shortcuts, please expand the next section. + +Essential Nano keyboard shortcuts (click to expand) + +**Shortcut** | **Description** +---|--- +nano filename | Open file for editing in Nano +Arrow keys | Move cursor up, down, left and right +Ctrl+A, Ctrl+E | Move cursor to start and end of the line +Ctrl+Y/Ctrl+V | Move page up and down +Ctrl+_ | Move cursor to a certain location +Alt+A and then use arrow key | Set a marker and select text +Alt+6 | Copy the selected text +Ctrl+K | Cut the selected text +Ctrl+U | Paste the selected text +Ctrl+6 | Cancel the selection +Ctrl+K | Cut/delete entire line +Alt+U | Undo last action +Alt+E | Redo last action +Ctrl+W, Alt+W | Search for text, move to next match +Ctrl+\ | Search and replace +Ctrl+O | Save the modification +Ctrl+X | Exit the editor + +### How to use Nano text editor + +![][5] + +I presume that you have Nano editor installed on your system already. If not, please your distribution’s package manager to install it. + +#### Getting familiar with the Nano editor interface + +If you’ve ever [used Vim][6] or Emacs, you’ll notice that using Nano is a lot simpler. You can start writing or editing text straightaway. + +Nano editor also shows important keyboard shortcuts you need to use for editing at the bottom of the editor. This way you won’t get stuck at [exiting the editor like Vim][7]. + +The wider your terminal window, the more shortcuts it shows. + +![Nano Editor Interface][8] + +You should get familiar with the symbols in Nano. + + * The caret symbol (^) means Ctrl key + * The M character mean the Alt key + + + +When it says “^X Exit”, it means to use Ctrl+X keys to exit the editor. When it says “M-U Undo”, it means use Alt+U key to undo your last action. + +#### Open or create a file for editing in Nano + +You can open a file for editing in Nano like this: + +``` +nano my_file +``` + +If the file doesn’t exist, it will still open the editor and when you exit, you’ll have the option for saving the text to my_file. + +You may also open a new file without any name (like new document) with Nano like this: + +``` +nano +``` + +#### Basic editing + +You can start writing or modifying the text straightaway in Nano. There are no special insert mode or anything of that sort. It is almost like using a regular text editor, at least for writing and editing. + +As soon as you modify anything in the file, you’ll notice that it reflects this information on the editor. + +![][9] + +Nothing is saved immediately to the file automatically unless you explicitly do so. When you exit the editor using Ctrl+X keyboard shortcut, you’ll be asked whether you want to save your modified text to the file or not. + +#### Moving around in the editor + +Mouse click doesn’t work here. Use the arrow keys to move up and down, left and right. + +You can use the Home key or Ctrl+A to move to the beginning of a line and End key or Ctrl+E to move to the end of a line. Ctrl+Y/Page Up and Ctrl+V/Page Down keys can be used to scroll by pages. + +If you want to go a specific location like last line, first line, to a certain text, use Ctrl+_ key combination. This will show you some options you can use at the bottom of the editor. + +![Jump to a specific line in Nano][10] + +#### Cut, copy and paste in Nano editor + +If you don’t want to spend too much time remembering the shortcuts, use mouse. + +Select a text with mouse and then use the right click menu to copy the text. You may also use the Ctrl+Shift+C [keyboard shortcut in Ubuntu][11] terminal. Similarly, you can use the right click and select paste from the menu or use the Ctrl+Shift+V key combination. + +**Nano specific shortcuts for copy and pasting** + +Nano also provides its own shortcuts for cutting and pasting text but that could become confusing for beginners. + +Move your cursor to the beginning of the text you want to copy. Press Alt+A to set a marker. Now use the arrow keys to highlight the selection. Once you have selected the desired text, you can Alt+6 key to copy the selected text or use Ctrl+K to cut the selected text. Use Ctrl+6 to cancel the selection. + +Once you have copied or cut the selected text, you can use Ctrl+U to paste it. + +![][12] + +#### Delete text or lines in Nano + +There is no dedicated option for deletion in Nano. You may use the Backspace or Delete key to delete one character at a time. Press them repeatedly or hold them to delete multiple characters. + +You can also use the Ctrl+K keys that cuts the entire line. If you don’t paste it anywhere, it’s as good as deleting a line. + +If you want to delete multiple lines, you may use Ctrl+K on all of them one by one. + +Another option is to use the marker (Ctrl+a). Set the marker and move the arrow to select a portion of text. Use Ctrl+K to cut the text. No need to paste it and the selected text will be deleted (in a way). + +#### Undo or redo your last action + +Cut the wrong line? Pasted the wrong text selection? It’s easy to make such silly mistakes and it’s easy to correct those silly mistakes. + +You can undo and redo your last actions using: + + * Alt+U : Undo + * Alt +E : Redo + + + +You can repeat these key combinations to undo or redo multiple times. + +#### Search and replace + +If you want to search for a certain text, use Ctrl+W and then enter the term you want to search and press enter. The cursor will move to the first match. To go to the next match, use Alt+W keys. + +![][13] + +By default, the search is case-insensitive. You can also use regex for the search terms. + +If you want to replace the searched term, use Ctr+\ keys and then enter the search term and press enter key. Next it will ask for the term you want to replace the searched items with. + +![][14] + +The cursor will move to the first match and Nano will ask for your conformation for replacing the matched text. Use Y or N to confirm or deny respectively. Using either of Y or N will move to the next match. You may also use A to replace all matches. + +![][15] + +#### Save your file while editing (without exiting) + +In a graphical editor, you are probable used to of saving your changes from time to time. In Nano, you can use Ctrl+O to save your changes you made to the file. It also works with a new, unnamed file. + +![][16] + +Nano actually shows this keyboard shortcut at the bottom but it’s not obvious. It says “^O Write Out” which actually means to use Ctrl+O (it is letter O, not number zero) to save your current work. Not everyone can figure that out. + +In a graphical text editor, you probably use Ctrl+S to save your changes. Old habits die hard but it could cause trouble. Out of habit, if you accidentally press Ctrl+S to save your file, you’ll notice that the terminal freezes and you can do nothing. + +If you accidentally press Ctrl+S press Ctrl+Q nothing can be more scary than a frozen terminal and losing the work. + +#### Save and exit Nano editor + +To exit the editor, press Ctrl+X keys. When you do that, it will give you the option to save the file, or discard the file or cancel the exit process. + +![][17] + +If you want to save the modified file as a new file (save as function in usual editors), you can do that as well. When you press Ctrl+X to exit and then Y to save the changes, it gives the option to which file it should save the changes. You can change the file name at this point. + +You’ll need to have ‘write permission’ on the file you are editing if you want to save the modifications to the file. + +#### Forgot keyboard shortcut? Use help + +Like any other terminal based text editor, Nano relies heavily on keyboard shortcuts. Though it displays several useful shortcuts on the bottom of the editor, you cannot see all of them. + +It is not possible to remember all the shortcuts, specially in the beginning. What you can do is to use the Ctrl+G keys to bring up the detailed help menu. The help menu lists all the keyboard shortcuts. + +![][18] + +#### Always look at the bottom of the Nano editor + +If you are using Nano, you’ll notice that it displays important information at the bottom. This includes the keyboard shortcuts that will be used in the scenario. It also shows the last action you performed. + +![][19] + +If you get too comfortable with Nano, you can get more screen for editing the text by disabling the shortcuts displayed at the bottom. You can use Alt+X keys for that. I don’t recommend doing it, to be honest. Pressing Alt+X brings the shortcut display back. + +### Download Nano cheatsheet [PDF] + +There are a lot more shortcuts and editing options in Nano. I am not going to overwhelm you by mentioning them all. + +Here’s a quick summary of the important Nano keyboard shortcuts you should rememeber. Download link is under the image. + +![][20] + +[Download Nano Cheat Sheet (free PDF)][21] + +You can download the cheatsheet, print it and keep at your desk. It will help you in remembering and mastering the shortcuts. + +I hope you find this beginner’s guide to Nano text editor helpful. If you liked it, please share it on Reddit, [Hacker News][22] or in various [Linux forums][23] you frequently visit. + +I welcome your questions and suggestions. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/nano-editor-guide/ + +作者:[Abhishek Prakash][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://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.nano-editor.org/ +[2]: https://itsfoss.com/command-line-text-editors-linux/ +[3]: https://www.vim.org/ +[4]: https://www.gnu.org/software/emacs/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-guide.png?ssl=1 +[6]: https://itsfoss.com/pro-vim-tips/ +[7]: https://itsfoss.com/how-to-exit-vim/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-interface.png?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-modified-text.png?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-jump-to-line.png?ssl=1 +[11]: https://itsfoss.com/ubuntu-shortcuts/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-set-mark.png?ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-search-text.png?ssl=1 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-search-replace.png?ssl=1 +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-search-replace-confirm.png?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-save-while-writing.png?ssl=1 +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-save-and-exit.png?ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-help-menu.png?ssl=1 +[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-editor-hints.png?ssl=1 +[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/nano-cheatsheet.png?ssl=1 +[21]: https://itsfoss.com/wp-content/uploads/2020/05/Nano-Cheat-Sheet.pdf +[22]: https://news.ycombinator.com/ +[23]: https://itsfoss.community/ From fe5a14ebd3a403c09d07253fab4dc03cde5ff64a Mon Sep 17 00:00:00 2001 From: DarkSun Date: Thu, 28 May 2020 01:11:33 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020200527=20Manage=20s?= =?UTF-8?q?tartup=20using=20systemd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20200527 Manage startup using systemd.md --- .../20200527 Manage startup using systemd.md | 567 ++++++++++++++++++ 1 file changed, 567 insertions(+) create mode 100644 sources/tech/20200527 Manage startup using systemd.md diff --git a/sources/tech/20200527 Manage startup using systemd.md b/sources/tech/20200527 Manage startup using systemd.md new file mode 100644 index 0000000000..c0ff18a13d --- /dev/null +++ b/sources/tech/20200527 Manage startup using systemd.md @@ -0,0 +1,567 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Manage startup using systemd) +[#]: via: (https://opensource.com/article/20/5/manage-startup-systemd) +[#]: author: (David Both https://opensource.com/users/dboth) + +Manage startup using systemd +====== +Learn how systemd determines the order services start, even though it is +essentially a parallel system. +![Penguin with green background][1] + +While setting up a Linux system recently, I wanted to know how to ensure that dependencies for services and other units were up and running before those dependent services and units start. Specifically, I needed more knowledge of how systemd manages the startup sequence, especially in determining the order services are started in what is essentially a parallel system. + +You may know that SystemV (systemd's predecessor, as I explained in the [first article][2] in this series) orders the startup sequence by naming the startup scripts with an SXX prefix, where XX is a number from 00 to 99. SystemV then uses the sort order by name and runs each start script in sequence for the desired runlevel. + +But systemd uses unit files, which can be created or modified by a sysadmin, to define subroutines for not only initialization but also for regular operation. In the [third article][3] in this series, I explained how to create a mount unit file. In this fifth article, I demonstrate how to create a different type of unit file—a service unit file that runs a program at startup. You can also change certain configuration settings in the unit file and use the systemd journal to view the location of your changes in the startup sequence. + +### Preparation + +Make sure you have removed `rhgb` and `quiet` from the `GRUB_CMDLINE_LINUX=` line in the `/etc/default/grub` file, as I showed in the [second article][4] in this series. This enables you to observe the Linux startup message stream, which you'll need for some of the experiments in this article. + +### The program + +In this tutorial, you will create a simple program that enables you to observe a message during startup on the console and later in the systemd journal. + +Create the shell program `/usr/local/bin/hello.sh` and add the following content. You want to ensure that the result is visible during startup and that you can easily find it when looking through the systemd journal. You will use a version of the "Hello world" program with some bars around it, so it stands out. Make sure the file is executable and has user and group ownership by root with [700 permissions][5] for security: + + +``` +#!/usr/bin/bash +# Simple program to use for testing startup configurations +# with systemd. +# By David Both +# Licensed under GPL V2 +# +echo "###############################" +echo "######### Hello World! ########" +echo "###############################" +``` + +Run this program from the command line to verify that it works correctly: + + +``` +[root@testvm1 ~]# hello.sh +############################### +######### Hello World! ######## +############################### +[root@testvm1 ~]# +``` + +This program could be created in any scripting or compiled language. The `hello.sh` program could also be located in other places based on the [Linux filesystem hierarchical structure][6] (FHS). I place it in the `/usr/local/bin` directory so that it can be easily run from the command line without having to prepend a path when I type the command. I find that many of the shell programs I create need to be run from the command line and by other tools such as systemd. + +### The service unit file + +Create the service unit file `/etc/systemd/system/hello.service` with the following content. This file does not need to be executable, but for security, it does need user and group ownership by root and [644][7] or [640][8] permissions: + + +``` +# Simple service unit file to use for testing +# startup configurations with systemd. +# By David Both +# Licensed under GPL V2 +# + +[Unit] +Description=My hello shell script + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/hello.sh + +[Install] +WantedBy=multi-user.target +``` + +Verify that the service unit file performs as expected by viewing the service status. Any syntactical errors will show up here: + + +``` +[root@testvm1 ~]# systemctl status hello.service +● hello.service - My hello shell script +     Loaded: loaded (/etc/systemd/system/hello.service; disabled; vendor preset: disabled) +     Active: inactive (dead) +[root@testvm1 ~]# +``` + +You can run this "oneshot" service type multiple times without problems. The oneshot type is intended for services where the program launched by the service unit file is the main process and must complete before systemd starts any dependent process. + +There are seven service types, and you can find an explanation of each (along with the other parts of a service unit file) in the [systemd.service(5)][9] man page. (You can also find more information in the [resources][10] at the end of this article.) + +As curious as I am, I wanted to see what an error might look like. So, I deleted the "o" from the `Type=oneshot` line, so it looked like `Type=neshot`, and ran the command again: + + +``` +[root@testvm1 ~]# systemctl status hello.service +● hello.service - My hello shell script +     Loaded: loaded (/etc/systemd/system/hello.service; disabled; vendor preset: disabled) +     Active: inactive (dead) + +May 06 08:50:09 testvm1.both.org systemd[1]: /etc/systemd/system/hello.service:12: Failed to parse service type, ignoring: neshot +[root@testvm1 ~]# +``` + +These results told me precisely where the error was and made it very easy to resolve the problem. + +Just be aware that even after you restore the `hello.service` file to its original form, the error will persist. Although a reboot will clear the error, you should not have to do that, so I went looking for a method to clear out persistent errors like this. I have encountered service errors that require the command `systemctl daemon-reload` to reset an error condition, but that did not work in this case. The error messages that can be fixed with this command always seem to have a statement to that effect, so you know to run it. + +It is, however, recommended that you run `systemctl daemon-reload` after changing a unit file or creating a new one. This notifies systemd that the changes have been made, and it can prevent certain types of issues with managing altered services or units. Go ahead and run this command. + +After correcting the misspelling in the service unit file, a simple `systemctl restart hello.service` cleared the error. Experiment a bit by introducing some other errors into the `hello.service` file to see what kinds of results you get. + +### Start the service + +Now you are ready to start the new service and check the status to see the result. Although you probably did a restart in the previous section, you can start or restart a oneshot service as many times as you want since it runs once and then exits. + +Go ahead and start the service (as shown below), and then check the status. Depending upon how much you experimented with errors, your results may differ from mine: + + +``` +[root@testvm1 ~]# systemctl start hello.service +[root@testvm1 ~]# systemctl status hello.service +● hello.service - My hello shell script +     Loaded: loaded (/etc/systemd/system/hello.service; disabled; vendor preset: disabled) +     Active: inactive (dead) + +May 10 10:37:49 testvm1.both.org hello.sh[842]: ######### Hello World! ######## +May 10 10:37:49 testvm1.both.org hello.sh[842]: ############################### +May 10 10:37:49 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:37:49 testvm1.both.org systemd[1]: Finished My hello shell script. +May 10 10:54:45 testvm1.both.org systemd[1]: Starting My hello shell script... +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ######### Hello World! ######## +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +May 10 10:54:45 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:54:45 testvm1.both.org systemd[1]: Finished My hello shell script. +[root@testvm1 ~]# +``` + +Notice in the status command's output that the systemd messages indicate that the `hello.sh` script started and the service completed. You can also see the output from the script. This display is generated from the journal entries of the most recent invocations of the service. Try starting the service several times, and then run the status command again to see what I mean. + +You should also look at the journal contents directly; there are multiple ways to do this. One way is to specify the record type identifier, in this case, the name of the shell script. This shows the journal entries for previous reboots as well as the current session. As you can see, I have been researching and testing for this article for some time now: + + +``` +[root@testvm1 ~]# journalctl -t hello.sh +<snip> +\-- Reboot -- +May 08 15:55:47 testvm1.both.org hello.sh[840]: ############################### +May 08 15:55:47 testvm1.both.org hello.sh[840]: ######### Hello World! ######## +May 08 15:55:47 testvm1.both.org hello.sh[840]: ############################### +\-- Reboot -- +May 08 16:01:51 testvm1.both.org hello.sh[840]: ############################### +May 08 16:01:51 testvm1.both.org hello.sh[840]: ######### Hello World! ######## +May 08 16:01:51 testvm1.both.org hello.sh[840]: ############################### +\-- Reboot -- +May 10 10:37:49 testvm1.both.org hello.sh[842]: ############################### +May 10 10:37:49 testvm1.both.org hello.sh[842]: ######### Hello World! ######## +May 10 10:37:49 testvm1.both.org hello.sh[842]: ############################### +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ######### Hello World! ######## +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +[root@testvm1 ~]# +``` + +To locate the systemd records for the `hello.service` unit, you can search on systemd. You can use **G+Enter** to page to the end of the journal entries and then scroll back to locate the ones you are interested in. Use the `-b` option to show only the entries for the most recent startup: + + +``` +[root@testvm1 ~]# journalctl -b -t systemd +<snip> +May 10 10:37:49 testvm1.both.org systemd[1]: Starting SYSV: Late init script for live image.... +May 10 10:37:49 testvm1.both.org systemd[1]: Started SYSV: Late init script for live image.. +May 10 10:37:49 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:37:49 testvm1.both.org systemd[1]: Finished My hello shell script. +May 10 10:37:50 testvm1.both.org systemd[1]: Starting D-Bus System Message Bus... +May 10 10:37:50 testvm1.both.org systemd[1]: Started D-Bus System Message Bus. +``` + +I copied a few other journal entries to give you an idea of what you might find. This command spews all of the journal lines pertaining to systemd—109,183 lines when I wrote this. That is a lot of data to sort through. You can use the pager's search facility, which is usually `less`, or you can use the built-in `grep` feature. The `-g` (or `--grep=`) option uses Perl-compatible regular expressions: + + +``` +[root@testvm1 ~]# journalctl -b -t systemd -g "hello" +[root@testvm1 ~]# journalctl -b -t systemd -g "hello" +\-- Logs begin at Tue 2020-05-05 18:11:49 EDT, end at Sun 2020-05-10 11:01:01 EDT. -- +May 10 10:37:49 testvm1.both.org systemd[1]: Starting My hello shell script... +May 10 10:37:49 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:37:49 testvm1.both.org systemd[1]: Finished My hello shell script. +May 10 10:54:45 testvm1.both.org systemd[1]: Starting My hello shell script... +May 10 10:54:45 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:54:45 testvm1.both.org systemd[1]: Finished My hello shell script. +[root@testvm1 ~]# +``` + +You could use the standard GNU `grep` command, but that would not show the log metadata in the first line. + +If you do not want to see just the journal entries pertaining to your `hello` service, you can narrow things down a bit by specifying a time range. For example, I will start with the beginning time of `10:54:00` on my test VM, which was the start of the minute the entries above are from. ****Note that the `--since=` option must be enclosed in quotes and that this option can also be expressed as `-S "