mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-03-21 02:10:11 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
0bf24191e3
@ -0,0 +1,118 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11770-1.html)
|
||||
[#]: subject: (App Highlight: Open Source Disk Partitioning Tool GParted)
|
||||
[#]: via: (https://itsfoss.com/gparted/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
应用推荐:开源磁盘分区工具 GParted
|
||||
======
|
||||
|
||||

|
||||
|
||||
> GParted 是一个可用于 Linux 发行版的非常受欢迎且免费的分区编辑器。在这里,我们简要地介绍一下它提供的功能。
|
||||
|
||||
### GParted:一个自由开源的图形化分区管理器
|
||||
|
||||
![][1]
|
||||
|
||||
GParted 无疑是 [Linux 下的最好的分区管理器][2]之一。用户界面非常简单而可以完成任务。
|
||||
|
||||
在某些情况下,你最终还是会使用 [GParted][3] 来修复或格式化你的 USB 驱动器。我有一个[在 Ubuntu 中使用“磁盘”应用程序不能格式化的 USB 磁盘][4],而这是 GParted 用来救援的地方。
|
||||
|
||||
所以,它是一个非常有用的工具,有很多出色的功能。让我为你们重点介绍一下。
|
||||
|
||||
> 警告!
|
||||
>
|
||||
> 进行磁盘分区是一件危险的工作。除非绝对必要,否则不要做。否则,你可能最终擦除了整个磁盘。
|
||||
|
||||
### GParted 的功能
|
||||
|
||||
从简单地格式化任务到重要的分区任务,你可以使用 GParted 做很多事。我将使用一些屏幕截图突出关键功能,以帮助你在安装它前进一步了解它。
|
||||
|
||||
#### 创建分区表
|
||||
|
||||
你可以为新磁盘创建一个新的分区表,也可以擦除你现存的磁盘内容来修改分区表。
|
||||
|
||||
![][5]
|
||||
|
||||
你能够选择 msdos、gpt、atari,以及更多类型的分区表。
|
||||
|
||||
#### 创建、移动、标记、删除和修改分区表
|
||||
|
||||
你可以使用 GParted 中一系列选项来轻松地创建、标记、删除或修改分区表。
|
||||
|
||||
![][6]
|
||||
|
||||
当然,你必须要谨慎你要做的事情。
|
||||
|
||||
好的是,GParted 可以确保你不能直接应用任何更改 —— 在你点击应用更改之前,它将排队你选择的操作/任务,并在你执行前最后再要求确认一次。
|
||||
|
||||
顶部的对号标记符号 `✓` 可以让你确认更改,然后你的更改才会生效。
|
||||
|
||||
这是分区可用选项的另一个屏幕截图:
|
||||
|
||||
![][7]
|
||||
|
||||
#### 尝试数据救援
|
||||
|
||||
除了编辑分区以外,你也可以试着使用“尝试数据救援”功能以[在 Linux 中恢复丢失的数据][8],如下面的屏幕截图所示。
|
||||
|
||||
![][9]
|
||||
|
||||
值得注意的是,默认情况下你没有安装此功能 —— 你只是能看到这个选项。因此,要使这个数据恢复功能可以正常工作,你必须使用下面的命令来单独地安装 gpart (在基于 Ubuntu/Debian 的发行版上):
|
||||
|
||||
```
|
||||
sudo apt install gpart
|
||||
```
|
||||
|
||||
除了所有这些关键功能以外,它支持各种存储设备和文件系统。你可以从其官方网站的[功能列表][10]中了解到更多信息。
|
||||
|
||||
### 在 Ubuntu 和其它 Linux 发行版上安装 GParted
|
||||
|
||||
你可能已经预安装了 GParted 。所以,务必核实一下。如果你尚未安装它,则可以进入软件中心安装它。
|
||||
|
||||
如果你想使用终端,简单地键入下面的命令:
|
||||
|
||||
```
|
||||
sudo apt install gparted
|
||||
```
|
||||
|
||||
如上所述,如果你想要使用数据恢复选项,除了安装 gparted 软件包外,还应该安装 gpart 软件包。
|
||||
|
||||
如果你使用的是其它 Linux 发行版,你可以在各自的软件管理器中找到它,或者直接查看[官方下载操作说明][11]。
|
||||
|
||||
- [下载 GParted][11]
|
||||
|
||||
### 总结
|
||||
|
||||
当涉及处理磁盘管理和分区时,GParted 是一个非常有用且重要的工具。但是,因为显而易见的原因,当你使用它时,你必须要小心。
|
||||
|
||||
你尝试过 GParted 吗?你在 Linux 上使用的其它哪个分区工具?请在下面的评论中分享你的经验。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/gparted/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[robsean](https://github.com/robsean)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/ankush/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-screenshot.png?ssl=1
|
||||
[2]: https://itsfoss.com/partition-managers-linux/
|
||||
[3]: https://gparted.org/
|
||||
[4]: https://itsfoss.com/format-usb-drive-sd-card-ubuntu/
|
||||
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-create-partition-table.png?ssl=1
|
||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-modify-partitions.png?ssl=1
|
||||
[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-partition-options.png?ssl=1
|
||||
[8]: https://itsfoss.com/recover-deleted-files-linux/
|
||||
[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-attempt-data-rescue-feature.png?ssl=1
|
||||
[10]: https://gparted.org/features.php
|
||||
[11]: https://gparted.org/download.php
|
@ -1,32 +1,34 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11771-1.html)
|
||||
[#]: subject: (My Raspberry Pi retrospective: 6 projects and more)
|
||||
[#]: via: (https://opensource.com/article/20/1/raspberry-pi-best)
|
||||
[#]: author: (Anderson Silva https://opensource.com/users/ansilva)
|
||||
|
||||
我的树莓派回顾:不止 6 个项目
|
||||
我的树莓派项目回顾
|
||||
======
|
||||
看看我在有趣的、有教育意义和有用的树莓派上做了什么。
|
||||
![Raspberry Pi 4 board, posterized filter][1]
|
||||
|
||||
从历史和理论上讲,十年、一个世纪或一千年从十进制一那年的 1 月 1 日物业开始。例如,20 世纪始于 1901 年 1 月 1 日,而不是 1900 年 1 月 1 日。原因很简单:现代日历中没有 0 年,因此这些时间段始于 1 年(使用公历)。但这不是我们在口语上和文化上指代时间段的方式。例如,当我们提到 80 年代的音乐或电影时,我们所说的是 1980 年至 1989 年。
|
||||
> 看看我在好玩、能学习、有用处的树莓派上做了些什么。
|
||||
|
||||
我可以说,最近过去的 21 世纪 10 年代是云计算、社交媒体、移动技术和物联网 (IoT) 的十年,这其中包括[树莓派][2]。最近,《时代》杂志将树莓派称为[过去十年中 10 个最佳小玩意][3]之一。我非常同意这点。
|
||||

|
||||
|
||||
最初的树莓派于 2012 年推出,我过了几年才使用上了它。但是从那以后,我在家中做了许多有趣的教育项目,甚至在 Opensource.com 中记录了一些。
|
||||
无论是从历史上,还是从理论上讲,当时钟走到一个十年份第一年的 1 月 1 日的午夜 0 点时,就开始了一个十年或一个世纪或一个千年纪元。例如,20 世纪始于 1901 年 1 月 1 日,而不是 1900 年 1 月 1 日。原因很简单:现代日历中没有 0 年,因此这些时间段始于 1 年(使用公历)。但这不是我们在口语上和文化上指代时间段的方式。例如,当我们提到 80 年代的音乐或电影时,我们所说的是 1980 年至 1989 年。
|
||||
|
||||
我可以说,最近过去的 21 世纪 10 年代是云计算、社交媒体、移动技术和物联网(IoT)的十年,这其中就包括[树莓派][2]。最近,《时代》杂志将树莓派称为[过去十年中 10 个最佳小玩意][3]之一。我非常同意这点。
|
||||
|
||||
树莓派最初的于 2012 年推出,我过了几年才使用上了它。不过从那以后,我在家中做了许多有趣的教育项目,还在 Opensource.com 中记录了一些。
|
||||
|
||||
### 圣诞灯三部曲
|
||||
|
||||
三年来,我写了三篇探讨如何使用树莓派和开源项目 LightShowPi 控制圣诞灯的文章。第一篇文章[_用树莓派创建你自己的音乐灯光秀_][4],是基础电子开发介绍和灯光秀的结合。第二篇文章,[_ 使用树莓派 SSH 进入你的圣诞树_][5],更深入地介绍了通过远程管理和电子按钮控制灯光的方法。三部曲的最后一章[_用树莓派设置假期心情_][6],回顾了上一年 LightShowPi 项目中引入的更改。
|
||||
三年来,我写了三篇探讨如何使用树莓派和开源项目 LightShowPi 控制圣诞灯的文章。第一篇文章《[用树莓派创建你自己的音乐灯光秀][4]》,非常基础地介绍了电子开发介绍和灯光秀的结合。第二篇文章,《[使用树莓派 SSH 进入你的圣诞树][5]》,稍微深入地介绍了通过远程管理和电子按钮控制灯光的方法。三部曲的最后一章《[用树莓派设置假期心情][6]》,回顾了上一年 LightShowPi 项目中引入的更改。
|
||||
|
||||
### DIY 项目
|
||||
|
||||
多年来,我已经将树莓派变成了几种有用的设备。有一次,我将树莓派变成了[带有 Pi MusicBox 的音乐播放设备][7],它可以让你在 Web 界面中导入你喜欢的音乐流并在房间中播放。
|
||||
多年来,我已经将树莓派变成了几种有用的设备。有一次,我将树莓派变成了 [Pi MusicBox 音乐播放设备][7],它可以让你在 Web 界面中导入你喜欢的音乐流并在房间中播放。
|
||||
|
||||
将树莓派做成[移动视频录制设备][8]是另一个 DIY 项目。它需要一些额外的硬件,例如触摸屏、Pi 摄像头和电池组,但是可以使用。这个设备的最大缺点之一是当时树莓派的可用内存很小。我认为如果我将它重新配置在具有 4GB 内存的树莓派 4 上,那么这款便携式摄像机的功能可能会更好。这可能是一个会在 2020 年重新做项目。
|
||||
将树莓派做成[移动视频录制设备][8]是另一个 DIY 项目。它需要一些额外的硬件,例如触摸屏、树莓派摄像头和电池组,但是它工作的很好。这个设备的最大缺点之一是当时树莓派的可用内存很小。我认为如果我将它重新配置在具有 4GB 内存的树莓派 4 上,那么这款便携式摄像机的功能可能会更好。这可能是一个会在 2020 年重新打造的项目。
|
||||
|
||||
我做的另一个小项目[客厅的数字时钟][9]使用了 Adafruit PiTFT 小屏幕。尽管这个项目很简单,但它可能是我使用时间最长的项目。那个时钟在我的电视机上呆了一年多,一天 24 小时不间断运行,直到屏幕烧坏为止。
|
||||
|
||||
@ -36,7 +38,7 @@
|
||||
|
||||
### 走向未来
|
||||
|
||||
我在树莓派基金会中不认识任何人,因此我不了解任何它的路线图和未来计划。我可以(但我不会)推测品牌及其设备的未来,它们让世界各地这么多不同社会地位的人扩展他们对计算机科学、电子和开源开发的知识。我希望基金会的管理层能够忠于其愿景和使命,并继续为世界各地的人们提供价格合理的技术。
|
||||
我不认识树莓派基金会中的任何人,因此我不了解它的任何路线图和未来计划。我可以(但我不会)推测品牌及其设备的未来,它们让世界各地这么多不同社会地位的人扩展他们对计算机科学、电子和开源开发的知识。我希望基金会的管理层能够忠于其愿景和使命,并继续为世界各地的人们提供价格合理的技术。
|
||||
|
||||
21 世纪 10 年代过去了,那是多么甜蜜的十年。对我来说,它闻起来就像树莓派馅饼。
|
||||
|
||||
@ -47,7 +49,7 @@ via: https://opensource.com/article/20/1/raspberry-pi-best
|
||||
作者:[Anderson Silva][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/) 荣誉推出
|
||||
|
@ -0,0 +1,82 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Don’t Use ZFS on Linux: Linus Torvalds)
|
||||
[#]: via: (https://itsfoss.com/linus-torvalds-zfs/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
|
||||
Don’t Use ZFS on Linux: Linus Torvalds
|
||||
======
|
||||
|
||||
_“Don’t use ZFS. It’s that simple. It was always more of a buzzword than anything else, I feel, and the licensing issues just make it a non-starter for me.”_
|
||||
|
||||
This is what Linus Torvalds [said in a mailing list][1] to once again express his disliking for [ZFS filesystem][2] specially over its licensing.
|
||||
|
||||
To avoid unnecessary confusion, this is more intended for Linux distributions, kernel developers and maintainers rather than individual Linux users.
|
||||
|
||||
### What’s the licensing issue with ZFS and Linux kernel?
|
||||
|
||||
![][3]
|
||||
|
||||
ZFS was open sourced around 2003. This would have meant that Linux distributions start supporting ZFS. But that didn’t really happen because of the complexity of [open source licenses][4].
|
||||
|
||||
ZFS is open source under [Common Development and Distribution License][5] (CDDL) 1.0 whereas Linux kernel is licensed under the GNU General Public License (GPL) 2.0.
|
||||
|
||||
These two open source licenses are not fully compatible with each other. As noted by [PCWorld][6], if ZFS with this license is included in the Linux kernel, this would mean that kernel+ZFS is a derivative work of the (original ZFS-less) Linux kernel.
|
||||
|
||||
### Torvalds doesn’t trust Oracle
|
||||
|
||||
![][7]
|
||||
|
||||
While the whole derivative thing is a matter of debate for legal and licensing experts, Torvalds is skeptical of Oracle. Oracle has a history of suing enterprises for using its code. Remember [Oracle vs Android lawsuit over the use of Java][8]?
|
||||
|
||||
> Other people think it can be ok to merge ZFS code into the kernel and that the module interface makes it ok, and that’s their decision. But considering Oracle’s litigious nature, and the questions over licensing, there’s no way I can feel safe in ever doing so.
|
||||
>
|
||||
> And I’m not at all interested in some “ZFS shim layer” thing either that some people seem to think would isolate the two projects. That adds no value to our side, and given Oracle’s interface copyright suits (see Java), I don’t think it’s any real licensing win either.
|
||||
|
||||
Torvalds doesn’t want Linux kernel to get into legal troubles with Oracle in future and hence he refuses to include ZFS in mainline kernel until Orcale provides a signed letter that a kernel with ZFS will be under GPL license.
|
||||
|
||||
> And honestly, there is no way I can merge any of the ZFS efforts until I get an official letter from Oracle that is signed by their main legal counsel or preferably by Larry Ellison himself that says that yes, it’s ok to do so and treat the end result as GPL’d.
|
||||
|
||||
He is not stopping other (distributions) from using ZFS. But they are on their own.
|
||||
|
||||
> If somebody adds a kernel module like ZFS, they are on their own. I can’t maintain it, and I can not be bound by other peoples kernel changes.
|
||||
|
||||
Canonical, Ubuntu’s parent company, has been too keen on ZFS. Their [legal department thinks that including ZFS in kernel doesn’t make it a derivative work][9]. So they took their chances and now they provide an option to [use ZFS on root from Ubuntu 19.10][10].
|
||||
|
||||
### Torvalds is also not impressed with ZFS in general
|
||||
|
||||
![][11]
|
||||
|
||||
While some people drool over ZFS, Linus Torvalds is not that impressed with ZFS. He doesn’t think it’s using ZFS is a good idea specially when it is not actively maintained by Oracle (after they open sourced it)
|
||||
|
||||
> The benchmarks I’ve seen do not make ZFS look all that great. And as far as I can tell, it has no real maintenance behind it either any more, so from a long-term stability standpoint, why would you ever want to use it in the first place?
|
||||
|
||||
I am no legal expert but if there is even a slightest doubt, I would prefer staying away from ZFS. What do you think of the whole ZFS debate?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/linus-torvalds-zfs/
|
||||
|
||||
作者:[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.realworldtech.com/forum/?threadid=189711&curpostid=189841
|
||||
[2]: https://itsfoss.com/what-is-zfs/
|
||||
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/dont_use_zfs_torvalds.jpg?ssl=1
|
||||
[4]: https://itsfoss.com/open-source-licenses-explained/
|
||||
[5]: https://opensource.org/licenses/CDDL-1.0
|
||||
[6]: https://www.pcworld.com/article/3061924/ubuntu-1604s-support-for-the-zfs-file-system-may-violate-the-general-public-license.html
|
||||
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/linus-torvalds-zfs-quotes-1.jpg?ssl=1
|
||||
[8]: https://itsfoss.com/oracle-google-dispute/
|
||||
[9]: https://ubuntu.com/blog/zfs-licensing-and-linux
|
||||
[10]: https://itsfoss.com/zfs-ubuntu/
|
||||
[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/linus-torvalds-zfs-quotes-2.jpg?ssl=1
|
@ -1,120 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (chen-ni)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Explained! Why Your Distribution Still Using an ‘Outdated’ Linux Kernel?)
|
||||
[#]: via: (https://itsfoss.com/why-distros-use-old-kernel/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
|
||||
Explained! Why Your Distribution Still Using an ‘Outdated’ Linux Kernel?
|
||||
======
|
||||
|
||||
[Check your Linux kernel version][1]. Chances are that you’ll find that the kernel version your system is using has already reached end of life (EOL) as listed on Linux Kernel website.
|
||||
|
||||
End of life means a software won’t get bug fixes and support anymore.
|
||||
|
||||
That poses some valid questions. Why is my Linux distribution using a kernel that has reached end of life? Is this not a security risk? Is my system safe?
|
||||
|
||||
Let me explain all these questions in this article.
|
||||
|
||||
Summary
|
||||
|
||||
The upstream kernel support and the your distribution’s kernel support are two different things.
|
||||
|
||||
For example, Linux kernel 4.15 might have reached end of life (as per the official Linux kernel website) but Ubuntu 18.04 LTS release will use it and maintain it till April 2023 by backporting security patches and bug fixes.
|
||||
|
||||
### Checking Linux kernel version and finding its end of life status
|
||||
|
||||
Let’s first check the Linux kernel version on your system:
|
||||
|
||||
```
|
||||
uname -r
|
||||
```
|
||||
|
||||
I am using Ubuntu 18.04 here and it shows the Linux kernel version like this:
|
||||
|
||||
```
|
||||
[email protected]:~$ uname -r
|
||||
5.0.0-37-generic
|
||||
```
|
||||
|
||||
Now, you may go to the official Linux kernel website and see what Linux kernels are still being supported. It’s displayed on the homepage itself.
|
||||
|
||||
[Linux Kernel Official Website][2]
|
||||
|
||||
You should see a status like this:
|
||||
|
||||
![Linux Kernel Status][3]
|
||||
|
||||
If you don’t see a kernel version listed on the homepage of kernel website, it means that specific version has reached end of life.
|
||||
|
||||
As you can see, kernel 5.0 is not listed here. It indicates that this kernel version is not being supported anymore. Actually, it [reached end of life in June 2019][4].
|
||||
|
||||
The life cycle of a Linux kernel doesn’t follow a set pattern, unfortunately. It’s NOT like a regular kernel stable release will be supported for X months and a long term support(LTS) kernel will be supported for Y years.
|
||||
|
||||
Based on the demand and requirements, there could be several LTS kernel versions with different EOL. You can find them along with their projected EOL on [this page][5].
|
||||
|
||||
Now comes the big question. Why is Ubuntu providing kernel 5.0 if the Linux kernel website shows that it has reached its end of life?
|
||||
|
||||
### Your distribution uses an EOL Linux kernel but that’s Okay!
|
||||
|
||||
![][6]
|
||||
|
||||
Have you ever wondered why Ubuntu/Debian/Fedora etc are called Linux distributions? It’s because they ‘distribute’ the Linux kernel.
|
||||
|
||||
They have their own modification of the Linux kernel, they add the GUI elements (desktop environment, display server etc) and software and they make it available to their users.
|
||||
|
||||
In the typical workflow, a Linux distribution will choose a kernel to provide to its users. And then it will hold on to this kernel for months or years even after the kernel has reached end of life.
|
||||
|
||||
How is it safe then? It’s because the _**distribution maintains the kernel by backporting all the important fixes to its kernel**_.
|
||||
|
||||
In other words, your Linux distribution makes sure that your Linux kernel is patched well and has all the bug fixes and important new features backported to it. There will be thousands of changes on top of the ‘old outdated Linux kernel’.
|
||||
|
||||
When the Linux kernel website says that a certain kernel version has reached EOL, it means that the core Linux kernel maintainers are not going to update/patch that kernel version anymore.
|
||||
|
||||
But at the same time, the developers at Debian/Ubuntu or other distributions work to keep the same old version alive by bringing the relevant changes from the newer kernel versions (being maintained by the core kernel team) to your distribution’s old kernel.
|
||||
|
||||
Bottom line is that even if it seems like your distribution is using an outdated Linux kernel, it is actually being well maintained and not really outdated.
|
||||
|
||||
### Should you use the latest stable kernel version?
|
||||
|
||||
![][7]
|
||||
|
||||
A new stable Linux kernel version is released every 2-3 months. And this makes many users wonder who they can get their hands on that new shiny thing.
|
||||
|
||||
To be frank, you should not do that unless you have a pretty good reason for it. Your distribution doesn’t provide it to you. You cannot just use ‘_sudo apt give-me-the-latest-stable-kernel_‘.
|
||||
|
||||
Now, manually [installing the mainline Linux kernel version][8] could be a challenge in itself. Even if you manage to install it, it is now up to you to make sure that this kernel is updated every time there is a bug fix. And when this new kernel reaches end of life, it becomes your responsibility to upgrade to the newer kernel version. It won’t be handled with apt upgrade like regular [Ubuntu updates][9].
|
||||
|
||||
You should also keep in mind that your distribution also has drivers and patches which you may not be able to use if you switch to the mainline kernel.
|
||||
|
||||
As [Greg Kroah-Hartman][10] puts it, “_**the best kernel you can use is one that someone else supports**_“. And who can be better at this job then your Linux distribution!
|
||||
|
||||
I hope you have a better understanding on this topic and you won’t panic the next time you find out that the kernel version your system is using has reached end of life.
|
||||
|
||||
I welcome your questions and suggestions. Please feel free to use the comment section.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/why-distros-use-old-kernel/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[chen-ni](https://github.com/chen-ni)
|
||||
校对:[校对者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://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/
|
||||
[2]: https://www.kernel.org/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/linux-kernel-status.jpg?ssl=1
|
||||
[4]: http://lkml.iu.edu/hypermail/linux/kernel/1906.0/02354.html
|
||||
[5]: https://www.kernel.org/category/releases.html
|
||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/Keep_Calm_and_Trust_Your_Distribution.png?ssl=1
|
||||
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/using_latest_kernel.png?ssl=1
|
||||
[8]: https://wiki.ubuntu.com/Kernel/MainlineBuilds
|
||||
[9]: https://itsfoss.com/update-ubuntu/
|
||||
[10]: https://en.wikipedia.org/wiki/Greg_Kroah-Hartman
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
105
sources/tech/20200110 5 ops hacks for sysadmins.md
Normal file
105
sources/tech/20200110 5 ops hacks for sysadmins.md
Normal file
@ -0,0 +1,105 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (5 ops hacks for sysadmins)
|
||||
[#]: via: (https://opensource.com/article/20/1/ops-hacks-sysadmins)
|
||||
[#]: author: (Stephen Bancroft https://opensource.com/users/stevereaver)
|
||||
|
||||
5 ops hacks for sysadmins
|
||||
======
|
||||
Five tools to help you find the source of your users' IT problems when
|
||||
you don't know where to start.
|
||||
![Wratchet set tools][1]
|
||||
|
||||
As a sysadmin, every day I am faced with problems I need to solve quickly because there are users and managers who expect things to run smoothly. In a large environment like the one I manage, it's nearly impossible to know all of the systems and products from end to end, so I have to use creative techniques to find the source of the problems and (hopefully) come up with solutions.
|
||||
|
||||
This has been my daily experience for well over 20 years, and I love it! Coming to work each day, I never quite know what will happen. So, I have a few quick and dirty tricks that I default to when a problem lands on my lap, but I don't know where to start.
|
||||
|
||||
_BUT WAIT!_ Before you jump straight onto the command line, spend some time talking to your users. Yes, it can be tedious, but they will have some good information for you. Keep in mind that users probably don't have as much experience as you have, and you will need to do some interpreting of whatever they say. Try to get a clear picture of what _is_ happening and what _should be_ happening, then describe the fault to yourself in technical language. Be aware that most users don't read what is on the screen in front of them; it's sad but true. Make sure you and the user are reading all of the text to gather as much information as possible. Once you have that together, jump onto the command line with these five tools.
|
||||
|
||||
### Telnet
|
||||
|
||||
I am starting with a classic. [Telnet][2] was the predecessor to SSH, and, in the olden days, it was used on Unix systems to connect to a remote terminal just like SSH does, but it was not encrypted. Telnet has a very neat and invaluable trick for diagnosing network connectivity issues: you can Telnet into TCP ports that are not reserved for it. To do so, use Telnet like you normally would, but add the TCP port onto the end (**telnet localhost 80,** for instance) to connect to a web server. This enables you to check a server to see if a service is running or if a firewall is blocking it. So, without having the application client or even a login for the application, you can check if the TCP port is responding. If you know how, sometimes you can elicit a response from the server by manually typing into the Telnet prompt and checking the response. Web servers and mail servers are two examples where you can do this.
|
||||
|
||||
![Getting a response from a webserver with Telnet][3]
|
||||
|
||||
### Tcpdump
|
||||
|
||||
The [tcpdump][4] tool lets you inspect what data is being transmitted on the network. Most network protocols are fairly simple and, if you combine tcpdump with a tool like [Wireshark][5], you will have a nice, easy way to browse the traffic that you have captured. In the example below, I am inspecting packets in the bottom window and connecting to TCP port 3260 in the top.
|
||||
|
||||
![Inspecting packets in real time with tcpdump][6]
|
||||
|
||||
This screenshot shows a real-world use of Wireshark to look at the iSCSI protocol; in this case, I was able to identify that there was a problem with the way our QNAP network-attached storage was configured.
|
||||
|
||||
![Using Wireshark to inspect a TCP session][7]
|
||||
|
||||
### find
|
||||
|
||||
The [find][8] command is simply the best tool if you don't know where to start. In its most simple form, you can use it to "find" files. For example, if I wanted to do a recursive search through all directories and get a list of the conf files, I could enter:
|
||||
|
||||
|
||||
```
|
||||
`find . -name '*.conf'.`
|
||||
```
|
||||
|
||||
![find command output][9]
|
||||
|
||||
But one of find's hidden gems is that you can use it to execute a command against each item it finds. For example, if I wanted to get a long list of each file, I could enter:
|
||||
|
||||
|
||||
```
|
||||
`find . -name '*.conf' -exec ls -las {} \;`
|
||||
```
|
||||
|
||||
![find command output][10]
|
||||
|
||||
Once you know this technique, you can use it in all sorts of creative ways to find, search, and execute programs in specific ways.
|
||||
|
||||
### strace
|
||||
|
||||
I was introduced to the concept of [strace][11] on Solaris, where it is called truss. It is still as useful today as it was all those years ago. strace allows you to inspect what a process is doing as it runs in real time. Using it is simple; just use the command **ps -ef** and find the process ID that you are interested in. Start strace with **strace -p <pid>**; this will start printing out a whole lot of stuff, which at first looks like junk. But if you look closer, you will see text that you recognize, such as words like **OPEN** and **CLOSE** and filenames. This can lead you in the right direction if you are trying to figure out why a program is not working.
|
||||
|
||||
### grep
|
||||
|
||||
Leaving the best for last: [grep][12]. This tool is so useful and powerful that I have trouble coming up with a succinct way to describe it. Put simply, it's a search tool, but the way it searches is what makes it so powerful. In problem analysis, I typically grep over a bunch of logs to search for something. A companion command called zgrep does the same thing with zipped files. In the following example, I used **zgrep /var/log/* bancroft** to grep across all the log files to see what I have been up to on the system. I used zgrep because there are zipped files in the directory.
|
||||
|
||||
![grep command output][13]
|
||||
|
||||
Another great way to use grep is for piping the output of other tools into it; this way, it can be used as a filter of sorts. In the following example, I listed the auth file and grepped for my login to see what I have been doing by using **cat auth.log |grep bancroft**. This can also be written as **grep bancroft auth.log**, but I used the pipe (**|**) to demonstrate the point.
|
||||
|
||||
![grep command output][14]
|
||||
|
||||
### Other tools to consider
|
||||
|
||||
You can do a lot more with these tools, but I hope this brief introduction gives you a window into how to use them to solve the nasty problems that come your way. Another tool worth your attention is [Nmap][15], which I did not include because it is so comprehensive that it needs an entire article (or more) to explain it. Finally, I recommend learning some white hat and hacking techniques; they can be very beneficial when trying to get to the bottom of a problem because they can help you collect information that can be crucial in decision making.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/1/ops-hacks-sysadmins
|
||||
|
||||
作者:[Stephen Bancroft][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://opensource.com/users/stevereaver
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4 (Wratchet set tools)
|
||||
[2]: https://en.wikipedia.org/wiki/Telnet
|
||||
[3]: https://opensource.com/sites/default/files/uploads/telnet_1.png (Getting a response from a webserver with Telnet)
|
||||
[4]: https://www.tcpdump.org/
|
||||
[5]: https://www.wireshark.org/
|
||||
[6]: https://opensource.com/sites/default/files/uploads/tcpdump_1.png (Inspecting packets in real time with tcpdump)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/tcpdump_2.png (Using Wireshark to inspect a TCP session)
|
||||
[8]: https://en.wikipedia.org/wiki/Find_%28Unix%29
|
||||
[9]: https://opensource.com/sites/default/files/uploads/find_1_0.png (find command output)
|
||||
[10]: https://opensource.com/sites/default/files/uploads/find_2.png (find command output)
|
||||
[11]: https://strace.io/
|
||||
[12]: https://en.wikipedia.org/wiki/Grep
|
||||
[13]: https://opensource.com/sites/default/files/uploads/grep_1.png (grep command output)
|
||||
[14]: https://opensource.com/sites/default/files/uploads/grep_2.png (grep command output)
|
||||
[15]: https://nmap.org/
|
@ -0,0 +1,237 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How I upgraded my CuBox open source music server)
|
||||
[#]: via: (https://opensource.com/article/20/1/upgrade-cubox-open-source-music-server)
|
||||
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen)
|
||||
|
||||
How I upgraded my CuBox open source music server
|
||||
======
|
||||
Our resident audiophile explains how he updated his CuBox music server
|
||||
after more than five years of excellent use.
|
||||
![open source music with piano keys background][1]
|
||||
|
||||
Back in early 2014, I purchased my first [ARM-based computer][2], a [SolidRun CuBox-i4][3]. My goal for the CuBox was to have a headless device (e.g., no display) that takes up minimal space in the audio equipment shelf, makes minimal noise, and serves music files to my digital-to-analog converter (DAC) and thus to the rest of the stereo. On paper, the CuBox was a perfect fit. It is fanless, works with various Linux distros, provides a separate [eSATA interface][4] for a locally mounted hard drive and therefore leaves the USB ports free for other stuff, provides a [TOSLINK port][5] for digital audio, uses a [MicroSD card][6] (by default, anyway) for the system installation and boot drive, and comes with 2GB of RAM and a reasonably fast [i.MX6q quad-core processor][7], all in an unobtrusive 5x5x5cm black plastic box.
|
||||
|
||||
And as luck would (sometimes) have it, those promises have mostly been kept. The box still runs and provides my family with a great deal of musical enjoyment. The attached hard drive contains about 275GB of music files—a bit over 7,500 FLAC files with some 300 or so MP3 files thrown in.
|
||||
|
||||
As our home music server, the CuBox runs a barebones Linux server distro with Music Player Daemon ([MPD][8]) as the music-serving software, sending digital data to the DAC via the [ALSA][9] with no software mixing, up- or down-sampling, or volume control on the server. Lately, I've found it convenient to run [lighttpd][10], a lightweight, simple-to-configure HTTP server, to provide cover images to the various MPD clients that we run in the house. (But now MPD provides that capability, so that convenience may soon go away.) For the user interfaces to play music, we use [Cantata][11] on the desktop and [MPD Remote][12] (caution: it may not be open source) on our Android phones to browse, select, and play music.
|
||||
|
||||
In 2017, I wrote about [my experiences using the CuBox][13]. I had tried [Voyage Linux][14], [Volumio][15], and [Archphile Linux][16], and had just moved to [Armbian][17], which at that time was based on Ubuntu 16.04 LTS (long term support). This fall, I decided it was time to upgrade the server, get the latest version of MPD, and deal with a few other bothersome details along the way.
|
||||
|
||||
### The upgrade
|
||||
|
||||
Given my generally great experience with Armbian, I decided to go there again for upgrade materials. There are two supported options: a Debian Buster-based server configuration and an Ubuntu 18.04 desktop configuration. Bearing in mind my desire to keep the system display-free and minimalist, I selected the Debian version.
|
||||
|
||||
![Armbian versions][18]
|
||||
|
||||
The download was trouble-free, and I soon had an install image in my Downloads folder. As before, I was impressed with the quality and "to the point" nature of the [Armbian documentation][19], which notes:
|
||||
|
||||
> Images shall only be written with Etcher on all platforms since, unlike other tools, Etcher validates burning results **saving you from corrupted SD card contents**.
|
||||
|
||||
This was my first experience using [Etcher][20], and I was duly impressed with its usability (yet another wonderful reason to use open source software). I inserted the resulting MicroSD card into the CuBox, connected the Ethernet cable, DAC, and eSATA drive, and powered it on. Soon, I could SSH into the CuBox to configure it. Talk about a painless experience! Here's what I see when I log into that machine using SSH:
|
||||
|
||||
![CuBox login][21]
|
||||
|
||||
In terms of configuration, I had the following objectives:
|
||||
|
||||
* Finish the initial configuration
|
||||
* Configure static IP addressing for the wired networking connection
|
||||
* Get the installed system up to date
|
||||
* Disable the wireless
|
||||
* Install and configure MPD
|
||||
* Install and configure lighttpd
|
||||
* Listen to some music!
|
||||
|
||||
|
||||
|
||||
I used the excellent [Armbian Config program][22] to carry out a bunch of these initial configuration tasks.
|
||||
|
||||
![Armbian-Config screen][23]
|
||||
|
||||
Choosing System presents this menu:
|
||||
|
||||
![Armbian-Config settings][24]
|
||||
|
||||
I used this to disable root login over SSH and enable password and public key authentication.
|
||||
|
||||
In the Network subsystem, I set static IP addressing (to conform to my home router settings), and in the Personal subsystem, I changed the time zone and hostname. I probably could have used the Software subsystem to run the initial update, but I chose to exit to the shell and use apt to finish up this initial configuration with:
|
||||
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
sudo apt upgrade
|
||||
```
|
||||
|
||||
I also used apt to install MPD and lighttpd with:
|
||||
|
||||
|
||||
```
|
||||
`sudo apt install mpd lighttpd`
|
||||
```
|
||||
|
||||
I had my previous MPD configuration file (**/etc/mpd.conf**); generally, I prefer to use these types of older files as guides to configure a new one, rather than just plunking the old one on top of the new. In the end, there weren't many changes to make; here are the differences between the old and new files:
|
||||
|
||||
|
||||
```
|
||||
clh@stereo:/etc$ diff mpd.conf.orig mpd.conf
|
||||
85c85,86
|
||||
< bind_to_address "localhost"
|
||||
\---
|
||||
> #bind_to_address "localhost"
|
||||
> bind_to_address "192.168.1.21"
|
||||
241c242,249
|
||||
< name "My ALSA Device"
|
||||
\---
|
||||
> name "Drop Airist R2R"
|
||||
> device "hw:CARD=U20,DEV=0"
|
||||
> mixer_type "none"
|
||||
> replay_gain_handler "none"
|
||||
> # name "Schit Bifrost 4490"
|
||||
> # device "hw:CARD=S2,DEV=0"
|
||||
> # mixer_type "none"
|
||||
> # replay_gain_handler "none"
|
||||
clh@stereo:/etc$
|
||||
```
|
||||
|
||||
You can see that I have two DACs (just because), and the second is commented out (and not connected). Also, I had to change **bind_to_address** so that MPD will listen over the local area network.
|
||||
|
||||
As for lighttpd, I only had to change the **document-root**:
|
||||
|
||||
|
||||
```
|
||||
clh@stereo:/etc/lighttpd$ diff lighttpd.conf.orig lighttpd.conf
|
||||
8c8,13
|
||||
< server.document-root = "/var/www/html"
|
||||
\---
|
||||
> # Used this config documentation
|
||||
> #<https://github.com/abarisain/dmix/wiki/Album-Art-on-your-LAN>
|
||||
> # which wasn't good - wrong user name, didn't need to add
|
||||
> # the mime config
|
||||
> # in the end just changed the document root.
|
||||
>
|
||||
> server.document-root = "/var/lib/mpd/music/"
|
||||
clh@stereo:/etc/lighttpd$
|
||||
```
|
||||
|
||||
To get to the music files, I added the following line to **/etc/fstab**:
|
||||
|
||||
|
||||
```
|
||||
`/dev/sda1 /mnt/eSATA ext4 rw 0 0`
|
||||
```
|
||||
|
||||
and created the mount point with:
|
||||
|
||||
|
||||
```
|
||||
`sudo mkdir /mnt/eSATA`
|
||||
```
|
||||
|
||||
At this point, I mounted the external hard drive with:
|
||||
|
||||
|
||||
```
|
||||
`sudo mount /dev/sda1`
|
||||
```
|
||||
|
||||
Finally, I linked MPD's configuration directory to the music with:
|
||||
|
||||
|
||||
```
|
||||
sudo rmdir /var/lib/mpd/music
|
||||
sudo ln -s /mnt/eSATA/Music /var/lib/mpd/music
|
||||
```
|
||||
|
||||
I used this approach because I'd rather not futz around with MPD's configuration more than I have to.
|
||||
|
||||
It's a good idea to check that the music files are owned by the correct MPD user ID. Do this with:
|
||||
|
||||
|
||||
```
|
||||
clh@stereo:~$ ls -ld /var/lib/mpd/music/* | head
|
||||
drwxrwxrwx 5 mpd audio 4096 Jan 22 2017 /var/lib/mpd/music/Academy of St. Martin-in-the-Fields
|
||||
drwxrwxrwx 3 mpd audio 4096 Jan 22 2017 /var/lib/mpd/music/Acantus
|
||||
drwxrwxrwx 3 mpd audio 4096 Dec 13 2014 /var/lib/mpd/music/Afrikan_Sciences
|
||||
drwxrwxrwx 5 mpd audio 4096 Sep 25 2016 /var/lib/mpd/music/Afro Celt Sound System
|
||||
drwxrwxrwx 3 mpd audio 4096 Mar 11 2014 /var/lib/mpd/music/Agnes Obel
|
||||
drwxrwxrwx 3 mpd audio 4096 Oct 9 2013 /var/lib/mpd/music/Alexander Malter, Dietmar Schwalke, Vladimir Spiakov, Sergej Bezrodny
|
||||
drwxrwxrwx 3 mpd audio 4096 Oct 8 2013 /var/lib/mpd/music/Ali Farka Toure & Toumani Diabate
|
||||
drwxrwxrwx 3 mpd audio 4096 Oct 8 2013 /var/lib/mpd/music/Ali Farka Touré with Ry Cooder
|
||||
drwxrwxrwx 5 mpd audio 4096 Jan 1 2018 /var/lib/mpd/music/Amadou et Mariam
|
||||
drwxrwxrwx 3 mpd audio 4096 Jul 11 2017 /var/lib/mpd/music/American Authors
|
||||
clh@stereo:~$
|
||||
```
|
||||
|
||||
This looks fine (user ID **mpd**, group ID **audio**).
|
||||
|
||||
Finally, to disable the wireless, I entered:
|
||||
|
||||
|
||||
```
|
||||
`sudo nmcli radio wifi off`
|
||||
```
|
||||
|
||||
And I'm done! Time for a reboot:
|
||||
|
||||
|
||||
```
|
||||
`sudo systemctl reboot`
|
||||
```
|
||||
|
||||
Once it rebooted, I used Cantata to force MPD to refresh its database. Here's what it looks like when that's done, and I'm listening to [Frameworks' latest album, _Imagine Gold_][25]:
|
||||
|
||||
![Frameworks "Imagine Gold" in Cantata][26]
|
||||
|
||||
Just to the left of the track listings, you can see the cover images that lighttpd serves.
|
||||
|
||||
### And speaking of music
|
||||
|
||||
I really do like Frameworks' latest album. It's quite similar to his previous work, and he always has the greatest hooks with very dance-able stuff and just that great bit of "yearning." It's nice to buy his stuff on Bandcamp, as usual (see link above, where you can also listen).
|
||||
|
||||
Lately, I've also been buying stuff in that other great open source format, vinyl records. In particular, two fine recent albums from the [Erased Tapes][27] label, [Anne Müller's _Heliopause_][28], which is a beautiful record of her own solo cello and supporting instruments and sounds, "focusing on novel approaches to classical instrumentation," and [Penguin Cafe's _Handfuls of Night_][29], which "began life after Greenpeace commissioned [Arthur] Jeffes [of Penguin Cafe] to write four pieces of music corresponding to four breeds of penguins to help raise awareness for the endangered Antarctic seas." How could a Linux user not have music about penguins by Penguin Cafe?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/20/1/upgrade-cubox-open-source-music-server
|
||||
|
||||
作者:[Chris Hermansen][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://opensource.com/users/clhermansen
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_LIFE_music_520x292_0411_ma.png?itok=v_ARy1ZT (open source music with piano keys background)
|
||||
[2]: https://en.wikipedia.org/wiki/ARM_architecture
|
||||
[3]: https://www.solid-run.com/nxp-family/cubox-i/
|
||||
[4]: https://en.wikipedia.org/wiki/Serial_ATA
|
||||
[5]: https://en.wikipedia.org/wiki/TOSLINK
|
||||
[6]: https://www.makeuseof.com/tag/5-mistakes-avoid-buying-next-microsd-card/
|
||||
[7]: https://www.nxp.com/products/processors-and-microcontrollers/arm-processors/i.mx-applications-processors/i.mx-6-processors/i.mx-6quad-processors-high-performance-3d-graphics-hd-video-arm-cortex-a9-core:i.MX6Q?&cid=ps_PRG100148_CAM262037_EETECH&gclid=CjwKCAiA27LvBRB0EiwAPc8XWfLpyKIpi4OPNrPLdmXpSynIaDP0FG2jQ9PPZ1q49ENp1CbQU2fKxxoCKtMQAvD_BwE
|
||||
[8]: https://www.musicpd.org/
|
||||
[9]: https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture
|
||||
[10]: https://www.lighttpd.net/
|
||||
[11]: https://opensource.com/article/17/8/cantata-music-linux
|
||||
[12]: https://play.google.com/store/apps/details?id=net.prezz.mpr&hl=en_CA
|
||||
[13]: https://opensource.com/article/17/6/armbian-cubox-i4pro
|
||||
[14]: https://wiki.debian.org/Derivatives/Census/VoyageLinux
|
||||
[15]: https://volumio.org/
|
||||
[16]: https://archphile.org/
|
||||
[17]: https://www.armbian.com/
|
||||
[18]: https://opensource.com/sites/default/files/uploads/armbianversions.png (Armbian versions)
|
||||
[19]: https://docs.armbian.com/
|
||||
[20]: https://www.etcher.io/
|
||||
[21]: https://opensource.com/sites/default/files/uploads/cuboxlogin.png (CuBox login)
|
||||
[22]: https://docs.armbian.com/User-Guide_Armbian-Config/
|
||||
[23]: https://opensource.com/sites/default/files/uploads/armbian-config.png (Armbian-config screen)
|
||||
[24]: https://opensource.com/sites/default/files/uploads/armbian-config_settings.png (Armbian-config settings)
|
||||
[25]: https://frameworksuk.bandcamp.com/album/imagine-gold
|
||||
[26]: https://opensource.com/sites/default/files/uploads/frameworks-imaginegold.png (Frameworks "Imagine Gold" in Cantata)
|
||||
[27]: https://www.erasedtapes.com/
|
||||
[28]: https://www.erasedtapes.com/release/eratp128-anne-mueller-heliopause
|
||||
[29]: https://www.erasedtapes.com/release/eratp127-penguin-cafe-handfuls-of-night
|
@ -1,116 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (App Highlight: Open Source Disk Partitioning Tool GParted)
|
||||
[#]: via: (https://itsfoss.com/gparted/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
应用程序推荐:开源磁盘分区工具 GParted
|
||||
======
|
||||
|
||||
_**摘要:GParted 是一个非常流行的自由的可用于 Linux 发行版的分区编辑器。在这里,我们简单地看看它提供了什么。**_
|
||||
|
||||
### GParted:一个基于自由和开放源码的图形化分区管理器
|
||||
|
||||
![][1]
|
||||
|
||||
GParted 无疑是[在 Linux 下的最好的分区管理器][2]之一。用户界面非常简单,可用完成任务。
|
||||
|
||||
在一些情况下,你最终也需要使用 [GParted][3] 来修复或格式化你的 USB 驱动器。我有一个[我不能在 Ubuntu 中格式化的 USB 磁盘][4],使用该“磁盘”应用程序 – 这里是 GParted 用来救援的地方。
|
||||
|
||||
所以,它是非常有用的工具,有很多好的特色。让我为你们推荐一下。
|
||||
|
||||
警告!
|
||||
|
||||
玩弄磁盘分区是一件危险的工作。除非绝对必要,否则不要做。否则,你可能最终会擦除整个磁盘。
|
||||
|
||||
### GParted 的特色
|
||||
|
||||
你可以使用 GParted 做很多事,排列一下简单地格式化任务到重要的分区任务。我将使用一些屏幕截图推荐关键特色,以帮助你在安装它前了解更多信息。
|
||||
|
||||
#### 创建分区表
|
||||
|
||||
你可以为你的新的磁盘创建一个新的分区表,或者擦除你现存的磁盘内容来修改分区表。
|
||||
|
||||
![][5]
|
||||
|
||||
你将能够选择 msdos ,gpt ,atari ,以及更多类型的分区表。
|
||||
|
||||
#### 创建,移动,标记,删除和修改分区表
|
||||
|
||||
你可以使用 GParted 中一系列可用的选项来简单地创建,标记,删除或修改分区表。
|
||||
|
||||
![][6]
|
||||
|
||||
当然,你将不得不小心你想做什么。
|
||||
|
||||
好的一些东西是,GParted 确保你不能直接应用任何更改 – 在你点击应用更改之前,它将排队你选择的操作/任务,并询问另外一处最后的确认。
|
||||
|
||||
在顶部的对号标记符号 ✓ 允许你来确认更改,只有你更改时开始生效。
|
||||
|
||||
这样有另一个你可用的分区选项的屏幕截图:
|
||||
|
||||
![][7]
|
||||
|
||||
#### 尝试数据救援
|
||||
|
||||
除了编辑分区,你也可以尝试使用“**尝试数据救援**”特色以[在Linux 中恢复你丢失的数据][8],像下面的屏幕截图所示。
|
||||
|
||||
![][9]
|
||||
|
||||
值得注意的是,默认情况下你没有安装这个功能 – 你仅能看到可见的选项。所以,对于数据恢复特色作业来说,你必需使用下面的命令来单独地安装 gpart (在基于 Ubuntu/Debian 的发行版上):
|
||||
|
||||
```
|
||||
sudo apt install gpart
|
||||
```
|
||||
|
||||
除了所有关键的特色外,它支持大量的存储设备和文件系统。在它们的官方网站上,你可以从[特色列表][10]中学到很多。
|
||||
|
||||
### 在 Ubuntu 和其它 Linux 发行版上安装 GParted
|
||||
|
||||
你可能已经预先安装 GParted 。所以,务必核实一下。如果你没有安装它,你可以前往进入软件中心安装它。
|
||||
|
||||
以备你想使用终端,简单地键入下面的命令:
|
||||
|
||||
```
|
||||
sudo apt install gparted
|
||||
```
|
||||
|
||||
像我如上所述,如果你想要数据恢复选项,除了 gparted 软件包外,你应该安装 gpart 软件包。
|
||||
|
||||
如果你正在使用一些其它 Linux 发行版,你可以在各自的软件管理器中找到它,或者简单地查看[官方下载操作指南][11]。
|
||||
|
||||
[下载 GParted][11]
|
||||
|
||||
**总结**
|
||||
|
||||
当涉及处理磁盘管理和分区时,GParted 是一个非常有用和重要的工具。但是,因为显而易见的原因,当你使用它时,你将不得不小心。
|
||||
|
||||
你尝试过 GParted 吗?你在 Linux 上使用的其它分区工具是什么?请在下面的评论中分享你的体验。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/gparted/
|
||||
|
||||
作者:[Ankush Das][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[robsean](https://github.com/robsean)
|
||||
校对:[校对者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://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-screenshot.png?ssl=1
|
||||
[2]: https://itsfoss.com/partition-managers-linux/
|
||||
[3]: https://gparted.org/
|
||||
[4]: https://itsfoss.com/format-usb-drive-sd-card-ubuntu/
|
||||
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-create-partition-table.png?ssl=1
|
||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-modify-partitions.png?ssl=1
|
||||
[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-partition-options.png?ssl=1
|
||||
[8]: https://itsfoss.com/recover-deleted-files-linux/
|
||||
[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/gparted-attempt-data-rescue-feature.png?ssl=1
|
||||
[10]: https://gparted.org/features.php
|
||||
[11]: https://gparted.org/download.php
|
@ -0,0 +1,120 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (chen-ni)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Explained! Why Your Distribution Still Using an ‘Outdated’ Linux Kernel?)
|
||||
[#]: via: (https://itsfoss.com/why-distros-use-old-kernel/)
|
||||
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
|
||||
|
||||
为什么你的发行版仍然在使用“过时的”Linux 内核?
|
||||
======
|
||||
|
||||
[检查一下你的系统所使用的 Linux 内核版本][1],你十有八九会发现,按照 Linux 内核官网提供的信息,该内核版本已经达到使用寿命终期了。
|
||||
|
||||
一个软件一旦达到了使用寿命终期,那么就意味着它再也不会得到 bug 修复和维护了。
|
||||
|
||||
这自然会引发一连串问题:为什么我的 Linux 发行版会使用一个已经达到使用寿命终期的内核呢?这样做有没有安全风险?我的系统还安全吗?
|
||||
|
||||
下面将逐一解答这些问题。
|
||||
|
||||
总结
|
||||
|
||||
上游内核维护与你的发行版的内核维护是两个不同的概念。
|
||||
|
||||
例如,根据 Linux 内核官网,Linux 内核 4.15 版本可能已经达到使用寿命终期了,但是在 2023 年 4 月之前,Ubuntu 18.04 长期维护版本将会继续使用这个版本,并通过向后移植安全补丁和修复 bug 来提供维护。
|
||||
|
||||
### 检查 Linux 内核版本,以及是否达到使用寿命终期
|
||||
|
||||
首先,查看你的系统所使用的 Linux 内核版本:
|
||||
|
||||
```
|
||||
uname -r
|
||||
```
|
||||
|
||||
我使用的是 Ubuntu 18.04,输出的 Linux 内核版本如下:
|
||||
|
||||
```
|
||||
[email protected]:~$ uname -r
|
||||
5.0.0-37-generic
|
||||
```
|
||||
|
||||
接下来,可以到 Linux 内核官网上看看哪些 Linux 内核版本仍然在维护状态。在网站主页上就可以看到相关信息。
|
||||
|
||||
[Linux 内核官网][2]
|
||||
|
||||
你看到的内核版本状态应该类似于下图:
|
||||
|
||||
![Linux 内核状态][3]
|
||||
|
||||
如果你的内核版本没有列在内核官网主页上,就说明该版本已经达到了使用寿命终期。
|
||||
|
||||
可以看到,5.0 内核版本并不在列,这说明该内核版本已经不再得到维护。事实上,该版本在 [2019 年 6 月就已经达到使用寿命终期了][4]。
|
||||
|
||||
不幸的是,Linux 内核的生命周期没有任何规律可循。不是说常规的内核稳定发布版可以得到 X 月的维护、长期维护版本(LTS)可以得到 Y 年的维护。没有这回事。
|
||||
|
||||
根据实际需求,可能会存在内核的多个 LTS 版本,其使用寿命终期各不相同。在[这个页面][5]上可以查到这些 LTS 版本的相关信息,包括推定的使用寿命终期。
|
||||
|
||||
那么问题来了:既然 Linux 内核官网上明确表示 5.0 版本的内核已经达到了使用寿命终期,Ubuntu 为什么还在提供这个内核版本呢?
|
||||
|
||||
### 你的发行版使用的 Linux 内核已经达到了使用寿命终期,但是没关系!
|
||||
|
||||
![][6]
|
||||
|
||||
你是否想过,为什么 Ubuntu/Debian/Fedora 等发行版被称为 Linux “发行版”?这是因为,它们“发行” Linux 内核。
|
||||
|
||||
这些发行版会对 Linux 内核进行不同的修改,并添加各种 GUI 元素(包括桌面环境,显示服务器等)以及软件,然后再呈现给用户。
|
||||
|
||||
按照通常的工作流,Linux 发行版会选择一个内核,提供给其用户,然后在接下来的几个月、几年中,甚至是达到内核的使用寿命终期之后,仍然会继续使用该内核。
|
||||
|
||||
这样能够保障安全吗?其实是可以的,因为 _**发行版会通过向后移植全部的重要修补来维护内核**_。
|
||||
|
||||
换句话说,你的 Linux 发行版会确保 Linux 内核没有漏洞和 bug,并且已经通过向后移植获得了重要的新特性。在“过时的旧版本 Linux 内核”上,其实有着数以千计的改动。
|
||||
|
||||
如果 Linux 内核网站上说某个内核版本已经达到了使用寿命终期,那么就意味着 Linux 内核的核心维护团队不会再对该内核版本进行升级和打补丁了。
|
||||
|
||||
但与此同时,Debian/Ubuntu 或者其他发行版的开发者们会继续工作,通过从(由内核核心团队维护的)更新的内核版本中迁移相关的修改,维持这个老版本的生命力。
|
||||
|
||||
重点在于,即使你的发行版看上去是在使用一个已经过时的 Linux 内核,其实该内核也得到了良好的维护,并非是真的过时了。
|
||||
|
||||
### 你是否应该使用最新的稳定内核版本?
|
||||
|
||||
![][7]
|
||||
|
||||
新的 Linux 内核稳定版本每隔 2 到 3 个月发布一次,有不少用户跃跃欲试。
|
||||
|
||||
实话说,除非有十分充分的理由,否则不应该使用最新版本的稳定内核。你使用的发行版并不会提供这个选项,你也不能指望通过在键盘上敲出“_sudo apt give-me-the-latest-stable-kernel_”解决问题。
|
||||
|
||||
此外,手动[安装主流 Linux 内核版本][8]本身就是一个挑战。即使安装成功,之后每次发布 bug 修复的时候,负责更新内核的就会是你了。此外,当新内核达到使用寿命终期之后,你就有责任将它升级到更新的内核版本了。和常规的[Ubuntu 更新][9]不同,内核升级无法通过 apt upgrade 完成。
|
||||
|
||||
同样需要记住的是,切换到主流内核之后,可能就无法使用你的发行版提供的一些驱动程序和补丁了。
|
||||
|
||||
正如 [Greg Kroah-Hartman][10]所言,“_**你能使用的最好的内核,就是别人在维护的内核。**_”除了你的 Linux 发行版之外,又有谁更胜任这份工作呢!
|
||||
|
||||
希望你对这个主题已经有了更好的理解。下回发现你的系统正在使用的内核版本已经达到使用寿命终期的时候,希望你不会感到惊慌失措。
|
||||
|
||||
欢迎在下面的评论区中留下你的疑问或建议。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/why-distros-use-old-kernel/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[chen-ni](https://github.com/chen-ni)
|
||||
校对:[校对者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://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/
|
||||
[2]: https://www.kernel.org/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/linux-kernel-status.jpg?ssl=1
|
||||
[4]: http://lkml.iu.edu/hypermail/linux/kernel/1906.0/02354.html
|
||||
[5]: https://www.kernel.org/category/releases.html
|
||||
[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/Keep_Calm_and_Trust_Your_Distribution.png?ssl=1
|
||||
[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/using_latest_kernel.png?ssl=1
|
||||
[8]: https://wiki.ubuntu.com/Kernel/MainlineBuilds
|
||||
[9]: https://itsfoss.com/update-ubuntu/
|
||||
[10]: https://en.wikipedia.org/wiki/Greg_Kroah-Hartman
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (heguangzhi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
@ -8,40 +8,36 @@
|
||||
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
|
||||
|
||||
Put some loot in your Python platformer game
|
||||
在你的 Python 平台类游戏中放一些奖励
|
||||
======
|
||||
Give your players some treasures to collect and boost their score in
|
||||
this installment on programming video games with Python's Pygame module.
|
||||
|
||||
这部分是关于在使用 Python 的 Pygame 模块开发视频游戏给你的玩家提供收集的宝物和经验值的内容。
|
||||
![Hearts, stars, and dollar signs][1]
|
||||
|
||||
This is part 9 in an ongoing series about creating video games in [Python 3][2] using the [Pygame][3] module. Previous articles are:
|
||||
这是正在进行的关于使用 [Python 3][2]的[Pygame][3]模块创建视频游戏的系列文章的第9部分。以前的文章有:
|
||||
|
||||
* [Learn how to program in Python by building a simple dice game][4]
|
||||
* [Build a game framework with Python using the Pygame module][5]
|
||||
* [How to add a player to your Python game][6]
|
||||
* [Using Pygame to move your game character around][7]
|
||||
* [What's a hero without a villain? How to add one to your Python game][8]
|
||||
* [Simulate gravity in your Python game][9]
|
||||
* [Add jumping to your Python platformer game][10]
|
||||
* [Enable your Python game player to run forward and backward][11]
|
||||
* [通过构建一个简单的骰子游戏学习如何用 Python 编程][4]
|
||||
* [使用 Pygame 模块用 Python 构建游戏框架][5]
|
||||
* [如何在 Python 游戏中添加玩家][6]
|
||||
* [使用 Pygame 移动你的游戏角色][7]
|
||||
* [没有恶棍的哪里来的英雄?如何在您的 Python 游戏中添加一个][8]
|
||||
* [在你的 Python 游戏中模拟重力][9]
|
||||
* [将跳跃添加到您的 Python 平台游戏中][10]
|
||||
* [使你的 Python 游戏玩家能够向前和向后跑][11]
|
||||
|
||||
如果你已经阅读了本系列的前几篇文章,那么你已经了解了编写游戏的所有基础知识。现在你可以在这些基础上,创造一个全功能的游戏。当你第一次学习时,遵循本系列代码示例,这样的“用例”是有帮助的,但是,用例也会约束你。现在是时候运用你学到的知识,以新的方式应用它们了。
|
||||
|
||||
如果说,说起来容易做起来难,这篇文章展示了一个如何将你已经了解的内容用于新目的的例子中。具体来说,就是它涵盖了如何使用你以前的课程中已经了解到的来实现奖励系统。
|
||||
|
||||
If you've followed along with the previous articles in this series, then you know all the basics of programming video game mechanics. You can build upon these basics to create a fully functional video game all your own. Following a "recipe" like the code samples in this series is helpful when you're first learning, but eventually, the recipe becomes a constraint. It's time to use the principles you've learned and apply them in new ways.
|
||||
在大多数电子游戏中,你有机会在游戏世界中获得“奖励”或收集到宝物和其他物品。奖励通常会增加你的分数或者你的健康指数,或者为你的下一次任务提供信息。
|
||||
|
||||
If that sounds easier said than done, this article demonstrates an example of how to leverage what you already know for new purposes. Specifically, it covers how to implement a looting system
|
||||
游戏中包含的奖励类似于编程平台。像平台一样,奖励没有用户控制,随着游戏世界的滚动进行,并且必须检查与玩家的碰撞。
|
||||
|
||||
using what you have already learned about platforms from previous lessons.
|
||||
### 创建奖励函数
|
||||
|
||||
In most video games, you have the opportunity to "loot," or collect treasures and other items within the game world. Loot usually increases your score or your health or provides information leading to your next quest.
|
||||
|
||||
Including loot in your game is similar to programming platforms. Like platforms, loot has no user controls, scrolls with the game world, and must check for collisions with the player sprite.
|
||||
|
||||
### Creating the loot function
|
||||
|
||||
Loot is so similar to platforms that you don't even need a Loot class. You can just reuse the **Platform** class and call the results loot.
|
||||
|
||||
Since loot type and placement probably differ from level to level, create a new function called **loot** in your **Level** class, if you don't already have one. Since loot items are not platforms, you must also create a new **loot_list** group and then add loot objects to it. As with platforms, ground, and enemies, this group is used when checking for collisions:
|
||||
奖励和平台非常相似,你甚至不需要奖励类。您可以重用 **Platform** 类,并将结果称为奖励。
|
||||
|
||||
由于奖励类型和位置可能因关卡不同而不同,如果你还没有一个新的功能,请在你的 **Level** 中创建一个名为 **Level** 的新功能。因为奖励物品不是平台,你也必须创建一个新的 **loot_list** 组,然后添加奖励物品。与平台、地面和敌人一样,该组用于检查玩家碰撞:
|
||||
|
||||
```
|
||||
def loot(lvl,lloc):
|
||||
@ -56,10 +52,9 @@ Since loot type and placement probably differ from level to level, create a new
|
||||
return loot_list
|
||||
```
|
||||
|
||||
You can add as many loot objects as you like; just remember to add each one to your loot list. The arguments for the **Platform** class are the X position, the Y position, the width and height of the loot sprite (it's usually easiest to keep your loot sprite the same size as all other tiles), and the image you want to use as loot. Placement of loot can be just as complex as mapping platforms, so use the level design document you created when creating the level.
|
||||
|
||||
Call your new loot function in the **Setup** section of your script. In the following code, the first three lines are for context, so just add the fourth:
|
||||
你可以随意添加任意数量的奖励对象;记住把每一个都加到你的奖励清单上。***Platform** 类的参数是奖励图标的X位置、Y位置、宽度和高度(通常最容易让你的奖励图标保持和所有其他方块一样的大小),以及你想要用作的奖励图标。奖励的放置可以和贴图平台一样复杂,所以使用创建关卡时需要创建关卡设计文档。
|
||||
|
||||
在脚本的 **Setup** 部分调用新的奖励函数。在下面的代码中,前三行是上下文,所以只需添加第四行:
|
||||
|
||||
```
|
||||
enemy_list = Level.bad( 1, eloc )
|
||||
@ -68,8 +63,7 @@ plat_list = Level.platform( 1,tx,ty )
|
||||
loot_list = Level.loot(1,tx,ty)
|
||||
```
|
||||
|
||||
As you know by now, the loot won't get drawn to the screen unless you include it in your main loop. Add the final line from the following code sample to your loop:
|
||||
|
||||
正如你现在所知道的,除非你把它包含在你的主循环中,否则奖励不会被显示到屏幕上。将下面代码示例的最后一行添加到循环中:
|
||||
|
||||
```
|
||||
enemy_list.draw(world)
|
||||
@ -78,16 +72,15 @@ As you know by now, the loot won't get drawn to the screen unless you include it
|
||||
loot_list.draw(world)
|
||||
```
|
||||
|
||||
Launch your game to see what happens.
|
||||
启动你的游戏看看会发生什么。
|
||||
|
||||
![Loot in Python platformer][12]
|
||||
|
||||
Your loot objects are spawned, but they don't do anything when your player runs into them, nor do they scroll when your player runs past them. Fix these issues next.
|
||||
你的奖励将会显示出来,但是当你的玩家碰到它们时,它们不会做任何事情,当你的玩家经过它们时,它们也不会滚动。接下来解决这些问题。
|
||||
|
||||
### Scrolling loot
|
||||
|
||||
Like platforms, loot has to scroll when the player moves through the game world. The logic is identical to platform scrolling. To scroll the loot forward, add the last two lines:
|
||||
### 滚动奖励
|
||||
|
||||
像平台一样,当玩家在游戏世界中移动时,奖励必须滚动。逻辑与平台滚动相同。要向前滚动奖励物品,添加最后两行:
|
||||
|
||||
```
|
||||
for e in enemy_list:
|
||||
@ -96,7 +89,7 @@ Like platforms, loot has to scroll when the player moves through the game world.
|
||||
l.rect.x -= scroll
|
||||
```
|
||||
|
||||
To scroll it backward, add the last two lines:
|
||||
要向后滚动,请添加最后两行:
|
||||
|
||||
|
||||
```
|
||||
@ -106,16 +99,15 @@ To scroll it backward, add the last two lines:
|
||||
l.rect.x += scroll
|
||||
```
|
||||
|
||||
Launch your game again to see that your loot objects now act like they're _in_ the game world instead of just painted on top of it.
|
||||
再次启动你的游戏,看看你的奖励物品现在表现得像在游戏世界里一样了,而不是仅仅画在上面。
|
||||
|
||||
### Detecting collisions
|
||||
### 检测碰撞
|
||||
|
||||
As with platforms and enemies, you can check for collisions between loot and your player. The logic is the same as other collisions, except that a hit doesn't (necessarily) affect gravity or health. Instead, a hit causes the loot to disappear and increment the player's score.
|
||||
就像平台和敌人一样,你可以检查奖励物品和玩家之间的碰撞。逻辑与其他碰撞相同,除了撞击不会(必然)影响重力或健康。取而代之的是,命中会导致奖励物品会消失并增加玩家的分数。
|
||||
|
||||
When your player touches a loot object, you can remove that object from the **loot_list**. This means that when your main loop redraws all loot items in **loot_list**, it won't redraw that particular object, so it will look like the player has grabbed the loot.
|
||||
|
||||
Add the following code above the platform collision detection in the **update** function of your **Player** class (the last line is just for context):
|
||||
当你的玩家触摸到一个奖励对象时,你可以从 **奖励列表** 中移除该对象。这意味着当你的主循环在 **loot_list** 中重绘所有奖励物品时,它不会重绘那个特定的对象,所以看起来玩家已经获得了奖励物品。
|
||||
|
||||
在 **Player** 类的 **update** 函数中的平台碰撞检测之上添加以下代码(最后一行仅用于上下文):
|
||||
|
||||
```
|
||||
loot_hit_list = pygame.sprite.spritecollide(self, loot_list, False)
|
||||
@ -127,8 +119,7 @@ Add the following code above the platform collision detection in the **update**
|
||||
plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False)
|
||||
```
|
||||
|
||||
Not only do you remove the loot object from its group when a collision happens, but you also award your player a bump in score. You haven't created a score variable yet, so add that to your player's properties, created in the **__init__** function of the **Player** class. In the following code, the first two lines are for context, so just add the score variable:
|
||||
|
||||
当碰撞发生时,你不仅要把奖励从它的组中移除,还要给你的玩家一个分数提升。你还没有创建分数变量,所以请将它添加到你的玩家属性中,该属性是在***Player** 类的**__init__**函数中创建的。在下面的代码中,前两行是上下文,所以只需添加分数变量:
|
||||
|
||||
```
|
||||
self.frame = 0
|
||||
@ -136,20 +127,18 @@ Not only do you remove the loot object from its group when a collision happens,
|
||||
self.score = 0
|
||||
```
|
||||
|
||||
When calling the **update** function in your main loop, include the **loot_list**:
|
||||
|
||||
当在主循环中调用**update**函数时,需要包括**loot_list**:
|
||||
|
||||
```
|
||||
player.gravity()
|
||||
player.update()
|
||||
```
|
||||
|
||||
As you can see, you've got all the basics. All you have to do now is use what you know in new ways.
|
||||
如你所见,你已经掌握了所有的基本知识。你现在要做的就是用新的方式使用你所知道的。
|
||||
|
||||
There are a few more tips in the next article, but in the meantime, use what you've learned to make a few simple, single-level games. Limiting the scope of what you are trying to create is important so that you don't overwhelm yourself. It also makes it easier to end up with a finished product that looks and feels finished.
|
||||
|
||||
Here's all the code you've written for this Python platformer so far:
|
||||
在下一篇文章中还有一些提示,但是与此同时,用你学到的知识来制作一些简单的单层游戏。限制你试图创造的东西的范围是很重要的,这样你就不会埋没自己。这也使得最终的成品看起来和感觉上更容易完成。
|
||||
|
||||
以下是迄今为止你为这个 Python 平台编写的所有代码:
|
||||
|
||||
```
|
||||
#!/usr/bin/env python3
|
||||
@ -514,7 +503,7 @@ via: https://opensource.com/article/20/1/loot-python-platformer-game
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[heguangzhi](https://github.com/heguangzhi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user