Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu.Wang 2019-01-01 21:44:01 +08:00
commit da2a532ebe
5 changed files with 175 additions and 179 deletions

View File

@ -1,28 +1,28 @@
[#]: collector: (lujun9972)
[#]: translator: (LazyWolfLin)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10406-1.html)
[#]: subject: (How to Update Ubuntu [Terminal & GUI Methods] It's FOSS)
[#]: via: (https://itsfoss.com/update-ubuntu/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
如何更新 Ubuntu [终端及GUI方式] It's FOSS
初级:如何在终端及图形界面中更新 Ubuntu
======
**这篇教程将向你展示如何更新服务器版本或者桌面版本的 Ubuntu。它还解释了更新和升级之间的区别以及你应该了解的有关于 Ubuntu Linux 中的更新的一些其他内容。**
> 这篇教程将向你展示如何更新服务器版本或者桌面版本的 Ubuntu。它还解释了更新和升级之间的区别以及你应该了解的有关于 Ubuntu Linux 中的更新的一些其他内容。
如果你是一个新手并已经体验 Ubuntu 数天或几周,你可能想知道如何更新你的 [Ubuntu][1] 系统以获取安全补丁,错误修复和应用升级。
更新 Ubuntu 非常简单。我并不是瞎说。它简单得只要运行两个命令。让我来告诉你这两个命令的更多细节。
请注意,本教程适用于 Ubuntu 18.0416.04 或任何其他版本。命令行方式也适用于基于 Ubuntu 的发行版如 Linux MintLinux Liteelementary OS 等。
请注意,本教程适用于 Ubuntu 18.04、16.04 或任何其他版本。命令行方式也适用于基于 Ubuntu 的发行版如 Linux Mint、Linux Lite、elementary OS 等。
### 通过命令行更新 Ubuntu
![如何更新 Ubuntu][2]
在桌面上,打开终端。你可以在菜单里找到它或者使用 Ctrl+Alt+T [快捷键][3]。如果你是登陆到一台 [Ubuntu 服务器][4],那你已经在访问一个终端了。
在桌面上,打开终端。你可以在菜单里找到它或者使用 `Ctrl+Alt+T` [快捷键][3]。如果你是登录到一台 [Ubuntu 服务器][4],那你已经在访问一个终端了。
在终端里,你只需要使用以下命令:
@ -30,13 +30,13 @@
sudo apt update && sudo apt upgrade -y
```
它将询问密码,而你可以使用你的账号密码。输入时,你将不会看到任何内容在屏幕上,所以请继续输入你的密码并按回车键。
它将询问密码,而你可以使用你的账号密码。输入时,你将不会看到任何内容在屏幕上,所以请继续输入你的密码并按回车键。
现在,我来解释下上面的命令。
事实上,这不是一条命令。它由两条命令组成。符号 `&&` 是合并两条命令的一个方法,第二条命令仅在前一条命令执行成功时执行。
当命令 `apt upgrade` 要求你在安装更新前确认时,末尾的参数 `-y` 会自动输入 yes。
当命令 `apt upgrade` 要求你在安装更新前确认时,末尾的参数 `-y` 会自动输入 `yes`
请注意,你也可以逐条使用这两条命令:
@ -51,7 +51,7 @@ sudo apt upgrade
这条命令更新了可用软件包的本地数据库。如果你没运行这条命令,本地数据库将不会被更新,而你的系统将不会知道是否有可用的新版本。
这就是为什么当你运行 `sudo apt update`,你会在输出中看到大量的 URLs。这条命令会从对应的储存库(你在输出中看到的 URLs)中获取软件包信息。
这就是为什么当你运行 `sudo apt update`,你会在输出中看到大量的 URL。这条命令会从对应的储存库你在输出中看到的 URL中获取软件包信息。
![更新 Ubuntu Linux][5]
@ -61,7 +61,7 @@ sudo apt upgrade
apt list --upgradable
```
**补充阅读:** 阅读这篇文章了解[命令 `apt update` 的输出中的 IgnHit 和 Get 是什么][6]。
**补充阅读:** 阅读这篇文章了解[命令 apt update 的输出中的 Ign、Hit 和 Get 是什么][6]。
#### 说明sudo apt upgrade
@ -69,17 +69,17 @@ apt list --upgradable
![通过命令行更新 Ubuntu Linux][7]
你可以键入 `yes``y` 或者只敲回车键去确认安装这些更新。
你可以键入 `yes``y` 或者只敲回车键去确认安装这些更新。
所以总的来说,`sudo apt update` 会检查可用的新版本,而 `sudo apt upgrade` 实际上会执行更新。
命令 `update` 可能会令人困惑,因为你可能期望通过命令 `apt update` 安装更新来更新系统,但这并不会发生。
### 通过 GUI 更新 Ubuntu[适用于桌面用户]
### 通过 GUI 更新 Ubuntu(适用于桌面用户)
如果你使用桌面版 Ubuntu你并不需要为了更新系统而打开终端。你可以仍可以使用命令行更新但这只是一个选择。
在菜单力,找到 `Software Updater` 并运行它。
在菜单里,找到 “软件更新” 并运行它。
![在 Ubuntu 中运行 Software Updater][8]
@ -91,7 +91,7 @@ apt list --upgradable
![在 Ubuntu 中通过更新管理器安装更新][10]
现在,点击 `Install`,它可能会向你询问密码。
现在,点击 “安装”,它可能会向你询问密码。
![通过 GUI 在 Ubuntu Linux 中安装更新][11]
@ -107,7 +107,7 @@ apt list --upgradable
![通过 GUI 在 Ubuntu 中安装更新][13]
提示:如果 `software updater` 返回一个错误,你需要在终端是使用命令 `sudo apt update`。输出的最后几行将包含真正的错误信息。你可以在因特网上搜索该错误并解决问题。
提示:如果“软件更新”返回一个错误,你需要在终端是使用命令 `sudo apt update`。输出的最后几行将包含真正的错误信息。你可以在因特网上搜索该错误并解决问题。
### 更新 Ubuntu 时要记住几件事
@ -125,7 +125,7 @@ sudo apt autoremove
如果是 Linux 内核更新,你将需要在系统更新后重启。当你不希望服务器停机时,这将会是一个问题。
[热修复][15]功能允许Linux内核在持续运行时打补丁。换句话说就是你不需要重启你的系统。
[热修复][15]功能允许 Linux 内核在持续运行时打补丁。换句话说就是你不需要重启你的系统。
如果你在管理服务器,你可能需要[在 Ubuntu 中启用热修复][16]。
@ -148,7 +148,7 @@ via: https://itsfoss.com/update-ubuntu/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[LazyWolfLin](https://github.com/LazyWolfLin)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,3 +1,4 @@
zgj1024 is translating
How to be the lazy sysadmin
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cat-yawn-vm.png?itok=0c_zy6aQ)

View File

@ -1,160 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (McFly A Replacement To Ctrl+R Bash History Search Feature)
[#]: via: (https://www.ostechnix.com/mcfly-a-replacement-to-ctrlr-bash-history-search-feature/)
[#]: author: (SK https://www.ostechnix.com/author/sk/)
McFly A Replacement To Ctrl+R Bash History Search Feature
======
![](https://www.ostechnix.com/wp-content/uploads/2018/12/mcfly-720x340.png)
If you spend a lot of time on CLI mode, you should definitely used or heard about **reverse search** function in BASH. The keyboard shortcut to do reverse search in Bash is **Ctrl+r**. Using bash reverse search, we can bring up all commands which we used previously executed without having to re-type them every time. You can, of course, use UP/DOWN arrows to search your bash history. However, Ctrl+r will make this process much easier and faster. Today, I Stumbled upon a replacement to Ctrl+r Bash history search feature. Meet **“McFly”** , a simple tool written in **Rust** programming language that replaces the default Ctrl+r Bash history search with an intelligent search engine. All command suggestions made by McFly are prioritized in real time with a small **neural network**.
McFly rebinds Ctrl+r functionality to bring up all recently executed commands from your Bash history. It augments your shell history by tracking the following:
* Command exit status,
* timestamp (When you run the command),
* and execution directory (Where you run the command).
It saves all tracking details in a SQLite database. Since it tracks the commands historical exit status, you can simply ignore the old failed commands. Cool, yeah?
When suggesting a command, McFly considers the following facts:
* On which directory you ran the command. Youre likely to repeat that command in the same directory in future.
* What commands you typed before the command.
* How often you run the command.
* When you last ran the command.
* If youve selected the command in McFly before.
* The commands historical exit status. Because, you probably dont want to run old failed commands, right?
McFly maintains your default Bash history file, so you can stop using McFly at any time. McFly is not just for BASH, it is also extendable for other shells as well.
### Installing McFly
McFly can be installed using Linuxbrew on Linux. If you havent installed Linuxbrew yet, refer the following link.
[Linuxbrew A Common Package Manager For Linux And Mac OS X][1]
Once Linuxbrew installed, run the following commands to install McFly:
```
$ brew tap cantino/mcfly https://github.com/cantino/mcfly
$ brew install mcfly
```
After the installation is completed, you will see the following output.
```
==> Installing mcfly from cantino/mcfly
==> Downloading https://github.com/cantino/mcfly/releases/download/v0.2.5/mcfly-v0
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.c
######################################################################## 100.0%
==> ONE MORE STEP! Edit ~/.bashrc and add the following:
if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
. $(brew --prefix)/opt/mcfly/mcfly.bash
fi
🍺 /home/linuxbrew/.linuxbrew/Cellar/mcfly/v0.2.5: 4 files, 3.5MB, built in 33 seconds
```
![](https://www.ostechnix.com/wp-content/uploads/2018/12/install-mcfly.png)
As you can see, we need to do one more step before start using McFly.
Add the following lines to your **~/.bashrc** file:
```
if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
. $(brew --prefix)/opt/mcfly/mcfly.bash
fi
```
Finally, run the following command to take effects changes:
```
$ source ~/.bashrc
```
Your BASH history will be imported to McFly database when you run this command for the first time. It will take a few moments depending upon size of your bash history file. Once the import is done, you will see the following message.
```
McFly: Importing Bash history for the first time. This may take a minute or two...done.
```
You can now start using McFly.
### Usage
To search through your command history, just type mcfly search followed by the part of the command name and hit ENTER key. Mcfly will display the command suggestions based on the search query you just type.
```
$ mcfly search <part-of-the-command>
```
For instance, I type the following command:
```
$ mcfly search mk
```
Here is the sample output from my Ubuntu machine:
![](https://www.ostechnix.com/wp-content/uploads/2018/12/mcfly-command-1.png)
As you can see, I have used mkdir command two times. If you want to run a command from the list of suggestions, just use **UP/DOWN** arrows to select it and hit ENTER to run it immediately. If you want to edit a command, choose it and hit **TAB** key to bring it back to your Terminal and then edit before running it. To delete the selected command from the history, just press **F2**.
Alternatively, type the following command to open the history search and then type any command or part of the command to view the suggestions from your history.
```
$ mcfly search
```
McFly will display the command suggestions as you type.
Here is a short video demonstration of McFly:
![](https://www.ostechnix.com/wp-content/uploads/2018/12/mcfly-demo.gif)
View help:
```
$ mcfly --help
```
### Remove McFly
Dont like McFly, no problem! Remove it using the following commands:
```
$ brew uninstall mcfly
$ brew untap cantino/mcfly
```
Finally, remove the lines which we added earlier from **~/.bashrc** file.
And, thats all for now. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/mcfly-a-replacement-to-ctrlr-bash-history-search-feature/
作者:[SK][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.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/linuxbrew-common-package-manager-linux-mac-os-x/

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (wyxplus)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,155 @@
[#]: collector: (lujun9972)
[#]: translator: (FSSlc)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (McFly A Replacement To Ctrl+R Bash History Search Feature)
[#]: via: (https://www.ostechnix.com/mcfly-a-replacement-to-ctrlr-bash-history-search-feature/)
[#]: author: (SK https://www.ostechnix.com/author/sk/)
McFly Bash 历史命令搜索特性的一个替代品
======
![](https://www.ostechnix.com/wp-content/uploads/2018/12/mcfly-720x340.png)
假如你在命令行模式下花费过很长时间,那么你必定使用过或者听说过 BASH 的 **反向搜索** 功能,在 Bash 中执行反向搜索功能的快捷键是 **Ctrl+r**。通过使用这个特性,我们可以找到我们执行过的命令而无需再次输入它们。当然,你可以使用上下键来搜索你的 bash 命令记录,但使用 Ctrl+r 快捷键可以让这个搜索过程更简单快速。今天我找寻到了 Bash 历史命令搜索特性 Ctrl+r 的一个替代品,它就是 **“McFly”**。McFly 是一个使用 **Rust** 编程语言写就的简洁工具,自带一个智能的搜索引擎,用来替换默认的 Ctrl+r 这个 Bash 历史命令搜索特性。 McFly 提供的命令建议都是通过一个小巧的 **神经网络** 来实时排序给出的。
McFly 重新绑定了 Ctrl+r 快捷键,可以从你的 Bash 历史命令中找到所有最近执行过的命令。它通过追溯下面的信息来增强你的 shell 历史命令搜索特性:
* 命令结束状态
* 当你运行命令时的时间戳
* 以及你运行命令的执行目录
它将所有追溯的信息保存在一个 SQLite 数据库中。由于它追溯了命令的历史结束状态,所以你可以很轻易地忽略掉失败的命令。听起来很酷,对吧?
在给出一个命令建议时,它将考虑如下因素:
* 你在哪个目录执行的这个命令,将来你很有可能在相同的目录重复这个命令
* 在你执行这个命令之前,执行过什么命令
* 你执行这个命令有多频繁
* 你最后执行该命令的时间
* 你是否在 McFly 中选择过这个命令
* 以及这个命令的历史结束状态。因为你很有可能不会去执行失败过的命令,对吧?
McFly 维护着你的默认 Bash 历史文件所以你可以随时停止使用它。McFly 也并不只服务于 BASH 它也可以扩展到其他 shell 程序。
### 安装 McFly
在 Linux 中McFly 可以使用 Linuxbrew 来安装。如若你还没有安装过 Linuxbrew那么你可以参考下面的这个链接。译者注从其github 主页了解到也可以下载其二进制来使用。)
[Linuxbrew —— 一个使用 Linux 和 Mac OS X 的通用包管理][1]
一旦安装好了 Linuxbrew运行下面的命令来安装 McFly
```
$ brew tap cantino/mcfly https://github.com/cantino/mcfly
$ brew install mcfly
```
在安装完成后,你将看到下面的输出:
```
==> Installing mcfly from cantino/mcfly
==> Downloading https://github.com/cantino/mcfly/releases/download/v0.2.5/mcfly-v0
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.c
######################################################################## 100.0%
==> ONE MORE STEP! Edit ~/.bashrc and add the following:
if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
. $(brew --prefix)/opt/mcfly/mcfly.bash
fi
🍺 /home/linuxbrew/.linuxbrew/Cellar/mcfly/v0.2.5: 4 files, 3.5MB, built in 33 seconds
```
![](https://www.ostechnix.com/wp-content/uploads/2018/12/install-mcfly.png)
正如你上面看到的那样,在使用 McFly 之前我们需要再做一些配置。
将下面几行添加到你的 **~/.bashrc** 文件中:
```
if [ -f $(brew --prefix)/opt/mcfly/mcfly.bash ]; then
. $(brew --prefix)/opt/mcfly/mcfly.bash
fi
```
最后,再运行下面的命令来让更改生效。
```
$ source ~/.bashrc
```
当你第一次执行上面的这个命令时,你的 BASH 历史将会被导入 McFly 的数据库。依据你的 bash 历史文件的大小,这个过程将花费一些时间。一旦导入完成,你讲看到下面的提示信息。
```
McFly: Importing Bash history for the first time. This may take a minute or two...done.
```
现在你就可以使用 McFly 了。
### 使用方法
要在你的命令中执行搜索,只需要键入 mcfly search 再加上命令名的一部分,最后敲击 ENTER 键即可。Mcfly 将会基于你刚才键入的搜索查询语句给出命令建议。
```
$ mcfly search <part-of-the-command>
```
例如我键入了下面的命令:
```
$ mcfly search mk
```
下面展示的是我 Ubuntu 机子上的示例输出:
![](https://www.ostechnix.com/wp-content/uploads/2018/12/mcfly-command-1.png)
如你所见,我已经使用过 'mkdir' 这个命令两次。假如你想从这些命令建议中执行其中之一,只需使用上下键来选择它,然后敲击 ENTER 键来执行它就可以了。假如你想编辑其中一个命令,则需要先选择它,然后敲 **TAB** 键将这个命令放置到终端中,最后在运行它之前更改它就行了。要从历史中删除已经选择的命令,按 **F2** 即可。
或者,输入下面的命令来打开历史搜索,然后输入任意一个命令或者命令的一部分来从你的历史命令中查看它提供的建议。
```
$ mcfly search
```
在你输入的同时, McFly 将会展示命令的提示。
下面是一个介绍 McFly 的简短演示视频:
![](https://www.ostechnix.com/wp-content/uploads/2018/12/mcfly-demo.gif)
你还可以使用下面的命令来查看帮助:
```
$ mcfly --help
```
### 移除 McFly
不喜欢 McFly没问题可以使用下面的命令来移除它
```
$ brew uninstall mcfly
$ brew untap cantino/mcfly
```
最后,移除先前添加到 **~/.bashrc** 文件中的几行命令。
好了,这些就是所有了,更多精彩内容敬请期待,请保存关注!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/mcfly-a-replacement-to-ctrlr-bash-history-search-feature/
作者:[SK][a]
选题:[lujun9972][b]
译者:[FSSlc](https://github.com/FSSlc)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[b]: https://github.com/lujun9972
[1]: https://www.ostechnix.com/linuxbrew-common-package-manager-linux-mac-os-x/