TranslateProject/translated/tech/20181210 How to Update Ubuntu -Terminal - GUI Methods- It-s FOSS.md

175 lines
8.1 KiB
Markdown
Raw Normal View History

2018-12-17 13:37:28 +08:00
[#]: collector: (lujun9972)
[#]: translator: (LazyWolfLin)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: 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/)
2018-12-18 14:05:23 +08:00
如何更新 Ubuntu [终端及GUI方式] It's FOSS
2018-12-17 13:37:28 +08:00
======
**这篇教程将向你展示如何更新服务器版本或者桌面版本的Ubuntu。它还解释了更新和升级之间的区别以及你应该了解的有关于Ubuntu Linux中的更新的一些其他内容。**
如果你是一个新手并已经体验Ubuntu数天或几周你可能想知道如何更新你的[Ubuntu][1]系统以获取安全补丁,错误修复和应用升级。
更新 Ubuntu 非常简单。我并不夸张的说。它简单得只要运行两个命令。让我来告诉你更多更新细节。
2018-12-18 14:05:23 +08:00
请注意,本教程适用于 Ubuntu 18.0416.04 或任何其他版本。命令行方式也适用于基于 Ubuntu 的发行版如 Linux MintLinux Liteelementary OS 等。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
### 通过命令行更新 Ubuntu
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
![如何更新 Ubuntu][2]
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
在桌面上,打开终端。你可以在菜单里找到它或者使用 Ctrl+Alt+T [快捷键][3]。如果你登陆到一台 [Ubuntu 服务器][4],那你已经在访问一个终端了。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
在终端里,你只需要使用以下命令:
2018-12-17 13:37:28 +08:00
```
sudo apt update && sudo apt upgrade -y
```
2018-12-18 14:05:23 +08:00
它将询问密码,而你可以使用你账号的密码。输入时,你将不会看到任何内容在屏幕上,所以请继续输入你的密码并按回车键。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
现在,我来解释下上面的命令。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
事实上,这不是一条命令。它由两条命令组成。符号 `&&` 是合并两条命令的一个方法,第二条命令仅在前一条命令执行成功时执行。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
当命令 `apt upgrade` 要求你在安装更新前确认时,末尾的参数 `-y` 会自动输入 yes。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
请注意,你也可以逐条使用这两条命令:
2018-12-17 13:37:28 +08:00
```
sudo apt update
sudo apt upgrade
```
2018-12-18 14:05:23 +08:00
这将花费更长的时间,因为你必须等待第一条命令执行完成后才能输入第二条命令。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
#### 说明sudo apt update
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
这条命令更新了可用软件包的本地数据库。如果你没运行这条命令,本地数据库将不会更新而你的系统将不会知道是否又可用的新版本。
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
这就是为什么当你运行 `sudo apt update`,你会在输出中看到大量的 URLs。这条命令从对应的储存库你在输出中看到的 URLs中获取软件包信息。
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
![更新 Ubuntu Linux][5]
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
在命令的末尾,它告诉你有多少个软件包可以被更新。你可以使用下列命令查看这些软件包:
2018-12-17 13:37:28 +08:00
```
apt list --upgradable
```
2018-12-19 13:40:24 +08:00
**补充阅读:** 阅读这篇文章了解[命令 `apt update` 的输出中的 IgnHit 和 Get 是什么][6]。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
#### 说明sudo apt upgrade
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
这条命令将已安装的软件包版本与本地数据库进行匹配。它收集全部信息,然后列出所有具有更新版本的软件包。此时,它会询问您是否要升级(已安装的软件包更新到新版本)。
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
![通过命令行更新 Ubuntu Linux][7]
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
你可以键入 `yes`,`y` 或者只敲回车键去确认安装这些更新。
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
所以总的来说,`sudo apt update` 会检查可用的新版本,而 `sudo apt upgrade` 实际上会执行更新。
2018-12-17 13:37:28 +08:00
2018-12-19 13:40:24 +08:00
命令 `update` 可能会令人困惑,因为你可能期望通过命令 `apt update` 安装更新来更新系统,但这并不会发生。
2018-12-17 13:37:28 +08:00
2018-12-18 14:05:23 +08:00
### 通过 GUI 更新 Ubuntu适用于桌面用户
2018-12-17 13:37:28 +08:00
If you are using Ubuntu as a desktop, you dont have to go to terminal just for updating the system. You can still use the command line but its optional for you.
In the menu, look for Software Updater and run it.
![Run Software Updater in Ubuntu][8]
It will check if there are updates available for your system.
![Checking if updates are available for Ubuntu][9]
If there are updates available, it will give provide you with options to install the updates.
![Install Updates via Update Manager in Ubuntu][10]
Click on Install Now, it may ask for your password.
![Installing Updates in Ubuntu Linux via GUI][11]
Once you enter your password, it will start installing the updates.
![Updating Ubuntu via GUI][12]
In some cases, you may need to reboot the system for the installed updates to work properly. Youll be notified at the end of the update if you need to restart the system.
![Updating Ubuntu via GUI][12]
You can choose to restart later if you dont want to reboot your system straightaway.
![Installing updates via GUI in Ubuntu][13]
Tip: If the software updater returns an error, you should use the command sudo apt update in the terminal. The last few lines of the output will contain the actual error message. You can search on the internet for that error and fix the problem.
2018-12-18 14:05:23 +08:00
### 更新 Ubuntu 时要记住几件事
2018-12-17 13:37:28 +08:00
You just learned how to update your Ubuntu system. If you are interested, you should also know these few things around Ubuntu updates.
2018-12-18 14:05:23 +08:00
#### 更新后清理
2018-12-17 13:37:28 +08:00
Your system will have some unnecessary packages that wont be required after the updates. You can remove such packages and [free up some space][14] using this command:
```
sudo apt autoremove
```
2018-12-18 14:05:23 +08:00
#### 在 Ubuntu Server 中热修复内核以避免重启
2018-12-17 13:37:28 +08:00
In case of a Linux kernel updates, youll have to restart the system after the update. This is an issue when you dont want downtime for your server.
[Live patching][15] feature allows the patching of Linux kernel while the kernel is still running. In other words, you dont have to reboot your system.
If you manage servers, you may want to [enable live patching in Ubuntu][16].
2018-12-18 14:05:23 +08:00
#### 版本升级是不同的
2018-12-17 13:37:28 +08:00
The updates discussed here is to keep your Ubuntu install fresh and updated. It doesnt cover the [version upgrades][17] (for example upgrading Ubuntu 16.04 to 18.04).
[Ubuntu version][18] upgrades are entirely a different thing. It updates the entire operating system core. You need to make proper backups before starting this lengthy process.
2018-12-18 14:05:23 +08:00
### 总结
2018-12-17 13:37:28 +08:00
I hope you liked this tutorial on updating the Ubuntu system and you learned a few new things.
If you have any questions, please fee free to ask. If you are an experienced Linux users and have some tip that can make this tutorial more useful, please share it with the rest of us.
--------------------------------------------------------------------------------
via: https://itsfoss.com/update-ubuntu/
作者:[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.ubuntu.com/
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/12/how-to-update-ubuntu.png?resize=800%2C450&ssl=1
[3]: https://itsfoss.com/ubuntu-shortcuts/
[4]: https://www.ubuntu.com/download/server
[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubunt-1.jpeg?resize=800%2C357&ssl=1
[6]: https://itsfoss.com/apt-get-linux-guide/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubunt-2.jpeg?ssl=1
[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-via-GUI-1.jpeg?resize=800%2C250&ssl=1
[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-via-GUI-2.jpeg?resize=800%2C250&ssl=1
[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/update-ubuntu-GUI-3.jpeg?resize=800%2C365&ssl=1
[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/install-update-ubuntu-1.jpg?resize=800%2C450&ssl=1
[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/12/installing-updates-ubuntu.jpg?ssl=1
[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/12/installing-updates-ubuntu-2.jpeg?ssl=1
[14]: https://itsfoss.com/free-up-space-ubuntu-linux/
[15]: https://www.ubuntu.com/livepatch
[16]: https://www.cyberciti.biz/faq/howto-live-patch-ubuntu-linux-server-kernel-without-rebooting/
[17]: https://itsfoss.com/upgrade-ubuntu-version/
[18]: https://itsfoss.com/how-to-know-ubuntu-unity-version/