Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2021-01-16 13:08:18 +08:00
commit 536171557b
10 changed files with 1130 additions and 88 deletions

View File

@ -0,0 +1,71 @@
[#]: collector: (lujun9972)
[#]: translator: (stevenzdg988)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13018-1.html)
[#]: subject: (Top articles for learning Python in 2020)
[#]: via: (https://opensource.com/article/19/12/learn-python)
[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg)
学习 Python 的好文章
======
> 无论你在 Python 编程过程中处于什么阶段,这些 Python 热门文章将会对你有很大帮助。
![](https://img.linux.net.cn/data/attachment/album/202101/15/231657xt8085wtyk5yvsz5.jpg)
2019 年是 Python 的好年景。根据 [GitHub][2] 和 [Stack Overflow][3] 的受欢迎资源程度来看它正在成为全球第二大流行语言。LCTT 译注:原文发表于 2019 年底,但是这里提及的文章并没有过时。)
> “在我们的调查中Python 作为增长最快的程序设计语言,在程序设计语言中排名再次上升,今年排在 Java 之前,成为第二大最受欢迎的程序设计语言(仅次于 Rust )。”
>
> — [Stack Overflow Insights][3]
同样Python 的读者人数呈跳跃式激增。以下是按主题分组的 2019 年以来最热门的 Python 文章,供你仔细阅读。
### 为什么选择 Python
在众多的程序设计语言中,是什么使 Python 成为首选呢?从文章的阅读量来看,那就是因为它的灵活性。正如 Jigyasa Grover 解释的那样Python 开发人员可以使用 [多种范例][4],包括 Seth Kenlon 教程所展示的流行的 [面向对象程序设计][5]。
如果你是 Python 的长期用户,并且正在寻找 Python 为什么是完美的程序设计语言的高级例子,那么可以看 Moshe Zadka 的 [喜欢 Python 的 5 大理由][6]。如果这还不够的话,你也可以使用功能强大的工具来尝试,无需编写大量代码,例如 Parul Pandey 关于 [图像处理][7] 的教程。
### 配置 Python
随着 Python 的受欢迎程度不断提高,使用它的人越来越多。这些新手中的许多人都是在 Mac 操作系统上进行的,并且正在使用 Moshe 和我写的 [Python3 配置向导][8]。
安装 Python 之后接下来就是决定利用什么工具编写代码。关于文本编辑器和集成开发环境IDE有很多选择但是读者似乎更喜欢图形界面在有关该主题的文章中Stephan Avenwedde 的关于 [Pythonic][9] 和我关于 [JupyterLab][10] 的文章的读者最多。
在对程序设计语言充满信心的途径上开发人员将不得不面对众多选择来管理程序设计语言的版本和项目依赖。幸运的是László Kiss Kollár 的文章 [Python 包管理][11] 让其变得更加容易。
当你准备好配置一个具有所有功能的 IDE以最大限度地利用这门语言时请一定尝试一下 [linter Black][12],如 Moshe 说的,保持代码的清洁。
### 小结
无论你处在 Python 程序设计的哪个阶段,这些热门 Python 文章都将为你提供帮助。如果没有至少一次对测试重要性的认可我无法对此进行总结为此Moshe 提供了另一篇 [关于 tox][13] 的好文章。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/12/learn-python
作者:[Matthew Broberg][a]
选题:[lujun9972][b]
译者:[stevenzdg988](https://github.com/stevenzdg988)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/mbbroberg
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd (Hands on a keyboard with a Python book )
[2]: https://octoverse.github.com/#top-languages
[3]: https://insights.stackoverflow.com/survey/2019
[4]: https://opensource.com/article/19/10/python-programming-paradigms
[5]: https://opensource.com/article/19/7/get-modular-python-classes
[6]: https://opensource.com/article/19/10/why-love-python
[7]: https://linux.cn/article-10679-1.html
[8]: https://opensource.com/article/19/5/python-3-default-mac
[9]: https://opensource.com/article/19/5/graphically-programming-pythonic
[10]: https://opensource.com/article/19/5/jupyterlab-python-developers-magic
[11]: https://opensource.com/article/19/4/managing-python-packages
[12]: https://linux.cn/article-10864-1.html
[13]: https://opensource.com/article/19/5/python-tox
[14]: https://opensource.com/how-submit-article

View File

@ -1,48 +1,50 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-13019-1.html)
[#]: subject: (Why I like the FED text editor)
[#]: via: (https://opensource.com/article/21/1/fed-editor)
[#]: author: (Jim Hall https://opensource.com/users/jim-hall)
我为什么喜欢 FED 文本编辑器
======
FED 编辑器让我可以轻松有效地对我的 FreeDOS 项目进行编码。学习如何充分利用这个灵活的 Linux、Windows 和 DOS 编辑器。
![Person using a laptop][1]
当我不[在我的 Linux 桌面上工作][2]的时候,你通常可以发现我在为一个旧版的 16 位系统写代码。[FreeDOS][3] 是一个开源的 DOS 兼容操作系统,你可以用它来玩经典的 DOS 游戏,运行旧版的商业软件,或者开发嵌入式系统。任何在 MS-DOS 上运行的程序也应该在 FreeDOS 上运行
> FED 编辑器让我可以轻松有效地对我的 FreeDOS 项目进行编码。学习如何充分利用这个灵活的 Linux、Windows 和 DOS 编辑器。
我是和 DOS 一起长大的。我家的第一台个人电脑是一台 Apple II 克隆机,但我们最终升级到了一台运行 DOS 的 IBM PC。从 1980 年代早期到 1993 年我[发现 Linux][4] 这段时间,我做了十多年的 DOS 用户。
![](https://img.linux.net.cn/data/attachment/album/202101/16/114344hgra9oq4q45mgz9r.jpg)
当我不[在我的 Linux 桌面上工作][2]的时候,我通常是在为一个旧版的 16 位系统写代码。[FreeDOS][3] 是一个开源的 DOS 兼容操作系统,你可以用它来玩经典的 DOS 游戏,运行旧版的商业软件,或者开发嵌入式系统。任何在 MS-DOS 上运行的程序在 FreeDOS 上也应该可以运行。
我是和 DOS 一起长大的。我家的第一台个人电脑是一台 Apple II 兼容机,但我们最终升级到了一台运行 DOS 的 IBM PC。从 1980 年代早期到 1993 年我[发现 Linux][4] 这段时间,我做了十多年的 DOS 用户。
Linux 和开源软件所提供的自由度给我留下了深刻的印象。所以当微软在 1994 年宣布 DOS 的终结,以及即将推出的 Windows 95 时,我决定编写自己的开源 DOS。这就是 [FreeDOS 的开始][4]。
这么多年过去了,我还在继续研究 FreeDOS。它是一个很好的爱好系统在这里我可以运行我最喜欢的 DOS 应用和游戏。是的,我仍然在为 FreeDOS 写代码。
这么多年过去了,我还在继续研究 FreeDOS。它是一个很好的业余兴趣系统,在这里我可以运行我最喜欢的 DOS 应用和游戏。是的,我仍然在为 FreeDOS 写代码。
我最喜欢的 DOS 编程编辑器是 FED 编辑器。FED 是一个极简的文本编辑器,没有太多的视觉效果。这种最小化的方法帮助我充分利用了 DOS 中标准的 80x25 屏幕。当编辑一个文件时FED 会在屏幕底部显示一行状态行,让你在剩下的 24 行来编写你的代码。FED 还支持彩色语法高亮显示,以不同的颜色显示代码的不同部分,使你更容易发现错别字,以免它们变成错误。
我最喜欢的 DOS 编程编辑器是 FED 编辑器。FED 是一个极简的文本编辑器,没有太多的视觉效果。这种精简的方法帮助我充分利用了 DOS 中标准的 80x25 屏幕。当编辑一个文件时FED 会在屏幕底部显示一行状态行,让你在剩下的 24 行来编写你的代码。FED 还支持彩色语法高亮显示,以不同的颜色显示代码的不同部分,使你更容易发现错别字,以免它们变成错误。
![Writing a Solitaire game with FED][5]
用 FED 写一个纸牌游戏 - opensource.com
*用 FED 写一个纸牌游戏*
当你需要在菜单中做一些事情时,按下键盘上的 **Alt**FED 就会在最上面一行显示一个菜单。FED 也支持键盘快捷键,但要注意默认值。例如,**Ctrl-C** 会关闭文件,**Ctrl-V** 会改变视图。如果你不喜欢这些默认键,你可以在 **Config** 菜单中更改键位映射。
当你需要菜单时,按下键盘上的 `Alt`FED 就会在最上面一行显示一个菜单。FED 也支持键盘快捷键,但要注意默认值。例如,`Ctrl-C` 会关闭文件,`Ctrl-V` 会改变视图。如果你不喜欢这些默认键,你可以在 **Config** 菜单中更改键位映射。
![Tap the Alt key to bring up the menu][6]
按下 Alt 键弹出菜单 - openource.com
*按下 Alt 键弹出菜单*
如果你不喜欢默认的白底黑字显示,你可以在 **Config** 菜单下更改颜色。我更喜欢蓝底白字的正文关键词用亮白色注释用亮蓝色特殊字符用青色数字用绿色。FED 可以很容易地设置你想要的颜色。
![My preferred colors when programming on DOS][7]
我在 DOS 上编程时喜欢的颜色 - openource.com
*我在 DOS 上编程时喜欢的颜色*
FED 也是一个折叠式文本编辑器,这意味着它可以折叠或展开我的部分代码,以便我可以看到更多的文件。在函数名上按下 **Ctrl-F**FED 会折叠整个函数。折叠在其他代码上也可以使用。我也使用折叠来隐藏 **for****while** 循环或其他流程控制,如 **if****switch** 块。
FED 也是一个折叠式文本编辑器,这意味着它可以折叠或展开我的部分代码,以便我可以看到更多的文件。在函数名上按下 `Ctrl-F`FED 会折叠整个函数。折叠在其他代码上也可以使用。我也使用折叠来隐藏 `for``while` 循环或其他流程控制,如 `if``switch` 块。
![Folding a function lets you see more of the file][8]
折叠函数可以让你看到更多的文件 - openource.com
*折叠函数可以让你看到更多的文件*
Shawn Hargreaves 从 1994 年至 2004 年编写并维护 FED。Robert Riebisch 从那时起就开始维护 FED。FED 在 GNU GPL 许可下发布,支持 DOS、Linux 和 Windows。
@ -55,7 +57,7 @@ via: https://opensource.com/article/21/1/fed-editor
作者:[Jim Hall][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/) 荣誉推出

View File

@ -0,0 +1,78 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (3 plain text note-taking tools)
[#]: via: (https://opensource.com/article/21/1/plain-text)
[#]: author: (Kevin Sonney https://opensource.com/users/ksonney)
3 plain text note-taking tools
======
Note-taking is important, and plain text is an easy, neutral way to do
it. Here are three tools you can spice up your notes without losing the
ease and portability of plain text.
![Typewriter with hands][1]
In prior years, this annual series covered individual apps. This year, we are looking at all-in-one solutions in addition to strategies to help in 2021. Welcome to day 5 of 21 Days of Productivity in 2021.
Plain text is the most resilient format for documents. Plain text documents are small, transfer quickly between machines, and can be read on _any_ device. Therefore, it makes a lot of sense to take notes in a plain text document.
However, plain text is also that - plain. We live in a rich text world and still need titles, lists, and ways to demark one section from the other. Fortunately, there are several ways we can add these elements without having to add complex markup to plain text documents.
### Markdown
![Markdown][2]
Markdown (Kevin Sonney, [CC BY-SA 4.0][3])
[Markdown][4], created by Aaron Schwartz and John Gruber, is the format I use the most day today. From reading and writing README files, documentation, note-taking, and even source code comments, Markdown allows me to add formatting without sacrificing the ability to read the document easily.
Additionally, Markdown has several "extended versions" to allow for items that were not part of the original design. In particular, [GitHub Flavored Markdown][5] is exceptionally popular due to its use in the eponymous source control site.
Many file editors support Markdown highlighting out of the box with no extra add-ons or effort required.
### AsciiDoc
![AsciiDoc][6]
AsciiDoc (Kevin Sonney, [CC BY-SA 4.0][3])
[AsciiDoc][7], created by Stuart Rackham, is another way to add rich text elements to plain text documents. AsciiDoc has many features for generating documentation, books, and papers. That does not mean it shouldn't be used for note-taking, however. There are many environments (particularly in the education and research fields) where being able to quickly convert notes to a more "formal" format is helpful.
AsciiDoc also has many tools for converting text to other formats for collaboration. There are also several add-ons for importing data from different sources and putting it in a final document, or for handling special formatting like MathML or LaTeX.
### Org Mode
![ORG-Mode][8]
ORG-Mode (Kevin Sonney, [CC BY-SA 4.0][3])
I cannot leave out [Org][9] when I talk about text formatting. Originally designed for use with [GNU Emacs][10], Org Mode has become one of the go-to plain text formats for notes, to-do lists, documentation, and more. Org can be written and used in a whole host of text editors, including [Vim][11]. Org is simple, easy to learn, and one of my favorite text formats for notes.
At the end of the day, choosing Markdown, AsciiDoc, or Org for plain text notes is a way to make sure they can be read and updated anywhere. And if you are like me, you'll find yourself using the same syntax when taking paper-based notes as well!
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/1/plain-text
作者:[Kevin Sonney][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/ksonney
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/typewriter-hands.jpg?itok=oPugBzgv (Typewriter with hands)
[2]: https://opensource.com/sites/default/files/pictures/markdown.png (Markdown)
[3]: https://creativecommons.org/licenses/by-sa/4.0/
[4]: https://opensource.com/article/19/9/introduction-markdown
[5]: https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown
[6]: https://opensource.com/sites/default/files/pictures/asciidoc.png (AsciiDoc)
[7]: https://asciidoc.org/
[8]: https://opensource.com/sites/default/files/pictures/org-mode.png (ORG-Mode)
[9]: https://orgmode.org/
[10]: https://www.gnu.org/software/emacs/
[11]: https://opensource.com/article/19/1/productivity-tool-org-mode

View File

@ -0,0 +1,66 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How open source builds distributed trust)
[#]: via: (https://opensource.com/article/21/1/open-source-distributed-trust)
[#]: author: (Mike Bursell https://opensource.com/users/mikecamel)
How open source builds distributed trust
======
Trust in open source is a positive feedback loop.
![Trust][1]
This is an edited excerpt from my forthcoming book on _Trust in Computing and the Cloud_ for [Wiley][2] and leads on from a previous article I wrote called [_Trust & choosing open source_][3].
In that article, I asked the question: What are we doing when we say, "I trust open source software"? In reply, I suggested that what we are doing is making a determination that enough of the people who have written and tested it have similar requirements to mine, and that their expertise, combined, is such that the risk to my using the software is acceptable. I also introduced the idea of _distributed trust_.
The concept of distributing trust across a community is an application of the _wisdom of the crowd_ theory posited by Aristotle, where the assumption is that the opinions of many typically show more wisdom than the opinion of one or a few. While demonstrably false in its simplest form in some situations—the most obvious example being examples of popular support for totalitarian regimes—this principle can provide a very effective mechanism for establishing certain information.
This distillation of collective experience allows what we refer to as _distributed trust_ and is collected through numerous mechanisms on the internet. Some, like TripAdvisor or Glassdoor, record information about organisations or the services they provide, while others, like UrbanSitter or LinkedIn, allow users to add information about specific people (see, for instance, LinkedIn's Recommendations and Skills & Endorsements sections in individuals' profiles). The benefits that can accrue from these examples are significantly increased by the network effect, as the number of possible connections between members increases exponentially as the number of members increases.
Other examples of distributed trust include platforms like Twitter, where the number of followers that an account receives can be seen as a measure of its reputation and even of its trustworthiness, a calculation which we should view with a strong degree of scepticism. Indeed, Twitter felt that it had to address the social power of accounts with large numbers of followers and instituted a "verified accounts" mechanism to let people know that "an account of public interest is authentic." Interestingly, the company had to suspend the service after problems related to users' expectations of exactly what "verified" meant or implied: a classic case of differing understanding of context between different groups.
Where is the relevance to open source, then? The community aspect of open source is actually a driver towards building distributed trust. This is because, once you become a part of the community around an open source project, you assume one or more of the roles that you start trusting once you say that you "trust" an open source project (see my previous article). Examples include architect, designer, developer, reviewer, technical writer, tester, deployer, bug reporter, or bug fixer. The more involvement you have in a project, the more you become part of the community, which can, in time, become a _community of practice_.
Jean Lave and Etienne Wenger introduced the concept of communities of practice in the book _[Situated Learning: Legitimate Peripheral Participation][4]_, where groups evolve into communities as their members share a passion and participate in shared activities, leading to improving their skills and knowledge together. The core concept here is that as participants learn _around_ a community of practice, they become members of it at the same time:
> "Legitimate peripheral participation refers both to the development of knowledgeably skilled identities in practice and to the reproduction and transformation of communities of practice."
Wenger further explored the concept of communities of practice, how they form, requirements for their health, and how they encourage learning in _[Communities of Practice: Learning, Meaning, and Identity][5]_. He identified _negotiability of meaning_ ("why are we working together, what are we trying to achieve?") as core to a community of practice and noted that without _engagement_, _imagination_, and _alignment_ by individuals, communities of practice will not be robust.
We can align this with our views of how distributed trust is established and built: when you realise that your impact on open source can be equal to that of others, the distributed trust relationships that you hold to members of a community become less transitive (second- or third-hand or even more remote) and more immediate. You understand that the impact you can have on the creation, maintenance, requirements, and quality of the software you are running can be the same as all of the other, previously anonymous contributors with whom you are now forming a community of practice or whose existing community of practice you are joining. Then you become part of a network of trust relationships that are distributed but less removed from what you experience when buying and operating proprietary software.
The process does not stop there; as a common property of open source projects is cross-pollination, where developers from one project also work on others. This increases as the network effect of multiple open source projects allows reuse and dependencies on other projects to rise and leads to greater take-up across the entire set of projects.
It is easy to see why many open source contributors become open source enthusiasts or evangelists, not just for a single project but for open source as a whole. In fact, work by Stanford sociologist [Mark Granovetter][6] suggests that too many strong ties within communities can lead to cliques and stagnation, but weak ties provide movement of ideas and trends around communities. This awareness of other projects and the communities that exist around them and the flexibility of ideas across projects leads to distributed trust being able to be extended (albeit with weaker assurances) beyond the direct or short-chain indirect relationships that contributors experience within projects where they have immediate experience and out towards other projects where external observation or peripheral involvement shows that similar relationships exist between contributors.
Put simply, the act of being involved in an open source project and building trust relationships through participation leads to stronger distributed trust towards similar open source projects or just to other projects that are similarly open source.
What does this mean for each of us? It means that the more we get involved in open source, the more trust we can have in open source, as there will be a corresponding growth in the involvement—and therefore trust—of other people in open source. Trust in open source isn't just a network effect: it's a positive feedback loop!
* * *
_This article was originally published on [Alice, Eve, and Bob][7] and is reprinted with the author's permission._
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/1/open-source-distributed-trust
作者:[Mike Bursell][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/mikecamel
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_trust.png?itok=KMfi0Rdo (Trust)
[2]: https://wiley.com/
[3]: https://aliceevebob.com/2019/06/18/trust-choosing-open-source/
[4]: https://books.google.com/books/about/Situated_Learning.html?id=CAVIOrW3vYAC
[5]: https://books.google.com/books?id=Jb8mAAAAQBAJ&dq=Communities%20of%20Practice:%20Learning,%20meaning%20and%20identity&lr=
[6]: https://en.wikipedia.org/wiki/Mark_Granovetter
[7]: https://aliceevebob.com/2020/11/17/how-open-source-builds-distributed-trust/

View File

@ -0,0 +1,214 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to Create and Manage Archive Files in Linux)
[#]: via: (https://www.linux.com/news/how-to-create-and-manage-archive-files-in-linux-2/)
[#]: author: (LF Training https://training.linuxfoundation.org/announcements/how-to-create-and-manage-archive-files-in-linux/)
How to Create and Manage Archive Files in Linux
======
_By Matt Zand and Kevin Downs_
In a nutshell, an archive is a single file that contains a collection of other files and/or directories. Archive files are typically used for a transfer (locally or over the internet) or make a backup copy of a collection of files and directories which allow you to work with only one file (if compressed, it has a lower size than the sum of all files within it) instead of many. Likewise, archives are used for software application packaging. This single file can be easily compressed for ease of transfer while the files in the archive retain the structure and permissions of the original files.
We can use the tar tool to create, list, and extract files from archives. Archives made with tar are normally called “tar files,” “tar archives,” or—since all the archived files are rolled into one—“tarballs.”
This tutorial shows how to use tar to create an archive, list the contents of an archive, and extract the files from an archive. Two common options used with all three of these operations are -f and -v: to specify the name of the archive file, use -f followed by the file name; use the -v (“verbose”) option to have tar output the names of files as they are processed. While the -v option is not necessary, it lets you observe the progress of your tar operation.
For the remainder of this tutorial, we cover 3 topics: 1- Create an archive file, 2- List contents of an archive file, and 3- Extract contents from an archive file. We conclude this tutorial by surveying 6 practical questions related to archive file management. What you take away from this tutorial is essential for performing tasks related to [cybersecurity][1] and [cloud technology][2].
### 1- Creating an Archive File
To create an archive with tar, use the -c (“create”) option, and specify the name of the archive file to create with the -f option. Its common practice to use a name with a .tar extension, such as my-backup.tar. Note that unless specifically mentioned otherwise, all commands and command parameters used in the remainder of this article are used in lowercase. Keep in mind that while typing commands in this article on your terminal, you need not type the $ prompt sign that comes at the beginning of each command line.
Give as arguments the names of the files to be archived; to create an archive of a directory and all of the files and subdirectories it contains, give the directorys name as an argument.
* *To create an archive called project.tar from the contents of the project directory, type:
$ _tar -cvf project.tar project_
This command creates an archive file called project.tar containing the project directory and all of its contents. The original project directory remains unchanged.
Use the -z option to compress the archive as it is being written. This yields the same output as creating an uncompressed archive and then using gzip to compress it, but it eliminates the extra step.
* *To create a compressed archive called project.tar.gz from the contents of the project directory, type:
$ _tar -zcvf project.tar.gz project_
This command creates a compressed archive file, project.tar.gz, containing the project directory and all of its contents. The original project directory remains unchanged.
**NOTE:** While using the -z option, you should specify the archive name with a .tar.gz extension and not a .tar extension, so the file name shows that the archive is compressed. Although not required, it is a good practice to follow.
Gzip is not the only form of compression. There is also bzip2 and and xz. When we see a file with an extension of xz we know it has been compressed using xz. When we see a file with the extension of .bz2 we can infer it was compressed using bzip2. We are going to steer away from bzip2 as it is becoming unmaintained and focus on xz. When compressing using xz it is going to take longer for the files to compressed. However, it is typically worth the wait as the compression is much more effective, meaning the resulting file will usually be smaller than other compression methods used. Even better is the fact that decompression, or expanding the file, is not much different between the different methods of compression. Below we see an example of how to utilize xz when compressing a file using tar
  $ _tar -Jcvf project.tar.xz project_
We simply switch -z for gzip to uppercase -J for xz. Here are some outputs to display the differences between the forms of compression:
![][3]
![][4]
As you can see xz does take the longest to compress. However it does the best job of reducing files size, so its worth the wait. The larger the file is the better the compression becomes too!
### 2- Listing Contents of an Archive File
To list the contents of a tar archive without extracting them, use tar with the -t option.
* *To list the contents of an archive called project.tar, type:
$ _tar -tvf project.tar_ * *
This command lists the contents of the project.tar archive. Using the -v option along with the -t option causes tar to output the permissions and modification time of each file, along with its file name—the same format used by the ls command with the -l option.
* *To list the contents of a compressed archive called project.tar.gz, type:
$ _tar -tvf project.tar_
* *3- Extracting contents from an Archive File
To extract (or _unpack_) the contents of a tar archive, use tar with the -x (“extract”) option.
* *To extract the contents of an archive called project.tar, type:
$ _tar -xvf project.tar_
This command extracts the contents of the project.tar archive into the current directory.
If an archive is compressed, which usually means it will have a .tar.gz or .tgz extension, include the -z option.
* *To extract the contents of a compressed archive called project.tar.gz, type:
$ _tar -zxvf project.tar.gz_
**NOTE:** If there are files or subdirectories in the current directory with the same name as any of those in the archive, those files will be overwritten when the archive is extracted. If you dont know what files are included in an archive, consider listing the contents of the archive first.
Another reason to list the contents of an archive before extracting them is to determine whether the files in the archive are contained in a directory. If not, and the current directory contains many unrelated files, you might confuse them with the files extracted from the archive.
To extract the files into a directory of their own, make a new directory, move the archive to that directory, and change to that directory, where you can then extract the files from the archive.
Now that we have learned how to create an Archive file and list/extract its contents, we can move on to discuss the following 9 practical questions that are frequently asked by Linux professionals.
* Can we add content to an archive file without unpacking it?
Unfortunately, once a file has been compressed there is no way to add content to it. You would have to “unpack” it or extract the contents, edit or add content, and then compress the file again. If its a small file this process will not take long. If its a larger file then be prepared for it to take a while.
* Can we delete content from an archive file without unpacking it?
This depends on the version of tar being used. Newer versions of tar will support a delete.
For example, lets say we have files file1 and file2 . They can be removed from file.tar with the following:
_$ tar -vf file.tar delete file1 file2_
To remove a directory dir1:
_$ tar -f file.tar delete dir1/*_
* What are the differences between compressing a folder and archiving it?
The simplest way to look at the difference between archiving and compressing is to look at the end result. When you archive files you are combining multiple files into one. So if we archive 10 100kb files you will end up with one 1000kb file. On the other hand if we compress those files we could end up with a file that is only a few kb or close to 100kb.
* How to compress archive files?
As we saw above you can create and archive files using the tar command with the cvf options. To compress the archive file we made there are two options; run the archive file through compression such as gzip. Or use a compression flag when using the tar command. The most common compression flags are- z for gzip, -j for bzip and -J for xz. We can see the first method below:
_$ gzip file.tar_
Or we can just use a compression flag when using the tar command, here well see the gzip flag “z”:
_$ tar -cvzf file.tar /some/directory_
* How to create archives of multiple directories and/or files at one time?
It is not uncommon to be in situations where we want to archive multiple files or directories at once. And its not as difficult as you think to tar multiple files and directories at one time. You simply supply which files or directories you want to tar as arguments to the tar command:
_$ tar -cvzf file.tar file1 file2 file3_
or
_$ tar -cvzf file.tar /some/directory1 /some/directory2_
* How to skip directories and/or files when creating an archive?
You may run into a situation where you want to archive a directory or file but you dont need certain files to be archived. To avoid archiving those files or “exclude” them you would use the exclude option with tar:
_$ tar exclude /some/directory -cvf file.tar /home/user_
So in this example /home/user would be archived but it would exclude the /some/directory if it was under /home/user. Its important that you put the exclude option before the source and destination as well as to encapsulate the file or directory being excluded with single quotation marks.
### Summary
The tar command is useful for creating backups or compressing files you no longer need. Its good practice to back up files before changing them. If something doesnt work how its intended to after the change you will always be able to revert back to the old file. Compressing files no longer in use helps keep systems clean and lowers the disk space usage. There are other utilities available but tar has reigned supreme for its versatility, ease of use and popularity.
### Resources
If you like to learn more about Linux, reading the following articles and tutorials are highly recommended:
* [Comprehensive Review of Linux File System Architecture and Management][5]
* [Comprehensive Review of How Linux File and Directory System Works][6]
* [Comprehensive list of all Linux OS distributions][7]
* [Comprehensive list of all special purpose Linux distributions][8]
* [Linux System Admin Guide- Best Practices for Making and Managing Backup Operations][9]
* [Linux System Admin Guide- Overview of Linux Virtual Memory and Disk Buffer Cache][10]
* [Linux System Admin Guide- Best Practices for Monitoring Linux Systems][11]
* [Linux System Admin Guide- Best Practices for Performing Linux Boots and Shutdowns][12]
### About the Authors
**Matt Zand** is a serial entrepreneur and the founder of 3 tech startups: [DC Web Makers][13], [Coding Bootcamps][14] and [High School Technology Services][15]. He is a leading author of [Hands-on Smart Contract Development with Hyperledger Fabric][16] book by OReilly Media. He has written more than 100 technical articles and tutorials on blockchain development for Hyperledger, Ethereum and Corda R3 platforms. At DC Web Makers, he leads a team of blockchain experts for consulting and deploying enterprise decentralized applications. As chief architect, he has designed and developed blockchain courses and training programs for Coding Bootcamps. He has a masters degree in business management from the University of Maryland. Prior to blockchain development and consulting, he worked as senior web and mobile App developer and consultant, angel investor, business advisor for a few startup companies. You can connect with him on LI: <https://www.linkedin.com/in/matt-zand-64047871>
**Kevin Downs** is Red Hat Certified System Administrator or RHCSA. At his current job at IBM as Sys Admin, he is in charge of administering hundreds of servers running on different Linux distributions. He is a Lead Linux Instructor at [Coding Bootcamps][17] where he has authored [5 self-paced Courses][18].
The post [How to Create and Manage Archive Files in Linux][19] appeared first on [Linux Foundation Training][20].
--------------------------------------------------------------------------------
via: https://www.linux.com/news/how-to-create-and-manage-archive-files-in-linux-2/
作者:[LF Training][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://training.linuxfoundation.org/announcements/how-to-create-and-manage-archive-files-in-linux/
[b]: https://github.com/lujun9972
[1]: https://learn.coding-bootcamps.com/p/essential-practical-guide-to-cybersecurity-for-system-admin-and-developers
[2]: https://learn.coding-bootcamps.com/p/introduction-to-cloud-technology
[3]: https://training.linuxfoundation.org/wp-content/uploads/2020/12/Linux1-300x94.png
[4]: https://training.linuxfoundation.org/wp-content/uploads/2020/12/Linux2-300x110.png
[5]: https://blockchain.dcwebmakers.com/blog/linux-os-file-system-architecture-and-management.html
[6]: https://coding-bootcamps.com/linux/filesystem/index.html
[7]: https://myhsts.org/tutorial-list-of-all-linux-operating-system-distributions.php
[8]: https://coding-bootcamps.com/list-of-all-special-purpose-linux-distributions.html
[9]: https://myhsts.org/tutorial-system-admin-best-practices-for-managing-backup-operations.php
[10]: https://myhsts.org/tutorial-how-linux-virtual-memory-and-disk-buffer-cache-work.php
[11]: https://myhsts.org/tutorial-system-admin-best-practices-for-monitoring-linux-systems.php
[12]: https://myhsts.org/tutorial-best-practices-for-performing-linux-boots-and-shutdowns.php
[13]: https://blockchain.dcwebmakers.com/
[14]: http://coding-bootcamps.com/
[15]: https://myhsts.org/
[16]: https://www.oreilly.com/library/view/hands-on-smart-contract/9781492086116/
[17]: https://coding-bootcamps.com/
[18]: https://learn.coding-bootcamps.com/courses/author/758905
[19]: https://training.linuxfoundation.org/announcements/how-to-create-and-manage-archive-files-in-linux/
[20]: https://training.linuxfoundation.org/

View File

@ -0,0 +1,208 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Learn awk by coding a "guess the number" game)
[#]: via: (https://opensource.com/article/21/1/learn-awk)
[#]: author: (Chris Hermansen https://opensource.com/users/clhermansen)
Learn awk by coding a "guess the number" game
======
Programming languages tend to share many common traits. One great way to
learn a new language is to create a familiar program. In this article, I
will create a "guess the number" game by using awk to demonstrate
familiar concepts.
![question mark in chalk][1]
When you learn a new programming language, it's good to focus on the things most programming languages have in common:
* Variables places where information is stored
* Expressions ways to calculate things
* Statements the means by which state changes are expressed in a program
These concepts are the basis of most programming languages.
Once you understand these concepts, you can start figuring the rest out. For example, most languages have a "way of doing things" supported by their design, and those ways can be quite different from one program to another. These ways include modularity (grouping related functionality together), declarative vs. imperative, object-orientation, low- vs. high-level syntactic features, and so on. An example familiar to many programmers is "ceremony," that is, the amount of work required to set the scene before tackling the problem. The Java programming language is said to have a significant ceremony requirement, stemming from its design, which requires all code to be defined within a class.
But back to the basics. Programming languages usually share similarities. Once you know one programming language, start by learning the basics of another to appreciate the differences in that new language.
A good way to proceed is to create a set of basic test programs. With these in hand, learning starts with these similarities.
One test program you can use is a "guess the number" program. The computer picks a number between one and one hundred and asks you to guess the number. The program loops until you make a correct guess.
The "guess the number" program exercises several concepts in programming languages:
* Variables
* Input
* Output
* Conditional evaluation
* Loops
That's a great practical experiment to learn a new programming language.
**Note**: This article is adapted from Moshe Zadka's article on doing using this approach in [Julia][2] and Jim Hall's article on doing it in [Bash][3].
### Guess the number in awk
Let's write a "guess the number" game as an Awk program.
Awk is dynamically typed, is a scripting language oriented toward data transformation, and has surprisingly good support for interactive use. Awk has been around since the 1970s, originally as a part of the Unix operating system. If you don't know Awk but love spreadsheets, this is a sign… [go learn Awk][4]!
You can begin your exploration of Awk by writing a version of the "guess the number" game.
Here is my implementation (with line numbers so we can review some of the specific features):
```
     1    BEGIN {
     2        srand(42)
     3        randomNumber = int(rand() * 100) + 1
     4        print "random number is",randomNumber
     5        printf "guess a number between 1 and 100\n"
     6    }
     7    {
     8        guess = int($0)
     9        if (guess &lt; randomNumber) {
    10            printf "too low, try again:"
    11        } else if (guess &gt; randomNumber) {
    12            printf "too high, try again:"
    13        } else {
    14            printf "that's right\n"
    15            exit
    16        }
    17    }
```
We can immediately see similarities between Awk control structures and those of C or Java, but unlike Python. In statements such as _if-then-else_ or _while_, the _then_, _else_, and _while_ parts take either a statement or a group of statements enclosed within **{** and **}**. However, there is one big difference about AWk that needs to be understood from the start:
By design, Awk is built around a data pipeline.
What does that mean? Most Awk programs are snippets of code that receive a line of input, do something with the data, and write it to output. Recognizing the need for such a transformation pipeline, Awk by default provides all the transformation plumbing. Let's explore that through the above program by asking a basic question: Where is the 'read data from the console' structure?
The answer to that is it's built-in. In particular, lines 7 17 tell Awk what to do with each line that is read. Given that context, it's pretty easy to see that lines 1 6 are executed before anything is read.
More specifically, the **BEGIN** keyword on line 1 is a kind of "pattern," in this case indicating to Awk that, before reading any data, it should execute what follows the **BEGIN** in the { … }. A similar **END** keyword, not used in this program, indicates to Awk what to do when everything has been read.
Coming back to lines 7 17, we see they create a block of code { … } that is similar, but there is no keyword in front. Because there is nothing before the **{** for Awk to match, it will apply this line to every line of input received. Each line of input will be entered as guesses by the user.
Let's look at the code being executed. First, the preamble that happens before any input is read.
In line 2, we initialize the random number generator with the number 42 (if we don't provide an argument, the system clock is used). 42? [Of course 42][5]. Line 3 calculates a random number between 1 and 100, and line 4 prints that number out for debugging purposes. Line 5 invites the user to guess a number. Note this line uses `printf`, not `print`. Like C, `printf'`s first argument is a template used to format the output.
Now that the user is aware the program expects input, she can type a guess on the console. Awk supplies this guess to the code in lines 7 17, as mentioned previously. Line 18 converts the input record to an integer; `$0` indicates the entire input record, whereas `$1` indicates the first field of the input record, `$2` the second, and so on. Yup, Awk splits an input line into constituent fields, using the predefined separator, which defaults to white space. Lines 9 15 compare the guess to the random number, printing appropriate responses. If the guess is correct, line 15 exits prematurely from the input line processing pipeline.
Simple!
Given the unusual structure of Awk programs as code snippets that react to specific input line configurations and do stuff with the data, lets look at an alternative structure just to see how the filtering part works:
```
     1    BEGIN {
     2        srand(42)
     3        randomNumber = int(rand() * 100) + 1
     4        print "random number is",randomNumber
     5        printf "guess a number between 1 and 100\n"
     6    }
     7    int($0) &lt; randomNumber {
     8        printf "too low, try again: "
     9    }
    10    int($0) &gt; randomNumber {
    11        printf "too high, try again: "
    12    }
    13    int($0) == randomNumber {
    14        printf "that's right\n"
    15        exit
    16    }
```
Lines 1 6 havent changed. But now we see that lines 7 9 is code that is executed when the integer value of the line is less than the random number, lines 10 12 is code that is executed when the integer value of the line is greater than the random number, and lines 13 16 is code that is executed when the two match.
This should seem "cool but weird" why would we repeatedly calculate `int($0)`, for example? And for sure, it would be a weird way to solve the problem. But those patterns can be really quite wonderful ways to separate conditional processing since they can employ regular expressions or any other structure supported by Awk.
For completeness, we can use these patterns to separate common computations from things that only apply to specific circumstances. Heres a third version to illustrate:
```
     1    BEGIN {
     2        srand(42)
     3        randomNumber = int(rand() * 100) + 1
     4        print "random number is",randomNumber
     5        printf "guess a number between 1 and 100\n"
     6    }
     7    {
     8        guess = int($0)
     9    }
    10    guess &lt; randomNumber {
    11        printf "too low, try again: "
    12    }
    13    guess &gt; randomNumber {
    14        printf "too high, try again: "
    15    }
    16    guess == randomNumber {
    17        printf "that's right\n"
    18        exit
    19    }
```
Recognizing that, no matter what value of input comes in, it needs to be converted to an integer, we have created lines 7 9 to do just that. Now the three groups of lines, 10 12, 13 15 and 16 19, refer to the already-defined variable guess instead of converting the input line each time.
Let's go back to the list of things we wanted to learn:
* variables yup, Awk has those; we can infer that input data comes in as strings but can be converted to a numeric value when required
* input Awk just sends input through its "data transformation pipeline" approach to reading stuff
* output we have used Awk's `print` and `printf` procedures to write stuff to output
* conditional evaluation we have learned about Awk's _if-then-else_ and input filters that respond to specific input line configurations
* loops huh, imagine that! We didn't need a loop here, once again, thanks to the "data transformation pipeline" approach that Awk takes; the loop "just happens." Note the user can exit the pipeline prematurely by sending an end-of-file signal to Awk (a **CTRL-D** when using a Linux terminal window)
It's well worth considering the importance of not needing a loop to handle input. One reason Awk has remained viable for so long is that Awk programs are compact, and one of the reasons they are compact is there is no boilerplate required to read from the console or a file.
Let's run the program:
```
$ awk -f guess.awk
random number is 25
guess a number between 1 and 100: 50
too high, try again: 30
too high, try again: 10
too low, try again: 25
that's right
$
```
One thing we didn't cover was comments. An Awk comment begins with a `#` and ends with the end of line.
### Wrap up
Awk is incredibly powerful and this "guess the number" game is a great way to get started. It shouldn't be the end of your journey, though. You can [read about the history of Awk and Gawk (GNU Awk)][6], an expanded version of Awk and probably the one you have on your computer if you're running Linux, or [read all about the original from its initial developers][7].
You can also [download our cheatsheet][8] to help you keep track of everything you learn.
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/1/learn-awk
作者:[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/question-mark_chalkboard.jpg?itok=DaG4tje9 (question mark in chalk)
[2]: https://opensource.com/article/20/12/julia
[3]: https://opensource.com/article/20/12/learn-bash
[4]: https://opensource.com/article/20/9/awk-ebook
[5]: https://en.wikipedia.org/wiki/42_(number)#The_Hitchhiker's_Guide_to_the_Galaxy
[6]: https://www.gnu.org/software/gawk/manual/html_node/History.html
[7]: https://archive.org/details/pdfy-MgN0H1joIoDVoIC7
[8]: https://opensource.com/downloads/cheat-sheet-awk-features

View File

@ -0,0 +1,110 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Review of Container-to-Container Communications in Kubernetes)
[#]: via: (https://www.linux.com/news/review-of-container-to-container-communications-in-kubernetes/)
[#]: author: (LF Training https://training.linuxfoundation.org/announcements/review-of-container-to-container-communications-in-kubernetes/)
Review of Container-to-Container Communications in Kubernetes
======
This article was originally posted at [TheNewStack][1].
_By Matt Zand and Jim Sullivan_
Kubernetes is a containerized solution. It provides virtualized runtime environments called Pods, which house one or more containers to provide a virtual runtime environment. An important aspect of Kubernetes is container communication within the Pod. Additionally, an important area of managing the Kubernetes network is to forward container ports internally and externally to make sure containers within a Pod communicate with one another properly. To manage such communications, Kubernetes offers the following four networking models:
* Container-to-Container communications
* Pod-to-Pod communications
* Pod-to-Service communications
* External-to-Internal communications
In this article, we dive into Container-to-Container communications, by showing you ways in which containers within a pod can network and communicate.
### Communication Between Containers in a Pod
Having multiple containers in a single Pod makes it relatively straightforward for them to communicate with each other. They can do this using several different methods. In this article, we discuss two methods: i- Shared Volumes and ii-Inter-Process Communications in more detail.
#### **I- Shared Volumes in a Kubernetes Pod**
In Kubernetes, you can use a shared Kubernetes Volume as a simple and efficient way to share data between containers in a Pod. For most cases, it is sufficient to use a directory on the host that is shared with all containers within a Pod.
Kubernetes Volumes enables data to survive container restarts, but these volumes have the same lifetime as the Pod. This means that the volume (and the data it holds) exists exactly as long as that Pod exists. If that Pod is deleted for any reason, even if an identical replacement is created, the shared Volume is also destroyed and created from scratch.
A standard use case for a multicontainer Pod with a shared Volume is when one container writes logs or other files to the shared directory, and the other container reads from the shared directory. For example, we can create a Pod like so:
![][2]
In this example, we define a volume named html. Its type is emptyDir, which means that the Volume is first created when a Pod is assigned to a node and exists as long as that Pod is running on that node; as the name says, it is initially empty. The first container runs the Nginx server and has the shared Volume mounted to the directory /usr/share/nginx/html. The second container uses the Debian image and has the shared Volume mounted to the directory /html. Every second, the second container adds the current date and time into the index.html file, which is located in the shared Volume. When the user makes an HTTP request to the Pod, the Nginx server reads this file and transfers it back to the user in response to the request. [Here][3] is a good article for reading more on similar Kubernetes topics.
<https://cdn.thenewstack.io/media/2020/11/d5362cd2-image1.png>
You can check that the pod is working either by exposing the nginx port and accessing it using your browser, or by checking the shared directory directly in the containers:
#### **![][4]**
#### **II- Inter-Process Communications (IPC)**
Containers in a Pod share the same IPC namespace, which means they can also communicate with each other using standard inter-process communications such as SystemV semaphores or POSIX shared memory. Containers use the strategy of the localhost hostname for communication within a pod.
In the following example, we define a Pod with two containers. We use the same Docker image for both. The first container is a producer that creates a standard Linux message queue, writes a number of random messages, and then writes a special exit message. The second container is a consumer which opens that same message queue for reading and reads messages until it receives the exit message. We also set the restart policy to “Never”, so the Pod stops after the termination of both containers.
![][5]
To check this out, create the pod using kubectl create and watch the Pod status:
![][6]
Now you can check logs for each container and verify that the second container received all messages from the first container, including the exit message:
![][7]
<https://cdn.thenewstack.io/media/2020/11/6517d90b-image2.png>
There is one major problem with this Pod, however, and it has to do with how containers start up.
### **Conclusion**
The primary reason that Pods can have multiple containers is to support helper applications that assist a primary application. Typical examples of helper applications are data pullers, data pushers and proxies. An example of this pattern is a web server with a helper program that polls a git repository for new updates.
The Volume in this exercise provides a way for containers to communicate during the life of the Pod. If the Pod is deleted and recreated, any data stored in the shared Volume is lost. In this article, we also discussed the concept of Inter-Process Communications among containers within a Pod, which is an alternative to shared Volume concepts. Now that you learn how containers inside a Pod can communicate and exchange data, you can move on to learn other Kubernetes networking models — such as Pod-to-Pod or Pod-to-Service communications. [Here][8] is a good article for learning more advanced topics on Kubernetes development.
### **About the Authors**
**Matt Zand**
Matt is is a serial entrepreneur and the founder of three successful tech startups: DC Web Makers, Coding Bootcamps and High School Technology Services. He is a leading author of Hands-on Smart Contract Development with Hyperledger Fabric book by OReilly Media.
**Jim Sullivan**
Jim has a bachelors degree in Electrical Engineering and a Masters Degree in Computer Science. Jim also holds an MBA. Jim has been a practicing software engineer for 18 years. Currently, Jim leads an expert team in Blockchain development, DevOps, Cloud, application development, and the SAFe Agile methodology. Jim is an IBM Master Instructor.
The post [Review of Container-to-Container Communications in Kubernetes][9] appeared first on [Linux Foundation Training][10].
--------------------------------------------------------------------------------
via: https://www.linux.com/news/review-of-container-to-container-communications-in-kubernetes/
作者:[LF Training][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://training.linuxfoundation.org/announcements/review-of-container-to-container-communications-in-kubernetes/
[b]: https://github.com/lujun9972
[1]: https://thenewstack.io/review-of-container-to-container-communications-in-kubernetes/
[2]: https://training.linuxfoundation.org/wp-content/uploads/2020/12/fig1-300x243.png
[3]: https://myhsts.org/tutorial-review-of-17-essential-topics-for-mastering-kubernetes.php
[4]: https://training.linuxfoundation.org/wp-content/uploads/2020/12/fig2-300x54.png
[5]: https://training.linuxfoundation.org/wp-content/uploads/2020/12/fig3-300x130.png
[6]: https://training.linuxfoundation.org/wp-content/uploads/2020/12/fig4-300x54.png
[7]: https://training.linuxfoundation.org/wp-content/uploads/2020/12/fig5-300x129.png
[8]: https://blockchain.dcwebmakers.com/blog/advance-topics-for-deploying-and-managing-kubernetes-containers.html
[9]: https://training.linuxfoundation.org/announcements/review-of-container-to-container-communications-in-kubernetes/
[10]: https://training.linuxfoundation.org/

View File

@ -0,0 +1,155 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Install Privacy-friendly WhatsApp Alternative Signal on Linux Desktop)
[#]: via: (https://itsfoss.com/install-signal-ubuntu/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
Install Privacy-friendly WhatsApp Alternative Signal on Linux Desktop
======
Its been more than a year [since we covered Signal as an ideal choice for instant messaging][1]. While privacy-aware and tech-savvy people were already aware of the existence of this awesome application, [Signal][2] got the much deserved fame after the latest WhatsApp privacy policy updates.
Whatever maybe the reason if you are new to Signal and you are wondering if you can use Signal on desktop, the answer is yes. You can install Signal on Linux, Windows and macOS systems along with your smartphone.
![Signal Messenger on Pop OS Linux distribution][3]
I am not going to highlight the features Signal offers because you might already be aware of them. I am going to show you different methods of installing Signal application Linux desktop:
* Install Signal on Linux using Snap (snap applications take longer to load but get automatic update and hassle-free installation)
* Install Signal on Debian and Ubuntu-based distributions using apt (additional efforts in adding the repository but installed apps get automatic updates)
* Install Signal on Arch and Manjaro Linux using AUR
* Install Signal on Fedora and other Linux using Flatpak package
You can choose one of the methods based on your distribution and preference:
### Method 1: Installing Signal on Ubuntu and other Linux using Snap
If you are using Ubuntu, you can find Signal desktop app in Snap package format in the Software Center.
![][4]
Alternatively, you can [use the Snap command][5] to install Signal on any [Linux distribution that has Snap support][6] enabled.
```
sudo snap install signal-desktop
```
You can remove it using `snap remove` or from the Software Center.
Some people do not like Snap packages because they take too long to start. The good news is that you can use apt command to install Signal. The next section discusses that.
### Method 2: Install Signal on Debian and Ubuntu-based distributions via APT (using official Signal repository)
Here are the steps you have to follow to install Signal from its official repository on Debian, Debian, Linux Mint, elementary OS and other distributions based on Debian/Ubuntu. You can [copy the commands and paste it in the terminal][7].
First thing is to get the GPG key for the official Signal repository and add it to the trusted keys of your APT package manager.
```
wget -O- https://updates.signal.org/desktop/apt/keys.asc | sudo apt-key add -
```
With the key added, you can safely add the repository to your system. _**Dont get alarmed with the use of xenial in the repository name**_. It will work with Ubuntu 18.04, 20.04 and newer version as well as Debian, Mint etc.
```
echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list
```
Thanks to the [tee command in Linux][8], youll have a new file `signal-xenial.list` in the sources.list directory `/etc/apt/sources.list.d`. This new file will have the Signal repository information i.e. `deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main`.
Now that you have added the repository, update the cache and install Signal desktop application:
```
sudo apt update && sudo apt install signal-desktop
```
Once installed, look for Signal in application menu and start it.
![][9]
Since you have added the repository, your installed Signal application will be automatically updated with the regular system updates.
Enjoy encrypted messaging with Signal on your Linux desktop.
#### Removing Signal
The tutorial wont be complete if I dont share the removal steps with you. Lets go through it.
First, remove the application:
```
sudo apt remove signal-desktop
```
You may leave it as it is, or you may remove the Signal repository from your system. Its optional and up to you. With the repository still in the system, you can install Signal again, easily. If you remove the repository, youll have to add it again following the steps in the previous section.
If you want to remove the Signal repository as well, you can opt for the graphical method by going to Software and Updated tool and deleting it from there.
![][10]
Alternatively, you can remove the file with rm command:
```
rm -i /etc/apt/sources.list.d/signal-xenial.list
```
### Method 3: Installing Signal on Arch and Manjaro from AUR
Signal is available to install on [Arch-based Linux distributions][11] via [AUR][12]. If you are using Pamac on Manjaro and have enabled AUR, you should find Signal in the package manager.
Otherwise, you can always [use an AUR helper][13].
```
sudo yay -Ss <package-name>
```
I believe you can delete Signal in the similar function.
### Method 4: Installing Signal on Fedora and other Linux using Flatpak
There is no .rpm file for Signal. However, a [Flatpak package is available][14], and you may use that to get Signal on Fedora.
```
flatpak install flathub org.signal.Signal
```
Once installed, you can run it from the menu or use the following command in the terminal:
```
flatpak run org.signal.Signal
```
Signal and Telegram are two mainstream and viable options to ditch WhatsApp. Both provide native Linux desktop applications. If you use Telegram, you can [join the official Its FOSS channel][15]. I use Signal in individual capacity because it doesnt have the channel feature yet.
--------------------------------------------------------------------------------
via: https://itsfoss.com/install-signal-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://itsfoss.com/signal-messaging-app/
[2]: https://signal.org/
[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/signal-shot.jpg?resize=800%2C565&ssl=1
[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/signal-desktop-ubuntu.png?resize=800%2C425&ssl=1
[5]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/
[6]: https://itsfoss.com/install-snap-linux/
[7]: https://itsfoss.com/copy-paste-linux-terminal/
[8]: https://linuxhandbook.com/tee-command/
[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2021/01/signal-app-in-ubuntu.jpg?resize=795%2C230&ssl=1
[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/remove-signal-repository.png?resize=800%2C401&ssl=1
[11]: https://itsfoss.com/arch-based-linux-distros/
[12]: https://itsfoss.com/aur-arch-linux/
[13]: https://itsfoss.com/best-aur-helpers/
[14]: https://flathub.org/apps/details/org.signal.Signal
[15]: https://t.me/joinchat/AAAAAEPRGUJrEE1itjpH6A

View File

@ -0,0 +1,210 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Looking to Ditch WhatsApp? Here are 5 Better Privacy Alternatives to WhatsApp)
[#]: via: (https://itsfoss.com/private-whatsapp-alternatives/)
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
Looking to Ditch WhatsApp? Here are 5 Better Privacy Alternatives to WhatsApp
======
After the latest [WhatsApp privacy policy updates][1], many users who trusted the service seem to be making the switch to alternatives like [Signal][2].
Even though WhatsApp tries to clarify and re-assure the change in the policies, users have made their mind while considering the benefits of using privacy alternatives to WhatsApp.
But, what are some useful and impressive alternatives to WhatsApp? In this article, let us take a look at some of the best options.
### Private messengers that do not violate your privacy
![][3]
There could be plenty of private messaging services. I have kept my focus on messaging services with the following criteria in mind:
* Mobile and desktop availability
* Group chats and channels
* Voice and video calls
* Emojis and sticker support
* Privacy and encryption
Basically, private messaging app that cater to the need of a common user.
#### 1\. Session
![][4]
**Key Features:**
* End-to-end Encryption
* Blockchain-based
* Decentralized
* Does not require phone number
* No data collected by Session
* Lets you create and manage open/closed groups (open groups are public channels)
* Voice messages
* Cross-platform with desktop apps
* **Open-Source**
Session is technically a fork of Signal and tries to go one step further by not requiring phone numbers. It isnt a typical WhatsApp replacement but if you want something different with privacy options, this could be it.
You will have to create a Session ID (that you can share to add contacts or ask your contacts to share theirs). If you delete the app, you will lose your ID, so you need to keep your recovery pass safely.
Unlike Signal, it does not rely on a centralized server but blockchain-based, i.e. decentralized. Thats good for reliability technically, but Ive noticed some significant delays in sending/receiving messages.
If youre tech-savvy, and want the absolute best for privacy, this could be it. But, it may not be a great option for elders and general consumers. For more information, you can check out my original [Session overview][5].
[Session][6]
#### 2\. Signal
![][7]
**Key Features:**
* End-to-End encryption
* Almost no data collection (Except your phone number)
* Supports Emojis and Stickers
* Lets you create and manage Groups
* Voice/Video calling supported
* Cross-platform support with desktop apps
* **Open-Source**
Signal is my personal favorite when it comes to privacy alternatives to WhatsApp. Ive made the switch for years, but I didnt have all my contacts in Signal. Fast-forward to 2021, I have most of my contacts on Signal.
Signal is the best blend of open-source and privacy. Theyve improved a lot over the years and is safe to assume as a perfect alternative to WhatsApp. You get almost every essential feature compared to WhatsApp.
However, just because it does not store your data, you may not be able to access all the messages of your smartphone on Desktop. In addition to that, it relies on local backup (which is protected by a passphrase) instead of cloud backups. So, you will have to head to the settings, start the backup, safely copy the passcode of the backup, check where the local backup gets stored, and make sure you dont delete it.
You can explore more about Signal in our [original coverage][2] and learn [how to install Signal in Linux][8].
[Signal][9]
**Recommended Read:**
![][10]
#### [9 Decentralized, P2P and Open Source Alternatives to Mainstream Social Media Platforms Like Twitter, Facebook, YouTube and Reddit][11]
#### 3\. Telegram
![][12]
**Key Features:**
* End-to-end Encryption (with Secret chat option)
* Cloud-based (no need to back up your chats, its all in the cloud)
* Ability to create public channels
* Create and manage groups
* Voice/Video Call
* Offers a better privacy policy to WhatsApp
* Supports Emojis and Stickers
* **Client-side Open-Source**
Telegram may not be the best bet for privacy, but it is certainly better than WhatsApp in several regards.
By default, the chats arent end-to-end encrypted but the convenience of having all the history in the cloud without needing to backup while having the secret chat option for encryption is a good deal for common consumers.
Not just limited to that, you also get native desktop apps and the client-side apps are open-source.
Of course, I wont recommend it over others for privacy-conscious users, but sometimes you just need a messenger that works, offers convenience, and respects the users privacy even if the chats are stored in the cloud.
[Telegram][13]
#### 4\. Threema (Paid)
![][14]
**Key Features:**
* End-to-end Encryption
* Does not require a phone number
* Lets you create and manage groups
* Ability to add polls
* Voice/Video calls
* **Switzerland-based** (known for best privacy policies)
* Cross-platform (with Threema Web for PC, no native desktop apps)
* **Open-Source**
Threema was among the best choices in the list of private messengers available out there. Initially, it wasnt open-source, which was a bummer.
But, now, Threema is completely open-source!
Threema offers the best features that youd always want in a messenger. However, it is a paid-only app.
Of course, if your friends/contacts do not mind paying for one of the best privacy alternatives to WhatsApp, you can easily recommend them this!
[Threema][15]
#### 5\. Element
![][16]
**Key Features:**
* End-to-end Encryption
* Does not require phone number
* Supports creating large public groups and closed groups as well
* Utilizes Decentralized [Matrix network][17]
* Voice/Video Calls
* Cross-platform with desktop apps
* **Open-Source**
Element is yet another fantastic WhatsApp alternative that is built keeping privacy in mind. It may not be a perfect replacement for a few contacts but if youre looking for an “All in One” platform for personal messaging and work as well, Element can be the perfect pick.
It was originally known as [Riot, and then it rebranded to Element][18]. Do note that it can be a little overwhelming if you wanted a simple alternative, but its great for privacy and security.
[Element][19]
### Wrapping Up
With the transparent policy updates to WhatsApp, more users are getting aware about the disadvantages of using a product owned by big tech companies. Hence, we need WhatsApp alternatives more than ever.
Of course, it is not easy to switch and convince other less tech-savvy users. But, it is certainly worth it.
What do you think about the best WhatsApp alternatives which offer better privacy? Let me know your thoughts in the comments below.
--------------------------------------------------------------------------------
via: https://itsfoss.com/private-whatsapp-alternatives/
作者:[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://fossbytes.com/whatsapp-privacy-policy-update/
[2]: https://itsfoss.com/signal-messaging-app/
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/messaging-services.jpg?resize=800%2C450&ssl=1
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/session-cross-platform.jpg?resize=800%2C444&ssl=1
[5]: https://itsfoss.com/session-messenger/
[6]: https://getsession.org/
[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2021/01/signal-messenger-new.jpg?resize=800%2C450&ssl=1
[8]: https://itsfoss.com/install-signal-ubuntu/
[9]: https://www.signal.org/
[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/1984-quote.png?fit=800%2C450&ssl=1
[11]: https://itsfoss.com/mainstream-social-media-alternaives/
[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/telegram-messenger.jpg?resize=800%2C450&ssl=1
[13]: https://telegram.org/
[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2021/01/threema.jpg?resize=800%2C450&ssl=1
[15]: https://threema.ch/
[16]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/element-apps.jpg?resize=799%2C480&ssl=1
[17]: https://matrix.org/
[18]: https://itsfoss.com/riot-to-element/
[19]: https://element.io/

View File

@ -1,72 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (stevenzdg988)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Top articles for learning Python in 2020)
[#]: via: (https://opensource.com/article/19/12/learn-python)
[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg)
2020 年学习 Python 的热门文章
======
无论您在Python编程过程中处于什么阶段**Opensource.com** 在2019年发布的Python热门文章将会对您有很大帮助。
![Hands on a keyboard with a Python book][1] ?[Python 手书][1]
Python 在 2019 年是丰收的一年。根据 [GitHub][2] 和 [Stack Overflow][3] 的受欢迎资源程度来看,它正在成为全球第二大流行语言。
> “ Python 是增长最快的程序设计语言,在我们的调查中发现它再次在程序设计语言中排名上升,今年排在 Java 之前,成为第二大最受欢迎的程序设计语言(仅次于 Rust )。”
> — [Stack Overflow Insights][3] [堆栈溢出顿悟][3]
同样Python 在 **Opensource.com** 上的读者人数呈跳跃式激增。 以下是按主题分组的 2019 年以来最热门的 Python 文章,供您仔细阅读。
### 为什么选择 Python
在众多的程序设计语言中,是什么使 Python 成为首选呢? 从大多数阅读的文章阅读量来看,那就是因为它的灵活性。 正如 Jigyasa Grover 解释的那样Python 开发人员可以访问 [多功能范例][4],包括流行的 [面向对象程序设计][5] 的 Seth Kenlon 教程。
如果您是 Python 的长期用户并且正在寻找 Python 为什么是完美的程序设计语言的例子,那么可以看 Moshe Zadka 的 [喜欢Python的5大理由][6]。 如果这还不够的话,您也可以使用功能强大的工具来尝试,无需编写大量代码,例如 Parul Pandey 关于 [图像处理][7] 的教程。
### 配置 Python
随着 Python 的受欢迎程度不断提高,使用它的人越来越多。这些新手中的许多人是利用 Mac 操作系统,并且正在使用 Moshe 和我写的[Python3配置向导][8]。
安装Python之后然后决定利用什么工具编写代码。关于文本编辑器和集成开发环境IDE有很多选择但是读者似乎更喜欢图形界面在 2019 年阅读有关该主题的文章中史蒂芬·阿文维德Stephan Avenwedde的关于 [Pythonic][9] 和我的关于 [JupyterLab][10] 的读者最多。
在对程序设计语言充满信心的途径上开发人员将不得不采用众多可选项来管理程序设计语言版本和项目依赖项。幸运的是László Kiss Kollár 的文章 [Python 包管理][11] 让其变得更加容易。
当您准备配置 IDE 时,充分利用该语言的所有功能,请确保尝试 Moshe 的 [opinionated linter Black][12],以保持代码的清洁。
### 小结
无论您处在 Python 程序设计的哪个阶段2019年以来的热门 Python 文章都将为您提供帮助。 在没有进行关键测试确认的情况下我无法对此进行总结为此目的Moshe 提供了另一本广为阅读的文章 [on tox][13]。
感谢所有在 2019 年为 Opensource.com 撰写的作者!如果您正在学习利用 Python 编程,请在评论中告诉我们您想知道的内容。而如果您是经验丰富的老手,请考虑通过 [writing an article][14] 与您感兴趣的 Python 主题来与我们分享您的技巧和窍门。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/12/learn-python
作者:[Matthew Broberg][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/stevenzdg988)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/mbbroberg
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd (Hands on a keyboard with a Python book )
[2]: https://octoverse.github.com/#top-languages
[3]: https://insights.stackoverflow.com/survey/2019
[4]: https://opensource.com/article/19/10/python-programming-paradigms
[5]: https://opensource.com/article/19/7/get-modular-python-classes
[6]: https://opensource.com/article/19/10/why-love-python
[7]: https://opensource.com/article/19/3/python-image-manipulation-tools
[8]: https://opensource.com/article/19/5/python-3-default-mac
[9]: https://opensource.com/article/19/5/graphically-programming-pythonic
[10]: https://opensource.com/article/19/5/jupyterlab-python-developers-magic
[11]: https://opensource.com/article/19/4/managing-python-packages
[12]: https://opensource.com/article/19/5/python-black
[13]: https://opensource.com/article/19/5/python-tox
[14]: https://opensource.com/how-submit-article