diff --git a/published/20190222 Developer happiness- What you need to know.md b/published/20190222 Developer happiness- What you need to know.md new file mode 100644 index 0000000000..706599ea05 --- /dev/null +++ b/published/20190222 Developer happiness- What you need to know.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (chenmu-kk) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12497-1.html) +[#]: subject: (Developer happiness: What you need to know) +[#]: via: (https://opensource.com/article/19/2/developer-happiness) +[#]: author: (Bart Copeland https://opensource.com/users/bartcopeland) + +开发者的福音:你需要知道的事 +====== + +> 开发者需要快速编程的工具和自由,而不会因为合规性和安全性所困扰。 + +![](https://img.linux.net.cn/data/attachment/album/202008/07/214051ki2zitovo8zzynco.jpg) + +一个人需要合适的工具来完成工作。比如说没有比修车修到一半,却发现你没有完成工作的专业工具更沮丧的事情了。同样的道理也适用在开发者身上:你需要工具来发挥你的才能,而不会因为合规性和安全性的需求打断你的工作流程,这样你才可以更快速地编码。 + +根据 ActiveState 的研究《[2018 年开发者调查:开源运行时的痛苦][1]》显示,超过一半的开发人员(具体为 51%),每天只需要花费 1-4 小时的时间进行编程。换句话说,大多数开发人员花费不到一半的时间编程。根据调查,一半的开发人员认为安全是他们最大的担忧之一,但是由于公司政策方面的原因,67% 的开发人员选择在编程时不添加新的语言。 + +结果是开发人员不得不投入更多的精力在非编码的活动上,例如在构建软件和语言之后检查软件的安全性和合规性标准。而且由于公司政策的原因,他们无法选择适合的开发工具或语言。他们的满意度会下降,同时风险提高。 + +因此,开发人员无法将时间投入在高价值的工作上。这会带来额外的商业风险,因为他们的软件上市时间变慢了,并且公司因为没有授权开发人员在不受公司政策影响的前提下决定“最佳的”技术的能力,从而增加了技术债务。 + +### 纳入安全性和合规性的工作流程 + +我们如何解决这个问题呢?一种方式是通过四个简单的步骤将安全性和合规性的工作流程集成到软件开发中: + +#### 1、集中你的力量 + +获得所有相关人员的支持,这是一个经常被遗忘但却至关重要的第一步。确保考虑到了广泛的利益相关者,包括: + + * 开发运维(DevOps) + * 开发人员 + * 信息安全 + * 合法/合规 + * IT 安全 + +利益相关者想要了解相关的商业利益,因此要为消除软件构建后的安全和合规性检查点提供坚实的理由。你可以在构建你的商业案例中考虑以下任何一个(或者全部)因素:节省时间、机会成本和开发人员生产力。在开发流程中,你也可以通过集成安全性和合规性来避免语言的改造。 + +#### 2、寻找可信赖的资源 + +接下来,选择可使用的可信资源,以及他们的许可证和安全要求。考虑到如下相关信息: + + * 基于环境或应用程序类型的使用限制以及每种语言的版本控制 + * 允许哪些开源组件,例如,特定的程序包 + * 哪种环境类型可以使用哪种许可证(例如,研究与生产) + * 安全级别的定义、可接受的脆弱性风险等级、什么样的风险级别会触发一个措施,这个措施是什么并且谁来负责它的执行 + +#### 3、从一开始就纳入安全性和合规性 + +纳入安全性和合规性的工作流程的结果是,它最终将安全性和合规性融入到代码的第一行。它消除了公司政策的拖累,因为你是按照规范进行编码,而不是必须事后解决问题。但要做到这一点,请考虑在构建代码时采用自动扫描代码的机制,以及使用无代理监控你的运行时代码。你可以节省时间,还可以通过编程实施策略来确保整个组织的合规性。 + +#### 4、监控、报告和更新 + +出现新的漏洞,新的补丁和版本也会出现。所以,将代码部署到生产中以及运行代码时,需要考虑安全性和合规性。你需要知道哪些(如果有的话)代码存在风险以及该代码在何处运行。所以,部署和运行代码的过程应该包括监视、报告和更新生产中的代码。 + +通过一开始就在你的软件开发过程中集成安全性和合规性,你还可以在部署后跟踪代码的运行位置,并在新的威胁出现时获得警报。你也能追踪当你的应用程序何时受到攻击,并通过自动执行软件策略做出响应。 + +如果你的软件开发过程中已经引入了安全性和合规性的工作流程,你将会提高你的生产率。你将能够通过增加编码时间、提高安全性和稳定性、以及在维护和发现安全性和合规性的威胁方面节省的成本和时间来衡量价值。 + +### 集成所带来的幸福 + +如果你不开发和更新软件,你的组织将无法前进。开发人员是公司成功的关键,这意味着他们需要快速编写代码的工具和自由。尽管合规性和安全性至关重要,但你不能让这个需求阻碍你的发展。开发人员显然很担心安全性,因此最好的办法就是“左移”,从一开始就集成安全性和合规性的工作流程。你将可以做更多的事情,在第一次就可以完成,而花费更少的时间进行代码更新。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/developer-happiness + +作者:[Bart Copeland][a] +选题:[lujun9972][b] +译者:[chenmu-kk](https://github.com/chenmu-kk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bartcopeland +[b]: https://github.com/lujun9972 +[1]: https://www.activestate.com/company/press/press-releases/activestate-developer-survey-examines-open-source-challenges/ diff --git a/published/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md b/published/201912/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md similarity index 100% rename from published/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md rename to published/201912/20171027 Share And Upload Files To Compatible Hosting Sites Automatically.md diff --git a/published/20180207 23 open source audio-visual production tools.md b/published/201912/20180207 23 open source audio-visual production tools.md similarity index 100% rename from published/20180207 23 open source audio-visual production tools.md rename to published/201912/20180207 23 open source audio-visual production tools.md diff --git a/published/20181018 Think global- How to overcome cultural communication challenges.md b/published/201912/20181018 Think global- How to overcome cultural communication challenges.md similarity index 100% rename from published/20181018 Think global- How to overcome cultural communication challenges.md rename to published/201912/20181018 Think global- How to overcome cultural communication challenges.md diff --git a/published/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md b/published/201912/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md similarity index 100% rename from published/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md rename to published/201912/20181231 Easily Upload Text Snippets To Pastebin-like Services From Commandline.md diff --git a/published/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md b/published/201912/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md similarity index 100% rename from published/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md rename to published/201912/20190217 Install Android 8.1 Oreo on Linux To Run Apps - Games.md diff --git a/published/20190225 Netboot a Fedora Live CD.md b/published/201912/20190225 Netboot a Fedora Live CD.md similarity index 100% rename from published/20190225 Netboot a Fedora Live CD.md rename to published/201912/20190225 Netboot a Fedora Live CD.md diff --git a/published/20190322 Easy means easy to debug.md b/published/201912/20190322 Easy means easy to debug.md similarity index 100% rename from published/20190322 Easy means easy to debug.md rename to published/201912/20190322 Easy means easy to debug.md diff --git a/published/20190513 How To Set Password Complexity On Linux.md b/published/201912/20190513 How To Set Password Complexity On Linux.md similarity index 100% rename from published/20190513 How To Set Password Complexity On Linux.md rename to published/201912/20190513 How To Set Password Complexity On Linux.md diff --git a/published/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md b/published/201912/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md similarity index 100% rename from published/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md rename to published/201912/20190602 How to Install LEMP (Linux, Nginx, MariaDB, PHP) on Fedora 30 Server.md diff --git a/published/20190711 DevOps for introverted people.md b/published/201912/20190711 DevOps for introverted people.md similarity index 100% rename from published/20190711 DevOps for introverted people.md rename to published/201912/20190711 DevOps for introverted people.md diff --git a/published/20190725 24 sysadmin job interview questions you should know.md b/published/201912/20190725 24 sysadmin job interview questions you should know.md similarity index 100% rename from published/20190725 24 sysadmin job interview questions you should know.md rename to published/201912/20190725 24 sysadmin job interview questions you should know.md diff --git a/published/20190827 curl exercises.md b/published/201912/20190827 curl exercises.md similarity index 100% rename from published/20190827 curl exercises.md rename to published/201912/20190827 curl exercises.md diff --git a/published/20190927 5 tips for GNU Debugger.md b/published/201912/20190927 5 tips for GNU Debugger.md similarity index 100% rename from published/20190927 5 tips for GNU Debugger.md rename to published/201912/20190927 5 tips for GNU Debugger.md diff --git a/published/20191004 What-s in an open source name.md b/published/201912/20191004 What-s in an open source name.md similarity index 100% rename from published/20191004 What-s in an open source name.md rename to published/201912/20191004 What-s in an open source name.md diff --git a/published/20191007 Using the Java Persistence API.md b/published/201912/20191007 Using the Java Persistence API.md similarity index 100% rename from published/20191007 Using the Java Persistence API.md rename to published/201912/20191007 Using the Java Persistence API.md diff --git a/published/20191017 How to type emoji on Linux.md b/published/201912/20191017 How to type emoji on Linux.md similarity index 100% rename from published/20191017 How to type emoji on Linux.md rename to published/201912/20191017 How to type emoji on Linux.md diff --git a/published/20191017 Using multitail on Linux.md b/published/201912/20191017 Using multitail on Linux.md similarity index 100% rename from published/20191017 Using multitail on Linux.md rename to published/201912/20191017 Using multitail on Linux.md diff --git a/published/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md b/published/201912/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md similarity index 100% rename from published/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md rename to published/201912/20191020 14 SCP Command Examples to Securely Transfer Files in Linux.md diff --git a/published/20191022 How to program with Bash- Logical operators and shell expansions.md b/published/201912/20191022 How to program with Bash- Logical operators and shell expansions.md similarity index 100% rename from published/20191022 How to program with Bash- Logical operators and shell expansions.md rename to published/201912/20191022 How to program with Bash- Logical operators and shell expansions.md diff --git a/published/20191023 How to program with Bash- Loops.md b/published/201912/20191023 How to program with Bash- Loops.md similarity index 100% rename from published/20191023 How to program with Bash- Loops.md rename to published/201912/20191023 How to program with Bash- Loops.md diff --git a/published/20191024 Get sorted with sort at the command line.md b/published/201912/20191024 Get sorted with sort at the command line.md similarity index 100% rename from published/20191024 Get sorted with sort at the command line.md rename to published/201912/20191024 Get sorted with sort at the command line.md diff --git a/published/20191028 6 signs you might be a Linux user.md b/published/201912/20191028 6 signs you might be a Linux user.md similarity index 100% rename from published/20191028 6 signs you might be a Linux user.md rename to published/201912/20191028 6 signs you might be a Linux user.md diff --git a/published/20191028 How to remove duplicate lines from files with awk.md b/published/201912/20191028 How to remove duplicate lines from files with awk.md similarity index 100% rename from published/20191028 How to remove duplicate lines from files with awk.md rename to published/201912/20191028 How to remove duplicate lines from files with awk.md diff --git a/published/20191101 Awk one-liners and scripts to help you sort text files.md b/published/201912/20191101 Awk one-liners and scripts to help you sort text files.md similarity index 100% rename from published/20191101 Awk one-liners and scripts to help you sort text files.md rename to published/201912/20191101 Awk one-liners and scripts to help you sort text files.md diff --git a/published/20191113 Edit images on Fedora easily with GIMP.md b/published/201912/20191113 Edit images on Fedora easily with GIMP.md similarity index 100% rename from published/20191113 Edit images on Fedora easily with GIMP.md rename to published/201912/20191113 Edit images on Fedora easily with GIMP.md diff --git a/published/20191114 Debugging Software Deployments with strace.md b/published/201912/20191114 Debugging Software Deployments with strace.md similarity index 100% rename from published/20191114 Debugging Software Deployments with strace.md rename to published/201912/20191114 Debugging Software Deployments with strace.md diff --git a/published/20191115 How to port an awk script to Python.md b/published/201912/20191115 How to port an awk script to Python.md similarity index 100% rename from published/20191115 How to port an awk script to Python.md rename to published/201912/20191115 How to port an awk script to Python.md diff --git a/published/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md b/published/201912/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md similarity index 100% rename from published/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md rename to published/201912/20191116 6 Methods to Quickly Check if a Website is up or down from the Linux Terminal.md diff --git a/published/20191118 How internet security works- TLS, SSL, and CA.md b/published/201912/20191118 How internet security works- TLS, SSL, and CA.md similarity index 100% rename from published/20191118 How internet security works- TLS, SSL, and CA.md rename to published/201912/20191118 How internet security works- TLS, SSL, and CA.md diff --git a/published/20191119 Top 10 Vim plugins for programming in multiple languages.md b/published/201912/20191119 Top 10 Vim plugins for programming in multiple languages.md similarity index 100% rename from published/20191119 Top 10 Vim plugins for programming in multiple languages.md rename to published/201912/20191119 Top 10 Vim plugins for programming in multiple languages.md diff --git a/published/20191120 Switching from Python 2 to Python 3- What you need to know.md b/published/201912/20191120 Switching from Python 2 to Python 3- What you need to know.md similarity index 100% rename from published/20191120 Switching from Python 2 to Python 3- What you need to know.md rename to published/201912/20191120 Switching from Python 2 to Python 3- What you need to know.md diff --git a/published/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md b/published/201912/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md similarity index 100% rename from published/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md rename to published/201912/20191121 Bash Script to View System Information on Linux Every Time You Log into Shell.md diff --git a/published/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md b/published/201912/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md similarity index 100% rename from published/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md rename to published/201912/20191125 How to Install Ansible (Automation Tool) on CentOS 8-RHEL 8.md diff --git a/published/20191125 How to use loops in awk.md b/published/201912/20191125 How to use loops in awk.md similarity index 100% rename from published/20191125 How to use loops in awk.md rename to published/201912/20191125 How to use loops in awk.md diff --git a/published/20191125 The many faces of awk.md b/published/201912/20191125 The many faces of awk.md similarity index 100% rename from published/20191125 The many faces of awk.md rename to published/201912/20191125 The many faces of awk.md diff --git a/published/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md b/published/201912/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md similarity index 100% rename from published/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md rename to published/201912/20191126 5 Commands to Find the IP Address of a Domain in the Linux Terminal.md diff --git a/published/20191127 Create virtual machines with Cockpit in Fedora.md b/published/201912/20191127 Create virtual machines with Cockpit in Fedora.md similarity index 100% rename from published/20191127 Create virtual machines with Cockpit in Fedora.md rename to published/201912/20191127 Create virtual machines with Cockpit in Fedora.md diff --git a/published/20191127 How to write a Python web API with Flask.md b/published/201912/20191127 How to write a Python web API with Flask.md similarity index 100% rename from published/20191127 How to write a Python web API with Flask.md rename to published/201912/20191127 How to write a Python web API with Flask.md diff --git a/published/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md b/published/201912/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md similarity index 100% rename from published/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md rename to published/201912/20191127 Nvidia quietly unveils faster, lower power Tesla GPU accelerator.md diff --git a/published/20191129 A quick introduction to Toolbox on Fedora.md b/published/201912/20191129 A quick introduction to Toolbox on Fedora.md similarity index 100% rename from published/20191129 A quick introduction to Toolbox on Fedora.md rename to published/201912/20191129 A quick introduction to Toolbox on Fedora.md diff --git a/published/20191202 Use the Window Maker desktop on Linux.md b/published/201912/20191202 Use the Window Maker desktop on Linux.md similarity index 100% rename from published/20191202 Use the Window Maker desktop on Linux.md rename to published/201912/20191202 Use the Window Maker desktop on Linux.md diff --git a/published/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md b/published/201912/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md similarity index 100% rename from published/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md rename to published/201912/20191203 An idiot-s guide to Kubernetes, low-code developers, and other industry trends.md diff --git a/published/20191203 Using Ansible to organize your SSH keys in AWS.md b/published/201912/20191203 Using Ansible to organize your SSH keys in AWS.md similarity index 100% rename from published/20191203 Using Ansible to organize your SSH keys in AWS.md rename to published/201912/20191203 Using Ansible to organize your SSH keys in AWS.md diff --git a/published/20191203 Why use the Pantheon desktop for Linux Elementary OS.md b/published/201912/20191203 Why use the Pantheon desktop for Linux Elementary OS.md similarity index 100% rename from published/20191203 Why use the Pantheon desktop for Linux Elementary OS.md rename to published/201912/20191203 Why use the Pantheon desktop for Linux Elementary OS.md diff --git a/published/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md b/published/201912/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md similarity index 100% rename from published/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md rename to published/201912/20191204 Dell XPS 13 7390 Review- The Best Laptop For Desktop Linux Users.md diff --git a/published/201912/20191204 Fedora Desktops - Memory Footprints.md b/published/201912/20191204 Fedora Desktops - Memory Footprints.md new file mode 100644 index 0000000000..21ae866e77 --- /dev/null +++ b/published/201912/20191204 Fedora Desktops - Memory Footprints.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11733-1.html) +[#]: subject: (Fedora Desktops – Memory Footprints) +[#]: via: (https://fedoramagazine.org/fedora-desktops-memory-footprints/) +[#]: author: (Troy Dawson https://fedoramagazine.org/author/tdawson/) + +Fedora 上的桌面环境内存占用测试 +====== + +![][1] + +Fedora 中有 40 多种桌面环境(DE)。每种桌面环境都有自己的优点和缺点。通常,根据功能、外观和其它品质,选择桌面是一件非常个人的偏好。但有时,你选择的桌面环境还会受到硬件限制。 + +本文旨在帮助人们根据桌面环境占用的基准内存来比较 Fedora 桌面环境。为了缩小范围,我们仅查看具有正式 Fedora Live 镜像的桌面环境。 + +### 安装与系统配置 + +每个桌面环境都安装在自己的 KVM 虚拟机上。每个虚拟机都有 1 个 CPU、4GB 内存、15GB virtio 固态磁盘,以及 RHEL 8.0 kvm 上所有其他标准配置。 + +用于安装的镜像是标准的 Fedora 31 Live 镜像。对于 GNOME,该镜像是 “Fedora 工作站”。对于其它桌面,使用了相应的 Spin 版本。未对“糖葫芦Sugar On A Stick”(SOAS)进行测试,因为它不容易安装到本地驱动器上。 + +用 Live CD 启动虚拟机,然后选择“安装到硬盘”。在安装过程中,仅使用默认值。创建了一个 root 用户和一个普通用户。安装并重新启动后,live 镜像已确认不在虚拟 CDROM 中。 + +每个桌面环境的设置都没有改动。它们每个都以 Live CD 环境中默认的设置运行。每个桌面环境都是通过普通用户登录的。打开了一个终端,在每台虚拟机中都使用 `sudo` 运行了 `dnf -y update`。在更新后,在该 sudo 终端中,每台虚拟机都运行 `/sbin/shutdown -h now` 以关闭。 + +### 测试方式 + +每台机器都已启动。桌面环境已通过普通用户登录。打开了三个桌面终端。xterm 从未使用过,始终用的是该桌面环境的终端,例如 konsole。 + +在一个终端中,启动 `top` 并按下 `M`,以显示按内存排序的进程。在另一个终端中,一个简单的 `while` 循环每 30 秒显示一次 `free -m`。第三个终端闲置。 + +然后,我等待了 5 分钟。这样就可以让所有启动的服务都启动完成。我记录了最终的 `free` 结果,以及 `top` 中最终的前三名内存使用者。 + +### 结果 + + * Cinnamon + * 使用了624 MB + * cinnamon 4.8% / Xorg 2.2% / dnfdragora 1.8% + * GNOME + * 使用了 612 MB + * gnome-shell 6.9% / gnome-software 1.8% / ibus-x11 1.5% + * KDE + * 使用了 733 MB + * plasmashell 6.2% / kwin\_x11 3.6% / akonadi\_mailfil 2.9% + * LXDE + * 使用了 318 MB + * Xorg 1.9% / nm-applet 1.8% / dnfdragora 1.8% + * LXQt + * 使用了 391 MB + * lxqt-panel 2.2% / pcmanfm-qt 2.1% / Xorg 2.1% + * MATE + * 使用了 465 MB + * Xorg 2.5% / dnfdragora 1.8% / caja 1.5% + * XFCE + * 使用了 448 MB + * Xorg 2.3% / xfwm4 2.0% / dnfdragora 1.8% + + + +### 结论 + +我会让数字说明一切。 + +请记住,这些数字来自默认的 Live 安装环境。如果删除或添加服务和功能,则内存使用量将发生变化。但是,如果要根据内存消耗确定桌面环境,这是一个很好的基准。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-desktops-memory-footprints/ + +作者:[Troy Dawson][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/tdawson/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/11/desktop-memory-footprint-816x346.jpg diff --git a/published/20191204 Java vs. Python- Which should you choose.md b/published/201912/20191204 Java vs. Python- Which should you choose.md similarity index 100% rename from published/20191204 Java vs. Python- Which should you choose.md rename to published/201912/20191204 Java vs. Python- Which should you choose.md diff --git a/published/20191206 5 cool terminal pagers in Fedora.md b/published/201912/20191206 5 cool terminal pagers in Fedora.md similarity index 100% rename from published/20191206 5 cool terminal pagers in Fedora.md rename to published/201912/20191206 5 cool terminal pagers in Fedora.md diff --git a/published/20191206 6 Ways to Send Email from the Linux Command Line.md b/published/201912/20191206 6 Ways to Send Email from the Linux Command Line.md similarity index 100% rename from published/20191206 6 Ways to Send Email from the Linux Command Line.md rename to published/201912/20191206 6 Ways to Send Email from the Linux Command Line.md diff --git a/published/20191206 Pekwm- A lightweight Linux desktop.md b/published/201912/20191206 Pekwm- A lightweight Linux desktop.md similarity index 100% rename from published/20191206 Pekwm- A lightweight Linux desktop.md rename to published/201912/20191206 Pekwm- A lightweight Linux desktop.md diff --git a/published/20191207 Getting started with the GNOME Linux desktop.md b/published/201912/20191207 Getting started with the GNOME Linux desktop.md similarity index 100% rename from published/20191207 Getting started with the GNOME Linux desktop.md rename to published/201912/20191207 Getting started with the GNOME Linux desktop.md diff --git a/published/20191209 Counting down the days using bash.md b/published/201912/20191209 Counting down the days using bash.md similarity index 100% rename from published/20191209 Counting down the days using bash.md rename to published/201912/20191209 Counting down the days using bash.md diff --git a/published/20191210 3 easy steps to update your apps to Python 3.md b/published/201912/20191210 3 easy steps to update your apps to Python 3.md similarity index 100% rename from published/20191210 3 easy steps to update your apps to Python 3.md rename to published/201912/20191210 3 easy steps to update your apps to Python 3.md diff --git a/published/20191210 Breaking Linux files into pieces with the split command.md b/published/201912/20191210 Breaking Linux files into pieces with the split command.md similarity index 100% rename from published/20191210 Breaking Linux files into pieces with the split command.md rename to published/201912/20191210 Breaking Linux files into pieces with the split command.md diff --git a/published/20191210 Customize your Linux desktop with FVWM.md b/published/201912/20191210 Customize your Linux desktop with FVWM.md similarity index 100% rename from published/20191210 Customize your Linux desktop with FVWM.md rename to published/201912/20191210 Customize your Linux desktop with FVWM.md diff --git a/published/20191211 Annotate screenshots on Linux with Ksnip.md b/published/201912/20191211 Annotate screenshots on Linux with Ksnip.md similarity index 100% rename from published/20191211 Annotate screenshots on Linux with Ksnip.md rename to published/201912/20191211 Annotate screenshots on Linux with Ksnip.md diff --git a/published/20191211 How to Find High CPU Consumption Processes in Linux.md b/published/201912/20191211 How to Find High CPU Consumption Processes in Linux.md similarity index 100% rename from published/20191211 How to Find High CPU Consumption Processes in Linux.md rename to published/201912/20191211 How to Find High CPU Consumption Processes in Linux.md diff --git a/published/20191212 How to configure Openbox for your Linux desktop.md b/published/201912/20191212 How to configure Openbox for your Linux desktop.md similarity index 100% rename from published/20191212 How to configure Openbox for your Linux desktop.md rename to published/201912/20191212 How to configure Openbox for your Linux desktop.md diff --git a/published/20191213 What GNOME 2 fans love about the Mate Linux desktop.md b/published/201912/20191213 What GNOME 2 fans love about the Mate Linux desktop.md similarity index 100% rename from published/20191213 What GNOME 2 fans love about the Mate Linux desktop.md rename to published/201912/20191213 What GNOME 2 fans love about the Mate Linux desktop.md diff --git a/published/20191214 Get started with Lumina for your Linux desktop.md b/published/201912/20191214 Get started with Lumina for your Linux desktop.md similarity index 100% rename from published/20191214 Get started with Lumina for your Linux desktop.md rename to published/201912/20191214 Get started with Lumina for your Linux desktop.md diff --git a/published/201912/20191217 5 interview questions every Kubernetes job candidate should know.md b/published/201912/20191217 5 interview questions every Kubernetes job candidate should know.md new file mode 100644 index 0000000000..f6d0f6685f --- /dev/null +++ b/published/201912/20191217 5 interview questions every Kubernetes job candidate should know.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11730-1.html) +[#]: subject: (5 interview questions every Kubernetes job candidate should know) +[#]: via: (https://opensource.com/article/19/12/kubernetes-interview-questions) +[#]: author: (Jessica Repka https://opensource.com/users/jrepka) + +每个 Kubernetes 应聘者应该知道的 5 个面试题 +====== + +> 如果你是要面试 Kubernetes 相关职位的应聘者,这里给出了要提问的问题以及这些问题的重要性。 + +![](https://img.linux.net.cn/data/attachment/album/201912/31/101229mmjumsesrzhh6rhk.jpg) + +面试对面试官及候选人来说都很不容易。最近,我发现面试 Kubernetes 相关工作的候选人似乎尤其困难。为什么呢?一方面,很难找到可以回答他们问题的人。而且,不管回答者回答的怎样,都很难确定他们是否有正确的经验。 + +跳过这个问题,让我们来看看面试 [Kubernetes][2] 求职者时应该提问的一些问题。 + +### Kubernetes 是什么? + +我发现这个问题是面试中最好的问题之一。我经常听到有人说“我用 Kubernetes 工作”,但是当我问道“Kubernetes 是什么”时,从来都没有得到过一个满意答案。 + +我最喜欢 [Chris Short][3] 给出的答案:“Kubernetes 就是带有一些 YAML 文件的 API 。” + +虽然他的回答没有错,但我会给你更详细的解释。 Kubernetes 是一个可移植容器的编排工具,用于自动执行管理、监控、扩展和部署容器化应用程序。 + +我认为“用于部署容器化应用程序的编排工具”这个回答可能与你期望的答案差不多了。能回答出这个,我觉得已经很不错了。尽管许多人认为 Kubernetes 做了更多更棒的工作,但总的来说,它为其核心功能——容器编排——添加了许多 API。 + +我认为,这是你在面试中可以提问的最好的问题之一,因为它至少证明了候选人是否知道 Kubernetes 是什么。 + +### Kubernetes 的节点和 Pod 有什么区别? + +该问题揭示了候选人对 Kubernetes 复杂性的初步了解。它将面试对话转换为对体系结构的概述,并可能导向许多有趣的后续细节问题。我已经听到了无数次关于该问题的错误解释了。 + +[节点][4] 是工作计算机。该计算机可以是虚拟机(VM)或物理计算机,具体取决于你是在虚拟机监控程序上运行还是在裸机上运行。该节点包含用于运行容器的服务,包括 kubelet、kube-proxy 和容器运行时。 + +[Pod][5] 包括:一个或多个**容器**、具有共享**网络**和**存储**,以及有关如何运行一起部署的容器的**规范**。这四个细节都很重要。更进一步,职位申请人应从技术层面解释,Pod 是 Kubernetes 可以创建和管理的最小可部署单元,而不是容器。 + +对于这个问题,我听到的最好的简答是:“节点是计算机,而 Pod 是容器运行于其中的东西。”这个区别很重要。Kubernetes 管理员的大部分工作是知道什么时间要部署什么,而节点的部署成本可能非常非常高,具体取决于它们的运行位置。我不希望有人一遍又一遍地部署节点,他们需要做的就是部署一堆 Pod。 + +### kubectl 是什么?(你怎么发音?) + +这个问题是我优先级较高的问题之一,但可能与你和你的团队无关。在我的团队中,我们不会使用图形化界面来管理 Kubernetes 环境,我们使用命令行操作。 + +那么什么是 [kubectl][6]?它是 Kubernetes 的命令行界面。你可以从该界面获取并设置任何内容,从收集日志和事件到编辑部署环境和机密文件。随机提问候选人关于如何使用此工具对测试候选人对 kubectl 的熟悉度是很有帮助的。 + +你是怎么读的?好吧,你随便吧(对此有很大的分歧),但是我很高兴向你介绍我朋友 [Waldo][7] 的精彩视频演示。 + +### 命名空间是什么? + +在多次面试中,我都没有得到关于这个问题的答案。我不确定在其他环境中使用的命名空间是否会在我所在的团队经常使用。我在这里给出一个简短的答案:命名空间是 Pod 中的虚拟集群。这种抽象可以使你将多个虚拟集保留在多个环境中以此来进行隔离。 + +### 容器是什么? + +了解 Pod 中正在部署的内容总是有帮助的,因为如果都不知道其中部署的是什么,何谈部署?容器是打包代码及其所有依赖项的软件的标准单元。我收到了两个可以接受的答案,其中包括:a)精简的操作系统镜像,以及 b)在受限的操作系统环境中运行的应用程序。如果你可以叫得出使用 [Docker][8] 以外的其他容器的编排软件(例如你最喜欢的公共云的容器服务),则可以得到加分。 + +### 其他问题 + +如果你想知道为什么我没有在此问题列表中添加更多问题,那么我可以给出一个简单的答案:我所列出的这些问题是在面试候选人时应了解的最基本的问题。接下来的问题应该是基于具体的团队、环境及组织。当你仔细研究这些内容时,尝试寻找有关技术如何相互作用的有趣问题,以了解人们如何应对基础架构挑战。考虑一下你的团队最近遇到的挑战(中断),要求逐步进行部署,或者考虑改善团队积极想要改进的策略(例如减少部署时间)。问题越不抽象,对面试后真正重要的技能的询问就越多。 + +没有两个环境是完全相同的。这也适用于面试中。我在每次面试中都会混合提问。我也有一个测试面试者的小环境。我经常发现回答问题是最容易的部分,而你所做的工作才是对你的真正的考验。 + +我给面试官的最后一点建议是:如果你遇到一个很有潜力但没有经验的候选人时,请给他们一个证明自己的机会。如果当初没有人看到我的潜力,没有给我机会的话,我不会拥有今天的知识和经验。 + +还有哪些重要的问题?请留言告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/kubernetes-interview-questions + +作者:[Jessica Repka][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard.png?itok=kBeRTFL1 (Pair programming) +[2]: https://kubernetes.io/ +[3]: https://twitter.com/ChrisShort +[4]: https://kubernetes.io/docs/concepts/architecture/nodes/ +[5]: https://kubernetes.io/docs/concepts/workloads/pods/pod/ +[6]: https://kubernetes.io/docs/reference/kubectl/kubectl/ +[7]: https://opensource.com/article/18/12/kubectl-definitive-pronunciation-guide +[8]: https://opensource.com/resources/what-docker +[9]: https://enterprisersproject.com/article/2019/2/kubernetes-job-interview-questions-how-prepare diff --git a/published/20191217 Build a retro Apple desktop with the Linux MLVWM.md b/published/201912/20191217 Build a retro Apple desktop with the Linux MLVWM.md similarity index 100% rename from published/20191217 Build a retro Apple desktop with the Linux MLVWM.md rename to published/201912/20191217 Build a retro Apple desktop with the Linux MLVWM.md diff --git a/published/20191218 How tracking pixels work.md b/published/201912/20191218 How tracking pixels work.md similarity index 100% rename from published/20191218 How tracking pixels work.md rename to published/201912/20191218 How tracking pixels work.md diff --git a/published/20191220 How to Start, Stop - Restart Services in Ubuntu and Other Linux Distributions.md b/published/201912/20191220 How to Start, Stop - Restart Services in Ubuntu and Other Linux Distributions.md similarity index 100% rename from published/20191220 How to Start, Stop - Restart Services in Ubuntu and Other Linux Distributions.md rename to published/201912/20191220 How to Start, Stop - Restart Services in Ubuntu and Other Linux Distributions.md diff --git a/translated/tech/20191221 Customize your Linux desktop with KDE Plasma.md b/published/201912/20191221 Customize your Linux desktop with KDE Plasma.md similarity index 77% rename from translated/tech/20191221 Customize your Linux desktop with KDE Plasma.md rename to published/201912/20191221 Customize your Linux desktop with KDE Plasma.md index 402fcd0e3b..23f83f5d41 100644 --- a/translated/tech/20191221 Customize your Linux desktop with KDE Plasma.md +++ b/published/201912/20191221 Customize your Linux desktop with KDE Plasma.md @@ -1,20 +1,22 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11728-1.html) [#]: subject: (Customize your Linux desktop with KDE Plasma) [#]: via: (https://opensource.com/article/19/12/linux-kde-plasma) [#]: author: (Seth Kenlon https://opensource.com/users/seth) 使用 KDE Plasma 定制 Linux 桌面 ====== -本文是 24 天 Linux 桌面特别系列的一部分。如果你认为没有太多机会进行自定义桌面,KDE Plasma 可能适合你。 + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你认为没有太多自定义桌面的需要,KDE Plasma 可能适合你。 + ![5 pengiuns floating on iceburg][1] -KDE 社区的 Plasma 桌面是开源桌面中的巅峰之作。KDE 很早就进入了 Linux 桌面市场,但是由于它的 基础 Qt 工具包当时没有完全开放的许可证,因此才有 [GNOME][2] 桌面。在此之后,Qt 开源了,并且 KDE(及其衍生产品,例如 [Trinity桌面][3])开始蓬勃发展。 +KDE 社区的 Plasma 桌面是开源桌面环境中的巅峰之作。KDE 很早就进入了 Linux 桌面环境市场,但是由于它的基础 Qt 工具包当时没有完全开放的许可证,因此才有 [GNOME][2] 桌面。在此之后,Qt 开源了,并且 KDE(及其衍生产品,例如 [Trinity 桌面][3])开始蓬勃发展。 -你可能会在发行版的软件仓库中找到 KDE 桌面,或者可以下载并安装将 KDE 作为默认桌面的发行版。在安装之前,请注意,KDE 提供了完整、集成且强大的桌面体验,因此会同时安装几个 KDE 应用。如果你已经在运行其他桌面,那么将发现有几个冗余的应用(两个 PDF 阅读器、多个媒体播放器、两个或多个文件管理器,等等)。如果你只想尝试而不是一直使用 KDE 桌面,那么可以在虚拟机,如[GNOME Boxes][4]中安装基于 KDE 的发行版,也可以尝试使用可引导的操作系统,例如 [Porteus][5]。 +你可能会在发行版的软件仓库中找到 KDE 桌面,或者可以下载并安装将 KDE 作为默认桌面的发行版。在安装之前,请注意,KDE 提供了完整、集成且强大的桌面体验,因此会同时安装几个 KDE 应用。如果你已经在运行其他桌面,那么将发现有几个冗余的应用(两个 PDF 阅读器、多个媒体播放器、两个或多个文件管理器,等等)。如果你只想尝试而不是一直使用 KDE 桌面,那么可以在虚拟机,如 [GNOME Boxes][4] 中安装基于 KDE 的发行版,也可以尝试使用可引导的操作系统,例如 [Porteus][5]。 ### KDE 桌面之旅 @@ -22,15 +24,15 @@ KDE 社区的 Plasma 桌面是开源桌面中的巅峰之作。KDE 很早就进 ![KDE Plasma desktop][7] -但是,使 KDE 与众不同的是,你几乎可以更改任何想要的东西。Qt 工具包可以以令人惊讶的方式分割和重新排列,这意味着你实质上可以使用 KDE 的部件作为基础来设计自己的桌面。桌面行为的可用设置也很多。KDE 可以充当标准桌面,平铺窗口管理器以及两者之间的任意形式。你可以通过窗口类、角色、类型、标题或它们的任意组合来创建自己的窗口规则,因此,如果希望特定应用的行为不同于其他行为,那么可以创建全局设置的例外。 +但是,使 KDE 与众不同的是,你几乎可以更改任何想要的东西。Qt 工具包可以以令人惊讶的方式分割和重新排列,这意味着你实质上可以使用 KDE 的部件作为基础来设计自己的桌面。桌面行为的可用设置也很多。KDE 可以充当标准桌面、平铺窗口管理器以及两者之间的任意形式。你可以通过窗口类、角色、类型、标题或它们的任意组合来创建自己的窗口规则,因此,如果希望特定应用的行为不同于其他行为,那么可以创建全局设置的例外。 -此外,它还有丰富的小部件集合,使你可以自定义与桌面交互的方式。它有一个类似 GNOME 的全屏应用启动器,一个类似 Unity 的 dock 启动器和仅有图标的任务栏,一个传统的任务栏。你可以在屏幕的任何边缘上创建和放置面板。 +此外,它还有丰富的小部件集合,使你可以自定义与桌面交互的方式。它有一个类似 GNOME 的全屏应用启动器,一个类似 Unity 的 dock 启动器和仅有图标的任务栏,以及一个传统的任务栏。你可以在屏幕的任何边缘上创建和放置面板。 ![A slightly customized KDE desktop][8] -实际上,它有太多的自定义项了,因此 KDE 最常见的批评之一是它的_太过可定制化_,所以请记住,自定义项是可选的。你可以在默认配置下使用 Plasma 桌面,并仅在你认为必要时逐步进行更改。Plasma 桌面配置选项最重要的不是它们的数目,而是它们容易发现和直观,它们都在系统设置应用或者右键单击中。 +实际上,它有太多的自定义项了,因此 KDE 最常见的批评之一是它的*太过可定制化*,所以请记住,自定义项是可选的。你可以在默认配置下使用 Plasma 桌面,并仅在你认为必要时逐步进行更改。Plasma 桌面配置选项最重要的不是它们的数目,而是它们容易发现和直观,它们都在系统设置应用或者右键单击中。 -事实是,在 KDE 上,几乎绝不会只有一种方法可以完成任何给定的任务,并且它的用户将其视为其最大的优势。KDE 中没有隐含的工作流,只有默认的。并且可以更改所有默认设置,直到你需要桌面做的成为你的习惯。 +事实是,在 KDE 上,几乎绝不会只有一种方法可以完成任何给定的任务,并且它的用户将这个视为其最大的优势。KDE 中没有隐含的工作流,只有默认的。并且可以更改所有默认设置,直到你需要桌面做的成为你的习惯。 ### 一致性和集成 @@ -42,8 +44,6 @@ KDE 社区以一致性和集成为荣,出色的开发人员、社区管理以 KDE 适合所有人。使用其默认设置可获得流畅、原始的桌面体验,或对其进行自定义以使其成为自己专属。它是一个稳定、有吸引力且强大的桌面环境,可能有你想要在 Linux 完成要做的事的一切。 -KDE 最初代表 Kool Desktop Environment,但现在被许多人称为 K Desktop。 - -------------------------------------------------------------------------------- via: https://opensource.com/article/19/12/linux-kde-plasma @@ -51,7 +51,7 @@ via: https://opensource.com/article/19/12/linux-kde-plasma 作者:[Seth Kenlon][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/) 荣誉推出 @@ -67,4 +67,4 @@ via: https://opensource.com/article/19/12/linux-kde-plasma [8]: https://opensource.com/sites/default/files/uploads/advent-kde-dock.jpg (A slightly customized KDE desktop) [9]: https://kde.org/applications/ [10]: https://opensource.com/life/16/5/how-use-digikam-photo-management -[11]: https://opensource.com/sites/default/files/uploads/advent-kde.jpg (KDE on Porteus) \ No newline at end of file +[11]: https://opensource.com/sites/default/files/uploads/advent-kde.jpg (KDE on Porteus) diff --git a/published/20191222 How to Update Grub on Ubuntu and Other Linux Distributions.md b/published/201912/20191222 How to Update Grub on Ubuntu and Other Linux Distributions.md similarity index 100% rename from published/20191222 How to Update Grub on Ubuntu and Other Linux Distributions.md rename to published/201912/20191222 How to Update Grub on Ubuntu and Other Linux Distributions.md diff --git a/published/20191222 Why your Python code needs to be beautiful and explicit.md b/published/201912/20191222 Why your Python code needs to be beautiful and explicit.md similarity index 100% rename from published/20191222 Why your Python code needs to be beautiful and explicit.md rename to published/201912/20191222 Why your Python code needs to be beautiful and explicit.md diff --git a/published/201912/20191224 App Highlight- Falkon Open Source Web Browser from KDE.md b/published/201912/20191224 App Highlight- Falkon Open Source Web Browser from KDE.md new file mode 100644 index 0000000000..bd4a26bc8e --- /dev/null +++ b/published/201912/20191224 App Highlight- Falkon Open Source Web Browser from KDE.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11732-1.html) +[#]: subject: (App Highlight: Falkon Open Source Web Browser from KDE) +[#]: via: (https://itsfoss.com/falkon-browser/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +应用推荐:来自 KDE 的 Falkon 开源 Web 浏览器 +====== + +> Falkon 是基于 QtWebEngine 的 Web 浏览器,它以前称为 Qupzilla。在本周的“应用推荐”中,我们来看看这个开源软件。 + +![](https://img.linux.net.cn/data/attachment/album/201912/31/105027tblfjlzn9xx8keud.png) + +### Falkon:适用于 Linux(和 Windows)的开源 Web 浏览器 + +![][1] + +首先,[Falkon][2] 并不是一款新的 Web 浏览器。它自 2010 年以来一直在开发中,但被称为 Qupzilla。2017 年,QupZilla 移到 KDE 旗下,并更名为 Falkon。处于 KDE 旗下意味着项目会按照 KDE 标准积极维护。 + +它使用 [QtWebEngine][3] 渲染引擎,这是 Chromium 核心的简化版本。 + +在本文中,我将仔细研究它提供的功能以及与 Linux 上其他主流 Web 浏览器的不同之处。 + +### Falkon 浏览器的功能 + +我认为它可能不是流行的浏览器,但我发现它足以浏览现代 Web 服务。让我重点介绍 Falkon 的主要功能,如果你觉得它很有趣,请尝试一下。 + +#### 简单的用户界面 + +![][4] + +我知道这不完全是一项“功能”,但是用户体验(UX)至关重要。尽管是轻量级的浏览器,但你会拥有一个不错的界面。你不会觉得使用的是一款源自 2000 年早期的浏览器。 + +#### AdBlock 扩展 + +![][5] + +它附带了 AdBlock 扩展程序,如果你想在浏览网站时摆脱广告,它的效果很好。你还可以自定义 AdBlock 扩展的行为。 + +#### DuckDuckGo 作为默认搜索引擎 + +如果你不喜欢使用 Google,那么这是一件好事,它将这个[主打隐私的搜索引擎][6]设为默认搜索引擎。 + +#### 会话管理器 + +![][7] + +Falkon 在浏览器菜单的可用选项中包含了一个有用的会话管理器。你可以用它还原特定的近期会话,这应该能派上用场。 + +#### 扩展支持 + +![][8] + +它确实支持添加扩展,但你不能从 Chrome/Firefox 插件市场添加扩展。你只能选择有限的一组扩展。 + +#### 主题支持 + +Falkon 还允许你在某种程度上自定义外观。如果要更改浏览器的外观,可以尝试一下。 + +![][9] + +#### 其他基本设置 + +![][10] + +我还尝试了其他设置/功能,例如添加书签或管理密码。或者,管理网页的通知。我还试了 YouTube,没有任何问题。 + +当然,这不是一个详尽的评测。但是,Falkon 确实拥有浏览器中需要的所有基本功能(除非你有特定要求)。 + +### 安装 Falkon 浏览器 + +你可以在软件中心轻松找到 Falkon 浏览器。如果没有,你可以从它的[官方下载页面][11]中找到 Flatpak/Snap 包。你还可以在下载页面上找到 Windows 的安装程序。 + +[Download Falkon Browser][11] + +### 总结 + +作为 KDE 产品,Falkon 是为 KDE 桌面环境量身定制的。一些 KDE 发行版(例如 OpenMandriva)使用 Falkon 作为默认的 Web 浏览器。 + +Falkon 浏览器适合那些正在寻求轻巧且功能丰富的 Web 浏览器的人。值得尝试的另一个替代是 [Midori][12]。 + +我认为,除非你需要大量的扩展、跨平台同步并且需要访问某些特定于浏览器的网站,不然它是一个很好的替代浏览器。 + +你如何看待 Falkon 浏览器?请在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/falkon-browser/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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/falkon-browser-screenshot.jpg?ssl=1 +[2]: https://www.falkon.org/ +[3]: https://wiki.qt.io/QtWebEngine +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser.png?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-adblock.jpg?ssl=1 +[6]: https://itsfoss.com/privacy-search-engines/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/session-manager-falkon.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser-extensions.png?ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser-theme.png?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/falkon-browser-preference.png?ssl=1 +[11]: https://www.falkon.org/download/ +[12]: https://itsfoss.com/midori-browser/ diff --git a/published/20191224 Unix is turning 50. What does that mean.md b/published/201912/20191224 Unix is turning 50. What does that mean.md similarity index 100% rename from published/20191224 Unix is turning 50. What does that mean.md rename to published/201912/20191224 Unix is turning 50. What does that mean.md diff --git a/published/202001/20171018 How to create an e-book chapter template in LibreOffice Writer.md b/published/202001/20171018 How to create an e-book chapter template in LibreOffice Writer.md new file mode 100644 index 0000000000..be6ce008f5 --- /dev/null +++ b/published/202001/20171018 How to create an e-book chapter template in LibreOffice Writer.md @@ -0,0 +1,118 @@ +如何在 LibreOffice Writer 中创建一个电子书章节模板 +====== + +> 将电子书分成几章,创建电子书会更容易。这是设置模板的分步指南。 + +![](https://img.linux.net.cn/data/attachment/album/202001/02/102817vmflleeemehetblt.jpg) + +对于很多人来说,使用 word 程序来撰写和发布一本电子书是一种最好的、最容易的、最熟悉的方法。但是,启动你的 word 程序和打字是不够的 —— 你需要遵循一种格式。 + +这就是模板的来源。一个模板确保你的电子书有一个一致的外观和体验。幸运的是,创建模板是快速和容易的,并你在其上花费的时间和努力将带给你一本更好感观的书。 + +在这篇文章中,我将陪伴你走过如何使用 LibreOffice Writer 创建一个简单的模板,可以用于一本电子书的各个章节。你可以将这个模板用于 PDF 和 EPUB 书籍,并加以修改来满足你的需要。 + +### 我的方法 + +为什么我着重于为一个章节创建一个模板,而不是为一整本书创建一个模板?因为编写和管理单独的章节比编写和管理单个庞大而僵化的文档更容易。 + +通过关注于单独的章节,你可以专心于你需要编写的东西。你可以很容易地四处移动这些章节,给审阅者发单独一章节比发送你的完整原稿更简单而高效。当你写完一章后,你可以简单地把你的章节拼凑在一起来出版这本书(我将在下面讨论如何做到这一点)。但是不要觉得你被这种方法所束缚 —— 如果你更喜欢在单个文件中编写,简单地调整在这篇文章中描述的步骤就行。 + +让我们开始吧。 + +### 设置页面 + +仅当你计划发布你的电子书为一本 PDF 书时,这是很重要的。设置页面意味着你的书将不包含大量的跨越屏幕的让眼睛疲劳的文本。 + +选择 **格式 > 页面** 来打开 **页面样式** 窗口。我的 PDF 电子书通常是 5x8 英寸高(大约 13x20cm ,对于我们这些生活在米制世界的人来说)。我也设置页边距为半英寸(约 1.25 cm)。这些是我较喜欢的尺寸;你可以使用任何适合你的尺寸。 + +![LibreOffice Page Style window][2] + +*在 LibreOffice Writer 中的页面样式窗口让你设置页边距和页格式。* + +接下来,添加页脚以显示页码。保持页面样式窗口打开着,并单击 **页脚** 选项卡。选择 **在页脚上** 并单击 **确定** 。 + +在该页面上,在页脚中单击,然后选择 **插入 > 字段 > 页码**。不要担心页码的位置和外观;我们接下来会处理。 + +### 设置你的样式 + +像模板本身一样,样式为你的文档提供一种一致的外观和体验。如果你想更改一个标题的字体或大小,例如,你只需要在一个地方完成它,而不是手动应用格式化到每个标题。 + +标准化的 LibreOffice 模板带有许多样式,你可以调整它们以适应你的需要。为此,按 `F11` 来打开 **样式和格式** 窗口。 + +![LibreOffice styles and formatting][4] + +*使用样式和格式窗口更改字体和其它细节。* + +在一个样式上右键单击,并选择 **修改** 来编辑它。 这里是我在每本中使用的主要样式: + + 样式 | 字体 | 间距 / 对齐方式 + :-: | :-: | :-: + 标题 1 | Liberation Sans, 36 pt | 上面 36 pt ,下面 48 pt ,左对齐 + 标题 2 | Liberation Sans, 18 pt | 上面 12 pt ,下面 12 pt ,左对齐 + 标题 3 | Liberation Sans, 14 pt | 上面 12 pt ,下面 12 pt ,左对齐 + 正文 | Liberation Sans, 12 pt | 上面 12 pt ,下面 12 pt ,左对齐 + 页脚 | Liberation Sans, 10 pt | 居中对齐 + + +![LibreOffice styles in action][6] + +*这是当我们应用到电子书内容时的一个选择的样式外观。* + +对于大多数书来说,这通常是最小要求。可以随便更改字体和空格来适应你的要求。 + +根据你正在编写书的类型,你可能也想创建或修改项目符合样式,以及数字列表、引号、代码示例、数字符号等等。只需要记住始终如一地使用字体以及其大小。 + +### 保存你的模板 + +选择 **文件 > 另存为** 。在保持对话框中,从格式列表中选择 “ODF 文本文档模板 (.ott)” 。这将保存模板为一个模板,以后你可以快速调用该模板。 + +保存模板的最佳位置是 LibreOffice 模板文件夹。例如,在 Linux 中,那是在你的家目录下,在 `.config/libreoffice/4/user/template` 下。 + +### 编写你的书 + +在你开始编写前,在你的计算机上创建一个文件夹,它将为你的书保存所有的文件 —— 章节、图像、笔记等等。 + +当你准备编写时,启动 LibreOffice Writer 并选择 **文件 > 新建 > 模板** 。然后从列表中选择你的模板,并单击 **打开**。 + +![LibreOffice Writer template list][8] + +*从你在 LibreOffice Writer 中设置的列表中选择你的模板,并开始编写。* + +然后用一个描述性名称保存文档。 + +建议使用像 “第 1 章” 和 “第 2 章” 这样的惯例 —— 在某些时候,你可能决定重新编排你的章节,当你尝试管理这些章节时,它可能会变得混乱。然而,你可以在文件名称中放置章节数字,像 “第 1 章” 或 “一” 。如果你最后要重新排列全书的章节,像这样重命名更容易。 + +无需赘言,开始编写吧。记住在模板中使用样式来格式化文本 —— 这就是为什么你要创建模板,对吧? + +### 发布你的电子书 + +在完成编写一堆章节后,并准备发布它们时,创建一个主控文档。把一个主控文档作为你所编写章节的一个容器。使用一个主控文档,你可以快速地组装你的书,并任意重新排序你的章节。LibreOffice 的帮助提供了使用[主控文档][9]的详细信息。 + +假设你想生成一个 PDF ,不要只是单击**直接导出到 PDF** 按钮。这将创建一个相当不错的 PDF ,但是你可能想优化它。为此,选择 **文件 > 导出为 PDF** ,并在 PDF 选项窗口中轻微调整。你可以在这篇 [LibreOffice Writer 文档][10] 中学到更多东西。 + +如果你想创建一个 EPUB 而不是一个 PDF,或者除了一个 PDF 以外,另外创建一个 EPUB,请安装 [Writer2EPUB][11] 扩展。Opensource.com 的 Bryan Behrenshausen 为这个扩展[分享了一些有用的说明][12] 。 + +### 结束语 + +我们在这里创建的模板是极简单的,但是你可以将其用于一本简单的书,或者作为构建一个复杂模板的起点。不管怎样,这个模板都会让你快速地开始编写和发布你的电子书。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/10/creating-ebook-chapter-template-libreoffice-writer + +作者:[Scott Nesbitt][a] +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/scottnesbitt +[2]:https://opensource.com/sites/default/files/images/life-uploads/lo-page-style.png (LibreOffice Page Style window) +[4]:https://opensource.com/sites/default/files/images/life-uploads/lo-paragraph-style.png (LibreOffice styles and formatting window) +[5]:/file/374466 +[6]:https://opensource.com/sites/default/files/images/life-uploads/lo-styles-in-action.png (Example of LibreOffice styles) +[8]:https://opensource.com/sites/default/files/images/life-uploads/lo-template-list.png (Template list - LibreOffice Writer) +[9]:https://help.libreoffice.org/Writer/Working_with_Master_Documents_and_Subdocuments +[10]:https://help.libreoffice.org/Common/Export_as_PDF +[11]:http://writer2epub.it/en/ +[12]:https://opensource.com/life/13/8/how-create-ebook-open-source-way diff --git a/published/202001/20190405 File sharing with Git.md b/published/202001/20190405 File sharing with Git.md new file mode 100644 index 0000000000..57d89c14c8 --- /dev/null +++ b/published/202001/20190405 File sharing with Git.md @@ -0,0 +1,230 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11768-1.html) +[#]: subject: (File sharing with Git) +[#]: via: (https://opensource.com/article/19/4/file-sharing-git) +[#]: author: (Seth Kenlon) + +用 Git 来共享文件 +====== + +> SparkleShare 是一个开源的基于 Git 的 Dropbox 风格的文件共享应用程序。在我们的系列文章中了解有关 Git 鲜为人知的用法。 + +![](https://img.linux.net.cn/data/attachment/album/202001/10/113645qb2ufvuu2ttimugv.png) + +[Git][2] 是一个少有的能将如此多的现代计算封装到一个程序之中的应用程序,它可以用作许多其他应用程序的计算引擎。虽然它以跟踪软件开发中的源代码更改而闻名,但它还有许多其他用途,可以让你的生活更轻松、更有条理。在这个 Git 系列中,我们将分享七种鲜为人知的使用 Git 的方法。 + +今天,我们将看看 SparkleShare,它使用 Git 作为文件共享的基础。 + +### 用于文件共享的 Git + +Git 的优点之一是它具有固有的分发能力。它可用来建立共享。即使你只是与自己网络上的其他计算机共享资源库,Git 也会为从共享位置获取文件的行为带来透明性。 + +随着其界面的发展,Git 变得非常简单。虽然因用户而异,他们坐下来完成一些工作时的共同点仅仅是 `git pull` 或稍微复杂一点的 `git pull && git checkout -b my-branch`。但是,对于某些人来说,将*命令输入*到他们的计算机中的做法完全是令人困惑或烦恼的。计算机旨在使生活变得轻松,它擅长于重复性工作,因此有更简便的方法可以与 Git 共享文件。 + +### SparkleShare + +[SparkleShare][3] 项目是一个基于 Git 的跨平台的、开源的 Dropbox 式的文件共享应用程序。它通过将文件拖放到专门指定的 SparkleShare 目录中的简单操作,自动执行所有 Git 命令,触发添加、提交、推送和拉取过程。因为它基于 Git,所以你可以获得基于差异(diff)的快速推送和拉取,并且继承了 Git 版本控制和后端基础设施(如 Git 挂钩)的所有优点。它可以完全自托管,也可以将其与 [GitLab][4]、GitHub、Bitbucket 等 Git 托管服务一起使用。此外,由于它基本上只是一个 Git 的前端,因此你可以在可能没有 SparkleShare 客户端但有 Git 客户端的设备上访问 SparkleShare 中的文件。 + +正如你获得 Git 的所有好处一样,你也会受到所有常见的 Git 限制:使用 SparkleShare 存储数百张照片、音乐和视频是不切实际的,因为 Git 是为文本而设计和优化的。Git 当然可以存储二进制文件的大文件,但是因为它可以跟踪历史记录,因此一旦将文件添加到其中,几乎就不可能完全删除它。这在某种程度上限制了 SparkleShare 对某些人的实用性,但使其非常适合许多工作流程,包括[日程安排][5]。 + +#### 安装 SparkleShare + +SparkleShare 是跨平台的,可从[网站][6]获得适用于 Windows 和 Mac 的安装程序。对于 Linux,有一个 [Flatpak][7] 安装包,或者你可以在终端中运行以下命令: + +``` +$ sudo flatpak remote-add flathub https://flathub.org/repo/flathub.flatpakrepo +$ sudo flatpak install flathub org.sparkleshare.SparkleShare +``` + +### 创建一个 Git 存储库 + +SparkleShare 并不是软件即服务(SaaS)。你在计算机上运行 SparkleShare 与 Git 存储库进行通信,而 SparkleShare 并不存储你的数据。如果你还没有与文件夹同步的 Git 存储库,则必须在启动 SparkleShare 之前创建一个文件夹。你有三个选择:托管的 Git、自托管 Git 或自托管 SparkleShare。 + +#### 托管的 Git + +SparkleShare 可以使用你能访问的任何 Git 存储库进行存储,因此,如果你拥有 GitLab 或任何其他托管服务的帐户(或创建一个),则它可以成为 SparkleShare 的后端。例如,开源 [Notabug.org][8] 服务是一个类似于 GitHub 和 GitLab 的 Git 托管服务,但其独特性足以证明 SparkleShare 的灵活性。根据用户界面的不同,不同的托管服务创建新存储库的方法也有所不同,但是所有主要存储库都遵循相同的通用模型。 + +首先,在托管服务中找到创建新项目或存储库的按钮,单击它以开始。然后逐步完成存储库的创建过程,为存储库提供名称、隐私级别(存储库通常默认为公共),以及是否使用 `README` 文件初始化存储库。无论你是否需要个 `README` 文件,请初始化建立一个。使用一个文件来创建存储库不是绝对必要的,但是它会强制 Git 主机实例化存储库中的 `master` 分支,这有助于确保前端应用程序(例如 SparkleShare)具有要提交并推送的分支。即使文件是几乎空的 `README` 文件,也可以用来查看该文件以确认你已连接成功。 + +![Creating a Git repository][9] + +创建存储库后,获取其用于 SSH 克隆的 URL。就像从 Git 项目获得其 URL 一样,你也可以获取此 URL:导航至存储库页面并查找 “Clone” 按钮或字段。 + +![Cloning a URL on GitHub][10] + +*GitHub 的克隆 URL。* + +![Cloning a URL on GitLab][11] + +*GitLab 的克隆 URL。* + +这是 SparkleShare 用于获取数据的地址,因此请记下它。你的 Git 存储库现已配置好。 + +#### 自托管的 Git + +你可以使用 SparkleShare 访问你有权访问的任何计算机上的 Git 存储库。除了一个 Git 裸存储库外,无需任何特殊设置。但是,如果你想将对 Git 存储库的访问权授予其他任何人,则应运行 [Gitolite][12] 之类的 Git 管理器或 SparkleShare 自己的 Dazzle 服务器来帮助你管理 SSH 密钥和帐户。至少,创建一个特定于 Git 的用户,以便有权访问你的 Git 存储库的用户不会自动获得对服务器其余部分的访问权限。 + +以 Git 用户身份登录服务器(如果你非常擅长管理用户和组权限,则可以以自己的用户登录)并创建存储库: + +``` +$ mkdir ~/sparkly.git +$ cd ~/sparkly.git +$ git init --bare . +``` + +你的 Git 存储库现已配置好。 + +#### Dazzle + +SparkleShare 的开发人员提供了一个名为 [Dazzle][13] 的 Git 管理系统,以帮助你自托管 Git 存储库。 + +在你的服务器上,将 Dazzle 应用程序下载到你的路径中的某个位置: + +``` +$ curl https://raw.githubusercontent.com/hbons/Dazzle/master/dazzle.sh --output ~/bin/dazzle +$ chmod +x ~/bin/dazzle +``` + +Dazzle 设置了一个特定于 Git 和 SparkleShare 的用户,并且还基于 SparkleShare 应用程序生成的密钥实现了访问权限。现在,只需设置一个项目: + +``` +$ dazzle create sparkly +``` + +你的服务器现在已经配置好,可以用作 SparkleShare 托管了。 + +### 配置 SparkleShare + +首次启动 SparkleShare 时,系统会提示你配置 SparkleShare 用于存储的服务器。这个过程可能看起来像一个首次运行的安装向导,但实际上是在 SparkleShare 中设置新共享位置的通常过程。与许多共享驱动器应用程序不同,使用 SparkleShare 可以一次配置多个位置。你配置的第一个共享位置并不比你以后可以配置的任何共享位置更重要,并且你也不用注册 SparkleShare 或任何其他服务。你只是将 SparkleShare 指向 Git 存储库,以便它知道如何使第一个 SparkleShare 文件夹保持同步。 + +在第一个屏幕上,给出一个身份信息,SparkleShare 将在代表你进行的 Git 提交记录中使用这些信息。你可以使用任何内容,甚至可以使用不代表任何意义的伪造信息。它仅用于提交消息,如果你对审查 Git 后端进程没有兴趣,你可能甚至看不到它们。 + +下一个屏幕提示你选择主机类型。如果你使用的是 GitLab、GitHub、Planio 或 Bitbucket,则可以选择一个适当的。否则,请选择“自己的服务器”。 + +![Choosing a Sparkleshare host][14] + +在此屏幕底部,你必须输入 SSH 的克隆 URL。如果你是自托管的 Git,则地址类似于 ``,而远程路径是为此目的而创建的 Git 存储库的绝对路径。 + +根据上面的自托管示例,我虚构的服务器的地址为 `ssh://git@example.com:22122`(`:22122` 表示一个非标准的 SSH 端口),远程路径为 `/home/git/sparkly.git`。 + +如果我改用 Notabug.org 帐户,则上例中的地址为 `ssh://git@notabug.org`,路径为 `seth/sparkly.git`。 + +SparkleShare 首次尝试连接到主机时会失败,因为你尚未将 SparkleShare 客户端 ID(特定于 SparkleShare 应用程序的 SSH 密钥)复制到 Git 主机。这是预料之中的,所以不要取消该过程。将 SparkleShare 设置窗口保持打开状态,并从系统任务栏中的 SparkleShare 图标处获取客户端 ID。然后将客户端 ID 复制到剪贴板,以便可以将其添加到 Git 主机。 + +![Getting the client ID from Sparkleshare][16] + +#### 将你的客户端 ID 添加到托管的 Git 帐户 + +除了较小的 UI 差异外,在任何托管服务上添加 SSH 密钥(所有客户端 ID 都是这样)的过程基本上是相同的。在你的 Git 主机的 Web 仪表板中,导航到你的用户设置,然后找到 “SSH 密钥”类别。单击“添加新密钥”按钮(或类似按钮),然后粘贴你的 SparkleShare 客户端 ID 的内容。 + +![Adding an SSH key][17] + +保存密钥。如果你希望其他人(例如协作者或家庭成员)能够访问同一存储库,则他们必须向你提供其 SparkleShare 客户端 ID,以便你可以将其添加到帐户中。 + +#### 将你的客户端 ID 添加到自托管的 Git 帐户 + +SparkleShare 客户端 ID 只是一个 SSH 密钥,因此将其复制并粘贴到 Git 用户的 `~/.ssh/authorized_keys` 文件中。 + +#### 使用 Dazzle 添加你的客户 ID + +如果你使用 Dazzle 管理 SparkleShare 项目,请使用以下命令添加客户端 ID: + +``` +$ dazzle link +``` + +当 Dazzle 提示你输入该 ID 时,请粘贴在 SparkleShare 菜单中找到的客户端 ID。 + +### 使用 SparkleShare + +将客户端 ID 添加到 Git 主机后,在 SparkleShare 窗口中单击“重试”按钮以完成设置。克隆存储库完成后,你可以关闭 SparkleShare 设置窗口,并在你的家目录中找到一个新的 `SparkleShare` 文件夹。如果你设置了带有托管服务的 Git 存储库,并选择包括 `README` 文件或许可证文件,则可以在 SparkleShare 目录中看到它们。 + +![Sparkleshare file manager][18] + +此外,有一些隐藏目录,你可以通过在文件管理器中显示隐藏目录来查看。 + +![Showing hidden files in GNOME][19] + +使用 SparkleShare 的方式与使用计算机上任何目录的方式相同:将文件放入其中。每当将文件或目录放入 SparkleShare 文件夹时,它都会在后台复制到你的 Git 存储库。 + +#### 排除某些文件 + +由于 Git 从设计上就是要记住*一切*,因此你可能希望从记录中排除特定的文件类型。排除一些文件是有原因的。通过定义摆脱 SparkleShare 管理的文件,可以避免意外复制大文件。你还可以为自己设计一种方案,使你可以将存储在一个目录中的逻辑上属于同一个文件(例如,MIDI 文件及其 .flac 导出文件),但是可以自己手动备份大文件,而同时让 SparkleShare 备份基于文本的文件。 + +如果在系统的文件管理器中看不到隐藏的文件,请显示它们。导航到你的 SparkleShare 文件夹,然后到代表你的存储库的目录,找到一个名为 `.gitignore` 的文件,然后在文本编辑器中将其打开。你可以在 `.gitignore` 中输入文件扩展名或文件名(每行一个),任何与你列出的文件匹配的文件都会被忽略(如文件名所示)。 + +``` +Thumbs.db +$RECYCLE.BIN/ +.DS_Store +._* +.fseventsd +.Spotlight-V100 +.Trashes +.directory +.Trash-* +*.wav +*.ogg +*.flac +*.mp3 +*.m4a +*.opus +*.jpg +*.png +*.mp4 +*.mov +*.mkv +*.avi +*.pdf +*.djvu +*.epub +*.od{s,t} +*.cbz +``` + +你知道最经常遇到哪些文件类型,因此请集中精力处理最有可能潜入你的 SparkleShare 目录的文件。如果你想稍微矫枉过正一些,可以在 Notabug.org 以及整个网上找到 `.gitignore` 文件的好集合。 + +通过将这些条目保存在 `.gitignore` 文件中,你可以将不需要发送到 Git 主机的大文件放在 SparkleShare 目录中,SparkleShare 将完全忽略它们。当然,这意味着你需要确保它们可以备份或通过其他方式分发给你的 SparkleShare 协作者。 + +### 自动化 + +[自动化][20] 是我们与计算机达成的默契之一:计算机执行重复的、无聊的工作,而我们人类要么不擅长做这些,要么不擅长记忆这些。SparkleShare 是一种很好的、简单的自动执行例行数据分发的方法。但不管怎么说,这并不适合每个 Git 存储库。它没有用于高级 Git 功能的接口,它没有暂停按钮或手动管理的操作。没关系,因为它的使用范围是有意限制的。SparkleShare 可以完成它计划要做的事情,它做得很好,而且它是你无需关心的一个 Git 存储库。 + +如果你想使用这种稳定的、看不见的自动化,请尝试一下 SparkleShare。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/file-sharing-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_cloud21x_cc.png?itok=5UwC92dO +[2]: https://git-scm.com/ +[3]: http://www.sparkleshare.org/ +[4]: http://gitlab.com +[5]: https://opensource.com/article/19/4/calendar-git +[6]: http://sparkleshare.org +[7]: /business/16/8/flatpak +[8]: http://notabug.org +[9]: https://opensource.com/sites/default/files/uploads/git-new-repo.jpg (Creating a Git repository) +[10]: https://opensource.com/sites/default/files/uploads/github-clone-url.jpg (Cloning a URL on GitHub) +[11]: https://opensource.com/sites/default/files/uploads/gitlab-clone-url.jpg (Cloning a URL on GitLab) +[12]: http://gitolite.org +[13]: https://github.com/hbons/Dazzle +[14]: https://opensource.com/sites/default/files/uploads/sparkleshare-host.jpg (Choosing a Sparkleshare host) +[15]: mailto:git@notabug.org +[16]: https://opensource.com/sites/default/files/uploads/sparkleshare-clientid.jpg (Getting the client ID from Sparkleshare) +[17]: https://opensource.com/sites/default/files/uploads/git-ssh-key.jpg (Adding an SSH key) +[18]: https://opensource.com/sites/default/files/uploads/sparkleshare-file-manager.jpg (Sparkleshare file manager) +[19]: https://opensource.com/sites/default/files/uploads/gnome-show-hidden-files.jpg (Showing hidden files in GNOME) +[20]: /downloads/ansible-quickstart diff --git a/published/202001/20190406 Run a server with Git.md b/published/202001/20190406 Run a server with Git.md new file mode 100644 index 0000000000..ee4497eb51 --- /dev/null +++ b/published/202001/20190406 Run a server with Git.md @@ -0,0 +1,226 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11795-1.html) +[#]: subject: (Run a server with Git) +[#]: via: (https://opensource.com/article/19/4/server-administration-git) +[#]: author: (Seth Kenlon https://opensource.com/users/seth/users/seth) + +使用 Git 来管理 Git 服务器 +====== + +> 借助 Gitolite,你可以使用 Git 来管理 Git 服务器。在我们的系列文章中了解这些鲜为人知的 Git 用途。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/132045yrr1pb9n497tfbiy.png) + +正如我在系列文章中演示的那样,[Git][2] 除了跟踪源代码外,还可以做很多事情。信不信由你,Git 甚至可以管理你的 Git 服务器,因此你可以或多或少地使用 Git 本身来运行 Git 服务器。 + +当然,这涉及除日常使用 Git 之外的许多组件,其中最重要的是 [Gitolite][3],该后端应用程序可以管理你使用 Git 的每个细微的配置。Gitolite 的优点在于,由于它使用 Git 作为其前端接口,因此很容易将 Git 服务器管理集成到其他基于 Git 的工作流中。Gitolite 可以精确控制谁可以访问你服务器上的特定存储库以及他们具有哪些权限。你可以使用常规的 Linux 系统工具自行管理此类事务,但是如果有好几个用户和不止一两个仓库,则需要大量的工作。 + +Gitolite 的开发人员做了艰苦的工作,使你可以轻松地为许多用户提供对你的 Git 服务器的访问权,而又不让他们访问你的整个环境 —— 而这一切,你可以使用 Git 来完成全部工作。 + +Gitolite 并**不是**图形化的管理员和用户面板。优秀的 [Gitea][4] 项目可提供这种体验,但是本文重点介绍 Gitolite 的简单优雅和令人舒适的熟悉感。 + +### 安装 Gitolite + +假设你的 Git 服务器运行在 Linux 上,则可以使用包管理器安装 Gitolite(在 CentOS 和 RHEL 上为 `yum`,在 Debian 和 Ubuntu 上为 `apt`,在 OpenSUSE 上为 `zypper` 等)。例如,在 RHEL 上: + +``` +$ sudo yum install gitolite3 +``` + +许多发行版的存储库提供的仍是旧版本的 Gitolite,但最新版本为版本 3。 + +你必须具有对服务器的无密码 SSH 访问权限。如果愿意,你可以使用密码登录服务器,但是 Gitolite 依赖于 SSH 密钥,因此必须配置使用密钥登录的选项。如果你不知道如何配置服务器以进行无密码 SSH 访问,请首先学习如何进行操作(Steve Ovens 的 Ansible 文章的[设置 SSH 密钥身份验证][5]部分对此进行了很好的说明)。这是加强服务器管理的安全以及运行 Gitolite 的重要组成部分。 + +### 配置 Git 用户 + +如果没有 Gitolite,则如果某人请求访问你在服务器上托管的 Git 存储库时,则必须向该人提供用户帐户。Git 提供了一个特殊的外壳,即 `git-shell`,这是一个仅执行 Git 任务的特别的特定 shell。这可以让你有个只能通过非常受限的 Shell 环境来过滤访问你的服务器的用户。 + +这个解决方案是一个办法,但通常意味着用户可以访问服务器上的所有存储库,除非你具有用于组权限的良好模式,并在创建新存储库时严格遵循这些权限。这种方式还需要在系统级别进行大量手动配置,这通常是只有特定级别的系统管理员才能做的工作,而不一定是通常负责 Git 存储库的人员。 + +Gitolite 通过为需要访问任何存储库的每个人指定一个用户名来完全回避此问题。默认情况下,该用户名是 `git`,并且由于 Gitolite 的文档中假定使用的是它,因此在学习该工具时保留它是一个很好的默认设置。对于曾经使用过 GitLab 或 GitHub 或任何其他 Git 托管服务的人来说,这也是一个众所周知的约定。 + +Gitolite 将此用户称为**托管用户**。在服务器上创建一个帐户以充当托管用户(我习惯使用 `git`,因为这是惯例): + +``` +$ sudo adduser --create-home git +``` + +为了控制该 `git` 用户帐户,该帐户必须具有属于你的有效 SSH 公钥。你应该已经进行了设置,因此复制你的公钥(**而不是你的私钥**)添加到 `git` 用户的家目录中: + +``` +$ sudo cp ~/.ssh/id_ed25519.pub /home/git/ +$ sudo chown git:git /home/git/id_ed25519.pub +``` + +如果你的公钥不以扩展名 `.pub` 结尾,则 Gitolite 不会使用它,因此请相应地重命名该文件。切换为该用户帐户以运行 Gitolite 的安装程序: + +``` +$ sudo su - git +$ gitolite setup --pubkey id_ed25519.pub +``` + +安装脚本运行后,`git` 的家用户目录将有一个 `repository` 目录,该目录(目前)包含存储库 `git-admin.git` 和 `testing.git`。这就是该服务器所需的全部设置,现在请登出 `git` 用户。 + +### 使用 Gitolite + +管理 Gitolite 就是编辑 Git 存储库中的文本文件,尤其是 `gitolite-admin.git` 中的。你不会通过 SSH 进入服务器来进行 Git 管理,并且 Gitolite 也建议你不要这样尝试。在 Gitolite 服务器上存储你和你的用户的存储库是个**裸**存储库,因此最好不要使用它们。 + +``` +$ git clone git@example.com:gitolite-admin.git gitolite-admin.git +$ cd gitolite-admin.git +$ ls -1 +conf +keydir +``` + +该存储库中的 `conf` 目录包含一个名为 `gitolite.conf` 的文件。在文本编辑器中打开它,或使用 `cat` 查看其内容: + +``` +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all +``` + +你可能对该配置文件的功能有所了解:`gitolite-admin` 代表此存储库,并且 `id_ed25519` 密钥的所有者具有读取、写入和管理 Git 的权限。换句话说,不是将用户映射到普通的本地 Unix 用户(因为所有用户都使用 `git` 用户托管用户身份),而是将用户映射到 `keydir` 目录中列出的 SSH 密钥。 + +`testing.git` 存储库使用特殊组符号为访问服务器的每个人提供了全部权限。 + +#### 添加用户 + +如果要向 Git 服务器添加一个名为 `alice` 的用户,Alice 必须向你发送她的 SSH 公钥。Gitolite 使用文件名的 `.pub` 扩展名左边的任何内容作为该 Git 用户的标识符。不要使用默认的密钥名称值,而是给密钥指定一个指示密钥所有者的名称。如果用户有多个密钥(例如,一个用于笔记本电脑,一个用于台式机),则可以使用子目录来避免文件名冲突。例如,Alice 在笔记本电脑上使用的密钥可能是默认的 `id_rsa.pub`,因此将其重命名为`alice.pub` 或类似名称(或让用户根据其计算机上的本地用户帐户来命名密钥),然后将其放入 `gitolite-admin.git/keydir/work/laptop/` 目录中。如果她从她的桌面计算机发送了另一个密钥,命名为 `alice.pub`(与上一个相同),然后将其添加到 `keydir/home/desktop/` 中。另一个密钥可能放到 `keydir/home/desktop/` 中,依此类推。Gitolite 递归地在 `keydir` 中搜索与存储库“用户”相匹配的 `.pub` 文件,并将所有匹配项视为相同的身份。 + +当你将密钥添加到 `keydir` 目录时,必须将它们提交回服务器。这是一件很容易忘记的事情,这里有一个使用自动化的 Git 应用程序(例如 [Sparkleshare][7])的真正的理由,因此任何更改都将立即提交给你的 Gitolite 管理员。第一次忘记提交和推送,在浪费了三个小时的你和你的用户的故障排除时间之后,你会发现 Gitolite 是使用 Sparkleshare 的完美理由。 + +``` +$ git add keydir +$ git commit -m 'added alice-laptop-0.pub' +$ git push origin HEAD +``` + +默认情况下,Alice 可以访问 `testing.git` 目录,因此她可以使用该目录测试连接性和功能。 + +#### 设置权限 + +与用户一样,目录权限和组也是从你可能习惯的的常规 Unix 工具中抽象出来的(或可从在线信息查找)。在 `gitolite-admin.git/conf` 目录中的 `gitolite.conf` 文件中授予对项目的权限。权限分为四个级别: + +* `R` 允许只读。在存储库上具有 `R` 权限的用户可以克隆它,仅此而已。 +* `RW` 允许用户执行分支的快进推送、创建新分支和创建新标签。对于大多数用户来说,这个基本上就像是一个“普通”的 Git 存储库。 +* `RW+` 允许可能具有破坏性的 Git 动作。用户可以执行常规的快进推送、回滚推送、变基以及删除分支和标签。你可能想要或不希望将其授予项目中的所有贡献者。 +* `-` 明确拒绝访问存储库。这与未在存储库的配置中列出的用户相同。 + +通过调整 `gitolite.conf` 来创建一个新的存储库或修改现有存储库的权限。例如,授予 Alice 权限来管理一个名为 `widgets.git` 的新存储库: + +``` +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all + +repo widgets + RW+ = alice +``` + +现在,Alice(也仅有 Alice 一个人)可以克隆该存储库: + +``` +[alice]$ git clone git@example.com:widgets.git +Cloning into 'widgets'... +warning: You appear to have cloned an empty repository. +``` + +在第一次推送时,Alice 必须使用 `-u` 选项将其分支发送到空存储库(如同她在任何 Git 主机上做的一样)。 + +为了简化用户管理,你可以定义存储库组: + +``` +@qtrepo = widgets +@qtrepo = games + +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all + +repo @qtrepo + RW+ = alice +``` + +正如你可以创建组存储库一样,你也可以对用户进行分组。默认情况下存在一个用户组:`@all`。如你所料,它包括所有用户,无一例外。你也可以创建自己的组: + +``` +@qtrepo = widgets +@qtrepo = games + +@developers = alice bob + +repo gitolite-admin + RW+ = id_ed22519 + +repo testing + RW+ = @all + +repo @qtrepo + RW+ = @developers +``` + +与添加或修改密钥文件一样,对 `gitolite.conf` 文件的任何更改都必须提交并推送以生效。 + +### 创建存储库 + +默认情况下,Gitolite 假设存储库的创建是从上至下进行。例如,有权访问 Git 服务器的项目经理创建了一个项目存储库,并通过 Gitolite 管理仓库添加了开发人员。 + +实际上,你可能更愿意向用户授予创建存储库的权限。Gitolite 称这些为“野生仓库(通配仓库)wild repos”(我不确定这是关于仓库的形成方式的描述,还是指配置文件所需的通配符)。这是一个例子: + +``` +@managers = alice bob + +repo foo/CREATOR/[a-z]..* + C = @managers + RW+ = CREATOR + RW = WRITERS + R = READERS +``` + +第一行定义了一组用户:该组称为 `@managers`,其中包含用户 `alice` 和 `bob`。下一行设置了通配符允许创建尚不存在的存储库,放在名为 `foo` 的目录下的创建该存储库的用户名的子目录中。例如: + +``` +[alice]$ git clone git@example.com:foo/alice/cool-app.git +Cloning into cool-app'... +Initialized empty Git repository in /home/git/repositories/foo/alice/cool-app.git +warning: You appear to have cloned an empty repository. +``` + +野生仓库的创建者可以使用一些机制来定义谁可以读取和写入其存储库,但是他们是有范围限定的。在大多数情况下,Gitolite 假定由一组特定的用户来管理项目权限。一种解决方案是使用 Git 挂钩来授予所有用户对 `gitolite-admin` 的访问权限,以要求管理者批准将更改合并到 master 分支中。 + +### 了解更多 + +Gitolite 具有比此介绍性文章所涵盖的更多功能,因此请尝试一下。其[文档][8]非常出色,一旦你通读了它,就可以自定义 Gitolite 服务器,以向用户提供你喜欢的任何级别的控制。Gitolite 是一种维护成本低、简单的系统,你可以安装、设置它,然后基本上就可以将其忘却。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/server-administration-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/server_data_system_admin.png?itok=q6HCfNQ8 (computer servers processing data) +[2]: https://git-scm.com/ +[3]: http://gitolite.com +[4]: http://gitea.io +[5]: Setting%20up%20SSH%20key%20authentication +[6]: mailto:git@example.com +[7]: https://opensource.com/article/19/4/file-sharing-git +[8]: http://gitolite.com/gitolite/quick_install.html diff --git a/published/202001/20190619 Getting started with OpenSSL- Cryptography basics.md b/published/202001/20190619 Getting started with OpenSSL- Cryptography basics.md new file mode 100644 index 0000000000..d7cd09934e --- /dev/null +++ b/published/202001/20190619 Getting started with OpenSSL- Cryptography basics.md @@ -0,0 +1,333 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11810-1.html) +[#]: subject: (Getting started with OpenSSL: Cryptography basics) +[#]: via: (https://opensource.com/article/19/6/cryptography-basics-openssl-part-1) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu/users/akritiko/users/clhermansen) + +OpenSSL 入门:密码学基础知识 +====== + +> 想要入门密码学的基础知识,尤其是有关 OpenSSL 的入门知识吗?继续阅读。 + +![](https://img.linux.net.cn/data/attachment/album/202001/23/142249fpnhyqz9y2cz1exe.jpg) + +本文是使用 [OpenSSL][2] 的密码学基础知识的两篇文章中的第一篇,OpenSSL 是在 Linux 和其他系统上流行的生产级库和工具包。(要安装 OpenSSL 的最新版本,请参阅[这里][3]。)OpenSSL 实用程序可在命令行使用,程序也可以调用 OpenSSL 库中的函数。本文的示例程序使用的是 C 语言,即 OpenSSL 库的源语言。 + +本系列的两篇文章涵盖了加密哈希、数字签名、加密和解密以及数字证书。你可以从[我的网站][4]的 ZIP 文件中找到这些代码和命令行示例。 + +让我们首先回顾一下 OpenSSL 名称中的 SSL。 + +### OpenSSL 简史 + +[安全套接字层][5]Secure Socket Layer(SSL)是 Netscape 在 1995 年发布的一种加密协议。该协议层可以位于 HTTP 之上,从而为 HTTPS 提供了 S:安全secure。SSL 协议提供了各种安全服务,其中包括两项在 HTTPS 中至关重要的服务: + +* 对等身份验证Peer authentication(也称为相互质询):连接的每一边都对另一边的身份进行身份验证。如果 Alice 和 Bob 要通过 SSL 交换消息,则每个人首先验证彼此的身份。 +* 机密性Confidentiality:发送者在通过通道发送消息之前先对其进行加密。然后,接收者解密每个接收到的消息。此过程可保护网络对话。即使窃听者 Eve 截获了从 Alice 到 Bob 的加密消息(即*中间人*攻击),Eve 会发现他无法在计算上解密此消息。 + +反过来,这两个关键 SSL 服务与其他不太受关注的服务相关联。例如,SSL 支持消息完整性,从而确保接收到的消息与发送的消息相同。此功能是通过哈希函数实现的,哈希函数也随 OpenSSL 工具箱一起提供。 + +SSL 有多个版本(例如 SSLv2 和 SSLv3),并且在 1999 年出现了一个基于 SSLv3 的类似协议传输层安全性Transport Layer Security(TLS)。TLSv1 和 SSLv3 相似,但不足以相互配合工作。不过,通常将 SSL/TLS 称为同一协议。例如,即使正在使用的是 TLS(而非 SSL),OpenSSL 函数也经常在名称中包含 SSL。此外,调用 OpenSSL 命令行实用程序以 `openssl` 开始。 + +除了 man 页面之外,OpenSSL 的文档是零零散散的,鉴于 OpenSSL 工具包很大,这些页面很难以查找使用。命令行和代码示例可以将主要主题集中起来。让我们从一个熟悉的示例开始(使用 HTTPS 访问网站),然后使用该示例来选出我们感兴趣的加密部分进行讲述。 + +### 一个 HTTPS 客户端 + +此处显示的 `client` 程序通过 HTTPS 连接到 Google: + +``` +/* compilation: gcc -o client client.c -lssl -lcrypto */ +#include +#include +#include /* BasicInput/Output streams */ +#include /* errors */ +#include /* core library */ +#define BuffSize 1024 + +void report_and_exit(const char* msg) { + perror(msg); + ERR_print_errors_fp(stderr); + exit(-1); +} + +void init_ssl() { + SSL_load_error_strings(); + SSL_library_init(); +} + +void cleanup(SSL_CTX* ctx, BIO* bio) { + SSL_CTX_free(ctx); + BIO_free_all(bio); +} + +void secure_connect(const char* hostname) { + char name[BuffSize]; + char request[BuffSize]; + char response[BuffSize]; + + const SSL_METHOD* method = TLSv1_2_client_method(); + if (NULL == method) report_and_exit("TLSv1_2_client_method..."); + + SSL_CTX* ctx = SSL_CTX_new(method); + if (NULL == ctx) report_and_exit("SSL_CTX_new..."); + + BIO* bio = BIO_new_ssl_connect(ctx); + if (NULL == bio) report_and_exit("BIO_new_ssl_connect..."); + + SSL* ssl = NULL; + + /* 链路 bio 通道,SSL 会话和服务器端点 */ + + sprintf(name, "%s:%s", hostname, "https"); + BIO_get_ssl(bio, &ssl); /* 会话 */ + SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); /* 鲁棒性 */ + BIO_set_conn_hostname(bio, name); /* 准备连接 */ + + /* 尝试连接 */ + if (BIO_do_connect(bio) <= 0) { + cleanup(ctx, bio); + report_and_exit("BIO_do_connect..."); + } + + /* 验证信任库,检查证书 */ + if (!SSL_CTX_load_verify_locations(ctx, + "/etc/ssl/certs/ca-certificates.crt", /* 信任库 */ + "/etc/ssl/certs/")) /* 其它信任库 */ + report_and_exit("SSL_CTX_load_verify_locations..."); + + long verify_flag = SSL_get_verify_result(ssl); + if (verify_flag != X509_V_OK) + fprintf(stderr, + "##### Certificate verification error (%i) but continuing...\n", + (int) verify_flag); + + /* 获取主页作为示例数据 */ + sprintf(request, + "GET / HTTP/1.1\x0D\x0AHost: %s\x0D\x0A\x43onnection: Close\x0D\x0A\x0D\x0A", + hostname); + BIO_puts(bio, request); + + /* 从服务器读取 HTTP 响应并打印到输出 */ + while (1) { + memset(response, '\0', sizeof(response)); + int n = BIO_read(bio, response, BuffSize); + if (n <= 0) break; /* 0 代表流结束,< 0 代表有错误 */ + puts(response); + } + + cleanup(ctx, bio); +} + +int main() { + init_ssl(); + + const char* hostname = "www.google.com:443"; + fprintf(stderr, "Trying an HTTPS connection to %s...\n", hostname); + secure_connect(hostname); + +return 0; +} +``` + +可以从命令行编译和执行该程序(请注意 `-lssl` 和 `-lcrypto` 中的小写字母 `L`): + +``` +gcc -o client client.c -lssl -lcrypto +``` + +该程序尝试打开与网站 [www.google.com][13] 的安全连接。在与 Google Web 服务器的 TLS 握手过程中,`client` 程序会收到一个或多个数字证书,该程序会尝试对其进行验证(但在我的系统上失败了)。尽管如此,`client` 程序仍继续通过安全通道获取 Google 主页。该程序取决于前面提到的安全工件,尽管在上述代码中只着重突出了数字证书。但其它工件仍在幕后发挥作用,稍后将对它们进行详细说明。 + +通常,打开 HTTP(非安全)通道的 C 或 C++ 的客户端程序将使用诸如*文件描述符*或*网络套接字*之类的结构,它们是两个进程(例如,这个 `client` 程序和 Google Web 服务器)之间连接的端点。另一方面,文件描述符是一个非负整数值,用于在程序中标识该程序打开的任何文件类的结构。这样的程序还将使用一种结构来指定有关 Web 服务器地址的详细信息。 + +这些相对较低级别的结构不会出现在客户端程序中,因为 OpenSSL 库会将套接字基础设施和地址规范等封装在更高层面的安全结构中。其结果是一个简单的 API。下面首先看一下 `client` 程序示例中的安全性详细信息。 + +* 该程序首先加载相关的 OpenSSL 库,我的函数 `init_ssl` 中对 OpenSSL 进行了两次调用: + + ``` +SSL_load_error_strings(); +SSL_library_init(); +``` +* 下一个初始化步骤尝试获取安全*上下文*,这是建立和维护通往 Web 服务器的安全通道所需的信息框架。如对 OpenSSL 库函数的调用所示,在示例中使用了 TLS 1.2: + + ``` +const SSL_METHOD* method = TLSv1_2_client_method(); /* TLS 1.2 */ +``` + + 如果调用成功,则将 `method` 指针被传递给库函数,该函数创建类型为 `SSL_CTX` 的上下文: + + ``` +SSL_CTX* ctx = SSL_CTX_new(method); +``` + + `client` 程序会检查每个关键的库调用的错误,如果其中一个调用失败,则程序终止。 +* 现在还有另外两个 OpenSSL 工件也在发挥作用:SSL 类型的安全会话,从头到尾管理安全连接;以及类型为 BIO(基本输入/输出Basic Input/Output)的安全流,用于与 Web 服务器进行通信。BIO 流是通过以下调用生成的: + + ``` +BIO* bio = BIO_new_ssl_connect(ctx); +``` + + 请注意,这个最重要的上下文是其参数。`BIO` 类型是 C 语言中 `FILE` 类型的 OpenSSL 封装器。此封装器可保护 `client` 程序与 Google 的网络服务器之间的输入和输出流的安全。 +* 有了 `SSL_CTX` 和 `BIO`,然后程序在 SSL 会话中将它们组合在一起。三个库调用可以完成工作: + + ``` +BIO_get_ssl(bio, &ssl); /* 会话 */ +SSL_set_mode(ssl, SSL_MODE_AUTO_RETRY); /* 鲁棒性 */ +BIO_set_conn_hostname(bio, name); /* 准备连接 */ +``` + + 安全连接本身是通过以下调用建立的: + + ``` +BIO_do_connect(bio); +``` + + 如果最后一个调用不成功,则 `client` 程序终止;否则,该连接已准备就绪,可以支持 `client` 程序与 Google Web 服务器之间的机密对话。 + +在与 Web 服务器握手期间,`client` 程序会接收一个或多个数字证书,以认证服务器的身份。但是,`client` 程序不会发送自己的证书,这意味着这个身份验证是单向的。(Web 服务器通常配置为**不**需要客户端证书)尽管对 Web 服务器证书的验证失败,但 `client` 程序仍通过了连接到 Web 服务器的安全通道继续获取 Google 主页。 + +为什么验证 Google 证书的尝试会失败?典型的 OpenSSL 安装目录为 `/etc/ssl/certs`,其中包含 `ca-certificates.crt` 文件。该目录和文件包含着 OpenSSL 自带的数字证书,以此构成信任库truststore。可以根据需要更新信任库,尤其是可以包括新信任的证书,并删除不再受信任的证书。 + +`client` 程序从 Google Web 服务器收到了三个证书,但是我的计算机上的 OpenSSL 信任库并不包含完全匹配的证书。如目前所写,`client` 程序不会通过例如验证 Google 证书上的数字签名(一个用来证明该证书的签名)来解决此问题。如果该签名是受信任的,则包含该签名的证书也应受信任。尽管如此,`client` 程序仍继续获取页面,然后打印出 Google 的主页。下一节将更详细地介绍这些。 + +### 客户端程序中隐藏的安全性 + +让我们从客户端示例中可见的安全工件(数字证书)开始,然后考虑其他安全工件如何与之相关。数字证书的主要格式标准是 X509,生产级的证书由诸如 [Verisign][14] 的证书颁发机构Certificate Authority(CA)颁发。 + +数字证书中包含各种信息(例如,激活日期和失效日期以及所有者的域名),也包括发行者的身份和*数字签名*(这是加密过的*加密哈希*值)。证书还具有未加密的哈希值,用作其标识*指纹*。 + +哈希值来自将任意数量的二进制位映射到固定长度的摘要。这些位代表什么(会计报告、小说或数字电影)无关紧要。例如,消息摘要版本 5Message Digest version 5(MD5)哈希算法将任意长度的输入位映射到 128 位哈希值,而 SHA1(安全哈希算法版本 1Secure Hash Algorithm version 1)算法将输入位映射到 160 位哈希值。不同的输入位会导致不同的(实际上在统计学上是唯一的)哈希值。下一篇文章将会进行更详细的介绍,并着重介绍什么使哈希函数具有加密功能。 + +数字证书的类型有所不同(例如根证书、中间证书和最终实体证书),并形成了反映这些证书类型的层次结构。顾名思义,*根*证书位于层次结构的顶部,其下的证书继承了根证书所具有的信任。OpenSSL 库和大多数现代编程语言都具有 X509 数据类型以及处理此类证书的函数。来自 Google 的证书具有 X509 格式,`client` 程序会检查该证书是否为 `X509_V_OK`。 + +X509 证书基于公共密钥基础结构public-key infrastructure(PKI),其中包括的算法(RSA 是占主导地位的算法)用于生成*密钥对*:公共密钥及其配对的私有密钥。公钥是一种身份:[Amazon][15] 的公钥对其进行标识,而我的公钥对我进行标识。私钥应由其所有者负责保密。 + +成对出现的密钥具有标准用途。可以使用公钥对消息进行加密,然后可以使用同一个密钥对中的私钥对消息进行解密。私钥也可以用于对文档或其他电子工件(例如程序或电子邮件)进行签名,然后可以使用该对密钥中的公钥来验证签名。以下两个示例补充了一些细节。 + +在第一个示例中,Alice 将她的公钥分发给全世界,包括 Bob。然后,Bob 用 Alice 的公钥加密邮件,然后将加密的邮件发送给 Alice。用 Alice 的公钥加密的邮件将可以用她的私钥解密(假设是她自己的私钥),如下所示: + +``` + +------------------+ encrypted msg +-------------------+ +Bob's msg--->|Alice's public key|--------------->|Alice's private key|---> Bob's msg + +------------------+ +-------------------+ +``` + +理论上可以在没有 Alice 的私钥的情况下解密消息,但在实际情况中,如果使用像 RSA 这样的加密密钥对系统,则在计算上做不到。 + +现在,第二个示例,请对文档签名以证明其真实性。签名算法使用密钥对中的私钥来处理要签名的文档的加密哈希: + +``` + +-------------------+ +Hash of document--->|Alice's private key|--->Alice's digital signature of the document + +-------------------+ +``` + +假设 Alice 以数字方式签署了发送给 Bob 的合同。然后,Bob 可以使用 Alice 密钥对中的公钥来验证签名: + +``` + +------------------+ +Alice's digital signature of the document--->|Alice's public key|--->verified or not + +------------------+ +``` + +假若没有 Alice 的私钥,就无法轻松伪造 Alice 的签名:因此,Alice 有必要保密她的私钥。 + +在 `client` 程序中,除了数字证书以外,这些安全性都没有明确展示。下一篇文章使用使用 OpenSSL 实用程序和库函数的示例填充更多详细的信息。 + +### 命令行的 OpenSSL + +同时,让我们看一下 OpenSSL 命令行实用程序:特别是在 TLS 握手期间检查来自 Web 服务器的证书的实用程序。调用 OpenSSL 实用程序可以使用 `openssl` 命令,然后添加参数和标志的组合以指定所需的操作。 + +看看以下命令: + +``` +openssl list-cipher-algorithms +``` + +该输出是组成加密算法套件cipher suite的相关算法的列表。下面是列表的开头,加了澄清首字母缩写词的注释: + +``` +AES-128-CBC ## Advanced Encryption Standard, Cipher Block Chaining +AES-128-CBC-HMAC-SHA1 ## Hash-based Message Authentication Code with SHA1 hashes +AES-128-CBC-HMAC-SHA256 ## ditto, but SHA256 rather than SHA1 +... +``` + +下一条命令使用参数 `s_client` 将打开到 [www.google.com][13] 的安全连接,并在屏幕上显示有关此连接的所有信息: + +``` +openssl s_client -connect www.google.com:443 -showcerts +``` + +端口号 443 是 Web 服务器用于接收 HTTPS(而不是 HTTP 连接)的标准端口号。(对于 HTTP,标准端口为 80)Web 地址 www.google.com:443 也出现在 `client` 程序的代码中。如果尝试连接成功,则将显示来自 Google 的三个数字证书以及有关安全会话、正在使用的加密算法套件以及相关项目的信息。例如,这是开头的部分输出,它声明*证书链*即将到来。证书的编码为 base64: + + +``` +Certificate chain + 0 s:/C=US/ST=California/L=Mountain View/O=Google LLC/CN=www.google.com + i:/C=US/O=Google Trust Services/CN=Google Internet Authority G3 +-----BEGIN CERTIFICATE----- +MIIEijCCA3KgAwIBAgIQdCea9tmy/T6rK/dDD1isujANBgkqhkiG9w0BAQsFADBU +MQswCQYDVQQGEwJVUzEeMBwGA1UEChMVR29vZ2xlIFRydXN0IFNlcnZpY2VzMSUw +... +``` + +诸如 Google 之类的主要网站通常会发送多个证书进行身份验证。 + +输出以有关 TLS 会话的摘要信息结尾,包括加密算法套件的详细信息: + +``` +SSL-Session: +    Protocol : TLSv1.2 +    Cipher : ECDHE-RSA-AES128-GCM-SHA256 +    Session-ID: A2BBF0E4991E6BBBC318774EEE37CFCB23095CC7640FFC752448D07C7F438573 +... +``` + +`client` 程序中使用了协议 TLS 1.2,`Session-ID` 唯一地标识了 `openssl` 实用程序和 Google Web 服务器之间的连接。`Cipher` 条目可以按以下方式进行解析: + +* `ECDHE`(椭圆曲线 Diffie-Hellman(临时)Elliptic Curve Diffie Hellman Ephemeral)是一种用于管理 TLS 握手的高效的有效算法。尤其是,ECDHE 通过确保连接双方(例如,`client` 程序和 Google Web 服务器)使用相同的加密/解密密钥(称为*会话密钥*)来解决“密钥分发问题”。后续文章会深入探讨该细节。 +* `RSA`(Rivest Shamir Adleman)是主要的公共密钥密码系统,并以 1970 年代末首次描述了该系统的三位学者的名字命名。这个正在使用的密钥对是使用 RSA 算法生成的。 +* `AES128`(高级加密标准Advanced Encryption Standard)是一种块式加密算法block cipher,用于加密和解密位块blocks of bits。(另一种算法是流式加密算法stream cipher,它一次加密和解密一个位。)这个加密算法是对称加密算法,因为使用同一个密钥进行加密和解密,这首先引起了密钥分发问题。AES 支持 128(此处使用)、192 和 256 位的密钥大小:密钥越大,安全性越好。 + + 通常,像 AES 这样的对称加密系统的密钥大小要小于像 RSA 这样的非对称(基于密钥对)系统的密钥大小。例如,1024 位 RSA 密钥相对较小,而 256 位密钥则当前是 AES 最大的密钥。 +* `GCM`(伽罗瓦计数器模式Galois Counter Mode)处理在安全对话期间重复应用的加密算法(在这种情况下为 AES128)。AES128 块的大小仅为 128 位,安全对话很可能包含从一侧到另一侧的多个 AES128 块。GCM 非常有效,通常与 AES128 搭配使用。 +* `SHA256`(256 位安全哈希算法Secure Hash Algorithm 256 bits)是我们正在使用的加密哈希算法。生成的哈希值的大小为 256 位,尽管使用 SHA 甚至可以更大。 + +加密算法套件正在不断发展中。例如,不久前,Google 使用 RC4 流加密算法(RSA 的 Ron Rivest 后来开发的 Ron's Cipher 版本 4)。 RC4 现在有已知的漏洞,这大概部分导致了 Google 转换为 AES128。 + +### 总结 + +我们通过安全的 C Web 客户端和各种命令行示例对 OpenSSL 做了首次了解,使一些需要进一步阐明的主题脱颖而出。[下一篇文章会详细介绍][17],从加密散列开始,到对数字证书如何应对密钥分发挑战为结束的更全面讨论。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/cryptography-basics-openssl-part-1 + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu/users/akritiko/users/clhermansen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_3reasons.png?itok=k6F3-BqA (A lock on the side of a building) +[2]: https://www.openssl.org/ +[3]: https://www.howtoforge.com/tutorial/how-to-install-openssl-from-source-on-linux/ +[4]: http://condor.depaul.edu/mkalin +[5]: https://en.wikipedia.org/wiki/Transport_Layer_Security +[6]: https://en.wikipedia.org/wiki/Netscape +[7]: http://www.opengroup.org/onlinepubs/009695399/functions/perror.html +[8]: http://www.opengroup.org/onlinepubs/009695399/functions/exit.html +[9]: http://www.opengroup.org/onlinepubs/009695399/functions/sprintf.html +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html +[11]: http://www.opengroup.org/onlinepubs/009695399/functions/memset.html +[12]: http://www.opengroup.org/onlinepubs/009695399/functions/puts.html +[13]: http://www.google.com +[14]: https://www.verisign.com +[15]: https://www.amazon.com +[16]: http://www.google.com:443 +[17]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-2 diff --git a/translated/tech/20190724 How to make an old computer useful again.md b/published/202001/20190724 How to make an old computer useful again.md similarity index 69% rename from translated/tech/20190724 How to make an old computer useful again.md rename to published/202001/20190724 How to make an old computer useful again.md index 1df6d5fabd..726436a18a 100644 --- a/translated/tech/20190724 How to make an old computer useful again.md +++ b/published/202001/20190724 How to make an old computer useful again.md @@ -1,18 +1,20 @@ [#]: collector: (lujun9972) [#]: translator: (chen-ni) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11746-1.html) [#]: subject: (How to make an old computer useful again) [#]: via: (https://opensource.com/article/19/7/how-make-old-computer-useful-again) -[#]: author: (Howard Fosdick https://opensource.com/users/howtechhttps://opensource.com/users/don-watkinshttps://opensource.com/users/suehlehttps://opensource.com/users/aseem-sharmahttps://opensource.com/users/sethhttps://opensource.com/users/marcobravohttps://opensource.com/users/dragonbitehttps://opensource.com/users/don-watkinshttps://opensource.com/users/jamesfhttps://opensource.com/users/seth) +[#]: author: (Howard Fosdick https://opensource.com/users/howtech) 如何把你的老爷机重新利用起来 ====== -按照下面各个步骤,让你的老爷机焕然一新 -![Person typing on a 1980's computer][1] -你的地下室里有一台用来落灰的旧电脑?为什么不把它利用起来呢?如果你常用的电脑坏了,又想用一个比手机更大的屏幕上网,这时候一台备用电脑可能就派上用场了。或者,它也可以充当一台全家人共用的廉价辅助电脑,甚至还可以改造为一台复古游戏机。 +> 按照下面各个步骤,让你的老爷机焕然一新。 + +![](https://img.linux.net.cn/data/attachment/album/202001/04/064017ztl28cn6jjhnjnaj.jpg) + +你的地下室里是不是有一台用来落灰的旧电脑?为什么不把它利用起来呢?如果你常用的电脑坏了,又想用一个比手机更大的屏幕上网,这时候一台备用电脑可能就派上用场了。或者,它也可以充当一台全家人共用的廉价备用电脑,甚至还可以改造为一台复古游戏机。 哪怕是一台有十余年历史的老爷机,只要选对了软件,也可以胜任很多新电脑能够完成的任务。其中的关键在于,要使用开源软件。 @@ -22,7 +24,7 @@ 第一步是检查硬件是否运转正常。如果在这个环节忽略了一个问题,后面可能会让你非常头疼。 -灰尘是电子器件的天敌,所以第一件事应该是打开机箱,清除灰尘。[压缩空气设备][2]这时候可能会派上用场。请注意,进行任何接触电脑的操作时,都应该确保你是[触地][3]的。此外,_避免_ 清洁布与任何物体发生摩擦。即使是一次小到你无法察觉的静电放电,也可能会导致电路损毁。 +灰尘是电子器件的天敌,所以第一件事应该是打开机箱,清除灰尘。[压缩空气设备][2]这时候可能会派上用场。请注意,进行任何接触电脑的操作时,都应该确保[接地][3]。此外,**不要**用清洁布擦拭任何东西。即使是一次小到你无法察觉的静电放电,也可能会导致电路损毁。 清洁工作完成之后,关闭机箱,检查是否所有硬件都可以正常工作。需要测试的项目包括: @@ -31,23 +33,23 @@ * 主板 * 外围设备(DVD 驱动器、USB 接口、声卡,等等) -首先,将计算机启动面板([UEFI][4] 或者是 [BIOS][5]面板)上的诊断测试依次运行一遍。如果不知道按哪个程序功能按键进入你电脑的启动面板,可以参考 [这份列表][6]。 +首先,将计算机启动界面([UEFI][4] 或者是 [BIOS][5] 界面)上的诊断测试依次运行一遍。如果不知道按哪个功能键进入你电脑的启动界面,可以参考 [这份列表][6]。 -此外,也可以使用诸如 [Hirens BootCD][7] 和 [Ultimate Boot CD][8] 之类的免费资源工具包,进行启动面板覆盖不到的测试。这些资源工具包涵盖了数百个测试程序,并且都是免费的,尽管不都开源。运行这些工具包无需安装任何软件,因为它们都是从 U 盘或者 DVD 驱动器启动的。 +此外,也可以使用诸如 [Hirens BootCD][7] 和 [Ultimate Boot CD][8] 之类的免费资源工具包,进行启动界面覆盖不到的测试。这些资源工具包涵盖了数百个测试程序,并且都是免费的,尽管不都开源。运行这些工具包无需安装任何软件,因为它们都是从 U 盘或者 DVD 驱动器启动的。 测试一定要彻底!对于内存和硬盘来说,基础测试还不够,应该运行深度测试,哪怕是运行一整夜也无妨。只有这样,才能够查出那些不易发现的瞬时故障。 -如果发现了问题,可以参考我的[硬件故障排除快速指南][9],帮你解决最常见的硬件问题。 +如果发现了问题,可以参考我的[硬件故障排除快速指南][9],可以帮你解决最常见的硬件问题。 ### 选择软件 电脑翻新的关键在于,根据手头的硬件资源,恰如其分地安装软件。最核心的三种硬件资源分别是: -1. 处理器(核数、速度) +1. 处理器(内核数、速度) 2. 内存 3. 显存 -可以在启动时的 UEFI/BIOS 面板上,弄清楚你电脑的硬件资源。记得抄下数据,以免遗忘。接下来,可以在 [CPU Benchmark][10] 网站上查看你的处理器,该网站除了提供 CPU 的背景资料,还提供一个 CPU 的性能分数。 +可以在启动时的 UEFI/BIOS 界面上,弄清楚你电脑的硬件资源。记得抄下数据,以免遗忘。接下来,可以在 [CPU Benchmark][10] 网站上查看你的处理器,该网站除了提供 CPU 的背景资料,还提供一个 CPU 的性能分数。 了解了硬件性能之后,就可以选择能够在硬件上高效运行的软件了。软件的选择涉及四个重要的层面: @@ -56,19 +58,19 @@ 3. 浏览器 4. 应用 -一个优秀的 Linux 发行版可以满足全部四个层面。不要试图使用已经停止维护的 Windows 版本,例如 Windows 8、Vista 或者 XP,哪怕已经安装在电脑上了。恶意软件的 [风险][11] 你是承受不起的。明智的做法是,使用一个更抗病毒的最新版本操作系统。 +一个优秀的 Linux 发行版可以满足上述全部四个层面。不要试图使用已经停止维护的 Windows 版本,例如 Windows 8、Vista 或者 XP,哪怕已经安装在电脑上了。恶意软件的[风险][11]你是承受不起的。明智的做法是,使用一个更抗病毒的最新版本操作系统。 -那 Windows 7 呢?[维护宽限期][12] 至 2020 年 1 月 14 日结束,也就是说,在此日期之前你还可以获得安全补丁,之后就想都别想了。现在正是迁出 Windows 7 的绝佳时机。 +那 Windows 7 呢?[维护宽限期][12]至 2020 年 1 月 14 日结束,也就是说,在此日期之前你还可以获得安全补丁,之后就想都别想了。现在正是迁出 Windows 7 的绝佳时机。 Linux 的巨大优势在于,有许多专门为过时硬件设计的[发行版][13]。此外,[桌面环境][14]和操作系统在 Linux 的设计中是分开的,你可以自行选择搭配。这一点非常重要,因为桌面环境对低端系统的性能有很大影响。(对于 Windows 和 MacOS 来说,你选择的操作系统版本决定了桌面环境,没得可选。) -Linux 的另一个好处是,拥有数以千计免费且开源的应用,不需要担心激活或者许可的问题。此外,Linux 是可移植的,可以在不同的分区、硬盘、设备或计算机之间,对操作系统和应用进行复制、移动或克隆。(Windows 则不然,使用注册表将系统捆绑在了所安装的计算机上。) +Linux 的另一个好处是,拥有数以千计自由且开源的应用,不需要担心激活或者许可的问题。此外,Linux 是可移植的,可以在不同的分区、硬盘、设备或计算机之间,对操作系统和应用进行复制、移动或克隆。(Windows 则不然,使用注册表将系统捆绑在了所安装的计算机上。) ### 翻新后的电脑能够做什么? 这里讨论的是大约在 2006 年到 2013 年之间生产的双核计算机,尤其是装载了 [Intel 酷睿 2][15] CPU 或 [AMD 速龙 64 X2][16] 系列处理器的计算机。它们的 [CPU 分数][10] 大多在 1000 到 4000 分之间。这种电脑卖不了几个钱,但用在运行轻量级 Linux 软件上,性能还是足够的。 -有一点需要注意:你的电脑应该至少拥有 2 GB 内存,如果不够就进行升级。就我翻新过的电脑来说,使用者用到的内存(不包括数据缓存)一般在 0.5 到 2 GB 之间,很少超过 2 GB。如果将内存升级到 2GB,系统就不至于进行 _swap_,即将硬盘当做内存使用。如果想要获得良好性能,这一点十分关键。 +有一点需要注意:你的电脑应该至少拥有 2 GB 内存,如果不够就进行升级。就我翻新过的电脑来说,使用者用到的内存(不包括数据缓存)一般在 0.5 到 2 GB 之间,很少超过 2 GB。如果将内存升级到 2GB,系统就不至于进行**内存交换**,即将硬盘当做内存使用。如果想要获得良好性能,这一点十分关键。 以我自己为例,我用来写作这篇文章的是一台有十年机龄的翻新电脑。取下 1 GB 内存条之后,它只剩下了 1 GB 内存,然后就慢得像一只乌龟。用它浏览网页,或者是做类似的事情,都让人感到灰心,甚至痛苦。一旦把内存条重新装回去,有了 2 GB 内存,它就立马回到了可以使用的状态。 @@ -76,19 +78,19 @@ Linux 的另一个好处是,拥有数以千计免费且开源的应用,不 ### 翻新电脑的局限 -那么,这些老爷机又有什么局限呢?由于它们的并发比不上最先进的计算机,所以应该使用轻量级浏览器,同时拦截广告(广告正是让网页加载变慢的罪魁祸首)。如果可以使用虚拟专用网络(VPN)拦截广告,为处理器免除广告加载的负荷,那就再好不过。此外,还需要禁用视频自动播放、Flash 以及网页动效;将浏览器上的标签页控制在少数几个,不要同时打开 20 个;以及下载可以开启/禁用 JavaScript 的浏览器扩展。 +那么,这些老爷机又有什么局限呢?由于它们的并发性能比不上最先进的计算机,所以应该使用轻量级浏览器,同时拦截广告(广告正是让网页加载变慢的罪魁祸首)。如果可以使用虚拟专用网络(VPN)拦截广告,为处理器免除加载广告的负荷,那就再好不过。此外,还需要禁用视频自动播放、Flash 以及网页动画效果;将浏览器上的标签页控制在少数几个,不要同时打开 20 个;以及下载可以开启/禁用 JavaScript 的浏览器扩展。 让处理器专注于你目前正在做的事情吧,不要同时打开一堆应用,也不要在后台运行很多程序。图像编辑和视频编辑的高级工具可能会很慢;至于运行虚拟机,还是别想了吧。 -那游戏呢?开源软件仓库提供了数以千计的游戏。这就是我为什么将显存列为三种核心硬件资源之一。如果你的电脑没有显卡,那很可能只有 32 或者 64 MB 的显存。可以增加一张显卡,将显存提升到 256 或者 512 MB,这样一来,处理器密集型的游戏就会顺畅很多了。如果不确定你的电脑有多少显存,可以参考[这里][17]。请注意,需要确保显卡与电脑的[显卡插槽][18](AGP、PCI-Express 或者 PCI)相匹配,同时使用正确的[连接线][19](VGA、DVI 或者 HDMI)。 +那游戏呢?开源软件仓库提供了数以千计的游戏。这就是我为什么将显存列为三种核心硬件资源之一。如果你的电脑没有独立显卡,那很可能只有 32 或者 64 MB 的显存。可以增加一张显卡,将显存提升到 256 或者 512 MB,这样一来,处理器密集型的游戏就会顺畅很多了。如果不确定你的电脑有多少显存,可以参考[这里][17]。请注意,需要确保显卡与电脑的[显卡插槽][18](AGP、PCI-Express 或者 PCI)相匹配,同时使用正确的[连接线][19](VGA、DVI 或者 HDMI)。 #### 与 Windows 系统的兼容性如何? -许多人关心 Linux 与 Windows 系统的兼容性如何。首先,对于任何一个 Windows 程序,都有一个 [Linux 的替代版本][20]。 +许多人关心 Linux 与 Windows 系统的兼容性如何。首先,对于任何一个 Windows 程序,都有一个 [Linux 版本的替代品][20]。 退一步说,即使你真的必须要运行某个特定的 Windows 程序,通常也可以借助 [Wine][21] 在 Linux 上运行。可以在 [Wine 数据库][22] 里查找一下你的应用,看看是否可以在 Wine 上运行,顺便学一些特殊安装技巧。[Winetricks][23] 和 [PlayOnLinux][24] 这两个辅助工具可以帮助你进行安装和配置。 -Wine 的另一个优势是可以运行 Windows 的老版本,例如 Vista、XP、ME/98/95 和 3.1。我认识一个家伙,搭建了一台特别赞的游戏电脑,然后用来玩 XP 上的老游戏。借助 [DOSBox][26],你甚至还可以运行数以千计的[免费 DOS 程序][25]。但是有一点需要注意,如果 Windows 程序可以运行,那么 Windows [病毒][27]也同样可以。你需要保护 Linux 上的 Wine 环境,正如保护任何其他 Windows 环境一样。 +Wine 的另一个优势是可以运行旧版本 Windows(例如 Vista、XP、ME/98/95 和 3.1)上的程序。我认识一个家伙,搭建了一台特别赞的游戏电脑,然后用来玩 XP 上的老游戏。借助 [DOSBox][26],你甚至还可以运行数以千计的[免费 DOS 程序][25]。但是有一点需要注意,如果 Windows 程序可以运行,那么 Windows [病毒][27]也同样可以。你需要保护 Linux 上的 Wine 环境,正如保护任何其他 Windows 环境一样。 对了,与 Microsoft Office 的兼容性又如何呢?我使用的是 LibreOffice,经常编辑并交换 Word 和 Excel 文件,完全没有问题。不过,你应该避免使用隐晦或者过于专业的功能。 @@ -96,7 +98,7 @@ Wine 的另一个优势是可以运行 Windows 的老版本,例如 Vista、XP 假设选择了 Linux 作为操作系统,那么你还需要选择桌面环境、浏览器和各种应用。最简单的方法是,安装一个包含了你所需要的一切的发行版。 -通过从 [live USB][28] U 盘或者 DVD 启动,你无需安装任何程序,就可以尝试不同的发行版。关于在 Linux 或 Windows 上创建可启动的 Linux 的方法,可以参考 [这里][29]。 +通过从 [live USB][28] U 盘或者 DVD 启动,你无需安装任何程序,就可以尝试不同的发行版。关于在 Linux 或 Windows 上创建可启动的 Linux 的方法,可以参考[这里][29]。 我进行电脑翻新的目的是做慈善,所以无法指望电脑使用者具备任何相应知识。我需要的发行版应该具有以下特性: @@ -110,11 +112,11 @@ Wine 的另一个优势是可以运行 Windows 的老版本,例如 Vista、XP * 更重视可靠性,而不是尖端功能 * 可以通过图形化用户界面进行设置,而不是只能通过文本文件进行设置 -许多发行版都能够满足上面的要求。我曾经尝试成功的有 [Mint/Xfce][30]、[Xubuntu,][31] 和 [Lubuntu][32]。前两个发行版使用 Xfce 桌面环境,第三个使用 LXQt。相比 GNOME、Unity、KDE、MATE 和 Cinnamon 这些桌面环境,运行上面这两种桌面环境只需要[更少][33]的处理器和内存资源。 +许多发行版都能够满足上面的要求。我曾经尝试成功的有 [Mint/Xfce][30]、[Xubuntu][31] 和 [Lubuntu][32]。前两个发行版使用 Xfce 桌面环境,第三个使用 LXQt。相比 GNOME、Unity、KDE、MATE 和 Cinnamon 这些桌面环境,运行上面这两种桌面环境只需要[更少][33]的处理器和内存资源。 Xfce 和 LXQt 用起来非常简单,我的客户们之前从未见过 Linux,但是都可以自如使用这些简单的、菜单驱动的用户界面。 -对于旧电脑来说,运行最快速、最高效的浏览器是一件非常重要的事情。[很多人觉得][34] Chromium 是最好的浏览器;此外,我还安装了 Firefox Quantum,因为大家比较熟悉它,并且[它的性能][35]可以和 [Chromium 的性能][36]媲美。我还加上了 Opera,因为它速度快,而且有一些独特功能,比如内置的广告拦截,以及免费的 [虚拟专用网络][37]。Opera 是免费的,但并非开源。 +对于旧电脑来说,运行最快速、最高效的浏览器是一件非常重要的事情。[很多人觉得][34] Chromium 是最好的浏览器;此外,我还安装了 Firefox Quantum,因为大家比较熟悉它,并且[它的性能][35]可以和 [Chromium 的性能][36]媲美。我还加上了 Opera,因为它速度快,而且有一些独特功能,比如内置的广告拦截,以及免费的[虚拟专用网络][37]。Opera 是免费的,但并非开源。 无论你使用什么浏览器,一定要拦截广告和追踪器,尽量降低浏览器的负荷。此外,除非得到你的明确批准,否则视频和 Flash 都不应该被允许运行。 @@ -122,7 +124,7 @@ Xfce 和 LXQt 用起来非常简单,我的客户们之前从未见过 Linux, ### 行动起来吧 -你是否会对翻新后的电脑感到满意呢?就我来说,我所使用的两台电脑的机龄都已经超过十年了,其中一个装载的是 Intel 双核处理器([eMachines T5274a][38]),另一个装载的是 AMD 速龙 64 x2 处理器([HP dc5750][39]),两台电脑都有 2 GB 内存。它们和我的另一台具备四核 i5 处理器和 16 GB 内存 的电脑一样,完全能够胜任我的办公工作。如果说有什么功能是这两台电脑缺失的,那就是运行虚拟机了。 +你是否会对翻新后的电脑感到满意呢?就我来说,我所使用的两台电脑的机龄都已经超过十年了,其中一个装载的是 Intel 双核处理器([eMachines T5274a][38]),另一个装载的是 AMD 速龙 64 x2 处理器([HP dc5750][39]),两台电脑都有 2 GB 内存。它们和我的另一台具备四核 i5 处理器和 16 GB 内存的电脑一样,完全能够胜任我的办公工作。如果说有什么功能是这两台电脑缺失的,那就是运行虚拟机了。 我们生活在一个非常神奇的年代。只需要付出一点努力,就可以将一台机龄在 5 到 12 年之间的旧电脑,翻新为一台具备实用价值的机器。还有什么比这更有趣吗? @@ -133,11 +135,11 @@ via: https://opensource.com/article/19/7/how-make-old-computer-useful-again 作者:[Howard Fosdick][a] 选题:[lujun9972][b] 译者:[chen-ni](https://github.com/chen-ni) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]: https://opensource.com/users/howtechhttps://opensource.com/users/don-watkinshttps://opensource.com/users/suehlehttps://opensource.com/users/aseem-sharmahttps://opensource.com/users/sethhttps://opensource.com/users/marcobravohttps://opensource.com/users/dragonbitehttps://opensource.com/users/don-watkinshttps://opensource.com/users/jamesfhttps://opensource.com/users/seth +[a]: https://opensource.com/users/howtech [b]: https://github.com/lujun9972 [1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) [2]: https://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=compressed+air+for+computers&rh=i%3Aaps%2Ck%3Acompressed+air+for+computers diff --git a/published/202001/20190924 An advanced look at Python interfaces using zope.interface.md b/published/202001/20190924 An advanced look at Python interfaces using zope.interface.md new file mode 100644 index 0000000000..f2918057fc --- /dev/null +++ b/published/202001/20190924 An advanced look at Python interfaces using zope.interface.md @@ -0,0 +1,127 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11752-1.html) +[#]: subject: (An advanced look at Python interfaces using zope.interface) +[#]: via: (https://opensource.com/article/19/9/zopeinterface-python-package) +[#]: author: (Moshe Zadka https://opensource.com/users/moshezhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/sethhttps://opensource.com/users/drmjg) + +借助 zope.interface 深入了解 Python 接口 +====== + +> Zope.interface 可以帮助声明存在哪些接口,是由哪些对象提供的,以及如何查询这些信息。 + +![Snake charmer cartoon with a yellow snake and a blue snake][1] + +`zope.interface` 库可以克服 Python 接口设计中的歧义性。让我们来研究一下。 + +### 隐式接口不是 Python 之禅 + +[Python 之禅][2] 很宽松,但是有点自相矛盾,以至于你可以用它来例证任何东西。让我们来思考其中最著名的原则之一:“显示胜于隐式”。 + +传统上,在 Python 中会隐含的一件事是预期的接口。比如函数已经记录了它期望一个“类文件对象”或“序列”。但是什么是类文件对象呢?它支持 `.writelines`吗?`.seek` 呢?什么是一个“序列”?是否支持步进切片,例如 `a[1:10:2]`? + +最初,Python 的答案是所谓的“鸭子类型”,取自短语“如果它像鸭子一样行走,像鸭子一样嘎嘎叫,那么它可能就是鸭子”。换句话说,“试试看”,这可能是你能得到的最具隐式的表达。 + +为了使这些内容显式地表达出来,你需要一种方法来表达期望的接口。[Zope][3] Web 框架是最早用 Python 编写的大型系统之一,它迫切需要这些东西来使代码明确呈现出来,例如,期望从“类似用户的对象”获得什么。 + +`zope.interface` 由 Zope 开发,但作为单独的 Python 包发布。`Zope.interface` 可以帮助声明存在哪些接口,是由哪些对象提供的,以及如何查询这些信息。 + +想象编写一个简单的 2D 游戏,它需要各种东西来支持精灵界面(LCTT 译注:“精灵 Sprite”是指游戏面板中各个组件)。例如,表示一个边界框,但也要表示对象何时与一个框相交。与一些其他语言不同,在 Python 中,将属性访问作为公共接口一部分是一种常见的做法,而不是实现 getter 和 setter。边界框应该是一个属性,而不是一个方法。 + +呈现精灵列表的方法可能类似于: + +``` +def render_sprites(render_surface, sprites): +    """ +    sprites 应该是符合 Sprite 接口的对象列表: +    * 一个名为 "bounding_box" 的属性,包含了边界框 +    * 一个名为 "intersects" 的方法,它接受一个边界框并返回 True 或 False +    """ +    pass # 一些做实际渲染的代码 +``` + +该游戏将具有许多处理精灵的函数。在每个函数中,你都必须在随附文档中指定预期。 + +此外,某些函数可能期望使用更复杂的精灵对象,例如具有 Z 序的对象。我们必须跟踪哪些方法需要 Sprite 对象,哪些方法需要 SpriteWithZ 对象。 + +如果能够使精灵是显式而直观的,这样方法就可以声明“我需要一个精灵”,并有个严格定义的接口,这不是很好吗?来看看 `zope.interface`。 + +``` +from zope import interface + +class ISprite(interface.Interface): + +    bounding_box = interface.Attribute( +        "边界框" +    ) + +    def intersects(box): +        "它和一个框相交吗?" +``` + +乍看起来,这段代码有点奇怪。这些方法不包括 `self`,而包含 `self` 是一种常见的做法,并且它有一个**属性**。这是在 `zope.interface` 中声明接口的方法。这看起来很奇怪,因为大多数人不习惯严格声明接口。 + +这样做的原因是接口显示了如何调用方法,而不是如何定义方法。因为接口不是超类,所以它们可以用来声明数据属性。 + +下面是一个能带有圆形精灵的接口的一个实现: + +``` +@implementer(ISprite) +@attr.s(auto_attribs=True) +class CircleSprite: +    x: float +    y: float +    radius: float + +    @property +    def bounding_box(self): +        return ( +            self.x - self.radius, +            self.y - self.radius, +            self.x + self.radius, +            self.y + self.radius, +        ) + +    def intersects(self, box): +        # 当且仅当至少一个角在圆内时,方框与圆相交 +        top_left, bottom_right = box[:2], box[2:] +        for choose_x_from (top_left, bottom_right): +            for choose_y_from (top_left, bottom_right): +                x = choose_x_from[0] +                y = choose_y_from[1] +                if (((x - self.x) ` 2 + (y - self.y) ` 2) <= +                    self.radius ` 2): +                     return True +        return False +``` + +这**显式**声明了实现了该接口的 `CircleSprite` 类。它甚至能让我们验证该类是否正确实现了接口: + +``` +from zope.interface import verify + +def test_implementation(): +    sprite = CircleSprite(x=0, y=0, radius=1) +    verify.verifyObject(ISprite, sprite) +``` + +这可以由 pytest、nose 或其他测试框架运行,它将验证创建的精灵是否符合接口。测试通常是局部的:它不会测试仅在文档中提及的内容,甚至不会测试方法是否可以在没有异常的情况下被调用!但是,它会检查是否存在正确的方法和属性。这是对单元测试套件一个很好的补充,至少可以防止简单的拼写错误通过测试。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/9/zopeinterface-python-package + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshezhttps://opensource.com/users/lauren-pritchetthttps://opensource.com/users/sethhttps://opensource.com/users/drmjg +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/getting_started_with_python.png?itok=MFEKm3gl (Snake charmer cartoon with a yellow snake and a blue snake) +[2]: https://en.wikipedia.org/wiki/Zen_of_Python +[3]: http://zope.org diff --git a/published/202001/20190930 How the Linux screen tool can save your tasks - and your sanity - if SSH is interrupted.md b/published/202001/20190930 How the Linux screen tool can save your tasks - and your sanity - if SSH is interrupted.md new file mode 100644 index 0000000000..f52dbd55f6 --- /dev/null +++ b/published/202001/20190930 How the Linux screen tool can save your tasks - and your sanity - if SSH is interrupted.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11822-1.html) +[#]: subject: (How the Linux screen tool can save your tasks – and your sanity – if SSH is interrupted) +[#]: via: (https://www.networkworld.com/article/3441777/how-the-linux-screen-tool-can-save-your-tasks-and-your-sanity-if-ssh-is-interrupted.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如果 SSH 被中断,Linux screen 工具如何拯救你的任务以及理智 +====== + +> 当你需要确保长时间运行的任务不会在 SSH 会话中断时被杀死时,Linux screen 命令可以成为救生员。以下是使用方法。 + +![](https://images.idgesg.net/images/article/2019/09/working_w_screen-shs-100812448-large.jpg) + +如果因 SSH 会话断开而不得不重启一个耗时的进程,那么你可能会很高兴了解一个有趣的工具,可以用来避免此问题:`screen` 工具。 + +`screen` 是一个终端多路复用器,它使你可以在单个 SSH 会话中运行多个终端会话,并随时从它们之中脱离或重新接驳。做到这一点的过程非常简单,仅涉及少数命令。 + +要启动 `screen` 会话,只需在 SSH 会话中键入 `screen`。 然后,你可以开始启动需要长时间运行的进程,并在适当的时候键入 `Ctrl + A Ctrl + D` 从会话中脱离,然后键入 `screen -r` 重新接驳。 + +如果你要运行多个 `screen` 会话,更好的选择是为每个会话指定一个有意义的名称,以帮助你记住正在处理的任务。使用这种方法,你可以在启动每个会话时使用如下命令命名: + +``` +$ screen -S slow-build +``` + +一旦运行了多个会话,要重新接驳到一个会话,需要从列表中选择它。在以下命令中,我们列出了当前正在运行的会话,然后再重新接驳其中一个。请注意,一开始这两个会话都被标记为已脱离。 + +``` +$ screen -ls +There are screens on: + 6617.check-backups (09/26/2019 04:35:30 PM) (Detached) + 1946.slow-build (09/26/2019 02:51:50 PM) (Detached) +2 Sockets in /run/screen/S-shs +``` + +然后,重新接驳到该会话要求你提供分配给会话的名称。例如: + +``` +$ screen -r slow-build +``` + +在脱离的会话中,保持运行状态的进程会继续进行处理,而你可以执行其他工作。如果你使用这些 `screen` 会话之一来查询 `screen` 会话情况,可以看到当前重新接驳的会话再次显示为 `Attached`。 + +``` +$ screen -ls +There are screens on: + 6617.check-backups (09/26/2019 04:35:30 PM) (Attached) + 1946.slow-build (09/26/2019 02:51:50 PM) (Detached) +2 Sockets in /run/screen/S-shs. +``` + +你可以使用 `-version` 选项查询正在运行的 `screen` 版本。 + +``` +$ screen -version +Screen version 4.06.02 (GNU) 23-Oct-17 +``` + +### 安装 screen + +如果 `which screen` 未在屏幕上提供信息,则可能你的系统上未安装该工具。 + +``` +$ which screen +/usr/bin/screen +``` + +如果你需要安装它,则以下命令之一可能适合你的系统: + +``` +sudo apt install screen +sudo yum install screen +``` + +当你需要运行耗时的进程时,如果你的 SSH 会话由于某种原因断开连接,则可能会中断这个耗时的进程,那么 `screen` 工具就会派上用场。而且,如你所见,它非常易于使用和管理。 + +以下是上面使用的命令的摘要: + +``` +screen -S 开始会话 +Ctrl+A Ctrl+D 从会话中脱离 +screen -ls 列出会话 +screen -r 重新接驳会话 +``` + +尽管还有更多关于 `screen` 的知识,包括可以在 `screen` 会话之间进行操作的其他方式,但这已经足够帮助你开始使用这个便捷的工具了。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3441777/how-the-linux-screen-tool-can-save-your-tasks-and-your-sanity-if-ssh-is-interrupted.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE20773&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20191015 How GNOME uses Git.md b/published/202001/20191015 How GNOME uses Git.md new file mode 100644 index 0000000000..d39600f1ef --- /dev/null +++ b/published/202001/20191015 How GNOME uses Git.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11806-1.html) +[#]: subject: (How GNOME uses Git) +[#]: via: (https://opensource.com/article/19/10/how-gnome-uses-git) +[#]: author: (Molly de Blanc https://opensource.com/users/mollydb) + +一个非技术人员对 GNOME 项目使用 GitLab 的感受 +====== + +> 将 GNOME 项目集中在 GitLab 上的决定为整个社区(不只是开发人员)带来了好处。 + +![red panda][1] + +“您的 GitLab 是什么?”这是我在 [GNOME 基金会][2]工作的第一天被问到的第一个问题之一,该基金会是支持 GNOME 项目(包括[桌面环境][3]、[GTK][4] 和 [GStreamer][5])的非盈利组织。此人问的是我在 [GNOME 的 GitLab 实例][6]上的用户名。我在 GNOME 期间,经常有人要求我提供我的 GitLab。 + +我们使用 GitLab 进行几乎所有操作。通常情况下,我会收到一些提案issue和参考错误报告,有时还需要修改文件。我不是以开发人员或系统管理员的身份进行此操作的。我参与了“参与度、包容性和多样性(I&D)”团队。我为 GNOME 朋友们撰写新闻通讯,并采访该项目的贡献者。我为 GNOME 活动提供赞助。我不写代码,但我每天都使用 GitLab。 + +在过去的二十年中,GNOME 项目的管理采用了各种方式。该项目的不同部分使用不同的系统来跟踪代码更改、协作以及作为项目和社交空间共享信息。但是,该项目决定,它需要更加地一体化,这从构思到完成大约花费了一年的时间。 + +GNOME 希望切换到单个工具供整个社区使用的原因很多。外部项目与 GNOME 息息相关,并为它们提供更简单的与资源交互的方式对于项目至关重要,无论是支持社区还是发展生态系统。我们还希望更好地跟踪 GNOME 的指标,即贡献者的数量、贡献的类型和数量以及项目不同部分的开发进度。 + +当需要选择一种协作工具时,我们考虑了我们需要的东西。最重要的要求之一是它必须由 GNOME 社区托管。由第三方托管并不是一种选择,因此像 GitHub 和 Atlassian 这样的服务就不在考虑之中。而且,当然了,它必须是自由软件。很快,唯一真正的竞争者出现了,它就是 GitLab。我们希望确保进行贡献很容易。GitLab 具有诸如单点登录的功能,该功能允许人们使用 GitHub、Google、GitLab.com 和 GNOME 帐户登录。 + +我们认为 GitLab 是一条出路,我们开始从许多工具迁移到单个工具。GNOME 董事会成员 [Carlos Soriano][7] 领导这项改变。在 GitLab 和 GNOME 社区的大力支持下,我们于 2018 年 5 月完成了该过程。 + +人们非常希望迁移到 GitLab 有助于社区的发展,并使贡献更加容易。由于 GNOME 以前使用了许多不同的工具,包括 Bugzilla 和 CGit,因此很难定量地评估这次切换对贡献量的影响。但是,我们可以更清楚地跟踪一些统计数据,例如在 2018 年 6 月至 2018 年 11 月之间关闭了近 10,000 个提案,合并了 7,085 个合并请求。人们感到社区在发展壮大,越来越受欢迎,而且贡献实际上也更加容易。 + +人们因不同的原因而开始使用自由软件,重要的是,可以通过为需要软件的人提供更好的资源和更多的支持来公平竞争。Git 作为一种工具已被广泛使用,并且越来越多的人使用这些技能来参与到自由软件当中。自托管的 GitLab 提供了将 Git 的熟悉度与 GitLab 提供的功能丰富、用户友好的环境相结合的绝佳机会。 + +切换到 GitLab 已经一年多了,变化确实很明显。持续集成(CI)为开发带来了巨大的好处,并且已经完全集成到 GNOME 的几乎每个部分当中。不进行代码开发的团队也转而使用 GitLab 生态系统进行工作。无论是使用问题跟踪来管理分配的任务,还是使用版本控制来共享和管理资产,就连“参与度、包容性和多样性(I&D)”这样的团队都已经使用了 GitLab。 + +一个社区,即使是一个正在开发的自由软件,也很难适应新技术或新工具。在类似 GNOME 的情况下,这尤其困难,该项目[最近已经 22 岁了] [8]。像 GNOME 这样经过了 20 多年建设的项目,太多的人和组织使用了太多的部件,但迁移工作之所以能实现,这要归功于 GNOME 社区的辛勤工作和 GitLab 的慷慨帮助。 + +在为使用 Git 进行版本控制的项目工作时,我发现很方便。这是一个令人感觉舒适和熟悉的系统,是一个在工作场所和爱好项目之间保持一致的工具。作为 GNOME 社区的新成员,能够参与并使用 GitLab 真是太好了。作为社区建设者,看到这样结果是令人鼓舞的:越来越多的相关项目加入并进入生态系统;新的贡献者和社区成员对该项目做出了首次贡献;以及增强了衡量我们正在做的工作以了解其成功和成功的能力。 + +如此多的做着完全不同的事情(例如他们正在从事的不同工作以及所使用的不同技能)的团队同意汇集在一个工具上(尤其是被认为是跨开源的标准工具),这一点很棒。作为 GNOME 的贡献者,我真的非常感谢我们使用了 GitLab。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/how-gnome-uses-git + +作者:[Molly de Blanc][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mollydb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/redpanda_firefox_pet_animal.jpg?itok=aSpKsyna (red panda) +[2]: https://www.gnome.org/foundation/ +[3]: https://gnome.org/ +[4]: https://www.gtk.org/ +[5]: https://gstreamer.freedesktop.org/ +[6]: https://gitlab.gnome.org/ +[7]: https://twitter.com/csoriano1618?lang=en +[8]: https://opensource.com/article/19/8/poll-favorite-gnome-version diff --git a/published/202001/20191016 Open source interior design with Sweet Home 3D.md b/published/202001/20191016 Open source interior design with Sweet Home 3D.md new file mode 100644 index 0000000000..814f0bdb23 --- /dev/null +++ b/published/202001/20191016 Open source interior design with Sweet Home 3D.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11774-1.html) +[#]: subject: (Open source interior design with Sweet Home 3D) +[#]: via: (https://opensource.com/article/19/10/interior-design-sweet-home-3d) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Sweet Home 3D 开放源码室内设计 +====== + +> 在你去真实世界购物前,在虚拟世界中尝试家具布局、配色方案等等。 + +![](https://img.linux.net.cn/data/attachment/album/202001/12/092633eyc3c9f7u3gfgj4e.jpg) + +这里有关于如何装饰房间的三大流派: + +1. 购买一堆家具,并把它们塞进房间。 +2. 仔细测量每件家具,计算房间的理论容量,然后把它们全部塞进房间,忽略你在床上放置一个书架的事实。 +3. 使用一台计算机进行预先可视化。 + +之前,我还实践了鲜为人知的第四个方式:不要家具。然而,自从我成为一个远程工作者,我发现家庭办公需要一些便利的设施,像一张桌子和一张椅子,一个用于存放参考书和技术手册的书架等等。因此,我一直在制定一个使用实际的家具来迁移我的生活和工作空间的计划,在该*计划*上强调由实木制作,而不是牛奶箱子(或胶水和锯末板之类的东西)。我最不想做的一件事:从旧货市场淘到得宝贝带回家时,发现其进不了门,或者比另一件家具大很多。 + +是时候做专业人士该做的事了,是时候做视觉预览了。 + +### 开放源码室内设计 + +[Sweet Home 3D][2] 是一个开源的(GPLv2)室内设计应用程序,可以帮助你绘制你的住宅平面图,然后定义、重新调整大小以及安排家具。你可以使用精确的尺寸来完成这些,精确到一厘米以下,而不使用任何数学运算,仅使用简单的拖拽操作就行。当你完成后,你可以以 3D 方式查看结果。在 Sweet Home 3D 中规划你家的室内设计,就和在 Word 程序中创建基本的表格一样简单。 + +### 安装 + +Sweet Home 3D 是一个 [Java][3] 应用程序,因此它是平台通用的。它运行在任何可以运行 Java 的操作系统上,包括 Linux、Windows、MacOS 和 BSD 。不用理会你的操作系统,你可以从网站[下载][4]该应用程序。 + +* 在 Linux 上,[untar][5] 存档文件。在 `SweetHome3D` 文件上右键单击,并选择**属性**。在**权限**选项卡中,授予文件可执行权限。 +* 在 MacOS 和 Windows 上,展开存档文件并启动应用程序。当系统提示时,你必需授予它权限来在你的系统上运行。 + +![Sweet Home 3D permissions][6] + +在 Linux 上,你也可以像一个 Snap 软件包一样安装 Sweet Home 3D ,前提是你已经安装并启用 **snapd**。 + +### 成功的测量 + +首先:打开你的卷尺。为充分利用 Sweet Home 3D,你必须知道你所计划的生活空间的实际尺寸。你可能需要测量精度到毫米或 1/16 英寸;你可以自己把握对偏差幅度的容忍度。但是你必需获得基本的尺寸,包括测量墙壁和门窗。 + +用你最好的判断力来判断常识。例如,当测量门时,包括门框;虽然从技术上讲它不是*门*本身的一部分,但它可能是你不想用家具遮挡的一部分墙壁空间。 + +![Measure twice, execute once][7] + +### 创建一间房间 + +当你第一次启动 Sweet Home 3D 时,它会以其默认查看模式来打开一个空白的画布,蓝图视图在顶部面板中,3D 渲染在底部面板中。在我的 [Slackware][8] 桌面计算机上,它可以很好地工作,不过我的桌面计算机也是我的视频编辑和游戏计算机,所以它有一个极好的 3D 渲染显卡。在我的笔记本计算机上,这种视图模式是非常慢的。为了最好的性能(尤其是在一台计没有 3D 渲染的专用计算机上),转到窗口顶部的 **3D 视图** 菜单,并选择 **虚拟访问** 。这个视图模式基于虚拟访客的位置从地面视图渲染你的工作。这意味着你可以控制渲染的内容和时机。 + +不管你计算机是否强力,切换到这个视图的有意义的,因为地表以上的 3D 渲染不比蓝图平面图向你提供更多有用的详细信息。在你更改视图模式后,你可以开始设计。 + +第一步是定义你家的墙壁。使用**创建墙壁**工具完成,可以在顶部工具栏的**手形**图标右侧找到。绘制墙壁很简单:单击你想要墙壁开始的位置,单击以锚定位置,不断单击锚定,直到你的房间完成。 + +![Drawing walls in Sweet Home 3D][9] + +在你闭合墙壁后,按 `Esc` 来退出工具。 + +#### 定义一间房间 + +Sweet Home 3D 在你如何创建墙壁的问题上是灵活的。你可以先绘制你房子的外部边界,然后再细分内部,或者你可以绘制每个房间作为结成一体的“容器”,最终形成你房子所占的空间量。这种灵活性是能做到的,因为在现实生活中和在 Sweet Home 3D 中,墙壁并不总是用来定义一间房间。为定义一间房间,使用在顶部工具栏的**创建墙壁**按钮右侧的**创建房间**按钮。 + +如果房间的地板空间是通过四面墙所定义,你需要做的全部的定义是像一间房间一样在四面墙壁内双击来圈占地方。Sweet Home 3D 将定义该空间为一间房间,并根据你的喜好,以英尺或米为单位向你提供房间的面积。 + +对于不规则的房间,你必需使用每次单击来手动定义房间的每个墙角。根据房间形状的复杂性,你可能不得不进行试验来发现你是否需要从你的原点来顺时针或逆时针工作,以避免奇怪的莫比斯条形地板。不过,一般来说,定义一间房间的地板空间是简单的。 + +![Defining rooms in Sweet Home 3D][10] + +在你给定房间一层地板后,你可以更改到**箭头**工具,并在房间上双击来给予它一个名称。你也可以设置地板、墙壁、天花板和踢脚线的颜色及纹理。 + +![Modifying room floors, ceilings, etc. in Sweet Home 3D][11] + +默认情况下,这些都不会在蓝图视图中渲染。为启用在你蓝图面板中的房间渲染,转到**文件**菜单并选择**首选项**。在**首选项**面板中,设置**平面图中房间渲染**为**地板颜色或纹理**。 + +### 门和窗 + +在你完成基本的地板平面图后,你可以长期地切换到**箭头**工具。 + +你可以在 Sweet Home 3D 的左栏中的**门和窗**类别下找到门和窗。你有很多选择,所以选择最接近你家的东西。 + +![Moving a door in Sweet Home 3D][12] + +为放置一扇门或窗到你的平面图中,在你的蓝图平面图中的合适的墙壁上拖拽门或窗。要调整它的位置和大小,请双击门或窗。 + +### 添加家具 + +随着基本平面图完成,这部分工作感觉像是结束了!从这点继续,你可以摆弄家具布置以及其它装饰。 + +你可以在左栏中找到家具,按预期的方式来组织每个房间。你可以拖拽任何项目到你的蓝图平面图中,当你的鼠标悬停在项目的区域上时,使用可视化工具控制方向和大小。在任何项目上双击双击来调整它的颜色和成品表面。 + +### 查看和导出 + +为了看看你未来的家将会看起来是什么样子,在你的蓝图视图中拖拽“人”图标到一个房间中。 + +![Sweet Home 3D rendering][13] + +你可以在现实和空间感受之间找到自己的平衡,你的想象力是你唯一的限制。你可以从 Sweet Home 3D [下载页面][4]获取附加的有用的资源来添加到你的家中。你甚至可以使用**库编辑器**应用程序创建你自己的家具和纹理,它可以从该项目的网站下载。 + +Sweet Home 3D 可以导出你的蓝图平面图为 SVG 格式,以便在 [Inkscape][14] 中使用,并且它可以导出你的 3D 模型为 OBJ 格式,以便在 [Blender][15] 中使用。为导出你的蓝图,转到**平面图**菜单,并选择**导出为 SVG 格式**。为导出一个 3D 模型,转到 **3D 视图** 菜单并选择**导出为 OBJ 格式**。 + +你也可以拍摄你家的"快照,以便于不打开 Sweet Home 3D 而回顾你的想法。为创建一个快照,转到 **3D 视图**菜单并选择**创建照片**。快照是按照蓝图视图中的人的图标的角度展现的,因此按照需要调整,然后在**创建照片**窗口中单击**创建**按钮。如果你对快照满意,单击**保存**。 + +### 甜蜜的家 + +在 Sweet Home 3D 中有更多的特色。你可以添加一片天空和一片草坪,为你的照片定位光线,设置天花板高度,给你房子添加另一楼层等等。不管你是打算租一套公寓,还是买一套房子,或是(尚)不存在的房子,Sweet Home 3D 是一款简单迷人的应用程序,当你匆忙购买家具时,它可以帮助你快乐地做出更好的购买选择。因此,你终于可以停止在厨房的柜台上吃早餐以及蹲在地上工作了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/interior-design-sweet-home-3d + +作者:[Seth Kenlon][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://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_housing.png?itok=s7i6pQL1 (Several houses) +[2]: http://www.sweethome3d.com/ +[3]: https://opensource.com/resources/java +[4]: http://www.sweethome3d.com/download.jsp +[5]: https://opensource.com/article/17/7/how-unzip-targz-file +[6]: https://opensource.com/sites/default/files/uploads/sweethome3d-permissions.png (Sweet Home 3D permissions) +[7]: https://opensource.com/sites/default/files/images/life/sweethome3d-measure.jpg (Measure twice, execute once) +[8]: http://www.slackware.com/ +[9]: https://opensource.com/sites/default/files/uploads/sweethome3d-walls.jpg (Drawing walls in Sweet Home 3D) +[10]: https://opensource.com/sites/default/files/uploads/sweethome3d-rooms.jpg (Defining rooms in Sweet Home 3D) +[11]: https://opensource.com/sites/default/files/uploads/sweethome3d-rooms-modify.jpg (Modifying room floors, ceilings, etc. in Sweet Home 3D) +[12]: https://opensource.com/sites/default/files/uploads/sweethome3d-move.jpg (Moving a door in Sweet Home 3D) +[13]: https://opensource.com/sites/default/files/uploads/sweethome3d-view.jpg (Sweet Home 3D rendering) +[14]: http://inkscape.org +[15]: http://blender.org diff --git a/published/202001/20191017 Intro to the Linux useradd command.md b/published/202001/20191017 Intro to the Linux useradd command.md new file mode 100644 index 0000000000..d088a1d16d --- /dev/null +++ b/published/202001/20191017 Intro to the Linux useradd command.md @@ -0,0 +1,204 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11756-1.html) +[#]: subject: (Intro to the Linux useradd command) +[#]: via: (https://opensource.com/article/19/10/linux-useradd-command) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +Linux useradd 命令介绍 +====== + +> 使用 useradd 命令来添加用户(并且根据需要修改账号)。 + +![](https://img.linux.net.cn/data/attachment/album/202001/06/225733hv1u7f4z4vbt8u5x.jpg) + +任何计算机系统中,添加用户都是最重要的事之一;本文着重介绍如何在 Linux 系统中添加用户。 + +正式开始之前,我先提三个概念。首先,跟大多数操作系统一样,Linux 用户也需要一个账号才能登录。本文只介绍本地账号,不涉及网络账号,如 LDAP。其次,每个账号都有一个名字(username)和一个对应的数字(用户 ID)。最后,每个用户通常都在一个组内,每个组都有一个名字和一个组 ID。 + +你可能已经想到了,Linux 提供了添加用户的命令行工具,就是 `useradd` 命令。有些版本也叫 `adduser`。为了方便使用,很多发行版上这个命令是一个指向 `useradd` 命令的符号链接。 + +``` +$ file `which adduser` +/usr/sbin/adduser: symbolic link to useradd +``` + +来看一下 `useradd`。 + +> 注意:本文描述的默认环境是 Red Hat Enterprise Linux 8.0。你可能会发现本文描述的这些文件和某些默认值与某些 Linux 发行版或其他 Unix 操作系统(FreeBSD 或 Solaris)偶尔会有差异。 + +### 默认处理 + +`useradd` 的基本用法相当简单:提供一个用户名就可以添加一个用户。 + +```bash +$ sudo useradd sonny +``` + +在本例中,`useradd` 命令创建了一个名为 `sonny` 的账号。此命令同时创建了一个同名的组,`sonny` 被放进了这个组,这个组也是 `sonny` 账号的主组。命令执行时,根据配置文件 `/etc/default/useradd` 和 `/etc/login.defs` 中的不同设置,也会有其他的参数,如语言和 shell。对于一个私人系统或微小的单服务商业环境,这些参数已经足够了。 + +上面两个文件控制 `useradd` 的处理,用户的信息保存在 `/etc` 目录下的一些其他文件中,关于这些信息的讲解会贯穿全文。 + +| 文件 | 描述 | 域 (加粗的表示由 useradd 命令设置) | +| ------ | ------------------------------------ | ------------------------------------------------------------ | +| `passwd` | 存储用户账号信息 | **用户名**:未使用:**UID**:**GID**:**备注**:**家目录**:**shell** | +| `shadow` | 存储用户账号的安全信息 | **用户名**:加密密码:上次修改时间:最短使用天数:最长使用天数间:**修改前警示天数**:**过期后宽限时间**:未使用 | +| `group` | 存储组信息 | **组名**:未使用:**GID**:**成员列表** | + +### 自定义处理 + +当管理员需要更好地控制账号时,可以使用命令行来自定义,如指定一个用户的 ID。 + +#### 用户和组 ID + +默认情况下,`useradd` 试图使用相同的用户 ID(UID)和主组 ID(GID),但也不完全是。虽然 UID 与 GID 相同不是必须的,但如果相同,会更方便管理员管理。 + +下面的场景就是一个 GID 与 UID 不同的例子。现在我添加另一账号,名为 Timmy。通过使用 `getent` 命令来比较 `sonny` 和 `timmy` 两个账号,显示两个用户和对应的主组。 + +```bash +$ getent passwd sonny timmy +sonny:x:1001:1002:Sonny:/home/sonny:/bin/bash +timmy:x:1002:1003::/home/timmy:/bin/bash + +$ getent group sonny timmy +sonny:x:1002: +timmy:x:1003: +``` + +不幸的是,两者的 UID 和 GID 都不相同。因为默认的处理是,创建用户时,把下一个可用的 UID 赋给用户,然后把同一个数字作为主组 ID 赋给它。然而,当要使用的组 ID 已经被使用时,就再把下一个可用的 GID 赋给它。为了弄清细节,我猜想 1001 这个 GID 已经被使用了,用一个命令确认了一下。 + +```bash +$ getent group 1001 +book:x:1001:alan +``` + +`book` 的 ID 是 `1001`,因此新创建的用户的 GID 都有偏移量 1。这就是为什么系统管理员在用户创建过程中需要多设置一些值的一个实例。为了解决这个问题,我必须先确定下一个可用的 UID 和 GID 是否相同。确定下一个可用值时,可以使用 `getent group` 和 `getent passwd` 命令,通过 `-u` 参数传递要确认的值。 + +```bash +$ sudo useradd -u 1004 bobby + +$ getent passwd bobby; getent group bobby +bobby:x:1004:1004::/home/bobby:/bin/bash +bobby:x:1004: +``` + +另一个需要指定 ID 的场景是,通过 NFS 访问远程系统上的文件时。对于一个给定的用户,当 NFS 所有客户端和服务系统的 ID 都一样时,管理员更容易控制。在我的文章 [使用 autofs 挂载 NFS][2] 中有详细介绍。 + +### 更多自定义 + +一些其他的指定用户信息的参数也用得比较频繁。这里是一些你会经常用到的参数的概括例子。 + +#### 注释 + +注释选项是通过 `-c` 参数指定的一个解释文本字段,可以提供一段简短的描述或其他信息。 + +```bash +$ sudo useradd -c "Bailey is cool" bailey +$ getent passwd bailey +bailey:x:1011:1011:Bailey is cool:/home/bailey:/bin/bash +``` + +#### 组 + +一个用户可以被指定一个主组和多个次组。`-g` 参数指定主组名称或 GID。如果不指定,`useradd` 会以用户名创建一个主组(前面演示过)。`-G`(大写)参数用一个逗号分隔的组列表来指定此用户所属的组,这些组就是次组。 + +```bash +$ sudo useradd -G tgroup,fgroup,libvirt milly +$ id milly +uid=1012(milly) gid=1012(milly) groups=1012(milly),981(libvirt),4000(fgroup),3000(tgroup) +``` + +#### 家目录 + +`useradd` 的默认处理是,在 `/home` 目录下创建用户的家目录。然而,下面的参数可以改写家目录的基础目录。`-b` 设置另一个可以创建家目录的基础目录。例如指定 `/home2` 而不是 `/home`。 + +```bash +$ sudo useradd -b /home2 vicky +$ getent passwd vicky +vicky:x:1013:1013::/home2/vicky:/bin/bash +``` + +`-d` 参数可以指定一个与用户名不同的家目录。 + +```bash +$ sudo useradd -d /home/ben jerry +$ getent passwd jerry +jerry:x:1014:1014::/home/ben:/bin/bash +``` + +#### 目录模板 + +指定 `-k` 参数会在创建新用户时,复制 `/etc/skel` 目录下的所有文件到用户的家目录中。这些文件通常是 shell 配置文件,当然也可以是系统管理员想在新建用户时使用的任何文件。 + +#### Shell + +`-s` 参数可以指定 shell。如果不指定,则使用默认的 shell。例如,下面的例子中 ,配置文件中定义的 shell 是 `bash`,但 `wally` 这个用户指定的是 `zsh`。 + +```bash +SHELL=/bin/bash + +$ sudo useradd -s /usr/bin/zsh wally +$ getent passwd wally +wally:x:1004:1004::/home/wally:/usr/bin/zsh +``` + +#### 安全 + +安全是用户管理的重中之重,因此 `useradd` 命令也提供了很多关于安全的选项。可以使用 `-e` 参数,以 YYYY-MM-DD 的格式指定一个用户的过期时间。 + +```bash +$ sudo useradd -e 20191231 sammy +$ sudo getent shadow sammy +sammy:!!:18171:0:99999:7::20191231: +``` + +当密码过期时,账号也会自动失效。`-f` 参数指定密码过期后经过几天账号失效。如果设为 0,则立即失效。 + +```bash +$ sudo useradd -f 30 willy +$ sudo getent shadow willy +willy:!!:18171:0:99999:7:30:: +``` + +### 实例 + +生产环境中,创建一个用户账号时会用到多个参数。例如,我要创建一个 Perry 账号,可能会用下面的命令: + +```bash +$ sudo useradd -u 1020 -c "Perry Example" \ +-G tgroup -b /home2 \ +-s /usr/bin/zsh \ +-e 20201201 -f 5 perry +``` + +查看前面的内容来理解每个选项。用下面的命令确认结果: + +```bash +$ getent passwd perry; getent group perry; getent shadow perry; id perry +perry:x:1020:1020:Perry Example:/home2/perry:/usr/bin/zsh +perry:x:1020: +perry:!!:18171:0:99999:7:5:20201201: +uid=1020(perry) gid=1020(perry) groups=1020(perry),3000(tgroup) +``` + +### 一点小建议 + +`useradd` 命令是所有 Unix(不仅仅是 Linux)系统管理员都必知必会的命令。由于用户创建不能出错,需要第一次就正确,所以理解它的每一个选项很重要。这意味着你需要有一套深思熟虑的命名约定,包括为整个企业环境而不仅仅是一个单系统预留一个专用的 UID/GID 范围,尤其是你为一个成长中的组织工作时。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/linux-useradd-command + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connection_people_team_collaboration.png?itok=0_vQT8xV (people in different locations who are part of the same team) +[2]: https://opensource.com/article/18/6/using-autofs-mount-nfs-shares diff --git a/published/202001/20191108 My Linux story- Learning Linux in the 90s.md b/published/202001/20191108 My Linux story- Learning Linux in the 90s.md new file mode 100644 index 0000000000..f31ae62e4f --- /dev/null +++ b/published/202001/20191108 My Linux story- Learning Linux in the 90s.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: (alim0x) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11831-1.html) +[#]: subject: (My Linux story: Learning Linux in the 90s) +[#]: via: (https://opensource.com/article/19/11/learning-linux-90s) +[#]: author: (Mike Harris https://opensource.com/users/mharris) + +我的 Linux 故事:在 90 年代学习 Linux +====== + +> 这是一个关于我如何在 WiFi 时代之前学习 Linux 的故事,那时的发行版还以 CD 的形式出现。 + +![](https://img.linux.net.cn/data/attachment/album/202001/29/213829t00wmwu2w0z502zg.jpg) + +大部分人可能不记得 1996 年时计算产业或日常生活世界的样子。但我很清楚地记得那一年。我那时候是堪萨斯中部一所高中的二年级学生,那是我的自由与开源软件(FOSS)旅程的开端。 + +我从这里开始进步。我在 1996 年之前就开始对计算机感兴趣。我在我家的第一台 Apple ][e 上启蒙成长,然后多年之后是 IBM Personal System/2。(是的,在这过程中有一些代际的跨越。)IBM PS/2 有一个非常激动人心的特性:一个 1200 波特的 Hayes 调制解调器。 + +我不记得是怎样了,但在那不久之前,我得到了一个本地 [BBS][2] 的电话号码。一旦我拨号进去,我可以得到本地的一些其他 BBS 的列表,我的网络探险就此开始了。 + +在 1995 年,[足够幸运][3]的人拥有了家庭互联网连接,每月可以使用不到 30 分钟。那时的互联网不像我们现代的服务那样,通过卫星、光纤、有线电视同轴电缆或任何版本的铜线提供。大多数家庭通过一个调制解调器拨号,它连接到他们的电话线上。(这时离移动电话无处不在的时代还早得很,大多数人只有一部家庭电话。)尽管这还要取决你所在的位置,但我不认为那时有很多独立的互联网服务提供商(ISP),所以大多数人从仅有的几家大公司获得服务,包括 America Online,CompuServe 以及 Prodigy。 + +你能获取到的服务速率非常低,甚至在拨号上网革命性地达到了顶峰的 56K,你也只能期望得到最高 3.5Kbps 的速率。如果你想要尝试 Linux,下载一个 200MB 到 800MB 的 ISO 镜像或(更加切合实际的)一套软盘镜像要贡献出时间、决心,以及减少电话的使用。 + +我走了一条简单一点的路:在 1996 年,我从一家主要的 Linux 发行商订购了一套 “tri-Linux” CD 集。这些光盘提供了三个发行版,我的这套包含了 Debian 1.1(Debian 的第一个稳定版本)、Red Hat Linux 3.0.3 以及 Slackware 3.1(代号 Slackware '96)。据我回忆,这些光盘是从一家叫做 [Linux Systems Labs][4] 的在线商店购买的。这家在线商店如今已经不存在了,但在 90 年代和 00 年代早期,这样的发行商很常见。这些是多光盘 Linux 套件。这是 1998 年的一套光盘,你可以了解到他们都包含了什么: + +![A tri-linux CD set][5] + +![A tri-linux CD set][6] + +在 1996 年夏天一个命中注定般的日子,那时我住在堪萨斯一个新的并且相对较为乡村的城市,我做出了安装并使用 Linux 的第一次尝试。在 1996 年的整个夏天,我尝试了那套三张 Linux CD 套件里的全部三个发行版。他们都在我母亲的老 Pentium 75MHz 电脑上完美运行。 + +我最终选择了 [Slackware][7] 3.1 作为我的首选发行版,相比其它发行版可能更多的是因为它的终端的外观,这是决定选择一个发行版前需要考虑的重要因素。 + +我将系统设置完毕并运行了起来。我连接到一家 “不太知名的” ISP(一家这个区域的本地服务商),通过我家的第二条电话线拨号(为了满足我的所有互联网使用而订购)。那就像在天堂一样。我有一台完美运行的双系统(Microsoft Windows 95 和 Slackware 3.1)电脑。我依然拨号进入我所知道和喜爱的 BBS,游玩在线 BBS 游戏,比如 Trade Wars、Usurper 以及 Legend of the Red Dragon。 + +我能够记得在 EFNet(IRC)上 #Linux 频道上渡过的日子,帮助其他用户,回答他们的 Linux 问题以及和版主们互动。 + +在我第一次在家尝试使用 Linux 系统的 20 多年后,已经是我进入作为 Red Hat 顾问的第五年,我仍然在使用 Linux(现在是 Fedora)作为我的日常系统,并且依然在 IRC 上帮助想要使用 Linux 的人们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/learning-linux-90s + +作者:[Mike Harris][a] +选题:[lujun9972][b] +译者:[alim0x](https://github.com/alim0x) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mharris +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS (Sky with clouds and grass) +[2]: https://en.wikipedia.org/wiki/Bulletin_board_system +[3]: https://en.wikipedia.org/wiki/Global_Internet_usage#Internet_users +[4]: https://web.archive.org/web/19961221003003/http://lsl.com/ +[5]: https://opensource.com/sites/default/files/20191026_142009.jpg (A tri-linux CD set) +[6]: https://opensource.com/sites/default/files/20191026_142020.jpg (A tri-linux CD set) +[7]: http://slackware.com diff --git a/published/202001/20191113 How to cohost GitHub and GitLab with Ansible.md b/published/202001/20191113 How to cohost GitHub and GitLab with Ansible.md new file mode 100644 index 0000000000..c9a05d6b40 --- /dev/null +++ b/published/202001/20191113 How to cohost GitHub and GitLab with Ansible.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11735-1.html) +[#]: subject: (How to cohost GitHub and GitLab with Ansible) +[#]: via: (https://opensource.com/article/19/11/how-host-github-gitlab-ansible) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何使用 Ansible 同步 GitHub 和 GitLab +====== + +> 通过使用 Ansible 镜像 Git 存储库,保护对重要项目的访问。 + +![](https://img.linux.net.cn/data/attachment/album/202001/01/104040fbdu68wosg8o99wg.jpg) + +开源无处不在。它在家里的计算机上、在工作场所的计算机上、在互联网上,并且很多都由 [Git][2] 管理。由于 Git 是分布式的,因此许多人也将其视为一种众包的备份解决方案。从理论上讲,每当有人将 Git 存储库克隆到其本地计算机时,他们就创建了该项目源代码的备份。如果有 100 个人这样做,则存储库就有 100 个备份副本。 + +从理论上讲,这可以缓解“灾难”的影响,例如当项目维护者[突然决定删除存储库][3]或[莫名其妙地阻止所有流量][4],导致开发人员们无头苍蝇般地寻找谁拥有主分支的最新版本。类似的,整个代码托管站点也会消失。没有人会想到 Google Code、Microsoft CodePlex 或 Gitorious 会在鼎盛时期将被关闭。 + +简而言之,如果在过去的几十年中互联网教给了我们一些东西,那就是依靠互联网神奇地创建备份并不是冗余的最可靠途径。 + +此外,对于许多人来说,很多开源项目都托管在 GitHub 上是个问题 —— GitHub 并不是开放平台。许多开发人员和用户都希望支持诸如 GitLab 之类的堆栈并与之交互,它具有开源社区版本。 + +### 使用 Ansible 管理 Git + +Git 的去中心方式对于解决这个问题很有用。使用纯 Git,你可以使用一个 `push` 命令轻松地将其推到两个或多个存储库。但是,为了使其在发生意外故障时有用,你必须经常与 Git 存储库进行交互(特别是推送)。此外,即使你可能永远不会自己推送或拉出代码,也可能有一些要备份的存储库。 + +但是,使用 Ansible,你可以自动执行项目主分支(或其他任何分支)的 Git 拉取,然后自动进行存储库到“异地”镜像的 Git 推送。换句话说,你可以让你的计算机定期从 GitHub 拉取并推送到 GitLab 或 [Gitolite][5] 或 Gitea(或你喜欢的任何 Git 托管主机)。 + +### Ansible 模块 + +如果不是因其出色的模块集合,那么 Ansible 就没那么出色。像 Python 的第三方库或 Linux 的应用程序一样,这个技术引擎的一个有用而令人惊讶的简单技巧是,Ansible 以其他人贡献的组件而闻名。因为本文正在研究如何有效和可靠地备份 Git 存储库,所以这里使用的模块是 [Git 模块][6]和 [ini_file][7] 模块。 + +首先,创建一个名为 `mirror.yaml` 的文件作为剧本playbook。你可以像通常使用 Ansible 一样,从 `name` 和 `task` 条目开始。本示例将 `localhost` 添加到 `hosts` 列表中,以便在控制器计算机(你现在坐在前面的计算机)上运行动作play,但是在现实生活中,你可能会在特定的主机或一组网络上的主机上运行它。 + +``` +--- +- name: "Mirror a Git repo with Ansible" + hosts: localhost + tasks: +``` + +### Git 拉取和克隆 + +如果要进行备份,则需要最新代码的副本。明显,在 Git 仓库中实现这一目标的方法是执行 `git pull`。 但是,`pull` 会假定克隆已经存在,而写得很好的 Ansible 动作(Ansible 脚本)则尽可能少的假定。最好告诉 Ansible 先克隆存储库。 + +将你的第一个任务添加到剧本: + +``` +--- +- name: "Mirror a Git repo with Ansible" + hosts: localhost + vars: + git_dir: /tmp/soso.git + tasks: + + - name: "Clone the git repo" + git: + repo: 'https://github.com/ozkl/soso.git' + dest: '{{ git_dir }}' + clone: yes + update: yes +``` + +这个例子使用了开源的、类似于 Unix 的操作系统 soso 作为我要镜像的存储库。这是一个完全任意的选择,绝不意味着我对该存储库的未来缺乏信心。它还使用变量来引用目标文件夹 `/tmp/soso.git`,这很方便,并且如果以后你希望将它扩展为一个通用的镜像脚本也会受益。在现实生活中,你的工作机上可能会比 `/tmp` 具有更永久的位置,例如 `/home/gitmirrors/soso.git` 或 `/opt/gitmirrors/soso.git`。 + +运行你的剧本: + +``` +$ ansible-playbook mirror.yaml +``` + +首次运行该剧本时,Ansible 会正确检测到 Git 存储库在本地尚不存在,因此将其克隆。 + +``` +PLAY [Ansible Git mirror] ******** + +TASK [Gathering Facts] *********** +ok: [localhost] + +TASK [Clone git repo] ************ +changed: [localhost] + +PLAY RECAP *********************** +localhost: ok=2 changed=1 failed=0 [...] +``` + +如果你再次运行该剧本,Ansible 会正确检测到自上次运行以来没有任何更改,并且会报告未执行任何操作: + +``` +localhost: ok=2 changed=0 failed=0 [...] +``` + +接下来,必须指示 Ansible 将存储库推送到另一个 Git 服务器。 + +### Git 推送 + +Ansible 中的 Git 模块不提供 `push` 功能,因此该过程的一部分是手动的。但是,在将存储库推送到备用镜像之前,你必须具有一个镜像,并且必须将镜像配置为备用远程服务器remote。 + +首先,必须将备用的远程服务器添加到 Git 配置。因为 Git 配置文件是 INI 样式的配置,所以你可以使用 `ini_file` Ansible 模块轻松地添加所需的信息。将此添加到你的剧本: + +``` + - name: "Add alternate remote" + ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='git@gitlab.com:example/soso-mirror.git' + tags: configuration +``` + +为此,你必须在目标服务器上有一个空的存储库(在本例中为 [GitLab.com][9])。如果需要在剧本中创建目标存储库,可以按照 Steve Ovens 的出色文章《[如何使用 Ansible 通过 SSH 设置 Git 服务器][10]》来完成。 + +最后,直接使用 Git 将 HEAD 推送到备用远程服务器: + +``` + - name: "Push the repo to alternate remote" + shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD' +``` + +像往常一样运行该剧本,然后使该过程自动化,这样你就不必再次直接运行它了。你可以使用变量和特定的 Git 命令来调整脚本以适应你的需求,但是通过常规的拉取和推送操作,可以确保驻留在一台服务器上的重要项目可以安全地镜像到另一台服务器上。 + +这是完整的剧本,供参考: + +``` +--- +- name: "Mirror a Git repository with Ansible" + hosts: localhost + vars: + git_dir: /tmp/soso.git + + tasks: + + - name: "Clone the Git repo" + git: + repo: 'https://github.com/ozkl/soso.git' + dest: '{{ git_dir }}' + clone: yes + update: yes + + - name: "Add alternate remote" + ini_file: dest={{ git_dir }}/.git/config section='remote \"mirrored\"' option=url value='git@gitlab.com:example/soso-mirror.git' + tags: configuration + + - name: "Push the repo to alternate remote" + shell: 'git --verbose --git-dir={{ git_dir }}/.git push mirrored HEAD' +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/how-host-github-gitlab-ansible + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) +[2]: https://opensource.com/resources/what-is-git +[3]: https://github.com/AntiMicro/antimicro/issues/3 +[4]: https://opensource.com/article/19/10/how-community-saved-artwork-creative-commons +[5]: https://opensource.com/article/19/4/server-administration-git +[6]: https://docs.ansible.com/ansible/latest/modules/git_module.html +[7]: https://docs.ansible.com/ansible/latest/modules/ini_file_module.html +[8]: mailto:git@gitlab.com +[9]: http://GitLab.com +[10]: https://opensource.com/article/17/8/ansible-environment-management diff --git a/published/202001/20191121 Simulate gravity in your Python game.md b/published/202001/20191121 Simulate gravity in your Python game.md new file mode 100644 index 0000000000..309dbf2091 --- /dev/null +++ b/published/202001/20191121 Simulate gravity in your Python game.md @@ -0,0 +1,395 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11780-1.html) +[#]: subject: (Simulate gravity in your Python game) +[#]: via: (https://opensource.com/article/19/11/simulate-gravity-python) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在你的 Python 游戏中模拟引力 +====== + +> 学习如何使用 Python 的 Pygame 模块编程电脑游戏,并开始操作引力。 + +![](https://img.linux.net.cn/data/attachment/album/202001/13/223923k6t4zmvvmo6tfmmg.png) + +真实的世界充满了运动和生活。物理学使得真实的生活如此忙碌和动态。物理学是物质在空间中运动的方式。既然一个电脑游戏世界没有物质,它也就没有物理学规律,使用游戏程序员不得不*模拟*物理学。 + +从大多数电脑游戏来说,这里基本上仅有两个方面的物理学是重要的:引力和碰撞。 + +当你[添加一个敌人][2]到你的游戏中时,你实现了一些碰撞检测,但是这篇文章要添加更多的东西,因为引力需要碰撞检测。想想为什么引力可能涉及碰撞。如果你不能想到任何原因,不要担心 —— 它会随着你开发示例代码工作而且显然。 + +在真实世界中的引力是有质量的物体来相互吸引的倾向性。物体(质量)越大,它施加越大的引力作用。在电脑游戏物理学中,你不必创建质量足够大的物体来证明引力的正确;你可以在电脑游戏世界本身中仅编程一个物体落向假设的最大的对象的倾向。 + +### 添加一个引力函数 + +记住你的玩家已经有了一个决定动作的属性。使用这个属性来将玩家精灵拉向屏幕底部。 + +在 Pygame 中,较高的数字更接近屏幕的底部边缘。 + +在真实的世界中,引力影响一切。然而,在平台游戏中,引力是有选择性的 —— 如果你添加引力到你的整个游戏世界,你的所有平台都将掉到地上。反之,你可以仅添加引力到你的玩家和敌人精灵中。 + +首先,在你的 `Player` 类中添加一个 `gravity` 函数: + +``` +    def gravity(self): +        self.movey += 3.2 # 玩家掉落的多快 +``` + +这是一个简单的函数。首先,不管你的玩家是否想运动,你设置你的玩家垂直运动。也就是说,你已经编程你的玩家总是在下降。这基本上就是引力。 + +为使引力函数生效,你必须在你的主循环中调用它。这样,当每一个处理循环时,Python 都应用下落运动到你的玩家。 + +在这代码中,添加第一行到你的循环中: + +``` +    player.gravity() # 检查引力 +    player.update() +``` + +启动你的游戏来看看会发生什么。要注意,因为它发生的很快:你是玩家从天空上下落,马上掉出了你的游戏屏幕。 + +你的引力模拟是工作的,但是,也许太好了。 + +作为一次试验,尝试更改你玩家下落的速度。 + +### 给引力添加一个地板 + +你的游戏没有办法发现你的角色掉落出世界的问题。在一些游戏中,如果一个玩家掉落出世界,该精灵被删除,并在某个新的位置重生。在另一些游戏中,玩家会丢失分数或一条生命。当一个玩家掉落出世界时,不管你想发生什么,你必须能够侦测出玩家何时消失在屏幕外。 + +在 Python 中,要检查一个条件,你可以使用一个 `if` 语句。 + +你必需查看你玩家**是否**正在掉落,以及你的玩家掉落的程度。如果你的玩家掉落到屏幕的底部,那么你可以做*一些事情*。简化一下,设置玩家精灵的位置为底部边缘上方 20 像素。 + +使你的 `gravity` 函数看起来像这样: + +``` +    def gravity(self): +        self.movey += 3.2 # 玩家掉落的多快 +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +``` + +然后,启动你的游戏。你的精灵仍然下落,但是它停在屏幕的底部。不过,你也许不能*看到*你在地面层之上的精灵。一个简单的解决方法是,在精灵碰撞游戏世界的底部后,通过添加另一个 `-ty` 到它的新 Y 位置,从而使你的精灵弹跳到更高处: + +``` +    def gravity(self): +        self.movey += 3.2 # 玩家掉落的多快 +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +``` + +现在你的玩家在屏幕底部弹跳,恰好在你地面精灵上面。 + +你的玩家真正需要的是反抗引力的方法。引力问题是,你不能反抗它,除非你有一些东西来推开引力作用。因此,在接下来的文章中,你将添加地面和平台碰撞以及跳跃能力。在这期间,尝试应用引力到敌人精灵。 + +到目前为止,这里是全部的代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + for enemy in enemy_hit_list: + self.health -= 1 + print(self.health) + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.health -= 1 + print(self.health) + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,lloc): + print(lvl) + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((0,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) + enemy_list.draw(world) + ground_list.draw(world) + plat_list.draw(world) + for e in enemy_list: + e.move() + pygame.display.flip() + clock.tick(fps) +``` + +* * * + +这是仍在进行中的关于使用 [Pygame][4] 模块来在 [Python 3][3] 在创建电脑游戏的第七部分。先前的文章是: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][5] + * [使用 Python 和 Pygame 模块构建一个游戏框架][6] + * [如何在你的 Python 游戏中添加一个玩家][7] + * [用 Pygame 使你的游戏角色移动起来][8] + * [如何向你的 Python 游戏中添加一个敌人][2] + * [在 Pygame 游戏中放置平台][9] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/simulate-gravity-python + +作者:[Seth Kenlon][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://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/space_stars_cosmic.jpg?itok=bE94WtN- (Cosmic stars in outer space) +[2]: https://linux.cn/article-10883-1.html +[3]: https://www.python.org/ +[4]: https://www.pygame.org +[5]: https://linux.cn/article-9071-1.html +[6]: https://linux.cn/article-10850-1.html +[7]: https://linux.cn/article-10858-1.html +[8]: https://linux.cn/article-10874-1.html +[9]: https://linux.cn/article-10902-1.html diff --git a/published/202001/20191129 How to write a Python web API with Django.md b/published/202001/20191129 How to write a Python web API with Django.md new file mode 100644 index 0000000000..5ba1650a1f --- /dev/null +++ b/published/202001/20191129 How to write a Python web API with Django.md @@ -0,0 +1,232 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to write a Python web API with Django) +[#]: via: (https://opensource.com/article/19/11/python-web-api-django) +[#]: author: (Rachel Waston https://opensource.com/users/rachelwaston) + +如何借助 Django 来编写一个 Python Web API +====== + +> Django 是 Python API 开发中最流行的框架之一,在这个教程中,我们来学习如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/202001/11/142503aio2325mk5weiozz.jpg) + +[Django][2] 所有 Web 框架中最全面的,也是最受欢迎的一个。自 2005 年以来,其流行度大幅上升。 + +Django 是由 Django 软件基金会维护,并且获得了社区的大力支持,在全球拥有超过 11,600 名成员。在 Stack Overflow 上,约有 191,000 个带 Django 标签的问题。Spotify、YouTube 和 Instagram 等都使用 Django 来构建应用程序和数据管理。 + +本文演示了一个简单的 API,通过它可以使用 HTTP 协议的 GET 方法来从服务器获取数据。 + +### 构建一个项目 + +首先,为你的 Django 应用程序创建一个目录结构,你可以在系统的任何位置创建: + +``` +$ mkdir myproject +$ cd myproject +``` + +然后,在项目目录中创建一个虚拟环境来隔离本地包依赖关系: + +``` +$ python3 -m venv env +$ source env/bin/activate +``` + +在 Windows 上,使用命令 `env\Scripts\activate` 来激活虚拟环境。 + +### 安装 Django 和 Django REST framework + +然后,安装 Django 和 Django REST 模块: + +``` +$ pip3 install django +$ pip3 install djangorestframework +``` + +### 实例化一个新的 Django 项目 + +现在你的应用程序已经有了一个工作环境,你必须实例化一个新的 Django 项目。与 [Flask][3] 这样微框架不同的是,Django 有专门的命令来创建(注意第一条命令后的 `.` 字符)。 + +``` +$ django-admin startproject tutorial . +$ cd tutorial +$ django-admin startapp quickstart +``` + +Django 使用数据库来管理后端,所以你应该在开始开发之前同步数据库,数据库可以通过 `manage.py` 脚本管理,它是在你运行 `django-admin` 命令时创建的。因为你现在在 `tutorial` 目录,所以使用 `../` 符号来运行脚本,它位于上一层目录: + +``` +$ python3 ../manage.py makemigrations +No changes detected +$ python4 ../manage.py migrate +Operations to perform: + Apply all migrations: admin, auth, contenttypes, sessions +Running migrations: + Applying contenttypes.0001_initial... OK + Applying auth.0001_initial... OK + Applying admin.0001_initial... OK + Applying admin.0002_logentry_remove_auto_add... OK + Applying admin.0003_logentry_add_action_flag_choices... OK + Applying contenttypes.0002_remove_content_type_name... OK + Applying auth.0002_alter_permission_name_max_length... OK + Applying auth.0003_alter_user_email_max_length... OK + Applying auth.0004_alter_user_username_opts... OK + Applying auth.0005_alter_user_last_login_null... OK + Applying auth.0006_require_contenttypes_0002... OK + Applying auth.0007_alter_validators_add_error_messages... OK + Applying auth.0008_alter_user_username_max_length... OK + Applying auth.0009_alter_user_last_name_max_length... OK + Applying auth.0010_alter_group_name_max_length... OK + Applying auth.0011_update_proxy_permissions... OK + Applying sessions.0001_initial... OK +``` + +### 在 Django 中创建用户 + +创建一个名为 `admin`,示例密码为 `password123` 的初始用户: + +``` +$ python3 ../manage.py createsuperuser \ + --email admin@example.com \ + --username admin +``` + +在提示时创建密码。 + +### 在 Django 中实现序列化和视图 + +为了使 Django 能够将信息传递给 HTTP GET 请求,必须将信息对象转化为有效的响应数据。Django 为此实现了“序列化类” `serializers`。 + +在你的项目中,创建一个名为 `quickstart/serializers.py` 的新模块,使用它来定义一些序列化器,模块将用于数据展示: + +``` +from django.contrib.auth.models import User, Group +from rest_framework import serializers + +class UserSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = User + fields = ['url', 'username', 'email', 'groups'] + +class GroupSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = Group + fields = ['url', 'name'] +``` + +Django 中的[视图][5]是一个接受 Web 请求并返回 Web 响应的函数。响应可以是 HTML、HTTP 重定向、HTTP 错误、JSON 或 XML 文档、图像或 TAR 文件,或者可以是从 Internet 获得的任何其他内容。要创建视图,打开 `quickstart/views.py` 并输入以下代码。该文件已经存在,并且其中包含一些示例文本,保留这些文本并将以下代码添加到文件中: + +``` +from django.contrib.auth.models import User, Group +from rest_framework import viewsets +from tutorial.quickstart.serializers import UserSerializer, GroupSerializer + +class UserViewSet(viewsets.ModelViewSet): + """ + API 允许查看或编辑用户 + """ + queryset = User.objects.all().order_by('-date_joined') + serializer_class = UserSerializer + +class GroupViewSet(viewsets.ModelViewSet): + """ + API 允许查看或编辑组 + """ + queryset = Group.objects.all() + serializer_class = GroupSerializer +``` + +### 使用 Django 生成 URL + +现在,你可以生成 URL 以便人们可以访问你刚起步的 API。在文本编辑器中打开 `urls.py` 并将默认示例代码替换为以下代码: + +``` +from django.urls import include, path +from rest_framework import routers +from tutorial.quickstart import views + +router = routers.DefaultRouter() +router.register(r'users', views.UserViewSet) +router.register(r'groups', views.GroupViewSet) + +# 使用自动路由 URL +# 还有登录 URL +urlpatterns = [ + path('', include(router.urls)), + path('api-auth/', include('rest_framework.urls', namespace='rest_framework')) +] +``` + +### 调整你的 Django 项目设置 + +这个示例项目的设置模块存储在 `tutorial/settings.py` 中,因此在文本编辑器中将其打开,然后在 `INSTALLED_APPS` 列表的末尾添加 `rest_framework`: + +``` +INSTALLED_APPS = [ + ... + 'rest_framework', +] +``` + +### 测试 Django API + +现在,你可以测试构建的 API。首先,从命令行启动内置服务器: + +``` +$ python3 manage.py runserver +``` + +你可以通过使用 `curl` 导航至 URL `http://localhost:8000/users` 来访问 API: + +``` +$ curl --get http://localhost:8000/users/?format=json +[{"url":"http://localhost:8000/users/1/?format=json","username":"admin","email":"admin@example.com","groups":[]}] +``` + +使用 Firefox 或你选择的[开源浏览器][6]: + +![一个简单的 Django API][7] + +有关使用 Django 和 Python 的 RESTful API 的更多深入知识,参考出色的 [Django 文档][8]。 + +### 为什么要使用 Djago? + +Django 的主要优点: + + 1. Django 社区的规模正在不断扩大,因此即使你做一个复杂项目,也会有大量的指导资源。 + 2. 默认包含模板、路由、表单、身份验证和管理工具等功能,你不必寻找外部工具,也不必担心第三方工具会引入兼容性问题。 + 3. 用户、循环和条件的简单结构使你可以专注于编写代码。 + 4. 这是一个成熟且经过优化的框架,它非常快速且可靠。 + +Django 的主要缺点: + + 1. Django 很复杂!从开发人员视角的角度来看,它可能比简单的框架更难学。 + 2. Django 有一个很大的生态系统。一旦你熟悉它,这会很棒,但是当你深入学习时,它可能会令人感到无所适从。 + +对你的应用程序或 API 来说,Django 是绝佳选择。下载并熟悉它,开始开发一个迷人的项目! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/python-web-api-django + +作者:[Rachel Waston][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rachelwaston +[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://www.djangoproject.com/ +[3]: https://opensource.com/article/19/11/python-web-api-flask +[4]: mailto:admin@example.com +[5]: https://docs.djangoproject.com/en/2.2/topics/http/views/ +[6]: https://opensource.com/article/19/7/open-source-browsers +[7]: https://opensource.com/sites/default/files/uploads/django-api.png (A simple Django API) +[8]: https://docs.djangoproject.com/en/2.2 diff --git a/published/202001/20191130 7 maker gifts for kids and teens.md b/published/202001/20191130 7 maker gifts for kids and teens.md new file mode 100644 index 0000000000..c92bcc29c9 --- /dev/null +++ b/published/202001/20191130 7 maker gifts for kids and teens.md @@ -0,0 +1,177 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11762-1.html) +[#]: subject: (7 maker gifts for kids and teens) +[#]: via: (https://opensource.com/article/19/11/maker-gifts-kids) +[#]: author: (Jess Weichler https://opensource.com/users/cyanide-cupcake) + +给儿童和青少年的 7 件创客礼物 +====== + +> 这份礼物指南使你轻松完成节日礼物的采购,它们可给婴儿、儿童、青少年及年龄更大的人们带来创造和创新能力。 + +![](https://img.linux.net.cn/data/attachment/album/202001/08/140516t4ewey9ryu24tpz5.jpg) + +还在纠结这个假期给年轻人买什么礼物?这是我精选的开源礼物,这些礼物将激发未来的创意和灵感。 + +### 蜂鸟机器人套件 + +![Hummingbird Robotics Kit][2] + +**年龄:**8 岁 - 成人 + +**这是什么:**[蜂鸟机器人套件][3]是一套完整的机器人套件,带有微控制器、电机、LED 和传感器。机器人的大脑具有特殊的端口,小手可以轻松地将其连接到机器人的组件上。蜂鸟套件并没有身体,而是鼓励用户自己创建一个。 + +**为什么我喜欢它:**蜂鸟可以使用多种编程语言 —— 从可视化编程(BirdBlox、MakeCode、Snap)到代码编程(Python 和 Java)—— 可以随着用户编码技能的提高而可扩展。所有组件均与你在电子商店中找到的组件完全相同,没有像其他机器人套件那样被塑料所遮盖。这使机器人的内部工作不再神秘,并在你需要时易于采购更多零件。 + +由于没有固定组装项目,因此蜂鸟是发挥创造力的完美机器人。 + +蜂鸟具有开源的软件和固件。它适用于 Linux、Windows、Mac、Chromebook、Android 和 iOS。 + +**费用:**起价为 99 美元。 + +### Makey Makey 经典版 + +![Makey Makey Classic][4] + +**年龄:** 6岁 - 成人 + +**这是什么:** [Makey Makey 经典版][5]可将任何导电物体(从棉花糖到你的朋友)变成计算机钥匙。 + +你可以使用鳄鱼夹将 Makey Makey 连接到你选择的导电物体上。然后,通过同时触摸两个导电物体来闭合接地和任何触发键之间的电路。Makey Makey 是一种安全的方法,可以安全地在家中探索电力,同时创造与计算机进行交互的有趣方式。 + +**为什么我喜欢它:** Makey Makey 可以与 Scratch 开发的视频游戏搭配使用,以创建独特的控制器,使用户进一步沉浸在游戏中。从用卫生纸卷和铝箔制成的工具到互动艺术和故事,可能性是无限的。它可以在具有 USB 端口的 Linux、Windows 和 Mac 计算机上使用。 + +**费用:** 49.95 美金 + +### Arduino Uno + +![Arduino Uno][6] + +**年龄:** 10 岁 - 成人 + +**这是什么:** Arduino 是随同电子套件购买的微控制器,也可以单独购买,它们具有多种版本,而我最喜欢 [Arduino Uno][7]。你可以根据需要从任何电子商店购买其他组件,例如 LED、电机和传感器。 + +**为什么我喜欢它:** Arduino Uno 的文档很完善,因此创客们很容易在线上找到教程。Arduino 可以实现从简单到复杂的各种电子项目。Arduino 具有开源的固件和硬件。它适用于 Linux、Mac 和 Windows。 + +**费用:** 主板的起价为 22.00 美元。总成本取决于项目和技能水平。 + +### DIY 创客套件 + +![A maker kit assembled in a quick trip to the hardware store][8] + +**年龄**:8 岁 - 成人 + +**这是什么:**当今许多创客、发明家和程序员都是从鼓捣碰巧出现在身边东西开始的。你可以快速前往最近的电子产品商店,为家里的年轻人创建一套出色的创客工具包。这是我的创客工具包中的内容: + +* 护目镜 +* 锤子 +* 钉子和螺丝 +* 碎木 +* 螺丝起子 +* 电线 +* LED +* 压电蜂鸣器 +* 马达 +* 带引线的 AA 电池组 +* 剪线钳 +* 纸板 +* 美纹纸胶带 +* 废布 +* 纽扣 +* 线程 +* 针 +* 拉链 +* 钩子 +* 一个很酷的工具盒,用来存放所有东西 + +**我为什么喜欢它:**还记得小时候,你把父母带回家的空纸箱变成了宇宙飞船、房屋或超级计算机吗?这就是为大孩子们准备的 DIY 创客工具包。 + +原始的组件使孩子们可以尝试并运用他们的想象力。DIY 创客工具包可以完全针对接收者定制。可以放入一些接受这份礼品的人可能从未想到过用之发挥创意的某些组件,例如为下水道提供一些 LED 或木工结构。 + +**费用:**不等 + +### 启发式游戏篮 + +![Heuristic play kit][9] + +**年龄:** 8 个月至 5 岁 + +**这是什么:**启发式游戏篮充满了由天然、无毒材料制成的有趣物品,可供婴幼儿使用其五种感官进行探索。这是一种开放式、自娱自乐的游戏。其想法是,成年人将监督(但不指导)儿童使用篮子及其物品半小时,然后将篮子拿走,等下一次再玩。 + +创建带有常见家用物品的可爱游戏篮很容易。尝试包括质地、声音、气味、形状和重量各不相同的物品。这里有一些想法可以帮助您入门。 + +* 漏勺或脊状柳条篮可容纳所有物品 +* 木勺子 +* 金属打蛋器和汤匙 +* 板刷 +* 海绵 +* 小型鸡蛋纸箱 +* 纸板管 +* 小擀面杖 +* 带纹理的毛巾 +* 岩石 +* 手铃 +* 钩针桌巾 +* 带盖的小铁罐 +   +游戏篮中不应包括任何容易破碎的东西或足够小到可以装入纸巾卷的东西,因为它们有窒息危险,应将所有物品彻底清洁后再交给孩子。 + +**我为什么喜欢它:**游戏篮非常适合感官发育,并可以帮助幼儿提出问题和探索周围的世界。这是培养创客思维方式的重要组成部分! + +很容易获得适合这个游戏篮的物品。你可能已经在家中或附近的二手商店里找到了很多有趣的物品。幼儿使用游戏篮的方式与婴儿不同。随着孩子们开始模仿成人生活并通过他们的游戏讲故事,这些物品将随孩子一起成长。 + +**费用:**不等 + +### 《Hello Ruby》 + +![Hello Ruby book cover][10] + +**年龄**:5-8 岁 + +**这是什么:** 《[Hello Ruby][11]:编码历险记》是 Linda Liukas 的插图书,通过有趣的故事讲述了一个遇到各种问题和朋友(每个都用一个码代表)的女孩,向孩子们介绍了编程概念。Liukas 还有其他副标题为《互联网探险》和《计算机内的旅程》的《Hello Ruby》系列书籍,而《编码历险记》已以 20 多种语言出版。 + +**为什么我喜欢它:**作者在书中附带了许多免费、有趣和无障碍的活动,可以从 Hello Ruby 网站下载和打印这些活动。这些活动教授编码概念、还涉及艺术表达、沟通、甚至时间安排。 + +**费用:**精装书的标价为 17.99 美元,但你可以通过本地或在线书店以较低的价格买到这本书。 + +### 《编程少女:学会编程和改变世界》 + +![Girls Who Code book cover][12] + +**年龄**:10 岁 - 成人 + +**内容是什么:**由《编程少女》的创始人 Reshma Saujani 撰写,《[编程少女:学会编程和改变世界][13]》为年轻女孩(以及男孩)提供了科技领域的实用信息。它涵盖了广泛的主题,包括编程语言、用例、术语和词汇、职业选择以及技术行业人士的个人简介和访谈。 + +**为什么我喜欢它:**本书以讲述了大多数面向成年人的网站都没有的技术故事。这些技术涉及许多学科,对于年轻人来说,重要的是要了解他们可以使用它来解决现实世界中的问题并有所作为。 + +**成本:**精装书的标价为 17.99 美元,平装书的标价为 10.99 美元,但你可以通过本地或在线书店以更低的价格找到。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/maker-gifts-kids + +作者:[Jess Weichler][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cyanide-cupcake +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://opensource.com/sites/default/files/uploads/hummingbird.png (Hummingbird Robotics Kit) +[3]: https://www.birdbraintechnologies.com/hummingbirdbit/ +[4]: https://opensource.com/sites/default/files/uploads/makeymakey2.jpg (Makey Makey Classic) +[5]: https://makeymakey.com/ +[6]: https://opensource.com/sites/default/files/uploads/arduinouno.jpg (Arduino Uno) +[7]: https://www.arduino.cc/ +[8]: https://opensource.com/sites/default/files/makerbox-makerkit.jpg (A maker kit assembled in a quick trip to the hardware store) +[9]: https://opensource.com/sites/default/files/makerbox-sensorykit.jpg (Heuristic play kit) +[10]: https://opensource.com/sites/default/files/uploads/helloruby2.jpg (Hello Ruby book cover) +[11]: https://www.helloruby.com/ +[12]: https://opensource.com/sites/default/files/uploads/girlswhocodebook.jpg (Girls Who Code book cover) +[13]: https://girlswhocode.com/book/girls-code-learn-code-change-world/ diff --git a/published/202001/20191205 Add jumping to your Python platformer game.md b/published/202001/20191205 Add jumping to your Python platformer game.md new file mode 100644 index 0000000000..d7195a008a --- /dev/null +++ b/published/202001/20191205 Add jumping to your Python platformer game.md @@ -0,0 +1,504 @@ +[#]: collector: (lujun9972) +[#]: translator: (cycoe) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11790-1.html) +[#]: subject: (Add jumping to your Python platformer game) +[#]: via: (https://opensource.com/article/19/12/jumping-python-platformer-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +为你的 Python 平台类游戏添加跳跃功能 +====== + +> 在本期使用 Python Pygame 模块编写视频游戏中,学会如何使用跳跃来对抗重力。 + +![](https://img.linux.net.cn/data/attachment/album/202001/16/214917c8mxn82fot82fx88.jpg) + +在本系列的 [前一篇文章][2] 中,你已经模拟了重力。但现在,你需要赋予你的角色跳跃的能力来对抗重力。 + +跳跃是对重力作用的暂时延缓。在这一小段时间里,你是向*上*跳,而不是被重力拉着向下落。但你一旦到达了跳跃的最高点,重力就会重新发挥作用,将你拉回地面。 + +在代码中,这种变化被表示为变量。首先,你需要为玩家精灵建立一个变量,使得 Python 能够跟踪该精灵是否正在跳跃中。一旦玩家精灵开始跳跃,他就会再次受到重力的作用,并被拉回最近的物体。 + +### 设置跳跃状态变量 + +你需要为你的 `Player` 类添加两个新变量: + + * 一个是为了跟踪你的角色是否正在跳跃中,可通过你的玩家精灵是否站在坚实的地面来确定 + * 一个是为了将玩家带回地面 + +将如下两个变量添加到你的 `Player` 类中。在下方的代码中,注释前的部分用于提示上下文,因此只需要添加最后两行: + +``` +                self.movex = 0 +                self.movey = 0 +                self.frame = 0 +                self.health = 10 +                # 此处是重力相关变量 +                self.collide_delta = 0 +                self.jump_delta = 6 +``` + +第一个变量 `collide_delta` 被设为 0 是因为在正常状态下,玩家精灵没有处在跳跃中的状态。另一个变量 `jump_delta` 被设为 6,是为了防止精灵在第一次进入游戏世界时就发生反弹(实际上就是跳跃)。当你完成了本篇文章的示例,尝试把该变量设为 0 看看会发生什么。 + +### 跳跃中的碰撞 + +如果你是跳到一个蹦床上,那你的跳跃一定非常优美。但是如果你是跳向一面墙会发生什么呢?(千万不要去尝试!)不管你的起跳多么令人印象深刻,当你撞到比你更大更硬的物体时,你都会立马停下。(LCTT 译注:原理参考动量守恒定律) + +为了在你的视频游戏中模拟这一点,你需要在你的玩家精灵与地面等东西发生碰撞时,将 `self.collide_delta` 变量设为 0。如果你的 `self.collide_delta` 不是 0 而是其它的什么值,那么你的玩家就会发生跳跃,并且当你的玩家与墙或者地面发生碰撞时无法跳跃。 + +在你的 `Player` 类的 `update` 方法中,将地面碰撞相关代码块修改为如下所示: + +``` +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +            self.collide_delta = 0 # 停止跳跃 + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) +``` + +这段代码块检查了地面精灵和玩家精灵之间发生的碰撞。当发生碰撞时,它会将玩家 Y 方向的坐标值设置为游戏窗口的高度减去一个瓷砖的高度再减去另一个瓷砖的高度。以此保证了玩家精灵是站在地面*上*,而不是嵌在地面里。同时它也将 `self.collide_delta` 设为 0,使得程序能够知道玩家未处在跳跃中。除此之外,它将 `self.movey` 设为 0,使得程序能够知道玩家当前未受到重力的牵引作用(这是游戏物理引擎的奇怪之处,一旦玩家落地,也就没有必要继续将玩家拉向地面)。 + +此处 `if` 语句用来检测玩家是否已经落到地面之*下*,如果是,那就扣除一点生命值作为惩罚。此处假定了你希望当你的玩家落到地图之外时失去生命值。这个设定不是必需的,它只是平台类游戏的一种惯例。更有可能的是,你希望这个事件能够触发另一些事件,或者说是一种能够让你的现实世界玩家沉迷于让精灵掉到屏幕之外的东西。一种简单的恢复方式是在玩家精灵掉落到地图之外时,将 `self.rect.y` 重新设置为 0,这样它就会在地图上方重新生成,并落到坚实的地面上。 + +### 撞向地面 + +模拟的重力使你玩家的 Y 坐标不断增大(LCTT 译注:此处原文中为 0,但在 Pygame 中越靠下方 Y 坐标应越大)。要实现跳跃,完成如下代码使你的玩家精灵离开地面,飞向空中。 + +在你的 `Player` 类的 `update` 方法中,添加如下代码来暂时延缓重力的作用: + +``` +        if self.collide_delta < 6 and self.jump_delta < 6: +            self.jump_delta = 6*2 +            self.movey -= 33  # 跳跃的高度 +            self.collide_delta += 6 +            self.jump_delta    += 6 +``` + +根据此代码所示,跳跃使玩家精灵向空中移动了 33 个像素。此处是*负* 33 是因为在 Pygame 中,越小的数代表距离屏幕顶端越近。 + +不过此事件视条件而定,只有当 `self.collide_delta` 小于 6(缺省值定义在你 `Player` 类的 `init` 方法中)并且 `self.jump_delta` 也于 6 的时候才会发生。此条件能够保证直到玩家碰到一个平台,才能触发另一次跳跃。换言之,它能够阻止空中二段跳。 + +在某些特殊条件下,你可能不想阻止空中二段跳,或者说你允许玩家进行空中二段跳。举个栗子,如果玩家获得了某个战利品,那么在他被敌人攻击到之前,都能够拥有空中二段跳的能力。 + +当你完成本篇文章中的示例,尝试将 `self.collide_delta` 和 `self.jump_delta` 设置为 0,从而获得百分之百的几率触发空中二段跳。 + +### 在平台上着陆 + +目前你已经定义了在玩家精灵摔落地面时的抵抗重力条件,但此时你的游戏代码仍保持平台与地面置于不同的列表中(就像本文中做的很多其他选择一样,这个设定并不是必需的,你可以尝试将地面作为另一种平台)。为了允许玩家精灵站在平台之上,你必须像检测地面碰撞一样,检测玩家精灵与平台精灵之间的碰撞。将如下代码放于你的 `update` 方法中: + +``` +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.collide_delta = 0 # 跳跃结束 +            self.movey = 0 +``` + +但此处还有一点需要考虑:平台悬在空中,也就意味着玩家可以通过从上面或者从下面接触平台来与之互动。 + +确定平台如何与玩家互动取决于你,阻止玩家从下方到达平台也并不稀奇。将如下代码加到上方的代码块中,使得平台表现得像天花板或者说是藤架。只有在玩家精灵跳得比平台上沿更高时才能跳到平台上,但会阻止玩家从平台下方跳上来: + +``` +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty +``` + +此处 `if` 语句代码块的第一个子句阻止玩家精灵从平台正下方跳到平台上。如果它检测到玩家精灵的坐标比平台更大(在 Pygame 中,坐标更大意味着在屏幕的更下方),那么将玩家精灵新的 Y 坐标设置为当前平台的 Y 坐标加上一个瓷砖的高度。实际效果就是保证玩家精灵距离平台一个瓷砖的高度,防止其从下方穿过平台。 + +`else` 子句做了相反的事情。当程序运行到此处时,如果玩家精灵的 Y 坐标*不*比平台的更大,意味着玩家精灵是从空中落下(不论是由于玩家刚刚从此处生成,或者是玩家执行了跳跃)。在这种情况下,玩家精灵的 Y 坐标被设为平台的 Y 坐标减去一个瓷砖的高度(切记,在 Pygame 中更小的 Y 坐标代表在屏幕上的更高处)。这样就能保证玩家在平台*上*,除非他从平台上跳下来或者走下来。 + +你也可以尝试其他的方式来处理玩家与平台之间的互动。举个栗子,也许玩家精灵被设定为处在平台的“前面”,他能够无障碍地跳跃穿过平台并站在上面。或者你可以设计一种平台会减缓而又不完全阻止玩家的跳跃过程。甚至你可以通过将不同平台分到不同列表中来混合搭配使用。 + +### 触发一次跳跃 + +目前为此,你的代码已经模拟了所有必需的跳跃条件,但仍缺少一个跳跃触发器。你的玩家精灵的 `self.jump_delta` 初始值被设置为 6,只有当它比 6 小的时候才会触发更新跳跃的代码。 + +为跳跃变量设置一个新的设置方法,在你的 `Player` 类中创建一个 `jump` 方法,并将 `self.jump_delta` 设为小于 6 的值。通过使玩家精灵向空中移动 33 个像素,来暂时减缓重力的作用。 + + +``` +    def jump(self,platform_list): +        self.jump_delta = 0 +``` + +不管你相信与否,这就是 `jump` 方法的全部。剩余的部分在 `update` 方法中,你已经在前面实现了相关代码。 + +要使你游戏中的跳跃功能生效,还有最后一件事情要做。如果你想不起来是什么,运行游戏并观察跳跃是如何生效的。 + +问题就在于你的主循环中没有调用 `jump` 方法。先前你已经为该方法创建了一个按键占位符,现在,跳跃键所做的就是将 `jump` 打印到终端。 + +### 调用 jump 方法 + +在你的主循环中,将*上*方向键的效果从打印一条调试语句,改为调用 `jump` 方法。 + +注意此处,与 `update` 方法类似,`jump` 方法也需要检测碰撞,因此你需要告诉它使用哪个 `plat_list`。 + +``` +            if event.key == pygame.K_UP or event.key == ord('w'): +                player.jump(plat_list) +``` + +如果你倾向于使用空格键作为跳跃键,使用 `pygame.K_SPACE` 替代 `pygame.K_UP` 作为按键。另一种选择,你可以同时使用两种方式(使用单独的 `if` 语句),给玩家多一种选择。 + +现在来尝试你的游戏吧!在下一篇文章中,你将让你的游戏卷动起来。 + +![Pygame 平台类游戏][3] + +以下是目前为止的所有代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved.  This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x 坐标,y 坐标,图像宽度,图像高度,图像文件 +    def __init__(self,xloc,yloc,imgw,imgh,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)).convert() +        self.image.convert_alpha() +        self.rect = self.image.get_rect() +        self.rect.y = yloc +        self.rect.x = xloc + +class Player(pygame.sprite.Sprite): +    ''' +    生成一个玩家 +    ''' +    def __init__(self): +        pygame.sprite.Sprite.__init__(self) +        self.movex = 0 +        self.movey = 0 +        self.frame = 0 +        self.health = 10 +        self.collide_delta = 0 +        self.jump_delta = 6 +        self.score = 1 +        self.images = [] +        for i in range(1,9): +            img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() +            img.convert_alpha() +            img.set_colorkey(ALPHA) +            self.images.append(img) +            self.image = self.images[0] +            self.rect  = self.image.get_rect() + +    def jump(self,platform_list): +        self.jump_delta = 0 + +    def gravity(self): +        self.movey += 3.2 # how fast player falls +        +        if self.rect.y > worldy and self.movey >= 0: +            self.movey = 0 +            self.rect.y = worldy-ty +        +    def control(self,x,y): +        ''' +        控制玩家移动 +        ''' +        self.movex += x +        self.movey += y +        +    def update(self): +        ''' +        更新精灵位置 +        ''' +        +        self.rect.x = self.rect.x + self.movex +        self.rect.y = self.rect.y + self.movey + +        # 向左移动 +        if self.movex < 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[self.frame//ani] + +        # 向右移动 +        if self.movex > 0: +            self.frame += 1 +            if self.frame > ani*3: +                self.frame = 0 +            self.image = self.images[(self.frame//ani)+4] + +        # 碰撞 +        enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) +        for enemy in enemy_hit_list: +            self.health -= 1 +            #print(self.health) + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.collide_delta = 0 # stop jumping +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty +            +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.movey = 0 +            self.rect.y = worldy-ty-ty +            self.collide_delta = 0 # stop jumping +            if self.rect.y > g.rect.y: +                self.health -=1 +                print(self.health) +                +        if self.collide_delta < 6 and self.jump_delta < 6: +            self.jump_delta = 6*2 +            self.movey -= 33  # how high to jump +            self.collide_delta += 6 +            self.jump_delta    += 6 +            +class Enemy(pygame.sprite.Sprite): +    ''' +    生成一个敌人 +    ''' +    def __init__(self,x,y,img): +        pygame.sprite.Sprite.__init__(self) +        self.image = pygame.image.load(os.path.join('images',img)) +        self.movey = 0 +        #self.image.convert_alpha() +        #self.image.set_colorkey(ALPHA) +        self.rect = self.image.get_rect() +        self.rect.x = x +        self.rect.y = y +        self.counter = 0 + +                +    def move(self): +        ''' +        敌人移动 +        ''' +        distance = 80 +        speed = 8 + +        self.movey += 3.2 +        +        if self.counter >= 0 and self.counter <= distance: +            self.rect.x += speed +        elif self.counter >= distance and self.counter <= distance*2: +            self.rect.x -= speed +        else: +            self.counter = 0 +        +        self.counter += 1 + +        if not self.rect.y >= worldy-ty-ty: +            self.rect.y += self.movey + +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +        for p in plat_hit_list: +            self.movey = 0 +            if self.rect.y > p.rect.y: +                self.rect.y = p.rect.y+ty +            else: +                self.rect.y = p.rect.y-ty + +        ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) +        for g in ground_hit_list: +            self.rect.y = worldy-ty-ty + +        +class Level(): +    def bad(lvl,eloc): +        if lvl == 1: +            enemy = Enemy(eloc[0],eloc[1],'yeti.png') # 生成敌人 +            enemy_list = pygame.sprite.Group() # 创建敌人组 +            enemy_list.add(enemy)              # 将敌人添加到敌人组 +            +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return enemy_list + +    def loot(lvl,lloc): +        print(lvl) + +    def ground(lvl,gloc,tx,ty): +        ground_list = pygame.sprite.Group() +        i=0 +        if lvl == 1: +            while i < len(gloc): +                ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') +                ground_list.add(ground) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return ground_list + +    def platform(lvl,tx,ty): +        plat_list = pygame.sprite.Group() +        ploc = [] +        i=0 +        if lvl == 1: +            ploc.append((0,worldy-ty-128,3)) +            ploc.append((300,worldy-ty-256,3)) +            ploc.append((500,worldy-ty-128,4)) + +            while i < len(ploc): +                j=0 +                while j <= ploc[i][2]: +                    plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') +                    plat_list.add(plat) +                    j=j+1 +                print('run' + str(i) + str(ploc[i])) +                i=i+1 + +        if lvl == 2: +            print("Level " + str(lvl) ) + +        return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # 帧率 +ani = 4  # 动画循环 +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE  = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # 生成玩家 +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 # how fast to move +jump = -24 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 # 瓷砖尺寸 +ty = 64 # 瓷砖尺寸 + +i=0 +while i <= (worldx/tx)+tx: +    gloc.append(i*tx) +    i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +主循环 +''' +while main == True: +    for event in pygame.event.get(): +        if event.type == pygame.QUIT: +            pygame.quit(); sys.exit() +            main = False + +        if event.type == pygame.KEYDOWN: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                print("LEFT") +                player.control(-steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                print("RIGHT") +                player.control(steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                print('jump') + +        if event.type == pygame.KEYUP: +            if event.key == pygame.K_LEFT or event.key == ord('a'): +                player.control(steps,0) +            if event.key == pygame.K_RIGHT or event.key == ord('d'): +                player.control(-steps,0) +            if event.key == pygame.K_UP or event.key == ord('w'): +                player.jump(plat_list) + +            if event.key == ord('q'): +                pygame.quit() +                sys.exit() +                main = False + +#    world.fill(BLACK) +    world.blit(backdrop, backdropbox) +    player.gravity() # 检查重力 +    player.update() +    player_list.draw(world) # 刷新玩家位置 +    enemy_list.draw(world)  # 刷新敌人 +    ground_list.draw(world)  # 刷新地面 +    plat_list.draw(world)   # 刷新平台 +    for e in enemy_list: +        e.move() +    pygame.display.flip() +    clock.tick(fps) +``` + +本期是使用 [Pygame][5] 模块在 [Python 3][4] 中创建视频游戏连载系列的第 7 期。往期文章为: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][6] + * [使用 Python 和 Pygame 模块构建一个游戏框架][7] + * [如何在你的 Python 游戏中添加一个玩家][8] + * [用 Pygame 使你的游戏角色移动起来][9] + * [如何向你的 Python 游戏中添加一个敌人][10] + * [在 Pygame 游戏中放置平台][11] + * [在你的 Python 游戏中模拟引力][2] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/jumping-python-platformer-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[cycoe](https://github.com/cycoe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/arcade_game_gaming.jpg?itok=84Rjk_32 (Arcade games) +[2]: https://linux.cn/article-11780-1.html +[3]: https://opensource.com/sites/default/files/uploads/pygame-jump.jpg (Pygame platformer) +[4]: https://www.python.org/ +[5]: https://www.pygame.org/ +[6]: https://linux.cn/article-9071-1.html +[7]: https://linux.cn/article-10850-1.html +[8]: https://linux.cn/article-10858-1.html +[9]: https://linux.cn/article-10874-1.html +[10]: https://linux.cn/article-10883-1.html +[11]: https://linux.cn/article-10902-1.html diff --git a/published/202001/20191208 What-s your favorite terminal emulator.md b/published/202001/20191208 What-s your favorite terminal emulator.md new file mode 100644 index 0000000000..3979bb4a53 --- /dev/null +++ b/published/202001/20191208 What-s your favorite terminal emulator.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11814-1.html) +[#]: subject: (What's your favorite terminal emulator?) +[#]: via: (https://opensource.com/article/19/12/favorite-terminal-emulator) +[#]: author: (Opensource.com https://opensource.com/users/admin) + +你最喜欢的终端模拟器是什么? +====== + +> 我们让社区讲述他们在终端仿真器方面的经验。以下是我们收到的一些回复。 + +![](https://img.linux.net.cn/data/attachment/album/202001/24/000846qsmpz7s7spig77qg.jpg) + +终端仿真器的偏好可以说明一个人的工作流程。无鼠标操作能力是否必须具备?你想要标签页还是窗口?对于终端仿真器你还有什么选择的原因?是否有酷的因素?欢迎参加调查或给我们留下评论,告诉我们你最喜欢的终端模拟器。你尝试过多少种终端仿真器呢? + +我们让社区讲述他们在终端仿真器方面的经验。以下是我们收到的一些回复。 + +“我最喜欢的终端仿真器是用 Powerline 定制的 Tilix。我喜欢它支持在一个窗口中打开多个终端。” —Dan Arel + +“[urxvt][2]。它可以通过文件简单配置,轻巧,并且在大多数程序包管理器存储库中都很容易找到。” —Brian Tomlinson + +“即使我不再使用 GNOME,gnome-terminal 仍然是我的首选。:)” —Justin W. Flory + +“现在 FC31 上的 Terminator。我刚刚开始使用它,我喜欢它的分屏功能,对我来说感觉很轻巧。我正在研究它的插件。” —Marc Maxwell + +“不久前,我切换到了 Tilix,它完成了我需要终端执行的所有工作。:) 多个窗格、通知,很精简,用来运行我的 tmux 会话很棒。” —Kevin Fenzi + +“alacritty。它针对速度进行了优化,是用 Rust 实现的,并且具有很多常规功能,但是老实说,我只关心一个功能:可配置的字形间距,使我可以进一步压缩字体。” —Alexander Sosedkin +  +“我是个老古板:KDE Konsole。如果是远程会话,请使用 tmux。” —Marcin Juszkiewicz + +“在 macOS 上用 iTerm2。是的,它是开源的。:-) 在 Linux 上是 Terminator。” —Patrick Mullins + +“我现在已经使用 alacritty 一两年了,但是最近我在全屏模式下使用 cool-retro-term,因为我必须运行一个输出内容有很多的脚本,而它看起来很酷,让我感觉很酷。这对我很重要。” —Nick Childers + +“我喜欢 Tilix,部分是因为它擅长免打扰(我通常全屏运行它,里面是 tmux),而且还提供自定义热链接支持:在我的终端中,像 ‘rhbz#1234’ 之类的文本是将我带到 Bugzilla 的热链接。类似的还有 LaunchPad 提案,OpenStack 的 Gerrit 更改 ID 等。” —Lars Kellogg-Stedman + +“Eterm,在使用 Vintage 配置文件的 cool-retro-term 中,演示效果也最好。” —Ivan Horvath + +“Tilix +1。这是 GNOME 用户最好的选择,我是这么觉得的!” —Eric Rich + +“urxvt。快速、小型、可配置、可通过 Perl 插件扩展,这使其可以无鼠标操作。” —Roman Dobosz  + +“Konsole 是最好的,也是 KDE 项目中我唯一使用的应用程序。所有搜索结果都高亮显示是一个杀手级功能,据我所知没有任何其它 Linux 终端有这个功能(如果能证明我错了,那我也很高兴)。最适合搜索编译错误和输出日志。” —Jan Horak + +“我过去经常使用 Terminator。现在我在 Tilix 中克隆了它的主题(深色主题),而感受一样好。它可以在选项卡之间轻松移动。就是这样。” —Alberto Fanjul Alonso + +“我开始使用的是 Terminator,自从差不多过去这三年,我已经完全切换到 Tilix。” —Mike Harris + +“我使用下拉式终端 X。这是 GNOME 3 的一个非常简单的扩展,使我始终可以通过一个按键(对于我来说是`F12`)拉出一个终端。它还支持制表符,这正是我所需要的。 ” —Germán Pulido + +“xfce4-terminal:支持 Wayland、缩放、无边框、无标题栏、无滚动条 —— 这就是我在 tmux 之外全部想要的终端仿真器的功能。我希望我的终端仿真器可以尽可能多地使用屏幕空间,我通常在 tmux 窗格中并排放着编辑器(Vim)和 repl。” —Martin Kourim + +“别问,问就是 Fish ! ;-)” —Eric Schabell + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/favorite-terminal-emulator + +作者:[Opensource.com][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/admin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_terminals_0.png?itok=XwIRERsn (Terminal window with green text) +[2]: https://opensource.com/article/19/10/why-use-rxvt-terminal diff --git a/published/202001/20191210 Lessons learned from programming in Go.md b/published/202001/20191210 Lessons learned from programming in Go.md new file mode 100644 index 0000000000..3c5e495b89 --- /dev/null +++ b/published/202001/20191210 Lessons learned from programming in Go.md @@ -0,0 +1,320 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11778-1.html) +[#]: subject: (Lessons learned from programming in Go) +[#]: via: (https://opensource.com/article/19/12/go-common-pitfalls) +[#]: author: (Eduardo Ferreira https://opensource.com/users/edufgf) + +Go 并发编程中的经验教训 +====== + +> 通过学习如何定位并发处理的陷阱来避免未来处理这些问题时的困境。 + +![](https://img.linux.net.cn/data/attachment/album/202001/13/150539n217ak1vcf717uzx.jpg) + +在复杂的分布式系统进行任务处理时,你通常会需要进行并发的操作。在 [Mode.net][2] 公司,我们每天都要和实时、快速和灵活的软件打交道。而没有一个高度并发的系统,就不可能构建一个毫秒级的动态地路由数据包的全球专用网络。这个动态路由是基于网络状态的,尽管这个过程需要考虑众多因素,但我们的重点是链路指标。在我们的环境中,链路指标可以是任何跟网络链接的状态和当前属性(如链接延迟)有关的任何内容。 + +### 并发探测链接监控 + +我们的动态路由算法 [H.A.L.O.][4](逐跳自适应链路状态最佳路由Hop-by-Hop Adaptive Link-State Optimal Routing)部分依赖于链路指标来计算路由表。这些指标由位于每个 PoP(存活节点Point of Presence)上的独立组件收集。PoP 是表示我们的网络中单个路由实体的机器,通过链路连接并分布在我们的网络拓扑中的各个位置。某个组件使用网络数据包探测周围的机器,周围的机器回复数据包给前者。从接收到的探测包中可以获得链路延迟。由于每个 PoP 都有不止一个临近节点,所以这种探测任务实质上是并发的:我们需要实时测量每个临近连接点的延迟。我们不能串行地处理;为了计算这个指标,必须尽快处理每个探测。 + +![latency computation graph][6] + +### 序列号和重置:一个重新排列场景 + +我们的探测组件互相发送和接收数据包,并依靠序列号进行数据包处理。这旨在避免处理重复的包或顺序被打乱的包。我们的第一个实现依靠特殊的序列号 0 来重置序列号。这个数字仅在组件初始化时使用。主要的问题是我们考虑了递增的序列号总是从 0 开始。在该组件重启后,包的顺序可能会重新排列,某个包的序列号可能会轻易地被替换成重置之前使用过的值。这意味着,后继的包都会被忽略掉,直到排到重置之前用到的序列值。 + +### UDP 握手和有限状态机 + +这里的问题是该组件重启前后的序列号是否一致。有几种方法可以解决这个问题,经过讨论,我们选择了实现一个带有清晰状态定义的三步握手协议。这个握手过程在初始化时通过链接建立会话。这样可以确保节点通过同一个会话进行通信且使用了适当的序列号。 + +为了正确实现这个过程,我们必须定义一个有清晰状态和过渡的有限状态机。这样我们就可以正确管理握手过程中的所有极端情况。 + +![finite state machine diagram][7] + +会话 ID 由握手的初始化程序生成。一个完整的交换顺序如下: + +1. 发送者发送一个 `SYN(ID)` 数据包。 +2. 接收者存储接收到的 `ID` 并发送一个 `SYN-ACK(ID)`。 +3. 发送者接收到 `SYN-ACK(ID)` 并发送一个 `ACK(ID)`。它还发送一个从序列号 0 开始的数据包。 +4. 接收者检查最后接收到的 `ID`,如果 ID 匹配,则接受 `ACK(ID)`。它还开始接受序列号为 0 的数据包。 + +### 处理状态超时 + +基本上,每种状态下你都需要处理最多三种类型的事件:链接事件、数据包事件和超时事件。这些事件会并发地出现,因此你必须正确处理并发。 + +* 链接事件包括网络连接或网络断开的变化,相应的初始化一个链接会话或断开一个已建立的会话。 +* 数据包事件是控制数据包(`SYN`/`SYN-ACK`/`ACK`)或只是探测响应。 +* 超时事件在当前会话状态的预定超时时间到期后触发。 + +这里面临的最主要的问题是如何处理并发的超时到期和其他事件。这里很容易陷入死锁和资源竞争的陷阱。 + +### 第一种方法 + +本项目使用的语言是 [Golang][8]。它确实提供了原生的同步机制,如自带的通道和锁,并且能够使用轻量级线程来进行并发处理。 + +![gophers hacking together][9] + +*gopher 们聚众狂欢* + +首先,你可以设计两个分别表示我们的会话和超时处理程序的结构体。 + +```go +type Session struct {   +  State SessionState   +  Id SessionId   +  RemoteIp string   +} + +type TimeoutHandler struct {   +  callback func(Session)   +  session Session   +  duration int   +  timer *timer.Timer   +} +``` + +`Session` 标识连接会话,内有表示会话 ID、临近的连接点的 IP 和当前会话状态的字段。 + +`TimeoutHandler` 包含回调函数、对应的会话、持续时间和指向调度计时器的指针。 + +每一个临近连接点的会话都包含一个保存调度 `TimeoutHandler` 的全局映射。 + +``` +SessionTimeout map[Session]*TimeoutHandler +``` + +下面方法注册和取消超时: + +```go +// schedules the timeout callback function.   +func (timeout* TimeoutHandler) Register() {   +  timeout.timer = time.AfterFunc(time.Duration(timeout.duration) * time.Second, func() {   +    timeout.callback(timeout.session)   +  })   +} + +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.timer == nil {   +    return   +  }   +  timeout.timer.Stop()   +} +``` + +你可以使用类似下面的方法来创建和存储超时: + +```go +func CreateTimeoutHandler(callback func(Session), session Session, duration int) *TimeoutHandler {   +  if sessionTimeout[session] == nil {   +    sessionTimeout[session] := new(TimeoutHandler)   +  }   +    +  timeout = sessionTimeout[session]   +  timeout.session = session   +  timeout.callback = callback   +  timeout.duration = duration   +  return timeout   +} +``` + +超时处理程序创建后,会在经过了设置的 `duration` 时间(秒)后执行回调函数。然而,有些事件会使你重新调度一个超时处理程序(与 `SYN` 状态时的处理一样,每 3 秒一次)。 + +为此,你可以让回调函数重新调度一次超时: + +```go +func synCallback(session Session) {   +  sendSynPacket(session) + +  // reschedules the same callback.   +  newTimeout := NewTimeoutHandler(synCallback, session, SYN_TIMEOUT_DURATION)   +  newTimeout.Register() + +  sessionTimeout[state] = newTimeout   +} +``` + +这次回调在新的超时处理程序中重新调度自己,并更新全局映射 `sessionTimeout`。 + +### 数据竞争和引用 + +你的解决方案已经有了。可以通过检查计时器到期后超时回调是否执行来进行一个简单的测试。为此,注册一个超时,休眠 `duration` 秒,然后检查是否执行了回调的处理。执行这个测试后,最好取消预定的超时时间(因为它会重新调度),这样才不会在下次测试时产生副作用。 + +令人惊讶的是,这个简单的测试发现了这个解决方案中的一个问题。使用 `cancel` 方法来取消超时并没有正确处理。以下顺序的事件会导致数据资源竞争: + +1. 你有一个已调度的超时处理程序。 +2. 线程 1: + 1. 你接收到一个控制数据包,现在你要取消已注册的超时并切换到下一个会话状态(如发送 `SYN` 后接收到一个 `SYN-ACK`) + 2. 你调用了 `timeout.Cancel()`,这个函数调用了 `timer.Stop()`。(请注意,Golang 计时器的停止不会终止一个已过期的计时器。) +3. 线程 2: + 1. 在取消调用之前,计时器已过期,回调即将执行。 + 2. 执行回调,它调度一次新的超时并更新全局映射。 +4. 线程 1: + 1. 切换到新的会话状态并注册新的超时,更新全局映射。 + +两个线程并发地更新超时映射。最终结果是你无法取消注册的超时,然后你也会丢失对线程 2 重新调度的超时的引用。这导致处理程序在一段时间内持续执行和重新调度,出现非预期行为。 + +### 锁也解决不了问题 + +使用锁也不能完全解决问题。如果你在处理所有事件和执行回调之前加锁,它仍然不能阻止一个过期的回调运行: + +```go +func (timeout* TimeoutHandler) Register() {   +  timeout.timer = time.AfterFunc(time.Duration(timeout.duration) * time._Second_, func() {   +    stateLock.Lock()   +    defer stateLock.Unlock() + +    timeout.callback(timeout.session)   +  })   +} +``` + +现在的区别就是全局映射的更新是同步的,但是这还是不能阻止在你调用 `timeout.Cancel()` 后回调的执行 —— 这种情况出现在调度计时器过期了但是还没有拿到锁的时候。你还是会丢失一个已注册的超时的引用。 + +### 使用取消通道 + +你可以使用取消通道,而不必依赖不能阻止到期的计时器执行的 golang 函数 `timer.Stop()`。 + +这是一个略有不同的方法。现在你可以不用再通过回调进行递归地重新调度;而是注册一个死循环,这个循环接收到取消信号或超时事件时终止。 + +新的 `Register()` 产生一个新的 go 线程,这个线程在超时后执行你的回调,并在前一个超时执行后调度新的超时。返回给调用方一个取消通道,用来控制循环的终止。 + +```go +func (timeout *TimeoutHandler) Register() chan struct{} {   +  cancelChan := make(chan struct{})   +    +  go func () {   +    select {   +    case _ = <- cancelChan:   +      return   +    case _ = <- time.AfterFunc(time.Duration(timeout.duration) * time.Second):   +      func () {   +        stateLock.Lock()   +        defer stateLock.Unlock() + +        timeout.callback(timeout.session)   +      } ()   +    }   +  } () + +  return cancelChan   +} + +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.cancelChan == nil {   +    return   +  }   +  timeout.cancelChan <- struct{}{}   +} +``` + +这个方法给你注册的所有超时提供了取消通道。一个取消调用向通道发送一个空结构体并触发取消操作。然而,这并不能解决前面的问题;可能在你通过通道取消之前以及超时线程拿到锁之前,超时时间就已经到了。 + +这里的解决方案是,在拿到锁**之后**,检查一下超时范围内的取消通道。 + +```go +  case _ = <- time.AfterFunc(time.Duration(timeout.duration) * time.Second):   +    func () {   +      stateLock.Lock()   +      defer stateLock.Unlock()   +      +      select {   +      case _ = <- handler.cancelChan:   +        return   +      default:   +        timeout.callback(timeout.session)   +      }   +    } ()   +  } +``` + +最终,这可以确保在拿到锁之后执行回调,不会触发取消操作。 + +### 小心死锁 + +这个解决方案看起来有效;但是还是有个隐患:[死锁][10]。 + +请阅读上面的代码,试着自己找到它。考虑下描述的所有函数的并发调用。 + +这里的问题在取消通道本身。我们创建的是无缓冲通道,即发送的是阻塞调用。当你在一个超时处理程序中调用取消函数时,只有在该处理程序被取消后才能继续处理。问题出现在,当你有多个调用请求到同一个取消通道时,这时一个取消请求只被处理一次。当多个事件同时取消同一个超时处理程序时,如连接断开或控制包事件,很容易出现这种情况。这会导致死锁,可能会使应用程序停机。 + +![gophers on a wire, talking][11] + +*有人在听吗?* + +(已获得 Trevor Forrey 授权。) + +这里的解决方案是创建通道时指定缓存大小至少为 1,这样向通道发送数据就不会阻塞,也显式地使发送变成非阻塞的,避免了并发调用。这样可以确保取消操作只发送一次,并且不会阻塞后续的取消调用。 + +```go +func (timeout* TimeoutHandler) Cancel() {   +  if timeout.cancelChan == nil {   +    return   +  }   +    +  select {   +  case timeout.cancelChan <- struct{}{}:   +  default:   +    // can’t send on the channel, someone has already requested the cancellation.   +  }   +} +``` + +### 总结 + +在实践中你学到了并发操作时出现的常见错误。由于其不确定性,即使进行大量的测试,也不容易发现这些问题。下面是我们在最初的实现中遇到的三个主要问题: + +#### 在非同步的情况下更新共享数据 + +这似乎是个很明显的问题,但如果并发更新发生在不同的位置,就很难发现。结果就是数据竞争,由于一个更新会覆盖另一个,因此对同一数据的多次更新中会有某些更新丢失。在我们的案例中,我们是在同时更新同一个共享映射里的调度超时引用。(有趣的是,如果 Go 检测到在同一个映射对象上的并发读写,会抛出致命错误 — 你可以尝试下运行 Go 的[数据竞争检测器](https://golang.org/doc/articles/race_detector.html))。这最终会导致丢失超时引用,且无法取消给定的超时。当有必要时,永远不要忘记使用锁。 + +![gopher assembly line][13] + +*不要忘记同步 gopher 们的工作* + +#### 缺少条件检查 + +在不能仅依赖锁的独占性的情况下,就需要进行条件检查。我们遇到的场景稍微有点不一样,但是核心思想跟[条件变量][14]是一样的。假设有个一个生产者和多个消费者使用一个共享队列的经典场景,生产者可以将一个元素添加到队列并唤醒所有消费者。这个唤醒调用意味着队列中的数据是可访问的,并且由于队列是共享的,消费者必须通过锁来进行同步访问。每个消费者都可能拿到锁;然而,你仍然需要检查队列中是否有元素。因为在你拿到锁的瞬间并不知道队列的状态,所以还是需要进行条件检查。 + +在我们的例子中,超时处理程序收到了计时器到期时发出的“唤醒”调用,但是它仍需要检查是否已向其发送了取消信号,然后才能继续执行回调。 + +![gopher boot camp][15] + +*如果你要唤醒多个 gopher,可能就需要进行条件检查* + +#### 死锁 + +当一个线程被卡住,无限期地等待一个唤醒信号,但是这个信号永远不会到达时,就会发生这种情况。死锁可以通过让你的整个程序停机来彻底杀死你的应用。 + +在我们的案例中,这种情况的发生是由于多次发送请求到一个非缓冲且阻塞的通道。这意味着向通道发送数据只有在从这个通道接收完数据后才能返回。我们的超时线程循环迅速从取消通道接收信号;然而,在接收到第一个信号后,它将跳出循环,并且再也不会从这个通道读取数据。其他的调用会一直被卡住。为避免这种情况,你需要仔细检查代码,谨慎处理阻塞调用,并确保不会发生线程饥饿。我们例子中的解决方法是使取消调用成为非阻塞调用 — 我们不需要阻塞调用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/go-common-pitfalls + +作者:[Eduardo Ferreira][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/edufgf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/go-golang.png?itok=OAW9BXny (Goland gopher illustration) +[2]: http://mode.net +[3]: https://en.wikipedia.org/wiki/Metrics_%28networking%29 +[4]: https://people.ece.cornell.edu/atang/pub/15/HALO_ToN.pdf +[5]: https://en.wikipedia.org/wiki/Point_of_presence +[6]: https://opensource.com/sites/default/files/uploads/image2_0_3.png (latency computation graph) +[7]: https://opensource.com/sites/default/files/uploads/image3_0.png (finite state machine diagram) +[8]: https://golang.org/ +[9]: https://opensource.com/sites/default/files/uploads/image4.png (gophers hacking together) +[10]: https://en.wikipedia.org/wiki/Deadlock +[11]: https://opensource.com/sites/default/files/uploads/image5_0_0.jpg (gophers on a wire, talking) +[12]: https://golang.org/doc/articles/race_detector.html +[13]: https://opensource.com/sites/default/files/uploads/image6.jpeg (gopher assembly line) +[14]: https://en.wikipedia.org/wiki/Monitor_%28synchronization%29#Condition_variables +[15]: https://opensource.com/sites/default/files/uploads/image7.png (gopher boot camp) diff --git a/published/202001/20191211 Enable your Python game player to run forward and backward.md b/published/202001/20191211 Enable your Python game player to run forward and backward.md new file mode 100644 index 0000000000..38d25cc1ab --- /dev/null +++ b/published/202001/20191211 Enable your Python game player to run forward and backward.md @@ -0,0 +1,467 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11819-1.html) +[#]: subject: (Enable your Python game player to run forward and backward) +[#]: via: (https://opensource.com/article/19/12/python-platformer-game-run) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使你的 Python 游戏玩家能够向前和向后跑 +====== +> 使用 Pygame 模块来使你的 Python 平台开启侧滚效果,来让你的玩家自由奔跑。 + +![](https://img.linux.net.cn/data/attachment/album/202001/25/220636x5mabbl47xvtsk55.jpg) + +这是仍在进行中的关于使用 Pygame 模块来在 Python 3 中在创建电脑游戏的第九部分。先前的文章是: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][2] + * [使用 Python 和 Pygame 模块构建一个游戏框架][3] + * [如何在你的 Python 游戏中添加一个玩家][4] + * [用 Pygame 使你的游戏角色移动起来][5] + * [如何向你的 Python 游戏中添加一个敌人][6] + * [在 Pygame 游戏中放置平台][12] + * [在你的 Python 游戏中模拟引力][7] + * [为你的 Python 平台类游戏添加跳跃功能][8] + +在这一系列关于使用 [Pygame][10] 模块来在 [Python 3][9] 中创建电脑游戏的先前文章中,你已经设计了你的关卡设计布局,但是你的关卡的一些部分可能已近超出你的屏幕的可视区域。在平台类游戏中,这个问题的普遍解决方案是,像术语“侧滚side-scroller”表明的一样,滚动。 + +滚动的关键是当玩家精灵接近屏的幕边缘时,使在玩家精灵周围的平台移动。这样给予一种错觉,屏幕是一个在游戏世界中穿梭追拍的"摄像机"。 + +这个滚动技巧需要两个在屏幕边缘的绝对区域,在绝对区域内的点处,在世界滚动期间,你的化身静止不动。 + +### 在侧滚动条中放置卷轴 + +如果你希望你的玩家能够后退,你需要一个触发点来向前和向后。这两个点仅仅是两个变量。设置它们各个距各个屏幕边缘大约 100 或 200 像素。在你的设置部分中创建变量。在下面的代码中,前两行用于上下文说明,所以仅需要添加这行后的代码: + +``` +player_list.add(player) +steps = 10 +forwardX  = 600 +backwardX = 230 +``` + +在主循环中,查看你的玩家精灵是否在 `forwardx` 或 `backwardx` 滚动点处。如果是这样,向左或向右移动使用的平台,取决于世界是向前或向后移动。在下面的代码中,代码的最后三行仅供你参考: + +``` +        # scroll the world forward +        if player.rect.x >= forwardx: +                scroll = player.rect.x - forwardx +                player.rect.x = forwardx +                for p in plat_list: +                        p.rect.x -= scroll + +        # scroll the world backward +        if player.rect.x <= backwardx: +                scroll = backwardx - player.rect.x +                player.rect.x = backwardx +                for p in plat_list: +                        p.rect.x += scroll + +        ## scrolling code above +    world.blit(backdrop, backdropbox) +    player.gravity() # check gravity +    player.update() +``` + +启动你的游戏,并尝试它。 + +![Scrolling the world in Pygame][11] + +滚动像预期的一样工作,但是你可能注意到一个发生的小问题,当你滚动你的玩家和非玩家精灵周围的世界时:敌人精灵不随同世界滚动。除非你要你的敌人精灵要无休止地追逐你的玩家,你需要修改敌人代码,以便当你的玩家快速撤退时,敌人被留在后面。 + +### 敌人卷轴 + +在你的主循环中,你必须对卷轴平台为你的敌人的位置的应用相同的规则。因为你的游戏世界将(很可能)有不止一个敌人在其中,该规则应该被应用于你的敌人列表,而不是一个单独的敌人精灵。这是分组类似元素到列表中的优点之一。 + +前两行用于上下文注释,所以只需添加这两行后面的代码到你的主循环中: + +``` +    # scroll the world forward +    if player.rect.x >= forwardx: +        scroll = player.rect.x - forwardx +        player.rect.x = forwardx +        for p in plat_list: +            p.rect.x -= scroll +        for e in enemy_list: +            e.rect.x -= scroll +``` + +来滚向另一个方向: + +``` +    # scroll the world backward +    if player.rect.x <= backwardx: +        scroll = backwardx - player.rect.x +        player.rect.x = backwardx +        for p in plat_list: +            p.rect.x += scroll +        for e in enemy_list: +            e.rect.x += scroll +``` + +再次启动游戏,看看发生什么。 + +这里是到目前为止你已经为这个 Python 平台所写所有的代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping +# add scrolling + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.collide_delta = 0 + self.jump_delta = 6 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def jump(self,platform_list): + self.jump_delta = 0 + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + for enemy in enemy_hit_list: + self.health -= 1 + #print(self.health) + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.collide_delta = 0 # stop jumping + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.movey = 0 + self.rect.y = worldy-ty-ty + self.collide_delta = 0 # stop jumping + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) + + if self.collide_delta < 6 and self.jump_delta < 6: + self.jump_delta = 6*2 + self.movey -= 33 # how high to jump + self.collide_delta += 6 + self.jump_delta += 6 + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + self.movey = 0 + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + self.movey += 3.2 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + + if not self.rect.y >= worldy-ty-ty: + self.rect.y += self.movey + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.rect.y = worldy-ty-ty + + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,lloc): + print(lvl) + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((0,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 +forwardx = 600 +backwardx = 230 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + player.jump(plat_list) + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + # scroll the world forward + if player.rect.x >= forwardx: + scroll = player.rect.x - forwardx + player.rect.x = forwardx + for p in plat_list: + p.rect.x -= scroll + for e in enemy_list: + e.rect.x -= scroll + + # scroll the world backward + if player.rect.x <= backwardx: + scroll = backwardx - player.rect.x + player.rect.x = backwardx + for p in plat_list: + p.rect.x += scroll + for e in enemy_list: + e.rect.x += scroll + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) #refresh player position + enemy_list.draw(world) # refresh enemies + ground_list.draw(world) # refresh enemies + plat_list.draw(world) # refresh platforms + for e in enemy_list: + e.move() + pygame.display.flip() + clock.tick(fps) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/python-platformer-game-run + +作者:[Seth Kenlon][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://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_gaming_games_roundup_news.png?itok=KM0ViL0f (Gaming artifacts with joystick, GameBoy, paddle) +[2]: https://linux.cn/article-9071-1.html +[3]: https://linux.cn/article-10850-1.html +[4]: https://linux.cn/article-10858-1.html +[5]: https://linux.cn/article-10874-1.html +[6]: https://linux.cn/article-10883-1.html +[7]: https://linux.cn/article-11780-1.html +[8]: https://linux.cn/article-11790-1.html +[9]: https://www.python.org/ +[10]: https://www.pygame.org/news +[11]: https://opensource.com/sites/default/files/uploads/pygame-scroll.jpg (Scrolling the world in Pygame) +[12]:https://linux.cn/article-10902-1.html diff --git a/published/202001/20191214 Make VLC More Awesome With These Simple Tips.md b/published/202001/20191214 Make VLC More Awesome With These Simple Tips.md new file mode 100644 index 0000000000..3bb170df03 --- /dev/null +++ b/published/202001/20191214 Make VLC More Awesome With These Simple Tips.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11776-1.html) +[#]: subject: (Make VLC More Awesome With These Simple Tips) +[#]: via: (https://itsfoss.com/simple-vlc-tips/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +这些简单的技巧使 VLC 更加出色 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/13/090635eu9va9999rr4ue92.jpeg) + +如果 [VLC][1] 不是最好的播放器,那它也是[最好的开源视频播放器][2]之一。大多数人不知道的是,它不仅仅是视频播放器。 + +你可以进行许多复杂的任务,如直播视频、捕捉设备等。只需打开菜单,你就可以看到它有多少选项。 + +我们有一个详细的教程,讨论一些[专业的 VLC 技巧][3],但这些对于普通用户太复杂。 + +这就是为什么我要写另一篇文章的原因,来向你展示一些可以在 VLC 中使用的简单技巧。 + +### 使用这些简单技巧让 VLC 做更多事 + +让我们看看除了播放视频文件之外,你还可以使用 VLC 做什么。 + +#### 1、使用 VLC 观看 YouTube 视频 + +![][4] + +如果你不想在 [YouTube][5] 上观看令人讨厌的广告,或者只想体验没有打扰地观看 YouTube 视频,你可以使用 VLC。 + +是的,在 VLC 上流式传输 YouTube 视频是非常容易的。 + +只需启动 VLC 播放器,前往媒体设置,然后单击 ”Open Network Stream“ 或使用快捷方式 `CTRL + N`。 + +![][6] + +接下来,你只需要粘贴要观看的视频的 URL。有一些选项可以调整,但通常你无需担心这些。如果你好奇,你可以点击 ”Advanced options“ 来探索。 + +你还可以通过这种方式向 YouTube 视频添加字幕。然而,[一个更简单的带字幕观看 Youtube 视频的办法是使用 Penguin 字幕播放器][7]。 + +#### 2、将视频转换为不同格式 + +![][8] + +你可以[在 Linux 命令行使用 ffmpeg 转换视频][9]。你还可以使用图形工具,如 [HandBrake 转换视频格式][10]。 + +但是,如果你不想用一个单独的应用来转码视频,你可以使用 VLC 播放器来完成该工作。 + +为此,只需点击 VLC 上的媒体选项,然后单击 “Convert/Save”,或者在 VLC 播放器处于活动状态时按下快捷键 `CTRL + R`。接下来,你需要从计算机/硬盘或者 URL 导入你想保存/转换的的视频。 + +不管是什么来源,只需选择文件后点击 “Convert/Save” 按钮。你现在会看到另外一个窗口可以更改 “Profile” 设置。点击并选择你想转换的格式(并保存)。 + +你还可以在转换之前通过在屏幕底部设置目标文件夹来更改转换文件的存储路径。 + +#### 3、从源录制音频/视频 + +![Vlc Advanced Controls][11] + +你是否想在 VLC 播放器中录制正在播放的音频/视频? + +如果是的话,有一个简单的解决方案。只需通过 “View”,然后点击 “Advanced Controls”。 + +完成后,你会看到一个新按钮(包括 VLC 播放器中的红色录制按钮)。 + +#### 4、自动下载字幕 + +![][12] + +是的,你可以[使用 VLC 自动下载字幕][13]。你甚至不必在单独的网站上查找字幕。你只需点击 +“View”->“VLSub”。 + +默认情况下,它是禁用的,因此当你单击该选项时,它会被激活,并允许你搜索/下载想要的字幕。 + +[VLC 还能让你使用简单的键盘快捷键同步字幕][14] + +#### 5、截图 + +![][15] + +你可以在观看视频时使用 VLC 获取一些视频的截图/图像。你只需在视频播放/暂停时右击播放器,你会看到一组选项,点击 “Video”->“Take Snapshot”。 + +如果安装了旧版本,你可能在右键时看到截图选项。 + +#### 额外技巧:给视频添加音频/视频效果 + +在菜单中,进入 “Tools” 选项。单击 “Effects and Filters”,或者在 VLC 播放器窗口中按 `CTRL + E` 打开选项。 + +好了,你可以观察你给视频添加的音频和视频效果了。你也许无法实时看到效果,因此你需要调整并保存来看发生了什么。 + +![][16] + +我建议在修改视频之前保存一份原始视频备份。 + +#### 你最喜欢的 VLC 技巧是什么? + +我分享了一些我最喜欢的 VLC 技巧。你知道什么你经常使用的很酷的 VLC 技巧吗?为什么不和我们分享呢?我可以把它添加到列表中。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/simple-vlc-tips/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://www.videolan.org/ +[2]: https://itsfoss.com/video-players-linux/ +[3]: https://itsfoss.com/vlc-pro-tricks-linux/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/youtube-video-stream.jpg?ssl=1 +[5]: https://www.youtube.com/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/youtube-video-play.jpg?ssl=1 +[7]: https://itsfoss.com/penguin-subtitle-player/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-video-convert.jpg?ssl=1 +[9]: https://itsfoss.com/ffmpeg/ +[10]: https://itsfoss.com/handbrake/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-advanced-controls.png?ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-subtitles-automatic.png?ssl=1 +[13]: https://itsfoss.com/download-subtitles-automatically-vlc-media-player-ubuntu/ +[14]: https://itsfoss.com/how-to-synchronize-subtitles-with-movie-quick-tip/ +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-snapshot.png?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc-effects-screenshot.jpg?ssl=1 diff --git a/published/202001/20191215 How to Add Border Around Text in GIMP.md b/published/202001/20191215 How to Add Border Around Text in GIMP.md new file mode 100644 index 0000000000..6a59c6ac66 --- /dev/null +++ b/published/202001/20191215 How to Add Border Around Text in GIMP.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11799-1.html) +[#]: subject: (How to Add Border Around Text in GIMP) +[#]: via: (https://itsfoss.com/gimp-text-outline/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 GIMP 中如何在文本周围添加边框 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/19/230506fzkyktqglfcyzkuh.jpg) + +这个简单的教程介绍了在 [GIMP][1] 中显示文本的轮廓的步骤。文本轮廓可以帮助你在其它颜色下高亮显示该文本。 + +![Outlined Text created in GIMP][2] + +让我们看看如何在你的文本周围添加一个边框。 + +### 在 GIMP 中添加文本轮廓 + +整个过程可以用这些简单的步骤描述: + +* 创建文本,并复制它的轮廓路径 +* 添加一层新的透明层,并添加轮廓路径到透明层中 +* 更改轮廓的大小,给它添加一种不同的颜色 + +这就是全部的东西。不用担心,我将使用适当地截图详细的展示每个步骤。按照这个教程,你应该能够为文本添加轮廓,即使你在此之前从未使用过 GIMP 。 + +仅需要确保你已经 [在 Linux 上安装 GIMP][3],或者也可以使用的其它任何操作系统。 + +这篇教程在 GIMP 2.10 版本下演示。 + +#### 步骤 1: 创建你的主要文本,并复制它的轮廓 + +打开 GIMP ,并通过转到 “菜单 -> 文件 -> 新建” 来创建一个新的文件。你应该可以使用 `Ctrl+N` 键盘快捷键。 + +![Create New File][4] + +你可以在这里选择画布的大小。你也可以选择要白色背景或一种透明背景。它在 “高级选项 -> 颜色” 配置文件下。 + +我选择默认的白色背景。它在以后能够更改。 + +现在从左边栏的工具箱中选择文本工具。 + +![Adding text in GIMP][5] + +写你想要的文本。你可以根据你的选择以更改文本的字体、大小和对齐方式。我保持这篇文章的文本的默认左对齐。 + +我故意为文本选择一种浅色,以便难于阅读。在这篇教程中我将添加一个深色轮廓到这个浅色的文本。 + +![Text added in GIMP][6] + +当你写完文本后,右键文本框并选择 “文本的路径” 。 + +![Right click on the text box and select ‘Path from Text’][7] + +#### 步骤 2: 添加一个带有文本轮廓的透明层 + +现在,转到顶部菜单,转到“层”,并添加一个新层。 + +![Use Shift+Ctrl+N to add a new layer][8] + +确保添加新层为透明的。你可以给它一个合适的名称,像“文本大纲”。单击确定来添加这个透明层。 + +![Add a transparent layer][9] + +再次转到菜单,这次转到 “选择” ,并单击 “来自路径” 。你将看到你的文本应该被高亮显示。 + +![Go to Select and choose From Path][10] + +总的来说,你只创建了一个透明层,它有像你的原文一样相同的文本(但是透明)。现在你需要做的是在这个层上增加文本的大小。 + +#### 步骤 3: 通过增加它的大小和更改它的颜色来添加文本轮廓 + +为此,再次在菜单中转到 “选择” ,这次选择 “增加”。这将允许增大透明层上的文本的大小。 + +![Grow the selection on the additional layer][11] + +以 5 或 10 像素增加,或者你喜欢的任意像素。 + +![Grow it by 5 or 10 pixel][12] + +你选择需要做是使用一种你选择的颜色来填充这个扩大的选择区。因为我的原文是浅色,在这里我将为轮廓使用背景色。 + +如果尚未选择的话,先选择你的主图像层。这些层在右侧栏中可视。然后转到工具箱并选择油漆桶工具。为你的轮廓选择想要的颜色。 + +选择使用该工具来填充黑色到你的选择区。记住。你填充文本外部的轮廓,而不是文本本身。 + +![Fill the outline of the text with a different color][13] + +在这里你完成了很多。使用 `Ctrl+Shift+A` 来取消你当前的选择区。 + +![Outline added to the text][14] + +如此,你现在已经在 GIMP 中成功地添加轮廓到你的文本。它是在白色背景中,如果你想要一个透明背景,只需要在右侧栏的图层菜单中删除背景层。 + +![Remove the white background layer if you want a transparent background][15] + +如果你对结果感到满意,保存文件未 PNG 文件(来保留透明背景),或你喜欢的任何文件格式。 + +### 你使它工作了吗? + +就这样。这就是你在 GIMP 中为添加一个文本轮廓而需要做的全部工作。 + +我希望你发现这个 GIMP 教程有帮助。你可能想查看另一个 [关于在 GIMP 中添加一个水印的简单教程][16]。 + +如果你有问题或建议,请在下面自由留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gimp-text-outline/ + +作者:[Abhishek Prakash][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/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.gimp.org/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outlined_text_GIMP.png?ssl=1 +[3]: https://itsfoss.com/gimp-2-10-release/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/create_outline_text_gimp_1.jpeg?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_2.jpg?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp-3.jpg?ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_4.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_5.jpg?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_6.jpg?ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_7.jpg?ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_8.jpg?ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_9.jpg?ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_10.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_11.jpg?ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/outline_text_gimp_12.jpg?ssl=1 +[16]: https://itsfoss.com/add-watermark-gimp-linux/ diff --git a/published/202001/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md b/published/202001/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md new file mode 100644 index 0000000000..088b578c82 --- /dev/null +++ b/published/202001/20191217 App Highlight- Open Source Disk Partitioning Tool GParted.md @@ -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 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/10/220015lp58jjjt22xfppjj.jpg) + +> 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 diff --git a/translated/tech/20191219 Kubernetes namespaces for beginners.md b/published/202001/20191219 Kubernetes namespaces for beginners.md similarity index 62% rename from translated/tech/20191219 Kubernetes namespaces for beginners.md rename to published/202001/20191219 Kubernetes namespaces for beginners.md index 5c1f6267b0..c45aa74d42 100644 --- a/translated/tech/20191219 Kubernetes namespaces for beginners.md +++ b/published/202001/20191219 Kubernetes namespaces for beginners.md @@ -1,50 +1,52 @@ [#]: collector: (lujun9972) [#]: translator: (lxbwolf) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11749-1.html) [#]: subject: (Kubernetes namespaces for beginners) [#]: via: (https://opensource.com/article/19/12/kubernetes-namespaces) [#]: author: (Jessica Cherry https://opensource.com/users/jrepka) Kubernetes 命名空间入门 ====== -命名空间是什么?你为什么需要它? -![Ship captain sailing the Kubernetes seas][1] -kubernetes 命名空间是什么?Shakespeare 以前写过,我们声称的命名空间,或者任何其他名字,仍是一个虚拟集群。命名空间,意味着 kubernetes 可以在单个集群上提供多个 kubernetes 的集群,类似一个对其主机进行抽象的虚拟机。[kubernetes 文档][2] 中的解释: +> 命名空间是什么?你为什么需要它? + +![](https://img.linux.net.cn/data/attachment/album/202001/05/094542qnq3qc3nrkkrjanh.jpg) + +kubernetes 命名空间namespace是什么?正如 Shakespeare 以前写过的,我们所谓的命名空间,或者任何其他名字,就是虚拟集群。通过虚拟集群,意味着 kubernetes 可以在单个集群上提供多个 kubernetes 的集群,类似一个在其主机抽象出来的虚拟机。[kubernetes 文档][2] 中的解释: > kubernetes 在一个物理集群上提供了多个虚拟集群。这些虚拟集群被称为命名空间。 -你为什么需要命名空间?一句话概括:隔离。 +你为什么需要命名空间?一言以蔽之:隔离。 -隔离有很多优点,如它提供了安全和干净的环境。如果你是基础设施的所属者,并且为开发者提供环境,隔离就相当重要。你最不需要的就是,一个不熟悉你集群是如何搭建的人去修改系统配置 — 这可能导致所有人都无法登录。 +隔离有很多优点,如它提供了安全和干净的环境。如果你是基础设施的所属者,并且要为开发者提供环境,隔离就相当重要。你最不需要的就是,一个不熟悉你集群是如何搭建的人去修改系统配置 —— 这可能导致所有人都无法登录。 ### 初始命名空间 - 一个集群的三个初始命名空间:**default**、**kube-system** 和 **kube-public**。虽然你可以用这三个命名空间作技术部署,但我还是推荐你把这三个命名空间留作系统配置用,而不是你的项目。 +一个集群的三个初始命名空间:`default`、`kube-system` 和 `kube-public`。虽然技术上你可以用这三个命名空间作部署,但我还是推荐你把这三个命名空间留作系统配置用,而不是你的项目。 - * **Default** 某些部署没有指明命名空间,这样部署可以快速创建一个网格,但如果做了很多错误信息的部署,就很能去清理。我不去修改它,因为它在为某一个目的服务时,会在不止一种情况下误导我。 - * **Kube-system** 系统相关的所有对象组成的命名空间。任何此命名空间的部署都可能是危险的操作,可能对系统本身造成不可挽回的破坏。没错,我试过;所以我不推荐。 - * **Kube-public** 所有人可读,但是这个命名空间是为系统保留的。 +* `Default` 用于某些没有指明命名空间的部署,这是一种快速创建混乱的做法,如果你在没有正确信息的情况下做了很多部署,将很难清理。我不会去动它,因为它只有这一个用途,而且在不止一种情况下误导过我。 +* `Kube-system` 是 Kubernetes 系统相关的所有对象组成的命名空间。任何对此命名空间的部署都可能是危险的操作,可能对系统本身造成不可挽回的破坏。没错,我试过;所以我不推荐。 +* `Kube-public` 所有人可读,但是这个命名空间是为系统保留的。 ### 用命名空间来实现隔离 -我用了多种方式通过命名空间来实现隔离。我经常用命名空间来把多个用户项目分割到不同的环境。这种方式可以有效防止跨项目的污染,因为命名空间提供了独立的环境。例如,使用者可以安装不同版本的 Jenkins,如果它们的环境变量是在不同的命名空间,就不会冲突。 +我用了多种方式通过命名空间来实现隔离。我经常用命名空间来把多个用户项目分割到不同的环境。这种方式可以有效防止跨项目的污染,因为命名空间提供了独立的环境。例如,用户可以安装不同版本的 Jenkins,如果它们的环境变量是在不同的命名空间,就不会冲突。 -这种隔离对于清理也很有帮助。如果部署组的多个项目被废弃,你可以用命令 `kubectl delete ns <$NAMESPACENAME>` 一键删除命名空间,清理命名空间内的所有东西。(请确认被删除的是正确的命名空间。我曾经在生产环境删除了错误的命名空间,这很不好。) +这种隔离对于清理也很有帮助。如果开发小组的多个项目突然被废弃,你可以用命令 `kubectl delete ns <$NAMESPACENAME>` 一键删除命名空间,清理命名空间内的所有东西。(请确认被删除的是正确的命名空间。我曾经在生产环境删除了错误的命名空间,这很不好。) -如果你是基础设施所有者,请谨慎操作,因为这可能会引发其他团队的的故障或引发其他问题。例如,如果你创建了一个特定的命名空间,里面有 DNS 函数,其他人删除了它,那么命名空间内的所有 pod 和它们运行的应用都会被清空。所有的**删除**操作在真正实施之前都应该由同事(通过 [GitOps][3])评审一下。 +如果你是基础设施所有者,请谨慎操作,因为这可能会引发其他团队的的故障或引发其他问题。例如,如果你创建了一个特定的命名空间,里面有特殊的额外安全的 DNS 功能,但是其他人删除了它,那么命名空间内的所有 pod 和它们运行的应用都会被清空。所有的**删除**操作在真正实施之前都应该由同事(通过 [GitOps][3])评审一下。 虽然官方文档不建议 [10 人以下团队][2] 使用多个命名空间,但出于架构需要,在我自己的集群上还是用了多个命名空间。集群越干净越好。 ### 关于命名空间管理员应该知道的 -首先,命名空间不能嵌套。部署只能在一个命名空间中进行。对于版本化项目,你不一定要用命名空间,你可以使用标签来区分有相同名字的版本化应用。命名空间使用配额来为不同的用户划分资源;例如,*某个命名空间最多能有 x 个 node*。最后,所有的命名空间对于资源类型只能使用一个独一无二的名字。 +首先,命名空间不能嵌套。部署只能在一个命名空间中进行。对于版本化项目,你不一定要用命名空间,你可以使用标签来区分有相同名字的版本化应用。命名空间使用配额来为不同的用户划分资源;例如,*某个命名空间最多能有 x 个节点*。最后,所有的命名空间对于该资源类型只能使用一个独一无二的名字。 ### 命名空间命令操作 -你需要安装 [Minikube][4]、 [Helm][5] 和 [kubectl][6] 命令行,才能使用下面的命名空间命令。我的文章 [_安全浏览你的 DevOps 流水线_][7] 中有它们的安装教程,你也可以去每个工程的官方主页去找安装教程。我使用的是最新的 Minikube。手动安装很快,第一次就能成功运行。 +你需要安装 [Minikube][4]、[Helm][5] 和 [kubectl][6] 命令行,才能使用下面的命名空间命令。我的文章《[安全扫描你的 DevOps 流水线][7]》中有它们的安装教程,你也可以去每个项目的官方主页去找安装教程。我使用的是最新的 Minikube。手动安装很快,第一次就能成功运行。 获取你的第一组命名空间: @@ -63,7 +65,7 @@ jess@Athena:~$ kubectl create namespace athena namespace/athena created ``` -现在开发者可以部署到你创建的命名空间;例如,这里是一个简短的 Helm 结构信息: +现在开发者可以部署到你创建的命名空间了;例如,这里是一个简短的 Helm chart: ``` jess@Athena:~$ helm install teset-deploy stable/redis --namespace athena @@ -74,7 +76,7 @@ STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: -** Please be patient while the chart is being deployed ** +` Please be patient while the chart is being deployed ` Redis can be accessed via port 6379 on the following DNS names from within your cluster: teset-deploy-redis-master.athena.svc.cluster.local for read/write operations @@ -98,6 +100,7 @@ export REDIS_PASSWORD=$(kubectl get secret --namespace athena teset-deploy-redis ``` 2. 使用 Redis CLI 连接: + ```bash redis-cli -h teset-deploy-redis-master -a $REDIS_PASSWORD redis-cli -h teset-deploy-redis-slave -a $REDIS_PASSWORD @@ -110,11 +113,10 @@ kubectl port-forward --namespace athena svc/teset-deploy-redis-master 6379:6379 redis-cli -h 127.0.0.1 -p 6379 -a $REDIS_PASSWORD ``` -现在这一套部署已经完成了,你有一个在命名空间 **test-deploy** 中部署的图表。 +现在这一套部署已经完成了,你有一个在命名空间 `test-deploy` 中部署的 chart。 查看你的命名空间中有哪些 pod: - ``` jess@Athena:~$ kubectl get pods --namespace athena NAME                            READY   STATUS  RESTARTS   AGE @@ -127,7 +129,6 @@ teset-deploy-redis-slave-1      1/1     Running   0             90s 一键删除所有东西: - ```bash jess@Athena:~$ kubectl delete namespace athena namespace "athena" deleted @@ -137,7 +138,6 @@ namespace "athena" deleted 再次检查一下所有东西是否被删除了: - ```bash jess@Athena:~$ kubectl get pods --all-namespaces NAMESPACE       NAME                            READY   STATUS  RESTARTS   AGE @@ -156,11 +156,11 @@ kube-system   storage-provisioner               1/1     Running   0 ### 命名空间实践 -现在我是为了安全使用命名空间,如限制用户的权限。你可以限制所有的东西 — 从哪些角色可以访问命名空间,到命名空间可使用的集群资源(CPU 等)的配额等级。例如,我通过资源配额和基于角色的访问控制(role-based access control,RBAC)配置来确保只有允许的服务账号可以访问命名空间。 +当前我是出于安全考虑才使用命名空间,如限制用户的权限。你可以限制所有的东西 —— 从哪些角色可以访问命名空间,到命名空间可使用的集群资源(CPU 等)的配额等级。例如,我通过资源配额和基于角色的访问控制role-based access control(RBAC)配置来确保只有允许的服务账号可以访问命名空间。 -对于隔离方面的安全,我不希望我的私人 Jenkins 应用可以通过一个信任的本地网络被当做有公共 IP 地址的安全镜像来访问(我不得不假定,可能会做出妥协)。 +对于隔离方面的安全,我不希望我的私人 Jenkins 应用可以通过一个信任的本地网络被当做一个有公共 IP 地址的安全镜像来访问(我不得不假定,可能会被侵袭)。 -如果你很难提前计算出到底要在你的云平台上部署多少 node(就我而言,在把我的私人服务器放到 [segfaulting][8] 之前可以部署多少个 node),那么命名空间在预算方面也很有用。虽然这超出了本文的讨论范围,而且很复杂,但值得你去调研和使用来防止你的集群过分扩展。 +如果你很难提前计算出到底要在你的云平台上部署多少节点(或者,就我而言,是在[搞崩][8]我的家庭服务器之前我能部署多少个),那么命名空间在预算方面也很有用。虽然这超出了本文的讨论范围,而且很复杂,但值得你去调研和使用来防止你的集群过分扩展。 ### 总结 @@ -173,7 +173,7 @@ via: https://opensource.com/article/19/12/kubernetes-namespaces 作者:[Jessica Cherry][a] 选题:[lujun9972][b] 译者:[lxbwolf](https://github.com/lxbwolf) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202001/20191220 4 ways to volunteer this holiday season.md b/published/202001/20191220 4 ways to volunteer this holiday season.md new file mode 100644 index 0000000000..ca2c8fb8e0 --- /dev/null +++ b/published/202001/20191220 4 ways to volunteer this holiday season.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11803-1.html) +[#]: subject: (4 ways to volunteer this holiday season) +[#]: via: (https://opensource.com/article/19/12/ways-volunteer) +[#]: author: (John Jones https://opensource.com/users/johnjones4) + +假期志愿服务的 4 种方式 +====== + +> 想要洒播些节日的快乐吗?为开源组织做贡献,帮助有需要的社区。 + +![](https://img.linux.net.cn/data/attachment/album/202001/20/223730f7983z8atxp1tf4l.jpg) + +当领导者们配置人员和资源以做出积极改变时,就会产生社会影响。但是,许多社会努力都缺乏能够为这些改变者提供服务的技术资源。然而,有些组织通过将想要做出改变的开发人员与迫切需要更好技术的社区和非营利组织联系起来,来促进技术进步。这些组织通常为特定的受众提供服务,并招募特定种类的技术人员,它们有一个共同点:开源。 + +作为开发人员,我们出于各种原因试图加入开源社区。有些是为了专业发展,有些是为了能够与广阔的网络上令人印象深刻的技术人员合作,还有其他人则是因为他们清楚自己的贡献对于项目的成功的必要性。为什么不将你作为开发人员的才华投入到需要它的地方,而同时又为开源组织做贡献呢?以下组织是实现此目标的一些主要事例。 + +### Code for America + +“Code for America” 是在数字时代,政府如何依靠人民为人民服务的一个例子。通过其 Brigade Network,该组织在美国各个城市中组织了一个由志愿程序员、数据科学家、相关公民和设计师组成的全国联盟。这些本地分支机构定期举行聚会,向社区开放。这样既可以向小组推出新项目,又可以协调正在进行的工作。为了使志愿者与项目相匹配,该网站经常列出项目所需的特定技能,例如数据分析、内容创建和JavaScript。同时,Brigade 网站也会关注当地问题,分享自然灾害等共同经验,这些都可以促进成员之间的合作。例如,新奥尔良、休斯敦和坦帕湾团队合作开发了一个飓风响应网站,当灾难发生时,该网站可以快速响应不同的城市灾难情况。 + +想要加入该组织,请访问 [该网站][2] 获取 70 多个 Brigade 的清单,以及个人加入组织的指南。 + +### Code for Change + +“Code for Change” 显示了即使在高中时期,也可以为社会做贡献。印第安纳波利斯的一群高中开发爱好者成立了自己的俱乐部,他们通过创建针对社区问题的开源软件解决方案来回馈当地组织。“Code for Change” 鼓励当地组织提出项目构想,学生团体加入并开发完全自由和开源的解决方案。该小组已经开发了诸如“蓝宝石”之类的项目,该项目优化了当地难民组织的志愿者管理系统,并建立了民权委员会的投诉表格,方便公民就他们所关心的问题在网上发表意见。 + +有关如何在你自己的社区中创建 “Code for Change”,[访问他们的网站][3]。 + +### Python for Good/Ruby for Good + +“Python for Good” 和 “Ruby for Good” 是在俄勒冈州波特兰市和弗吉尼亚州费尔法克斯市举办的双年展活动,该活动将人们聚集在一起,为各自的社区开发和制定解决方案。 + +在周末,人们聚在一起聆听当地非营利组织的建议,并通过构建开源解决方案来解决他们的问题。 2017 年,“Ruby For Good” 参与者创建了 “Justice for Juniors”,该计划指导当前和以前被监禁的年轻人,并将他们重新融入社区。参与者还创建了 “Diaperbase”,这是一种库存管理系统,为美国各地的尿布库diaper bank所使用。这些活动的主要目标之一是将看似不同的行业和思维方式的组织和个人聚集在一起,以谋求共同利益。公司可以赞助活动,非营利组织可以提交项目构想,各种技能的人都可以注册参加活动并做出贡献。通过两岸(美国大西洋和太平洋东西海岸)的努力,“Ruby for Good” 和 “Python for Good” 一直恪守“使世界变得更好”的座右铭。 + +“[Ruby for Good][4]” 在夏天举行,举办地点在弗吉尼亚州费尔法克斯的乔治•梅森大学。 + +### Social Coder + +英国的 Ed Guiness 创建了 “Social Coder”,将志愿者和慈善机构召集在一起,为六大洲的非营利组织创建和使用开源项目。“Social Coder” 积极招募来自世界各地的熟练 IT 志愿者,并将其与通过 Social Coder 注册的慈善机构和非营利组织进行匹配。项目范围从简单的网站更新到整个移动应用程序的开发。 + +例如,PHASE Worldwide 是一个在尼泊尔支持工作的小型非政府组织,因为 “Social Coder”,它获得了利用开源技术的关键支持和专业知识。 + +有许多慈善机构已经与英国的 “Social Coder”进行了合作,也欢迎其它国家的组织加入。通过他们的网站,个人可以注册为社会软件项目工作,找到寻求帮助的组织和慈善机构。 + +对 “Social Coder” 的志愿服务感兴趣的个人可以 [在此][5]注册. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/ways-volunteer + +作者:[John Jones][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/johnjones4 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://brigade.codeforamerica.org/ +[3]: http://codeforchange.herokuapp.com/ +[4]: https://rubyforgood.org/ +[5]: https://socialcoder.org/Home/Programmer diff --git a/published/202001/20191220 Why Vim fans love the Herbstluftwm Linux window manager.md b/published/202001/20191220 Why Vim fans love the Herbstluftwm Linux window manager.md new file mode 100644 index 0000000000..91bb816e93 --- /dev/null +++ b/published/202001/20191220 Why Vim fans love the Herbstluftwm Linux window manager.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11734-1.html) +[#]: subject: (Why Vim fans love the Herbstluftwm Linux window manager) +[#]: via: (https://opensource.com/article/19/12/herbstluftwm-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +为什么 Vim 爱好者喜欢 Herbstluftwm Linux 窗口管理器 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。如果你是 Vim 爱好者,请试试 Herbstluftwm,这是一个受到 “Vim 方式”启发的平铺式 Linux 窗口管理器。 + +![](https://img.linux.net.cn/data/attachment/album/201912/31/215943pisvzwkm8mvsefhm.jpg) + +每个人都喜欢 Vim(除了 Dvorak 和 Emacs 用户)。Vim 非常流行,它不仅仅是个编辑器,还有整个都使用 Vim 键绑定来浏览网页的 Web 浏览器,在非常流行的 [Zsh][2] 终端仿真器中也有 Vim 模式。此外,还有一个名为 [herbstluftwm][3] 的窗口管理器,它部分模仿了 “Vim 方式”。Herbstluftwm 取消了窗口,而是在程序载入和使用时使用平铺的贴片或者象限代替。你可以使用键盘(`Alt+h`、`Alt+j`、`Alt+k` 和 `Alt+l`)从一个平铺贴片移动到另一个平铺贴片。 + +可以从发行版软件仓库安装 Herbstluftwm。安装后,请退出当前桌面会话,以便可以登录到新会话。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,具体取决于你的设置)将继续登录到以前的桌面,因此在登录之前必须覆盖它。 + +在 GDM 中: + +![][5] + +在 SDDM 中: + +![][6] + +### Herbstluftwm 桌面之旅 + +第一次登录 Herbstluftwm 时,你只会看到一个绿屏,边缘有深绿色边框。你所看到的是初始的平铺贴片,其中没有加载任何应用程序。要启动默认应用,请按 `Alt+Enter`。 + +![][4] + +文档中强调使用 `$HOME/.config/herbstluftwm/autostart` 作为登录时启动重要应用的配置文件。对于不必在每次登录时启动的应用,可以使用 xterm 作为启动守护进程。与往常一样,在命令后加一个 `&` 符号会将 shell 的控制权返回给你。例如,要启动 Emacs: + +``` +% emacs & +``` + +这将在新的平铺贴片中启动 Emacs 窗口,然后返回命令行。 + +![Emacs running in Herbstluftwm][7] + +#### 切换平铺贴片 + +要从一个平铺贴片移动到另一个平铺贴片,请使用经典的 `h`、`j`、`k` 或 `l` 与 `Alt` 的 Vim 导航组合键。例如,要从终端切换到其下方的平铺贴片中的应用(即屏幕底部),请按 `Alt+j`。要返回,请按 `Alt+k`。左移和右移分别为 `Alt+h` 和 `Alt+l`。 + +#### 分割屏幕 + +你可以使用 `Alt+o` 垂直分割屏幕,使用 `Alt+u` 水平分割屏幕。 + +要删除空白平铺贴片,请移动到该平铺贴片,然后按 `Alt+r`。 + +### 配置 herbstluftwm + +除了 `Alt` 键绑定外,你还可通过 `herbstclient` 命令与 Herbstluftwm 进行通信。此命令可以在 shell 中交互,或者你可在配置文件中保留你的首选项。 + +你可以查看 Herbstluftwm 中的所有可用属性: + +``` +$ herbstclient attr +``` + +Herbstluftwm 的默认行为定义在其默认配置文件中,你可以将其复制到你的家目录并进行修改。启动后,Herbstluftwm 执行配置文件中包含的命令。例如,你觉得使用以 `Alt` 为中心的键绑定很笨拙(它传统上是应用内保留快捷键),那你可以在配置文件中更改触发 Herbstluftwm 操作的键: + +``` +% mkdir ~/.config/herbstluftwm +% cp /usr/xdg/herbstluftwm/autostart ~/.config/herbstluftwm +% sed -i 's/Mod=Mod1/Mod=Mod4/' ~/.config/herbstluftwm +% herbstclient reload +``` + +这将使 Herbstluftwm 的修饰键更改为 `Super` 键(“Windows” 或 “Tux” 键,具体取决于你的键盘)。 + +使用 `autostart` 文件,你可以设置自定义键绑定,为特定类型的应用创建标签,以便以一致的方式平铺应用,并执行更多操作。 + +### 为何你要尝试 herbstluftwm + +Herbstluftwm 是一个平铺窗口管理器的很好例子。它默认平铺窗口,并允许用户定义全局规则的例外。它使用类似 Vim 的导航方式,但可以快速简单地覆盖它。它可能是你一直在寻找的平铺管理器,所以请马上尝试一下。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/herbstluftwm-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_2.jpg?itok=4fza48WU (OpenStack source code (Python) in VIM) +[2]: https://opensource.com/article/19/9/getting-started-zsh +[3]: https://herbstluftwm.org +[4]: https://opensource.com/sites/default/files/uploads/advent-herbsluftwm.png (Herbstluftwm) +[5]: https://opensource.com/sites/default/files/advent-gdm_1.jpg +[6]: https://opensource.com/sites/default/files/advent-kdm_0.jpg +[7]: https://opensource.com/sites/default/files/uploads/advent-herbsluftwm-emacs.jpg (Emacs running in Herbstluftwm) diff --git a/translated/tech/20191221 Pop-_OS vs Ubuntu- Which One is Better.md b/published/202001/20191221 Pop-_OS vs Ubuntu- Which One is Better.md similarity index 81% rename from translated/tech/20191221 Pop-_OS vs Ubuntu- Which One is Better.md rename to published/202001/20191221 Pop-_OS vs Ubuntu- Which One is Better.md index 3693d00e22..dd86eb3196 100644 --- a/translated/tech/20191221 Pop-_OS vs Ubuntu- Which One is Better.md +++ b/published/202001/20191221 Pop-_OS vs Ubuntu- Which One is Better.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (wxy) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11744-1.html) [#]: subject: (Pop!_OS vs Ubuntu: Which One is Better?) [#]: via: (https://itsfoss.com/pop-os-vs-ubuntu/) [#]: author: (Ankush Das https://itsfoss.com/author/ankush/) @@ -12,7 +12,7 @@ Pop!_OS 与 Ubuntu:哪个更棒? 好吧,你可能会发现从[最佳 Linux 发行版][1]列表中选择一个发行版很容易,但是,将两个类似的 Linux 发行版进行比较通常会令人困惑,就像 Pop!_OS 与 Ubuntu 一样。 -有趣的是,Pop!\_OS 基于 [Ubuntu][2]。那么,Pop!\_OS 和 Ubuntu 之间有什么区别呢?为什么要从中选择一个呢? +有趣的是,Pop!\_OS 是基于 [Ubuntu][2] 的。那么,Pop!\_OS 和 Ubuntu 之间有什么区别呢?为什么要从中选择一个呢? 在本文中,我将比较 Pop!_OS 和 Ubuntu(两者都是我的最爱)。 @@ -24,7 +24,7 @@ Pop!_OS 与 Ubuntu:哪个更棒? 发现相似之处可帮助你区分其他差异之处。因此,让我们从一些明显的相似之处开始。 -就像我提到的,Pop!\_OS 是基于 Ubuntu 之上的 Linux 发行版。因此,当你使用 Pop!_OS 时,你将获得使用 Ubuntu 的所有好处(从技术上说,其核心是一样的)。 +就像我提到的,Pop!\_OS 是基于 Ubuntu 之上的 Linux 发行版。因此,当你使用 Pop!\_OS 时,你将获得使用 Ubuntu 的所有好处(从技术上说,其核心是一样的)。 它们都默认带有 [GNOME 桌面环境][4],因此它们具有相似的用户界面(UI)。 @@ -42,7 +42,7 @@ Pop!_OS 与 Ubuntu:哪个更棒? 除了外观之外,[Ubuntu 还通过添加程序坞和其他一些小花巧来定制了 GNOME 的体验][6]。如果你喜欢定制的 GNOME 体验,可能会发现它更好。 -但是,如果你更喜欢纯粹的 GNOME 体验,默认情况下 Pop!_OS 会为你提供。 +但是,如果你更喜欢纯粹的 GNOME 体验,Pop!_OS 默认情况下为你提供的就是这样。 在你亲自尝试之前,我无法说服你。但是,Pop!_OS 中的总体配色方案、图标和主题可以说是令人愉悦的高级用户体验。 @@ -60,7 +60,7 @@ Ubuntu 非常重视 Snap 软件包。这增加了它提供的应用程序的数 我为什么要说这个呢? -因为 Pop!_OS 具有其[自己的官方 PPA][8],并在默认情况下已启用。你会在此处找到一些有用的应用程序,例如 Android Studio、TensorFlow。无需下载 Android Studio 的 1GB 大的 Snap 程序包。只需使用 [apt-get install][9]就可以了。 +因为 Pop!_OS 具有其[自己的官方 PPA][8],并已默认启用。你会在此处找到一些有用的应用程序,例如 Android Studio、TensorFlow。无需下载 Android Studio 的 1GB 大的 Snap 程序包。只需使用 [apt-get install][9]就可以了。 #### 预装应用 @@ -76,13 +76,13 @@ Ubuntu 非常重视 Snap 软件包。这增加了它提供的应用程序的数 ![][11] -对于熟悉 Snap 程序包的用户来说,Ubuntu 的软件中心是比 Pop!_OS 商店更好的解决方案,因为你可以在软件中心中列出快照程序包。 +对于熟悉 Snap 程序包的用户来说,Ubuntu 的软件中心是比 Pop!_OS 商店更好的解决方案,因为你可以在软件中心中列出 Snap 程序包。 -你无法在软件中心中过滤快照包,但是当你在软件中心中发现一个 Snap 包(查看应用程序来源的详细信息为“ Snap store ”/“Snapcraft”)时安装它就更容易了。 +你无法在软件中心中过滤 Snap 软件包,但是当你在软件中心中发现一个 Snap 软件包(查看应用程序来源的详细信息为 “Snap store”/“Snapcraft”)时安装它就更容易了。 -如果你感到困惑,Pop!\_OS 也确实支持快照包。但是,你不会在 Pop!_OS 商店中找到它们,这是唯一的区别。 +可能你会感到困惑,Pop!\_OS 也确实支持 Snap 软件包。但是,你不会在 Pop!\_OS 商店中找到它们,这是唯一的区别。 -如果不确定什么是 Snap 软件包及其功能,可以查看我们的文章[在 Linux 上安装 Snap 应用][12]。 +如果不确定什么是 Snap 软件包及其功能,可以查看我们的文章《[在 Linux 上安装 Snap 应用][12]》。 #### 单独的 NVIDIA/AMD ISO 文件 @@ -96,9 +96,9 @@ Ubuntu 非常重视 Snap 软件包。这增加了它提供的应用程序的数 #### 可靠性与问题 -毫无疑问,这两个[发行版都适合初学者][14],并且相当可靠。如果你想要更好的可靠性和更少的问题,则可能希望一直用长期支持(LTS)版本。 +毫无疑问,这两个[发行版都适合初学者][14],并且相当可靠。如果你想要更好的可靠性和更少的问题,则可能希望一直使用长期支持(LTS)版本。 -当出现新版本的 Ubuntu 时,Pop!_OS 将在其上开发,并有可能解决用户在 Ubuntu 原始发行版上遇到的问题,然后再进行新的升级。这给他们带来了一点优势,但这没什么实质性的不同,因为这些修复最终都可以运用于 Ubuntu。 +当出现新版本的 Ubuntu 时,Pop!_OS 将在其上开发,并有可能解决用户在 Ubuntu 原始发行版上遇到的问题,然后再进行新的升级。这给它们带来了一点优势,但这没什么实质性的不同,因为这些修复最终都可以运用于 Ubuntu。 #### 性能 @@ -110,7 +110,7 @@ Ubuntu 非常重视 Snap 软件包。这增加了它提供的应用程序的数 当然,你可以手动进行一些优化调整以满足要求——无论它们中的哪个不满足你的硬件配置。 -但是,如果你想使用 System76 笔记本电脑,那么 Pop!\_OS 将可以证明自己是 [Linux 领域的苹果][15],因为 Pop!_OS 是针对其硬件量身定制的,与 Ubuntu 有所不同。 +但是,如果你想使用 System76 笔记本电脑,那么 Pop!\_OS 将可以证明自己是 [Linux 领域的苹果][15],因为 Pop!\_OS 是针对其硬件量身定制的,与 Ubuntu 有所不同。 #### 硬件兼容性 @@ -131,7 +131,7 @@ via: https://itsfoss.com/pop-os-vs-ubuntu/ 作者:[Ankush Das][a] 选题:[lujun9972][b] 译者:[wxy](https://github.com/wxy) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202001/20191224 Chill out with the Linux Equinox Desktop Environment.md b/published/202001/20191224 Chill out with the Linux Equinox Desktop Environment.md new file mode 100644 index 0000000000..c6a96672d7 --- /dev/null +++ b/published/202001/20191224 Chill out with the Linux Equinox Desktop Environment.md @@ -0,0 +1,90 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11745-1.html) +[#]: subject: (Chill out with the Linux Equinox Desktop Environment) +[#]: via: (https://opensource.com/article/19/12/ede-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +轻松使用 Linux Equinox 桌面环境 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。EDE 不是最迷人、最小或效率最高的桌面。但它的柔和、安宁让人平静,它让人感到熟悉舒缓,它的图标主题也很有趣。 + +我还没有认真用过 Fast Light Toolkit([FLTK] [2]),但我是 C++ GUI 工具箱的粉丝,它非常易于学习,并且即使进行更新也很可靠。当我发现有一个用 FLTK 构建的桌面环境时,我很想尝试一下,并且我很快为我的决定感到高兴。[Equinox 桌面环境(EDE)][3] 是用 C++ 和 FLTK 为 Unix 桌面编写的快速、简单的桌面环境。它使用通用的桌面约定,因此外观和感觉都非常熟悉,并且在使用几天后,我发现它的简单性提供了我所喜欢的最低限度的优雅。 + +![EDE desktop][4] + +### 安装 EDE + +你可能会发现 EDE 包含在发行版的软件仓库中,但你也可以在它的 [SourceForge 仓库][5]中找到它。如果你已经在运行其他桌面环境,你可以安全地在同一系统上安装 EDE,因为它仅带来了一些额外的应用,这些应用程序特定于 EDE,因此它们不会妨碍你的其他桌面。 + +EDE 只是桌面环境,它使用 [Pekwm][6] 窗口管理器来处理布局。 + +安装 EDE 之后,注销当前的桌面会话,以便你可以登录到新的会话。默认情况下,会话管理器(KDM、GDM、LightDM 或 XDM,取决于你的设置)将继续登录到以前的桌面环境,因此你必须在登录之前覆盖该桌面环境。 + +在 GDM 中: + +![][7] + +在 SDDM 中: + +![][8] + +首次启动 EDE 时,可能会提示你确认一些启动任务。在我的 Slackware 工作站上,KDE 将某些服务标记为启动任务(例如 HPLIP 打印监视器和蓝牙守护程序),并且 EDE 在一个确认框中显示了它们。 + +![Importing desktop services in EDE][9] + +设置一次后,你无需再次进行设置。 + +### EDE 桌面之旅 + +EDE 的布局恰恰是大多数人在桌面上所期望的布局:左侧的应用菜单、中间的任务栏、右侧的系统托盘。这是标准的现成布局,不会让任何人感到困惑。这是一个可以安全地装在 Linux 上并且可以自信地给任何没有使用过 Linux 的人使用的桌面。他们将以舒适的方式很快地适应这个桌面。 + +你可以单击鼠标右键打开一个小型桌面菜单。这可以让你在桌面上创建应用启动器、创建文件夹并设置一些主题选项。 + +屏幕底部的面板是可伸缩的,因此你可以根据需要在全屏模式下工作。单击屏幕右下角的时钟来调出日历和时区设置。 + +EDE 有一个小的配置应用,可用于设置一些简单的选项: + +* 背景和图标设置 +* 屏幕保护程序设置 +* 时间和时钟 +* 系统铃声 +* 键盘 +* 偏好应用 + +![EDE Configuration Place][10] + +EDE 的功能不多。没有文件管理器、文本编辑器、绘画程序或纸牌游戏。你必须安装你想在桌面运行的程序。这意味着你可以从各种各样的 Linux 应用中进行选择,并使用你最喜欢的。 + +### EDE 总结 + +我发现 EDE 至少作为一种“假日”桌面而言,它的简单性令人舒适。它值得一看。它不是最迷人的桌面,也不是最精简的、也不是最高效的。但它的柔和、安宁让人平静,它让人感到熟悉舒缓,并且它的图标主题充满乐趣和生气。EDE 是一个以其缓慢而稳定的步调而自豪的桌面。 + +如果你想放松心情使用一个干净和令人愉悦的界面,请试试 EDE。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/ede-linux-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/penguin.igloo_.png?itok=K92O7H6b (Linux penguin at the north pole beside an igloo) +[2]: https://www.fltk.org/ +[3]: https://sourceforge.net/projects/ede/ +[4]: https://opensource.com/sites/default/files/uploads/advent-ede.jpg (EDE desktop) +[5]: http://ede.sf.net +[6]: https://opensource.com/article/19/12/pekwm-linux-desktop +[7]: https://opensource.com/sites/default/files/advent-gdm_2.jpg +[8]: https://opensource.com/sites/default/files/advent-kdm_1.jpg +[9]: https://opensource.com/sites/default/files/uploads/advent-ede-init.jpg (Importing desktop services in EDE) +[10]: https://opensource.com/sites/default/files/uploads/advent-ede-conf.jpg (EDE Configuration Place) diff --git a/published/202001/20191226 Darktable 3 Released With GUI Rework and New Features.md b/published/202001/20191226 Darktable 3 Released With GUI Rework and New Features.md new file mode 100644 index 0000000000..b7c6b53cbb --- /dev/null +++ b/published/202001/20191226 Darktable 3 Released With GUI Rework and New Features.md @@ -0,0 +1,110 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11741-1.html) +[#]: subject: (Darktable 3 Released With GUI Rework and New Features) +[#]: via: (https://itsfoss.com/darktable-3-release/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Darktable 3 发布,带来重新打造的 UI 及新的功能 +====== + +> 这是给摄影爱好者的圣诞节礼物。Darktable 3.0 刚刚发布了。 + +[Darktable][1] 是[在 Linux 上编辑 RAW 图像的最佳应用之一][2]。你可以将其视为 [Adobe Lightroom 的自由开源替代品][3]。 + +Darktable 3 是一个主版本更新,它带来了大量的功能改进和重新打造的用户界面。现在,GUI 完全由 GTK+ CSS 规则所控制,这使得整个 GUI 都可定制主题。它默认有八个主题。 + +借助 3000 多个提交和 553 个拉取请求,新版本修复了 66 个 bug 并添加了许多新功能。 + +让我们看看这个新版本带来了什么功能。 + +### Darktable 3.0 的新功能 + +![Darktable 3.0 Screenshot][4] + +以下是重要的新功能: + +* 重新打造的 UI +* 用于处理 3D RGB Lut 变换的新模块 +* 对“降噪(轮廓化)”模块进行了许多改进 +* 添加了新的“剔除”模式和时间轴视图 +* 对“降噪(轮廓化)”模块进行了许多改进 +* 新色调均衡器的基本和电影 RGB 模块 +* 更好的 4K/5K 显示支持 +* 撤消/重做支持更多操作 +* 针对 CPU 和 SSE 路径的许多代码优化 +* 支持导出到 Google 相册 +* 支持更多的相机,白平衡预设和噪点配置 +* 大量的 bug 修复和功能改进 + +你可以在 [GitHub 发行说明][5]中了解所有更改。 + +### 在 Linux 上安装 Darktable 3.0 + +让我们看看如何获​​取最新的 Darktable 版本。 + +#### 在基于 Ubuntu 的发行版上安装 Darktable 3.0 + +Ubuntu 仓库中有 Darktable,但你不能得到马上最新的版本。对于 LTS 版本,它的更新可能需要几个月的时间。 + +不用担心!Darktable 提供了[自己的 PPA][6] 来在基于 Ubuntu 的发行版上安装最新版本。 + +不幸的是,此 Darktable PPA 尚未随新版本更新。 + +不用担心了!多亏了我们的朋友 [Ubuntu Handbook 的 Ji M][7],我们有一个非正式的 PPA,可以轻松地在 Ubuntu 和其他基于 Ubuntu 的发行版上安装 Darktable 3.0。 + +打开终端,并使用这些命令: + +``` +sudo add-apt-repository ppa:ubuntuhandbook1/darktable +sudo apt update +sudo apt install darktable +``` + +#### 卸载 Darktable 3 + +要删除通过此 PPA 安装的 Darktable,你可以先卸载该应用: + +``` +sudo apt remove darktable +``` + +接着[删除 PPA][8]: + +``` +sudo add-apt-repository -r ppa:ubuntuhandbook1/darktable +``` + +#### 在其他 Linux 发行版上安装 Darktable + +你可以等待到你的发行版的软件管理器提供新版本。 + +你也可以从 GitHub 发布页面(位于页面底部)下载 tarball 或所有源代码。 + +- [下载 Darktable 3.0][5] + +使用 Darktable 3,你可以更好地编辑自己的假期照片:) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/darktable-3-release/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.darktable.org/ +[2]: https://itsfoss.com/raw-image-tools-linux/ +[3]: https://itsfoss.com/open-source-photoshop-alternatives/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/darktable_3_screenshot.jpg?ssl=1 +[5]: https://github.com/darktable-org/darktable/releases/tag/release-3.0.0 +[6]: https://launchpad.net/~pmjdebruijn/+archive/ubuntu/darktable-release +[7]: http://ubuntuhandbook.org/index.php/2019/12/install-darktable-3-0-0-ubuntu-18-04-19-10/ +[8]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ diff --git a/published/202001/20191227 10 resources to boost your Git skills.md b/published/202001/20191227 10 resources to boost your Git skills.md new file mode 100644 index 0000000000..8dc63c18bf --- /dev/null +++ b/published/202001/20191227 10 resources to boost your Git skills.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11737-1.html) +[#]: subject: (10 resources to boost your Git skills) +[#]: via: (https://opensource.com/article/19/12/git-resources) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +10 个提高 Git 技能的资源 +====== + +> 年末总结一下 Git 的最佳表现。以下是告诉你可以在新的一年中以新奇的方式使用 Git 的十篇文章。 + +![](https://img.linux.net.cn/data/attachment/album/202001/02/093934q5ifu46u4nuq4lgi.jpg) + +2019 年过去了,是时候回顾一下我们(opensource.com)今年发表的有关 Git 的前 10 篇文章了。 + +这些文章包括从用例和教程到一些非常有趣的(甚至有些非常规的)使用 Git 的方法。所有这些文章都可以帮助你提高 Git 技能,但是,如果你确实需要 Git 入门介绍,请务必查看我们的《[Git 入门:术语入门][2]》文章,并下载我们的 [Git 备忘单][3]。 + +1. Molly de Blanc 写的《[GNOME 项目如何使用 Git][4]》考察了 GNOME 项目采用的自托管 GitLab 实例的做法,该实例作为 GNOME 项目集中保存对 GNOME 做出的贡献的位置。De Blanc 从事于非编码职位,因此她的文章还探讨了切换到 GitLab 如何使主要角色不是编写代码的贡献者受益。 +2. Ahmad Awais 写的《[Emoji-Log:编写 Git 提交信息的新方法][5]》解释了如何使用 Emoji-Log(一种直白的、开源的 Git 提交日志标准)来编写更好、更用户友好的 Git 提交消息。本文概述了 Emoji-Log 背后的理论以及可添加到 `.bashrc`、`.zshrc` 或 `.gitconfig` 中的配置示例,以便你快速开始使用 Emoji-Log。 +3. 在《[用 Git 管理你的每日行程][6]》中,Seth Kenlon 解释了如何使用 Git 来管理日历。通过结合 Org 模式、Git 和其他一些工具,Kenlon 描述了如何创建可在设备之间同步的基于 Git 的日历工作流。 +4. 《[用 Git 作为聊天应用的后端][7]》,Seth Kenlon 探索了另一种使用 Git 的非常规方式。在本文中,他探讨了 GIC,这是一个用 Node.js 编写的聊天客户端,其中 Git 用作后端数据库。GIC 是一个概念验证模型,不是供产品环境使用的东西,但是它提供了一个有趣的示例,说明了使用 Git 的真正独特方法。 +5. Alan Formy-Duval 的《[Git 学习实用练习][8]》是一份他为提高 Git 技能而努力的编年史。他分享了自己的经验,以使其他人受益于他所学,而 Git 新手将从这篇对 Git 核心功能的出色概述中受益匪浅。 +6. 《[用 Git 帮助写作者更好地完成工作][9]》的作者 Seth Kenlon 着眼于写作者如何从基于 Git 的工作流中受益。本文介绍了如何使用 Git 和 Atom 利用 Markdown 进行书写。通过遵循本文中的示例,写作者可以轻松地将复杂的版本控制系统添加到其编写工作流中。 +7. Sachin Patil 在《[如何使用 Magit 管理 Git 项目][10]》中,解释了如何使用 Emacs 的 Magit 扩展来管理 Git 存储库。本文提供了有关如何在 Emacs 中执行一系列关键 Git 任务的清晰示例。这些示例带有说明各种任务的屏幕截图。 +8. 《[把“点文件”放到版本控制中][11]》的作者 Matthew Broberg 演示了如何使用 Git 存储放在主目录中的点文件。将你的点文件存储在 Git 存储库中,可以更轻松地在计算机之间共享系统配置,并且,如果你愿意的话,也可以与其他人共享配置。这篇文章也有不要共享哪些文件的警告,因为共享错误的点文件会将其暴露给其他人。 +9. Austin Dewey 的《[4 种用于 Git 加密的机密管理工具][12]》在本文中比较了 Git-crypt、BlackBox、SOPS 和 Transcrypt,研究了在 Git 中存储机密的工具。本文涵盖四个主要领域:支持的加密类型、每个项目的目标、项目的工作流和差异以及其他功能。 +10. Seth Kenlon 的《[使用 Git 管理 Git 服务器][13]》解释了如何使用 Gitolite 管理 Git 服务器。Gitolite 是使用 Git 来管理 Git 服务器的“管理杂项的后端应用程序”。本文演示了如何安装、配置和使用 Gitolite,并提供了清晰的示例详细说明了该过程的每个步骤。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/git-resources + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/button_push_open_keyboard_file_organize.png?itok=KlAsk1gx (open source button on keyboard) +[2]: https://opensource.com/article/19/2/git-terminology +[3]: https://opensource.com/downloads/cheat-sheet-git +[4]: https://opensource.com/article/19/10/how-gnome-uses-git +[5]: https://linux.cn/article-10627-1.html +[6]: https://linux.cn/article-11320-1.html +[7]: https://linux.cn/article-11342-1.html +[8]: https://opensource.com/article/19/5/practical-learning-exercise-git +[9]: https://linux.cn/article-11499-1.html +[10]: https://opensource.com/article/19/1/how-use-magit +[11]: https://linux.cn/article-11419-1.html +[12]: https://opensource.com/article/19/2/secrets-management-tools-git +[13]: https://opensource.com/article/19/4/server-administration-git diff --git a/translated/tech/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md b/published/202001/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md similarity index 77% rename from translated/tech/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md rename to published/202001/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md index b8af543814..4075e017a8 100644 --- a/translated/tech/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md +++ b/published/202001/20191227 Explained- Why Your Distribution Still Using an ‘Outdated- Linux Kernel.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (chen-ni) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11791-1.html) [#]: 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/) @@ -10,7 +10,9 @@ 为什么你的发行版仍然在使用“过时的”Linux 内核? ====== -[检查一下你的系统所使用的 Linux 内核版本][1],你十有八九会发现,按照 Linux 内核官网提供的信息,该内核版本已经达到使用寿命终期了。 +![](https://img.linux.net.cn/data/attachment/album/202001/16/225806jbqyacu3loolobae.png) + +[检查一下你的系统所使用的 Linux 内核版本][1],你十有八九会发现,按照 Linux 内核官网提供的信息,该内核版本已经达到使用寿命终期(EOL)了。 一个软件一旦达到了使用寿命终期,那么就意味着它再也不会得到 bug 修复和维护了。 @@ -18,11 +20,11 @@ 下面将逐一解答这些问题。 -总结 - -上游内核维护与你的发行版的内核维护是两个不同的概念。 - -例如,根据 Linux 内核官网,Linux 内核 4.15 版本可能已经达到使用寿命终期了,但是在 2023 年 4 月之前,Ubuntu 18.04 长期维护版本将会继续使用这个版本,并通过向后移植安全补丁和修复 bug 来提供维护。 +> **总结** +> +> 上游内核维护与你的发行版的内核维护是两个不同的概念。 +> +> 例如,根据 Linux 内核官网,Linux 内核 4.15 版本可能已经达到使用寿命终期了,但是在 2023 年 4 月之前,Ubuntu 18.04 长期维护版本将会继续使用这个版本,并通过向后移植安全补丁和修复 bug 来提供维护。 ### 检查 Linux 内核版本,以及是否达到使用寿命终期 @@ -35,13 +37,11 @@ uname -r 我使用的是 Ubuntu 18.04,输出的 Linux 内核版本如下: ``` -[email protected]:~$ uname -r +abhishek@itsfoss:~$ uname -r 5.0.0-37-generic ``` -接下来,可以到 Linux 内核官网上看看哪些 Linux 内核版本仍然在维护状态。在网站主页上就可以看到相关信息。 - -[Linux 内核官网][2] +接下来,可以到 [Linux 内核官网][2]上看看哪些 Linux 内核版本仍然在维护状态。在网站主页上就可以看到相关信息。 你看到的内核版本状态应该类似于下图: @@ -53,7 +53,7 @@ uname -r 不幸的是,Linux 内核的生命周期没有任何规律可循。不是说常规的内核稳定发布版可以得到 X 月的维护、长期维护版本(LTS)可以得到 Y 年的维护。没有这回事。 -根据实际需求,可能会存在内核的多个 LTS 版本,其使用寿命终期各不相同。在[这个页面][5]上可以查到这些 LTS 版本的相关信息,包括推定的使用寿命终期。 +根据实际需求,可能会存在内核的多个 LTS 版本,其使用寿命终期各不相同。在[这个页面][5]上可以查到这些 LTS 版本的相关信息,包括计划的使用寿命终期。 那么问题来了:既然 Linux 内核官网上明确表示 5.0 版本的内核已经达到了使用寿命终期,Ubuntu 为什么还在提供这个内核版本呢? @@ -63,11 +63,11 @@ uname -r 你是否想过,为什么 Ubuntu/Debian/Fedora 等发行版被称为 Linux “发行版”?这是因为,它们“发行” Linux 内核。 -这些发行版会对 Linux 内核进行不同的修改,并添加各种 GUI 元素(包括桌面环境,显示服务器等)以及软件,然后再呈现给用户。 +这些发行版会对 Linux 内核进行不同的修改,并添加各种 GUI 元素(包括桌面环境、显示服务器等)以及软件,然后再呈现给用户。 按照通常的工作流,Linux 发行版会选择一个内核,提供给其用户,然后在接下来的几个月、几年中,甚至是达到内核的使用寿命终期之后,仍然会继续使用该内核。 -这样能够保障安全吗?其实是可以的,因为 _**发行版会通过向后移植全部的重要修补来维护内核**_。 +这样能够保障安全吗?其实是可以的,因为 **发行版会通过向后移植全部的重要修补来维护内核**。 换句话说,你的 Linux 发行版会确保 Linux 内核没有漏洞和 bug,并且已经通过向后移植获得了重要的新特性。在“过时的旧版本 Linux 内核”上,其实有着数以千计的改动。 @@ -83,13 +83,13 @@ uname -r 新的 Linux 内核稳定版本每隔 2 到 3 个月发布一次,有不少用户跃跃欲试。 -实话说,除非有十分充分的理由,否则不应该使用最新版本的稳定内核。你使用的发行版并不会提供这个选项,你也不能指望通过在键盘上敲出“_sudo apt give-me-the-latest-stable-kernel_”解决问题。 +实话说,除非有十分充分的理由,否则不应该使用最新版本的稳定内核。你使用的发行版并不会提供这个选项,你也不能指望通过在键盘上敲出 `sudo apt give-me-the-latest-stable-kernel` 解决问题。 -此外,手动[安装主流 Linux 内核版本][8]本身就是一个挑战。即使安装成功,之后每次发布 bug 修复的时候,负责更新内核的就会是你了。此外,当新内核达到使用寿命终期之后,你就有责任将它升级到更新的内核版本了。和常规的[Ubuntu 更新][9]不同,内核升级无法通过 apt upgrade 完成。 +此外,手动[安装主流 Linux 内核版本][8]本身就是一个挑战。即使安装成功,之后每次发布 bug 修复的时候,负责更新内核的就会是你了。此外,当新内核达到使用寿命终期之后,你就有责任将它升级到更新的内核版本了。和常规的 [Ubuntu 更新][9]不同,内核升级无法通过 `apt upgrade` 完成。 同样需要记住的是,切换到主流内核之后,可能就无法使用你的发行版提供的一些驱动程序和补丁了。 -正如 [Greg Kroah-Hartman][10]所言,“_**你能使用的最好的内核,就是别人在维护的内核。**_”除了你的 Linux 发行版之外,又有谁更胜任这份工作呢! +正如 [Greg Kroah-Hartman][10]所言,“**你能使用的最好的内核,就是别人在维护的内核。**”除了你的 Linux 发行版之外,又有谁更胜任这份工作呢! 希望你对这个主题已经有了更好的理解。下回发现你的系统正在使用的内核版本已经达到使用寿命终期的时候,希望你不会感到惊慌失措。 @@ -102,7 +102,7 @@ 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) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202001/20191229 The best resources for agile software development.md b/published/202001/20191229 The best resources for agile software development.md new file mode 100644 index 0000000000..7ffc566009 --- /dev/null +++ b/published/202001/20191229 The best resources for agile software development.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: (algzjh) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11816-1.html) +[#]: subject: (The best resources for agile software development) +[#]: via: (https://opensource.com/article/19/12/agile-resources) +[#]: author: (Leigh Griffin https://opensource.com/users/lgriffin) + +敏捷软件开发的最佳资源 +====== + +> 请阅读我们的热门文章,这些文章着重讨论了敏捷的过去、现在和未来。 + +![](https://img.linux.net.cn/data/attachment/album/202001/25/121308jrs4speu2y09u09e.jpg) + +对于 Opensource.com 上的敏捷主题来说,2019 年是非常棒的一年。随着 2020 年的到来,我们回顾了我们读者所读的与敏捷相关的热门文章。 + +### 小规模 Scrum 指南 + +Opensource.com 关于[小规模 Scrum][2] 的指南(我曾参与合著)由六部分组成,为小型团队提供了关于如何将敏捷引入到他们的工作中的建议。在官方的 [Scrum 指南][3]的概述中,传统的 Scrum 框架推荐至少三个人来实现,以充分发挥其潜力。但是,它并没有为一两个人的团队如何成功遵循 Scrum 提供指导。我们的六部分系列旨在规范化小规模的 Scrum,并检验我们在现实世界中使用它的经验。该系列受到了读者的热烈欢迎,以至于这六篇文章占据了前 10 名文章的 60%。因此,如果你还没有阅读的话,一定要从我们的[小规模 Scrum 介绍页面][2]下载。 + +### 全面的敏捷项目管理指南 + +遵循传统项目管理方法的团队最初对敏捷持怀疑态度,现在已经热衷于敏捷的工作方式。目前,敏捷已被接受,并且一种更加灵活的混合风格已经找到了归宿。Matt Shealy 撰写的[有关敏捷项目管理的综合指南][4]涵盖了敏捷项目管理的 12 条指导原则,对于希望为其项目带来敏捷性的传统项目经理而言,它是完美的选择。 + +### 成为出色的敏捷开发人员的 4 个步骤 + +DevOps 文化已经出现在许多现代软件团队中,这些团队采用了敏捷软件开发原则,利用了最先进的工具和自动化技术。但是,这种机械的敏捷方法并不能保证开发人员在日常工作中遵循敏捷实践。Daniel Oh 在[成为出色的敏捷开发人员的 4 个步骤][5]中给出了一些很棒的技巧,通过关注设计思维,使用可预测的方法,以质量为中心并不断学习和探索来提高你的敏捷性。用你的敏捷工具补充这些方法将形成非常灵活和强大的敏捷开发人员。 + +### Scrum 和 kanban:哪种敏捷框架更好? + +对于以敏捷方式运行的团队来说,Scrum 和 kanban 是两种最流行的方法。在 “[Scrum 与 kanban:哪种敏捷框架更好?][6]” 中,Taz Brown 探索了两者的历史和目的。在阅读本文时,我想起一句名言:“如果你的工具箱里只有锤子,那么所有问题看起来都像钉子。”知道何时使用 kanban 以及何时使用 Scrum 非常重要,本文有助于说明两者都有一席之地,这取决于你的团队、挑战和目标。 + +### 开发人员对敏捷发表意见的 4 种方式 + +当采用敏捷的话题出现时,开发人员常常会担心自己会被强加上一种工作风格。在“[开发人员对敏捷发表意见的 4 种方式][7]”中,[Clément Verna][8] 着眼于开发人员通过帮助确定敏捷在其团队中的表现形式来颠覆这种说法的方法。检查敏捷的起源和基础是一个很好的起点,但是真正的价值在于拥有可帮助指导你的过程的指标。知道你将面临什么样的挑战会给你的前进提供坚实的基础。根据经验进行决策不仅可以增强团队的能力,还可以使他们对整个过程有一种主人翁意识。Verna 的文章还探讨了将人置于过程之上并作为一个团队来实现目标的重要性。 + +### 敏捷的现在和未来 + +今年,Opensource.com 的作者围绕敏捷的过去、现在以及未来可能会是什么样子进行了大量的讨论。感谢他们所有人,请一定于 2020 年在这里分享[你自己的敏捷故事][9]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/agile-resources + +作者:[Leigh Griffin][a] +选题:[lujun9972][b] +译者:[algzjh](https://github.com/algzjh) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lgriffin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard2.png?itok=WnKfsl-G "Women programming" +[2]: https://opensource.com/downloads/small-scale-scrum +[3]: https://scrumguides.org/scrum-guide.html +[4]: https://opensource.com/article/19/8/guide-agile-project-management +[5]: https://opensource.com/article/19/2/steps-agile-developer +[6]: https://opensource.com/article/19/8/scrum-vs-kanban +[7]: https://opensource.com/article/19/10/ways-developers-what-agile +[8]: https://twitter.com/clemsverna +[9]: https://opensource.com/how-submit-article diff --git a/published/202001/20191230 10 articles to enhance your security aptitude.md b/published/202001/20191230 10 articles to enhance your security aptitude.md new file mode 100644 index 0000000000..4f55e44590 --- /dev/null +++ b/published/202001/20191230 10 articles to enhance your security aptitude.md @@ -0,0 +1,92 @@ +[#]: collector: "lujun9972" +[#]: translator: "nacyro" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-11742-1.html" +[#]: subject: "10 articles to enhance your security aptitude" +[#]: via: "https://opensource.com/article/19/12/security-resources" +[#]: author: "Ben Cotton https://opensource.com/users/bcotton" + +10 篇强化你的安全能力的文章 +====== + +> 无论你是新手还是想要增加技能,这十篇安全文章中都有适合你的内容。 + +![](https://img.linux.net.cn/data/attachment/album/202001/03/004344rco51cnc153ns1zz.jpg) + +如果安全是一个过程(确实如此),那么理所当然的,不同的项目(及其贡献者)的情况各有不同。有些应用程序经历了多年的安全测试,由在信息安全领域工作了几十年的人员所设计。而另外一些则是由开发人员在他们的第一个开源项目中开发的全新项目。毫不奇怪,这十大安全文章囊括了代表这一范围的经验。我们有介绍基本安全实践的文章,也有深入探讨更高级主题的文章。 + +无论你是新手还是想要增加你在传奇职业生涯中获得的技能,2019 年十大安全文章中都有适合你的内容。 + +### 《安全强化你的 Linux 服务器的七个步骤》 + +安全如舍,地基不牢,房屋不稳。Patrick H. Mullins 的杰作《[安全强化你的 Linux 服务器的七个步骤][2]》让你从 Linux 服务器的基本安全步骤开始。即使你有很多管理服务器的经验,本文也提供了一个很好的清单以确保你掌握了基础知识。在此基础上,你可以开始添加额外的安全层。 + +### 《使用防火墙让你的 Linux 更加强大》 + +七步捍卫你的 Linux 服务器中的一步即是启用防火墙。但什么**是**防火墙,它是如何工作的呢? Seth Kenlon 在《[使用防火墙让你的 Linux 更加强大][3]》一文中回答了这些问题,然后详细描述了为了更好的安全性应如何配置你的防火墙。使用 firewalld 与 Network Manager,你可以为不同的网络设置不同的防火墙配置。例如,这允许你在家庭网络上进行信任配置,并在你最喜欢的咖啡店的 WiFi 网络上进行更多疑的配置。 + +### 《用集中日志减少安全风险》 + +保护系统安全,只有开始,没有结束:安全是一个过程而不是状态。**保持**系统安全工作的一部分即是密切关注所发生的事情。集中化日志是实现这一点的一种方法,尤其是在管理多系统时。在《[减少集中日志的安全风险][4]》中 Hannah Suarez 分享了要如何开始(她这篇文章基于她在 FOSDEM'19 [自由及开源软件开发者欧洲会议] 中的闪电演讲)。 + +### 《在 SSH 中使用 GPG 密钥》 + +大多数人都会为 SSH 的密钥认证使用 SSH 密钥。为什么不呢?毕竟 SSH 就在名字里。从安全的角度来看,这些方法非常好。但若想简化某些形式的密钥分发与备份还有另一种方法,Brian Exelbierd 的三部曲系列介绍了《[如何启用使用 GPG 子钥的 SSH 访问][5]》、《[如何导入现有 SSH 密钥][6]》、《[如何将备份量减少到单个密钥文件][7]》 + +### 《使用 Seahorse 图形化管理 SSH 密钥》 + +并不是所有人都喜欢用 GPG 作为 SSH 密钥,但这并不意味着你在密钥管理上会不顺利。Seahorse 是一个在 GNOME 桌面中用于管理 SSH 密钥及其他身份验证方法的图形化工具。Alan Formy-Duval 的《[使用 Seahorse 图形化管理 SSH 密钥》对新手用户特别有帮助。 + +### 《安全扫描你的 DevOps 流程》 + +如今到处都是容器。但它们容纳着什么?了解容器满足你的安全策略是保持安全性的重要部分。幸运的是,你可以使用开源工具来帮助自动化合规检查。Jessica Cherry(原名: Repka)的《[安全扫描你的 DevOps 流程][9]》是一个循序渐进的教程,向你展示了如何使用 Jenkins 构建系统和 Anchore 检查服务为容器镜像和注册库创建扫描流程。 + +### 《4 种开源云安全工具》 + +云服务的一大优点是你的数据可以从任何地方访问。云服务的一个缺点是你的数据可以从任何地方访问。如果你使用的是 “-as-a-Service”(LCTT 译注: 某某即服务,如 IaaS、PaaS、Saa)产品,那么你需要确保它们是经过安全配置的。Anderson Silva、Alison Naylor、Travis McPeak 和 Rich Monk 联合推出《[4 种开源云安全工具][10]》以帮助在使用 GitHub 和 AWS 时提高安全性。如果你正在寻找被不小心提交的机密信息,或尝试从一开始就阻止这些机密信息被提交,这篇文章提供了工具。 + +### 《如何使用 OpenSSL:哈希、数字签名等》 + +许多信息安全是基于数学的:特别是用于加密数据和验证用户或文件内容的加密函数。在《[开始使用 OpenSSL:密码学基础][11]》中进行介绍后,Marty Kalin 深入讨论了《[如何使用 OpenSSL:哈希、数字签名等][12]》的细节,解释了如何使用 OpenSSL 实用程序来探索这些常用但不常被理解的概念。 + +### 《使用树莓派和 Kali Linux 学习计算机安全》 + +廉价硬件与开源软件构成了一个很好的组合,特别是对于那些希望边做边学的人来说。在《[使用树莓派和 Kali Linux 学习计算机安全][13]》这篇文章中,Anderson Silva 介绍了面向安全的 Kali Linux 发行版。这是一篇短文,但它满是关于文档和安全相关项目的有用的链接,你可以在自己的树莓派上使用它们。 + +### 《量子计算会打破现有的安全体系吗?》 + +这篇文章的余下部分是浪费吗?量子计算会让我们对安全的所知变得过时吗?好消息是:回答是否定的,但是量子计算仍然可以在更广泛的范围内对安全和计算世界产生深远的影响。在《[量子计算会打破现有的安全体系吗?][14]》一文中,Mike Bursell 剖析了它好坏两方面的影响,当然,量子计算可能会让加密的破解变得更容易,但如果坏人一开始就无法获得你的数据,那也没有关系。 + +### 展望 2020 + +安全永远是重要的,(正如那篇量子计算文章所建议的)未来几年将是该领域的一个有趣时期。在 2020 年,我们的文章将着眼于开源安全的前沿,并帮助向不断增长的开源社区解释基础知识。如果你有一个你想要我们报导的主题,请在评论中分享它,或者更进一步 —— 如果你想写一篇文章,就写给我们吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/security-resources + +作者:[Ben Cotton][a] +选题:[lujun9972][b] +译者:[nacyro](https://github.com/nacyro) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bcotton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_security_cc.png?itok=3V07Lpko "A secure lock." +[2]: https://linux.cn/article-11444-1.html +[3]: https://linux.cn/article-11093-1.html +[4]: https://opensource.com/article/19/2/reducing-security-risks-centralized-logging +[5]: https://opensource.com/article/19/4/gpg-subkeys-ssh +[6]: https://opensource.com/article/19/4/gpg-subkeys-ssh-multiples +[7]: https://opensource.com/article/19/4/gpg-subkeys-ssh-manage +[8]: https://opensource.com/article/19/4/ssh-keys-seahorse +[9]: https://opensource.com/article/19/7/security-scanning-your-devops-pipeline +[10]: https://linux.cn/article-11432-1.html +[11]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-1 +[12]: https://opensource.com/article/19/6/cryptography-basics-openssl-part-2 +[13]: https://opensource.com/article/19/3/computer-security-raspberry-pi +[14]: https://linux.cn/article-10566-1.html +[15]: https://opensource.com/how-submit-article diff --git a/published/202001/20191230 Fixing -VLC is Unable to Open the MRL- Error -Quick Tip.md b/published/202001/20191230 Fixing -VLC is Unable to Open the MRL- Error -Quick Tip.md new file mode 100644 index 0000000000..51b076d906 --- /dev/null +++ b/published/202001/20191230 Fixing -VLC is Unable to Open the MRL- Error -Quick Tip.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11748-1.html) +[#]: subject: (Fixing “VLC is Unable to Open the MRL” Error [Quick Tip]) +[#]: via: (https://itsfoss.com/vlc-is-unable-to-open-the-mrl/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +修复 “VLC is Unable to Open the MRL” 错误 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/05/084139mzlt1lfivilnnbkl.jpg) + +一个使用 [VLC 的技巧][1]是使用 [VLC] [2] 播放 YouTube 和其他在线视频。这可以帮助你[观看带有字幕的在线视频][3]。 + +但是事情并不总是这么简单,因为有时使用 VLC 打开 YouTube 视频时会遇到此错误: + +> Your input can’t be opened: VLC is unable to open the MRL ''. Check the log for details. + +![VLC error while playing YouTube videos][4] + +这是因为 Google 不想让你使用任何第三方应用观看 YouTube,因为这样他们就无法正常收集数据。 + +因此,他们不断修改服务端,以使第三发开发更难与 Youtube 集成。 + +以 [youtube-dl][5] 为例。你会发现自己无法突然[下载 YouTube 视频] [6],最简单的方案是安装最新版本的 youtube-dl。 + +对于 VLC 也是如此。如果你[在 Ubuntu 或任何你用的系统中安装了最新的 VLC][7],那么可能不会看到此错误。 + +### 修复 “VLC is unable to open the MRL” 错误 + +让我向你展示对于 YouTube 的修复步骤。 + +进入 VLC 媒体播放器的官方 Github 仓库页面的[这个页面][8],并使用 `Ctrl+S` 保存文件: + +现在,你需要做的是用此下载文件替换 `lib/vlc/lua/playlist` 目录中的 `youtube.luac`(注意 luac 中的 “c”)。 + +#### Linux 中的步骤 + +如果你使用的是 Linux,请打开终端并使用 [locate 命令][9]查找 `youtube.luac` 文件的确切位置: + +``` +locate youtube.luac +``` + +当你得到文件的路径时,只需将该文件替换为下载的文件即可。我相信你可以完成这项简单的任务。 + +对我而言,以下是文件路径: + +``` +abhishek@itsfoss:~$ locate youtube.lua +/usr/lib/x86_64-linux-gnu/vlc/lua/playlist/youtube.luac +``` + +因此,我要做的就是将下载的文件移到该位置并替换它的内容: + +``` +sudo cp ~/Downloads/youtube.lua /usr/lib/x86_64-linux-gnu/vlc/lua/playlist/youtube.luac +``` + +你现在应该可以在 VLC 中播放 YouTube 视频了。 + +#### Windows 中的步骤 + +如果你使用的是 Windows,那么应遵循以下步骤: + + * 将下载的 `youtube.lua` 文件重命名为 `youtube.luac` + * 复制此文件并将其粘贴到 `C:\Program Files (x86)\VideoLAN\VLC\lua\playlist\` + +就是这些了。 + +如果你在 Dailymotion 或其他视频流网站上遇到问题,那么可以从 VLC 仓库的[此处][10]下载它们各自的 lua 文件,并替换 VLC 安装中的现有 lua 文件。 + +我希望这个快速提示可以解决 VLC 无法为你播放 YouTube 视频的问题。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/vlc-is-unable-to-open-the-mrl/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/simple-vlc-tips/ +[2]: https://www.videolan.org/index.html +[3]: https://itsfoss.com/penguin-subtitle-player/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/vlc_error_input_cant_be_played.png?ssl=1 +[5]: https://itsfoss.com/download-youtube-linux/ +[6]: https://itsfoss.com/download-youtube-videos-ubuntu/ +[7]: https://itsfoss.com/install-latest-vlc/ +[8]: https://raw.githubusercontent.com/videolan/vlc/master/share/lua/playlist/youtube.lua +[9]: https://linuxhandbook.com/locate-command/ +[10]: https://github.com/videolan/vlc/tree/master/share/lua/playlist diff --git a/published/202001/20191231 10 Ansible resources to accelerate your automation skills.md b/published/202001/20191231 10 Ansible resources to accelerate your automation skills.md new file mode 100644 index 0000000000..00d31b98a2 --- /dev/null +++ b/published/202001/20191231 10 Ansible resources to accelerate your automation skills.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (BrunoJu) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11760-1.html) +[#]: subject: (10 Ansible resources to accelerate your automation skills) +[#]: via: (https://opensource.com/article/19/12/ansible-resources) +[#]: author: (James Farrell https://opensource.com/users/jamesf) + +提升自动化技巧的 10 篇 Ansible 文章 +====== + +> 今年,准备好,用出色的 Ansible 自动化技能装备自己的技能包吧。 + +![](https://img.linux.net.cn/data/attachment/album/202001/07/231057fbtfjwrn29ficxj0.jpg) + +今年我关注了大量关于 Ansible 的文章,以下这些内容都值得每个人学习,无论是否是 Ansible 的新手。 + +这些文章值得大家标记为书签,或者设置个计划任务(亦或者是设置一个 Tower/AWX 任务),用来提醒自己常读常新。 + +如果你是 Ansible 的新手,那么就从这些文章开始着手吧: + +* 《[Ansible 快速入门指南][2]》拥有一些对新手非常有用的信息,同时还介绍了一些更高级的话题。 +* 《[你需要知道的 10 个 Ansible 模块][3]》和《[5 个 Ansible 运维任务][4]》(译文)这两篇文章有每一位 Ansible 管理员都应该熟悉并认真研习的一些最基础的 Ansible 功能。 +* 《[如何使用 Ansible 记录流程][5]》这篇文章是对一些额外话题的纵览,我猜你一定会感到很有趣。 + +剩余的这些文章包含了更多高级的话题,比如 Windows 管理、测试、硬件、云和容器,甚至包括了一个案例研究,如何管理那些对技术有兴趣的孩子的需求。 + +我希望你能像我一样好好享受 Ansible 带来的乐趣。不要停止学习哦! + +1. 《[Ansible 如何为我的家庭带来和平][6]》这个异想天开的案例,你能看到如何利用 Ansible 为孩子们快速部署一个新的笔记本(或者重装旧笔记本) +2. Taz Brown 和 Abner Malivert 的《[适用于 Windows 管理员的 Ansible][7]》:你知道 Ansible 也可以管理 Windows 的节点吗?这篇文章以部署一个 IIS 为案例,阐述了基础的 Ansible 服务器和 Windows 客户端的安装。 +3. Shashank Hegde 的《[你需要知道的 10 个 Ansible 模块][3]》是个学习你最应该知道的那些最常见、最基础的 Ansible 模块的好文章。运行命令、安装软件包和操作文件是许多有用的自动化工作的基础。 +4. Marco Bravo 的《[如何使用 Ansible 记录流程][5]》:Ansible 的 YAML 文件易于阅读,因此它们可以被用于记录完成任务所需的手动步骤。这一特性可以帮助你调试与扩展,这令工作变得异常轻松。同时,这篇文章还包含关于测试和分析等 Ansible 相关主题的指导。 +5. Clement Verna 的《[使用 Testinfra 和 Ansible 验证服务器状态][8]》(译文):测试环节是任何一个 CI/CD DevOps 流程不可或缺的一部分。所以为什么不把测试 Ansible 的运行结果也纳入其中呢?这个测试架构 Testinfra 的入门级文章可以帮助你检查配置结果。 +6. Mark Phillips 的《[Ansible 硬件起步][9]》:这个世界并不是完全已经被容器和虚拟机所占据。许多系统管理员仍然需要管理众多硬件资源。通过 Ansible 与一点 PXE、DHCP 以及其他技巧的结合,你可以创建一个方便的管理框架使硬件易于启动和运行。 +7. Jairo da Silva Junior 的《[你需要了解的关于 Ansible 模块的知识][10]》:模块给 Ansible 带来了巨大的潜力,已经有许多模块可以拿来利用。但如果没有你所需的模块,那你可以尝试给自己打造一个。看看这篇文章吧,它能让你了解如何从零开始打造自己所需的模块。 +8. Mark Phillips 的《[5 个 Ansible 运维任务][4]》(译文):这是另一个有关于如何使用 Ansible 来管理常见的系统操作任务的文章。这里描述了一系列可以取代命令行操作的 Tower(或 AWX)的案例。 +9. Chris Short 的《[Ansible 快速入门指南][2]》是个可以下载的 PDF 文档。它可以作为一本随时拿来翻阅的手册。这篇文章的开头有助于初学者入门。同时,还包括了一些其他的研究领域,比如模块测试、系统管理任务和针对 K8S 对象的管理。 +10. Mark Phillips 的《[Ansible 参考指南,带有 Ansible Tower 和 GitHub 的 CI/CD,等等][11]》:这是一篇每月进行总结更新的文章,充满了有趣的链接。话题包括了 Ansible 的基础内容、管理 Netapp 的 E 系列存储产品、调试、打补丁包和其他一些相关内容。文章中还包括了一些视频以及一些聚会的链接。请查看详情。 + +如果你也有一些你喜爱的 Ansible 文章,那请留言告诉我们吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/ansible-resources + +作者:[James Farrell][a] +选题:[lujun9972][b] +译者:[BrunoJu](https://github.com/BrunoJu) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chaos_engineer_monster_scary_devops_gear_kubernetes.png?itok=GPYLvfVh (Gears above purple clouds) +[2]: https://opensource.com/article/19/2/quickstart-guide-ansible +[3]: https://opensource.com/article/19/9/must-know-ansible-modules +[4]: https://linux.cn/article-11312-1.html +[5]: https://opensource.com/article/19/4/ansible-procedures +[6]: https://opensource.com/article/19/9/ansible-documentation-kids-laptops +[7]: https://opensource.com/article/19/2/ansible-windows-admin +[8]: https://linux.cn/article-10943-1.html +[9]: https://opensource.com/article/19/5/hardware-bootstrapping-ansible +[10]: https://opensource.com/article/19/3/developing-ansible-modules +[11]: https://opensource.com/article/19/7/ansible-news-edition-one diff --git a/published/202001/20191231 12 programming resources for coders of all levels.md b/published/202001/20191231 12 programming resources for coders of all levels.md new file mode 100644 index 0000000000..2e32ec2515 --- /dev/null +++ b/published/202001/20191231 12 programming resources for coders of all levels.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11751-1.html) +[#]: subject: (12 programming resources for coders of all levels) +[#]: via: (https://opensource.com/article/19/12/programming-resources) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny) + +12 个给全等级码农们的编程资源 +====== + +> 无论你身处编程旅程中的何处,这 12 篇编程文章都有你需要学习一些东西。 + +![](https://img.linux.net.cn/data/attachment/album/202001/05/102002cdjy66jucbcfs6dg.jpg) + +> “学习计算机编程的最佳时间是 20 年前,其次是现在。” +> — 计算机科学的谚语(也许是) + +无论你是新程序员、经验丰富的 Web 开发人员、后端大师、头发花白的系统程序员,还是其他神秘物种的计算机极客?无论你身处广阔的软件开发人员生态系统中的何处,在我们领域中唯一不变的就是需要了解新技术及其应用方法。这是过去一年来阅读量最大的 Opensource.com 文章的集合,我很高兴在这里与你分享它们。 + +### 好好学习 + +无论你的技能或兴趣是什么,学习如何编写计算机程序都可以将特定领域的知识变成一种超能力。不幸的是,至少从现在开始,还不可能通过坐在计算机前面接受电磁辐射就能学会如何编程。在这之前,我推荐这些出色的文章来帮助激发你的编程技能。它们解决了一些重要的问题,例如考虑学习哪种语言以及不同的入门方式。 + +* [你应该学习哪种编程语言?][2](译文) +* [学习 Python 的 12 个方式][3](译文) +* [你可以使用树莓派学习的三种流行编程语言][4](译文) +* [利用 Python 引导孩子的计算机思维][5](译文) + +### 天天向上 + +经验丰富的程序员知道,与学习编程相比,唯一更难的就是使你的技能和知识保持最新。但是我们是[自学成才][6]的一族,总是希望提高我们的专业知识和理解力。即使我们不期望使用新技术,我们也知道总会有人问起它们。这些有关 Rust、WebAssembly 和 Podman 的文章是开始学习软件技术一些即将出现的趋势的好地方。 + +* [为什么要在 WebAssembly 中使用 Rust?][7] +* [使用 WebAssembly 扩展命令行领域][8] +* [免 root 的 Podman 如何工作?][9] +* [为什么选择 Rust 作为你的下一种编程语言][10] + +### 老兵不死 + +尽管新技术层出不穷,但回顾过去可以帮助你前进。当今惊人的技术是建立在昨天的工具之上的,即使我们从未使用这些传奇语言编写过代码,它也将使我们很好地理解这些工具的功能和局限性。这一系列文章集中于 C 语言、用 AWK 编写的实际应用程序,以及对流行度下降但也许还没有消亡的计算机语言的有趣讨论。 + +* [C 的巨大影响] [11] +* [如何写好 C main 函数][12](译文) +* [用 AWK 喝咖啡][13](译文) +* [你最喜欢的“死”语言是什么?][14] + +### 学习不止 + +无论你在编程过程中处于何处,总有更多东西需要学习。我希望这些来自 2019 年的顶级资源能帮助你为 2020 年做好准备。感谢作者们和你——读者。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/programming-resources + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjny +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_3.png?itok=qw2A18BM (Woman sitting in front of her computer) +[2]: https://linux.cn/article-10769-1.html +[3]: https://linux.cn/article-11280-1.html +[4]: https://linux.cn/article-10661-1.html +[5]: https://linux.cn/article-11116-1.html +[6]: https://en.wikipedia.org/wiki/Autodidacticism +[7]: https://opensource.com/article/19/2/why-use-rust-webassembly +[8]: https://opensource.com/article/19/4/command-line-playgrounds-webassembly +[9]: https://opensource.com/article/19/2/how-does-rootless-podman-work +[10]: https://opensource.com/article/19/10/choose-rust-programming-language +[11]: https://opensource.com/article/19/10/command-line-heroes-c +[12]: https://linux.cn/article-10949-1.html +[13]: https://linux.cn/article-10555-1.html +[14]: https://opensource.com/article/19/6/favorite-dead-language diff --git a/published/202001/20200101 5 predictions for Kubernetes in 2020.md b/published/202001/20200101 5 predictions for Kubernetes in 2020.md new file mode 100644 index 0000000000..2ad58abd67 --- /dev/null +++ b/published/202001/20200101 5 predictions for Kubernetes in 2020.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11758-1.html) +[#]: subject: (5 predictions for Kubernetes in 2020) +[#]: via: (https://opensource.com/article/20/1/kubernetes-2020) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux) + +2020 年对 Kubernetes 的 5 个预测 +====== + +> 以及,对 2019 年最受欢迎的 Kubernetes 文章的回顾。 + +![](https://img.linux.net.cn/data/attachment/album/202001/07/094358qucr5o2lu2lo23od.jpg) + +你是怎么追踪一个广受欢迎的项目(如 Kubernetes)的发展轨迹?你是怎么了解它发展到什么程度了?如果你在为这个项目作贡献或加入了特殊兴趣组(SIG),可能你会在潜移默化中了解到它的发展轨迹,但如果你的全日工作不涉及到为 Kubernetes 作贡献,那么你可能需要一点关于未来的预测来帮助你了解。对于一个诸如 Kubernetes 的快速发展的项目,年末是回顾过去的一年和展望新的一年的最好时机。 + +今年,Kubernetes 取得了很大的进展。除了去查看源码、文档、会议笔记,你也可以去浏览博客。为了深入了解,我在 Opensource.com 上找到了 Kubernetes 排名前十的文章。通过这些文章,我们能了解开发者们更喜欢读和写哪些话题的文章。我们开始吧! + +- [为什么数据科学家喜欢Kubernetes][13] +- [Kubernetes 机密信息和 ConfigMap 简介][14] +- [怎样在 Kubernetes 上运行 PostgreSQL][15](译文) +- [为什么说 Kubernetes 是一辆翻斗车][16](译文) +- [安全扫描你的 DevOps 流程][17] +- [在 Kubernetes 上部署 InfluxDB 和 Grafana 以收集 Twitter 统计信息][18] +- [使用 Kubernetes 操作器扩展 PostgreSQL][19] +- [使用 Kubernetes 控制器减少系统管理员的工作量][20] +- [将 Kubernetes 带到裸金属边缘计算][21] +- [为什么你不必担心 Kubernetes][22] + +首先,我要指明这些文章中有 5 篇是关于 Kubernetes 工作负载的扩展以及它们可以运行在什么场景。这些工作负载涵盖数据科学、PostgreSQL、InfluxDB、Grafana(不仅仅监控集群本身)和边缘计算。从历史角度看,Kubernetes 和容器都是在虚拟机上运行的,尤其是运行在由云提供的基础设施上时。抛开对于 Kubernetes 的兴趣因素,这也表明了终端用户们极度希望在裸机上安装 Kubernetes(参照 [用 OpenShift 在裸机环境运行 Kubernetes][2])。 + +其次,也有很多开发者希望了解操作相关的知识以及 Kubernetes 的最佳实践。从 [Kubernetes 操作器][3] 到 [Kubernetes 控制器][4],从 [机密信息][5] 到 [ConfigMaps][6],开发者和运维人员都希望能找到简化部署和管理工作的最佳实践。我们经常纠结在怎么去修改配置文件或别人会怎么配置,而不去回头想想这些配置是怎么让应用部署运转的(不是怎么安装,也不是怎么运行 Kubernetes)。 + +最后,人们似乎对入门教程真的感兴趣。事实上,构建 Kubernetes 所需了解的信息太多了,以至于让人们望而却步,也使他们走了错误的路。流行度高的文章中有几篇讲述了为什么你需要了解用 Kubernetes 运行应用程序,而不仅仅是安装它。就像最佳实践类的文章一样,人们也通常不会回头分析在入门时他们应该在什么地方花费时间。我一直秉持的理念是,把有限的时间和金钱投入到如何使用某项技术上,而不是如何构建它。 + +### 2020 年对 Kubernetes 的 5 个预测 + +回顾了 2019 年的相关主题,这些主题告诉我们 2020 年将如何发展?结合这些文章中的观点,加上我自己的看法,我来分享下我对于 2020 年以及未来发展趋势的想法: + +1. 工作负载扩展。我会关注高性能计算、AI/ML 以及使用操作器的有状态工作负载。 +2. 更多的生产中的最佳实践,尤其是跟一些成熟的标准相关的,像 PCI、HIPAA、NIST 等等。 +3. 提升免 root 和更安全的[运行时类][7](如 [gVisor][8]、[Kata Containers][9] 等等)的安全性。 +4. 在部署和开发者们共享应用时,把 Kubernetes 清单的更好的规范标准作为部署的核心要素。如 [podman 生成 kube][10]、[podman 运行 kube][11],还有多合一 Kubernetes 环境,如 [CodeReady Containers (CRC)][12] +5. 一个前所未有的网络、存储和专业硬件(如 GPU 等等)供应商的生态系统,为 Kubernetes 提供 BoB(LCTT 译注:best of breed,单项最佳品牌)解决方案(在自由软件中,我们相信开放的生态系统好过垂直整合的解决方案)。 + +期待 Kubernetes 在新的一年里再创辉煌! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/kubernetes-2020 + +作者:[Scott McCarty][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer) +[2]: https://blog.openshift.com/kubernetes-on-metal-with-openshift/ +[3]: https://kubernetes.io/docs/concepts/extend-kubernetes/operator/ +[4]: https://kubernetes.io/docs/concepts/architecture/controller/ +[5]: https://kubernetes.io/docs/concepts/configuration/secret/ +[6]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/ +[7]: https://kubernetes.io/docs/concepts/containers/runtime-class/ +[8]: https://gvisor.dev/ +[9]: https://katacontainers.io/ +[10]: https://developers.redhat.com/blog/2019/01/29/podman-kubernetes-yaml/ +[11]: https://www.redhat.com/en/blog/rhel-81-minor-release-major-new-container-capabilities +[12]: https://developers.redhat.com/products/codeready-containers/overview +[13]: https://opensource.com/article/19/1/why-data-scientists-love-kubernetes +[14]: https://opensource.com/article/19/6/introduction-kubernetes-secrets-and-configmaps +[15]: https://linux.cn/article-10762-1.html +[16]: https://linux.cn/article-11011-1.html +[17]: https://opensource.com/article/19/7/security-scanning-your-devops-pipeline +[18]: https://opensource.com/article/19/2/deploy-influxdb-grafana-kubernetes +[19]: https://opensource.com/article/19/2/scaling-postgresql-kubernetes-operators +[20]: https://opensource.com/article/19/3/reducing-sysadmin-toil-kubernetes-controllers +[21]: https://opensource.com/article/19/3/bringing-kubernetes-bare-metal-edge +[22]: https://opensource.com/article/19/10/kubernetes-complex-business-problem diff --git a/published/202001/20200101 9 cheat sheets and guides to enhance your tech skills.md b/published/202001/20200101 9 cheat sheets and guides to enhance your tech skills.md new file mode 100644 index 0000000000..966b7aee3a --- /dev/null +++ b/published/202001/20200101 9 cheat sheets and guides to enhance your tech skills.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (nacyro) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11753-1.html) +[#]: subject: (9 cheat sheets and guides to enhance your tech skills) +[#]: via: (https://opensource.com/article/20/1/cheat-sheets-guides) +[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett) + +九个提升程序员技术技能的备忘单和指南 +====== + +> 用我们最新的编程备忘单和指南来为新年开局,它适合所有技能水平的人。 + +![](https://img.linux.net.cn/data/attachment/album/202001/05/233115etzm6hv4a3z5yvhg.jpg) + +对刚接触命令行的新程序员来说备忘单是完美的。然而,即便是最有经验的程序员也需要时不时地依靠参考资料。假如你刚好敲不出那个讨厌的快捷键,那么手边有个备忘单就很赞了。这是一份我们可供下载指南的综述,它将助你在 2020 年取得成功。 + +### 备忘单 + +#### Markdown + +[Markdown][2] 不仅针对程序员,任何人都可以借助它为纯文本文档增添语法和结构。此备忘单提供了使用 CommonMark 规范的 Markdown 基础要点。它还包括 GitHub 和 GitLab 的语法。 + +#### Linux 权限和用户 + +用这个 Linux 备忘单把[用户管理][3]命令放在手边。快速学习如何增删用户、查看历史以及设置权限。 + +#### Bash + +一旦你了解了 [Bash][4],在命令行中就蕴含了无限可能。我们的 Bash 备忘单可以帮助你更有效地使用键盘快捷键。不知不觉间,你就能在睡眠中(字面意义上)运行脚本。 + +#### Linux 常用命令 + +毫不奇怪,我们的 [Linux 常用命令备忘单][5]是如此受欢迎。这个备忘单包含了开始安装软件和导览文件系统的要点。为自己和你的同事打印出来吧。 + +#### 微服务 + +似乎每个人都在谈论[微服务][6],而且理由很充分。微服务使应用程序模块化,因此更容易构建和维护。它不再只是这个备忘单上的流行语。在[微服务开源指南][7]中了解重要的术语并学习更多关于微服务的基础知识。 + +#### Java + +此备忘单非常适合初级和中级 [Java][8] 程序员。它包括重要的上下文以及处理导入、变量、类等的代码。 + +#### pip + +程序员爱用 [pip][9] 命令来帮助安装、管理和使用 Python 软件包。然而,pip 可以做的远不止这些。这个备忘单将教你如何构建 wheels 和 record 包。 + +### 指南 + +#### 七个不可或缺的 PyPI 库 + +[这组 Python 教程][10]将帮助你学习如何更快地编写扩展、格式化代码、自动化测试、确保代码一致性,以及更多使用 PyPI 库的方法。 + +#### 开始学习 Kubernetes + +在这份平易近人的[指南][11]中,作者 Scott McCarty 用了一个出人意料的类比来解释 Kubernetes 的价值和上手步骤。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/cheat-sheets-guides + +作者:[Lauren Pritchett][a] +选题:[lujun9972][b] +译者:[nacyro](https://github.com/nacyro) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lauren-pritchett +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk (a checklist for a team) +[2]: https://opensource.com/downloads/cheat-sheet-markdown +[3]: https://opensource.com/downloads/linux-permissions-cheat-sheet +[4]: https://opensource.com/downloads/bash-cheat-sheet +[5]: https://opensource.com/downloads/linux-common-commands-cheat-sheet +[6]: https://opensource.com/downloads/microservices-cheat-sheet +[7]: https://opensource.com/article/19/11/microservices-cheat-sheet +[8]: https://opensource.com/downloads/java-cheat-sheet +[9]: https://opensource.com/downloads/pip-cheat-sheet +[10]: https://opensource.com/downloads/7-essential-pypi-libraries +[11]: https://opensource.com/downloads/getting-started-kubernetes-ebook +[12]: https://opensource.com/users/fatherlinux +[13]: https://opensource.com/downloads/cheat-sheets +[14]: https://opensource.com/email-newsletter diff --git a/published/202001/20200101 Signal- A Secure, Open Source Messaging App.md b/published/202001/20200101 Signal- A Secure, Open Source Messaging App.md new file mode 100644 index 0000000000..4248470b90 --- /dev/null +++ b/published/202001/20200101 Signal- A Secure, Open Source Messaging App.md @@ -0,0 +1,122 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11764-1.html) +[#]: subject: (Signal: A Secure, Open Source Messaging App) +[#]: via: (https://itsfoss.com/signal-messaging-app/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Signal:安全、开源的聊天应用 +====== + +> Signal 是一款智能手机上的安全开源聊天应用。它还提供了适用于 Linux、Windows 和 macOS 的独立桌面应用。在本文中,我们来看看它的功能和可用性。 + +### 对于关注隐私的人来说,Signal 是 WhatsApp(和 Telegram)的绝佳替代品 + +![Signal App On Linux][1] + +Signal 是一款关注隐私的开源应用。像[爱德华·斯诺登][2]这样的隐私权倡导者建议使用它。 + +它可能没有 Telegram 或 WhatsApp 这么多的功能。但是,如果你想在交流时增强隐私,这是一个可靠的开源方案。 + +你可以在智能手机([iOS][3]/[Android][4])上安装,也可以在 Linux、Windows 和 macOS 上安装。 + +### Signal 的功能 + +**注意:** 某些功能是智能手机特有的。你可能无法在桌面应用上看到所有功能。 + +另请注意,目前,Signal 需要电话号码才能注册。如果你不想公开自己的私人电话号码,则可以使用 Google 语音或类似服务。 + +正如我已经提到的,这是为增强你的隐私而量身定制的。因此,用户体验可能不是你见过“最佳”的。但是,从隐私/安全角度考虑,我认为这是一个不错的选择。 + +![Signal Features][5] + +#### 消失的消息 + +你可以为对话中的消息设置一个计时器,以便根据它自动删除消息。 + +本质上,对话中的任何人都可以激活此功能。因此,你可以控制对话中的消息时保留还是消失。 + +#### 用作默认短信应用 + +如果你想在短信中使用开源应用,那么只需进入 Signal 的设置,并将其设置为短信和彩信的默认设置。 + +#### 屏幕安全 + +有一个巧妙的功能可以阻止应用内截图,它就是“屏幕安全”。 + +如果你开启它,那么你将无法为应用中的任何对话截图。你可以从应用设置中找到启用或禁用它的选项。 + +它可能并不是对所有人有用,但你可以尝试一下。 + +#### 安全数字 + +如果你想与朋友一起验证加密的安全性,只需点击个人资料并向下滚动找到“查看安全数字”。 + +你可以扫描验证或者看一眼并标记为已验证。 + +#### 锁定消息 + +如果你使用了锁(密码/指纹)来保护应用,那么即使你的设备已解锁,你也无法在通知中看到消息。 + +因此,当 Signal 处于锁定状态收到通知时,你会注意到通知的内容为 “**Locked Message**”,这对于注重隐私的用户来说是一个加分项。 + +#### 其它功能 + +![][6] + +如你所期待的聊天应用,你可以使用几个标签,并且可以根据需要创建一个组。但是,你无法管理你的组,你只能添加成员和更改群头像。 + +此外,Signal 还为其应用支持生物识别。 + +### 在 Ubuntu/Linux 上安装 Signal + +不幸的是,你无法在你的 Linux 发行版上找到 .deb 或者 .AppImage。因此,你需要根据[官方安装说明][7]在终端上安装。 + +在终端中输入以下内容: + +``` +curl -s https://updates.signal.org/desktop/apt/keys.asc | sudo apt-key add - +echo "deb [arch=amd64] https://updates.signal.org/desktop/apt xenial main" | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list +sudo apt update && sudo apt install signal-desktop +``` + +只需在终端中一个接一个地复制并粘贴命令。 + +[Download Signal for Other Devices][7] + +### 我对 Signal 的想法 + +我已经使用 Signal 有几年了,它的功能已经得到了改善。但是,我仍然认为可以改善用户体验。 + +在隐私方面,(在我看来)这绝对是我们已有软件的一个很好的替代方案。你可以尝试一下,看看它的使用效果如何。 + +如果你想尝试一下它,也可以看看它的 [GitHub 页面][8]以获取最新的开发和 beta 版本。 + +与 WhatsApp 甚至 [Linux 上的 Telegram][9] 相比,Signal 可能不是流行的聊天应用。但是,你可以自己尝试一下,并鼓励你的朋友使用它。 + +你尝试过了吗?在下面的评论中,让我知道你对 “Signal” 的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/signal-messaging-app/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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/signal-shot.jpg?ssl=1 +[2]: https://en.wikipedia.org/wiki/Edward_Snowden +[3]: https://apps.apple.com/us/app/signal-private-messenger/id874139669 +[4]: https://play.google.com/store/apps/details?id=org.thoughtcrime.securesms&hl=en_IN +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/signal-phone.jpg?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/12/signal-shot-1.jpg?ssl=1 +[7]: https://signal.org/download/ +[8]: https://github.com/signalapp +[9]: https://itsfoss.com/install-telegram-desktop-linux/ diff --git a/published/202001/20200102 Put some loot in your Python platformer game.md b/published/202001/20200102 Put some loot in your Python platformer game.md new file mode 100644 index 0000000000..e379cc1307 --- /dev/null +++ b/published/202001/20200102 Put some loot in your Python platformer game.md @@ -0,0 +1,525 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11828-1.html) +[#]: subject: (Put some loot in your Python platformer game) +[#]: via: (https://opensource.com/article/20/1/loot-python-platformer-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在你的 Python 平台类游戏中放一些奖励 +====== + +> 这部分是关于在使用 Python 的 Pygame 模块开发的视频游戏总给你的玩家提供收集的宝物和经验值的内容。 + +![](https://img.linux.net.cn/data/attachment/album/202001/29/131158jkwnhgd1nnawzn86.jpg) + +这是正在进行的关于使用 [Python 3][2] 的 [Pygame][3] 模块创建视频游戏的系列文章的第十部分。以前的文章有: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][4] + * [使用 Python 和 Pygame 模块构建一个游戏框架][5] + * [如何在你的 Python 游戏中添加一个玩家][6] + * [用 Pygame 使你的游戏角色移动起来][7] + * [如何向你的 Python 游戏中添加一个敌人][8] + * [在 Pygame 游戏中放置平台][13] + * [在你的 Python 游戏中模拟引力][9] + * [为你的 Python 平台类游戏添加跳跃功能][10] + * [使你的 Python 游戏玩家能够向前和向后跑][11] + +如果你已经阅读了本系列的前几篇文章,那么你已经了解了编写游戏的所有基础知识。现在你可以在这些基础上,创造一个全功能的游戏。当你第一次学习时,遵循本系列代码示例,这样的“用例”是有帮助的,但是,用例也会约束你。现在是时候运用你学到的知识,以新的方式应用它们了。 + +如果说,说起来容易做起来难,这篇文章展示了一个如何将你已经了解的内容用于新目的的例子中。具体来说,就是它涵盖了如何使用你以前的课程中已经了解到的来实现奖励系统。 + +在大多数电子游戏中,你有机会在游戏世界中获得“奖励”或收集到宝物和其他物品。奖励通常会增加你的分数或者你的生命值,或者为你的下一次任务提供信息。 + +游戏中包含的奖励类似于编程平台。像平台一样,奖励没有用户控制,随着游戏世界的滚动进行,并且必须检查与玩家的碰撞。 + +### 创建奖励函数 + +奖励和平台非常相似,你甚至不需要一个奖励的类。你可以重用 `Platform` 类,并将结果称为“奖励”。 + +由于奖励类型和位置可能因关卡不同而不同,如果你还没有,请在你的 `Level` 中创建一个名为 `loot` 的新函数。因为奖励物品不是平台,你也必须创建一个新的 `loot_list` 组,然后添加奖励物品。与平台、地面和敌人一样,该组用于检查玩家碰撞: + +``` + def loot(lvl,lloc): + if lvl == 1: + loot_list = pygame.sprite.Group() + loot = Platform(300,ty*7,tx,ty, 'loot_1.png') + loot_list.add(loot) + + if lvl == 2: + print(lvl) + + return loot_list +``` + +你可以随意添加任意数量的奖励对象;记住把每一个都加到你的奖励清单上。`Platform` 类的参数是奖励图标的 X 位置、Y 位置、宽度和高度(通常让你的奖励精灵保持和所有其他方块一样的大小最为简单),以及你想要用作的奖励的图片。奖励的放置可以和贴图平台一样复杂,所以使用创建关卡时需要的关卡设计文档。 + +在脚本的设置部分调用新的奖励函数。在下面的代码中,前三行是上下文,所以只需添加第四行: + +``` +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) +loot_list = Level.loot(1,tx,ty) +``` + +正如你现在所知道的,除非你把它包含在你的主循环中,否则奖励不会被显示到屏幕上。将下面代码示例的最后一行添加到循环中: + +``` +    enemy_list.draw(world) +    ground_list.draw(world) +    plat_list.draw(world) +    loot_list.draw(world) +``` + +启动你的游戏看看会发生什么。 + +![Loot in Python platformer][12] + +你的奖励将会显示出来,但是当你的玩家碰到它们时,它们不会做任何事情,当你的玩家经过它们时,它们也不会滚动。接下来解决这些问题。 + +### 滚动奖励 + +像平台一样,当玩家在游戏世界中移动时,奖励必须滚动。逻辑与平台滚动相同。要向前滚动奖励物品,添加最后两行: + +``` +        for e in enemy_list: +            e.rect.x -= scroll +        for l in loot_list: +            l.rect.x -= scroll +``` + +要向后滚动,请添加最后两行: + +``` +        for e in enemy_list: +            e.rect.x += scroll +        for l in loot_list: +            l.rect.x += scroll +``` + +再次启动你的游戏,看看你的奖励物品现在表现得像在游戏世界里一样了,而不是仅仅画在上面。 + +### 检测碰撞 + +就像平台和敌人一样,你可以检查奖励物品和玩家之间的碰撞。逻辑与其他碰撞相同,除了撞击不会(必然)影响重力或生命值。取而代之的是,命中会导致奖励物品会消失并增加玩家的分数。 + +当你的玩家触摸到一个奖励对象时,你可以从 `loot_list` 中移除该对象。这意味着当你的主循环在 `loot_list` 中重绘所有奖励物品时,它不会重绘那个特定的对象,所以看起来玩家已经获得了奖励物品。 + +在 `Player` 类的 `update` 函数中的平台碰撞检测之上添加以下代码(最后一行仅用于上下文): + +``` +                loot_hit_list = pygame.sprite.spritecollide(self, loot_list, False) +                for loot in loot_hit_list: +                        loot_list.remove(loot) +                        self.score += 1 +                print(self.score) +  +        plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) +``` + +当碰撞发生时,你不仅要把奖励从它的组中移除,还要给你的玩家一个分数提升。你还没有创建分数变量,所以请将它添加到你的玩家属性中,该属性是在 `Player` 类的 `__init__` 函数中创建的。在下面的代码中,前两行是上下文,所以只需添加分数变量: + +``` +        self.frame = 0 +        self.health = 10 +        self.score = 0 +``` + +当在主循环中调用 `update` 函数时,需要包括 `loot_list`: + +``` +        player.gravity() +        player.update() +``` + +如你所见,你已经掌握了所有的基本知识。你现在要做的就是用新的方式使用你所知道的。 + +在下一篇文章中还有一些提示,但是与此同时,用你学到的知识来制作一些简单的单关卡游戏。限制你试图创造的东西的范围是很重要的,这样你就不会埋没自己。这也使得最终的成品看起来和感觉上更容易完成。 + +以下是迄今为止你为这个 Python 平台编写的所有代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping +# add scrolling + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.collide_delta = 0 + self.jump_delta = 6 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def jump(self,platform_list): + self.jump_delta = 0 + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + for enemy in enemy_hit_list: + self.health -= 1 + #print(self.health) + + loot_hit_list = pygame.sprite.spritecollide(self, loot_list, False) + for loot in loot_hit_list: + loot_list.remove(loot) + self.score += 1 + print(self.score) + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.collide_delta = 0 # stop jumping + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.movey = 0 + self.rect.y = worldy-ty-ty + self.collide_delta = 0 # stop jumping + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) + + if self.collide_delta < 6 and self.jump_delta < 6: + self.jump_delta = 6*2 + self.movey -= 33 # how high to jump + self.collide_delta += 6 + self.jump_delta += 6 + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + self.movey = 0 + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + self.movey += 3.2 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + + if not self.rect.y >= worldy-ty-ty: + self.rect.y += self.movey + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.rect.y = worldy-ty-ty + + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,tx,ty): + if lvl == 1: + loot_list = pygame.sprite.Group() + loot = Platform(200,ty*7,tx,ty, 'loot_1.png') + loot_list.add(loot) + + if lvl == 2: + print(lvl) + + return loot_list + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((20,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 +forwardx = 600 +backwardx = 230 + +eloc = [] +eloc = [200,20] +gloc = [] +#gloc = [0,630,64,630,128,630,192,630,256,630,320,630,384,630] +tx = 64 #tile size +ty = 64 #tile size + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) +loot_list = Level.loot(1,tx,ty) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + player.jump(plat_list) + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + # scroll the world forward + if player.rect.x >= forwardx: + scroll = player.rect.x - forwardx + player.rect.x = forwardx + for p in plat_list: + p.rect.x -= scroll + for e in enemy_list: + e.rect.x -= scroll + for l in loot_list: + l.rect.x -= scroll + + # scroll the world backward + if player.rect.x <= backwardx: + scroll = backwardx - player.rect.x + player.rect.x = backwardx + for p in plat_list: + p.rect.x += scroll + for e in enemy_list: + e.rect.x += scroll + for l in loot_list: + l.rect.x += scroll + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) #refresh player position + enemy_list.draw(world) # refresh enemies + ground_list.draw(world) # refresh enemies + plat_list.draw(world) # refresh platforms + loot_list.draw(world) # refresh loot + + for e in enemy_list: + e.move() + pygame.display.flip() + clock.tick(fps) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/loot-python-platformer-game + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_lovemoneyglory2.png?itok=AvneLxFp (Hearts, stars, and dollar signs) +[2]: https://www.python.org/ +[3]: https://www.pygame.org/news +[4]: https://linux.cn/article-9071-1.html +[5]: https://linux.cn/article-10850-1.html +[6]: https://linux.cn/article-10858-1.html +[7]: https://linux.cn/article-10874-1.html +[8]: https://linux.cn/article-10883-1.html +[9]: https://linux.cn/article-11780-1.html +[10]: https://linux.cn/article-11790-1.html +[11]: https://linux.cn/article-11819-1.html +[12]: https://opensource.com/sites/default/files/uploads/pygame-loot.jpg (Loot in Python platformer) +[13]: https://linux.cn/article-10902-1.html diff --git a/published/202001/20200103 GNOME has a Secret- Screen Recorder. Here-s How to Use it.md b/published/202001/20200103 GNOME has a Secret- Screen Recorder. Here-s How to Use it.md new file mode 100644 index 0000000000..87e445c9b0 --- /dev/null +++ b/published/202001/20200103 GNOME has a Secret- Screen Recorder. Here-s How to Use it.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11766-1.html) +[#]: subject: (GNOME has a ‘Secret’ Screen Recorder. Here’s How to Use it!) +[#]: via: (https://itsfoss.com/gnome-screen-recorder/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +GNOME 有一个“隐藏”的屏幕录像机 +====== + +[GNOME][1] 是[最受欢迎的桌面环境][2]之一。它有现代的 UI,并且带有许多特定于 GNOME 的应用,这些应用与桌面整体外观完美融合。 + +你可以根据自己的喜好来[调整 GNOME][3],但我不在这里讨论。GNOME 桌面有一些你可能不知道的隐藏功能。 + +这种不太显眼的功能之一是内置的屏幕录像机。 + +是的,你没有看错。如果你使用的是 GNOME 桌面,那么不必安装其他的 [Linux 屏幕录像机][4]。你只需要知道正确的快捷键即可。 + +### 立即使用 GNOME 屏幕录像机录制屏幕 + +要快速打开 GNOME 屏幕录像机,你需要[在 Ubuntu 或其他带有 GNOME 桌面的发行版中按下此快捷键][5]: + +``` +Ctrl + Alt + Shift + R +``` + +这将会立即开始录制你的桌面。你可以通过顶部的系统托盘区域的红点了解到正在录制: + +![The red dot in the system tray area indicates that screen recording is in progress][6] + +#### 增加录制时间 + +默认的最大录制时间仅为 30 秒。但是可以增加。 + +打开终端并使用以下命令: + +``` +gsettings set org.gnome.settings-daemon.plugins.media-keys max-screencast-length 300 +``` + +在上面的命令中,我将录音的最大长度增加到 300 秒(即 5 分钟)。你可以将其更改为任何其它值,但应以秒为单位。 + +如果你**不希望最长录音时间有任何限制,请将其设置为 `0`**,之后它会在你手动停止或者磁盘空间不足才会停止。 + +#### 停止屏幕录制 + +如前所述,你的桌面录制将在达到最大时间限制后自动停止。 + +要在此之前停止录制,你可以按下相同的组合键: + +``` +Ctrl + Alt + Shift + R +``` + +你的录制内容将以 [webm][7] 格式保存在家目录的 `Videos` 文件夹中。 + +#### 局限性 + +尽管使用这个小工具可以方便地快速录制桌面,但是与功能强大的 [Simple Screen Recorder][8] 这样的屏幕录制工具相比,它有一些局限性。 + +* 录制开始之前没有时间延迟选项 +* 没有暂停和播放选项 +* 它录制整个屏幕。无法仅录制应用窗口、特定区域或特定屏幕(如果你有多个屏幕)。 +* 视频以 webm 格式保存在用户的 `Videos` 目录中。你无法更改。你必须使用 [HandBrake 之类的工具将视频转换为其他格式][9]。 + +如你所见,这个秘密的 GNOME 屏幕录像机与 [Kazam][10] 之类的工具或其他此类工具所提供的功能相差很远。但是,它并不会尝试成为全功能的屏幕录像机。它只是为你提供录制屏幕的快速方法。 + +GNOME 是一个多功能的现代桌面环境。你可以大量地[调整 GNOME][3]。[GNOME 扩展][11]为桌面自定义提供了另一个维度。 + +该屏幕录像机是 GNOME 的隐藏功能之一,就像你自己很难轻易找到的挂起选项。 + +你喜欢它吗?你是否还想与我们分享其他隐藏的 GNOME 功能?请在评论区留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gnome-screen-recorder/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://gnome.org/ +[2]: https://itsfoss.com/best-linux-desktop-environments/ +[3]: https://itsfoss.com/gnome-tweak-tool/ +[4]: https://itsfoss.com/best-linux-screen-recorders/ +[5]: https://itsfoss.com/ubuntu-shortcuts/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/gnome_screen_recording.jpg?ssl=1 +[7]: https://www.webmproject.org/about/ +[8]: https://itsfoss.com/record-screen-ubuntu-simplescreenrecorder/ +[9]: https://itsfoss.com/handbrake/ +[10]: https://itsfoss.com/kazam-screen-recorder/ +[11]: https://itsfoss.com/best-gnome-extensions/ diff --git a/published/202001/20200103 Introducing the guide to inter-process communication in Linux.md b/published/202001/20200103 Introducing the guide to inter-process communication in Linux.md new file mode 100644 index 0000000000..91a1f7821b --- /dev/null +++ b/published/202001/20200103 Introducing the guide to inter-process communication in Linux.md @@ -0,0 +1,168 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11832-1.html) +[#]: subject: (Introducing the guide to inter-process communication in Linux) +[#]: via: (https://opensource.com/article/20/1/inter-process-communication-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +免费电子书《Linux 进程间通信指南》介绍 +====== + +> 这本免费的电子书使经验丰富的程序员更深入了解 Linux 中进程间通信(IPC)的核心概念和机制。 + +![](https://img.linux.net.cn/data/attachment/album/202001/30/115631jthl0h61zhhmwpv1.jpeg) + +让一个软件过程与另一个软件过程进行对话是一个微妙的平衡行为。但是,它对于应用程序而言可能是至关重要的功能,因此这是任何从事复杂项目的程序员都必须解决的问题。你的应用程序是否需要启动由其它软件处理的工作;监视外设或网络上正在执行的操作;或者检测来自其它来源的信号,当你的软件需要依赖其自身代码之外的东西来知道下一步做什么或什么时候做时,你就需要考虑进程间通信inter-process communication(IPC)。 + +这在 Unix 操作系统上已经由来已久了,这可能是因为人们早期预期软件会来自各种来源。按照相同的传统,Linux 提供了一些同样的 IPC 接口和一些新接口。Linux 内核具有多种 IPC 方法,[util-linux 包][2]包含了 `ipcmk`、`ipcrm`、`ipcs` 和 `lsipc` 命令,用于监视和管理 IPC 消息。 + +### 显示进程间通信信息 + +在尝试 IPC 之前,你应该知道系统上已经有哪些 IPC 设施。`lsipc` 命令提供了该信息。 + +``` +RESOURCE DESCRIPTION LIMIT USED USE% +MSGMNI Number of message queues 32000 0 0.00% +MSGMAX Max size of message (byt.. 8192 - - +MSGMNB Default max size of queue 16384 - - +SHMMNI Shared memory segments 4096 79 1.93% +SHMALL Shared memory pages 184[...] 25452 0.00% +SHMMAX Max size of shared memory 18446744073692774399 +SHMMIN Min size of shared memory 1 - - +SEMMNI Number of semaphore ident 32000 0 0.00% +SEMMNS Total number of semaphore 1024000.. 0 0.00% +SEMMSL Max semaphores per semap 32000 - - +SEMOPM Max number of operations p 500 - - +SEMVMX Semaphore max value 32767 - - +``` + +你可能注意到,这个示例清单包含三种不同类型的 IPC 机制,每种机制在 Linux 内核中都是可用的:消息(MSG)、共享内存(SHM)和信号量(SEM)。你可以用 `ipcs` 命令查看每个子系统的当前活动: + +``` +$ ipcs + +------ Message Queues Creators/Owners --- +msqid perms cuid cgid [...] + +------ Shared Memory Segment Creators/Owners +shmid perms cuid cgid [...] +557056 700 seth users [...] +3571713 700 seth users [...] +2654210 600 seth users [...] +2457603 700 seth users [...] + +------ Semaphore Arrays Creators/Owners --- +semid perms cuid cgid [...] +``` + +这表明当前没有消息或信号量阵列,但是使用了一些共享内存段。 + +你可以在系统上执行一个简单的示例,这样就可以看到正在工作的系统之一。它涉及到一些 C 代码,所以你必须在系统上有构建工具。必须安装这些软件包才能从源代码构建软件,这些软件包的名称取决于发行版,因此请参考文档以获取详细信息。例如,在基于 Debian 的发行版上,你可以在 wiki 的[构建教程][3]部分了解构建需求,而在基于 Fedora 的发行版上,你可以参考该文档的[从源代码安装软件][4]部分。 + +### 创建一个消息队列 + +你的系统已经有一个默认的消息队列,但是你可以使用 `ipcmk` 命令创建你自己的消息队列: + +``` +$ ipcmk --queue +Message queue id: 32764 +``` + +编写一个简单的 IPC 消息发送器,为了简单,在队列 ID 中硬编码: + +``` +#include +#include +#include +#include + +struct msgbuffer { + char text[24]; +} message; + +int main() { + int msqid = 32764; + strcpy(message.text,"opensource.com"); + msgsnd(msqid, &message, sizeof(message), 0); + printf("Message: %s\n",message.text); + printf("Queue: %d\n",msqid); + return 0; + } +``` + +编译该应用程序并运行: + +``` +$ gcc msgsend.c -o msg.bin +$ ./msg.bin +Message: opensource.com +Queue: 32769 +``` + +你刚刚向你的消息队列发送了一条消息。你可以使用 `ipcs` 命令验证这一点,可以使用 `——queue` 选项将输出限制到该消息队列: + +``` +$ ipcs -q + +------ Message Queues -------- +key msqid owner perms used-bytes messages +0x7b341ab9 0 seth 666 0 0 +0x72bd8410 32764 seth 644 24 1 +``` + +你也可以检索这些消息: + +``` +#include +#include +#include + +struct msgbuffer { + char text[24]; +} message; + +int main() { + int msqid = 32764; + msgrcv(msqid, &message, sizeof(message),0,0); + printf("\nQueue: %d\n",msqid); + printf("Got this message: %s\n", message.text); + msgctl(msqid,IPC_RMID,NULL); + return 0; +``` + +编译并运行: + +``` +$ gcc get.c -o get.bin +$ ./get.bin + +Queue: 32764 +Got this message: opensource.com +``` + +### 下载这本电子书 + +这只是 Marty Kalin 的《[Linux 进程间通信指南][5]》中课程的一个例子,可从 Opensource.com 下载的这本最新免费(且 CC 授权)的电子书。在短短的几节课中,你将从消息队列、共享内存和信号量、套接字、信号等中了解 IPC 的 POSIX 方法。认真阅读 Marty 的书,你将成为一个博识的程序员。而这不仅适用于经验丰富的编码人员,如果你编写的只是 shell 脚本,那么你将拥有有关管道(命名和未命名)和共享文件的大量实践知识,以及使用共享文件或外部消息队列时需要了解的重要概念。 + +如果你对制作具有动态和具有系统感知的优秀软件感兴趣,那么你需要了解 IPC。让[这本书][5]做你的向导。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/inter-process-communication-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coverimage_inter-process_communication_linux_520x292.png?itok=hPoen7oI (Inter-process Communication in Linux) +[2]: https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/ +[3]: https://wiki.debian.org/BuildingTutorial +[4]: https://docs.pagure.org/docs-fedora/installing-software-from-source.html +[5]: https://opensource.com/downloads/guide-inter-process-communication-linux diff --git a/published/202001/20200103 My Raspberry Pi retrospective- 6 projects and more.md b/published/202001/20200103 My Raspberry Pi retrospective- 6 projects and more.md new file mode 100644 index 0000000000..ad2ff90485 --- /dev/null +++ b/published/202001/20200103 My Raspberry Pi retrospective- 6 projects and more.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: 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) + +我的树莓派项目回顾 +====== + +> 看看我在好玩、能学习、有用处的树莓派上做了些什么。 + +![](https://img.linux.net.cn/data/attachment/album/202001/11/091748wekfv77t5ux5zzv2.jpg) + +无论是从历史上,还是从理论上讲,当时钟走到一个十年份第一年的 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 项目中引入的更改。 + +### DIY 项目 + +多年来,我已经将树莓派变成了几种有用的设备。有一次,我将树莓派变成了 [Pi MusicBox 音乐播放设备][7],它可以让你在 Web 界面中导入你喜欢的音乐流并在房间中播放。 + +将树莓派做成[移动视频录制设备][8]是另一个 DIY 项目。它需要一些额外的硬件,例如触摸屏、树莓派摄像头和电池组,但是它工作的很好。这个设备的最大缺点之一是当时树莓派的可用内存很小。我认为如果我将它重新配置在具有 4GB 内存的树莓派 4 上,那么这款便携式摄像机的功能可能会更好。这可能是一个会在 2020 年重新打造的项目。 + +我做的另一个小项目[客厅的数字时钟][9]使用了 Adafruit PiTFT 小屏幕。尽管这个项目很简单,但它可能是我使用时间最长的项目。那个时钟在我的电视机上呆了一年多,一天 24 小时不间断运行,直到屏幕烧坏为止。 + +### 圆周率日系列 + +最后但并非最不重要的一点是,在 2019 年的圆周率日(3 月 14 日)之前,我在 [14 内发布了 14 篇文章][10]。这是迄今为止我完成过的最具挑战性的写作项目,但是它使我能够涵盖许多不同的主题,并希望使读者对树莓派的丰富功能有更多的了解。 + +### 走向未来 + +我不认识树莓派基金会中的任何人,因此我不了解它的任何路线图和未来计划。我可以(但我不会)推测品牌及其设备的未来,它们让世界各地这么多不同社会地位的人扩展他们对计算机科学、电子和开源开发的知识。我希望基金会的管理层能够忠于其愿景和使命,并继续为世界各地的人们提供价格合理的技术。 + +21 世纪 10 年代过去了,那是多么甜蜜的十年。对我来说,它闻起来就像树莓派馅饼。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/raspberry-pi-best + +作者:[Anderson Silva][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ansilva +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi4_board_hardware.jpg?itok=KnFU7NvR (Raspberry Pi 4 board, posterized filter) +[2]: https://www.raspberrypi.org/ +[3]: https://time.com/5745302/best-gadgets-of-the-2010s-decade/?utm_source=reddit.com +[4]: https://opensource.com/life/15/2/music-light-show-with-raspberry-pi +[5]: https://opensource.com/life/15/12/ssh-your-christmas-tree-raspberry-pi +[6]: https://opensource.com/article/18/12/lightshowpi-raspberry-pi +[7]: https://opensource.com/life/15/3/pi-musicbox-guide +[8]: https://opensource.com/life/15/9/turning-raspberry-pi-portable-streaming-camera +[9]: https://opensource.com/article/17/7/raspberry-pi-clock +[10]: https://opensource.com/article/19/3/happy-pi-day diff --git a/published/202001/20200105 PaperWM- tiled window management for GNOME.md b/published/202001/20200105 PaperWM- tiled window management for GNOME.md new file mode 100644 index 0000000000..ea412dae95 --- /dev/null +++ b/published/202001/20200105 PaperWM- tiled window management for GNOME.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11779-1.html) +[#]: subject: (PaperWM: tiled window management for GNOME) +[#]: via: (https://jvns.ca/blog/2020/01/05/paperwm/) +[#]: author: (Julia Evans https://jvns.ca/) + +PaperWM:GNOME 下的平铺窗口管理 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/13/212936hsk572f4jrsj2jsh.jpg) + +当我开始在个人计算机上使用 Linux 时,首先令我兴奋的就是轻巧的窗口管理器,这主要是因为当时我的笔记本电脑只有有 32MB 的内存,其它的都运行不了了。 + +接着我开始接触 [xmonad][1] 之类的平铺窗口管理器!我可以用键盘管理窗口了!它们是如此之快!我可以通过编写 Haskell 程序来配置 xmonad!我可以用各种有趣的方式自定义所有内容(例如使用 [dmenu][2] 作为启动器)!这些年来,我用过 3、4 个不同的平铺窗口管理器,它们都很有趣。 + +大约 6 年前,我觉得配置平铺窗口管理器对我来说不再是一件有趣的事情,因此转而使用 Ubuntu 桌面环境 Gnome。(现在,我的笔记本电脑中的内存增加了 500 倍,这要快得多 :) ) + +我使用 Gnome 已有很长时间了,但是我仍然有点想念平铺窗口管理器。六个月前,一个朋友告诉我有关 [PaperWM][3] 的消息,它使你可以在 Gnome 中平铺窗口!我立即安装了它,并从那时起我一直在使用它。 + +### PaperWM:Gnome 下的平铺窗口管理 + +[PaperWM][3] 的基本思想是:你想继续使用 Gnome(因为在 Gnome 中各种任务都能完成),但是你也希望使用平铺窗口管理器。 + +它是一个 Gnome 扩展程序(而不是一个独立的窗口管理器),并且使用 Javascript。 + +### “Paper” 表示你的所有窗户都在一行中 + +PaperWM 的主要想法是将所有窗口排成一行,这实际上与传统的平铺窗口管理器大不相同,在传统的平铺窗口管理器中,你可以按任意方式平铺窗口。这是我写这篇博客时在几个窗口之间切换/调整大小的 gif 图像(有一个浏览器和两个终端窗口): + +![][4] + +PaperWM 的 Github README 链接了此视频:,它描述为一个类似的”线性窗口管理器“。 + +我以前从未听说过这种组织窗口的方式,但是我喜欢它的简单性。如果要查找特定的窗口,只需向左/向右移动,直到找到它。 + +### 我在 PaperWM 中所做的一切 + +还有很多其他功能,但这是我使用的功能: + +* 在窗口之间左右移动(`Super + ,`、`Super + .`) +* 按顺序向左/向右移动窗口(`Super+Shift+,`、`Super+Shift+.`) +* 全屏显示窗口(`Super + f`) +* 缩小窗口(`Super + r`) + +### 我喜欢不需要配置的工具 + +我在笔记本上使用 PaperWM 已经 6 个月了,我真的很喜欢它!即使它是可配置(通过编写 Javascript 配置文件),我也非常欣赏它,它自带我想要的功能,我无需研究如何去配置。 + +[fish shell][5] 是另一个类似的令人愉悦的工具,我基本上没有配置 fish(除了设置环境变量等),我真的很喜欢它的默认功能。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/01/05/paperwm/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://xmonad.org/ +[2]: https://wiki.archlinux.org/index.php/Dmenu +[3]: https://github.com/paperwm/PaperWM +[4]: https://jvns.ca/images/paperwm.gif +[5]: https://jvns.ca/blog/2017/04/23/the-fish-shell-is-awesome/ diff --git a/published/202001/20200106 How to write a Python web API with Pyramid and Cornice.md b/published/202001/20200106 How to write a Python web API with Pyramid and Cornice.md new file mode 100644 index 0000000000..1ebcc920e9 --- /dev/null +++ b/published/202001/20200106 How to write a Python web API with Pyramid and Cornice.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11788-1.html) +[#]: subject: (How to write a Python web API with Pyramid and Cornice) +[#]: via: (https://opensource.com/article/20/1/python-web-api-pyramid-cornice) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何使用 Pyramid 和 Cornice 编写 Python Web API +====== + +> 使用 Pyramid 和 Cornice 构建和描述可扩展的 RESTful Web 服务。 + +![](https://img.linux.net.cn/data/attachment/album/202001/16/120352fcgeeccvfgt8sfvc.jpg) + +[Python][2] 是一种高级的、面向对象的编程语言,它以其简单的语法而闻名。它一直是构建 RESTful API 的顶级编程语言之一。 + +[Pyramid][3] 是一个 Python Web 框架,旨在随着应用的扩展而扩展:这可以让简单的应用很简单,也可以增长为大型、复杂的应用。此外,Pyramid 为 PyPI (Python 软件包索引)提供了强大的支持。[Cornice][4] 为使用 Pyramid 构建和描述 RESTful Web 服务提供了助力。 + +本文将使用 Web 服务的例子来获取名人名言,来展示如何使用这些工具。 + +### 建立 Pyramid 应用 + +首先为你的应用创建一个虚拟环境,并创建一个文件来保存代码: + +``` +$ mkdir tutorial +$ cd tutorial +$ touch main.py +$ python3 -m venv env +$ source env/bin/activate +(env) $ pip3 install cornice twisted +``` + +### 导入 Cornice 和 Pyramid 模块 + +使用以下命令导入这些模块: + +``` +from pyramid.config import Configurator +from cornice import Service +``` + +### 定义服务 + +将引用服务定义为 `Service` 对象: + +``` +QUOTES = Service(name='quotes', +                 path='/', +                 description='Get quotes') +``` + +### 编写引用逻辑 + +到目前为止,这仅支持获取名言。用 `QUOTES.get` 装饰函数。这是将逻辑绑定到 REST 服务的方法: + +``` +@QUOTES.get() +def get_quote(request): +    return { +        'William Shakespeare': { +            'quote': ['Love all, trust a few, do wrong to none', +            'Some are born great, some achieve greatness, and some have greatness thrust upon them.'] +    }, +    'Linus': { +        'quote': ['Talk is cheap. Show me the code.'] +        } +    } +``` + +请注意,与其他框架不同,装饰器*不会*更改 `get_quote` 函数。如果导入此模块,你仍然可以定期调用该函数并检查结果。 + +在为 Pyramid RESTful 服务编写单元测试时,这很有用。 + +### 定义应用对象 + +最后,使用 `scan` 查找所有修饰的函数并将其添加到配置中: + +``` +with Configurator() as config: +    config.include("cornice") +    config.scan() +    application = config.make_wsgi_app() +``` + +默认扫描当前模块。如果要扫描软件包中的所有模块,你也可以提供软件包的名称。 + +### 运行服务 + +我使用 Twisted 的 WSGI 服务器运行该应用,但是如果需要,你可以使用任何其他 [WSGI][5] 服务器,例如 Gunicorn 或 uWSGI。 + +``` +(env)$ python -m twisted web --wsgi=main.application +``` + +默认情况下,Twisted 的 WSGI 服务器运行在端口 8080 上。你可以使用 [HTTPie][6] 测试该服务: + +``` +(env) $ pip install httpie +... +(env) $ http GET +HTTP/1.1 200 OK +Content-Length: 220 +Content-Type: application/json +Date: Mon, 02 Dec 2019 16:49:27 GMT +Server: TwistedWeb/19.10.0 +X-Content-Type-Options: nosniff + +{ +    "Linus": { +        "quote": [ +            "Talk is cheap. Show me the code." +        ] +    }, +    "William Shakespeare": { +        "quote": [ +            "Love all,trust a few,do wrong to none", +            "Some are born great, some achieve greatness, and some greatness thrust upon them." +        ] +    } +} +``` + +### 为什么要使用 Pyramid? + +Pyramid 并不是最受欢迎的框架,但它已在 [PyPI][7] 等一些引人注目的项目中使用。我喜欢 Pyramid,因为它是认真对待单元测试的框架之一:因为装饰器不会修改函数并且没有线程局部变量,所以可以直接从单元测试中调用函数。例如,需要访问数据库的函数将从通过 `request.config` 传递的 `request.config` 对象中获取它。这允许单元测试人员将模拟(或真实)数据库对象放入请求中,而不用仔细设置全局变量、线程局部变量或其他特定于框架的东西。 + +如果你正在寻找一个经过测试的库来构建你接下来的 API,请尝试使用 Pyramid。你不会失望的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/python-web-api-pyramid-cornice + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://opensource.com/resources/python +[3]: https://opensource.com/article/18/5/pyramid-framework +[4]: https://cornice.readthedocs.io/en/latest/ +[5]: https://en.wikipedia.org/wiki/Web_Server_Gateway_Interface +[6]: https://opensource.com/article/19/8/getting-started-httpie +[7]: https://pypi.org/ diff --git a/published/202001/20200107 Generating numeric sequences with the Linux seq command.md b/published/202001/20200107 Generating numeric sequences with the Linux seq command.md new file mode 100644 index 0000000000..c04fc6ff3a --- /dev/null +++ b/published/202001/20200107 Generating numeric sequences with the Linux seq command.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11784-1.html) +[#]: subject: (Generating numeric sequences with the Linux seq command) +[#]: via: (https://www.networkworld.com/article/3511954/generating-numeric-sequences-with-the-linux-seq-command.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 Linux seq 命令生成数字序列 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/15/112717drpb9nuwss84xebu.jpg) + +> Linux 的 seq 命令可以以闪电般的速度生成数字列表,而且它也易于使用而且灵活。 + +在 Linux 中生成数字列表的最简单方法之一是使用 `seq`(系列sequence)命令。其最简单的形式是,`seq` 接收一个数字参数,并输出从 1 到该数字的列表。例如: + +``` +$ seq 5 +1 +2 +3 +4 +5 +``` + +除非另有指定,否则 `seq` 始终以 1 开头。你可以在最终数字前面插上不同数字开始一个序列。 + +``` +$ seq 3 5 +3 +4 +5 +``` + +### 指定增量 + +你还可以指定增量步幅。假设你要列出 3 的倍数。指定起点(在此示例中为第一个 3 ),增量(第二个 3)和终点(18)。 + +``` +$ seq 3 3 18 +3 +6 +9 +12 +15 +18 +``` + +你可以选择使用负增量(即减量)将数字从大变小。 + +``` +$ seq 18 -3 3 +18 +15 +12 +9 +6 +3 +``` + +`seq` 命令也非常快。你或许可以在 10 秒内生成一百万个数字的列表。 + +``` +$ time seq 1000000 +1 +2 +3 +… +… +999998 +999999 +1000000 + +real 0m9.290s <== 9+ seconds +user 0m0.020s +sys 0m0.899s +``` + +### 使用分隔符 + +另一个非常有用的选项是使用分隔符。你可以插入逗号、冒号或其他一些字符,而不是在每行上列出单个数字。`-s` 选项后跟要使用的字符。 + +``` +$ seq -s: 3 3 18 +3:6:9:12:15:18 +``` + +实际上,如果只是希望将数字列在一行上,那么可以使用空格代替默认的换行符。 + +``` +$ seq -s' ' 3 3 18 +3 6 9 12 15 18 +``` + +### 开始数学运算 + +从生成数字序列到进行数学运算似乎是一个巨大的飞跃,但是有了正确的分隔符,`seq` 可以轻松地传递给 `bc` 进行计算。例如: + +``` +$ seq -s* 5 | bc +120 +``` + +该命令中发生了什么?让我们来看看。首先,`seq` 生成一个数字列表,并使用 `*` 作为分隔符。 + +``` +$ seq -s* 5 +1*2*3*4*5 +``` + +然后,它将字符串传递给计算器(`bc`),计算器立即将数字相乘。你可以在不到一秒的时间内进行相当庞大的计算。 + +``` +$ time seq -s* 117 | bc +39699371608087208954019596294986306477904063601683223011297484643104\ +22041758630649341780708631240196854767624444057168110272995649603642\ +560353748940315749184568295424000000000000000000000000000 + +real 0m0.003s +user 0m0.004s +sys 0m0.000s +``` + +### 局限性 + +你只能选择一个分隔符,因此计算将非常有限。而单独使用 `bc` 可进行更复杂的数学运算。此外,`seq` 仅适用于数字。要生成单个字母的序列,请改用如下命令: + +``` +$ echo {a..g} +a b c d e f g +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3511954/generating-numeric-sequences-with-the-linux-seq-command.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://creativecommons.org/licenses/by/2.0/ +[2]: https://creativecommons.org/licenses/by/2.0/legalcode +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20200107 How piwheels will save Raspberry Pi users time in 2020.md b/published/202001/20200107 How piwheels will save Raspberry Pi users time in 2020.md new file mode 100644 index 0000000000..2fc0aafef9 --- /dev/null +++ b/published/202001/20200107 How piwheels will save Raspberry Pi users time in 2020.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11786-1.html) +[#]: subject: (How piwheels will save Raspberry Pi users time in 2020) +[#]: via: (https://opensource.com/article/20/1/piwheels) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +piwheels 是如何为树莓派用户节省时间的 +====== + +> 通过为树莓派提供预编译的 Python 包,piwheels 项目为用户节省了大量的时间和精力。 + +![rainbow colors on pinwheels in the sun][1] + +piwheels 自动为 Python 包索引 [PiPi][2] 上的所有项目构建 Python wheels(预编译的 Python包),并使用了树莓派硬件以确保其兼容性。这意味着,当树莓派用户想要使用 `pip` 安装一个 Python 库时,他们会得到一个现成编译好的版本,并保证可以在树莓派上良好的工作。这使得树莓派用户更容易入门并开始他们的项目。 + +![Piwheels logo][3] + +当我在 2018 年 10 月写 [piwheels:为树莓派提供快速 Python 包安装][4]时,那时 piwheels 项目已经有一年了,并且已经证明了其为树莓派用户节省大量时间和精力。但当这个项目进入第二年时,它为树莓派提供了预编译的 Python 包做了更多工作。 + +![Raspberry Pi 4][5] + +### 它是怎么工作的 + +树莓派的主要操作系统 [Raspbian][6] 预配置使用了 piwheels,所以用户不需要做任何特殊的事情就可以使用 piwheels。 + +配置文件(在 `/etc/pip.conf`)告诉 `pip` 使用 [piwheels.org][7] 作*附加索引*,因此 `pip` 会首先查找 PyPI,然后查找 piwheels。piwheels 的网站被托管在一个树莓派 3 上,该项目构建的所有 wheels 都托管在该树莓派上。它每月提供 100 多万个软件包——这对于一台 35 美元的电脑来说还真不赖! + +除了提供网站服务的主树莓派以外,piwheels 项目还使用其他七个树莓派来构建软件包。其中一些运行 Raspbian Jessie,为 Python 3.4 构建 wheels;另外一些运行 Raspbian Stretch 为 Python 3.5 构建;还有一些运行 Raspbian Buster 为 Python 3.7 构建。该项目通常不支持其他 Python 版本。还有一个“合适的服务器”——一台运行 Postgres 数据库的虚拟机。由于树莓派 3 只有 1GB 的内存,所以(非常大的)数据库不能在其上很好地运行,所以我们把它移到了虚拟机上。带 4GB 内存的树莓派 4 可能是合用的,所以我们将来可能会用到它。 + +这些树莓派都在“派云”中的 IPv6 网络上——这是一项由总部位于剑桥的托管公司 [Mythic Beasts][8] 提供的卓越服务。 + +![Mythic Beasts hosting service][9] + +### 下载和统计趋势 + +每次下载 piwheels 文件时,它都会记录在数据库中。这提供了对什么包最受欢迎以及人们使用什么 Python 版本和操作系统的统计。我们没有太多来自用户代理的信息,但是因为树莓派 1/Zero 的架构显示为 “armv6”,树莓派 2/3/4 显示为 “armv7”,所以我们可以将它们区分开来。 + +截至 2019 年 12 月中旬,从 piwheels 下载的软件包超过 1400 万个,仅 2019 年就有近 900 万个。 + +自项目开始以来最受欢迎的 10 个软件包是: + + 1. [pycparser][10](821,060 个下载) + 2. [PyYAML][11](366,979 个下载) + 3. [numpy][12](354,531 个下载) + 4. [cffi][13](336,982 个下载) + 5. [MarkupSafe][14](318,878 个下载) + 6. [future][15](282,349 个下载) + 7. [aiohttp][16](277,046 个下载) + 8. [cryptography][17](276,167 个下载) + 9. [home-assistant-frontend][18](266,667 个下载) + 10. [multidict][19](256,185 个下载) + +请注意,许多纯 Python 包,如 [urllib3][20],都是作为 PyPI 上的 wheels 提供的;因为这些是跨平台兼容的,所以通常不会从 piwheels 下载,因为 PyPI 优先。 + +随着时间的推移,我们也看到了使用哪些 Python 版本的趋势。这里显示了 Raspbian Buster 发布时从 3.5 版快速升级到了 Python 3.7: + +![Data from piwheels on Python versions used over time][21] + +你可以在我们的这篇 [统计博文][22] 看到更多的统计趋势。 + +### 节省的时间 + +每个包构建都被记录在数据库中,并且每个下载也被存储。交叉引用下载数和构建时间显示了节省了多少时间。一个例子是 numpy —— 最新版本大约需要 11 分钟来构建。 + +迄今为止,piwheels 项目已经为用户节省了总计超过 165 年的构建时间。按照目前的使用率,piwheels 项目每天可以节省 200 多天。 + +除了节省构建时间,拥有预编译的 wheels 也意味着人们不必安装各种开发工具来构建包。一些包需要其他 apt 包来访问共享库。弄清楚你需要哪一个可能会很痛苦,所以我们也让这一步变得容易了。首先,我们找到了这个过程,[在博客上记录了这个过程][23]。然后,我们将这个逻辑添加到构建过程中,这样当构建一个 wheels 时,它的依赖关系会被自动计算并添加到包的项目页面中: + +![numpy dependencies][24] + +### piwheels 的下一步是什么? + +今年,我们推出了项目页面(例如,[numpy][25]),这是一种非常有用的方式,可以让人们以人类可读的方式查找项目信息。它们还使人们更容易报告问题,例如 piwheels 中缺少一个项目,或者他们下载的包有问题。 + +2020 年初,我们计划对 piwheels 项目进行一些升级,以启用新的 JSON 应用编程接口,这样你就可以自动检查哪些版本可用,查找项目的依赖关系,等等。 + +下一次 Debian/Raspbian 升级要到 2021 年年中才会发生,所以在那之前我们不会开始为任何新的 Python 版本构建 wheels。 + +你可以在这个项目的[博客][26]上读到更多关于 piwheels 的信息,我将在 2020 年初在那里发表一篇 2019 年的综述。你也可以在推特上关注 [@piwheels][27],在那里你可以看到每日和每月的统计数据以及任何达到的里程碑。 + +当然,piwheels 是一个开源项目,你可以在 [GitHub][28] 上看到整个项目源代码。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/piwheels + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rainbow-pinwheel-piwheel-diversity-inclusion.png?itok=di41Wd3V (rainbow colors on pinwheels in the sun) +[2]: https://pypi.org/ +[3]: https://opensource.com/sites/default/files/uploads/piwheels.png (Piwheels logo) +[4]: https://opensource.com/article/18/10/piwheels-python-raspberrypi +[5]: https://opensource.com/sites/default/files/uploads/raspberry-pi-4_0.jpg (Raspberry Pi 4) +[6]: https://www.raspberrypi.org/downloads/raspbian/ +[7]: http://piwheels.org +[8]: https://www.mythic-beasts.com/order/rpi +[9]: https://opensource.com/sites/default/files/uploads/pi-cloud.png (Mythic Beasts hosting service) +[10]: https://www.piwheels.org/project/pycparser +[11]: https://www.piwheels.org/project/PyYAML +[12]: https://www.piwheels.org/project/numpy +[13]: https://www.piwheels.org/project/cffi +[14]: https://www.piwheels.org/project/MarkupSafe +[15]: https://www.piwheels.org/project/future +[16]: https://www.piwheels.org/project/aiohttp +[17]: https://www.piwheels.org/project/cryptography +[18]: https://www.piwheels.org/project/home-assistant-frontend +[19]: https://www.piwheels.org/project/multidict +[20]: https://piwheels.org/project/urllib3/ +[21]: https://opensource.com/sites/default/files/uploads/pyvers2019.png (Data from piwheels on Python versions used over time) +[22]: https://blog.piwheels.org/piwheels-stats-for-2019/ +[23]: https://blog.piwheels.org/how-to-work-out-the-missing-dependencies-for-a-python-package/ +[24]: https://opensource.com/sites/default/files/uploads/numpy-deps.png (numpy dependencies) +[25]: https://www.piwheels.org/project/numpy/ +[26]: https://blog.piwheels.org/ +[27]: https://twitter.com/piwheels +[28]: https://github.com/piwheels/ diff --git a/published/202001/20200108 How to setup multiple monitors in sway.md b/published/202001/20200108 How to setup multiple monitors in sway.md new file mode 100644 index 0000000000..153933d6be --- /dev/null +++ b/published/202001/20200108 How to setup multiple monitors in sway.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11809-1.html) +[#]: subject: (How to setup multiple monitors in sway) +[#]: via: (https://fedoramagazine.org/how-to-setup-multiple-monitors-in-sway/) +[#]: author: (arte219 https://fedoramagazine.org/author/arte219/) + +如何在 Sway 中设置多个显示器 +====== + +![][1] + +Sway 是一种平铺式 Wayland 合成器,具有与 [i3 X11 窗口管理器][2]相同的功能、外观和工作流程。由于 Sway 使用 Wayland 而不是 X11,因此就不能一如既往地使用设置 X11 的工具。这包括 `xrandr` 之类的工具,这些工具在 X11 窗口管理器或桌面中用于设置显示器。这就是为什么必须通过编辑 Sway 配置文件来设置显示器的原因,这就是本文的目的。 + +### 获取你的显示器 ID + +首先,你必须获得 Sway 用来指代显示器的名称。你可以通过运行以下命令进行操作: + +``` +$ swaymsg -t get_outputs +``` + +你将获得所有显示器的相关信息,每个显示器都用空行分隔。 + +你必须查看每个部分的第一行,以及 `Output` 之后的内容。例如,当你看到 `Output DVI-D-1 'Philips Consumer Electronics Company'` 之类的行时,则该输出 ID 为 `DVI-D-1`。注意这些 ID 及其所属的物理监视器。 + +### 编辑配置文件 + +如果你之前没有编辑过 Sway 配置文件,则必须通过运行以下命令将其复制到主目录中: + +``` +cp -r /etc/sway/config ~/.config/sway/config +``` + +现在,默认配置文件位于 `~/.config/sway` 中,名为 `config`。你可以使用任何文本编辑器进行编辑。 + +现在你需要做一点数学。想象有一个网格,其原点在左上角。X 和 Y 坐标的单位是像素。Y 轴反转。这意味着,例如,如果你从原点开始,向右移动 100 像素,向下移动 80 像素,则坐标将为 `(100, 80)`。 + +你必须计算最终显示在此网格上的位置。显示器的位置由左上方的像素指定。例如,如果我们要使用名称为“HDMI1”且分辨率为 1920×1080 的显示器,并在其右侧使用名称为 “eDP1” 且分辨率为 1600×900 的笔记本电脑显示器,则必须在配置文件中键入 : + +``` +output HDMI1 pos 0 0 +output eDP1 pos 1920 0 +``` + +你还可以使用 `res` 选项手动指定分辨率: + +``` +output HDMI1 pos 0 0 res 1920x1080 +output eDP1 pos 1920 0 res 1600x900 +``` + +### 将工作空间绑定到显示器上 + +与多个监视器一起使用 Sway 在工作区管理中可能会有些棘手。幸运的是,你可以将工作区绑定到特定的显示器上,因此你可以轻松地切换到该显示器并更有效地使用它。只需通过配置文件中的 `workspace` 命令即可完成。例如,如果要绑定工作区 1 和 2 到显示器 “DVI-D-1”,绑定工作区 8 和 9 到显示器 “HDMI-A-1”,则可以使用以下方法: + +``` +workspace 1 output DVI-D-1 +workspace 2 output DVI-D-1 +``` + +``` +workspace 8 output HDMI-A-1 +workspace 9 output HDMI-A-1 +``` + +就是这样。这就在 Sway 中多显示器设置的基础知识。可以在 中找到更详细的指南。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-setup-multiple-monitors-in-sway/ + +作者:[arte219][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/arte219/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/01/sway-multiple-monitors-816x345.png +[2]: https://fedoramagazine.org/getting-started-i3-window-manager/ diff --git a/published/202001/20200109 Huawei-s Linux Distribution openEuler is Available Now.md b/published/202001/20200109 Huawei-s Linux Distribution openEuler is Available Now.md new file mode 100644 index 0000000000..891902da7e --- /dev/null +++ b/published/202001/20200109 Huawei-s Linux Distribution openEuler is Available Now.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11787-1.html) +[#]: subject: (Huawei’s Linux Distribution openEuler is Available Now!) +[#]: via: (https://itsfoss.com/openeuler/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +外媒:华为的 Linux 发行版 openEuler 可以使用了! +====== + +> 华为提供了一个基于 CentOS 的企业级 Linux 发行版 EulerOS。最近,华为发布了一个名为 [openEuler][1] 的 EulerOS 社区版。 + +openEuler 的源代码也一同发布了。你在微软旗下的 GitHub 上找不到它——源代码可以在 [Gitee][2] 找到,这是一个中文的 [GitHub 的替代品][3]。 + +它有两个独立的存储库,一个用于存储[源代码][2];另一个作为[软件包的源代码][4],存储有助于构建该操作系统的软件包。 + +![][5] + +openEuler 基础架构团队分享了他们使源代码可用的经验: + +> 我们现在很兴奋。很难想象我们会管理成千上万的仓库。为了确保它们能被成功地编译,我们要感谢所有参与贡献的人。 + +### openEuler 是基于 CentOS 的 Linux 发行版 + +与 EulerOS 一样,openEuler OS 也是基于 [CentOS][6],但华为技术有限公司为企业应用进一步开发了该操作系统。 + +它是为 ARM64 架构的服务器量身定做的,同时华为声称已经做了一些改变来提高其性能。你可以在[华为开发博客][7]上了解更多。 + +![][8] + +目前,根据 openEuler 的官方声明,有 50 多名贡献者为 openEuler 贡献了近 600 个提交。 + +贡献者们使源代码对社区可用成为可能。 + +值得注意的是,存储库还包括两个与之相关的新项目(或子项目),[iSulad][9] 和 A-Tune。 + +A-Tune 是一个基于 AI 的操作系统调优软件,iSulad 是一个轻量级的容器运行时守护进程,如在 [Gitee][2] 中提到的那样,它是为物联网和云基础设施设计的。 + +另外,官方的[公告][10]提到,这些系统是在华为云上通过脚本自动构建的。这确实十分有趣。 + +### 下载 openEuler + +![][11] + +到目前为止,你找不到它的英文文档,所以你必须等待或选择通过(贡献)[文档][12]来帮助他们。 + +你可以直接从它的[官方网站][13]下载 ISO 来测试它: + +- [下载 openEuler ][13] + +### 你认为华为的 openEuler 怎么样? + +据 cnTechPost 报道,华为曾宣布 EulerOS 将以新名字 openEuler 成为开源软件。 + +目前还不清楚 openEuler 是否会取代 EulerOS ,或者两者会像 CentOS(社区版)和 Red Hat(商业版)一样同时存在。 + +我还没有测试过它,所以我不能说 openEuler 是否适合英文用户。 + +你愿意试一试吗?如果你已经尝试过了,欢迎在下面的评论中告诉我你的体验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/openeuler/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[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 +[c]: (https://github.com/qianmingtian) +[1]: https://openeuler.org/en/ +[2]: https://gitee.com/openeuler +[3]: https://itsfoss.com/github-alternatives/ +[4]: https://gitee.com/src-openeuler +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/openEuler-website.jpg?ssl=1 +[6]: https://www.centos.org/ +[7]: https://developer.huaweicloud.com/en-us/euleros/euleros-introduction.html +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/openeuler-gitee.jpg?ssl=1 +[9]: https://gitee.com/openeuler/iSulad +[10]: https://openeuler.org/en/news/20200101.html +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/openEuler.jpg?ssl=1 +[12]: https://gitee.com/openeuler/docs +[13]: https://openeuler.org/en/download.html diff --git a/published/202001/20200110 Bash Script to Send eMail With a List of User Accounts Expiring in -X- Days.md b/published/202001/20200110 Bash Script to Send eMail With a List of User Accounts Expiring in -X- Days.md new file mode 100644 index 0000000000..9a46a42281 --- /dev/null +++ b/published/202001/20200110 Bash Script to Send eMail With a List of User Accounts Expiring in -X- Days.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11781-1.html) +[#]: subject: (Bash Script to Send eMail With a List of User Accounts Expiring in “X” Days) +[#]: via: (https://www.2daygeek.com/bash-script-to-check-user-account-password-expiry-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +使用 Bash 脚本发送包含几天内到期的用户账号列表的电子邮件 +====== + +![](https://img.linux.net.cn/data/attachment/album/202001/13/232047vfxkrr47mn7eapda.jpg) + +密码强制策略对所有操作系统和应用程序都是通用的。如果要[在 Linux 上实现密码强制策略][1],请参阅以下文章。 + +默认情况下,大多数公司都会强制执行密码强制策略,但根据公司的要求,密码的时间周期会有所不同。通常每个人都使用 90 天的密码周期。用户只会在他们使用的一些服务器上[更改密码][2],而不会在他们不经常使用的服务器上更改密码。 + +特别地,大多数团队忘记更改服务帐户密码,这可能导致日常工作的中断,即使他们配置有[基于 SSH 密钥的身份验证][3]。如果用户帐户密码过期,基于SSH密钥的身份验证和 [cronjob][4] 将不起作用。 + +为了避免这种情况,我们创建了一个 [shell 脚本][5]来向你发送 10 天内到期的用户帐户列表。 + +本教程中包含两个 [bash 脚本][6]可以帮助你收集系统中用户到期天数的信息。 + +### 1) 检查 10 天后到期的用户帐户列表 + +此脚本将帮助你在终端上检查 10 天内到期的用户帐户列表。 + +``` +# vi /opt/script/user-password-expiry.sh +``` + +``` +#!/bin/sh +/tmp/user-expiry-1.txt +/tmp/user-expiry.txt +echo "-------------------------------------------------" +echo "UserName The number of days the password expires" +echo "-------------------------------------------------" +for usern in u1 u2 u3 u4 +do +today=$(date +%s) +userexpdate=$(chage -l $usern | grep 'Password expires' |cut -d: -f2) +passexp=$(date -d "$userexpdate" "+%s") +exp=`expr \( $passexp - $today \)` +expday=`expr \( $exp / 86400 \)` +echo "$usern $expday" >> /tmp/user-expiry.txt +done +cat /tmp/user-expiry.txt | awk '$2 <= 10' > /tmp/user-expiry-1.txt +cat /tmp/user-expiry-1.txt | column -t +``` + +将文件 `user-password-expiry.sh` 设置为可执行的 Linux 文件权限。 + +``` +# chmod +x /opt/script/user-password-expiry.sh +``` + +你将得到如下输出,但用户与天数可能不同。 + +``` +# sh /opt/script/user-password-expiry.sh + +------------------------------------------------- +UserName The number of days the password expires +------------------------------------------------- +u1 -25 +u2 9 +u3 3 +u4 5 +``` + +### 2) 发送包含 10 天内到期的用户帐户列表的电子邮件 + +此脚本将发送一封包含 10 天内到期的用户帐户列表的邮件。 + +``` +# vi /opt/script/user-password-expiry-mail.sh +``` + +``` +#!/bin/sh +SUBJECT="Information About User Password Expiration on "`date`"" +MESSAGE="/tmp/user-expiry.txt" +MESSAGE1="/tmp/user-expiry-1.txt" +TO="magesh.m@rentacenter.com" +echo "-------------------------------------------------" >> $MESSAGE1 +echo "UserName The number of days the password expires" >> $MESSAGE1 +echo "-------------------------------------------------" >> $MESSAGE1 +for usern in u1 u2 u3 u4 +do +today=$(date +%s) +userexpdate=$(chage -l $usern | grep 'Password expires' |cut -d: -f2) +passexp=$(date -d "$userexpdate" "+%s") +exp=`expr \( $passexp - $today \)` +expday=`expr \( $exp / 86400 \)` +echo "$usern $expday" >> $MESSAGE +done +cat $MESSAGE | awk '$2 <= 10' >> $MESSAGE1 +mail -s "$SUBJECT" "$TO" < $MESSAGE1 +rm $MESSAGE +rm $MESSAGE1 +``` + +将文件 `user-password-expiry-mail.sh` 设置为可执行的 Linux 文件权限。 + +``` +# chmod +x /opt/script/user-password-expiry-mail.sh +``` + +最后,添加一个 [cronjob][4] 去自动执行脚本。每天早上 8 点运行一次。 + +``` +# crontab -e +0 8 * * * /bin/bash /opt/script/user-password-expiry-mail.sh +``` + +你将收到一封与第一个脚本输出类似的电子邮件。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-script-to-check-user-account-password-expiry-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[1]: https://linux.cn/article-11709-1.html +[2]: https://www.2daygeek.com/linux-passwd-chpasswd-command-set-update-change-users-password-in-linux-using-shell-script/ +[3]: https://www.2daygeek.com/configure-setup-passwordless-ssh-key-based-authentication-linux/ +[4]: https://www.2daygeek.com/linux-crontab-cron-job-to-schedule-jobs-task/ +[5]: https://www.2daygeek.com/category/shell-script/ +[6]: https://www.2daygeek.com/category/bash-script/ diff --git a/published/202001/20200111 Sync files across multiple devices with Syncthing.md b/published/202001/20200111 Sync files across multiple devices with Syncthing.md new file mode 100644 index 0000000000..65959e3d59 --- /dev/null +++ b/published/202001/20200111 Sync files across multiple devices with Syncthing.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11793-1.html) +[#]: subject: (Sync files across multiple devices with Syncthing) +[#]: via: (https://opensource.com/article/20/1/sync-files-syncthing) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Syncthing 在多个设备间同步文件 +====== + +> 2020 年,在我们的 20 个使用开源提升生产力的系列文章中,首先了解如何使用 Syncthing 同步文件。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/123416rebvs7sjwm6c889y.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Synthing 同步文件 + +设置新机器很麻烦。我们都有在机器之间复制的“标准设置”。多年来,我使用了很多方法来使它们在计算机之间同步。在过去(这会告诉你我年纪有多大了),曾经是软盘、然后是 Zip 磁盘、U 盘、SCP、Rsync、Dropbox、ownCloud,你想到的都试过。但这些似乎对我都不够好。 + +然后我偶然发现了 [Syncthing][2]。 + +![syncthing console][3] + +Syncthing 是一个轻量级的点对点文件同步系统。你不需要为服务付费,也不需要第三方服务器,而且速度很快。以我的经验,比文件同步中的许多“大牌”要快得多。 + +Syncthing 可在 Linux、MacOS、Windows 和多种 BSD 中使用。还有一个 Android 应用(但尚无官方 iOS 版本)。以上所有终端都有方便的图形化前端(尽管我不会在这里介绍)。在 Linux 上,大多数发行版都有可用的软件包,因此安装非常简单。 + +![Installing Syncthing on Ubuntu][4] + +首次启动 Syncthing 时,它将启动 Web 浏览器以配置守护程序。第一台计算机上没有太多要做,但是这是一个很好的机会来介绍一下用户界面 (UI)。最重要的是在右上方的 “Actions” 菜单下的 “System ID”。 + +![Machine ID][5] + +设置第一台计算机后,请在第二台计算机上重复安装。在 UI 中,右下方将显示一个按钮,名为 “Add Remote Device”。单击该按钮,你将会看到一个要求输入 “Device ID and a Name” 的框。从第一台计算机上复制并粘贴 “Device ID”,然后单击 “Save”。 + +你应该会在第一台上看到一个请求添加第二台的弹出窗口。接受后,新机器将显示在第一台机器的右下角。与第二台计算机共享默认目录。单击 “Default Folder”,然后单击 “Edit” 按钮。弹出窗口的顶部有四个链接。单击 “Sharing”,然后选择第二台计算机。单击 “Save”,然后查看第二台计算机。你会看到一个接受共享目录的提示。接受后,它将开始在两台计算机之间同步文件。 + +![Sharing a directory in Syncthing][6] + +测试从一台计算机上复制文件到默认目录(“/你的家目录/Share”)。它应该很快会在另一台上出现。 + +你可以根据需要添加任意数量的目录,这非常方便。如你在第一张图中所看到的,我有一个用于保存配置的 `myconfigs` 文件夹。当我买了一台新机器时,我只需安装 Syncthing,如果我在一台机器上调整了配置,我不必更新所有,它会自动更新。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/sync-files-syncthing + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: https://syncthing.net/ +[3]: https://opensource.com/sites/default/files/uploads/productivity_1-1.png (syncthing console) +[4]: https://opensource.com/sites/default/files/uploads/productivity_1-2.png (Installing Syncthing on Ubuntu) +[5]: https://opensource.com/sites/default/files/uploads/productivity_1-3.png (Machine ID) +[6]: https://opensource.com/sites/default/files/uploads/productivity_1-4.png (Sharing a directory in Syncthing) diff --git a/published/202001/20200112 Use Stow for configuration management of multiple machines.md b/published/202001/20200112 Use Stow for configuration management of multiple machines.md new file mode 100644 index 0000000000..cf673d3e6b --- /dev/null +++ b/published/202001/20200112 Use Stow for configuration management of multiple machines.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11796-1.html) +[#]: subject: (Use Stow for configuration management of multiple machines) +[#]: via: (https://opensource.com/article/20/1/configuration-management-stow) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Stow 管理多台机器配置 +====== +> 2020 年,在我们的 20 个使用开源提升生产力的系列文章中,让我们了解如何使用 Stow 跨机器管理配置。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/141330jdcjalqzjal84a03.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Stow 管理符号链接 + +昨天,我解释了如何使用 [Syncthing][2] 在多台计算机上保持文件同步。但是,这只是我用来保持配置一致性的工具之一。还有另一个表面上看起来更简单的工具:[Stow][3]。 + +![Stow help screen][4] + +Stow 管理符号链接。默认情况下,它会链接目录到上一级目录。还有设置源和目标目录的选项,但我通常不使用它们。 + +正如我在 Syncthing 的[文章][5] 中提到的,我使用 Syncthing 来保持 `myconfigs` 目录在我所有的计算机上一致。`myconfigs` 目录下面有多个子目录。每个子目录包含我经常使用的应用之一的配置文件。 + +![myconfigs directory][6] + +在每台计算机上,我进入 `myconfigs` 目录,并运行 `stow -S <目录名称>` 以将目录中的文件符号链接到我的家目录。例如,在 `vim` 目录下,我有 `.vimrc` 和 `.vim` 目录。在每台机器上,我运行 `stow -S vim` 来创建符号链接 `~/.vimrc` 和 `~/.vim`。当我在一台计算机上更改 Vim 配置时,它会应用到我的所有机器上。 + +然而,有时候,我需要一些特定于机器的配置,这就是为什么我有如 `msmtp-personal` 和 `msmtp-elastic`(我的雇主)这样的目录。由于我的 `msmtp` SMTP 客户端需要知道要中继电子邮件服务器,并且每个服务器都有不同的设置和凭据,我会使用 `-D` 标志来取消链接,接着链接另外一个。 + +![Unstow one, stow the other][7] + +有时我要给配置添加文件。为此,有一个 `-R` 选项来“重新链接”。例如,我喜欢在图形化 Vim 中使用一种与控制台不同的特定字体。除了标准 `.vimrc` 文件,`.gvimrc` 文件能让我设置特定于图形化版本的选项。当我第一次设置它时,我移动 `~/.gvimrc` 到 `~/myconfigs/vim` 中,然后运行 `stow -R vim`,它取消链接并重新链接该目录中的所有内容。 + +Stow 让我使用一个简单的命令行在多种配置之间切换,并且,结合 Syncthing,我可以确保无论我身在何处或在哪里进行更改,我都有我喜欢的工具的设置。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/configuration-management-stow + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://syncthing.net/ +[3]: https://www.gnu.org/software/stow/ +[4]: https://opensource.com/sites/default/files/uploads/productivity_2-1.png (Stow help screen) +[5]: https://linux.cn/article-11793-1.html +[6]: https://opensource.com/sites/default/files/uploads/productivity_2-2.png (myconfigs directory) +[7]: https://opensource.com/sites/default/files/uploads/productivity_2-3.png (Unstow one, stow the other) diff --git a/published/202001/20200113 Keep your email in sync with OfflineIMAP.md b/published/202001/20200113 Keep your email in sync with OfflineIMAP.md new file mode 100644 index 0000000000..64ecd19ab6 --- /dev/null +++ b/published/202001/20200113 Keep your email in sync with OfflineIMAP.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11804-1.html) +[#]: subject: (Keep your email in sync with OfflineIMAP) +[#]: via: (https://opensource.com/article/20/1/sync-email-offlineimap) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 OfflineIMAP 同步邮件 +====== + +> 将邮件镜像保存到本地是整理消息的第一步。在我们的 20 个使用开源提升生产力的系列的第三篇文章中了解该如何做。 + +![](https://img.linux.net.cn/data/attachment/album/202001/20/235324nbgfyuwl98syowta.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 OfflineIMAP 在本地同步你的邮件 + +我与邮件之间存在爱恨交织的关系。我喜欢它让我与世界各地的人交流的方式。但是,像你们中的许多人一样,我收到过很多邮件,许多是来自邮件列表的,但也有很多垃圾邮件、广告等。这些积累了很多。 + +![The OfflineIMAP "blinkenlights" UI][2] + +我尝试过的大多数工具(除了大型邮件服务商外)都可以很好地处理大量邮件,它们都有一个共同点:它们都依赖于以 [Maildir][3] 格式存储的本地邮件副本。这其中最有用的是 [OfflineIMAP][4]。OfflineIMAP 是将 IMAP 邮箱镜像到本地 Maildir 文件夹树的 Python 脚本。我用它来创建邮件的本地副本并使其保持同步。大多数 Linux 发行版都包含它,并且可以通过 Python 的 pip 包管理器获得。 + +示例的最小配置文件是一个很好的模板。首先将其复制到 `~/.offlineimaprc`。我的看起来像这样: + +``` +[general] +accounts = LocalSync +ui=Quiet +autorefresh=30 + +[Account LocalSync] +localrepository = LocalMail +remoterepository = MirrorIMAP + +[Repository MirrorIMAP] +type = IMAP +remotehost = my.mail.server +remoteuser = myusername +remotepass = mypassword +auth_mechanisms = LOGIN +createfolder = true +ssl = yes +sslcacertfile = OS-DEFAULT + +[Repository LocalMail] +type = Maildir +localfolders = ~/Maildir +sep = . +createfolder = true +``` + +我的配置要做的是定义两个仓库:远程 IMAP 服务器和本地 Maildir 文件夹。还有一个**帐户**,告诉 OfflineIMAP 运行时要同步什么。你可以定义链接到不同仓库的多个帐户。除了本地复制外,这还允许你从一台 IMAP 服务器复制到另一台作为备份。 + +如果你有很多邮件,那么首次运行 OfflineIMAP 将花费一些时间。但是完成后,下次会花*少得多*的时间。你也可以将 OfflineIMAP 作为 cron 任务(我的偏好)或作为守护程序在仓库之间不断进行同步。其文档涵盖了所有这些内容以及 Gmail 等高级配置选项。 + +现在,我的邮件已在本地复制,并有多种工具用来加快搜索、归档和管理邮件的速度。这些我明天再说。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/sync-email-offlineimap + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/newsletter_email_mail_web_browser.jpg?itok=Lo91H9UH (email or newsletters via inbox and browser) +[2]: https://opensource.com/sites/default/files/uploads/productivity_3-1.png (The OfflineIMAP "blinkenlights" UI) +[3]: https://en.wikipedia.org/wiki/Maildir +[4]: http://www.offlineimap.org/ diff --git a/published/202001/20200113 setV- A Bash function to maintain Python virtual environments.md b/published/202001/20200113 setV- A Bash function to maintain Python virtual environments.md new file mode 100644 index 0000000000..45e4beaf52 --- /dev/null +++ b/published/202001/20200113 setV- A Bash function to maintain Python virtual environments.md @@ -0,0 +1,296 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11800-1.html) +[#]: subject: (setV: A Bash function to maintain Python virtual environments) +[#]: via: (https://opensource.com/article/20/1/setv-bash-function) +[#]: author: (Sachin Patil https://opensource.com/users/psachin) + +setV:一个管理 Python 虚拟环境的 Bash 函数 +====== + +> 了解一下 setV,它是一个轻量级的 Python 虚拟环境管理器,是 virtualenvwrapper 的替代产品。 + +![](https://img.linux.net.cn/data/attachment/album/202001/19/234306tvvg5ffwakrzr5vv.jpg) + +这一年多来,我的 [bash_scripts][3] 项目中悄悄隐藏这 [setV][2],但现在是时候该公开了。setV 是一个 Bash 函数,我可以用它代替 [virtualenvwrapper][4]。它提供了使你能够执行以下操作的基本功能: + +* 默认使用 Python 3 +* 创建一个新的虚拟环境 +* 使用带有 `-p`(或 `--python`)的自定义 Python 路径来创建新的虚拟环境 +* 删除现有的虚拟环境 +* 列出所有现有的虚拟环境 +* 使用制表符补全(以防你忘记虚拟环境名称) + +### 安装 + +要安装 setV,请下载该脚本: + +``` +curl https://gitlab.com/psachin/setV/raw/master/install.sh +``` + +审核一下脚本,然后运行它: + +``` +sh ./install.sh +``` + +当安装 setV 时,安装脚本会要求你引入(`source`)一下 `~/.bashrc` 或 `~/.bash_profile` 的配置,根据你的喜好选择一个。 + +### 用法 + +基本的命令格式是 `setv`。 + +#### 创建虚拟环境 + +``` +setv --new rango  # setv -n rango + +# 或使用定制的 Python 路径 +setv --new --python /opt/python/python3 rango  # setv -n -p /opt/python/python3 rango +``` + +#### 激活已有的虚拟环境 + +``` +setv VIRTUAL_ENVIRONMENT_NAME +``` + +``` +# 示例 +setv rango +``` + +#### 列出所有的虚拟环境 + +``` +setv --list +# 或 +setv [TAB] [TAB] +``` + +#### 删除虚拟环境 + +``` +setv --delete rango +``` + +#### 切换到另外一个虚拟环境 + +``` +# 假设你现在在 'rango',切换到 'tango' +setv tango +``` + +#### 制表符补完 + +如果你不完全记得虚拟环境的名称,则 Bash 式的制表符补全也可以适用于虚拟环境名称。 + +### 参与其中 + +setV 在 GNU [GPLv3][5]下开源,欢迎贡献。要了解更多信息,请访问它的 GitLab 存储库中的 setV 的 [README][6] 的贡献部分。 + +### setV 脚本 + +``` +#!/usr/bin/env bash +# setV - A Lightweight Python virtual environment manager. +# Author: Sachin (psachin) +# Author's URL: https://psachin.gitlab.io/about +# +# License: GNU GPL v3, See LICENSE file +# +# Configure(Optional): +# Set `SETV_VIRTUAL_DIR_PATH` value to your virtual environments +# directory-path. By default it is set to '~/virtualenvs/' +# +# Usage: +# Manual install: Added below line to your .bashrc or any local rc script(): +# --- +# source /path/to/virtual.sh +# --- +# +# Now you can 'activate' the virtual environment by typing +# $ setv +# +# For example: +# $ setv rango +# +# or type: +# setv [TAB] [TAB] (to list all virtual envs) +# +# To list all your virtual environments: +# $ setv --list +# +# To create new virtual environment: +# $ setv --new new_virtualenv_name +# +# To delete existing virtual environment: +# $ setv --delete existing_virtualenv_name +# +# To deactivate, type: +# $ deactivate + +# Path to virtual environment directory +SETV_VIRTUAL_DIR_PATH="$HOME/virtualenvs/" +# Default python version to use. This decides whether to use `virtualenv` or `python3 -m venv` +SETV_PYTHON_VERSION=3 # Defaults to Python3 +SETV_PY_PATH=$(which python${SETV_PYTHON_VERSION}) + +function _setvcomplete_() +{ + # Bash-autocompletion. + # This ensures Tab-auto-completions work for virtual environment names. + local cmd="${1##*/}" # to handle command(s). + # Not necessary as such. 'setv' is the only command + + local word=${COMP_WORDS[COMP_CWORD]} # Words thats being completed + local xpat='${word}' # Filter pattern. Include + # only words in variable '$names' + local names=$(ls -l "${SETV_VIRTUAL_DIR_PATH}" | egrep '^d' | awk -F " " '{print $NF}') # Virtual environment names + + COMPREPLY=($(compgen -W "$names" -X "$xpat" -- "$word")) # compgen generates the results +} + +function _setv_help_() { + # Echo help/usage message + echo "Usage: setv [OPTIONS] [NAME]" + echo Positional argument: + echo -e "NAME Activate virtual env." + echo Optional arguments: + echo -e "-l, --list List all Virtual Envs." + echo -e "-n, --new NAME Create a new Python Virtual Env." + echo -e "-d, --delete NAME Delete existing Python Virtual Env." + echo -e "-p, --python PATH Python binary path." +} + +function _setv_custom_python_path() +{ + if [ -f "${1}" ]; + then + if [ "`expr $1 : '.*python\([2,3]\)'`" = "3" ]; + then + SETV_PYTHON_VERSION=3 + else + SETV_PYTHON_VERSION=2 + fi + SETV_PY_PATH=${1} + _setv_create $2 + else + echo "Error: Path ${1} does not exist!" + fi +} + +function _setv_create() +{ + # Creates new virtual environment if ran with -n|--new flag + if [ -z ${1} ]; + then + echo "You need to pass virtual environment name" + _setv_help_ + else + echo "Creating new virtual environment with the name: $1" + + if [ ${SETV_PYTHON_VERSION} -eq 3 ]; + then + ${SETV_PY_PATH} -m venv ${SETV_VIRTUAL_DIR_PATH}${1} + else + virtualenv -p ${SETV_PY_PATH} ${SETV_VIRTUAL_DIR_PATH}${1} + fi + + echo "You can now activate the Python virtual environment by typing: setv ${1}" + fi +} + +function _setv_delete() +{ + # Deletes virtual environment if ran with -d|--delete flag + # TODO: Refactor + if [ -z ${1} ]; + then + echo "You need to pass virtual environment name" + _setv_help_ + else + if [ -d ${SETV_VIRTUAL_DIR_PATH}${1} ]; + then + read -p "Really delete this virtual environment(Y/N)? " yes_no + case $yes_no in + Y|y) rm -rvf ${SETV_VIRTUAL_DIR_PATH}${1};; + N|n) echo "Leaving the virtual environment as it is.";; + *) echo "You need to enter either Y/y or N/n" + esac + else + echo "Error: No virtual environment found by the name: ${1}" + fi + fi +} + +function _setv_list() +{ + # Lists all virtual environments if ran with -l|--list flag + echo -e "List of virtual environments you have under ${SETV_VIRTUAL_DIR_PATH}:\n" + for virt in $(ls -l "${SETV_VIRTUAL_DIR_PATH}" | egrep '^d' | awk -F " " '{print $NF}') + do + echo ${virt} + done +} + +function setv() { + # Main function + if [ $# -eq 0 ]; + then + _setv_help_ + elif [ $# -le 3 ]; + then + case "${1}" in + -n|--new) _setv_create ${2};; + -d|--delete) _setv_delete ${2};; + -l|--list) _setv_list;; + *) if [ -d ${SETV_VIRTUAL_DIR_PATH}${1} ]; + then + # Activate the virtual environment + source ${SETV_VIRTUAL_DIR_PATH}${1}/bin/activate + else + # Else throw an error message + echo "Sorry, you don't have any virtual environment with the name: ${1}" + _setv_help_ + fi + ;; + esac + elif [ $# -le 5 ]; + then + case "${2}" in + -p|--python) _setv_custom_python_path ${3} ${4};; + *) _setv_help_;; + esac + fi +} + +# Calls bash-complete. The compgen command accepts most of the same +# options that complete does but it generates results rather than just +# storing the rules for future use. +complete -F _setvcomplete_ setv +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/setv-bash-function + +作者:[Sachin Patil][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/psachin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://gitlab.com/psachin/setV +[3]: https://github.com/psachin/bash_scripts +[4]: https://virtualenvwrapper.readthedocs.org/ +[5]: https://gitlab.com/psachin/setV/blob/master/LICENSE +[6]: https://gitlab.com/psachin/setV/blob/master/ReadMe.org +[7]: mailto:iclcoolster@gmail.com diff --git a/published/202001/20200114 Organize your email with Notmuch.md b/published/202001/20200114 Organize your email with Notmuch.md new file mode 100644 index 0000000000..dc9a67f7d6 --- /dev/null +++ b/published/202001/20200114 Organize your email with Notmuch.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11807-1.html) +[#]: subject: (Organize your email with Notmuch) +[#]: via: (https://opensource.com/article/20/1/organize-email-notmuch) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Notmuch 组织你的邮件 +====== + +> Notmuch 可以索引、标记和排序电子邮件。在我们的 20 个使用开源提升生产力的系列的第四篇文章中了解该如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/202001/22/112231xg5dgv6f6g5a1iv1.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用 Notmuch 为你的邮件建立索引 + +昨天,我谈到了如何使用 OfflineIMAP [将我的邮件同步][2]到本地计算机。今天,我将讨论如何在阅读之前预处理所有邮件。 + +![Notmuch][3] + +[Maildir][4] 可能是最有用的邮件存储格式之一。有很多工具可以帮助你管理邮件。我经常使用一个名为 [Notmuch][5] 的小程序,它能索引、标记和搜索邮件。Notmuch 配合其他几个程序一起使用可以使处理大量邮件更加容易。 + +大多数 Linux 发行版都包含 Notmuch,你也可以在 MacOS 上获得它。Windows 用户可以通过 Linux 的 Windows 子系统([WSL][6])访问它,但可能需要进行一些其他调整。 + +![Notmuch's first run][7] + +Notmuch 首次运行时,它将询问你一些问题,并在家目录中创建 `.notmuch-config` 文件。接下来,运行 `notmuch new` 来索引并标记所有邮件。你可以使用 `notmuch search tag:new` 进行验证,它会找到所有带有 `new` 标签的消息。这可能会有很多邮件,因为 Notmuch 使用 `new` 标签来指示新邮件,因此你需要对其进行清理。 + +运行 `notmuch search tag:unread` 来查找未读消息,这会减少很多邮件。要从你已阅读的消息中删除 `new` 标签,请运行 `notmuch tag -new not tag:unread`,它将搜索所有没有 `unread` 标签的消息,并从其中删除 `new` 标签。现在,当你运行 `notmuch search tag:new` 时,它将仅显示未读邮件。 + +但是,批量标记消息可能更有用,因为在每次运行时手动更新标记可能非常繁琐。`--batch` 命令行选项告诉 Notmuch 读取多行命令并执行它们。还有一个 `--input=filename` 选项,该选项从文件中读取命令并应用它们。我有一个名为 `tagmail.notmuch` 的文件,用于给“新”邮件添加标签;它看起来像这样: + +``` +# Manage sent, spam, and trash folders +-unread -new folder:Trash +-unread -new folder:Spam +-unread -new folder:Sent + +# Note mail sent specifically to me (excluding bug mail) ++to-me to:kevin at sonney.com and tag:new and not tag:to-me + +# And note all mail sent from me ++sent from:kevin at sonney.com and tag:new and not tag:sent + +# Remove the new tag from messages +-new tag:new +``` + +我可以在运行 `notmuch new` 后运行 `notmuch tag --input=tagmail.notmuch` 批量处理我的邮件,之后我也可以搜索这些标签。 + +Notmuch 还支持 `pre-new` 和 `post-new` 钩子。这些脚本存放在 `Maildir/.notmuch/hooks` 中,它们定义了在使用 `notmuch new` 索引新邮件之前(`pre-new`)和之后(`post-new`)要做的操作。在昨天的文章中,我谈到了使用 [OfflineIMAP][8] 同步来自 IMAP 服务器的邮件。从 `pre-new` 钩子运行它非常容易: + + +``` +#!/bin/bash +# Remove the new tag from messages that are still tagged as new +notmuch tag -new tag:new + +# Sync mail messages +offlineimap -a LocalSync -u quiet +``` + +你还可以使用可以操作 Notmuch 数据库的 Python 应用 [afew][9],来为你标记*邮件列表*和*垃圾邮件*。你可以用类似的方法在 `post-new` 钩子中使用 `afew`: + +``` +#!/bin/bash +# tag with my custom tags +notmuch tag --input=~/tagmail.notmuch + +# Run afew to tag new mail +afew -t -n +``` + +我建议你在使用 `afew` 标记邮件时,不要使用 `[ListMailsFilter]`,因为某些邮件处理程序会在邮件中添加模糊或者彻头彻尾是垃圾的列表标头(我说的就是你 Google)。 + +![alot email client][10] + +此时,任何支持 Notmuch 或 Maildir 的邮件阅读器都可以读取我的邮件。有时,我会使用 [alot][11](一个 Notmuch 特定的客户端)在控制台中阅读邮件,但是它不像其他邮件阅读器那么美观。 + +在接下来的几天,我将向你展示其他一些邮件客户端,它们可能会与你在使用的工具集成在一起。同时,请查看可与 Maildir 邮箱一起使用的其他工具。你可能会发现我没发现的好东西。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/organize-email-notmuch + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/files_documents_organize_letter.png?itok=GTtiiabr (Filing cabinet for organization) +[2]: https://linux.cn/article-11804-1.html +[3]: https://opensource.com/sites/default/files/uploads/productivity_4-1.png (Notmuch) +[4]: https://en.wikipedia.org/wiki/Maildir +[5]: https://notmuchmail.org/ +[6]: https://docs.microsoft.com/en-us/windows/wsl/install-win10 +[7]: https://opensource.com/sites/default/files/uploads/productivity_4-2.png (Notmuch's first run) +[8]: http://www.offlineimap.org/ +[9]: https://afew.readthedocs.io/en/latest/index.html +[10]: https://opensource.com/sites/default/files/uploads/productivity_4-3.png (alot email client) +[11]: https://github.com/pazz/alot diff --git a/published/202001/20200115 6 handy Bash scripts for Git.md b/published/202001/20200115 6 handy Bash scripts for Git.md new file mode 100644 index 0000000000..8a43bb3220 --- /dev/null +++ b/published/202001/20200115 6 handy Bash scripts for Git.md @@ -0,0 +1,510 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11797-1.html) +[#]: subject: (6 handy Bash scripts for Git) +[#]: via: (https://opensource.com/article/20/1/bash-scripts-git) +[#]: author: (Bob Peterson https://opensource.com/users/bobpeterson) + +6 个方便的 Git 脚本 +====== + +> 当使用 Git 存储库时,这六个 Bash 脚本将使你的生活更轻松。 + +![](https://img.linux.net.cn/data/attachment/album/202001/18/231713jegbk8fyek798gxb.jpg) + +我编写了许多 Bash 脚本,这些脚本使我在使用 Git 存储库时工作更加轻松。我的许多同事说没有必要:我所做的一切都可以用 Git 命令完成。虽然这可能是正确的,但我发现脚本远比尝试找出适当的 Git 命令来执行我想要的操作更加方便。 + +### 1、gitlog + +`gitlog` 打印针对 master 分支的当前补丁的简短列表。它从最旧到最新打印它们,并显示作者和描述,其中 `H` 代表 `HEAD`,`^` 代表 `HEAD^`,`2` 代表 `HEAD~2`,依此类推。例如: + +``` +$ gitlog +-----------------------[ recovery25 ]----------------------- +(snip) +11 340d27a33895 Bob Peterson gfs2: drain the ail2 list after io errors +10 9b3c4e6efb10 Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode + 9 d2e8c22be39b Bob Peterson gfs2: Do proper error checking for go_sync family of glops + 8 9563e31f8bfd Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite + 7 ebac7a38036c Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing + 6 f703a3c27874 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency + 5 a3e86d2ef30e Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite + 4 da3c604755b0 Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite + 3 4525c2f5b46f Bob Peterson Rafael Aquini's slab instrumentation + 2 a06a5b7dea02 Bob Peterson GFS2: Add go_get_holdtime to gl_ops + ^ 8ba93c796d5c Bob Peterson gfs2: introduce new function remaining_hold_time and use it in dq + H e8b5ff851bb9 Bob Peterson gfs2: Allow rgrps to have a minimum hold time +``` + +如果我想查看其他分支上有哪些补丁,可以指定一个替代分支: + +``` +$ gitlog recovery24 +``` + +### 2、gitlog.id + +`gitlog.id` 只是打印出补丁的 SHA1 ID: + +``` +$ gitlog.id +-----------------------[ recovery25 ]----------------------- +56908eeb6940 2ca4a6b628a1 fc64ad5d99fe 02031a00a251 f6f38da7dd18 d8546e8f0023 fc3cc1f98f6b 12c3e0cb3523 76cce178b134 6fc1dce3ab9c 1b681ab074ca 26fed8de719b 802ff51a5670 49f67a512d8c f04f20193bbb 5f6afe809d23 2030521dc70e dada79b3be94 9b19a1e08161 78a035041d3e f03da011cae2 0d2b2e068fcd 2449976aa133 57dfb5e12ccd 53abedfdcf72 6fbdda3474b3 49544a547188 187032f7a63c 6f75dae23d93 95fc2a261b00 ebfb14ded191 f653ee9e414a 0e2911cb8111 73968b76e2e3 8a3e4cb5e92c a5f2da803b5b 7c9ef68388ed 71ca19d0cba8 340d27a33895 9b3c4e6efb10 d2e8c22be39b 9563e31f8bfd ebac7a38036c f703a3c27874 a3e86d2ef30e da3c604755b0 4525c2f5b46f a06a5b7dea02 8ba93c796d5c e8b5ff851bb9 +``` + +同样,它假定是当前分支,但是如果需要,我可以指定其他分支。 + +### 3、gitlog.id2 + +`gitlog.id2` 与 `gitlog.id` 相同,但顶部没有显示分支的行。这对于从一个分支挑选所有补丁到当前分支很方便: + +``` +$ # 创建一个新分支 +$ git branch --track origin/master +$ # 检出刚刚创建的新分支 +$ git checkout recovery26 +$ # 从旧的分支挑选所有补丁到新分支 +$ for i in `gitlog.id2 recovery25` ; do git cherry-pick $i ;done +``` + +### 4、gitlog.grep + +`gitlog.grep` 会在该补丁集合中寻找一个字符串。例如,如果我发现一个错误并想修复引用了函数 `inode_go_sync` 的补丁,我可以简单地执行以下操作: + +``` +$ gitlog.grep inode_go_sync +-----------------------[ recovery25 - 50 patches ]----------------------- +(snip) +11 340d27a33895 Bob Peterson gfs2: drain the ail2 list after io errors +10 9b3c4e6efb10 Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode + 9 d2e8c22be39b Bob Peterson gfs2: Do proper error checking for go_sync family of glops +152:-static void inode_go_sync(struct gfs2_glock *gl) +153:+static int inode_go_sync(struct gfs2_glock *gl) +163:@@ -296,6 +302,7 @@ static void inode_go_sync(struct gfs2_glock *gl) + 8 9563e31f8bfd Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite + 7 ebac7a38036c Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing + 6 f703a3c27874 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency + 5 a3e86d2ef30e Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite + 4 da3c604755b0 Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite + 3 4525c2f5b46f Bob Peterson Rafael Aquini's slab instrumentation + 2 a06a5b7dea02 Bob Peterson GFS2: Add go_get_holdtime to gl_ops + ^ 8ba93c796d5c Bob Peterson gfs2: introduce new function remaining_hold_time and use it in dq + H e8b5ff851bb9 Bob Peterson gfs2: Allow rgrps to have a minimum hold time +``` + +因此,现在我知道补丁 `HEAD~9` 是需要修复的补丁。我使用 `git rebase -i HEAD~10` 编辑补丁 9,`git commit -a --amend`,然后 `git rebase --continue` 以进行必要的调整。 + +### 5、gitbranchcmp3 + +`gitbranchcmp3` 使我可以将当前分支与另一个分支进行比较,因此我可以将较旧版本的补丁与我的较新版本进行比较,并快速查看已更改和未更改的内容。它生成一个比较脚本(使用了 KDE 工具 [Kompare][2],该工具也可在 GNOME3 上使用)以比较不太相同的补丁。如果除行号外没有其他差异,则打印 `[SAME]`。如果仅存在注释差异,则打印 `[same]`(小写)。例如: + +``` +$ gitbranchcmp3 recovery24 +Branch recovery24 has 47 patches +Branch recovery25 has 50 patches + +(snip) +38 87eb6901607a 340d27a33895 [same] gfs2: drain the ail2 list after io errors +39 90fefb577a26 9b3c4e6efb10 [same] gfs2: clean up iopen glock mess in gfs2_create_inode +40 ba3ae06b8b0e d2e8c22be39b [same] gfs2: Do proper error checking for go_sync family of glops +41 2ab662294329 9563e31f8bfd [SAME] gfs2: use page_offset in gfs2_page_mkwrite +42 0adc6d817b7a ebac7a38036c [SAME] gfs2: don't use buffer_heads in gfs2_allocate_page_backing +43 55ef1f8d0be8 f703a3c27874 [SAME] gfs2: Improve mmap write vs. punch_hole consistency +44 de57c2f72570 a3e86d2ef30e [SAME] gfs2: Multi-block allocations in gfs2_page_mkwrite +45 7c5305fbd68a da3c604755b0 [SAME] gfs2: Fix end-of-file handling in gfs2_page_mkwrite +46 162524005151 4525c2f5b46f [SAME] Rafael Aquini's slab instrumentation +47 a06a5b7dea02 [ ] GFS2: Add go_get_holdtime to gl_ops +48 8ba93c796d5c [ ] gfs2: introduce new function remaining_hold_time and use it in dq +49 e8b5ff851bb9 [ ] gfs2: Allow rgrps to have a minimum hold time + +Missing from recovery25: +The missing: +Compare script generated at: /tmp/compare_mismatches.sh +``` + +### 6、gitlog.find + +最后,我有一个 `gitlog.find` 脚本,可以帮助我识别补丁程序的上游版本在哪里以及每个补丁的当前状态。它通过匹配补丁说明来实现。它还会生成一个比较脚本(再次使用了 Kompare),以将当前补丁与上游对应补丁进行比较: + +``` +$ gitlog.find +-----------------------[ recovery25 - 50 patches ]----------------------- +(snip) +11 340d27a33895 Bob Peterson gfs2: drain the ail2 list after io errors +lo 5bcb9be74b2a Bob Peterson gfs2: drain the ail2 list after io errors +10 9b3c4e6efb10 Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode +fn 2c47c1be51fb Bob Peterson gfs2: clean up iopen glock mess in gfs2_create_inode + 9 d2e8c22be39b Bob Peterson gfs2: Do proper error checking for go_sync family of glops +lo feb7ea639472 Bob Peterson gfs2: Do proper error checking for go_sync family of glops + 8 9563e31f8bfd Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite +ms f3915f83e84c Christoph Hellwig gfs2: use page_offset in gfs2_page_mkwrite + 7 ebac7a38036c Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing +ms 35af80aef99b Christoph Hellwig gfs2: don't use buffer_heads in gfs2_allocate_page_backing + 6 f703a3c27874 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency +fn 39c3a948ecf6 Andreas Gruenbacher gfs2: Improve mmap write vs. punch_hole consistency + 5 a3e86d2ef30e Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite +fn f53056c43063 Andreas Gruenbacher gfs2: Multi-block allocations in gfs2_page_mkwrite + 4 da3c604755b0 Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite +fn 184b4e60853d Andreas Gruenbacher gfs2: Fix end-of-file handling in gfs2_page_mkwrite + 3 4525c2f5b46f Bob Peterson Rafael Aquini's slab instrumentation + Not found upstream + 2 a06a5b7dea02 Bob Peterson GFS2: Add go_get_holdtime to gl_ops + Not found upstream + ^ 8ba93c796d5c Bob Peterson gfs2: introduce new function remaining_hold_time and use it in dq + Not found upstream + H e8b5ff851bb9 Bob Peterson gfs2: Allow rgrps to have a minimum hold time + Not found upstream +Compare script generated: /tmp/compare_upstream.sh +``` + +补丁显示为两行,第一行是你当前的修补程序,然后是相应的上游补丁,以及 2 个字符的缩写,以指示其上游状态: + +* `lo` 表示补丁仅在本地(`local`)上游 Git 存储库中(即尚未推送到上游)。 +* `ms` 表示补丁位于 Linus Torvald 的主(`master`)分支中。 +* `fn` 意味着补丁被推送到我的 “for-next” 开发分支,用于下一个上游合并窗口。 +   +我的一些脚本根据我通常使用 Git 的方式做出假设。例如,当搜索上游补丁时,它使用我众所周知的 Git 树的位置。因此,你需要调整或改进它们以适合你的条件。`gitlog.find` 脚本旨在仅定位 [GFS2][3] 和 [DLM][4] 补丁,因此,除非你是 GFS2 开发人员,否则你需要针对你感兴趣的组件对其进行自定义。 + +### 源代码 + +以下是这些脚本的源代码。 + +#### 1、gitlog + +``` +#!/bin/bash +branch=$1 + +if test "x$branch" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +patches=0 +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +LIST=`git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' '` +for i in $LIST; do patches=$(echo $patches + 1 | bc);done + +if [[ $branch =~ .*for-next.* ]] +then + start=HEAD +# start=origin/for-next +else + start=origin/master +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +/usr/bin/echo "-----------------------[" $branch "]-----------------------" +patches=$(echo $patches - 1 | bc); +for i in $LIST; do + if [ $patches -eq 1 ]; then + cnt=" ^" + elif [ $patches -eq 0 ]; then + cnt=" H" + else + if [ $patches -lt 10 ]; then + cnt=" $patches" + else + cnt="$patches" + fi + fi + /usr/bin/git show --abbrev-commit -s --pretty=format:"$cnt %h %<|(32)%an %s %n" $i + patches=$(echo $patches - 1 | bc) +done +#git log --reverse --abbrev-commit --pretty=format:"%h %<|(32)%an %s" $tracking..$branch +#git log --reverse --abbrev-commit --pretty=format:"%h %<|(32)%an %s" ^origin/master ^linux-gfs2/for-next $branch +``` + +#### 2、gitlog.id + +``` +#!/bin/bash +branch=$1 + +if test "x$branch" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +/usr/bin/echo "-----------------------[" $branch "]-----------------------" +git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' ' +``` + +#### 3、gitlog.id2 + +``` +#!/bin/bash +branch=$1 + +if test "x$branch" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` +git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' ' +``` + +#### 4、gitlog.grep + +``` +#!/bin/bash +param1=$1 +param2=$2 + +if test "x$param2" = x; then + branch=`git branch -a | grep "*" | cut -d ' ' -f2` + string=$param1 +else + branch=$param1 + string=$param2 +fi + +patches=0 +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +LIST=`git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' '` +for i in $LIST; do patches=$(echo $patches + 1 | bc);done +/usr/bin/echo "-----------------------[" $branch "-" $patches "patches ]-----------------------" +patches=$(echo $patches - 1 | bc); +for i in $LIST; do + if [ $patches -eq 1 ]; then + cnt=" ^" + elif [ $patches -eq 0 ]; then + cnt=" H" + else + if [ $patches -lt 10 ]; then + cnt=" $patches" + else + cnt="$patches" + fi + fi + /usr/bin/git show --abbrev-commit -s --pretty=format:"$cnt %h %<|(32)%an %s" $i + /usr/bin/git show --pretty=email --patch-with-stat $i | grep -n "$string" + patches=$(echo $patches - 1 | bc) +done +``` + +#### 5、gitbranchcmp3 + +``` +#!/bin/bash +# +# gitbranchcmp3 [] +# +oldbranch=$1 +newbranch=$2 +script=/tmp/compare_mismatches.sh + +/usr/bin/rm -f $script +echo "#!/bin/bash" > $script +/usr/bin/chmod 755 $script +echo "# Generated by gitbranchcmp3.sh" >> $script +echo "# Run this script to compare the mismatched patches" >> $script +echo " " >> $script +echo "function compare_them()" >> $script +echo "{" >> $script +echo " git show --pretty=email --patch-with-stat \$1 > /tmp/gronk1" >> $script +echo " git show --pretty=email --patch-with-stat \$2 > /tmp/gronk2" >> $script +echo " kompare /tmp/gronk1 /tmp/gronk2" >> $script +echo "}" >> $script +echo " " >> $script + +if test "x$newbranch" = x; then + newbranch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi + +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +declare -a oldsha1s=(`git log --reverse --abbrev-commit --pretty=oneline $tracking..$oldbranch | cut -d ' ' -f1 |paste -s -d ' '`) +declare -a newsha1s=(`git log --reverse --abbrev-commit --pretty=oneline $tracking..$newbranch | cut -d ' ' -f1 |paste -s -d ' '`) + +#echo "old: " $oldsha1s +oldcount=${#oldsha1s[@]} +echo "Branch $oldbranch has $oldcount patches" +oldcount=$(echo $oldcount - 1 | bc) +#for o in `seq 0 ${#oldsha1s[@]}`; do +# echo -n ${oldsha1s[$o]} " " +# desc=`git show $i | head -5 | tail -1|cut -b5-` +#done + +#echo "new: " $newsha1s +newcount=${#newsha1s[@]} +echo "Branch $newbranch has $newcount patches" +newcount=$(echo $newcount - 1 | bc) +#for o in `seq 0 ${#newsha1s[@]}`; do +# echo -n ${newsha1s[$o]} " " +# desc=`git show $i | head -5 | tail -1|cut -b5-` +#done +echo + +for new in `seq 0 $newcount`; do + newsha=${newsha1s[$new]} + newdesc=`git show $newsha | head -5 | tail -1|cut -b5-` + oldsha=" " + same="[ ]" + for old in `seq 0 $oldcount`; do + if test "${oldsha1s[$old]}" = "match"; then + continue; + fi + olddesc=`git show ${oldsha1s[$old]} | head -5 | tail -1|cut -b5-` + if test "$olddesc" = "$newdesc" ; then + oldsha=${oldsha1s[$old]} + #echo $oldsha + git show $oldsha |tail -n +2 |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk1 + git show $newsha |tail -n +2 |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk2 + diff /tmp/gronk1 /tmp/gronk2 &> /dev/null + if [ $? -eq 0 ] ;then +# No differences + same="[SAME]" + oldsha1s[$old]="match" + break + fi + git show $oldsha |sed -n '/diff/,$p' |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk1 + git show $newsha |sed -n '/diff/,$p' |grep -v "index.*\.\." |grep -v "@@" > /tmp/gronk2 + diff /tmp/gronk1 /tmp/gronk2 &> /dev/null + if [ $? -eq 0 ] ;then +# Differences in comments only + same="[same]" + oldsha1s[$old]="match" + break + fi + oldsha1s[$old]="match" + echo "compare_them $oldsha $newsha" >> $script + fi + done + echo "$new $oldsha $newsha $same $newdesc" +done + +echo +echo "Missing from $newbranch:" +the_missing="" +# Now run through the olds we haven't matched up +for old in `seq 0 $oldcount`; do + if test ${oldsha1s[$old]} != "match"; then + olddesc=`git show ${oldsha1s[$old]} | head -5 | tail -1|cut -b5-` + echo "${oldsha1s[$old]} $olddesc" + the_missing=`echo "$the_missing ${oldsha1s[$old]}"` + fi +done + +echo "The missing: " $the_missing +echo "Compare script generated at: $script" +#git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' ' +``` + +#### 6、gitlog.find + +``` +#!/bin/bash +# +# Find the upstream equivalent patch +# +# gitlog.find +# +cwd=$PWD +param1=$1 +ubranch=$2 +patches=0 +script=/tmp/compare_upstream.sh +echo "#!/bin/bash" > $script +/usr/bin/chmod 755 $script +echo "# Generated by gitbranchcmp3.sh" >> $script +echo "# Run this script to compare the mismatched patches" >> $script +echo " " >> $script +echo "function compare_them()" >> $script +echo "{" >> $script +echo " cwd=$PWD" >> $script +echo " git show --pretty=email --patch-with-stat \$2 > /tmp/gronk2" >> $script +echo " cd ~/linux.git/fs/gfs2" >> $script +echo " git show --pretty=email --patch-with-stat \$1 > /tmp/gronk1" >> $script +echo " cd $cwd" >> $script +echo " kompare /tmp/gronk1 /tmp/gronk2" >> $script +echo "}" >> $script +echo " " >> $script + +#echo "Gathering upstream patch info. Please wait." +branch=`git branch -a | grep "*" | cut -d ' ' -f2` +tracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` + +cd ~/linux.git +if test "X${ubranch}" = "X"; then + ubranch=`git branch -a | grep "*" | cut -d ' ' -f2` +fi +utracking=`git rev-parse --abbrev-ref --symbolic-full-name @{u}` +# +# gather a list of gfs2 patches from master just in case we can't find it +# +#git log --abbrev-commit --pretty=format:" %h %<|(32)%an %s" master |grep -i -e "gfs2" -e "dlm" > /tmp/gronk +git log --reverse --abbrev-commit --pretty=format:"ms %h %<|(32)%an %s" master fs/gfs2/ > /tmp/gronk.gfs2 +# ms = in Linus's master +git log --reverse --abbrev-commit --pretty=format:"ms %h %<|(32)%an %s" master fs/dlm/ > /tmp/gronk.dlm + +cd $cwd +LIST=`git log --reverse --abbrev-commit --pretty=oneline $tracking..$branch | cut -d ' ' -f1 |paste -s -d ' '` +for i in $LIST; do patches=$(echo $patches + 1 | bc);done +/usr/bin/echo "-----------------------[" $branch "-" $patches "patches ]-----------------------" +patches=$(echo $patches - 1 | bc); +for i in $LIST; do + if [ $patches -eq 1 ]; then + cnt=" ^" + elif [ $patches -eq 0 ]; then + cnt=" H" + else + if [ $patches -lt 10 ]; then + cnt=" $patches" + else + cnt="$patches" + fi + fi + /usr/bin/git show --abbrev-commit -s --pretty=format:"$cnt %h %<|(32)%an %s" $i + desc=`/usr/bin/git show --abbrev-commit -s --pretty=format:"%s" $i` + cd ~/linux.git + cmp=1 + up_eq=`git log --reverse --abbrev-commit --pretty=format:"lo %h %<|(32)%an %s" $utracking..$ubranch | grep "$desc"` +# lo = in local for-next + if test "X$up_eq" = "X"; then + up_eq=`git log --reverse --abbrev-commit --pretty=format:"fn %h %<|(32)%an %s" master..$utracking | grep "$desc"` +# fn = in for-next for next merge window + if test "X$up_eq" = "X"; then + up_eq=`grep "$desc" /tmp/gronk.gfs2` + if test "X$up_eq" = "X"; then + up_eq=`grep "$desc" /tmp/gronk.dlm` + if test "X$up_eq" = "X"; then + up_eq=" Not found upstream" + cmp=0 + fi + fi + fi + fi + echo "$up_eq" + if [ $cmp -eq 1 ] ; then + UP_SHA1=`echo $up_eq|cut -d' ' -f2` + echo "compare_them $UP_SHA1 $i" >> $script + fi + cd $cwd + patches=$(echo $patches - 1 | bc) +done +echo "Compare script generated: $script" +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/bash-scripts-git + +作者:[Bob Peterson][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bobpeterson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolseriesk12_rh_021x_0.png?itok=fvorN0e- (Digital hand surrounding by objects, bike, light bulb, graphs) +[2]: https://kde.org/applications/development/org.kde.kompare +[3]: https://en.wikipedia.org/wiki/GFS2 +[4]: https://en.wikipedia.org/wiki/Distributed_lock_manager diff --git a/published/202001/20200115 Organize and sync your calendar with khal and vdirsyncer.md b/published/202001/20200115 Organize and sync your calendar with khal and vdirsyncer.md new file mode 100644 index 0000000000..5ddb647095 --- /dev/null +++ b/published/202001/20200115 Organize and sync your calendar with khal and vdirsyncer.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11812-1.html) +[#]: subject: (Organize and sync your calendar with khal and vdirsyncer) +[#]: via: (https://opensource.com/article/20/1/open-source-calendar) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 khal 和 vdirsyncer 组织和同步你的日历 +====== + +> 保存和共享日历可能会有点麻烦。在我们的 20 个使用开源提升生产力的系列的第五篇文章中了解如何让它更简单。 + +![](https://img.linux.net.cn/data/attachment/album/202001/23/150009wsr3d5ovg4g1vzws.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 khal 和 vdirsyncer 跟踪你的日程 + +处理日历很*麻烦*,要找到好的工具总是很困难的。但是自从我去年将日历列为[我的“失败"之一][2]以来,我已经取得了一些进步。 + +目前使用日历最困难的是一直需要以某种方式在线共享。两种最受欢迎的在线日历是 Google Calendar 和 Microsoft Outlook/Exchange。两者都在公司环境中大量使用,这意味着我的日历必须支持其中之一或者两个。 + +![khal calendar][3] + +[Khal][4] 是基于控制台的日历,可以读取和写入 VCalendar 文件。它配置相当容易,但是不支持与其他应用同步。 + +幸运的是,khal 能与 [vdirsyncer][5] 一起使用,它是一个漂亮的命令行程序,可以将在线日历(和联系人,我将在另一篇文章中讨论)同步到本地磁盘。是的,它还可以上传新事件。 + +![vdirsyncer][6] + +Vdirsyncer 是个 Python 3 程序,可以通过软件包管理器或 `pip` 安装。它可以同步 CalDAV、VCalendar/iCalendar、Google Calendar 和目录中的本地文件。由于我使用 Google Calendar,尽管这不是最简单的设置,我也将以它为例。 + +在 vdirsyncer 中设置 Google Calendar 是[有文档参考的][7],所以这里我不再赘述。重要的是确保设置你的同步对,将 Google Calendar 设置为冲突解决的“赢家”。也就是说,如果同一事件有两个更新,那么需要知道哪个更新优先。类似这样做: + +``` +[general] +status_path = "~/.calendars/status" + +[pair personal_sync] +a = "personal" +b = "personallocal" +collections = ["from a", "from b"] +conflict_resolution = "a wins" +metadata = ["color"] + +[storage personal] +type = "google_calendar" +token_file = "~/.vdirsyncer/google_calendar_token" +client_id = "google_client_id" +client_secret = "google_client_secret" + +[storage personallocal] +type = "filesystem" +path = "~/.calendars/Personal" +fileext = ".ics" +``` + +在第一次 vdirsyncer 同步之后,你将在存储路径中看到一系列目录。每个文件夹都将包含多个文件,日历中的每个事件都是一个文件。下一步是导入 khal。首先运行 `khal configure` 进行初始设置。 + +![Configuring khal][8] + +现在,运行 `khal interactive` 将显示本文开头的界面。输入 `n` 将打开“新事件”对话框。这里要注意的一件事:日历的名称与 vdirsyncer 创建的目录匹配,但是你可以更改 khal 配置文件来指定更清晰的名称。根据条目所在的日历,向条目添加颜色还可以帮助你确定日历内容: + +``` +[calendars] +[[personal]] +path = ~/.calendars/Personal/kevin@sonney.com/ +color = light magenta +[[holidays]] +path = ~/.calendars/Personal/cln2stbjc4hmgrrcd5i62ua0ctp6utbg5pr2sor1dhimsp31e8n6errfctm6abj3dtmg@virtual/ +color = light blue +[[birthdays]] +path = ~/.calendars/Personal/c5i68sj5edpm4rrfdchm6rreehgm6t3j81jn4rrle0n7cbj3c5m6arj4c5p2sprfdtjmop9ecdnmq@virtual/ +color = brown +``` + +现在,当你运行 `khal interactive` 时,每个日历将被着色以区别于其他日历,并且当你添加新条目时,它将有更具描述性的名称。 + +![Adding a new calendar entry][9] + +设置有些麻烦,但是完成后,khal 和 vdirsyncer 可以一起为你提供一种简便的方法来管理日历事件并使它们与你的在线服务保持同步。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-calendar + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/calendar.jpg?itok=jEKbhvDT (Calendar close up snapshot) +[2]: https://opensource.com/article/19/1/productivity-tool-wish-list +[3]: https://opensource.com/sites/default/files/uploads/productivity_5-1.png (khal calendar) +[4]: https://khal.readthedocs.io/en/v0.9.2/index.html +[5]: https://github.com/pimutils/vdirsyncer +[6]: https://opensource.com/sites/default/files/uploads/productivity_5-2.png (vdirsyncer) +[7]: https://vdirsyncer.pimutils.org/en/stable/config.html#google +[8]: https://opensource.com/sites/default/files/uploads/productivity_5-3.png (Configuring khal) +[9]: https://opensource.com/sites/default/files/uploads/productivity_5-4.png diff --git a/published/202001/20200115 Root User in Ubuntu- Important Things You Should Know.md b/published/202001/20200115 Root User in Ubuntu- Important Things You Should Know.md new file mode 100644 index 0000000000..0abc566f4b --- /dev/null +++ b/published/202001/20200115 Root User in Ubuntu- Important Things You Should Know.md @@ -0,0 +1,169 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11837-1.html) +[#]: subject: (Root User in Ubuntu: Important Things You Should Know) +[#]: via: (https://itsfoss.com/root-user-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Ubuntu 中的 root 用户:你应该知道的重要事情 +====== + +![][5] + +当你刚开始使用 Linux 时,你将发现与 Windows 的很多不同。其中一个“不同的东西”是 root 用户的概念。 + +在这个初学者系列中,我将解释几个关于 Ubuntu 的 root 用户的重要的东西。 + +**请记住,尽管我正在从 Ubuntu 用户的角度编写这篇文章,它应该对大多数的 Linux 发行版也是有效的。** + +你将在这篇文章中学到下面的内容: + +* 为什么在 Ubuntu 中禁用 root 用户 +* 像 root 用户一样使用命 +* 切换为 root 用户 +* 解锁 root 用户 + +### 什么是 root 用户?为什么它在 Ubuntu 中被锁定? + +在 Linux 中,有一个称为 [root][6] 的超级用户。这是超级管理员账号,它可以做任何事以及使用系统的一切东西。它可以在你的 Linux 系统上访问任何文件和运行任何命令。 + +能力越大,责任越大。root 用户给予你完全控制系统的能力,因此,它应该被谨慎地使用。root 用户可以访问系统文件,运行更改系统配置的命令。因此,一个错误的命令可能会破坏系统。 + +这就是为什么 [Ubuntu][7] 和其它基于 Ubuntu 的发行版默认锁定 root 用户,以从意外的灾难中挽救你的原因。 + +对于你的日常任务,像移动你家目录中的文件,从互联网下载文件,创建文档等等,你不需要拥有 root 权限。 + +**打个比方来更好地理解它。假设你想要切一个水果,你可以使用一把厨房用刀。假设你想要砍一颗树,你就得使用一把锯子。现在,你可以使用锯子来切水果,但是那不明智,不是吗?**_ + +这意味着,你不能是 Ubuntu 中 root 用户或者不能使用 root 权限来使用系统吗?不,你仍然可以在 `sudo` 的帮助下来拥有 root 权限来访问(在下一节中解释)。 + +> **要点:** 使用于常规任务,root 用户权限太过强大。这就是为什么不建议一直使用 root 用户。你仍然可以使用 root 用户来运行特殊的命令。 + +### 如何在 Ubuntu 中像 root 用户一样运行命令? + +![Image Credit: xkcd][8] + +对于一些系统的特殊任务来说,你将需要 root 权限。例如。如果你想[通过命令行更新 Ubuntu][9],你不能作为一个常规用户运行该命令。它将给出权限被拒绝的错误。 + +``` +apt update +Reading package lists... Done +E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) +E: Unable to lock directory /var/lib/apt/lists/ +W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied) +W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied) +``` + +那么,你如何像 root 用户一样运行命令?简单的答案是,在命令前添加 `sudo`,来像 root 用户一样运行。 + +``` +sudo apt update +``` + +Ubuntu 和很多其它的 Linux 发行版使用一个被称为 `sudo` 的特殊程序机制。`sudo` 是一个以 root 用户(或其它用户)来控制运行命令访问的程序。 + +实际上,`sudo` 是一个非常多用途的工具。它可以配置为允许一个用户像 root 用户一样来运行所有的命令,或者仅仅一些命令。你也可以配置为无需密码即可使用 sudo 运行命令。这个主题内容比较丰富,也许我将在另一篇文章中详细讨论它。 + +就目前而言,你应该知道[当你安装 Ubuntu 时][10],你必须创建一个用户账号。这个用户账号在你系统上以管理员身份来工作,并且按照 Ubuntu 中的默认 sudo 策略,它可以在你的系统上使用 root 用户权限来运行任何命令。 + +`sudo` 的问题是,运行 **sudo 不需要 root 用户密码,而是需要用户自己的密码**。 + +并且这就是为什么当你使用 `sudo` 运行一个命令,会要求输入正在运行 `sudo` 命令的用户的密码的原因: + +``` +[email protected]:~$ sudo apt update +[sudo] password for abhishek: +``` + +正如你在上面示例中所见 `abhishek` 在尝试使用 `sudo` 来运行 `apt update` 命令,系统要求输入 `abhishek` 的密码。 + +**如果你对 Linux 完全不熟悉,当你在终端中开始输入密码时,你可能会惊讶,在屏幕上什么都没有发生。这是十分正常的,因为作为默认的安全功能,在屏幕上什么都不会显示。甚至星号(`*`)都没有。输入你的密码并按回车键。** + +> **要点:**为在 Ubuntu 中像 root 用户一样运行命令,在命令前添加 `sudo`。 当被要求输入密码时,输入你的账户的密码。当你在屏幕上输入密码时,什么都看不到。请继续输入密码,并按回车键。 + +### 如何在 Ubuntu 中成为 root 用户? + +你可以使用 `sudo` 来像 root 用户一样运行命令。但是,在某些情况下,你必须以 root 用户身份来运行一些命令,而你总是忘了在命令前添加 `sudo`,那么你可以临时切换为 root 用户。 + +`sudo` 命令允许你来模拟一个 root 用户登录的 shell ,使用这个命令: + +``` +sudo -i +``` + +``` +[email protected]:~$ sudo -i +[sudo] password for abhishek: +[email protected]:~# whoami +root +[email protected]:~# +``` + +你将注意到,当你切换为 root 用户时,shell 命令提示符从 `$`(美元符号)更改为 `#`(英镑符号)。我开个(拙劣的)玩笑,英镑比美元强大。 + +**虽然我已经向你显示如何成为 root 用户,但是我必须警告你,你应该避免作为 root 用户使用系统。毕竟它有阻拦你使用 root 用户的原因。** + +另外一种临时切换为 root 用户的方法是使用 `su` 命令: + +``` +sudo su +``` + +如果你尝试使用不带有的 `sudo` 的 `su` 命令,你将遇到 “su authentication failure” 错误。 + +你可以使用 `exit` 命令来恢复为正常用户。 + +``` +exit +``` + +### 如何在 Ubuntu 中启用 root 用户? + +现在你知道,root 用户在基于 Ubuntu 发行版中是默认锁定的。 + +Linux 给予你在系统上想做什么就做什么的自由。解锁 root 用户就是这些自由之一。 + +如果出于某些原因,你决定启用 root 用户,你可以通过为其设置一个密码来做到: + +``` +sudo passwd root +``` + +再强调一次,不建议使用 root 用户,并且我也不鼓励你在桌面上这样做。如果你忘记了密码,你将不能再次[在 Ubuntu 中更改 root 用户密码][11]。(LCTT 译注:可以通过单用户模式修改。) + +你可以通过移除密码来再次锁定 root 用户: + +``` +sudo passwd -dl root +``` + +### 最后… + +我希望你现在对 root 概念理解得更好一点。如果你仍然有些关于它的困惑和问题,请在评论中让我知道。我将尝试回答你的问题,并且也可能更新这篇文章。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/root-user-ubuntu/ + +作者:[Abhishek Prakash][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/abhishek/ +[b]: https://github.com/lujun9972 +[1]: tmp.IrHYJBAqVn#what-is-root +[2]: tmp.IrHYJBAqVn#run-command-as-root +[3]: tmp.IrHYJBAqVn#become-root +[4]: tmp.IrHYJBAqVn#enable-root +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/root_user_ubuntu.png?ssl=1 +[6]: http://www.linfo.org/root.html +[7]: https://ubuntu.com/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/sudo_sandwich.png?ssl=1 +[9]: https://itsfoss.com/update-ubuntu/ +[10]: https://itsfoss.com/install-ubuntu/ +[11]: https://itsfoss.com/how-to-hack-ubuntu-password/ diff --git a/published/202001/20200115 Why everyone is talking about WebAssembly.md b/published/202001/20200115 Why everyone is talking about WebAssembly.md new file mode 100644 index 0000000000..e8fdb04ce0 --- /dev/null +++ b/published/202001/20200115 Why everyone is talking about WebAssembly.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11823-1.html) +[#]: subject: (Why everyone is talking about WebAssembly) +[#]: via: (https://opensource.com/article/20/1/webassembly) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +为什么每个人都在谈论 WebAssembly +====== + +> 了解有关在 Web 浏览器中运行任何代码的最新方法的更多信息。 + +![](https://img.linux.net.cn/data/attachment/album/202001/27/125343ch0hxdfbzibrihfn.jpg) + +如果你还没有听说过 [WebAssembly][2],那么你很快就会知道。这是业界最保密的秘密之一,但它无处不在。所有主流的浏览器都支持它,并且它也将在服务器端使用。它很快,它能用于游戏编程。这是主要的国际网络标准组织万维网联盟(W3C)的一个开放标准。 + +你可能会说:“哇,这听起来像是我应该学习编程的东西!”你可能是对的,但也是错的。你不需要用 WebAssembly 编程。让我们花一些时间来学习这种通常被缩写为“Wasm”的技术。 + +### 它从哪里来? + +大约十年前,人们越来越认识到,广泛使用的 JavaScript 不够快速,无法满足许多目的。JavaScript 无疑是成功和方便的。它可以在任何浏览器中运行,并启用了今天我们认为理所当然的动态网页类型。但这是一种高级语言,在设计时并没有考虑到计算密集型工作负载。 + +然而,尽管负责主流 web 浏览器的工程师们对性能问题的看法大体一致,但他们对如何解决这个问题却意见不一。出现了两个阵营,谷歌开始了它的原生客户端Native Client项目,后来又推出了可移植原生客户端Portable Native Client变体,着重于允许用 C/C++ 编写的游戏和其它软件在 Chrome 的一个安全隔间中运行。与此同时,Mozilla 赢得了微软对 asm.js 的支持。该方法更新了浏览器,因此它可以非常快速地运行 JavaScript 指令的低级子集(有另一个项目可以将 C/C++ 代码转换为这些指令)。 + +由于这两个阵营都没有得到广泛采用,各方在 2015 年同意围绕一种称为 WebAssembly 的新标准,以 asm.js 所采用的基本方法为基础,联合起来。[如 CNET 的 Stephen Shankland 当时所写][3],“在当今的 Web 上,浏览器的 JavaScript 将这些指令转换为机器代码。但是,通过 WebAssembly,程序员可以在此过程的早期阶段完成很多工作,从而生成介于两种状态之间的程序。这使浏览器摆脱了创建机器代码的繁琐工作,但也实现了 Web 的承诺 —— 该软件将在具有浏览器的任何设备上运行,而无需考虑基础硬件的细节。” + +在 2017 年,Mozilla 宣布了它的最小可行的产品(MVP),并使其脱离预览版阶段。到该年年底,所有主流的浏览器都采用了它。[2019 年 12 月][4],WebAssembly 工作组发布了三个 W3C 推荐的 WebAssembly 规范。 + +WebAssembly 定义了一种可执行程序的可移植二进制代码格式、相应的文本汇编语言以及用于促进此类程序与其宿主环境之间的交互接口。WebAssembly 代码在低级虚拟机中运行,这个可运行于许多微处理器之上的虚拟机可模仿这些处理器的功能。通过即时(JIT)编译或解释,WebAssembly 引擎可以以近乎原生平台编译代码的速度执行。 + +### 为什么现在感兴趣? + +当然,最近对 WebAssembly 感兴趣的部分原因是最初希望在浏览器中运行更多计算密集型代码。尤其是笔记本电脑用户,越来越多的时间都花在浏览器上(或者,对于 Chromebook 用户来说,基本上是所有时间)。这种趋势已经迫切需要消除在浏览器中运行各种应用程序的障碍。这些障碍之一通常是性能的某些方面,这正是 WebAssembly 及其前身最初旨在解决的问题。 + +但是,WebAssembly 并不仅仅适用于浏览器。在 2019 年,[Mozilla 宣布了一个名为 WASI][5](WebAssembly 系统接口WebAssembly System Interface)的项目,以标准化 WebAssembly 代码如何与浏览器上下文之外的操作系统进行交互。通过将浏览器对 WebAssembly 和 WASI 的支持结合在一起,编译后的二进制文件将能够以接近原生的速度,跨不同的设备和操作系统在浏览器内外运行。 + +WebAssembly 的低开销立即使它可以在浏览器之外使用,但这无疑是赌注;显然,还有其它不会引入性能瓶颈的运行应用程序的方法。为什么要专门使用 WebAssembly? + +一个重要的原因是它的可移植性。如今,像 C++ 和 Rust 这样的广泛使用的编译语言可能是与 WebAssembly 关联最紧密的语言。但是,[各种各样的其他语言][6]可以编译为 WebAssembly 或拥有它们的 WebAssembly 虚拟机。此外,尽管 WebAssembly 为其执行环境[假定了某些先决条件][7],但它被设计为在各种操作系统和指令集体系结构上有效执行。因此,WebAssembly 代码可以使用多种语言编写,并可以在多种操作系统和处理器类型上运行。 + +另一个 WebAssembly 优势源于这样一个事实:代码在虚拟机中运行。因此,每个 WebAssembly 模块都在沙盒环境中执行,并使用故障隔离技术将其与宿主机运行时环境分开。这意味着,对于其它部分而言,应用程序独立于其宿主机环境的其余部分执行,如果不调用适当的 API,就无法摆脱沙箱。 + +### WebAssembly 现状 + +这一切在实践中意味着什么? + +如今在运作中的 WebAssembly 的一个例子是 [Enarx][8]。 + +Enarx 是一个提供硬件独立性的项目,可使用受信任的执行环境Trusted Execution Environments(TEE)保护应用程序的安全。Enarx 使你可以安全地将编译为 WebAssembly 的应用程序始终交付到云服务商,并远程执行它。正如 Red Hat 安全工程师 [Nathaniel McCallum 指出的那样][9]:“我们这样做的方式是,我们将你的应用程序作为输入,并使用远程硬件执行认证过程。我们使用加密技术验证了远程硬件实际上是它声称的硬件。最终的结果不仅是我们对硬件的信任度提高了;它也是一个会话密钥,我们可以使用它将加密的代码和数据传递到我们刚刚要求加密验证的环境中。” + +另一个例子是 OPA,开放策略代理Open Policy Agent,它[发布][10]于 2019 年 11 月,你可以[编译][11]他们的策略定义语言 Rego 为 WebAssembly。Rego 允许你编写逻辑来搜索和组合来自不同来源的 JSON/YAML 数据,以询问诸如“是否允许使用此 API?”之类的问题。 + +OPA 已被用于支持策略的软件,包括但不限于 Kubernetes。使用 OPA 之类的工具来简化策略[被认为是在各种不同环境中正确保护 Kubernetes 部署的重要步骤][12]。WebAssembly 的可移植性和内置的安全功能非常适合这些工具。 + +我们的最后一个例子是 [Unity][13]。还记得我们在文章开头提到过 WebAssembly 可用于游戏吗?好吧,跨平台游戏引擎 Unity 是 WebAssembly 的较早采用者,它提供了在浏览器中运行的 Wasm 的首个演示品,并且自 2018 年 8 月以来,[已将 WebAssembly][14]用作 Unity WebGL 构建目标的输出目标。 + +这些只是 WebAssembly 已经开始产生影响的几种方式。你可以在 上查找更多信息并了解 Wasm 的所有最新信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/webassembly + +作者:[Mike Bursell][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [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/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://opensource.com/article/19/8/webassembly-speed-code-reuse +[3]: https://www.cnet.com/news/the-secret-alliance-that-could-give-the-web-a-massive-speed-boost/ +[4]: https://www.w3.org/blog/news/archives/8123 +[5]: https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ +[6]: https://github.com/appcypher/awesome-wasm-langs +[7]: https://webassembly.org/docs/portability/ +[8]: https://enarx.io +[9]: https://enterprisersproject.com/article/2019/9/application-security-4-facts-confidential-computing-consortium +[10]: https://blog.openpolicyagent.org/tagged/webassembly +[11]: https://github.com/open-policy-agent/opa/tree/master/wasm +[12]: https://enterprisersproject.com/article/2019/11/kubernetes-reality-check-3-takeaways-kubecon +[13]: https://opensource.com/article/20/1/www.unity.com +[14]: https://blogs.unity3d.com/2018/08/15/webassembly-is-here/ diff --git a/published/202001/20200116 3 open source tools to manage your contacts.md b/published/202001/20200116 3 open source tools to manage your contacts.md new file mode 100644 index 0000000000..a1862377d8 --- /dev/null +++ b/published/202001/20200116 3 open source tools to manage your contacts.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11834-1.html) +[#]: subject: (3 open source tools to manage your contacts) +[#]: via: (https://opensource.com/article/20/1/sync-contacts-locally) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +用于联系人管理的三个开源工具 +====== + +> 通过将联系人同步到本地从而更快访问它。在我们的 20 个使用开源提升生产力的系列的第六篇文章中了解该如何做。 + +![](https://img.linux.net.cn/data/attachment/album/202001/30/194811bbtt449zfr9zppb3.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用于联系人管理的开源工具 + +在本系列之前的文章中,我解释了如何在本地同步你的[邮件][2]和[日历][3]。希望这些加速了你访问邮件和日历。现在,我将讨论联系人同步,你可以给他们发送邮件和日历邀请。 + +![abook][4] + +我目前收集了很多邮件地址。管理这些数据可能有点麻烦。有基于 Web 的服务,但它们不如本地副本快。 + +几天前,我谈到了用于管理日历的 [vdirsyncer][5]。vdirsyncer 还使用 CardDAV 协议处理联系人。vdirsyncer 除了可以使用**文件系统**存储日历外,还支持通过 **google_contacts** 和 **carddav** 进行联系人同步,但 `fileext` 设置会被更改,因此你无法在日历文件中存储联系人。 + +我在配置文件添加了一块配置,并从 Google 镜像了我的联系人。设置它需要额外的步骤。从 Google 镜像完成后,配置非常简单: + +``` +[pair address_sync] +a = "googlecard" +b = "localcard" +collections = ["from a", "from b"] +conflict_resolution = "a wins" + +[storage googlecard] +type = "google_contacts" +token_file = "~/.vdirsyncer/google_token" +client_id = "my_client_id" +client_secret = "my_client_secret" + +[storage localcard] +type = "filesystem" +path = "~/.calendars/Addresses/" +fileext = ".vcf" +``` + +现在,当我运行 `vdirsyncer discover` 时,它会找到我的 Google 联系人,并且 `vdirsyncer sync` 将它们复制到我的本地计算机。但同样,这只进行到一半。现在我想查看和使用联系人。需要 [khard][6] 和 [abook][7]。 + +![khard search][8] + +为什么选择两个应用?因为每个都有它自己的使用场景,在这里,越多越好。khard 用于管理地址,类似于 [khal][9] 用于管理日历条目。如果你的发行版附带了旧版本,你可能需要通过 `pip` 安装最新版本。安装 khard 后,你需要创建 `~/.config/khard/khard.conf`,因为 khard 没有与 khal 那样漂亮的配置向导。我的看起来像这样: + +``` +[addressbooks] +[[addresses]] +path = ~/.calendars/Addresses/default/ + +[general] +debug = no +default_action = list +editor = vim, -i, NONE +merge_editor = vimdiff + +[contact table] +display = first_name +group_by_addressbook = no +reverse = no +show_nicknames = yes +show_uids = no +sort = last_name +localize_dates = yes + +[vcard] +preferred_version = 3.0 +search_in_source_files = yes +skip_unparsable = no +``` + +这会定义源通讯簿(并给它一个友好的名称)、显示内容和联系人编辑程序。运行 `khard list` 将列出所有条目,`khard list ` 可以搜索特定条目。如果要添加或编辑条目,`add` 和 `edit` 命令将使用相同的基本模板打开配置的编辑器,唯一的区别是 `add` 命令的模板将为空。 + +![editing in khard][11] + +abook 需要你导入和导出 VCF 文件,但它为查找提供了一些不错的功能。要将文件转换为 abook 格式,请先安装 abook 并创建 `~/.abook` 默认目录。然后让 abook 解析所有文件,并将它们放入 `~/.abook/addresses` 文件中: + +``` +apt install abook +ls ~/.calendars/Addresses/default/* | xargs cat | abook --convert --informat vcard --outformat abook > ~/.abook/addresses +``` + +现在运行 `abook`,你将有一个非常漂亮的 UI 来浏览、搜索和编辑条目。将它们导出到单个文件有点痛苦,所以我用 khard 进行大部分编辑,并有一个 cron 任务将它们导入到 abook 中。 + +abook 还可在命令行中搜索,并有大量有关将其与邮件客户端集成的文档。例如,你可以在 `.config/alot/config` 文件中添加一些信息,从而在 [Nmuch][12] 的邮件客户端 [alot][13] 中使用 abook 查询联系人: + +``` +[accounts] + [[Personal]] + realname = Kevin Sonney + address = kevin@sonney.com + alias_regexp = kevin\+.+@sonney.com + gpg_key = 7BB612C9 + sendmail_command = msmtp --account=Personal -t + # ~ expansion works + sent_box = maildir://~/Maildir/Sent + draft_box = maildir://~/Maildir/Drafts + [[[abook]]] + type = abook +``` + +这样你就可以在邮件和日历中快速查找联系人了! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/sync-contacts-locally + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ (Team communication, chat) +[2]: https://linux.cn/article-11804-1.html +[3]: https://linux.cn/article-11812-1.html +[4]: https://opensource.com/sites/default/files/uploads/productivity_6-1.png (abook) +[5]: https://github.com/pimutils/vdirsyncer +[6]: https://github.com/scheibler/khard +[7]: http://abook.sourceforge.net/ +[8]: https://opensource.com/sites/default/files/uploads/productivity_6-2.png (khard search) +[9]: https://khal.readthedocs.io/en/v0.9.2/index.html +[10]: mailto:some@email.adr +[11]: https://opensource.com/sites/default/files/uploads/productivity_6-3.png (editing in khard) +[12]: https://opensource.com/article/20/1/organize-email-notmuch +[13]: https://github.com/pazz/alot +[14]: mailto:kevin@sonney.com +[15]: mailto:+.+@sonney.com diff --git a/published/202001/20200117 C vs. Rust- Which to choose for programming hardware abstractions.md b/published/202001/20200117 C vs. Rust- Which to choose for programming hardware abstractions.md new file mode 100644 index 0000000000..dcdbc98b5a --- /dev/null +++ b/published/202001/20200117 C vs. Rust- Which to choose for programming hardware abstractions.md @@ -0,0 +1,477 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11825-1.html) +[#]: subject: (C vs. Rust: Which to choose for programming hardware abstractions) +[#]: via: (https://opensource.com/article/20/1/c-vs-rust-abstractions) +[#]: author: (Dan Pittman https://opensource.com/users/dan-pittman) + +C 还是 Rust:选择哪个用于硬件抽象编程 +====== + +> 在 Rust 中使用类型级编程可以使硬件抽象更加安全。 + +![](https://img.linux.net.cn/data/attachment/album/202001/28/123350k2w4mr3tp7crd4m2.jpg) + +Rust 是一种日益流行的编程语言,被视为硬件接口的最佳选择。通常会将其与 C 的抽象级别相比较。本文介绍了 Rust 如何通过多种方式处理按位运算,并提供了既安全又易于使用的解决方案。 + +语言 | 诞生于 | 官方描述 | 总览 +---|---|---|--- +C | 1972 年 | C 是一种通用编程语言,具有表达式简约、现代的控制流和数据结构,以及丰富的运算符集等特点。(来源:[CS 基础知识] [2])| C 是(一种)命令式语言,旨在以相对简单的方式进行编译,从而提供对内存的低级访问。(来源:[W3schools.in] [3]) +Rust | 2010 年 | 一种赋予所有人构建可靠、高效的软件的能力的语言(来源:[Rust 网站] [4])| Rust 是一种专注于安全性(尤其是安全并发性)的多范式系统编程语言。(来源:[维基百科] [5]) + +### 在 C 语言中对寄存器值进行按位运算 + +在系统编程领域,你可能经常需要编写硬件驱动程序或直接与内存映射设备进行交互,而这些交互几乎总是通过硬件提供的内存映射寄存器来完成的。通常,你通过对某些固定宽度的数字类型进行按位运算来与这些寄存器进行交互。 + +例如,假设一个 8 位寄存器具有三个字段: + +``` ++----------+------+-----------+---------+ +| (unused) | Kind | Interrupt | Enabled | ++----------+------+-----------+---------+ +   5-7       2-4        1          0 +``` + +字段名称下方的数字规定了该字段在寄存器中使用的位。要启用该寄存器,你将写入值 `1`(以二进制表示为 `0000_0001`)来设置 `Enabled` 字段的位。但是,通常情况下,你也不想干扰寄存器中的现有配置。假设你要在设备上启用中断功能,但也要确保设备保持启用状态。为此,必须将 `Interrupt` 字段的值与 `Enabled` 字段的值结合起来。你可以通过按位操作来做到这一点: + +``` +1 | (1 << 1) +``` + +通过将 1 和 2(`1` 左移一位得到)进行“或”(`|`)运算得到二进制值 `0000_0011` 。你可以将其写入寄存器,使其保持启用状态,但也启用中断功能。 + +你的头脑中要记住很多事情,特别是当你要在一个完整的系统上和可能有数百个之多的寄存器打交道时。在实践上,你可以使用助记符来执行此操作,助记符可跟踪字段在寄存器中的位置以及字段的宽度(即它的上边界是什么) + +下面是这些助记符之一的示例。它们是 C 语言的宏,用右侧的代码替换它们的出现的地方。这是上面列出的寄存器的简写。`&` 的左侧是该字段的起始位置,而右侧则限制该字段所占的位: + +``` +#define REG_ENABLED_FIELD(x) (x << 0) & 1 +#define REG_INTERRUPT_FIELD(x) (x << 1) & 2 +#define REG_KIND_FIELD(x) (x << 2) & (7 << 2) +``` + +然后,你可以使用这些来抽象化寄存器值的操作,如下所示: + +``` +void set_reg_val(reg* u8, val u8); + +fn enable_reg_with_interrupt(reg* u8) { +    set_reg_val(reg, REG_ENABLED_FIELD(1) | REG_INTERRUPT_FIELD(1)); +} +``` + +这就是现在的做法。实际上,这就是大多数驱动程序在 Linux 内核中的使用方式。 + +有没有更好的办法?如果能够基于对现代编程语言研究得出新的类型系统,就可能能够获得安全性和可表达性的好处。也就是说,如何使用更丰富、更具表现力的类型系统来使此过程更安全、更持久? + +### 在 Rust 语言中对寄存器值进行按位运算 + +继续用上面的寄存器作为例子: + +``` ++----------+------+-----------+---------+ +| (unused) | Kind | Interrupt | Enabled | ++----------+------+-----------+---------+ +   5-7       2-4        1          0 +``` + +你想如何用 Rust 类型来表示它呢? + +你将以类似的方式开始,为每个字段的*偏移*定义常量(即,距最低有效位有多远)及其掩码。*掩码*是一个值,其二进制表示形式可用于更新或读取寄存器内部的字段: + +``` +const ENABLED_MASK: u8 = 1; +const ENABLED_OFFSET: u8 = 0; + +const INTERRUPT_MASK: u8 = 2; +const INTERRUPT_OFFSET: u8 = 1; + +const KIND_MASK: u8 = 7 << 2; +const KIND_OFFSET: u8 = 2; +``` + +接下来,你将声明一个 `Field` 类型并进行操作,将给定值转换为与其位置相关的值,以供在寄存器内使用: + +``` +struct Field { + value: u8, +} + +impl Field { + fn new(mask: u8, offset: u8, val: u8) -> Self { + Field { + value: (val << offset) & mask, + } + } +} +``` + +最后,你将使用一个 `Register` 类型,该类型会封装一个与你的寄存器宽度匹配的数字类型。 `Register` 具有 `update` 函数,可使用给定字段来更新寄存器: + +``` +struct Register(u8); + +impl Register { + fn update(&mut self, val: Field) { + self.0 = self.0 | field.value; + } +} + +fn enable_register(&mut reg) { + reg.update(Field::new(ENABLED_MASK, ENABLED_OFFSET, 1)); +} +``` + +使用 Rust,你可以使用数据结构来表示字段,将它们与特定的寄存器联系起来,并在与硬件交互时提供简洁明了的工效。这个例子使用了 Rust 提供的最基本的功能。无论如何,添加的结构都会减轻上述 C 示例中的某些晦涩的地方。现在,字段是个带有名字的事物,而不是从模糊的按位运算符派生而来的数字,并且寄存器是具有状态的类型 —— 这在硬件上多了一层抽象。 + +### 一个易用的 Rust 实现 + +用 Rust 重写的第一个版本很好,但是并不理想。你必须记住要带上掩码和偏移量,并且要手工进行临时计算,这容易出错。人类不擅长精确且重复的任务 —— 我们往往会感到疲劳或失去专注力,这会导致错误。一次一个寄存器地手动记录掩码和偏移量几乎可以肯定会以糟糕的结局而告终。这是最好留给机器的任务。 + +其次,从结构上进行思考:如果有一种方法可以让字段的类型携带掩码和偏移信息呢?如果可以在编译时就发现硬件寄存器的访问和交互的实现代码中存在错误,而不是在运行时才发现,该怎么办?也许你可以依靠一种在编译时解决问题的常用策略,例如类型。 + +你可以使用 [typenum][6] 来修改前面的示例,该库在类型级别提供数字和算术。在这里,你将使用掩码和偏移量对 `Field` 类型进行参数化,使其可用于任何 `Field` 实例,而无需将其包括在调用处: + +``` +#[macro_use] +extern crate typenum; + +use core::marker::PhantomData; + +use typenum::*; + +// Now we'll add Mask and Offset to Field's type +struct Field { + value: u8, + _mask: PhantomData, + _offset: PhantomData, +} + +// We can use type aliases to give meaningful names to +// our fields (and not have to remember their offsets and masks). +type RegEnabled = Field; +type RegInterrupt = Field; +type RegKind = Field; +``` + +现在,当重新访问 `Field` 的构造函数时,你可以忽略掩码和偏移量参数,因为类型中包含该信息: + +``` +impl Field { + fn new(val: u8) -> Self { + Field { + value: (val << Offset::U8) & Mask::U8, + _mask: PhantomData, + _offset: PhantomData, + } + } +} + +// And to enable our register... +fn enable_register(&mut reg) { + reg.update(RegEnabled::new(1)); +} +``` + +看起来不错,但是……如果你在给定的值是否*适合*该字段方面犯了错误,会发生什么?考虑一个简单的输入错误,你在其中放置了 `10` 而不是 `1`: + +``` +fn enable_register(&mut reg) { +    reg.update(RegEnabled::new(10)); +} +``` + +在上面的代码中,预期结果是什么?好吧,代码会将启用位设置为 0,因为 `10&1 = 0`。那真不幸;最好在尝试写入之前知道你要写入字段的值是否适合该字段。事实上,我认为截掉错误字段值的高位是一种 1*未定义的行为*(哈)。 + +### 出于安全考虑使用 Rust + +如何以一般方式检查字段的值是否适合其规定的位置?需要更多类型级别的数字! + +你可以在 `Field` 中添加 `Width` 参数,并使用它来验证给定的值是否适合该字段: + +``` +struct Field { + value: u8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, +} + +type RegEnabled = Field; +type RegInterrupt = Field; +type RegKind = Field; + +impl Field { + fn new(val: u8) -> Option { + if val <= (1 << Width::U8) - 1 { + Some(Field { + value: (val << Offset::U8) & Mask::U8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, + }) + } else { + None + } + } +} +``` + +现在,只有给定值适合时,你才能构造一个 `Field` !否则,你将得到 `None` 信号,该信号指示发生了错误,而不是截掉该值的高位并静默写入意外的值。 + +但是请注意,这将在运行时环境中引发错误。但是,我们事先知道我们想写入的值,还记得吗?鉴于此,我们可以教编译器完全拒绝具有无效字段值的程序 —— 我们不必等到运行它! + +这次,你将向 `new` 的新实现 `new_checked` 中添加一个特征绑定(`where` 子句),该函数要求输入值小于或等于给定字段用 `Width` 所能容纳的最大可能值: + +``` +struct Field { + value: u8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, +} + +type RegEnabled = Field; +type RegInterrupt = Field; +type RegKind = Field; + +impl Field { + const fn new_checked() -> Self + where + V: IsLessOrEqual, + { + Field { + value: (V::U8 << Offset::U8) & Mask::U8, + _mask: PhantomData, + _offset: PhantomData, + _width: PhantomData, + } + } +} +``` + +只有拥有此属性的数字才实现此特征,因此,如果使用不适合的数字,它将无法编译。让我们看一看! + +``` +fn enable_register(&mut reg) { + reg.update(RegEnabled::new_checked::()); +} +12 | reg.update(RegEnabled::new_checked::()); + | ^^^^^^^^^^^^^^^^ expected struct `typenum::B0`, found struct `typenum::B1` + | + = note: expected type `typenum::B0` + found type `typenum::B1` +``` + +`new_checked` 将无法生成一个程序,因为该字段的值有错误的高位。你的输入错误不会在运行时环境中才爆炸,因为你永远无法获得一个可以运行的工件。 + +就使内存映射的硬件进行交互的安全性而言,你已经接近 Rust 的极致。但是,你在 C 的第一个示例中所写的内容比最终得到的一锅粥的类型参数更简洁。当你谈论潜在可能有数百甚至数千个寄存器时,这样做是否容易处理? + +### 让 Rust 恰到好处:既安全又方便使用 + +早些时候,我认为手工计算掩码有问题,但我又做了同样有问题的事情 —— 尽管是在类型级别。虽然使用这种方法很不错,但要达到编写任何代码的地步,则需要大量样板和手动转录(我在这里谈论的是类型的同义词)。 + +我们的团队想要像 [TockOS mmio 寄存器][7]之类的东西,而以最少的手动转录生成类型安全的实现。我们得出的结果是一个宏,该宏生成必要的样板以获得类似 Tock 的 API 以及基于类型的边界检查。要使用它,请写下一些有关寄存器的信息,其字段、宽度和偏移量以及可选的[枚举][8]类的值(你应该为字段可能具有的值赋予“含义”): + +``` +register! { + // The register's name + Status, + // The type which represents the whole register. + u8, + // The register's mode, ReadOnly, ReadWrite, or WriteOnly. + RW, + // And the fields in this register. + Fields [ + On WIDTH(U1) OFFSET(U0), + Dead WIDTH(U1) OFFSET(U1), + Color WIDTH(U3) OFFSET(U2) [ + Red = U1, + Blue = U2, + Green = U3, + Yellow = U4 + ] + ] +} +``` + +由此,你可以生成寄存器和字段类型,如上例所示,其中索引:`Width`、`Mask` 和 `Offset` 是从一个字段定义的 `WIDTH` 和 `OFFSET` 部分的输入值派生的。另外,请注意,所有这些数字都是 “类型数字”;它们将直接进入你的 `Field` 定义! + +生成的代码通过为寄存器及字段指定名称来为寄存器及其相关字段提供名称空间。这很绕口,看起来是这样的: + +``` +mod Status { + struct Register(u8); + mod On { + struct Field; // There is of course more to this definition + } + mod Dead { + struct Field; + } + mod Color { + struct Field; + pub const Red: Field = Field::new(); + // &c. + } +} +``` + +生成的 API 包含名义上期望的读取和写入的原语,以获取原始寄存器的值,但它也有办法获取单个字段的值、执行集合操作以及确定是否设置了任何(或全部)位集合的方法。你可以阅读[完整生成的 API][9]上的文档。 + +### 粗略检查 + +将这些定义用于实际设备会是什么样?代码中是否会充斥着类型参数,从而掩盖了视图中的实际逻辑? + +不会!通过使用类型同义词和类型推断,你实际上根本不必考虑程序的类型层面部分。你可以直接与硬件交互,并自动获得与边界相关的保证。 + +这是一个 [UART][10] 寄存器块的示例。我会跳过寄存器本身的声明,因为包括在这里就太多了。而是从寄存器“块”开始,然后帮助编译器知道如何从指向该块开头的指针中查找寄存器。我们通过实现 `Deref` 和 `DerefMut` 来做到这一点: + +``` +#[repr(C)] +pub struct UartBlock { + rx: UartRX::Register, + _padding1: [u32; 15], + tx: UartTX::Register, + _padding2: [u32; 15], + control1: UartControl1::Register, +} + +pub struct Regs { + addr: usize, +} + +impl Deref for Regs { + type Target = UartBlock; + + fn deref(&self) -> &UartBlock { + unsafe { &*(self.addr as *const UartBlock) } + } +} + +impl DerefMut for Regs { + fn deref_mut(&mut self) -> &mut UartBlock { + unsafe { &mut *(self.addr as *mut UartBlock) } + } +} +``` + +一旦到位,使用这些寄存器就像 `read()` 和 `modify()` 一样简单: + +``` +fn main() { + // A pretend register block. + let mut x = [0_u32; 33]; + + let mut regs = Regs { + // Some shenanigans to get at `x` as though it were a + // pointer. Normally you'd be given some address like + // `0xDEADBEEF` over which you'd instantiate a `Regs`. + addr: &mut x as *mut [u32; 33] as usize, + }; + + assert_eq!(regs.rx.read(), 0); + + regs.control1 + .modify(UartControl1::Enable::Set + UartControl1::RecvReadyInterrupt::Set); + + // The first bit and the 10th bit should be set. + assert_eq!(regs.control1.read(), 0b_10_0000_0001); +} +``` + +当我们使用运行时值时,我们使用如前所述的**选项**。这里我使用的是 `unwrap`,但是在一个输入未知的真实程序中,你可能想检查一下从新调用中返回的**某些东西**: [^1] [^2] + +``` +fn main() { +    // A pretend register block. +    let mut x = [0_u32; 33]; + +    let mut regs = Regs { +        // Some shenanigans to get at `x` as though it were a +        // pointer. Normally you'd be given some address like +        // `0xDEADBEEF` over which you'd instantiate a `Regs`. +        addr: &mut x as *mut [u32; 33] as usize, +    }; + +    let input = regs.rx.get_field(UartRX::Data::Field::Read).unwrap(); +    regs.tx.modify(UartTX::Data::Field::new(input).unwrap()); +} +``` + +### 解码失败条件 + +根据你的个人痛苦忍耐程度,你可能已经注意到这些错误几乎是无法理解的。看一下我所说的不那么微妙的提醒: + +``` +error[E0271]: type mismatch resolving `, typenum::B0>, typenum::B1>, typenum::B0>, typenum::B0> as typenum::IsLessOrEqual, typenum::B0>, typenum::B1>, typenum::B0>>>::Output == typenum::B1` + --> src/main.rs:12:5 + | +12 | less_than_ten::(); + | ^^^^^^^^^^^^^^^^^^^^ expected struct `typenum::B0`, found struct `typenum::B1` + | + = note: expected type `typenum::B0` + found type `typenum::B1` +``` + +`expected struct typenum::B0, found struct typenum::B1` 部分是有意义的,但是 ` typenum::UInt疯了,地狱了,不要再忍受了Mad As Hell And Wasn't Going To Take It Anymore》,并做了一个小工具 `tnfilt`,从这种命名空间的二进制 cons 单元的痛苦中解脱出来。`tnfilt` 将 cons 单元格式的表示法替换为可让人看懂的十进制数字。我们认为其他人也会遇到类似的困难,所以我们分享了 [tnfilt][14]。你可以像这样使用它: + +``` +$ cargo build 2>&1 | tnfilt +``` + +它将上面的输出转换为如下所示: + +``` +error[E0271]: type mismatch resolving `>::Output == typenum::B1` +``` + +现在*这*才有意义! + +### 结论 + +当在软件与硬件进行交互时,普遍使用内存映射寄存器,并且有无数种方法来描述这些交互,每种方法在易用性和安全性上都有不同的权衡。我们发现使用类型级编程来取得内存映射寄存器交互的编译时检查可以为我们提供制作更安全软件的必要信息。该代码可在 [bounded-registers][15] crate(Rust 包)中找到。 + +我们的团队从安全性较高的一面开始,然后尝试找出如何将易用性滑块移近易用端。从这些雄心壮志中,“边界寄存器”就诞生了,我们在 Auxon 公司的冒险中遇到内存映射设备的任何时候都可以使用它。 + +* * * + +[^1]: 从技术上讲,从定义上看,从寄存器字段读取的值只能在规定的范围内,但是我们当中没有一个人生活在一个纯净的世界中,而且你永远都不知道外部系统发挥作用时会发生什么。你是在这里接受硬件之神的命令,因此与其强迫你进入“可能的恐慌”状态,还不如给你提供处理“这将永远不会发生”的机会。 +[^2]: `get_field` 看起来有点奇怪。我正在专门查看 `Field::Read` 部分。`Field` 是一种类型,你需要该类型的实例才能传递给 `get_field`。更干净的 API 可能类似于:`regs.rx.get_field::();` 但是请记住,`Field` 是一种具有固定的宽度、偏移量等索引的类型的同义词。要像这样对 `get_field` 进行参数化,你需要使用更高级的类型。 + +* * * + +此内容最初发布在 [Auxon Engineering 博客][16]上,并经许可进行编辑和重新发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/c-vs-rust-abstractions + +作者:[Dan Pittman][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dan-pittman +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_hardware_purple.png?itok=3NdVoYhl (Tools illustration) +[2]: https://cs-fundamentals.com/c-programming/history-of-c-programming-language.php +[3]: https://www.w3schools.in/c-tutorial/history-of-c/ +[4]: https://www.rust-lang.org/ +[5]: https://en.wikipedia.org/wiki/Rust_(programming_language) +[6]: https://docs.rs/crate/typenum +[7]: https://docs.rs/tock-registers/0.3.0/tock_registers/ +[8]: https://en.wikipedia.org/wiki/Enumerated_type +[9]: https://github.com/auxoncorp/bounded-registers#the-register-api +[10]: https://en.wikipedia.org/wiki/Universal_asynchronous_receiver-transmitter +[11]: tmp.shpxgDsodx#1 +[12]: tmp.shpxgDsodx#2 +[13]: https://en.wikipedia.org/wiki/Cons +[14]: https://github.com/auxoncorp/tnfilt +[15]: https://crates.io/crates/bounded-registers +[16]: https://blog.auxon.io/2019/10/25/type-level-registers/ diff --git a/published/202001/20200117 Get started with this open source to-do list manager.md b/published/202001/20200117 Get started with this open source to-do list manager.md new file mode 100644 index 0000000000..deaa6da72a --- /dev/null +++ b/published/202001/20200117 Get started with this open source to-do list manager.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11835-1.html) +[#]: subject: (Get started with this open source to-do list manager) +[#]: via: (https://opensource.com/article/20/1/open-source-to-do-list) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +开始使用开源待办事项清单管理器 +====== + +> 待办事项清单是跟踪任务列表的强大方法。在我们的 20 个使用开源提升生产力的系列的第七篇文章中了解如何使用它。 + +![](https://img.linux.net.cn/data/attachment/album/202001/31/111103kmv55ploshuso4ot.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 todo 跟踪任务 + +任务管理和待办事项清单是我非常喜欢0的东西。我是一位生产效率的狂热粉丝(以至于我为此做了一个[播客][2]),我尝试了各种不同的应用。我甚至为此[做了演讲][3]并[写了些文章][4]。因此,当我谈到提高工作效率时,肯定会出现任务管理和待办事项清单工具。 + +![Getting fancy with Todo.txt][5] + +说实话,由于简单、跨平台且易于同步,用 [todo.txt][6] 肯定不会错。它是我不断反复提到的两个待办事项清单以及任务管理应用之一(另一个是 [Org 模式][7])。让我反复使用它的原因是它简单、可移植、易于理解,并且有许多很好的附加组件,并且当一台机器有附加组件,而另一台没有,也不会破坏它。由于它是一个 Bash shell 脚本,我还没发现一个无法支持它的系统。 + +#### 设置 todo.txt + +首先,你需要安装基本 shell 脚本并将默认配置文件复制到 `~/.todo` 目录: + +``` +git clone https://github.com/todotxt/todo.txt-cli.git +cd todo.txt-cli +make +sudo make install +mkdir ~/.todo +cp todo.cfg ~/.todo/config +``` + +接下来,设置配置文件。一般,我想取消对颜色设置的注释,但必须马上设置的是 `TODO_DIR` 变量: + +``` +export TODO_DIR="$HOME/.todo" +``` + +#### 添加待办事件 + +要添加第一个待办事件,只需输入 `todo.sh add ` 就能添加。这还将在 `$HOME/.todo/` 中创建三个文件:`todo.txt`、`done.txt` 和 `reports.txt`。 + +添加几个项目后,运行 `todo.sh ls` 查看你的待办事项。 + +![Basic todo.txt list][8] + +#### 管理任务 + +你可以通过给项目设置优先级来稍微改善它。要向项目添加优先级,运行 `todo.sh pri # A`。数字是列表中任务的数量,而字母 `A` 是优先级。你可以将优先级设置为从 A 到 Z,因为这是它的排序方式。 + +要完成任务,运行 `todo.sh do #` 来标记项目已完成并将它移动到 `done.txt`。运行 `todo.sh report` 会向 `report.txt` 写入已完成和未完成项的数量。 + +所有这三个文件的格式都有详细的说明,因此你可以使用你的文本编辑器修改。`todo.txt` 的基本格式是: + +``` +(Priority) YYYY-MM-DD Task +``` + +该日期表示任务的到期日期(如果已设置)。手动编辑文件时,只需在任务前面加一个 `x` 来标记为已完成。运行 `todo.sh archive` 会将这些项目移动到 `done.txt`,你可以编辑该文本文件,并在有时间时将已完成的项目归档。 + +#### 设置重复任务 + +我有很多重复的任务,我需要以每天/周/月来计划。 + +![Recurring tasks with the ice_recur add-on][9] + +这就是 `todo.txt` 的灵活性所在。通过在 `~/.todo.actions.d/` 中使用[附加组件][10],你可以添加命令并扩展基本 `todo.sh` 的功能。附加组件基本上是实现特定命令的脚本。对于重复执行的任务,插件 [ice_recur][11] 应该符合要求。按照其页面上的说明操作,你可以设置任务以非常灵活的方式重复执行。 + +![Todour on MacOS][12] + +在该[附加组件目录][10]中有很多附加组件,包括同步到某些云服务,也有链接到桌面或移动端应用的组件,这样你可以随时看到待办列表。 + +我只是简单介绍了这个代办事项清单功能,请花点时间深入了解这个工具的强大!它确实可以帮助我每天完成任务。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-to-do-list + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/checklist_todo_clock_time_team.png?itok=1z528Q0y (Team checklist) +[2]: https://productivityalchemy.com/ +[3]: https://www.slideshare.net/AllThingsOpen/getting-to-done-on-the-command-line +[4]: https://opensource.com/article/18/2/getting-to-done-agile-linux-command-line +[5]: https://opensource.com/sites/default/files/uploads/productivity_7-1.png +[6]: http://todotxt.org/ +[7]: https://orgmode.org/ +[8]: https://opensource.com/sites/default/files/uploads/productivity_7-2.png (Basic todo.txt list) +[9]: https://opensource.com/sites/default/files/uploads/productivity_7-3.png (Recurring tasks with the ice_recur add-on) +[10]: https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory +[11]: https://github.com/rlpowell/todo-text-stuff +[12]: https://opensource.com/sites/default/files/uploads/productivity_7-4.png (Todour on MacOS) diff --git a/published/202001/20200117 Locking and unlocking accounts on Linux systems.md b/published/202001/20200117 Locking and unlocking accounts on Linux systems.md new file mode 100644 index 0000000000..64a19e1010 --- /dev/null +++ b/published/202001/20200117 Locking and unlocking accounts on Linux systems.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (FSSlc) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11813-1.html) +[#]: subject: (Locking and unlocking accounts on Linux systems) +[#]: via: (https://www.networkworld.com/article/3513982/locking-and-unlocking-accounts-on-linux-systems.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 系统中禁用与解禁用户的账号 +====== + +> 总有这样的时候:有时你需要禁用某位 Linux 用户的账号,有时你还需要反过来解禁用户的账号。 +本文将介绍一些管理用户访问的命令,并介绍它们背后的原理。 + +![](https://images.idgesg.net/images/article/2019/10/cso_cybersecurity_mysterious_padlock_complex_circuits_gold_by_sqback_gettyimages-1177918748_2400x1600-100813830-large.jpg) + +假如你正管理着一台 [Linux][1] 系统,那么很有可能将遇到需要禁用一个账号的情况。可能是某人已经换了职位,他们是否还需要该账号仍是个问题;或许有理由相信再次使用该账号并没有大碍。不管上述哪种情况,知晓如何禁用账号并解禁账号都是你需要知道的知识。 + +需要你记住的一件重要的事是尽管有多种方法来禁用账号,但它们并不都达到相同的效果。假如用户使用公钥/私钥来使用该账号而不是使用密码来访问,那么你使用的某些命令来阻止用户获取该账号或许将不会生效。 + +### 使用 passwd 来禁用一个账号 + +最为简单的用来禁用一个账号的方法是使用 `passwd -l` 命令。例如: + +``` +$ sudo passwd -l tadpole +``` + +上面这个命令的效果是在加密后的密码文件 `/etc/shadow` 中,用户对应的那一行的最前面加上一个 `!` 符号。这样就足够阻止用户使用密码来访问账号了。 + +在没有使用上述命令前,加密后的密码行如下所示(请注意第一个字符): + +``` +$6$IC6icrWlNhndMFj6$Jj14Regv3b2EdK.8iLjSeO893fFig75f32rpWpbKPNz7g/eqeaPCnXl3iQ7RFIN0BGC0E91sghFdX2eWTe2ET0:18184:0:99999:7::: +``` + +而禁用该账号后,这一行将变为: + +``` +!$6$IC6icrWlNhndMFj6$Jj14Regv3b2EdK.8iLjSeO893fFig75f32rpWpbKPNz7g/eqeaPCnXl3iQ7RFIN0BGC0E91sghFdX2eWTe2ET0:18184:0:99999:7::: +``` + +在 tadpole 下一次尝试登录时,他可能会使用他原有的密码来尝试多次登录,但就是无法再登录成功了。另一方面,你则可以使用下面的命令来查看他这个账号的状态(`-S` = status): + +``` +$ sudo passwd -S tadpole +tadpole L 10/15/2019 0 99999 7 -1 +``` + +第二项的 `L` 告诉你这个账号已经被禁用了。在该账号被禁用前,这一项应该是 `P`。如果显示的是 `NP` 则意味着该账号还没有设置密码。 + +命令 `usermod -L` 也具有相同的效果(添加 `!` 来禁用账号的使用)。 + +使用这种方法来禁用某个账号的一个好处是当需要解禁某个账号时非常容易。只需要使用一个文本编辑器或者使用 `passwd -u` 命令来执行相反的操作,即将添加的 `!` 移除即可。 + +``` +$ sudo passwd -u tadpole +passwd: password expiry information changed. +``` + +但使用这种方式的问题是如果用户使用公钥/私钥对的方式来访问他/她的账号,这种方式将不能阻止他们使用该账号。 + +### 使用 chage 命令来禁用账号 + +另一种禁用用户账号的方法是使用 `chage` 命令,它可以帮助管理用户账号的过期日期。 + +``` +$ sudu chage -E0 tadpole +$ sudo passwd -S tadpole +tadpole P 10/15/2019 0 99999 7 -1 +``` + +`chage` 命令将会稍微修改 `/etc/shadow` 文件。在这个使用 `:` 来分隔的文件(下面将进行展示)中,某行的第 8 项将被设置为 `0`(先前为空),这就意味着这个账号已经过期了。`chage` 命令会追踪密码更改期间的天数,通过选项也可以提供账号过期信息。第 8 项如果是 0 则意味着这个账号在 1970 年 1 月 1 日后的一天过期,当使用上面显示的那个命令时可以用来禁用账号。 + +``` +$ sudo grep tadpole /etc/shadow | fold +tadpole:$6$IC6icrWlNhndMFj6$Jj14Regv3b2EdK.8iLjSeO893fFig75f32rpWpbKPNz7g/eqeaPC +nXl3iQ7RFIN0BGC0E91sghFdX2eWTe2ET0:18184:0:99999:7::0: + ^ + | + +--- days until expiration +``` + +为了执行相反的操作,你可以简单地使用下面的命令将放置在 `/etc/shadow` 文件中的 `0` 移除掉: + +``` +% sudo chage -E-1 tadpole +``` + +一旦一个账号使用这种方式被禁用,即便是无密码的 [SSH][4] 登录也不能再访问该账号了。 + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3513982/locking-and-unlocking-accounts-on-linux-systems.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[FSSlc](https://github.com/FSSlc) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3215226/what-is-linux-uses-featres-products-operating-systems.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua +[4]: https://www.networkworld.com/article/3441777/how-the-linux-screen-tool-can-save-your-tasks-and-your-sanity-if-ssh-is-interrupted.html +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20200119 What-s your favorite Linux terminal trick.md b/published/202001/20200119 What-s your favorite Linux terminal trick.md new file mode 100644 index 0000000000..675f36a935 --- /dev/null +++ b/published/202001/20200119 What-s your favorite Linux terminal trick.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11817-1.html) +[#]: subject: (What's your favorite Linux terminal trick?) +[#]: via: (https://opensource.com/article/20/1/linux-terminal-trick) +[#]: author: (Opensource.com https://opensource.com/users/admin) + +你有什么喜欢的 Linux 终端技巧? +====== + +> 告诉我们你最喜欢的终端技巧,无论是提高生产率的快捷方式还是有趣的彩蛋。 + +![](https://img.linux.net.cn/data/attachment/album/202001/25/135858accxc70tfxuifxx1.jpg) + +新年伊始始终是评估提高效率的新方法的好时机。许多人尝试使用新的生产力工具,或者想找出如何优化其最常用的流程。终端是一个需要评估的领域,尤其是在开源世界中,有无数种方法可以通过快捷键和命令使终端上的生活更加高效(又有趣!)。 + +我们向作者们询问了他们最喜欢的终端技巧。他们分享了一些节省时间的技巧,甚至还有一个有趣的终端彩蛋。你会采用这些键盘快捷键或命令行技巧吗?你有喜欢分享的最爱吗?请发表评论来告诉我们。 + +“我找不出哪个是我最喜欢的;每天我都会使用这三个: + +* `Ctrl + L` 来清除屏幕(而不是键入 `clear`)。 +* `sudo !!` 以 `sudo` 特权运行先前的命令。 +* `grep -Ev '^#|^$' ` 将显示文件内容,不带注释或空行。” —Mars Toktonaliev + +“对我来说,如果我正在使用终端文本编辑器,并且希望将其丢开,以便可以快速执行其他操作,则可以使用 `Ctrl + Z` 将其放到后台,接着执行我需要做的一切,然后用 `fg` 将其带回前台。有时我也会对 `top` 或 `htop` 做同样的事情。我可以将其丢到后台,并在我想检查当前性能时随时将其带回前台。我不会将通常很快能完成的任务在前后台之间切换,它确实可以增强终端上的多任务处理能力。” —Jay LaCroix + +“我经常在某一天在终端中做很多相同的事情,有两件事是每天都不变的: + +* `Ctrl + R` 反向搜索我的 Bash 历史记录以查找我已经运行并且希望再次执行的命令。 +* 插入号(`^`)替换是最好的,因为我经常做诸如 `sudo dnf search ` 之类的事情,然后,如果我以这种方式找到合适的软件包,则执行 `^search^install` 来重新运行该命令,以 `install` 替换 `search`。 + +这些东西肯定是很基本的,但是对我来说却节省了时间。” —Steve Morris + +“我的炫酷终端技巧不是我在终端上执行的操作,而是我使用的终端。有时候我只是想要使用 Apple II 或旧式琥珀色终端的感觉,那我就启动了 Cool-Retro-Term。它的截屏可以在这个[网站][2]上找到。” —Jim Hall + +“可能是用 `ssh -X` 来在其他计算机上运行图形程序。(在某些终端仿真器上,例如 gnome-terminal)用 `C-S c` 和 `C-S v` 复制/粘贴。我不确定这是否有价值(因为它有趣的是以 ssh 启动的图形化)。最近,我需要登录另一台计算机,但是我的孩子们可以在笔记本电脑的大屏幕上看到它。这个[链接][3]向我展示了一些我从未见过的内容:通过局域网从我的笔记本电脑上镜像来自另一台计算机屏幕上的活动会话(`x11vnc -desktop`),并能够同时从两台计算机上进行控制。” —Kyle R. Conway + +“你可以安装 `sl`(`$ sudo apt install sl` 或 `$ sudo dnf install sl`),并且当在 Bash 中输入命令 `sl` 时,一个基于文本的蒸汽机车就会在显示屏上移动。” —Don Watkins + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/linux-terminal-trick + +作者:[Opensource.com][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/admin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE (Terminal command prompt on orange background) +[2]: https://github.com/Swordfish90/cool-retro-term +[3]: https://elinux.org/Screen_Casting_on_a_Raspberry_Pi diff --git a/published/202001/20200122 Setting up passwordless Linux logins using public-private keys.md b/published/202001/20200122 Setting up passwordless Linux logins using public-private keys.md new file mode 100644 index 0000000000..89f54a6b45 --- /dev/null +++ b/published/202001/20200122 Setting up passwordless Linux logins using public-private keys.md @@ -0,0 +1,202 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11830-1.html) +[#]: subject: (Setting up passwordless Linux logins using public/private keys) +[#]: via: (https://www.networkworld.com/article/3514607/setting-up-passwordless-linux-logins-using-publicprivate-keys.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用公钥/私钥对设定免密的 Linux 登录方式 +====== + +> 使用一组公钥/私钥对让你不需要密码登录到远程 Linux 系统或使用 ssh 运行命令,这会非常方便,但是设置过程有点复杂。下面是帮助你的方法和脚本。 + +![](https://img.linux.net.cn/data/attachment/album/202001/29/141343ldps4muy4kp64k4l.jpg) + +在 [Linux][1] 系统上设置一个允许你无需密码即可远程登录或运行命令的帐户并不难,但是要使它正常工作,你还需要掌握一些繁琐的细节。在本文,我们将完成整个过程,然后给出一个可以帮助处理琐碎细节的脚本。 + +设置好之后,如果希望在脚本中运行 `ssh` 命令,尤其是希望配置自动运行的命令,那么免密访问特别有用。 + +需要注意的是,你不需要在两个系统上使用相同的用户帐户。实际上,你可以把公用密钥用于系统上的多个帐户或多个系统上的不同帐户。 + +设置方法如下。 + +### 在哪个系统上启动? + +首先,你需要从要发出命令的系统上着手。那就是你用来创建 `ssh` 密钥的系统。你还需要可以访问远程系统上的帐户并在其上运行这些命令。 + +为了使角色清晰明了,我们将场景中的第一个系统称为 “boss”,因为它将发出要在另一个系统上运行的命令。 + +因此,命令提示符如下: + +``` +boss$ +``` + +如果你还没有在 boss 系统上为你的帐户设置公钥/私钥对,请使用如下所示的命令创建一个密钥对。注意,你可以在各种加密算法之间进行选择。(一般使用 RSA 或 DSA。)注意,要在不输入密码的情况下访问系统,你需要在下面的对话框中的两个提示符出不输入密码。 + +如果你已经有一个与此帐户关联的公钥/私钥对,请跳过此步骤。 + +``` +boss$ ssh-keygen -t rsa +Generating public/private rsa key pair. +Enter file in which to save the key (/home/myself/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): <== 按下回车键即可 +Enter same passphrase again: <== 按下回车键即可 +Your identification has been saved in /home/myself/.ssh/id_rsa. +Your public key has been saved in /home/myself/.ssh/id_rsa.pub. +The key fingerprint is: +SHA256:1zz6pZcMjA1av8iyojqo6NVYgTl1+cc+N43kIwGKOUI myself@boss +The key's randomart image is: ++---[RSA 3072]----+ +| . .. | +| E+ .. . | +| .+ .o + o | +| ..+.. .o* . | +| ... So+*B o | +| + ...==B . | +| . o . ....++. | +|o o . . o..o+ | +|=..o.. ..o o. | ++----[SHA256]-----+ +``` + +上面显示的命令将创建公钥和私钥。其中公钥用于加密,私钥用于解密。因此,这些密钥之间的关系是关键的,私有密钥**绝不**应该被共享。相反,它应该保存在 boss 系统的 `.ssh` 文件夹中。 + +注意,在创建时,你的公钥和私钥将会保存在 `.ssh` 文件夹中。 + +下一步是将**公钥**复制到你希望从 boss 系统免密访问的系统。你可以使用 `scp` 命令来完成此操作,但此时你仍然需要输入密码。在本例中,该系统称为 “target”。 + +``` +boss$ scp .ssh/id_rsa.pub myacct@target:/home/myaccount +myacct@target's password: +``` + +你需要安装公钥在 target 系统(将运行命令的系统)上。如果你没有 `.ssh` 目录(例如,你从未在该系统上使用过 `ssh`),运行这样的命令将为你设置一个目录: + +``` +target$ ssh localhost date +target$ ls -la .ssh +total 12 +drwx------ 2 myacct myacct 4096 Jan 19 11:48 . +drwxr-xr-x 6 myacct myacct 4096 Jan 19 11:49 .. +-rw-r--r-- 1 myacct myacct 222 Jan 19 11:48 known_hosts +``` + +仍然在目标系统上,你需要将从“boss”系统传输的公钥添加到 `.ssh/authorized_keys` 文件中。如果该文件已经存在,使用下面的命令将把它添加到文件的末尾;如果文件不存在,则创建该文件并添加密钥。 + +``` +target$ cat id_rsa.pub >> .ssh/authorized_keys +``` + +下一步,你需要确保你的 `authorized_keys` 文件权限为 600。如果还不是,执行命令 `chmod 600 .ssh/authorized_keys`。 + +``` +target$ ls -l authorized_keys +-rw------- 1 myself myself 569 Jan 19 12:10 authorized_keys +``` + +还要检查目标系统上 `.ssh` 目录的权限是否设置为 700。如果需要,执行 `chmod 700 .ssh` 命令修改权限。 + +``` +target$ ls -ld .ssh +drwx------ 2 myacct myacct 4096 Jan 14 15:54 .ssh +``` + +此时,你应该能够从 boss 系统远程免密运行命令到目标系统。除非目标系统上的目标用户帐户拥有与你试图连接的用户和主机相同的旧公钥,否则这应该可以工作。如果是这样,你应该删除早期的(并冲突的)条目。 + +### 使用脚本 + +使用脚本可以使某些工作变得更加容易。但是,在下面的示例脚本中,你会遇到的一个烦人的问题是,在配置免密访问权限之前,你必须多次输入目标用户的密码。一种选择是将脚本分为两部分——需要在 boss 系统上运行的命令和需要在 target 系统上运行的命令。 + +这是“一步到位”版本的脚本: + +``` +#!/bin/bash +# NOTE: This script requires that you have the password for the remote acct +# in order to set up password-free access using your public key + +LOC=`hostname` # the local system from which you want to run commands from + # wo a password + +# get target system and account +echo -n "target system> " +read REM +echo -n "target user> " +read user + +# create a key pair if no public key exists +if [ ! -f ~/.ssh/id_rsa.pub ]; then + ssh-keygen -t rsa +fi + +# ensure a .ssh directory exists in the remote account +echo checking for .ssh directory on remote system +ssh $user@$REM "if [ ! -d /home/$user/.ssh ]; then mkdir /home/$user/.ssh; fi" + +# share the public key (using local hostname) +echo copying the public key +scp ~/.ssh/id_rsa.pub $user@$REM:/home/$user/$user-$LOC.pub + +# put the public key into the proper location +echo adding key to authorized_keys +ssh $user@$REM "cat /home/$user/$user-$LOC.pub >> /home/$user/.ssh/authorized_ke +ys" + +# set permissions on authorized_keys and .ssh (might be OK already) +echo setting permissions +ssh $user@$REM "chmod 600 ~/.ssh/authorized_keys" +ssh $user@$REM "chmod 700 ~/.ssh" + +# try it out -- should NOT ask for a password +echo testing -- if no password is requested, you are all set +ssh $user@$REM /bin/hostname +``` + +脚本已经配置为在你每次必须输入密码时告诉你它正在做什么。交互看起来是这样的: + +``` +$ ./rem_login_setup +target system> fruitfly +target user> lola +checking for .ssh directory on remote system +lola@fruitfly's password: +copying the public key +lola@fruitfly's password: +id_rsa.pub 100% 567 219.1KB/s 00:00 +adding key to authorized_keys +lola@fruitfly's password: +setting permissions +lola@fruitfly's password: +testing -- if no password is requested, you are all set +fruitfly +``` + +在上面的场景之后,你就可以像这样登录到 lola 的帐户: + +``` +$ ssh lola@fruitfly +[lola@fruitfly ~]$ +``` + +一旦设置了免密登录,你就可以不需要键入密码从 boss 系统登录到 target 系统,并且运行任意的 `ssh` 命令。以这种免密的方式运行并不意味着你的帐户不安全。然而,根据 target 系统的性质,保护你在 boss 系统上的密码可能变得更加重要。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3514607/setting-up-passwordless-linux-logins-using-publicprivate-keys.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3215226/what-is-linux-uses-featres-products-operating-systems.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.networkworld.com/article/3143050/linux/linux-hardening-a-15-step-checklist-for-a-secure-linux-server.html#tk.nww-fsb +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202001/20200123 Wine 5.0 is Released- Here-s How to Install it.md b/published/202001/20200123 Wine 5.0 is Released- Here-s How to Install it.md new file mode 100644 index 0000000000..683f033104 --- /dev/null +++ b/published/202001/20200123 Wine 5.0 is Released- Here-s How to Install it.md @@ -0,0 +1,165 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11827-1.html) +[#]: subject: (Wine 5.0 is Released! Here’s How to Install it) +[#]: via: (https://itsfoss.com/wine-5-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Wine 5.0 发布了! +====== + +> Wine 的一个新的主要版本发布了。使用 Wine 5.0,在 Linux 上运行 Windows 应用程序和游戏的体验得到进一步改进。 + +通过一些努力,你可以使用 Wine [在 Linux 上运行 Windows 应用程序][1]。当你必须使用一个仅在 Windows 上可用的软件时,Wine 是一个可以尝试的工具。它支持许多这样的软件。 + +Wine 的一个新的主要发布版本已经降临,即 Wine 5.0,几乎距它的 4.0 发布一年之后。 + +Wine 5.0 发布版本引进了几个主要特性和很多显著的更改/改进。在这篇文章中,我将重点介绍新的特性是什么,并且也将提到安装说明。 + +### 在 Wine 5.0 中有什么新的特性? + +![][2] + +如他们的[官方声明][3]所述,这是 5.0 发布版本中的关键更改: + +* PE 格式的内置模块。 +* 支持多显示器。 +* 重新实现了 XAudio2。 +* 支持 Vulkan 1.1。 +* 支持微软安装程序(MSI)补丁文件。 +* 性能提升。 + +因此,随着 Vulkan 1.1 和对多显示器的支持 —— Wine 5.0 发布版本是一件大事。 + +除了上面强调的这些关键内容以外,在新的版本中包含成千上万的更改/改进中,你还可以期待对控制器的支持更好。 + +值得注意的是,此版本特别纪念了 **Józef Kucia**(vkd3d 项目的首席开发人员)。 + +他们也已经在[发布说明][4]中提到这一点: + +> 这个发布版本特别纪念了 Józef Kucia,他于 2019 年 8 月去世,年仅 30 岁。Józef 是 Wine 的 Direct3D 实现的一个主要贡献者,并且是 vkd3d 项目的首席开发人员。我们都非常怀念他的技能和友善。 + +### 如何在 Ubuntu 和 Linux Mint 上安装 Wine 5.0 + +> 注意: + +> 如果你在以前安装过 Wine,你应该将其完全移除,以(如你希望的)避免一些冲突。此外,WineHQ 存储库的密钥最近已被更改,针对你的 Linux 发行版的更多的操作指南,你可以参考它的[下载页面][5]。 + +Wine 5.0 的源码可在它的[官方网站][3]上获得。为了使其工作,你可以阅读更多关于[构建 Wine][6] 的信息。基于 Arch 的用户应该很快就会得到它。 + +在这里,我将向你展示在 Ubuntu 和其它基于 Ubuntu 的发行版上安装 Wine 5.0 的步骤。请耐心,并按照步骤一步一步安装和使用 Wine。这里涉及几个步骤。 + +请记住,Wine 安装了太多软件包。你会看到大量的软件包列表,下载大小约为 1.3 GB。 + +### 在 Ubuntu 上安装 Wine 5.0(不适用于 Linux Mint) + +首先,使用这个命令来移除现存的 Wine: + +``` +sudo apt remove winehq-stable wine-stable wine1.6 wine-mono wine-geco winetricks +``` + +然后确保添加 32 位体系结构支持: + +``` +sudo dpkg --add-architecture i386 +``` + +下载并添加官方 Wine 存储库密钥: + +``` +wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - +``` + +现在,接下来的步骤需要添加存储库,为此, 你需要首先[知道你的 Ubuntu 版本][7]。 + +对于 **Ubuntu 18.04 和 19.04**,用这个 PPA 添加 FAudio 依赖, **Ubuntu 19.10** 不需要它: + +``` +sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport +``` + +现在使用此命令添加存储库: + +``` +sudo apt-add-repository "deb https://dl.winehq.org/wine-builds/ubuntu $(lsb_release -cs) main" +``` + +现在你已经添加了正确的存储库,可以使用以下命令安装 Wine 5.0: + +``` +sudo apt update && sudo apt install --install-recommends winehq-stable +``` + +请注意,尽管[在软件包列表中将 Wine 5 列为稳定版][8],但你仍可能会看到 winehq-stable 的 wine 4.0.3。也许它不会传播到所有地理位置。从今天早上开始,我可以看到 Wine 5.0。 + +### 在 Linux Mint 19.1、19.2 和 19.3 中安装 Wine 5.0 + +正如一些读者通知我的那样,[apt-add 存储库命令][9]不适用于 Linux Mint 19.x 系列。 + +这是添加自定义存储库的另一种方法。你必须执行与 Ubuntu 相同的步骤。如删除现存的 Wine 包: + +``` +sudo apt remove winehq-stable wine-stable wine1.6 wine-mono wine-geco winetricks +``` + +添加 32 位支持: + +``` +sudo dpkg --add-architecture i386 +``` + +然后添加 GPG 密钥: + +``` +wget -qO - https://dl.winehq.org/wine-builds/winehq.key | sudo apt-key add - +``` + +添加 FAudio 依赖: + +``` +sudo add-apt-repository ppa:cybermax-dexter/sdl2-backport +``` + +现在为 Wine 存储库创建一个新条目: + +``` +sudo sh -c "echo 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main' >> /etc/apt/sources.list.d/winehq.list" +``` + +更新软件包列表并安装Wine: + +``` +sudo apt update && sudo apt install --install-recommends winehq-stable +``` + +### 总结 + +你尝试过最新的 Wine 5.0 发布版本吗?如果是的话,在运行中你看到什么改进? + +在下面的评论区域,让我知道你对新的发布版本的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/wine-5-release/ + +作者:[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://itsfoss.com/use-windows-applications-linux/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/wine_5.png?ssl=1 +[3]: https://www.winehq.org/news/2020012101 +[4]: https://www.winehq.org/announce/5.0 +[5]: https://wiki.winehq.org/Download +[6]: https://wiki.winehq.org/Building_Wine +[7]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[8]: https://dl.winehq.org/wine-builds/ubuntu/dists/bionic/main/binary-amd64/ +[9]: https://itsfoss.com/add-apt-repository-command-not-found/ diff --git a/published/20200107 Bash Script to Check How Long the High CPU-Memory Consumption Processes Runs on Linux.md b/published/20200107 Bash Script to Check How Long the High CPU-Memory Consumption Processes Runs on Linux.md new file mode 100644 index 0000000000..59ebd1255b --- /dev/null +++ b/published/20200107 Bash Script to Check How Long the High CPU-Memory Consumption Processes Runs on Linux.md @@ -0,0 +1,145 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12477-1.html) +[#]: subject: (Bash Script to Check How Long the High CPU/Memory Consumption Processes Runs on Linux) +[#]: via: (https://www.2daygeek.com/bash-script-to-check-how-long-the-high-cpu-memory-consumption-processes-runs-on-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +实用脚本:检查高 CPU / 内存消耗进程 +====== + +![](https://img.linux.net.cn/data/attachment/album/202008/01/205420jllu1nsngu9qszu5.jpg) + +过去,我们写了三篇不同的文章来使用 Linux 命令来识别这些进程。 + +你可以通过下面相关的 URL 立即访问: + + * [如何在 Linux 中找出 CPU 占用高的进程][1] + * [如何在 Linux 中找出内存消耗最大的进程][2] + * [在 Linux 中如何查找一个命令或进程的执行时间][3] + +本教程中包含两个脚本,它们可以帮助你确定 Linux 上高 CPU/内存消耗进程的运行时间。 + +该脚本将显示进程 ID、进程的所有者、进程的名称以及进程的运行时间。这将帮助你确定哪些(必须事先完成)作业正在超时运行。这可以使用 `ps` 命令来实现。 + +### 什么是 ps 命令 + +`ps` 是进程状态processes status,它显示有关系统上活动/正在运行的进程的信息。 + +它提供了当前进程的快照以及详细信息,例如用户名、用户 ID、CPU 使用率、内存使用率、进程开始日期和时间等。 + +#### 1)检查高 CPU 消耗进程在 Linux 上运行了多长时间的 Bash 脚本 + +该脚本将帮助你确定高 CPU 消耗进程在 Linux 上运行了多长时间。 + +``` +# vi /opt/scripts/long-running-cpu-proc.sh + +#!/bin/bash +ps -eo pid,user,ppid,%mem,%cpu,cmd --sort=-%cpu | head | tail -n +2 | awk '{print $1}' > /tmp/long-running-processes.txt +echo "--------------------------------------------------" +echo "UName PID CMD Process_Running_Time" +echo "--------------------------------------------------" +for userid in `cat /tmp/long-running-processes.txt` +do +username=$(ps -u -p $userid | tail -1 | awk '{print $1}') +pruntime=$(ps -p $userid -o etime | tail -1) +ocmd=$(ps -p $userid | tail -1 | awk '{print $4}') +echo "$username $userid $ocmd $pruntime" +done | column -t +echo "--------------------------------------------------" +``` + +给 `long-running-cpu-proc.sh` 设置可执行的 [Linux 文件权限][4]。 + +``` +# chmod +x /opt/scripts/long-running-cpu-proc.sh +``` + +运行此脚本时,你将获得类似以下的输出: + +``` +# sh /opt/scripts/long-running-cpu-proc.sh + +---------------------------------------------------- +UName PID CMD Process_Running_Time +---------------------------------------------------- +daygeek 5214 Web 01:18:48 +daygeek 5748 Web 01:08:20 +daygeek 8043 inkscape 22:11 +daygeek 5269 Web 01:18:31 +daygeek 1712 Web 10:44:50 +daygeek 5335 RDD 01:17:54 +daygeek 1639 firefox 10:44:51 +daygeek 7793 nautilus 24:14 +daygeek 6301 Web 57:40 +---------------------------------------------------- +``` + +#### 2)检查高内存消耗进程在 Linux 上运行了多长时间的 Bash 脚本 + +该脚本将帮助你确定最大的内存消耗进程在 Linux 上运行了多长时间。 + +``` +# sh /opt/scripts/long-running-memory-proc.sh + +#!/bin/bash +ps -eo pid,user,ppid,%mem,%cpu,cmd --sort=-%mem | head | tail -n +2 | awk '{print $1}' > /tmp/long-running-processes-1.txt +echo "--------------------------------------------------" +echo "UName PID CMD Process_Running_Time" +echo "--------------------------------------------------" +for userid in `cat /tmp/long-running-processes-1.txt` +do +username=$(ps -u -p $userid | tail -1 | awk '{print $1}') +pruntime=$(ps -p $userid -o etime | tail -1) +ocmd=$(ps -p $userid | tail -1 | awk '{print $4}') +echo "$username $userid $ocmd $pruntime" +done | column -t +echo "--------------------------------------------------" +``` + +给 `long-running-memory-proc.sh` 设置可执行的 Linux 文件权限。 + +``` +# chmod +x /opt/scripts/long-running-memory-proc.sh +``` + +运行此脚本时,你将获得类似以下的输出: + +``` +# sh /opt/scripts/long-running-memory-proc.sh + +---------------------------------------------------- +UName PID CMD Process_Running_Time +---------------------------------------------------- +daygeek 1639 firefox 10:44:56 +daygeek 2997 Web 10:39:54 +daygeek 5269 Web 01:18:37 +daygeek 1712 Web 10:44:55 +daygeek 8043 inkscape 22:17 +daygeek 5214 Web 01:18:54 +daygeek 1898 Web 10:44:48 +daygeek 1129 Xorg 10:45:07 +daygeek 6301 Web 57:45 +---------------------------------------------------- +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-script-to-check-how-long-the-high-cpu-memory-consumption-processes-runs-on-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11678-1.html +[2]: https://linux.cn/article-11542-1.html +[3]: https://linux.cn/article-10261-1.html +[4]: https://www.2daygeek.com/understanding-linux-file-permissions/ diff --git a/published/202002/20180503 How the four components of a distributed tracing system work together.md b/published/202002/20180503 How the four components of a distributed tracing system work together.md new file mode 100644 index 0000000000..1f073d897e --- /dev/null +++ b/published/202002/20180503 How the four components of a distributed tracing system work together.md @@ -0,0 +1,149 @@ +分布式跟踪系统的四大功能模块如何协同工作 +====== + +> 了解分布式跟踪中的主要体系结构决策,以及各部分如何组合在一起。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/touch-tracing.jpg?itok=rOmsY-nU) + +早在十年前,认真研究过分布式跟踪基本上只有学者和一小部分大型互联网公司中的人。对于任何采用微服务的组织来说,它如今成为一种筹码。其理由是确立的:微服务通常会发生让人意想不到的错误,而分布式跟踪则是描述和诊断那些错误的最好方法。 + +也就是说,一旦你准备将分布式跟踪集成到你自己的应用程序中,你将很快意识到对于不同的人来说“分布式跟踪Distributed Tracing”一词意味着不同的事物。此外,跟踪生态系统里挤满了具有相似内容的重叠项目。本文介绍了分布式跟踪系统中四个(可能)独立的功能模块,并描述了它们间将如何协同工作。 + +### 分布式跟踪:一种思维模型 + +大多数用于跟踪的思维模型来源于 [Google 的 Dapper 论文][1]。[OpenTracing][2] 使用相似的术语,因此,我们从该项目借用了以下术语: + +![Tracing][3] + +* 跟踪Trace:事物在分布式系统运行的过程描述。 +* 跨度Span:一种命名的定时操作,表示工作流的一部分。跨度可接受键值对标签以及附加到特定跨度实例的细粒度的、带有时间戳的结构化日志。 +* 跨度上下文Span context:携带分布式事务的跟踪信息,包括当它通过网络或消息总线将服务传递给服务时。跨度上下文包含跟踪标识符、跨度标识符以及跟踪系统所需传播到下游服务的任何其他数据。 + +如果你想要深入研究这种思维模式的细节,请仔细参照 [OpenTracing 技术规范][1]。 + +### 四大功能模块 + +从应用层分布式跟踪系统的观点来看,现代软件系统架构如下图所示: + +![Tracing][5] + +现代软件系统的组件可分为三类: + +* **应用程序和业务逻辑**:你的代码。 +* **广泛共享库**:他人的代码 +* **广泛共享服务**:他人的基础架构 + +这三类组件有着不同的需求,驱动着监控应用程序的分布式跟踪系统的设计。最终的设计得到了四个重要的部分: + +* 跟踪检测 APIA tracing instrumentation API:修饰应用程序代码 +* 线路协议Wire protocol:在 RPC 请求中与应用程序数据一同发送的规定 +* 数据协议Data protocol:将异步信息(带外)发送到你的分析系统的规定 +* 分析系统Analysis system:用于处理跟踪数据的数据库和交互式用户界面 + +为了更深入的解释这个概念,我们将深入研究驱动该设计的细节。如果你只需要我的一些建议,请跳转至下方的四大解决方案。 + +### 需求,细节和解释 + +应用程序代码、共享库以及共享式服务在操作上有显著的差别,这种差别严重影响了对其进行检测的请求操作。 + +#### 检测应用程序代码和业务逻辑 + +在任何特定的微服务中,由微服务开发者编写的大部分代码是应用程序或者商业逻辑。这部分代码规定了特定区域的操作。通常,它包含任何特殊、独一无二的逻辑判断,这些逻辑判断首先证明了创建新型微服务的合理性。基本上按照定义,**该代码通常不会在多个服务中共享或者以其他方式出现。** + +也即是说你仍需了解它,这也意味着需要以某种方式对它进行检测。一些监控和跟踪分析系统使用黑盒代理black-box agents自动检测代码,另一些系统更想使用显式的白盒检测工具。对于后者,抽象跟踪 API 提供了许多对于微服务的应用程序代码来说更为实用的优势: + +* 抽象 API 允许你在不重新编写检测代码的条件下换新的监视工具。你可能想要变更云服务提供商、供应商和监测技术,而一大堆不可移植的检测代码将会为该过程增加有意义的开销和麻烦。 +* 事实证明,除了生产监控之外,该工具还有其他有趣的用途。现有的项目使用相同的跟踪工具来驱动测试工具、分布式调试器、“混沌工程”故障注入器和其他元应用程序。 +* 但更重要的是,若将应用程序组件提取到共享库中要怎么办呢?由上述内容可得到结论: + +#### 检测共享库 + +在大多数应用程序中出现的实用程序代码(处理网络请求、数据库调用、磁盘写操作、线程、并发管理等)通常情况下是通用的,而非特别应用于某个特定应用程序。这些代码会被打包成库和框架,而后就可以被装载到许多的微服务上并且被部署到多种不同的环境中。 + +其真正的不同是:对于共享代码,其他人则成为了使用者。大多数用户有不同的依赖关系和操作风格。如果尝试去使用该共享代码,你将会注意到几个常见的问题: + +* 你需要一个 API 来编写检测。然而,你的库并不知道你正在使用哪个分析系统。会有多种选择,并且运行在相同应用下的所有库无法做出不兼容的选择。 +* 由于这些包封装了所有网络处理代码,因此从请求报头注入和提取跨度上下文的任务往往指向 RPC 库。然而,共享库必须了解到每个应用程序正在使用哪种跟踪协议。 +* 最后,你不想强制用户使用相互冲突的依赖项。大多数用户有不同的依赖关系和操作风格。即使他们使用 gRPC,绑定的 gRPC 版本是否相同?因此任何你的库附带用于跟踪的监控 API 必定是免于依赖的。 + +**因此,一个(a)没有依赖关系、(b)与线路协议无关、(c)使用流行的供应商和分析系统的抽象 API 应该是对检测共享库代码的要求。** + +#### 检测共享式服务 + +最后,有时整个服务(或微服务集合体)的通用性足以使许多独立的应用程序使用它们。这种共享式服务通常由第三方托管和管理,例如缓存服务器、消息队列以及数据库。 + +从应用程序开发者的角度来看,理解共享式服务本质上是黑盒子是极其重要的。它不可能将你的应用程序监控注入到共享式服务。恰恰相反,托管服务通常会运行它自己的监控方案。 + +### 四个方面的解决方案 + +因此,抽象的跟踪应用程序接口将会帮助库发出数据并且注入/抽取跨度上下文。标准的线路协议将会帮助黑盒服务相互连接,而标准的数据格式将会帮助分离的分析系统合并其中的数据。让我们来看一下部分有希望解决这些问题的方案。 + +#### 跟踪 API:OpenTracing 项目 + +如你所见,我们需要一个跟踪 API 来检测应用程序代码。为了将这种工具扩展到大多数进行跨度上下文注入和提取的共享库中,则必须以某种关键方式对 API 进行抽象。 + +[OpenTracing][2] 项目主要针对解决库开发者的问题,OpenTracing 是一个与供应商无关的跟踪 API,它没有依赖关系,并且迅速得到了许多监控系统的支持。这意味着,如果库附带了内置的本地 OpenTracing 工具,当监控系统在应用程序启动连接时,跟踪将会自动启动。 + +就个人而言,作为一个已经编写、发布和操作开源软件十多年的人,在 OpenTracing 项目上工作并最终解决这个观察性的难题令我十分满意。 + +除了 API 之外,OpenTracing 项目还维护了一个不断增长的工具列表,其中一些可以在[这里][6]找到。如果你想参与进来,无论是通过提供一个检测插件,对你自己的 OSS 库进行本地测试,或者仅仅只想问个问题,都可以通过 [Gitter][7] 向我们打招呼。 + +#### 线路协议: HTTP 报头 trace-context + +为了监控系统能进行互操作,以及减轻从一个监控系统切换为另外一个时带来的迁移问题,需要标准的线路协议来传播跨度上下文。 + +[w3c 分布式跟踪上下文社区小组][8]在努力制定此标准。目前的重点是制定一系列标准的 HTTP 报头。该规范的最新草案可以在[此处][9]找到。如果你对此小组有任何的疑问,[邮件列表][10]和[Gitter 聊天室][11]是很好的解惑地点。 + +(LCTT 译注:本文原文发表于 2018 年 5 月,可能现在社区已有不同进展) + +#### 数据协议 (还未出现!!) + +对于黑盒服务,在无法安装跟踪程序或无法与程序进行交互的情况下,需要使用数据协议从系统中导出数据。 + +目前这种数据格式和协议的开发工作尚处在初级阶段,并且大多在 w3c 分布式跟踪上下文工作组的上下文中进行工作。需要特别关注的是在标准数据模式中定义更高级别的概念,例如 RPC 调用、数据库语句等。这将允许跟踪系统对可用数据类型做出假设。OpenTracing 项目也通过定义一套[标准标签集][12]来解决这一事务。该计划是为了使这两项努力结果相互配合。 + +注意当前有一个中间地带。对于由应用程序开发者操作但不想编译或以其他方式执行代码修改的“网络设备”,动态链接可以帮助避免这种情况。主要的例子就是服务网格和代理,就像 Envoy 或者 NGINX。针对这种情况,可将兼容 OpenTracing 的跟踪器编译为共享对象,然后在运行时动态链接到可执行文件中。目前 [C++ OpenTracing API][13] 提供了该选项。而 JAVA 的 OpenTracing [跟踪器解析][14]也在开发中。 + +这些解决方案适用于支持动态链接,并由应用程序开发者部署的的服务。但从长远来看,标准的数据协议可以更广泛地解决该问题。 + +#### 分析系统:从跟踪数据中提取有见解的服务 + +最后不得不提的是,现在有足够多的跟踪监视解决方案。可以在[此处][15]找到已知与 OpenTracing 兼容的监控系统列表,但除此之外仍有更多的选择。我更鼓励你研究你的解决方案,同时希望你在比较解决方案时发现本文提供的框架能派上用场。除了根据监控系统的操作特性对其进行评级外(更不用提你是否喜欢 UI 和其功能),确保你考虑到了上述三个重要方面、它们对你的相对重要性以及你感兴趣的跟踪系统如何为它们提供解决方案。 + +### 结论 + +最后,每个部分的重要性在很大程度上取决于你是谁以及正在建立什么样的系统。举个例子,开源库的作者对 OpenTracing API 非常感兴趣,而服务开发者对 trace-context 规范更感兴趣。当有人说一部分比另一部分重要时,他们的意思通常是“一部分对我来说比另一部分重要”。 + +然而,事实是:分布式跟踪已经成为监控现代系统所必不可少的事物。在为这些系统进行构建模块时,“尽可能解耦”的老方法仍然适用。在构建像分布式监控系统一样的跨系统的系统时,干净地解耦组件是维持灵活性和前向兼容性地最佳方式。 + +感谢你的阅读!现在当你准备好在你自己的应用程序中实现跟踪服务时,你已有一份指南来了解他们正在谈论哪部分部分以及它们之间如何相互协作。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/distributed-tracing + +作者:[Ted Young][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[chenmu-kk](https://github.com/chenmu-kk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/tedsuo +[1]:https://research.google.com/pubs/pub36356.html +[2]:http://opentracing.io/ +[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/tracing1_0.png?itok=dvDTX0JJ (Tracing) +[4]:https://github.com/opentracing/specification/blob/master/specification.md +[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/tracing2_0.png?itok=yokjNLZk (Tracing) +[6]:https://github.com/opentracing-contrib/ +[7]:https://gitter.im/opentracing/public +[8]:https://www.w3.org/community/trace-context/ +[9]:https://w3c.github.io/distributed-tracing/report-trace-context.html +[10]:http://lists.w3.org/Archives/Public/public-trace-context/ +[11]:https://gitter.im/TraceContext/Lobby +[12]:https://github.com/opentracing/specification/blob/master/semantic_conventions.md +[13]:https://github.com/opentracing/opentracing-cpp +[14]:https://github.com/opentracing-contrib/java-tracerresolver +[15]:http://opentracing.io/documentation/pages/supported-tracers +[16]:https://events.linuxfoundation.org/kubecon-eu-2018/ +[17]:https://events.linuxfoundation.org/events/kubecon-cloudnativecon-north-america-2018/ diff --git a/published/202002/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md b/published/202002/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md new file mode 100644 index 0000000000..48ebc210e1 --- /dev/null +++ b/published/202002/20180511 MidnightBSD Could Be Your Gateway to FreeBSD.md @@ -0,0 +1,159 @@ +MidnightBSD:或许是你通往 FreeBSD 的大门 +====== + +![](https://www.linux.com/wp-content/uploads/2019/08/midnight_4_0.jpg) + +[FreeBSD][1] 是一个开源操作系统,衍生自著名的 [伯克利软件套件][2]Berkeley Software Distribution(BSD)。FreeBSD 的第一个版本发布于 1993 年,并且仍然在继续发展。2007 年左右,Lucas Holt 想要利用 OpenStep(现在是 Cocoa)的 Objective-C 框架、widget 工具包和应用程序开发工具的 [GnuStep][3] 实现,来创建一个 FreeBSD 的分支。为此,他开始开发 MidnightBSD 桌面发行版。 + +MidnightBSD(以 Lucas 的猫 Midnight 命名)仍然在积极地(尽管缓慢)开发。从 2017 年 8 月开始,可以获得最新的稳定发布版本(0.8.6)(LCTT 译注:截止至本译文发布时,当前是 2019/10/31 发布的 1.2 版)。尽管 BSD 发行版不是你所说的用户友好型发行版,但上手安装是熟悉如何处理 文本(ncurses)安装过程以及通过命令行完成安装的好方法。 + +这样,你最终会得到一个非常可靠的 FreeBSD 分支的桌面发行版。这需要花费一点精力,但是如果你是一名正在寻找扩展你的技能的 Linux 用户……这是一个很好的起点。 + +我将带你走过安装 MidnightBSD 的流程,如何添加一个图形桌面环境,然后如何安装应用程序。 + +### 安装 + +正如我所提到的,这是一个文本(ncurses)安装过程,因此在这里找不到可以用鼠标点击的地方。相反,你将使用你键盘的 `Tab` 键和箭头键。在你下载[最新的发布版本][4]后,将它刻录到一个 CD/DVD 或 USB 驱动器,并启动你的机器(或者在 [VirtualBox][5] 中创建一个虚拟机)。安装程序将打开并给你三个选项(图 1)。使用你的键盘的箭头键选择 “Install”,并敲击回车键。 + +![MidnightBSD installer][6] + +*图 1: 启动 MidnightBSD 安装程序。* + +在这里要经历相当多的屏幕。其中很多屏幕是一目了然的: + +1. 设置非默认键盘映射(是/否) +2. 设置主机名称 +3. 添加可选系统组件(文档、游戏、32 位兼容性、系统源码代码) +4. 对硬盘分区 +5. 管理员密码 +6. 配置网络接口 +7. 选择地区(时区) +8. 启用服务(例如 ssh) +9. 添加用户(图 2) + +![Adding a user][7] + +*图 2: 向系统添加一个用户。* + +在你向系统添加用户后,你将被进入到一个窗口中(图 3),在这里,你可以处理任何你可能忘记配置或你想重新配置的东西。如果你不需要作出任何更改,选择 “Exit”,然后你的配置就会被应用。 + +![Applying your configurations][8] + +*图 3: 应用你的配置。* + +在接下来的窗口中,当出现提示时,选择 “No”,接下来系统将重启。在 MidnightBSD 重启后,你已经为下一阶段的安装做好了准备。 + +### 后安装阶段 + +当你最新安装的 MidnightBSD 启动时,你将发现你自己处于命令提示符当中。此刻,还没有图形界面。要安装应用程序,MidnightBSD 依赖于 `mport` 工具。比如说你想安装 Xfce 桌面环境。为此,登录到 MidnightBSD 中,并发出下面的命令: + +``` +sudo mport index +sudo mport install xorg +``` + +你现在已经安装好 Xorg 窗口服务器了,它允许你安装桌面环境。使用命令来安装 Xfce : + +``` +sudo mport install xfce +``` + +现在 Xfce 已经安装好。不过,我们必须让它同命令 `startx` 一起启用。为此,让我们先安装 nano 编辑器。发出命令: + +``` +sudo mport install nano +``` + +随着 nano 安装好,发出命令: + +``` +nano ~/.xinitrc +``` + +这个文件仅包含一行内容: + +``` +exec startxfce4 +``` + +保存并关闭这个文件。如果你现在发出命令 `startx`, Xfce 桌面环境将会启动。你应该会感到有点熟悉了吧(图 4)。 + +![ Xfce][9] + +*图 4: Xfce 桌面界面已准备好服务。* + +因为你不会总是想必须发出命令 `startx`,你希望启用登录守护进程。然而,它却没有安装。要安装这个子系统,发出命令: + +``` +sudo mport install mlogind +``` + +当完成安装后,通过在 `/etc/rc.conf` 文件中添加一个项目来在启动时启用 mlogind。在 `rc.conf` 文件的底部,添加以下内容: + +``` +mlogind_enable=”YES” +``` + +保存并关闭该文件。现在,当你启动(或重启)机器时,你应该会看到图形登录屏幕。在写这篇文章的时候,在登录后我最后得到一个空白屏幕和讨厌的 X 光标。不幸的是,目前似乎并没有这个问题的解决方法。所以,要访问你的桌面环境,你必须使用 `startx` 命令。 + +### 安装应用 + +默认情况下,你找不到很多能可用的应用程序。如果你尝试使用 `mport` 安装应用程序,你很快就会感到沮丧,因为只能找到很少的应用程序。为解决这个问题,我们需要使用 `svnlite` 命令来查看检出的可用 mport 软件列表。回到终端窗口,并发出命令: + +``` +svnlite co http://svn.midnightbsd.org/svn/mports/trunk mports +``` + +在你完成这些后,你应该看到一个命名为 `~/mports` 的新目录。使用命令 `cd ~/.mports` 更改到这个目录。发出 `ls` 命令,然后你应该看到许多的类别(图 5)。 + +![applications][10] + +*图 5: mport 现在可用的应用程序类别。* + +你想安装 Firefox 吗?如果你查看 `www` 目录,你将看到一个 `linux-firefox` 列表。发出命令: + +``` +sudo mport install linux-firefox +``` + +现在你应该会在 Xfce 桌面菜单中看到一个 Firefox 项。翻找所有的类别,并使用 `mport` 命令来安装你需要的所有软件。 + +### 一个悲哀的警告 + +一个悲哀的小警告是,`mport` (通过 `svnlite`)仅能找到的一个办公套件的版本是 OpenOffice 3 。那是非常过时的。尽管在 `~/mports/editors` 目录中能找到 Abiword ,但是它看起来不能安装。甚至在安装 OpenOffice 3 后,它会输出一个执行格式错误。换句话说,你不能使用 MidnightBSD 在办公生产效率方面做很多的事情。但是,嘿嘿,如果你周围正好有一个旧的 Palm Pilot,你可以安装 pilot-link。换句话说,可用的软件不足以构成一个极其有用的桌面发行版……至少对普通用户不是。但是,如果你想在 MidnightBSD 上开发,你将找到很多可用的工具可以安装(查看 `~/mports/devel` 目录)。你甚至可以使用命令安装 Drupal : + +``` +sudo mport install drupal7 +``` + +当然,在此之后,你将需要创建一个数据库(MySQL 已经安装)、安装 Apache(`sudo mport install apache24`),并配置必要的 Apache 配置。 + +显然地,已安装的和可以安装的是一个应用程序、系统和服务的大杂烩。但是随着足够多的工作,你最终可以得到一个能够服务于特殊目的的发行版。 + +### 享受 \*BSD 优良 + +这就是如何使 MidnightBSD 启动,并使其运行某种有用的桌面发行版的方法。它不像很多其它的 Linux 发行版一样快速简便,但是如果你想要一个促使你思考的发行版,这可能正是你正在寻找的。尽管大多数竞争对手都准备了很多可以安装的应用软件,但 MidnightBSD 无疑是一个 Linux 爱好者或管理员应该尝试的有趣挑战。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/5/midnightbsd-could-be-your-gateway-freebsd + +作者:[Jack Wallen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[robsean](https://github.com/robsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.freebsd.org/ +[2]:https://en.wikipedia.org/wiki/Berkeley_Software_Distribution +[3]:https://en.wikipedia.org/wiki/GNUstep +[4]:http://www.midnightbsd.org/download/ +[5]:https://www.virtualbox.org/ +[6]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_1.jpg (MidnightBSD installer) +[7]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_2.jpg (Adding a user) +[8]:https://lcom.static.linuxfound.org/sites/lcom/files/mightnight_3.jpg (Applying your configurations) +[9]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_4.jpg (Xfce) +[10]:https://lcom.static.linuxfound.org/sites/lcom/files/midnight_5.jpg (applications) +[11]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/published/202002/20190114 Some Advice for How to Make Emacs Tetris Harder.md b/published/202002/20190114 Some Advice for How to Make Emacs Tetris Harder.md new file mode 100644 index 0000000000..7e06e1b241 --- /dev/null +++ b/published/202002/20190114 Some Advice for How to Make Emacs Tetris Harder.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11938-1.html) +[#]: subject: (Some Advice for How to Make Emacs Tetris Harder) +[#]: via: (https://nickdrozd.github.io/2019/01/14/tetris.html) +[#]: author: (nickdrozd https://nickdrozd.github.io) + +如何让 Emacs 俄罗斯方块变得更难 +====== + +你知道吗,Emacs 捆绑了一个俄罗斯方块的实现?只需要输入 `M-x tetris` 就行了。 + +![](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-normal.png) + +在对文本编辑器的讨论中,Emacs 鼓吹者经常提到这一点。“没错,但是你那个编辑器能运行俄罗斯方块吗?”我很好奇,这会让大家相信 Emacs 更优秀吗?比如,为什么有人会关心他们是否可以在文本编辑器中玩游戏呢?“没错,但是你那台吸尘器能播放 mp3 吗?” + +有人说,俄罗斯方块总是很有趣的。像 Emacs 中的所有东西一样,它的源代码是开放的,易于检查和修改,因此 **我们可以使它变得更加有趣**。所谓更加有趣,我的意思是更难。 + +让游戏变得更难的一个最简单的方法就是“隐藏下一个块预览”。你无法在知道下一个块会填满空间的情况下有意地将 S/Z 块放在一个危险的位置——你必须碰碰运气,希望出现最好的情况。下面是没有预览的情况(如你所见,没有预览,我做出的某些选择带来了“可怕的后果”): + +![](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-no-preview.png) + +预览框由一个名为 `tetris-draw-next-shape` [^1] 的函数设置: + +``` +(defun tetris-draw-next-shape () + (dotimes (x 4) + (dotimes (y 4) + (gamegrid-set-cell (+ tetris-next-x x) + (+ tetris-next-y y) + tetris-blank))) + (dotimes (i 4) + (let ((tetris-shape tetris-next-shape) + (tetris-rot 0)) + (gamegrid-set-cell (+ tetris-next-x + (aref (tetris-get-shape-cell i) 0)) + (+ tetris-next-y + (aref (tetris-get-shape-cell i) 1)) + tetris-shape)))) +``` + +首先,我们引入一个标志,决定是否允许显示下一个预览块 [^2]: + +``` +(defvar tetris-preview-next-shape nil + "When non-nil, show the next block the preview box.") +``` + +现在的问题是,我们如何才能让 `tetris-draw-next-shape` 遵从这个标志?最明显的方法是重新定义它: + +``` +(defun tetris-draw-next-shape () + (when tetris-preview-next-shape + ;; existing tetris-draw-next-shape logic + )) +``` + +但这不是理想的解决方案。同一个函数有两个定义,这很容易引起混淆,如果上游版本发生变化,我们必须维护修改后的定义。 + +一个更好的方法是使用 **advice**。Emacs 的 advice 类似于 **Python 装饰器**,但是更加灵活,因为 advice 可以从任何地方添加到函数中。这意味着我们可以修改函数而不影响原始的源文件。 + +有很多不同的方法使用 Emacs advice([查看手册][4]),但是这里我们只使用 `advice-add` 函数和 `:around` 标志。advice 函数将原始函数作为参数,原始函数可能执行也可能不执行。我们这里,我们让原始函数只有在预览标志是非空的情况下才能执行: + +``` +(defun tetris-maybe-draw-next-shape (tetris-draw-next-shape) + (when tetris-preview-next-shape + (funcall tetris-draw-next-shape))) + +(advice-add 'tetris-draw-next-shape :around #'tetris-maybe-draw-next-shape) +``` + +这段代码将修改 `tetris-draw-next-shape` 的行为,而且它可以存储在配置文件中,与实际的俄罗斯方块代码分离。 + +去掉预览框是一个简单的改变。一个更激烈的变化是,**让块随机停止在空中**: + +![](https://nickdrozd.github.io/assets/2019-01-14-tetris/tetris-air.png) + +本图中,红色的 I 和绿色的 T 部分没有掉下来,它们被固定下来了。这会让游戏变得 **极其困难**,但却很容易实现。 + +和前面一样,我们首先定义一个标志: + +``` +(defvar tetris-stop-midair t + "If non-nil, pieces will sometimes stop in the air.") +``` + +目前,**Emacs 俄罗斯方块的工作方式** 类似这样子:活动部件有 x 和 y 坐标。在每个时钟滴答声中,y 坐标递增(块向下移动一行),然后检查是否有与现存的块重叠。如果检测到重叠,则将该块回退(其 y 坐标递减)并设置该活动块到位。为了让一个块在半空中停下来,我们所要做的就是破解检测函数 `tetris-test-shape`。 + +**这个函数内部做什么并不重要** —— 重要的是它是一个返回布尔值的无参数函数。我们需要它在正常情况下返回布尔值 true(否则我们将出现奇怪的重叠情况),但在其他时候也需要它返回 true。我相信有很多方法可以做到这一点,以下是我的方法的: + +``` +(defun tetris-test-shape-random (tetris-test-shape) + (or (and + tetris-stop-midair + ;; Don't stop on the first shape. + (< 1 tetris-n-shapes ) + ;; Stop every INTERVAL pieces. + (let ((interval 7)) + (zerop (mod tetris-n-shapes interval))) + ;; Don't stop too early (it makes the game unplayable). + (let ((upper-limit 8)) + (< upper-limit tetris-pos-y)) + ;; Don't stop at the same place every time. + (zerop (mod (random 7) 10))) + (funcall tetris-test-shape))) + +(advice-add 'tetris-test-shape :around #'tetris-test-shape-random) +``` + +这里的硬编码参数使游戏变得更困难,但仍然可玩。当时我在飞机上喝醉了,所以它们可能需要进一步调整。 + +顺便说一下,根据我的 `tetris-scores` 文件,我的 **最高分** 是: + +``` +01389 Wed Dec 5 15:32:19 2018 +``` + +该文件中列出的分数默认最多为五位数,因此这个分数看起来不是很好。 + +### 给读者的练习 + +1. 使用 advice 修改 Emacs 俄罗斯方块,使得每当方块下移动时就闪烁显示讯息 “OH SHIT”。消息的大小与块堆的高度成比例(当没有块时,消息应该很小的或不存在的,当最高块接近天花板时,消息应该很大)。 +2. 在这里给出的 `tetris-test-shape-random` 版本中,每隔七格就有一个半空中停止。一个玩家有可能能计算出时间间隔,并利用它来获得优势。修改它,使间隔随机在一些合理的范围内(例如,每 5 到 10 格)。 +3. 另一个对使用 Tetris 使用 advise 的场景,你可以试试 [autotetris-mode][1]。 +4. 想出一个有趣的方法来打乱块的旋转机制,然后使用 advice 来实现它。 + +[^1]: Emacs 只有一个巨大的全局命名空间,因此函数和变量名一般以包名做前缀以避免冲突。 +[^2]: 很多人会说你不应该使用已有的命名空间前缀而且应该将自己定义的所有东西都放在一个预留的命名空间中,比如像这样 `my/tetris-preview-next-shape`,然而这样很难看而且没什么意义,因此我不会这么干。 + +-------------------------------------------------------------------------------- + +via: https://nickdrozd.github.io/2019/01/14/tetris.html + +作者:[nickdrozd][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://nickdrozd.github.io +[b]: https://github.com/lujun9972 +[1]: https://nullprogram.com/blog/2014/10/19/ +[2]: https://nickdrozd.github.io/2019/01/14/tetris.html#fn.1 +[3]: https://nickdrozd.github.io/2019/01/14/tetris.html#fn.2 +[4]: https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html +[5]: https://nickdrozd.github.io/2019/01/14/tetris.html#fnr.1 +[6]: https://nickdrozd.github.io/2019/01/14/tetris.html#fnr.2 diff --git a/sources/tech/20190116 Zipping files on Linux- the many variations and how to use them.md b/published/202002/20190116 Zipping files on Linux- the many variations and how to use them.md similarity index 61% rename from sources/tech/20190116 Zipping files on Linux- the many variations and how to use them.md rename to published/202002/20190116 Zipping files on Linux- the many variations and how to use them.md index fb98f78b06..fbd32f20ca 100644 --- a/sources/tech/20190116 Zipping files on Linux- the many variations and how to use them.md +++ b/published/202002/20190116 Zipping files on Linux- the many variations and how to use them.md @@ -1,21 +1,24 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11913-1.html) [#]: subject: (Zipping files on Linux: the many variations and how to use them) [#]: via: (https://www.networkworld.com/article/3333640/linux/zipping-files-on-linux-the-many-variations-and-how-to-use-them.html) [#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) -Zipping files on Linux: the many variations and how to use them +在 Linux 上压缩文件:zip 命令的各种变体及用法 ====== -![](https://images.idgesg.net/images/article/2019/01/zipper-100785364-large.jpg) -Some of us have been zipping files on Unix and Linux systems for many decades — to save some disk space and package files together for archiving. Even so, there are some interesting variations on zipping that not all of us have tried. So, in this post, we’re going to look at standard zipping and unzipping as well as some other interesting zipping options. +> 除了压缩和解压缩文件外,你还可以使用 zip 命令执行许多有趣的操作。这是一些其他的 zip 选项以及它们如何提供帮助。 -### The basic zip command +![](https://img.linux.net.cn/data/attachment/album/202002/21/120507ox11ak23f9x2hxaq.jpg) -First, let’s look at the basic **zip** command. It uses what is essentially the same compression algorithm as **gzip** , but there are a couple important differences. For one thing, the gzip command is used only for compressing a single file where zip can both compress files and join them together into an archive. For another, the gzip command zips “in place”. In other words, it leaves a compressed file — not the original file alongside the compressed copy. Here's an example of gzip at work: +为了节省一些磁盘空间并将文件打包在一起进行归档,我们中的一些人已经在 Unix 和 Linux 系统上压缩文件数十年了。即使这样,并不是所有人都尝试过一些有趣的压缩工具的变体。因此,在本文中,我们将介绍标准的压缩和解压缩以及其他一些有趣的压缩选项。 + +### 基本的 zip 命令 + +首先,让我们看一下基本的 `zip` 命令。它使用了与 `gzip` 基本上相同的压缩算法,但是有一些重要的区别。一方面,`gzip` 命令仅用于压缩单个文件,而 `zip` 既可以压缩文件,也可以将多个文件结合在一起成为归档文件。另外,`gzip` 命令是“就地”压缩。换句话说,它会只留下一个压缩文件,而原始文件则没有了。 这是工作中的 `gzip` 示例: ``` $ gzip onefile @@ -23,7 +26,7 @@ $ ls -l -rw-rw-r-- 1 shs shs 10514 Jan 15 13:13 onefile.gz ``` -And here's zip. Notice how this command requires that a name be provided for the zipped archive where gzip simply uses the original file name and adds the .gz extension. +而下面是 `zip`。请注意,此命令要求为压缩存档提供名称,其中 `gzip`(执行压缩操作后)仅使用原始文件名并添加 `.gz` 扩展名。 ``` $ zip twofiles.zip file* @@ -35,9 +38,9 @@ $ ls -l -rw-rw-r-- 1 shs shs 21289 Jan 15 13:35 twofiles.zip ``` -Notice also that the original files are still sitting there. +请注意,原始文件仍位于原处。 -The amount of disk space that is saved (i.e., the degree of compression obtained) will depend on the content of each file. The variation in the example below is considerable. +所节省的磁盘空间量(即获得的压缩程度)将取决于每个文件的内容。以下示例中的变化很大。 ``` $ zip mybin.zip ~/bin/* @@ -56,9 +59,9 @@ $ zip mybin.zip ~/bin/* adding: bin/tt (deflated 6%) ``` -### The unzip command +### unzip 命令 -The **unzip** command will recover the contents from a zip file and, as you'd likely suspect, leave the zip file intact, whereas a similar gunzip command would leave only the uncompressed file. +`unzip` 命令将从一个 zip 文件中恢复内容,并且,如你所料,原来的 zip 文件还保留在那里,而类似的 `gunzip` 命令将仅保留未压缩的文件。 ``` $ unzip twofiles.zip @@ -71,9 +74,9 @@ $ ls -l -rw-rw-r-- 1 shs shs 21289 Jan 15 13:35 twofiles.zip ``` -### The zipcloak command +### zipcloak 命令 -The **zipcloak** command encrypts a zip file, prompting you to enter a password twice (to help ensure you don't "fat finger" it) and leaves the file in place. You can expect the file size to vary a little from the original. +`zipcloak` 命令对一个 zip 文件进行加密,提示你输入两次密码(以确保你不会“胖手指”),然后将该文件原位存储。你可以想到,文件大小与原始文件会有所不同。 ``` $ zipcloak twofiles.zip @@ -89,11 +92,11 @@ total 204 unencrypted version ``` -Keep in mind that the original files are still sitting there unencrypted. +请记住,压缩包之外的原始文件仍处于未加密状态。 -### The zipdetails command +### zipdetails 命令 -The **zipdetails** command is going to show you details — a _lot_ of details about a zipped file, likely a lot more than you care to absorb. Even though we're looking at an encrypted file, zipdetails does display the file names along with file modification dates, user and group information, file length data, etc. Keep in mind that this is all "metadata." We don't see the contents of the files. +`zipdetails` 命令将向你显示详细信息:有关压缩文件的详细信息,可能比你想象的要多得多。即使我们正在查看一个加密的文件,`zipdetails` 也会显示文件名以及文件修改日期、用户和组信息、文件长度数据等。请记住,这都是“元数据”。我们看不到文件的内容。 ``` $ zipdetails twofiles.zip @@ -233,9 +236,9 @@ $ zipdetails twofiles.zip Done ``` -### The zipgrep command +### zipgrep命令 -The **zipgrep** command is going to use a grep-type feature to locate particular content in your zipped files. If the file is encrypted, you will need to enter the password provided for the encryption for each file you want to examine. If you only want to check the contents of a single file from the archive, add its name to the end of the zipgrep command as shown below. +`zipgrep` 命令将使用 `grep` 类的功能来找到压缩文件中的特定内容。如果文件已加密,则需要为要检查的每个文件输入为加密所提供的密码。如果只想检查归档文件中单个文件的内容,请将其名称添加到 `zipgrep` 命令的末尾,如下所示。 ``` $ zipgrep hazard twofiles.zip file1 @@ -243,9 +246,9 @@ $ zipgrep hazard twofiles.zip file1 Certain pesticides should be banned since they are hazardous to the environment. ``` -### The zipinfo command +### zipinfo 命令 -The **zipinfo** command provides information on the contents of a zipped file whether encrypted or not. This includes the file names, sizes, dates and permissions. +`zipinfo` 命令提供有关压缩文件内容的信息,无论是否加密。这包括文件名、大小、日期和权限。 ``` $ zipinfo twofiles.zip @@ -256,9 +259,9 @@ Zip file size: 21313 bytes, number of entries: 2 2 files, 116954 bytes uncompressed, 20991 bytes compressed: 82.1% ``` -### The zipnote command +### zipnote 命令 -The **zipnote** command can be used to extract comments from zip archives or add them. To display comments, just preface the name of the archive with the command. If no comments have been added previously, you will see something like this: +`zipnote` 命令可用于从 zip 归档中提取注释或添加注释。要显示注释,只需在命令前面加上归档名称即可。如果之前未添加任何注释,你将看到类似以下内容: ``` $ zipnote twofiles.zip @@ -269,21 +272,21 @@ $ zipnote twofiles.zip @ (zip file comment below this line) ``` -If you want to add comments, write the output from the zipnote command to a file: +如果要添加注释,请先将 `zipnote` 命令的输出写入到文件: ``` $ zipnote twofiles.zip > comments ``` -Next, edit the file you've just created, inserting your comments above the **(comment above this line)** lines. Then add the comments using a zipnote command like this one: +接下来,编辑你刚刚创建的文件,将注释插入到 `(comment above this line)` 行上方。然后使用像这样的 `zipnote` 命令添加注释: ``` $ zipnote -w twofiles.zip < comments ``` -### The zipsplit command +### zipsplit 命令 -The **zipsplit** command can be used to break a zip archive into multiple zip archives when the original file is too large — maybe because you're trying to add one of the files to a small thumb drive. The easiest way to do this seems to be to specify the max size for each of the zipped file portions. This size must be large enough to accomodate the largest included file. +当归档文件太大时,可以使用 `zipsplit` 命令将一个 zip 归档文件分解为多个 zip 归档文件,这样你就可以将其中某一个文件放到小型 U 盘中。最简单的方法似乎是为每个部分的压缩文件指定最大大小,此大小必须足够大以容纳最大的所包含的文件。 ``` $ zipsplit -n 12000 twofiles.zip @@ -296,15 +299,11 @@ $ ls twofile*.zip -rw-rw-r-- 1 shs shs 21377 Jan 15 14:27 twofiles.zip ``` -Notice how the extracted files are sequentially named "twofile1" and "twofile2". +请注意,提取的文件是如何依次命名为 `twofile1` 和 `twofile2` 的。 -### Wrap-up +### 总结 -The **zip** command, along with some of its zipping compatriots, provide a lot of control over how you generate and work with compressed file archives. - -**[ Also see:[Invaluable tips and tricks for troubleshooting Linux][1] ]** - -Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind. +`zip` 命令及其一些压缩工具变体,对如何生成和使用压缩文件归档提供了很多控制。 -------------------------------------------------------------------------------- @@ -312,8 +311,8 @@ via: https://www.networkworld.com/article/3333640/linux/zipping-files-on-linux-t 作者:[Sandra Henry-Stocker][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202002/20190322 12 open source tools for natural language processing.md b/published/202002/20190322 12 open source tools for natural language processing.md new file mode 100644 index 0000000000..ee4bf2e0ec --- /dev/null +++ b/published/202002/20190322 12 open source tools for natural language processing.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (zhangxiangping) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11927-1.html) +[#]: subject: (12 open source tools for natural language processing) +[#]: via: (https://opensource.com/article/19/3/natural-language-processing-tools) +[#]: author: (Dan Barker https://opensource.com/users/barkerd427) + +12 种自然语言处理的开源工具 +====== + +> 让我们看看可以用在你自己的 NLP 应用中的十几个工具吧。 + +![](https://img.linux.net.cn/data/attachment/album/202002/25/103230j77i7zx8uyymj7y3.jpg) + +在过去的几年里,自然语言处理(NLP)推动了聊天机器人、语音助手、文本预测等这些渗透到我们的日常生活中的语音或文本应用程技术的发展。目前有着各种各样开源的 NLP 工具,所以我决定调查一下当前开源的 NLP 工具来帮助你制定开发下一个基于语音或文本的应用程序的计划。 + +尽管我并不熟悉所有工具,但我将从我所熟悉的编程语言出发来介绍这些工具(对于我不熟悉的语言,我无法找到大量的工具)。也就是说,出于各种原因,我排除了三种我熟悉的语言之外的工具。 + +R 语言可能是没有被包含在内的最重要的语言,因为我发现的大多数库都有一年多没有更新了。这并不一定意味着它们没有得到很好的维护,但我认为它们应该得到更多的更新,以便和同一领域的其他工具竞争。我还选择了最有可能用在生产场景中的语言和工具(而不是在学术界和研究中使用),而我主要是使用 R 作为研究和发现工具。 + +我也惊讶地发现 Scala 的很多库都没有更新了。我上次使用 Scala 已经过去了两年了,当时它非常流行。但是大多数库从那个时候就再没有更新过,或者只有少数一些有更新。 + +最后,我排除了 C++。 这主要是因为我上次使用 C++ 编写程序已经有很多年了,而我所工作的组织还没有将 C++ 用于 NLP 或任何数据科学方面的工作。 + +### Python 工具 + +#### 自然语言工具包(NLTK) + +毋庸置疑,[自然语言工具包(NLTK)][2]是我调研过的所有工具中功能最完善的一个。它几乎实现了自然语言处理中多数功能组件,比如分类、令牌化、词干化、标注、分词和语义推理。每一个都有多种不同的实现方式,所以你可以选择具体的算法和方式。同时,它也支持不同的语言。然而,它以字符串的形式表示所有的数据,对于一些简单的数据结构来说可能很方便,但是如果要使用一些高级的功能来说就可能有点困难。它的使用文档有点复杂,但也有很多其他人编写的使用文档,比如[这本很棒的书][3]。和其他的工具比起来,这个工具库的运行速度有点慢。但总的来说,这个工具包非常不错,可以用于需要具体算法组合的实验、探索和实际应用当中。 + +#### SpaCy + +[SpaCy][4] 可能是 NLTK 的主要竞争者。在大多数情况下都比 NLTK 的速度更快,但是 SpaCy 的每个自然语言处理的功能组件只有一个实现。SpaCy 把所有的东西都表示为一个对象而不是字符串,从而简化了应用构建接口。这也方便它与多种框架和数据科学工具的集成,使得你更容易理解你的文本数据。然而,SpaCy 不像 NLTK 那样支持多种语言。它确实接口简单,具有简化的选项集和完备的文档,以及用于语言处理和分析各种组件的多种神经网络模型。总的来说,对于需要在生产中表现出色且不需要特定算法的新应用程序,这是一个很不错的工具。 + +#### TextBlob + +[TextBlob][5] 是 NLTK 的一个扩展库。你可以通过 TextBlob 用一种更简单的方式来使用 NLTK 的功能,TextBlob 也包括了 Pattern 库中的功能。如果你刚刚开始学习,这将会是一个不错的工具,可以用于对性能要求不太高的生产环境的应用。总体来说,TextBlob 适用于任何场景,但是对小型项目尤佳。 + +#### Textacy + +这个工具是我用过的名字最好听的。先重读“ex”再带出“cy”,多读“[Textacy][6]”几次试试。它不仅仅是名字读起来好,同时它本身也是一个很不错的工具。它使用 SpaCy 作为它自然语言处理核心功能,但它在处理过程的前后做了很多工作。如果你想要使用 SpaCy,那么最好使用 Textacy,从而不用去编写额外的附加代码就可以处理不同种类的数据。 + +#### PyTorch-NLP + +[PyTorch-NLP][7] 才出现短短的一年,但它已经有一个庞大的社区了。它适用于快速原型开发。当出现了最新的研究,或大公司或者研究人员推出了完成新奇的处理任务的其他工具时,比如图像转换,它就会被更新。总体来说,PyTorch 的目标用户是研究人员,但它也能用于原型开发,或使用最先进算法的初始生产载荷中。基于此基础上的创建的库也是值得研究的。 + +### Node.js 工具 + +#### Retext + +[Retext][8] 是 [Unified 集合][9]的一部分。Unified 是一个接口,能够集成不同的工具和插件以便它们能够高效的工作。Retext 是 Unified 工具中使用的三种语法之一,另外的两个分别是用于 Markdown 的 Remark 和用于 HTML 的 Rehype。这是一个非常有趣的想法,我很高兴看到这个社区的发展。Retext 没有涉及很多的底层技术,更多的是使用插件去完成你在 NLP 任务中想要做的事情。拼写检查、字形修复、情绪检测和增强可读性都可以用简单的插件来完成。总体来说,如果你不想了解底层处理技术又想完成你的任务的话,这个工具和社区是一个不错的选择。 + +#### Compromise + +[Compromise][10] 显然不是最复杂的工具,如果你正在找拥有最先进的算法和最完备的系统的话,它可能不适合你。然而,如果你想要一个性能好、功能广泛、还能在客户端运行的工具的话,Compromise 值得一试。总体来说,它的名字(“折中”)是准确的,因为作者更关注更具体功能的小软件包,而在功能性和准确性上有所折中,这些小软件包得益于用户对使用环境的理解。 + +#### Natural + +[Natural][11] 包含了常规自然语言处理库所具有的大多数功能。它主要是处理英文文本,但也包括一些其它语言,它的社区也欢迎支持其它的语言。它能够进行令牌化、词干化、分类、语音处理、词频-逆文档频率计算(TF-IDF)、WordNet、字符相似度计算和一些变换。它和 NLTK 有的一比,因为它想要把所有东西都包含在一个包里头,但它更易于使用,而且不一定专注于研究。总的来说,这是一个非常完整的库,目前仍在活跃开发中,但可能需要对底层实现有更多的了解才能完全发挥效力。 + +#### Nlp.js + +[Nlp.js][12] 建立在其他几个 NLP 库之上,包括 Franc 和 Brain.js。它为许多 NLP 组件提供了一个很好的接口,比如分类、情感分析、词干化、命名实体识别和自然语言生成。它也支持一些其它语言,在你处理英语之外的语言时能提供一些帮助。总之,它是一个不错的通用工具,并且提供了调用其他工具的简化接口。在你需要更强大或更灵活的工具之前,这个工具可能会在你的应用程序中用上很长一段时间。 + +### Java 工具 + +#### OpenNLP + +[OpenNLP][13] 是由 Apache 基金会管理的,所以它可以很方便地集成到其他 Apache 项目中,比如 Apache Flink、Apache NiFi 和 Apache Spark。这是一个通用的 NLP 工具,包含了所有 NLP 组件中的通用功能,可以通过命令行或者以包的形式导入到应用中来使用它。它也支持很多种语言。OpenNLP 是一个很高效的工具,包含了很多特性,如果你用 Java 开发生产环境产品的话,它是个很好的选择。 + +#### Stanford CoreNLP + +[Stanford CoreNLP][14] 是一个工具集,提供了统计 NLP、深度学习 NLP 和基于规则的 NLP 功能。这个工具也有许多其他编程语言的版本,所以可以脱离 Java 来使用。它是由高水平的研究机构创建的一个高效的工具,但在生产环境中可能不是最好的。此工具采用双许可证,具有可以用于商业目的的特定许可证。总之,在研究和实验中它是一个很棒的工具,但在生产系统中可能会带来一些额外的成本。比起 Java 版本来说,读者可能对它的 Python 版本更感兴趣。同样,在 Coursera 上最好的机器学习课程之一是斯坦福教授提供的,[点此][15]访问其他不错的资源。 + +#### CogCompNLP + +[CogCompNLP][16] 由伊利诺斯大学开发的一个工具,它也有一个相似功能的 Python 版本。它可以用于处理文本,包括本地处理和远程处理,能够极大地缓解你本地设备的压力。它提供了很多处理功能,比如令牌化、词性标注、断句、命名实体标注、词型还原、依存分析和语义角色标注。它是一个很好的研究工具,你可以自己探索它的不同功能。我不确定它是否适合生产环境,但如果你使用 Java 的话,它值得一试。 + +* * * + +你最喜欢的开源 NLP 工具和库是什么?请在评论区分享文中没有提到的工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/natural-language-processing-tools + +作者:[Dan Barker][a] +选题:[lujun9972][b] +译者:[zxp](https://github.com/zhangxiangping) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/barkerd427 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_communication_team.png?itok=CYfZ_gE7 (Chat bubbles) +[2]: http://www.nltk.org/ +[3]: http://www.nltk.org/book_1ed/ +[4]: https://spacy.io/ +[5]: https://textblob.readthedocs.io/en/dev/ +[6]: https://readthedocs.org/projects/textacy/ +[7]: https://pytorchnlp.readthedocs.io/en/latest/ +[8]: https://www.npmjs.com/package/retext +[9]: https://unified.js.org/ +[10]: https://www.npmjs.com/package/compromise +[11]: https://www.npmjs.com/package/natural +[12]: https://www.npmjs.com/package/node-nlp +[13]: https://opennlp.apache.org/ +[14]: https://stanfordnlp.github.io/CoreNLP/ +[15]: https://opensource.com/article/19/2/learn-data-science-ai +[16]: https://github.com/CogComp/cogcomp-nlp diff --git a/published/202002/20190407 Manage multimedia files with Git.md b/published/202002/20190407 Manage multimedia files with Git.md new file mode 100644 index 0000000000..befd819d4f --- /dev/null +++ b/published/202002/20190407 Manage multimedia files with Git.md @@ -0,0 +1,236 @@ +[#]: collector: (lujun9972) +[#]: translator: (svtter) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11889-1.html) +[#]: subject: (Manage multimedia files with Git) +[#]: via: (https://opensource.com/article/19/4/manage-multimedia-files-git) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + + +通过 Git 来管理多媒体文件 +====== + +> 在我们有关 Git 鲜为人知的用法系列的最后一篇文章中,了解如何使用 Git 跟踪项目中的大型多媒体文件。 + +![](https://img.linux.net.cn/data/attachment/album/202002/13/235436mhub12qhxzmbw11p.png) + +Git 是专用于源代码版本控制的工具。因此,Git 很少被用于非纯文本的项目以及行业。然而,异步工作流的优点是十分诱人的,尤其是在一些日益增长的行业中,这种类型的行业把重要的计算和重要的艺术创作结合起来,这包括网页设计、视觉效果、视频游戏、出版、货币设计(是的,这是一个真实的行业)、教育……等等。还有许多行业属于这个类型。 + +在这个 Git 系列文章中,我们分享了六种鲜为人知的 Git 使用方法。在最后一篇文章中,我们将介绍将 Git 的优点带到管理多媒体文件的软件。 + +### Git 管理多媒体文件的问题 + +众所周知,Git 用于处理非文本文件不是很好,但是这并不妨碍我们进行尝试。下面是一个使用 Git 来复制照片文件的例子: + +``` +$ du -hs +108K . +$ cp ~/photos/dandelion.tif . +$ git add dandelion.tif +$ git commit -m 'added a photo' +[master (root-commit) fa6caa7] two photos + 1 file changed, 0 insertions(+), 0 deletions(-) + create mode 100644 dandelion.tif +$ du -hs +1.8M . +``` + +目前为止没有什么异常。增加一个 1.8MB 的照片到一个目录下,使得目录变成了 1.8 MB 的大小。所以下一步,我们尝试删除文件。 + +``` +$ git rm dandelion.tif +$ git commit -m 'deleted a photo' +$ du -hs +828K . +``` + +在这里我们可以看到有些问题:删除一个已经被提交的文件,还是会使得存储库的大小扩大到原来的 8 倍(从 108K 到 828K)。我们可以测试多次来得到一个更好的平均值,但是这个简单的演示与我的经验一致。提交非文本文件,在一开始花费空间比较少,但是一个工程活跃地时间越长,人们可能对静态内容修改的会更多,更多的零碎文件会被加和到一起。当一个 Git 存储库变的越来越大,主要的成本往往是速度。拉取和推送的时间,从最初抿一口咖啡的时间到你觉得你可能断网了。 + +静态内容导致 Git 存储库的体积不断扩大的原因是什么呢?那些通过文本的构成的文件,允许 Git 只拉取那些修改的部分。光栅图以及音乐文件对 Git 文件而言与文本不同,你可以查看一下 .png 和 .wav 文件中的二进制数据。所以,Git 只不过是获取了全部的数据,并且创建了一个新的副本,哪怕是一张图仅仅修改了一个像素。 + +### Git-portal + +在实践中,许多多媒体项目不需要或者不想追踪媒体的历史记录。相对于文本或者代码的部分,项目的媒体部分一般有一个不同的生命周期。媒体资源一般按一个方向产生:一张图片从铅笔草稿开始,以数字绘画的形式抵达它的目的地。然后,尽管文本能够回滚到早起的版本,但是艺术制品只会一直向前发展。工程中的媒体很少被绑定到一个特定的版本。例外情况通常是反映数据集的图形,通常是可以用基于文本的格式(如 SVG)完成的表、图形或图表。 + +所以,在许多同时包含文本(无论是叙事散文还是代码)和媒体的工程中,Git 是一个用于文件管理的,可接受的解决方案,只要有一个在版本控制循环之外的游乐场来给艺术家游玩就行。 + +![Graphic showing relationship between art assets and Git][2] + +一个启用这个特性的简单方法是 [Git-portal][3],这是一个通过带有 Git 钩子的 Bash 脚本,它可将静态文件从文件夹中移出 Git 的范围,并通过符号链接来取代它们。Git 提交链接文件(有时候称作别名或快捷方式),这种符号链接文件比较小,所以所有的提交都是文本文件和那些代表媒体文件的链接。因为替身文件是符号链接,所以工程还会像预期的运行,因为本地机器会处理他们,转换成“真实的”副本。当用符号链接替换出文件时,Git-portal 维护了项目的结构,因此,如果你认为 Git-portal 不适合你的项目,或者你需要构建项目的一个没有符号链接的版本(比如用于分发),则可以轻松地逆转该过程。 + +Git-portal 也允许通过 `rsync` 来远程同步静态资源,所以用户可以设置一个远程存储位置,来做为一个中心的授权源。 + +Git-portal 对于多媒体的工程是一个理想的解决方案。类似的多媒体工程包括视频游戏、桌面游戏、需要进行大型 3D 模型渲染和纹理的虚拟现实工程、[带图][4]以及 .odt 输出的书籍、协作型的[博客站点][5]、音乐项目,等等。艺术家在应用程序中以图层(在图形世界中)和曲目(在音乐世界中)的形式执行版本控制并不少见——因此,Git 不会向多媒体项目文件本身添加任何内容。Git 的功能可用于艺术项目的其他部分(例如散文和叙述、项目管理、字幕文件、致谢、营销副本、文档等),而结构化远程备份的功能则由艺术家使用。 + +#### 安装 Git-portal + +Git-portal 的 RPM 安装包位于 ,可用于下载和安装。 + +此外,用户可以从 Git-portal 的 Gitlab 主页手动安装。这仅仅是一个 Bash 脚本以及一些 Git 钩子(也是 Bash 脚本),但是需要一个快速的构建过程来让它知道安装的位置。 + +``` +$ git clone https://gitlab.com/slackermedia/git-portal.git git-portal.clone +$ cd git-portal.clone +$ ./configure +$ make +$ sudo make install +``` + +#### 使用 Git-portal + +Git-portal 与 Git 一起使用。这意味着,如同 Git 的所有大型文件扩展一样,都需要记住一些额外的步骤。但是,你仅仅需要在处理你的媒体资源的时候使用 Git-portal,所以很容易记住,除非你把大文件都当做文本文件来进行处理(对于 Git 用户很少见)。使用 Git-portal 必须做的一个安装步骤是: + +``` +$ mkdir bigproject.git +$ cd !$ +$ git init +$ git-portal init +``` + +Git-portal 的 `init` 函数在 Git 存储库中创建了一个 `_portal` 文件夹并且添加到 `.gitignore` 文件中。 + +在平日里使用 Git-portal 和 Git 协同十分平滑。一个较好的例子是基于 MIDI 的音乐项目:音乐工作站产生的项目文件是基于文本的,但是 MIDI 文件是二进制数据: + +``` +$ ls -1 +_portal +song.1.qtr +song.qtr +song-Track_1-1.mid +song-Track_1-3.mid +song-Track_2-1.mid +$ git add song*qtr +$ git-portal song-Track*mid +$ git add song-Track*mid +``` + +如果你查看一下 `_portal` 文件夹,你会发现那里有最初的 MIDI 文件。这些文件在原本的位置被替换成了指向 `_portal` 的链接文件,使得音乐工作站像预期一样运行。 + +``` +$ ls -lG +[...] _portal/ +[...] song.1.qtr +[...] song.qtr +[...] song-Track_1-1.mid -> _portal/song-Track_1-1.mid* +[...] song-Track_1-3.mid -> _portal/song-Track_1-3.mid* +[...] song-Track_2-1.mid -> _portal/song-Track_2-1.mid* +``` + +与 Git 相同,你也可以添加一个目录下的文件。 + +``` +$ cp -r ~/synth-presets/yoshimi . +$ git-portal add yoshimi +Directories cannot go through the portal. Sending files instead. +$ ls -lG _portal/yoshimi +[...] yoshimi.stat -> ../_portal/yoshimi/yoshimi.stat* +``` + +删除功能也像预期一样工作,但是当从 `_portal` 中删除一些东西时,你应该使用 `git-portal rm` 而不是 `git rm`。使用 Git-portal 可以确保文件从 `_portal` 中删除: + +``` +$ ls +_portal/ song.qtr song-Track_1-3.mid@ yoshimi/ +song.1.qtr song-Track_1-1.mid@ song-Track_2-1.mid@ +$ git-portal rm song-Track_1-3.mid +rm 'song-Track_1-3.mid' +$ ls _portal/ +song-Track_1-1.mid* song-Track_2-1.mid* yoshimi/ +``` + +如果你忘记使用 Git-portal,那么你需要手动删除 `_portal` 下的文件: + +``` +$ git-portal rm song-Track_1-1.mid +rm 'song-Track_1-1.mid' +$ ls _portal/ +song-Track_1-1.mid* song-Track_2-1.mid* yoshimi/ +$ trash _portal/song-Track_1-1.mid +``` + +Git-portal 其它的唯一功能,是列出当前所有的链接并且找到里面可能已经损坏的符号链接。有时这种情况会因为项目文件夹中的文件被移动而发生: + +``` +$ mkdir foo +$ mv yoshimi foo +$ git-portal status +bigproject.git/song-Track_2-1.mid: symbolic link to _portal/song-Track_2-1.mid +bigproject.git/foo/yoshimi/yoshimi.stat: broken symbolic link to ../_portal/yoshimi/yoshimi.stat +``` + +如果你使用 Git-portal 用于私人项目并且维护自己的备份,以上就是技术方面所有你需要知道关于 Git-portal 的事情了。如果你想要添加一个协作者或者你希望 Git-portal 来像 Git 的方式来管理备份,你可以创建一个远程位置。 + +#### 增加 Git-portal 远程位置 + +为 Git-portal 增加一个远程位置是通过 Git 已有的远程功能来实现的。Git-portal 实现了 Git 钩子(隐藏在存储库 `.git` 文件夹中的脚本),来寻找你的远程位置上是否存在以 `_portal` 开头的文件夹。如果它找到一个,它会尝试使用 `rsync` 来与远程位置同步文件。Git-portal 在用户进行 Git 推送以及 Git 合并的时候(或者在进行 Git 拉取的时候,实际上是进行一次获取和自动合并),都会执行此操作。 + +如果你仅克隆了 Git 存储库,那么你可能永远不会自己添加一个远程位置。这是一个标准的 Git 过程: + +``` +$ git remote add origin git@gitdawg.com:seth/bigproject.git +$ git remote -v +origin git@gitdawg.com:seth/bigproject.git (fetch) +origin git@gitdawg.com:seth/bigproject.git (push) +``` + +对你的主要 Git 存储库来说,`origin` 这个名字是一个流行的惯例,将其用于 Git 数据是有意义的。然而,你的 Git-portal 数据是分开存储的,所以你必须创建第二个远程位置来让 Git-portal 了解向哪里推送和从哪里拉取。取决于你的 Git 主机,你可能需要一个单独的服务器,因为空间有限的 Git 主机不太可能接受 GB 级的媒体资产。或者,可能你的服务器仅允许你访问你的 Git 存储库而不允许访问外部的存储文件夹: + +``` +$ git remote add _portal seth@example.com:/home/seth/git/bigproject_portal +$ git remote -v +origin git@gitdawg.com:seth/bigproject.git (fetch) +origin git@gitdawg.com:seth/bigproject.git (push) +_portal seth@example.com:/home/seth/git/bigproject_portal (fetch) +_portal seth@example.com:/home/seth/git/bigproject_portal (push) +``` + +你可能不想为所有用户提供服务器上的个人帐户,也不必这样做。为了提供对托管资源库大文件资产的服务器的访问权限,你可以运行一个 Git 前端,比如 [Gitolite][8] 或者你可以使用 `rrsync` (受限的 rsync)。 + +现在你可以推送你的 Git 数据到你的远程 Git 存储库,并将你的 Git-portal 数据到你的远程的门户: + +``` +$ git push origin HEAD +master destination detected +Syncing _portal content... +sending incremental file list +sent 9,305 bytes received 18 bytes 1,695.09 bytes/sec +total size is 60,358,015 speedup is 6,474.10 +Syncing _portal content to example.com:/home/seth/git/bigproject_portal +``` + +如果你已经安装了 Git-portal,并且配置了 `_portal` 的远程位置,你的 `_portal` 文件夹将会被同步,并且从服务器获取新的内容,以及在每一次推送的时候发送新的内容。尽管你不需要进行 Git 提交或者推送来和服务器同步(用户可以使用直接使用 `rsync`),但是我发现对于艺术性内容的改变,提交是有用的。这将会把艺术家及其数字资产集成到工作流的其余部分中,并提供有关项目进度和速度的有用元数据。 + +### 其他选择 + +如果 Git-portal 对你而言太过简单,还有一些用于 Git 管理大型文件的其他选择。[Git 大文件存储][9](LFS)是一个名为 git-media 的停工项目的分支,这个分支由 GitHub 维护和支持。它需要特殊的命令(例如 `git lfs track` 来保护大型文件不被 Git 追踪)并且需要用户维护一个 `.gitattributes` 文件来更新哪些存储库中的文件被 LFS 追踪。对于大文件而言,它**仅**支持 HTTP 和 HTTPS 远程主机。所以你必须配置 LFS 服务器,才能使得用户可以通过 HTTP 而不是 SSH 或 `rsync` 来进行鉴权。 + +另一个相对 LFS 更灵活的选择是 [git-annex][10]。你可以在我的文章 [管理 Git 中大二进制 blob][11] 中了解更多(忽略其中 git-media 这个已经废弃项目的章节,因为其灵活性没有被它的继任者 Git LFS 延续下来)。Git-annex 是一个灵活且优雅的解决方案。它拥有一个细腻的系统来用于添加、删除、移动存储库中的大型文件。因为它灵活且强大,有很多新的命令和规则需要进行学习,所以建议看一下它的[文档][12]。 + +然而,如果你的需求很简单,你可能更加喜欢整合已有技术来进行简单且明显任务的解决方案,则 Git-portal 可能是对于工作而言比较合适的工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/manage-multimedia-files-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[svtter](https://github.com/svtter) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/video_editing_folder_music_wave_play.png?itok=-J9rs-My (video editing dashboard) +[2]: https://opensource.com/sites/default/files/uploads/git-velocity.jpg (Graphic showing relationship between art assets and Git) +[3]: http://gitlab.com/slackermedia/git-portal.git +[4]: https://www.apress.com/gp/book/9781484241691 +[5]: http://mixedsignals.ml +[6]: mailto:git@gitdawg.com +[7]: mailto:seth@example.com +[8]: https://opensource.com/article/19/4/file-sharing-git +[9]: https://git-lfs.github.com/ +[10]: https://git-annex.branchable.com/ +[11]: https://opensource.com/life/16/8/how-manage-binary-blobs-git-part-7 +[12]: https://git-annex.branchable.com/walkthrough/ diff --git a/published/202002/20190729 How to structure a multi-file C program- Part 1.md b/published/202002/20190729 How to structure a multi-file C program- Part 1.md new file mode 100644 index 0000000000..196892cb41 --- /dev/null +++ b/published/202002/20190729 How to structure a multi-file C program- Part 1.md @@ -0,0 +1,189 @@ +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11935-1.html) +[#]: subject: (How to structure a multi-file C program: Part 1) +[#]: via: (https://opensource.com/article/19/7/structure-multi-file-c-part-1) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjnyhttps://opensource.com/users/jnyjnyhttps://opensource.com/users/jim-salterhttps://opensource.com/users/cldxsolutions) + +如何组织构建多文件 C 语言程序(一) +====== + +> 准备好你喜欢的饮料、编辑器和编译器,放一些音乐,然后开始构建一个由多个文件组成的 C 语言程序。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/214517o5p7q45l2a8jkx4k.jpg) + +大家常说计算机编程的艺术部分是处理复杂性,部分是命名某些事物。此外,我认为“有时需要添加绘图”是在很大程度上是正确的。 + +在这篇文章里,我会编写一个小型 C 程序,命名一些东西,同时处理一些复杂性。该程序的结构大致基于我在 《[如何写一个好的 C 语言 main 函数][2]》 文中讨论的。但是,这次做一些不同的事。准备好你喜欢的饮料、编辑器和编译器,放一些音乐,让我们一起编写一个有趣的 C 语言程序。 + +### 优秀 Unix 程序哲学 + +首先,你要知道这个 C 程序是一个 [Unix][3] 命令行工具。这意味着它运行在(或者可被移植到)那些提供 Unix C 运行环境的操作系统中。当贝尔实验室发明 Unix 后,它从一开始便充满了[设计哲学][4]。用我自己的话来说就是:程序只做一件事,并做好它,并且对文件进行一些操作。虽然“只做一件事,并做好它”是有意义的,但是“对文件进行一些操作”的部分似乎有点儿不合适。 + +事实证明,Unix 中抽象的 “文件” 非常强大。一个 Unix 文件是以文件结束符(EOF)标志为结尾的字节流。仅此而已。文件中任何其它结构均由应用程序所施加而非操作系统。操作系统提供了系统调用,使得程序能够对文件执行一套标准的操作:打开、读取、写入、寻址和关闭(还有其他,但说起来那就复杂了)。对于文件的标准化访问使得不同的程序共用相同的抽象,而且可以一同工作,即使它们是不同的人用不同语言编写的程序。 + +具有共享的文件接口使得构建*可组合的*的程序成为可能。一个程序的输出可以作为另一个程序的输入。Unix 家族的操作系统默认在执行程序时提供了三个文件:标准输入(`stdin`)、标准输出(`stdout`)和标准错误(`stderr`)。其中两个文件是只写的:`stdout` 和 `stderr`。而 `stdin` 是只读的。当我们在常见的 Shell 比如 Bash 中使用文件重定向时,可以看到其效果。 + +``` +$ ls | grep foo | sed -e 's/bar/baz/g' > ack +``` + +这条指令可以被简要地描述为:`ls` 的结果被写入标准输出,它重定向到 `grep` 的标准输入,`grep` 的标准输出重定向到 `sed` 的标准输入,`sed` 的标准输出重定向到当前目录下文件名为 `ack` 的文件中。 + +我们希望我们的程序在这个灵活又出色的生态系统中运作良好,因此让我们编写一个可以读写文件的程序。 + +### 喵呜喵呜:流编码器/解码器概念 + +当我还是一个露着豁牙的孩子懵懵懂懂地学习计算机科学时,学过很多编码方案。它们中的有些用于压缩文件,有些用于打包文件,另一些毫无用处因此显得十分愚蠢。列举最后这种情况的一个例子:[哞哞编码方案][5]。 + +为了让我们的程序有个用途,我为它更新了一个 [21 世纪][6] 的概念,并且实现了一个名为“喵呜喵呜” 的编码方案的概念(毕竟网上大家都喜欢猫)。这里的基本的思路是获取文件并且使用文本 “meow” 对每个半字节(半个字节)进行编码。小写字母代表 0,大写字母代表 1。因为它会将 4 个比特替换为 32 个比特,因此会扩大文件的大小。没错,这毫无意义。但是想象一下人们看到经过这样编码后的惊讶表情。 + +``` +$ cat /home/your_sibling/.super_secret_journal_of_my_innermost_thoughts +MeOWmeOWmeowMEoW... +``` + +这非常棒。 + +### 最终的实现 + +完整的源代码可以在 [GitHub][7] 上面找到,但是我会写下我在编写程序时的思考。目的是说明如何组织构建多文件 C 语言程序。 + +既然已经确定了要编写一个编码和解码“喵呜喵呜”格式的文件的程序时,我在 Shell 中执行了以下的命令 : + +``` +$ mkdir meowmeow +$ cd meowmeow +$ git init +$ touch Makefile     # 编译程序的方法 +$ touch main.c       # 处理命令行选项 +$ touch main.h       # “全局”常量和定义 +$ touch mmencode.c   # 实现对喵呜喵呜文件的编码 +$ touch mmencode.h   # 描述编码 API +$ touch mmdecode.c   # 实现对喵呜喵呜文件的解码 +$ touch mmdecode.h   # 描述解码 API +$ touch table.h      # 定义编码查找表 +$ touch .gitignore   # 这个文件中的文件名会被 git 忽略 +$ git add . +$ git commit -m "initial commit of empty files" +``` + +简单的说,我创建了一个目录,里面全是空文件,并且提交到 git。 + +即使这些文件中没有内容,你依旧可以从它的文件名推断每个文件的用途。为了避免万一你无法理解,我在每条 `touch` 命令后面进行了简单描述。 + +通常,程序从一个简单 `main.c` 文件开始,只有两三个解决问题的函数。然后程序员轻率地向自己的朋友或者老板展示了该程序,然后为了支持所有新的“功能”和“需求”,文件中的函数数量就迅速爆开了。“程序俱乐部”的第一条规则便是不要谈论“程序俱乐部”,第二条规则是尽量减少单个文件中的函数。 + +老实说,C 编译器并不关心程序中的所有函数是否都在一个文件中。但是我们并不是为计算机或编译器写程序,我们是为其他人(有时也包括我们)去写程序的。我知道这可能有些奇怪,但这就是事实。程序体现了计算机解决问题所采用的一组算法,当问题的参数发生了意料之外的变化时,保证人们可以理解它们是非常重要的。当在人们修改程序时,发现一个文件中有 2049 函数时他们会诅咒你的。 + +因此,优秀的程序员会将函数分隔开,将相似的函数分组到不同的文件中。这里我用了三个文件 `main.c`、`mmencode.c` 和 `mmdecode.c`。对于这样小的程序,也许看起来有些过头了。但是小的程序很难保证一直小下去,因此哥忒拓展做好计划是一个“好主意”。 + +但是那些 `.h` 文件呢?我会在后面解释一般的术语,简单地说,它们被称为头文件,同时它们可以包含 C 语言类型定义和 C 预处理指令。头文件中不应该包含任何函数。你可以认为头文件是提供了应用程序接口(API)的定义的一种 `.c` 文件,可以供其它 `.c` 文件使用。 + +### 但是 Makefile 是什么呢? + +我知道下一个轰动一时的应用都是你们这些好孩子们用 “终极代码粉碎者 3000” 集成开发环境来编写的,而构建项目是用 Ctrl-Meta-Shift-Alt-Super-B 等一系列复杂的按键混搭出来的。但是如今(也就是今天),使用 `Makefile` 文件可以在构建 C 程序时帮助做很多有用的工作。`Makefile` 是一个包含如何处理文件的方式的文本文件,程序员可以使用其自动地从源代码构建二进制程序(以及其它东西!) + +以下面这个小东西为例: + +``` +00 # Makefile +01 TARGET= my_sweet_program +02 $(TARGET): main.c +03    cc -o my_sweet_program main.c +``` + +`#` 符号后面的文本是注释,例如 00 行。 + +01 行是一个变量赋值,将 `TARGET` 变量赋值为字符串 `my_sweet_program`。按照惯例,也是我的习惯,所有 `Makefile` 变量均使用大写字母并用下划线分隔单词。 + +02 行包含该步骤recipe要创建的文件名和其依赖的文件。在本例中,构建目标target是 `my_sweet_program`,其依赖是 `main.c`。 + +最后的 03 行使用了一个制表符号(`tab`)而不是四个空格。这是将要执行创建目标的命令。在本例中,我们使用 C 编译器C compiler前端 `cc` 以编译链接为 `my_sweet_program`。 + +使用 `Makefile` 是非常简单的。 + +``` +$ make +cc -o my_sweet_program main.c +$ ls +Makefile  main.c  my_sweet_program +``` + +构建我们喵呜喵呜编码器/解码器的 [Makefile][8] 比上面的例子要复杂,但其基本结构是相同的。我将在另一篇文章中将其分解为 Barney 风格。 + +### 形式伴随着功能 + +我的想法是程序从一个文件中读取、转换它,并将转换后的结果存储到另一个文件中。以下是我想象使用程序命令行交互时的情况: + +``` +$ meow < clear.txt > clear.meow +$ unmeow < clear.meow > meow.tx +$ diff clear.txt meow.tx +$ +``` + +我们需要编写代码以进行命令行解析和处理输入/输出流。我们需要一个函数对流进行编码并将结果写到另一个流中。最后,我们需要一个函数对流进行解码并将结果写到另一个流中。等一下,我们在讨论如何写一个程序,但是在上面的例子中,我调用了两个指令:`meow` 和 `unmeow`?我知道你可能会认为这会导致越变越复杂。 + +### 次要内容:argv[0] 和 ln 指令 + +回想一下,C 语言 main 函数的结构如下: + +``` +int main(int argc, char *argv[]) +``` + +其中 `argc` 是命令行参数的数量,`argv` 是字符指针(字符串)的列表。`argv[0]` 是包含正在执行的程序的文件路径。在 Unix 系统中许多互补功能的程序(比如:压缩和解压缩)看起来像两个命令,但事实上,它们是在文件系统中拥有两个名称的一个程序。这个技巧是通过使用 `ln` 命令创建文件系统链接来实现两个名称的。 + +在我笔记本电脑中 `/usr/bin` 的一个例子如下: + +``` +$ ls -li /usr/bin/git* +3376 -rwxr-xr-x. 113 root root     1.5M Aug 30  2018 /usr/bin/git +3376 -rwxr-xr-x. 113 root root     1.5M Aug 30  2018 /usr/bin/git-receive-pack +... +``` + +这里 `git` 和 `git-receive-pack` 是同一个文件但是拥有不同的名字。我们说它们是相同的文件因为它们具有相同的 inode 值(第一列)。inode 是 Unix 文件系统的一个特点,对它的介绍超越了本文的内容范畴。 + +优秀或懒惰的程序可以通过 Unix 文件系统的这个特点达到写更少的代码但是交付双倍的程序。首先,我们编写一个基于其 `argv[0]` 的值而作出相应改变的程序,然后我们确保为导致该行为的名称创建链接。 + +在我们的 `Makefile` 中,`unmeow` 链接通过以下的方式来创建: + +``` +# Makefile +... +$(DECODER): $(ENCODER) + $(LN) -f $< $@ + ... +``` + +我倾向于在 `Makefile` 中将所有内容参数化,很少使用 “裸” 字符串。我将所有的定义都放置在 `Makefile` 文件顶部,以便可以简单地找到并改变它们。当你尝试将程序移植到新的平台上时,需要将 `cc` 改变为某个 `cc` 时,这会很方便。 + +除了两个内置变量 `$@` 和 `$<` 之外,该步骤recipe看起来相对简单。第一个便是该步骤的目标的快捷方式,在本例中是 `$(DECODER)`(我能记得这个是因为 `@` 符号看起来像是一个目标)。第二个,`$<` 是规则依赖项,在本例中,它解析为 `$(ENCODER)`。 + +事情肯定会变得复杂,但它还在管理之中。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/structure-multi-file-c-part-1 + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjnyhttps://opensource.com/users/jnyjnyhttps://opensource.com/users/jim-salterhttps://opensource.com/users/cldxsolutions +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A (Programming keyboard.) +[2]: https://linux.cn/article-10949-1.html +[3]: https://en.wikipedia.org/wiki/Unix +[4]: http://harmful.cat-v.org/cat-v/ +[5]: http://www.jabberwocky.com/software/moomooencode.html +[6]: https://giphy.com/gifs/nyan-cat-sIIhZliB2McAo +[7]: https://github.com/JnyJny/meowmeow +[8]: https://github.com/JnyJny/meowmeow/blob/master/Makefile diff --git a/published/202002/20191022 How to Go About Linux Boot Time Optimisation.md b/published/202002/20191022 How to Go About Linux Boot Time Optimisation.md new file mode 100644 index 0000000000..b6db365389 --- /dev/null +++ b/published/202002/20191022 How to Go About Linux Boot Time Optimisation.md @@ -0,0 +1,208 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11881-1.html) +[#]: subject: (How to Go About Linux Boot Time Optimisation) +[#]: via: (https://opensourceforu.com/2019/10/how-to-go-about-linux-boot-time-optimisation/) +[#]: author: (B Thangaraju https://opensourceforu.com/author/b-thangaraju/) + +如何进行 Linux 启动时间优化 +====== + +![][2] + +> 快速启动嵌入式设备或电信设备,对于时间要求紧迫的应用程序是至关重要的,并且在改善用户体验方面也起着非常重要的作用。这个文章给予一些关于如何增强任意设备的启动时间的重要技巧。 + +快速启动或快速重启在各种情况下起着至关重要的作用。为了保持所有服务的高可用性和更好的性能,嵌入式设备的快速启动至关重要。设想有一台运行着没有启用快速启动的 Linux 操作系统的电信设备,所有依赖于这个特殊嵌入式设备的系统、服务和用户可能会受到影响。这些设备维持其服务的高可用性是非常重要的,为此,快速启动和重启起着至关重要的作用。 + +一台电信设备的一次小故障或关机,即使只是几秒钟,都可能会对无数互联网上的用户造成破坏。因此,对于很多对时间要求严格的设备和电信设备来说,在它们的设备中加入快速启动的功能以帮助它们快速恢复工作是非常重要的。让我们从图 1 中理解 Linux 启动过程。 + +![图 1:启动过程][3] + +### 监视工具和启动过程 + +在对机器做出更改之前,用户应注意许多因素。其中包括计算机的当前启动速度,以及占用资源并增加启动时间的服务、进程或应用程序。 + +#### 启动图 + +为监视启动速度和在启动期间启动的各种服务,用户可以使用下面的命令来安装: + +``` +sudo apt-get install pybootchartgui +``` + +你每次启动时,启动图会在日志中保存一个 png 文件,使用户能够查看该 png 文件来理解系统的启动过程和服务。为此,使用下面的命令: + +``` +cd /var/log/bootchart +``` + +用户可能需要一个应用程序来查看 png 文件。Feh 是一个面向控制台用户的 X11 图像查看器。不像大多数其它的图像查看器,它没有一个精致的图形用户界面,但它只用来显示图片。Feh 可以用于查看 png 文件。你可以使用下面的命令来安装它: + +``` +sudo apt-get install feh +``` + +你可以使用 `feh xxxx.png` 来查看 png 文件。 + + +![图 2:启动图][4] + +图 2 显示了一个正在查看的引导图 png 文件。 + +#### systemd-analyze + +但是,对于 Ubuntu 15.10 以后的版本不再需要引导图。为获取关于启动速度的简短信息,使用下面的命令: + +``` +systemd-analyze +``` + +![图 3:systemd-analyze 的输出][5] + +图表 3 显示命令 `systemd-analyze` 的输出。 + +命令 `systemd-analyze blame` 用于根据初始化所用的时间打印所有正在运行的单元的列表。这个信息是非常有用的,可用于优化启动时间。`systemd-analyze blame` 不会显示服务类型为简单(`Type=simple`)的服务,因为 systemd 认为这些服务应是立即启动的;因此,无法测量初始化的延迟。 + +![图 4:systemd-analyze blame 的输出][6] + +图 4 显示 `systemd-analyze blame` 的输出。 + +下面的命令打印时间关键的服务单元的树形链条: + +``` +command systemd-analyze critical-chain +``` + +图 5 显示命令 `systemd-analyze critical-chain` 的输出。 + +![图 5:systemd-analyze critical-chain 的输出][7] + +### 减少启动时间的步骤 + +下面显示的是一些可以减少启动时间的各种步骤。 + +#### BUM(启动管理器) + +BUM 是一个运行级配置编辑器,允许在系统启动或重启时配置初始化服务。它显示了可以在启动时启动的每个服务的列表。用户可以打开和关闭各个服务。BUM 有一个非常清晰的图形用户界面,并且非常容易使用。 + +在 Ubuntu 14.04 中,BUM 可以使用下面的命令安装: + +``` +sudo apt-get install bum +``` + +为在 15.10 以后的版本中安装它,从链接 http://apt.ubuntu.com/p/bum 下载软件包。 + +以基本的服务开始,禁用扫描仪和打印机相关的服务。如果你没有使用蓝牙和其它不想要的设备和服务,你也可以禁用它们中一些。我强烈建议你在禁用相关的服务前学习服务的基础知识,因为这可能会影响计算机或操作系统。图 6 显示 BUM 的图形用户界面。 + +![图 6:BUM][8] + +#### 编辑 rc 文件 + +要编辑 rc 文件,你需要转到 rc 目录。这可以使用下面的命令来做到: + +``` +cd /etc/init.d +``` + +然而,访问 `init.d` 需要 root 用户权限,该目录基本上包含的是开始/停止脚本,这些脚本用于在系统运行时或启动期间控制(开始、停止、重新加载、启动启动)守护进程。 + +在 `init.d` 目录中的 `rc` 文件被称为运行控制run control脚本。在启动期间,`init` 执行 `rc` 脚本并发挥它的作用。为改善启动速度,我们可以更改 `rc` 文件。使用任意的文件编辑器打开 `rc` 文件(当你在 `init.d` 目录中时)。 + +例如,通过输入 `vim rc` ,你可以更改 `CONCURRENCY=none` 为 `CONCURRENCY=shell`。后者允许某些启动脚本同时执行,而不是依序执行。 + +在最新版本的内核中,该值应该被更改为 `CONCURRENCY=makefile`。 + +图 7 和图 8 显示编辑 `rc` 文件前后的启动时间比较。可以注意到启动速度有所提高。在编辑 `rc` 文件前的启动时间是 50.98 秒,然而在对 `rc` 文件进行更改后的启动时间是 23.85 秒。 + +但是,上面提及的更改方法在 Ubuntu 15.10 以后的操作系统上不工作,因为使用最新内核的操作系统使用 systemd 文件,而不再是 `init.d` 文件。 + +![图 7:对 rc 文件进行更改之前的启动速度][9] + +![图 8:对 rc 文件进行更改之后的启动速度][10] + +#### E4rat + +E4rat 代表 e4 减少访问时间reduced access time(仅在 ext4 文件系统的情况下)。它是由 Andreas Rid 和 Gundolf Kiefer 开发的一个项目。E4rat 是一个通过碎片整理来帮助快速启动的应用程序。它还会加速应用程序的启动。E4rat 使用物理文件的重新分配来消除寻道时间和旋转延迟,因而达到较高的磁盘传输速度。 + +E4rat 可以 .deb 软件包形式获得,你可以从它的官方网站 http://e4rat.sourceforge.net/ 下载。 + +Ubuntu 默认安装的 ureadahead 软件包与 e4rat 冲突。因此必须使用下面的命令安装这几个软件包: + +``` +sudo dpkg purge ureadahead ubuntu-minimal +``` + +现在使用下面的命令来安装 e4rat 的依赖关系: + +``` +sudo apt-get install libblkid1 e2fslibs +``` + +打开下载的 .deb 文件,并安装它。现在需要恰当地收集启动数据来使 e4rat 工作。 + +遵循下面所给的步骤来使 e4rat 正确地运行并提高启动速度。 + +* 在启动期间访问 Grub 菜单。这可以在系统启动时通过按住 `shift` 按键来完成。 +* 选择通常用于启动的选项(内核版本),并按 `e`。 +* 查找以 `linux /boot/vmlinuz` 开头的行,并在该行的末尾添加下面的代码(在句子的最后一个字母后按空格键):`init=/sbin/e4rat-collect or try - quiet splash vt.handsoff =7 init=/sbin/e4rat-collect +`。 +* 现在,按 `Ctrl+x` 来继续启动。这可以让 e4rat 在启动后收集数据。在这台机器上工作,并在接下来的两分钟时间内打开并关闭应用程序。 +* 通过转到 e4rat 文件夹,并使用下面的命令来访问日志文件:`cd /var/log/e4rat`。 +* 如果你没有找到任何日志文件,重复上面的过程。一旦日志文件就绪,再次访问 Grub 菜单,并对你的选项按 `e`。 +* 在你之前已经编辑过的同一行的末尾输入 `single`。这可以让你访问命令行。如果出现其它菜单,选择恢复正常启动(Resume normal boot)。如果你不知为何不能进入命令提示符,按 `Ctrl+Alt+F1` 组合键。 +* 在你看到登录提示后,输入你的登录信息。 +* 现在输入下面的命令:`sudo e4rat-realloc /var/lib/e4rat/startup.log`。此过程需要一段时间,具体取决于机器的磁盘速度。 +* 现在使用下面的命令来重启你的机器:`sudo shutdown -r now`。 +* 现在,我们需要配置 Grub 来在每次启动时运行 e4rat。 +* 使用任意的编辑器访问 grub 文件。例如,`gksu gedit /etc/default/grub`。 +* 查找以 `GRUB CMDLINE LINUX DEFAULT=` 开头的一行,并在引号之间和任何选项之前添加下面的行:`init=/sbin/e4rat-preload 18`。 +* 它应该看起来像这样:`GRUB CMDLINE LINUX DEFAULT = init=/sbin/e4rat- preload quiet splash`。 +* 保存并关闭 Grub 菜单,并使用 `sudo update-grub` 更新 Grub 。 +* 重启系统,你将发现启动速度有明显变化。 + +图 9 和图 10 显示在安装 e4rat 前后的启动时间之间的差异。可注意到启动速度的提高。在使用 e4rat 前启动所用时间是 22.32 秒,然而在使用 e4rat 后启动所用时间是 9.065 秒。 + +![图 9:使用 e4rat 之前的启动速度][11] + +![图 10:使用 e4rat 之后的启动速度][12] + +### 一些易做的调整 + +使用很小的调整也可以达到良好的启动速度,下面列出其中两个。 + +#### SSD + +使用固态设备而不是普通的硬盘或者其它的存储设备将肯定会改善启动速度。SSD 也有助于加快文件传输和运行应用程序方面的速度。 + +#### 禁用图形用户界面 + +图形用户界面、桌面图形和窗口动画占用大量的资源。禁用图形用户界面是获得良好的启动速度的另一个好方法。 + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/10/how-to-go-about-linux-boot-time-optimisation/ + +作者:[B Thangaraju][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://opensourceforu.com/author/b-thangaraju/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/Screenshot-from-2019-10-07-13-16-32.png?&ssl=1 (Screenshot from 2019-10-07 13-16-32) +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/Screenshot-from-2019-10-07-13-16-32.png?fit=700%2C499&ssl=1 +[3]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-1.png?ssl=1 +[4]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-2.png?ssl=1 +[5]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-3.png?ssl=1 +[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-4.png?ssl=1 +[7]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-5.png?ssl=1 +[8]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-6.png?ssl=1 +[9]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-7.png?ssl=1 +[10]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-8.png?ssl=1 +[11]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-9.png?ssl=1 +[12]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/10/fig-10.png?ssl=1 diff --git a/sources/tech/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md b/published/202002/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md similarity index 54% rename from sources/tech/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md rename to published/202002/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md index 7b71e21ff3..31c93609ab 100644 --- a/sources/tech/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md +++ b/published/202002/20191204 --acid -words- Handle Chromium - Firefox sessions with org-mode.md @@ -1,22 +1,24 @@ [#]: collector: (lujun9972) [#]: translator: (lujun9972) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (#:acid 'words: Handle Chromium & Firefox sessions with org-mode) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11926-1.html) +[#]: subject: (Handle Chromium & Firefox sessions with org-mode) [#]: via: (https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions-with-org-mode.html) [#]: author: (Sanel Z https://acidwords.com/) -Handle Chromium & Firefox sessions with org-mode +通过 Org 模式管理 Chromium 和 Firefox 会话 ====== -I was big fan of [Session Manager][1], small addon for Chrome and Chromium that will save all open tabs, assign the name to session and, when is needed, restore it. +![](https://img.linux.net.cn/data/attachment/album/202002/24/113047w8jtoh2o5j085750.jpg) -Very useful, especially if you are like me, switching between multiple "mind sessions" during the day - research, development or maybe news reading. Or simply, you'd like to remember workflow (and tabs) you had few days ago. +我是[会话管理器][1]的铁粉,它是 Chrome 和 Chromium 的小插件,可以保存所有打开的选项卡,为会话命名,并在需要时恢复会话。 -After I decided to ditch all extensions from Chromium except [uBlock Origin][2], it was time to look for alternative. My main goal was it to be browser agnostic and session links had to be stored in text file, so I can enjoy all the goodies of plain text file. What would be better for that than good old [org-mode][3] ;) +它非常有用,特别是如果你像我一样,白天的时候需要在多个“思维活动”之间切换——研究、开发或者阅读新闻。或者你只是单纯地希望记住几天前的工作流(和选项卡)。 -Long time ago I found this trick: [Get the currently open tabs in Google Chrome via the command line][4] and with some elisp sugar and coffee, here is the code: +在我决定放弃 chromium 上除了 [uBlock Origin][2] 之外的所有扩展后,就必须寻找一些替代品了。我的主要目标是使之与浏览器无关,同时会话链接必须保存在文本文件中,这样我就可以享受所有纯文本的好处了。还有什么比 [org 模式][3]更好呢 ;) + +很久以前我就发现了这个小诀窍:[通过命令行获取当前在谷歌 Chrome 中打开的标签][4] 再加上些 elisp 代码: ``` (require 'cl-lib) @@ -57,9 +59,9 @@ Make sure to put cursor on date heading that contains list of urls." (forward-line 1))))) ``` -So, how does it work? +那么,它的工作原理是什么呢? -Evaluate above code, open new org-mode file and call `M-x save-chromium-session`. It will create something like this: +运行上述代码,打开一个新 org 模式文件并调用 `M-x save-chromium-session`。它会创建类似这样的东西: ``` * [2019-12-04 12:14:02] @@ -68,9 +70,9 @@ Evaluate above code, open new org-mode file and call `M-x save-chromium-session` - https://news.ycombinator.com ``` -or whatever urls are running in Chromium instance. To restore it back, put cursor on desired date and run `M-x restore-chromium-session`. All tabs should be back. +也就是任何在 chromium 实例中运行着的 URL。要还原的话,则将光标置于所需日期上然后运行 `M-x restore-chromium-session`。所有标签都应该恢复了。 -Here is how I use it, with randomly generated data for the purpose of this text: +以下是我的使用案例,其中的数据是随机生成的: ``` #+TITLE: Browser sessions @@ -88,27 +90,27 @@ Here is how I use it, with randomly generated data for the purpose of this text: - https://news.ycombinator.com ``` -Note that hack for reading Chromium session isn't perfect: `strings` will read whatever looks like string and url from binary database and sometimes that will yield small artifacts in urls. But, you can easily edit those and keep session file lean and clean. +请注意,用于读取 Chromium 会话的方法并不完美:`strings` 将从二进制数据库中读取任何类似 URL 字符串的内容,有时这将产生不完整的 URL。不过,你可以很方便地地编辑它们,从而保持会话文件简洁。 -To actually open tabs, elisp code will use [browse-url][5] and it can be further customized to run Chromium, Firefox or any other browser with `browse-url-browser-function` variable. Make sure to read documentation for this variable. +为了真正打开标签,elisp 代码中使用到了 [browse-url][5],它可以通过 `browse-url-browser-function` 变量进一步定制成运行 Chromium、Firefox 或任何其他浏览器。请务必阅读该变量的相关文档。 -Don't forget to put session file in git, mercurial or svn and enjoy the fact that you will never loose your session history again :) +别忘了把会话文件放在 git、mercurial 或 svn 中,这样你就再也不会丢失会话历史记录了 :) -### What about Firefox? +### 那么 Firefox 呢? -If you are using Firefox (recent versions) and would like to pull session urls, here is how to do it. +如果你正在使用 Firefox(最近的版本),并且想要获取会话 URL,下面是操作方法。 -First, download and compile [lz4json][6], small tool that will decompress Mozilla lz4json format, where Firefox stores session data. Session data (at the time of writing this post) is stored in `$HOME/.mozilla/firefox//sessionstore-backups/recovery.jsonlz4`. +首先,下载并编译 [lz4json][6],这是一个可以解压缩 Mozilla lz4json 格式的小工具,Firefox 以这种格式来存储会话数据。会话数据(在撰写本文时)存储在 `$HOME/.mozilla/firefox//sessionstore-backup /recovery.jsonlz4` 中。 -If Firefox is not running, `recovery.jsonlz4` will not be present, but use `previous.jsonlz4` instead. +如果 Firefox 没有运行,则没有 `recovery.jsonlz4`,这种情况下用 `previous.jsonlz4` 代替。 -To extract urls, try this in terminal: +要提取网址,尝试在终端运行: ``` $ lz4jsoncat recovery.jsonlz4 | grep -oP '"(http.+?)"' | sed 's/"//g' | sort | uniq ``` -and update `save-chromium-session` with: +然后更新 `save-chromium-session` 为: ``` (defun save-chromium-session () @@ -122,7 +124,7 @@ and update `save-chromium-session` with: ;; rest of the code is unchanged ``` -Updating documentation strings, function name and any further refactoring is left for exercise. +更新本函数的文档字符串、函数名以及进一步的重构都留作练习。 -------------------------------------------------------------------------------- @@ -131,7 +133,7 @@ via: https://acidwords.com/posts/2019-12-04-handle-chromium-and-firefox-sessions 作者:[Sanel Z][a] 选题:[lujun9972][b] 译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20191225 8 Commands to Check Memory Usage on Linux.md b/published/202002/20191225 8 Commands to Check Memory Usage on Linux.md similarity index 57% rename from sources/tech/20191225 8 Commands to Check Memory Usage on Linux.md rename to published/202002/20191225 8 Commands to Check Memory Usage on Linux.md index 89108b5ded..70e07c8181 100644 --- a/sources/tech/20191225 8 Commands to Check Memory Usage on Linux.md +++ b/published/202002/20191225 8 Commands to Check Memory Usage on Linux.md @@ -1,49 +1,45 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11870-1.html) [#]: subject: (8 Commands to Check Memory Usage on Linux) [#]: via: (https://www.2daygeek.com/linux-commands-check-memory-usage/) [#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) -8 Commands to Check Memory Usage on Linux +检查 Linux 中内存使用情况的 8 条命令 ====== -Linux is not like Windows and you will not get a GUI always, especially in a server environment. +![](https://img.linux.net.cn/data/attachment/album/202002/09/121112mg0jigxtcc5xr8or.jpg) -As a Linux administrator, it is important to know how to check your available and used resources, such as memory, CPU, disk space, etc. +Linux 并不像 Windows,你经常不会有图形界面可供使用,特别是在服务器环境中。 -If there are any applications that use too much resources on the system to run your system at the optimum level you need to find and fix. +作为一名 Linux 管理员,知道如何获取当前可用的和已经使用的资源情况,比如内存、CPU、磁盘等,是相当重要的。如果某一应用在你的系统上占用了太多的资源,导致你的系统无法达到最优状态,那么你需要找到并修正它。 -If you want to **[find out the top 10 memory (RAM) consumption processes in Linux][1]**, go to the following article. +如果你想找到消耗内存前十名的进程,你需要去阅读这篇文章:[如何在 Linux 中找出内存消耗最大的进程][1]。 -In Linux, there are commands for everything, so use the corresponding commands. +在 Linux 中,命令能做任何事,所以使用相关命令吧。在这篇教程中,我们将会给你展示 8 个有用的命令来即查看在 Linux 系统中内存的使用情况,包括 RAM 和交换分区。 -In this tutorial, we will show you eight powerful commands to check memory usage on a Linux system, including RAM and swap. +创建交换分区在 Linux 系统中是非常重要的,如果你想了解如何创建,可以去阅读这篇文章:[在 Linux 系统上创建交换分区][2]。 -**[Creating swap space on a Linux system][2]** is very important. +下面的命令可以帮助你以不同的方式查看 Linux 内存使用情况。 -The following commands can help you check memory usage in Linux in different ways. + * `free` 命令 + * `/proc/meminfo` 文件 + * `vmstat` 命令 + * `ps_mem` 命令 + * `smem` 命令 + * `top` 命令 + * `htop` 命令 + * `glances` 命令 - * free Command - * /proc/meminfo File - * vmstat Command - * ps_mem Command - * smem Command - * top Command - * htop Command - * glances Command +### 1)如何使用 free 命令查看 Linux 内存使用情况 +[free 命令][3] 是被 Linux 管理员广泛使用的主要命令。但是它提供的信息比 `/proc/meminfo` 文件少。 +`free` 命令会分别展示物理内存和交换分区内存中已使用的和未使用的数量,以及内核使用的缓冲区和缓存。 -### 1) How to Check Memory Usage on Linux Using the free Command - -**[Free command][3]** is the most powerful command widely used by the Linux administrator. But it provides very little information compared to the “/proc/meminfo” file. - -Free command displays the total amount of free and used physical and swap memory on the system, as well as buffers and caches used by the kernel. - -These information is gathered from the “/proc/meminfo” file. +这些信息都是从 `/proc/meminfo` 文件中获取的。 ``` # free -m @@ -52,24 +48,18 @@ Mem: 15867 9199 1702 3315 4965 3039 Swap: 17454 666 16788 ``` - * **total:** Total installed memory - * **used:** Memory is currently in use by running processes (used= total – free – buff/cache) - * **free:** Unused memory (free= total – used – buff/cache) - * **shared:** Memory shared between two or more processes (multiple processes) - * **buffers:** Memory reserved by the kernel to hold a process queue request. - * **cache:** Size of the page cache that holds recently used files in RAM - * **buff/cache:** Buffers + Cache - * **available:** Estimation of how much memory is available for starting new applications, without swapping. + * `total`:总的内存量 + * `used`:被当前运行中的进程使用的内存量(`used` = `total` – `free` – `buff/cache`) + * `free`: 未被使用的内存量(`free` = `total` – `used` – `buff/cache`) + * `shared`: 在两个或多个进程之间共享的内存量 + * `buffers`: 内存中保留用于内核记录进程队列请求的内存量 + * `cache`: 在 RAM 中存储最近使用过的文件的页缓冲大小 + * `buff/cache`: 缓冲区和缓存总的使用内存量 + * `available`: 可用于启动新应用的可用内存量(不含交换分区) +### 2) 如何使用 /proc/meminfo 文件查看 Linux 内存使用情况 - -### 2) How to Check Memory Usage on Linux Using the /proc/meminfo File - -The “/proc/meminfo” file is a virtual file that contains various real-time information about memory usage. - -It shows memory stats in kilobytes, most of which are somewhat difficult to understand. - -However it contains useful information about memory usage. +`/proc/meminfo` 文件是一个包含了多种内存使用的实时信息的虚拟文件。它展示内存状态单位使用的是 kB,其中大部分属性都难以理解。然而它也包含了内存使用情况的有用信息。 ``` # cat /proc/meminfo @@ -124,13 +114,11 @@ DirectMap2M: 14493696 kB DirectMap1G: 2097152 kB ``` -### 3) How to Check Memory Usage on Linux Using the vmstat Command +### 3) 如何使用 vmstat 命令查看 Linux 内存使用情况 -The **[vmstat command][4]** is another useful tool for reporting virtual memory statistics. +[vmstat 命令][4] 是另一个报告虚拟内存统计信息的有用工具。 -vmstat reports information about processes, memory, paging, block IO, traps, disks, and cpu functionality. - -vmstat does not require special permissions, and it can help identify system bottlenecks. +`vmstat` 报告的信息包括:进程、内存、页面映射、块 I/O、陷阱、磁盘和 CPU 特性信息。`vmstat` 不需要特殊的权限,并且它可以帮助诊断系统瓶颈。 ``` # vmstat @@ -140,58 +128,35 @@ procs -----------memory---------- ---swap-- -----io---- -system-- ------cpu----- 1 0 682060 1769324 234188 4853500 0 3 25 91 31 16 34 13 52 0 0 ``` -If you want to understand this in detail, read the field description below. +如果你想详细了解每一项的含义,阅读下面的描述。 -**Procs** +* `procs`:进程 + * `r`: 可以运行的进程数目(正在运行或等待运行) + * `b`: 处于不可中断睡眠中的进程数目 +* `memory`:内存 + * `swpd`: 使用的虚拟内存数量 + * `free`: 空闲的内存数量 + * `buff`: 用作缓冲区内存的数量 + * `cache`: 用作缓存内存的数量 + * `inact`: 不活动的内存数量(使用 `-a` 选项) + * `active`: 活动的内存数量(使用 `-a` 选项) +* `Swap`:交换分区 + * `si`: 每秒从磁盘交换的内存数量 + * `so`: 每秒交换到磁盘的内存数量 +* `IO`:输入输出 + * `bi`: 从一个块设备中收到的块(块/秒) + * `bo`: 发送到一个块设备的块(块/秒) +* `System`:系统 + * `in`: 每秒的中断次数,包括时钟。 + * `cs`: 每秒的上下文切换次数。 +* `CPU`:下面这些是在总的 CPU 时间占的百分比 + * `us`: 花费在非内核代码上的时间占比(包括用户时间,调度时间) + * `sy`: 花费在内核代码上的时间占比 (系统时间) + * `id`: 花费在闲置的时间占比。在 Linux 2.5.41 之前,包括 I/O 等待时间 + * `wa`: 花费在 I/O 等待上的时间占比。在 Linux 2.5.41 之前,包括在空闲时间中 + * `st`: 被虚拟机偷走的时间占比。在 Linux 2.6.11 之前,这部分称为 unknown - * **r:** The number of runnable processes (running or waiting for run time). - * **b:** The number of processes in uninterruptible sleep. - - - -**Memory** - - * **swpd:** the amount of virtual memory used. - * **free:** the amount of idle memory. - * **buff:** the amount of memory used as buffers. - * **cache:** the amount of memory used as cache. - * **inact:** the amount of inactive memory. (-a option) - * **active:** the amount of active memory. (-a option) - - - -**Swap** - - * **si:** Amount of memory swapped in from disk (/s). - * **so:** Amount of memory swapped to disk (/s). - - - -**IO** - - * **bi:** Blocks received from a block device (blocks/s). - * **bo:** Blocks sent to a block device (blocks/s). - - - -**System** - - * **in:** The number of interrupts per second, including the clock. - * **cs:** The number of context switches per second. - - - -**CPU : These are percentages of total CPU time.** - - * **us:** Time spent running non-kernel code. (user time, including nice time) - * **sy:** Time spent running kernel code. (system time) - * **id:** Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time. - * **wa:** Time spent waiting for IO. Prior to Linux 2.5.41, included in idle. - * **st:** Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown. - - - -Run the following command for detailed information. +运行下面的命令查看详细的信息。 ``` # vmstat -s @@ -223,16 +188,13 @@ Run the following command for detailed information. 1577163147 boot time 3318 forks ``` +### 4) 如何使用 ps_mem 命令查看 Linux 内存使用情况 -### 4) How to Check Memory Usage on Linux Using the ps_mem Command +[ps_mem][5] 是一个用来查看当前内存使用情况的简单的 Python 脚本。该工具可以确定每个程序使用了多少内存(不是每个进程)。 -**[ps_mem][5]** is a simple Python script that allows you to get core memory usage accurately for a program in Linux. +该工具采用如下的方法计算每个程序使用内存:总的使用 = 程序进程私有的内存 + 程序进程共享的内存。 -This can determine how much RAM is used per program (not per process). - -It calculates the total amount of memory used per program, total = sum (private RAM for program processes) + sum (shared RAM for program processes). - -The shared RAM is problematic to calculate, and the tool automatically selects the most accurate method available for the running kernel. +计算共享内存是存在不足之处的,该工具可以为运行中的内核自动选择最准确的方法。 ``` # ps_mem @@ -285,15 +247,13 @@ The shared RAM is problematic to calculate, and the tool automatically selects t ================================== ``` -### 5) How to Check Memory Usage on Linux Using the smem Command +### 5)如何使用 smem 命令查看 Linux 内存使用情况 -**[smem][6]** is a tool that can provide numerous reports of memory usage on Linux systems. Unlike existing tools, smem can report Proportional Set Size (PSS), Unique Set Size (USS) and Resident Set Size (RSS). +[smem][6] 是一个可以为 Linux 系统提供多种内存使用情况报告的工具。不同于现有的工具,`smem` 可以报告比例集大小Proportional Set Size(PSS)、唯一集大小Unique Set Size(USS)和驻留集大小Resident Set Size(RSS)。 -Proportional Set Size (PSS): refers to the amount of memory used by libraries and applications in the virtual memory system. - -Unique Set Size (USS) : Unshared memory is reported as USS (Unique Set Size). - -Resident Set Size (RSS) : The standard measure of physical memory (it typically shared among multiple applications) usage known as resident set size (RSS) will significantly overestimate memory usage. +- 比例集大小(PSS):库和应用在虚拟内存系统中的使用量。 +- 唯一集大小(USS):其报告的是非共享内存。 +- 驻留集大小(RSS):物理内存(通常多进程共享)使用情况,其通常高于内存使用量。 ``` # smem -tk @@ -336,13 +296,11 @@ Resident Set Size (RSS) : The standard measure of physical memory (it typically 90 1 0 4.8G 5.2G 8.0G ``` -### 6) How to Check Memory Usage on Linux Using the top Command +### 6) 如何使用 top 命令查看 Linux 内存使用情况 -**[top command][7]** is one of the most frequently used commands by Linux administrators to understand and view the resource usage for a process on a Linux system. +[top 命令][7] 是一个 Linux 系统的管理员最常使用的用于查看进程的资源使用情况的命令。 -It displays the total memory of the system, current memory usage, free memory and total memory used by the buffers. - -In addition, it displays total swap memory, current swap usage, free swap memory, and total cached memory by the system. +该命令会展示了系统总的内存量、当前内存使用量、空闲内存量和缓冲区使用的内存总量。此外,该命令还会展示总的交换空间内存量、当前交换空间的内存使用量、空闲的交换空间内存量和缓存使用的内存总量。 ``` # top -b | head -10 @@ -368,27 +326,25 @@ KiB Swap: 17873388 total, 17873388 free, 0 used. 9179772 avail Mem 2174 daygeek 20 2466680 122196 78604 S 0.8 0.8 0:17.75 WebExtensi+ ``` -### 7) How to Check Memory Usage on Linux Using the htop Command +### 7) 如何使用 htop 命令查看 Linux 内存使用情况 -The **[htop command][8]** is an interactive process viewer for Linux/Unix systems. It is a text-mode application and requires the ncurses library, it was developed by Hisham. +[htop 命令][8] 是一个可交互的 Linux/Unix 系统进程查看器。它是一个文本模式应用,且使用它需要 Hisham 开发的 ncurses 库。 -It is designed as an alternative to the top command. +该名令的设计目的使用来代替 `top` 命令。该命令与 `top` 命令很相似,但是其允许你可以垂直地或者水平地的滚动以便可以查看系统中所有的进程情况。 -This is similar to the top command, but allows you to scroll vertically and horizontally to see all the processes running the system. +`htop` 命令拥有不同的颜色,这个额外的优点当你在追踪系统性能情况时十分有用。 -htop comes with Visual Colors, which have added benefits and are very evident when it comes to tracking system performance. +此外,你可以自由地执行与进程相关的任务,比如杀死进程或者改变进程的优先级而不需要其进程号(PID)。 -You are free to carry out any tasks related to processes, such as process killing and renicing without entering their PIDs. +![][10] -[![][9]][10] +### 8)如何使用 glances 命令查看 Linux 内存使用情况 -### 8) How to Check Memory Usage on Linux Using the glances Command +[Glances][11] 是一个 Python 编写的跨平台的系统监视工具。 -**[Glances][11]** is a cross-platform system monitoring tool written in Python. +你可以在一个地方查看所有信息,比如:CPU 使用情况、内存使用情况、正在运行的进程、网络接口、磁盘 I/O、RAID、传感器、文件系统信息、Docker、系统信息、运行时间等等。 -You can see all information in one place such as CPU usage, Memory usage, running process, Network interface, Disk I/O, Raid, Sensors, Filesystem info, Docker, System info, Uptime, etc,. - -![][9] +![][12] -------------------------------------------------------------------------------- @@ -396,21 +352,22 @@ via: https://www.2daygeek.com/linux-commands-check-memory-usage/ 作者:[Magesh Maruthamuthu][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://www.2daygeek.com/author/magesh/ [b]: https://github.com/lujun9972 -[1]: https://www.2daygeek.com/how-to-find-high-cpu-consumption-processes-in-linux/ -[2]: https://www.2daygeek.com/add-extend-increase-swap-space-memory-file-partition-linux/ -[3]: https://www.2daygeek.com/free-command-to-check-memory-usage-statistics-in-linux/ -[4]: https://www.2daygeek.com/linux-vmstat-command-examples-tool-report-virtual-memory-statistics/ -[5]: https://www.2daygeek.com/ps_mem-report-core-memory-usage-accurately-in-linux/ -[6]: https://www.2daygeek.com/smem-linux-memory-usage-statistics-reporting-tool/ +[1]: https://linux.cn/article-11542-1.html +[2]: https://linux.cn/article-9579-1.html +[3]: https://linux.cn/article-8314-1.html +[4]: https://linux.cn/article-8157-1.html +[5]: https://linux.cn/article-8639-1.html +[6]: https://linux.cn/article-7681-1.html [7]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ [8]: https://www.2daygeek.com/linux-htop-command-linux-system-performance-resource-monitoring-tool/ [9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 [10]: https://www.2daygeek.com/wp-content/uploads/2019/12/linux-commands-check-memory-usage-2.jpg [11]: https://www.2daygeek.com/linux-glances-advanced-real-time-linux-system-performance-monitoring-tool/ +[12]: https://www.2daygeek.com/wp-content/uploads/2019/12/linux-commands-check-memory-usage-3.jpg diff --git a/published/202002/20191227 Top CI-CD resources to set you up for success.md b/published/202002/20191227 Top CI-CD resources to set you up for success.md new file mode 100644 index 0000000000..a19cea5720 --- /dev/null +++ b/published/202002/20191227 Top CI-CD resources to set you up for success.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11875-1.html) +[#]: subject: (Top CI/CD resources to set you up for success) +[#]: via: (https://opensource.com/article/19/12/cicd-resources) +[#]: author: (Jessica Cherry https://opensource.com/users/jrepka) + +顶级 CI / CD 资源,助你成功 +====== + +> 随着企业期望实现无缝、灵活和可扩展的部署,持续集成和持续部署成为 2019 年的关键主题。 + +![Plumbing tubes in many directions][1] + +对于 CI/CD 和 DevOps 来说,2019 年是非常棒的一年。Opensource.com 的作者分享了他们专注于无缝、灵活和可扩展部署时是如何朝着敏捷和 scrum 方向发展的。以下是我们 2019 年发布的 CI/CD 文章中的一些重要文章。 + +### 学习和提高你的 CI/CD 技能 + +我们最喜欢的一些文章集中在 CI/CD 的实操经验上,并涵盖了许多方面。通常以 [Jenkins][2] 管道开始,Bryant Son 的文章《[用 Jenkins 构建 CI/CD 管道][3]》将为你提供足够的经验,以开始构建你的第一个管道。Daniel Oh 在《[用 DevOps 管道进行自动验收测试][4]》一文中,提供了有关验收测试的重要信息,包括可用于自行测试的各种 CI/CD 应用程序。我写的《[安全扫描 DevOps 管道][5]》非常简短,其中简要介绍了如何使用 Jenkins 平台在管道中设置安全性。 + +### 交付工作流程 + +正如 Jithin Emmanuel 在《[Screwdriver:一个用于持续交付的可扩展构建平台][6]》中分享的,在学习如何使用和提高你的 CI/CD 技能方面,工作流程很重要,特别是当涉及到管道时。Emily Burns 在《[为什么 Spinnaker 对 CI/CD 很重要][7]》中解释了灵活地使用 CI/CD 工作流程准确构建所需内容的原因。Willy-Peter Schaub 还盛赞了为所有产品创建统一管道的想法,以便《[在一个 CI/CD 管道中一致地构建每个产品][8]》。这些文章将让你很好地了解在团队成员加入工作流程后会发生什么情况。 + +### CI/CD 如何影响企业 + +2019 年也是认识到 CI/CD 的业务影响以及它是如何影响日常运营的一年。Agnieszka Gancarczyk 分享了 Red Hat 《[小型 Scrum vs. 大型 Scrum][9]》的调查结果, 包括受访者对 Scrum、敏捷运动及对团队的影响的不同看法。Will Kelly 的《[持续部署如何影响整个组织][10]》,也提及了开放式沟通的重要性。Daniel Oh 也在《[DevOps 团队必备的 3 种指标仪表板][11]》中强调了指标和可观测性的重要性。最后是 Ann Marie Fred 的精彩文章《[不在生产环境中测试?要在生产环境中测试!][12]》详细说明了在验收测试前在生产环境中测试的重要性。 + +感谢许多贡献者在 2019 年与 Opensource 的读者分享他们的见解,我期望在 2020 年里从他们那里了解更多有关 CI/CD 发展的信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/cicd-resources + +作者:[Jessica Cherry][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plumbing_pipes_tutorial_how_behind_scenes.png?itok=F2Z8OJV1 (Plumbing tubes in many directions) +[2]: https://jenkins.io/ +[3]: https://linux.cn/article-11546-1.html +[4]: https://opensource.com/article/19/4/devops-pipeline-acceptance-testing +[5]: https://opensource.com/article/19/7/security-scanning-your-devops-pipeline +[6]: https://opensource.com/article/19/3/screwdriver-cicd +[7]: https://opensource.com/article/19/8/why-spinnaker-matters-cicd +[8]: https://opensource.com/article/19/7/cicd-pipeline-rule-them-all +[9]: https://opensource.com/article/19/3/small-scale-scrum-vs-large-scale-scrum +[10]: https://opensource.com/article/19/7/organizational-impact-continuous-deployment +[11]: https://linux.cn/article-11183-1.html +[12]: https://opensource.com/article/19/5/dont-test-production diff --git a/published/202002/20200102 Data streaming and functional programming in Java.md b/published/202002/20200102 Data streaming and functional programming in Java.md new file mode 100644 index 0000000000..cf3b1bd11d --- /dev/null +++ b/published/202002/20200102 Data streaming and functional programming in Java.md @@ -0,0 +1,456 @@ +[#]: collector: (lujun9972) +[#]: translator: (laingke) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11857-1.html) +[#]: subject: (Data streaming and functional programming in Java) +[#]: via: (https://opensource.com/article/20/1/javastream) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) + +Java 中的数据流和函数式编程 +====== + +> 学习如何使用 Java 8 中的流 API 和函数式编程结构。 + +![](https://img.linux.net.cn/data/attachment/album/202002/06/002505flazlb4cg4aavvb4.jpg) + +当 Java SE 8(又名核心 Java 8)在 2014 年被推出时,它引入了一些更改,从根本上影响了用它进行的编程。这些更改中有两个紧密相连的部分:流 API 和函数式编程构造。本文使用代码示例,从基础到高级特性,介绍每个部分并说明它们之间的相互作用。 + +### 基础特性 + +流 API 是在数据序列中迭代元素的简洁而高级的方法。包 `java.util.stream` 和 `java.util.function` 包含了用于流 API 和相关函数式编程构造的新库。当然,代码示例胜过千言万语。 + +下面的代码段用大约 2,000 个随机整数值填充了一个 `List`: + +``` +Random rand = new Random2(); +List list = new ArrayList(); // 空 list +for (int i = 0; i < 2048; i++) list.add(rand.nextInt()); // 填充它 +``` + +另外用一个 `for` 循环可用于遍历填充列表,以将偶数值收集到另一个列表中。 + +流 API 提供了一种更简洁的方法来执行此操作: + +``` +List evens = list + .stream() // 流化 list + .filter(n -> (n & 0x1) == 0) // 过滤出奇数值 + .collect(Collectors.toList()); // 收集偶数值 +``` + +这个例子有三个来自流 API 的函数: + +- `stream` 函数可以将**集合**转换为流,而流是一个每次可访问一个值的传送带。流化是惰性的(因此也是高效的),因为值是根据需要产生的,而不是一次性产生的。 +- `filter` 函数确定哪些流的值(如果有的话)通过了处理管道中的下一个阶段,即 `collect` 阶段。`filter` 函数是 高阶的higher-order,因为它的参数是一个函数 —— 在这个例子中是一个 lambda 表达式,它是一个未命名的函数,并且是 Java 新的函数式编程结构的核心。 + +lambda 语法与传统的 Java 完全不同: + +``` +n -> (n & 0x1) == 0 +``` + +箭头(一个减号后面紧跟着一个大于号)将左边的参数列表与右边的函数体分隔开。参数 `n` 虽未明确类型,但也可以明确。在任何情况下,编译器都会发现 `n` 是个 `Integer`。如果有多个参数,这些参数将被括在括号中,并用逗号分隔。 + +在本例中,函数体检查一个整数的最低位(最右)是否为零,这用来表示偶数。过滤器应返回一个布尔值。尽管可以,但该函数的主体中没有显式的 `return`。如果主体没有显式的 `return`,则主体的最后一个表达式即是返回值。在这个例子中,主体按照 lambda 编程的思想编写,由一个简单的布尔表达式 `(n & 0x1) == 0` 组成。 + +- `collect` 函数将偶数值收集到引用为 `evens` 的列表中。如下例所示,`collect` 函数是线程安全的,因此,即使在多个线程之间共享了过滤操作,该函数也可以正常工作。 + +### 方便的功能和轻松实现多线程 + +在生产环境中,数据流的源可能是文件或网络连接。为了学习流 API, Java 提供了诸如 `IntStream` 这样的类型,它可以用各种类型的元素生成流。这里有一个 `IntStream` 的例子: + +``` +IntStream // 整型流 + .range(1, 2048) // 生成此范围内的整型流 + .parallel() // 为多个线程分区数据 + .filter(i -> ((i & 0x1) > 0)) // 奇偶校验 - 只允许奇数通过 + .forEach(System.out::println); // 打印每个值 +``` + +`IntStream` 类型包括一个 `range` 函数,该函数在指定的范围内生成一个整数值流,在本例中,以 1 为增量,从 1 递增到 2048。`parallel` 函数自动划分该工作到多个线程中,在各个线程中进行过滤和打印。(线程数通常与主机系统上的 CPU 数量匹配。)函数 `forEach` 参数是一个*方法引用*,在本例中是对封装在 `System.out` 中的 `println` 方法的引用,方法输出类型为 `PrintStream`。方法和构造器引用的语法将在稍后讨论。 + +由于具有多线程,因此整数值整体上以任意顺序打印,但在给定线程中是按顺序打印的。例如,如果线程 T1 打印 409 和 411,那么 T1 将按照顺序 409-411 打印,但是其它某个线程可能会预先打印 2045。`parallel` 调用后面的线程是并发执行的,因此它们的输出顺序是不确定的。 + +### map/reduce 模式 + +*map/reduce* 模式在处理大型数据集方面变得很流行。一个 map/reduce 宏操作由两个微操作构成。首先,将数据分散(映射mapped)到各个工作程序中,然后将单独的结果收集在一起 —— 也可能收集统计起来成为一个值,即归约reduction。归约可以采用不同的形式,如以下示例所示。 + +下面 `Number` 类的实例用 `EVEN` 或 `ODD` 表示有奇偶校验的整数值: + +``` +public class Number { + enum Parity { EVEN, ODD } + private int value; + public Number(int n) { setValue(n); } + public void setValue(int value) { this.value = value; } + public int getValue() { return this.value; } + public Parity getParity() { + return ((value & 0x1) == 0) ? Parity.EVEN : Parity.ODD; + } + public void dump() { + System.out.format("Value: %2d (parity: %s)\n", getValue(), + (getParity() == Parity.ODD ? "odd" : "even")); + } +} +``` + +下面的代码演示了用 `Number` 流进行 map/reduce 的情形,从而表明流 API 不仅可以处理 `int` 和 `float` 等基本类型,还可以处理程序员自定义的类类型。 + +在下面的代码段中,使用了 `parallelStream` 而不是 `stream` 函数对随机整数值列表进行流化处理。与前面介绍的 `parallel` 函数一样,`parallelStream` 变体也可以自动执行多线程。 + +``` +final int howMany = 200; +Random r = new Random(); +Number[] nums = new Number[howMany]; +for (int i = 0; i < howMany; i++) nums[i] = new Number(r.nextInt(100)); +List listOfNums = Arrays.asList(nums); // 将数组转化为 list + +Integer sum4All = listOfNums + .parallelStream() // 自动执行多线程 + .mapToInt(Number::getValue) // 使用方法引用,而不是 lambda + .sum(); // 将流值计算出和值 +System.out.println("The sum of the randomly generated values is: " + sum4All); +``` + +高阶的 `mapToInt` 函数可以接受一个 lambda 作为参数,但在本例中,它接受一个方法引用,即 `Number::getValue`。`getValue` 方法不需要参数,它返回给定的 `Number` 实例的 `int` 值。语法并不复杂:类名 `Number` 后跟一个双冒号和方法名。回想一下先前的例子 `System.out::println`,它在 `System` 类中的 `static` 属性 `out` 后面有一个双冒号。 + +方法引用 `Number::getValue` 可以用下面的 lambda 表达式替换。参数 `n` 是流中的 `Number` 实例中的之一: + +``` +mapToInt(n -> n.getValue()) +``` + +通常,lambda 表达式和方法引用是可互换的:如果像 `mapToInt` 这样的高阶函数可以采用一种形式作为参数,那么这个函数也可以采用另一种形式。这两个函数式编程结构具有相同的目的 —— 对作为参数传入的数据执行一些自定义操作。在两者之间进行选择通常是为了方便。例如,lambda 可以在没有封装类的情况下编写,而方法则不能。我的习惯是使用 lambda,除非已经有了适当的封装方法。 + +当前示例末尾的 `sum` 函数通过结合来自 `parallelStream` 线程的部分和,以线程安全的方式进行归约。但是,程序员有责任确保在 `parallelStream` 调用引发的多线程过程中,程序员自己的函数调用(在本例中为 `getValue`)是线程安全的。 + +最后一点值得强调。lambda 语法鼓励编写纯函数pure function,即函数的返回值仅取决于传入的参数(如果有);纯函数没有副作用,例如更新一个类中的 `static` 字段。因此,纯函数是线程安全的,并且如果传递给高阶函数的函数参数(例如 `filter` 和 `map` )是纯函数,则流 API 效果最佳。 + +对于更细粒度的控制,有另一个流 API 函数,名为 `reduce`,可用于对 `Number` 流中的值求和: + +``` +Integer sum4AllHarder = listOfNums + .parallelStream() // 多线程 + .map(Number::getValue) // 每个 Number 的值 + .reduce(0, (sofar, next) -> sofar + next); // 求和 +``` + +此版本的 `reduce` 函数带有两个参数,第二个参数是一个函数: + +- 第一个参数(在这种情况下为零)是*特征*值,该值用作求和操作的初始值,并且在求和过程中流结束时用作默认值。 +- 第二个参数是*累加器*,在本例中,这个 lambda 表达式有两个参数:第一个参数(`sofar`)是正在运行的和,第二个参数(`next`)是来自流的下一个值。运行的和以及下一个值相加,然后更新累加器。请记住,由于开始时调用了 `parallelStream`,因此 `map` 和 `reduce` 函数现在都在多线程上下文中执行。 + +在到目前为止的示例中,流值被收集,然后被规约,但是,通常情况下,流 API 中的 `Collectors` 可以累积值,而不需要将它们规约到单个值。正如下一个代码段所示,收集活动可以生成任意丰富的数据结构。该示例使用与前面示例相同的 `listOfNums`: + +``` +Map> numMap = listOfNums + .parallelStream() + .collect(Collectors.groupingBy(Number::getParity)); + +List evens = numMap.get(Number.Parity.EVEN); +List odds = numMap.get(Number.Parity.ODD); +``` + +第一行中的 `numMap` 指的是一个 `Map`,它的键是一个 `Number` 奇偶校验位(`ODD` 或 `EVEN`),其值是一个具有指定奇偶校验位值的 `Number` 实例的 `List`。同样,通过 `parallelStream` 调用进行多线程处理,然后 `collect` 调用(以线程安全的方式)将部分结果组装到 `numMap` 引用的 `Map` 中。然后,在 `numMap` 上调用 `get` 方法两次,一次获取 `evens`,第二次获取 `odds`。 + +实用函数 `dumpList` 再次使用来自流 API 的高阶 `forEach` 函数: + +``` +private void dumpList(String msg, List list) { + System.out.println("\n" + msg); + list.stream().forEach(n -> n.dump()); // 或者使用 forEach(Number::dump) +} +``` + +这是示例运行中程序输出的一部分: + +``` +The sum of the randomly generated values is: 3322 +The sum again, using a different method: 3322 + +Evens: + +Value: 72 (parity: even) +Value: 54 (parity: even) +... +Value: 92 (parity: even) + +Odds: + +Value: 35 (parity: odd) +Value: 37 (parity: odd) +... +Value: 41 (parity: odd) +``` + +### 用于代码简化的函数式结构 + +函数式结构(如方法引用和 lambda 表达式)非常适合在流 API 中使用。这些构造代表了 Java 中对高阶函数的主要简化。即使在糟糕的过去,Java 也通过 `Method` 和 `Constructor` 类型在技术上支持高阶函数,这些类型的实例可以作为参数传递给其它函数。由于其复杂性,这些类型在生产级 Java 中很少使用。例如,调用 `Method` 需要对象引用(如果方法是非**静态**的)或至少一个类标识符(如果方法是**静态**的)。然后,被调用的 `Method` 的参数作为**对象**实例传递给它,如果没有发生多态(那会出现另一种复杂性!),则可能需要显式向下转换。相比之下,lambda 和方法引用很容易作为参数传递给其它函数。 + +但是,新的函数式结构在流 API 之外具有其它用途。考虑一个 Java GUI 程序,该程序带有一个供用户按下的按钮,例如,按下以获取当前时间。按钮按下的事件处理程序可能编写如下: + +``` +JButton updateCurrentTime = new JButton("Update current time"); +updateCurrentTime.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + currentTime.setText(new Date().toString()); + } +}); +``` + +这个简短的代码段很难解释。关注第二行,其中方法 `addActionListener` 的参数开始如下: + +``` +new ActionListener() { +``` + +这似乎是错误的,因为 `ActionListener` 是一个**抽象**接口,而**抽象**类型不能通过调用 `new` 实例化。但是,事实证明,还有其它一些实例被实例化了:一个实现此接口的未命名内部类。如果上面的代码封装在名为 `OldJava` 的类中,则该未命名的内部类将被编译为 `OldJava$1.class`。`actionPerformed` 方法在这个未命名的内部类中被重写。 + +现在考虑使用新的函数式结构进行这个令人耳目一新的更改: + +``` +updateCurrentTime.addActionListener(e -> currentTime.setText(new Date().toString())); +``` + +lambda 表达式中的参数 `e` 是一个 `ActionEvent` 实例,而 lambda 的主体是对按钮上的 `setText` 的简单调用。 + +### 函数式接口和函数组合 + +到目前为止,使用的 lambda 已经写好了。但是,为了方便起见,我们可以像引用封装方法一样引用 lambda 表达式。以下一系列简短示例说明了这一点。 + +考虑以下接口定义: + +``` +@FunctionalInterface // 可选,通常省略 +interface BinaryIntOp { + abstract int compute(int arg1, int arg2); // abstract 声明可以被删除 +} +``` + +注释 `@FunctionalInterface` 适用于声明*唯一*抽象方法的任何接口;在本例中,这个抽象接口是 `compute`。一些标准接口,(例如具有唯一声明方法 `run` 的 `Runnable` 接口)同样符合这个要求。在此示例中,`compute` 是已声明的方法。该接口可用作引用声明中的目标类型: + +``` +BinaryIntOp div = (arg1, arg2) -> arg1 / arg2; +div.compute(12, 3); // 4 +``` + +包 `java.util.function` 提供各种函数式接口。以下是一些示例。 + +下面的代码段介绍了参数化的 `Predicate` 函数式接口。在此示例中,带有参数 `String` 的 `Predicate` 类型可以引用具有 `String` 参数的 lambda 表达式或诸如 `isEmpty` 之类的 `String` 方法。通常情况下,Predicate 是一个返回布尔值的函数。 + +``` +Predicate pred = String::isEmpty; // String 方法的 predicate 声明 +String[] strings = {"one", "two", "", "three", "four"}; +Arrays.asList(strings) + .stream() + .filter(pred) // 过滤掉非空字符串 + .forEach(System.out::println); // 只打印空字符串 +``` + +在字符串长度为零的情况下,`isEmpty` Predicate 判定结果为 `true`。 因此,只有空字符串才能进入管道的 `forEach` 阶段。 + +下一段代码将演示如何将简单的 lambda 或方法引用组合成更丰富的 lambda 或方法引用。考虑这一系列对 `IntUnaryOperator` 类型的引用的赋值,它接受一个整型参数并返回一个整型值: + +``` +IntUnaryOperator doubled = n -> n * 2; +IntUnaryOperator tripled = n -> n * 3; +IntUnaryOperator squared = n -> n * n; +``` + +`IntUnaryOperator` 是一个 `FunctionalInterface`,其唯一声明的方法为 `applyAsInt`。现在可以单独使用或以各种组合形式使用这三个引用 `doubled`、`tripled` 和 `squared`: + +``` +int arg = 5; +doubled.applyAsInt(arg); // 10 +tripled.applyAsInt(arg); // 15 +squared.applyAsInt(arg); // 25 +``` + +以下是一些函数组合的样例: + +``` +int arg = 5; +doubled.compose(squared).applyAsInt(arg); // 5 求 2 次方后乘 2:50 +tripled.compose(doubled).applyAsInt(arg); // 5 乘 2 后再乘 3:30 +doubled.andThen(squared).applyAsInt(arg); // 5 乘 2 后求 2 次方:100 +squared.andThen(tripled).applyAsInt(arg); // 5 求 2 次方后乘 3:75 +``` + +函数组合可以直接使用 lambda 表达式实现,但是引用使代码更简洁。 + +### 构造器引用 + +构造器引用是另一种函数式编程构造,而这些引用在比 lambda 和方法引用更微妙的上下文中非常有用。再一次重申,代码示例似乎是最好的解释方式。 + +考虑这个 [POJO][13] 类: + +``` +public class BedRocker { // 基岩的居民 + private String name; + public BedRocker(String name) { this.name = name; } + public String getName() { return this.name; } + public void dump() { System.out.println(getName()); } +} +``` + +该类只有一个构造函数,它需要一个 `String` 参数。给定一个名字数组,目标是生成一个 `BedRocker` 元素数组,每个名字代表一个元素。下面是使用了函数式结构的代码段: + +``` +String[] names = {"Fred", "Wilma", "Peebles", "Dino", "Baby Puss"}; + +Stream bedrockers = Arrays.asList(names).stream().map(BedRocker::new); +BedRocker[] arrayBR = bedrockers.toArray(BedRocker[]::new); + +Arrays.asList(arrayBR).stream().forEach(BedRocker::dump); +``` + +在较高的层次上,这个代码段将名字转换为 `BedRocker` 数组元素。具体来说,代码如下所示。`Stream` 接口(在包 `java.util.stream` 中)可以被参数化,而在本例中,生成了一个名为 `bedrockers` 的 `BedRocker` 流。 + +`Arrays.asList` 实用程序再次用于流化一个数组 `names`,然后将流的每一项传递给 `map` 函数,该函数的参数现在是构造器引用 `BedRocker::new`。这个构造器引用通过在每次调用时生成和初始化一个 `BedRocker` 实例来充当一个对象工厂。在第二行执行之后,名为 `bedrockers` 的流由五项 `BedRocker` 组成。 + +这个例子可以通过关注高阶 `map` 函数来进一步阐明。在通常情况下,一个映射将一个类型的值(例如,一个 `int`)转换为另一个*相同*类型的值(例如,一个整数的后继): + +``` +map(n -> n + 1) // 将 n 映射到其后继 +``` + +然而,在 `BedRocker` 这个例子中,转换更加戏剧化,因为一个类型的值(代表一个名字的 `String`)被映射到一个*不同*类型的值,在这个例子中,就是一个 `BedRocker` 实例,这个字符串就是它的名字。转换是通过一个构造器调用来完成的,它是由构造器引用来实现的: + +``` +map(BedRocker::new) // 将 String 映射到 BedRocker +``` + +传递给构造器的值是 `names` 数组中的其中一项。 + +此代码示例的第二行还演示了一个你目前已经非常熟悉的转换:先将数组先转换成 `List`,然后再转换成 `Stream`: + +``` +Stream bedrockers = Arrays.asList(names).stream().map(BedRocker::new); +``` + +第三行则是另一种方式 —— 流 `bedrockers` 通过使用*数组*构造器引用 `BedRocker[]::new` 调用 `toArray` 方法: + +``` +BedRocker[ ] arrayBR = bedrockers.toArray(BedRocker[]::new); +``` + +该构造器引用不会创建单个 `BedRocker` 实例,而是创建这些实例的整个数组:该构造器引用现在为 `BedRocker[]:new`,而不是 `BedRocker::new`。为了进行确认,将 `arrayBR` 转换为 `List`,再次对其进行流式处理,以便可以使用 `forEach` 来打印 `BedRocker` 的名字。 + +``` +Fred +Wilma +Peebles +Dino +Baby Puss +``` + +该示例对数据结构的微妙转换仅用几行代码即可完成,从而突出了可以将 lambda,方法引用或构造器引用作为参数的各种高阶函数的功能。 + +### 柯里化Currying + +*柯里化*函数是指减少函数执行任何工作所需的显式参数的数量(通常减少到一个)。(该术语是为了纪念逻辑学家 Haskell Curry。)一般来说,函数的参数越少,调用起来就越容易,也更健壮。(回想一下一些需要半打左右参数的噩梦般的函数!)因此,应将柯里化视为简化函数调用的一种尝试。`java.util.function` 包中的接口类型适合于柯里化,如以下示例所示。 + +引用的 `IntBinaryOperator` 接口类型是为函数接受两个整型参数,并返回一个整型值: + +``` +IntBinaryOperator mult2 = (n1, n2) -> n1 * n2; +mult2.applyAsInt(10, 20); // 200 +mult2.applyAsInt(10, 30); // 300 +``` + +引用 `mult2` 强调了需要两个显式参数,在本例中是 10 和 20。 + +前面介绍的 `IntUnaryOperator` 比 `IntBinaryOperator` 简单,因为前者只需要一个参数,而后者则需要两个参数。两者均返回整数值。因此,目标是将名为 `mult2` 的两个参数 `IntBinraryOperator` 柯里化成一个单一的 `IntUnaryOperator` 版本 `curriedMult2`。 + +考虑 `IntFunction` 类型。此类型的函数采用整型参数,并返回类型为 `R` 的结果,该结果可以是另一个函数 —— 更准确地说,是 `IntBinaryOperator`。让一个 lambda 返回另一个 lambda 很简单: + +``` +arg1 -> (arg2 -> arg1 * arg2) // 括号可以省略 +``` + +完整的 lambda 以 `arg1` 开头,而该 lambda 的主体以及返回的值是另一个以 `arg2` 开头的 lambda。返回的 lambda 仅接受一个参数(`arg2`),但返回了两个数字的乘积(`arg1` 和 `arg2`)。下面的概述,再加上代码,应该可以更好地进行说明。 + +以下是如何柯里化 `mult2` 的概述: + +- 类型为 `IntFunction` 的 lambda 被写入并调用,其整型值为 10。返回的 `IntUnaryOperator` 缓存了值 10,因此变成了已柯里化版本的 `mult2`,在本例中为 `curriedMult2`。 +- 然后使用单个显式参数(例如,20)调用 `curriedMult2` 函数,该参数与缓存的参数(在本例中为 10)相乘以生成返回的乘积。。 + +这是代码的详细信息: + +``` +// 创建一个接受一个参数 n1 并返回一个单参数 n2 -> n1 * n2 的函数,该函数返回一个(n1 * n2 乘积的)整型数。 +IntFunction curriedMult2Maker = n1 -> (n2 -> n1 * n2); +``` + +调用 `curriedMult2Maker` 生成所需的 `IntUnaryOperator` 函数: + +``` +// 使用 curriedMult2Maker 获取已柯里化版本的 mult2。 +// 参数 10 是上面的 lambda 的 n1。 +IntUnaryOperator curriedMult2 = curriedMult2Maker2.apply(10); +``` + +值 `10` 现在缓存在 `curriedMult2` 函数中,以便 `curriedMult2` 调用中的显式整型参数乘以 10: + +``` +curriedMult2.applyAsInt(20); // 200 = 10 * 20 +curriedMult2.applyAsInt(80); // 800 = 10 * 80 +``` + +缓存的值可以随意更改: + +``` +curriedMult2 = curriedMult2Maker.apply(50); // 缓存 50 +curriedMult2.applyAsInt(101); // 5050 = 101 * 50 +``` + +当然,可以通过这种方式创建多个已柯里化版本的 `mult2`,每个版本都有一个 `IntUnaryOperator`。 + +柯里化充分利用了 lambda 的强大功能:可以很容易地编写 lambda 表达式来返回需要的任何类型的值,包括另一个 lambda。 + +### 总结 + +Java 仍然是基于类的面向对象的编程语言。但是,借助流 API 及其支持的函数式构造,Java 向函数式语言(例如 Lisp)迈出了决定性的(同时也是受欢迎的)一步。结果是 Java 更适合处理现代编程中常见的海量数据流。在函数式方向上的这一步还使以在前面的代码示例中突出显示的管道的方式编写清晰简洁的 Java 代码更加容易: + +``` +dataStream + .parallelStream() // 多线程以提高效率 + .filter(...) // 阶段 1 + .map(...) // 阶段 2 + .filter(...) // 阶段 3 + ... + .collect(...); // 或者,也可以进行归约:阶段 N +``` + +自动多线程,以 `parallel` 和 `parallelStream` 调用为例,建立在 Java 的 fork/join 框架上,该框架支持 任务窃取task stealing 以提高效率。假设 `parallelStream` 调用后面的线程池由八个线程组成,并且 `dataStream` 被八种方式分区。某个线程(例如,T1)可能比另一个线程(例如,T7)工作更快,这意味着应该将 T7 的某些任务移到 T1 的工作队列中。这会在运行时自动发生。 + +在这个简单的多线程世界中,程序员的主要职责是编写线程安全函数,这些函数作为参数传递给在流 API 中占主导地位的高阶函数。尤其是 lambda 鼓励编写纯函数(因此是线程安全的)函数。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/javastream + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[laingke](https://github.com/laingke) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK (computer screen ) +[2]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+random +[3]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+list +[4]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+system +[5]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+number +[6]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+arrays +[7]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+integer +[8]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+string +[9]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+jbutton +[10]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionlistener +[11]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+actionevent +[12]: http://www.google.com/search?hl=en&q=allinurl%3Adocs.oracle.com+javase+docs+api+date +[13]: https://en.wikipedia.org/wiki/Plain_old_Java_object diff --git a/published/202002/20200103 Add scorekeeping to your Python game.md b/published/202002/20200103 Add scorekeeping to your Python game.md new file mode 100644 index 0000000000..62fa3fe600 --- /dev/null +++ b/published/202002/20200103 Add scorekeeping to your Python game.md @@ -0,0 +1,626 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11839-1.html) +[#]: subject: (Add scorekeeping to your Python game) +[#]: via: (https://opensource.com/article/20/1/add-scorekeeping-your-python-game) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +添加计分到你的 Python 游戏 +====== + +> 在本系列的第十一篇有关使用 Python Pygame 模块进行编程的文章中,显示玩家获得战利品或受到伤害时的得分。 + +![](https://img.linux.net.cn/data/attachment/album/202002/01/154838led0y08y2aqetz1q.jpg) + +这是仍在进行中的关于使用 [Pygame][3] 模块来在 [Python 3][2] 在创建电脑游戏的第十一部分。先前的文章是: + + * [通过构建一个简单的掷骰子游戏去学习怎么用 Python 编程][4] + * [使用 Python 和 Pygame 模块构建一个游戏框架][5] + * [如何在你的 Python 游戏中添加一个玩家][6] + * [用 Pygame 使你的游戏角色移动起来][7] + * [如何向你的 Python 游戏中添加一个敌人][8] + * [在 Pygame 游戏中放置平台][19] + * [在你的 Python 游戏中模拟引力][9] + * [为你的 Python 平台类游戏添加跳跃功能][10] + * [使你的 Python 游戏玩家能够向前和向后跑][11] + * [在你的 Python 平台类游戏中放一些奖励][12] + +如果你已经跟随这一系列很久,那么已经学习了使用 Python 创建一个视频游戏所需的所有基本语法和模式。然而,它仍然缺少一个至关重要的组成部分。这一组成部分不仅仅对用 Python 编程游戏重要;不管你探究哪个计算机分支,你都必需精通:作为一个程序员,通过阅读一种语言的或库的文档来学习新的技巧。 + +幸运的是,你正在阅读本文的事实表明你熟悉文档。为了使你的平台类游戏更加美观,在这篇文章中,你将在游戏屏幕上添加得分和生命值显示。不过,教你如何找到一个库的功能以及如何使用这些新的功能的这节课程并没有多神秘。 + +### 在 Pygame 中显示得分 + +现在,既然你有了可以被玩家收集的奖励,那就有充分的理由来记录分数,以便你的玩家看到他们收集了多少奖励。你也可以跟踪玩家的生命值,以便当他们被敌人击中时会有相应结果。 + +你已经有了跟踪分数和生命值的变量,但是这一切都发生在后台。这篇文章教你在游戏期间在游戏屏幕上以你选择的一种字体来显示这些统计数字。 + +### 阅读文档 + +大多数 Python 模块都有文档,即使那些没有文档的模块,也能通过 Python 的帮助功能来进行最小的文档化。[Pygame 的主页面][13] 链接了它的文档。不过,Pygame 是一个带有很多文档的大模块,并且它的文档不像在 Opensource.com 上的文章一样,以同样易理解的(和友好的、易解释的、有用的)叙述风格来撰写的。它们是技术文档,并且列出在模块中可用的每个类和函数,各自要求的输入类型等等。如果你不适应参考代码组件描述,这可能会令人不知所措。 + +在烦恼于库的文档前,第一件要做的事,就是来想想你正在尝试达到的目标。在这种情况下,你想在屏幕上显示玩家的得分和生命值。 + +在你确定你需要的结果后,想想它需要什么的组件。你可以从变量和函数的方面考虑这一点,或者,如果你还没有自然地想到这一点,你可以进行一般性思考。你可能意识到需要一些文本来显示一个分数,你希望 Pygame 在屏幕上绘制这些文本。如果你仔细思考,你可能会意识到它与在屏幕上渲染一个玩家、奖励或一个平台并多么大的不同。 + +从技术上讲,你*可以*使用数字图形,并让 Pygame 显示这些数字图形。它不是达到你目标的最容易的方法,但是如果它是你唯一知道的方法,那么它是一个有效的方法。不过,如果你参考 Pygame 的文档,你看到列出的模块之一是 `font`,这是 Pygame 使得在屏幕上来使打印文本像输入文字一样容易的方法。 + +### 解密技术文档 + +`font` 文档页面以 `pygame.font.init()` 开始,它列出了用于初始化字体模块的函数。它由 `pygame.init()` 自动地调用,你已经在代码中调用了它。再强调一次,从技术上讲,你已经到达一个*足够好*的点。虽然你尚不知道*如何做*,你知道你*能够*使用 `pygame.font` 函数来在屏幕上打印文本。 + +然而,如果你阅读更多一些,你会找到这里还有一种更好的方法来打印字体。`pygame.freetype` 模块在文档中的描述方式如下: + +> `pygame.freetype` 模块是 `pygame.fontpygame` 模块的一个替代品,用于加载和渲染字体。它有原函数的所有功能,外加很多新的功能。 + +在 `pygame.freetype` 文档页面的下方,有一些示例代码: + +``` +import pygame +import pygame.freetype +``` + +你的代码应该已经导入了 Pygame,不过,请修改你的 `import` 语句以包含 Freetype 模块: + +``` +import pygame +import sys +import os +import pygame.freetype +``` + +### 在 Pygame 中使用字体 + +从 `font` 模块的描述中可以看出,显然 Pygame 使用一种字体(不管它的你提供的或内置到 Pygame 的默认字体)在屏幕上渲染字体。滚动浏览 `pygame.freetype` 文档来找到 `pygame.freetype.Font` 函数: + +``` +pygame.freetype.Font +从支持的字体文件中创建一个新的字体实例。 + +Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font + +pygame.freetype.Font.name +  符合规则的字体名称。 + +pygame.freetype.Font.path +  字体文件路径。 + +pygame.freetype.Font.size +  在渲染中使用的默认点大小 +``` + +这描述了如何在 Pygame 中构建一个字体“对象”。把屏幕上的一个简单对象视为一些代码属性的组合对你来说可能不太自然,但是这与你构建英雄和敌人精灵的方式非常类似。你需要一个字体文件,而不是一个图像文件。在你有一个字体文件后,你可以在你的代码中使用 `pygame.freetype.Font` 函数来创建一个字体对象,然后使用该对象来在屏幕上渲染文本。 + +因为并不是世界上的每个人的电脑上都有完全一样的字体,因此将你选择的字体与你的游戏捆绑在一起是很重要的。要捆绑字体,首先在你的游戏文件夹中创建一个新的目录,放在你为图像而创建的文件目录旁边。称其为 `fonts` 。 + +即使你的计算机操作系统随附了几种字体,但是将这些字体给予其他人是非法的。这看起来很奇怪,但法律就是这样运作的。如果想与你的游戏一起随附一种字体,你必需找到一种开源或知识共享的字体,以允许你随游戏一起提供该字体。 + +专门提供自由和合法字体的网站包括: + + * [Font Library][14] + * [Font Squirrel][15] + * [League of Moveable Type][16] + +当你找到你喜欢的字体后,下载下来。解压缩 ZIP 或 [TAR][17] 文件,并移动 `.ttf` 或 `.otf` 文件到你的项目目录下的 `fonts` 文件夹中。 + +你没有安装字体到你的计算机上。你只是放置字体到你游戏的 `fonts` 文件夹中,以便 Pygame 可以使用它。如果你想,你*可以*在你的计算机上安装该字体,但是没有必要。重要的是将字体放在你的游戏目录中,这样 Pygame 可以“描绘”字体到屏幕上。 + +如果字体文件的名称复杂且带有空格或特殊字符,只需要重新命名它即可。文件名称是完全任意的,并且对你来说,文件名称越简单,越容易将其键入你的代码中。 + +现在告诉 Pygame 你的字体。从文档中你知道,当你至少提供了字体文件路径给 `pygame.freetype.Font` 时(文档明确指出所有其余属性都是可选的),你将在返回中获得一个字体对象: + +``` +Font(file, size=0, font_index=0, resolution=0, ucs4=False) -> Font +``` + +创建一个称为 `myfont` 的新变量来充当你在游戏中字体,并放置 `Font` 函数的结果到这个变量中。这个示例中使用 `amazdoom.ttf` 字体,但是你可以使用任何你想使用的字体。在你的设置部分放置这些代码: + +``` +font_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"fonts","amazdoom.ttf") +font_size = tx +myfont = pygame.freetype.Font(font_path, font_size) +``` + +### 在 Pygame 中显示文本 + +现在你已经创建一个字体对象,你需要一个函数来绘制你想绘制到屏幕上的文本。这和你在你的游戏中绘制背景和平台是相同的原理。 + +首先,创建一个函数,并使用 `myfont` 对象来创建一些文本,设置颜色为某些 RGB 值。这必须是一个全局函数;它不属于任何具体的类: + +``` +def stats(score,health): +    myfont.render_to(world, (4, 4), "Score:"+str(score), WHITE, None, size=64) +    myfont.render_to(world, (4, 72), "Health:"+str(health), WHITE, None, size=64) +``` + +当然,你此刻已经知道,如果它不在主循环中,你的游戏将不会发生任何事,所以在文件的底部添加一个对你的 `stats` 函数的调用: + +``` +    for e in enemy_list: +        e.move() +    stats(player.score,player.health) # draw text +    pygame.display.flip() +``` + +尝试你的游戏。 + +当玩家收集奖励品时,得分会上升。当玩家被敌人击中时,生命值下降。成功! + +![Keeping score in Pygame][18] + +不过,这里有一个问题。当一个玩家被敌人击中时,健康度会*一路*下降,这是不公平的。你刚刚发现一个非致命的错误。非致命的错误是这些在应用程序中小问题,(通常)不会阻止应用程序启动或甚至导致停止工作,但是它们要么没有意义,要么会惹恼用户。这里是如何解决这个问题的方法。 + +### 修复生命值计数 + +当前生命值系统的问题是,敌人接触玩家时,Pygame 时钟的每一次滴答,健康度都会减少。这意味着一个缓慢移动的敌人可能在一次遭遇中将一个玩家降低健康度至 -200 ,这不公平。当然,你可以给你的玩家一个 10000 的起始健康度得分,而不用担心它;这可以工作,并且可能没有人会注意。但是这里有一个更好的方法。 + +当前,你的代码侦查出一个玩家和一个敌人发生碰撞的时候。生命值问题的修复是检测*两个*独立的事件:什么时候玩家和敌人碰撞,并且,在它们碰撞后,什么时候它们*停止*碰撞。 + +首先,在你的玩家类中,创建一个变量来代表玩家和敌人碰撞在一起: + +``` +        self.frame = 0 +        self.health = 10 +        self.damage = 0 +``` + +在你的 `Player` 类的 `update` 函数中,*移除*这块代码块: + +``` +        for enemy in enemy_hit_list: +            self.health -= 1 +            #print(self.health) +``` + +并且在它的位置,只要玩家当前没有被击中,检查碰撞: + +``` +        if self.damage == 0: +            for enemy in enemy_hit_list: +                if not self.rect.contains(enemy): +                    self.damage = self.rect.colliderect(enemy) +``` + +你可能会在你删除的语句块和你刚刚添加的语句块之间看到相似之处。它们都在做相同的工作,但是新的代码更复杂。最重要的是,只有当玩家*当前*没有被击中时,新的代码才运行。这意味着,当一个玩家和敌人碰撞时,这些代码运行一次,而不是像以前那样一直发生碰撞。 + +新的代码使用两个新的 Pygame 函数。`self.rect.contains` 函数检查一个敌人当前是否在玩家的边界框内,并且当它是 `true` 时, `self.rect.colliderect` 设置你的新的 `self.damage` 变量为 1,而不管它多少次是 `true` 。 + +现在,即使被一个敌人击中 3 秒,对 Pygame 来说仍然看作一次击中。 + +我通过通读 Pygame 的文档而发现了这些函数。你没有必要一次阅读完全部的文档,并且你也没有必要阅读每个函数的每个单词。不过,花费时间在你正在使用的新的库或模块的文档上是很重要的;否则,你极有可能在重新发明轮子。不要花费一个下午的时间来尝试修改拼接一个解决方案到一些东西,而这些东西已经被你正在使用的框架的所解决。阅读文档,知悉函数,并从别人的工作中获益! + +最后,添加另一个代码语句块来侦查出什么时候玩家和敌人不再接触。然后直到那时,才从玩家减少一个生命值。 + +``` +        if self.damage == 1: +            idx = self.rect.collidelist(enemy_hit_list) +            if idx == -1: +                self.damage = 0   # set damage back to 0 +                self.health -= 1  # subtract 1 hp +``` + +注意,*只有*当玩家被击中时,这个新的代码才会被触发。这意味着,在你的玩家在你的游戏世界正在探索或收集奖励时,这个代码不会运行。它仅当 `self.damage` 变量被激活时运行。 + +当代码运行时,它使用 `self.rect.collidelist` 来查看玩家是否*仍然*接触在你敌人列表中的敌人(当其未侦查到碰撞时,`collidelist` 返回 -1)。在它没有接触敌人时,是该处理 `self.damage` 的时机:通过设置 `self.damage` 变量回到 0 来使其无效,并减少一点生命值。 + +现在尝试你的游戏。 + +### 得分反应 + +现在,你有一个来让你的玩家知道它们分数和生命值的方法,当你的玩家达到某些里程碑时,你可以确保某些事件发生。例如,也许这里有一个特殊的恢复一些生命值的奖励项目。也许一个到达 0 生命值的玩家不得不从一个关卡的起始位置重新开始。 + +你可以在你的代码中检查这些事件,并且相应地操纵你的游戏世界。你已经知道该怎么做,所以请浏览文档来寻找新的技巧,并且独立地尝试这些技巧。 + +这里是到目前为止所有的代码: + +``` +#!/usr/bin/env python3 +# draw a world +# add a player and player control +# add player movement +# add enemy and basic collision +# add platform +# add gravity +# add jumping +# add scrolling +# add loot +# add score + +# GNU All-Permissive License +# Copying and distribution of this file, with or without modification, +# are permitted in any medium without royalty provided the copyright +# notice and this notice are preserved. This file is offered as-is, +# without any warranty. + +import pygame +import sys +import os +import pygame.freetype + +''' +Objects +''' + +class Platform(pygame.sprite.Sprite): + # x location, y location, img width, img height, img file + def __init__(self,xloc,yloc,imgw,imgh,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)).convert() + self.image.convert_alpha() + self.rect = self.image.get_rect() + self.rect.y = yloc + self.rect.x = xloc + +class Player(pygame.sprite.Sprite): + ''' + Spawn a player + ''' + def __init__(self): + pygame.sprite.Sprite.__init__(self) + self.movex = 0 + self.movey = 0 + self.frame = 0 + self.health = 10 + self.damage = 0 + self.collide_delta = 0 + self.jump_delta = 6 + self.score = 1 + self.images = [] + for i in range(1,9): + img = pygame.image.load(os.path.join('images','hero' + str(i) + '.png')).convert() + img.convert_alpha() + img.set_colorkey(ALPHA) + self.images.append(img) + self.image = self.images[0] + self.rect = self.image.get_rect() + + def jump(self,platform_list): + self.jump_delta = 0 + + def gravity(self): + self.movey += 3.2 # how fast player falls + + if self.rect.y > worldy and self.movey >= 0: + self.movey = 0 + self.rect.y = worldy-ty + + def control(self,x,y): + ''' + control player movement + ''' + self.movex += x + self.movey += y + + def update(self): + ''' + Update sprite position + ''' + + self.rect.x = self.rect.x + self.movex + self.rect.y = self.rect.y + self.movey + + # moving left + if self.movex < 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[self.frame//ani] + + # moving right + if self.movex > 0: + self.frame += 1 + if self.frame > ani*3: + self.frame = 0 + self.image = self.images[(self.frame//ani)+4] + + # collisions + enemy_hit_list = pygame.sprite.spritecollide(self, enemy_list, False) + if self.damage == 0: + for enemy in enemy_hit_list: + if not self.rect.contains(enemy): + self.damage = self.rect.colliderect(enemy) + + if self.damage == 1: + idx = self.rect.collidelist(enemy_hit_list) + if idx == -1: + self.damage = 0 # set damage back to 0 + self.health -= 1 # subtract 1 hp + + loot_hit_list = pygame.sprite.spritecollide(self, loot_list, False) + for loot in loot_hit_list: + loot_list.remove(loot) + self.score += 1 + print(self.score) + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.collide_delta = 0 # stop jumping + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.movey = 0 + self.rect.y = worldy-ty-ty + self.collide_delta = 0 # stop jumping + if self.rect.y > g.rect.y: + self.health -=1 + print(self.health) + + if self.collide_delta < 6 and self.jump_delta < 6: + self.jump_delta = 6*2 + self.movey -= 33 # how high to jump + self.collide_delta += 6 + self.jump_delta += 6 + +class Enemy(pygame.sprite.Sprite): + ''' + Spawn an enemy + ''' + def __init__(self,x,y,img): + pygame.sprite.Sprite.__init__(self) + self.image = pygame.image.load(os.path.join('images',img)) + self.movey = 0 + #self.image.convert_alpha() + #self.image.set_colorkey(ALPHA) + self.rect = self.image.get_rect() + self.rect.x = x + self.rect.y = y + self.counter = 0 + + + def move(self): + ''' + enemy movement + ''' + distance = 80 + speed = 8 + + self.movey += 3.2 + + if self.counter >= 0 and self.counter <= distance: + self.rect.x += speed + elif self.counter >= distance and self.counter <= distance*2: + self.rect.x -= speed + else: + self.counter = 0 + + self.counter += 1 + + if not self.rect.y >= worldy-ty-ty: + self.rect.y += self.movey + + plat_hit_list = pygame.sprite.spritecollide(self, plat_list, False) + for p in plat_hit_list: + self.movey = 0 + if self.rect.y > p.rect.y: + self.rect.y = p.rect.y+ty + else: + self.rect.y = p.rect.y-ty + + ground_hit_list = pygame.sprite.spritecollide(self, ground_list, False) + for g in ground_hit_list: + self.rect.y = worldy-ty-ty + + +class Level(): + def bad(lvl,eloc): + if lvl == 1: + enemy = Enemy(eloc[0],eloc[1],'yeti.png') # spawn enemy + enemy_list = pygame.sprite.Group() # create enemy group + enemy_list.add(enemy) # add enemy to group + + if lvl == 2: + print("Level " + str(lvl) ) + + return enemy_list + + def loot(lvl,tx,ty): + if lvl == 1: + loot_list = pygame.sprite.Group() + loot = Platform(200,ty*7,tx,ty, 'loot_1.png') + loot_list.add(loot) + + if lvl == 2: + print(lvl) + + return loot_list + + def ground(lvl,gloc,tx,ty): + ground_list = pygame.sprite.Group() + i=0 + if lvl == 1: + while i < len(gloc): + ground = Platform(gloc[i],worldy-ty,tx,ty,'ground.png') + ground_list.add(ground) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return ground_list + + def platform(lvl,tx,ty): + plat_list = pygame.sprite.Group() + ploc = [] + i=0 + if lvl == 1: + ploc.append((20,worldy-ty-128,3)) + ploc.append((300,worldy-ty-256,3)) + ploc.append((500,worldy-ty-128,4)) + + while i < len(ploc): + j=0 + while j <= ploc[i][2]: + plat = Platform((ploc[i][0]+(j*tx)),ploc[i][1],tx,ty,'ground.png') + plat_list.add(plat) + j=j+1 + print('run' + str(i) + str(ploc[i])) + i=i+1 + + if lvl == 2: + print("Level " + str(lvl) ) + + return plat_list + +def stats(score,health): + myfont.render_to(world, (4, 4), "Score:"+str(score), SNOWGRAY, None, size=64) + myfont.render_to(world, (4, 72), "Health:"+str(health), SNOWGRAY, None, size=64) + +''' +Setup +''' +worldx = 960 +worldy = 720 + +fps = 40 # frame rate +ani = 4 # animation cycles +clock = pygame.time.Clock() +pygame.init() +main = True + +BLUE = (25,25,200) +BLACK = (23,23,23 ) +WHITE = (254,254,254) +SNOWGRAY = (137,164,166) +ALPHA = (0,255,0) + +world = pygame.display.set_mode([worldx,worldy]) +backdrop = pygame.image.load(os.path.join('images','stage.png')).convert() +backdropbox = world.get_rect() +player = Player() # spawn player +player.rect.x = 0 +player.rect.y = 0 +player_list = pygame.sprite.Group() +player_list.add(player) +steps = 10 +forwardx = 600 +backwardx = 230 + +eloc = [] +eloc = [200,20] +gloc = [] +tx = 64 #tile size +ty = 64 #tile size + +font_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),"fonts","amazdoom.ttf") +font_size = tx +myfont = pygame.freetype.Font(font_path, font_size) + +i=0 +while i <= (worldx/tx)+tx: + gloc.append(i*tx) + i=i+1 + +enemy_list = Level.bad( 1, eloc ) +ground_list = Level.ground( 1,gloc,tx,ty ) +plat_list = Level.platform( 1,tx,ty ) +loot_list = Level.loot(1,tx,ty) + +''' +Main loop +''' +while main == True: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + pygame.quit(); sys.exit() + main = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_LEFT or event.key == ord('a'): + print("LEFT") + player.control(-steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + print("RIGHT") + player.control(steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + print('jump') + + if event.type == pygame.KEYUP: + if event.key == pygame.K_LEFT or event.key == ord('a'): + player.control(steps,0) + if event.key == pygame.K_RIGHT or event.key == ord('d'): + player.control(-steps,0) + if event.key == pygame.K_UP or event.key == ord('w'): + player.jump(plat_list) + + if event.key == ord('q'): + pygame.quit() + sys.exit() + main = False + + # scroll the world forward + if player.rect.x >= forwardx: + scroll = player.rect.x - forwardx + player.rect.x = forwardx + for p in plat_list: + p.rect.x -= scroll + for e in enemy_list: + e.rect.x -= scroll + for l in loot_list: + + l.rect.x -= scroll + + # scroll the world backward + if player.rect.x <= backwardx: + scroll = backwardx - player.rect.x + player.rect.x = backwardx + for p in plat_list: + p.rect.x += scroll + for e in enemy_list: + e.rect.x += scroll + for l in loot_list: + l.rect.x += scroll + + world.blit(backdrop, backdropbox) + player.gravity() # check gravity + player.update() + player_list.draw(world) #refresh player position + enemy_list.draw(world) # refresh enemies + ground_list.draw(world) # refresh enemies + plat_list.draw(world) # refresh platforms + loot_list.draw(world) # refresh loot + for e in enemy_list: + e.move() + stats(player.score,player.health) # draw text + pygame.display.flip() + clock.tick(fps) +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/add-scorekeeping-your-python-game + +作者:[Seth Kenlon][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://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW_maze.png?itok=mZ5LP4-X (connecting yellow dots in a maze) +[2]: https://www.python.org/ +[3]: https://www.pygame.org/news +[4]: https://linux.cn/article-9071-1.html +[5]: https://linux.cn/article-10850-1.html +[6]: https://linux.cn/article-10858-1.html +[7]: https://linux.cn/article-10874-1.html +[8]: https://linux.cn/article-10883-1.html +[9]: https://linux.cn/article-11780-1.html +[10]: https://linux.cn/article-11790-1.html +[11]: https://linux.cn/article-11819-1.html +[12]: https://linux.cn/article-11828-1.html +[13]: http://pygame.org/news +[14]: https://fontlibrary.org/ +[15]: https://www.fontsquirrel.com/ +[16]: https://www.theleagueofmoveabletype.com/ +[17]: https://opensource.com/article/17/7/how-unzip-targz-file +[18]: https://opensource.com/sites/default/files/uploads/pygame-score.jpg (Keeping score in Pygame) +[19]: https://linux.cn/article-10902-1.html diff --git a/published/202002/20200109 My favorite Bash hacks.md b/published/202002/20200109 My favorite Bash hacks.md new file mode 100644 index 0000000000..da0173b7a2 --- /dev/null +++ b/published/202002/20200109 My favorite Bash hacks.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11841-1.html) +[#]: subject: (My favorite Bash hacks) +[#]: via: (https://opensource.com/article/20/1/bash-scripts-aliases) +[#]: author: (Katie McLaughlin https://opensource.com/users/glasnt) + +我珍藏的 Bash 秘籍 +====== + +> 通过别名和其他捷径来提高你经常忘记的那些事情的效率。 + +![bash logo on green background][1] + +要是你整天使用计算机,如果能找到需要重复执行的命令并记下它们以便以后轻松使用那就太棒了。它们全都呆在那里,藏在 `~/.bashrc` 中(或 [zsh 用户][2]的 `~/.zshrc` 中),等待着改善你的生活! + +在本文中,我分享了我最喜欢的这些助手命令,对于我经常遗忘的事情,它们很有用,也希望这可以帮助到你,以及为你解决一些经常头疼的问题。 + +### 完事吱一声 + +当我执行一个需要长时间运行的命令时,我经常采用多任务的方式,然后就必须回头去检查该操作是否已完成。然而通过有用的 `say` 命令,现在就不用再这样了(这是在 MacOS 上;请根据你的本地环境更改为等效的方式): + +``` +function looooooooong { + START=$(date +%s.%N) + $* + EXIT_CODE=$? + END=$(date +%s.%N) + DIFF=$(echo "$END - $START" | bc) + RES=$(python -c "diff = $DIFF; min = int(diff / 60); print('%s min' % min)") + result="$1 completed in $RES, exit code $EXIT_CODE." + echo -e "\n⏰ $result" + ( say -r 250 $result 2>&1 > /dev/null & ) +} +``` + +这个命令会记录命令的开始和结束时间,计算所需的分钟数,并“说”出调用的命令、花费的时间和退出码。当简单的控制台铃声无法使用时,我发现这个超级有用。 + +### 安装小助手 + +我在小时候就开始使用 Ubuntu,而我需要学习的第一件事就是如何安装软件包。我曾经首先添加的别名之一是它的助手(根据当天的流行梗命名的): + +``` +alias canhas="sudo apt-get install -y" +``` + +### GPG 签名 + +有时候,我必须在没有 GPG 扩展程序或应用程序的情况下给电子邮件签署 [GPG][3] 签名,我会跳到命令行并使用以下令人讨厌的别名: + +``` +alias gibson="gpg --encrypt --sign --armor" +alias ungibson="gpg --decrypt" +``` + +### Docker + +Docker 的子命令很多,但是 Docker compose 的更多。我曾经使用这些别名来将 `--rm` 标志丢到脑后,但是现在不再使用这些有用的别名了: + +``` +alias dc="docker-compose" +alias dcr="docker-compose run --rm" +alias dcb="docker-compose run --rm --build" +``` + +### Google Cloud 的 gcurl 助手 + +对于我来说,Google Cloud 是一个相对较新的东西,而它有[极多的文档][4]。`gcurl` 是一个别名,可确保在用带有身份验证标头的本地 `curl` 命令连接 Google Cloud API 时,可以获得所有正确的标头。 + +### Git 和 ~/.gitignore + +我工作中用 Git 很多,因此我有一个专门的部分来介绍 Git 助手。 + +我最有用的助手之一是我用来克隆 GitHub 存储库的。你不必运行: + +``` +git clone git@github.com:org/repo /Users/glasnt/git/org/repo +``` + +我设置了一个克隆函数: + +``` +clone(){ +    echo Cloning $1 to ~/git/$1 +    cd ~/git +    git clone git@github.com:$1 $1 +    cd $1 +} +``` + +即使每次进入 `~/.bashrc` 文件看到这个时,我总是会忘记和傻笑,我也有一个“刷新上游”命令: + +``` +alias yoink="git checkout master && git fetch upstream master && git merge upstream/master" +``` + +给 Git 一族的另一个助手是全局忽略文件。在你的 `git config --global --list` 中,你应该看到一个 `core.excludesfile`。如果没有,请[创建一个][6],然后将你总是放到各个 `.gitignore` 文件中的内容填满它。作为 MacOS 上的 Python 开发人员,对我来说,这些内容是: + +``` +.DS_Store     # macOS clutter +venv/         # I never want to commit my virtualenv +*.egg-info/*  # ... nor any locally compiled packages +__pycache__   # ... or source +*.swp         # ... nor any files open in vim +``` + +你可以在 [Gitignore.io][7] 或 GitHub 上的 [Gitignore 存储库][8]上找到其他建议。 + +### 轮到你了 + +你最喜欢的助手命令是什么?请在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/bash-scripts-aliases + +作者:[Katie McLaughlin][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/glasnt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://opensource.com/article/19/9/getting-started-zsh +[3]: https://gnupg.org/ +[4]: https://cloud.google.com/service-infrastructure/docs/service-control/getting-started +[5]: mailto:git@github.com +[6]: https://help.github.com/en/github/using-git/ignoring-files#create-a-global-gitignore +[7]: https://www.gitignore.io/ +[8]: https://github.com/github/gitignore diff --git a/published/202002/20200109 What-s HTTPS for secure computing.md b/published/202002/20200109 What-s HTTPS for secure computing.md new file mode 100644 index 0000000000..975b4ebdff --- /dev/null +++ b/published/202002/20200109 What-s HTTPS for secure computing.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11877-1.html) +[#]: subject: (What's HTTPS for secure computing?) +[#]: via: (https://opensource.com/article/20/1/confidential-computing) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +用于安全计算的 HTTPS 是什么? +====== + +> 在默认的情况下,网站的安全性还不足够。 + +![](https://img.linux.net.cn/data/attachment/album/202002/11/123552rqncn4c7474j44jq.jpg) + +在过去的几年里,寻找一个只以 “http://...” 开头的网站变得越来越难,这是因为业界终于意识到,网络安全“是件事”,同时也是因为客户端和服务端之间建立和使用 https 连接变得更加容易了。类似的转变可能正以不同的方式发生在云计算、边缘计算、物联网、区块链,人工智能、机器学习等领域。长久以来,我们都知道我们应该对存储的静态数据和在网络中传输的数据进行加密,但是在使用和处理数据的时候对它进行加密是困难且昂贵的。可信计算(使用例如受信任的执行环境Trusted Execution Environments TEEs 这样的硬件功能来提供数据和算法这种类型的保护)可以保护主机系统中的或者易受攻击的环境中的数据。 + +关于 [TEEs][2],当然,还有我和 Nathaniel McCallum 共同创立的 [Enarx 项目][3],我已经写了几次文章(参见《[给每个人的 Enarx(一个任务)][4]》 和 《[Enarx 迈向多平台][5]》)。Enarx 使用 TEEs 来提供独立于平台和语言的部署平台,以此来让你能够安全地将敏感应用或者敏感组件(例如微服务)部署在你不信任的主机上。当然,Enarx 是完全开源的(顺便提一下,我们使用的是 Apache 2.0 许可证)。能够在你不信任的主机上运行工作负载,这是可信计算的承诺,它扩展了使用静态敏感数据和传输中数据的常规做法: + +* **存储**:你要加密你的静态数据,因为你不完全信任你的基础存储架构。 +* **网络**:你要加密你正在传输中的数据,因为你不完全信任你的基础网络架构。 +* **计算**:你要加密你正在使用中的数据,因为你不完全信任你的基础计算架构。 + +关于信任,我有非常多的话想说,而且,上述说法里的单词“**完全**”是很重要的(在重新读我写的这篇文章的时候,我新加了这个单词)。不论哪种情况,你必须在一定程度上信任你的基础设施,无论是传递你的数据包还是存储你的数据块,例如,对于计算基础架构,你必须要去信任 CPU 和与之关联的固件,这是因为如果你不信任他们,你就无法真正地进行计算(现在有一些诸如同态加密homomorphic encryption一类的技术,这些技术正在开始提供一些可能性,但是它们依然有限,这些技术还不够成熟)。 + +考虑到发现的一些 CPU 安全性问题,是否应该完全信任 CPU 有时自然会产生疑问,以及它们是否在针对其所在的主机的物理攻击中具有完全的安全性。 + +这两个问题的回答都是“不”,但是在考虑到大规模可用性和普遍推广的成本,这已经是我们当前拥有的最好的技术了。为了解决第二个问题,没有人去假装这项技术(或者任何的其他技术)是完全安全的:我们需要做的是思考我们的[威胁模型][6]并确定这个情况下的 TEEs 是否为我们的特殊需求提供了足够的安全防护。关于第一个问题,Enarx 采用的模型是在部署时就对你是否信任一个特定的 CPU 组做出决定。举个例子,如果供应商 Q 的 R 代芯片被发现有漏洞,可以很简单地说“我拒绝将我的工作内容部署到 Q 的 R 代芯片上去,但是仍然可以部署到 Q 的 S 型号、T 型号和 U 型号的芯片以及任何 P、M 和 N 供应商的任何芯片上去。” + +我认为这里发生了三处改变,这些改变引起了人们现在对机密计算confidential computing的兴趣和采用。 + +1. **硬件可用**:只是在过去的 6 到 12 个月里,支持 TEEs 的硬件才开始变得广泛可用,这会儿市场上的主要例子是 Intel 的 SGX 和 AMD 的 SEV。我们期望在未来可以看到支持 TEE 的硬件的其他例子。 +2. **行业就绪**:就像上云越来越多地被接受作为应用程序部署的模型,监管机构和立法机构也在提高各类组织保护其管理的数据的要求。组织开始呼吁在不受信任的主机运行敏感程序(或者是处理敏感数据的应用程序)的方法,更确切地说,是在无法完全信任且带有敏感数据的主机上运行的方法。这不足为奇:如果芯片制造商看不到这项技术的市场,他们就不会投太多的钱在这项技术上。Linux 基金会的[机密计算联盟(CCC)][7]的成立就是业界对如何寻找使用加密计算的通用模型并且鼓励开源项目使用这些技术感兴趣的案例。(红帽发起的 Enarx 是一个 CCC 项目。) +3. **开放源码**:就像区块链一样,机密计算是使用开源绝对明智的技术之一。如果你要运行敏感程序,你需要去信任正在为你运行的程序。不仅仅是 CPU 和固件,同样还有在 TEE 内执行你的工作负载的框架。可以很好地说,“我不信任主机机器和它上面的软件栈,所以我打算使用 TEE,”但是如果你不够了解 TEE 软件环境,那你就是将一种软件不透明换成另外一种。TEEs 的开源支持将允许你或者社区(实际上是你与社区)以一种专有软件不可能实现的方式来检查和审计你所运行的程序。这就是为什么 CCC 位于 Linux 基金会旗下(这个基金会致力于开放式开发模型)并鼓励 TEE 相关的软件项目加入且成为开源项目(如果它们还没有成为开源)。 + +我认为,在过去的 15 到 20 年里,硬件可用、行业就绪和开放源码已成为推动技术改变的驱动力。区块链、人工智能、云计算、大规模计算webscale computing、大数据和互联网商务都是这三个点同时发挥作用的例子,并且在业界带来了巨大的改变。 + +在一般情况下,安全是我们这数十年来听到的一种承诺,并且其仍然未被实现。老实说,我不确定它未来会不会实现。但是随着新技术的到来,特定用例的安全变得越来越实用和无处不在,并且在业内受到越来越多的期待。这样看起来,机密计算似乎已准备好成为成为下一个重大变化 —— 而你,我亲爱的读者,可以一起来加入到这场革命(毕竟它是开源的)。 + +这篇文章最初是发布在 Alice, Eve, and Bob 上的,这是得到了作者许可的重发。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/confidential-computing + +作者:[Mike Bursell][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[wxy](https://github.com/wxy) + +本文由 [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/secure_https_url_browser.jpg?itok=OaPuqBkG (Secure https browser) +[2]: https://aliceevebob.com/2019/02/26/oh-how-i-love-my-tee-or-do-i/ +[3]: https://enarx.io/ +[4]: https://aliceevebob.com/2019/08/20/enarx-for-everyone-a-quest/ +[5]: https://aliceevebob.com/2019/10/29/enarx-goes-multi-platform/ +[6]: https://aliceevebob.com/2018/02/20/there-are-no-absolutes-in-security/ +[7]: https://confidentialcomputing.io/ +[8]: tmp.VEZpFGxsLv#1 +[9]: https://aliceevebob.com/2019/12/03/confidential-computing-the-new-https/ diff --git a/published/202002/20200112 What I learned going from prison to Python.md b/published/202002/20200112 What I learned going from prison to Python.md new file mode 100644 index 0000000000..283212f4b4 --- /dev/null +++ b/published/202002/20200112 What I learned going from prison to Python.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11893-1.html) +[#]: subject: (What I learned going from prison to Python) +[#]: via: (https://opensource.com/article/20/1/prison-to-python) +[#]: author: (Shadeed "Sha" Wallace-Stepter https://opensource.com/users/shastepter) + +从监狱到 Python +====== + +> 入狱后,开源编程是如何提供机会的。 + +![书架上的编程书籍][1] + +不到一年前,我还在圣昆廷州立监狱服刑,我是无期徒刑。 + +我高三的时候,我抢劫了一个人并向他开了枪。现在,我经过一段时间才意识到并承认自己做错了,这是在经历了陪审团审判并看到我的行为带来的恶果后,我知道需要改变自己,我也确实做到了。尽管我对我的行为表示懊悔,但我毕竟开枪打了一个人,并差点杀了他。做这样的事是有后果的,这是理所当然的。所以在我 18 岁的时候,我被判了终身监禁。 + +监狱是一个非常可怕的地方;我是不推荐你去的。但是我必须去,所以我去了。我不告诉你具体的细节,但你可以放心,这是一个没有太多动机去改变的地方,许多人在这里养成的坏习惯比他们过去在别处养成的更多。 + +我是幸运儿之一。当我在服刑的时候,发生了一些不同寻常的事情。我开始想象自己出狱后的的未来,虽然在这之前,我还是已经在那里度过了我整个成年生活。 + +现在你想想:我是黑人,只受过高中教育。我没有工作经历,如果我离开监狱,在被释放前,我还是一个被定罪的重罪犯。当每个雇主看到我的简历,都不会有“我需要雇用这个人”想法,我认为是正常的。 + +我不知道我的选择是什么,但我已经下定决心了。我需要做些活下去的事情,并且这和我入狱前的生活一点也不像。 + +### Python 之路 + +最终,我被关在了圣昆廷州立监狱,我不知道我为何幸运地被关在那里。圣昆廷提供了几个自助和教育编程项目。这些[改造机会][2]帮助囚犯使他们拥有在获释后避免再次犯罪的技能。 + +作为其中一个编程项目的一部分,2017 年我通过圣昆廷媒体项目认识了[杰西卡·麦凯拉][3]。杰西卡是编程语言 [Python][4] 的爱好者,她开始向我推荐 Python 有多棒,以及它是刚起步的人学习的完美语言。这就是故事变得比小说更精彩的地方。 + +> 感谢 [@northbaypython][5] 让 [@ShaStepter][6] 和我重复 [@pycon][7] 的主题演讲,让他们被录制下来。我很荣幸与大家分享: +> +> 从监狱到 Pythone: https://t.co/rcumoAgZHm +> +> 大规模裁员:如果我们不雇佣被判重罪的人,谁会呢? https://t.co/fENDUFdxfX +> +> [pic.Twitter.com/kpjo8d3ul6][8] +> +> —杰西卡·麦凯拉(@jessicamckellar)[2019 年 11 月 5 日][9] + +杰西卡向我介绍了一些 Python 视频教程,这些教程是她为一家名叫 [O’Reilly Media][10] 的公司做的,课程是在线的,如果我能接触到它们,那该有多好呀。不幸的是,在监狱里上网是不可能的。但是,我遇到了一个叫 Tim O’Reilly 的人,他最近刚来到圣昆廷。在他访问之后,Tim 从他的公司 O’Reilly Media 公司向监狱的编程班捐赠了大量内容。最终,我拿到了一款平板电脑,上面有杰西卡的 Python 教程,并学会了如何使用这些 Python 教程进行编码。 + +真是难以置信。背景和生活与我完全不同的陌生人把这些联系在一起,让我学会了编码。 + +### 对 Python 社区的热爱 + +在这之后,我开始经常和杰西卡见面,她开始告诉我关于开源社区的情况。我了解到,从根本上说,开源社区就是关于伙伴关系和协作的社区。之所以如此有效,是因为没有人被排除在外。 + +对我来说,一个努力寻找自己定位的人,我所看到的是一种非常基本的爱——通过合作和接受的爱,通过接触的爱,通过包容的爱。我渴望成为其中的一部分。所以我继续学习 Python,不幸的是,我无法获得更多的教程,但是我能够从开源社区收集的大量书面知识中获益。我读一切提到 Python 的东西,从平装本到晦涩难懂的杂志文章,我使用平板电脑来解决我读到的 Python 问题。 + +我对 Python 和编程的热情不是我的许多同龄人所共有的。除了监狱编程课上的极少数人之外,我认识的其他人都没有提到过编程;一般囚犯都不知道。我认为这是因为有过监禁经历的人无法接触编程,尤其是如果你是有色人种。 + +### 监狱外的 Python 生活 + +然而,在 2018 年 8 月 17 日,我得到了生命中的惊喜。时任州长的杰里·布朗将我 27 年的刑期减刑,在服刑将近 19 年后,我被释放出狱了。 + +但现实情况是,这也是为什么我认为编程和开源社区如此有价值。我是一名 37 岁的黑人罪犯,没有工作经历,刚刚在监狱服刑 18 年。我有犯罪史,并且现存偏见导致没有多少职业适合我。但是编程是少数例外之一。 + +现在,监禁后重返社会的人们迫切需要包容,但当谈及工作场所的多样性以及对多样性的需求时,你真的听不到这个群体被提及或包容。 + +> 还有什么: +> +> 1、背景调查:询问他们在你的公司是如何使用的。 +> +> 2、初级角色:删除虚假的、不必要的先决条件,这些条件将排除有记录的合格人员。 +> +> 3、积极拓展:与当地再就业项目合作,创建招聘渠道。 +> +> [pic.twitter.com/WnzdEUTuxr][11] +> +> —杰西卡·麦凯拉(@jessicamckellar)[2019 年 5 月 12 日][12] +  + +因此,我想谦卑地挑战开源社区的所有程序员和成员,让他们围绕包容和多样性展开思考。今天,我自豪地站在你们面前,代表一个大多数人都没有想到的群体——以前被监禁的人。但是我们存在,我们渴望证明我们的价值,最重要的是,我们期待被接受。当我们重返社会时,许多挑战等待着我们,我请求你们允许我们有机会展示我们的价值。欢迎我们,接受我们,最重要的是,包容我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/prison-to-python + +作者:[Shadeed "Sha" Wallace-Stepter][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shastepter +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_programming_languages.jpg?itok=KJcdnXM2 (Programming books on a shelf) +[2]: https://www.dailycal.org/2019/02/27/san-quentin-rehabilitation-programs-offer-inmates-education-a-voice/ +[3]: https://twitter.com/jessicamckellar?lang=en +[4]: https://www.python.org/ +[5]: https://twitter.com/northbaypython?ref_src=twsrc%5Etfw +[6]: https://twitter.com/ShaStepter?ref_src=twsrc%5Etfw +[7]: https://twitter.com/pycon?ref_src=twsrc%5Etfw +[8]: https://t.co/Kpjo8d3ul6 +[9]: https://twitter.com/jessicamckellar/status/1191601209917837312?ref_src=twsrc%5Etfw +[10]: http://shop.oreilly.com/product/110000448.do +[11]: https://t.co/WnzdEUTuxr +[12]: https://twitter.com/jessicamckellar/status/1127640222504636416?ref_src=twsrc%5Etfw diff --git a/published/202002/20200117 Use this Python script to find bugs in your Overcloud.md b/published/202002/20200117 Use this Python script to find bugs in your Overcloud.md new file mode 100644 index 0000000000..94428426e4 --- /dev/null +++ b/published/202002/20200117 Use this Python script to find bugs in your Overcloud.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11886-1.html) +[#]: subject: (Use this Python script to find bugs in your Overcloud) +[#]: via: (https://opensource.com/article/20/1/logtool-root-cause-identification) +[#]: author: (Arkady Shtempler https://opensource.com/users/ashtempl) + +用 Python 脚本发现 OpenStack Overcloud 中的问题 +====== + +> LogTool 是一组 Python 脚本,可帮助你找出 Overcloud 节点中问题的根本原因。 + +![](https://img.linux.net.cn/data/attachment/album/202002/12/211455woy57xx5q19cx175.jpg) + +OpenStack 在其 Overcloud 节点和 Undercloud 主机上存储和管理了一堆日志文件。因此,使用 OSP 日志文件来排查遇到的问题并不是一件容易的事,尤其在你甚至都不知道是什么原因导致问题时。 + +如果你正处于这种情况,那么 [LogTool][2] 可以使你的生活变得更加轻松!它会为你节省本需要人工排查问题所需的时间和精力。LogTool 基于模糊字符串匹配算法,可提供过去发生的所有唯一错误和警告信息。你可以根据日志中的时间戳导出特定时间段(例如 10 分钟前、一个小时前、一天前等)的这些信息。 + +LogTool 是一组 Python 脚本,其主要模块 `PyTool.py` 在 Undercloud 主机上执行。某些操作模式使用直接在 Overcloud 节点上执行的其他脚本,例如从 Overcloud 日志中导出错误和警告信息。 + +LogTool 支持 Python 2 和 Python 3,你可以根据需要更改工作目录:[LogTool_Python2][3] or [LogTool_Python3][4]。 + +### 操作方式 + +#### 1、从 Overcloud 日志中导出错误和警告信息 + +此模式用于从过去发生的 Overcloud 节点中提取 **错误** 和 **警告** 信息。作为用户,系统将提示你提供“开始时间”和“调试级别”,以用于提取错误或警告消息。例如,如果在过去 10 分钟内出了问题,你则可以只提取该时间段内的错误和警告消息。 + +此操作模式将为每个 Overcloud 节点生成一个包含结果文件的目录。结果文件是经过压缩的简单文本文件(`*.gz`),以减少从 Overcloud 节点下载所需的时间。将压缩文件转换为常规文本文件,可以使用 `zcat` 或类似工具。此外,Vi 的某些版本和 Emacs 的任何最新版本均支持读取压缩数据。结果文件分为几部分,并在底部包含目录。 + +LogTool 可以即时检测两种日志文件:标准和非标准。在标准文件中,每条日志行都有一个已知的和已定义的结构:时间戳、调试级别、信息等等。在非标准文件中,日志的结构未知。例如,它可能是第三方的日志。在目录中,你可以找到每个部分的“名称 --> 行号”例如: + + * **原始数据 - 从标准 OSP 日志中提取的错误/警告消息:** 这部分包含所有提取的错误/警告消息,没有任何修改或更改。这些消息是 LogTool 用于模糊匹配分析的原始数据。 + * **统计信息 - 每个标准 OSP 日志的错误/警告信息数量:** 在此部分,你将找到每个标准日志文件的错误和警告数量。这些信息可以帮助你了解用于排查问题根本原因的潜在组件。 + * **统计信息 - 每个标准 OSP 日志文件的唯一消息:** 这部分提供指定时间戳内的唯一的错误和警告消息。有关每个唯一错误或警告的更多详细信息,请在“原始数据”部分中查找相同的消息。 + * **统计信息 - 每个非标准日志文件在任意时间的唯一消息:** 此部分包含非标准日志文件中的唯一消息。遗憾的是,LogTool 无法像标准日志文件那样的处理方式处理这些日志文件。因此,在你提取“特定时间”的日志信息时会被忽略,你会看到过去创建的所有唯一的错误/警告消息。因此,首先,向下滚动到结果文件底部的目录并查看其部分-使用目录中的行索引跳到相关部分,其中第 3、4 和 5 行的信息最重要。 + +#### 2、从 Overcloud 节点下载所有日志 + +所有 Overcloud 节点的日志将被压缩并下载到 Undercloud 主机上的本地目录。 + +#### 3、所有 Overcloud 日志中搜索字符串 + +该模式“grep”(搜索)由用户在所有 Overcloud 日志上提供的字符串。例如,你可能希望查看特定请求的所有日志消息,例如,“Create VM”的失败的请求 ID。 + +#### 4、检查 Overcloud 上当前的 CPU、RAM 和磁盘使用情况 + +该模式显示每个 Overcloud 节点上的当前 CPU、RAM 和磁盘信息。 + +#### 5、执行用户脚本 + +该模式使用户可以在 Overcloud 节点上运行自己的脚本。例如,假设 Overcloud 部署失败,你就需要在每个控制器节点上执行相同的过程来修复该问题。你可以实现“替代方法”脚本,并使用此模式在控制器上运行它。 + +#### 6、仅按给定的时间戳下载相关日志 + +此模式仅下载 Overcloud 上 “给定的时间戳”的“上次修改时间”的日志。例如,如果 10 分钟前出现错误,则与旧日志文件就没有关系,因此无需下载。此外,你不能(或不应)在某些错误报告工具中附加大文件,因此此模式可能有助于编写错误报告。 + +#### 7、从 Undercloud 日志中导出错误和警告信息 + +这与上面的模式 1 相同。 + +#### 8、在 Overcloud 上检查不正常的 docker + +此模式用于在节点上搜索不正常的 Docker。 + +#### 9、下载 OSP 日志并在本地运行 LogTool + +此模式允许你从 Jenkins 或 Log Storage 下载 OSP 日志(例如,`cougar11.scl.lab.tlv.redhat.com`),并在本地分析。 + +#### 10、在 Undercloud 上分析部署日志 + +此模式可以帮助你了解 Overcloud 或 Undercloud 部署过程中出了什么问题。例如,在`overcloud_deploy.sh` 脚本中,使用 `--log` 选项时会生成部署日志;此类日志的问题是“不友好”,你很难理解是什么出了问题,尤其是当详细程度设置为 `vv` 或更高时,使得日志中的数据难以读取。此模式提供有关所有失败任务的详细信息。 + +#### 11、分析 Gerrit(Zuul)失败的日志 + +此模式用于分析 Gerrit(Zuul)日志文件。它会自动从远程 Gerrit 门下载所有文件(HTTP 下载)并在本地进行分析。 + +### 安装 + +GitHub 上有 LogTool,使用以下命令将其克隆到你的 Undercloud 主机: + +``` +git clone https://github.com/zahlabut/LogTool.git +``` + +该工具还使用了一些外部 Python 模块: + +#### Paramiko + +默认情况下,SSH 模块通常会安装在 Undercloud 上。使用以下命令来验证是否已安装: + +``` +ls -a /usr/lib/python2.7/site-packages | grep paramiko +``` + +如果需要安装模块,请在 Undercloud 上执行以下命令: + +``` +sudo easy_install pip +sudo pip install paramiko==2.1.1 +``` + +#### BeautifulSoup + +此 HTML 解析器模块仅在使用 HTTP 下载日志文件的模式下使用。它用于解析 Artifacts HTML 页面以获取其中的所有链接。安装 BeautifulSoup,请输入以下命令: + +``` +pip install beautifulsoup4 +``` + +你还可以通过执行以下命令使用 [requirements.txt][6] 文件安装所有必需的模块: + +``` +pip install -r requirements.txt +``` + +### 配置 + +所有必需的参数都直接在 `PyTool.py` 脚本中设置。默认值为: + +``` +overcloud_logs_dir = '/var/log/containers' +overcloud_ssh_user = 'heat-admin' +overcloud_ssh_key = '/home/stack/.ssh/id_rsa' +undercloud_logs_dir ='/var/log/containers' +source_rc_file_path='/home/stack/' +``` + +### 用法 + +此工具是交互式的,因此要启动它,只需输入: + +``` +cd LogTool +python PyTool.py +``` + +### 排除 LogTool 故障 + + +在运行时会创建两个日志文件:`Error.log` 和 `Runtime.log`。请在你要打开的问题的描述中添加两者的内容。 + +### 局限性 + +LogTool 进行硬编码以处理最大 500 MB 的文件。 + +### LogTool_Python3 脚本 + +在 [github.com/zahlabut/LogTool][2] 获取。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/logtool-root-cause-identification + +作者:[Arkady Shtempler][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/译者ID) +校对:[wxy](https://github.com/wxy) + + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ashtempl +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://github.com/zahlabut/LogTool +[3]: https://github.com/zahlabut/LogTool/tree/master/LogTool_Python2 +[4]: https://github.com/zahlabut/LogTool/tree/master/LogTool_Python3 +[5]: https://opensource.com/article/19/2/getting-started-cat-command +[6]: https://github.com/zahlabut/LogTool/blob/master/LogTool_Python3/requirements.txt diff --git a/published/202002/20200118 Keep a journal of your activities with this Python program.md b/published/202002/20200118 Keep a journal of your activities with this Python program.md new file mode 100644 index 0000000000..6426f86baa --- /dev/null +++ b/published/202002/20200118 Keep a journal of your activities with this Python program.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11846-1.html) +[#]: subject: (Keep a journal of your activities with this Python program) +[#]: via: (https://opensource.com/article/20/1/python-journal) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用这个 Python 程序记录你的活动 +====== + +> jrnl 可以创建可搜索、带时间戳、可导出、加密的(如果需要)的日常活动日志。在我们的 20 个使用开源提升生产力的系列的第八篇文章中了解更多。 + +![](https://img.linux.net.cn/data/attachment/album/202002/03/105455tx03zo2pu7woyusp.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 jrnl 记录日志 + +在我的公司,许多人会在下班之前在 Slack 上发送一个“一天结束”的状态。在有着许多项目和全球化的团队里,这是一个分享你已完成、未完成以及你需要哪些帮助的一个很好的方式。但有时候我太忙了,以至于我忘了做了什么。这时候就需要记录日志了。 + +![jrnl][2] + +打开一个文本编辑器并在你做一些事的时候添加一行很容易。但是在需要找出你在什么时候做的笔记,或者要快速提取相关的行时会有挑战。幸运的是,[jrnl][3] 可以提供帮助。 + +jrnl 能让你在命令行中快速输入条目、搜索过去的条目并导出为 HTML 和 Markdown 等富文本格式。你可以有多个日志,这意味着你可以将工作条目与私有条目分开。它将条目存储为纯文本,因此即使 jrnl 停止工作,数据也不会丢失。 + +由于 jrnl 是一个 Python 程序,最简单的安装方法是使用 `pip3 install jrnl`。这将确保你获得最新和最好的版本。第一次运行它会询问一些问题,接下来就能正常使用。 + +![jrnl's first run][4] + +现在,每当你需要做笔记或记录日志时,只需输入 `jrnl `,它将带有时间戳的记录保存到默认文件中。你可以使用 `jrnl -on YYYY-MM-DD` 搜索特定日期条目,`jrnl -from YYYY-MM-DD` 搜索在那日期之后的条目,以及用 `jrnl -to YYYY-MM-DD` 搜索到那日期的条目。搜索词可以与 `-and` 参数结合使用,允许像 `jrnl -from 2019-01-01 -and -to 2019-12-31` 这类搜索。 + +你还可以使用 `--edit` 标志编辑日志中的条目。开始之前,通过编辑文件 `~/.config/jrnl/jrnl.yaml` 来设置默认编辑器。你还可以指定日志使用什么文件、用于标签的特殊字符以及一些其他选项。现在,重要的是设置编辑器。我使用 Vim,jrnl 的文档中有一些使用其他编辑器如 VSCode 和 Sublime Text 的[有用提示][5]。 + +![Example jrnl config file][6] + +jrnl 还可以加密日志文件。通过设置全局 `encrypt` 变量,你将告诉 jrnl 加密你定义的所有日志。还可在配置文件中的针对文件设置 `encrypt: true` 来加密文件。 + +``` +journals: +  default: ~/journals/journal.txt +  work: ~/journals/work.txt +  private: +    journal: ~/journals/private.txt +    encrypt: true +``` + +如果日志尚未加密,系统将提示你输入在对它进行任何操作的密码。日志文件将加密保存在磁盘上,以免受窥探。[jrnl 文档][7] 中包含其工作原理、使用哪些加密方式等的更多信息。 + +![Encrypted jrnl file][8] + +日志记录帮助我记住什么时候做了什么事,并在我需要的时候能够找到它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/python-journal + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/notebook-writing-pen.jpg?itok=uA3dCfu_ (Writing in a notebook) +[2]: https://opensource.com/sites/default/files/uploads/productivity_8-1.png (jrnl) +[3]: https://jrnl.sh/ +[4]: https://opensource.com/sites/default/files/uploads/productivity_8-2.png (jrnl's first run) +[5]: https://jrnl.sh/recipes/#external-editors +[6]: https://opensource.com/sites/default/files/uploads/productivity_8-3.png (Example jrnl config file) +[7]: https://jrnl.sh/encryption/ +[8]: https://opensource.com/sites/default/files/uploads/productivity_8-4.png (Encrypted jrnl file) diff --git a/published/202002/20200119 How to Set or Change Timezone in Ubuntu Linux -Beginner-s Tip.md b/published/202002/20200119 How to Set or Change Timezone in Ubuntu Linux -Beginner-s Tip.md new file mode 100644 index 0000000000..5395a64b6e --- /dev/null +++ b/published/202002/20200119 How to Set or Change Timezone in Ubuntu Linux -Beginner-s Tip.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11838-1.html) +[#]: subject: (How to Set or Change Timezone in Ubuntu Linux [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/change-timezone-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu Linux 中设置或更改时区 +====== + +[你安装 Ubuntu 时][1],它会要求你设置时区。如果你选择一个错误的时区,或者你移动到世界的一些其它地方,你可以很容易地在以后更改它。 + +### 如何在 Ubuntu 和其它 Linux 发行版中更改时区 + +这里有两种方法来更改 Ubuntu 中的时区。你可以使用图形化设置或在终端中使用 `timedatectl` 命令。你也可以直接更改 `/etc/timezone` 文件,但是我不建议这样做。 + +在这篇初学者教程中,我将向你展示图形化和终端两种方法: + + * [通过 GUI 更改 Ubuntu 中的时区][2] (适合桌面用户) + * [通过命令行更改 Ubuntu 中的时区][3] (桌面和服务器都工作) + +![][4] + +#### 方法 1: 通过终端更改 Ubuntu 时区 + +[Ubuntu][5] 或一些使用 systemd 的其它发行版可以在 Linux 终端中使用 `timedatectl` 命令来设置时区。 + +你可以使用没有任何参数的 `timedatectl` 命令来检查当前是日期和时区设置: + +``` +[email protected]:~$ timedatectl + Local time: Sat 2020-01-18 17:39:52 IST + Universal time: Sat 2020-01-18 12:09:52 UTC + RTC time: Sat 2020-01-18 12:09:52 + Time zone: Asia/Kolkata (IST, +0530) + System clock synchronized: yes +systemd-timesyncd.service active: yes + RTC in local TZ: no +``` + +正如你在上面的输出中所看,我的系统使用 Asia/Kolkata 。它也告诉我现在比世界时早 5 小时 30 分钟。 + +为在 Linux 中设置时区,你需要知道准确的时区。你必需使用时区的正确的格式 (时区格式是洲/城市)。 + +为获取时区列表,使用 `timedatectl` 命令的 `list-timezones` 参数: + +``` +timedatectl list-timezones +``` + +它将向你显示大量可用的时区列表。 + +![Timezones List][6] + +你可以使用向上箭头和向下箭头或 `PgUp` 和 `PgDown` 键来在页面之间移动。 + +你也可以 `grep` 输出,并搜索你的时区。例如,假如你正在寻找欧洲的时区,你可以使用: + +``` +timedatectl list-timezones | grep -i europe +``` + +比方说,你想设置时区为巴黎。在这里,使用的时区值的 Europe/Paris : + +``` +timedatectl set-timezone Europe/Paris +``` + +它虽然不显示任何成功信息,但是时区会立即更改。你不需要重新启动或注销。 + +记住,虽然你不需要成为 root 用户并对命令使用 `sudo`,但是你的账户仍然需要拥有管理器权限来更改时区。 + +你可以使用 [date 命令][7] 来验证更改的时间好时区: + +``` +[email protected]:~$ date +Sat Jan 18 13:56:26 CET 2020 +``` + +#### 方法 2: 通过 GUI 更改 Ubuntu 时区 + +按下 `super` 键 (Windows 键) ,并搜索设置: + +![Applications Menu Settings][8] + +在左侧边栏中,向下滚动一点,查看详细信息: + +![Go to Settings -> Details][9] + +在详细信息中,你将在左侧边栏中找到“日期和时间”。在这里,你应该关闭自动时区选项(如果它已经被启用),然后在时区上单击: + +![In Details -> Date & Time, turn off the Automatic Time Zone][10] + +当你单击时区时,它将打开一个交互式地图,你可以在你选择的地理位置上单击,关闭窗口。 + +![Select a timezone][11] + +在选择新的时区后,除了关闭这个地图后,你不必做任何事情。不需要注销或 [关闭 Ubuntu][12]。 + +我希望这篇快速教程能帮助你在 Ubuntu 和其它 Linux 发行版中更改时区。如果你有问题或建议,请告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/change-timezone-ubuntu/ + +作者:[Abhishek Prakash][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/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/install-ubuntu/ +[2]: tmp.bHvVztzy6d#change-timezone-gui +[3]: tmp.bHvVztzy6d#change-timezone-command-line +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/Ubuntu_Change-_Time_Zone.png?ssl=1 +[5]: https://ubuntu.com/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/timezones_in_ubuntu.jpg?ssl=1 +[7]: https://linuxhandbook.com/date-command/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/applications_menu_settings.jpg?ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/settings_detail_ubuntu.jpg?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/change_timezone_in_ubuntu.jpg?ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/change_timezone_in_ubuntu_2.jpg?ssl=1 +[12]: https://itsfoss.com/schedule-shutdown-ubuntu/ diff --git a/published/202002/20200119 One open source chat tool to rule them all.md b/published/202002/20200119 One open source chat tool to rule them all.md new file mode 100644 index 0000000000..1d2240f8f7 --- /dev/null +++ b/published/202002/20200119 One open source chat tool to rule them all.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11856-1.html) +[#]: subject: (One open source chat tool to rule them all) +[#]: via: (https://opensource.com/article/20/1/open-source-chat-tool) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +一个通过 IRC 管理所有聊天的开源聊天工具 +====== + +> BitlBee 将多个聊天应用集合到一个界面中。在我们的 20 个使用开源提升生产力的系列的第九篇文章中了解如何设置和使用 BitlBee。 + +![](https://img.linux.net.cn/data/attachment/album/202002/05/123636dw8uw34mbkqzmw84.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 将所有聊天都放到 BitlBee 中 + +即时消息和聊天已经成为网络世界的主要内容。如果你像我一样,你可能打开五六个不同的应用与你的朋友、同事和其他人交谈。关注所有聊天真的很痛苦。谢天谢地,你可以使用一个应用(好吧,是两个)将这些聊天整个到一个地方。 + +![BitlBee on XChat][2] + +[BitlBee][3] 是作为服务运行的应用,它可以将标准的 IRC 客户端与大量的消息服务进行桥接。而且,由于它本质上是 IRC 服务器,因此你可以选择很多客户端。 + +BitlBee 几乎包含在所有 Linux 发行版中。在 Ubuntu 上安装(我选择的 Linux 桌面),类似这样: + +``` +sudo apt install bitlbee-libpurple +``` + +在其他发行版上,包名可能略有不同,但搜索 “bitlbee” 应该就能看到。 + +你会注意到我用的 libpurple 版的 BitlBee。这个版本能让我使用 [libpurple][4] 即时消息库中提供的所有协议,该库最初是为 [Pidgin][5] 开发的。 + +安装完成后,服务应会自动启动。现在,使用一个 IRC 客户端(图片中为 [XChat][6]),我可以连接到端口 6667(标准 IRC 端口)上的服务。 + +![Initial BitlBee connection][7] + +你将自动连接到控制频道 &bitlbee。此频道对于你是独一无二的,在多用户系统上每个人都有一个自己的。在这里你可以配置该服务。 + +在控制频道中输入 `help`,你可以随时获得完整的文档。浏览它,然后使用 `register` 命令在服务器上注册帐户。 + +``` +register +``` + +现在,你在服务器上所做的任何配置更改(IM 帐户、设置等)都将在输入 `save` 时保存。每当你连接时,使用 `identify ` 连接到你的帐户并加载这些设置。 + +![purple settings][8] + +命令 `help purple` 将显示 libpurple 提供的所有可用协议。例如,我安装了 [telegram-purple][9] 包,它增加了连接到 Telegram 的能力。我可以使用 `account add` 命令将我的电话号码作为帐户添加。 + +``` +account add telegram +15555555 +``` + +BitlBee 将显示它已添加帐户。你可以使用 `account list` 列出你的帐户。因为我只有一个帐户,我可以通过 `account 0 on` 登录,它会进行 Telegram 登录,列出我所有的朋友和聊天,接下来就能正常聊天了。 + +但是,对于 Slack 这个最常见的聊天系统之一呢?你可以安装 [slack-libpurple][10] 插件,并且对 Slack 执行同样的操作。如果你不愿意编译和安装这些,这可能不适合你。 + +按照插件页面上的说明操作,安装后重新启动 BitlBee 服务。现在,当你运行 `help purple` 时,应该会列出 Slack。像其他协议一样添加一个 Slack 帐户。 + +``` +account add slack ksonney@myslack.slack.com +account 1 set password my_legcay_API_token +account 1 on +``` + +你知道么,你已经连接到 Slack 中,你可以通过 `chat add` 命令添加你感兴趣的 Slack 频道。比如: + +``` +chat add 1 happyparty +``` + +将 Slack 频道 happyparty 添加为本地频道 #happyparty。现在可以使用标准 IRC `/join` 命令访问该频道。这很酷。 + +BitlBee 和 IRC 客户端帮助我的(大部分)聊天和即时消息保存在一个地方,并减少了我的分心,因为我不再需要查找并切换到任何一个刚刚找我的应用上。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-chat-tool + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://opensource.com/sites/default/files/uploads/productivity_9-1.png (BitlBee on XChat) +[3]: https://www.bitlbee.org/ +[4]: https://developer.pidgin.im/wiki/WhatIsLibpurple +[5]: http://pidgin.im/ +[6]: http://xchat.org/ +[7]: https://opensource.com/sites/default/files/uploads/productivity_9-2.png (Initial BitlBee connection) +[8]: https://opensource.com/sites/default/files/uploads/productivity_9-3.png (purple settings) +[9]: https://github.com/majn/telegram-purple +[10]: https://github.com/dylex/slack-libpurple +[11]: mailto:ksonney@myslack.slack.com diff --git a/published/202002/20200120 Use this Twitter client for Linux to tweet from the terminal.md b/published/202002/20200120 Use this Twitter client for Linux to tweet from the terminal.md new file mode 100644 index 0000000000..6a6bf89b13 --- /dev/null +++ b/published/202002/20200120 Use this Twitter client for Linux to tweet from the terminal.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11858-1.html) +[#]: subject: (Use this Twitter client for Linux to tweet from the terminal) +[#]: via: (https://opensource.com/article/20/1/tweet-terminal-rainbow-stream) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用这个 Twitter 客户端在 Linux 终端中发推特 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十篇文章中,使用 Rainbow Stream 跟上你的 Twitter 流而无需离开终端。 + +![](https://img.linux.net.cn/data/attachment/album/202002/06/113720bwi55j7xcccwwwi0.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 通过 Rainbow Stream 跟上Twitter + +我喜欢社交网络和微博。它快速、简单,还有我可以与世界分享我的想法。当然,缺点是几乎所有非 Windows 的桌面客户端都对是网站的封装。[Twitter][2] 有很多客户端,但我真正想要的是轻量、易于使用,最重要的是吸引人的客户端。 + +![Rainbow Stream for Twitter][3] + +[Rainbow Stream][4] 是好看的 Twitter 客户端之一。它简单易用,并且可以通过 `pip3 install rainbowstream` 快速安装。第一次运行时,它将打开浏览器窗口,并让你通过 Twitter 授权。完成后,你将回到命令行,你的 Twitter 时间线将开始滚动。 + +![Rainbow Stream first run][5] + +要了解的最重要的命令是 `p` 暂停推流、`r` 继续推流、`h` 得到帮助,以及 `t` 发布新的推文。例如,`h tweets` 将提供发送和回复推文的所有选项。另一个有用的帮助页面是 `h messages`,它提供了处理直接消息的命令,这是我妻子和我经常使用的东西。还有很多其他命令,我会回头获得很多帮助。 + +随着时间线的滚动,你可以看到它有完整的 UTF-8 支持,并以正确的字体显示推文被转推以及喜欢的次数,图标和 emoji 也能正确显示。 + +![Kill this love][6] + +关于 Rainbow Stream 的*最好*功能之一就是你不必放弃照片和图像。默认情况下,此功能是关闭的,但是你可以使用 `config` 命令尝试它。 + +``` +config IMAGE_ON_TERM = true +``` + +此命令将任何图像渲染为 ASCII 艺术。如果你有大量照片流,它可能会有点多,但是我喜欢。它有非常复古的 1990 年代 BBS 感觉,我也确实喜欢 1990 年代的 BBS 场景。 + +你还可以使用 Rainbow Stream 管理列表、屏蔽某人、拉黑某人、关注、取消关注以及 Twitter API 的所有其他功能。它还支持主题,因此你可以用喜欢的颜色方案自定义流。 + +当我正在工作并且不想在浏览器上打开另一个选项卡时,Rainbow Stream 让我可以留在终端中。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/tweet-terminal-rainbow-stream + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/talk_chat_communication_team.png?itok=CYfZ_gE7 (Chat bubbles) +[2]: https://twitter.com/home +[3]: https://opensource.com/sites/default/files/uploads/productivity_10-1.png (Rainbow Stream for Twitter) +[4]: https://rainbowstream.readthedocs.io/en/latest/ +[5]: https://opensource.com/sites/default/files/uploads/productivity_10-2.png (Rainbow Stream first run) +[6]: https://opensource.com/sites/default/files/uploads/day10-image3_1.png (Kill this love) diff --git a/published/202002/20200121 Read Reddit from the Linux terminal.md b/published/202002/20200121 Read Reddit from the Linux terminal.md new file mode 100644 index 0000000000..2910769f83 --- /dev/null +++ b/published/202002/20200121 Read Reddit from the Linux terminal.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11869-1.html) +[#]: subject: (Read Reddit from the Linux terminal) +[#]: via: (https://opensource.com/article/20/1/open-source-reddit-client) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +在 Linux 终端中阅读 Reddit +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十一篇文章中使用 Reddit 客户端 Tuir 在工作中短暂休息一下。 + +![](https://img.linux.net.cn/data/attachment/album/202002/09/104113w1ytjmlv1jly0j1t.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Tuir 阅读 Reddit + +短暂休息对于保持生产力很重要。我休息时喜欢去的地方之一是 [Reddit][2],如果你愿意,这可能是一个很好的资源。我在那里发现了各种有关 DevOps、生产力、Emacs、鸡和 ChromeOS 项目的文章。这些讨论可能很有价值。我还关注了一些只有动物图片的子板,因为我喜欢动物(而不只是鸡)照片,有时经过长时间的工作后,我真正需要的是小猫照片。 + +![/r/emacs in Tuir][3] + +当我阅读 Reddit(不仅仅是看动物宝宝的图片)时,我使用 [Tuir][4](Reddit 终端 UI)。Tuir 是功能齐全的 Reddit 客户端,可以在运行 Python 的任何系统上运行。安装是通过 `pip` 完成的,非常简单。 + +首次运行时,Tuir 会进入 Reddit 默认文章列表。屏幕的顶部和底部有列出不同命令的栏。顶部栏显示你在 Reddit 上的位置,第二行显示根据 Reddit “Hot/New/Controversial” 等类别筛选的命令。按下筛选器前面的数字触发筛选。 + +![Filtering by Reddit's "top" category][5] + +你可以使用箭头键或 `j`、`k`、`h` 和 `l` 键浏览列表,这与 Vi/Vim 使用的键相同。底部栏有用于应用导航的命令。如果要跳转到另一个子板,只需按 `/` 键打开提示,然后输入你要进入的子板名称。 + +![Logging in][6] + +某些东西除非你登录,否则无法访问。如果你尝试执行需要登录的操作,那么 Tuir 就会提示你,例如发布新文章 (`c`)或赞成/反对 (`a` 和 `z`)。要登录,请按 `u` 键。这将打开浏览器以通过 OAuth2 登录,Tuir 将保存令牌。之后,你的用户名应出现在屏幕的右上方。 + +Tuir 还可以打开浏览器来查看图像、加载链接等。稍作调整,它甚至可以在终端中显示图像(尽管我没有让它可以正常工作)。 + +总的来说,我对 Tuir 在我需要休息时能快速跟上 Reddit 感到很满意。 + +Tuir 是现已淘汰的 [RTV][7] 的两个分叉之一。另一个是 [TTRV][8],它还无法通过 `pip` 安装,但功能相同。我期待看到它们随着时间的推移脱颖而出。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-reddit-client + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://www.reddit.com/ +[3]: https://opensource.com/sites/default/files/uploads/productivity_11-1.png (/r/emacs in Tuir) +[4]: https://gitlab.com/ajak/tuir +[5]: https://opensource.com/sites/default/files/uploads/productivity_11-2.png (Filtering by Reddit's "top" category) +[6]: https://opensource.com/sites/default/files/uploads/productivity_11-3.png (Logging in) +[7]: https://github.com/michael-lazar/rtv +[8]: https://github.com/tildeclub/ttrv diff --git a/published/202002/20200122 Get your RSS feeds and podcasts in one place with this open source tool.md b/published/202002/20200122 Get your RSS feeds and podcasts in one place with this open source tool.md new file mode 100644 index 0000000000..ec53804d3a --- /dev/null +++ b/published/202002/20200122 Get your RSS feeds and podcasts in one place with this open source tool.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11876-1.html) +[#]: subject: (Get your RSS feeds and podcasts in one place with this open source tool) +[#]: via: (https://opensource.com/article/20/1/open-source-rss-feed-reader) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用此开源工具在一起收取你的 RSS 订阅源和播客 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十二篇文章中使用 Newsboat 收取你的新闻 RSS 源和播客。 + +![](https://img.linux.net.cn/data/attachment/album/202002/10/162526wv5jdl0m12sw10md.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Newsboat 访问你的 RSS 源和播客 + +RSS 新闻源是了解各个网站最新消息的非常方便的方法。除了 Opensource.com,我还会关注 [SysAdvent][2] sysadmin 年度工具,还有一些我最喜欢的作者以及一些网络漫画。RSS 阅读器可以让我“批处理”阅读内容,因此,我每天不会在不同的网站上花费很多时间。 + +![Newsboat][3] + +[Newsboat][4] 是一个基于终端的 RSS 订阅源阅读器,外观感觉很像电子邮件程序 [Mutt][5]。它使阅读新闻变得容易,并有许多不错的功能。 + +安装 Newsboat 非常容易,因为它包含在大多数发行版(以及 MacOS 上的 Homebrew)中。安装后,只需在 `~/.newsboat/urls` 中添加订阅源。如果你是从其他阅读器迁移而来,并有导出的 OPML 文件,那么可以使用以下方式导入: + +``` +newsboat -i +``` + +添加订阅源后,Newsboat 的界面非常熟悉,特别是如果你使用过 Mutt。你可以使用箭头键上下滚动,使用 `r` 检查某个源中是否有新项目,使用 `R` 检查所有源中是否有新项目,按回车打开订阅源,并选择要阅读的文章。 + +![Newsboat article list][6] + +但是,你不仅限于本地 URL 列表。Newsboat 还是 [Tiny Tiny RSS][7]、ownCloud 和 Nextcloud News 等新闻阅读服务以及一些 Google Reader 后续产品的客户端。[Newsboat 的文档][8]中涵盖了有关此的详细信息以及其他许多配置选项。 + +![Reading an article in Newsboat][9] + +#### 播客 + +Newsboat 还通过 Podboat 提供了[播客支持][10],Podboat 是一个附带的应用,它可帮助下载和排队播客节目。在 Newsboat 中查看播客源时,按下 `e` 将节目添加到你的下载队列中。所有信息将保存在 `~/.newsboat` 目录中的队列文件中。Podboat 读取此队列并将节目下载到本地磁盘。你可以在 Podboat 的用户界面(外观和行为类似于 Newsboat)执行此操作,也可以使用 `podboat -a` 让 Podboat 下载所有内容。作为播客人和播客听众,我认为这*真的*很方便。 + +![Podboat][11] + +总体而言,Newsboat 有一些非常好的功能,并且是一些基于 Web 或桌面应用的不错的轻量级替代方案。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-rss-feed-reader + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ship_captain_devops_kubernetes_steer.png?itok=LAHfIpek (Ship captain sailing the Kubernetes seas) +[2]: https://sysadvent.blogspot.com/ +[3]: https://opensource.com/sites/default/files/uploads/productivity_12-1.png (Newsboat) +[4]: https://newsboat.org +[5]: http://mutt.org/ +[6]: https://opensource.com/sites/default/files/uploads/productivity_12-2.png (Newsboat article list) +[7]: https://tt-rss.org/ +[8]: https://newsboat.org/releases/2.18/docs/newsboat.html +[9]: https://opensource.com/sites/default/files/uploads/productivity_12-3.png (Reading an article in Newsboat) +[10]: https://newsboat.org/releases/2.18/docs/newsboat.html#_podcast_support +[11]: https://opensource.com/sites/default/files/uploads/productivity_12-4.png (Podboat) diff --git a/published/202002/20200122 Screenshot your Linux system configuration with Bash tools.md b/published/202002/20200122 Screenshot your Linux system configuration with Bash tools.md new file mode 100644 index 0000000000..e8507162f9 --- /dev/null +++ b/published/202002/20200122 Screenshot your Linux system configuration with Bash tools.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11920-1.html) +[#]: subject: (Screenshot your Linux system configuration with Bash tools) +[#]: via: (https://opensource.com/article/20/1/screenfetch-neofetch) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +使用 Bash 工具截屏 Linux 系统配置 +====== + +> 使用 ScreenFetch 和 Neofetch 与其他人轻松分享你的 Linux 环境。 + +![](https://img.linux.net.cn/data/attachment/album/202002/23/124525yiiqs18ll736oro8.jpg) + +你可能有很多原因想要与他人分享你的 Linux 配置。你可能正在寻求帮助来对系统上的问题进行故障排除,或者你对所创建的环境感到非常自豪,因此想向其他开源爱好者展示。 + +你可以在 Bash 提示符下使用 `cat /proc/cpuinfo` 或 `lscpu` 命令获取某些信息。但是,如果你想共享更多详细信息,例如你的操作系统、内核、运行时间、shell 环境,屏幕分辨率等,那么可以选择两个很棒的工具:screenFetch 和 Neofetch。 + +### screenFetch + +[screenFetch][2] 是 Bash 命令行程序,它可以产生非常漂亮的系统配置和运行时间的截图。这是方便的与它人共享系统配置的方法。 + +在许多 Linux 发行版上安装 screenFetch 很简单。 + +在 Fedora 上,输入: + +``` +$ sudo dnf install screenfetch +``` + +在 Ubuntu 上,输入: + +``` +$ sudo apt install screenfetch +``` + +对于其他操作系统,包括 FreeBSD、MacOS 等,请查阅 screenFetch 的 wiki [安装页面][3]。安装 screenFetch 后,它可以生成详细而彩色的截图,如下所示: + +![screenFetch][4] + +ScreenFetch 还提供各种命令行选项来调整你的结果。例如,`screenfetch -v` 返回详细输出,逐行显示每个选项以及上面的显示。 + +`screenfetch -n` 在显示系统信息时消除了操作系统图标。 + +![screenfetch -n option][5] + +其他选项包括 `screenfetch -N`,它去除所有输出的颜色。`screenfetch -t`,它根据终端的大小截断输出。`screenFetch -E`,它可抑制错误输出。 + +请检查手册页来了解其他选项。screenFetch 在 GPLv3 许可证下的开源,你可以在它的 [GitHub 仓库][6]中了解有关该项目的更多信息。 + +### Neofetch + +[Neofetch][7] 是创建系统信息截图的另一个工具。它是用 Bash 3.2 编写的,在 [MIT 许可证][8]下开源。 + +根据项目网站所述,“Neofetch 支持近 150 种不同的操作系统。从 Linux 到 Windows,一直到 Minix、AIX 和 Haiku 等更晦涩的操作系统。” + +![Neofetch][9] + +该项目维护了一个 wiki,其中包含用于各种发行版和操作系统的出色的[安装文档][10]。 + +如果你使用的是 Fedora、RHEL 或 CentOS,那么可以在 Bash 提示符下使用以下命令安装 Neofetch: + +``` +$ sudo dnf install neofetch +``` + +在 Ubuntu 17.10 及更高版本上,你可以使用: + +``` +$ sudo apt install neofetch +``` + +首次运行时,Neofetch 将 `~/.config/neofetch/config.conf` 文件写入主目录(`.config/config.conf`),它让你可以[自定义和控制][11] Neofetch 输出的各个方面。例如,你可以配置 Neofetch 使用图像、ASCII 文件、你选择的壁纸,或者完全不使用。config.conf 文件还让与它人分享配置变得容易。 + +如果 Neofetch 不支持你的操作系统或不提供所需选项,请在项目的 [GitHub 仓库][12]中打开一个问题。 + +### 总结 + +无论为什么要共享系统配置,screenFetch 或 Neofetch 都应该能做到。你是否知道在 Linux 上提供此功能的另一个开源工具?请在评论中分享你的最爱。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/screenfetch-neofetch + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://github.com/KittyKatt/screenFetch +[3]: https://github.com/KittyKatt/screenFetch/wiki/Installation +[4]: https://opensource.com/sites/default/files/uploads/screenfetch.png (screenFetch) +[5]: https://opensource.com/sites/default/files/uploads/screenfetch-n.png (screenfetch -n option) +[6]: http://github.com/KittyKatt/screenFetch +[7]: https://github.com/dylanaraps/neofetch +[8]: https://github.com/dylanaraps/neofetch/blob/master/LICENSE.md +[9]: https://opensource.com/sites/default/files/uploads/neofetch.png (Neofetch) +[10]: https://github.com/dylanaraps/neofetch/wiki/Installation +[11]: https://github.com/dylanaraps/neofetch/wiki/Customizing-Info +[12]: https://github.com/dylanaraps/neofetch/issues diff --git a/published/202002/20200123 How to stop typosquatting attacks.md b/published/202002/20200123 How to stop typosquatting attacks.md new file mode 100644 index 0000000000..728bf29f50 --- /dev/null +++ b/published/202002/20200123 How to stop typosquatting attacks.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11899-1.html) +[#]: subject: (How to stop typosquatting attacks) +[#]: via: (https://opensource.com/article/20/1/stop-typosquatting-attacks) +[#]: author: (Sam Bocetta https://opensource.com/users/sambocetta) + +如何防范误植攻击 +====== + +> 误植Typosquatting是一种引诱用户将敏感数据泄露给不法分子的方式,针对这种攻击方式,我们很有必要了解如何保护我们的组织、我们的开源项目以及我们自己。 + +![Gears above purple clouds][1] + +除了常规手段以外,网络罪犯还会利用社会工程的方式,试图让安全意识较弱的人泄露私人信息或是有价值的证书。很多[网络钓鱼骗局][2]的实质都是攻击者伪装成信誉良好的公司或组织,然后借此大规模传播病毒或恶意软件。 + +[误植][3]Typosquatting就是其中一个常用的手法。它是一种社会工程学的攻击方式,通过使用一些合法网站的错误拼写的 URL 以引诱用户访问恶意网站,这样的做法既使真正的原网站遭受声誉上的损害,又诱使用户向这些恶意网站提交个人敏感信息。因此,网站的管理人员和用户双方都应该意识到这个问题带来的风险,并采取措施加以保护。 + +一些由广大开发者在公共代码库中维护的开源软件通常都被认为具有安全上的优势,但当面临社会工程学攻击或恶意软件植入时,开源软件也需要注意以免受到伤害。 + +下面就来关注一下误植攻击的发展趋势,以及这种攻击方式在未来可能对开源软件造成的影响。 + +### 什么是误植? + +误植是一种非常特殊的网络犯罪形式,其背后通常是一个更大的网络钓鱼骗局。不法分子首先会购买和注册域名,而他们注册的域名通常是一个常用网站的错误拼写形式,例如在正确拼写的基础上添加一个额外的元音字母,又或者是将字母“i”替换成字母“l”。对于同一个正常域名,不法分子通常会注册数十个拼写错误的变体域名。 + +用户一旦访问这样的域名,不法分子的目的就已经成功了一半。为此,他们会通过电子邮件的方式,诱导用户访问这样的伪造域名。伪造域名指向的页面中,通常都带有一个简单的登录界面,还会附上熟悉的被模仿网站的徽标,尽可能让用户认为自己访问的是真实的网站。 + +如果用户没有识破这一个骗局,在页面中提交了诸如银行卡号、用户名、密码等敏感信息,这些数据就会被不法分子所完全掌控。进一步来看,如果这个用户在其它网站也使用了相同的用户名和密码,那就有同样受到波及的风险。受害者最终可能会面临身份被盗、信用记录被破坏等危险。 + +### 最近的一些案例 + +从网站的所有方来看,遭到误植攻击可能会带来一场公关危机。尽管网站域名的所有者没有参与到犯罪当中,但这会被认为是一次管理上的失职,因为域名所有者有主动防御误植攻击的责任,以避免这一类欺诈事件的发生。 + +在几年之前就发生过[一起案件][4],很多健康保险客户收到了一封指向 we11point.com 的钓鱼电子邮件,其中 URL 里正确的字母“l”被换成了数字“1”,从而导致一批用户成为了这一次攻击的受害者。 + +最初,与特定国家/地区相关的顶级域名是不允许随意注册的。但后来国际域名规则中放开这一限制之后,又兴起了一波新的误植攻击。例如最常见的一种手法就是注册一个与 .com 域名类似的 .om 域名,一旦在输入 URL 时不慎遗漏了字母 c 就会给不法分子带来可乘之机。 + +### 网站如何防范误植攻击 + +对于一个公司来说,最好的策略就是永远比误植攻击采取早一步的行动。 + +也就是说,在注册域名的时候,不仅要注册自己商标名称的域名,最好还要同时注册可能由于拼写错误产生的其它域名。当然,没有太大必要把可能导致错误的所有顶级域名都注册掉,但至少要把可能导致错误的一些一级域名抢注下来。 + +如果你有让用户跳转到一个第三方网站的需求,务必要让用户从你的官方网站上进行跳转,而不应该通过类似群发邮件的方式向用户告知 URL。因此,必须明确一个策略:在与用户通信交流时,不将用户引导到官方网站以外的地方去。在这样的情况下,如果有不法分子试图以你公司的名义发布虚假消息,用户将会从带有异样的页面或 URL 上有所察觉。 + +你可以使用类似 [DNS Twist][5] 的开源工具来扫描公司正在使用的域名,它可以确定是否有相似的域名已被注册,从而暴露潜在的误植攻击。DNS Twist 可以在 Linux 系统上通过一系列的 shell 命令来运行。 + +还有一些网络提供商(ISP)会将防护误植攻击作为他们网络产品的一部分。这就相当于一层额外的保护,如果用户不慎输入了带有拼写错误的 URL,就会被提示该页面已经被阻止并重定向到正确的域名。 + +如果你是系统管理员,还可以考虑运行一个自建的 [DNS 服务器][6],以便通过黑名单的机制禁止对某些域名的访问。 + +你还可以密切监控网站的访问流量,如果来自某个特定地区的用户被集体重定向到了虚假的站点,那么访问量将会发生骤降。这也是一个有效监控误植攻击的角度。 + +防范误植攻击与防范其它网络攻击一样需要保持警惕。所有用户都希望网站的所有者能够扫除那些与正主类似的假冒站点,如果这项工作没有做好,用户的信任对你的信任程度就会每况愈下。 + +### 误植对开源软件的影响 + +因为开源项目的源代码是公开的,所以其中大部分项目都会进行安全和渗透测试。但错误是不可能完全避免的,如果你参与了开源项目,还是有需要注意的地方。 + +当你收到一个不明来源的合并请求Merge Request或补丁时,必须在合并之前仔细检查,尤其是相关代码涉及到网络层面的时候。不要屈服于只测试构建的诱惑; 一定要进行严格的检查和测试,以确保没有恶意代码混入正常的代码当中。 + +同时,还要严格按照正确的方法使用域名,避免不法分子创建仿冒的下载站点并提供带有恶意代码的软件。可以通过如下所示的方法使用数字签名来确保你的软件没有被篡改: + +``` +gpg --armor --detach-sig \ + --output advent-gnome.sig \ + example-0.0.1.tar.xz +``` + +同时给出你提供的文件的校验和: + +``` +sha256sum example-0.0.1.tar.xz > example-0.0.1.txt +``` + +无论你的用户会不会去用上这些安全措施,你也应该提供这些必要的信息。因为只要有那么一个人留意到签名有异样,就能为你敲响警钟。 + +### 总结 + +人类犯错在所难免。世界上数百万人输入同一个网址时,总会有人出现拼写的错误。不法分子也正是抓住了这个漏洞才得以实施误植攻击。 + +用抢注域名的方式去完全根治误植攻击也是不太现实的,我们更应该关注这种攻击的传播方式以减轻它对我们的影响。最好的保护就是和用户之间建立信任,并积极检测误植攻击的潜在风险。作为开源社区,我们更应该团结起来一起应对误植攻击。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/stop-typosquatting-attacks + +作者:[Sam Bocetta][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sambocetta +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chaos_engineer_monster_scary_devops_gear_kubernetes.png?itok=GPYLvfVh (Gears above purple clouds) +[2]: https://www.cloudberrylab.com/resources/guides/types-of-phishing/ +[3]: https://en.wikipedia.org/wiki/Typosquatting +[4]: https://www.menlosecurity.com/blog/-a-new-approach-to-end-typosquatting +[5]: https://github.com/elceef/dnstwist +[6]: https://opensource.com/article/17/4/build-your-own-name-server diff --git a/published/202002/20200123 Use this open source tool to get your local weather forecast.md b/published/202002/20200123 Use this open source tool to get your local weather forecast.md new file mode 100644 index 0000000000..e0022dfdee --- /dev/null +++ b/published/202002/20200123 Use this open source tool to get your local weather forecast.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11879-1.html) +[#]: subject: (Use this open source tool to get your local weather forecast) +[#]: via: (https://opensource.com/article/20/1/open-source-weather-forecast) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用这个开源工具获取本地天气预报 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十三篇文章中使用 wego 来了解出门前你是否要需要外套、雨伞或者防晒霜。 + +![](https://img.linux.net.cn/data/attachment/album/202002/11/140842a8qwomfeg9mwegg8.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 wego 了解天气 + +过去十年我对我的职业最满意的地方之一是大多数时候是远程工作。尽管现实情况是我很多时候是在家里办公,但我可以在世界上任何地方工作。缺点是,离家时我会根据天气做出一些决定。在我居住的地方,“晴朗”可以表示从“酷热”、“低于零度”到“一小时内会小雨”。能够了解实际情况和快速预测非常有用。 + +![Wego][2] + +[Wego][3] 是用 Go 编写的程序,可以获取并显示你的当地天气。如果你愿意,它甚至可以用闪亮的 ASCII 艺术效果进行渲染。 + +要安装 `wego`,你需要确保在系统上安装了[Go][4]。之后,你可以使用 `go get` 命令获取最新版本。你可能还想将 `~/go/bin` 目录添加到路径中: + +``` +go get -u github.com/schachmat/wego +export PATH=~/go/bin:$PATH +wego +``` + +首次运行时,`wego` 会报告缺失 API 密钥。现在你需要决定一个后端。默认后端是 [Forecast.io][5],它是 [Dark Sky][6]的一部分。`wego` 还支持 [OpenWeatherMap][7] 和 [WorldWeatherOnline][8]。我更喜欢 OpenWeatherMap,因此我将在此向你展示如何设置。 + +你需要在 OpenWeatherMap 中[注册 API 密钥][9]。注册是免费的,尽管免费的 API 密钥限制了一天可以查询的数量,但这对于普通用户来说应该没问题。得到 API 密钥后,将它放到 `~/.wegorc` 文件中。现在可以填写你的位置、语言以及使用公制、英制(英国/美国)还是国际单位制(SI)。OpenWeatherMap 可通过名称、邮政编码、坐标和 ID 确定位置,这是我喜欢它的原因之一。 + +``` +# wego configuration for OEM +aat-coords=false +aat-monochrome=false +backend=openweathermap +days=3 +forecast-lang=en +frontend=ascii-art-table +jsn-no-indent=false +location=Pittsboro +owm-api-key=XXXXXXXXXXXXXXXXXXXXX +owm-debug=false +owm-lang=en +units=imperial +``` + +现在,在命令行运行 `wego` 将显示接下来三天的当地天气。 + +`wego` 还可以输出 JSON 以便程序使用,还可显示 emoji。你可以使用 `-f` 参数或在 `.wegorc` 文件中指定前端。 + +![Wego at login][10] + +如果你想在每次打开 shell 或登录主机时查看天气,只需将 wego 添加到 `~/.bashrc`(我这里是 `~/.zshrc`)即可。 + +[wttr.in][11] 项目是 wego 上的基于 Web 的封装。它提供了一些其他显示选项,并且可以在同名网站上看到。关于 wttr.in 的一件很酷的事情是,你可以使用 `curl` 获取一行天气信息。我有一个名为 `get_wttr` 的 shell 函数,用于获取当前简化的预报信息。 + +``` +get_wttr() { +  curl -s "wttr.in/Pittsboro?format=3"     +} +``` + +![weather tool for productivity][12] + +现在,在我离开家之前,我就可以通过命令行快速简单地获取我是否需要外套、雨伞或者防晒霜了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-weather-forecast + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/bus-cloud.png?itok=vz0PIDDS (Sky with clouds and grass) +[2]: https://opensource.com/sites/default/files/uploads/productivity_13-1.png (Wego) +[3]: https://github.com/schachmat/wego +[4]: https://golang.org/doc/install +[5]: https://forecast.io +[6]: https://darksky.net +[7]: https://openweathermap.org/ +[8]: https://www.worldweatheronline.com/ +[9]: https://openweathermap.org/api +[10]: https://opensource.com/sites/default/files/uploads/productivity_13-2.png (Wego at login) +[11]: https://github.com/chubin/wttr.in +[12]: https://opensource.com/sites/default/files/uploads/day13-image3.png (weather tool for productivity) diff --git a/published/202002/20200124 3 handy command-line internet speed tests.md b/published/202002/20200124 3 handy command-line internet speed tests.md new file mode 100644 index 0000000000..58426cffea --- /dev/null +++ b/published/202002/20200124 3 handy command-line internet speed tests.md @@ -0,0 +1,147 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11882-1.html) +[#]: subject: (3 handy command-line internet speed tests) +[#]: via: (https://opensource.com/article/20/1/internet-speed-tests) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +3 个方便的命令行网速测试工具 +====== + +> 用这三个开源工具检查你的互联网和局域网速度。 + +![](https://img.linux.net.cn/data/attachment/album/202002/12/115915kk6hkax1vparkuvk.jpg) + +能够验证网络连接速度使您可以控制计算机。 使您可以在命令行中检查互联网和网络速度的三个开源工具是 Speedtest、Fast 和 iPerf。 + +### Speedtest + +[Speedtest][2] 是一个旧宠。它用 Python 实现,并打包在 Apt 中,也可用 `pip` 安装。你可以将它作为命令行工具或在 Python 脚本中使用。 + +使用以下命令安装: + +``` +sudo apt install speedtest-cli +``` + +或者 + +``` +sudo pip3 install speedtest-cli +``` + +然后使用命令 `speedtest` 运行它: + +``` +$ speedtest +Retrieving speedtest.net configuration... +Testing from CenturyLink (65.128.194.58)... +Retrieving speedtest.net server list... +Selecting best server based on ping... +Hosted by CenturyLink (Cambridge, UK) [20.49 km]: 31.566 ms +Testing download speed................................................................................ +Download: 68.62 Mbit/s +Testing upload speed...................................................................................................... +Upload: 10.93 Mbit/s +``` + +它给你提供了互联网上传和下载的网速。它快速而且可脚本调用,因此你可以定期运行它,并将输出保存到文件或数据库中,以记录一段时间内的网络速度。 + +### Fast + +[Fast][3] 是 Netflix 提供的服务。它的网址是 [Fast.com][4],同时它有一个可通过 `npm` 安装的命令行工具: + +``` +npm install --global fast-cli +``` + +网站和命令行程序都提供了相同的基本界面:它是一个尽可能简单的速度测试: + +``` +$ fast + +     82 Mbps ↓ +``` + +该命令返回你的网络下载速度。要获取上传速度,请使用 `-u` 标志: + +``` +$ fast -u + +   ⠧ 80 Mbps ↓ / 8.2 Mbps ↑ +``` + +### iPerf + +[iPerf][5] 测试的是局域网速度(而不是像前两个工具一样测试互联网速度)的好方法。Debian、Raspbian 和 Ubuntu 用户可以使用 apt 安装它: + +``` +sudo apt install iperf +``` + +它还可用于 Mac 和 Windows。 + +安装完成后,你需要在同一网络上的两台计算机上使用它(两台都必须安装 iPerf)。指定其中一台作为服务器。 + +获取服务端计算机的 IP 地址: + +``` +ip addr show | grep inet.*brd +``` + +你的本地 IP 地址(假设为 IPv4 本地网络)以 `192.168` 或 `10` 开头。记下 IP 地址,以便可以在另一台计算机(指定为客户端的计算机)上使用它。 + +在服务端启动 `iperf`: + +``` +iperf -s +``` + +它会等待来自客户端的传入连接。将另一台计算机作为为客户端并运行此命令,将示例中的 IP 替换为服务端计算机的 IP: + +``` +iperf -c 192.168.1.2 +``` + +![iPerf][6] + +只需几秒钟即可完成测试,然后返回传输大小和计算出的带宽。我使用家用服务器作为服务端,在 PC 和笔记本电脑上进行了一些测试。我最近在房屋周围安装了六类线以太网,因此我的有线连接速度达到 1Gbps,但 WiFi 连接速度却低得多。 + +![iPerf][7] + +你可能注意到它记录到 16Gbps。那是我使用服务器进行自我测试,因此它只是在测试写入磁盘的速度。该服务器具有仅 16 Gbps 的硬盘驱动器,但是我的台式机有 46Gbps,另外我的(较新的)笔记本超过了 60Gbps,因为它们都有固态硬盘。 + +![iPerf][8] + +### 总结 + +通过这些工具来了解你的网络速度是一项非常简单的任务。如果你更喜欢脚本或者在命令行中运行,上面的任何一个都能满足你。如果你要了解点对点的指标,iPerf 能满足你。 + +你还使用其他哪些工具来衡量家庭网络?在评论中分享你的评论。 + +本文最初发表在 Ben Nuttall 的 [Tooling blog][9] 上,并获准在此使用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/internet-speed-tests + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/train-plane-speed-big-machine.png?itok=f377dXKs (Old train) +[2]: https://github.com/sivel/speedtest-cli +[3]: https://github.com/sindresorhus/fast-cli +[4]: https://fast.com/ +[5]: https://iperf.fr/ +[6]: https://opensource.com/sites/default/files/uploads/iperf.png (iPerf) +[7]: https://opensource.com/sites/default/files/uploads/iperf2.png (iPerf) +[8]: https://opensource.com/sites/default/files/uploads/iperf3.png (iPerf) +[9]: https://tooling.bennuttall.com/command-line-speedtest-tools/ diff --git a/published/202002/20200124 Run multiple consoles at once with this open source window environment.md b/published/202002/20200124 Run multiple consoles at once with this open source window environment.md new file mode 100644 index 0000000000..33593eb788 --- /dev/null +++ b/published/202002/20200124 Run multiple consoles at once with this open source window environment.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11892-1.html) +[#]: subject: (Run multiple consoles at once with this open source window environment) +[#]: via: (https://opensource.com/article/20/1/multiple-consoles-twin) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用开源窗口环境 twin 一次运行多个控制台 +====== + +> 在我们的 20 个使用开源提升生产力的系列的第十四篇文章中用 twin 模拟了老式的 DESQview 体验。 + +![](https://img.linux.net.cn/data/attachment/album/202002/14/193658tlbyft0lbu44f0s3.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 通过 twin 克服“一个屏幕,一个应用程序”的限制 + +还有人记得 [DESQview][2] 吗?我们在 Windows、Linux 和 MacOS 中理所当然地可以在屏幕上同时运行多个程序,而 DESQview 赋予了 DOS 同样的功能。在我运营拨号 BBS 服务的初期,DESQview 是必需的,它使我能够让 BBS 在后台运行,同时在前台进行其他操作。例如,当有人拨打电话时,我可能正在开发新功能或设置新的外部程序而不会影响他们的体验。后来,在我早期做支持工作的时候,我可以同时运行我的工作电子邮件([MHS 上的 DaVinci 电子邮件][3])、支持单据系统和其他 DOS 程序。这是令人吃惊的! + +![twin][4] + +从那时起,运行多个控制台应用程序的功能已经发展了很多。但是 [tmux][5] 和 [Screen][6] 等应用仍然遵循“一个屏幕,一个应用”的显示方式。好吧,是的,tmux 具有屏幕拆分和窗格,但是不像 DESQview 那样具有将窗口“浮动”在其他窗口上的功能,就我个人而言,我怀念那个功能。 + +让我们来看看 [twin][7](文本模式窗口环境)。我认为,这个相对年轻的项目是 DESQview 的精神继任者。它支持控制台和图形环境,并具有与会话脱离和重新接驳的功能。设置起来并不是那么容易,但是它可以在大多数现代操作系统上运行。 + +Twin 是从源代码安装的(现在是这样)。但是首先,你需要安装所需的开发库。库名称将因操作系统而异。 以下示例显示了在我的 Ubuntu 19.10 系统中的情况。一旦安装了依赖库,请从 Git 中检出 twin 源代码,并运行 `./configure` 和 `make`,它们应自动检测所有内容并构建 twin: + +``` +sudo apt install libx11-dev libxpm-dev libncurses-dev zlib1g-dev libgpm-dev +git clone git@github.com:cosmos72/twin.git +cd twin +./configure +make +sudo make install +``` + +注意:如果要在 MacOS 或 BSD 上进行编译,则需要在运行 `make` 之前在文件 `include/Tw/autoconf.h` 和 `include/twautoconf.h` 中注释掉 `#define socklen_t int`。这个问题应该在 [twin #57][9] 解决了。 + +![twin text mode][10] + +第一次调用 twin 是一个挑战。你需要通过 `--hw` 参数告诉它正在使用哪种显示。例如,要启动文本模式的 twin,请输入 `twin --hw=tty,TERM=linux`。这里指定的 `TERM` 变量替代了你当前 Shell 中终端变量。要启动图形版本,运行 `twin --hw=X@$DISPLAY`。在 Linux 上,twin 一般都“可以正常工作”,而在 MacOS 上,Twin 基本是只能在终端上使用。 + +*真正*的乐趣是可以通过 `twattach` 和 `twdisplay` 命令接驳到正在运行的会话的功能。它们使你可以接驳到其他正在运行的 twin 会话。例如,在 Mac 上,我可以运行以下命令以接驳到演示机器上运行的 twin 会话: + +``` +twdisplay --twin@20days2020.local:0 --hw=tty,TERM=linux +``` + +![remote twin session][11] + +通过多做一些工作,你还可以将其用作登录外壳,以代替控制台上的 [getty][12]。这需要 gdm 鼠标守护程序、twdm 应用程序(包括)和一些额外的配置。在使用 systemd 的系统上,首先安装并启用 gdm(如果尚未安装),然后使用 `systemctl` 为控制台(我使用 tty6)创建一个覆盖。这些命令必须以 root 用户身份运行;在 Ubuntu 上,它们看起来像这样: + +``` +apt install gdm +systemctl enable gdm +systemctl start gdm +systemctl edit getty@tty6 +``` + +`systemctl edit getty@tty6` 命令将打开一个名为 `override.conf` 的空文件。它可以定义 systemd 服务设置以覆盖 tty6 的默认设置。将内容更新为: + +``` +[service] +ExecStart= +ExecStart=-/usr/local/sbin/twdm --hw=tty@/dev/tty6,TERM=linux +StandardInput=tty +StandardOutput=tty +``` + +现在,重新加载 systemd 并重新启动 tty6 以获得 twin 登录提示界面: + +``` +systemctl daemon-reload +systemctl restart getty@tty6 +``` + +![twin][13] + +这将为登录的用户启动一个 twin 会话。我不建议在多用户系统中使用此会话,但是对于个人桌面来说,这是很酷的。并且,通过使用 `twattach` 和 `twdisplay`,你可以从本地 GUI 或远程桌面访问该会话。 + +我认为 twin 真是太酷了。它还有一些细节不够完善,但是基本功能都已经有了,并且有一些非常好的文档。另外,它也使我可以在现代操作系统上稍解对 DESQview 式的体验的渴望。我希望随着时间的推移它会有所改进,希望你和我一样喜欢它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/multiple-consoles-twin + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [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/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://en.wikipedia.org/wiki/DESQview +[3]: https://en.wikipedia.org/wiki/Message_Handling_System +[4]: https://opensource.com/sites/default/files/uploads/productivity_14-1.png (twin) +[5]: https://github.com/tmux/tmux/wiki +[6]: https://www.gnu.org/software/screen/ +[7]: https://github.com/cosmos72/twin +[8]: mailto:git@github.com +[9]: https://github.com/cosmos72/twin/issues/57 +[10]: https://opensource.com/sites/default/files/uploads/productivity_14-2.png (twin text mode) +[11]: https://opensource.com/sites/default/files/uploads/productivity_14-3.png (remote twin session) +[12]: https://en.wikipedia.org/wiki/Getty_(Unix) +[13]: https://opensource.com/sites/default/files/uploads/productivity_14-4.png (twin) diff --git a/published/202002/20200125 Use tmux to create the console of your dreams.md b/published/202002/20200125 Use tmux to create the console of your dreams.md new file mode 100644 index 0000000000..9e1d32dbd3 --- /dev/null +++ b/published/202002/20200125 Use tmux to create the console of your dreams.md @@ -0,0 +1,117 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11900-1.html) +[#]: subject: (Use tmux to create the console of your dreams) +[#]: via: (https://opensource.com/article/20/1/tmux-console) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 tmux 创建你的梦想主控台 +====== + +> 使用 tmux 可以做很多事情,尤其是在将 tmuxinator 添加到其中时。在我们的二十篇系列文章的第十五期中查看它们,以在 2020 年实现开源生产力的提高。 + +![](https://img.linux.net.cn/data/attachment/album/202002/16/220832bd4l1ag4tlqxlpr4.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 tmux 和 tmuxinator 全部放到主控台上 + +到目前为止,在本系列文章中,我已经撰写了有关单个应用程序和工具的文章。从今天开始,我将把它们放在一起进行全面设置以简化操作。让我们从命令行开始。为什么使用命令行?简而言之,在命令行上工作可以使我能够从运行 SSH 的任何位置访问许多这些工具和功能。我可以 SSH 进入我的一台个人计算机,并在工作计算机上运行与我的个人计算机上所使用的相同设置。我要使用的主要工具是 [tmux][2]。 + +大多数人都只使用了 tmux 非常基础的功能,比如说在远程服务器上打开 tmux,然后启动进程,也许还会打开第二个会话以查看日志文件或调试信息,然后断开连接并在稍后返回。但是其实你可以使用 tmux 做很多工作。 + +![tmux][3] + +首先,如果你有一个已有的 tmux 配置文件,请对其进行备份。tmux 的配置文件是 `~/.tmux.conf`。将其移动到另一个目录,例如 `~/tmp`。现在,用 Git 克隆 [Oh My Tmux][4] 项目。从该克隆目录中将 `.tmux.conf` 符号链接到你的家目录,并复制该克隆目录中的 `.tmux.conf.local` 文件到家目录中以进行调整: + +``` +cd ~ +mkdir ~/tmp +mv ~/.tmux.conf ~/tmp/ +git clone https://github.com/gpakosz/.tmux.git +ln -s ~/.tmux/.tmux.conf ./ +cp ~/.tmux/.tmux.conf.local ./ +``` + +`.tmux.conf.local` 文件包含了本地设置和覆盖的设置。例如,我稍微更改了默认颜色,然后启用了 [Powerline][5] 分隔线。下面的代码段仅显示了我更改过的内容: + +``` +tmux_conf_theme_24b_colour=true +tmux_conf_theme_focused_pane_bg='default' +tmux_conf_theme_pane_border_style=fat +tmux_conf_theme_left_separator_main='\uE0B0' +tmux_conf_theme_left_separator_sub='\uE0B1' +tmux_conf_theme_right_separator_main='\uE0B2' +tmux_conf_theme_right_separator_sub='\uE0B3' +#tmux_conf_battery_bar_symbol_full='◼' +#tmux_conf_battery_bar_symbol_empty='◻' +tmux_conf_battery_bar_symbol_full='♥' +tmux_conf_battery_bar_symbol_empty='·' +tmux_conf_copy_to_os_clipboard=true +set -g mouse on +``` + +请注意,你不需要安装 Powerline,你只需要支持 Powerline 符号的字体即可。我在与控制台相关的所有内容中几乎都使用 [Hack Nerd Font][6],因为它易于阅读并且具有许多有用的额外符号。你还会注意到,我打开了操作系统剪贴板支持和鼠标支持。 + +现在,当 tmux 启动时,底部的状态栏会以吸引人的颜色提供更多信息。`Ctrl` + `b` 仍然是输入命令的 “引导” 键,但其他一些进行了更改。现在水平拆分(顶部/底部)窗格为 `Ctrl` + `b` + `-`,垂直拆分为 `Ctrl` + `b` + `_`。启用鼠标模式后,你可以单击以在窗格之间切换,并拖动分隔线以调整其大小。打开新窗口仍然是 `Ctrl` + `b` + `n`,你现在可以单击底部栏上的窗口名称在它们之间进行切换。同样,`Ctrl` + `b` + `e` 将打开 `.tmux.conf.local` 文件以进行编辑。退出编辑器时,tmux 将重新加载配置,而不会重新加载其他任何内容。这很有用。 + +到目前为止,我仅对功能和视觉显示进行了一些简单的更改,并增加了鼠标支持。现在,我将它设置为以一种有意义的方式启动我想要的应用程序,而不必每次都重新定位和调整它们的大小。为此,我将使用 [tmuxinator][7]。tmuxinator 是 tmux 的启动器,它允许你指定和管理布局以及使用 YAML 文件自动启动应用程序。要使用它,请启动 tmux 并创建要在其中运行程序的窗格。然后,使用 `Ctrl` + `b` + `n` 打开一个新窗口,并执行 `tmux list-windows`。你将获得有关布局的详细信息。 + +![tmux layout information][8] + +请注意上面代码中的第一行,我在其中设置了四个窗格,每个窗格中都有一个应用程序。保存运行时的输出以供以后使用。现在,运行 `tmuxinator new 20days` 以创建名为 “20days” 的布局。这将显示一个带有默认布局文件的文本编辑器。它包含很多有用的内容,我建议你阅读所有选项。首先输入上方的布局信息以及所需的应用程序: + +``` +# /Users/ksonney/.config/tmuxinator/20days.yml +name: 20days +root: ~/ +windows: + - mail: + layout: d9da,208x60,0,0[208x26,0,0{104x26,0,0,0,103x26,105,0,5},208x33,0,27{104x33,0,27,1,103x33,105,27,4}]] @0 + panes: + - alot + - abook + - ikhal + - todo.sh ls +20days +``` + +注意空格缩进!与 Python 代码一样,空格和缩进关系到文件的解释方式。保存该文件,然后运行 `tmuxinator 20days`。你应该会得到四个窗格,分别是 [alot][9] 邮件程序、[abook][10]、ikhal(交互式 [khal][11] 的快捷方式)以及 [todo.txt][12] 中带有 “+20days” 标签的任何内容。 + +![sample layout launched by tmuxinator][13] + +你还会注意到,底部栏上的窗口标记为 “Mail”。你可以单击该名称(以及其他命名的窗口)以跳到该视图。漂亮吧?我在同一个文件中还设置了名为 “Social” 的第二个窗口,包括 [Tuir][14]、[Newsboat][15]、连接到 [BitlBee][16] 的 IRC 客户端和 [Rainbow Stream][17]。 + +tmux 是我跟踪所有事情的生产力动力之源,有了 tmuxinator,我不必在不断调整大小、放置和启动我的应用程序上费心。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/tmux-console + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [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/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer) +[2]: https://github.com/tmux/tmux +[3]: https://opensource.com/sites/default/files/uploads/productivity_15-1.png (tumux) +[4]: https://github.com/gpakosz/.tmux +[5]: https://github.com/powerline/powerline +[6]: https://www.nerdfonts.com/ +[7]: https://github.com/tmuxinator/tmuxinator +[8]: https://opensource.com/sites/default/files/uploads/productivity_15-2.png (tmux layout information) +[9]: https://opensource.com/article/20/1/organize-email-notmuch +[10]: https://opensource.com/article/20/1/sync-contacts-locally +[11]: https://opensource.com/article/20/1/open-source-calendar +[12]: https://opensource.com/article/20/1/open-source-to-do-list +[13]: https://opensource.com/sites/default/files/uploads/productivity_15-3.png (sample layout launched by tmuxinator) +[14]: https://opensource.com/article/20/1/open-source-reddit-client +[15]: https://opensource.com/article/20/1/open-source-rss-feed-reader +[16]: https://opensource.com/article/20/1/open-source-chat-tool +[17]: https://opensource.com/article/20/1/tweet-terminal-rainbow-stream diff --git a/published/202002/20200126 Use Vim to send email and check your calendar.md b/published/202002/20200126 Use Vim to send email and check your calendar.md new file mode 100644 index 0000000000..032329e76e --- /dev/null +++ b/published/202002/20200126 Use Vim to send email and check your calendar.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11908-1.html) +[#]: subject: (Use Vim to send email and check your calendar) +[#]: via: (https://opensource.com/article/20/1/vim-email-calendar) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Vim 发送邮件和检查日历 +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的第十六篇文章中,直接通过文本编辑器管理你的电子邮件和日历。 + +![](https://img.linux.net.cn/data/attachment/album/202002/19/185842eyz2znxx1yc2ctnc.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用 Vim 做(几乎)所有事情,第一部分 + +我经常使用两个文本编辑器 —— [Vim][2] 和 [Emacs][3]。为什么两者都用呢?它们有不同的使用场景,在本系列的后续几篇文章中,我将讨论其中的一些用例。 + +![][4] + +好吧,为什么要在 Vim 中执行所有操作?因为如果有一个应用程序是我可以访问的每台计算机上都有的,那就是 Vim。如果你像我一样,可能已经在 Vim 中打发了很多时光。那么,为什么不将其用于**所有事情**呢? + +但是,在此之前,你需要做一些事情。首先是确保你的 Vim 具有 Ruby 支持。你可以使用 `vim --version | grep ruby`。如果结果不是 `+ruby`,则需要解决这个问题。这可能有点麻烦,你应该查看发行版的文档以获取正确的软件包。在 MacOS 上,用的是官方的 MacVim(不是 Brew 发行的),在大多数 Linux 发行版中,用的是 vim-nox 或 vim-gtk,而不是 vim-gtk3。 + +我使用 [Pathogen][5] 自动加载插件和捆绑软件。如果你使用 [Vundle][6] 或其他 Vim 软件包管理器,则需要调整以下命令才能使用它。 + +#### 在 Vim 中管理你的邮件 + +使 Vim 在你的生产力计划中发挥更大作用的一个很好的起点是使用它通过 [Notmuch] [7] 发送和接收电子邮件,和使用 [abook] [8] 访问你的联系人列表。你需要为此安装一些东西。下面的所有示例代码都运行在 Ubuntu 上,因此如果你使用其他发行版,则需要对此进行调整。通过以下步骤进行设置: + +``` +sudo apt install notmuch-vim ruby-mail +curl -o ~/.vim/plugin/abook --create-dirs https://raw.githubusercontent.com/dcbaker/vim-abook/master/plugin/abook.vim +``` + +到目前为止,一切都很顺利。现在启动 Vim 并执行 `:NotMuch`。由于是用较旧版本的邮件库 `notmuch-vim` 编写的,可能会出现一些警告,但总的来说,Vim 现在将成为功能齐全的 Notmuch 邮件客户端。 + +![Reading Mail in Vim][9] + +如果要搜索特定标签,请输入 `\t`,输入标签名称,然后按回车。这将拉出一个带有该标签的所有消息的列表。`\s` 组合键会弹出 `Search:` 提示符,可以对 Notmuch 数据库进行全面搜索。使用箭头键浏览消息列表,按回车键显示所选项目,然后输入 `\q` 退出当前视图。 + +要撰写邮件,请使用 `\c` 按键。你将看到一条空白消息。这是 `abook.vim` 插件发挥作用的位置。按下 `Esc` 并输入 `:AbookQuery `,其中 `` 是你要查找的名称或电子邮件地址的一部分。你将在 abook 数据库中找到与你的搜索匹配的条目列表。通过键入你想要的地址的编号,将其添加到电子邮件的地址行中。完成电子邮件的键入和编辑,按 `Esc` 退出编辑模式,然后输入 `,s` 发送。 + +如果要在 `:NotMuch` 启动时更改默认文件夹视图,则可以将变量 `g:notmuch_folders` 添加到你的 `.vimrc` 文件中: + +``` +let g:notmuch_folders = [ + \ [ 'new', 'tag:inbox and tag:unread' ], + \ [ 'inbox', 'tag:inbox' ], + \ [ 'unread', 'tag:unread' ], + \ [ 'News', 'tag:@sanenews' ], + \ [ 'Later', 'tag:@sanelater' ], + \ [ 'Patreon', 'tag:@patreon' ], + \ [ 'LivestockConservancy', 'tag:livestock-conservancy' ], + \ ] +``` + +Notmuch 插件的文档中涵盖了更多设置,包括设置标签键和使用其它的邮件程序。 + +#### 在 Vim 中查询日历 + +![][10] + +遗憾的是,似乎没有使用 vCalendar 或 iCalendar 格式的 Vim 日历程序。有个 [Calendar.vim][11],做得很好。设置 Vim 通过以下方式访问你的日历: + +``` +cd ~/.vim/bundle +git clone git@github.com:itchyny/calendar.vim.git +``` + +现在,你可以通过输入 `:Calendar` 在 Vim 中查看日历。你可以使用 `<` 和 `>` 键在年、月、周、日和时钟视图之间切换。如果要从一个特定的视图开始,请使用 `-view=` 标志告诉它你希望看到哪个视图。你也可以在任何视图中定位日期。例如,如果我想查看 2020 年 7 月 4 日这一周的情况,请输入 `:Calendar -view week 7 4 2020`。它的帮助信息非常好,可以使用 `?` 键参看。 + +![][13] + +Calendar.vim 还支持 Google Calendar(我需要),但是在 2019 年 12 月,Google 禁用了它的访问权限。作者已在 [GitHub 上的这个提案][14]中发布了一种变通方法。 + +这样你就在 Vim 中有了这些:你的邮件、地址簿和日历。但是这些还没有完成; 下一篇你将在 Vim 上做更多的事情! + +Vim 为作家提供了很多好处,无论他们是否具有技术意识。 + +需要保持时间表正确吗?了解如何使用这些免费的开源软件来做到这一点。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/vim-email-calendar + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [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/calendar.jpg?itok=jEKbhvDT (Calendar close up snapshot) +[2]: https://www.vim.org/ +[3]: https://www.gnu.org/software/emacs/ +[4]: https://opensource.com/sites/default/files/uploads/day16-image1.png +[5]: https://github.com/tpope/vim-pathogen +[6]: https://github.com/VundleVim/Vundle.vim +[7]: https://opensource.com/article/20/1/organize-email-notmuch +[8]: https://opensource.com/article/20/1/sync-contacts-locally +[9]: https://opensource.com/sites/default/files/uploads/productivity_16-2.png (Reading Mail in Vim) +[10]: https://opensource.com/sites/default/files/uploads/day16-image3.png +[11]: https://github.com/itchyny/calendar.vim +[12]: mailto:git@github.com +[13]: https://opensource.com/sites/default/files/uploads/day16-image4.png +[14]: https://github.com/itchyny/calendar.vim/issues/156 diff --git a/published/202002/20200126 What-s your favorite Linux distribution.md b/published/202002/20200126 What-s your favorite Linux distribution.md new file mode 100644 index 0000000000..d3d8e99b87 --- /dev/null +++ b/published/202002/20200126 What-s your favorite Linux distribution.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11867-1.html) +[#]: subject: (What's your favorite Linux distribution?) +[#]: via: (https://opensource.com/article/20/1/favorite-linux-distribution) +[#]: author: (Opensource.com https://opensource.com/users/admin) + +你最喜欢哪个 Linux 发行版? +====== + +![](https://img.linux.net.cn/data/attachment/album/202002/08/004438ei1y4pp44pw4xy3w.jpg) + +你最喜欢哪个 Linux 发行版?虽然有所变化,但现在仍有数百种 [Linux 发行版][2]保持活跃且运作良好。发行版、包管理器和桌面的组合为 Linux 用户创建了无数客制化系统环境。 + +我们询问了社区的作者们,哪个是他们的最爱以及原因。尽管回答中存在一些共性(由于各种原因,Fedora 和 Ubuntu 是最受欢迎的选择),但我们也听到一些惊奇的回答。以下是他们的一些回答: + +> “我使用 Fedora 发行版!我喜欢这样的社区,成员们共同创建一个令人惊叹的操作系统,展现了开源软件世界最伟大的造物。”——Matthew Miller + +> “我在家中使用 Arch。作为一名游戏玩家,我希望可以轻松使用最新版本的 Wine 和 GFX 驱动,同时最大限度地掌控我的系统。所以我选择一个滚动升级并且每个包都保持领先的发行版。”——Aimi Hobson + +> “NixOS,在业余爱好者市场中没有比这更合适的。”——Alexander Sosedkin + +> “我用过每个 Fedora 版本作为我的工作系统。这意味着我从第一个版本开始使用。从前,我问自己是否会忘记我使用的是哪一个版本。而这一天已经到来了,是从什么时候开始忘记了的呢?”——Hugh Brock + +> “通常,在我的家里和办公室里都有运行 Ubuntu、CentOS 和 Fedora 的机器。我依赖这些发行版来完成各种工作。Fedora 速度很快,而且可以获取最新版本的应用和库。Ubuntu 有大型社区支持,可以轻松使用。CentOS 则当我们需要稳如磐石的服务器平台时。”——Steve Morris + +> “我最喜欢?对于社区以及如何为发行版构建软件包(从源码构建而非二进制文件),我选择 Fedora。对于可用包的范围和包的定义和开发,我选择 Debian。对于文档,我选择 Arch。对于新手的提问,我以前会推荐 Ubuntu,而现在会推荐 Fedora。”——Al Stone + +* * * + +自从 2014 以来,我们一直向社区提出这一问题。除了 2015 年 PCLinuxOS 出乎意料的领先,Ubuntu 往往每年都获得粉丝们的青睐。其他受欢迎的竞争者还包括 Fedora、Debian、Mint 和 Arch。在新的十年里,哪个发行版更吸引你?如果我们的投票列表中没有你最喜欢的选择,请在评论中告诉我们。 + +下面是过去七年来你最喜欢的 Linux 发行版投票的总览。你可以在我们去年的年刊《[Opensource.com 上的十年最佳][3]》中看到它。[点击这里][3]下载完整版电子书! + +![Poll results for favorite Linux distribution through the years][4] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/favorite-linux-distribution + +作者:[Opensource.com][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/admin +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) +[2]: https://distrowatch.com/ +[3]: https://opensource.com/downloads/2019-yearbook-special-edition +[4]: https://opensource.com/sites/default/files/pictures/linux-distributions-through-the-years.jpg (favorite Linux distribution through the years) +[5]: https://opensource.com/article/20/1/favorite-linux-distribution diff --git a/published/202002/20200127 Use Vim to manage your task list and access Reddit and Twitter.md b/published/202002/20200127 Use Vim to manage your task list and access Reddit and Twitter.md new file mode 100644 index 0000000000..dcf7ef9dd8 --- /dev/null +++ b/published/202002/20200127 Use Vim to manage your task list and access Reddit and Twitter.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11912-1.html) +[#]: subject: (Use Vim to manage your task list and access Reddit and Twitter) +[#]: via: (https://opensource.com/article/20/1/vim-task-list-reddit-twitter) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Vim 管理任务列表和访问 Reddit 和 Twitter +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的第十七篇文章中,了解在编辑器中处理待办列表以及获取社交信息。 + +![](https://img.linux.net.cn/data/attachment/album/202002/21/112633yf3mx8qlssltugzm.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 用 Vim 做(几乎)所有事情,第 2 部分 + +在[昨天的文章][2]中,你开始用 Vim 检查邮件和日历。今天,你可以做的更多。首先,你会在 Vim 编辑器中跟踪任务,然后获取社交信息。 + +#### 使用 todo.txt-vim 在 Vim 中跟踪待办任务 + +![to-dos and Twitter with Vim][3] + +使用 Vim 编辑一个文本待办事件是一件自然的事,而 [todo.txt-vim][4] 包使其更加简单。首先安装 todo.txt-vim 包: + +``` +git clone https://github.com/freitass/todo.txt-vim ~/.vim/bundle/todo.txt-vim +vim ~/path/to/your/todo.txt +``` + +todo.txt-vim 自动识别以 `todo.txt` 和 `done.txt` 结尾的文件作为 [todo.txt][5] 文件。它添加特定于 todo.txt 格式的键绑定。你可以使用 `\x` 标记“已完成”的内容,使用 `\d` 将其设置为当前日期,然后使用 `\a`、`\b` 和 `\c` 更改优先级。你可以提升(`\k`)或降低(`\j`)优先级,并根据项目(`\s+`)、上下文(`\s@`)或日期(`\sd`)排序(`\s`)。完成后,你可以和平常一样关闭和保存文件。 + +todo.txt-vim 包是我几天前写的 [todo.sh 程序][6]的一个很好的补充,使用 [todo edit][7] 加载项,它可以增强的你待办事项列表跟踪。 + +#### 使用 vim-reddit 读取 Reddit + +![Reddit in Vim][8] + +Vim 还有一个不错的用于 [Reddit][9] 的加载项,叫 [vim-reddit][10]。它不如 [Tuir][11] 好,但是用于快速查看最新的文章,它还是不错的。首先安装捆绑包: + +``` +git clone https://github.com/DougBeney/vim-reddit.git ~/.vim/bundle/vim-reddit +vim +``` + +现在输入 `:Reddit` 将加载 Reddit 首页。你可以使用 `:Reddit name` 加载特定子板。打开文章列表后,使用箭头键导航或使用鼠标滚动。按 `o` 将在 Vim 中打开文章(除非它多媒体文章,它会打开浏览器),然后按 `c` 打开评论。如果要直接转到页面,请按 `O` 而不是 `o`。只需按 `u` 就能返回。当你 Reddit 看完后,输入 `:bd` 就行。vim-reddit 唯一的缺点是无法登录或发布新文章和评论。话又说回来,有时这是一件好事。 + +#### 使用 twitvim 在 Vim 中发推 + +![Twitter in Vim][12] + +最后,我们有 [twitvim][13],这是一个于阅读和发布 Twitter 的 Vim 软件包。它需要更多设置。首先从 GitHub 安装 twitvim: + +``` +git clone https://github.com/twitvim/twitvim.git ~/.vim/bundle/twitvim +``` + +现在你需要编辑 `.vimrc` 文件并设置一些选项。它帮助插件知道使用哪些库与 Twitter 交互。运行 `vim --version` 并查看哪些语言的前面有 `+` 就代表你的 Vim 支持它。 + +![Enabled and Disabled things in vim][14] + +因为我的是 `+perl -python +python3`,所以我知道我可以启用 Perl 和 Python 3 但不是 Python 2 (python)。 + +``` +" TwitVim Settings +let twitvim_enable_perl = 1 +" let twitvim_enable_python = 1 +let twitvim_enable_python3 = 1 +``` + +现在,你可以通过运行 `:SetLoginTwitter` 启动浏览器窗口,它会打开一个浏览器窗口要求你授权 VimTwit 访问你的帐户。在 Vim 中输入提供的 PIN 后就可以了。 + +Twitvim 的命令不像其他包中一样简单。要加载好友和关注者的时间线,请输入 `:FriendsTwitter`。要列出提及你的和回复,请使用 `:MentionsTwitter`。发布新推文是 `:PosttoTwitter `。你可以滚动列表并输入 `\r` 回复特定推文,你可以用 `\d` 直接给某人发消息。 + +就是这些了。你现在可以在 Vim 中做(几乎)所有事了! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/vim-task-list-reddit-twitter + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/email_chat_communication_message.png?itok=LKjiLnQu (Chat via email) +[2]: https://linux.cn/article-11908-1.html +[3]: https://opensource.com/sites/default/files/uploads/productivity_17-1.png (to-dos and Twitter with Vim) +[4]: https://github.com/freitass/todo.txt-vim +[5]: http://todotxt.org +[6]: https://opensource.com/article/20/1/open-source-to-do-list +[7]: https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory#edit-open-in-text-editor +[8]: https://opensource.com/sites/default/files/uploads/productivity_17-2.png (Reddit in Vim) +[9]: https://reddit.com +[10]: https://github.com/DougBeney/vim-reddit +[11]: https://opensource.com/article/20/1/open-source-reddit-client +[12]: https://opensource.com/sites/default/files/uploads/productivity_17-3.png (Twitter in Vim) +[13]: https://github.com/twitvim/twitvim +[14]: https://opensource.com/sites/default/files/uploads/productivity_17-4.png (Enabled and Disabled things in vim) diff --git a/published/202002/20200128 Send email and check your calendar with Emacs.md b/published/202002/20200128 Send email and check your calendar with Emacs.md new file mode 100644 index 0000000000..2ffdbd22d7 --- /dev/null +++ b/published/202002/20200128 Send email and check your calendar with Emacs.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11932-1.html) +[#]: subject: (Send email and check your calendar with Emacs) +[#]: via: (https://opensource.com/article/20/1/emacs-mail-calendar) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Emacs 发送电子邮件和检查日历 +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的第十八篇文章中,使用 Emacs 文本编辑器管理电子邮件和查看日程安排。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/103647mnee75vxhcc00z06.jpg) + +去年,我给你们带来了 2019 年的 19 天新生产力工具系列。今年,我将采取一种不同的方式:建立一个新的环境,让你使用已用或未用的工具来在新的一年里变得更有效率。 + +### 使用 Emacs 做(几乎)所有的事情,第 1 部分 + +两天前,我曾经说过我经常使用 [Vim][2] 和 [Emacs][3],在本系列的 [16][4] 和 [17][5] 天,我讲解了如何在 Vim 中做几乎所有的事情。现在,Emacs 的时间到了! + +![Emacs 中的邮件和日历][6] + +在深入之前,我需要说明两件事。首先,我这里使用默认的 Emacs 配置,而不是我之前[写过][8]的 [Spacemacs][7]。为什么呢?因为这样一来我使用的就是默认快捷键,从而使你可以参考文档,而不必将“原生的 Emacs” 转换为 Spacemacs。第二,在本系列文章中我没有对 Org 模式进行任何设置。Org 模式本身几乎可以自成一个完整的系列,它非常强大,但是设置可能非常复杂。 + +#### 配置 Emacs + +配置 Emacs 比配置 Vim 稍微复杂一些,但以我之见,从长远来看,这样做是值得的。首先我们创建一个配置文件,并在 Emacs 中打开它: + +``` +mkdir ~/.emacs.d +emacs ~/.emacs.d/init.el +``` + +接下来,向内置的包管理器添加一些额外的包源。在 `init.el` 中添加以下内容: + +``` +(package-initialize) +(add-to-list 'package-archives '("melpa" . "")) +(add-to-list 'package-archives '("org" . "") t) +(add-to-list 'package-archives '("gnu" . "")) +(package-refresh-contents) +``` + +使用 `Ctrl+x Ctrl+s` 保存文件,然后按下 `Ctrl+x Ctrl+c` 退出,再重启 Emacs。Emacs 会在启动时下载所有的插件包列表,之后你就可以使用内置的包管理器安装插件了。输入 `Meta+x` 会弹出命令提示符(大多数键盘上 `Meta` 键就是的 `Alt` 键,而在 MacOS 上则是 `Option`)。在命令提示符下输入 `package-list-packages` 就会显示可以安装的包列表。遍历该列表并使用 `i` 键选择以下包: + +``` +bbdb +bbdb-vcard +calfw +calfw-ical +notmuch +``` + +选好软件包后按 `x` 安装它们。根据你的网络连接情况,这可能需要一段时间。你也许会看到一些编译错误,但是可以忽略它们。安装完成后,使用组合键 `Ctrl+x Ctrl+f` 打开 `~/.emacs.d/init.el`,并在 `(package-refresh-packages)` 之后、 `(custom-set-variables` 之前添加以下行到文件中。 +`(custom-set-variables` 行由 Emacs 内部维护,你永远不应该修改它之后的任何内容。以 `;;` 开头的行则是注释。 + +``` +;; Set up bbdb +(require 'bbdb) +(bbdb-initialize 'message) +(bbdb-insinuate-message) +(add-hook 'message-setup-hook 'bbdb-insinuate-mail) +;; set up calendar +(require 'calfw) +(require 'calfw-ical) +;; Set this to the URL of your calendar. Google users will use +;; the Secret Address in iCalendar Format from the calendar settings +(cfw:open-ical-calendar "") +;; Set up notmuch +(require 'notmuch) +;; set up mail sending using sendmail +(setq send-mail-function (quote sendmail-send-it)) +(setq user-mail-address "[myemail@mydomain.com][9]" +      user-full-name "My Name") +``` + +现在,你已经准备好使用自己的配置启动 Emacs 了!保存 `init.el` 文件(`Ctrl+x Ctrl+s`),退出 Emacs(`Ctrl+x Ctrl+c`),然后重启之。这次重启要多花些时间。 + +#### 使用 Notmuch 在 Emacs 中读写电子邮件 + +一旦你看到了 Emacs 启动屏幕,你就可以使用 [Notmuch][10] 来阅读电子邮件了。键入 `Meta+x notmuch`,你将看到 notmuch 的 Emacs 界面。 + +![使用 notmuch 阅读邮件][11] + +所有加粗的项目都是指向电子邮件视图的链接。你可以通过点击鼠标或者使用 `tab` 键在它们之间跳转并按回车来访问它们。你可以使用搜索栏来搜索 Notmuch 的数据库,语法与 Notmuch 命令行上的[语法][12] 相同。如果你愿意,还可以使用 `[save]` 按钮保存搜索以便未来使用,这些搜索会被添加到屏幕顶部的列表中。如果你进入一个链接就会看到一个相关电子邮件的列表。你可以使用箭头键在列表中导航,并在要读取的消息上按回车。按 `r` 可以回复一条消息,`f` 转发该消息,`q` 退出当前屏幕。 + +你可以通过键入 `Meta+x compose-mail` 来编写新消息。撰写、回复和转发都将打开编写邮件的界面。写完邮件后,按 `Ctrl+c Ctrl+c` 发送。如果你决定不发送它,按 `Ctrl+c Ctrl+k` 关闭消息撰写缓冲区(窗口)。 + +#### 使用 BBDB 在 Emacs 中自动补完电子邮件地址 + +![在消息中使用 BBDB 地址][13] + +那么通讯录怎么办?这就是 [BBDB][14] 发挥作用的地方。但首先我们需要从 [abook][15] 导入所有地址,方法是打开命令行并运行以下导出命令: + +``` +abook --convert --outformat vcard --outfile ~/all-my-addresses.vcf --infile ~/.abook/addresses +``` + +Emacs 启动后,运行 `Meta+x bbdb-vcard-import-file`。它将提示你输入要导入的文件名,即 `~/all-my-address.vcf`。导入完成后,在编写消息时,可以开始输入名称并使用 `Tab` 搜索和自动完成 “to” 字段的内容。BBDB 还会打开一个联系人缓冲区,以便你确保它是正确的。 + +既然在 [vdirsyncer][16] 中已经为每个地址都生成了对应的 .vcf 文件了,为什么我们还要这样做呢?如果你像我一样,有许多地址,一次处理一个地址是很麻烦的。这样做,你就可以把所有的东西都放在 abook 里,做成一个大文件。 + +#### 使用 calfw 在 Emacs 中浏览日历 + +![calfw 日历 ][17] + +最后,你可以使用 Emacs 查看日历。在上面的配置中,你安装了 [calfw][18] 包,并添加了一些行来告诉它在哪里可以找到要加载的日历。Calfw 是 “Emacs 日历框架Calendar Framework for Emacs”的简称,它支持多种日历格式。我使用的是谷歌日历,这也是我放在配置中的链接。日历将在启动时自动加载,你可以通过 `Ctrl+x+b` 命令切换到 cfw-calendar 缓冲区来查看日历。 + +Calfw 提供日、周、双周和月视图。你可以在日历顶部选择视图,并使用箭头键导航日历。不幸的是,calfw 只能查看日历,所以你仍然需要使用 [khal][19] 之类的工具或通过 web 界面来添加、删除和修改事件。 + +这就是 Emacs 中的邮件、日历和邮件地址。明天我会展示更多。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/emacs-mail-calendar + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [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/email_paper_envelope_document.png?itok=uPj_kouJ (Document sending) +[2]: https://www.vim.org/ +[3]: https://www.gnu.org/software/emacs/ +[4]: https://linux.cn/article-11908-1.html +[5]: https://linux.cn/article-11912-1.html +[6]: https://opensource.com/sites/default/files/uploads/productivity_18-1.png (Mail and calendar in Emacs) +[7]: https://www.spacemacs.org/ +[8]: https://opensource.com/article/19/12/spacemacs +[9]: mailto:myemail@mydomain.com +[10]: https://notmuchmail.org/ +[11]: https://opensource.com/sites/default/files/uploads/productivity_18-2.png (Reading mail with Notmuch) +[12]: https://linux.cn/article-11807-1.html +[13]: https://opensource.com/sites/default/files/uploads/productivity_18-3.png (Composing a message with BBDB addressing) +[14]: https://www.jwz.org/bbdb/ +[15]: https://linux.cn/article-11834-1.html +[16]: https://linux.cn/article-11812-1.html +[17]: https://opensource.com/sites/default/files/uploads/productivity_18-4.png (calfw calendar) +[18]: https://github.com/kiwanami/emacs-calfw +[19]: https://khal.readthedocs.io/en/v0.9.2/index.html diff --git a/published/202002/20200129 4 cool new projects to try in COPR for January 2020.md b/published/202002/20200129 4 cool new projects to try in COPR for January 2020.md new file mode 100644 index 0000000000..d6c46e11ea --- /dev/null +++ b/published/202002/20200129 4 cool new projects to try in COPR for January 2020.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11863-1.html) +[#]: subject: (4 cool new projects to try in COPR for January 2020) +[#]: via: (https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-january-2020/) +[#]: author: (Dominik Turecek https://fedoramagazine.org/author/dturecek/) + +COPR 仓库中 4 个很酷的新项目(2020.01) +====== + +![][1] + +COPR 是个人软件仓库[集合][2],它不在 Fedora 中。这是因为某些软件不符合轻松打包的标准;或者它可能不符合其他 Fedora 标准,尽管它是自由而开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 基础设施的支持,或者是由项目自己背书的。但是,这是一种尝试新的或实验性的软件的一种巧妙的方式。 + +本文介绍了 COPR 中一些有趣的新项目。如果你第一次使用 COPR,请参阅 [COPR 用户文档][3]。 + +### Contrast + +[Contrast][4] 是一款小应用,用于检查两种颜色之间的对比度并确定其是否满足 [WCAG][5] 中指定的要求。可以使用十六进制 RGB 代码或使用颜色选择器选择颜色。除了显示对比度之外,Contrast 还以选定的颜色为背景上显示短文本来显示比较。 + +![][6] + +#### 安装说明 + +[仓库][7]当前为 Fedora 31 和 Rawhide 提供了 Contrast。要安装 Contrast,请使用以下命令: + +``` +sudo dnf copr enable atim/contrast +sudo dnf install contrast +``` + +### Pamixer + +[Pamixer][8] 是一个使用 PulseAudio 调整和监控声音设备音量的命令行工具。你可以显示设备的当前音量并直接增加/减小它,或静音/取消静音。Pamixer 可以列出所有源和接收器。 + +#### 安装说明 + +[仓库][7]当前为 Fedora 31 和 Rawhide 提供了 Pamixer。要安装 Pamixer,请使用以下命令: + +``` +sudo dnf copr enable opuk/pamixer +sudo dnf install pamixer +``` + +### PhotoFlare + +[PhotoFlare][10] 是一款图像编辑器。它有简单且布局合理的用户界面,其中的大多数功能都可在工具栏中使用。尽管它不支持使用图层,但 PhotoFlare 提供了诸如各种颜色调整、图像变换、滤镜、画笔和自动裁剪等功能。此外,PhotoFlare 可以批量编辑图片,来对所有图片应用相同的滤镜和转换,并将结果保存在指定目录中。 + +![][11] + +#### 安装说明 + +[仓库][7]当前为 Fedora 31 提供了 PhotoFlare。要安装 PhotoFlare,请使用以下命令: + +``` +sudo dnf copr enable adriend/photoflare +sudo dnf install photoflare +``` + +### Tdiff + +[Tdiff][13] 是用于比较两个文件树的命令行工具。除了显示某些文件或目录仅存在于一棵树中之外,tdiff 还显示文件大小、类型和内容,所有者用户和组 ID、权限、修改时间等方面的差异。 + +#### 安装说明 + +[仓库][7]当前为 Fedora 29-31、Rawhide、EPEL 6-8 和其他发行版提供了 tdiff。要安装 tdiff,请使用以下命令: + +``` +sudo dnf copr enable fif/tdiff +sudo dnf install tdiff +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-january-2020/ + +作者:[Dominik Turecek][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/dturecek/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg +[2]: https://copr.fedorainfracloud.org/ +[3]: https://docs.pagure.org/copr.copr/user_documentation.html# +[4]: https://gitlab.gnome.org/World/design/contrast +[5]: https://www.w3.org/WAI/standards-guidelines/wcag/ +[6]: https://fedoramagazine.org/wp-content/uploads/2020/01/contrast-screenshot.png +[7]: https://copr.fedorainfracloud.org/coprs/atim/contrast/ +[8]: https://github.com/cdemoulins/pamixer +[9]: https://copr.fedorainfracloud.org/coprs/opuk/pamixer/ +[10]: https://photoflare.io/ +[11]: https://fedoramagazine.org/wp-content/uploads/2020/01/photoflare-screenshot.png +[12]: https://copr.fedorainfracloud.org/coprs/adriend/photoflare/ +[13]: https://github.com/F-i-f/tdiff +[14]: https://copr.fedorainfracloud.org/coprs/fif/tdiff/ diff --git a/published/202002/20200129 Joplin- The True Open Source Evernote Alternative.md b/published/202002/20200129 Joplin- The True Open Source Evernote Alternative.md new file mode 100644 index 0000000000..106d670f11 --- /dev/null +++ b/published/202002/20200129 Joplin- The True Open Source Evernote Alternative.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11896-1.html) +[#]: subject: (Joplin: The True Open Source Evernote Alternative) +[#]: via: (https://itsfoss.com/joplin/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Joplin:真正的 Evernote 开源替代品 +====== + +> Joplin 是一个开源笔记记录和待办应用。你可以将笔记组织到笔记本中并标记它们。Joplin 还提供网络剪贴板来保存来自互联网的文章。 + +### Joplin:开源笔记管理器 + +![][4] + +如果你喜欢 [Evernote][2],那么你不会不太适应这个开源软件 [Joplin][3]。 + +Joplin 是一个优秀的开源笔记应用,拥有丰富的功能。你可以记笔记、记录待办事项并且通过和 Dropbox 和 NextCloud 等云服务链接来跨设备同步笔记。同步过程通过端到端加密保护。 + +Joplin 还有一个 Web 剪贴板,能让你将网页另存为笔记。这个网络剪贴板可用于 Firefox 和 Chrome/Chromium 浏览器。 + +Joplin 可以导入 enex 格式的 Evernote 文件,这让从 Evernote 切换变得容易。 + +因为数据自行保存,所以你可以用 Joplin 格式或者原始格式导出所有文件。 + +### Joplin 的功能 + +![][1] + +以下是 Joplin 的所有功能列表: + +* 将笔记保存到笔记本和子笔记本中,以便更好地组织 +* 创建待办事项清单 +* 可以标记和搜索笔记 +* 离线优先,因此即使没有互联网连接,所有数据始终在设备上可用 +* Markdown 笔记支持图片、数学符号和复选框 +* 支持附件 +* 可在桌面、移动设备和终端(CLI)使用 +* 可在 Firefox 和 Chrome 使用[网页剪切板][5] +* 端到端加密 +* 保留笔记历史 +* 根据名称、时间等对笔记进行排序 +* 可与 [Nextcloud][7]、Dropbox、WebDAV 和 OneDrive 等各种[云服务][6]同步 +* 从 Evernote 导入文件 +* 导出 JEX 文件(Joplin 导出格式)和原始文件 +* 支持笔记、待办事项、标签和笔记本 +* 任意跳转功能 +* 支持移动设备和桌面应用通知 +* 地理位置支持 +* 支持多种语言 +* 外部编辑器支持:在 Joplin 中一键用你最喜欢的编辑器打开笔记 + +### 在 Linux 和其它平台上安装 Joplin + +![][10] + +[Joplin][11] 是一个跨平台应用,可用于 Linux、macOS 和 Windows。在移动设备上,你可以[获取 APK 文件][12]将其安装在 Android 和基于 Android 的 ROM 上。你也可以[从谷歌 Play 商店下载][13]。 + +在 Linux 中,你可以获取 Joplin 的 [AppImage][14] 文件,并作为可执行文件运行。你需要为下载的文件授予执行权限。 + +- [下载 Joplin][15] + +### 体验 Joplin + +Joplin 中的笔记使用 Markdown,但你不需要了解它。编辑器的顶部面板能让你以图形方式选择项目符号、标题、图像、链接等。 + +虽然 Joplin 提供了许多有趣的功能,但你需要自己去尝试。例如,默认情况下未启用 Web 剪切板,我需要发现如何打开它。 + +你需要从桌面应用启用剪切板。在顶部菜单中,进入 “Tools->Options”。你可以在此处找到 Web 剪切板选项: + +![Enable Web Clipper from the desktop application first][16] + +它的 Web 剪切板不如 Evernote 的 Web 剪切板聪明,后者可以以图形方式剪辑网页文章的一部分。但是,也足够了。 + +这是一个在活跃开发中的开源软件,我希望它随着时间的推移得到更多的改进。 + +### 总结 + +如果你正在寻找一个不错的拥有 Web 剪切板的笔记应用,你可以试试 Joplin。如果你喜欢它,并将继续使用,尝试通过捐赠或改进代码和文档来帮助 Joplin 开发。我以 FOSS 的名义[捐赠][17]了 25 欧。 + +如果你曾经使用过 Joplin,或者仍在使用它,你对此的体验如何?如果你用的是其他笔记应用,你会切换到 Joplin 么?欢迎分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/joplin/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_logo.png?ssl=1 +[2]: https://evernote.com/ +[3]: https://joplinapp.org/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_featured.jpg?ssl=1 +[5]: https://joplinapp.org/clipper/ +[6]: https://itsfoss.com/cloud-services-linux/ +[7]: https://nextcloud.com/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_ubuntu.jpg?ssl=1 +[11]: https://github.com/laurent22/joplin +[12]: https://itsfoss.com/download-apk-ubuntu/ +[13]: https://play.google.com/store/apps/details?id=net.cozic.joplin&hl=en_US +[14]: https://itsfoss.com/use-appimage-linux/ +[15]: https://github.com/laurent22/joplin/releases +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_web_clipper.jpg?ssl=1 +[17]: https://itsfoss.com/donations-foss/ diff --git a/published/202002/20200129 Showing memory usage in Linux by process and user.md b/published/202002/20200129 Showing memory usage in Linux by process and user.md new file mode 100644 index 0000000000..e1cd22286b --- /dev/null +++ b/published/202002/20200129 Showing memory usage in Linux by process and user.md @@ -0,0 +1,189 @@ +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11849-1.html) +[#]: subject: (Showing memory usage in Linux by process and user) +[#]: via: (https://www.networkworld.com/article/3516319/showing-memory-usage-in-linux-by-process-and-user.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +查看 Linux 系统中进程和用户的内存使用情况 +====== + +> 有一些命令可以用来检查 Linux 系统中的内存使用情况,下面是一些更好的命令。 + +![Fancycrave][1] + +有许多工具可以查看 Linux 系统中的内存使用情况。一些命令被广泛使用,比如 `free`、`ps`。而另一些命令允许通过多种方式展示系统的性能统计信息,比如 `top`。在这篇文章中,我们将介绍一些命令以帮助你确定当前占用着最多内存资源的用户或者进程。 + +下面是一些按照进程查看内存使用情况的命令: + +### 按照进程查看内存使用情况 + +#### 使用 top + +`top` 是最好的查看内存使用情况的命令之一。为了查看哪个进程使用着最多的内存,一个简单的办法就是启动 `top`,然后按下 `shift+m`,这样便可以查看按照内存占用百分比从高到底排列的进程。当你按下了 `shift+m` ,你的 `top` 应该会得到类似于下面这样的输出结果: + +``` +$top +top - 09:39:34 up 5 days, 3 min, 3 users, load average: 4.77, 4.43, 3.72 +Tasks: 251 total, 3 running, 247 sleeping, 1 stopped, 0 zombie +%Cpu(s): 50.6 us, 35.9 sy, 0.0 ni, 13.4 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st +MiB Mem : 5944.4 total, 128.9 free, 2509.3 used, 3306.2 buff/cache +MiB Swap: 2048.0 total, 2045.7 free, 2.2 used. 3053.5 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 400 nemo 20 0 3309580 550188 168372 S 0.3 9.0 1:33.27 Web Content +32469 nemo 20 0 3492840 447372 163296 S 7.3 7.3 3:55.60 firefox +32542 nemo 20 0 2845732 433388 140984 S 6.0 7.1 4:11.16 Web Content + 342 nemo 20 0 2848520 352288 118972 S 10.3 5.8 4:04.89 Web Content + 2389 nemo 20 0 1774412 236700 90044 S 39.7 3.9 9:32.64 vlc +29527 nemo 20 0 2735792 225980 84744 S 9.6 3.7 3:02.35 gnome-shell +30497 nemo 30 10 1088476 159636 88884 S 0.0 2.6 0:11.99 update-manager +30058 nemo 20 0 1089464 140952 33128 S 0.0 2.3 0:04.58 gnome-software +32533 nemo 20 0 2389088 104712 79544 S 0.0 1.7 0:01.43 WebExtensions + 2256 nemo 20 0 1217884 103424 31304 T 0.0 1.7 0:00.28 vlc + 1713 nemo 20 0 2374396 79588 61452 S 0.0 1.3 0:00.49 Web Content +29306 nemo 20 0 389668 74376 54340 S 2.3 1.2 0:57.25 Xorg +32739 nemo 20 0 289528 58900 34480 S 1.0 1.0 1:04.08 RDD Process +29732 nemo 20 0 789196 57724 42428 S 0.0 0.9 0:00.38 evolution-alarm + 2373 root 20 0 150408 57000 9924 S 0.3 0.9 10:15.35 nessusd +``` + +注意 `%MEM` 排序。列表的大小取决于你的窗口大小,但是占据着最多的内存的进程将会显示在列表的顶端。 + +#### 使用 ps + +`ps` 命令中的一列用来展示每个进程的内存使用情况。为了展示和查看哪个进程使用着最多的内存,你可以将 `ps` 命令的结果传递给 `sort` 命令。下面是一个有用的示例: + +``` +$ ps aux | sort -rnk 4 | head -5 +nemo 400 3.4 9.2 3309580 563336 ? Sl 08:59 1:36 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9086 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 32469 8.2 7.7 3492840 469516 ? Sl 08:54 4:15 /usr/lib/firefox/firefox -new-window +nemo 32542 8.9 7.6 2875428 462720 ? Sl 08:55 4:36 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 1 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 342 9.9 5.9 2854664 363528 ? Sl 08:59 4:44 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 8763 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 2389 39.5 3.8 1774412 236116 pts/1 Sl+ 09:15 12:21 vlc videos/edge_computing.mp4 +``` + +在上面的例子中(文中已截断),`sort` 命令使用了 `-r` 选项(反转)、`-n` 选项(数字值)、`-k` 选项(关键字),使 `sort` 命令对 `ps` 命令的结果按照第四列(内存使用情况)中的数字逆序进行排列并输出。如果我们首先显示 `ps` 命令的标题,那么将会便于查看。 + +``` +$ ps aux | head -1; ps aux | sort -rnk 4 | head -5 +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +nemo 400 3.4 9.2 3309580 563336 ? Sl 08:59 1:36 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9086 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 32469 8.2 7.7 3492840 469516 ? Sl 08:54 4:15 /usr/lib/firefox/firefox -new-window +nemo 32542 8.9 7.6 2875428 462720 ? Sl 08:55 4:36 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 1 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 342 9.9 5.9 2854664 363528 ? Sl 08:59 4:44 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 8763 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 2389 39.5 3.8 1774412 236116 pts/1 Sl+ 09:15 12:21 vlc videos/edge_computing.mp4 +``` + +如果你喜欢这个命令,你可以用下面的命令为他指定一个别名,如果你想一直使用它,不要忘记把该命令添加到你的 `~/.bashrc` 文件中。 + +``` +$ alias mem-by-proc="ps aux | head -1; ps aux | sort -rnk 4" +``` + +下面是一些根据用户查看内存使用情况的命令: + +### 按用户查看内存使用情况 + +#### 使用 top + +按照用户检查内存使用情况会更复杂一些,因为你需要找到一种方法把用户所拥有的所有进程统计为单一的内存使用量。 + +如果你只想查看单个用户进程使用情况,`top` 命令可以采用与上文中同样的方法进行使用。只需要添加 `-U` 选项并在其后面指定你要查看的用户名,然后按下 `shift+m` 便可以按照内存使用有多到少进行查看。 + +``` +$ top -U nemo +top - 10:16:33 up 5 days, 40 min, 3 users, load average: 1.91, 1.82, 2.15 +Tasks: 253 total, 2 running, 250 sleeping, 1 stopped, 0 zombie +%Cpu(s): 28.5 us, 36.8 sy, 0.0 ni, 34.4 id, 0.3 wa, 0.0 hi, 0.0 si, 0.0 st +MiB Mem : 5944.4 total, 224.1 free, 2752.9 used, 2967.4 buff/cache +MiB Swap: 2048.0 total, 2042.7 free, 5.2 used. 2812.0 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 400 nemo 20 0 3315724 623748 165440 S 1.0 10.2 1:48.78 Web Content +32469 nemo 20 0 3629380 607492 161688 S 2.3 10.0 6:06.89 firefox +32542 nemo 20 0 2886700 404980 136648 S 5.6 6.7 6:50.01 Web Content + 342 nemo 20 0 2922248 375784 116096 S 19.5 6.2 8:16.07 Web Content + 2389 nemo 20 0 1762960 234644 87452 S 0.0 3.9 13:57.53 vlc +29527 nemo 20 0 2736924 227260 86092 S 0.0 3.7 4:09.11 gnome-shell +30497 nemo 30 10 1088476 156372 85620 S 0.0 2.6 0:11.99 update-manager +30058 nemo 20 0 1089464 138160 30336 S 0.0 2.3 0:04.62 gnome-software +32533 nemo 20 0 2389088 102532 76808 S 0.0 1.7 0:01.79 WebExtensions +``` + +#### 使用 ps + +你依旧可以使用 `ps` 命令通过内存使用情况来排列某个用户的进程。在这个例子中,我们将使用 `grep` 命令来筛选得到某个用户的所有进程。 + +``` +$ ps aux | head -1; ps aux | grep ^nemo| sort -rnk 4 | more +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +nemo 32469 7.1 11.5 3724364 701388 ? Sl 08:54 7:21 /usr/lib/firefox/firefox -new-window +nemo 400 2.0 8.9 3308556 543232 ? Sl 08:59 2:01 /usr/lib/firefox/firefox -contentproc -childID 6 -isForBrowser -prefsLen 9086 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni/usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 32542 7.9 7.1 2903084 436196 ? Sl 08:55 8:07 /usr/lib/firefox/firefox -contentproc -childID 2 -isForBrowser -prefsLen 1 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 342 10.8 7.0 2941056 426484 ? Rl 08:59 10:45 /usr/lib/firefox/firefox -contentproc -childID 5 -isForBrowser -prefsLen 8763 -prefMapSize 210653 -parentBuildID 20200107212822 -greomni /usr/lib/firefox/omni.ja -appomni /usr/lib/firefox/browser/omni.ja -appdir /usr/lib/firefox/browser 32469 true tab +nemo 2389 16.9 3.8 1762960 234644 pts/1 Sl+ 09:15 13:57 vlc videos/edge_computing.mp4 +nemo 29527 3.9 3.7 2736924 227448 ? Ssl 08:50 4:11 /usr/bin/gnome-shell +``` +### 使用 ps 和其他命令的搭配 + +如果你想比较某个用户与其他用户内存使用情况将会比较复杂。在这种情况中,创建并排序一个按照用户总的内存使用量是一个不错的方法,但是它需要做一些更多的工作,并涉及到许多命令。在下面的脚本中,我们使用 `ps aux | grep -v COMMAND | awk '{print $1}' | sort -u` 命令得到了用户列表。其中包含了系统用户比如 `syslog`。我们对每个任务使用 `awk` 命令以收集每个用户总的内存使用情况。在最后一步中,我们展示每个用户总的内存使用量(按照从大到小的顺序)。 + +``` +#!/bin/bash + +stats=”” +echo "% user" +echo "============" + +# collect the data +for user in `ps aux | grep -v COMMAND | awk '{print $1}' | sort -u` +do + stats="$stats\n`ps aux | egrep ^$user | awk 'BEGIN{total=0}; \ + {total += $4};END{print total,$1}'`" +done + +# sort data numerically (largest first) +echo -e $stats | grep -v ^$ | sort -rn | head +``` + +这个脚本的输出可能如下: + +``` +$ ./show_user_mem_usage +% user +============ +69.6 nemo +5.8 root +0.5 www-data +0.3 shs +0.2 whoopsie +0.2 systemd+ +0.2 colord +0.2 clamav +0 syslog +0 rtkit +``` + +在 Linux 有许多方法可以报告内存使用情况。可以通过一些用心设计的工具和命令,来查看并获得某个进程或者用户占用着最多的内存。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3516319/showing-memory-usage-in-linux-by-process-and-user.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/06/chips_processors_memory_cards_by_fancycrave_cc0_via_unsplash_1200x800-100760955-large.jpg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202002/20200130 Meet FuryBSD- A New Desktop BSD Distribution.md b/published/202002/20200130 Meet FuryBSD- A New Desktop BSD Distribution.md new file mode 100644 index 0000000000..611ed7c315 --- /dev/null +++ b/published/202002/20200130 Meet FuryBSD- A New Desktop BSD Distribution.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11915-1.html) +[#]: subject: (Meet FuryBSD: A New Desktop BSD Distribution) +[#]: via: (https://itsfoss.com/furybsd/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +认识 FuryBSD:一个新的桌面 BSD 发行版 +====== + +在过去的几个月中,出现了一些新的桌面 BSD。之前有 [HyperbolaBSD,它之前是 Hyperbola GNU/Linux][1]。[BSD][2] 世界中的另一个新入者是 [FuryBSD][3]。 + +### FuryBSD:一个新的 BSD 发行版 + +![][4] + +从本质上讲,FuryBSD 是一个非常简单的小东西。根据[它的网站][5]:“FuryBSD 一个是基于 FreeBSD 的轻量级桌面发行版。” 它基本上是预配置了桌面环境,并预安装了多个应用的 FreeBSD。目地是快速地在你的计算机上运行基于 FreeBSD 的系统。 + +你可能会认为这听起来很像其他几个已有的 BSD,例如 [NomadBSD][6] 和 [GhostBSD][7]。这些 BSD 与 FuryBSD 之间的主要区别在于 FuryBSD 与现有的 FreeBSD 更加接近。例如,FuryBSD 使用 FreeBSD 安装程序,而其他发行版则用了自己的安装程序和工具。 + +正如[它的网站][8]所说:“尽管 FuryBSD 可能类似于 PC-BSD 和 TrueOS 等图形化 BSD 项目,但 FuryBSD 是由不同的团队创建的,并且采用了不同与 FreeBSD 着重于紧密集成的方法。这样可以降低开销,并保持与上游的兼容性。”开发负责人还告诉我:“FuryBSD 的一个主要重点是使其成为一种小型现场版介质,并带有一些测试硬件驱动程序的辅助工具。” + +当前,你可以进入 [FuryBSD 主页][3]并下载 XFCE 或 KDE 的 LiveCD。GNOME 版本正在开发中。 + +### FuryBSD 的背后是谁 + +FuryBSD 的主要开发者是 [Joe Maloney][9]。Joe 多年来一直是 FreeBSD 的用户。他为 PC-BSD 等其他 BSD 项目做过贡献。他还与 GhostBSD 的创建者 Eric Turgeon 一起重写了 GhostBSD LiveCD。在此过程中,他对 BSD 有了更好的了解,并开始形成自己如何做一个发行版的想法。 + +Joe 与其他参与 BSD 世界多年的开发者一起加入了开发,例如 Jaron Parsons、Josh Smith 和 Damian Szidiropulosz。 + +### FuryBSD 的未来 + +目前,FuryBSD 仅仅是预配置的 FreeBSD。但是,开发者有一份[要改进的清单][5]。包括: + +* 可靠的加载框架、第三方专有图形驱动、无线网络 +* 进一步整理 LiveCD 体验,以使其更加友好 +* 开箱即用的打印支持 +* 包含更多默认应用,以提供完整的桌面体验 +* 集成的 [ZFS][10] 复制工具,用于备份和还原 +* Live 镜像持久化选项 +* 默认自定义 pkg 仓库 +* 用于应用更新的持续集成 +* 桌面 FreeBSD 的质量保证 +* 自定义、色彩方案和主题 +* 目录服务集成 +* 安全加固 + +开发者非常清楚地表明,他们所做的任何更改都需要大量的思考和研究。他们不会改进某个功能,只会在它破坏一些东西时删除或者修改它。 + +![FuryBSD desktop][11] + +### 你可以如何帮助 FuryBSD? + +目前,该项目还很年轻。由于所有项目都需要帮助才能生存,所以我问 Joe 他们正在寻求什么样的帮助。他说:“我们可以帮助[在论坛上回答问题][12]、回答 [GitHub][13] 上的问题,完善文档。”他还说如果人们想增加对其他桌面环境的支持,欢迎发起拉取请求。 + +### 最后的想法 + +尽管我还没有尝试过,但是我对 FuryBSD 感觉不错。听起来项目在掌握中。十多年来,Joe Maloney 一直在思考如何达到最佳的 BSD 桌面体验。与大多数 Linux 发行版基本上都是经过重新设计的 Ubuntu 不同,FuryBSD 背后的开发者知道他们在做什么,并且他们在更看重质量而不是花哨的功能。 + +你对这个在不断增长的桌面 BSD 市场的新入者怎么看?你尝试过 FuryBSD 或者会尝试一下吗?请在下面的评论中告诉我们。 + +如果你觉得这篇文章有趣,请在 Hacker News 或 [Reddit][14] 等社交媒体上分享它。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/furybsd/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/hyperbola-linux-bsd/ +[2]: https://itsfoss.com/bsd/ +[3]: https://www.furybsd.org/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/fury-bsd.jpg?ssl=1 +[5]: https://www.furybsd.org/manifesto/ +[6]: https://itsfoss.com/nomadbsd/ +[7]: https://ghostbsd.org/ +[8]: https://www.furybsd.org/furybsd-video-overview-at-knoxbug/ +[9]: https://github.com/pkgdemon +[10]: https://itsfoss.com/what-is-zfs/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/FuryBSDS-desktop.jpg?resize=800%2C450&ssl=1 +[12]: https://forums.furybsd.org/ +[13]: https://github.com/furybsd +[14]: https://reddit.com/r/linuxusersgroup diff --git a/published/202002/20200131 Intro to the Linux command line.md b/published/202002/20200131 Intro to the Linux command line.md new file mode 100644 index 0000000000..49550210fe --- /dev/null +++ b/published/202002/20200131 Intro to the Linux command line.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11864-1.html) +[#]: subject: (Intro to the Linux command line) +[#]: via: (https://www.networkworld.com/article/3518440/intro-to-the-linux-command-line.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux 命令行简介 +====== + +> 下面是一些针对刚开始使用 Linux 命令行的人的热身练习。警告:它可能会上瘾。 + +![](https://images.idgesg.net/images/article/2020/01/cmd_linux-control_linux-logo_-100828420-large.jpg) + +如果你是 Linux 新手,或者从来没有花时间研究过命令行,你可能不会理解为什么这么多 Linux 爱好者坐在舒适的桌面前兴奋地输入命令来使用大量工具和应用。在这篇文章中,我们将快速浏览一下命令行的奇妙之处,看看能否让你着迷。 + +首先,要使用命令行,你必须打开一个命令工具(也称为“命令提示符”)。如何做到这一点将取决于你运行的 Linux 版本。例如,在 RedHat 上,你可能会在屏幕顶部看到一个 “Activities” 选项卡,它将打开一个选项列表和一个用于输入命令的小窗口(类似 “cmd” 为你打开的窗口)。在 Ubuntu 和其他一些版本中,你可能会在屏幕左侧看到一个小的终端图标。在许多系统上,你可以同时按 `Ctrl+Alt+t` 键打开命令窗口。 + +如果你使用 PuTTY 之类的工具登录 Linux 系统,你会发现自己已经处于命令行界面。 + +一旦你得到你的命令行窗口,你会发现自己坐在一个提示符面前。它可能只是一个 `$` 或者像 `user@system:~$` 这样的东西,但它意味着系统已经准备好为你运行命令了。 + +一旦你走到这一步,就应该开始输入命令了。下面是一些要首先尝试的命令,以及这里是一些特别有用的命令的 [PDF][4] 和适合打印和做成卡片的双面命令手册。 + + +| 命令 | 用途 | +|---|---| +| `pwd` | 显示我在文件系统中的位置(在最初进入系统时运行将显示主目录) | +| `ls` | 列出我的文件 | +| `ls -a` | 列出我更多的文件(包括隐藏文件) | +| `ls -al` | 列出我的文件,并且包含很多详细信息(包括日期、文件大小和权限) | +| `who` | 告诉我谁登录了(如果只有你,不要失望) | +| `date` | 日期提醒我今天是星期几(也显示时间) | +| `ps` | 列出我正在运行的进程(可能只是你的 shell 和 `ps` 命令) | + +一旦你从命令行角度习惯了 Linux 主目录之后,就可以开始探索了。也许你会准备好使用以下命令在文件系统中闲逛: + +| 命令 | 用途 | +|---|---| +| `cd /tmp` | 移动到其他文件夹(本例中,打开 `/tmp` 文件夹) | +| `ls` | 列出当前位置的文件 | +| `cd` | 回到主目录(不带参数的 `cd` 总是能将你带回到主目录) | +| `cat .bashrc` | 显示文件的内容(本例中显示 `.bashrc` 文件的内容) | +| `history` | 显示最近执行的命令 | +| `echo hello` | 跟自己说 “hello” | +| `cal` | 显示当前月份的日历 | + +要了解为什么高级 Linux 用户如此喜欢命令行,你将需要尝试其他一些功能,例如重定向和管道。“重定向”是当你获取命令的输出并将其放到文件中而不是在屏幕上显示时。“管道”是指你将一个命令的输出发送给另一条将以某种方式对其进行操作的命令。这是可以尝试的命令: + +| 命令 | 用途 | +|---|---| +| `echo "echo hello" > tryme` | 创建一个新的文件并将 “echo hello” 写入该文件 | +| `chmod 700 tryme` | 使新建的文件可执行 | +| `tryme` | 运行新文件(它应当运行文件中包含的命令并且显示 “hello” )| +| `ps aux` | 显示所有运行中的程序 | +| `ps aux | grep $USER` | 显示所有运行中的程序,但是限制输出的内容包含你的用户名 | +| `echo $USER` | 使用环境变量显示你的用户名 | +| `whoami` | 使用命令显示你的用户名 | +| `who | wc -l` | 计数所有当前登录的用户数目 | + +### 总结 + +一旦你习惯了基本命令,就可以探索其他命令并尝试编写脚本。 你可能会发现 Linux 比你想象的要强大并且好用得多. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3518440/intro-to-the-linux-command-line.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[1]: https://commons.wikimedia.org/wiki/File:Tux.svg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[4]: https://www.networkworld.com/article/3391029/must-know-linux-commands.html +[5]: https://www.networkworld.com/newsletters/signup.html +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/published/202002/20200202 4 Key Changes to Look Out for in Linux Kernel 5.6.md b/published/202002/20200202 4 Key Changes to Look Out for in Linux Kernel 5.6.md new file mode 100644 index 0000000000..e6bf7ef27a --- /dev/null +++ b/published/202002/20200202 4 Key Changes to Look Out for in Linux Kernel 5.6.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11853-1.html) +[#]: subject: (4 Key Changes to Look Out for in Linux Kernel 5.6) +[#]: via: (https://itsfoss.com/linux-kernel-5-6/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +四大亮点带你看 Linux 内核 5.6 +====== + +当我们还在体验 Linux 5.5 稳定发行版带来更好的硬件支持时,Linux 5.6 已经来了。 + +说实话,Linux 5.6 比 5.5 更令人兴奋。即使即将发布的 Ubuntu 20.04 LTS 发行版将自带 Linux 5.5,你也需要切实了解一下 Linux 5.6 内核为我们提供了什么。 + +我将在本文中重点介绍 Linux 5.6 发布版中值得期待的关键更改和功能: + +### Linux 5.6 功能亮点 + +![][1] + +当 Linux 5.6 有新消息时,我会努力更新这份功能列表。但现在让我们先看一下当前已知的内容: + +#### 1、支持 WireGuard + +WireGuard 将被添加到 Linux 5.6,出于各种原因的考虑它可能将取代 [OpenVPN][2]。 + +你可以在官网上进一步了解 [WireGuard][3] 的优点。当然,如果你使用过它,那你可能已经知道它比 OpenVPN 更好的原因。 + +同样,[Ubuntu 20.04 LTS 将支持 WireGuard][4]。 + +#### 2、支持 USB4 + +Linux 5.6 也将支持 **USB4**。 + +如果你不了解 USB 4.0 (USB4),你可以阅读这份[文档][5]。 + +根据文档,“USB4 将使 USB 的最大带宽增大一倍并支持多并发数据和显示协议multiple simultaneous data and display protocols。” + +另外,虽然我们都知道 USB4 基于 Thunderbolt 接口协议,但它将向后兼容 USB 2.0、USB 3.0 以及 Thunderbolt 3,这将是一个好消息。 + +#### 3、使用 LZO/LZ4 压缩 F2FS 数据 + +Linux 5.6 也将支持使用 LZO/LZ4 算法压缩 F2FS 数据。 + +换句话说,这只是 Linux 文件系统的一种新压缩技术,你可以选择待定的文件扩展技术。 + +#### 4、解决 32 位系统的 2038 年问题 + +Unix 和 Linux 将时间值以 32 位有符号整数格式存储,其最大值为 2147483647。时间值如果超过这个数值则将由于整数溢出而存储为负数。 + +这意味着对于 32 位系统,时间值不能超过 1970 年 1 月 1 日后的 2147483647 秒。也就是说,在 UTC 时间 2038 年 1 月 19 日 03:14:07 时,由于整数溢出,时间将显示为 1901 年 12 月 13 日而不是 2038 年 1 月 19 日。 + +Linux kernel 5.6 解决了这个问题,因此 32 位系统也可以运行到 2038 年以后。 + +#### 5、改进硬件支持 + +很显然,在下一个发布版中,硬件支持也将继续提升。而支持新式无线外设的计划也同样是优先的。 + +新内核中将增加对 MX Master 3 鼠标以及罗技其他无线产品的支持。 + +除了罗技的产品外,你还可以期待获得许多不同硬件的支持(包括对 AMD GPU、NVIDIA GPU 和 Intel Tiger Lake 芯片组的支持)。 + +#### 6、其他更新 + +此外,Linux 5.6 中除了上述主要的新增功能或支持外,下一个内核版本也将进行其他一些改进: + + * 改进 AMD Zen 的温度/功率报告 + * 修复华硕飞行堡垒系列笔记本中 AMD CPU 过热 + * 开源支持 NVIDIA RTX 2000 图灵系列显卡 + * 内建 FSCRYPT 加密 + +[Phoronix][6] 跟踪了 Linux 5.6 带来的许多技术性更改。因此,如果你好奇 Linux 5.6 所涉及的全部更改,则可以亲自了解一下。 + +现在你已经了解了 Linux 5.6 发布版带来的新功能,对此有什么看法呢?在下方评论中留下你的看法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-kernel-5-6/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/linux-kernel-5.6.jpg?ssl=1 +[2]: https://openvpn.net/ +[3]: https://www.wireguard.com/ +[4]: https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-20.04-Adds-WireGuard +[5]: https://www.usb.org/sites/default/files/2019-09/USB-IF_USB4%20spec%20announcement_FINAL.pdf +[6]: https://www.phoronix.com/scan.php?page=news_item&px=Linux-5.6-Spectacular diff --git a/published/202002/20200203 Give an old MacBook new life with Linux.md b/published/202002/20200203 Give an old MacBook new life with Linux.md new file mode 100644 index 0000000000..4a2ec03b17 --- /dev/null +++ b/published/202002/20200203 Give an old MacBook new life with Linux.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11902-1.html) +[#]: subject: (Give an old MacBook new life with Linux) +[#]: via: (https://opensource.com/article/20/2/macbook-linux-elementary) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +用 Linux 让旧 MacBook 焕发新生 +====== + +> Elementary OS 的最新版本 Hera 是一个令人印象深刻的平台,它可以让过时的 MacBook 得以重生。 + +![](https://img.linux.net.cn/data/attachment/album/202002/18/113614k2jx6ju7uuu0alhk.png) + +当我安装苹果的 [MacOS Mojave][2] 时,它使我以前可靠的 MacBook Air 慢得像爬一样。我的计算机发售于 2015 年,具有 4 GB 内存、i5 处理器和 Broadcom 4360 无线卡,但是对于我的日常使用来说,Mojava 有点过分了,它不能和 [GnuCash][3] 一起工作,这激起了我重返 Linux 的欲望。我很高兴能重返,但是我深感遗憾的是,我的这台出色的 MacBook 被闲置了。 + +我在 MacBook Air 上尝试了几种 Linux 发行版,但总会有缺陷。有时是无线网卡;还有一次,它缺少对触摸板的支持。看了一些不错的评论后,我决定尝试 [Elementary OS][4] 5.0(Juno)。我用 USB [制作了启动盘][5],并将其插入 MacBook Air 。我来到了一个现场live桌面,并且操作系统识别出了我的 Broadcom 无线芯片组 —— 我认为这可能行得通! + +我喜欢在 Elementary OS 中看到的内容。它的 [Pantheon][6] 桌面真的很棒,并且其外观和使用起来的感觉对 Apple 用户来说很熟悉 —— 它的显示屏底部有一个扩展坞,并带有一些指向常用应用程序的图标。我对我之前期待的预览感到满意,所以我决定安装它,然后我的无线设备消失了。真的很令人失望。我真的很喜欢 Elementary OS ,但是没有无线网络是不行的。 + +时间快进到 2019 年 12 月,当我在 [Linux4Everyone][7] 播客上听到有关 Elementary 最新版本 v.5.1(Hera) 使 MacBook 复活的评论时,我决定用 Hera 再试一次。我下载了 ISO ,创建了可启动驱动器,将其插入电脑,这次操作系统识别了我的无线网卡。我可以在上面工作了。 + +![运行 Hera 的 MacBook Air][8] + +我非常高兴我轻巧又功能强大的 MacBook Air 通过 Linux 焕然一新。我一直在更详细地研究 Elementary OS,我可以告诉你我印象深刻的东西。 + +### Elementary OS 的功能 + +根据 [Elementary 的博客][9],“新设计的登录和锁定屏幕问候语看起来更清晰、效果更好,并且修复了以前问候语中报告的许多问题,包括输入焦点问题,HiDPI 问题和更好的本地化。Hera 的新设计是为了响应来自 Juno 的用户反馈,并启用了一些不错的新功能。” + +“不错的新功能”是在轻描淡写 —— Elementary OS 拥有我见过的最佳设计的 Linux 用户界面之一。默认情况下,系统上的“系统设置”图标位于扩展坞上。更改设置很容易,很快我就按照自己的喜好配置了系统。我需要的文字大小比默认值大,辅助功能是易于使用的,允许我设置大文字和高对比度。我还可以使用较大的图标和其他选项来调整扩展坞。 + +![Elementary OS 的设置界面][10] + +按下 Mac 的 Command 键将弹出一个键盘快捷键列表,这对新用户非常有帮助。 + +![Elementary OS 的键盘快捷键][11] + +Elementary OS 附带的 [Epiphany][12] Web 浏览器,我发现它非常易于使用。它与 Chrome、Chromium 或 Firefox 略有不同,但它已经绰绰有余。 + +对于注重安全的用户(我们应该都是),Elementary OS 的安全和隐私设置提供了多个选项,包括防火墙、历史记录、锁定,临时和垃圾文件的自动删除以及用于位置服务开/关的开关。 + +![Elementary OS 的隐私与安全][13] + +### 有关 Elementray OS 的更多信息 + +Elementary OS 最初于 2011 年发布,其最新版本 Hera 于 2019 年 12 月 3 日发布。 Elementary 的联合创始人兼 CXO 的 [Cassidy James Blaede][14] 是操作系统的 UX 架构师。 Cassidy 喜欢使用开放技术来设计和构建有用、可用和令人愉悦的数字产品。 + +Elementary OS 具有出色的用户[文档][15],其代码(在 GPL 3.0 下许可)可在 [GitHub][16] 上获得。Elementary OS 鼓励参与该项目,因此请务必伸出援手并[加入社区][17]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/macbook-linux-elementary + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop) +[2]: https://en.wikipedia.org/wiki/MacOS_Mojave +[3]: https://www.gnucash.org/ +[4]: https://elementary.io/ +[5]: https://opensource.com/life/14/10/test-drive-linux-nothing-flash-drive +[6]: https://opensource.com/article/19/12/pantheon-linux-desktop +[7]: https://www.linux4everyone.com/20-macbook-pro-elementary-os +[8]: https://opensource.com/sites/default/files/uploads/macbookair_hera.png (MacBook Air with Hera) +[9]: https://blog.elementary.io/introducing-elementary-os-5-1-hera/ +[10]: https://opensource.com/sites/default/files/uploads/elementaryos_settings.png (Elementary OS's Settings screen) +[11]: https://opensource.com/sites/default/files/uploads/elementaryos_keyboardshortcuts.png (Elementary OS's Keyboard shortcuts) +[12]: https://en.wikipedia.org/wiki/GNOME_Web +[13]: https://opensource.com/sites/default/files/uploads/elementaryos_privacy-security.png (Elementary OS's Privacy and Security screen) +[14]: https://github.com/cassidyjames +[15]: https://elementary.io/docs/learning-the-basics#learning-the-basics +[16]: https://github.com/elementary +[17]: https://elementary.io/get-involved diff --git a/published/202002/20200203 Troubleshoot Kubernetes with the power of tmux and kubectl.md b/published/202002/20200203 Troubleshoot Kubernetes with the power of tmux and kubectl.md new file mode 100644 index 0000000000..8fe0552828 --- /dev/null +++ b/published/202002/20200203 Troubleshoot Kubernetes with the power of tmux and kubectl.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11930-1.html) +[#]: subject: (Troubleshoot Kubernetes with the power of tmux and kubectl) +[#]: via: (https://opensource.com/article/20/2/kubernetes-tmux-kubectl) +[#]: author: (Abhishek Tamrakar https://opensource.com/users/tamrakar) + +利用 Tmux 和 kubectl 解决 Kubernetes 故障 +====== + +> 一个使用 tmux 的 kubectl 插件可以使 Kubernetes 疑难问题变得更简单。 + +![](https://img.linux.net.cn/data/attachment/album/202002/25/125435a4v3vpss3s4w3sks.jpg) + +[Kubernetes][2] 是一个活跃的开源容器管理平台,它提供了可扩展性、高可用性、健壮性和富有弹性的应用程序管理。它的众多特性之一是支持通过其主要的二进制客户端 [kubectl][3] 运行定制脚本或可执行程序,kubectl 很强大的,允许用户在 Kubernetes 集群上用它直接做很多事情。 + +### 使用别名进行 Kubernetes 的故障排查 + +使用 Kubernetes 进行容器编排的人都知道由于设计上原因带来了其功能的复杂性。举例说,迫切需要以更快的速度并且几乎不需要手动干预的方式来简化 Kubernetes 中的故障排除(除过特殊情况)。 + +在故障排查功能方面,有很多场景需要考虑。在一种场景下,你知道你需要运行什么,但是这个命令的语法(即使作为一个单独的命令运行)过于复杂,或需要一、两次交互才能起作用。 + +例如,如果你需要经常进入一个系统命名空间中运行的容器,你可能发现自己在重复地键入: + +``` +kubectl --namespace=kube-system exec -i -t +``` + +为了简化故障排查,你可以用这些指令的命令行别名。比如,你可以增加下面命令到你的隐藏配置文件(`.bashrc` 或 `.zshrc`): + +``` +alias ksysex='kubectl --namespace=kube-system exec -i -t' +``` + +这是来自于 [Kubernetes 常见别名][4]存储库的一个例子,它展示了一种简化 `kubectl` 中的功能的方法。像这种场景下的简单情形,使用别名很有用。 + +### 切换到 kubectl 插件 + +更复杂的故障排查场景是需要一个一个的执行很多命令,调查环境,最后得出结论。仅仅用别名方法是不能解决这种情况的;你需要知道你所部署的 Kubernetes 之间逻辑和相关性,你真正需要的是自动化,以在更短的时间内输出你想要的。 + +考虑到你的集群有 10 ~ 20 或 50 ~ 100 个命名空间来提供不同的微服务。一般在进行故障排查时,什么对你有帮助? + +* 你需要能够快速分辨出抛出错误的是哪个 命名空间的哪个 Pod 的东西。 +* 你需要一些可监视一个命名空间的所有 Pod 日志的东西。 +* 你可能也需要监视特定命名空间的出现错误的某个 Pod 的日志。 + +涵盖这些要点的解决方案对于定位生产环境的问题有很大的帮助,以及在开发和测试环节中也很有用。 + +你可以用 [kubectl 插件][5]创建比简单的别名更强大的功能。插件类似于其它用任何语言编写的独立脚本,但被设计为可以扩充 Kubernetes 管理员的主要命令。 + +创建一个插件,你必须用 `kubectl-` 的正确的语法来拷贝这个脚本到 `$PATH` 中的导出目录之一,并需要为其赋予可执行权限(`chmod +x`)。 + +创建插件之后将其移动到路径中,你可以立即运行它。例如,我的路径下有一个 `kubectl-krawl` 和 `kubectl-kmux`: + +``` +$ kubectl plugin list +The following compatible plugins are available: + +/usr/local/bin/kubectl-krawl +/usr/local/bin/kubectl-kmux + +$ kubectl kmux +``` + +现在让我们见识下带有 tmux 的 Kubernetes 的有多强大。 + +### 驾驭强大的 tmux + +[Tmux][6] 是一个非常强大的工具,许多管理员和运维团队都依赖它来解决与易操作性相关的问题:通过将窗口分成多个窗格以便在多台计算机上运行并行的调试来监视日志。它的主要的优点是可在命令行或自动化脚本中使用。 + +我创建[一个 kubectl 插件][7],使用 tmux 使故障排查更加简单。我将通过注释来解析插件背后的逻辑(插件的完整代码留待给你实现): + +``` +# NAMESPACE 是要监控的名字空间 +# POD 是 Pod 名称 +# Containers 是容器名称 + +# 初始化一个计数器 n 以计算循环计数的数量, +# 之后 tmux 使用它来拆分窗格。 +n=0; + +# 在 Pod 和容器列表上开始循环 +while IFS=' ' read -r POD CONTAINERS +do + # tmux 为每个 Pod 创建一个新窗口 + tmux neww $COMMAND -n $POD 2>/dev/null + # 对运行中的 Pod 中 的所有容器启动循环 + for CONTAINER in ${CONTAINERS//,/ } + do + if [ x$POD = x -o x$CONTAINER = x ]; then + # 如果任何值为 null,则退出。 + warn "Looks like there is a problem getting pods data." + break + fi + + # 设置要执行的命令 + COMMAND=”kubectl logs -f $POD -c $CONTAINER -n $NAMESPACE” + # 检查 tmux 会话 + if tmux has-session -t <会话名> 2>/dev/null; + then + <设置会话退出> + else + <创建会话> + fi + # 在当前窗口为每个容器切分窗格 + tmux selectp -t $n \; \ + splitw $COMMAND \; \ + select-layout tiled \; + # 终止容器循环 + done + + # 用 Pod 名称重命名窗口以识别 + tmux renamew $POD 2>/dev/null + + # 增加计数器 + ((n+=1)) + +# 终止 Pod 循环 +done<<(<从 kubernetes 集群获取 Pod 和容器的列表>) + +# 最后选择窗口并附加会话 +tmux selectw -t <会话名>:1 \; \ +attach-session -t <会话名>\; +``` + +运行插件脚本后,将产生类似于下图的输出。每个 Pod 有一个自己的窗口,每个容器(如果有多个)被分割到其窗口中 Pod 窗格中,并在日志到达时输出。Tmux 之美如下可见;通过正确的配置,你甚至会看到哪个窗口正处于激活运行状态(可看到标签是白色的)。 + +![kmux 插件的输出][8] + +### 总结 + +别名是在 Kubernetes 环境下常见的也有用的简易故障排查方法。当环境变得复杂,用高级脚本生成的kubectl 插件是一个更强大的方法。至于用哪个编程语言来编写 kubectl 插件是没有限制。唯一的要求是该名字在路径中是可执行的,并且不能与已知的 kubectl 命令重复。 + +要阅读完整的插件源码,或试试我创建的插件,请查看我的 [kube-plugins-github][7] 存储库。欢迎提交提案和补丁。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/kubernetes-tmux-kubectl + +作者:[Abhishek Tamrakar][a] +选题:[lujun9972][b] +译者:[guevaraya](https://github.com/guevaraya) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/tamrakar +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_women_computing_4.png?itok=VGZO8CxT (一个坐在笔记本面前的妇女) +[2]: https://opensource.com/resources/what-is-kubernetes +[3]: https://kubernetes.io/docs/reference/kubectl/overview/ +[4]: https://github.com/ahmetb/kubectl-aliases/blob/master/.kubectl_aliases +[5]: https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/ +[6]: https://opensource.com/article/19/6/tmux-terminal-joy +[7]: https://github.com/abhiTamrakar/kube-plugins +[8]: https://raw.githubusercontent.com/abhiTamrakar/kube-plugins/master/kmux/kmux.png diff --git a/published/202002/20200204 Ubuntu 19.04 Has Reached End of Life- Existing Users Must Upgrade to Ubuntu 19.10.md b/published/202002/20200204 Ubuntu 19.04 Has Reached End of Life- Existing Users Must Upgrade to Ubuntu 19.10.md new file mode 100644 index 0000000000..3526c8e6ec --- /dev/null +++ b/published/202002/20200204 Ubuntu 19.04 Has Reached End of Life- Existing Users Must Upgrade to Ubuntu 19.10.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11866-1.html) +[#]: subject: (Ubuntu 19.04 Has Reached End of Life! Existing Users Must Upgrade to Ubuntu 19.10) +[#]: via: (https://itsfoss.com/ubuntu-19-04-end-of-life/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Ubuntu 19.04 已经到期!现有用户必须升级到 Ubuntu 19.10 +====== + +> Ubuntu 19.04 已在 2020 年 1 月 23 日到期,这意味着运行 Ubuntu 19.04 的系统将不再会接收到安全和维护更新,因此将使其容易受到攻击。 + +![][1] + +[Ubuntu 19.04][2] 发布于 2019 年 4 月 18 日。由于它不是长期支持(LTS)版本,因此只有 9 个月的支持。完成它的发行周期后,Ubuntu 19.04 于 2020 年 1 月 23 日到期。 + +Ubuntu 19.04 带来了一些视觉和性能方面的改进,为时尚和美观的 Ubuntu 外观铺平了道路。与其他常规 Ubuntu 版本一样,它的生命周期为 9 个月。它如今结束了。 + +### Ubuntu 19.04 终止了吗?这是什么意思? + +EOL(End of life)是指在某个日期之后操作系统版本将无法获得更新。你可能已经知道 Ubuntu(或其他操作系统)提供了安全性和维护升级,以使你的系统免受网络攻击。当发行版到期后,操作系统将停止接收这些重要更新。 + +如果你的操作系统版本到期后继续使用该系统,那么系统将容易受到网络和恶意软件的攻击。不仅如此。在 Ubuntu 中,你使用 APT 从软件中心下载的应用也不会更新。实际上,你将不再能够[使用 apt-get 命令安装新软件][3](如果不是立即,那就是逐渐地)。 + +### 所有 Ubuntu 19.04 用户必须升级到 Ubuntu 19.10 + +从 2020 年 1 月 23 日开始,Ubuntu 19.04 将停止接收更新。你必须升级到 2020 年 7 月之前受支持的 Ubuntu 19.10。这也适用于其他[官方 Ubuntu 衍生版][4],例如 Lubuntu、Xubuntu、Kubuntu 等。 + +你可以在“设置 -> 细节” 或使用如下命令来[检查你的 Ubuntu 版本][9]: + +``` +lsb_release -a +``` + +#### 如何升级到 Ubuntu 19.10? + +值得庆幸的是,Ubuntu 提供了简单的方法来将现有系统升级到新版本。实际上,Ubuntu 还会提示你有新的 Ubuntu 版本可用,你应该升级到该版本。 + +![Existing Ubuntu 19.04 should see a message to upgrade to Ubuntu 19.10][5] + +如果你的互联网连接良好,那么可以使用[和更新 Ubuntu 一样的 Software Updater 工具][6]。在上图中,你只需单击 “Upgrade” 按钮并按照说明进行操作。我已经编写了有关使用此方法[升级到 Ubuntu 18.04][7]的文章。 + +如果你没有良好的互联网连接,那么有一种临时方案。在外部磁盘上备份家目录或重要数据。 + +然后,制作一个 Ubuntu 19.10 的 Live USB。下载 Ubuntu 19.10 ISO,并使用 Ubuntu 系统上已安装的启动磁盘创建器从该 ISO 创建 Live USB。 + +从该 Live USB 引导,然后继续“安装” Ubuntu 19.10。在安装过程中,你应该看到一个删除 Ubuntu 19.04 并将其替换为 Ubuntu 19.10 的选项。选择此选项,然后像重新[安装 Ubuntu][8]一样进行下去。 + +#### 你是否仍在使用 Ubuntu 19.04、18.10、17.10 或其他不受支持的版本? + +你应该注意,目前仅 Ubuntu 16.04、18.04 和 19.10(或更高版本)版本还受支持。如果你运行的不是这些 Ubuntu 版本,那么你必须升级到较新版本。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-19-04-end-of-life/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/End-of-Life-Ubuntu-19.04.png?ssl=1 +[2]: https://itsfoss.com/ubuntu-19-04-release/ +[3]: https://itsfoss.com/apt-get-linux-guide/ +[4]: https://itsfoss.com/which-ubuntu-install/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/ubuntu_19_04_end_of_life.jpg?ssl=1 +[6]: https://itsfoss.com/update-ubuntu/ +[7]: https://itsfoss.com/upgrade-ubuntu-version/ +[8]: https://itsfoss.com/install-ubuntu/ +[9]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ diff --git a/published/202002/20200205 Getting started with GnuCash.md b/published/202002/20200205 Getting started with GnuCash.md new file mode 100644 index 0000000000..00dc0465c5 --- /dev/null +++ b/published/202002/20200205 Getting started with GnuCash.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11895-1.html) +[#]: subject: (Getting started with GnuCash) +[#]: via: (https://opensource.com/article/20/2/gnucash) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +开始使用 GnuCash +====== + +> 使用 GnuCash 管理你的个人或小型企业会计。 + +![](https://img.linux.net.cn/data/attachment/album/202002/15/124236wz5e0z5vq7571qby.jpg) + +在过去的四年里,我一直在用 [GnuCash][2] 来管理我的个人财务,我对此非常满意。这个开源(GPL v3)项目自 1998 年首次发布以来一直成长和改进,2019 年 12 月发布的最新版本 3.8 增加了许多改进和 bug 修复。 + +GnuCash 可在 Windows、MacOS 和 Linux 中使用。它实现了一个复式记账系统,并可以导入各种流行的开放和专有文件格式,包括 QIF、QFX、OFX、CSV 等。这使得从其他财务应用转换(包括 Quicken)而来很容易,它是为取代这些而出现的。 + +借助 GnuCash,你可以跟踪个人财务状况以及小型企业会计和开票。它没有集成的工资系统。根据文档,你可以在 GnuCash 中跟踪工资支出,但你必须在该软件外计算税金和扣减。 + +### 安装 + +要在 Linux 上安装 GnuCash: + + * 在 Red Hat、CentOS 或 Fedora 中: `$ sudo dnf install gnucash` + * 在 Debian、Ubuntu 或 Pop_OS 中: `$ sudo apt install gnucash` + +你也可以从 [Flathub][3] 安装它,我在运行 Elementary OS 的笔记本上使用它。(本文中的所有截图都来自此次安装)。 + +### 设置 + +安装并启动程序后,你将看到一个欢迎屏幕,该页面提供了创建新账户集、导入 QIF 文件或打开新用户教程的选项。 + +![GnuCash Welcome screen][4] + +#### 个人账户 + +如果你选择第一个选项(正如我所做的那样),GnuCash 会打开一个页面帮你起步。它收集初始数据并设置账户首选项,例如账户类型和名称、商业数据(例如,税号)和首选货币。 + +![GnuCash new account setup][5] + +GnuCash 支持个人银行账户、商业账户、汽车贷款、CD 和货币市场账户、儿童保育账户等。 + +例如,首先创建一个简单的支票簿。你可以输入账户的初始余额或以多种格式导入现有账户数据。 + +![GnuCash import data][6] + +#### 开票 + +GnuCash 还支持小型企业功能,包括客户、供应商和开票。要创建发票,请在 “Business -> Invoice” 中输入数据。 + +![GnuCash create invoice][7] + +然后,你可以将发票打印在纸上,也可以将其导出到 PDF 并通过电子邮件发送给你的客户。 + +![GnuCash invoice][8] + +### 获取帮助 + +如果你有任何疑问,它有一个优秀的帮助,你可在菜单栏的右侧获取指导。 + +![GnuCash help][9] + +该项目的网站包含许多有用的信息的链接,例如 GnuCash [功能][10]的概述。GnuCash 还提供了[详细的文档][11],可供下载和离线阅读,它还有一个 [wiki][12],为用户和开发人员提供了有用的信息。 + +你可以在项目的 [GitHub][13] 仓库中找到其他文件和文档。GnuCash 项目由志愿者驱动。如果你想参与,请查看项目的 wiki 上的 [Getting involved][14] 部分。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/gnucash + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_whitehurst_money.png?itok=ls-SOzM0 (A dollar sign in a network) +[2]: https://www.gnucash.org/ +[3]: https://flathub.org/apps/details/org.gnucash.GnuCash +[4]: https://opensource.com/sites/default/files/images/gnucash_welcome.png (GnuCash Welcome screen) +[5]: https://opensource.com/sites/default/files/uploads/gnucash_newaccountsetup.png (GnuCash new account setup) +[6]: https://opensource.com/sites/default/files/uploads/gnucash_importdata.png (GnuCash import data) +[7]: https://opensource.com/sites/default/files/uploads/gnucash_enter-invoice.png (GnuCash create invoice) +[8]: https://opensource.com/sites/default/files/uploads/gnucash_invoice.png (GnuCash invoice) +[9]: https://opensource.com/sites/default/files/uploads/gnucash_help.png (GnuCash help) +[10]: https://www.gnucash.org/features.phtml +[11]: https://www.gnucash.org/docs/v3/C/gnucash-help.pdf +[12]: https://wiki.gnucash.org/wiki/GnuCash +[13]: https://github.com/Gnucash +[14]: https://wiki.gnucash.org/wiki/GnuCash#Getting_involved_in_the_GnuCash_project diff --git a/published/202002/20200206 3 ways to use PostgreSQL commands.md b/published/202002/20200206 3 ways to use PostgreSQL commands.md new file mode 100644 index 0000000000..edb92e9144 --- /dev/null +++ b/published/202002/20200206 3 ways to use PostgreSQL commands.md @@ -0,0 +1,218 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11904-1.html) +[#]: subject: (3 ways to use PostgreSQL commands) +[#]: via: (https://opensource.com/article/20/2/postgresql-commands) +[#]: author: (Greg Pittman https://opensource.com/users/greg-p) + +3 种使用 PostgreSQL 命令的方式 +====== + +> 无论你需要的东西简单(如一个购物清单)亦或复杂(如色卡生成器) ,PostgreSQL 命令都能使它变得容易起来。 + +![](https://img.linux.net.cn/data/attachment/album/202002/18/124003twk7fryz2krw2r39.jpg) + +在 [PostgreSQL 入门][2]一文中, 我解释了如何安装、设置和开始使用这个开源数据库软件。不过,使用 [PostgreSQL][3] 中的命令可以做更多事情。 + +例如,我使用 Postgres 来跟踪我的杂货店购物清单。我的大多数杂货店购物是在家里进行的,而且每周进行一次大批量的采购。我去几个不同的地方购买清单上的东西,因为每家商店都提供特定的选品或质量,亦或更好的价格。最初,我制作了一个 HTML 表单页面来管理我的购物清单,但这样无法保存我的输入内容。因此,在想到要购买的物品时我必须马上列出全部清单,然后到采购时我常常会忘记一些我需要或想要的东西。 + +相反,使用 PostgreSQL,当我想到需要的物品时,我可以随时输入,并在购物前打印出来。你也可以这样做。 + +### 创建一个简单的购物清单 + +首先,输入 `psql` 命令进入数据库,然后用下面的命令创建一个表: + +``` +Create table groc (item varchar(20), comment varchar(10)); +``` + +输入如下命令在清单中加入商品: + +``` +insert into groc values ('milk', 'K'); +insert into groc values ('bananas', 'KW'); +``` + +括号中有两个信息(逗号隔开):前面是你需要买的东西,后面字母代表你要购买的地点以及哪些东西是你每周通常都要买的(`W`)。 + +因为 `psql` 有历史记录,你可以按向上键在括号内编辑信息,而无需输入商品的整行信息。 + +在输入一小部分商品后,输入下面命令来检查前面的输入内容。 + +``` +Select * from groc order by comment; + + item | comment +----------------+--------- + ground coffee | H + butter | K + chips | K + steak | K + milk | K + bananas | KW + raisin bran | KW + raclette | L + goat cheese | L + onion | P + oranges | P + potatoes | P + spinach | PW + broccoli | PW + asparagus | PW + cucumber | PW + sugarsnap peas | PW + salmon | S +(18 rows) +``` + +此命令按 `comment` 列对结果进行排序,以便按购买地点对商品进行分组,从而使你的购物更加方便。 + +使用 `W` 来指明你每周要买的东西,当你要清除表单为下周的列表做准备时,你可以将每周的商品保留在购物清单上。输入: + +``` +delete from groc where comment not like '%W'; +``` + +注意,在 PostgreSQL 中 `%` 表示通配符(而非星号)。所以,要保存输入内容,需要输入: + +``` +delete from groc where item like 'goat%'; +``` + +不能使用 `item = 'goat%'`,这样没用。 + +在购物时,用以下命令输出清单并打印或发送到你的手机: + +``` +\o groclist.txt +select * from groc order by comment; +\o +``` + +最后一个命令 `\o` 后面没有任何内容,将重置输出到命令行。否则,所有的输出会继续输出到你创建的杂货店购物文件 `groclist.txt` 中。 + +### 分析复杂的表 + +这个逐项列表对于数据量小的表来说没有问题,但是对于数据量大的表呢?几年前,我帮 [FreieFarbe.de][4] 的团队从 HLC 调色板中创建一个自由色的色样册。事实上,任何能想象到的打印色都可按色调、亮度、浓度(饱和度)来规定。最终结果是 [HLC Color Atlas][5],下面是我们如何实现的。 + +该团队向我发送了具有颜色规范的文件,因此我可以编写可与 Scribus 配合使用的 Python 脚本,以轻松生成色样册。一个例子像这样开始: + +``` +HLC, C, M, Y, K +H010_L15_C010, 0.5, 49.1, 0.1, 84.5 +H010_L15_C020, 0.0, 79.7, 15.1, 78.9 +H010_L25_C010, 6.1, 38.3, 0.0, 72.5 +H010_L25_C020, 0.0, 61.8, 10.6, 67.9 +H010_L25_C030, 0.0, 79.5, 18.5, 62.7 +H010_L25_C040, 0.4, 94.2, 17.3, 56.5 +H010_L25_C050, 0.0, 100.0, 15.1, 50.6 +H010_L35_C010, 6.1, 32.1, 0.0, 61.8 +H010_L35_C020, 0.0, 51.7, 8.4, 57.5 +H010_L35_C030, 0.0, 68.5, 17.1, 52.5 +H010_L35_C040, 0.0, 81.2, 22.0, 46.2 +H010_L35_C050, 0.0, 91.9, 20.4, 39.3 +H010_L35_C060, 0.1, 100.0, 17.3, 31.5 +H010_L45_C010, 4.3, 27.4, 0.1, 51.3 +``` + +这与原始数据相比,稍有修改,原始数据用制表符分隔。我将其转换成 CSV 格式(用逗号分割值),我更喜欢其与 Python 一起使用(CSV 文也很有用,因为它可轻松导入到电子表格程序中)。 + +在每一行中,第一项是颜色名称,其后是其 C、M、Y 和 K 颜色值。 该文件包含 1,793 种颜色,我想要一种分析信息的方法,以了解这些值的范围。这就是 PostgreSQL 发挥作用的地方。我不想手动输入所有数据 —— 我认为输入过程中我不可能不出错,而且令人头痛。幸运的是,PostgreSQL 为此提供了一个命令。 + +首先用以下命令创建数据库: + +``` +Create table hlc_cmyk (color varchar(40), c decimal, m decimal, y decimal, k decimal); +``` + +然后通过以下命令引入数据: + +``` +\copy hlc_cmyk from '/home/gregp/HLC_Atlas_CMYK_SampleData.csv' with (header, format CSV); +``` + +开头有反斜杠,是因为使用纯 `copy` 命令的权限仅限于 root 用户和 Postgres 的超级用户。在括号中,`header` 表示第一行包含标题,应忽略,`CSV` 表示文件格式为 CSV。请注意,在此方法中,颜色名称不需要用括号括起来。 + +如果操作成功,会看到 `COPY NNNN`,其中 N 表示插入到表中的行数。 + +最后,可以用下列命令查询: + +``` +select * from hlc_cmyk; + + color | c | m | y | k +---------------+-------+-------+-------+------ + H010_L15_C010 | 0.5 | 49.1 | 0.1 | 84.5 + H010_L15_C020 | 0.0 | 79.7 | 15.1 | 78.9 + H010_L25_C010 | 6.1 | 38.3 | 0.0 | 72.5 + H010_L25_C020 | 0.0 | 61.8 | 10.6 | 67.9 + H010_L25_C030 | 0.0 | 79.5 | 18.5 | 62.7 + H010_L25_C040 | 0.4 | 94.2 | 17.3 | 56.5 + H010_L25_C050 | 0.0 | 100.0 | 15.1 | 50.6 + H010_L35_C010 | 6.1 | 32.1 | 0.0 | 61.8 + H010_L35_C020 | 0.0 | 51.7 | 8.4 | 57.5 + H010_L35_C030 | 0.0 | 68.5 | 17.1 | 52.5 +``` + + +所有的 1,793 行数据都是这样的。回想起来,我不能说此查询对于 HLC 和 Scribus 任务是绝对必要的,但是它减轻了我对该项目的一些担忧。 + +为了生成 HLC 色谱,我使用 Scribus 为色板页面中的 13,000 多种颜色自动创建了颜色图表。 + +我可以使用 `copy` 命令输出数据: + +``` +\copy hlc_cmyk to '/home/gregp/hlc_cmyk_backup.csv' with (header, format CSV); +``` + +我还可以使用 `where` 子句根据某些值来限制输出。 + +例如,以下命令将仅发送以 `H10` 开头的色调值。 + +``` +\copy hlc_cmyk to '/home/gregp/hlc_cmyk_backup.csv' with (header, format CSV) where color like 'H10%'; +``` + +### 备份或传输数据库或表 + +我在此要提到的最后一个命令是 `pg_dump`,它用于备份 PostgreSQL 数据库,并在 `psql` 控制台之外运行。 例如: + +``` +pg_dump gregp -t hlc_cmyk > hlc.out +pg_dump gregp > dball.out +``` + +第一行是导出 `hlc_cmyk` 表及其结构。第二行将转储 `gregp` 数据库中的所有表。这对于备份或传输数据库或表非常有用。 + +要将数据库或表传输到另一台电脑(查看 [PostgreSQL 入门][2]那篇文章获取详细信息),首先在要转入的电脑上创建一个数据库,然后执行相反的操作。 + +``` +psql -d gregp -f dball.out +``` + +一步创建所有表并输入数据。 + +### 总结 + +在本文中,我们了解了如何使用 `WHERE` 参数限制操作,以及如何使用 PostgreSQL 通配符 `%`。我们还了解了如何将大批量数据加载到表中,然后将部分或全部表数据输出到文件,甚至是将整个数据库及其所有单个表输出。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/postgresql-commands + +作者:[Greg Pittman][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/todo_checklist_team_metrics_report.png?itok=oB5uQbzf (Team checklist and to dos) +[2]: https://linux.cn/article-11593-1.html +[3]: https://www.postgresql.org/ +[4]: http://freiefarbe.de +[5]: https://www.freiefarbe.de/en/thema-farbe/hlc-colour-atlas/ diff --git a/published/202002/20200207 Best Open Source eCommerce Platforms to Build Online Shopping Websites.md b/published/202002/20200207 Best Open Source eCommerce Platforms to Build Online Shopping Websites.md new file mode 100644 index 0000000000..ae38ffcddd --- /dev/null +++ b/published/202002/20200207 Best Open Source eCommerce Platforms to Build Online Shopping Websites.md @@ -0,0 +1,186 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11884-1.html) +[#]: subject: (Best Open Source eCommerce Platforms to Build Online Shopping Websites) +[#]: via: (https://itsfoss.com/open-source-ecommerce/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +7 个可用于自建电商站点的开源解决方案 +====== + +在[之前的文章][1]中,我介绍过一些开源内容管理系统Content Management System(CMS),顾名思义,这些 CMS 平台更适用于以内容为主的站点。 + +那如果想要建立自己的线上购物站点呢?我们正好还有一些优秀的开源电商解决方案,可以自行部署在自己的 Linux 服务器上。 + +这些电商解决方案是专为搭建线上购物站点设计的,因此都集成了库存管理、商品列表、购物车、下单、愿望清单以及支付这些必需的基础功能。 + +但请注意,这篇文章并不会进行深入介绍。因此,我建议最好广泛试用其中的多个产品,以便进一步的了解和比较。 + +### 优秀的开源电商解决方案 + +![][2] + +开源电商解决方案种类繁多,一些缺乏维护的都会被我们忽略掉,以免搭建出来的站点因维护不及时而受到影响。 + +另外,以下的列表排名不分先后。 + +#### 1、nopCommerce + +![][3] + +nopCommerce 是基于 [ASP.NET Core][4] 的自由开源的电商解决方案。如果你要找的是基于 PHP 的解决方案,可以跳过这一节了。 + +nopCommerce 的管理面板界面具有简洁易用的特点,如果你还使用过 OpenCart,就可能会感到似曾相识(我不是在抱怨)。在默认情况下,它就已经自带了很多基本的功能,同时还为移动端用户提供了响应式的设计。 + +你可以在其[官方商店][5]中获取到一些兼容的界面主题和应用扩展,还可以选择付费的支持服务。 + +在开始使用前,你可以从 nopCommerce 的[官方网站][6]下载源代码包,然后进行自定义配置和部署;也可以直接下载完整的软件包快速安装到 web 服务器上。详细信息可以查阅 nopCommerce 的 [GitHub 页面][7]或官方网站。 + +- [nopCommerce][8] + +#### 2、OpenCart + +![][9] + +OpenCart 是一个基于 PHP 的非常流行的电商解决方案,就我个人而言,我曾为一个项目用过它,并且体验非常好,如果不是最好的话。 + +或许你会觉得它维护得不是很频繁,但实际上使用 OpenCart 的开发者并不在少数。你可以获得许多受支持的扩展并将它们的功能加入到 OpenCart 中。 + +OpenCart 不一定是适合所有人的“现代”电商解决方案,但如果你需要的只是一个基于 PHP 的开源解决方案,OpenCart 是个值得一试的选择。在大多数具有一键式应用程序安装支持的网络托管平台中,应该可以安装 OpenCart。想要了解更多,可以查阅 OpenCart 的官方网站或 [GitHub 页面][10]。 + +- [OpenCart][11] + +#### 3、PrestaShop + +![][12] + +PrestaShop 也是一个可以尝试的开源电商解决方案。 + +PrestaShop 是一个积极维护下的开源解决方案,它的官方商店中也有额外提供主题和扩展。与 OpenCart 不同,在托管服务平台上,你可能找不到一键安装的 PrestaShop。但不需要担心,从官方网站下载下来之后,它的部署过程也并不复杂。如果你需要帮助,也可以参考 PrestaShop 的[安装指南][15]。 + +PrestaShop 的特点就是配置丰富和易于使用,我发现很多其它用户也在用它,你也不妨试用一下。 + +你也可以在 PrestaShop 的 [GitHub 页面][16]查阅到更多相关内容。 + +- [PrestaShop][17] + +#### 4、WooCommerce + +![][18] + +如果你想用 [WordPress][19] 来搭建电商站点,不妨使用 WooCommerce。 + +从技术上来说,这种方式其实是搭建一个 WordPress 应用,然后把 WooCommerce 作为一个插件或扩展以实现电商站点所需要的功能。很多 web 开发者都知道如何使用 WordPress,因此 WooCommerce 的学习成本不会很高。 + +WordPress 作为目前最好的开源站点项目之一,对大部分人来说都不会有太高的门槛。它具有易用、稳定的特点,同时还支持大量的扩展插件。 + +WooCommerce 的灵活性也是一大亮点,在它的线上商店提供了许多设计和扩展可供选择。你也可以到它的 [GitHub 页面][20]查看相关介绍。 + +- [WooCommerce][21] + +#### 5、Zen Cart + +![][22] + +这或许是一个稍显古老的电商解决方案,但同时也是最好的开源解决方案之一。如果你喜欢老式风格的模板(主要基于 HTML),而且只需要一些基础性的扩展,那你也可以尝试使用 Zen Cart。 + +就我个人而言,我不建议把 Zen Cart 用在一个新项目当中。但考虑到它仍然是一个活跃更新中的解决方案,如果你喜欢的话,也不妨用它来进行试验。 + +你也可以在 [SourceForge][23] 找到 Zen Cart 这个项目。 + +- [Zen Cart][24] + +#### 6、Magento + +![Image Credits: Magestore][25] + +Magento 是 Abode 旗下的开源电商解决方案,从某种角度来说,可能比 WordPress 表现得更为优秀。 + +Magento 完全是作为电商应用程序而生的,因此你会发现它的很多基础功能都非常好用,甚至还提供了高级的定制。 + +但如果你使用的是 Magento 的开源版,可能会接触不到托管版的一些高级功能,两个版本的差异,可以在[官方文档][26]中查看到。如果你使用托管版,还可以选择相关的托管支持服务。 + +想要了解更多,可以查看 Magento 的 [GitHub 页面][27]。 + +- [Magento][28] + +#### 7、Drupal + +![Drupal][29] + +Drupal 是一个适用于创建电商站点的开源 CMS 解决方案。 + +我没有使用过 Drupal,因此我不太确定它用起来是否足够灵活。但从它的官方网站上来看,它提供的扩展模块和主题列表,足以让你轻松完成一个电商站点需要做的任何事情。 + +跟 WordPress 类似,Drupal 在服务器上的部署并不复杂,不妨看看它的使用效果。在它的[下载页面][30]可以查看这个项目以及下载最新的版本。 + +- [Drupal][31] + +#### 8、Odoo eCommerce + +![Odoo Ecommerce Platform][32] + +如果你还不知道,Odoo 提供了一套开源商务应用程序。他们还提供了[开源会计软件][33]和 CRM 解决方案,我们将会在单独的列表中进行介绍。 + +对于电子商务门户,你可以根据需要使用其在线拖放生成器自定义网站。你也可以推广该网站。除了简单的主题安装和自定义选项之外,你还可以利用 HTML/CSS 在一定程度上手动自定义外观。 + +你也可以查看其 [GitHub][34] 页面以进一步了解它。 + +- [Odoo eCommerce][35] + +### 总结 + +我敢肯定还有更多的开源电子商务平台,但是,我现在还没有遇到比我上面列出的更好的东西。 + +如果你还有其它值得一提的产品,可以在评论区发表。也欢迎在评论区分享你对开源电商解决方案的经验和想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/open-source-ecommerce/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[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://itsfoss.com/open-source-cms/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/open-source-eCommerce.png?ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/nopCommerce.png?ssl=1 +[4]: https://en.wikipedia.org/wiki/ASP.NET_Core +[5]: https://www.nopcommerce.com/marketplace +[6]: https://www.nopcommerce.com/download-nopcommerce +[7]: https://github.com/nopSolutions/nopCommerce +[8]: https://www.nopcommerce.com/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/opencart.jpg?ssl=1 +[10]: https://github.com/opencart/opencart +[11]: https://www.opencart.com/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/prestashop.jpg?ssl=1 +[13]: https://addons.prestashop.com/en/3-templates-prestashop +[14]: https://addons.prestashop.com/en/ +[15]: http://doc.prestashop.com/display/PS17/Installing+PrestaShop +[16]: https://github.com/PrestaShop/PrestaShop +[17]: https://www.prestashop.com/en +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/woocommerce.jpg?ssl=1 +[19]: https://wordpress.org/ +[20]: https://github.com/woocommerce/woocommerce +[21]: https://woocommerce.com/ +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/Zen-cart.jpg?ssl=1 +[23]: https://sourceforge.net/projects/zencart/ +[24]: https://www.zen-cart.com/ +[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/magento.jpg?ssl=1 +[26]: https://magento.com/compare-open-source-and-magento-commerce +[27]: https://github.com/magento +[28]: https://magento.com/ +[29]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/drupal.png?ssl=1 +[30]: https://www.drupal.org/project/drupal +[31]: https://www.drupal.org/industries/ecommerce +[32]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/odoo-ecommerce-platform.jpg?w=800&ssl=1 +[33]: https://itsfoss.com/open-source-accounting-software/ +[34]: https://github.com/odoo/odoo +[35]: https://www.odoo.com/page/open-source-ecommerce diff --git a/published/202002/20200207 Connect Fedora to your Android phone with GSConnect.md b/published/202002/20200207 Connect Fedora to your Android phone with GSConnect.md new file mode 100644 index 0000000000..80a2884a6f --- /dev/null +++ b/published/202002/20200207 Connect Fedora to your Android phone with GSConnect.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (chai-yuan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11897-1.html) +[#]: subject: (Connect Fedora to your Android phone with GSConnect) +[#]: via: (https://fedoramagazine.org/connect-fedora-to-your-android-phone-with-gsconnect/) +[#]: author: (Lokesh Krishna https://fedoramagazine.org/author/lowkeyskywalker/) + +使用 GSConnect 将 Android 手机连接到 Fedora 系统 +====== + +![][1] + +苹果和微软公司都不同程度的提供了桌面产品与移动设备集成。Fedora 提供了类似甚至更高集成度的工具——GSConnect。它可以让你将安卓手机和你的 Fedora 桌面配对并使用。请继续阅读,以了解更多关于它的情况以及它是如何工作的信息。 + +### GSConnect 是什么? + +GSConnect 是针对 GNOME 桌面定制的 KDE Connect 程序。KDE Connect 可以使你的设备能够互相通信。但是,在 Fedora 默认的 GNOME 桌面上安装它需要安装大量的 KDE 依赖。 + +GSConnect 是一个 KDE Connect 的完整实现,其以 GNOME shell 的拓展形式出现。安装后,GSConnect 允许你执行以下操作及更多: + +* 在计算机上接收电话通知并回复信息 +* 用手机操纵你的桌面 +* 在不同设备之间分享文件与链接 +* 在计算机上查看手机电量 +* 让手机响铃以便你能找到它 + +### 设置 GSConnect 扩展 + +设置 GSConnect 需要安装两个组件:计算机上的 GSConnect 扩展和 Android 设备上的 KDE Connect 应用。 + +首先,从 GNOME Shell 扩展网站上安装 [GSConnect][2] 扩展。(Fedora Magazine 有一篇关于[如何安装 GNOME Shell 扩展][3]的文章,可以帮助你完成这一步。) + +KDE Connect 应用程序可以在 Google 的 [Play 商店][4]上找到。它也可以在 FOSS Android 应用程序库 [F-Droid][5] 上找到。 + +一旦安装了这两个组件,就可以配对两个设备。安装扩展后它在你的系统菜单中显示为“移动设备Mobile Devices”。单击它会出现一个下拉菜单,你可以从中访问“移动设置Mobile Settings”。 + +![][6] + +你可以在这里用 GSConnect 查看并管理已配对的设备。进入此界面后,需要在 Android 设备上启动应用程序。 + +你可以在任意一台设备上进行配对初始化,在这里我们从 Android 设备连接到计算机。点击应用程序上的“刷新”,只要两个设备都在同一个无线网络环境中,你的 Android 设备便可以搜索到你的计算机。现在可以向桌面发送配对请求,并在桌面上接受配对请求以完成配对。 + +![][7] + +### 使用 GSConnect + +配对后,你将需要在 Android 设备授予权限,才能使用 GSConnect 上提供的许多功能。单击设备列表中的已配对设备,便可以查看所有可用功能,并根据你的偏好和需要启用或禁用它们。 + +![][8] + +请记住,你还需要在这个 Android 应用程序中授予相应的权限才能使用这些功能。启用权限后,你现在可以访问桌面上的移动联系人,获得消息通知并回复消息,甚至同步桌面和 Android 设备的剪贴板。 + +### 将你的浏览器与“文件”应用集成 + +GSConnect 允许你直接从计算机上的文件资源管理器的关联菜单向 Android 设备发送文件。 + +在 Fedora 的默认 GNOME 桌面上,你需要安装 `nautilus-python` 依赖包,以便在关联菜单中显示配对的设备。安装此命令非常简单,只需要在你的首选终端运行以下命令: + +``` +$ sudo dnf install nautilus-python +``` + +完成后,将在“文件Files”应用的关联菜单中显示“发送到移动设备Send to Mobile Device”选项。 + +![][9] + +同样,为你的浏览器安装相应的 WebExtension,无论是 [Firefox][10] 还是 [Chrome][11] 浏览器,都可以将链接发送到你的 Android 设备。你可以选择直接发送链接以在浏览器中直接打开,或将其作为短信息发送。 + +### 运行命令 + +GSConnect 允许你定义命令,然后可以从远程设备在计算机上运行这些命令。这使得你可以远程截屏,或者从你的 Android 设备锁定和解锁你的桌面。 + +![][12] + +要使用此功能,可以使用标准的 shell 命令和 GSConnect 提供的 CLI。该项目的 GitHub 存储库(CLI Scripting)中提供了有关此操作的文档。 + +[KDE UserBase Wiki][13] 有一个命令示例列表。这些例子包括控制桌面的亮度和音量、锁定鼠标和键盘,甚至更改桌面主题。其中一些命令是针对 KDE Plasma 设计的,需要进行修改才能在 GNOME 桌面上运行。 + +### 探索并享受乐趣 + +GSConnect 使我们能够享受到极大的便利和舒适。深入研究首选项,查看你可以做的所有事情,灵活的使用这些命令功能发挥创意,并在下面的评论中自由分享你解锁的新方式。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/connect-fedora-to-your-android-phone-with-gsconnect/ + +作者:[Lokesh Krishna][a] +选题:[lujun9972][b] +译者:[chai-yuan](https://github.com/chai-yuan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/lowkeyskywalker/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/12/gsconnect-816x345.jpg +[2]: https://extensions.gnome.org/extension/1319/gsconnect/ +[3]: https://fedoramagazine.org/install-gnome-shell-extension/ +[4]: https://play.google.com/store/apps/details?id=org.kde.kdeconnect_tp +[5]: https://f-droid.org/en/packages/org.kde.kdeconnect_tp/ +[6]: https://fedoramagazine.org/wp-content/uploads/2020/01/within-the-menu-1024x576.png +[7]: https://fedoramagazine.org/wp-content/uploads/2020/01/pair-request-1024x576.png +[8]: https://fedoramagazine.org/wp-content/uploads/2020/01/permissions-1024x576.png +[9]: https://fedoramagazine.org/wp-content/uploads/2020/01/send-to-mobile-2-1024x576.png +[10]: https://addons.mozilla.org/en-US/firefox/addon/gsconnect/ +[11]: https://chrome.google.com/webstore/detail/gsconnect/jfnifeihccihocjbfcfhicmmgpjicaec +[12]: https://fedoramagazine.org/wp-content/uploads/2020/01/commands-1024x576.png +[13]: https://userbase.kde.org/KDE_Connect/Tutorials/Useful_commands +[14]: https://unsplash.com/@pathum_danthanarayana?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[15]: https://unsplash.com/s/photos/android?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202002/20200207 Customize your internet with an open source search engine.md b/published/202002/20200207 Customize your internet with an open source search engine.md new file mode 100644 index 0000000000..ed102d2f0e --- /dev/null +++ b/published/202002/20200207 Customize your internet with an open source search engine.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11905-1.html) +[#]: subject: (Customize your internet with an open source search engine) +[#]: via: (https://opensource.com/article/20/2/open-source-search-engine) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +用开源搜索引擎定制你的互联网 +====== + +> 上手开源的对等 Web 索引器 YaCy。 + +![](https://img.linux.net.cn/data/attachment/album/202002/19/103541la7erglz7oloa4ye.jpg) + +很久以前,互联网很小,小到几个人就可以索引它们,这些人收集了所有网站的名称和链接,并按主题将它们分别列在页面或印刷书籍中。随着万维网网络的发展,形成了“网站环”形式,具有类似的内容、主题或敏感性的站点捆绑在一起,形成了通往每个成员的循环路径。环中任何站点的访问者都可以单击按钮以转到环中的下一个或上一个站点,以发现与其兴趣相关的新站点。 + +又过了一段时间,互联网似乎变得臃肿不堪了。每个人都在网络上,有很多冗余信息和垃圾邮件,多到让你无法找到任何东西。Yahoo 和 AOL、CompuServe 以及类似的服务各自采用了不同的方法来解决这个问题,但是直到谷歌出现后,现代的搜索模型才得以普及。按谷歌的做法,互联网应该通过搜索引擎进行索引、排序和排名。 + +### 为什么选择开源替代品? + +像谷歌和 DuckDuckGo 这样的搜索引擎显然是卓有成效的。你可能是通过搜索引擎访问的本站。尽管对于因主机没有选择遵循优化搜索引擎的最佳实践从而导致会内容陷入困境这件事仍存在争论,但用于管理丰富的文化、知识和轻率的信息(即互联网)的现代解决方案是冷冰冰的索引。 + +但是也许出于隐私方面的考虑,或者你希望为使互联网更加独立而做出贡献,你或许不愿意使用谷歌或 DuckDuckGo。如果你对此感兴趣,那么可以考虑参加 [YaCy][2],这是一个对等互联网索引器和搜索引擎。 + +### 安装 YaCy + +要安装并尝试 YaCy,请首先确保已安装 Java。如果你使用的是 Linux,则可以按照我的《[如何在 Linux 上安装 Java][3]》中的说明进行操作。如果你使用 Windows 或 MacOS,请从 [AdoptOpenJDK.net][4] 获取安装程序。 + +安装 Java 后,请根据你的平台[下载安装程序][5]。 + +如果你使用的是 Linux,请解压缩 tarball 并将其移至 `/opt` 目录: + +``` +$ sudo tar --extract --file  yacy_*z --directory /opt +``` + +根据下载的安装程序的说明启动 YaCy。 + +在 Linux 上,启动在后台运行的 YaCy: + +``` +$ /opt/startYACY.sh & +``` + +在 Web 浏览器中,导航到 `localhost:8090` 并进行搜索。 + +![YaCy start page][6] + +### 将 YaCy 添加到你的地址栏 + +如果你使用的是 Firefox Web 浏览器,则只需单击几下,即可在 Awesome Bar(Mozilla 给 URL 栏起的名称)中将 YaCy 设置为默认搜索引擎。 + +首先,如果尚未显示,在 Firefox 工具栏中使专用搜索栏显示出来(你不必使搜索栏保持一直可见;只需要激活它足够长的时间即可添加自定义搜索引擎)。Firefox 右上角的“汉堡”菜单中的“自定义”菜单中提供了搜索栏。在 Firefox 工具栏上的搜索栏可见后,导航至 `localhost:8090`,然后单击刚添加的 Firefox 搜索栏中的放大镜图标。单击选项将 YaCy 添加到你的 Firefox 的搜索引擎中。 + +![Adding YaCy to Firefox][7] + +完成此操作后,你可以在 Firefox 首选项中将其标记为默认值,或者仅在 Firefox 搜索栏中执行的搜索中选择性地使用它。如果将其设置为默认搜索引擎,则可能不需要专用搜索栏,因为 Awesome Bar 也使用默认引擎,因此可以将其从工具栏中删除。 + +### 对等搜索引擎如何工作 + +YaCy 是一个开源的分布式搜索引擎。它是用 [Java][8] 编写的,因此可以在任何平台上运行,并且可以执行 Web 爬网、索引和搜索。这是一个对等(P2P)网络,因此每个运行 YaCy 的用户都将努力地不断跟踪互联网的变化情况。当然,没有单个用户能拥有整个互联网的完整索引,因为这将需要一个数据中心来容纳,但是该索引分布在所有 YaCy 用户中且是冗余的。它与 BitTorrent 非常相似(因为它使用分布式哈希表 DHT 来引用索引条目),只不过你所共享的数据是单词和 URL 关联的矩阵。通过混合哈希表返回的结果,没人能说出谁搜索了哪些单词,因此所有搜索在功能上都是匿名的。这是用于无偏见、无广告、未跟踪和匿名搜索的有效系统,你只需要使用它就加入了它。 + +### 搜索引擎和算法 + +索引互联网的行为是指将网页分成单个单词,然后将页面的 URL 与每个单词相关联。在搜索引擎中搜索一个或多个单词将获取与该查询关联的所有 URL。YaCy 客户端在运行时也是如此。 + +客户端要做的另一件事是为你的浏览器提供搜索界面。你可以将 Web 浏览器指向 `localhost:8090` 来搜索 YaCy,而不是在要搜索时导航到谷歌。你甚至可以将其添加到浏览器的搜索栏中(取决于浏览器的可扩展性),因此可以从 URL 栏中进行搜索。 + +### YaCy 的防火墙设置 + +首次开始使用 YaCy 时,它可能运行在“初级”模式下。这意味着你的客户端爬网的站点仅对你可用,因为其他 YaCy 客户端无法访问你的索引条目。要加入对等环境,必须在路由器的防火墙(或者你正在运行的软件防火墙)中打开端口 8090,这称为“高级”模式。 + +如果你使用的是 Linux,则可以在《[使用防火墙让你的 Linux 更加强大][9]》中找到有关计算机防火墙的更多信息。在其他平台上,请参考操作系统的文档。 + +互联网服务提供商(ISP)提供的路由器上几乎总是启用了防火墙,并且有太多种类的防火墙无法准确说明。大多数路由器都提供了在防火墙上“打洞”的选项,因为许多流行的联网游戏都需要双向流量。 + +如果你知道如何登录路由器(通常为 192.168.0.1 或 10.1.0.1,但可能因制造商的设置而异),则登录并查找配置面板来控制“防火墙”或“端口转发”或“应用”。 + +找到路由器防火墙的首选项后,将端口 8090 添加到白名单。例如: + +![Adding YaCy to an ISP router][10] + +如果路由器正在进行端口转发,则必须使用相同的端口将传入的流量转发到计算机的 IP 地址。例如: + +![Adding YaCy to an ISP router][11] + +如果由于某种原因无法调整防火墙设置,那也没事。YaCy 将继续以初级模式运行并作为对等搜索网络的客户端运行。 + +### 你的互联网 + +使用 YaCy 搜索引擎可以做的不仅仅是被动搜索。你可以强制抓取不太显眼的网站,可以请求对网站进行网络抓取,可以选择使用 YaCy 进行本地搜索等等。你可以更好地控制*你的*互联网的所呈现的一切。高级用户越多,索引的网站就越多。索引的网站越多,所有用户的体验就越好。加入吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/open-source-search-engine + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://yacy.net/ +[3]: https://linux.cn/article-11614-1.html +[4]: https://adoptopenjdk.net/releases.html +[5]: https://yacy.net/download_installation/ +[6]: https://opensource.com/sites/default/files/uploads/yacy-startpage.jpg (YaCy start page) +[7]: https://opensource.com/sites/default/files/uploads/yacy-add-firefox.jpg (Adding YaCy to Firefox) +[8]: https://opensource.com/resources/java +[9]: https://opensource.com/article/19/7/make-linux-stronger-firewalls +[10]: https://opensource.com/sites/default/files/uploads/router-add-app.jpg (Adding YaCy to an ISP router) +[11]: https://opensource.com/sites/default/files/uploads/router-add-app1.jpg (Adding YaCy to an ISP router) diff --git a/published/202002/20200207 NVIDIA-s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux.md b/published/202002/20200207 NVIDIA-s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux.md new file mode 100644 index 0000000000..4a6e9f660f --- /dev/null +++ b/published/202002/20200207 NVIDIA-s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11888-1.html) +[#]: subject: (NVIDIA’s Cloud Gaming Service GeForce NOW Shamelessly Ignores Linux) +[#]: via: (https://itsfoss.com/geforce-now-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +NVIDIA 的云游戏服务 GeForce NOW 无耻地忽略了Linux +====== + +NVIDIA 的 [GeForce NOW][1] 云游戏服务对于那些可能没有硬件但想使用 GeForce NOW 在最新的最好的游戏上获得尽可能好的游戏体验玩家来说是充满前景的(在线推流游戏,并可以在任何设备上玩)。 + +该服务仅限于一些用户(以等待列表的形式)使用。然而,他们最近宣布 [GeForce NOW 面向所有人开放][2]。但实际上并不是。 + +有趣的是,它**并不是面向全球所有区域**。而且,更糟的是 **GeForce NOW 不支持 Linux**。 + +![][3] + +### GeForce NOW 并不是向“所有人开放” + +制作一个基于订阅的云服务来玩游戏的目的是消除平台依赖性。 + +就像你通常使用浏览器访问网站一样,你应该能够在每个平台上玩游戏。是这个概念吧? + +![][4] + +好吧,这绝对不是火箭科学,但是 NVIDIA 仍然不支持 Linux(和 iOS)? + +### 是因为没有人使用 Linux 吗? + +我非常不同意这一点,即使这是某些不支持 Linux 的原因。如果真是这样,我不会使用 Linux 作为主要桌面操作系统来为 “It’s FOSS” 写文章。 + +不仅如此,如果 Linux 不值一提,你认为为何一个 Twitter 用户会提到缺少 Linux 支持? + +![][5] + +是的,也许用户群不够大,但是在考虑将其作为基于云的服务时,**不支持 Linux** 显得没有意义。 + +从技术上讲,如果 Linux 上没有游戏,那么 **Valve** 就不会在 Linux 上改进 [Steam Play][6] 来帮助更多用户在 Linux 上玩纯 Windows 的游戏。 + +我不想说任何不正确的说法,但台式机 Linux 游戏的发展比以往任何时候都要快(即使统计上要比 Mac 和 Windows 要低)。 + +### 云游戏不应该像这样 + +![][7] + +如上所述,找到使用 Steam Play 的 Linux 玩家不难。只是你会发现 Linux 上游戏玩家的整体“市场份额”低于其他平台。 + +即使这是事实,云游戏也不应该依赖于特定平台。而且,考虑到 GeForce NOW 本质上是一种基于浏览器的可以玩游戏的流媒体服务,所以对于像 NVIDIA 这样的大公司来说,支持 Linux 并不困难。 + +来吧,Nvidia,*你想要我们相信在技术上支持 Linux 有困难?或者,你只是想说不值得支持 Linux 平台?* + +### 结语 + +不管我为 GeForce NOW 服务发布而感到多么兴奋,当看到它根本不支持 Linux,我感到非常失望。 + +如果像 GeForce NOW 这样的云游戏服务在不久的将来开始支持 Linux,**你可能没有理由使用 Windows 了**(*咳嗽*)。 + +你怎么看待这件事?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/geforce-now-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://www.nvidia.com/en-us/geforce-now/ +[2]: https://blogs.nvidia.com/blog/2020/02/04/geforce-now-pc-gaming/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/nvidia-geforce-now-linux.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/nvidia-geforce-now.png?ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/geforce-now-twitter-1.jpg?ssl=1 +[6]: https://itsfoss.com/steam-play/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/ge-force-now.jpg?ssl=1 diff --git a/published/202002/20200207 What is WireGuard- Why Linux Users Going Crazy Over it.md b/published/202002/20200207 What is WireGuard- Why Linux Users Going Crazy Over it.md new file mode 100644 index 0000000000..56b1584ee1 --- /dev/null +++ b/published/202002/20200207 What is WireGuard- Why Linux Users Going Crazy Over it.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11916-1.html) +[#]: subject: (What is WireGuard? Why Linux Users Going Crazy Over it?) +[#]: via: (https://itsfoss.com/wireguard/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +什么是 WireGuard?为什么 Linux 用户为它疯狂? +====== + +从普通的 Linux 用户到 Linux 创建者 [Linus Torvalds][1],每个人都对 WireGuard 很感兴趣。什么是 WireGuard,它为何如此特别? + +### 什么是 WireGuard? + +![][2] + +[WireGuard][3] 是一个易于配置、快速且安全的开源 [VPN][4],它利用了最新的加密技术。目的是提供一种更快、更简单、更精简的通用 VPN,它可以轻松地在树莓派这类低端设备到高端服务器上部署。 + +[IPsec][5] 和 OpenVPN 等大多数其他解决方案是几十年前开发的。安全研究人员和内核开发人员 Jason Donenfeld 意识到它们速度慢且难以正确配置和管理。 + +这让他创建了一个新的开源 VPN 协议和解决方案,它更加快速、安全、易于部署和管理。 + +WireGuard 最初是为 Linux 开发的,但现在可用于 Windows、macOS、BSD、iOS 和 Android。它仍在活跃开发中。 + +### 为什么 WireGuard 如此受欢迎? + +![][6] + +除了可以跨平台之外,WireGuard 的最大优点之一就是易于部署。配置和部署 WireGuard 就像配置和使用 SSH 一样容易。 + +看看 [WireGuard 设置指南][7]。安装 WireGuard、生成公钥和私钥(像 SSH 一样),设置防火墙规则并启动服务。现在将它和 [OpenVPN 设置指南][8]进行比较——有太多要做的了。 + +WireGuard 的另一个好处是它有一个仅 4000 行代码的精简代码库。将它与 [OpenVPN][9](另一个流行的开源 VPN)的 100,000 行代码相比。显然,调试 WireGuard 更加容易。 + +不要因其简单而小看它。WireGuard 支持所有最新的加密技术,例如 [Noise 协议框架][10]、[Curve25519][11]、[ChaCha20][12]、[Poly1305][13]、[BLAKE2][14]、[SipHash24][15]、[HKDF][16] 和安全受信任结构。 + +由于 WireGuard 运行在[内核空间][17],因此可以高速提供安全的网络。 + +这些是 WireGuard 越来越受欢迎的一些原因。Linux 创造者 Linus Torvalds 非常喜欢 WireGuard,以至于将其合并到 [Linux Kernel 5.6][18] 中: + +> 我能否再次声明对它的爱,并希望它能很快合并?也许代码不是完美的,但我不在乎,与 OpenVPN 和 IPSec 的恐怖相比,这是一件艺术品。 +> +> Linus Torvalds + +### 如果 WireGuard 已经可用,那么将其包含在 Linux 内核中有什么大惊小怪的? + +这可能会让新的 Linux 用户感到困惑。你知道可以在 Linux 上安装和配置 WireGuard VPN 服务器,但同时也会看到 Linux Kernel 5.6 将包含 WireGuard 的消息。让我向您解释。 + +目前,你可以将 WireGuard 作为[内核模块][19]安装在 Linux 中。而诸如 VLC、GIMP 等常规应用安装在 Linux 内核之上(在 [用户空间][20]中),而不是内部。 + +当将 WireGuard 安装为内核模块时,基本上需要你自行修改 Linux 内核并向其添加代码。从 5.6 内核开始,你无需手动添加内核模块。默认情况下它将包含在内核中。 + +在 5.6 内核中包含 WireGuard 很有可能[扩展 WireGuard 的采用,从而改变当前的 VPN 场景][21]。 + +### 总结 + +WireGuard 之所以受欢迎是有充分理由的。诸如 [Mullvad VPN][23] 之类的一些流行的[关注隐私的 VPN][22] 已经在使用 WireGuard,并且在不久的将来,采用率可能还会增长。 + +希望你对 WireGuard 有所了解。与往常一样,欢迎提供反馈。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/wireguard/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/linus-torvalds-facts/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/wireguard.png?ssl=1 +[3]: https://www.wireguard.com/ +[4]: https://en.wikipedia.org/wiki/Virtual_private_network +[5]: https://en.wikipedia.org/wiki/IPsec +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/wireguard-logo.png?ssl=1 +[7]: https://www.linode.com/docs/networking/vpn/set-up-wireguard-vpn-on-ubuntu/ +[8]: https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-ubuntu-16-04 +[9]: https://openvpn.net/ +[10]: https://noiseprotocol.org/ +[11]: https://cr.yp.to/ecdh.html +[12]: https://cr.yp.to/chacha.html +[13]: https://cr.yp.to/mac.html +[14]: https://blake2.net/ +[15]: https://131002.net/siphash/ +[16]: https://eprint.iacr.org/2010/264 +[17]: http://www.linfo.org/kernel_space.html +[18]: https://itsfoss.com/linux-kernel-5-6/ +[19]: https://wiki.archlinux.org/index.php/Kernel_module +[20]: http://www.linfo.org/user_space.html +[21]: https://www.zdnet.com/article/vpns-will-change-forever-with-the-arrival-of-wireguard-into-linux/ +[22]: https://itsfoss.com/best-vpn-linux/ +[23]: https://mullvad.net/en/ diff --git a/published/202002/20200210 Install All Essential Media Codecs in Ubuntu With This Single Command -Beginner-s Tip.md b/published/202002/20200210 Install All Essential Media Codecs in Ubuntu With This Single Command -Beginner-s Tip.md new file mode 100644 index 0000000000..5c6d5e90ea --- /dev/null +++ b/published/202002/20200210 Install All Essential Media Codecs in Ubuntu With This Single Command -Beginner-s Tip.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11906-1.html) +[#]: subject: (Install All Essential Media Codecs in Ubuntu With This Single Command [Beginner’s Tip]) +[#]: via: (https://itsfoss.com/install-media-codecs-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +一条命令在 Ubuntu 中安装所有基本的媒体编解码器 +====== + +如果你刚刚安装了 Ubuntu 或其他 [Ubuntu 特色版本][1] 如 Kubuntu、Lubuntu 等,你会注意到系统无法播放某些音频或视频文件。 + +对于视频文件,你可以[在 Ubuntu 上安装 VLC][2]。[VLC][3] 是 [Linux 上的最佳视频播放器][4]之一,它几乎可以播放任何视频文件格式。但你仍然会遇到无法播放音频和 flash 的麻烦。 + +好消息是 [Ubuntu][5] 提供了一个软件包来安装所有基本的媒体编解码器:ubuntu-restricted-extras。 + +![][6] + +### 什么是 Ubuntu Restricted Extras? + +ubuntu-restricted-extras 是一个包含各种基本软件,如 Flash 插件、[unrar][7]、[gstreamer][8]、mp4、[Ubuntu 中的 Chromium 浏览器][9]的编解码器等的软件包。 + +由于这些软件不是开源软件,并且其中一些涉及软件专利,因此 Ubuntu 默认情况下不会安装它们。你必须使用 multiverse 仓库,它是 Ubuntu 专门为用户提供非开源软件而创建的仓库。 + +请阅读本文以[了解有关各种 Ubuntu 仓库的更多信息][10]。 + +### 如何安装 Ubuntu Restricted Extras? + +令我惊讶的是,我发现软件中心未列出 Ubuntu Restricted Extras。不管怎样,你都可以使用命令行安装该软件包,这非常简单。 + +在菜单中搜索或使用[终端键盘快捷键 Ctrl+Alt+T][11] 打开终端。 + +由于 ubuntu-restrcited-extras 软件包在 multiverse 仓库中,因此你应验证系统上已启用 multiverse 仓库: + +``` +sudo add-apt-repository multiverse +``` + +然后你可以使用以下命令安装: + +``` +sudo apt install ubuntu-restricted-extras +``` + +输入回车后,你会被要求输入密码,**当你输入密码时,屏幕不会有显示**。这是正常的。输入你的密码并回车。 + +它将显示大量要安装的包。按回车确认选择。 + +你会看到 [EULA][12](最终用户许可协议),如下所示: + +![Press Tab key to select OK and press Enter key][13] + +浏览此页面可能会很麻烦,但是请放心。只需按 Tab 键,它将高亮选项。当高亮在正确的选项上,按下回车确认你的选择。 + +![Press Tab key to highlight Yes and press Enter key][14] + +安装完成后,由于新安装的媒体编解码器,你应该可以播放 MP3 和其他媒体格式了。 + +##### 在 Kubuntu、Lubuntu、Xubuntu 上安装受限制的额外软件包 + +请记住,Kubuntu、Lubuntu 和 Xubuntu 都有此软件包,并有各自不同的名称。它们本应使用相同的名字,但不幸的是并不是。 + +在 Kubuntu 上,使用以下命令: + +``` +sudo apt install kubuntu-restricted-extras +``` + +在 Lubuntu 上,使用: + +``` +sudo apt install lubuntu-restricted-extras +``` + +在 Xubuntu 上,你应该使用: + +``` +sudo apt install xubuntu-restricted-extras +``` + +我一直建议将 ubuntu-restricted-extras 作为[安装 Ubuntu 后要做的基本事情][15]之一。只需一个命令即可在 Ubuntu 中安装多个编解码器。 + +希望你喜欢 Ubuntu 初学者系列中这一技巧。以后,我将分享更多此类技巧。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-media-codecs-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/which-ubuntu-install/ +[2]: https://itsfoss.com/install-latest-vlc/ +[3]: https://www.videolan.org/index.html +[4]: https://itsfoss.com/video-players-linux/ +[5]: https://ubuntu.com/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/Media_Codecs_in_Ubuntu.png?ssl=1 +[7]: https://itsfoss.com/use-rar-ubuntu-linux/ +[8]: https://gstreamer.freedesktop.org/ +[9]: https://itsfoss.com/install-chromium-ubuntu/ +[10]: https://itsfoss.com/ubuntu-repositories/ +[11]: https://itsfoss.com/ubuntu-shortcuts/ +[12]: https://en.wikipedia.org/wiki/End-user_license_agreement +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/installing_ubuntu_restricted_extras.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/installing_ubuntu_restricted_extras_1.jpg?ssl=1 +[15]: https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/ diff --git a/published/202002/20200210 Playing Music on your Fedora Terminal with MPD and ncmpcpp.md b/published/202002/20200210 Playing Music on your Fedora Terminal with MPD and ncmpcpp.md new file mode 100644 index 0000000000..b78452578b --- /dev/null +++ b/published/202002/20200210 Playing Music on your Fedora Terminal with MPD and ncmpcpp.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (chai-yuan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11909-1.html) +[#]: subject: (Playing Music on your Fedora Terminal with MPD and ncmpcpp) +[#]: via: (https://fedoramagazine.org/playing-music-on-your-fedora-terminal-with-mpd-and-ncmpcpp/) +[#]: author: (Carmine Zaccagnino https://fedoramagazine.org/author/carzacc/) + +在你的 Fedora 终端上播放音乐 +====== + +![][1] + +MPD(Music Playing Daemon),顾名思义,是一个音乐(Music)播放(Playing)守护进程(Daemon)。它可以播放音乐,并且作为一个守护进程,任何软件都可以与之交互并播放声音,包括一些 CLI 客户端。 + +其中一个被称为 `ncmpcpp`,它是对之前 `ncmpc` 工具的改进。名字的变化与编写它们的语言没有太大关系:都是 C++,而之所以被称为 `ncmpcpp`,因为它是 “NCurses Music Playing Client Plus Plus”。 缘故 + +### 安装 MPD 和 ncmpcpp + +`ncmpmpcc` 的客户端可以从官方 Fedora 库中通过 `dnf` 命令直接安装。 + +``` +$ sudo dnf install ncmpcpp +``` + +另一方面,MPD 必须从 RPMFusion free 库安装,你可以通过运行: + +``` +$ sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm +``` + +然后你可以运行下面的命令安装它: + +``` +$ sudo dnf install mpd +``` + +### 配置并启用 MPD + +设置 MPD 最简单的方法是以普通用户的身份运行它。默认情况是以专用 `mpd` 用户的身份运行它,但这会导致各种权限问题。 + +在运行它之前,我们需要创建一个本地配置文件,允许我们作为普通用户运行。 + +首先在 `~/.config` 里创建一个名叫 `mpd` 的目录: + +``` +$ mkdir ~/.config/mpd +``` + +将配置文件拷贝到此目录下: + +``` +$ cp /etc/mpd.conf ~/.config/mpd +``` + +然后用 `vim`、`nano` 或 `gedit` 之类的软件编辑它: + +``` +$ nano ~/.config/mpd/mpd.conf +``` + +我建议你通读所有内容,检查是否有任何需要做的事情,但对于大多数设置你都可以删除,只需保留以下内容: + +``` +db_file "~/.config/mpd/mpd.db" +log_file "syslog" +``` + +现在你可以运行它了: + +``` +$ mpd +``` + +没有报错,这将在后台启动 MPD 守护进程。 + +### 使用 ncmpcpp + +只需运行: + +``` +$ ncmpcpp +``` + +你将在终端中看到一个由 ncurses 所支持的图形用户界面。 + +按下 `4` 键,然后就可以看到本地的音乐目录,用方向键进行选择并按下回车进行播放。 + +多播放几个歌曲就会创建一个*播放列表*,让你可以使用 `>` 键(不是右箭头, 是右尖括号)移动到下一首,并使用 `<` 返回上一首。`+` 和 `–` 键可以调节音量。`Q` 键可以让你退出 `ncmpcpp` 但不停止播放音乐。你可以按下 `P` 来控制暂停和播放。 + +你可以按下 `1` 键来查看当前播放列表(这是默认的视图)。从这个视图中,你可以按 `i` 查看有关当前歌曲的信息(标签)。按 `6` 可更改当前歌曲的标签。 + +按 `\` 按钮将在视图顶部添加(或删除)信息面板。在左上角,你可以看到如下的内容: + +``` +[------] +``` + +按下 `r`、`z`、`y`、`R`、`x` 将会分别切换到 `repeat`、`random`、`single`、`consume` 和 `crossfade` 等播放模式,并将这个小指示器中的 `–` 字符替换为选定模式。 + +按下 `F1` 键将会显示一些帮助文档,包含一系列的键绑定列表,因此无需在此处列出完整列表。所以继续吧!做一个极客,在你的终端上播放音乐! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/playing-music-on-your-fedora-terminal-with-mpd-and-ncmpcpp/ + +作者:[Carmine Zaccagnino][a] +选题:[lujun9972][b] +译者:[chai-yuan](https://github.com/chai-yuan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/carzacc/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/02/play_music_mpd-816x346.png +[2]: https://rpmfusion.org/Configuration diff --git a/published/202002/20200210 Scan Kubernetes for errors with KRAWL.md b/published/202002/20200210 Scan Kubernetes for errors with KRAWL.md new file mode 100644 index 0000000000..22fcd2a098 --- /dev/null +++ b/published/202002/20200210 Scan Kubernetes for errors with KRAWL.md @@ -0,0 +1,220 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11936-1.html) +[#]: subject: (Scan Kubernetes for errors with KRAWL) +[#]: via: (https://opensource.com/article/20/2/kubernetes-scanner) +[#]: author: (Abhishek Tamrakar https://opensource.com/users/tamrakar) + +使用 KRAWL 扫描 Kubernetes 错误 +====== + +> 用 KRAWL 脚本来识别 Kubernetes Pod 和容器中的错误。 + +![Ship captain sailing the Kubernetes seas][1] + +当你使用 Kubernetes 运行容器时,你通常会发现它们堆积在一起。这是设计使然。它是容器的优点之一:每当需要新的容器时,它们启动成本都很低。你可以使用前端工具(如 OpenShift 或 OKD)来管理 Pod 和容器。这些工具使可视化设置变得容易,并且它具有一组丰富的用于快速交互的命令。 + +如果管理容器的平台不符合你的要求,你也可以仅使用 Kubernetes 工具链获取这些信息,但这需要大量命令才能全面了解复杂环境。出于这个原因,我编写了 [KRAWL][2],这是一个简单的脚本,可用于扫描 Kubernetes 集群命名空间下的 Pod 和容器,并在发现任何事件时,显示事件的输出。它也可用作为 Kubernetes 插件使用。这是获取大量有用信息的快速简便方法。 + +### 先决条件 + + * 必须安装 `kubectl`。 + * 集群的 kubeconfig 配置必须在它的默认位置(`$HOME/.kube/config`)或已被导出到环境变量(`KUBECONFIG=/path/to/kubeconfig`)。 + +### 使用 + + +``` +$ ./krawl +``` + +![KRAWL script][3] + +### 脚本 + + +``` +#!/bin/bash +# AUTHOR: Abhishek Tamrakar +# EMAIL: abhishek.tamrakar08@gmail.com +# LICENSE: Copyright (C) 2018 Abhishek Tamrakar +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +## +#define the variables +KUBE_LOC=~/.kube/config +#define variables +KUBECTL=$(which kubectl) +GET=$(which egrep) +AWK=$(which awk) +red=$(tput setaf 1) +normal=$(tput sgr0) +# define functions + +# wrapper for printing info messages +info() +{ + printf '\n\e[34m%s\e[m: %s\n' "INFO" "$@" +} + +# cleanup when all done +cleanup() +{ + rm -f results.csv +} + +# just check if the command we are about to call is available +checkcmd() +{ + #check if command exists + local cmd=$1 + if [ -z "${!cmd}" ] + then + printf '\n\e[31m%s\e[m: %s\n' "ERROR" "check if $1 is installed !!!" + exit 1 + fi +} + +get_namespaces() +{ + #get namespaces + namespaces=( \ + $($KUBECTL get namespaces --ignore-not-found=true | \ + $AWK '/Active/ {print $1}' \ + ORS=" ") \ + ) +#exit if namespaces are not found +if [ ${#namespaces[@]} -eq 0 ] +then + printf '\n\e[31m%s\e[m: %s\n' "ERROR" "No namespaces found!!" + exit 1 +fi +} + +#get events for pods in errored state +get_pod_events() +{ + printf '\n' + if [ ${#ERRORED[@]} -ne 0 ] + then + info "${#ERRORED[@]} errored pods found." + for CULPRIT in ${ERRORED[@]} + do + info "POD: $CULPRIT" + info + $KUBECTL get events \ + --field-selector=involvedObject.name=$CULPRIT \ + -ocustom-columns=LASTSEEN:.lastTimestamp,REASON:.reason,MESSAGE:.message \ + --all-namespaces \ + --ignore-not-found=true + done + else + info "0 pods with errored events found." + fi +} + +#define the logic +get_pod_errors() +{ + printf "%s %s %s\n" "NAMESPACE,POD_NAME,CONTAINER_NAME,ERRORS" > results.csv + printf "%s %s %s\n" "---------,--------,--------------,------" >> results.csv + for NAMESPACE in ${namespaces[@]} + do + while IFS=' ' read -r POD CONTAINERS + do + for CONTAINER in ${CONTAINERS//,/ } + do + COUNT=$($KUBECTL logs --since=1h --tail=20 $POD -c $CONTAINER -n $NAMESPACE 2>/dev/null| \ + $GET -c '^error|Error|ERROR|Warn|WARN') + if [ $COUNT -gt 0 ] + then + STATE=("${STATE[@]}" "$NAMESPACE,$POD,$CONTAINER,$COUNT") + else + #catch pods in errored state + ERRORED=($($KUBECTL get pods -n $NAMESPACE --no-headers=true | \ + awk '!/Running/ {print $1}' ORS=" ") \ + ) + fi + done + done< <($KUBECTL get pods -n $NAMESPACE --ignore-not-found=true -o=custom-columns=NAME:.metadata.name,CONTAINERS:.spec.containers[*].name --no-headers=true) + done + printf "%s\n" ${STATE[@]:-None} >> results.csv + STATE=() +} +#define usage for seprate run +usage() +{ +cat << EOF + + USAGE: "${0##*/} (optional)" + + This program is a free software under the terms of Apache 2.0 License. + COPYRIGHT (C) 2018 Abhishek Tamrakar + +EOF +exit 0 +} + +#check if basic commands are found +trap cleanup EXIT +checkcmd KUBECTL +# +#set the ground +if [ $# -lt 1 ]; then + if [ ! -e ${KUBE_LOC} -a ! -s ${KUBE_LOC} ] + then + info "A readable kube config location is required!!" + usage + fi +elif [ $# -eq 1 ] +then + export KUBECONFIG=$1 +elif [ $# -gt 1 ] +then + usage +fi +#play +get_namespaces +get_pod_errors + +printf '\n%40s\n' 'KRAWL' +printf '%s\n' '---------------------------------------------------------------------------------' +printf '%s\n' ' Krawl is a command line utility to scan pods and prints name of errored pods ' +printf '%s\n\n' ' +and containers within. To use it as kubernetes plugin, please check their page ' +printf '%s\n' '=================================================================================' + +cat results.csv | sed 's/,/,|/g'| column -s ',' -t +get_pod_events +``` + +此文最初发布在 [KRAWL 的 GitHub 仓库][2]下的 README 中,并被或许重用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/kubernetes-scanner + +作者:[Abhishek Tamrakar][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/tamrakar +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_captain_devops_kubernetes_steer.png?itok=LAHfIpek (Ship captain sailing the Kubernetes seas) +[2]: https://github.com/abhiTamrakar/kube-plugins/tree/master/krawl +[3]: https://opensource.com/sites/default/files/uploads/krawl_0.png (KRAWL script) +[4]: mailto:abhishek.tamrakar08@gmail.com diff --git a/published/202002/20200210 Top hacks for the YaCy open source search engine.md b/published/202002/20200210 Top hacks for the YaCy open source search engine.md new file mode 100644 index 0000000000..aaa71c4f0e --- /dev/null +++ b/published/202002/20200210 Top hacks for the YaCy open source search engine.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11919-1.html) +[#]: subject: (Top hacks for the YaCy open source search engine) +[#]: via: (https://opensource.com/article/20/2/yacy-search-engine-hacks) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用开源搜索引擎 YaCy 的技巧 +====== + +> 无需适应其他人的眼光,而是使用 YaCY 搜索引擎定义你想要的互联网。 + +![](https://img.linux.net.cn/data/attachment/album/202002/23/115822jqkdyjwzdqwdad0y.jpg) + +在我以前介绍 [YaCy 入门][2]的文章中讲述过 [YaCy][3] 这个对等peer-to-peer式的搜索引擎是如何安装和使用的。YaCy 最令人兴奋的一点就是它事实上是一个本地客户端,全球范围内的每一个 YaCy 用户都是构成整个这个分布式搜索引擎架构的一个节点,这意味着每个用户都可以掌控自己的互联网搜索体验。 + +Google 曾经提供过 google.com/linux 这样的主题简便方式以便快速筛选出和 Linux 相关的搜索内容,这个小功能受到了很多人的青睐,但 Google 最终还是在 2011 年的时候把它[下线][4]了。 + +而 YaCy 则让自定义搜索引擎变得可能。 + +### 自定义 YaCy + +YaCy 安装好之后,只需要访问 `localhost:8090` 就可以使用了。要自定义搜索引擎,只需要点击右上角的“管理Administration”按钮(它可能隐藏在小屏幕的菜单图标中)。 + +你可以在管理面板中配置 YaCy 对系统资源的使用策略,以及如何跟其它的 YaCy 客户端进行交互。 + +![YaCy profile selector][5] + +例如,点击侧栏中的“第一步First steps”按钮可以配置备用端口,以及设置 YaCy 对内存和硬盘的使用量;而“监控Monitoring”面板则可以监控 YaCy 的运行状况。大多数功能都只需要在面板上点击几下就可以完成了,例如以下几个常用的功能。 + +### 内网搜索应用 + +目前市面上也有不少公司推出了[内网搜索应用][6],而 YaCy 可以免费为你提供一个。对于能够通过 HTTP、FTP、Samba 等协议访问的文件,YaCy 都可以进行索引,因此无论是作为私人的文件搜索还是企业内部的本地共享文件搜索,YaCy 都可以实现。它可以让内部网络中的用户使用你个人的 YaCy 实例来查找共享文件,于此同时保持对内部网络以外的用户不可见。 + +### 网络配置 + +YaCy 在默认情况下就支持隐私和隔离。点击“用例与账号Use Case & Account”页面顶部的“网络配置Network Configuration”链接,即可进入网络配置面板设置对等网络。 + +![YaCy network configuration][7] + +### 爬取站点 + +YaCy 的分布式运作方式决定了它对页面的爬取是由用户驱动的。并没有一个大型公司对整个互联网上的所有可访问页面都进行搜索,对于 YaCy 来说也是这样,一个站点只有在被用户指定爬取的前提下,才会被 YaCy 爬取并进入索引。 + +YaCy 客户端提供了两种爬取页面的方式:你可以手动爬取,并让 YaCy 根据建议去爬取。 + +![YaCy advanced crawler][8] + +#### 手动爬取 + +手动爬取是指由用户输入指定的网站 URL 并启动 YaCy 的爬虫任务。只需要点击“高级爬虫Advanced Crawler”并输入计划爬取的若干 URL,然后选择页面底部的“进行远程索引Do Remote indexing”选项,这个选项会让客户端向互联网广播它要索引的 URL,可选地接受这些请求的客户端可以帮助你爬取这些 URL。 + +点击页面底部的“开始新爬虫任务Start New Crawl Job”按钮就可以开始进行爬取了,我就是这样对一些常用和有用站点进行爬取和索引的。 + +爬虫任务启动之后,YaCy 会将这些 URL 对应的页面在本地生成和存储索引。在高级模式下,也就是本地计算机允许 8090 端口流量进出时,全网的 YaCy 用户都可以使用到这一份索引。 + +#### 加入爬虫网络 + +尽管一些非常敬业的 YaCy 高级用户已经强迫症般地在互联网上爬取了很多页面,但对于全网浩如烟海的页面而言也只是沧海一粟。单个用户所拥有的资源远不及很多大公司的网络爬虫,但大量 YaCy 用户如果联合起来成为一个社区,能产生的力量就大得多了。只要开启了 YaCy 的爬虫请求广播功能,就可以让其它客户端参与进来爬取更多页面。 + +只需要在“高级爬虫Advanced Crawler”面板中点击页面顶部的“远程爬取Remote Crawling”,勾选“加载Load”旁边的复选框,就可以让你的客户端接受其它人发来的爬虫任务请求了。 + +![YaCy remote crawling][9] + +### YaCy 监控相关 + +YaCy 除了作为一个非常强大的搜索引擎,还提供了很丰富的主题和用户体验。你可以在“监控Monitor”面板中监控 YaCy 客户端的网络运行状况,甚至还可以了解到有多少人从 YaCy 社区中获取到了自己所需要的东西。 + +![YaCy monitoring screen][10] + +### 搜索引擎发挥了作用 + +你使用 YaCy 的时间越长,就越会思考搜索引擎如何改变自己的视野,因为你对互联网的体验很大一部分来自于你在搜索引擎中一次次简单查询的结果。实际上,当你和不同行业的人交流时,可能会注意到每个人对“互联网”的理解都有所不同。有些人会认为,互联网的搜索引擎中充斥着各种广告和推广,同时也仅仅能从搜索结果中获取到有限的信息。例如,假设有人不断搜索关于关键词 X 的内容,那么大部分商业搜索引擎都会在搜索结果中提高关键词 X 的权重,但与此同时,另一个关键词 Y 的权重则会相对降低,从而让关键词 Y 被淹没在搜索结果当中,即使这样对完成特定任务更好。 + +就像在现实生活中一样,走出虚拟的世界视野会让你看到一个更广阔的世界。尝试使用 YaCy,看看你发现了什么。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/yacy-search-engine-hacks + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things) +[2]: https://linux.cn/article-11905-1.html +[3]: https://yacy.net/ +[4]: https://www.linuxquestions.org/questions/linux-news-59/is-there-no-more-linux-google-884306/ +[5]: https://opensource.com/sites/default/files/uploads/yacy-profiles.jpg (YaCy profile selector) +[6]: https://en.wikipedia.org/wiki/Vivisimo +[7]: https://opensource.com/sites/default/files/uploads/yacy-network-config.jpg (YaCy network configuration) +[8]: https://opensource.com/sites/default/files/uploads/yacy-advanced-crawler.jpg (YaCy advanced crawler) +[9]: https://opensource.com/sites/default/files/uploads/yacy-remote-crawl-accept.jpg (YaCy remote crawling) +[10]: https://opensource.com/sites/default/files/uploads/yacy-monitor.jpg (YaCy monitoring screen) diff --git a/published/202002/20200211 Dino is a Modern Looking Open Source XMPP Client.md b/published/202002/20200211 Dino is a Modern Looking Open Source XMPP Client.md new file mode 100644 index 0000000000..82b969948c --- /dev/null +++ b/published/202002/20200211 Dino is a Modern Looking Open Source XMPP Client.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11917-1.html) +[#]: subject: (Dino is a Modern Looking Open Source XMPP Client) +[#]: via: (https://itsfoss.com/dino-xmpp-client/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Dino:一个有着现代外观的开源 XMPP 客户端 +====== + +> Dino 是一个相对较新的开源 XMPP 客户端,它试图提供良好的用户体验,鼓励注重隐私的用户使用 XMPP 发送消息。 + +![](https://img.linux.net.cn/data/attachment/album/202002/22/102844mhzgzb3533xgq6d8.jpg) + +### Dino:一个开源 XMPP 客户端 + +![][1] + +[XMPP][2](可扩展通讯和表示协议eXtensible Messaging Presence Protocol) 是一个去中心化的网络模型,可促进即时消息传递和协作。去中心化意味着没有中央服务器可以访问你的数据。通信直接点对点。 + +我们中的一些人可能会称它为“老派”技术,可能是因为 XMPP 客户端通常用户体验非常糟糕,或者仅仅是因为它需要时间来适应(或设置它)。 + +这时候 [Dino][3] 作为现代 XMPP 客户端出现了,在不损害你的隐私的情况下提供干净清爽的用户体验。 + +### 用户体验 + +![][4] + +Dino 试图改善 XMPP 客户端的用户体验,但值得注意的是,它的外观和感受将在一定程度上取决于你的 Linux 发行版。你的图标主题或 Gnome 主题会让你的个人体验更好或更糟。 + +从技术上讲,它的用户界面非常简单,易于使用。所以,我建议你看下 Ubuntu 中的[最佳图标主题][5]和 [GNOME 主题][6]来调整 Dino 的外观。 + +### Dino 的特性 + +![Dino Screenshot][7] + +你可以将 Dino 用作 Slack、[Signal][8] 或 [Wire][9] 的替代产品,来用于你的业务或个人用途。 + +它提供了消息应用所需的所有基本特性,让我们看下你可以从中得到的: + +* 去中心化通信 +* 如果无法设置自己的服务器,它支持公共 XMPP 的服务器 +* 和其他流行消息应用相似的 UI,因此易于使用 +* 图像和文件共享 +* 支持多个帐户 +* 高级消息搜索 +* 支持 [OpenPGP][10] 和 [OMEMO][11] 加密 +* 轻量级原生桌面应用 + +### 在 Linux 上安装 Dino + +你可能会发现它列在你的软件中心中,也可能未找到。Dino 为基于 Debian(deb)和 Fedora(rpm)的发行版提供了可用的二进制文件。 + +Dino 在 Ubuntu 的 universe 仓库中,你可以使用以下命令安装它: + +``` +sudo apt install dino-im +``` + +类似地,你可以在 [GitHub 分发包页面][12]上找到其他 Linux 发行版的包。 + +如果你想要获取最新的,你可以在 [OpenSUSE 的软件页面][13]找到 Dino 的 **.deb** 和 .**rpm** (每日构建版)安装在 Linux 中。 + +在任何一种情况下,前往它的 [Github 页面][14]或点击下面的链接访问官方网站。 + +- [下载 Dino][3] + +### 总结 + +在我编写这篇文章时快速测试过它,它工作良好,没有出过问题。我将尝试探索更多,并希望能涵盖更多有关 XMPP 的文章来鼓励用户使用 XMPP 的客户端和服务器用于通信。 + +你觉得 Dino 怎么样?你会推荐另一个可能好于 Dino 的开源 XMPP 客户端吗?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/dino-xmpp-client/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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/2020/02/dino-main.png?ssl=1 +[2]: https://xmpp.org/about/ +[3]: https://dino.im/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/dino-xmpp-client.jpg?ssl=1 +[5]: https://itsfoss.com/best-icon-themes-ubuntu-16-04/ +[6]: https://itsfoss.com/best-gtk-themes/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/dino-screenshot.png?ssl=1 +[8]: https://itsfoss.com/signal-messaging-app/ +[9]: https://itsfoss.com/wire-messaging-linux/ +[10]: https://www.openpgp.org/ +[11]: https://en.wikipedia.org/wiki/OMEMO +[12]: https://github.com/dino/dino/wiki/Distribution-Packages +[13]: https://software.opensuse.org/download.html?project=network:messaging:xmpp:dino&package=dino +[14]: https://github.com/dino/dino + diff --git a/published/202002/20200212 How to Change the Default Terminal in Ubuntu.md b/published/202002/20200212 How to Change the Default Terminal in Ubuntu.md new file mode 100644 index 0000000000..b90a79887f --- /dev/null +++ b/published/202002/20200212 How to Change the Default Terminal in Ubuntu.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11903-1.html) +[#]: subject: (How to Change the Default Terminal in Ubuntu) +[#]: via: (https://itsfoss.com/change-default-terminal-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 中更改默认终端 +====== + +终端Terminal是 Linux 系统的关键部分。它能让你通过 shell 访问 Linux 系统。Linux 上有多个终端应用(技术上称为终端仿真器)。 + +大多数[桌面环境][1]都有自己的终端实现。它们的外观可能有所不同,并且可能有不同的快捷键。例如,[Guake 终端][2]对高级用户非常有用,它提供了一些可能无法在发行版默认终端中使用的功能。 + +你可以在系统上安装其他终端,并将其设为默认,并能通过[快捷键 Ctrl+Alt+T][3] 打开。 + +现在问题来了,如何在 Ubuntu 中更改默认终端。它没有遵循[更改 Ubuntu 中的默认应用][4]的标准方式,要怎么做? + +### 更改 Ubuntu 中的默认终端 + +![][5] + +在基于 Debian 的发行版中,有一个方便的命令行程序,称为 [update-alternatives][6],可用于处理默认应用。 + +你可以使用它来更改默认的命令行文本编辑器、终端等。为此,请运行以下命令: + +``` +sudo update-alternatives --config x-terminal-emulator +``` + +它将显示系统上存在的所有可作为默认值的终端仿真器。当前的默认终端标有星号。 + +``` +abhishek@nuc:~$ sudo update-alternatives --config x-terminal-emulator +There are 2 choices for the alternative x-terminal-emulator (providing /usr/bin/x-terminal-emulator). + + Selection Path Priority Status +------------------------------------------------------------ + 0 /usr/bin/gnome-terminal.wrapper 40 auto mode + 1 /usr/bin/gnome-terminal.wrapper 40 manual mode +* 2 /usr/bin/st 15 manual mode + +Press to keep the current choice[*], or type selection number: +``` + +你要做的就是输入选择编号。对我而言,我想使用 GNOME 终端,而不是来自 [Regolith 桌面][7]的终端。 + +``` +Press to keep the current choice[*], or type selection number: 1 +update-alternatives: using /usr/bin/gnome-terminal.wrapper to provide /usr/bin/x-terminal-emulator (x-terminal-emulator) in manual mode +``` + +> **自动模式 vs 手动模式** +> +> 你可能已经在 `update-alternatives` 命令的输出中注意到了自动模式和手动模式。 +> +> 如果选择自动模式,那么在安装或删除软件包时,系统可能会自动决定默认应用。该决定受优先级数字的影响(如上一节中的命令输出所示)。 +> +> 假设你的系统上安装了 5 个终端仿真器,并删除了默认的仿真器。现在,你的系统将检查哪些仿真器处于自动模式。如果有多个,它将​​选择优先级最高的一个作为默认仿真器。 + +我希望你觉得这个小技巧有用。随时欢迎提出问题和建议。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/change-default-terminal-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/best-linux-desktop-environments/ +[2]: http://guake-project.org/ +[3]: https://itsfoss.com/ubuntu-shortcuts/ +[4]: https://itsfoss.com/change-default-applications-ubuntu/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/switch_default_terminal_ubuntu.png?ssl=1 +[6]: https://manpages.ubuntu.com/manpages/trusty/man8/update-alternatives.8.html +[7]: https://itsfoss.com/regolith-linux-desktop/ diff --git a/published/202002/20200212 How to use byobu to multiplex SSH sessions.md b/published/202002/20200212 How to use byobu to multiplex SSH sessions.md new file mode 100644 index 0000000000..061ca4c41a --- /dev/null +++ b/published/202002/20200212 How to use byobu to multiplex SSH sessions.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11944-1.html) +[#]: subject: (How to use byobu to multiplex SSH sessions) +[#]: via: (https://opensource.com/article/20/2/byobu-ssh) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +如何使用 byobu 复用 SSH 会话 +====== + +> Byobu 能让你在保持会话活跃的情况下维护多个终端窗口,通过 SSH 连接、断开、重连以及共享访问。 + +![Person drinking a hat drink at the computer][1] + +[Byobu][2] 是基于文本的窗口管理器和终端多路复用器。它类似于 [GNU Screen][3],但更现代、更直观。它还适用于大多数 Linux、BSD 和 Mac 发行版。 + +Byobu 能让你在保持会话活跃的情况下维护多个终端窗口、通过 SSH(secure shell)连接、断开、重连,甚至让其他人访问。 + +比如,你 SSH 进入树莓派或服务器,并运行(比如) `sudo apt update && sudo apt upgrade`,然后你在它运行的时候失去了互联网连接,你的命令会丢失无效。然而,如果你首先启动 byobu 会话,那么它会继续运行,在你重连后,你会发现它仍在继续运行。 + +![The byobu logo is a fun play on screens.][4] + +Byobu 名称来自于日语的装饰性多面板屏风,它可作为折叠式隔断,我认为这很合适。 + +要在 Debian/Raspbian/Ubuntu 上安装 byobu: + +``` +sudo apt install byobu +``` + +接着启用它: + +``` +byobu-enable +``` + +现在,请退出 SSH 会话并重新登录,你将会在 byobu 会话中登录。运行类似 `sudo apt update` 命令并关闭窗口(或输入转义序列([Enter + ~ + .][5])并重新登录。你将看到更新命令在你离开后还在运行。 + +有*很多*我不常使用的功能。我通常使用的是: + + * `F2` – 新窗口 + * `F3/F4` – 在窗口间导航 + * `Ctrl`+`F2` – 垂直拆分窗格 + * `Shift`+`F2` – 水平拆分窗格 + * `Shift`+`左箭头/Shift`+`右箭头` – 在拆分窗格间导航 + * `Shift`+`F11` – 放大(或缩小)拆分窗格 + +### 我们如何使用 byobu + +Byobu 对于维护 [piwheels][6](一个用于树莓派的方便的,预编译 Python 包)很好用。我水平拆分了窗格,在上半部分显示了 piwheels 监视器,在下半部分实时显示了 syslog 条目。接着,如果我们想要做其他事情,我们可以切换到另外一个窗口。当我们进行协作分析时,这特别方便,因为当我在 IRC 中聊天时,我可以看到我的同事 Dave 输入了什么(并纠正他的错字)。 + +我在家庭和办公服务器上启用了 byobu,因此,当我登录到任何一台计算机时,一切都与我离开时一样。它正在运行多个作业、在特定目录中保留一个窗口,以另一个用户身份运行进程等。 + +![byobu screenshot][7] + +Byobu 对于在树莓派上进行开发也很方便。你可以在桌面上启动它,运行命令,然后 SSH 进入,并连接到该命令运行所在的会话。请注意,启用 byobu 不会更改终端启动器的功能。只需运行 `byobu` 即可启动它。 + +本文最初发表在 Ben Nuttall 的 [Tooling blog][8] 中,并获许重用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/byobu-ssh + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer) +[2]: https://byobu.org/ +[3]: http://www.gnu.org/software/screen/ +[4]: https://opensource.com/sites/default/files/uploads/byobu.png (byobu screen) +[5]: https://www.google.com/search?client=ubuntu&channel=fs&q=Enter-tilde-dot&ie=utf-8&oe=utf-8 +[6]: https://opensource.com/article/20/1/piwheels +[7]: https://opensource.com/sites/default/files/uploads/byobu-screenshot.png (byobu screenshot) +[8]: https://tooling.bennuttall.com/byobu/ diff --git a/published/202002/20200212 elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution.md b/published/202002/20200212 elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution.md new file mode 100644 index 0000000000..6619254799 --- /dev/null +++ b/published/202002/20200212 elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11939-1.html) +[#]: subject: (elementary OS is Building an App Center Where You Can Buy Open Source Apps for Your Linux Distribution) +[#]: via: (https://itsfoss.com/appcenter-for-everyone/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +elementary OS 正在构建一个可以买应用的开源应用商店 +====== + +> elementary OS 正在构建一个应用中心生态系统,你可以在其中购买用于 Linux 发行版的开源应用程序。 + +### 众筹构建一个开源应用中心 + +![][1] + +[elementary OS][2] 最近宣布,它正在[众筹举办一个构建应用中心的活动][3],你可以从这个应用中心购买开源应用程序。应用中心中的应用程序将为 Flatpak 格式。 + +尽管这是 elementary OS 发起的活动,但这个新的应用中心也将适用于其他发行版。 + +该活动旨在资助在美国科罗拉多州丹佛市进行的一项一周个人开发冲刺活动,其中包括来自 elementary OS、[Endless][4]、[Flathub][5] 和 [GNOME][6] 的开发人员。 + +众筹活动已经超过了筹集 1 万美元的目标(LCTT 译注:截止至本译文发布,已近 15000 美金)。但你仍然可以为其提供资金,因为其他资金将用于开发 elementary OS。 + +### 这个应用中心将带来什么功能 + +其重点是提供“安全”应用程序,因此使用 [Flatpak][7] 应用来提供受限的应用程序。在这种格式下,默认情况下将会限制应用程序访问系统或个人文件,并在技术层面上将它们与其他应用程序隔离。 + +仅当你明确表示同意时,应用程序才能访问操作系统和个人文件。 + +除了安全性,[Flatpak][8] 还捆绑了所有依赖项。这样,即使当前 Linux 发行版中不提供这些依赖项,应用程序开发人员也可以利用这种最先进的技术使用它。 + +AppCenter 还具有钱包功能,可以保存你的信用卡详细信息。这样,你无需每次输入卡的详细信息即可快速为应用付费。 + +![][9] + +这个新的开源“应用中心”也将适用于其他 Linux 发行版。 + +### 受到了 elementary OS 自己的“按需付费”应用中心模型成功的启发 + +几年前,elementary OS 推出了自己的应用中心。应用中心的“按需付费”方法很受欢迎。开发人员可以为其开源应用设置最低金额,而用户可以选择支付等于或高于最低金额的金额。 + +![][10] + +这帮助了几位独立开发人员可以对其开源应用程序接受付款。该应用中心现在拥有约 160 个原生应用程序,elementary OS 表示已通过应用中心向开发人员支付了数千美元。 + +受到此应用中心实验在 elementary OS 中的成功的启发,他们现在也希望将此应用中心的方法也引入其他发行版。 + +### 如果应用程序是开源的,你怎么为此付费? + +某些人仍然对 FOSS(自由而开源)的概念感到困惑。在这里,该软件的“源代码”是“开源的”,任何人都可以“自由”进行修改和重新分发。 + +但这并不意味着开源软件必须免费。一些开发者依靠捐赠,而另一些则收取支持费用。 + +获得开源应用程序的报酬可能会鼓励开发人员创建 [Linux 应用程序][11]。 + +### 让我们拭目以待 + +![][12] + +就个人而言,我不是 Flatpak 或 Snap 包格式的忠实拥护者。它们确实有其优点,但是它们花费了相对更多的时间来启动,并且它们的包大小很大。如果安装了多个此类 Snap 或 Flatpak 软件包,磁盘空间就会慢慢耗尽。 + +也需要对这个新的应用程序生态系统中的假冒和欺诈开发者保持警惕。想象一下,如果某些骗子开始创建冷门的开源应用程序的 Flatpak 程序包,并将其放在应用中心上?我希望开发人员采用某种机制来淘汰此类应用程序。 + +我确实希望这个新的应用中心能够复制在 elementary OS 中已经看到的成功。对于桌面 Linux 的开源应用程序,我们绝对需要更好的生态系统。 + +你对此有何看法?这是正确的方法吗?你对改进应用中心有什么建议? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/appcenter-for-everyone/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/appcenter.png?ssl=1 +[2]: https://elementary.io/ +[3]: https://www.indiegogo.com/projects/appcenter-for-everyone/ +[4]: https://itsfoss.com/endless-linux-computers/ +[5]: https://flathub.org/ +[6]: https://www.gnome.org/ +[7]: https://flatpak.org/ +[8]: https://itsfoss.com/flatpak-guide/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/appcenter-wallet.png?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/appcenter-payment.png?ssl=1 +[11]: https://itsfoss.com/essential-linux-applications/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/open_source_app_center.png?ssl=1 diff --git a/published/202002/20200213 Why developers like to code at night.md b/published/202002/20200213 Why developers like to code at night.md new file mode 100644 index 0000000000..144345c44f --- /dev/null +++ b/published/202002/20200213 Why developers like to code at night.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11924-1.html) +[#]: subject: (Why developers like to code at night) +[#]: via: (https://opensource.com/article/20/2/why-developers-code-night) +[#]: author: (Matt Shealy https://opensource.com/users/mshealy) + +程序员为什么喜欢在晚上编码 +====== + +> 对许多开源程序员来说,夜间的工作计划是创造力和生产力来源的关键。 + +![](https://img.linux.net.cn/data/attachment/album/202002/24/104251b2hxch46h45c8zwd.jpg) + +如果你问大多数开发人员更喜欢在什么时候工作,大部人会说他们最高效的时间在晚上。这对于那些在工作之余为开源项目做贡献的人来说更是如此(尽管如此,希望在他们的健康范围内[避免透支][2])。 + +有些人喜欢从晚上开始,一直工作到凌晨,而另一些人则很早就起床(例如,凌晨 4 点),以便在开始日常工作之前完成大部分编程工作。 + +这种工作习惯可能会使许多开发人员看起来像个怪人,不合时宜。但是,为什么有这么多的程序员喜欢在非正常时间工作,原因有很多: + +### 制造者日程 + +根据 [保罗·格雷厄姆][3]Paul Graham 的观点,“生产东西”的人倾向于遵守 制造者日程 —— 他们更愿意以半天或更长时间为单位使用时间。事实上,大多数[开发人员也有相同的偏好][4]。(LCTT 译注:保罗·格雷厄姆有[一篇文章][8]述及制造者日程和管理者日程。) + +一方面,开发人员从事大型抽象系统工作,需要思维空间来处理整个模型。将他们的日程分割成 15 分钟或 30 分钟的时间段来处理电子邮件、会议、电话以及来自同事的打断,工作效果只会适得其反。 + +另一方面,通常不可能以小时为单位进行有效编程。因为这么短的时间几乎不够让你把思绪放在手头的任务上并开始工作。 + +上下文切换也会对编程产生不利影响。在晚上工作,开发人员可以避免尽可能多的干扰。在没有不断的干扰的情况下,他们可以花几个小时专注于手头任务,并尽可能提高工作效率。 + +### 平和安静的环境 + +由于晚上或凌晨不太会有来自各种活动的噪音(例如,办公室闲谈、街道上的交通),这使许多程序员感到放松,促使他们更具创造力和生产力,特别是在处理诸如编码之类的精神刺激任务时。 + +独处与平静,加上他们知道自己将有几个小时不被中断的工作时间,通常会使他们摆脱白天工作计划相关的时间压力,从而产出高质量的工作。 + +更不用说了,当解决了一个棘手的问题后,没有什么比尽情享受自己最喜欢的午夜小吃更美好的事情了! + +### 沟通 + +与在公司内工作的程序员相比,从事开源项目的开发人员可以拥有不同的沟通节奏。大多数开源项目的沟通都是通过邮件或 GitHub 上的评论等渠道异步完成的。很多时候,其他程序员在不同的国家和时区,因此实时交流通常需要开发人员变成一个夜猫子。 + +### 昏昏欲睡的大脑 + +这听起来可能违反直觉,但是随着时间的推移,大脑会变得非常疲倦,因此只能专注于一项任务。晚上工作从根本上消除了多任务处理,而这是保持专注和高效的主要障碍。当大脑处于昏昏欲睡的状态时,你是无法保持专注的! + +此外,许多开发人员在入睡时思考要解决的问题通常会取得重大进展。潜意识开始工作,答案通常在他们半睡半醒的凌晨时分就出现了。 + +这不足为奇,因为[睡眠可增强大脑功能][5],可帮助我们理解新信息并进行更有创造性的思考。当解决方案在凌晨出现时,这些开发人员便会起来开始工作,不错过任何机会。 + +### 灵活和创造性思考 + +许多程序员体会到晚上创造力会提升。前额叶皮层,即大脑中与集中能力有关的部分,在一天结束时会感到疲倦。这似乎为某些人提供了更灵活和更具创造性的思考。 + +匹兹堡大学医学院精神病学助理教授 [Brant Hasler][6] 表示:“由于自上而下的控制和‘认知抑制’的减少,大脑可能会解放出来进行更发散的思考,从而使人们更容易地将不同概念之间的联系建立起来。” 结合轻松环境所带来的积极情绪,开发人员可以更轻松地产生创新想法。 + +此外,在没有干扰的情况下集中精力几个小时,“沉浸在你做的事情中”。这可以帮助你更好地专注于项目并参与其中,而不必担心周围发生的事情。 + +### 明亮的电脑屏幕 + +因为整天看着明亮的屏幕, 许多程序员的睡眠周期被延迟。电脑屏幕发出的蓝光[扰乱我们的昼夜节律][7],延迟了释放诱发睡眠的褪黑激素和提高人的机敏性,并将人体生物钟重置到更晚的时间。从而导致,开发人员往往睡得越来越晚。 + +### 来自过去的影响 + +过去,大多数开发人员是出于必要在晚上工作,因为在白天当公司其他人都在使用服务器时,共享服务器的计算能力支撑不了编程工作,所以开发人员需要等到深夜才能执行白天无法进行的任务,例如测试项目、运行大量的“编码-编译-运行-调试”周期以及部署新代码。现在尽管服务器功能变强大了,大多数可以满足需求,但夜间工作的趋势仍是这种文化的一部分。 + +### 结语 + +尽管开发人员喜欢在晚上工作的原因很多,但请记住,做为夜猫子并不意味着你应该克扣睡眠时间。睡眠不足会导致压力和焦虑,并最终导致倦怠。 + +获得足够质量的睡眠是维持良好身体健康和大脑功能的关键。例如,它可以帮助你整合新信息、巩固记忆、创造性思考、清除身体积聚的毒素、调节食欲并防止过早衰老。 + +无论你是哪种日程,请确保让你的大脑得到充分的休息,这样你就可以在一整天及每天的工作中发挥最大的作用! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/why-developers-code-night + +作者:[Matt Shealy][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mshealy +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_code_programming_laptop.jpg?itok=ormv35tV (Person programming on a laptop on a building) +[2]: https://opensource.com/article/19/11/burnout-open-source-communities +[3]: http://www.paulgraham.com/makersschedule.html +[4]: https://www.chamberofcommerce.com/business-advice/software-development-trends-overtaking-the-market +[5]: https://amerisleep.com/blog/sleep-impacts-brain-health/ +[6]: https://www.vice.com/en_us/article/mb58a8/late-night-creativity-spike +[7]: https://www.sleepfoundation.org/articles/how-blue-light-affects-kids-sleep +[8]: http://www.paulgraham.com/makersschedule.html diff --git a/published/202002/20200214 Digging up IP addresses with the Linux dig command.md b/published/202002/20200214 Digging up IP addresses with the Linux dig command.md new file mode 100644 index 0000000000..01f72b47fd --- /dev/null +++ b/published/202002/20200214 Digging up IP addresses with the Linux dig command.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11931-1.html) +[#]: subject: (Digging up IP addresses with the Linux dig command) +[#]: via: (https://www.networkworld.com/article/3527430/digging-up-ip-addresses-with-the-dig-command.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 dig 命令挖掘域名解析信息 +====== + +> 命令行工具 `dig` 是用于解析域名和故障排查的一个利器。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/094028jgvzguau1pdgicpz.jpg) + +从主要功能上来说,`dig` 和 `nslookup` 之间差异不大,但 `dig` 更像一个加强版的 `nslookup`,可以查询到一些由域名服务器管理的信息,这在排查某些问题的时候非常有用。总的来说,`dig` 是一个既简单易用又功能强大的命令行工具。(LCTT 译注:`dig` 和 `nslookup` 行为的主要区别来自于 `dig` 使用是是操作系统本身的解析库,而 `nslookup` 使用的是该程序自带的解析库,这有时候会带来一些行为差异。此外,从表现形式上看,`dig` 返回是结果是以 BIND 配置信息的格式返回的,也带有更多的技术细节。) + +`dig` 最基本的功能就是查询域名信息,因此它的名称实际上是“域名信息查询工具Domain Information Groper”的缩写。`dig` 向用户返回的内容可以非常详尽,也可以非常简洁,展现内容的多少完全由用户在查询时使用的选项来决定。 + +### 我只需要查询 IP 地址 + +如果只需要查询某个域名指向的 IP 地址,可以使用 `+short` 选项: + +``` +$ dig facebook.com +short +31.13.66.35 +``` + +在查询的时候发现有的域名会指向多个 IP 地址?这其实是网站提高其可用性的一种措施。 + +``` +$ dig networkworld.com +short +151.101.2.165 +151.101.66.165 +151.101.130.165 +151.101.194.165 +``` + +也正是由于这些网站通过负载均衡实现高可用,在下一次查询的时候,或许会发现这几个 IP 地址的排序有所不同。(LCTT 译注:浏览器等应用默认会使用返回的第一个 IP 地址,因此这样实现了一种简单的负载均衡。) + +``` +$ dig networkworld.com +short +151.101.130.165 +151.101.194.165 +151.101.2.165 +151.101.66.165 +``` + +### 标准返回 + +`dig` 的标准返回内容则包括这个工具本身的一些信息,以及请求域名服务器时返回的响应内容: + +``` +$ dig networkworld.com + +; <<>> DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu <<>*gt; networkworld.com +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39932 +;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 65494 +;; QUESTION SECTION: +;networkworld.com. IN A + +;; ANSWER SECTION: +networkworld.com. 300 IN A 151.101.194.165 +networkworld.com. 300 IN A 151.101.130.165 +networkworld.com. 300 IN A 151.101.66.165 +networkworld.com. 300 IN A 151.101.2.165 + +;; Query time: 108 msec +;; SERVER: 127.0.0.53#53(127.0.0.53) +;; WHEN: Thu Feb 13 13:49:53 EST 2020 +;; MSG SIZE rcvd: 109 +``` + +由于域名服务器有缓存机制,返回的内容可能是之前缓存好的信息。在这种情况下,`dig` 最后显示的查询时间Query time会是 0 毫秒(0 msec): + +``` +;; Query time: 0 msec <== +;; SERVER: 127.0.0.53#53(127.0.0.53) +;; WHEN: Thu Feb 13 15:30:09 EST 2020 +;; MSG SIZE rcvd: 109 +``` + +### 向谁查询? + +在默认情况下,`dig` 会根据 `/etc/resolv.conf` 这个文件的内容决定向哪个域名服务器获取查询结果。你也可以使用 `@` 来指定 `dig` 请求的域名服务器。 + +在下面的例子中,就指定了 `dig` 向 Google 的域名服务器 8.8.8.8 查询域名信息。 + +``` +$ dig @8.8.8.8 networkworld.com + +; <<>> DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu <<>> @8.8.8.8 networkworld.com +; (1 server found) +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21163 +;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 512 +;; QUESTION SECTION: +;networkworld.com. IN A + +;; ANSWER SECTION: +networkworld.com. 299 IN A 151.101.130.165 +networkworld.com. 299 IN A 151.101.66.165 +networkworld.com. 299 IN A 151.101.194.165 +networkworld.com. 299 IN A 151.101.2.165 + +;; Query time: 48 msec +;; SERVER: 8.8.8.8#53(8.8.8.8) +;; WHEN: Thu Feb 13 14:26:14 EST 2020 +;; MSG SIZE rcvd: 109 +``` + +想要知道正在使用的 `dig` 工具的版本,可以使用 `-v` 选项。你会看到类似这样: + +``` +$ dig -v +DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu +``` + +或者这样的返回信息: + +``` +$ dig -v +DiG 9.11.4-P2-RedHat-9.11.4-22.P2.el8 +``` + +如果你觉得 `dig` 返回的内容过于详细,可以使用 `+noall`(不显示所有内容)和 `+answer`(仅显示域名服务器的响应内容)选项,域名服务器的详细信息就会被忽略,只保留域名解析结果。 + +``` +$ dig networkworld.com +noall +answer + +; <<>> DiG 9.11.5-P4-5.1ubuntu2.1-Ubuntu <<>> networkworld.com +noall +answer +;; global options: +cmd +networkworld.com. 300 IN A 151.101.194.165 +networkworld.com. 300 IN A 151.101.130.165 +networkworld.com. 300 IN A 151.101.66.165 +networkworld.com. 300 IN A 151.101.2.165 +``` + +### 批量查询域名 + +如果你要查询多个域名,可以把这些域名写入到一个文件内(`domains`),然后使用下面的 `dig` 命令遍历整个文件并给出所有查询结果。 + +``` +$ dig +noall +answer -f domains +networkworld.com. 300 IN A 151.101.66.165 +networkworld.com. 300 IN A 151.101.2.165 +networkworld.com. 300 IN A 151.101.130.165 +networkworld.com. 300 IN A 151.101.194.165 +world.std.com. 77972 IN A 192.74.137.5 +uushenandoah.org. 1982 IN A 162.241.24.209 +amazon.com. 18 IN A 176.32.103.205 +amazon.com. 18 IN A 176.32.98.166 +amazon.com. 18 IN A 205.251.242.103 +``` + +你也可以在上面的命令中使用 `+short` 选项,但如果其中有些域名指向多个 IP 地址,就无法看出哪些 IP 地址对应哪个域名了。在这种情况下,更好地做法应该是让 `awk` 对返回内容进行处理,只留下第一列和最后一列: + +``` +$ dig +noall +answer -f domains | awk '{print $1,$NF}' +networkworld.com. 151.101.66.165 +networkworld.com. 151.101.130.165 +networkworld.com. 151.101.194.165 +networkworld.com. 151.101.2.165 +world.std.com. 192.74.137.5 +amazon.com. 176.32.98.166 +amazon.com. 205.251.242.103 +amazon.com. 176.32.103.205 +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3527430/digging-up-ip-addresses-with-the-dig-command.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202002/20200217 How to get MongoDB Server on Fedora.md b/published/202002/20200217 How to get MongoDB Server on Fedora.md new file mode 100644 index 0000000000..8c5522b477 --- /dev/null +++ b/published/202002/20200217 How to get MongoDB Server on Fedora.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11942-1.html) +[#]: subject: (How to get MongoDB Server on Fedora) +[#]: via: (https://fedoramagazine.org/how-to-get-mongodb-server-on-fedora/) +[#]: author: (Honza Horak https://fedoramagazine.org/author/hhorak/) + +如何在 Fedora 上安装 MongoDB 服务器 +====== + +![][1] + +Mongo(来自 “humongous” —— 巨大的)是一个高性能、开源、无模式的、面向文档的数据库,它是最受欢迎的 [NoSQL][2] 数据库之一。它使用 JSON 作为文档格式,并且可以在多个服务器节点之间进行扩展和复制。 + +### 有关许可证更改的故事 + +MongoDB 上游决定更改服务器代码的许可证已经一年多了。先前的许可证是 GNU Affero General Public License v3(AGPLv3)。但是,上游公司写了一个新许可证,旨在使运行 MongoDB 即服务的公司可以回馈社区。新许可证称为 Server Side Public License(SSPLv1),关于这个举措及其解释的更多说明,请参见 [MongoDB SSPL FAQ][3]。 + +Fedora 一直只包含自由软件。当 SSPL 发布后,Fedora [确定][4]它并不是自由软件许可证。许可证更改日期(2018 年 10 月)之前发布的所有 MongoDB 版本都可保留在 Fedora 中,但之后再也不更新的软件包会带来安全问题。因此,从 Fedora 30 开始,Fedora 社区决定完全[移除 MongoDB 服务器][5]。 + +### 开发人员还有哪些选择? + +是的,还有替代方案,例如 PostgreSQL 在最新版本中也支持 JSON,它可以在无法再使用 MongoDB 的情况下使用它。使用 JSONB 类型,索引在 PostgreSQL 中可以很好地工作,其性能可与 MongoDB 媲美,甚至不会受到 ACID 的影响。 + +开发人员可能选择 MongoDB 的技术原因并未随许可证而改变,因此许多人仍想使用它。重要的是要意识到,SSPL 许可证仅更改仅针对 MongoDB 服务器。MongoDB 上游还开发了其他项目,例如 MongoDB 工具、C 和 C++ 客户端库以及用于各种动态语言的连接器,这些项目在客户端使用(通过网络与服务器通信的应用中)。由于这些包的许可证人保持自由(主要是 Apache 许可证),因此它们保留在 Fedora 仓库中,因此用户可以将其用于应用开发。 + +唯一的变化实际是服务器软件包本身,它已从 Fedora 仓库中完全删除。让我们看看 Fedora 用户可以如何获取非自由的包。 + +### 如何从上游安装 MongoDB 服务器 + +当 Fedora 用户想要安装 MongoDB 服务器时,他们需要直接向上游获取 MongoDB。但是,上游不为 Fedora 提供 RPM 包。相反,MongoDB 服务器可以获取源码 tarball,用户需要自己进行编译(这需要一些开发知识),或者 Fedora 用户可以使用一些兼容的包。在兼容的选项中,最好的选择是 RHEL-8 RPM。以下步骤描述了如何安装它们以及如何启动守护进程。 + +#### 1、使用上游 RPM 创建仓库(RHEL-8 构建) + +``` +$ sudo cat > /etc/yum.repos.d/mongodb.repo >>EOF +[mongodb-upstream] +name=MongoDB Upstream Repository +baseurl=https://repo.mongodb.org/yum/redhat/8Server/mongodb-org/4.2/x86_64/ +gpgcheck=1 +enabled=1 +gpgkey=https://www.mongodb.org/static/pgp/server-4.2.asc +EOF +``` + +#### 2、安装元软件包,来拉取服务器和工具包 + +``` +$ sudo dnf install mongodb-org +...... +Installed: + mongodb-org-4.2.3-1.el8.x86_64 mongodb-org-mongos-4.2.3-1.el8.x86_64 + mongodb-org-server-4.2.3-1.el8.x86_64 mongodb-org-shell-4.2.3-1.el8.x86_64 + mongodb-org-tools-4.2.3-1.el8.x86_64 + +Complete! +``` + +#### 3、启动 MongoDB 守护进程 + +``` +$ sudo systemctl status mongod +● mongod.service - MongoDB Database Server + Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) + Active: active (running) since Sat 2020-02-08 12:33:45 EST; 2s ago + Docs: https://docs.mongodb.org/manual + Process: 15768 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) + Process: 15769 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) + Process: 15770 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) + Process: 15771 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS) + Main PID: 15773 (mongod) + Memory: 70.4M + CPU: 611ms + CGroup: /system.slice/mongod.service + +``` + +#### 4、通过 mongo shell 连接服务器来验证是否运行 + +``` +$ mongo +MongoDB shell version v4.2.3 +connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb +Implicit session: session { "id" : UUID("20b6e61f-c7cc-4e9b-a25e-5e306d60482f") } +MongoDB server version: 4.2.3 +Welcome to the MongoDB shell. +For interactive help, type "help". +For more comprehensive documentation, see + http://docs.mongodb.org/ +--- +``` + + +就是这样了。如你所见,RHEL-8 包完美兼容,只要 Fedora 包还与 RHEL-8 兼容,它就应该会一直兼容。请注意,在使用时必须遵守 SSPLv1 许可证。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-get-mongodb-server-on-fedora/ + +作者:[Honza Horak][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/hhorak/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/02/mongodb-816x348.png +[2]: https://en.wikipedia.org/wiki/NoSQL +[3]: https://www.mongodb.com/licensing/server-side-public-license/faq +[4]: https://lists.fedoraproject.org/archives/list/legal@lists.fedoraproject.org/thread/IQIOBOGWJ247JGKX2WD6N27TZNZZNM6C/ +[5]: https://fedoraproject.org/wiki/Changes/MongoDB_Removal diff --git a/published/202002/20200217 How to install Vim plugins.md b/published/202002/20200217 How to install Vim plugins.md new file mode 100644 index 0000000000..f3ce601e53 --- /dev/null +++ b/published/202002/20200217 How to install Vim plugins.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11923-1.html) +[#]: subject: (How to install Vim plugins) +[#]: via: (https://opensource.com/article/20/2/how-install-vim-plugins) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何安装 Vim 插件 +====== + +> 无论你是手动安装还是通过包管理器安装,插件都可以帮助你在工作流中打造一个完美的 Vim 。 + +![](https://img.linux.net.cn/data/attachment/album/202002/23/215719kwhqzwwj1ezoen6o.jpg) + +虽然 [Vim][2] 是快速且高效的,但在默认情况下,它仅仅只是一个文本编辑器。至少,这就是没有插件的情况 Vim 应当具备的样子,插件构建在 Vim 之上,并添加额外的功能,使 Vim 不仅仅是一个输入文本的窗口。有了合适的插件组合,你可以控制你的生活,形成你自己独特的 Vim 体验。你可以[自定义你的主题][3],你可以添加语法高亮,代码 linting,版本跟踪器等等。 + +### 怎么安装 Vim 插件 + +Vim 可以通过插件进行扩展,但很长一段时间以来,并没有官方的安装方式去安装这些插件。从 Vim 8 开始,有一个关于插件如何安装和加载的结构。你可能会在网上或项目自述文件中遇到旧的说明,但只要你运行 Vim 8 或更高版本,你应该根据 Vim 的[官方插件安装方法][4]安装或使用 Vim 包管理器。你可以使用包管理器,无论你运行的是什么版本(包括比 8.x 更老的版本),这使得安装过程比你自己维护更新更容易。 + +手动和自动安装方法都值得了解,所以请继续阅读以了解这两种方法。 + +### 手动安装插件(Vim 8 及以上版本) + +所谓的 “Vim 包”是一个包含一个或多个插件的目录。默认情况下,你的 Vim 设置包含在 `~/.vim` 中,这是 Vim 在启动时寻找插件的地方。(下面的示例使用了通用名称 `vendor` 来表示插件是从其它地方获得的。) + +当你启动 Vim 时,它首先处理你的 `.vimrc`文件,然后扫描 `~/.vim` 中的所有目录,查找包含在 `pack/*/start` 中的插件。 + +默认情况下,你的 `~/.vim` 目录(如果你有的话)中没有这样的文件结构,所以设置为: + +``` +$ mkdir -p ~/.vim/pack/vendor/start +``` + +现在,你可以将 Vim 插件放在 `~/.vim/pack/vendor/start` 中,它们会在你启动 Vim 时自动加载。 + +例如,尝试安装一下 [NERDTree][5],这是一个基于文本的 Vim 文件管理器。首先,使用 Git 克隆 NERDTree 存储库的快照: + +``` +$ git clone --depth 1 \ +  https://github.com/preservim/nerdtree.git \ +  ~/.vim/pack/vendor/start/nerdtree +``` + +启动 Vim 或者 gvim,然后键入如下命令: + +``` +:NERDTree +``` + +Vim 窗口左侧将打开一个文件树。 + +![NERDTree plugin][6] + +如果你不想让一个插件每次启动 Vim 时都自动加载,你可以在 `~/.vim/pack/vendor` 中创建 `opt` 文件夹: + +``` +$ mkdir ~/.vim/pack/vendor/opt +``` + +任何安装到 `opt` 的插件都可被 Vim 使用,但是只有当你使用 `packadd` 命令将它们添加到一个会话中时,它们才会被加载到内存中。例如,一个虚构的叫 foo 的插件: + +``` +:packadd foo +``` + +Vim 官方建议每个插件项目在 `~/.Vim/pack` 中创建自己的目录。例如,如果你要安装 NERDTree 插件和假想的 foo 插件,你需要创建这样的目录结构: + +``` +$ mkdir -p ~/.vim/pack/NERDTree/start/ +$ git clone --depth 1 \ + https://github.com/preservim/nerdtree.git \ + ~/.vim/pack/NERDTree/start/NERDTree +$ mkdir -p ~/.vim/pack/foo/start/ +$ git clone --depth 1 \ + https://notabug.org/foo/foo.git \ + ~/.vim/pack/foo/start/foo +``` + +这样做是否方便取决于你。 + +### 使用 Vim 包管理器(任何 Vim 版本) + +自从 Vim 8 以后,包管理器变得不那么有用了,但是一些用户仍然喜欢它们,因为它们能够自动更新一些插件。有几个包管理器可供选择,并且它们各不相同,但是 [vim-plug][7] 有一些很棒的特性和最好的文档,这使我们很容易开始并在以后深入研究。 + +#### 使用 vim-plug 安装插件 + +安装 vim-plug,以便它在启动时自动加载: + +``` +$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ +  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +``` + +创建一个 `~/.vimrc` 文件(如果你还没有这个文件),然后输入以下文本: + +``` +call plug#begin() +Plug 'preservim/NERDTree' +call plug#end() +``` + +每次要安装插件时,都必须在 `plug#begin()` 和 `plug#end()` 之间输入插件的名称和位置(上面以 NERDTree 文件管理器为例)。如果你所需的插件未托管在 GitHub 上,你可以提供完整的 URL,而不仅仅是 GitHub 的用户名和项目 ID。你甚至可以在 `~/.vim` 目录之外“安装”本地插件。 + +最后,启动 Vim 并提示 vim-plug 安装 `~/.vimrc` 中列出的插件: + +``` +:PlugInstall +``` + +等待插件下载。 + +#### 通过 vim-plug 更新插件 + +与手动安装过程相比,编辑 `~/.vimrc` 并使用命令来进行安装可能看起来并没有多省事,但是 vim-plug 的真正优势在更新。更新所有安装的插件,使用这个 Vim 命令: + +``` +:PlugUpdate +``` + +如果你不想更新所有的插件,你可以通过添加插件的名字来更新任何插件: + +``` +:PlugUpdate NERDTree +``` + +#### 恢复插件 + +vim-plug 的另一个优点是它的导出和恢复功能。Vim 用户都知道,正是插件的缘故,通常每个用户使用 Vim 的工作方式都是独一无二的。一旦你安装和配置了正确的插件组合,你最不想要的局面就是再也找不到它们。 + +Vim-plug 有这个命令来生成一个脚本来恢复所有当前的插件: + +``` +:PlugSnapshot ~/vim-plug.list +``` +vim-plug 还有许多其他的功能,所以请参考它的[项目页面][7]以获得完整的文档。 + +### 打造一个完美的 Vim + +当你整天都在做一个项目时,你希望每一个小细节都能为你提供最好的服务。了解 Vim 和它的许多插件,直到你为你所做的事情构建出一个完美的应用程序。 + +有喜欢的 Vim 插件吗?请在评论中告诉我们吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/how-install-vim-plugins + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/todo_checklist_team_metrics_report.png?itok=oB5uQbzf (Team checklist and to dos) +[2]: https://www.vim.org/ +[3]: https://opensource.com/article/19/12/colors-themes-vim +[4]: https://github.com/vim/vim/blob/03c3bd9fd094c1aede2e8fe3ad8fd25b9f033053/runtime/doc/repeat.txt#L515 +[5]: https://github.com/preservim/nerdtree +[6]: https://opensource.com/sites/default/files/uploads/vim-nerdtree.jpg (NERDTree plugin) +[7]: https://github.com/junegunn/vim-plug diff --git a/published/202002/20200219 Don-t like IDEs- Try grepgitvi.md b/published/202002/20200219 Don-t like IDEs- Try grepgitvi.md new file mode 100644 index 0000000000..7284c57f0f --- /dev/null +++ b/published/202002/20200219 Don-t like IDEs- Try grepgitvi.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11934-1.html) +[#]: subject: (Don't like IDEs? Try grepgitvi) +[#]: via: (https://opensource.com/article/20/2/no-ide-script) +[#]: author: (Yedidyah Bar David https://opensource.com/users/didib) + +不喜欢 IDE?试试看 grepgitvi +====== + +> 一个简单又原始的脚本来用 Vim 打开你选择的文件。 + +![](https://img.linux.net.cn/data/attachment/album/202002/26/113942a99a1aujmjpfnfrh.jpg) + +像大多数开发者一样,我整天都在搜索和阅读源码。就我个人而言,我从来没有习惯过集成开发环境 (IDE),多年来,我主要使用 `grep` (找到文件),并复制/粘贴文件名来打开 Vi(m)。 + +最终,我写了这个脚本,并根据需要缓慢地对其进行了完善。 + +它依赖 [Vim][2] 和 [rlwrap][3],并使用 Apache 2.0 许可证开源。要使用该脚本,请[将它放到 PATH 中][4],然后在文本目录下运行: + +``` +grepgitvi +``` + +它将返回搜索结果的编号列表,并提示你输入结果编号并打开 Vim。退出 Vim 后,它将再次显示列表,直到你输入除结果编号以外的任何内容。你也可以使用向上和向下箭头键选择一个文件。(这对我来说)更容易找到我已经看过的结果。 + +与现代 IDE 甚至与 Vim 的更复杂的用法相比,它简单而原始,但它对我有用。 + +### 脚本 + + +``` +#!/bin/bash + +# grepgitvi - grep source files, interactively open vim on results +# Doesn't really have to do much with git, other than ignoring .git +# +# Copyright Yedidyah Bar David 2019 +# +# SPDX-License-Identifier: Apache-2.0 +# +# Requires vim and rlwrap +# +# Usage: grepgitvi +# + +TMPD=$(mktemp -d /tmp/grepgitvi.XXXXXX) +UNCOLORED=${TMPD}/uncolored +COLORED=${TMPD}/colored + +RLHIST=${TMPD}/readline-history + +[ -z "${DIRS}" ] && DIRS=. + +cleanup() { + rm -rf "${TMPD}" +} + +trap cleanup 0 + +find ${DIRS} -iname .git -prune -o \! -iname "*.min.css*" -type f -print0 > ${TMPD}/allfiles + +cat ${TMPD}/allfiles | xargs -0 grep --color=always -n -H "$@" > $COLORED +cat ${TMPD}/allfiles | xargs -0 grep -n -H "$@" > $UNCOLORED + +max=`cat $UNCOLORED | wc -l` +pat="${@: -1}" + +inp='' +while true; do + echo "============================ grep results ===============================" + cat $COLORED | nl + echo "============================ grep results ===============================" + prompt="Enter a number between 1 and $max or anything else to quit: " + inp=$(rlwrap -H $RLHIST bash -c "read -p \"$prompt\" inp; echo \$inp") + if ! echo "$inp" | grep -q '^[0-9][0-9]*$' || [ "$inp" -gt "$max" ]; then + break + fi + + filename=$(cat $UNCOLORED | awk -F: "NR==$inp"' {print $1}') + linenum=$(cat $UNCOLORED | awk -F: "NR==$inp"' {print $2-1}') + vim +:"$linenum" +"norm zz" +/"${pat}" "$filename" +done +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/no-ide-script + +作者:[Yedidyah Bar David][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/didib +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: https://www.vim.org/ +[3]: https://linux.die.net/man/1/rlwrap +[4]: https://opensource.com/article/17/6/set-path-linux diff --git a/published/202002/20200219 How Kubernetes Became the Standard for Compute Resources.md b/published/202002/20200219 How Kubernetes Became the Standard for Compute Resources.md new file mode 100644 index 0000000000..3d1a903916 --- /dev/null +++ b/published/202002/20200219 How Kubernetes Became the Standard for Compute Resources.md @@ -0,0 +1,49 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11940-1.html) +[#]: subject: (How Kubernetes Became the Standard for Compute Resources) +[#]: via: (https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/) +[#]: author: (Swapnil Bhartiya https://www.linux.com/author/swapnil/) + +Kubernetes 如何成为计算资源的标准 +====== + +![](https://img.linux.net.cn/data/attachment/album/202002/28/131634mwzyylmv93m4ccws.jpg) + +对于原生云生态系统来说,2019 年是改变游戏规则的一年。有大的[并购][1],如 Red Hat Docker 和 Pivotal,并出现其他的玩家,如 Rancher Labs 和 Mirantis。 + +Rancher Labs (一家为采用容器的团队提供完整软件栈的公司)的联合创始人兼首席执行官盛亮表示:“所有这些整合和并购,都表明这一领域的市场成熟的速度很快。” + +传统上,像 Kubernetes 和 Docker 这样的新兴技术吸引着开发者和像脸书和谷歌这样的超级用户。除了这群人之外则没什么兴趣。然而,这两种技术都在企业层面得到了广泛采用。突然间,出现了一个巨大的市场,有着巨大的机会。几乎每个人都跳了进去。有人带来了创新的解决方案,也有人试图赶上其他人。它很快变得非常拥挤和热闹起来。 + +它也改变了创新的方式。[早期采用者通常是精通技术的公司][2]。现在,几乎每个人都在使用它,即使是在不被认为是 Kubernetes 地盘的地方。它改变了市场动态,像 Rancher Labs 这样的公司见证了独特的用例。 + +盛亮补充道,“我从来没有经历过像 Kubernete 这样快速、动态的市场或技术演变。当我们五年前开始的时候,这是一个非常拥挤的空间。随着时间的推移,我们大多数的友商因为这样或那样的原因消失了。他们要么无法适应变化,要么选择不适应某些变化。” + +在 Kubernetes 的早期,最明显的机会是建立 Kubernetes 发行版本和 Kubernetes 业务。这是新技术。众所周知,它的安装、升级和操作相当的复杂。 + +当谷歌、AWS 和微软进入市场时,一切都变了。当时,一群供应商蜂拥而至,为平台提供解决方案。盛亮表示:“一旦像谷歌这样的云提供商决定将 Kubernetes 作为一项服务,并免费提供亏本出售的商品,以推动基础设施消费;我们就知道,运营和支持 Kubernetes 业务的优势将非常有限了。” + +对谷歌之外的其它玩家来说,并非一切都不好。由于云供应商通过将它作为服务来提供,消除了 Kubernetes 带来的所有复杂性,这意味着更广泛地采用该技术,即使是那些由于运营成本而不愿使用该技术的人也是如此。这意味着 Kubernetes 将变得无处不在,并将成为一个行业标准。 + +“Rancher Labs 是极少数将此视为机遇并比其他公司看得更远的公司之一。我们意识到 Kubernetes 将成为新的计算标准,就像 TCP/IP 成为网络标准一样,”盛亮说。 + +CNCF 在围绕 Kubernetes 构建一个充满活力的生态系统方面发挥着至关重要的作用,创建了一个庞大的社区来构建、培育和商业化原生云开源技术。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/articles/how-kubernetes-became-the-standard-for-compute-resources/ + +作者:[Swapnil Bhartiya][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/author/swapnil/ +[b]: https://github.com/lujun9972 +[1]: https://www.cloudfoundry.org/blog/2019-is-the-year-of-consolidation-why-ibms-deal-with-red-hat-is-a-harbinger-of-things-to-come/ +[2]: https://www.packet.com/blog/open-source-season-on-the-kubernetes-highway/ diff --git a/published/202002/20200219 How to Install Latest Git Version on Ubuntu.md b/published/202002/20200219 How to Install Latest Git Version on Ubuntu.md new file mode 100644 index 0000000000..c05c0d3c02 --- /dev/null +++ b/published/202002/20200219 How to Install Latest Git Version on Ubuntu.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11929-1.html) +[#]: subject: (How to Install Latest Git Version on Ubuntu) +[#]: via: (https://itsfoss.com/install-git-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 上安装最新版本的 Git +====== + +在 Ubuntu 上安装 Git 非常容易。它存在于 [Ubuntu 的主仓库][1]中,你可以像这样[使用 apt 命令][2]安装它: + +``` +sudo apt install git +``` + +很简单?是不是? + +只有一点点小问题(这可能根本不是问题),就是它安装的 [Git][3] 版本。 + +在 LTS 系统上,软件稳定性至关重要,这就是为什么 Ubuntu 18.04 和其他发行版经常提供较旧但稳定的软件版本的原因,它们都经过发行版的良好测试。 + +这就是为什么当你检查 Git 版本时,会看到安装的版本会比 [Git 网站上当前最新 Git 版本][4]旧: + +``` +$ git --version +git version 2.17.1 +``` + +在编写本教程时,网站上提供的版本为 2.25。那么,如何在 Ubuntu 上安装最新的 Git? + +### 在基于 Ubuntu 的 Linux 发行版上安装最新的 Git + +![][5] + +一种方法是[从源代码安装][6]。这种很酷又老派的方法不适合所有人。值得庆幸的是,Ubuntu Git 维护团队提供了 [PPA][7],莫可以使用它轻松地安装最新的稳定 Git 版本。 + +``` +sudo add-apt-repository ppa:git-core/ppa +sudo apt update +sudo apt install git +``` + +即使你以前使用 `apt` 安装了 Git,它也将更新为最新的稳定版本。 + +``` +$ git --version +git version 2.25.0 +``` + +[使用PPA][8] 的好处在于,如果发布了新的 Git 稳定版本,那么就可以通过系统更新获得它。[仅更新 Ubuntu][9] 来获取最新的 Git 稳定版本。 + +### 配置 Git (推荐给开发者) + +如果你出于开发目的安装了 Git,你会很快开始克隆仓库,进行更改并提交更改。 + +如果你尝试提交代码,那么你可能会看到 “Please tell me who you are” 这样的错误: + +``` +$ git commit -m "update readme" + +*** Please tell me who you are. + +Run + + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + +to set your account's default identity. +Omit --global to set the identity only in this repository. + +fatal: unable to auto-detect email address (got 'abhishek@itsfoss.(none)') +``` + +这是因为你还没配置必要的个人信息。 + +正如错误已经暗示的那样,你可以像这样设置全局 Git 配置: + +``` +git config --global user.name "Your Name" +git config --global user.email "you@example.com" +``` + +你可以使用以下命令检查 Git 配置: + +``` +git config --list +``` + +它应该显示如下输出: + +``` +user.email=you@example.com +user.name=Your Name +``` + +配置保存在 `~/.gitconfig` 中。你可以手动修改配置。 + +### 结尾 + +我希望这个小教程可以帮助你在 Ubuntu 上安装 Git。使用 PPA,你可以轻松获得最新的 Git 版本。 + +如果你有任何疑问或建议,请随时在评论部分提问。也欢迎直接写“谢谢” :) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-git-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ubuntu-repositories/ +[2]: https://itsfoss.com/apt-command-guide/ +[3]: https://git-scm.com/ +[4]: https://git-scm.com/downloads +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/install_git_ubuntu.png?ssl=1 +[6]: https://itsfoss.com/install-software-from-source-code/ +[7]: https://launchpad.net/~git-core/+archive/ubuntu/ppa +[8]: https://itsfoss.com/ppa-guide/ +[9]: https://itsfoss.com/update-ubuntu/ diff --git a/published/202002/20200220 Using Python and GNU Octave to plot data.md b/published/202002/20200220 Using Python and GNU Octave to plot data.md new file mode 100644 index 0000000000..5f2b7dba66 --- /dev/null +++ b/published/202002/20200220 Using Python and GNU Octave to plot data.md @@ -0,0 +1,483 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11943-1.html) +[#]: subject: (Using Python and GNU Octave to plot data) +[#]: via: (https://opensource.com/article/20/2/python-gnu-octave-data-science) +[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana) + +使用 Python 和 GNU Octave 绘制数据 +====== + +> 了解如何使用 Python 和 GNU Octave 完成一项常见的数据科学任务。 + +![](https://img.linux.net.cn/data/attachment/album/202002/29/114750tr7qykssk90yrvyz.jpg) + +数据科学是跨越编程语言的知识领域。有些语言以解决这一领域的问题而闻名,而另一些则鲜为人知。这篇文章将帮助你熟悉用一些流行的语言完成数据科学的工作。 + +### 选择 Python 和 GNU Octave 做数据科学工作 + +我经常尝试学习一种新的编程语言。为什么?这既有对旧方式的厌倦,也有对新方式的好奇。当我开始学习编程时,我唯一知道的语言是 C 语言。那些年的编程生涯既艰难又危险,因为我必须手动分配内存、管理指针、并记得释放内存。 + +后来一个朋友建议我试试 Python,现在我的编程生活变得轻松多了。虽然程序运行变得慢多了,但我不必通过编写分析软件来受苦了。然而,我很快就意识到每种语言都有比其它语言更适合自己的应用场景。后来我学习了一些其它语言,每种语言都给我带来了一些新的启发。发现新的编程风格让我可以将一些解决方案移植到其他语言中,这样一切都变得有趣多了。 + +为了对一种新的编程语言(及其文档)有所了解,我总是从编写一些执行我熟悉的任务的示例程序开始。为此,我将解释如何用 Python 和 GNU Octave 编写一个程序来完成一个你可以归类为数据科学的特殊任务。如果你已经熟悉其中一种语言,从它开始,然后通过其他语言寻找相似之处和不同之处。这篇文章并不是对编程语言的详尽比较,只是一个小小的展示。 + +所有的程序都应该在[命令行][2]上运行,而不是用[图形用户界面][3](GUI)。完整的例子可以在 [polyglot_fit 存储库][4]中找到。 + +### 编程任务 + +你将在本系列中编写的程序: + + * 从 [CSV 文件][5]中读取数据 + * 用直线插入数据(例如 `f(x)=m ⋅ x + q`) + * 将结果生成图像文件 + +这是许多数据科学家遇到的常见情况。示例数据是 [Anscombe 的四重奏][6]的第一组,如下表所示。这是一组人工构建的数据,当用直线拟合时会给出相同的结果,但是它们的曲线非常不同。数据文件是一个文本文件,以制表符作为列分隔符,开头几行作为标题。此任务将仅使用第一组(即前两列)。 + +![](https://img.linux.net.cn/data/attachment/album/202002/29/122805h3yrs1dkrgysssxk.png) + +### Python 方式 + +[Python][7] 是一种通用编程语言,是当今最流行的语言之一(依据 [TIOBE 指数][8]、[RedMonk 编程语言排名][9]、[编程语言流行指数][10]、[GitHub Octoverse 状态][11]和其他来源的调查结果)。它是一种[解释型语言][12];因此,源代码由执行该指令的程序读取和评估。它有一个全面的[标准库][13]并且总体上非常好用(我对这最后一句话没有证据;这只是我的拙见)。 + +#### 安装 + +要使用 Python 开发,你需要解释器和一些库。最低要求是: + +* [NumPy][14] 用于简化数组和矩阵的操作 +* [SciPy][15] 用于数据科学 +* [Matplotlib][16] 用于绘图 + +在 [Fedora][17] 安装它们是很容易的: + +``` +sudo dnf install python3 python3-numpy python3-scipy python3-matplotlib +``` + +#### 代码注释 + +在 Python中,[注释][18]是通过在行首添加一个 `#` 来实现的,该行的其余部分将被解释器丢弃: + +``` +# 这是被解释器忽略的注释。 +``` + +[fitting_python.py][19] 示例使用注释在源代码中插入许可证信息,第一行是[特殊注释][20],它允许该脚本在命令行上执行: + +``` +#!/usr/bin/env python3 +``` + +这一行通知命令行解释器,该脚本需要由程序 `python3` 执行。 + +#### 需要的库 + +在 Python 中,库和模块可以作为一个对象导入(如示例中的第一行),其中包含库的所有函数和成员。可以通过使用 `as` 方式用自定义标签重命名它们: + +``` +import numpy as np +from scipy import stats +import matplotlib.pyplot as plt +``` + +你也可以决定只导入一个子模块(如第二行和第三行)。语法有两个(基本上)等效的方式:`import module.submodule` 和 `from module import submodule`。 + +#### 定义变量 + +Python 的变量是在第一次赋值时被声明的: + +``` +input_file_name = "anscombe.csv" +delimiter = "\t" +skip_header = 3 +column_x = 0 +column_y = 1 +``` + +变量类型由分配给变量的值推断。没有具有常量值的变量,除非它们在模块中声明并且只能被读取。习惯上,不应被修改的变量应该用大写字母命名。 + +#### 打印输出 + +通过命令行运行程序意味着输出只能打印在终端上。Python 有 [print()][21] 函数,默认情况下,该函数打印其参数,并在输出的末尾添加一个换行符: + +``` +print("#### Anscombe's first set with Python ####") +``` + +在 Python 中,可以将 `print()` 函数与[字符串类][23]的[格式化能力][22]相结合。字符串具有`format` 方法,可用于向字符串本身添加一些格式化文本。例如,可以添加格式化的浮点数,例如: + +``` +print("Slope: {:f}".format(slope)) +``` + +#### 读取数据 + +使用 NumPy 和函数 [genfromtxt()][24] 读取 CSV 文件非常容易,该函数生成 [NumPy 数组][25]: + +``` +data = np.genfromtxt(input_file_name, delimiter = delimiter, skip_header = skip_header) +``` + +在 Python 中,一个函数可以有数量可变的参数,你可以通过指定所需的参数来传递一个参数的子集。数组是非常强大的矩阵状对象,可以很容易地分割成更小的数组: + +``` +x = data[:, column_x] +y = data[:, column_y] +``` + +冒号选择整个范围,也可以用来选择子范围。例如,要选择数组的前两行,可以使用: + +``` +first_two_rows = data[0:1, :] +``` + +#### 拟合数据 + +SciPy 提供了方便的数据拟合功能,例如 [linregress()][26] 功能。该函数提供了一些与拟合相关的重要值,如斜率、截距和两个数据集的相关系数: + +``` +slope, intercept, r_value, p_value, std_err = stats.linregress(x, y) + +print("Slope: {:f}".format(slope)) +print("Intercept: {:f}".format(intercept)) +print("Correlation coefficient: {:f}".format(r_value)) +``` + +因为 `linregress()` 提供了几条信息,所以结果可以同时保存到几个变量中。 + +#### 绘图 + +Matplotlib 库仅仅绘制数据点,因此,你应该定义要绘制的点的坐标。已经定义了 `x` 和 `y` 数组,所以你可以直接绘制它们,但是你还需要代表直线的数据点。 + +``` +fit_x = np.linspace(x.min() - 1, x.max() + 1, 100) +``` + +[linspace()][27] 函数可以方便地在两个值之间生成一组等距值。利用强大的 NumPy 数组可以轻松计算纵坐标,该数组可以像普通数值变量一样在公式中使用: + +``` +fit_y = slope * fit_x + intercept +``` + +该公式在数组中逐元素应用;因此,结果在初始数组中具有相同数量的条目。 + +要绘图,首先,定义一个包含所有图形的[图形对象][28]: + +``` +fig_width = 7 #inch +fig_height = fig_width / 16 * 9 #inch +fig_dpi = 100 + +fig = plt.figure(figsize = (fig_width, fig_height), dpi = fig_dpi) +``` + +一个图形可以画几个图;在 Matplotlib 中,这些图被称为[轴][29]。本示例定义一个单轴对象来绘制数据点: + +``` +ax = fig.add_subplot(111) + +ax.plot(fit_x, fit_y, label = "Fit", linestyle = '-') +ax.plot(x, y, label = "Data", marker = '.', linestyle = '') + +ax.legend() +ax.set_xlim(min(x) - 1, max(x) + 1) +ax.set_ylim(min(y) - 1, max(y) + 1) +ax.set_xlabel('x') +ax.set_ylabel('y') +``` + +将该图保存到 [PNG 图形文件][30]中,有: + +``` +fig.savefig('fit_python.png') +``` + +如果要显示(而不是保存)该绘图,请调用: + +``` +plt.show() +``` + +此示例引用了绘图部分中使用的所有对象:它定义了对象 `fig` 和对象 `ax`。这在技术上是不必要的,因为 `plt` 对象可以直接用于绘制数据集。《[Matplotlib 教程][31]》展示了这样一个接口: + +``` +plt.plot(fit_x, fit_y) +``` + +坦率地说,我不喜欢这种方法,因为它隐藏了各种对象之间发生的重要交互。不幸的是,有时[官方的例子][32]有点令人困惑,因为他们倾向于使用不同的方法。在这个简单的例子中,引用图形对象是不必要的,但是在更复杂的例子中(例如在图形用户界面中嵌入图形时),引用图形对象就变得很重要了。 + +#### 结果 + +命令行输入: + +``` +#### Anscombe's first set with Python #### +Slope: 0.500091 +Intercept: 3.000091 +Correlation coefficient: 0.816421 +``` + +这是 Matplotlib 产生的图像: + +![Plot and fit of the dataset obtained with Python][33] + +### GNU Octave 方式 + +[GNU Octave][34] 语言主要用于数值计算。它提供了一个简单的操作向量和矩阵的语法,并且有一些强大的绘图工具。这是一种像 Python 一样的解释语言。由于 Octave 的语法[几乎兼容][35] [MATLAB][36],它经常被描述为一个替代 MATLAB 的免费方案。Octave 没有被列为最流行的编程语言,而 MATLAB 则是,所以 Octave 在某种意义上是相当流行的。MATLAB 早于 NumPy,我觉得它是受到了前者的启发。当你看这个例子时,你会看到相似之处。 + +#### 安装 + +[fitting_octave.m][37] 的例子只需要基本的 Octave 包,在 Fedora 中安装相当简单: + +``` +sudo dnf install octave +``` + +#### 代码注释 + +在 Octave 中,你可以用百分比符号(`%`)为代码添加注释,如果不需要与 MATLAB 兼容,你也可以使用 `#`。使用 `#` 的选项允许你编写像 Python 示例一样的特殊注释行,以便直接在命令行上执行脚本。 + +#### 必要的库 + +本例中使用的所有内容都包含在基本包中,因此你不需要加载任何新的库。如果你需要一个库,[语法][38]是 `pkg load module`。该命令将模块的功能添加到可用功能列表中。在这方面,Python 具有更大的灵活性。 + +#### 定义变量 + +变量的定义与 Python 的语法基本相同: + +``` +input_file_name = "anscombe.csv"; +delimiter = "\t"; +skip_header = 3; +column_x = 1; +column_y = 2; +``` + +请注意,行尾有一个分号;这不是必需的,但是它会抑制该行结果的输出。如果没有分号,解释器将打印表达式的结果: + +``` +octave:1> input_file_name = "anscombe.csv" +input_file_name = anscombe.csv +octave:2> sqrt(2) +ans = 1.4142 +``` + +#### 打印输出结果 + +强大的函数 [printf()][39] 是用来在终端上打印的。与 Python 不同,`printf()` 函数不会自动在打印字符串的末尾添加换行,因此你必须添加它。第一个参数是一个字符串,可以包含要传递给函数的其他参数的格式信息,例如: + +``` +printf("Slope: %f\n", slope); +``` + +在 Python 中,格式是内置在字符串本身中的,但是在 Octave 中,它是特定于 `printf()` 函数。 + +#### 读取数据 + +[dlmread()][40] 函数可以读取类似 CSV 文件的文本内容: + +``` +data = dlmread(input_file_name, delimiter, skip_header, 0); +``` + +结果是一个[矩阵][41]对象,这是 Octave 中的基本数据类型之一。矩阵可以用类似于 Python 的语法进行切片: + +``` +x = data(:, column_x); +y = data(:, column_y); +``` + +根本的区别是索引从 1 开始,而不是从 0 开始。因此,在该示例中,`x` 列是第一列。 + +#### 拟合数据 + +要用直线拟合数据,可以使用 [polyfit()][42] 函数。它用一个多项式拟合输入数据,所以你只需要使用一阶多项式: + +``` +p = polyfit(x, y, 1); + +slope = p(1); +intercept = p(2); +``` + +结果是具有多项式系数的矩阵;因此,它选择前两个索引。要确定相关系数,请使用 [corr()][43] 函数: + +``` +r_value = corr(x, y); +``` + +最后,使用 `printf()` 函数打印结果: + +``` +printf("Slope: %f\n", slope); +printf("Intercept: %f\n", intercept); +printf("Correlation coefficient: %f\n", r_value); +``` + +#### 绘图 + +与 Matplotlib 示例一样,首先需要创建一个表示拟合直线的数据集: + +``` +fit_x = linspace(min(x) - 1, max(x) + 1, 100); +fit_y = slope * fit_x + intercept; +``` + +与 NumPy 的相似性也很明显,因为它使用了 [linspace()][44] 函数,其行为就像 Python 的等效版本一样。 + +同样,与 Matplotlib 一样,首先创建一个[图][45]对象,然后创建一个[轴][46]对象来保存这些图: + +``` +fig_width = 7; %inch +fig_height = fig_width / 16 * 9; %inch +fig_dpi = 100; + +fig = figure("units", "inches", +             "position", [1, 1, fig_width, fig_height]); + +ax = axes("parent", fig); + +set(ax, "fontsize", 14); +set(ax, "linewidth", 2); +``` + +要设置轴对象的属性,请使用 [set()][47] 函数。然而,该接口相当混乱,因为该函数需要一个逗号分隔的属性和值对列表。这些对只是代表属性名的一个字符串和代表该属性值的第二个对象的连续。还有其他设置各种属性的函数: + +``` +xlim(ax, [min(x) - 1, max(x) + 1]); +ylim(ax, [min(y) - 1, max(y) + 1]); +xlabel(ax, 'x'); +ylabel(ax, 'y'); +``` + +绘图是用 [plot()][48] 功能实现的。默认行为是每次调用都会重置坐标轴,因此需要使用函数 [hold()][49]。 + +``` +hold(ax, "on"); + +plot(ax, fit_x, fit_y, +     "marker", "none", +     "linestyle", "-", +     "linewidth", 2); +plot(ax, x, y, +     "marker", ".", +     "markersize", 20, +     "linestyle", "none"); + +hold(ax, "off"); +``` + +此外,还可以在 `plot()` 函数中添加属性和值对。[legend][50] 必须单独创建,标签应手动声明: + +``` +lg = legend(ax, "Fit", "Data"); +set(lg, "location", "northwest"); +``` + +最后,将输出保存到 PNG 图像: + +``` +image_size = sprintf("-S%f,%f", fig_width * fig_dpi, fig_height * fig_dpi); +image_resolution = sprintf("-r%f,%f", fig_dpi); + +print(fig, 'fit_octave.png', +      '-dpng', +      image_size, +      image_resolution); +``` + +令人困惑的是,在这种情况下,选项被作为一个字符串传递,带有属性名和值。因为在 Octave 字符串中没有 Python 的格式化工具,所以必须使用 [sprintf()][51] 函数。它的行为就像 `printf()` 函数,但是它的结果不是打印出来的,而是作为字符串返回的。 + +在这个例子中,就像在 Python 中一样,图形对象很明显被引用以保持它们之间的交互。如果说 Python 在这方面的文档有点混乱,那么 [Octave 的文档][52]就更糟糕了。我发现的大多数例子都不关心引用对象;相反,它们依赖于绘图命令作用于当前活动图形。全局[根图形对象][53]跟踪现有的图形和轴。 + +#### 结果 + +命令行上的结果输出是: + +``` +#### Anscombe's first set with Octave #### +Slope: 0.500091 +Intercept: 3.000091 +Correlation coefficient: 0.816421 +``` + +它显示了用 Octave 生成的结果图像。 + +![Plot and fit of the dataset obtained with Octave][54] + +###接下来 + +Python 和 GNU Octave 都可以绘制出相同的信息,尽管它们的实现方式不同。如果你想探索其他语言来完成类似的任务,我强烈建议你看看 [Rosetta Code][55]。这是一个了不起的资源,可以看到如何用多种语言解决同样的问题。 + +你喜欢用什么语言绘制数据?在评论中分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/python-gnu-octave-data-science + +作者:[Cristiano L. Fontana][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cristianofontana +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/analytics-graphs-charts.png?itok=sersoqbV (Analytics: Charts and Graphs) +[2]: https://en.wikipedia.org/wiki/Command-line_interface +[3]: https://en.wikipedia.org/wiki/Graphical_user_interface +[4]: https://gitlab.com/cristiano.fontana/polyglot_fit +[5]: https://en.wikipedia.org/wiki/Comma-separated_values +[6]: https://en.wikipedia.org/wiki/Anscombe%27s_quartet +[7]: https://www.python.org/ +[8]: https://www.tiobe.com/tiobe-index/ +[9]: https://redmonk.com/sogrady/2019/07/18/language-rankings-6-19/ +[10]: http://pypl.github.io/PYPL.html +[11]: https://octoverse.github.com/ +[12]: https://en.wikipedia.org/wiki/Interpreted_language +[13]: https://docs.python.org/3/library/ +[14]: https://numpy.org/ +[15]: https://www.scipy.org/ +[16]: https://matplotlib.org/ +[17]: https://getfedora.org/ +[18]: https://en.wikipedia.org/wiki/Comment_(computer_programming) +[19]: https://gitlab.com/cristiano.fontana/polyglot_fit/-/blob/master/fitting_python.py +[20]: https://en.wikipedia.org/wiki/Shebang_(Unix) +[21]: https://docs.python.org/3/library/functions.html#print +[22]: https://docs.python.org/3/library/string.html#string-formatting +[23]: https://docs.python.org/3/library/string.html +[24]: https://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html +[25]: https://docs.scipy.org/doc/numpy/reference/generated/numpy.array.html +[26]: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linregress.html +[27]: https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html +[28]: https://matplotlib.org/api/_as_gen/matplotlib.figure.Figure.html#matplotlib.figure.Figure +[29]: https://matplotlib.org/api/axes_api.html#matplotlib.axes.Axes +[30]: https://en.wikipedia.org/wiki/Portable_Network_Graphics +[31]: https://matplotlib.org/tutorials/introductory/pyplot.html#sphx-glr-tutorials-introductory-pyplot-py +[32]: https://matplotlib.org/gallery/index.html +[33]: https://opensource.com/sites/default/files/uploads/fit_python.png (Plot and fit of the dataset obtained with Python) +[34]: https://www.gnu.org/software/octave/ +[35]: https://wiki.octave.org/FAQ#Differences_between_Octave_and_Matlab +[36]: https://en.wikipedia.org/wiki/MATLAB +[37]: https://gitlab.com/cristiano.fontana/polyglot_fit/-/blob/master/fitting_octave.m +[38]: https://octave.org/doc/v5.1.0/Using-Packages.html#Using-Packages +[39]: https://octave.org/doc/v5.1.0/Formatted-Output.html#XREFprintf +[40]: https://octave.org/doc/v5.1.0/Simple-File-I_002fO.html#XREFdlmread +[41]: https://octave.org/doc/v5.1.0/Matrices.html +[42]: https://octave.org/doc/v5.1.0/Polynomial-Interpolation.html +[43]: https://octave.org/doc/v5.1.0/Correlation-and-Regression-Analysis.html#XREFcorr +[44]: https://octave.sourceforge.io/octave/function/linspace.html +[45]: https://octave.org/doc/v5.1.0/Multiple-Plot-Windows.html +[46]: https://octave.org/doc/v5.1.0/Graphics-Objects.html#XREFaxes +[47]: https://octave.org/doc/v5.1.0/Graphics-Objects.html#XREFset +[48]: https://octave.org/doc/v5.1.0/Two_002dDimensional-Plots.html#XREFplot +[49]: https://octave.org/doc/v5.1.0/Manipulation-of-Plot-Windows.html#XREFhold +[50]: https://octave.org/doc/v5.1.0/Plot-Annotations.html#XREFlegend +[51]: https://octave.org/doc/v5.1.0/Formatted-Output.html#XREFsprintf +[52]: https://octave.org/doc/v5.1.0/Two_002dDimensional-Plots.html#Two_002dDimensional-Plots +[53]: https://octave.org/doc/v5.1.0/Graphics-Objects.html#XREFgroot +[54]: https://opensource.com/sites/default/files/uploads/fit_octave.png (Plot and fit of the dataset obtained with Octave) +[55]: http://www.rosettacode.org/ diff --git a/published/202003/20170918 Fun and Games in Emacs.md b/published/202003/20170918 Fun and Games in Emacs.md new file mode 100644 index 0000000000..2602ba804c --- /dev/null +++ b/published/202003/20170918 Fun and Games in Emacs.md @@ -0,0 +1,220 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11949-1.html) +[#]: subject: (Fun and Games in Emacs) +[#]: via: (https://www.masteringemacs.org/article/fun-games-in-emacs) +[#]: author: (Mickey Petersen https://www.masteringemacs.org/about) + +“Emacs 游戏机”完全指南 +====== + +又是周一,你正在为你的老板 Lumbergh (LCTT 译注:《上班一条虫》中的副总裁)努力倒腾那些 [无聊之极的文档][1]。为什么不玩玩 Emacs 中类似 zork 的文字冒险游戏来让你的大脑从单调的工作中解脱出来呢? + +但说真的,Emacs 中既有游戏,也有古怪的玩物。有些你可能有所耳闻。这些玩意唯一的共同点就是,它们大多是很久以前就添加到 Emacs 中的:有些东西真的是相当古怪(如你将在下面看到的),而另一些则显然是由无聊的员工或学生们编写的。它们全有一个共同点,都带着一种奇思妙想和随意性,这在今天的 Emacs 中很少见。Emacs 现在变得十分严肃,在某种程度上,它已经与 20 世纪 80 年代那些游戏被编写出来的时候大不一样。 + +### 汉诺塔 + +[汉诺塔][2] 是一款古老的数学解密游戏,有些人可能对它很熟悉,因为它的递归和迭代解决方案经常被用于计算机科学教学辅助。 + +![Tower of Hanoi Screenshot](https://www.masteringemacs.org/static/uploads/hanoi.png) + +Emacs 中有三个命令可以运行汉诺塔:`M-x hanoi` 默认为 3 个碟子; `M-x hanoi-unix` 和 `M-x hanoi-unix-64` 使用 unix 时间戳的位数(32 位或 64 位)作为默认盘子的个数,并且每秒钟自动移动一次,两者不同之处在于后者假装使用 64 位时钟(因此有 64 个碟子)。 + +Emacs 中汉诺塔的实现可以追溯到 20 世纪 80 年代中期——确实是久得可怕。它有一些自定义选项(`M-x customize-group RET hanoi RET`),如启用彩色碟子等。当你离开汉诺塔缓冲区或输入一个字符,你会收到一个讽刺的告别信息(见上图)。 + +### 5x5 + +![5x5 game grid](https://www.masteringemacs.org/static/uploads/5x5.png) + +5x5 的游戏是一个逻辑解密游戏:你有一个 5x5 的网格,中间的十字被填满;你的目标是通过按正确的顺序切换它们的空满状态来填充所有的单元格,从而获得胜利。这并不像听起来那么容易! + +输入 `M-x 5x5` 就可以开始玩了,使用可选的数字参数可以改变网格的大小。这款游戏的有趣之处在于它能向你建议下一步行动并尝试找到该游戏网格的解法。它用到了 Emacs 自己的一款非常酷的符号 RPN 计算器 `M-x calc`(在《[Emacs 快乐计算][3]》这篇文章中,我使用它来解决了一个简单的问题)。 + +所以我喜欢这个游戏的原因是它提供了一个非常复杂的解题器——真的,你应该通过 `M-x find-library RET 5x5` 来阅读其源代码——这是一个试图通过暴力破解游戏解法的“破解器”。 + +创建一个更大的游戏网格,例如输入 `M-10 M-x 5x5`,然后运行下面某个 `crack` 命令。破解器将尝试通过迭代获得最佳解决方案。它会实时运行该游戏,观看起来非常有趣: + +- `M-x 5x5-crack-mutating-best`: 试图通过变异最佳解决方案来破解 5x5。 +- `M-x 5x5-crack-mutating-current`: 试图通过变异当前解决方案来破解 5x5。 +- `M-x 5x5-crack-random`: 尝试使用随机方案解破解 5x5。 +- `M-x 5x5-crack-xor-mutate`: 尝试通过将当前方案和最佳方案进行异或运算来破解 5x5。 + +### 文本动画 + +你可以通过运行 `M-x animation-birthday-present` 并给出你的名字来显示一个奇特的生日礼物动画。它看起来很酷! + +![xkcd](https://imgs.xkcd.com/comics/real_programmers.png) + +这里用的 `animate` 包也用在了 `M-x butterfly` 命令中,这是一个向上面的 [XKCD][4] 漫画致敬而添加到 Emacs 中的命令。当然,漫画中的 Emacs 命令在技术上是无效的,但它的幽默足以弥补这一点。 + +### 黑箱 + +我将逐字引用这款游戏的目标: + +> 游戏的目标是通过向黑盒子发射光线来找到四个隐藏的球。有四种可能: +> 1) 射线将通过盒子不受干扰; +> 2) 它将击中一个球并被吸收; +> 3) 它将偏转并退出盒子,或 +> 4) 立即偏转,甚至不能进入盒子。 + +所以,这有点像我们小时候玩的[战舰游戏][5],但是……是专为物理专业高学历的人准备的吧? + +这是另一款添加于 20 世纪 80 年代的游戏。我建议你输入 `C-h f blackbox` 来阅读玩法说明(文档巨大)。 + + +### 泡泡 + +![Bubbles game](https://www.masteringemacs.org/static/uploads/bubbles.png) + +`M-x bubble` 游戏相当简单:你必须用尽可能少移动清除尽可能多的“泡泡”。当你移除气泡时,其他气泡会掉落并粘在一起。这是一款有趣的游戏,此外如果你使用 Emacs 的图形用户界面,它还支持图像显示。而且它还支持鼠标。 + +你可以通过调用 `M-x bubbles-set-game-` 来设置难度,其中 `` 可以是这些之一:`easy`、`medium`、`difficult`、`hard` 或 `userdefined`。此外,你可以使用:`M-x custom-group bubbles` 来更改图形、网格大小和颜色。 + +由于它即简单又有趣,这是 Emacs 中我最喜欢的游戏之一。 + +### 幸运饼干 + +我喜欢 `fortune` 命令。每当我启动一个新 shell 时,这些与文学片段、谜语相结合的刻薄、无益、常常带有讽刺意味的“建议”就会点亮我的一天。 + +令人困惑的是,Emacs 中有两个包或多或少地做着类似的事情:`fortune` 和 `cookie`。前者主要用于在电子邮件签名中添加幸运饼干消息,而后者只是一个简单的 fortune 格式阅读器。 + +不管怎样,使用 Emacs 的 `cookie` 包前,你首先需要通过 `customize-option RET cookie RET` 来自定义变量 `cookie-file` 告诉它从哪找到 fortune 文件。 + +如果你的操作系统是 Ubuntu,那么你先安装 `fortune` 软件包,然后就能在 `/usr/share/games/fortune/` 目录中找到这些文件了。 + +之后你就可以调用 `M-x cookie` 随机显示 fortune 内容,或者,如果你想的话,也可以调用 `M-x cookie-apropos` 查找所有匹配的饼干。 + +### 破译器 + +这个包完美地抓住了 Emacs 的功利本质:这个包为你破解简单的替换密码(如“密码谜题”)提供了一个很有用的界面。你知道,二十多年前,有些人确实迫切需要破解很多基本的密码。正是像这个模块这样的小玩意让我非常高兴地用起 Emacs 来:一个只对少数人有用的模块,但是,如果你突然需要它了,那么它就在那里等着你。 + +那么如何使用它呢?让我们假设使用 “rot13” 密码:在 26 个字符的字母表中,将字符旋转 13 个位置。 +通过 `M-x ielm` (Emacs 用于 [运行 Elisp][6] 的 REPL 环境)可以很容易在 Emacs 中进行尝试: + +``` +*** Welcome to IELM *** Type (describe-mode) for help. +ELISP> (rot13 "Hello, World") +"Uryyb, Jbeyq" +ELISP> (rot13 "Uryyb, Jbeyq") +"Hello, World" +ELISP> +``` + +简而言之,你将明文旋转了 13 个位置,就得到了密文。你又旋转了一次 13 个位置,就返回了最初的明文。 这就是这个包可以帮助你解决的问题。 + +那么,decipher 模块又是如何帮助我们的呢?让我们创建一个新的缓冲区 `test-cipher` 并输入你的密文(在我的例子中是 `Uryyb,Jbeyq`)。 + +![cipher](https://www.masteringemacs.org/static/uploads/cipher.png) + +你现在面对的是一个相当复杂的界面。现在把光标放在紫色行的密文的任意字符上,并猜测这个字符可能是什么:Emacs 将根据你的选择更新其他明文的猜测结果,并告诉你目前为止字母表中的字符是如何分配的。 + +你现在可以用下面各种助手命令来关闭选项,以帮助推断密码字符可能对应的明文字符: + +- `D`: 列出示意图(该加密算法中双字符对)及其频率 +- `F`: 表示每个密文字母的频率 +- `N`: 显示字符的邻近信息。我不确定这是干啥的。 +- `M` 和 `R`: 保存和恢复一个检查点,允许你对工作进行分支以探索破解密码的不同方法。 + +总而言之,对于这样一个深奥的任务,这个包是相当令人印象深刻的!如果你经常破解密码,也许这个程序包能帮上忙? + +### 医生 + +![doctor](https://www.masteringemacs.org/static/uploads/doctor.png) + +啊,Emacs 医生。其基于最初的 [ELIZA][7],“医生”试图对你说的话进行心理分析,并试图把问题复述给你。体验几分钟,相当有趣,它也是 Emacs 中最著名的古怪玩意之一。你可以使用 `M-x doctor` 来运行它。 + +### Dunnet + +Emacs 自己特有的类 Zork 文字冒险游戏。输入 `M-x dunnet` 就能玩了。这是一款相当不错的游戏,简单的说,它是另一款非常著名的 Emacs 游戏,很少有人真正玩到通关。 + +如果你发现自己能在无聊的文档工作之间空出时间来,那么这是一个超级棒的游戏,内置“老板屏幕”,因为它是纯文本的。 + +哦,还有,不要想着吃掉那块 CPU 卡 :) + +### 五子棋 + +![gomoku](https://www.masteringemacs.org/static/uploads/gomoku.png) + +另一款写于 20 世纪 80 年代的游戏。你必须将 5 个方块连成一条线,井字棋风格。你可以运行 `M-x gomoku` 来与 Emacs 对抗。游戏还支持鼠标,非常方便。你也可以自定义 `gomoku` 组来调整网格的大小。 + +### 生命游戏 + +[康威的生命游戏][8] 是细胞自动机的一个著名例子。Emacs 版本提供了一些启动模式,你可以(通过 elisp 编程)调整 `life-patterns` 变量来更改这些模式。 + +你可以用 `M-x life` 触发生命游戏。事实上,所有的东西,包括显示代码、注释等等一切,总共不到 300 行,这也让人印象深刻。 + +### 乒乓,贪吃蛇和俄罗斯方块 + +![tetris](https://www.masteringemacs.org/static/uploads/tetris.png) + +这些经典游戏都是使用 Emacs 包 `gamegrid` 实现的,这是一个用于构建网格游戏(如俄罗斯方块和贪吃蛇)的通用框架。gamegrid 包的伟大之处在于它同时兼容图形化和终端 Emacs:如果你在 GUI 中运行 Emacs,你会得到精美的图形;如果你没有,你看到简单的 ASCII 艺术。 + +你可以通过输入 `M-x pong`、`M-x snake`、`M-x tetris` 来运行这些游戏。 + +特别是俄罗斯方块游戏实现的非常到位,会逐渐增加速度并且能够滑块。而且既然你已经有了源代码,你完全可以移除那个讨厌的 Z 形块,没人喜欢它! + +### Solitaire + +![solitaire image](https://www.masteringemacs.org/static/uploads/solitaire.png) + +可惜,这不是纸牌游戏,而是一个基于“钉子”的游戏,你可以选择一块石头(`o`)并“跳过”相邻的石头进入洞中(`.`),并在这个过程中去掉你跳过的石头,最终只能在棋盘上留下一块石头,重复该过程直到棋盘被请空(只保留一个石头)。 + +如果你卡住了,有一个内置的解题器名为 `M-x solitire-solve`。 + +### Zone + +我的另一个最爱。这是一个屏幕保护程序——或者更确切地说,是一系列的屏幕保护程序。 + +输入 `M-x zone`,然后看看屏幕上发生了什么! + +你可以通过运行 `M-x zone-when-idle`(或从 elisp 调用它)来配置屏幕保护程序的空闲时间,时间以秒为单位。你也可以通过 `M-x zone-leave-me-alone` 来关闭它。 + +如果在你的同事看着的时候启动它,你的同事肯定会抓狂的。 + +### 乘法解谜 + +![mpuz](https://www.masteringemacs.org/static/uploads/mpuz.png) + +这是另一个脑筋急转弯的益智游戏。当你运行 `M-x mpuz` 时,将看到一个乘法解谜题,你必须将字母替换为对应的数字,并确保数字相加(相乘?)符合结果。 + +如果遇到难题,可以运行 `M-x mpuz-show-solution` 来解决。 + +### 杂项 + +还有更多好玩的东西,但它们就不如刚才那些那么好玩好用了: + +- 你可以通过 `M-x morse-region` 和 `M-x unmorse-region` 将一个区域翻译成莫尔斯电码。 +- Dissociated Press 是一个非常简单的命令,它将一个类似随机穿行的马尔可夫链生成器应用到缓冲区中的文本中,并以此生成无意义的文本。试一下 `M-x dissociated-press`。 +- `gametree` 软件包是一个通过电子邮件记录和跟踪国际象棋游戏的复杂方法。 +- `M-x spook` 命令插入随机单词(通常是到电子邮件中),目的是混淆/超载 “NSA 拖网渔船” —— 记住,这个模块可以追溯到 20 世纪 80 年代和 90 年代,那时应该有间谍们在监听各种单词。当然,即使是在十年前,这样做也会显得非常偏执和古怪,不过现在看来已经不那么奇怪了…… + +### 总结 + +我喜欢 Emacs 附带的游戏和玩具。它们大多来自于,嗯,我们姑且称之为一个不同的时代:一个允许或甚至鼓励奇思妙想的时代。有些玩意非常经典(如俄罗斯方块和汉诺塔),有些对经典游戏进行了有趣的变种(如黑盒)——但我很高兴这么多年后它们依然存在于 Emacs 中。我想知道时至今日,类似这些的玩意是否还会再纳入 Emacs 的代码库中;嗯,它们很可能不会——它们将被归入包管理仓库中,而在这个干净而无菌的世界中,它们无疑属于包管理仓库。 + +Emacs 要求将对 Emacs 体验不重要的内容转移到包管理仓库 ELPA 中。我的意思是,作为一个开发者,这是有道理的,但是……对于每一个被移出并流放到 ELPA 的包,我们是不是在蚕食 Emacs 的精髓? + +-------------------------------------------------------------------------------- + + +via: https://www.masteringemacs.org/article/fun-games-in-emacs + +作者:[Mickey Petersen][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.masteringemacs.org/about +[b]:https://github.com/lujun9972 +[1]:https://en.wikipedia.org/wiki/Office_Space +[2]:https://en.wikipedia.org/wiki/Tower_of_Hanoi +[3]:https://www.masteringemacs.org/article/fun-emacs-calc +[4]:http://www.xkcd.com +[5]:https://en.wikipedia.org/wiki/Battleship_(game) +[6]:https://www.masteringemacs.org/article/evaluating-elisp-emacs +[7]:https://en.wikipedia.org/wiki/ELIZA +[8]:https://en.wikipedia.org/wiki/Conway's_Game_of_Life diff --git a/published/202003/20180306 Exploring free and open web fonts.md b/published/202003/20180306 Exploring free and open web fonts.md new file mode 100644 index 0000000000..3e688cbd35 --- /dev/null +++ b/published/202003/20180306 Exploring free and open web fonts.md @@ -0,0 +1,71 @@ +探索自由而开放的 Web 字体 +====== + +> 谷歌字体和开放字体库中的免费 Web 字体已经改变了游戏规则,但仅在有限的范围内。 + +![](https://img.linux.net.cn/data/attachment/album/202003/08/174910xoklikblgkkbooib.jpg) + +毫无疑问,近些年来互联网的面貌已经被开源字体所改变。早在 2010 年之前,你在 Web 浏览器上几乎只能看到微软制作的通常“Web 安全”的[核心字体][1]。但这一年(2010)正好是好几轮技术革新开始的见证之年:[Web 开放字体格式][2]Web Open Font Format(WOFF)的引入为通过 HTTP 有效地传输字体文件提供了一个开放的标准,以及像[谷歌字体][3]和[开放字体库][4]Open Font Library这样的 Web 字体服务的推出,使得 Web 内容发布者可以在开源许可证之下免费使用海量的字体库。 + +这些事件对 Web 排版的积极影响再夸大都不过分。但是要将 Web 开放字体的成功与整个开源排版等同起来,并得到结论——挑战已经远离了我们,困难悉数被解决了——却很容易。然而事实并非如此,如果你很关注字体,那么好消息是你有好多机会参与到对这些字体的改进工作当中去。 + +对新手来说,至关重要的是必须要意识到谷歌字体和开放字体库提供了专用的服务(为网页提供字体),而没有为其他使用情况制定字体解决方案。这不是服务方面的缺点,这只是意味着我们必须去开发其它的解决方案。 + +需要解决的问题还非常多。可能最明显的例子就是给 Linux 桌面计算机的其他软件安装字体所遇到的尴尬情况。你可以通过任何一种服务下载任何一种 Web 字体,但是你得到的只是一个最普通的压缩包文件,里面有一些 TTF 或 OTF 二进制文件和一个普通文本文件的许可证。接下来会发生什么完完全全需要你去猜。 + +大部分用户很快学会了“正确”的步骤就是手动地复制这些字体二进制文件到他们硬盘里几个特殊文件夹里的某一个里。但是这样做只能使这个文件对操作系统可见。它并不能为用户体验带来什么提升。再强调一遍,这不是 Web 字体服务的缺陷,相反它佐证了对于关于服务到哪里停止和需要在其他方面做更多工作的观点。 + +在用户视角来说,一个巨大的提升可能就是在“只是下载”这个阶段,操作系统或者桌面环境变得更智能。系统或桌面环境不仅会把字体文件安装到正确的位置上,更重要的是,当用户选择要在一个项目中使用的字体时,它会自己添加用户所需要的重要的元数据。 + +这些附加信息包含的内容与它如何呈现给用户与另一个挑战有关:与其它操作系统相比,在 Linux 环境管理一个字体库显然不那么令人满意。字体管理器总是时不时的出现一下(例如 [GTK+ 字体管理器][5],这是最近的一个例子),但是它们很少变得流行起来。我一直在思考一大堆这些软件让人失望的方面。一个核心的原因是它们把自己局限于只展示内嵌在二进制字体文件内的信息:基本字符集的覆盖、粗细/宽度和斜率的设定,内置的许可证和版权说明等等。 + +但是除了这些内嵌数据中的内容,在选择字体的过程中还涉及很多决策。严肃的字体用户,像信息设计者、杂志文章作者,或者书籍美工设计者,他们的字体选择是根据每一份文件的要求和需求做出的。这当然包含了许可证信息,但它还包含了更多,像关于设计师和厂商的信息、潮流风格的趋势,或者字体在使用中的细节。 + +举个例子,如果你的文档包含了英语和阿拉伯文,你多半想要拉丁文和阿拉伯文的字体由同时熟悉这两种字母系统script的设计师所设计。否则,你将浪费一大堆时间来微调字体大小和行间距来使两种字母系统良好地结合在一起。你可能从经验中学到,某些设计师或字体厂商比其他人更善于多种字母系统设计。或许和你职业相关的是今天的时尚杂志几乎无一例外的采用 “[Didone][6]”风格的字体,“[Didone][6]”是指一种两百多年前最先被 [Firmin Didot][7] 和 [Giambattista Bodoni][8] 设计出来的超高反差的字体风格。这种字体恰好就是现在的潮流。 + +但是像 Didone、Didot 或 Bodoni 这些术语都不可能会出现在二进制文件的内置数据当中,你也不容易判断拉丁文和阿拉伯文是否相得益彰或其它关于字体的历史背景。这些信息有可能出现在补充的材料中,类似某种字形样本或字体文件中,如果这些东西存在的话。 + +字形样本specimen是一份设计好的文档(一般是 PDF),它展示了这种字体的使用情况,而且包括了背景信息。字形样本经常在挑选字体时充当市场营销和外观样例的双重角色。一份精心设计的样本展示了字体在实际应用中的情况和在自动生成的字符表中所不能体现的风格。字形样本文件也有可能包含了一些其他重要信息,比如怎样激活字体的 OpenType 特性、提供的数学表达式或古体字,或者它在支持的多种语言上的风格变化。在字体管理应用程序中向用户提供此类材料,对于帮助用户找到适合其项目需求的字体将大有帮助。 + +当然,如果我们希望一个字体管理软件能够处理文件和样本问题,我们也必须仔细观察一下各种发行版提供的字体包所随附的内容。Linux 的用户刚开始只有自动安装的那几种字体,并且发行版存储库提供的包是大部分用户除了下载通用的压缩包档案之外的唯一字体来源。这些包往往非常的“简陋”。商业字体总的来说都包含了样本、文档,还有其他的支持项目,然而开源字体往往没有这些配套文件。 + +也有一些优秀的开放字体提供了高质量的样本和文档(例如 [SIL Gentium][9] 和 [Bungee][10] 是两种差异明显但是都有效的方案),但是它们几乎不涉足下游的打包工作链。我们显然可以做的更好一些。 + +要在系统的字体交互方面提供更丰富的用户体验上面还存在一些技术问题。一方面,[AppStream][11] 的元数据标准定义了一些字体文件特有的参数,但是到现在为止,这些参数没有包含样本、设计师/厂商和其他相关细节的任何信息。另外一个例子,[SPDX][13](软件包数据交换Software Package Data Exchange)格式也没有包含太多用于分发字体的软件许可证(及许可证变体)。 + +最后,就像任何一个唱片爱好者都会告诉你的,一个不允许你编辑和完善你的 MP3 曲库中的 ID3 信息的音乐播放器很快就会变得令人失望(LCTT 译注:ID3 信息是 MP3 文件头部的元信息,用于存储歌曲信息)。你想要处理标签里的错误、想要添加注释和专辑封面之类的信息,本质上,这就是完善你的音乐库。同样,你可能也想要让你的本地字体库也保持在一个方便使用的状态。 + +但是改动字体文件的内置数据一直有所忌讳,因为字体往往是被内置或附加到其他文件里的。如果你随意改变了字体二进制文件中的字段,然后将其与你的演示文稿一起重新分发,那么下载这些演示文稿的任何人最终都会得到错误的元数据,但这个错误不是他们自己造成的。所以任何一个要改善字体管理体验的人都要想明白如何从策略上解决对内置或外置的字体元数据的重复修改。 + +除了技术角度之外,丰富的字体管理经验也是一项设计挑战。就像我在前面说的一样,有几种开放字体也带了良好的样本和精心编写的文档。但是更多的字体包这两者都没有,还有大量的更老的字体包已经没有人维护了。这很可能意味着大部分开放字体包想要获得样本和证明文件的唯一办法就是让社区去创建它们。 + +也许这是一个很高的要求。但是开源设计社区现在比以往任何时候都要庞大,它是整个自由开源软件运动中的一个高度活跃的组成部分。所以谁知道呢,也许明年这个时候会发现,在 Linux 桌面系统查找、下载和使用字体会变成一种完全不同的体验。 + +在这一连串关于现代 Linux 用户的文字设计上的挑战的思考中包含了打包、文档设计,甚至有可能需要在桌面环境加入不少新的软件部分。此外还有其他一系列的东西也需要考虑。其共通性就是在 Web 字体服务不可及的地方,事情就会变得更加困难。 + +从我的视角来看,最好的消息是现在比起以前有更多的人对这个话题感兴趣。我认为我们要感谢像谷歌字体和开放字体库这样的 Web 字体服务巨头让开放字体得到了更高的关注。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/webfonts + +作者:[Nathan Willis][a] +译者:[Fisherman110](https://github.com/Fisherman110) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/n8willis +[1]:https://en.wikipedia.org/wiki/Core_fonts_for_the_Web +[2]:https://en.wikipedia.org/wiki/Web_Open_Font_Format +[3]:https://fonts.google.com/ +[4]:https://fontlibrary.org/ +[5]:https://fontmanager.github.io/ +[6]:https://en.wikipedia.org/wiki/Didone_(typography) +[7]:https://en.wikipedia.org/wiki/Firmin_Didot +[8]:https://en.wikipedia.org/wiki/Giambattista_Bodoni +[9]:https://software.sil.org/gentium/ +[10]:https://djr.com/bungee/ +[11]:https://www.freedesktop.org/wiki/Distributions/AppStream/ +[12]:https://www.freedesktop.org/software/appstream/docs/sect-Metadata-Fonts.html +[13]:https://spdx.org/ diff --git a/published/202003/20180522 Advanced use of the less text file viewer in Linux.md b/published/202003/20180522 Advanced use of the less text file viewer in Linux.md new file mode 100644 index 0000000000..399f0d05b8 --- /dev/null +++ b/published/202003/20180522 Advanced use of the less text file viewer in Linux.md @@ -0,0 +1,109 @@ +你所不知道的用 less 查看文件的高级用法 +====== + +> 使用 less 文件查看器的一些技巧。 + +![](https://img.linux.net.cn/data/attachment/album/202003/16/152826assmtybsohopo4b7.png) + +最近,我正在拜读 Scott Nesbitt 的文章《[在 Linux 命令行中使用 less 来查看文本文件][1]》,并受到了一些启发,所以我想分享一些使用 `less` 命令的技巧。 + +### LESS 环境变量 + +如果你定义了环境变量 `LESS`(例如在 `.bashrc` 中),那么 `less` 会将其视为一个选项列表,就像在命令行中传递给它一样。 + +我这样定义: + +``` +LESS='-C -M -I -j 10 -# 4' +``` + +它的意思是: + +* `-C` – 通过不从底部滚动来加快全屏打印速度。 +* `-M` – 在最后一行(状态行)显示更多信息。你可以使用 `-PM` 来自定义显示的信息,但我通常只用 `-M`。 +* `-I` – 忽略搜索中的大小写。 +* `-j 10` – 在终端的第 10 行而不是第一行显示搜索结果。这样,每次按 `n` 或(`N`) 跳到下一个(或上一个)匹配项时,就会有 10 条上下文。 +* `-# 4` – 当按下向右或向左的箭头时,会向右或向左跳四个字符。默认情况时跳转半个屏幕,我觉得太多了。一般来说,`less` 似乎(至少部分)是按最初开发它时的环境优化的,那时使用慢速调制解调器和低带宽的互联网连接,所以跳过半个屏幕是有意义的。 + +### PAGER 环境变量 + +许多程序使用在 `PAGER` 环境变量中的命令来显示信息。因此,你可以在 `.bashrc` 中设置 `PAGER=less`,然后让程序运行 `less`。查看手册页(`man 7 environ`)中是否有其它此类变量。 + +### -S + +`-S` 告诉 `less` 将长行切断而不是将它们换行。除非我在(或我要)查看文件,否则我很少需要这样做。幸运的是,你可以在 `less` 中输入所有命令行选项,就像它们是键盘命令一样。因此,如果我想在文件已经打开的情况下隔断长行,我可以简单地输入 `-S`。(LCTT 译注:注意大写 `S` ,并按回车) + +这是我经常使用的一个例子: + +``` +su - postgres +export PAGER=less  # 因为我不用在所有的机器上编辑 postgres 的 .bashrc +psql +``` + +有时当我查看一个 `SELECT` 命令的输出非常宽时,我会输入 `-S` 以便将其格式化的漂亮一些。如果当我按下右箭头想查看更多内容时它跳得太远(因为我没有设置 `-#`),则可以输入 `-#8`,那么每次按下右箭头都会向右移动八个字符。 + +有时在多次输入 `-S` 之后,我会退出 psql 并设置环境变量后再次运行它: + +``` +export LESS=-S +``` + +### F + +命令 `F` 可以使 `less` 像 `tail -f` 一样工作,等待更多的数据被添加到文件后再显示它们。与 `tail -f` 相比,它的一个优点是,高亮显示搜索匹配仍然有效。因此,你可以输入 `less /var/log/logfile`,搜索某些内容时,它将高亮显示所有出现的内容(除非你使用了 `-g`),然后按下 `F` 键,当更多数据写入到日志时,`less` 将显示它并高亮新的匹配项。 + +按下 `F` 后,可以按 `Ctrl+C` 来停止其查找新数据(这不会干掉它),这样你可以返回文件查看旧内容,搜索其它内容等,然后再次按 `F` 键来查看更多新数据。 + +### 搜索 + +搜索使用系统的正则表达式库,这通常意味着你可以使用扩展正则表达式。特别是,搜索 `one|two|three` 可以找到并高亮所有的 one、two 或 three。 + +我经常使用的另一种模式是 `.*someting.*`,特别是对于一些很长的日志行(例如,跨越多个终端宽度的行),它会高亮整行。这种模式使查看一行的起始和结束位置变得更加容易。我还会结合其它内容,例如 `.*one thing.*|.*another thing.*`,或者使用 `key: .*|.*marker.*` 来查看 `key` 的内容。例如,一个日志文件中包含一些字典/哈希的转储。它会高亮相关的标记行,这样我就看到上下文了,甚至,如果我知道这个值被引号引起来的话,就可以: + +``` +key: '[^']*'|.*marker.* +``` + +`less` 会保留你的搜索项的历史纪录,并将其保存到磁盘中以备将来调用。当你按下 `/` 或 `?` 时,可以使用向上或向下箭头浏览历史记录(以及进行基本的行编辑)。 + +在撰写本文时,我无意间看了下 `less` 手册页,发现了一个非常有用的功能:使用 `&!pattern` 跳过无关的行。例如,当我在 `/var/log/messages` 中寻找内容时,经常会一个个迭代使用以下命令: + +``` +cat /var/log/messages | egrep -v 'systemd: Started Session' | less +cat /var/log/messages | egrep -v 'systemd: Started Session|systemd: Starting Session' | less +cat /var/log/messages | egrep -v 'systemd: Started Session|systemd: Starting Session|User Slice' | less +cat /var/log/messages | egrep -v 'systemd: Started Session|systemd: Starting Session|User Slice|dbus' | less +cat /var/log/messages | egrep -v 'systemd: Started Session|systemd: Starting Session|User Slice|dbus|PackageKit Daemon' | less +``` + +但是现在我知道如何在 `less` 中做同样的事情。例如,我可以输入 `&!systemd: Started Session`,然后想要隐藏 `systemd: Starting Session`,所以我输入 `&!`,并使用向上箭头从历史记录中获得上一次搜索的结果。然后我接着输入 `|systemd: Starting Session` 并按下回车,继续以相同的方式添加更多条目,直到我过滤掉足够多的条目,看到更有趣的内容。 + +### = + +命令 `=` 显示有关文件和位置的更多信息,甚至比 `-M` 更多。如果文件非常大,计算 `=` 花费的时间太长,可以按下 `Ctrl+C`,它将停止尝试计算。 + +如果你正在查看的内容来自管道而不是文件,则 `=`(和 `-M`)不会显示未知内容,包括文件中的行数和字节数。要查看这些数据,如果你知道管道命令将很快结束,则可以使用 `G` 跳到最后,然后 `less` 将开始显示这些信息。 + +如果按下 `G` 并且写入管道的命令花费的时间比预期的长,你可以按下 `Ctrl+C`,该命令将被终止。即使你没有按 `G`,`Ctrl+C` 键也会杀死它。因此,如果你不想终止命令,请不要意外按下 `Ctrl+C`。出于这个原因,如果命令执行了某些操作(不仅是显示信息),通常更安全的做法是将其输出写入文件并在单独的终端中查看文件,而不是使用管道。 + +### 为什么你需要 less + +`less` 是一个非常强大的程序,与该领域中较新的竞争者(例如 `most` 和 `moar`)不同,你可能会在几乎所有的系统上找到它,就像 `vi` 一样。因此,即使你使用 GUI 查看器或编辑器,花一些时间浏览 `less` 手册页也是值得的,至少可以了解一下它的用处。这样,当你需要做一些已有的功能可能提供的工作时,就会知道如何要搜索手册页或互联网来找到所需的内容。 + +有关更多信息,访问 [less 主页][2]。该网站有一个不错的常见问题解答,其中包含更多提示和技巧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/advanced-use-less-text-file-viewer + +作者:[Yedidyah Bar David][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/didib +[1]:http://opensource.com/article/18/4/using-less-view-text-files-command-line +[2]:http://www.greenwoodsoftware.com/less/ diff --git a/sources/tech/20180708 Building a Messenger App- Conversations.md b/published/202003/20180708 Building a Messenger App- Conversations.md similarity index 60% rename from sources/tech/20180708 Building a Messenger App- Conversations.md rename to published/202003/20180708 Building a Messenger App- Conversations.md index 1a5c7d251a..722383745d 100644 --- a/sources/tech/20180708 Building a Messenger App- Conversations.md +++ b/published/202003/20180708 Building a Messenger App- Conversations.md @@ -1,41 +1,41 @@ [#]: collector: (lujun9972) [#]: translator: (PsiACE) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12056-1.html) [#]: subject: (Building a Messenger App: Conversations) [#]: via: (https://nicolasparada.netlify.com/posts/go-messenger-conversations/) [#]: author: (Nicolás Parada https://nicolasparada.netlify.com/) -Building a Messenger App: Conversations +构建一个即时消息应用(三):对话 ====== -This post is the 3rd in a series: +![](https://img.linux.net.cn/data/attachment/album/202003/30/193824w7xsj2ixs8frsal8.jpg) - * [Part 1: Schema][1] - * [Part 2: OAuth][2] +本文是该系列的第三篇。 +* [第一篇:模式][1] +* [第二篇:OAuth][2] +在我们的即时消息应用中,消息表现为两个参与者对话的堆叠。如果你想要开始一场对话,就应该向应用提供你想要交谈的用户,而当对话创建后(如果该对话此前并不存在),就可以向该对话发送消息。 -In our messenger app, messages are stacked by conversations between two participants. You start a conversation providing the user you want to chat with, the conversations is created (if not exists already) and you can start sending messages to that conversations. +就前端而言,我们可能想要显示一份近期对话列表。并在此处显示对话的最后一条消息以及另一个参与者的姓名和头像。 -On the front-end we’re interested in showing a list of the lastest conversations. There we’ll show the last message of it and the name and avatar of the other participant. +在这篇帖子中,我们将会编写一些端点endpoint来完成像“创建对话”、“获取对话列表”以及“找到单个对话”这样的任务。 -In this post, we’ll code the endpoints to start a conversation, list the latest and find a single one. +首先,要在主函数 `main()` 中添加下面的路由。 -Inside the `main()` function add this routes. - -``` +```go router.HandleFunc("POST", "/api/conversations", requireJSON(guard(createConversation))) router.HandleFunc("GET", "/api/conversations", guard(getConversations)) router.HandleFunc("GET", "/api/conversations/:conversationID", guard(getConversation)) ``` -These three endpoints require authentication so we use the `guard()` middleware. There is a new middleware that checks for the request content type JSON. +这三个端点都需要进行身份验证,所以我们将会使用 `guard()` 中间件。我们也会构建一个新的中间件,用于检查请求内容是否为 JSON 格式。 -### Require JSON Middleware +### JSON 请求检查中间件 -``` +```go func requireJSON(handler http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if ct := r.Header.Get("Content-Type"); !strings.HasPrefix(ct, "application/json") { @@ -47,11 +47,11 @@ func requireJSON(handler http.HandlerFunc) http.HandlerFunc { } ``` -If the request isn’t JSON, it responds with a `415 Unsupported Media Type` error. +如果请求request不是 JSON 格式,那么它会返回 `415 Unsupported Media Type`(不支持的媒体类型)错误。 -### Create Conversation +### 创建对话 -``` +```go type Conversation struct { ID string `json:"id"` OtherParticipant *User `json:"otherParticipant"` @@ -60,9 +60,9 @@ type Conversation struct { } ``` -So, a conversation holds a reference to the other participant and the last message. Also has a bool field to tell if it has unread messages. +就像上面的代码那样,对话中保持对另一个参与者和最后一条消息的引用,还有一个 `bool` 类型的字段,用来告知是否有未读消息。 -``` +```go type Message struct { ID string `json:"id"` Content string `json:"content"` @@ -74,11 +74,11 @@ type Message struct { } ``` -Messages are for the next post, but I define the struct now since we are using it. Most of the fields are the same as the database table. We have `Mine` to tell if the message is owned by the current authenticated user and `ReceiverID` will be used to filter messanges once we add realtime capabilities. +我们会在下一篇文章介绍与消息相关的内容,但由于我们这里也需要用到它,所以先定义了 `Message` 结构体。其中大多数字段与数据库表一致。我们需要使用 `Mine` 来断定消息是否属于当前已验证用户所有。一旦加入实时功能,`ReceiverID` 可以帮助我们过滤消息。 -Lets write the HTTP handler then. It’s quite long but don’t be scared. +接下来让我们编写 HTTP 处理程序。尽管它有些长,但也没什么好怕的。 -``` +```go func createConversation(w http.ResponseWriter, r *http.Request) { var input struct { Username string `json:"username"` @@ -170,19 +170,19 @@ func createConversation(w http.ResponseWriter, r *http.Request) { } ``` -For this endpoint you do a POST request to `/api/conversations` with a JSON body containing the username of the user you want to chat with. +在此端点,你会向 `/api/conversations` 发送 POST 请求,请求的 JSON 主体中包含要对话的用户的用户名。 -So first it decodes the request body into an struct with the username. Then it validates that the username is not empty. +因此,首先需要将请求主体解析成包含用户名的结构。然后,校验用户名不能为空。 -``` +```go type Errors struct { Errors map[string]string `json:"errors"` } ``` -This is the `Errors` struct. It’s just a map. If you enter an empty username you get this JSON with a `422 Unprocessable Entity` error. +这是错误消息的结构体 `Errors`,它仅仅是一个映射。如果输入空用户名,你就会得到一段带有 `422 Unprocessable Entity`(无法处理的实体)错误消息的 JSON 。 -``` +```json { "errors": { "username": "Username required" @@ -190,17 +190,17 @@ This is the `Errors` struct. It’s just a map. If you enter an empty username y } ``` -Then, we begin an SQL transaction. We only received an username, but we need the actual user ID. So the first part of the transaction is to query for the id and avatar of that user (the other participant). If the user is not found, we respond with a `404 Not Found` error. Also, if the user happens to be the same as the current authenticated user, we respond with `403 Forbidden`. There should be two different users, not the same. +然后,我们开始执行 SQL 事务。收到的仅仅是用户名,但事实上,我们需要知道实际的用户 ID 。因此,事务的第一项内容是查询另一个参与者的 ID 和头像。如果找不到该用户,我们将会返回 `404 Not Found`(未找到) 错误。另外,如果找到的用户恰好和“当前已验证用户”相同,我们应该返回 `403 Forbidden`(拒绝处理)错误。这是由于对话只应当在两个不同的用户之间发起,而不能是同一个。 -Then, we try to find a conversation those two users have in common. We use `INTERSECT` for that. If there is one, we redirect to that conversation `/api/conversations/{conversationID}` and return there. +然后,我们试图找到这两个用户所共有的对话,所以需要使用 `INTERSECT` 语句。如果存在,只需要通过 `/api/conversations/{conversationID}` 重定向到该对话并将其返回。 -If no common conversation was found, we continue by creating a new one and adding the two participants. Finally, we `COMMIT` the transaction and respond with the newly created conversation. +如果未找到共有的对话,我们需要创建一个新的对话并添加指定的两个参与者。最后,我们 `COMMIT` 该事务并使用新创建的对话进行响应。 -### Get Conversations +### 获取对话列表 -This endpoint `/api/conversations` is to get all the conversations of the current authenticated user. +端点 `/api/conversations` 将获取当前已验证用户的所有对话。 -``` +```go func getConversations(w http.ResponseWriter, r *http.Request) { ctx := r.Context() authUserID := ctx.Value(keyAuthUserID).(string) @@ -267,17 +267,17 @@ func getConversations(w http.ResponseWriter, r *http.Request) { } ``` -This handler just does a query to the database. It queries to the conversations table with some joins… First, to the messages table to get the last message. Then to the participants, but it adds a condition to a participant whose ID is not the one of the current authenticated user; this is the other participant. Then it joins to the users table to get his username and avatar. And finally joins with the participants again but with the contrary condition, so this participant is the current authenticated user. We compare `messages_read_at` with the message `created_at` to know whether the conversation has unread messages. And we use the message `user_id` to check if it’s “mine” or not. +该处理程序仅对数据库进行查询。它通过一些联接来查询对话表……首先,从消息表中获取最后一条消息。然后依据“ID 与当前已验证用户不同”的条件,从参与者表找到对话的另一个参与者。然后联接到用户表以获取该用户的用户名和头像。最后,再次联接参与者表,并以相反的条件从该表中找出参与对话的另一个用户,其实就是当前已验证用户。我们会对比消息中的 `messages_read_at` 和 `created_at` 两个字段,以确定对话中是否存在未读消息。然后,我们通过 `user_id` 字段来判定该消息是否属于“我”(指当前已验证用户)。 -Note that this query assumes that a conversation has just two users. It only works for that scenario. Also, if you want to show a count of the unread messages, this design isn’t good. I think you could add a `unread_messages_count` `INT` field on the `participants` table and increment it each time a new message is created and reset it when the user read them. +注意,此查询过程假定对话中只有两个用户参与,它也仅仅适用于这种情况。另外,该设计也不很适用于需要显示未读消息数量的情况。如果需要显示未读消息的数量,我认为可以在 `participants` 表上添加一个`unread_messages_count` `INT` 字段,并在每次创建新消息的时候递增它,如果用户已读则重置该字段。 -Then it iterates over the rows, scan each one to make an slice of conversations and respond with those at the end. +接下来需要遍历每一条记录,通过扫描每一个存在的对话来建立一个对话切片slice of conversations并在最后进行响应。 -### Get Conversation +### 找到单个对话 -This endpoint `/api/conversations/{conversationID}` respond with a single conversation by its ID. +端点 `/api/conversations/{conversationID}` 会根据 ID 对单个对话进行响应。 -``` +```go func getConversation(w http.ResponseWriter, r *http.Request) { ctx := r.Context() authUserID := ctx.Value(keyAuthUserID).(string) @@ -321,17 +321,17 @@ func getConversation(w http.ResponseWriter, r *http.Request) { } ``` -The query is quite similar. We’re not interested in showing the last message, so we omit those fields, but we need the message to know whether the conversation has unread messages. This time we do a `LEFT JOIN` instead of an `INNER JOIN` because the `last_message_id` is `NULLABLE`; in other case we won’t get any rows. We use an `IFNULL` in the `has_unread_messages` comparison for that reason too. Lastly, we filter by ID. +这里的查询与之前有点类似。尽管我们并不关心最后一条消息的显示问题,并因此忽略了与之相关的一些字段,但是我们需要根据这条消息来判断对话中是否存在未读消息。此时,我们使用 `LEFT JOIN` 来代替 `INNER JOIN`,因为 `last_message_id` 字段是 `NULLABLE`(可以为空)的;而其他情况下,我们无法得到任何记录。基于同样的理由,我们在 `has_unread_messages` 的比较中使用了 `IFNULL` 语句。最后,我们按 ID 进行过滤。 -If the query returns no rows, we respond with a `404 Not Found` error, otherwise `200 OK` with the found conversation. +如果查询没有返回任何记录,我们的响应会返回 `404 Not Found` 错误,否则响应将会返回 `200 OK` 以及找到的对话。 * * * -Yeah, that concludes with the conversation endpoints. +本篇帖子以创建了一些对话端点结束。 -Wait for the next post to create and list messages 👋 +在下一篇帖子中,我们将会看到如何创建并列出消息。 -[Souce Code][3] +- [源代码][3] -------------------------------------------------------------------------------- @@ -340,12 +340,12 @@ via: https://nicolasparada.netlify.com/posts/go-messenger-conversations/ 作者:[Nicolás Parada][a] 选题:[lujun9972][b] 译者:[PsiACE](https://github.com/PsiACE) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://nicolasparada.netlify.com/ [b]: https://github.com/lujun9972 -[1]: https://nicolasparada.netlify.com/posts/go-messenger-schema/ -[2]: https://nicolasparada.netlify.com/posts/go-messenger-oauth/ +[1]: https://linux.cn/article-11396-1.html +[2]: https://linux.cn/article-11510-1.html [3]: https://github.com/nicolasparada/go-messenger-demo diff --git a/sources/tech/20181231 Troubleshooting hardware problems in Linux.md b/published/202003/20181231 Troubleshooting hardware problems in Linux.md similarity index 57% rename from sources/tech/20181231 Troubleshooting hardware problems in Linux.md rename to published/202003/20181231 Troubleshooting hardware problems in Linux.md index dcc89034db..34dbed5f44 100644 --- a/sources/tech/20181231 Troubleshooting hardware problems in Linux.md +++ b/published/202003/20181231 Troubleshooting hardware problems in Linux.md @@ -1,26 +1,28 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11953-1.html) [#]: subject: (Troubleshooting hardware problems in Linux) [#]: via: (https://opensource.com/article/18/12/troubleshooting-hardware-problems-linux) [#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) -Troubleshooting hardware problems in Linux +Linux 硬件故障排除指南 ====== -Learn what's causing your Linux hardware to malfunction so you can get it back up and running quickly. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_other11x_cc.png?itok=I_kCDYj0) -[Linux servers][1] run mission-critical business applications in many different types of infrastructures including physical machines, virtualization, private cloud, public cloud, and hybrid cloud. It's important for Linux sysadmins to understand how to manage Linux hardware infrastructure—including software-defined functionalities related to [networking][2], storage, Linux containers, and multiple tools on Linux servers. +> 了解是什么原因导致你的 Linux 硬件发生故障,以便你可以将其恢复并快速运行。 -It can take some time to troubleshoot and solve hardware-related issues on Linux. Even highly experienced sysadmins sometimes spend hours working to solve mysterious hardware and software discrepancies. +![](https://img.linux.net.cn/data/attachment/album/202003/03/101312zcazy02wl2g8uhy1.jpg) -The following tips should make it quicker and easier to troubleshoot hardware in Linux. Many different things can cause problems with Linux hardware; before you start trying to diagnose them, it's smart to learn about the most common issues and where you're most likely to find them. +[Linux 服务器][1]在物理机、虚拟化、私有云、公共云和混合云等许多不同种类的基础设施中运行着关键的业务应用程序。对于 Linux 系统管理员来说,了解如何管理 Linux 硬件基础设施(包括与 [网络][2]、存储、Linux 容器相关的软件定义功能)和 Linux 服务器上的多种工具非常重要。 -### Quick-diagnosing devices, modules, and drivers +在 Linux 上进行排除和解决与硬件相关的问题可能需要一些时间。即使是经验丰富的系统管理员,有时也会花费数小时来解决神秘的硬件和软件差异。 -The first step in troubleshooting usually is to display a list of the hardware installed on your Linux server. You can obtain detailed information on the hardware using **ls** commands such as **[lspci][3]** , **[lsblk][4]** , **[lscpu][5]** , and **[lsscsi][6]**. For example, here is output of the **lsblk** command: +以下提示可以使你更快、更轻松地对 Linux 中的硬件进行故障排除。许多不同的事情都可能导致 Linux 硬件出现问题。在开始诊断它们之前,明智的做法是了解最常见的问题以及最有可能找到问题的地方。 + +### 快速诊断设备、模块和驱动程序 + +故障排除的第一步通常是显示 Linux 服务器上安装的硬件的列表。你可以使用诸如 [lspci][3]、[lsblk][4]、[lscpu][5] 和 [lsscsi][6] 之类的列出命令获取有关硬件的详细信息。例如,这是 `lsblk` 命令的输出: ``` # lsblk @@ -32,7 +34,7 @@ xvdb    202:16   0  20G  0 disk └─xvdb1 202:17   0  20G  0 part ``` -If the **ls** commands don't reveal any errors, use init processes (e.g., **systemd** ) to see how the Linux server is working. **systemd** is the most popular init process for bootstrapping user spaces and controlling multiple system processes. For example, here is output of the **systemctl status** command: +如果这些列出命令没有显示任何错误,请使用初始化系统(例如 systemd)查看 Linux 服务器的工作方式。 systemd 是最流行的初始化系统,用于启动用户空间并控制多个系统进程。例如,这是 `systemctl status` 命令的输出: ``` # systemctl status @@ -52,9 +54,9 @@ If the **ls** commands don't reveal any errors, use init processes (e.g., **syst .... ``` -### Digging into multiple loggings +### 深入到各个日志当中 -**Dmesg** allows you to figure out errors and warnings in the kernel's latest messages. For example, here is output of the **dmesg | more** command: +使用 `dmesg` 可以找出内核最新消息中的错误和警告。例如,这是 `dmesg | more` 命令的输出: ``` # dmesg | more @@ -73,7 +75,7 @@ If the **ls** commands don't reveal any errors, use init processes (e.g., **syst .... ``` -You can also look at all Linux system logs in the **/var/log/messages** file, which is where you'll find errors related to specific issues. It's worthwhile to monitor the messages via the **tail** command in real time when you make modifications to your hardware, such as mounting an extra disk or adding an Ethernet network interface. For example, here is output of the **tail -f /var/log/messages** command: +你还可以在 `/var/log/messages` 文件中查看所有 Linux 系统日志,在该文件中你可以找到与特定问题相关的错误。当你对硬件进行修改(例如安装额外的磁盘或添加以太网网卡)时,通过 `tail` 命令实时监视消息是值得的。例如,这是 `tail -f /var/log/messages` 命令的输出: ``` # tail -f /var/log/messages @@ -89,9 +91,9 @@ Dec  1 13:21:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domai Dec  1 13:21:33 bastion dnsmasq[30201]: using nameserver 127.0.0.1#53 for domain cluster.local ``` -### Analyzing networking functions +### 分析网络功能 -You may have hundreds of thousands of cloud-native applications to serve business services in a complex networking environment; these may include virtualization, multiple cloud, and hybrid cloud. This means you should analyze whether networking connectivity is working correctly as part of your troubleshooting. Useful commands to figure out networking functions in the Linux server include **ip addr** , **traceroute** , **nslookup** , **dig** , and **ping** , among others. For example, here is output of the **ip addr show** command: +你可能有成千上万的云原生应用程序在一个复杂的网络环境中为业务提供服务,其中可能包括虚拟化、多云和混合云。这意味着,作为故障排除的一部分,你应该分析网络连接是否正常工作。弄清 Linux 服务器中网络功能的有用命令包括:`ip addr`、`traceroute`、`nslookup`、`dig` 和 `ping` 等。例如,这是 `ip addr show` 命令的输出: ``` # ip addr show @@ -116,9 +118,9 @@ You may have hundreds of thousands of cloud-native applications to serve busines .... ``` -### In conclusion +### 总结 -Troubleshooting Linux hardware requires considerable knowledge, including how to use powerful command-line tools and figure out system loggings. You should also know how to diagnose the kernel space, which is where you can find the root cause of many hardware problems. Keep in mind that hardware issues in Linux may come from many different sources, including devices, modules, drivers, BIOS, networking, and even plain old hardware malfunctions. +对 Linux 硬件进行故障排除需要大量的知识,包括如何使用功能强大的命令行工具以及找出系统日志记录。 你还应该知道如何诊断内核空间,在那里你可以找到许多硬件问题的根本原因。请记住,Linux 中的硬件问题可能来自许多不同的来源,包括设备、模块、驱动程序、BIOS、网络,甚至是普通的旧硬件故障。 -------------------------------------------------------------------------------- @@ -126,8 +128,8 @@ via: https://opensource.com/article/18/12/troubleshooting-hardware-problems-linu 作者:[Daniel Oh][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/202003/20190113 Editing Subtitles in Linux.md b/published/202003/20190113 Editing Subtitles in Linux.md new file mode 100644 index 0000000000..fe3a66da99 --- /dev/null +++ b/published/202003/20190113 Editing Subtitles in Linux.md @@ -0,0 +1,235 @@ +[#]: collector: (lujun9972) +[#]: translator: (chenmu-kk) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11946-1.html) +[#]: subject: (Editing Subtitles in Linux) +[#]: via: (https://itsfoss.com/editing-subtitles) +[#]: author: (Shirish https://itsfoss.com/author/shirish/) + +如何在 Linux 中编辑字幕 +====== + +我作为一位世界电影和地区电影爱好者已经几十年了。这期间字幕是一个必不可少的工具,它可以使我享受来自不同国家不同语言的优秀电影。 + +如果你喜欢观看带有字幕的电影,你可能会注意到有时字幕并不同步或者说并不正确。 + +你知道你可以自己编写字幕并使得它们更完美吗?让我们向你展示一些 Linux 中的基本字幕编辑吧。 + +![Editing subtitles in Linux][1] + +### 从闭路字幕数据中提取字幕 + +大概在 2012、2013 年我开始了解到有一款叫做 [CCEextractor][2] 的工具。随着时间的推移,它已经成为我必不可少的工具之一,尤其是当我偶然发现一份内含有字幕的媒体文件。 + +CCExtractor 负责解析视频文件以及从闭路字幕closed captions数据中产生独立的字幕文件。 + +CCExtractor 是一个跨平台的、自由开源工具。自它形成的那年起该工具已经成熟了不少而如今已成为 [GSOC][3] 和谷歌编码输入的一部分。 + +简单来说,这个工具基本上是一系列脚本,这些脚本以一种顺序方式一个接着一个地给你提供提取到的字幕。 + +你可以按照[本页][5]的 CCExtractor 安装指南进行操作。 + +若安装后你想从媒体文件中提取字幕,请按以下步骤操作: + +``` +ccextractor +``` + +该命令将会输出以下内容: + +``` +$ ccextractor $something.mkv +CCExtractor 0.87, Carlos Fernandez Sanz, Volker Quetschke. +Teletext portions taken from Petr Kutalek's telxcc +-------------------------------------------------------------------------- +Input: $something.mkv +[Extract: 1] [Stream mode: Autodetect] +[Program : Auto ] [Hauppage mode: No] [Use MythTV code: Auto] +[Timing mode: Auto] [Debug: No] [Buffer input: No] +[Use pic_order_cnt_lsb for H.264: No] [Print CC decoder traces: No] +[Target format: .srt] [Encoding: UTF-8] [Delay: 0] [Trim lines: No] +[Add font color data: Yes] [Add font typesetting: Yes] +[Convert case: No] [Video-edit join: No] +[Extraction start time: not set (from start)] +[Extraction end time: not set (to end)] +[Live stream: No] [Clock frequency: 90000] +[Teletext page: Autodetect] +[Start credits text: None] +[Quantisation-mode: CCExtractor's internal function] +----------------------------------------------------------------- +Opening file: $something.mkv +File seems to be a Matroska/WebM container +Analyzing data in Matroska mode + +Document type: matroska +Timecode scale: 1000000 +Muxing app: libebml v1.3.1 + libmatroska v1.4.2 +Writing app: mkvmerge v8.2.0 ('World of Adventure') 64bit +Title: $something + +Track entry: + Track number: 1 + UID: 1 + Type: video + Codec ID: V_MPEG4/ISO/AVC + Language: mal + Name: $something + +Track entry: + Track number: 2 + UID: 2 + Type: audio + Codec ID: A_MPEG/L3 + Language: mal + Name: $something + +Track entry: + Track number: 3 + UID: somenumber + Type: subtitle + Codec ID: S_TEXT/UTF8 + Name: $something + 99% | 144:34 +100% | 144:34 +Output file: $something_eng.srt +Done, processing time = 6 seconds +Issues? Open a ticket here +https://github.com/CCExtractor/ccextractor/issues +``` +它会大致浏览媒体文件。在这个例子中,它发现该媒体文件是马拉雅拉姆语言(mal)并且格式是 [.mkv][6]。之后它将字幕文件提取出来,命名为源文件名并添加“_eng”后缀。 + +CCExtractor 是一款用来增强字幕功能和字幕编辑的优秀工具,我将在下一部分对它进行介绍。 + +> 趣味阅读:在 [vicaps][7] 有一份有趣的字幕提要,它讲解和分享为何字幕对我们如此重要。对于那些对这类话题感兴趣的人来说,这里面也有许多电影制作的细节。 + +### 用 SubtitleEditor 工具编辑字幕 + +你大概意识到大多数的字幕都是 [.srt 格式][8] 的。这种格式的优点在于你可以将它加载到文本编辑器中并对它进行少量的修改。 + +当进入一个简单的文本编辑器时,一个 srt 文件看起来会是这个样子: + +``` +1 +00:00:00,959 --> 00:00:13,744 +"THE CABINET +OF DR. CALIGARI" + +2 +00:00:40,084 --> 00:01:02,088 +A TALE of the modern re-appearance of an 11th Century Myth +involting the strange and mysterious influence +of a mountebank monk over a somnambulist. +``` + +我分享的节选字幕来自于一部非常老的德国电影《[卡里加里博士的小屋][9]》(1920)。 + +Subtitleeditor 是一款非常棒的字幕编辑软件。字幕编辑器可以用来设置字幕持续时间、与多媒体文件同步的字幕帧率以及字幕间隔时间等等。接下来我将在这分享一些基本的字幕编辑。 + +![][10] + +首先,以安装 ccextractor 工具同样的方式安装 subtitleeditor 工具,使用你自己喜爱的安装方式。在 Debian 中,你可以使用命令: + +``` +sudo apt install subtitleeditor +``` + +当你安装完成后,让我们来看一下在你编辑字幕时一些常见的场景。 + +#### 调整帧率使其媒体文件同步 + +如果你发现字幕与视频不同步,一个原因可能是视频文件的帧率与字幕文件的帧率并不一致。 + +你如何得知这些文件的帧率呢,然后呢?为了获取视频文件的帧率,你可以使用 `mediainfo` 工具。首先你可能需要发行版的包管理器来安装它。 + +使用 `mediainfo` 非常简单: + +``` +$ mediainfo somefile.mkv | grep Frame + Format settings : CABAC / 4 Ref Frames + Format settings, ReFrames : 4 frames + Frame rate mode : Constant + Frame rate : 25.000 FPS + Bits/(Pixel*Frame) : 0.082 + Frame rate : 46.875 FPS (1024 SPF) +``` + +现在你可以看到视频文件的帧率是 25.000 FPS 。我们看到的另一个帧率则是音频文件的帧率。虽然我可以分享为何在视频解码和音频解码等地方会使用特定的 fps,但这将会是一个不同的主题,与它相关的历史信息有很多。 + +下一个问题是解决字幕文件的帧率,这个稍微有点复杂。 + +通常情况下,大多数字幕都是压缩格式的。将.zip 归档文件和字幕文件(以 XXX.srt 结尾)一起解压缩。除此之外,通常还会有一个同名的 .info 文件,该文件可能包含字幕的帧率。 + +如果不是,那么通常最好去某个站点并从具有该帧速率信息的站点下载字幕。对于这个特定的德文文件,我使用 [Opensubtitle.org][11] 来找到它。 + +正如你在链接中所看到的,字幕的帧率是 23.976 FPS 。很明显,它不能与帧率为 25.000 FPS 的视频文件一起很好地播放。 + +在这种情况下,你可以使用字幕编辑工具来改变字幕文件的帧率。 + +按下 `CTRL+A` 选择字幕文件中的全部内容。点击 “Timings -> Change Framerate” ,将 23.976 fps 改为 25.000 fps 或者你想要的其他帧率,保存已更改的文件。 + +![synchronize frame rates of subtitles in Linux][12] + +#### 改变字幕文件的起点 + +有时以上的方法就足够解决问题了,但有时候以上方法并不足够解决问题。 + +在帧率相同时,你可能会发现字幕文件的开头与电影或媒体文件中起点并不相同。 + +在这种情况下,请按以下步骤进行操作: + +按下 `CTRL+A` 键选中字幕文件的全部内容。点击 “Timings -> Select Move Subtitle” 。 + +![Move subtitles using Subtitle Editor on Linux][13] + +设定字幕文件的新起点,保存已更改的文件。 + +![Move subtitles using Subtitle Editor in Linux][14] + +如果你想要时间更精确一点,那么可以使用 [mpv][15] 来查看电影或者媒体文件并点击进度条(可以显示电影或者媒体文件的播放进度),它也会显示微秒。 + +通常我喜欢精准无误的操作,因此我会试着尽可能地仔细调节。相较于人类的反应时间来说,MPV 中的反应时间很精确。如果我想要极其精确的时间,那么我可以使用像 [Audacity][16] 之类的东西,但是那是另一种工具,你可以在上面做更多的事情。那也将会是我未来博客中将要探讨的东西。 + +#### 调整字幕间隔时间 + +有时,两种方法都采用了还不够,甚至你可能需要缩短或增加间隔时间以使其与媒体文件同步。这是较为繁琐的工作之一,因为你必须单独确定每个句子的间隔时间。尤其是在媒体文件中帧率可变的情况下(现已很少见,但你仍然会得到此类文件) + +在这种设想下,你可能因为无法实现自动编辑而不得不手动的修改间隔时间。最好的方式是修改视频文件(会降低视频质量)或者换另一个更高质量的片源,用你喜欢的设置对它进行[转码][17] 。这又是一重大任务,以后我会在我的一些博客文章上阐明。 + +### 总结 + +以上我分享的内容或多或少是对现有字幕文件的改进。如果从头开始,你需要花费大量的时间。我完全没有分享这一点,因为一部电影或一个小时内的任何视频材料都可以轻易地花费 4-6 个小时,甚至更多的时间,这取决于字幕员的技巧、耐心、上下文、行话、口音、是否是以英语为母语的人、翻译等,所有的这些都会对字幕的质量产生影响。 + +我希望自此以后你会觉得这件事很有趣,并将你的字幕处理的更好一点。如果你有其他想要补充的问题,请在下方留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/editing-subtitles + +作者:[Shirish][a] +选题:[lujun9972][b] +译者:[chenmu-kk](https://github.com/chenmu-kk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/shirish/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/editing-subtitles-in-linux.jpeg?resize=800%2C450&ssl=1 +[2]: https://www.ccextractor.org/ +[3]: https://itsfoss.com/best-open-source-internships/ +[4]: https://www.ccextractor.org/public:codein:google_code-in_2018 +[5]: https://github.com/CCExtractor/ccextractor/wiki/Installation +[6]: https://en.wikipedia.org/wiki/Matroska +[7]: https://www.vicaps.com/blog/history-of-silent-movies-and-subtitles/ +[8]: https://en.wikipedia.org/wiki/SubRip#SubRip_text_file_format +[9]: https://www.imdb.com/title/tt0010323/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/12/subtitleeditor.jpg?ssl=1 +[11]: https://www.opensubtitles.org/en/search/sublanguageid-eng/idmovie-4105 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/subtitleeditor-frame-rate-sync.jpg?resize=800%2C450&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/Move-subtitles-Caligiri.jpg?resize=800%2C450&ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/move-subtitles.jpg?ssl=1 +[15]: https://itsfoss.com/mpv-video-player/ +[16]: https://www.audacityteam.org/ +[17]: https://en.wikipedia.org/wiki/Transcoding +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/editing-subtitles-in-linux.jpeg?fit=800%2C450&ssl=1 diff --git a/published/202003/20190124 ffsend - Easily And Securely Share Files From Linux Command Line Using Firefox Send Client.md b/published/202003/20190124 ffsend - Easily And Securely Share Files From Linux Command Line Using Firefox Send Client.md new file mode 100644 index 0000000000..0663005ce5 --- /dev/null +++ b/published/202003/20190124 ffsend - Easily And Securely Share Files From Linux Command Line Using Firefox Send Client.md @@ -0,0 +1,283 @@ +[#]: collector: "lujun9972" +[#]: translator: "FSSlc" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12051-1.html" +[#]: subject: "ffsend – Easily And Securely Share Files From Linux Command Line Using Firefox Send Client" +[#]: via: "https://www.2daygeek.com/ffsend-securely-share-files-folders-from-linux-command-line-using-firefox-send-client/" +[#]: author: "Vinoth Kumar https://www.2daygeek.com/author/vinoth/" + +ffsend:在命令行中通过 FireFox Send 分享文件 +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/29/202308w7ormrouomij2dzq.jpg) + +Linux 用户偏爱使用 `scp` 或 `rsync` 来进行文件或目录的复制拷贝。不过在 Linux 上正出现了许多新的可选方式,因为 Linux 是开源的,所以任何人都可以为 Linux 开发一个安全软件。 + +在过去我们已经写了多篇有关安全分享这个话题的文章,它们分别是 [OnionShare][1]、[Magic Wormhole][2]、[Transfer.sh][3] 和 [Dcp – Dat Copy][4]。 + +今天我们甚至还将继续讨论这个话题,我们将介绍名为 `ffsend` 的工具。 + +### ffsend 是什么? + +[ffsend][5] 是 Firefox Send 服务的一个命令行客户端,允许用户通过命令行来传递和接收文件或目录。 + +它允许我们通过一个安全、私密、加密的链接,使用一个简单的命令来轻易安全地分享文件和目录。 + +通过 Firefox 的 Send 服务共享的文件最大大小为 2GB(LCTT 译注:现在官网上写的是最大 1GB,登录后最大 2.5GB)。其他人可以通过这个工具或者网页浏览器来下载这些分享的文件。 + +所有的文件都是在客户端加密的,并且秘钥将不会被共享到远程主机。另外,你还可以为上传的文件额外设置一个密码。 + +上传的文件在下载(默认被下载 1 次,最多可被下载 10 次)后或者 24 小时后,就会自动删除。这将确保你的文件不会一直保留在网络上。 + +该工具当前处于 alpha 阶段,使用时请自担风险。而且,当前只有有限的安装方式可用。 + +### ffsend 的特点: + + * 全功能且使用友好的命令行工具 + * 可以安全地上传和下载文件与目录 + * 总是在客户端加密 + * 可用额外的密码进行保护、密码生成和可配置下载次数限制 + * 内置的文件或目录的打包和解压 + * 可以轻松地管理你的历史分享记录 + * 能够使用你自己的 Send 主机 + * 审查或者删除共享文件 + * 精准的错误报告 + * 低内存消耗,用于加密或上传下载 + * 无需交互,可以集成在脚本中 + +### 如何在 LInux 中安装 ffsend 呢? + +当前除了 Debian 和 Arch Linux 系统,其他发行版还没有相应的安装包(LCTT 译注:这个信息已过时,最新内容请看[这里](https://github.com/timvisee/ffsend#install))。然而,我们可以轻易地根据我们自己的操作系统和架构下载到相应的预编译二进制文件。 + +运行下面的命令来为你的操作系统下载 `ffsend` 最新可用的版本(LCTT 译注:当前最新版本为 v0.2.58): + +``` +$ wget https://github.com/timvisee/ffsend/releases/download/v0.1.2/ffsend-v0.1.2-linux-x64.tar.gz +``` + +然后使用下面的命令来解压 tar 包: + +``` +$ tar -xvf ffsend-v0.1.2-linux-x64.tar.gz +``` + +接着运行下面的命令来查看你的 `PATH` 环境变量: + +``` +$ echo $PATH +/home/daygeek/.cargo/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl +``` + +正如我先前告知的那样,下面我们要做的就是将这个可执行文件放置到 `PATH` 环境变量中的某个目录中: + +``` +$ sudo mv ffsend /usr/local/sbin +``` + +直接运行 `ffsend` 可以获取其基本使用信息: + +``` +$ ffsend +ffsend 0.1.2 +Usage: ffsend [FLAGS] ... + +Easily and securely share files from the command line. +A fully featured Firefox Send client. + +Missing subcommand. Here are the most used: + ffsend upload ... + ffsend download ... + +To show all subcommands, features and other help: + ffsend help [SUBCOMMAND] +``` + +对于使用基于 Arch Linux 系统的用户可以简单地借助 [AUR 助手][6]来安装它,因为这个包已经在 AUR 软件仓库中了。 + +``` +$ yay -S ffsend +``` + +对于使用 Debian/Ubuntu 系统的用户,使用 [DPKG 命令][7]来安装 `ffsend`。 + +``` +$ wget https://github.com/timvisee/ffsend/releases/download/v0.1.2/ffsend_0.1.2_amd64.deb +$ sudo dpkg -i ffsend_0.1.2_amd64.deb +``` + +### 如何使用 ffsend + +这并不复杂,我们可以简单地通过下面的语法来发送文件。 + +**语法:** + +``` +$ ffsend upload [/Path/to/the/file/name] +``` + +在下面的例子中,我们将上传一个名为 `passwd-up1.sh` 的文件,一旦你上传了该文件,你将得到一个唯一的 URL。 + +``` +$ ffsend upload passwd-up1.sh --copy +Upload complete +Share link: https://send.firefox.com/download/a4062553f4/#yy2_VyPaUMG5HwXZzYRmpQ +``` + +![][9] + +在任何远端的系统上,只需要使用上面那个唯一的 URL 就可以下载上传的文件了。 + +**语法:** + +``` +$ ffsend download [Generated URL] +``` + +命令的输出如下: + +``` +$ ffsend download https://send.firefox.com/download/a4062553f4/#yy2_VyPaUMG5HwXZzYRmpQ +Download complete +``` + +![][10] + +使用下面的语法来对目录进行上传: + +``` +$ ffsend upload [/Path/to/the/Directory] --copy +``` + +在下面的例子中,我们将上传一个名为 `2g` 的目录: + +``` +$ ffsend upload /home/daygeek/2g --copy +You've selected a directory, only a single file may be uploaded. +Archive the directory into a single file? [Y/n]: y +Archiving... +Upload complete +Share link: https://send.firefox.com/download/90aa5cfe67/#hrwu6oXZRG2DNh8vOc3BGg +``` + +在任意的远端系统中,只需要利用上面生成的唯一 URL 就可以获取到刚才上传的目录了。 + +``` +$ ffsend download https://send.firefox.com/download/90aa5cfe67/#hrwu6oXZRG2DNh8vOc3BGg +You're downloading an archive, extract it into the selected directory? [Y/n]: y +Extracting... +Download complete +``` + +上面已经通过安全、私密和加密过的链接来发送了文件。然而,如果你想在你的掌控范围内再添加额外的安全措施,你可以为文件添加密码。 + +``` +$ ffsend upload file-copy-rsync.sh --copy --password +Password: +Upload complete +Share link: https://send.firefox.com/download/0742d24515/#P7gcNiwZJ87vF8cumU71zA +``` + +当你在远端系统中尝试下载该文件时,它将要求你输入密码: + +``` +$ ffsend download https://send.firefox.com/download/0742d24515/#P7gcNiwZJ87vF8cumU71zA +This file is protected with a password. +Password: +Download complete +``` + +另外,你还可以在上传过程中提供下载次数限制来限制文件被下载的次数。 + +``` +$ ffsend upload file-copy-scp.sh --copy --downloads 10 +Upload complete +Share link: https://send.firefox.com/download/23cb923c4e/#LVg6K0CIb7Y9KfJRNZDQGw +``` + +然后你可以在任意的远程系统中使用上面的唯一 URL 来下载该文件: + +``` +ffsend download https://send.firefox.com/download/23cb923c4e/#LVg6K0CIb7Y9KfJRNZDQGw +Download complete +``` + +假如你想看这个链接的更多细节,你可以使用下面的命令来查看它的信息,它将为你展示文件名称、文件大小、被下载次数以及过期时间。 + +**语法:** + +``` +$ ffsend info [Generated URL] + +$ ffsend info https://send.firefox.com/download/23cb923c4e/#LVg6K0CIb7Y9KfJRNZDQGw +ID: 23cb923c4e +Name: file-copy-scp.sh +Size: 115 B +MIME: application/x-sh +Downloads: 3 of 10 +Expiry: 23h58m (86280s) +``` + +此外,你还可以使用下面的命令来查看你的传输历史: + +``` +$ ffsend history +# LINK EXPIRY +1 https://send.firefox.com/download/23cb923c4e/#LVg6K0CIb7Y9KfJRNZDQGw 23h57m +2 https://send.firefox.com/download/0742d24515/#P7gcNiwZJ87vF8cumU71zA 23h55m +3 https://send.firefox.com/download/90aa5cfe67/#hrwu6oXZRG2DNh8vOc3BGg 23h52m +4 https://send.firefox.com/download/a4062553f4/#yy2_VyPaUMG5HwXZzYRmpQ 23h46m +5 https://send.firefox.com/download/74ff30e43e/#NYfDOUp_Ai-RKg5g0fCZXw 23h44m +6 https://send.firefox.com/download/69afaab1f9/#5z51_94jtxcUCJNNvf6RcA 23h43m +``` + +假如你不想再分享某个链接,你可以使用下面的语法来删除它: + +**语法:** + +``` +$ ffsend delete [Generated URL] + +$ ffsend delete https://send.firefox.com/download/69afaab1f9/#5z51_94jtxcUCJNNvf6RcA +File deleted +``` + +### 如何在浏览器中使用 Send + +另外,你还可以通过使用 firefox 浏览器打开 https://send.firefox.com/ 来完成相应的分享。 + +只需要拖拽该文件就可以上传它: + +![][11] + +一旦该文件被下载,它将展示 100% 的下载状态。 + +![][12] + +想查看其他的可能选项,请浏览它对应的 man 信息或者帮助页。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/ffsend-securely-share-files-folders-from-linux-command-line-using-firefox-send-client/ + +作者:[Vinoth Kumar][a] +选题:[lujun9972][b] +译者:[FSSlc](https://github.com/FSSlc) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/vinoth/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-9177-1.html +[2]: https://www.2daygeek.com/wormhole-securely-share-files-from-linux-command-line/ +[3]: https://www.2daygeek.com/transfer-sh-easy-fast-way-share-files-over-internet-from-command-line/ +[4]: https://linux.cn/article-10516-1.html +[5]: https://github.com/timvisee/ffsend +[6]: https://www.2daygeek.com/category/aur-helper/ +[7]: https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/ +[8]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[9]: https://www.2daygeek.com/wp-content/uploads/2019/01/ffsend-easily-and-securely-share-files-from-linux-command-line-using-firefox-send-client-1.png +[10]: https://www.2daygeek.com/wp-content/uploads/2019/01/ffsend-easily-and-securely-share-files-from-linux-command-line-using-firefox-send-client-2.png +[11]: https://www.2daygeek.com/wp-content/uploads/2019/01/ffsend-easily-and-securely-share-files-from-linux-command-line-using-firefox-send-client-3.png +[12]: https://www.2daygeek.com/wp-content/uploads/2019/01/ffsend-easily-and-securely-share-files-from-linux-command-line-using-firefox-send-client-4.png diff --git a/published/202003/20190422 9 ways to save the planet.md b/published/202003/20190422 9 ways to save the planet.md new file mode 100644 index 0000000000..28a8cf2c55 --- /dev/null +++ b/published/202003/20190422 9 ways to save the planet.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (MFGJT) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11978-1.html) +[#]: subject: (9 ways to save the planet) +[#]: via: (https://opensource.com/article/19/4/save-planet) +[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike/users/alanfdoss/users/jmpearce) + +九种用开源拯救地球的方法 +====== + +> 这些主意都用到了有关的开源技巧。 + +![](https://img.linux.net.cn/data/attachment/album/202003/10/004034vbl5qb5lbij66zil.jpg) + +人们可以做些什么来拯救地球?这个问题可能会让人感到压抑,因为有时我们感觉个人可以做的贡献太少了。但是作为地球公民,我们从来不是一个人。所以,我向我们的作家社区征集了一些开源软件或硬件可以帮助改变现状的方法。以下是他们的回复。 + +### 九种利用开源的方法来拯救地球的方式 + +#### 1、在你的终端禁用闪烁的光标 + +这听起来可能有点傻,但是那个无关紧要的闪烁的光标可能导致[每小时两瓦特的额外电力开销][2]。如果要禁用光标闪烁,可以通过更改终端设置:编辑Edit > 偏好设置Preferences > 光标Cursor > 光标闪烁Cursor blinking > 禁用Disabled。 + +*由 Mars Toktonaliev 推荐* + +#### 2、减少有关动物产品和加工食物的消费 + +这样做的一种方法是在你的手机中添加这些开源的 App:Daily Dozen、OpenFoodFacts、OpenVegeMap 和 Food Restrictions。这些 App 可以帮助你准备一份健康的素食饮食计划,为你找到素食主义者和严格素食主义者可以就餐的餐厅,还可以帮助你把你的饮食需求告诉别人,即使他们不和你讲同一种语言。如果想要了解更多有关这些的 App 的信息,你可以阅读《[4 款“吃草”的开源应用][3]》。 + +*由 Joshua Allen Holm 推荐* + +#### 3、让旧电脑重焕新生 + +怎么做?当然是用 Linux。通过给那些自己得不到新电脑的人创造一台新电脑来传递爱心,同时也可以避免让这台电脑进到垃圾填埋场。可以在 [The Asian Penguins][4] 看看我们是怎么做的。 + +*由 Stu Keroff 推荐* + +#### 4、在你不使用设备时关闭它们 + +你可以使用带有主插座和控制插座的“智能插座板”。把你的电脑连接到主插座上,这样的话当你打开电脑时所有你连接到控制插座上的设备如显示器,打印机等也都会打开。一个更简单的、技术含量更低的方法是使用一个带有计时器的插座板。我在家里就是用的这个。你可以用计时器上的开关设定一个定时开关电源的时间表。这样可以在没有人在家时自动关闭网络打印机。或者以我的用了六年的笔记本电脑为例,我通过一个交替使用外接电源(插座打开)和使用电脑电池(插座关闭)的电源计划延长了电脑电池的寿命。 + +*由 Jim Hall 推荐* + +#### 5、减少供暖通风系统(HVAC)的使用 + +在夏天,透过窗户的阳光可以为室内提供很多热量。使用 Home Assistant 可以[基于一天中的时间的][6],甚至是基于太阳高度角[自动调节][5]窗帘和遮阳棚。 + +*由 Michael Hrivnak 推荐* + +#### 6、出门就把恒温器关闭或调低 + +如果你的家用恒温器具有“离开”功能,你很容易忘记在出门时启用它。借助自动化,任何连接到网络的恒温器都可以在你不在家时自动节省能量。[Stataway][7] 就是一个这样项目。它通过调用你的手机的 GPS 坐标来决定是将你的恒温器设置为“在家”还是“离开”。 + +*由 Michael Hrivnak 推荐* + +#### 7、为未来储蓄算力 + +我有一个主意:创建一个可以读取可选的能量阵列(如风能或太阳能)的输出的脚本。这个脚本应该将计算集群中的服务器从睡眠模式更改为激活模式,直到过量的电能(超出可以储存的部分)被用尽。然后在高产能时段使用这些过量的电能来进行需要大量计算的项目,比如渲染。这个过程本质应该是免费的,因为使用的能量无法被储存起来挪作它用。我相信现有的监控、能量管理和服务器阵列工具一定可以实现这个功能。那么剩下的只是一些整合上的问题,就可以让整个系统工作起来。 + +*由 Terry Hancock 推荐* + +#### 8、关掉你的灯 + +根据[人工夜空亮度图集][8]World Atlas of Artificial Night Sky Brightness的说法,光污染影响了全世界超过 80% 的人口。这一结论在 2016 年(遵循 CC-NC 4.0 协议)发表在公开访问的期刊《科学进展Science Advances》上。关闭外部照明是一个可以使野生生物、人类健康受益并让我们享受夜晚的天空的快速途径,而且可以减少能量消耗。访问 [darksky.org][9] 来查看更多减少外部照明影响的方法。 + +*由 Michael Hrivnak 推荐* + +#### 9、减少你的 CPU 数量 + +就我个人而言,我记得我以前有很多在地下室运行的电脑作为我的 IT 游乐场/实验室。我现在对于能源消耗更加注意了,所以确实大大地减少了我的 CPU 数量。我现在更喜欢利用虚拟机、区域和容器等技术。另外,我很高兴有小型电脑和 SoC 电脑这种东西,比如树莓派,因为我可以用一台这样的电脑做很多事情,比如运行一个 DNS 或者 Web 服务器,而无需使整个屋子变热并积累昂贵的电费账单。 + +P.S. 这些电脑都运行于 Linux、FreeBSD,或者 Raspbian 系统! + +*由 Alan Formy-Duvall 推荐* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/save-planet + +作者:[Jen Wike Huger][a] +选题:[lujun9972][b] +译者:[MFGJT](https://github.com/MFGJT) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jen-wike/users/alanfdoss/users/jmpearce +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pixelated-world.png?itok=fHjM6m53 +[2]: https://www.redhat.com/archives/fedora-devel-list/2009-January/msg02406.html +[3]: https://linux.cn/article-10926-1.html +[4]: https://opensource.com/article/19/2/asian-penguins-close-digital-divide +[5]: https://www.home-assistant.io/docs/automation/trigger/#sun-trigger +[6]: https://www.home-assistant.io/components/cover/ +[7]: https://github.com/mhrivnak/stataway +[8]: http://advances.sciencemag.org/content/2/6/e1600377 +[9]: http://darksky.org/ diff --git a/published/202003/20190527 How To Enable Or Disable SSH Access For A Particular User Or Group In Linux.md b/published/202003/20190527 How To Enable Or Disable SSH Access For A Particular User Or Group In Linux.md new file mode 100644 index 0000000000..0c0a600eeb --- /dev/null +++ b/published/202003/20190527 How To Enable Or Disable SSH Access For A Particular User Or Group In Linux.md @@ -0,0 +1,288 @@ +[#]: collector: "lujun9972" +[#]: translator: "way-ww" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12027-1.html" +[#]: subject: "How To Enable Or Disable SSH Access For A Particular User Or Group In Linux?" +[#]: via: "https://www.2daygeek.com/allow-deny-enable-disable-ssh-access-user-group-in-linux/" +[#]: author: "2daygeek http://www.2daygeek.com/author/2daygeek/" + +如何在 Linux 上为特定的用户或用户组启用或禁用 SSH? +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/23/105915r1azn34i82sp48ca.jpg) + +由于你的公司标准规定,你可能只能允许部分人访问 Linux 系统。或者你可能只能够允许几个用户组中的用户访问 Linux 系统。那么如何实现这样的要求呢?最好的方法是什么呢?如何使用一个简单的方法去实现呢? + +是的,我们会有很多种方法去实现它。但是我们应该使用简单轻松的方法。为了简单轻松的完成目的,我们可以通过对 `/etc/ssh/sshd_config` 文件做必要的修改来实现。在这篇文章中我们将会向你展示实现要求的详细步骤。 + +为什么我们要这样做呢?是出于安全的原因。你可以访问[这个链接][1]来获取更多关于 openSSH 的使用方法。 + +### 什么是 SSH ? + +openssh 全称为 OpenBSD Secure Shell。Secure Shell(ssh)是一个自由开源的网络工具,它能让我们在一个不安全的网络中通过使用 Secure Shell(SSH)协议来安全访问远程主机。 + +它采用了客户端-服务器架构(C/S),拥有用户身份认证、加密、在计算机和隧道之间传输文件等功能。 + +我们也可以用 `telnet` 或 `rcp` 等传统工具来完成,但是这些工具都不安全,因为它们在执行任何动作时都会使用明文来传输密码。 + +### 如何在 Linux 中允许用户使用 SSH? + +通过以下内容,我们可以为指定的用户或用户列表启用 `ssh` 访问。如果你想要允许多个用户,那么你可以在添加用户时在同一行中用空格来隔开他们。 + +为了达到目的只需要将下面的值追加到 `/etc/ssh/sshd_config` 文件中去。 在这个例子中, 我们将会允许用户 `user3` 使用 ssh。 + +``` +# echo "AllowUsers user3" >> /etc/ssh/sshd_config +``` + +你可以运行下列命令再次检查是否添加成功。 + +``` +# cat /etc/ssh/sshd_config | grep -i allowusers +AllowUsers user3 +``` + +这样就行了, 现在只需要重启 `ssh` 服务和见证奇迹了。(下面这两条命令效果相同, 请根据你的服务管理方式选择一条执行即可) + +``` +# systemctl restart sshd +或 +# service restart sshd +``` + +接下来很简单,只需打开一个新的终端或者会话尝试用不同的用户身份访问 Linux 系统。是的,这里 `user2` 用户是不被允许使用 SSH 登录的并且会得到如下所示的错误信息。 + +``` +# ssh user2@192.168.1.4 +user2@192.168.1.4's password: +Permission denied, please try again. +``` + +输出: + +``` +Mar 29 02:00:35 CentOS7 sshd[4900]: User user2 from 192.168.1.6 not allowed because not listed in AllowUsers +Mar 29 02:00:35 CentOS7 sshd[4900]: input_userauth_request: invalid user user2 [preauth] +Mar 29 02:00:40 CentOS7 unix_chkpwd[4902]: password check failed for user (user2) +Mar 29 02:00:40 CentOS7 sshd[4900]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=user2 +Mar 29 02:00:43 CentOS7 sshd[4900]: Failed password for invalid user user2 from 192.168.1.6 port 42568 ssh2 +``` + +与此同时用户 `user3` 被允许登入系统因为他在被允许的用户列表中。 + +``` +# ssh user3@192.168.1.4 +user3@192.168.1.4's password: +[user3@CentOS7 ~]$ +``` + +输出: + +``` +Mar 29 02:01:13 CentOS7 sshd[4939]: Accepted password for user3 from 192.168.1.6 port 42590 ssh2 +Mar 29 02:01:13 CentOS7 sshd[4939]: pam_unix(sshd:session): session opened for user user3 by (uid=0) +``` + +### 如何在 Linux 中阻止用户使用 SSH ? + +通过以下内容,我们可以配置指定的用户或用户列表禁用 `ssh`。如果你想要禁用多个用户,那么你可以在添加用户时在同一行中用空格来隔开他们。 + +为了达到目的只需要将以下值追加到 `/etc/ssh/sshd_config` 文件中去。 在这个例子中, 我们将禁用用户 `user1` 使用 `ssh`。 + +``` +# echo "DenyUsers user1" >> /etc/ssh/sshd_config +``` + +你可以运行下列命令再次检查是否添加成功。 + +``` +# cat /etc/ssh/sshd_config | grep -i denyusers +DenyUsers user1 +``` + +这样就行了, 现在只需要重启 `ssh` 服务和见证奇迹了。 + +``` +# systemctl restart sshd +活 +# service restart sshd +``` + +接下来很简单,只需打开一个新的终端或者会话,尝试使用被禁用的用户身份被访问 Linux 系统。是的,这里 `user1` 用户在禁用名单中。所以,当你尝试登录时,你将会得到如下所示的错误信息。 + +``` +# ssh user1@192.168.1.4 +user1@192.168.1.4's password: +Permission denied, please try again. +``` + +输出: + +``` +Mar 29 01:53:42 CentOS7 sshd[4753]: User user1 from 192.168.1.6 not allowed because listed in DenyUsers +Mar 29 01:53:42 CentOS7 sshd[4753]: input_userauth_request: invalid user user1 [preauth] +Mar 29 01:53:46 CentOS7 unix_chkpwd[4755]: password check failed for user (user1) +Mar 29 01:53:46 CentOS7 sshd[4753]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=user1 +Mar 29 01:53:48 CentOS7 sshd[4753]: Failed password for invalid user user1 from 192.168.1.6 port 42522 ssh2 +``` + +### 如何在 Linux 中允许用户组使用 SSH? + +通过以下内容,我们可以允许一个指定的组或多个组使用 `ssh`。 + +如果你想要允许多个组使用 `ssh` 那么你在添加用户组时需要在同一行中使用空格来隔开他们。 + +为了达到目的只需将以下值追加到 `/etc/ssh/sshd_config` 文件中去。在这个例子中,我们将允许 `2g-admin` 组使用 ssh。 + +``` +# echo "AllowGroups 2g-admin" >> /etc/ssh/sshd_config +``` + +你可以运行下列命令再次检查是否添加成功。 + +``` +# cat /etc/ssh/sshd_config | grep -i allowgroups +AllowGroups 2g-admin +``` + +运行下列命令查看属于该用户组的用户有哪些。 + +``` +# getent group 2g-admin +2g-admin:x:1005:user1,user2,user3 +``` + +这样就行了, 现在只需要重启 `ssh` 服务和见证奇迹了。 + +``` +# systemctl restart sshd +或 +# service restart sshd +``` + +是的, `user1` 被允许登入系统因为用户 `user1` 属于 `2g-admin` 组。 + +``` +# ssh user1@192.168.1.4 +user1@192.168.1.4's password: +[user1@CentOS7 ~]$ +``` + +输出: + +``` +Mar 29 02:10:21 CentOS7 sshd[5165]: Accepted password for user1 from 192.168.1.6 port 42640 ssh2 +Mar 29 02:10:22 CentOS7 sshd[5165]: pam_unix(sshd:session): session opened for user user1 by (uid=0) +``` + +是的, `user2` 被允许登入系统因为用户 `user2` 同样属于 `2g-admin` 组。 + +``` +# ssh user2@192.168.1.4 +user2@192.168.1.4's password: +[user2@CentOS7 ~]$ +``` + +输出: + +``` +Mar 29 02:10:38 CentOS7 sshd[5225]: Accepted password for user2 from 192.168.1.6 port 42642 ssh2 +Mar 29 02:10:38 CentOS7 sshd[5225]: pam_unix(sshd:session): session opened for user user2 by (uid=0) +``` + +当你尝试使用其他不在被允许的组中的用户去登入系统时, 你将会得到如下所示的错误信息。 + +``` +# ssh ladmin@192.168.1.4 +ladmin@192.168.1.4's password: +Permission denied, please try again. +``` + +输出: + +``` +Mar 29 02:12:36 CentOS7 sshd[5306]: User ladmin from 192.168.1.6 not allowed because none of user's groups are listed in AllowGroups +Mar 29 02:12:36 CentOS7 sshd[5306]: input_userauth_request: invalid user ladmin [preauth] +Mar 29 02:12:56 CentOS7 unix_chkpwd[5310]: password check failed for user (ladmin) +Mar 29 02:12:56 CentOS7 sshd[5306]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=ladmin +Mar 29 02:12:58 CentOS7 sshd[5306]: Failed password for invalid user ladmin from 192.168.1.6 port 42674 ssh2 +``` + +### 如何在 Linux 中阻止用户组使用 SSH? + +通过以下内容,我们可以禁用指定的组或多个组使用 `ssh`。 + +如果你想要禁用多个用户组使用 `ssh`,那么你需要在添加用户组时在同一行中使用空格来隔开他们。 + +为了达到目的只需要将下面的值追加到 `/etc/ssh/sshd_config` 文件中去。 + +``` +# echo "DenyGroups 2g-admin" >> /etc/ssh/sshd_config +``` + +你可以运行下列命令再次检查是否添加成功。 + +``` +# # cat /etc/ssh/sshd_config | grep -i denygroups +DenyGroups 2g-admin + +# getent group 2g-admin +2g-admin:x:1005:user1,user2,user3 +``` + +这样就行了, 现在只需要重启 `ssh` 服务和见证奇迹了。 + +``` +# systemctl restart sshd +或 +# service restart sshd +``` + +是的 `user1` 不被允许登入系统,因为他是 `2g-admin` 用户组中的一员。他属于被禁用 `ssh` 的组中。 + +``` +# ssh user1@192.168.1.4 +user1@192.168.1.4's password: +Permission denied, please try again. +``` + +输出: + +``` +Mar 29 02:17:32 CentOS7 sshd[5400]: User user1 from 192.168.1.6 not allowed because a group is listed in DenyGroups +Mar 29 02:17:32 CentOS7 sshd[5400]: input_userauth_request: invalid user user1 [preauth] +Mar 29 02:17:38 CentOS7 unix_chkpwd[5402]: password check failed for user (user1) +Mar 29 02:17:38 CentOS7 sshd[5400]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=192.168.1.6 user=user1 +Mar 29 02:17:41 CentOS7 sshd[5400]: Failed password for invalid user user1 from 192.168.1.6 port 42710 ssh2 +``` + +除了 `2g-admin` 用户组之外的用户都可以使用 ssh 登入系统。 例如,`ladmin` 等用户就允许登入系统。 + +``` +# ssh ladmin@192.168.1.4 +ladmin@192.168.1.4's password: +[ladmin@CentOS7 ~]$ +``` + +输出: + +``` +Mar 29 02:19:13 CentOS7 sshd[5432]: Accepted password for ladmin from 192.168.1.6 port 42716 ssh2 +Mar 29 02:19:13 CentOS7 sshd[5432]: pam_unix(sshd:session): session opened for user ladmin by (uid=0) +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/allow-deny-enable-disable-ssh-access-user-group-in-linux/ + +作者:[2daygeek][a] +选题:[lujun9972][b] +译者:[way-ww](https://github.com/way-ww) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.2daygeek.com/author/2daygeek/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/ssh-tutorials/ diff --git a/published/202003/20190731 How to structure a multi-file C program- Part 2.md b/published/202003/20190731 How to structure a multi-file C program- Part 2.md new file mode 100644 index 0000000000..53dc8bb70e --- /dev/null +++ b/published/202003/20190731 How to structure a multi-file C program- Part 2.md @@ -0,0 +1,224 @@ +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12000-1.html) +[#]: subject: (How to structure a multi-file C program: Part 2) +[#]: via: (https://opensource.com/article/19/7/structure-multi-file-c-part-2) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny) + +如何组织构建多文件 C 语言程序(二) +====== + +> 我将在本系列的第二篇中深入研究由多个文件组成的 C 程序的结构。 + +![](https://img.linux.net.cn/data/attachment/album/202003/16/122928i6qheufnh24jq2qf.jpg) + +在[第一篇][2]中,我设计了一个名为[喵呜喵呜][3]的多文件 C 程序,该程序实现了一个玩具[编解码器][4]。我也提到了程序设计中的 Unix 哲学,即在一开始创建多个空文件,并建立一个好的结构。最后,我创建了一个 `Makefile` 文件夹并阐述了它的作用。在本文中将另一个方向展开:现在我将介绍简单但具有指导性的喵呜喵呜编解码器的实现。 + +当读过我的《[如何写一个好的 C 语言 main 函数][5]》后,你会觉得喵呜喵呜编解码器的 `main.c` 文件的结构很熟悉,其主体结构如下: + +``` +/* main.c - 喵呜喵呜流式编解码器 */ + +/* 00 系统包含文件 */ +/* 01 项目包含文件 */ +/* 02 外部声明 */ +/* 03 定义 */ +/* 04 类型定义 */ +/* 05 全局变量声明(不要用)*/ +/* 06 附加的函数原型 */ +    +int main(int argc, char *argv[]) +{ +  /* 07 变量声明 */ +  /* 08 检查 argv[0] 以查看该程序是被如何调用的 */ +  /* 09 处理来自用户的命令行选项 */ +  /* 10 做点有用的事情 */ +} +    +/* 11 其它辅助函数 */ +``` + +### 包含项目头文件 + +位于第二部分中的 `/* 01 项目包含文件 */` 的源代码如下: + + +``` +/* main.c - 喵呜喵呜流式编解码器 */ +... +/* 01 项目包含文件 */ +#include "main.h" +#include "mmecode.h" +#include "mmdecode.h" +``` + +`#include` 是 C 语言的预处理命令,它会将该文件名的文件内容拷贝到当前文件中。如果程序员在头文件名称周围使用双引号(`""`),编译器将会在当前目录寻找该文件。如果文件被尖括号包围(`<>`),编译器将在一组预定义的目录中查找该文件。 + +[main.h][6] 文件中包含了 [main.c][7] 文件中用到的定义和类型定义。我喜欢尽可能多将声明放在头文件里,以便我在我的程序的其他位置使用这些定义。 + +头文件 [mmencode.h][8] 和 [mmdecode.h][9] 几乎相同,因此我以 `mmencode.h` 为例来分析。 + +``` +/* mmencode.h - 喵呜喵呜流编解码器 */ +   +#ifndef _MMENCODE_H +#define _MMENCODE_H + +#include + +int mm_encode(FILE *src, FILE *dst); + +#endif /* _MMENCODE_H */ +``` + +`#ifdef`、`#define`、`#endif` 指令统称为 “防护” 指令。其可以防止 C 编译器在一个文件中多次包含同一文件。如果编译器在一个文件中发现多个定义/原型/声明,它将会产生警告。因此这些防护措施是必要的。 + +在这些防护内部,只有两个东西:`#include` 指令和函数原型声明。我在这里包含了 `stdio.h` 头文件,以便于能在函数原型中使用 `FILE` 定义。函数原型也可以被包含在其他 C 文件中,以便于在文件的命名空间中创建它。你可以将每个文件视为一个独立的命名空间,其中的变量和函数不能被另一个文件中的函数或者变量使用。 + +编写头文件很复杂,并且在大型项目中很难管理它。不要忘记使用防护。 + +### 喵呜喵呜编码的最终实现 + +该程序的功能是按照字节进行 `MeowMeow` 字符串的编解码,事实上这是该项目中最简单的部分。截止目前我所做的工作便是支持允许在适当的位置调用此函数:解析命令行,确定要使用的操作,并打开将要操作的文件。下面的循环是编码的过程: + +``` +/* mmencode.c - 喵呜喵呜流式编解码器 */ +... + while (!feof(src)) { + + if (!fgets(buf, sizeof(buf), src)) + break; + + for(i=0; i> 4; + fputs(tbl[hi], dst); + fputs(tbl[lo], dst); + } + } +``` + +简单的说,当文件中还有数据块时( `feof(3)` ),该循环读取(`feof(3)` )文件中的一个数据块。然后将读入的内容的每个字节分成两个 `hi` 和 `lo` 的半字节nibble。半字节是半个字节,即 4 个位。这里的奥妙之处在于可以用 4 个位来编码 16 个值。我将 `hi` 和 `lo` 用作 16 个字符串查找表 `tbl` 的索引,表中包含了用半字节编码的 `MeowMeow` 字符串。这些字符串使用 `fputs(3)` 函数写入目标 `FILE` 流,然后我们继续处理缓存区的下一个字节。 + +该表使用 [table.h][14] 中的宏定义进行初始化,在没有特殊原因(比如:要展示包含了另一个项目的本地头文件)时,我喜欢使用宏来进行初始化。我将在未来的文章中进一步探讨原因。 + +### 喵呜喵呜解码的实现 + +我承认在开始工作前花了一些时间。解码的循环与编码类似:读取 `MeowMeow` 字符串到缓冲区,将编码从字符串转换为字节 + +``` + /* mmdecode.c - 喵呜喵呜流式编解码器 */ + ... + int mm_decode(FILE *src, FILE *dst) + { +   if (!src || !dst) { +     errno = EINVAL; +     return -1; +   } +   return stupid_decode(src, dst); + } +``` + +这不符合你的期望吗? + +在这里,我通过外部公开的 `mm_decode()` 函数公开了 `stupid_decode()` 函数细节。我上面所说的“外部”是指在这个文件之外。因为 `stupid_decode()` 函数不在该头文件中,因此无法在其他文件中调用它。 + +当我们想发布一个可靠的公共接口时,有时候会这样做,但是我们还没有完全使用函数解决问题。在本例中,我编写了一个 I/O 密集型函数,该函数每次从源中读取 8 个字节,然后解码获得 1 个字节写入目标流中。较好的实现是一次处理多于 8 个字节的缓冲区。更好的实现还可以通过缓冲区输出字节,进而减少目标流中单字节的写入次数。 + +``` +/* mmdecode.c - 喵呜喵呜流式编解码器 */ +... +int stupid_decode(FILE *src, FILE *dst) +{ + char buf[9]; + decoded_byte_t byte; + int i; + + while (!feof(src)) { + if (!fgets(buf, sizeof(buf), src)) + break; + byte.field.f0 = isupper(buf[0]); + byte.field.f1 = isupper(buf[1]); + byte.field.f2 = isupper(buf[2]); + byte.field.f3 = isupper(buf[3]); + byte.field.f4 = isupper(buf[4]); + byte.field.f5 = isupper(buf[5]); + byte.field.f6 = isupper(buf[6]); + byte.field.f7 = isupper(buf[7]); + + fputc(byte.value, dst); + } + return 0; +} +``` + +我并没有使用编码器中使用的位移方法,而是创建了一个名为 `decoded_byte_t` 的自定义数据结构。 + +``` +/* mmdecode.c - 喵呜喵呜流式编解码器 */ +... + +typedef struct { +  unsigned char f7:1; +  unsigned char f6:1; +  unsigned char f5:1; +  unsigned char f4:1; +  unsigned char f3:1; +  unsigned char f2:1; +  unsigned char f1:1; +  unsigned char f0:1; +} fields_t; +   +typedef union { +  fields_t      field; +  unsigned char value; +} decoded_byte_t; +``` + +初次看到代码时可能会感到有点儿复杂,但不要放弃。`decoded_byte_t` 被定义为 `fields_t` 和 `unsigned char` 的 **联合**。可以将联合中的命名成员看作同一内存区域的别名。在这种情况下,`value` 和 `field` 指向相同的 8 位内存区域。将 `field.f0` 设置为 `1` 也将会设置 `value` 中的最低有效位。 + +虽然 `unsigned char` 并不神秘,但是对 `fields_t` 的类型定义(`typedef`)也许看起来有些陌生。现代 C 编译器允许程序员在结构体中指定单个位字段的值。字段所在的类型是一个无符号整数类型,并在成员标识符后紧跟一个冒号和一个整数,该整数指定了位字段的长度。 + +这种数据结构使得按字段名称访问字节中的每个位变得简单,并可以通过联合中的 `value` 字段访问组合后的值。我们依赖编译器生成正确的移位指令来访问字段,这可以在调试时为你节省不少时间。 + +最后,因为 `stupid_decode()` 函数一次仅从源 `FILE` 流中读取 8 个字节,所以它效率并不高。通常我们尝试最小化读写次数,以提高性能和降低调用系统调用的开销。请记住:少量的读取/写入大的块比大量的读取/写入小的块好得多。 + +### 总结 + +用 C 语言编写一个多文件程序需要程序员要比只是是一个 `main.c` 做更多的规划。但是当你添加功能或者重构时,只需要多花费一点儿努力便可以节省大量时间以及避免让你头痛的问题。 + +回顾一下,我更喜欢这样做:多个文件,每个文件仅有简单功能;通过头文件公开那些文件中的小部分功能;把数字常量和字符串常量保存在头文件中;使用 `Makefile` 而不是 Bash 脚本来自动化处理事务;使用 `main()` 函数来处理命令行参数解析并作为程序主要功能的框架。 + +我知道我只是蜻蜓点水般介绍了这个简单的程序,并且我很高兴知道哪些事情对你有所帮助,以及哪些主题需要详细的解释。请在评论中分享你的想法,让我知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/structure-multi-file-c-part-2 + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjny +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/file_system.jpg?itok=pzCrX1Kc (4 manilla folders, yellow, green, purple, blue) +[2]: https://linux.cn/article-11935-1.html +[3]: https://github.com/jnyjny/MeowMeow.git +[4]: https://en.wikipedia.org/wiki/Codec +[5]: https://linux.cn/article-10949-1.html +[6]: https://github.com/JnyJny/meowmeow/blob/master/main.h +[7]: https://github.com/JnyJny/meowmeow/blob/master/main.c +[8]: https://github.com/JnyJny/meowmeow/blob/master/mmencode.h +[9]: https://github.com/JnyJny/meowmeow/blob/master/mmdecode.h +[10]: http://www.opengroup.org/onlinepubs/009695399/functions/feof.html +[11]: http://www.opengroup.org/onlinepubs/009695399/functions/fgets.html +[12]: http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html +[13]: http://www.opengroup.org/onlinepubs/009695399/functions/fputs.html +[14]: https://github.com/JnyJny/meowmeow/blob/master/table.h +[15]: http://www.opengroup.org/onlinepubs/009695399/functions/isupper.html +[16]: http://www.opengroup.org/onlinepubs/009695399/functions/fputc.html diff --git a/published/202003/20190813 Building a non-breaking breakpoint for Python debugging.md b/published/202003/20190813 Building a non-breaking breakpoint for Python debugging.md new file mode 100644 index 0000000000..0ad21ebeab --- /dev/null +++ b/published/202003/20190813 Building a non-breaking breakpoint for Python debugging.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (caiichenr) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11986-1.html) +[#]: subject: (Building a non-breaking breakpoint for Python debugging) +[#]: via: (https://opensource.com/article/19/8/debug-python) +[#]: author: (Liran Haimovitch https://opensource.com/users/liranhaimovitch) + +在 Python 调试过程中设置不中断的断点 +====== + +> 你对如何让调试器变得更快产生过兴趣吗?本文将分享我们在为 Python 构建调试器时得到的一些经验。 + +![](https://img.linux.net.cn/data/attachment/album/202003/12/104433hq3qx2k81w1wamwm.jpg) + +整段故事讲的是我们在 [Rookout][2] 公司的团队为 Python 调试器开发不中断断点的经历,以及开发过程中得到的经验。我将在本月于旧金山举办的 [PyBay 2019][3] 上介绍有关 Python 调试过程的更多细节,但现在就让我们立刻开始这段故事。 + +### Python 调试器的心脏:sys.set_trace + +在诸多可选的 Python 调试器中,使用最广泛的三个是: + +* pdb,它是 Python 标准库的一部分 +* PyDev,它是内嵌在 Eclipse 和 Pycharm 等 IDE 中的调试器 +* ipdb,它是 IPython 的调试器 + +Python 调试器的选择虽多,但它们几乎都基于同一个函数:`sys.settrace`。 值得一提的是, [sys.settrace][4] 可能也是 Python 标准库中最复杂的函数。 + +![set_trace Python 2 docs page][5] + +简单来讲,`settrace` 的作用是为解释器注册一个跟踪函数,它在下列四种情形发生时被调用: + +* 函数调用 +* 语句执行 +* 函数返回 +* 异常抛出 + +一个简单的跟踪函数看上去大概是这样: + +``` +def simple_tracer(frame, event, arg): +  co = frame.f_code +  func_name = co.co_name +  line_no = frame.f_lineno +  print("{e} {f} {l}".format( +e=event, f=func_name, l=line_no)) +  return simple_tracer +``` + +在分析函数时我们首先关注的是参数和返回值,该跟踪函数的参数分别是: + +* `frame`,当前堆栈帧,它是包含当前函数执行时解释器里完整状态的对象 +* `event`,事件,它是一个值可能为 `call`、`line`、`return` 或 `exception` 的字符串 +* `arg`,参数,它的取值基于 `event` 的类型,是一个可选项 + +该跟踪函数的返回值是它自身,这是由于解释器需要持续跟踪两类跟踪函数: + +* **全局跟踪函数(每线程)**:该跟踪函数由当前线程调用 `sys.settrace` 来设置,并在解释器创建一个新的堆栈帧时被调用(即代码中发生函数调用时)。虽然没有现成的方式来为不同的线程设置跟踪函数,但你可以调用 `threading.settrace` 来为所有新创建的 `threading` 模块线程设置跟踪函数。 +* **局部跟踪函数(每一帧)**:解释器将该跟踪函数的值设置为全局跟踪函数创建帧时的返回值。同样也没有现成的方法能够在帧被创建时自动设置局部跟踪函数。 + +该机制的目的是让调试器对被跟踪的帧有更精确的把握,以减少对性能的影响。 + +### 简单三步构建调试器 (我们最初的设想) + +仅仅依靠上文提到的内容,用自制的跟踪函数来构建一个真正的调试器似乎有些不切实际。幸运的是,Python 的标准调试器 pdb 是基于 Bdb 构建的,后者是 Python 标准库中专门用于构建调试器的基类。 + +基于 Bdb 的简易断点调试器看上去是这样的: + +``` +import bdb +import inspect + +class Debugger(bdb.Bdb): +  def __init__(self): +      Bdb.__init__(self) +      self.breakpoints = dict() +      self.set_trace() + +def set_breakpoint(self, filename, lineno, method): +  self.set_break(filename, lineno) +  try : +      self.breakpoints[(filename, lineno)].add(method) +  except KeyError: +      self.breakpoints[(filename, lineno)] = [method] + +def user_line(self, frame): +  if not self.break_here(frame): +      return + +  # Get filename and lineno from frame +  (filename, lineno, _, _, _) = inspect.getframeinfo(frame) + +  methods = self.breakpoints[(filename, lineno)] +  for method in methods: +      method(frame) +``` + +这个调试器类的全部构成是: + +1. 继承 `Bdb`,定义一个简单的构造函数来初始化基类,并开始跟踪。 +2. 添加 `set_breakpoint` 方法,它使用 `Bdb` 来设置断点,并跟踪这些断点。 +3. 重载 `Bdb` 在当前用户行调用的 `user_line` 方法,该方法一定被一个断点调用,之后获取该断点的源位置,并调用已注册的断点。 + +### 这个简易的 Bdb 调试器效率如何呢? + +Rookout 的目标是在生产级性能的使用场景下提供接近普通调试器的使用体验。那么,让我们来看看先前构建出来的简易调试器表现的如何。 + +为了衡量调试器的整体性能开销,我们使用如下两个简单的函数来进行测试,它们分别在不同的情景下执行了 1600 万次。请注意,在所有情景下断点都不会被执行。 + +``` +def empty_method(): +   pass + +def simple_method(): +   a = 1 +   b = 2 +   c = 3 +   d = 4 +   e = 5 +   f = 6 +   g = 7 +   h = 8 +   i = 9 +   j = 10 +``` + +在使用调试器的情况下需要大量的时间才能完成测试。糟糕的结果指明了,这个简陋 `Bdb` 调试器的性能还远不足以在生产环境中使用。 + +![First Bdb debugger results][6] + +### 对调试器进行优化 + +降低调试器的额外开销主要有三种方法: + +1. **尽可能的限制局部跟踪**:由于每一行代码都可能包含大量事件,局部跟踪比全局跟踪的开销要大得多。 +2. **优化 `call` 事件并尽快将控制权还给解释器**:在 `call` 事件发生时调试器的主要工作是判断是否需要对该事件进行跟踪。 +3. **优化 `line` 事件并尽快将控制权还给解释器**:在 `line` 事件发生时调试器的主要工作是判断我们在此处是否需要设置一个断点。 + +于是我们复刻了 `Bdb` 项目,精简特征、简化代码,针对使用场景进行优化。这些工作虽然得到了一些效果,但仍无法满足我们的需求。因此我们又继续进行了其它的尝试,将代码优化并迁移至 `.pyx` 使用 [Cython][7] 进行编译,可惜结果(如下图所示)依旧不够理想。最终,我们在深入了解 CPython 源码之后意识到,让跟踪过程快到满足生产需求是不可能的。 + +![Second Bdb debugger results][8] + +### 放弃 Bdb 转而尝试字节码操作 + +熬过先前对标准调试方法进行的试验-失败-再试验循环所带来的失望,我们将目光转向另一种选择:字节码操作。 + +Python 解释器的工作主要分为两个阶段: + +1. **将 Python 源码编译成 Python 字节码**:这种(对人类而言)不可读的格式专为执行的效率而优化,它们通常缓存在我们熟知的 `.pyc` 文件当中。 +2. **遍历 解释器循环中的字节码**: 在这一步中解释器会逐条的执行指令。 + +我们选择的模式是:使用**字节码操作**来设置没有全局额外开销的**不中断断点**。这种方式的实现首先需要在内存中的字节码里找到我们感兴趣的部分,然后在该部分的相关机器指令前插入一个函数调用。如此一来,解释器无需任何额外的工作即可实现我们的不中断断点。 + +这种方法并不依靠魔法来实现,让我们简要地举个例子。 + +首先定义一个简单的函数: + +``` +def multiply(a, b): +   result = a * b +   return result +``` + +在 [inspect][9] 模块(其包含了许多实用的单元)的文档里,我们得知可以通过访问 `multiply.func_code.co_code` 来获取函数的字节码: + +``` +'|\x00\x00|\x01\x00\x14}\x02\x00|\x02\x00S' +``` + +使用 Python 标准库中的 [dis][10] 模块可以翻译这些不可读的字符串。调用 `dis.dis(multiply.func_code.co_code)` 之后,我们就可以得到: + +``` +  4          0 LOAD_FAST               0 (a) +             3 LOAD_FAST               1 (b) +             6 BINARY_MULTIPLY     +             7 STORE_FAST              2 (result) + +  5         10 LOAD_FAST               2 (result) +            13 RETURN_VALUE       +``` + +与直截了当的解决方案相比,这种方法让我们更靠近发生在调试器背后的事情。可惜 Python 并没有提供在解释器中修改函数字节码的方法。我们可以对函数对象进行重写,不过那样做的效率满足不了大多数实际的调试场景。最后我们不得不采用一种迂回的方式来使用原生拓展才能完成这一任务。 + +### 总结 + +在构建一个新工具时,总会学到许多事情的工作原理。这种刨根问底的过程能够使你的思路跳出桎梏,从而得到意料之外的解决方案。 + +在 Rookout 团队中构建不中断断点的这段时间里,我学到了许多有关编译器、调试器、服务器框架、并发模型等等领域的知识。如果你希望更深入的了解字节码操作,谷歌的开源项目 [cloud-debug-python][11] 为编辑字节码提供了一些工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/debug-python + +作者:[Liran Haimovitch][a] +选题:[lujun9972][b] +译者:[caiichenr](https://github.com/caiichenr) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/liranhaimovitch +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_jungle_lead.jpeg?itok=pFKKEvT- (Real python in the graphic jungle) +[2]: https://rookout.com/ +[3]: https://pybay.com/ +[4]: https://docs.python.org/3/library/sys.html#sys.settrace +[5]: https://opensource.com/sites/default/files/uploads/python2docs.png (set_trace Python 2 docs page) +[6]: https://opensource.com/sites/default/files/uploads/debuggerresults1.png (First Bdb debugger results) +[7]: https://cython.org/ +[8]: https://opensource.com/sites/default/files/uploads/debuggerresults2.png (Second Bdb debugger results) +[9]: https://docs.python.org/2/library/inspect.html +[10]: https://docs.python.org/2/library/dis.html +[11]: https://github.com/GoogleCloudPlatform/cloud-debug-python +[12]: https://pybay.com/speaker/liran-haimovitch/ +[13]: https://ti.to/sf-python/pybay2019/discount/OpenSource35 diff --git a/published/202003/20190925 Debugging in Emacs- The Grand Unified Debugger.md b/published/202003/20190925 Debugging in Emacs- The Grand Unified Debugger.md new file mode 100644 index 0000000000..ef4b71f194 --- /dev/null +++ b/published/202003/20190925 Debugging in Emacs- The Grand Unified Debugger.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (cycoe) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11994-1.html) +[#]: subject: (Debugging in Emacs: The Grand Unified Debugger) +[#]: via: (https://opensourceforu.com/2019/09/debugging-in-emacs-the-grand-unified-debugger/) +[#]: author: (Vineeth Kartha https://opensourceforu.com/author/vineeth-kartha/) + +Emacs 调试秘籍之 GUD 调试器 +====== + +![][2] + +> 本文简短地对 Emacs 的调试工具 GUD 的特性进行了探索。 + +如果你是一个 C 或 C++ 开发者,你很可能已经使用过 GDB(GNU 调试器),毫无疑问,它是现今最强大、最无可匹敌的调试器之一。它唯一的缺点就是它基于命令行,虽然仍能提供许多强大的功能,但有时也会具有一些局限性。这也就是为什么聪明的人们开始追求整合了编辑器和调试器的图形化 GUI 集成开发环境Integrated Development Environment。仍有些开发者坚信使用鼠标会降低工作效率,在 GUI 上用鼠标点~点~点~是来自恶魔的诱惑。 + +因为 Emacs 是现今最酷的文本编辑器之一,我将为你展示如何在不碰鼠标且不离开 Emacs 的情况下,实现写代码、编译代码、调试代码的过程。 + +GUD(LCTT 译注:全称大统一调试器Grand Unified Debugger,鉴于其缩写形式更为人熟知,以下全文将使用缩写替代此全称)是 Emacs 下的一个模式mode,用于在 Emacs 中运行 GDB。它向 GDB 提供了 Emacs 的所有特性,使用户无需离开编辑器就可以对代码进行调试。 + +### 使用 GUD 的前期准备 + +如果你正在使用一个 Linux 机器,很可能你已经安装了 GDB 和 gcc,接下来就是要确保已经安装了 Emacs。以下的内容我将假设读者熟悉 GDB 并且至少用它做过基本的调试。如果你未曾接触过 GDB,你可以做个快速入门,这些资料在网上随处可得。 + +对于那些 Emacs 新手,我将向你介绍一些基本术语。纵览整篇文章,你将看到诸如 `C-c M-x` 等快捷键。此处 `C` 代表 `Ctrl` 键,`M` 代表 `Alt` 键。`C-c` 代表 `Ctrl` 键和 `c` 键被同时按下。如果你看到 `C-c c`,它代表同时按下 `Ctrl` 键和 `c` 键,释放后紧接着按下 `c` 键。在 Emacs 中,编辑文本的主要区域被称为主缓冲区main buffer,而在 Emacs 窗口下方用于输入命令的区域被称为迷你缓冲区mini buffer。 + +启动 Emacs,并按下 `C-x C-f` 来创建一个新文件。Emacs 将提示你输入一个文件名,此处让我们将文件命名为 `buggyFactorial.cpp`。一旦文件打开,输入如下代码: + +``` +#include +#include + +int factorial(int num) { + int product = 1; + while(num--) { + product *= num; + } + return product; +} +int main() { + int result = factorial(5); + assert(result == 120); +} +``` + +使用 `C-x C-s` 快捷键保存文件。文件保存完毕,是时候进行编译了。按下 `M-x`,在弹出的提示符prompt后输入 `compile` 并点击回车。然后在提示符后,将内容替换为 `g++ -g buggyFactorial.cpp` 并再次点击回车。 + +![图 1: Emacs 迷你缓冲区中编译命令][3] + +这将在 Emacs 中开启另一个缓冲区,显示编译的状态。如果你的代码输入没有错误,你将预期得到如图 2 所示的缓冲区。 + +![图 2: 编译状态][4] + +要想隐藏编译缓冲区,首先确保你的光标在编译缓冲区中(你可以不使用鼠标,而是通过 `C-x o` 快捷键将光标从一个缓冲区移动到另一个),然后按下 `C-x 0`。下一步就是运行代码,并观察是否运行良好。按下 `M-!` 快捷键并在迷你缓冲区的提示符后面输入 `./a.out`。 + +![图 3: 代码在迷你缓冲区中的输出][5] + +你可以看到迷你缓冲区中显示断言失败。很明显代码中有错误,因为 5 的阶乘是 120。那么让我们现在开始调试吧。 + +### 使用 GUD 调式代码 + +现在,我们的代码已经编译完成,是时候看看到底哪里出错了。按下 `M-x` 快捷键并在提示符后输入 `gdb`。在接下来的提示符后,输入 `gdb -i=mi a.out`。如果一切顺利,GDB 会在 Emacs 缓冲区中启动,你会看到如图 4 所示的窗口。 + +![图 4: Emacs 中的 GDB 缓冲区][6] + +在 `gdb` 提示符后,输入 `break main` 来设置断点,并输入 `r` 来运行程序。程序会开始运行并停在 `main()` 函数处。 + +一旦 GDB 到达了 `main` 处设置的断点,就会弹出一个新的缓冲区显示你正在调试的代码。注意左侧的红点,正是你设置断点的位置,同时会有一个小的标志提示你当前代码运行到了哪一行。当前,该标志就在断点处(如图 5)。 + +![图 5: GDB 与代码显示在两个分离的窗口][7] + +为了调试 `factorial` 函数,我们需要单步运行。想要达到此目的,你可以在 GBD 提示符使用 GDB 命令 `step`,或者使用 Emacs 快捷键 `C-c C-s`。还有其它一些快捷键,但我更喜欢 GDB 命令。因此我将在本文的后续部分使用它们。 + +单步运行时让我们注意一下局部变量中的阶乘值。参考图 6 来设置在 Emacs 帧中显示局部变量值。 + +![图 6: 在 Emacs 中使用独立帧显示局部变量][8] + +在 GDB 提示符中进行单步运行并观察局部变量值的变化。在循环的第一次迭代中,我们发现了一个问题。此处乘法的结果应该是 5 而不是 4。 + +本文到这里也差不多结束了,读者可以自行探索发现 GUD 模式这片新大陆。GDB 中的所有命令都可以在 GUD 模式中运行。我将此代码的修复留给读者作为一个练习。看看你在调试的过程中,可以做哪一些定制化,来使你的工作流更加简单和高效。 + +-------------------------------------------------------------------------------- + +via: https://opensourceforu.com/2019/09/debugging-in-emacs-the-grand-unified-debugger/ + +作者:[Vineeth Kartha][a] +选题:[lujun9972][b] +译者:[cycoe](https://github.com/cycoe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensourceforu.com/author/vineeth-kartha/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Screenshot-from-2019-09-25-15-39-46.png?ssl=1 +[2]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Screenshot-from-2019-09-25-15-39-46.png?ssl=1 +[3]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Figure_1.png?ssl=1 +[4]: https://i2.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Figure_2.png?ssl=1 +[5]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Figure_3.png?ssl=1 +[6]: https://i0.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Figure_4.png?ssl=1 +[7]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Figure_5.png?ssl=1 +[8]: https://i1.wp.com/opensourceforu.com/wp-content/uploads/2019/09/Figure_6.png?ssl=1 diff --git a/published/202003/20191126 Calculator N- is an open source scientific calculator for your smartphone.md b/published/202003/20191126 Calculator N- is an open source scientific calculator for your smartphone.md new file mode 100644 index 0000000000..3ba3711fe6 --- /dev/null +++ b/published/202003/20191126 Calculator N- is an open source scientific calculator for your smartphone.md @@ -0,0 +1,60 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11981-1.html) +[#]: subject: (Calculator N+ is an open source scientific calculator for your smartphone) +[#]: via: (https://opensource.com/article/19/11/calculator-n-mobile) +[#]: author: (Ricardo Berlasso https://opensource.com/users/rgb-es) + +Calculator N+:一款智能手机上的开源科学计算器 +====== + +> 这个 Android 应用可在掌中计算许多高级数学函数。 + +![](https://img.linux.net.cn/data/attachment/album/202003/10/113543hlb5xu7b5e17ba90.jpg) + +移动电话每天都在变得越来越强大,因此毫不奇怪它们可以击败不太久前的大多数计算机。这也意味着移动手机上的工具每天都在变得越来越强大。 + +之前,我写过一篇 [两款 Linux 桌面端可用的科学计算器][2],我接着将介绍 [Calculator N+][3],这是一款很棒的适用于 Android 设备的计算机代数系统(CAS)应用,采用 GPL v3.0 许可证下。 + +Calculator N+ 被认为是“适用于 Android 的强大计算器”,但这是一个谦虚的说法。它不仅可以以任意精度工作,还可以显示根数和分数等*很多*功能。 + +寻找多项式根?可以。分解因数?可以。导数、积分和极限?可以。数论(模算术、组合学、素因数分解)?可以。 + +你还可以求解方程系统、简化表达式(包括三角函数)、转换单位,只要你想到的,它都能做! + +![Calculator N+ graphical interface][4] + +其结果以 LaTeX 输出。左上方的菜单提供了许多强大的功能,只需触摸一下即可使用。同样在该菜单中,你将找到该应用所有功能的帮助文件。在屏幕的右上角,你可以在精确表示法和十进制表示法之间切换。最后,点击屏幕底部的蓝色栏,即可访问应用中的所有函数库。不过要小心!如果你不是数学家、物理学家或工程师,那么这么长的列表会看上去很吓人。 + +所有这些功能都来自 [Symja 库][5],这是另一个出色的 GPL 3 项目。 + +这两个项目都处于积极开发中,并且每个版本都在不断完善。特别是,Calculator N+ 的 v3.4.6 在用户界面(UI)品质方面取得了重大飞跃。虽然还是存在一些不够好的地方,但是要在智能手机的小巧的用户界面中发挥如此强大的功能是一项艰巨的任务,我认为应用开发人员正在很好地解决其剩余的问题。对他们表示敬意! + +如果你是老师、学生或在理工科领域工作,请试试 Calculator N+。它是免费、无广告、开源的,并可以满足你所有的数学需求。(当然,除了数学考试期间,为防止作弊绝对不允许使用智能手机。) + +可以在 [Google Play 商店][6]找到 Calculator N+,也可以使用 GitHub 页面上的说明[从源代码构建][7]。 + +如果你知道用于科学或工程的其他有用的开源应用,请在评论中告知我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/calculator-n-mobile + +作者:[Ricardo Berlasso][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rgb-es +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/calculator_money_currency_financial_tool.jpg?itok=2QMa1y8c (scientific calculator) +[2]: https://linux.cn/article-9643-1.html +[3]: https://github.com/tranleduy2000/ncalc +[4]: https://opensource.com/sites/default/files/uploads/calculatornplus_sqrt-frac.png (Calculator N+ graphical interface) +[5]: https://github.com/axkr/symja_android_library +[6]: https://play.google.com/store/apps/details?id=com.duy.calculator.free +[7]: https://github.com/tranleduy2000/ncalc/blob/master/README.md diff --git a/published/202003/20191223 10 articles to learn Linux your way.md b/published/202003/20191223 10 articles to learn Linux your way.md new file mode 100644 index 0000000000..a38a98dff2 --- /dev/null +++ b/published/202003/20191223 10 articles to learn Linux your way.md @@ -0,0 +1,99 @@ +[#]: collector: "lujun9972" +[#]: translator: "messon007" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12035-1.html" +[#]: subject: "10 articles to learn Linux your way" +[#]: via: "https://opensource.com/article/19/12/learn-linux" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" + +10 篇关于 Linux 的好文章 +======= + +> 2019 年对于 Linux 来说是个好年份,让我们一起来回顾一下这十篇关于 Linux 的好文章。 + +![](https://img.linux.net.cn/data/attachment/album/202003/25/115447rrjfuufccumf0oz6.jpg) + +2019 年对于 Linux 来说是个好年份,显然这里的 “Linux” 一词有更多含义: 内核? 桌面? 或是生态? 在此次回顾年度 Linux 好文中,我在选择十大好文时有意采取了更开放的视角。下面就是十大好文(无先后次序之分)。 + +### 《Linux 权限入门指南》 + +Bryant Son 的《[Linux 权限入门指南][2]》向新用户介绍了文件权限的概念,通过图形和图表的方式来说明每个要点。通常很难以视觉的方式来解释纯粹基于文本的概念,而本文则对可视方式学习的人非常友好。 Bryant 在讲述时也很专注主题。关于文件权限的任何阐述都可能引出几个相关主题(例如所有权和访问控制列表等),但是本文致力于解释一件事并很好地解释它。 + +### 《为什么我从 Mac 换到了 Linux》 + +Matthew Broberg 在《[为什么我从 Mac 换到了 Linux][3]》中清楚而客观的介绍了他从 MacOS 切换到 Linux 的经历。通常切换平台是很困难的,因此记录决定切换的背后考虑非常重要。我认为 Matt 的文章带有几个目的,但对我来说最重要的两个目的是:通过解答他的问题并提供潜在的解决方案,他请 Linux 社区的人们来支持他;这对于其他正在考虑采用 Linux 的人来说是一个很好的参考。 + +### 《在 Linux 上定位 WiFi 速度慢的问题》 + +《[在 Linux 上定位 WiFi 速度慢的问题][4]》这篇文章中,David Clinton 对每个人都可能遇到的问题进行了分析,并提供了怎么样一步步解决的思路。这是“偶然的 Linux”技巧的一个很好的例子,但它不仅可以帮助经常遇到问题的人,而且可以向非 Linux 用户展示如何在其他平台上进行问题定位。 + +### 《一个非技术人员对 GNOME 项目使用 GitLab 的感受》 + +Molly de Blanc 所写的《[一个非技术人员对 GNOME 项目使用 GitLab 的感受][5]》深层次地揭示了开源界的一个典范(GNOME 桌面)如何使用开源界的另一个典范(Git)进行开发。听到一个开放源代码项目对于任何需要做的事情默认为开放源代码解决方案,这总是让我感到振奋。无论如何,这种情况并不常见,然而对于 GNOME 来说,这是项目本身的重要且受欢迎的部分。 + +### 《详解 Linux 中的虚拟文件系统》 + +Alison Chaiken 在《[详解 Linux 中的虚拟文件系统][6]》中巧妙地解释了对许多用户来说都很难理解的东西。理解文件系统是什么、虚拟文件系统和真实的文件系统是一回事,但从定义上讲,*虚拟的*其实并不是真正的文件系统。Linux 以一种普通用户也能从中受益的方式提供了它们,Alison 的文章以一种易于理解的方式对其进行了阐述。另外,Alison 在文章的后半部分更深入地介绍了如何使用 `bcc` 脚本查看她刚刚讲的虚拟文件系统的相关内容。 + +### 《理解文件路径并学会使用它们》 + +我认为《[理解文件路径并学会使用它们][7]》很重要,因为这是大多数用户(在任何平台上)似乎都没有学过的概念。这是一个奇怪的现象,因为现在比以往任何时候,人们都越来越多地看到*文件路徑*:几乎所有的互联网网址都包含一个文件路径,该路径告诉你你在域中的确切位置。我常常在想为什么计算机教育不是从互联网开始的,互联网是目前最熟悉的应用程序,并且可以说是使用最频繁的超级计算机,完全可以用它来解释我们每天使用的设备。(我想如果这些设备运行 Linux 会有所帮助,但是我们正在努力。) + +### 《Linux 下的进程间通信:共享存储》 + +Marty Kalin 的《[Linux 下的进程间通信:共享存储][8]》从 Linux 的开发者视角解释了 IPC 以及如何在代码中使用它。虽然我只是列入了这篇文章,不过它实际上是一个三篇文章的系列,而它是同类文章中阐述的最好的。很少有文档能够解释 Linux 怎样处理 IPC,更不用说 IPC 是什么,为什么它很重要,或者在编程时该如何使用它。通常这是你在大学读书时关注的话题。现在,你可以在这里阅读所有内容。 + +### 《在 Linux 上用 strace 来理解系统调用》 + +Gaurav Kamathe 的《[在 Linux 上用 strace 来理解系统调用][9]》具有很强的技术性,我希望我所见过的有关 `strace` 的每次会议演讲都是如此。这是对一个复杂但非常有用的命令的清晰演示。令我惊讶的是,我读了本文才发现自己一直使用的命令不是这个命令,而是 `ltrace`(可以用来查看命令调用了哪些函数)。本文包含了丰富的信息,是开发人员和测试人员的快捷参考手册。 + +### 《Linux 桌面发展旅程》 + +Jim Hall 的《[Linux 桌面发展旅程][10]》是对 Linux 桌面历史的一次视觉之旅。从 [TWM][11] 开始,经历了 [FVWM][12]、[GNOME][13]、[KDE][14] 等薪火相传。如果你是 Linux 的新手,那么这将是一个出自那个年代的人的有趣的历史课(有截图可以证明这一点)。如果你已经使用 Linux 多年,那么这肯定会唤醒你的记忆。最后,可以肯定的是:仍然可以找到 20 年前屏幕快照的人都是神一样的数据档案管理员。 + +### 《用 Linux 创建你自己的视频流服务器》 + +Aaron J. Prisk 的 《[用 Linux 创建你自己的视频流服务器][15]》消除了大多数人对我们视为理所当然的服务的误解。由于 YouTube 和 Twitch 之类服务的存在,许多人认为这是向世界广播视频的唯一方式。当然,人们过去常常以为 Windows 和 Mac 是计算机的唯一入口,值得庆幸的是,最终证明这是严重的误解。在本文中,Aaron 建立了一个视频流服务器,甚至还顺便讨论了一下 [OBS][16],以便你可以创建视频。这是一个有趣的周末项目还是新职业的开始?你自己决定。 + +### 《塑造 Linux 历史的 10 个时刻》 + +Alan Formy-Duval 撰写的《[塑造 Linux 历史的 10 个时刻][17]》试图完成一项艰巨的任务,即从 Linux 的历史中选出 10 件有代表性的事情。当然,这是很难的,因为有如此多重要的时刻,所以我想看看 Alan 是如何通过自己的经历来选择它。例如,什么时候开始意识到 Linux 必然可以发展下去?—— 当 Alan 意识到他维护的所有系统都在运行 Linux 时。用这种方式来解释历史是很美的,因为每个人的重要时刻都会有所不同。 关于 Linux 没有权威性列表,关于 Linux 的文章也没有,关于开源也没有。你可以创建你自己的列表,也可以使你自己成为列表的一部分。 + +(LCTT 译注:这里推荐了 11 篇,我数了好几遍,没眼花……) + +### 你想从何学起? + +你还想知道 Linux 的什么内容?请在评论区告诉我们或来文讲述你的 Linux 经验。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/learn-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_Penguin_Image_520x292_12324207_0714_mm_v1a.png?itok=p7cWyQv9 "Penguins gathered together in the Artic" +[2]: https://linux.cn/article-11056-1.html +[3]: https://linux.cn/article-11586-1.html +[4]: http://opensource.com/article/19/4/troubleshooting-wifi-linux +[5]: https://linux.cn/article-11806-1.html +[6]: https://linux.cn/article-10884-1.html +[7]: https://opensource.com/article/19/8/understanding-file-paths-linux +[8]: https://linux.cn/article-10826-1.html +[9]: https://linux.cn/article-11545-1.html +[10]: https://opensource.com/article/19/8/how-linux-desktop-grown +[11]: https://github.com/freedesktop/twm +[12]: http://www.fvwm.org/ +[13]: http://gnome.org +[14]: http://kde.org +[15]: https://opensource.com/article/19/1/basic-live-video-streaming-server +[16]: https://opensource.com/life/15/12/real-time-linux-video-editing-with-obs-studio +[17]: https://opensource.com/article/19/4/top-moments-linux-history +[18]: https://opensource.com/how-submit-article diff --git a/published/202003/20191223 Prioritizing simplicity in your Python code.md b/published/202003/20191223 Prioritizing simplicity in your Python code.md new file mode 100644 index 0000000000..e0760548c7 --- /dev/null +++ b/published/202003/20191223 Prioritizing simplicity in your Python code.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (caiichenr) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11999-1.html) +[#]: subject: (Prioritizing simplicity in your Python code) +[#]: via: (https://opensource.com/article/19/12/zen-python-simplicity-complexity) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +简单是 Python 编程的第一要则 +====== + +> 本文是 Python 之禅特别系列的第二篇,我们将要关注其中第三与第四条原则:简单与复杂。 + +![](https://img.linux.net.cn/data/attachment/album/202003/15/124150t4wf3wwgdrijx6xx.jpg) + +> "Il semble que la perfection soit atteinte non quand il n'y a plus rien à ajouter, mais quand il n'y plus rien à retrancher." +> +> "It seems that perfection is finally attained not when there is no longer anything to add, but when there is no longer anything to take away." +> +> “完美并非无可增,而是不可减。” +> +> —Antoine de Saint-Exupéry, [Terre des Hommes][2], 1939 + +编程时最常有的考量是与复杂性的斗争,只想写出让旁人无从下手的繁杂代码,对每个程序员来讲都算不上难事。倘若未能触及代码的简繁取舍,那么 《[Python 之禅][3]》 就有了一角残缺。 + +### 简单胜过复杂Simple is better than complex + +尚有选择余地时,应该选简单的方案。Python 少有*不可为*之事,这意味着设计出巴洛克风格(LCTT 译注:即夸张和不理性)的程序只为解决浅显的问题不仅有可能,甚至很简单。 + +正因如此,编程时应当谨记,代码的简单性是最易丢失,却最难复得的。 + +这意味着,在可以选用函数来表达时不要去引入额外的类;避免使用强力的第三方库往往有助于你针对迫切的问题场景设计更妥当的简短函数。不过其根本的意图,旨在让你减少对将来的盘算,而去着重解决手头的问题。 + +以简单和优美作为指导原则的代码相比那些想要囊括将来一切变数的,在日后要容易修改得多。 + +### 复杂胜过错综复杂Complex is better than complicated + +把握用词的精确含义对于理解这条令人费解的原则是至关重要的。形容某事复杂complex,是说它由许多部分组成,着重组成成分之多;而形容某事错综复杂complicated,则是指其包含着差异巨大、难以预料的行为,强调的是各组成部分之间的杂乱联系。 + +解决困难问题时,往往没有可行的简单方案。此时,最 Python 化的策略是“自底向上bottom-up”地构建出简单的工具,之后将其组合用以解决该问题。 + +这正是对象组合object composition这类技术的闪耀之处,它避免了错综复杂的继承体系,转而由独立的对象把一些方法调用传递给别的独立对象。这些对象都能独立地测试与部署,最终却可以组成一体。 + +“自底建造” 的另一例即是[单分派泛函数][4]singledispatch的使用,抛弃了错综复杂的对象之后,我们得到是简单、几乎无行为的对象以及独立的行为。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/zen-python-simplicity-complexity + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[caiichenr](https://github.com/caiichenr) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/read_book_guide_tutorial_teacher_student_apaper.png?itok=_GOufk6N (Person reading a book and digital copy) +[2]: https://en.wikipedia.org/wiki/Wind,_Sand_and_Stars +[3]: https://www.python.org/dev/peps/pep-0020/ +[4]: https://opensource.com/article/19/5/python-singledispatch diff --git a/published/202003/20191226 10 Linux command tutorials for beginners and experts.md b/published/202003/20191226 10 Linux command tutorials for beginners and experts.md new file mode 100644 index 0000000000..b9d216695c --- /dev/null +++ b/published/202003/20191226 10 Linux command tutorials for beginners and experts.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12011-1.html) +[#]: subject: (10 Linux command tutorials for beginners and experts) +[#]: via: (https://opensource.com/article/19/12/linux-commands) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +10 篇对初学者和专家都有用的 Linux 命令教程 +====== + +> 在这有关 Linux 命令的十大文章中,了解如何使 Linux 发挥所需的作用。 + +![](https://img.linux.net.cn/data/attachment/album/202003/19/095932xc64xw7cwqlolale.jpg) + +**很好地**使用 Linux 意味着了解有哪些命令以及它们可以为你执行的功能。 + +### 《在 Linux 命令行下使用“原力”》 + +原力force有光明的一面和黑暗的一面。正确理解这个对于真正掌握它至关重要。Alan Formy-Duval 在他的文章《[在 Linux 命令行下使用“原力”][2]》中,解释了一些流行的、有时是危险的命令的 `-f` 选项(也称为 `--force`)。 + +### 《Linux useradd 命令介绍》 + +共享帐户是一个坏主意。相反,请使用典型的 `useradd` 命令为不同的人(甚至是不同的角色)分配单独的帐户。作为其经典的 Linux 管理基础系列的一部分,Alan Formy-Duval 提供了《[Linux useradd 命令介绍][3]》,并且像往常一样,他用**朴实明白的语言**对其进行了解释,以便新老管理员都可以理解。 + +### 《用 Linux 命令显示硬件信息》 + +机器**里面**是什么?有时不使用螺丝刀检查硬件很有用。无论是你正在使用的计算机,还是在商店购买前进行测试的计算机、或者是正在尝试维修的计算机,在《[用 Linux 命令显示硬件信息][4]》中,Howard Fosdick 提供了或流行或晦涩难懂的命令,以帮助你深入了解计算机的硬件信息。 + +### 《如何在 Linux 上使用 gocryptfs 加密文件》 + +从社会保险号到个人信件再到亲人,我们的文件中包含了许多私人数据。在《[如何在 Linux 上使用 gocryptfs 加密文件][5]》中,Brian "Bex" Exelbierd 解释了如何保持**隐私*的私密性。此外,他展示了一种加密文件的方式,这种方式对你现有的工作流程几乎没有影响。这不是复杂的 PGP 风格的密钥管理和后台密钥代理的难题,这是快速、无缝和安全的文件加密。 + +### 《如何使用 rsync 的高级用法进行大型备份》 + +在新的一年中,许多人会下定决心要更加努力地进行备份。Alan Formy-Duval 早在几年前就已经做出了解决方案,因为在《[如何使用 rsync 的高级用法进行大型备份][6]》中,他表现出对文件同步命令的极其熟悉。你可能不会马上记住所有语法,但其思路是读取和处理选项、构造备份命令,然后使其自动化。这是使用 `rsync` 的明智方法,也是可靠地执行备份的**唯一**方法。 + +### 《在 Linux 命令行使用 more 查看文本文件》 + +在 Scott Nesbitt 的文章《[在 Linux 命令行使用 more 查看文本文件][7]》中,古老而良好的默认分页器 `more` 引起了人们的关注。许多人安装和使用 `less`,因为它比 `more` 更灵活。但是,随着越来越多的系统在新出现的容器中实现,有时甚至不存在像 `less` 或 `most` 之类的新颖的豪华工具。了解和使用`more` 很简单,这是常见的默认设置,并且是生产系统最后的调试工具。 + +### 《关于 sudo 你可能不知道的》 + +`sudo` 命令因其过失而闻名。人们知道 `sudo` 一词,我们大多数人认为我们知道它的作用。我们的观点是正确的,但是正如 Peter Czanik 在他的文章《[关于 sudo 你可能不知道的][8]》中所揭示的那样,该命令所包含的不仅仅是“西蒙说的Simon says”(LCTT 译注:国外的一个儿童游戏)。就像这个经典的童年游戏一样,`sudo` 命令功能强大,也容易犯愚蠢的错误 —— 有更多的可能产生可怕都后果,而这是你绝不想遇上的事情! + +### 《怎样用 Bash 编程:语法和工具》 + +如果你是 Linux、BSD 或 Mac(以及近来的 Windows)用户,你也许使用过交互式 Bash shell。它是快速的、一次性命令的绝佳 shell,这就是为什么这么多 Linux 用户喜欢将其用作主要用户界面的原因。但是,Bash 不仅仅是个命令提示符。它也是一种编程语言,如果你已经在使用 Bash 命令,那么自动化的道路从未如此简单过。在 David Both 的出色作品《[怎样用 Bash 编程:语法和工具][9]》中对其进行全面了解。 + +### 《精通 Linux 的 ls 命令》 + +`ls` 命令是那些两个字母的命令之一。单字母命令是针对慢速终端的优化,因为慢速终端的输入的每个字母都会导致明显的延迟,而这对于懒惰的打字员来说也是不错的奖励。一如既往地,Seth Kenlon 清晰实用地解释了你可以怎样《[精通 Linux 的 ls 命令][10]》。最重要的是,在“一切都是文件”的系统中,列出文件至关重要。 + +### 《Linux cat 命令入门》 + +`cat` 命令(con*cat*enate 的缩写)看似简单。无论是使用它来快速查看文件的内容还是将内容通过管道传输到另一个命令,你都可能没有充分利用 `cat` 的功能。Alan Formy-Duval 的《[Linux cat 命令入门][11]》提供了一些新思路,可以使你没有打开文件的感觉就可以看到文件内容。另外,了解各种有关 `zcat` 的知识,这样你就可以无需解压缩就可以得到压缩文件的内容!这是一件小而简单的事情,但是**这**是使 Linux 很棒的原因。 + +### 继续旅程 + +不要让这些关于 Linux 命令的 10 篇最佳文章成为你的旅程终点。关于 Linux 及其多才多艺的提示符,还有更多值得去发现,因此,请继续关注以获取更多知识。而且,如果你想让我们介绍一个 Linux 命令,请在评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-commands + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/car-penguin-drive-linux-yellow.png?itok=twWGlYAc (Penguin driving a car with a yellow background) +[2]: https://linux.cn/article-10881-1.html +[3]: https://linux.cn/article-11756-1.html +[4]: https://linux.cn/article-11422-1.html +[5]: https://opensource.com/article/19/8/how-encrypt-files-gocryptfs +[6]: https://linux.cn/article-10865-1.html +[7]: https://linux.cn/article-10531-1.html +[8]: https://linux.cn/article-11595-1.html +[9]: https://linux.cn/article-11552-1.html +[10]: https://linux.cn/article-11159-1.html +[11]: https://opensource.com/article/19/2/getting-started-cat-command +[12]: https://opensource.com/how-submit-article diff --git a/published/202003/20200113 How to setup a DNS server with bind.md b/published/202003/20200113 How to setup a DNS server with bind.md new file mode 100644 index 0000000000..356ea4bf8c --- /dev/null +++ b/published/202003/20200113 How to setup a DNS server with bind.md @@ -0,0 +1,387 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11997-1.html) +[#]: subject: (How to setup a DNS server with bind) +[#]: via: (https://fedoramagazine.org/how-to-setup-a-dns-server-with-bind/) +[#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/) + +简明指南:使用 bind 设置 DNS 服务器 +====== + +![][1] + +域名系统Domain Name System,我们更通常称为 DNS 的系统,可以将域名翻译或转换为与该域关联的 IP 地址。DNS 是能够让你通过名称找到自己喜欢的网站而不是在浏览器中输入 IP 地址的原因。本指南将向你展示如何配置一个主 DNS 系统以及客户端。 + +以下是本文示例中使用的系统细节: + +``` +dns01.fedora.local (192.168.1.160)- 主 DNS 服务器 +client.fedora.local (192.168.1.136)- 客户端 +``` + +### DNS 服务器配置 + +使用 `sudo` 安装 bind 包: + +``` +$ sudo dnf install bind bind-utils -y +``` + +bind 包提供了 `/etc/named.conf` 配置文件,来供你配置 DNS 服务器。 + +编辑 `/etc/named.conf` 文件: + +``` +sudo vi /etc/named.conf +``` + +查找以下行: + +``` +listen-on port 53 { 127.0.0.1; }; +``` + +添加主 DNS 服务器的 IP 地址,如下所示: + +``` +listen-on port 53 { 127.0.0.1; 192.168.1.160; }; +``` + +查找以下行: + +``` +allow-query { localhost; }; +``` + +添加本地网络范围。该示例系统使用的 IP 地址在 192.168.1.X 的范围内。指定如下: + +``` +allow-query { localhost; 192.168.1.0/24; }; +``` + +指定转发和反向区域。区域文件Zone file就是具有系统上 DNS 信息(例如 IP 地址和主机名)的文本文件。转发区域文件forward zone file使得将主机名转换为 IP 地址成为可能。反向区域文件reverse zone file则相反。它允许远程系统将 IP 地址转换为主机名。 + +在 `/etc/named.conf` 文件的底部查找以下行: + +``` +include "/etc/named.rfc1912.zones"; +``` + +在此处,你将在**该行的正上方**指定区域文件信息,如下所示: + +``` +zone "dns01.fedora.local" IN { + type master; + file "forward.fedora.local"; + allow-update { none; }; +}; + +zone "1.168.192.in-addr.arpa" IN { + type master; + file "reverse.fedora.local"; + allow-update { none; }; +}; +``` + +`forward.fedora.local` 和 `reverse.fedora.local` 文件是要创建的区域文件的名称。它们可以是任意名字。 + +保存并退出。 + +#### 创建区域文件 + +创建你在 `/etc/named.conf` 文件中指定的转发和反向区域文件: + +``` +$ sudo vi /var/named/forward.fedora.local +``` + +添加以下行: + +``` +$TTL 86400 +@ IN SOA dns01.fedora.local. root.fedora.local. ( + 2011071001 ;Serial + 3600 ;Refresh + 1800 ;Retry + 604800 ;Expire + 86400 ;Minimum TTL +) +@ IN NS dns01.fedora.local. +@ IN A 192.168.1.160 +dns01 IN A 192.168.1.160 +client IN A 192.168.1.136 +``` + +所有**粗体**(LCTT 译注:本译文中无法呈现粗体)内容都特定于你的环境。保存文件并退出。接下来,编辑 `reverse.fedora.local` 文件: + +``` +$ sudo vi /var/named/reverse.fedora.local +``` + +添加以下行: + +``` +$TTL 86400 +@ IN SOA dns01.fedora.local. root.fedora.local. ( + 2011071001 ;Serial + 3600 ;Refresh + 1800 ;Retry + 604800 ;Expire + 86400 ;Minimum TTL +) +@ IN NS dns01.fedora.local. +@ IN PTR fedora.local. +dns01 IN A 192.168.1.160 +client IN A 192.168.1.136 +160 IN PTR dns01.fedora.local. +136 IN PTR client.fedora.local. +``` + +所有**粗体**(LCTT 译注:本译文中无法呈现粗体)内容都特定于你的环境。保存文件并退出。 + +你还需要配置 SELinux 并为配置文件添加正确的所有权。 + +``` +sudo chgrp named -R /var/named +sudo chown -v root:named /etc/named.conf +sudo restorecon -rv /var/named +sudo restorecon /etc/named.conf +``` + +配置防火墙: + +``` +sudo firewall-cmd --add-service=dns --perm +sudo firewall-cmd --reload +``` + +#### 检查配置是否存在语法错误 + +``` +sudo named-checkconf /etc/named.conf +``` + +如果没有输出或返回错误,那么你的配置有效。 + +检查转发和反向区域文件。 + +``` +$ sudo named-checkzone forward.fedora.local /var/named/forward.fedora.local + +$ sudo named-checkzone reverse.fedora.local /var/named/reverse.fedora.local +``` + +你应该看到 “OK” 的响应: + +``` +zone forward.fedora.local/IN: loaded serial 2011071001 +OK + +zone reverse.fedora.local/IN: loaded serial 2011071001 +OK +``` + +#### 启用并启动 DNS 服务 + +``` +$ sudo systemctl enable named +$ sudo systemctl start named +``` + +#### 配置 resolv.conf 文件 + +编辑 `/etc/resolv.conf` 文件: + +``` +$ sudo vi /etc/resolv.conf +``` + +查找你当前的 `nameserver` 行。在示例系统上,使用调制解调器/路由器充当名称服务器,因此当前看起来像这样: + +``` +nameserver 192.168.1.1 +``` + +这需要更改为主 DNS 服务器的 IP 地址: + +``` +nameserver 192.168.1.160 +``` + +保存更改并退出。 + +不幸的是需要注意一点。如果系统重启或网络重启,那么 NetworkManager 会覆盖 `/etc/resolv.conf` 文件。这意味着你将丢失所做的所有更改。 + +为了防止这种情况发生,请将 `/etc/resolv.conf` 设为不可变: + +``` +$ sudo chattr +i /etc/resolv.conf +``` + +如果要重新设置,就需要允许其再次被覆盖: + +``` +$ sudo chattr -i /etc/resolv.conf +``` + +#### 测试 DNS 服务器 + +``` +$ dig fedoramagazine.org +``` + +``` +; <<>> DiG 9.11.13-RedHat-9.11.13-2.fc30 <<>> fedoramagazine.org +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8391 +;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 6 + +;; OPT PSEUDOSECTION: + ; EDNS: version: 0, flags:; udp: 4096 + ; COOKIE: c7350d07f8efaa1286c670ab5e13482d600f82274871195a (good) + ;; QUESTION SECTION: + ;fedoramagazine.org. IN A + +;; ANSWER SECTION: + fedoramagazine.org. 50 IN A 35.197.52.145 + +;; AUTHORITY SECTION: + fedoramagazine.org. 86150 IN NS ns05.fedoraproject.org. + fedoramagazine.org. 86150 IN NS ns02.fedoraproject.org. + fedoramagazine.org. 86150 IN NS ns04.fedoraproject.org. + +;; ADDITIONAL SECTION: + ns02.fedoraproject.org. 86150 IN A 152.19.134.139 + ns04.fedoraproject.org. 86150 IN A 209.132.181.17 + ns05.fedoraproject.org. 86150 IN A 85.236.55.10 + ns02.fedoraproject.org. 86150 IN AAAA 2610:28:3090:3001:dead:beef:cafe:fed5 + ns05.fedoraproject.org. 86150 IN AAAA 2001:4178:2:1269:dead:beef:cafe:fed5 + + ;; Query time: 830 msec + ;; SERVER: 192.168.1.160#53(192.168.1.160) + ;; WHEN: Mon Jan 06 08:46:05 CST 2020 + ;; MSG SIZE rcvd: 266 +``` + +需要检查几件事以验证 DNS 服务器是否正常运行。显然,取得结果很重要,但这本身并不意味着 DNS 服务器实际上正常工作。 + +顶部的 `QUERY`、`ANSWER` 和 `AUTHORITY` 字段应显示为非零,如我们的示例所示: + +``` +;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 6 +``` + +并且 `SERVER` 字段应有你的 DNS 服务器的 IP 地址: + +``` +;; SERVER: 192.168.1.160#53(192.168.1.160) +``` + +如果这是你第一次运行 `dig` 命令,请注意完成查询要花费 830 毫秒的时间: + +``` +;; Query time: 830 msec +``` + +如果再次运行它,查询将会更快: + +``` +$ dig fedoramagazine.org +``` + +``` +;; Query time: 0 msec +;; SERVER: 192.168.1.160#53(192.168.1.160) +``` + +### 客户端配置 + +客户端配置将简单得多。 + +安装 bind 程序: + +``` +$ sudo dnf install bind-utils -y +``` + +编辑 `/etc/resolv.conf` 文件,并将主 DNS 配置为唯一的名称服务器: + +``` +$ sudo vi /etc/resolv.conf +``` + +它看起来像这样: + +``` +nameserver 192.168.1.160 +``` + +保存更改并退出。然后,使 `/etc/resolv.conf` 文件不可变,防止其被覆盖并变回默认设置: + +``` +$ sudo chattr +i /etc/resolv.conf +``` + +#### 测试客户端 + +你应该获得与 DNS 服务器相同的结果: + +``` +$ dig fedoramagazine.org +``` + +``` +; <<>> DiG 9.11.13-RedHat-9.11.13-2.fc30 <<>> fedoramagazine.org +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8391 +;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 6 + +;; OPT PSEUDOSECTION: + ; EDNS: version: 0, flags:; udp: 4096 + ; COOKIE: c7350d07f8efaa1286c670ab5e13482d600f82274871195a (good) + ;; QUESTION SECTION: + ;fedoramagazine.org. IN A + +;; ANSWER SECTION: + fedoramagazine.org. 50 IN A 35.197.52.145 + +;; AUTHORITY SECTION: + fedoramagazine.org. 86150 IN NS ns05.fedoraproject.org. + fedoramagazine.org. 86150 IN NS ns02.fedoraproject.org. + fedoramagazine.org. 86150 IN NS ns04.fedoraproject.org. + +;; ADDITIONAL SECTION: + ns02.fedoraproject.org. 86150 IN A 152.19.134.139 + ns04.fedoraproject.org. 86150 IN A 209.132.181.17 + ns05.fedoraproject.org. 86150 IN A 85.236.55.10 + ns02.fedoraproject.org. 86150 IN AAAA 2610:28:3090:3001:dead:beef:cafe:fed5 + ns05.fedoraproject.org. 86150 IN AAAA 2001:4178:2:1269:dead:beef:cafe:fed5 + + ;; Query time: 1 msec + ;; SERVER: 192.168.1.160#53(192.168.1.160) + ;; WHEN: Mon Jan 06 08:46:05 CST 2020 + ;; MSG SIZE rcvd: 266 +``` + +确保 `SERVER` 输出的是你 DNS 服务器的 IP 地址。 + +你的 DNS 服务器设置完成了,现在所有来自客户端的请求都会经过你的 DNS 服务器了! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-setup-a-dns-server-with-bind/ + +作者:[Curt Warfield][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rcurtiswarfield/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/01/dns-server-bind-1-816x345.png diff --git a/published/202003/20200121 Syncthing- Open Source P2P File Syncing Tool.md b/published/202003/20200121 Syncthing- Open Source P2P File Syncing Tool.md new file mode 100644 index 0000000000..383fc2f351 --- /dev/null +++ b/published/202003/20200121 Syncthing- Open Source P2P File Syncing Tool.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11960-1.html) +[#]: subject: (Syncthing: Open Source P2P File Syncing Tool) +[#]: via: (https://itsfoss.com/syncthing/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Syncthing:开源 P2P 文件同步工具 +====== + +> Syncthing 是一个开源的 P2P 文件同步工具,可用于在多个设备(包括 Android 手机)之间同步文件。 + +![](https://img.linux.net.cn/data/attachment/album/202003/05/094211oy2dosttvoaseovk.jpg) + +通常,我们有 [MEGA][1] 或 Dropbox 之类的云同步解决方案,以便在云上备份我们的文件,同时更易于共享。但是,如果要跨多个设备同步文件而不将其存储在云中怎么办? + +这就是 [Syncthing][2] 派上用场的地方了。 + +### Syncthing:一个跨设备同步文件的开源工具 + +![][3] + +Syncthing 可让你跨多个设备同步文件(包括对 Android 智能手机的支持)。它主要通过 Linux 上的 Web UI 进行工作,但也提供了 GUI(需要单独安装)。 + +然而,Syncthing 完全没有利用云,它是 [P2P][4] 文件同步工具。你的数据不会被发送到中央服务器。而是会在所有设备之间同步。因此,它并不能真正取代 [Linux 上的典型云存储服务][5]。 + +要添加远程设备,你只需要设备 ID(或直接扫描二维码),而无需 IP 地址。 + +如果你想要远程备份文件,那么你可能应该依靠云。 + +![Syncthing GUI][6] + +考虑到所有因素,Syncthing 可以在很多方面派上用场。从技术上讲,你可以安全、私密地在多个系统上访问重要文件,而不必担心有人监视你的数据。 + +例如,你可能不想在云上存储一些敏感文件,因此你可以添加其他受信任的设备来同步并保留这些文件的副本。 + +即使我对它的描述很简单,但它并不像看到的那么简单。如果你感兴趣的话,我建议你阅读[官方 FAQ][7] 来了解它如何工作的。 + +### Syncthing 的特性 + +你可能不希望同步工具中有很多选项。它要可靠地同步文件,应该非常简单。 + +Syncthing 确实非常简单且易于理解。即使这样,如果你想使用它的所有功能,那么也建议你阅读它的[文档][8]。 + +在这里,我将重点介绍 Syncthing 的一些有用特性: + +#### 跨平台支持 + +![Syncthing on Android][9] + +作为开源解决方案,它支持 Windows、Linux 和 macOS。 + +除此之外,它还支持 Android 智能手机。如果你使用的是 iOS 设备,那么你会感到失望。到目前为止,它还没有支持 iOS 的计划。 + +#### 文件版本控制 + +![Syncthing File Versioning][10] + +如果替换或删除了旧文件,那么 Syncthing 会利用各种[文件版本控制方法][11]来存档旧文件。 + +默认情况下,你不会发现它启用。但是,当你创建一个要同步的文件夹时,你将找到将文件版本控制切换为首选方法的选项。 + +#### 易于使用 + +作为 P2P 文件同步工具,它无需高级调整即可使用。 + +但是,它允许你在需要时配置高级设置。 + +#### 安全和隐私 + +即使你不与任何云服务提供商共享数据,仍会有一些连接可能会引起窃听者的注意。因此,Syncthing 使用 TLS 保护通信。 + +此外,它还有可靠的身份验证方法,以确保仅授予只有你允许的设备/连接能够取得同步/读取数据的权限。 + +对于 Android 智能手机,如果你使用 [Orbot 应用][12],你还可以强制将流量通过 Tor。在 Android 中你还有几个不同选择。 + +#### 其他功能 + +![][13] + +当你探索这个工具时,你会注意到可以同步的文件夹数和可同步的设备数没有限制。 + +因此,作为一个有着丰富有用特性的自由开源解决方案,对于在寻找 P2P 同步客户端的 Linux 用户而言是一个令人印象深刻的选择。 + +### 在 Linux 上安装 Syncthing + +你可能无法在官网上找到 .deb 或者 .AppImage 文件。但是,你可在 [Snap 商店][14]中找到 snap 包。如果你好奇,你可以阅读在 Linux 上[使用 snap 应用][15]的文章来开始使用。 + +你可能无法在软件中心找到它(如果你找到了,那它可能不是最新版本)。 + +**注意:**如果你需要一个 GUI 应用而不是浏览器来管理它,它还有一个 [Syncthing-GTK][16]。 + +- [Syncthing][2] + +如果你有基于 Debian 的发行版,你也可以利用终端来安装它,这些说明位于[官方下载页面][17]上。 + +### 我在 Syncthing 方面的体验 + +就个人而言,我把它安装在 Pop!_OS 19.10 上,并在写这篇文章之前用了一会儿。 + +我尝试同步文件夹、删除它们、添加重复文件以查看文件版本控制是否工作,等等。它工作良好。 + +然而,当我尝试同步它到手机(安卓),同步启动有点晚,它不是很快。因此,如果我们可以选择显式强制同步,那会有所帮助。或者,我错过了什么选项吗?如果是的话,请在评论中让我知道。 + +从技术上讲,它使用系统资源来工作,因此,如果你连接了多个设备进行同步,这可能会提高同步速度(上传/下载)。 + +总体而言,它工作良好,但我必须说,你不应该依赖它作为唯一的数据备份方案。 + +### 总结 + +你试过 Syncthing 了吗?如果有的话,你的体验如何?欢迎在下面的评论中分享。 + +此外,如果你知道一些不错的替代品,也请让我知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/syncthing/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://itsfoss.com/install-mega-cloud-storage-linux/ +[2]: https://syncthing.net/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/syncthing-screenshot.jpg?ssl=1 +[4]: https://en.wikipedia.org/wiki/Peer-to-peer +[5]: https://itsfoss.com/cloud-services-linux/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/syncthing-gtk.png?ssl=1 +[7]: https://docs.syncthing.net/users/faq.html +[8]: https://docs.syncthing.net/users/index.html +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/syncthing-android.jpg?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/syncthing-file-versioning.jpg?ssl=1 +[11]: https://docs.syncthing.net/users/versioning.html +[12]: https://play.google.com/store/apps/details?id=org.torproject.android&hl=en_IN +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/syncthing-screenshot1.jpg?ssl=1 +[14]: https://snapcraft.io/syncthing +[15]: https://itsfoss.com/install-snap-linux/ +[16]: https://github.com/syncthing/syncthing-gtk/releases/latest +[17]: https://syncthing.net/downloads/ diff --git a/published/202003/20200123 6 things you should be doing with Emacs.md b/published/202003/20200123 6 things you should be doing with Emacs.md new file mode 100644 index 0000000000..27dfd5bb49 --- /dev/null +++ b/published/202003/20200123 6 things you should be doing with Emacs.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12004-1.html) +[#]: subject: (6 things you should be doing with Emacs) +[#]: via: (https://opensource.com/article/20/1/emacs-cheat-sheet) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +6 件你应该用 Emacs 做的事 +====== + +> 下面六件事情你可能都没有意识到可以在 Emacs 下完成。此外还有我们的新备忘单,拿去,充分利用 Emacs 的功能吧。 + +![](https://img.linux.net.cn/data/attachment/album/202003/17/133738wjj66p2safcpc50z.jpg) + +想象一下使用 Python 的 IDLE 界面来编辑文本。你可以将文件加载到内存中,编辑它们,并保存更改。但是你执行的每个操作都由 Python 函数定义。例如,调用 `upper()` 来让一个单词全部大写,调用 `open` 打开文件,等等。文本文档中的所有内容都是 Python 对象,可以进行相应的操作。从用户的角度来看,这与其他文本编辑器的体验一致。对于 Python 开发人员来说,这是一个丰富的 Python 环境,只需在配置文件中添加几个自定义函数就可以对其进行更改和开发。 + +这就是 [Emacs][2] 对 1958 年的编程语言 [Lisp][3] 所做的事情。在 Emacs 中,运行应用程序的 Lisp 引擎与输入文本之间无缝结合。对 Emacs 来说,一切都是 Lisp 数据,因此一切都可以通过编程进行分析和操作。 + +这造就了一个强大的用户界面(UI)。但是,如果你是 Emacs 的普通用户,你可能对它的能力知之甚少。下面是你可能没有意识到 Emacs 可以做的六件事。 + +### 使用 Tramp 模式进行云端编辑 + +Emacs 早在网络流行化之前就实现了透明的网络编辑能力了,而且时至今日,它仍然提供了最流畅的远程编辑体验。Emacs 中的 [Tramp 模式][4](以前称为 RPC 模式)代表着 “透明的远程(文件)访问,多协议Transparent Remote (file) Access,Multiple Protocol”,这准确说明了它提供的功能:通过最流行的网络协议轻松访问你希望编辑的远程文件。目前最流行、最安全的能用于远程编辑的协议是 [OpenSSH][5],因此 Tramp 使用它作为默认的协议。 + +在 Emacs 22.1 或更高版本中已经包含了 Tramp,因此要使用 Tramp,只需使用 Tramp 语法打开一个文件。在 Emacs 的 “File” 菜单中,选择 “Open File”。当在 Emacs 窗口底部的小缓冲区中出现提示时,使用以下语法输入文件名: + +``` +/ssh:user@example.com:/path/to/file +``` + +如果需要交互式登录,Tramp 会提示你输入密码。但是,Tramp 直接使用 OpenSSH,所以为了避免交互提示,你可以将主机名、用户名和 SSH 密钥路径添加到你的 `~/.ssh/config` 文件。与 Git 一样,Emacs 首先使用你的 SSH 配置,只有在出现错误时才会停下来询问更多信息。 + +Tramp 非常适合编辑并没有放在你的计算机上的文件,它的用户体验与编辑本地文件没有明显的区别。下次,当你 SSH 到服务器启动 Vim 或 Emacs 会话时,请尝试使用 Tramp。 + +### 日历 + +如果你喜欢文本多过图形界面,那么你一定会很高兴地知道,可以使用 Emacs 以纯文本的方式安排你的日程(或生活),而且你依然可以在移动设备上使用开源的 [Org 模式][6]查看器来获得华丽的通知。 + +这个过程需要一些配置,以创建一个方便的方式来与移动设备同步你的日程(我使用 Git,但你可以调用蓝牙、KDE Connect、Nextcloud,或其他文件同步工具),此外你必须在移动设备上安装一个 Org 模式查看器(如 [Orgzly][7])以及 Git 客户程序。但是,一旦你搭建好了这些基础,该流程就会与你常用的(或正在完善的,如果你是新用户)Emacs 工作流完美地集成在一起。你可以在 Emacs 中方便地查阅日程、更新日程,并专注于任务上。议程上的变化将会反映在移动设备上,因此即使在 Emacs 不可用的时候,你也可以保持井然有序。 + +![][8] + +感兴趣了?阅读我的关于[使用 Org mode 和 Git 进行日程安排][9]的逐步指南。 + +### 访问终端 + +有[许多终端模拟器][10]可用。尽管 Emacs 中的 Elisp 终端仿真器不是最强大的通用仿真器,但是它有两个显著的优点: + +1. **打开在 Emacs 缓冲区之中**:我使用 Emacs 的 Elisp shell,因为它在 Emacs 窗口中打开很方便,我经常全屏运行该窗口。这是一个小而重要的优势,只需要输入 `Ctrl+x+o`(或用 Emacs 符号来表示就是 `C-x o`)就能使用终端了,而且它还有一个特别好的地方在于当运行漫长的作业时能够一瞥它的状态报告。 +2. **在没有系统剪贴板的情况下复制和粘贴特别方便**:无论是因为懒惰不愿将手从键盘移动到鼠标,还是因为在远程控制台运行 Emacs 而无法使用鼠标,在 Emacs 中运行终端有时意味着可以从 Emacs 缓冲区中很快地传输数据到 Bash。 + +要尝试 Emacs 终端,输入 `Alt+x`(用 Emacs 符号表示就是 `M-x`),然后输入 `shell`,然后按回车。 + +### 使用 Racket 模式 + +[Racket][11] 是一种激动人心的新兴 Lisp 方言,拥有动态编程环境、GUI 工具包和充满激情的社区。学习 Racket 的默认编辑器是 DrRacket,它的顶部是定义面板,底部是交互面板。使用该设置,用户可以编写影响 Racket 运行时环境的定义。就像旧的 [Logo Turtle][12] 程序,但是有一个终端而不是仅仅一个海龟。 + +![Racket-mode][13] + +*由 PLT 提供的 LGPL 示例代码* + +基于 Lisp 的 Emacs 为资深 Racket 编程人员提供了一个很好的集成开发环境(IDE)。它尚未附带 [Racket 模式][14],但你可以使用 Emacs 包安装程序安装 Racket 模式和辅助扩展。要安装它,按下 `Alt+X`(用 Emacs 符号表示就是 `M-x`),键入 `package-install`,然后按回车。接着输入要安装的包 `racet-mode`,按回车。 + +使用 `M-x racket-mode` 进入 Racket 模式。如果你是 Racket 新手,而对 Lisp 或 Emacs 比较熟悉,可以从这份优秀的[图解 Racket][15] 入手。 + +## 脚本 + +你可能知道,Bash 脚本在自动化和增强 Linux 或 Unix 体验方面很流行。你可能听说过 Python 在这方面也做得很好。但是你知道 Lisp 脚本可以用同样的方式运行吗?有时人们会对 Lisp 到底有多有用感到困惑,因为许多人是通过 Emacs 来了解 Lisp 的,因此有一种潜在的印象,即在 21 世纪运行 Lisp 的惟一方法是在 Emacs 中运行。幸运的是,事实并非如此,Emacs 是一个很好的 IDE,它支持将 Lisp 脚本作为一般的系统可执行文件来运行。 + +除了 Elisp 之外,还有两种流行的现代 Lisp 可以很容易地用来作为独立脚本运行。 + +1. **Racket**:你可以通过在系统上运行 Racket 来提供运行 Racket 脚本所需的运行时支持,或者你可以使用 `raco exe` 产生一个可执行文件。`raco exe` 命令将代码和运行时支持文件一起打包,以创建可执行文件。然后,`raco distribution` 命令将可执行文件打包成可以在其他机器上工作的发行版。Emacs 有许多 Racket 工具,因此在 Emacs 中创建 Racket 文件既简单又有效。 +2. **GNU Guile**:[GNU Guile][16](GNU 通用智能语言扩展GNU Ubiquitous Intelligent Language for Extensions 的缩写)是 [Scheme][17] 编程语言的一个实现,它可以用于为桌面、互联网、终端等创建应用程序和游戏。Emacs 中的 Scheme 扩展众多,使用任何一个扩展来编写 Scheme 都很容易。例如,这里有一个用 Guile 编写的 “Hello world” 脚本: + +``` +#!/usr/bin/guile -s +!# + +(display "hello world") + (newline) +``` + +用 `guile` 编译并允许它: + +``` +$ guile ./hello.scheme +;;; compiling /home/seth/./hello.scheme +;;; compiled [...]/hello.scheme.go +hello world +$ guile ./hello.scheme +hello world +``` + +### 无需 Emacs 允许 Elisp + +Emacs 可以作为 Elisp 的运行环境,但是你无需按照传统印象中的必须打开 Emacs 来运行 Elisp。`--script` 选项可以让你使用 Emacs 作为引擎来执行 Elisp 脚本,而无需运行 Emacs 图形界面(甚至也无需使用终端)。下面这个例子中,`-Q` 选项让 Emacs 忽略 `.emacs` 文件,从而避免由于执行 Elisp 脚本时产生延迟(若你的脚本依赖于 Emacs 配置中的内容,那么请忽略该选项)。 + +``` +emacs -Q --script ~/path/to/script.el +``` + +### 下载 Emacs 备忘录 + +Emacs 许多重要功能都不是只能通过 Emacs 来实现的;Org 模式是 Emacs 扩展也是一种格式标准,流行的 Lisp 方言大多不依赖于具体的应用,我们甚至可以在没有可见或可交互式 Emacs 实例的情况下编写和运行 Elisp。然后若你对为什么模糊代码和数据之间的界限能够引发创新和效率感到好奇的话,那么 Emacs 是一个很棒的工具。 + +幸运的是,现在是 21 世纪,Emacs 有了带有传统菜单的图形界面以及大量的文档,因此学习曲线不再像以前那样。然而,要最大化 Emacs 对你的好处,你需要学习它的快捷键。由于 Emacs 支持的每个任务都是一个 Elisp 函数,Emacs 中的任何功能都可以对应一个快捷键,因此要描述所有这些快捷键是不可能完成的任务。你只要学习使用频率 10 倍于不常用功能的那些快捷键即可。 + +我们汇聚了最常用的 Emacs 快捷键成为一份 Emacs 备忘录以便你查询。将它挂在屏幕附近或办公室墙上,把它作为鼠标垫也行。让它触手可及经常翻阅一下。每次翻两下可以让你获得十倍的学习效率。而且一旦开始编写自己的函数,你一定不会后悔获取了这个免费的备忘录副本的! + +- [这里下载 Emacs 备忘录(需注册)](https://opensource.com/downloads/emacs-cheat-sheet) + +-------------------------------------------------------------------------------- +via: https://opensource.com/article/20/1/emacs-cheat-sheet + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png +[2]: https://www.gnu.org/software/emacs/ +[3]: https://en.wikipedia.org/wiki/Lisp_(programming_language) +[4]: https://www.gnu.org/software/tramp/ +[5]: https://www.openssh.com/ +[6]: https://orgmode.org/ +[7]: https://f-droid.org/en/packages/com.orgzly/ +[8]: https://opensource.com/sites/default/files/uploads/orgzly-agenda.jpg +[9]: https://linux.cn/article-11320-1.html +[10]: https://linux.cn/article-11814-1.html +[11]: http://racket-lang.org/ +[12]: https://en.wikipedia.org/wiki/Logo_(programming_language)#Turtle_and_graphics +[13]: https://opensource.com/sites/default/files/racket-mode.jpg +[14]: https://www.racket-mode.com/ +[15]: https://docs.racket-lang.org/quick/index.html +[16]: https://www.gnu.org/software/guile/ +[17]: https://en.wikipedia.org/wiki/Scheme_(programming_language) diff --git a/published/202003/20200127 Build your own cloud with Fedora 31 and Nextcloud Server.md b/published/202003/20200127 Build your own cloud with Fedora 31 and Nextcloud Server.md new file mode 100644 index 0000000000..295e111690 --- /dev/null +++ b/published/202003/20200127 Build your own cloud with Fedora 31 and Nextcloud Server.md @@ -0,0 +1,222 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11964-1.html) +[#]: subject: (Build your own cloud with Fedora 31 and Nextcloud Server) +[#]: via: (https://fedoramagazine.org/build-your-own-cloud-with-fedora-31-and-nextcloud-server/) +[#]: author: (storyteller https://fedoramagazine.org/author/storyteller/) + +使用 Fedora 31 和 Nextcloud 服务器构建自己的云 +====== + +![][1] + +[Nextcloud][2] 是用于跨多个设备存储和同步数据的软件套件。你可以从 [https://github.com/nextcloud/server][3] 了解有关 Nextcloud 服务器的更多特性信息。 + +本文通过几个简单的步骤演示了如何使用 Fedora 和 Nextcloud 构建个人云。对于本教程,你将需要一台独立计算机或运行 Fedora 31 服务器版的虚拟机,还需要互联网连接。 + +### 步骤 1:预先安装条件 + +在安装和配置 Nextcloud 之前,必须满足一些预先条件。 + +首先,安装 Apache Web 服务器: + +``` +# dnf install httpd +``` + +接下来,安装 PHP 和一些其他模块。确保所安装的 PHP 版本符合 [Nextcloud 的要求][4]: + +``` +# dnf install php php-gd php-mbstring php-intl php-pecl-apcu php-mysqlnd php-pecl-redis php-opcache php-imagick php-zip php-process +``` + +安装 PHP 后,启用并启动 Apache Web 服务器: + +``` +# systemctl enable --now httpd +``` + +接下来,允许 HTTP 流量穿过防火墙: + +``` +# firewall-cmd --permanent --add-service=http +# firewall-cmd --reload +``` + +接下来,安装 MariaDB 服务器和客户端: + +``` +# dnf install mariadb mariadb-server +``` + +然后启用并启动 MariaDB 服务器 + +``` +# systemctl enable --now mariadb +``` + +现在,MariaDB 正在运行,你可以运行 `mysql_secure_installation` 命令来保护它: + +``` +# mysql_secure_installation + +NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL + MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP + CAREFULLY! + +In order to log into MariaDB to secure it, we'll need the +current password for the root user. If you've just installed +MariaDB, and you haven't set the root password yet, the password +will be blank, so you should just press enter here. + +Enter current password for root (enter for none): +OK, successfully used password, moving on... + +Setting the root password ensures that nobody can log into +the MariaDB root user without the proper authorization. + +Set root password? [Y/n] +New password: Your_Password_Here +Re-enter new password: Your_Password_Here + +Password updated successfully! + +Reloading privilege tables... + ... Success! + +By default, a MariaDB installation has an anonymous user, +allowing anyone to log into MariaDB without having to have +a user account created for them. This is intended only for +testing, and to make the installation go a bit smoother. You +should remove them before moving into a production environment. + +Remove anonymous users? [Y/n] + ... Success! + +Normally, root should only be allowed to connect from +'localhost'. This ensures that someone cannot guess at the +root password from the network. + +Disallow root login remotely? [Y/n] + ... Success! + +By default, MariaDB comes with a database named 'test' that +anyone can access. This is also intended only for testing, and +should be removed before moving into a production environment. + +Remove test database and access to it? [Y/n] + + - Dropping test database... + ... Success! + + - Removing privileges on test database... + ... Success! + +Reloading the privilege tables will ensure that all changes +made so far will take effect immediately. + +Reload privilege tables now? [Y/n] + ... Success! + +Cleaning up... + +All done! If you've completed all of the above steps, your +MariaDB installation should now be secure. + +Thanks for using MariaDB! +``` + +接下来,为你的 Nextcloud 实例创建独立的用户和数据库: + +``` +# mysql -p +> create database nextcloud; +> create user 'nc_admin'@'localhost' identified by 'SeCrEt'; +> grant all privileges on nextcloud.* to 'nc_admin'@'localhost'; +> flush privileges; +> exit; +``` + +### 步骤 2:安装 Nextcloud 服务器 + +现在,你已满足 Nextcloud 安装的预先条件,请下载并解压 [Nextcloud 压缩包][5]: + +``` +# wget https://download.nextcloud.com/server/releases/nextcloud-17.0.2.zip +# unzip nextcloud-17.0.2.zip -d /var/www/html/ +``` + +接下来,创建一个数据文件夹,并授予 Apache 对 `nextcloud` 目录树的读写访问权限: + +``` +# mkdir /var/www/html/nextcloud/data +# chown -R apache:apache /var/www/html/nextcloud +``` + +SELinux 必须配置为可与 Nextcloud 一起使用。基本命令如下所示,但在 nexcloud 安装中还有很多其他的命令,发布在这里:[Nextcloud SELinux 配置][6]。 + +``` +# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/config(/.*)?' +# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/apps(/.*)?' +# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/data(/.*)?' +# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/.user.ini' +# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/nextcloud/3rdparty/aws/aws-sdk-php/src/data/logs(/.*)?' +# restorecon -Rv '/var/www/html/nextcloud/' +``` + +### 步骤 3:配置 Nextcloud + +可以使用它的 Web 界面或在命令行配置 Nextcloud。 + +#### 使用 Web 界面 + +在你喜欢的浏览器中,访问 并输入字段: + +![][7] + +#### 使用命令行 + +在命令行中,只需输入以下内容,使用你之前在 MariaDB 中创建的独立 Nextcloud 用户替换相应的值: + +``` +# sudo -u apache php occ maintenance:install --data-dir /var/www/html/nextcloud/data/ --database "mysql" --database-name "nextcloud" --database-user "nc_admin" --database-pass "DB_SeCuRe_PaSsWoRd" --admin-user "admin" --admin-pass "Admin_SeCuRe_PaSsWoRd" +``` + +### 最后几点 + +* 我使用的是 http 协议,但是 Nextcloud 也可以在 https 上运行。我可能会在以后的文章中写一篇有关保护 Nextcloud 的文章。 +* 我禁用了 SELinux,但是如果配置它,你的服务器将更加安全。 +* Nextcloud 的建议 PHP 内存限制为 512M。要更改它,请编辑 `/etc/php.ini` 配置文件中的 `memory_limit` 变量,然后重新启动 httpd 服务。 +* 默认情况下,只能使用 URL 访问 Web 界面。如果要允许使用其他域名访问,[你可编辑 /var/www/html/nextcloud/config/config.php 来进行此操作][8]。`*` 字符可用于绕过域名限制,并允许任何解析为服务器 IP 的 URL 访问。 + + ``` +'trusted_domains' => + array ( + 0 => 'localhost', + 1 => '*', + ), +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/build-your-own-cloud-with-fedora-31-and-nextcloud-server/ + +作者:[storyteller][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/storyteller/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/01/nextcloud-1-816x345.png +[2]: https://nextcloud.com/ +[3]: https://github.com/nextcloud/server#nextcloud-server- +[4]: https://docs.nextcloud.com/server/17/admin_manual/installation/system_requirements.html#server +[5]: https://nextcloud.com/install/#instructions-server +[6]: https://docs.nextcloud.com/server/17/admin_manual/installation/selinux_configuration.html +[7]: https://fedoramagazine.org/wp-content/uploads/2019/11/image.png +[8]: https://help.nextcloud.com/t/adding-a-new-trusted-domain/26 diff --git a/published/202003/20200129 Use Emacs to get social and track your todo list.md b/published/202003/20200129 Use Emacs to get social and track your todo list.md new file mode 100644 index 0000000000..0d7bbc42c5 --- /dev/null +++ b/published/202003/20200129 Use Emacs to get social and track your todo list.md @@ -0,0 +1,163 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11956-1.html) +[#]: subject: (Use Emacs to get social and track your todo list) +[#]: via: (https://opensource.com/article/20/1/emacs-social-track-todo-list) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +使用 Emacs 进行社交并跟踪你的待办事项列表 +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的第十九篇文章中,访问 Twitter、Reddit、 交谈、电子邮件 、RSS 和你的待办事项列表。 + +![](https://img.linux.net.cn/data/attachment/album/202003/04/100911lg2vrv92692b422y.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 使用 Emacs 做(几乎)所有的事情,第 2 部分 + +[昨天][2],我谈到了如何在 Emacs 中读取电子邮件、访问电子邮件地址和显示日历。Emacs 功能繁多,你还可以将它用于 Twitter、交谈、待办事项列表等等! + +![在 Emacs 中处理所有事情][3] + +要完成所有这些,你需要安装一些 Emacs 包。和昨天一样,用 `Meta+x package-manager` 打开 Emacs 包管理器(Meta 键在大多数键盘上是 `Alt`,在 MacOS 上是 `Option`)。然后通过 `i` 选择以下带有的软件包,然后输入 `x` 进行安装: + +``` +nnreddit +todotxt +twittering-mode +``` + +安装之后,按下 `Ctrl+x ctrl+f` 打开 `~/.emacs.d/init.el`,并在 `(custom-set-variables` 行前加上: + +``` +;; Todo.txt +(require 'todotxt) +(setq todotxt-file (expand-file-name "~/.todo/todo.txt")) + +;; Twitter +(require 'twittering-mode) +(setq twittering-use-master-password t) +(setq twittering-icon-mode t) + +;; Python3 for nnreddit +(setq elpy-rpc-python-command "python3") +``` + +按下 `Ctrl+x Ctrl+s` 保存文件,使用 `Ctrl+x Ctrl+c` 退出 Emacs,然后重启 Emacs。 + +#### 使用 twittering-mode 在 Emacs 中发推 + +![Emacs 中的 Twitter][4] + +[Twittering-mode][5] 是 Twitter 最好的 Emacs 接口之一。它几乎支持 Twitter 的所有功能,并且键盘快捷键也易于使用。 + +首先,输入 `Meta+x twit` 来启动 twittering-mode。它会提供一个 URL 并提示你启动浏览器来访问它,你登录该 URL 后就能获得授权令牌。将令牌复制并粘贴到 Emacs 中,你的 Twitter 时间线就会加载了。你可以使用箭头键滚动,使用 `Tab` 从一个项目移动到另一个项目,并按回车访问光标所在的 URL。如果光标在用户名上,按回车将在 web 浏览器中打开时间轴。如果你在一条推文的文本上,按回车将回复该推文。你可以用 `u` 创建一个新的推文,用 `Ctrl+c+Enter` 转发一些内容,然后用 `d` 发送一条即时消息——它打开的对话框中有关于如何发送、取消和缩短 URL 的说明。 + +按 `V` 会打开一个提示让你跳转到其他时间线。输入 `:mentions` 打开你的提及。输入 `:home` 打开你的主时间线,输入用户名将进入该用户的时间线。最后,按 `q` 会退出 twittering-mode 并关闭窗口。 + +twitter-mode 还有更多功能,我鼓励你阅读它 GitHub 页面上的[完整功能列表][6]。 + +#### 在 Emacs 上使用 Todotxt.el 追踪你的待办事项 + +![Emacs 中的 todo.txt][7] + +[Todotxt.el][8] 是一个很棒的 [todo.txt][9] 待办列表管理器接口。它的快捷键几乎无所不包。 + +输入 `Meta+x todotxt` 启动它将加载 `todotxt-file` 变量中指定的 `todo.txt` 文件(本文的第一部分中设置了该文件)。在 `todo.txt` 的缓冲区(窗口),你可以按 `a` 添加新任务并和按 `c` 标记它已被完成。你还可以使用 `r` 设置优先级,并使用 `t` 添加项目和上下文。完成事项后只需要按下 `A` 即可将任务移如 `done.txt`。你可以使用 `/` 过滤列表,也可以使用 `l` 刷新完整列表。同样,你可以按 `q` 退出。 + +#### 在 Emacs 中使用 ERC 进行交谈 + +![使用 ERC 与人交谈 ][10] + +Vim 的缺点之一是很难用它与人交谈。另一方面,Emacs 则将 [ERC][11] 客户端内置到默认发行版中。使用 `Meta+x ERC` 启动 ERC,系统将提示你输入服务器、用户名和密码。你可以使用几天前介绍设置 [BitlBee][12] 时使用的相同信息:服务器为 `localhost`,端口为 `6667`,相同用户名,无需密码。 + +ERC 使用起来与其他 IRC 客户端一样。每个频道单独一个缓冲区(窗口),你可以使用 `Ctrl+x ctrl+b` 进行频道间切换,这也可以在 Emacs 中的其他缓冲区之间进行切换。`/quit` 命令将退出 ERC。 + +#### 使用 Gnus 阅读电子邮件,Reddit 和 RSS + +![Mail,Reddit,and RSS feeds with Gnus][13] + +我相信昨天在我提及在 Emacs 中阅读邮件时,许多 Emacs 的老用户会问,“怎么没有 [Gnus][14] 呢?” + +这个疑问很合理。Gnus 是一个内置在 Emacs 中的邮件和新闻阅读器,尽管它这个邮件阅读器不支持以 [Notmuch][15] 作为搜索引擎。但是,如果你将其配置来阅读 Reddit 和 RSS feed(稍后你将这样做),那么同时使用它来阅读邮件是个聪明的选择。 + +Gnus 是为阅读 Usenet 新闻而创建的,并从此发展而来。因此,它的很多外观和感觉(以及术语)看起来很像 Usenet 的新闻阅读器。 + +Gnus 以 `~/.gnus` 作为自己的配置文件。(该配置也可以包含在 `~/.emacs.d/init.el` 中)。使用 `Ctrl+x Ctrl+f` 打开 `~/.gnus`,并添加以下内容: + + +``` +;; Required packages +(require 'nnir) +(require 'nnrss) + +;; Primary Mailbox +(setq gnus-select-method +      '(nnmaildir "Local" +                  (directory "~/Maildir") +                  (nnir-search-engine notmuch) +      )) +(add-to-list 'gnus-secondary-select-methods +             '(nnreddit "")) +``` + +用 `Ctrl+x Ctrl+s` 保存文件。这分配置告诉 Gnus 从 `~/Maildir` 这个本地邮箱中读取邮件作为主源(参见 `gnus-select-method` 变量),并使用 [nnreddit][16] 插件添加辅源(`gnus-secondary-select-methods` 变量)。你还可以定义多个辅助源,包括 Usenet 新闻(nntp)、IMAP (nnimap)、mbox(nnmbox)和虚拟集合(nnvirtual)。你可以在 [Gnus 手册][17] 中了解更多有关所有选项的信息。 + +保存文件后,使用 `Meta+x Gnus` 启动 Gnus。第一次运行将在 Python 虚拟环境中安装 [Reddit 终端查看器][18],Gnus 通过它获取 Reddit 上的文章。然后它会启动浏览器来登录 Reddit。之后,它会扫描并加载你订阅的 Reddit 群组。你会看到一个有新邮件的邮件夹列表和一个有新内容的看板列表。在任一列表上按回车将加载该组中的消息列表。你可以使用箭头键导航并按回车加载和读取消息。在查看消息列表时,按 `q` 将返回到前一个视图,从主窗口按 `q` 将退出 Gnus。在阅读 Reddit 群组时,`a` 会创建一条新消息;在邮件组中,`m` 创建一个新的电子邮件;并且在任何一个视图中按 `r` 回复邮件。 + +你还可以向 Gnus 接口中添加 RSS 流,并像阅读邮件和新闻组一样阅读它们。要添加 RSS 流,输入 `G+R` 并填写 RSS 流的 URL。会有提示让你输入 RSS 的标题和描述,这些信息可以从流中提取出来并填充进去。现在输入 `g` 来检查新消息(这将检查所有组中的新消息)。阅读 RSS 流 就像阅读 Reddit 群组和邮件一样,它们使用相同的快捷键。 + +Gnus 中有*很多*功能,还有大量的键组合。[Gnus 参考卡][19]为每个视图列出了所有这些键组合(以非常小的字体显示在 5 页纸上)。 + +#### 使用 nyan-mode 查看位置 + +最后,你可能会一些截屏底部注意到 [Nyan cat][20]。这是 [nyan-mode][21],它指示了你在缓冲区中的位置,因此当你接近文档或缓冲区的底部时,它会变长。你可以使用包管理器安装它,并在 `~/.emacs.d/init.el` 中使用以下代码进行设置: + +``` +;; Nyan Cat +(setq nyan-wavy-trail t) +(setq nyan-bar-length 20) +(nyan-mode) +``` + +### Emacs 的基本功能 + +这只是 Emacs 所有功能的皮毛。Emacs *非常*强大,是我用来提高工作效率的必要工具之一,无论我是在追踪待办事项、阅读和回复邮件、编辑文本,还是与朋友和同事交流我都用它。这需要一点时间来适应,但是一旦你习惯了,它就会成为你桌面上最有用的工具之一。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/emacs-social-track-todo-list + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [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/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ (Team communication, chat) +[2]: https://linux.cn/article-11932-1.html +[3]: https://opensource.com/sites/default/files/uploads/productivity_19-1.png (All the things with Emacs) +[4]: https://opensource.com/sites/default/files/uploads/productivity_19-2.png (Twitter in Emacs) +[5]: https://github.com/hayamiz/twittering-mode +[6]: https://github.com/hayamiz/twittering-mode#features +[7]: https://opensource.com/sites/default/files/uploads/productivity_19-3.png (todo.txt in emacs) +[8]: https://github.com/rpdillon/todotxt.el +[9]: http://todotxt.org/ +[10]: https://opensource.com/sites/default/files/uploads/productivity_19-4.png (Chatting with erc) +[11]: https://www.gnu.org/software/emacs/manual/html_mono/erc.html +[12]: https://linux.cn/article-11856-1.html +[13]: https://opensource.com/sites/default/files/uploads/productivity_19-5.png (Mail, Reddit, and RSS feeds with Gnus) +[14]: https://www.gnus.org/ +[15]: https://linux.cn/article-11807-1.html +[16]: https://github.com/dickmao/nnreddit +[17]: https://www.gnus.org/manual/gnus.html +[18]: https://pypi.org/project/rtv/ +[19]: https://www.gnu.org/software/emacs/refcards/pdf/gnus-refcard.pdf +[20]: http://www.nyan.cat/ +[21]: https://github.com/TeMPOraL/nyan-mode diff --git a/published/202003/20200130 4 open source productivity tools on my wishlist.md b/published/202003/20200130 4 open source productivity tools on my wishlist.md new file mode 100644 index 0000000000..533247844b --- /dev/null +++ b/published/202003/20200130 4 open source productivity tools on my wishlist.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11961-1.html) +[#]: subject: (4 open source productivity tools on my wishlist) +[#]: via: (https://opensource.com/article/20/1/open-source-productivity-tools) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +我的愿望清单上的 4 种开源生产力工具 +====== + +> 在 2020 年用开源实现更高生产力的二十种方式的最后一篇文章中,了解开源世界还需要什么。 + +![](https://img.linux.net.cn/data/attachment/album/202003/05/100642k52u7oydcwnc1c2w.jpg) + +去年,我在 19 天里给你介绍了 19 个新(对你而言)的生产力工具。今年,我换了一种方式:使用你在使用或者还没使用的工具,构建一个使你可以在新一年更加高效的环境。 + +### 然而… + +在搜索生产力应用程序时,我找不到想要的所有应用,而且几乎总是会丢失一些读者与我分享的精彩内容。 因此,当我结束本系列文章时,是时候[再次][2]谈论我在本年度系列文章中未能涵盖的一些主题。 + +![Desktop with Joplin, Emacs, and Firefox][3] + +#### 在 Vim 中聊天 + +我试过了。我真的非常、非常想能够在 Vim 中聊天,但我做不到。我找到的一个软件包 [VimIRC.vim][4] 一直就工作不起来,我试了几天也没用。我探索的另一个选项是 [Irc it][5],这需要我付出更多的[努力去设置][6],超过了我正常可以付出的耐心或时间。我尝试过了,也确实做到了,但对于同处于相同境地的 Vim 用户,对不起,我无法帮到你。 + +#### Org 模式 + +![Org Mode in Emacs][7] + +我喜欢 [Org 模式][8],并且每天都使用它。关于 Org 模式我可以滔滔不绝的说上几天。它提供了基本的[任务跟踪][9];谷歌[日历][10]同步和 [CalFW][11] 集成;富文本文档、网站和演示文稿;链接到任何事物;等等、等等…… + +我希望你会在 2020 年从我这里收到更多有关 Org 模式的信息,因为它真的很酷。 + +#### 图形用户界面程序 + +在 2019 年的生产力系列中,我共享了很多图形用户界面程序,而今年几乎都是命令行应用程序。有一些很棒的图形程序可以帮助解决我今年谈论的一些问题,例如可以使用 Maildir 邮箱的[邮件][12]程序、用于读取本地日历文件的日历程序、[天气][13]应用程序等等。我甚至尝试了几项对我而言新奇的事物,看它们是否适合这个主题。除了 [twin][14] 之外,我没有感觉到有什么图形用户界面程序是新颖的(对我而言)或值得注意的(同样对我而言)是今年要写的。至于…… + +#### 移动应用程序 + +越来越多的人将平板电脑(有时与笔记本电脑结合使用)作为主要设备。我将手机用于大多数社交媒体和即时消息传递,并且经常使用平板电脑(好的,老实说,好几个平板电脑)来阅读或浏览网络。可以肯定的是,并不是没有开源移动应用程序,但是它们与我今年的主题不符。开源和移动应用程序正在发生很多变化,我正在仔细地寻找可以帮助我在手机和平板电脑上提高工作效率的事物。 + +### 该你了 + +非常感谢你阅读今年的系列文章。请你发表评论,告诉我错过的或需要在 2021 年看到的内容。正如我在 [Productivity Alchemy][15] 播客上所说:“哥们,记着:要保持生产力!” + +### 本系列汇总 + +1. [使用 Syncthing 在多个设备间同步文件](https://linux.cn/article-11793-1.html) +2. [使用 Stow 管理多台机器配置](https://linux.cn/article-11796-1.html) +3. [使用 OfflineIMAP 同步邮件](https://linux.cn/article-11804-1.html) +4. [使用 Notmuch 组织你的邮件](https://linux.cn/article-11807-1.html) +5. [使用 khal 和 vdirsyncer 组织和同步你的日历](https://linux.cn/article-11812-1.html) +6. [用于联系人管理的三个开源工具](https://linux.cn/article-11834-1.html) +7. [开始使用开源待办事项清单管理器](https://linux.cn/article-11835-1.html) +8. [使用这个 Python 程序记录你的活动](https://linux.cn/article-11846-1.html) +9. [一个通过 IRC 管理所有聊天的开源聊天工具](https://linux.cn/article-11856-1.html) +10. [使用这个 Twitter 客户端在 Linux 终端中发推特](https://linux.cn/article-11858-1.html) +11. [在 Linux 终端中阅读 Reddit](https://linux.cn/article-11869-1.html) +12. [使用此开源工具在一起收取你的 RSS 订阅源和播客](https://linux.cn/article-11876-1.html) +13. [使用这个开源工具获取本地天气预报](https://linux.cn/article-11879-1.html) +14. [使用此开源窗口环境一次运行多个控制台](https://linux.cn/article-11892-1.html) +15. [使用 tmux 创建你的梦想主控台](https://linux.cn/article-11900-1.html) +16. [使用 Vim 发送邮件和检查日历](https://linux.cn/article-11908-1.html) +17. [使用 Vim 管理任务列表和访问 Reddit 和 Twitter](https://linux.cn/article-11912-1.html) +18. [使用 Emacs 发送电子邮件和检查日历](https://linux.cn/article-11932-1.html) +19. [使用 Emacs 进行社交并跟踪你的待办事项列表](https://linux.cn/article-11956-1.html) +20. [我的愿望清单上的 4 种开源生产力工具](https://linux.cn/article-11961-1.html) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/open-source-productivity-tools + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [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/world_hands_diversity.png?itok=zm4EDxgE (Two diverse hands holding a globe) +[2]: https://opensource.com/article/19/1/productivity-tool-wish-list +[3]: https://opensource.com/sites/default/files/uploads/productivity_20-1.png (Desktop with Joplin, Emacs, and Firefox) +[4]: https://github.com/vim-scripts/VimIRC.vim +[5]: https://tools.suckless.org/ii/ +[6]: https://www.reddit.com/r/vim/comments/48t7ws/vim_ii_irc_client_xpost_runixporn/d0macnl/ +[7]: https://opensource.com/sites/default/files/uploads/productivity_20-2.png (Org Mode in Emacs) +[8]: https://orgmode.org/ +[9]: https://opensource.com/article/20/1/open-source-to-do-list +[10]: https://opensource.com/article/20/1/open-source-calendar +[11]: https://github.com/kiwanami/emacs-calfw +[12]: https://opensource.com/article/20/1/organize-email-notmuch +[13]: https://opensource.com/article/20/1/open-source-weather-forecast +[14]: https://github.com/cosmos72/twin +[15]: https://productivityalchemy.com diff --git a/published/202003/20200204 DevOps vs Agile- What-s the difference.md b/published/202003/20200204 DevOps vs Agile- What-s the difference.md new file mode 100644 index 0000000000..e221cbc775 --- /dev/null +++ b/published/202003/20200204 DevOps vs Agile- What-s the difference.md @@ -0,0 +1,160 @@ +[#]: collector: "lujun9972" +[#]: translator: "messon007" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12031-1.html" +[#]: subject: "DevOps vs Agile: What's the difference?" +[#]: via: "https://opensource.com/article/20/2/devops-vs-agile" +[#]: author: "Taz Brown https://opensource.com/users/heronthecli" + +DevOps 和敏捷:究竟有什么区别? +====== + +> 两者之间的区别在于开发完毕之后发生的事情。 + +![](https://img.linux.net.cn/data/attachment/album/202003/23/200609w2rlzrjjhpf2hzsq.jpg) + +早期,软件开发并没有特定的管理流程。随后出现了[瀑布开发流程][2]Waterfall,它提出软件开发活动可以用开发和构建应用所耗费的时间来定义。 + +那时候,由于在开发流程中没有审查环节和权衡考虑,常常需要花费很长的时间来开发、测试和部署软件。交付的软件也是带有缺陷和 Bug 的质量较差的软件,而且交付时间也不满足要求。那时候软件项目管理的重点是长期而拖沓的计划。 + +瀑布流程与[三重约束模型][3]triple constraint model相关,三重约束模型也称为项目管理三角形project management triangle。三角形的每一个边代表项目管理三要素的一个要素: **范围、时间和成本**。正如 [Angelo Baretta 写到][4],三重约束模型“认为成本是时间和范围的函数,这三个约束以一种确定的、可预测的方式相互作用。……如果我们想缩短时间表(时间),就必须增加成本。如果我们想增加范围,就必须增加成本或时间。” + +### 从瀑布流程过渡到敏捷开发 + +瀑布流程来源于生产和工程领域,这些领域适合线性化的流程:正如房屋封顶之前需要先盖好支撑墙。相似地,软件开发问题被认为可以通过提前做好计划来解决。从头到尾,开发流程均由路线图清晰地定义,沿着路线图就可以得到最终交付的产品。 + +最终,瀑布模型被认为对软件开发是不利的而且违反人的直觉,因为通常直到开发流程的最后才能体现出项目的价值,这导致许多项目最终都以失败告终。而且,在项目结束前客户看不到任何可以工作的软件。 + +敏捷Agile采用了一种不同的方法,它抛弃了规划整个项目,承诺估计的时间点,简单的遵循计划。与瀑布流程相反,它假设和拥抱不确定性。它的理念是以响应变化代替讨论过去,它认为变更是客户需求的一部分。 + +### 敏捷价值观 + +敏捷由敏捷宣言Agile Manifesto代言,敏捷宣言定义了 [12 条原则][5](LCTT 译注:此处没有采用本文原本的简略句式,而是摘录了来自敏捷软件开发宣言官方的[中文译本][14]): + +1. 我们最重要的目标,是通过持续不断地及早交付有价值的软件使客户满意。 +2. 欣然面对需求变化,即使在开发后期也一样。 +3. 经常交付可工作的软件,相隔几星期或一两个月,倾向于采取较短的周期。 +4. 业务人员和开发人员必须相互合作,项目中的每一天都不例外。 +5. 激发个体的斗志,以他们为核心搭建项目。提供所需的环境和支援,辅以信任,从而达成目标。 +6. 面对面沟通是传递信息的最佳的也是效率最高的方法。 +7. 可工作的软件是进度的首要度量标准。 +8. 敏捷流程倡导可持续的开发,责任人、开发人员和用户要能够共同维持其步调稳定延续。 +9. 坚持不懈地追求技术卓越和良好设计,敏捷能力由此增强。 +10. 以简洁为本,它是极力减少不必要工作量的艺术。 +11. 最好的架构,需求和设计出自自组织团队 +12. 团队定期地反思如何能提高成效,并依此调整自身的举止表现。 + +敏捷的四个[核心价值观][6]是(LCTT 译注:[此处译文][15]同样来自敏捷软件开发宣言官方): + +* **个体和互动** 高于流程和工具 +* **工作的软件** 高于详尽的文档 +* **客户合作** 高于合同谈判 +* **响应变化** 高于遵循计划 + +这与瀑布流程死板的计划风格相反。在敏捷流程中,客户是开发团队的一员,而不仅仅是在项目开始时参与项目需求的定义,在项目结束时验收最终的产品。客户帮忙团队完成[验收标准][7],并在整个过程中保持投入。另外,敏捷需要整个组织的变化和持续的改进。开发团队和其他团队一起合作,包括项目管理团队和测试团队。做什么和计划什么时候做由指定的角色领导,并由整个团队同意。 + +### 敏捷软件开发 + +敏捷软件开发需要自适应的规划、演进式的开发和交付。许多软件开发方法、框架和实践遵从敏捷的理念,包括: + +* Scrum +* 看板Kanban(可视化工作流) +* 极限编程Xtreme Programming(XP) +* 精益方法Lean +* DevOps +* 特性驱动开发Feature-Driven Development(FDD) +* 测试驱动开发Test-Driven Development(TDD) +* 水晶方法Crystal +* 动态系统开发方法Dynamic Systems Development Method(DSDM) +* 自适应软件开发Adaptive Software Development(ASD) + +所有这些已经被单独用于或一起用于开发和部署软件。最常用的是 [Scrum][8]、看板(或 Scrumban)和 DevOps。 + +[Scrum][9] 是一个框架,采用该框架的团队通常由一个 Scrum 教练、产品经理和开发人员组成,该团队以跨职能、自主的工作方式运作,能够加快软件交付速度从而给客户带来巨大的商业价值。其关注点是[较小增量][10]的快速迭代。 + +[看板][11] 是一个敏捷框架,有时也叫工作流管理系统,它能帮助团队可视化他们的工作从而最大化效率(因而变得敏捷)。看板通常由数字或物理展示板来呈现。团队的工作在展示板上随着进度而移动,例如从未启动到进行中,一直到测试中、已完成。看板使得每个团队成员可以随时查看到所有工作的状态。 + +### DevOps 价值观 + +DevOps 是一种文化,是一种思维状态,是一种软件开发的方式或者基础设施的方式,也是一种构建和部署软件和应用的方式。它假设开发和运维之间没有隔阂,他们一起合作,没有矛盾。 + +DevOps 基于其它两个领域的实践: 精益和敏捷。DevOps 不是一个公司内的岗位或角色;它是一个组织或团队对持续交付、持续部署和持续集成的坚持不懈的追求。[Gene Kim][12](Phoenix 项目和 Unicorn 项目的作者)认为,有三种方式定义 DevOps 的理念: + +* 第一种: 流程原则 +* 第二种: 反馈原则 +* 第三种: 持续学习原则 + +### DevOps 软件开发 + +DevOps 不会凭空产生;它是一种灵活的实践,它的本质是一种关于软件开发和 IT 或基础设施实施的共享文化和思维方式。 + +当你想到自动化、云、微服务时,你会想到 DevOps。在一次[访谈][13]中,《加速构建和扩张高性能技术组织》的作者 Nicol Forsgren、Jez Humble 和 Gene Kim 这样解释到: + +> * 软件交付能力很重要,它极大地影响到组织的成果,例如利润、市场份额、质量、客户满意度以及组织战略目标的达成。 +> * 优秀的团队能达到很高的交付量、稳定性和质量;他们并没有为了获得这些属性而进行取舍。 +> * 你可以通过实施精益、敏捷和 DevOps 中的实践来提升能力。 +> * 实施这些实践和能力也会影响你的组织文化,并且会进一步对你的软件交付能力和组织能力产生有益的提升。 +> * 懂得怎样改进能力需要做很多工作。 + +### DevOps 和敏捷的对比 + +DevOps 和敏捷有相似性,但是它们不完全相同,一些人认为 DevOps 比敏捷更好。为了避免造成混淆,深入地了解它们是很重要的。 + +#### 相似之处 + +* 毫无疑问,两者都是软件开发技术。 +* 敏捷已经存在了 20 多年,DevOps 是最近才出现的。 +* 两者都追求软件的快速开发,它们的理念都基于怎样在不伤害客户或运维利益的情况下快速开发出软件。 + +#### 不同之处 + +* 两者的差异在于软件开发完成后发生的事情。 + * 在 DevOps 和敏捷中,都有软件开发、测试和部署的阶段。然而,敏捷流程在这三个阶段之后会终止。相反,DevOps 包括后续持续的运维。因此,DevOps 会持续的监控软件运行情况和进行持续的开发。 +* 敏捷中,不同的人负责软件的开发、测试和部署。而 DevOps 工程角色负责所有活动,开发即运维,运维即开发。 +* DevOps 更关注于削减成本,而敏捷则是精益和减少浪费的代名词,侧重于像敏捷项目会计和最小可行产品的概念。 +* 敏捷专注于并体现了经验主义(适应、透明和检查),而不是预测性措施。 + +敏捷 | DevOps +--- | --- +从客户得到反馈 | 从自己得到反馈 +较小的发布周期 | 较小的发布周期,立即反馈 +聚焦于速度 | 聚焦于速度和自动化 +对业务不是最好 | 对业务最好 + +### 总结 + +敏捷和 DevOps 是截然不同的,尽管它们的相似之处使人们认为它们是相同的。这对敏捷和 DevOps 都是一种伤害。 + +根据我作为一名敏捷专家的经验,我发现对于组织和团队从高层次上了解敏捷和 DevOps 是什么,以及它们如何帮助团队更高效地工作,更快地交付高质量产品从而提高客户满意度非常有价值。 + +敏捷和 DevOps 绝不是对抗性的(或至少没有这个意图)。在敏捷革命中,它们更像是盟友而不是敌人。敏捷和 DevOps 可以相互协作一致对外,因此可以在相同的场合共存。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/devops-vs-agile + +作者:[Taz Brown][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/heronthecli +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard.png?itok=kBeRTFL1 "Pair programming" +[2]: http://www.agilenutshell.com/agile_vs_waterfall +[3]: https://en.wikipedia.org/wiki/Project_management_triangle +[4]: https://www.pmi.org/learning/library/triple-constraint-erroneous-useless-value-8024 +[5]: http://agilemanifesto.org/principles.html +[6]: https://agilemanifesto.org/ +[7]: https://www.productplan.com/glossary/acceptance-criteria/ +[8]: https://opensource.com/article/19/8/scrum-vs-kanban +[9]: https://www.scrum.org/ +[10]: https://www.scrum.org/resources/what-is-an-increment +[11]: https://www.atlassian.com/agile/kanban +[12]: https://itrevolution.com/the-unicorn-project/ +[13]: https://www.infoq.com/articles/book-review-accelerate/ +[14]: http://agilemanifesto.org/iso/zhchs/principles.html +[15]: http://agilemanifesto.org/iso/zhchs/manifesto.html diff --git a/published/202003/20200211 Basic kubectl and Helm commands for beginners.md b/published/202003/20200211 Basic kubectl and Helm commands for beginners.md new file mode 100644 index 0000000000..5cb41e2c38 --- /dev/null +++ b/published/202003/20200211 Basic kubectl and Helm commands for beginners.md @@ -0,0 +1,198 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12007-1.html) +[#]: subject: (Basic kubectl and Helm commands for beginners) +[#]: via: (https://opensource.com/article/20/2/kubectl-helm-commands) +[#]: author: (Jessica Cherry https://opensource.com/users/jrepka) + +适用于初学者的基本 kubectl 和 Helm 命令 +====== + +> 去杂货店“采购”这些命令,你需要用这些 Kubernetes 工具来入门。 + +![](https://img.linux.net.cn/data/attachment/album/202003/18/113120adp34myy90eb944b.jpg) + +最近,我丈夫告诉我他即将要去参加一个工作面试,面试时他需要在计算机上运行一些基本命令。他对这场面试感到焦虑,但是对于他来说,学习和记住事情的最好方法是将不了解的事物比喻为非常熟悉的事物。因为我们的谈话是在我逛杂货店试图决定当晚要烹饪的食物之后进行的,所以这启发我用一次去杂货店的行程来介绍 `kubectl` 和 `helm` 命令。 + +[Helm][2](“舵轮”)是在 Kubernetes(来自希腊语,意思是“舵手” 或 “领航员”)中管理应用程序的工具。你可以轻松地使用你的应用程序信息来部署“海图chart”,从而可以在你的 Kubernetes 环境中几分钟之内让它们就绪并预配置好。在学习新知识时,查看示例的“海图”以了解其用法总是很有帮助的,因此,如果有时间,请查看这些成型的“[海图][3]”。(LCTT 译注:Kubernetes 生态中大量使用了和航海有关的比喻,因此本文在翻译时也采用了这些比喻) + +[kubectl][4] 是与 Kubernetes 环境交互的命令行界面,允许你配置和管理集群。它需要一些配置才能在环境中工作,因此请仔细阅读其[文档][5]以了解你需要做什么。 + +我会在示例中使用命名空间,你可以在我的文章《[Kubernetes 命名空间入门][6]》中了解它。 + +现在我们已经准备好了,让我们开始 `kubectl`和 `helm` 基本命令的购物之旅! + +### 用 Helm 列出清单 + +你去商店之前要做的第一件事是什么?好吧,如果你做事有条理,会创建一个“清单”。同样,这是我将解释的第一个基本的 Helm 命令。 + +在一个用 Helm 部署的应用程序中,`list` 命令提供有关应用程序当前版本的详细信息。在此示例中,我有一个已部署的应用程序:Jenkins CI/CD 应用程序。运行基本的 `list` 命令总是会显示默认的命名空间。由于我没有在默认的命名空间中部署任何内容,因此不会显示任何内容: + +``` +$helm list +NAME    NAMESPACE    REVISION    UPDATED    STATUS    CHART    APP VERSION +``` + +但是,如果运行带有额外标志的命令,则会显示我的应用程序和信息: + +``` +$helm list --all-namespaces +NAME     NAMESPACE  REVISION  UPDATED                   STATUS      CHART           APP  VERSION +jenkins  jenkins        1         2020-01-18 16:18:07 EST   deployed    jenkins-1.9.4   lts +``` + +最后,我可以指示 `list` 命令只检查我想从中获取信息的命名空间: + +``` +$helm list --namespace jenkins +NAME     NAMESPACE  REVISION  UPDATED                   STATUS    CHART          APP VERSION +jenkins    jenkins      1              2020-01-18 16:18:07 EST  deployed  jenkins-1.9.4  lts     +``` + +现在我有了一个清单,并且知道该清单上有什么,我可以使用 `get` 命令来“获取”我的物品!我会从 Kubernetes 集群开始,看看我能从中获取到什么? + +### 用 Kubectl 获取物品 + +`kubectl get` 命令提供了有关 Kubernetes 中许多事物的信息,包括“吊舱Pod”、节点和命名空间。同样,如果没有指定命名空间标志,就会使用默认的命名空间。首先,我获取集群中的命名空间以查看正在运行的命名空间: + +``` +$kubectl get namespaces +NAME             STATUS   AGE +default          Active   53m +jenkins          Active   44m +kube-node-lease  Active   53m +kube-public      Active   53m +kube-system      Active   53m +``` + +现在我已经知道了在我的环境中运行的有哪些命名空间了,接下来获取节点并查看有多少个节点正在运行: + +``` +$kubectl get nodes +NAME       STATUS   ROLES       AGE   VERSION +minikube   Ready    master  55m   v1.16.2 +``` + +我有一个节点正在运行,这主要是因为我的 Minikube 运行在一台小型服务器上。要得到在我的这一个节点上运行的“吊舱”可以这样: + +``` +$kubectl get pods +No resources found in default namespace. +``` + +啊哦,它是空的。我将通过以下方式获取 Jenkins 命名空间中的内容: + +``` +$kubectl get pods --namespace jenkins +NAME                      READY  STATUS   RESTARTS  AGE +jenkins-7fc688c874-mh7gv  1/1    Running  0         40m +``` + +好消息!这里发现了一个“吊舱”,它还没有重新启动过,已运行了 40 分钟了。好的,如今我知道“吊舱”已经装好,所以我想看看用 Helm 命令可以得到什么。 + +### 用 Helm 获取信息 + +`helm get` 命令稍微复杂一点,因为这个“获取”命令所需要的不仅仅是一个应用程序名称,而且你可以从应用程序中请求多个内容。我会从获取用于制作该应用程序的值开始,然后展示“获取全部”的操作结果的片段,该操作将提供与该应用程序相关的所有数据。 + +``` +$helm get values jenkins -n jenkins +USER-SUPPLIED VALUES: +null +``` + +由于我只安装了最小限度的稳定版,因此配置没有更改。如果我运行“获取全部”命令,我将得到所有的“海图”: + +``` +$helm get all jenkins -n jenkins +``` + +![output from helm get all command][7] + +这会产生大量数据,因此我始终建议保留一份 Helm “海图”的副本,以便你可以查看“海图”中的模板。我还创建自己的值来了解自己所拥有的。 + +现在,我把所有的商品都放在购物车中了,我会检查一下“描述”它们包含什么的标签。这些示例仅与 `kubectl` 命令有关,它们描述了我通过 Helm 部署的内容。 + +### 用 kubectl 查看描述 + +正如我使用“获取”命令(该命令可以描述 Kubernetes 中的几乎所有内容)所做的那样,我将示例限定到命名空间、“吊舱”和节点上。由于我知道它们每一个是什么,因此这很容易。 + +``` +$kubectl describe ns jenkins +Name:           jenkins +Labels:         <none> +Annotations:  <none> +Status:         Active +No resource quota. +No resource limits. +``` + +我可以看到我的命名空间的名称,并且它是活动的,没有资源或限额限制。 + +`describe pods` 命令会产生大量信息,因此我这里提供的是一小段输出。如果你在不使用“吊舱”名称的情况下运行该命令,它将返回名称空间中所有“吊舱”的信息,这可能会很麻烦。因此,请确保在此命令中始终包含“吊舱”名称。例如: + +``` +$kubectl describe pods jenkins-7fc688c874-mh7gv --namespace jenkins +``` + +![output of kubectl-describe-pods][8] + +这会提供容器的状态、管理方式、标签以及“吊舱”中所使用的镜像(还有很多其它信息)。没有在这个简化过的输出中包括的数据有:在 Helm 配置值文件中应用的各种条件下的资源请求和限制、初始化容器和存储卷信息。如果你的应用程序由于资源不足而崩溃,或者是一个需要运行前置脚本进行配置的初始配置容器,或者生成不应该存储于纯文本 YAML 文件中的隐藏密码,则此数据很有用。 + +最后,我将使用 `describe node` 命令,当然,它是用来描述节点的。由于本示例只有一个名为 Minikube 的示例,因此我将使用这个名字。如果你的环境中有多个节点,则必须包含你想查找的的节点名称。 + +与“吊舱”一样,这个节点的命令会产生大量数据,因此我将仅包括输出片段。 + +``` +$kubectl describe node minikube +``` + +![output of kubectl describe node][9] + +注意,`describe node` 是更重要的基本命令之一。如此图所示,该命令返回统计信息,该信息指示节点何时资源用尽,并且该数据非常适合在需要扩展时(如果你的环境中没有自动扩展)向你发出警报。此输出片段中未包含的其它内容包括:对所有资源和限制的请求所占的百分比,以及资源的使用期限和分配(例如,对于我的应用程序而言)。 + +### 买单 + +使用这些命令,我完成了“购物”并得到了我想要的一切。希望这些基本命令也能在你使用 Kubernetes 的日常工作中提供帮助。 + +我鼓励你经常使用命令行并学习“帮助”部分中的速记标志,你可以通过运行以下命令来查看这些标志: + +``` +$helm --help +``` + +或 + +``` +$kubectl -h +``` + +### 花生酱和果冻 + +有些东西像花生酱和果冻一样混在一起。Helm 和 `kubectl` 就有点像那样交错在一起。 + +我经常在自己的环境中使用这些工具。因为它们在很多地方都有很多相似之处,所以在使用其中一个之后,我通常需要跟进另一个。例如,我可以进行 Helm 部署,并使用 `kubectl` 观察它是否失败。一起试试它们,看看它们能为你做什么。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/kubectl-helm-commands + +作者:[Jessica Cherry][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_os_rh2x.png?itok=jbRfXinl (A person working.) +[2]: https://helm.sh/ +[3]: https://github.com/helm/charts/tree/master/stable +[4]: https://kubernetes.io/docs/reference/kubectl/kubectl/ +[5]: https://kubernetes.io/docs/reference/kubectl/overview/ +[6]: https://linux.cn/article-11749-1.html +[7]: https://opensource.com/sites/default/files/uploads/helm-get-all.png (output from helm get all command) +[8]: https://opensource.com/sites/default/files/uploads/kubectl-describe-pods.png (output of kubectl-describe-pods) +[9]: https://opensource.com/sites/default/files/uploads/kubectl-describe-node.png (output of kubectl describe node) diff --git a/published/202003/20200212 Extend the life of your SSD drive with fstrim.md b/published/202003/20200212 Extend the life of your SSD drive with fstrim.md new file mode 100644 index 0000000000..dfb2969cf9 --- /dev/null +++ b/published/202003/20200212 Extend the life of your SSD drive with fstrim.md @@ -0,0 +1,152 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11959-1.html) +[#]: subject: (Extend the life of your SSD drive with fstrim) +[#]: via: (https://opensource.com/article/20/2/trim-solid-state-storage-linux) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +在 Linux 下使用 fstrim 延长 SSD 驱动器的寿命 +====== + +> 这个新的系统服务可以使你的生活更轻松。 + +![](https://img.linux.net.cn/data/attachment/album/202003/04/121625sl380ga10g56d33h.jpg) + +在过去的十年中,固态驱动器(SSD)带来了一种管理存储的新方法。与上一代的转盘产品相比,SSD 具有无声、更冷却的操作和更快的接口规格等优点。当然,新技术带来了新的维护和管理方法。SSD 具有一种称为 TRIM 的功能。从本质上讲,这是一种用于回收设备上未使用的块的方法,该块可能先前已被写入,但不再包含有效数据,因此可以返回到通用存储池以供重用。Opensource.com 的 Don Watkins 首先在其 2017 年的文章《[Linux 固态驱动器:为 SSD 启用 TRIM][2]》中介绍过 TRIM 的内容。 + +如果你一直在 Linux 系统上使用此功能,则你可能熟悉下面描述的两种方法。 + +### 老的方式 + +#### 丢弃选项 + +我最初使用 `mount` 命令的 `discard` 选项启用了此功能。每个文件系统的配置都放在 `/etc/fstab` 文件中。 + +``` +# cat /etc/fstab +UUID=3453g54-6628-2346-8123435f  /home  xfs  defaults,discard   0 0 +``` + +丢弃选项可启用自动的在线 TRIM。由于可能会对性能造成负面影响,最近关于这是否是最佳方法一直存在争议。使用此选项会在每次将新数据写入驱动器时启动 TRIM。这可能会引入其他磁盘活动,从而影响存储性能。 + +#### Cron 作业 + +我从 `fstab` 文件中删除了丢弃选项。然后,我创建了一个 cron 作业来按计划调用该命令。 + +``` +# crontab -l +@midnight /usr/bin/trim +``` + +这是我最近在 Ubuntu Linux 系统上使用的方法,直到我了解到另一种方法。 + +### 一个新的 TRIM 服务 + +我最近发现有一个用于 TRIM 的 systemd 服务。Fedora 在版本 30 中将其[引入][3],尽管默认情况下在版本 30 和 31 中未启用它,但计划在版本 32 中使用它。如果你使用的是 Fedora 工作站 31,并且你想要开始使用此功能,可以非常轻松地启用它。我还将在下面向你展示如何对其进行测试。该服务并非 Fedora 独有的服务。它是否存在及其地位将因发行版而异。 + +#### 测试 + +我喜欢先进行测试,以更好地了解幕后情况。我通过打开终端并发出配置服务调用的命令来执行此操作。 + +``` +/usr/sbin/fstrim --fstab --verbose --quiet +``` + +`fstrim` 的 `-help` 参数将描述这些信息和其他参数。 + +``` +$ sudo /usr/sbin/fstrim --help + +Usage: + fstrim [options] + +Discard unused blocks on a mounted filesystem. + +Options: + -a, --all trim all supported mounted filesystems + -A, --fstab trim all supported mounted filesystems from /etc/fstab + -o, --offset the offset in bytes to start discarding from + -l, --length the number of bytes to discard + -m, --minimum the minimum extent length to discard + -v, --verbose print number of discarded bytes + --quiet suppress error messages + -n, --dry-run does everything, but trim + + -h, --help display this help + -V, --version display version +``` + +因此,现在我可以看到这个 systemd 服务已配置为在我的 `/etc/fstab` 文件中的所有受支持的挂载文件系统上运行该修剪操作(`-fstab`),并打印出所丢弃的字节数(`-verbose`),但是抑制了任何可能会发生的错误消息(`–quiet`)。了解这些选项对测试很有帮助。例如,我可以从最安全的方法开始,即空运行。我还将去掉 `-quiet` 参数,以便确定驱动器设置是否发生任何错误。 + +``` +$ sudo /usr/sbin/fstrim --fstab --verbose --dry-run +``` + +这就会显示 `fstrim` 命令根据在 `/etc/fstab` 文件中找到的文件系统要执行的操作。 + +``` +$ sudo /usr/sbin/fstrim --fstab --verbose +``` + +现在,这会将 TRIM 操作发送到驱动器,并报告每个文件系统中丢弃的字节数。以下是我最近在新的 NVME SSD 上全新安装 Fedora 之后的示例。 + +``` +/home: 291.5 GiB (313011310592 bytes) trimmed on /dev/mapper/wkst-home +/boot/efi: 579.2 MiB (607301632 bytes) trimmed on /dev/nvme0n1p1 +/boot: 787.5 MiB (825778176 bytes) trimmed on /dev/nvme0n1p2 +/: 60.7 GiB (65154805760 bytes) trimmed on /dev/mapper/wkst-root +``` + +#### 启用 + +Fedora Linux 实现了一个计划每周运行它的 systemd 计时器服务。要检查其是否存在及当前状态,请运行 `systemctl status`。 + +``` +$ sudo systemctl status fstrim.timer +``` + +现在,启用该服务。 + +``` +$ sudo systemctl enable fstrim.timer +``` + +#### 验证 + +然后,你可以通过列出所有计时器来验证该计时器是否已启用。 + +``` +$ sudo systemctl list-timers --all +``` + +会显示出下列行,表明 `fstrim.timer` 存在。注意,该计时器实际上激活了 `fstrim.service` 服务。这是实际调用 `fstrim` 的地方。与时间相关的字段显示为 `n/a`,因为该服务已启用且尚未运行。 + +``` +NEXT   LEFT    LAST   PASSED   UNIT           ACTIVATES +n/a    n/a     n/a    n/a      fstrim.timer   fstrim.service +``` + +### 结论 + +该服务似乎是在驱动器上运行 TRIM 的最佳方法。这比必须创建自己的 crontab 条目来调用 `fstrim` 命令要简单得多。不必编辑 `fstab` 文件也更安全。观察固态存储技术的发展很有趣,并且我很高兴看到 Linux 似乎正在朝着标准且安全的方向实现它。 + +在本文中,学习了固态驱动器与传统硬盘驱动器有何不同以及它的含义... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/trim-solid-state-storage-linux + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_keyboard_desktop.png?itok=I2nGw78_ (Linux keys on the keyboard for a desktop computer) +[2]: https://linux.cn/article-8177-1.html +[3]: https://fedoraproject.org/wiki/Changes/EnableFSTrimTimer (Fedora Project WIKI: Changes/EnableFSTrimTimer) diff --git a/published/202003/20200214 How to set up your own fast, private open source mesh network.md b/published/202003/20200214 How to set up your own fast, private open source mesh network.md new file mode 100644 index 0000000000..dbf4bfc481 --- /dev/null +++ b/published/202003/20200214 How to set up your own fast, private open source mesh network.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11968-1.html) +[#]: subject: (How to set up your own fast, private open source mesh network) +[#]: via: (https://opensource.com/article/20/2/mesh-network-freemesh) +[#]: author: (Spencer Thomason https://opensource.com/users/spencerthomason) + +如何建立自己的快速、私有的开源网状网络(mesh) +====== + +> 只需要不到 10 分钟的安装时间,就可以用 FreeMesh 搭建一个经济实惠、性能卓越、尊重隐私的网格系统。 + +![](https://img.linux.net.cn/data/attachment/album/202003/06/234848jaga52a0wx05w0f0.jpg) + +[FreeMesh][2] 系统有望为大众带来完全开源的网状网络mesh network(LCTT 译注:也称之为“多跳网络”)。我最近有机会对它进行了测试;它安装迅速,性能非常好 —— 特别是相对它的价格而言。 + +### 为什么要网格化和开源? + +使用开源的原因很简单:隐私。有了 FreeMesh,你的数据就是你自己的。它不会跟踪或收集数据。不相信吗?毕竟,你可以轻松检查 —— 它是开源的!而其它大型高科技企业集团提供的一些流行的网状网络解决方案,你是否相信它们会保护你的数据? + +另一个重要因素:更新。FreeMesh 表示,它将致力于定期发布安全性和性能更新。从现在起到 10 年后呢?使用开源解决方案,你可以根据需要自由地更新产品。 + +那么为什么要用网状网络呢?在网状网络中,多个无线路由器一起工作以广播单个超大型的无线网络。网状网络中的每个路由器都可与其他路由器智能地通信,以便为你的数据提供最佳的“路径”。FreeMesh 网站上的以下图片突出显示了使用单个无线路由器和网状网络之间的区别。红色网络表示单个无线路由器,绿色网络是网状网络。 + +![单路由器网络] [3] + +![网状网络] [4] + +### 采购设备 + +要开始使用 FreeMesh,请[订购套件][5]。它提供两种套件:标准套件和 4G LTE。 + +顾名思义,4G LTE 套件支持蜂窝数据连接。此功能在消费级网络领域非常罕见,但对某些人来说非常有用。你可以在提供电源和电池的任何地方建立具有完整的快速故障转移功能的便携式网状网络。 + +FreeMesh 套件带有一个主路由器和两个节点。路由器和节点使用 802.11ac、802.11r 和 802.11s 标准。随附的固件运行定制版本的 [OpenWrt] [6],这是嵌入式设备的 Linux 发行版。 + +FreeMesh 路由器的一些规格非常好: + +* CPU:双核 880MHz MediaTek MT7621AT(双核/四线程!) +* 内存:DDR3 512MB +* 接口:1 个 GbE WAN、4 个 GbE LAN、1 个 USB 2.0 端口、1 个 microSD 卡插槽、1 个 SIM 插槽 +* 天线:2 个 5dBi 2.4GHz、2 个 5dBi 5GHz、2 个 3dBi 3G/4G(内置) +* 4G LTE 调制解调器:LTE 4 类模块,下行 150Mbps/上行 50Mbps + +### 设置 + +设置很容易,FreeMesh 的 [README][7] 提供了简单的说明和图表。首先首先设置主路由器。然后按照以下简单步骤操作: + +1、将第一个节点(蓝色 WAN 端口)连接到主路由器(黄色 LAN 端口)。 + +![FreeMesh 设置步骤 1][8] + +2、等待约 30 至 60 秒。设置完成后,节点的 LED 将会闪烁。 + +![FreeMesh 设置步骤 2][9] + +3、将节点移到另一个位置。 + +仅此而已!节点不需要手动设置。你只需将它们插入主路由器,其余的工作就完成了。你可以以相同的方式添加更多节点;只需重复上述步骤即可。 + +### 功能 + +FreeMesh 是开箱即用的,它由 OpenWRT 和 LuCI 组合而成。它具有你期望路由器提供的所有功能。是否要安装新功能或软件包?SSH 连入并开始魔改! + +![FreeMesh 网络上的实时负载][10] + +![FreeMesh 网络概览][11] + +![OpenWrt 状态报告][12] + +### 性能如何 + +设置完 FreeMesh 系统后,我将节点移动到了房屋周围的各个地方。我使用 [iPerf][13] 测试带宽,它达到了约 150Mbps。WiFi 可能会受到许多环境变量的影响,因此你的结果可能会有所不同。节点与主路由器之间的距离在带宽中也有很大的影响。 + +但是,网状网络的真正优势不是高峰速度,而是整个空间的平均速度要好得多。即使在我家很远的地方,我仍然能够用流媒体播放视频并正常工作。我甚至可以在后院工作。在出门之前,我只是将一个节点重新放在窗口前面而已。 + +### 结论 + +FreeMesh 确实令人信服。它以简单、开源的形式为你提供高性价比和隐私。 + +以我的经验,设置非常容易,而且足够快。覆盖范围非常好,远远超过了任何单路由器环境。你可以随意魔改和定制 FreeMesh 设置,但是我觉得没有必要。它提供了我需要的一切。 + +如果你正在寻找价格可承受、性能良好且尊重隐私的网格系统,且该系统可以在不到 10 分钟的时间内安装完毕,你可以考虑一下 FreeMesh。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/mesh-network-freemesh + +作者:[Spencer Thomason][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/spencerthomason +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-networking.png?itok=fHmulI9p (people on top of a connected globe) +[2]: https://freemeshwireless.com/ +[3]: https://opensource.com/sites/default/files/uploads/singlerouternetwork.png (Single-router network) +[4]: https://opensource.com/sites/default/files/uploads/meshnetwork.png (Mesh network) +[5]: https://freemeshwireless.com/#pricing +[6]: https://openwrt.org/ +[7]: https://gitlab.com/slthomason/freemesh/-/blob/master/README.md +[8]: https://opensource.com/sites/default/files/uploads/connecttorouter.png (FreeMesh setup step 1) +[9]: https://opensource.com/sites/default/files/uploads/setupcomplete.png (FreeMesh setup step 2) +[10]: https://opensource.com/sites/default/files/uploads/freemeshrealtimeload.png (Real-time load on FreeMesh network) +[11]: https://opensource.com/sites/default/files/uploads/freemeshwirelessoverview.png (Overview of FreeMesh network) +[12]: https://opensource.com/sites/default/files/uploads/openwrt.png (OpenWrt status report) +[13]: https://opensource.com/article/20/1/internet-speed-tests diff --git a/published/202003/20200214 Linux is our love language.md b/published/202003/20200214 Linux is our love language.md new file mode 100644 index 0000000000..293568e366 --- /dev/null +++ b/published/202003/20200214 Linux is our love language.md @@ -0,0 +1,80 @@ +[#]: collector: (lujun9972) +[#]: translator: (sndnvaps) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12022-1.html) +[#]: subject: (Linux is our love language) +[#]: via: (https://opensource.com/article/20/2/linux-love-language) +[#]: author: (Christopher Cherry https://opensource.com/users/chcherry) + +学习 Linux 是我们的爱情语言 +====== + +> 当一个妻子教丈夫一些新技能的时候,他们都学到了比期待更多的东西。 + +![](https://img.linux.net.cn/data/attachment/album/202003/22/163819clzuy77dc4d7q8zu.jpg) + +2019 年是我们 Cherry 家学习的一年。我是一个喜欢学习新技术的高级软件工程师,并把学到的内容一起教给了我的丈夫 Chris。通过教给他一些我学到的东西,并让他全程经历我的技术演练文章,我帮助 Chris 学习到了新技术,使他能够将自己的职业生涯更深入地转向技术领域。而我学习到了新的方法,使我的演练和培训材料更易于让读者理解。 + +在这篇文章中,我们来讨论一下我们各自和彼此学习到了什么东西,然后探讨这对于我们的未来有何影响。 + +### 向学生的提问 + +**Jess:** Chris,是什么导致你想深入学习我的领域的技能呢? + +**Chris:** 主要目的是为了让我事业更进一步。作为一个网络工程师的经历告诉我,现在的网络专家已经不像以前一样有价值了,我必须掌握更多的知识。由于网络经常被认为是造成这些天程序中断或出错的原因,我想从开发人员的角度了解更多关于编写应用程序的知识,以便于了解它们如何依赖网络资源。 + +**Jess:** 我首先教你什么内容?你从中学到什么? + +**Chris:** 首先是从学习除此安装 Linux 系统开始的,之后又安装了 [Ansible][2]。只要硬件兼容,我用过的每一个 Linux 发行版都很容易安装,但可能会出现个别不兼容的情况。这就意味着我有时候第一手学习到的是如何解决系统安装过程的最初 5 分钟出现的问题了(这个我最喜欢了)。Ansible 给了一个我学习使用软件管理器来安装程序的理由。当程序安装完成后,通过查看 yum 安装的程序,我快速了解了程序管理器是如何处理程序的依赖项的,因此,用 Python 编写的 Ansible 能够在我的系统运行。自此之后,我开始使用 Ansible 来安装各种各样的程序。 + +**Jessica:** 你喜欢我这种教学方式不? + +**Chris:** 我们一开始有过争吵,直到我们弄清楚了我喜欢的学习方式,你也知道了应该怎样为我提供最好的学习方式。在一开始的时候,我很难跟上你讲的内容。例如,当你说“一个码头工人集装箱”的时候,我完全不知道你在讲什么。比较早的时候,我的回答就是“这是一个集装箱”,然而当时这对我来说,完全没有意义。当你对这些内容进行一些更深入的讲解后,才让学习更有趣。 + +**Jess:** 老实说,这对我来说也是一个重要的教训。在你之前,我从来没有教过在这个技术领域知识比我少的人,所以你帮助我认识到我需要解释更多细节。我也得说声谢谢。 + +当你通过这几个学习步骤的时候,你觉得我的这篇测试文章怎样呢? + +**Chris:** 就我个人而言,我认为这很容易,但我错了。在我主要学习的内容中,比如你[介绍的Vagrant][3],它在不同的 Linux 发行版间的变化比我想像的要多。操作系统的变化会影响设置的方式、运行都要求和特定的命令。这看起来比我用的网络设备变化更大。这让我花费更多的精力去查看这些说明是对应我的系统还是其它的系统(有时候很难知道)。在这学习路上,我似乎碰到很多问题。 + +**Jess:** 我每天都会遇到各种各样的问题,所以对我来说日常就是用各种方法解决各种问题。 + +### 向老师的提问 + +**Chris:** Jess,你将来教我的方式会有所改变吗? + +**Jess:** 我想让你像我一样读多一些书。通过翻阅书籍来学习新技术。每天起床后一小时和睡觉前一小时我都会看书,花费一个星期左右我就能看一到两本书。我也会创建为期两周的任务计划来实践我从书本中学习到的技能。这是除了我一天中第一个小时在喝大量咖啡时读到的科技文章之外的。当我考虑到你的职业发展目标的时候,我认为除了我们谈到的优秀博客文章和文章之外,书籍是一个重要的元素。我觉得我的阅读量使我保持进步,如果你也这么做了,你也会很快赶上我的。 + +**Chris:** 那么学生有没有教过老师呢? + +**Jess:** 我在你那里学习到耐心。举个例子,当你完成了安装 Ansible 的时候,我问你下一步要怎样操作的时候。你直接回复我,“不知道”,这不是我想让你学习到的内容。所以我改变了策略,现在在逐步安装任何组件之前,我们将详细讨论你想要实现的目标。当我们在写 Vagrant 文章的时候,我们一起进行相应的演示操作,我以创建它时就牢记目标,因此我们就有一些需要马上实现的目标。 + +这实际上对我在工作中的培训方式产生了巨大的改变。现在我在大家学习的过程中会问更多问题,并更多地进行手把手讲解。我更愿意坐下来仔细检查,确保有人明白我在说什么和我们在做什么。这是我之前从来没有做过的。 + +### 我们一起学到了什么 + +做为一对夫妇,在这一年的技术合作中我们的技术都有所增长。 + +**Chris:** 我对自己学到的东西感到震惊。通过一年课程学习,我认识了新操作系统、如何使用 API、使用 Ansible 部署 Web 应用和使用 Vagrant 启动虚拟机器。我还学习到了文档可以让生活变得更好,所以我也会尝试去写一写。然而,在这个工作领域,操作并不总是被记录在案,所以我学会了准备好处理棘手的问题,并记录如何解决它们。 + +**Jess:** 除了我在教你中学到的知识外,我还专注于学习 Kubernetes 在云环境中的应用知识。这包括部署策略、Kubernetes API 的复杂度、创建我自己的容器,并对环境进行加密处理。我还节省了探索的时间:研究了 serverless 的代码、AI 模型、Python 和以图形方式显示热图。对于我来说,这一年也很充足。 + +我们下一个目标是什么?现在还不知道,但我可以向你保证,我们将会继续进行分享它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/linux-love-language + +作者:[Christopher Cherry][a] +选题:[lujun9972][b] +译者:[sndnvaps](https://github.com/sndnvaps) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/chcherry +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/red-love-heart-alone-stone-path.jpg?itok=O3q1nEVz (红心 "你不是孤单的") +[2]: https://opensource.com/resources/what-ansible +[3]: https://opensource.com/resources/vagrant diff --git a/published/202003/20200214 PHP Development on Fedora with Eclipse.md b/published/202003/20200214 PHP Development on Fedora with Eclipse.md new file mode 100644 index 0000000000..d373722c0e --- /dev/null +++ b/published/202003/20200214 PHP Development on Fedora with Eclipse.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11967-1.html) +[#]: subject: (PHP Development on Fedora with Eclipse) +[#]: via: (https://fedoramagazine.org/php-development-on-fedora-with-eclipse/) +[#]: author: (Mehdi Haghgoo https://fedoramagazine.org/author/powergame/) + +使用 Eclipse 在 Fedora 上进行 PHP 开发 +====== + +![][1] + +[Eclipse][2] 是由 Eclipse 基金会开发的功能全面的自由开源 IDE。它诞生于 2001 年。你可以在此 IDE 中编写各种程序,从 C/C++ 和 Java 到 PHP,乃至于 Python、HTML、JavaScript、Kotlin 等等。 + +### 安装 + +该软件可从 Fedora 的官方仓库中获得。要安装它,请用: + +``` +sudo dnf install eclipse +``` + +这将安装基本的 IDE 和 Eclipse 平台,能让你开发 Java 应用。为了将 PHP 开发支持添加到 IDE,请运行以下命令: + +``` +sudo dnf install eclipse-pdt +``` + +这将安装 PHP 开发工具,如 PHP 项目向导、PHP 服务器配置,composer 支持等。 + +### 功能 + +该 IDE 有许多使 PHP 开发更加容易的功能。例如,它有全面的项目向导(你可以在其中为新项目配置许多选项)。它还有如 composer 支持、调试支持、浏览器、终端等内置功能。 + +### 示例项目 + +现在已经安装了 IDE,让我们创建一个简单的 PHP 项目。进入 “File →New → Project”。在出现的对话框中,选择 “PHP project”。输入项目的名称。你可能还需要更改其他一些选项,例如更改项目的默认位置,启用 JavaScript 以及更改 PHP 版本。请看以下截图。 + +![Create A New PHP Project in Eclipse][3] + +你可以单击 “Finish” 按钮创建项目,或按 “Next” 配置其他选项,例如添加包含和构建路径。在大多数情况下,你无需更改这些设置。 + +创建项目后,右键单击项目文件夹,然后选择 “New→PHP File” 将新的 PHP 文件添加到项目。在本教程中,我将其命名为 `index.php`,这是每个 PHP 项目中公认的默认文件。 + +![add a new PHP file][4] + +接着在新文件中添加代码。 + +![Demo PHP code][5] + +在上面的例子中,我在同一页面上使用了 CSS、JavaScript 和 PHP 标记,主要是为了展示 IDE 能够支持所有这些标记。 + +页面完成后,你可以将文件移至 Web 服务器文档根目录或在项目目录中创建一个 PHP 开发服务器来查看输出。 + +借助 Eclipse 中的内置终端,我们可以直接在 IDE 中启动 PHP 开发服务器。只需单击工具栏上的终端图标(![Terminal Icon][6]),然后单击 “OK”。在新终端中,进入项目目录,然后运行以下命令: + +``` +php -S localhost:8080 -t . index.php +``` + +![Terminal output][7] + +现在,打开浏览器并进入 。如果按照说明正确完成了所有操作,并且代码没有错误,那么你将在浏览器中看到 PHP 脚本的输出。 + +![PHP output in Fedora][8] + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/php-development-on-fedora-with-eclipse/ + +作者:[Mehdi Haghgoo][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/powergame/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/02/php-eclipse-816x346.png +[2]: https://projects.eclipse.org/projects/eclipse +[3]: https://fedoramagazine.org/wp-content/uploads/2020/02/Screenshot-from-2020-02-07-01-58-39.png +[4]: https://fedoramagazine.org/wp-content/uploads/2020/02/Screenshot-from-2020-02-07-02-02-05-1024x576.png +[5]: https://fedoramagazine.org/wp-content/uploads/2020/02/code-1024x916.png +[6]: https://fedoramagazine.org/wp-content/uploads/2020/02/Screenshot-from-2020-02-07-03-50-05.png +[7]: https://fedoramagazine.org/wp-content/uploads/2020/02/terminal-1024x239.png +[8]: https://fedoramagazine.org/wp-content/uploads/2020/02/output.png diff --git a/published/202003/20200219 Basic Vim Commands You Need to Know to Work in Vim Editor.md b/published/202003/20200219 Basic Vim Commands You Need to Know to Work in Vim Editor.md new file mode 100644 index 0000000000..2a6b8e91d7 --- /dev/null +++ b/published/202003/20200219 Basic Vim Commands You Need to Know to Work in Vim Editor.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (mengxinayan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12053-1.html) +[#]: subject: (Basic Vim Commands You Need to Know to Work in Vim Editor) +[#]: via: (https://www.2daygeek.com/basic-vim-commands-cheat-sheet-quick-start-guide/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +必知必会的 Vim 编辑器基础命令 +====== + +如果你是一名系统管理员或者开发者,当你在终端工作时有时会需要编辑一个文件。在 Linux 系统中有几种文件编辑器,你可以根据需求选择合适的文件编辑器。在这里,我想推荐 Vim 编辑器。 + +### 为什么推荐 Vim 编辑器 + +相对于创建新文件,你更多是修改已经存在的文件。在这种情况下,Vim 快捷键可以有效地满足你的需求。 + +下列文章可以帮助你了解对文件和目录的操作。 + +- [Linux 基础:对文件和目录进行操作的 Linux 和 Unix 命令][1] +- [在 Linux 中查看不同文件格式的 10 种方法][2] + +### 什么是 Vim + +Vim 是被 Linux 管理员和开发者广泛使用的最流行和功能强大的编辑器之一。它可以通过高度的自定义配置来提高文本编辑效率。它是在众多 Unix 默认安装的 Vi 编辑器的升级版。 + +Vim 通常被称为“程序员的编辑器”,但并不限于此,它也可用于编辑任何类型的文件。它具有许多功能,例如:多次撤销、多窗口和缓冲区、语法高亮、命令行编辑、文件名补全、可视选择等等。你可以使用 `:help` 命令来获取在线帮助。 + +### 理解 Vim 的模式 + +Vim 有两种模式,详细介绍如下: + +**命令模式:** 当启动 Vim 编辑器后,默认处在命令模式下。你可以在文件中移动并且修改内容,剪切、复制和粘贴文件的一部分,同时发出命令执行更多操作(按 `ESC` 键进入命令模式) + +**插入模式:** 插入模式用于在给定的文档位置插入文本(按 `i` 键进入插入模式) + +### 我如何知道我正使用哪种 Vim 模式呢? + +如果你正在使用插入模式,你会在编辑器的底部看到 `INSERT`。如果编辑器底部没有显示任何内容,或者在编辑器底部显示了文件名,则处于 “命令模式”。 + +### 命令模式下的光标移动 + +Vim 快捷键允许你使用不同的方式来移动光标: + + * `G` – 跳转到文件最后一行 + * `gg` – 跳转到文件首行 + * `$` – 跳转到行末尾 + * `0`(数字 0) – 跳转到行开头 + * `w` – 跳转到下一个单词的开始(单词的分隔符可以是空格或其他符号) + * `W` – 跳转到下一个单词的开始(单词的分隔符只能是空格) + * `b` – 跳转到下一个单词的末尾(单词的分隔符可以是空格或其他符号) + * `B` – 跳转到下一个单词的末尾(单词的分隔符只能是空格) + + * `PgDn` 键 – 向下移动一页 + * `PgUp` 键 – 向上移动一页 + * `Ctrl+d` – 向下移动半页 + * `Ctrl+u` – 向上移动半页 + +### 插入模式:插入文字 + +下面的 Vim 快捷键允许你根据需要在光标的不同位置插入内容。 + + * `i` – 在光标之前插入 + * `a` – 在光标之后插入 + * `I` – 在光标所在行的开头插入。当光标位于行中间时,这个键很有用 + * `A` – 在光标所在行的末尾插入。 + * `o` – 在光标所在行的下面插入新行 + * `O` – 在光标所在行的上面插入新行 + * `ea` – 在单词的末尾插入 + +### 拷贝、粘贴和删除一行 + + * `yy` – 复制一行 + * `p` / `P` – 将内容粘贴到光标之后 / 之前 + * `dd` – 删除一行 + * `dw` – 删除一个单词 + +### 在 Vim 中搜索和替换匹配的模式 + + * `/模式` – 向后搜索给定的模式 + * `?模式` – 向前搜索给定的模式 + * `n` – 向后重复搜索之前给定的模式 + * `N` – 向前重复搜索之前给定的模式 + * `:%s/旧模式/新模式/g` – 将文件中所有的旧模式替换为新模式 + * `:s/旧模式/新模式/g` – 将当前行中所有的旧模式替换为新模式 + * `:%s/旧模式/新模式/gc` – 逐个询问是否文件中的旧模式替换为新模式 + +### 如何在 Vim 编辑器中跳转到特定行 + +你可以根据需求以两种方式达到该目的,如果你不知道行号,建议采用第一种方法。 + +通过打开文件并运行下面的命令来显示行号 + +``` +:set number +``` + +当你设置好显示行号后,按 `:n` 跳转到相应的行号。例如,如果你想跳转到第 15 行,请输入: + +``` +:15 +``` + +如果你已经知道行号,请使用以下方法在打开文件时直接跳转到相应行。例如,如果在打开文件时直接跳转到 20 行,请输入下面的命令: + +``` +$ vim +20 [文件名] +``` + +### 撤销操作/恢复上一次操作/重复上一次操作 + + * `u` – 撤销更改 + * `Ctrl+r` – 恢复更改 + * `.` – 重复上一条命令 + +### 保存和退出 Vim + + * `:w` – 保存更改但不退出 vim + * `:wq` – 写并退出 + * `:q!` – 强制退出 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/basic-vim-commands-cheat-sheet-quick-start-guide/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[萌新阿岩](https://github.com/mengxinayan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-basic-commands-file-directory-manipulation/ +[2]: https://www.2daygeek.com/unix-linux-command-to-view-file/ diff --git a/published/202003/20200219 Here Are The Most Beautiful Linux Distributions in 2020.md b/published/202003/20200219 Here Are The Most Beautiful Linux Distributions in 2020.md new file mode 100644 index 0000000000..b4eafe90dd --- /dev/null +++ b/published/202003/20200219 Here Are The Most Beautiful Linux Distributions in 2020.md @@ -0,0 +1,195 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12046-1.html) +[#]: subject: (Here Are The Most Beautiful Linux Distributions in 2020) +[#]: via: (https://itsfoss.com/beautiful-linux-distributions/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +我眼中的 2020 年最漂亮的 Linux 发行版 +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/28/103619o7gog737dg7fi9ii.jpg) + +以我的观点,每个人都该有一个 Linux 发行版,不管他们喜欢的是哪种,或者想用来做什么。 + +要是你刚刚开始使用 Linux,你可以使用这些[最适合于初学者的 Linux 发行版][1];要是你是从 Windows 投奔过来的,你可以使用这些[看起来像 Windows 一样的 Linux 发行版][2];要是你有台旧电脑想让它发挥余热,你可以使用这些[轻量级 Linux 发行版][3]。当然,无论你是在[企业][36]还是 [SOHO][37],Linux 还可以用于[个人工作][38]、[开发][39],以及作为[服务器][40]或[嵌入式系统][41]的操作系统,它可以用于[各种用途][42]。 + +但在这个列表中,我们只关注最漂亮的 Linux 发行版。 + +### 7 款最漂亮的 Linux 发行版 + +![][4] + +等一下!Linux 发行版有漂亮这个分类吗?显然,你可以自己定制任何发行版的外观,并使用[主题][5]和[图标][6]之类的来使其看起来更漂亮。 + +你说得对。但是在这里,我所说的是指不需要用户进行任何调整和自定义工作就看起来很漂亮的发行版。这些发行版提供友好的顺滑、流畅、开箱即用的桌面体验。 + +**注意:** 以下列表排名不分前后,名单纯属个人喜好,请使劲喷你的观点。 + +#### 1、elementary OS + +![][7] + +首先踏上 T 台的 elementary OS 是最漂亮的 Linux 发行版(如果非得说的话,可以是“之一”)。它靠着一种类似 macOS 的外观,而为 Linux 用户提供了出色的体验。如果你已经适应了 macOS,那么你在使用 elementary OS 时就不会有任何不适感。 + +此外,elementary OS 是基于 Ubuntu 的,因此,你可以很容易地找到大量的可以满足你的需要的应用程序。 + +不仅仅是外观和感受,elementary OS 总是努力地引入一些重要的变化。因此,你可以期待用户体验会随着每次更新而获得提升。 + +- [elementary OS][8] + +#### 2、深度 Linux + +![][9] + +深度 Linux(或许现在该叫统信 UOS?)是另外一个漂亮的 Linux 发行版,它起源于 Debian 的稳定版分支。对于某些人来说,其动画效果(外观和感受)可能有点过度了,虽然它看起来很漂亮。 + +它有它自己特色的 Deepin 桌面环境(DDE),蕴藏了多种基本功能,从而提供尽可能好的用户体验。它可能不像其它发行版的用户界面,但你很容易就可以习惯。 + +我个人对深度中的控制中心和特色配色方案印象深刻。你可以自己尝试一下,我觉得值得一试。 + +- [深度][10] + +#### 3、Pop!_OS + +![][11] + +Pop!_OS 在提供了纯净的 [GNOME][12] 体验的同事,也成功地在 Ubuntu 之上打造出了一个出色的用户界面。 + +这正是我的最爱,我使用它作为我的主要桌面系统。Pop!_OS 既不浮华,也没有一些花哨的动画。然而,它通过图标和主题的完美组合做到了最好,同时从技术角度提升了用户体验。 + +我不想发起一场 [Ubuntu 和 Pop!\_OS][13] 之间的争论,但是如果你已经习惯了 Ubuntu,Pop!_OS 可能是一个可能更好的用户体验的绝佳选择。 + +- [Pop!_OS][14] + +#### 4、Manjaro Linux + +![][15] + +Manjaro Linux 是一个基于 [Arch][16] 的 Linux 发行版。虽然[安装 Arch Linux][17] 是一件稍微复杂的工作,而 Manjaro 则提供了一种更舒适、更流畅的 Arch 体验。 + +它提供各种各样的[桌面环境版本][18],在下载时可供选择。不管你选择哪一个,你都仍然有足够的选择权来自定义外观和感觉或布局。 + +对我来说,这样一个开箱即用的、基于 Arch 的发行版看起来棒极了,你值得拥有! + +- [Manjaro Linux][19] + +#### 5、KDE Neon + +![][20] + +[KDE Neon][21] 是为那些想要采用简化的设计方案而仍可以得到丰富体验的用户所准备的。 + +它是一个基于 Ubuntu 的轻量级 Linux 发行版。顾名思义,它采用 KDE Plasma 桌面,看起来精美绝伦。 + +KDE Neon 给予你最新的、最好的 KDE Plasma 桌面及 KDE 应用程序。不像 [Kubuntu][22] 或其它基于 KDE 的发行版,你不需要等待数月来获取新的 [KDE 软件][23]。 + +你可以在 KDE 桌面中获取很多内置的自定义选项,请按你的心意摆弄它! + +- [KDE Neon][24] + +#### 6、Zorin OS + +![][25] + +毫无疑问,Zorin OS 是一款令人印象深刻的 Linux 发行版,它努力提供了良好的用户体验,即便是它的精简版也是如此。 + +你可以尝试完整版或精简版(使用 [Xfce 桌面][26])。这个用户界面是专门为习惯于 Windows 和 macOS 的用户定制的。虽然它是基于 Ubuntu 的,但它仍然提供了出色的用户体验。 + +如果你开始喜欢上了它的用户界面,那你也可以尝试使用 [Zorin Grid][27] 来管理运行在工作区/家庭中的 Zorin OS 计算机。而使用其终极版,你还可以控制桌面布局(如上图所示)。 + +- [video](https://youtu.be/UsUm_ERVLpQ) + +- [Zorin OS][28] + +#### 7、Nitrux OS + +![][29] + +[Nitrux OS][30] 在 Linux 发行版里算是个另类,它某种程度上基于 Ubuntu,但是不完全基于 Ubuntu 。 + +对于那些正在寻找在 Linux 发行版上使用全新方式的独特设计语言的用户来说,它专注于为他们提供一种良好的用户体验。它使用基于 KDE 的 Nomad 桌面。 + +Nitrux 鼓励使用 [AppImage][31] 应用程序。但是在这个基于 Ubuntu 的 Nitrux 中你也可以使用 Arch Linux 的 pacman 软件包管理器。真令人惊叹! + +如果它不是你安装过(或尚未安装过)的完美的操作系统,但它确实看起来很漂亮,并且对大多数基本任务来说已经足够了。你可以阅读我们的 [Nitrux 创始人的采访][32],可以更多地了解它。 + +这是一个稍微过时的 Nitrux 视频,但是它仍然看起来很好: + +- [video](https://youtu.be/8p2BK0AwuV8) + +- [Nitrux OS][33] + +#### 赠品:eXtern OS (处于‘停滞’开发阶段) + +![][34] + +如果你想尝试一个实验性的 Linux 发行版,extern OS 是非常漂亮的。 + +它没有积极维护,因此不应该用于生产系统。但是,它提供独特的用户体验,尽管还不够完美无缺。 + +如果只是想尝试一个好看的 Linux 发行版,你可以试试。 + +- [eXtern OS][35] + +### 总结 + +俗话说,情人眼里出西施。所以这份来自我眼中的最漂亮 Linux 发行版列表。你可以随意提出不同的意见 (当然要礼貌一点),并提出你最喜欢的 Linux 发行版。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/beautiful-linux-distributions/ + +作者:[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://linux.cn/article-11145-1.html +[2]: https://linux.cn/article-8311-1.html +[3]: https://linux.cn/article-11040-1.html +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/beautiful-linux-distros.png?ssl=1 +[5]: https://itsfoss.com/best-gtk-themes/ +[6]: https://itsfoss.com/best-icon-themes-ubuntu-16-04/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/01/elementary-os-hera.png?ssl=1 +[8]: https://elementary.io/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/deepin-screenshot.jpg?ssl=1 +[10]: https://www.deepin.org/en/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/pop-os-stock.jpg?ssl=1 +[12]: https://www.gnome.org/ +[13]: https://itsfoss.com/pop-os-vs-ubuntu/ +[14]: https://system76.com/pop +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/manjaro_kde.jpg?ssl=1 +[16]: https://en.wikipedia.org/wiki/Arch +[17]: https://itsfoss.com/install-arch-linux/ +[18]: https://itsfoss.com/best-linux-desktop-environments/ +[19]: https://manjaro.org/download/ +[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/kde-neon-screenshot.jpg?ssl=1 +[21]: https://itsfoss.com/kde-neon-unveiled/ +[22]: https://kubuntu.org/ +[23]: https://kde.org/ +[24]: https://neon.kde.org/ +[25]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/zorin-lite-ultimate-appearance.jpg?ssl=1 +[26]: https://www.xfce.org/ +[27]: https://itsfoss.com/zorin-grid/ +[28]: https://zorinos.com/ +[29]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/nitrux-screenshot.jpg?ssl=1 +[30]: https://itsfoss.com/nitrux-linux-overview/ +[31]: https://itsfoss.com/use-appimage-linux/ +[32]: https://itsfoss.com/nitrux-linux/ +[33]: https://nxos.org/ +[34]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/extern-os.png?ssl=1 +[35]: https://externos.io/ +[36]: https://linux.cn/article-9553-1.html +[37]: https://linux.cn/article-10490-1.html +[38]: https://linux.cn/article-11028-1.html +[39]: https://linux.cn/article-10534-1.html +[40]: https://linux.cn/article-7813-1.html +[41]: https://linux.cn/article-9324-1.html +[42]: https://linux.cn/article-8628-1.html diff --git a/published/202003/20200219 How to find what you-re looking for on Linux with find.md b/published/202003/20200219 How to find what you-re looking for on Linux with find.md new file mode 100644 index 0000000000..4b2ca325ef --- /dev/null +++ b/published/202003/20200219 How to find what you-re looking for on Linux with find.md @@ -0,0 +1,236 @@ +[#]: collector: (lujun9972) +[#]: translator: (heguangzhi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11966-1.html) +[#]: subject: (How to find what you’re looking for on Linux with find) +[#]: via: (https://www.networkworld.com/article/3527420/how-to-find-what-you-re-looking-for-on-linux-with-find.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +通过 find 命令找到你要找的东西 +====== + +> find 命令有巨多的选项可以帮助你准确定位你在 Linux 系统上需要寻找的文件。这篇文章讨论了一系列非常有用的选项。 + +![](https://img.linux.net.cn/data/attachment/album/202003/06/113842txki5llopb5aagbt.jpg) + +在 Linux 系统上有许多用于查找文件的命令,而你在使用它们时也有巨多的选项可以使用。 + +例如,你不仅可以通过文件的名称来查找文件,还可以通过文件的所有者或者组、它们的创建时间、大小、分配的权限、最后一次访问它们的时间、关联的信息节点,甚至是文件是否属于系统上不再存在的帐户或组等等来查找文件。 + +你还可以指定搜索从哪里开始,搜索应该深入到文件系统的什么位置,以及搜索结果将告诉你它所找到的文件的数量。 + +而所有这些要求都可以通过 `find` 命令来处理。 + +下面提供了根据这些要求查找文件的示例。在某些命令中,错误(例如试图列出你没有读取权限的文件)输出将被发送到 `/dev/null`,以便我们不必查看它。或者,我们可以简单地以 root 身份运行以避免这个问题。 + +请记住,还有更多的其他选项。这篇文章涵盖了很多内容,但并不是 `find` 命令帮助你定位查找文件的所有方式。 + +### 选择起点 + +使用 `find`,你可以选择一个起点或从你所在的位置开始。要选择的搜索的起点,请在单词 `find` 后输入它。例如,`find /usr` 或 `find ./bin` 将在 `/usr` 目录或当前位置下的 `bin` 目录开始搜索,而 `find ~` 将在你的主目录中开始搜索,即使你当前位于当前文件系统中的其他位置。 + +### 选择你要找的 + +最常用的搜索策略之一是按名称搜索文件。这需要使用 `-name` 选项。 + +默认情况下,`find` 会显示找到的文件的完整路径。如果你在命令中添加 `-print`,你会看到同样的结果。如果你想查看与文件相关的详细信息—-例如:文件的长度、权限等,你需要在你的 `find` 命令的末尾添加 `-ls` 参数。 + +``` +$ find ~/bin -name tryme +/home/shs/bin/tryme +$ find ~/bin -name tryme -print +/home/shs/bin/tryme +$ find ~/bin -name tryme -ls + 917528 4 -rwx------ 1 shs shs 139 Apr 8 2019 /home/shs/bin/tryme +``` + +你也可以使用子字符串来查找文件。例如,如果你将上面示例中的 `tryme` 替换为 `try*`,你将会找到所有名称以 `try` 开头的文件。(LCTT 译注:如果要使用通配符 `*` ,请将搜索字符串放到单引号或双引号内,以避免通配符被 shell 所解释) + +按名称查找文件可能是 `find` 命令最典型的用法,不过还有很多其他的方式来查找文件,并且有这样做的需要。下面的部分展示了如何使用其他可用的方式。 + +此外,当按文件大小、组、索引节点等条件来搜索文件时,你需要确认找到的文件与你要查找的文件是否相匹配。使用 `-ls` 选项来显示细节是非常有用。 + +### 通过大小查找文件 + +按大小查找文件需要使用 `-size` 选项并且对相应规范使用一点技巧。例如,如果你指定 `-size 189b`,你将找到 189 个块大小的文件,而不是 189 个字节。(LCTT 译注:如果不跟上单位,默认单位是 `b`。一个块是 512 个字节大小,不足或正好 512 个字节将占据一个块。)对于字节,你需要使用 `--size 189c`(字符)。而且,如果你指定 `--size 200w` ,你将会找到 200 个“word”的文件——以“双字节增量”为单位的字,而不是“我们互相谈论的那些事情”中的单词。你还可以通过以千字节(`k`)、兆字节(`M`)和千兆字节(`G`)为单位提供大小来查找文件。(LCTT 译注:乃至还有 `T`、`P`) + +大多数情况下,Linux 用户会搜索比选定大小要大的文件。例如,要查找大于 1 千兆字节的文件,你可以使用这样的命令,其中 `+1G` 表示“大于 1 千兆字节”: + +``` +$ find -size +1G -ls 2>/dev/null + 787715 1053976 -rw-rw-r-- 1 shs shs 1079263432 Dec 21 2018 ./backup.zip + 801834 1052556 -rw-rw-r-- 1 shs shs 1077809525 Dec 21 2018 ./2019/hold.zip +``` + +### 通过索引节点号查找文件 + +你可以通过用于维护文件元数据(即除文件内容和文件名之外的所有内容)的索引节点来查找文件。 + +``` +$ find -inum 919674 -ls 2>/dev/null + 919674 4 -rw-rw-r-- 1 shs shs 512 Dec 27 15:25 ./bin/my.log +``` + +### 查找具有特定文件所有者或组的文件 + +按所有者或组查找文件也非常简单。这里我们使用 `sudo` 来解决权限问题。 + +``` +$ sudo find /home -user nemo -name "*.png" -ls + 1705219 4 drwxr-xr-x 2 nemo nemo 4096 Jan 28 08:50 /home/nemo/Pictures/me.png +``` + +在下面这个命令中,我们寻找一个被称为 `admins` 的多用户组拥有的文件。 + +``` +# find /tmp -group admins -ls + 262199 4 -rwxr-x--- 1 dory admins 27 Feb 16 18:57 /tmp/testscript +``` + +### 查找没有所有者或组的文件 + +你可以使用如下命令所示的 `-nouser` 选项来查找不属于当前系统上的任何用户的文件。 + +``` +# find /tmp -nouser -ls +262204 4 -rwx------ 1 1016 1016 17 Feb 17 16:42 /tmp/hello +``` + +请注意,该列表显示了旧用户的 UID 和 GID,这清楚地表明该用户未在系统上定义。这种命令将查找帐户已从系统中删除的用户创建在主目录之外的文件,或者在用户帐户被删除后而未被删除的主目录中创建的文件。类似地,`-nogroup` 选项也会找到这样的文件,尤其是当这些用户是相关组的唯一成员时。 + +### 按上次更新时间查找文件 + +在此命令中,我们在特定用户的主目录中查找过去 24 小时内更新过的文件。`sudo` 用于搜索另一个用户的主目录。 + +``` +$ sudo find /home/nemo -mtime -1 +/home/nemo +/home/nemo/snap/cheat +/home/nemo/tryme +``` + +### 按上次更改权限的时间查找文件 + +`-ctime` 选项可以帮助你查找在某个参考时间范围内状态(如权限)发生更改的文件。以下是查找在最后一天内权限发生更改的文件的示例: + +``` +$ find . -ctime -1 -ls + 787987 4 -rwxr-xr-x 1 shs shs 189 Feb 11 07:31 ./tryme +``` + +请记住,显示的日期和时间只反映了对文件内容进行的最后更新。你需要使用像 `stat` 这样的命令来查看与文件相关联的三个状态(文件创建、修改和状态更改)。 + +### 按上次访问的时间查找文件 + +在这个命令中,我们使用 `-atime` 选项查找在过去两天内访问过的本地 pdf 文件。 + +``` +$ find -name "*.pdf" -atime -2 +./Wingding_Invites.pdf +``` + +### 根据文件相对于另一个文件的时间来查找文件 + +你可以使用 `-newer` 选项来查找比其他文件更新的文件。 + +``` +$ find . -newer dig1 -ls + 786434 68 drwxr-xr-x 67 shs shs 69632 Feb 16 19:05 . + 1064442 4 drwxr-xr-x 5 shs shs 4096 Feb 16 11:06 ./snap/cheat + 791846 4 -rw-rw-r-- 1 shs shs 649 Feb 13 14:26 ./dig +``` + +没有相应的 `-older` 选项,但是你可以用 `! -newer` (即更旧)得到类似的结果,它们基本上一样。 + +### 按类型查找文件 + +通过文件类型找到一个文件,你有很多选项——常规文件、目录、块和字符文件等等。以下是文件类型选项列表: + +``` +b 块特殊文件(缓冲的) +c 字符特殊文件(无缓冲的) +d 目录 +p 命名管道(FIFO) +f 常规文件 +l 符号链接 +s 套接字 +``` + +这里有一个寻找符号链接的例子: + +``` +$ find . -type l -ls + 805717 0 lrwxrwxrwx 1 shs shs 11 Apr 10 2019 ./volcano -> volcano.pdf + 918552 0 lrwxrwxrwx 1 shs shs 1 Jun 16 2018 ./letter -> pers/letter2mom +``` + +### 限制查找的深度 + +`-mindepth` 和 `-maxdepth` 选项控制在文件系统中搜索的深度(从当前位置或起始点开始)。 + +``` +$ find -maxdepth 3 -name "*loop" +./bin/save/oldloop +./bin/long-loop +./private/loop +``` + +### 查找空文件 + +在这个命令中,我们寻找空文件,但不进入目录及其子目录。 + +``` +$ find . -maxdepth 2 -empty -type f -ls + 917517 0 -rw-rw-r-- 1 shs shs 0 Sep 23 11:00 ./complaints/newfile + 792050 0 -rw-rw-r-- 1 shs shs 0 Oct 4 19:02 ./junk +``` + +### 按权限查找文件 + +你可以使用 `-perm` 选项查找具有特定权限集的文件。在下面的示例中,我们只查找常规文件(`-type f`),以避免看到符号链接,默认情况下符号链接被赋予了这种权限,即使它们所引用的文件是受限的。 + +``` +$ find -perm 777 -type f -ls +find: ‘./.dbus’: Permission denied + 798748 4 -rwxrwxrwx 1 shs shs 15 Mar 28 2019 ./runme +``` + +### 使用查找来帮助你删除文件 + +如果使用如下命令,你可以使用 `find` 命令定位并删除文件: + +``` +$ find . -name runme -exec rm {} \; +``` + +`{}` 代表根据搜索条件找到的每个文件的名称。 + +一个非常有用的选项是将 `-exec` 替换为 `-ok`。当你这样做时,`find` 会在删除任何文件之前要求确认。 + +``` +$ find . -name runme -ok rm -rf {} \; +< rm ... ./bin/runme > ? +``` + +删除文件并不是 `-ok` 和 `-exec` 能为你做的唯一事情。例如,你可以复制、重命名或移动文件。 + +确实有很多选择可以有效地使用 `find` 命令,毫无疑问还有一些在本文中没有涉及到。我希望你已经找到一些新的,特别有帮助的。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3527420/how-to-find-what-you-re-looking-for-on-linux-with-find.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202003/20200219 Try this Bash script for-large filesystems.md b/published/202003/20200219 Try this Bash script for-large filesystems.md new file mode 100644 index 0000000000..8ebc16d6d3 --- /dev/null +++ b/published/202003/20200219 Try this Bash script for-large filesystems.md @@ -0,0 +1,330 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12025-1.html) +[#]: subject: (Try this Bash script for large filesystems) +[#]: via: (https://opensource.com/article/20/2/script-large-files) +[#]: author: (Nick Clifton https://opensource.com/users/nickclifton) + +针对大型文件系统可以试试此 Bash 脚本 +====== + +> 一个可以列出文件、目录、可执行文件和链接的简单脚本。 + +![bash logo on green background][1] + +你是否曾经想列出目录中的所有文件,但仅列出文件,而不列出其它的。仅列出目录呢?如果有这种需求的话,那么下面的脚本可能正是你一直在寻找的,它在 GPLv3 下开源。 + +当然,你可以使用 `find` 命令: + +``` +find . -maxdepth 1 -type f -print +``` + +但这键入起来很麻烦,输出也不友好,并且缺少 `ls` 命令拥有的一些改进。你还可以结合使用 `ls` 和 `grep` 来达到相同的结果: + +``` +ls -F . | grep -v / +``` + +但是,这又有点笨拙。下面这个脚本提供了一种简单的替代方法。 + +### 用法 + +该脚本提供了四个主要功能,具体取决于你调用它的名称:`lsf` 列出文件,`lsd` 列出目录,`lsx` 列出可执行文件以及 `lsl` 列出链接。 + +通过符号链接无需安装该脚本的多个副本。这样可以节省空间并使脚本更新更容易。 + +该脚本通过使用 `find` 命令进行搜索,然后在找到的每个项目上运行 `ls`。这样做的好处是,任何给脚本的参数都将传递给 `ls` 命令。因此,例如,这可以列出所有文件,甚至包括以点开头的文件: + +``` +lsf -a +``` + +要以长格式列出目录,请使用 `lsd` 命令: + +``` +lsd -l +``` + +你可以提供多个参数,以及文件和目录路径。 + +下面提供了当前目录的父目录和 `/usr/bin` 目录中所有文件的长分类列表: + +``` +lsf -F -l .. /usr/bin +``` + +目前该脚本不处理递归,仅列出当前目录中的文件。 + +``` +lsf -R +``` + +该脚本不会深入子目录,这个不足有一天可能会进行修复。 + +### 内部 + +该脚本采用自上而下的方式编写,其初始化功能位于脚本的开头,而工作主体则接近结尾。脚本中只有两个真正重要的功能。函数 `parse_args()` 会仔细分析命令行,将选项与路径名分开,并处理脚本中的 `ls` 命令行选项中的特定选项。 + +`list_things_in_dir()` 函数以目录名作为参数并在其上运行 `find` 命令。找到的每个项目都传递给 `ls` 命令进行显示。 + +### 总结 + +这是一个可以完成简单功能的简单脚本。它节省了时间,并且在使用大型文件系统时可能会非常有用。 + +### 脚本 + +``` +#!/bin/bash + +# Script to list: +# directories (if called "lsd") +# files (if called "lsf") +# links (if called "lsl") +# or executables (if called "lsx") +# but not any other type of filesystem object. +# FIXME: add lsp (list pipes) +# +# Usage: +# [switches valid for ls command] [dirname...] +# +# Works with names that includes spaces and that start with a hyphen. +# +# Created by Nick Clifton. +# Version 1.4 +# Copyright (c) 2006, 2007 Red Hat. +# +# This is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published +# by the Free Software Foundation; either version 3, or (at your +# option) any later version. + +# It is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# ToDo: +# Handle recursion, eg: lsl -R +# Handle switches that take arguments, eg --block-size +# Handle --almost-all, --ignore-backups, --format and --ignore + +main () +{ + init + + parse_args ${1+"$@"} + + list_objects + + exit 0 +} + +report () +{ + echo $prog": " ${1+"$@"} +} + +fail () +{ + report " Internal error: " ${1+"$@"} + exit 1 +} + +# Initialise global variables. +init () +{ + # Default to listing things in the current directory. + dirs[0]="."; + + # num_dirs is the number of directories to be listed minus one. + # This is because we are indexing the dirs[] array from zero. + num_dirs=0; + + # Default to ignoring things that start with a period. + no_dots=1 + + # Note - the global variables 'type' and 'opts' are initialised in + # parse_args function. +} + +# Parse our command line +parse_args () +{ + local no_more_args + + no_more_args=0 ; + + prog=`basename $0` ; + + # Decide if we are listing files or directories. + case $prog in + lsf | lsf.sh) + type=f + opts=""; + ;; + lsd | lsd.sh) + type=d + # The -d switch to "ls" is presumed when listing directories. + opts="-d"; + ;; + lsl | lsl.sh) + type=l + # Use -d to prevent the listed links from being followed. + opts="-d"; + ;; + lsx | lsx.sh) + type=f + find_extras="-perm /111" + ;; + *) + fail "Unrecognised program name: '$prog', expected either 'lsd', 'lsf', 'lsl' or 'lsx'" + ;; + esac + + # Locate any additional command line switches for ls and accumulate them. + # Likewise accumulate non-switches to the directories list. + while [ $# -gt 0 ] + do + case "$1" in + # FIXME: Handle switches that take arguments, eg --block-size + # FIXME: Properly handle --almost-all, --ignore-backups, --format + # FIXME: and --ignore + # FIXME: Properly handle --recursive + -a | -A | --all | --almost-all) + no_dots=0; + ;; + --version) + report "version 1.2" + exit 0 + ;; + --help) + case $type in + d) report "a version of 'ls' that lists only directories" ;; + l) report "a version of 'ls' that lists only links" ;; + f) if [ "x$find_extras" = "x" ] ; then + report "a version of 'ls' that lists only files" ; + else + report "a version of 'ls' that lists only executables"; + fi ;; + esac + exit 0 + ;; + --) + # A switch to say that all further items on the command line are + # arguments and not switches. + no_more_args=1 ; + ;; + -*) + if [ "x$no_more_args" = "x1" ] ; + then + dirs[$num_dirs]="$1"; + let "num_dirs++" + else + # Check for a switch that just uses a single dash, not a double + # dash. This could actually be multiple switches combined into + # one word, eg "lsd -alF". In this case, scan for the -a switch. + # XXX: FIXME: The use of =~ requires bash v3.0+. + if [[ "x${1:1:1}" != "x-" && "x$1" =~ "x-.*a.*" ]] ; + then + no_dots=0; + fi + opts="$opts $1"; + fi + ;; + *) + dirs[$num_dirs]="$1"; + let "num_dirs++" + ;; + esac + shift + done + + # Remember that we are counting from zero not one. + if [ $num_dirs -gt 0 ] ; + then + let "num_dirs--" + fi +} + +list_things_in_dir () +{ + local dir + + # Paranoia checks - the user should never encounter these. + if test "x$1" = "x" ; + then + fail "list_things_in_dir called without an argument" + fi + + if test "x$2" != "x" ; + then + fail "list_things_in_dir called with too many arguments" + fi + + # Use quotes when accessing $dir in order to preserve + # any spaces that might be in the directory name. + dir="${dirs[$1]}"; + + # Catch directory names that start with a dash - they + # confuse pushd. + if test "x${dir:0:1}" = "x-" ; + then + dir="./$dir" + fi + + if [ -d "$dir" ] + then + if [ $num_dirs -gt 0 ] + then + echo " $dir:" + fi + + # Use pushd rather passing the directory name to find so that the + # names that find passes on to xargs do not have any paths prepended. + pushd "$dir" > /dev/null + if [ $no_dots -ne 0 ] ; then + find . -maxdepth 1 -type $type $find_extras -not -name ".*" -printf "%f\000" \ + | xargs --null --no-run-if-empty ls $opts -- ; + else + find . -maxdepth 1 -type $type $find_extras -printf "%f\000" \ + | xargs --null --no-run-if-empty ls $opts -- ; + fi + popd > /dev/null + else + report "directory '$dir' could not be found" + fi +} + +list_objects () +{ + local i + + i=0; + while [ $i -le $num_dirs ] + do + list_things_in_dir i + let "i++" + done +} + +# Invoke main +main ${1+"$@"} +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/script-large-files + +作者:[Nick Clifton][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/nickclifton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) diff --git a/published/202003/20200219 Waterfox- Firefox Fork With Legacy Add-ons Options.md b/published/202003/20200219 Waterfox- Firefox Fork With Legacy Add-ons Options.md new file mode 100644 index 0000000000..959c2b5f9e --- /dev/null +++ b/published/202003/20200219 Waterfox- Firefox Fork With Legacy Add-ons Options.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12033-1.html) +[#]: subject: (Waterfox: Firefox Fork With Legacy Add-ons Options) +[#]: via: (https://itsfoss.com/waterfox-browser/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +水狐:一个支持旧版扩展的火狐复刻版 +====== + +> 在本周的开源软件推荐中,我们将介绍一个基于 Firefox 的浏览器,该浏览器支持 Firefox 如今已不再支持的旧版扩展,同时尽可能地提供了快速的用户体验。 + +在 Web 浏览器方面,虽然谷歌浏览器已经占据了最大的市场份额,但 [Mozilla Firefox 仍然是关切隐私的主流 Web 浏览器的一面大旗][1]。 + +Firefox 最近有了很多改进,这些改进的副作用之一是它删除了旧版扩展附件add-on的支持。如果你最喜欢的扩展附件在最近几个月/几年内消失了,那么你可以以 Witerfox 的形式再次拥有它们。 + +> 注意! +> +> 我们注意到,Waterfox 已被 System1 收购。该公司还收购了注重隐私的搜索引擎 Startpage。尽管 System1 声称他们提供注重隐私的产品,因为“这是刚需”,但我们不能对此担保。换句话说,这要取决于你是否信任 System1 和 Waterfox。 + +### Waterfox:一个基于 Firefox 的浏览器 + +![Waterfox Classic][2] + +[Waterfox][3] 是基于 Firefox 构建的一个好用的开源浏览器,它注重隐私并支持旧版扩展。它没有将自己定位为偏执于隐私的浏览器,但确实尊重这个基本的认知。 + +你可以得到两个单独的 Waterfox 浏览器版本。当前版旨在提供现代体验,而经典版则旨在支持 [NPAPI 插件][4] 和 [bootstrap 扩展][5]。 + +![Waterfox Classic][6] + +如果你不需要使用 bootstrap 扩展程序,而是需要 [WebExtensions][7],则应该选择 Waterfox 当前版。 + +而如果你需要设置一个需要大量 NPAPI 插件或 Bootstrap 扩展的浏览器,则 Waterfox 经典版将非常适合你。 + +因此,如果你喜欢 Firefox,但想在同一阵营内尝试一些不同的体验,那么这个 Firefox 替代选择就是为此而生的。 + +### Waterfox 的功能 + +![Waterfox Current][8] + +当然,从技术上讲,你应该能够做 Mozilla Firefox 支持的许多操作。 + +因此,我将在此处的列表中突出显示 Waterfox 的所有重要功能。 + +* 支持 NPAPI 插件 +* 支持 Bootstrap 扩展 +* 分别提供了支持旧版本扩展和现代的 WebExtension 两个版本。 +* 跨平台支持(Windows、Linux 和 macOS) +* 主题定制 +* 支持已经归档的扩展 + +### 在 Ubuntu/Linux 上安装 Waterfox + +与其他流行的浏览器不同,它没有可以安装的软件包。因此,你将必须从其[官方下载页面][9]下载归档包。 + +![][10] + +根据你想要的版本(当前版/经典版),只需下载该文件,它是以 .tar.bz2 为扩展名的文件。 + +下载后,只需解压缩文件即可。 + +接下来,转到解压缩的文件夹并查找 `Waterfox` 文件。你只需双击它即可运行以启动浏览器。 + +如果这不起作用,则可以使用终端并导航到提取的 `Waterfox` 文件夹。到达那里后,你只需使用一个命令即可运行它。看起来如下: + +``` +cd waterfox-classic +./waterfox +``` + +无论是哪种情况,你都可以访问其 [GitHub 页面][11]以了解将其安装在系统上的更多方式。 + +- [下载 Waterfox][3] + +### 总结 + +我在我的 Pop!_OS 19.10 系统中启动了它,在我这里工作的很好。尽管我不准备从 Firefox 切换到 Waterfox,因为我没有使用任何旧版扩展附件。但对于某些用户来说,它可能是一个重要选择。 + +你可以尝试一下,在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/waterfox-browser/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://itsfoss.com/why-firefox/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/waterfox-classic.png?fit=800%2C423&ssl=1 +[3]: https://www.waterfox.net/ +[4]: https://en.wikipedia.org/wiki/NPAPI +[5]: https://wiki.mozilla.org/Extension_Manager:Bootstrapped_Extensions +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/waterfox-classic-screenshot.jpg?ssl=1 +[7]: https://wiki.mozilla.org/WebExtensions +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/waterfox-screenshot.jpg?ssl=1 +[9]: https://www.waterfox.net/download/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/waterfox-download-page.jpg?ssl=1 +[11]: https://github.com/MrAlex94/Waterfox diff --git a/published/202003/20200220 Tools for SSH key management.md b/published/202003/20200220 Tools for SSH key management.md new file mode 100644 index 0000000000..9331cf701f --- /dev/null +++ b/published/202003/20200220 Tools for SSH key management.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11947-1.html) +[#]: subject: (Tools for SSH key management) +[#]: via: (https://opensource.com/article/20/2/ssh-tools) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +SSH 密钥管理工具 +====== + +> 常用开源工具的省时快捷方式。 + +![](https://img.linux.net.cn/data/attachment/album/202003/01/122336zyldgpse6eyrbymt.jpg) + +我经常使用 SSH。我发现自己每天都要登录多个服务器和树莓派(与我位于同一房间,并接入互联网)。我有许多设备需要访问,并且获得访问权限的要求也不同,因此,除了使用各种 `ssh` / `scp` 命令选项之外,我还必须维护一个包含所有连接详细信息的配置文件。 + +随着时间的推移,我发现了一些省时的技巧和工具,你可能也会发现它们有用。 + +### SSH 密钥 + +SSH 密钥是一种在不使用密码的情况下认证 SSH 连接的方法,可以用来加快访问速度或作为一种安全措施(如果你关闭了密码访问权限并确保仅允许授权的密钥)。要创建 SSH 密钥,请运行以下命令: + +``` +$ ssh-keygen +``` + +这将在 `~/.ssh/` 中创建一个密钥对(公钥和私钥)。将私钥(`id_rsa`)保留在 PC 上,切勿共享。你可以与其他人共享公钥(`id_rsa.pub`)或将其放置在其他服务器上。 + +### ssh-copy-id + +如果我在家中或公司工作时使用树莓派,则倾向于将 SSH 设置保留为默认设置,因为我不担心内部信任网络上的安全性,并且通常将 SSH 密钥(公钥)复制到树莓派上,以避免每次都使用密码进行身份验证。为此,我使用 `ssh-copy-id` 命令将其复制到树莓派。这会自动将你的密钥(公钥)添加到树莓派: + +``` +$ ssh-copy-id pi@192.168.1.20 +``` + +在生产服务器上,我倾向于关闭密码身份验证,仅允许授权的 SSH 密钥登录。 + +### ssh-import-id + +另一个类似的工具是 `ssh-import-id`。你可以使用此方法通过从 GitHub 导入密钥来授予你自己(或其他人)对计算机或服务器的访问权限。例如,我已经在我的 GitHub 帐户中注册了各个 SSH 密钥,因此无需密码即可推送到 GitHub。这些公钥是有效的,因此 `ssh-import-id` 可以使用它们在我的任何计算机上授权我: + +``` +$ ssh-import-id gh:bennuttall +``` + +我还可以使用它来授予其他人访问服务器的权限,而无需询问他们的密钥: + +``` +$ ssh-import-id gh:waveform80 +``` + +### storm + +我还使用了名为 Storm 的工具,该工具可帮助你将 SSH 连接添加到 SSH 配置中,因此你不必记住这些连接细节信息。你可以使用 `pip` 安装它: + +``` +$ sudo pip3 install stormssh +``` + +然后,你可以使用以下命令将 SSH 连接信息添加到配置中: + +``` +$ storm add pi3 pi@192.168.1.20 +``` + +然后,你可以只使用 `ssh pi3` 来获得访问权限。类似的还有 `scp file.txt pi3:` 或 `sshfs pi pi3:`。 + +你还可以使用更多的 SSH 选项,例如端口号: + +``` +$ storm add pi3 pi@192.168.1.20:2000 +``` + +你可以参考 Storm 的[文档][2]轻松列出、搜索和编辑已保存的连接。Storm 实际所做的只是管理 SSH 配置文件 `~/.ssh/config` 中的项目。一旦了解了它们是如何存储的,你就可以选择手动编辑它们。配置中的示例连接如下所示: + +``` +Host pi3 +   user pi +   hostname 192.168.1.20 +   port 22 +``` + +### 结论 + +从树莓派到大型的云基础设施,SSH 是系统管理的重要工具。熟悉密钥管理会很方便。你还有其他 SSH 技巧要添加吗?我希望你在评论中分享他们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/ssh-tools + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_BUS_Apple_520.png?itok=ZJu-hBV1 (collection of hardware on blue backround) +[2]: https://stormssh.readthedocs.io/en/stable/usage.html diff --git a/published/202003/20200224 Using C and C-- for data science.md b/published/202003/20200224 Using C and C-- for data science.md new file mode 100644 index 0000000000..f1dfdce174 --- /dev/null +++ b/published/202003/20200224 Using C and C-- for data science.md @@ -0,0 +1,514 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11950-1.html) +[#]: subject: (Using C and C++ for data science) +[#]: via: (https://opensource.com/article/20/2/c-data-science) +[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana) + +在数据科学中使用 C 和 C++ +====== + +> 让我们使用 C99 和 C++11 完成常见的数据科学任务。 + +![metrics and data shown on a computer screen][1] + +虽然 [Python][2] 和 [R][3] 之类的语言在数据科学中越来越受欢迎,但是 C 和 C++ 对于高效的数据科学来说是一个不错的选择。在本文中,我们将使用 [C99][4] 和 [C++11][5] 编写一个程序,该程序使用 [Anscombe 的四重奏][6]数据集,下面将对其进行解释。 + +我在一篇涉及 [Python 和 GNU Octave][7] 的文章中写了我不断学习编程语言的动机,值得大家回顾。这里所有的程序都需要在[命令行][8]上运行,而不是在[图形用户界面(GUI)][9]上运行。完整的示例可在 [polyglot_fit 存储库][10]中找到。 + +### 编程任务 + +你将在本系列中编写的程序: + +* 从 [CSV 文件][11]中读取数据 +* 用直线插值数据(即 `f(x)=m ⋅ x + q`) +* 将结果绘制到图像文件 + +这是许多数据科学家遇到的普遍情况。示例数据是 [Anscombe 的四重奏][6]的第一组,如下表所示。这是一组人工构建的数据,当拟合直线时可以提供相同的结果,但是它们的曲线非常不同。数据文件是一个文本文件,其中的制表符用作列分隔符,前几行作为标题。该任务将仅使用第一组(即前两列)。 + +![](https://img.linux.net.cn/data/attachment/album/202002/29/122805h3yrs1dkrgysssxk.png) + +### C 语言的方式 + +[C][12] 语言是通用编程语言,是当今使用最广泛的语言之一(依据 [TIOBE 指数][13]、[RedMonk 编程语言排名][14]、[编程语言流行度指数][15]和 [GitHub Octoverse 状态][16] 得来)。这是一种相当古老的语言(大约诞生在 1973 年),并且用它编写了许多成功的程序(例如 Linux 内核和 Git 仅是其中的两个例子)。它也是最接近计算机内部运行机制的语言之一,因为它直接用于操作内存。它是一种[编译语言][17];因此,源代码必须由[编译器][18]转换为[机器代码][19]。它的[标准库][20]很小,功能也不多,因此人们开发了其它库来提供缺少的功能。 + +我最常在[数字运算][21]中使用该语言,主要是因为其性能。我觉得使用起来很繁琐,因为它需要很多[样板代码][22],但是它在各种环境中都得到了很好的支持。C99 标准是最新版本,增加了一些漂亮的功能,并且得到了编译器的良好支持。 + +我将一路介绍 C 和 C++ 编程的必要背景,以便初学者和高级用户都可以继续学习。 + +#### 安装 + +要使用 C99 进行开发,你需要一个编译器。我通常使用 [Clang][23],不过 [GCC][24] 是另一个有效的开源编译器。对于线性拟合,我选择使用 [GNU 科学库][25]。对于绘图,我找不到任何明智的库,因此该程序依赖于外部程序:[Gnuplot][26]。该示例还使用动态数据结构来存储数据,该结构在[伯克利软件分发版(BSD)][27]中定义。 + +在 [Fedora][28] 中安装很容易: + +``` +sudo dnf install clang gnuplot gsl gsl-devel +``` + +#### 代码注释 + +在 C99 中,[注释][29]的格式是在行的开头放置 `//`,行的其它部分将被解释器丢弃。另外,`/*` 和 `*/` 之间的任何内容也将被丢弃。 + +``` +// 这是一个注释,会被解释器忽略 +/* 这也被忽略 */ +``` + +#### 必要的库 + +库由两部分组成: + +* [头文件][30],其中包含函数说明 +* 包含函数定义的源文件 + +头文件包含在源文件中,而库文件的源文件则[链接][31]到可执行文件。因此,此示例所需的头文件是: + +``` +// 输入/输出功能 +#include +// 标准库 +#include +// 字符串操作功能 +#include +// BSD 队列 +#include +// GSL 科学功能 +#include +#include +``` + +#### 主函数 + +在 C 语言中,程序必须位于称为主函数 [main()][32] 的特殊函数内: + +``` +int main(void) { +    ... +} +``` + +这与上一教程中介绍的 Python 不同,后者将运行在源文件中找到的所有代码。 + +#### 定义变量 + +在 C 语言中,变量必须在使用前声明,并且必须与类型关联。每当你要使用变量时,都必须决定要在其中存储哪种数据。你也可以指定是否打算将变量用作常量值,这不是必需的,但是编译器可以从此信息中受益。 以下来自存储库中的 [fitting_C99.c 程序][33]: + +``` +const char *input_file_name = "anscombe.csv"; +const char *delimiter = "\t"; +const unsigned int skip_header = 3; +const unsigned int column_x = 0; +const unsigned int column_y = 1; +const char *output_file_name = "fit_C99.csv"; +const unsigned int N = 100; +``` + +C 语言中的数组不是动态的,从某种意义上说,数组的长度必须事先确定(即,在编译之前): + +``` +int data_array[1024]; +``` + +由于你通常不知道文件中有多少个数据点,因此请使用[单链列表][34]。这是一个动态数据结构,可以无限增长。幸运的是,BSD [提供了链表][35]。这是一个示例定义: + +``` +struct data_point { + double x; + double y; + + SLIST_ENTRY(data_point) entries; +}; + +SLIST_HEAD(data_list, data_point) head = SLIST_HEAD_INITIALIZER(head); +SLIST_INIT(&head); +``` + +该示例定义了一个由结构化值组成的 `data_point` 列表,该结构化值同时包含 `x` 值和 `y` 值。语法相当复杂,但是很直观,详细描述它就会太冗长了。 + +#### 打印输出 + +要在终端上打印,可以使用 [printf()][36] 函数,其功能类似于 Octave 的 `printf()` 函数(在第一篇文章中介绍): + +``` +printf("#### Anscombe's first set with C99 ####\n"); +``` + +`printf()` 函数不会在打印字符串的末尾自动添加换行符,因此你必须添加换行符。第一个参数是一个字符串,可以包含传递给函数的其他参数的格式信息,例如: + +``` +printf("Slope: %f\n", slope); +``` + +#### 读取数据 + +现在来到了困难的部分……有一些用 C 语言解析 CSV 文件的库,但是似乎没有一个库足够稳定或流行到可以放入到 Fedora 软件包存储库中。我没有为本教程添加依赖项,而是决定自己编写此部分。同样,讨论这些细节太啰嗦了,所以我只会解释大致的思路。为了简洁起见,将忽略源代码中的某些行,但是你可以在存储库中找到完整的示例代码。 + +首先,打开输入文件: + +``` +FILE* input_file = fopen(input_file_name, "r"); +``` + +然后逐行读取文件,直到出现错误或文件结束: + +``` +while (!ferror(input_file) && !feof(input_file)) { + size_t buffer_size = 0; + char *buffer = NULL; + + getline(&buffer, &buffer_size, input_file); + + ... +} +``` + +[getline()][39] 函数是 [POSIX.1-2008 标准][40]新增的一个不错的函数。它可以读取文件中的整行,并负责分配必要的内存。然后使用 [strtok()][42] 函数将每一行分成[字元][41]token。遍历字元,选择所需的列: + +``` +char *token = strtok(buffer, delimiter); + +while (token != NULL) +{ + double value; + sscanf(token, "%lf", &value); + + if (column == column_x) { + x = value; + } else if (column == column_y) { + y = value; + } + + column += 1; + token = strtok(NULL, delimiter); +} +``` + +最后,当选择了 `x` 和 `y` 值时,将新数据点插入链表中: + +``` +struct data_point *datum = malloc(sizeof(struct data_point)); +datum->x = x; +datum->y = y; + +SLIST_INSERT_HEAD(&head, datum, entries); +``` + +[malloc()][46] 函数为新数据点动态分配(保留)一些持久性内存。 + +#### 拟合数据 + +GSL 线性拟合函数 [gsl_fit_linear()][47] 期望其输入为简单数组。因此,由于你将不知道要创建的数组的大小,因此必须手动分配它们的内存: + +``` +const size_t entries_number = row - skip_header - 1; + +double *x = malloc(sizeof(double) * entries_number); +double *y = malloc(sizeof(double) * entries_number); +``` + +然后,遍历链表以将相关数据保存到数组: + +``` +SLIST_FOREACH(datum, &head, entries) { + const double current_x = datum->x; + const double current_y = datum->y; + + x[i] = current_x; + y[i] = current_y; + + i += 1; +} +``` + +现在你已经处理完了链表,请清理它。要**总是**释放已手动分配的内存,以防止[内存泄漏][48]。内存泄漏是糟糕的、糟糕的、糟糕的(重要的话说三遍)。每次内存没有释放时,花园侏儒都会找不到自己的头: + +``` +while (!SLIST_EMPTY(&head)) { + struct data_point *datum = SLIST_FIRST(&head); + + SLIST_REMOVE_HEAD(&head, entries); + + free(datum); +} +``` + +终于,终于!你可以拟合你的数据了: + +``` +gsl_fit_linear(x, 1, y, 1, entries_number, + &intercept, &slope, + &cov00, &cov01, &cov11, &chi_squared); +const double r_value = gsl_stats_correlation(x, 1, y, 1, entries_number); + +printf("Slope: %f\n", slope); +printf("Intercept: %f\n", intercept); +printf("Correlation coefficient: %f\n", r_value); +``` + +#### 绘图 + +你必须使用外部程序进行绘图。因此,将拟合数据保存到外部文件: + +``` +const double step_x = ((max_x + 1) - (min_x - 1)) / N; + +for (unsigned int i = 0; i < N; i += 1) { + const double current_x = (min_x - 1) + step_x * i; + const double current_y = intercept + slope * current_x; + + fprintf(output_file, "%f\t%f\n", current_x, current_y); +} +``` + +用于绘制两个文件的 Gnuplot 命令是: + +``` +plot 'fit_C99.csv' using 1:2 with lines title 'Fit', 'anscombe.csv' using 1:2 with points pointtype 7 title 'Data' +``` + +#### 结果 + +在运行程序之前,你必须编译它: + +``` +clang -std=c99 -I/usr/include/ fitting_C99.c -L/usr/lib/ -L/usr/lib64/ -lgsl -lgslcblas -o fitting_C99 +``` + +这个命令告诉编译器使用 C99 标准、读取 `fitting_C99.c` 文件、加载 `gsl` 和 `gslcblas` 库、并将结果保存到 `fitting_C99`。命令行上的结果输出为: + +``` +#### Anscombe's first set with C99 #### +Slope: 0.500091 +Intercept: 3.000091 +Correlation coefficient: 0.816421 +``` + +这是用 Gnuplot 生成的结果图像: + +![Plot and fit of the dataset obtained with C99][52] + +### C++11 方式 + +[C++][53] 语言是一种通用编程语言,也是当今使用的最受欢迎的语言之一。它是作为 [C 的继承人][54]创建的(诞生于 1983 年),重点是[面向对象程序设计(OOP)][55]。C++ 通常被视为 C 的超集,因此 C 程序应该能够使用 C++ 编译器进行编译。这并非完全正确,因为在某些极端情况下它们的行为有所不同。 根据我的经验,C++ 与 C 相比需要更少的样板代码,但是如果要进行面向对象开发,语法会更困难。C++11 标准是最新版本,增加了一些漂亮的功能,并且基本上得到了编译器的支持。 + +由于 C++ 在很大程度上与 C 兼容,因此我将仅强调两者之间的区别。我在本部分中没有涵盖的任何部分,则意味着它与 C 中的相同。 + +#### 安装 + +这个 C++ 示例的依赖项与 C 示例相同。 在 Fedora 上,运行: + +``` +sudo dnf install clang gnuplot gsl gsl-devel +``` + +#### 必要的库 + +库的工作方式与 C 语言相同,但是 `include` 指令略有不同: + +``` +#include +#include +#include +#include +#include +#include +#include + +extern "C" { +#include +#include +} +``` + +由于 GSL 库是用 C 编写的,因此你必须将这个特殊情况告知编译器。 + +#### 定义变量 + +与 C 语言相比,C++ 支持更多的数据类型(类),例如,与其 C 语言版本相比,`string` 类型具有更多的功能。相应地更新变量的定义: + +``` +const std::string input_file_name("anscombe.csv"); +``` + +对于字符串之类的结构化对象,你可以定义变量而无需使用 `=` 符号。 + +#### 打印输出 + +你可以使用 `printf()` 函数,但是 `cout` 对象更惯用。使用运算符 `<<` 来指示要使用 `cout` 打印的字符串(或对象): + +``` +std::cout << "#### Anscombe's first set with C++11 ####" << std::endl; + +... + +std::cout << "Slope: " << slope << std::endl; +std::cout << "Intercept: " << intercept << std::endl; +std::cout << "Correlation coefficient: " << r_value << std::endl; +``` + +#### 读取数据 + +该方案与以前相同。将打开文件并逐行读取文件,但语法不同: + +``` +std::ifstream input_file(input_file_name); + +while (input_file.good()) { + std::string line; + + getline(input_file, line); + + ... +} +``` + +使用与 C99 示例相同的功能提取行字元。代替使用标准的 C 数组,而是使用两个[向量][56]。向量是 [C++ 标准库][57]中对 C 数组的扩展,它允许动态管理内存而无需显式调用 `malloc()`: + +``` +std::vector x; +std::vector y; + +// Adding an element to x and y: +x.emplace_back(value); +y.emplace_back(value); +``` + +#### 拟合数据 + +要在 C++ 中拟合,你不必遍历列表,因为向量可以保证具有连续的内存。你可以将向量缓冲区的指针直接传递给拟合函数: + +``` +gsl_fit_linear(x.data(), 1, y.data(), 1, entries_number, + &intercept, &slope, + &cov00, &cov01, &cov11, &chi_squared); +const double r_value = gsl_stats_correlation(x.data(), 1, y.data(), 1, entries_number); + +std::cout << "Slope: " << slope << std::endl; +std::cout << "Intercept: " << intercept << std::endl; +std::cout << "Correlation coefficient: " << r_value << std::endl; +``` + +#### 绘图 + +使用与以前相同的方法进行绘图。 写入文件: + +``` +const double step_x = ((max_x + 1) - (min_x - 1)) / N; + +for (unsigned int i = 0; i < N; i += 1) { + const double current_x = (min_x - 1) + step_x * i; + const double current_y = intercept + slope * current_x; + + output_file << current_x << "\t" << current_y << std::endl; +} + +output_file.close(); +``` + +然后使用 Gnuplot 进行绘图。 + +#### 结果 + +在运行程序之前,必须使用类似的命令对其进行编译: + +``` +clang++ -std=c++11 -I/usr/include/ fitting_Cpp11.cpp -L/usr/lib/ -L/usr/lib64/ -lgsl -lgslcblas -o fitting_Cpp11 +``` + +命令行上的结果输出为: + +``` +#### Anscombe's first set with C++11 #### +Slope: 0.500091 +Intercept: 3.00009 +Correlation coefficient: 0.816421 +``` + +这就是用 Gnuplot 生成的结果图像: + +![Plot and fit of the dataset obtained with C++11][58] + +### 结论 + +本文提供了用 C99 和 C++11 编写的数据拟合和绘图任务的示例。由于 C++ 在很大程度上与 C 兼容,因此本文利用了它们的相似性来编写了第二个示例。在某些方面,C++ 更易于使用,因为它部分减轻了显式管理内存的负担。但是其语法更加复杂,因为它引入了为 OOP 编写类的可能性。但是,仍然可以用 C 使用 OOP 方法编写软件。由于 OOP 是一种编程风格,因此可以在任何语言中使用。在 C 中有一些很好的 OOP 示例,例如 [GObject][59] 和 [Jansson][60]库。 + +对于数字运算,我更喜欢在 C99 中进行,因为它的语法更简单并且得到了广泛的支持。直到最近,C++11 还没有得到广泛的支持,我倾向于避免使用先前版本中的粗糙不足之处。对于更复杂的软件,C++ 可能是一个不错的选择。 + +你是否也将 C 或 C++ 用于数据科学?在评论中分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/c-data-science + +作者:[Cristiano L. Fontana][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cristianofontana +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://opensource.com/article/18/9/top-3-python-libraries-data-science +[3]: https://opensource.com/article/19/5/learn-python-r-data-science +[4]: https://en.wikipedia.org/wiki/C99 +[5]: https://en.wikipedia.org/wiki/C%2B%2B11 +[6]: https://en.wikipedia.org/wiki/Anscombe%27s_quartet +[7]: https://linux.cn/article-11943-1.html +[8]: https://en.wikipedia.org/wiki/Command-line_interface +[9]: https://en.wikipedia.org/wiki/Graphical_user_interface +[10]: https://gitlab.com/cristiano.fontana/polyglot_fit +[11]: https://en.wikipedia.org/wiki/Comma-separated_values +[12]: https://en.wikipedia.org/wiki/C_%28programming_language%29 +[13]: https://www.tiobe.com/tiobe-index/ +[14]: https://redmonk.com/sogrady/2019/07/18/language-rankings-6-19/ +[15]: http://pypl.github.io/PYPL.html +[16]: https://octoverse.github.com/ +[17]: https://en.wikipedia.org/wiki/Compiled_language +[18]: https://en.wikipedia.org/wiki/Compiler +[19]: https://en.wikipedia.org/wiki/Machine_code +[20]: https://en.wikipedia.org/wiki/C_standard_library +[21]: https://en.wiktionary.org/wiki/number-crunching +[22]: https://en.wikipedia.org/wiki/Boilerplate_code +[23]: https://clang.llvm.org/ +[24]: https://gcc.gnu.org/ +[25]: https://www.gnu.org/software/gsl/ +[26]: http://www.gnuplot.info/ +[27]: https://en.wikipedia.org/wiki/Berkeley_Software_Distribution +[28]: https://getfedora.org/ +[29]: https://en.wikipedia.org/wiki/Comment_(computer_programming) +[30]: https://en.wikipedia.org/wiki/Include_directive +[31]: https://en.wikipedia.org/wiki/Linker_%28computing%29 +[32]: https://en.wikipedia.org/wiki/Entry_point#C_and_C++ +[33]: https://gitlab.com/cristiano.fontana/polyglot_fit/-/blob/master/fitting_C99.c +[34]: https://en.wikipedia.org/wiki/Linked_list#Singly_linked_list +[35]: http://man7.org/linux/man-pages/man3/queue.3.html +[36]: https://en.wikipedia.org/wiki/Printf_format_string +[37]: http://www.opengroup.org/onlinepubs/009695399/functions/ferror.html +[38]: http://www.opengroup.org/onlinepubs/009695399/functions/feof.html +[39]: http://man7.org/linux/man-pages/man3/getline.3.html +[40]: https://en.wikipedia.org/wiki/POSIX +[41]: https://en.wikipedia.org/wiki/Lexical_analysis#Token +[42]: http://man7.org/linux/man-pages/man3/strtok.3.html +[43]: http://www.opengroup.org/onlinepubs/009695399/functions/strtok.html +[44]: http://www.opengroup.org/onlinepubs/009695399/functions/sscanf.html +[45]: http://www.opengroup.org/onlinepubs/009695399/functions/malloc.html +[46]: http://man7.org/linux/man-pages/man3/malloc.3.html +[47]: https://www.gnu.org/software/gsl/doc/html/lls.html +[48]: https://en.wikipedia.org/wiki/Memory_leak +[49]: http://www.opengroup.org/onlinepubs/009695399/functions/free.html +[50]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html +[51]: http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html +[52]: https://opensource.com/sites/default/files/uploads/fit_c99.png (Plot and fit of the dataset obtained with C99) +[53]: https://en.wikipedia.org/wiki/C%2B%2B +[54]: http://www.cplusplus.com/info/history/ +[55]: https://en.wikipedia.org/wiki/Object-oriented_programming +[56]: https://en.wikipedia.org/wiki/Sequence_container_%28C%2B%2B%29#Vector +[57]: https://en.wikipedia.org/wiki/C%2B%2B_Standard_Library +[58]: https://opensource.com/sites/default/files/uploads/fit_cpp11.png (Plot and fit of the dataset obtained with C++11) +[59]: https://en.wikipedia.org/wiki/GObject +[60]: http://www.digip.org/jansson/ diff --git a/published/202003/20200224 What developers need to know about domain-specific languages.md b/published/202003/20200224 What developers need to know about domain-specific languages.md new file mode 100644 index 0000000000..c0e01b7923 --- /dev/null +++ b/published/202003/20200224 What developers need to know about domain-specific languages.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11957-1.html) +[#]: subject: (What developers need to know about domain-specific languages) +[#]: via: (https://opensource.com/article/20/2/domain-specific-languages) +[#]: author: (Girish Managoli https://opensource.com/users/gammay) + + +开发者需要了解的领域特定语言(DSL) +====== + +> 领域特定语言是在特定领域下用于特定上下文的语言。作为开发者,很有必要了解领域特定语言的含义,以及为什么要使用特定领域语言。 + +![](https://img.linux.net.cn/data/attachment/album/202003/04/112240b0os2988kolritlo.jpg) + +领域特定语言domain-specific language(DSL)是一种旨在特定领域下的上下文的语言。这里的领域是指某种商业上的(例如银行业、保险业等)上下文,也可以指某种应用程序的(例如 Web 应用、数据库等)上下文。与之相比的另一个概念是通用语言general-purpose language(GPL,LCTT 译注:注意不要和 GPL 许可证混淆),通用语言则可以广泛应用于各种商业或应用问题当中。 + +DSL 并不具备很强的普适性,它是仅为某个适用的领域而设计的,但它也足以用于表示这个领域中的问题以及构建对应的解决方案。HTML 是 DSL 的一个典型,它是在 Web 应用上使用的语言,尽管 HTML 无法进行数字运算,但也不影响它在这方面的广泛应用。 + +而 GPL 则没有特定针对的领域,这种语言的设计者不可能知道这种语言会在什么领域被使用,更不清楚用户打算解决的问题是什么,因此 GPL 会被设计成可用于解决任何一种问题、适合任何一种业务、满足任何一种需求。例如 Java 就属于 GPL,它可以在 PC 或移动设备上运行,嵌入到银行、金融、保险、制造业等各种行业的应用中去。 + +### DSL 的类别 + +从使用方式的角度,语言可以划分出以下两类: + +* DSL:使用 DSL 形式编写或表示的语言 +* 宿主语言host language:用于执行或处理 DSL 的语言 + +由不同的语言编写并由另一种宿主语言处理的 DSL 被称为外部external DSL。 + +以下就是可以在宿主语言中处理的 SQL 形式的 DSL: + +``` +SELECT account +FROM accounts +WHERE account = '123' AND branch = 'abc' AND amount >= 1000 +``` + +因此,只要在规定了词汇和语法的情况下,DSL 也可以直接使用英语来编写,并使用诸如 ANTLR 这样的解析器生成器parser generator以另一种宿主语言来处理 DSL: + +``` +if smokes then increase premium by 10% +``` + +如果 DSL 和宿主语言是同一种语言,这种 DSL 称为内部internalDSL,其中 DSL 由以同一种语义的宿主语言编写和处理,因此又称为嵌入式embedded DSL。以下是两个例子: + +* Bash 形式的 DSL 可以由 Bash 解释器执行: + + ``` +if today_is_christmas; then apply_christmas_discount; fi +``` + 同时这也是一段看起来符合英语语法的 Bash。 +* 使用类似 Java 语法编写的 DSL: + + ``` +orderValue = orderValue + .applyFestivalDiscount() + .applyCustomerLoyalityDiscount() + .applyCustomerAgeDiscount(); +``` + 这一段的可读性也相当强。 + +实际上,DSL 和 GPL 之间并没有非常明确的界限。 + +### DSL 家族 + +以下这些语言都可以作为 DSL 使用: + +* Web 应用:HTML +* Shell:用于类 Unix 系统的 sh、Bash、CSH 等;用于 Windows 系统的 MS-DOS、Windows Terminal、PowerShell 等 +* 标记语言:XML +* 建模:UML +* 数据处理:SQL 及其变体 +* 业务规则管理:Drools +* 硬件:Verilog、VHD +* 构建工具:Maven、Gradle +* 数值计算和模拟:MATLAB(商业)、GNU Octave、Scilab +* 解析器和生成器:Lex、YACC、GNU Bison、ANTLR + +### 为什么要使用 DSL? + +DSL 的目的是在某个领域中记录一些需求和行为,在某些方面(例如金融商品交易)中,DSL 的适用场景可能更加狭窄。业务团队和技术团队能通过 DSL 有效地协同工作,因此 DSL 除了在业务用途上有所发挥,还可以让设计人员和开发人员用于设计和开发应用程序。 + +DSL 还可以用于生成一些用于解决特定问题的代码,但生成代码并不是 DSL 的重点并不在此,而是对专业领域知识的结合。当然,代码生成在领域工程中是一个巨大的优势。 + +### DSL 的优点和缺点 + +DSL 的优点是,它对于领域的特征捕捉得非常好,同时它不像 GPL 那样包罗万有,学习和使用起来相对比较简单。因此,它在专业人员之间、专业人员和开发人员之间都提供了一个沟通的桥梁。 + +而 DSL 最显著的缺点就在于它只能用于一个特定的领域和目标。尽管学习起来不算太难,但学习成本仍然存在。如果使用到 DSL 相关的工具,即使对工作效率有所提升,但开发或配置这些工具也会增加一定的工作负担。另外,如果要设计一款 DSL,设计者必须具备专业领域知识和语言开发知识,而同时具备这两种知识的人却少之又少。 + +### DSL 相关软件 + +开源的 DSL 软件包括: + +* Xtext:Xtext 可以与 Eclipse 集成,并支持 DSL 开发。它能够实现代码生成,因此一些开源和商业产品都用它来提供特定的功能。用于农业活动建模分析的多用途农业数据系统Multipurpose Agricultural Data System(MADS)就是基于 Xtext 实现的一个项目,可惜的是这个项目现在已经不太活跃了。 +* JetBrains MPS:JetBrains MPS 是一个可供开发 DSL 的集成开发环境Integrated Development Environment,它将文档在底层存储为一个抽象树结构(Microsoft Word 也使用了这一概念),因此它也自称为一个投影编辑器projectional editor。JetBrains MPS 支持 Java、C、JavaScript 和 XML 的代码生成。 + +### DSL 的最佳实践 + +如果你想使用 DSL,记住以下几点: + +* DSL 不同于 GPL,DSL 只能用于解决特定领域中有限范围内的问题。 +* 不必动辄建立自己的 DSL,可以首先尝试寻找已有的 DSL。例如 [DSLFIN][4] 这个网站就提供了很多金融方面的 DSL。在实在找不到合适的 DSL 的情况下,才需要建立自己的 DSL。 +* DSL 最好像平常的语言一样具有可读性。 +* 尽管代码生成不是一项必需的工作,但它确实会大大提高工作效率。 +* 虽然 DSL 被称为语言,但 DSL 不需要像 GPL 一样可以被执行,可执行性并不是 DSL 需要达到的目的。 +* DSL 可以使用文本编辑器编写,但专门的 DSL 编辑器可以更轻松地完成 DSL 的语法和语义检查。 + +如果你正在使用或将要使用 DSL,欢迎在评论区留言。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/domain-specific-languages + +作者:[Girish Managoli][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gammay +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_language_c.png?itok=mPwqDAD9 (Various programming languages in use) +[2]: https://en.wikipedia.org/wiki/Domain-specific_language +[3]: http://mads.sourceforge.net/ +[4]: http://www.dslfin.org/resources.html diff --git a/published/202003/20200225 3 eBook readers for the Linux desktop.md b/published/202003/20200225 3 eBook readers for the Linux desktop.md new file mode 100644 index 0000000000..07fbb8f09a --- /dev/null +++ b/published/202003/20200225 3 eBook readers for the Linux desktop.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (wenwensnow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11990-1.html) +[#]: subject: (3 eBook readers for the Linux desktop) +[#]: via: (https://opensource.com/article/20/2/linux-ebook-readers) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +可在 Linux 桌面使用的 3 个电子书阅读器应用 +====== + +> 任意一个开源电子书应用都能使你在大屏设备上的阅读体验得到提升。 + +![电脑浏览器阅读书籍界面][1] + +我通常使用手机或 Kobo 阅读器阅读电子书,总是没有在大屏设备上阅读书籍那么爽。很多人经常在自己的笔记本或桌面电脑上阅读电子书,如果你有这种需求(或者你认为以后会遇到这种情况),我想向你介绍三种 Linux 桌面下的电子书阅读器。 + +### Bookworm(书虫) + +[Bookworm][2] 意在成为一个“简洁、专注的电子书阅读器”。事实证明它也确实做到了。Bookworm 内置一系列基础功能,有人抱怨它太过*简单*,缺少*功能性*(虽然这词显然有点指意不明)。Bookworm 起到了应有的作用而没有无关的花哨功能。 + +该应用的界面整洁干净。 + +![Bookworm 电子书应用][3] + +你可通过以下方式查看书籍: + +* 空格键前往下一页 +* 上下方向键按行移动 +* 左右方向键跳转至前后章节 + +你也可以通过添加注释或书签跳转至特定页面。 + +![Bookworm 注释][4] + +Bookworm 没有太多设置选项。你能调整书籍字体大小及间距,开启双页模式或夜间模式。在应用中添加新文件夹后,Bookworm 会自动扫描文件夹中的电子书。 + +![Bookworm 参数设置][5] + +Bookworm 支持常用的电子书格式:EPUB、PDF、MOBI、[FB2][6],你还能用它阅读 [CBR][7] 和 CBZ 格式的数字版漫画。我只在 Bookworm 上测试了前三种格式,PDF 倒是能打开,但加载速度很慢,格式也很难看。 + +### Foliate + +单从功能上来说,[Foliate][8] 确实比 Bookworm 强上一些。Foliate 不仅功能更强,它还有更多设置选项。这个功能多样、简单干净的应用满足了所有要求。 + +![Foliate 电子书应用][9] + +在 Foliate 中可以通过空格、方向键、向上或向下翻页键浏览电子书,这里没什么特别的。 + +你还可以在书籍中添加注释、查找以及翻译字句、查询字词含义。如果你电脑上安装了智能语音应用, Foliate 还能将文本朗读出来。 + +![在 Foliate 中的注释文本][10] + +Foliate 与 Bookworm 相比有更多自定义选项。你能在应用中修改字体类型及大小、行间距、电子书页边距,也可以调高或降低屏幕亮度,从应用内置的四个主题中选择一个等。 + +![Foliate 设置][11] + +你可以在 Foliate 上阅读 EPUB、MOBI、AZW、AZW3 格式的电子书。如果你不了解,我可以提前告诉你,后三种格式是亚马逊 Kindle 阅读器上架的书籍的闭源格式。 + +### Calibre 电子书阅读器 + +这个[电子书阅读器][12]是 [Calibre][13] 电子书管理工具的一个组件,就像它的前代一样,电子书阅读器这部分并不是软件整体最棒的部分。 + +![电子书阅读器应用][14] + +不过别被上面的话吓到,它也的确是个桌面电子书阅读器。 + +在 Calibre 电子书阅读器中,你可以通过方向键、向上/向下翻页键以及空格浏览书籍,还能在在线字典中查找词语含义,添加书签。这一阅读器没有注释功能,但内置的搜索引擎却很好用,你还能将书籍保存为 PDF 格式(虽然我不太明白你为什么要这么做)。 + +不过参数设置这里确是它出彩的地方,它的可选设置比 Bookworm 和 Foliate 加起来都多,从字体到文本布局,页面分割方式你都能改。除此之外,你还能自定义应用按键设置,将你喜欢的词典网站添加进来,方便阅读查找。 + +![电子书参数设置][15] + +Calibre 电子书阅读器一个很有用的功能,就是把自行设置的 CSS 配置文件效果应用到电子书上。赘言一句,CSS 是一种调整网页格式的方法(这类文件就是许多电子书的一个组成部分)。如果你是使用 CSS 的高手,你可以将自己的 CSS 文件复制粘贴到配置窗口的 “User stylesheet” 部分,这就是个性化的究极办法。 + +据开发者描述,这一电子书阅读器“能支持所有主流电子书格式”。如果你想知道具体支持格式是什么,[这是列表链接][16]。我测试了列表中的一小部分格式,没有发现问题。 + +### 留在最后的话 + +不管你只是单纯想找个电子书阅读器,还是有个更多复杂功能的应用,上文提到的三个选择都很不错,而且它们都能提升你在大屏设备上的阅读体验。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/linux-ebook-readers + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[wenwensnow](https://github.com/wenwensnow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_browser_program_books_read.jpg?itok=iNMWe8Bu (Computer browser with books on the screen) +[2]: https://babluboy.github.io/bookworm/ +[3]: https://opensource.com/sites/default/files/uploads/bookworm-reading.png (Bookworm e-book application) +[4]: https://opensource.com/sites/default/files/uploads/bookworm-annotations.png (Annotations in Bookworm) +[5]: https://opensource.com/sites/default/files/uploads/bookworm-preferences.png (Bookworm preferences) +[6]: https://en.wikipedia.org/wiki/FictionBook +[7]: https://en.wikipedia.org/wiki/Comic_book_archive +[8]: https://johnfactotum.github.io/foliate/ +[9]: https://opensource.com/sites/default/files/uploads/foliate-reading.png (Foliate e-book application) +[10]: https://opensource.com/sites/default/files/uploads/foliate-annotation_0.png +[11]: https://opensource.com/sites/default/files/uploads/foliate-settings.png (Foliate settings) +[12]: https://calibre-ebook.com/about +[13]: https://opensourcemusings.com/managing-your-ebooks-with-calibre +[14]: https://opensource.com/sites/default/files/uploads/e-book_viewer-reading.png (E-book Viewer application) +[15]: https://opensource.com/sites/default/files/uploads/ebook-viewer-preferences.png (E-book Viewer preferences) +[16]: https://manual.calibre-ebook.com/faq.html#what-formats-does-calibre-support-conversion-to-from +[17]: https://opensourcemusings.com/three-ebook-readers-for-the-linux-desktop +[18]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/published/202003/20200225 7 tips for writing an effective technical resume.md b/published/202003/20200225 7 tips for writing an effective technical resume.md new file mode 100644 index 0000000000..5748eea651 --- /dev/null +++ b/published/202003/20200225 7 tips for writing an effective technical resume.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (Morisun029) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12020-1.html) +[#]: subject: (7 tips for writing an effective technical resume) +[#]: via: (https://opensource.com/article/20/2/technical-resume-writing) +[#]: author: (Emily Brand https://opensource.com/users/emily-brand) + +撰写有效的技术简历的 7 个技巧 +====== + +> 遵循以下这些要点,把自己最好的一面呈现给潜在雇主。 + +![](https://img.linux.net.cn/data/attachment/album/202003/21/092248u2w2gz2aezre2ba2.jpg) + +如果你是一名软件工程师或技术领域的经理,那么创建或更新简历可能是一项艰巨的任务。要考虑的重点是什么?应该怎么把控格式、内容以及求职目标或摘要?哪些工作经验相关?如何确保自动化招聘工具不会过滤掉你的简历? + +在过去的七年中,作为一名招聘经理,我看到了各种各样的简历;尽管有些令人印象深刻,但还有很多人写的很糟糕。 + +在编写或更新简历时,请遵循以下七个简单原则。 + +### 1、概述 + +简历顶部的简短段落应简洁明了、目的明确,避免过度使用形容词和副词。诸如“令人印象深刻”、“广泛”和“卓越”之类的词,这些词不会增加你的招聘机会;相反,它们看起来和感觉上像是过度使用的填充词。 关于你的求职目标,问自己一个重要的问题:**它是否告诉招聘经理我正在寻找什么样的工作以及如何为他们提供价值?** 如果不是,请加强并简化它以回答该问题,或者将其完全排除在外。 + +### 2、工作经验 + +数字、数字、数字——重要的事情说三遍。用确凿的事实传达观点远比一般的陈述,例如“帮助构建、管理、交付许多对客户利润有贡献的项目”更能对你有帮助。你的表达中应包括统计数据,例如“直接影响了 5 个顶级银行的项目,这些项目将其上市时间缩短了 40%”,你提交了多少行代码或管理了几个团队。数据比修饰语更能有效地展示你的能力和价值。 + +如果你经验不足,没有什么工作经验可展示,那些无关的经验,如暑期兼职工作,就不要写了。相反,将相关经验的细节以及你所学到的知识的详细信息写进简历,这些可以使你成为一个更好的候选人。 + +### 3、搜索术语和行话 + +随着技术在招聘过程中发挥如此巨大的作用,确保简历被标记为正确的职位非常重要,但不要在简历上过分吹嘘自己。如果你提到敏捷技能但不知道看板是什么,请三思。如果你提到自己精通 Java,但是已经有五年都没有使用过 Java 了,请小心。如果存在你熟悉但不一定是当前在用的语言和框架,请创建其他类别或将你的经验分为“精通”和“熟悉”。 + +### 4、教育 + +如果你不是应届大学毕业生,那就没必要再写你的 GPA 或你参加过的俱乐部或兄弟会,除非你计划将它们用作谈话要点以在面试中赢得信任。确保将你发表的或获取过专利的东西包括在内,即使它与该工作无关。如果你没有大学学位,请添加一个证书部分代替教育背景部分。如果你是军人,请包括现役和预备役时间。 + +### 5、资质证书 + +除非你想重新进入之前离开的领域,否则不要写过期的证书,例如,如果你曾经是一名人事经理,而现在正寻求动手编程的工作。如果你拥有与该领域不再相关的认证,就不要写这些认证,因为这些可能会分散招聘者的注意力,使你的简历失去吸引力。利用你的 LinkedIn 个人资料为简历添加更多色彩,因为大多数人在面试之前都会阅读你的简历和 LinkedIn 个人资料。 + +### 6、拼写和语法 + +让其他人帮忙对你的简历校对一下。很多时候,我在简历中看到过拼写错误的单词,或者错误用词,如“他们的”、“他们是”、“那些”。这些可以避免和修复的错误会产生负面影响。理想情况下,你的简历应用主动语态,但是如果这样会使你感到不舒服,那么就用过去时书写 —— 最重要的是要始终保持一致。不正确的拼写和语法会传递你要么不是很在乎所申请的工作,要么没有足够注意细节。 + +### 7、格式 + +确保你的简历是最新的并且富有吸引力,这是留下良好第一印象的简便方法。确保格式一致,例如相同的页边距,相同的间距、大写字母和颜色(将调色板保持在最低限度,不要花花绿绿)是简历写作中最基本的部分,但有必要表明你对工作感到自豪,并重视自己的价值和未来的雇主。在适当的地方使用表格,以视觉吸引人的方式分配信息。如果支持的话,以 .pdf 和 .docx 格式上传简历,然后用 Google Docs 导出为 .odt 格式,这样可以在 LibreOffice 中轻松打开。这里有一个我推荐的简单的 Google 文档[简历模板][2]。 你还可以支付少量费用(不到 10 美元)从一些设计公司购买模板。 + +### 定期更新 + +如果你需要(或希望)申请一份工作,定期更新简历可以最大程度地减少压力,也可以帮助你创建和维护更准确的简历版本。撰写简历时,要有远见,确保至少让另外三个人对你的简历内容、拼写和语法进行检查。即使你是由公司招募或其他人推荐给公司的,面试官也可能只能通过简历来认识你,因此请确保它为你带来良好的第一印象。 + +你还有其他提示要添加吗? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/technical-resume-writing + +作者:[Emily Brand][a] +选题:[lujun9972][b] +译者:[Morisun029](https://github.com/Morisun029) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/emily-brand +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/resume_career_document_general.png?itok=JEaFL2XI (Two hands holding a resume with computer, clock, and desk chair ) +[2]: https://docs.google.com/document/d/1ARVyybC5qQEiCzUOLElwAdPpKOK0Qf88srr682eHdCQ/edit diff --git a/published/202003/20200226 Use logzero for simple logging in Python.md b/published/202003/20200226 Use logzero for simple logging in Python.md new file mode 100644 index 0000000000..e6bcd095c4 --- /dev/null +++ b/published/202003/20200226 Use logzero for simple logging in Python.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11970-1.html) +[#]: subject: (Use logzero for simple logging in Python) +[#]: via: (https://opensource.com/article/20/2/logzero-python) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +使用 logzero 在 Python 中进行简单日志记录 +====== + +> 快速了解一个方便的日志库,来帮助你掌握这个重要的编程概念。 + +![](https://img.linux.net.cn/data/attachment/album/202003/07/122445v743hy7ajdyrrda1.jpg) + +logzero 库使日志记录就像打印语句一样容易,是简单性的杰出代表。我不确定 logzero 的名称是否要与 pygame-zero、GPIO Zero 和 guizero 这样的 “zero 样板库”契合,但是肯定属于该类别。它是一个 Python 库,可以使日志记录变得简单明了。 + +你可以使用它基本的记录到标准输出的日志记录,就像你可以使用 print 来获得信息和调试一样,学习它的更高级日志记录(例如记录到文件)的学习曲线也很平滑。 + +首先,使用 pip 安装 logzero: + +``` +$ sudo pip3 install logzero +``` + +在 Python 文件中,导入 logger 并尝试以下一个或所有日志实例: + +``` +from logzero import logger + +logger.debug("hello") +logger.info("info") +logger.warning("warning") +logger.error("error") +``` + +输出以易于阅读的方式自动着色: + +![Python, Raspberry Pi: import logger][2] + +因此现在不要再使用 `print` 来了解发生了什么,而应使用有相关日志级别的日志器。 + +### 在 Python 中将日志写入文件 + +如果你阅读至此,并会在你写代码时做一点改变,这对我就足够了。如果你要了解更多,请继续阅读! + +写到标准输出对于测试新程序不错,但是仅当你登录到运行脚本的计算机时才有用。在很多时候,你需要远程执行代码并在事后查看错误。这种情况下,记录到文件很有帮助。让我们尝试一下: + +``` +from logzero import logger, logfile + +logfile('/home/pi/test.log') +``` + +现在,你的日志条目将记录到文件 `test.log` 中。记住确保[脚本有权限][3]写入该文件及其目录结构。 + +你也可以指定更多选项: + +``` +logfile('/home/pi/test.log', maxBytes=1e6, backupCount=3) +``` + +现在,当提供给 `test.log` 文件的数据达到 1MB(10^6 字节)时,它将通过 `test.log.1`、`test.log.2` 等文件轮替写入。这种行为可以避免系统打开和关闭大量 I/O 密集的日志文件,以至于系统无法打开和关闭。更专业一点,你或许还要记录到 `/var/log`。假设你使用的是 Linux,那么创建一个目录并将用户设为所有者,以便可以写入该目录: + +``` +$ sudo mkdir /var/log/test +$ sudo chown pi /var/log/test +``` + +然后在你的 Python 代码中,更改 `logfile` 路径: + +``` +logfile('/var/log/test/test.log', maxBytes=1e6, backupCount=3) +``` + +当要在 `logfile` 中捕获异常时,可以使用 `logging.exception`: + +``` +try: +    c = a / b +except Exception as e: +    logger.exception(e) +``` + +这将输出(在 `b` 为零的情况下): + +``` +[E 190422 23:41:59 test:9] division by zero +     Traceback (most recent call last): +       File "test.py", line 7, in +         c = a / b +     ZeroDivisionError: division by zero +``` + +你会得到日志,还有完整回溯。另外,你可以使用 `logging.error` 并隐藏回溯: + +``` +try: +    c = a / b +except Exception as e: +    logger.error(f"{e.__class__.__name__}: {e}") +``` + +现在,将产生更简洁的结果: + +``` +[E 190423 00:04:16 test:9] ZeroDivisionError: division by zero +``` + +![Logging output][4] + +你可以在 [logzero.readthedocs.io] [5] 中阅读更多选项。 + +### logzero 为教育而生 + +对于新手程序员来说,日志记录可能是一个具有挑战性的概念。大多数框架依赖于流控制和大量变量操作来生成有意义的日志,但是 logzero 不同。由于它的语法类似于 `print` 语句,因此它在教育上很成功,因为它无需解释其他概念。在你的下个项目中试试它。 + + +此文章最初发布在[我的博客][6]上,经许可重新发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/logzero-python + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/getting_started_with_python.png?itok=MFEKm3gl (Snake charmer cartoon with a yellow snake and a blue snake) +[2]: https://opensource.com/sites/default/files/uploads/rpi_ben_1.png (Python, Raspberry Pi: import logger) +[3]: https://opensource.com/article/19/6/understanding-linux-permissions +[4]: https://opensource.com/sites/default/files/uploads/rpi_ben_2.png (Logging output) +[5]: https://logzero.readthedocs.io/en/latest/ +[6]: https://tooling.bennuttall.com/logzero/ diff --git a/published/202003/20200228 Converting between uppercase and lowercase on the Linux command line.md b/published/202003/20200228 Converting between uppercase and lowercase on the Linux command line.md new file mode 100644 index 0000000000..a90b4d411c --- /dev/null +++ b/published/202003/20200228 Converting between uppercase and lowercase on the Linux command line.md @@ -0,0 +1,157 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11983-1.html) +[#]: subject: (Converting between uppercase and lowercase on the Linux command line) +[#]: via: (https://www.networkworld.com/article/3529409/converting-between-uppercase-and-lowercase-on-the-linux-command-line.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 命令行中转换大小写 +====== + +> 转换文本的大小写可能非常繁琐,尤其是当你要避免无意间的拼写错误时。幸运的是,Linux 提供了一些命令,可以使工作变得非常容易。 + +![](https://img.linux.net.cn/data/attachment/album/202003/11/095821df7u8nlyfyyydqvf.jpg) + +有很多方法可以在 Linux 命令行中将文本从小写更改为大写,反之亦然。实际上,有一组这样的命令可以选择。这篇文章检验了一些最佳的命令来完成这项工作,以及你该如何让它们正常工作。 + +### 使用 tr + +`tr`(translate)命令是在命令行或脚本中最容易使用的命令之一。如果你要确定要一串大写字符串,你只需将它传给 `tr`,如下所示: + +``` +$ echo Hello There | tr [:lower:] [:upper:] +HELLO THERE +``` + +下面是一个在脚本中使用这个命令的例子,当你要确保添加到文件中的所有文本都使用大写形式以保持一致性时(LCTT 译注:这里输入部门名称作为示例): + +``` +#!/bin/bash + +echo -n "Enter department name: " +read dept +echo $dept | tr [:lower:] [:upper:] >> depts +``` + +将顺序切换为 `[:upper:] [:lower:]` 会产生相反的效果,将所有大写的部门名称都转换为小写: + +``` +echo $dept | tr [:upper:] [:lower:] >> depts +``` + +同样,你可以使用 `sed` 命令的 `A-Z` 和 `a-z` 字符串完成相同的操作: + +``` +echo $dept | tr a-z A-Z >> depts +``` + +毫无疑问,反转 `a-z` 和 `A-Z` 字符串的顺序将产生相反的效果,将文本全部变为小写。 + +### 使用 awk + +`awk` 命令可让你使用它的 `toupper` 和 `tolower` 选项执行相同的操作。上例脚本中的命令可以用这种方式代替: + +``` +echo $dept | awk '{print toupper($0)}' >> depts +``` + +相反操作(切换为小写)如下所示: + +``` +echo $dept | awk '{print tolower($0)}' >> depts +``` + +### 使用 sed + +`sed`(stream editor)命令也可用于切换大小写。它与上面显示的两个命令中的第一个具有相同的效果。 + +``` +echo $dept | sed 's/[a-z]/\U&/g' >> depts +``` + +从大写字母切换到小写字母只需将行尾附近的 `U` 替换为 `L`。 + +``` +echo $dept | sed 's/[A-Z]/\L&/g' >> depts +``` + +### 操作文件中的文本 + +`awk` 和 `sed` 都能更改整个文件的文本大小写。因此,你发现你的老板需要所有部门名称的小写么?没问题。只需带上文件名运行以下命令: + +``` +$ awk '{print tolower($0)}' depts +finance +billing +bookkeeping +``` + +如果要覆盖 `depts` 文件,而不仅仅是以小写形式显示,则需要执行以下操作: + +``` +$ awk '{print tolower($0)}' depts > depts- +$ mv depts- depts +``` + +但是,使用 `sed` 进行更改,你可以避免最后一步,因为 `sed` 可以“原地”编辑文件,如下所示,文件完整,但文本全部小写: + +``` +$ sed 's/[A-Z]/\L&/g' depts +``` + +### 仅将首字母转换为大写 + +要仅将字符串中单词的首字母转换为大写,那么可以执行以下操作: + +``` +$ echo design \& engineering| sed -e "s/\b\(.\)/\u\1/g" +Design & Engineering +``` + +该命令将确保首字母大写,但不会更改其余字母。 + +### 确保只有首字母大写 + +当要更改文本以使只有首字母大写时,这更具挑战性。假设你正在处理一个工作人员姓名列表,并且希望以正常的“名 姓”方式对其格式化。 + +#### 使用 sed + +你可以使用更复杂的 `sed` 命令来确保以下结果: + +``` +$ echo design \& ENGINEERING | sed 's/\b\([[:alpha:]]\)\([[:alpha:]]*\)\b/\u\1\L\2/g' +Design & Engineering +``` + +#### 使用 Python + +如果你已安装 Python,你可以运行这样的命令,它还可以设置文本格式,以便每个单词只有首字母大写,并且它可能比上面显示的 `sed` 命令更易于解析: + +``` +$ echo -n "design & engineering" | python3 -c "import sys; print(sys.stdin.read().title())" +Design & Engineering +``` + +有多种方法可以在大小写之间更改文本格式。哪种方法效果最好取决于你要处理的是单个字符串还是整个文件,以及想要的最终结果。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3529409/converting-between-uppercase-and-lowercase-on-the-linux-command-line.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]:https://images.idgesg.net/images/article/2019/04/alphabetic_letters_characters_language_by_andybrandon50_cc_by-sa_2-0_1500x1000-100794409-large.jpg +[2]: https://creativecommons.org/licenses/by-sa/2.0/legalcode +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/202003/20200302 How to Add New Brushes in GIMP -Quick Tip.md b/published/202003/20200302 How to Add New Brushes in GIMP -Quick Tip.md new file mode 100644 index 0000000000..4608cec762 --- /dev/null +++ b/published/202003/20200302 How to Add New Brushes in GIMP -Quick Tip.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11975-1.html) +[#]: subject: (How to Add New Brushes in GIMP [Quick Tip]) +[#]: via: (https://itsfoss.com/add-brushes-gimp/) +[#]: author: (Community https://itsfoss.com/author/itsfoss/) + +快速技巧:如何在 GIMP 中添加新画笔 +====== + +[GIMP][1] 是最流行的自由开源的图像编辑器,它也许是 Linux 上最好的 [Adobe Photoshop 替代品][2]。 + +当你[在 Ubuntu 或其他任何操作系统上安装了 GIMP 后][3],你会发现已经安装了一些用于基本图像编辑的画笔。如果你需要更具体的画笔,你可以随时在 GIMP 中添加新画笔。 + +怎么样?让我在这个快速教程中向你展示。 + +### 如何在 GIMP 中添加画笔 + +![][4] + +在 GIMP 中安装新画笔需要三个步骤: + +* 获取新画笔 +* 将其放入指定的文件夹中 +* 刷新 GIMP 中的画笔 + +#### 步骤 1:下载新的 GIMP 画笔 + +第一步是获取新的 GIMP 画笔。你从哪里获取?当然是从互联网上。 + +你可以在 Google 或[如 Duck Duck Go 这种隐私搜索引擎][5]来搜索 “GIMP brushes”,并从网站下载一个你喜欢的。 + +GIMP 画笔通常以 .gbr 和 .gih 文件格式提供。.gbr 文件用于常规画笔,而 .gih 用于动画画笔。 + +> 你知道吗? +> +> 从 2.4 版本起,GIMP 使安装和使用 Photoshop 画笔(.abr 文件)非常简单。你只需将 Photoshop 画笔文件放在正确的文件夹中。 +> +> 请记住,最新的 Photoshop 画笔可能无法完美地在 GIMP 中使用。 + +#### 步骤 2:将新画笔复制到它的位置 + +获取画笔文件后,下一步是复制该文件并将其粘贴到 GIMP 配置目录中所在的文件夹。 + +> 在微软 Windows 上,你必须进入类似 `C:\Documents and Settings\myusername.gimp-2.10\brushes` 这样的文件夹。 + +我将展示 Linux 上的详细步骤,因为我们是一个专注于 Linux 的网站。 + +选择画笔文件后,在家目录中按下 `Ctrl+h` [查看 Linux 中的隐藏文件][6]。 + +![Press Ctrl+H to see hidden files in the home directory][7] + +你应该进入 `.config/GIMP/2.10/brushes` 文件夹(如果你使用的是 GIMP 2.10)。如果使用其他版本,那么应在 `.config/GIMP` 下看到相应文件夹。 + +![Adding New Brushes in GIMP][8] + +将画笔文件粘贴到此文件夹中。可选地,你可以通过再次按 `Ctrl+h` 来隐藏隐藏的文件。 + +#### 步骤 3:刷新画笔(避免重启 GIMP) + +GIMP 将在启动时自动加载画笔。如果已在运行,并且不想关闭它,你可以刷新画笔。 + +在 GIMP 的主菜单中找到 “Windows->Dockable Dialogues->Brushes”。 + +![Refresh GIMP Brushes by going go to Windows->Dockable Dialogues-> Brushes][9] + +在右侧栏的 Brushes 对话框中找到“refresh”图标。 + +![Refresh GIMP Brushes][10] + +如果你的画笔没有出现,那么你可以试试重启 GIMP。 + +> 额外的技巧! +> +> 在 [GIMP 中添加新画笔还能让你轻松给图片添加水印][11]。只需将 logo 用作画笔,并点击一下就可添加到图片中。 + +我希望你喜欢这个快速 GIMP 技巧。敬请期待更多。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/add-brushes-gimp/ + +作者:[Community][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://www.gimp.org/ +[2]: https://itsfoss.com/open-source-photoshop-alternatives/ +[3]: https://itsfoss.com/gimp-2-10-release/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/Install-New-Brushes-in-GIMP.jpg?ssl=1 +[5]: https://itsfoss.com/privacy-search-engines/ +[6]: https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/adding-brushes-GIMP-1.jpg?ssl=1 +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/adding-brushes-GIMP.png?ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/Refresh-GIMP-Brushes.jpg?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/Refresh-GIMP-Brushes-2.jpg?ssl=1 +[11]: https://itsfoss.com/add-watermark-gimp-linux/ diff --git a/published/202003/20200302 Install GNU Emacs on Windows.md b/published/202003/20200302 Install GNU Emacs on Windows.md new file mode 100644 index 0000000000..7432b0e600 --- /dev/null +++ b/published/202003/20200302 Install GNU Emacs on Windows.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11971-1.html) +[#]: subject: (Install GNU Emacs on Windows) +[#]: via: (https://opensource.com/article/20/3/emacs-windows) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Windows 上安装 GNU Emacs +====== + +> 即使你的操作系统是闭源的,你仍然可以使用这个流行的开源文本编辑器。 + +![](https://img.linux.net.cn/data/attachment/album/202003/08/094942ihwcnsqojnup46wo.jpg) + +GNU Emacs 是一个专为各种程序员设计的流行的文本编辑器。因为它是在 Unix 上开发的,并在 Linux(macOS 中也有)上得到了广泛使用,所以人们有时没有意识到它也可用于微软 Windows 上。你也无需成为有经验的或专职的程序员即可使用 Emacs。只需单击几下就可以下载并安装 Emacs,本文向你展示了如何进行。 + +你可以手动安装 Windows,也可以使用包管理器安装,例如 [Chocolatey][2]。 + +### 7-zip + +如果还没在 Windows 中安装 7-zip,那么就先安装它。[7-zip][3] 是一个开源的归档程序,能够创建和解压 ZIP、7z、TAR、XZ、BZIP2 和 GZIP(以及更多)文件。对于 Windows 用户来说,这是一个宝贵的工具。 + +安装 7-zip 后,在 Windows 资源管理器中浏览文件时,右键单击菜单中就有新的 7-zip 归档选项。 + +### Powershell 和 Chocolatey + +要在 Windows 上使用 Chocolatey 安装 GNU Emacs : + +``` +PS> choco install emacs-full +``` + +安装后,在 Powershell 中启动 Emacs: + +``` +PS> emacs +``` + +![Emacs running on Windows][4] + +### 下载适用于 Windows 的 GNU Emacs + +要在 Windows 上手动安装 GNU Emacs,你必须[下载 Emacs][5]。 + +![GNU Windows downloader][6] + +它会打开连接到离你最近的服务器,并展示所有可用的 Emacs 版本。找到发行版本号最高的目录,然后单击进入。Windows 有许多不同的 Emacs 构建,但是最通用的版本只是被命名为 `emacs-VERSION-ARCHITECTURE.zip`。`VERSION` 取决于你要下载的版本,而 `ARCHITECTURE` 取决于你使用的是 32 位还是 64 位计算机。大多数现代计算机都是 64 位的,但是如果你有疑问,可以下载 32 位版本,它可在两者上运行。 + +如果要下载 64 位计算机的 Emacs v26,你应该点击 `emacs-26.2-x86_64.zip` 的链接。有较小的下载包(例如 “no-deps” 等),但是你必须熟悉如何从源码构建 Emacs,知道它需要哪些库以及你的计算机上已经拥有哪些库。通常,获取较大版本的 Emacs 最容易,因为它包含了在计算机上运行所需的一切。 + +### 解压 Emacs + +接下来,解压下载的 ZIP 文件。要解压缩,请右键单击 Emacs ZIP 文件,然后从 7-zip 子菜单中选择 “Extract to Emacs-VERSION”。这是一个很大的压缩包,因此解压可能需要一段时间,但是完成后,你将拥有一个新目录,其中包含与 Emacs 一起分发的所有文件。例如,在此例中,下载了 `emacs-26.2-x86_64.zip`,因此解压后的目录为 `emacs-26.2-x86_64`。 + +### 启动 Emacs + +在 Emacs 目录中,找到 `bin` 目录。此文件夹存储随 Emacs 一起分发的所有二进制可执行文件(EXE 文件)。双击 `emacs.exe` 文件启动应用。 + +![Emacs running on Windows][7] + +你可以在桌面上创建 `emacs.exe` 的快捷方式,以便于访问。 + +### 学习 Emacs + +Emacs 并不像传闻那样难用。它具有自己的传统和惯例,但是当你其中输入文本时,你可以像在记事本或者网站的文本框中那样使用它。 + +重要的区别是在你*编辑*输入的文本时。 + +但是,学习的唯一方法是开始使用它,因此,使 Emacs 成为完成简单任务的首选文本编辑器。当你通常打开记事本、Word 或 Evernote 或其他工具来做快速笔记或临时记录时,请启动 Emacs。 + +Emacs 以基于终端的应用而闻名,但它显然有 GUI,因此请像使用其他程序一样经常使用它的 GUI。从菜单而不是使用键盘复制、剪切和粘贴(paste)(或用 Emacs 的术语 “yank”),然后从菜单或工具栏打开和保存文件。从头开始,并根据应用本身来学习它,而不是根据你以往对其他编辑器的经验就认为它应该是怎样。 + +- 下载[速查表][8]! + +感谢 Matthias Pfuetzner 和 Stephen Smoogen。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/emacs-windows + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows_building_sky_scale.jpg?itok=mH6CAX29 (Tall building with windows) +[2]: https://github.com/chocolatey/choco +[3]: https://www.7-zip.org/ +[4]: https://opensource.com/sites/default/files/uploads/windows-ps-choco-emacs.jpg (Emacs running on Windows) +[5]: https://www.gnu.org/software/emacs/download.html +[6]: https://opensource.com/sites/default/files/uploads/windows-emacs-download.jpg (GNU Windows downloader) +[7]: https://opensource.com/sites/default/files/uploads/windows-emacs.jpg (Emacs running on Windows) +[8]: https://opensource.com/downloads/emacs-cheat-sheet diff --git a/published/202003/20200303 Getting started with the Rust package manager, Cargo.md b/published/202003/20200303 Getting started with the Rust package manager, Cargo.md new file mode 100644 index 0000000000..55f3f7491d --- /dev/null +++ b/published/202003/20200303 Getting started with the Rust package manager, Cargo.md @@ -0,0 +1,561 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11977-1.html) +[#]: subject: (Getting started with the Rust package manager, Cargo) +[#]: via: (https://opensource.com/article/20/3/rust-cargo) +[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) + +Rust 包管理器 Cargo 入门 +====== + +> 了解 Rust 的软件包管理器和构建工具。 + +![](https://img.linux.net.cn/data/attachment/album/202003/09/104906tdl21k977t8999qt.jpg) + +[Rust][2] 是一种现代编程语言,可提供高性能、可靠性和生产力。几年来,它一直被 StackOverflow 调查评为[最受欢迎的语言][3]。 + +除了是一种出色的编程语言之外,Rust 还具有一个称为 Cargo 的构建系统和软件包管理器。Cargo 处理许多任务,例如构建代码、下载库或依赖项等等。这两者捆绑在一起,因此在安装 Rust 时会得到 Cargo。 + +### 安装 Rust 和 Cargo + +在开始之前,你需要安装 Rust 和 Cargo。Rust 项目提供了一个可下载的脚本来处理安装。要获取该脚本,请打开浏览器以访问 [https://sh.rustup.rs][4] 并保存该文件。阅读该脚本以确保你对它的具体行为有所了解,然后再运行它: + +``` +$ sh ./rustup.rs +``` + +你也可以参考这个[安装 Rust][5] 的网页以获取更多信息。 + +安装 Rust 和 Cargo 之后,你必须获取source `env` 文件中的配置: + +``` +$ source $HOME/.cargo/env +``` + +更好的办法是,将所需目录添加到 `PATH` 环境变量中: + +``` +export PATH=$PATH:~/.cargo/bin +``` + +如果你更喜欢使用软件包管理器(例如 Linux 上的 DNF 或 Apt),请在发行版本的存储库中查找 Rust 和 Cargo 软件包,并进行相应的安装。 例如: + +``` +$ dnf install rust cargo +``` + +安装并设置它们后,请验证你拥有的 Rust 和 Cargo 版本: + +``` +$ rustc --version +rustc 1.41.0 (5e1a79984 2020-01-27) +$ cargo --version +cargo 1.41.0 (626f0f40e 2019-12-03) +``` + +### 手动构建和运行 Rust + +从在屏幕上打印“Hello, world!”的简单程序开始。打开你喜欢的文本编辑器,然后键入以下程序: + +``` +$ cat hello.rs +fn main() { +    println!("Hello, world!"); +} +``` + +以扩展名 `.rs` 保存文件,以将其标识为 Rust 源代码文件。 + +使用 Rust 编译器 `rustc` 编译程序: + +``` +$ rustc hello.rs +``` + +编译后,你将拥有一个与源程序同名的二进制文件: + +``` +$ ls -l +total 2592 +-rwxr-xr-x. 1 user group 2647944 Feb 13 14:14 hello +-rw-r--r--. 1 user group      45 Feb 13 14:14 hello.rs +$ +``` + +执行程序以验证其是否按预期运行: + +``` +$ ./hello +Hello, world! +``` + +这些步骤对于较小的程序或任何你想快速测试的东西就足够了。但是,在进行涉及到多人的大型程序时,Cargo 是前进的最佳之路。 + +### 使用 Cargo 创建新包 + +Cargo 是 Rust 的构建系统和包管理器。它可以帮助开发人员下载和管理依赖项,并帮助创建 Rust 包。在 Rust 社区中,Rust 中的“包”通常被称为“crate”(板条箱),但是在本文中,这两个词是可以互换的。请参阅 Rust 社区提供的 Cargo [FAQ][6] 来区分。 + +如果你需要有关 Cargo 命令行实用程序的任何帮助,请使用 `--help` 或 `-h` 命令行参数: + +``` +$ cargo –help +``` + +要创建一个新的包,请使用关键字 `new`,跟上包名称。在这个例子中,使用 `hello_opensource` 作为新的包名称。运行该命令后,你将看到一条消息,确认 Cargo 已创建具有给定名称的二进制包: + +``` +$ cargo new hello_opensource +     Created binary (application) `hello_opensource` package +``` + +运行 `tree` 命令以查看目录结构,它会报告已创建了一些文件和目录。首先,它创建一个带有包名称的目录,并且在该目录内有一个存放你的源代码文件的 `src` 目录: + +``` +$ tree . +. +└── hello_opensource +    ├── Cargo.toml +    └── src +        └── main.rs + +2 directories, 2 files +``` + +Cargo 不仅可以创建包,它也创建了一个简单的 “Hello, world” 程序。打开 `main.rs` 文件看看: + +``` +$ cat hello_opensource/src/main.rs +fn main() { +    println!("Hello, world!"); +} +``` + +下一个要处理的文件是 `Cargo.toml`,这是你的包的配置文件。它包含有关包的信息,例如其名称、版本、作者信息和 Rust 版本信息。 + +程序通常依赖于外部库或依赖项来运行,这使你可以编写应用程序来执行不知道如何编码或不想花时间编码的任务。你所有的依赖项都将在此文件中列出。此时,你的新程序还没有任何依赖关系。打开 `Cargo.toml` 文件并查看其内容: + +``` +$ cat hello_opensource/Cargo.toml +[package] +name = "hello_opensource" +version = "0.1.0" +authors = ["user "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +``` + +### 使用 Cargo 构建程序 + +到目前为止,一切都很顺利。现在你已经有了一个包,可构建一个二进制文件(也称为可执行文件)。在此之前,进入包目录: + +``` +$ cd hello_opensource/ +``` + +你可以使用 Cargo 的 `build` 命令来构建包。注意消息说它正在“编译”你的程序: + +``` +$ cargo build +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 0.38s +``` + +运行 `build` 命令后,检查项目目录发生了什么: + +``` +$ tree . +. +├── Cargo.lock +├── Cargo.toml +├── src +│   └── main.rs +└── target +    └── debug +        ├── build +        ├── deps +        │   ├── hello_opensource-147b8a0f466515dd +        │   └── hello_opensource-147b8a0f466515dd.d +        ├── examples +        ├── hello_opensource +        ├── hello_opensource.d +        └── incremental +            └── hello_opensource-3pouh4i8ttpvz +                ├── s-fkmhjmt8tj-x962ep-1hivstog8wvf +                │   ├── 1r37g6m45p8rx66m.o +                │   ├── 2469ykny0eqo592v.o +                │   ├── 2g5i2x8ie8zed30i.o +                │   ├── 2yrvd7azhgjog6zy.o +                │   ├── 3g9rrdr4hyk76jtd.o +                │   ├── dep-graph.bin +                │   ├── query-cache.bin +                │   ├── work-products.bin +                │   └── wqif2s56aj0qtct.o +                └── s-fkmhjmt8tj-x962ep.lock + +9 directories, 17 files +``` + +哇!编译过程产生了许多中间文件。另外,你的二进制文件将以与软件包相同的名称保存在 `./target/debug` 目录中。 + +### 使用 Cargo 运行你的应用程序 + +现在你的二进制文件已经构建好了,使用 Cargo 的 `run` 命令运行它。如预期的那样,它将在屏幕上打印 `Hello, world!`。 + +``` +$ cargo run +    Finished dev [unoptimized + debuginfo] target(s) in 0.01s +     Running `target/debug/hello_opensource` +Hello, world! +``` + +或者,你可以直接运行二进制文件,该文件位于: + +``` +$ ls -l ./target/debug/hello_opensource +-rwxr-xr-x. 2 root root 2655552 Feb 13 14:19 ./target/debug/hello_opensource +``` + +如预期的那样,它产生相同的结果: + +``` +$ ./target/debug/hello_opensource +Hello, world! +``` + +假设你需要重建包,并丢弃早期编译过程创建的所有二进制文件和中间文件。Cargo 提供了一个方便的`clean` 选项来删除所有中间文件,但源代码和其他必需文件除外: + +``` +$ cargo clean +$ tree . +. +├── Cargo.lock +├── Cargo.toml +└── src +    └── main.rs + +1 directory, 3 files +``` + +对程序进行一些更改,然后再次运行以查看其工作方式。例如,下面这个较小的更改将 `Opensource` 添加到 `Hello, world!` 字符串中: + +``` +$ cat src/main.rs +fn main() { +    println!("Hello, Opensource world!"); +} +``` + +现在,构建该程序并再次运行它。这次,你会在屏幕上看到 `Hello, Opensource world!`: + +``` +$ cargo build +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 0.39s + +$ cargo run +    Finished dev [unoptimized + debuginfo] target(s) in 0.01s +     Running `target/debug/hello_opensource` +Hello, Opensource world! +``` + +### 使用 Cargo 添加依赖项 + +Cargo 允许你添加程序需要运行的依赖项。使用 Cargo 添加依赖项非常容易。每个 Rust 包都包含一个 `Cargo.toml` 文件,其中包含一个依赖关系列表(默认为空)。用你喜欢的文本编辑器打开该文件,找到 `[dependencies]` 部分,然后添加要包含在包中的库。例如,将 `rand` 库添加为依赖项: + +``` +$ cat Cargo.toml +[package] +name = "hello_opensource" +version = "0.1.0" +authors = ["test user "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rand = "0.3.14" +``` + +试试构建你的包,看看会发生什么。 + +``` +$ cargo build +    Updating crates.io index +   Compiling libc v0.2.66 +   Compiling rand v0.4.6 +   Compiling rand v0.3.23 +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 4.48s +``` + +现在,Cargo 会联系 [Crates.io][9](这是 Rust 用于存储 crate(或包)的中央仓库),并下载和编译 `rand`。但是,等等 —— `libc` 包是怎么回事?你没有要安装 libc 啊。是的,`rand` 包依赖于 `libc` 包;因此,Cargo 也会下载并编译 `libc`。 + +库的新版本会不断涌现,而 Cargo 提供了一种使用 `update` 命令更新其所有依赖关系的简便方法: + +``` +cargo update +``` + +你还可以选择使用 `-p` 标志跟上包名称来更新特定的库: + +``` +cargo update -p rand +``` + +### 使用单个命令进行编译和运行 + +到目前为止,每当对程序进行更改时,都先使用了 `build` 之后是 `run`。有一个更简单的方法:你可以直接使用 `run` 命令,该命令会在内部进行编译并运行该程序。要查看其工作原理,请首先清理你的软件包目录: + +``` +$ cargo clean +$ tree . +. +├── Cargo.lock +├── Cargo.toml +└── src +    └── main.rs + +1 directory, 3 files +``` + +现在执行 `run`。输出信息表明它已进行编译,然后运行了该程序,这意味着你不需要每次都显式地运行 `build`: + +``` +$ cargo run +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 0.41s +     Running `target/debug/hello_opensource` +Hello, world! +``` + +### 在开发过程中检查代码 + +在开发程序时,你经常会经历多次迭代。你需要确保你的程序没有编码错误并且可以正常编译。你不需要负担在每次编译时生成二进制文件的开销。Cargo 为你提供了一个 `check` 选项,该选项可以编译代码,但跳过了生成可执行文件的最后一步。首先在包目录中运行 `cargo clean`: + +``` +$ tree . +. +├── Cargo.lock +├── Cargo.toml +└── src +    └── main.rs + +1 directory, 3 files +``` + +现在运行 `check` 命令,查看对目录进行了哪些更改: + +``` +$ cargo check +    Checking hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 0.18s +``` + +该输出显示,即使在编译过程中创建了中间文件,但没有创建最终的二进制文件或可执行文件。这样可以节省一些时间,如果该包包含了数千行代码,这非常重要: + +``` +$ tree . +. +├── Cargo.lock +├── Cargo.toml +├── src +│   └── main.rs +└── target +    └── debug +        ├── build +        ├── deps +        │   ├── hello_opensource-842d9a06b2b6a19b.d +        │   └── libhello_opensource-842d9a06b2b6a19b.rmeta +        ├── examples +        └── incremental +            └── hello_opensource-1m3f8arxhgo1u +                ├── s-fkmhw18fjk-542o8d-18nukzzq7hpxe +                │   ├── dep-graph.bin +                │   ├── query-cache.bin +                │   └── work-products.bin +                └── s-fkmhw18fjk-542o8d.lock + +9 directories, 9 files +``` + +要查看你是否真的节省了时间,请对 `build` 和 `check` 命令进行计时并进行比较。首先,计时 `build` 命令: + +``` +$ time cargo build +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 0.40s + +real    0m0.416s +user    0m0.251s +sys     0m0.199s +``` + +在运行 `check` 命令之前清理目录: + +``` +$ cargo clean +``` + +计时 `check` 命令: + +``` +$ time cargo check +    Checking hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 0.15s + +real    0m0.166s +user    0m0.086s +sys     0m0.081s +``` + +显然,`check` 命令要快得多。 + +### 建立外部 Rust 包 + +到目前为止,你所做的这些都可以应用于你从互联网上获得的任何 Rust crate。你只需要下载或克隆存储库,移至包文件夹,然后运行 `build` 命令,就可以了: + +``` +git clone +cd +cargo build +``` + +### 使用 Cargo 构建优化的 Rust 程序 + +到目前为止,你已经多次运行 `build`,但是你注意到它的输出了吗?不用担心,再次构建它并密切注意: + +``` +$ cargo build +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished dev [unoptimized + debuginfo] target(s) in 0.36s +``` + +看到了每次编译后的 `[unoptimized + debuginfo]` 文本了吗?这意味着 Cargo 生成的二进制文件包含大量调试信息,并且未针对执行进行优化。开发人员经常经历开发的多次迭代,并且需要此调试信息进行分析。同样,性能并不是开发软件时的近期目标。因此,对于现在而言是没问题的。 + +但是,一旦准备好发布软件,就不再需要这些调试信息。而是需要对其进行优化以获得最佳性能。在开发的最后阶段,可以将 `--release` 标志与 `build` 一起使用。仔细看,编译后,你应该会看到 `[optimized]` 文本: + +``` +$ cargo build --release +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +    Finished release [optimized] target(s) in 0.29s +``` + +如果愿意,你可以通过这种练习来了解运行优化软件与未优化软件时节省的时间。 + +### 使用 Cargo 创建库还是二进制文件 + +任何软件程序都可以粗略地分类为独立二进制文件或库。一个独立二进制文件也许即使是当做外部库使用的,自身也是可以运行的。但是,作为一个库,是可以被另一个独立二进制文件所利用的。到目前为止,你在本教程中构建的所有程序都是独立二进制文件,因为这是 Cargo 的默认设置。 要创建一个**库**,请添加 `--lib` 选项: + +``` +$ cargo new --lib libhello +     Created library `libhello` package +``` + +这次,Cargo 不会创建 `main.rs` 文件,而是创建一个 `lib.rs` 文件。 你的库的代码应该是这样的: + +``` +$ tree . +. +└── libhello +    ├── Cargo.toml +    └── src +        └── lib.rs + +2 directories, 2 files +``` + +Cargo 就是这样的,不要奇怪,它在你的新库文件中添加了一些代码。通过移至包目录并查看文件来查找添加的内容。默认情况下,Cargo 在库文件中放置一个测试函数。 + +### 使用 Cargo 运行测试 + +Rust 为单元测试和集成测试提供了一流的支持,而 Cargo 允许你执行以下任何测试: + +``` +$ cd libhello/ + +$ cat src/lib.rs +#[cfg(test)] +mod tests { +    #[test] +    fn it_works() { +        assert_eq!(2 + 2, 4); +    } +} +``` + +Cargo 有一个方便的 `test` 命令,可以运行代码中存在的任何测试。尝试默认运行 Cargo 在库代码中放入的测试: + +``` +$ cargo test +   Compiling libhello v0.1.0 (/opensource/libhello) +    Finished test [unoptimized + debuginfo] target(s) in 0.55s +     Running target/debug/deps/libhello-d52e35bb47939653 + +running 1 test +test tests::it_works ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out + +   Doc-tests libhello + +running 0 tests + +test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out +``` + +### 深入了解 Cargo 内部 + +你可能有兴趣了解在运行一个 Cargo 命令时它底下发生了什么。毕竟,在许多方面,Cargo 只是个封装器。要了解它在做什么,你可以将 `-v` 选项与任何 Cargo 命令一起使用,以将详细信息输出到屏幕。 + +这是使用 `-v` 选项运行 `build` 和 `clean` 的几个例子。 + +在 `build` 命令中,你可以看到这些给定的命令行选项触发了底层的 `rustc`(Rust 编译器): + +``` +$ cargo build -v +   Compiling hello_opensource v0.1.0 (/opensource/hello_opensource) +     Running `rustc --edition=2018 --crate-name hello_opensource src/main.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -C debuginfo=2 -C metadata=147b8a0f466515dd -C extra-filename=-147b8a0f466515dd --out-dir /opensource/hello_opensource/target/debug/deps -C incremental=/opensource/hello_opensource/target/debug/incremental -L dependency=/opensource/hello_opensource/target/debug/deps` +    Finished dev [unoptimized + debuginfo] target(s) in 0.36s +``` + +而 `clean` 命令表明它只是删除了包含中间文件和二进制文件的目录: + +``` +$ cargo clean -v +    Removing /opensource/hello_opensource/target +``` + +### 不要让你的技能生锈 + +要扩展你的技能,请尝试使用 Rust 和 Cargo 编写并运行一个稍微复杂的程序。很简单就可以做到:例如,尝试列出当前目录中的所有文件(可以用 9 行代码完成),或者尝试自己回显输入。小型的实践应用程序可帮助你熟悉语法以及编写和测试代码的过程。 + +本文为刚起步的 Rust 程序员提供了大量信息,以使他们可以开始入门 Cargo。但是,当你开始处理更大、更复杂的程序时,你需要对 Cargo 有更深入的了解。当你准备好迎接更多内容时,请下载并阅读 Rust 团队编写的开源的《[Cargo 手册][10]》,看看你可以创造什么! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/rust-cargo + +作者:[Gaurav Kamathe][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gkamathe +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-containers2.png?itok=idd8duC_ (Shipping containers stacked in a yard) +[2]: https://www.rust-lang.org/ +[3]: https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages +[4]: https://sh.rustup.rs/ +[5]: https://www.rust-lang.org/tools/install +[6]: https://doc.rust-lang.org/cargo/faq.html +[7]: mailto:user@mail.com +[8]: mailto:test@mail.com +[9]: http://crates.io +[10]: https://doc.rust-lang.org/cargo diff --git a/published/202003/20200303 Session- An Open Source Private Messenger That Doesn-t Need Your Phone Number.md b/published/202003/20200303 Session- An Open Source Private Messenger That Doesn-t Need Your Phone Number.md new file mode 100644 index 0000000000..1d98fdf187 --- /dev/null +++ b/published/202003/20200303 Session- An Open Source Private Messenger That Doesn-t Need Your Phone Number.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11982-1.html) +[#]: subject: (Session: An Open Source Private Messenger That Doesn’t Need Your Phone Number) +[#]: via: (https://itsfoss.com/session-messenger/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Session:一款不需要电话号码的开源通信应用 +====== + +Signal 作为一款私人通信应用,正在变得愈发流行。而我们下面要介绍开源应用 Session 则是 Signal 的一个复刻fork,它的一大亮点是并不需要提供手机号码即可以开始使用。 + +### Session:一款真正意义上的私人通信应用 + +![][1] + +对于私人通信服务来说,有没有既能保护通信安全性,又尊重用户跨平台隐私的集大成者呢?很多注重个人隐私的用户似乎都在寻找这个问题的答案。 + +最近,我留意到 [Loki 基金会][3]开发的一款叫做 [Session][2] 的开源通信应用。从技术上来说,Session 是另一款[开源、加密的通信应用 Signal][4] 的一个复刻。 + +在本文中,我会讲述我自己使用 Session 的体验,以及 Session 的一些主要功能。 + +Session 在这个领域中算是一款比较新的应用了,因此我还会在文章的最后提到它的一些不足之处。 + +### Session 的一些主要功能 + +接下来我会重点介绍 Session 的主要功能,可以供你参考这款应用是否值得使用。 + +#### Session 的使用过程中不需要提供手机号码 + +![][5] + +在 Signal 或者其它类似的通信应用中,用户都需要提供手机号码才得以成功注册。注重隐私的用户们都认为这样的做法会潜藏着巨大的安全隐患。 + +而使用 Session 则简单得多。在 PC 或手机上安装应用之后,只需要点击“创建账号Create Account”,无须提供手机号码,它就会生成一个类似 05652245af9a8bfee4f5a8138fd5c..... 这样的随机且唯一的 Session ID。 + +此后,把 Session ID 分享给想要添加的联系人就可以了。Session 还支持二维码,其他人可以通过扫描二维码添加你的 Session ID 为好友。 + +#### Session 使用了区块链等加密技术 + +![Session ID][6] + +对[区块链][7]有所了解的用户都很期待区块链能为普罗大众做出什么有实际意义的应用,而 Session 可以算得上其中一个。尽管 Session 的核心是基于区块链的,但普通用户在使用时并不需要真正弄懂区块链。 + +如果你好奇它的工作原理,可以参考这篇[官方的博客文章][8],里面有相关的解释。 + +#### 跨平台支持 + +![][9] + +这样严格保护隐私的应用,是否能在不同平台上使用? + +答案是肯定的。首先,它支持 Linux 和 Android 平台,同时也支持 Windows/Mac/iOS 平台。因此跨平台、跨设备的消息同步是没有问题的。 + +#### 包含基本隐私选项 + +![][10] + +毫无疑问,基本的隐私功能是必须有的,这是作为一个以安全为卖点的应用所必备的体验。 + +最基本的选项包括: + +* **消息有效期**:你可以控制一条消息在接收者阅读前的保留时长 +* **已读回执**:消息发送者可以知晓你已经阅读该消息 + +#### Session 使用去中心化网络保护你的元数据 + +尽管 Session 不使用端对端peer-to-peer技术,但它也不使用中心化的服务器。 + +Session 采用了去中心化的架构实现消息的传输和路由。如果你不熟悉这方面的内容,可以关注 Session 的官方博客,尝试了解[中心化网络和去中心化网络的区别][11],以及它的实际工作原理。 + +同时,这样的网络架构还有助于保护诸如与 IP 地址相关的信息等元数据。 + +#### 其它功能 + +除了专注于隐私之外,Session 也支持群聊、语音消息、发送附件等通信应用的基本功能。 + +### 在 Linux 上安装 Session + +在[官方下载页面][12]中可以下载到对应的 .AppImage 文件。如果你不了解这个文件的使用方法,可以查阅我们的[相关文章][13]。 + +另外,你也可以在它的 [Github 发布页面][14] 获取到对应的 .deb 安装文件。 + +- [下载 Session][12] + +### 我使用 Session 的体验 + +我在各种平台上都试用过 Session,其中在 PC 上我使用了 Pop!\_OS 19.10 的 .AppImage 文件运行这个应用。 + +总的来说,使用的体验很不错,用户界面也没有出现问题。 + +在设置中备份了密码(也称为种子seed)后,可以很方便地恢复账号。 + +![][15] + +当然,我也发现了一些需要改进的地方: + +* 在接受好友请求时会出现延迟 +* 设备间连接的方式不太直观 +* 当你在不同的设备上使用同一个 Session ID 向同一个人回复消息时,对方会收到两个不同的对话 + +### 总结 + +当然,最完美的事物是不存在的。我也会一直使用 Session 并考虑它发展的方向,这是一个注重隐私的用户应该做的事情。 + +欢迎在评论区发表你的看法。 + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/session-messenger/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/session-app.jpg?ssl=1 +[2]: https://getsession.org/ +[3]: https://loki.foundation/ +[4]: https://linux.cn/article-11764-1.html +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/02/session-create.jpg?ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/session-application-id.jpg?ssl=1 +[7]: https://en.wikipedia.org/wiki/Blockchain +[8]: https://getsession.org/how-session-protects-your-anonymity-with-blockchain-and-crypto/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/session-cross-platform.jpg?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/session-settings.jpg?fit=800%2C512&ssl=1 +[11]: https://getsession.org/centralisation-vs-decentralisation-in-private-messaging/ +[12]: https://getsession.org/download/ +[13]: https://itsfoss.com/use-appimage-linux/ +[14]: https://github.com/loki-project/session-desktop/releases +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/session-seed.jpg?ssl=1 diff --git a/published/202003/20200304 Drauger OS Linux Aims to Bring Console Gaming Experience on the Desktop.md b/published/202003/20200304 Drauger OS Linux Aims to Bring Console Gaming Experience on the Desktop.md new file mode 100644 index 0000000000..d574442156 --- /dev/null +++ b/published/202003/20200304 Drauger OS Linux Aims to Bring Console Gaming Experience on the Desktop.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11972-1.html) +[#]: subject: (Drauger OS Linux Aims to Bring Console Gaming Experience on the Desktop) +[#]: via: (https://itsfoss.com/drauger-os/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Drauger OS Linux 旨在为台式机带来主机游戏体验 +====== + +多年来(或数十年),人们抱怨不[使用Linux][1] 的原因之一是它缺乏主流游戏。[Linux 上的游戏][2]在最近几年有了显著改进,特别是 [Steam Proton][3] 项目的引入使你可以[在 Linux 上玩很多 Windows 专用的游戏][4]。 + +这也鼓励了一些[以游戏为中心的 Linux发行版][5]。以 [Lakka][6] 为例,你可以[借助 Lakka Linux 将旧计算机变成复古的街机游戏机][7]。 + +另一个以游戏为中心的 Linux 发行版是 [Draguer OS][8],我们今天将对其进行研究。 + +### Drauger OS + +根据[该项目的网站][9],“Drauger OS 是 Linux 桌面游戏操作系统。它旨在为游戏玩家提供一个平台,使他们可以在不牺牲安全性的情况下获得出色的性能。此外,它旨在使任何人都可以轻松玩游戏,无论他们使用键盘和鼠标还是某种控制器。” + +他们强调 Drauger OS 并非供日常使用。因此,大多数其他发行版附带的许多生产力工具都不在 Drauger OS 中。 + +![Drauger OS 7.4.1][10] + +Drauger OS [基于][9] Ubuntu 之上。当前版本(7.4.1 Jiangshi)使用 “[Liquorix][11] 低延迟Linux 内核,这是一种预编译的 ZEN 内核,设计时考虑了延迟和吞吐量之间的平衡”。但是,这将在下一版本中更改。他们只有一个桌面环境可供选择,即一个修改版本的 [Xfce][12]。 + +Drauger OS 开箱即用地安装了多个应用程序和工具,以改善游戏体验。这些包括: + +* [PlayOnLinux][13] +* WINE +* [Lutris][14] +* Steam +* [DXVK][15] + +它还具有一组与游戏无关的有趣工具。[Drauger 安装器][16]是 .deb 安装程序,是 Gdebi 的替代品。[多软件库应用安装器][17](mrai)是“用于基于 Debian 的 Linux 操作系统的类似于 AUR-helper 的脚本”。Mrai 旨在与 apt、snap、flatpaks 配合使用,并且可以从 GitHub 安装应用程序。 + +有趣的是,Drauger OS 的名称是一个错误。开发负责人 [Thomas Castleman][18](即 batcastle)曾打算为其发行版命名为 Draugr,但是却打错了名字。在 Drauger OS 播客的[第 23 集][19]中,Castleman 说会保留这个拼写错误的名称,因为要对其进行更正需要大量工作。根据 [Wikipedia][20] 的描述,Draugr 是“来自北欧神话中的不死生物”。 + +是的,你没看错。Drauger OS 是仅有的几个具有自己的[播客][21]的发行版之一。当被问到这个问题时,Castleman 告诉我:“无论他们的情况如何,我都希望确保我们的社区拥有最大的透明度。”多数情况下,播客是 Drauger OS 博客的音频版本,但有时他们会在没有时间撰写博客文章时使用它来发布公告。 + +### Drauger OS 的未来 + +![Drauger OS][22] + +Druager OS 背后的开发人员正在开发其下一个主要版本:7.5.1。此版本将基于 Ubuntu 19.10。将有三个主要变化。首先,将使用“我们内部构建的内核” [替换][23] Liquorix 内核。该内核将基于 Linux 内核 GitHub 存储库,“因此,它会变得越来越原汁原味”。 + +新版本的第二个主要变化将是为其桌面提供新布局。根据用户的反馈,他们决定将其更改为看起来更类似于 GNOME 的样子。 + +第三,他们放弃了 SystemBack 作为其备份工具和安装程序。相反,他们从头开始编写了新的[安装程序][24]。 + +开发团队也正在研究 Drauger OS 的 [ARM 版本][25]。他们希望在 2022 年的某个时候发布它。 + +### 系统要求 + +Drauger OS [系统要求][25]非常适中。请记住,Drauger OS 仅在 64 位系统上运行。 + +#### 最低系统要求 + +* CPU:双核、1.8GHz、64 位处理器 +* RAM:1 GB +* 储存空间:16 GB +* 图形处理器:集成 +* 屏幕分辨率:60Hz 时为 1024×768 +* 外部端口:1 个用于显示的端口(HDMI/DisplayPort/VGA/DVI),2 个用于安装 USB 驱动器和键盘的 USB 端口(鼠标可选,但建议使用) + +#### 推荐系统要求 + +* CPU:四核、2.2Ghz、64 位处理器 +* RAM:4 GB +* 储存空间:128 GB +* 图形处理器:NVIDIA GTX 1050、AMD RX 460 或同等显卡 +* 屏幕分辨率:60Hz 时为 1080p +* 外部端口:1 个用于显示的端口(HDMI/DisplayPort/VGA/DVI),3 个用于安装 USB 驱动器、键盘和鼠标的 USB 端口,1 个音频输出端口 + +### 如何为Drauger OS提供帮助 + +如果你有兴趣,可以通过多种方法来帮助 Drauger OS。他们一直在寻找[财政支持][26]以保持发展。 + +如果你想贡献代码,他们正在寻找具有 BASH、C++ 和 Python 经验的人员。他们所有的代码都在 [GitHub][27] 上。你也可以在社交媒体上[联系][28]他们。 + +### 结语 + +Drauger OS 只是这类项目之一。我还见过其他[面向游戏的发行版][29],但 Drauger OS 在专注于游戏方面一心一意。由于我更喜欢休闲游戏,因此该发行版对我个人而言并不具有吸引力。但是,我可以看到它如何吸引游戏爱好者使用 Linux。祝他们在以后的发行中好运。 + +你对这个仅限于游戏的发行版有何想法?你最喜欢的 Linux 游戏解决方案是什么?请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/drauger-os/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/why-use-linux/ +[2]: https://linux.cn/article-7316-1.html +[3]: https://linux.cn/article-10054-1.html +[4]: https://itsfoss.com/steam-play/ +[5]: https://itsfoss.com/linux-gaming-distributions/ +[6]: http://www.lakka.tv/ +[7]: https://itsfoss.com/lakka-retrogaming-linux/ +[8]: https://draugeros.org/go/ +[9]: https://www.draugeros.org/go/about/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/drauger-os-7.4.1.jpg?ssl=1 +[11]: https://liquorix.net/ +[12]: https://www.xfce.org/ +[13]: https://www.playonlinux.com/en/ +[14]: https://lutris.net/ +[15]: https://github.com/doitsujin/dxvk +[16]: https://github.com/drauger-os-development/drauger-installer +[17]: https://github.com/drauger-os-development/mrai +[18]: https://github.com/Batcastle +[19]: https://anchor.fm/drauger-os/episodes/Episode-23-eapu47 +[20]: https://en.wikipedia.org/wiki/Draugr +[21]: https://anchor.fm/drauger-os +[22]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/02/drauger-os-7.5.1.png?ssl=1 +[23]: https://www.draugeros.org/go/2020/01/20/major-changes-in-drauger-os-7-5-1/ +[24]: https://github.com/drauger-os-development/system-installer +[25]: https://www.draugeros.org/go/system-requirements/ +[26]: https://www.draugeros.org/go/contribute/ +[27]: https://github.com/drauger-os-development +[28]: https://www.draugeros.org/go/contact-us/ +[29]: https://itsfoss.com/manjaro-gaming-linux/ +[30]: https://reddit.com/r/linuxusersgroup diff --git a/published/202003/20200305 Install and Use Wireshark on Ubuntu Linux.md b/published/202003/20200305 Install and Use Wireshark on Ubuntu Linux.md new file mode 100644 index 0000000000..ec70ef40a8 --- /dev/null +++ b/published/202003/20200305 Install and Use Wireshark on Ubuntu Linux.md @@ -0,0 +1,216 @@ +[#]: collector: (lujun9972) +[#]: translator: (qianmingtian) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11987-1.html) +[#]: subject: (Install and Use Wireshark on Ubuntu Linux) +[#]: via: (https://itsfoss.com/install-wireshark-ubuntu/) +[#]: author: (Community https://itsfoss.com/author/itsfoss/) + +Ubuntu 上 Wireshark 的安装与使用 +====== + +> 在本教程中,你将学习如何在 Ubuntu 和其它基于 Ubuntu 的发行版上安装最新的 Wireshark。同时你也将学习如何在没有 sudo 的情况下来运行 Wireshark,以及如何设置它来进行数据包嗅探。 + +[Wireshark][1] 是一款自由开源的网络协议分析器,它在全球被广泛使用。 + +通过使用 Wireshark,你可以实时捕获网络的传入和传出数据包,并将其用于网络故障排除、数据包分析、软件和通信协议开发等。 + +它适用于所有主流的桌面操作系统,如 Windows、Linux、macOS、BSD 等。 + +在本教程中,我将指导你在 Ubuntu 和其他基于 Ubuntu 的发行版上安装 Wireshark 。我还将介绍如何设置和配置 Wireshark 来捕获数据包。 + +### 在基于 Ubuntu 的 Linux 发行版上安装 Wireshark + +![][2] + +Wireshark 适用于所有主流 Linux 发行版。你应该查看[官方安装说明][3]。因为在本教程中,我将着重在仅基于 Ubuntu 的发行版上安装最新版本的 Wireshark 。 + +Wireshark 可以在 Ubuntu 的 Universe 存储库中找到。你可以[启用 universe 存储库][4],然后按如下方式安装: + +``` +sudo add-apt-repository universe +sudo apt install wireshark +``` + +这种方法的一个小问题是,你可能并不总是得到最新版本的 Wireshark 。 + +例如,在 Ubuntu 18.04 中,如果你使用 [apt][5] 命令检查 Wireshark 的可用版本,可用版本会显示是 2.6 。 + +``` +abhishek@nuc:~$ apt show wireshark +Package: wireshark +Version: 2.6.10-1~ubuntu18.04.0 +Priority: optional +Section: universe/net +Origin: Ubuntu +Maintainer: Balint Reczey +``` + +然而, [Wireshark 3.2 稳定版][6]已经在几个月前发布了。当然,新版本拥有新的特性。 + +那么在这种情况下,你应该怎么办呢?谢天谢地, Wireshark 开发者提供了一种官方 PPA 方式,你可以使用它在 Ubuntu 和其它基于 Ubuntu 的发行版上安装最新稳定版本的 Wireshark. + +我希望你熟悉 PPA。如果没有,请[阅读我们关于 PPA 的优秀指南,以便完全理解它][7]。 + +打开终端并逐个使用以下命令: + +``` +sudo add-apt-repository ppa:wireshark-dev/stable +sudo apt update +sudo apt install wireshark +``` + +即使安装了旧版本的 Wireshark ,它也将更新为新版本。 + +安装时,系统将询问你是否允许非超级用户捕获数据包。选择“Yes”允许,选择“No”限制非超级用户捕获数据包,最后完成安装。 + +### 不使用 sudo 运行 Wireshark + +如果在上一次安装中选择了“No”,则以 root 用户身份运行以下命令: + +``` +sudo dpkg-reconfigure wireshark-common +``` + +然后按 `tab` 键并使用回车键选择“No”: + +![][8] + +由于你允许非超级用户捕获数据包,因此你必须将该用户添加到 `wireshark` 组。使用 [usermod][9] 命令将自己添加到 `wireshark` 组。 + +``` +sudo usermod -aG wireshark $(whoami) +``` + +最后,[重启你的 Ubuntu 系统][10]对你的系统进行必要的修改。 + +> 冷知识 +> +> Wireshark 于 1998 年首次发布,最初被称为 Ethereal 。2006 年,由于商标问题,开发商不得不将其名称改为 Wireshark 。 + +### 启动 Wireshark + +你可以从应用程序启动器或者命令行启动 Wireshark 应用。 + +如果从命令行启动,只需要在你的控制台中输入 `wireshark`: + +``` +wireshark +``` + +要是从**图形化界面**启动,需要在搜索栏搜索 Wireshark 应用,并按回车键。 + +![][11] + +现在,让我们来玩玩 Wireshark 吧。 + +### 使用 Wireshark 捕获数据包 + +当你启动 Wireshark 的时候,你会看到一个接口列表,你可以使用它来捕获这个接口接收和发送的数据包。 + +你可以使用 Wireshark 监视许多类型的接口,例如,有线、外部设备等。根据你的偏好,你可以从下图中的标记区域选择在欢迎屏幕中显示特定类型的接口。 + +![Select interface][12] + +例如,我只列出了**有线**网络接口。 + +![][13] + +接下来,要开始捕获数据包,你必须选择接口(在我的示例中是 `ens33` ),然后单击“Start capturing packets”图标,如下图所示。 + +![Start capturing packets with Wireshark][14] + +你还可以同时从多个接口捕获数据包。只需按住 `CTRL` 按钮,同时单击要捕获的接口,然后点击“Start capturing packets”图标,如下图所示。 + +![][15] + +接下来,我尝试在终端中使用 `ping google.com` 命令,如你所见,捕获了许多数据包。 + +![Captured packets][16] + +现在你可以选择任何数据包来检查该特定数据包。在点击一个特定的包之后,你可以看到与它相关的 TCP/IP 协议的不同层的信息。 + +![Packet info][17] + +你还可以在底部看到该特定数据包的原始数据,如下图所示。 + +![Check RAW data in the captured packets][18] + +> 这就是为什么端到端加密很重要。 +> +> 假设你正在登录一个不使用 HTTPS 的网站。与你在同一网络上的任何人都可以嗅探数据包,并在原始数据中看到用户名和密码。 +> +> 这就是为什么现在大多数聊天应用程序使用端到端加密,而大多数网站使用 https (而不是 http)。 + +#### 在 Wireshark 中停止数据包捕获 + +你可以点击如图所示的红色图标停止捕获数据包。 + +![Stop packet capture in Wireshark][19] + +#### 将捕获的数据包保存成文件 + +你可以单击下图中标记的图标,将捕获的数据包保存到文件中以备将来使用。 + +![Save captured packets by Wireshark][20] + + +**注意**:输出可以导出为 XML、PostScript、CSV 或纯文本。 + +接下来,选择一个目标文件夹,键入文件名并单击“Save”。 + +然后选择文件并单击“Open”。 + +![][21] + +现在你可以随时打开和分析保存的数据包。要打开文件,请按 `\+o`,或从 Wireshark 转到 “File > Open”。 + +捕获的数据包将从文件中加载。 + +![][22] + +### 结语 + +Wireshark 支持许多不同的通信协议。有许多选项和功能,使你能够以独特的方式捕获和分析网络数据包。你可以从 Wireshark 的[官方文档][23]了解更多关于 Wireshark 的信息。 + +我希望这个教程能帮助你在 Ubuntu 上安装 Wireshark 。请让我知道你的问题和建议。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-wireshark-ubuntu/ + +作者:[Kushal Rai][a] +选题:[lujun9972][b] +译者:[qianmingtian][c] +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[c]: https://github.com/qianmingtian +[1]: https://www.wireshark.org/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/wireshark_ubuntu.png?ssl=1 +[3]: https://www.wireshark.org/docs/wsug_html_chunked/ChBuildInstallUnixInstallBins.html +[4]: https://itsfoss.com/ubuntu-repositories/ +[5]: https://itsfoss.com/apt-command-guide/ +[6]: https://www.wireshark.org/news/20191218.html +[7]: https://itsfoss.com/ppa-guide/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/yes.png?ssl=1 +[9]: https://linuxhandbook.com/usermod-command/ +[10]: https://itsfoss.com/schedule-shutdown-ubuntu/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/wire.png?ssl=1 +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/interfaces.jpg?ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/intoption.jpg?ssl=1 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/singleinterface.jpg?ssl=1 +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/selint.jpg?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/capture.jpg?ssl=1 +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/packetinfo.png?ssl=1 +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/raw.png?ssl=1 +[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/stopcapture.png?ssl=1 +[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/savepackets.jpg?ssl=1 +[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/savename.jpg?ssl=1 +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/openpacket.png?ssl=1 +[23]: https://www.wireshark.org/docs/https://www.wireshark.org/docs/ +[24]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/kushal_rai.jpg?ssl=1 diff --git a/published/202003/20200306 Communicating with other users on the Linux command line.md b/published/202003/20200306 Communicating with other users on the Linux command line.md new file mode 100644 index 0000000000..b5af59b838 --- /dev/null +++ b/published/202003/20200306 Communicating with other users on the Linux command line.md @@ -0,0 +1,143 @@ +[#]: collector: (lujun9972) +[#]: translator: (linusboyle) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12023-1.html) +[#]: subject: (Communicating with other users on the Linux command line) +[#]: via: (https://www.networkworld.com/article/3530343/communicating-with-other-users-on-the-linux-command-line.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 Linux 命令行与其他用户进行通信 +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/22/171055z3q772v2zq320zx3.jpg) + +使用 Linux 命令行向其他用户发送消息或许非常容易,这里有一些相关的命令你可以考虑使用。在这篇文章中,我们会考察 4 个这样的命令,看看它们是怎么工作的。 + +### wall + +`wall`(“Write ALL” 的简称)命令允许你向所有系统中已登录的用户发送一条信息。这里我们假设用户都使用命令行在同一台服务器上工作。虽然 `wall` 命令最常被系统管理员用于向用户发布公告和传递信息(比如说,服务器即将因维护而关闭),但它可以被任何用户使用。 + +系统管理员可能会用类似下面的方式发送信息: + +``` +$ wall The system will be going down in 15 minutes to address a serious problem +``` + +而所有登录的用户都将看到类似这样的信息: + +``` +Broadcast message from admin@dragonfly (pts/0) (Thu Mar 5 08:56:42 2020): +The system is going down in 15 minutes to address a serious problem +``` + +如果希望在消息中使用单引号,你可以像这样将信息用双引号括起来: + +``` +$ wall "Don't forget to save your work before logging off" +``` + +最外层的双引号不会出现在发出的消息中,但是如果没有它们,`wall` 会停下并等待输入一个配对的单引号。 + +### mesg + +如果出于某种理由你不想接收来自另一个用户的消息,你可以使用 `mesg` 命令来屏蔽这些消息。这个命令可以接受一个 `n` 作为参数来拒绝某用户的消息,或者接收一个 `y` 作为参数来接收用户发来的消息。 + +``` +$ mesg n doug +$ mesg y doug +``` + +被屏蔽的用户不会被告知这一事实。你也可以像这样使用 `mesg` 来屏蔽或者接收所有消息: + +``` +$ mesg y +$ mesg n +``` + +### write + +另一个在不使用电子邮件的情况下发送文本的命令是 `write`,这个命令可以用来和一个特定的用户通信。 + +``` +$ write nemo +Are you still at your desk? +I need to talk with you right away. +^C +``` + +输入你的信息后用 `ctrl-c` 退出,这样就完成了通信。这个命令允许你发送文本,但并不会建立一个双向的通话。它只是将文本发送过去而已。如果目标用户在多个终端上登录,你可以指定你想将消息发送到哪一个终端,否则系统会选择空闲时间最短的那个终端。 + +``` +$ write nemo#1 +``` + +如果你试图向一个将消息屏蔽了的用户发送信息,你应该会看到这样的输出: + +``` +$ write nemo +write: nemo has messages disabled +``` + +### talk/ytalk + +`talk` 和 `ytalk` 命令让你可以和一个或多个用户进行交互式的聊天。它们会展示一个有上下两个子窗口的界面,每个用户向显示在他们屏幕上方的窗口内输入内容,并在下方的窗口看到回复信息。要回复一个`talk` 请求,接收方可以输入 `talk`,在后面加上请求方的用户名。 + +``` +Message from Talk_Daemon@dragonfly at 10:10 ... +talk: connection requested by dory@127.0.0.1. +talk: respond with: talk dory@127.0.0.1 + +$ talk dory +``` + +如果使用的是 `ytalk`,那么窗口中可以包含多于两个参与者。正如下面的例子所展示的(这是上面 `talk dory` 命令的结果),`talk` 通常指向 `ytalk`。 + +``` +----------------------------= YTalk version 3.3.0 =-------------------------- +Is the report ready? + +-------------------------------= nemo@dragonfly =---------------------------- +Just finished it +``` + +如上所述,在通话的另一侧,`talk`会话界面的窗口是相反的: + +``` +----------------------------= YTalk version 3.3.0 =-------------------------- +Just finished it + +-------------------------------= dory@dragonfly =---------------------------- +Is the report ready? +``` + +同样的,使用 `ctrl-c` 来退出。 + +如果要和非本机的用户通讯,你需要加上 `-h` 选项和目标主机名或IP地址,就像这样: + +``` +$ talk -h 192.168.0.11 nemo +``` + +### 总结 + +Linux 上有若干基本的命令可以用来向其他登录的用户发送消息。如果你需要向所有用户快速发送信息或是需要便捷的电话替代品,又或是希望能简单地开始一个多用户快速通讯会话,这些命令会十分实用。 + +一些命令如 `wall` 允许广播消息但却不是交互式的。另外的一些命令如 `talk` 允许多用户进行长时间通讯,当你只需要非常快速地交换一些信息,它们可以你你避免建立一个电话会议。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3530343/communicating-with-other-users-on-the-linux-command-line.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[linusboyle](https://github.com/linusboyle) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/202003/20200306 Three Ways to Exclude-Hold-Prevent a Specific Package from an apt Upgrade.md b/published/202003/20200306 Three Ways to Exclude-Hold-Prevent a Specific Package from an apt Upgrade.md new file mode 100644 index 0000000000..f005d928fa --- /dev/null +++ b/published/202003/20200306 Three Ways to Exclude-Hold-Prevent a Specific Package from an apt Upgrade.md @@ -0,0 +1,182 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11992-1.html) +[#]: subject: (Three Ways to Exclude/Hold/Prevent a Specific Package from an apt Upgrade) +[#]: via: (https://www.2daygeek.com/debian-ubuntu-exclude-hold-prevent-packages-from-apt-get-upgrade/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +从 apt 升级中排除/保留/阻止特定软件包的三种方法 +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/13/103902tfyv8eeuo5jf9ifo.jpg) + +有时,由于某些应用依赖性,你可能会意外更新不想更新的软件包。这在全系统更新或自动包升级时经常会发生。如果发生这种情况,可能会破坏应用的功能。这会造成严重的问题,你需要花费大量时间来解决问题。 + +如何避免这种情况?如何从 `apt-get` 更新中排除软件包? + +> 如果你要[从 Yum Update 中排除特定软件包][1],请参考这篇。 + +是的,可以在 Debian 和 Ubuntu 系统上使用以下三种方法来完成。 + +* [apt-mark 命令][2] +* [dpkg 命令][3] +* aptitude 命令 + +我们将分别详细展示。 + +### 方法 1:如何使用 apt-mark 命令排除 Debian/Ubuntu 系统上的软件包更新 + +`apt-mark` 用于将软件包标记/取消标记为自动安装。 + +`hold` 选项用于将软件包标记为保留,以防止软件包被自动安装、升级或删除。 + +`unhold` 选项用于取消先前面的设置,以允许重复执行所有操作。 + +运行以下命令以使用 `apt-mark` 命令保留指定的软件包。 + +``` +$ sudo apt-mark hold nano +nano set on hold. +``` + +保留软件包后,请运行以下 `apt-mark` 命令查看它们。 + +``` +$ sudo apt-mark showhold +nano +``` + +这表明在执行完整的系统更新时,不会升级 nano 包。 + +``` +$ sudo apt update + +Reading package lists… Done +Building dependency tree +Reading state information… Done +Calculating upgrade… Done +The following packages have been kept back: + nano +0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. +``` + +运行以下命令,使用 `apt-mark` 命令取消保留 nano 包。 + +``` +$ sudo apt-mark unhold nano +Canceled hold on nano. +``` + +### 方法 2:如何使用 dpkg 命令在 Debian/Ubuntu 系统上排除软件包更新 + +`dpkg` 命令是一个 CLI 工具,用于安装、构建、删除和管理 Debian 软件包。`dpkg` 的主要且更用户友好的前端是 `aptitude`。 + +运行以下命令使用 `dpkg` 命令阻止给定的软件包。 + +语法: + +``` +$ echo "package_name hold" | sudo dpkg --set-selections +``` + +运行以下 `dpkg` 命令以保留 apache2 包。 + +``` +$ echo "apache2 hold" | sudo dpkg --set-selections +``` + +保留软件包后,请运行以下命令查看它们。 + +``` +$ sudo dpkg --get-selections | grep "hold" +apache2 hold +``` + +它会显示在执行完整的系统更新时,不会升级 apache2包。 + +``` +$ sudo apt update + +Reading package lists… Done +Building dependency tree +Reading state information… Done +Calculating upgrade… Done +The following packages have been kept back: + apache2 +0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. +``` + +运行以下命令,使用 `dpkg` 命令取消对指定软件包的保留。 + +语法: + +``` +$ echo "package_name install" | sudo dpkg --set-selections +``` + +运行以下命令,使用 `dpkg` 命令取消保留 apache2 包。 + +``` +$ echo "apache2 install" | sudo dpkg --set-selections +``` + +### 方法 3:如何使用 aptitude 命令排除 Debian/Ubuntu 系统上的软件包更新 + +`aptitude` 命令是 Debian 及其衍生版本的基于文​​本的软件包管理界面。 + +它允许用户查看软件包列表并执行软件包管理任务,例如安装、升级和删除软件包。它可以从可视界面或命令行执行操作。 + +运行以下命令,使用 `aptitude` 命令保留指定的软件包。 + +``` +$ sudo aptitude hold python3 +``` + +保留某些软件包后,请运行以下命令查看它们。 + +``` +$ sudo dpkg --get-selections | grep "hold" +或者 +$ sudo apt-mark showhold + +python3 +``` + +这表明在执行完整的系统更新时,不会升级 python3 软件包。 + +``` +$ sudo apt update + +Reading package lists… Done +Building dependency tree +Reading state information… Done +Calculating upgrade… Done +The following packages have been kept back: + python3 +0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded. +``` + +使用 `aptitude ` 命令运行以下命令以解除对 python3 软件包的保留。 + +``` +$ sudo aptitude unhold python3 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/debian-ubuntu-exclude-hold-prevent-packages-from-apt-get-upgrade/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/redhat-centos-yum-update-exclude-specific-packages/ +[2]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[3]: https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/ diff --git a/published/202003/20200309 6 Raspberry Pi tutorials to try out.md b/published/202003/20200309 6 Raspberry Pi tutorials to try out.md new file mode 100644 index 0000000000..a15b85f450 --- /dev/null +++ b/published/202003/20200309 6 Raspberry Pi tutorials to try out.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12005-1.html) +[#]: subject: (6 Raspberry Pi tutorials to try out) +[#]: via: (https://opensource.com/article/20/3/raspberry-pi-tutorials) +[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett) + +6 个可以尝试的树莓派教程 +====== + +> 这些树莓派项目均旨在简化你的生活并提高生产力。 + +![](https://img.linux.net.cn/data/attachment/album/202003/17/142619e7jbh7dj5448nf1i.jpg) + +没有什么比体验树莓派创作结果更令人兴奋了。经过数小时的编程、测试和徒手构建,你的项目终于开始成形,你不禁大喊 “哇哦!”树莓派可以带给日常生活的可能性让我着迷。无论你是想学习新知识、尝试提高效率还是只是乐在其中,本文总有一个树莓派项目适合你。 + +### 设置 VPN 服务器 + +本[教程][2]教你如何使用树莓派添加一个网络安全层。这个项目不仅有实际好处,而且还能为你带来很多乐趣。额外的安全性使你可以放心地做其它项目,例如下面列出的项目。 + +### 创建一个物体跟踪摄像机 + +树莓派之所以具有吸引力,是因为它提供了较低的入门门槛来学习机器学习等新技术。这份[分步指南][3]提供了详尽的说明,说明了如何构建一个全景摄像头,以便使用 TensorFlow 和树莓派跟踪运动。 + +### 使用照片幻灯片展示你最喜欢的回忆 + +你是否曾经问过自己:“我应该怎么处理这些数码照片?”。如果你像我一样这样想过,那么答案是“是”。在朋友和家人圈子中,我被公认为摄像爱好者。这就是为什么我喜欢这个树莓派项目。在[本教程][4]中,你将学习如何设置照片幻灯片,以便轻松地在家里展示自己喜欢的回忆,而无需打印机! + +### 玩复古电子游戏 + +如果你对复古游戏系统怀有怀旧之情,那么可以尝试[本教程][5]。了解包括树莓派在内的哪些设备可以运行 Amiga 模拟器。完成设置后,你将可在树莓派上玩自己喜欢的 Amiga 游戏。 + +### 为你的娱乐中心搭建时钟 + +在过去的十年中,家庭娱乐中心发生了很大的变化。我的家人完全依靠流媒体服务来观看节目和电影。我之所以爱它是因为我可以通过移动设备或语音助手控制电视。但是,当你不再能一眼看到时钟时,便会失去一定程度的便利!请遵循[这些步骤][6],使用树莓派从头开始搭建自己的时钟显示。 + +### 扩大自制啤酒的生产规模 + +在[本教程][7]中,经验丰富的家庭酿酒师分享了他建立电动啤酒酿造系统的经验。该项目需要在硬件和零件上进行更多的前期投资,但由此产生的效率和一致性让这些值得。为此祝贺! + +如果你是像我这样的树莓派新手,那么我建议你阅读我们这些可下载的树莓派指南。我们的[单页速查表][8]提供了入门指南。有关更多技巧和教程,我们的[综合指南][9]涵盖了一些主题,例如选择树莓派、保持更新、为社区做出贡献等。 + +你会尝试哪个树莓派项目?让我们在评论中知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/raspberry-pi-tutorials + +作者:[Lauren Pritchett][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lauren-pritchett +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi_cartoon.png?itok=m3TcBONJ (Cartoon graphic of Raspberry Pi board) +[2]: https://opensource.com/article/19/6/raspberry-pi-vpn-server +[3]: https://opensource.com/article/20/1/object-tracking-camera-raspberry-pi +[4]: https://opensource.com/article/19/2/wifi-picture-frame-raspberry-pi +[5]: https://opensource.com/article/19/3/amiga-raspberry-pi +[6]: https://opensource.com/article/17/7/raspberry-pi-clock +[7]: https://opensource.com/article/17/7/brewing-beer-python-and-raspberry-pi +[8]: https://opensource.com/downloads/getting-started-raspberry-pi-cheat-sheet +[9]: https://opensource.com/downloads/raspberry-pi-guide diff --git a/published/202003/20200310 2020 Will Be a Year of Hindsight for SD-WAN.md b/published/202003/20200310 2020 Will Be a Year of Hindsight for SD-WAN.md new file mode 100644 index 0000000000..6b4c3c1886 --- /dev/null +++ b/published/202003/20200310 2020 Will Be a Year of Hindsight for SD-WAN.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (hkurj) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12034-1.html) +[#]: subject: (2020 Will Be a Year of Hindsight for SD-WAN) +[#]: via: (https://www.networkworld.com/article/3531315/2020-will-be-a-year-of-hindsight-for-sd-wan.html) +[#]: author: (Zeus Kerravala https://www.networkworld.com/author/Zeus-Kerravala/) + +2020 年将是 SD-WAN 的回顾之年 +====== + +![](https://images.idgesg.net/images/article/2020/03/istock-1127447341-100834720-large.jpg) + +对于软件定义的广域网(SD-WAN),“过去看起来困难的选择,知道了这些选择的结果后,现在看起来就很清晰了” 这一说法再合适不过了。总结过去的几年:云计算和数字化转型促使公司重新评估传统的 WAN 技术,该技术不再能够满足其不断增长的业务需求。从那时起,SD-WAN 成为一种有前途的新技术。 + +SD-WAN 旨在解决物理设备的流量管理问题,并支持从云进行基于软件的配置。许多最初的 SD-WAN 部署都因希望取代昂贵的多协议标签交换 (MPLS) 而得到推动。公司希望它可以神奇地解决他们所有的网络问题。但是在实践中,基本的 SD-WAN 解决方案远没有实现这一愿景。 + +快速发展到现在,围绕 SD-WAN 的炒作已经尘埃落定,并且早期的实施工作已经过去。现在是时候回顾一下我们在 2019 年学到的东西以及在 2020 年要改进的地方。所以,让我们开始吧。 + +### 1、这与节省成本无关 + +大多数公司选择 SD-WAN 作为 MPLS 的替代品,因为它可以降低 WAN 成本。但是,[节省的成本][1]会因 SD-WAN 的不同而异,因此不应将其用作部署该技术的主要驱动力。无论公司需要什么,公司都应该专注于提高网络敏捷性,例如实现更快的站点部署和减少配置时间。SD-WAN 的主要驱动力是使网络更高效。如果成功实现那么成本也会随之降低。 + +### 2、WAN 优化是必要的 + +说到效率,[WAN 优化][2]提高了应用程序和数据流量的性能。通过应用协议加速、重复数据消除、压缩和缓存等技术,WAN 优化可以增加带宽、减少延迟并减轻数据包丢失。最初的想法是 SD-WAN 可以完成对 WAN 优化的需求,但是我们现在知道某些应用程序需要更多的性能支持。这些技术相互补充,而不是相互替代。它们应该用来解决不同的问题。 + +### 3、安全性不应该事后考虑 + +SD-WAN 具有许多优点,其中之一就是使用宽带互联网快速发送企业应用程序流量。但是这种方法也带来了安全风险,因为它使用户及其本地网络暴露于不受信任的公共互联网中。从一开始,安全性就应该成为 SD-WAN 实施的一部分,而不是在事后。公司可以通过使用[安全的云托管][3]之类的服务,将安全性放在分支机构附近,从而实现所需的应用程序性能和保护。 + +### 4、可见性对于 SD-WAN 成功至关重要 + +在应用程序和数据流量中具有[可见性][4],这使网络管理不再需要猜测。最好的起点是部署前阶段,在此阶段,公司可以在实施 SD-WAN 之前评估其现有功能以及缺少的功能。可见性以日常监控和警报的形式在部署后继续发挥重要作用。了解网络中正在发生的情况的公司会更好地准备应对性能问题,并可以利用这些知识来避免将来出现问题。 + +### 5、无线广域网尚未准备就绪 + +SD-WAN 可通过包括宽带和 4G/LTE 无线在内的任何传输将用户连接到应用程序。这就是[移动互联][5]越来越多地集成到 SD-WAN 解决方案中的原因。尽管公司渴望将 4G 用作潜在的传输替代方案(尤其是在偏远地区),但由此带来的按使用付费 4G 服务成本却很高。此外,由于延迟和带宽限制,4G 可能会出现问题。最好的方法是等待服务提供商部署具有更好的价格选择的 5G。今年我们将看到 5G 的推出,并更加关注无线 SD-WAN。 + +请务必观看以下 SD-WAN 视频系列:[你应该知道的所有关于 SD-WAN 的知识][6]。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3531315/2020-will-be-a-year-of-hindsight-for-sd-wan.html + +作者:[Zeus Kerravala][a] +选题:[lujun9972][b] +译者:[hkurj](https://github.com/hkurj) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Zeus-Kerravala/ +[b]: https://github.com/lujun9972 +[1]: https://blog.silver-peak.com/to-maximize-the-value-of-sd-wan-look-past-hardware-savings +[2]: https://blog.silver-peak.com/sd-wan-vs-wan-optimization +[3]: https://blog.silver-peak.com/sd-wans-enable-scalable-local-internet-breakout-but-pose-security-risk +[4]: https://blog.silver-peak.com/know-the-true-business-drivers-for-sd-wan +[5]: https://blog.silver-peak.com/mobility-and-sd-wan-part-1-sd-wan-with-4g-lte-is-a-reality +[6]: https://www.silver-peak.com/everything-you-need-to-know-about-sd-wan diff --git a/published/202003/20200310 Basilisk- A Firefox Fork For The Classic Looks and Classic Extensions.md b/published/202003/20200310 Basilisk- A Firefox Fork For The Classic Looks and Classic Extensions.md new file mode 100644 index 0000000000..b15e81597e --- /dev/null +++ b/published/202003/20200310 Basilisk- A Firefox Fork For The Classic Looks and Classic Extensions.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12001-1.html) +[#]: subject: (Basilisk: A Firefox Fork For The Classic Looks and Classic Extensions) +[#]: via: (https://itsfoss.com/basilisk-browser/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Basilisk:一个有着经典的外观和扩展的 Firefox 复刻 +====== + +> Basilisk 是一个 Firefox 复刻,它支持旧版的扩展等更多功能。在这里,我们看一下它的功能并尝试一下。 + +![](https://img.linux.net.cn/data/attachment/album/202003/16/130319lvls6fvsaslzllrv.jpg) + +### Basilisk:基于 XUL 的开源 Web 浏览器 + +尽管最好使用 Linux 上的常规浏览器(如 Firefox 或 Chromium),但了解其他浏览器也没坏处。最近,我偶然发现了一个 Firefox 复刻:[Basilisk][1] 浏览器,它有经典的 Firefox 用户界面以及对旧版扩展的支持(就像 [Waterfox][2] 一样)。 + +![itsfoss.com homepage on Basilisk][3] + +如果你迫切需要使用旧版扩展程序或怀念 Firefox 的经典外观,Basilisk 浏览器可以帮到你。这个浏览器是由 [Pale Moon][4] 浏览器背后的团队维护(这是我接下来要介绍的另一个 Firefox 复刻)。 + +如果你正在寻找开源 [Chrome 替代品][5],那么你可以快速了解一下 Basilisk 提供的功能。 + +**注意:**Basilisk 是开发中软件。即使我在使用时没有遇到重大的可用性问题,但你也不应依赖它作为唯一使用的浏览器。 + +### Basilisk 浏览器的特性 + +![][6] + +Basilisk 开箱即用。但是,在考虑使用之前,可能需要先看一下以下这些特性: + +* 基于 [XUL][7] 的 Web 浏览器 +* 它具有 “Australis” Firefox 界面,这在 v29–v56 的 Firefox 版本中非常流行。 +* 支持 [NPAPI][8] 插件(Flash、Unity、Java 等) +* 支持 XUL/Overlay Mozilla 形式的扩展。 +* 使用 [Goanna][9] 开源浏览器引擎,它是 Mozilla [Gecko][10] 的复刻 +* 不使用 Rust 或 Photon 用户界面 +* 仅支持 64 位系统 + +### 在 Linux 上安装 Basilisk + +你可能没有在软件中心中找到它。因此,你必须前往其官方[下载页面][11]获得 tarball(tar.xz)文件。 + +下载后,只需将其解压缩并进入文件夹。接下来,你将在其中找到一个 `Basilisk` 可执行文件。你只需双击或右键单击并选择 “运行” 即可运行它。 + +你可以查看它的 [GitHub 页面][12]获取更多信息。 + +![][13] + +你也可以按照下面的步骤使用终端进入下载的文件夹,并运行文件: + +``` +cd basilisk-latest.linux64 +cd basilisk +./basilisk +``` + +- [下载 Basilisk][1] + +### 使用 Basilisk 浏览器 + +![][14] + +如果你想要支持旧版扩展,Basilisk 是不错的 Firefox 复刻。它是由 Pale Moon 背后的团队积极开发的,对于希望获得 Mozilla Firefox(在 Quantum 更新之前)经典外观,且不包括现代 Web 支持的用户而言,它可能是一个不错的选择。 + +浏览网页没有任何问题。但是,我注意到 YouTube 将其检测为过时的浏览器,并警告说它将很快停止支持它。 + +**因此,我不确定 Basilisk 是否适合所有现有的 Web 服务 —— 但是,如果你确实需要使用 Firefox 较早版本中的扩展,那这是一个解决方案。** + +### 总结 + +你认为这个 Firefox 复刻值得尝试吗?你喜欢哪个?在下面的评论中分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/basilisk-browser/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://www.basilisk-browser.org/ +[2]: https://itsfoss.com/waterfox-browser/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/basilisk-itsfoss.jpg?ssl=1 +[4]: https://www.palemoon.org +[5]: https://itsfoss.com/open-source-browsers-linux/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/basilisk-options-1.jpg?ssl=1 +[7]: https://developer.mozilla.org/en-US/docs/Archive/Mozilla/XUL +[8]: https://wiki.mozilla.org/NPAPI +[9]: https://en.wikipedia.org/wiki/Goanna_(software) +[10]: https://developer.mozilla.org/en-US/docs/Mozilla/Gecko +[11]: https://www.basilisk-browser.org/download.shtml +[12]: https://github.com/MoonchildProductions/Basilisk +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/basilisk-folder-1.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/basilisk-browser-1.jpg?ssl=1 diff --git a/published/202003/20200310 Containers vs. VMs, Istio in production, and more industry news.md b/published/202003/20200310 Containers vs. VMs, Istio in production, and more industry news.md new file mode 100644 index 0000000000..c897efde43 --- /dev/null +++ b/published/202003/20200310 Containers vs. VMs, Istio in production, and more industry news.md @@ -0,0 +1,85 @@ +[#]: collector: "lujun9972" +[#]: translator: "messon007" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12015-1.html" +[#]: subject: "Containers vs. VMs, Istio in production, and more industry news" +[#]: via: "https://opensource.com/article/20/3/survey-istio-industry-news" +[#]: author: "Tim Hildred https://opensource.com/users/thildred" + +每周开源点评:容器 vs 虚拟机、生产环境中的 Istio 等 +====== + +> 本文是最近一周开源社区的新闻和行业进展。 + +![Person standing in front of a giant computer screen with numbers, data][1] + +我在一家采用开源软件开发模型的企业软件公司任高级产品营销经理,我的一部分职责是为产品营销人员,经理和其他相关人定期发布有关开源社区,市场和业界发展趋势的更新。以下是该更新中我和他们最喜欢的五篇文章。 + +### 云原生应用采用的技术:容器等 + +- [文章链接][2] + +> * 在生产环境中采用容器的比例从 2018 年的 73% 上升到 2019 年的 84%。其中,运行了至少 250 个容器的比例从 2018 年的 46% 上升到 2019 年的 58%。2017 到 2019 年间, 环境中拥有 50 台以上计算机(物理或虚拟)的受访者人数从 2017 年的 77% 上升到 2019 年的 81%。 +> * 表明: 容器的引入似乎缓解了需要管理的 VM 的快速增长。但是,请警惕要管理的原始机器数量会减少的说法。 +> + +**分析**:从直觉上看,随着容器使用的增长,虚拟机的增长将放缓;有许多容器被部署在虚拟机内部,从而充分利用了两者的优势特性,而且许多应用不会很快被容器化(留意下你所在企业的传统单体式应用)。 + +### 在生产环境中运行Istio的经验 + +- [文章链接][3] + +> 在 HelloFresh,我们将团队分为小队和团伙。每个团伙都有自己的 Kubernetes 命名空间。如上所述,我们先按命名空间启用 sidecar 注入,然后再逐个对应用启用。在将应用添加到 Istio 之前,我们举办了研讨会,以使小队了解其应用发生的变化。由于我们采用“您构建,您维护”的模型,团队可以在故障定位时了解应用的进出流量。不仅如此,它还提升了公司内部的知识量。我们还创建了 Istio 相关的 [OKR][4] ,来跟踪我们的进度并达成我们引入Istio的目的。 + +**分析**:引入或是不引入技术,要由自己决定,同时要自行承担相应的后果。 + +### Aether: 首个开源的边缘云平台 + +- [文章链接][5] + +> ONF 的营销副主席 Sloane 这样解释 Aether: 它将多个正在自己的沙箱中开发和运行的项目聚集到一起,ONF 试图在该框架下将多种边缘服务在一个融合平台上支持起来。ONF 的各个项目将保持独立并可继续单独使用,但是 Aether 试图将多个能力绑定到一起来简化企业的私有边缘云运营。 +> +> 他说:“我们认为我们正在创造一个新的合作空间,工业界和社区可以携手帮助推动通用平台背后的整合和关键工作,然后可以帮助这些边缘云中的通用功能不断发展”。 + +**分析**:当今,使用技术解决的问题过于复杂,无法通过单一技术解决。比技术更重要的是要解决的业务问题需要聚焦于真正增值的部分。将两者结合起来,就是企业之间需要在他们共同的需求上找到合作的方法,并在它们特有的方面进行竞争。除了开源,你找不到比这更好的方法了。 + +### 与云相关职业的女性正在改变现状 + +- [文章链接][6] + +> Yordanova 说:“由于云是一种相对较新的技术,我的[成为一名“科技女性”][7]的经验可能并不典型,因为云行业极为多样化”。“实际上,我的团队中性别比例相当,成员由随着云技术而成长的不同个性、文化和优势的具体人员组成。“ + +**分析**:我想考虑的一件事就是跨越式的演进思路。你可能可以跳过演进过程中的某个步骤或阶段,因为原先导致其存在的条件已不再适用。云技术时代没有形成“谁发明的以及它是为谁而生”的固有说法,所以也许它所承载的某些前代的技术负担更少? + +### StarlingX 如何在中国开源项目的星空中闪耀 + +- [文章链接][8] + +> 我们的团队在中国,因此我们的任务之一是帮助中国的社区开发软件、贡献代码、文档等。大多数 StarlingX 项目会议是在中国的深夜举行,因此华人社区成员的出席和参与颇具挑战。为了克服这些障碍,我们与中国的其他社区成员(例如 99cloud 的朋友)一起采取了一些措施,例如和其他社区成员一起聚会,一起参加动手实践研讨会和中文的特设技术会议,将一些文档翻译成中文,并在微信小组中不断进行互动(就像每个人都可以享受的 24/7 通话服务一样) + +**分析**:随着中国对开源项目的贡献不断增长,这种情况似乎有可能逆转或至少相当。“学习英语”根本不是参与开源项目开发的先决条件。 + +希望你喜欢这个列表,下周再见。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/survey-istio-industry-news + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr "Person standing in front of a giant computer screen with numbers, data" +[2]: https://thenewstack.io/cncf-survey-snapshot-tech-adoption-in-the-cloud-native-world/ +[3]: https://engineering.hellofresh.com/everything-we-learned-running-istio-in-production-part-1-51efec69df65 +[4]: https://en.wikipedia.org/wiki/OKR +[5]: https://www.sdxcentral.com/articles/news/onf-projects-coalesce-for-enterprise-edge-cloud/2020/03/ +[6]: https://www.cloudpro.co.uk/leadership/cloud-essentials/8446/how-women-in-cloud-are-challenging-the-narrative +[7]: https://www.itpro.co.uk/business-strategy/33301/diversity-not-a-company-priority-claim-nearly-half-of-women-in-tech +[8]: https://superuser.openstack.org/articles/starlingx-community-interview-how-starlingx-shines-in-the-starry-sky-of-open-source-projects-in-china/ diff --git a/published/202003/20200310 Run Kubernetes on a Raspberry Pi with k3s.md b/published/202003/20200310 Run Kubernetes on a Raspberry Pi with k3s.md new file mode 100644 index 0000000000..79b42ade4d --- /dev/null +++ b/published/202003/20200310 Run Kubernetes on a Raspberry Pi with k3s.md @@ -0,0 +1,187 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12049-1.html) +[#]: subject: (Run Kubernetes on a Raspberry Pi with k3s) +[#]: via: (https://opensource.com/article/20/3/kubernetes-raspberry-pi-k3s) +[#]: author: (Lee Carpenter https://opensource.com/users/carpie) + +使用 K3s 在树莓派上运行 Kubernetes 集群 +====== + +> 跟随接下来的介绍,自己搭建一个三节点的 Kubernetes 集群。 + +![](https://img.linux.net.cn/data/attachment/album/202003/29/121559p44e3dfrerf3zver.jpg) + +我对在树莓派上搭建 [Kubernetes][2] 集群已经感兴趣很长时间了,只要照着网上的教程,我可以在由三个树莓派组成的集群中搭建一套 Kubernetes 并正常运行。但在这种情况下,主节点上的内存和 CPU 资源捉襟见肘,执行 Kubernetes 任务的时候往往性能不佳,想要升级 Kubernetes 就更不可能了。 + +这个时候,我非常激动地发现了 [K3s][3] 这个项目。K3s 被誉为在可用于资源受限环境下的轻量级 Kubernetes,它还针对 ARM 处理器做出了优化,这让 Kubernetes 集群可以在树莓派上运行得更好。在下文中,我们将会使用 K3s 来创建一个 Kubernetes 集群。 + +- [video](https://youtu.be/6PqxJhV-t1s) + +### 准备 + +要按照本文介绍的方式创建 Kubernetes 集群,首先需要准备: + +* 至少一个树莓派(包括 SD 卡和电源) +* 网线 +* 将所有树莓派连接到一起的交换机或路由器 + +我们会通过在线安装的方式安装 K3s,因此还需要可以连接到互联网。 + +### 集群概览 + +在这个集群里,我们会使用三个树莓派。其中一个树莓派作为主节点,我们将它命名为 `kmaster`,并为其分配一个静态 IP `192.168.0.50`(注:假设使用的私有网段是 192.168.0.0/24),而另外两个树莓派作为工作节点,分别命名为 `knode1` 和 `knode2`,也分别分配 `192.168.0.51` 和 `192.168.0.52` 两个 IP 地址。 + +当然,如果你实际的网络布局和上面不同,只要将文中所提及到的 IP 替换成你实际可用的 IP 就可以了。 + +为了不需要通过 IP 来引用某一个节点,我们将每个节点的主机名记录到 PC 的 `/etc/hosts` 文件当中: + +``` +echo -e "192.168.0.50\tkmaster" | sudo tee -a /etc/hosts +echo -e "192.168.0.51\tknode1" | sudo tee -a /etc/hosts +echo -e "192.168.0.52\tknode2" | sudo tee -a /etc/hosts +``` + +### 部署主节点 + +我们首先部署主节点。最开始的步骤当然是使用镜像安装最新的 Raspbian,这个步骤可以参考我的[另一篇文章][4],在这里就不展开介绍了。在安装完成之后,启动 SSH 服务,将主机名设置为 `kmaster`,然后分配静态 IP `192.168.0.50`。 + +在主节点上安装 Raspbian 完成后,启动树莓派并通过 `ssh` 连接上去: + +``` +ssh pi@kmaster +``` + +在主节点上执行以下命令安装 K3s: + +``` +curl -sfL https://get.k3s.io | sh - +``` + +等到命令跑完以后,一个单节点集群就已经运行起来了。让我们检查一下,还在这个树莓派上执行: + +``` +sudo kubectl get nodes +``` + +就会看到这样的输出: + +``` +NAME STATUS ROLES AGE VERSION +kmaster Ready master 2m13s v1.14.3-k3s.1 +``` + +### 获取连接令牌join token + +之后我们需要部署工作节点。在工作节点上安装 K3s 的时候,会需要用到连接令牌,它放置在主节点的文件系统上。首先把连接令牌保存出来以便后续使用: + +``` +sudo cat /var/lib/rancher/k3s/server/node-token +``` + +### 部署工作节点 + +通过 SD 卡在每个作为工作节点的树莓派上安装 Raspbian。在这里,我们把其中一个树莓派的主机名设置为 `knode1`,为其分配 IP 地址 `192.168.0.51`,另一个树莓派的主机名设置为 `knode2`,分配 IP 地址 `192.168.0.52`。接下来就可以安装 K3s 了。 + +启动主机名为 `knode1` 的树莓派,通过 `ssh` 连接上去: + +``` +ssh pi@knode1 +``` + +在这个树莓派上,安装 K3s 的过程和之前差不多,但需要另外加上一些参数,表示它是一个工作节点,需要连接到一个已有的集群上: + +``` +curl -sfL http://get.k3s.io | K3S_URL=https://192.168.0.50:6443 \ +K3S_TOKEN=刚才保存下来的连接令牌 sh - +``` + +`K3S_TOKEN` 的值需要替换成刚才保存下来的实际的连接令牌。完成之后,在主机名为 `knode2` 的树莓派上重复这个安装过程。 + +### 通过 PC 访问集群 + +现在如果我们想要查看或者更改集群,都必须 `ssh` 到集群的主节点才能使用 `kubectl`,这是比较麻烦的。因此我们会将 `kubectl` 放到 PC 上使用。首先,在主节点上获取一些必要的配置信息,`ssh` 到 `kmaster` 上执行: + +``` +sudo cat /etc/rancher/k3s/k3s.yaml +``` + +复制上面命令的输出,然后在你的 PC 上创建一个目录用来放置配置文件: + +``` +mkdir ~/.kube +``` + +将复制好的内容写入到 `~/.kube/config` 文件中,然后编辑该文件,将 + +``` +server: https://localhost:6443 +``` + +改为 + +``` +server: https://kmaster:6443 +``` + +出于安全考虑,只对自己保留这个配置文件的读写权限: + +``` +chmod 600 ~/.kube/config +``` + +如果 PC 上还没有安装 `kubectl` 的话,就可以开始安装了。Kubernetes 官方网站上有各种平台安装 `kubectl` 的[方法说明][5],我使用的是 Ubuntu 的衍生版 Linux Mint,所以我的安装方法是这样的: + +``` +sudo apt update && sudo apt install -y apt-transport-https +curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - +echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list +sudo apt update && sudo apt install kubectl +``` + +上面几个命令的作用是添加了一个包含 Kubernetes 的 Debian 软件库,获取 GPG 密钥以确保安全,然后更新软件包列表并安装 `kubectl`。如果 `kubectl` 有更新,我们将会通过标准软件更新机制standard software update mechanism收到通知。 + +现在在 PC 上就可以查看 Kubernetes 集群了: + +``` +kubectl get nodes +``` + +输出大概会是这样: + +``` +NAME STATUS ROLES AGE VERSION +kmaster Ready master 12m v1.14.3-k3s.1 +knode1 Ready worker 103s v1.14.3-k3s.1 +knode1 Ready worker 103s v1.14.3-k3s.1 +``` + +至此,我们已经搭建了一个三节点的 Kubernetes 集群。 + +### K3s 的彩蛋 + +如果执行 `kubectl get pods --all-namespaces`,就会看到其它服务的一些 Pod,比如 [Traefik][6]。Traefik 在这里起到是反向代理和负载均衡器的作用,它可以让流量从单个入口进入集群后引导到集群中的各个服务。Kubernetes 支持这种机制,但 Kubernetes 本身不提供这个功能,因此 Traefik 是一个不错的选择,K3s 安装后立即可用的优点也得益于此。 + +在后续的文章中,我们会继续探讨 Traefik 在 Kubernetes ingress 中的应用,以及在集群中部署其它组件。敬请关注。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/kubernetes-raspberry-pi-k3s + +作者:[Lee Carpenter][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/carpie +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_wheel_gear_devops_kubernetes.png?itok=xm4a74Kv (A ship wheel with someone steering) +[2]: https://opensource.com/resources/what-is-kubernetes +[3]: https://k3s.io/ +[4]: https://carpie.net/articles/headless-pi-with-static-ip-wired-edition +[5]: https://kubernetes.io/docs/tasks/tools/install-kubectl/ +[6]: https://traefik.io/ diff --git a/published/202003/20200311 How to install pip to manage PyPI packages easily.md b/published/202003/20200311 How to install pip to manage PyPI packages easily.md new file mode 100644 index 0000000000..b6453085c1 --- /dev/null +++ b/published/202003/20200311 How to install pip to manage PyPI packages easily.md @@ -0,0 +1,145 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11993-1.html) +[#]: subject: (How to install pip to manage PyPI packages easily) +[#]: via: (https://opensource.com/article/20/3/pip-linux-mac-windows) +[#]: author: (Vijay Singh Khatri https://opensource.com/users/vijaytechnicalauthor) + +安装 pip 轻松管理 PyPI 软件包 +====== + +> 在 Linux、Mac 或 Windows 上为旧版 Python 安装 pip。 + +![](https://img.linux.net.cn/data/attachment/album/202003/14/102539wq3a73opalpzoabb.jpg) + +Python 是一种功能强大、流行广泛的编程语言,在常规编程、数据科学等很多方面它都有丰富的软件包可供使用。但这些软件包通常都不会在 Python 安装时自动附带,而是需要由用户自行下载、安装和管理。所有的这些软件包(包括库和框架)都存放在一个名叫 [PyPI][2](也就是 Python 软件包索引 Python Package Index)的中央存储库当中,而 `pip`(也就是首选安装程序Preferred Installer Program)则是管理这个中央存储库的工具。 + +在安装 `pip` 之后,管理 PyPI 的软件包就变得很方便了。大部分的软件包都可以通过在终端或者命令行界面执行 `python -m pip install <软件包名>` 这样的命令来完成安装。 + +较新版本的 Python 3(3.4 或以上)和 Python 2(2.7.9 或以上)都已经预装了 `pip`,旧版本的 Python 没有自带 `pip`,但可以另外安装。 + +在这篇文章中,我将会介绍 `pip` 在 Linux、Mac 和 Windows 系统上的安装过程。想要了解更多详细信息,可以参考 [pip.pypa][3] 的文档。 + +### 首先需要安装 Python + +首先你的系统中需要安装好 Python,否则 `pip` 安装器无法理解任何相关的命令。你可以在命令行界面、Bash 或终端执行 `python` 命令确认系统中是否已经安装 Python,如果系统无法识别 `python` 命令,请先[下载 Python][4] 并安装。安装完成后,你就可以看到一些引导你安装 `pip` 的提示语了。 + +### 在 Linux 上安装 pip + +在不同发行版的 Linux 上,安装 `pip` 的命令也有所不同。 + +在 Fedora、RHEL 或 CentOS 上,执行以下命令安装: + +``` +$ sudo dnf install python3 +``` + +在 Debian 或 Ubuntu 上,使用 `apt` 包管理工具安装: + +``` +$ sudo apt install python3-pip +``` + +其它的发行版可能还会有不同的包管理工具,比如 Arch Linux 使用的是 `pacman`: + +``` +$ sudo pacman -S python-pip +``` + +执行 `pip --version` 命令就可以确认 `pip` 是否已经正确安装。 + +在 Linux 系统上安装 `pip` 就是这样简单,你可以直接跳到“使用 pip”部分继续阅读。 + +### 在 Mac 上安装 pip + +MacOS 已经预装了 Python,但 Python 版本一般是比较旧的。如果你要使用 Python 的话,建议[另外安装 Python 3][6]。 + +在 Mac 上可以使用 [homebrew][7] 安装 Python 3: + +``` +$ brew update && brew upgrade python +``` + +如果你安装的是以上提到的新版本 Python 3,它会自带 `pip` 工具。你可以使用以下命令验证: + +``` +$ python3 -m pip --version +``` + +如果你使用的是 Mac,安装过程也到此结束,可以从“使用 pip”部分继续阅读。 + +### 在 Windows 上安装 pip + +以下 `pip` 安装过程是针对 Windows 8 和 Windows 10 的。下面文章中的截图是 Windows 10 环境下的截图,但对 Windows 8 同样适用。 + +首先确认 [Python 已经安装完成][8]。 + +如果你想在 Windows 系统上像 Linux 一样使用包管理工具,[Chocolatey][9] 是一个不错的选择,它可以让 Python 的调用和更新变得更加方便。Chocolatey 在 PowerShell 中就可以运行,只需要简单的命令,Python 就可以顺利安装。 + +``` +PS> choco install python +``` + +接下来就可以使用 `pip` 安装所需的软件包了。 + +### 使用 pip + +在 Linux、BSD、Windows 和 Mac 上,`pip` 都是以同样的方式使用的。 + +例如安装某个库: + +``` +python3 -m pip install foo --user +``` + +卸载某个已安装的库: + +``` +python3 -m pip uninstall foo +``` + +按照名称查找软件包: + +``` +python3 -m pip search foo +``` + +将 `pip` 更新到一个新版本: + +``` +$ sudo pip install --upgrade pip +``` + +需要注意的是,在 Windows 系统中不需要在前面加上 `sudo` 命令,这是因为 Windows 通过独有的方式管理用户权限,对应的做法是[创建一个执行策略例外][10]。 + +``` +python -m pip install --upgrade pip +``` + +希望本文介绍的的方法能对你有所帮助,欢迎在评论区分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/pip-linux-mac-windows + +作者:[Vijay Singh Khatri][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/vijaytechnicalauthor +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://pypi.org/ +[3]: https://pip.pypa.io/en/stable/installing/ +[4]: https://www.python.org/downloads/ +[5]: tmp.u1JOYd3gs9#usage +[6]: https://opensource.com/article/19/5/python-3-default-mac +[7]: https://brew.sh +[8]: https://opensource.com/article/19/8/how-install-python-windows +[9]: https://opensource.com/article/20/3/chocolatey +[10]: https://opensource.com/article/20/3/chocolatey#admin diff --git a/published/202003/20200312 Amazon Has Launched Its Own Linux Distribution But It-s Not for Everyone.md b/published/202003/20200312 Amazon Has Launched Its Own Linux Distribution But It-s Not for Everyone.md new file mode 100644 index 0000000000..49d54dbc48 --- /dev/null +++ b/published/202003/20200312 Amazon Has Launched Its Own Linux Distribution But It-s Not for Everyone.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12018-1.html) +[#]: subject: (Amazon Has Launched Its Own Linux Distribution But It’s Not for Everyone) +[#]: via: (https://itsfoss.com/bottlerocket-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Amazon 推出了自己的容器专用 Linux 发行版“瓶装火箭” +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/21/074953h0a55lq72h0qlpzd.jpg) + +Amazon 已经[推出][1]了自己的基于 Linux 的开源操作系统 Bottlerocket(“瓶装火箭”)。但在你兴奋地想要尝试安装和运行它之前,我必须告诉你,它不是常规的如 Ubuntu、Fedora 或 Debian 这样的 Linux 发行版。那它是什么? + +### Bottlerocket:来自 Amazon 的 Linux 发行版,用于运行容器 + +![][2] + +如果你不了解 Linux 容器,建议你阅读 Red Hat 的[这篇文章][3]。 + +自从首次提出云计算一词以来,IT 行业发生了许多变化。得益于 Amazon AWS、Google、Linode、Digital Ocean 等云服务器提供商,部署 Linux 服务器(通常在虚拟机中运行)只需几秒钟。最重要的是,你可以借助 Docker 和 Kubernetes 之类的工具在这些服务器上以容器形式部署应用和服务。 + +问题是,当你唯一目的是在 Linux 系统上运行容器时,并不总是需要完整的 Linux 发行版。这就是为什么容器专用 Linux 仅提供必要软件包的原因。这将大大减少操作系统的大小,从而进一步减少部署时间。 + +[Bottlerocket][5] Linux 由 Amazon Web Services(AWS)专门构建,用于在虚拟机或裸机上运行容器。它支持 docker 镜像和其他遵循 [OCI 镜像][6]格式的镜像。 + +### Bottlerocket Linux 的特性 + +![][7] + +这是来自 Amazon 的新 Linux 发行版提供的特性: + +#### 没有逐包更新 + +传统的 Linux 发行版更新过程由更新单个软件包组成。Bottlerocket 改用基于镜像的更新。 + +由于采用了这种方法,可以避免冲突和破坏,并可以进行快速而完整的回滚(如有必要)。 + +#### 只读文件系统 + +Bottlerocket 还使用了只读主文件系统。在启动时通过 dm-verity 检查其完整性。在其他安全措施上,也不建议使用 SSH 访问,并且只能通过[管理容器][8](附加机制)使用。 + +AWS 已经统治了云世界。 + +#### 自动更新 + +你可以使用 Amazon EKS 之类的编排服务来自动执行 Bottlerocket 更新。 + +Amazon 还声称,与通用 Linux 发行版相比,仅包含运行容器的基本软件可以减少攻击面。 + +### 你怎么看? + +Amazon 并不是第一个创建“容器专用 Linux” 的公司。我认为 CoreOS 是最早的此类发行版之一。[CoreOS 被 Red Hat 收购][9],Red Hat 又被 [IBM 收购][10]。Red Hat 公司最近停用了 CoreOS,并用 [Fedora CoreOS][11] 代替了它。 + +云服务器是一个巨大的行业,它将继续发展壮大。像 Amazon 这样的巨头将竭尽所能与它竞争对手保持一致或领先。我认为,Bottlerocket 是对 IBM Fedora CoreOS(目前)的应答。 + +尽管 [Bottlerocket 仓库可在 GitHub 上找到][12],但我还没发现就绪的镜像(LCTT 译注:源代码已经提供)。在撰写本文时,它仅[可在 AWS 上预览][5]。 + +你对此有何看法?Amazon 会从 Bottlerocket 获得什么?如果你以前使用过 CoreOS 之类的软件,你会切换到 Bottlerocket 么? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bottlerocket-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://aws.amazon.com/blogs/aws/bottlerocket-open-source-os-for-container-hosting/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/botlerocket-logo.png?ssl=1 +[3]: https://www.redhat.com/en/topics/containers/whats-a-linux-container +[4]: https://www.linode.com/ +[5]: https://aws.amazon.com/bottlerocket/ +[6]: https://www.opencontainers.org/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/BottleRocket.png?ssl=1 +[8]: https://github.com/bottlerocket-os/bottlerocket-admin-container +[9]: https://itsfoss.com/red-hat-acquires-coreos/ +[10]: https://itsfoss.com/ibm-red-hat-acquisition/ +[11]: https://getfedora.org/en/coreos/ +[12]: https://github.com/bottlerocket-os/bottlerocket diff --git a/published/202003/20200312 How to write effective documentation for your open source project.md b/published/202003/20200312 How to write effective documentation for your open source project.md new file mode 100644 index 0000000000..1635591917 --- /dev/null +++ b/published/202003/20200312 How to write effective documentation for your open source project.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12052-1.html) +[#]: subject: (How to write effective documentation for your open source project) +[#]: via: (https://opensource.com/article/20/3/documentation) +[#]: author: (Kevin Xu https://opensource.com/users/kevin-xu) + +如何为你的开源项目编写实用的文档 +====== + +> 一份优质的文档可以让很多用户对你的项目路人转粉。 + +![](https://img.linux.net.cn/data/attachment/album/202003/29/215343srdknc1o8kplbu8z.jpg) + +好的代码很多时候并不代表一切。或许你能用最精巧的代码解决了世界上最迫切需要解决的问题,但如果你作为一个开源开发者,没能用准确的语言将你的作品公之于世,你的代码也只能成为沧海遗珠。因此,技术写作和文档编写是很重要的技能。 + +一般来说,项目中的文档是最受人关注的部分,很多用户会通过文档来决定自己是否应该对某个项目开始学习或研究。所以,我们不能忽视技术写作和文档编写的工作,尤其要重点关注其中的“入门Getting Started”部分,这会对你项目的发展起到关键性的作用。 + +对于很多人来说,写作是一件令人厌烦甚至恐惧的事情。我们这些工程师出身的人,更多学习的是“写代码”而不是学习“为代码写文档”。不少人会把英语作为自己的第二语言或者第三语言,他们可能会对英语写作感到不自信甚至害怕(我的母语是汉语,英语是作为我的第二语言学习的,所以我也能感受到这种痛苦)。 + +但如果你希望自己的项目能在全球范围内产生一定的影响力,英语就是你必须使用的语言,这是一个无法避免的现实。但不必害怕,我在写这篇文章的时候就考虑到了这些可能带来的挑战,并给出了我的一些建议。 + +### 五条有用的写作建议 + +这五条建议你马上就可以用起来,尽管看起来似乎有些浅显,但在技术写作时却经常被忽视。 + +1. **使用主动语态**:感受一下[主动语态][2]下的“你可以这样更改配置(You can change these configurations by...)”和被动语态下的“配置可以这样更改(These configurations can be changed by…)”有什么不同之处。 +2. **使用简洁明了的句子**:可以借助 [Hemingway App][3] 或者 [Grammarly][4] 这样的工具,尽管它们并不开源。 +3. **保持条理性**:你可以在文档中通过写标题、划重点、引链接等方式,把各类信息划分为不同的部分,避免将所有内容都杂糅在一大段冗长的文字当中。 +4. **提高可读性**:除了单纯的文字之外,运用图表也是从多种角度表达的手段之一。 +5. **注意拼写和语法**:必须记得检查文档中是否有拼写错误或者语法错误。 + +只要在文档的写作和编辑过程中应用到这些技巧,你就能够和读者建立起沟通和信任。 + +* **高效沟通**:对于工程师们来说,阅读长篇大论的冗长文字,还不如去看小说。在阅读技术文档时,他们总是希望能够从中快速准确地获取到有用的信息。因此,技术文档的最佳风格应该是精简而有效的,不过这并不代表文档中不能出现类似幽默、emoji 甚至段子这些东西,这些元素可以当你的文档更有个性、更使人印象深刻。当然,具体的实现方式就因人而异了 +* **建立信任**:你需要取得文档读者们的信任,这在一个项目的前期尤为重要。读者对你的信任除了来源于你代码的质量,还跟你文档编写的质量有关。所以你不仅要打磨代码,还要润色好相关的文档,这也是上面第 5 点建议拼写和语法检查的原因。 + +### 从编写“入门”文档开始 + +现在,最需要花费功夫的应该就是“入门”部分了,这是一篇技术文档最重要的部分,[二八定律][5]在这里得到了充分体现:访问一个项目的大部分流量都会落在项目文档上,而访问项目文档的大部分流量则会落在文档的“入门”部分中。因此,如果文档的“入门”部分写得足够好,项目就会吸引到很多用户,反之,用户会对你的项目敬而远之。 + +那么如何写好“入门”部分呢?我建议按照以下三步走: + +1. **任务化**:入门指南应该以任务为导向。这里的任务指的是对于开发者来说可以完成的离散的小项目,而不应该包含太多涉及到体系结构、核心概念等的抽象信息,因此在“入门”部分只需要提供一个简单明了的概述就可以了。也不要在“入门”部分大谈这个项目如何优秀地解决了问题,这个话题可以放在文档中别的部分进行说明。总而言之,“入门”部分最好是给出一些主要的操作步骤,这样显得开门见山。 +2. **30 分钟内能够完成**:这一点的核心是耗时尽可能短,不宜超过 30 分钟,这个时间上限是考虑到用户可能对你的项目并不了解。这一点很重要,大部分愿意浏览文档的人都是有技术基础的,但对你的项目也仅仅是一知半解。首先让这些读者尝试进行一些相关操作,在收到一定效果后,他们才会愿意花更多时间深入研究整个项目。因此,你可以从耗时这个角度来评估你的文档“入门”部分有没有需要改进之处。 +3. **有意义的任务**:这里“有意义”的含义取决于你的开源项目。最重要的是认真思考并将“入门”部分严格定义为一项任务,然后交给你的读者去完成。这个项目的价值应该在这项有意义的任务中有所体现,不然读者可能会感觉这是一个浪费时间的行为。 + +提示:假如你的项目是一个分布式数据库,那么达到“整个集群在某些节点故障的情况下可以不中断地保持可用”的目标就可以认为是“有意义”的;假如你的项目是一个数据分析工具或者是商业智能工具,“有意义”的目标也可以是“加载数据后能快速生成多种可视化效果的仪表板”。总之,无论你的项目需要达到什么“有意义”的目标,都应该能在笔记本电脑上本地快速实现。 + +[Linkerd 入门][6]就是一个很好的例子。Linkerd 是一个开源的 Kubernetes 服务网格Service Mesh,当时我对 Kubernetes 了解并不多,也不熟悉服务网格。但我在自己的笔记本电脑上很轻松地就完成了其中的任务,同时也加深了对服务网格的理解。 + +上面提到的三步过程是一个很有用的框架,对一篇文档“入门”部分的设计和量化评估很有帮助。今后你如果想将你的[开源项目产品化][7],这个框架还可能对实现价值的时间time-to-value产生影响。 + +### 其它核心部分 + +认真写好“入门”部分之后,你的文档中还需要有这五个部分:架构设计、生产环境使用指导、使用案例、参考资料以及未来展望,这五个部分在一份完整的文档中是必不可少的。 + +* **架构设计**:这一部分需要深入探讨整个项目架构设计的依据,“入门”部分中那些一笔带过的关键细节就应该在这里体现。在产品化过程中,这个部分将会是[产品推广计划][8]的核心,因此通常会包含一些可视化呈现的内容,期望的效果是让更多用户长期参与到项目中来。 +* **生产环境使用指导**:对于同一个项目,在生产环境中部署比在笔记本电脑上部署要复杂得多。因此,指导用户认真使用就尤为重要。同时,有些用户可能对项目很感兴趣,但对生产环境下的使用有所顾虑,而指导和展示的过程则正好能够吸引到这类潜在的用户。 +* **使用案例**:社会认同social proof的力量是有目共睹的,所以很有必要列出正在生产环境使用这个项目的其他用户,并把这些信息摆放在显眼的位置。这个部分的浏览量甚至仅次于“入门”部分。 +* **参考资料**:这个部分是对项目的一些详细说明,让用户得以进行详细的研究以及查阅相关信息。一些开源作者会在这个部分事无巨细地列出项目中的每一个细节和边缘情况edge case,这种做法可以理解,但不推荐在项目初期就在这个部分花费过多的时间。你可以采取更折中的方式,在质量和效率之间取得平衡,例如提供一些相关社区的链接、Stack Overflow 上的标签或单独的 FAQ 页面。 +* **未来展望**:你需要制定一个简略的时间表,规划这个项目的未来发展方向,这会让用户长期保持兴趣。尽管项目在当下可能并不完美,但要让用户知道你仍然有完善这个项目的计划。这个部分也能让整个社区构建一个强大的生态,因此还要向用户提供表达他们对未来展望的看法的交流区。 + +以上这几个部分或许还没有在你的文档中出现,甚至可能会在后期才能出现,尤其是“使用案例”部分。尽管如此,还是应该在文档中逐渐加入这些部分。如果用户对“入门”部分已经感觉良好,那以上这几个部分将会提起用户更大的兴趣。 + +最后,请在“入门”部分、README 文件或其它显眼的位置注明整个项目所使用的许可证。这个细节会让你的项目更容易通过最终用户的审核。 + +### 花 20% 的时间写作 + +一般情况下,我建议把整个项目 10% 到 20% 的时间用在文档写作上。也就是说,如果你是全职进行某一个项目的,文档写作需要在其中占半天到一天。 + +再细致一点,应该将写作纳入到常规的工作流程中,这样它就不再是一件孤立的琐事,而是日常的事务。文档写作应该随着工作进度同步进行,切忌将所有写作任务都堆积起来最后完成,这样才可以帮助你的项目达到最终目标:吸引用户、获得信任。 + +* * * + +*特别鸣谢云原生计算基金会的布道师 [Luc Perkins][9] 给出的宝贵意见。* + +*本文首发于 [COSS Media][10] 并经许可发布。* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/documentation + +作者:[Kevin Xu][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/kevin-xu +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-docdish-typewriter-pink.png?itok=OXJBtyYf (A pink typewriter) +[2]: https://www.grammar-monster.com/glossary/active_voice.htm +[3]: http://www.hemingwayapp.com/ +[4]: https://www.grammarly.com/ +[5]: https://en.wikipedia.org/wiki/Pareto_principle +[6]: https://linkerd.io/2/getting-started/ +[7]: https://opensource.com/article/19/11/products-open-source-projects +[8]: https://opensource.com/article/20/2/product-marketing-open-source-project +[9]: https://twitter.com/lucperkins +[10]: https://coss.media/open-source-documentation-technical-writing-101/ diff --git a/published/202003/20200313 6 Best AUR (Arch User Repository) Helpers for Arch Linux.md b/published/202003/20200313 6 Best AUR (Arch User Repository) Helpers for Arch Linux.md new file mode 100644 index 0000000000..0a49142c98 --- /dev/null +++ b/published/202003/20200313 6 Best AUR (Arch User Repository) Helpers for Arch Linux.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (hkurj) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12019-1.html) +[#]: subject: (6 Best AUR (Arch User Repository) Helpers for Arch Linux) +[#]: via: (https://www.2daygeek.com/best-aur-arch-user-repository-helpers-arch-linux-manjaro/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +6 个用于 Arch Linux 的最佳 AUR 助手 +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/21/082920kxdmlwkk7xx7llpw.jpeg) + +Arch Linux 是一款 Linux 发行版,主要由针对 x86-64 微处理器计算机的二进制软件包组成。Arch Linux 使用的是滚动发布模型,这种模式会频繁的给应用程序交付更新。它使用名为 [pacman][1] 的软件包管理器,可以用来安装、删除和更新软件包。 + +由于 Arch Linux 是为有经验的用户构建的,建议新手在使用过其他 Linux 后再来尝试。 + +### 什么是 AUR(Arch 用户软件仓库)? + +[Arch 用户软件仓库][2] 通常称为 AUR,是给 Arch 用户的基于社区的软件存储库。 + +根据软件包在 AUR 社区的流行程度,用户编译的软件包会进入到 Arch 的官方存储库。 + +### 什么是 AUR 助手? + +[AUR 助手][3]是一个包装程序,允许用户从 AUR 存储库安装软件包,而无需手动干预。 + +很多用例实现了自动化,比如包搜索、解决依赖关系、检索和构建 AUR 包、Web 内容检索和 AUR 包提交之类。 + +以下列出了 6 种最佳的 AUR 助手: + +* Yay(Yet another Yogurt) +* Pakku +* Pacaur +* Pikaur +* Trizen +* Aura + +### 1)Yay(Yet another Yogurt) + +[Yay][4] 是 Arch Linux 下基于 CLI 的最佳 AUR 助手,使用 Go 语言编写。Yay 是基于 yaourt、apacman 和 pacaur 设计的。 + +这是最合适推荐给新手的 AUR 助手。类似于 Pacman,其使用方法和 `pacman` 中的命令和选项很相似,可以让用户在搜索过程中找到匹配的软件包提供程序,并进行选择。 + +#### 如何安装 yay + +依次运行以下命令以在 Arch Linux 系统上安装。 + +``` +$ sudo pacman -S git go base-devel +$ git clone https://aur.archlinux.org/yay.git +$ cd yay +$ makepkg -si +``` + +#### 如何使用 yay + +`yay` 语法与 `pacman` 相同,使用以下命令安装软件包。 + +``` +$ yay -s arch-wiki-man +``` + +### 2)Pakku + +[Pakku][5] 可以被视为一个初始阶段的 Pacman。它是一个包装程序,可以让用户从 AUR 中搜索或安装软件包。 + +它在删除依赖项方面做得不错,并且还允许通过克隆 PKGBUILD 来安装软件包。 + +#### 如何安装 Pakku + +要在 Arch Linux 的系统上安装 Pakku,请依次运行以下命令。 + +``` +$ sudo pacman -S git base-devel +$ git clone https://aur.archlinux.org/pakku.git +$ cd pakku +$ makepkg -si +``` + +#### 如何使用 Pakku + +`pakku` 语法与 `pacman` 相同,使用以下命令安装软件包。 + +``` +$ pakku -s dropbox +``` + +### 3)Pacaur + +另一个基于 CLI 的 AUR 助手,可帮助减少用户与提示符的交互。 + +[Pacaur][6] 专为倾向于自动化重复任务的高级用户而设计。用户需要熟悉 `makepkg` 及其配置的 AUR 手动构建过程。 + +#### 如何安装 Pacaur + +要在 Arch Linux 的系统上安装 Pakku,请依次运行以下命令。 + +``` +$ sudo pacman -S git base-devel +$ git clone https://aur.archlinux.org/pacaur.git +$ cd pacaur +$ makepkg -si +``` + +#### 如何使用 Pacaur + +`pacaur` 语法与 `pacman` 相同,使用以下命令安装软件包。 + +``` +$ pacaur -s spotify +``` + +### 4)Pikaur + +[Pikaur][7] 是具有最小依赖性的 AUR 助手,可以一次查看所有 PKGBUILD,无需用户交互即可全部构建。 + +Pikaur 将通过控制 `pacman` 命令来告知 Pacman 要执行的下一个步骤。 + +#### 如何安装 Pikaur + +要在 Arch Linux 的系统上安装 Pakku,请依次运行以下命令。 + +``` +$ sudo pacman -S git base-devel +$ git clone https://aur.archlinux.org/pikaur.git +$ cd pikaur +$ makepkg -fsri +``` + +#### 如何使用 Pikaur + +`pikaur` 语法与 `pacman` 相同,使用以下命令安装软件包。 + +``` +$ pacaur -s spotify +``` + +### 5)Trizen + +[Trizen][8] 是用 Perl 编写的基于命令行的 AUR 轻量级包装器。这个面向速度的 AUR 助手,它允许用户搜索、安装软件包,还允许阅读 AUR 软件包注释。 + +支持编辑文本文件,并且输入/输出使用 UTF-8。内置与 `pacman` 的交互功能。 + +#### 如何安装 Trizen + +要在 Arch Linux 的系统上安装 Trizen,请依次运行以下命令。 + +``` +$ sudo pacman -S git base-devel +$ git clone https://aur.archlinux.org/trizen.git +$ cd trizen +$ makepkg -si +``` + +#### 如何使用 Trizen + +`trizen` 语法与 `pacman` 相同,使用以下命令安装软件包。 + +``` +$ pacaur -s google-chrome +``` + +### 6)Aura + +[Aura][9] 是用 Haskell 编写的,是用于 Arch Linux 和 AUR 的安全的多语言包管理器。它支持许多Pacman 操作和子选项,可轻松进行开发并编写精美的代码。 + +它可以自动从 AUR 安装软件包。使用 Aura 时,用户通常会在系统升级方面遇到一些困难。 + +#### 如何安装 Aura + +要在 Arch Linux 的系统上安装 Pakku,请依次运行以下命令。 + +``` +$ sudo pacman -S git base-devel +$ git clone https://aur.archlinux.org/aura.git +$ cd aura +$ makepkg -si +``` + +#### 如何使用 Aura + +`aura` 语法与 `pacman` 相同,使用以下命令安装软件包。 + +``` +$ pacaur -s android-sdk +``` + +### 结论 + +用户可以凭借这些分析在上述 6 个 AUR 助手中进行选择。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/best-aur-arch-user-repository-helpers-arch-linux-manjaro/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[hkurj](https://github.com/hkurj) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[2]: https://wiki.archlinux.org/index.php/Arch_User_Repository +[3]: https://wiki.archlinux.org/index.php/AUR_helpers +[4]: https://github.com/Jguer/yay +[5]: https://github.com/kitsunyan/pakku +[6]: https://github.com/E5ten/pacaur +[7]: https://github.com/actionless/pikaur +[8]: https://github.com/trizen/trizen +[9]: https://github.com/fosskers/aura diff --git a/published/202003/20200313 GNOME 3.36 Released With Visual - Performance Improvements.md b/published/202003/20200313 GNOME 3.36 Released With Visual - Performance Improvements.md new file mode 100644 index 0000000000..f193b4d245 --- /dev/null +++ b/published/202003/20200313 GNOME 3.36 Released With Visual - Performance Improvements.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12030-1.html) +[#]: subject: (GNOME 3.36 Released With Visual & Performance Improvements) +[#]: via: (https://itsfoss.com/gnome-3-36-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +GNOME 3.36 发布,对视觉和性能进行了改进 +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/23/151837oglshll1b7kjj8jg.jpg) + +在 [GNOME 3.34][1] 发布 6 个月后,最新版本的 GNOME 3.36 代号为 “Gresik” 也最终发布了。不仅是添加了功能,GNOME 3.36 还改进了许多我们需要的功能。 + +在本文中,我将重点介绍 GNOME 新版本的主要更改。 + +### GNOME 3.36 的关键改进 + +如果你想快速了解发生了什么变化,可以看以下官方视频: + +[视频][2] + +现在,让我分别重点介绍最新版本中的更改: + +#### GNOME Shell 扩展应用 + +你可以通过专门的“扩展”程序轻松管理 GNOME Shell 的扩展。 + +![][3] + +因此,你可以使用该程序更新、配置、删除或禁用现有扩展。 + +#### 切换到请勿打扰(DND) + +![][4] + +你可能已经在 Pop!\_OS 或其他 Linux 发行版中注意到了它。 + +但是,GNOME 3.36 现在在通知弹出区域中实现了 DND 切换。除非你将其关闭,否则不会收到任何通知。 + +#### 锁屏改进 + +![][5] + +在新版本中,锁定屏幕在输入凭据之前没有额外的动画。取而代之会在登录屏幕直接打招呼。 + +另外,为了提升一致性,锁屏背景将是墙纸的模糊版本。 + +总的来说,对锁屏的改进旨在使之更易于访问,同时改善其外观/感觉。 + +#### 视觉变化 + +![][6] + +包含了一些明显的新增,这些设计更改改善了 GNOME 3.36 的总体外观。 + +从图标的重新设计到文件夹和系统对话框,进行了许多小的改进以增强 GNOME 3.36 的用户体验。 + +此外,设置应用已进行了调整,通过微小的界面重新设计,使得选项访问更加容易。 + +#### 主要性能改进 + +GNOME 声称,此更新还提升了 GNOME 桌面的性能。 + +当使用装有 GNOME 3.36 的发行版时,你会注意到在性能上有明显的不同。无论是动画、重新设计还是微小的调整,对于 GNOME 3.36 所做的一切都会对用户的性能产生积极影响。 + +#### 其他更改 + +除了上述关键更改之外,还有很多其他改进,例如: + +* 时钟重新设计 +* 用户文档更新 +* GNOME 安装助手改进 + +还有许多其他更改。你可以查看[官方发布说明][7]了解更多信息。 + +### 如何获取 GNOME 3.36? + +即使 GNOME 3.36 已正式发布。Linux 发行版可能需要一段时间才能让你轻松升级 GNOME 体验。 + +[Ubuntu 20.04 LTS][8] 将提供最新版本 GNOME。你可以等待。 + +其他[流行的 Linux 发行版][9],如 Fedora、OpenSuse、Pop!\_OS,应该会很快包含 GNOME 3.36。[Arch Linux][10] 已升级到 GNOME 3.36。 + +我建议你耐心等待,直到获得发行版本的更新。不过,你可以查看[源代码][11]或尝试即将发布的流行发行版的开发版本,这些发行版可能有 GNOME 3.36。 + +你如何看待 GNOME 3.36?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gnome-3-36-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://itsfoss.com/gnome-3-34-release/ +[2]: https://img.linux.net.cn/static/video/Introducing%20GNOME%203.36%20-%20%27Gresik%27-ae2D4aWTsXM.mp4 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/extensions-gnome.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/dnd-gnome.jpg?ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/gnome-lockscreen.jpg?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/gnome-settings.jpg?ssl=1 +[7]: https://help.gnome.org/misc/release-notes/3.36/ +[8]: https://itsfoss.com/ubuntu-20-04-release-features/ +[9]: https://itsfoss.com/best-linux-distributions/ +[10]: https://www.archlinux.org/ +[11]: https://gitlab.gnome.org/GNOME diff --git a/published/202003/20200313 How to Change MAC Address in Linux.md b/published/202003/20200313 How to Change MAC Address in Linux.md new file mode 100644 index 0000000000..5e8d12da57 --- /dev/null +++ b/published/202003/20200313 How to Change MAC Address in Linux.md @@ -0,0 +1,173 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12008-1.html) +[#]: subject: (How to Change MAC Address in Linux) +[#]: via: (https://itsfoss.com/change-mac-address-linux/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/itsfoss/) + +如何在 Linux 中更改 MAC 地址 +====== + +在向你展示如何在 Linux 中更改 MAC 地址之前,让我们首先讨论为什么要更改它。 + +可能有几个原因。也许你不希望在公共网络上公开你的实际 [MAC 地址][1](也称为物理地址)?还有可能是网络管理员可能已在路由器或防火墙中阻止了特定的 MAC 地址。 + +一个实用的“好处”是某些公共网络(例如机场 WiFi)允许在有限的时间内免费上网。如果你还想继续使用,那么伪造 Mac 地址可能会欺骗网络,让它认为是一台新设备。这也是一个有名的原因。 + +![](https://img.linux.net.cn/data/attachment/album/202003/18/120702qdjyb7hvyj7bsrj7.jpg) + +我将展示更改 MAC 地址(也称为欺骗/伪造 MAC 地址)的步骤。 + +### 在 Linux 中更改 MAC 地址 + +让我们一步步来: + +#### 查找你的 MAC 地址和网络接口 + +让我们找出一些[关于 Linux 中网卡的细节][3]。使用此命令获取网络接口详细信息: + +``` +ip link show +``` + +在输出中,你将看到一些详细信息以及 MAC 地址: + +``` +1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 +2: eno1: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 + link/ether 94:c6:f8:a7:d7:30 brd ff:ff:ff:ff:ff:ff +3: enp0s31f6: mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000 + link/ether 38:42:f8:8b:a7:68 brd ff:ff:ff:ff:ff:ff +4: docker0: mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default + link/ether 42:02:07:8f:a7:38 brd ff:ff:ff:ff:ff:ff +``` + +如你所见,在这里,我的网络接口称为 `enp0s31f6`,MAC 地址为 `38:42:f8:8b:a7:68`。 + +你可能需要在安全的地方记录下来,以便稍后还原到该原始 MAC 地址。 + +现在你可以继续更改 MAC 地址。 + +注意! + +如果在当前使用的网络接口上执行此操作,那么可能会中断你的网络连接。因此,请在其他网卡上尝试使用此方法,或者准备重启网络。 + +#### 方法 1:使用 Macchanger 更改 MAC 地址 + +![][4] + +[Macchanger][5] 是查看、修改和操作网卡 MAC 地址的简单程序。它几乎在所有 GNU/Linux 操作系统中都可用,你可以使用发行版的包安装程序进行安装。 + +在 Arch Linux 或 Manjaro 上: + +``` +sudo pacman -S macchanger +``` + +在 Fedora、CentOS 和 RHEL 上: + +``` +sudo dnf install macchanger +``` + +在 Debian、Ubuntu、Linux Mint、Kali Linux 上: + +``` +sudo apt install macchanger +``` + +**重要!**系统会要求你选择是否应将 `macchanger` 设置为在每次启动或关闭网络设备时自动运行。每当你接到网线或重启 WiFi 时,它都会提供一个新的 MAC 地址。 + +![Not a good idea to run it automatically][6] + +我建议不要自动运行它,除非你确实需要每次更改 MAC 地址。因此,选择“No”(按 `Tab` 键),然后按回车键继续。 + +**如何使用 Macchanger 更改 MAC 地址** + +你还记得网络接口名称吗?你在前面的步骤中获得了它。 + +现在,要将随机 MAC 地址分配给该网卡,请使用: + +``` +sudo macchanger -r enp0s31f6 +``` + +更改 MAC 后,使用以下命令进行验证: + +``` +ip addr +``` + +现在你将看到已经伪造 MAC。 + +要将 MAC 地址更改为特定值,请使用以下命令指定自定义 MAC 地址: + +``` +macchanger --mac=XX:XX:XX:XX:XX:XX +``` + +其中 XX:XX:XX:XX:XX:XX 是你要更改的新 MAC。 + +最后,要将 MAC 地址恢复为其原始硬件值,请运行以下命令: + +``` +macchanger -p enp0s31f6 +``` + +但是,你不必如此。重启系统后,更改将自动丢失,并且实际的 MAC 地址将再次恢复。 + +你可以随时查看手册页以获取更多详细信息。 + +#### 方法 2:使用 iproute2 更改 Mac 地址(中级知识) + +我建议你使用 macchanger,但如果你不想使用它,那么可以使用另一种方法在 Linux 中更改 MAC 地址。 + +首先,使用以下命令关闭网卡: + +``` +sudo ip link set dev enp0s31f6 down +``` + +接下来,使用以下命令设置新的 MAC: + +``` +sudo ip link set dev enp0s31f6 address XX:XX:XX:XX:XX:XX +``` + +最后,使用以下命令重新打开网络: + +``` +sudo ip link set dev enp0s31f6 up +``` + +现在,验证新的 MAC 地址: + +``` +ip link show enp0s31f6 +``` + +就是这些了。你已经成功地在 Linux 中修改了 MAC 地址。敬请期待 FOSS 更多有关 Linux 教程和技巧的文章。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/change-mac-address-linux/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/MAC_address +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/airport_wifi_meme.jpg?ssl=1 +[3]: https://itsfoss.com/find-network-adapter-ubuntu-linux/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/Change_MAC_Address_Linux.jpg?ssl=1 +[5]: https://github.com/alobbs/macchanger +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/configuring_mcchanger.jpg?ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/Dimitrios.jpg?ssl=1 diff --git a/published/202003/20200314 How to Install Netbeans on Ubuntu and Other Linux.md b/published/202003/20200314 How to Install Netbeans on Ubuntu and Other Linux.md new file mode 100644 index 0000000000..95cd74089e --- /dev/null +++ b/published/202003/20200314 How to Install Netbeans on Ubuntu and Other Linux.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12017-1.html) +[#]: subject: (How to Install Netbeans on Ubuntu and Other Linux) +[#]: via: (https://itsfoss.com/install-netbeans-ubuntu/) +[#]: author: (Community https://itsfoss.com/author/itsfoss/) + +如何在 Ubuntu 和其他 Linux 上安装 Netbeans +====== + +> 在本教程中,你将学习在 Ubuntu 和其他 Linux 发行版上安装 Netbeans IDE 的各种方法。 + +[NetBeans][1] 是一个开源集成开发环境,具有良好的跨平台支持。此工具已被 Java 和 C/C++ 开发社区广泛认可。 + +开发环境相当灵活。你可以配置它以支持各种开发。实际上,你可以用它来开发 Web、桌面和移动应用,而无需离开此平台。这太神奇了,不是吗?除此之外,用户可以添加许多已知语言,如 [PHP][2]、C、C++、HTML、[Ajax][3]、JavaScript、JSP、Ruby on Rails 等。 + +如果你正在了解如何在 Linux 上安装 Netbeans,那么有几种方法可以做到。我编写本教程主要是为了 Ubuntu,但一些安装方法也适用于其他发行版。 + +* [使用 apt 在 Ubuntu 上安装 Netbeans][4]:适用于 Ubuntu 和基于 Ubuntu 的发行版,但通常**它是旧版的 Netbeans** +* [使用 Snap 在 Ubuntu 上安装 Netbeans][5]:适用于已启用 Snap 包支持的任何 Linux 发行版 +* [使用 Flatpak 安装 Netbeans] [6]:适用于所有支持 Flatpak 包的 Linux 发行版 + +### 使用 Apt 包管理器在 Ubuntu 上安装 Netbeans IDE + +如果在 Ubuntu 软件中心搜索 Netbeans,你将找到两个版本的 Netbeans。Apache Netbeans 是 snap 版本,大小较大,但提供了最新的 Netbeans。 + +只需单击一下即可安装它。无需打开终端。是最简单的方法。 + +![Apache Netbeans in Ubuntu Software Center][7] + +你也可以选择使用 `apt` 命令,但使用 `apt` 时,你无法获得最新的 Netbeans。例如,在编写本教程时,Ubuntu 18.04 中 Apt 提供 Netbeans 10,而 Snap 有最新的 Netbeans 11。 + +如果你是 [apt 或 apt-get][8] 的粉丝,那么可以[启用 universe 仓库][9],并在终端中使用此命令安装 Netbeans: + +``` +sudo apt install netbeans +``` + +### 使用 Snap 在任何 Linux 发行版上安装 Netbeans IDE + +![][10] + +Snap 是一个通用包管理器,如果[发行版上启用了 Snap][11],那么可以使用以下命令安装它: + +``` +sudo snap install netbeans --classic +``` + +此过程可能需要一些时间才能完成,因为总下载大小约为 1 GB。完成后,你将在应用程序启动器中看到它。 + +你不仅可以通过 Snap 获取最新的 Netbeans,已安装的版本将自动更新到较新版本。 + +### 使用 Flatpak 安装 Netbeans + +[Flatpak][12] 是另一个类似 Snap 的包安装器。默认情况下,某些发行版支持 Flatpak,在其他发行版上你可以[启用 Flatpak 支持][13]。 + +发行版支持 Flatpak 后,你可以使用以下命令安装 Netbeans: + +``` +flatpak install flathub org.apache.netbeans +``` + +另外,你可以下载源码并自己编译。 + +- [下载 Netbeans][14] + +希望你使用了上面其中一个方法在你的 Ubuntu 上安装了 Netbeans。但你使用的是哪个方法?有遇到问题么?让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-netbeans-ubuntu/ + +作者:[Srimanta Koley][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://netbeans.org/ +[2]: https://www.php.net/ +[3]: https://en.wikipedia.org/wiki/Ajax_(programming) +[4]: tmp.ZNFNEC210y#apt +[5]: tmp.ZNFNEC210y#snap +[6]: tmp.ZNFNEC210y#flatpak +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/apache-netbeans-ubuntu-software-center.jpg?ssl=1 +[8]: https://itsfoss.com/apt-vs-apt-get-difference/ +[9]: https://itsfoss.com/ubuntu-repositories/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/Install_Netbeans_Linux.jpg?ssl=1 +[11]: https://itsfoss.com/install-snap-linux/ +[12]: https://flatpak.org/ +[13]: https://itsfoss.com/flatpak-guide/ +[14]: https://netbeans.apache.org/download/index.html +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/srimanta.jpg?ssl=1 diff --git a/published/202003/20200316 Connect your Google Drive to Fedora Workstation.md b/published/202003/20200316 Connect your Google Drive to Fedora Workstation.md new file mode 100644 index 0000000000..134703d0dc --- /dev/null +++ b/published/202003/20200316 Connect your Google Drive to Fedora Workstation.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12037-1.html) +[#]: subject: (Connect your Google Drive to Fedora Workstation) +[#]: via: (https://fedoramagazine.org/connect-your-google-drive-to-fedora-workstation/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +将你的 Google Drive 连接到 Fedora 工作站 +====== + +![][1] + +有大量的云服务可用于存储重要文档。Google Drive 无疑是最受欢迎的之一。它提供了一组相应的应用程序,例如文档,表格和幻灯片来创建内容。但是,你也可以在 Google Drive 中存储任意内容。本文向你展示如何将其连接到 [Fedora 工作站][2]。 + +### 添加帐户 + +Fedora 工作站可在安装后首次启动或者之后的任何时候添加一个帐户。要在首次启动期间添加帐户,请按照提示进行操作。其中包括选择添加一个帐户: + +![][3] + +选择 Google,然后会出现一个登录提示,请使用你的 Google 帐户信息登录。 + +![][4] + +请注意,此信息仅传输给 Google,而不传输给 GNOME 项目。下一个页面要求你授予访问权限,这是必需的,以便系统桌面可以与 Google 进行交互。向下滚动查看访问请求,然后选择“允许”继续。 + +你会在移动设备和 Gmail 中收到有关新设备(系统)访问 Google 帐户的通知。这是正常现象。 + +![][5] + +如果你在初次启动时没有执行此操作,或者需要重新添加帐户,请打开“设置”,然后选择“在线账户”来添加帐户。可以通过顶部栏右侧的下拉菜单(“齿轮”图标)或打开“概览”并输入“settings”来使用它。接着和上面一样。 + +### 在 Google Drive 中使用“文件”应用 + +打开“文件”应用(以前称为 “nautilus”)。“文件”应用可以通过左侧栏访问。在列表中找到你的 Google 帐户。 + +当你选择帐户后,“文件”应用会显示你的 Google Drive 的内容。你可以使用 Fedora 工作站的本地应用打开某些文件,例如声音文件或 [LibreOffice][6] 兼容文件(包括 Microsoft Office 文档)。其他文件(例如 Google 文档、表格和幻灯片等 Google 应用文件)将使用浏览器和相应的应用打开。 + +请记住,如果文件很大,将需要一些时间才能通过网络接收文件,你才可以打开它。 + +你还可以复制粘贴 Google Drive 中的文件到连接到 Fedora 工作站的其他存储,或者反之。你还可以使用内置功能来重命名文件、创建文件夹并组织它们。对于共享和其他高级选项,请和平常一样在浏览器中使用 Google Drive。 + +请注意,“文件”应用程序不会实时刷新内容。如果你从其他连接 Google 的设备(例如手机或平板电脑)添加或删除文件,那么可能需要按 `Ctrl+R` 刷新“文件”应用。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/connect-your-google-drive-to-fedora-workstation/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/03/gdrive-workstation-816x345.jpg +[2]: https://getfedora.org/workstation +[3]: https://fedoramagazine.org/wp-content/uploads/2020/03/firstboot-choices.jpg +[4]: https://fedoramagazine.org/wp-content/uploads/2020/03/firstboot-signin.jpg +[5]: https://fedoramagazine.org/wp-content/uploads/2020/03/firstboot-grantaccess.jpg +[6]: https://fedoramagazine.org/discover-hidden-gems-libreoffice/ +[7]: https://unsplash.com/@beatriz_perez?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[8]: https://unsplash.com/s/photos/office-files?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202003/20200317 Coronavirus challenges remote networking.md b/published/202003/20200317 Coronavirus challenges remote networking.md new file mode 100644 index 0000000000..9467133c2d --- /dev/null +++ b/published/202003/20200317 Coronavirus challenges remote networking.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12039-1.html) +[#]: subject: (Coronavirus challenges remote networking) +[#]: via: (https://www.networkworld.com/article/3532440/coronavirus-challenges-remote-networking.html) +[#]: author: (Michael Cooney https://www.networkworld.com/author/Michael-Cooney/) + +新型冠状病毒对远程网络的影响 +====== + +> 由于 COVID-19 的肆虐,IBM、谷歌、亚马逊、AT&T、思科、苹果等公司都争先恐后地为远程办公提供了技术上的支持,这为远程网络带来了不少的压力。 + +![](https://images.idgesg.net/images/article/2018/02/crisis_survival_strategy_disaster_preparedness_readiness_recovery_continuity_plan_thinkstock_600161484-100749343-large.jpg) + +在新型冠状病毒广泛传播的大环境下,很多公司都要求员工留在家中远程办公,远程网络技术因此承受了更大的压力,一些带宽和安全方面的问题也接踵而至。 + +在过去的几十年当中,由于企业的蓬勃发展,远程办公的人数估计增加了 400 多万。而当前疫情流行的背景下,远程办公的需求激增,有望达到一个新的高峰。 + +一家虚拟私有网络Virtual Private Network(缩写:???)提供商 [Atlas][1] 的一份研究表明,在今年 3 月 9 日到 3 月 15 日之间,美国的虚拟私有网络使用量增加了 53%,并且还会继续提高。而在意大利这个疫情爆发比美国早两周的国家,过去一周内的虚拟私有网络使用量甚至增加了 112%。Atlas 虚拟私有网络的首席执行官 Rachel Welch 在一份声明中称,美国的虚拟私有网络使用量在 3 月底预估会达到 150% 的增幅。 + +部分企业正在尝试通过一日测试one-day test来评估远程办公的可行性。据《[芝加哥论坛报][2]》的报道,摩根大通、晨星以及一家数据分析方面的初创公司 Arity 已经通过让员工在家办公一天来测试整个办公系统的稳定性。 + +在政府方面,[美国国家海洋与大气管理局][3]和 NASA 都已经进行或计划进行网络方面的压力测试,评估是否有足够的网络容量足以让上千名工作人员远程办公,以及远程办公可能造成的影响。而放眼整个美国,供职于美国政府部门的员工数量在 [200 万][4]左右。 + +为了避免蜂窝数据网络发生拥堵,美国[联邦通信委员会][5]已批准 T-mobile 临时访问已分配给其它运营商的 600MHz 频段,T-mobile 表示“将使用这个频段让美国人更方便地享受远程医疗、参与远程工作和学习,同时在保持‘物理距离’的情况下保持联系”。 + +- [video](https://youtu.be/-1-ugVx0hVc) + +但也有一些业内人士指出,在一些对蜂窝网络有较强依赖的的场景下,“最后一英里”的网络访问会变得非常拥堵。 + +网络情报公司 ThousandEyes 的主要产品是局域网和广域网性能分析的软件,该公司的产品经理 Alex Cruz Farmer 表示,网络瓶颈在于一些较为偏远的农村地区,因为那些地区的网络基础设施较为薄弱,主要通过微波或蜂窝网络来访问互联网。最大的挑战在于现有的解决方案所能提供的带宽远远不足。 + +Alex Cruz Farmer 还补充道,尽管持续时间不长,但现在的确已经出现一些由于运营商问题或网络负载增加导致的故障现象。 + +AT&T 表示目前已经留意到蜂窝网络使用量的变化,但网络容量并没有作出提高。 + +[AT&T 在一份声明中称][7],在新冠病毒传播最严重的城市中,由于越来越多的人留在了家中远程办公,减少了通勤和人群聚集,很多特定位置和特定时段的蜂窝网络使用量峰值都明显降低了。他们还使用了一些工具对网络带宽进行了统计和监控,通过这些工具,他们可以更直观地了解网络使用情况的趋势,同时获取网络性能和网络容量方面的报告,进而管理整个通信网络。 + +Verison 表示,自从新型冠状病毒疫情爆发以来,尽管在家办公的用户数量大增,但使用的数据量并没有明显的上升。他们在一份声明中称:“Verison 的网络是为满足未来的需求设计建造的,面对各种需求量的增加或使用方式的改变,我们都有充分的准备。虽然这是一次前所未有的社会事件,整个局面也在不断发生改变,但随着不断了解实际需求的变化情况,我们随时可以对网络资源作出调整”。 + +Verison 一直在关注受影响最严重的地区的网络使用情况,并承诺将会与医院、医护人员、政府机构合作,制定网络资源使用的优先级,以满足他们的需求。Verison 还宣布计划在 2020 年将支出在 170 亿至 180 亿美元的基础上再提高 5 亿美元,以实现“加快 Verison 向 5G 过渡并在困难时期帮助支撑经济”的目标。 + +### 企业虚拟私有网络安全问题 + +对于企业来说,数据中心与远程用户之间的网络和安全问题解决起来绝非易事,尤其是使用虚拟私有网络进行远程访问时,来自用户所在住宅网络的访问几乎无法由企业控制。CIMI 公司总裁 Tom Nolle 认为,IT 部门有必要验证这些连接是否符合企业的标准(关于 Tom Nolle 更多关于在家办公的看法,可以查阅[这里][8])。 + +Tom Nolle 认为像 ISP、DNS 和 Wi-Fi 这些常见的家用网络要素都应该作为适合远程办公网络业务认证的一部分。他发现 Google 的 DNS 服务比 ISP 提供的服务更能承受压力,OpenDNS 也是一个很好的选择,这说明用户可以考虑使用其中一种。 + +Tom Nolle 还说,家庭 Wi-Fi 网络的安全性也是一个问题,IT 部门应该要求远程办公的员工提交 Wi-Fi 配置的屏幕截图,以保证使用了正确的加密方式。之所以有这样的想法,是因为他觉得很多远程办公的员工都会绕过企业预设的一些安全措施。 + +DNS 软件公司 BlueCat 的首席战略官 Andrew Wertkin 表示,对一些刚刚开始在家远程办公的员工来说,适当提供相关指导是很有必要的。大部分员工从来没有尝试过在家远程办公,他们或许并不了解安全的重要性。如果员工访问公司网络的时候使用的是个人设备而不是公司设备,就更有可能出现问题。 + +而使用[虚拟私有网络][9]远程办公的人数激增也会为企业带来成本上的挑战。 + +“虚拟私有网络设备并不便宜,如果考虑到计算资源的成本和每个人的均摊成本,迁移到云上的虚拟环境会带来一笔不小的开支,这还不包括每个虚拟私有网络许可证价格的上升”,Alex Cruz Farmer 坦言。 + +在容量方面,随着远程访问量的增加,用于分配 IP 地址的 DHCP 服务也会承受巨大的压力。Andrew Wertkin 指出,如果进行远程连接的设备无法获取到网络地址,则是否具有足够的虚拟私有网络许可证并不重要。企业内部必须对这些风险进行测试,了解其中存在瓶颈的部分,并制定规避这些风险的策略。 + +按照这个思路,企业甚至需要验证数据中心可以用于公开的 SSL 套接字数量,否则也会面临数量不足的风险。 + +微软 Office 365 产品团队的高级程序经理 Paul Collinge 也表达了类似的担忧。他在一篇关于优化 Office 365 员工远程办公流量的[博客][10]中写道,当大量员工在同时接入企业网络时,会对诸如虚拟私有网络集中器、中央网络出口设备(例如代理、DLP)、中央互联网带宽、回程 MPLS 和 NAT 等网络要素产生巨大的压力。最终导致的结果是低下的性能、低下的生产力,以及员工们低下的使用体验。 + +Alex Cruz Farmer 提出,企业很可能需要增加网络上虚拟私有网络集中器的数量,这样就可以让远程用户分布在多个不同的虚拟私有网络端点上,避免产生拥堵。退而求其次,只能在防火墙上把某些端口放开,允许特定应用程序的公开访问,尽管这样有助于提高工作效率,但却降低了整体的安全性。 + +### 虚拟私有网络隧道分割技术有效吗? + +业内人士对隧道分割tunneling split有不同的看法。 + +BlueCat 的 Andrew Wertkin 认为,虚拟私有网络可以使用隧道分割技术,使得仅有需要访问企业内部网络的流量才通过虚拟私有网络隧道访问,其余流量则直接进入互联网。这意味着会有部分流量不受隧道和企业网络内部的安全控制,用户的计算机会暴露在互联网当中,进而导致企业的数据和网络面临安全风险。 + +尽管如此,微软在上周还是建议 IT 管理员使用隧道分割技术以缓解 Office 365 由于大量远程用户涌入导致的拥堵问题。微软在[建议][10]中提供了相关接入点的 URL 和 IP 地址列表,并引导 IT 人员如何按照这个方式将流量路由到 Office 365。 + +按照 Paul Collinge 的说法,虚拟私有网络客户端需要经过配置,才能将流量路由到已标识的 URL/IP/ 端口上,进而为全球的用户提供高性能的服务。 + +Alex Cruz Farmer 认为,在虚拟私有网络使用率上升之后,企业很有必要对网络安全进行一个全面的审查。对于仍然在使用传统网络安全架构的企业来说,应该开始考虑基于云端的网络安全方案了,这不仅可以提升远程办公的性能,还能减少企业对于广域网的使用量。 + +其它相关情况: + +* [FCC][11] 呼吁,宽带提供商应该适当放宽数据传输的限制,电话运营商应该适当免除用户的长途电话费,远程教育提供商应该合作为社会提供远程学习的机会,网络运营商应该优先考虑医院或医疗机构的网络连接需求。对此,AT&T 已经作出了相关的回应和行动。 +* [美国参议员 Mark R. Warner (D-VA)][12] 和其他 17 名参议员致信了 AT&T、CenturyLink、Charter Communications、Comcast、Cox Communications、Sprint、T-Mobile、Verizon 这八家主要 ISP 的首席执行官,呼吁这些公司应该采取措施应对远程办公、在线教育、远程医疗、远程支持服务等方面需求激增带来的压力。这些参议员在信中呼吁,各公司应该降低可能对远程服务产生影响的限制和费用,同时还应该为受到疫情影响的学生提供免费或收费的宽带服务,否则学生在疫情期间无法接入网络进行在线学习。 +* [思科][13]、微软、[谷歌][14]、[LogMeIn][15]、[Spectrum][16] 等供应商都提供了一些免费工具,帮助用户在疫情爆发期间正常进行安全通信。 + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3532440/coronavirus-challenges-remote-networking.html + +作者:[Michael Cooney][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Michael-Cooney/ +[b]: https://github.com/lujun9972 +[1]: https://atlasvpn.com/blog/vpn-usage-in-italy-rockets-by-112-and-53-in-the-us-amidst-coronavirus-outbreak/ +[2]: https://www.chicagotribune.com/coronavirus/ct-coronavirus-work-from-home-20200312-bscm4ifjvne7dlugjn34sksrz4-story.html +[3]: https://federalnewsnetwork.com/workforce/2020/03/agencies-ramp-up-coronavirus-preparations-as-noaa-plans-large-scale-telework-test/ +[4]: https://fas.org/sgp/crs/misc/R43590.pdf +[5]: https://www.fcc.gov/coronavirus +[6]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[7]: https://about.att.com/pages/COVID-19.html +[8]: https://blog.cimicorp.com/?p=4055 +[9]: https://www.networkworld.com/article/3268744/understanding-virtual-private-networks-and-why-vpns-are-important-to-sd-wan.html +[10]: https://techcommunity.microsoft.com/t5/office-365-blog/how-to-quickly-optimize-office-365-traffic-for-remote-staff-amp/ba-p/1214571 +[11]: https://www.fcc.gov/document/commissioner-starks-statement-fccs-response-covid-19 +[12]: https://www.warner.senate.gov/public/_cache/files/2/3/239084db-83bd-4641-bf59-371cb829937a/A99E41ACD1BA92FB37BDE54E14A97BFA.letter-to-isps-on-covid-19-final-v2.-signed.pdf +[13]: https://blogs.cisco.com/collaboration/cisco-announces-work-from-home-webex-contact-center-quick-deployment +[14]: https://cloud.google.com/blog/products/g-suite/helping-businesses-and-schools-stay-connected-in-response-to-coronavirus +[15]: https://www.gotomeeting.com/work-remote?clickid=RFlSQF3DBxyOTSr0MKVSfWfHUknShrScK0%3AhTY0&irgwc=1&cid=g2m_noam_ir_aff_cm_pl_ct +[16]: https://www.multichannel.com/news/charter-opening-wi-fi-hotspots-in-face-of-covid-19 +[17]: https://www.facebook.com/NetworkWorld/ +[18]: https://www.linkedin.com/company/network-world diff --git a/published/202003/20200317 Viewing and configuring password aging on Linux.md b/published/202003/20200317 Viewing and configuring password aging on Linux.md new file mode 100644 index 0000000000..a6699b8878 --- /dev/null +++ b/published/202003/20200317 Viewing and configuring password aging on Linux.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12041-1.html) +[#]: subject: (Viewing and configuring password aging on Linux) +[#]: via: (https://www.networkworld.com/article/3532815/viewing-and-configuring-password-aging-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 上查看和配置密码时效 +====== + +![](https://images.idgesg.net/images/article/2019/09/cso_nw_user_id_password_credentials_authentication_by_bluebay2014_gettyimages-924698706_2400x1600-100811223-large.jpg) + +> 使用正确的设置,可以强制 Linux 用户定期更改密码。以下是查看密码时效以及如何更改其中设置的方法。 + +可以将 Linux 系统上的用户密码配置为永久或设置过期时间,以让人们必须定期重置它们。出于安全原因,通常认为定期更改密码是一种好习惯,但默认并未配置。 + +要查看和修改密码时效,你需要熟悉几个重要的命令:`chage` 命令及其 `-l` 选项,以及 `passwd` 命令及其 `-S` 选项。本文会介绍这些命令,还有其他一些 `chage` 命令选项来配置密码时效。 + +### 查看密码时效设置 + +确定某个特定帐户是否已设置密码时效的方法是使用如下 `chage` 命令。请注意,除了你自己的帐户以外,其他任何帐户都需要 root 权限。请注意下面的密码到期日期。 + +``` +$ sudo chage -l dory +Last password change : Mar 15, 2020 +Password expires : Jun 13, 2020 <== +Password inactive : never +Account expires : never +Minimum number of days between password change : 10 +Maximum number of days between password change : 90 +Number of days of warning before password expires : 14 +``` + +如果未应用密码时效,那么帐户信息将如下所示: + +``` +$ sudo chage -l nemo +Last password change : Jan 14, 2019 +Password expires : never <== +Password inactive : never +Account expires : Mar 26, 2706989 +Minimum number of days between password change : 0 +Maximum number of days between password change : 99999 +Number of days of warning before password expires : 7 +``` + +你也可以使用 `passwd -S` 命令查看某些信息,但是你需要知道输出中的每个字段代表什么: + +``` +dory$ passwd -S +dory P 03/15/2020 10 90 14 -1 +``` + +这里的七个字段代表: + +* 1 – 用户名 +* 2 - 帐户状态(`L` = 锁定,`NP` = 无密码,`P` = 可用密码) +* 3 – 上次密码更改的日期 +* 4 – 可更改最低时效(如果没有这么多天,则不能更改密码) +* 5 – 最长时效(这些天后,密码必须更改) +* 6 – 密码过期前提前警告的天数 +* 7 – 密码过期后锁定之前的天数(设为无效) + +需要注意的一件事是,`chage` 命令不会显示帐户是否被锁定;它仅显示密码时效设置。另一方面,`passwd -S` 命令将告诉你密码被锁定的时间。在此例中,请注意帐户状态为 `L`: + +``` +$ sudo passwd -S dorothy +dorothy L 07/09/2019 0 99999 7 10 +``` + +通过将 `/etc/shadow` 文件中通常包含密码的“哈希”字段变为 `!`,从而达成锁定的效果。 + +``` +$ sudo grep dorothy /etc/shadow +dorothy:!:18086:0:99999:7:10:: <== +``` + +帐户被锁定的事实在 `chage` 输出中并不明显: + +``` +$ sudo chage -l dorothy +Last password change : Jul 09, 2019 +Password expires : never +Password inactive : never +Account expires : never +Minimum number of days between password change : 0 +Maximum number of days between password change : 99999 +Number of days of warning before password expires : 7 +``` + +### 密码时效的一些选项 + +最常用的设置是最短和最长的天数。它们经常结合使用。例如,你可以配置一个密码,使其最长不能使用超过 90 天(最大),然后添加一个有效期为一周或 10 天(最小)的密码。这样可以确保用户不会在需要更改密码后马上改回以前的密码。 + +``` +$ sudo chage -M 90 -m 10 shark +$ sudo chage -l shark +Last password change : Mar 16, 2020 +Password expires : Jun 14, 2020 +Password inactive : never +Account expires : never +Minimum number of days between password change : 10 <== +Maximum number of days between password change : 90 <== +Number of days of warning before password expires : 7 +``` + +你还可以使用 `-E` 选项为帐户设置特定的到期日期。 + +``` +$ sudo chage -E 2020-11-11 tadpole +$ sudo chage -l tadpole +Last password change : Oct 15, 2019 +Password expires : never +Password inactive : never +Account expires : Nov 11, 2020 <== +Minimum number of days between password change : 0 +Maximum number of days between password change : 99999 +Number of days of warning before password expires : 7 +``` + +密码时效可能是一个重要的选择,只要它不鼓励用户使用过于简单的密码或以不安全的方式写下来即可。有关控制密码字符(例如,大小写字母、数字等的组合)的更多信息,请参考这篇关于[密码复杂度][3]的文章。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3532815/viewing-and-configuring-password-aging-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[3]: https://www.networkworld.com/article/2726217/how-to-enforce-password-complexity-on-linux.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202003/20200318 Top 10 open source tools for working from home.md b/published/202003/20200318 Top 10 open source tools for working from home.md new file mode 100644 index 0000000000..c8357aadc7 --- /dev/null +++ b/published/202003/20200318 Top 10 open source tools for working from home.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12014-1.html) +[#]: subject: (Top 10 open source tools for working from home) +[#]: via: (https://opensource.com/article/20/3/open-source-working-home) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +在家工作的十大开源工具 +====== + +> 无论你是在家工作的资深人士还是远程工作的新手,这些工具都可以使交流和协作变得轻而易举。 + +![](https://img.linux.net.cn/data/attachment/album/202003/20/103814bwxxqxkxc9qqxkbb.jpg) + +如果你在家工作work from home(WFH),你就会知道拥有一系列实用的工具是很重要的,这些工具可以让你远离烦恼,专注于重要的事情。在工作期间工作越努力,工作日结束后,你就越容易放松。 + +我已经在家工作多年了,这是我精选的远程工作者必备的最佳开源工具。 + +### 视频会议:Jitsi + +![Jitsi screenshot][2] + +当你不在同事身边时,每周保持连接几次非常重要,甚至只是这样也可以保持人与人之间的联系,否则你就会变得孤独。市场上有很多视频会议系统,但以我的经验,最简单、最好的是开源的 [Jitsi][3]。 + +通过易于记忆的 URL([meet.jit.si][3])和按需会议室,Jitsi 使得召开即席会议非常简单。而且更好的是,无需注册。你只需进入 [meet.jit.si][3],找到一个带有友好的、随机生成的 URL(此处没有字母和数字的随机组合) 的会议室,你就可以立即开始聊天。如果你选择注册,那么还可以与几种日历进行集成。 + +在现实生活中,我参加了许多来自新西兰最偏远地区的会议,而 Jitsi 无疑是我迄今为止拥有的最好的视频聊天体验。不需要浪费一半的会议时间在迷宫般的虚拟会议室中寻找彼此,也不用在尴尬的滞后时间中坐着发呆,更不用努力地为聊天应用程序安装更新。使用开源和符合标准的 webRTC 协议的 Jitsi 可以让你有个愉悦的开会体验。 + +### 白板:Drawpile + +![Drawpile screenshot][4] + +有时,白板非常适合解释事情、跟踪想法或只是散布一下疯狂的想法。白板是办公室会议室的常见物品,但在数字世界中却很难获得。幸运的是,有了 [Drawpile][5],这是一个实时协作的绘图应用程序。你可以在自己的计算机上托管绘图会话并邀请其他用户,也可以在 Drawpile 的服务器上托管会话。 + +它易于使用,足够精简、直观而功能强大,当你的粗略想法开始逐渐成型时,它是使其成为可行的作品的应用程序。 + +### 看板:Taiga + +![Taiga screenshot][6] + +想要保持有序并与你的部门保持同步吗?你应该试试 [Taiga][7],这是一个虚拟的“便利贴”面板,可以帮助团队跟踪各个任务。这种组织和项目计划方法被称为看板kanban,在软件开发中很流行,而它也流行于从假期规划到家庭装修项目的所有计划之中。 + +Taiga 的优点是它是一个在线共享空间。与你进行协作或与之合作的任何人都可以把任务放到面板上,并且随着每个人的进展,他们将任务从左列(起点)移到右边(终点线)。Taiga 具有令人愉悦的图形化和交互性,没有什么比从一列移动到另一列的拖放任务令人感到舒适的了。 + +如果你的团队有 Taiga 无法满足的特定需求,那么你应该看看[我们挑选的最佳开源看板][8]。 + +### 个人笔记本:Joplin + +![Joplin][9] + +我在办公桌旁放着一个纸质笔记本,这样我就可以随时记下思考或想法了。想要捕捉这种简单动作的感受和便利是很棘手的,但 Joplin 却做的很好。 + +你可以在 Joplin 中创建虚拟笔记本,每个笔记本可以有任意数量的条目。这些条目可以是简单的文本,也可以是带有图形、任务列表、超链接等的复杂的动态文档。最重要的是,你可以将 Joplin 与所有的在线存储服务同步,包括开源的 Nextcloud 服务,这样你可以在任何计算机和任何设备上使用笔记本。这是使你的工作日井井有条、专心致志并保持活动顺畅的好方法。 + +如果 Joplin 不太满足你的要求,请查看一些我们最喜欢的[笔记本应用][10]。 + +### 群聊:Riot + +![Riot screenshot][11] + +并非所有内容都需要视频聊天或语音通话,但是有些事情比电子邮件更紧急。这就是团队聊天发挥作用的地方。一个好的群聊应用程序应该具有这些功能:即时消息传递、支持表情符号、支持 GIF 和图像,按需聊天室或“频道”、广泛的兼容性和隐私性。[Matrix][12] 是一个用于实时通信的开放标准和轻量级协议,如果你厌烦于键入大段消息,则可以使用相同的协议快速切换到 VOIP。你将获得世界上最好的群聊体验。 + +Matrix 是一种协议,并且有许多应用程序可以接驳到它(就像使用 Internet 协议一样,Firefox 是使人类可以访问的应用程序)。最受欢迎的客户端之一是 [Riot.im][13]。你可以为你的计算机和手机下载 Riot,并且只是短时间使用的话,可以通过 Web 浏览器连接到 Riot。你的团队总是会近在咫尺,但永远不会近到让你感到不舒服。 + +### 共享文档:Etherpad + +![Etherpad screenshot][14] + +如果你想与他人协作处理文档或与开会,则仅需 Etherpad 就行。Etherpad 是一个实时共享的文字处理器。可以邀请一个或多个人访问文档,并在每个人进行添加和编辑时进行观察。这是一种快速有效的方法,可将想法记入“纸上”并一起迭代修订。 + +有几种使用 Etherpad 的方法。如果你拥有良好的 IT 支持,则可以要求你的 IT 部门为你的组织托管一个 Etherpad 实例。否则,将有来自开源支持者的在线公共实例,例如 [Riseup][15] 和 [Etherpad][16] 本身所提供的。 + +### 共享电子表格:Ethercalc + +![Ethercalc screenshot][17] + +与 Etherpad 相似,在线 [Ethercalc][18] 编辑器允许多个用户同时在同一屏幕上远程地在电子表格上工作。Ethercalc 甚至可以从现有电子表格和定界文本文件中导入数据。你可能会也可能不会丢失大部分格式,具体取决于要导入的内容的复杂性,但是我从来没有弄坏过我的数据,因此导入文件总是一个好的开始。 下次需要复杂公式的帮助时,或者需要在最新预算中输入收据时,或者只是需要某人在格子上的输入时,请将其输入到 Ethercalc。 + +### 共享存储与日历:Nextcloud + +![Nextcloud screenshot][19] + +[Nextcloud][20] 是一个心存远志的应用程序。顾名思义,它是你自己的个人云。它最明显的切入点是在线共享存储,它可以与台式机和移动设备上的文件夹同步。将文件放入文件中,文件会上传到存储空间,然后当一切内容都同步后,它们会出现在所有设备上。为组织中的每个人提供一个帐户,你马上便拥有了共享的存储空间,可以通过单击鼠标单击以共享带有或不带有密码的文件和文件夹。 + +但是,除了充当共享数据的保管箱之外,Nextcloud 还有很多其他功能。由于其插件式结构,你可以将无数的 Web 应用程序安装到 Nextcloud 中,例如聊天客户端、电子邮件客户端、视频聊天等等。并非所有插件都是“官方的”,因此其支持服务各不相同,但是有几个非常好的官方插件。值得注意的是,有一个官方的日历应用程序,你和你的同事可以用它安排会议并跟踪即将发生的重要事件。该日历使用 CalDAV 协议,因此你所做的一切都可以与任何 CalDAV 客户端兼容。 + +### LibreOffice + +![LibreOffice screenshot][21] + +如果你习惯于每天一整天都在办公室里工作,那么你也可能习惯整天在办公套件里工作。包含所有常用功能的面面俱到的应用程序会令人感到某种程度的舒适,而在开源办公世界中的这样的应用程序就是 [LibreOffice][22]。它具有办公套件所应有的一切:文字处理器、电子表格和幻灯片演示。它还具有超出预期的功能,例如基于矢量的绘图应用程序,它还可以编辑 PDF 文件,还有一个带有图形界面构建器的关系型数据库。如果你正在寻找一个好的办公应用程序,那么 LibreOffice 是你应该首先看一看的,因为一旦你使用它,你就再也不用看别的了。 + +### Linux + +![][23] + +如果你不熟悉远程工作,而可能是由于某种原因而正在经历一场重大变革。对于某些人来说,变革的时光是一个极好的动力,它可以一劳永逸地改变一切。如果你是其中的一员,那么可能是时候更改一下整个操作系统了。Windows 和 Mac 可能在过去为你提供了很好的服务,但是如果你希望从非开源软件转向开源软件,为什么不换一下运行所有这些应用程序的平台呢? + +有许多出色的 Linux 发行版可以让你认真地工作、认真地自我管理和认真地进阶。获取一份 Linux 副本,不论是 [Fedora][24]、[Elementary][25] 还是 [Red Hat Enterprise Linux][26] 的长期支持订购,去尝试使用自由的开源操作系统吧。等你熟悉了远程人的生活时,你最终将成为一名 Linux 专家! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/open-source-working-home + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/oatmeal-and-fedora.jpg?itok=NBFUH9eF (Oatmeal and a laptop.) +[2]: https://opensource.com/sites/default/files/uploads/jitsi_0.jpg (Jitsi screenshot) +[3]: http://meet.jit.si +[4]: https://opensource.com/sites/default/files/uploads/drawpile-whiteboard.jpg (Drawpile screenshot) +[5]: https://drawpile.net/ +[6]: https://opensource.com/sites/default/files/uploads/taiga_kanban_screen_0.jpg (Taiga screenshot) +[7]: http://taiga.io +[8]: https://opensource.com/alternatives/trello +[9]: https://opensource.com/sites/default/files/joplin_0.png (Joplin) +[10]: https://opensource.com/alternatives/evernote +[11]: https://opensource.com/sites/default/files/uploads/riot-matrix.jpg (Riot screenshot) +[12]: http://matrix.org +[13]: http://riot.im +[14]: https://opensource.com/sites/default/files/uploads/etherpad.jpg (Etherpad screenshot) +[15]: https://pad.riseup.net/ +[16]: https://beta.etherpad.org +[17]: https://opensource.com/sites/default/files/uploads/ethercalc.jpg (Ethercalc screenshot) +[18]: https://ethercalc.org +[19]: https://opensource.com/sites/default/files/uploads/nextcloud-calendar.jpg (Nextcloud screenshot) +[20]: http://nextcloud.com +[21]: https://opensource.com/sites/default/files/uploads/libreoffice.png (LibreOffice screenshot) +[22]: http://libreoffice.org +[23]: https://opensource.com/sites/default/files/uploads/advent-pantheon.jpg +[24]: https://getfedora.org/ +[25]: https://elementary.io +[26]: https://www.redhat.com/en/store/red-hat-enterprise-linux-workstation diff --git a/published/202003/20200319 4 Markdown tools for the Linux command line.md b/published/202003/20200319 4 Markdown tools for the Linux command line.md new file mode 100644 index 0000000000..0aa052696b --- /dev/null +++ b/published/202003/20200319 4 Markdown tools for the Linux command line.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12048-1.html) +[#]: subject: (4 Markdown tools for the Linux command line) +[#]: via: (https://opensource.com/article/20/3/markdown-apps-linux-command-line) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +4 个 Linux 命令行下的 Markdown 工具 +====== + +> 命令行 Markdown 工具快速、强大、灵活。以下是 4 个值得试一下的工具。 + +![](https://img.linux.net.cn/data/attachment/album/202003/29/112110pbd22dku6b2g6ku6.jpg) + +(在 Linux 上)在处理 [Markdown][2] 格式的文件时,命令行工具会占据主导地位。它们轻巧、快速、强大、灵活,它们大多数都遵循 Unix 哲学只做好一件事。 + +看一下这四个程序,它们可以帮助你在命令行中更有效地处理 Markdown 文件。 + +### mdless + +如果你使用过一段时间的 Linux 命令行,那么你可能对名为 [less][3] 的文本查看器很熟悉。当然,你可以使用 `less` 查看 Markdown 文件,但结果有点枯燥。如何在终端中查看 Markdown 文件效果更好一点?来使用 [mdless][4]。 + +![mdless][5] + +你可以使用键盘上的箭头键四处移动,并且 `mdless` 提供了很好的搜索功能。 + +`mdless` 不仅会显示文本,而且还会渲染标题、粗体和斜体等格式。它还可以显示表格并语法高亮代码块。你还可以创建一个或多个主题文件来[定制][6] `mdless` 的外观。 + +### Markdown lint 工具 + +你在快速输入时会犯错误。如果你在使用 Markdown(或其他任何标记语言)时丢失了一些格式,那么在将文件转换为另一种格式时可能会有问题。 + +程序员通常使用名为 linter 的工具来检查语法是否正确。你可以使用 [Markdown lint 工具][7]对 Markdown 执行相同的操作。 + +在你对 Markdown 文件运行该工具时,它会根据[规则集][8]检查格式。这些规则控制着文档的结构,包括标题级别的顺序、不正确的缩进和间距、代码块问题、文件中存在 HTML 等等。 + +![Markdown lint tool][9] + +规则可能有点严格。但是,在将文件转换为其他格式之前对文件运行 Markdown lint 工具可以防止由于格式错误或不一致引起的麻烦。 + +### mdmerge + +合并任何类型的文件可能会很痛苦。例如,我在整理一本电子书。它是一篇文章集,最初发布在我的[每周邮件][10]中。这些文章都放在单独的文件中,作为受虐狂,我以凌乱、手动的方式将它们组合在一起。 + +我希望在开始这个项目之前就知道 [mdmerge][11]。这样我可以节省很多时间和精力。 + +`mdmerge`,你可能已经从名称中猜到了它的作用,它将两个或多个 Markdown 文件合并为一个文件。你无需在命令行中输入文件名。相反,你可以将它们添加到名为 `book.txt` 的文件中,并将其用作 `mdmerge` 的输入文件。 + +这并不是 `mdmerge` 能做的一切。你可以添加对另一个文档的引用(使用 Markdown 格式引用或一段源代码),然后将其放入主文档中。这样一来,你就可以创建针对特定受众定制的[主文档][12]。 + +`mdmerge` 不会是你经常使用的程序。但当你需要时,你会很高兴硬盘上有它。 + +### bashblog + +严格说 [bashblog][13] 并不是 Markdown 工具。它获取 Markdown 文件,并使用它们来构建简单的博客或网站。你可以将 bashblog 视为[静态站点生成器][14],但是它没有很多脆弱的依赖关系。一切几乎都在一个不到 50KB 的 shell 脚本中。 + +要使用 bashblog,只需在计算机上安装 Markdown 处理器即可。在此,你可以编辑 Shell 脚本添加有关博客的信息,例如标题、名字、社交媒体链接等。然后运行该脚本。之后会在默认文本编辑器中新建一篇文章。开始输入。 + +保存文章后,你可以发布它或将其另存为草稿。如果你选择发布文章,那么 bashblog 会将你的博客、文章和所有内容生成为一组 HTML 文件,你可以将它们上传到 Web 服务器。 + +它开箱即用,你的博客或许会平淡无奇,但可以使用。你可以根据自己喜好编辑站点的 CSS 文件来改变外观。 + +![bashblog][15] + +### Pandoc 如何? + +当然,Panddoc 是一个非常强大的工具,可以将 Markdown 文件转换为其他标记语言。但是,在命令行上使用 Markdown 要比 Pandoc 多。 + +如果你需要 Pandoc,请查看我们发布的文章: + +* [在命令行使用 Pandoc 进行文件转换][16] +* [使用 Pandoc 将你的书转换成网页和电子书][17] +* [用 Pandoc 生成一篇调研论文][18] +* [使用 pandoc 将 Markdown 转换为格式化文档][19] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/markdown-apps-linux-command-line + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_os_rh2x.png?itok=jbRfXinl (A person working.) +[2]: https://opensource.com/article/19/9/introduction-markdown +[3]: https://opensource.com/article/18/4/using-less-view-text-files-command-line +[4]: https://github.com/ttscoff/mdless +[5]: https://opensource.com/sites/default/files/uploads/mdless.png (mdless) +[6]: https://github.com/ttscoff/mdless#customization +[7]: https://github.com/markdownlint/markdownlint +[8]: https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md +[9]: https://opensource.com/sites/default/files/uploads/mdl.png (Markdown lint tool) +[10]: https://buttondown.email/weeklymusings +[11]: https://github.com/JeNeSuisPasDave/MarkdownTools +[12]: https://help.libreoffice.org/6.2/en-US/text/swriter/guide/globaldoc.html +[13]: https://github.com/cfenollosa/bashblog +[14]: https://en.wikipedia.org/wiki/Web_template_system#Static_site_generators +[15]: https://opensource.com/sites/default/files/uploads/bashblog.png (bashblog) +[16]: https://linux.cn/article-10228-1.html +[17]: https://linux.cn/article-10287-1.html +[18]: https://linux.cn/article-10179-1.html +[19]: https://linux.cn/article-11160-1.html diff --git a/published/202003/20200319 7 open hardware projects working to solve COVID-19.md b/published/202003/20200319 7 open hardware projects working to solve COVID-19.md new file mode 100644 index 0000000000..3b3f5cf23e --- /dev/null +++ b/published/202003/20200319 7 open hardware projects working to solve COVID-19.md @@ -0,0 +1,208 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12047-1.html) +[#]: subject: (7 open hardware projects working to solve COVID-19) +[#]: via: (https://opensource.com/article/20/3/open-hardware-covid19) +[#]: author: (Harris Kenny https://opensource.com/users/harriskenny) + +应对新冠病毒的 7 个开源硬件项目 +====== + +> 开源硬件解决方案可以为抵御新型冠状病毒的传播和痛苦做出贡献。 + +![](https://img.linux.net.cn/data/attachment/album/202003/29/103909f50gm91z22twuv23.jpg) + +开源[硬件][2]运动长期以来一直主张维修权的重要性,完全拥有所购买的技术,并能够像音乐一样重新组合和复制部件。因此,在这个充满挑战的时期内,开源硬件为由冠状病毒大流行引起的一些问题提供了一些答案。 + +### 背景概述 + +首先,全球的硬件开发人员正在努力使用开源解决供应链中的弱点,在过去 30 年中,这种理念推动了新软件技术的大量涌现。过去在硬件运动方面的成功,如 [RepRap Project][3]、[Open Source Ecology][4] 和 [Open Source Beehives][5],证明了这一点是可以做到的。 + +对于使用 3D 打印和其他技术按需生产安全设备和按需制造它的替换零件,创客们的兴趣日益增加。例如,香港理工大学实验室为医院工作人员提供 [3D 打印面罩][6]。意大利初创公司 Isinnova 与米兰 FabLab 合作,为受重灾的意大利北部提供用于呼吸机的 [3D 打印替换阀][7]。公司们还发布了设计以适应我们的物理接触需求,例如 Materialise 的 [3D 打印免提开门器][8]。这些更换零件和解决问题的示例是一个很好的起点,为挽救生命做出了努力。 + +另一种传统的硬件技术正在加速发展:缝纫。法新社报道说,全球急需口罩,来自世界卫生组织的指导也指明了其重要性。随着一次性口罩要优先供给于医护人员,捷克共和国的人们[开始缝制自己的口罩][9]。(重复使用的口罩确实会带来细菌问题。)Facebook 小组“捷克缝制口罩”开始在他们的国家解决这个问题,成千上万的成员开始用起了他们的家用缝纫机。 + +开源硬件设备和机械项目也越来越受欢迎。首先,有一些测试性设备具备高精度且功能强大。其次,在没有其他选择方案的情况下,有一些医疗设备(顶多)可以归类为现场级。这些项目将在下面详细概述。 + +为了解更多信息,我与总部位于芝加哥的 [Tapster Robotics][10] 的创始人兼首席执行官 Jason Huggins 进行了交谈。Tapster Robotics 使用 3D 打印、计算机数控(CNC)加工和 [Arduino][11] 等开源电子产品设计和制造台式机器人。他兼具技术知识和工业能力,具有很高的影响力。他想投入自己公司的资源来帮助这场斗争。 + +“基本上,我们现在正处于第二次世界大战的动员时刻。即使我不是医生,我们仍然应该遵循希波克拉底誓言。无论我做什么,我都不想让问题变得更糟”,Huggins 解释,他认为:“作为对策,世卫组织执行主任 Michael Ryan 博士发表了这样的评论:‘速度胜过完美’。” + +> 哇! +> +> 这个人是疾病传播的全球权威。如果您是领导者(无论以何种身份),请注意。如果不是,也请注意。 +> +> [pic.twitter.com/bFogaekehM][12] +> +> — Jim RichardsSh🎙wgram(@JIMrichards1010)[2020 年 3 月 15 日][13] + +Huggins 在应需提供方面具有丰富的经验。他的努力有助于 [Healthcare.gov][14] 在挑战性的最初启动后得以扩展。他还创建了软件行业标准的测试框架 Selenium 和 Appium。有了这一经验,他的建议非常值得考虑。 + +我还与 [Tyson Law][15] 的西雅图律师 Mark Tyson 进行了交谈,他的合作对象是初创公司和小型企业。他在快速发展的行业中与敏捷公司合作有着直接的经验。在阐述整个问题时,Tyson 说到: + +> 《善良的撒玛利亚人法Good Samaritan law》保护志愿者(即“好撒玛利亚人”)免于因其在紧急情况下提供援助的决定而承担责任。尽管这些法律的具体内容因州而异,但它们具有共同的公共政策依据:即鼓励旁观者帮助遇到紧急情况的其他人。可以想象,除了传统的把车祸的受害者从伤害中拉出来之外,这种理论依据可以证明在不太传统的环境中应用这类法律的合理性。 + +对于这种特定情况,Tyson 指出: + +> “在采取行动之前,创客们明智的做法是与律师沟通一下,以针对特定的州进行风险评估。还应谨慎地要求大型机构(例如医院或保险公司)通过合同接受潜在的责任风险,例如,通过使用赔偿协议,使医院或其保险人同意赔偿创客们的责任。” + +Tyson 明白情况的紧迫性和严重性。使用合同的这种选择并不意味着障碍。相反,这可能是一种帮助其大规模采用的方法,以更快地产生更大的变化。这取决于你或你的机构。 + +综上所述,让我们探索正在使用或正在开发中的项目(可能很快就可以部署)。 + +### 7 个与新冠病毒对抗的开源硬件项目 + +#### Opentrons + +[Opentrons][16] 的开源实验室自动化平台由一套开源硬件、经过验证的实验室器具、消耗品、试剂和工作站组成。Opentrons 表示,其产品可以“在下订单后几天内每天自动进行多达 2400 个测试”的系统,可以极大地帮助提高[新冠病毒测试规模][17]。它计划在 7 月 1 日之前提升到多达 100 万个测试样本。 + +![Opentrons roadmap graphic][18] + +*来自 Opentrons [网站][17],版权所有* + +该公司已经在与联邦和地方政府机构合作,以确定其系统是否可以在[紧急使用授权][19]下用于临床诊断。 Opentrons 在 [Apache 2.0 许可证][20]下共享。我最初是从与该项目有联系的生物学家 Kristin Ellis 那里得知它的。 + +#### Chai 的 Open qPCR + +Chai 的 [Open qPCR][21] 设备使用[聚合酶链反应][22](PCR)快速检测物品表面(例如,门把手和电梯按钮)上的拭子,以查看是否存在新型冠状病毒。这种在 [Apache 2.0 许可证][23]下共享的开源硬件使用 [BeagleBone][24] 低功耗 Linux 计算机。Chai 的 Open qPCR 提供的数据可以使公共卫生、公民和企业领导者做出有关清洁、缓解、关闭设施、接触追踪和测试的更明智的决策。 + +#### OpenPCR + +[OpenPCR][25] 是 Chai Open qPCR 的创建者 Josh Perfetto 和 Jessie Ho 的 PCR 测试设备套件。与他们的前一个项目相比,这更像是一种 DIY 开源设备,但它具有相同的使用场景:使用环境测试来识别野外冠状病毒。正如该项目页面所指出的那样,“能够检测这些病原体的传统实时 PCR 设备通常花费超过 30,000 美元,而且不适合在现场使用。”由于 OpenPCR 是用户构建的工具包,并且在 [GPLv3.0 许可证][26]下共享,因此该设备旨在使分子诊断的访问大众化。 + +![OpenPCR][27] + +*来自 OpenPCR [网站][25],版权所有* + +而且,就像任何优秀的开源项目一样,它也有一个衍生产品!瑞士的 [Gaudi Labs][29] 推出的 [WildOpenPCR][28] 也以 [GPLv3.0 许可证][30]共享。 + +#### PocketPCR + +Gaudi Labs 的 [PocketPCR][31] 热循环仪可通过升高和降低小试管中液体的温度来激活生物反应。它可以通过简单的 USB 电源适配器供电,该适配器可以绑定到设备上,也可以单独使用,不使用计算机或智能手机时可使用预设参数。 + +![PocketPCR][32] + +*来自 PocketPCR [网站][31],版权所有* + +与本文所述的其他 PCR 产品一样,此设备可能有助于对冠状病毒进行环境测试,尽管其项目页面并未明确说明。PocketPCR 在 [GPLv3.0 许可证][33]下共享。 + +#### Open Lung 低资源呼吸机 + +[Open Lung 低资源呼吸机][34]是一种快速部署的呼吸机,它以[气囊阀罩][35](BVM)(也称为 Ambu 气囊)为核心组件。Ambu 气囊已批量生产,经过认证,体积小,机械简单,并且适用于侵入性导管和口罩。 Open Lung 呼吸机使用微电子技术来感测和控制气压和流量,以实现半自主运行。 + +![Open Lung ventilator][36] + +*Open Lung,[GitLab][37]* + +这个早期项目拥有一支由数百名贡献者组成的大型团队,领导者包括:Colin Keogh、David Pollard、Connall Laverty 和 Gui Calavanti。它是以 [GPLv3.0 许可证][38]共享的。 + +#### Pandemic 呼吸机 + +[Pandemic 呼吸机][39]是 DIY 呼吸机的原型。像 RepRap 项目一样,它在设计中使用了常用的硬件组件。该项目已由用户 Panvent 于 10 多年前上传到 Instructables,并且有六个主要的生产步骤。该项目是以 [CC BY-NC-SA 许可证][39]共享的。 + +#### Folding at Home + +[Folding at Home][40] 是一个分布式计算项目,用于模拟蛋白质动力学,包括蛋白质折叠的过程以及与多种疾病有关的蛋白质运动。这是一个面向公民科学家、研究人员和志愿者的行动呼吁,类似于退役的 [SETI@Home 项目][41]使用家中的计算机来运行解码计算。如果你是具备强大计算机硬件功能的技术人员,那么这个项目适合你。 + +![Markov state model][42] + +*Vincent Voelz,CC BY-SA 3.0* + +Folding at Home 项目使用马尔可夫状态模型(如上所示)来建模蛋白质可能采取的形状和折叠途径,以寻找新的治疗机会。你可以在华盛顿大学生物物理学家 Greg Bowman 的帖子《[它是如何运作的以及如何提供帮助][43]》中找到有关该项目的更多信息。 + +该项目涉及来自许多国家和地区(包括香港、克罗地亚、瑞典和美国)的财团的学术实验室、贡献者和公司赞助者。 在 [GitHub][45] 上,[在混合了 GPL 和专有许可证][44]下共享,并且可以在 Windows、macOS 和 GNU/Linux(例如 Debian、Ubuntu、Mint、RHEL、CentOS、Fedora)。 + +### 许多其他有趣的项目 + +这些项目只是在开源硬件领域中解决或治疗新冠病毒活动中的一小部分。在研究本文时,我发现了其他值得探索的项目,例如: + +* Coronavirus Tech Handbook 提供的[开源呼吸机、氧气浓缩器等][46] +* 来自 ProjectOpenAir 的 [有用的工程][47] +* Hackaday 上的[开源呼吸机黑客马拉松][48] +* 约翰·霍普金斯急诊医学住院医师 Julian Botta 的[简单开源机械呼吸机规范][49] +* [与冠状病毒有关的网络钓鱼、恶意软件和随机软件正在增加][50],作者:Shannon Morse +* [将低成本的 CPAP 鼓风机转换为基本呼吸机][51],作者: jcl5m1 +* [A.I.R.E. 论坛上关于开源呼吸器和风扇的讨论][52](西班牙语) +* [关于新冠病毒的开源医疗硬件的特殊问题][53],作者:Elsevier HardwareX + +这些项目遍布全球,而这种全球合作正是我们所需要的,因为病毒无视国界。新冠病毒大流行在不同时期以不同方式影响国家,因此我们需要一种分布式方法。 + +正如我和同事 Steven Abadie 在 [OSHdata 2020 报告][54]中所写的那样,开源硬件运动是全球性运动。参与该认证项目的个人和组织遍布全球 35 个国家地区和每个半球。 + +![Open source hardware map][55] + +*OSHdata,CC BY-SA 4.0 国际版* + +如果你有兴趣加入这场与全球开源硬件开发人员的对话,请加入[开源硬件峰会的 Discord][56] 服务器,并通过专用渠道进行有关新冠病毒的讨论。你在这里可以找到机器人专家、设计师、艺术家、固件和机械工程师、学生、研究人员以及其他共同为这场战争而战的人。希望可以看到你。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/open-hardware-covid19 + +作者:[Harris Kenny][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/harriskenny +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/health_heartbeat.png?itok=P-GXea-p (open on blue background with heartbeat symbol) +[2]: https://opensource.com/resources/what-open-hardware +[3]: https://reprap.org/wiki/RepRap +[4]: https://www.opensourceecology.org/ +[5]: https://www.osbeehives.com/ +[6]: https://www.scmp.com/news/hong-kong/health-environment/article/3052135/polytechnic-university-lab-3d-printing-face +[7]: https://www.3dprintingmedia.network/covid-19-3d-printed-valve-for-reanimation-device/ +[8]: https://www.3dprintingmedia.network/materialise-shows-3d-printed-door-opener-for-coronavirus-containment-efforts/ +[9]: https://news.yahoo.com/stitch-time-czechs-sew-combat-virus-mask-shortage-205213804.html +[10]: http://tapster.io/ +[11]: https://opensource.com/life/15/5/arduino-or-raspberry-pi +[12]: https://t.co/bFogaekehM +[13]: https://twitter.com/JIMrichards1010/status/1239140710558969857?ref_src=twsrc%5Etfw +[14]: http://Healthcare.gov +[15]: https://www.marktysonlaw.com/ +[16]: https://opentrons.com/ +[17]: https://blog.opentrons.com/testing-for-covid-19-with-opentrons/ +[18]: https://opensource.com/sites/default/files/uploads/opentrons.png (Opentrons roadmap graphic) +[19]: https://www.fda.gov/regulatory-information/search-fda-guidance-documents/policy-diagnostics-testing-laboratories-certified-perform-high-complexity-testing-under-clia-prior +[20]: https://github.com/Opentrons/opentrons/blob/edge/LICENSE +[21]: https://www.chaibio.com/openqpcr +[22]: https://en.wikipedia.org/wiki/Polymerase_chain_reaction +[23]: https://github.com/chaibio/chaipcr +[24]: https://beagleboard.org/bone +[25]: https://openpcr.org/ +[26]: https://github.com/jperfetto/OpenPCR/blob/master/license.txt +[27]: https://opensource.com/sites/default/files/uploads/openpcr.png (OpenPCR) +[28]: https://github.com/GenericLab/WildOpenPCR +[29]: http://www.gaudi.ch/GaudiLabs/?page_id=328 +[30]: https://github.com/GenericLab/WildOpenPCR/blob/master/license.txt +[31]: http://gaudi.ch/PocketPCR/ +[32]: https://opensource.com/sites/default/files/uploads/pocketpcr.png (PocketPCR) +[33]: https://github.com/GaudiLabs/PocketPCR/blob/master/LICENSE +[34]: https://gitlab.com/TrevorSmale/low-resource-ambu-bag-ventilor +[35]: https://en.wikipedia.org/wiki/Bag_valve_mask +[36]: https://opensource.com/sites/default/files/uploads/open-lung.png (Open Lung ventilator) +[37]: https://gitlab.com/TrevorSmale/low-resource-ambu-bag-ventilor/-/blob/master/images/CONCEPT_1_MECH.png +[38]: https://gitlab.com/TrevorSmale/low-resource-ambu-bag-ventilor/-/blob/master/LICENSE +[39]: https://www.instructables.com/id/The-Pandemic-Ventilator/ +[40]: https://foldingathome.org/ +[41]: https://setiathome.ssl.berkeley.edu/ +[42]: https://opensource.com/sites/default/files/uploads/foldingathome.png (Markov state model) +[43]: https://foldingathome.org/2020/03/15/coronavirus-what-were-doing-and-how-you-can-help-in-simple-terms/ +[44]: https://en.wikipedia.org/wiki/Folding@home +[45]: https://github.com/FoldingAtHome +[46]: https://coronavirustechhandbook.com/hardware +[47]: https://app.jogl.io/project/121#about +[48]: https://hackaday.com/2020/03/12/ultimate-medical-hackathon-how-fast-can-we-design-and-deploy-an-open-source-ventilator/ +[49]: https://docs.google.com/document/d/1FNPwrQjB1qW1330s5-S_-VB0vDHajMWKieJRjINCNeE/edit?fbclid=IwAR3ugu1SGMsacwKi6ycAKJFOMduInSO4WVM8rgmC4CgMJY6cKaGBNR14mpM +[50]: https://www.youtube.com/watch?v=dmQ1twpPpXA +[51]: https://github.com/jcl5m1/ventilator +[52]: https://foro.coronavirusmakers.org/ +[53]: https://www.journals.elsevier.com/hardwarex/call-for-papers/special-issue-on-open-source-covid19-medical-hardware +[54]: https://oshdata.com/2020-report +[55]: https://opensource.com/sites/default/files/uploads/oshdata-country.png (Open source hardware map) +[56]: https://discord.gg/duAtG5h diff --git a/published/202003/20200319 Fedora 32 Release Date, New Features and Everything Else.md b/published/202003/20200319 Fedora 32 Release Date, New Features and Everything Else.md new file mode 100644 index 0000000000..b47291dfe1 --- /dev/null +++ b/published/202003/20200319 Fedora 32 Release Date, New Features and Everything Else.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12044-1.html) +[#]: subject: (Fedora 32 Release Date, New Features and Everything Else) +[#]: via: (https://itsfoss.com/fedora-32/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Fedora 32 发布日期、新功能和其它信息 +====== + +Fedora 32 应该和 [Ubuntu 20.04 LTS][1] 一样都在 4 月底发布。 + +由于我们详细介绍了 Ubuntu 20.04,因此我们考虑在这里为 Fedora 粉丝做同样的事情。 + +在本文中,我将重点介绍 Fedora 32 的新功能。随着开发的进行,我将对本文进行更新。 + +### Fedora 32 的新功能 + +![][2] + +#### 启用了 EarlyOOM + +在此版本中,默认启用 [EarlyOOM][3]。提供一下背景知识,EarlyOOM 可以让用户在大量进行[交换][4]时轻松地摆脱内存不足状况恢复其系统。 + +值得注意的是,它适用于 Fedora 32 Beta 工作站版本。 + +#### 添加了 GNOME 3.36 + +新的 Fedora 32 工作站版也包含了新的 [GNOME 3.36][5]。不仅限于 Fedora 32 Beta 工作站版,[Ubuntu 20.04 LTS][1] 的每日构建版中也添加了它。 + +当然,GNOME 3.36 中的改进也进入了 Fedora 的最新版本,总体上提供了更快,更好的体验。因此,你将获得新的锁定屏幕、请勿打扰功能以及 GNOME 3.36 附带的所有其他功能。 + +#### 软件包更新 + +Fedora 32 版本还更新了许多重要的软件包,包括 Ruby、Perl 和 Python。它还有 [GNU 编译器集合(GCC)][6]的最新版本 10。 + +#### 其他更改 + +除了主要亮点之外,还有很多更改、改进或修复。你可以详细查看它的[更新日志][7]来了解有关更多信息。 + +### 下载Fedora 32(开发版) + +Fedora 32 仍在开发中。Beta 版已经发布,你可以在空闲系统或虚拟机上对其进行测试。**我不建议你在最终版本之前在主系统上使用它**。当前版本有一个官方的[已知 bug 列表] [8],你也可以参考。 + +在[官方公告][9]中,他们提到了 **Fedora 32 beta 工作站版**和**服务器版**以及其他流行版本的可用性。 + +要获取工作站和服务器版本,你必须访问 [Fedora 工作站][10]和 [Fedora 服务器][11]的官方下载页面(取决于你的需求)。 + +![Fedora Download Beta][12] + +打开后,你只需查找如上图所示的标记为 “**Beta!**” 的发行版,然后开始下载。对于其他变体版本,请单击下面的链接以转到各自的下载页面: + +* [Fedora 32 Beta Spins][13] +* [Fedora 32 Beta Labs][14] +* [Fedora 32 Beta ARM][15] + +你是否注意到 Fedora 32 中的其他新功能?你想在这里看到哪些功能?请随时在下面发表评论。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/fedora-32/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://itsfoss.com/ubuntu-20-04-release-features/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/update_fedora.jpg?ssl=1 +[3]: https://fedoraproject.org/wiki/Changes/EnableEarlyoom#Enable_EarlyOOM +[4]: https://itsfoss.com/swap-size/ +[5]: https://itsfoss.com/gnome-3-36-release/ +[6]: https://gcc.gnu.org/ +[7]: https://fedoraproject.org/wiki/Releases/32/ChangeSet +[8]: https://fedoraproject.org/wiki/Common_F32_bugs +[9]: https://fedoramagazine.org/announcing-the-release-of-fedora-32-beta/ +[10]: https://getfedora.org/workstation/download/ +[11]: https://getfedora.org/server/download/ +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/fedora-download-beta.jpg?ssl=1 +[13]: https://spins.fedoraproject.org/prerelease +[14]: https://labs.fedoraproject.org/prerelease +[15]: https://arm.fedoraproject.org/prerelease diff --git a/published/202003/20200319 Manually rotating log files on Linux.md b/published/202003/20200319 Manually rotating log files on Linux.md new file mode 100644 index 0000000000..ae5f7294e3 --- /dev/null +++ b/published/202003/20200319 Manually rotating log files on Linux.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12038-1.html) +[#]: subject: (Manually rotating log files on Linux) +[#]: via: (https://www.networkworld.com/article/3531969/manually-rotating-log-files-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 系统中手动滚动日志 +====== + +![](https://img.linux.net.cn/data/attachment/album/202003/25/223932xqibwq5fafx5ao3f.jpg) + +日志滚动log rotation在 Linux 系统上是再常见不过的一个功能了,它为系统监控和故障排查保留必要的日志内容,同时又防止过多的日志造成单个日志文件太大。 + +日志滚动的过程是这样的:在一组日志文件之中,编号最大的(最旧的)一个日志文件会被删除,其余的日志文件编号则依次增大并取代较旧的日志文件,而较新的文件则取代它作为当前的日志文件。这一个过程很容易就可以实现自动化,在细节上还能按需作出微调。 + +使用 `logrotate` 命令可以手动执行日志滚动的操作。本文将要介绍的就是手动进行日志滚动的方法,以及预期产生的结果。 + +文中出现的示例适用于 Ubuntu 等 Linux 系统,对于其它类型的系统,日志文件和配置文件可能会有所不同,但日志滚动的过程是大同小异的。 + +### 为什么需要滚动日志 + +一般情况下,无需手动旋转日志文件。Linux 系统会每隔一天(或间隔更长的时间)或根据日志文件的大小自动进行一次日志滚动。如果你需要滚动日志以释放存储空间,又或者将某一部分日志从当前的活动中分割出来,这很容易做到,具体要取决于文件滚动规则。 + +### 一点背景介绍 + +在 Linux 系统安装完成后就已经有很多日志文件被纳入到日志滚动的范围内了。另外,一些应用程序在安装时也会为自己产生的日志文件设置滚动规则。一般来说,日志滚动的配置文件会放置在 `/etc/logrotate.d`。如果你想了解日志滚动的详细实现,可以参考[这篇以前的文章][4]。 + +在日志滚动的过程中,活动日志会以一个新名称命名,例如 `log.1`,之前被命名为 `log.1` 的文件则会被重命名为 `log.2`,依此类推。在这一组文件中,最旧的日志文件(假如名为 `log.7`)会从系统中删除。日志滚动时文件的命名方式、保留日志文件的数量等参数是由 `/etc/logrotate.d` 目录中的配置文件决定的,因此你可能会看到有些日志文件只保留少数几次滚动,而有些日志文件的滚动次数会到 7 次或更多。 + +例如 `syslog` 在经过日志滚动之后可能会如下所示(注意,行尾的注释部分只是说明滚动过程是如何对文件名产生影响的): + +``` +$ ls -l /var/log/syslog* +-rw-r----- 1 syslog adm 128674 Mar 10 08:00 /var/log/syslog <== 新文件 +-rw-r----- 1 syslog adm 2405968 Mar 9 16:09 /var/log/syslog.1 <== 之前的 syslog +-rw-r----- 1 syslog adm 206451 Mar 9 00:00 /var/log/syslog.2.gz <== 之前的 syslog.1 +-rw-r----- 1 syslog adm 216852 Mar 8 00:00 /var/log/syslog.3.gz <== 之前的 syslog.2.gz +-rw-r----- 1 syslog adm 212889 Mar 7 00:00 /var/log/syslog.4.gz <== 之前的 syslog.3.gz +-rw-r----- 1 syslog adm 219106 Mar 6 00:00 /var/log/syslog.5.gz <== 之前的 syslog.4.gz +-rw-r----- 1 syslog adm 218596 Mar 5 00:00 /var/log/syslog.6.gz <== 之前的 syslog.5.gz +-rw-r----- 1 syslog adm 211074 Mar 4 00:00 /var/log/syslog.7.gz <== 之前的 syslog.6.gz +``` + +你可能会发现,除了当前活动的日志和最新一次滚动的日志文件之外,其余的文件都已经被压缩以节省存储空间。这样设计的原因是大部分系统管理员都只需要查阅最新的日志文件,其余的日志文件压缩起来,需要的时候可以解压查阅,这是一个很好的折中方案。 + +### 手动日志滚动 + +你可以这样执行 `logrotate` 命令进行手动日志滚动: + +``` +$ sudo logrotate -f /etc/logrotate.d/rsyslog +``` + +值得一提的是,`logrotate` 命令使用 `/etc/logrotate.d/rsyslog` 这个配置文件,并通过了 `-f` 参数实行“强制滚动”。因此,整个过程将会是: + +- 删除 `syslog.7.gz`, +- 将原来的 `syslog.6.gz` 命名为 `syslog.7.gz`, +- 将原来的 `syslog.5.gz` 命名为 `syslog.6.gz`, +- 将原来的 `syslog.4.gz` 命名为 `syslog.5.gz`, +- 将原来的 `syslog.3.gz` 命名为 `syslog.4.gz`, +- 将原来的 `syslog.2.gz` 命名为 `syslog.3.gz`, +- 将原来的 `syslog.1.gz` 命名为 `syslog.2.gz`, +- 但新的 `syslog` 文件不一定必须创建。 + +你可以按照下面的几条命令执行操作,以确保文件的属主和权限正确: + +``` +$ sudo touch /var/log/syslog +$ sudo chown syslog:adm /var/log/syslog +$ sudo chmod 640 /var/log/syslog +``` + +你也可以把以下这一行内容添加到 `/etc/logrotate.d/rsyslog` 当中,由 `logrotate` 来帮你完成上面三条命令的操作: + +``` +create 0640 syslog adm +``` + +整个配置文件的内容是这样的: + +``` +/var/log/syslog +{ +rotate 7 +daily +missingok +notifempty +create 0640 syslog adm <== +delaycompress +compress +postrotate +/usr/lib/rsyslog/rsyslog-rotate +endscript +} +``` + +下面是手动滚动记录用户登录信息的 `wtmp` 日志的示例。由于 `/etc/logrotate.d/wtmp` 中有 `rotate 2` 的配置,因此系统中只保留了两份 `wtmp` 日志文件。 + +滚动前: + +``` +$ ls -l wtmp* +-rw-r----- 1 root utmp 1152 Mar 12 11:49 wtmp +-rw-r----- 1 root utmp 768 Mar 11 17:04 wtmp.1 +``` + +执行滚动命令: + +``` +$ sudo logrotate -f /etc/logrotate.d/wtmp +``` + +滚动后: + +``` +$ ls -l /var/log/wtmp* +-rw-r----- 1 root utmp 0 Mar 12 11:52 /var/log/wtmp +-rw-r----- 1 root utmp 1152 Mar 12 11:49 /var/log/wtmp.1 +-rw-r----- 1 root adm 99726 Feb 21 07:46 /var/log/wtmp.report +``` + +需要知道的是,无论发生的日志滚动是自动滚动还是手动滚动,最近一次的滚动时间都会记录在 `logrorate` 的状态文件中。 + +``` +$ grep wtmp /var/lib/logrotate/status +"/var/log/wtmp" 2020-3-12-11:52:57 +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3531969/manually-rotating-log-files-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.flickr.com/photos/klif/4244284159/in/photolist-7t44P6-oPFpsr-a8c5W-gWNZ6-32EEo4-cjdxqy-diHaq9-8DYZWf-gWNWM-bgLApc-hBt94C-cj71kY-PMESV-dZBcCU-pSqgNM-51eKHq-EecbfS-osGNau-KMUx-nFaWEL-cj71PE-HFVXn-gWNWs-85HueR-8QpDh8-kV1dEc-76qYSV-5YnxuS-gWNXr-dYoQ5w-dzj1j3-3AJyd-mHbaWF-q2fTri-e9bFa6-nJyvfR-4PnMyH-gWNZr-8VUtGS-gWNWZ-ajzUd4-2hAjMk-gWW3g-gWP11-dwYbH5-4XMew-cj71B1-ica9kJ-5RonM6-8z5tGL +[2]: https://creativecommons.org/licenses/by/2.0/legalcode +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3218728/how-log-rotation-works-with-logrotate.html +[5]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[6]: https://www.facebook.com/NetworkWorld/ +[7]: https://www.linkedin.com/company/network-world diff --git a/published/202003/20200322 Linus Torvalds- Advice on Working From Home during Coronavirus Lockdown.md b/published/202003/20200322 Linus Torvalds- Advice on Working From Home during Coronavirus Lockdown.md new file mode 100644 index 0000000000..753398999f --- /dev/null +++ b/published/202003/20200322 Linus Torvalds- Advice on Working From Home during Coronavirus Lockdown.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12029-1.html) +[#]: subject: (Linus Torvalds’ Advice on Working From Home during Coronavirus Lockdown) +[#]: via: (https://itsfoss.com/torvalds-remote-work-advice/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Linus Torvalds 关于在冠状病毒禁足期间在家工作的建议 +====== + +在冠状病毒爆发期间,我们中的许多人都在室内自我隔离。[ZDNet][1] 特此与 Linus Torvalds 进行了专题采访,讨论了他对冠状病毒禁足期间在家工作的看法或想法。 + +如果你还不知道(怎么可能不知道),[Linus Torvalds][2] 是 Linux 的创建者,也是 [Git][3] 的创建者,而所有这一切都是他在家里工作时做的。这是 2016 年的视频,Torvalds 展示了他的家庭办公室: + +- [video](https://img.linux.net.cn/static/video/Linus%20Torvalds%20Guided%20Tour%20of%20His%20Home%20Office-SOXeXauRAm0.mp4) + +因此,在本文中,我将分享我关注的一些主要要点,以及来自 Linus Torvalds 接受 ZDNet [Steven J. Vaughan-Nichols][4] 采访互动时的回应。 + +### 消除对人际交往缺失的恐惧 + +Linus 提到,几年前刚开始在家工作时,他担心过缺少人与人之间的互动,包括去办公室、与人互动或哪怕只是出去吃个午餐。 + +有趣的是,他似乎并没有错过任何东西,他更喜欢在家中没有人际交往的时间。 + +当然,将自己与人际互动隔离开并不是最好的事情 ,但在目前看来,这是一件好事。 + +### 利用在家工作的优势 + +![][5] + +就像我们是完全远程操作一样,你可以做很多事情,而无需实际在办公室。 + +不要忘记,你可以随心所欲地养猫,我有 6 只猫,我知道这很困难(*哈哈*)。 + +而且,正如 Linus 所提到的,远程工作的真正优势在于“灵活性”。你不一定需要朝九晚五甚至更长的时间坐在办公桌前。从技术上讲,你可以在工作中自由休息,并在家中做你想做的任何事情。 + +换句话说,Linus 建议**不要在你的家中重新搞一个办公室**,这比去办公室还差。 + +### 高效沟通是关键 + +![][6] + +虽然你可以在一天之中召开几次会议(视频会议或音频呼叫),但这真的有必要吗? + +对于某些人来说,这可能很重要,但是你应该通过简化和整理内容来尽量减少会议花费的时间。 + +或者,按照 Linus 的建议,最好有个电子邮件列表来记录事情,以确保一切各司其职,这就是 [Linux 内核][7] 的运行方式。 + +James Bottomley 是 [IBM 研究院][8]的杰出工程师,也是资深 Linux 内核开发人员,他也建议你重新阅读你的文字以确保发送的准确信息不会被人不小心跳过。 + +就个人而言,出于同样的原因,我更喜欢文本而不是语音。实际上,它可以节省你的时间。 + +但是,请记住,你需要只以适当的方式传达必要的信息,而不要使通过文本/电子邮件发送的信息过载。 + +### 追踪你的时间 + +灵活性并不一定意味着你可以减少工作量并泡在社交媒体平台上,除非那就是你的工作。 + +因此,你需要确保充分利用自己的时间。为此,你可以使用多种工具来跟踪你的时间用在什么地方,以及在计算机上花费的时间。 + +你甚至可以将其记录在便签上,以确保你可以将时间高效地分配于工作上。你可以选择使用 [RescueTime][9] 或 [ActivityWatch][10] 来跟踪你在计算机或智能手机上花费的时间。 + +### 和猫(宠物)一起玩 + +![][11] + +不歧视其他宠物,但这就是 Linus Torvalds 提到的。 + +正因为你在家中,你在安排工作或尝试有效利用时间时要做的事情有很多。 + +Linus 坚持认为,每当你感到无聊时,可以在必要时出门获取必需品,也可以与猫(或你的其它宠物)一起玩。 + +### 结语 + +虽然 Linus 还提到了当你在家时没人会评判你,但他的建议似乎是正确的,对于那些在家工作的人来说可能很有用。 + +不仅是因为冠状病毒的爆发,而且如果你打算一直在家工作,应该牢记这些。 + +你如何看待 Linus 的看法呢?你同意他的观点吗? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/torvalds-remote-work-advice/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://www.zdnet.com/article/pet-the-cat-own-the-bathrobe-linus-torvalds-on-working-from-home/ +[2]: https://en.wikipedia.org/wiki/Linus_Torvalds +[3]: https://git-scm.com/ +[4]: https://twitter.com/sjvn +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/Work-from-Home-torvalds.jpg?ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/torvalds-home-office.jpg?ssl=1 +[7]: https://en.wikipedia.org/wiki/Linux_kernel +[8]: https://www.research.ibm.com/ +[9]: https://www.rescuetime.com/ +[10]: https://activitywatch.net/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/torvalds-penguins.jpeg?ssl=1 diff --git a/published/202003/20200322 Meet DebianDog - Puppy sized Debian Linux.md b/published/202003/20200322 Meet DebianDog - Puppy sized Debian Linux.md new file mode 100644 index 0000000000..c5b50c7670 --- /dev/null +++ b/published/202003/20200322 Meet DebianDog - Puppy sized Debian Linux.md @@ -0,0 +1,120 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12059-1.html) +[#]: subject: (Meet DebianDog – Puppy sized Debian Linux) +[#]: via: (https://itsfoss.com/debiandog/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +体验 DebianDog:Puppy 式的 Debian Linux +====== + +不久前,我偶然发现了一个有趣的 Linux 项目。这个项目旨在为 Debian 和基于 Debian 的系统创建一个小型的现场版 CD,类似于 [Puppy Linux 项目][1] 。让我们看看 DebianDog 。 + +### DebianDog 是什么? + +正如字面所述,[DebianDog][2] “是一个被塑造成一个外观和动作都像 Puppy Linux 的小型 Debian 现场版 CD。没有改动 Debian 结构和方式,Debian 的文档对 DebianDog 来说是完全有效的。你可以使用 `apt-get` 或 synaptic 来访问所有的 Debian 存储库。” + +![DebianDog][3] + +对于那些不熟悉 [Puppy Linux][1] 的人来说,该项目是 “多个 Linux 发行版的一个集合,建立在相同的共享准则之上”。这些准则能够实现快速、小型(300 MB 或更少)、易于使用。这里有为支持 Ubuntu, Slackware 和 Raspbian 软件包构建的 Puppy Linux 变种。 + +DebianDog 和 Puppy Linux 之间最大的不同是,Puppy Linux 有其自己的软件包管理器 [Puppy 软件包管理器][4] 。如上所述,DebianDog 使用 Debian 软件包管理器及其软件包。甚至 DebianDog 网站也试图澄清这一点:“它不是 Puppy Linux,并且也与基于 Debian 的 Puppy 无关。” + +### 为什么一些人使用 DebianDog ? + +安装 DebianDog(或其任何衍生产品)的主要原因是让一台较旧电脑重焕新生。在 DebianDog 上的每个版本都有一个 32 位版本。它们还有更轻量级的桌面环境/窗口管理器,例如 [Openbox][5] 或 [Trinity Desktop][6] 环境。它们中大多数也都有一个 systemd 的可替代版本。它们也安装更轻的应用程序,例如 [PCManFM][7] 。 + +### DebianDog 有哪些可用的变体版本? + +尽管 DebianDog 在本系列中是第一个,但是该项目被称为 ‘Dog Linux’ ,提供各种基于Debian 和 Ubuntu的流行发行版的 ‘Dog 变体’。 + +#### DebianDog Jessie + +DebianDog 的第一个(也是最初的)版本是 DebianDog Jessie。它有两个 [32 位版本][8] ,一个使用 [Joe’s Window Manager (JWM)][9] 作为默认桌面环境,另一个使用 XFCE 作为默认桌面环境。systemd 和 sysvinit 都是可用的。它还有一个 [64 位版本][10]。DebianDog Jessie 基于 Debian 8.0(Jessie)。Debian 8.0 的支持将于 2020 年 6 月 30 日结束,因此安装需谨慎。 + +#### StretchDog + +[StretchDog][12] 基于 Debian 9.0(Stretch)。它有 32 位和 64 位两种版本可用。Openbox 是默认的窗口管理器,但是我们可以切换到 JWM 。Debian 9.0 的支持将于 2022 年 6 月 30 日结束。 + +#### BusterDog + +[BusterDog][13] 是很有趣的。它基于 [Debian 10][14](Buster)。它不使用 systemd,反而像 [AntiX][16] 一样使用 [elogind][15] 。Debian 10.0 的支持将于 2024 年 6 月结束。 + +#### MintPup + +[MintPup][17] 基于 [Linux Mint][18] 17.1。现场版 CD 仅有 32 位版本。你也可以使用 “apt-get 或 synaptic 访问 Ubuntu/Mint 的存储库”。考虑到 Mint 17 已经到了生命的尽头,这一版本必须避免使用。 + +#### XenialDog + +XenialDog 有 [32 位][19]和 [64 位][20] 两种变种,基于 Ubuntu 16.04 LTS 。两个变种都使用 Openbox 作为默认版本,JWM 可选。Ubuntu 16.04 LTS 的支持将于 2021 年 4 月结束, 因此安装需谨慎。 + +#### TrinityDog + +[TrintyDog][21] 有两种变体。一个基于 Debian 8 ,另一个基于 Debian 9 。两种变体都有 32 位版本,并且都使用 [Trinity Desktop Environment][6] ,以此得名。 + +![TrinityDog][11] + +#### BionicDog + +你应该能够从名称猜到。[BionicDog][23] 基于 [Ubuntu 18.04 LTS][24]。主要版本有 32 位和 64 位两个版本,Openbox 是默认的窗口管理器。这里也有一个使用 [Cinnamon desktop][25] 的版本,并且只有 64 位版本。 + +![BionicDog][22] + +### 结束语 + +我喜欢任何 [想让较旧电脑系统有用的 Linux 项目][26]。但是,通过 DebianDog 项目提供的大多数操作系统不再受支持,或者接近它们的生命尽头。从长远来看,这就不那么有用了。 + +**我不建议在你的主计算机上使用它。**在现场版 USB 中或一台闲置的系统上尝试它。此外,如果你想使用较新的基础系统,[你可以创建][27]你自己的现场版 CD 。 + +似乎冥冥中自有天意,我总是在探索鲜为人知的 Linux 发行版的路上艰难地前行,像 [FatDog64][28]、[4M Linux][29] 以及 [Vipper Linux][30] 。虽然我不建议使用它们,但是知晓这些项目的存在的意义总是好的。 + +你对 DebianDog 有什么看法?你最最喜欢的 Puppy 式的操作系统是什么?请在下面的评论区中告诉我们。 + +如果你觉得这篇文章很有趣,请花点时间在社交媒体、黑客新闻或 Reddit 上分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/debiandog/ + +作者:[John Paul][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/john/ +[b]: https://github.com/lujun9972 +[1]: http://puppylinux.com/ +[2]: https://debiandog.github.io/doglinux/ +[3]: https://www.linuxinsider.com/article_images/2017/84328_990x556.jpg +[4]: http://wikka.puppylinux.com/PPM?redirect=no +[5]: http://openbox.org/wiki/Main_Page +[6]: https://www.trinitydesktop.org/ +[7]: https://wiki.lxde.org/en/PCManFM +[8]: https://debiandog.github.io/doglinux/zz01debiandogjessie.html +[9]: https://en.wikipedia.org/wiki/JWM +[10]: https://debiandog.github.io/doglinux/zz02debiandog64.html +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/TrinityDog.jpg?ssl=1 +[12]: https://debiandog.github.io/doglinux/zz02stretchdog.html +[13]: https://debiandog.github.io/doglinux/zz03busterdog.html +[14]: https://itsfoss.com/debian-10-buster/ +[15]: https://github.com/elogind/elogind +[16]: https://antixlinux.com/ +[17]: https://debiandog.github.io/doglinux/zz04mintpup.html +[18]: https://linuxmint.com/ +[19]: https://debiandog.github.io/doglinux/zz05xenialdog.html +[20]: https://debiandog.github.io/doglinux/zz05zxenialdog.html +[21]: https://debiandog.github.io/doglinux/zz06-trinitydog.html +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/BionicDog.jpg?ssl=1 +[23]: https://debiandog.github.io/doglinux/zz06-zbionicdog.html +[24]: https://itsfoss.com/ubuntu-18-04-released/ +[25]: https://en.wikipedia.org/wiki/Cinnamon_(desktop_environment) +[26]: https://itsfoss.com/lightweight-linux-beginners/ +[27]: https://github.com/DebianDog/MakeLive +[28]: https://itsfoss.com/fatdog64-linux-review/ +[29]: https://itsfoss.com/4mlinux-review/ +[30]: https://itsfoss.com/viperr-linux-review/ +[31]: https://reddit.com/r/linuxusersgroup diff --git a/published/202003/20200322 Purism Librem Mini- A Privacy-First Linux-Based Mini PC.md b/published/202003/20200322 Purism Librem Mini- A Privacy-First Linux-Based Mini PC.md new file mode 100644 index 0000000000..3df6585958 --- /dev/null +++ b/published/202003/20200322 Purism Librem Mini- A Privacy-First Linux-Based Mini PC.md @@ -0,0 +1,107 @@ +[#]: collector: "lujun9972" +[#]: translator: "wxy" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12042-1.html" +[#]: subject: "Purism Librem Mini: A Privacy-First Linux-Based Mini PC" +[#]: via: "https://itsfoss.com/purism-librem-mini/" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" + +Purism Librem Mini:隐私为重的基于 Linux 的微型个人电脑 +====== + +> Purism 推出了一款外形小巧的微型个人电脑 “Librem Mini”,旨在提供隐私和安全性。让我们来看看它的细节。 + +[Purism][1] 以专注于增强用户的数字隐私和安全性的服务或产品而闻名。 + +Purism 自诩为“[社会目地公司][2]Social Purpose Company”,旨在为社会造福,并在这方面提供了多种服务和产品。 + +你可能听说过它的 Librem 系列 [Linux 笔记本电脑][3]、[Librem One][4](加密服务)、[PureOS Linux][5] 和 [Librem 5 Linux 智能手机][6]。现在,他们已经针对想要掌控自己的隐私和安全性的用户推出了小尺寸微型个人电脑。 + +### Librem Mini: Purism 的微型个人电脑 + +![Librem Mini PC][7] + +[Purism][1] 的 [Librem Mini][8] 旨在成为小型、轻便且功能强大的微型个人电脑。 + +当然,已经有很多[基于 Linux 的微型个人电脑][9]了,但是 Librem Mini 专门关注于其用户的隐私和安全性。它随附了 [PureOS][5]、[Pureboot][10] 和 [Librem Key][11] 支持。 + +基本配置将以 699 美元的价格提供。这比大多数其他微型个人电脑要贵。但是,与大多数其他产品不同,Librem Mini 并不是又一个 [Intel NUC][12]。 那么,它提供了什么呢? + +### Librem Mini 的规格 + +![][13] + +这是它的规格表: + + * Intel Core i7-8565U(Whiskey Lake),主动(风扇)冷却,4 核 8 线程最高频率 4.6GHz + * Intel UHD Graphics 620 + * RAM: 最多 64 GB DDR4 2400 MHz(2 个 SO-DIMM 插槽) + * 1 SATA III 6GB/s SSD/HDD(7mm) + * 1 M.2 SSD(SATA III/NVMe x4) + * 1 HDMI 2.0 4K @ 60Hz + * 1 DisplayPort 1.2 4K @ 60Hz + * 4 x USB 3.0 + * 2 x USB 2.0 + * 1 x Type-C 3.1 + * 3.5mm 音频插孔(麦克风输入和耳机插孔合一) + * 1 RJ45 Gigabit Ethernet LAN + * WiFi 802.11n(2.4/5.0 GHz),可选 Atheros ATH9k 模块 + * 包括在 WiFi 模块的蓝牙 4.0(可选) + * 重量:1 公斤(2.2 磅) + * 尺寸:12.8 厘米(5.0 英寸) x 12.8 厘米(5.0 英寸) x 3.8 厘米(1.5 英寸) + +我不知道他们为什么决定采用 Intel 的 8 代处理器,而市场上已经出现了 10 代处理器。也许是因为 Whiskey Lake 是第 8 代处理器的最新产品。 + +是的,他们已禁用并中止了 Intel 的管理引擎,所以仍然可以采用这个产品。 + +除此之外,你还应该记住,这款微型个人电脑在提供全盘加密的同时具有检测硬件和软件篡改的功能。 + +而且,当然,用的是 Linux。 + +### 价格和供应 + +![Librem Mini from the back][14] + +具有 8 Gigs RAM 和 256 GB SSD 的基本配置将需要花费 $699。而且,如果你想要最强大的配置,其价格轻松就升高到 $3000。 + +他们的预定销售额目标是 $50,000,并且他们计划在达到预定目标后一个月内开始发货。 + +因此,如果你要是现在[预订][15]的话,不要指望很快就会开始发货。因此,我建议你关注 [Librem Mini 产品页面][8]的预定目标。 + +### 总结 + +如果你正在寻找一台微型个人电脑(不是专门为隐私和安全而设计的),则可以看看我们的[基于 Linux 的最佳微型个人电脑][9]列表,以获取更多建议。 + +对于普通消费者而言,Librem Mini 绝对听起来很昂贵。对于隐私发烧友来说,它仍然是一个不错的选择。 + +你怎么看?让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/purism-librem-mini/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://puri.sm/ +[2]: https://puri.sm/about/social-purpose/ +[3]: https://itsfoss.com/get-linux-laptops/ +[4]: https://itsfoss.com/librem-one/ +[5]: https://itsfoss.com/pureos-convergence/ +[6]: https://itsfoss.com/librem-linux-phone/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/librem-mini-pc.png?ssl=1 +[8]: https://puri.sm/products/librem-mini/ +[9]: https://itsfoss.com/linux-based-mini-pc/ +[10]: https://docs.puri.sm/PureBoot.html +[11]: https://puri.sm/products/librem-key/ +[12]: https://itsfoss.com/intel-nuc-essential-accessories/ +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/librem-mini-pc-1.png?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/librem-mini-back.png?ssl=1 +[15]: https://shop.puri.sm/shop/librem-mini/ diff --git a/published/202003/20200327 How open source software is fighting COVID-19.md b/published/202003/20200327 How open source software is fighting COVID-19.md new file mode 100644 index 0000000000..28429de34e --- /dev/null +++ b/published/202003/20200327 How open source software is fighting COVID-19.md @@ -0,0 +1,108 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12057-1.html) +[#]: subject: (How open source software is fighting COVID-19) +[#]: via: (https://opensource.com/article/20/3/open-source-software-covid19) +[#]: author: (Jeff Stern https://opensource.com/users/jeffstern) + +开源软件在应对新冠病毒中的贡献 +====== + +> 在新冠疫情爆发之际,涌现了数以千计的开源项目,今天我们来了解其中四个。 + +![](https://img.linux.net.cn/data/attachment/album/202003/30/210613wchojyc5rrwh8y5k.jpg) + +在当前紧张的疫情环境下,保持专注和积极性是一个很大的挑战。而研究开源社区如何应对这一次疫情爆发,对于我来说却成为了一种宣泄。 + +从今年一月底开始,整个开源社区已经贡献了数以千计关于冠状病毒或新冠病毒的[开源软件仓库][2],其中涉及的内容包括但不限于数据集、模型、可视化、Web 应用、移动应用,且大多数都使用了 JavaScript 和 Python 编写。 + +之前我们分享过一些关于[开源硬件创客们在帮助][3]遏制冠状病毒传播方面做的贡献,现在将继续分享四个由开源社区作出的应对冠状病毒和新冠病毒的项目,这体现了开发者们和整个开源社区在当下对整个世界的影响力。 + +### 1. PennSignals:CHIME + +![CHIME by PennSignals][4] + +新冠病毒流行病医院影响模型COVID-19 Hospital Impact Model for Epidemics([CHIME][5])是由宾夕法尼亚大学 Penn Medicine 机构的数据科学家们建立的开源在线应用,它可以让医院更好地了解本次新型冠状病毒对医院需求的影响。 + +医院的管理人员可以通过 CHIME 来大致预测未来几天和几周内将会有多少患者需要住院治疗,并推算 ICU 和呼吸机的需求量。只需要输入当前住院患者数以及一些相关的变量,就可以看到未来几天内需求的变化情况。 + +CHIME 主要使用 Python 开发,并通过 [Pandas][6] 这个开源库实现了大部分的数据转换和数值计算,最终得出相关的估计值。Pandas 的背后有一个强大的团队进行支持,它是在数据分析方面被广泛使用的 Python 库之一。和很多其它的开源项目一样,Pandas 团队的收入大部分来源于[用户的资金支持][7]。 + +### 2. Locale.ai:实时新冠病毒可视化 + +![Locale.ai COVID-19 visualization][8] + +实时显示世界各地病例数量分布的地图可以让我们直观了解新冠病毒的规模和扩散程度。Locale.ai 就开发了这样一个开源、可交互的[新冠病毒已知病例可视化分布图][9],这个图会根据最新的可靠数据实时进行更新。 + +这个项目有趣的地方在于,它的数据是是通过 GitHub 用户 ExpDev07 创建的[开源 API][10] 进行检索的,这个 API 的数据来源是[约翰·霍普金斯大学的开源数据集][11],而约翰·霍普金斯大学这份聚合了多个来源的数据集则是 GitHub 上新冠病毒相关的最受欢迎的项目。这就是开源领域中分支带来的一大好处。 + +Locale.ai 的这个图表通过 [Vue.js][11] 开发。Vue.js 是一个在 Web 应用开发方面非常流行的框架,它是由[尤雨溪][12]创造并维护的。值得一提的是,尤雨溪是少数以全职参与开源项目维护的人之一。 + +### 3. BlankerL:DXY-COVID-19-Crawler + +![BlankerL DXY-COVID-19-Crawler][13] + +[DXY-COVID-19-Crawler][14] 建立于今年 1 月份,是开源社区对新冠病毒最早发起响应的项目之一。当时该病毒主要在中国范围内传播,中国医学界通过[丁香园][15]网站来进行病例的报告和跟踪。为了使这些疫情信息具有更高的可读性和易用性,GitHub 用户 BlankerL 开发了一个爬虫,系统地从丁香园网站获取数据,并通过 API 和数据仓库的方式对外公开。这些数据也被学术研究人员用于研究病毒传播趋势和制作相关的可视化图表。到目前为止,DXY-COVID-19-Crawler 这个项目已经获得了超过 1300 个星标和近 300 次的复刻。 + +BlankerL 使用 Python 和 [Beautiful Soup][16] 库开发了这个爬虫。Beautiful Soup 是 Python 开发者用于从页面 HTML DOM 中提取信息的库,它由 Leonard Richardson 维护,这位作者另外还全职担任软件架构师。 + +### 4. 东京新冠病毒工作组网站 + +![City of Tokyo's COVID-19 Task Force site][17] + +世界各地很多城市都在网络上持续更新当地的新冠病毒信息。东京都政府则为此创建了一个[综合性的网站][18],让东京当地居民、在东京设有办事处的公司以及到东京的游客了解最新情况,并采取相应的预防措施。 + +这个网站的不同之处在于它是由东京都政府[开源][19]的。这个项目受到了来自 180 多名用户的贡献,日本的[长野市、千叶市、福冈市][20]还对这个网站进行了改造。这个项目是城市公共建设更好地服务大众的有力示范。 + +这个开源网站也使用了很多开源技术。通过 [Tidelift][21],我留意到项目中存在了 1365 个依赖项,而这都是由 38 个由开发者明确使用的直接依赖项所依赖的。也就是说,超过一千多个开源项目(包括 [Nuxt.js][22]、[Prettier][23]、[Babel][24]、[Ajv][25] 等等)都为东京向市民共享信息提供了帮助。 + +![Dependencies in Tokyo's COVID-19 Task Force site][26] + +### 其它项目 + +除此以外,还有很多[应对新冠病毒的重要项目][27]正在公开进行当中。在这次研究中,开源社区应对流行病以及利用开源技术开展工作的方式让我深受启发。接下来的一段时间都是应对疫情的关键时期,我们也可以继续在开源社区中寻找到更大的动力。 + +如果你也参与到了新冠病毒相关的开源项目当中,欢迎在评论区分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/open-source-software-covid19 + +作者:[Jeff Stern][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jeffstern +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/Medical%20costs.jpg?itok=ke57j6cs (symbols showing healthcare) +[2]: https://github.com/search?q=coronavirus+OR+covid19 +[3]: https://linux.cn/article-12047-1.html +[4]: https://opensource.com/sites/default/files/uploads/chime_pennsignals.png (CHIME by PennSignals) +[5]: http://penn-chime.phl.io/ +[6]: https://tidelift.com/subscription/pkg/pypi-pandas +[7]: https://pandas.pydata.org/about/sponsors.html +[8]: https://opensource.com/sites/default/files/uploads/locale-ai-visualization.png (Locale.ai COVID-19 visualization) +[9]: https://github.com/localeai/covid19-live-visualization +[10]: https://github.com/CSSEGISandData/COVID-19 +[11]: https://tidelift.com/subscription/pkg/npm-vue +[12]: https://blog.tidelift.com/vuejs-evan-you-javascript-framework +[13]: https://opensource.com/sites/default/files/uploads/dxy-covid-19-crawler.png (BlankerL DXY-COVID-19-Crawler) +[14]: https://github.com/BlankerL/DXY-COVID-19-Crawler +[15]: https://dxy.cn +[16]: https://blog.tidelift.com/beautiful-soup-is-now-part-of-the-tidelift-subscription +[17]: https://opensource.com/sites/default/files/uploads/tokyo-covid19-task-force.png (City of Tokyo's COVID-19 Task Force site) +[18]: https://stopcovid19.metro.tokyo.lg.jp/en/ +[19]: https://github.com/tokyo-metropolitan-gov/covid19 +[20]: https://github.com/tokyo-metropolitan-gov/covid19/issues/1802 +[21]: https://tidelift.com/ +[22]: https://tidelift.com/subscription/pkg/npm-nuxt +[23]: https://blog.tidelift.com/prettier-is-now-part-of-the-tidelift-subscriptions +[24]: https://tidelift.com/subscription/pkg/npm-babel +[25]: https://blog.tidelift.com/ajv-is-now-part-of-the-tidelift-subscription +[26]: https://opensource.com/sites/default/files/uploads/tokyo-dependencies.png (Dependencies in Tokyo's COVID-19 Task Force site) +[27]: https://github.com/soroushchehresa/awesome-coronavirus diff --git a/published/20200318 Share data between C and Python with this messaging library.md b/published/20200318 Share data between C and Python with this messaging library.md new file mode 100644 index 0000000000..83c68e0bdb --- /dev/null +++ b/published/20200318 Share data between C and Python with this messaging library.md @@ -0,0 +1,627 @@ +[#]: collector: (lujun9972) +[#]: translator: (silentdawn-zz) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12499-1.html) +[#]: subject: (Share data between C and Python with this messaging library) +[#]: via: (https://opensource.com/article/20/3/zeromq-c-python) +[#]: author: (Cristiano L. Fontana https://opensource.com/users/cristianofontana) + +使用 ZeroMQ 消息库在 C 和 Python 间共享数据 +====== + +> ZeroMQ 是一个快速灵活的消息库,用于数据收集和不同编程语言间的数据共享。 + +![](https://img.linux.net.cn/data/attachment/album/202008/08/202106uale11l1qf11slzw.jpg) + +作为软件工程师,我有多次在要求完成指定任务时感到浑身一冷的经历。其中有一次,我必须在一些新的硬件基础设施和云基础设施之间写一个接口,这些硬件需要 C 语言,而云基础设施主要是用 Python。 + +实现的方式之一是 [用 C 写扩展模块][2],Python 支持 C 扩展的调用。快速浏览文档后发现,这需要编写大量的 C 代码。这样做的话,在有些情况下效果还不错,但不是我喜欢的方式。另一种方式就是将两个任务放在不同的进程中,并使用 [ZeroMQ 消息库][3] 在两者之间交换消息。 + +在发现 ZeroMQ 之前,遇到这种类型的情况时,我选择了编写扩展的方式。这种方式不算太差,但非常费时费力。如今,为了避免那些问题,我将一个系统细分为独立的进程,通过 [通信套接字][4] 发送消息来交换信息。这样,不同的编程语言可以共存,每个进程也变简单了,同时也容易调试。 + +ZeroMQ 提供了一个更简单的过程: + +1. 编写一小段 C 代码,从硬件读取数据,然后把发现的东西作为消息发送出去。 +2. 使用 Python 编写接口,实现新旧基础设施之间的对接。 + +[Pieter Hintjens][5] 是 ZeroMQ 项目发起者之一,他是个拥有 [有趣视角和作品][6] 的非凡人物。 + +### 准备 + +本教程中,需要: + +* 一个 C 编译器(例如 [GCC][7] 或 [Clang][8]) +* [libzmq 库][9] +* [Python 3][10] +* [ZeroMQ 的 Python 封装][11] + +Fedora 系统上的安装方法: + +``` +$ dnf install clang zeromq zeromq-devel python3 python3-zmq +``` + +Debian 和 Ubuntu 系统上的安装方法: + +``` +$ apt-get install clang libzmq5 libzmq3-dev python3 python3-zmq +``` + +如果有问题,参考对应项目的安装指南(上面附有链接)。 + +### 编写硬件接口库 + +因为这里针对的是个设想的场景,本教程虚构了包含两个函数的操作库: + +* `fancyhw_init()` 用来初始化(设想的)硬件 +* `fancyhw_read_val()` 用于返回从硬件读取的数据 + +将库的完整代码保存到文件 `libfancyhw.h` 中: + +``` +#ifndef LIBFANCYHW_H +#define LIBFANCYHW_H + +#include +#include + +// This is the fictitious hardware interfacing library + +void fancyhw_init(unsigned int init_param) +{ + srand(init_param); +} + +int16_t fancyhw_read_val(void) +{ + return (int16_t)rand(); +} + +#endif +``` + +这个库可以模拟你要在不同语言实现的组件间交换的数据,中间有个随机数发生器。 + +### 设计 C 接口 + +下面从包含管理数据传输的库开始,逐步实现 C 接口。 + +#### 需要的库 + +开始先加载必要的库(每个库的作用见代码注释): + +``` +// For printf() +#include +// For EXIT_* +#include +// For memcpy() +#include +// For sleep() +#include + +#include + +#include "libfancyhw.h" +``` + +#### 必要的参数 + +定义 `main` 函数和后续过程中必要的参数: + +``` +int main(void) +{ +    const unsigned int INIT_PARAM = 12345; +    const unsigned int REPETITIONS = 10; +    const unsigned int PACKET_SIZE = 16; +    const char *TOPIC = "fancyhw_data"; + +    ... +``` + +#### 初始化 + +所有的库都需要初始化。虚构的那个只需要一个参数: + +``` +fancyhw_init(INIT_PARAM); +``` + +ZeroMQ 库需要实打实的初始化。首先,定义对象 `context`,它是用来管理全部的套接字的: + +``` +void *context = zmq_ctx_new(); + +if (!context) +{ + printf("ERROR: ZeroMQ error occurred during zmq_ctx_new(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; +} +``` + +之后定义用来发送数据的套接字。ZeroMQ 支持若干种套接字,各有其用。使用 `publish` 套接字(也叫 `PUB` 套接字),可以复制消息并分发到多个接收端。这使得你可以让多个接收端接收同一个消息。没有接收者的消息将被丢弃(即不会入消息队列)。用法如下: + +``` +void *data_socket = zmq_socket(context, ZMQ_PUB); +``` + +套接字需要绑定到一个具体的地址,这样客户端就知道要连接哪里了。本例中,使用了 [TCP 传输层][15](当然也有 [其它选项][16],但 TCP 是不错的默认选择): + +``` +const int rb = zmq_bind(data_socket, "tcp://*:5555"); + +if (rb != 0) +{ + printf("ERROR: ZeroMQ error occurred during zmq_ctx_new(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; +} +``` + +下一步, 计算一些后续要用到的值。 注意下面代码中的 `TOPIC`,因为 `PUB` 套接字发送的消息需要绑定一个主题。主题用于供接收者过滤消息: + +``` +const size_t topic_size = strlen(TOPIC); +const size_t envelope_size = topic_size + 1 + PACKET_SIZE * sizeof(int16_t); + +printf("Topic: %s; topic size: %zu; Envelope size: %zu\n", TOPIC, topic_size, envelope_size); +``` + +#### 发送消息 + +启动一个发送消息的循环,循环 `REPETITIONS` 次: + +``` +for (unsigned int i = 0; i < REPETITIONS; i++) +{ + ... +``` + +发送消息前,先填充一个长度为 `PACKET_SIZE` 的缓冲区。本库提供的是 16 个位的有符号整数。因为 C 语言中 `int` 类型占用空间大小与平台相关,不是确定的值,所以要使用指定宽度的 `int` 变量: + +``` +int16_t buffer[PACKET_SIZE]; + +for (unsigned int j = 0; j < PACKET_SIZE; j++) +{ + buffer[j] = fancyhw_read_val(); +} + +printf("Read %u data values\n", PACKET_SIZE); +``` + +消息的准备和发送的第一步是创建 ZeroMQ 消息,为消息分配必要的内存空间。空白的消息是用于封装要发送的数据的: + +``` +zmq_msg_t envelope; + +const int rmi = zmq_msg_init_size(&envelope, envelope_size); +if (rmi != 0) +{ + printf("ERROR: ZeroMQ error occurred during zmq_msg_init_size(): %s\n", zmq_strerror(errno)); + + zmq_msg_close(&envelope); + + break; +} +``` + +现在内存空间已分配,数据保存在 ZeroMQ 消息 “信封”中。函数 `zmq_msg_data()` 返回一个指向封装数据缓存区顶端的指针。第一部分是主题,之后是一个空格,最后是二进制数。主题和二进制数据之间的分隔符采用空格字符。需要遍历缓存区的话,使用类型转换和 [指针算法][18]。(感谢 C 语言,让事情变得直截了当。)做法如下: + +``` +memcpy(zmq_msg_data(&envelope), TOPIC, topic_size); +memcpy((void*)((char*)zmq_msg_data(&envelope) + topic_size), " ", 1); +memcpy((void*)((char*)zmq_msg_data(&envelope) + 1 + topic_size), buffer, PACKET_SIZE * sizeof(int16_t)) +``` + +通过 `data_socket` 发送消息: + +``` +const size_t rs = zmq_msg_send(&envelope, data_socket, 0); +if (rs != envelope_size) +{ + printf("ERROR: ZeroMQ error occurred during zmq_msg_send(): %s\n", zmq_strerror(errno)); + + zmq_msg_close(&envelope); + + break; +} +``` + +使用数据之前要先解除封装: + +``` +zmq_msg_close(&envelope); + +printf("Message sent; i: %u, topic: %s\n", i, TOPIC); +``` + +#### 清理 + +C 语言不提供 [垃圾收集][20] 功能,用完之后记得要自己扫尾。发送消息之后结束程序之前,需要运行扫尾代码,释放分配的内存: + +``` +const int rc = zmq_close(data_socket); + +if (rc != 0) +{ + printf("ERROR: ZeroMQ error occurred during zmq_close(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; +} + +const int rd = zmq_ctx_destroy(context); + +if (rd != 0) +{ + printf("Error occurred during zmq_ctx_destroy(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; +} + +return EXIT_SUCCESS; +``` + +#### 完整 C 代码 + +保存下面完整的接口代码到本地名为 `hw_interface.c` 的文件: + +``` +// For printf() +#include +// For EXIT_* +#include +// For memcpy() +#include +// For sleep() +#include + +#include + +#include "libfancyhw.h" + +int main(void) +{ + const unsigned int INIT_PARAM = 12345; + const unsigned int REPETITIONS = 10; + const unsigned int PACKET_SIZE = 16; + const char *TOPIC = "fancyhw_data"; + + fancyhw_init(INIT_PARAM); + + void *context = zmq_ctx_new(); + + if (!context) + { + printf("ERROR: ZeroMQ error occurred during zmq_ctx_new(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; + } + + void *data_socket = zmq_socket(context, ZMQ_PUB); + + const int rb = zmq_bind(data_socket, "tcp://*:5555"); + + if (rb != 0) + { + printf("ERROR: ZeroMQ error occurred during zmq_ctx_new(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; + } + + const size_t topic_size = strlen(TOPIC); + const size_t envelope_size = topic_size + 1 + PACKET_SIZE * sizeof(int16_t); + + printf("Topic: %s; topic size: %zu; Envelope size: %zu\n", TOPIC, topic_size, envelope_size); + + for (unsigned int i = 0; i < REPETITIONS; i++) + { + int16_t buffer[PACKET_SIZE]; + + for (unsigned int j = 0; j < PACKET_SIZE; j++) + { + buffer[j] = fancyhw_read_val(); + } + + printf("Read %u data values\n", PACKET_SIZE); + + zmq_msg_t envelope; + + const int rmi = zmq_msg_init_size(&envelope, envelope_size); + if (rmi != 0) + { + printf("ERROR: ZeroMQ error occurred during zmq_msg_init_size(): %s\n", zmq_strerror(errno)); + + zmq_msg_close(&envelope); + + break; + } + + memcpy(zmq_msg_data(&envelope), TOPIC, topic_size); + + memcpy((void*)((char*)zmq_msg_data(&envelope) + topic_size), " ", 1); + + memcpy((void*)((char*)zmq_msg_data(&envelope) + 1 + topic_size), buffer, PACKET_SIZE * sizeof(int16_t)); + + const size_t rs = zmq_msg_send(&envelope, data_socket, 0); + if (rs != envelope_size) + { + printf("ERROR: ZeroMQ error occurred during zmq_msg_send(): %s\n", zmq_strerror(errno)); + + zmq_msg_close(&envelope); + + break; + } + + zmq_msg_close(&envelope); + + printf("Message sent; i: %u, topic: %s\n", i, TOPIC); + + sleep(1); + } + + const int rc = zmq_close(data_socket); + + if (rc != 0) + { + printf("ERROR: ZeroMQ error occurred during zmq_close(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; + } + + const int rd = zmq_ctx_destroy(context); + + if (rd != 0) + { + printf("Error occurred during zmq_ctx_destroy(): %s\n", zmq_strerror(errno)); + + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +} +``` + +用如下命令编译: + +``` +$ clang -std=c99 -I. hw_interface.c -lzmq -o hw_interface +``` + +如果没有编译错误,你就可以运行这个接口了。贴心的是,ZeroMQ `PUB` 套接字可以在没有任何应用发送或接受数据的状态下运行,这简化了使用复杂度,因为这样不限制进程启动的次序。 + +运行该接口: + +``` +$ ./hw_interface +Topic: fancyhw_data; topic size: 12; Envelope size: 45 +Read 16 data values +Message sent; i: 0, topic: fancyhw_data +Read 16 data values +Message sent; i: 1, topic: fancyhw_data +Read 16 data values +... +... +``` + +输出显示数据已经通过 ZeroMQ 完成发送,现在要做的是让一个程序去读数据。 + +### 编写 Python 数据处理器 + +现在已经准备好从 C 程序向 Python 应用传送数据了。 + +#### 库 + +需要两个库帮助实现数据传输。首先是 ZeroMQ 的 Python 封装: + +``` +$ python3 -m pip install zmq +``` + +另一个就是 [struct 库][21],用于解码二进制数据。这个库是 Python 标准库的一部分,所以不需要使用 `pip` 命令安装。 + +Python 程序的第一部分是导入这些库: + +``` +import zmq +import struct +``` + +#### 重要参数 + +使用 ZeroMQ 时,只能向常量 `TOPIC` 定义相同的接收端发送消息: + +``` +topic = "fancyhw_data".encode('ascii') + +print("Reading messages with topic: {}".format(topic)) +``` + +#### 初始化 + +下一步,初始化上下文和套接字。使用 `subscribe` 套接字(也称为 `SUB` 套接字),它是 `PUB` 套接字的天生伴侣。这个套接字发送时也需要匹配主题。 + +``` +with zmq.Context() as context: +    socket = context.socket(zmq.SUB) + +    socket.connect("tcp://127.0.0.1:5555") +    socket.setsockopt(zmq.SUBSCRIBE, topic) + +    i = 0 + +    ... +``` + +#### 接收消息 + +启动一个无限循环,等待接收发送到 `SUB` 套接字的新消息。这个循环会在你按下 `Ctrl+C` 组合键或者内部发生错误时终止: + +``` +    try: +        while True: + +            ... # we will fill this in next + +    except KeyboardInterrupt: +        socket.close() +    except Exception as error: +        print("ERROR: {}".format(error)) +        socket.close() +``` + +这个循环等待 `recv()` 方法获取的新消息,然后将接收到的内容从第一个空格字符处分割开,从而得到主题: + + +``` +binary_topic, data_buffer = socket.recv().split(b' ', 1) +``` + +#### 解码消息 + +Python 此时尚不知道主题是个字符串,使用标准 ASCII 编解码器进行解码: + +``` +topic = binary_topic.decode(encoding = 'ascii') + +print("Message {:d}:".format(i)) +print("\ttopic: '{}'".format(topic)) +``` + +下一步就是使用 `struct` 库读取二进制数据,它可以将二进制数据段转换为明确的数值。首先,计算数据包中数值的组数。本例中使用的 16 个位的有符号整数对应的是 `struct` [格式字符][22] 中的 `h`: + +``` +packet_size = len(data_buffer) // struct.calcsize("h") + +print("\tpacket size: {:d}".format(packet_size)) +``` + +知道数据包中有多少组数据后,就可以通过构建一个包含数据组数和数据类型的字符串,来定义格式了(比如“`16h`”): + +``` +struct_format = "{:d}h".format(packet_size) +``` + +将二进制数据串转换为可直接打印的一系列数字: + +``` +data = struct.unpack(struct_format, data_buffer) + +print("\tdata: {}".format(data)) +``` + +#### 完整 Python 代码 + +下面是 Python 实现的完整的接收端: + +``` +#! /usr/bin/env python3 + +import zmq +import struct + +topic = "fancyhw_data".encode('ascii') + +print("Reading messages with topic: {}".format(topic)) + +with zmq.Context() as context: + socket = context.socket(zmq.SUB) + + socket.connect("tcp://127.0.0.1:5555") + socket.setsockopt(zmq.SUBSCRIBE, topic) + + i = 0 + + try: + while True: + binary_topic, data_buffer = socket.recv().split(b' ', 1) + + topic = binary_topic.decode(encoding = 'ascii') + + print("Message {:d}:".format(i)) + print("\ttopic: '{}'".format(topic)) + + packet_size = len(data_buffer) // struct.calcsize("h") + + print("\tpacket size: {:d}".format(packet_size)) + + struct_format = "{:d}h".format(packet_size) + + data = struct.unpack(struct_format, data_buffer) + + print("\tdata: {}".format(data)) + + i += 1 + + except KeyboardInterrupt: + socket.close() + except Exception as error: + print("ERROR: {}".format(error)) + socket.close() +``` + +将上面的内容保存到名为 `online_analysis.py` 的文件。Python 代码不需要编译,你可以直接运行它。 + +运行输出如下: + +``` +$ ./online_analysis.py +Reading messages with topic: b'fancyhw_data' +Message 0: +        topic: 'fancyhw_data' +        packet size: 16 +        data: (20946, -23616, 9865, 31416, -15911, -10845, -5332, 25662, 10955, -32501, -18717, -24490, -16511, -28861, 24205, 26568) +Message 1: +        topic: 'fancyhw_data' +        packet size: 16 +        data: (12505, 31355, 14083, -19654, -9141, 14532, -25591, 31203, 10428, -25564, -732, -7979, 9529, -27982, 29610, 30475) +... +... +``` + +### 小结 + +本教程介绍了一种新方式,实现从基于 C 的硬件接口收集数据,并分发到基于 Python 的基础设施的功能。借此可以获取数据供后续分析,或者转送到任意数量的接收端去。它采用了一个消息库实现数据在发送者和处理者之间的传送,来取代同样功能规模庞大的软件。 + +本教程还引出了我称之为“软件粒度”的概念,换言之,就是将软件细分为更小的部分。这种做法的优点之一就是,使得同时采用不同的编程语言实现最简接口作为不同部分之间沟通的组件成为可能。 + +实践中,这种设计使得软件工程师能以更独立、合作更高效的方式做事。不同的团队可以专注于数据分析的不同方面,可以选择自己中意的实现工具。这种做法的另一个优点是实现了零代价的并行,因为所有的进程都可以并行运行。[ZeroMQ 消息库][3] 是个令人赞叹的软件,使用它可以让工作大大简化。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/zeromq-c-python + +作者:[Cristiano L. Fontana][a] +选题:[lujun9972][b] +译者:[silentdawn-zz](https://github.com/译者ID) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cristianofontana +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_chat_communication_message.png?itok=LKjiLnQu (Chat via email) +[2]: https://docs.python.org/3/extending/extending.html +[3]: https://zeromq.org/ +[4]: https://en.wikipedia.org/wiki/Network_socket +[5]: https://en.wikipedia.org/wiki/Pieter_Hintjens +[6]: http://hintjens.com/ +[7]: https://gcc.gnu.org/ +[8]: https://clang.llvm.org/ +[9]: https://github.com/zeromq/libzmq#installation-of-binary-packages- +[10]: https://www.python.org/downloads/ +[11]: https://zeromq.org/languages/python/ +[12]: http://www.opengroup.org/onlinepubs/009695399/functions/srand.html +[13]: http://www.opengroup.org/onlinepubs/009695399/functions/rand.html +[14]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html +[15]: https://en.wikipedia.org/wiki/Transmission_Control_Protocol +[16]: http://zguide.zeromq.org/page:all#Plugging-Sockets-into-the-Topology +[17]: http://www.opengroup.org/onlinepubs/009695399/functions/strlen.html +[18]: https://en.wikipedia.org/wiki/Pointer_%28computer_programming%29%23C_and_C++ +[19]: http://www.opengroup.org/onlinepubs/009695399/functions/memcpy.html +[20]: https://en.wikipedia.org/wiki/Garbage_collection_(computer_science) +[21]: https://docs.python.org/3/library/struct.html +[22]: https://docs.python.org/3/library/struct.html#format-characters diff --git a/published/20200331 How failure-driven development makes you successful.md b/published/20200331 How failure-driven development makes you successful.md new file mode 100644 index 0000000000..6b6bc55b96 --- /dev/null +++ b/published/20200331 How failure-driven development makes you successful.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: (JonnieWayy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12479-1.html) +[#]: subject: (How failure-driven development makes you successful) +[#]: via: (https://opensource.com/article/20/3/failure-driven-development) +[#]: author: (Jessica Cherry https://opensource.com/users/jrepka) + +屡屡失败犯错的我为什么没有被开除 +====== + +> 我是词典里 “失败” 一词旁边的插图,这就是为什么我擅长我的工作的原因。 + +![](https://img.linux.net.cn/data/attachment/album/202008/02/212013q5jjc78ihwd72cij.jpg) + +我的职称是高级软件工程师,但我最亲近的同事并不这么称呼我。由于我摧毁一切,他们管我叫“樱桃炸弹”(正巧我姓“樱桃”)。我定期会遇到的失败已经可以影响到我们的季度性收益和停机时间。简单的来说,我就是你所听说过的生产灾难:“别动,啥都别做,无论何时何地。” + +我的职业生涯始于支持服务台,在那里我写了一些循环,破坏了高端客户的服务器。我曾在没有警告的情况下将生产应用程序关闭了长达八个小时,并且在试图使得情况好转的过程中摧毁了无数个集群,有几次只是因为我打错了字。 + +我是我们在 [Kubernetes][2] 中设有灾难恢复(DR)集群的原因。我是个混乱的工程师,我们有一个应用程序,它的故障恢复计划还从未测试过,而我在没有警告的情况下,就教人们如何快速行动和排除故障。我作为可能失败的最好例子而存在,这实际上是有史以来最酷的事情。 + +### 我和消失的 K8s 集群 + +我的正式职责之一涉及到我们的应用架构。对于任何形式的架构改动,我都要进行代码的编写与测试,看看有什么可能性。近来,据说这成了我老板史诗级的痛苦,这只是轻描淡写。 + +我们在 Kubernetes 上运行我们的大多数基础架构,Kubernetes 以其弹性著称。尽管有这样的声誉,我还是使得两个集群,好吧,消失了。你可能会好奇我是怎么做到的,很容易,`terraform destroy`。我们通过 [Terraform][3] 以代码的方式管理我们的基础架构,并且不需要任何软件知识就知道 `destroy` 可做坏事。在你惊慌失措之前,好吧,是开发集群,所以我还活着。 + +鉴于此,你们肯定会问我为什么还没丢掉饭碗,以及为什么我要写下这些事情。这很好回答:我仍然有工作,是因为我更新的基础架构代码比起起初的代码工作得更好更快了。我写下这些是因为每个人都会经常性地遭遇失败,这是非常非常正常的。如果你没有时不时遭遇失败,我认为你并没有足够努力地学习。 + +### 破坏东西并培训人们 + +你可能还会认为永远不会有人让我去培训任何人。那是最糟糕的主意,因为(就像我的团队开玩笑说的)你永远都不应该做我所做的事情。但是我的老板却让我定期去训练新人。我甚至为整个团队提供使用我们的基础设施或代码的培训,教人们如何建立自己的基础设施。 + +原因是这样的:失败是你迈向成功的第一步。失败的教训绝不只是“备份是个绝佳的主意”。不,从失败中,你学会了更快地恢复、更快地排除故障并且在你工作中取得惊人的进步。当你在工作中变得惊人的时候,你就可以培训其他人,教给他们什么事情不要做,并且帮助他们去理解一切是如何工作的。由于你的经验,他们会比你开始时更进一步 —— 而且他们也很可能以新的、惊人的、史诗般的方式失败,每个人都可以从中学到东西。 + +### 你的成功取决于你的失败 + +没有人生来就具有软件工程和云基础架构方面的天赋,就像没有人天生就会走路。我们都是从滚动和翻爬开始的。从那时起,我们学会爬行,然后能够站立一会儿。当我们开始走路后,我们会跌倒并且擦伤膝盖,撞到手肘,还有,比如像我哥哥,走着走着撞上桌子的尖角,然后在眉毛中间缝了针。 + +凡事都需要时间去学习。一路上阅读手边能获得的一切来帮助你,但这永远只是个开始。完美是无法实现的幻想,你必须通过失败来取得成功。 + +每走一步,我的失败都教会我如何把事情做得更好。 + +最终,你的成功和你累积的失败一样多,这标志着你成功的程度。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/failure-driven-development + +作者:[Jessica Cherry][a] +选题:[lujun9972][b] +译者:[JonnieWayy](https://github.com/JonnieWayy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jrepka +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_failure_celebrate.png?itok=LbvDAEZF (failure sign at a party, celebrating failure) +[2]: https://www.redhat.com/en/topics/containers/what-is-kubernetes +[3]: https://github.com/hashicorp/terraform diff --git a/published/202004/20190107 Different Ways To Update Linux Kernel For Ubuntu.md b/published/202004/20190107 Different Ways To Update Linux Kernel For Ubuntu.md new file mode 100644 index 0000000000..50e1bb7e16 --- /dev/null +++ b/published/202004/20190107 Different Ways To Update Linux Kernel For Ubuntu.md @@ -0,0 +1,220 @@ +[#]: collector: "lujun9972" +[#]: translator: "mr-ping" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12125-1.html" +[#]: subject: "Different Ways To Update Linux Kernel For Ubuntu" +[#]: via: "https://www.ostechnix.com/different-ways-to-update-linux-kernel-for-ubuntu/" +[#]: author: "SK https://www.ostechnix.com/author/sk/" + +升级 Ubuntu Linux 内核的几种不同方法 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/01/ubuntu-linux-kernel-720x340.png) + +这个指南里介绍了 7 种为 Ubuntu 升级 Linux 内核的不同方法。这 7 种方法里,有 5 种需要重启系统来使新内核生效,其他两种则不用。升级之前,**强烈建议你将重要数据进行备份!** 这里提到的所有方法只在 Ubuntu 中测试过。我们并不确定这些方法是不是也能适用于其他 Ubuntu 的特色发行版(如: Xubuntu)和衍生发行版(如:Linux Mint)。 + +### 第一部分:需要重启的内核升级 + +以下方法需要你重启系统以便新的内核生效。以下所有方法都建议在个人系统或测试系统中进行。重要的事儿再说一遍,请备份好你 Ubuntu 中的重要数据、配置文件和其他重要的东西。 + +#### 方法 1 - 使用 dpkg 升级 Linux 内核(手动方式) + +这个方法可以帮助你从 [kernel.ubuntu.com][1] 网站手动下载可用的最新 Linux 内核。如果你打算安装最新版(而不是稳定版或者正式发布版),那这种方法对你会很有用。从以上链接下载 Linux 内核版本。编写这个指南的时候,最新的可用版本是 **5.0-rc1**,最新的稳定版是 **v4.20**。 + +![][3] + +点击你所选择的 Linux 内核版本链接,找到你对应的架构(“Build for XXX”)的那部分。然后下载符合以下格式的两个文件(其中 X.Y.Z 是最高版本号): + + 1. linux-image-*X.Y.Z*-generic-*.deb + 2. linux-modules-X.Y.Z*-generic-*.deb + +在终端中改变到文件所在的目录,然后执行此命令手动安装内核: + +``` +$ sudo dpkg --install *.deb +``` + +重启系统,使用新内核: + +``` +$ sudo reboot +``` + +检查是否如你所愿: + +``` +$ uname -r +``` + +对于分步的说明,请查看下列链接中对应的部分。 + ++ [在基于 RPM 和 DEB 的系统中安装 Linux 内核 4.15](https://www.ostechnix.com/install-linux-kernel-4-15-rpm-deb-based-systems/) + +以上的指南是针对的是 4.15 版本,不过安装最新版本的所有的步骤都是一样的。 + +**优势:** 不必联网(你可以从任何系统中下载 Linux 内核来使用) + +**缺点:** 手动更新,需要重启系统。 + +#### 方法 2 - 用 apt-get 来升级 Linux 内核(推荐方法) + +这是在类 Ubuntu 系统中升级 Linux 内核的推荐方法。不同于上一个方法,这种方法会从 Ubuntu 官方仓库下载、安装内核版本,而不是从 **kernel.ubuntu.com**网站。 + +要升级包括内核的整个系统,只需要执行: + +``` +$ sudo apt-get update +$ sudo apt-get upgrade +``` + +如果只希望升级内核,运行: + +``` +$ sudo apt-get upgrade linux-image-generic +``` + +**优势:** 简单。推荐方法。 + +**缺点:** 需要联网,需要重启。 + +从官方库中升级内核是最接近开箱即用的方法,并且不会出什么问题。如果是生产环境的系统,这是最为推荐的升级 Linux 内核的方法。 + +方法 1 和方法 2 都需要用户去介入到升级 Linux 内核的过程中。而下边的方法(3、 4、 5)则几乎是全自动的。 + +#### 方法 3 - 使用 Ukuu 升级 Linux 内核 + +**Ukuu**是一个 Gtk GUI 和命令行工具,它可以从 kernel.ubuntu.com 下载最新的 Linux 主线内核,并自动安装到你的 Ubuntu 桌面版和服务器版中。Ukku 不仅简化了手动下载和安装新内核的过程,同时也会帮助你安全地移除旧的和不再需要的内核。更多细节可以参照以下指南。 + ++ [Ukuu:在 Ubuntu 系统中安装和升级 Linux 内核的简单方法](https://www.ostechnix.com/ukuu-an-easy-way-to-install-and-upgrade-linux-kernel-in-ubuntu-based-systems/) + +**优势:** 易于安装使用。自动安装主线内核。 + +**缺点:** 需要联网,需要重启。 + +#### 方法 4 - 使用 UKTools 升级 Linux 内核 + +跟 Ukuu 差不多,**UKTools** 也会从 kernel.ubuntu.com 网站获取最新的稳定内核并且自动安装到 Ubuntu 以及类似于 Linux Mint 的延伸发行版中。关于UKTools的更多详情,请参见下面的链接。 + ++ [UKTools:升级Ubuntu及其衍生产品中的最新Linux内核](https://www.ostechnix.com/uktools-upgrade-latest-linux-kernel-in-ubuntu-and-derivatives/) + +**优势:** 简单,自动。 + +**缺点:** 需要联网,需要重启。 + +#### 方法 5 - 使用 Linux 内核实用程序更新 Linux 内核 + +**Linux 内核实用程序**是目前另一个用于升级类 Ubuntu 系统 Linux 内核的程序。实质上,它是一个由一系列 Bash 脚本构成的合集,用于编译并且可以选择性地为 Debian(LCTT 译注:Ubuntu 的上游发行版)及其衍生发行版升级内核。它包含三个实用程序,一个用于手动编译、安装来自于 [http://www.kernel.org][4] 网站的源码内核,另一个用于安装来自 网站的预编译的内核,第三个脚本用于移除旧内核。更多细节请浏览以下链接。 + ++ [Linux 内核实用程序:编译和更新最新的 Linux 内核的脚本,适用于 Debian 及其衍生产品](https://www.ostechnix.com/linux-kernel-utilities-scripts-compile-update-latest-linux-kernel-debian-derivatives/) + +**优势:** 简单,自动。 + +**缺点:** 需要联网,需要重启。 + +### 第二部分:无需重启的内核升级 + +我之前说过,上边所有的方法都需要你重启服务器(LCTT 译注:也可以是桌面版)来启用新内核。如果是个人系统或者测试系统,可以这么办。但对于无法停机的生产环境系统该怎么办呢?一点问题没有,这时候实时补丁livepatching就派上用场了。 + +**实时补丁**(或者叫热补丁)允许你在不重启的情况下安装 Linux 更新或补丁,使你的服务器处于最新的安全级别。这对 web 主机、游戏服务器这类需要不间断在线的服务器来说是很有价值的。事实上,任何情况下,服务器都应该保持在不间断运行的状态下。由于 Linux 供应商只会在出于修复安全漏洞的目的下维护补丁,所以如果安全性是你最关注的问题时,这种方式再适合不过了。 + +以下两种方法不需要重启,对于生产环境和执行关键任务的 Ubuntu 服务器的 Linux 内核更新非常有用。 + +#### 方法 6 – 使用 Canonical 实时补丁服务来更新 Linux 内核 + +![][5] + +[Canonical 实时补丁服务][6]可以在不需要重启 Ubuntu 系统的情况下自动应用内核更新、补丁和安全补丁。它可以减少Ubuntu系统的停机时间,并保证系统的安全。Canonical 实时补丁服务可以在安装过程当中或安装之后进行设置。如果你使用的是 Ubuntu 桌面版,软件更新器会自动检查内核补丁的更新,并通知你。在基于控制台的系统中,则需要你定期运行 `apt-get update` 命令来进行升级。由于需要你手动运行 `apt-get upgrade` 命令它才会安装内核的安全补丁,所以算是半自动的。 + +实时补丁对三个及以下系统免费,如果多于三个,你需要升级成名为 **Ubuntu Advantage** 的企业支持方案套件。这个套件包括 **Kernel 实时补丁**及以下服务: + + * 扩展安全维护 – Ubuntu 生命周期后的重要安全更新 + * Landscape – 针对大规模使用 Ubuntu 的系统管理工具 + * 知识库 – 由 Ubuntu 专家撰写的私人文章和教程 + * 电话和网站支持 + +**价格** + +Ubuntu Advantage 包含三种付费计划,即基本计划、标准计划和高级计划。最基础的计划(基本计划)从 **单物理节点 225 美元/年**和**单VPS 75美元/年**开始计价。对于 Ubuntu 服务器版和桌面版看上去没有按月订阅。你可以在[此处][7]浏览所有计划的细节信息。 + +**优势:** 简单。半自动化。无需重启。支持三个免费系统。 + +**缺点:** 4 个以上主机的话非常昂贵。没有补丁回滚。 + +##### 开启 Canonical 实时补丁 + +如果你想在安装后设置实时补丁服务,依照以下方法逐步执行: + +从 [https://auth.livepatch.canonical.com/][8] 获取一个密钥。 + +``` +$ sudo snap install canonical-livepatch +$ sudo canonical-livepatch enable your-key +``` + +#### 方法 7 - 使用 KernelCare 升级 Linux 内核 + +![][9] + +[KernelCare][10] 是最新的实时补丁方案。它是 [CloudLinux][11] 推出的产品。KernelCare 可以运行在 Ubuntu 和其他的 Linux 发行版中。它每四个小时检查一遍补丁的发布,并在无需确认的情况下安装它们。如果更新后存在问题,可以将补丁进行回滚。 + +**价格** + +费用,每台服务器:**4 美元/月**,**45 美元/年**。 + +跟 Ubuntu 实时补丁相比,KernelCare 看起来非常便宜、实惠。好的方面在于**也可以按月订阅**。另一个前者不具备的功能是支持其他 Linux 发行版,如 Red Hat、CentOS、Debian、Oracle Linux、Amazon Linux 以及 OpenVZ、Proxmox 等虚拟化平台。 + +你可以在[此处][12]了解 KernelCare 的所有特性和简介,以及所有的付费计划的细节。 + +**优势:** 简单。全自动化。覆盖范围更广的操作系统。补丁回滚。无需重启。对非营利组织提供免费许可。价格低廉。 + +**缺点:** 不是免费的(除了30天的试用期)。 + +##### 开启 KernelCare 服务 + +在 [https://cloudlinux.com/kernelcare-free-trial5][14] 获取一个 30 天免费试用密钥。 + +执行以下命令开启 KernelCare 并注册秘钥。 + +``` +$ sudo wget -qq -O - https://repo.cloudlinux.com/kernelcare/kernelcare_install.sh | bash +$ sudo /usr/bin/kcarectl --register KEY +``` + +如果你正在寻找一种经济实惠且可靠的商业服务来保持 Linux 服务器上的 Linux 内核更新,那么 KernelCare 是个不错的选择。 + +*由来自 Cloud Linux 的技术撰稿人和内容作者 Paul A. Jacobs 提供。* + +到此,希望这边文章能对你有所帮助。如果你觉得还有其他的工具和方法需要列在这里,可以在留言区给我们留言。我会根据反馈检查和更新这篇指南的。 + +接下来会有更多好东西给大家呈现,敬请期待。 + +Cheers! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/different-ways-to-update-linux-kernel-for-ubuntu/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[mr-ping](https://github.com/mr-ping) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: http://kernel.ubuntu.com/~kernel-ppa/mainline/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: http://www.ostechnix.com/wp-content/uploads/2019/01/Ubuntu-mainline-kernel.png +[4]: http://www.kernel.org +[5]: http://www.ostechnix.com/wp-content/uploads/2019/01/Livepatch.png +[6]: https://www.ubuntu.com/livepatch +[7]: https://www.ubuntu.com/support/plans-and-pricing +[8]: https://auth.livepatch.canonical.com/ +[9]: http://www.ostechnix.com/wp-content/uploads/2019/01/KernelCare.png +[10]: https://www.kernelcare.com/ +[11]: https://www.cloudlinux.com/ +[12]: https://www.kernelcare.com/update-kernel-linux/ +[13]: https://www.kernelcare.com/pricing/ +[14]: https://cloudlinux.com/kernelcare-free-trial5 diff --git a/published/202004/20190116 Best Audio Editors For Linux.md b/published/202004/20190116 Best Audio Editors For Linux.md new file mode 100644 index 0000000000..a6977b7d73 --- /dev/null +++ b/published/202004/20190116 Best Audio Editors For Linux.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: (MFGJT) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12095-1.html) +[#]: subject: (Best Audio Editors For Linux) +[#]: via: (https://itsfoss.com/best-audio-editors-linux) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Linux 上的最佳音频编辑工具推荐 +====== + +在 Linux 上,有很多种音频编辑器可供你选用。不论你是一个专业的音乐制作人,还是只想学学怎么做出超棒的音乐的爱好者,这些强大的音频编辑器都是很有用的工具。 + +对于专业级的使用,我总是建议使用 [DAW][1](数码音频工作站)。但并不是每个人都需要全部的功能,所以你也应该了解一些最简单的音频编辑器。 + +在本文中,我们将讨论几款 DAW 和基础的音频编辑器,而且它们都是在 Linux 和(可能)其它操作系统上可以使用的**自由开源**的解决方案。 + +### Linux 上的最佳音频编辑器 + +![Best audio editors and DAW for Linux][2] + +我们不会关注 DAW 提供的所有功能,而只是关注基本的音频编辑功能。不过,你仍然可以把以下内容看作是 Linux 的最佳 DAW 名单。 + +**安装说明:**你可以在 AppCenter 或软件中心中找到所有提到的音频编辑器或 DAW。如果你在这两个地方没有找到它们,请前往它们的官方网站获取更多信息。 + +#### 1、Audacity + +![Audacity audio editor][3] + +[Audacity](https://www.audacityteam.org/) 是 Linux 中最基本音频编辑器之一,但是它也很强大。它是一个自由开源的跨平台工具。肯定已经有很多人了解这个软件了。 + +现在的它相比它最初流行的时候有了很大的改进。我记得我以前试着通过从音频中去除人声来制作卡拉 OK 伴奏。现在有些时候,你仍然可以这么做。 + +**特性:** + +它还支持包含 VST 效果的插件。当然,你不应该期望它支持 VST 乐器。 + + * 通过麦克风或混音器进行现场录制 + * 支持同时从多种音频格式的多个文件中批量导出/导入内容 + * 支持 LADSPA、LV2、Nyquist、VST 和 Audio Unit 的效果插件 + * 使用简单,带有剪切、粘贴、删除和拷贝的功能 + * 可观测声音频率的频谱模式 + +#### 2、LMMS + +![LMMS audio editor][4] + +[LMMS](https://lmms.io/) 是一个自由开源的(跨平台)数码音频工作站。它包括所有基本的音频编辑功能以及许多高级功能。 + +你可以混音、组合音频,或使用 VST 设备创造音频。LMMS 支持这些功能。此外,它还自带一些样本音频、预设、VST 设备和特效来帮助你起步。此外,你还可以得到一个频谱分析仪,以便进行高级的音频编辑工作。 + +**特性:** + + * 基于 MIDI 的音符回放 + * 支持 VST 设备 + * 原生支持多采样 + * 内置压缩器、限制器、延迟功能、混响功能、失真功能和低音增强器 + +#### 3、Ardour + +![Ardour audio editor][5] + +[Ardour](https://ardour.org/) 是另一个自由开源的数码音频工作站。只要你有音频接口,Ardour 就支持它的使用。当然,你也可以无限地添加多声道音轨。这些多声道音轨也可以被指派到不同的混音带,以方便编辑和录音。 + +你也可以导入一个视频,编辑其中的音频,然后导出新的视频。它提供了许多内置插件,并且支持 VST 插件。 + +**特性:** + + * 非线性编辑 + * 垂直窗口堆叠,便于导航 + * 静默消除功能strip silence推拉修剪功能push-pull trimming,和用以短暂片段或基于基于音符开始的编辑的 Rhythm Ferret。 + +#### 4、Cecilia + +![Cecilia audio editor][6] + +[Cecilia](http://ajaxsoundstudio.com/software/cecilia/) 不是一个普通的音频编辑器。它的使用者一般是音效设计师或者正在努力成为音效设计师的人。 Cecilia 实际上是一个音频信号处理环境。它可以让你的作品余音绕梁。 + +你还可以得到内置的音效与合成模组和插件。Cecilia 为一个明确的目的而生:如果你正在找音效设计工具,这是你的不二之选! + +**特性:** + + * 利用模块来完成更多工作(UltimateGrainer —— 最先进的颗粒化处理工具,RandomAccumulator —— 记录变量速度的累加器,UpDistoRes——通过上采样和谐振低通滤波器创造失真效果的工具) + * 自动保存调制设定 + +#### 5、Mixxx + +![Mixxx audio DJ][7] + +如果你想要在混合和录制一些东西的同时能够有一个虚拟的 DJ 工具,[Mixxx](https://www.mixxx.org/) 将是完美的工具。你可以用到 BPM、音调,并使用主同步功能来匹配歌曲的节奏和节拍。另外,不要忘记它也是一个 Linux 的自由开源的软件。 + +它还支持自定义 DJ 设备。所以,如果你有 DJ 设备或者 MIDI,你可以用这个工具录制你的现场混音。 + +**特性:** + + * 播送和录制你的歌曲的 DJ 混音 + * 可以连接到你的设备并且现场演奏 + * 音调检测和 BPM 检测 + +#### 6、Rosegarden + +![Rosegarden audio editor][9] + +[Rosegarden](https://www.rosegardenmusic.com/) 是另一个令人赞叹的 Linux 的自由开源的音频编辑器。它既不是一个功能齐全的 DAW,也不是一个基本的音频编辑工具。它是两者的混合体,并带有一些缩减的功能。 + +我不会向专业人士推荐这款软件,但如果你经营家庭音乐工作室或只是想体验一下,这将是 Linux 上可以安装的最好的音频编辑器之一。 + +**特性:** + + * 乐谱编辑 + * 录音、混音以及采样 + +### 小结 + +这些是你可以找到的 Linux 上的最棒的一些音频编辑器了。不论你是需要 DAW,一个剪切/粘贴的编辑工具,或者仅仅想要一个拥有基础的混音和录音功能的音频编辑工具,上述软件都能够满足你的需求。 + +如果在这篇文章中我们遗漏了你最喜欢的一些音频工具,可以在原文下方评论中回复告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/best-audio-editors-linux + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[MFGJT](https://github.com/MFGJT) +校对:[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://en.wikipedia.org/wiki/Digital_audio_workstation +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/linux-audio-editors-800x450.jpeg?resize=800%2C450&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/audacity-audio-editor.jpg?fit=800%2C591&ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/lmms-daw.jpg?fit=800%2C472&ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/ardour-audio-editor.jpg?fit=800%2C639&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/cecilia.jpg?fit=800%2C510&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/mixxx.jpg?fit=800%2C486&ssl=1 +[8]: https://itsfoss.com/dj-mixxx-2/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/rosegarden.jpg?fit=800%2C391&ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/linux-audio-editors.jpeg?fit=800%2C450&ssl=1 diff --git a/published/202004/20190205 Installing Kali Linux on VirtualBox- Quickest - Safest Way.md b/published/202004/20190205 Installing Kali Linux on VirtualBox- Quickest - Safest Way.md new file mode 100644 index 0000000000..31ce0c27f0 --- /dev/null +++ b/published/202004/20190205 Installing Kali Linux on VirtualBox- Quickest - Safest Way.md @@ -0,0 +1,156 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12113-1.html) +[#]: subject: (Installing Kali Linux on VirtualBox: Quickest & Safest Way) +[#]: via: (https://itsfoss.com/install-kali-linux-virtualbox/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +在 VirtualBox 上安装 Kali Linux:最快速和最安全的方法 +====== + +> 这篇教程向你展示如何在 Windows 和 Linux 中以最快的方式在 VirtualBox 上安装 Kali Linux。 + +[Kali Linux][1] 是 [最适合脆弱性测试和安全爱好者的 Linux 发行版][2] 之一。 + +因为它涉及一个像黑客之类的敏感话题,就像一把双刃剑。我们过去在详细的 Kali Linux 评论中讨论过,所以我不会再次赘述。 + +虽然你可以通过替换现有的操作系统的形式安装 Kali Linux,但是通过虚拟机来使用它可能会是更好、更安全的选择。 + +使用 VirtualBox,你可以在 Windows/Linux 系统中将 Kail Linux 作为常规应用程序使用。这和在系统中运行 VLC 或游戏几乎是一样的。 + +在虚拟机中使用 Kali Linux 是安全的。不管你在 Kali Linux 做什么都不会影响你的 ‘宿主系统’(即你原来的 Windows 或 Linux 操作系统)。你的实际操作系统将不会受到影响,并且在你的宿主系统中数据也是安全的。 + +![][3] + +### 如何在 VirtualBox 中安装 Kali Linux + +在这里我会使用 [VirtualBox][4]。它是一个非常好的开源虚拟化解决方案,几乎适合于任何人,无论是专业使用或个人使用。它是免费提供的。 + +在这篇文章中,我们将特别讨论 Kali Linux,但你也可以安装几乎任何其他的操作系统,只要有 ISO 文件或预建的虚拟机保存文件就可以安装。 + +**注意:**同样的步骤适用于运行 VirtualBox 的 Windows 或 Linux。 + +如上所述 ,你可以安装 Windows 或 Linux 作为你的宿主系统。但是,在我已安装 Windows 10 的情况下(别仇恨我!),我会尝试着在其上的 VirtualBox 中一步步地安装 Kali Linux 。 + +并且,最棒的是,即使你碰巧使用一个 Linux 发行版作为你的主要操作系统,也将使用同样的步骤! + +想知道如何做?让我们来看看… + +- [video](https://youtu.be/TGOiAsSdADs) + +### 在 VirtualBox 上安装 Kali Linux 的分步指南 + +我们将使用一个专门为 VirtualBox 定制的 Kali Linux 镜像。你也可以下载 Kali Linux 的 ISO 文件,并创建一个新的虚拟机,但是当你有一个简单的选择时,为什么还这样做呢? + +#### 1、下载并安装 VirtualBox + +第一件要做的事是从甲骨文的官方网站下载和安装 VirtualBox。 + +- [下载 VirtualBox][6] + +在你下载了安装器之后,只需要双击它来安装 VirtualBox。在 [Ubuntu][7]/Fedora Linux 安装 VirtualBox 也是一样的方式。 + +#### 2、下载即用型的 Kali Linux 虚拟镜像 + +在安装成功后,前往 [Offensive Security 的下载页面][8] 来下载适用于 VirtualBox 的虚拟机镜像。如果你改变主意使用 [VMware][9],那里也有适用的。 + +![][10] + +如你所见,文件大小大约 3 GB,你应该使用 torrent 方式,或者使用一个[下载管理器][11]来下载它。 + +- [下载 Kali Linux 虚拟镜像][8] + +#### 3、在 Virtual Box 上安装 Kali Linux + +当你安装 VirtualBox 并下载 Kali Linux 镜像后,你只需要将其导入到 VirtualBox 中就可以使其正常工作。 + +这里是如何导入 Kali Linux 的 VirtualBox 镜像: + +##### 步骤 1 + +启动 VirtualBox。你会看到一个导入Import 按钮,点击它。 + +![点击导入按钮][12] + +##### 步骤 2 + +接下来,浏览刚刚下载的文件,选择要导入的文件(如下图所示)。文件名应该以“kali linux”开始,以 .ova 扩展名结束。 + +![导入 Kali Linux 镜像][13] + +选择后,单击下一步Next继续进行。 + +##### 步骤 3 + +现在,你会看到要导入的虚拟机的设置。所以,你可以自定义它们或者不自定义,这是你的选择。采用默认设置也是可以的。 + +你需要选择一个有足够可用存储空间的路径。在 Windows 上,我绝不建议使用 C: 盘。 + +![将硬盘驱动器导入为 VDI][14] + +在这里,“将硬盘驱动器导入为 VDI”指的是通过分配存储器空间集来虚拟挂载硬盘驱动器。 + +在你完成设置后,单击导入Import,等待一段时间。 + +##### 步骤 4 + +你现在将看到它被列在虚拟机列表中。所以,只需点击开始Start来启动它。 + +你可能会在开始时得到一个 USB 2.0 端口控制器的错误,你可以禁用它来解决问题,或者只需按照屏幕上的指示来安装一个附加软件包修复问题。然后就大功告成了! + +![Kali Linux 运行在 VirtualBox 中][15] + +以前 Kali Linux 中的默认用户名是 root,默认密码是 toor。但从 2020 年 1 月起,Kali Linux 就不使用 root 账号了。现在,默认账号和密码都是 kali。 + +你应该可以用它来登录系统了。 + +请注意,在尝试安装一个新的应用程序或尝试破解 WiFi 密码之前,请先[更新 Kali Linux][16] 。 + +我希望这篇指南能帮助您在 VirtualBox 上很容易地安装 Kali Linux。当然,Kali Linux 有很多有用的渗透测试工具 – 祝你好运! + +**提示** : Kali Linux 和 Ubuntu 都是基于 Debian 的,如果你在使用 Kali Linux 时遇到任何问题或错误,你可以按照互联网上的 Ubuntu 和 Debian 的教程解决。 + +### 奖励: 免费的 Kali Linux 指南书 + +如果你刚刚开始使用 Kali Linux, 那么了解如何使用 Kali Linux 就很有必要了。 + +Kali Linux 背后的公司 Offensive Security 制作了一本指南书,讲解了 Linux 的基础知识、Kali Linux 的基础知识、配置和设置,书中还有一些关于渗透测试和安全工具的章节。 + +基本上,它包含你上手 Kali Linux 所需要的一切东西。更重要的是,这本书可以免费下载。 + +- [免费下载《揭秘 Kali Linux》][17] + +如果你在 VirtualBox 上使用 Kali Linux 时遇到问题,请在下面的评论中告诉我们,或者直接分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-kali-linux-virtualbox/ + +作者:[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://www.kali.org/ +[2]: https://itsfoss.com/linux-hacking-penetration-testing/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/kali-linux-virtual-box.png?resize=800%2C450&ssl=1 +[4]: https://www.virtualbox.org/ +[5]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[6]: https://www.virtualbox.org/wiki/Downloads +[7]: https://itsfoss.com/install-virtualbox-ubuntu/ +[8]: https://www.offensive-security.com/kali-linux-vm-vmware-virtualbox-image-download/ +[9]: https://itsfoss.com/install-vmware-player-ubuntu-1310/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/kali-linux-virtual-box-image.jpg?resize=800%2C347&ssl=1 +[11]: https://itsfoss.com/4-best-download-managers-for-linux/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmbox-import-kali-linux.jpg?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmbox-linux-next.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmbox-kali-linux-settings.jpg?ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/kali-linux-on-windows-virtualbox.jpg?resize=800%2C429&ssl=1 +[16]: https://linuxhandbook.com/update-kali-linux/ +[17]: https://kali.training/downloads/Kali-Linux-Revealed-1st-edition.pdf diff --git a/published/202004/20190429 10 moments that shaped Linux history.md b/published/202004/20190429 10 moments that shaped Linux history.md new file mode 100644 index 0000000000..8dc04ce5de --- /dev/null +++ b/published/202004/20190429 10 moments that shaped Linux history.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12060-1.html) +[#]: subject: (10 moments that shaped Linux history) +[#]: via: (https://opensource.com/article/19/4/top-moments-linux-history) +[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss) + +塑造 Linux 历史的 10 个时刻 +====== + +> 自 1991 年诞生以来,Linux 已经走了漫长的一段路,而这些事件标志着它的发展。 + +![](https://img.linux.net.cn/data/attachment/album/202004/01/093243wukmsiwdkkwfrg00.jpg) + +在 2018 年 8 月,Opensource.com 发布了一项包含七个选项的民意测验,询问读者:[Linux 历史上最重要的时刻是什么?][2]我觉得我需要扩大这个清单,并提出我认为的 10 个在塑造 Linux 历史上发挥了重要作用的时刻。 + +### 1、Linus 发布 Linux + +Linus Torvalds 最初是在 1991 年将 Linux 当成一个业余爱好发布到世上的。结果这个业余爱好成了他的职业! + +### 2、出现 Linux 发行版 + +1993 年,出现了几个 Linux 发行版,需要特别指出的有 [Debian][3]、[Red Hat][4] 和 [Slackware][5]。这个时刻之所以重要是因为它们证明了 Linux 在市场认可度和开发水平方面的成就,使其能够在 1990 年代动荡的操作系统战争、浏览器战争和协议战争中生存下来。相反,那时许多成熟的、商业的和专有的产品并没有活过千禧年之交! + +### 3、IBM 斥巨资投注 Linux + +2000 年,IBM 宣布将在 Linux 上投资 10 亿美元。Richard Richtmyer 在他的 CNN Money [有关投资的文章][6] 中写道:“这一声明强调了蓝色巨人对 Linux 的承诺,标志着将这个替代操作系统推向主流商业市场的重大进展。” + +### 4、好莱坞接纳 Linux + +在 2002 年,整个好莱坞电影业似乎都采用了 Linux。[迪尼斯][7]、[梦工厂][8] 和 [工业光魔][9] 都在那一年开始用 Linux 制作电影。 + +### 5、Linux 得到政府认可 + +2003 年,美国政府对 Linux 的接受是它的又一个重要时刻。红帽 Linux 被[授予][10]美国防部通用操作环境(COE)认证。这很重要,因为政府(特别是情报和军事机构)对计算机系统有非常严格的要求,以防止攻击和支持国家安全。这为其他机构使用 Linux 打开了大门。在那年晚些时候,[美国国家气象局宣布][11],它将用运行 Linux 的新计算机代替过时的系统。 + +### 6、我管理的系统 + +这个“时刻”确实是我个人经历的集合。随着在 2000 年代我的职业发展,我发现自己管理的几种类型的系统和设备都运行着 Linux。我在 VMware ESX、F5 Big-IP、Check Point UTM Edge、Cisco ASA 和 PIX 这些地方发现了 Linux。这使我意识到 Linux 确实可行并且可以继续存在下去。 + +### 7、Ubuntu + +2004 年,Mark Shuttleworth 创立了 Canonical,该公司基于 Debian 发行版提供了易于使用的 Linux 桌面:[Ubuntu Linux][12]。我认为 Ubuntu Linux 帮助扩展了桌面 Linux 安装基数。从休闲的家庭用户到专业软件开发人员,它使 Linux 出现在更多人面前。 + +### 8、Google 的 Linux + +Google 发行了两种基于 Linux 内核的操作系统:2008 年中期的 Android 移动操作系统和 2011 年在 Chromebook 上运行的 Chrome OS。在那之后,已经售出了数百万部 Android 手机和 Chromebook。 + +### 9、云计算即 Linux + +在过去这十年左右的时间里,云计算已经从互联网计算的宏伟愿景变成了我们如何个人和专业地使用计算机的全新方式。云计算领域中的主要参与者都是构建于 Linux 之上的,包括 [Amazon Web Services(AWS)][13]、[Google Cloud Services(GCS)][14] 和 [Linode][15]。即使在一些我们不能确信的地方(例如 Microsoft Azure),也很好地支持运行 Linux 工作负载。 + +### 10、我的汽车运行着 Linux + +你的也一样!许多汽车制造商几年前开始引入 Linux。这导致了名为 [汽车级 Linux(AGL)][16] 的协作开源项目的形成。丰田和斯巴鲁等主要汽车制造商已经联合开发基于 Linux 的汽车娱乐、导航和引擎管理系统。 + +### 分享你的最爱 + +这是我从贯穿我的职业生涯的 Linux 文章和事件的档案库中提取出来的主观清单,因此可能还有其他更值得注意的时刻。请分享你的评论吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/4/top-moments-linux-history + +作者:[Alan Formy-Duval][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_penguin_green.png?itok=ENdVzW22 (Penguin with green background) +[2]: https://opensource.com/article/18/8/linux-history +[3]: https://www.debian.org/doc/manuals/project-history/ch-intro.en.html +[4]: https://brand.redhat.com/foundations/history +[5]: https://opensource.com/article/18/7/stackware-turns-25 +[6]: https://money.cnn.com/2000/12/12/technology/ibm_linux +[7]: https://www.nytimes.com/2002/06/18/business/technology-disney-shifting-to-linux-for-film-animation.html +[8]: https://www.linux.com/news/stallion-and-penguin-dreamworks-uses-linux-create-new-animated-film +[9]: https://www.linuxjournal.com/article/6011 +[10]: https://www.cnet.com/news/government-tips-hat-to-red-hat +[11]: https://www.computerworld.com/article/2574142/national-weather-service-migrates-to-linux-based-ibm-workstations.html +[12]: https://www.ubuntu.com/about +[13]: https://aws.amazon.com/amazon-linux-2 +[14]: https://cloud.google.com +[15]: https://www.linode.com/docs/getting-started +[16]: https://www.automotivelinux.org diff --git a/published/202004/20190523 Run your blog on GitHub Pages with Python.md b/published/202004/20190523 Run your blog on GitHub Pages with Python.md new file mode 100644 index 0000000000..ea62c62a04 --- /dev/null +++ b/published/202004/20190523 Run your blog on GitHub Pages with Python.md @@ -0,0 +1,233 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12064-1.html) +[#]: subject: (Run your blog on GitHub Pages with Python) +[#]: via: (https://opensource.com/article/19/5/run-your-blog-github-pages-python) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny/users/jasperzanjani/users/jasperzanjani/users/jasperzanjani/users/jnyjny/users/jasperzanjani) + +使用 Python 在 GitHub 上运行你的博客 +====== + +> 使用 Pelican 创建博客,这是一个基于 Python 的平台,与 GitHub 配合的不错。 + +![](https://img.linux.net.cn/data/attachment/album/202004/02/101030cy0t0f0e0jvf5e5e.jpg) + +[GitHub][2] 是一个非常流行的用于源代码控制的 Web 服务,它使用 [Git][3] 同步本地文件和 GitHub 服务器上保留的副本,这样你就可以轻松地共享和备份你的工作。 + +除了为代码仓库提供用户界面之外,GitHub 还运允许用户直接从仓库[发布网页][4]。GitHub 推荐的网站生成软件包是 [Jekll][5],是使用 Ruby 编写的。因为我是 [Python][6] 的忠实粉丝,所以我更喜欢 [Pelican][7],这是一个基于 Python 的博客平台,可与 GitHub 很好地协同工作。 + +Pelican 和 Jekll 都可以将 [Markdown][8] 或 [reStructuredText][9] 中编写的内容转换为 HTML 以生成静态网站,并且两个生成器都支持定制的主题。 + +在本文中,我将介绍如何安装 Pelican、设置 GitHub 仓库、运行快速入门帮助、编写一些 Markdown 文件以及发布第一篇博客。我假设你有一个 [GitHub 账户][10],熟悉[基础的 Git 命令][11],并且想使用 Pelican 发布博客。 + +### 安装 Pelican 并创建仓库 + +首先,你必须在本地计算机上安装 Pelican 和 `ghp-import`。使用 Python 软件包安装工具 [pip][12](你有,对吧?),这非常容易: + +``` +$ pip install pelican ghp-import Markdown +``` + +然后,打开浏览器并在 GitHub 上为你新鲜出炉的博客创建一个新仓库,命名如下(在此处以及整个教程中,用 GitHub 用户名替换 `username`): + +``` +https://GitHub.com/username/username.github.io +``` + +让它保持为空,稍后我们用引人注目的博客内容来填充它。 + +使用命令行(确保正确),将这个空 Git 仓库克隆到本地计算机: + +``` +$ git clone blog +$ cd blog +``` + +### 奇怪的把戏... + +在 GitHub 上发布 Web 内容有一个不太引入注意的技巧,对于托管在名为 `username.github.io` 的仓库的用户页面,其内容由 `master` 分支提供服务。 + +我强烈建议所有的 Pelican 配置文件和原始的 Markdown 文件都不要保留在 `master` 中,`master` 中只保留 Web 内容。因此,我将 Pelican 配置和原始内容保留在一个我喜欢称为 `content` 的单独分支中。(你可以随意创建一个分支,但以下内容沿用 `content`。)我喜欢这种结构,因为我可以放弃掉 `master` 中的所有文件,然后用 `content` 分支重新填充它。 + +``` +$ git checkout -b content +Switched to a new branch 'content' +``` + +### 配置 Pelican + +现在该进行内容配置了。Pelican 提供了一个很棒的初始化工具 `pelican-quickstart`,它会询问你有关博客的一系列问题。 + +``` +$ pelican-quickstart +Welcome to pelican-quickstart v3.7.1. + +This script will help you create a new Pelican-based website. + +Please answer the following questions so this script can generate the files +needed by Pelican. + +> Where do you want to create your new web site? [.] +> What will be the title of this web site? Super blog +> Who will be the author of this web site? username +> What will be the default language of this web site? [en] +> Do you want to specify a URL prefix? e.g., http://example.com (Y/n) n +> Do you want to enable article pagination? (Y/n) +> How many articles per page do you want? [10] +> What is your time zone? [Europe/Paris] US/Central +> Do you want to generate a Fabfile/Makefile to automate generation and publishing? (Y/n) y +> Do you want an auto-reload & simpleHTTP script to assist with theme and site development? (Y/n) y +> Do you want to upload your website using FTP? (y/N) n +> Do you want to upload your website using SSH? (y/N) n +> Do you want to upload your website using Dropbox? (y/N) n +> Do you want to upload your website using S3? (y/N) n +> Do you want to upload your website using Rackspace Cloud Files? (y/N) n +> Do you want to upload your website using GitHub Pages? (y/N) y +> Is this your personal page (username.github.io)? (y/N) y +Done. Your new project is available at /Users/username/blog +``` + +你可以对每个问题都采用默认值,但除了以下这些问题: + +* 网站标题,应该唯一且特殊 +* 网站作者,可以是个人用户名或你的全名 +* 时区,可能你不在巴黎 +* 上传到 GitHub 页面,我们选择 `y` + +回答完所有问题后,Pelican 会在当前目录中留下以下内容: + +``` +$ ls +Makefile content/ develop_server.sh* +fabfile.py output/ pelicanconf.py +publishconf.py +``` + +你可以查看 [Pelican 文档][13]来了解如何使用这些文件,但**现在**我们要做的是完成手头的工作。说实话,我也没有阅读文档。 + +### 继续 + +将所有 Pelican 生成的文件添加到本地 Git 仓库的 `content` 分支,提交更改,然后将本地更改推送到 Github 上托管的远程仓库: + +``` +$ git add . +$ git commit -m 'initial pelican commit to content' +$ git push origin content +``` + +这件事情并不是特别令人兴奋,但是如果我们需要撤销这些文件之一的修改时,这将非常方便。 + +### 终于 + +终于,现在你得到一个博客了!你所有的博客文章、照片、图像、PDF 等都将位于 `content` 目录中,它最初是空的。要开始创建第一篇博客和关于页面,输入: + +``` +$ cd content +$ mkdir pages images +$ cp /Users/username/SecretStash/HotPhotoOfMe.jpg images +$ touch first-post.md +$ touch pages/about.md +``` + +接下来,在你喜欢的文本编辑器中打开 `first-post.md`,并添加以下内容: + +``` +title: First Post on My Sweet New Blog +date: +author: Your Name Here + +# I am On My Way To Internet Fame and Fortune! + +This is my first post on my new blog. While not super informative it +should convey my sense of excitement and eagerness to engage with you, +the reader! +``` + +前三行是 Pelican 用于组织内容的元数据。有很多不同的元数据可供你选择。再说一次,文档是你了解更多选项的最佳选择。 + +现在,打开空白文件 `pages/about.md` 并添加以下文本: + +``` +title: About +date: + +![So Schmexy][my_sweet_photo] + +Hi, I am and I wrote this epic collection of Interweb +wisdom. In days of yore, much of this would have been deemed sorcery +and I would probably have been burned at the stake. + +😆 + +[my_sweet_photo]: {static}/images/HotPhotoOfMe.jpg +``` + +现在,`content` 目录中将包含三个新的 Web 内容,在 `content` 分支中还有很多内容。 + +### 发布 + +不要急,马上要见到成果了! + +剩下要做的就是: + +* 运行 Pelican 以在 `output` 中生成静态 HTML 文件: + + ``` +$ pelican content -o output -s publishconf.py +``` +* 使用 `ghp-import` 将 `output` 目录的内容添加到 `master` 分支中: + + ``` +$ ghp-import -m "Generate Pelican site" --no-jekyll -b master output +``` +* 将本地 `master` 分支推送到远程仓库: + + ``` +$ git push origin master +``` +* 提交新内容并将其推送到 `content` 分支 + + ``` +$ git add content +$ git commit -m 'added a first post, a photo and an about page' +$ git push origin content +``` + +### OMG,我成功了 + +现在最激动的时候到了,当你想要看到你发布给大家的博客内容时,打开浏览器输入: + +``` +https://username.github.io +``` + +恭喜你可以在 GitHub 上发布自己的博客了!当你想添加更多页面或文章时,都可以按照上面的步骤来。希望你可以愉快地发布博客。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/5/run-your-blog-github-pages-python + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjny/users/jasperzanjani/users/jasperzanjani/users/jasperzanjani/users/jnyjny/users/jasperzanjani +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/getting_started_with_python.png?itok=MFEKm3gl (Raspberry Pi and Python) +[2]: https://github.com/ +[3]: https://git-scm.com +[4]: https://help.github.com/en/categories/github-pages-basics +[5]: https://jekyllrb.com +[6]: https://python.org +[7]: https://blog.getpelican.com +[8]: https://guides.github.com/features/mastering-markdown +[9]: http://docutils.sourceforge.net/docs/user/rst/quickref.html +[10]: https://github.com/join?source=header-home +[11]: https://git-scm.com/docs +[12]: https://pip.pypa.io/en/stable/ +[13]: https://docs.getpelican.com diff --git a/published/202004/20190605 What is GraphQL.md b/published/202004/20190605 What is GraphQL.md new file mode 100644 index 0000000000..49d68894b1 --- /dev/null +++ b/published/202004/20190605 What is GraphQL.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12070-1.html) +[#]: subject: (What is GraphQL?) +[#]: via: (https://opensource.com/article/19/6/what-is-graphql) +[#]: author: (Zach Lendon https://opensource.com/users/zachlendon) + +什么是 GraphQL? +====== + +> GraphQL 是一种查询语言、一个执行引擎,也是一种规范,它让开发人员重新思考如何构建客户端和 API 应用。 + +![](https://img.linux.net.cn/data/attachment/album/202004/04/112938odz6sbw6hzwsh7f6.jpg) + +GraphQL 是当今软件技术中最大的流行语之一。但它*究竟*是什么?是像 [SQL][2] 一样的查询语言吗?是像 [JVM][3] 这样的执行引擎?还是像 [XML][4] 这样的规范? + +如果你回答上面这些都是,那么你是对的![GraphQL][5] 是一种查询语言的语法、是一种编程语言无关的执行引擎,也是一种不断发展的规范。 + +让我们深入了解一下 GraphQL 如何成为所有这些东西的,并了解一下人们为什么对它感到兴奋。 + +### 查询语言 + +GraphQL 作为查询语言似乎是合理的 —— 毕竟 “QL” 似乎重要到出现在名称中。但是我们查询什么呢?看一个示例查询请求和相应的响应可能会有所帮助。 + +以下的用户查询: + +``` +{ + user(id: 4) { +    name +    email +    phoneNumber +  } +} +``` + +可能会返回下面的 JSON 结果: + +``` +{ +  "user": { +    "name": "Zach Lendon" +    “email”: “zach@hydrate.io” +    “phoneNumber”: “867-5309” +  } +} +``` + +想象一下,客户端应用查询用户详细信息、获取结果,并使用它填充配置屏幕。作为查询语言,GraphQL 的核心优势之一是客户端应用可以*只请求它需要*的数据,并期望以一致的方式返回这些数据。 + +那么 GraphQL 响应返回的*什么*呢?这就是执行引擎发挥的作用,通常是以 GraphQL 服务器的形式出现。 + +### 执行引擎 + +![GraphQL execution engine][7] + +GraphQL 执行引擎负责处理 GraphQL 查询并返回 JSON 响应。所有 GraphQL 服务器由两个核心组件组成,分别定义了执行引擎的结构和行为:模式和解析器。 + +GraphQL 模式是一种自定义类型语言,它公开哪些查询既允许(有效),又由 GraphQL 服务器实现处理。上面用户示例查询的模式可能如下所示: + +``` +type User { + name: String +    email: String +    phoneNumber: String +} + +type Query { +    user: User +} +``` + +此模式定义了一个返回用户的用户查询。客户端可以通过用户查询请求用户上的任何字段,并且 GraphQL 服务器将仅返回请求的字段。通过使用强类型模式,GraphQL 服务器可以根据定义的模式验证传入的查询,以确保是有效的。 + +确定查询有效后,就会由 GraphQL 服务器的解析器处理。解析器函数支持每个 GraphQL 类型的每个字段。我们的这个用户查询的示例解析器可能如下所示: + +``` +Query: { + user(obj, args, context, info) { + return context.db.loadUserById(args.id).then( + userData => new User(userData) + ) + } +} +``` + +虽然上面的例子是用 JavaScript 编写的,但 GraphQL 服务器可以用任意语言编写。这是因为 GraphQL 也是*也是*一种规范! + +### 规范 + +GraphQL 规范定义了 GraphQL 实现必须遵循的功能和特性。作为一个在开放网络基金会的最终规范协议([OWFa 1.0][8])下提供的开放规范,技术社区可以审查 GraphQL 实现必须符合规范的要求,并帮助制定 GraphQL 的未来。 + +虽然该规范对 GraphQL 的语法,什么是有效查询以及模式的工作方式进行了非常具体的说明,但它没有提供有关如何存储数据或 GraphQL 服务器应使用哪种编程语言实现的指导。这在软件领域是非常强大的,也是相对独特的。它允许以各种编程语言创建 GraphQL 服务器,并且由于它们符合规范,因此客户端会确切知道它们的工作方式。GraphQL 服务器已经有多种语言实现,人们不仅可以期望像 JavaScript、Java和 C# 这样的语言,还可以使用 Go、Elixir 和 Haskell 等。服务器实现所使用的语言不会成为采用过程的障碍。它不仅存在多种语言实现,而且它们都是开源的。如果没有你选择的语言的实现,那么可以自己实现。 + +### 总结 + +GraphQL 是开源 API 领域中一个令人兴奋的、相对较新的参与者。它将查询语言、执行引擎与开源规范结合在一起,它定义了 GraphQL 实现的外观和功能。 + +GraphQL 已经开始改变企业对构建客户端和 API 应用的看法。通过将 GraphQL 作为技术栈的一部分,前端开发人员可以自由地查询所需的数据,而后端开发人员可以将客户端应用需求与后端系统架构分离。通常,公司在使用 GraphQL 的过程中,首先会在其现有的后端服务之上构建一个 GraphQL API “层”。这使得客户端应用开始获得他们所追求的性能和运营效率,同时使后端团队有机会确定他们可能需要在 GraphQL 层后面的“幕后”进行哪些更改。通常,这些更改都是为了优化,这些优化有助于确保使用 GraphQL 的应用可以尽可能高效地运行。由于 GraphQL 提供了抽象性,因此系统团队可以进行更改的同时继续在其 GraphQL API 级别上遵守 GraphQL 的“合约”。 + +由于 GraphQL 相对较新,因此开发人员仍在寻找新颖而激动人心的方法来利用它构建更好的软件解决方案。GraphQL 将如何改变你构建应用的方式,它是否对得起众望所归?只有一种方法可以找到答案 —— 用 GraphQL 构建一些东西! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/what-is-graphql + +作者:[Zach Lendon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/zachlendon +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/analytics-graphs-charts.png?itok=sersoqbV (Analytics: Charts and Graphs) +[2]: https://opensource.com/article/18/2/getting-started-sql +[3]: https://www.cubrid.org/blog/understanding-jvm-internals/ +[4]: https://www.w3.org/TR/xml/ +[5]: http://graphql.org/ +[6]: mailto:zach@hydrate.io +[7]: https://opensource.com/sites/default/files/pictures/graphql-execution-engine.png (GraphQL execution engine) +[8]: http://www.openwebfoundation.org/legal/the-owf-1-0-agreements/owfa-1-0---patent-only diff --git a/published/202004/20190612 How to write a loop in Bash.md b/published/202004/20190612 How to write a loop in Bash.md new file mode 100644 index 0000000000..6649f2b926 --- /dev/null +++ b/published/202004/20190612 How to write a loop in Bash.md @@ -0,0 +1,262 @@ +[#]: collector: "lujun9972" +[#]: translator: "chunibyo-wly" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12088-1.html" +[#]: subject: "How to write a loop in Bash" +[#]: via: "https://opensource.com/article/19/6/how-write-loop-bash" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" + +如何在 Bash 中使用循环 +====== + +> 使用循环和查找命令批量自动对多个文件进行一系列的操作。 + +![](https://img.linux.net.cn/data/attachment/album/202004/08/225655by8i8k7uyppp18ph.jpg) + +人们希望学习批处理命令的一个普遍原因是要得到批处理强大的功能。如果你希望批量的对文件执行一些指令,构造一个可以重复运行在那些文件上的命令就是一种方法。在编程术语中,这被称作*执行控制*,`for` 循环就是其中最常见的一种。 + +`for` 循环可以详细描述你希望计算机对你指定的每个数据对象(比如说文件)所进行的操作。 + +### 一般的循环 + +使用循环的一个简单例子是对一组文件进行分析。这个循环可能没什么用,但是这是一个安全的证明自己有能力独立处理文件夹里每一个文件的方法。首先,创建一个文件夹然后拷贝一些文件(例如 JPEG、PNG 等类似的文件)至文件夹中生成一个测试环境。你可以通过文件管理器或者终端来完成创建文件夹和拷贝文件的操作: + +```bash +$ mkdir example +$ cp ~/Pictures/vacation/*.{png,jpg} example +``` + +切换到你刚创建的那个新文件夹,然后列出文件并确认这个测试环境是你需要的: + +``` +$ cd example +$ ls -1 +cat.jpg +design_maori.png +otago.jpg +waterfall.png +``` + +在循环中逐一遍历文件的语法是:首先声明一个变量(例如使用 `f` 代表文件),然后定义一个你希望用变量循环的数据集。在这种情况下,使用 `*` 通配符来遍历当前文件夹下的所有文件(通配符 `*` 匹配*所有文件*)。然后使用一个分号(`;`)来结束这个语句。 + +``` +$ for f in * ; +``` + +取决于你个人的喜好,你可以选择在这里按下回车键。在语法完成前,shell 是不会尝试执行这个循环的。 + +接下来,定义你想在每次循环中进行的操作。简单起见,使用 `file` 命令来得到 `f` 变量(使用 `$` 告诉 shell 使用这个变量的值,无论这个变量现在存储着什么)所存储着的文件的各种信息: + +``` +do file $f ; +``` + +使用另一个分号结束这一行,然后关闭这个循环: + +``` +done +``` + +按下回车键启动 shell 对当前文件夹下*所有东西*的遍历。`for` 循环将会一个一个的将文件分配给变量 `f` 并且执行你的命令: + +``` +$ for f in * ; do +> file $f ; +> done +cat.jpg: JPEG image data, EXIF standard 2.2 +design_maori.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +otago.jpg: JPEG image data, EXIF standard 2.2 +waterfall.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +``` + +你也可以用这种形式书写命令: + +``` +$ for f in *; do file $f; done +cat.jpg: JPEG image data, EXIF standard 2.2 +design_maori.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +otago.jpg: JPEG image data, EXIF standard 2.2 +waterfall.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +``` + +对你的 shell 来说,多行和单行的格式没有什么区别,并且会输出完全一样的结果。 + +### 一个实用的例子 + +下面是一个循环在日常使用中的实用案例。假如你拥有一堆假期拍的照片想要发给你的朋友。但你的照片太大了,无法通过电子邮件发送,上传到[图片分享服务][2]也不方便。因此你想为你的照片创建小型的 web 版本,但是你不希望花费太多时间在一个一个的压缩图片体积上。 + +首先,在你的 Linux、BSD 或者 Mac 上使用包管理器安装 ImageMagick 命令。例如,在 Fedora 和 RHEL 上: + +``` +$ sudo dnf install ImageMagick +``` + +在 Ubuntu 和 Debian 上: + +``` +$ sudo apt install ImageMagick +``` + +在 BSD 上,使用 `ports` 或者 [pkgsrc][3] 安装。在 Mac 上,使用 [Homebrew][4] 或者 [MacPorts][5] 安装。 + +在你安装了 ImageMagick 之后,你就拥有一系列可以用来操作图片的新命令了。 + +为你将要创建的文件建立一个目标文件夹: + +``` +$ mkdir tmp +``` + +使用下面的循环可以将每张图片减小至原来大小的 33%。 + +``` +$ for f in * ; do convert $f -scale 33% tmp/$f ; done +``` + +然后就可以在 `tmp` 文件夹中看到已经缩小了的照片了。 + +你可以在循环体中使用任意数量的命令,因此如果你需要对一批文件进行复杂的操作,可以将你的命令放在一个 `for` 循环的 `do` 和 `done` 语句之间。例如,假设你希望将所有处理过的图片拷贝至你的网站所托管的图片文件夹并且在本地系统移除这些文件: + +``` +$ for f in * ; do + convert $f -scale 33% tmp/$f + scp -i seth_web tmp/$f seth@example.com:~/public_html + trash tmp/$f ; +done +``` + +你的计算机会对 `for` 循环中处理的每一个文件自动的执行 3 条命令。这意味着假如你仅仅处理 10 张图片,也会省下输入 30 条指令和更多的时间。 + +### 限制你的循环 + +一个循环常常不需要处理所有文件。在示例文件夹中,你可能需要处理的只是 JPEG 文件: + +``` +$ for f in *.jpg ; do convert $f -scale 33% tmp/$f ; done +$ ls -m tmp +cat.jpg, otago.jpg +``` + +或者,你希望重复特定次数的某个操作而不仅仅只处理文件。`for` 循环的变量的值是被你赋给它的(不管何种类型的)数据所决定的,所以你可以创建一个循环遍历数字而不只是文件: + +``` +$ for n in {0..4}; do echo $n ; done +0 +1 +2 +3 +4 +``` + +### 更多循环 + +现在你了解的知识已经足够用来创建自己的循环体了。直到你对循环非常熟悉之前,尽可能的在需要处理的文件的*副本*上进行操作。使用内置的保护措施可以预防损坏自己的数据和制造不可复现的错误,例如偶然将一个文件夹下的所有文件重命名为同一个名字,就可能会导致他们的相互覆盖。 + +更进一步的 `for` 循环话题,请继续阅读。 + +### 不是所有的 shell 都是 Bash + +关键字 `for` 是内置在 Bash shell 中的。许多类似的 shell 会使用和 Bash 同样的关键字和语法,但是也有某些 shell ,比如 [tcsh][7],使用不同的关键字,例如 `foreach`。 + +tcsh 的语法与 Bash 类似,但是它更为严格。例如在下面的例子中,不要在你的终端的第 2、3 行键入 `foreach?` 。它只是提示你仍处在构建循环的过程中。 + +``` +$ foreach f (*) +foreach? file $f +foreach? end +cat.jpg: JPEG image data, EXIF standard 2.2 +design_maori.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +otago.jpg: JPEG image data, EXIF standard 2.2 +waterfall.png: PNG image data, 4608 x 2592, 8-bit/color RGB, non-interlaced +``` + +在 tcsh 中,`foreach` 和 `end` 都必须单独的在一行中出现。因此你不能像 Bash 或者其他类似的 shell 一样只使用一行命令创建一个 `for` 循环。 + +### for 循环与 find 命令 + +理论上,你可能会用到不支持 `for` 循环的 shell,或者你只是更想使用其他命令的一些特性来完成和循环一样的工作。 + +使用 `find` 命令是另一个实现 `for` 循环功能的途径。这个命令提供了多种方法来定义循环中包含哪些文件的范围以及[并行][8]处理的选项。 + +`find` 命令顾名思义就是帮助你查询存储在硬盘里的文件。它的用法很简单:提供一个你希望它查询的位置的路径,接着 `find` 就会查询这个路径下面的所有文件和文件夹。 + +``` +$ find . +. +./cat.jpg +./design_maori.png +./otago.jpg +./waterfall.png +``` + +你可以通过添加名称的某些部分来过滤搜索结果: + +``` +$ find . -name "*jpg" +./cat.jpg +./otago.jpg +``` + +`find` 命令非常好的地方在于你可以通过 `-exec` 参数标志将它查询到的每一个文件放入循环中。例如,只对存放在你的 `example` 文件夹下的 PNG 图片进行体积压缩操作: + +``` +$ find . -name "*png" -exec convert {} -scale 33% tmp/{} \; +$ ls -m tmp +design_maori.png, waterfall.png +``` + +在 `-exec` 短语中,括号 `{}` 表示的是 `find` 正在处理的条目(换句话说,每一个被找到的以 PNG 结尾的文件)。`-exec` 短语必须使用分号结尾,但是 Bash 中常常也会使用分号。为了解决这个二义性问题,你的 `结束符` 可以使用反斜杠加上一个分号(`\;`),使得 `find` 命令可以知道这个结束符是用来标识自己结束使用的。 + +`find` 命令的操作非常棒,某些情况下它甚至可以表现得更棒。比如说,在一个新的进程中使用同一条命令查找 PNG 文件,你可能就会得到一些错误信息: + +``` +$ find . -name "*png" -exec convert {} -flip -flop tmp/{} \; +convert: unable to open image `tmp/./tmp/design_maori.png': +No such file or directory @ error/blob.c/OpenBlob/2643. +... +``` + +看起来 `find` 不只是定位了当前文件夹(`.`)下的所有 PNG 文件,还包括已经处理并且存储到了 `tmp` 下的文件。在一些情况下,你可能希望 `find` 查询当前文件夹下再加上其子文件夹下的所有文件。`find` 命令是一个功能强大的递归工具,特别体现在处理一些文件结构复杂的情境下(比如用来放置存满了音乐人音乐专辑的文件夹),同时你也可以使用 `-maxdepth` 选项来限制最大的递归深度。 + +只在当前文件夹下查找 PNG 文件(不包括子文件夹): + +``` +$ find . -maxdepth 1 -name "*png" +``` + +上一条命令的最大深度再加 1 就可以查找和处理当前文件夹及下一级子文件夹下面的文件: + +``` +$ find . -maxdepth 2 -name "*png" +``` + +`find` 命令默认是查找每一级文件夹。 + +### 循环的乐趣与收益 + +你使用的循环越多,你就可以越多的省下时间和力气,并且可以应对庞大的任务。虽然你只是一个用户,但是通过使用循环,可以使你的计算机完成困难的任务。 + +你可以并且应该就像使用其他的命令一样使用循环。在你需要重复处理单个或多个文件时,尽可能的使用这个命令。无论如何,这也算是一项需要被严肃对待的编程活动,因此如果你需要在一些文件上完成复杂的任务,你应该多花点时间在规划自己的工作流上面。如果你可以在一份文件上完成你的工作,接下来将操作包装进 `for` 循环里就相对简单了,这里面唯一的“编程”的需要只是理解变量是如何工作的并且进行充分的规划工作将已处理过的文件和未处理过的文件分开。经过一段时间的练习,你就可以从一名 Linux 用户升级成一位知道如何使用循环的 Linux 用户,所以开始让计算机为你工作吧! + +--- + +via: https://opensource.com/article/19/6/how-write-loop-bash + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[chunibyo-wly](https://github.com/chunibyo-wly) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth/users/goncasousa/users/howtopamm/users/howtopamm/users/seth/users/wavesailor/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U "bash logo on green background" +[2]: http://nextcloud.com +[3]: http://pkgsrc.org +[4]: http://brew.sh +[5]: https://www.macports.org +[6]: mailto:seth@example.com +[7]: https://en.wikipedia.org/wiki/Tcsh +[8]: https://opensource.com/article/18/5/gnu-parallel diff --git a/published/202004/20190612 Why use GraphQL.md b/published/202004/20190612 Why use GraphQL.md new file mode 100644 index 0000000000..b71cb64206 --- /dev/null +++ b/published/202004/20190612 Why use GraphQL.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12075-1.html) +[#]: subject: (Why use GraphQL?) +[#]: via: (https://opensource.com/article/19/6/why-use-graphql) +[#]: author: (Zach Lendon https://opensource.com/users/zachlendon/users/goncasousa/users/patrickhousley) + +为什么使用 GraphQL? +====== + +> 以下是 GraphQL 在标准 REST API 技术上获得发展的原因。 + +[](https://img.linux.net.cn/data/attachment/album/202004/05/105820rdnjrppprjdjddfd.jpg) + +正如我[以前][3]所写,[GraphQL][2] 是一种下一代 API 技术,它正在改变客户端应用程序与后端系统的通信方式以及后端系统的设计方式。 + +由于一开始就从创建它的组织 Facebook 获得了支持,并得到了其他技术巨头(如 Github、Twitter 和 AirBnB)的支持,因此 GraphQL 作为应用程序系统的关键技术的地位似乎是稳固的 —— 无论现在还是将来。 + +### GraphQL 的崛起 + +移动应用程序性能和组织敏捷性重要性的提高为 GraphQL 登上现代企业体系结构的顶端提供了助推器。 + +鉴于 [REST][4] 是一种非常流行的体系结构风格,早已提供了数据交互机制,与 [REST][4] 相比,GraphQL 这项新技术具有哪些优势呢?GraphQL 中的 “QL” 代表着查询语言,而这是一个很好的起点。 + +借助 GraphQL,组织内的不同客户端应用程序可以轻松地仅查询所需数据,这一点超越了其它 REST 方法,并带来了实际应用程序性能的提高。使用传统的 [REST][4] API 端点,客户端应用程序将详询服务器资源,并接受包含了与请求匹配的所有数据的响应。如果来自 [REST][4] API 端点的成功响应返回 35 个字段,那么客户端应用程序就会收到 35 个字段。 + +### 获取的问题 + +传统上,[REST][4] API 没有为客户端应用程序提供简便的方法来仅检索或只更新它们关心的数据。这通常被描述为“过度获取over-fetching”的问题。随着移动应用程序在人们的日常生活中的普遍使用,过度获取问题会给现实世界带来不良后果。移动应用程序发出的每个请求、每一个字节的接受和发送,对终端用户的性能影响越来越大。数据连接速度较慢的用户尤其会受到不太好的 API 设计方案的影响。使用移动应用程序而性能体验不佳的客户更有可能不购买产品或不使用服务。低效的 API 设计只会浪费企业的钱。 + +并非只有“过度获取”是问题,“欠缺获取”同样也是问题。默认情况下,端点只返回客户端实际需要的部分数据,这需要客户端进行额外的调用以满足其数据需求,这就产生了额外的 HTTP 请求。由于过度和欠缺的获取问题及其对客户端应用程序性能的影响,促进有效获取的 API 技术才有机会在市场上引起轰动 —— GraphQL 大胆地介入并填补了这一空白。 + +### REST 的应对 + +[REST][4] API 设计师不甘心不战而退,他们试图通过以下几种方式来应对移动应用程序性能问题: + +* “包含”和“排除”查询参数,允许客户端应用程序通过可能较长的查询格式来指定所需的字段。 +* “复合”服务,将多个端点组合在一起,以使客户端应用程序在其发出的请求数量和接收到的数据方面更高效。 +   +尽管这些模式是 [REST][4] API 社区为解决移动客户端所面临的挑战而做出的英勇尝试,但它们在以下几个关键方面仍存在不足: + +* 包含和排除查询键/值对很快就会变得混乱,特别是对于需要用嵌套“点表示法”语法(或类似方法)以对目标数据进行包含和排除的深层对象图而言,更是如此。此外,在此模型中调试查询字符串的问题通常需要手动分解 URL。 +* 包含和排除查询的服务器的实现往往是自定义的,因为基于服务器的应用程序没有标准的方式来处理包含和排除查询的使用,就像没有定义包含和排除查询的标准方式一样。 +* 复合服务的兴起形成了更加紧密耦合的后端和前端系统,这就需要加强协调以交付项目,并且将曾经的敏捷项目转回瀑布式开发。这种协调和耦合还有一个痛苦的副作用,那就是减宦了组织的敏捷性。此外,顾名思义,组合服务不是 RESTful。 +   +### GraphQL 的起源 + +对于 Facebook 来说,从其 2011-2012 年基于 HTML5 版本的旗舰移动应用程序中感受到的痛点和体验,才造就了 GraphQL。Facebook 工程师意识到提高性能至关重要,因此意识到他们需要一种新的 API 设计来确保最佳性能。可能考虑到上述 [REST][4] 的局限性,并且需要支持许多 API 客户端的不同需求,因此人们可以理解是什么导致其共同创建者 Lee Byron 和 Dan Schaeffer(那时尚是 Facebook 员工)创建了后来被称之为 GraphQL 的技术的早期种子。 + +通过 GraphQL 查询语言,客户端(通常是单个 GraphQL 端点)应用程序通常可以显著减少所需的网络调用数量,并确保仅检索所需的数据。在许多方面,这可以追溯到早期的 Web 编程模型,在该模型中,客户端应用程序代码会直接查询后端系统 —— 比如说,有些人可能还记得 10 到 15 年前在 JSP 上用 JSTL 编写 SQL 查询的情形吧! + +现在最大的区别是使用 GraphQL,我们有了一个跨多种客户端和服务器语言和库实现的规范。借助 GraphQL 这样一种 API 技术,我们通过引入 GraphQL 应用程序中间层来解耦后端和前端应用程序系统,该层提供了一种机制,以与组织的业务领域相一致的方式来访问组织数据。 + +除了解决软件工程团队遇到的技术挑战之外,GraphQL 还促进了组织敏捷性的提高,特别是在企业中。启用 GraphQL 的组织敏捷性通常归因于以下因素: + + * GraphQL API 设计人员和开发人员无需在客户端需要一个或多个新字段时创建新的端点,而是能够将这些字段包含在现有的图实现中,从而以较少的开发工作量和跨应用程序系统的较少更改的方式展示出新功能。 + * 通过鼓励 API 设计团队将更多的精力放在定义对象图上,而不是在专注于客户端应用程序交付上,前端和后端软件团队为客户交付解决方案的速度日益解耦。 +   +### 采纳之前的注意事项 + +尽管 GraphQL 具有引人注目的优势,但 GraphQL 并非没有实施挑战。一些例子包括: + +* 为 [REST][4] API 建立的缓存机制更加成熟。 +* 使用 [REST][4] 来构建 API 的模式更加完善。 +* 尽管工程师可能更喜欢 GraphQL 等新技术,但与 GraphQL 相比,市场上的人才库更多是从事于构建基于 [REST][4] 的解决方案。 + +### 结论 + +通过同时提高性能和组织敏捷性,GraphQL 在过去几年中被企业采纳的数量激增。但是,与 API 设计的 RESTful 生态系统相比,它确实还需要更成熟一些。 + +GraphQL 的一大优点是,它并不是作为替代 API 解决方案的批发替代品而设计的。相反,GraphQL 可以用来补充或增强现有的 API。因此,鼓励企业探索在 GraphQL 对其最有意义的地方逐步采用 GraphQL —— 在他们发现它对应用程序性能和组织敏捷性具有最大的积极影响的地方。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/6/why-use-graphql + +作者:[Zach Lendon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/zachlendon/users/goncasousa/users/patrickhousley +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D +[2]: https://graphql.org/ +[3]: https://linux.cn/article-12070-1.html +[4]: https://en.wikipedia.org/wiki/Representational_state_transfer diff --git a/published/202004/20190712 What is Silverblue.md b/published/202004/20190712 What is Silverblue.md new file mode 100644 index 0000000000..7437135b98 --- /dev/null +++ b/published/202004/20190712 What is Silverblue.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12153-1.html) +[#]: subject: (What is Silverblue?) +[#]: via: (https://fedoramagazine.org/what-is-silverblue/) +[#]: author: (Tomáš Popela https://fedoramagazine.org/author/tpopela/) + +Silverblue 是什么? +====== + +![][1] + +Fedora Silverblue 在 Fedora 世界内外越来越受欢迎。因此,根据社区的反馈,以下是关于这个项目的一些有趣问题的答案。如果你有任何其他与 Silverblue 相关的问题,请在评论区留言,我们会在未来的文章中回答。 + +### Silverblue 是什么? + +Silverblue 是新一代桌面操作系统的代号,之前被称为 Atomic Workstation。该操作系统是通过利用 [rpm-ostree 项目][2]创建的映像来交付的。这种系统的主要优点是速度、安全性、原子更新和不变性。 + +### “Silverblue” 到底是什么意思? + +“Team Silverblue” 或简称 “Silverblue”,没有任何隐藏的含义。该项目以前被称为 Atomic Workstation,大约两个月后更名时选中了这个名字。在这个过程中,审查过 150 多个单词或单词组合。最终选择了 “Silverblue”,因为它有一个可用的域名以及社交网络账号。人们可以把它看成是 Fedora 的蓝色品牌的一个新的品牌形象,可以用在诸如“加油,Silverblue 团队!”或“想加入该团队,改进 Silverblue 吗?”这样的短语中。 + +### 何谓 ostree? + +[OSTree(或 libostree)是一个项目][3],它结合了一个类似 Git 的提交和下载可引导文件系统树的模型,以及用于部署它们和管理引导加载程序配置的层。OSTree 由 rpm-ostree 使用,这是 Silverblue 使用的一个基于包/镜像的混合系统。它原子化地复制了一个基础操作系统,并允许用户在需要时在基础操作系统之上“层叠”传统的 RPM。 + +### 为何使用 Silverblue? + +因为它可以让你专注于你的工作,而不是你正在运行的操作系统。因为系统的更新是原子式的,所以它更稳健。你唯一需要做的事情就是重新启动到新的镜像中。此外,如果当前启动的镜像有什么问题,你可以很容易地重启/回滚到之前可以工作的镜像,如果有的话。如果没有,你可以使用 `ostree` 命令下载并启动过去生成的任何其他镜像。 + +另一个好处是可以在不同的分支(或者用旧的语境说就是不同的 Fedora 风味版本)之间轻松切换。你可以轻松地尝试 [Rawhide][4] 或 [updates-testing][5] 分支,然后返回到包含当前稳定版本的分支。另外,如果你想尝试一些新奇的东西,也可以考虑试试 Silverblue。 + +### 不可变的操作系统有什么好处? + +其中一个主要的好处是安全。基础操作系统是以只读的形式挂载的,因此不能被恶意软件修改。唯一可以改变系统的方法是通过 `rpm-ostree` 实用程序。 + +另一个好处是健壮性。普通用户几乎不可能在不小心或无意中删除了一些系统库后,导致操作系统回到不启动或无法正常工作的状态。试着想想你过去的这些经历,就可以明白 Silverblue 可以如何帮助你。 + +### 如何在 Silverblue 中管理应用程序和包? + +对于图形化用户界面的应用程序,建议使用 [Flatpak][6] —— 如果应用程序是以 Flatpak 的形式提供的话。用户可以选择来自 Fedora 的 Flatpak,和从 Fedora 包及 Fedora 自己的基础架构中构建的 Flatpak,或者是目前有更广泛的交付品的 Flathub。用户可以通过已经支持 Fedora Silverblue 的 GNOME “软件”轻松安装它们。 + +用户首先发现的一件事就是操作系统中没有预装 `dnf`。主要原因是它不能在 Silverblue 上工作 —— 它的部分功能被 `rpm-ostree` 命令所取代。用户可以通过使用 `rpm-ostree install PACKAGE` 来层叠传统的软件包。但只有在没有其他方法的情况下,才应该使用这种方式。这是因为从存储库中提取新的系统镜像时,每次更改系统镜像时都必须重新构建系统镜像,以容纳层叠的包或从基础操作系统中删除及替换为其他版本的包。 + +Fedora Silverblue 自带的默认 GUI 应用程序集是基础操作系统的一部分。团队正在努力将它们移植到 Flatpak 上,这样它们就可以通过这种方式分发。其中一个好处是,基础操作系统将变得更小,更容易维护和测试,用户可以更容易修改他们的默认安装环境。如果你想看一下它是怎么做的,或者有什么帮助,可以看看官方的[文档][7]。 + +### 什么是 Toolbox? + +[Toolbox][8] 是一个让普通用户可以轻松使用容器的项目。它通过使用 podman 的无 root 容器环境来实现。Toolbox 可以让你在常规的 Fedora 环境中轻松、快速地创建一个容器,你可以在这个容器上折腾或开发,而与你的操作系统分离。 + +### Silverblue 有路线图吗? + +形式上没有,因为我们正在关注在测试过程中发现的问题和社区的反馈。我们目前正在使用 Fedora 的 [Taiga][9] 来进行规划。 + +### Silverblue 的发布周期是多少? + +它和普通的 Fedora Workstation 是一样的。每 6 个月发布一次新版本,支持期为 13 个月。团队计划每两周(或更长时间)发布一次更新,而不是像现在这样每天发布一次。这样一来,更新可以在发送给其他用户之前,由 QA 和社区志愿者进行更彻底的测试。 + +### 不可变操作系统的未来前景如何? + +从我们的角度来看,桌面的未来会走向到不可变的操作系统。这对用户来说是最安全的,Android、ChromeOS、ChromeOS、最近的 macOS Catalina 全都在底层采用了这种方式。而对于 Linux 桌面来说,一些第三方软件期望写到操作系统的问题还是存在的。HP 打印机驱动程序就是一个很好的例子。 + +另一个问题是系统中的部分软件如何分发和安装。字体就是一个很好的例子。目前在 Fedora 中,它们是以 RPM 包的形式分发的。如果你想使用它们,你必须层叠它们,然后重新启动到新创建的包含它们的镜像中。 + +### 标准版 Workstation 的前景如何? + +Silverblue 有可能会取代普通的 Workstation 版本。但 Silverblue 要提供与 Workstation 版本相同的功能和用户体验还有很长的路要走。在此期间,这两款桌面产品将同时推出。 + +### Atomic Workstation 或 Fedora CoreOS 与这些有什么关系? + +Atomic Workstation 是在更名为 Fedora Silverblue 之前的项目名称。 + +Fedora CoreOS 是一个不同但相似的项目。它与 Silverblue 共享一些基本技术,如 `rpm-ostree`、`toolbox` 等。尽管如此,CoreOS 是一个更简约、专注于容器、自动更新的操作系统。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/what-is-silverblue/ + +作者:[Tomáš Popela][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/tpopela/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/07/what-is-fedora-silverblue-816x345.jpg +[2]: https://rpm-ostree.readthedocs.io/en/latest/ +[3]: https://ostree.readthedocs.io/en/latest/ +[4]: https://fedoraproject.org/wiki/Releases/Rawhide +[5]: https://fedoraproject.org/wiki/QA:Updates_Testing +[6]: https://flatpak.org/ +[7]: https://docs.fedoraproject.org/en-US/flatpak/tutorial/ +[8]: https://github.com/debarshiray/toolbox +[9]: https://teams.fedoraproject.org/project/silverblue/ diff --git a/published/202004/20190814 9 open source cloud native projects to consider.md b/published/202004/20190814 9 open source cloud native projects to consider.md new file mode 100644 index 0000000000..0c2ffabd03 --- /dev/null +++ b/published/202004/20190814 9 open source cloud native projects to consider.md @@ -0,0 +1,251 @@ +[#]: collector: (lujun9972) +[#]: translator: (messon007) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12135-1.html) +[#]: subject: (9 open source cloud native projects to consider) +[#]: via: (https://opensource.com/article/19/8/cloud-native-projects) +[#]: author: (Bryant Son https://opensource.com/users/brsonhttps://opensource.com/users/marcobravo) + +值得关注的 9 个开源云原生项目 +====== + +> 工作中用了容器?熟悉这些出自云原生计算基金会的项目吗? + +![](https://img.linux.net.cn/data/attachment/album/202004/21/222735oa1wib1wgypoiwpp.jpg) + +随着用容器来开发应用的实践变得流行,[云原生应用][2]也在增长。云原生应用的定义为: + +> “云原生技术用于开发使用打包在容器中的服务所构建的应用程序,以微服务的形式部署,并通过敏捷的 DevOps 流程和持续交付工作流在弹性基础设施上进行管理。” + +这个定义提到了构成云原生应用的不可或缺的四个元素: + + 1. 容器 + 2. 微服务 + 3. DevOps + 4. 持续集成和持续交付 (CI/CD) + +尽管这些技术各有各自独特的历史,但它们之间却相辅相成,在短时间内实现了云原生应用和工具的惊人的指数级增长。这个[云原生计算基金会(CNCF)][4]信息图呈现了当今云原生应用生态的规模和广度。 + +![Cloud-Native Computing Foundation applications ecosystem][5] + +*云原生计算基金会项目* + +我想说,瞧着吧!这仅仅是一个开始。正如 NodeJS 的出现引发了无数的 JavaScript 工具的爆炸式增长一样,容器技术的普及也推动了云原生应用的指数增长。 + +好消息是,有几个组织负责监管并将这些技术连接在一起。 其中之一是 [开放容器倡议][6]Open Containers Initiative(OCI),它是一个轻量级的、开放的治理机构(或项目),“它是在 Linux 基金会的支持下形成的,其明确目的是创建开放的行业标准的容器格式和运行时。” 另一个是 CNCF,它是“一个致力于使云原生计算普及和可持续发展的开源软件基金会”。 + +通常除了围绕云原生应用建立社区之外,CNCF 还帮助项目围绕其云原生应用建立结构化管理。CNCF 创建了成熟等级的概念(沙箱级、孵化级或毕业级),分别与下图中的“创新者”、“早期采用者”和“早期大量应用”相对应。 + +![CNCF project maturity levels][7] + +*CNCF 项目成熟等级* + +CNCF 为每个成熟等级制定了详细的[标准][8](为方便读者而列在下面)。获得技术监督委员会(TOC)三分之二的同意才能转为孵化或毕业级。 + +**沙箱级** + +> 要想成为沙箱级,一个项目必须至少有两个 TOC 赞助商。 有关详细过程,请参见《CNCF 沙箱指南 v1.0》。 + +**孵化级** + +> 注:孵化级是我们期望对项目进行全面的尽职调查的起点。 +> +> 要进入孵化级,项目除了满足沙箱级的要求之外还要满足: +> +> * 证明至少有三个独立的最终用户已成功将其用于生产,且 TOC 判断这些最终用户具有足够的质量和范围。 +> * 提交者的数量要合理。提交者定义为具有提交权的人,即可以接受部分或全部项目贡献的人。 +> * 显示出有大量持续提交和合并贡献。 +> * 由于这些指标可能会根据项目的类型、范围和大小而有很大差异,所以 TOC 有权决定是否满足这些标准的活动水平。 + +**毕业级** + +> 要从沙箱或孵化级毕业,或者要使一个新项目作为已毕业项目加入,项目除了必须满足孵化级的标准外还要满足: +> +> * 至少有两个来自组织的提交者。 +> * 已获得并保持了“核心基础设施计划最佳实践徽章”。 +> * 已完成独立的第三方安全审核,并发布了具有与以下示例类似的范围和质量的结果(包括已解决的关键漏洞):,并在毕业之前需要解决所有关键的漏洞。 +> * 采用《CNCF 行为准则》。 +> * 明确规定项目治理和提交流程。最好将其列在 `GOVERNANCE.md` 文件中,并引用显示当前提交者和荣誉提交者的 `OWNERS.md` 文件。 +> * 至少有一个主仓的项目采用者的公开列表(例如,`ADOPTERS.md` 或项目网站上的徽标)。 +> * 获得 TOC 的绝大多数票,进入毕业阶段。如果项目能够表现出足够的成熟度,则可以尝试直接从沙箱级过渡到毕业级。项目可以无限期保持孵化状态,但是通常预计它们会在两年内毕业。 + +### 值得关注的 9 个项目 + +本文不可能涵盖所有的 CNCF 项目,我将介绍最有趣的 9 个毕业和孵化的开源项目。 + +名称|授权类型|简要描述 +---|---|--- +[Kubernetes][9] | Apache 2.0 | 容器编排平台 +[Prometheus][10] | Apache 2.0 | 系统和服务监控工具 +[Envoy][11] | Apache 2.0 | 边缘和服务代理 +[rkt][12] | Apache 2.0 | Pod 原生的容器引擎 +[Jaeger][13] | Apache 2.0 | 分布式跟踪系统 +[Linkerd][14] | Apache 2.0 | 透明服务网格 +[Helm][15] | Apache 2.0 | Kubernetes 包管理器 +[Etcd][16] | Apache 2.0 | 分布式键值存储 +[CRI-O][17] | Apache 2.0 | 专门用于 Kubernetes 的轻量级运行时环境 + +我也创建了视频材料来介绍这些项目。 + +- [video](https://youtu.be/3cDxYO2GK4w) + +### 毕业项目 + +毕业的项目被认为是成熟的,已被许多组织采用的,并且严格遵守了 CNCF 的准则。以下是三个最受欢迎的开源 CNCF 毕业项目。(请注意,其中一些描述来源于项目的网站并被做了改编。) + +#### Kubernetes(希腊语“舵手”) + +Kubernetes! 说起云原生应用,怎么能不提 Kubernetes 呢? Google 发明的 Kubernetes 无疑是最著名的基于容器的应用程序的容器编排平台,而且它还是一个开源工具。 + +什么是容器编排平台?通常,一个容器引擎本身可以管理几个容器。但是,当你谈论数千个容器和数百个服务时,管理这些容器变得非常复杂。这就是容器编排引擎的用武之地。容器编排引擎通过自动化容器的部署、管理、网络和可用性来帮助管理大量的容器。 + +Docker Swarm 和 Mesosphere Marathon 也是容器编排引擎,但是可以肯定地说,Kubernetes 已经赢得了这场比赛(至少现在是这样)。Kubernetes 还催生了像 [OKD][18] 这样的容器即服务(CaaS)平台,它是 Kubernetes 的 Origin 社区发行版,并成了 [Red Hat OpenShift][19] 的一部分。 + +想开始学习,请访问 [Kubernetes GitHub 仓库][9],并从 [Kubernetes 文档][20]页面访问其文档和学习资源。 + +#### Prometheus(普罗米修斯) + +Prometheus 是 2012 年在 SoundCloud 上构建的一个开源的系统监控和告警工具。之后,许多公司和组织都采用了 Prometheus,并且该项目拥有非常活跃的开发者和用户群体。现在,它已经成为一个独立的开源项目,独立于公司之外进行维护。 + +![Prometheus’ architecture][21] + +*Prometheus 的架构* + +理解 Prometheus 的最简单方法是可视化一个生产系统,该系统需要 24(小时)x 365(天)都可以正常运行。没有哪个系统是完美的,也有减少故障的技术(称为容错系统),但是,如果出现问题,最重要的是尽快发现问题。这就是像 Prometheus 这样的监控工具的用武之地。Prometheus 不仅仅是一个容器监控工具,但它在云原生应用公司中最受欢迎。此外,其他开源监视工具,包括 [Grafana][22],都借助了 Prometheus。 + +开始使用 Prometheus 的最佳方法是下载其 [GitHub 仓库][10]。在本地运行 Prometheus 很容易,但是你需要安装一个容器引擎。你可以在 [Prometheus 网站][23]上查看详细的文档。 + +#### Envoy(使者) + +Envoy(或 Envoy 代理)是专为云原生应用设计的开源的边缘代理和服务代理。由 Lyft 创建的 Envoy 是为单一服务和应用而设计的高性能的 C++ 开发的分布式代理,同时也是为由大量微服务组成的服务网格架构而设计的通信总线和通用数据平面。Envoy 建立在 Nginx、HAProxy、硬件负载均衡器和云负载均衡器等解决方案的基础上,Envoy 与每个应用相伴(并行)运行,并通过提供平台无关的方式提供通用特性来抽象网络。 + +当基础设施中的所有服务流量都经过 Envoy 网格时,很容易就可以通过一致的可观测性来可视化问题域,调整整体性能,并在单个位置添加基础功能。基本上,Envoy 代理是一个可帮助组织为生产环境构建容错系统的服务网格工具。 + +服务网格应用有很多替代方案,例如 Uber 的 [Linkerd][24](下面会讨论)和 [Istio][25]。Istio 通过将其部署为 [Sidecar][26] 并利用了 [Mixer][27] 的配置模型,实现了对 Envoy 的扩展。Envoy 的显著特性有: + +* 包括所有的“入场筹码table stakes(LCTT 译注:引申为基础必备特性)”特性(与 Istio 这样的控制平面组合时) +* 带载运行时 99% 数据可达到低延时 +* 可以作为核心的 L3/L4 过滤器,提供了开箱即用的 L7 过滤器 +* 支持 gRPC 和 HTTP/2(上行/下行) +* 由 API 驱动,并支持动态配置和热重载 +* 重点关注指标收集、跟踪和整体可监测性 + +要想了解 Envoy,证实其能力并实现其全部优势,需要丰富的生产级环境运行的经验。你可以在其[详细文档][28]或访问其 [GitHub][11] 仓库了解更多信息。 + +### 孵化项目 + +下面是六个最流行的开源的 CNCF 孵化项目。 + +#### rkt(火箭) + +rkt, 读作“rocket”,是一个 Pod 原生的容器引擎。它有一个命令行接口用来在 Linux 上运行容器。从某种意义上讲,它和其他容器如 [Podman][29]、Docker 和 CRI-O 相似。 + +rkt 最初是由 CoreOS (后来被 Red Hat 收购)开发的,你可以在其网站上找到详细的[文档][30],以及在 [GitHub][12] 上访问其源代码。 + +#### Jaeger(贼鸥) + +Jaeger 是一个开源的端到端的分布式追踪系统,适用于云端应用。在某种程度上,它是像 Prometheus 这样的监控解决方案。但它有所不同,因为其使用场景有所扩展: + +* 分布式事务监控 +* 性能和延时优化 +* 根因分析 +* 服务依赖性分析 +* 分布式上下文传播 + +Jaeger 是一项 Uber 打造的开源技术。你可以在其网站上找到[详细文档][31],以及在 [GitHub][13] 上找到其源码。 + +#### Linkerd + +像创建 Envoy 代理的 Lyft 一样,Uber 开发了 Linkerd 开源解决方案用于生产级的服务维护。在某些方面,Linkerd 就像 Envoy 一样,因为两者都是服务网格工具,旨在提供平台级的可观测性、可靠性和安全性,而无需进行配置或代码更改。 + +但是,两者之间存在一些细微的差异。 尽管 Envoy 和 Linkerd 充当代理并可以通过所连接的服务进行上报,但是 Envoy 并不像 Linkerd 那样被设计为 Kubernetes Ingress 控制器。Linkerd 的显著特点包括: + +* 支持多种平台(Docker、Kubernetes、DC/OS、Amazon ECS 或任何独立的机器) +* 内置服务发现抽象,可以将多个系统联合在一起 +* 支持 gRPC、HTTP/2 和 HTTP/1.x请 求和所有的 TCP 流量 + +你可以在 [Linkerd 网站][32]上阅读有关它的更多信息,并在 [GitHub][14] 上访问其源码。 + +#### Helm(舵轮) + +Helm 基本上就是 Kubernetes 的包管理器。如果你使用过 Apache Maven、Maven Nexus 或类似的服务,你就会理解 Helm 的作用。Helm 可帮助你管理 Kubernetes 应用程序。它使用“Helm Chart”来定义、安装和升级最复杂的 Kubernetes 应用程序。Helm 并不是实现此功能的唯一方法;另一个流行的概念是 [Kubernetes Operators][33],它被 Red Hat OpenShift 4 所使用。 + +你可以按照其文档中的[快速开始指南][34]或 [GitHub 指南][15]来试用 Helm。 + +#### Etcd + +Etcd 是一个分布式的、可靠的键值存储,用于存储分布式系统中最关键的数据。其主要特性有: + +* 定义明确的、面向用户的 API(gRPC) +* 自动 TLS,可选的客户端证书验证 +* 速度(可达每秒 10,000 次写入) +* 可靠性(使用 Raft 实现分布式) + +Etcd 是 Kubernetes 和许多其他技术的默认的内置数据存储方案。也就是说,它很少独立运行或作为单独的服务运行;相反,它以集成到 Kubernetes、OKD/OpenShift 或其他服务中的形式来运作。还有一个 [etcd Operator][35] 可以用来管理其生命周期并解锁其 API 管理功能: + +你可以在 [etcd 文档][36]中了解更多信息,并在 [GitHub][16]上访问其源码。 + +#### CRI-O + +CRI-O 是 Kubernetes 运行时接口的 OCI 兼容实现。CRI-O 用于各种功能,包括: + +* 使用 runc(或遵从 OCI 运行时规范的任何实现)和 OCI 运行时工具运行 +* 使用容器/镜像进行镜像管理 +* 使用容器/存储来存储和管理镜像层 +* 通过容器网络接口(CNI)来提供网络支持 + +CRI-O 提供了大量的[文档][37],包括指南、教程、文章,甚至播客,你还可以访问其 [GitHub 页面][17]。 + +我错过了其他有趣且开源的云原生项目吗?请在评论中提醒我。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/cloud-native-projects + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brsonhttps://opensource.com/users/marcobravo +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003601_05_mech_osyearbook2016_cloud_cc.png?itok=XSV7yR9e (clouds in the sky with blue pattern) +[2]: https://opensource.com/article/18/7/what-are-cloud-native-apps +[3]: https://thenewstack.io/10-key-attributes-of-cloud-native-applications/ +[4]: https://www.cncf.io +[5]: https://opensource.com/sites/default/files/uploads/cncf_1.jpg (Cloud-Native Computing Foundation applications ecosystem) +[6]: https://www.opencontainers.org +[7]: https://opensource.com/sites/default/files/uploads/cncf_2.jpg (CNCF project maturity levels) +[8]: https://github.com/cncf/toc/blob/master/process/graduation_criteria.adoc +[9]: https://github.com/kubernetes/kubernetes +[10]: https://github.com/prometheus/prometheus +[11]: https://github.com/envoyproxy/envoy +[12]: https://github.com/rkt/rkt +[13]: https://github.com/jaegertracing/jaeger +[14]: https://github.com/linkerd/linkerd +[15]: https://github.com/helm/helm +[16]: https://github.com/etcd-io/etcd +[17]: https://github.com/cri-o/cri-o +[18]: https://www.okd.io/ +[19]: https://www.openshift.com +[20]: https://kubernetes.io/docs/home +[21]: https://opensource.com/sites/default/files/uploads/cncf_3.jpg (Prometheus’ architecture) +[22]: https://grafana.com +[23]: https://prometheus.io/docs/introduction/overview +[24]: https://linkerd.io/ +[25]: https://istio.io/ +[26]: https://istio.io/docs/reference/config/networking/v1alpha3/sidecar +[27]: https://istio.io/docs/reference/config/policy-and-telemetry +[28]: https://www.envoyproxy.io/docs/envoy/latest +[29]: https://podman.io +[30]: https://coreos.com/rkt/docs/latest +[31]: https://www.jaegertracing.io/docs/1.13 +[32]: https://linkerd.io/2/overview +[33]: https://coreos.com/operators +[34]: https://helm.sh/docs +[35]: https://github.com/coreos/etcd-operator +[36]: https://etcd.io/docs/v3.3.12 +[37]: https://github.com/cri-o/cri-o/blob/master/awesome.md diff --git a/published/202004/20190822 How the Linux desktop has grown.md b/published/202004/20190822 How the Linux desktop has grown.md new file mode 100644 index 0000000000..0bfb102dd6 --- /dev/null +++ b/published/202004/20190822 How the Linux desktop has grown.md @@ -0,0 +1,185 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12068-1.html) +[#]: subject: (How the Linux desktop has grown) +[#]: via: (https://opensource.com/article/19/8/how-linux-desktop-grown) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) + +Linux 桌面史话 +====== + +> 自 20 世纪 90 年代初以来,Linux 桌面已从一个简单的窗口管理器发展为一个完整的桌面。让我们一起来回顾一下 Linux 桌面的历史。 + +![](https://img.linux.net.cn/data/attachment/album/202004/03/142430kei55auvvv254aka.jpg) + +我第一次安装 Linux 是在 1993 年。那时,安装这种操作系统没有太多的选择。早期,许多人只是从别人那里复制一个运行中的镜像。然后有人有了一个很好的想法,创建一个 Linux 的“发行版”,让你可以自定义要安装的软件。这就是 Softlanding Linux 系统(SLS),也是我首次接触 Linux。 + +当时我的 386 PC 虽然内存不多,但已经足够了。SLS 1.03 需要 2MB 的内存才能运行,如果要编译程序,则需要 4MB 的内存。如果要运行 X 窗口系统,则需要多达 8MB 的内存!而我的电脑正好有足够的内存来运行 X 窗口系统。 + +因为我是在命令行中成长的,所以图形化的用户界面对我来说并不重要,但它确实很方便,我可以在不同的窗口中运行应用程序,并在任务间轻松切换。 + +从我第一次尝试 Linux 开始,我就迷上了它。从那以后,我一直在台式机上使用 Linux。和许多人一样,我也曾有一段时间以双引导配置运行 Linux,这样我就可以跳回到 MS-DOS 和 Windows 来运行某些程序。直到 1998 年,我终于冒了个险,全面投身于 Linux 之中。 + +在过去的 26 年中,我看着 Linux 桌面逐渐成熟。在这段时间里,我还尝试了各种有趣的桌面环境,下面我来分享一下 Linux 桌面的历史。 + +### X 和窗口管理器 + +Linux 上的第一个“桌面”还不是桌面。相反,它们是运行在 X 窗口系统上的“窗口管理器window manager”(WM)。X 提供了图形用户界面的基本构件,比如在屏幕上创建窗口,并提供键盘和鼠标输入。就其本身而言,X 的用处并不大。为了使 X 图形环境变得有用,你需要一种方法来管理会话中的所有窗口。这就出现了窗口管理器window manager。运行 xterm 或 xclock 之类的 X 程序就会在一个窗口中打开该程序。窗口管理器可以跟踪窗口并进行基本的内部管理,例如让你可以来回移动窗口并将其最小化。其余的事情取决于你自己。你可以通过将程序名列在 `~/.xinitrc` 文件中以在 X 开始时启动这些程序,但是通常,你会从 xterm 中运行新程序。 + +在 1993 年,最常见的窗口管理器是 TWM,它的历史可以追溯到 1988 年。TWM 相当简单,仅仅提供了基本的窗口管理功能。 + +![TWM on SLS 1.05][2] + +*SLS 1.05 上的 TWM,显示了 xterm、xclock 和 Emacs 编辑器* + +另一个早期的窗口管理器是 OpenLook 虚拟窗口管理器(OLVWM)。OpenLook 是 Sun 微系统公司在 20世纪 80 年代开发的图形用户界面,后来被移植到其它 Unix 平台。作为一个*虚拟*窗口管理器,OLVWM 支持多个工作区。 + +![OLVWM on SLS 1.05][3] + +*SLS 1.05 上的 OLVWM,显示了 xterm 和虚拟工作区选择器* + +当 Linux 开始流行起来的时候,没多久就有人创建出性能更流畅、界面更好的新窗口管理器。这些新的窗口管理器中首先出现的是虚拟窗口管理器 FVWM。FVWM 比 TWM 或 OLVWM 更具现代感。但是,我们仍然没有桌面。 + +![FVWM on SLS 1.05][4] + +*SLS 1.05 上的 FVWM,显示了 xterm 和文件管理器* + +以现代的眼光来看,TWM 和 FVWM 可能看起来很朴素。但重要的是要想想当时其它图形环境是什么样子。 Windows 当时的版本看起来也相当简单。Windows 版本 1 到版本 3 使用了一个称为“程序管理器”的普通启动器。 + +![Windows 3.11][5] + +*Windows 3.11,显示程序管理器和记事本编辑器* + +1995 年 8 月,微软发布了 Windows 95,改变了现代 PC 桌面的格局。当然,我当时对此印象很深刻。我曾觉得 Windows 3.x 笨拙而丑陋,但 Windows 95 却流畅而漂亮。更重要的是,我们现在将 Windows 95 视为“**桌面**”。新的“桌面”隐喻是一个巨大的进步。你可以在桌面上放置图标——事实上,Windows 95 提供了两个默认的桌面图标,分别是“我的电脑”(用于打开文件管理器)和“回收站”(用于放置以后要删除的文件)。 + +但是,更重要的是,Windows 95 桌面的意味着*整合*。程序管理器不见了,取而代之的是屏幕底部的任务栏,可让你使用更简单的“开始”菜单启动新程序。任务栏是多功能的,还通过一系列的按钮显示了你正在运行的程序,而托盘显示了时间、扬声器音量和其它简单的控件。你可以在这个新桌面上右键单击任何对象, Windows 95 会为你提供一个上下文相关的菜单,其中又你可以执行的操作。 + +![Windows 95][6] + +*Windows 95,显示了记事本编辑器* + +与以前版本的 Windows 甚至其它 Linux 窗口管理器相比,Windows 95 的界面更加流畅并且易于使用。值得一提的是,Linux 开发人员创建了一个模仿 Windows 95 界面的 FVWM 的新版本。名为 FVWM95 的新窗口管理器仍然不是桌面,但它看起来非常漂亮。新的任务栏让你可以使用“开始”菜单启动新的 X 程序。任务栏还可以使用类似于 Windows 95 的按钮显示了正在运行的程序。 + +![FVWM95 on Red Hat Linux 5.2][7] + +*在 Red Hat Linux 5.2 上的 FVWM95,显示了 xterm 和一个带有 xterm 图标、文件管理器和其他程序的快速访问程序启动器* + +虽然 FVWM95 和其他窗口管理器都在改进,但核心问题仍然存在:Linux 并没有真正的桌面。它具有一堆窗口管理器,仅此而已。使用图形用户界面的 Linux 应用程序(基本上意味着它们是 X 应用程序)看起来形态各异且工作方式也不同。除了 X 窗口系统提供的简单的纯文本复制/粘贴功能外,你不能从一个应用程序复制和粘贴到另一个应用程序里。Linux 真正需要的是在其图形用户界面中进行彻底的重新打造,以创建它的第一个桌面。 + +### Linux 桌面之初啼 + +在 1996 年,Matthias Ettrich 有感于 X 之下 Linux 应用程序体验不一致的困扰。他想使找个更易于使用的图形环境,而且更重要的是,他想让所有东西都“集成”在一起,就像真正的桌面一样。 + +Matthias 开始了K 桌面环境K Desktop Environment(KDE)的工作。那个 K 代表着 “Kool”(LCTT 译注:即 Cool)。但是 KDE 这个名字也意味着可以类似通用桌面环境Common Desktop Environment(CDE)的做法,而 CDE 是“大 Unix”世界的标准。尽管到了 1996 年,CDE 看起来已经有点过时了。CDE 基于 Motif 部件集,这也是 FVWM 所模仿的设计。KDE 1.0 于 1998 年 7 月完成,与 FVWM95 等普通窗口管理器相比,它有了明显改进。 + +![KDE 1.0][8] + +*K 桌面环境(KDE)版本 1.0。图片来源:Paul Brown / KDE* + +KDE 是 Linux 向前迈出的一大步。最终,Linux 有了一个真正的桌面,集成了应用程序和更多现代的桌面图标。KDE 的设计与 Windows 95 并无不同。屏幕底部有一个任务栏,它提供了相当于 Windows 95 的“开始”菜单以及一些应用程序的快捷键。KDE 还支持虚拟桌面,这些桌面被巧妙地标记为 “One”、“ Two”、“Three” 和 “Four”。正在运行的应用程序通过位于屏幕顶部单独的任务栏的按钮表示。 + +但并不是每个人都对 KDE 感到满意。为了将 GUI 从系统中抽象出来,KDE 使用了 Trolltech 的 Qt 工具套件库。不幸的是,Qt 并不是以自由软件的许可证进行分发的。Trolltech 允许 Qt 在自由软件应用程序中免费使用,但在商业或专有应用程序中要收取使用费。而且这种二分法与自由软件不符。这给 Linux 发行版带来了问题:它们应该包括 KDE 吗?还是默认使用 FVWM 这样老式但属于自由软件的图形用户界面? + +面对这种情况,Miguel de Icaza 和 Federico Mena 于 1997 年开始开发新的 Linux 桌面上。这个新项目被称为 GNOME,即GNU 网络对象模型环境GNU Network Object Model Environment的缩写。GNOME 旨在成为一个完全自由的软件,并使用了一个不同的工具套件库 —— 来自 GIMP 图像编辑器的 GTK。GTK 从字面上的意思 GIMP 工具套件GIMP Tool Kit。当 GNOME 1.0 终于在 1999 年发布时,Linux 又多了一个现代化的桌面环境。 + +![GNOME 1.0][9] + +*GNOME 1.0 版。图片来源:GNOME 文档项目* + +有两个 Linux 桌面环境固然很棒,但“KDE 与 GNOME”之争仍持续了一段时间。到了 1999 年,Trolltech 以新的公共许可证 Q 公共许可证Q Public License(QPL)重新发布了 Qt 库。但是,新许可证有其自身的包袱—-QPL 仅适用于 Qt 在开源软件项目中的使用,而不适用于商业项目。因此,自由软件基金会Free Software Foundation(FSF)认为 QPL 与 GNU 通用公共许可证GNU General Public License(GNU GPL)[不兼容][10]。这个许可证问题一直持续到 2000 年 Trolltech 在 GNU GPL v2 下重新发布 Qt 库。 + +### 随着时间的发展 + +Linux 桌面继续走向成熟。KDE 和 GNOME 进行了一场友好的竞争,促使双方都在增加了新的功能,还互相交流了思想和观念。到了 2004 年,GNOME 和 KDE 都取得了长足的进步,但只是给用户界面带来了渐进式的变化。 + +KDE 2 和 3 继续依赖屏幕底部的任务栏概念,但并入了用于运行应用程序的按钮。KDE 最明显的变化之一是添加了 Konqueror 浏览器,该浏览器首次出现在 KDE 2 中。 + +![KDE 2.2.2 \(2001\) showing the Konqueror browser][11] + +*KDE 2.2.2(2001),显示了 Konqueror 浏览器。图片来源:Paul Brown / KDE* + +![KDE 3.2.2][12] + +*Fedora Core 2 上的 KDE 3.2.2(2004),显示了 Konqueror 文件管理器(使用 Fedora Core 2 主题)* + +GNOME 2 也使用了任务栏概念,但将任务栏一分为二:屏幕顶部的任务栏用于启动应用程序并响应桌面提示,屏幕底部的任务栏用于显示正在运行的应用程序。我把这两个任务栏称之为“你可以做的事情”(顶部)和“你正在做的事情”(底部)。除了精简的用户界面外,GNOME 还添加了由 Eazel 开发的更新过的文件管理器,名为 Nautilus。 + +![GNOME 2.6.0][13] + +*Fedora Core 2 上的 GNOME 2.6.0(2004),显示了 Nautilus 文件管理器(使用 Fedora Core 2 主题)* + +随着时间的流逝,KDE 和 GNOME 走了不同的道路。两者都提供了功能丰富、健壮且现代化的桌面环境,但是却具有不同的用户界面目标。2011 年,GNOME 和 KDE 在桌面界面上出现了很大的偏差。KDE 4.6(2011 年 1 月)和 KDE 4.7(2011 年 7 月)提供了更传统的桌面感受,同时继续根植于许多用户熟悉的任务栏概念。当然,KDE 的底层发生很多变化,但是它仍然保留了熟悉的外观。 + +![KDE 4.6][14] + +*KDE 4.6,显示 Gwenview 图像查看器。图片来源:KDE* + +2011 年,GNOME 以一个新的桌面概念彻底改变了走向。GNOME 3 旨在创建一个更简单、更精简的桌面体验,使用户能够专注于自己的工作。任务栏消失了,取而代之的是屏幕顶部的黑色状态栏,其中包括音量和网络控件,显示了时间和电池状态,并允许用户通过重新设计过的菜单启动新程序。 + +菜单的变化最具最戏剧性。单击“活动”菜单或将鼠标移到“活动”的“热角”,所有打开的应用程序会显示为单独的窗口。用户还可以从“概述”中单击“应用程序”选项卡以启动新程序。“概述”还提供了一个内部集成的搜索功能。 + +![GNOME 3.0][15] + +*GNOME 3.0,显示 GNOME 图片应用程序。图片来源:GNOME* + +![GNOME 3.0][16] + +*GNOME 3.0,显示活动概述。图片来源:GNOME* + +### 你的桌面之选 + +拥有两个 Linux 桌面意味着用户有很大的选择余地。有些人喜欢 KDE,而另一些人喜欢 GNOME。没关系,选择最适合你的桌面就行。 + +可以肯定的是,KDE 和 GNOME 都有拥护者和批评者。例如,GNOME 因为放弃任务栏而改成“活动概述”而受到了不少批评。也许最著名的批评者是 Linus Torvalds,他在 2011 年[大声斥责并抛弃了][17]新的 GNOME,将其视为“邪恶的烂摊子”,然后在两年后又[回到了][18] GNOME。 + +其他人也对 GNOME 3 提出了类似的批评,以至于一些开发人员复刻 GNOME 2 的源代码创建了 MATE 桌面。MATE(是MATE 高级传统环境MATE Advanced Traditional Environment的递归缩写)延续了 GNOME 2 的传统任务栏界面。 + +无论如何,毫无疑问当今两个最受欢迎的 Linux 桌面是 KDE 和 GNOME。它们的当前版本非常成熟,功能也很丰富。KDE 5.16(2019)和 GNOME 3.32(2019)都试图简化和精简 Linux 桌面体验,但是方式有所不同。GNOME 3.32 继续致力于极简外观,删除所有分散用户注意力的用户界面元素,以便用户可以专注于其应用程序和工作。KDE 5.16 采用了更为熟悉的任务栏方法,但也增加了其他视觉上的改进和亮点,尤其是改进的小部件处理和图标。 + +![KDE 5.16 Plasma][19] + +*KDE 5.16 Plasma。图片来源:KDE* + +![GNOME 3.32][20] + +*GNOME 3.32。图片来源:GNOME* + +同时,你也不会完全失去它们之间的兼容性。每个主要的 Linux 发行版都提供了兼容性库,因此你可以在运行 GNOME 的同时来运行 KDE 应用程序。当你真正想使用的应用程序是为其他桌面环境编写的,这一点非常有用。你可以在 GNOME 上运行 KDE 应用程序,反之亦然。 + +我认为这种态势不会很快改变,这是一件好事。KDE 和 GNOME 之间的良性竞争使这两个阵营的开发人员可以避免故步自封。无论你使用 KDE 还是 GNOME,你都将拥有一个集成度很高的现代化桌面。而最重要的是,这意味着 Linux 拥有自由软件最好的特点:选择。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/how-linux-desktop-grown + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hallhttps://opensource.com/users/jason-bakerhttps://opensource.com/users/jlacroixhttps://opensource.com/users/doni08521059https://opensource.com/users/etc-eterahttps://opensource.com/users/marcobravohttps://opensource.com/users/alanfdoss +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://opensource.com/sites/default/files/uploads/twm-sls105.png (TWM on SLS 1.05) +[3]: https://opensource.com/sites/default/files/uploads/olvwm-sls105.png (OLVWM on SLS 1.05) +[4]: https://opensource.com/sites/default/files/uploads/fvwm-sls105.png (FVWM on SLS 1.05) +[5]: https://opensource.com/sites/default/files/uploads/win311.png (Windows 3.11) +[6]: https://opensource.com/sites/default/files/uploads/win95.png (Windows 95) +[7]: https://opensource.com/sites/default/files/uploads/fvwm95-rh52.png (FVWM95 on Red Hat Linux 5.2) +[8]: https://opensource.com/sites/default/files/uploads/kde1.png (KDE 1.0) +[9]: https://opensource.com/sites/default/files/uploads/gnome10.png (GNOME 1.0) +[10]: https://www.linuxtoday.com/developer/2000090500121OPLFKE +[11]: https://opensource.com/sites/default/files/uploads/kde_2.2.2.png (KDE 2.2.2 (2001) showing the Konqueror browser) +[12]: https://opensource.com/sites/default/files/uploads/kde322-fc2.png (KDE 3.2.2) +[13]: https://opensource.com/sites/default/files/uploads/gnome26-fc2.png (GNOME 2.6.0) +[14]: https://opensource.com/sites/default/files/uploads/kde46.png (KDE 4.6) +[15]: https://opensource.com/sites/default/files/uploads/gnome30.png (GNOME 3.0) +[16]: https://opensource.com/sites/default/files/uploads/gnome30-overview.png (GNOME 3.0) +[17]: https://www.theregister.co.uk/2011/08/05/linus_slams_gnome_three/ +[18]: https://www.phoronix.com/scan.php?page=news_item&px=MTMxNjc +[19]: https://opensource.com/sites/default/files/uploads/kde516.png (KDE 5.16 Plasma) +[20]: https://opensource.com/sites/default/files/uploads/gnome332.png (GNOME 3.32) diff --git a/published/202004/20191014 How to make a Halloween lantern with Inkscape.md b/published/202004/20191014 How to make a Halloween lantern with Inkscape.md new file mode 100644 index 0000000000..1cd31042d1 --- /dev/null +++ b/published/202004/20191014 How to make a Halloween lantern with Inkscape.md @@ -0,0 +1,155 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12152-1.html) +[#]: subject: (How to make a Halloween lantern with Inkscape) +[#]: via: (https://opensource.com/article/19/10/how-make-halloween-lantern-inkscape) +[#]: author: (Jess Weichler https://opensource.com/users/cyanide-cupcake) + +如何使用 Inkscape 制作万圣节灯笼 +====== + +> 使用开源软件为你最喜欢的万圣节鬼屋制作一个有趣和怪异的装饰品。 + +![万圣节 - 背光飞行的蝙蝠][1] + +使用开源软件装饰一个独一无二的万圣节灯笼! + +通常,灯笼的一部分结构体是不透明的,以阻挡内部的光线。灯笼之所以成为灯笼,是因为其去掉了一些东西 :从结构体上切开的窗口,这样光线就可以射出。虽然对于照明来说不实用,但是一个有着怪异形状窗口和隐藏暗色轮廓的灯笼却可以令人兴奋,并创造出很多乐趣。 + +这篇演示如何使用 [Inkscape][2] 创建你自己的灯笼。如果还没有 Inkscape ,在 Linux 上,你可以从软件库中安装它,在 MacOS 和 Windows 上,你可以从[Inkscape 网站][3] 上下载它. + +### 使用材料 + + * 模板([A4][4] 或[信纸][5]大小) + * 卡片纸(黑色是传统色) + * 描图纸(可选) + * 裁纸刀、尺子、切割垫板(可使用工艺切割机/激光切割机代替) + * 工艺胶 + * LED 茶灯"蜡烛" + +安全注意事项:这个项目只使用电池操作的蜡烛。 + +### 理解模板 + +首先,从上面的链接下载你所在区域(A4 或信纸)的合适的模板,然后在 Inkscape 中打开它。 + +![灯笼模板荧光屏][6] + +灰白色的棋盘格背景是透明的(从技术角度来说,它是 alpha 通道。) + +黑色基板构成了灯笼。现在,没有窗口可以让光线穿过;灯笼有一个非镂空的黑色基板。你将在 Inkscape 中使用**并集**和**差集**选项来数字化的设计窗口。 + +蓝色虚线表示折线。橙色实线表示参考线。采光窗口不应该放在橙色盒子的外面。 + +模板的左侧是你可以在你设计中使用的一些预先制作好的对象。 + +### 创建一个窗口或形状 + +1. 创建一个看起来像你想要的窗口样式的对象。可以使用 Inkscape 左侧工具栏中的一些形状工具来创建对象。此外,你可以下载共创或公共领域的剪贴画,并导入 PNG 文件到你的项目中。 +2. 当你对对象的形状满意时,在顶部菜单中选择“路径” -> “对象转化成路径” 将其转换为一个路径(而不是一个形状,Inkscape 视其为两种不同的对象)。 + + ![对象到路径 菜单][7] + +3. 在基板形状的上面放置对象。 +4. 选择对象和黑色基板。通过先单击一个,并按住 `Shift` 按键,再选择另一个来完成。 +5. 从顶部菜单选择“路径” -> “差集” 来从基板的对象中移除形状。这将创建灯笼中的一个窗口。 + + ![路径 > 差集 菜单][8] + +### 添加对象到窗口中 + +在制作了一个窗口后,你可以添加对象到其中来创建一个场景。 + +提示: + +* 所有的对象,包括文本,必须连接到灯笼的基板,否则,在切割后会掉落下来,并留下一片空白。 +* 避免小而复杂的细微之处。即使使用激光切割机或工艺切割机等机器,也很难切割这些细微之处。 + +1. 创建或导入一个对象。 +2. 放置对象到窗口内,以便它至少接触基板的两侧。 +3. 选择对象后,从顶部菜单选择“连接” -> “对象转化成路径”。 + + ![对象到路径 菜单][9] + +4. 选择对象和黑色基板,通过在按住 `Shift` 按键的同时单击每一个来完成。 +5. 选择“路径” -> “并集”来使对象和基板合二为一。 + +### 添加文本 + +文本既可以从基板剪出文字来创建一个窗口(就像我对星星所做的那样),或者也可以添加到一个窗口上(它可以阻挡来自灯笼内部的光线)。如果你要创建一个窗口,只需要执行下面的步骤 1 和步骤 2,然后使用“差集”来从基板移除文本。 + +1. 从左侧边栏中选择文本工具来创建文本。粗体字体效果最好。 + + ![文本工具][10] + +2. 选择你的文本,然后从顶部菜单选择“路径” -> “对象转化成路径”。这将转换文本对象为一个路径。注意,这个步骤意味着你将不能再编辑该文本,所以,*只有当*你确定你拥有想要的单词后,执行这个步骤。 +3. 在你转换文本后,你可以按键盘上的 `F2` 来激活节点编辑器工具,当选择使用这个工具时,可以清楚地显示文本的节点。 + + ![选中的文本使用节点编辑器][11] + +4. 取消文本分组。 +5. 调整每个字母,以便使其与相邻字母或基板稍微重叠。 + + ![重叠文本][12] + +6. 为将所有的字母彼此连接,并连接到基板,重新选择所有文本和基板,然后选择“路径” -> “并集”。 + + ![使用 路径 > 并集 连接字母和基板][13] + +### 准备打印 + +下面是手工切割灯笼的说明。如果使用激光切割机或工艺切割机,遵循硬件所需要的技巧来准备好你的文件。 + +1. 在“图层”面板中,单击“安全”图层旁边的“眼睛”图标来隐藏安全线。如果你看不到图层面板,通过顶部菜单选择“图层” -> “图层”来显示它。 +2. 选择黑色基板。在“填充和笔划”面板中,设置填充为“X”(意味着*不填充*),设置“笔划”为纯黑色(对于喜欢十六进制的粉丝来说是 `#000000ff` )。 + + ![设置填充和笔划][14] + +3. 使用“文件” -> “打印”来打印你的图案。 +4. 使用一把工艺刀和直尺,小心地绕着每一条黑线切割。在蓝色虚线上轻划,然后折叠。 + + ![裁剪灯笼][15] + +5. 要完成窗口的制作,剪切描图纸为每个窗口的大小,然后粘贴它到灯笼的内侧。 + + ![添加描图纸][16] + +6. 在折条处把灯笼的边粘在一起。 +7. 接通电池供电的 LED 蜡烛,并放置它到你灯笼中。 + + ![完成灯笼][17] + +现在你的灯笼已经完成了,准备好点亮你的鬼屋了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/how-make-halloween-lantern-inkscape + +作者:[Jess Weichler][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://opensource.com/users/cyanide-cupcake +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/halloween_bag_bat_diy.jpg?itok=24M0lX25 (Halloween - backlit bat flying) +[2]: https://opensource.com/article/18/1/inkscape-absolute-beginners +[3]: http://inkscape.org +[4]: https://www.dropbox.com/s/75qzjilg5ak2oj1/papercraft_lantern_A4_template.svg?dl=0 +[5]: https://www.dropbox.com/s/8fswdge49jwx91n/papercraft_lantern_letter_template%20.svg?dl=0 +[6]: https://opensource.com/sites/default/files/uploads/lanterntemplate_screen.png (Lantern template screen) +[7]: https://opensource.com/sites/default/files/uploads/lantern1.png (Object to path menu) +[8]: https://opensource.com/sites/default/files/uploads/lantern2.png (Object > Difference menu) +[9]: https://opensource.com/sites/default/files/uploads/lantern3.png (Object to path menu) +[10]: https://opensource.com/sites/default/files/uploads/lantern4.png (Text tool) +[11]: https://opensource.com/sites/default/files/uploads/lantern5.png (Text selected with Node editor) +[12]: https://opensource.com/sites/default/files/uploads/lantern6.png (Overlapping the text) +[13]: https://opensource.com/sites/default/files/uploads/lantern7.png (Connecting letters and base with Path > Union) +[14]: https://opensource.com/sites/default/files/uploads/lantern8.png (Setting fill and stroke) +[15]: https://opensource.com/sites/default/files/uploads/lantern9.jpg (Cutting out the lantern) +[16]: https://opensource.com/sites/default/files/uploads/lantern10.jpg (Adding tracing paper) +[17]: https://opensource.com/sites/default/files/uploads/lantern11.jpg (Completed lantern) diff --git a/published/202004/20191209 Use the Fluxbox Linux desktop as your window manager.md b/published/202004/20191209 Use the Fluxbox Linux desktop as your window manager.md new file mode 100644 index 0000000000..d3eb78339e --- /dev/null +++ b/published/202004/20191209 Use the Fluxbox Linux desktop as your window manager.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12082-1.html) +[#]: subject: (Use the Fluxbox Linux desktop as your window manager) +[#]: via: (https://opensource.com/article/19/12/fluxbox-linux-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 Fluxbox 桌面作为你的窗口管理器 +====== + +> 本文是 24 天 Linux 桌面特别系列的一部分。Fluxbox 对系统资源的占用非常轻量,但它拥有重要的 Linux 桌面功能,让你的用户体验轻松、高效、快捷。 + +![](https://img.linux.net.cn/data/attachment/album/202004/07/113105p0ng5skkn5kmvdm0.jpg) + +桌面的概念可谓是仁者见仁智者见智。很多人把桌面看作一个家的基地,或者一个舒适的客厅,甚至是一个字面意义上的桌面,在其中放置着他们经常使用的记事本、最好的笔和铅笔,还有他们最喜欢的咖啡杯。KDE、 GNOME、Pantheon 等等在 Linux 上提供了这种舒适的生活方式。 + +但是对一些用户来说,桌面只是一个空荡荡的显示器空间,这是还没有任何可以自由浮动的应用程序窗口直接投射到他们的视网膜上的副作用。对于这些用户来说,桌面是一个空的空间,他们可以在上面运行应用程序 —— 无论是大型办公软件和图形套件,还是一个简单的终端窗口,或是来管理服务的托盘小程序。这种操作 [POSIX][2] 计算机的模式由来已久,该家族树的一支是 *box 窗口管理器:Blackbox、Fluxbox 和 Openbox。 + +[Fluxbox][3] 是一个 X11 系统的窗口管理器,它基于一个较老的名为 Blackbox 的项目。当我发现 Linux 时,Blackbox 的开发已进入衰退期,因此我就喜欢上了 Fluxbox ,此后我至少在一个以上的常用的系统上使用过它。它是用 C++ 编写的,并在 MIT 开源许可证下授权。 + +### 安装 Fluxbox + +你很可能会在你的 Linux 发行版的软件库中找到 Fluxbox,但是你也可以在 [Fluxbox.org][4] 上找到它。如果你正在运行另外一个桌面,在同一个系统上安装 Fluxbox 是安全的,因为 Fluxbox 不会预设任何配置或附带的应用程序。 + +在安装 Fluxbox 后,注销你当前的桌面会话,以便你可以登录一个新的桌面会话。默认情况下,你的桌面会话管理器 (KDM、GDM、LightDM 或 XDM,取决于你的安装设置) 将继续让登录到之前的桌面,所以你在登录前必需要覆盖上一个桌面。 + +使用 GDM 覆盖一个桌面: + +![在 GDM 中选择你的桌面会话][5] + +或者使用 KDM: + +![使用 KDM 选择你的桌面会话][6] + +### 配置 Fluxbox 桌面 + +当你第一次登录到桌面时,屏幕基本是空的,因为 Fluxbox 提供的所有东西是面板(用于任务栏、系统托盘等等)和用于应用程序窗口的窗口装饰品。 + +![在 CentOS 7 上的默认 Fluxbox 配置][7] + +如果你的发行版提供一个简单的 Fluxbox 桌面,你可以使用 `feh` 命令(你可能需要从你的发行版的软件库中安装它)来为你的桌面设置背景。这个命令有几个用于设置背景的选项,包括使用你选择的墙纸来填充屏幕的 `--bg-fill` 选项,来按比例缩放的 `--bg-scale` 等等选项。 + +``` +$ feh --bg-fill ~/photo/oamaru/leaf-spiral.jpg +``` + +![应用主题的 Fluxbox ][8] + +默认情况下,Fluxbox 自动生成一个菜单,在桌面上任意位置右键单击可用该菜单,这给予你访问应用程序的能力。根据你的发行版的不同,这个菜单可能非常小,也可能列出 `/usr/share/applications` 目录中的所有启动程序。 + +Fluxbox 配置是在文本文件中设置的,这些文本文件包含在 `$HOME/.fluxbox` 目录中。你可以: + +* 在 `keys` 中设置键盘快捷键 +* 在 `startup` 中启动的服务和应用程序 +* 在 `init` 设置桌面首选项(例如工作区数量、面板位置等等) +* 在 `menu` 中设置菜单项 + +该文本配置文件非常易于推断,但是你也可以(并且是应该)阅读 Fluxbox 的[文档][9]。 + +例如,这是我的典型菜单(或者说至少有它的基本结构): + +``` +# 为使用你自己的菜单,复制这些文本到 ~/.fluxbox/menu,然后编辑 +# ~/.fluxbox/init ,并更改 session.menuFile 文件路径到 ~/.fluxbox/menu + +[begin] (fluxkbox) + [submenu] (apps) {} + [submenu] (txt) {} + [exec] (Emacs 23 (text\)) { x-terminal-emulator -T "Emacs (text)" -e /usr/bin/emacs -nw} <> + [exec] (Emacs (X11\)) {/usr/bin/emacs} <> + [exec] (LibreOffice) {/usr/bin/libreoffice} + [end] + [submenu] (code) {} + [exec] (qtCreator) {/usr/bin/qtcreator} + [exec] (eclipse) {/usr/bin/eclipse} + [end] + [submenu] (graphics) {} + [exec] (ksnapshot) {/usr/bin/ksnapshot} + [exec] (gimp) {/usr/bin/gimp} + [exec] (blender) {/usr/bin/blender} + [end] + [submenu] (files) {} + [exec] (dolphin) {/usr/bin/dolphin} + [exec] (konqueror) { /usr/bin/kfmclient openURL $HOME } + [end] + [submenu] (network) {} + [exec] (firefox) {/usr/bin/firefox} + [exec] (konqueror) {/usr/bin/konqueror} + [end] + [end] +## 更改窗口管理器或工作环境 +[submenu] (environments) {} + [restart] (flux) {/usr/bin/startfluxbox} + [restart] (ratpoison) {/usr/bin/ratpoison} + [exec] (openIndiana) {/home/kenlon/qemu/startSolaris.sh} +[end] + +[config] (config) + [submenu] (styles) {} + [stylesdir] (/usr/share/fluxbox/styles) + [stylesdir] (~/.fluxbox/styles) + [end] +[workspaces] (workspaces) +[reconfig] (reconfigure) +[restart] (restart) +[exit] (exeunt) +[end] +``` + +该菜单也提供一些首选项设置,例如,选择一个主题,从 Fluxbox 会话中重启或注销的能力。 + +我使用键盘快捷键来启动大多数的应用程序,这些快捷键写入到 `keys` 配置文件中。这里有一些示例(`Mod4` 按键是 `Super` 键,我使用其来指定全局快捷键): + +``` +# 打开应用程序 +Mod4 t :Exec konsole +Mod4 k :Exec konqueror +Mod4 z :Exec fbrun +Mod4 e :Exec emacs +Mod4 f :Exec firefox +Mod4 x :Exec urxvt +Mod4 d :Exec dolphin +Mod4 q :Exec xscreensaver-command -activate +Mod4 3 :Exec ksnapshot +``` + +在这些快捷方式和一个打开的终端之间,在我工作日的大部分时间内很少使用鼠标,因此从一个控制器切换到另一个控制器不会浪费时间。并且因为 Fluxbox 很好地避开了控制器之间切换的方法,因此在其中操作没有一丝干扰。 + +### 为什么你应该使用 Fluxbox + +Fluxbox 对系统资源的占用非常轻量,但是它拥有重要的功能,可以使你的用户体验轻松、快速、高效。它很容易定制,并且允许你定义你自己的工作流。你不必使用 Fluxbox 的面板,因为还有其它优秀的面板。你甚至可以鼠标中键点击并拖动两个独立的应用程序窗口到彼此之中,以便它们成为一个窗口,每个窗口都有自己的选项卡。 + +可能性是无穷的,所以今天就在你的 Linux 上尝试一下 Fluxbox 的简单稳定吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/fluxbox-linux-desktop + +作者:[Seth Kenlon][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://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue) +[2]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[3]: http://fluxbox.org +[4]: http://fluxbox.org/download/ +[5]: https://opensource.com/sites/default/files/advent-gdm_0.jpg (Select your desktop session in GDM) +[6]: https://opensource.com/sites/default/files/advent-kdm.jpg (Select your desktop session with KDM) +[7]: https://opensource.com/sites/default/files/advent-fluxbox-default.jpg (Default Fluxbox configuration on CentOS 7) +[8]: https://opensource.com/sites/default/files/advent-fluxbox-green.jpg (Fluxbox with a theme applied) +[9]: http://fluxbox.org/features/ diff --git a/published/202004/20191216 Relive Linux history with the ROX desktop.md b/published/202004/20191216 Relive Linux history with the ROX desktop.md new file mode 100644 index 0000000000..72c2993473 --- /dev/null +++ b/published/202004/20191216 Relive Linux history with the ROX desktop.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12123-1.html) +[#]: subject: (Relive Linux history with the ROX desktop) +[#]: via: (https://opensource.com/article/19/12/linux-rox-desktop) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +用 ROX 桌面重温 Linux 历史 +====== + +> 这篇文章是 Linux 桌面 24 天特别系列的一部分。如果你想来一次有趣的时光之旅,ROX 桌面非常值得一试。 + +![](https://img.linux.net.cn/data/attachment/album/202004/18/151533n196wag64gwhs0ga.jpg) + +[ROX][2] 桌面已经不再积极开发,而它的遗留问题至今仍然存在,但即使在它活跃开发的时候,它也是一个另类的 Linux 桌面。当其他的桌面感觉与旧式的 Unix 或 Windows 界面大致相似时,ROX 则属于 BeOS、AmigaOS 和 [RISC OS][3] 桌面阵营。 + +它专注于拖放式操作(这使得它的可访问性对某些用户来说并不理想)、点击式操作、弹出式上下文菜单,以及一个独特的应用程序目录系统,无需安装即可运行本地应用程序。 + +### 安装 ROX + +如今,ROX 基本上都被遗弃了,只剩下一点残渣碎片留给用户自己去收集整理。幸运的是,这个难题相对来说比较容易解决,但是当你在发行版的软件仓库中找到 ROX 桌面的碎片时,不要被迷惑了,因为那并不是 ROX 桌面全部的碎片。ROX 常用的部分 —— 文件管理器([ROX-Filer][4])和终端([ROXTerm][5]) —— 似乎在大多数流行的发行版软件仓库中都有存在,你可以将它们作为独立的应用程序安装(并使用)。然而,要运行 ROX 桌面,你必须同时安装 ROX-Session 和它所依赖的库。 + +我在 Slackware 14.2 上安装了 ROX,但它应该可以在任何 Linux 或 BSD 系统上运行。 + +首先,你必须从其版本库中安装 [ROX-lib2][6]。你要安装 ROX-lib2,按照它的理念,只需下载tarball、[解压][7],然后将 `ROX-lib` 目录移动到 `/usr/local/lib` 下就行。 + +接下来,你要安装 [ROX-Session][8]。这可能需要从源码中编译,因为它很可能不在你的软件仓库中。编译过程需要编译工具,这些工具在 Slackware 上是默认提供的,但在其他发行版中往往会被省略,以节省初始下载空间。根据你的发行版不同,你必须安装的包的名称也不同,所以请参考文档来了解具体内容。例如,在 Debian 发行版中,你可以在 [Debian 的 wiki][9] 中了解构建需求,而在 Fedora 发行版中,请参考 [Fedora 的文档][10]。安装了构建工具后,执行自定义的 ROX-Session 构建脚本。 + +``` +$ ./AppRun +``` + +这个脚本会自己管理构建和安装,并提示你需要 root 权限,以在你的登录屏上将其添加为一个选项。 + +如果你还没有从你的软件库中安装 ROX-Filer,请在继续之前安装。 + +这些组件共同组成了一个完整的 ROX 桌面。要登录到新桌面,请从当前桌面会话中注销。默认情况下,你的会话管理器(KDM、GDM、LightDM 或 XDM,视你的设置而定)会继续登录到你之前的桌面,所以在登录前必须覆盖。 + +使用 SDDM: + +![][11] + +使用 GDM: + +![][12] + +### ROX 桌面特性 + +ROX 桌面默认情况下很简单,屏幕底部有一个面板,桌面上有一个通往主目录的快捷方式图标。面板中包含了一些常用位置的快捷方式。这就是 ROX 桌面的全部功能,至少在安装后就是这样。如果你想要时钟、日历或系统托盘,你需要找到提供这些功能的应用程序。 + +![Default ROX desktop][13] + +虽然没有任务栏,但当你将窗口最小化时,它就会成为桌面上的一个临时图标。你可以点击该图标,将其窗口恢复到以前的大小和位置。 + +面板也可以进行一些修改。你可以在其中放置不同的快捷方式,甚至可以创建自己的小程序。 + +它没有应用菜单,也没有上下文菜单中的应用快捷方式。相反,你可以手动导航到 `/usr/share/applications`,或者你可以将你的应用目录或目录添加到 ROX 面板中。 + +![ROX desktop][14] + +ROX 桌面的工作流程集中在鼠标驱动上,让人联想到 Mac OS 7.5 和 8 系统。通过 ROX-filer,你可以管理权限、文件管理、内省introspection、脚本启动、后台设置,以及几乎所有你能想到的东西,只要你有足够的耐心,就可以实现点击式的交互。对于高级用户来说,这似乎很慢,但 ROX 设法让它变得相对无痛,而且非常直观。 + +### 应用程序目录、AppRun 和 AppImage + +ROX 桌面有一个优雅的惯例,按照此惯例,包含一个名为 `AppRun` 的脚本的目录就可以像一个应用程序一样被执行。这意味着,要制作一个 ROX 应用程序,你所要做的就是将代码编译到一个目录中,将一个名为`AppRun` 的脚本放在该目录的根目录下,来执行你所编译的二进制文件,然后将该目录标记为可执行即可。ROX-Filer 会按照你设置的方式来显示一个目录,并以特殊的图标和颜色显示一个目录。当你点击一个应用程序目录,ROX-Filer 会自动运行里面的 `AppRun` 脚本。它的外观和行为就像一个已经安装好的应用程序,但它是在用户的主目录下的本地目录,不需要特殊的权限。 + +这是一个方便的功能,但它是那些你使用时感觉很好的小功能之一,因为它很容易做到。它绝不是必要的,它只是比在本地建立一个应用程序,将目录隐藏在某个不显眼的地方,并建立一个快速的 `.desktop` 文件作为你的启动器,要领先了几步。然而,应用程序目录的概念已经当做灵感被 [AppImage][16] 打包系统所 [借鉴][15]。 + +### 为什么应该试试 ROX 桌面 + +把 ROX 设置好并使用是有些困难的,它似乎真的被抛弃了。然而,它的遗产在今天以多种方式继续存在,它是 Linux 历史上的一段迷人而有趣的历史。它可能不会成为你的主要桌面,但如果你想来一次有趣的回溯之旅,那么 ROX 非常值得一试。探索它、定制它,看看它包含了哪些巧妙的想法。也许还有一些隐藏的宝石可以让开源社区受益。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/linux-rox-desktop + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: http://rox.sourceforge.net/desktop/ +[3]: https://www.riscosopen.org/content/ +[4]: http://rox.sourceforge.net/desktop/ROX-Filer +[5]: http://roxterm.sourceforge.net/ +[6]: http://rox.sourceforge.net/desktop/ROX-Lib +[7]: https://opensource.com/article/17/7/how-unzip-targz-file +[8]: http://rox.sourceforge.net/desktop/ROX-Session.html +[9]: https://wiki.debian.org/BuildingTutorial +[10]: https://docs.pagure.org/docs-fedora/installing-software-from-source.html +[11]: https://opensource.com/sites/default/files/advent-kdm_0.jpg +[12]: https://opensource.com/sites/default/files/advent-gdm_1.jpg +[13]: https://opensource.com/sites/default/files/uploads/advent-rox.jpg (Default ROX desktop) +[14]: https://opensource.com/sites/default/files/uploads/advent-rox-custom.jpg (ROX desktop) +[15]: https://github.com/AppImage/AppImageKit/wiki/AppDir +[16]: https://appimage.org/ diff --git a/published/202004/20191220 The Difference Between DNF and YUM, Why is Yum Replaced by DNF.md b/published/202004/20191220 The Difference Between DNF and YUM, Why is Yum Replaced by DNF.md new file mode 100644 index 0000000000..8521ab4291 --- /dev/null +++ b/published/202004/20191220 The Difference Between DNF and YUM, Why is Yum Replaced by DNF.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12161-1.html) +[#]: subject: (The Difference Between DNF and YUM, Why is Yum Replaced by DNF?) +[#]: via: (https://www.2daygeek.com/comparison-difference-between-dnf-vs-yum/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +DNF 和 Yum 的区别,为什么 Yum 会被 DNF 取代? +====== + +由于 Yum 中许多长期存在的问题仍未得到解决,因此 [Yum 包管理器][1]已被 [DNF 包管理器][2]取代。这些问题包括性能差、内存占用过多、依赖解析速度变慢等。 + +DNF 使用 `libsolv` 进行依赖解析,由 SUSE 开发和维护,旨在提高性能。 + +Yum 主要是用 Python 编写的,它有自己的应对依赖解析的方法。它的 API 没有完整的文档,它的扩展系统只允许 Python 插件。 + +Yum 是 RPM 的前端工具,它管理依赖关系和资源库,然后使用 RPM 来安装、下载和删除包。 + +为什么他们要建立一个新的工具,而不是修复现有的问题呢? + +Ales Kozamblak 解释说,这个修复在技术上是不可行的,而且 Yum 团队还没有准备好立即接受修改。 + +另外,最大的挑战是,Yum 有 56000 行代码,但 DNF 只有 29000 行代码。 + +所以除了分叉,没有办法解决。 + +不过 Yum 的运行情况还算可以。 + + +编号 | DNF(Dandified YUM) | YUM(Yellowdog Updater, Modified) +---|---|--- +1 | DNF 使用 libsolv 来解析依赖关系,由 SUSE 开发和维护 | YUM 使用公开的 API 来解析依赖关系 +2 | API 有完整的文档 | API 没有完整的文档 +3 | 由 C、C++、Python 编写的 | 只用 Python 编写 +4 | DNF 目前在 Fedora、RHEL 8、CentOS 8、OEL 8 和 Mageia 6/7 中使用 | YUM 目前在 RHEL 6/7、CentOS 6/7、OEL 6/7 中使用 +5 | DNF 支持各种扩展 | Yum 只支持基于 Python 的扩展 +6 | API 有良好的文档,因此很容易创建新的功能 | 因为 API 没有正确的文档化,所以创建新功能非常困难 +7 | DNF 在同步存储库的元数据时,使用的内存较少 | 在同步存储库的元数据时,YUM 使用了过多的内存 +8 | DNF 使用满足性算法来解决依赖关系解析(它是用字典的方法来存储和检索包和依赖信息)| 由于使用公开 API 的原因,Yum 依赖性解析变得迟钝 +9 | 从内存使用量和版本库元数据的依赖性解析来看,性能都不错 | 总的来说,在很多因素的影响下,表现不佳 +10 | DNF 更新:在 DNF 更新过程中,如果包中包含不相关的依赖,则不会更新 | YUM 将在没有验证的情况下更新软件包 +11 | 如果启用的存储库没有响应,DNF 将跳过它,并继续使用可用的存储库处理事务 | 如果有存储库不可用,YUM 会立即停止 +12 | `dnf update` 和 `dnf upgrade` 是等价的 | 在 Yum 中则不同 +13 | 安装包的依赖关系不更新 | Yum 为这种行为提供了一个选项 +14 | 清理删除的包:当删除一个包时,DNF 会自动删除任何没有被用户明确安装的依赖包 | Yum 不会这样做 +15 | 存储库缓存更新计划:默认情况下,系统启动后 10 分钟后,DNF 每小时会对配置的存储库检查一次更新。这个动作由系统定时器单元 `dnf-makecache.timer` 控制 | Yum 也会这样做 +16 | 内核包不受 DNF 保护。不像 Yum,你可以删除所有的内核包,包括运行中的内核包 | Yum 不允许你删除运行中的内核 +17 | libsolv:用于解包和读取资源库。hawkey: 为 libsolv 提供简化的 C 和 Python API 库。librepo: 提供 C 和 Python(类似 libcURL)API 的库,用于下载 Linux 存储库元数据和软件包。libcomps: 是 yum.comps 库的替代品。它是用纯 C 语言编写的库,有 Python 2 和 Python 3 的绑定。| Yum 不使用单独的库来执行这些功能 +18 | DNF 包含 29000 行代码 | Yum 包含 56000 行代码 +19 | DNF 由 Ales Kozumplik 开发 | YUM 由 Zdenek Pavlas、Jan Silhan 和团队成员开发 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/comparison-difference-between-dnf-vs-yum/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[2]: https://www.2daygeek.com/linux-dnf-command-examples-manage-packages-fedora-centos-rhel-systems/ diff --git a/published/202004/20191224 Why your Python code should be flat and sparse.md b/published/202004/20191224 Why your Python code should be flat and sparse.md new file mode 100644 index 0000000000..5f9bf864e6 --- /dev/null +++ b/published/202004/20191224 Why your Python code should be flat and sparse.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: (caiichenr) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12087-1.html) +[#]: subject: (Why your Python code should be flat and sparse) +[#]: via: (https://opensource.com/article/19/12/zen-python-flat-sparse) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +为何你的 Python 代码应是扁平与稀疏的 +====== + +> 本文是 Python 之禅特别系列的第三篇,此篇着眼于其中第五与第六条原则:扁平与稀疏。 + +![](https://img.linux.net.cn/data/attachment/album/202004/08/191645uiniiy56keig95gi.jpg) + +[Python 之禅][2] 之所以得名,正是由于它那简明扼要的规则被设计出的意图在于让读者进行深入地思考,而绝不单是为编程提供一份易于遵守的指南。 + +读后不去三思其意,断然难以体会 Python 之禅的妙处。倘若 Python 之禅仅仅罗列出一组清晰的法则,那法则之间的矛盾是一种缺憾,然而作为引导读者沉思最优方案沉思的工具,矛盾却是绝佳的。 + +### 扁平胜过嵌套Flat is better than nested + +迫于对缩进的强硬要求,Python 对“扁平化”的需求显然远超它者。其余编程语言为了缓解对缩进的需求,通常会在嵌套结构里加入一种“作弊”的手段。为了理解这一点,不妨一同来看看 JavaScript。 + +JavaScript 本质上是异步的,这意味着程序员用 JavaScript 写的代码会用到大量的回调函数。 + +``` +a(function(resultsFromA) { +  b(resultsFromA, function(resultsfromB) { +    c(resultsFromC, function(resultsFromC) { +      console.log(resultsFromC) +   } +  } +} +``` + +忽略这段代码的具体内容,只去观察这段代码的形状与缩进带来一个最右边的点的方式。这种独特的“箭头”图形在我们扫看代码时格外扎眼,这种写法也因此被视作不可取,甚至得到了“回调地狱”的绰号。不过,在 JavaScript 中,这种反映嵌套关系的缩进可以通过“作弊”来回避。 + +``` +a(function(resultsFromA) { +b(resultsFromA, +  function(resultsfromB) { +c(resultsFromC, +  function(resultsFromC) { +    console.log(resultsFromC) +}}} +``` + +Python 并没有提供这种作弊手段:每一级嵌套在代码中都如实的对应着一层缩进。因此,Python 深层的嵌套关系在*视觉*上也一定是深层嵌套的。这使得“回调地狱”的问题对于 Python 而言要比在 JavaScript 中严重得多:嵌套的回调函数必定带来缩进,而绝无使用花括号来“作弊”的可能。 + +这项挑战与 Python 之禅的指导原则相结合后,在我参与的库中催生出了一个优雅的解决方案。我们在 [Twisted][3] 框架里提出了 deferred 抽象,日后 JavaScript 中流行的 promise 抽象亦是受其启发而生。正是由于 Python 对整洁代码的坚守,方能推动 Python 开发者去发掘新的、强力的抽象。 + +``` +future_value = future_result() +future_value.addCallback(a) +future_value.addCallback(b) +future_value.addCallback(c) +``` + +(现代 JavaScript 程序员也许会觉得这段代码十分眼熟:promise 着实受到了 Twisted 里 deferred 抽象的深远影响。) + +### 稀疏胜过密集Sparse is better than dense + +最易降低代码密集程度的方法是引入嵌套。这种习惯也正是有关稀疏的原则要随着前一条提出的原因:在竭尽所能地减少嵌套之后,我们往往会遗留下*密集的*代码或数据结构。此处的密集,是指塞进过量信息的小段代码,它们会导致错误发生后的解析变得困难。 + +这种密集性唯有通过创造性的思考方可改善,此外别无捷径。Python 之禅并不为我们提供简单的解决方案,它只会指明改善代码的方向,而非提供“如何”去做的向导。 + +起身走走,泡个热水澡,抑或是闻闻花香。盘坐冥思,直至灵感袭来。当你终于得到启发,便是动身写代码之时。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/12/zen-python-flat-sparse + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[caiichenr](https://github.com/caiichenr) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://www.python.org/dev/peps/pep-0020/ +[3]: https://twistedmatrix.com/trac/ diff --git a/published/202004/20200211 Navigating man pages in Linux.md b/published/202004/20200211 Navigating man pages in Linux.md new file mode 100644 index 0000000000..98ca0579ed --- /dev/null +++ b/published/202004/20200211 Navigating man pages in Linux.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12127-1.html) +[#]: subject: (Navigating man pages in Linux) +[#]: via: (https://www.networkworld.com/article/3519853/navigating-man-pages-in-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 中遨游手册页的海洋 +====== + +> Linux 系统上的手册页可以做的不仅仅是提供特定命令的信息。它们可以帮助你发现你没有意识到的命令。 + +![Hello I'm Nik][1] + +手册页提供了关于 Linux 命令的基本信息,很多用户经常参考它,但手册页的内容比我们很多人意识到的要多得多。 + +你总是可以输入一个像 `man who` 这样的命令,然后得到 `who` 命令的工作原理的漂亮描述,但是探索你可能不知道的命令可能会更有启发。例如,你可以使用 `man` 命令来帮助找到一些处理非常具有挑战性的任务的命令,或者显示一些选项,这些选项可以帮助你以新的更好的方式使用你已经知道的命令。 + +让我们来浏览一些选项,看看最终的结果是什么。 + +### 用 man 去识别命令 + +`man` 命令可以帮助你按主题查找命令。例如,如果你要找一个计算文件中的行数的命令,你可以提供一个关键字。在下面的例子中,我们把关键字 “count” 放在了引号中,并添加了空格,这样我们就不会得到与 “accounts” 或 “accounting” 相关的命令,而是得到那些可以为我们做一些计算的命令。 + +``` +$ man -k ' count ' +anvil (8postfix) - Postfix session count and request rate control +cksum (1) - checksum and count the bytes in a file +sum (1) - checksum and count the blocks in a file +timer_getoverrun (2) - get overrun count for a POSIX per-process timer +``` + +为了显示与新用户账户相关的命令,我们可以尝试使用这样的命令。 + +``` +$ man -k "new user" +newusers (8) - update and create new users in batch +useradd (8) - create a new user or update default new user information +zshroadmap (1) - informal introduction to the zsh manual The Zsh Manual, … +``` + +需要说明的是,上面的第三项只是提到 “new users” 类似的内容,并不是设置、删除或配置用户账号的命令。`man` 命令只是在命令描述中匹配了一些词,作用很像 `apropos` 命令。注意上面列出的每个命令后面的括号中的数字。这些数字与包含这些命令的手册页的分区有关。 + +### 确定手册页的分区 + +`man` 命令的分区将其内容划分为不同的类别。要列出这些类别,请键入 `man man`,并查看类似下面的描述。你的系统中很可能没有第 9 分区的命令。 + +- `1`:可执行程序或 shell 命令 +- `2`:系统调用(内核提供的函数) +- `3`:库调用(程序库内的函数) +- `4`:特殊文件(通常在可以 `/dev` 中找到) +- `5`:文件格式和惯例,例如 `/etc/passwd` +- `6`:游戏 +- `7`:杂项(包括宏包和约定),例如 `man`(7)、`groff`(7) +- `8`:系统管理命令(通常只由 root 用户使用) +- `9`:内核例程(非标准) + +手册页涵盖了比我们通常认为的“命令”更多的内容。从上面的描述中可以看到,它们涵盖了系统调用、库调用、特殊文件等等。 + +下面的列表显示了 Linux 系统中的手册页的实际存储位置。这些目录上的日期会有所不同,因为随着更新,其中一些分区会有新的内容,而另一些则不会。 + +``` +$ ls -ld /usr/share/man/man? +drwxr-xr-x 2 root root 98304 Feb 5 16:27 /usr/share/man/man1 +drwxr-xr-x 2 root root 65536 Oct 23 17:39 /usr/share/man/man2 +drwxr-xr-x 2 root root 270336 Nov 15 06:28 /usr/share/man/man3 +drwxr-xr-x 2 root root 4096 Feb 4 10:16 /usr/share/man/man4 +drwxr-xr-x 2 root root 28672 Feb 5 16:25 /usr/share/man/man5 +drwxr-xr-x 2 root root 4096 Oct 23 17:40 /usr/share/man/man6 +drwxr-xr-x 2 root root 20480 Feb 5 16:25 /usr/share/man/man7 +drwxr-xr-x 2 root root 57344 Feb 5 16:25 /usr/share/man/man8 +``` + +注意,为了节省空间,手册页文件一般都是 gzip 压缩的。每当你使用 `man` 命令时,`man` 命令会根据需要解压。 + +``` +$ ls -l /usr/share/man/man1 | head -10 +total 12632 +lrwxrwxrwx 1 root root 9 Sep 5 06:38 [.1.gz -> test.1.gz +-rw-r--r-- 1 root root 563 Nov 7 05:07 2to3-2.7.1.gz +-rw-r--r-- 1 root root 592 Apr 23 2016 411toppm.1.gz +-rw-r--r-- 1 root root 2866 Aug 14 10:36 a2query.1.gz +-rw-r--r-- 1 root root 2361 Sep 9 15:13 aa-enabled.1.gz +-rw-r--r-- 1 root root 2675 Sep 9 15:13 aa-exec.1.gz +-rw-r--r-- 1 root root 1142 Apr 3 2018 aaflip.1.gz +-rw-r--r-- 1 root root 3847 Aug 14 10:36 ab.1.gz +-rw-r--r-- 1 root root 2378 Aug 23 2018 ac.1.gz +``` + +### 按分区列出的手册页 + +即使只看第 1 分区的前 10 个手册页(如上所示),你也可能会看到一些新的命令 —— 也许是 `a2query` 或 `aaflip`(如上所示)。 + +探索命令的更好策略是按分区列出命令,不查看文件本身,而是使用 `man` 命令向你显示命令并提供每个命令的简要说明。 + +在下面的命令中,`-s 1` 指示 `man` 显示第 1 分区中的命令信息。`-k .` 使该命令对所有命令都有效,而不是指定一个特定的关键字;如果没有这个,`man` 命令就会回过头来问:“你想要什么手册页?”所以,使用关键字来选择一组相关的命令,或者使用点来显示一个分区中的所有命令。 + +``` +$ man -s 1 -k . +2to3-2.7 (1) - Python2 to Python3 converter +411toppm (1) - convert Sony Mavica .411 image to ppm +as (1) - the portable GNU assembler. +baobab (1) - A graphical tool to analyze disk usage +busybox (1) - The Swiss Army Knife of Embedded Linux +cmatrix (1) - simulates the display from "The Matrix" +expect_dislocate (1) - disconnect and reconnect processes +red (1) - line-oriented text editor +enchant (1) - a spellchecker +… +``` + +### 有多少手册页? + +如果你对每个分区中有多少手册页感到好奇,可以使用以下命令按分区对它们进行计数: + +``` +$ for num in {1..8} +> do +> man -s $num -k . | wc -l +> done +2382 +493 +2935 +53 +441 +11 +245 +919 +``` + +确切的数量可能有所不同,但是大多数 Linux 系统的命令数量差不多。如果我们使用命令将这些数字加在一起,我们可以看到运行该命令的系统上有将近 7500 个手册页。有很多命令,系统调用等。 + +``` +$ for num in {1..8} +> do +> num=`man -s $num -k . | wc -l` +> tot=`expr $num + $tot` +> echo $tot +> done +2382 +2875 +5810 +5863 +6304 +6315 +6560 +7479 <=== total +``` + +阅读手册页可以学到很多东西,但是以其他方式浏览手册页可以帮助你了解系统上可能不知道的命令。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3519853/navigating-man-pages-in-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/10/field-note_play-book_playbook_map_navigation_journey_by-hello-i-m-nik-via-unsplash-100813507-large.jpg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/slideshow/153439/linux-best-desktop-distros-for-newbies.html#tk.nww-infsb +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/202004/20200213 Manage complex Git workspaces with Great Teeming Workspaces.md b/published/202004/20200213 Manage complex Git workspaces with Great Teeming Workspaces.md new file mode 100644 index 0000000000..9ae4ee5618 --- /dev/null +++ b/published/202004/20200213 Manage complex Git workspaces with Great Teeming Workspaces.md @@ -0,0 +1,173 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12156-1.html) +[#]: subject: (Manage complex Git workspaces with Great Teeming Workspaces) +[#]: via: (https://opensource.com/article/20/2/git-great-teeming-workspaces) +[#]: author: (Daniel Gryniewicz https://opensource.com/users/dang) + +使用 GTWS 管理复杂的 Git 工作空间 +====== + +> GTWS 是一系列脚本,它使我们在开发环境中管理不同的项目和项目的各个版本变得很容易。 + +![](https://img.linux.net.cn/data/attachment/album/202004/27/182149xh9s7kb5bkf5875b.jpg) + +[Great Teeming Workspaces][2](GTWS)是一个 Git 的复杂工作空间管理工具包,它使我们在开发环境中管理不同的项目和项目的各个版本变得很容易。 + +有点像 Python 的 [venv][3],但不是为 Python 语言准备的。GTWS 用来管理多个项目的多个版本的工作空间。你可以很容易地创建、更新、进入和离开工作空间,每个项目或版本的组合(最多)有一个本地的 origin,用来与 upstream 同步 — 其余的所有工作空间都从本地的 origin 更新。 + +### 部署 + +``` +${GTWS_ORIGIN}//[/] +${GTWS_BASE_SRCDIR}////{[,...]} +``` + +源代码目录的每一级(包括全局的家目录)可以包含一个 `.gtwsrc` 文件,这个文件中维护与当前级相关的设置和 bash 代码。每一级的配置会覆盖上一级。 + +### 安装 + +用下面的命令检出 GTWS: + +``` +git clone https://github.com/dang/gtws.git +``` + +配置你的 `${HOME}/.gtwsrc`。它应该包含 `GTWS_ORIGIN`,也可以再包含 `GTWS_SETPROMPT`。 + +把仓库目录加到环境变量中: + +``` +export PATH="${PATH}:/path/to/gtws +``` + +### 配置 + +通过级联 `.gtwsrc` 文件来进行配置。它从根目录向下遍历,会执行在每级目录中找到的 `.gtwsrc` 文件。下级目录的文件会覆盖上一级。 + +在你最上层的文件 `~/.gtws/.gtwsrc` 中进行如下设置: + + * `GTWS_BASE_SRCDIR`:所有项目源文件目录树的基目录。默认为 `$HOME/src`。 + * `GTWS_ORIGIN`: 指定 origin git 目录树的路径。默认为 `$HOME/origin`。 + * `GTWS_SETPROMPT`: 可选配置。如果配置了这个参数,shell 提示符会有工作空间的名字。 + * `GTWS_DEFAULT_PROJECT`: 不指定项目或项目未知时默认的项目名。如果不指定,使用命令行时必须指明项目。 + * `GTWS_DEFAULT_PROJECT_VERSION`: 检出的默认版本。默认为 `master`。 + +在每个项目的根目录进行以下设置: + + * `GTWS_PROJECT`: 项目的名字(和基目录)。 + * `gtws_project_clone`: 这个函数用于克隆一个项目的指定版本。如果未定义,它会假定项目的 origin 对每一个版本都有一个单独的目录,这样会导致克隆一堆 Git 仓库。 + * `gtws_project_setup`: 在克隆完所有的仓库后,可以选择是否调用这个函数,调用后可以对项目进行必要的配置,如在 IDE 中配置工作空间。 + +在项目版本级进行以下设置: + + * `GTWS_PROJECT_VERSION:` 项目的版本。用于正确地从 origin 拉取代码。类似 Git 中的分支名字。 + +下面这些参数可以在目录树的任意地方进行配置,如果能生效,它们可以被重写多次: + + * `GTWS_PATH_EXTRA`: 这些是工作空间中加到路径后的额外的路径元素。 + * `GTWS_FILES_EXTRA`: 这些是不在版本控制内,但应该在工作空间中被检出的额外的文件。这些文件包括 `.git/info/exclude`,每个文件都与仓库的基目录相关联。 + +### origin 目录 + +`GTWS_ORIGIN` (大部分脚本中)指向拉取和推送的原始 Git 检出目录。 + +`${GTWS_ORIGIN}` 部署: + + * `/` + * 这是一个项目的仓库的基目录。 + * 如果指定了 `gtws_project_clone`,你可以配置任意的部署路径。 + * 如果没有指定 `gtws_project_clone`,这个路径下必须有个名为 `git` 的子目录,且 `git` 目录下有一系列用来克隆的裸 Git 仓库。 + +### 工作流示例 + +假设你有一个项目名为 `Foo`,它的 upstream 为 `github.com/foo/foo.git`。这个仓库有个名为 `bar` 的子模块,它的 upstream 是 `github.com/bar/bar.git`。Foo 项目在 master 分支开发,使用稳定版本的分支。 + +为了能在 Foo 中使用 GTWS,你首先要配置目录结构。本例中假设你使用默认的目录结构。 + + * 配置你最上层的 `.gtwsrc`: + * `cp ${GTWS_LOC}/examples/gtwsrc.top ~/.gtwsrc` + * 根据需要修改 `~/.gtwsrc`。 + * 创建顶级目录: + * `mkdir -p ~/origin ~/src` + * 创建并配置项目目录: + * `mkdir -p ~/src/foo` + + `cp ${GTWS_LOC}/examples/gtwsrc.project ~/src/foo/.gtwsrc` + * 根据需要修改 `~/src/foo/.gtwsrc`。 + * 创建并配置 master 版本目录: + * `mkdir -p ~/src/foo/master` + + `cp ${GTWS_LOC}/examples/gtwsrc.version ~/src/foo/master/.gtwsrc` + * 根据需要修改 `~/src/foo/master/.gtwsrc`。 + * 进入版本目录并创建一个临时工作空间来配置镜像: + * `mkdir -p ~/src/foo/master/tmp` + + `cd ~/src/foo/master/tmp` + + `git clone --recurse-submodules git://github.com/foo/foo.git` + + `cd foo` + + `gtws-mirror -o ~/origin -p foo`(译注:这个地方原文有误,不加 `-s` 参数会报错) + * 上面命令会创建 `~/origin/foo/git/foo.git` 和 `~/origin/foo/submodule/bar.git`。 + * 以后的克隆操作会从这些 origin 而不是 upstream 克隆。 + * 现在可以删除工作空间了。 + +到现在为止,Foo 的 master 分支的工作可以结束了。假设你现在想修复一个 bug,名为 `bug1234`。你可以脱离你当前的工作空间为修复这个 bug 单独创建一个工作空间,之后在新创建的工作空间中开发。 + + * 进入版本目录,创建一个新的工作空间: + * `cd ~/src/foo/master` + + `mkws bug1234` + * 上面的命令创建了 `bug1234/`,在这个目录下检出了 Foo(和它的子模块 `bar`),并创建了 `build/foo` 来构建它。 + * 有两种方式进入工作空间: + * `cd ~/src/foo/master/bug1234` + + `startws` + + 或者 + + `cd ~/src/foo/master/` + + `startws bug1234` + * 上面的命令在 `bug1234` 工作空间中开启了一个子 shell。这个 shell 有 GTWS 的环境和你在各级 `.gtwsrc` 文件中设置的环境。它也把你工作空间的基目录加入到了 CD,因此你可以从 base 路径 `cd` 到相关的目录中。 + * 现在你可以修复 `bug1234` 了,构建、测试、提交你的修改。当你可以把代码推送到 upstream 时,执行下面的命令: + + `cd foo` + + `wspush`  + * `wspush` 会把代码推送到与你工作空间相关的分支 — 先推送到本地的 origin,再推送到 upstream。 + * 当 upstream 有修改时,你可以用下面的命令同步到本地: + + `git sync` + * 上面的命令调用了 GTWS 的 `git-sync` 脚本,会从本地 origin 更新代码。使用下面的命令来更新本地的 origin: + + `git sync -o`  + * 上面的命令会更新你本地的 origin 和子模块的镜像,然后用那些命令来更新你的检出仓库的代码。`git-sync` 也有一些其他的很好的工鞥。 + * 当要结束工作空间中的工作时,直接退出 shell: + + `exit` + * 你可以在任何时间重复进入工作空间,也可以在同一时间在相同的工作空间中开多个 shell。 + * 当你不需要某个工作空间时,你可以使用 `rmws` 来删除它,或者直接删除它的目录树。 + * 还有一个脚本 `tmws` 使用 tmux 进入工作空间,能创建一系列的窗口/窗格,这完美契合我的工作流。你可以根据你自己的需求来修改它。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/git-great-teeming-workspaces + +作者:[Daniel Gryniewicz][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dang +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://github.com/dang/gtws +[3]: https://docs.python.org/3/library/venv.html diff --git a/published/202004/20200228 Getting started with Linux firewalls.md b/published/202004/20200228 Getting started with Linux firewalls.md new file mode 100644 index 0000000000..a8a9749395 --- /dev/null +++ b/published/202004/20200228 Getting started with Linux firewalls.md @@ -0,0 +1,117 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12130-1.html) +[#]: subject: (Getting started with Linux firewalls) +[#]: via: (https://opensource.com/article/20/2/firewall-cheat-sheet) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Linux 防火墙入门教程 +====== + +> 防火墙是你的计算机防止网络入侵的第一道屏障。为确保你的安全,请下载我们的备忘单。 + +![](https://img.linux.net.cn/data/attachment/album/202004/20/104205paugcytauqctqw6c.jpg) + +合理的防火墙是你的计算机防止网络入侵的第一道屏障。你在家里上网,通常互联网服务提供会在路由中搭建一层防火墙。当你离开家时,那么你计算机上的那层防火墙就是仅有的一层,所以配置和控制好你 Linux 电脑上的防火墙很重要。如果你维护一台 Linux 服务器,那么知道怎么去管理你的防火墙同样重要,只要掌握了这些知识你才能保护你的服务器免于本地或远程非法流量的入侵。 + +### 安装防火墙 + +很多 Linux 发行版本已经自带了防火墙,通常是 `iptables`。它很强大并可以自定义,但配置起来有点复杂。幸运的是,有开发者写出了一些前端程序来帮助用户控制防火墙,而不需要写冗长的 iptables 规则。 + +在 Fedora、CentOS、Red Hat 和一些类似的发行版本上,默认安装的防火墙软件是 `firewalld`,通过 `firewall-cmd` 命令来配置和控制。在 Debian 和大部分其他发行版上,可以从你的软件仓库安装 firewalld。Ubuntu 自带的是简单防火墙Uncomplicated Firewall(ufw),所以要使用 firewalld,你必须启用 `universe` 软件仓库: + +``` +$ sudo add-apt-repository universe +$ sudo apt install firewalld +``` + +你还需要停用 ufw: + +``` +$ sudo systemctl disable ufw +``` + +没有理由*不用* ufw。它是一个强大的防火墙前端。然而,本文重点讲 firewalld,因为大部分发行版都支持它而且它集成到了 systemd,systemd 是几乎所有发行版都自带的。 + +不管你的发行版是哪个,都要先激活防火墙才能让它生效,而且需要在启动时加载: + +``` +$ sudo systemctl enable --now firewalld +``` + +### 理解防火墙的域 + +Firewalld 旨在让防火墙的配置工作尽可能简单。它通过建立zone来实现这个目标。一个域是一组的合理、通用的规则,这些规则适配大部分用户的日常需求。默认情况下有九个域。 + + * `trusted`:接受所有的连接。这是最不偏执的防火墙设置,只能用在一个完全信任的环境中,如测试实验室或网络中相互都认识的家庭网络中。 + * `home`、`work`、`internal`:在这三个域中,接受大部分进来的连接。它们各自排除了预期不活跃的端口进来的流量。这三个都适合用于家庭环境中,因为在家庭环境中不会出现端口不确定的网络流量,在家庭网络中你一般可以信任其他的用户。 + * `public`:用于公共区域内。这是个偏执的设置,当你不信任网络中的其他计算机时使用。只能接收选定的常见和最安全的进入连接。 + * `dmz`:DMZ 表示隔离区。这个域多用于可公开访问的、位于机构的外部网络、对内网访问受限的计算机。对于个人计算机,它没什么用,但是对某类服务器来说它是个很重要的选项。 + * `external`:用于外部网络,会开启伪装(你的私有网络的地址被映射到一个外网 IP 地址,并隐藏起来)。跟 DMZ 类似,仅接受经过选择的传入连接,包括 SSH。 + * `block`:仅接收在本系统中初始化的网络连接。接收到的任何网络连接都会被 `icmp-host-prohibited` 信息拒绝。这个一个极度偏执的设置,对于某类服务器或处于不信任或不安全的环境中的个人计算机来说很重要。 + * `drop`:接收的所有网络包都被丢弃,没有任何回复。仅能有发送出去的网络连接。比这个设置更极端的办法,唯有关闭 WiFi 和拔掉网线。 + +你可以查看你发行版本的所有域,或通过配置文件 `/usr/lib/firewalld/zones` 来查看管理员设置。举个例子:下面是 Fefora 31 自带的 `FedoraWorkstation` 域: + +``` +$ cat /usr/lib/firewalld/zones/FedoraWorkstation.xml + + + Fedora Workstation + Unsolicited incoming network packets are rejected from port 1 to 1024, except for select network services. Incoming packets that are related to outgoing network connections are accepted. Outgoing network connections are allowed. + + + + + + +``` + +### 获取当前的域 + +任何时候你都可以通过 `--get-active-zones` 选项来查看你处于哪个域: + +``` +$ sudo firewall-cmd --get-active-zones +``` + +输出结果中,会有当前活跃的域的名字和分配给它的网络接口。笔记本电脑上,在默认域中通常意味着你有个 WiFi 卡: + +``` +FedoraWorkstation +  interfaces: wlp61s0 +``` + +### 修改你当前的域 + +要更改你的域,请将网络接口重新分配到不同的域。例如,把例子中的 `wlp61s0` 卡修改为 public 域: + +``` +$ sudo firewall-cmd --change-interface=wlp61s0 --zone=public +``` + +你可以在任何时候、任何理由改变一个接口的活动域 —— 无论你是要去咖啡馆,觉得需要增加笔记本的安全策略,还是要去上班,需要打开一些端口进入内网,或者其他原因。在你凭记忆学会 `firewall-cmd` 命令之前,你只要记住了关键词 `change` 和 `zone`,就可以慢慢掌握,因为按下 `Tab` 时,它的选项会自动补全。 + +### 更多信息 + +你可以用你的防火墙干更多的事,比如自定义已存在的域,设置默认域,等等。你对防火墙越了解,你在网上的活动就越安全,所以我们创建了一个[备忘单][2]便于速查和参考。 + +- 下载你的 [防火墙备忘单][2]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/firewall-cheat-sheet + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coverimage_cheat_sheet.png?itok=lYkNKieP (Cheat Sheet cover image) +[2]: https://opensource.com/downloads/firewall-cmd-cheat-sheet diff --git a/published/202004/20200309 Fish - A Friendly Interactive Shell.md b/published/202004/20200309 Fish - A Friendly Interactive Shell.md new file mode 100644 index 0000000000..cb7b6cb62d --- /dev/null +++ b/published/202004/20200309 Fish - A Friendly Interactive Shell.md @@ -0,0 +1,183 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12069-1.html) +[#]: subject: (Fish – A Friendly Interactive Shell) +[#]: via: (https://fedoramagazine.org/fish-a-friendly-interactive-shell/) +[#]: author: (Michal Konečný https://fedoramagazine.org/author/zlopez/) + +Fish:一个友好的交互式 Shell +====== + +![Fish — A Friendly Interactive Shell][1] + +你是否正在寻找 bash 的替代品?你是否在寻找更人性化的东西?不用再看了,因为你刚发现了 fish! + +Fish(友好的交互式 shell)是一个智能且用户友好的命令行 shell,可在 Linux、MacOS 和其他操作系统上运行。可以将其用于终端的日常工作和脚本编写。用 fish 编写的脚本比相同的 bash 版本具有更少的神秘性。 + +### Fish 的用户友好功能 + +* **建议**:Fish 会提示你之前写过的命令。当经常输入相同命令时,这样可以提高生产率。 +* **健全的脚本能力**:Fish 避免使用那些隐秘字符。这提供了更清晰和更友好的语法。 +* **基于手册页的补全**:Fish 会根据命令的手册页自动补全参数。 +* **语法高亮**:Fish 会高亮显示命令语法以使其在视觉上友好。 + +### 安装 + +#### Fedora 工作站 + +使用 `dnf` 命令安装 fish: + +``` +$ sudo dnf install fish +``` + +安装 `util-linux-user` 包,然后使用适当的参数运行 `chsh`(更改 shell 程序)命令,将 fish 设置为默认 shell 程序: + +``` +$ sudo dnf install util-linux-user +$ chsh -s /usr/bin/fish +``` + +你需要注销然后重新登录,更改才能生效。 + +#### Fedora Silverblue + +由于它不是 GUI 应用,因此你需要使用 `rpm-ostree` 将其加到层内。使用以下命令在 Fedora Silverblue 上安装 fish: + +``` +$ rpm-ostree install fish +``` + +在 Fedora Silverblue 上,你需要重启 PC 才能切换到新的 ostree 镜像。 + +如果你想在 Fedora Silverblue 用 fish 作为主要 shell,最简单的方法是更新 `/etc/passwd` 文件。找到你的用户,并将 `/bin/bash` 更改为 `/usr/bin/fish`。 + +你需要 [root 权限][2]来编辑 `/etc/passwd` 文件。另外,你需要注销并重新登录才能使更改生效。 + +### 配置 + +fish 的用户配置文件在 `~/.config/fish/config.fish`。要更改所有用户的配置,请编辑 `/etc/fish/config.fish`。 + +用户配置文件必须手动创建。安装脚本不会创建 `~/.config/fish/config.fish`。 + +以下是两个个配置示例以及它们的 bash 等效项,以帮助你入门: + +#### 创建别名 + +* `~/.bashrc`:`alias ll='ls -lh'` +* `~/.config/fish/config.fish`: `alias ll='ls -lh'` + +#### 设置环境变量 + + * `~/.bashrc`:`export PATH=$PATH:~/bin` + * `~/.config/fish/config.fish`:`set -gx PATH $PATH ~/bin` + +### 使用 fish 工作 + +将 fish 配置为默认 shell 程序后,命令提示符将类似于下图所示。如果尚未将 fish 配置为默认 shell,只需运行 `fish` 命令以在当前终端会话中启动。 + +![][3] + +在你开始输入命令时,你会注意到语法高亮显示: + +![][4] + +很酷,不是吗?🙂 + +你还将在输入时看到建议的命令。例如,再次开始输入上一个命令: + +![][5] + +注意输入时出现的灰色文本。灰色文本显示建议之前编写的命令。要自动补全,只需按 `CTRL+F`。 + +通过输入连接号(`–`)然后使用 `TAB` 键,它会根据前面命令的手册页获取参数建议: + +![][6] + +如果你按一次 `TAB`,它将显示前几个建议(或所有建议,如果只有少量参数可用)。如果再次按 `TAB`,它将显示所有建议。如果连续三次按 `TAB`,它将切换到交互模式,你可以使用箭头键选择一个参数。 + +除此之外,fish 的工作与大多数其他 shell 相似。其他差异已经写在文档中。因此,找到你可能感兴趣的其他功能应该不难。 + +### 让 fish 变得更强大 + +使用 [powerline][7] 使 fish 变得更强大。Powerline 可以为 fish 的界面添加命令执行时间、彩色化 git 状态、当前 git 分支等。 + +在安装 powerline 之前,你必须先安装 [Oh My Fish][8]。Oh My Fish 扩展了 fish 的核心基础架构,以支持安装其他插件。安装 Oh My Fish 的最简单方法是使用 `curl` 命令: + +``` +> curl -L https://get.oh-my.fish | fish +``` + +如果你不想直接将安装命令管道传给 `fish`,请参见 Oh My Fish 的 [README][9] 的安装部分,以了解其他安装方法。 + +Fish 的 powerline 插件是 [bobthefish][7]。Bobthefish 需要 `powerline-fonts` 包。 + +在 Fedora 工作站上: + +``` +> sudo dnf install powerline-fonts +``` + +在 Fedora Silverblue 上: + +``` +> rpm-ostree install powerline-fonts +``` + +在 Fedora Silverblue 上,你必须重启以完成字体的安装。 + +安装 `powerline-fonts` 之后,安装 `bobthefish`: + +``` +> omf install bobthefish +``` + +现在你可以通过 powerline 体验 fish 的全部奇妙之处: + +![][10] + +### 更多资源 + +查看这些网页,了解更多 fish 内容: + + * [官网][11] + * [文档][12] + * [教程][13] + * [常见问题][14] + * [在线体验][15] + * [邮件列表][16] + * [GitHub][17] + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fish-a-friendly-interactive-shell/ + +作者:[Michal Konečný][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/zlopez/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/03/fish-816x345.jpg +[2]: https://fedoramagazine.org/howto-use-sudo/ +[3]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-00-35.png +[4]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-19-24.png +[5]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-25-31.png +[6]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-14-58-07.png +[7]: https://github.com/oh-my-fish/theme-bobthefish +[8]: https://github.com/oh-my-fish/oh-my-fish +[9]: https://github.com/oh-my-fish/oh-my-fish/blob/master/README.md#installation +[10]: https://fedoramagazine.org/wp-content/uploads/2020/03/Screenshot-from-2020-03-03-15-38-07.png +[11]: https://fishshell.com/ +[12]: https://fishshell.com/docs/current/index.html +[13]: https://fishshell.com/docs/current/tutorial.html +[14]: https://fishshell.com/docs/current/faq.html +[15]: https://rootnroll.com/d/fish-shell/ +[16]: https://sourceforge.net/projects/fish/lists/fish-users +[17]: https://github.com/fish-shell/fish-shell/ diff --git a/published/202004/20200311 Directing Kubernetes traffic with Traefik.md b/published/202004/20200311 Directing Kubernetes traffic with Traefik.md new file mode 100644 index 0000000000..c9cc3c3f8e --- /dev/null +++ b/published/202004/20200311 Directing Kubernetes traffic with Traefik.md @@ -0,0 +1,381 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12049-1.html) +[#]: subject: (Directing Kubernetes traffic with Traefik) +[#]: via: (https://opensource.com/article/20/3/kubernetes-traefik) +[#]: author: (Lee Carpenter https://opensource.com/users/carpie) + +使用 Traefik 引导 Kubernetes 流量 +====== + +> 将流量引入 Kubernetes 树莓派集群的分步指南。 + +![Digital creative of a browser on the internet][1] + +在本文中,我们将部署几个简单的网站,并学习如何使用 Traefik 将来自外部世界的流量引入到我们的集群中。之后,我们还将学习如何删除 Kubernetes 资源。让我们开始吧! + +- [video](https://img.linux.net.cn/static/video/Ingressing%20with%20k3s-QcC-5fRhsM8.mp4) + +### 准备 + +要继续阅读本文,你只需要我们在上一篇文章中构建的 [k3s 树莓派集群][2]。由于你的集群将从网络上拉取镜像,因此该集群需要能够访问互联网。 + +出于解释目的,本文将显示一些配置文件和示例 HTML 文件。所有示例文件都可以在[此处][3]下载。 + +### 部署一个简单的网站 + +之前,我们使用 `kubectl` 进行了直接部署。但是,这不是典型的部署方法。一般情况都会使用 YAML 配置文件,这也是我们要在本文中使用的配置文件。我们将从顶部开始,并以自顶向下的方式创建该配置文件。 + +### 部署配置 + +首先是部署配置。配置如下所示,并在下面进行说明。我通常以 [Kubernetes 文档][4]中的示例为起点,然后根据需要对其进行修改。例如,下面的配置是复制了[部署文档][5]中的示例后修改的。 + +创建一个文件 `mysite.yaml`,其内容如下: + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysite-nginx + labels: + app: mysite-nginx +spec: + replicas: 1 + selector: + matchLabels: + app: mysite-nginx + template: + metadata: + labels: + app: mysite-nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 +``` + +其中大部分是样板。重要的部分,我们会将该部署命名为 `mysite-nginx`,并为其加上同名的 `app` 标签。我们指定了一个副本replica,这意味着将只创建一个 Pod。我们还指定了一个容器,我们将其命名为 `nginx`。我们将镜像image指定为 `nginx`。这意味着在部署时,k3s 将从 DockerHub 下载 `nginx` 镜像并从中创建一个 Pod。最后,我们指定了容器端口containerPort为 `80`,这只意味着在容器内部 Pod 会监听 `80` 端口。 + +我在上面强调了“在容器内部”,因为这是一个重要的区别。由于我们是按容器配置的,因此只能在容器内部访问它,并且进一步将其限制为内部网络。这对于允许多个容器在同一容器端口上监听所是必要的。换句话说,通过这种配置,其他一些 Pod 也可以在其容器端口 80 上侦听,并且不会与此容器冲突。为了提供对该 Pod 的正式访问权限,我们需要一个服务service配置。 + +### 服务配置 + +在 Kubernetes 中,服务service是一种抽象。它提供了一种访问 Pod 或 Pod 集合的方法。当连接到服务时,服务会路由到单个 Pod,或者如果定义了多个 Pod 副本,会通过负载均衡路由到多个 Pod。 + +可以在同一配置文件中指定该服务,这就是我们将在此处要做的。用 `---` 分隔配置区域,将以下内容添加到 `mysite.yaml` 中: + +``` +--- +apiVersion: v1 +kind: Service +metadata: + name: mysite-nginx-service +spec: + selector: + app: mysite-nginx + ports: + - protocol: TCP + port: 80 +``` + +在此配置中,我们将服务命名为 `mysite-nginx-service`。我们提供了一个选择器selector:`app: mysite-nginx`。这是服务选择其路由到的应用程序容器的方式。请记住,我们为容器提供了 `app` 标签:`mysite-nginx` 。这就是服务用来查找我们的容器的方式。最后,我们指定服务协议为 `TCP`,在端口 `80` 上监听。 + +### 入口配置 + +入口Ingress配置指定了如何将流量从集群外部传递到集群内部的服务。请记住,k3s 预先配置了 Traefik 作为入口控制器。因此,我们将编写特定于 Traefik 的入口配置。将以下内容添加到 `mysite.yaml` 中(不要忘了用 `---` 分隔): + +``` +--- +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: mysite-nginx-ingress + annotations: + kubernetes.io/ingress.class: "traefik" +spec: + rules: + - http: + paths: + - path: / + backend: + serviceName: mysite-nginx-service + servicePort: 80 +``` + +在此配置中,我们将入口记录命名为 `mysite-nginx-ingress`。我们告诉 Kubernetes,我们希望 `traefik` 成为我们的入口控制器,再加上 `kubernetes.io/ingress.class` 的注解。 + +在规则rules部分中,我们基本上是说,当 `http` 流量进入时,并且 `path` 匹配 `/`(或其下的任何内容),将其路由到由 `serviceName mysite-nginx-service` 指定的后端backend服务中,并将其路由到 `servicePort 80`。这会将传入的 HTTP 流量连接到我们之前定义的服务。 + +### 需要部署的东西 + +就配置而言,就是这样了。如果我们现在部署,我们将获得默认的 nginx 页面,但这不是我们想要的。让我们创建一些简单但可自定义的部署方式。创建具有以下内容的文件 `index.html`: + +``` + +K3S! + + + +
Hello from K3S!
+ + +``` + +我们尚未介绍 Kubernetes 中的存储机制,因此在这里我们偷懒一下,仅将该文件存储在 Kubernetes 配置映射中。这不是我们推荐的部署网站的方式,但对于我们的目的来说是可行的。运行以下命令: + +``` +kubectl create configmap mysite-html --from-file index.html +``` + +该命令从本地文件 `index.html` 创建名为 `mysite-html` 的配置映射configmap资源。这实际上是在 Kubernetes 资源中存储一个文件(或一组文件),我们可以在配置中调出该文件。它通常用于存储配置文件(因此而得名),我们在这里稍加滥用。在以后的文章中,我们将讨论 Kubernetes 中适当的存储解决方案。 + +创建配置映射后,让我们将其挂载在我们的 `nginx` 容器中。我们分两个步骤进行。首先,我们需要指定一个volume来调出配置映射。然后我们需要将该卷挂载到 `nginx` 容器中。通过在 `mysite.yaml` 中的 `container` 后面的 `spec` 标签下添加以下内容来完成第一步: + +``` +      volumes: +      - name: html-volume +        configMap: +          name: mysite-html +``` + +这告诉 Kubernetes 我们要定义一个名为 `html-volume` 的卷,并且该卷应包含名为 `html-volume`(我们在上一步中创建的)的配置映射的内容。 + +接下来,在 `nginx` 容器规范中的端口ports下方,添加以下内容: + +``` +        volumeMounts: +        - name: html-volume +          mountPath: /usr/share/nginx/html +``` + +这告诉 Kubernetes,对于 `nginx` 容器,我们想在容器中的 `/usr/share/nginx/html` 路径上挂载名为 `html-volume` 的卷。 为什么要使用 `/usr/share/nginx/html`?那个位置就是 `nginx` 镜像提供 HTML 服务的地方。通过在该路径上挂载卷,我们用该卷内容替换了默认内容。 + +作为参考,配置文件的 `deployment` 部分现在应如下所示: + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: +  name: mysite-nginx +  labels: +    app: mysite-nginx +spec: +  replicas: 1 +  selector: +    matchLabels: +      app: mysite-nginx +  template: +    metadata: +      labels: +        app: mysite-nginx +    spec: +      containers: +      - name: nginx +        image: nginx +        ports: +        - containerPort: 80 +        volumeMounts: +        - name: html-volume +          mountPath: /usr/share/nginx/html +      volumes: +      - name: html-volume +        configMap: +          name: mysite-html +``` + +### 部署它! + +现在我们准备部署! 我们可以这样做: + +``` +kubectl apply -f mysite.yaml +``` + +你应该看到类似于以下内容: + +``` +deployment.apps/mysite-nginx created +service/mysite-nginx-service created +ingress.networking.k8s.io/mysite-nginx-ingress created +``` + +这意味着 Kubernetes 为我们指定的三个配置分别创建了资源。使用以下方法检查 Pod 的状态: + +``` +kubectl get pods +``` + +如果看到状态为 `ContainerCreating`,请给它一些时间并再次运行 `kubectl get pods`。通常,第一次会花一些时间,因为 k3s 必须下载 `nginx` 镜像来创建 Pod。一段时间后,你应该看到 `Running` 的状态。 + +### 尝试一下! + +Pod 运行之后,就该尝试了。打开浏览器,然后在地址栏中输入 `kmaster`。 + +![][6] + +恭喜你!你已经在 k3s 集群上部署了一个网站! + +### 另一个 + +因此,现在我们有了一个运行单个网站的整个 k3s 集群。但是我们可以有更多的网站!如果我们要在同一集群中提供另一个网站怎么办?让我们看看如何做到这一点。 + +同样,我们需要部署一些东西。碰巧我的狗有一条她想让全世界都知道的信息,她想了好久了。因此,我专门为她制作了一些 HTML(可从示例 zip 文件中获得)。同样,我们将使用配置映射的技巧来托管这些 HTML。这次我们将把整个目录(`html` 目录)放到配置映射中,但是调用是相同的。 + +``` +kubectl create configmap mydog-html --from-file html +``` + +现在,我们需要为此站点创建一个配置文件。它几乎与用于 `mysite.yaml` 的完全相同,因此首先将 `mysite.yaml` 复制为 `mydog.yaml`。现在将 `mydog.yaml` 修改为: + +``` +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mydog-nginx + labels: + app: mydog-nginx +spec: + replicas: 1 + selector: + matchLabels: + app: mydog-nginx + template: + metadata: + labels: + app: mydog-nginx + spec: + containers: + - name: nginx + image: nginx + ports: + - containerPort: 80 + volumeMounts: + - name: html-volume + mountPath: /usr/share/nginx/html + volumes: + - name: html-volume + configMap: + name: mydog-html +--- +apiVersion: v1 +kind: Service +metadata: + name: mydog-nginx-service +spec: + selector: + app: mydog-nginx + ports: + - protocol: TCP + port: 80 +--- +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: mydog-nginx-ingress + annotations: + kubernetes.io/ingress.class: "traefik" + traefik.frontend.rule.type: PathPrefixStrip +spec: + rules: + - http: + paths: + - path: /mydog + backend: + serviceName: mydog-nginx-service + servicePort: 80 +``` + +我们只需进行搜索并将 `mysite` 替换为 `mydog`即可完成大多数修改。其他两个修改在入口部分中。我们将 `path` 更改为 `/mydog`,并添加了一个注解 `traefik.frontend.rule.type: PathPrefixStrip`。 + +`/mydog` 路径的规范指示 Traefik 将以 `/mydog` 路径开头的所有传入请求路由到 `mydog-nginx-service`。任何其他路径将继续路由到 `mysite-nginx-service`。 + +新的注解 `PathPrefixStrip` 告诉 Traefik 在将请求发送到 `mydog-nginx-service` 之前先去除前缀 `/mydog`。我们这样做是因为 `mydog-nginx` 应用程序不需要前缀。这意味着我们可以简单地通过更改入口记录中的前缀来更改挂载的服务的位置。 + +现在我们可以像以前一样进行部署: + +``` +kubectl apply -f mydog.yaml +``` + +现在,我的狗的消息应该可以在 上找到。 + +![][7] + + +呼!消息发出去了!也许今晚我们都可以睡一觉。 + +因此,现在,我们有了一个 k3s 集群,该集群托管了两个网站,Traefik 根据路径名决定将请求传递给哪个服务!但是,不仅限于基于路径的路由,我们也可以使用基于主机名的路由,我们将在以后的文章中进行探讨。 + +另外,我们刚刚托管的网站是标准的未加密 HTML 网站,而如今的所有内容都使用 SSL/TLS 加密。在我们的下一篇文章中,我们将为 k3s 集群添加支持以托管 SSL/TLS HTTPS 站点! + +### 清理 + +在开始之前,由于本文主要涉及的是示例站点,因此我想向你展示如何删除内容,以防万一你不希望将这些示例丢在集群中。 + +对于大多数配置,只需使用与部署时使用的相同配置文件运行 `delete` 命令即可撤消配置。因此,让我们同时清理 `mysite` 和 `mydog`。 + +``` +kubectl delete -f mysite.yaml +kubectl delete -f mydog.yaml +``` + +由于我们是手动创建配置映射的,因此我们也需要手动删除它们。 + +``` +kubectl delete configmap mysite-html +kubectl delete configmap mydog-html +``` + +现在,如果我们执行 `kubectl get pods`,我们应该看到我们的 nginx Pod 不存在了。 + +``` +$ kubectl get pods +No resources found in default namespace. +``` + +一切都清理了。 + +请在下面的评论中告诉我你对这个项目有什么想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/kubernetes-traefik + +作者:[Lee Carpenter][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/carpie +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://linux.cn/article-12049-1.html +[3]: https://gitlab.com/carpie/ingressing_with_k3s/-/archive/master/ingressing_with_k3s-master.zip +[4]: https://kubernetes.io/docs/ +[5]: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment +[6]: https://opensource.com/sites/default/files/uploads/mysite.jpg +[7]: https://opensource.com/sites/default/files/uploads/mydog.jpg diff --git a/published/202004/20200311 What you need to know about variables in Emacs.md b/published/202004/20200311 What you need to know about variables in Emacs.md new file mode 100644 index 0000000000..a53c1200ed --- /dev/null +++ b/published/202004/20200311 What you need to know about variables in Emacs.md @@ -0,0 +1,227 @@ +[#]: collector: (lujun9972) +[#]: translator: (cycoe) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12150-1.html) +[#]: subject: (What you need to know about variables in Emacs) +[#]: via: (https://opensource.com/article/20/3/variables-emacs) +[#]: author: (Clemens Radermacher https://opensource.com/users/clemera) + +关于 Emacs 中的变量你需要知道的事情 +====== + +> 学习 Elisp 是如何处理变量的,以及如何在你的脚本与配置中使用它们。 + +![](https://img.linux.net.cn/data/attachment/album/202004/25/190905pq1qfk1f8f9qs9v8.jpg) + +GNU Emacs 是由 C 和 Emacs Lisp(Elisp,Lisp 编程语言的一种方言)写成,它是一个编辑器的同时,又碰巧是 Elisp 的沙盒。因此,理解 Elisp 中的一些基本编程概念会对你有一些帮助。 + +如果你是 [Emacs][2] 新手,请先阅读 Sacha Chua 的《[给 Emacs 新手的资源][3]》精品帖。本篇文章假定你熟悉常见的 Emacs 术语,并且能够阅读并求值 Elisp 代码的简单片段。最好你也听说过变量作用域的概念,知道它在其它编程语言中的作用。本篇文章中的示例假定你使用的是相对较新的 Emacs 版本([v.25 之后的版本][4])。 + +[Elisp 手册][5] 包含了 Elisp 的方方面面,但它是写给那些有明确查找目标的人们的(它在这方面也做得相当棒)。但是很多人想要能够在更高的层次上解释 Elisp 概念的材料,同时将信息压缩成最精华的部分。本篇文章也正是我回应这种呼声的一次尝试,为读者描绘基础的大体轮廓。使他们能在配置中用上这些技巧,也让他们在手册中查询细节变得更容易。 + +### 全局变量 + +用 `defcustom` 定义的用户设置和用 `defvar` 或 `defconst` 定义的变量是全局的。使用 `defcustom` 或 `defvar` 声明变量的一个非常重要的原因是,当一个变量已经被绑定bind,对它们进行重新求值不会覆盖掉已有的值。举个栗子,如果你在初始化文件中对 `my-var` 进行如下绑定: + +``` +(setq my-var nil) +``` + +对如下表达式求值不会将变量覆盖为 `t`: + +``` +(defvar my-var t) +``` + +注意此处有*一个例外*:如果你用 `C-M-x` 快捷键对上述声明求值,它将调用 `eval-defun` 函数,并将变量覆盖为 `t`。通过此方式,你可以按需将变量强制覆盖。这种行为是刻意而为之的:你可能知道,Emacs 中的许多特性是按需加载的,也可以称为自动加载。如果那些文件中的声明将变量覆盖为它们的默认值,那它也就覆盖了你初始化文件中的设置。 + +### 用户选项 + +用户选项就是使用 `defcustom` 声明的全局变量。与使用 `defvar` 声明的变量不同,这些变量可以用 `M-x customize` 界面来配置。据我所知,大部分人因为觉得它开销较大而不经常使用。一旦你知道如何在你的初始化文件中设置变量,也就没有理由一定要去使用它了。许多用户没有意识到的一个细节是,通过 `customize` 的方式设置用户选项能够执行代码,有的时间可用来运行一些附加的配置说明: + +``` +(defcustom my-option t +  "My user option." +  :set (lambda (sym val) +         (set-default sym val) +         (message "Set %s to %s" sym val))) +``` + +若你对这段代码求值,并键入 `M-x customize-option RET my-option RET` 运行 `customize` 界面,lambda 匿名函数就会被调用,回显区域就会显示出该选项的符号名与值。 + +如果你在初始化文件中使用 `setq` 改变该选项的值,那么匿名函数不会运行。要想在 Elisp 中正确设置一个选项,你需要使用函数 `customize-set-variable`。或者,人们在他们的配置文件中使用了各种版本的 `csetq` 宏来自动处理(如你所愿,你可以通过 GitHub 的代码搜索发现更复杂的变体)。 + +``` +(defmacro csetq (sym val) +  `(funcall (or (get ',sym 'custom-set) 'set-default) ',sym ,val)) +``` + +若你正在使用 [use-package][6] 宏,`:custom` 关键字会替你处理好以上这些。 + +在你将以上代码放入到你的初始化文件中之后,你便可以使用 `csetq` 宏在设置变量的同时运行任何现存的 `setter` 函数。要证明这点,你可以使用此宏来改变上面定义的选项,并观察回显区域的消息输出。 + +``` +(csetq my-option nil) +``` + +### 动态绑定与词法绑定 + +当你在使用其它编程语言时,你可能不会意识到动态绑定与词法绑定的区别。当今的大部分编程语言使用词法绑定,并且在学习变量作用域与变量查找时也没有必要去了解它们之间的区别。 + +如此看来,Emacs Lisp 比较特殊因为动态绑定是默认选项,词法绑定需要显式启用。这里有一些历史遗留原因,但在实际使用中,你应该*时刻*启用词法绑定,因为它更快并且不容易出错。要启用词法绑定,只需将如下的注释行作为你的 Emacs Lisp 文件的第一行: + +``` +;;; -*- lexical-binding: t; -*- +``` + +另一种方式,你可以调用 `add-file-local-variable-prop-line`,在你选择将变量 `lexical-binding` 置为 `t` 后,会自动插入如上的注释行。 + +在加载包含如上特殊格式行的文件时,Emacs 会相应地设置变量,这意味着该缓冲区中的代码加载时启用了词法绑定。若要采用交互式的方式,你可以调用 `M-x eval-buffer` 命令,它会将词法绑定考虑在内。 + +既然你已经知道了如何启用词法绑定,那么了解这些术语的含义就很明智了。对于动态绑定,在程序执行期间建立的最后一个绑定将用于变量查找。你可以通过将以下代码放入空缓冲区并执行 `M-x eval buffer`,以对此进行测试: + +``` +(defun a-exists-only-in-my-body (a) +  (other-function)) + +(defun other-function () +  (message "I see `a', its value is %s" a)) + +(a-exists-only-in-my-body t) +``` + +你可能会很惊讶地发现,在 `other-function` 中查找变量 `a` 竟然成功了。 + +若你在顶部添加了特殊的词法绑定注释后,重新运行前面的示例,这段代码将抛出 `variable is void` 错误,因为 `other-functioin` 无法识别变量 `a`。如果你使用的是其它编程语言,这才是你所期望的行为。 + +启用词法绑定后,作用域会由周围的代码所定义。这并不单单是性能原因,时间也已经表明了词法绑定才是更受喜爱的。 + +### 特殊变量与动态绑定 + +如你所知,`let` 用于临时建立局部绑定: + +``` +(let ((a "I'm a") +      (b "I'm b")) +  (message "Hello, %s. Hello %s" a b)) +``` + +接下来有趣的是——使用 `defcustom`、`defvar` 以及 `defconst` 定义的变量被称为*特殊变量*,不论词法绑定是否启用,它们都将使用动态绑定: + +``` +;;; -*- lexical-binding: t; -*- + +(defun some-other-function () +  (message "I see `c', its value is: %s" c)) + +(defvar c t) + +(let ((a "I'm lexically bound") +      (c "I'm special and therefore dynamically bound")) +  (some-other-function) +  (message "I see `a', its values is: %s" a)) +``` + +通过 `C-h e` 切换至 `Messages` 缓冲区,查看上述示例输出的消息。 + +使用 `let` 或者函数参数绑定的局部变量会遵循由 `lexical-binding` 变量定义的查找规则,但使用 `defvar`、`defconst` 或 `defcustom` 定义的全局变量,能够沿着调用栈在 `let` 表达式中被修改。 + +这种技巧允许方便地进行特殊定制,并且经常在 Emacs 中被使用。这并不奇怪,毕竟 Emacs Lisp 最开始只提供动态绑定作为唯一选择。下面是一个常见的示例,说明如何向只读缓冲区临时写入数据: + +``` +(let ((inhibit-read-only t)) +  (insert ...)) +``` + +这是另一个常见的示例,如何进行大小写敏感的搜索: + +``` +(let ((case-fold-search nil)) +  (some-function-which-uses-search ...)) +``` + +动态绑定允许你采用作者未曾预料的方式对函数进行修改。对于像 Emacs 这样设计使用的程序来说,这是个强大的工具与特性。 + +有一点需要注意:你可能会意外地使用局部变量名,该变量在其他地方被声明为特殊变量。防止这种冲突的一个技巧是避免在局部变量名中使用下划线。在我当前的 Emacs 会话中,以下代码只留下少数潜在冲突的候选: + +``` +(let ((vars ())) + (mapatoms + (lambda (cand) + (when (and (boundp cand) + (not (keywordp cand)) + (special-variable-p cand) + (not (string-match "-" + (symbol-name cand)))) + (push cand vars)))) + vars) ;; => (t obarray noninteractive debugger nil) +``` + +### 缓冲区局部变量 + +每个缓冲区都能够拥有变量的一个局部绑定。这就意味着对于任何变量,都会首先在当前缓冲区中查找缓冲区局部变量取代默认值。局部变量是 Emacs 中一个非常重要的特性,比如它们被主模式用来建立缓冲区范围内的行为与设置。 + +事实上你已经在本文中见过*缓冲区局部变量*——也就是将 `lexical-binding` 在缓冲区范围内设置为 `t` 的特殊注释行。在 Emacs 中,在特殊注释行中定义的缓冲区局部变量也被称为*文件局部变量*。 + +任何的全局变量都可以用缓冲区局部变量来遮掩,比如上面定义的变量 `my-var`,你可用如下方式设置局部变量: + +``` +(setq-local my-var t) +;; or (set (make-local-variable 'my-var) t) +``` + +此时 `my-var` 对于你在对上述代码进行求值时对应的缓冲区来说就是局部变量。若你对它调用 `describe-variable`,文档会同时告诉你局部与全局的值。从编程的角度来讲,你可以分别用 `buffer-local-value` 获取局部值,用 `default-value` 获取全局值。若要移除局部值,你可以调用 `kill-local-variable`。 + +另一个需要注意的重要性质就是,一旦一个变量成为缓冲区局部变量,后续在该缓冲区中使用的 `setq` 都将只能设置局部的值。要想设置默认值,你需要使用 `setq-default`。 + +因为局部变量意味着对缓冲区的定制,它们也就经常被用于模式钩子中。一个典型的例子如下所示: + +``` +(add-hook 'go-mode-hook +          (defun go-setup+ () +            (setq-local compile-command +              (if (string-suffix-p "_test.go" buffer-file-name) +                  "go test -v" +                (format "go run %s" +                        (shell-quote-argument +                         (file-name-nondirectory buffer-file-name))))))) +``` + +这将设置 `go-mode` 缓冲区中 `M-x compile` 使用的编译命令。 + +另一个重要的方面就是一些变量会*自动*成为缓冲区局部变量。这也就意味着当你使用 `setq` 设置这样一个变量时,它会针对当前缓冲区设置局部绑定。这个特性不应该被经常使用,因为这种隐式的行为并不好。不过如果你想的话,你可以使用如下方法创建自动局部变量: + +``` +(defvar-local my-automatical-local-var t) +;; or (make-variable-buffer-local 'my-automatical-local-var) +``` + +变量 `indent-tabs-mode` 就是 Emacs 内建的一个例子。如果你在初始化文件中使用 `setq` 改变变量的值,根本不会影响默认值。只有在你加载初始化文件时正处在当前的缓冲区的局部值会被改变。因此,你需要使用 `setq-default` 来改变 `indent-tabs-mode` 的默认值。 + +### 结语 + +Emacs 是一个强大的编辑器,并且随着你的定制它将变得更加强大。现在,你知道了 Elisp 是如何处理变量的,以及你应如何在你自己的脚本与配置中使用它们。 + +*本篇文章此前采用 CC BY-NC-SA 4.0 许可证发布在 [With-Emacs][7] 上,经过修改(带有合并请求)并在作者允许的情况下重新发布。* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/variables-emacs + +作者:[Clemens Radermacher][a] +选题:[lujun9972][b] +译者:[cycoe](https://github.com/cycoe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clemera +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A (Programming keyboard.) +[2]: https://www.gnu.org/software/emacs/ +[3]: http://sachachua.com/blog/p/27144 +[4]: https://www.gnu.org/software/emacs/download.html +[5]: https://www.gnu.org/software/emacs/manual/html_node/elisp/ +[6]: https://github.com/jwiegley/use-package#customizing-variables +[7]: https://with-emacs.com/posts/tutorials/almost-all-you-need-to-know-about-variables/ diff --git a/published/202004/20200312 Make SSL certs easy with k3s.md b/published/202004/20200312 Make SSL certs easy with k3s.md new file mode 100644 index 0000000000..657d88123f --- /dev/null +++ b/published/202004/20200312 Make SSL certs easy with k3s.md @@ -0,0 +1,331 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12106-1.html) +[#]: subject: (Make SSL certs easy with k3s) +[#]: via: (https://opensource.com/article/20/3/ssl-letsencrypt-k3s) +[#]: author: (Lee Carpenter https://opensource.com/users/carpie) + +用 k3s 轻松管理 SSL 证书 +====== + +> 如何在树莓派上使用 k3s 和 Let's Encrypt 来加密你的网站。 + +![](https://img.linux.net.cn/data/attachment/album/202004/13/153032ncp8q55pjwdj8ppj.jpg) + +在[上一篇文章][2]中,我们在 k3s 集群上部署了几个简单的网站。那些是未加密的网站。不错,它们可以工作,但是未加密的网站有点太过时了!如今,大多数网站都是加密的。在本文中,我们将安装 [cert-manager][3] 并将其用于在集群上以部署采用 TLS 加密的网站。这些网站不仅会被加密,而且还会使用有效的公共证书,这些证书会从 [Let's Encrypt][4] 自动获取和更新!让我们开始吧! + +### 准备 + +要继续阅读本文,你将需要我们在上一篇文章中构建的 [k3s 树莓派集群][5]。另外,你需要拥有一个公用静态 IP 地址,并有一个可以为其创建 DNS 记录的域名。如果你有一个动态 DNS 提供程序为你提供域名,可能也行。但是,在本文中,我们使用静态 IP 和 [CloudFlare][6] 来手动创建 DNS 的 A 记录。 + +我们在本文中创建配置文件时,如果你不想键入它们,则可以在[此处][7]进行下载。 + +### 我们为什么使用 cert-manager? + +Traefik(在 k3s 预先捆绑了)实际上具有内置的 Let's Encrypt 支持,因此你可能想知道为什么我们要安装第三方软件包来做同样的事情。在撰写本文时,Traefik 中的 Let's Encrypt 支持检索证书并将其存储在文件中。而 cert-manager 会检索证书并将其存储在 Kubernetes 的 “机密信息secret” 中。我认为,“机密信息”可以简单地按名称引用,因此更易于使用。这就是我们在本文中使用 cert-manager 的主要原因。 + +### 安装 cert-manager + +通常,我们只是遵循 cert-manager 的[文档][8]在 Kubernetes 上进行安装。但是,由于我们使用的是 ARM 体系结构,因此我们需要进行一些更改,以便我们可以完成这个操作。 + +第一步是创建 cert-manager 命名空间。命名空间有助于将 cert-manager 的 Pod 排除在我们的默认命名空间之外,因此当我们使用自己的 Pod 执行 `kubectl get pods` 之类的操作时,我们不必看到它们。创建名称空间很简单: + +``` +kubectl create namespace cert-manager +``` + +安装说明会让你下载 cert-manager 的 YAML 配置文件并将其一步全部应用到你的集群。我们需要将其分为两个步骤,以便为基于 ARM 的树莓派修改文件。我们将下载文件并一步一步进行转换: + +``` +curl -sL \ +https://github.com/jetstack/cert-manager/releases/download/v0.11.0/cert-manager.yaml |\ +sed -r 's/(image:.*):(v.*)$/\1-arm:\2/g' > cert-manager-arm.yaml +``` + +这会下载配置文件,并将包含的所有 docker 镜像更新为 ARM 版本。来检查一下它做了什么: + +``` +$ grep image: cert-manager-arm.yaml +          image: "quay.io/jetstack/cert-manager-cainjector-arm:v0.11.0" +          image: "quay.io/jetstack/cert-manager-controller-arm:v0.11.0" +          image: "quay.io/jetstack/cert-manager-webhook-arm:v0.11.0" +``` + +如我们所见,三个镜像现在在镜像名称上添加了 `-arm`。现在我们有了正确的文件,我们只需将其应用于集群: + +``` +kubectl apply -f cert-manager-arm.yaml +``` + +这将安装 cert-manager 的全部。我们可以通过 `kubectl --namespace cert-manager get pods` 来检查安装何时完成,直到所有 Pod 都处于 `Running` 状态。 + +这就完成了 cert-manager 的安装! + +### Let's Encrypt 概述 + +Let's Encrypt 的好处是,它免费为我们提供了经过公共验证的 TLS 证书!这意味着我们可以拥有一个完全有效的、可供任何人访问的 TLS 加密网站,这些家庭或业余的爱好活动挣不到钱,也无需自己掏腰包购买 TLS 证书!以及,当通过 cert-manager 使用 Let's Encrypt 的证书时,获得证书的整个过程是自动化的,证书的续订也是自动的! + +但它是如何工作的?下面是该过程的简化说明。我们(或代表我们的 cert-manager)向 Let's Encrypt 发出我们拥有的域名的证书请求。Let's Encrypt 通过使用 ACME DNS 或 HTTP 验证机制来验证我们是否拥有该域。如果验证成功,则 Let's Encrypt 将向我们提供证书,这些证书将由 cert-manager 安装在我们的网站(或其他 TLS 加密的端点)中。在需要重复此过程之前,这些证书可以使用 90 天。但是,cert-manager 会自动为我们更新证书。 + +在本文中,我们将使用 HTTP 验证方法,因为它更易于设置并且适用于大多数情况。以下是幕后发生的基本过程。cert-manager 向 Let's Encrypt 发出证书请求。作为回应,Let's Encrypt 发出所有权验证的质询challenges。这个质询是将一个 HTTP 资源放在请求证书的域名下的一个特定 URL 上。从理论上讲,如果我们可以将该资源放在该 URL 上,并且让 Let's Encrypt 可以远程获取它,那么我们实际上必须是该域的所有者。否则,要么我们无法将资源放置在正确的位置,要么我们无法操纵 DNS 以使 Let's Encrypt 访问它。在这种情况下,cert-manager 会将资源放在正确的位置,并自动创建一个临时的 `Ingress` 记录,以将流量路由到正确的位置。如果 Let's Encrypt 可以读到该质询要求的资源并正确无误,它将把证书发回给 cert-manager。cert-manager 将证书存储为“机密信息”,然后我们的网站(或其他任何网站)将使用这些证书通过 TLS 保护我们的流量。 + +### 为该质询设置网络 + +我假设你要在家庭网络上进行设置,并拥有一个以某种方式连接到更广泛的互联网的路由器/接入点。如果不是这种情况,则可能不需要以下过程。 + +为了使质询过程正常运行,我们需要一个我们要申请证书的域名,以将其路由到端口 80 上的 k3s 集群。为此,我们需要告诉世界上的 DNS 系统它的位置。因此,我们需要将域名映射到我们的公共 IP 地址。如果你不知道你的公共 IP 地址是什么,可以访问 [WhatsMyIP][9] 之类的地方,它会告诉你。接下来,我们需要输入 DNS 的 A 记录,该记录将我们的域名映射到我们的公共 IP 地址。为了使此功能可靠地工作,你需要一个静态的公共 IP 地址,或者你可以使用动态 DNS 提供商。一些动态 DNS 提供商会向你颁发一个域名,你可以按照以下说明使用它。我没有尝试过,所以不能肯定地说它适用于所有提供商。 + +对于本文,我们假设有一个静态公共 IP,并使用 CloudFlare 来设置 DNS 的 A 记录。如果愿意,可以使用自己的 DNS 服务器。重要的是你可以设置 A 记录。 + +在本文的其余部分中,我将使用 [k3s.carpie.net][10] 作为示例域名,因为这是我拥有的域。你显然会用自己拥有的任何域名替换它。 + +为示例起见,假设我们的公共 IP 地址是 198.51.100.42。我们转到我们的 DNS 提供商的 DNS 记录部分,并添加一个名为 [k3s.carpie.net][10] 的类型为 `A` 的记录(CloudFlare 已经假定了域的部分,因此我们只需输入 `k3s`),然后输入 `198.51.100.42` 作为 IPv4 地址。 + +![][11] + +请注意,有时 DNS 更新要传播一段时间。你可能需要几个小时才能解析该名称。在继续之前该名称必须可以解析。否则,我们所有的证书请求都将失败。 + +我们可以使用 `dig` 命令检查名称是否解析: + +``` +$ dig +short k3s.carpie.net +198.51.100.42 +``` + +继续运行以上命令,直到可以返回 IP 才行。关于 CloudFlare 有个小注释:ClouldFlare 提供了通过代理流量来隐藏你的实际 IP 的服务。在这种情况下,我们取回的是 CloudFlare 的 IP,而不是我们的 IP。但对于我们的目的,这应该可以正常工作。 + +网络配置的最后一步是配置路由器,以将端口 80 和 443 上的传入流量路由到我们的 k3s 集群。可悲的是,路由器配置页面的差异很大,因此我无法确切地说明你的外观是什么样子。大多数时候,我们需要的管理页面位于“端口转发”或类似内容下。我甚至看到过它列在“游戏”之下(显然是端口转发主要用于的游戏)!让我们看看我的路由器的配置如何。 + +![][12] + +如果你和我的环境一样,则转到 192.168.0.1 登录到路由器管理应用程序。对于此路由器,它位于 “ NAT/QoS” -> “端口转发”。在这里,我们将端口 80/TCP 协议设置为转发到 192.168.0.50(主节点 `kmaster` 的 IP)的端口 80。我们还设置端口 443 也映射到 `kmaster`。从技术上讲,这对于质询来说并不是必需的,但是在本文的结尾,我们将部署一个启用 TLS 的网站,并且需要映射 443 来进行访问。因此,现在进行映射很方便。我们保存并应用更改,应该一切顺利! + +### 配置 cert-manager 来使用 Let's Encrypt(暂存环境) + +现在,我们需要配置 cert-manager 来通过 Let's Encrypt 颁发证书。Let's Encrypt 为我们提供了一个暂存(例如用于测试)环境,以便审视我们的配置。这样它更能容忍错误和请求的频率。如果我们对生产环境做了错误的操作,我们很快就会发现自己被暂时禁止访问了!因此,我们将使用暂存环境手动测试请求。 + +创建一个文件 `letsencrypt-issuer-staging.yaml`,内容如下: + +``` +apiVersion: cert-manager.io/v1alpha2 +kind: ClusterIssuer +metadata: + name: letsencrypt-staging +spec: + acme: + # The ACME server URL + server: https://acme-staging-v02.api.letsencrypt.org/directory + # Email address used for ACME registration + email: @example.com + # Name of a secret used to store the ACME account private key + privateKeySecretRef: + name: letsencrypt-staging + # Enable the HTTP-01 challenge provider + solvers: + - http01: + ingress: + class: traefik +``` + +请确保将电子邮件地址更新为你的地址。如果出现问题或我们弄坏了一些东西,这就是 Let's Encrypt 与我们联系的方式! + +现在,我们使用以下方法创建发行者issuer: + +``` +kubectl apply -f letsencrypt-issuer-staging.yaml +``` + +我们可以使用以下方法检查发行者是否已成功创建: + +``` +kubectl get clusterissuers +``` + +`clusterissuers` 是由 cert-manager 创建的一种新的 Kubernetes 资源类型。 + +现在让我们手动请求一个测试证书。对于我们的网站,我们不需要这样做;我们只是在测试这个过程,以确保我们的配置正确。 + +创建一个包含以下内容的证书请求文件 `le-test-certificate.yaml`: + +``` +apiVersion: cert-manager.io/v1alpha2 +kind: Certificate +metadata: + name: k3s-carpie-net + namespace: default +spec: + secretName: k3s-carpie-net-tls + issuerRef: + name: letsencrypt-staging + kind: ClusterIssuer + commonName: k3s.carpie.net + dnsNames: + - k3s.carpie.net +``` + +该记录仅表示我们要使用名为 `letsencrypt-staging`(我们在上一步中创建的)的 `ClusterIssuer` 来请求域 [k3s.carpie.net][10] 的证书,并在 Kubernetes 的机密信息中名为 `k3s-carpie-net-tls` 的文件中存储该证书。 + +像平常一样应用它: + +``` +kubectl apply -f le-test-certificate.yaml +``` + +我们可以通过以下方式查看状态: + +``` +kubectl get certificates +``` + +如果我们看到类似以下内容: + +``` +NAME                    READY   SECRET                  AGE +k3s-carpie-net          True    k3s-carpie-net-tls      30s +``` + +我们走在幸福之路!(这里的关键是 `READY` 应该是 `True`)。 + +### 解决证书颁发问题 + +上面是幸福的道路。如果 `READY` 为 `False`,我们可以等等它,然后再次花点时间检查状态。如果它一直是 `False`,那么我们就有需要解决的问题。此时,我们可以遍历 Kubernetes 资源链,直到找到一条告诉我们问题的状态消息。 + +假设我们执行了上面的请求,而 `READY` 为 `False`。我们可以从以下方面开始故障排除: + +``` +kubectl describe certificates k3s-carpie-net +``` + +这将返回很多信息。通常,有用的内容位于 `Events:` 部分,该部分通常位于底部。假设最后一个事件是 `Created new CertificateRequest resource "k3s-carpie-net-1256631848`。然后我们描述describe一下该请求: + +``` +kubectl describe certificaterequest k3s-carpie-net-1256631848 +``` + +现在比如说最后一个事件是 `Waiting on certificate issuance from order default/k3s-carpie-net-1256631848-2342473830`。 + +那么,我们可以描述该顺序: + +``` +kubectl describe orders default/k3s-carpie-net-1256631848-2342473830 +``` + +假设有一个事件,事件为 `Created Challenge resource "k3s-carpie-net-1256631848-2342473830-1892150396" for domain "k3s.carpie.net"`。让我们描述一下该质询: + +``` +kubectl describe challenges k3s-carpie-net-1256631848-2342473830-1892150396 +``` + +从这里返回的最后一个事件是 `Presented challenge using http-01 challenge mechanism`。看起来没问题,因此我们浏览一下描述的输出,并看到一条消息 `Waiting for http-01 challenge propagation: failed to perform self check GET request ... no such host`。终于!我们发现了问题!在这种情况下,`no such host` 意味着 DNS 查找失败,因此我们需要返回并手动检查我们的 DNS 设置,正确解析域的 DNS,并进行所需的任何更改。 + +### 清理我们的测试证书 + +我们实际上想要使用的是域名的真实证书,所以让我们继续清理证书和我们刚刚创建的机密信息: + +``` +kubectl delete certificates k3s-carpie-net +kubectl delete secrets k3s-carpie-net-tls +``` + +### 配置 cert-manager 以使用 Let's Encrypt(生产环境) + +现在我们已经有了测试证书,是时候移动到生产环境了。就像我们在 Let's Encrypt 暂存环境中配置 cert-manager 一样,我们现在也需要对生产环境进行同样的操作。创建一个名为 `letsencrypt-issuer-production.yaml` 的文件(如果需要,可以复制和修改暂存环境的文件),其内容如下: + +``` +apiVersion: cert-manager.io/v1alpha2 +kind: ClusterIssuer +metadata: +name: letsencrypt-prod +spec: +acme: + # The ACME server URL + server: https://acme-v02.api.letsencrypt.org/directory + # Email address used for ACME registration + email: @example.com + # Name of a secret used to store the ACME account private key + privateKeySecretRef: + name: letsencrypt-prod + # Enable the HTTP-01 challenge provider + solvers: + - http01: + ingress: + class: traefik +``` + +(如果要从暂存环境进行复制,则唯一的更改是 `server:` URL。也请不要忘记修改电子邮件!) + +应用它: + +``` +kubectl apply -f letsencrypt-issuer-production.yaml +``` + +### 申请我们网站的证书 + +重要的是需要注意,我们到目前为止完成的所有步骤都只需要进行一次!而对于将来的任何其他申请,我们可以从这个说明开始! + +让我们部署在[上一篇文章][13]中部署的同样站点。(如果仍然可用,则可以修改 YAML 文件。如果没有,则可能需要重新创建并重新部署它)。 + +我们只需要将 `mysite.yaml` 的 `Ingress` 部分修改为: + +``` +--- +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: mysite-nginx-ingress + annotations: + kubernetes.io/ingress.class: "traefik" + cert-manager.io/cluster-issuer: letsencrypt-prod +spec: + rules: + - host: k3s.carpie.net + http: + paths: + - path: / + backend: + serviceName: mysite-nginx-service + servicePort: 80 + tls: + - hosts: + - k3s.carpie.net + secretName: k3s-carpie-net-tls +``` + +请注意,上面仅显示了 `mysite.yaml` 的 `Ingress` 部分。所做的更改是添加了注解 `cert-manager.io/cluster-issuer: letsencrypt-prod`。这告诉 traefik 创建证书时使用哪个发行者。 其他唯一增加的是 `tls:` 块。这告诉 traefik 我们希望在主机 [k3s.carpie.net][10] 上具有 TLS 功能,并且我们希望 TLS 证书文件存储在机密信息 `k3s-carpie-net-tls` 中。 + +请记住,我们没有创建这些证书!(好吧,我们创建了名称相似的测试证书,但我们删除了这些证书。)Traefik 将读取这些配置并继续寻找机密信息。当找不到时,它会看到注释说我们想使用 `letsencrypt-prod` 发行者来获取它。由此,它将提出请求并为我们安装证书到机密信息之中! + +大功告成! 让我们尝试一下。 + +它现在具有了加密 TLS 所有优点!恭喜你! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/ssl-letsencrypt-k3s + +作者:[Lee Carpenter][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/carpie +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_paper_folder.png?itok=eIJWac15 (Files in a folder) +[2]: https://linux.cn/article-12081-1.html +[3]: https://cert-manager.io/ +[4]: https://letsencrypt.org/ +[5]: https://linux.cn/article-12049-1.html +[6]: https://cloudflare.com/ +[7]: https://gitlab.com/carpie/k3s_using_certmanager/-/archive/master/k3s_using_certmanager-master.zip +[8]: https://cert-manager.io/docs/installation/kubernetes/ +[9]: https://whatsmyip.org/ +[10]: http://k3s.carpie.net +[11]: https://opensource.com/sites/default/files/uploads/ep011_dns_example.png +[12]: https://opensource.com/sites/default/files/uploads/ep011_router.png +[13]:https://linux.cn/article-12081-1.html +[14]: http://cert-manager.io/cluster-issuer diff --git a/published/202004/20200313 What is the internet backbone and how it works.md b/published/202004/20200313 What is the internet backbone and how it works.md new file mode 100644 index 0000000000..5e120b20da --- /dev/null +++ b/published/202004/20200313 What is the internet backbone and how it works.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (messon007) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12141-1.html) +[#]: subject: (What is the internet backbone and how it works) +[#]: via: (https://www.networkworld.com/article/3532318/what-is-the-internet-backbone-and-how-it-works.html) +[#]: author: (Tim Greene https://www.networkworld.com/author/Tim-Greene/) + +什么是互联网骨干网,它是怎样工作的 +====== + +> 一级互联网服务提供商(ISP)将其高速光纤网络连接在一起,形成互联网的骨干网,实现在不同地理区域之间高效地传输流量。 + +![](https://images.idgesg.net/images/article/2018/04/global_network_connections_by_gerd_altmann_cc0_via_pixabay_1200x800-100754306-large.jpg) + +互联网会产生大量的计算机到计算机的流量,要确保所有流量都可以在世界上任何地方之间传输,就需要大量汇聚的高速网络,这些网络统称为互联网骨干网,但是它是如何工作的呢? + +### 互联网的骨干网是什么? + +像任何其他网络一样,互联网由接入链路组成,这些接入链路将流量传输到高带宽路由器,路由器又将流量从源地址通过最佳可用路径传输到目的地址。其核心是由相互连接的、彼此对等的各个高速光纤网络而构成的互联网骨干网。 + +单个独立的核心网络由一级互联网服务提供商(ISP)所拥有。他们的网络连接在一起。这些提供商包括 AT&T、CenturyLink、Cogent Communications,、Deutsche Telekom、Global Telecom and Technology (GTT)、NTT Communications、Sprint、Tata Communications,、Telecom Italia Sparkle、Telia Carrier和 Verizon。 + +通过将这些长途网连接在一起,一级 ISP 们创建了一个他们可以访问整个路由表的单一的全球性网络,因此他们可以通过逐步层次化地增加本地 ISP 网络来有效地将流量传输到其目的地。 + +除了物理连接之外,这些骨干网提供商还通过一致的网络协议 TCP/IP 融合在一起,这实际上是两个协议,传输控制协议transport control protocol互联网协议internet protocol,它们在计算机之间建立连接,以确保连接可靠,并将消息格式化为数据包。 + +### 互联网交接点(IXP)将骨干网连接在一起 + +骨干网 ISP 在中立位置的对等点通过高速交换机和路由器连接其网络。这些通常由第三方(有时是非营利组织)提供,以促进骨干网的统一。 + +参与的一级 ISP 会帮助资助 IXP,但不向其他一级 ISP 收取流量传输费用,这种关系称为无结算对等。这种协议消除了可能导致互联网性能下降的潜在财务纠纷。 + +### 骨干网有多快? + +互联网骨干网由最快的路由器组成,可以提供 100Gbps 的线路速度。这些路由器由包括 Cisco、Extreme、华为、Juniper 和 Nokia 在内的供应商制造,使用边界网关协议(BGP)在彼此之间路由流量。 + +### 流量是如何进入骨干网的 + +在 1 级 ISP 之下是规模较小的 2 级和 3 级 ISP。 + +3 级 ISP 为企业和消费者提供了互联网接入服务。这些提供商自己没有接入互联网骨干网,因此,他们自己无法将其客户连接到数十亿台互联网上的计算机。 + +购买一级 ISP 提供商的接入非常昂贵。通常 3 级 ISP 与拥有自己网络的 2 级(区域)ISP 签订合同,利用 2 级 ISP 的网络将流量传输到有限的地理区域,但不能传输到所有互联网上的设备。 + +为此,2 级 ISP 与 1 级 ISP 签约以访问全球骨干网,并以这种方式使客户可以访问整个互联网。 + +这种方式使得来自世界一侧的计算机的流量能够连接到另一侧的计算机。流量从源计算机流向 3 级 ISP,再路由到 2 级 ISP,再路由到 1 级骨干网提供商,再路由到正确的 2 级 ISP,最后路由到提供该数据的 3 级接入提供商连接的目标计算机。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3532318/what-is-the-internet-backbone-and-how-it-works.html + +作者:[Tim Greene][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Tim-Greene/ +[b]: https://github.com/lujun9972 +[1]: https://pixabay.com/en/social-media-digitization-faces-3271592/ +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.networkworld.com/article/3440100/take-the-intelligent-route-with-consumption-based-storage.html?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE21620&utm_content=sidebar ( Take the Intelligent Route with Consumption-Based Storage) +[5]: https://www.facebook.com/NetworkWorld/ +[6]: https://www.linkedin.com/company/network-world diff --git a/published/202004/20200320 Build a private social network with a Raspberry Pi.md b/published/202004/20200320 Build a private social network with a Raspberry Pi.md new file mode 100644 index 0000000000..8e9faaa8cc --- /dev/null +++ b/published/202004/20200320 Build a private social network with a Raspberry Pi.md @@ -0,0 +1,341 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12120-1.html) +[#]: subject: (Build a private social network with a Raspberry Pi) +[#]: via: (https://opensource.com/article/20/3/raspberry-pi-open-source-social) +[#]: author: (Giuseppe Cassibba https://opensource.com/users/peppe8o) + +用树莓派搭建一个私人社交网络 +====== + +> 手把手教你怎样以低成本的硬件和简易步骤搭建自己的社交网络。 + +![Team of people around the world][1] + +近年来,社交网络已经革新了人们的生活习惯。人们每天都会使用社交频道与朋友和家人联系。但是涉及到隐私和数据安全时,仍有一些共同的问题。尽管社交网络创建了复杂的隐私策略来保护用户的信息,但如果你不想自己的信息被泄露,最好的办法还是把数据保存在自己的服务器上。 + +一个树莓派 — 多才多艺的 Raspbian Lite 版本就可以让你搭建很多有用的家庭服务(参照我的文章[树莓派项目][2])。通过搜索开源软件你就可以实现一些令人痴迷的功能,你也可以用这个神奇的设备来感受那些功能。其中一个有趣的尝试就是在你的树莓派上安装 OSSN。 + +### OSSN 是什么? + +[开源社交网络][3]OpenSource Social Network(OSSN)是用 PHP 写的一个快速开发社交网络软件,让你可以搭建自己的社交网站。OSSN 可以用来搭建不同类型的社交应用,如: + + * 私人内部网 + * 公用/公开网络 + * 社区 + +OSSN 支持的功能: + + * 照片 + * 个人资料 + * 朋友圈 + * 表情 + * 搜索 + * 聊天 + +OSSN 运行在 LAMP 服务器上。硬件需求很简单,却能提供强大的用户界面,也友好支持移动端。 + +### 我们需要准备什么 + +这个项目很简单,而且由于我们只安装远程 Web 服务,因此我们只需要一些便宜的零件就够了。我使用的是树莓派 3B+,但是用树莓派 3A+ 或其他更新的板应该也可以。 + +硬件: + + * 带有电源模块的树莓派 3B+ + * 一张 SD 卡(最好是性能好点的卡,至少 16 GB) + * 一台有 SFTP 软件(如免费的 [Filezilla][4])的桌面 PC,用来把安装包传到你的树莓派上 + +### 操作步骤 + +我们首先搭建一个传统的 LAMP 服务器,然后配置数据库用户和安装 OSSN。 + +#### 1、安装 Raspbian Buster Lite 操作系统 + +你可以直接参照我的文章[在你的树莓派上安装 Raspbian Buster Lite][5]。 + +为了确保你的系统是最新的,ssh 登录到树莓派后在终端输入下面的命令: + +```bash +sudo apt-get update +sudo apt-get upgrade +``` + +#### 2、安装 LAMP 服务 + +LAMP(Linux–Apache–Mysql–Php)服务通常与 MySQL 数据库配合。在我们的项目中,我们选择 MariaDB,因为它更轻量,完美支持树莓派。 + +安装 Apache 服务: + +``` +sudo apt-get install apache2 -y +``` + +你可以通过在浏览器输入 `http://<>` 来检查 Apache 是否安装正确: + +![][6] + +安装 PHP: + +``` +sudo apt-get install php -y +``` + +安装 MariaDB 服务和 PHP connector: + +``` +sudo apt-get install mariadb-server php-mysql -y +``` + +安装 phpMyAdmin: + +在 OSSN 中 phpMyAdmin 不是强制安装的,但我建议你安装,因为它可以简化数据库的管理。 + +``` +sudo apt-get install phpmyadmin +``` + +在 phpMyAdmin 配置界面,执行以下步骤: + + * 按下空格和 “OK” 选择 apache(强制)。 + * 在 dbconfig-common 选择“Yes”,配置 phpMyAdmin 的数据库。 + * 输入想设置的密码,按下 “OK”。 + * 再次输入 phpMyAdmin 密码来确认,按下 “OK”。 + +为 phpMyAdmin 用户添加数据库权限来管理数据库: + +我们用 root 用户连接 MariaDB(默认没有密码)来设置权限。 + +``` +sudo mysql -uroot -p +grant all privileges on *.* to 'phpmyadmin'@'localhost'; +flush privileges; +quit +``` + +最后,重启 Apache 服务: + +``` +sudo systemctl restart apache2.service +``` + +在浏览器输入 `http://<>/phpmyadmin/` 来检查 phpMyAdmin 是否正常: + +![][7] + +默认的 phpMyAdmin 登录凭证: + + * 用户名:`phpmyadmin` + * 密码:在 phpMyAdmin 安装步骤中你设置的密码 + +#### 3、安装 OSSN 所需的其他包和配置 PHP + +在第一次配置 OSSN 前,我们还需要在系统上安装一些所需的包: + + * PHP 版本 5.6、7.0 或 7.1 + * MYSQL 5 及以上 + * APACHE + * MOD_REWRITE + * 需要打开 PHP 扩展 cURL 和 Mcrypt + * PHP GD 扩展 + * PHP ZIP 扩展 + * 打开 PHP 设置 `allow_url_fopen` + * PHP JSON 支持 + * PHP XML 支持 + * PHP OpenSSL + +在终端输入以下命令来安装上述包: + +``` +sudo apt-get install php7.3-curl php7.3-gd php7.3-zip php7.3-json php7.3-xml +``` + +打开 mod_rewrite: + +``` +sudo a2enmod rewrite +``` + +修改默认的 Apache 配置,使用 mod_rewrite: + +``` +sudo nano /etc/apache2/sites-available/000-default.conf +``` + +在 `000-default.conf` 文件中添加下面的内容: + +```ini + + ServerAdmin webmaster@localhost + DocumentRoot /var/www/html + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + # 需要添加的部分开始 -------------------------------- + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Require all granted + + # 需要添加的部分结束 -------------------------------- + +``` + +安装 Mcrypt: + +```bash +sudo apt install php-dev libmcrypt-dev php-pear +sudo pecl channel-update pecl.php.net +sudo pecl install mcrypt-1.0.2 +``` + +打开 Mcrypt 模块: + +在 `/etc/php/7.3/apache2/php.ini` 文件中 `extension=mcrypt.so`(或取消注释): + +```bash +sudo nano /etc/php/7.3/apache2/php.ini +``` + +`allow_url_fopen` 应该已经在 `/etc/php/7.3/apache2/php.ini` 文件中打开了。OpenSSL 应该在 php7.3 中安装了。 + +我建议的另一个设置是把 PHP 最大上传文件数修改为 16 MB: + +``` +sudo nano /etc/php/7.3/apache2/php.ini +``` + +搜索到 `upload_max_filesize` 所在的行,参照下面的设置: + +``` +upload_max_filesize = 16M +``` + +保存并退出,重启 Apache: + +``` +sudo systemctl restart apache2.service +``` + +#### 4、安装 OSSN + +##### 创建数据库,设置用户 + +回到 phpmyadmin web 页面(浏览器输入 `http://<>/phpmyadmin/`)并登录: + +- 用户名: `phpmyadmin` +- 密码:在 phpMyAdmin 安装步骤中你设置的密码 + +点击数据库标签页: + +![][8] + +创建一个数据库,记下数据库的名字,因为在之后的安装过程中,你要手动输入它。 + +![][9] + +现在为 OSSN 创建一个数据库用户,我使用下面的凭证: + +- 用户名: `ossn_db_user` +- 密码: `ossn_db_password` + +在终端输入下面的命令(如果你没有修改过密码,root 密码应该仍然是空): + +```bash +sudo mysql -uroot -p +CREATE USER 'ossn_db_user'@'localhost' IDENTIFIED BY 'ossn_db_password'; +GRANT ALL PRIVILEGES ON ossn_db.* TO 'ossn_db_user'@'localhost'; +flush privileges; +quit +``` + +##### 安装 OSSN 软件 + +在你 PC 上从 [OSSN 下载页面][10] 下载 OSSN 安装压缩文件,保存为文件 `ossn-v5.2-1577836800.zip`。 + +使用你习惯的 SFTP 软件把整个压缩文件通过 SFTP 传到树莓派的新目录 `/home/pi/download` 下。常用的(默认)SFP 连接参数是: + + * 主机:你树莓派的 IP 地址 + * 用户名:`pi` + * 密码:raspberry(如果没有修改过默认密码) + * 端口: 22 + +在终端输入: + +```bash +cd /home/pi/download/ # 进入上传的 OSSN 安装文件的目录。 +unzip ossn-v5.2-1577836800.zip # 从压缩包中提取所有文件 +cd /var/www/html/ # 进入 Apache Web 目录 +sudo rm index.html # 删除 Apache 默认页面 - 我们将使用 OSSN +sudo cp -R /home/pi/download/ossn-v5.2-1577836800/* ./ #Copy installation files to web directory +sudo chown -R www-data:www-data ./ +``` + +创建数据文件夹:OSSN 需要一个文件夹来存放数据。出于安全目的,OSSN 建议这个文件夹创建在公开文档根目录之外。所以,我们在 `/opt` 下创建。 + +```bash +sudo mkdir /opt/ossn_data +sudo chown -R www-data:www-data /opt/ossn_data/ +``` + +在浏览器输入 `http://<>` 来开始安装向导。 + +![][11] + +所有项都检查完后,点击页面最下面的下一步按钮。 + +![][12] + +阅读证书验证并点击页面最下面的下一步按钮来接受证书。 + +![][13] + +输入数据库用户名,密码和你选择的数据库名字,记得也要输入 OSSN 数据文件夹名称。点击安装。 + +![][14] + +输入你的管理员账号信息,点击创建按钮。 + +![][15] + +现在所有的工作应该都完成了。点击结束,进入管理员首页。 + +![][16] + +你可以通过 URL `http://<>/administrator` 进入管理员控制面板,普通用户可以访问链接是 `http://<>`。 + +![][17] + +本文首发在 [peppe8o.com][18]。已获得转载授权。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/raspberry-pi-open-source-social + +作者:[Giuseppe Cassibba][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/peppe8o +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_global_people_gis_location.png?itok=Rl2IKo12 (Team of people around the world) +[2]: https://peppe8o.com/2019/04/best-raspberry-pi-projects-with-open-source-software/ +[3]: https://www.opensource-socialnetwork.org/ +[4]: https://filezilla-project.org/ +[5]: https://peppe8o.com/2019/07/install-raspbian-buster-lite-in-your-raspberry-pi/ +[6]: https://opensource.com/sites/default/files/uploads/ossn_1_0.jpg +[7]: https://opensource.com/sites/default/files/uploads/ossn_2.jpg +[8]: https://opensource.com/sites/default/files/uploads/ossn_3.jpg +[9]: https://opensource.com/sites/default/files/uploads/ossn_4.jpg +[10]: https://www.opensource-socialnetwork.org/download +[11]: https://opensource.com/sites/default/files/uploads/ossn_5.jpg +[12]: https://opensource.com/sites/default/files/uploads/ossn_6.jpg +[13]: https://opensource.com/sites/default/files/uploads/ossn_7.jpg +[14]: https://opensource.com/sites/default/files/uploads/ossn_8.jpg +[15]: https://opensource.com/sites/default/files/uploads/ossn_9.jpg +[16]: https://opensource.com/sites/default/files/uploads/ossn_10.jpg +[17]: https://opensource.com/sites/default/files/uploads/ossn_11.jpg +[18]: https://peppe8o.com/private-social-network-with-raspberry-pi-and-opensource-social-network/ diff --git a/published/202004/20200320 Control the firewall at the command line.md b/published/202004/20200320 Control the firewall at the command line.md new file mode 100644 index 0000000000..4cf7283963 --- /dev/null +++ b/published/202004/20200320 Control the firewall at the command line.md @@ -0,0 +1,134 @@ +[#]: collector: "lujun9972" +[#]: translator: "tinyeyeser" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12103-1.html" +[#]: subject: "Control the firewall at the command line" +[#]: via: "https://fedoramagazine.org/control-the-firewall-at-the-command-line/" +[#]: author: "Paul W. Frields https://fedoramagazine.org/author/pfrields/" + +在 Fedora 命令行下玩转防火墙 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/12/123040ghxuicphyhsoppch.jpg) + +网络防火墙,顾名思义:为了阻止不需要的网络连接而设置的防护性屏障。在与外界建立连接或是提供网络服务时常常会用到。例如,在学校或是咖啡厅里使用笔记本电脑时,你一定不想某个陌生人窥探你的电脑。 + +每个 Fedora 系统都内置了一款防火墙。这是 Linux 内核网络功能的一部分。本文介绍如何通过 `firewall-cmd` 命令修改防火墙的配置。 + +### 网络基础 + +本文并不教授计算机网络的[所有知识][2],但还是会简单介绍一些网络基础。 + +网络中的所有计算机都有一个 *IP 地址*,可以把它想象成一个邮箱地址,有了邮箱地址,邮件才知道发往何处。每台计算机还会拥有一组*端口*,端口号范围从 0 到 65535。同样的,你可以把这些端口想象成用来连接邮箱地址的连接点。 + +通常情况下,端口会是一个标准端口号或是根据应用程序的应答要求选定的一个端口范围。例如,一台 Web 服务器通常会保留 80 端口用于 HTTP 通信,443 端口用于 HTTPS。小于 1024 的端口主要用于系统或常见用途,1024-49151 端口是已经注册的,49152 及以上端口多为临时使用(只限短时间使用)。 + +互联网传输中最常见的两个协议,[TCP][4] 和 [UDP][5]。当要传输的数据很重要,不能有丢包时,就使用 TCP 协议,如果数据包没有按顺序到达,还需要重组为正确的顺序。UDP 协议则更多用于对时间敏感的服务,为了保证时效性,有时允许丢失部分数据。 + +系统中运行的应用,例如 Web 服务器,会保留一些端口(例如上文提到的 80 和 443)。在网络传输过程中,主机会为传输的两端建立一个链接,一端是源地址和源端口,另一端是目的地址和目的端口。 + +网络防火墙就是基于地址、端口及其他标准的一组规则集,来对网络数据的传输进行屏蔽或阻断的。通过 `firewall-cmd` 命令,我们就可以查看或修改防火墙的工作配置。 + +### 防火墙域(zone) + +为了验证防火墙是否开启,使用 `firewall-cmd` 命令,输入时要加上 [sudo](https://fedoramagazine.org/howto-use-sudo/)。(通常,在运行了 [PolicyKit](https://en.wikipedia.org/wiki/Polkit) 的环境中,你也可以不加 `sudo`) + +``` +$ sudo firewall-cmd --state +running +``` + +firewalld 服务支持任意数量的域。每个域都可以拥有独立的配置和防护规则。一台 Fedora 工作站的外部接口(例如 WIFI 或有线网卡)其默认域为 `FedoraWorkstation`。 + +要看有哪些域是激活状态,可以使用 `-–get-active-zones` 选项。在本示例中,有两个网卡,有线以太网卡 `wlp2s0` 和虚拟(libvirt)桥接网卡 `virbr0`: + +``` +$ sudo firewall-cmd --get-active-zones +FedoraWorkstation + interfaces: wlp2s0 +libvirt + interfaces: virbr0 +``` + +如果想看看默认域是什么,或是直接查询所有域: + +``` +$ sudo firewall-cmd --get-default-zone +FedoraWorkstation +$ sudo firewall-cmd --get-zones +FedoraServer FedoraWorkstation block dmz drop external home internal libvirt public trusted work +``` + +查询默认域中防火墙放行了哪些系统,使用 `-–list-services` 选项。下例给出了一个定制系统的查询结果,你可以看到与常见的结果有些不同。 + +``` +$ sudo firewall-cmd --list-services +dhcpv6-client mdns samba-client ssh +``` + +该系统对外开启了四个服务。每个服务都对应一个常见端口。例如 `ssh` 服务对应 22 端口。 + +如果要查看当前域中防火墙还开启了哪些端口,可以使用 `--list-ports` 选项。当然,你也可以随时对其他域进行查询: + +``` +$ sudo firewall-cmd --list-ports --zone=FedoraWorkstation +1025-65535/udp 1025-65535/tcp +``` + +结果表明,从 1025 到 65535 端口(包含 UDP 和 TCP)默认都是开启的。 + +### 修改域、端口及服务 + +以上的配置都是预先设计好的防火墙策略。是为了确保新手用户安装的应用都能够正常访问网络。如果你确定自己心里有数,想要一个保护性更强的策略,可以将接口放入 `FedoraServer` 域,明确禁止所有端口的访问。(**警告**:如果你的服务器之前是联网状态,这么做可能会导致连接中断,那你就得到机房里去修改更多的配置项!) + +``` +$ sudo firewall-cmd --change-interface= --zone=FedoraServer +success +``` + +**本文并不讨论如何制定防火墙策略,Fedora 社区里已经有很多讨论了。你大可以按照自身需要来修改配置。** + +如果你想要开放某个服务的常见端口,可以将该服务加入默认域(或使用 `--zone` 指定一个不同的域)。还可以一次性将其加入多个域。下例开放了 HTTP 和 HTTPS 的常见端口 80、443: + +``` +$ sudo firewall-cmd --add-service=http --add-service=https +success +``` + +并非所有的服务都有默认端口,不过大部分都是有的。使用 `-–get-services` 选项可以查看完整列表。 + +如果你想指定某个特定端口号,可以直接用数字和协议进行配置。(多数情况下,`-–add-service` 和 `-–add-port` 这两个选项是合在一起使用的)下例开启的是 UDP 协议的网络启动服务: + +``` +$ sudo firewall-cmd --add-port=67/udp +success +``` + +**重要**:如果想要在系统重启或是 firewalld 服务重启后,配置仍然生效,**必须**在命令中加上 `-–permanent` 选项。本文中的例子只是临时修改了配置,下次遇到系统重启或是 firewalld 服务重启,这些配置就失效了。 + +以上只是 `firewall-cmd` 和 firewalld 服务诸多功能中的一小部分。firewalld 项目的[主页][8]还有更多信息值得你去探索和尝试。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/control-the-firewall-at-the-command-line/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[tinyeyeser](https://github.com/tinyeyeser) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/03/firewall-cmd-816x345.jpg +[2]: https://en.wikipedia.org/wiki/Portal:Internet +[3]: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers +[4]: https://en.wikipedia.org/wiki/Transmission_Control_Protocol +[5]: https://en.wikipedia.org/wiki/User_Datagram_Protocol +[6]: https://fedoramagazine.org/howto-use-sudo/ +[7]: https://en.wikipedia.org/wiki/Polkit +[8]: https://firewalld.org/ +[9]: https://unsplash.com/@jakobustrop?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[10]: https://unsplash.com/s/photos/brick-wall?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202004/20200320 How to Check Password Expiration Date for All Users on Linux.md b/published/202004/20200320 How to Check Password Expiration Date for All Users on Linux.md new file mode 100644 index 0000000000..1633f32694 --- /dev/null +++ b/published/202004/20200320 How to Check Password Expiration Date for All Users on Linux.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12062-1.html) +[#]: subject: (How to Check Password Expiration Date for All Users on Linux) +[#]: via: (https://www.2daygeek.com/linux-check-user-password-expiration-date/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Linux 上检查所有用户密码到期日期 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/01/104918dn0n0anhxoia40rc.jpg) + +如果你在 [Linux 上启用了密码策略][1]。密码必须在到期前进行更改,并且登录到系统时会收到通知。 + +如果你很少使用自己的帐户,那么可能由于密码过期而被锁定。在许多情况下,这可能会在[无需密码登录][2]的服务帐户中发生,因为没人会注意到它。 + +这将导致停止服务器上配置的 [cronjob/crontab][3]。 + +如果如此,该如何缓解这种情况。 + +你可以写一个 shell 脚本来获得有关它的通知,我们前一段时间为此写了一篇文章。 + + * [使用 Bash 脚本发送包含几天内到期的用户账号列表的电子邮件][5] + +它将给出天数,但是本文旨在在终端中给你实际日期。 + +这可以使用 `chage` 命令来实现。 + +### 什么是 chage 命令? + +`chage` 代表更改时效change age。它更改用户密码到期信息。 + +`chage` 命令可以修改两次密码更改之间的天数,以及最后一次更改密码的日期。 + +系统使用此信息来确定用户何时应更改密码。 + +它还允许用户执行其他功能,例如设置帐户到期日期、在到期后将密码设置为无效、显示帐户时效信息、设置密码更改之前的最小和最大天数以及设置到期警告天数。 + +### 1)如何在 Linux 上检查特定用户的密码到期日期 + +如果要检查 Linux 上特定用户的密码到期日期,请使用以下命令。 + +``` +# chage -l daygeek + +Last password change : Feb 13, 2020 +Password expires : May 13, 2020 +Password inactive : never +Account expires : never +Minimum number of days between password change : 7 +Maximum number of days between password change : 90 +Number of days of warning before password expires : 7 +``` + +### 2)如何在 Linux 上检查所有用户的密码到期日期 + +你可以直接对单个用户使用 chage 命令,不过可能你对多个用户使用时可能无效。 + +为此,你需要编写一个小的 shell 脚本。下面的 shell 脚本可以列出添加到系统中的所有用户,包括系统用户。 + +``` +# for user in $(cat /etc/passwd |cut -d: -f1); do echo $user; chage -l $user | grep "Password expires"; done | paste -d " " - - | sed 's/Password expires//g' +``` + +你将得到类似以下的输出,但是用户名可能不同。 + +``` +root : never +bin : never +daemon : never +adm : never +lp : never +sync : never +shutdown : never +u1 : Nov 12, 2018 +u2 : Jun 17, 2019 +u3 : Jun 17, 2019 +u4 : Jun 17, 2019 +u5 : Jun 17, 2019 +``` + +### 3)如何检查 Linux 上除系统用户外的所有用户的密码有效期 + +下面的 shell 脚本将显示有到期日期的用户列表。 + +``` +# for user in $(cat /etc/passwd |cut -d: -f1); do echo $user; chage -l $user | grep "Password expires"; done | paste -d " " - - | sed 's/Password expires//g' | grep -v "never" +``` + +你将得到类似以下的输出,但是用户名可能不同。 + +``` +u1 : Nov 12, 2018 +u2 : Jun 17, 2019 +u3 : Jun 17, 2019 +u4 : Jun 17, 2019 +u5 : Jun 17, 2019 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-check-user-password-expiration-date/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10698-1.html +[2]: https://www.2daygeek.com/configure-setup-passwordless-ssh-key-based-authentication-linux/ +[3]: https://www.2daygeek.com/linux-crontab-cron-job-to-schedule-jobs-task/ +[4]: https://www.2daygeek.com/category/shell-script/ +[5]: https://linux.cn/article-11781-1.html diff --git a/published/202004/20200323 Don-t love diff- Use Meld instead.md b/published/202004/20200323 Don-t love diff- Use Meld instead.md new file mode 100644 index 0000000000..9fd421118f --- /dev/null +++ b/published/202004/20200323 Don-t love diff- Use Meld instead.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12067-1.html) +[#]: subject: (Don't love diff? Use Meld instead) +[#]: via: (https://opensource.com/article/20/3/meld) +[#]: author: (Ben Nuttall https://opensource.com/users/bennuttall) + +不喜欢 diff 么?试试 Meld 吧 +====== + +> Meld 是一个可视化 diff 工具,它可让你轻松比较和合并文件、目录、Git 仓库等的更改。 + +![](https://img.linux.net.cn/data/attachment/album/202004/03/122428dkagz1qtgh9f2g10.jpg) + +Meld 是我处理代码和数据文件的基本工具之一。它是一个图形化的 diff 工具,因此,如果你曾经使用过 `diff` 命令并难以理解输出,那么 [Meld][2] 可以为你提供帮助。 + +这是该项目网站的精彩描述: + +>“Meld 是面向开发人员的可视化 diff 和合并工具。Meld 可以帮助你比较文件、目录和版本控制的项目。它提供文件和目录的双向和三向比较,并支持许多流行的版本控制系统。” +> +>“Meld 可以帮助你检查代码更改并了解补丁。它甚至可以帮助你弄清你一直在避免的合并中发生了什么。” + +你可以使用以下命令在 Debian/Ubuntu 系统(包括 Raspbian)上安装 Meld: + +``` +$ sudo apt install meld +``` + +在 Fedora 或类似产品上: + +``` +$ sudo dnf install meld +``` + +Meld 是跨平台的,它有一个使用 [Chocolately][4] 包管理器的 [Windows 安装包][3]。尽管它在 macOS 上不受官方支持,但有[可用于 Mac 的版本][5],你可以使用 Homebrew 安装: + +``` +$ brew cask install meld +``` + +有关[其他系统][2],请参见 Meld 的主页。 + +### Meld 对比 diff 命令 + +如果你有两个相似的文件(也许一个是另一个的修改版本),并想要查看它们之间的更改,那么可以在终端中运行 `diff` 命令查看它们的区别: + +![diff output][6] + +此例显示了 `conway1.py` 和 `conway2.py` 之间的区别。表明我: + +* 删除了[释伴][7]和第二行 +* 从类声明中删除了 `(object)` +* 为类添加了 docstring +* 在方法中交换了 `alive` 和 `neighbours == 2` 的顺序 + +这是使用 `meld` 命令的相同例子。你可以在命令行中运行以下命令进行相同的比较: + +``` +$ meld conway1.py conway2.py +``` + +![Meld output][8] + +Meld 更清晰! + +你可以轻松查看并单击箭头(左右都行)合并文件之间的更改。你甚至可以实时编辑文件(在输入时,Meld 可以用作具有实时比较功能的简单文本编辑器)—只是要记得在关闭窗口之前保存。 + +你甚至可以比较和编辑三个不同的文件: + +![Comparing three files in Meld][9] + +### Meld 的 Git 感知 + +希望你正在使用 [Git][10] 之类的版本控制系统。如果是这样,那么你的比较就不是在两个不同文件之间进行,而是要查找当前文件与 Git 历史文件之间的差异。Meld 理解这一点,因此,如果你运行 `meld conway.py`(`conway.py` 在 Git 中),它将显示自上次 Git 提交以来所做的更改: + +![Comparing Git files in Meld][11] + +你可以看到当前版本(右侧)和仓库版本(左侧)之间的更改。你可以看到,自上次提交以来,我删除了一个方法,并添加了一个参数和一个循环。 + +如果你运行 `meld .`,你将看到当前目录(如果位于仓库的根目录,就是整个仓库)中的所有更改: + +![Meld . output][12] + +你会看到一个文件被修改了,另一个文件未加入版本控制(这意味着它对 Git 是新的,因此在比较之前,我需要 `git add` 添加该文件),以及许多其他未修改的文件。顶部的图标提供了各种显示选项。 + +你还可以比较两个目录,这有时很方便: + +![Comparing directories in Meld][13] + +### 结论 + +即使是普通用户也会觉得 diff 的比较难以理解。我发现 Meld 提供的可视化在找出文件之间的更改方面有很大的不同。最重要的是,Meld 有一些有用的版本控制认知,可以帮助你在不考虑太多内容的情况下对 Git 提交进行比较。快来试试 Meld,并轻松解决问题。 + +* * * + +*本文最初发表在 Ben Nuttall 的 [Tooling blog][14] 上,并经允许重新使用。* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/meld + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_tea_laptop_computer_work_desk.png?itok=D5yMx_Dr (Person drinking a hat drink at the computer) +[2]: https://meldmerge.org/ +[3]: https://chocolatey.org/packages/meld +[4]: https://opensource.com/article/20/3/chocolatey +[5]: https://yousseb.github.io/meld/ +[6]: https://opensource.com/sites/default/files/uploads/diff-output.png (diff output) +[7]: https://en.wikipedia.org/wiki/Shebang_(Unix) +[8]: https://opensource.com/sites/default/files/uploads/meld-output.png (Meld output) +[9]: https://opensource.com/sites/default/files/uploads/meld-3-files.png (Comparing three files in Meld) +[10]: https://opensource.com/resources/what-is-git +[11]: https://opensource.com/sites/default/files/uploads/meld-git.png (Comparing Git files in Meld) +[12]: https://opensource.com/sites/default/files/uploads/meld-directory-changes.png (Meld . output) +[13]: https://opensource.com/sites/default/files/uploads/meld-directory-compare.png (Comparing directories in Meld) +[14]: https://tooling.bennuttall.com/meld/ diff --git a/published/202004/20200325 Linux firewall basics with ufw.md b/published/202004/20200325 Linux firewall basics with ufw.md new file mode 100644 index 0000000000..538d1a928a --- /dev/null +++ b/published/202004/20200325 Linux firewall basics with ufw.md @@ -0,0 +1,213 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12079-1.html) +[#]: subject: (Linux firewall basics with ufw) +[#]: via: (https://www.networkworld.com/article/3533551/linux-firewall-basics-with-ufw.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux 防火墙 ufw 简介 +====== + +> 我们来研究下 Linux 上的 ufw(简单防火墙),为你更改防火墙提供一些见解和命令。 + +![][0] + +`ufw`(简单防火墙Uncomplicated FireWall)真正地简化了 [iptables][1],它从出现的这几年,已经成为 Ubuntu 和 Debian 等系统上的默认防火墙。而且 `ufw` 出乎意料的简单,这对新管理员来说是一个福音,否则他们可能需要投入大量时间来学习防火墙管理。 + +`ufw` 也有 GUI 客户端(例如 `gufw`),但是 `ufw` 命令通常在命令行上执行的。本文介绍了一些使用 `ufw` 的命令,并研究了它的工作方式。 + +首先,快速查看 `ufw` 配置的方法是查看其配置文件 —— `/etc/default/ufw`。使用下面的命令可以查看其配置,使用 `grep` 来抑制了空行和注释(以 # 开头的行)的显示。 + +``` +$ grep -v '^#\|^$' /etc/default/ufw +IPV6=yes +DEFAULT_INPUT_POLICY="DROP" +DEFAULT_OUTPUT_POLICY="ACCEPT" +DEFAULT_FORWARD_POLICY="DROP" +DEFAULT_APPLICATION_POLICY="SKIP" +MANAGE_BUILTINS=no +IPT_SYSCTL=/etc/ufw/sysctl.conf +IPT_MODULES="nf_conntrack_ftp nf_nat_ftp nf_conntrack_netbios_ns" +``` + +正如你所看到的,默认策略是丢弃输入但允许输出。允许你接受特定的连接的其它规则是需要单独配置的。 + +`ufw` 命令的基本语法如下所示,但是这个概要并不意味着你只需要输入 `ufw` 就行,而是一个告诉你需要哪些参数的快速提示。 + +``` +ufw [--dry-run] [options] [rule syntax] +``` + +`--dry-run` 选项意味着 `ufw` 不会运行你指定的命令,但会显示给你如果执行后的结果。但是它会显示假如更改后的整个规则集,因此你要做有好多行输出的准备。 + +要检查 `ufw` 的状态,请运行以下命令。注意,即使是这个命令也需要使用 `sudo` 或 root 账户。 + +``` +$ sudo ufw status +Status: active + +To Action From +-- ------ ---- +22 ALLOW 192.168.0.0/24 +9090 ALLOW Anywhere +9090 (v6) ALLOW Anywhere (v6) +``` + +否则,你会看到以下内容: + +``` +$ ufw status +ERROR: You need to be root to run this script +``` + +加上 `verbose` 选项会提供一些其它细节: + +``` +$ sudo ufw status verbose +Status: active +Logging: on (low) +Default: deny (incoming), allow (outgoing), disabled (routed) +New profiles: skip + +To Action From +-- ------ ---- +22 ALLOW IN 192.168.0.0/24 +9090 ALLOW IN Anywhere +9090 (v6) ALLOW IN Anywhere (v6) +``` + +你可以使用以下命令轻松地通过端口号允许和拒绝连接: + +``` +$ sudo ufw allow 80 <== 允许 http 访问 +$ sudo ufw deny 25 <== 拒绝 smtp 访问 +``` + +你可以查看 `/etc/services` 文件来找到端口号和服务名称之间的联系。 + +``` +$ grep 80/ /etc/services +http 80/tcp www # WorldWideWeb HTTP +socks 1080/tcp # socks proxy server +socks 1080/udp +http-alt 8080/tcp webcache # WWW caching service +http-alt 8080/udp +amanda 10080/tcp # amanda backup services +amanda 10080/udp +canna 5680/tcp # cannaserver +``` + +或者,你可以命令中直接使用服务的名称。 + +``` +$ sudo ufw allow http +Rule added +Rule added (v6) +$ sudo ufw allow https +Rule added +Rule added (v6) +``` + +进行更改后,你应该再次检查状态来查看是否生效: + +``` +$ sudo ufw status +Status: active + +To Action From +-- ------ ---- +22 ALLOW 192.168.0.0/24 +9090 ALLOW Anywhere +80/tcp ALLOW Anywhere <== +443/tcp ALLOW Anywhere <== +9090 (v6) ALLOW Anywhere (v6) +80/tcp (v6) ALLOW Anywhere (v6) <== +443/tcp (v6) ALLOW Anywhere (v6) <== +``` + +`ufw` 遵循的规则存储在 `/etc/ufw` 目录中。注意,你需要 root 用户访问权限才能查看这些文件,每个文件都包含大量规则。 + +``` +$ ls -ltr /etc/ufw +total 48 +-rw-r--r-- 1 root root 1391 Aug 15 2017 sysctl.conf +-rw-r----- 1 root root 1004 Aug 17 2017 after.rules +-rw-r----- 1 root root 915 Aug 17 2017 after6.rules +-rw-r----- 1 root root 1130 Jan 5 2018 before.init +-rw-r----- 1 root root 1126 Jan 5 2018 after.init +-rw-r----- 1 root root 2537 Mar 25 2019 before.rules +-rw-r----- 1 root root 6700 Mar 25 2019 before6.rules +drwxr-xr-x 3 root root 4096 Nov 12 08:21 applications.d +-rw-r--r-- 1 root root 313 Mar 18 17:30 ufw.conf +-rw-r----- 1 root root 1711 Mar 19 10:42 user.rules +-rw-r----- 1 root root 1530 Mar 19 10:42 user6.rules +``` + +本文前面所作的更改,为 `http` 访问添加了端口 `80` 和为 `https` 访问添加了端口 `443`,在 `user.rules` 和 `user6.rules` 文件中看起来像这样: + +``` +# grep " 80 " user*.rules +user6.rules:### tuple ### allow tcp 80 ::/0 any ::/0 in +user6.rules:-A ufw6-user-input -p tcp --dport 80 -j ACCEPT +user.rules:### tuple ### allow tcp 80 0.0.0.0/0 any 0.0.0.0/0 in +user.rules:-A ufw-user-input -p tcp --dport 80 -j ACCEPT +You have new mail in /var/mail/root +# grep 443 user*.rules +user6.rules:### tuple ### allow tcp 443 ::/0 any ::/0 in +user6.rules:-A ufw6-user-input -p tcp --dport 443 -j ACCEPT +user.rules:### tuple ### allow tcp 443 0.0.0.0/0 any 0.0.0.0/0 in +user.rules:-A ufw-user-input -p tcp --dport 443 -j ACCEPT +``` + +使用 `ufw`,你还可以使用以下命令轻松地阻止来自一个 IP 地址的连接: + +``` +$ sudo ufw deny from 208.176.0.50 +Rule added +``` + +`status` 命令将显示更改: + +``` +$ sudo ufw status verbose +Status: active +Logging: on (low) +Default: deny (incoming), allow (outgoing), disabled (routed) +New profiles: skip + +To Action From +-- ------ ---- +22 ALLOW IN 192.168.0.0/24 +9090 ALLOW IN Anywhere +80/tcp ALLOW IN Anywhere +443/tcp ALLOW IN Anywhere +Anywhere DENY IN 208.176.0.50 <== new +9090 (v6) ALLOW IN Anywhere (v6) +80/tcp (v6) ALLOW IN Anywhere (v6) +443/tcp (v6) ALLOW IN Anywhere (v6) +``` + +总而言之,`ufw` 不仅容易配置,而且且容易理解。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3533551/linux-firewall-basics-with-ufw.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[0]: https://images.idgesg.net/images/article/2019/06/cso_network_security_encryption_automation_by_vertigo3d_gettyimages-597931354_2400x1600-100798880-large.jpg +[1]: https://www.networkworld.com/article/2716098/working-with-iptables.html +[2]: https://www.networkworld.com/article/3143050/linux/linux-hardening-a-15-step-checklist-for-a-secure-linux-server.html#tk.nww-fsb +[3]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202004/20200326 3 open source tools for sticking to a budget.md b/published/202004/20200326 3 open source tools for sticking to a budget.md new file mode 100644 index 0000000000..8504fec779 --- /dev/null +++ b/published/202004/20200326 3 open source tools for sticking to a budget.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12072-1.html) +[#]: subject: (3 open source tools for sticking to a budget) +[#]: via: (https://opensource.com/article/20/3/open-source-budget) +[#]: author: (Lauren Pritchett https://opensource.com/users/lauren-pritchett) + +3 个控制预算的开源工具 +====== + +> 在这篇开源预算工具汇总中找到适合你的解决方案。另外学习有关开源的备税务软件。 + +![](https://img.linux.net.cn/data/attachment/album/202004/05/092735ni323vgji9sbigq9.jpg) + +鉴于目前世界上许多国家/地区的经济形势都在变化,你可能会想改造或改善财务状况和你对它的了解。或者,也许你的新年决心之一是开始预算?你并不孤单。 + +坚持该决心的最佳方法是定期跟踪你的支出和收入。问题是,许多流行的个人理财应用都是专有的。你是否正在寻找 Quicken、Mint 或 You Need a Budget 的开源替代方案?无论你是开源软件新手,还是预算新手,这些工具之一都将满足你的需求和舒适度。 + +### LibreOffice Calc + +我向希望做预算的任何开源新手推荐使用 LibreOffice Calc。如果你使用过 Google Sheets 或 Microsoft Excel 等专有电子表格,那么 LibreOffice Calc 模板将非常熟悉。在此[预算教程][2]中,作者 Jess Weichler 已经为你提供了方便、可下载的模板。该模板已经有费用类别,例如水电费、杂货、外出就餐等,但是你可以自由地根据自己的生活方式对其进行自定义。在第二篇文章中,她向你展示了如何[创建自己的模板][3]。 + +### HomeBank + +对于所有的开源用户来说,HomeBank 都是另一个不错的选择。HomeBank 是免费的,但它拥有许多它同类专有软件的分析和交易功能。实际上,你可以将 Quicken 文件导入到 HomeBank 中,这使得转换到它变得轻而易举。最后,你可以使用一种工具来帮助你明智地做出有关资金的决定,而无需花费更多的钱。在 Jessica Cherry 的[教程][4]中学习如何入门。 + +### GnuCash + +就像这里提到的其他预算工具一样,GnuCash 可以在 Windows、macOS 和 Linux 上使用。它提供了大量文档,但 Don Watkins 会在[此教程][5]中指导你在 Linux 上设置 GnuCash。GnuCash 不仅是控制个人财务的绝佳选择,而且还有开发票等功能来帮助你管理小型企业。 + +### 赠品:OpenTaxSolver + +对许多美国人来说,可怕的税收季可能是一个压力很大的时期。许多人购买 TurboTax 或请会计师或税务服务来缴税。与普遍的看法相反,开源的备税务软件是存在的!作者 Jessica Cherry 在[本文][6]中做了研究,并向读者介绍 OpenTaxSolver。要正确使用 OpenTaxSolver,你需要特别注意细节,但是你不必担心进行复杂的数学运算。 + +你会尝试使用哪个开源预算应用?你是否有我在此列表中未提及的最喜欢的工具?请在评论区分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/open-source-budget + +作者:[Lauren Pritchett][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lauren-pritchett +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_whitehurst_money.png?itok=ls-SOzM0 (A dollar sign in a network) +[2]: https://opensource.com/article/20/3/libreoffice-open-source-budget +[3]: https://opensource.com/article/20/3/libreoffice-templates +[4]: https://opensource.com/article/20/2/open-source-homebank +[5]: https://opensource.com/article/20/2/gnucash +[6]: https://opensource.com/article/20/2/open-source-taxes diff --git a/published/202004/20200327 Build a private chat server with a Raspberry Pi and Rocket.Chat.md b/published/202004/20200327 Build a private chat server with a Raspberry Pi and Rocket.Chat.md new file mode 100644 index 0000000000..25a4581dd7 --- /dev/null +++ b/published/202004/20200327 Build a private chat server with a Raspberry Pi and Rocket.Chat.md @@ -0,0 +1,98 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12116-1.html) +[#]: subject: (Build a private chat server with a Raspberry Pi and Rocket.Chat) +[#]: via: (https://opensource.com/article/20/3/raspberry-pi-rocketchat) +[#]: author: (Giuseppe Cassibba https://opensource.com/users/peppe8o) + +使用树莓派和 Rocket.Chat 构建一个私人聊天服务器 +====== + +> 使用这些简单、经济高效的开源工具构建自己真正的私人聊天和消息解决方案。 + +![](https://img.linux.net.cn/data/attachment/album/202004/16/203055g5r5w7ei8eenw1ex.jpg) + +互联网提供了大量免费的消息服务。像 WhatsApp 和 Viber 这样的应用已经是我们日常生活的一部分,也是我们与亲朋好友沟通的最常见方式。但是,安全意识的提高,让人们对真正的私密聊天解决方案的需求越来越大。此外,消息类应用在我们的设备中占用了大量空间,因此一个备用聊天渠道可能对于我们与朋友分享媒体、信息和联系人很有作用。 + +今天,我们将了解如何使用[树莓派][2]和 Rocket.Chat 安装一个私人聊天和消息服务器。 + +### 什么是 Rocket.Chat? + +[Rocket.Chat][3] 是一个开源解决方案,它提供了一个增强的聊天服务。它包括媒体共享、屏幕共享和视频/音频呼叫支持等协作工具。 + +它可以通过浏览器或从所有主要应用商店(Google Play、App Store 等)下载使用。 + +除了社区版本外,Rocket.Chat 还提供企业版和专业版,包括支持和其他附加功能。 + +### 我们需要什么 + +对于这个项目,我将使用更便宜的树莓派 3A+。树莓派 3B 和 3B+ 以及树莓派 4B 应该也可以用同样的方法。 + +我也建议使用一块高性能 SD 卡,因为 Rocket.Chat 会给树莓派带来很大的负载。如其他文章中所述,高性能 SD 卡可显著提高 Raspbian 操作系统的性能。 + +我们将使用 Raspbian 的精简版本,拥有预配置的 WiFi 访问和 SSH 服务,因此不需要键盘或 HDMI 线缆。 + +### 分步过程 + +从[安装最新版本的 Raspbian Buster Lite][5] 开始。 + +我们将使用 [Snap][6] 简化 Rocket.Chat 安装。通过 SSH 登录并从终端输入: + +``` +sudo apt-get update +sudo apt-get upgrade +``` + +安装 Snap: + +``` +sudo apt-get install snapd +``` + +安装 Snap 后,我们需要重启系统使其正常工作: + +``` +sudo reboot +``` + +再次通过 SSH 登录,并用以下简单的命令安装 Rocket.Chat: + +``` +sudo snap install rocketchat-server +``` + +从终端安装后,请等待一段时间,让 Rocket.Chat 初始化数据库和服务。休息一下,几分钟后,你应该能够在浏览器中访问 `http://<>:3000`,你应该看到以下内容: + +![Rocket Chat setup wizard][7] + +填写所需的表单就可以了。经过四个简单的设置窗口后,你应该会进入 Rocket.Chat 主页: + +![Rocket Chat home page][8] + +享受吧! + +本文最初发表在 [peppe8o.com][9],并获许重新发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/raspberry-pi-rocketchat + +作者:[Giuseppe Cassibba][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/peppe8o +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_chat_communication_message.png?itok=LKjiLnQu (Chat via email) +[2]: https://opensource.com/resources/raspberry-pi +[3]: https://rocket.chat/ +[5]: https://peppe8o.com/2019/07/install-raspbian-buster-lite-in-your-raspberry-pi/ +[6]: https://snapcraft.io/ +[7]: https://opensource.com/sites/default/files/uploads/rocket-chat-setup-wizard.jpg (Rocket Chat setup wizard) +[8]: https://opensource.com/sites/default/files/uploads/rocket-chat-home.jpg (Rocket Chat home page) +[9]: https://peppe8o.com/private-chat-and-messaging-server-with-raspberry-pi-and-rocket-chat/ diff --git a/published/202004/20200329 How to install Microsoft TrueType Fonts on Ubuntu-based Distributions.md b/published/202004/20200329 How to install Microsoft TrueType Fonts on Ubuntu-based Distributions.md new file mode 100644 index 0000000000..2300ffee80 --- /dev/null +++ b/published/202004/20200329 How to install Microsoft TrueType Fonts on Ubuntu-based Distributions.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12074-1.html) +[#]: subject: (How to install Microsoft TrueType Fonts on Ubuntu-based Distributions) +[#]: via: (https://itsfoss.com/install-microsoft-fonts-ubuntu/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/itsfoss/) + +如何在基于 Ubuntu 的发行版上安装微软 TrueType 字体 +====== + +如果你在 Linux 上用 LibreOffice 打开一些微软文档,你会发现字体看起来有一点不同。你也将注意到有些常用字体找不到,如 [Times New Roman][1]、Arial 等等。 + +不用担心。我将向你展示如何在 Ubuntu 上和其它基于 Ubuntu 的 Linux 发行版上安装这些字体。但是在此之前,让我告诉你为什么这些字体没有被默认安装。 + +### 为什么微软字体不被默认安装在 Linux 中? + +![][2] + +Times New Roman、Arial 等字体都是微软的,并且这些字体不是开源的。很多 Linux 发行版默认不提供专有软件,以避免授权问题。 + +这就是为什么在默认情况下 Ubuntu 和其它 Linux 发行版使用开源字体 “Liberation” 字体来替代微软字体的原因。[Red Hat][4] 创建 [Liberation 字体][3] 来代替 Arial、Arial Narrow、 Times New Roman 和 Courier New,因为这些字体的宽度一样。当你打开一个使用 Times New Roman 字体书写的文档时,会使用对应的 Liberation 字体来保持文档不被破坏。 + +不过,Liberation 字体与微软的字体并不是完全相同的,在一些情况下,你可能需要使用 Arial 或 Times New Roman。一个非常常见的情况是,在学校、大学和其他公共或私人机构中,微软的字体是唯一的选择。他们要求你使用这些字体之一来提交文档。 + +好在,你可以在 Ubuntu 和其它发行版上很容易地安装微软字体。以这种方式,你将增强 LibreOffice 的兼容性,并可以自由选择开源办公软件。 + +### 在基于 Ubuntu 的 Linux 发行版上安装微软字体 + +你可以自行下载字体,并[在 Ubuntu 中安装新的字体][5]。但是由于微软字体非常受欢迎(并且是免费提供的),所以 Ubuntu 提供了一种简单的方法来安装它们。 + +要知道尽管微软已经免费发布了其核心字体,在其它操作系统中使用该字体依然是受到限制的。在 Ubuntu 中安装微软字体前,你必须阅读并接受 EULA (最终用户许可协议) 。 + +这些字体 [可在 multiverse 存储库中获得,首先要确保启用它][6]: + +``` +sudo add-apt-repository multiverse +``` + +在此之后,你可以更新你的 Ubuntu 存储库缓存,并像这样安装微软字体: + +``` +sudo apt update && sudo apt install ttf-mscorefonts-installer +``` + +当微软的最终用户协议出现时,按 `tab` 键来选择 “OK” ,并按回车键。 + +![按 tab 键来高亮选择][7] + +单击 “Yes” 来接受微软的协议: + +![使用 tab 键来作出选择,并按回车键][8] + +当安装完成后,你应该使用下面的命令来更新字体缓存: + +``` +sudo fc-cache -f -v +``` + +![][9] + +如果你现在打开 LibreOffice ,你将看到微软 [TrueType 字体][10] 。 + +![][11] + +如果意外地拒绝了许可协议,你可以使用这个命令来重新安装安装程序: + +``` +sudo apt install –reinstall ttf-mscorefonts-installer +``` + +微软的 TrueType 字体也可以通过 [Ubuntu Restricted Extras package][12] 获得,其包含用来播放 MP3 等文件的其它专有的多媒体编解码器。 + +> 不要轻视专有字体。 +> +> 你可能认为字体有什么大不了的呢?毕竟,它只是一款字体,而不是软件的一个关键部分,对吧?但是你知道,这些年来 [Netflix 为其使用的专有字体支付了数百万美元][13]吗?最后,他们创建了自己的自定义字体,这为他们节省了一大笔钱。 + +希望这个快速教程有用。更多的生产力教程即将上线,请在下面留下你的评论,了解更多信息请订阅我们的社交媒体! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-microsoft-fonts-ubuntu/ + +作者:[Dimitrios Savvopoulos][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/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Times_New_Roman +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/microsoft-fonts-ubuntu.png?ssl=1 +[3]: https://en.wikipedia.org/wiki/Liberation_fonts +[4]: https://en.wikipedia.org/wiki/Red_Hat +[5]: https://itsfoss.com/install-fonts-ubuntu/ +[6]: https://itsfoss.com/ubuntu-repositories/ +[7]: https://i1.wp.com/i.imgur.com/JoEJp5w.png?ssl=1 +[8]: https://i0.wp.com/i.imgur.com/M8zTc7f.png?ssl=1 +[9]: https://i0.wp.com/i.imgur.com/Cshle6S.png?ssl=1 +[10]: https://en.wikipedia.org/wiki/TrueType +[11]: https://i1.wp.com/i.imgur.com/9oIu3oj.png?ssl=1 +[12]: https://itsfoss.com/install-media-codecs-ubuntu/ +[13]: https://thehustle.co/nextflix-sans-custom-font/ +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/Dimitrios.jpg?ssl=1 diff --git a/published/202004/20200329 Oracle Announces Java 14- How to Install it on Ubuntu Linux.md b/published/202004/20200329 Oracle Announces Java 14- How to Install it on Ubuntu Linux.md new file mode 100644 index 0000000000..fc7af79bb5 --- /dev/null +++ b/published/202004/20200329 Oracle Announces Java 14- How to Install it on Ubuntu Linux.md @@ -0,0 +1,80 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12076-1.html) +[#]: subject: (Oracle Announces Java 14! How to Install it on Ubuntu Linux) +[#]: via: (https://itsfoss.com/java-14-ubuntu/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +如何在 Ubuntu Linux 上安装 Oracle Java 14 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/05/205313e188lsbrbgz9932d.jpg) + +最近,Oracle 宣布 Java 14(或 Oracle JDK 14)公开可用。如果你想进行最新的实验或者开发的话,那么你可以试试在 Linux 系统上安装 Java 14。 + +Oracle JDK 14(或简称 Java 14)[发布版][1]包含几个新功能,如果你想预览它们的话。我已添加了链接: + + * [instanceof 的模式匹配][2] + * [Records][3] + * [Text Blocks][4] + +除预览功能外,它还包含一些改进和补充。在新闻中,他们还提到了其他改进: + +> 此外,最新的 Java 版本增加了 Java 语言对 switch 表达式的支持,新增了用于持续监控 JDK Flight Recorder 数据的新 API,将低延迟 zgc 扩展到了 macOS 和 Windows,并添加在 incubator 模块中,独立的 Java 应用打包,以及为了安全、有效地访问 Java 堆外部内存的新的外部内存访问 API。 + +当然,如果你想深入了解细节,那么你应查看[官方公告][1]。 + +在本教程中,我将向你展示在 Ubuntu 系统上安装 Java 14 的简便方法。请继续阅读。 + +**注意:**如果你选择使用 Oracle Java 11 或更高版本,那么应该了解新的 [Oracle 技术网络许可协议][5],以了解它如何影响个人用户、开发人员和商业组织。通常,它们可以免费用于开发和测试,但不能用于生产环境。 + +### 如何在 Ubuntu Linux 上安装 Java 14? + +作为参考,我已成功在默认安装 **OpenJDK 11** 的 **Pop!_OS 19.10** 上成功安装了它。 + +这里,我们将使用 [Linux Uprising][7] 的 Java 14 安装程序(最初基于 WebUpd8 Java 软件包)。 + +只需在终端中输入以下命令即可进行安装: + +``` +sudo add-apt-repository ppa:linuxuprising/java +sudo apt update +sudo apt install oracle-java14-installer +``` + +这应该就完成了,如果你想将它设为默认,那么你可以输入以下命令: + +``` +sudo apt install oracle-java14-set-default +``` + +值得注意的是,这仅适用于基于 Ubuntu 的发行版。如果要在 Debian 和其他 Linux 发行版上安装它,那么也可以按照 [Linux Uprising 中的详细指南][7]安装 Java 14。 + +### 总结 + +当然,这些会带来最新的特性,如果你不想破环原有环境,你或许会希望继续使用 Java 11。如果你想在了解风险的情况下进行试验,请继续尝试! + +欢迎在下面的评论中让我知道你对 Java 14 的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/java-14-ubuntu/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://www.oracle.com/corporate/pressrelease/oracle-announces-java14-031720.html +[2]: https://openjdk.java.net/jeps/305 +[3]: https://openjdk.java.net/jeps/359 +[4]: https://openjdk.java.net/jeps/368 +[5]: https://www.oracle.com/technetwork/java/javase/overview/oracle-jdk-faqs.html +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/install-java-14-ubuntu.png?ssl=1 +[7]: https://www.linuxuprising.com/2020/03/how-to-install-oracle-java-14-jdk14-on.html diff --git a/published/202004/20200329 The Keyring Concept in Ubuntu- What is It and How to Use it.md b/published/202004/20200329 The Keyring Concept in Ubuntu- What is It and How to Use it.md new file mode 100644 index 0000000000..3af840a02c --- /dev/null +++ b/published/202004/20200329 The Keyring Concept in Ubuntu- What is It and How to Use it.md @@ -0,0 +1,182 @@ +[#]: collector: (lujun9972) +[#]: translator: (messon007) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12093-1.html) +[#]: subject: (The Keyring Concept in Ubuntu: What is It and How to Use it?) +[#]: via: (https://itsfoss.com/ubuntu-keyring/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +解读 Ubuntu 里的密钥环概念 +====== + +![][3] + +如果你用过 Ubuntu 或者其他的 Linux 发行版里的[自动登录功能][1], 你可能遇到过这种弹出消息: + +> 请输入密码以解锁你的登录密钥环 +> +> 登录密钥环在你登录系统时未解锁。 + +![Enter Password To Unlock Your Login Keyring Ubuntu][2] + +如果你一直点击取消,它会不断弹出几次才会消失。你可能想知道,为什么你会一直看到这个密钥环信息呢? + +让我来告诉你吧。它其实不是错误,而是一个安全特性。 + +奇怪吗?下面就让我来解释下 Linux 里的密钥环概念。 + +### Linux 里的密钥环是什么。为什么需要它? + +在现实生活中你为什么要用钥匙环(也叫[钥匙链][4])?你用它把一把或多把钥匙串到一起, 以便于携带和查找。 + +Linux 里也是类似的。密钥环特性使你的系统可以将各种密码放在一起,并将其保存在一个地方。 + +大多数 Linux 桌面环境,如 GNOME、KDE、Xfce 等采用 [GNOME 密钥环][5]来提供这个功能。 + +该密钥环保存了 ssh 密钥、GPG 密钥以及使用此功能的应用程序(例如 Chromium 浏览器)的密钥。默认情况下,**“密钥环”通过主密码来保护**,该密码通常是帐户的登录密码。 + +系统上的每个用户都有自己的密钥环,(通常)密码与用户帐户本身的密码相同。当你使用密码登录系统时,你的密匙环将使用你帐户的密码自动解锁。 + +当你[启用 Ubuntu 中的自动登录功能时][1]时,就有问题了。这意味着你无需输入密码即可登录系统。在这种情况下,你的密钥环不会自动解锁。 + +#### 密钥环是一个安全特性 + +记得我说过密钥环是一个安全特性吗?现在想象一下你在 Linux 电脑上开启了自动登录功能。有权访问你电脑的任何人无需密码就能进入你的系统。但是你可能不会在意,因为你只是用它来访问互联网。 + +但是,如果你在 Ubuntu 中使用 Chromium 或 [Google Chrome][6] 之类的浏览器,并使用它来保存各种网站的登录密码,那么你将遇到麻烦。任何人都可以使用浏览器并利用你在浏览器中保存的密码登录网站。这不很危险吗? + +这就是为什么当你使用 Chrome 时,它将反复地提示你先解锁密钥环。这确保了只有知道密钥环密码(即账户密码)的人才能使用在浏览器中保存的密码来登录它们相关的网站。 + +如果你反复取消解锁密钥环的提示,它最终将消失,并允许你使用浏览器。但是,保存的密码将不会被解锁,你在 Chromium/Chome 浏览器上将会看到“同步暂停”的提示。 + +![Sync paused in Google Chrome][7] + +#### 如果密钥环一直存在,为什么你从来没有见过它呢? + +如果你在你的 Linux 系统上从没见过它的话,这个问题就很有道理。 + +如果你从没有用过自动登录功能(或者修改你的账户密码),你可能都没有意识到这个特性的存在。 + +这是因为当你通过你的密码登录系统时,你的密钥环被你的账户密码自动解锁了。 + +Ubuntu(和其他发行版)在执行普通的管理任务如修改用户、安装新软件等需要输入密码,无论你是否是自动登录的。但是对于日常任务像使用浏览器,它不需要输入密码因为密钥环已经被解锁了。 + +当你切换到自动登录时,你不再需要输入登录密码。这意味着密钥环没有被自动解锁,因此当你使用利用了密钥环特性的浏览器时,它将提示你来解锁密钥环。 + +#### 你可以轻松地管理密钥环和密码 + +这个密钥环放在哪里?它的核心是一个守护任务(一个后台自动运行的程序)。 + +别担心。你不必通过终端来操作守护任务。大多数桌面环境都自带一个可以和这个守护进程进行交互的图形化应用程序。KDE 上有 KDE 钱包,GNOME 和其他桌面上叫做“密码和密钥”(之前叫 [Seahorse][8])。 + +![Password And Keys App in Ubuntu][9] + +你可以用这个 GUI 程序来查看哪些应用程序在用密钥环来管理/保护密码。 + +你可以看到,我的系统有自动创建的登录密钥环。也有一个存储 GPG 和 SSH 密钥的密钥环。那个[证书][10]用来保存证书机构颁发的证书(如 HTTPS 证书)。 + +![Password and Keys application in Ubuntu][11] + +你也可以使用这个应用程序来手动保存网站的密码。例如,我创建了一个新的叫做“Test”的被密码保护的密钥环,并手动存储了一个密码。 + +这比在一个文本文件中保存一批密码要好一些。至少在这种情况下,你的密码只有在你通过密码解锁了密钥环时才允许被看到。 + +![Saving New Password Seahorse][12] + +这里有一个潜在的问题,如果你格式化你的系统,手动保存的密码必然会丢失。通常,你会备份你的个人文件,但并不是所有的用户特定数据,如密钥环文件。 + +有一种办法能解决它。密钥环数据通常保存在 `~/.local/share/keyrings` 目录。在这里你可以看到所有的密钥环,但是你不能直接看到它们的内容。如果你移除密钥环的密码(我会在这篇文章的后面描述操作步骤),你可以像一个普通的文本文件一样读取密钥环的内容。你可以将这个解锁后的密钥环文件完整地复制下来,并在其他的 Linux 机器上运行“密码和密钥”应用程序导入到其中。 + +总结一下目前为止所学的内容: + + * 大多数 Linux 系统缺省已经安装并激活了密钥环特性 + * 系统上的每个用户都拥有他自己的密钥环 + * 密钥环通常是用账户密码锁定的(保护) + * 当你通过密码登录时密钥环会被自动解锁 + * 对于自动登录,密钥环不会自动解锁,因此当你试图使用依赖密钥环的应用程序时会被提示先解锁它 + * 并不是所有的浏览器或应用程序利用了密钥环特性 + * (Linux 上)安装一个 GUI 程序可以和密钥环交互 + * 你可以用密钥环来手动存储加密格式的密码 + * 你可以自己修改密钥环密码 + * 你可以通过导出(需要先解锁密钥环)并导入到其他计算机上的方式来获取手工保存的密码。 + +### 修改密钥环密码 + +假设你修改了你的账户密码。当你登录时,你的系统试图通过新的登录密码来自动解锁密钥环。但是密钥环还在使用老的登录密码。 + +这种情况下,你可以修改密钥环密码为新的登录密码,这样密码环才能在你登录系统时自动解锁。 + +从菜单中打开“密码和密钥”应用程序: + +![Look for Password and Keys app in the menu][9] + +在“Login”密钥环上右击并点击“修改密码”: + +![Change Keyring Password][13] + +#### 如果你不记得老的登录密码怎么办? + +你可能知道在 [Ubuntu 上重置忘记的密码很容易][14]。但是密钥环在这种场景下还是有问题。你修改了账户密码,但是你不记得仍然被密钥环使用的老的账户密码。 + +你不能修改它因为你不知道老的密码。怎么办? + +这种情况下,你将不得不移除整个密钥环。你可以通过“密码和密钥”应用程序来操作: + +![Delete Keyring Ubuntu][15] + +它会提示你进行确认: + +![Delete Keyring][16] + +另外,你也可以手动删除 `~/.local/share/keyrings` 目录下的密钥环文件。 + +老的密钥环文件被移除后,你再打开 Chrome/Chromium 时,它会提示你创建一个新的密钥环。 + +![New Keyring Password][17] + +你可以用新的登录密码,密钥环就会被自动解锁了。 + +### 禁用密钥环密码 + +在你想用自动登录但又不想手动解锁密钥环时,你可以把禁用密钥环密码作为一个规避方法。记住你正在禁用一个安全特性,因此请三思。 + +操作步骤和修改密钥环相似。打开“密码和密钥”应用程序,然后修改密钥环密码。 + +技巧在于当它提示修改密码时,不要输入新密码,而是点击“继续”按钮。这将移除密钥环的密码。 + +![Disable Keyring password by not setting any password at all][18] + +这种方法,密钥环没有密码保护,并将一直处于解锁状态。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-keyring/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ubuntu-automatic-logon/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/enter-password-to-unlock-your-login-keyring-ubuntu.jpg?ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/keyring-concept-ubuntu-1.png?ssl=1 +[4]: https://en.wikipedia.org/wiki/Keychain +[5]: https://wiki.archlinux.org/index.php/GNOME/Keyring +[6]: https://itsfoss.com/install-chrome-ubuntu/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/sync-paused-keyring-ubuntu.jpg?ssl=1 +[8]: https://wiki.debian.org/Seahorse +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/password-and-keys-app-ubuntu.jpg?ssl=1 +[10]: https://help.ubuntu.com/lts/serverguide/certificates-and-security.html +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/keyring-pasword-ubuntu.png?ssl=1 +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/saving-new-password-seahorse.png?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/change-keyring-password.png?ssl=1 +[14]: https://itsfoss.com/how-to-hack-ubuntu-password/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/delete-keyring-ubuntu.jpg?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/delete-keyring.jpg?ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/new-keyring-password.jpg?ssl=1 +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/disable-keyring-password-ubuntu.png?ssl=1 diff --git a/published/202004/20200329 Turn Your Regular TV into a Smart TV With KDE Plasma Bigscreen.md b/published/202004/20200329 Turn Your Regular TV into a Smart TV With KDE Plasma Bigscreen.md new file mode 100644 index 0000000000..fd51a345f3 --- /dev/null +++ b/published/202004/20200329 Turn Your Regular TV into a Smart TV With KDE Plasma Bigscreen.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12063-1.html) +[#]: subject: (Turn Your Regular TV into a Smart TV With KDE Plasma Bigscreen) +[#]: via: (https://itsfoss.com/kde-plasma-bigscreen/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +用 KDE “等离子大屏幕”把你的普通电视变成智能电视 +====== + +> KDE 即将推出的“等离子大屏幕”项目可让你使用开源技术将普通电视变成智能电视。 + +如今,智能电视已成为新的常态。这些智能电视主要基于 Android,可让你播放 YouTube、Netflix、Spotify 和其他流媒体服务。你甚至可以使用语音命令来控制你的智能电视。 + +这些所谓的“智能电视”的一个主要问题是它们可能正在[监视你][1]。你的数据在你或许知道或许不知道的情况下被收集。 + +这就是 KDE 的“[等离子大屏幕项目][2]”旨在解决的问题。(LCTT 译注: 等离子Plasma恰是 KDE 桌面环境的名称,和大屏幕Bigscreen很搭,因此这个惯常不翻译的名称这里翻译出来。) + +### “等离子大屏幕”:通过开源技术使电视更智能 + +![][3] + +你可能了解 [KDE][4] 项目。它开始是一个 Linux 桌面环境项目,而在发展了 20 多年后,KDE 项目变得越来越大,这就是为什么他们创建了 Plasma 桌面环境的原因,以明确表明 KDE 不再仅仅是“K 桌面环境K Desktop Environment(KDE)”了。 + +Plasma 项目本身具有多种用途,当然,你可以在台式机 Linux 计算机上使用它,而 [Plasma 也具有移动版本][5],你可以在基于 Linux 的智能手机上运行它,例如 [Librem5][6] 和 [PinePhone][7]。 + +“等离子大屏幕Plasma Bigscreen”是 KDE 的一个新项目,旨在提供类似于智能电视所提供的界面和功能。 + +你需要的是一台[树莓派之类的单板计算机][8]和一台带 HDMI 端口的电视,然后在你的树莓派设备上安装“等离子大屏幕”,将其连接到电视就行。 + +### “等离子大屏幕”的功能:不仅仅是媒体服务器 + +![YouTube In Plasma Bigscreen][9] + +乍一看,它看起来很像是一个媒体服务器,但“等离子大屏幕”却和 Kodi 及其它 [Linux 媒体服务器][10] 不同,它不止于此。 + +#### 使用常规遥控器进行控制 + +你不需要新的专用遥控器。多亏了 [CEC][11],你可以使用常规的电视遥控器。 + +#### 带有开源 Mycroft AI 的语音控制 + +“等离子大屏幕”利用了开源 Mycroft AI 项目。借助“等离子大屏幕”内置的 Mycroft AI,你可以使用语音命令播放内容、检查天气并控制智能电视的其他方面。你可以通过教它新技能来进一步训练它。 + +#### 传统的桌面应用程序 + +“等离子大屏幕”不仅提供丰富的媒体应用程序,还提供经过重新设计,适合它的体验的传统桌面应用程序。 + +#### 自由开源软件 + +最重要的是它是一个开源项目,它使用其他开源技术为你提供对数据和智能电视的完全控制。 + +由于它是开源的,我相信一旦发布,就会有一些供应商将其作为即插即用设备提供。 + +### 如何获取“等离子大屏幕”? + +“等离子大屏幕”仍处于测试阶段,没有确定稳定版发布的时间表。 + +但是,测试版已经可以在树莓派 4 等设备上正常运行。下面是一个从事此项目的开发人员的视频。 + +- [video](https://youtu.be/iOxMuexAPaQ) + +如果你有树莓派 4,则可以从其官方下载页面上下载“[等离子大屏幕][13]”的测试版,然后按照[此处][14]的步骤进行安装。 + +就个人而言,我对此感到非常兴奋。我要花一些时间在[树莓派 4][15]上尝试一下。你呢?你认为该项目具有潜力吗?你想试试看吗? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/kde-plasma-bigscreen/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.zdnet.com/article/fbi-warns-about-snoopy-smart-tvs-spying-on-you/ +[2]: https://plasma-bigscreen.org/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/plasma-bigscreen-menu.jpg?ssl=1 +[4]: https://kde.org/ +[5]: https://itsfoss.com/kde-announces-plasma-mobile/ +[6]: https://itsfoss.com/librem-linux-phone/ +[7]: https://itsfoss.com/pinephone/ +[8]: https://itsfoss.com/raspberry-pi-alternatives/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/youtube-in-plasma-bigscreen.jpg?ssl=1 +[10]: https://itsfoss.com/best-linux-media-server/ +[11]: http://libcec.pulse-eight.com/ +[12]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[13]: https://plasma-bigscreen.org/#download-jumpto +[14]: https://plasma-bigscreen.org/manual/ +[15]: https://itsfoss.com/raspberry-pi-4/ diff --git a/published/202004/20200330 Using data from spreadsheets in Fedora with Python.md b/published/202004/20200330 Using data from spreadsheets in Fedora with Python.md new file mode 100644 index 0000000000..9cff11bd8f --- /dev/null +++ b/published/202004/20200330 Using data from spreadsheets in Fedora with Python.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12099-1.html) +[#]: subject: (Using data from spreadsheets in Fedora with Python) +[#]: via: (https://fedoramagazine.org/using-data-from-spreadsheets-in-fedora-with-python/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +使用 Python 读取电子表格中的数据 +====== + +![][1] + +[Python][2] 是最流行、功能最强大的编程语言之一。由于它是自由开源的,因此每个人都可以使用。大多数 Fedora 系统都已安装了该语言。Python 可用于多种任务,其中包括处理逗号分隔值(CSV)数据。CSV文件一开始往往是以表格或电子表格的形式出现。本文介绍了如何在 Python 3 中处理 CSV 数据。 + +CSV 数据正如其名。CSV 文件按行放置数据,数值之间用逗号分隔。每行由相同的*字段*定义。简短的 CSV 文件通常易于阅读和理解。但是较长的数据文件或具有更多字段的数据文件可能很难用肉眼解析,因此在这种情况下计算机做得更好。 + +这是一个简单的示例,其中的字段是 `Name`、`Email` 和 `Country`。在此例中,CSV 数据将字段定义作为第一行,尽管并非总是如此。 + +``` +Name,Email,Country +John Q. Smith,jqsmith@example.com,USA +Petr Novak,pnovak@example.com,CZ +Bernard Jones,bjones@example.com,UK +``` + +### 从电子表格读取 CSV + +Python 包含了一个 `csv` 模块,它可读取和写入 CSV 数据。大多数电子表格应用,无论是原生(例如 Excel 或 Numbers)还是基于 Web 的(例如 Google Sheet),都可以导出 CSV 数据。实际上,许多其他可发布表格报告的服务也可以导出为 CSV(例如,PayPal)。 + +Python `csv` 模块有一个名为 `DictReader` 的内置读取器方法,它可以将每个数据行作为有序字典 (`OrderedDict`) 处理。它需要一个文件对象访问 CSV 数据。因此,如果上面的文件在当前目录中为 `example.csv`,那么以下代码段是获取此数据的一种方法: + +``` +f = open('example.csv', 'r') +from csv import DictReader +d = DictReader(f) +data = [] +for row in d: + data.append(row) +``` + +现在,内存中的 `data` 对象是 `OrderedDict` 对象的列表: + +``` +[OrderedDict([('Name', 'John Q. Smith'), + ('Email', 'jqsmith@example.com'), + ('Country', 'USA')]), + OrderedDict([('Name', 'Petr Novak'), + ('Email', 'pnovak@example.com'), + ('Country', 'CZ')]), + OrderedDict([('Name', 'Bernard Jones'), + ('Email', 'bjones@example.com'), + ('Country', 'UK')])] +``` + +引用这些对象很容易: + +``` +>>> print(data[0]['Country']) +USA +>>> print(data[2]['Email']) +bjones@example.com +``` + +顺便说一句,如果你需要处理没有字段名标题行的 CSV 文件,那么 `DictReader` 类可以让你定义它们。在上面的示例中,添加 `fieldnames` 参数并传递一系列名称: + +``` +d = DictReader(f, fieldnames=['Name', 'Email', 'Country']) +``` + +### 真实例子 + +我最近想从一长串人员名单中随机选择一个中奖者。我从电子表格中提取的 CSV 数据是一个简单的名字和邮件地址列表。 + +幸运的是,Python 有一个有用的 `random` 模块,可以很好地生成随机值。该模块 `Random` 类中的 `randrange` 函数正是我需要的。你可以给它一个常规的数字范围(例如整数),以及它们之间的步长值。然后,该函数会生成一个随机结果,这意味着我可以在数据的总行数范围内获得一个随机整数(或者说是行号)。 + +这个小程序运行良好: + +``` +from csv import DictReader +from random import Random + +d = DictReader(open('mydata.csv')) +data = [] +for row in d: + data.append(row) + +r = Random() +winner = data[r.randrange(0, len(data), 1)] +print('The winner is:', winner['Name']) +print('Email address:', winner['Email']) +``` + +显然,这个例子非常简单。电子表格本身包含了复杂的分析数据的方法。但是,如果你想在电子表格应用之外做某事,Python 或许是一种技巧! + +题图由 [Isaac Smith][3] 拍摄,发表于 [U​​nsplash][4]。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/using-data-from-spreadsheets-in-fedora-with-python/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/03/spreadsheets-python-816x345.jpg +[2]: https://python.org +[3]: https://unsplash.com/@isaacmsmith?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://unsplash.com/s/photos/spreadsheets?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202004/20200331 5 ways to level up your Vim skills.md b/published/202004/20200331 5 ways to level up your Vim skills.md new file mode 100644 index 0000000000..487f0247ba --- /dev/null +++ b/published/202004/20200331 5 ways to level up your Vim skills.md @@ -0,0 +1,156 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12077-1.html) +[#]: subject: (5 ways to level up your Vim skills) +[#]: via: (https://opensource.com/article/20/3/vim-skills) +[#]: author: (Detlef Johnson https://opensource.com/users/deckart) + +提升你的 Vim 技能的 5 个方法 +====== + +> 通过一些有趣的小技巧使你的文本编辑器更上一层楼。 + +![](https://img.linux.net.cn/data/attachment/album/202004/05/232434x1hnzlnhcnm3nrc7.jpg) + +Vim 是最受欢迎的文本编辑器之一,因此绝对值得你花时间去学习如何使用它。就算你只是学习使用这个无处不在的 [Vi(m)][2] 命令行文本编辑器打开文件、输入和编辑一些文本、保存编辑的文件并退出程序,你都会受益匪浅。 + +你会发现,使用 Vim 非常方便的的场景几乎总是涉及到运行远程 Shell 操作的任务。如果你时不时地使用 ssh,比如 + +``` +$ ssh user@hostname.provider.com +``` + +并在虚拟专用服务器(VPS)或本地虚拟化容器中工作,那么就可以从这些强大的 Vim 技能中受益匪浅。 + +### 将 Vim 设置为默认的文本编辑器 + +几乎所有的现代 Linux(或 BSD)发行版中,都可以在终端仿真器的 shell 命令提示符下使用 Vim。一旦在你的用户 shell 程序中将 Vim 定义为默认编辑器后,那么就可以使用熟悉的 Vim 键绑定来在内置的实用程序(例如 `man`)中导航。我将说明如何使用 Bash 和 Z shell(zsh)来实现此目的,zsh 现在是 macOS 用户的默认 shell(自 Catalina 起)。 + +#### 在 Bash 中将 Vim 设置为默认 + +Bash 通过点文件的组合来管理设置。最常见的的做法将你的编辑器添加到主目录中的 `.bashrc` 文件中,但也可以将其添加到 `.bash_profile` 中。(请阅读 [GNU Bash 文档][3]了解两者的不同之处)。 + +通过在 `~/.bashrc` 中添加以下内容,将 Vim 设置为默认编辑器: + +``` +# set default editor to Vim +export EDITOR=vim +``` + +以 `#` 开头的行是可选的注释,这是一个好方法,可以提醒自己该命令的作用。 + +#### 在 zsh 中将 Vim 设置为默认 + +zsh 是一种越来越流行的终端仿真器,尤其是在苹果公司的基于 FreeBSD 的 Darwin 系统最近从 Bash 转向 zsh 以来。 + +zsh 点文件与 Bash 的文件相当,因此你可以在 `~/.zshrc` 或 `~/.zprofile` 之间进行选择。有关何时使用哪一个的详细信息,请参见 [zsh文档][4]。 + +将其设置为默认: + +``` +# set default editor to Vim +export EDITOR=vim +``` + +### 优化 Vim 配置 + +Vim 像是终端仿真器 shell 一样,也使用点文件来设置个人偏好。如果你发现了这种模式,则可能已经猜到它是 `~/.vimrc`。 + +你可能要更改的第一个设置是将对传统的 Vi 兼容模式切换为“关闭”。由于 Vim 是 Vi 的超集,因此 Vi 中的所有功能在 Vim 中都是可用的,并且在 Vim 中得到了很大的改进,你可以获得许多高级功能。最新版本(8.2)允许你在分割的窗口中以子进程 shell 的方式打开一个终端。 + +顺便说一句,明确关闭对传统的 Vi 的兼容性看起来没有什么作用([事实上,可能并没有什么作用][5])。当 Vim 遇到 `.vimrc` 文件时,它会暗暗地自动将兼容模式切换到关闭。但有时将其明确关闭仍然很重要。缩写 `nocp` 是 `nocompatible` 的同义词,作用是一样的。[条条大道通罗马][6],切换首选项有很多方式。 + +在 `.vimrc` 语法中, 以 `"` 开头的行是注释(就像 `.bashrc` 文件中的 `#` 一样),这些注释可以帮助你记住诸如为何选择了一个隐晦的设置名称之类的内容。 + +要关闭 Vi 兼容性,请将以下内容添加到 `~/.vimrc` 文件中: + +``` +" ensure that legacy compatibility mode is off +" documentation: ' +set nocp +``` + +### 理解模式 + +Vim 的 “模式”概念是非常重要的,尤其是“普通模式”和“插入模式”之间的区别。对模式的混淆是大多数新用户的困扰。模式并不是 Vim 所独有的,甚至也不是 Vi 所引入的。命令模式是如此的古老,以至于它比 70 年代发明的[复制和粘贴][7]功能还要早。 + +#### 重要的模式 + +Vim 依赖于不同的模式来定义键盘的敲击行为。需要了解的重要模式有: + +* 普通模式:默认模式,主要用于导航和打开文件。 +* 插入模式(包括替换):这种模式下 Vim 允许将文本输入到打开的文件中。 +* 可视模式:Vim 的行为类似于基于鼠标的输入方式,如复制、编辑、替换等。 +* 命令模式(包括行模式、Ex 命令模式和末行模式):是在 Vim 中做更多事情的强大方法。 + +每种模式都有很多值得探索的地方。使用 [Vimtutor][8](`vimtutor`)可以交互式地学习移动光标、模式和在末行模式下运行 Ex 命令。一些不可缺少的生产力操作符包括: + +操作符 | 说明 +--- | --- +`:E` | 打开资源管理器,用于定位文件和目录。 +`.` | 重复上次的编辑操作。 +`;` | 向前重复上一次的动作或移动 +`,` | 向后重复上一次的动作或移动。 +`/` | 向前搜索文档。 +`?` | 向后搜索文档。 +`*` | 查找光标所在处的单词的下一个出现的地方。 +`#` | 查找光标所在处的单词的上一次出现的地方。 +`~` | 切换大小写。 +`%` | 在 `()`、`[]` 和 `{}` 的开闭符号之间切换;对编码非常有用。 +`z=` | 提出拼写建议。 + +### 像钢琴一样弹奏 Vim + +尽管把 Vim 的操作符“语言”记在记忆中是很重要的,但要想掌握它,难点在于学会像音乐家一样思考,把操作符和动作组合成“和弦”,这样你就可以像弹钢琴一样弹奏 Vim。这就是 Vim 的文本操作能力可以与另一个著名的命令行编辑器 Emacs 相媲美的地方。(虽然其中一个编辑器会让磨损掉你的 `Esc` 键,而另一个编辑器会让你的 `Ctrl` 键磨损掉。) + +在描述键“和弦”时,Vim 中的传统做法是用大写字母 C 后面加上一个连字符(`C-`)来指代 `Ctrl` 键。这并不是通用的,但我将从这里开始遵循这一惯例,并在有可能引起混淆的时候加以说明。 + +如果你在 Vim 中键入长行,你会想把它设置成可以换行。想要根据你的工作方式对 Vim 进行个性化设置,请考虑一下这个设置:默认情况下,你希望 Vim 启动时如何处理文本换行?开还是关?我喜欢将其关闭,并将其留在运行命令文件之外。当我想让文本自动换行时,我只需在命令行模式下用 `:set wrap` 设置即可。 + +让 Vim 设置为默认情况下自动换行并没有错,这只是一个偏好问题 —— 它可能随着时间的推移而改变。同样你也可以控制粘贴、代码语言缩进语法和 `Tab` 键的设置(制表符还是空格?多少个空格?可也在[这里][9]深入研究这些选项)。所有这些默认行为的选项都是完全可配置和可更改的,并且在你使用命令行模式操作时可以实时更改。 + +你会在社区论坛、Vim 维基和文章(比如这篇文章)中找到很多关于设置 Vim 默认设置的建议。你应该很熟悉为你的个人计算环境设置首选项,Vim 也不例外。我强烈建议你从对设置进行很小的更改开始,慢慢地进行其它更改,以便你可以轻松地恢复设置。这样一来,你就可以好多年避免使用插件或完全不用插件。 + +### Vim 8.2 中的分割、标签和终端 + +有两种方法可以将你正在处理的文件分割成不同的视图:它们可以并排显示,也可以使用应用程序标签页在全屏(窗口)中切换。这些对应用程序窗口的更改是从命令模式启动的,这需要使用冒号(`:`)来调起提示符。 + +每个分割的窗口可以容纳一个文件进行编辑,你可以通过标签页在更多的文件之间随意切换。分割的屏幕空间有限,所以当你想分割更多的屏幕时,标签页是很方便的。想要如何设置,纯属个人喜好的问题。要水平分割一个窗口,使用 `:sp`,垂直分割时使用 `:vs`。 + +从 [Vim 8.2][10] 开始,你可以用 `:vert term` 打开一个垂直分割的终端 shell 子进程,以在你的代码旁边的命令行上进行操作。你需要键入 `exit` 来关闭你的终端进程,就像你结束一个 shell 会话一样,但你关闭这个分割的窗口和标签页的方式和关闭任何普通的 Vim 窗口一样,要用 `:q` 来关闭。 + +要初始化一个标签页,请使用一个特殊的编辑命令:`:tabedit`,它会自动切换到新打开的标签页。如果你给该命令一个文件名作为参数,会打开该文件并进行编辑。如果你忽略了给它一个文件名作为参数,可以在命令行模式下的使用编辑命令 `:e filename.txt`,就像在任何一个普通的 Vim 窗口中一样。可以使用下一个(`:tabn`)和上一个(`:tabp`)命令在标签页间导航。 + +要使用分割,你需要知道如何使用组合键 `C-w` 和你想要移动的方向的移动键,例如左(`h`)、下(`j`)、左(`k`)、右(`l`)。如果你想学习更多的组合键,请阅读 Vim 手册中的 `:help split` 和 `:help tabpage`。 + +### 获取帮助 + +虽然可以在 Vimtutor 中打开参考 Vim 手册,但用 `:help` 打开 Vim 帮助,可以让你自己把时间花在编辑器上,不用完全依赖像这样的文章,就能获得更多的成果。经验是掌握 Vim 的关键。经验有助于提高你的整体计算直觉,因为 Vim 中的很多东西都是从 Unix 宇宙中汲取的。 + +祝你在探索 Vim 之美的过程中玩得开心,有什么问题可以在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/vim-skills + +作者:[Detlef Johnson][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/deckart +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/keyboaord_enter_writing_documentation.jpg?itok=kKrnXc5h (Computer keyboard typing) +[2]: https://www.vim.org/ +[3]: https://www.gnu.org/software/bash/manual/html_node/Bash-Startup-Files.html +[4]: http://zsh.sourceforge.net/Intro/intro_3.html +[5]: http://vimdoc.sourceforge.net/htmldoc/starting.html#compatible-default +[6]: https://en.wikipedia.org/wiki/There%27s_more_than_one_way_to_do_it +[7]: https://www.npr.org/2020/02/22/808404858/remembering-the-pioneer-behind-your-computers-cut-copy-and-paste-functions +[8]: http://www2.geog.ucl.ac.uk/~plewis/teaching/unix/vimtutor +[9]: https://opensource.com/article/18/9/vi-editor-productivity-powerhouse +[10]: https://www.vim.org/vim-8.2-released.php diff --git a/published/202004/20200401 How to Find Which Graphics Card do You Have in Linux.md b/published/202004/20200401 How to Find Which Graphics Card do You Have in Linux.md new file mode 100644 index 0000000000..6ad35a9367 --- /dev/null +++ b/published/202004/20200401 How to Find Which Graphics Card do You Have in Linux.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12086-1.html) +[#]: subject: (How to Find Which Graphics Card do You Have in Linux?) +[#]: via: (https://itsfoss.com/check-graphics-card-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何知道你的 Linux 用的哪种显卡? +====== + +无论是 [Nvidia][1] 还是 [Radeon][2] 或者 Intel,它们的显卡都可能在 Linux 中有问题。当你要对图形问题进行故障排除时,首先要了解系统中装有哪种显卡。 + +Linux 有几个命令可以检查硬件信息。你可以使用它们来检查你有哪些显卡(也称为视频卡)。让我向你展示一些命令来获取 Linux 中的 GPU 信息。 + +### 在 Linux 命令行中检查显卡详细信息 + +![][3] + +#### 使用 lspci 命令查找显卡 + +`lspci` 命令显示通过 [PCI][4](外设组件互连Peripheral Component Interconnect)总线连接的设备的信息。基本上,此命令提供有关系统从键盘和鼠标到声卡、网卡和显卡的所有外设的详细信息。 + +默认情况下,你会有大量的此类外设列表。这就是为什么你需要用 `grep` 命令过滤出显卡的原因: + +``` +lspci | grep VGA +``` + +这应该会显示一行有关你显卡的信息: + +``` +abhishek@itsfoss:~$ lspci | grep VGA +00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02) +``` + +如你所见,我的系统中有 Intel HD 620 显卡。 + +#### 在 Linux 中使用 lshw 命令获取显卡详细信息 + +`lspci` 命令足以查看你的显卡,但是并不能告诉你很多信息。你可以使用 `lshw` 命令获取有关它的更多信息。 + +此命令要求你有 root 用户权限。你需要以这种方式查找视频卡(显卡)信息: + +``` +sudo lshw -C video +``` + +正如你在下面的输出中看到的那样,此命令提供了有关显卡的更多信息,例如时钟频率、位宽、驱动等。 + +``` +abhishek@itsfoss:~$ sudo lshw -C video +[sudo] password for abhishek: + *-display + description: VGA compatible controller + product: HD Graphics 620 + vendor: Intel Corporation + physical id: 2 + bus info: [email protected]:00:02.0 + version: 02 + width: 64 bits + clock: 33MHz + capabilities: pciexpress msi pm vga_controller bus_master cap_list rom + configuration: driver=i915 latency=0 + resources: irq:139 memory:db000000-dbffffff memory:90000000-9fffffff ioport:f000(size=64) memory:c0000-dffff +``` + +#### 附赠技巧:以图形方式检查显卡详细信息 + +并非必须使用命令行在 Linux 中查找显卡详细信息。大多数 Linux 发行版(或者应该说是桌面环境)在设置中提供了必要的详细信息。 + +例如,如果你使用的是 [GNOME 桌面环境][5],那么可以进入“设置”的“关于”部分来检查详细信息。[Ubuntu 20.04][6] 中看上去像这样: + +![Graphics card information check graphically][7] + +我希望这个快速技巧对你有所帮助。你也可以使用相同的命令来[查找网卡][8]和 [Linux 中的 CPU 信息][9]。 + +如果你有任何疑问或建议,请随时发表评论。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/check-graphics-card-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.nvidia.com/en-us/ +[2]: https://www.amd.com/en/graphics/radeon-rx-graphics +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/check-gpu-info-linux.jpg?ssl=1 +[4]: https://en.wikipedia.org/wiki/Conventional_PCI +[5]: https://www.gnome.org/ +[6]: https://itsfoss.com/ubuntu-20-04-release-features/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/ubuntu-gpu-check.jpg?ssl=1 +[8]: https://itsfoss.com/find-network-adapter-ubuntu-linux/ +[9]: https://linuxhandbook.com/check-cpu-info-linux/ diff --git a/published/202004/20200401 IEEE Standards Association Launches an Open Source Collaboration Platform.md b/published/202004/20200401 IEEE Standards Association Launches an Open Source Collaboration Platform.md new file mode 100644 index 0000000000..891edf7bdb --- /dev/null +++ b/published/202004/20200401 IEEE Standards Association Launches an Open Source Collaboration Platform.md @@ -0,0 +1,93 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12096-1.html) +[#]: subject: (IEEE Standards Association Launches an Open Source Collaboration Platform) +[#]: via: (https://itsfoss.com/ieee-open-source-collaboration-platform/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +IEEE 标准协会推出开源协作平台 +====== + +> IEEE 标准协会宣布了一个基于 GitLab 的开源协作平台。 + +![](https://img.linux.net.cn/data/attachment/album/202004/10/222910vjpiqd6lqqm6riqp.jpg) + +[IEEE][1] 是世界上最大的技术专业组织,致力于推动技术的发展。IEEE 标准协会the IEEE Standards Association(IEEE SA)是 IEEE 内部的一个组织,负责制定全球各行业的标准。 + +IEEE 标准协会(SA)提出了一个开源协作平台,即 [IEEE SA Open][2]。 + +技术上来说,它是一个自托管的 GitLab 实例,结合了 [Mattermost][3](一个 [Slack 的替代品][4])和 [GitLab Pages][5]。[其官方博文][6]对此进一步解释道: + +> 该平台使独立软件开发者、初创企业、业界、学术机构等能够在一个协作、安全、负责任的环境中创建、测试、管理和部署创新项目。 + +### 它有什么不同或有用的地方? + +这个平台最主要的吸引力应该是 IEEE 的会员网络、技术专长和资源。 + +IEEE 主席 [Robert Fish][7],也曾(在接受 Radio Kan 的采访时)简单地提到它有什么不同之处,以及为什么 IEEE 想要使用它。 + +> 如今,世界上大部分的基础设施都是由软件运行的,而这些软件需要符合通信网络、电网、农业等方面的标准。 + +这是有道理的 —— 如果我们想提高标准化技术,这在很大程度上取决于软件。所以,这听起来肯定是要对创新的开源项目进行标准化,让它们也能为潜在的资本机会做好准备。 + +IEEE 还澄清说: + +> 随着软件在当今世界越来越普遍,道德规范、可靠性、透明度和民主治理成为必须具备的条件。IEEE 在赋予开源项目这些属性方面有着得天独厚的优势。 + +虽然听起来很好,但 IEEE 的开源平台究竟能提供什么?让我们一起来看看这个问题。 + +### IEEE SA Open 概览 + +![][8] + +首先,它对所有人开放并且完全免费使用。你只需要创建一个 [IEEE 帐户][9],然后[登录到这个开源平台][10]就可以开始。 + +除了与 IEEE 广泛的会员网络相关的好处之外,你还可以期望其开源社区经理或社区成员提供指导性支持。 + +![Ieee Gitlab][11] + +该平台提供了标准和非标准项目的用例,你可以尝试一下。 + +因为选择将 GitLab 与 Mattermost 和 Pages 结合起来,你可以获得一些有用的功能,它们是: + + * 项目规划和管理功能 + * 源代码管理 + * 测试、代码质量和持续集成功能 + * Docker 容器注册库和 Kubernetes 集成 + * 应用程序的发布和交付功能 + * 集成了 Mattermost 聊天论坛的斜线命令(完全支持 Android 和 iPhone 应用程序) + * 能够弥合标准制定和开源社区之间的差距,以便以更快的速度推进灵活和创造性的技术解决方案 + * 安全的开放空间,并有严格的行为准则。 + +### 小结 + +显然,有更多的平台来潜在地放大开源项目的曝光率是一件好事 —— 因此,IEEE 的举措听起来很有希望。 + +你对此有何看法?让我知道你的想法吧! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ieee-open-source-collaboration-platform/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://www.ieee.org/about/index.html +[2]: https://standards.ieee.org/content/ieee-standards/en/initiatives/opensource/ +[3]: https://mattermost.com/ +[4]: https://itsfoss.com/open-source-slack-alternative/ +[5]: https://docs.gitlab.com/ee/user/project/pages/ +[6]: https://spectrum.ieee.org/the-institute/ieee-products-services/ieee-standards-association-launches-a-platform-for-open-source-collaboration +[7]: https://www.linkedin.com/in/robertsfish/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/ieee-opensource.jpg?ssl=1 +[9]: https://www.ieee.org/profile/public/createwebaccount/showRegister.html +[10]: https://opensource.ieee.org/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/ieee-gitlab.jpg?ssl=1 diff --git a/published/202004/20200402 How to Upgrade to Ubuntu 20.04 Beta from 18.04 - 19.10.md b/published/202004/20200402 How to Upgrade to Ubuntu 20.04 Beta from 18.04 - 19.10.md new file mode 100644 index 0000000000..10db11050c --- /dev/null +++ b/published/202004/20200402 How to Upgrade to Ubuntu 20.04 Beta from 18.04 - 19.10.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12085-1.html) +[#]: subject: (How to Upgrade to Ubuntu 20.04 Beta from 18.04 & 19.10) +[#]: via: (https://itsfoss.com/upgrade-ubuntu-beta/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何将 Ubuntu 18.04 LTS/19.10 升级到 Ubuntu 20.04 beta +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/08/125043m1qyy7gzvkjazx41.jpg) + +[Ubuntu 20.04 LTS 版本][1]还有不到一个月就发布了,Ubuntu 在这一个版本中对视觉效果作出了大变动,同时在性能方面也有所提高。 + +如果你还在使用 Ubuntu 18.04 LTS 版本,你会发现 Ubuntu 20.04 配合深色 Yaru 主题非常惊艳,看过 [Ubuntu 20.04 的展示视频][2]你就知道了。 + +- [video](https://img.linux.net.cn/static/video/Ubuntu%2020.04%20Desktop%20Tour%20-%20Check%20Out%20New%20Features-9u5B0njRgOw.mp4) + +感觉确实不错。如果你想在 4 月 23 日最终稳定版正式发布前率先使用 Ubuntu 20.04,也可以在官方网站上下载 beta 版本。尽管是测试版本,但它的稳定性并不差,同时你也可以在使用这个版本的过程中帮助 Ubuntu 团队进行测试。 + +你可以下载每日构建daily build版并进行重新安装,如果你正在使用的是 Ubuntu 18.04 或 Ubuntu 19.10,也可以在现有系统的基础上直接升级到 Ubuntu 20.04 beta 版本。 + +从现有系统中升级是很方便的,因为你不会丢失系统设置和其他文件。与重新安装不同的是,你不需要从头开始重新安装所有的软件。当你切换到新版本时,你的主目录、应用程序(大部分)、文件都会保持原样。 + +> 如果你需要确认正在使用的 Ubuntu 版本,可以参考[这篇文章][4]。 + +在本文中,我将会介绍如何升级到 Ubuntu 20.04 beta 版本。 + +### 如何将 Ubuntu 18.04/19.10 升级到 Ubuntu 20.04 beta + +![Upgrade Ubuntu 20 04 Beta][5] + +在你阅读后面的内容之前,我首先说明一些关于升级到 Ubuntu beta 版本的常见问题。 + + * 版本升级的过程并不复杂,但在整个过程中需要有良好的网络连接,以便下载高达好几 GB 的数据。 + * 版本升级的过程中,第三方存储库(比如你自行添加的 [PPA][6])会被禁用,有些 PPA 可能也和新版本不兼容,在版本升级完毕后,你可以手动启用这些 PPA。 + * 强烈建议将重要数据备份到外部的 USB 硬盘上。你只需要将各个目录下的重要文件直接复制到外部 USB 硬盘上保存即可。 + * 升级到新版本之后,就无法再回滚到之前的旧版本了,如果需要旧版本的系统,只能重新安装。 + * 如果你选择升级到 Ubuntu 20.04 beta 版本,那么在 Ubuntu 20.04 最终稳定版发布之后,你也不需要重新安装。只需要保持定期更新 Ubuntu 系统,届时你就可以直接用上最终稳定版了。 + * Ubuntu 16.04/17/18/19.04 都无法直接升级到 Ubuntu 20.04。 + +了解完上面的内容之后,下面开始从 Ubuntu 18.04/19.10 升级到 Ubuntu 20.04。 + +#### 步骤 1:检查设置是否正确 + +进入“软件和升级Software & Updates”应用: + +![Software & Updates application in Ubuntu][7] + +在“升级Updates”选项卡中,设置“有任何新版本 Ubuntu 都提醒我”或“有 LTS 版本 Ubuntu 就提醒我”: + +![Ubuntu Upgrade Version Settings][8] + +设置完成后,系统会刷新软件库缓存。 + +#### 步骤 2:安装系统更新 + +在上面的步骤完成之后,打开终端(在 Ubuntu 中可以使用 `Ctrl+Alt+T` [快捷键][9]),然后使用以下命令[更新 Ubuntu 系统][10]: + +``` +sudo apt update && sudo apt full-upgrade +``` + +`apt full-upgrade` 或 `apt dist-upgrade` 的功能和 `apt upgrade` 大致相同,但对于系统版本的升级,`apt full-upgrade` 会在需要的情况下将当前已安装的软件移除掉。 + +更新安装完成后,系统可能会需要重新启动。在重新启动之后,就可以进入步骤 3 了。 + +#### 步骤 3:使用更新管理器查找开发版本 + +在步骤 2 中已经安装了所有必要的更新,现在通过下面的命令打开更新管理器,其中 `-d` 参数表示需要查找开发版本: + +``` +update-manager -d +``` + +整个过程可能需要好几分钟,随后会提示有新版本的 Ubuntu 可用: + +![Availability of Ubuntu 20.04 in Ubuntu 19.10][11] + +在 Ubuntu 18.04 上的提示是这样的: + +![Availability of Ubuntu 20.04 in Ubuntu 18.04][12] + +然后点击对话框中的“升级upgrade”按钮。 + +#### 步骤 4:开始升级到 Ubuntu 20.04 beta + +接下来只要等待下载更新就可以了,遇到对话框直接点击 “OK” 即可。 + +![][13] + +点击“升级upgrade”按钮,然后按照提示进行操作。 + +![][14] + +在升级过程中,可能会有提示信息告知所有第三方源都已经禁用。有时候还会提示有哪些软件包需要升级或删除,以及是否需要保留一些已经过时了的软件包。一般情况下,我会选择直接删除。 + +整个升级过程通常会需要几个小时,但主要还是取决于实际的网速。升级完成后,系统会提示需要重新启动。 + +![][15] + +下面的视频展示了所有相关步骤。 + +- [video](https://img.linux.net.cn/static/video/How%20to%20Upgrade%20to%20Ubuntu%2020.04%20Beta%20from%2018.04%20&%2019.10%20Right%20Now-RkxxEtaTVkA.mp4) + +由此可见,这个升级流程并不复杂。欢迎体验 Ubuntu 20.04 带来的新特性。 + +如果你有疑问或建议,欢迎在评论区留言。 + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/upgrade-ubuntu-beta/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ubuntu-20-04-release-features/ +[2]: https://www.youtube.com/watch?v=9u5B0njRgOw +[3]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[4]: https://linux.cn/article-9872-1.html +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/upgrade-ubuntu-20-04-beta.jpg?ssl=1 +[6]: https://itsfoss.com/ppa-guide/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/software-updates-app-ubuntu.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/ubuntu-upgrade-version-settings.jpg?ssl=1 +[9]: https://itsfoss.com/ubuntu-shortcuts/ +[10]: https://itsfoss.com/update-ubuntu/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/upgrade-ubuntu-20-04.jpg?ssl=1 +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/upgrade-ubuntu-20-04-from-18-04.jpg?ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/upgrade-ubuntu-20-04-steps-1.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/upgrade-ubuntu-20-04-steps-2.jpg?ssl=1 +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/restart-to-finish-beta-upgarde-ubuntu-20-04.jpg?ssl=1 diff --git a/published/202004/20200403 Scheduling tasks on Linux using the at command.md b/published/202004/20200403 Scheduling tasks on Linux using the at command.md new file mode 100644 index 0000000000..5c692a68ef --- /dev/null +++ b/published/202004/20200403 Scheduling tasks on Linux using the at command.md @@ -0,0 +1,161 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12092-1.html) +[#]: subject: (Scheduling tasks on Linux using the at command) +[#]: via: (https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +使用 at 命令在 Linux 上安排任务 +====== + +> at 命令可以很容易地安排 Linux 任务在你选择的任何时间或日期运行,让我们来看看它能为你做什么。 + +![][0] + +当你希望命令或脚本在某个特定时间运行时,你不需要将手指放在键盘上盘旋等待按下回车键,或者是在特定时间坐在办公桌前。相反,你可以通过 `at` 命令来设置任务。在本文中,我们将研究如何使用 `at` 来安排任务,如何精确地选择任务希望运行的时间,以及如何使用 `at` 来查看安排运行的任务。 + +### at vs cron + +对于那些使用 cron 在 Linux 系统上安排任务的人来说,`at` 命令类似于 cron,因为你可以在选定的时间调度任务,但是 cron 用于定期运行的作业 —— 甚至是每年仅一次。大多数 cron 作业的频率都设置为每天、每周或每月运行一次,不过你可以控制运行的频率和时间。 + +另一方面,`at` 命令用于仅运行一次的任务。想在午夜重启系统?没问题,只要你有适当的权限,`at` 可以为你完成此操作。如果你希望系统在每个星期六凌晨 2 点重启,那么改用 cron。 + +### 使用 at + +`at` 命令很容易使用,只需记住几件事。一个简单使用 `at` 的例子类似于这样: + +``` +$ at 5:00PM +at> date >> thisfile +at> +``` + +在输入 `at` 和应该运行命令的时间,`at` 会提示你在设定时间会运行该命令(此例中是 `date` 命令)。输入 `^D`(`Ctrl + d`)来完成请求。 + +假设我们在下午 5 点之前设置这个 `at` 命令,那么这个日期和时间将在当天下午 5 点添加到名为 `thisfile` 文件的末尾。否则,该命令将在第二天下午 5 点运行。 + +与 `at` 命令进行交互时,可以输入多个命令。如果你要同时运行多个命令,只需输入多个命令行即可: + +``` +$ at 6:22 +warning: commands will be executed using /bin/sh +at> echo first >> thisfile +at> echo second >> thisfile +at> +``` + +在上面的命令中,我们使用了一个普通的用户账户,将一些简单的文本添加到该用户主目录的文件中。如果在上午 6:22 之后运行这些命令,那么命令会在第二天运行,因为 6:22 表示上午 6:22。如果你想在下午 6:22 运行,使用 `6:22 PM` 或者 `18:22`。`6:22 PM` 这样也是可以工作的。 + +你也可以通过使用 `at` 来安排命令在指定的日期或时间运行,例如 `10:00AM April 15 2021` 或 `noon + 5 days`(从今天起 5 天内的中午运行),以下是一些例子: + +``` +at 6PM tomorrow +at noon April 15 2021 +at noon + 5 days +at 9:15 + 1000 days +``` + +在指定要运行的命令并按下 `^D` 后,你会注意到 `at` 命令为每个请求分配了一个作业编号,这个数字将显示在 `at` 命令的作业队列中。 + +``` +$ at noon + 1000 days +warning: commands will be executed using /bin/sh +at> date >> thisfile +at> +job 36 at Tue Dec 27 12:00:00 2022 <== job # is 36 +``` + +### 检查队列 + +你可以使用 `atq`(at queue)命令来查看 `at` 作业队列: + +``` +$ atq +32 Thu Apr 2 03:06:00 2020 a shs +35 Mon Apr 6 12:00:00 2020 a shs +36 Tue Dec 27 12:00:00 2022 a shs +34 Thu Apr 2 18:00:00 2020 a shs +``` + +如果你需要取消队列中的一个作业,使用 `atrm`(at remove)命令和作业编号: + +``` +$ atrm 32 +$ atq +35 Mon Apr 6 12:00:00 2020 a shs +36 Tue Dec 27 12:00:00 2022 a shs +34 Thu Apr 2 18:00:00 2020 a shs +``` + +你可以使用 `at -c` 命令来查看安排任务的详细信息,其它详细信息(活动的搜索路径等)也可以看到,但是输出的最后一行将显示计划运行的命令。 + +``` +$ at -c 36 | tail -6 +cd /home/shs || { + echo 'Execution directory inaccessible' >&2 + exit 1 +} +date >> thisfile +``` + +注意,该命令显示首先会测试是否可以通过 `cd` 命令进入用户目录。如果不可以,作业将退出并显示错误。如果可以,则运行在 `at` 中指定的命令。它将命令视为 “进入 `/home/shs` 或退出并显示错误”。 + +### 以 root 身份运行作业 + +要以 root 身份运行 `at` 作业,只需将 `sudo` 与你的 `at` 命令一起使用,如下所示: + +``` +$ sudo at 8PM +[sudo] password for shs: +warning: commands will be executed using /bin/sh +at> reboot now +at> +job 37 at Wed Apr 1 16:00:00 2020 +``` + +注意,root 的任务以 `root` 作为执行者显示在队列中。 + +``` +35 Mon Apr 6 12:00:00 2020 a shs +36 Tue Dec 27 12:00:00 2022 a shs +37 Wed Apr 1 20:00:00 2020 a root <== +``` + +### 运行脚本 + +你还可以使用 `at` 命令来运行脚本,这里有一个例子: + +``` +$ at 4:30PM +warning: commands will be executed using /bin/sh +at> bin/tryme +at> +``` + +### 禁止使用 at 命令 + +`/etc/at.deny` 文件提供了一种禁止用户使用 `at` 命令的方法。默认情况下,它可能会包含一个不允许的账户列表,例如 `ftp` 和 `nobody`。可以使用 `/etc/at.allow` 文件执行相反的操作,但是通常只配置 `at.deny` 文件。 + +### 总结 + +当你要安排一项一次性任务时,无论你是希望在今天下午或几年后运行,`at` 命令都是通用且易于使用的。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3535808/scheduling-tasks-on-linux-using-the-at-command.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[0]: https://images.idgesg.net/images/article/2019/08/gettyimages-140389307-100808283-large.jpg +[1]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/202004/20200403 Take back your dotfiles with Chezmoi.md b/published/202004/20200403 Take back your dotfiles with Chezmoi.md new file mode 100644 index 0000000000..caded6c08c --- /dev/null +++ b/published/202004/20200403 Take back your dotfiles with Chezmoi.md @@ -0,0 +1,308 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12109-1.html) +[#]: subject: (Take back your dotfiles with Chezmoi) +[#]: via: (https://fedoramagazine.org/take-back-your-dotfiles-with-chezmoi/) +[#]: author: (Ryan Walter https://fedoramagazine.org/author/rwaltr/) + +用 Chezmoi 取回你的点文件 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/14/183618dwkhe4ehx1kthxvw.jpg) + +在 Linux 中,点文件是隐藏的文本文件,从 Bash、Git 到 i3 或 VSCode 等更复杂的许多应用程序,都用它存储配置设置。 + +这些文件大多数都放在 `~/.config` 目录中或用户主目录中。编辑这些文件使你可以自定义也许没有提供设置菜单的应用程序,并且它们可以跨设备甚至是跨其它 Linux 发行版移植。但是,整个 Linux 发烧友社区的讨论焦点是如何管理这些点文件以及如何共享它们。 + +我们将展示一个名为 [Chezmoi][2] 的工具,该工具与其它工具略有不同。 + +### 点文件管理的历史 + +如果你在 [GitHub 上搜索“dotfiles”][3],那么你将看到有超过 10 万个存储库在解决一个目标:将人们的点文件存储在可共享且可重复的领地中。但是,除了都在使用 Git 之外,它们存储文件的方式各有不同。 + +虽然 Git 解决了代码管理问题,也将其转换为配置文件管理,但它并没有解决如何区分发行版、角色(例如家用计算机与工作计算机)、机密信息管理以及按设备配置的问题。 + +因此,许多用户决定制定自己的解决方案,多年来,社区已经做出了许多成果。本文将简要介绍已有的一些解决方案。 + +#### 在孤立的环境中进行实验 + +你想在封闭的环境中快速尝试以下解决方案吗?运行: + +``` +$ podman run --rm -it fedora +``` + +来创建一个 Fedora 容器尝试应用程序。退出容器时,该容器将自动删除自身。 + +#### 安装问题 + +如果将点文件存储在 Git 存储库中,你肯定希望可以让更改轻松地自动应用到主目录之中,乍一看,最简单的方法是使用符号链接,例如 `ln -s ~/.dotfies/bashrc ~/.bashrc`。这可以使你的更改在更新存储库时立即就绪。 + +符号链接的问题在于管理符号链接可能很麻烦。Stow 和 [RCM][4](在 Fedora 杂志上介绍过)可以帮助你管理这些,但是这些并不是非常舒服的解决方案。下载后,需要对私有文件进行适当的修改和设置访问模式。如果你在一个系统上修改了点文件,然后将存储库下载到另一个系统,则可能会发生冲突并需要进行故障排除。 + +解决此问题的另一种方法是编写自己的安装脚本。这是最灵活的选项,但要权衡花费更多时间来构建自定义解决方案是否值得。 + +#### 机密信息问题 + +Git 旨在跟踪更改。如果你在 Git 存储库中存储密码或 API 密钥之类的机密信息,则会比较麻烦,并且需要重写 Git 历史记录以删除该机密信息。如果你的存储库是公开的,那么如果其他人下载了你的存储库,你的机密信息将不再保密。仅这个问题就会阻止许多人与公共世界共享其点文件。 + +#### 多设备配置问题 + +问题不在于如何将配置拉到多个设备,而是当你有多个需要不同配置的设备的问题。大多数人通过使用不同的文件夹或使用不同的复刻fork来处理此问题。这使得难以在不同设备和角色集之间共享配置。 + +### Chezmoi 是如何干的 + +Chezmoi 是一种考虑了以上问题的用于管理点文件的工具,它不会盲目地从存储库复制或符号链接文件。 Chezmoi 更像是模板引擎,可以根据系统变量、模板、机密信息管理器和 Chezmoi 自己的配置文件来生成你的点文件。 + +#### Chezmoi 入门 + +目前,Chezmoi 并不在 Fedora 的默认软件库中。你可以使用以下命令下载 Chezmoi 的当前版本。 + +``` +$ sudo dnf install https://github.com/twpayne/chezmoi/releases/download/v1.7.17/chezmoi-1.7.17-x86_64.rpm +``` + +这会将预打包的 RPM 安装到你的系统中。 + +让我们继续使用以下方法创建你的存储库: + +``` +$ chezmoi init +``` + +它将在 `~/.local/share/chezmoi/` 中创建你的新存储库。你可以使用以下命令轻松地切换到该目录: + +``` +$ chezmoi cd +``` + +让我们添加第一个文件: + +``` +chezmoi add ~/.bashrc +``` + +这将你的 `.bashrc` 文件添加到 chezmoi 存储库。 + +注意:如果你的 `.bashrc` 文件实际上是一个符号链接,则需要添加 `-f` 标志以跟随它来读取实际文件的内容。 + +现在,你可以使用以下命令编辑该文件: + +``` +$ chezmoi edit ~/.bashrc +``` + +现在让我们添加一个私有文件,这是一个具有 600 或类似权限的文件。我在 `.ssh/config` 中有一个文件,我想通过使用如下命令添加它: + +``` +$ chezmoi add ~/.ssh/config +``` + +Chezmoi 使用特殊的前缀来跟踪隐藏文件和私有文件,以解决 Git 的限制。运行以下命令以查看它: + +``` +$ chezmoi cd +``` + +**请注意,标记为私有的文件实际上并不是私有的,它们仍会以纯文本格式保存在你的 Git 存储库中。稍后会进一步解释。** + +你可以使用以下方法应用任何更改: + +``` +$ chezmoi apply +``` + +并使用如下命令检查有什么不同: + +``` +$ chezmoi diff +``` + +#### 使用变量和模板 + +要导出 Chezmoi 可以收集的所有数据,请运行: + +``` +$ chezmoi data +``` + +其中大多数是有关用户名、架构、主机名、操作系统类型和操作系统名称的信息。但是你也可以添加我们自己的变量。 + +继续,运行: + +``` +$ chezmoi edit-config +``` + +然后输入以下内容: + +``` +[data] + email = "fedorauser@example.com" + name = "Fedora Mcdora" +``` + +保存文件,然后再次运行 `chezmoi data`。你将在底部看到你的电子邮件和姓名已经添加成功。现在,你可以将这些与 Chezmoi 的模板一起使用。运行: + +``` +$ chezmoi add -T --autotemplate ~/.gitconfig +``` + +来将你的 `.gitconfig` 作为模板添加到 Chezmoi 中。如果 Chezmoi 成功地正确推断了模板,你将获得以下信息: + +``` +[user] + email = "{{ .email }}" + name = "{{ .name }}" +``` + +如果没有,则可以将文件更改为这样。 + +使用以下方法检查文件: + +``` +$ chezmoi edit ~/.gitconfig +``` + +然后使用: + +``` +$ chezmoi cat ~/.gitconfig +``` + +来查看 Chezmoi 为此文件生成什么。我生成的示例如下: + +``` +[root@a6e273a8d010 ~]# chezmoi cat ~/.gitconfig +[user] + email = "fedorauser@example.com" + name = "Fedora Mcdora" +[root@a6e273a8d010 ~]# +``` + +它将在我们的 Chezmoi 配置中生成一个充满变量的文件。你也可以使用变量执行简单的逻辑语句。一个例子是: + +``` +{{- if eq .chezmoi.hostname "fsteel" }} +# 如果主机名为 "fsteel" 才包括此部分 +{{- end }} +``` + +请注意,要使其正常工作,该文件必须是模板。你可以通过查看文件是否在 `chezmoi cd` 中的文件名后附加 `.tmpl` 或使用 `-T` 选项读取文件来进行检查。 + +#### 让机密信息保持机密 + +要对设置进行故障排除,请使用以下命令。 + +``` +$ chezmoi doctor +``` + +这里重要的是它还向你显示了[所支持的密码管理器][5]。 + +``` +[root@a6e273a8d010 ~]# chezmoi doctor + warning: version dev + ok: runtime.GOOS linux, runtime.GOARCH amd64 + ok: /root/.local/share/chezmoi (source directory, perm 700) + ok: /root (destination directory, perm 550) + ok: /root/.config/chezmoi/chezmoi.toml (configuration file) + ok: /bin/bash (shell) + ok: /usr/bin/vi (editor) + warning: vimdiff (merge command, not found) + ok: /usr/bin/git (source VCS command, version 2.25.1) + ok: /usr/bin/gpg (GnuPG, version 2.2.18) + warning: op (1Password CLI, not found) + warning: bw (Bitwarden CLI, not found) + warning: gopass (gopass CLI, not found) + warning: keepassxc-cli (KeePassXC CLI, not found) + warning: lpass (LastPass CLI, not found) + warning: pass (pass CLI, not found) + warning: vault (Vault CLI, not found) + [root@a6e273a8d010 ~]# +``` + +你可以使用这些客户端,也可以使用[通用客户端][6],也可以使用系统的[密钥环][7]。 + +对于 GPG,你需要使用以下命令将以下内容添加到配置中: + +``` +$ chezmoi edit-config +``` + +``` +[gpg] + recipient = "开悟 enlightenment
”。 + +然而,当 Enlightenment 18 版本发布以后,这一切都改变了。该版本是如此的糟糕,以至于它并没有集成到 Bodhi 中。Enlightenment 19 发布后修复了一些问题,但仍然存在一些不足。 + +在尝试与 Enlightenment 开发团队合作却毫无进展之后,Bodhi 开发者在 2015 年[复刻][8]了 Enlightenment 17。新的桌面环境被命名为 [Moksha][9],它是基于梵文单词“解脱、解放或释放”。你可以在 [GitHub][10] 上找到它的代码。 + +### 5.1.0 有什么新特性? + +- [Bodhi Linux 5.1 Trailer](https://youtu.be/e8wcRL9F3p8) + +[Bodhi 5.1.0][12] 是这两年内发布的第一个版本,也是基于 Ubuntu 18.04 的第二个版本。除了更新包,它还有新的默认图标和主题。该版本对默认应用程序做了几处更改。预装版 Leafpad 取代了 epad 并且 [GNOME Web][13](也被称为 Epiphany)代替了 [Midori][14]。删除了 eepDater 系统更新器。 + +目前有[四个不同的版本][15]的 Bodhi5.1.0 可以[下载][16]: 标准版Standard硬件支持版Hwe兼容版Legacy软件包版AppPack。 + +* 标准适用于过去十年内电脑配置。它不推送内核更新。 +* 硬件支持版是 Bodhi 家族的新成员,其设计用来包括对更新的硬件的支持,并会接收到内核更新。5.1 版本的使用的是 5.3.0-42 内核。 +* 兼容版是仅有的 32 位版本。它使用“较旧的 4.9.0-6-686 Linux 内核,该内核针对旧的(15 年以上)硬件进行了优化。这个内核也不包括许多老系统不支持的 PAE 扩展。” +* 软件包版是为那些想要一个开箱即用的全载系统的人准备的,并预装了许多应用程序。 + +### Bodhi Linux 的系统要求 + +最低系统要求: + + * 500 MHz 处理器 + * 256 MB 内存 + * 5 GB 的硬盘存储空间 + +推荐系统要求: + + * 1.0 GHz 处理器 + * 512 MB 内存 + * 10 GB 的硬盘存储空间 + +### 体验 Bodhi Linux + +![Old Bodhi Linux][17] + +由于它是基于 Ubuntu 的,所以安装 Bodhi 非常简单。当我登录到 Bodhi 后,新的主题和图标集让我大吃一惊。上次我安装 Bodhi(包括几个月前的 5.0)时,我认为它需要换一个新的外观。之前的主题并没有什么问题,但看起来像是二十一世纪初的东西。新的主题使它看起来更具现代感。 + +![Bodhi Linux 5.1][18] + +我也很高兴看到 Midori 浏览器被 GNOME Web 所取代。我不是 [Midori 浏览器][19]的粉丝。对我来说,它总是显得功能太少了。(不过,随着 [Midori Next][20] 的推出,这种情况可能会改变。)GNOME Web 更像是我需要的网页浏览器。最重要的是它带有 Firefox Sync,这样我就可以同步我所有的书签和密码了。 + +与许多 Linux 发行版不同,Bodhi 并没有一个独立的软件中心。相反,如果你点击 AppCenter 图标,它会打开浏览器,并导航到 Bodhi 网站的软件中心页面 [AppCenter 页面][21]。这里的应用程序是按类别排序的,它们中的大多数是[轻量级应用程序][22]。 + +![Bodhi Linux Appcenter][23] + +如果你点击其中一个页面并点击“安装”,(在你输入密码之后)Bodhi 就会安装它。这是通过一个名为 [apturl][24] 的小程序实现的,它是“是一个非常简单的从网页浏览器安装软件包的方法”。它非常灵巧,我希望更多基于 Ubuntu 的发行版使用它。 + +总的来说,我喜欢 Moksha 桌面。它坚持我们几十年来看到的桌面风格(这是我最喜欢的)。它不会影响你,却很容易改变和定制。我唯一怀念的是,当我按下超级键时,应用程序菜单不打开。但我猜你不可能拥有生活中的一切。 + +### 结语 + +我对最近发布的 Bodhi Linux 感到十分惊喜。过去,我经常折腾它。并且我一直很喜欢它,但最近的这个版本是迄今为止最好的。在某种程度上,他们打破了 Bodhi 只适合老系统的想法,加入了对较新内核的支持。 + +如果你想换换个环境,同时又想在 Ubuntu 的世界里寻找新的风景,那就试试[Bodhi Linux][3]吧。 + +你用过 Bodhi Linux 吗?你最喜欢的基于 Ubuntu 的发行版是什么?请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bodhi-linux-review/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/lightweight-linux-beginners/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/bodhi-start-page.png?resize=800%2C500&ssl=1 +[3]: https://www.bodhilinux.com/ +[4]: https://www.bodhilinux.com/w/wiki/ +[5]: https://www.bodhilinux.com/w/what-is-bodhi-linux/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/bodhi-desktop.jpg?resize=800%2C500&ssl=1 +[7]: https://www.enlightenment.org/start +[8]: https://www.bodhilinux.com/2015/04/28/introducing-the-moksha-desktop/ +[9]: https://www.bodhilinux.com/moksha-desktop/ +[10]: https://github.com/JeffHoogland/moksha +[11]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[12]: https://www.bodhilinux.com/2020/03/25/bodhi-linux-5-1-0-released/ +[13]: https://wiki.gnome.org/Apps/Web/ +[14]: https://en.wikipedia.org/wiki/Midori_(web_browser +[15]: https://www.bodhilinux.com/w/selecting-the-correct-iso-image/ +[16]: https://www.bodhilinux.com/download/ +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/bodhi.png?resize=800%2C400&ssl=1 +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/bodhi-Linux-5-1-screenshot.jpg?ssl=1 +[19]: https://itsfoss.com/midori-browser/ +[20]: https://www.midori-browser.org/2020/01/15/midori-next-come-on-yarovi-we-can/ +[21]: https://www.bodhilinux.com/a/ +[22]: https://itsfoss.com/lightweight-alternative-applications-ubuntu/ +[23]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/Bodhi-Linux-AppCenter.png?resize=800%2C500&ssl=1 +[24]: https://wiki.ubuntu.com/AptUrl +[25]: https://reddit.com/r/linuxusersgroup diff --git a/published/202004/20200404 What is Arch User Repository (AUR)- How to Use AUR on Arch and Manjaro Linux.md b/published/202004/20200404 What is Arch User Repository (AUR)- How to Use AUR on Arch and Manjaro Linux.md new file mode 100644 index 0000000000..df0074259a --- /dev/null +++ b/published/202004/20200404 What is Arch User Repository (AUR)- How to Use AUR on Arch and Manjaro Linux.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12107-1.html) +[#]: subject: (What is Arch User Repository (AUR)? How to Use AUR on Arch and Manjaro Linux?) +[#]: via: (https://itsfoss.com/aur-arch-linux/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +什么是 Arch 用户仓库(AUR)以及如何使用? +====== + +如果你一直在使用 [Arch Linux][1] 或其他基于 Arch 的发行版,如 Manjaro,那么可能会遇到 AUR。你尝试安装新软件,有人建议从 AUR 中安装它。这让你感到困惑。 + +什么是 AUR?为什么使用它?如何使用 AUR?我将在本文中回答这些问题。 + +### 什么是 AUR? + +![][2] + +AUR 表示Arch 用户仓库Arch User Repository。它是针对基于 Arch 的 Linux 发行版用户的社区驱动的仓库。它包含名为 [PKGBUILD][3] 的包描述,它可让你使用 [makepkg][4] 从源代码编译软件包,然后通过 [pacman][5](Arch Linux 中的软件包管理器)安装。 + +创建 AUR 的目的是组织和共享社区中的新软件包,并帮助加速将流行的软件包纳入[社区仓库][6]。 + +进入官方仓库的大量新软件包都从 AUR 开始。在 AUR 中,用户可以贡献自己的软件包构建(PKGBUILD 和相关文件)。 + +AUR 社区可以对 AUR 中的软件包进行投票。如果一个软件包变得足够流行(假设它具有兼容的许可证和良好的打包技术),那么可以将其加入 `pacman` 直接访问的社区仓库中。 + +> 简而言之,AUR 是开发人员在 Arch 仓库中正式包含新软件之前向 Arch Linux 用户提供新软件的一种方式。 + +### 你应该使用 AUR 吗?有什么风险? + +使用 AUR 就像过马路一样。如果你谨慎操作,应该就没问题。 + +如果你刚接触 Linux,建议你在建立有关 Arch/Manjaro 和 Linux 的基础知识之前不要使用 AUR。 + +的确,任何人都可以将软件包上传到 AUR,但[受信任用户][7](TU)负责监视上传的内容。尽管 TU 对上传的软件包执行质量控制,但不能保证 AUR 中的软件包格式正确或没有恶意。 + +在实践中,AUR 似乎很安全,但理论上讲它可以造成一定程度的损害,但前提是你不小心。从 AUR 构建软件包时,聪明的 Arch 用户**总是**检查 `PKGBUILD` 和 `*.install` 文件。 + +此外,TU(受信任用户)还会删除 AUR 中包含在 core/extra/community 中的软件包,因此它们之间不应存在命名冲突。AUR 通常会包含软件包的开发版本(cvs/svn/git 等),但它们的名称会被修改,例如 foo-git。 + +对于 AUR 软件包,`pacman` 会处理依赖关系并检测文件冲突,因此,除非你默认使用 `–force` 选项,否则你不必担心用另一个包中的文件会覆盖另一个包的文件。如果这么做了,你可能会遇到比文件冲突更严重的问题。 + +### 如何使用 AUR? + +使用 AUR 的最简单方法是通过 AUR 助手。 [AUR 助手][8] 是一个命令行工具(有些还有 GUI),可让你搜索在 AUR 上发布的软件包并安装。 + +#### 在 Arch Linux 上安装 AUR 助手 + +假设你要使用 [Yay AUR 助手][9]。确保在 Linux 上安装了 git。然后克隆仓库,进入目录并构建软件包。 + +依次使用以下命令: + +``` +sudo pacman -S git +sudo git clone https://aur.archlinux.org/yay-git.git +cd yay +makepkg -si +``` + +安装后,你可以使用 `yay` 命令来安装软件包: + +``` +yay -S package_name +``` + +并非必须使用 AUR 助手来从 AUR 安装软件包。从以下文章解如何在没有 AUR 助手的情况下使用 AUR。 + +#### 不使用 AUR 助手安装 AUR 软件包 + +如果你不想使用 AUR 助手,那么也可以自行从 AUR 安装软件包。 + +在 [AUR 页面][10]上找到要安装的软件包后,建议确认“许可证”、“流行程度”、“最新更新”、“依赖项”等,作为额外的质量控制步骤。 + +``` +git clone [package URL] +cd [package name] +makepkg -si +``` + +例如。假设你要安装 [telegram 桌面包][11]: + +``` +git clone https://aur.archlinux.org/telegram-desktop-git.git +cd telegram-desktop-git +makepkg -si +``` + +#### 在 Manjaro Linux 中启用 AUR 支持 + +它默认情况下未启用 AUR,你必须通过 `pamac` 启用它。我的笔记本电脑运行 [Manjaro][12] Cinnamon,但是所有 Manjaro 变种的步骤都相同。 + +打开 Pamac(显示为 “Add/Remove Software”): + +![][13] + +进入 Pamac 后,请进入如下所示的首选项preferences。 + +![][14] + +在首选项对话框中,进入 “AUR” 选项卡,启用 AUR 支持,启用检查更新,并关闭对话框。 + +![][15] + +现在,你可以搜索软件包,并且可以通过软件包描述下的标签来识别属于 AUR 的软件包。 + +![][16] + +希望本文对你有用,并关注社交媒体上即将出现的与 Arch 相关的主题。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/aur-arch-linux/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://www.archlinux.org/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/what-is-aur.png?ssl=1 +[3]: https://wiki.archlinux.org/index.php/PKGBUILD +[4]: https://wiki.archlinux.org/index.php/Makepkg +[5]: https://wiki.archlinux.org/index.php/Pacman#Additional_commands +[6]: https://wiki.archlinux.org/index.php/Community_repository +[7]: https://wiki.archlinux.org/index.php/Trusted_Users +[8]: https://itsfoss.com/best-aur-helpers/ +[9]: https://github.com/Jguer/yay +[10]: https://aur.archlinux.org/ +[11]: https://aur.archlinux.org/packages/telegram-desktop-git +[12]: https://manjaro.org/ +[13]: https://i1.wp.com/i.imgur.com/kFF6HtW.png?ssl=1 +[14]: https://i0.wp.com/i.imgur.com/47r963A.png?ssl=1 +[15]: https://i1.wp.com/i.imgur.com/UThiDHO.png?ssl=1 +[16]: https://i2.wp.com/i.imgur.com/RM5BKi2.png?ssl=1 diff --git a/published/202004/20200407 15 years of Git- How to get started or learn something new.md b/published/202004/20200407 15 years of Git- How to get started or learn something new.md new file mode 100644 index 0000000000..d08342b3e7 --- /dev/null +++ b/published/202004/20200407 15 years of Git- How to get started or learn something new.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12104-1.html) +[#]: subject: (15 years of Git: How to get started or learn something new) +[#]: via: (https://opensource.com/article/20/4/get-started-git) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Git 都 15 岁了,如何入门或学习点新东西 +====== + +> 在 Git 15 周年之际,了解为什么 Git 是保持软件行业运行的重要组成部分。 + +![](https://img.linux.net.cn/data/attachment/album/202004/13/091410k80er3mttrznc22e.jpg) + +如果说过去二十年来有什么东西改变了软件,那么 [Git][2] 肯定位列榜首。 + +如果你没有亲自使用过 Git,你可能会认为它只是一种技术时尚,只是因为它是由 [Linux][3] 项目的创始人创建的,所以在开发者中只是一个偶然的宠儿。这或许有一定的道理,但 Git 确实取得了一些其他行业所没有的成就。有了 Git,分布在世界各地的开发者们可以在同一时间对同一段代码进行工作,并记录下每一次修改的历史,然后将所有的工作合并到一起,形成一个成品。由于这件事情非常复杂,所以这个工具本身也会变得很复杂,但归根结底,它是维持软件行业运行的重要组成部分。 + +无论你是否了解 Git,如果你足够深入的研究开源软件,或者进入计算机科学领域,都有可能遇到它。无论你使用 Git 只是为了下载一个安装包,还是每天与它交互来管理代码,了解更多关于它的知识,都会对你有很大的启发和帮助。 + +### Git 术语 + +与任何专业工具一样,Git 中也有很多行话。像“克隆clone”、“合并merge”和“变基rebase”这样的术语,最起码也是神秘的,而更糟的情况下会令人感到排斥。试图理解这些术语的含义可能会让人不知所措,但如果你从 Matthew Broberg 的优秀文章《[Git 术语基础][4]》中得到一点指导,就不会这样了。只需快速阅读一下,你就能真正理解地听懂关于 Git 的对话。 + +### Git 入门 + +如果你需要知道如何使用 Git,那么我自己的[关于使用 Git 的入门文章系列][5]是一个很好的开始。这些文章已经有几年的历史了,但就像许多 Linux 和 UNIX 技术一样,它的界面并没有发生很大的变化,所以这些文章和我写这些文章那时一样,在今天还是很有意义的。这一系列文章向你介绍了 Git 最基本的概念,并带领你完成创建仓库、提交文件、恢复文件、合并分支等过程。 + +### 常见的 Git 服务 + +Git 最常见的用途之一是公共的 Git 托管服务,比如 GitLab 和 GitHub。Kedar Vijay Kulkarni 在他的《[如何在 Git 中克隆、修改、添加和删除文件][6]》一文中,演示了大多数开发者使用 Git 执行的日常任务。这不是非开发者的必读书目,但对于任何想在公共 Git 托管服务上为项目做贡献的人来说,这篇文章是必读的。这篇文章专门针对的是 Github,因为它是当今最常见的平台之一,但其原理也适用于任何 Git 服务的 Web 前端,包括 [GitLab][7]、[Gogs][8] 和 [Gitea][9] 等流行的开源框架。 + +### 试试这个 Git 演练 + +与其漫无目的的探索,你是不是更喜欢在导游的带领下学习?有时候,学习一件事最简单的方法就是模仿别人的准确步骤。你知道最终的结果是肯定成功的,所以你在进行练习的时候会有信心,而你的大脑和手指也会得到重复的好处,从而建立起记忆。如果这是你的学习风格,那就跟着 Alan Formy-Duvall 的《[Git 的实用学习练习][10]》,找出成功的 Git 课程的感觉。 + +### Git 应用程序 + +信不信由你,Git 的界面比你在终端输入的文字更多。显然,在线托管的 Git 有 Web 界面,但是你也可以在计算机上使用 Git 客户端。如果想获得更多的帮助,请阅读 Jesse Duffield 关于 [Lazygit][11] 的文章或 Olaf Anders 关于 [Tig][12] 的文章。要获得完整的图形应用程序体验,请阅读我有关 [Git-cola][13]、[Sparkleshare][14] 以及[其它应用][15]的文章。是的,甚至还有[用于你的移动设备的界面][16]! + +### 了解更多关于 Git 的信息 + +知识就是力量,所以不要让 Git 对你来说像个谜。无论你是直接使用它,还是只知道它的名字,或者你以前从未听说过它,现在都是了解 Git 的好时机。这里有很多资源可以帮助你了解它的工作原理、工作原理以及人们为什么这么喜欢它。潜入其中,按照自己的节奏来学习,并学会爱上 Git 吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/get-started-git + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2 (Scissors cutting open access to files) +[2]: https://en.wikipedia.org/wiki/Git +[3]: https://opensource.com/resources/linux +[4]: https://opensource.com/article/19/2/git-terminology +[5]: https://opensource.com/life/16/7/stumbling-git +[6]: https://opensource.com/article/18/2/how-clone-modify-add-delete-git-files +[7]: https://about.gitlab.com/install/ +[8]: https://gogs.io/ +[9]: https://gitea.io/en-us/ +[10]: https://opensource.com/article/19/5/practical-learning-exercise-git +[11]: https://opensource.com/article/20/3/lazygit +[12]: https://opensource.com/article/19/6/what-tig +[13]: https://opensource.com/article/20/3/git-cola +[14]: https://opensource.com/article/19/4/file-sharing-git +[15]: https://opensource.com/life/16/8/graphical-tools-git +[16]: https://opensource.com/article/19/4/calendar-git#mobile diff --git a/published/202004/20200407 Bitwarden- A Free - Open Source Password Manager.md b/published/202004/20200407 Bitwarden- A Free - Open Source Password Manager.md new file mode 100644 index 0000000000..5341efed3d --- /dev/null +++ b/published/202004/20200407 Bitwarden- A Free - Open Source Password Manager.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12111-1.html) +[#]: subject: (Bitwarden: A Free & Open Source Password Manager) +[#]: via: (https://itsfoss.com/bitwarden/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Bitwarden:一个自由开源的密码管理器 +====== + +> Bitwarden 是流行的开源密码管理器。在这里,我们来看看它提供了什么。 + +![][1] + +[Bitwarden][2] 是一个自由开源的密码管理器。你可能还记得,我们之前将它列为 [Linux 中的最佳密码管理器][3]之一。 + +就个人而言,几个月来我一直在多个设备上使用 Bitwarden 作为我的密码管理器。因此,在本文中,我将说明它提供的功能以及我的使用经验。 + +**注意:** 如果你对服务的安全性有疑问,请查看其官方安全性[常见问题页面][4]。 + +### Bitwarden 密码管理器的特性 + +![][5] + +[Bitwarden][2] 是许多其他方便的密码管理器的不错替代品。 + +以下是它的特性: + + * 提供免费和付费选择 + * 适用于团队(企业)和个人 + * 开源 + * 支持自托管 + * 能够作为身份验证器应用(如 Google 身份验证器) + * 跨平台支持(安卓、iOS、Linux、Windows 和 macOS) + * 提供浏览器扩展(Firefox,、Chrome、Opera、Edge、Safari) + * 提供命令行工具 + * 提供网页保管库 + * 能够导入/导出密码 + * [密码生成器][6] + * 自动填充密码 + * 两步身份验证 + +从技术上讲,Bitwarden 使用完全免费。然而,它也提供了一些付费计划(个人付费和商务付费计划)。 + +通过付费计划,你可以与更多用户共享密码、获取 API 访问权限(业务使用)以及更多此类高级功能。 + +以下是定价(在编写本文时): + +![][7] + +对于大多数个人来说,考虑到支持开源项目,10 美元/年的高级个人计划不应成为问题。当然,你也可以选择没有限制地免费使用。 + +### 在 Linux 上安装 Bitwarden + +![][8] + +很容易将 Bitwarden 安装到你的 Linux 系统上,因为它提供了一个 .AppImage 文件。如果你还不知道[如何使用 AppImage][9] 文件,你可以参考我们的指南。 + +如果你不喜欢使用 AppImage,你可以选择 [snap 包][10]或在其[官方下载页面][11]上下载 .deb 或者 .rpm 文件。你还可以查看其 [GitHub 页面][12]了解更多信息。 + +- [下载 Bitwarden][2] + +如果你对使用桌面应用不感兴趣,也可以使用浏览器扩展。 + +### 我使用 Bitwarden 的体验 + +在 Bitwarden 之前,我使用 [LastPass][13] 作为密码管理器。尽管这不是一个糟糕的选择,但它不是开源软件。 + +所以,在我发现 Bitwarden 后就决定使用它。 + +首先,我从 LastPass 导出我的数据,并导入到 Bitwarden 没有遇到困难。在此过程中我没有丢失任何数据。 + +除了桌面应用,我一直在使用 Bitwarden 的火狐插件和 Android 应用。使用六个多月后,我没有遇到任何问题。所以,如果你愿意试试看,我一定会给它好评! + +### 总结 + +我想说,对于那些想要一个可以到处工作,并且跨设备轻松同步的密码管理器的用户而言,Bitwarden 是一个完整的解决方案。 + +你可以免费入门,但如果可以,请购买 **10 美元/年**的高级计划来支持这个开源项目。 + +如果你正在寻找更多选择,你也可以查看我们的 [Linux 中 5 个最佳密码管理器][3]。 + +你试过 Bitwarden 了吗?如果没有,请试试看!此外,你最喜欢的密码管理器是什么?让我在下面的评论中知道! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bitwarden/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-screenshot.jpg?ssl=1 +[2]: https://bitwarden.com/ +[3]: https://linux.cn/article-11531-1.html +[4]: https://help.bitwarden.com/security/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-dark-mode.jpg?ssl=1 +[6]: https://itsfoss.com/password-generators-linux/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-pricing.jpg?ssl=1 +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/bitwarden-settings.png?ssl=1 +[9]: https://itsfoss.com/use-appimage-linux/ +[10]: https://snapcraft.io/bitwarden +[11]: https://bitwarden.com/#download +[12]: https://github.com/bitwarden +[13]: https://www.lastpass.com/ diff --git a/published/202004/20200407 New Linux Distribution UbuntuDDE Brings The Beautiful Deepin Desktop to Ubuntu.md b/published/202004/20200407 New Linux Distribution UbuntuDDE Brings The Beautiful Deepin Desktop to Ubuntu.md new file mode 100644 index 0000000000..87410d1362 --- /dev/null +++ b/published/202004/20200407 New Linux Distribution UbuntuDDE Brings The Beautiful Deepin Desktop to Ubuntu.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12114-1.html) +[#]: subject: (New Linux Distribution UbuntuDDE Brings The Beautiful Deepin Desktop to Ubuntu) +[#]: via: (https://itsfoss.com/ubuntudde/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +新的 Linux 发行版 UbuntuDDE 将漂亮的深度桌面带到 Ubuntu +====== + +深度是一个漂亮桌面环境,拥有直观的 UI。UbuntuDDE 项目结合了 Ubuntu 的强大和深度之美。 + +[深度桌面环境][1](DDE)是由[深度 Linux][2] 的开发人员创建的漂亮桌面环境。最初,深度 Linux 基于 [Ubuntu][3],但后来他们切换到了 [Debian][4]。 + +![Deepin Desktop Environment in Ubuntu][5] + +深度 Linux 的一个主要问题是它的下载服务器速度较慢。常规系统需要花几个小时才能下载,因为他们的所有服务器都在中国,而这些服务器很不幸的是速度极慢。 + +如果你想使用深度桌面,那没有什么可以阻止你将其安装在常规 Ubuntu 系统上。[UbuntuDDE][6] 试图通过在 Ubuntu 之上为你提供开箱即用的深度桌面体验来使其更简单。这样可以节省你在 Ubuntu 上安装和配置深度桌面的时间和精力。 + +![Screenshot of UbuntuDDE][7] + +### Ubuntu DDE:Ubuntu 的强大和深度桌面的漂亮 + +请注意,UbuntuDDE 不是 Ubuntu 的官方变种。UbuntuDDE 的开发人员与 Ubuntu 团队无关。UbuntuDDE 目前一个混合发行版,其目标是在未来的发行版中被接纳为 Ubuntu 的官方变种。 + +UbuntuDDE 开发人员得到了 Ubuntu Snapcraft 团队的 Alan Pope、Ubuntu Budgie 团队和 [Ubuntu Cinnamon][8] 团队,以及其他开发者,如 Hualet Wang 和 Felix Yan 的帮助。 + +在与 FOSS 的对话中,其主要开发人员 Arun 强调说,该项目的重点是定期维护 Ubuntu 的 DDE 软件包,并帮助用户享受 DDE(深度桌面环境)的全部乐趣。 + +![Ubuntu Deepin Edition login screen][9] + +Arun 还提到,这个 Ubuntu 和深度的混合项目首先是维护和打包来自上游(即深度仓库)的最新版本。然后,它最终与 Ubuntu 20.04 focal 结合,生成了一个镜像文件,每个人都可以安装,而不必麻烦地先安装常规的 Ubuntu,然后再安装深度桌面。UbuntuDDE 不仅是 DDE 和 Ubuntu 的组合,而且还是 UbuntuDDE 团队的软件包选择和设计变更的融合。 + +![UbuntuDDE screenshot][10] + +与 Deepin Linux 不同,UbuntuDDE 不使用深度应用商店。它改用 Ubuntu 软件中心。如果你被[这个来自武汉的深度 Linux 的间谍软件谣言][11]吓到了,这应该是一个好消息。 + +### 下载 UbuntuDDE 20.04 Beta + +UbuntuDDE 的目标是与 Ubuntu 20.04 一起发布第一个正式的稳定版本。像[其他 Ubuntu 变种][12]一样,UbuntuDDE 20.04 beta 也可供你下载并尝试。 + +> 警告! +> +> 一句话警告。 UbuntuDDE 是正在开发的新手项目。请不要在你的主用系统上使用它。如果要尝试,请在虚拟机或备用系统中使用它。 + +- [下载 Ubuntu 20.04 DDE Beta][13] + +![Installing UbuntuDDE][14] + +由于本质上是 Ubuntu,因此安装 UbuntuDDE 与安装 Ubuntu 相同。你可以参考这篇教程,其中展示了[如何在 VirtualBox 内安装 Ubuntu][15]。 + +我知道你可能会认为这“不过是另一个 Ubuntu” 或者“只是 Ubuntu 上的深度,任何人都可以做到的”。但是我也知道有一小部分用户喜欢像 UbuntuDDE 这样的项目,这对他们来说使事情变得容易。我的意思是有许多 Ubuntu 变种就是这样出现的。你怎么看? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntudde/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.deepin.org/en/dde/ +[2]: https://www.deepin.org/en/ +[3]: https://ubuntu.com/ +[4]: https://www.debian.org/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-deepin-edition-screenshot.jpg?ssl=1 +[6]: https://ubuntudde.com/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-deepin-edition-screenshot-1.jpg?ssl=1 +[8]: https://itsfoss.com/ubuntu-cinnamon/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-deepin-edition-screenshot-5.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-deepin-edition-screenshot-2.jpg?ssl=1 +[11]: https://www.deepin.org/en/2018/04/14/linux-deepin-is-not-spyware/ +[12]: https://itsfoss.com/which-ubuntu-install/ +[13]: https://ubuntudde.com/download/ +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-deepin-edition-screenshot-4.jpg?ssl=1 +[15]: https://itsfoss.com/install-linux-in-virtualbox/ diff --git a/published/202004/20200408 Create web tutorials with Reveal.js and Git.md b/published/202004/20200408 Create web tutorials with Reveal.js and Git.md new file mode 100644 index 0000000000..8d549aceaf --- /dev/null +++ b/published/202004/20200408 Create web tutorials with Reveal.js and Git.md @@ -0,0 +1,203 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12139-1.html) +[#]: subject: (Create web tutorials with Reveal.js and Git) +[#]: via: (https://opensource.com/article/20/4/create-web-tutorial-git) +[#]: author: (Eric D. Schabell https://opensource.com/users/eschabell) + +使用 Reveal.js 和 Git 创建网页教程 +====== + +> 通过这个简单的工作流程创建的研讨会幻灯片,可以在任何浏览器、设备和平台上获得一致的查看效果。 + +![](https://img.linux.net.cn/data/attachment/album/202004/23/094800ohkpbjd3zbj0dj0d.jpg) + +无论你是学习者还是教师,你可能都会认识到采用幻灯片放映来传播知识的在线研讨会workshop的价值。如果你曾经偶然看到过这样一个逐页、逐章设置的井井有条的教程,你可能会想知道创建这样的一个网站有多难。 + +好吧,让我在这里向你展示,使用全自动化的流程来生成这样的教程是多么容易。 + +### 介绍 + +当我开始将学习内容放到网上置时,体验并不是很好。我想要的是一种可重复的、一致的、易于维护的东西,因为我的内容会随着我教学的技术发展而变化。 + +我尝试了许多交付模型,从 [Asciidoctor][2] 这样的低级代码生成器到在单个 PDF 文件中放置教程。全都不能让我满意。当我举办现场的在座研讨会时,我喜欢使用幻灯片放映,因此我想知道我是否可以为我自己的在线的,自定进度的研讨会体验做同样的事情。 + +经过一番挖掘,我为创建无痛的研讨会网站打下了基础。当时我已经在使用一个演示文稿生成框架,这对我来说是很有帮助的,因为这个框架可以产生对网站友好的格式(HTML)。 + +### 设置 + +这里是这个项目所需要的基本组件。 + + * 研讨会的想法(这是你的问题,我帮不了你) + * 用于研讨会幻灯片的 Reveal.js + * GitLab 项目仓库 + * 你常用的 HTML 代码编辑器 + * Web 浏览器 + * 在你的机器上安装好 Git + +如果这个列表看起来令人望而生畏,那么有一个快速入门的方法,不需要把所有的东西一个个都拉到一起。你可以用我的模板项目来给你提供幻灯片和项目设置的入门教程。 + +本文假设你熟悉 Git 和在 Git 平台(如 GitLab)上托管项目。如果你需要指导或教程,请查看我们的[Git 入门系列][3]。 + +首先,将模板项目克隆到本地机器上。 + +``` +$ git clone https://gitlab.com/eschabell/beginners-guide-automated-workshops.git +``` + +为此设置一个新的 GitLab 项目,导入模板项目作为初始导入。 + +研讨会网站有一些重要的文件。在**根目录**下,你会发现一个名为 `.gitlab-ci.yml` 的文件,当你向主分支提交修改时(即将拉取请求合并到 `master` 分支),这个文件会作为触发器。它可以触发将 `slides` 目录的全部内容复制到 GitLab 项目的 `website` 文件夹中。 + +我把它托管在我的 GitLab 账户中,名为 `beginners-guide-automated-workshops`。当它部署完毕后,你可以在浏览器中通过导航到下列地址查看 `slides` 目录的内容: + +``` +https://eschabell.gitlab.io/beginners-guide-automated-workshops +``` + +对于你的用户帐户和项目,URL 如下所示: + +``` +https://[YOUR_USERNAME].gitlab.io/[YOUR_PROJECT_NAME] +``` + +这些是你开始创建网站内容所需要的基本素材。当你推送修改后,它们会自动生成更新过的研讨会网站。请注意,默认模板包含了几个示例幻灯片,这将是你完成对存储库的完整签入后的第一个研讨会网站。 + +研讨会模板生成的结果是一个 [receive.js][4] 幻灯片,可以在任何浏览器中运行,并可以自动调整大小,几乎可以让任何人在任何地方、任何设备上观看。 + +这样创建一个方便、易访问的研讨会怎么样? + +### 它是如何工作的 + +有了这些背景信息,你就可以开始探索研讨会的这些素材,并开始把你的内容放在一起了。你需要的一切都可以在项目的 `slides` 目录中找到;这里是使用 reveal.js 在浏览器中创建研讨会幻灯片的地方。 + +你将用来制作研讨会的文件和目录是: + + * `default.css`文件 + * `images` 目录 + * `index.html`文件 + +在你常用的 HTML/CSS 编辑器中打开每一个文件,然后进行下面描述的修改。你用哪个编辑器并不重要,我更喜欢 [RubyMine IDE][5],因为它能在本地浏览器中提供页面预览。这对我在将内容推送到研讨会网站之前测试内容时很有帮助。 + +#### default.css 文件 + +文件 `css/theme/default.css` 是一个基础文件,你将在这里为你的研讨会幻灯片设置重要的全局设置。其中值得注意的两个主要的项目是所有幻灯片的默认字体和背景图片。 + +在 `default.css` 中,看一下标有 `GLOBAL STYLES` 的部分。当前的默认字体在这一行中列出了。 + +``` +font-family: "Red Hat Display", "Overpass", san-serif; +``` + +如果你使用的是非标准字体类型,则必须在以下行中将其导入(Overpass 字体类型就是这样做的): + +``` +@import url('SOME_URL'); +``` + +`background` 是你创建的每张幻灯片的默认图像。它存储在 `images` 目录下(见下面),并在下面这一行中设置(重点是图像路径)。 + +``` +background: url("…/…/images/backgrounds/basic.png") +``` + +要设置一个默认背景,只需将这一行指向你要使用的图片。 + +#### images 目录 + +顾名思义,`images` 目录是用来存储你想在研讨会幻灯片上使用的图片。例如,我通常会把展示研讨会主题进展的截图放在我的个人幻灯片上。 + +现在,你只需要知道你需要将背景图片存储在一个子目录(`backgrounds`)中,并将你计划在幻灯片中使用的图片存储在 `images` 目录中。 + +#### index.html 文件 + +现在你已经把这两个文件整理好了,剩下的时间你就可以在 HTML 文件中创建幻灯片了,从 `index.html` 开始。为了让你的研讨会网站开始成形,请注意这个文件中的以下三个部分。 + + * `head `部分,在这里你可以设置标题、作者和描述。 + * `body` 部分,你可以在这里找到要设计的单个幻灯片。 + * 你可以在每个 `section` 中定义各个幻灯片的内容。 + +从 `head` 部分开始,因为它在顶部。模板项目有三个占位符行供你更新。 + +``` +INSERT-YOUR-TITLE-HERE + + +``` + +`title` 标签包含文件打开时显示在浏览器选项卡中的文字。请将其改为与你的研讨会的标题相关的内容(或研讨会的某个部分),但记得要简短,因为标签页的标题空间有限。`description` 元标签包含了对你的工作坊的简短描述,而 `author` 元标签是你应该把你的名字(如果你是为别人写的,则是工作坊创建者的名字)。 + +现在继续到 `body` 部分。你会注意到它被分成了许多 `section` 标签。`body` 的开头包含了一个注释,说明你正在为每个标有 `section` 的打开和关闭的标签创建幻灯片。 + +``` + +
+ + +
+``` + +接下来,创建你的各个幻灯片,每张幻灯片都用 `section` 标签封装起来。这个模板包括了一些幻灯片来帮助你开始制作。例如,这里是第一张幻灯片。 + +``` +
+
+

Beginners guide

+

to automated workshops

+
+
+ Brought to you by,
+ YOUR-NAME
+
+ +
+``` + +这张幻灯片有两个区域,用 `div` 标签分隔。用空格隔开了标题和作者。 + +如果你有一定的 HTML 使用知识,可以尝试各种东西来开发你的研讨会。使用浏览器预览结果的时候真的很方便。有些 IDE 提供了本地查看修改,但你也可以打开 `index.html` 文件查看你的修改,然后再推送到资源库中。 + +一旦你对你的研讨会感到满意,推送你的修改,然后等待它们通过持续集成管道。它们将像模板项目一样被托管在 。 + +### 了解更多 + +要了解更多关于这个工作流程可以做什么,请查看下面的示例研讨会和托管了研讨会集合的网站。所有这些都是基于本文中描述的工作流程。 + +研讨会例子: + + * [Red Hat Process Automation Manage workshop][6] + * [JBoss Travel Agency BPM Suite online workshop][7] + +研讨会集合: + + * [Rule the world: Practical decisions & process automation development workshops][8] + * [Application development in the cloud workshop][9] + * [Portfolio architecture: Workshops for creating impactful architectural diagrams][10] + +我希望这本新手指南和模板研讨会项目能让你看到,在开发和维护研讨会网站的过程中,可以轻松、无痛地完成。我也希望这个工作流程能让你的研讨会受众几乎在任何设备上都能完全访问你的内容,这样他们就能从你分享的知识中学习到你的知识。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/create-web-tutorial-git + +作者:[Eric D. Schabell][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/eschabell +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/read_book_guide_tutorial_teacher_student_apaper.png?itok=_GOufk6N (Person reading a book and digital copy) +[2]: https://asciidoctor.org/ +[3]: https://opensource.com/resources/what-is-git +[4]: https://revealjs.com/#/ +[5]: https://www.jetbrains.com/ruby/ +[6]: https://gitlab.com/bpmworkshop/rhpam-devops-workshop +[7]: https://gitlab.com/bpmworkshop/presentation-bpmworkshop-travel-agency +[8]: https://bpmworkshop.gitlab.io/ +[9]: https://appdevcloudworkshop.gitlab.io/ +[10]: https://redhatdemocentral.gitlab.io/portfolio-architecture-workshops diff --git a/published/202004/20200408 How to Create Templates in LibreOffice to Save Time and Increase Productivity.md b/published/202004/20200408 How to Create Templates in LibreOffice to Save Time and Increase Productivity.md new file mode 100644 index 0000000000..1377f03523 --- /dev/null +++ b/published/202004/20200408 How to Create Templates in LibreOffice to Save Time and Increase Productivity.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (qfzy1233) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12118-1.html) +[#]: subject: (How to Create Templates in LibreOffice to Save Time and Increase Productivity) +[#]: via: (https://itsfoss.com/create-templates-libreoffice/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +如何在 LibreOffice 中创建模板以实现省时高效 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/16/214314y17oww0ymfylyn1m.jpg) + +在 [LibreOffice][1] 中为你经常使用的文档创建模板可以为你节省一些时间。它可以是信件、财务表格抑或是简报。 + +模板不仅可以为你节省时间,另一方面它可以保证在同一机构内参与统一项目的小组成员文档的一致性。 + +举例而言,如果你是一家需要经常开具工作经验证明的企业,你可以创建一个模板,而不再需要从某个地方复制粘贴已保存的文档。当你需要开具一个新的经验证明时,你可以从模板中创建,稍微编辑一下就可以了。 + +LibreOffice 默认情况下提供了一些模板,但并不仅仅局限于使用这些,你可以根据自己的需求自由定制。 + +我认为模板是每个用户都应该了解的 [LibreOffice 基础技巧之一][2]。下面我将为你演示如何使用。 + +### 如何在 LibreOffice 中创建一个模板 + +首先,创建你希望通过最少的编辑就可以重复使用的文档。它可以是文档、电子表格或演示文稿。我在示例中使用的是 word 文档,但是所有步骤都是相同的。 + +然后转到“文件”选项卡并选择“存储为模板”。你将被提示输入“名称”及选择“类别”,再单击“保存”。 + +![Creating a new template in LibreOffice][3] + +此文件将以 .ots 格式保存在 LibreOffice 的模板文件夹中。你可以在其他安装了 LibreOffice 的系统上使用这些 .ots 文件,并在这些系统上使用相同的模板。 + +### 如何在 LibreOffice 中使用模板 + +要使用模板,请选择 “文件选项卡”,然后选择 “模板”。 + +不要担心! LibreOffice 在打开一个模板时会在不影响原始模板的情况下创建一个副本。你可以随意编辑文档而不必担心模板发生改动。 + +![Using templates][4] + +选择模板后,单击打开。你就可以随意编辑了。 + +### 如何在 LibreOffice 中更改模板 + +我们需求可能会不时变化,所以需要对模板进行相应。 + +编辑一个现有的模板,单击“文件” -> “模板”,然后右键单击所需的模板,然后单击“编辑”。 + +![edit Template][5] + +当你完成对模板的编辑时,单击“保存”以使更改生效。 + +总之,模板不仅可以减少重复任务的工作量,还可以防止用户出错。你可以利用电脑优势来灵活的处理重复性的任务,并以此提高你的效率。 + +> 福利小贴士 + +你可以在 [LibreOffice 网站][7]上找到大量的附加模板。你可以搜索你需要的,下载并使用它们。请注意,这些模板来自第三方和未经验证的用户。所以使用它们的风险需要自己承担。 + +之后我会继续分享更多这样的技巧。同时,你还可以学习一下如何创建模板[在 GNOME 的右键菜单上下文中添加“创建新文档”选项][8]。 + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/create-templates-libreoffice/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://www.libreoffice.org/ +[2]: https://itsfoss.com/libreoffice-tips/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/1.Template-save-as.png?resize=800%2C567&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/2.Use-a-template.png?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/3.edit-template.png?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2017/12/LibreOffice-logo.jpeg?fit=800%2C450&ssl=1 +[7]: https://extensions.libreoffice.org/templates +[8]: https://itsfoss.com/add-new-document-option/ diff --git a/published/202004/20200409 Here-s How to Find Out Which Desktop Environment You are Using.md b/published/202004/20200409 Here-s How to Find Out Which Desktop Environment You are Using.md new file mode 100644 index 0000000000..963a64f356 --- /dev/null +++ b/published/202004/20200409 Here-s How to Find Out Which Desktop Environment You are Using.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12124-1.html) +[#]: subject: (Here’s How to Find Out Which Desktop Environment You are Using) +[#]: via: (https://itsfoss.com/find-desktop-environment/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何找出你所使用的桌面环境 +====== + +如果你是 Linux 新用户,并在一个 Linux 论坛中寻求帮助,那么你可能会被问以下问题: + +> “你使用的是哪个桌面环境?” + +你知道什么是桌面环境desktop environment(DE),但你如何知道你使用的是哪一个?我会告诉你如何找到它。我将首先展示命令行方法,因为这适用于[各种 Linux 发行版][1]。我还将展示如何通过图形方式获得。 + +### 检查你使用的是哪个桌面环境 + +![][2] + +你可以[在 Linux 中使用 echo 命令][3]在终端中显示 `XDG_CURRENT_DESKTOP` 变量的值。 + +打开终端并复制粘贴此命令: + +``` +echo $XDG_CURRENT_DESKTOP +``` + +例如,这表明我在 [Ubuntu 20.04][5] 中使用了 [GNOME 桌面][4]: + +``` +[email protected]:~$ echo $XDG_CURRENT_DESKTOP +ubuntu:GNOME +``` + +尽管此命令可以快速告诉你正在使用哪个桌面环境,但它不会提供任何其他信息。 + +在某些情况下,了解桌面环境版本可能很重要。软件的每个新版本都会带来新功能或删除某些功能。[GNOME 3.36][6] 引入了“请勿打扰”选项,以关闭所有桌面通知。 + +假设你了解了这个新的“请勿打扰”功能。你确认自己正在使用 GNOME,但是在 GNOME 桌面上看不到此选项。如果你可以检查系统上已安装的 GNOME 桌面版本,那么这会很清楚。 + +我将先向你展示命令检查桌面环境版本,因为你可以在任何运行桌面环境的 Linux 中使用它。 + +### 如何获取桌面环境版本 + +与获取桌面环境的名称不同。获取其版本号的方法并不直接,因为它没有标准的命令或环境变量可以提供此信息。 + +在 Linux 中获取桌面环境信息的一种方法是使用 [Screenfetch][7] 之类的工具。此[命令行工具以 ascii 格式显示 Linux 发行版的 logo][8] 以及一些基本的系统信息。桌面环境版本就是其中之一。 + +在基于 Ubuntu 的发行版中,你可以通过[启用 Universe 仓库][9]安装 Screenfetch,然后使用以下命令: + +``` +sudo apt install screenfetch +``` + +对于其他 Linux 发行版,请使用系统的软件包管理器来安装此程序。 + +安装后,只需在终端中输入 `screenfetch` 即可,它应该显示桌面环境版本以及其他系统信息。 + +![Check Desktop Environment Version][10] + +如上图所示,我的系统使用 GNOME 3.36.1(基本版本是 GNOME 3.36)。你也可以这样[检查 Linux 内核版本][11]和其他详细信息。 + +请记住,Screenfetch 不一定显示桌面环境版本。我查看了它的源码,它有许多 if-else 代码,可以从各种桌面环境中的许多源和参数获取版本信息。如果找不到任何版本,那么仅显示桌面环境名称。 + +### 使用 GUI 检查桌面环境版本 + +几乎所有桌面环境在其 “Settings”->“About” 部分中都提供了基本的系统详细信息。 + +一个主要问题是,大多数桌面环境看起来都不同,因此我无法展示每个桌面环境的确切步骤。我将展示 GNOME 的,让你在桌面上发现它。 + +在菜单中搜索 “Settings”(按 Windows 键并搜索): + +![Search for Settings application][12] + +在这里,找到底部的 “About” 部分。单击它,你应该就能看到桌面环境及其版本。 + +![Check Desktop Environment in Ubuntu][13] + +如你所见,这表明我的系统正在使用 GNOME 3.36。 + +我希望这个快速入门技巧对你有所帮助。如果你有任何疑问或建议,请在下面发表评论。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/find-desktop-environment/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/what-is-linux/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/check-desktop-environment.jpg?ssl=1 +[3]: https://linuxhandbook.com/echo-command/ +[4]: https://www.gnome.org/ +[5]: https://itsfoss.com/ubuntu-20-04-release-features/ +[6]: https://itsfoss.com/gnome-3-36-release/ +[7]: https://github.com/KittyKatt/screenFetch +[8]: https://itsfoss.com/display-linux-logo-in-ascii/ +[9]: https://itsfoss.com/ubuntu-repositories/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/check-desktop-environment-version.jpg?ssl=1 +[11]: https://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/applications_menu_settings.jpg?ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/check-desktop-environment-ubuntu.jpg?ssl=1 diff --git a/published/202004/20200410 How I-m using AI to translate -wash your hands- in 500 languages.md b/published/202004/20200410 How I-m using AI to translate -wash your hands- in 500 languages.md new file mode 100644 index 0000000000..4117cefacf --- /dev/null +++ b/published/202004/20200410 How I-m using AI to translate -wash your hands- in 500 languages.md @@ -0,0 +1,136 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12131-1.html) +[#]: subject: (How I'm using AI to translate 'wash your hands' in 500 languages) +[#]: via: (https://opensource.com/article/20/4/ai-translation) +[#]: author: (Daniel Whitenack https://opensource.com/users/datadan) + +我是如何用 AI 把“请洗手”翻译成 500 种语言的? +====== + +> 通过使用人类和机器生成的翻译,可以将关键的健康短语翻译成世界各地的当地语言。 + +![](https://img.linux.net.cn/data/attachment/album/202004/20/184427f1a2t5z61m5xxo1t.jpg) + +你可能不知道,目前世界上有 [7117 种语言][2]在使用,不是方言,而是在用的语言! 然而,世界上许多数字媒体只能使用几十种语言,而像谷歌翻译这样的翻译平台只支持 100 种左右的语言。这样的现实意味着,由于缺乏及时获取信息的机会,全世界有数十亿人被边缘化。当前的冠状病毒(COVID-19)大流行已经让人痛苦地意识到了这一点,凸显了将健康相关的短语(如“请洗手wash your hands”或“保持距离”等)即时、快速翻译成小众语言的必要性。 + +为此,我应用了最先进的 AI 技术,用 544 种语言构建出了与“请洗手”相近的短语并进行了统计(我的 GPU 还在运行)。多语言无监督和受监督嵌入Multilingual Unsupervised and Supervised Embeddings(MUSE)方法被用来训练这 544 种语言和英语之间的跨语言单词嵌入。然后,这些嵌入方法可以从现有文档中提取出与目标短语相似的短语。 + +我与 SIL 国际公司的同事们合作完成了这项工作,他们收集了该短语的更多的人工翻译结果。这些人工翻译结果和我的一些机器翻译结果的组合可以在[这个民族语指南页面][3]上搜索到(机器生成的短语用一个小的机器人图标表示),更多的翻译将在生成/收集到的时候加入。 + +### 利用现有的语料库 + +SIL 国际公司已经完成了 2000 多种语言的语言工作,目前管理着 1600 多个语言项目。因此,当我解决这个特殊的问题时,我知道我们很可能已经多次将“请洗手”和/或类似的短语翻译成了数百种语言,而这一猜测得到了回报。我很快就从我们的档案库中收集到了超过 900 种语言的文档(主要是完成的贝壳书模板、教材和圣经)。这些文档中的每一份都有一个英文的对应版本,其中必然包括“请洗手”和/或类似“请洗脸”这样的短语。此外,这些文档的质量都很高,并与当地语言社区合作进行了翻译和检查。 + +这是相当多语言的数据集。然而,有两个问题需要克服。首先,这个数据包含了大多数语言的数千种样本,这与训练机器翻译模型所使用的数百万个样本形成了鲜明对比。其次,即使文档中包含目标语言中的“请洗手”这个短语,我们也不知道这个短语在周围文本中的确切位置。 + +我们当然可以利用[低资源语言的机器翻译][4]中的一些最新技巧,但是需要花费一些时间来调整自动化方法,以快速适应每种语言对中的翻译模型。此外,我们所针对的许多语言都没有现成的的基线,可以用来比较评估指标(例如 [BLEU 评分][5])。考虑到对冠状病毒大流行的迫切担忧,我们希望比这更快一点(尽管我们计划在将来再来解决这个问题)。 + +我选择通过在现有的文档中寻找短语本身或短语的组件(如“请洗”或“你的手”)来尝试构建“请洗手”这个短语。为了找到这些成分,我使用 Facebook Research 的[多语言无监督和受监督嵌入(MUSE)][6]对每个 {英语、目标语言} 对进行了跨语言cross-lingual嵌入训练。MUSE 以单语言monolingual的单词嵌入作为输入(我使用 [fasttext][7] 来生成这些词),并使用对抗性方法学习了从英语到目标嵌入空间的映射。这个过程的输出是跨语言cross-lingual的单词嵌入。 + +![Using fasttext along with MUSE to perform cross-language embedding][8] + +一旦产生了跨语言嵌入,我们就可以开始在目标语言文档中寻找短语组件。结果发现,整个文档中清楚地使用了“请洗脸”这个短语以及单独的“手”、“请洗”等词。对于每一种语言,我都通过 n-gram 搜索我预期该短语会出现的地方(根据其在英语的对应版本中的用法)。使用跨语言嵌入法对 n-gram 进行了矢量化处理,并使用各种距离指标与英语短语的矢量化版本进行了比较。在嵌入空间中,与英文短语“最接近”的 n-gram 被确定为与目标语言匹配。 + +最后,将与英语对应的成分短语进行组合,生成目标语言中的“请洗手”短语。这种组合方式再次利用了跨语言嵌入,以确保以合适方式组合组件。例如,如果我们在目标语言中匹配“请洗脚”这个短语,就必须将“脚”对应的 n-gram 替换成“手”对应的 n-gram。下面是伯利兹·克里奥尔Belize Kriol英语的一个例子: + +![][9] + +当然,在这个匹配过程中,会做一些假设,这个过程完全有可能不能产生语法上正确的预测。例如,我假设在大多数语言中,“手”的单词和“脚”的单词都是一个字元token长的(字元由空格和标点符号隔开)。当然并非总是如此。这可能会造成类似于“和洗和手你”或类似的瑕疵词条。希望我们可以克服其中的一些局限性,并在未来扩展这个系统,但是,现在,我们选择用图形来强化这个想法。 + +我们将世界卫生组织的洗手说明改编成了一个 PNG 图片模板。然后,我们把我们翻译和生成的短语,用 Bash 和 Go 脚本的组合将其渲染到洗手图像中。这样,在文字和图像中都强调了正确洗手的理念(以防万一我们生成的翻译很尴尬)。 + +![][10] + +### 结果 + +到目前为止,我已经能够训练出 544 种语言的跨语言嵌入。我使用上述讨论过的方法尝试为所有这些语言构建“请洗手”这个短语。因为我没有许多语言对的对齐数据,所以我使用了同样包含“请洗手”成分的单独的保留文档来帮助验证构造短语中的字元。这让我们对公开发布的翻译版本有了一些信心(至少它们包含了表示“洗”和/或“手”的信息)。此外,我还将该方法与谷歌翻译支持的和/或有可用的人工翻译的语言对进行了比较。以下是来自 [Ethnologue][11] 带有语言统计的翻译样本。 + +**语言:意大利语 [Ita]** + +- 地点:意大利 +- 人口: 68,000,000 +- 我们的系统: làvati la mani +- 谷歌翻译: Lavati le mani + +**语言:保加利亚语 [bul]** + +- 地点:保加利亚 +- 人口:8,000,000 +- 我们的系统:умий ръцете +- 谷歌翻译:Измий си ръцете + +**语言: 荷兰语 [nld]** + +- 地点:荷兰 +- 人口:24,000,000,000 +- 我们的系统:wast uw handen +- 谷歌翻译:Was je handen + +**语言: Pijin [pis]** + +- 地点:所罗门群岛 +- 人口: 550,000 +- 我们的系统:wasim han +- 谷歌翻译:不支持 + +**语言:Tikar [tik]** + +- 地点:喀麦隆 +- 人口:110,000 +- 我们的系统:ɓɔsi fyàʼ +- 谷歌翻译:不支持 + +**语言:Waffa [waj]** + +- 地点:巴布亚新几内亚 +- 人口:1,300 +- 我们的系统:yaakuuvaitana nnikiiyauvaa fini +- 谷歌翻译:不支持 + +构造的短语类似于参考翻译,或者似乎是“请洗手”的另一种说法。例如,在保加利亚语中,我预测为“умий ръцете”,而谷歌翻译预测为“Измий си ръцете”。 然而,如果我用谷歌翻译回译我的预测,我还是会得到“请洗手”。有一些不确定的地方,我无法与参考译文(例如,所罗门群岛的 Pijin [pis])或人类注释的跨度进行比较,但我仍然可以验证“洗”(wasim)和“手”(han)分别用在其他必定是谈论洗或手的参考文件中。 大约有 15% 的译文可以用这个方法验证,我希望在收集参考文献字典的过程中能进行更多的验证。 + +请注意,我最多使用了每种语言中大约 7000 个句子来得到上述译文,即使是意大利语这样的高资源语言也是如此。我也不依赖语言对之间的对齐句子。尽管存在这种数据非常稀缺、无监督的情况,但对于两个系统都支持的语言,我仍然能够获得类似于谷歌翻译的短语。这证明了这种“混合”方法(无监督的单词嵌入+基于规则的匹配)在将短语翻译成数据非常少的语言中的潜在用途。 + +注意:我绝对不是说这是解决冠状病毒和其他健康相关的信息传播问题的解决方案。这里仍有很多东西需要探索和正式评估,我们正在为此努力。在很多情况下,这种方法无法帮助构建数百种语言的重要信息资料。但是,我认为,我们所有人都应该尝试着为当前危机的相关问题制定创造性的解决方案。也许这只是一个非常大的拼图中的一块。 + +你可以在[这个民族语言指南][3]上查看经过验证的译文加上人工翻译的完整列表。此外,我们即将以论文的形式对这一系统进行更深入的描述和分析。我们欢迎公众对翻译进行反馈,以帮助系统进行微调,最重要的是,确保将健康信息传递给世界各地的边缘化语言社区。 + +### 制作自己的洗手海报 + +我们已经开源了[用于渲染复合的脚本和生成洗手海报的代码][12]。这种方法应该能够处理几乎所有的语言和脚本。你可以在海报中添加你自己的“请洗手”的翻译,以帮助传播,或者根据自己的本地语境进行翻译。请务必在社交媒体上以 #WashYourHands 为标签分享你生成的海报。 + +### 培养你的 AI 技能 + +有很多令人兴奋的 AI 问题,可以给世界带来巨大的影响。如果你想用人工智能解决像上面提到的问题,或者你认为你的企业可能需要开始利用人工智能来做其他事情(供应链优化、推荐、客户服务自动化等),那么不要错过今年 5 月的[AI 课堂培训活动][13]。*AI 课堂*是一个沉浸式的、为期三天的虚拟培训活动,适合至少有一定编程经验和数学基础知识的人参加。该培训提供了使用 Python 和开源框架(如 TensorFlow 和 PyTorch)进行现实的 AI 开发的实用基础知识。完成课程后,学员将有信心开始开发和部署自己的 AI 解决方案。 + +本文经许可转载自 https://datadan.io/blog/wash-your-hands + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/ai-translation + +作者:[Daniel Whitenack][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/datadan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/world_hands_diversity.png?itok=zm4EDxgE (Two diverse hands holding a globe) +[2]: https://www.ethnologue.com/guides/how-many-languages +[3]: https://www.ethnologue.com/guides/health +[4]: https://datadan.io/blog/resources-for-low-resource-machine-translation +[5]: https://en.wikipedia.org/wiki/BLEU +[6]: https://github.com/facebookresearch/MUSE +[7]: https://fasttext.cc/ +[8]: https://opensource.com/sites/default/files/uploads/ai-language-translation-wash-your-hands-opensourcedotcom.gif (Using fasttext along with MUSE to perform cross-language embedding) +[9]: https://opensource.com/sites/default/files/uploads/ai-language-translation-wash-your-hands-opensourcedotcom2.gif +[10]: https://opensource.com/sites/default/files/uploads/ai-language-translation-wash-your-hands-opensourcedotcom3.gif +[11]: https://www.ethnologue.com/ +[12]: https://github.com/sil-ai/wash-your-hands +[13]: https://datadan.io/ diff --git a/published/202004/20200410 How to Go Full Dark Mode in Ubuntu 20.04.md b/published/202004/20200410 How to Go Full Dark Mode in Ubuntu 20.04.md new file mode 100644 index 0000000000..5ff72f17b5 --- /dev/null +++ b/published/202004/20200410 How to Go Full Dark Mode in Ubuntu 20.04.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12098-1.html) +[#]: subject: (How to Go Full Dark Mode in Ubuntu 20.04) +[#]: via: (https://itsfoss.com/dark-mode-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 Ubuntu 20.04 中完全进入深色模式 +====== + +> 深色模式是 Ubuntu 20.04 最受瞩目的[新功能][1]之一了。任何版本的 Ubuntu 都可以通过[安装深色主题][2]让用户界面拥有一个深色的外观,但在 Ubuntu 20.04 中,这个过程变得更简单。 + +![](https://img.linux.net.cn/data/attachment/album/202004/11/200841gvvaja25jaz5z7hv.jpg) + +在 Ubuntu 20.04 中,无需额外安装主题,默认主题(称为 Yaru)本身就带有三种模式,其中就包括深色模式。 + +下面我会展示如何将 Ubuntu 系统完全设置为深色模式。 + +### 在 Ubuntu 20.04 打开深色模式 + +- [video](https://player.vimeo.com/video/405726943) + +这个步骤是在 GNOME 桌面上进行的,如果你[使用的是其它桌面][4],你看到的可能会和下面的截图不一样。 + +按下 super 键(或 Windows 键),然后输入 “settings”,就可以找到系统设置。 + +![Search for Settings][5] + +在系统设置中,进入“外观Appearance”部分,就可以看到浅色light标准standard深色dark三个选项。既然要使用深色模式,那自然而然要选择“深色”这个选项了。 + +![Enable Dark Theme in Ubuntu][6] + +完成设置以后,使用了 GTK3 的应用程序都可以跟随深色模式。因此你会看到系统中包括文本编辑器、终端、LibreOffice 等在内的大多数应用程序都已经切换成深色了。但未使用 GTK3 的应用程序可能并没有跟随进入深色模式,下面我会展示如何更完整地进入深色模式。 + +### 继续调整,进入完整深色模式 + +这个时候你会发现,shell 主题、屏幕顶部面板中的消息托盘和系统托盘还仍然保持在原有的模式当中。 + +![No Dark Shell by default in Ubuntu][7] + +现在就需要使用 [GNOME 扩展][8]安装 Yaru 深色 shell 主题了。[在 Ubuntu 中通过 Ctrl+Alt+T 打开终端][9],然后执行以下这个命令安装浏览器扩展: + +``` +sudo apt install chrome-gnome-shell +``` + +进入[扩展页面][10]启用这个扩展: + +![Enable User Themes GNOME Extension][11] + +执行以下命令安装 [GNOME 调整工具][12]: + +``` +sudo apt install gnome-tweaks +``` + +打开 GNOME 调整工具,进入“外观Appearance”部分,就可以看到 shell 主题的选项,现在只需要把它启用就可以了。 + +![Enable Yaru Dark Shell Theme in Ubuntu][13] + +设置完之后再观察一下,桌面通知、消息托盘、系统托盘等等都已经进入深色模式了。 + +![Yaru Dark Shell Theme in Ubuntu][14] + +现在感觉好多了。但你可能还会注意到,在使用浏览器访问网站的时候,很多网站都使用了白色的背景色。如果期望网站方提供深色模式,那是很不现实的,但我们可以自己实现这一件事。 + +你需要用到的东西就是诸如 [Dark Reader][15] 这样的浏览器扩展。《[在 Firefox 中启用深色模式][16]》这篇文章中也有讨论过这个浏览器扩展,它的使用过程并不复杂,如果你使用的浏览器是 Firefox、Chrome 或 [Ubuntu 下的 Chromium][17],就可以直接安装[其官方网站][15]上列出的扩展。 + +Dark Reader 安装完成后,就会以深色模式打开网站了。 + +![It’s FOSS Homepage in Dark Mode with Dark Reader][18] + +当然,有些外部的第三方应用程序可能仍然是浅色状态。如果它们自己附带了深色模式的选项,就需要手动启用它们的深色模式。 + +如今,深色模式在非开发者人群中也越来越流行了。按照以上的步骤,你就可以轻松进入深色模式。 + +请享受深色模式。 + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/dark-mode-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ubuntu-20-04-release-features/ +[2]: https://itsfoss.com/install-themes-ubuntu/ +[3]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[4]: https://itsfoss.com/find-desktop-environment/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/settings-search-ubuntu-20-04.jpg?ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/enable-dark-theme-ubuntu.png?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/no-dark-shell-ubuntu.jpg?ssl=1 +[8]: https://itsfoss.com/gnome-shell-extensions/ +[9]: https://itsfoss.com/ubuntu-shortcuts/ +[10]: https://extensions.gnome.org/extension/19/user-themes/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/enable-user-themes-gnome.jpg?ssl=1 +[12]: https://itsfoss.com/gnome-tweak-tool/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-yaru-dark-shell-theme.jpeg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/yaru-dark-shell-theme-ubuntu.jpg?ssl=1 +[15]: https://darkreader.org/ +[16]: https://itsfoss.com/firefox-dark-mode/ +[17]: https://itsfoss.com/install-chromium-ubuntu/ +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/01/itsfoss_dark_mode.jpg?ssl=1 diff --git a/published/202004/20200413 A handy utility for creating Raspberry Pi SD card images.md b/published/202004/20200413 A handy utility for creating Raspberry Pi SD card images.md new file mode 100644 index 0000000000..9fd472c01d --- /dev/null +++ b/published/202004/20200413 A handy utility for creating Raspberry Pi SD card images.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12136-1.html) +[#]: subject: (A handy utility for creating Raspberry Pi SD card images) +[#]: via: (https://opensource.com/article/20/4/raspberry-pi-imager-mac) +[#]: author: (James Farrell https://opensource.com/users/jamesf) + +一个方便的用于创建树莓派 SD 卡镜像的程序 +====== + +> 开始在 Mac 上使用 Raspberry Pi Imager。 + +![Raspberries with pi symbol overlay][1] + +有多种购买树莓派的方法,根据你的购买渠道的不同,可能附带或不附带操作系统。要在树莓派上安装操作系统,只需将操作系统镜像 “闪存” 到 SD 卡即可。为了使之尽可能简单,[树莓派基金会][2]推出一个 Raspberry Pi Imager 实用程序,你可以在所有主流平台上下载它。下面就来简单介绍一下这个有用的新工具。 + +### 安装 Imager + +你通常可以在[树莓派下载][3]页面上找到 Raspberry Pi Imager。它有 Mac、Ubuntu 和 Windows 版本。我将下载并演示 Mac 版本。 + +Mac 的安装包是常规的 DMG 镜像,它会挂载到你的桌面,然后经典的安装界面就会出现: + +![Raspberry Pi Imager installer][4] + +只需将可爱的树莓图标拖到“应用”文件夹,就可以完成。从启动台中调用它,你会看到一系列简单的按钮和菜单供你选择。真的不能比这更简单了: + +![Raspberry Pi Imager home screen][5] + +### 可用的镜像和选项 + +默认选项包含各种树莓派型号的镜像。Raspbian 是首选,它有两个可用的选项,较小的 “Lite” 版本和较大的 “Full” 版本。LibreELEC Kodi 娱乐系统有各种特定于型号的版本。Ubuntu 18 和 19 有适用于不同树莓派型号的 32 位和 64 位版本。有一个 RPi 4 EEPROM 恢复程序,以及使用 FAT32 格式化卡的功能。最后,有一个通用的镜像安装程序选项,稍后我将进行尝试。这个简单而紧凑的程序非常方便。 + +### 安装一些镜像 + +我决定使用 16g 的 micro SD 卡。我选择了默认的 Raspbian 镜像,选择已连接的 USB/SD 设备,然后按下 “WRITE” 按钮。这是一个简短的演示: + +![Raspberry Pi Imager demo][6] + +我没有在此处发布整个操作过程。我认为它是在写入的时候下载了镜像,对于我的无线连接这花费了几分钟。该过程在完成之前要先经过写入,然后经过验证环节。完成后,我弹出设备,并将卡插入到我的树莓派 3 中,然后按照通常的图形 Raspbian 安装向导和桌面环境进行设置。 + +这对我来说还不够。我每天都会下载许多 Linux,今天我还在寻找更多。我回到了[树莓派下载][3]页面,并下载了 RISC OS 镜像。这个过程几乎一样容易。下载 RISCOSPi.5.24.zip 文件,将其解压缩,然后找到 ro524-1875M.img 文件。在 “Operating System” 按钮中,我选择了 “Use Custom” 并选择了所需的镜像文件。这个过程几乎是相同的。唯一真正的不同是我必须在下载目录中搜寻并选择一个镜像。文件写完后,回到树莓派 3,RISC OS 可以使用了。 + +### 对 USB C 的抱怨 + +顺便说一句,如今有多少人对 USB C 带来的不便感到沮丧?我使用的是只有 USB C 口的 MacBook Pro,我需要不断更换适配器才能完成工作。看看这个: + +![USB C adapter][7] + +是的,那是一个 USB C 到 USB A 适配器,然后是一个 USB 到 SD 卡读卡器,以及一个 SD 到 micro SD 适配器。我可能可以在网上找到一些东西来简化此过程,但这些都是我手头有的部件,以支持我家五花八门的 Mac、Windows 和 Linux 主机。说到这里就不多说了,但我希望你能从这些疯狂的东西中得到一个笑点。 + +### 总结 + +新的 Raspberry Pi Imager 是一种简单有效的工具,可以快速烧录树莓派镜像。[BalenaEtcher][8] 是用于对可移动设备进行烧录的类似工具,但是新的 Raspberry Pi Imager 通过省去了获取那些常见镜像的步骤,使普通树莓派系统安装(如 Raspbian)更加容易。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/raspberry-pi-imager-mac + +作者:[James Farrell][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life-raspberrypi_0.png?itok=Kczz87J2 (Raspberries with pi symbol overlay) +[2]: https://www.raspberrypi.org/ +[3]: https://www.raspberrypi.org/downloads/ +[4]: https://opensource.com/sites/default/files/uploads/install_1.png (Raspberry Pi Imager installer) +[5]: https://opensource.com/sites/default/files/uploads/screen_2_0.png (Raspberry Pi Imager home screen) +[6]: https://opensource.com/sites/default/files/uploads/demo_3.gif (Raspberry Pi Imager demo) +[7]: https://opensource.com/sites/default/files/uploads/adapter_4.png (USB C adapter) +[8]: https://www.balena.io/etcher/ diff --git a/published/202004/20200413 How to Add Multiple Time Zones in Ubuntu.md b/published/202004/20200413 How to Add Multiple Time Zones in Ubuntu.md new file mode 100644 index 0000000000..8cd0619343 --- /dev/null +++ b/published/202004/20200413 How to Add Multiple Time Zones in Ubuntu.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12121-1.html) +[#]: subject: (How to Add Multiple Time Zones in Ubuntu) +[#]: via: (https://itsfoss.com/add-multiple-time-zones-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 中添加多个时区 +====== + +> 本快速教程介绍了在 Ubuntu 和其他发行版中使用 GNOME 桌面环境添加多时区时钟的步骤。 + +![](https://img.linux.net.cn/data/attachment/album/202004/18/142021jborblzkglbebrkk.jpg) + +如果你的家人或同事在另一个国家,或者你居住在一个有多个时区的国家,那么了解时差就变得很重要。毕竟,你不想在凌晨 4 点打电话打扰别人。 + +一些 Linux 用户还会记下 [UTC 时间][1],因为大多数服务器都使用 UTC。 + +如果你有多个时钟,那么可以更好地管理此类情况。你可以将一个时钟设置为本地时间,并将其他时钟同步到其他时区。这使得了解不同时间变得更加容易。 + +在本教程中,我将向你展示如何在 Ubuntu 和其他使用 GNOME 桌面环境的 Linux 发行版中添加其他时钟。 + +### 在 Ubuntu(以及其他使用 GNOME 的 Linux)中添加多个时区时钟 + +请[检查你正在使用的桌面环境][2]。本教程仅适用于 GNOME 桌面。 + +要添加其他时钟,可以使用一个叫 [GNOME Clocks][3] 的小程序。 + +GNOME Clocks 是一个简单的应用,它可以显示多个位置的时间和日期。你也可以使用它来设置闹钟或计时器,它还包括秒表功能。 + +GNOME Clocks 存在于 Ubuntu 的 Universe 仓库中。因此,请确保首先[启用 Universe 仓库][4]。 + +你可以在软件中心中搜索 “GNOME Clocks” 并从那里安装它。 + +![Gnome Clocks Ubuntu Software Center][5] + +或者,你可以打开终端并使用以下命令来安装 GNOME Clocks: + +``` +sudo apt install gnome-clocks +``` + +如果你使用的是其他 Linux 发行版,那么请使用发行版的软件中心或软件包管理器来安装此程序。 + +安装后,请按 `Super` 键( `Windows` 键)并搜索 clocks: + +![Gnome Clocks App Search Ubuntu][6] + +启动程序,你应该会看到一个界面,提供一些选项,例如添加世界时钟、设置闹钟、使用秒表和计时器。 + +单击左上角的 “+” 号,它将为你提供搜索地理位置的选项。搜索、选择并添加。 + +![Adding additional clocks][7] + +通过地理位置添加所需的时区后,你可以看到现在在消息托盘中添加了这个新时钟。它还显示了你当地时间与其他时区之间的时差。 + +![Multiple clocks for multiple time zones][8] + +你可以使用 `Super + M` 键快速打开消息托盘。你可以掌握这些[有用的 Ubuntu 快捷方式][9]来节省时间。 + +如果要删除其他时钟,你可以从 GNOME Clocks 应用界面执行以下操作: + +![Remove Additional Clocks][10] + +你无法(在这里)删除当前时区并设置为其他时区。有其他方法[更改 Linux 中的当前时区][11]。 + +我希望你喜欢这个快速技巧。欢迎提出问题和建议。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/add-multiple-time-zones-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Coordinated_Universal_Time +[2]: https://itsfoss.com/find-desktop-environment/ +[3]: https://wiki.gnome.org/Apps/Clocks +[4]: https://itsfoss.com/ubuntu-repositories/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/gnome-clocks-ubuntu-software-center.jpg?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/gnome-clocks-app-search-ubuntu.jpg?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/add-multiple-time-zones-gnome.jpg?ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/multiple-clocks-ubuntu.jpg?ssl=1 +[9]: https://itsfoss.com/ubuntu-shortcuts/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/remove-additional-clocks-ubuntu.jpg?ssl=1 +[11]: https://itsfoss.com/change-timezone-ubuntu/ diff --git a/published/202004/20200413 How to install Python on Linux.md b/published/202004/20200413 How to install Python on Linux.md new file mode 100644 index 0000000000..7a152a5489 --- /dev/null +++ b/published/202004/20200413 How to install Python on Linux.md @@ -0,0 +1,149 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12132-1.html) +[#]: subject: (How to install Python on Linux) +[#]: via: (https://opensource.com/article/20/4/install-python-linux) +[#]: author: (Vijay Singh Khatri https://opensource.com/users/vijaytechnicalauthor) + +如何在 Linux 上安装 Python +====== + +> 在 Linux 上安装最新 Python,替代或与老版本并存的分步说明。 + +![](https://img.linux.net.cn/data/attachment/album/202004/21/094500u63lnlgukgnjb0t0.jpg) + +[Python][2] 现在是[最流行][3]、最常用的编程语言。Python 的简单语法和较低的学习曲线使其成为初学者和专业开发人员的终极选择。Python 还是一种非常通用的编程语言。从 Web 开发到人工智能,它几乎在除了移动开发的所有地方都有使用。 + +如果你使用的是 Python,那么你很有可能是一名开发人员(或想成为一名开发人员),而 Linux 是创建软件的绝佳平台。但是,当你每天使用 Python 时,有时你希望使用最新版本。你可能不想仅仅为了测试最新版本的系统而替换了默认的 Python 安装,因此本文说明了如何在 Linux 上安装最新版本的 Python 3,而不替换发行版提供的版本。 + +使用 `python --version` 终端命令检查是否已安装 Python,如果已安装,那么检查是哪个版本。如果你的 Linux 系统上未安装 Python,或者你想安装更新的版本,请按照以下步骤操作。 + +### 分步安装说明 + +#### 步骤 1:首先,安装构建 Python 所需的开发包 + +在 Debian 上 + +``` +$ sudo apt update +$ sudo apt install build-essential zlib1g-dev \ +libncurses5-dev libgdbm-dev libnss3-dev \ +libssl-dev libreadline-dev libffi-dev curl +``` + +在 Fedora 上: + +``` +$ sudo dnf groupinstall development +``` + +#### 步骤 2:下载最新的稳定版本的 Python 3 + +访问[官方 Python 网站][4]并下载最新版本的 Python 3。下载完成后,你会有一个 `.tar.xz` 归档文件(“tarball”),其中包含 Python 的源代码。 + +#### 步骤 3:解压 tarball + +下载完成后,使用解压程序或 [Linux 的 tar 命令][5]解压压缩包,例如: + +``` +$ tar -xf Python-3.?.?.tar.xz +``` + +#### 步骤 4:配置脚本 + +解压 Python 压缩包后,进入 `configure` 脚本所在目录并在 Linux 终端中使用以下命令执行该脚本: + +``` +$ cd Python-3.* +./configure +``` + +配置可能需要一些时间。等待直到成功完成,然后再继续。 + +#### 步骤 5:开始构建过程 + +如果你的系统上已经安装了某个版本的 Python,并且希望同时安装新版本的 Python,请使用以下命令: + +``` +$ sudo make altinstall +``` + +构建过程可能需要一些时间。 + +如果要使用此版本替换当前版本的 Python,那么应使用包管理器(例如 `apt` 或 `dnf`)卸载当前的 Python 包,然后安装: + +``` +$ sudo make install +``` + +但是,通常最好以软件包的形式(例如 `.deb` 或 `.rpm` 文件)来安装软件,以便系统可以为你跟踪和更新它。因为本文假设尚未打包最新的 Python,所以你可能没有这个选择。在这种情况下,你可以按照建议使用 `altinstall` 来安装 Python,或者使用最新的源代码重构现有的 Python 包。这是一个高级主题,并且特定于你的发行版,因此不在本文讨论范围之内。 + +#### 步骤 6:验证安装 + +如果你没有遇到任何错误,那么现在你的 Linux 系统上已安装了最新的 Python。要进行验证,请在终端中输入以下命令之一: + +``` +python3 --version +``` + +或者 + +``` +python --version +``` + +如果输出显示 `Python 3.x`,那么说明 Python 3 已成功安装。 + +### 创建虚拟环境(可选) + +Python 提供了名为 `venv`(虚拟环境)的软件包,可帮助你将程序目录或软件包与其他目录或软件包隔离。 + +要创建虚拟环境,请在 Python 终端中输入以下内容(在此示例中,假定你安装的 Python 版本为 `3.8` 系列): + +``` +python3.8 -m venv example +``` + +该命令创建一个带有一些子目录的新目录(我将其命名为 `example`)。 + +要激活虚拟环境,请输入: + +``` +$ source example/bin/activate +(example) $ +``` + +请注意,你的终端提示符(`$`)现在以环境名称开头。 + +要停用虚拟环境,请使用 `deactivate` 命令: + +``` +(example) $ deactivate +``` + +### 总结 + +Python 是一种有趣的语言,它的开发和改进非常频繁。一旦了解了如何安装最新版本而又不干扰发行版提供的稳定版本,熟悉新功能将很容易。 + +如果你有任何反馈或问题,请在评论中提出。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/install-python-linux + +作者:[Vijay Singh Khatri][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/vijaytechnicalauthor +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openstack_python_vim_1.jpg?itok=lHQK5zpm (OpenStack source code (Python) in VIM) +[2]: https://www.python.org/ +[3]: http://pypl.github.io/PYPL.html +[4]: http://python.org +[5]: https://opensource.com/article/17/7/how-unzip-targz-file diff --git a/published/202004/20200415 How to Open Files and Folders as Administrator in Nautilus File Manager in Linux.md b/published/202004/20200415 How to Open Files and Folders as Administrator in Nautilus File Manager in Linux.md new file mode 100644 index 0000000000..4b46fad9b3 --- /dev/null +++ b/published/202004/20200415 How to Open Files and Folders as Administrator in Nautilus File Manager in Linux.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12128-1.html) +[#]: subject: (How to Open Files and Folders as Administrator in Nautilus File Manager in Linux) +[#]: via: (https://itsfoss.com/open-nautilus-as-administrator/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Linux 的 Nautilus 文件管理器中以管理员身份打开文件和文件夹 +====== + +> 了解如何在 Ubuntu 和其他 Linux 发行版的 Nautilus 文件管理器的右键菜单中添加“以管理员身份打开”选项。 + +![](https://img.linux.net.cn/data/attachment/album/202004/19/211224hurk01u0kuvqnpvn.jpg) + +如果要以根用户身份打开或编辑文件,你总是可以在终端中执行此操作。但我知道有些人对命令行不适应。 + +桌面 Linux 通常为那些害怕终端的人提供方法避免命令行。 + +如果你必须以 root 用户身份访问文件夹或以 root 用户权限编辑文件,那你可以在 [Nautilus 文件管理器][1]中以图形方式进行操作。 + +一个小巧优雅的 Nautilus 技巧能让你以管理员(也就是 root)打开文件和文件夹。让我向你展示如何做。 + +### 在 Nautilus 文件管理器的右键菜单中添加“以管理员身份打开”选项 + +> 警告!请不要以 root 用户身份打开和编辑随机文件,因为这样可能会弄乱文件并导致系统损坏。仅在需要时使用它。 + +我展示的是 Ubuntu 的步骤。你可以根据你的发行版的软件包管理器进行更改。 + +你必须使用终端(即使你不喜欢它)来安装 Nautilus 插件。请[确保已启用 Universe 仓库][4]: + +``` +sudo apt install nautilus-admin +``` + +关闭并再次打开 Nautilus 文件管理器以查看更改生效。 + +![Right clock to see the “Open as Administrator” option][5] + +你也可以用 root 用户身份编辑文件。只需选择文件,右键单击它,然后选择“以管理员身份编辑”选项。 + +![Edit Files As Root Ubuntu][6] + +这两种情况下,系统都会提示你输入帐户密码: + +![You need to enter your password, of course][7] + +差不多了。你可以享受 GUI 的舒适了。 + +如果你不想再以 root 用户身份运行 Nautilus,那么可以删除此插件。删除已安装但不再使用的其他东西总是没错的。 + +在终端中(没错,再一次在终端),使用以下命令删除 Nautilus 插件。 + +``` +sudo apt remove nautilus-admin +``` + +顺便说一句,如果你在使用 [Ubuntu MATE][8],你可以使用 caja-admin 代替 nautilus-admin。其他文件管理器可能会或可能不会提供此类功能。 + +我希望这个快速技巧对你有所帮助。随时欢迎提出问题和建议。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/open-nautilus-as-administrator/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://wiki.gnome.org/Apps/Files +[3]: https://itsfoss.com/root-user-ubuntu/ +[4]: https://itsfoss.com/ubuntu-repositories/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/open-folder-as-administrator-ubuntu.jpg?ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/edit-files-as-root-ubuntu.jpg?ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/authentication-pop-up-ubuntu.png?ssl=1 +[8]: https://ubuntu-mate.org/ diff --git a/published/202004/20200416 How to package Python applications for Linux.md b/published/202004/20200416 How to package Python applications for Linux.md new file mode 100644 index 0000000000..95b6bba528 --- /dev/null +++ b/published/202004/20200416 How to package Python applications for Linux.md @@ -0,0 +1,169 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12143-1.html) +[#]: subject: (How to package Python applications for Linux) +[#]: via: (https://opensource.com/article/20/4/package-python-applications-linux) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +如何为 Linux 打包 Python 应用 +====== + +> 了解如何使用 dh_virtualenv 来让你的 Python 应用可作为 .deb 包安装。 + +![](https://img.linux.net.cn/data/attachment/album/202004/23/235547iztz5d955t9s9b5t.jpg) + +在基于 Debian 的操作系统(例如 Debian 或 [Elementary OS][2])上安装 Python 应用的一种方法是使用 [dh_virtualenv][3] 工具。它可以构建一个 `.deb` 包,在应用之外封装了一个 Python 虚拟环境,并在安装时进行部署。 + +在本文中,我将以构建一个包含 [HTTPie][4] 工具的包为例来解释如何使用它,以便在无需激活虚拟环境的情况下从命令行测试 HTTP API。 + +### 使用 dh_virtualenv 打包 + +首先,你需要安装 `dh_virtualenv` 所需的工具。`dh_virtualenv` 的[文档][5]提供了所有安装选项。在基于 Debian 的系统上,我输入: + +``` +apt-get install dh-virtualenv devscripts +``` + +尽管不需要 [devscripts][6] 包,但它可以简化后续操作。 + +现在,创建一个目录来保存源码。由于这是一个本地的、非官方的 HTTPie 打包,因此我将其称为 `myhttp`。接下来,让我们在 `myhttp` 内创建一些文件,向 Debian 构建系统提供元数据。 + +首先,创建 `debian/control` 文件: + +``` +Source: myhttp +Section: python +Priority: extra +Maintainer: Jan Doe +Build-Depends: debhelper (>= 9), python3.7, dh-virtualenv (>= 0.8) +Standards-Version: 3.9.5 + +Package: myhttp +Architecture: any +Pre-Depends: dpkg (>= 1.16.1), python3.7, ${misc:Pre-Depends} +Depends: ${misc:Depends} +Description: http client + Useful for doing stuff +``` + +那么这些是什么信息呢?正如 [Debian 文档][8]指出的: + +>“第 1–7 行是源码包的控制信息。第 9–13 行是二进制包的控制信息。” + +以下是我使用的: + +* `Section` 的值对于我们来说大多没有意义,但需要存在。它对给引导式 UI 安装程序提供信息是有意义的,但对于这个包来说,没有意义。 +* `Priority` 对像这样的第三方包的正确值是 `extra`。 +* 强烈建议在 `Maintainer` 字段中填写正确的联系人信息。但不一定非得是你的个人电子邮件,如果包由团队维护,并且你希望将问题发送到团队的邮件别名,例如 `Infrastructure Team `。 +* `Build-Depends` 字段标识你需要 `debhelper`、`python` 和 `dh-virtualenv` 来构建包:包构建过程中将确保这些依赖项在包构建时已安装。 +* `Standards-Version` 字段主要给人看。它表明你遵循的指南。本指南基于 `dh-virtualenv` 的官方文档,它是基于 Debian 的 3.9.5 指南。最好一直将源码包和二进制包命名相同。 +* `Architecture` 字段应为 `Any`,因为除非虚拟环境可能包含一些特定于体系结构的文件。否则,最好选择该字段为 `any`。 +* 保持 `Pre-Depends` 列表不变:它是一种非常严格的依赖关系形式,你很少会需要比这里建议的最小依赖更多的依赖项。依赖项通常由构建系统准确计算,因此没有理由手动指定它们。 +* 如果你的包主要用于内部,那么 `Description` 字段可能只需要最少的信息或者指向公司 wiki 的链接,不然更多的信息会更有用。 + +然后创建 `debian/compat` 文件,它[主要出于历史目的而存在][10]: + +``` +$ echo "9" > debian/compat +``` + +接下来,创建更新日志以告知包用户自上次发布以来发生了什么变化。最简单的方法是使用 `dch --create` 创建模板,然后填写值。 + +填写后,它看起来像: + +``` +myhttp (2.0.0-1) stable; urgency=medium + + * Initial release. + + -- Jan Doe Fri, 27 Mar 2020 01:09:22 +0000 +``` + +现在你需要告诉工具安装 HTTPie,但是哪个版本? + +创建一个宽松版本的 `requirements.in` 文件: + +``` +httpie +``` + +通常,宽松的需求文件将仅包含项目的直接依赖项,并在需要时指定最低版本。不一定总是需要指定最低版本:这些工具通常偏向于将依赖关系转化为“可能的最新版本”。如果你的 Debian 包与一个内部 Python 包相对应,这是内部应用中的一种常见情况,那么宽松的需求文件看起来将很相似:仅包含包名的一行。 + +然后使用 `pip-compile`(可通过安装 PyPI 包 `pip-tools` 获得): + +``` +$ pip-compile requirements.in > requirements.txt +``` + +这会生成一个严格的依赖文件,名为 `requirements.txt`: + +``` +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile requirements.in +# +certifi==2019.11.28 # via requests +chardet==3.0.4 # via requests +httpie==2.0.0 # via -r requirements.in +idna==2.9 # via requests +pygments==2.6.1 # via httpie +requests==2.23.0 # via httpie +urllib3==1.25.8 # via requests +``` + +最后,写一个 `debian/rules` 文件来创建包。因为 `dh_virtualenv` 会处理所有困难的事,因此规则文件很简单: + +``` +#!/usr/bin/make -f + +%: + dh $@ --with python-virtualenv --python /usr/bin/python3.7 +``` + +确保指定 Python 解释器。默认它会使用 `/usr/bin/python`,这是 Python2,但是你应该使用一个[受支持的 Python 版本][11]。 + +完成了,接下来就是构建包: + +``` +$ debuild -b -us -uc +``` + +这会在父目录生成一个类似 `myhttp_2.0.0-1_amd64.deb` 的文件。该文件可在任何兼容的系统上安装。 + +通常,最好在同一平台上构建用于特定平台(例如 Debian 10.0)的 Debian 包。 + +你可以将此 Debian 包保存在软件仓库中,并使用例如 [Ansible][12] 的工具将其安装在所有相关系统上。 + +### 总结 + +给基于 Debian 的系统的打包应用是一个有着多个步骤的过程。使用 `dh_virtualenv` 将使过程变得简单明了。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/package-python-applications-linux + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life-python.jpg?itok=F2PYP2wT (Python in a tree) +[2]: https://opensource.com/article/19/12/pantheon-linux-desktop +[3]: https://dh-virtualenv.readthedocs.io/en/latest/ +[4]: https://opensource.com/article/19/8/getting-started-httpie +[5]: https://dh-virtualenv.readthedocs.io/en/1.1/tutorial.html +[6]: http://man.he.net/man1/devscripts +[7]: mailto:jandoe@example.org +[8]: https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#control +[9]: mailto:infra-team-list@company.example.com +[10]: https://www.debian.org/doc/manuals/maint-guide/dother.en.html#compat +[11]: https://opensource.com/article/19/11/end-of-life-python-2 +[12]: https://opensource.com/resources/what-ansible diff --git a/published/202004/20200417 12 Linux Commands to Have Some Fun in the Terminal.md b/published/202004/20200417 12 Linux Commands to Have Some Fun in the Terminal.md new file mode 100644 index 0000000000..d13219c30a --- /dev/null +++ b/published/202004/20200417 12 Linux Commands to Have Some Fun in the Terminal.md @@ -0,0 +1,329 @@ +[#]: collector: (lujun9972) +[#]: translator: (Zioyi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12149-1.html) +[#]: subject: (12 Linux Commands to Have Some Fun in the Terminal) +[#]: via: (https://itsfoss.com/funny-linux-commands/) +[#]: author: (Community https://itsfoss.com/author/itsfoss/) + +12 个有趣的 Linux 终端命令 +====== + +> 你觉得 Linux 终端里只有无趣的工作吗?那你一定不知道下面这些有趣的 Linux 命令吧。 + +Linux 终端是用来完成复杂的工作的,我们有很多有用的 [linux 命令奇技淫巧][1]来帮助你。 + +但是,你知道你还可以用终端来做很多有趣的事吗?如果你不知道,没关系,大多数 Linux 用户也都只把终端视为一个用来管理系统和开发工作的交互界面。 + +然而,如果你知道这里有些你可以在终端玩的[基于终端的游戏][2]和 [ASCII 码游戏][3],你一定会大吃一惊。 + +在这篇文章中,我将会探索一些有趣的、可笑的、荒谬的命令来让你可以在终端中找点乐子! + +### 用这些命令在 Linux 终端中找点乐子 + +![][4] + +你可能会觉得这些命令荒谬或没用,但是有一些还是可以被好好利用的。 + +我已经放上了 Ubuntu/Debian 的安装指令,如果你使用基于 Ubuntu 的发行版,请确保[启用 universe 仓库][5],因为大多数命令不在主仓库中。 + +如果你使用 Arch、Fedora、SUSE、Solus 或者其他非 Ubuntu 的发行版,请使用你的发行版包管理工具去安装这些有趣的 Linux 命令。 + +#### 1、在终端开一辆火车 + +让我们坐上火车,来一场说走就走的旅行的,没错,就是字面意思! + +`sl` 命令可以让你在终端运行一辆火车。 + +![][6] + +安装方法: + +``` +sudo apt install sl +``` + +完成后,你只要在终端输入下面的命令就可以开始: + +``` +sl +``` + +很精彩,对吧?但等等,我们还没结束!你还可以让你的火车飞起来,只要加上参数 `-F`,波特先生,请飞吧: + +``` +sl -F +``` + +这样会让火车长出翅膀飞出终端窗口! + +#### 2、给你的 Linux 终端加上黑客帝国效果 + +还记得科幻电影[黑客帝国][7]吗?终端里掉落的绿色字符成为了黑客帝国的标志形象。 + +你也可以在你的 Linux 电脑里有这样的黑客帝国数字雨!你只需要安装 `cmatric` 然后在终端输入它就行。 + +![][8] + +在 Debian/Ubuntu Linux 上安装 cmatrix: + +``` +sudo apt install cmatrix +``` + +现在,你要做的就是输入下面的命令,在终端就会有黑客帝国屏幕了: + +``` +cmatrix +``` + +按下 `Ctrl+C` 来停止它,黑客先生。 + +#### 3、燃起来 + +拿好灭火器,因为接下来你要在你的终端里点火了! + +![][11] + +想安装它,你要输入: + +``` +sudo apt install libaa-bin +``` + +完成后,你输入下面的命令,你的终端就会燃起一团火焰: + +``` +aafire +``` + +按下 `Ctrl+C` 来停止它。 + +#### 4、幸运饼干命令 + +想知道你的运气怎样但身边没有幸运饼干? + +别担心,你只需在终端打出 `fortune` 然后按下回车。终端将会随机显示出一个幸运语,就像你从幸运饼干里得到的一样。 + +![][12] + +安装它: + +``` +sudo apt install fortune +``` + +完成后,只要在命令行打出下面的内容,你就会知道你的运气怎样: + +``` +fortune +``` + +这是一个你可以实际使用的命令。你可以用它作为每日消息,这样在多用户环境下,每个用户登录后都会得到一个“幸运饼干”。 + +你也可以把它添加到 `bashrc` 文件,这样当你登进终端你就会看到了。 + +#### 5、宠物爱好者?这是给你准备的 + +`oneko` 是一个有趣的命令,可以把你的光标变成一只老鼠,然后创造一只好奇的猫,一旦你移动光标,就会来追你。这不仅局限于终端。当猫追逐光标时,你可以继续工作。 + +如果你家里有孩子这一定很有趣。 + +![][13] + +用下面的命令安装 `oneko`: + +``` +sudo apt install oneko +``` + +用下面的命令运行它: + +``` +oneko +``` + +如果你不喜欢猫,喜欢狗,输入: + +``` +oneko -dog +``` + +它有很多种小宠物,你可以用 `oneko -help` 获取信息。按下 `Ctrl+C` 终止它。 + +#### 6、有个小兄弟在看着你 + +`xeyes` 是一个很小的 GUI 程序,它可以绘制出一双眼睛一直盯着你!它会不断跟随你的鼠标光标,运行命令自己看看! + +![][14] + +你可以用下面命令安装: + +``` +sudo apt install xeyes +``` + +然后这样用它: + +``` +xeyes +``` + +按下 `Ctrl+C` 终止它。 + +#### 7、让终端帮你讲话 + +打开你的扬声器,你来试试这个命令,[eSpeak][15] 是一个有趣的命令,它可以让你的终端说话。是的,你没听错。 + +先安装这个包: + +``` +sudo apt install espeak +``` + +接下来,你只需要输入在命令行中输入你想听到的话: + +``` +espeak "Type what your computer says" +``` + +无论你在双引号里面填什么,你的电脑都会复述出来!它就像[在 Linux 中的 echo 命令][16],但不是打印出来,而是说出来。 + +#### 8、Toilet(但与洗手间无关) + +这听起来有点奇怪,是的。但是,这只是一个命令,用来将文本转换成大的 ASCII 字符。 + +![][17] + +用这个命令安装 `toilet`: + +``` +sudo apt install toilet +``` + +完成后,你只需输入: + +``` +toilet sample text you want +``` + +我也不知道为啥这个小程序叫 Toilet。 + +#### 9、那个牛说什么? + +`cowsay` 是一个在终端中用 ASCII 字符展示出一头牛的命令。通过这个命令,你可以控制牛说出你想说的话。 + +别纠结声音,它只展示文本(就是你看漫画书一样)。 + +![Cowsay Cowthink][18] + +安装 `cowsay`: + +``` +sudo apt install cowsay +``` + +安装完成后,你只要输入: + +``` +cowsay "your text" +``` + +无论你在双引号里填什么,你的牛都会说!我看到一些系统管理员用它来展示每天的消息。你也可以这样,你甚至可以把它和 `fortune` 命令结合。 + +#### 10、旗帜 + +`banner` 命令与 `toilet` 命令相似,但它限制最多只能打印 10 个字符。 + +![][19] + +你可以这样安装 `banner` 命令: + +``` +sudo apt install sysvbanner +``` + +然后这样运行: + +``` +banner "Welcome" +``` + +替换双引号里的内容,你将会得到你想要的展示内容。 + +#### 11、Yes + +![][20] + +`yes` 命令帮助你在循环中自动响应直到终止命令。这个命令将会一直打印相同的内容。如果你想快速生成大量垃圾文本,那么此命令将像超级按钮一样工作。 + +你也可以使用它为命令提供 `yes` 应答(如果提示应答时)。例如,`apt upgrade` 命令会要求你确认,你可以像这样使用它: + +``` +yes | sudo apt upgrade +``` + +你不需要安装任何包,`yes` 命令已经存在了。 + +想要终止 `yes` 命令循环,只需按下 `CTRL+C`。 + +#### 12、得到一个新的身份 + +要生成一个随机的假身份吗?我推荐你用 `rig` 命令。你在终端运行它,就会生成一个假的身份。 + +![][21] + +用这个命令安装 `rig`: + +``` +sudo apt install rig +``` + +只需像这样输入: + +``` +rig +``` + +它可能被用在脚本或者 web 应用中展示随机信息,但我自己还没做过什么。 + +### 结尾 + +我希望你会喜欢这个有趣的 Linux 命令列表。你最喜欢哪个命令呢?你还知道其他有趣的命令吗?请在评论部分与我们分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/funny-linux-commands/ + +作者:[Srimanta Koley][a] +选题:[lujun9972][b] +译者:[Zioyi](https://github.com/Zioyi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/linux-command-tricks/ +[2]: https://itsfoss.com/best-command-line-games-linux/ +[3]: https://itsfoss.com/best-ascii-games/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fun-linux-commands.png?ssl=1 +[5]: https://itsfoss.com/ubuntu-repositories/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/sl-command.jpg?ssl=1 +[7]: https://en.wikipedia.org/wiki/The_Matrix +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/matrix-screen-command.png?ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2015/12/Star-Wars-Linux-Terminal-2.png?fit=732%2C462&ssl=1 +[10]: https://itsfoss.com/star-wars-linux/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fire-command.png?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/fortune-command.jpg?ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/oneko-command.jpg?ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/xeyes-command.jpg?ssl=1 +[15]: https://itsfoss.com/espeak-text-speech-linux/ +[16]: https://linuxhandbook.com/echo-command/ +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/toilet-command.jpg?ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cowsay-cowthink.jpg?ssl=1 +[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/banner-command.jpg?ssl=1 +[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/yes-yourtext.jpg?ssl=1 +[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/rig-command.jpg?ssl=1 +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/srimanta.jpg?ssl=1 diff --git a/published/202004/20200418 Ethernet consortium announces completion of 800GbE spec.md b/published/202004/20200418 Ethernet consortium announces completion of 800GbE spec.md new file mode 100644 index 0000000000..c909b1fb0e --- /dev/null +++ b/published/202004/20200418 Ethernet consortium announces completion of 800GbE spec.md @@ -0,0 +1,51 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12138-1.html) +[#]: subject: (Ethernet consortium announces completion of 800GbE spec) +[#]: via: (https://www.networkworld.com/article/3538529/ethernet-consortium-announces-completion-of-800gbe-spec.html) +[#]: author: (Andy Patrizio https://www.networkworld.com/author/Andy-Patrizio/) + +以太网技术联盟宣布完成 800Gb 以太网规范 +====== + +> 800Gb 以太网规范使当前以太网标准的最高速度提高了一倍,但同时也对包括延迟在内的其他方面进行了调整。 + +![](https://images.techhive.com/images/article/2017/05/170522-networking-2-100723415-large.jpg) + +由业界支持的以太网技术联盟Ethernet Technology Consortium(ETC)已宣布完成 800Gb 以太网技术规范。 + +新规范基于当前高端 400Gb 以太网协议中使用的许多技术,新规范正式称为 800GBASE-R。设计它的联盟(当时称为 25Gb 以太网联盟)在开发 25、50 和 100Gb 以太网协议方面也发挥了重要作用,其成员包括 博通、思科、谷歌和微软。 + +800Gb 以太网规范增加了新的介质访问控制media access control(MAC)和物理编码子层physical coding sublayer(PCS)方法,新规范对这些功能进行了调整,来使用 8 条 106.25Gbps 的物理通道分发数据。(通道可以是铜双绞线,也可以是光缆,一束光纤或光波。)800GBASE-R 规范建立在两个 400 GbE 2xClause PCS 之上,以创建一个以 800Gbps 的总速率运行的单个 MAC。 + +尽管主要是使用八条 106.25Gb 通道,但这并不是固定的。它可以以一半的速度 (53.125Gbps) 使用 16 条通道。 + +新标准提供了 400G 以太网规范的一半延迟,但是新规范也将运行在 50 Gbps、100 Gbps 和 200 Gbps 的网络上的前向纠错forward error correction(FEC)开销减少了一半,从而减少了网卡上的数据包处理负担。 + +通过降低延迟,这将满足对延迟敏感的应用(例如[高性能计算][2]和人工智能)中对速度的需求,在这些应用中,需要尽可能快地移动大量数据。 + +从 400G 增加到 800G 并不是太大的技术飞跃。它意味着在相同的传输速率下增加更多的通道,再做一些调整。但是,要想突破 Tb 级,Cisco 和其他网络公司已经讨论了十年了,这将需要对技术进行重大修改,而且并非易事。 + +新技术可能也不便宜。800G 可与现有硬件一起使用,而 400Gb 以太网交换机价格不菲,高达六位数。对技术进行重大修改,越过 Tb 障碍,可能会变得更加昂贵。但是对于大客户和高性能计算客户而言,这也是情理之中的事。 + +ETC 并未透露何时会支持 800G 的新硬件,但考虑到它对现有规格的变化不大,它可能会在今年出现,前提是疫情引起的停滞不会影响它。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3538529/ethernet-consortium-announces-completion-of-800gbe-spec.html + +作者:[Andy Patrizio][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Andy-Patrizio/ +[b]: https://github.com/lujun9972 +[2]: https://www.networkworld.com/article/3444399/high-performance-computing-do-you-need-it.html +[3]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202004/20200421 MystiQ- A Free and Open Source Audio-Video Converter.md b/published/202004/20200421 MystiQ- A Free and Open Source Audio-Video Converter.md new file mode 100644 index 0000000000..c4c99dac95 --- /dev/null +++ b/published/202004/20200421 MystiQ- A Free and Open Source Audio-Video Converter.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12160-1.html) +[#]: subject: (MystiQ: A Free and Open Source Audio/Video Converter) +[#]: via: (https://itsfoss.com/mystiq/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +MystiQ:一个自由开源的音视频转换器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/28/223258cr9rxzyrj344kh68.jpg) + +> MystiQ 是一款全新的开源视频转换工具,适用于 Linux 和 Windows。它的底层使用 FFMPEG,并为你提供了一个基于 Qt 的整洁干净的图形界面。 + +### MystiQ,一个基于 QT 的 FFmpeg GUI 前端 + +![][1] + +音频/视频转换工具可为每位跨多个平台的计算机用户提供方便。 + +出于同样的原因,我想着重介绍 [MystiQ][2] 是个好主意,这是一个相对较新的视频/音频转换器工具,适用于 Linux 和 Windows。截至目前,它还不支持 macOS,但可能会在不久的将来支持。 + +MystiQ 是基于 [Qt 5 界面][4]的 [FFmpeg][3] 图形前端。现在,你可以随时[在 Linux 命令行中安装并使用 ffmpeg][5],但这不是很舒服,是吗?这就是为什么 [Handbrake][6] 和 MystiQ 之类的工具可以使我们的生活更方便的原因。 + +由于 MystiQ 基于 FFmpeg,因此你可以将其用于一些基本的视频编辑,例如修剪、旋转等。 + +让我们来看看它的功能。 + +### MystiQ 视频转换器的功能 + +![][7] + +即使 MystiQ 目前还算是一个新事物,但它也包含了一组很好的基本功能。以下它提供的: + + * 视频转换 + * 音频转换(也可从视频中提取音频) + * 支持的格式:MP4、WEBM、MKV、MP3、MOV、OGG、WAV、ASF、FLV、3GP、M4A 等。 + * 跨平台(Windows 和 Linux) + * 适用于 32 位和 64 位系统的安装包 + * 能够调整音频质量(采样率、比特率等)进行转换 + * 基本的视频编辑功能(剪辑视频、插入字幕、旋转视频、缩放视频等) + * 将彩色视频转换为黑白 + * 有几个预设方案,可轻松转换视频以获得最佳质量或获得最佳压缩效果。 + +### 安装 MystiQ + +你可能没有在软件中心中找到它,但将它安装在 Linux 发行版上非常容易。 + +它提供了 .AppImage 文件和 .deb / .rpm 文件(32 位和 64 位软件包)。如果你不清楚如何使用的话,可以阅读[如何使用 AppImage 文件][10]。 + +如果你想帮助他们测试软件进行改进,你还可以找到他们的 [GitHub 页面][11],并查看源码或任何近期的预发布软件包。 + +你可以在其官方网站下载适用于 Linux 和 Windows 的安装程序文件。 + +- [下载 MystiQ][2] + +### 总结 + +在本文中,我使用 [Pop!_OS][12] 20.04 测试了 MytiQ 转换器,并且在转换视频和音频时没遇到任何问题。而且,对于像我这样的普通用户来说,它的转换速度足够快。 + +欢迎尝试一下,让我知道你对它的想法!另外,如果你在 Linux 上一直使用其他工具转换视频和音频,那它是什么? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/mystiq/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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/2020/04/mystiq-converter-ft.jpg?ssl=1 +[2]: https://mystiqapp.com/ +[3]: https://www.ffmpeg.org/ +[4]: https://www.qt.io/ +[5]: https://itsfoss.com/ffmpeg/ +[6]: https://itsfoss.com/handbrake/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/mystiq-options.jpg?ssl=1 +[9]: https://itsfoss.com/sound-converter-linux/ +[10]: https://itsfoss.com/use-appimage-linux/ +[11]: https://github.com/swl-x/MystiQ/ +[12]: https://system76.com/pop diff --git a/published/202004/20200422 How to Check the Available Network Interfaces, Associated IP Addresses, MAC Addresses, and Interface Speed on Linux.md b/published/202004/20200422 How to Check the Available Network Interfaces, Associated IP Addresses, MAC Addresses, and Interface Speed on Linux.md new file mode 100644 index 0000000000..8464da643e --- /dev/null +++ b/published/202004/20200422 How to Check the Available Network Interfaces, Associated IP Addresses, MAC Addresses, and Interface Speed on Linux.md @@ -0,0 +1,198 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12165-1.html) +[#]: subject: (How to Check the Available Network Interfaces, Associated IP Addresses, MAC Addresses, and Interface Speed on Linux) +[#]: via: (https://www.2daygeek.com/linux-unix-check-network-interfaces-names-nic-speed-ip-mac-address/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在 Linux 上检查网卡信息 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/29/214835m1ms3n00s6qbcycz.jpg) + +默认情况下,在设置服务器时你会配置主网络接口。这是每个人所做的构建工作的一部分。有时出于各种原因,你可能需要配置额外的网络接口。 + +这可以是通过网络绑定bonding/协作teaming来提供高可用性,也可以是用于应用需求或备份的单独接口。 + +为此,你需要知道计算机有多少接口以及它们的速度来配置它们。 + +有许多命令可检查可用的网络接口,但是我们仅使用 `ip` 命令。以后,我们会另外写一篇文章来全部介绍这些工具。 + +在本教程中,我们将向你显示可用网络网卡(NIC)信息,例如接口名称、关联的 IP 地址、MAC 地址和接口速度。 + +### 什么是 ip 命令 + +[ip 命令][1] 类似于 `ifconfig`, 用于分配静态 IP 地址、路由和默认网关等。 + +``` +# ip a + +1: lo: mtu 65536 qdisc noqueue state UNKNOWN + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + inet6 ::1/128 scope host + valid_lft forever preferred_lft forever +2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 + link/ether fa:16:3e:a0:7d:5a brd ff:ff:ff:ff:ff:ff + inet 192.168.1.101/24 brd 192.168.1.101 scope global eth0 + inet6 fe80::f816:3eff:fea0:7d5a/64 scope link + valid_lft forever preferred_lft forever +``` + +### 什么是 ethtool 命令 + +`ethtool` 用于查询或控制网络驱动或硬件设置。 + +``` +# ethtool eth0 +``` + +### 1)如何在 Linux 上使用 ip 命令检查可用的网络接口 + +在不带任何参数的情况下运行 `ip` 命令时,它会提供大量信息,但是,如果仅需要可用的网络接口,请使用以下定制的 `ip` 命令。 + +``` +# ip a |awk '/state UP/{print $2}' + +eth0: +eth1: +``` + +### 2)如何在 Linux 上使用 ip 命令检查网络接口的 IP 地址 + +如果只想查看 IP 地址分配给了哪个接口,请使用以下定制的 `ip` 命令。 + +``` +# ip -o a show | cut -d ' ' -f 2,7 +或 +ip a |grep -i inet | awk '{print $7, $2}' + +lo 127.0.0.1/8 +192.168.1.101/24 +192.168.1.102/24 +``` + +### 3)如何在 Linux 上使用 ip 命令检查网卡的 MAC 地址 + +如果只想查看网络接口名称和相应的 MAC 地址,请使用以下格式。 + +检查特定的网络接口的 MAC 地址: + +``` +# ip link show dev eth0 |awk '/link/{print $2}' +00:00:00:55:43:5c +``` + +检查所有网络接口的 MAC 地址,创建该脚本: + +``` +# vi /opt/scripts/mac-addresses.sh + +#!/bin/sh +ip a |awk '/state UP/{print $2}' | sed 's/://' | while read output; +do + echo $output: + ethtool -P $output +done +``` + +运行该脚本获取多个网络接口的 MAC 地址: + +``` +# sh /opt/scripts/mac-addresses.sh + +eth0: +Permanent address: 00:00:00:55:43:5c +eth1: +Permanent address: 00:00:00:55:43:5d +``` + +### 4)如何在 Linux 上使用 ethtool 命令检查网络接口速度 + +如果要在 Linux 上检查网络接口速度,请使用 `ethtool` 命令。 + +检查特定网络接口的速度: + +``` +# ethtool eth0 |grep "Speed:" + +Speed: 10000Mb/s +``` + +检查所有网络接口速度,创建该脚本: + +``` +# vi /opt/scripts/port-speed.sh + +#!/bin/sh +ip a |awk '/state UP/{print $2}' | sed 's/://' | while read output; +do + echo $output: + ethtool $output |grep "Speed:" +done +``` + +运行该脚本获取多个网络接口速度: + +``` +# sh /opt/scripts/port-speed.sh + +eth0: +Speed: 10000Mb/s +eth1: +Speed: 10000Mb/s +``` + +### 5)验证网卡信息的 Shell 脚本 + +通过此 shell 脚本你可以收集上述所有信息,例如网络接口名称、网络接口的 IP 地址,网络接口的 MAC 地址以及网络接口的速度。创建该脚本: + +``` +# vi /opt/scripts/nic-info.sh + +#!/bin/sh +hostname +echo "-------------" +for iname in $(ip a |awk '/state UP/{print $2}') +do + echo "$iname" + ip a | grep -A2 $iname | awk '/inet/{print $2}' + ip a | grep -A2 $iname | awk '/link/{print $2}' + ethtool $iname |grep "Speed:" +done +``` + +运行该脚本检查网卡信息: + +``` +# sh /opt/scripts/nic-info.sh + +vps.2daygeek.com +---------------- +eth0: +192.168.1.101/24 +00:00:00:55:43:5c +Speed: 10000Mb/s +eth1: +192.168.1.102/24 +00:00:00:55:43:5d +Speed: 10000Mb/s +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-unix-check-network-interfaces-names-nic-speed-ip-mac-address/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/ip-command-configure-network-interface-usage-linux/ +[2]: https://www.2daygeek.com/category/shell-script/ diff --git a/published/202004/20200422 Things You Should Know About Ubuntu 20.04.md b/published/202004/20200422 Things You Should Know About Ubuntu 20.04.md new file mode 100644 index 0000000000..a6a56b25f2 --- /dev/null +++ b/published/202004/20200422 Things You Should Know About Ubuntu 20.04.md @@ -0,0 +1,129 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12158-1.html) +[#]: subject: (Things You Should Know About Ubuntu 20.04) +[#]: via: (https://itsfoss.com/ubuntu-20-04-faq/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +关于 Ubuntu 20.04 你应该了解的事情 +====== + +[Ubuntu 20.04][1] 已经发布,你可能对升级、安装等有一些问题和疑问。 + +我在各种社交媒体渠道上主持了一些问答环节,回答像你这样的读者的疑虑。我将列出这些关于 Ubuntu 20.04 的常见问题,并给出答案。我希望它能帮助你消除你的疑虑。如果你仍有问题,请随时在下面的评论栏提问。 + +### Ubuntu 20.04:已回复的问题 + +![][2] + +为了澄清一下,这里的一些答案也许受我个人意见的影响。如果你是一个有经验的 Ubuntu 用户,有些问题听起来可能有点愚蠢,但它对 Ubuntu 新用户不是这样。 + +#### Ubuntu 20.04 何时发布? + +Ubuntu 20.04 LTS 于 2020 年 4 月 23 日发布。所有变种,如 Kubuntu、Lubuntu,、Xubuntu、Budgie、MATE 都将和 20.04 同一天发布。 + +#### Ubuntu 20.04 的系统要求是什么? + +对于默认的 GNOME 版本,应至少具有 4GB 的内存、2GHz 双核处理器和至少 25GB 的磁盘空间。 + +其他 [Ubuntu 变种][3]可能有不同的系统要求。 + +#### 我可以在 32 位系统上使用 Ubuntu 20.04 吗? + +完全不行。你不能在 32 位系统上使用 Ubuntu 20.04。即使你使用的是 32 位 Ubuntu 18.04,也不能升级到 Ubuntu 20.04。32 位的系统 ISO 是以前用的。 + +![Error while upgrading 32-bit Ubuntu 18.04 to Ubuntu 20.04][4] + +#### 我可以在 Ubuntu 20.04 上使用 Wine 吗? + +是的,你仍然可以在 Ubuntu 20.04 上使用 Wine,因为仍然用于 Wine 和 [Steam Play][5] 软件包所需的 32 位库。 + +#### 我需要购买 Ubuntu 20.04 或许可证? + +不,Ubuntu 完全可以免费使用。你不必像在 Windows 中那样购买许可证密钥或激活 Ubuntu。 + +Ubuntu 的下载页会请求你捐赠一些资金,如果你想为开发这个强大的操作系统捐钱,由你自己决定。 + +#### GNOME 版本是什么? + +Ubuntu 20.04 有 GNOME 3.36。 + +#### Ubuntu 20.04 的性能是否优于 Ubuntu 18.04? + +是的,在几个方面。Ubuntu 20.04 系统速度更快,甚至超快。我在下面这个视频的 4:40 处展示了性能对比。 + +- [video](https://img.linux.net.cn/static/video/Top%207%20Best%20Features%20You%27ll%20Love%20in%20Ubuntu%2020.04-lpq8pm_xkSE.mp4) + +在 GNOME 3.36 中,滚动、窗口动画和其他 UI 元素更加流畅,提供了更流畅的体验。 + +#### Ubuntu 20.04 将支持多长时间? + +它是一个长期支持(LTS)版本,与任何 LTS 版本一样,它将在五年内得到支持。这意味着 Ubuntu 20.04 将在 2025 年 4 月之前获得安全和维护更新。 + +#### 升级到 Ubuntu 20.04 时,是否会丢失数据? + +你可以从 Ubuntu 19.10 或 Ubuntu 18.04 升级到 Ubuntu 20.04。你无需创建 live USB 并从中安装。你所需要的是一个良好的互联网连接,来下载约 1.5GB 的数据。 + +从现有系统升级不会破坏你的文件。你应该会留有所有文件,并且大多数现有软件应具有相同的版本或升级后的版本。 + +如果你使用了某些第三方工具或[其他 PPA][6],升级过程将禁用它们。如果 Ubuntu 20.04 可以使用这些其他存储库,那么可以再次启用它们。 + +升级大约需要一个小时,重启后,你将登录到新版本。 + +虽然你的数据不会被触碰,并且不会丢失系统文件和配置,但最好在外部设备备份重要数据。 + +#### 何时可以升级到 Ubuntu 20.04? + +![][7] + +如果你正在使用 Ubuntu 19.10 并有正确的更新设置(如前面部分所述),那么应在发布后的几天内通知你升级到 Ubuntu 20.04。 + +对于 Ubuntu 18.04 用户,可能需要几周时间才能正式通知他们 Ubuntu 20.04 可用。可能,你可能会在第一个点版本 Ubuntu 20.04.1 后获得提示。 + +#### 如果我升级到 Ubuntu 20.04,我可以降级到 19.10 或 18.04 吗? + +不行。虽然升级到新版本很容易,但无法选择降级。如果你想回到 Ubuntu 18.04,你需要重新[安装 Ubuntu 18.04][8]。 + +#### 我使用的是 Ubuntu 18.04 LTS。我应该升级到 Ubuntu 20.04 LTS 吗? + +这取决于你。如果你对 Ubuntu 20.04 中的新功能印象深刻,并希望上手尝试,那么你应该升级。 + +如果你想要一个更稳定的系统,我建议等待第一个点版本 Ubuntu 20.04.1,新版本会有 bug 修复。20.04.1 通常在 Ubuntu 20.04 发布后大约两个月到来。 + +无论是那种情况,我都建议你或早或晚升级到 Ubuntu 20.04。Ubuntu 20.04 具有更新的内核、性能改进,尤其是仓库中有更新版本的软件。 + +在外部磁盘上进行备份,并且有良好的互联网连接,升级不应成为问题。 + +#### 我应该重新安装 Ubuntu 20.04 还是从 18.04/19.10 升级到 Ubuntu? + +如果你可以选择,请备份数据,并重新安装 Ubuntu 20.04。 + +从现有版本升级到 20.04 是一个方便的选择。然而,在我看来,它仍然保留有一些旧版本的痕迹/包。全新安装更加干净。 + +#### 关于 Ubuntu 20.04 的任何其他问题? + +如果你对 Ubuntu 20.04 有任何疑问,请随时在下面发表评论。如果你认为应该将其他信息添加到列表中,请让我知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-20-04-faq/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-12142-1.html +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu_20_04_faq.jpg?ssl=1 +[3]: https://itsfoss.com/which-ubuntu-install/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-32-bit.jpg?ssl=1 +[5]: https://itsfoss.com/steam-play/ +[6]: https://itsfoss.com/ppa-guide/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/upgrade-ubuntu-20-04.jpg?ssl=1 +[8]: https://itsfoss.com/install-ubuntu/ diff --git a/published/202004/20200424 Ubuntu 20.04 LTS Released. Download Now.md b/published/202004/20200424 Ubuntu 20.04 LTS Released. Download Now.md new file mode 100644 index 0000000000..fcd11c0e8d --- /dev/null +++ b/published/202004/20200424 Ubuntu 20.04 LTS Released. Download Now.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12146-1.html) +[#]: subject: (Ubuntu 20.04 LTS Released. Download Now!) +[#]: via: (https://itsfoss.com/download-ubuntu-20-04/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Ubuntu 20.04 LTS 下载及新特性 +====== + +> Ubuntu 20.04 LTS Focal Fossa 终于发布了。以下是 Ubuntu 20.04 的新功能和下载链接,以及Ubuntu 20.04的官方风味版。 + +等待终于结束了。Ubuntu 20.04 LTS 终于来了,可以下载了! + +![][1] + +如果你已经在使用 Ubuntu 19.10,你可能发现没有太多明显的差异 —— 但我所看到的改进清单确实令人印象深刻。 + +如果你想知道有什么新的东西,我将会提到这个版本的几个主要亮点。 + +### Ubuntu 20.04 有什么新特性? + +与之前的 18.04 LTS 版本相比,Ubuntu 20.04 LTS 有很多视觉上的改变,同时也包括了一些底层的改进。 + +当然,随着 [GNOME 3.36][2] 的加入,视觉上的重大升级和性能上的提升是相当明显的。以下是一段视频,重点介绍了 Ubuntu 20.04 中的新功能。 + +- [What's New in Ubuntu 20.04 Take a Look at the Top Features](https://youtu.be/9u5B0njRgOw) + +如果你有兴趣的话,你也可以深入到我们的文章中去看看,重点介绍 [Ubuntu 20.04 的新功能][3]。 + +不管是哪种情况,让我来给你介绍一些亮点。 + + * GNOME 3.36 是默认的桌面系统 + * 性能提高了很多 + * 新的 Yaru 主题很华丽,也有黑暗模式。 + * 你不会再看到亚马逊应用程序,它已经永远消失了! + * 改进的 [ZFS][4] 支持 + * 你可以获得最新的 [Linux 内核 5.4][5](LTS) + * 增加了对 exFAT 的支持 + * 改进硬件和图形支持 + * 更新软件 Python 3.8.2 + * Wireguard 已被移植到 Linux 内核5.4,可以在 Ubuntu 20.04 上使用。 + +如果你想看详细的功能介绍,请观看这段视频,重点介绍 20.04 LTS 的最佳功能。 + +- [Top 7 Best Features You'll Love in Ubuntu 20.04](https://youtu.be/lpq8pm_xkSE) + +如果你是 Ubuntu 的新手,对 Ubuntu 20.04 有疑问,我们也为你提供了一篇快速的 [Ubuntu 20.04 FAQ][7] 文章。 + +### 从 18.04 和 19.10 升级到 Ubuntu 20.04 + +如果你已经在使用 Ubuntu 18.04 或 19.10,你可以从系统中轻松升级到 Ubuntu 20.04。 + +这样一来,当你开始使用新版本的时候,你的文件和大部分的应用程序设置都会保持原样,而无需从 ISO 中重新安装。 + +你可以阅读此详细教程来学习[如何将 Ubuntu 升级到新版本][8]。 + +请注意,如果你使用的是 Lubuntu 18.04,请不要升级到 Lubuntu 20.04。Lubuntu 18.04 使用的是 Lxde 桌面,而后面的版本使用的是 LXQt 桌面。这样升级可能会导致冲突和系统崩溃。 + +### 下载 Ubuntu 20.04 LTS + +你可以抓取 ISO 或 torrent 文件,这取决于你喜欢什么。 + +- [Ubuntu 20.04 LTS (ISO)][9] +- [Ubuntu 20.04 LTS (Torrent)][10] + +请按照本教程学习[如何安装 Ubuntu][11]。 + +### 下载Ubuntu 20.04 LTS官方版下载 + +如果你想在不同的桌面环境下得到 Ubuntu 的官方版本,请按照下面的链接进行操作。 + +- [Ubuntu MATE 20.04 LTS][12] +- [Kubuntu 20.04 LTS][13] +- [Xubuntu 20.04 LTS][14] +- [Ubuntu Budgie 20.04 LTS][15] +- [Ubuntu Studio 20.04 LTS][16] +- [Lubuntu 20.04 LTS][17] + +如果你没有在各自的官方网站上找到最新的 ISO/torrent 文件,只需前往 [cdimages.ubuntu.com][18] 找到所有的版本。 + +接下来,导航到“发行版名称” -> “releases” -> “20.04” -> “release”,然后你应该可以找到列出的 ISO 和 torrent 文件的链接。 + +如果你有问题,请参考这篇文章,它回答了[关于 Ubuntu 20.04 的常见问题][7]。如果你要安装,请查看我们推荐的[安装 Ubuntu 20.04 之后要做的事情][19]。 + +享受 Ubuntu 20.04 LTS Focal Fossa! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/download-ubuntu-20-04/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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/2020/04/Ubuntu-20.04-LTS-released.png?ssl=1 +[2]: https://itsfoss.com/gnome-3-36-release/ +[3]: https://itsfoss.com/ubuntu-20-04-release-features/ +[4]: https://itsfoss.com/what-is-zfs/ +[5]: https://itsfoss.com/linux-kernel-5-4/ +[6]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[7]: https://itsfoss.com/ubuntu-20-04-faq/ +[8]: https://itsfoss.com/upgrade-ubuntu-version/ +[9]: http://releases.ubuntu.com/focal/ubuntu-20.04-desktop-amd64.iso +[10]: http://releases.ubuntu.com/focal/ubuntu-20.04-desktop-amd64.iso.torrent +[11]: https://itsfoss.com/install-ubuntu/ +[12]: https://ubuntu-mate.org/download/amd64/focal/ +[13]: https://kubuntu.org/getkubuntu/ +[14]: https://xubuntu.org/download/ +[15]: https://ubuntubudgie.org/downloads/ +[16]: https://ubuntustudio.org/ +[17]: https://lubuntu.me/downloads/ +[18]: http://cdimages.ubuntu.com/ +[19]: https://itsfoss.com/things-to-do-after-installing-ubuntu-20-04/ diff --git a/published/202004/20200424 What you need to know about open source ad blockers.md b/published/202004/20200424 What you need to know about open source ad blockers.md new file mode 100644 index 0000000000..c28cbc6080 --- /dev/null +++ b/published/202004/20200424 What you need to know about open source ad blockers.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (CrazyShipOne) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12157-1.html) +[#]: subject: (What you need to know about open source ad blockers) +[#]: via: (https://opensource.com/article/20/4/ad-blockers) +[#]: author: (Joshua Pearce https://opensource.com/users/jmpearce) + +开源的广告拦截器不但节能,而且能拯救生命! +====== +> 三个开源广告拦截器与“无广告拦截器”对照组进行了测试。 + +![](https://img.linux.net.cn/data/attachment/album/202004/27/220109b86sidn56sn6inoh.jpg) + +一项旨在调查自由开源的广告拦截器节能的情况的[研究][2],意外地发现了互联网广告正在浪费你大量的时间。 + +更重要的是,研究结果表明了你可以挽救回这些失去的时间。这项研究评估发现,使用 [uBlock Origin][3](一个开源免费的广告拦截器)的情况下平均每个网民一年可以节约超过 100 个小时的时间。uBlock Origin 是测试中最有效的广告拦截器,不过其他的广告拦截器也为网民节省了时间、能源以及金钱。 + +![Ad blocker screen comparison][4] + +在研究结果中,[AdBlock+][5] 减少了 11% 的页面加载时间,[Privacy Badger][6] 减少了 22%,[uBlock Origin][3] 减少了 28%。对于单独一个页面来说这个时间並不算多,但是网民们一半以上的浏览时间都是在网站间快速跳转,通常在一个页面停留少于 15 秒。鉴于这种情况,加载广告的额外时间加起来就很多了。 + +发布于 Technologies 杂志上的《[用开源的广告拦截器节能][7]》一文最初旨在解决日益增长的能源消耗问题。随着全球网民每日上网时间超过 6.5 小时,与互联网相关的用电量正在快速地增加。以美国人为例,自 2000 年他们的上网时间已经增加了一倍,几乎达到每周 24 小时。开源广告拦截器通过消灭上网和观看视频时产生的广告,潜在地减少了时间,从而减少用电。 + +在研究过程中,对三个开源广告拦截器与“无广告拦截器”对照组进行了测试。研究人员记录了浏览全球访问量最大的网站的页面加载时间,其中包括网络搜索(谷歌、雅虎、必应)、信息(Weather.com、维基百科)和新闻网站(CNN、福克斯、纽约时报)。除此之外,研究还分析了观看流行与非流行视频内容时广告所花费的时间。这部分研究由于缺乏 Youtube 上流行和非流行内容观看比例的数据而非常具有挑战性。每个视频浪费在广告观看上的时间可以从 0.06% 到惊人的 21% 不等。而且,这还只是浏览器上记录的加载广告而失去的时间。 + +总的来说,研究结果表明加载广告所浪费的能源并不是是小事。由于运行电脑所使用的大量电力仍然来自于煤炭,而煤炭会造成空气污染和过早死亡,因此该研究分析了广告拦截器拯救美国人生命的潜力。(LCTT 译注:由于这项研究是美国人完成的,所以这里仅提及了美国人,但是同理可推至全球。)结果是令人震惊的:如果美国人都使用开源广告拦截器,每年节约的能源将会拯救超过 36 个美国人的生命。 + +电能即金钱,所以削减广告也可以为消费者节约钱财。在美国,如果所有的网民都在他们的电脑上开启 [Privacy Badger][8],美国人每年可以节约超过 9100 万美元。在全球范围内,调查研究的结果则更令人吃惊。uBlock Origin 每年可以为全球消费者节约 18 亿美元。 + +这项研究始于人们因为新冠肺炎大流行而被迫居家之前,因此所有的数据都可以被认为是保守的估算。整体来说,研究发现了开源广告拦截器是一项潜在的节能技术。 + +虽然自由开源的广告拦截器可以节约能源,对自然环境也有好处,但你可能主要是为了拦截恼人的广告和节省自己的时间而使用它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/ad-blockers + +作者:[Joshua Pearce][a] +选题:[lujun9972][b] +译者:[CrazyShipOne](https://github.com/CrazyShipOne) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jmpearce +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_desktop_website_checklist_metrics.png?itok=OKKbl1UR (Browser of things) +[2]: https://www.mdpi.com/2227-7080/8/2/18 +[3]: https://github.com/gorhill/uBlock +[4]: https://opensource.com/sites/default/files/uploads/os_ad_blocker_story_.png (Ad blocker screen comparison) +[5]: https://adblockplus.org/ +[6]: https://privacybadger.org/ +[7]: https://www.academia.edu/42434401/Energy_Conservation_with_Open_Source_Ad_Blockers +[8]: https://privacybadger.org/ diff --git a/published/202004/20200425 What Happened to IPv5- Why there is IPv4, IPv6 but no IPv5.md b/published/202004/20200425 What Happened to IPv5- Why there is IPv4, IPv6 but no IPv5.md new file mode 100644 index 0000000000..3a8ab6b8bd --- /dev/null +++ b/published/202004/20200425 What Happened to IPv5- Why there is IPv4, IPv6 but no IPv5.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12168-1.html) +[#]: subject: (What Happened to IPv5? Why there is IPv4, IPv6 but no IPv5?) +[#]: via: (https://itsfoss.com/what-happened-to-ipv5/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +IPv5 发生了什么?为什么有 IPv4、IPv6 但没有 IPv5? +====== + +如果你花过很多时间在互联网上,那么你应该已经听说过计算机每天使用的 IPv4 和 IPv6 协议。 + +你可能会问的一个问题是:为什么没有 IPv5?为什么 IPv6 在 IPv4 之后而不是 IPv5 之后出现?是否有 IPv5,如果是,那么 IPv5 发生了什么? + +答案是肯定的,曾经有一个 IPv5。让我解释一下这里发生的事。 + +### 互联网的早期历史 + +![ARPA Logical Map in 1977 | Image courtesy: Wikipedia][1] + +在 1960 年代后期,美国国防部的[高级研究计划局][2](DARPA)发起了一个[项目][3]来连接全国的计算机。最初的目标是创建一个由全国 ARPA 资助的所有计算机组成的网络系统。 + +由于这是第一次将如此规模的网络整合在一起,因此他们也在不断发展自己的技术和硬件。他们首先做的工作之一就是开发名为[传输控制协议][4]Transmission Control Protocol(TCP)的互联网协议Internet Protocol(IP)。该协议“可靠、有序,并会对运行于通过 IP 网络传输的主机上的应用的八进制(字节)流通讯进行错误检测”。简单来说,它可以确保数据安全到达。 + +最初,TCP 被设计为[“主机级别的端到端协议以及封装和路由协议”][5]。但是,他们意识到他们需要拆分协议以使其更易于管理。于是决定由 IP 协议处理封装和路由。 + +那时,TCP 已经经历了三个版本,因此新协议被称为 IPv4。 + +### IPv5 的诞生 + +IPv5 开始时有个不同的名字:互联网流协议Internet Stream Protocol(ST)。它是[由 Apple、NeXT 和 Sun Microsystems][6] 为试验流式语音和视频而创建的。 + +该新协议能够“在保持通信的同时,以特定频率传输数据包”。 + +### 那么 IPv5 发生了什么? + +![][7] + +IPv5 从未被接受为正式的互联网协议。这主要是由于 32 位限制。 + +IPV5 使用与 IPv4 相同的寻址系统。每个地址由 0 到 255 之间的四组数字组成。这将可能的地址数量限制为 [43 亿][6]个。 + +在 1970 年代初,这似乎比全世界所需要的还要多。但是,互联网的爆炸性增长证明了这一想法是错误的。2011 年,世界上的IPv4地址正式用完了。 + +在 1990 年代,一个新项目开始致力于研究下一代互联网协议(IPng)。这形成了 128 位的 IPv6。IPv6 地址包含 [“8 组 4 字符的十六进制数字”][6],它可以包含从 0 到 9 的数字和从 A 到 F 的字母。与 IPv4 不同,IPv6 拥有数万亿个可能的地址,因此我们应该能安全一阵子。 + +同时,IPv5 奠定了 VoIP 的基础,而该技术已被我们用于当今世界范围内的通信。**因此,我想在某种程度上,你可以说 IPv5 仍然可以保留到了今天**。 + +希望你喜欢有关互联网历史的轶事。你可以阅读其他[关于 Linux 和技术的琐事文章][8]。 + +如果你觉得这篇文章有趣,请花一点时间在社交媒体、Hacker News 或 [Reddit][9] 上分享它。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/what-happened-to-ipv5/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/Arpa_internet.png?fit=800%2C573&ssl=1 +[2]: https://en.wikipedia.org/wiki/DARPA +[3]: https://en.wikipedia.org/wiki/ARPANET +[4]: https://en.wikipedia.org/wiki/Transmission_Control_Protocol +[5]: https://fcw.com/articles/2006/07/31/what-ever-happened-to-ipv5.aspx +[6]: https://www.lifewire.com/what-happened-to-ipv5-3971327 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/what-happened-to-ipv5.png?ssl=1 +[8]: https://itsfoss.com/category/story/ +[9]: https://reddit.com/r/linuxusersgroup diff --git a/published/202004/20200428 Fedora 32 is officially here.md b/published/202004/20200428 Fedora 32 is officially here.md new file mode 100644 index 0000000000..acad6862f5 --- /dev/null +++ b/published/202004/20200428 Fedora 32 is officially here.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12164-1.html) +[#]: subject: (Fedora 32 is officially here!) +[#]: via: (https://fedoramagazine.org/announcing-fedora-32/) +[#]: author: (Matthew Miller https://fedoramagazine.org/author/mattdm/) + +Fedora 32 正式发布! +====== + +![][1] + +它来了! 我们很荣幸地宣布 Fedora 32 的发布。感谢成千上万的 Fedora 社区成员和贡献者的辛勤工作,我们又一次准时发布了。 + +如果你只想马上就能拿到它,请马上访问 。更多详情,请继续阅读本文。 + +### Fedora 的全部变种 + +Fedora Editions 是针对特定的“展示”用途输出的。 + +Fedora Workstation 专注于桌面系统。特别是,它面向的是那些希望获得“可以工作的” Linux 操作系统体验的软件开发者。这个版本采用了 [GNOME 3.36][2],一如既往地有很多很棒的改进。我最喜欢的是新的锁屏! + +Fedora Server 以一种易于部署的方式为系统管理员带来了新锐的开源服务器软件。对于边缘计算用例,[Fedora IoT][3] 为 IoT 生态系统提供了坚实的基础。 + +Fedora CoreOS 是一个新兴的 Fedora Edition。它是一个自动更新的、最小化的操作系统,用于安全地大规模运行容器化工作负载。它提供了几个[更新流][4],遵循大约每两周一次的自动更新。目前,next 流是基于 Fedora 32,后续还有 testing 流和 stable 流。你可以从[下载页面][5]中找到关于按 next 流发布的工件的信息,并在 [Fedora CoreOS 文档][6]中找到关于如何使用这些工件的信息。 + +当然,我们制作的不仅仅是 Editions。[Fedora Spins][7] 和[实验室][8]针对的是不同的受众和用例,包括[Fedora 天文学实验室][9],它为业余和专业的天文学家带来了完整的开源工具链,还有像 [KDE Plasma][10] 和 [Xfce][11] 这样的桌面环境。Fedora 32 中新增的 [计算神经科学实验室][12] 是由我们的神经科学特别兴趣小组开发的,它可以实现计算神经科学。 + +还有,别忘了我们的备用架构,[ARM AArch64、Power 和 S390x][13]。特别值得一提的是,我们改进了对 Rockchip 系统级芯片的支持,包括 Rock960、RockPro64 和 Rock64。 + +### 一般性的改进 + +无论你使用 Fedora 的哪个变体,你都能获得最新的开源世界。遵循我们的“[First][14]”理念,我们更新了关键的编程语言和系统库包,包括 GCC 10、Ruby 2.7 和 Python 3.8。当然,随着 Python 2 已经过了报废期,我们已经从 Fedora 中删除了大部分 Python 2 包,但我们为仍然需要它的开发者和用户提供了一个遗留的 python27 包。在 Fedora Workstation 中,我们默认启用了 EarlyOOM 服务,以改善低内存情况下的用户体验。 + +我们非常期待你能尝试一下新版本的使用体验! 现在就去 下载它。或者如果你已经在运行 Fedora 操作系统,请按照简单的[升级说明][15]进行升级。 + +### 万一出现问题…… + +如果你遇到问题,请查看[Fedora 32 常见错误][16]页面,如果有问题,请访问我们的 [Askedora][17] 用户支持平台。 + +### 谢谢大家 + +感谢在这个发布周期中为 Fedora 项目做出贡献的成千上万的人,特别是感谢那些在大流行期间为又一次准时发布而付出额外努力的人。Fedora 是一个社区,很高兴看到我们彼此之间的支持。我邀请大家参加 4 月28-29 日的[红帽峰会虚拟体验][18],了解更多关于 Fedora 和其他社区的信息。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/announcing-fedora-32/ + +作者:[Matthew Miller][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/mattdm/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/04/f32-final-816x345.png +[2]: https://www.gnome.org/news/2020/03/gnome-3-36-released/ +[3]: https://iot.fedoraproject.org/ +[4]: https://docs.fedoraproject.org/en-US/fedora-coreos/update-streams/ +[5]: https://getfedora.org/en/coreos/download?stream=next +[6]: https://docs.fedoraproject.org/en-US/fedora-coreos/getting-started/ +[7]: https://spins.fedoraproject.org/ +[8]: https://labs.fedoraproject.org/ +[9]: https://labs.fedoraproject.org/en/astronomy/ +[10]: https://spins.fedoraproject.org/en/kde/ +[11]: https://spins.fedoraproject.org/en/xfce/ +[12]: https://labs.fedoraproject.org/en/comp-neuro +[13]: https://alt.fedoraproject.org/alt/ +[14]: https://docs.fedoraproject.org/en-US/project/#_first +[15]: https://docs.fedoraproject.org/en-US/quick-docs/upgrading/ +[16]: https://fedoraproject.org/wiki/Common_F32_bugs +[17]: http://ask.fedoraproject.org +[18]: https://www.redhat.com/en/summit diff --git a/published/202004/20200429 Manjaro 20 Lysia Arrives with ZFS and Snap Support.md b/published/202004/20200429 Manjaro 20 Lysia Arrives with ZFS and Snap Support.md new file mode 100644 index 0000000000..2ed94dd0a8 --- /dev/null +++ b/published/202004/20200429 Manjaro 20 Lysia Arrives with ZFS and Snap Support.md @@ -0,0 +1,110 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12166-1.html) +[#]: subject: (Manjaro 20 Lysia Arrives with ZFS and Snap Support) +[#]: via: (https://itsfoss.com/manjaro-20-release/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Manjaro 20 Lysia 到来,支持 ZFS 和 Snap +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/29/232925j8paomvp11pfu12v.jpg) + +> Manjaro Linux 刷新了其 Manjaro 20 “Lysia” 的 ISO。现在在 Pamac 中支持了 Snap 和 Flatpak 软件包。在 Manjaro Architect 安装程序中增加了 ZFS 选项,并使用最新的内核 5.6 作为基础。 + +最近新的发行版的发布像下雨一样。在上周发布了 [Ubuntu 20.04 LTS](https://linux.cn/article-12142-1.html) ,紧接着 [Fedora 32](https://linux.cn/article-12164-1.html) 也刚刚发布,而现在 [Manjaro 发布了版本 20][1],代号为 Lysia。 + +### Manjaro 20 Lysia 有什么新东西? + +其实有很多。让我给大家介绍一下 Manjaro 20 中的一些主要新功能。 + +#### 新的抹茶主题 + +Manjaro 20 有一个新的默认主题,名为 Matcha(抹茶)。它让桌面看起来更有质感。 + +![][2] + +#### 对 Snap 和 Flatpak 的支持 + +Snap 和 Flatpak 软件包的支持得到了改进。如果你愿意,你可以在命令行中使用它们。 + +你还可以在 Pamac 图形界面包管理器中启用 Snap 和 Flatpak 支持。 + +![Enable Snap support in Pamac Manjaro][3] + +启用后,你可以在 Pamac 软件管理器中找到并安装 Snap/Flatpak 应用程序。 + +![Snap applications in Pamac][4] + +#### Pamac 提供了基于搜索安装新软件的方式(在 GNOME 中) + +在 GNOME 变种中,如果你搜索某个东西,Pamac 软件管理器会提供安装符合查询的软件。在其他使用 GNOME 桌面的发行版中,GNOME 软件中心也会这样做。 + +#### ZFS 支持登陆了 Manjaro Architect + +现在,你可以在 Manjaro Linux 中轻松地使用 ZFS 作为根文件系统。在 [Manjaro Architect][6] 中提供了对 [ZFS 文件系统][5]的支持。 + +请注意,我说的是 Manjaro Architect,即基于终端的安装程序。它和普通的图形化的 [Calamares 安装程序][7]不一样。 + +![][8] + +#### Linux kernel 5.6 + +最新的稳定版 [Linux 内核 5.6][9] 带来了更多的硬件支持,如 thunderbolt、Nvidia 和 USB4。你也可以使用 [WireGuard VPN][10]。 + +![][11] + +#### 其他杂项变化 + + * 新的桌面环境版本:Xfce 4.14、GNOME 3.36 和 KDE Plasma 5.18。 + * 新的默认 shell 是 zsh。 + * Display-Profiles 允许你存储一个或多个配置文件,用于你的首选显示配置。 + * 改进后的 Gnome-Layout-Switcher。 + * 最新的驱动程序。 + * 改进和完善了 Manjaro 工具。 + +### 如何取得 Manjaro 20 Lysia? + +如果你已经在使用 Manjaro,只需更新你的 Manjaro Linux 系统,你就应该已经在使用 Lysia 了。 + +Manjaro 采用了滚动发布模式,这意味着你不必手动从一个版本升级到另一个版本。只要有新的版本发布,不需要重新安装就可以使用了。 + +既然 Manjaro 是滚动发布的,为什么每隔一段时间就会发布一个新版本呢?这是因为他们要刷新 ISO,这样下载 Manjaro 的新用户就不用再安装过去几年的更新了。这就是为什么 Arch Linux 也会每个月刷新一次 ISO 的原因。 + +Manjaro 的“ISO 刷新”是有代号和版本的,因为它可以帮助开发者清楚地标明每个开发阶段的发展方向。 + +所以,如果你已经在使用它,只需使用 Pamac 或命令行[更新你的 Manjaro Linux 系统][12]即可。 + +如果你想尝试 Manjaro 或者想使用 ZFS,那么你可以通过从它的网站上[下载 ISO][14] 来[安装 Manjaro][13]。 + +愿你喜欢新的 Manjaro Linux 发布。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/manjaro-20-release/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://forum.manjaro.org/t/manjaro-20-0-lysia-released/138633 +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/manjaro-20-lysia.jpeg?resize=800%2C440&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/enable-snap-in-pamac-manjaro.jpg?resize=800%2C490&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/snap-app-pacman.jpg?resize=800%2C489&ssl=1 +[5]: https://itsfoss.com/what-is-zfs/ +[6]: https://itsfoss.com/manjaro-architect-review/ +[7]: https://calamares.io/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/pacman-prompts-install-apps.jpg?resize=800%2C331&ssl=1 +[9]: https://itsfoss.com/linux-kernel-5-6/ +[10]: https://itsfoss.com/wireguard/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/manjaro-20-neofetch-screen.jpg?resize=800%2C495&ssl=1 +[12]: https://itsfoss.com/update-arch-linux/ +[13]: https://itsfoss.com/install-manjaro-linux/ +[14]: https://manjaro.org/download/ diff --git a/published/202005/20180425 An introduction to the GNU Core Utilities - Opensource.com.md b/published/202005/20180425 An introduction to the GNU Core Utilities - Opensource.com.md new file mode 100644 index 0000000000..fe61c265f0 --- /dev/null +++ b/published/202005/20180425 An introduction to the GNU Core Utilities - Opensource.com.md @@ -0,0 +1,127 @@ +GNU 核心实用程序简介 +====== + +> 大多数 Linux 系统管理员需要做的事情都可以在 GNU coreutils 或 util-linux 中找到。 + +![](https://img.linux.net.cn/data/attachment/album/202005/10/172312hofgh88i3g6jajfj.jpg) + +许多 Linux 系统管理员最基本和常用的工具主要包括在两套实用程序中:[GNU 核心实用程序(coreutils)][3]和 util-linux。它们的基本功能允许系统管理员执行许多管理 Linux 系统的任务,包括管理和操作文本文件、目录、数据流、存储介质、进程控制、文件系统等等。 + +这些工具是不可缺少的,因为没有它们,就不可能在 Unix 或 Linux 计算机上完成任何有用的工作。鉴于它们的重要性,让我们来研究一下它们。 + +### GNU coreutils + +要了解 GNU 核心实用程序的起源,我们需要乘坐时光机进行一次短暂的旅行,回到贝尔实验室的 Unix 早期。[编写 Unix][8] 是为了让 Ken Thompson、Dennis Ritchie、Doug McIlroy 和 Joe Ossanna 可以继续他们在大型多任务和多用户计算机项目 [Multics][9] 上的工作:开发一个叫做《太空旅行》游戏的小东西。正如今天一样,推动计算技术发展的似乎总是游戏玩家。这个新的操作系统比 Multics(LCTT 译注:multi- 字头的意思是多数的)的局限性更大,因为一次只能有两个用户登录,所以被称为 Unics(LCTT 译注:uni- 字头的意思是单独的)。后来这个名字被改成了 Unix。 + +随着时间的推移,Unix 取得了如此巨大的成功,开始贝尔实验室基本上是将其赠送给大学,后来送给公司也只是收取介质和运输的费用。在那个年代,系统级的软件是在组织和程序员之间共享的,因为在系统管理这个层面,他们努力实现的是共同的目标。 + +最终,AT&T 公司的[老板们][10]决定,他们应该在 Unix 上赚钱,并开始使用限制更多的、昂贵的许可证。这发生在软件变得更加专有、受限和封闭的时期,从那时起,与其他用户和组织共享软件变得不可能。 + +有些人不喜欢这种情况,于是用自由软件来对抗。Richard M. Stallman(RMS),他带领着一群“反叛者”试图编写一个开放的、自由的可用操作系统,他们称之为 GNU 操作系统。这群人创建了 GNU 实用程序,但并没有产生一个可行的内核。 + +当 Linus Torvalds 开始编写和编译 Linux 内核时,他需要一套非常基本的系统实用程序来开始执行一些稍微有用的工作。内核并不提供命令或任何类型的命令 shell,比如 Bash,它本身是没有任何用处的,因此,Linus 使用了免费提供的 GNU 核心实用程序,并为 Linux 重新编译了它们。这让他拥有了一个完整的、即便是相当基本的操作系统。 + +你可以通过在终端命令行中输入命令 `info coreutils` 来了解 GNU 核心实用程序的全部内容。下面的核心实用程序列表就是这个信息页面的一部分。这些实用程序按功能进行了分组,以方便查找;在终端中,选择你想了解更多信息的组,然后按回车键。 + +``` +* Output of entire files::       cat tac nl od base32 base64 +* Formatting file contents::     fmt pr fold +* Output of parts of files::     head tail split csplit +* Summarizing files::            wc sum cksum b2sum md5sum sha1sum sha2 +* Operating on sorted files::    sort shuf uniq comm ptx tsort +* Operating on fields::          cut paste join +* Operating on characters::      tr expand unexpand +* Directory listing::            ls dir vdir dircolors +* Basic operations::             cp dd install mv rm shred +* Special file types::           mkdir rmdir unlink mkfifo mknod ln link readlink +* Changing file attributes::     chgrp chmod chown touch +* Disk usage::                   df du stat sync truncate +* Printing text::                echo printf yes +* Conditions::                   false true test expr +* Redirection::                  tee +* File name manipulation::       dirname basename pathchk mktemp realpath +* Working context::              pwd stty printenv tty +* User information::             id logname whoami groups users who +* System context::               date arch nproc uname hostname hostid uptime +* SELinux context::              chcon runcon +* Modified command invocation::  chroot env nice nohup stdbuf timeout +* Process control::              kill +* Delaying::                     sleep +* Numeric operations::           factor numfmt seq +``` + +这个列表里有 102 个实用程序。它涵盖了在 Unix 或 Linux 主机上执行基本任务所需的许多功能。但是,很多基本的实用程序都缺失了,例如,`mount` 和 `umount` 命令不在这个列表中。这些命令和其他许多不在 GNU 核心实用程序中的命令可以在 util-linux 中找到。 + +### util-linux + +util-linix 实用程序包中包含了许多系统管理员常用的其它命令。这些实用程序是由 Linux 内核组织发布的,这 107 条命令中几乎每一个都来自原本是三个单独的集合 —— fileutils、shellutils 和 textutils,2003 年它们被[合并成一个包][11]:util-linux。 + +``` +agetty          fsck.minix      mkfs.bfs        setpriv +blkdiscard      fsfreeze        mkfs.cramfs     setsid +blkid           fstab           mkfs.minix      setterm +blockdev        fstrim          mkswap          sfdisk +cal             getopt          more            su +cfdisk          hexdump         mount           sulogin +chcpu           hwclock         mountpoint      swaplabel +chfn            ionice          namei           swapoff +chrt            ipcmk           newgrp          swapon +chsh            ipcrm           nologin         switch_root +colcrt          ipcs            nsenter         tailf +col             isosize         partx           taskset +colrm           kill            pg              tunelp +column          last            pivot_root      ul +ctrlaltdel      ldattach        prlimit         umount +ddpart          line            raw             unshare +delpart         logger          readprofile     utmpdump +dmesg           login           rename          uuidd +eject           look            renice          uuidgen +fallocate       losetup         reset           vipw +fdformat        lsblk           resizepart      wall +fdisk           lscpu           rev             wdctl +findfs          lslocks         RTC Alarm       whereis +findmnt         lslogins        runuser         wipefs +flock           mcookie         script          write +fsck            mesg            scriptreplay    zramctl +fsck.cramfs     mkfs            setarch +``` + +这些实用程序中的一些已经被淘汰了,很可能在未来的某个时候会从集合中被踢出去。你应该看看[维基百科的 util-linux 页面][12]来了解其中许多实用程序的信息,而 man 页面也提供了关于这些命令的详细信息。 + +### 总结 + +这两个 Linux 实用程序的集合,GNU 核心实用程序和 util-linux,共同提供了管理 Linux 系统所需的基本实用程序。在研究这篇文章的过程中,我发现了几个有趣的实用程序,这些实用程序是我从不知道的。这些命令中的很多都是很少需要的,但当你需要的时候,它们是不可缺少的。 + +在这两个集合里,有 200 多个 Linux 实用工具。虽然 Linux 的命令还有很多,但这些都是管理一个典型的 Linux 主机的基本功能所需要的。 + +--- + +via: [https://opensource.com/article/18/4/gnu-core-utilities][17] + +作者: [David Both][18] 选题者: [lujun9972][19] 译者: [wxy][20] 校对: [wxy][21] + +本文由 [LCTT][22] 原创编译,[Linux中国][23] 荣誉推出 + +[1]: https://pixabay.com/en/tiny-people-core-apple-apple-half-700921/ +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.gnu.org/software/coreutils/coreutils.html +[4]: https://opensource.com/life/17/10/top-terminal-emulators?intcmp=7016000000127cYAAQ +[5]: https://opensource.com/article/17/2/command-line-tools-data-analysis-linux?intcmp=7016000000127cYAAQ +[6]: https://opensource.com/downloads/advanced-ssh-cheat-sheet?intcmp=7016000000127cYAAQ +[7]: https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=7016000000127cYAAQ +[8]: https://en.wikipedia.org/wiki/History_of_Unix +[9]: https://en.wikipedia.org/wiki/Multics +[10]: https://en.wikipedia.org/wiki/Pointy-haired_Boss +[11]: https://en.wikipedia.org/wiki/GNU_Core_Utilities +[12]: https://en.wikipedia.org/wiki/Util-linux +[13]: https://opensource.com/users/dboth +[14]: https://opensource.com/users/dboth +[15]: https://opensource.com/users/dboth +[16]: https://opensource.com/participate +[17]: https://opensource.com/article/18/4/gnu-core-utilities +[18]: https://opensource.com/users/dboth +[19]: https://github.com/lujun9972 +[20]: https://github.com/译者ID +[21]: https://github.com/校对者ID +[22]: https://github.com/LCTT/TranslateProject +[23]: https://linux.cn/ diff --git a/published/202005/20180612 Systemd Services- Reacting to Change.md b/published/202005/20180612 Systemd Services- Reacting to Change.md new file mode 100644 index 0000000000..8a7be7cde2 --- /dev/null +++ b/published/202005/20180612 Systemd Services- Reacting to Change.md @@ -0,0 +1,266 @@ +Systemd 服务:响应变化 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/12/001037iz91uu9b15dqb9w3.jpg) + +[我有一个这样的电脑棒][1](图1),我把它用作通用服务器。它很小且安静,由于它是基于 x86 架构的,因此我为我的打印机安装驱动没有任何问题,而且这就是它大多数时候干的事:与客厅的共享打印机和扫描仪通信。 + +![ComputeStick][3] + +*一个英特尔电脑棒。欧元硬币大小。* + +大多数时候它都是闲置的,尤其是当我们外出时,因此我认为用它作监视系统是个好主意。该设备没有自带的摄像头,也不需要一直监视。我也不想手动启动图像捕获,因为这样就意味着在出门前必须通过 SSH 登录,并在 shell 中编写命令来启动该进程。 + +因此,我以为应该这么做:拿一个 USB 摄像头,然后只需插入它即可自动启动监视系统。如果这个电脑棒重启后发现连接了摄像头也启动监视系统就更加分了。 + +在先前的文章中,我们看到 systemd 服务既可以[手动启动或停止][5],也可以[在满足某些条件时启动或停止][6]。这些条件不限于操作系统在启动或关机时序中达到某种状态,还可以在你插入新硬件或文件系统发生变化时进行。你可以通过将 Udev 规则与 systemd 服务结合起来实现。 + +### 有 Udev 支持的热插拔 + +Udev 规则位于 `/etc/udev/rules` 目录中,通常是由导致一个动作action条件conditions赋值assignments的单行语句来描述。 + +有点神秘。让我们再解释一次: + +通常,在 Udev 规则中,你会告诉 systemd 当设备连接时需要查看什么信息。例如,你可能想检查刚插入的设备的品牌和型号是否与你让 Udev 等待的设备的品牌和型号相对应。这些就是前面提到的“条件”。 + +然后,你可能想要更改一些内容,以便以后可以方便使用该设备。例如,更改设备的读写权限:如果插入 USB 打印机,你会希望用户能够从打印机读取信息(用户的打印应用程序需要知道其模型、制造商,以及是否准备好接受打印作业)并向其写入内容,即发送要打印的内容。更改设备的读写权限是通过你之前阅读的“赋值” 之一完成的。 + +最后,你可能希望系统在满足上述条件时执行某些动作,例如在插入某个外部硬盘时启动备份程序以复制重要文件。这就是上面提到的“动作”的例子。 + +了解这些之后, 来看看以下几点: + +``` +ACTION=="add", SUBSYSTEM=="video4linux", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="e207", +SYMLINK+="mywebcam", TAG+="systemd", MODE="0666", ENV{SYSTEMD_WANTS}="webcam.service" +``` + +规则的第一部分, + +``` +ACTION=="add", SUBSYSTEM=="video4linux", ATTRS{idVendor}=="03f0", +ATTRS{idProduct}=="e207" [etc... ] +``` + +表明了执行你想让系统执行的其他动作之前设备必须满足的条件。设备必须被添加到(`ACTION=="add"`)机器上,并且必须添加到 `video4linux` 子系统中。为了确保仅在插入正确的设备时才应用该规则,你必须确保 Udev 正确识别设备的制造商(`ATTRS{idVendor}=="03f0"`)和型号(`ATTRS{idProduct}=="e207"`)。 + +在本例中,我们讨论的是这个设备(图2): + +![webcam][8] + +*这个试验使用的是 HP 的摄像头。* + +注意怎样用 `==` 来表示这是一个逻辑操作。你应该像这样阅读上面的简要规则: + +> 如果添加了一个设备并且该设备由 video4linux 子系统控制,而且该设备的制造商编码是 03f0,型号是 e207,那么... + +但是,你从哪里获取的这些信息?你在哪里找到触发事件的动作、制造商、型号等?你可要使用多个来源。你可以通过将摄像头插入机器并运行 `lsusb` 来获得 `IdVendor` 和 `idProduct` : + +``` +lsusb +Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub +Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub +Bus 003 Device 003: ID 03f0:e207 Hewlett-Packard +Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +Bus 001 Device 003: ID 04f2:b1bb Chicony Electronics Co., Ltd +Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub +Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub +``` + +我用的摄像头是 HP 的,你在上面的列表中只能看到一个 HP 设备。`ID` 提供了制造商和型号,它们以冒号(`:`)分隔。如果你有同一制造商的多个设备,不确定哪个是哪个设备,请拔下摄像头,再次运行 `lsusb` , 看看少了什么。 + +或者... + +拔下摄像头,等待几秒钟,运行命令 `udevadmin monitor --environment` ,然后重新插入摄像头。当你使用的是HP摄像头时,你将看到: + +``` +udevadmin monitor --environment +UDEV [35776.495221] add /devices/pci0000:00/0000:00:1c.3/0000:04:00.0 + /usb3/3-1/3-1:1.0/input/input21/event11 (input) +.MM_USBIFNUM=00 +ACTION=add +BACKSPACE=guess +DEVLINKS=/dev/input/by-path/pci-0000:04:00.0-usb-0:1:1.0-event + /dev/input/by-id/usb-Hewlett_Packard_HP_Webcam_HD_2300-event-if00 +DEVNAME=/dev/input/event11 +DEVPATH=/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/ + usb3/3-1/3-1:1.0/input/input21/event11 +ID_BUS=usb +ID_INPUT=1 +ID_INPUT_KEY=1 +ID_MODEL=HP_Webcam_HD_2300 +ID_MODEL_ENC=HPx20Webcamx20HDx202300 +ID_MODEL_ID=e207 +ID_PATH=pci-0000:04:00.0-usb-0:1:1.0 +ID_PATH_TAG=pci-0000_04_00_0-usb-0_1_1_0 +ID_REVISION=1020 +ID_SERIAL=Hewlett_Packard_HP_Webcam_HD_2300 +ID_TYPE=video +ID_USB_DRIVER=uvcvideo +ID_USB_INTERFACES=:0e0100:0e0200:010100:010200:030000: +ID_USB_INTERFACE_NUM=00 +ID_VENDOR=Hewlett_Packard +ID_VENDOR_ENC=Hewlettx20Packard +ID_VENDOR_ID=03f0 +LIBINPUT_DEVICE_GROUP=3/3f0/e207:usb-0000:04:00.0-1/button +MAJOR=13 +MINOR=75 +SEQNUM=3162 +SUBSYSTEM=input +USEC_INITIALIZED=35776495065 +XKBLAYOUT=es +XKBMODEL=pc105 +XKBOPTIONS= +XKBVARIANT= +``` + +可能看起来有很多信息要处理,但是,看一下这个:列表前面的 `ACTION` 字段, 它告诉你刚刚发生了什么事件,即一个设备被添加到系统中。你还可以在其中几行中看到设备名称的拼写,因此可以非常确定它就是你要找的设备。输出里还显示了制造商的ID(`ID_VENDOR_ID = 03f0`)和型号(`ID_VENDOR_ID = 03f0`)。 + +这为你提供了规则条件部分需要的四个值中的三个。你可能也会想到它还给了你第四个,因为还有一行这样写道: + +``` +SUBSYSTEM=input +``` + +小心!尽管 USB 摄像头确实是提供输入的设备(键盘和鼠标也是),但它也属于 usb 子系统和其他几个子系统。这意味着你的摄像头被添加到了多个子系统,并且看起来像多个设备。如果你选择了错误的子系统,那么你的规则可能无法按你期望的那样工作,或者根本无法工作。 + +因此,第三件事就是检查网络摄像头被添加到的所有子系统,并选择正确的那个。为此,请再次拔下摄像头,然后运行: + +``` +ls /dev/video* +``` + +这将向你显示连接到本机的所有视频设备。如果你使用的是笔记本,大多数笔记本都带有内置摄像头,它可能会显示为 `/dev/video0` 。重新插入摄像头,然后再次运行 `ls /dev/video*`。 + +现在,你应该看到多一个视频设备(可能是`/dev/video1`)。 + +现在,你可以通过运行 `udevadm info -a /dev/video1` 找出它所属的所有子系统: + +``` +udevadm info -a /dev/video1 + +Udevadm info starts with the device specified by the devpath and then +walks up the chain of parent devices. It prints for every device +found, all possible attributes in the udev rules key format. +A rule to match, can be composed by the attributes of the device +and the attributes from one single parent device. + + looking at device '/devices/pci0000:00/0000:00:1c.3/0000:04:00.0 +  /usb3/3-1/3-1:1.0/video4linux/video1': + KERNEL=="video1" + SUBSYSTEM=="video4linux" + DRIVER=="" + ATTR{dev_debug}=="0" + ATTR{index}=="0" + ATTR{name}=="HP Webcam HD 2300: HP Webcam HD" + +[etc...] +``` + +输出持续了相当长的时间,但是你感兴趣的只是开头的部分:`SUBSYSTEM =="video4linux"`。你可以将这行文本直接复制粘贴到你的规则中。输出的其余部分(为简洁未显示)为你提供了更多的信息,例如制造商和型号 ID,同样是以你可以复制粘贴到你的规则中的格式。 + +现在,你有了识别设备的方式吗,并明确了什么事件应该触发该动作,该对设备进行修改了。 + +规则的下一部分,`SYMLINK+="mywebcam", TAG+="systemd", MODE="0666"` 告诉 Udev 做三件事:首先,你要创建设备的符号链接(例如 `/dev/video1` 到 `/dev/mywebcam`。这是因为你无法预测系统默认情况下会把那个设备叫什么。当你拥有内置摄像头并热插拔一个新的时,内置摄像头通常为 `/dev/video0`,而外部摄像头通常为 `/dev/video1`。但是,如果你在插入外部 USB 摄像头的情况下重启计算机,则可能会相反,内部摄像头可能会变成 `/dev/video1` ,而外部摄像头会变成 `/dev/video0`。这想告诉你的是,尽管你的图像捕获脚本(稍后将看到)总是需要指向外部摄像头设备,但是你不能依赖它是 `/dev/video0` 或 `/dev/video1`。为了解决这个问题,你告诉 Udev 创建一个符号链接,该链接在设备被添加到 `video4linux` 子系统的那一刻起就不会再变,你将使你的脚本指向该链接。 + +第二件事就是将 `systemd` 添加到与此规则关联的 Udev 标记列表中。这告诉 Udev,该规则触发的动作将由 systemd 管理,即它将是某种 systemd 服务。 + +注意在这个两种情况下是如何使用 `+=` 运算符的。这会将值添加到列表中,这意味着你可以向 `SYMLINK` 和 `TAG` 添加多个值。 + +另一方面,`MODE` 值只能包含一个值(因此,你可以使用简单的 `=` 赋值运算符)。`MODE` 的作用是告诉 Udev 谁可以读或写该设备。如果你熟悉 `chmod`(你读到此文, 应该会熟悉),你就也会熟悉[如何用数字表示权限][9]。这就是它的含义:`0666` 的含义是 “向所有人授予对设备的读写权限”。 + +最后, `ENV{SYSTEMD_WANTS}="webcam.service"` 告诉 Udev 要运行什么 systemd 服务。 + +将此规则保存到 `/etc/udev/rules.d` 目录名为 `90-webcam.rules`(或类似的名称)的文件中,你可以通过重启机器或运行以下命令来加载它: + +``` +sudo udevadm control --reload-rules && udevadm trigger +``` + +### 最后是服务 + +Udev 规则触发的服务非常简单: + +``` +# webcam.service + +[Service] +Type=simple +ExecStart=/home/[user name]/bin/checkimage.sh +``` + +基本上,它只是运行存储在你个人 `bin/` 中的 `checkimage.sh` 脚本并将其放到后台。[这是你在先前的文章中看过的内容][5]。它看起来似乎很小,但那只是因为它是被 Udev 规则调用的,你刚刚创建了一种特殊的 systemd 单元,称为 `device` 单元。 恭喜。 + +至于 `webcam.service` 调用的 `checkimage.sh` 脚本,有几种方法从摄像头抓取图像并将其与前一个图像进行比较以检查变化(这是 `checkimage.sh` 所做的事),但这是我的方法: + +``` +#!/bin/bash +# This is the checkimage.sh script + +mplayer -vo png -frames 1 tv:// -tv driver=v4l2:width=640:height=480:device= + /dev/mywebcam &>/dev/null +mv 00000001.png /home/[user name]/monitor/monitor.png + +while true +do + mplayer -vo png -frames 1 tv:// -tv driver=v4l2:width=640:height=480:device=/dev/mywebcam &>/dev/null + mv 00000001.png /home/[user name]/monitor/temp.png + + imagediff=`compare -metric mae /home/[user name]/monitor/monitor.png /home/[user name] + /monitor/temp.png /home/[user name]/monitor/diff.png 2>&1 > /dev/null | cut -f 1 -d " "` + if [ `echo "$imagediff > 700.0" | bc` -eq 1 ] + then + mv /home/[user name]/monitor/temp.png /home/[user name]/monitor/monitor.png + fi + + sleep 0.5 +done +``` + +首先使用[MPlayer][10]从摄像头抓取一帧(`00000001.png`)。注意,我们怎样将 `mplayer` 指向 Udev 规则中创建的 `mywebcam` 符号链接,而不是指向 `video0` 或 `video1`。然后,将图像传输到主目录中的 `monitor/` 目录。然后执行一个无限循环,一次又一次地执行相同的操作,但还使用了[Image Magick 的 compare 工具][11]来查看最后捕获的图像与 `monitor/` 目录中已有的图像之间是否存在差异。 + +如果图像不同,则表示摄像头的镜框里某些东西动了。该脚本将新图像覆盖原始图像,并继续比较以等待更多变动。 + +### 插线 + +所有东西准备好后,当你插入摄像头后,你的 Udev 规则将被触发并启动 `webcam.service`。 `webcam.service` 将在后台执行 `checkimage.sh` ,而 `checkimage.sh` 将开始每半秒拍一次照。你会感觉到,因为摄像头的 LED 在每次拍照时将开始闪。 + +与往常一样,如果出现问题,请运行: + +``` +systemctl status webcam.service +``` + +检查你的服务和脚本正在做什么。 + +### 接下来 + +你可能想知道:为什么要覆盖原始图像?当然,系统检测到任何动静,你都想知道发生了什么,对吗?你是对的,但是如你在下一部分中将看到的那样,将它们保持原样,并使用另一种类型的 systemd 单元处理图像将更好,更清晰和更简单。 + +请期待下一篇。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/intro-to-linux/2018/6/systemd-services-reacting-change + +作者:[Paul Brown][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[b]: https://github.com/lujun9972 +[1]: https://www.intel.com/content/www/us/en/products/boards-kits/compute-stick/stk1a32sc.html +[2]: https://www.linux.com/files/images/fig01png +[3]: https://lcom.static.linuxfound.org/sites/lcom/files/fig01.png +[4]: https://www.linux.com/licenses/category/used-permission +[5]: https://linux.cn/article-9700-1.html +[6]: https://linux.cn/article-9703-1.html +[7]: https://www.linux.com/files/images/fig02png +[8]: https://www.linux.com/sites/lcom/files/styles/floated_images/public/fig02.png?itok=esFv4BdM (webcam) +[9]: https://chmod-calculator.com/ +[10]: https://mplayerhq.hu/design7/news.html +[11]: https://www.imagemagick.org/script/compare.php +[12]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/published/202005/20190915 How to Configure SFTP Server with Chroot in Debian 10.md b/published/202005/20190915 How to Configure SFTP Server with Chroot in Debian 10.md new file mode 100644 index 0000000000..51a75f3521 --- /dev/null +++ b/published/202005/20190915 How to Configure SFTP Server with Chroot in Debian 10.md @@ -0,0 +1,199 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12186-1.html) +[#]: subject: (How to Configure SFTP Server with Chroot in Debian 10) +[#]: via: (https://www.linuxtechi.com/configure-sftp-chroot-debian10/) +[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/) + +如何在 Debian 10 中配置 Chroot 环境的 SFTP 服务 +====== + +SFTP 意思是“安全文件传输协议Secure File Transfer Protocol” 或 “SSH 文件传输协议SSH File Transfer Protocol”,它是最常用的用于通过 `ssh` 将文件从本地系统安全地传输到远程服务器的方法,反之亦然。`sftp` 的主要优点是,除 `openssh-server` 之外,我们不需要安装任何额外的软件包,在大多数的 Linux 发行版中,`openssh-server` 软件包是默认安装的一部分。`sftp` 的另外一个好处是,我们可以允许用户使用 `sftp` ,而不允许使用 `ssh` 。 + +![](https://img.linux.net.cn/data/attachment/album/202005/05/223518ip4mbdi4nggbdtgu.jpg) + +当前发布的 Debian 10 代号为 ‘Buster’,在这篇文章中,我们将演示如何在 Debian 10 系统中在 “监狱式的” Chroot 环境中配置 `sftp`。在这里,Chroot 监狱式环境意味着,用户不能超出各自的家目录,或者用户不能从各自的家目录更改目录。下面实验的详细情况: + +* OS = Debian 10 +* IP 地址 = 192.168.56.151 + +让我们跳转到 SFTP 配置步骤, + +### 步骤 1、使用 groupadd 命令给 sftp 创建一个组 + +打开终端,使用下面的 `groupadd` 命令创建一个名为的 `sftp_users` 组: + +``` +root@linuxtechi:~# groupadd sftp_users +``` + +### 步骤 2、添加用户到组 sftp_users 并设置权限 + +假设你想创建新的用户,并且想添加该用户到 `sftp_users` 组中,那么运行下面的命令, + +**语法:** + +``` +# useradd -m -G sftp_users <用户名> +``` + +让我们假设用户名是 `jonathan`: + +``` +root@linuxtechi:~# useradd -m -G sftp_users jonathan +``` + +使用下面的 `chpasswd` 命令设置密码: + +``` +root@linuxtechi:~# echo "jonathan:<输入密码>" | chpasswd +``` + +假设你想添加现有的用户到 `sftp_users` 组中,那么运行下面的 `usermod` 命令,让我们假设已经存在的用户名称是 `chris`: + +``` +root@linuxtechi:~# usermod -G sftp_users chris +``` + +现在设置用户所需的权限: + +``` +root@linuxtechi:~# chown root /home/jonathan /home/chris/ +``` + +在各用户的家目录中都创建一个上传目录,并设置正确地所有权: + +``` +root@linuxtechi:~# mkdir /home/jonathan/upload +root@linuxtechi:~# mkdir /home/chris/upload +root@linuxtechi:~# chown jonathan /home/jonathan/upload +root@linuxtechi:~# chown chris /home/chris/upload +``` + +**注意:** 像 Jonathan 和 Chris 之类的用户可以从他们的本地系统上传文件和目录。 + +### 步骤 3、编辑 sftp 配置文件 /etc/ssh/sshd_config + +正如我们已经陈述的,`sftp` 操作是通过 `ssh` 完成的,所以它的配置文件是 `/etc/ssh/sshd_config`,在做任何更改前,我建议首先备份文件,然后再编辑该文件,接下来添加下面的内容: + +``` +root@linuxtechi:~# cp /etc/ssh/sshd_config /etc/ssh/sshd_config-org +root@linuxtechi:~# vim /etc/ssh/sshd_config +...... +#Subsystem sftp /usr/lib/openssh/sftp-server +Subsystem sftp internal-sftp + +Match Group sftp_users + X11Forwarding no + AllowTcpForwarding no + ChrootDirectory %h + ForceCommand internal-sftp +...... +``` + +保存并退出文件。 + +为使上述更改生效,使用下面的 `systemctl` 命令来重新启动 `ssh` 服务: + +``` +root@linuxtechi:~# systemctl restart sshd +``` + +在上面的 `sshd_config` 文件中,我们已经注释掉了以 `Subsystem` 开头的行,并添加了新的条目 `Subsystem sftp internal-sftp` 和新的行。而 + +`Match Group sftp_users` –> 它意味着如果用户是 `sftp_users` 组中的一员,那么将应用下面提到的规则到这个条目。 + +`ChrootDierctory %h` –> 它意味着用户只能在他们自己各自的家目录中更改目录,而不能超出他们各自的家目录。或者换句话说,我们可以说用户是不允许更改目录的。他们将在他们的目录中获得监狱一样的环境,并且不能访问其他用户的目录和系统的目录。 + +`ForceCommand internal-sftp` –> 它意味着用户仅被限制到只能使用 `sftp` 命令。 + +### 步骤 4、测试和验证 sftp + +登录到你的 `sftp` 服务器的同一个网络上的任何其它的 Linux 系统,然后通过我们放入 `sftp_users` 组中的用户来尝试 ssh 和 sftp 服务。 + +``` +[root@linuxtechi ~]# ssh root@linuxtechi +root@linuxtechi's password: +Write failed: Broken pipe +[root@linuxtechi ~]# ssh root@linuxtechi +root@linuxtechi's password: +Write failed: Broken pipe +[root@linuxtechi ~]# +``` + +以上操作证实用户不允许 `ssh` ,现在使用下面的命令尝试 `sftp`: + +``` +[root@linuxtechi ~]# sftp root@linuxtechi +root@linuxtechi's password: +Connected to 192.168.56.151. +sftp> ls -l +drwxr-xr-x 2 root 1001 4096 Sep 14 07:52 debian10-pkgs +-rw-r--r-- 1 root 1001 155 Sep 14 07:52 devops-actions.txt +drwxr-xr-x 2 1001 1002 4096 Sep 14 08:29 upload +``` + +让我们使用 sftp 的 `get` 命令来尝试下载一个文件: + +``` +sftp> get devops-actions.txt +Fetching /devops-actions.txt to devops-actions.txt +/devops-actions.txt 100% 155 0.2KB/s 00:00 +sftp> +sftp> cd /etc +Couldn't stat remote file: No such file or directory +sftp> cd /root +Couldn't stat remote file: No such file or directory +sftp> +``` + +上面的输出证实我们能从我们的 sftp 服务器下载文件到本地机器,除此之外,我们也必须测试用户不能更改目录。 + +让我们在 `upload` 目录下尝试上传一个文件: + +``` +sftp> cd upload/ +sftp> put metricbeat-7.3.1-amd64.deb +Uploading metricbeat-7.3.1-amd64.deb to /upload/metricbeat-7.3.1-amd64.deb +metricbeat-7.3.1-amd64.deb 100% 38MB 38.4MB/s 00:01 +sftp> ls -l +-rw-r--r-- 1 1001 1002 40275654 Sep 14 09:18 metricbeat-7.3.1-amd64.deb +sftp> +``` + +这证实我们已经成功地从我们的本地系统上传一个文件到 sftp 服务中。 + +现在使用 winscp 工具来测试 sftp 服务,输入 sftp 服务器 IP 地址和用户的凭证: + +![][3] + +在 “Login” 上单击,然后尝试下载和上传文件: + +![][4] + +现在,在 `upload` 文件夹中尝试上传文件: + +![][5] + +上面的窗口证实上传是完好地工作的,这就是这篇文章的全部。如果这些步骤能帮助你在 Debian 10 中使用 chroot 环境配置 SFTP 服务器s,那么请分享你的反馈和评论。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/configure-sftp-chroot-debian10/ + +作者:[Pradeep Kumar][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://www.linuxtechi.com/author/pradeep/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Configure-sftp-debian10.jpg +[3]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Winscp-sftp-debian10.jpg +[4]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Download-file-winscp-debian10-sftp.jpg +[5]: https://www.linuxtechi.com/wp-content/uploads/2019/09/Upload-File-using-winscp-Debian10-sftp.jpg diff --git a/published/202005/20200222 How to install TT-RSS on a Raspberry Pi.md b/published/202005/20200222 How to install TT-RSS on a Raspberry Pi.md new file mode 100644 index 0000000000..e3f83399d4 --- /dev/null +++ b/published/202005/20200222 How to install TT-RSS on a Raspberry Pi.md @@ -0,0 +1,227 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12264-1.html) +[#]: subject: (How to install TT-RSS on a Raspberry Pi) +[#]: via: (https://opensource.com/article/20/2/ttrss-raspberry-pi) +[#]: author: (Patrick H. Mullins https://opensource.com/users/pmullins) + +怎样在树莓派上安装 TT-RSS +====== + +> 使用 Tiny Tiny RSS 来保护你阅读新闻馈送时的隐私。 + +![](https://img.linux.net.cn/data/attachment/album/202005/29/230337vmazkl65hh61l0qq.png) + +[Tiny Tiny RSS][2](TT-RSS)是一个自由开源的基于 Web 的新闻馈送feed(RSS/Atom)阅读器和聚合工具。它非常适合那些注重隐私,并且仍然依赖 RSS 来获取日常新闻的人。TT-RSS 是自行托管的软件,因此你可以 100% 的掌控你的服务器、数据以及你的全部隐私。它还支持大量的插件、扩展和主题。你喜欢黑暗模式的界面?没问题。想基于关键词过滤发来的消息?TT-RSS 也能让你得偿所愿。 + +![Tiny Tiny RSS screenshot][3] + +现在你知道 TT-RSS 是什么了,那么为什么你可能会想用它。我会讲述要把它安装到树莓派或 Debian 10 服务器上你需要了解的所有的东西。 + +### 安装和配置 TT-RSS + +要把 TT-RSS 安装到树莓派上,你还需要安装和配置最新版本的 PHP(本文撰写时 PHP 最新版本是 7.3)、后端数据库 PostgreSQL、Nginx web 服务器、Git,最后才是 TT-RSS。 + +#### 1、安装 PHP 7 + +安装 PHP 7 是整个过程中最复杂的部分。幸运的是,它并不像看起来那样困难。从安装下面的支持包开始: + +``` +$ sudo apt install -y ca-certificates apt-transport-https +``` + +现在,添加存储库 PGP 密钥: + +``` +$ wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add - +``` + +下一步,把 PHP 库添加到你的 apt 源: + +``` +$ echo "deb https://packages.sury.org/php/ buster main" | sudo tee /etc/apt/sources.list.d/php.list +``` + +然后更新你的存储库索引: + +``` +$ sudo apt update +``` + +最后,安装 PHP 7.3(或最新版本)和一些通用组件: + +``` +$ sudo apt install -y php7.3 php7.3-cli php7.3-fpm php7.3-opcache php7.3-curl php7.3-mbstring php7.3-pgsql php7.3-zip php7.3-xml php7.3-gd php7.3-intl +``` + +上面的命令默认你使用的后端数据库是 PostgreSQL,会安装 `php7.3-pgsql`。如果你想用 MySQL 或 MariaDB,你可以把命令参数改为 `php7.3-mysql`。 + +下一步,确认 PHP 已安装并在你的树莓派上运行着: + +``` +$ php -v +``` + +现在是时候安装和配置 Web 服务器了。 + +#### 2、安装 Nginx + +可以用下面的命令安装 Nginx: + +``` +$ sudo apt install -y nginx +``` + +修改默认的 Nginx 虚拟主机配置,这样 Web 服务器才能识别 PHP 文件以及知道如何处理它们。 + +``` +$ sudo nano /etc/nginx/sites-available/default +``` + +你可以安全地删除原文件中的所有内容,用下面的内容替换: + +``` +server { + listen 80 default_server; + listen [::]:80 default_server; + + root /var/www/html; + index index.html index.htm index.php; + server_name _; + + location / { + try_files $uri $uri/ =404; + } + + location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/run/php/php7.3-fpm.sock; + } + +} +``` + +按 `Ctrl+O` 保存修改后的配置文件,然后按 `Ctrl+X` 退出 Nano。你可以用下面的命令测试你的新配置文件: + + +``` +$ nginx -t +``` + +如果没有报错,重启 Nginx 服务: + +``` +$ systemctl restart nginx +``` + +#### 3、安装 PostgreSQL + +接下来是安装数据库服务器。在树莓派上安装 PostgreSQL 超级简单: + +``` +$ sudo apt install -y postgresql postgresql-client postgis +``` + +输入下面的命令看一下数据库服务器安装是否成功: + +``` +$ psql --version +``` + +#### 4、创建 Tiny Tiny RSS 数据库 + +在做其他事之前,你需要创建一个数数据库,用来给 TT-RSS 软件保存数据。首先,登录 PostgreSQL 服务器: + +``` +sudo -u postgres psql +``` + +下一步,新建一个用户,设置密码: + +``` +CREATE USER username WITH PASSWORD 'your_password' VALID UNTIL 'infinity'; +``` + +然后创建一个给 TT-RSS 用的数据库: + + +``` +CREATE DATABASE tinyrss; +``` + +最后,给新建的用户赋最高权限: + +``` +GRANT ALL PRIVILEGES ON DATABASE tinyrss to user_name; +``` + +这是安装数据库的步骤。你可以输入 `\q` 来退出 `psql` 程序。 + +#### 5、安装 Git + +安装 TT-RSS 需要用 Git,所以输入下面的命令安装 Git: + +``` +$ sudo apt install git -y +``` + +现在,进入到 Nginx 服务器的根目录: + +``` +$ cd /var/www/html +``` + +下载 TT-RSS 最新源码: + +``` +$ git clone https://git.tt-rss.org/fox/tt-rss.git tt-rss +``` + +注意,这一步会创建一个 `tt-rss` 文件夹。 + +#### 6、安装和配置Tiny Tiny RSS + +现在是安装和配置你的新 TT-RSS 服务器的最后时刻了。首先,确认下你在浏览器中能打开 `http://your.site/tt-rss/install/index.php`。如果浏览器显示 `403 Forbidden`,那么就证明 `/var/www/html` 文件夹的权限没有设置正确。下面的命令通常能解决这个问题: + +``` +$ chmod 755 /var/www/html/ -v +``` + +如果一切正常,你会看到 TT-RSS 安装页面,它会让你输入一些数据的信息。你只需要输入前面你创建的数据库用户名和密码;数据库名;主机名填 `localhost`;端口填 `5432`。 + +点击“Test Configuration”。如果一切正常,你会看到一个标记着“Initialize Database”的红色按钮。点击它来开始安装。结束后,你会看到一个配置文件,你可以把它复制到 TT-RSS 的目录,另存为 `config.php`。 + +安装过程结束后,浏览器输入 `http://yoursite/tt-rss/` 打开 TT-RSS,使用默认的凭证登录(用户名:`admin`,密码:`password`)。登录后系统会提示你修改密码。我强烈建议你尽快修改密码。 + +### 配置 TT-RSS + +如果一切正常,你现在就可以开始使用 TT-RSS 了。建议你新建一个非管理员用户,使用新用户名登录,并开始导入你的馈送、订阅,按照你的意愿来配置它。 + +最后,并且是超级重要的事,不要忘了阅读 TT-RSS 维基上的 [Updating Feeds][4] 部分。它讲述了如何创建一个简单的 systemd 服务来更新馈送。如果你跳过了这一步,你的 RSS 馈送就不会自动更新。 + +### 总结 + +呵!工作量不小,但是你做完了!你现在有自己的 RSS 聚合服务器了。想了解 TT-RSS 更多的知识?我推荐你去看官方的 [FAQ][5]、[支持][6]论坛,和详细的[安装][7]笔记。如果你有任何问题,尽情地在下面评论吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/2/ttrss-raspberry-pi + +作者:[Patrick H. Mullins][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/pmullins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life-raspberrypi_0.png?itok=Kczz87J2 (Raspberries with pi symbol overlay) +[2]: https://tt-rss.org/ +[3]: https://opensource.com/sites/default/files/uploads/tt-rss.jpeg (Tiny Tiny RSS screenshot) +[4]: https://tt-rss.org/wiki/UpdatingFeeds +[5]: https://tt-rss.org/wiki/FAQ +[6]: https://community.tt-rss.org/c/tiny-tiny-rss/support +[7]: https://tt-rss.org/wiki/InstallationNotes diff --git a/published/202005/20200317 Create Stunning Pixel Art With Free and Open Source Editor Pixelorama.md b/published/202005/20200317 Create Stunning Pixel Art With Free and Open Source Editor Pixelorama.md new file mode 100644 index 0000000000..7a267a672e --- /dev/null +++ b/published/202005/20200317 Create Stunning Pixel Art With Free and Open Source Editor Pixelorama.md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12173-1.html) +[#]: subject: (Create Stunning Pixel Art With Free and Open Source Editor Pixelorama) +[#]: via: (https://itsfoss.com/pixelorama/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +使用 Pixelorama 创建令人惊叹的像素艺术 +====== + +> Pixelorama 是一个跨平台、自由开源的 2D 精灵编辑器。它在一个整洁的用户界面中提供了创建像素艺术所有必要工具。 + +### Pixelorama:开源 Sprite 编辑器 + +[Pixelorama][1] 是 [Orama 互动][2]公司的年轻游戏开发人员创建的一个工具。他们已经开发了一些 2D 游戏,其中一些使用了像素艺术。 + +虽然 Orama 主要从事于游戏开发,但开发人员也创建实用工具,帮助他们(和其他人)创建这些游戏。 + +自由开源的精灵Sprite编辑器 Pixelorama 就是这样一个实用工具。它构建在 [Godot 引擎][3]之上,非常适合创作像素艺术。 + +![Pixelorama screenshot][4] + +你看到上面截图中的像素艺术了吗?它是使用 Pixelorama 创建的。这段视频展示了制作上述图片的时间推移视频。 + +### Pixelorama 的功能 + +以下是 Pixelorama 提供的主要功能: + + * 多种工具,如铅笔、橡皮擦、填充桶、取色器等 + * 多层系统,你可以根据需要添加、删除、上下移动、克隆和合并多个层 + * 支持 Spritesheets + * 导入图像并在 Pixelorama 中编辑它们 + * 带有 [Onion Skinning][5] 的动画时间线 + * 自定义画笔 + * 以 Pixelorama 的自定义文件格式 .pxo 保存并打开你的项目 + * 水平和垂直镜像绘图 + * 用于创建图样的磁贴模式 + * 拆分屏幕模式和迷你画布预览 + * 使用鼠标滚轮缩放 + * 无限次撤消和重做 + * 缩放、裁剪、翻转、旋转、颜色反转和去饱和图像 + * 键盘快捷键 + * 提供多种语言 + * 支持 Linux、Windows 和 macOS + +### 在 Linux 上安装 Pixelorama + +Pixelorama 提供 Snap 应用,如果你使用的是 Ubuntu,那么可以在软件中心找到它。 + +![Pixelorama is available in Ubuntu Software Center][6] + +或者,如果你在 [Linux 发行版上启用了 Snap 支持][7],那么可以使用此命令安装它: + +``` +sudo snap install pixelorama +``` + +如果你不想使用 Snap,不用担心。你可以从[他们的 GitHub 仓库][8]下载最新版本的 Pixelorama,[解压 zip 文件][9],你会看到一个可执行文件。授予此文件执行权限,并双击它运行应用。 + +- [下载 Pixelorama][10] + +### 总结 + +![Pixelorama Welcome Screen][11] + +在 Pixeloaram 的功能中,它说你可以导入图像并对其进行编辑。我想,这只是对某些类型的文件,因为当我尝试导入 PNG 或 JPEG 文件,程序崩溃了。 + +然而,我可以像一个 3 岁的孩子那样随意涂鸦并制作像素艺术。我对艺术不是很感兴趣,但我认为这[对 Linux 上的数字艺术家是个有用的工具][12]。 + +我喜欢这样的想法:尽管是游戏开发人员,但他们创建的工具,可以帮助其他游戏开发人员和艺术家。这就是开源的精神。 + +如果你喜欢这个项目,并且会使用它,请考虑通过捐赠来支持他们。[It’s FOSS 捐赠了][13] 25 美元,以感谢他们的努力。 + +- [向 Pixelorama 捐赠(主要开发者的个人 Paypal 账户)][14] + +你喜欢 Pixelorama 吗?你是否使用其他开源精灵编辑器?请随时在评论栏分享你的观点。 + +-------------------------------------------------------------------------------- +via: https://itsfoss.com/pixelorama/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.orama-interactive.com/pixelorama +[2]: https://www.orama-interactive.com/ +[3]: https://godotengine.org/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama-v6.jpg?ssl=1 +[5]: https://en.wikipedia.org/wiki/Onion_skinning +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama-ubuntu-software-center.jpg?ssl=1 +[7]: https://itsfoss.com/install-snap-linux/ +[8]: https://github.com/Orama-Interactive/Pixelorama +[9]: https://itsfoss.com/unzip-linux/ +[10]: https://github.com/Orama-Interactive/Pixelorama/releases +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/pixelorama.jpg?ssl=1 +[12]: https://itsfoss.com/best-linux-graphic-design-software/ +[13]: https://itsfoss.com/donations-foss/ +[14]: https://www.paypal.me/erevos diff --git a/published/202005/20200323 How to create a personal file server with SSH on Linux.md b/published/202005/20200323 How to create a personal file server with SSH on Linux.md new file mode 100644 index 0000000000..14abf4cc64 --- /dev/null +++ b/published/202005/20200323 How to create a personal file server with SSH on Linux.md @@ -0,0 +1,134 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12255-1.html) +[#]: subject: (How to create a personal file server with SSH on Linux) +[#]: via: (https://opensource.com/article/20/3/personal-file-server-ssh) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) + +怎样在 Linux 下用 SSH 搭建个人文件服务器 +====== + +> 通过 SSH 连接远程 Linux 系统很简单。下面是教程。 + +![](https://img.linux.net.cn/data/attachment/album/202005/27/120338v62cakrqnccpjckk.jpg) + +树莓派是一个有用且价格低廉的家庭服务器,可用于很多事情。我的树莓派最常用来做[打印服务器][2],可以在我的家庭网络中共享激光打印机,或作为个人文件服务器保存项目副本和其他数据。 + +我的文件服务器有很多用途。假设说我现在有一个项目,比如一本新书,我想把我的工作和所有相关的文件都复制一份快照。这种场景下,我只需要把 `BookProject` 文件夹复制到文件服务器的 `BookBackup` 文件夹。 + +或者我现在正在清理我的本地文件时,发现一些我不需要的文件,但是我不确定是否要删除,我会把它们复制到文件服务器的 `KeepForLater` 文件夹。这是我日常 Linux 系统中清除杂乱的文件,并将不常用的文件卸载到个人文件服务器上的方便方法。 + +用树莓派或其他 Linux 系统搭建个人文件服务器不需要配置 NFS(网络文件系统Network File System>)或 CIFS(通用互联网文件系统Common Internet File System)或改造其他的文件共享系统如 WebDAV。你可以很轻松的使用 SSH 来搭建远程文件服务器。下面是教程。 + +### 在远程服务器上配置 SSHD + +你的 Linux 系统可能已经安装了 SSH 守护进程(`sshd`),甚至它已经默认运行了。如果没有,你可以使用你 Linux 发行版本上的任何控制面板来轻松配置 SSH。我在树莓派上运行了 [Fedora ARM][3],通过 Web 浏览器访问树莓派的 9090 端口,我可以远程访问控制面板。(在我的家庭网络中,树莓派的 IP 地址是 `10.0.0.11`,因此我连接的是 `10.0.0.11:9090`。)如果 SSH 守护进程没有默认运行,你可以在控制面板的“服务”里把它设置为开机启动。 + +![sshd in the list of system services][4] + +你可以在系统服务列表里找到 `sshd`。 + +![slider to activate sshd][5] + +如果 `sshd` 没有开启,点击切换按钮打开它。 + +### 你有账号吗? + +你需要有个远程系统的账号。它可以与你本地系统的账号相同,也可以不同。 + +在流行的 Raspbian 发行版本上,默认的账号名是 `pi`。但是其他的 Linux 发行版本可能需要你在安装系统时就设置一个唯一的新用户。如果你不知道你的用户名,你可以用系统的控制面板创建一个。在我的树莓派上,我创建了一个 `jhall` 账号,与我日常用的 Linux 桌面机器的用户名相同。 + +![Set up a new account on Fedora Server][6] + +如果你用的是 Fedora 服务器,你可以点击“创建新账号”按钮。 + +![Set password or SSH key][7] + +不要忘记设置密码或添加公钥。 + +### 可选:添加公钥 + +如果你把公钥添加到远程 Linux 系统上,你就可以不使用密码登录。这一步是可选的;如果你愿意,你仍可以用密码登录。 + +你可以在下面的文章中学到更多关于 SSH 密钥的信息: + +* [SSH 密钥管理工具][8] +* [用 Seahorse 对 SSH 密钥进行图形化管理][9] +* [如何管理多个 SSH 密钥][10] +* [使用 GPG 密钥作为鉴权依据开启 SSH 访问][11] + +### 创建文件管理器的快捷方式 + +现在你已经在远程系统上启动 SSH 守护进程了,也设置了用户名和密码,最后一步就是在你本地的文件管理器中创建一个快捷方式,地址映射到远程 Linux 系统。我的桌面是 GNOME,但是在其他的 Linux 桌面上的基本操作步骤都是一样的。 + +#### 建立初始连接 + +在 GNOME 的文件管理器中,在左边导航栏找到 “+其它位置” 按钮。点击它会出现一个 “连接到服务器” 提示框。在框中输入远程 Linux 服务器的地址,地址以 SSH 连接协议开头。 + +![Creating a shortcut in GNOME file manager][12] + +GNOME 文件管理器支持多种连接协议。要通过 SSH 进行连接,服务器地址请以 `sftp://` 或 `ssh://` 开头。 + +如果你远程 Linux 系统的用户名与本地的相同,那么你只需要输入服务器的地址和文件夹路径就可以了。比如要连接到我的树莓派的 `/home/jhall` 目录,我输入: + +``` +sftp://10.0.0.11/home/jhall +``` + +![GNOME file manager Connect to Server][13] + +如果你远程 Linux 系统的用户名与本地的不同,你可以在远程系统地址前加 `@` 符号来指定远程系统的用户名。要连接到远程的 Raspbian 系统,你可能要输入: + +``` +sftp://pi@10.0.0.11/home/pi +``` + +![GNOME file manager Connect to Server][14] + +如果你没有把公钥添加到远程服务器,那么你需要输入密码。如果你已经添加,GNOME 文件管理器应该会自动打开远程系统上的文件夹来让你跳转到不同的目录。 + +![GNOME file manager connection][15] + +#### 创建一个快捷方式,之后就可以轻松连接服务器 + +在 GNOME 文件管理器中,这很简单。右击导航栏中远程系统的名字,选择“添加书签”。这一步操作就创建了连接到远程路径的快捷方式。 + +![GNOME file manager - adding bookmark][16] + +如果你想把标签中的快捷方式改成一个更容易记的名字,你可以右击快捷方式选择“重命名”。 + +### 总结 + +通过 SSH 连接到远程 Linux 系统是很简单的事。你可以用相同的方式连接到家庭文件服务器以外的其他系统。我还创建了一个能让我立即访问我的提供商 Web 服务器上的文件的快捷方式,和另一个能迅速打开我的项目服务器的文件夹的快捷方式。SSH 使它成为一个安全的连接;所有的传输都是加密的。当我通过 SSH 打开远程的文件时,我可以像在本地操作一样使用 GNOME 文件管理器轻松打开远程文件。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/personal-file-server-ssh + +作者:[Jim Hall][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/yearbook-haff-rx-linux-file-lead_0.png?itok=-i0NNfDC (Hand putting a Linux file folder into a drawer) +[2]: https://opensource.com/article/18/3/print-server-raspberry-pi +[3]: https://arm.fedoraproject.org/ +[4]: https://opensource.com/sites/default/files/uploads/fedora-server-control-panel-sshd.png (sshd in the list of system services) +[5]: https://opensource.com/sites/default/files/uploads/fedora-server-control-panel-sshd-service.png (slider to activate sshd) +[6]: https://opensource.com/sites/default/files/uploads/fedora-server-control-panel-accounts_create-user.png (Set up a new account on Fedora Server) +[7]: https://opensource.com/sites/default/files/uploads/fedora-server-control-panel-accounts.png (Set password or SSH key) +[8]: https://linux.cn/article-11947-1.html +[9]: https://linux.cn/article-9451-1.html +[10]: https://opensource.com/article/19/4/gpg-subkeys-ssh-manage +[11]: https://opensource.com/article/19/4/gpg-subkeys-ssh +[12]: https://opensource.com/sites/default/files/uploads/gnome-file-manager-other-locations.png (Creating a shortcut in GNOME file manager) +[13]: https://opensource.com/sites/default/files/uploads/gnome-file-manager-other-sftp.png (GNOME file manager Connect to Server) +[14]: https://opensource.com/sites/default/files/uploads/gnome-file-manager-other-sftp-username.png (GNOME file manager Connect to Server) +[15]: https://opensource.com/sites/default/files/uploads/gnome-file-manager-remote-jhall.png (GNOME file manager connection) +[16]: https://opensource.com/sites/default/files/uploads/gnome-file-manager-remote-jhall-add-bookmark.png (GNOME file manager - adding bookmark) diff --git a/published/202005/20200324 Audacious 4.0 Released With Qt 5- Here-s How to Install it on Ubuntu.md b/published/202005/20200324 Audacious 4.0 Released With Qt 5- Here-s How to Install it on Ubuntu.md new file mode 100644 index 0000000000..8b46842802 --- /dev/null +++ b/published/202005/20200324 Audacious 4.0 Released With Qt 5- Here-s How to Install it on Ubuntu.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12250-1.html) +[#]: subject: (Audacious 4.0 Released With Qt 5: Here’s How to Install it on Ubuntu) +[#]: via: (https://itsfoss.com/audacious-4-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +如何安装使用 Qt 5 的音频播放器 Audacious 4.0 +====== + +[Audacious][1] 是一个开源音频播放器,可用于包括 Linux 在内的多个平台。继上次发布主版本将近 2 年后,Audacious 4.0 带来了一些重大变化。 + +最新版本的 Audacious 4.0 默认带 [Qt 5][2] 用户界面。你仍然可以和以前一样使用旧的 GTK2 UI,但是,新功能仅会添加到 Qt UI 中。 + +让我们看下发生了什么变化,以及如何在 Linux 系统上安装最新的 Audacious。 + +### Audacious 4.0 关键变化和功能 + +![Audacious 4 Release][3] + +当然,主要的变化是默认使用 Qt 5 UI。除此之外,他们的[官方公告][4]中提到了许多改进和功能补充,它们是: + +* 单击播放列表列头可对播放列表进行排序 +* 拖动播放列表列头会更改列顺序 +* 应用中的音量和时间步长设置 +* 隐藏播放列表标签的新选项 +* 按路径对播放列表排序,现在将文件夹排序在文件后面 +* 实现了额外的 MPRIS 调用,以与 KDE 5.16+ 兼容 +* 新的基于 OpenMPT 的跟踪器模块插件 +* 新的 VU Meter 可视化插件 +* 添加了使用 SOCKS 网络代理的选项 +* 换歌插件现在可在 Windows 上使用 +* 新的“下一张专辑”和“上一张专辑”命令 +* Qt UI 中的标签编辑器现在可以一次编辑多个文件 +* 为 Qt UI 实现均衡器预设窗口 +* 歌词插件获得了在本地保存和加载歌词的能力 +* 模糊范围和频谱分析器可视化已移植到 Qt +* MIDI 插件 “SoundFont 选择”已移植到 Qt +* JACK 输出插件获得了一些新选项 +* 添加了无限循环 PSF 文件的选项 + +如果你以前不了解它,你可以轻松安装它,并使用均衡器和 [LADSP][5] 效果器来调整音乐体验。 + +![Audacious Winamp Classic Interface][6] + +### 如何在 Ubuntu 上安装 Audacious 4.0 + +值得注意的是,[非官方 PPA][7] 是由 [UbuntuHandbook][8] 提供的。你可以按照以下说明在 Ubuntu 16.04、18.04、19.10 和 20.04 上进行安装。 + +1、首先,你必须在终端中输入以下命令将 PPA 添加到系统中: + +``` +sudo add-apt-repository ppa:ubuntuhandbook1/apps +``` + +2、接下来,你需要从仓库中更新(刷新)软件包信息,然后继续安装该应用。方法如下: + +``` +sudo apt update +sudo apt install audacious audacious-plugins +``` + +就是这样。你无需执行其他任何操作。无论什么情况,如果你想[删除 PPA 和软件][9],只需按顺序输入以下命令: + +``` +sudo add-apt-repository --remove ppa:ubuntuhandbook1/apps +sudo apt remove --autoremove audacious audacious-plugins +``` + +你也可以在它的 GitHub 页面上查看有关源码的更多信息,并根据需要在其他 Linux 发行版上进行安装。 + +- [Audacious 源代码][10] + +### 总结 + +新功能和 Qt 5 UI 开关对于改善用户体验和音频播放器的功能应该是一件好事。如果你是经典 Winamp 界面的粉丝,它也可以正常工作。但缺少其公告中提到的一些功能。 + +你可以尝试一下,并在下面的评论中让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/audacious-4-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://audacious-media-player.org +[2]: https://doc.qt.io/qt-5/qt5-intro.html +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/audacious-4-release.jpg?ssl=1 +[4]: https://audacious-media-player.org/news/45-audacious-4-0-released +[5]: https://www.ladspa.org/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/audacious-winamp.jpg?ssl=1 +[7]: https://itsfoss.com/ppa-guide/ +[8]: http://ubuntuhandbook.org/index.php/2020/03/audacious-4-0-released-qt5-ui/ +[9]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ +[10]: https://github.com/audacious-media-player/audacious diff --git a/published/202005/20200326 Tricks for getting around your Linux file system.md b/published/202005/20200326 Tricks for getting around your Linux file system.md new file mode 100644 index 0000000000..d9d6cf1006 --- /dev/null +++ b/published/202005/20200326 Tricks for getting around your Linux file system.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12239-1.html) +[#]: subject: (Tricks for getting around your Linux file system) +[#]: via: (https://www.networkworld.com/article/3533421/tricks-for-getting-around-your-linux-file-system.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 文件系统中导航的技巧 +====== + +> cd 命令可能是任何 Linux 用户学习的前 10 个命令之一,但这并不是在 Linux 文件系统中导航的唯一方法,这里还有其他一些方法。 + +![](https://img.linux.net.cn/data/attachment/album/202005/22/114058yrzlx94rz9lbx974.jpg) + +无论你是在文件系统中四处查看、寻找文件还是尝试进入重要目录,Linux 都可以提供很多帮助。在本文中,我们将介绍一些技巧,使你可以在文件系统中移动,查找和使用所需的命令也更加轻松。 + +### 添加到 \$PATH + +确保你不必花费大量时间在 Linux 系统上查找命令的最简单、最有用的方法之一就是在 `$PATH` 变量中添加适当的目录。但是,添加到 `$PATH` 变量中的目录顺序非常重要。它们确定系统在目录中查找要运行命令的目录顺序--在找到第一个匹配项时停止。 + +例如,你可能希望将家目录放在第一个,这样,如果你创建的脚本与其他可执行文件有相同的名称,那么只要输入该脚本的名称,它便会运行。 + +要将家目录添加到 `$PATH` 变量中,可以执行以下操作: + +``` +$ export PATH=~:$PATH +``` + +`~` 字符代表家目录。 + +如果将脚本保存在 `bin` 目录中,下面的会有效: + +``` +$ export PATH=~/bin:$PATH +``` + +然后,你可以运行位于家目录中的脚本,如下所示: + +``` +$ myscript +Good morning, you just ran /home/myacct/bin/myscript +``` + +**重要提示:**上面显示的命令会添加到你的搜索路径中,因为 `$PATH`(当前路径)被包含在内。它们不会覆盖它。你的搜索路径应该在你的 `.bashrc` 文件中配置,任何你打算永久化的更改也应该添加到那里。 + +### 使用符号链接 + +符号链接提供了一种简单而明显的方式来记录可能经常需要使用的目录的位置。例如,如果你管理网站的内容,那么可能需要通过创建如下链接来使你的帐户“记住”网页文件的位置: + +``` +ln -s /var/www/html www +``` + +参数的顺序很重要。第一个(`/var/www/html`)是目标,第二个是你创建的链接的名称。如果你当前不在家目录中,那么以下命令将执行相同的操作: + +``` +ln -s /var/www/html ~/www +``` + +设置好之后,你可以使用 `cd www` 进入 `/var/www/html`。 + +### 使用 shopt + +`shopt` 命令还提供了一种让移动到其他目录更加容易的方法。当你使用 `shopt` 的 `autocd` 选项时,只需输入名称即可转到目录。例如: + +``` +$ shopt -s autocd +$ www +cd -- www +/home/myacct/www +$ pwd -P +/var/www/html + +$ ~/bin +cd -- /home/myacct/bin +$ pwd +/home/myacct/bin +``` + +在上面的第一组命令中,启用了 `shopt` 命令的 `autocd` 选项。输入 `www`,就会调用 `cd www` 命令。由于此符号链接是在上面的 `ln` 命令示例之一中创建的,因此将我们移至 `/var/www/html`。 `pwd -P` 命令显示实际位置。 + +在第二组中,键入 `~/bin` 会调用 `cd` 进入在用户家目录的 `bin` 目录。 + +请注意,当你输入的是命令时,`autocd` 行为将*不会*生效,即使它也是目录的名称。 + +`shopt` 是 bash 内置命令,它有很多选项。这只是意味着你不必在要进入每个目录的名称之前输入 `cd`。 + +要查看 `shopt` 的其他选项,只需输入 `shopt`。 + +### 使用 \$CDPATH + +可能进入特定目录的最有用技巧之一,就是将你希望能够轻松进入的路径添加到 `$CDPATH` 中。这将创建一个目录列表,只需输入完整路径名的一部分即可进入。 + +一方面,这可能有点棘手。你的 `$CDPATH` 需要包含要移动到的目录的父目录,而不是目录本身。 + +例如,假设你希望仅通过输入 `cd html` 就可以移至 `/var/www/html` 目录,并仅使用 `cd` 和简单目录名即可移至 `/var/log` 中的子目录。在这种情况下,此 `$CDPATH` 就可以起作用: + +``` +$ CDPATH=.:/var/log:/var/www +``` + +你将看到: + +``` +$ cd journal +/var/log/journal +$ cd html +/var/www/html +``` + +当你输入的不是完整路径时,`$CDPATH` 就会生效。它向下查看其目录列表,以查看指定的目录是否存在于其中一个目录中。找到匹配项后,它将带你到那里。 + +在 `$CDPATH` 开头保持 `.` 意味着你可以进入本地目录,而不必在 `$CDPATH` 中定义它们。 + +``` +$ export CDPATH=".:$CDPATH" +$ Videos +cd -- Videos +/home/myacct/Videos +``` + +在 Linux 文件系统键切换并不难,但是如果你使用一些方便的技巧轻松地到达各个位置,那你可以节省一些大脑细胞。 + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3533421/tricks-for-getting-around-your-linux-file-system.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[2]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202005/20200331 Rambox is an All-in-one Messenger for Linux.md b/published/202005/20200331 Rambox is an All-in-one Messenger for Linux.md new file mode 100644 index 0000000000..93a73f4a54 --- /dev/null +++ b/published/202005/20200331 Rambox is an All-in-one Messenger for Linux.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12171-1.html) +[#]: subject: (Rambox is an All-in-one Messenger for Linux) +[#]: via: (https://itsfoss.com/rambox/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Rambox:Linux 中多合一的消息收发工具 +====== + +> Rambox 是一个多合一消息收发工具,允许你将多种服务(如 Discord、Slack、Facebook Messenger)和数百个此类服务结合在一起。 + +### Rambox:在单个应用中添加多个消息服务 + +![][1] + +Rambox 是通过安装单个应用管理多个通信服务的最佳方式之一。你可以在一个界面使用[多个消息服务][2],如 Facebook Messenger、Gmail chats、AOL、Discord、Google Duo、[Viber][3] 等。 + +这样,你就不需要安装单独的应用或者在浏览器中一直打开着。你可以使用主密码锁定 Rambox 应用。你还可以使用“请勿打扰”功能。 + +Rambox 提供可免费使用的[开源社区版][4]。付费专业版允许你访问 600 多个应用,而社区版则包含 99 多个应用。专业版本具有额外的功能,如主题、休眠、ad-block、拼写检查和高级支持。 + +不用担心。开源社区版本身非常有用,你甚至不需要这些专业功能。 + +### Rambox 的功能 + +![][5] + +虽然你应该在开源版中找到大多数基本功能,但你可能会注意到其中一些功能仅限于专业版。 + +此处,我说下所有的基本功能: + + * 在开源版本中,你有大约 100 个应用/服务可供选择 + * 能够使用单个主密码锁保护应用 + * 能够锁定加载的每个会话 + * 请勿打扰模式 + * 能够跨多个设备同步应用和配置 + * 你可以创建和添加自定义应用 + * 支持键盘快捷键 + * 启用/禁用应用而无需删除它们 + * JS 和 CSS 注入支持,以调整应用的样式 + * Ad-block (**专业版**) + * 休眠支持 (**专业版**) + * 主题支持(**专业版**) + * 移动设备视图 (**专业版**) + * 拼写检查 (**专业版**) + * 工作时间 - 计划传入通知的时间 (**专业版**) + * 支持代理 (**专业版**) + +除了我在这里列出的内容外,你还可以在 Rambox Pro 版本中找到更多功能。要了解有关它的更多信息,你可以参考[正式功能列表][6]。 + +还值得注意的是,你不能超过 3 个活跃并发设备的连接。 + +### 在 Linux 上安装 Rambox + +你可以在[官方下载页][4]获取 .AppImage 文件来运行 Rambox。如果你不清楚,你可以参考我们的指南,了解如何[在 Linux 上使用 AppImage 文件][7]。 + +另外,你也可以从 [Snap 商店][8]获取它。此外,请查看其 [GitHub release][9] 部分的 .deb / .rpm 或其他包。 + +- [下载 Rambox 社区版][4] + +### 总结 + +使用 Rambox 安装大量应用可能会有点让人不知所措。因此,我建议你在添加更多应用并将其用于工作时监视内存使用情况。 + +还有一个类似的应用称为 [Franz][10],它也像 Rambox 部分开源、部分高级版。 + +尽管像 Rambox 或 Franz 这样的解决方案非常有用,但它们并不总是节约资源,特别是如果你同时使用数十个服务。因此,请留意系统资源(如果你注意到对性能的影响)。 + +除此之外,这是一个令人印象深刻的应用。你有试过了么?欢迎随时让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/rambox/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/rambox-ce.jpg?ssl=1 +[2]: https://itsfoss.com/best-messaging-apps-linux/ +[3]: https://itsfoss.com/viber-linux-client-beta-install/ +[4]: https://rambox.pro/#ce +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/rambox-preferences.png?ssl=1 +[6]: https://rambox.pro/#features +[7]: https://itsfoss.com/use-appimage-linux/ +[8]: https://snapcraft.io/rambox +[9]: https://github.com/ramboxapp/community-edition/releases +[10]: https://itsfoss.com/franz-messaging-app/ diff --git a/published/202005/20200401 3 Python templating languages you should (probably) never use.md b/published/202005/20200401 3 Python templating languages you should (probably) never use.md new file mode 100644 index 0000000000..a5a7502767 --- /dev/null +++ b/published/202005/20200401 3 Python templating languages you should (probably) never use.md @@ -0,0 +1,177 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12252-1.html) +[#]: subject: (3 Python templating languages you should (probably) never use) +[#]: via: (https://opensource.com/article/20/4/python-templating-languages) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +你应该(或许)没使用过的 3 种 Python 模板语言 +====== + +> 包括这 3 个模板语言在内,Python 积累了许多模板语言。 + +![](https://img.linux.net.cn/data/attachment/album/202005/26/110220lxie9osmd592m5ee.jpg) + +当需要使用模板语言来编写 [Python][2] Web 应用时,有很多健壮的解决方案。 + +有 [Jinja2][3]、[Genshi 和 Mako][4]。甚至还有 [Chameleon][5] 之类的解决方案,虽然有些陈旧,但仍被 [Pyramid][6] 框架推荐。 + +Python 已经存在了很长时间。此时,在系统的深处,它积累了一些几乎被遗忘的模板语言,它们都是值得一试的。 + +这些语言就像桉树上可爱的考拉一样,在自己的生态圈里快乐地生活着,有时也会有危险的工作,这些都是很少有人听说过的模板语言,使用过的应该更少。 + +### 3、string.Template + +你是否曾经想过:“如何获得一种没有任何特性的模板语言,而且同时也不需要 `pip install` 安装任何东西?” Python 标准库已经为你提供了答案。虽然没有循环和条件,但 `string.Template` 类是一种最小的模板语言。 + +使用它很简单。 + +``` +>>> import string +>>> greeting = string.Template("Hello, $name, good $time!") +>>> greeting.substitute(name="OpenSource.com", time="afternoon") +'Hello, OpenSource.com, good afternoon!' +``` + +### 2、twisted.web.template + +你会给一个包罗万象的库送什么礼物? + +当然,不是模板语言,因为它已经有了。twisted.web.template 中嵌套了两种模板语言。一种是基于 XML 的,并有一个[很棒的文档][7]。 + +但是它还有另一种,一种基于使用 Python 作为领域特定语言(DSL)来生成 HTML 文档。 + +它基于两个原语:包含标签对象的 `twisted.web.template.tags` 和渲染它们的 `twisted.web.template.flattenString`。由于它是 Twisted 的一部分,因此它内置支持高效异步渲染。 + +此例将渲染一个小页面: + +``` +async def render(reactor): + my_title = "A Fun page" + things = ["one", "two", "red", "blue"] + template = tags.html( + tags.head( + tags.title(my_title), + ), + tags.body( + tags.h1(my_title), + tags.ul( + [tags.li(thing) for thing in things], + ), + tags.p( + task.deferLater(reactor, 3, lambda: "Hello "), + task.deferLater(reactor, 3, lambda: "world!"), + ) + ) + ) + res = await flattenString(None, template) + res = res.decode('utf-8') + with open("hello.html", 'w') as fpout: + fpout.write(res) +``` + +该模板是使用 `tags.` 来指示层次结构的常规 Python 代码。原生支持渲染字符串,因此任何字符串都正常。 + +要渲染它,你需要做的是添加调用: + +``` +from twisted.internet import task, defer +from twisted.web.template import tags, flattenString + +def main(reactor): +    return defer.ensureDeferred(render(reactor)) +``` + +最后写上: + + +``` +task.react(main) +``` + +只需 3 秒(而不是 6 秒),它将渲染一个不错的 HTML 页面。在实际中,这些 `deferLater` 可以是对 HTTP API 的调用:它们将并行发送和处理,而无需付出任何努力。我建议你阅读关于[更好地使用 Twisted][8]。不过,这已经可以工作了。 + +### 1、Quixote + +你会说:“但是 Python 并不是针对 HTML 领域而优化的领域特定语言。” 如果有一种语言可以[转化][9]到 Python,但是更适合定义模板,而不是像 Python 那样按原样解决呢?如果可以的话,请使用“Python 模板语言”(PTL)。 + +编写自己的语言,有时被说成是一个攻击假想敌人的唐吉坷德项目。当 Quixote(可在 [PyPI][10] 中找到)的创造者决定这样做时,并没有受此影响。 + +以下将渲染与上面 Twisted 相同的模板。*警告:以下不是有效的 Python 代码*: + +``` +import time + +def render [html] (): + my_title = "A Fun page" + things = ["one", "two", "red", "blue"] + "" + my_title + "</head>

" + my_title + "

" + "
    " + for thing in things: + "
  • " + thing + "
  • " + "

    " + time.sleep(3) + (lambda: "Hello ")() + time.sleep(3) + (lambda: "world!")() + "

    " + "" + +def write(): + result = render() + with open("hello.html", 'w') as fpout: + fpout.write(str(result)) +``` + +但是,如果将它放到 `template.ptl` 文件中,那么可以将其导入到 Quixote 中,并写出可以渲染模板的版本: + + +``` +>>> from quixote import enable_ptl +>>> enable_ptl() +>>> import template +>>> template.write() +``` + +Quixote 安装了一个导入钩子,它会将 PTL 文件转换为 Python。请注意,此渲染需要 6 秒,而不是 3 秒。你不再获得自由的异步性。 + +### Python 中的模板太多 + +Python 库的历史悠久且曲折,其中一些库可以或多或少都能达到类似结果(例如,Python [包管理][11])。 + +我希望你喜欢探索这三种*可以*用 Python 创建模板的方式。另外,我建议从[这三个库之一][4]开始了解。 + +你是否有另一种深奥的模板方法?请在下面的评论中分享! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/python-templating-languages + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[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://opensource.com/resources/python +[3]: https://opensource.com/article/20/2/jinja2-cheat-sheet +[4]: https://opensource.com/resources/python/template-libraries +[5]: https://chameleon.readthedocs.io/en/latest/ +[6]: https://opensource.com/article/18/5/pyramid-framework +[7]: https://twistedmatrix.com/documents/13.1.0/web/howto/twisted-templates.html +[8]: https://opensource.com/article/20/3/treq-python +[9]: https://en.wikipedia.org/wiki/Source-to-source_compiler +[10]: https://pypi.org/project/Quixote/ +[11]: https://opensource.com/article/19/4/managing-python-packages diff --git a/published/202005/20200401 The ins and outs of high-performance computing as a service.md b/published/202005/20200401 The ins and outs of high-performance computing as a service.md new file mode 100644 index 0000000000..ef96b09ffe --- /dev/null +++ b/published/202005/20200401 The ins and outs of high-performance computing as a service.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (messon007) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12202-1.html) +[#]: subject: (The ins and outs of high-performance computing as a service) +[#]: via: (https://www.networkworld.com/article/3534725/the-ins-and-outs-of-high-performance-computing-as-a-service.html) +[#]: author: (Josh Fruhlinger https://www.networkworld.com/author/Josh-Fruhlinger/) + +超算即服务:超级计算机如何上云 +====== + +> 高性能计算(HPC)服务可能是一种满足不断增长的超级计算需求的方式,但依赖于使用场景,它们不一定比使用本地超级计算机好。 + +![](https://img.linux.net.cn/data/attachment/album/202005/09/223805mrjfjzecr3hceais.jpg) + +导弹和军用直升机上的电子设备需要工作在极端条件下。美国国防承包商麦考密克·史蒂文森公司McCormick Stevenson Corp.在部署任何物理设备之前都会事先模拟它所能承受的真实条件。模拟依赖于像 Ansys 这样的有限元素分析软件,该软件需要强大的算力。 + +几年前的一天,它出乎意料地超出了计算极限。 + +麦考密克·史蒂文森公司的首席工程师 Mike Krawczyk 说:“我们的一些工作会使办公室的计算机不堪重负。购买机器并安装软件在经济上或计划上都不划算。”相反,他们与 Rescale 签约,该公司销售其超级计算机系统上的处理能力,而这只花费了他们购买新硬件上所需的一小部分。 + +麦考密克·史蒂文森公司已成为被称为超级计算即服务或高性能计算即服务(两个紧密相关的术语)市场的早期采用者之一。根据国家计算科学研究所的定义,HPC 是超级计算机在计算复杂问题上的应用,而超级计算机是处理能力最先进的那些计算机。 + +无论叫它什么,这些服务都在颠覆传统的超级计算市场,并将 HPC 能力带给以前负担不起的客户。但这不是万能的,而且绝对不是即插即用的,至少现在还不是。 + +### HPC 服务实践 + +从最终用户的角度来看,HPC 即服务类似于早期大型机时代的批处理模型。 “我们创建一个 Ansys 批处理文件并将其发送过去,运行它,然后将结果文件取下来,然后导入到本地,” Krawczyk 说。 + +在 HPC 服务背后,云提供商在其自己的数据中心中运行超级计算基础设施,尽管这不一定意味着当你听到“超级计算机”时你就会看到最先进的硬件。正如 IBM OpenPOWER 计算技术副总裁 Dave Turek 解释的那样,HPC 服务的核心是“相互互连的服务器集合。你可以调用该虚拟计算基础设施,它能够在你提出问题时,使得许多不同的服务器并行工作来解决问题。” + +理论听起来很简单。但都柏林城市大学数字商业教授 Theo Lynn 表示,要使其在实践中可行,需要解决一些技术问题。普通计算与 HPC 的区别在于那些互联互通 —— 高速的、低延时的而且昂贵的 —— 因此需要将这些互连引入云基础设施领域。在 HPC 服务可行之前,至少需要将存储性能和数据传输也提升到与本地 HPC 相同的水平。 + +但是 Lynn 说,一些制度创新相比技术更好的帮助了 HPC 服务的起飞。特别是,“我们现在看到越来越多的传统 HPC 应用采用云友好的许可模式 —— 这在过去是阻碍采用的障碍。” + +他说,经济也改变了潜在的客户群。“云服务提供商通过向那些负担不起传统 HPC 所需的投资成本的低端 HPC 买家开放,进一步开放了市场。随着市场的开放,超大规模经济模型变得越来越多,更可行,成本开始下降。” + +### 避免本地资本支出 + +HPC 服务对传统超级计算长期以来一直占据主导地位的私营部门客户具有吸引力。这些客户包括严重依赖复杂数学模型的行业,包括麦考密克·史蒂文森公司等国防承包商,以及石油和天然气公司、金融服务公司和生物技术公司。都柏林城市大学的 Lynn 补充说,松耦合的工作负载是一个特别好的用例,这意味着许多早期采用者将其用于 3D 图像渲染和相关应用。 + +但是,何时考虑 HPC 服务而不是本地 HPC 才有意义?对于德国的模拟烟雾在建筑物中的蔓延和火灾对建筑物结构部件的破坏的 hhpberlin 公司来说,答案是在它超出了其现有资源时。 + +Hpberlin 公司数值模拟的科学负责人 Susanne Kilian 说:“几年来,我们一直在运行自己的小型集群,该集群具有多达 80 个处理器核。……但是,随着应用复杂性的提高,这种架构已经越来越不足以支撑;可用容量并不总是够快速地处理项目。” + +她说:“但是,仅仅花钱买一个新的集群并不是一个理想的解决方案:鉴于我们公司的规模和管理环境,不断地维护这个集群(定期进行软件和硬件升级)是不现实的。另外,需要模拟的项目数量会出现很大的波动,因此集群的利用率并不是真正可预测的。通常,使用率很高的阶段与很少使用或不使用的阶段交替出现。”通过转换为 HPC 服务模式,hhpberlin 释放了过剩的产能,并无需支付升级费用。 + +IBM 的 Turek 解释了不同公司在评估其需求时所经历的计算过程。对于拥有 30 名员工的生物科学初创公司来说,“你需要计算,但你真的不可能让 15% 的员工专门负责计算。这就像你可能也会说你不希望有专职的法律代表,所以你也会把它作为一项服务来做。”不过,对于一家较大的公司而言,最终归结为权衡 HPC 服务的运营费用与购买内部超级计算机或 HPC 集群的费用。 + +到目前为止,这些都是你采用任何云服务时都会遇到的类似的争论。但是,可以 HPC 市场的某些特殊性将使得衡量运营支出(OPEX)与资本支出(CAPEX)时选择前者。超级计算机不是诸如存储或 x86 服务器之类的商用硬件;它们非常昂贵,技术进步很快会使其过时。正如麦考密克·史蒂文森公司的 Krawczyk 所说,“这就像买车:只要车一开走,它就会开始贬值。”对于许多公司,尤其是规模较大,灵活性较差的公司,购买超级计算机的过程可能会陷入无望的泥潭。IBM 的 Turek 说:“你会被规划问题、建筑问题、施工问题、培训问题所困扰,然后必须执行 RFP。你必须得到 CIO 的支持。你必须与内部客户合作以确保服务的连续性。这是一个非常、非常复杂的过程,并没有很多机构有非常出色的执行力。” + +一旦你选择走 HPC 服务的路线,你会发现你会得到你期望从云服务中得到的许多好处,特别是仅在业务需要时才需付费的能力,从而可以带来资源的高效利用。Gartner 高级总监兼分析师 Chirag Dekate 表示,当你对高性能计算有短期需求时,突发性负载是推动选择 HPC 服务的关键用例。 + +他说:“在制造业中,在产品设计阶段前后,HPC 活动往往会达到很高的峰值。但是,一旦产品设计完成,在其余产品开发周期中,HPC 资源的利用率就会降低。” 相比之下,他说:“当你拥有大型的、长期运行的工作时,云计算的经济性才会逐渐减弱。” + +通过巧妙的系统设计,你可以将这些 HPC 服务突发活动与你自己的内部常规计算集成在一起。埃森哲Accenture实验室常务董事 Teresa Tung 举了一个例子:“通过 API 访问 HPC 可以与传统计算无缝融合。在模型构建阶段,传统的 AI 流水线可能会在高端超级计算机上进行训练,但是最终经过反复按预期运行的训练好的模型将部署在云端的其他服务上,甚至部署在边缘设备上。” + +### 它并不适合所有的应用场景 + +HPC 服务适合批处理和松耦合的场景。这与一个常见的 HPC 缺点有关:数据传输问题。高性能计算本身通常涉及庞大的数据集,而将所有这些信息通过互联网发送到云服务提供商并不容易。IBM 的 Turek 说:“我们与生物技术行业的客户交流,他们每月仅在数据费用上就花费 1000 万美元。” + +而钱并不是唯一的潜在问题。构建一个利用数据的工作流程,可能会对你的工作流程提出挑战,让你绕过数据传输所需的漫长时间。hhpberlin 的 Kilian 说:“当我们拥有自己的 HPC 集群时,当然可以随时访问已经产生的仿真结果,从而进行交互式的临时评估。我们目前正努力达到在仿真的任意时刻都可以更高效地、交互地访问和评估云端生成的数据,而无需下载大量的模拟数据。” + +Mike Krawczyk 提到了另一个绊脚石:合规性问题。国防承包商使用的任何服务都需要遵从《国际武器交易条例》(ITAR),麦考密克·史蒂文森公司之所以选择 Rescale,部分原因是因为这是他们发现的唯一符合的供应商。如今,尽管有更多的公司使用云服务,但任何希望使用云服务的公司都应该意识到使用其他人的基础设施时所涉及的法律和数据保护问题,而且许多 HPC 场景的敏感性使得 HPC 即服务的这个问题更加突出。 + +此外,HPC 服务所需的 IT 治理超出了目前的监管范围。例如,你需要跟踪你的软件许可证是否允许云使用­ —— 尤其是专门为本地 HPC 群集上运行而编写的软件包。通常,你需要跟踪 HPC 服务的使用方式,它可能是一个诱人的资源,尤其是当你从员工习惯的内部系统过渡到有可用的空闲的 HPC 能力时。例如,Avanade 全球平台高级主管兼 Azure 平台服务全球负责人 Ron Gilpin 建议,将你使用的处理核心的数量回拨给那些对时间不敏感的任务。他说:“如果一项工作只需要用一小时来完成而不需要在十分钟内就完成,那么它可以使用 165 个处理器而不是 1,000 个,从而节省了数千美元。” + +### 对 HPC 技能的要求很高 + +一直以来,采用 HPC 的最大障碍之一就是其所需的独特的内部技能,而 HPC 服务并不能神奇使这种障碍消失。Gartner 的 Dekate 表示:“许多 CIO 将许多工作负载迁移到了云上,他们看到了成本的节约、敏捷性和效率的提升,因此相信在 HPC 生态中也可以达成类似的效果。一个普遍的误解是,他们可以通过彻底地免去系统管理员,并聘用能解决其 HPC 工作负载的新的云专家,从而以某种方式优化人力成本。”对于 HPC 即服务来说更是如此。 + +“但是 HPC 并不是一个主流的企业环境。” 他说。“你正在处理通过高带宽、低延迟的网络互联的高端计算节点,以及相当复杂的应用和中间件技术栈。许多情况下,甚至连文件系统层也是 HPC 环境所独有的。没有对应的技能可能会破坏稳定性。” + +但是超级计算技能的供给却在减少,Dekate 将其称为劳动力“老龄化”,这是因为这一代开发人员将目光投向了新兴的初创公司,而不是学术界或使用 HPC 的更老套的公司。因此,HPC 服务供应商正在尽其所能地弥补差距。IBM 的 Turek 表示,许多 HPC 老手将总是想运行他们自己精心调整过的代码,并需要专门的调试器和其他工具来帮助他们在云端实现这一目标。但是,即使是 HPC 新手也可以调用供应商构建的代码库,以利用超级计算的并行处理能力。第三方软件提供商出售的交钥匙软件包可以减少 HPC 的许多复杂性。 + +埃森哲的 Tung 表示,该行业需要进一步加大投入才能真正繁荣。她说:“HPCaaS 已经创建了具有重大影响力的新功能,但还需要做的是使它易于被数据科学家、企业架构师或软件开发人员使用。这包括易用的 API、文档和示例代码。它包括解答问题的用户支持。仅仅提供 API 是不够的,API 需要适合特定的用途。对于数据科学家而言,这可能是以 Python 形式提供,并容易更换她已经在使用的框架。价值来自于使这些用户能够通过新的效率和性能最终使他们的工作得到改善,只要他们能够访问新的功能就可以了。” 如果供应商能够做到这一点,那么 HPC 服务才能真正将超级计算带给大众。 + + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3534725/the-ins-and-outs-of-high-performance-computing-as-a-service.html + +作者:[Josh Fruhlinger][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Josh-Fruhlinger/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3236875/embargo-10-of-the-worlds-fastest-supercomputers.html +[2]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202005/20200404 Best Raspberry Pi Operating Systems for Various Purposes.md b/published/202005/20200404 Best Raspberry Pi Operating Systems for Various Purposes.md new file mode 100644 index 0000000000..25ebd65fcd --- /dev/null +++ b/published/202005/20200404 Best Raspberry Pi Operating Systems for Various Purposes.md @@ -0,0 +1,353 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12219-1.html) +[#]: subject: (Best Raspberry Pi Operating Systems for Various Purposes) +[#]: via: (https://itsfoss.com/raspberry-pi-os/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +用于各种用途的最佳树莓派操作系统 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/15/105040b17d6v7gdmj63k3k.jpg) + +[树莓派][1] 是一款不可缺少的单板电脑,在很多工作中都能派上用场。不相信?只要[看看这个树莓派项目列表][2],就能了解这个小小的设备能做什么。 + +考虑到树莓派用途这么多,为它选择一个合适的操作系统就极其重要。当然,你可以用 Linux 做很多事,但专门为特定目的配置的操作系统可以为你节省大量的时间和精力。 + +因此,本文中我要介绍一些专门为树莓派量身定制的流行且实用的操作系统。 + +### 由于有树莓派镜像工具,安装任何操作系统到树莓派上都很容易 + +[在 SD 卡上安装树莓派操作系统][3]比以前容易得多。你只需下载[树莓派镜像][4]就可以快速地安装任何树莓派操作系统。请看下面的官方视频,你就知道有多简单。 + +- [HOW TO INSTALL RASPBIAN OS to your Raspberry Pi with ease - Raspberry Pi Imager](https://youtu.be/J024soVgEeM) + +你也可以使用 [NOOBS][5](新开箱即用软件New Out Of the Box Software)在树莓派上轻松安装各种的操作系统。你还可以从他们的 [NOOBS 官方下载页面][5]提到的支持的零售商列表中获得预装 SD 卡。 + +欢迎在他们的[官方文档][6]中了解更多关于安装操作系统的信息。 + +- [下载树莓派操作系统][4] + +现在你知道了怎么安装它(以及从哪儿获取),让我来重点介绍几个有用的树莓派操作系统,希望对你有所帮助。 + +### 适用于树莓派的各种操作系统 + +请注意,我花了一些精力筛选出了那些被积极维护的树莓派操作系统项目。如果某个项目在不久的将来会停止维护,请在评论区告诉我,我会更新本文。 + +另一件事是,我关注到现在最新的版本是树莓派 4,但是下面的列表不应被认为是树莓派 4 的操作系统列表,这些系统应该也能用于树莓派 3、3B+ 和其他变种,但是请参照项目的官方网站了解详细信息。 + +**注意:** 排名不分先后。 + +#### 1、Raspbian OS:官方的树莓派操作系统 + +![][7] + +Raspbian OS 是官方支持的树莓派板卡操作系统。它集成了很多工具,用于教育、编程以及其他广泛的用途。具体来说,它包含了 Python、Scratch、Sonic Pi、Java 和其他一些重要的包。 + +最初,Raspbian OS 是基于 Debian 的,并预装了大量有用的包。因此,当你安装 Raspbian OS 后,你可能就不需要特意安装基本工具了 — 你会发现大部分工具已经提前安装好了。 + +Raspbian OS 是被积极地维护着的,它也是最流行的树莓派操作系统之一。你可以使用 [NOOBS][5] 或参照[官方文档][6]来安装它。 + +- [Raspbian OS][8] + +#### 2、Ubuntu MATE:适合通用计算需求 + +![][9] + +尽管 Raspbian 是官方支持的操作系统,但它的特点不是最新、最大的软件包。因此,如果你想更快的更新,想用最新的包,你可以试试 Ubuntu MATE 的树莓派版本。 + +Ubuntu MATE 的树莓派定制版是值得安装的非常不错的轻量级发行版。它还被广泛用于 [NVIDIA 的 Jetson Nano][10]。换言之,你可以在树莓派的很多场景下使用它。 + +为了更好地帮助你,我们还有一份详细的教程:[怎样在树莓派上安装 Ubuntu MATE][11]。 + +- [Ubuntu MATE for Raspberry Pi][12] + +#### 3、Ubuntu Server:把树莓派作为一台 Linux 服务器来使用 + +![][13] + +如果你计划把你的树莓派当作项目的某个服务器来使用,那么安装 Ubuntu Server 会是一个不错的选择。 + +Ubuntu Server 有 32 位和 64 位的镜像。你可以根据你的板卡类型(是否支持 64 位)来选择对应的操作系统。 + +然而,值得注意的一点是 Ubuntu Server 不是为桌面用户定制的。因此,你需要留意 Ubuntu Server 默认不会安装图形用户界面。 + +- [Ubuntu Server][14] + +#### 4、LibreELEC:适合做媒体服务器 + +![][15] + +我们已经有一个 [Linux 下可用的媒体服务器软件][16],LibreELEC 在列表中。 + +它是一个很棒的轻量级操作系统,让你可以在树莓派上安装 [KODI][17]。你可以尝试使用树莓派镜像工具来安装它。 + +你可以很容易地找到他们的[官方下载页面][18],并找到适合你板卡的安装镜像。 + +- [LibreELEC][19] + +#### 5、OSMC:适合做媒体服务器 + +![][20] + +OSMC 是另一个 Linux 下[流行的媒体服务器软件][16]。如果要把树莓派板作为媒体中心设备,那么 OSMC 是你可以向他人推荐的操作系统之一。 + +类似 LibreELEC,OSMC 也运行 KODI,可以帮助你管理你的媒体文件和欣赏你已有的素材。 + +OSMC 没有正式提及对树莓派 4 的支持。因此,如果你的树莓派是树莓派 3 或更早的版本,那么应该没有问题。 + +- [OSMC][21] + +#### 6、RISC OS:最初的 ARM 操作系统 + +![][22] + +RISC OS 最初是为 ARM 设备打造的,至今已有近 30 年左右的历史。 + +如果你想了解,我们也有篇详细介绍 [RISC OS][23] 的文章。简而言之,RISC OS 也是为诸如树莓派的现代基于 ARM 的单板计算机定制的。它的用户界面很简单,更专注于性能。 + +同样的,这并不是为树莓派 4 量身定做的。因此,如果你的树莓派是 3 或更早的版本,你可以试一下。 + +- [RISC OS][24] + +#### 7、Mozilla WebThings Gateway:适合 IoT 项目 + +![][25] + +作为 Mozilla 的 [IoT 设备的开源实现][26]的一部分,WebThings Gateway 让你可以监控和控制所有连接的 IoT 设备。 + +你可以参考[官方文档][27]来检查所需的环境,遵照指导把安装到树莓派上。它确实是适合 IoT 应用的最有用的树莓派操作系统之一。 + +- [WebThings Gateway][28] + +#### 8、Ubuntu Core:适合 IoT 项目 + +Ubuntu Core 是又一个树莓派操作系统,适用于潜在的 [IoT][29] 应用,或者只是测试一下 Snap。 + +Ubuntu Core 是专门为 IoT 设备或者具体来说是树莓派定制的。我不会刻意宣传它 —— 但是 Ubuntu Core 是一款适合树莓派板卡的安全操作系统。你可以自己尝试一下! + +- [Ubuntu Core][30] + +#### 9、DietPi:轻量级树莓派操作系统 + +![][31] + +DietPi 是一款轻量级的 [Debian][32] 操作系统,它还宣称比 “Raspbian Lite” 操作系统更轻量。 + +虽然它被视作一款轻量级的树莓派操作系统,但它提供了很多功能,可以在多个使用场景中派上用场。从简单的软件安装包到备份解决方案,还有很多功能值得探索。 + +如果你想安装一个低内存占用而性能相对更好的操作系统,你可以尝试一下 DietPi。 + +- [DietPi][33] + +#### 10、Lakka Linux:打造复古的游戏主机 + +![][34] + +想让你的树莓派变成一个复古的游戏主机? + +Lakka Linux 发行版本最初是建立在 RetroArch 模拟器上的。因此,你可以立刻在树莓派上获得所有的复古游戏。 + +如果你想了解,我们也有一篇介绍 [Lakka Linux][35] 的文章。或者直接上手吧! + +- [Lakka][36] + +#### 11、RetroPie:适合复古游戏 + +![][37] + +RetroPie 是另一款可以让树莓派变成复古游戏主机的树莓派操作系统。它提供了几个配置工具,让你可以自定义主题,或者调整模拟器即可拥有最好的复古游戏。 + +值得注意的是它不包含任何有版权的游戏。你可以试一下,看看它是怎么工作的! + +- [RetroPie][38] + +#### 12、Kali Linux:适合低成本渗透 + +![][39] + +想要在你的树莓派上尝试和学习一些道德黑客技巧吗?[Kali Linux][64] 会是最佳选择。是的,Kali Linux 通常在最新的树莓派一发布就会支持它。 + +Kali Linux 不仅适合树莓派,它也支持很多其他设备。尝试一下,玩得愉快! + +- [Kali Linux][40] + +#### 13、OpenMediaVault:适合网络附加存储(NAS) + +![][41] + +如果你想在极简的硬件上搭建 [NAS][42] 解决方案,树莓派可以帮助你。 + +OpenMediaVault 最初是基于 Debian Linux 的,提供了大量功能,如基于 Web 的管理能力、插件支持,等等。它支持大多数树莓派型号,因此你可以尝试下载并安装它! + +- [OpenMediaVault][43] + +#### 14、ROKOS:适合加密挖矿 + +![][44] + +如果你对加密货币和比特币很感兴趣,那么 ROKOS 会吸引你。 + +ROKOS 是基于 Debian 的操作系统,基本上可以让你把你的树莓派变成一个节点,同时预装了相应的驱动程序和软件包。当然,在安装之前你需要了解它是怎么工作的。因此,如果你对此不太了解,我建议你先调研下。 + +- [ROKOS][45] + +#### 15、Alpine Linux:专注于安全的轻量级 Linux + +当今年代,很多用户都在寻找专注于安全和[隐私的发行版本][46]。如果你也是其中一员,你可以试试在树莓派上安装 Alpine Linux。 + +如果你是个树莓派新手,它可能不像你想象的那样对用户友好(或者说对初学者来说容易上手)。但是,如果你想尝试一些不一样的东西,那么你可以试试 Alpine Linux 这个专注于安全的 Linux 发行版本。 + +- [Alpine Linux][47] + +#### 16、Kano OS:适合儿童教育的操作系统 + +![][48] + +如果你在寻找一款能让学习变得有趣还能教育儿童的树莓派操作系统,那么 Kano OS 是个不错的选择。 + +它正在积极维护中,而且 Kano OS 上的桌面集成的用户体验相当简单,玩起来也很有趣,可以让孩子们从中学习。 + +- [Kano OS][49] + +#### 17、KDE Plasma Bigscreen:把普通电视转换为智能电视 + +![][50] + +这是 KDE 一个正在开发中的项目。在树莓派上安装 [KDE “等离子大屏”][51] 后,你可以把普通电视变成智能电视。 + +你不需要特殊的遥控器来控制电视,你可以使用普通的遥控器。 + +“等离子大屏”也集成了 [MyCroft 开源 AI][52] 作为声控。 + +这个项目还在测试阶段,所以如果你想尝试,可能会有一些错误和问题。 + +- [Plasma Bigscreen][53] + +#### 18、Manjaro Linux:为你提供多功能的桌面体验 + +![][54] + +如果你想在树莓派上寻找一个基于 Arch 的 Linux 发行版,那么 Manjaro Linux 应该是一个很好的补充,它可以做很多事情,适合一般的计算任务。 + +Manjaro Linux ARM 版也支持最新的树莓派 4。它为你的树莓派或任何[树莓派替代品][55]提供了 XFCE 和 KDE Plasma 变体。 + +此外,它似乎还提供了树莓派设备上最快/最好的体验之一。如果你还没试过,那就试试吧! + +- [Manjaro ARM][56] + +#### 19、Volumio:作为一个开源音乐播放器使用 + +![][57] + +想做一个廉价的音乐发烧友系统?Volumio 应该可以帮到你。 + +它是一个自由而开源的操作系统([GitHub][58]),还支持集成多个设备的能力。你可以通过一个简单的 Web 控制界面,对所有连接的设备进行管理。除了免费版之外,它还提供了一个高级版,可以让你获得独家功能。 + +它也确实支持最新的树莓派 4。所以,如果你对调整已有的家庭立体声系统有一定的兴趣,想要获得最佳的音质,不妨试试这个。 + +- [Volumio][59] + +#### 20、FreeBSD + +不想使用 Linux 发行版?不用担心,你也可以用 FreeBSD 在树莓派上安装一个类 UNIX 操作系统。 + +如果你不知道的话,我们有一篇关于 [FreeBSD 项目][60]的详细文章。 + +一旦你按照他们的[官方说明][61]安装好之后,你可以利用它来进行任何 DIY 实验,或者只是把它作为一个轻量级的桌面系统来完成特定的任务。 + +- [FreeBSD][62] + +#### 21、NetBSD + +NetBSD 是另一个令人印象深刻的类 UNIX 操作系统,你可以在树莓派上安装。它的目标是成为一个跨多个系统的便携式操作系统。 + +如果你在其他系统中使用过它,你可能已经知道它的好处了。然而,它不仅仅是一个轻量级的便携式操作系统,它的特点是拥有一套有用的功能,可以完成各种任务。 + +- [NetBSD][63] + +### 结语 + +我相信还有很多为树莓派定制的操作系统 — 但是我尽力列出了被积极维护的最流行的或最有用的操作系统。 + +如果你觉得我遗漏了最合适树莓派的操作系统,尽情在下面的评论去告诉我吧! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/raspberry-pi-os/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[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://www.raspberrypi.org/ +[2]: https://itsfoss.com/raspberry-pi-projects/ +[3]: https://linux.cn/article-12136-1.html +[4]: https://www.raspberrypi.org/downloads/ +[5]: https://www.raspberrypi.org/downloads/noobs/ +[6]: https://www.raspberrypi.org/documentation/installation/installing-images/README.md +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/raspbian_home_screen.jpg?resize=800%2C492&ssl=1 +[8]: https://www.raspbian.org/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/04/Desktop-ubuntu.jpg?resize=800%2C600&ssl=1 +[10]: https://www.nvidia.com/en-us/autonomous-machines/embedded-systems/jetson-nano/ +[11]: https://linux.cn/article-10817-1.html +[12]: https://ubuntu-mate.org/raspberry-pi/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/ubunt-server.png?ssl=1 +[14]: https://ubuntu.com/download/raspberry-pi +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/libreelec.jpg?resize=800%2C600&ssl=1 +[16]: https://itsfoss.com/best-linux-media-server/ +[17]: https://kodi.tv/ +[18]: https://libreelec.tv/downloads_new/ +[19]: https://libreelec.tv/ +[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/osmc-server.jpg?resize=800%2C450&ssl=1 +[21]: https://osmc.tv/ +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/10/riscos5.1.jpg?resize=800%2C600&ssl=1 +[23]: https://itsfoss.com/risc-os-is-now-open-source/ +[24]: https://www.riscosopen.org/content/ +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/web-things-gateway.png?ssl=1 +[26]: https://iot.mozilla.org/about/ +[27]: https://iot.mozilla.org/docs/gateway-getting-started-guide.html +[28]: https://iot.mozilla.org/gateway/ +[29]: https://en.wikipedia.org/wiki/Internet_of_things +[30]: https://ubuntu.com/download/raspberry-pi-core +[31]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/diet-pi.jpg?ssl=1 +[32]: https://www.debian.org/ +[33]: https://dietpi.com/ +[34]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2016/08/lakkaos.jpg?resize=1024%2C640&ssl=1 +[35]: https://linux.cn/article-10158-1.html +[36]: http://www.lakka.tv/ +[37]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/retro-pie.png?ssl=1 +[38]: https://retropie.org.uk/ +[39]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/kali-linux-pi.png?ssl=1 +[40]: https://www.offensive-security.com/kali-linux-arm-images/ +[41]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/openmediavault.jpg?ssl=1 +[42]: https://en.wikipedia.org/wiki/Network-attached_storage +[43]: https://www.openmediavault.org/ +[44]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/03/rocos-bitcoin-pi.jpg?ssl=1 +[45]: https://rokos.space/ +[46]: https://itsfoss.com/privacy-focused-linux-distributions/ +[47]: https://alpinelinux.org/ +[48]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/03/kano-os-pi.jpeg?ssl=1 +[49]: https://kano.me/row/downloadable +[50]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/plasma-bigscreen-menu.jpg?ssl=1 +[51]: https://itsfoss.com/kde-plasma-bigscreen/ +[52]: https://itsfoss.com/mycroft-mark-2/ +[53]: https://plasma-bigscreen.org/#download-jumpto +[54]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/manjaro-arm.jpg?w=800&ssl=1 +[55]: https://linux.cn/article-10823-1.html +[56]: https://manjaro.org/download/#raspberry-pi-4 +[57]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/volumio.jpg?w=800&ssl=1 +[58]: https://github.com/volumio +[59]: https://volumio.org/ +[60]: https://itsfoss.com/freebsd-interview-deb-goodkin/ +[61]: https://www.freebsdfoundation.org/freebsd/how-to-guides/installing-freebsd-for-raspberry-pi/ +[62]: https://www.freebsd.org/ +[63]: https://www.netbsd.org/ +[64]: https://linux.cn/article-10690-1.html diff --git a/published/202005/20200407 How to avoid man-in-the-middle cyber attacks.md b/published/202005/20200407 How to avoid man-in-the-middle cyber attacks.md new file mode 100644 index 0000000000..8ae4bb8a6d --- /dev/null +++ b/published/202005/20200407 How to avoid man-in-the-middle cyber attacks.md @@ -0,0 +1,80 @@ +[#]: collector: "lujun9972" +[#]: translator: "tinyeyeser" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12191-1.html" +[#]: subject: "How to avoid man-in-the-middle cyber attacks" +[#]: via: "https://opensource.com/article/20/4/mitm-attacks" +[#]: author: "Jackie Lam https://opensource.com/users/beenverified" + +如何避免中间人攻击(MITM) +====== + +> 首先搞明白到底什么是中间人攻击(MITM),才能避免成为此类高科技窃听的受害者。 + +![](https://img.linux.net.cn/data/attachment/album/202005/07/100655i7og1eqsw6o3ww81.jpg) + +当你使用电脑发送数据或与某人在线通话的时候,你一定采取了某种程度的安全隐私手段。 + +但如果有第三方在你不知情的情况下窃听,甚至冒充某个你信任的商业伙伴窃取破坏性的信息呢?你的私人数据就这样被放在了危险分子的手中。 + +这就是臭名昭著的中间人攻击man-in-the-middle(MITM)。 + +### 到底什么是中间人攻击? + +黑客潜入到你与受害者或是某个设备间的通信过程中,窃取敏感信息(多数是身份信息)进而从事各种违法行为的过程,就是一次中间人攻击。Scamicide 公司创始人 Steve J. J. Weisman 介绍说: + +> “中间人攻击也可以发生在受害者与某个合法 app 或网页中间。当受害者以为自己面对的是正常 app 或网页时,其实 Ta 正在与一个仿冒的 app 或网页互动,将自己的敏感信息透露给了不法分子。” + +中间人攻击诞生于 1980 年代,是最古老的网络攻击形式之一。但它却更为常见。Weisman 解释道,发生中间人攻击的场景有很多种: + + * **攻陷一个未有效加密的 WiFi 路由器**:该场景多见于人们使用公共 WiFi 的时候。“虽然家用路由器也很脆弱,但黑客攻击公共 WiFi 网络的情况更为常见。”Weisman 说,“黑客的目标就是从毫无戒心的人们那里窃取在线银行账户这样的敏感信息。” + * **攻陷银行、金融顾问等机构的电子邮件账户**:“一旦黑客攻陷了这些电子邮件系统,他们就会冒充银行或此类公司给受害者发邮件”,Weisman 说,”他们以紧急情况的名义索要个人信息,诸如用户名和密码。受害者很容易被诱骗交出这些信息。” + * **发送钓鱼邮件**:窃贼们还可能冒充成与受害者有合作关系的公司,向其索要个人信息。“在多个案例中,钓鱼邮件会引导受害者访问一个伪造的网页,这个伪造的网页看起来就和受害者常常访问的合法公司网页一模一样。”Weisman 说道。 + * **在合法网页中嵌入恶意代码**:攻击者还会把恶意代码(通常是 JavaScript)嵌入到一个合法的网页中。“当受害者加载这个合法网页时,恶意代码首先按兵不动,直到用户输入账户登录或是信用卡信息时,恶意代码就会复制这些信息并将其发送至攻击者的服务器。”网络安全专家 Nicholas McBride 介绍说。 + +### 有哪些中间人攻击的著名案例? + +联想作为主流的计算机制造厂商,在 2014 到 2015 年售卖的消费级笔记本电脑中预装了一款叫做 VisualDiscovery 的软件,拦截用户的网页浏览行为。当用户的鼠标在某个产品页面经过时,这款软件就会弹出一个来自合作伙伴的类似产品的广告。 + +这起中间人攻击事件的关键在于:VisualDiscovery 拥有访问用户所有私人数据的权限,包括身份证号、金融交易信息、医疗信息、登录名和密码等等。所有这些访问行为都是在用户不知情和未获得授权的情况下进行的。联邦交易委员会(FTC)认定此次事件为欺诈与不公平竞争。2019 年,联想同意为此支付 8300 万美元的集体诉讼罚款。 + +### 我如何才能避免遭受中间人攻击? + + * **避免使用公共 WiFi**:Weisman 建议,从来都不要使用公开的 WiFi 进行金融交易,除非你安装了可靠的 VPN 客户端并连接至可信任的 VPN 服务器。通过 VPN 连接,你的通信是加密的,信息也就不会失窃。 + * **时刻注意:**对要求你更新密码或是提供用户名等私人信息的邮件或文本消息要时刻保持警惕。这些手段很可能被用来窃取你的身份信息。 + + 如果不确定收到的邮件来自于确切哪一方,你可以使用诸如电话反查或是邮件反查等工具。通过电话反查,你可以找出未知发件人的更多身份信息。通过邮件反查,你可以尝试确定谁给你发来了这条消息。 + + 通常来讲,如果发现某些方面确实有问题,你可以听从公司中某个你认识或是信任的人的意见。或者,你也可以去你的银行、学校或其他某个组织,当面寻求他们的帮助。总之,重要的账户信息绝对不要透露给不认识的“技术人员”。 + + * **不要点击邮件中的链接**:如果有人给你发了一封邮件,说你需要登录某个账户,不要点击邮件中的链接。相反,要通过平常习惯的方式自行去访问,并留意是否有告警信息。如果在账户设置中没有看到告警信息,给客服打电话的时候也*不要*联系邮件中留的电话,而是联系站点页面中的联系人信息。 + * **安装可靠的安全软件**:如果你使用的是 Windows 操作系统,安装开源的杀毒软件,如 [ClamAV][2]。如果使用的是其他平台,要保持你的软件安装有最新的安全补丁。 + * **认真对待告警信息**:如果你正在访问的页面以 HTTPS 开头,浏览器可能会出现一则告警信息。例如,站点证书的域名与你尝试访问的站点域名不相匹配。千万不要忽视此类告警信息。听从告警建议,迅速关掉页面。确认域名没有输入错误的情况下,如果情况依旧,要立刻联系站点所有者。 + * **使用广告屏蔽软件**:弹窗广告(也叫广告软件攻击)可被用于窃取个人信息,因此你还可以使用广告屏蔽类软件。对个人用户来说,中间人攻击其实是很难防范的,因为它被设计出来的时候,就是为了让受害者始终蒙在鼓里,意识不到任何异常。有一款不错的开源广告屏蔽软件叫 [uBlock origin][4]。可以同时支持 Firefox 和 Chromium(以及所有基于 Chromium 的浏览器,例如 Chrome、Brave、Vivaldi、Edge 等),甚至还支持 Safari。 + +### 保持警惕 + +要时刻记住,你并不需要立刻就点击某些链接,你也并不需要听从某个陌生人的建议,无论这些信息看起来有多么紧急。互联网始终都在。你大可以先离开电脑,去证实一下这些人的真实身份,看看这些“无比紧急”的页面到底是真是假。 + +尽管任何人都可能遭遇中间人攻击,只要弄明白何为中间人攻击,理解中间人攻击如何发生,并采取有效的防范措施,就可以保护自己避免成为其受害者。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/mitm-attacks + +作者:[Jackie Lam][a] +选题:[lujun9972][b] +译者:[tinyeyeser](https://github.com/tinyeyeser) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/beenverified +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security_password_chaos_engineer_monster.png?itok=J31aRccu "Security monster" +[2]: https://www.clamav.net +[3]: https://opensource.com/article/20/1/stop-typosquatting-attacks +[4]: https://github.com/gorhill/uBlock +[5]: https://www.beenverified.com/crime/what-is-a-man-in-the-middle-attack/ +[6]: https://creativecommons.org/licenses/by-sa/2.0/ diff --git a/published/202005/20200407 How to use pyenv to run multiple versions of Python on a Mac.md b/published/202005/20200407 How to use pyenv to run multiple versions of Python on a Mac.md new file mode 100644 index 0000000000..3bcf991e02 --- /dev/null +++ b/published/202005/20200407 How to use pyenv to run multiple versions of Python on a Mac.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12241-1.html) +[#]: subject: (How to use pyenv to run multiple versions of Python on a Mac) +[#]: via: (https://opensource.com/article/20/4/pyenv) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) + +如何在 Mac 上使用 pyenv 运行多个版本的 Python +====== + +> 如果你在 macOS 上运行的项目需要没有安装的 Python 版本,请试试 pyenv。 + +![](https://img.linux.net.cn/data/attachment/album/202005/23/112041pawp65alw6tmea6l.jpg) + +即使对于有经验的开发人员,管理本地 Python 开发环境仍然是一个挑战。尽管有详细的[软件包管理策略][2],但仍需要采取另外的步骤来确保你在需要时运行所需的 Python 版本。 + +### 为什么 Python 版本重要? + +起初这是一个奇怪的概念,但是编程语言会像其他任何软件一样发生变化。它们有错误、修复和更新,就像你喜欢的 [API][3] 和任何其他软件一样。同样,不同的发行版由称为[语义化版本][4]的三位数标识。 + +> 😭😭😭 [pic.twitter.com/yt1Z2439W8][5] +> +> — Denny Perez (@dennyperez18) [May 28, 2019][6] + +多年来,Python 2 是该语言的常用主要版本。在 2020 年 1 月,Python 2 [到达最后寿命][7],此后,Python 的核心维护者将仅支持 Python 3。Python 3 稳步发展,并定期发布新更新。对我来说定期获取这些更新很重要。 + +最近,我试图在 macOS 上运行一个依赖于 Python 3.5.9 的项目,而我的系统上并没有安装这个版本。我认为 Python 包管理器 `pip` 可以安装它,但事实并非如此: + +``` +$ pip install python3.5.9 +Collecting python3.5.9 +  ERROR: Could not find a version that satisfies the requirement python3.5.9 (from versions: none) +ERROR: No matching distribution found for python3.5.9 +``` + +或者,我也可以从官方 Python 网站下载该版本,但我如何在我的 Mac 上与现有的 Python 版本一起运行?每次运行时指定 Python 解释器版本(例如 python3.7 或 python3.5)似乎很容易出错。一定会有更好的方法。 + +(说明:我知道这对经验丰富的 Python 开发人员没有意义,但对当时的我来说是有意义的。我很乐意谈一谈为什么我仍然认为它应该这样做。) + +### 安装和设置 pyenv + +值得庆幸的是,`pyenv` 可以绕开这一系列复杂的问题。首先,我需要安装 `pyenv`。我可以[从源码][8]克隆并编译它,但是我更喜欢通过 Homebrew 包管理器来管理软件包: + +``` +$ brew install pyenv +``` + +为了通过 `pyenv` 使用 Python 版本,必须了解 shell 的 `PATH` 变量。`PATH` 决定了 shell 通过命令的名称来搜索文件的位置。你必须确保 shell 程序能够找到通过 `pyenv` 运行的 Python 版本,而不是默认安装的版本(通常称为*系统版本*)。如果不更改路径,那么结果如下: + +``` +$ which python +/usr/bin/python +``` + +这是 Python 的系统版本。 + +要正确设置 `pyenv`,可以在 Bash 或 zsh 中运行以下命令: + +``` +$ PATH=$(pyenv root)/shims:$PATH +``` + +现在,如果你检查 Python 的版本,你会看到它是 `pyenv` 管理的版本: + +``` +$ which python +/Users/my_username/.pyenv/shims/python +``` + +该导出语句(`PATH=`)仅会对该 shell 实例进行更改,为了使更改永久生效,你需要将它添加到点文件当中。由于 zsh 是 macOS 的默认 shell,因此我将重点介绍它。将相同的语法添加到 `~/.zshrc` 文件中: + +``` +$ echo 'PATH=$(pyenv root)/shims:$PATH' >> ~/.zshrc +``` + +现在,每次我们在 zsh 中运行命令时,它将使用 `pyenv` 版本的 Python。请注意,我在 `echo` 中使用了单引号,因此它不会评估和扩展命令。 + +`.zshrc` 文件仅管理 zsh 实例,因此请确保检查你的 shell 程序并编辑关联的点文件。如果需要再次检查默认 shell 程序,可以运行 `echo $SHELL`。如果是 zsh,请使用上面的命令。如果你使用 Bash,请将 `~/.zshrc` 更改为 `~/.bashrc`。如果你想了解更多信息,可以在 `pyenv` 的 `README` 中深入研究[路径设置][9]。 + +### 使用 pyenv 管理 Python 版本 + +现在 `pyenv` 已经可用,我们可以看到它只有系统 Python 可用: + +``` +$ pyenv versions +system +``` + +如上所述,你绝对不想使用此版本([阅读更多有关信息][10])。现在 `pyenv` 已正确设置,我希望它能有我经常使用的几个不同版本的 Python。 + +有一种方法可以通过运行 `pyenv install --list` 来查看 pyenv 可以访问的所有仓库中的所有 Python 版本。这是一个很长的列表,将来回顾的时候可能会有所帮助。目前,我决定在 [Python 下载页面][11]找到的每个最新的“点版本”(3.5.x 或 3.6.x,其中 x 是最新的)。因此,我将安装 3.5.9 和 3.8.0: + +``` +$ pyenv install 3.5.9 +$ pyenv install 3.8.0 +``` + +这将需要一段时间,因此休息一会(或阅读上面的链接之一)。有趣的是,输出中显示了该版本的 Python 的下载和构建。例如,输出显示文件直接来自 [Python.org][12]。 + +安装完成后,你可以设置默认值。我喜欢最新的,因此将全局默认 Python 版本设置为最新版本: + +``` +$ pyenv global 3.8.0 +``` + +该版本立即在我的 shell 中设置完成。确认一下: + +``` +$ python -V +Python 3.8.0 +``` + +我要运行的项目仅适于 Python 3.5,因此我将在本地设置该版本并确认: + +``` +$ pyenv local 3.5.9 +$ python -V +Python 3.5.9 +``` + +因为我在 `pyenv` 中使用了 `local` 选项,所以它向当前目录添加了一个文件来跟踪该信息。 + +``` +$ cat .python-version +3.5.9 +``` + +现在,我终于可以为想要的项目设置虚拟环境,并确保运行正确版本的 Python。 + +``` +$ python -m venv venv +$ source ./venv/bin/activate +(venv) $ which python +/Users/mbbroberg/Develop/my_project/venv/bin/python +``` + +要了解更多信息,请查看有关[在 Mac 上管理虚拟环境][13]的教程。 + +### 总结 + +默认情况下,运行多个 Python 版本可能是一个挑战。我发现 `pyenv` 可以确保在我需要时可以有我需要的 Python 版本。 + +你还有其他初学者或中级 Python 问题吗? 请发表评论,我们将在以后的文章中考虑介绍它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/pyenv + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://opensource.com/article/19/4/managing-python-packages +[3]: https://opensource.com/article/19/5/api-evolution-right-way +[4]: https://semver.org/ +[5]: https://t.co/yt1Z2439W8 +[6]: https://twitter.com/dennyperez18/status/1133505310516232203?ref_src=twsrc%5Etfw +[7]: https://opensource.com/article/19/11/end-of-life-python-2 +[8]: https://github.com/pyenv/pyenv +[9]: https://github.com/pyenv/pyenv#understanding-path +[10]: https://opensource.com/article/19/5/python-3-default-mac +[11]: https://www.python.org/downloads/ +[12]: http://python.org +[13]: https://linux.cn/article-11086-1.html diff --git a/published/202005/20200408 My Linux Story- From 8-bit enthusiast to Unix sysadmin.md b/published/202005/20200408 My Linux Story- From 8-bit enthusiast to Unix sysadmin.md new file mode 100644 index 0000000000..60ab428ad3 --- /dev/null +++ b/published/202005/20200408 My Linux Story- From 8-bit enthusiast to Unix sysadmin.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (Acceleratorrrr) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12228-1.html) +[#]: subject: (My Linux Story: From 8-bit enthusiast to Unix sysadmin) +[#]: via: (https://opensource.com/article/20/4/linux-story) +[#]: author: (James Farrell https://opensource.com/users/jamesf) + +我的 Linux 故事:从 8 位发烧友到 Unix 系统管理员 +====== + +> 我是如何从一个电脑爱好者成为职业系统管理员和 Linux 粉丝的。 + +![](https://img.linux.net.cn/data/attachment/album/202005/18/132731pnnzy7t5tz7hvc6z.jpg) + +故事得从 1980 年中期我父母给家里购买[苹果 \]\[c][2] 开始。尽管很喜欢打游戏,但我还是很快被实用又好玩的 BASIC 编程迷住了。那个年代的人们还是把电脑当作小一点的打字机对待,所以拥有“高级电脑技能”的人可以轻松使用他们的魔法。 + +以用 BASIC 和点阵打印机自动生成惩罚作业来举个例子。被罚写两百遍道歉时,我问老师我可不可以用打字代替手写。经过同意后,我写了 5 行 BASIC 语句来自动生成作业。另外一个小技巧是用非可视化文本编辑器,比如用 AppleWorks 微调字体、行距和边距,把学期论文“拉长”到要求的篇幅。 + +对电脑的痴迷很快让我得到了带有内存驱动卡和 x86 协处理器的苹果 ][gs。那时候,调制解调器和 BBS 刚开始火起来,有了这样的双处理器系统后,我就可以安装各种琳琅满目的软件。但是由于调制解调器 2400bps 的速度限制,对我每天都要下载几 KB 的有趣东西形成了阻碍。我对苹果痴迷一段时间,不久之后就换了。 + +### 探索 Unix + +我的本科专业是计算机信息系统,研究生专业是计算机科学。本科教育主要使用个人电脑,很少涉及大型分时系统。研究生的时候才开始真正有意思起来,拨号进入带有互联网连接的 Unix 简直打开了新世界的大门。尽管我依然用着我的双处理器 ][gs 来使用调制解调器还有写写论文,不过 Unix 系统真正吸引了我的注意力,因为它可以访问通用的 Telnet 游戏、文件传输协议(FTP)、在线邮箱和进行 C 语言编程。当时 Gopher 非常受欢迎,特别是在我们这群终端用户当中。 + +被分到学院计算机部门是我研究生命运的转折点,这个部门主管学校的计算机服务。学生们可以使用 X Window 终端来登录基于 [Ultrix][3] 的系统。大部分都是灰度的黑白界面,彩色处理在当时非常占用 CPU,也很影响系统性能。也有一些彩色系统还不错,但是这些机器都很慢。 + +我很喜欢那个时候,我有系统管理员权限而且工作是维护系统和网络。我有一些很好的导师,他们对我选择从事系统管理员而不是程序员起了关键作用(尽管我至今仍然热爱编程)。 + +### 从 Unix 到 Linux + +稀缺是创造之母,当需要分享匮乏的学校电脑系统资源的时候,我们学生们变得富有创造力。需要用电脑的学生是 Ultrix 工作站承受量的三到五倍,所以寻找资源往往是个难题(特别是要交付项目的时候)。在不需要图形化显示的时候,我们有一个 56k 的点对点协议的调制解调器池可供远程系统访问接入。但是找到一个有空余资源的机器并共享系统进行源码编译通常会导致进度缓慢。和大部分人一样,我发现晚上工作通常会有所帮助,但我还需要其它一些东西让我的项目迭代快一点。 + +后来学校的一个系统管理员建议我去看一个免费提供的 Unix 系统。那就是 Linux,它被装在 3.5 英寸的软盘里。多亏我们学校超快的 T1 线路,我很容易就搜索到新闻组和其他资源来学习如何下载它。它全是基于 32 位的英特尔 PC 机的,而我并没有这一类的设备。 + +幸运的是,我在学校的工作让我有机会接触到堆积如山的废旧电脑,所以命运的齿轮又开始旋转起来。 + +我找到了足够多的废旧 PC 组装了一个可靠的 80386 PC,带有足够内存(我确定不到 1GB),它有一个能用的显卡、一个细缆(同轴)以太网卡和一个硬盘。我所用的镜像是 Linux 内核 0.98,我不记得它是不是正式发行版的一部分了(可能是 SLS)。我所记得的是,它有一系列的软盘镜像,第一张软盘启动内核和一个最小安装程序,然后格式化硬盘,接着要求插入每个后续的软盘来安装 GNU 核心实用程序。在核心实用程序装好并引导系统之后,你可以下载和安装其他的软件包镜像,比如编译器之类的。 + +这是我学术道路上巨大的福音。在没有运行 X Window 显示服务器的情况下,这台电脑性能比学校的 Ultrix 工作站强很多。学校允许我把这台机器连到校园网络,挂载学校的学生网络文件系统(NFS)共享,并且能直接访问互联网。因为我的研究生课程用 [GCC][5](还有 Perl 4)来完成大部分学生作业,所以我可以在本地进行开发工作。这使得我可以独享关键资源,从而使我能够更快速地迭代我的项目。 + +但是,这个方案不是完美的。硬件有时会有点不稳定(这可能就是它们被丢弃的原因),但我都能搞定。真正让我感受到的是 Linux 和 Ultrix 在操作系统和系统库层面的差异。我开始理解移植软件到其他操作系统的意义,我可以自由地在任何地方开发,但是我必须以 Ultrix 编译的二进制文件交付项目。在一个平台上完美运行的 C 语言代码可能在另一个平台出错。这非常令人沮丧,但是我可能本能的察觉到了早期 Linux 解引用空指针的方法。Linux 倾向于把它作为空操作处理,但是 Ultrix 会立即触发核心转储和段错误 [SIGSEGV][6]。这是我第一次程序移植时的重大发现,正好在要交作业的几天之前。这同时对我研究 C++ 造成了一些麻烦,因为我粗心地同时使用了 `malloc()`/`free()` 和自动[构造函数和析构函数][7]处理,让我的项目到处都是空指针炸弹。 + +研究生课程快结束的时候,我升级到了一台性能野兽工作站:一颗英特尔 486DX2 66MHz 芯片、一块 SCSI 硬盘、一块光驱和一个 1024x768 RGB 显示器,并且还用一个 16550 UART 串口卡完美地匹配了我的新 US Robotics V.Everything 牌调制解调器。它可以双启动 Windows 和 Linux 系统,但更重要的是显卡和 CPU 的速度让我的开发环境幸福感倍增。那台旧的 386 依然在学校服役,不过我我现在大部分繁重的功课和钻研都转移到了家里。 + +和 [Mike Harris][8] 关于 90 年代的 Linux 故事类似,我真的对当时流行的 CD 集合很着迷。我住的附近有家新开的 Micro Center 计算机商店,这个宝库充满了电脑配件、高级专业书籍和你能想到的各种 Linux(以及免费的 Unix)CD。我还记得 [Yggdrasil][9] 和 [Slackware][10] 是我最喜欢的发行版。真正让人难以置信的是 CD 存储空间的巨大容量 —— 650MB!使它成为获得软件的必不可少的载体。是的,你可以用 56k 的速度下载,但是真的很慢。更别提大部分人负担不起存档这么多供以后使用的闲置数据。 + +### 而到了今天 + +就是这些开启了我长达 25 年的系统管理员的职业生涯和开源软件的乐趣。Linux 一直是我事业和个人开发中的重要组成部分。最近我依旧醉心于 Linux(主要是 CentOS、RedHat 和 Ubuntu),但也经常从 [FreeBSD][11] 和其他炫酷开源软件中得到乐趣。 + +Linux 让我来到了 Opensource.com,我希望在这里能回馈社区,为新一代电脑爱好者出一份力。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/linux-story + +作者:[James Farrell][a] +选题:[lujun9972][b] +译者:[Accelerator](https://github.com/Acceleratorrrr) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jamesf +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://en.wikipedia.org/wiki/Apple_IIc +[3]: https://en.wikipedia.org/wiki/Ultrix +[4]: https://en.wikipedia.org/wiki/Point-to-Point_Protocol +[5]: https://en.wikipedia.org/wiki/GNU_Compiler_Collection +[6]: https://en.wikipedia.org/wiki/Segmentation_fault +[7]: https://www.tutorialspoint.com/cplusplus/cpp_constructor_destructor.htm +[8]: https://linux.cn/article-11831-1.html +[9]: https://en.wikipedia.org/wiki/Yggdrasil_Linux/GNU/X +[10]: http://slackware.com +[11]: https://www.freebsd.org/ diff --git a/published/202005/20200413 9 open source CSS frameworks for frontend web development.md b/published/202005/20200413 9 open source CSS frameworks for frontend web development.md new file mode 100644 index 0000000000..00ab65d520 --- /dev/null +++ b/published/202005/20200413 9 open source CSS frameworks for frontend web development.md @@ -0,0 +1,249 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12227-1.html) +[#]: subject: (9 open source CSS frameworks for frontend web development) +[#]: via: (https://opensource.com/article/20/4/open-source-css-frameworks) +[#]: author: (Bryant Son https://opensource.com/users/brson) + +9 个用于前端 Web 开发的开源 CSS 框架 +====== + +> 探索开源 CSS 框架,找到适合你的项目的框架。 + +![](https://img.linux.net.cn/data/attachment/album/202005/18/094922of81rqfiei8x78xi.jpg) + +当大多数人想到 Web 开发时,通常会想到 HTML 或 JavaScript。他们通常会忘记对网站的欣赏能力有更大影响的技术:[级联样式表][2]cascading style sheets(简称 CSS)。据维基百科的说法,CSS 既是网页中最重要的部分,也是最常被遗忘的部分,尽管它是万维网的三大基石技术之一。 + +本文将探讨九种流行的、强大的、开源的框架,是这些框架让构建漂亮的网站前端的 CSS 开发变得简单明了。 + +名称 | 介绍| 许可证 +---|---|--- +[Bootstrap][3] | 最流行的 CSS 框架,来自 Twitter | MIT +[PatternFly][4] | 开源框架,来自 Red Hat | MIT +[MDC Web][5] | Material Design 组件开源框架,来自 Google | MIT +[Pure][6] | 开源框架,来自 Yahoo | BSD +[Foundation][7] | 前端框架,来自 Zurb 基金会 | MIT +[Bulma][8] | 现代 CSS 框架,基于 Flexbox | MIT +[Skeleton][9] | 轻量级 CSS 框架 | MIT +[Materialize][10] | 基于 Material Design 的 CSS 框架 | MIT +[Bootflat][11] | 开源 Flat UI 工具,基于 Bootstrap 3.3.0 | MIT + +### Bootstrap + +[Bootstrap][2] 无疑是最流行的 CSS 框架,它是所有前端 Web 设计的开端。Bootstrap 由 Twitter 开发,提供了可用性、功能性和可扩展性。 + +![Bootstrap homepage][13] + +Bootstrap 还提供了大量的[例子][14]来帮助你入门。 + +![Bootstrap examples][15] + +使用 Bootstrap,你可以将不同的组件和布局拼接在一起,创造出有趣的页面设计。它还提供了大量详细的文档。 + +![Bootstrap documentation][16] + +Bootstrap 的 [GitHub][3] 仓库有超过 19000 个提交和 1100 个贡献者。它基于 MIT 许可证,所以(和这个列表中的所有框架一样)你也可以加入并贡献。 + +![Bootstrap GitHub][17] + +### PatternFly + +[PatternFly][18] 是由 Red Hat 开发的一个开源的(MIT 许可证)CSS 框架。PatternFly 采取了与 Bootstrap 不同的方法:Bootstrap 是为任何对创建一个漂亮网站感兴趣的人而设计的,而 PatternFly 主要针对企业级应用开发者,它提供的组件,如条形图、图表和导航,对于创建强大的、指标驱动的仪表盘非常有吸引力。事实上,Red Hat 在其产品(如 OpenShift)的设计中也使用了这个 CSS 框架。 + +![PatternFly homepage][19] + +除了静态 HTML 之外,PatternFly 还支持 ReactJS 框架,ReactJS 是 Facebook 开发的一个流行的 JavaScript 框架。 + +![PatternFly ReactJS support][20] + +PatternFly 有许多高级组件,如条形图、图表、[模态窗口][21]和布局等,适用于企业级应用。 + +![PatternFly chart component][22] + +PatternFly 的 [GitHub][4] 页面列出了超过 1050 个提交和 44 个贡献者。PatternFly 得到了很多人的关注,欢迎大家踊跃贡献。 + +![PatternFly GitHub][23] + +### MDC Web + +凭借其大获成功的安卓平台,谷歌以一个名为 [Material Design][24] 的概念制定了自己的标准设计准则。Material Design 标准旨在体现在所有谷歌的产品中,这些标准也可以面向大众,并且在 MIT 许可证下开源。 + +![Material Design homepage][25] + +Material Design 有许多“用于创建用户界面的交互式构建块”的[组件][26]。这些按钮、卡片、背景等可用于创建网站或移动应用程序的任何类型的用户界面。 + +![Material Components webpage][27] + +维护人员为不同的平台提供了详尽的文档。 + +![Material Design documentation][28] + +还有分步教程,其中包含用于实现不同目标的练习。 + +![Material Design tutorial][29] + +Material 组件的 GitHub 页面承载了面向不同平台的存储库,包括用于网站开发的 [Material Web 组件(MDC Web)][5]。MDC Web 有超过 5700 个提交和 349 个贡献者。 + +![MDC Web GitHub][30] + +### Pure + +Bootstrap、Patternfly 和 MDC Web 都是非常强大的 CSS 框架,但是它们可能相当的笨重和复杂。如果你想要一个轻量级的 CSS 框架,它更接近于自己编写 CSS,但又能帮助你建立一个漂亮的网页,可以试试 [Pure.css][31]。Pure 是一个轻量级的 CSS 框架,它的体积很小。它是由 Yahoo 开发的,在 BSD 许可证下开源。 + +![Pure.css homepage][32] + +尽管体积小,但 Pure 提供了建立一个漂亮网页的很多必要的组件。 + +![Pure.css components][33] + +Pure 的 [GitHub][6] 页面显示它有超过 565 个提交和 59 个贡献者。 + +![Pure.css GitHub][34] + +### Foundation + +[Foundation][35] 号称是世界上最先进的响应式前端框架。它提供了先进的功能和教程,用于构建专业网站。 + +![Foundation homepage][36] + +该框架被许多公司、组织甚至政客[使用][37],并且有大量的文档可用。 + +![Foundation documentation][38] + +Foundation 的 [GitHub][7] 页面显示有近 17000 个提交和 1000 个贡献者。和这个列表中的大多数其他框架一样,它也是在 MIT 许可证下提供的。 + +![Foundation GitHub][39] + +### Bulma + +[Bulma][40] 是一个基于 Flexbox 的开源框架,在 MIT 许可证下提供。Bulma 是一个相当轻量级的框架,因为它只需要一个 CSS 文件。 + +![Bulma homepage][41] + +Bulma 有简洁明快的文档,让你可以很容易地选择你想要探索的主题。它也有很多网页组件,你可以直接拿起来在设计中使用。 + +![Bulma documentation][42] + +Bulma 的 [GitHub][8] 页面列出了 1400 多个提交和 300 多个贡献者。 + +![Bulma GitHub][43] + +### Skeleton + +如果连 Pure 都觉得太重了,那么还有一个叫 [Skeleton][44] 的更轻量级框架。Skeleton 库只有 400 行左右的长度,而且这个框架只提供了开始你的 CSS 框架之旅的基本组件。 + +![Skeleton homepage][45] + +尽管它很简单,但 Skeleton 提供了详细的文档,可以帮助你马上上手。 + +![Skeleton documentation][46] + +Skeleton 的 [GitHub][9] 列出了 167 个提交和 22 个贡献者。然而,它不是很活跃,它的最后一次更新是在 2014 年,所以在使用之前可能需要一些维护。由于它是在 MIT 许可证下发布的,你可以自行维护。 + +![Skeleton GitHub][47] + +### Materialize + +[Materialize][48] 是一个基于 Google 的 Material Design 的响应式前端框架,带有由 Materialize 的贡献者开发的附加主题和组件。 + +![Materialize homepage][49] + +Materialize 的文档页面非常全面,而且相当容易理解。它的组件页面包括按钮、卡片、导航等等。 + +![Materialize documentation][50] + +Materialize 是 MIT 许可证下的开源项目,它的 [GitHub][10] 列出了超过 3800 个提交和 250 个贡献者。 + +![Materialize GitHub][51] + +### Bootflat + +[Bootflat][52] 是由 Twitter 的 Bootstrap 衍生出来的一个开源 CSS 框架。与 Bootstrap 相比, Bootflat 更简单,框架组件更轻量级。 + +![Bootflat homepage][53] + +Bootflat 的[文档][54]几乎像是受到了宜家的启发 —— 它显示的是每个组件的图片,没有太多的文字。 + +![Bootflat docs][55] + +Bootflat 是在 MIT 许可证下提供的,其 [GitHub][11] 页面包括 159 个提交和 8 个贡献者。 + +![Bootflat GitHub][56] + +### 你应该选择哪个 CSS 框架? + +对于开源的 CSS 框架,你有很多选择,这取决于你想要的工具功能有多丰富或简单。就像所有的技术决定一样,没有一个正确的答案,只有在给定的时间和项目中才有正确的选择。 + +尝试一下其中的一些,看看要在下一个项目中使用哪个。另外,我有没有错过任何有趣的开源 CSS 框架?请在下面的评论中分享你的反馈和想法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/open-source-css-frameworks + +作者:[Bryant Son][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/brson +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://en.wikipedia.org/wiki/Cascading_Style_Sheets +[3]: https://github.com/twbs/bootstrap +[4]: https://github.com/patternfly/patternfly +[5]: https://github.com/material-components/material-components-web +[6]: https://github.com/pure-css/pure +[7]: https://github.com/foundation/foundation-sites +[8]: https://github.com/jgthms/bulma +[9]: https://github.com/dhg/Skeleton +[10]: https://github.com/Dogfalo/materialize +[11]: https://github.com/bootflat/bootflat.github.io +[12]: https://getbootstrap.com +[13]: https://opensource.com/sites/default/files/uploads/2_bootstrapscreenshot.jpg (Bootstrap homepage) +[14]: https://getbootstrap.com/docs/4.4/examples/ +[15]: https://opensource.com/sites/default/files/uploads/3_bootstrapsamples.jpg (Bootstrap examples) +[16]: https://opensource.com/sites/default/files/uploads/4_bootstrapdocs.jpg (Bootstrap documentation) +[17]: https://opensource.com/sites/default/files/uploads/5_bootstrapgithub.jpg (Bootstrap GitHub) +[18]: https://www.patternfly.org +[19]: https://opensource.com/sites/default/files/uploads/6_patternflyhomepage.jpg (PatternFly homepage) +[20]: https://opensource.com/sites/default/files/uploads/7_patternflyreactjs.jpg (PatternFly ReactJS support) +[21]: https://en.wikipedia.org/wiki/Modal_window +[22]: https://opensource.com/sites/default/files/uploads/8_patternflycomponents.jpg (PatternFly chart component) +[23]: https://opensource.com/sites/default/files/uploads/9_patternflygithub.jpg (PatternFly GitHub) +[24]: https://material.io +[25]: https://opensource.com/sites/default/files/uploads/10_materialhome.jpg (Material Design homepage) +[26]: https://material.io/components/ +[27]: https://opensource.com/sites/default/files/uploads/11_materialcomponents.jpg (Material Components webpage) +[28]: https://opensource.com/sites/default/files/uploads/12_materialdocs.jpg (Material Design documentation) +[29]: https://opensource.com/sites/default/files/uploads/13_materialtutorial.jpg (Material Design tutorial) +[30]: https://opensource.com/sites/default/files/uploads/15_materialgithub.jpg (MDC Web GitHub) +[31]: https://purecss.io +[32]: https://opensource.com/sites/default/files/uploads/16_purehome.jpg (Pure.css homepage) +[33]: https://opensource.com/sites/default/files/uploads/17_purecomponents.jpg (Pure.css components) +[34]: https://opensource.com/sites/default/files/uploads/18_puregithub.jpg (Pure.css GitHub) +[35]: https://get.foundation +[36]: https://opensource.com/sites/default/files/uploads/19_foundationhome.jpg (Foundation homepage) +[37]: https://zurb.com/responsive +[38]: https://opensource.com/sites/default/files/uploads/21_foundationdocs.jpg (Foundation documentation) +[39]: https://opensource.com/sites/default/files/uploads/22_foundationgithub.jpg (Foundation GitHub) +[40]: https://bulma.io +[41]: https://opensource.com/sites/default/files/uploads/23_bulmahome.jpg (Bulma homepage) +[42]: https://opensource.com/sites/default/files/uploads/24_bulmadoc.jpg (Bulma documentation) +[43]: https://opensource.com/sites/default/files/uploads/25_bulmagithub.jpg (Bulma GitHub) +[44]: http://getskeleton.com +[45]: https://opensource.com/sites/default/files/uploads/26_skeletonhome.jpg (Skeleton homepage) +[46]: https://opensource.com/sites/default/files/uploads/27_skeletondocs.jpg (Skeleton documentation) +[47]: https://opensource.com/sites/default/files/uploads/28_skeletongithub.jpg (Skeleton GitHub) +[48]: https://materializecss.com +[49]: https://opensource.com/sites/default/files/uploads/29_materializehome.jpg (Materialize homepage) +[50]: https://opensource.com/sites/default/files/uploads/30_materializedocs.jpg (Materialize documentation) +[51]: https://opensource.com/sites/default/files/uploads/31_materializegithub.jpg (Materialize GitHub) +[52]: http://bootflat.github.io +[53]: https://opensource.com/sites/default/files/uploads/32_bootflathome.jpg (Bootflat homepage) +[54]: http://bootflat.github.io/documentation.html +[55]: https://opensource.com/sites/default/files/uploads/33_bootflatdocs.jpg (Bootflat docs) +[56]: https://opensource.com/sites/default/files/uploads/34_bootflatgithub.jpg (Bootflat GitHub) diff --git a/published/202005/20200414 How I containerize a build system.md b/published/202005/20200414 How I containerize a build system.md new file mode 100644 index 0000000000..e268f779ff --- /dev/null +++ b/published/202005/20200414 How I containerize a build system.md @@ -0,0 +1,163 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12232-1.html) +[#]: subject: (How I containerize a build system) +[#]: via: (https://opensource.com/article/20/4/how-containerize-build-system) +[#]: author: (Ravi Chandran https://opensource.com/users/ravichandran) + +对构建系统进行容器化的指南 +====== + +> 搭建一个通过容器分发应用的可复用系统可能很复杂,但这儿有个好方法。 + +![](https://img.linux.net.cn/data/attachment/album/202005/19/085248ausakkjfu05akqr2.jpg) + +一个用于将源代码转换成可运行的应用的构建系统是由工具和流程共同组成。在转换过程中还涉及到代码的受众从软件开发者转变为最终用户,无论最终用户是运维的同事还是部署的同事。 + +在使用容器搭建了一些构建系统后,我觉得有一个不错的可复用的方法值得分享。虽然这些构建系统被用于编译机器学习算法和为嵌入式硬件生成可加载的软件镜像,但这个方法足够抽象,可用于任何基于容器的构建系统。 + +这个方法是以一种易于使用和维护的方式搭建或组织构建系统,但并不涉及处理特定编译器或工具容器化的技巧。它适用于软件开发人员构建软件,并将可维护镜像交给其他技术人员(无论是系统管理员、运维工程师或者其他一些头衔)的常见情况。该构建系统被从终端用户中抽象出来,这样他们就可以专注于软件。 + +### 为什么要容器化构建系统? + +搭建基于容器的可复用构建系统可以为软件团队带来诸多好处: + + * **专注**:我希望专注于应用的开发。当我调用一个工具进行“构建”时,我希望这个工具集能生成一个随时可用的二进制文件。我不想浪费时间在构建系统的查错上。实际上,我宁愿不了解,或者说不关心构建系统。 + * **一致的构建行为**:无论在哪种使用情况下,我都想确保整个团队使用相同版本的工具集并在构建时得到相同的结果。否则,我就得不断地处理“我这咋就是好的”的麻烦。在团队项目中,使用相同版本的工具集并对给定的输入源文件集产生一致的输出是非常重要。 + * **易于部署和升级**:即使向每个人都提供一套详细说明来安装一个项目的工具集,也可能会有人翻车。问题也可能是由于每个人对自己的 Linux 环境的个性化修改导致的。在团队中使用不同的 Linux 发行版(或者其他操作系统),情况可能还会变得更复杂。当需要将工具集升级到下一版本时,问题很快就会变得更糟糕。使用容器和本指南将使得新版本升级非常简单。 + +对我在项目中使用的构建系统进行容器化的这些经验显然很有价值,因为它可以缓解上述问题。我倾向于使用 Docker 作为容器工具,虽然在相对特殊的环境中安装和网络配置仍可能出现问题,尤其是当你在一个使用复杂代理的企业环境中工作时。但至少现在我需要解决的构建系统问题已经很少了。 + +### 漫步容器化的构建系统 + +我创建了一个[教程存储库][2],随后你可以克隆并检查它,或者按照本文内容进行操作。我将逐个介绍存储库中的文件。这个构建系统非常简单(它运行 `gcc`),从而可以让你专注于这个构建系统结构上。 + +### 构建系统需求 + +我认为构建系统中有两个关键点: + + * **标准化构建调用**:我希望能够指定一些形如 `/path/to/workdir` 的工作目录来构建代码。我希望以如下形式调用构建: + + ./build.sh /path/to/workdir + + 为了使得示例的结构足够简单(以便说明),我将假定输出也在 `/path/to/workdir` 路径下的某处生成。(否则,将增加容器中显示的卷的数量,虽然这并不困难,但解释起来比较麻烦。) + * **通过 shell 自定义构建调用**:有时,工具集会以出乎意料的方式被调用。除了标准的工具集调用 `build.sh` 之外,如果需要还可以为 `build.sh` 添加一些选项。但我一直希望能够有一个可以直接调用工具集命令的 shell。在这个简单的示例中,有时我想尝试不同的 `gcc` 优化选项并查看效果。为此,我希望调用: + + ./shell.sh /path/to/workdir + + 这将让我得到一个容器内部的 Bash shell,并且可以调用工具集和访问我的工作目录(`workdir`),从而我可以根据需要尝试使用这个工具集。 + +### 构建系统的架构 + +为了满足上述基本需求,这是我的构架系统架构: + +![Container build system architecture][3] + +在底部的 `workdir` 代表软件开发者用于构建的任意软件源码。通常,这个 `workdir` 是一个源代码的存储库。在构建之前,最终用户可以通过任何方式来操纵这个存储库。例如,如果他们使用 `git` 作为版本控制工具的话,可以使用 `git checkout` 切换到他们正在工作的功能分支上并添加或修改文件。这样可以使得构建系统独立于 `workdir` 之外。 + +顶部的三个模块共同代表了容器化的构建系统。最左边的黄色模块代表最终用户与构建系统交互的脚本(`build.sh` 和 `shell.sh`)。 + +在中间的红色模块是 Dockerfile 和相关的脚本 `build_docker_image.sh`。开发运营者(在这个例子中指我)通常将执行这个脚本并生成容器镜像(事实上我多次执行它直到一切正常为止,但这是另一回事)。然后我将镜像分发给最终用户,例如通过容器信任注册库container trusted registry进行分发。最终用户将需要这个镜像。另外,他们将克隆构建系统的存储库(即一个与[教程存储库][2]等效的存储库)。 + +当最终用户调用 `build.sh` 或者 `shell.sh` 时,容器内将执行右边的 `run_build.sh` 脚本。接下来我将详细解释这些脚本。这里的关键是最终用户不需要为了使用而去了解任何关于红色或者蓝色模块或者容器工作原理的知识。 + +### 构建系统细节 + +把教程存储库的文件结构映射到这个系统结构上。我曾将这个原型结构用于相对复杂构建系统,因此它的简单并不会造成任何限制。下面我列出存储库中相关文件的树结构。文件夹 `dockerize-tutorial` 能用构建系统的其他任何名称代替。在这个文件夹下,我用 `workdir` 的路径作参数调用 `build.sh` 或 `shell.sh`。 + +``` +dockerize-tutorial/ +├── build.sh +├── shell.sh +└── swbuilder +    ├── build_docker_image.sh +    ├── install_swbuilder.dockerfile +    └── scripts +        └── run_build.sh +``` + +请注意,我上面特意没列出 `example_workdir`,但你能在教程存储库中找到它。实际的源码通常存放在单独的存储库中,而不是构建工具库中的一部分;本教程为了不必处理两个存储库,所以我将它包含在这个存储库中。 + +如果你只对概念感兴趣,本教程并非必须的,因为我将解释所有文件。但是如果你继续本教程(并且已经安装 Docker),首先使用以下命令来构建容器镜像 `swbuilder:v1`: + +``` +cd dockerize-tutorial/swbuilder/ +./build_docker_image.sh +docker image ls  # resulting image will be swbuilder:v1 +``` + +然后调用 `build.sh`: + +``` +cd dockerize-tutorial +./build.sh ~/repos/dockerize-tutorial/example_workdir +``` + +下面是 [build.sh][4] 的代码。这个脚本从容器镜像 `swbuilder:v1` 实例化一个容器。而这个容器实例映射了两个卷:一个将文件夹 `example_workdir` 挂载到容器内部路径 `/workdir` 上,第二个则将容器外的文件夹 `dockerize-tutorial/swbuilder/scripts` 挂载到容器内部路径 `/scripts` 上。 + +``` +docker container run                              \ +    --volume $(pwd)/swbuilder/scripts:/scripts    \ +    --volume $1:/workdir                          \ +    --user $(id -u ${USER}):$(id -g ${USER})      \ +    --rm -it --name build_swbuilder swbuilder:v1  \ +    build +``` + +另外,`build.sh` 还会用你的用户名(以及组,本教程假设两者一致)去运行容器,以便在访问构建输出时不出现文件权限问题。 + +请注意,[shell.sh][5] 和 `build.sh` 大体上是一致的,除了两点不同:`build.sh` 会创建一个名为 `build_swbuilder` 的容器,而 `shell.sh` 则会创建一个名为 `shell_swbuilder` 的容器。这样一来,当其中一个脚本运行时另一个脚本被调用也不会产生冲突。 + +两个脚本之间的另一处关键不同则在于最后一个参数:`build.sh` 传入参数 `build` 而 `shell.sh` 则传入 `shell`。如果你看了用于构建容器镜像的 [Dockerfile][6],就会发现最后一行包含了下面的 `ENTRYPOINT` 语句。这意味着上面的 `docker container run` 调用将使用 `build` 或 `shell` 作为唯一的输入参数来执行 `run_build.sh` 脚本。 + +``` +# run bash script and process the input command +ENTRYPOINT [ "/bin/bash", "/scripts/run_build.sh"] +``` + +[run_build.sh][7] 使用这个输入参数来选择启动 Bash shell 还是调用 `gcc` 来构建 `helloworld.c` 项目。一个真正的构建系统通常会使用 Makefile 而非直接运行 `gcc`。 + +``` +cd /workdir + +if [ $1 = "shell" ]; then     +    echo "Starting Bash Shell" +    /bin/bash +elif [ $1 = "build" ]; then +    echo "Performing SW Build" +    gcc helloworld.c -o helloworld -Wall +fi +``` + +在使用时,如果你需要传入多个参数,当然也是可以的。我处理过的构建系统,构建通常是对给定的项目调用 `make`。如果一个构建系统有非常复杂的构建调用,则你可以让 `run_build.sh` 调用 `workdir` 下最终用户编写的特定脚本。 + +### 关于 scripts 文件夹的说明 + +你可能想知道为什么 `scripts` 文件夹位于目录树深处而不是位于存储库的顶层。两种方法都是可行的,但我不想鼓励最终用户到处乱翻并修改里面的脚本。将它放到更深的地方是一个让他们更难乱翻的方法。另外,我也可以添加一个 `.dockerignore` 文件去忽略 `scripts` 文件夹,因为它不是容器必需的部分。但因为它很小,所以我没有这样做。 + +### 简单而灵活 + +尽管这一方法很简单,但我在几个相当不同的构建系统中使用过,发现它相当灵活。相对稳定的部分(例如,一年仅修改数次的给定工具集)被固定在容器镜像内。较为灵活的部分则以脚本的形式放在镜像外。这使我能够通过修改脚本并将更改推送到构建系统存储库中,轻松修改调用工具集的方式。用户所需要做的是将更改拉到本地的构建系统存储库中,这通常是非常快的(与更新 Docker 镜像不同)。这种结构使其能够拥有尽可能多的卷和脚本,同时使最终用户摆脱复杂性。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/how-containerize-build-system + +作者:[Ravi Chandran][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ravichandran +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_2015-3-osdc-lead.png?itok=O6aivM_W (Containers on a ship on the ocean) +[2]: https://github.com/ravi-chandran/dockerize-tutorial +[3]: https://opensource.com/sites/default/files/uploads/build_sys_arch.jpg (Container build system architecture) +[4]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/build.sh +[5]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/shell.sh +[6]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/swbuilder/install_swbuilder.dockerfile +[7]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/swbuilder/scripts/run_build.sh diff --git a/published/202005/20200416 Learning to love systemd.md b/published/202005/20200416 Learning to love systemd.md new file mode 100644 index 0000000000..5cacf21a0c --- /dev/null +++ b/published/202005/20200416 Learning to love systemd.md @@ -0,0 +1,318 @@ +[#]: collector: (lujun9972) +[#]: translator: (messon007) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12214-1.html) +[#]: subject: (Learning to love systemd) +[#]: via: (https://opensource.com/article/20/4/systemd) +[#]: author: (David Both https://opensource.com/users/dboth) + +学会爱上 systemd +====== + +> systemd 是所有进程之母,负责将 Linux 主机启动到可以做生产性任务的状态。 + +![](https://img.linux.net.cn/data/attachment/album/202005/13/085016gy86wj713zh7xq71.jpg) + +systemd(是的,全小写,即使在句子开头也是小写),是初始化程序(`init`)和 SystemV 初始化脚本的现代替代者。此外,它还有更多功能。 + +当我想到 `init` 和 SystemV 初始化时,像大多数系统管理员一样,我想到的是 Linux 的启动和关闭,而不是真正意义上的管理服务,例如在服务启动和运行后对其进行管理。像 `init` 一样,systemd 是所有进程之母,它负责使 Linux 主机启动到可以做生产性任务的状态。systemd 设定的一些功能比老的初始化程序要广泛得多,它要管理正在运行的 Linux 主机的许多方面,包括挂载文件系统、管理硬件、处理定时器以及启动和管理生产性主机所需的系统服务。 + +本系列文章是基于我的三期 Linux 培训课程《[使用和管理 Linux:从零开始进行学习系统管理][2]》部分内容的摘录,探讨了 systemd 在启动和启动完成后的功能。 + +### Linux 引导 + +Linux 主机从关机状态到运行状态的完整启动过程很复杂,但它是开放的并且是可知的。在详细介绍之前,我将简要介绍一下从主机硬件被上电到系统准备好用户登录的过程。大多数时候,“引导过程”被作为一个整体来讨论,但这是不准确的。实际上,完整的引导和启动过程包含三个主要部分: + +* 硬件引导:初始化系统硬件 +* Linux 引导boot:加载 Linux 内核和 systemd +* Linux 启动startup:systemd 为主机的生产性工作做准备 + +Linux 启动阶段始于内核加载了 `init` 或 systemd(取决于具体发行版使用的是旧的方式还是还是新的方式)之后。`init` 和 systemd 程序启动并管理所有其它进程,它们在各自的系统上都被称为“所有进程之母”。 + +将硬件引导与 Linux 引导及 Linux 启动区分开,并明确定义它们之间的分界点是很重要的。理解它们的差异以及它们每一个在使 Linux 系统进入生产状态所起的作用,才能够管理这些进程,并更好地确定大部分人所谓的“启动”问题出在哪里。 + +启动过程按照三步引导流程,使 Linux 计算机进入可进行生产工作的状态。当内核将主机的控制权转移到 systemd 时,启动环节开始。 + +### systemd 之争 + +systemd 引起了系统管理员和其它负责维护 Linux 系统正常运行人员的广泛争议。在许多 Linux 系统中,systemd 接管了大量任务,这在某些开发者和sysadmins群体中引起了反对和不和谐。 + +SystemV 和 systemd 是执行 Linux 启动环节的两种不同的方法。SystemV 启动脚本和 `init` 程序是老的方法,而使用目标target的 systemd 是新方法。尽管大多数现代 Linux 发行版都使用较新的 systemd 进行启动、关机和进程管理,但仍有一些发行版未采用。原因之一是某些发行版维护者和系统管理员喜欢老的 SystemV 方法,而不是新的 systemd。 + +我认为两者都有其优势。 + +#### 为何我更喜欢 SystemV + +我更喜欢 SystemV,因为它更开放。使用 Bash 脚本来完成启动。内核启动 `init` 程序(这是一个编译后的二进制)后,`init` 启动 `rc.sysinit` 脚本,该脚本执行许多系统初始化任务。`rc.sysinit` 执行完后,`init` 启动 `/etc/rc.d/rc` 脚本,该脚本依次启动 `/etc/rc.d/rcX.d` 中由 SystemV 启动脚本定义的各种服务。其中 `X` 是待启动的运行级别号。 + +除了 `init` 程序本身之外,所有这些程序都是开放且易于理解的脚本。可以通读这些脚本并确切了解整个启动过程中发生的事情,但是我不认为有太多系统管理员真正做到这一点。每个启动脚本都被编了号,以便按特定顺序启动预期的服务。服务是串行启动的,一次只能启动一个服务。 + +systemd 是由 Red Hat 的 Lennart Poettering 和 Kay Sievers 开发的,它是一个由大型的、编译的二进制可执行文件构成的复杂系统,不访问其源码就无法理解。它是开源的,因此“访问其源代码”并不难,只是不太方便。systemd 似乎表现出对 Linux 哲学多个原则的重大驳斥。作为二进制文件,systemd 无法被直接打开供系统管理员查看或进行简单更改。systemd 试图做所有事情,例如管理正在运行的服务,同时提供明显比 SystemV 更多的状态信息。它还管理硬件、进程、进程组、文件系统挂载等。systemd 几乎涉足于现代 Linux 主机的每个方面,使它成为系统管理的一站式工具。所有这些都明显违反了“程序应该小,且每个程序都应该只做一件事并做好”的原则。 + +#### 为何我更喜欢 systemd + +我更喜欢用 systemd 作为启动机制,因为它会根据启动阶段并行地启动尽可能多的服务。这样可以加快整个的启动速度,使得主机系统比 SystemV 更快地到达登录屏幕。 + +systemd 几乎可以管理正在运行的 Linux 系统的各个方面。它可以管理正在运行的服务,同时提供比SystemV 多得多的状态信息。它还管理硬件、进程和进程组、文件系统挂载等。systemd 几乎涉足于现代 Linux 操作系统的每方面,使其成为系统管理的一站式工具。(听起来熟悉吧?) + +systemd 工具是编译后的二进制文件,但该工具包是开放的,因为所有配置文件都是 ASCII 文本文件。可以通过各种 GUI 和命令行工具来修改启动配置,也可以添加或修改各种配置文件来满足特定的本地计算环境的需求。 + +#### 真正的问题 + +你认为我不能喜欢两种启动系统吗?我能,我会用它们中的任何一个。 + +我认为,SystemV 和 systemd 之间大多数争议的真正问题和根本原因在于,在系统管理层面[没有选择权][3]。使用 SystemV 还是 systemd 已经由各种发行版的开发人员、维护人员和打包人员选择了(但有充分的理由)。由于 `init` 极端的侵入性,挖出并替换 `init` 系统会带来很多影响,会带来很多在发行版设计过程之外难以解决的后果。 + +尽管该选择实际上是为我而选的,但我的Linux主机能不能开机、能不能工作,这是我平时最关心的。作为最终用户,甚至是系统管理员,我主要关心的是我是否可以完成我的工作,例如写我的书和这篇文章,安装更新以及编写脚本来自动化所有事情。只要我能做我的工作,我就不会真正在意发行版中使用的启动系统。 + +在启动或服务管理出现问题时,我会在意。无论主机上使用哪种启动系统,我都足够了解如何沿着事件顺序来查找故障并进行修复。 + +#### 替换SystemV + +以前曾有过用更现代的东西替代 SystemV 的尝试。大约在两个版本中,Fedora 使用了一个叫作 Upstart 的东西来替换老化的 SystemV,但是它没有取代 `init`,也没有提供我所注意到的任何变化。由于 Upstart 并未对 SystemV 的问题进行任何显著的改变,所以在这个方向上的努力很快就被放弃了,转而使用 systemd。 + +尽管大部分 Linux 开发人员都认可替换旧的 SystemV 启动系统是个好主意,但许多开发人员和系统管理员并不喜欢 systemd。与其重新讨论人们在 systemd 中遇到的或曾经遇到过的所有所谓的问题,不如带你去看两篇好文章,尽管有些陈旧,但它们涵盖了大多数内容。Linux 内核的创建者 Linus Torvalds 对 systemd 似乎不感兴趣。在 2014 年 ZDNet 的一篇文章《[Linus Torvalds 和其他人对 Linux 上的 systemd 的看法][4]》中,Linus 清楚地表达了他的感受。 + +> “实际上我对 systemd 本身没有任何特别强烈的意见。我对一些核心开发人员有一些问题,我认为他们在对待错误和兼容性方面过于轻率,而且我认为某些设计细节是疯狂的(例如,我不喜欢二进制日志),但这只是细节,不是大问题。” + +如果你对 Linus 不太了解的话,我可以告诉你,如果他不喜欢某事,他是非常直言不讳的,很明确,而且相当明确的表示不喜欢。他解决自己对事物不满的方式已经被社会更好地接受了。 + +2013 年,Poettering 写了一篇很长的博客,他在文章驳斥了[关于 systemd 的迷思][5],同时对创建 systemd 的一些原因进行了深入的剖析。这是一分很好的读物,我强烈建议你阅读。 + +### systemd 任务 + +根据编译过程中使用的选项(不在本系列中介绍),systemd 可以有多达 69 个二进制可执行文件执行以下任务,其中包括: + +* `systemd` 程序以 1 号进程(PID 1)运行,并提供使尽可能多服务并行启动的系统启动能力,它额外加快了总体启动时间。它还管理关机顺序。 +* `systemctl` 程序提供了服务管理的用户接口。 +* 支持 SystemV 和 LSB 启动脚本,以便向后兼容。 +* 服务管理和报告提供了比 SystemV 更多的服务状态数据。 +* 提供基本的系统配置工具,例如主机名、日期、语言环境、已登录用户的列表,正在运行的容器和虚拟机、系统帐户、运行时目录及设置,用于简易网络配置、网络时间同步、日志转发和名称解析的守护进程。 +* 提供套接字管理。 +* systemd 定时器提供类似 cron 的高级功能,包括在相对于系统启动、systemd 启动时间、定时器上次启动时间的某个时间点运行脚本。 +* 它提供了一个工具来分析定时器规范中使用的日期和时间。 +* 能感知分层的文件系统挂载和卸载功能可以更安全地级联挂载的文件系统。 +* 允许主动的创建和管理临时文件,包括删除。 +* D-Bus 的接口提供了在插入或移除设备时运行脚本的能力。这允许将所有设备(无论是否可插拔)都被视为即插即用,从而大大简化了设备的处理。 +* 分析启动环节的工具可用于查找耗时最多的服务。 +* 它包括用于存储系统消息的日志以及管理日志的工具。 + +### 架构 + +这些以及更多的任务通过许多守护程序、控制程序和配置文件来支持。图 1 显示了许多属于 systemd 的组件。这是一个简化的图,旨在提供概要描述,因此它并不包括所有独立的程序或文件。它也不提供数据流的视角,数据流是如此复杂,因此在本系列文章的背景下没用。 + +![系统架构][6] + +*图 1:systemd 的架构,作者 Shmuel Csaba Otto Traian (CC BY-SA 3.0)* + +如果要完整地讲解 systemd 就需要一本书。你不需要了解图 1 中的 systemd 组件是如何组合在一起的细节。只需了解支持各种 Linux 服务管理以及日志文件和日志处理的程序和组件就够了。但是很明显, systemd 并不是某些批评者所宣称的那样,它是一个单一的怪物。 + +### 作为 1 号进程的 systemd + +systemd 是 1 号进程(PID 1)。它的一些功能,比老的 SystemV3 `init` 要广泛得多,用于管理正在运行的 Linux 主机的许多方面,包括挂载文件系统以及启动和管理 Linux 生产主机所需的系统服务。与启动环节无关的任何 systemd 任务都不在本文讨论范围之内(但本系列后面的一些文章将探讨其中的一些任务)。 + +首先,systemd 挂载 `/etc/fstab` 所定义的文件系统,包括所有交换文件或分区。此时,它可以访问位于 `/etc` 中的配置文件,包括它自己的配置文件。它使用其配置链接 `/etc/systemd/system/default.target` 来确定将主机引导至哪个状态或目标。`default.target` 文件是指向真实目标文件的符号链接。对于桌面工作站,通常是 `graphical.target`,它相当于 SystemV 中的运行级别 5。对于服务器,默认值更可能是 `multi-user.target`,相当于 SystemV 中的运行级别 3。`emergency.target` 类似于单用户模式。目标target服务service是 systemd 的单元unit。 + +下表(图 2)将 systemd 目标与老的 SystemV 启动运行级别进行了比较。systemd 提供 systemd 目标别名以便向后兼容。目标别名允许脚本(以及许多系统管理员)使用 SystemV 命令(如 `init 3`)更改运行级别。当然,SystemV 命令被转发给 systemd 进行解释和执行。 + +systemd 目标 | SystemV 运行级别 | 目标别名 | 描述 +--- | --- | --- | --- +`default.target` | | | 此目标总是通过符号连接的方式成为 `multi-user.target` 或 `graphical.target` 的别名。systemd 始终使用 `default.target` 来启动系统。`default.target` 绝不应该设为 `halt.target`,`poweroff.target` 或 `reboot.target` 的别名。 +`graphic.target` | 5 | `runlevel5.target` |带有 GUI 的 `multi-user.target`。 + | 4 | `runlevel4.target` |未用。在 SystemV 中运行级别 4 与运行级别 3 相同。可以创建并自定义此目标以启动本地服务,而无需更改默认的 `multi-user.target`。 +`multi-user.target` | 3 | `runlevel3.target` |所有服务在运行,但仅有命令行界面(CLI)。 + | 2 | `runlevel2.target` | 多用户,没有 NFS,其它所有非 GUI 服务在运行。 +`rescue.target` | 1 | `runlevel1.target` | 基本系统,包括挂载文件系统,运行最基本的服务和主控制台的恢复 shell。 +`emergency.target` | S | |单用户模式:没有服务运行;不挂载文件系统。这是最基本的工作级别,只有主控制台上运行的一个紧急 Shell 供用户与系统交互。 +`halt.target` | | | 停止系统而不关闭电源。 +`reboot.target` | 6 | `runlevel6.target` | 重启。 +`poweroff.target` | 0 | `runlevel0.target` | 停止系统并关闭电源。 + +*图 2:SystemV 运行级别与 systemd 目标和一些目标别名的比较* + +每个目标在其配置文件中都描述了一个依赖集。systemd 启动必须的依赖项,这些依赖项是运行 Linux 主机到特定功能级别所需的服务。当目标配置文件中列出的所有依赖项被加载并运行后,系统就在该目标级别运行了。在图 2 中,功能最多的目标位于表的顶部,从顶向下,功能逐步递减。 + +systemd 还会检查老的 SystemV `init` 目录,以确认是否存在任何启动文件。如果有,systemd 会将它们作为配置文件以启动它们描述的服务。网络服务是一个很好的例子,在 Fedora 中它仍然使用 SystemV 启动文件。 + +图 3(如下)是直接从启动手册页复制来的。它显示了 systemd 启动期间一般的事件环节以及确保成功启动的基本顺序要求。 + +``` + cryptsetup-pre.target + | + (various low-level v + API VFS mounts: (various cryptsetup devices...) + mqueue, configfs, | | + debugfs, ...) v | + | cryptsetup.target | + | (various swap | | remote-fs-pre.target + | devices...) | | | | + | | | | | v + | v local-fs-pre.target | | | (network file systems) + | swap.target | | v v | + | | v | remote-cryptsetup.target | + | | (various low-level (various mounts and | | | + | | services: udevd, fsck services...) | | remote-fs.target + | | tmpfiles, random | | | / + | | seed, sysctl, ...) v | | / + | | | local-fs.target | | / + | | | | | | / + \____|______|_______________ ______|___________/ | / + \ / | / + v | / + sysinit.target | / + | | / + ______________________/|\_____________________ | / + / | | | \ | / + | | | | | | / + v v | v | | / + (various (various | (various | |/ + timers...) paths...) | sockets...) | | + | | | | | | + v v | v | | + timers.target paths.target | sockets.target | | + | | | | v | + v \_______ | _____/ rescue.service | + \|/ | | + v v | + basic.target rescue.target | + | | + ________v____________________ | + / | \ | + | | | | + v v v | + display- (various system (various system | + manager.service services services) | + | required for | | + | graphical UIs) v v + | | multi-user.target + emergency.service | | | + | \_____________ | _____________/ + v \|/ + emergency.target v + graphical.target +``` + +*图 3: systemd 启动图* + +`sysinit.target` 和 `basic.target` 目标可以看作启动过程中的检查点。尽管 systemd 的设计目标之一是并行启动系统服务,但是某些服务和功能目标必须先启动,然后才能启动其它服务和目标。直到该检查点所需的所有服务和目标被满足后才能通过这些检查点。 + +当 `sysinit.target` 所依赖的所有单元都完成时,就会到达 `sysinit.target`。所有这些单元,包括挂载文件系统、设置交换文件、启动 Udev、设置随机数生成器种子、启动低层服务以及配置安全服务(如果一个或多个文件系统是加密的)都必须被完成,但在 `sysinit.target` 中,这些任务可以并行执行。 + +`sysinit.target` 启动了系统接近正常运行所需的所有低层服务和单元,它们也是进入 `basic.target` 所需的。 + +在完成 `sysinit.target` 之后,systemd 会启动实现下一个目标所需的所有单元。`basic.target` 通过启动所有下一目标所需的单元来提供一些额外功能。包括设置为各种可执行程序目录的路径、设置通信套接字和计时器之类。 + +最后,用户级目标 `multi-user.target` 或 `graphical.target` 被初始化。要满足 `graphical.target` 的依赖必须先达到 `multi-user.target`。图 3 中带下划线的目标是通常的启动目标。当达到这些目标之一时,启动就完成了。如果 `multi-user.target` 是默认设置,那么你应该在控制台上看到文本模式的登录界面。如果 `graphical.target` 是默认设置,那么你应该看到图形的登录界面。你看到的具体的 GUI 登录界面取决于你的默认显示管理器。 + +引导手册页还描述并提供了引导到初始化 RAM 磁盘和 systemd 关机过程的图。 + +systemd 还提供了一个工具,该工具列出了完整的启动过程或指定单元的依赖项。单元是一个可控的 systemd 资源实体,其范围可以从特定服务(例如 httpd 或 sshd)到计时器、挂载、套接字等。尝试以下命令并滚动查看结果。 + +``` +systemctl list-dependencies graphical.target +``` + +注意,这会完全展开使系统进入 `graphical.target` 运行模式所需的顶层目标单元列表。也可以使用 `--all` 选项来展开所有其它单元。 + +``` +systemctl list-dependencies --all graphical.target +``` + +你可以使用 `less` 命令来搜索诸如 `target`、`slice` 和 `socket` 之类的字符串。 + +现在尝试下面的方法。 + +``` +systemctl list-dependencies multi-user.target +``` + +和 + +``` +systemctl list-dependencies rescue.target +``` + +和 + +``` +systemctl list-dependencies local-fs.target +``` + +和 + +``` +systemctl list-dependencies dbus.service +``` + +这个工具帮助我可视化我正用的主机的启动依赖细节。继续花一些时间探索一个或多个 Linux 主机的启动树。但是要小心,因为 systemctl 手册页包含以下注释: + +> “请注意,此命令仅列出当前被服务管理器加载到内存的单元。尤其是,此命令根本不适合用于获取特定单元的全部反向依赖关系列表,因为它不会列出被单元声明了但是未加载的依赖项。” + +### 结尾语 + +即使在没有深入研究 systemd 之前,很明显能看出它既强大又复杂。显然,systemd 不是单一、庞大、独体且不可知的二进制文件。相反,它是由许多较小的组件和旨在执行特定任务的子命令组成。 + +本系列的下一篇文章将更详细地探讨 systemd 的启动,以及 systemd 的配置文件,更改默认的目标以及如何创建简单服务单元。 + +### 资源 + +互联网上有大量关于 systemd 的信息,但是很多都很简短、晦涩甚至是带有误导。除了本文提到的资源外,以下网页还提供了有关 systemd 启动的更详细和可靠的信息。 + +* Fedora 项目有一个很好的实用的 [systemd 指南][7]。它有你需要知道的通过 systemd 来配置、管理和维护 Fedora 主机所需的几乎所有知识。 +* Fedora 项目还有一个不错的[速记表][8],将老的 SystemV 命令与对比的 systemd 命令相互关联。 +* 有关 systemd 的详细技术信息及创建它的原因,请查看 [Freedesktop.org][9] 对 [systemd 描述][10]。 +* [Linux.com][11] 的“systemd 的更多乐趣”提供了更高级的 systemd [信息和技巧][12]。 + +还有针对 Linux 系统管理员的一系列技术性很强的文章,作者是 systemd 的设计师和主要开发者 Lennart Poettering。这些文章是在 2010 年 4 月至 2011 年 9 月之间撰写的,但它们现在和那时一样有用。关于 systemd 及其生态的其它许多好文都基于这些论文。 + +* [重新思考 1 号进程][13] +* [systemd 系统管理员篇 I][14] +* [systemd 系统管理员篇 II][15] +* [systemd 系统管理员篇 III][16] +* [systemd 系统管理员篇 IV][17] +* [systemd 系统管理员篇 V][18] +* [systemd 系统管理员篇 VI][19] +* [systemd 系统管理员篇 VII][20] +* [systemd 系统管理员篇 VIII][21] +* [systemd 系统管理员篇 IX][22] +* [systemd 系统管理员篇 X][23] +* [systemd 系统管理员篇 XI][24] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/systemd + +作者:[David Both][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/car-penguin-drive-linux-yellow.png?itok=twWGlYAc (Penguin driving a car with a yellow background) +[2]: http://www.both.org/?page_id=1183 +[3]: http://www.osnews.com/story/28026/Editorial_Thoughts_on_Systemd_and_the_Freedom_to_Choose +[4]: https://www.zdnet.com/article/linus-torvalds-and-others-on-linuxs-systemd/ +[5]: http://0pointer.de/blog/projects/the-biggest-myths.html +[6]: https://opensource.com/sites/default/files/uploads/systemd-architecture.png (systemd architecture) +[7]: https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html +[8]: https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet +[9]: http://Freedesktop.org +[10]: http://www.freedesktop.org/wiki/Software/systemd +[11]: http://Linux.com +[12]: https://www.linux.com/training-tutorials/more-systemd-fun-blame-game-and-stopping-services-prejudice/ +[13]: http://0pointer.de/blog/projects/systemd.html +[14]: http://0pointer.de/blog/projects/systemd-for-admins-1.html +[15]: http://0pointer.de/blog/projects/systemd-for-admins-2.html +[16]: http://0pointer.de/blog/projects/systemd-for-admins-3.html +[17]: http://0pointer.de/blog/projects/systemd-for-admins-4.html +[18]: http://0pointer.de/blog/projects/three-levels-of-off.html +[19]: http://0pointer.de/blog/projects/changing-roots +[20]: http://0pointer.de/blog/projects/blame-game.html +[21]: http://0pointer.de/blog/projects/the-new-configuration-files.html +[22]: http://0pointer.de/blog/projects/on-etc-sysinit.html +[23]: http://0pointer.de/blog/projects/instances.html +[24]: http://0pointer.de/blog/projects/inetd.html diff --git a/published/202005/20200417 Create a SDN on Linux with open source.md b/published/202005/20200417 Create a SDN on Linux with open source.md new file mode 100644 index 0000000000..e05b649ee1 --- /dev/null +++ b/published/202005/20200417 Create a SDN on Linux with open source.md @@ -0,0 +1,185 @@ +[#]: collector: (lujun9972) +[#]: translator: (messon007) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12199-1.html) +[#]: subject: (Create a SDN on Linux with open source) +[#]: via: (https://opensource.com/article/20/4/quagga-linux) +[#]: author: (M Umer https://opensource.com/users/noisybotnet) + +在 Linux 上使用开源软件创建 SDN +====== + +> 使用开源路由协议栈 Quagga,使你的 Linux 系统成为一台路由器。 + +![](https://img.linux.net.cn/data/attachment/album/202005/09/093541rqx3zr5dxn3yvnq6.jpg) + +网络路由协议分为两大类:内部网关协议和外部网关协议。路由器使用内部网关协议在单个自治系统内共享信息。如果你用的是 Linux,则可以通过开源(GPLv2)路由协议栈 [Quagga][2] 使其表现得像一台路由器。 + +### Quagga 是什么? + +Quagga 是一个[路由软件包][3],并且是 [GNU Zebra][4] 的一个分支。它为类 Unix 平台提供了所有主流路由协议的实现,例如开放最短路径优先(OSPF),路由信息协议(RIP),边界网关协议(BGP)和中间系统到中间系统协议(IS-IS)。 + +尽管 Quagga 实现了 IPv4 和 IPv6 的路由协议,但它并不是一个完整的路由器。一个真正的路由器不仅实现了所有路由协议,而且还有转发网络流量的能力。 Quagga 仅仅实现了路由协议栈,而转发网络流量的工作由 Linux 内核处理。 + +### 架构 + +Quagga 通过特定协议的守护程序实现不同的路由协议。守护程序名称与路由协议相同,加了字母“d”作为后缀。Zebra 是核心,也是与协议无关的守护进程,它为内核提供了一个[抽象层][5],并通过 TCP 套接字向 Quagga 客户端提供 Zserv API。每个特定协议的守护程序负责运行相关的协议,并基于交换的信息来建立路由表。 + +![Quagga architecture][6] + +### 环境 + +本教程通过 Quagga 实现的 OSPF 协议来配置动态路由。该环境包括两个名为 Alpha 和 Beta 的 CentOS 7.7 主机。两台主机共享访问 **192.168.122.0/24** 网络。 + +**主机 Alpha:** + +IP:192.168.122.100/24 +网关:192.168.122.1 + +**主机 Beta:** + +IP:192.168.122.50/24 +网关:192.168.122.1 + +### 安装软件包 + +首先,在两台主机上安装 Quagga 软件包。它存在于 CentOS 基础仓库中: + +``` +yum install quagga -y +``` + +### 启用 IP 转发 + +接下来,在两台主机上启用 IP 转发,因为它将由 Linux 内核来执行: + +``` +sysctl -w net.ipv4.ip_forward = 1 +sysctl -p +``` + +### 配置 + +现在,进入 `/etc/quagga` 目录并为你的设置创建配置文件。你需要三个文件: + +* `zebra.conf`:Quagga 守护程序的配置文件,你可以在其中定义接口及其 IP 地址和 IP 转发 +* `ospfd.conf`:协议配置文件,你可以在其中定义将通过 OSPF 协议提供的网络 +* `daemons`:你将在其中指定需要运行的相关的协议守护程序 + +在主机 Alpha 上, + +``` + [root@alpha]# cat /etc/quagga/zebra.conf +interface eth0 + ip address 192.168.122.100/24 + ipv6 nd suppress-ra +interface eth1 + ip address 10.12.13.1/24 + ipv6 nd suppress-ra +interface lo +ip forwarding +line vty + +[root@alpha]# cat /etc/quagga/ospfd.conf +interface eth0 +interface eth1 +interface lo +router ospf + network 192.168.122.0/24 area 0.0.0.0 + network 10.12.13.0/24 area 0.0.0.0 +line vty + +[root@alphaa ~]# cat /etc/quagga/daemons +zebra=yes +ospfd=yes +``` + +在主机 Beta 上, + +``` +[root@beta quagga]# cat zebra.conf +interface eth0 + ip address 192.168.122.50/24 + ipv6 nd suppress-ra +interface eth1 + ip address 10.10.10.1/24 + ipv6 nd suppress-ra +interface lo +ip forwarding +line vty + +[root@beta quagga]# cat ospfd.conf +interface eth0 +interface eth1 +interface lo +router ospf + network 192.168.122.0/24 area 0.0.0.0 + network 10.10.10.0/24 area 0.0.0.0 +line vty + +[root@beta ~]# cat /etc/quagga/daemons +zebra=yes +ospfd=yes +``` + +### 配置防火墙 + +要使用 OSPF 协议,必须允许它通过防火墙: + +``` +firewall-cmd --add-protocol=ospf –permanent + +firewall-cmd –reload +``` + +现在,启动 `zebra` 和 `ospfd` 守护程序。 + +``` +# systemctl start zebra +# systemctl start ospfd +``` + +用下面命令在两个主机上查看路由表: + +``` +[root@alpha ~]# ip route show   +default via 192.168.122.1 dev eth0 proto static metric 100 +10.10.10.0/24 via 192.168.122.50 dev eth0 proto zebra metric 20 +10.12.13.0/24 dev eth1 proto kernel scope link src 10.12.13.1 +192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.100 metric 100 +``` + +你可以看到 Alpha 上的路由表包含通过 **192.168.122.50** 到达 **10.10.10.0/24** 的路由项,它是通过协议 zebra 获取的。同样,在主机 Beta 上,该表包含通过 **192.168.122.100** 到达网络 **10.12.13.0/24** 的路由项。 + +``` +[root@beta ~]# ip route show +default via 192.168.122.1 dev eth0 proto static metric 100 +10.10.10.0/24 dev eth1 proto kernel scope link src 10.10.10.1 +10.12.13.0/24 via 192.168.122.100 dev eth0 proto zebra metric 20 +192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.50 metric 100 +``` + +### 结论 + +如你所见,环境和配置相对简单。要增加复杂性,你可以向路由器添加更多网络接口,以为更多网络提供路由。你也可以使用相同的方法来实现 BGP 和 RIP 协议。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/quagga-linux + +作者:[M Umer][a] +选题:[lujun9972][b] +译者:[messon007](https://github.com/messon007) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/noisybotnet +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://www.quagga.net/ +[3]: https://en.wikipedia.org/wiki/Quagga_(software) +[4]: https://www.gnu.org/software/zebra/ +[5]: https://en.wikipedia.org/wiki/Abstraction_layer +[6]: https://opensource.com/sites/default/files/uploads/quagga_arch.png (Quagga architecture) diff --git a/published/202005/20200417 How to compress files on Linux 5 ways.md b/published/202005/20200417 How to compress files on Linux 5 ways.md new file mode 100644 index 0000000000..5ba0c7feeb --- /dev/null +++ b/published/202005/20200417 How to compress files on Linux 5 ways.md @@ -0,0 +1,203 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12190-1.html) +[#]: subject: (How to compress files on Linux 5 ways) +[#]: via: (https://www.networkworld.com/article/3538471/how-to-compress-files-on-linux-5-ways.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 上压缩文件的 5 种方法 +====== + +> 在 Linux 系统上有很多可以用于压缩文件的工具,但它们的表现并不都是一样的,也不是所有的压缩效果都是一样的。在这篇文章中,我们比较其中的五个工具。 + +![](https://img.linux.net.cn/data/attachment/album/202005/06/231536tgxma941yb8dgl53.jpg) + +在 Linux 上有不少用于压缩文件的命令。最新最有效的一个方法是 `xz`,但是所有的方法都有节省磁盘空间和维护备份文件供以后使用的优点。在这篇文章中,我们将比较这些压缩命令并指出显著的不同。 + +### tar + +`tar` 命令不是专门的压缩命令。它通常用于将多个文件拉入一个单个的文件中,以便容易地传输到另一个系统,或者将文件作为一个相关的组进行备份。它也提供压缩的功能,这就很有意义了,附加一个 `z` 压缩选项能够实现压缩文件。 + +当使用 `z` 选项为 `tar` 命令附加压缩过程时,`tar` 使用 `gzip` 来进行压缩。 + +就像压缩一组文件一样,你可以使用 `tar` 来压缩单个文件,尽管这种操作与直接使用 `gzip` 相比没有特别的优势。要使用 `tar` 这样做,只需要使用 `tar cfz newtarfile filename` 命令来标识要压缩的文件,就像标识一组文件一样,像这样: + +``` +$ tar cfz bigfile.tgz bigfile + ^ ^ + | | + +- 新的文件 +- 将被压缩的文件 + +$ ls -l bigfile* +-rw-rw-r-- 1 shs shs 103270400 Apr 16 16:09 bigfile +-rw-rw-r-- 1 shs shs 21608325 Apr 16 16:08 bigfile.tgz +``` + +注意,文件的大小显著减少了。 + +如果你愿意,你可以使用 `tar.gz` 扩展名,这可能会使文件的特征更加明显,但是大多数的 Linux 用户将很可能会意识到与 `tgz` 的意思是一样的 – `tar` 和 `gz` 的组合来显示文件是一个压缩的 tar 文件。在压缩完成后,你将同时得到原始文件和压缩文件。 + +要将很多文件收集在一起并在一个命令中压缩出 “tar ball”,使用相同的语法,但要指定要包含的文件为一组,而不是单个文件。这里有一个示例: + +``` +$ tar cfz bin.tgz bin/* + ^ ^ + | +-- 将被包含的文件 + + 新的文件 +``` + +### zip + +`zip` 命令创建一个压缩文件,与此同时保留原始文件的完整性。语法像使用 `tar` 一样简单,只是你必需记住,你的原始文件名称应该是命令行上的最后一个参数。 + +``` +$ zip ./bigfile.zip bigfile +updating: bigfile (deflated 79%) +$ ls -l bigfile bigfile.zip +-rw-rw-r-- 1 shs shs 103270400 Apr 16 11:18 bigfile +-rw-rw-r-- 1 shs shs 21606889 Apr 16 11:19 bigfile.zip +``` + +### gzip + +`gzip` 命令非常容易使用。你只需要键入 `gzip`,紧随其后的是你想要压缩的文件名称。不像上述描述的命令,`gzip` 将“就地”“加密”文件。换句话说,原始文件将被“加密”文件替换。 + +``` +$ gzip bigfile +$ ls -l bigfile* +-rw-rw-r-- 1 shs shs 21606751 Apr 15 17:57 bigfile.gz +``` + +### bzip2 + +像使用 `gzip` 命令一样,`bzip2` 将在你选择的文件“就地”压缩,不留下原始文件。 + +``` +$ bzip bigfile +$ ls -l bigfile* +-rw-rw-r-- 1 shs shs 18115234 Apr 15 17:57 bigfile.bz2 +``` + +### xz + +`xz` 是压缩命令团队中的一个相对较新的成员,在压缩文件的能力方面,它是一个领跑者。像先前的两个命令一样,你只需要将文件名称提供给命令。再强调一次,原始文件被就地压缩。 + +``` +$ xz bigfile +$ ls -l bigfile* +-rw-rw-r-- 1 shs shs 13427236 Apr 15 17:30 bigfile.xz +``` + +对于大文件来说,你可能会注意到 `xz` 将比其它的压缩命令花费更多的运行时间,但是压缩的结果却是非常令人赞叹的。 + +### 对比 + +大多数人都听说过“大小不是一切”。所以,让我们比较一下文件大小以及一些当你计划如何压缩文件时的问题。 + +下面显示的统计数据都与压缩单个文件相关,在上面显示的示例中使用 `bigfile`。这个文件是一个大的且相当随机的文本文件。压缩率在一定程度上取决于文件的内容。 + +#### 大小减缩率 + +当比较时,上面显示的各种压缩命产生下面的结果。百分比表示压缩文件与原始文件的比较效果。 + +``` +-rw-rw-r-- 1 shs shs 103270400 Apr 16 14:01 bigfile +------------------------------------------------------ +-rw-rw-r-- 1 shs shs 18115234 Apr 16 13:59 bigfile.bz2 ~17% +-rw-rw-r-- 1 shs shs 21606751 Apr 16 14:00 bigfile.gz ~21% +-rw-rw-r-- 1 shs shs 21608322 Apr 16 13:59 bigfile.tgz ~21% +-rw-rw-r-- 1 shs shs 13427236 Apr 16 14:00 bigfile.xz ~13% +-rw-rw-r-- 1 shs shs 21606889 Apr 16 13:59 bigfile.zip ~21% +``` + +`xz` 命令获胜,最终只有压缩文件 13% 的大小,但是所有这些压缩命令都相当显著地减少原始文件的大小。 + +#### 是否替换原始文件 + +`bzip2`、`gzip` 和 `xz` 命令都用压缩文件替换原始文件。`tar` 和 `zip` 命令不替换。 + +#### 运行时间 + +`xz` 命令似乎比其它命令需要花费更多的时间来“加密”文件。对于 `bigfile` 来说,大概的时间是: + +``` +命令 运行时间 +tar 4.9 秒 +zip 5.2 秒 +bzip2 22.8 秒 +gzip 4.8 秒 +xz 50.4 秒 +``` + +解压缩文件很可能比压缩时间要短得多。 + +#### 文件权限 + +不管你对压缩文件设置什么权限,压缩文件的权限将基于你的 `umask` 设置,但 `bzip2` 除外,它保留了原始文件的权限。 + +#### 与 Windows 的兼容性 + +`zip` 命令创建的文件可以在 Windows 系统以及 Linux 和其他 Unix 系统上使用(即解压),而无需安装其他工具,无论这些工具可能是可用还是不可用的。 + +### 解压缩文件 + +解压文件的命令与压缩文件的命令类似。在我们运行上述压缩命令后,这些命令用于解压缩 `bigfile`: + + * tar: `tar xf bigfile.tgz` + * zip: `unzip bigfile.zip` + * gzip: `gunzip bigfile.gz` + * bzip2: `bunzip2 bigfile.gz2` + * xz: `xz -d bigfile.xz` 或 `unxz bigfile.xz` + +### 自己运行压缩对比 + +如果你想自己运行一些测试,抓取一个大的且可以替换的文件,并使用上面显示的每个命令来压缩它 —— 最好使用一个新的子目录。你可能需要先安装 `xz`,如果你想在测试中包含它的话。这个脚本可能更容易地进行压缩,但是可能需要花费几分钟完成。 + +``` +#!/bin/bash + +# 询问用户文件名称 +echo -n "filename> " +read filename + +# 你需要这个,因为一些命令将替换原始文件 +cp $filename $filename-2 + +# 先清理(以免先前的结果仍然可用) +rm $filename.* + +tar cvfz ./$filename.tgz $filename > /dev/null +zip $filename.zip $filename > /dev/null +bzip2 $filename +# 恢复原始文件 +cp $filename-2 $filename +gzip $filename +# 恢复原始文件 +cp $filename-2 $filename +xz $filename + +# 显示结果 +ls -l $filename.* + +# 替换原始文件 +mv $filename-2 $filename +``` + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3538471/how-to-compress-files-on-linux-5-ways.html + +作者:[Sandra Henry-Stocker][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://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/blog/itaas-and-the-corporate-storage-technology/?utm_source=IDG&utm_medium=promotions&utm_campaign=HPE22140&utm_content=sidebar (ITAAS and Corporate Storage Strategy) +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/202005/20200420 4 Git scripts I can-t live without.md b/published/202005/20200420 4 Git scripts I can-t live without.md new file mode 100644 index 0000000000..43102c69e6 --- /dev/null +++ b/published/202005/20200420 4 Git scripts I can-t live without.md @@ -0,0 +1,192 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12180-1.html) +[#]: subject: (4 Git scripts I can't live without) +[#]: via: (https://opensource.com/article/20/4/git-extras) +[#]: author: (Vince Power https://opensource.com/users/vincepower) + +4 个不可或缺的 Git 脚本 +====== + +> Git Extras 版本库包含了 60 多个脚本,它们是 Git 基本功能的补充。以下是如何安装、使用和贡献的方法。 + +![](https://img.linux.net.cn/data/attachment/album/202005/03/211446dshwbzoh235b3gre.jpg) + +2005 年,[Linus Torvalds][2] 创建了 [Git][3],以取代他之前用于维护 Linux 内核的分布式源码控制管理的专有解决方案。从那时起,Git 已经成为开源和云原生开发团队的主流版本控制解决方案。 + +但即使是像 Git 这样功能丰富的应用程序,也没有人们想要或需要的每个功能,所以会有人花大力气去创建这些缺少的功能。就 Git 而言,这个人就是 [TJ Holowaychuk][4]。他的 [Git Extras][5] 项目承载了 60 多个“附加功能”,这些功能扩展了 Git 的基本功能。 + +### 使用 Git 附加功能 + +下面介绍一下如何使用四种最受欢迎的 Git 附加功能。 + +#### git-ignore + +`git ignore` 是一个方便的附加功能,它可以让你手动添加文件类型和注释到 `.git-ignore` 文件中,而不需要打开文本编辑器。它可以操作你的个人用户帐户的全局忽略文件和单独用于你正在工作的版本库中的忽略文件。 + +在不提供参数的情况下执行 `git ignore` 会先列出全局忽略文件,然后是本地的忽略文件。 + +``` +$ git ignore +Global gitignore: /home/alice/.gitignore +# Numerous always-ignore extensions +*.diff +*.err +*.orig +*.rej +*.swo +*.swp +*.vi +*~ +*.sass-cache + +# OS or Editor folders +Thumbs.db +--------------------------------- +Local gitignore: .gitignore +nbproject +``` + +#### git-info + +`git info` 可以检索你所需要的所有信息,以获取你正在使用的版本库的上下文信息。它包括远程 URL、远程分支、本地分支、配置信息和最后一次的提交信息。 + +``` +$ git info + +## Remote URLs: + +origin git@github.com:sampleAuthor/git-extras.git (fetch) +origin git@github.com:sampleAuthor/git-extras.git (push) + +## Remote Branches: + +origin/HEAD -> origin/master +origin/myBranch + +## Local Branches: + +myBranch +* master + +## Most Recent Commit: + +commit e3952df2c172c6f3eb533d8d0b1a6c77250769a7 +Author: Sample Author + +Added git-info command. + +Type ´git log´ for more commits, or ´git show ´ for full commit details. + +## Configuration (.git/config): + +color.diff=auto +color.status=auto +color.branch=auto +user.name=Sample Author +user.email=sampleAuthor@gmail.com +core.repositoryformatversion=0 +core.filemode=true +core.bare=false +core.logallrefupdates=true +core.ignorecase=true +remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* +remote.origin.url=git@github.com:mub/git-extras.git +branch.master.remote=origin +branch.master.merge=refs/heads/master +``` + +#### git-mr 和 git-pr + +这些附加功能的作用类似,工作方式也基本相同。 + +* `git mr` 检出来自 GitLab 的合并请求。 +* `git pr` 检出来自 GitHub 的拉取请求。 + +无论是哪种情况,你只需要合并请求号/拉取请求号或完整的 URL,它就会抓取远程引用,检出分支,并调整配置,这样 Git 就知道要替换哪个分支了。 + +``` +$ git mr 51 +From gitlab.com:owner/repository + * [new ref] refs/merge-requests/51/head -> mr/51 +Switched to branch 'mr/51' +``` + +#### git-release + +通过将 `commit`、`tag` 和 `push` 合并到一个命令中,`git release` 可以节省大量的按键来执行这三个命令,而这三个命令往往是依次运行的。 + +要用特定的 `` 和自定义消息提交: + +``` +$ git release 0.1.0 -m <+ powerful feature added> +``` + +#### 其他附加功能 + +这只是该版本库中 60 多个 Git 附加功能中的四个命令。要访问 Git Extras 中的全部命令,请查看该源代码库中的 [Commands.md][8] 文件,或者在安装 Git Extras 后运行以下命令。 + +``` +$ git extras --help +``` + +### 安装 Git 附加功能 + +使用 Git 附加功能的主要前提是安装了 Git 的命令行版本。如果你打算从源码中构建,还需要有额外的工具(例如:`make`)。 + +如果你使用的是最新版本的 macOS,那么 Git 附加功能的安装最好使用 [Homebrew][9](和大多数开源工具一样)。 + +``` +$ brew install git-extras +``` + +在 Linux 上,每个平台原生的包管理器中都包含有 Git Extras。有时,你需要启用额外的仓库,比如在 CentOS 上的 [EPEL][10],然后运行一条命令。 + +``` +$ sudo yum install git-extras +``` + +其他 Linux 发行版、BSD 和其他平台的完整安装说明可以在该版本库的 [Installation.md][11] 文件中找到。 + +### 贡献 + +你是否认为 Git 中有缺少的功能,并且已经构建了一个脚本来处理它?为什么不把它作为 Git Extras 发布版的一部分,与全世界分享呢? + +要做到这一点,请将该功能贡献到 Git Extras 仓库中。更多具体细节请参见仓库中的 [CONTRIBUTING.md][12] 文件,但基本的操作方法很简单: + +1. 创建一个处理该功能的 Bash 脚本。 +2. 创建一个基本的 man 文件,让大家知道如何使用它。 +3. 更新命令列表和补完脚本,让人们知道这个功能的存在。 +4. 运行完整性检查,确保你没有破坏任何东西。 +5. 为你的功能创建一个拉取请求。 + +向 Git Extras 贡献贡献,会让你的 Git 用户的生活更轻松一些。你可以在项目的 [README][13] 中了解更多。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/git-extras + +作者:[Vince Power][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/vincepower +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://en.wikipedia.org/wiki/Linus_Torvalds +[3]: https://git-scm.com/ +[4]: https://github.com/tj +[5]: https://github.com/tj/git-extras +[6]: mailto:git@github.com +[7]: mailto:sampleAuthor@gmail.com +[8]: https://github.com/tj/git-extras/blob/master/Commands.md +[9]: https://brew.sh/ +[10]: https://fedoraproject.org/wiki/EPEL +[11]: https://github.com/tj/git-extras/blob/master/Installation.md +[12]: https://github.com/tj/git-extras/blob/master/CONTRIBUTING.md +[13]: https://github.com/tj/git-extras/blob/master/Readme.md diff --git a/published/202005/20200421 Using Python to visualize COVID-19 projections.md b/published/202005/20200421 Using Python to visualize COVID-19 projections.md new file mode 100644 index 0000000000..aaf5fc72d0 --- /dev/null +++ b/published/202005/20200421 Using Python to visualize COVID-19 projections.md @@ -0,0 +1,238 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12172-1.html) +[#]: subject: (Using Python to visualize COVID-19 projections) +[#]: via: (https://opensource.com/article/20/4/python-data-covid-19) +[#]: author: (AnuragGupta https://opensource.com/users/999anuraggupta) + +使用 Python 来可视化 COVID-19 预测 +====== + +> 我将演示如何利用提供的全球病毒传播的开放数据,使用开源库来创建两个可视效果。 + +![](https://img.linux.net.cn/data/attachment/album/202005/01/193624a2p2osojyf0yg4go.jpg) + +使用 [Python][2] 和一些图形库,你可以预测 COVID-19 确诊病例总数,也可以显示一个国家(本文以印度为例)在给定日期的死亡总数。人们有时需要帮助解释和处理数据的意义,所以本文还演示了如何为五个国家创建一个动画横条形图,以显示按日期显示病例的变化。 + +### 印度的确诊病例和死亡人数预测 + +这要分三步来完成。 + +#### 1、下载数据 + +科学数据并不总是开放的,但幸运的是,许多现代科学和医疗机构都乐于相互之间及与公众共享信息。关于 COVID-19 病例的数据可以在网上查到,并且经常更新。 + +要解析这些数据,首先必须先下载。 。 + +直接将数据加载到 Pandas `DataFrame` 中。Pandas 提供了一个函数 `read_csv()`,它可以获取一个 URL 并返回一个 `DataFrame` 对象,如下所示。 + +``` +import pycountry +import plotly.express as px +import pandas as pd +URL_DATASET = r'https://raw.githubusercontent.com/datasets/covid-19/master/data/countries-aggregated.csv' +df1 = pd.read_csv(URL_DATASET) +print(df1.head(3)) # 获取数据帧中的前 3 项 +print(df1.tail(3)) # 获取数据帧中的后 3 项 +``` + +数据集的顶行包含列名。 + +1. `Date` +2. `Country` +3. `Confirmed` +4. `Recovered` +5. `Deaths` + +`head` 查询的输出包括一个唯一的标识符(不作为列列出)和每个列的条目。 + +``` +0 2020-01-22 Afghanistan 0 0 0 +1 2020-01-22 Albania 0 0 0 +1 2020-01-22 Algeria 0 0 0 +``` + +`tail` 查询的输出类似,但包含数据集的尾端。 + +``` +12597 2020-03-31 West Bank and Gaza 119 18 1 +12598 2020-03-31 Zambia 35 0 0 +12599 2020-03-31 Zimbabwe 8 0 1 +``` + +从输出中,可以看到 DataFrame(`df1`)有以下几个列: + +1. 日期 +2. 国家 +3. 确诊 +4. 康复 +5. 死亡 + +此外,你可以看到 `Date` 栏中的条目从 1 月 22 日开始到 3 月 31 日。这个数据库每天都会更新,所以你会有当前的值。 + +#### 2、选择印度的数据 + +在这一步中,我们将只选择 DataFrame 中包含印度的那些行。这在下面的脚本中可以看到。 + +``` +#### ----- Step 2 (Select data for India)---- +df_india = df1[df1['Country'] == 'India'] +print(df_india.head(3)) +``` + +#### 3、数据绘图 + +在这里,我们创建一个条形图。我们将把日期放在 X 轴上,把确诊的病例数和死亡人数放在 Y 轴上。这一部分的脚本有以下几个值得注意的地方。 + + * `plt.rcParams["figure.figsize"]=20,20` 这一行代码只适用于 Jupyter。所以如果你使用其他 IDE,请删除它。 + * 注意这行代码:`ax1 = plt.gca()`。为了确保两个图,即确诊病例和死亡病例的图都被绘制在同一个图上,我们需要给第二个图的 `ax` 对象。所以我们使用 `gca()` 来完成这个任务。(顺便说一下,`gca` 代表 “获取当前坐标轴get current axis”) + +完整的脚本如下所示。 + +``` +# Author:- Anurag Gupta # email:- 999.anuraggupta@gmail.com +%matplotlib inline +import matplotlib.pyplot as plt +import pandas as pd + +#### ----- Step 1 (Download data)---- +URL_DATASET = r'https://raw.githubusercontent.com/datasets/covid-19/master/data/countries-aggregated.csv' +df1 = pd.read_csv(URL_DATASET) +# print(df1.head(3)) # Uncomment to see the dataframe + +#### ----- Step 2 (Select data for India)---- +df_india = df1[df1['Country'] == 'India'] +print(df_india.head(3)) + +#### ----- Step 3 (Plot data)---- +# Increase size of plot +plt.rcParams["figure.figsize"]=20,20 # Remove if not on Jupyter +# Plot column 'Confirmed' +df_india.plot(kind = 'bar', x = 'Date', y = 'Confirmed', color = 'blue') + +ax1 = plt.gca() +df_india.plot(kind = 'bar', x = 'Date', y = 'Deaths', color = 'red', ax = ax1) +plt.show() +``` + +整个脚本[可在 GitHub 上找到][4]。 + +### 为五个国家创建一个动画水平条形图 + +关于 Jupyter 的注意事项:要在 Jupyter 中以动态动画的形式运行,而不是静态 png 的形式,你需要在单元格的开头添加一个神奇的命令,即: `%matplotlib notebook`。这将使图形保持动态,而不是显示为静态的 png 文件,因此也可以显示动画。如果你在其他 IDE 上,请删除这一行。 + +#### 1、下载数据 + +这一步和前面的脚本完全一样,所以不需要重复。 + +#### 2、创建一个所有日期的列表 + +如果你检查你下载的数据,你会发现它有一列 `Date`。现在,这一列对每个国家都有一个日期值。因此,同一个日期会出现多次。我们需要创建一个只具有唯一值的日期列表。这会用在我们条形图的 X 轴上。我们有一行代码,如 `list_dates = df[‘Date’].unique()`。`unique()` 方法将只提取每个日期的唯一值。 + +#### 3、挑选五个国家并创建一个 `ax` 对象。 + +做一个五个国家的名单。(你可以选择你喜欢的国家,也可以增加或减少国家的数量。)我也做了一个五个颜色的列表,每个国家的条形图的颜色对应一种。(如果你喜欢的话,也可以改一下。)这里有一行重要的代码是:`fig, ax = plt.subplots(figsize=(15, 8))`。这是创建一个 `ax` 对象所需要的。 + +#### 4、编写回调函数 + +如果你想在 Matplotlib 中做动画,你需要创建一个名为 `matplotlib.animation.FuncAnimation` 的类的对象。这个类的签名可以在网上查到。这个类的构造函数,除了其他参数外,还需要一个叫 `func` 的参数,你必须给这个参数一个回调函数。所以在这一步中,我们会写个回调函数,这个回调函数会被反复调用,以渲染动画。 + +#### 5、创建 `FuncAnimation` 对象 + +这一步在上一步中已经部分说明了。 + +我们创建这个类的对象的代码是: + +``` +my_anim = animation.FuncAnimation(fig = fig, func = plot_bar, + frames = list_dates, blit = True, + interval=20) +``` + +要给出的三个重要参数是: + +* `fig`,必须给出一个 fig 对象,也就是我们之前创建的 fig 对象。 +* `func`,必须是回调函数。 +* `frames`,必须包含要做动画的变量。在我们这里,它是我们之前创建的日期列表。 + +#### 6、将动画保存为 mp4 文件 + +你可以将创建的动画保存为 mp4 文件。但是,你需要 `ffmpeg`。你可以用 `pip` 下载:`pip install ffmpeg-python`,或者用 conda(在 Jupyter 上):`install -c conda-forge ffmpeg`。 + +最后,你可以使用 `plt.show()` 运行动画。请注意,在许多平台上,`ffmpeg` 可能无法正常工作,可能需要进一步“调整”。 + +``` +%matplotlib notebook +# Author:- Anurag Gupta # email:- 999.anuraggupta@gmail.com +import pandas as pd +import matplotlib.pyplot as plt +import matplotlib.animation as animation +from time import sleep + +#### ---- Step 1:- Download data +URL_DATASET = r'https://raw.githubusercontent.com/datasets/covid-19/master/data/countries-aggregated.csv' +df = pd.read_csv(URL_DATASET, usecols = ['Date', 'Country', 'Confirmed']) +# print(df.head(3)) # uncomment this to see output + +#### ---- Step 2:- Create list of all dates +list_dates = df['Date'].unique() +# print(list_dates) # Uncomment to see the dates + +#### --- Step 3:- Pick 5 countries. Also create ax object +fig, ax = plt.subplots(figsize=(15, 8)) +# We will animate for these 5 countries only +list_countries = ['India', 'China', 'US', 'Italy', 'Spain'] +# colors for the 5 horizontal bars +list_colors = ['black', 'red', 'green', 'blue', 'yellow'] + +### --- Step 4:- Write the call back function +# plot_bar() is the call back function used in FuncAnimation class object +def plot_bar(some_date): + df2 = df[df['Date'].eq(some_date)] + ax.clear() + # Only take Confirmed column in descending order + df3 = df2.sort_values(by = 'Confirmed', ascending = False) + # Select the top 5 Confirmed countries + df4 = df3[df3['Country'].isin(list_countries)] + # print(df4) # Uncomment to see that dat is only for 5 countries + sleep(0.2) # To slow down the animation + # ax.barh() makes a horizontal bar plot. + return ax.barh(df4['Country'], df4['Confirmed'], color= list_colors) + +###----Step 5:- Create FuncAnimation object--------- +my_anim = animation.FuncAnimation(fig = fig, func = plot_bar, + frames= list_dates, blit=True, + interval=20) + +### --- Step 6:- Save the animation to an mp4 +# Place where to save the mp4. Give your file path instead +path_mp4 = r'C:\Python-articles\population_covid2.mp4' +# my_anim.save(path_mp4, fps=30, extra_args=['-vcodec', 'libx264']) +my_anim.save(filename = path_mp4, writer = 'ffmpeg', + fps=30, + extra_args= ['-vcodec', 'libx264', '-pix_fmt', 'yuv420p']) +plt.show() +``` + +完整的脚本[可以在 GitHub 上找到][5]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/python-data-covid-19 + +作者:[AnuragGupta][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/999anuraggupta +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/colorful_sound_wave.png?itok=jlUJG0bM (Colorful sound wave graph) +[2]: https://opensource.com/resources/python +[3]: mailto:999.anuraggupta@gmail.com +[4]: https://raw.githubusercontent.com/ag999git/jupyter_notebooks/master/corona_bar_india +[5]: https://raw.githubusercontent.com/ag999git/jupyter_notebooks/master/corona_bar_animated diff --git a/published/202005/20200423 Difference Between YUM and RPM Package Manager.md b/published/202005/20200423 Difference Between YUM and RPM Package Manager.md new file mode 100644 index 0000000000..bf916108e1 --- /dev/null +++ b/published/202005/20200423 Difference Between YUM and RPM Package Manager.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12170-1.html) +[#]: subject: (Difference Between YUM and RPM Package Manager) +[#]: via: (https://www.2daygeek.com/comparison-difference-between-yum-vs-rpm/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +YUM 和 RPM 包管理器的不同之处 +====== + +![](https://img.linux.net.cn/data/attachment/album/202004/30/215525o4e88nen85d8dzd7.jpg) + +软件包管理器在 Linux 系统中扮演着重要的角色。它允许你安装、更新、查看、搜索和删除软件包,以满足你的需求。 + +每个发行版都有自己的一套包管理器,依据你的 Linux 发行版来分别使用它们。 + +RPM 是最古老的传统软件包管理器之一,它是为基于 Red Hat 的系统设计的,如 Red Hat Enterprise Linux(RHEL)、CentOS、Fedora 和 openSUSE(它基于 suse Enterprise Linux)等系统。但在依赖解析和包更新(全系统更新/升级)方面,RPM 包管理器有一个突出的限制。 + +> 如果你想知道 [YUM 和 DNF 包管理器的区别][1]请参考该文章。 + +这意味着 `yum` 可以自动下载并安装所有需要的依赖项,但 `rpm` 会告诉你安装一个依赖项列表,然后你必须手动安装。 + +当你想用 [rpm 命令][2] 安装一组包时,这实际上是不可能的,而且很费时间。 + +这时,[YUM 包管理器][3] 就派上了用场,解决了这两个问题。 + +### 什么是 RPM? + +RPM 指的是 RPM Package Manager(原名 Red Hat Package Manager),是一个功能强大的命令行包管理工具,是为 Red Hat 操作系统开发的。 + +它现在被用作许多 Linux 发行版的核心组件,如 Centos、Fedora、Oracle Linux、openSUSE 和 Mageia 等。 + +RPM 软件包管理器允许你在基于 RPM 的 Linux 系统上安装、升级、删除、查询和验证软件包。 + +RPM 文件的扩展名为 `.rpm`。RPM 包由一个存档文件组成,其中包含了一个特定包的库和依赖关系,这些库和依赖关系与系统上安装的其他包不冲突。 + +在 Linux 上有很多前端工具可以用来安装 RPM 包,与 RPM 工具相比,这些工具可以使安装过程更加高效,尤其是在处理依赖关系方面。 + +如果你想了解更多关于 Linux 发行版的前端包管理器的信息,请到下面的链接。 + +* [Linux 命令行包管理器列表][4] + +如果你想了解 Linux 的 GUI 包管理器,请到下面的链接。 + +* [Linux GUI 包管理器列表][5] + +### 什么是 YUM? + +Yum 是一个 Linux 操作系统上的自由开源的命令行包管理程序,它使用 RPM 包管理器。Yum 是一个 RPM 的前端工具,可以自动解决软件包的依赖关系。它可以从发行版官方仓库和其他第三方仓库中安装 RPM 软件包。 + +Yum 允许你在系统中安装、更新、搜索和删除软件包。如果你想让你的系统保持更新,你可以通过 yum-cron 启用自动更新。 + +此外,如果你需要的话,它还允许你在 `yum update` 中排除一个或多个软件包。 + +Yum 是默认安装的,你不需要安装它。 + +编号 | RPM | YUM +--- | --- | --- +1 | 红帽在 1997 年引入了 RPM | Yellowdog UPdater(YUP)开发于 1999-2001 年,YUM 于 2003 年取代了原来的 YUP 工具 +2 | RPM 代表 RPM Package manager(原名 Red Hat package manager) | YUM 代表 Yellowdog Updater Modified +3 | RPM 文件的命名规则如下,`httpd-2.4.6-92.el7.x86_64.rpm`:`httpd` - 实际的包名;`2.4.6` - 包发布版本号;`92` - 包发布子版本号;`el7` - Red Hat 版本;`x86_64` - 硬件架构;`rpm` - 文件扩展名 | 后台使用 rpm 数据库 +4 | 不解析依赖关系,你必须手动安装依赖 | 可以自动解析依赖关系并同时安装它们(任何包都会和它的依赖关系一起安装) +5 | 允许你同时安装多个版本的软件包 | 不允许,并显示该软件包已经安装 +6 | 当使用 RPM 命令安装一个软件包时,你必须提供 `.rpm` 软件包的确切位置 | 你可以安装仓库中的任何软件包,而你只需要知道软件包的名称就可以了 +7 | RPM 不依赖于 YUM | 它是一个前端工具,在后台使用 RPM 包管理器来管理包 +8 | RPM 在安装包的管理方面比较难 | YUM 是最简单的管理 RPM 包的方法 +9 | RPM 不能让你将整个系统升级到最新的版本 | YUM 可以让你将系统升级到最新的版本(例如 7.0 到 7.x 的小版本升级) +10 | RPM 不能让你自动更新/升级安装在系统上的软件包 | YUM 可以让你自动更新/升级系统上的更新 +11 | 不使用在线仓库来执行任何操作 | 完全依赖在线仓库来完成所有的工作 +12 | RPM 是一种包格式,它也是一个底层的包管理器,只做基本的事情 | 这是一个上层的包管理器前端,它可以完成你所需要的一切工作 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/comparison-difference-between-yum-vs-rpm/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-12161-1.html +[2]: https://www.2daygeek.com/linux-rpm-command-examples-manage-packages-fedora-centos-rhel-systems/ +[3]: https://www.2daygeek.com/linux-yum-command-examples-manage-packages-rhel-centos-systems/ +[4]: https://www.2daygeek.com/list-of-command-line-package-manager-for-linux/ +[5]: https://www.2daygeek.com/list-of-graphical-frontend-tool-for-linux-package-manager/ diff --git a/published/202005/20200424 16 Things to do After Installing Ubuntu 20.04.md b/published/202005/20200424 16 Things to do After Installing Ubuntu 20.04.md new file mode 100644 index 0000000000..ded221ab6c --- /dev/null +++ b/published/202005/20200424 16 Things to do After Installing Ubuntu 20.04.md @@ -0,0 +1,283 @@ +[#]: collector: (lujun9972) +[#]: translator: (qfzy1233) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12183-1.html) +[#]: subject: (16 Things to do After Installing Ubuntu 20.04) +[#]: via: (https://itsfoss.com/things-to-do-after-installing-ubuntu-20-04/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +安装完 Ubuntu 20.04 后要做的 16 件事 +====== + +> 以下是安装 Ubuntu 20.04 之后需要做的一些调整和事项,它将使你获得更流畅、更好的桌面 Linux 体验。 + +[Ubuntu 20.04 LTS(长期支持版)带来了许多新的特性][1]和观感上的变化。如果你要安装 Ubuntu 20.04,让我向你展示一些推荐步骤便于你的使用。 + +### 安装完 Ubuntu 20.04 LTS “Focal Fossa” 后要做的 16 件事 + +![][2] + +我在这里提到的步骤仅是我的建议。如果一些定制或调整不适合你的需要和兴趣,你可以忽略它们。 + +同样的,有些步骤看起来很简单,但是对于一个 Ubuntu 新手来说是必要的。 + +这里的一些建议适用于启用 GNOME 作为默认桌面 Ubuntu 20.04,所以请检查 [Ubuntu 版本][3]和[桌面环境][4]。 + +以下列表便是安装了代号为 Focal Fossa 的 Ubuntu 20.04 LTS 之后要做的事。 + +#### 1、通过更新和启用额外的软件仓库来准备你的系统 + +安装 Ubuntu 或任何其他 Linux 发行版之后,你应该做的第一件事就是更新它。Linux 的运作是建立在本地的可用软件包数据库上,而这个缓存需要同步以便你能够安装软件。 + +升级 Ubuntu 非常简单。你可以运行软件更新从菜单(按 `Super` 键并搜索 “software updater”): + +![Ubuntu 20.04 的软件升级器][5] + +你也可以在终端使用以下命令更新你的系统: + +``` +sudo apt update && sudo apt upgrade +``` + +接下来,你应该确保启用了 [universe(宇宙)和 multiverse(多元宇宙)软件仓库][6]。使用这些软件仓库,你可以访问更多的软件。我还推荐阅读关于 [Ubuntu 软件仓库][6]的文章,以了解它背后的基本概念。 + +在菜单中搜索 “Software & Updates”: + +![软件及更新设置项][7] + +请务必选中软件仓库前面的勾选框: + +![启用额外的软件仓库][8] + +#### 2、安装媒体解码器来播放 MP3、MPEG4 和其他格式媒体文件 + +如果你想播放媒体文件,如 MP3、MPEG4、AVI 等,你需要安装媒体解码器。由于各个国家的版权问题, Ubuntu 在默认情况下不会安装它。 + +作为个人,你可以[使用 Ubuntu Restricted Extra 安装包][9]很轻松地安装这些媒体编解码器。这将[在你的 Ubuntu 系统安装][10]媒体编解码器、Adobe Flash 播放器和微软 True Type 字体等。 + +你可以通过[点击这个链接][11]来安装它(它会要求在软件中心打开它),或者使用以下命令: + +``` +sudo apt install ubuntu-restricted-extras +``` + +如果遇到 EULA 或许可证界面,请记住使用 `tab` 键在选项之间进行选择,然后按回车键确认你的选择。 + +![按 tab 键选择 OK 并按回车键][12] + +#### 3、从软件中心或网络上安装软件 + +现在已经设置好了软件仓库并更新了软件包缓存,应该开始安装所需的软件了。 + +在 Ubuntu 中安装应用程序有几种方法,最简单和正式的方法是使用软件中心。 + +![Ubuntu 软件中心][14] + +如果你想要一些关于软件的建议,请参考这个[丰富的各种用途的 Ubuntu 应用程序列表][15]。 + +一些软件供应商提供了 .deb 文件来方便地安装他们的应用程序。你可以从他们的网站获得 .deb 文件。例如,要[在 Ubuntu 上安装谷歌 Chrome][16],你可以从它的网站上获得 .deb 文件,双击它开始安装。 + +#### 4、享受 Steam Proton 和 GameModeEnjoy 上的游戏 + +[在 Linux 上进行游戏][17]已经有了长足的发展。你不再受限于自带的少数游戏。你可以[在 Ubuntu 上安装 Steam][18]并享受许多游戏。 + +[Steam 新的 Proton 项目][19]可以让你在 Linux 上玩许多只适用于 Windows 的游戏。除此之外,Ubuntu 20.04 还默认安装了 [Feral Interactive 的 GameMode][20]。 + +GameMode 会自动调整 Linux 系统的性能,使游戏具有比其他后台进程更高的优先级。 + +这意味着一些支持 GameMode 的游戏(如[古墓丽影·崛起][21])在 Ubuntu 上的性能应该有所提高。 + +#### 5、管理自动更新(适用于进阶用户和专家) + +最近,Ubuntu 已经开始自动下载并安装对你的系统至关重要的安全更新。这是一个安全功能,作为一个普通用户,你应该让它保持默认开启。 + +但是,如果你喜欢自己进行配置更新,而这个自动更新经常导致你[“无法锁定管理目录”错误][22],也许你可以改变自动更新行为。 + +你可以选择“立即显示”,这样一有安全更新就会立即通知你,而不是自动安装。 + +![管理自动更新设置][23] + +#### 6、控制电脑的自动挂起和屏幕锁定 + +如果你在笔记本电脑上使用 Ubuntu 20.04,那么你可能需要注意一些电源和屏幕锁定设置。 + +如果你的笔记本电脑处于电池模式,Ubuntu 会在 20 分钟不活动后休眠系统。这样做是为了节省电池电量。就我个人而言,我不喜欢它,因此我禁用了它。 + +类似地,如果你离开系统几分钟,它会自动锁定屏幕。我也不喜欢这种行为,所以我宁愿禁用它。 + +![Ubuntu 20.04 的电源设置][24] + +#### 7、享受夜间模式 + +[Ubuntu 20.04 中最受关注的特性][25]之一是夜间模式。你可以通过进入设置并在外观部分中选择它来启用夜间模式。 + +![开启夜间主题 Ubuntu][26] + +你可能需要做一些[额外的调整来获得完整的 Ubuntu 20.04 夜间模式][27]。 + +#### 8、控制桌面图标和启动程序 + +如果你想要一个最简的桌面,你可以禁用桌面上的图标。你还可以从左侧禁用启动程序,并在顶部面板中禁用软件状态栏。 + +所有这些都可以通过默认的新 GNOME 扩展来控制,该程序默认情况下已经可用。 + +![禁用 Ubuntu 20 04 的 Dock][28] + +顺便说一下,你也可以通过“设置”->“外观”来将启动栏的位置改变到底部或者右边。 + +#### 9、使用表情符和特殊字符,或从搜索中禁用它 + +Ubuntu 提供了一个使用表情符号的简单方法。在默认情况下,有一个专用的应用程序叫做“字符”。它基本上可以为你提供表情符号的 [Unicode][29]。 + +不仅是表情符号,你还可以使用它来获得法语、德语、俄语和拉丁语字符的 unicode。单击符号你可以复制 unicode,当你粘贴该代码时,你所选择的符号便被插入。 + +![Ubuntu 表情符][30] + +你也能在桌面搜索中找到这些特殊的字符和表情符号。也可以从搜索结果中复制它们。 + +![表情符出现在桌面搜索中][31] + +如果你不想在搜索结果中看到它们,你应该禁用搜索功能对它们的访问。下一节将讨论如何做到这一点。 + +#### 10、掌握桌面搜索 + +GNOME 桌面拥有强大的搜索功能,大多数人使用它来搜索已安装的应用程序,但它不仅限于此。 + +按 `Super` 键并搜索一些东西,它将显示与搜索词匹配的任何应用程序,然后是系统设置和软件中心提供的匹配应用程序。 + +![桌面搜索][32] + +不仅如此,搜索还可以找到文件中的文本。如果你正在使用日历,它也可以找到你的会议和提醒。你甚至可以在搜索中进行快速计算并复制其结果。 + +![Ubuntu搜索的快速计算][33] + +你可以进入“设置”中来控制可以搜索的内容和顺序。 + +![][34] + +#### 11、使用夜灯功能,减少夜间眼睛疲劳 + +如果你在晚上使用电脑或智能手机,你应该使用夜灯功能来减少眼睛疲劳。我觉得这很有帮助。 + +夜灯的特点是在屏幕上增加了一种黄色的色调,比白光少了一些挤压感。 + +你可以在“设置”->“显示”切换到夜灯选项卡来开启夜光功能。你可以根据自己的喜好设置“黄度”。 + +![夜灯功能][35] + +#### 12、使用 2K/4K 显示器?使用分辨率缩放得到更大的图标和字体 + +如果你觉得图标、字体、文件夹在你的高分辨率屏幕上看起来都太小了,你可以利用分辨率缩放。 + +启用分辨率缩放可以让你有更多的选项来从 100% 增加到 200%。你可以选择适合自己喜好的缩放尺寸。 + +![在设置->显示中启用高分缩放][36] + +#### 13、探索 GNOME 扩展功能以扩展 GNOME 桌面可用性 + +GNOME 桌面有称为“扩展”的小插件或附加组件。你应该[学会使用 GNOME 扩展][37]来扩展系统的可用性。 + +如下图所示,天气扩展顶部面板中显示了天气信息。不起眼但十分有用。你也可以在这里查看一些[最佳 GNOME 扩展][38]。不需要全部安装,只使用那些对你有用的。 + +![天气扩展][39] + +#### 14、启用“勿扰”模式,专注于工作 + +如果你想专注于工作,禁用桌面通知会很方便。你可以轻松地启用“勿扰”模式,并静音所有通知。 + +![启用“请勿打扰”清除桌面通知][40] + +这些通知仍然会在消息栏中,以便你以后可以阅读它们,但是它们不会在桌面上弹出。 + +#### 15、清理你的系统 + +这是你安装 Ubuntu 后不需要马上做的事情。但是记住它会对你有帮助。 + +随着时间的推移,你的系统将有大量不再需要的包。你可以用这个命令一次性删除它们: + +``` +sudo apt autoremove +``` + +还有其他[清理 Ubuntu 以释放磁盘空间的方法][41],但这是最简单和最安全的。 + +#### 16、根据你的喜好调整和定制 GNOME 桌面 + +我强烈推荐[安装 GNOME 设置工具][42]。这将让你可以通过额外的设置来进行定制。 + +![Gnome 设置工具][43] + +比如,你可以[以百分比形式显示电池容量][44]、[修正在触摸板右键问题][45]、改变 Shell 主题、改变鼠标指针速度、显示日期和星期数、改变应用程序窗口行为等。 + +定制是没有尽头的,我可能仅使用了它的一小部分功能。这就是为什么我推荐[阅读这些][42]关于[自定义 GNOME 桌面][46]的文章。 + +你也可以[在 Ubuntu 中安装新主题][47],不过就我个人而言,我喜欢这个版本的默认主题。这是我第一次在 Ubuntu 发行版中使用默认的图标和主题。 + +#### 安装 Ubuntu 之后你会做什么? + +如果你是 Ubuntu 的初学者,我建议你[阅读这一系列 Ubuntu 教程][48]开始学习。 + +这就是我的建议。安装 Ubuntu 之后你要做什么?分享你最喜欢的东西,我可能根据你的建议来更新这篇文章。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/things-to-do-after-installing-ubuntu-20-04/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-12146-1.html +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/things-to-do-after-installing-ubuntu-20-04.jpg?ssl=1 +[3]: https://linux.cn/article-9872-1.html +[4]: https://linux.cn/article-12124-1.html +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/software-updater-ubuntu-20-04.jpg?ssl=1 +[6]: https://itsfoss.com/ubuntu-repositories/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/software-updates-settings-ubuntu-20-04.jpg?ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/extra-repositories-ubuntu-20.jpg?ssl=1 +[9]: https://linux.cn/article-11906-1.html +[10]: https://linux.cn/article-12074-1.html +[11]: //ubuntu-restricted-extras/ +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/02/installing_ubuntu_restricted_extras.jpg?ssl=1 +[13]: https://itsfoss.com/remove-install-software-ubuntu/ +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/software-center-ubuntu-20.png?resize=800%2C509&ssl=1 +[15]: https://itsfoss.com/best-ubuntu-apps/ +[16]: https://itsfoss.com/install-chrome-ubuntu/ +[17]: https://linux.cn/article-7316-1.html +[18]: https://itsfoss.com/install-steam-ubuntu-linux/ +[19]: https://linux.cn/article-10054-1.html +[20]: https://github.com/FeralInteractive/gamemode +[21]: https://en.wikipedia.org/wiki/Rise_of_the_Tomb_Raider +[22]: https://itsfoss.com/could-not-get-lock-error/ +[23]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/auto-updates-ubuntu.png?resize=800%2C361&ssl=1 +[24]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/power-settings-ubuntu-20-04.png?fit=800%2C591&ssl=1 +[25]: https://www.youtube.com/watch?v=lpq8pm_xkSE +[26]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/enable-dark-theme-ubuntu.png?ssl=1 +[27]: https://linux.cn/article-12098-1.html +[28]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/disable-dock-ubuntu-20-04.png?ssl=1 +[29]: https://en.wikipedia.org/wiki/List_of_Unicode_characters +[30]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/emoji-ubuntu.jpg?ssl=1 +[31]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/emojis-desktop-search-ubuntu.jpg?ssl=1 +[32]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-desktop-search-1.jpg?ssl=1 +[33]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/quick-calculations-ubuntu-search.jpg?ssl=1 +[34]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/search-settings-control-ubuntu.png?resize=800%2C534&ssl=1 +[35]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/nightlight-ubuntu-20-04.png?ssl=1 +[36]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/fractional-scaling-ubuntu.jpg?ssl=1 +[37]: https://itsfoss.com/gnome-shell-extensions/ +[38]: https://itsfoss.com/best-gnome-extensions/ +[39]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/weather-extension-ubuntu.jpg?ssl=1 +[40]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/03/do-not-distrub-option-ubuntu-20-04.png?ssl=1 +[41]: https://itsfoss.com/free-up-space-ubuntu-linux/ +[42]: https://itsfoss.com/gnome-tweak-tool/ +[43]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/gnome-tweaks-tool-ubuntu-20-04.png?fit=800%2C551&ssl=1 +[44]: https://itsfoss.com/display-battery-ubuntu/ +[45]: https://itsfoss.com/fix-right-click-touchpad-ubuntu/ +[46]: https://itsfoss.com/gnome-tricks-ubuntu/ +[47]: https://itsfoss.com/install-themes-ubuntu/ +[48]: https://itsfoss.com/getting-started-with-ubuntu/ diff --git a/published/202005/20200425 Inlining optimisations in Go.md b/published/202005/20200425 Inlining optimisations in Go.md new file mode 100644 index 0000000000..12f1cb67b7 --- /dev/null +++ b/published/202005/20200425 Inlining optimisations in Go.md @@ -0,0 +1,213 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12176-1.html) +[#]: subject: (Inlining optimisations in Go) +[#]: via: (https://dave.cheney.net/2020/04/25/inlining-optimisations-in-go) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Go 中的内联优化 +====== + +> 本文讨论 Go 编译器是如何实现内联的,以及这种优化方法如何影响你的 Go 代码。 + +![](https://img.linux.net.cn/data/attachment/album/202005/02/222202e3v3pppkhnndpbpn.jpg) + +*请注意:*本文重点讨论 *gc*,这是来自 [golang.org](https://github.com/golang/go) 的事实标准的 Go 编译器。讨论到的概念可以广泛适用于其它 Go 编译器,如 gccgo 和 llgo,但它们在实现方式和功效上可能有所差异。 + +### 内联是什么? + +内联inlining就是把简短的函数在调用它的地方展开。在计算机发展历程的早期,这个优化是由程序员手动实现的。现在,内联已经成为编译过程中自动实现的基本优化过程的其中一步。 + +### 为什么内联很重要? + +有两个原因。第一个是它消除了函数调用本身的开销。第二个是它使得编译器能更高效地执行其他的优化策略。 + +#### 函数调用的开销 + +在任何语言中,调用一个函数 [^1] 都会有消耗。把参数编组进寄存器或放入栈中(取决于 ABI),在返回结果时的逆反过程都会有开销。引入一次函数调用会导致程序计数器从指令流的一点跳到另一点,这可能导致管道滞后。函数内部通常有前置处理preamble,需要为函数执行准备新的栈帧,还有与前置相似的后续处理epilogue,需要在返回给调用方之前释放栈帧空间。 + +在 Go 中函数调用会消耗额外的资源来支持栈的动态增长。在进入函数时,goroutine 可用的栈空间与函数需要的空间大小进行比较。如果可用空间不同,前置处理就会跳到运行时runtime的逻辑中,通过把数据复制到一块新的、更大的空间的来增长栈空间。当这个复制完成后,运行时就会跳回到原来的函数入口,再执行栈空间检查,现在通过了检查,函数调用继续执行。这种方式下,goroutine 开始时可以申请很小的栈空间,在有需要时再申请更大的空间。[^2] + +这个检查消耗很小,只有几个指令,而且由于 goroutine 的栈是成几何级数增长的,因此这个检查很少失败。这样,现代处理器的分支预测单元可以通过假定检查肯定会成功来隐藏栈空间检查的消耗。当处理器预测错了栈空间检查,不得不放弃它在推测性执行所做的操作时,与为了增加 goroutine 的栈空间运行时所需的操作消耗的资源相比,管道滞后的代价更小。 + +虽然现代处理器可以用预测性执行技术优化每次函数调用中的泛型和 Go 特定的元素的开销,但那些开销不能被完全消除,因此在每次函数调用执行必要的工作过程中都会有性能消耗。一次函数调用本身的开销是固定的,与更大的函数相比,调用小函数的代价更大,因为在每次调用过程中它们做的有用的工作更少。 + +因此,消除这些开销的方法必须是要消除函数调用本身,Go 的编译器就是这么做的,在某些条件下通过用函数的内容来替换函数调用来实现。这个过程被称为*内联*,因为它在函数调用处把函数体展开了。 + +#### 改进的优化机会 + +Cliff Click 博士把内联描述为现代编译器做的优化措施,像常量传播(LCTT 译注:此处作者笔误,原文为 constant proportion,修正为 constant propagation)和死代码消除一样,都是编译器的基本优化方法。实际上,内联可以让编译器看得更深,使编译器可以观察调用的特定函数的上下文内容,可以看到能继续简化或彻底消除的逻辑。由于可以递归地执行内联,因此不仅可以在每个独立的函数上下文处进行这种优化决策,也可以在整个函数调用链中进行。 + +### 实践中的内联 + +下面这个例子可以演示内联的影响: + +```go +package main + +import "testing" + +//go:noinline +func max(a, b int) int { + if a > b { + return a + } + return b +} + +var Result int + +func BenchmarkMax(b *testing.B) { + var r int + for i := 0; i < b.N; i++ { + r = max(-1, i) + } + Result = r +} +``` + +运行这个基准,会得到如下结果:[^3] + +```bash +% go test -bench=. +BenchmarkMax-4 530687617 2.24 ns/op +``` + +在我的 2015 MacBook Air 上 `max(-1, i)` 的耗时约为 2.24 纳秒。现在去掉 `//go:noinline` 编译指令,再看下结果: + +```bash +% go test -bench=. +BenchmarkMax-4 1000000000 0.514 ns/op +``` + +从 2.24 纳秒降到了 0.51 纳秒,或者从 `benchstat` 的结果可以看出,有 78% 的提升。 + +```bash +% benchstat {old,new}.txt +name old time/op new time/op delta +Max-4 2.21ns ± 1% 0.49ns ± 6% -77.96% (p=0.000 n=18+19) +``` + +这个提升是从哪儿来的呢? + +首先,移除掉函数调用以及与之关联的前置处理 [^4] 是主要因素。把 `max` 函数的函数体在调用处展开,减少了处理器执行的指令数量并且消除了一些分支。 + +现在由于编译器优化了 `BenchmarkMax`,因此它可以看到 `max` 函数的内容,进而可以做更多的提升。当 `max` 被内联后,`BenchmarkMax` 呈现给编译器的样子,看起来是这样的: + +```go +func BenchmarkMax(b *testing.B) { + var r int + for i := 0; i < b.N; i++ { + if -1 > i { + r = -1 + } else { + r = i + } + } + Result = r +} +``` + +再运行一次基准,我们看一下手动内联的版本和编译器内联的版本的表现: + +```bash +% benchstat {old,new}.txt +name old time/op new time/op delta +Max-4 2.21ns ± 1% 0.48ns ± 3% -78.14% (p=0.000 n=18+18) +``` + +现在编译器能看到在 `BenchmarkMax` 里内联 `max` 的结果,可以执行以前不能执行的优化措施。例如,编译器注意到 `i` 初始值为 `0`,仅做自增操作,因此所有与 `i` 的比较都可以假定 `i` 不是负值。这样条件表达式 `-1 > i` 永远不是 `true`。[^5] + +证明了 `-1 > i` 永远不为 true 后,编译器可以把代码简化为: + +```go +func BenchmarkMax(b *testing.B) { + var r int + for i := 0; i < b.N; i++ { + if false { + r = -1 + } else { + r = i + } + } + Result = r +} +``` + +并且因为分支里是个常量,编译器可以通过下面的方式移除不会走到的分支: + +```go +func BenchmarkMax(b *testing.B) { + var r int + for i := 0; i < b.N; i++ { + r = i + } + Result = r +} +``` + +这样,通过内联和由内联解锁的优化过程,编译器把表达式 `r = max(-1, i))` 简化为 `r = i`。 + +### 内联的限制 + +本文中我论述的内联称作叶子内联leaf inlining:把函数调用栈中最底层的函数在调用它的函数处展开的行为。内联是个递归的过程,当把函数内联到调用它的函数 A 处后,编译器会把内联后的结果代码再内联到 A 的调用方,这样持续内联下去。例如,下面的代码: + +```go +func BenchmarkMaxMaxMax(b *testing.B) { + var r int + for i := 0; i < b.N; i++ { + r = max(max(-1, i), max(0, i)) + } + Result = r +} +``` + +与之前的例子中的代码运行速度一样快,因为编译器可以对上面的代码重复地进行内联,也把代码简化到 `r = i` 表达式。 + +下一篇文章中,我会论述当 Go 编译器想要内联函数调用栈中间的某个函数时选用的另一种内联策略。最后我会论述编译器为了内联代码准备好要达到的极限,这个极限 Go 现在的能力还达不到。 + +[^1]: 在 Go 中,一个方法就是一个有预先定义的形参和接受者的函数。假设这个方法不是通过接口调用的,调用一个无消耗的函数所消耗的代价与引入一个方法是相同的。 +[^2]: 在 Go 1.14 以前,栈检查的前置处理也被垃圾回收器用于 STW,通过把所有活跃的 goroutine 栈空间设为 0,来强制它们切换为下一次函数调用时的运行时状态。这个机制[最近被替换][8]为一种新机制,新机制下运行时可以不用等 goroutine 进行函数调用就可以暂停 goroutine。 +[^3]: 我用 `//go:noinline` 编译指令来阻止编译器内联 `max`。这是因为我想把内联 `max` 的影响与其他影响隔离开,而不是用 `-gcflags='-l -N'` 选项在全局范围内禁止优化。关于 `//go:` 注释在[这篇文章][10]中详细论述。 +[^4]: 你可以自己通过比较 `go test -bench=. -gcflags=-S` 有无 `//go:noinline` 注释时的不同结果来验证一下。 +[^5]: 你可以用 `-gcflags=-d=ssa/prove/debug=on` 选项来自己验证一下。 + +#### 相关文章: + +1. [使 Go 变快的 5 件事](https://dave.cheney.net/2014/06/07/five-things-that-make-go-fast) +2. [为什么 Goroutine 的栈空间会无限增长?](https://dave.cheney.net/2013/06/02/why-is-a-goroutines-stack-infinite) +3. [Go 中怎么写基准测试](https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go) +4. [Go 中隐藏的编译指令](https://dave.cheney.net/2018/01/08/gos-hidden-pragmas) + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2020/04/25/inlining-optimisations-in-go + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://github.com/golang/go +[2]: tmp.gBQ2tEtMHc#easy-footnote-bottom-1-4053 (In Go, a method is just a function with a predefined formal parameter, the receiver. The relative costs of calling a free function vs a invoking a method, assuming that method is not called through an interface, are the same.) +[3]: tmp.gBQ2tEtMHc#easy-footnote-bottom-2-4053 (Up until Go 1.14 the stack check preamble was also used by the garbage collector to stop the world by setting all active goroutine’s stacks to zero, forcing them to trap into the runtime the next time they made a function call. This system was recently replaced with a mechanism which allowed the runtime to pause an goroutine without waiting for it to make a function call.) +[4]: tmp.gBQ2tEtMHc#easy-footnote-bottom-3-4053 (I’m using the //go:noinline pragma to prevent the compiler from inlining max. This is because I want to isolate the effects of inlining on max rather than disabling optimisations globally with -gcflags='-l -N'. I go into detail about the //go: comments in this presentation.) +[5]: tmp.gBQ2tEtMHc#easy-footnote-bottom-4-4053 (You can check this for yourself by comparing the output of go test -bench=. -gcflags=-S with and without the //go:noinline annotation.) +[6]: tmp.gBQ2tEtMHc#easy-footnote-bottom-5-4053 (You can check this yourself with the -gcflags=-d=ssa/prove/debug=on flag.) +[7]: tmp.gBQ2tEtMHc#easy-footnote-1-4053 +[8]: https://github.com/golang/proposal/blob/master/design/24543-non-cooperative-preemption.md +[9]: tmp.gBQ2tEtMHc#easy-footnote-2-4053 +[10]: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas +[11]: tmp.gBQ2tEtMHc#easy-footnote-3-4053 +[12]: tmp.gBQ2tEtMHc#easy-footnote-4-4053 +[13]: tmp.gBQ2tEtMHc#easy-footnote-5-4053 +[14]: https://dave.cheney.net/2014/06/07/five-things-that-make-go-fast (Five things that make Go fast) +[15]: https://dave.cheney.net/2013/06/02/why-is-a-goroutines-stack-infinite (Why is a Goroutine’s stack infinite ?) +[16]: https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go (How to write benchmarks in Go) +[17]: https://dave.cheney.net/2018/01/08/gos-hidden-pragmas (Go’s hidden #pragmas) diff --git a/published/202005/20200427 How to secure your Linux email services with SSL-TLS.md b/published/202005/20200427 How to secure your Linux email services with SSL-TLS.md new file mode 100644 index 0000000000..48c2138c7a --- /dev/null +++ b/published/202005/20200427 How to secure your Linux email services with SSL-TLS.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (Acceleratorrrr) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12217-1.html) +[#]: subject: (How to secure your Linux email services with SSL/TLS) +[#]: via: (https://opensource.com/article/20/4/securing-linux-email) +[#]: author: (Marc Skinner https://opensource.com/users/marc-skinner) + +如何利用 SSL/TLS 保护你的 Linux 邮件服务 +====== + +> 通过理解安全证书来保护你的 Linux 邮件服务。 + +![](https://img.linux.net.cn/data/attachment/album/202005/13/215637khaogmririavnrlk.jpg) + +通常,不管你是通过简单邮件传输协议Simple Mail Transport Protocol(SMTP)或者互联网消息访问协议Internet Message Access Protocol(IMAP)或邮局协议Post Office Protocol(POP)发送或者接受邮件,邮件服务默认都是以无保护的明文来传输数据。近来随着数据加密成为越来越多程序的共识,你需要安全套接层Secure Sockets Layer/传输层安全性Transport Layer Security(SSL/TLS)的安全证书来保护你的邮件服务。 + +首先,快速回顾一下邮件服务和协议的基本流程。邮件通过 SMTP 从 TCP 端口 25 发出。这个协议依靠 DNS 邮件交换服务器Mail eXchanger(MX)记录的地址信息来传输邮件。当邮件到达邮件服务器后,可以被以下两种服务中的任意一种检索:使用 TCP 端口 143 的 IMAP,或者使用 TCP 端口 110 的 POP3(邮局协议第 3 版)。然而,以上服务都默认使用明文传输邮件和认证信息。这非常的不安全! + +为了保护电子邮件数据和认证,这些服务都增加了一个安全功能,使它们可以利用 SSL/TLS 证书对数据流和通讯进行加密封装。SSL/TLS 是如何加密数据的细节不在本文讨论范围,有兴趣的话可以阅读 [Bryant Son 关于互联网安全的文章][2]了解更多细节。概括的说,SSL/TLS 加密是一种基于公钥和私钥的算法。 + +通过加入这些安全功能后,这些服务将监听在新的 TCP 端口: + +服务 | 默认 TCP 端口 | SSL/TLS 端口 +---|---|--- +SMTP | 25 | 587 +IMAP | 143 | 993 +POP3 | 110 | 995 + +### 生成 SSL/TLS 证书 + +[OpenSSL][3] 可以生成免费的 SSL/TLS 证书,或者你也可以从公共证书颁发机构Certificate Authoritie(CA)购买。过去,生成自签发证书十分简单而且通用,但是由于安全被日益重视,大部分的邮件客户端是不信任自签发证书的,除非手动设置。 + +如果你只是自己使用或者做做测试,那就使用自签发证书省点钱吧。但是如果很多人或者客户也需要使用的话,那最好还是从受信任的证书颁发机构购买。 + +不管是哪种情况,开始请求新证书的过程是使用 Linux 系统上的 OpenSSL 工具来创建一个证书签发请求Certificate Signing Request完全合规域名Fully Qualified Domain Name(FQDN)、邮件联系信息等等。当你输入完这些信息后,私钥和 CSR 文件就生成完毕了。 + +#### 如果你想生成自签发证书 + +如果你想要生成自签发证书的话,在运行以上 CSR 命令之前,你必须先创建一个[自己的根 CA][4]。你可以通过以下方法创建自己的根 CA。 + +``` +$ openssl genrsa -des3 -out myCA.key 2048 +``` + +命令行会提示你输入一个密码。请输入一个复杂点的密码而且不要弄丢了,因为这将会是根 CA 私钥的密码,正如其名称所示,它是你的证书中所有信任关系的根。 + +接下来,生成根 CA 证书: + +``` +$ openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 -out myCA.pem +``` + +在回答完一些问题后,你就拥有一个有效期为 5 年的根 CA 证书了。 + +用之前生成的 CSR 文件,你可以请求生成一个新证书,并由您刚才创建的根 CA 签名。 + +``` +$ openssl x509 -req -in mail.mydomain.csr -CA myCA.pem -CAkey myCA.key -CAcreateserial -out mail.mydomain.pem -days 1825 -sha256 +``` + +输入你的根 CA 私钥的密码来创建和签署证书。 + +现在你有了配置电子邮件服务以增强安全性所需的两个文件:私匙文件 `mail.mydomain.key` 和公开证书文件 `mail.mydomain.pem`。 + +#### 如果你愿意购买证书 + +如果你愿意从机构购买证书,则需要上传 CSR 文件到证书颁发机构的系统中,它将会被用于生成 SSL/TLS 证书。证书可作为文件下载,比如 `mail.mydomain.pem`。很多 SSL 机构也需要你下载一个中间证书。如果是这样的话,你必须把这个两个证书合并成一个,这样电子邮件服务就可以将这两个证书结合起来处理。可以使用以下命令把你的证书和第三方中间证书合并在一起: + +``` +$ cat mail.mydomain.pem gd_bundle-g2-g1.crt > mail.mydomain.pem +``` + +值得一提的是 `.pem` 文件后缀代表隐私增强邮件Privacy-Enhanced Mail。 + +现在你就有全部的设置邮件服务安全所需文件了:私匙文件 `mail.mydomain.key` 和组合的公开证书文件 `mail.mydomain.pem`。 + +### 为你的文件生成一个安全的文件夹 + +不管你是的证书是自签发的或者从机构购买,你都需要生成一个安全的,管理员拥有的文件夹用于保存这两个文件。可以使用以下命令来生成: + +``` +$ mkdir /etc/pki/tls +$ chown root:root /etc/pki/tls +$ chmod 700 /etc/pki/tls +``` + +在复制文件到 `/etc/pki/tls` 后,再次设置这些文件的权限: + +``` +$ chmod 600 /etc/pki/tls/* +``` + +### 配置你的 SMTP 和 IMAP 服务 + +接下来,让 SMTP 和 IMAP 服务使用新的安全证书。我们用 `postfix` 和 `dovecot` 来作为例子。 + +用你顺手的编辑器来编辑 `/etc/postfix/main.cf` 文件。添加以下几行: + +``` +smtpd_use_tls = yes +smtpd_tls_cert_file = /etc/pki/tls/mail.mydomain.pem +smtpd_tls_key_file = /etc/pki/tls/mail.mydomain.key +``` + +### 自定义选项 + +以下选项可以启用或禁用各种加密算法,协议等等: + +``` +smtpd_tls_eecdh_grade = strong +smtpd_tls_protocols= !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 +smtpd_tls_mandatory_protocols= !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 +smtpd_tls_mandatory_ciphers = high +smtpd_tls_security_level=may +smtpd_tls_ciphers = high +tls_preempt_cipherlist = yes +smtpd_tls_mandatory_exclude_ciphers = aNULL, MD5 , DES, ADH, RC4, PSD, SRP, 3DES, eNULL +smtpd_tls_exclude_ciphers = aNULL, MD5 , DES, ADH, RC4, PSD, SRP, 3DES, eNULL +smtp_tls_mandatory_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 +smtp_tls_protocols = !SSLv2, !SSLv3, !TLSv1, !TLSv1.1 +``` + +编辑 `/etc/dovecot/dovecot.conf` 文件,添加以下三行: + +``` +ssl = required +ssl_cert = </etc/pki/tls/mail.mydomain.pem +ssl_key = </etc/pki/tls/mail.mydomain.key +``` + +添加下列更多选项来启用或禁用各种加密算法、协议等等(我把这些留给你来理解): + +``` +ssl_cipher_list = EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:ALL:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SSLv2 +ssl_prefer_server_ciphers = yes +ssl_protocols = !SSLv2 !SSLv3 !TLSv1 !TLSv1.1 +ssl_min_protocol = TLSv1.2 +``` + +### 设置 SELinux 上下文 + +如果你的 Linux 发行版启用了 SELinux,请为你的新证书文件设置正确的 SELinux 上下文。 + +对于 Postfix 设置 SELinux: + +``` +$ chcon -u system_u -t cert_t mail.mydomain.* +``` + +对于 Dovecot 设置 SELinux: + +``` +$ chcon -u system_u -t dovecot_cert_t mail.mydomain.* +``` + +重启这些服务,并与你相应更新过的电子邮件客户端配置连接。有些电子邮件客户端会自动探测到新的端口,有些则需要你手动更新。 + +### 测试配置 + +用 `openssl` 命令行和 `s_client` 插件来简单测试一下: + +``` +$ openssl s_client -connect mail.mydomain.com:993 +$ openssl s_client -starttls imap -connect mail.mydomain.com:143 +$ openssl s_client -starttls smtp -connect mail.mydomain.com:587 +``` + +这些测试命令会打印出很多信息,关于你使用的连接、证书、加密算法、会话和协议。这不仅是一个验证新设置的好方法,也可以确认你使用了适当的证书,以及在 postfix 或 dovecot 配置文件中定义的安全设置正确。 + +保持安全! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/securing-linux-email + +作者:[Marc Skinner][a] +选题:[lujun9972][b] +译者:[Acceleratorrrr](https://github.com/Acceleratorrrr) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/marc-skinner +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/newsletter_email_mail_web_browser.jpg?itok=Lo91H9UH (email or newsletters via inbox and browser) +[2]: https://linux.cn/article-11699-1.html +[3]: https://www.openssl.org/ +[4]: https://en.wikipedia.org/wiki/Root_certificate diff --git a/published/202005/20200428 Lubuntu 20.04 Review- Lightweight, Minimalistic, Polished.md b/published/202005/20200428 Lubuntu 20.04 Review- Lightweight, Minimalistic, Polished.md new file mode 100644 index 0000000000..3b04dc37b8 --- /dev/null +++ b/published/202005/20200428 Lubuntu 20.04 Review- Lightweight, Minimalistic, Polished.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: (qfzy1233) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12242-1.html) +[#]: subject: (Lubuntu 20.04 Review: Lightweight, Minimalistic, Polished) +[#]: via: (https://itsfoss.com/lubuntu-20-04-review/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +Lubuntu 20.04 点评:轻量、简约、文雅 +====== + +> Lubuntu 20.04 LTS 与之前的 LTS 版本有很大的不同。它旨在给你一个更完善的体验,而不仅仅是关注旧电脑。请阅读更多关于 Lubuntu 20.04 的内容。 + +### Lubuntu 20.04 点评:第一个基于 LXQt 的长期支持版 + +我在 Lubuntu 20.04 发行前几天就已经开始使用它了。我通常使用 Arch 阵营中 Manjaro 和 Cinnamon 桌面,所以使用 Lubuntu 对我来说是一个愉快的改变。 + +以下是我在使用 Lubuntu 20.04.时的一些感受和注记。 + +#### 再见 LXDE,你好 LXQt! + +长期以来,[Lubuntu][1] 都依靠 [LXDE][2] 来提供轻量级的 Linux 体验。但现在,它使用的是 LXQt 桌面环境。 + +[LXDE][3] 是基于 GTK(GNOME 所使用的库),更具体地说是基于 2020 年的 GTK+ 2。由于对 GTK+ 3 不满意,LXDE 开发人员 Hong Jen Yee 决定将整个桌面移植到 Qt(KDE 所使用的库)。LXDE 的 Qt 移植版本和 [Razor-qt][4] 项目合并形成 [LXQt][5]。所以现在,LXDE 和 LXQt 作为单独的项目而共存。 + +既然 LXDE 开发者本身专注于 LXQt,那么 Lubuntu 坚持使用三年多前上一次稳定发布版的桌面环境 LXDE 是没有意义的。 + +因此,Lubuntu 18.04 是使用 [LXDE][3] 的最后一个版本。幸运的是,这是一个长期支持版本。Lubuntu 团队将提供支持直到 2021 年。 + +![][6] + +#### 不仅适于老机器 + +随着在 2020 年“老机器”的定义发生了变化,Lubuntu 18.04 成为了最后一个 32 位版本。现在,即使是一台 10 年前的老机器也至少有 2G 的内存和一个双核 64 位处理器。 + +因此,Lubuntu 团队将不再设置最低的系统需求,也不再主要关注旧硬件。尽管 LXQt 仍然是一个轻量级的、经典而不失精致的、功能丰富的桌面环境。 + +在 Lubuntu 20.04 LTS 发布之前,Lubuntu 的第一个 LXQt 发行版是 18.10,开发人员经历了三个标准发行版来完善 LXQt 桌面,这是一个很好的开发策略。 + +#### 不用常规的 Ubiquity,Lubuntu 20.04 使用的是 Calamares 安装程序 + +![Lubuntu 20.04 Calamares 安装程序][8] + +在新版本中使用了全新的 [Calamares][9] 安装程序,取代了其它 [Ubuntu 官方版本][10]使用的 Ubiquity 安装程序。 + +整个安装过程在大约能在 10 分钟内完成,比之前 Lubuntu 的版本稍微快一些。 + +由于镜像文件附带了预先安装的基本应用程序,所以你可以很快就可以完成系统的完全配置。 + +#### 不要直接从 Lubuntu 18.04 升级到 Lubuntu 20.04 + +通常,你可以[将 Ubuntu 从一个 LTS 版本升级到另一个 LTS 版本][11]。但是 Lubuntu 团队建议不要从 Lubuntu 18.04 升级到 20.04。他们建议重新安装,这才是正确的。 + +Lubuntu 18.04 使用 LXDE 桌面,20.04 使用 LXQt。由于桌面环境的巨大变化,从 18.04 升级到 20.04 将导致系统崩溃。 + +#### 更多的 KDE 和 Qt 应用程序 + +![][12] + +下面是在这个新版本中默认提供的一些应用程序,正如我们所看到的,并非所有应用程序都是轻量级的,而且大多数应用程序都是基于 Qt 的。 + +甚至使用的软件中心也是 KDE 的 Discover,而不是 Ubuntu 的 GNOME 软件中心。 + + * Ark – 归档文件管理器 + * Bluedevil – 蓝牙连接管理 + * Discover 软件中心 – 包管理系统 + * FeatherPad – 文本编辑器 + * FireFox – 浏览器 + * K3b – CD/DVD 刻录器 + * Kcalc – 计算器 + * KDE 分区管理器 – 分区管理工具 + * LibreOffice – 办公套件(Qt 界面版本) + * LXimage-Qt – 图片查看器及截图制作 + * Muon – 包管理器 + * Noblenote – 笔记工具 + * PCManFM-Qt – 文件管理器 + * Qlipper – 剪贴板管理工具 + * qPDFview – PDF 阅读器 + * PulseAudio – 音频控制器 + * Qtransmission – BT 下载工具(Qt 界面版本) + * Quassel – IRC 客户端 + * ScreenGrab – 截屏制作工具 + * Skanlite – 扫描工具 + * 启动盘创建工具 – USB 启动盘制作工具 + * Trojita – 邮件客户端 + * VLC – 媒体播放器 + * [MPV 视频播放器][13] + +#### 测试 Lubuntu 20.04 LTS + +LXQt 版 Lubuntu 的启动时间不到一分钟,虽然是从 SSD 启动的。 + +LXQt 目前需要的内存比基于 Gtk+ 2 的 LXDE 稍微多一点,但是另一种 Gtk+ 3 工具包也需要更多的内存。 + +在重新启动之后,系统以非常低的内存占用情况运行,大约只有 340 MB(按照现代标准),比 LXDE 多 100 MB。 + +![htop 在 Lubuntu 20.04 上运行][14] + +LXQt 不仅适用于硬件较旧的用户,也适用于那些希望在新机器上获得简约经典体验的用户。 + +桌面布局看起来类似于 KDE 的 Plasma 桌面,你觉得呢? + +![Lubuntu 20.04 桌面环境][15] + +在左下角有一个应用程序菜单,一个用于显示固定和活动的应用程序的任务栏,右下角有一个系统托盘。 + +Lubuntu 的 LXQt 版本可以很容易的定制,所有的东西都在菜单的首选项下,大部分的关键项目都在 LXQt “设置”中。 + +值得一提的是,LXQt 在默认情况下使用流行的 [Openbox 窗口管理器][16]。 + +与前三个发行版一样,20.04 LTS 附带了一个默认的黑暗主题 Lubuntu Arc,但是如果不适合你的口味,可以快速更换,也很方便。 + +就日常使用而言,事实证明,Lubuntu 20.04 向我证明,其实每一个 Ubuntu 的分支版本都完全没有问题。 + +#### 结论 + +Lubuntu 团队已经成功地过渡到一个现代的、依然轻量级的、极简的桌面环境。LXDE 看起来被遗弃了,迁移到一个活跃的项目也是一件好事。 + +我希望 Lubuntu 20.04 能够让你和我一样热爱,如果是这样,请在下面的评论中告诉我。请继续关注! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/lubuntu-20-04-review/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[qfzy1233](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://lubuntu.me/ +[2]: https://github.com/lxde +[3]: https://lxde.org/ +[4]: https://web.archive.org/web/20160220061334/http://razor-qt.org/ +[5]: https://lxqt.org/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/Lubuntu-20-04-review.jpg?ssl=1 +[7]: https://itsfoss.com/lubuntu-no-more-old-distro/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/lubuntu-20-04-installer.jpg?ssl=1 +[9]: https://calamares.io/ +[10]: https://itsfoss.com/which-ubuntu-install/ +[11]: https://itsfoss.com/upgrade-ubuntu-version/ +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/Lubuntu-20.04.gif?ssl=1 +[13]: https://itsfoss.com/mpv-video-player/ +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/htop.jpg?fit=800%2C629&ssl=1 +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/Lubuntu-20.04-desktop.jpg?fit=800%2C450&ssl=1 +[16]: https://en.wikipedia.org/wiki/Openbox diff --git a/published/202005/20200428 Upgrading Fedora 31 to Fedora 32.md b/published/202005/20200428 Upgrading Fedora 31 to Fedora 32.md new file mode 100644 index 0000000000..c2c4bc0301 --- /dev/null +++ b/published/202005/20200428 Upgrading Fedora 31 to Fedora 32.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12195-1.html) +[#]: subject: (Upgrading Fedora 31 to Fedora 32) +[#]: via: (https://fedoramagazine.org/upgrading-fedora-31-to-fedora-32/) +[#]: author: (Adam Šamalík https://fedoramagazine.org/author/asamalik/) + +将 Fedora 31 升级到 Fedora 32 +====== + +![][1] + +Fedora 32 [已经发布][2]。你可能想升级系统以获得 Fedora 中的最新功能。Fedora Workstation 有图形化的升级方法。另外,Fedora 提供了命令行方法,用于将 Fedora 31 升级到 Fedora 32。 + +升级前,请访问 [Fedora 32 个常见 bug 的维基页面][3],查看是否存在可能影响升级的问题。尽管 Fedora 社区试图确保升级正常进行,但是无法为用户可能使用的每种软硬件组合提供保证。 + +### 将 Fedora 31 Workstation 升级到 Fedora 32 + +在新版本发布不久之后就会出现通知,告诉你有可用的升级。你可以单击该通知启动 “GNOME 软件”。或者,你可以从 GNOME Shell 中选择“软件”。 + +在 “GNOME 软件”中选择更新Updates选项卡,你会看到一个页面通知你 Fedora 32 现在可用。 + +如果你在此页面看不到任何内容,请尝试使用左上方的重新加载按钮。发布后,所有系统可能都需要一段时间才能看到可用的升级。 + +选择下载Download获取升级包。你可以继续做事直到下载完成。然后使用 “GNOME 软件”重启系统并应用升级。升级需要时间,因此你可能需要喝杯咖啡,稍后再回来。 + +### 使用命令行 + +如果你是从 Fedora 的先前版本升级的,那么你可能对 `dnf upgrade` 插件很熟悉。这个方法是推荐和受支持的从 Fedora 31 升级到 Fedora 32 的方法。使用此插件将使你轻松地升级到 Fedora 32。 + +#### 1、更新软件并备份系统 + +在开始升级过程之前,请确保你有 Fedora 31 的最新软件。如果你安装了模块化软件modular software,这尤为重要。`dnf` 和 “GNOME 软件”的最新版本对某些模块化流的升级过程进行了改进。要更新软件,请使用 “GNOME 软件” 或在终端中输入以下命令。 + +``` +sudo dnf upgrade --refresh +``` + +此外,在继续操作之前,请确保备份系统。有关备份的帮助,请参阅 Fedora Magazine 上的[备份系列][4]。 + +#### 2、安装 DNF 插件 + +接下来,打开终端并输入以下命令安装插件: + +``` +sudo dnf install dnf-plugin-system-upgrade +``` + +#### 3、使用 DNF 开始更新 + +现在,你的系统已更新、已备份、并且已安装 DNF 插件,你可以在终端中使用以下命令开始升级: + +``` +sudo dnf system-upgrade download --releasever=32 +``` + +这个命令将开始在本地下载所有的升级包,为升级做准备。如果你在升级的时候因为没有更新的包、依赖关系破损或退役的包而出现问题,请在输入上述命令时添加 `--allowerasing` 标志。这将允许 DNF 移除可能阻碍系统升级的软件包。 + +#### 4、重启并升级 + +当上一个命令完成了所有升级包的下载,你的系统就可以重新启动了。要将系统引导至升级过程,请在终端中输入以下命令: + +``` +sudo dnf system-upgrade reboot +``` + +此后,系统将重启。在许多版本之前,`fedup` 工具会在内核选择/启动页上创建一个新选项。使用 `dnf-plugin-system-upgrade` 包,你的系统会重启进入 Fedora 31 当前安装的内核;这个是正常的。在选择内核之后,你的系统会立即开始升级过程。 + +现在可能是喝杯咖啡休息的好时机!完成后,系统将重启,你将能够登录到新升级的 Fedora 32 系统。 + +![][5] + +### 解决升级问题 + +有时,升级系统时可能会出现意外问题。如果你遇到任何问题,请访问 [DNF 系统升级文档][6],以获取有关故障排除的更多信息。 + +如果升级时遇到问题,并且系统上安装了第三方仓库,那么在升级时可能需要禁用这些仓库。对于 Fedora 不提供的仓库的支持,请联系仓库的提供者。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/upgrading-fedora-31-to-fedora-32/ + +作者:[Adam Šamalík][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/asamalik/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/04/31-32-816x345.png +[2]: https://linux.cn/article-12164-1.html +[3]: https://fedoraproject.org/wiki/Common_F32_bugs +[4]: https://fedoramagazine.org/taking-smart-backups-duplicity/ +[5]: https://cdn.fedoramagazine.org/wp-content/uploads/2016/06/Screenshot_f23-ws-upgrade-test_2016-06-10_110906-1024x768.png +[6]: https://docs.fedoraproject.org/en-US/quick-docs/dnf-system-upgrade/#Resolving_post-upgrade_issues diff --git a/published/202005/20200428 Using Files and Folders on Desktop Screen in Ubuntu.md b/published/202005/20200428 Using Files and Folders on Desktop Screen in Ubuntu.md new file mode 100644 index 0000000000..a58f9a7895 --- /dev/null +++ b/published/202005/20200428 Using Files and Folders on Desktop Screen in Ubuntu.md @@ -0,0 +1,102 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12198-1.html) +[#]: subject: (Using Files and Folders on Desktop Screen in Ubuntu) +[#]: via: (https://itsfoss.com/add-files-on-desktop-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 Ubuntu 桌面中使用文件和文件夹 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/08/224609chff5qn5ccah56af.jpg) + +> 此初学者教程讨论了 在Ubuntu 桌面上添加文件和文件夹时可能遇到的一些困难。 + +我认识一些习惯将所有重要/常用文件放在桌面上以便快速访问的人。 + +![][1] + +我不喜欢杂乱的桌面,但是我可以想象它实际上可能对某些人有所帮助。 + +在过去的几个版本中,很难在 Ubuntu 的默认 GNOME 桌面上添加文件。这并不是 Ubuntu 的错。 + +[GNOME][2] 的开发者认为,桌面上没有图标和文件的存身之地。当你可以在菜单中轻松搜索文件时,无需将文件放在桌面上。这在部分情况下是事实。 + +这就是为什么 [GNOME 的文件管理器 Nautilus][3] 的较新版本不能很好地支持桌面上的图标和文件的原因。 + +也就是说,在桌面上添加文件和文件夹并非没有可能。让我告诉你如何做。 + +### 在 Ubuntu 的桌面上添加文件和文件夹 + +![][4] + +我在本教程中使用的是 Ubuntu 20.04。对于其他 Ubuntu 版本,步骤可能会有所不同。 + +#### 将文件和文件夹添加到“桌面文件夹” + +如果打开文件管理器,你应该在左侧边栏或文件夹列表中看到一个名为“桌面”的条目。此文件夹(以某种方式)代表你的桌面。 + +![Desktop folder can be used to add files to the desktop screen][5] + +你添加到此文件夹的所有内容都会反映在桌面上。 + +![Anything added to the Desktop folder will be reflected on the desktop screen][6] + +如果你从“桌面文件夹”中删除文件,那么文件也会从桌面中删除。 + +#### 将文件拖放到桌面不起作用 + +现在,如果你尝试从文件管理器往桌面上拖放文件,它会不起使用。这不是一个 bug,它是一个使很多人恼火的功能。 + +一种临时方案是打开两个文件管理器。在其中一个打开“桌面”文件夹,然后将文件拖放到该文件夹​​中,它们将被添加到桌面上。 + +我知道这并不理想,但是你没有太多选择。 + +#### 你不能使用 Ctrl+C 和 Ctrl+V 在桌面上复制粘贴,请使用右键单击菜单 + +更恼人的是,你不能使用 `Ctrl+V`(著名的键盘快捷键)将文件粘贴到桌面上。 + +但是,你仍然可以使用右键单击,然后选择“粘贴”,将文件复制到桌面上。你甚至可以通过这种方式创建新文件夹。 + +![Right click menu can be used for copy-pasting files to desktop][7] + +是否有意义?对我来说不是,但这就是 Ubuntu 20.04 的方式。 + +#### 你无法使用 Delete 键删除文件和文件夹,请再次使用右键菜单 + +更糟糕的是,你无法使用 `Delete` 键或 `Shift+Delete` 键从桌面上删除文件。但是你仍然可以右键单击文件或文件夹,然后选择“移至回收站”来删除文件。 + +![Delete files from desktop using right click][8] + +好了,你现在知道至少有一种方法可以在桌面上添加文件,但有一些限制。不幸的是,这还没有结束。 + +你无法在桌面上用名称搜索文件。通常,如果你开始输入 “abc”,那么以 “abc” 开头的文件会高亮显示。但是在这里不行。 + +我不知道为什么在桌面上添加文件受到了如此多的限制。值得庆幸的是,我不会经常使用它,否则我会感到非常沮丧。 + +如果有兴趣,你也可以阅读[在 Ubuntu 桌面上添加应用快捷方式][9]这篇文章。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/add-files-on-desktop-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/files-on-desktop-ubuntu.jpg?ssl=1 +[2]: https://www.gnome.org/ +[3]: https://wiki.gnome.org/Apps/Files +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/adding-files-desktop-ubuntu.png?ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/desktop-folder-ubuntu.png?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/adding-files-desktop-screen-ubuntu.jpg?ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/adding-new-files-ubuntu-desktop.jpg?ssl=1 +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/delete-files-from-desktop-ubuntu.jpg?ssl=1 +[9]: https://itsfoss.com/ubuntu-desktop-shortcut/ diff --git a/published/202005/20200428 What-s new in Fedora 32 Workstation.md b/published/202005/20200428 What-s new in Fedora 32 Workstation.md new file mode 100644 index 0000000000..17050794d2 --- /dev/null +++ b/published/202005/20200428 What-s new in Fedora 32 Workstation.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12201-1.html) +[#]: subject: (What’s new in Fedora 32 Workstation) +[#]: via: (https://fedoramagazine.org/whats-new-fedora-32-workstation/) +[#]: author: (Ryan Lerch https://fedoramagazine.org/author/ryanlerch/) + +Fedora 32 Workstation 的新功能 +====== + +![][1] + +Fedora 32 Workstation 是我们免费的领先操作系统的[最新版本][2]。你现在可以从[官方网站][3]下载它。Fedora 32 Workstation 中有几个新的且值得注意的变化。请阅读下面的详情。 + +### GNOME 3.36 + +Fedora 32 Workstation 包含了适合所有用户的 GNOME 桌面环境的最新版本。Fedora 32 Workstation 中的 GNOME 3.36 包含了许多更新和改进,包括: + +#### 重新设计的锁屏界面 + +Fedora 32 中的锁屏是一种全新的体验。新设计消除了以前版本中使用的“窗口阴影”,并着重于易用性和速度。 + +![Unlock screen in Fedora 32][4] + +#### 新的扩展程序 + +Fedora 32 有新的“扩展”应用,它可轻松管理你的 GNOME 扩展。过去,扩展是使用“软件”和/或“调整工具”来安装、配置和启用的。 + +![The new Extensions application in Fedora 32][5] + +请注意,默认情况下,Fedora 32 上未安装这个“扩展”应用。需要使用“软件”进行搜索和安装,或在终端中使用以下命令: + +``` +sudo dnf install gnome-extensions-app +``` + +#### 重新组织的设置应用 + +敏锐的 Fedora 用户会注意到“设置”应用已重新组织。设置类别的结构更加扁平,因此可以一次看到更多设置。 + +此外,“关于”中现在有有关系统的更多信息,包括正在运行的窗口系统(例如 Wayland)。 + +![The reorganized settings application in Fedora 32][6] + +#### 重新设计的通知/日历弹出框 + +单击桌面顶部的“日期和时间”可切换“通知/日历”弹出窗口,其中有许多小的样式调整项。此外,弹出窗口现在有“请勿打扰”开关,可快速禁用所有通知。这在希望只显示屏幕而不显示个人通知时很有用。 + +![The new Notification / Calendar popover in Fedora 32 ][7] + +#### 重新设计的时钟应用 + +Fedora 32 完全重新设计了时钟。该设计在较小的窗口中效果更好。 + +![The Clocks application in Fedora 32][8] + +GNOME 3.36 还提供了许多其他功能和增强。有关更多信息,请查看 [GNOME 3.36 的发布说明][9]。 + +### 改进的内存不足处理 + +以前,如果系统内存不足,那么可能会遇到大量使用交换(也称为 [交换抖动][10])–有时会导致 Workstation UI 变慢或在一段时间内无响应。Fedora 32 Workstation 现在默认启用 EarlyOOM。EarlyOOM 可以让用户在低内存的情况下,存在大量使用交换的情况下,更快速地恢复和恢复对系统的控制。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/whats-new-fedora-32-workstation/ + +作者:[Ryan Lerch][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/ryanlerch/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/04/fedora32workstation-816x345.jpg +[2]: https://linux.cn/article-12164-1.html +[3]: https://getfedora.org/workstation +[4]: https://fedoramagazine.org/wp-content/uploads/2020/04/unlock.gif +[5]: https://fedoramagazine.org/wp-content/uploads/2020/04/extensions.png +[6]: https://fedoramagazine.org/wp-content/uploads/2020/04/settings.png +[7]: https://fedoramagazine.org/wp-content/uploads/2020/04/donotdisturb.png +[8]: https://fedoramagazine.org/wp-content/uploads/2020/04/clocks.png +[9]: https://help.gnome.org/misc/release-notes/3.36/ +[10]: https://en.wikipedia.org/wiki/Thrashing_(computer_science) diff --git a/published/202005/20200429 Drop PNG and JPG for your online images- Use WebP.md b/published/202005/20200429 Drop PNG and JPG for your online images- Use WebP.md new file mode 100644 index 0000000000..7f581e778f --- /dev/null +++ b/published/202005/20200429 Drop PNG and JPG for your online images- Use WebP.md @@ -0,0 +1,165 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12193-1.html) +[#]: subject: (Drop PNG and JPG for your online images: Use WebP) +[#]: via: (https://opensource.com/article/20/4/webp-image-compression) +[#]: author: (Jeff Macharyas https://opensource.com/users/jeffmacharyas) + +线上图片请抛弃 PNG 和 JPG:使用 WebP +====== + +> 了解一下这个开源的图片编辑工具来节省时间和空间。 + +![](https://img.linux.net.cn/data/attachment/album/202005/07/143932l22hot7ebhbbqjmm.jpg) + +WebP 是 2010 年 Google 开发的一种图片格式,它为网页上的图片提供了卓越的无损和有损压缩。网站开发者们可以使用 WebP 来创建尺寸更小、细节更丰富的图片,以此来提高网站的速度。更快的加载速度对于网站的用户体验和网站的营销效果是至关重要的。 + +为了在所有设备和用户中达到最佳加载效果,你网站上的图片文件大小不应该超过 500 KB。 + +与 PNG 图片相比,WebP 无损图片通常至少要比 PNG 图片小 25%。在同等的 SSIM(结构相似度structural similarity)质量指标下,WebP 有损图片通常比 JPEG 图片小 25% 到 34%。 + +无损 WebP 也支持透明度。而在可接受有损 RGB 压缩的情况下,有损 WebP 也支持透明度,通常其大小比 PNG 文件小三倍。 + +Google 报告称,把动画 GIF 文件转换为有损 WebP 后文件大小减少了 64%,转换为无损 WebP 后文件大小减少了 19%。 + +WebP 文件格式是一种基于 RIFF(资源互换文件格式resource interchange file format)的文档格式。你可以用 [hexdump][2] 看到文件的签名是 `52 49 46 46`(RIFF): + + +``` +$ hexdump --canonical pixel.webp +00000000  52 49 46 46 26 00 00 00  [...]  |RIFF&...WEBPVP8 | +00000010  1a 00 00 00 30 01 00 9d  [...]  |....0....*......| +00000020  0e 25 a4 00 03 70 00 fe  [...]  |.%...p...`....| +0000002e +``` + +独立的 libwebp 库作为 WebP 技术规范的参考实现,可以从 Google 的 [Git 仓库][3] 或 tar 包中获得。 + +全球在用的 80% 的 web 浏览器兼容 WebP 格式。本文撰写时,Apple 的 Safari 浏览器还不兼容。解决这个问题的方法是将 JPG/PNG 图片与 WebP 图片一起提供,有一些方法和 Wordpress 插件可以做到这一点。 + +### 为什么要这样做? + +我的部分工作是设计和维护我们组织的网站。由于网站是个营销工具,而网站的速度是衡量用户体验的重要指标,我一直致力于提高网站速度,通过把图片转换为 WebP 来减少图片大小是一个很好的解决方案。 + +我使用了 web.dev 来检测其中一个网页,该工具是由 Lighthouse 提供服务的,遵循 Apache 2.0 许可证,可以在 找到。 + +据其官方描述,“LIghthouse 是一个开源的,旨在提升网页质量的自动化工具。你可以在任何公共的或需要鉴权的网页上运行它。它有性能、可用性、渐进式 web 应用、SEO 等方面的审计。你可以在 Chrome 浏览器的开发工具中运行 Lighthouse,也可以通过命令行或作为 Node 模块运行。你输入一个 URL 给 Lighthouse,它会对这个网页进行一系列的审计,然后生成这个网页的审计结果报告。从报告的失败审计条目中可以知道应该怎么优化网页。每条审计都有对应的文档解释为什么该项目是重要的,以及如何修复它。” + +### 创建更小的 WebP 图片 + +我测试的页面返回了三张图片。在它生成的报告中,它提供了推荐和目标。我选择了它报告有 650 KB 的 `app-graphic` 图片。通过把它转换为 WebP 格式,预计可以把图片大小降到 61 KB,节省 589 KB。我在 Photoshop 中把它转换了,用默认的 WebP 设置参数保存它,它的文件大小为 44.9 KB。比预期的还要好!从下面的 Photoshop 截图中可以看出,两张图在视觉质量上完全一样。 + +![WebP vs JPG comparison][4] + +*左图:650 KB(实际大小)。右图: 44.9 KB(转换之后的目标大小)。* + +当然,也可以用开源图片编辑工具 [GIMP][5] 把图片导出为 WebP。它提供了几个质量和压缩的参数: + +![GIMP dialog for exporting webp, as a webp][6] + +另一张图放大后: + +![WebP vs PNG comparison][7] + +PNG(左图)和 WebP(右图),都是从 JPG 转换而来,两图对比可以看出 WebP 不仅在文件大小更小,在视觉质量上也更优秀。 + +### 把图片转换为 WebP + +你也可以用 Linux 的命令行工具把图片从 JPG/PNG 转换为 WebP: + +在命令行使用 `cwebp` 把 PNG 或 JPG 图片文件转换为 WebP 格式。你可以用下面的命令把 PNG 图片文件转换为质量参数为 80 的 WebP 图片。 + +``` +cwebp -q 80 image.png -o image.webp +``` + +你还可以用 [Image Magick][8],这个工具可能在你的发行版本软件仓库中可以找到。转换的子命令是 `convert`,它需要的所有参数就是输入和输出文件: + +``` +convert pixel.png pixel.webp +``` + +### 使用编辑器把图片转换为 WebP + +要在图片编辑器中来把图片转换为 WebP,可以使用 [GIMP][9]。从 2.10 版本开始,它原生地支持 WebP。 + +如果你是 Photoshop 用户,由于 Photoshop 默认不包含 WebP 支持,因此你需要一个转换插件。遵循 Apache License 2.0 许可证发布的 WebPShop 0.2.1 是一个用于打开和保存包括动画图在内的 WebP 图片的 Photoshop 模块,在 可以找到。 + +为了能正常使用它,你需要把它放进 Photoshop 插件目录下的 `bin` 文件夹: + +Windows x64 :`C:\Program Files\Adobe\Adobe Photoshop\Plug-ins\WebPShop.8bi` + +Mac:`Applications/Adobe Photoshop/Plug-ins/WebPShop.plugin` + +### Wordpress 上的 WebP + +很多网站是用 Wordpress 搭建的(我的网站就是)。因此,Wordpress 怎么上传 WebP 图片?本文撰写时,它还不支持。但是,当然已经有插件来满足这种需求,因此你可以在你的网站上同时准备 WebP 和 PNG/JPG 图片(为 Apple 用户)。 + +在 [Marius Hosting][11] 有下面的[说明][10]: + +“直接向 Wordpress 上传 WebP 图片会怎样?这很简单。向你的主题 `functions.php` 文件添加几行内容就可以了。Wordpress 默认不支持展示和上传 WebP 文件,但是我会向你介绍一下怎么通过几个简单的步骤来让它支持。登录进你的 Wordpress 管理员界面,进入‘外观/主题编辑器’找到 `functions.php`。复制下面的代码粘贴到该文件最后并保存: + +``` +//** *Enable upload for webp image files.*/ +function webp_upload_mimes($existing_mimes) { + $existing_mimes['webp'] = 'image/webp'; + return $existing_mimes; +} +add_filter('mime_types', 'webp_upload_mimes'); +``` + +如果你想在‘媒体/媒体库’时看到缩略图预览,那么你需要把下面的代码也添加到 `functions.php` 文件。为了找到 `functions.php` 文件,进入‘外观/主题编辑器’并搜索 `functions.php`,然后复制下面的代码粘贴到文件最后并保存: + +``` +//** * Enable preview / thumbnail for webp image files.*/ +function webp_is_displayable($result, $path) { + if ($result === false) { + $displayable_image_types = array( IMAGETYPE_WEBP ); + $info = @getimagesize( $path ); + + if (empty($info)) { + $result = false; + } elseif (!in_array($info[2], $displayable_image_types)) { + $result = false; + } else { + $result = true; + } + } + + return $result; +} +add_filter('file_is_displayable_image', 'webp_is_displayable', 10, 2); +``` + +” + +### WebP 和未来 + +WebP 是一个健壮而优化的格式。它看起来更好,压缩率更高,并具有其他大部分常见图片格式的所有特性。不必再等了,现在就使用它吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/webp-image-compression + +作者:[Jeff Macharyas][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jeffmacharyas +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/painting_computer_screen_art_design_creative.png?itok=LVAeQx3_ (Painting art on a computer screen) +[2]: https://opensource.com/article/19/8/dig-binary-files-hexdump +[3]: https://storage.googleapis.com/downloads.webmproject.org/releases/webp/index.html +[4]: https://opensource.com/sites/default/files/uploads/webp-vs-jpg-app-graphic.png (WebP vs JPG comparison) +[5]: http://gimp.org +[6]: https://img.linux.net.cn/data/attachment/album/202005/07/143538plu797s4wmhy9b1p.jpg (GIMP dialog for exporting webp, as a webp) +[7]: https://opensource.com/sites/default/files/uploads/xcompare-png-left-webp-right.png (WebP vs PNG comparison) +[8]: https://imagemagick.org +[9]: https://en.wikipedia.org/wiki/GIMP +[10]: https://mariushosting.com/how-to-upload-webp-files-on-wordpress/ +[11]: https://mariushosting.com/ diff --git a/published/202005/20200429 The life-changing magic of git rebase -i.md b/published/202005/20200429 The life-changing magic of git rebase -i.md new file mode 100644 index 0000000000..54665c70fe --- /dev/null +++ b/published/202005/20200429 The life-changing magic of git rebase -i.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12231-1.html) +[#]: subject: (The life-changing magic of git rebase -i) +[#]: via: (https://opensource.com/article/20/4/git-rebase-i) +[#]: author: (Dave Neary https://opensource.com/users/dneary) + +完美生活:git rebase -i +====== + +> 让大家觉得你一次就能写出完美的代码,并让你的补丁更容易审核和合并。 + +![](https://img.linux.net.cn/data/attachment/album/202005/18/185911fvwztwyp4lvbzkw4.jpg) + +软件开发是混乱的。有很多错误的转折、有需要修复的错别字、有需要修正的错误、有需要稍后纠正的临时和粗陋的代码,还有在以后的开发过程中发现一次又一次的问题。有了版本控制,在创建“完美”的最终产品(即准备提交给上游的补丁)的过程中,你会有一个记录着每一个错误转折和修正的原始记录。就像电影中的花絮一样,它们会让人有点尴尬,有时也会让人觉得好笑。 + +如果你使用版本控制来定期保存你的工作线索,然后当你准备提交审核的东西时,又可以隐藏所有这些私人草稿工作,并只提交一份单一的、完美的补丁,那不是很好吗?`git rebase -i`,是重写历史记录的完美方法,可以让大家觉得你一次就写出了完美的代码! + +### git rebase 的作用是什么? + +如果你不熟悉 Git 的复杂性,这里简单介绍一下。在幕后,Git 将项目的不同版本与唯一标识符关联起来,这个标识符由父节点的唯一标识符的哈希以及新版本与其父节点的差异组成。这样就形成了一棵修订树,每个签出项目的人都会得到自己的副本。不同的人可以把项目往不同的方向发展,每个方向都可能从不同的分支点开始。 + +![Master branch vs. private branch][2] + +*左边是 origin 版本库中的主分支,右边是你个人副本中的私有分支。* + +有两种方法可以将你的工作与原始版本库中的主分支整合起来:一种是使用合并:`git merge`,另一种是使用变基:`git rebase`。它们的工作方式非常不同。 + +当你使用 `git merge` 时,会在主分支(`master`)上创建一个新的提交,其中包括所有来自原始位置(`origin`)的修改和所有本地的修改。如果有任何冲突(例如,如果别人修改了你也在修改的文件),则将这些冲突标记出来,并且你有机会在将这个“合并提交”提交到本地版本库之前解决这些冲突。当你将更改推送回父版本库时,所有的本地工作都会以分支的形式出现在 Git 版本库的其他用户面前。 + +但是 `git rebase` 的工作方式不同。它会回滚你的提交,并从主分支(`master`)的顶端再次重放这些提交。这导致了两个主要的变化。首先,由于你的提交现在从一个不同的父节点分支出来,它们的哈希值会被重新计算,并且任何克隆了你的版本库的人都可能得到该版本库的一个残破副本。第二,你没有“合并提交”,所以在将更改重放到主分支上时会识别出任何合并冲突,因此,你需要在进行变基rebase之前先修复它们。现在,当你现在推送你的修改时,你的工作不会出现在分支上,并且看起来像是你是在主分支的最新的提交上写入了所有的修改。 + +![Merge commits preserve history, and rebase rewrites history.][3] + +*合并提交(左)保留了历史,而变基(右)重写历史。* + +然而,这两种方式都有一个缺点:在你准备好分享代码之前,每个人都可以看到你在本地处理问题时的所有涂鸦和编辑。这就是 `git rebase` 的 `--interactive`(或简写 `-i`)标志发挥作用的地方。 + +### git rebase -i 登场 + +`git rebase` 的最大优点是它可以重写历史。但是,为什么仅止于假装你从后面的点分支出来呢?有一种更进一步方法可以重写你是如何准备就绪这些代码的:`git rebase -i`,即交互式的 `git rebase`。 + +这个功能就是 Git 中的 “魔术时光机” 功能。这个标志允许你在做变基时对修订历史记录进行复杂的修改。你可以隐藏你的错误! 将许多小的修改合并到一个崭新的功能补丁中! 重新排列修改历史记录中的显示顺序! + +![output of git rebase -i][4] + +当你运行 `git rebase -i` 时,你会进入一个编辑器会话,其中列出了所有正在被变基的提交,以及可以对其执行的操作的多个选项。默认的选择是选择(`Pick`)。 + +* `Pick`:会在你的历史记录中保留该提交。 +* `Reword`:允许你修改提交信息,可能是修复一个错别字或添加其它注释。 +* `Edit`:允许你在重放分支的过程中对提交进行修改。 +* `Squash`:可以将多个提交合并为一个。 +* 你可以通过在文件中移动来重新排序提交。 + +当你完成后,只需保存最终结果,变基操作就会执行。在你选择修改提交的每个阶段(无论是用 `reword`、`edit`、`squash` 还是发生冲突时),变基都会停止,并允许你在继续提交之前进行适当的修改。 + +上面这个例子的结果是 “One-liner bug fix” 和 “Integate new header everywhere” 被合并到一个提交中,而 “New header for docs website” 和 “D'oh - typo. Fixed” 合并到另一个提交中。就像变魔术一样,其他提交的工作还在你的分支中,但相关的提交已经从你的历史记录中消失了! + +这使得使用 `git send-email` 或者用你新整理好的补丁集在父版本库中创建一个拉取请求,然后来提交一个干净的补丁给上游项目变得很容易。这有很多好处,包括让你的代码更容易审核,更容易接受,也更容易合并。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/git-rebase-i + +作者:[Dave Neary][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dneary +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) +[2]: https://opensource.com/sites/default/files/uploads/master-private-branches.png (Master branch vs. private branch) +[3]: https://opensource.com/sites/default/files/uploads/merge-commit-vs-rebase.png (Merge commits preserve history, and rebase rewrites history.) +[4]: https://opensource.com/sites/default/files/uploads/git-rebase-i.png (output of git rebase -i) diff --git a/published/202005/20200429 Why strace doesn-t work in Docker.md b/published/202005/20200429 Why strace doesn-t work in Docker.md new file mode 100644 index 0000000000..57e5a5b42e --- /dev/null +++ b/published/202005/20200429 Why strace doesn-t work in Docker.md @@ -0,0 +1,161 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12251-1.html) +[#]: subject: (Why strace doesn't work in Docker) +[#]: via: (https://jvns.ca/blog/2020/04/29/why-strace-doesnt-work-in-docker/) +[#]: author: (Julia Evans https://jvns.ca/) + +为什么 strace 在 Docker 中不起作用? +====== + +在编辑“容器如何工作”爱好者杂志的能力页面时,我想试着解释一下为什么 `strace` 在 Docker 容器中无法工作。 + +这里的问题是 —— 如果我在笔记本上的 Docker 容器中运行 `strace`,就会出现这种情况: + +``` +$ docker run -it ubuntu:18.04 /bin/bash +$ # ... install strace ... +[email protected]:/# strace ls +strace: ptrace(PTRACE_TRACEME, ...): Operation not permitted +``` + +`strace` 通过 `ptrace` 系统调用起作用,所以如果不允许使用 `ptrace`,它肯定是不能工作的! 这个问题很容易解决 —— 在我的机器上,是这样解决的: + +``` +docker run --cap-add=SYS_PTRACE -it ubuntu:18.04 /bin/bash +``` + +但我对如何修复它不感兴趣,我想知道为什么会出现这种情况。为什么 `strace` 不能工作,为什么`--cap-add=SYS_PTRACE` 可以解决这个问题? + +### 假设 1:容器进程缺少 `CAP_SYS_PTRACE` 能力。 + +我一直以为原因是 Docker 容器进程默认不具备 `CAP_SYS_PTRACE` 能力。这和它可以被 `--cap-add=SYS_PTRACE` 修复是一回事,是吧? + +但这实际上是不合理的,原因有两个。 + +原因 1:在实验中,作为一个普通用户,我可以对我的用户运行的任何进程进行 `strace`。但如果我检查我的当前进程是否有 `CAP_SYS_PTRACE` 能力,则没有: + +``` +$ getpcaps $$ +Capabilities for `11589': = +``` + +原因 2:`capabilities` 的手册页对 `CAP_SYS_PTRACE` 的介绍是: + +``` +CAP_SYS_PTRACE + * Trace arbitrary processes using ptrace(2); +``` + +所以,`CAP_SYS_PTRACE` 的作用是让你像 root 一样,可以对任何用户拥有的**任意**进程进行 `ptrace`。你不需要用它来对一个只是由你的用户拥有的普通进程进行 `ptrace` 。 + +我用第三种方法测试了一下(LCTT 译注:此处可能原文有误) —— 我用 `docker run --cap-add=SYS_PTRACE -it ubuntu:18.04 /bin/bash` 运行了一个 Docker 容器,去掉了 `CAP_SYS_PTRACE` 能力,但我仍然可以跟踪进程,虽然我已经没有这个能力了。什么?为什么?! + +### 假设 2:关于用户命名空间的事情? + +我的下一个(没有那么充分的依据的)假设是“嗯,也许这个过程是在不同的用户命名空间里,而 `strace` 不能工作,因为某种原因而行不通?”这个问题其实并不相关,但这是我观察时想到的。 + +容器进程是否在不同的用户命名空间中?嗯,在容器中: + +``` +root@e27f594da870:/# ls /proc/$$/ns/user -l +... /proc/1/ns/user -> 'user:[4026531837]' +``` + +在宿主机: + +``` +bork@kiwi:~$ ls /proc/$$/ns/user -l +... /proc/12177/ns/user -> 'user:[4026531837]' +``` + +因为用户命名空间 ID(`4026531837`)是相同的,所以容器中的 root 用户和主机上的 root 用户是完全相同的用户。所以,绝对没有理由不能够对它创建的进程进行 `strace`! + +这个假设并没有什么意义,但我(之前)没有意识到 Docker 容器中的 root 用户和主机上的 root 用户同一个,所以我觉得这很有意思。 + +### 假设 3:ptrace 系统的调用被 seccomp-bpf 规则阻止了 + +我也知道 Docker 使用 seccomp-bpf 来阻止容器进程运行许多系统调用。而 `ptrace` 在[被 Docker 默认的 seccomp 配置文件阻止的系统调用列表][2]中!(实际上,允许的系统调用列表是一个白名单,所以只是`ptrace` 不在默认的白名单中。但得出的结果是一样的。) + +这很容易解释为什么 `strace` 在 Docker 容器中不能工作 —— 如果 `ptrace` 系统调用完全被屏蔽了,那么你当然不能调用它,`strace` 就会失败。 + +让我们来验证一下这个假设 —— 如果我们禁用了所有的 seccomp 规则,`strace` 能在 Docker 容器中工作吗? + +``` +$ docker run --security-opt seccomp=unconfined -it ubuntu:18.04 /bin/bash +$ strace ls +execve("/bin/ls", ["ls"], 0x7ffc69a65580 /* 8 vars */) = 0 +... it works fine ... +``` + +是的,很好用!很好。谜底解开了,除了..... + +### 为什么 `--cap-add=SYS_PTRACE` 能解决问题? + +我们还没有解释的是:为什么 `--cap-add=SYS_PTRACE` 可以解决这个问题? + +`docker run` 的手册页是这样解释 `--cap-add` 参数的。 + +``` +--cap-add=[] + Add Linux capabilities +``` + +这跟 seccomp 规则没有任何关系! 怎么回事? + +### 我们来看看 Docker 源码 + +当文档没有帮助的时候,唯一要做的就是去看源码。 + +Go 语言的好处是,因为依赖关系通常是在一个 Go 仓库里,你可以通过 `grep` 来找出做某件事的代码在哪里。所以我克隆了 `github.com/moby/moby`,然后对一些东西进行 `grep`,比如 `rg CAP_SYS_PTRACE`。 + +我认为是这样的。在 `containerd` 的 seccomp 实现中,在 [contrib/seccomp/seccomp/seccomp_default.go][3] 中,有一堆代码来确保如果一个进程有一个能力,那么它也会(通过 seccomp 规则)获得访问权限,以使用与该能力相关的系统调用。 + +``` +case "CAP_SYS_PTRACE": + s.Syscalls = append(s.Syscalls, specs.LinuxSyscall{ + Names: []string{ + "kcmp", + "process_vm_readv", + "process_vm_writev", + "ptrace", + }, + Action: specs.ActAllow, + Args: []specs.LinuxSeccompArg{}, + }) +``` + +在 moby 中的 [profile/seccomp/seccomp.go][4] 和 [默认的 seccomp 配置文件][5]中,也有一些其他的代码似乎做了一些非常类似的事情,所以有可能就是这个代码在做这个事情。 + +所以我想我们有答案了! + +### Docker 中的 `--cap-add` 做的事情比它说的要多 + +结果似乎是,`--cap-add` 并不像手册页里说的那样,它更像是 `--cap-add-and-also-whiteelist-some-extra-system-calls-if-required`。这很有意义! 如果你具有一个像 `--CAP_SYS_PTRACE` 这样的能力,可以让你使用 `process_vm_readv` 系统调用,但是该系统调用被 seccomp 配置文件阻止了,那对你没有什么帮助! + +所以当你给容器 `CAP_SYS_PTRACE` 能力时,允许使用 `process_vm_readv` 和 `ptrace` 系统调用似乎是一个合理的选择。 + +### 就这样! + +这是个有趣的小事情,我认为这是一个很好的例子,说明了容器是由许多移动的部件组成的,它们以不完全显而易见的方式一起工作。 + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/04/29/why-strace-doesnt-work-in-docker/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: https://wizardzines.com/zines/containers +[2]: https://docs.docker.com/engine/security/seccomp/ +[3]: https://github.com/containerd/containerd/blob/4be98fa28b62e8a012491d655a4d6818ef87b080/contrib/seccomp/seccomp_default.go#L527-L537 +[4]: https://github.com/moby/moby/blob/cc0dfb6e7b22ad120c60a9ce770ea15415767cf9/profiles/seccomp/seccomp.go#L126-L132 +[5]: https://github.com/moby/moby/blob/master/profiles/seccomp/default.json#L723-L739 diff --git a/published/202005/20200430 10 ways to analyze binary files on Linux.md b/published/202005/20200430 10 ways to analyze binary files on Linux.md new file mode 100644 index 0000000000..35fedf607a --- /dev/null +++ b/published/202005/20200430 10 ways to analyze binary files on Linux.md @@ -0,0 +1,314 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12187-1.html) +[#]: subject: (10 ways to analyze binary files on Linux) +[#]: via: (https://opensource.com/article/20/4/linux-binary-analysis) +[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) + +在 Linux 上分析二进制文件的 10 种方法 +====== + +> 这些简单的命令和工具可以帮助你轻松完成分析二进制文件的任务。 + +![](https://img.linux.net.cn/data/attachment/album/202005/05/232115nn0oduodo4oztv0a.jpg) + +“这个世界上有 10 种人:懂二进制的人和不懂二进制的人。” + +我们每天都在与二进制文件打交道,但我们对二进制文件却知之甚少。我所说的二进制,是指你每天运行的可执行文件,从命令行工具到成熟的应用程序都是。 + +Linux 提供了一套丰富的工具,让分析二进制文件变得轻而易举。无论你的工作角色是什么,如果你在 Linux 上工作,了解这些工具的基本知识将帮助你更好地理解你的系统。 + +在这篇文章中,我们将介绍其中一些最流行的 Linux 工具和命令,其中大部分都是 Linux 发行版的一部分。如果没有找到,你可以随时使用你的软件包管理器来安装和探索它们。请记住:学习在正确的场合使用正确的工具需要大量的耐心和练习。 + +### file + +它的作用:帮助确定文件类型。 + +这将是你进行二进制分析的起点。我们每天都在与文件打交道,并非所有的文件都是可执行类型,除此之外还有各种各样的文件类型。在你开始之前,你需要了解要分析的文件类型。是二进制文件、库文件、ASCII 文本文件、视频文件、图片文件、PDF、数据文件等文件吗? + +`file` 命令将帮助你确定你所处理的文件类型。 + +``` +$ file /bin/ls +/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=94943a89d17e9d373b2794dcb1f7e38c95b66c86, stripped +$ +$ file /etc/passwd +/etc/passwd: ASCII text +$ +``` + +### ldd + +它的作用:打印共享对象依赖关系。 + +如果你已经在一个可执行的二进制文件上使用了上面的 `file` 命令,你肯定会看到输出中的“动态链接dynamically linked”信息。它是什么意思呢? + +在开发软件的时候,我们尽量不要重造轮子。有一组常见的任务是大多数软件程序需要的,比如打印输出或从标准输入/打开的文件中读取等。所有这些常见的任务都被抽象成一组通用的函数,然后每个人都可以使用,而不是写出自己的变体。这些常用的函数被放在一个叫 `libc` 或 `glibc` 的库中。 + +如何找到可执行程序所依赖的库?这就是 `ldd` 命令的作用了。对动态链接的二进制文件运行该命令会显示出所有依赖库和它们的路径。 + +``` +$ ldd /bin/ls + linux-vdso.so.1 => (0x00007ffef5ba1000) + libselinux.so.1 => /lib64/libselinux.so.1 (0x00007fea9f854000) + libcap.so.2 => /lib64/libcap.so.2 (0x00007fea9f64f000) + libacl.so.1 => /lib64/libacl.so.1 (0x00007fea9f446000) + libc.so.6 => /lib64/libc.so.6 (0x00007fea9f079000) + libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fea9ee17000) + libdl.so.2 => /lib64/libdl.so.2 (0x00007fea9ec13000) + /lib64/ld-linux-x86-64.so.2 (0x00007fea9fa7b000) + libattr.so.1 => /lib64/libattr.so.1 (0x00007fea9ea0e000) + libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fea9e7f2000) +$ +``` + +### ltrace + +它的作用:库调用跟踪器。 + +我们现在知道如何使用 `ldd` 命令找到一个可执行程序所依赖的库。然而,一个库可以包含数百个函数。在这几百个函数中,哪些是我们的二进制程序正在使用的实际函数? + +`ltrace` 命令可以显示运行时从库中调用的所有函数。在下面的例子中,你可以看到被调用的函数名称,以及传递给该函数的参数。你也可以在输出的最右边看到这些函数返回的内容。 + +``` +$ ltrace ls +__libc_start_main(0x4028c0, 1, 0x7ffd94023b88, 0x412950 +strrchr("ls", '/') = nil +setlocale(LC_ALL, "") = "en_US.UTF-8" +bindtextdomain("coreutils", "/usr/share/locale") = "/usr/share/locale" +textdomain("coreutils") = "coreutils" +__cxa_atexit(0x40a930, 0, 0, 0x736c6974756572) = 0 +isatty(1) = 1 +getenv("QUOTING_STYLE") = nil +getenv("COLUMNS") = nil +ioctl(1, 21523, 0x7ffd94023a50) = 0 +<< snip >> +fflush(0x7ff7baae61c0) = 0 +fclose(0x7ff7baae61c0) = 0 ++++ exited (status 0) +++ +$ +``` + +### hexdump + +它的作用:以 ASCII、十进制、十六进制或八进制显示文件内容。 + +通常情况下,当你用一个应用程序打开一个文件,而它不知道如何处理该文件时,就会出现这种情况。尝试用 `vim` 打开一个可执行文件或视频文件,你屏幕上会看到的只是抛出的乱码。 + +在 `hexdump` 中打开未知文件,可以帮助你看到文件的具体内容。你也可以选择使用一些命令行选项来查看用 ASCII 表示的文件数据。这可能会帮助你了解到它是什么类型的文件。 + +``` +$ hexdump -C /bin/ls | head +00000000  7f 45 4c 46 02 01 01 00  00 00 00 00 00 00 00 00  |.ELF............| +00000010  02 00 3e 00 01 00 00 00  d4 42 40 00 00 00 00 00  |..>......B@.....| +00000020  40 00 00 00 00 00 00 00  f0 c3 01 00 00 00 00 00  |@...............| +00000030  00 00 00 00 40 00 38 00  09 00 40 00 1f 00 1e 00  |....@.8...@.....| +00000040  06 00 00 00 05 00 00 00  40 00 00 00 00 00 00 00  |........@.......| +00000050  40 00 40 00 00 00 00 00  40 00 40 00 00 00 00 00  |@.@.....@.@.....| +00000060  f8 01 00 00 00 00 00 00  f8 01 00 00 00 00 00 00  |................| +00000070  08 00 00 00 00 00 00 00  03 00 00 00 04 00 00 00  |................| +00000080  38 02 00 00 00 00 00 00  38 02 40 00 00 00 00 00  |8.......8.@.....| +00000090  38 02 40 00 00 00 00 00  1c 00 00 00 00 00 00 00  |8.@.............| +$ +``` + +### strings + +它的作用:打印文件中的可打印字符的字符串。 + +如果你只是在二进制中寻找可打印的字符,那么 `hexdump` 对于你的使用场景来说似乎有点矫枉过正,你可以使用 `strings` 命令。 + +在开发软件的时候,各种文本/ASCII 信息会被添加到其中,比如打印信息、调试信息、帮助信息、错误等。只要这些信息都存在于二进制文件中,就可以用 `strings` 命令将其转储到屏幕上。 + +``` +$ strings /bin/ls +``` + +### readelf + +它的作用:显示有关 ELF 文件的信息。 + +ELF(可执行和可链接文件格式Executable and Linkable File Format)是可执行文件或二进制文件的主流格式,不仅是 Linux 系统,也是各种 UNIX 系统的主流文件格式。如果你已经使用了像 `file` 命令这样的工具,它告诉你文件是 ELF 格式,那么下一步就是使用 `readelf` 命令和它的各种选项来进一步分析文件。 + +在使用 `readelf` 命令时,有一份实际的 ELF 规范的参考是非常有用的。你可以在[这里][2]找到该规范。  + +``` +$ readelf -h /bin/ls +ELF Header: +  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 +  Class:                             ELF64 +  Data:                              2's complement, little endian +  Version:                           1 (current) +  OS/ABI:                            UNIX - System V +  ABI Version:                       0 +  Type:                              EXEC (Executable file) +  Machine:                           Advanced Micro Devices X86-64 +  Version:                           0x1 +  Entry point address:               0x4042d4 +  Start of program headers:          64 (bytes into file) +  Start of section headers:          115696 (bytes into file) +  Flags:                             0x0 +  Size of this header:               64 (bytes) +  Size of program headers:           56 (bytes) +  Number of program headers:         9 +  Size of section headers:           64 (bytes) +  Number of section headers:         31 +  Section header string table index: 30 +$ +``` + +### objdump + +它的作用:从对象文件中显示信息。 + +二进制文件是通过你编写的源码创建的,这些源码会通过一个叫做编译器的工具进行编译。这个编译器会生成相对于源代码的机器语言指令,然后由 CPU 执行特定的任务。这些机器语言代码可以通过被称为汇编语言的助记词来解读。汇编语言是一组指令,它可以帮助你理解由程序所进行并最终在 CPU 上执行的操作。 + +`objdump` 实用程序读取二进制或可执行文件,并将汇编语言指令转储到屏幕上。汇编语言知识对于理解 `objdump` 命令的输出至关重要。 + +请记住:汇编语言是特定于体系结构的。 + +``` +$ objdump -d /bin/ls | head + +/bin/ls: file format elf64-x86-64 + +Disassembly of section .init: + +0000000000402150 <_init@@Base>: + 402150: 48 83 ec 08 sub $0x8,%rsp + 402154: 48 8b 05 6d 8e 21 00 mov 0x218e6d(%rip),%rax # 61afc8 <__gmon_start__> + 40215b: 48 85 c0 test %rax,%rax +$ +``` + +### strace + +它的作用:跟踪系统调用和信号。 + +如果你用过前面提到的 `ltrace`,那就把 `strace` 想成是类似的。唯一的区别是,`strace` 工具不是追踪调用的库,而是追踪系统调用。系统调用是你与内核对接来完成工作的。 + +举个例子,如果你想把一些东西打印到屏幕上,你会使用标准库 `libc` 中的 `printf` 或 `puts` 函数;但是,在底层,最终会有一个名为 `write` 的系统调用来实际把东西打印到屏幕上。 + +``` +$ strace -f /bin/ls +execve("/bin/ls", ["/bin/ls"], [/* 17 vars */]) = 0 +brk(NULL) = 0x686000 +mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f967956a000 +access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory) +open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3 +fstat(3, {st_mode=S_IFREG|0644, st_size=40661, ...}) = 0 +mmap(NULL, 40661, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f9679560000 +close(3) = 0 +<< snip >> +fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0 +mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9679569000 +write(1, "R2 RH\n", 7R2 RH +) = 7 +close(1) = 0 +munmap(0x7f9679569000, 4096) = 0 +close(2) = 0 +exit_group(0) = ? ++++ exited with 0 +++ +$ +``` + +### nm + +它的作用:列出对象文件中的符号。 + +如果你所使用的二进制文件没有被剥离,`nm` 命令将为你提供在编译过程中嵌入到二进制文件中的有价值的信息。`nm` 可以帮助你从二进制文件中识别变量和函数。你可以想象一下,如果你无法访问二进制文件的源代码时,这将是多么有用。 + +为了展示 `nm`,我们快速编写了一个小程序,用 `-g` 选项编译,我们会看到这个二进制文件没有被剥离。 + +``` +$ cat hello.c +#include + +int main() { + printf("Hello world!"); + return 0; +} +$ +$ gcc -g hello.c -o hello +$ +$ file hello +hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=3de46c8efb98bce4ad525d3328121568ba3d8a5d, not stripped +$ +$ ./hello +Hello world!$ +$ + + +$ nm hello | tail +0000000000600e20 d __JCR_END__ +0000000000600e20 d __JCR_LIST__ +00000000004005b0 T __libc_csu_fini +0000000000400540 T __libc_csu_init + U __libc_start_main@@GLIBC_2.2.5 +000000000040051d T main + U printf@@GLIBC_2.2.5 +0000000000400490 t register_tm_clones +0000000000400430 T _start +0000000000601030 D __TMC_END__ +$ +``` + +### gdb + +它的作用:GNU 调试器。 + +好吧,不是所有的二进制文件中的东西都可以进行静态分析。我们确实执行了一些运行二进制文件(进行分析)的命令,比如 `ltrace` 和 `strace`;然而,软件由各种条件组成,这些条件可能会导致执行不同的替代路径。 + +分析这些路径的唯一方法是在运行时环境,在任何给定的位置停止或暂停程序,并能够分析信息,然后再往下执行。 + +这就是调试器的作用,在 Linux 上,`gdb` 就是调试器的事实标准。它可以帮助你加载程序,在特定的地方设置断点,分析内存和 CPU 的寄存器,以及更多的功能。它是对上面提到的其他工具的补充,可以让你做更多的运行时分析。 + +有一点需要注意的是,一旦你使用 `gdb` 加载一个程序,你会看到它自己的 `(gdb)` 提示符。所有进一步的命令都将在这个 `gdb` 命令提示符中运行,直到你退出。 + +我们将使用我们之前编译的 `hello` 程序,使用 `gdb` 来看看它的工作原理。 + +``` +$ gdb -q ./hello +Reading symbols from /home/flash/hello...done. +(gdb) break main +Breakpoint 1 at 0x400521: file hello.c, line 4. +(gdb) info break +Num Type Disp Enb Address What +1 breakpoint keep y 0x0000000000400521 in main at hello.c:4 +(gdb) run +Starting program: /home/flash/./hello + +Breakpoint 1, main () at hello.c:4 +4 printf("Hello world!"); +Missing separate debuginfos, use: debuginfo-install glibc-2.17-260.el7_6.6.x86_64 +(gdb) bt +#0 main () at hello.c:4 +(gdb) c +Continuing. +Hello world![Inferior 1 (process 29620) exited normally] +(gdb) q +$ +``` + +### 结语 + +一旦你习惯了使用这些原生的 Linux 二进制分析工具,并理解了它们提供的输出,你就可以转向更高级和专业的开源二进制分析工具,比如 [radare2][3]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/linux-binary-analysis + +作者:[Gaurav Kamathe][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gkamathe +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY (Tux with binary code background) +[2]: http://www.skyfree.org/linux/references/ELF_Format.pdf +[3]: https://github.com/radareorg/radare2 diff --git a/published/202005/20200430 Three Methods Boot CentOS-RHEL 7-8 Systems in Single User Mode.md b/published/202005/20200430 Three Methods Boot CentOS-RHEL 7-8 Systems in Single User Mode.md new file mode 100644 index 0000000000..4b7edb67e9 --- /dev/null +++ b/published/202005/20200430 Three Methods Boot CentOS-RHEL 7-8 Systems in Single User Mode.md @@ -0,0 +1,165 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12181-1.html) +[#]: subject: (Three Methods Boot CentOS/RHEL 7/8 Systems in Single User Mode) +[#]: via: (https://www.2daygeek.com/boot-centos-7-8-rhel-7-8-single-user-mode/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +以单用户模式启动 CentOS/RHEL 7/8 的三种方法 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/03/230109uw1f9zvv9upbhwv8.jpg) + +单用户模式,也被称为维护模式,超级用户可以在此模式下恢复/修复系统问题。 + +通常情况下,这类问题在多用户环境中修复不了。系统可以启动但功能不能正常运行或者你登录不了系统。 + +在基于 [Red Hat][1](RHEL)7/8 的系统中,使用 `runlevel1.target` 或 `rescue.target` 来实现。 + +在此模式下,系统会挂载所有的本地文件系统,但不开启网络接口。 + +系统仅启动特定的几个服务和修复系统必要的尽可能少的功能。 + +当你想运行文件系统一致性检查来修复损坏的文件系统,或忘记 root 密码后重置密码,或要修复系统上的一个挂载点问题时,这个方法会很有用。 + +你可以用下面三种方法以单用户模式启动 [CentOS][2]/[RHEL][3] 7/8 系统。 + + * 方法 1:通过向内核添加 `rd.break` 参数来以单用户模式启动 CentOS/RHEL 7/8 系统 + * 方法 2:通过用 `init=/bin/bash` 或 `init=/bin/sh` 替换内核中的 `rhgb quiet` 语句来以单用户模式启动 CentOS/RHEL 7/8 系统 + * 方法 3:通过用 `rw init=/sysroot/bin/sh` 参数替换内核中的 `ro` 语句以单用户模式启动 CentOS/RHEL 7/8 系统 + +### 方法 1 + +通过向内核添加 `rd.break` 参数来以单用户模式启动 CentOS/RHEL 7/8 系统。 + +重启你的系统,在 GRUB2 启动界面,按下 `e` 键来编辑选中的内核。你需要选中第一行,第一个是最新的内核,然而如果你想用旧的内核启动系统你也可以选择其他的行。 + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-2.png) + +根据你的 RHEL/CentOS 版本,找到 `linux16` 或 `linux` 语句,按下键盘上的 `End` 键,跳到行末,像下面截图中展示的那样添加关键词 `rd.break`,按下 `Ctrl+x` 或 `F10` 来进入单用户模式。 + +如果你的系统是 RHEL/CentOS 7,你需要找 `linux16`,如果你的系统是 RHEL/CentOS 8,那么你需要找 `linux`。 + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-3.png) + +这个修改会让你的 root 文件系统以 “只读(`ro`)” 模式挂载。你可以用下面的命令来验证下。下面的输出也明确地告诉你当前是在 “紧急模式Emergency Mode”。 + +``` +# mount | grep root +``` + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-5.png) + +为了修改 `sysroot` 文件系统,你需要用读写模式(`rw`)重新挂载它。 + +``` +# mount -o remount,rw /sysroot +``` + +运行下面的命令修改环境,这就是大家熟知的 “监禁目录” 或 “chroot 监狱”。 + +``` +# chroot /sysroot +``` + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-8.png) + +现在,单用户模式已经完全准备好了。当你修复了你的问题要退出单用户模式时,执行下面的步骤。 + +CentOS/RHEL 7/8 默认使用 SELinux,因此创建下面的隐藏文件,这个文件会在下一次启动时重新标记所有文件。 + +``` +# touch /.autorelabel +``` + +最后,用下面的命令重启系统。你也可以输入两次 `exit` 命令来重启你的系统。 + +``` +# reboot -f +``` + +### 方法 2 + +通过用 `init=/bin/bash` 或 `init=/bin/sh` 替换内核中的 `rhgb quiet` 语句来以单用户模式启动 CentOS/RHEL 7/8 系统。 + +重启你的系统,在 GRUB2 启动界面,按下 `e` 键来编辑选中的内核。 + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-2.png) + +找到语句 `rhgb quiet`,用 `init=/bin/bash` 或 `init=/bin/sh` 替换它,然后按下 `Ctrl+x` 或 `F10` 来进入单用户模式。 + +`init=/bin/bash` 的截图。 + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-1.png) + +`init=/bin/sh` 的截图。 + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-1a.png) + +默认情况下,上面的操作会以只读(`ro`)模式挂载你的 `/` 分区,因此你需要以读写(`rw`)模式重新挂载 `/` 文件系统,这样才能修改它。 + +``` +# mount -o remount,rw / +``` + +![](https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-4.png) + +现在你可以执行你的任务了。当结束时,执行下面的命令来开启重启时的 SELinux 重新标记。 + +``` +# touch /.autorelabel +``` + +最后,重启系统。 + +``` +# exec /sbin/init 6 +``` + +### 方法 3 + +通过用 `rw init=/sysroot/bin/sh` 参数替换内核中的 `ro` 单词,以单用户模式启动 CentOS/RHEL 7/8 系统。 + +为了中断自动启动的过程,重启你的系统并在 GRUB2 启动界面按下任意键。 + +现在会展示你系统上所有可用的内核,选择最新的内核,按下 `e` 键来编辑选中的内核参数。 + +找到以 `linux` 或 `linux16` 开头的语句,用 `rw init=/sysroot/bin/sh` 替换 `ro`。替换完后按下 `Ctrl+x` 或 `F10` 来进入单用户模式。 + +运行下面的命令把环境切换为 “chroot 监狱”。 + +``` +# chroot /sysroot +``` + +如果需要,做出必要的修改。修改完后,执行下面的命令来开启重启时的 SELinux 重新标记。 + +``` +# touch /.autorelabel +``` + +最后,重启系统。 + +``` +# reboot -f +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/boot-centos-7-8-rhel-7-8-single-user-mode/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/red-hat/ +[2]: https://www.2daygeek.com/category/centos/ +[3]: https://www.2daygeek.com/category/rhel/ +[4]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 diff --git a/published/202005/20200501 How to Handle Automatic Updates in Ubuntu.md b/published/202005/20200501 How to Handle Automatic Updates in Ubuntu.md new file mode 100644 index 0000000000..4339c22494 --- /dev/null +++ b/published/202005/20200501 How to Handle Automatic Updates in Ubuntu.md @@ -0,0 +1,129 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12257-1.html) +[#]: subject: (How to Handle Automatic Updates in Ubuntu) +[#]: via: (https://itsfoss.com/auto-updates-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 中处理自动的无人值守升级 +====== + +> 本教程教你如何处理无人值守的升级,即 Ubuntu Linux 的自动系统更新。 + +![](https://img.linux.net.cn/data/attachment/album/202005/27/234040fxb0nkc53pk0nxvx.jpg) + +有时,当你尝试[关闭 Ubuntu 系统][1]时,可能看到这个阻止你关闭的页面: + +> 关机过程中正在进行无人值守升级,请不要关闭计算机。 + +![Unattended Upgrade In Progress In Ubuntu][2] + +你可能会问这个“无人值守升级”是什么,怎么会在你不知情的情况下运行呢? + +原因是 [Ubuntu][3] 非常重视系统的安全性。默认情况下,它会每天自动检查系统更新,如果发现安全更新,它会下载这些更新并自行安装。对于正常的系统和应用更新,它会通过软件更新程序通知你。 + +由于所有这些都是在后台发生的,所以在你尝试关闭系统或尝试自行安装应用程序之前,你甚至不会意识到这一点。 + +在这些无人值守的升级过程中,尝试安装新软件,会导致著名的[无法获得锁定的错误][4]。 + +![][5] + +如你所见,自动更新带来了一些小麻烦。你可以选择禁用自动更新,但这意味着你必须一直手动检查并[更新你的 Ubuntu 系统][6]。 + +> **你真的需要禁用自动更新吗?** +> +> 请注意,这是一项安全功能。Linux 实际上允许你禁用系统中的所有功能,甚至禁用这些安全功能。 +> +> 但是我认为,作为普通用户,**你不应该禁用自动更新**。毕竟,它可以确保你的系统安全。 +> +> 为了确保系统的安全性,你可以忍受自动更新所带来的小麻烦。 + +现在,你已经收到警告,还是觉得承担手动更新系统的额外任务更好,那么让我们看看如何处理自动更新。 + +与往常一样,有两种方法可以做到:GUI 和命令行。 我将向你展示两种方法。 + +我在这里使用 Ubuntu 20.04,但是这些步骤对 Ubuntu 18.04 和任何其他 Ubuntu 版本均有效。 + +### 方法 1:以图形方式禁用 Ubuntu 中的自动更新 + +进入菜单并查找“软件和更新”工具。 + +![Software & Updates Settings][7] + +在此处,进入“更新”选项卡。查找“自动检查更新”。默认情况下,它设置为“每日”。 + +你可以将其更改为“从不”,你的系统将永远不会检查更新。如果不检查更新,它就不会找到要安装的新的更新。 + +![Disable Auto Updates in Ubuntu Completely][8] + +如果这样做,那么必须不时手动更新系统。但是,这是额外的工作,你可能不会一直记得。 + +#### 在 Ubuntu 中处理自动更新的更好方法 + +就个人而言,我建议让它自己检查更新。如果你不希望它自动安装更新,那么可以更改该行为,以通知有关安全更新的可用性。 + +保持“自动检查更新”为“每日”,然后将“有安全更新时”选项更改为“立即显示”,而不是“自动下载并安装”。 + +![Get notified for security updates instead of automatically installing them][9] + +这样,它会检查是否有更新,而不是在后台自动安装更新,软件更新程序会通知你有可用于系统的更新。而你的系统已经完成正常的系统和软件更新。 + +![Get notified about security updates][10] + +使用此设置,关闭系统时将不会看到“正在进行的无人值守升级”。但是,由于两个不同的进程无法同时使用 apt 包管理器,因此你仍然可能会遇到“无法锁定”错误。 + +我相信这是一个更好的解决方案,你不认为是么? + +如我承诺的同时有 GUI 和命令行方法一样,让我向你展示如何在终端中禁用无人值守的升级。 + +### 如何在 Ubuntu 中使用命令行禁用自动更新 + +你可以在 `/etc/apt/apt.conf.d/20auto-upgrades` 中找到自动升级设置。Ubuntu 终端中的默认文本编辑器是 Nano,因此你可以使用以下命令来编辑此文件: + +``` +sudo nano /etc/apt/apt.conf.d/20auto-upgrades +``` + +现在,如果你不希望系统自动检查更新,那么可以将 `APT::Periodic::Update-Package-Lists` 的值更改为 `"0"`。 + +``` +APT::Periodic::Update-Package-Lists "0"; +APT::Periodic::Unattended-Upgrade "0"; +``` + +如果你希望它检查更新但不自动安装无人值守的升级,那么可以选择将其设置为: + +``` +APT::Periodic::Update-Package-Lists "1"; +APT::Periodic::Unattended-Upgrade "0"; +``` + +### 最后 + +由于某种原因,启用了自动安全更新,建议你保持这种状态。这个小烦恼实际上并不值得冒险损害系统安全性。你怎么看? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/auto-updates-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/schedule-shutdown-ubuntu/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/unattended-upgrade-in-progress-in-ubuntu.png?ssl=1 +[3]: https://ubuntu.com/ +[4]: https://itsfoss.com/could-not-get-lock-error/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/Could_not_get_lock.jpg?ssl=1 +[6]: https://itsfoss.com/update-ubuntu/ +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/software-updates-settings-ubuntu-20-04.jpg?ssl=1 +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/disable-auto-updates-ubuntu.jpg?ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/handle-auto-updates-ubuntu.jpg?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/updates-available-ubuntu.png?ssl=1 diff --git a/published/202005/20200501 Using mergerfs to increase your virtual storage.md b/published/202005/20200501 Using mergerfs to increase your virtual storage.md new file mode 100644 index 0000000000..de9b8af2c7 --- /dev/null +++ b/published/202005/20200501 Using mergerfs to increase your virtual storage.md @@ -0,0 +1,143 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12207-1.html) +[#]: subject: (Using mergerfs to increase your virtual storage) +[#]: via: (https://fedoramagazine.org/using-mergerfs-to-increase-your-virtual-storage/) +[#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/) + +使用 mergefs 增加虚拟存储 +====== + +![][1] + +如果你想在一个媒体项目中用到了多个磁盘或分区,不想丢失任何现有数据,但又想将所有文件都存放在一个驱动器下,该怎么办?这时,mergefs 就能派上用场! + +[mergerfs][2] 是一个联合文件系统,旨在简化存储和管理众多商业存储设备上的文件。 + +你需要从他们的 [GitHub][3] 页面获取最新的 RPM。Fedora 的版本名称中带有 “fc” 和版本号。例如,这是 Fedora 31 的版本: [mergerfs-2.29.0-1.fc31.x86_64.rpm][4]。 + +### 安装和配置 mergefs + +使用 `sudo` 安装已下载的 mergefs 软件包: + +``` +$ sudo dnf install mergerfs-2.29.0-1.fc31.x86_64.rpm +``` + +现在,你可以将多个磁盘挂载为一个驱动器。如果你有一台媒体服务器,并且希望所有媒体文件都显示在一个地方,这将很方便。如果将新文件上传到系统,那么可以将它们复制到 mergefs 目录,mergefs 会自动将它们复制具有足够可用空间的磁盘上。 + +这是使你更容易理解的例子: + +``` +$ df -hT | grep disk +/dev/sdb1 ext4 23M 386K 21M 2% /disk1 +/dev/sdc1 ext4 44M 1.1M 40M 3% /disk2 + +$ ls -l /disk1/Videos/ +total 1 +-rw-r--r--. 1 curt curt 0 Mar 8 17:17 Our Wedding.mkv + +$ ls -l /disk2/Videos/ +total 2 +-rw-r--r--. 1 curt curt 0 Mar 8 17:17 Baby's first Xmas.mkv +-rw-rw-r--. 1 curt curt 0 Mar 8 17:21 Halloween hijinks.mkv +``` + +在此例中挂载了两块磁盘,分别为 `disk1` 和 `disk2`。两个驱动器都有一个包含文件的 `Videos` 目录。 + +现在,我们将使用 mergefs 挂载这些驱动器,使它们看起来像一个更大的驱动器。 + +``` +$ sudo mergerfs -o defaults,allow_other,use_ino,category.create=mfs,moveonenospc=true,minfreespace=1M /disk1:/disk2 /media +``` + +mergefs 手册页非常庞杂,因此我们将说明上面提到的选项。 + + * `defaults`:除非指定,否则将使用默认设置。 + * `allow_other`:允许 `sudo` 或 `root` 以外的用户查看文件系统。 + * `use_ino`:让 mergefs 提供文件/目录 inode 而不是 libfuse。虽然不是默认值,但建议你启用它,以便链接的文件共享相同的 inode 值。 + * `category.create=mfs`:根据可用空间在驱动器间传播文件。 + * `moveonenospc=true`:如果启用,那么如果写入失败,将进行扫描以查找具有最大可用空间的驱动器。 + * `minfreespace=1M`:最小使用空间值。 + * `disk1`:第一块硬盘。 + * `disk2`:第二块硬盘。 + * `/media`:挂载驱动器的目录。 + +看起来是这样的: + +``` +$ df -hT | grep disk +/dev/sdb1 ext4 23M 386K 21M 2% /disk1 +/dev/sdc1 ext4 44M 1.1M 40M 3% /disk2 + +$ df -hT | grep media +1:2 fuse.mergerfs 66M 1.4M 60M 3% /media +``` + +你可以看到现在 mergefs 挂载显示的总容量为 66M,这是两块硬盘的总容量。 + +继续示例: + +有一个叫 `Baby's second Xmas.mkv` 的 30M 视频。让我们将其复制到用 mergerfs 挂载的 `/media` 文件夹中。 + +``` +$ ls -lh "Baby's second Xmas.mkv" +-rw-rw-r--. 1 curt curt 30M Apr 20 08:45 Baby's second Xmas.mkv +$ cp "Baby's second Xmas.mkv" /media/Videos/ +``` + +这是最终结果: + +``` +$ df -hT | grep disk +/dev/sdb1 ext4 23M 386K 21M 2% /disk1 +/dev/sdc1 ext4 44M 31M 9.8M 76% /disk2 + +$ df -hT | grep media +1:2 fuse.mergerfs 66M 31M 30M 51% /media +``` + +从磁盘空间利用率中可以看到,因为 `disk1` 没有足够的可用空间,所以 mergefs 自动将文件复制到 `disk2`。 + +这是所有文件详情: + +``` +$ ls -l /disk1/Videos/ +total 1 +-rw-r--r--. 1 curt curt 0 Mar 8 17:17 Our Wedding.mkv + +$ ls -l /disk2/Videos/ +total 30003 +-rw-r--r--. 1 curt curt 0 Mar 8 17:17 Baby's first Xmas.mkv +-rw-rw-r--. 1 curt curt 30720000 Apr 20 08:47 Baby's second Xmas.mkv +-rw-rw-r--. 1 curt curt 0 Mar 8 17:21 Halloween hijinks.mkv + +$ ls -l /media/Videos/ +total 30004 +-rw-r--r--. 1 curt curt 0 Mar 8 17:17 Baby's first Xmas.mkv +-rw-rw-r--. 1 curt curt 30720000 Apr 20 08:47 Baby's second Xmas.mkv +-rw-rw-r--. 1 curt curt 0 Mar 8 17:21 Halloween hijinks.mkv +-rw-r--r--. 1 curt curt 0 Mar 8 17:17 Our Wedding.mkv +``` + +当你将文件复制到 mergefs 挂载点时,它将始终将文件复制到有足够可用空间的硬盘上。如果池中的所有驱动器都没有足够的可用空间,那么你将无法复制它们。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/using-mergerfs-to-increase-your-virtual-storage/ + +作者:[Curt Warfield][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rcurtiswarfield/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/04/mergerfs-816x346.png +[2]: https://github.com/trapexit/mergerfs +[3]: https://github.com/trapexit/mergerfs/releases +[4]: https://github.com/trapexit/mergerfs/releases/download/2.29.0/mergerfs-2.29.0-1.fc31.x86_64.rpm diff --git a/published/202005/20200502 Mid-stack inlining in Go.md b/published/202005/20200502 Mid-stack inlining in Go.md new file mode 100644 index 0000000000..588286626a --- /dev/null +++ b/published/202005/20200502 Mid-stack inlining in Go.md @@ -0,0 +1,208 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12184-1.html) +[#]: subject: (Mid-stack inlining in Go) +[#]: via: (https://dave.cheney.net/2020/05/02/mid-stack-inlining-in-go) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Go 中对栈中函数进行内联 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/04/230304avxkxlyoozbiw1bn.jpg) + +[上一篇文章][1]中我论述了叶子内联leaf inlining是怎样让 Go 编译器减少函数调用的开销的,以及延伸出了跨函数边界的优化的机会。本文中,我要论述内联的限制以及叶子内联与栈中内联mid-stack inlining的对比。 + +### 内联的限制 + +把函数内联到它的调用处消除了调用的开销,为编译器进行其他的优化提供了更好的机会,那么问题来了,既然内联这么好,内联得越多开销就越少,*为什么不尽可能多地内联呢?* + +内联可能会以增加程序大小换来更快的执行时间。限制内联的最主要原因是,创建许多函数的内联副本会增加编译时间,并导致生成更大的二进制文件的边际效应。即使把内联带来的进一步的优化机会考虑在内,太激进的内联也可能会增加生成的二进制文件的大小和编译时间。 + +内联收益最大的是[小函数][2],相对于调用它们的开销来说,这些函数做很少的工作。随着函数大小的增长,函数内部做的工作与函数调用的开销相比省下的时间越来越少。函数越大通常越复杂,因此优化其内联形式相对于原地优化的好处会减少。 + +### 内联预算 + +在编译过程中,每个函数的内联能力是用*内联预算*计算的 [^1]。开销的计算过程可以巧妙地内化,像一元和二元等简单操作,在抽象语法数Abstract Syntax Tree(AST)中通常是每个节点一个单位,更复杂的操作如 `make` 可能单位更多。考虑下面的例子: + +```go +package main + +func small() string { + s := "hello, " + "world!" + return s +} + +func large() string { + s := "a" + s += "b" + s += "c" + s += "d" + s += "e" + s += "f" + s += "g" + s += "h" + s += "i" + s += "j" + s += "k" + s += "l" + s += "m" + s += "n" + s += "o" + s += "p" + s += "q" + s += "r" + s += "s" + s += "t" + s += "u" + s += "v" + s += "w" + s += "x" + s += "y" + s += "z" + return s +} + +func main() { + small() + large() +} +``` + +使用 `-gcflags=-m=2` 参数编译这个函数能让我们看到编译器分配给每个函数的开销: + +```bash +% go build -gcflags=-m=2 inl.go +# command-line-arguments +./inl.go:3:6: can inline small with cost 7 as: func() string { s := "hello, world!"; return s } +./inl.go:8:6: cannot inline large: function too complex: cost 82 exceeds budget 80 +./inl.go:38:6: can inline main with cost 68 as: func() { small(); large() } +./inl.go:39:7: inlining call to small func() string { s := "hello, world!"; return s } +``` + +编译器根据函数 `func small()` 的开销(7)决定可以对它内联,而 `func large()` 的开销太大,编译器决定不进行内联。`func main()` 被标记为适合内联的,分配了 68 的开销;其中 `small` 占用 7,调用 `small` 函数占用 57,剩余的(4)是它自己的开销。 + +可以用 `-gcflag=-l` 参数控制内联预算的等级。下面是可使用的值: + + * `-gcflags=-l=0` 默认的内联等级。 + * `-gcflags=-l`(或 `-gcflags=-l=1`)取消内联。 + * `-gcflags=-l=2` 和 `-gcflags=-l=3` 现在已经不使用了。和 `-gcflags=-l=0` 相比没有区别。 + * `-gcflags=-l=4` 减少非叶子函数和通过接口调用的函数的开销。[^2] + +#### 不确定语句的优化 + +一些函数虽然内联的开销很小,但由于太复杂它们仍不适合进行内联。这就是函数的不确定性,因为一些操作的语义在内联后很难去推导,如 `recover`、`break`。其他的操作,如 `select` 和 `go` 涉及运行时的协调,因此内联后引入的额外的开销不能抵消内联带来的收益。 + +不确定的语句也包括 `for` 和 `range`,这些语句不一定开销很大,但目前为止还没有对它们进行优化。 + +### 栈中函数优化 + +在过去,Go 编译器只对叶子函数进行内联 —— 只有那些不调用其他函数的函数才有资格。在上一段不确定的语句的探讨内容中,一次函数调用就会让这个函数失去内联的资格。 + +进入栈中进行内联,就像它的名字一样,能内联在函数调用栈中间的函数,不需要先让它下面的所有的函数都被标记为有资格内联的。栈中内联是 David Lazar 在 Go 1.9 中引入的,并在随后的版本中做了改进。[这篇文稿][5]深入探究了保留栈追踪行为和被深度内联后的代码路径里的 `runtime.Callers` 的难点。 + +在前面的例子中我们看到了栈中函数内联。内联后,`func main()` 包含了 `func small()` 的函数体和对 `func large()` 的一次调用,因此它被判定为非叶子函数。在过去,这会阻止它被继续内联,虽然它的联合开销小于内联预算。 + +栈中内联的最主要的应用案例就是减少贯穿函数调用栈的开销。考虑下面的例子: + +```go +package main + +import ( + "fmt" + "strconv" +) + +type Rectangle struct {} + +//go:noinline +func (r *Rectangle) Height() int { + h, _ := strconv.ParseInt("7", 10, 0) + return int(h) +} + +func (r *Rectangle) Width() int { + return 6 +} + +func (r *Rectangle) Area() int { return r.Height() * r.Width() } + +func main() { + var r Rectangle + fmt.Println(r.Area()) +} +``` + +在这个例子中, `r.Area()` 是个简单的函数,调用了两个函数。`r.Width()` 可以被内联,`r.Height()` 这里用 `//go:noinline` 指令标注了,不能被内联。[^3] + +```bash +% go build -gcflags='-m=2' square.go +# command-line-arguments +./square.go:12:6: cannot inline (*Rectangle).Height: marked go:noinline +./square.go:17:6: can inline (*Rectangle).Width with cost 2 as: method(*Rectangle) func() int { return 6 } +./square.go:21:6: can inline (*Rectangle).Area with cost 67 as: method(*Rectangle) func() int { return r.Height() * r.Width() } +./square.go:21:61: inlining call to (*Rectangle).Width method(*Rectangle) func() int { return 6 } +./square.go:23:6: cannot inline main: function too complex: cost 150 exceeds budget 80 +./square.go:25:20: inlining call to (*Rectangle).Area method(*Rectangle) func() int { return r.Height() * r.Width() } +./square.go:25:20: inlining call to (*Rectangle).Width method(*Rectangle) func() int { return 6 } +``` + +由于 `r.Area()` 中的乘法与调用它的开销相比并不大,因此内联它的表达式是纯收益,即使它的调用的下游 `r.Height()` 仍是没有内联资格的。 + +#### 快速路径内联 + +关于栈中内联的效果最令人吃惊的例子是 2019 年 [Carlo Alberto Ferraris][7] 通过允许把 `sync.Mutex.Lock()` 的快速路径(非竞争的情况)内联到它的调用方来[提升它的性能][7]。在这个修改之前,`sync.Mutex.Lock()` 是个很大的函数,包含很多难以理解的条件,使得它没有资格被内联。即使锁可用时,调用者也要付出调用 `sync.Mutex.Lock()` 的代价。 + +Carlo 把 `sync.Mutex.Lock()` 分成了两个函数(他自己称为外联outlining)。外部的 `sync.Mutex.Lock()` 方法现在调用 `sync/atomic.CompareAndSwapInt32()` 且如果 CAS(比较并交换Compare and Swap)成功了之后立即返回给调用者。如果 CAS 失败,函数会走到 `sync.Mutex.lockSlow()` 慢速路径,需要对锁进行注册,暂停 goroutine。[^4] + +```bash +% go build -gcflags='-m=2 -l=0' sync 2>&1 | grep '(*Mutex).Lock' +../go/src/sync/mutex.go:72:6: can inline (*Mutex).Lock with cost 69 as: method(*Mutex) func() { if "sync/atomic".CompareAndSwapInt32(&m.state, 0, mutexLocked) { if race.Enabled { }; return }; m.lockSlow() } +``` + +通过把函数分割成一个简单的不能再被分割的外部函数,和(如果没走到外部函数就走到的)一个处理慢速路径的复杂的内部函数,Carlo 组合了栈中函数内联和[编译器对基础操作的支持][9],减少了非竞争锁 14% 的开销。之后他在 `sync.RWMutex.Unlock()` 重复这个技巧,节省了另外 9% 的开销。 + +[^1]: 不同发布版本中,在考虑该函数是否适合内联时,Go 编译器对同一函数的预算是不同的。 +[^2]: 时刻记着编译器的作者警告过[“更高的内联等级(比 -l 更高)可能导致错误或不被支持”][11]。 Caveat emptor。 +[^3]: 编译器有足够的能力来内联像 `strconv.ParseInt` 的复杂函数。作为一个实验,你可以尝试去掉 `//go:noinline` 注释,使用 `-gcflags=-m=2` 编译后观察。 +[^4]: `race.Enable` 表达式是通过传递给 `go` 工具的 `-race` 参数控制的一个常量。对于普通编译,它的值是 `false`,此时编译器可以完全省略代码路径。 + +### 相关文章: + + 1. [Go 中的内联优化][15] + 2. [goroutine 的栈为什么会无限增长?][16] + 3. [栈追踪和 errors 包][17] + 4. [零值是什么,为什么它很有用?][18] + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2020/05/02/mid-stack-inlining-in-go + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-12176-1.html +[2]: https://medium.com/@joshsaintjacque/small-functions-considered-awesome-c95b3fd1812f +[3]: tmp.FyRthF1bbF#easy-footnote-bottom-1-4076 (The budget the Go compiler applies to each function when considering if it is eligible for inlining changes release to release.) +[4]: tmp.FyRthF1bbF#easy-footnote-bottom-2-4076 (Keep in mind that the compiler authors warn that “Additional levels of inlining (beyond -l) may be buggy and are not supported”. Caveat emptor.) +[5]: https://docs.google.com/presentation/d/1Wcblp3jpfeKwA0Y4FOmj63PW52M_qmNqlQkNaLj0P5o/edit#slide=id.p +[6]: tmp.FyRthF1bbF#easy-footnote-bottom-3-4076 (The compiler is powerful enough that it can inline complex functions like strconv.ParseInt. As a experiment, try removing the //go:noinline annotation and observe the result with -gcflags=-m=2.) +[7]: https://go-review.googlesource.com/c/go/+/148959 +[8]: tmp.FyRthF1bbF#easy-footnote-bottom-4-4076 (The expression race.Enable is a constant controlled by the -race flag passed to the go tool. It is false for normal builds which allows the compiler to elide those code paths entirely.) +[9]: https://dave.cheney.net/2019/08/20/go-compiler-intrinsics +[10]: tmp.FyRthF1bbF#easy-footnote-1-4076 +[11]: https://github.com/golang/go/blob/be08e10b3bc07f3a4e7b27f44d53d582e15fd6c7/src/cmd/compile/internal/gc/inl.go#L11 +[12]: tmp.FyRthF1bbF#easy-footnote-2-4076 +[13]: tmp.FyRthF1bbF#easy-footnote-3-4076 +[14]: tmp.FyRthF1bbF#easy-footnote-4-4076 +[15]: https://dave.cheney.net/2020/04/25/inlining-optimisations-in-go (Inlining optimisations in Go) +[16]: https://dave.cheney.net/2013/06/02/why-is-a-goroutines-stack-infinite (Why is a Goroutine’s stack infinite ?) +[17]: https://dave.cheney.net/2016/06/12/stack-traces-and-the-errors-package (Stack traces and the errors package) +[18]: https://dave.cheney.net/2013/01/19/what-is-the-zero-value-and-why-is-it-useful (What is the zero value, and why is it useful?) diff --git a/published/202005/20200502 Pop OS 20.04 Review- Best Ubuntu-based Distribution Just Got Better.md b/published/202005/20200502 Pop OS 20.04 Review- Best Ubuntu-based Distribution Just Got Better.md new file mode 100644 index 0000000000..731c14fa0b --- /dev/null +++ b/published/202005/20200502 Pop OS 20.04 Review- Best Ubuntu-based Distribution Just Got Better.md @@ -0,0 +1,228 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12175-1.html) +[#]: subject: (Pop OS 20.04 Review: Best Ubuntu-based Distribution Just Got Better) +[#]: via: (https://itsfoss.com/pop-os-20-04-review/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Pop!_OS 20.04 点评:最好的基于 Ubuntu 的发行版越来越好了 +====== + +> Pop!_OS 20.04 是一款令人印象深刻的基于 Ubuntu 的 Linux 发行版。我在这篇评论中回顾了其主要的新功能,并分享了我对最新版本的体验。 + +现在,Ubuntu 20.04 LTS 及其官方变体版本已经发布了 - 是时候看看 [System76][1] 的 Pop!_OS 20.04 了,这是基于 Ubuntu 的最好的发行版之一。 + +老实说,Pop!_OS 是我最喜欢的 Linux 发行版,主要用于我做的所有事情。 + +现在,Pop!_OS 20.04 终于来了。是时候来看看它提供了哪些功能,以及你是否应该升级? + +### Pop!_OS 20.04 LTS 中有什么新东西? + +![][2] + +从视觉上看,Pop!\_OS 20.04 LTS 与 Pop!\_OS 19.10 并没有太大的区别。然而,你可以发现几个新功能和改进。 + +但是,如果你之前使用的是 Pop!_OS 18.04 LTS,则可以发现有很多东西可以尝试。 + +随着 [GNOME 3.36][3] 的到来,及其带来的一些新功能,Pop!_OS 20.04 成为了一个令人激动的版本。 + +总的来说,以下是一些主要的亮点。 + + * 自动窗口平铺 + * 新的应用程序切换器和启动器 + * 在 Pop!_Shop 中增加了对 Flatpack 的支持。 + * GNOME 3.36 + * Linux 内核 5.4 + * 改进的混合图形支持 + +虽然听起来很有趣,但我们还是来了解一下详细的变化,以及到目前为止 Pop!_OS 20.04 的体验如何。 + +#### Pop!_OS 20.04 中的用户体验提升 + +毫无疑问,很多 Linux 发行版都提供了开箱即用的用户体验。同样的,[Ubuntu 20.04 LTS 也有一流的改进和功能][4]。 + +而对于 System76 的 Pop!_OS,他们总是试图更进一步。并且,大多数新功能旨在通过提供有用的功能来改善用户体验。 + +在这里,我将介绍一些改进,其中包括 [GNOME 3.36][3] 和 Pop!_OS 特有的一些功能。 + +#### 支持系统托盘图标 + +总算是有了!这可能不是什么大的改变 —— 但 Pop!_OS 以前没有支持系统托盘图标(或小程序图标)。 + +![][5] + +随着 20.04 LTS 的发布,默认情况就有了系统托盘,不需要任何扩展。 + +依靠系统托盘图标的程序可能并不多 —— 但它仍然是重要的东西。 + +就我而言,我以前无法在 Pop!_OS 19.10 上使用 [ActivityWatch][6] —— 但现在可以了。 + +#### 自动窗口平铺 + +![][7] + +自动窗口平铺是我一直想尝试的东西 —— 但从来没花时间使用过 [i3][9] 这样的[平铺窗口管理器][8]来设置它,更别说是 [Regolith 桌面][10]了。 + +在 Pop!_OS 20.04 中,你就不需要这样做了。自动窗口平铺功能已经内置,无需设置。 + +它还提供了“显示活动提示”的选项,也就是说,它将高亮显示活动窗口以避免混淆。而且,你还可以调整窗口之间的间隙。 + +![][11] + +你可以在他们的官方视频中看到它是如何工作的: + +- [System76 Pop!_OS 20.04 - Auto Tiling](https://youtu.be/-fltwBKsMY0) + +而且,我得说,这是 Pop!_OS 20.04 上最大的新增功能之一,有可能帮助你更有效地进行多任务处理。 + +即使每次使用该功能都很方便,但为了最大程度地利用它,最好是使用一个大于 21 英寸的显示屏(至少)! 而且,因为这个原因 —— 我真的很想把我的显示器也升级一下! + +#### 新的扩展应用 + +![][13] + +Pop!_OS 内置了一些独特的 GNOME 扩展。但是,你不需要用 GNOME Tweaks 来管理扩展。 + +新增加的 “Extensions” 应用可以让你在 Pop!_OS 20.04 上配置和管理扩展程序。 + +#### 改进的通知中心 + +![][14] + +在新的 GNOME 3.36 中,通知中心的外观经过了改进。这里,我启用了黑暗模式。 + +#### 新的应用程序切换器 & 启动器 + +![][15] + +你仍然可以用 `ALT+TAB` 或 `Super+TAB` 来浏览正在运行的应用程序。 + +但是,当你有很多事情要做的时候,这很耗时。所以,在 Pop!_OS 20.04上,你可以使用 `Super+ /` 激活应用程序切换器和启动器。 + +一旦你习惯了这个快捷键,它将是非常方便的东西。 + +除此以外,你可能会发现 Pop!_OS 20.04 上的图标/窗口在视觉上有许多其它细微的改进。 + +#### 新的登录界面 + +嗯,这是 GNOME 3.36 带来的一个明显的变化。但是,它看起来确实很不错! + +![][16] + +#### Pop!_Shop 支持 Flatpak + +通常,Pop!_Shop 已经是一个非常有用的东西了,包括它自有的在内,它带有一个巨大的软件仓库。 + +现在,在 Pop!\_OS 20.04 中,你可以用 Pop!_Shop 安装任何可用软件的 Debian 包或 Flatpak(通过 Flathub) —— 当然,前提是某个软件有 Flatpak 软件包。 + +如果你没有使用 Pop!_OS 20.04,你可能要看看[如何在 Linux 上使用 Flatpak][18]。 + +![][19] + +就我个人而言,我并不是 Flatpak 的粉丝,但有些应用如 GIMP 需要你安装 Flatpak 包才能获得最新版本。所以,在 Pop!_Shop 上直接支持了 Flatpak 绝对是一件好事。 + +#### 键盘快捷键更改 + +如果你习惯了 Pop!_OS 19.10 或更早的版本上现有的键盘快捷键,这可能会让你很烦。 + +不管是哪种情况,有几个重要的键盘快捷键变化可能会改善你的体验,如下: + + * 锁定屏幕:`Super + L` 改为 `Super + Escape`。 + * 移动工作区:`Super + 上/下箭头键` 改为 `Super + CTRL + 上/下箭头键`。 + * 关闭窗口:`Super + W` 变更为 `Super + Q`。 + * 切换最大化:`Super +向上箭头` 改为 `Super + M`。 + +#### Linux 内核 5.4 + +与其他大多数最新的 Linux 发行版相似,Pop!_OS 20.04 搭载了 [Linux 内核 5.4][20]。 + +所以,很明显,你可以期望获得对 [exFAT 支持][21]、改进的 AMD 图形兼容性以及它附带所有其他功能。 + +#### 性能提升 + +尽管 Pop!_OS 并不称自己是轻量级的 Linux 发行版,但它仍然是一个资源节约型的发行版。而且,有了 GNOME 3.36 的支持,它的速度应该足够快了。 + +考虑到我已经将 Pop!\_OS 作为主要发行版使用已经一年多了,我从来没有遇到过性能问题。这就是你安装了 Pop!_OS 20.04 之后的资源使用情况(取决于你的系统配置)。 + +![][22] + +给你一个作为参考,我的台式机配置包括 i5-7400 处理器、16GB 内存(2400MHz)、NVIDIA GTX 1050ti 显卡和 SSD。 + +我不是一个系统基准测试的忠实拥护者,因为除非你去尝试,否则它并不能让你知道特定的应用或游戏的性能。 + +你可以试试 [Phoronix 测试套件][23]来分析你的系统表现。但是,Pop!_OS 20.04 LTS 应该是一个很爽快的体验! + +#### 软件包更新 & 其他改进 + +尽管每个基于Ubuntu的发行版都受益于Ubuntu 20.04 LTS的改进,但也有一些 Pop!_OS 特有的错误修复和改进。 + +除此之外,一些主要的应用程序/包(如 Firefox 75.0)也已经更新到了最新版本。 + +到现在为止,应该没有任何严重的错误,至少对我来说没有。 + +你可以在 [GitHub 上查看他们的开发进度][24],以了解他们在测试期间已经修复的问题和发布后即将修复的问题。 + +### 下载 & 支持 Pop!_OS 20.04 + +![][25] + +在这个版本中,System76 终于增加了一个可选的订阅模式来支持 Pop!_OS 的开发。 + +你可以免费下载 Pop!_OS 20.04 —— 但如果你想支持他们,我建议你只需要 \$1/月就可以订阅。 + +- [Pop!_OS 20.04][26] + +### 我对 Pop OS 20.04 的看法 + +我必须提到的是,我正在为最新的 20.04 版本提供全新的墙纸。但是,这没什么大不了的。 + +有了窗口平铺功能、支持 flatpak,以及众多其他改进,到目前为止,我对 Pop!_OS 20.04 的体验是一流的。另外,很高兴看到他们在一些流行软件的开箱即用支持上突出了他们对创意专业人士的关注。 + +![][27] + +Ubuntu 20.04 的所有优点,再加上 System76 的一些额外的加料,让我印象深刻! + +你试过 Pop!_OS 20.04 吗?请在下面的评论中告诉我你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/pop-os-20-04-review/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://system76.com +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/pop_os_20_04_review.jpg?ssl=1 +[3]: https://itsfoss.com/gnome-3-36-release/ +[4]: https://itsfoss.com/ubuntu-20-04-release-features/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/system-tray-icons-pop-os.jpg?ssl=1 +[6]: https://activitywatch.net/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/pop-os-automatic-screen-tiling.png?ssl=1 +[8]: https://en.wikipedia.org/wiki/Tiling_window_manager +[9]: https://i3wm.org/ +[10]: https://itsfoss.com/regolith-linux-desktop/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/tile-feature-options-popos.jpg?ssl=1 +[12]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/pop-os-extensions.jpg?ssl=1 +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/notification-center-pop-os.jpg?ssl=1 +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/pop-os-application-launcher.jpg?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/pop-os-20-04-lock-screen.jpg?ssl=1 +[17]: https://launchpad.net/~system76/+archive/ubuntu/pop +[18]: https://itsfoss.com/flatpak-guide/ +[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/pop-os-flatpak-deb.jpg?ssl=1 +[20]: https://itsfoss.com/linux-kernel-5-4/ +[21]: https://itsfoss.com/mount-exfat/ +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/pop-os-20-04-performance.jpg?ssl=1 +[23]: https://www.phoronix-test-suite.com/ +[24]: https://github.com/orgs/pop-os/projects/13 +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/support-pop-os.jpg?ssl=1 +[26]: https://pop.system76.com/ +[27]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/pop-os-stem-focus.jpg?ssl=1 diff --git a/published/202005/20200504 4 cool new projects to try in COPR for May 2020.md b/published/202005/20200504 4 cool new projects to try in COPR for May 2020.md new file mode 100644 index 0000000000..9a63887910 --- /dev/null +++ b/published/202005/20200504 4 cool new projects to try in COPR for May 2020.md @@ -0,0 +1,108 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12230-1.html) +[#]: subject: (4 cool new projects to try in COPR for May 2020) +[#]: via: (https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-april-2020/) +[#]: author: (Dominik Turecek https://fedoramagazine.org/author/dturecek/) + +COPR 仓库中 4 个很酷的新项目(2020.05) +====== + +![][1] + +COPR 是个人软件仓库[集合][2],它不在 Fedora 中。这是因为某些软件不符合轻松打包的标准;或者它可能不符合其他 Fedora 标准,尽管它是自由而开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不受 Fedora 基础设施的支持,或者是由项目自己背书的。但是,这是一种尝试新的或实验性的软件的一种巧妙的方式。 + +本文介绍了 COPR 中一些有趣的新项目。如果你第一次使用 COPR,请参阅 [COPR 用户文档][3]。 + +### Ytop + +[ytop][4] 是类似于 `htop` 的命令行系统监视器。它们之间的主要区别是,`ytop` 在显示进程及其 CPU 和内存使用率的顶部显示了系统的 CPU、内存和网络使用率随时间变化的图表。此外,`ytop` 还显示磁盘使用情况和计算机温度。最后,`ytop` 支持多种配色方案以及创建新配色的选项。 + +![][5] + +#### 安装说明 + +[该仓库][6]当前为 Fedora 30、31、32 和 Rawhide 以及 EPEL 7 提供了 `ytop`。要安装 `ytop`,请[带上 sudo][7] 使用以下命令: + +``` +sudo dnf copr enable atim/ytop +sudo dnf install ytop +``` + +### Ctop + +[ctop][8] 是另一个命令行系统监视器。但是,与 `htop` 和 `ytop` 不同,`ctop` 专注于显示容器的资源使用情况。`ctop` 同时显示计算机上运行的所有容器的 CPU、内存、网络和磁盘使用情况的概要,以及单个容器的更全面的信息,包括一段时间内资源使用情况的图表。当前,`ctop` 支持 Docker 和 runc 容器。 + +![][9] + +#### 安装说明 + +[该仓库][10]当前为 Fedora 31、32 和 Rawhide 以及 EPEL 7 还有其他发行版提供了安装包。要安装 `ctop`,请使用以下命令: + +``` +sudo dnf copr enable fuhrmann/ctop +sudo dnf install ctop +``` + +### Shortwave + +[shortwave][11] 是用于收听广播电台的程序。`shortwave` 使用广播电台的社区数据库 [www.radio-browser.info][12]。在此数据库中,你可以发现或搜索广播电台,将它们添加到库中,然后收听。此外,`shortwave` 还提供有关当前播放歌曲的信息,并且还可以记录这些歌曲。 + +![][13] + +#### 安装说明 + +[该仓库][14] 当前为 Fedora 31、32 和 Rawhide 提供了 shortwave。要安装 `shortwave`,请使用以下命令: + +``` +sudo dnf copr enable atim/shortwave +sudo dnf install shortwave +``` + +### Setzer + +[setzer][15] 是 LaTeX 编辑器,它可以构建 pdf 文档并查看它们。它提供了各种类型文档(例如文章或幻灯片)的模板。此外,`setzer` 还有许多特殊符号、数学符号和希腊字母的按钮。 + +![][16] + +#### 安装说明 + +[该仓库][17] 当前为 Fedora 30、31、32 和 Rawhide 提供了 `setzer`。要安装 `setzer`,请使用以下命令: + +``` +sudo dnf copr enable lyessaadi/setzer +sudo dnf install setzer +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-april-2020/ + +作者:[Dominik Turecek][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/dturecek/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg +[2]: https://copr.fedorainfracloud.org/ +[3]: https://docs.pagure.org/copr.copr/user_documentation.html# +[4]: https://github.com/cjbassi/ytop +[5]: https://fedoramagazine.org/wp-content/uploads/2020/04/ytop.png +[6]: https://copr.fedorainfracloud.org/coprs/atim/ytop/ +[7]: https://fedoramagazine.org/howto-use-sudo/ +[8]: https://github.com/bcicen/ctop +[9]: https://fedoramagazine.org/wp-content/uploads/2020/04/ctop.png +[10]: https://copr.fedorainfracloud.org/coprs/fuhrmann/ctop/ +[11]: https://github.com/ranfdev/shortwave +[12]: http://www.radio-browser.info/gui/#!/ +[13]: https://fedoramagazine.org/wp-content/uploads/2020/04/shortwave.png +[14]: https://copr.fedorainfracloud.org/coprs/atim/shortwave/ +[15]: https://www.cvfosammmm.org/setzer/ +[16]: https://fedoramagazine.org/wp-content/uploads/2020/04/setzer.png +[17]: https://copr.fedorainfracloud.org/coprs/lyessaadi/setzer/ diff --git a/published/202005/20200505 Browse the Peer-to-peer Web With Beaker Browser.md b/published/202005/20200505 Browse the Peer-to-peer Web With Beaker Browser.md new file mode 100644 index 0000000000..701d66156e --- /dev/null +++ b/published/202005/20200505 Browse the Peer-to-peer Web With Beaker Browser.md @@ -0,0 +1,124 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12203-1.html) +[#]: subject: (Browse the Peer-to-peer Web With Beaker Browser) +[#]: via: (https://itsfoss.com/beaker-browser/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +使用 Beaker 浏览器浏览对等 Web +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/10/082745ztmi4kqh4iq449ll.jpg) + +在过去 50 年中,我们所了解的互联网没有什么变化,全球的网民使用他们的设备从遍布在世界各地的服务器上检索数据。 + +一群专业的技术专家想改变现状,使互联网变成人们可以连接和直接分享信息的地方,而不是依赖一个中心服务器(去中心化)。 + +我们已经在 It’s FOSS 讨论过很多这样的去中心化的服务。[YouTube 竞品:LBRY][1]、[Twitter 竞品:Mastodon][2] 是其中的两个例子。 + +今天我将要介绍另一个这样的产品,名为 [Beaker 浏览器][3],它的设计目标是浏览对等 Web。 + +![Beaker Browser][4] + +### “对等 Web” 是什么? + +根据 Beaker 浏览器的[开发者之一][5]的描述,“对等 Web 是一项实验性的技术 ……旨在提高我们掌控 Web 的能力。” + +还有,他们说对等 Web 有三个主要原则:任何一点都可以成为服务器;多台计算机可以为同一个网站提供服务;没有后端。 + +从这些原则中你可以看出,对等 Web 的思想与 BitTorrent 很像,文件由多个对端做种,这些对端共同承担带宽负载。这减少了一个用户需要提供给他们的网站的总带宽。 + +![Beaker Browser Settings][6] + +对等 Web 另一个重要的方面是创作者对于他们自己的想法的控制能力。当今年代,平台都是由庞大的组织控制的,往往拿你的数据为他们所用。Beaker 把数据的控制能力返还给了内容创造者。 + +### 使用 Beaker 浏览去中心化的 web + +[Beaker 浏览器][3] 是在 2016 年被创建的。该项目(及其周边技术)由[蓝链实验室][7]的三人团队创建。Beaker 浏览器使用 [Dat 协议][8]在计算机之间共享数据。使用 Dat 协议的网站以 `dat://` 而不是 `http://` 开头。 + +Dat 协议的优势如下: + + * 快速 – 档案能立即从多个源同步。 + * 安全 – 所有的更新都是有签名和经过完整性检查的。 + * 灵活 – 可以在不修改档案 URL 的情况下迁移主机。 + * 版本控制 – 每次修改都被写到只能追加的版本日志中。 + * 去中心化 – 任何设备都可以作为承载档案的主机。 + +![Beaker Browser Seeding][9] + +Beaker 浏览器本质上是阉割版的 Chromium,原生支持 `dat://` 地址,也可以访问普通的 `http://` 站点。 + +每次访问一个 dat 站点,在你请求时该站点的内容才会下载到你的计算机。例如,在一个站点上的 about 页面中有一张 Linux Torvalds 的图片,只有在你浏览到该站点的这个页面时,才会下载这张图片。 + +此外,当你浏览一个 dat 网站时,“[你会短暂性的][10]重新上传或做种你从该网站上下载的所有文件。”你也可以选择为网站(主动)做种来帮助创造者。 + +![Beaker Browser Menu][11] + +由于 Beaker 的志向就是创建一个更开放的网络,因此你可以很容易地查看任何网站的源码。不像在大多数浏览器上你只能看到当前浏览的页面的源码那样,使用 Beaker 你能以类似 GitHub 的视图查看整个站点的结构。你甚至可以复刻这个站点,并托管你自己的版本。 + +除了浏览基于 dat 的网站外,你还可以创建自己的站点。在 Beaker 浏览器的菜单里,有创建新网站或空项目的选项。如果你选择了创建一个新网站,Beaker 会搭建一个小的演示站点,你可以使用浏览器里自带的编辑器来编辑。 + +然而,如果你像我一样更喜欢用 Markdown,你可以选择创建一个空项目。Beaker 会创建一个站点的结构,赋给它一个 `dat://` 地址。你只需要创建一个 `index.md` 文件后就行了。这有个[简短教程][12],你可以看到更多信息。你也可以用创建空项目的方式搭建一个 web 应用。 + +![Beaker Browser Website Template][13] + +由于 Beaker 的角色是个 Web 服务器和站点做种者,当你关闭它或关机后你的站点就不可用了。幸运的是,你不必一直开着你的计算机或浏览器。你也可以使用名为 [Hashbase][14] 的做种服务或者你可以搭建一个 [homebase][15] 做种服务器。 + +虽然 Beaker [适用于][16] Linux、Windows 和 macOS,但是在使用 Beaker 之前,还是要查阅下[各平台的教程][17]。 + +### Beaker 浏览器不是大众可用的,但它有这个意图 + +当第一次接触到时,我对 Beaker 浏览器有极高的热情。(但是)如它现在的名字一样(烧杯),Beaker 浏览器仍是非常实验性的。我尝试浏览过的很多 dat 站点还不可用,因为用户并没有为站点做种。当站点恢复可用时 Beaker 确实可以选择通知你。 + +![Beaker Browser No Peer][18] + +另一个问题是,Beaker 是真正阉割版的 Chromium。它不能安装扩展或主题。你只能使用白色主题和极少的工具集。我不会把 Beaker 浏览器作为常用浏览器,而且能访问 dat 网站并不是把它留在系统上的充分条件。 + +我曾经寻找一个能支持 `dat://` 协议的 Firefox 扩展。我确实找到了这样一款扩展,但它需要安装一系列其他的软件。相比而言,安装 Beaker 比安装那些软件容易点。 + +就如它现在的名字一样,Beaker 不适合我。也许在将来更多的人使用 Beaker 或者其他浏览器支持 dat 协议。那时会很有趣。目前而言,聊胜于无。 + +在使用 Beaker 的时间里,我用内建的工具创建了一个[网站][19]。不要担心,我已经为它做种了。 + +![Beaker Bowser Site Source][20] + +你怎么看 Beaker 浏览器?你怎么看对等 Web?请尽情在下面评论。 + +如果你觉得本文有意思,请花点时间把它分享到社交媒体,Hacker News 或 [Reddit][21]。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/beaker-browser/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/lbry/ +[2]: https://itsfoss.com/mastodon-open-source-alternative-twitter/ +[3]: https://beakerbrowser.com/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/beaker-browser.jpg?resize=800%2C426&ssl=1 +[5]: https://pfrazee.hashbase.io/blog/what-is-the-p2p-web +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/beaker-bowser-setting.jpg?resize=800%2C573&ssl=1 +[7]: https://bluelinklabs.com/ +[8]: https://www.datprotocol.com/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/beaker-bowser-seedding.jpg?resize=800%2C466&ssl=1 +[10]: https://beakerbrowser.com/docs/faq/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/beaker-browser-menu.jpg?ssl=1 +[12]: https://beakerbrowser.com/docs/guides/create-a-markdown-site +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/beaker-browser-website-template.jpg?resize=800%2C459&ssl=1 +[14]: https://hashbase.io/ +[15]: https://github.com/beakerbrowser/homebase +[16]: https://beakerbrowser.com/install/ +[17]: https://beakerbrowser.com/docs/guides/ +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/beaker-browser-no-peer.jpg?resize=800%2C424&ssl=1 +[19]: https://41bfbd06731e8d9c5d5676e8145069c69b254e7a3b710ddda4f6e9804529690c/ +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/beaker-bowser-source.jpg?resize=800%2C544&ssl=1 +[21]: https://reddit.com/r/linuxusersgroup diff --git a/published/202005/20200506 After More Than 3 Years, Inkscape 1.0 is Finally Here With Tons of Feature Improvements.md b/published/202005/20200506 After More Than 3 Years, Inkscape 1.0 is Finally Here With Tons of Feature Improvements.md new file mode 100644 index 0000000000..fcf6c3b3ca --- /dev/null +++ b/published/202005/20200506 After More Than 3 Years, Inkscape 1.0 is Finally Here With Tons of Feature Improvements.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12188-1.html) +[#]: subject: (After More Than 3 Years, Inkscape 1.0 is Finally Here With Tons of Feature Improvements) +[#]: via: (https://itsfoss.com/inkscape-1-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +经过了 3 年,Inkscape 1.0 终于发布了 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/06/094055fvnh9nnnbybwl4jn.jpg) + +虽然我不是这方面的专业人员,但可以肯定地说,Inkscape 是[最好的矢量图形编辑器][1]之一。 + +不仅仅因为它是自由开源软件,而且对于数字艺术家来说,它是一个非常有用的应用程序。 + +上一次发布(0.92 版本)是在 3 年前。现在,终于,[Inkscape 宣布了它的 1.0 版本][2] —— 增加了很多新的功能和改进。 + +### Inkscape 1.0 里的新东西 + +![Inkscape 1.0][3] + +在这里,让我重点介绍一下 Inkscape 1.0 版本中重要关键变化。 + +#### 首个原生 macOS 应用 + +对于像 Inkscape 这样的神奇工具来说,适当的跨平台支持总是好的。在这个最新的版本中,它推出了原生的 macOS 应用。 + +请注意,这个 macOS 应用仍然是一个**预览版**,还有很多改进的空间。不过,在无需 [XQuartz][4] 的情况下就做到了更好的系统集成,对于 macOS 用户来说,应该是一个值得期许的进步。 + +#### 性能提升 + +不管是什么应用程序/工具,都会从显著的性能提升中受益,而 Inkscape 也是如此。 + +随着其 1.0 版本的发布,他们提到,当你使用 Inkscape 进行各种创意工作时,你会发现性能更加流畅。 + +除了在 macOS 上(仍为“预览版”),Inkscape 在 Linux 和 Windows 上的运行都是很好的。 + +#### 改进的 UI 和 HiDPI 支持 + +![][5] + +他们在发布说明中提到: + +> ……达成了一个重要的里程碑,使 Inkscape 能够使用最新的软件(即 GTK+3)来构建编辑器的用户界面。拥有 HiDPI(高分辨率)屏幕的用户要感谢 2018 年波士顿黑客节期间的团队合作,让更新后的 GTK 轮子开始运转起来。 + +从 GTK+3 的用户界面到高分辨率屏幕的 HiDPI 支持,这都是一次精彩的升级。 + +更不要忘了,你还可以获得更多的自定义选项来调整外观和感受。 + +#### 新增功能 + +![][6] + +即便是从纸面上看,这些列出新功能都看起来不错。根据你的专业知识和你的喜好,这些新增功能应该会派上用场。 + +以下是新功能的概述: + + * 新改进过的实时路径效果(LPE)功能。 + * 新的可搜索的 LPE 选择对话框。 + * 自由式绘图用户现在可以对画布进行镜像和旋转。 + * 铅笔工具的新的 PowerPencil 模式提供了压感的宽度,并且终于可以创建封闭路径了。 + * 包括偏移、PowerClip 和 PowerMask LPE 在内的新路径效果会吸引艺术类用户。 + * 能够创建复制引导、将网格对齐到页面上、测量工具的路径长度指示器和反向 Y 轴。 + * 能够导出带有可点击链接和元数据的 PDF 文件。 + * 新的调色板和网状渐变,可在网页浏览器中使用。 + +虽然我已经尝试着整理了这个版本中添加的关键功能列表,但你可以在他们的[发布说明][7]中获得全部细节。 + +#### 其他重要变化 + +作为重大变化之一,Inkscape 1.0 现在支持 Python 3。而且,随着这一变化,你可能会注意到一些扩展程序无法在最新版本中工作。 + +所以,如果你的工作依赖于某个扩展程序的工作流程,我建议你仔细看看他们的[发布说明][7],了解所有的技术细节。 + +### 在 Linux 上下载和安装 Inkscape 1.0 + +Inkscape 1.0 有用于 Linux 的 AppImage 和 Snap 软件包,你可以从 Inkscape 的网站上下载。 + +- [下载 Inkscape 1.0 for Linux][8] + +如果你还不知道,可以查看[如何在 Linux 上使用 AppImage 文件][9]来入门。你也可以参考[这个 Snap 指南][10]。 + +Ubuntu 用户可以在 Ubuntu 软件中心找到 Inskcape 1.0 的 Snap 版本。 + +我在 [Pop!_OS 20.04][11] 上使用了 AppImage 文件,工作的很好。你可以详细体验所有的功能,看看它的效果如何。 + +你试过了吗?请在下面的评论中告诉我你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/inkscape-1-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://itsfoss.com/vector-graphics-editors-linux/ +[2]: https://inkscape.org/news/2020/05/04/introducing-inkscape-10/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/inkscape-1-0.jpg?ssl=1 +[4]: https://en.wikipedia.org/wiki/XQuartz +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/inkscape-ui-customization.jpg?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/inkscape-live-path-effects.jpg?ssl=1 +[7]: https://wiki.inkscape.org/wiki/index.php/Release_notes/1.0 +[8]: https://inkscape.org/release/1.0/gnulinux/ +[9]: https://itsfoss.com/use-appimage-linux/ +[10]: https://itsfoss.com/install-snap-linux/ +[11]: https://itsfoss.com/pop-os-20-04-review/ diff --git a/published/202005/20200506 Customizing my open source PHP framework for web development.md b/published/202005/20200506 Customizing my open source PHP framework for web development.md new file mode 100644 index 0000000000..de6b46f8b7 --- /dev/null +++ b/published/202005/20200506 Customizing my open source PHP framework for web development.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12235-1.html) +[#]: subject: (Customizing my open source PHP framework for web development) +[#]: via: (https://opensource.com/article/20/5/codeigniter) +[#]: author: (Wee Ben Sen https://opensource.com/users/bswee14) + +自定义用于 Web 开发的开源 PHP 框架 Codeigniter +====== + +> Codeigniter 是一个 PHP 框架,可以使公司进行开发具有灵活性和便捷性的高性能网站。 + +![](https://img.linux.net.cn/data/attachment/album/202005/21/102637vslj5zqk52x98a52.jpg) + +PHP Codeigniter 是一个开源框架,为商业应用提供易于使用的 PHP 编程语言和强大的编码工具。它还提供商务智能、服务器监视、开发和应用集成功能。这是一个相对冷清的项目,你很少听到它,但它功能强大,许多刚接触的开发人员都对此感到惊讶和耳目一新。 + +我在新加坡的一家在线学习服务提供商处使用 [Codeigniter][2]。我们提供的服务并不算常见,没有可以作为模板的默认功能集或现有后台管理系统,所以我需要一个能提供良好的、可靠的、可以建立在此基础上的原始材料。最初,我考虑用其他平台(如 Wordpress)用于我们的网站。但是,我决定使用 Codeigniter,因为它的灵活性,以及集成了在我们的补课匹配过程中需要的功能。 + +以下是打动我使用 Codeigniter 的原因: + +* 与 MySQL 数据库的集成 —— 主要功能是允许客户端浏览导师的数据库并添加导师,例如类似于电子商务平台的“购物车”。 +* 客户端界面系统 —— 用户可以登录来管理偏好并编辑详细信息,修改所教的科目、旅游的地区、手机号码、地址等。 +* 定制的管理员面板 —— 管理员可以使用定制的管理面板访问客户提交的资料,它与客户服务功能集成在一起,因此管理员可以单独跟进。 +* 付款系统 —— 管理面板带有与 Paypal 集成的发票和付款网关。 +* CMS 编辑器界面 —— 管理员能够编辑博客和文章中的文本和图像,以及添加新页面。 + +该项目花费了大约六个月的时间来完成,另外花了两个月的调试时间。如果我需要从头开始构建所有,或者尝试重新设计现有的框架以满足我们的需求,那将花费更长的时间,而且可能最终无法满足客户需求。 + +### 功能和优点 + +PHP Codeigniter还有很多吸引开发者的功能,包括错误处理和代码格式化,这些功能在各种编码情景下都非常有用。它支持模板,可用于向现有网站添加功能或生成新网站。有许多基于 web 系统商业需要的功能,包括使用自定义标签。即使没有编程经验的普通开发人员也可以使用大多数工具。 + +Codeigniter 的主要功能是: + +* XML 核心服务, +* HTTP/FTP 核心服务 +* AppData 和 PHP 沙箱功能 +* XSLT 和 HTML 模板 +* 加密的信息传输 +* PCM Codeigniter 服务器监控 +* 应用集成 +* 文件传输协议(FTP) +* 服务台支持 +* Apache POI(用于托管网站的内容管理基础架构) + +#### 兼容性 + +Codeigniter 与许多领先的软件程序兼容,例如 PHP、MySQL、[MariaDB][3]、[phpMyAdmin][4]、[Apache][5]、OpenBSD、XSLT、[SQLite][6] 等。许多公司更喜欢使用 Codeigniter 产品来满足网站要求,因为它们易于使用和集成。如果你不想创建自己的网站,你可以找到许多提供自定义 Web 开发服务的开发人员和设计机构。 + +#### 安全 + +Codeigniter 还通过 SSL 加密提供数据安全性。加密可以保护数据免受入侵者和防火墙外部威胁的侵害。数据存储功能还允许对公司网站进行安全审核。 + +#### 其它功能 + +一家优秀的 PHP Web 开发公司会使用几种高级技术和第三方技术,例如 XML 和 PHP。它为企业提供了一个完整的平台,可以开发出具有看起来专业的、好用的商业网站。Codeigniter 使得第三方技术的使用变得容易,并可以与常见的 Web 开发软件一起使用。这使得 Web 公司可以轻松地使用所选模块创建网站。大多数 PHP 开发者也为个人提供支持和培训服务。 + +### 使用 PHP 框架 Codeigniter + +Codeigniter 给企业提供了完整的 PHP 开发包,它将提供强大的功能、灵活性和性能完美结合在一起。到目前为止,我很满意我们的网站,并不断地升级和添加新的功能。并不断升级和增加新的功能。我期待着发现我们的网站还能用 Codeigniter 做些什么。你也是这样么? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/codeigniter + +作者:[Wee Ben Sen][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bswee14 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) +[2]: https://codeigniter.com/ +[3]: http://mariadb.org/ +[4]: https://www.phpmyadmin.net/ +[5]: http://apache.org/ +[6]: http://sqlite.org/ diff --git a/published/202005/20200506 Managing Git projects with submodules and subtrees.md b/published/202005/20200506 Managing Git projects with submodules and subtrees.md new file mode 100644 index 0000000000..d52aef42a6 --- /dev/null +++ b/published/202005/20200506 Managing Git projects with submodules and subtrees.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12244-1.html) +[#]: subject: (Managing Git projects with submodules and subtrees) +[#]: via: (https://opensource.com/article/20/5/git-submodules-subtrees) +[#]: author: (Manaswini Das https://opensource.com/users/manaswinidas) + +使用子模块和子树来管理 Git 项目 +====== + +> 使用子模块和子树来帮助你管理多个存储库中共有的子项目。 + +![](https://img.linux.net.cn/data/attachment/album/202005/23/201323myyhob22eg2y2jqt.jpg) + +如果你参与了开源项目的开发,那么你很可能已经用了 Git 来管理你的源码。你可能遇到过有很多依赖和/或子项目的项目。你是如何管理它们的? + +对于一个开源组织,要实现社区**和**产品的单一来源文档和依赖管理比较棘手。文档和项目往往会碎片化和变得冗余,这致使它们很难维护。 + +### 必要性 + +假设你想把单个项目作为一个存储库内的子项目,传统的方法是把该项目复制到父存储库中,但是,如果你想要在多个父项目中使用同一个子项目呢?如果把子项目复制到所有父项目中,当有更新时,你都要在每个父项目中做修改,这是不太可行的。这会导致父项目中的冗余和数据不一致,使更新和维护子项目变得很困难。 + +### Git 子模块和子树 + +如果你可以用一条命令把一个项目放进另一个项目中,会怎样呢?如果你随时可以把一个项目作为子项目添加到任意数目的项目中,并可以同步更新修改呢?Git 提供了这类问题的解决方案:Git 子模块submodule和 Git 子树subtree。创建这些工具的目的是以更加模块化的水平来支持共用代码的开发工作流,旨在 Git 存储库源码管理source-code management(SCM)与它下面的子树之间架起一座桥梁。 + +![Cherry tree growing on a mulberry tree][2] + +*生长在桑树上的樱桃树* + +下面是本文要详细介绍的概念的一个真实应用场景。如果你已经很熟悉树形结构,这个模型看起来是下面这样: + +![Tree with subtrees][3] + +### Git 子模块是什么? + +Git 在它默认的包中提供了子模块,子模块可以把 Git 存储库嵌入到其他存储库中。确切地说,Git 子模块指向子树中的某次提交。下面是我 [Docs-test][4] GitHub 存储库中的 Git 子模块的样子: + +![Git submodules screenshot][5] + +[文件夹@提交 Id][6] 格式表明这个存储库是一个子模块,你可以直接点击文件夹进入该子树。名为 `.gitmodules` 的配置文件包含所有子模块存储库的详细信息。我的存储库的 `.gitmodules` 文件如下: + +![Screenshot of .gitmodules file][7] + +你可以用下面的命令在你的存储库中使用 Git 子模块: + +#### 克隆一个存储库并加载子模块 + +克隆一个含有子模块的存储库: + +``` +$ git clone --recursive +``` + +如果你之前已经克隆了存储库,现在想加载它的子模块: + +``` +$ git submodule update --init +``` + +如果有嵌套的子模块: + +``` +$ git submodule update --init --recursive +``` + +#### 下载子模块 + +串行地连续下载多个子模块是很枯燥的工作,所以 `clone` 和 `submodule update` 会支持 `--jobs` (或 `-j`)参数: + +例如,想一次下载 8 个子模块,使用: + +``` +$ git submodule update --init --recursive -j 8 +$ git clone --recursive --jobs 8 +``` + +#### 拉取子模块 + +在运行或构建父项目之前,你需要确保依赖的子项目都是最新的。 + +拉取子模块的所有修改: + +``` +$ git submodule update --remote +``` + +#### 使用子模块创建存储库: + +向一个父存储库添加子树: + +``` +$ git submodule add +``` + +初始化一个已存在的 Git 子模块: + +``` +$ git submodule init +``` + +你也可以通过为 `submodule update` 命令添加 `--update` 参数在子模块中创建分支和追踪提交: + +``` +$ git submodule update --remote +``` + +#### 更新子模块的提交 + +上面提到过,一个子模块就是一个指向子树中某次提交的链接。如果你想更新子模块的提交,不要担心。你不需要显式地指定最新的提交。你只需要使用通用的 `submodule update` 命令: + +``` +$ git submodule update +``` + +就像你平时创建父存储库和把父存储库推送到 GitHub 那样添加和提交就可以了。 + +#### 从一个父存储库中删除一个子模块 + +仅仅手动删除一个子项目文件夹不会从父项目中移除这个子项目。想要删除名为 `childmodule` 的子模块,使用: + +``` +$ git rm -f childmodule +``` + +虽然 Git 子模块看起来很容易上手,但是对于初学者来说,有一定的使用门槛。 + +### Git 子树是什么? + +Git 子树 subtree,是在 Git 1.7.11 引入的,让你可以把任何存储库的副本作为子目录嵌入另一个存储库中。它是 Git 项目可以注入和管理项目依赖的几种方法之一。它在常规的提交中保存了外部依赖信息。Git 子树提供了整洁的集成点,因此很容易复原它们。 + +如果你参考 [GitHub 提供的子树教程][8]来使用子树,那么无论你什么时候添加子树,在本地都不会看到 `.gittrees` 配置文件。这让我们很难分辨哪个是子树,因为它们看起来很像普通的文件夹,但是它们却是子树的副本。默认的 Git 包中不提供带 `.gittrees` 配置文件的 Git 子树版本,因此如果你想要带 `.gittrees` 配置文件的 git-subtree 命令,必须从 Git 源码存储库的 [/contrib/subtree 文件夹][9] 下载 git-subtree。 + +你可以像克隆其他常规的存储库那样克隆任何含有子树的存储库,但由于在父存储库中有整个子树的副本,因此克隆过程可能会持续很长时间。 + +你可以用下面的命令在你的存储库中使用 Git 子树。 + +#### 向父存储库中添加一个子树 + +想要向父存储库中添加一个子树,首先你需要执行 `remote add`,之后执行 `subtree add` 命令: + +``` +$ git remote add remote-name +$ git subtree add --prefix=folder/ remote-name subtree-branchname +``` + +上面的命令会把整个子项目的提交历史合并到父存储库。 + +#### 向子树推送修改以及从子树拉取修改 + +``` +$ git subtree push-all +``` + +或者 + +``` +$ git subtree pull-all +``` + +### 你应该使用哪个? + +任何工具都有优缺点。下面是一些可能会帮助你决定哪种最适合你的特性: + + * Git 子模块的存储库占用空间更小,因为它们只是指向子项目的某次提交的链接,而 Git 子树保存了整个子项目及其提交历史。 + * Git 子模块需要在服务器中可访问,但子树是去中心化的。 + * Git 子模块大量用于基于组件的开发,而 Git 子树多用于基于系统的开发。 + +Git 子树并不是 Git 子模块的直接可替代项。有明确的说明来指导我们该使用哪种。如果有一个归属于你的外部存储库,使用场景是向它回推代码,那么就使用 Git 子模块,因为推送代码更容易。如果你有第三方代码,且不会向它推送代码,那么使用 Git 子树,因为拉取代码更容易。 + +自己尝试使用 Git 子树和子模块,然后在评论中留下你的使用感想。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/git-submodules-subtrees + +作者:[Manaswini Das][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/manaswinidas +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_web_internet_website.png?itok=g5B_Bw62 (Digital creative of a browser on the internet) +[2]: https://opensource.com/sites/default/files/uploads/640px-bialbero_di_casorzo.jpg (Cherry tree growing on a mulberry tree) +[3]: https://opensource.com/sites/default/files/subtree_0.png (Tree with subtrees) +[4]: https://github.com/manaswinidas/Docs-test/ +[5]: https://opensource.com/sites/default/files/uploads/git-submodules_github.png (Git submodules screenshot) +[6]: mailto:folder@commitId +[7]: https://opensource.com/sites/default/files/uploads/gitmodules.png (Screenshot of .gitmodules file) +[8]: https://help.github.com/en/github/using-git/about-git-subtree-merges +[9]: https://github.com/git/git/tree/master/contrib/subtree diff --git a/published/202005/20200506 Speed up administration of Kubernetes clusters with k9s.md b/published/202005/20200506 Speed up administration of Kubernetes clusters with k9s.md new file mode 100644 index 0000000000..2d3665fc79 --- /dev/null +++ b/published/202005/20200506 Speed up administration of Kubernetes clusters with k9s.md @@ -0,0 +1,232 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12247-1.html) +[#]: subject: (Speed up administration of Kubernetes clusters with k9s) +[#]: via: (https://opensource.com/article/20/5/kubernetes-administration) +[#]: author: (Jessica Cherry https://opensource.com/users/cherrybomb) + +k9s:你没看错,这是一个加速 k8s 集群管理的工具 +====== + +> 看看这个很酷的 Kubernetes 管理的终端 UI。 + +![](https://img.linux.net.cn/data/attachment/album/202005/25/104742pqjmiroc44honcs5.jpg) + +通常情况下,我写的关于 Kubernetes 管理的文章中用的都是做集群管理的 `kubectl` 命令。然而最近,有人给我介绍了 [k9s][2] 项目,可以让我快速查看并解决 Kubernetes 中的日常问题。这极大地改善了我的工作流程,我会在这篇教程中告诉你如何上手它。  + +它可以安装在 Mac、Windows 和 Linux 中,每种操作系统的说明可以在[这里][2]找到。请先完成安装,以便能够跟上本教程。 + +我会使用 Linux 和 Minikube,这是一种在个人电脑上运行 Kubernetes 的轻量级方式。按照[此教程][3]或使用[该文档][4]来安装它。 + +### 设置 k9s 配置文件 + +安装好 `k9s` 应用后,从帮助命令开始总是很好的起点。 + +``` +$ k9s help +``` + +正如你在帮助信息所看到的,我们可以用 `k9s` 来配置很多功能。我们唯一需要进行的步骤就是编写配置文件。而 `info` 命令会告诉我们该应用程序要在哪里找它的配置文件。 + +``` +$ k9s info + ____ __.________ +| |/ _/ __ \______ +| < \____ / ___/ +| | \ / /\___ \ +|____|__ \ /____//____ > + \/ \/ + +Configuration: /Users/jess/.k9s/config.yml +Logs: /var/folders/5l/c1y1gcw97szdywgf9rk1100m0000gn/T/k9s-jess.log +Screen Dumps: /var/folders/5l/c1y1gcw97szdywgf9rk1100m0000gn/T/k9s-screens-jess +``` + +如果要添加配置文件,该配置目录不存在的话就创建它,然后添加一个配置文件。 + +``` +$ mkdir -p ~/.k9s/ +$ touch ~/.k9s/config.yml +``` + +在这篇介绍中,我们将使用 `k9s` 版本库中推荐的默认 `config.yml`。维护者请注意,这种格式可能会有变化,可以[在这里查看][5]最新版本。 + +``` +k9s: +  refreshRate: 2 +  headless: false +  readOnly: false +  noIcons: false +  logger: +    tail: 200 +    buffer: 500 +    sinceSeconds: 300 +    fullScreenLogs: false +    textWrap: false +    showTime: false +  currentContext: minikube +  currentCluster: minikube +  clusters: +    minikube: +      namespace: +        active: "" +        favorites: +        - all +        - kube-system +        - default +      view: +        active: dp +  thresholds: +    cpu: +      critical: 90 +      warn: 70 +    memory: +      critical: 90 +      warn: 70 +``` + +我们设置了 `k9s` 寻找本地的 minikube 配置,所以我要确认 minikube 已经上线可以使用了。 + +``` +$ minikube status +host: Running +kubelet: Running +apiserver: Running +kubeconfig: Configured +``` + +### 运行 k9s 来探索一个 Kubernetes 集群 + +有了配置文件,并指向我们的本地集群,我们现在可以运行 `k9s` 命令了。 + +``` +$ k9s +``` + +启动后,会弹出 `k9s` 的基于文本的用户界面。在没有指定命名空间标志的情况下,它会向你显示默认命名空间中的 Pod。 + +![K9s screenshot][6] + +如果你运行在一个有很多 Pod 的环境中,默认视图可能会让人不知所措。或者,我们可以将注意力集中在给定的命名空间上。退出该应用程序,运行 `k9s -n `,其中 `` 是已存在的命名空间。在下图中,我运行了 `k9s -n minecraft`,它显示了我损坏的 Pod: + +![K9s screenshot][7] + +所以,一旦你有了 `k9s` 后,有很多事情你可以更快地完成。  + +通过快捷键来导航 `k9s`,我们可以随时使用方向键和回车键来选择列出的项目。还有不少其他的通用快捷键可以导航到不同的视图。 + +* `0`:显示在所有命名空间中的所有 Pod + ![K9s screenshot][8] +* `d`:描述所选的 Pod + ![K9s screenshot][9] +* `l`:显示所选的 Pod 的日志 + ![Using k9s to show Kubernetes pod logs][10] + +你可能会注意到 `k9s` 设置为使用 [Vim 命令键][11],包括使用 `J` 和 `K` 键上下移动等。Emacs 用户们,败退吧 :) + +### 快速查看不同的 Kubernetes 资源 + +需要去找一个不在 Pod 里的东西吗?是的,我也需要。当我们输入冒号(`:`)键时,可以使用很多快捷方式。从那里,你可以使用下面的命令来导航。 + +* `:svc`:跳转到服务视图 + ![K9s screenshot][12] +* `:deploy`:跳转到部署视图 + ![K9s screenshot][13] +* `:rb`:跳转到角色绑定视图,用于 [基于角色的访问控制(RBAC)][14]管理 + ![K9s screenshot][15] +* `:namespace`:跳转到命名空间视图 + ![K9s screenshot][16] +* `:cj`:跳转到 cronjob 视图,查看集群中计划了哪些作业。 + ![K9s screenshot][17] + +这个应用最常用的工具是键盘;要在任何页面往上或下翻页,请使用方向键。如果你需要退出,记得使用 Vim 绑定键,键入 `:q`,然后按回车键离开。 + +### 用 k9s 排除 Kubernetes 的故障示例 + +当出现故障的时候,`k9s` 怎么帮忙?举个例子,我让几个 Pod 由于配置错误而死亡。下面你可以看到我那个可怜的 “hello” 部署死了。当我们将其高亮显示出来,可以按 `d` 运行 `describe` 命令,看看是什么原因导致了故障。 + +![K9s screenshot][18] + +![K9s screenshot][19] + +草草掠过那些事件并不能告诉我们故障原因。接下来,我按了 `esc` 键,然后通过高亮显示 Pod 并输入`shift-l` 来检查日志。 + +![K9s screenshot][20] + +不幸的是,日志也没有提供任何有用的信息(可能是因为部署从未正确配置过),而且 Pod 也没有出现。 + +然后我使用 `esc` 退了出来,我看看删除 Pod 是否能解决这个问题。要做到这一点,我高亮显示该 Pod,然后使用 `ctrl-d`。幸好 `k9s` 在删除前会提示用户。  + +![K9s screenshot][21] + +虽然我确实删除了这个 Pod,但部署资源仍然存在,所以新的 Pod 会重新出现。无论什么原因(我们还不知道),它还会继续重启并死掉。 + +在这里,我会重复查看日志,描述资源,甚至使用 `e` 快捷方式来编辑运行中的 Pod 以排除故障行为。在这个特殊情况下,失败的 Pod 是因为没有配置在这个环境下运行。因此,让我们删除部署来停止崩溃接着重启的循环。 + +我们可以通过键入 `:deploy` 并点击回车进入部署。从那里我们高亮显示并按 `ctrl-d` 来删除。 + +![K9s screenshot][22] + +![K9s screenshot][23] + +这个有问题的部署被干掉了! 只用了几个按键就把这个失败的部署给清理掉了。 + +### k9s 是极其可定制的 + +这个应用有很多自定义选项、乃至于 UI 的配色方案。这里有几个可编辑的选项,你可能会感兴趣。 + +* 调整你放置 `config.yml` 文件的位置(这样你就可以把它存储在[版本控制][24]中)。 +* 在 `alias.yml` 文件中添加[自定义别名][25]。 +* 在 `hotkey.yml` 文件中创建[自定义热键][26]。 +* 探索现有的[插件][27]或编写自己的插件。 + +整个应用是在 YAML 文件中配置的,所以定制化对于任何 Kubernetes 管理员来说都会觉得很熟悉。 + +### 用 k9s 简化你的生活 + +我倾向于以一种非常手动的方式来管理我团队的系统,更多的是为了锻炼脑力,而不是别的。当我第一次听说 `k9s` 的时候,我想,“这只是懒惰的 Kubernetes 而已。”于是我否定了它,然后回到了到处进行人工干预的状态。实际上,当我在处理积压工作时就开始每天使用它,而让我震惊的是它比单独使用 `kubectl` 快得多。现在,我已经皈依了。  + +了解你的工具并掌握做事情的“硬道理”很重要。还有一点很重要的是要记住,就管理而言,重要的是要更聪明地工作,而不是更努力。使用 `k9s`,就是我践行这个目标的方法。我想,我们可以把它叫做懒惰的 Kubernetes 管理,也没关系。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/kubernetes-administration + +作者:[Jessica Cherry][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/cherrybomb +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/game-dogs-chess-play-lead.png?itok=NAuhav4Z (Dogs playing chess) +[2]: https://github.com/derailed/k9s +[3]: https://opensource.com/article/18/10/getting-started-minikube +[4]: https://kubernetes.io/docs/tasks/tools/install-minikube/ +[5]: https://github.com/derailed/k9s#k9s-configuration +[6]: https://opensource.com/sites/default/files/uploads/k9s_1.png (K9s screenshot) +[7]: https://opensource.com/sites/default/files/uploads/k9s_2.png (K9s screenshot) +[8]: https://opensource.com/sites/default/files/uploads/k9s_3.png (K9s screenshot) +[9]: https://opensource.com/sites/default/files/uploads/k9s_5_0.png (K9s screenshot) +[10]: https://opensource.com/sites/default/files/uploads/k9s-show-logs-opensourcedotcom.png (Using k9s to show Kubernetes pod logs) +[11]: https://opensource.com/article/19/3/getting-started-vim +[12]: https://opensource.com/sites/default/files/uploads/k9s_5.png (K9s screenshot) +[13]: https://opensource.com/sites/default/files/uploads/k9s_6.png (K9s screenshot) +[14]: https://kubernetes.io/docs/reference/access-authn-authz/rbac/ +[15]: https://opensource.com/sites/default/files/uploads/k9s_7.png (K9s screenshot) +[16]: https://opensource.com/sites/default/files/uploads/k9s_8.png (K9s screenshot) +[17]: https://opensource.com/sites/default/files/uploads/k9s_9.png (K9s screenshot) +[18]: https://opensource.com/sites/default/files/uploads/k9s_10.png (K9s screenshot) +[19]: https://opensource.com/sites/default/files/uploads/k9s_11.png (K9s screenshot) +[20]: https://opensource.com/sites/default/files/uploads/k9s_12.png (K9s screenshot) +[21]: https://opensource.com/sites/default/files/uploads/k9s_13.png (K9s screenshot) +[22]: https://opensource.com/sites/default/files/uploads/k9s_14.png (K9s screenshot) +[23]: https://opensource.com/sites/default/files/uploads/k9s_15.png (K9s screenshot) +[24]: https://opensource.com/article/19/3/move-your-dotfiles-version-control +[25]: https://k9scli.io/topics/aliases/ +[26]: https://k9scli.io/topics/hotkeys/ +[27]: https://github.com/derailed/k9s/tree/master/plugins diff --git a/published/202005/20200506 Three Methods to Check Uptime of MySQL-MariaDB Database Server on Linux.md b/published/202005/20200506 Three Methods to Check Uptime of MySQL-MariaDB Database Server on Linux.md new file mode 100644 index 0000000000..a319cb3be6 --- /dev/null +++ b/published/202005/20200506 Three Methods to Check Uptime of MySQL-MariaDB Database Server on Linux.md @@ -0,0 +1,139 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12263-1.html) +[#]: subject: (Three Methods to Check Uptime of MySQL/MariaDB Database Server on Linux) +[#]: via: (https://www.2daygeek.com/check-mysql-mariadb-database-server-uptime-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +在 Linux 上检查 MySQL/MariaDB 数据库正常运行时间的三种方法 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/29/211031hqb8qlyddtlrt2fl.jpg) + +我们都知道在 Linux 中使用 `uptime` 命令的目的。它用于检查 [Linux 系统的正常运行时间][1]以及系统上次启动以来运行的时间。 + +而 Linux 管理员的工作是保持系统正常运行。 + +如果要检查 Linux 上的其他服务(例如 [Apache][2]、MySQL、MariaDB、sftp 等)运行了多长时间,该怎么做? + +每个服务都有自己的命令来检查服务的正常运行时间。但是你也可以为此使用其他命令。 + +### 方法 1:如何使用 ps 命令在 Linux 上检查 MySQL/MariaDB 数据库的正常运行时间 + +[ps 命令][3]的意思是进程状态process status。这是最基本的命令之一,它显示了系统正在运行的进程的详细信息。 + +为此,你首先需要使用 [pidof 命令][5]查找 [MySQL][4]/[MariaDB][6] 的 PID。 + +``` +# pidof mysqld | cut -d" " -f1 + +2412 +``` + +获取 MySQL/MariaDB 的 PID 后,请在 `ps` 命令中使用 `--etime` 选项获得正常运行时间。 + +* `--etime`:自进程启动以来经过的时间,形式为 `[[DD-]hh:]mm:ss`。 + +``` +# ps -p 2412 -o etime + + ELAPSED +2-08:49:30 +``` + +或者,在 `ps` 命令中使用 `--lstart` 选项来获取指定 PID 的正常运行时间。 + +``` +# ps -p 2412 -o lstart + + STARTED +Sat May 2 03:02:15 2020 +``` + +MySQL/MariaDB 进程已经运行了 2 天 03 小时 02 分 15 秒。 + +### 方法 2:如何使用 systemctl 命令在 Linux 上检查 MySQL/MariaDB 数据库的正常运行时间 + +[systemctl 命令][7]用于控制 systemd 系统和服务管理器。 + +systemd 是新的初始化系统和系统管理器,现在大多数 Linux 发行版都淘汰了传统的 SysVinit 管理器而采用了 systemd。 + +``` +# systemctl status mariadb +或者 +# systemctl status mysql + +● mariadb.service - MariaDB 10.1.44 database server + Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled) + Drop-In: /etc/systemd/system/mariadb.service.d + └─migrated-from-my.cnf-settings.conf + Active: active (running) since Sat 2020-05-02 03:02:18 UTC; 2 days ago + Docs: man:mysqld(8) + https://mariadb.com/kb/en/library/systemd/ + Process: 2448 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) + Process: 2388 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= || VAR=/usr/bin/galera_recovery; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS) + Process: 2386 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS) + Main PID: 2412 (mysqld) + Status: "Taking your SQL requests now…" + CGroup: /system.slice/mariadb.service + └─2412 /usr/sbin/mysqld + +May 03 21:41:26 ns2.2daygeek.com mysqld[2412]: 2020-05-03 21:41:26 140328136861440 [Warning] Host name '1.1.1.1' could not be resolved: … not known +May 04 02:00:46 ns2.2daygeek.com mysqld[2412]: 2020-05-04 2:00:46 140328436418304 [Warning] IP address '1.1.1.1' has been resolved to the host name '2…ss itself. +May 04 03:01:31 ns2.2daygeek.com mysqld[2412]: 2020-05-04 3:01:31 140328436111104 [Warning] IP address '1.1.1.1' could not be resolved: Temporary fai…resolution +May 04 04:03:06 ns2.2daygeek.com mysqld[2412]: 2020-05-04 4:03:06 140328136861440 [Warning] IP address '1.1.1.1' could not be resolved: Name or ser… not known +May 04 07:23:54 ns2.2daygeek.com mysqld[2412]: 2020-05-04 7:23:54 140328435189504 [Warning] IP address '1.1.1.1' could not be resolved: Name or service not known +May 04 08:03:31 ns2.2daygeek.com mysqld[2412]: 2020-05-04 8:03:31 140328436418304 [Warning] IP address '1.1.1.1' could not be resolved: Name or service not known +May 04 08:25:56 ns2.2daygeek.com mysqld[2412]: 2020-05-04 8:25:56 140328135325440 [Warning] IP address '1.1.1.1' could not be resolved: Name or service not known +Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable. +Hint: Some lines were ellipsized, use -l to show in full. +``` + +### 方法 3:如何使用 MySQLAdmin 命令在 Linux 上检查 MySQL/MariaDB 数据库的正常运行时间 + +[MySQLAdmin][8] 是安装 MySQL 软件包时安装的 MySQL 服务器命令行程序。 + +MySQLAdmin 客户端允许你在 MySQL 服务器上执行一些基本的管理功能。 + +它用于创建数据库、删除数据库、设置 root 密码、更改 root 密码、检查 MySQL 状态、验证 MySQL 功能、监视 mysql 进程以及验证服务器的配置。 + +``` +# mysqladmin -u root -pPassword version + +mysqladmin Ver 8.42 Distrib 5.7.27, for Linux on x86_64 +Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + +Oracle is a registered trademark of Oracle Corporation and/or its +affiliates. Other names may be trademarks of their respective +owners. + +Server version 5.7.27 +Protocol version 10 +Connection Localhost via UNIX socket +UNIX socket /var/lib/mysql/mysql.sock +Uptime: 1 day 10 hours 44 min 13 sec +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/check-mysql-mariadb-database-server-uptime-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-system-server-uptime-check/ +[2]: https://www.2daygeek.com/check-find-apache-httpd-web-server-uptime-linux/ +[3]: https://www.2daygeek.com/linux-ps-command-find-running-process-monitoring/ +[4]: https://www.2daygeek.com/category/mysql/ +[5]: https://www.2daygeek.com/check-find-parent-process-id-pid-ppid-linux/ +[6]: https://www.2daygeek.com/category/mariadb/ +[7]: https://www.2daygeek.com/sysvinit-vs-systemd-cheatsheet-systemctl-command-usage/ +[8]: https://www.2daygeek.com/linux-mysqladmin-command-administrate-mysql-mariadb-server/ diff --git a/published/202005/20200507 Ubuntu Studio To Replace Xfce With KDE Plasma Desktop Environment.md b/published/202005/20200507 Ubuntu Studio To Replace Xfce With KDE Plasma Desktop Environment.md new file mode 100644 index 0000000000..d349c73567 --- /dev/null +++ b/published/202005/20200507 Ubuntu Studio To Replace Xfce With KDE Plasma Desktop Environment.md @@ -0,0 +1,71 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12223-1.html) +[#]: subject: (Ubuntu Studio To Replace Xfce With KDE Plasma Desktop Environment) +[#]: via: (https://itsfoss.com/ubuntu-studio-opts-for-kde/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Ubuntu Studio 将用 KDE Plasma 桌面环境替换 Xfce +====== + +[Ubuntu Studio][1] 是一个流行的 [Ubuntu 官方变种][2],它是为从事音频制作、视频、图形、摄影和书籍出版的创意内容创建者量身定制的。它提供了许多多媒体内容创建应用,开箱即用,体验极佳。 + +在最近的 20.04 LTS 版本发布之后,Ubuntu Studio 团队在其[官方公告][3]中强调了一些非常重要的内容。而且,也许不是每个人都注意到关键信息,即 Ubuntu Studio 的未来。 + +Ubuntu Studio 20.04 将是带有 [Xfce 桌面环境][4]的最后一个版本。将来的所有发行版都将改用 [KDE Plasma][5]。 + +### 为什么 Ubuntu Studio 放弃 XFCE? + +![][6] + +据他们的澄清,Ubuntu Studio 并不专注于任何特定的外观/感受,而是旨在提供最佳的用户体验。同时,KDE 被证明是一个更好的选择。 + +> 事实证明,Plasma 为图形艺术家和摄影师提供了更好的工具,例如在 Gwenview、Krita 甚至文件管理器 Dolphin 中都可以看出。此外,它对 Wacom 平板的支持比其他任何桌面环境都更好。 + +> 它已经变得如此之好,以至于现在大部分 Ubuntu Studio 团队成员都在使用通过 Ubuntu Studio 安装程序添加了 Ubuntu Studio 的 Kubuntu 作为日常工作使用。既然我们中的这么多人都在使用 Plasma,因此在我们的下一个版本中过渡到 Plasma 似乎是个好时机。 + +当然,每一个桌面环境都是针对不同的用户量身定制的。在此,他们认为 KDE Plasma 是最适合取代 XFCE 的桌面环境,可以为所有用户提供更好的用户体验。 + +尽管我不确定用户对此会有何反应,因为每个用户都有不同的偏好。如果现有用户对 KDE 没有问题,那就没什么大问题。 + +值得注意的是,Ubuntu Studio 还提到了为什么 KDE 可能是它们的更好选择: + +> 在没有 Akonadi 的情况下,Plasma 桌面环境的资源使用与 Xfce 一样轻量级,甚至更轻。Fedora Jam 和 KXStudio 等其他以音频为重点的 Linux 发行版在历史上一直使用 KDE Plasma 桌面环境,并且在音频方面做得很好。 + +此外,他们还强调了 [Jason Evangelho 在福布斯杂志上的一篇文章][7],其中一些基准测试表明 KDE 几乎与 Xfce 一样轻量级。尽管这是一个好的迹象,我们仍然需要等待用户试驾 KDE 驱动的 Ubuntu Studio。只有这样,我们才能观察到 Ubuntu Studio 放弃 XFCE 桌面环境的决定是否正确。 + +### 更改后,Ubuntu Studio 用户将发生什么变化? + +在带有 KDE 的 Ubuntu Studio 20.10 及更高版本上的整体工作流程可能会受到影响(或改善)。 + +但是,升级过程(从 20.04 到 20.10)会导致系统损坏。因此,全新安装 Ubuntu Studio 20.10 或更高版本将是唯一的方法。 + +他们还提到,他们还会不断评估与预安装的应用是否存在重复。所以,相信在未来的日子里,更多的细节也会随之而来。 + +Ubuntu Studio 是最近一段时间内第二个改变了主桌面环境的发行版。先前,[Lubuntu][8] 从 LXDE 切换到 LXQt。 + +你如何看待这种变化?欢迎在下面的评论中分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-studio-opts-for-kde/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://ubuntustudio.org/ +[2]: https://itsfoss.com/which-ubuntu-install/ +[3]: https://ubuntustudio.org/2020/04/ubuntu-studio-20-04-lts-released/ +[4]: https://xfce.org +[5]: https://kde.org/plasma-desktop +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-studio-kde-xfce.jpg?ssl=1 +[7]: https://www.forbes.com/sites/jasonevangelho/2019/10/23/bold-prediction-kde-will-steal-the-lightweight-linux-desktop-crown-in-2020 +[8]: https://itsfoss.com/lubuntu-20-04-review/ diff --git a/published/202005/20200508 5 ways to split your Linux terminal.md b/published/202005/20200508 5 ways to split your Linux terminal.md new file mode 100644 index 0000000000..3bc58045fa --- /dev/null +++ b/published/202005/20200508 5 ways to split your Linux terminal.md @@ -0,0 +1,158 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12236-1.html) +[#]: subject: (5 ways to split your Linux terminal) +[#]: via: (https://opensource.com/article/20/5/split-terminal) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +5 种拆分 Linux 终端的方法 +====== + +> 本文介绍了 Linux 提供的拆分终端的方法,它能够帮助你完成多任务工作。那么,你最喜欢哪一款终端复用工具呢? + +![](https://img.linux.net.cn/data/attachment/album/202005/21/132437ypzpqqppqh1qfznh.jpg) + +没有什么问题是不能用一个 Linux 终端解决的,如果不行,那就用两个。 + +很早以前,[终端其实是一个物理设备][2],而现在的终端实际上是在计算机上被模拟出来的一个应用程序。当你使用终端和计算机进行交互的时候,就会发现,只打开一个终端是不够用的。在进行编译、数据处理等长时间任务的时候,你不得不打开一个新终端或新选项卡tab来同时进行其它工作。 + +如果你是系统管理员,你就需要更多的终端窗口,以便连接到多个不同的主机上并行工作了。 + +在 Linux 系统中,终端应用程序在很久之前就已经开始带有选项卡功能了。而现在的终端应用程序里,选项卡已经是标配功能了,这是非常流行的趋势。尽管如此,工作的时候在多个选项卡之间来回切换,或多或少也会分散我们的注意力,甚至带来不便。 + +而最好的解决方案就是将整个屏幕划分为多个部分,这样多个终端就可以在同一个终端应用程序窗口中同时存在。Linux 发行版中也有很多相关的工具可以实现这一功能。 + +### Shell、终端和控制台 + +在此之前,我们首先要明确 Shell、终端terminal控制台console这三个概念。想要详细了解的话,请参阅 [Enable Sysadmin][2] 博客上的相关文章。 + +简而言之: + +* **Shell** 是带有命令提示符prompt的用于输入、输出的界面。准确地说,[POSIX][3] 桌面底层也运行着一个 Shell,即使这个 Shell 对用户不可见,因为用户会话就是由这个 Shell 启动的。 +* **终端**是在图形界面服务器(例如 X11 或 Wayland)中运行的应用程序,其中加载了一个 Shell。只有在终端窗口启动之后,才算是运行了一个终端。终端可以认为是操作 Shell 的一个入口。 +* **控制台**(或称“虚拟控制台”)通常表示在桌面环境以外使用的 Shell,你可以通过 `Alt+Ctrl+F2` 进入控制台,通常情况下从 `F3` 到 `F7` 都是不同的控制台,其中桌面环境有可能是 `F1` 或者 `F7`,这在不同的发行版中可能会有所不同。 + +因此,有些应用程序提供的功能是拆分 Shell 或者控制台,有些应用程序的功能则是拆分终端。 + +### tmux + +![tmux terminal][4] + +[tmux][5] 可以说是最灵活、最强大的屏幕拆分工具了,它通过键盘控制对多个终端的复用,因此你可以将一个控制台叠放在另一个控制台上面,并在两个控制台之间切换。你还可以将整个屏幕等分为多个控制台,以便同时观察不同控制台上的状况。 + +`tmux` 的所有操作都是通过键盘完成的,这就意味着你的手不需要离开键盘去寻找鼠标。为此,你需要记住一些按键组合。 + +如果你只用 `tmux` 来做屏幕拆分,那你只需要记住一下这些命令: + + * `Ctrl-B %` 竖直拆分屏幕(两个 Shell 分别位于左右) + * `Ctrl-B "` 水平拆分屏幕(两个 Shell 分别位于上下) + * `Ctrl-B O` 切换到另一个 Shell + * `Ctrl-B ?` 查看帮助 + * `Ctrl-B d` 断开 `tmux` 并让其在后台运行(可以使用 `tmux attach` 重新进入) + +`tmux` 的一大好处是,在一台计算机上启动 `tmux` 会话之后,也可以从另一台计算机上进入到这个会话,由此可以看出,`tmux` 对 Shell 进行了守护进程化daemonize。 + +例如,当我在树莓派上运行 `tmux`,我就可以从计算机上连接到树莓派并登录 IRC,当我断开连接时,树莓派上的 `tmux` 会继续运行,并等待我的下一次连接,在此期间 IRC 是处于持续登录状态的。 + +### GNU Screen + +![GNU Screen terminal][6] + +[GNU Screen][7] 也是一个 Shell 复用工具,类似于 `tmux`,你可以在断开一个活动会话后重连到其中,它也支持竖直或水平拆分屏幕。 + +`screen` 的灵活性比 `tmux` 要弱一些。它默认的绑定按键组合是 `Ctrl-A`,和 Bash 中光标移动到行首的快捷键是一样的。因此,当你正在运行 `screen` 的时候,如果想要将光标移动到行首,就需要多按一次 `Ctrl-A`。而我自己的做法是,在 `$HOME/.screenrc` 文件中将绑定按键组合重新设置为 `Ctrl-J`。 + +``` +escape ^jJ +``` + +尽管 `screen` 在屏幕拆分功能上做得很好,但 `tmux` 上的一些缺点在 Screen 上也同样存在。例如在拆分 Shell 时,在一个新的面板中不会启动新的 Shell ,而是需要使用 `Ctrl-A Tab` 导航到另一个面板(如果你按照我的方式重新设置了按键组合,需要对应地把 `Ctrl-A` 改为 `Ctrl-J`),然后通过 `Ctrl-A C` 手动创建一个新的 Shell。 + +和 `tmux` 不同的是,`screen` 在退出一个 Shell 的时候,屏幕拆分状态不会改变,这样的设计在某些情况下是比较适合的,但麻烦之处在于需要手动管理屏幕拆分状态。 + +尽管如此,`screen` 还是一个相当可靠灵活的应用程序,在无法使用 `tmux` 的时候,你可以选择 `screen` 作为备选方案。 + +在默认按键方案下,`screen` 常用的基本命令包括: + + * `Ctrl-A |` 竖直拆分屏幕(两个 Shell 分别位于左右) + * `Ctrl-A S` 水平拆分屏幕(两个 Shell 分别位于上下) + * `Ctrl-A Tab` 切换到另一个 Shell + * `Ctrl-A ?` 查看帮助 + * `Ctrl-A d` 断开 `screen` 并让其在后台运行(可以使用 `screen -r` 重新进入) + +### Konsole + +![Konsole screen][8] + +[Konsole][9] 是 KDE Plasma 桌面使用的终端应用程序。和 KDE 一样,Konsole 也以高度可定制、功能强大的特点而著称。 + +和 `tmux`、GNU Screen 类似,Konsole 也具有拆分屏幕的功能。由于 Konsole 是图形界面的终端,因此还可以用鼠标来控制它的屏幕拆分。 + +Konsole 的屏幕拆分功能在“查看View”菜单中。它也支持竖直和水平方向的拆分,只要点击鼠标就可以切换到另一个面板上。每个面板都是一个独立的终端,因此都可以拥有独立的主题和标签页。 + +Konsole 和 `tmux`、GNU Screen 最大的不同之处在于不能断开和重新连接 Konsole。除非使用远程桌面软件,否则只能在打开 Konsole 时使用,这一点和大多数图形界面应用程序是一样的。 + +### Emacs + +![Emacs rpg][10] + +严格来说,Emacs 并不算是一个终端复用工具,但它的使用界面支持拆分和调整大小,同时还带有一个内建的终端。 + +如果 Emacs 是你日常使用的文本编辑器,你就可以在不关闭编辑器的情况下,在不同的应用程序之间轻松互相切换。由于 Emacs eshell 模块是通过 eLISP 实现的,因此你可以在 Emacs 中使用相同的命令进行交互,让一些繁琐的操作变得更为简单。 + +如果你是在图形界面中使用 Emacs,还可以使用鼠标进行操作。例如通过点击切换面板、用鼠标调整拆分屏幕的的大小等等。尽管如此,键盘的操作速度还是更快,因此记住一些键盘快捷键还是很有必要的。 + +Emacs 的一些重要快捷键包括: + + * `Ctrl-X 3` 竖直拆分屏幕(两个 Shell 分别位于左右) + * `Ctrl-X 2` 水平拆分屏幕(两个 Shell 分别位于上下) + * `Ctrl-X O` (大写字母 `O`)切换到另一个 Shell(你也可以使用鼠标操作) + * `Ctrl-X 0` (数字 `0`)关闭当前面板 + +如果你运行了 emacs-client 的话,就可以像 tmux 和 GNU Screen 一样断开和重新连接到 Emacs 了。 + +### 窗口管理器 + +![Ratpoison split screen][11] + +除了文本编辑器之外,一些 Linux 桌面也同样具有拆分屏幕、加载终端这样的功能。例如 [Ratpoison][12]、[Herbsluftwm][13]、i3、Awesome,甚至是启用了特定设置的 KDE Plasma 桌面,都可以将多个应用程序在桌面上分块显示。 + +这些桌面可以让各个应用程序占据屏幕的固定位置,而不是浮在你的桌面“之上”,因此你可以在多个应用程序窗口之间轻松切换。你还可以打开多个终端,排布成网格,就像终端复用工具一样。更进一步,你还可以在你的桌面复用工具中加载一个终端复用工具。 + +而且,没有什么可以阻止你在里面载入 Emacs 并分割缓冲区。没有人知道,如果你把它更进一步,会发生什么,大多数 Linux 用户不会外传这种秘密。 + +和 `tmux`、GNU Screen 不同,你在断开与桌面的连接后无法重新连接到同一个桌面会话,除非你使用了远程桌面软件进行连接。 + +### 更多选择 + +除了上面介绍到的工具以外,还有诸如 [Tilix][14]、Terminator 这样的终端模拟器,它们同样可以实现屏幕拆分、嵌入终端组件等功能。欢迎在评论区分享你喜欢的终端拆分工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/split-terminal + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/freedos.png?itok=aOBLy7Ky (4 different color terminal windows with code) +[2]: https://www.redhat.com/sysadmin/terminals-shells-consoles +[3]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[4]: https://opensource.com/sites/default/files/uploads/terminal-split-tmux2.png (tmux terminal) +[5]: https://github.com/tmux/tmux +[6]: https://opensource.com/sites/default/files/uploads/terminal-split-screen.png (GNU Screen terminal) +[7]: https://www.gnu.org/software/screen/ +[8]: https://opensource.com/sites/default/files/uploads/konsole.jpg (Konsole screen) +[9]: https://konsole.kde.org +[10]: https://opensource.com/sites/default/files/uploads/emacs-rpg_0.jpg (Emacs rpg) +[11]: https://opensource.com/sites/default/files/uploads/advent-ratpoison-split_0.jpg (Ratpoison split screen) +[12]: https://opensource.com/article/19/12/ratpoison-linux-desktop +[13]: https://opensource.com/article/19/12/herbstluftwm-linux-desktop +[14]: https://gnunn1.github.io/tilix-web/ diff --git a/published/202005/20200508 Fixing -Unable to parse package file -var-lib-apt-lists- Error in Ubuntu and Other Linux Distributions.md b/published/202005/20200508 Fixing -Unable to parse package file -var-lib-apt-lists- Error in Ubuntu and Other Linux Distributions.md new file mode 100644 index 0000000000..41c25c7d8d --- /dev/null +++ b/published/202005/20200508 Fixing -Unable to parse package file -var-lib-apt-lists- Error in Ubuntu and Other Linux Distributions.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12216-1.html) +[#]: subject: (Fixing “Unable to parse package file /var/lib/apt/lists” Error in Ubuntu and Other Linux Distributions) +[#]: via: (https://itsfoss.com/unable-to-parse-package-file/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +修复 Ubuntu 中的 “Unable to parse package file” 错误 +====== + +过去,我已经讨论了许多 [Ubuntu 更新错误][1]。如果你[使用命令行更新 Ubuntu][2],那可能会遇到一些“错误”。 + +其中一些“错误”基本上是内置功能,可防止对系统进行不必要的更改。在本教程中,我不会涉及那些细节。 + +在本文中,我将向你展示如何解决在更新系统或安装新软件时可能遇到的以下错误: + +``` +Reading package lists… Error! +E: Unable to parse package file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease +E: The package lists or status file could not be parsed or opened. +``` + +在 Debian 中可能会遇到类似的错误: + +``` +E: Unable to parse package file /var/lib/apt/extended_states (1) +``` + +即使遇到 `The package cache file is corrupted` 也完全不必惊慌。这真的很容易“修复”。 + +### 在基于 Ubuntu 和 Debian 的 Linux 发行版中处理 “Unable to parse package file” 错误 + +![][3] + +以下是你需要做的。仔细查看 [Ubuntu][4] 报错文件的名称和路径。 + +``` +Reading package lists… Error! +E: Unable to parse package file /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease +E: The package lists or status file could not be parsed or opened. +``` + +例如,上面的错误是在报 `/var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease` 文件错误。 + +这让你想到这个文件不正确。现在,你需要做的就是删除该文件并重新生成缓存。 + +``` +sudo rm +``` + +因此,这里我可以使用以下命令:`sudo rm /var/lib/apt/lists/archive.ubuntu.com_ubuntu_dists_bionic_InRelease`,然后使用 `sudo apt update` 命令重建缓存。 + +#### 给初学者的分步指导 + +如果你熟悉 Linux 命令,那么可能知道如何使用绝对路径删除文件。对于新手用户,让我指导你安全删除文件。 + +首先,你应该进入文件目录: + +``` +cd /var/lib/apt/lists/ +``` + +现在删除无法解析的文件: + +``` +sudo rm archive.ubuntu.com_ubuntu_dists_bionic_InRelease +``` + +现在,如果你再次运行更新,将重新生成 apt 缓存。 + +``` +sudo apt update +``` + +#### 有很多文件无法解析? + +如果你在更新系统时有一个或两个文件无法解析,那么问题不大。但是,如果系统报错有十个或二十个此类文件,那么一一删除它们就太累了。 + +在这种情况下,你可以执行以下操作来删除整个缓存,然后再次生成它: + +``` +sudo rm -r /var/lib/apt/lists/* +sudo apt update +``` + +#### 解释这为何能解决问题 + +`/var/lib/apt` 是与 apt 软件包管理器相关的文件和数据的存储目录。`/var/lib/apt/lists` 是用于保存系统 `source.list` 中指定的每个软件包资源信息的目录。 + +简单点来说,`/var/lib/apt/lists` 保存软件包信息缓存。当你要安装或更新程序时,系统会在此目录中检查该软件包中的信息。如果找到了该包的详细信息,那么它将进入远程仓库并实际下载程序或其更新。 + +当你运行 `sudo apt update` 时,它将构建缓存。这就是为什么即使删除 `/var/lib/apt/lists` 目录中的所有内容,运行更新也会建立新的缓存的原因。 + +这就是处理文件无法解析问题的方式。你的系统报某个软件包或仓库信息以某种方式损坏(下载失败或手动更改 `sources.list`)。删除该文件(或所有文件)并重建缓存即可解决此问题。 + +#### 仍然有错误? + +这应该能解决你的问题。但是,如果问题仍然存在,或者你还有其他相关问题,请在评论栏告诉我,我将尽力帮助你。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/unable-to-parse-package-file/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ubuntu-update-error/ +[2]: https://itsfoss.com/update-ubuntu/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/Unable-to-parse-package-file.png?ssl=1 +[4]: https://ubuntu.com/ diff --git a/published/202005/20200508 Getting started with FreeBSD as a desktop operating system.md b/published/202005/20200508 Getting started with FreeBSD as a desktop operating system.md new file mode 100644 index 0000000000..ef63e7b696 --- /dev/null +++ b/published/202005/20200508 Getting started with FreeBSD as a desktop operating system.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12225-1.html) +[#]: subject: (Getting started with FreeBSD as a desktop operating system) +[#]: via: (https://opensource.com/article/20/5/furybsd-linux) +[#]: author: (Joshua Allen Holm https://opensource.com/users/holmja) + +使用 FreeBSD 作为桌面操作系统 +====== + +> FuryBSD 的实时桌面环境能让你在实际使用之前先尝试。 + +![FuryBSD Post-Install XFCE Desktop][10] + +[FreeBSD][2] 是一个很棒的操作系统,但是从设计上讲,它并没有自带桌面环境。如果不从 FreeBSD 的 [ports 和软件包集][3]安装其他软件,那么 FreeBSD 仅能体验命令行。下面的截图显示了在安装过程中选择了每个“可选系统组件”后,登录 FreeBSD 12.1 的样子。 + +![FreeBSD][4] + +FreeBSD 可以用各种桌面环境中的任何一种来变成桌面操作系统,但是这需要时间、精力和[遵循大量书面说明][5]。使用使用 desktop-installer 包(为用户提供基于文本的菜单并帮助自动执行大部分过程)仍然非常耗时。这两种方法的最大问题是,用户可能在花了很多时间进行设置之后,可能会发现他们的硬件系统与 FreeBSD 不完全兼容。 + +[FuryBSD][6] 通过提供实时桌面镜像来解决此问题,用户可以在安装之前对其进行评估。目前,FuryBSD 提供 Xfce 镜像和 KDE 镜像。每个镜像都提供了一个已预安装桌面环境的 FreeBSD。如果用户试用该镜像并发现其硬件工作正常,那么他们可以安装 FuryBSD,并拥有一个由 FreeBSD 驱动的即用桌面操作系统。在本文中,我会使用 Xfce 镜像,但 KDE 镜像的工作原理完全一样。 + +对于安装过 Linux 发行版、BSD 或任何其他类 Unix 的开源操作系统的人,FuryBSD 的上手过程应该很熟悉。从 FuryBSD 网站下载 ISO,将它复制到闪存盘,然后从闪存盘启动计算机。如果从闪存盘引导失败,请确保“安全引导”已禁用。 + +![FuryBSD Live XFCE Desktop][7] + +从闪存盘启动后,桌面环境将自动加载。除了“家”、“文件系统”和“回收站”图标外,实时桌面还有用于配置 Xorg 的工具、入门指南、FuryBSD 安装程序和系统信息程序的图标。除了这些额外功能以及一些自定义的 Xfce 设置和壁纸外,桌面环境除了基本的 Xfce 应用和 Firefox 之外并没有其他功能。 + +![FuryBSD Xorg Tool][8] + +此时仅加载基本的图形驱动,但足以检查 FuryBSD 是否支持系统的有线和无线网络接口。如果网络接口没有一个能自动工作,那么 `Getting Started.txt` 文件包含有关尝试配置网络接口和其他配置任务的说明。如果至少有一个网络接口有效,那么可以使用 Configure Xorg 应用安装 Intel、NVidia 或 VirtualBox 图形驱动。它将下载并安装驱动,并且需要重新启动 Xorg。如果系统未自动重新登录到实时镜像用户,那么密码为 `furybsd`(你可以使用它来登录)。配置后,图形驱动将转移到已安装的系统中。 + +![FuryBSD Installer - ZFS Configuration][9] + +如果一切都可以在实时环境中正常运行,那么 FuryBSD 安装程序可以将 FuryBSD 配置并安装到计算机上。该安装程序在终端中运行,但提供与大多数其他 BSD 和 Linux 安装程序相同的选项。系统将要求用户设置系统的主机名、配置 ZFS 存储、设置 root 密码,添加至少一个非 root 用户以及配置时间和日期。完成后,系统可以引导到预装有 Xfce (或 KDE)的 FreeBSD 中。FuryBSD 完成了所有困难的工作,甚至还花了很多精力使桌面看起来更漂亮。 + + + +如上所述,桌面环境没有大量预装软件,因此几乎肯定要安装额外的软件包。最快的方法是在终端中使用 `pkg` 命令。该命令的行为很像 `dnf` 和 `apt`,因此使用过其中之一的来自 Linux 发行版的用户在查找和安装软件包时应该感到很熟悉。FreeBSD 的软件包集合非常多,因此大多数知名的开源软件包都可用。 + +如果用户在没有太多 FreeBSD 经验的情况下尝试 FuryBSD,应查阅 [FreeBSD 手册][11],以了解有关如何以 FreeBSD 的方式操作。有任何 Linux 发行版或其他 BSD 使用经验的用户应该能弄清很多事情,但是手册可以帮助你弄清一些差异。进一步了解 FreeBSD 的一个很好的资源是 Michael W. Lucas 的 《[Absolute FreeBSD,第三版][12]》。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/furybsd-linux + +作者:[Joshua Allen Holm][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/holmja +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh (web development and design, desktop and browser) +[2]: https://www.freebsd.org +[3]: https://www.freebsd.org/ports/ +[4]: https://opensource.com/sites/default/files/uploads/freebsd.png (FreeBSD) +[5]: https://www.freebsdfoundation.org/freebsd/how-to-guides/installing-a-desktop-environment-on-freebsd/ +[6]: https://www.furybsd.org +[7]: https://opensource.com/sites/default/files/uploads/furybsd_live_xfce_desktop.png (FuryBSD Live XFCE Desktop) +[8]: https://opensource.com/sites/default/files/uploads/furybsd_xorg_tool.png (FuryBSD Xorg Tool) +[9]: https://opensource.com/sites/default/files/uploads/furybsd_installer_-_zfs_configuration.png (FuryBSD Installer - ZFS Configuration) +[10]: https://opensource.com/sites/default/files/uploads/furybsd_post-install_xfce_desktop.png (FuryBSD Post-Install XFCE Desktop) +[11]: https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ +[12]: https://nostarch.com/absfreebsd3 diff --git a/published/202005/20200509 Ensmallening Go binaries by prohibiting comparisons.md b/published/202005/20200509 Ensmallening Go binaries by prohibiting comparisons.md new file mode 100644 index 0000000000..1d1a6b1590 --- /dev/null +++ b/published/202005/20200509 Ensmallening Go binaries by prohibiting comparisons.md @@ -0,0 +1,162 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12238-1.html) +[#]: subject: (Ensmallening Go binaries by prohibiting comparisons) +[#]: via: (https://dave.cheney.net/2020/05/09/ensmallening-go-binaries-by-prohibiting-comparisons) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +通过禁止比较让 Go 二进制文件变小 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/22/101617lcha7vvqzhh7d565.jpg) + +大家常规的认知是,Go 程序中声明的类型越多,生成的二进制文件就越大。这个符合直觉,毕竟如果你写的代码不去操作定义的类型,那么定义一堆类型就没有意义了。然而,链接器的部分工作就是检测没有被程序引用的函数(比如说它们是一个库的一部分,其中只有一个子集的功能被使用),然后把它们从最后的编译产出中删除。常言道,“类型越多,二进制文件越大”,对于多数 Go 程序还是正确的。 + +本文中我会深入讲解在 Go 程序的上下文中“相等”的意义,以及为什么[像这样][1]的修改会对 Go 程序的大小有重大的影响。 + +### 定义两个值相等 + +Go 的语法定义了“赋值”和“相等”的概念。赋值是把一个值赋给一个标识符的行为。并不是所有声明的标识符都可以被赋值,如常量和函数就不可以。相等是通过检查标识符的内容是否相等来比较两个标识符的行为。 + +作为强类型语言,“相同”的概念从根源上被植入标识符的类型中。两个标识符只有是相同类型的前提下,才有可能相同。除此之外,值的类型定义了如何比较该类型的两个值。 + +例如,整型是用算数方法进行比较的。对于指针类型,是否相等是指它们指向的地址是否相同。映射和通道等引用类型,跟指针类似,如果它们指向相同的地址,那么就认为它们是相同的。 + +上面都是按位比较相等的例子,即值占用的内存的位模式是相同的,那么这些值就相等。这就是所谓的 memcmp,即内存比较,相等是通过比较两个内存区域的内容来定义的。 + +记住这个思路,我过会儿再来谈。 + +### 结构体相等 + +除了整型、浮点型和指针等标量类型,还有复合类型:结构体。所有的结构体以程序中的顺序被排列在内存中。因此下面这个声明: + +``` +type S struct { + a, b, c, d int64 +} +``` + +会占用 32 字节的内存空间;`a` 占用 8 个字节,`b` 占用 8 个字节,以此类推。Go 的规则说如果结构体所有的字段都是可以比较的,那么结构体的值就是可以比较的。因此如果两个结构体所有的字段都相等,那么它们就相等。 + +``` +a := S{1, 2, 3, 4} +b := S{1, 2, 3, 4} +fmt.Println(a == b) // 输出 true +``` + +编译器在底层使用 memcmp 来比较 `a` 的 32 个字节和 `b` 的 32 个字节。 + +### 填充和对齐 + +然而,在下面的场景下过分简单化的按位比较的策略会返回错误的结果: + +``` +type S struct { + a byte + b uint64 + c int16 + d uint32 +} + +func main() + a := S{1, 2, 3, 4} + b := S{1, 2, 3, 4} + fmt.Println(a == b) // 输出 true +} +``` + +编译代码后,这个比较表达式的结果还是 `true`,但是编译器在底层并不能仅依赖比较 `a` 和 `b` 的位模式,因为结构体有*填充*。 + +Go 要求结构体的所有字段都对齐。2 字节的值必须从偶数地址开始,4 字节的值必须从 4 的倍数地址开始,以此类推 [^1]。编译器根据字段的类型和底层平台加入了填充来确保字段都*对齐*。在填充之后,编译器实际上看到的是 [^2]: + +``` +type S struct { + a byte + _ [7]byte // 填充 + b uint64 + c int16 + _ [2]int16 // 填充 + d uint32 +} +``` + +填充的存在保证了字段正确对齐,而填充确实占用了内存空间,但是填充字节的内容是未知的。你可能会认为在 Go 中 填充字节都是 0,但实际上并不是 — 填充字节的内容是未定义的。由于它们并不是被定义为某个确定的值,因此按位比较会因为分布在 `s` 的 24 字节中的 9 个填充字节不一样而返回错误结果。 + +Go 通过生成所谓的相等函数来解决这个问题。在这个例子中,`s` 的相等函数只比较函数中的字段略过填充部分,这样就能正确比较类型 `s` 的两个值。 + +### 类型算法 + +呵,这是个很大的设置,说明了为什么,对于 Go 程序中定义的每种类型,编译器都会生成几个支持函数,编译器内部把它们称作类型的算法。如果类型是一个映射的键,那么除相等函数外,编译器还会生成一个哈希函数。为了维持稳定,哈希函数在计算结果时也会像相等函数一样考虑诸如填充等因素。 + +凭直觉判断编译器什么时候生成这些函数实际上很难,有时并不明显,(因为)这超出了你的预期,而且链接器也很难消除没有被使用的函数,因为反射往往导致链接器在裁剪类型时变得更保守。 + +### 通过禁止比较来减小二进制文件的大小 + +现在,我们来解释一下 Brad 的修改。向类型添加一个不可比较的字段 [^3],结构体也随之变成不可比较的,从而强制编译器不再生成相等函数和哈希函数,规避了链接器对那些类型的消除,在实际应用中减小了生成的二进制文件的大小。作为这项技术的一个例子,下面的程序: + +``` +package main + +import "fmt" + +func main() { + type t struct { + // _ [0][]byte // 取消注释以阻止比较 + a byte + b uint16 + c int32 + d uint64 + } + var a t + fmt.Println(a) +} +``` + +用 Go 1.14.2(darwin/amd64)编译,大小从 2174088 降到了 2174056,节省了 32 字节。单独看节省的这 32 字节似乎微不足道,但是考虑到你的程序中每个类型及其传递闭包都会生成相等和哈希函数,还有它们的依赖,这些函数的大小随类型大小和复杂度的不同而不同,禁止它们会大大减小最终的二进制文件的大小,效果比之前使用 `-ldflags="-s -w"` 还要好。 + +最后总结一下,如果你不想把类型定义为可比较的,可以在源码层级强制实现像这样的奇技淫巧,会使生成的二进制文件变小。 + +* * * + +附录:在 Brad 的推动下,[Cherry Zhang][5] 和 [Keith Randall][6] 已经在 Go 1.15 做了大量的改进,修复了最严重的故障,消除了无用的相等和哈希函数(虽然我猜想这也是为了避免这类 CL 的扩散)。 + +[^1]: 在 32 位平台上 `int64` 和 `unit64` 的值可能不是按 8 字节对齐的,因为平台原生的是以 4 字节对齐的。查看 [议题 599][7] 了解内部详细信息。 +[^2]: 32 位平台会在 `a` 和 `b` 的声明中填充 `_ [3]byte`。参见前一条。 +[^3]: Brad 使用的是`[0]func()`,但是所有能限制和禁止比较的类型都可以。添加了一个有 0 个元素的数组的声明后,结构体的大小和对齐不会受影响。 + +#### 相关文章: + + 1. [Go 运行时如何高效地实现映射(不使用泛型)][11] + 2. [空结构体][12] + 3. [填充很难][13] + 4. [Go 中有类型的 nil(2)][14] + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2020/05/09/ensmallening-go-binaries-by-prohibiting-comparisons + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://github.com/golang/net/commit/e0ff5e5a1de5b859e2d48a2830d7933b3ab5b75f +[2]: tmp.uBLyaVR1Hm#easy-footnote-bottom-1-4116 (On 32bit platforms int64 and uint64 values may not be 8 byte aligned as the natural alignment of the platform is 4 bytes. See issue 599 for the gory details.) +[3]: tmp.uBLyaVR1Hm#easy-footnote-bottom-2-4116 (32 bit platforms would see _ [3]byte padding between the declaration of a and b. See previous.) +[4]: tmp.uBLyaVR1Hm#easy-footnote-bottom-3-4116 (Brad used [0]func(), but any type that the spec limits or prohibits comparisons on will do. By declaring the array has zero elements the type has no impact on the size or alignment of the struct.) +[5]: https://go-review.googlesource.com/c/go/+/231397 +[6]: https://go-review.googlesource.com/c/go/+/191198 +[7]: https://github.com/golang/go/issues/599 +[8]: tmp.uBLyaVR1Hm#easy-footnote-1-4116 +[9]: tmp.uBLyaVR1Hm#easy-footnote-2-4116 +[10]: tmp.uBLyaVR1Hm#easy-footnote-3-4116 +[11]: https://dave.cheney.net/2018/05/29/how-the-go-runtime-implements-maps-efficiently-without-generics (How the Go runtime implements maps efficiently (without generics)) +[12]: https://dave.cheney.net/2014/03/25/the-empty-struct (The empty struct) +[13]: https://dave.cheney.net/2015/10/09/padding-is-hard (Padding is hard) +[14]: https://dave.cheney.net/2017/08/09/typed-nils-in-go-2 (Typed nils in Go 2) diff --git a/published/202005/20200511 Can-t Install Deb File on Ubuntu 20.04- Here-s What You Need to do.md b/published/202005/20200511 Can-t Install Deb File on Ubuntu 20.04- Here-s What You Need to do.md new file mode 100644 index 0000000000..bc6bc1aec8 --- /dev/null +++ b/published/202005/20200511 Can-t Install Deb File on Ubuntu 20.04- Here-s What You Need to do.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12220-1.html) +[#]: subject: (Can’t Install Deb File on Ubuntu 20.04? Here’s What You Need to do!) +[#]: via: (https://itsfoss.com/cant-install-deb-file-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +无法在 Ubuntu 20.04 上安装 Deb 文件?这是你需要做的! +====== + +> 双击 deb 文件后无法通过 Ubuntu 20.04 的软件中心安装?你不是唯一遇到此问题的人。本教程展示了解决方法。 + +![](https://img.linux.net.cn/data/attachment/album/202005/15/112149cfdyg556upv6vd66.jpg) + +在“[安装 Ubuntu 20.04 之后要做的事][1]”一文中,一些读者提到他们[用 Deb 文件安装软件][2]遇到了麻烦。 + +我发现这很奇怪,因为使用 deb 文件安装程序是最简单的方法之一。你要做的就是双击下载的文件,它会在软件中心中打开(默认情况下)。单击安装,它要求你输入密码,并在几秒钟/分钟内安装了该软件。 + +我[从 19.10 升级到 Ubuntu 20.04][3]直到今天都没有遇到这个问题。 + +我下载了 .deb 文件来安装 [Rocket Chat Messenger][4],然后双击该文件安装时,文件用存档管理器打开。这不是我所期望的。 + +![DEB files opened with Archive Manager instead of Software Center][5] + +“修复”很简单,我将在本教程中向你展示。 + +### 在 Ubuntu 20.04 中安装 deb 文件 + +由于某些原因,在 Ubuntu 20.04 中 deb 文件的默认打开程序被设置为存档管理器。存档管理器是用于[解压 zip][6] 和其他压缩文件。 + +解决此问题的方法非常简单。[在 Ubuntu 中更改默认应用][7],将打开 DEB 文件从“存档管理器”改到“软件安装”。让我告诉你步骤。 + +**步骤 1:**右键单击下载的 .deb 文件,然后选择**属性**: + +![][8] + +**步骤 2:**进入“**打开方式**”标签,选择“**软件安装**”,然后点击“**设置为默认**”。 + +![][9] + +这样,以后所有的 .deb 文件都将通过“软件安装”即软件中心打开。 + +双击 .deb 文件确认,看看是否在软件中心中打开。 + +### 忽视的 bug 还是愚蠢的功能? + +为什么会用存档管理器打开 deb 文件让人无法理解。我确实希望这是一个 bug,而不是像[在 Ubuntu 20.04 中不允许在桌面上拖放文件][10]这样的怪异功能。 + +既然我们在讨论 deb 文件的安装,就让我告诉你一个不错的工具 [gdebi][11]。它是一个轻量级应用,其唯一目的是安装 DEB 文件。有时它也可以处理依赖关系。 + +你可以了解更多有关[使用 gdebi 并默认设为安装 deb 文件的工具][12]。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/cant-install-deb-file-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-12183-1.html +[2]: https://itsfoss.com/install-deb-files-ubuntu/ +[3]: https://itsfoss.com/upgrade-ubuntu-version/ +[4]: https://rocket.chat/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/error-opening-deb-file.png?ssl=1 +[6]: https://itsfoss.com/unzip-linux/ +[7]: https://itsfoss.com/change-default-applications-ubuntu/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/open-deb-files.png?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/deb-file-install-fix-ubuntu.png?fit=800%2C454&ssl=1 +[10]: https://itsfoss.com/add-files-on-desktop-ubuntu/ +[11]: https://launchpad.net/gdebi +[12]: https://itsfoss.com/gdebi-default-ubuntu-software-center/ diff --git a/published/202005/20200520 How to configure your router using VTY shell.md b/published/202005/20200520 How to configure your router using VTY shell.md new file mode 100644 index 0000000000..5b2874fa82 --- /dev/null +++ b/published/202005/20200520 How to configure your router using VTY shell.md @@ -0,0 +1,188 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12268-1.html) +[#]: subject: (How to configure your router using VTY shell) +[#]: via: (https://opensource.com/article/20/5/vty-shell) +[#]: author: (M Umer https://opensource.com/users/noisybotnet) + +如何使用 VTY Shell 配置路由器 +====== + +> FRR(free range routing)给了你实现多种协议的选择。本指南将帮助你入门。 + +![](https://img.linux.net.cn/data/attachment/album/202005/31/122310xi9aag5iqihqgcxl.jpg) + +最近,我写了一篇文章,解释了如何使用 [Quagga][2] 路由套件实现开放式最短路径优先Open Shortest Path First(OSPF)。可以使用多个软件套件代替 Quagga 来实现不同的路由协议。其中一种是 FRR(free range routing)。 + +### FRR + +[FRR][3] 是一个路由软件套件,它衍生自 Quagga,并在 GNU GPL2 许可下分发。与 Quagga 一样,它为类 Unix 平台提供了所有主要路由协议的实现,例如 OSPF、路由信息协议Routing Information Protocol(RIP)、边界网关协议Border Gateway Protocol(BGP) 和中间系统到中间系统Intermediate system-to-intermediate system (IS-IS)。 + +开发了 Quagga 的一些公司,例如 Big Switch Networks、Cumulus、Open Source Routing 和 6wind,创建了 FRR 以在 Quagga 的良好基础上进行改善。 + +#### 体系结构 + +FRR 是一组守护进程,它们可以共同构建路由表。每个主协议都在其自己的守护进程中实现,并且这些守护进程与独立于协议的核心守护进程 Zebra 通信,后者提供内核路由表更新、接口查找以及不同路由协议之间路由的重新分配。每个特定协议的守护进程负责运行相关协议并根据交换的信息构建路由表。 + +![FRR architecture][4] + +### VTY shell + +[VTYSH][5] 是 FRR 路由引擎的集成 shell。它将每个守护进程中定义的所有 CLI 命令合并,并在单个 shell 中将它们呈现给用户。它提供了类似于 Cisco 的命令行模式,并且许多命令与 Cisco IOS 命令相似。CLI 有不同的模式,某些命令仅在特定模式下可用。 + +### 设置 + +在本教程中,我们将使用 FRR 配置动态路由来实现路由信息协议(RIP)。我们可以通过两种方式来做到这一点:在编辑器中编辑协议守护进程配置文件或使用 VTY Shell。在此例中,我们将使用 VTY shell。我们的设置包括两个名为 Alpha 和 Beta 的 CentOS 7.7 主机。这两台主机都有两个网络接口,并共享对 192.168.122.0/24 网络的访问。我们将广播 10.12.11.0/24 和 10.10.10.0/24 网络的路由。 + +对于主机 Alpha: + +* eth0 IP:192.168.122.100/24 +* 网关:192.168.122.1 +* eth1 IP:10.10.10.12/24 + +对于主机 Beta: + +* eth0 IP:192.168.122.50/24 +* 网关:192.168.122.1 +* eth1 IP:10.12.11.12/24 + +#### 安装软件包 + +首先,我们需要在两台主机上都安装 FRR 软件包。可以按照[官方 FRR 文档][6]中的说明进行操作。 + +#### 启用 IP 转发 + +对于路由,我们需要在两台主机上都启用 IP 转发,因为这将由 Linux 内核执行: + +``` +sysctl -w net.ipv4.conf.all.forwarding = 1 +sysctl -w net.ipv6.conf.all.forwarding = 1 +sysctl -p +``` + +#### 启用 RIPD 守护进程 + +安装后,所有配置文件将保存在 `/etc/frr` 目录中。 必须通过编辑 `/etc/frr/daemons` 文件显式启用守护进程。该文件确定启动 FRR 服务时激活哪些守护进程。要启用特定的守护进程,只需将相应的 `no` 改为 `yes`。之后的服务重启将启动守护进程。 + +![FRR daemon restart][7] + +#### 防火墙配置 + +由于 RIP 协议使用 UDP 作为传输协议,并被分配了 520 端口,因此我们需要在 `firewalld` 配置中允许该端口。 + +``` +firewall-cmd --add-port=520/udp –permanent +firewalld-cmd -reload +``` + +现在,我们可以使用以下命令启动 FRR 服务: + +``` +systemctl start frr +``` + +#### 使用 VTY 进行配置 + +现在,我们需要使用 VTY Shell 配置 RIP。 + +在主机 Alpha 上: + +``` +[root@alpha ~]# vtysh + +Hello, this is FRRouting (version 7.2RPKI). +Copyright 1996-2005 Kunihiro Ishiguro, et al. + +alpha# configure terminal +alpha(config)# router rip +alpha(config-router)# network 192.168.122.0/24 +alpha(config-router)# network 10.10.10.0/24 +alpha(config-router)# route 10.10.10.5/24 +alpha(config-router)# do write +Note: this version of vtysh never writes vtysh.conf +Building Configuration... +Configuration saved to /etc/frr/ripd.conf +Configuration saved to /etc/frr/staticd.conf +alpha(config-router)# do write memory +Note: this version of vtysh never writes vtysh.conf +Building Configuration... +Configuration saved to /etc/frr/ripd.conf +Configuration saved to /etc/frr/staticd.conf +alpha(config-router)# exit +``` + +类似地,在主机 Beta 上: + +``` +[root@beta ~]# vtysh + +Hello, this is FRRouting (version 7.2RPKI). +Copyright 1996-2005 Kunihiro Ishiguro, et al. + +beta# configure terminal +beta(config)# router rip +beta(config-router)# network 192.168.122.0/24 +beta(config-router)# network 10.12.11.0/24 +beta(config-router)# do write +Note: this version of vtysh never writes vtysh.conf +Building Configuration... +Configuration saved to /etc/frr/zebra.conf +Configuration saved to /etc/frr/ripd.conf +Configuration saved to /etc/frr/staticd.conf +beta(config-router)# do write memory +Note: this version of vtysh never writes vtysh.conf +Building Configuration... +Configuration saved to /etc/frr/zebra.conf +Configuration saved to /etc/frr/ripd.conf +Configuration saved to /etc/frr/staticd.conf +beta(config-router)# exit +``` + +完成后,像下面这样检查两台主机路由: + +``` +[root@alpha ~]# ip route show +default via 192.168.122.1 dev eth0 proto static metric 100 +10.10.10.0/24 dev eth1 proto kernel scope link src 10.10.10.12 metric 101 +10.12.11.0/24 via 192.168.122.50 dev eth0 proto 189 metric 20 +192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.100 metric 100 +``` + +我们可以看到 Alpha 上的路由表通过 `192.168.122.50` 包含了 `10.12.11.0/24` 的条目,它是通过 RIP 提供的。 + +类似地,在 Beta 上,该表通过 `192.168.122.100` 包含了 `10.10.10.0/24` 的条目。 + +``` +[root@beta ~]# ip route show +default via 192.168.122.1 dev eth0 proto static metric 100 +10.10.10.0/24 via 192.168.122.100 dev eth0 proto 189 metric 20 +10.12.11.0/24 dev eth1 proto kernel scope link src 10.12.11.12 metric 101 +192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.50 metric 100 +``` + +### 总结 + +如你所见,设置和配置相对简单。要增加复杂性,我们可以向路由器添加更多的网络接口,以为更多的网络提供路由。可以在编辑器中编辑配置文件来进行配置,但是使用 VTY Shell 在单个组合会话中为我们提供了所有 FRR 守护进程的前端。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/vty-shell + +作者:[M Umer][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/noisybotnet +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connections_wires_sysadmin_cable.png?itok=d5WqHmnJ (Multi-colored and directional network computer cables) +[2]: https://linux.cn/article-12199-1.html +[3]: https://en.wikipedia.org/wiki/FRRouting +[4]: https://opensource.com/sites/default/files/uploads/frr_architecture.png (FRR architecture) +[5]: http://docs.frrouting.org/projects/dev-guide/en/latest/vtysh.html +[6]: http://docs.frrouting.org/projects/dev-guide/en/latest/building-frr-for-centos7.html +[7]: https://opensource.com/sites/default/files/uploads/frr_daemon_restart.png (FRR daemon restart) diff --git a/published/202005/20200525 How to Properly Install and Setup KDE Plasma on Arch Linux.md b/published/202005/20200525 How to Properly Install and Setup KDE Plasma on Arch Linux.md new file mode 100644 index 0000000000..93defdb7c9 --- /dev/null +++ b/published/202005/20200525 How to Properly Install and Setup KDE Plasma on Arch Linux.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12258-1.html) +[#]: subject: (How to Properly Install and Setup KDE Plasma on Arch Linux) +[#]: via: (https://itsfoss.com/install-kde-arch-linux/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +如何在 Arch Linux 上正确安装和设置 KDE Plasma? +====== + +我相信你是按照[这份很棒的指南安装来 Arch Linux][1] 的,这篇指南最后提到了 [GNOME 桌面][2]的安装步骤。 + +但现在,不是每个人都是 GNOME 的粉丝,有几个读者要求我们向他们展示如何在 [Arch Linux][4] 上配置 [KDE 桌面][3]。 + +因此,我创建了这个指南来演示如何在 Arch Linux 上正确安装和配置 KDE 桌面(也被称为 KDE Plasma桌面)的步骤。 + +### 如何在 Arch Linux 上安装和设置 KDE 桌面环境? + +![][5] + +请记住,KDE 不允许直接以 root 身份登录。如果你已经安装了 Arch Linux 并以 root 身份使用,你应该创建一个新的用户,并给它以 root 身份运行命令的 sudo 权限。 + +如果你只是最小化安装了 Arch Linux,那么你可能是以 TTY 终端方式登录的。如果你使用的是其他桌面环境,步骤也是一样的。 + +让我们开始吧! + +#### 步骤 1:创建一个 sudo 用户(如果你只有 root 用户) + +你可以使用 [useradd 命令][6]来创建一个新用户。我创建的用户名为 `dimitrios`(这是我的名字)。你可以使用与你的名字匹配的东西。 + +选项 `-m` 为新创建的用户创建一个主目录。 + +``` +useradd -m dimitrios +``` + +你还应该为这个用户设置一个密码。使用此命令: + +``` +passwd dimitrios +``` + +现在你已经创建了用户,给它 sudo 权限。首先,安装 sudo 和一个像 [nano][8] 这样的[命令行文本编辑器][7]。 + +``` +pacman -S sudo nano +``` + +sudo 的配置文件是 `/etc/sudoers`。该文件应该使用 `visudo` 来编辑,它会锁定 `sudoers` 文件,将编辑的内容保存到一个临时文件中,并在复制到 `/etc/sudoers` 之前检查该文件的语法。 + +要使用 `nano` 作为 `visudo` 编辑器,请这样设置: + +``` +EDITOR=nano visudo +``` + +像我的示例那样添加下面这一行,然后保存并退出。 + +``` +dimitrios ALL=(ALL) ALL +``` + +![Adding Sudoer in Arch Linux][9] + +保存你的更改,然后退出编辑器。你现在在 Arch Linux 上有了一个 sudo 用户。 + +#### 步骤 2 :安装 KDE Plasma 桌面 + +要运行 KDE 桌面,你需要以下软件包。 + + * [Xorg][10] 组 + * [KDE Plasma][3] 桌面环境 + * [Wayland][11] KDE Plasma 的会话 + * [KDE 应用程序][12]组(包括 KDE 特有的应用程序:Dolphin 管理器和其他有用的应用程序)。 + +你可以用下面的命令安装上述部分。 + +``` +pacman -S xorg plasma plasma-wayland-session kde-applications +``` + +安装后,启用显示管理器和网络管理器服务。 + +``` +systemctl enable sddm.service +systemctl enable NetworkManager.service +``` + +快完成了。关闭你的系统。 + +``` +shutdown now +``` + +重新打开系统电源,你应该会看到 KDE 的登录界面。你还记得为你的 sudo 用户设置的密码吗?用它来登录。 + +![Arch KDE Plasma Desktop][13] + +#### 接下来? + +你可能会想探索一下[基本的 pacman 命令][14],了解一下 [Arch 用户资源库][15],了解一下 [AUR 助手][16]。 + +希望这篇教程对你在 Arch Linux 上安装 KDE 桌面有所帮助。如果你在安装过程中遇到任何障碍或困难,请在下面的评论中告诉我们。 + +你最喜欢的桌面环境或窗口管理器是什么?请告诉我们,别忘了在我们的社交媒体上订阅。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-kde-arch-linux/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-9170-1.html +[2]: https://www.gnome.org/ +[3]: https://kde.org/plasma-desktop +[4]: https://www.archlinux.org/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/install-kde-arch-linux.png?ssl=1 +[6]: https://linuxhandbook.com/useradd-command/ +[7]: https://itsfoss.com/command-line-text-editors-linux/ +[8]: https://www.nano-editor.org/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/adding-sudoer-arch-linux.png?ssl=1 +[10]: https://wiki.archlinux.org/index.php/Xorg +[11]: https://wiki.archlinux.org/index.php/Wayland +[12]: https://www.archlinux.org/groups/x86_64/kde-applications/ +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/Arch-Plasma-desktop.jpg?fit=800%2C450&ssl=1 +[14]: https://itsfoss.com/pacman-command/ +[15]: https://linux.cn/article-12107-1.html +[16]: https://linux.cn/article-12019-1.html diff --git a/published/202005/20200525 Now You Can Run Linux Apps in Windows (Thanks to WSL).md b/published/202005/20200525 Now You Can Run Linux Apps in Windows (Thanks to WSL).md new file mode 100644 index 0000000000..21173f87f8 --- /dev/null +++ b/published/202005/20200525 Now You Can Run Linux Apps in Windows (Thanks to WSL).md @@ -0,0 +1,105 @@ +[#]: collector: (lujun9972) +[#]: translator: (lnrCoder) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12254-1.html) +[#]: subject: (Now You Can Run Linux Apps in Windows (Thanks to WSL)) +[#]: via: (https://itsfoss.com/run-linux-apps-windows-wsl/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +现在你可以在 Windows 中运行 Linux 应用了 +====== + +![](https://img.linux.net.cn/data/attachment/album/202005/27/111439z64u19z6ct6r46kb.jpg) + +微软最近的 “[Build 2020][1]” 开发者大会公布了一些有趣的公告。我不确定这该令人兴奋还是该令人怀疑 —— 但是微软,你现在比以往任何时候都受到我们的关注。 + +同时,在所有的这些公告中,能够在 WSL(Windows Subsystem for Linux)上运行 GUI 应用程序的功能备受关注。 + +更不要忘了 [Xamrin.Forms 更名为 MAUI 的尴尬结局][2],它与 [Nitrux Linux][4] 的 Uri Herrera 的现有开源项目([Maui Project][3])名字冲突。 + +以防你不清楚,WSL 是一种环境,可让你在 Windows 10 中获得 Linux 控制台的体验。它也是在 [Windows 中运行 Linux 命令的最佳方法][5]之一。 + +正如 [Liam Dawe][7] 认为的那样,通过博客文章([DirectX ❤ Linux][6])发布的公告可能是只是个公关诱饵。但是,仍然值得一提。 + +### WSL 上对 Linux GUI 应用程序的支持 + +![][8] + +最近,Microsoft 在在线开发者大会上宣布了 WSL(即 WSL 2)的一系列新功能。 + +[Windows 包管理器][9]、[Windows 终端 1.0][10],以及其他一些功能的引入是其亮点。 + +但是, WSL 2 对 GPU 硬件加速的支持非常重要。 + +那么,是否意味着你可以使用 WSL 在 Windows 上运行 Linux 应用程序呢?看起来像是。 + +微软计划通过使用全新的 Linux 内核驱动程序 `dxgkrnl` 来实现它。为了给你一个技术性的简报, 我在这里引用他们的公告中的描述: + +![Linux Kernel Driver Wsl][11] + +> dxgkrnl 是一个全新的 Linux 内核驱动程序,它将 `/dev/dxg` 设备提供给用户模式的 Linux。 `/dev/dxg` 提供了一组 IOCTL,它们与 Winodws 上的原生 WDDM D3DKMT 内核服务层非常相似。Linux 内核中的 dxgkrnl 通过 VM 总线连接到 Windows 主机上,并使用此 VM 总线连接与物理 GPU 进行通讯。 + +我不是这方面的专家,但这意味着 WSL 上的 Linux 应用程序将与原生的 Windows 应用程序一样可以访问 GPU。 + +针对 GUI 应用程序的支持将在今年秋季的晚些时候提供(而不是 2020 年 5 月的更新) —— 所以我们要看看什么时候提供。 + +微软专门针对的是那些希望在 Windows 上轻松使用 Linux IDE 的开发人员。谷歌也在瞄准同样的用户群,[将 GUI Linux 应用程序引入到 Chromebook][12]。 + +那么,对于那些坚持使用 Windows 的用户来说,这是个好消息。但是,这是真的吗? + +### 微软爱上了 Linux —— 真的吗? + +![Microsoft Loves Linux][13] + +他们在 Windows 上整合 Linux 环境来拥抱 Linux 及其优势的努力,绝对是一件好事。 + +但是,它真的能给**桌面 Linux 用户**带来什么好处呢?到目前为止,我还没有看到任何实际的好处。 + +在这里,你可以有不同的看法。但是,我认为 WSL 的开发对于 Linux 桌面用户来说没有真正的价值。至少,到目前为止没有。 + +有趣的是,[Linux Unplugged podcast][14] 上有人强调了微软的举动,认为这与他们的 EEE(拥抱、延伸和扑灭Embrace, extend, and extinguish)的思路是一致的。 + +可能吧,谁知道呢?当然,他们为实现这一目标而付出的努力值得赞赏 —— 同时又令人感到兴奋和神秘。 + +### 这是否以为着 Windows 用户将不必再转到 Linux? + +微软之所以在其平台上集成 Linux,是因为他们知道 Liunx 的能力,也知道开发人员(或用户)喜欢使用它的原因。 + +但是,随着 WSL 2 的更新,如果这种情况持续下去,我倾向于同意 Abhishek 的看法: + +> 最终,桌面 Linux 将被限制在 Windows 下,成为桌面应用程序…… + +好吧,当然,原生的体验暂时还是比较好的。而且,很难看到现有的 Linux 桌面用户会使用 Windows 来将其替代。但是,这仍然值得担心。 + +你如何看待这一切?我不认为 WSL 对于被迫使用 Windows 的用户有什么好处 —— 但是,从长远来看,你认为微软在 WSL 方面的进展本质上是敌意还是对 Linux 有帮助? + +在评论中让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/run-linux-apps-windows-wsl/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[lnrCoder](https://github.com/lnrCoder) +校对:[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://news.microsoft.com/build2020/ +[2]: https://itsfoss.com/microsoft-maui-kde-row/ +[3]: https://mauikit.org/ +[4]: https://itsfoss.com/nitrux-linux/ +[5]: https://itsfoss.com/run-linux-commands-in-windows/ +[6]: https://devblogs.microsoft.com/directx/directx-heart-linux/ +[7]: https://www.gamingonlinux.com/2020/05/microsoft-build-directx-and-linux-plus-more +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/Linux-GUI-app-Windows-WSL.png?ssl=1 +[9]: https://devblogs.microsoft.com/commandline/windows-package-manager-preview/ +[10]: https://devblogs.microsoft.com/commandline/windows-terminal-1-0/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/linux-kernel-driver-wsl.png?ssl=1 +[12]: https://itsfoss.com/linux-apps-chromebook/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/microsoft-loves-linux.jpg?ssl=1 +[14]: https://linuxunplugged.com/354 diff --git a/published/202005/20200526 How to write about open source software.md b/published/202005/20200526 How to write about open source software.md new file mode 100644 index 0000000000..fb883d8e59 --- /dev/null +++ b/published/202005/20200526 How to write about open source software.md @@ -0,0 +1,175 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12267-1.html) +[#]: subject: (How to write about open source software) +[#]: via: (https://opensource.com/article/20/5/write-about-open-source-software) +[#]: author: (Dawn Parzych https://opensource.com/users/dawnparzych) + +如何为开源软件写作文章 +====== + +> 通过以下提示,成为一个更好的作者。 + +![](https://img.linux.net.cn/data/attachment/album/202005/31/115044ecfpxc2q9z0ca8wq.jpg) + +开始接触开源社区的一个方法就是写关于它的文章。你可以贡献技术文档,分享你如何使用软件,或者为我们社区写一篇文章。但是开始写作说起来容易做起来难。我听到的最常见的两个不写文章的借口是:“我没有什么新东西可写”和“我不是一个好的作者”。我在这里是为了打破这两个误区。 + +### 你应该写什么? + +> “寻找那些经常被遗漏的故事。” +> 埃里克·拉尔森 + +对于某些人来说,写作的最大障碍是找到要写的想法或话题。很容易就落入了这样的思维陷阱:“这个话题已经写过了,何必再麻烦。” + +我不是第一个写文章的人,也不会是最后一个。我带来的是我独特的视角和这些年来所学到的东西。曾经有人向我请教过一些关于写作入门的建议,或者是如何让自己的写作更上一层楼。我决定把这些建议变成一篇文章。 + +文如其人,没有人会以你的方式来述事,你的经验和观点可能正是别人所需要的。 + +这里有一些提示,可以帮助你想出一个主题: + +* 你最近学到了什么东西?写出你是如何学习的,你学到了什么,或使你感到惊讶的事情。 +* 你经常被问到的问题是什么?把答案写出来。 +* 你最近是否在搜索一篇怎么做的文章,但在搜索结果中,你对排名靠前的文章不满意?请写出你要找的文章。 +* 你是否参加过会议或研讨会?写一篇会后总结来说明你所学到的东西。 +* 你开始使用新工具了吗?写一份操作指南或入门指南。 + +### 你写的是什么类型的文章? + +有不同类型的文章,包括: + +* 技术文档 +* 操作指南 +* 博客 +* 白皮书或电子书 +* 回顾性的文章 + +内容的类型会影响你的写作风格和语气。博客更加非正式和是对话式的。而技术文档更正式,更具有指导性。 + +### 你是为谁而写的? + +每一篇文章都应该有一个单一的受众。受众是指你为之写作的对象是什么类型的人。在你开始写作之前,写下你的读者的一些特征是有助于写作的。重要的是要考虑到你要为谁写,以及你**不是为**谁写的 —— 确定你的目标受众将决定要包括哪些内容和不包括哪些内容。 + +例如,我在写这篇文章的时候,我设想的目标受众是这样的: + +* 有基本的写作和语法知识 +* 有兴趣提高写作能力 +* 在技术领域担任开发人员、销售工程师、客户经理或类似职位的工作 +* 不是经验丰富或资深的作者,可能在个人或工作博客上发表过几篇文章,想写更多的文章。 +* 非虚构写作 + +如果你有针对多个受众的内容,可以考虑针对不同的受众将其分解成不同的内容。对你的受众要考虑的一些方面: + +* 专业水平:新手、中级、高级 +* 作用:管理人员、个人贡献者 +* 目标:他们为什么要阅读这些? + +### 言语很重要 + +你选择的言语会对读者产生影响。晦涩难懂的词汇会使文章更难理解,不常见的词汇会让读者觉得自己很笨,某些词汇可能会不小心冒犯读者。作为一个作者,你的目标是避免所有这些。下面是怎么做的: + +#### 使用日常用语 + +不要把写作作为炫耀你的词汇量或你从“每日一字”台历上学到的单词的方式。写作是为了让读者能够理解。每一篇文章都有相关的阅读水平。如果你写的是技术文档,那么你的目标大约是初中的阅读水平。这并不意味着你的受众只有初中的教育水平。它意味着你的写作会更容易被人理解。你想让人们对这些言语过目不忘,还是想让他们觉得自己学到了什么?虽然你可以使用长而复杂的词汇,但并不意味着你应该这样做。使用简单的语言不一定意味着你的文章会很无聊。 + +使用 [Hemingway 应用][2]等工具来检查你的作品的可读性(它不是开源的,但很优秀)。比如说,在初稿之后,这篇文章被评定为五年级的阅读水平。Hemingway 还提供了如何改进写作的建议 —— 找出难以理解的句子或需要改变选词的地方。 + +如果你想要找出替代的词汇,可以查看 [Plain English Campaign][3] 的建议或 [Power Thesaurus][4] 的众包建议。 + +#### 知道应该规避哪些词 + +> “每次你想写‘非常’的时候,就用‘该死的’代替;你的编辑会把它删掉,而作品就会如它应有的那样。” +> 马克·吐温 + +在写教程或指南的时候,这里有一些要避免的词,包括“简单simple”、“容易easy”和“就这样just”。你是你所写的主题的专家,经过多年的实践,可能会觉得事情很简单。而初学者可能会觉得事情不“简单”,也不“容易”。你的读者可能会感到沮丧,因为他们觉得过程或解释并不简单。 + +你是否曾经因为无法理解作者的意思而不得不反复重读一个句子或段落?你有没有因为一篇文章对你来说没有意义而放弃过?我有过。 + +作为一个作者,你希望你的读者感到困惑或不理解吗?我希望不会。 + +在你的写作中要避免的其它词语: + +* 这件事That +* 真的Really +* 非常Very +* 所以So +* 为了In order to + +一般来说,这些词可以在不改变句子意思的情况下删除。 + +在我写完之后,我会在文档中搜索这些词。当我在这篇文章中搜索时,我发现了以下这句话: + +> “这并不意味着你的受众只有初中的教育水平*这件事*,而意味着你的写作会更容易被理解*这件事*。” + +这句话中出现了两个“这件事That”的例子。它们并没有给句子增加价值。它们可以被删除而不改变其含义。删除这些词汇可以缩短句子,并且更短的句子更容易理解。而说到短句,我还把它改写成了两句话。 + +> “这并不意味着你的受众只有初中的教育水平。它意味着你的写作会更容易被人理解。” + +#### 使用包容性语言 + +词语和短语的历史背景可能会导致人们感到被排斥或冒犯。在写作时,你要让读者感到被包容。当你使用包容性的语言时,会让读者感到被理解、被尊重,感觉被包容。我参考了 Buffer 中的这篇[关于使用包容性语言的指南][5]。 + +### 修订和编辑 + +> “几乎所有好的写作都是从糟糕的第一次努力开始的。你需要从某个地方开始。” +> 安妮·拉莫特 + +写作是一个迭代的过程。如果你认为作者们坐在办公桌前,在一个小时内就能完成一篇文章准备发表,那么请你再想一想。有些文章需要我花几个星期的时间来完成。以下是我的标准流程: + +* 写一个粗略的初稿。我说的粗略,我的意思是*粗陋*。写的时候不用担心语法问题。目的是让文字从我的脑海中浮现出来,写在纸上。这一步可能需要一个小时到几周的时间。 +* 将草稿放一段时间。这可能需要几个小时到几天的时间,这取决于出版时间线。 +* 审阅草稿。进行调整和编辑。 +* 征求反馈意见,可以是同事或朋友的反馈意见。在这个阶段的反馈中,我的重点是明确性。是否有意义?是否有什么令人困惑的地方?有什么缺失的部分? +* 纳入反馈意见。无论你的写作经验有多丰富,让其他作者审阅你的作品,都会让你的作品变得更好。 + +在这个阶段,我有了一个相当扎实的草稿。现在到了我最不喜欢的写作部分 —— 编辑。我之前提到的 Hemingway 应用不仅能告诉你阅读水平,还能提供改进写作的建议。我还使用 Grammarly 来帮助编辑语法。关于 Grammarly 的开源替代工具,请查看[语言工具网站][6]或这篇文章中的[开源写作工具][7]。 + +我的写作挑战之一就是适当地使用逗号。Grammarly 可以帮助我找出我缺失或滥用逗号的地方。Grammarly 发现了 43 个这篇文章的最终草稿的正确性问题。其中大部分是逗号错误。 + +![Errors identified by Grammarly][8] + +除了语法错误之外,该应用程序还提供了一些建议,以帮助提高清晰度、参与度和表达能力(其中一些功能可能在免费版中没有)。这包括单词选择和使用主动语气与被动语气等。有些建议我接受,有些则拒绝。在审查了所有的警报和建议后,Grammarly 会在各个方面进行反馈。 + +![Grammarly results][10] + +不要害怕寻求写作上的帮助。每一个好的作者背后都有一个好的编辑或好的编辑应用。 + +### 文体指南 + +文体指南为改善书面交流提供了标准。它们包括标点符号、语法和用词等方面。如果是为你的公司撰写文档,请检查一下公司是否有文体指南。如果没有文体指南,或者你是为自己写的,下面是一些常用的文体指南: + +* [芝加哥文体手册][11] +* [谷歌开发者文档指南][12] +* [微软写作文体指南][13] +* [美联社文体手册][14] + +写作是一种与社区分享自己的思想和知识的方式。开始写作的唯一方法就是开始打字。用这些建议来微调你的写作。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/write-about-open-source-software + +作者:[Dawn Parzych][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dawnparzych +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/doc-dish-lead.png?itok=h3fCkVmU (Typewriter in the grass) +[2]: http://www.hemingwayapp.com/ +[3]: http://www.plainenglish.co.uk/the-a-z-of-alternative-words.html +[4]: https://www.powerthesaurus.org/ +[5]: https://open.buffer.com/inclusive-language-tech/ +[6]: https://languagetool.org/ +[7]: https://opensource.com/article/20/3/open-source-writing-tools +[8]: https://opensource.com/sites/default/files/uploads/grammarlyerrors.png (Errors identified by Grammarly) +[9]: https://creativecommons.org/licenses/by-sa/4.0/ +[10]: https://opensource.com/sites/default/files/uploads/grammarlyresults.png (Grammarly results) +[11]: https://www.chicagomanualofstyle.org/home.html +[12]: https://developers.google.com/style +[13]: https://docs.microsoft.com/en-us/style-guide/welcome/ +[14]: https://www.apstylebook.com/ diff --git a/published/20200519 24 Linux desktops you need to try.md b/published/20200519 24 Linux desktops you need to try.md new file mode 100644 index 0000000000..f96ba38567 --- /dev/null +++ b/published/20200519 24 Linux desktops you need to try.md @@ -0,0 +1,123 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12487-1.html) +[#]: subject: (24 Linux desktops you need to try) +[#]: via: (https://opensource.com/article/20/5/linux-desktops) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +24 个值得尝试的 Linux 桌面环境 +====== + +> 我全要! + +![](https://img.linux.net.cn/data/attachment/album/202008/04/222604tj9mpc66zyzxppbx.jpg) + +Linux 桌面的最大优点之一是它提供给用户选择的权利。如果你不喜欢你屏幕左下角的应用程序菜单,你可以移除它。如果你不喜欢你的文件管理器组织文件的方式,你可以使用另外一个文件管理器。不过,不可否认的是,这对那些不习惯自己选择如何使用计算机的用户来说可能会感到困惑。如果你正在考虑安装 Linux,你要做的选择之一就是你想使用哪一个桌面,最好的方法就是尝试几个不同的桌面,直到你找到感觉适合你的桌面。 + +### 默认桌面 + +![][2] + +作为在 Fedora、Ubuntu、Debian 和一些其它操作系统上的默认桌面,GNOME 桌面可能是最流行的 Linux 桌面。它有一个易于使用和现代化的界面,并带有为手机环境设计的小点缀,因此即使在触摸屏上也感觉很自然。 + +不过,一些 Linux 发行版选择了不同的桌面环境,如 KDE Plasma、Pantheon、Cinnamon 和 Mate。 + + * [GNOME][3]: 现代化和易于使用,默认桌面 + * [Mate][4]: 传统的 GNOME + * [KDE][5]: 功能强大、可配置的 Plasma 桌面 + * [Cinnamon][6]: 经典的 GNOME + * [Pantheon][7]: [ElementaryOS][8] 的默认桌面 + * [Budgie][9]: 一个柔和的桌面 + * [Trinity][10]: 传统的 KDE + +### 传统的 Unix + +![运行在 Fedora 上的 Window Maker][11] + +Unix 是现代操作系统的鼻祖,也是 Linux 的直接灵感来源,拥有令人吃惊的丰富的桌面历史。大多数人都不熟悉 Unix 桌面设计,因为 Unix 计算机被认为是学术界、科学界和电影界常见的专业机器,而不是家用计算机。如果你是一名 Unix、IRIX 或 NeXT 的用户,那么你可能会对类似于 [CDE][12] 或 NeXTStep 的桌面有着美好的回忆。你很幸运,因为这一传统延续至今: + + * [Windowmaker][13]: NeXT 界面的复兴 + * [Enlightenment][14]: 一个现代化的改进型 Windowmaker 风格的桌面 + * [Fluxbox][15]: 跳出 Blackbox 思维定式 + * [Openbox][16]: 改善 Blackbox 的可用性 + * [TWM][17]: 与 X11 绑定至死的示例桌面 + * [Fvwm][18]: 改进的 TWM + +### 轻量级桌面 + +![XFCE in 2019 年 在 Mageia Linux 上的][19] + +你可能想知道为什么 Linux 有那么多的桌面可供选择。你可以把它归结为个人喜好和对效率低下的低容忍度,但优化用户界面也有技术上的好处。例如,老电脑难以跟上用户界面的更新,可以使用轻量级桌面[赋予它新的生命]() 。另外,你可能只是想把 CPU 处理能力分配到除桌面以外的其它东西上,所以保持你的主用户界面极简是有意义的。不管你的动机是什么,这里有一些你可以尝试的桌面: + + * [XFCE][20]: 熟悉的桌面,极少的性能损失 + * [LXQT 和 LXDE][21]: 熟悉的桌面,较少的性能损失 + * [PekWM][22]: 一个 Blackbox 式的窗口管理器 + * [Joe's Window Manager][23]: 另一个 Blackbox 式的窗口管理器 + * [Ratpoison][24]: 不使用鼠标 + * [Herbstluftwm][25]: 针对 [Vim 用户][26] 的Ratpoison + * [Lumina][27]: 一个为 PC-BSD 开发的桌面 + +### 实验性桌面 + +![Unix 桌面环境][28] + +当创建一个桌面并将其集成到一个系统中相对容易的时候,会发生的事情之一就是你会得到一些有趣的概念验证项目和试验性项目。有一些会比其它的更精致,有一些则不是很容易安装。这些很可能注定不会成为你的永久桌面,但是它们可以是很有趣的体验: + + * [Unix Desktop Environment][29]: 该桌面的重塑版 + * [Rox][30]: 在它那个时代是先进和现代的桌面 + * [MLVWM][31]: 要是 Apple IIe 运行 Unix 怎么样? + * [Equinox][32]: 只是个最基础的东西 + +### 选择你的桌面 + +如果太多的选择让你不知所措,那么记住:桌面意味着 *可选*。你没有义务来尝试发行版附带的多个桌面。 + +许多 Linux 的高级用户都会满足于他们的发行版所提供的某个桌面。最重要的是得到一个可以与你的计算机一起工作的 Linux 系统系统,并花费时间来学习它是如何工作的。归根结底,所有的桌面都只是为了做同一件事:帮助你组织和管理你的重要数据。让你了解你的桌面是如何工作的,这才是最重要的。但是如果你已经了解了你的默认桌面的各个方面,那你现在有了可以在周末尝试的大量选择。祝你玩得开心! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/linux-desktops + +作者:[Seth Kenlon][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://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguins.png?itok=yKOpaJM_ (Penguins) +[2]: https://opensource.com/sites/default/files/advent-gnome.jpg +[3]: https://linux.cn/article-11675-1.html +[4]: https://linux.cn/article-11703-1.html +[5]: https://linux.cn/article-11728-1.html +[6]: https://linux.cn/article-8606-1.html +[7]: https://linux.cn/article-11660-1.html +[8]: https://elementary.io/ +[9]: https://linux.cn/article-10547-1.html +[10]: https://opensource.com/article/19/12/linux-trinity-desktop-environment-tde +[11]: https://opensource.com/sites/default/files/uploads/advent-windowmaker.jpg (Window Maker running on Fedora) +[12]: https://sourceforge.net/projects/cdesktopenv/ +[13]: https://linux.cn/article-11650-1.html +[14]: https://opensource.com/article/19/12/linux-enlightenment-desktop +[15]: https://linux.cn/article-12082-1.html +[16]: https://linux.cn/article-11698-1.html +[17]: https://linux.cn/article-11734-1.html +[18]: https://linux.cn/article-11712-1.html +[19]: https://opensource.com/sites/default/files/advent-xfce.jpg (XFCE on Mageia Linux in 2019) +[20]: https://linux.cn/article-10413-1.html +[21]: https://opensource.com/article/19/12/lxqt-lxde-linux-desktop +[22]: https://linux.cn/article-11670-1.html +[23]: https://opensource.com/article/19/12/joes-window-manager-linux-desktop +[24]: https://opensource.com/article/19/12/ratpoison-linux-desktop +[25]: https://linux.cn/article-11734-1.html +[26]: https://opensource.com/resources/what-vim +[27]: https://linux.cn/article-11706-1.html +[28]: https://opensource.com/sites/default/files/uploads/advent-ude.jpg (Unix Desktop Environment) +[29]: https://opensource.com/article/19/12/linux-unix-desktop-environment-ude +[30]: https://linux.cn/article-12123-1.html +[31]: https://linux.cn/article-11720-1.html +[32]: https://opensource.com/article/19/12/ede-linux-desktop diff --git a/published/20200521 Easy DNS configuration with PowerDNS for nameservers.md b/published/20200521 Easy DNS configuration with PowerDNS for nameservers.md new file mode 100644 index 0000000000..0a0f7aa7ae --- /dev/null +++ b/published/20200521 Easy DNS configuration with PowerDNS for nameservers.md @@ -0,0 +1,88 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12496-1.html) +[#]: subject: (Easy DNS configuration with PowerDNS for nameservers) +[#]: via: (https://opensource.com/article/20/5/powerdns) +[#]: author: (Jonathan Garrido https://opensource.com/users/jgarrido) + +使用 PowerDNS 轻松配置 DNS 名称服务器 +====== + +> 使用 PDNS 为你的项目提供稳定可靠的域名系统(DNS)服务器。 + +![](https://img.linux.net.cn/data/attachment/album/202008/07/202953copoqjmkefkdf3j4.jpg) + +几个月前,我们接到了一个要求,为一个新项目提供一个稳定可靠的域名系统([DNS][2])服务器。该项目使用容器进行自动部署,每个新环境都会生成唯一的随机 URL。在对可能的方案进行了大量研究之后,我们决定尝试一下 [PowerDNS][3](PDNS)。 + +一开始,我们发现 PowerDNS 在所有主流 Linux 发行版中都得到了支持,它采用 GPL 许可,且仓库保持更新。我们还在官方网站上发现了整洁、组织良好的[文档][4],以及大量来自真正喜欢和使用该产品的人在网络上的使用方法。看了一些并学习了一些基本命令之后,安装了 PDNS,启动并运行,我们的旅程开始了。 + +### 数据库驱动 + +PowerDNS 将记录保存在 SQL 数据库中。这对我们来说是新变化,不必使用文本文件来保存记录是一个不错的更改。我们选择 MariaDB 作为首选的强大工具,由于有大量的正确地设置来安装名称服务器的信息,我们可以完美地设置和加固我们的数据库。 + +### 简单配置 + +其次使我们感兴趣的是 PDNS 的所有功能都在配置文件中。`pdns.conf` 有许多选项,你可以通过添加或删除 `#` 号来启用或禁用这些选项。这真是太神奇了,因为它使我们有机会将这项新的服务集成到我们现有的基础架构中,并且只有我们想要的功能,不多也不少。一个简单的例子: + +谁可以访问你的网络服务器? + +``` +webserver-allow-from=172.10.0.1,172.10.1.2 +``` + +我可以转发基于域的请求吗?当然! + +``` +forward-zones=mylocal.io=127.0.0.1:5300 +forward-zones+=example.com=172.10.0.5:53 +forward-zones+=lucky.tech=172.10.1.5:53 +``` + +### 包含 API + +我们可以使用配置文件进行激活 API 服务,解决了我们开发团队的第一个需求,让我们见识到了 PDNS 的强大。这个功能让我们通过发送请求,简单、干净地创建、修改或删除 DNS 服务器中的记录。 + +这个 API 有一些基本的安全性参数,因此,只需几步,你就可以基于 IP 地址和预共享密钥验证的组合来控制谁有权与名称服务器进行交互。这是配置文件的样子: + +``` +api=yes +api-key=lkjdsfpoiernf +webserver-allow-from=172.10.7.13,172.10.7.5 +``` + +### 日志 + +在日志方面,PDNS 做得非常出色。你可以使用日志文件和一个简单的内置 Web 服务器来监控服务器并查看计算机的运行状况。你可以使用浏览器查看服务器不同类型的统计信息,例如 CPU 使用率和收到的 DNS 查询。这非常有价值。例如,我们能够检测到一些“不太健康”的 PC,它们正在向我们的服务器发送与恶意流量相关的站点的 DNS 请求。深入查看日志后,我们可以看到流量来自何处,并对这些 PC 进行清理操作。 + +### 其他功能 + +这只是你使用 PowerDNS 可以做的所有事情的一点点。它还有更多的功能。它是一个拥有很多功能和特性的完整名称服务器,因此值得一试。 + +目前,我们尚未部署 [DNSSEC][5],但似乎只需点击一下即可将其快速投入生产环境。另外,在将递归服务与名称服务器分离时,PowerDNS 有个不错的方法。我了解到它还支持 [DNS RPZ][6](响应策略区域),并且还提供了非常不错且设计良好的前端,可让你使用 Web 浏览器来管理服务器,如下图。 + +![PowerDNS frontend][7] + +信不信由你,你只需花费几个小时了解 PDNS,就可以大大提高你对 DNS 和 IT 操作的了解。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/powerdns + +作者:[Jonathan Garrido][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jgarrido +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_space_graphic_cosmic.png?itok=wu493YbB (Computer laptop in space) +[2]: https://en.wikipedia.org/wiki/Domain_Name_System +[3]: https://www.powerdns.com/opensource.html +[4]: https://doc.powerdns.com/ +[5]: https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions +[6]: https://dnsrpz.info/ +[7]: https://opensource.com/sites/default/files/uploads/pdns.jpg (PowerDNS frontend) diff --git a/published/202006/20190218 Talk, then code.md b/published/202006/20190218 Talk, then code.md new file mode 100644 index 0000000000..5e4c56af1d --- /dev/null +++ b/published/202006/20190218 Talk, then code.md @@ -0,0 +1,55 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12319-1.html) +[#]: subject: (Talk, then code) +[#]: via: (https://dave.cheney.net/2019/02/18/talk-then-code) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +给开源项目贡献代码时:先讨论,再编码 +====== + +我所参与的开源项目遵循的是一种这样的理念,我把它描述为 “先讨论,再编码”。我认为一般来说这是开发软件的好方法,我想花一点时间来谈谈这种方法的好处。 + +### 避免伤害感情 + +先讨论你想做的改变最重要的原因是避免伤害感情。我经常看到一个贡献者闭门造车地提交了一个 PR,却发现他的努力工作被拒绝了。这可能有一堆原因:PR 太大了,PR 没有遵循本地风格,PR 修复了一个对项目不重要的问题或者最近间接修复了的问题,等等。 + +这些问题的根本原因都是缺乏沟通。“先讨论,再编码” 理念的目标不是阻碍你或给你带来挫折,而是确保一个功能第一次就能正确落地,而不至于产生大量的维护债务。无论是改动的作者,还是审查者,当一个改动突然出现时,并暗示说 “好吧,我已经做完了,你要做的就是合并它,对吧?”,先讨论可以让他们不必背负伤害感情的情绪负担。 + +### 讨论应该如何进行? + +每一个新功能或错误修复都应该在工作开始前与项目的维护者讨论。私下试验是可以的,但不要在没有讨论之前就发送修改。 + +对于简单的改动,“讨论” 的定义可以只是 GitHub 议题中的一个设计草图。如果你的 PR 修复了一个 bug,你应该链接到它修复的 bug。如果没有,你应该先提出一个 bug,等待维护者确认后再发送 PR。这可能看起来有点落后 —— 谁不希望一个 bug 被修复呢 —— 但考虑到这个 bug 可能是对软件工作方式的误解,也可能是一个更大问题的症状,这需要进一步调查。 + +对于比较复杂的改动,尤其是功能请求,我建议在发送代码之前,先分发一份设计文档并达成一致。这不一定是一个完整的文档,发一个议题,带个草图可能就足够了,但关键是在用代码搞定之前,先用文字达成一致。 + +在任何情况下,你都不应该继续发送你的代码,直到维护者同意你的方法是他们所满意的。拉取请求是日常生活,而不仅仅是为了赶着过节。 + +### 代码审查,而不是由委员会设计 + +代码审查不是争论设计的地方。这有两个原因。首先,大多数代码审查工具都不适合长长的评论会话,GitHub 的 PR 界面在这方面非常糟糕,Gerrit 比较好,但很少有管理员团队会维护 Gerrit 实例。更重要的是,在代码审查阶段就出现了分歧,说明大家对如何实现这个变化并没有达成一致。 + +* * * + +讨论你想写的代码,然后再写你所讨论的代码。请不要反其道而行之。 + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2019/02/18/talk-then-code + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://dave.cheney.net/2013/09/07/how-to-include-c-code-in-your-go-package (How to include C code in your Go package) +[2]: https://dave.cheney.net/2015/11/05/lets-talk-about-logging (Let’s talk about logging) +[3]: https://dave.cheney.net/2016/04/11/the-value-of-tdd (The value of TDD) +[4]: https://dave.cheney.net/2016/03/12/suggestions-for-contributing-to-an-open-source-project (Suggestions for contributing to an Open Source project) diff --git a/published/202006/20190510 Learn to change history with git rebase.md b/published/202006/20190510 Learn to change history with git rebase.md new file mode 100644 index 0000000000..339e4ef696 --- /dev/null +++ b/published/202006/20190510 Learn to change history with git rebase.md @@ -0,0 +1,605 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12271-1.html) +[#]: subject: (Learn to change history with git rebase!) +[#]: via: (https://git-rebase.io/) +[#]: author: (git-rebase https://git-rebase.io/) + +学习用 Git 变基来改变历史! +====== + +[Git][1] 核心的附加价值之一就是编辑历史记录的能力。与将历史记录视为神圣的记录的版本控制系统不同,在 Git 中,我们可以修改历史记录以适应我们的需要。这为我们提供了很多强大的工具,让我们可以像使用重构来维护良好的软件设计实践一样,编织良好的提交历史。这些工具对于新手甚至是有经验的 Git 用户来说可能会有些令人生畏,但本指南将帮助我们揭开强大的 git-rebase 的神秘面纱。 + +> 值得注意的是:一般建议不要修改公共分支、共享分支或稳定分支的历史记录。编辑特性分支和个人分支的历史记录是可以的,编辑还没有推送的提交也是可以的。在编辑完提交后,可以使用 `git push -f` 来强制推送你的修改到个人分支或特性分支。 + +尽管有这么可怕的警告,但值得一提的是,本指南中提到的一切都是非破坏性操作。实际上,在 Git 中永久丢失数据是相当困难的。本指南结尾介绍了在犯错误时进行纠正的方法。 + +### 设置沙盒 + +我们不想破坏你的任何实际的版本库,所以在整个指南中,我们将使用一个沙盒版本库。运行这些命令来开始工作。[^1] + +``` +git init /tmp/rebase-sandbox +cd /tmp/rebase-sandbox +git commit --allow-empty -m"Initial commit" +``` + +如果你遇到麻烦,只需运行 `rm -rf /tmp/rebase-sandbox`,并重新运行这些步骤即可重新开始。本指南的每一步都可以在新的沙箱上运行,所以没有必要重做每个任务。 + +### 修正最近的提交 + +让我们从简单的事情开始:修复你最近的提交。让我们向沙盒中添加一个文件,并犯个错误。 + +``` +echo "Hello wrold!" >greeting.txt +git add greeting.txt +git commit -m"Add greeting.txt" +``` + +修复这个错误是非常容易的。我们只需要编辑文件,然后用 `--amend` 提交就可以了,就像这样: + +``` +echo "Hello world!" >greeting.txt +git commit -a --amend +``` + +指定 `-a` 会自动将所有 Git 已经知道的文件进行暂存(例如 Git 添加的),而 `--amend` 会将更改的内容压扁到最近的提交中。保存并退出你的编辑器(如果需要,你现在可以修改提交信息)。你可以通过运行 `git show` 看到修复的提交。 + +``` +commit f5f19fbf6d35b2db37dcac3a55289ff9602e4d00 (HEAD -> master) +Author: Drew DeVault +Date: Sun Apr 28 11:09:47 2019 -0400 + + Add greeting.txt + +diff --git a/greeting.txt b/greeting.txt +new file mode 100644 +index 0000000..cd08755 +--- /dev/null ++++ b/greeting.txt +@@ -0,0 +1 @@ ++Hello world! +``` + +### 修复较旧的提交 + +`--amend` 仅适用于最近的提交。如果你需要修正一个较旧的提交会怎么样?让我们从相应地设置沙盒开始: + +``` +echo "Hello!" >greeting.txt +git add greeting.txt +git commit -m"Add greeting.txt" + +echo "Goodbye world!" >farewell.txt +git add farewell.txt +git commit -m"Add farewell.txt" +``` + +看起来 `greeting.txt ` 像是丢失了 `"world"`。让我们正常地写个提交来解决这个问题: + +``` +echo "Hello world!" >greeting.txt +git commit -a -m"fixup greeting.txt" +``` + +现在文件看起来正确,但是我们的历史记录可以更好一点 —— 让我们使用新的提交来“修复”(`fixup`)最后一个提交。为此,我们需要引入一个新工具:交互式变基。我们将以这种方式编辑最后三个提交,因此我们将运行 `git rebase -i HEAD~3`(`-i` 代表交互式)。这样会打开文本编辑器,如下所示: + +``` +pick 8d3fc77 Add greeting.txt +pick 2a73a77 Add farewell.txt +pick 0b9d0bb fixup greeting.txt + +# Rebase f5f19fb..0b9d0bb onto f5f19fb (3 commands) +# +# Commands: +# p, pick = use commit +# f, fixup = like "squash", but discard this commit's log message +``` + +这是变基计划,通过编辑此文件,你可以指导 Git 如何编辑历史记录。我已经将该摘要削减为仅与变基计划这一部分相关的细节,但是你可以在文本编辑器中浏览完整的摘要。 + +当我们保存并关闭编辑器时,Git 将从其历史记录中删除所有这些提交,然后一次执行一行。默认情况下,它将选取(`pick`)每个提交,将其从堆中召唤出来并添加到分支中。如果我们对此文件根本没有做任何编辑,则将直接回到起点,按原样选取每个提交。现在,我们将使用我最喜欢的功能之一:修复(`fixup`)。编辑第三行,将操作从 `pick` 更改为 `fixup`,并将其立即移至我们要“修复”的提交之后: + +``` +pick 8d3fc77 Add greeting.txt +fixup 0b9d0bb fixup greeting.txt +pick 2a73a77 Add farewell.txt +``` + +> **技巧**:我们也可以只用 `f` 来缩写它,以加快下次的速度。 + +保存并退出编辑器,Git 将运行这些命令。我们可以检查日志以验证结果: + +``` +$ git log -2 --oneline +fcff6ae (HEAD -> master) Add farewell.txt +a479e94 Add greeting.txt +``` + +### 将多个提交压扁为一个 + +在工作时,当你达到较小的里程碑或修复以前的提交中的错误时,你可能会发现写很多提交很有用。但是,在将你的工作合并到 `master` 分支之前,将这些提交“压扁”(`squash`)到一起以使历史记录更清晰可能很有用。为此,我们将使用“压扁”(`squash `)操作。让我们从编写一堆提交开始,如果要加快速度,只需复制并粘贴这些: + +``` +git checkout -b squash +for c in H e l l o , ' ' w o r l d; do + echo "$c" >>squash.txt + git add squash.txt + git commit -m"Add '$c' to squash.txt" +done +``` + +要制作出一个写着 “Hello,world” 的文件,要做很多事情!让我们开始另一个交互式变基,将它们压扁在一起。请注意,我们首先签出了一个分支来进行尝试。因此,因为我们使用 `git rebase -i master` 进行的分支,我们可以快速变基所有提交。结果: + +``` +pick 1e85199 Add 'H' to squash.txt +pick fff6631 Add 'e' to squash.txt +pick b354c74 Add 'l' to squash.txt +pick 04aaf74 Add 'l' to squash.txt +pick 9b0f720 Add 'o' to squash.txt +pick 66b114d Add ',' to squash.txt +pick dc158cd Add ' ' to squash.txt +pick dfcf9d6 Add 'w' to squash.txt +pick 7a85f34 Add 'o' to squash.txt +pick c275c27 Add 'r' to squash.txt +pick a513fd1 Add 'l' to squash.txt +pick 6b608ae Add 'd' to squash.txt + +# Rebase 1af1b46..6b608ae onto 1af1b46 (12 commands) +# +# Commands: +# p, pick = use commit +# s, squash = use commit, but meld into previous commit +``` + +> **技巧**:你的本地 `master` 分支独立于远程 `master` 分支而发展,并且 Git 将远程分支存储为 `origin/master`。结合这种技巧,`git rebase -i origin/master` 通常是一种非常方便的方法,可以变基所有尚未合并到上游的提交! + +我们将把所有这些更改压扁到第一个提交中。为此,将第一行除外的每个“选取”(`pick`)操作都更改为“压扁”(`squash`),如下所示: + +``` +pick 1e85199 Add 'H' to squash.txt +squash fff6631 Add 'e' to squash.txt +squash b354c74 Add 'l' to squash.txt +squash 04aaf74 Add 'l' to squash.txt +squash 9b0f720 Add 'o' to squash.txt +squash 66b114d Add ',' to squash.txt +squash dc158cd Add ' ' to squash.txt +squash dfcf9d6 Add 'w' to squash.txt +squash 7a85f34 Add 'o' to squash.txt +squash c275c27 Add 'r' to squash.txt +squash a513fd1 Add 'l' to squash.txt +squash 6b608ae Add 'd' to squash.txt +``` + +保存并关闭编辑器时,Git 会考虑片刻,然后再次打开编辑器以修改最终的提交消息。你会看到以下内容: + +``` +# This is a combination of 12 commits. +# This is the 1st commit message: + +Add 'H' to squash.txt + +# This is the commit message #2: + +Add 'e' to squash.txt + +# This is the commit message #3: + +Add 'l' to squash.txt + +# This is the commit message #4: + +Add 'l' to squash.txt + +# This is the commit message #5: + +Add 'o' to squash.txt + +# This is the commit message #6: + +Add ',' to squash.txt + +# This is the commit message #7: + +Add ' ' to squash.txt + +# This is the commit message #8: + +Add 'w' to squash.txt + +# This is the commit message #9: + +Add 'o' to squash.txt + +# This is the commit message #10: + +Add 'r' to squash.txt + +# This is the commit message #11: + +Add 'l' to squash.txt + +# This is the commit message #12: + +Add 'd' to squash.txt + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# Date: Sun Apr 28 14:21:56 2019 -0400 +# +# interactive rebase in progress; onto 1af1b46 +# Last commands done (12 commands done): +# squash a513fd1 Add 'l' to squash.txt +# squash 6b608ae Add 'd' to squash.txt +# No commands remaining. +# You are currently rebasing branch 'squash' on '1af1b46'. +# +# Changes to be committed: +# new file: squash.txt +# +``` + +默认情况下,这是所有要压扁的提交的消息的组合,但是像这样将其保留肯定不是你想要的。不过,旧的提交消息在编写新的提交消息时可能很有用,所以放在这里以供参考。 + +> **提示**:你在上一节中了解的“修复”(`fixup`)命令也可以用于此目的,但它会丢弃压扁的提交的消息。 + +让我们删除所有内容,并用更好的提交消息替换它,如下所示: + +``` +Add squash.txt with contents "Hello, world" + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# Date: Sun Apr 28 14:21:56 2019 -0400 +# +# interactive rebase in progress; onto 1af1b46 +# Last commands done (12 commands done): +# squash a513fd1 Add 'l' to squash.txt +# squash 6b608ae Add 'd' to squash.txt +# No commands remaining. +# You are currently rebasing branch 'squash' on '1af1b46'. +# +# Changes to be committed: +# new file: squash.txt +# +``` + +保存并退出编辑器,然后检查你的 Git 日志,成功! + +``` +commit c785f476c7dff76f21ce2cad7c51cf2af00a44b6 (HEAD -> squash) +Author: Drew DeVault +Date: Sun Apr 28 14:21:56 2019 -0400 + + Add squash.txt with contents "Hello, world" +``` + +在继续之前,让我们将所做的更改拉入 `master` 分支中,并摆脱掉这一草稿。我们可以像使用 `git merge` 一样使用 `git rebase`,但是它避免了创建合并提交: + +``` +git checkout master +git rebase squash +git branch -D squash +``` + +除非我们实际上正在合并无关的历史记录,否则我们通常希望避免使用 `git merge`。如果你有两个不同的分支,则 `git merge` 对于记录它们合并的时间非常有用。在正常工作过程中,变基通常更为合适。 + +### 将一个提交拆分为多个 + +有时会发生相反的问题:一个提交太大了。让我们来看一看拆分它们。这次,让我们写一些实际的代码。从一个简单的 C 程序 [^2] 开始(你仍然可以将此代码段复制并粘贴到你的 shell 中以快速执行此操作): + +``` +cat <main.c +int main(int argc, char *argv[]) { + return 0; +} +EOF +``` + +首先提交它: + +``` +git add main.c +git commit -m"Add C program skeleton" +``` + +然后把这个程序扩展一些: + +``` +cat <main.c +#include <stdio.h> + +const char *get_name() { + static char buf[128]; + scanf("%s", buf); + return buf; +} + +int main(int argc, char *argv[]) { + printf("What's your name? "); + const char *name = get_name(); + printf("Hello, %s!\n", name); + return 0; +} +EOF +``` + +提交之后,我们就可以准备学习如何将其拆分: + +``` +git commit -a -m"Flesh out C program" +``` + +第一步是启动交互式变基。让我们用 `git rebase -i HEAD~2` 来变基这两个提交,给出的变基计划如下: + +``` +pick 237b246 Add C program skeleton +pick b3f188b Flesh out C program + +# Rebase c785f47..b3f188b onto c785f47 (2 commands) +# +# Commands: +# p, pick = use commit +# e, edit = use commit, but stop for amending +``` + +将第二个提交的命令从 `pick` 更改为 `edit`,然后保存并关闭编辑器。Git 会考虑一秒钟,然后向你建议: + +``` +Stopped at b3f188b... Flesh out C program +You can amend the commit now, with + + git commit --amend + +Once you are satisfied with your changes, run + + git rebase --continue +``` + +我们可以按照以下说明为提交*添加*新的更改,但我们可以通过运行 `git reset HEAD^` 来进行“软重置” [^3]。如果在此之后运行 `git status`,你将看到它取消了提交最新的提交,并将其更改添加到工作树中: + +``` +Last commands done (2 commands done): + pick 237b246 Add C program skeleton + edit b3f188b Flesh out C program +No commands remaining. +You are currently splitting a commit while rebasing branch 'master' on 'c785f47'. + (Once your working directory is clean, run "git rebase --continue") + +Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: main.c + +no changes added to commit (use "git add" and/or "git commit -a") +``` + +为了对此进行拆分,我们将进行*交互式提交*。这使我们能够选择性地仅提交工作树中的特定更改。运行 `git commit -p` 开始此过程,你将看到以下提示: + +``` +diff --git a/main.c b/main.c +index b1d9c2c..3463610 100644 +--- a/main.c ++++ b/main.c +@@ -1,3 +1,14 @@ ++#include <stdio.h> ++ ++const char *get_name() { ++ static char buf[128]; ++ scanf("%s", buf); ++ return buf; ++} ++ + int main(int argc, char *argv[]) { ++ printf("What's your name? "); ++ const char *name = get_name(); ++ printf("Hello, %s!\n", name); + return 0; + } +Stage this hunk [y,n,q,a,d,s,e,?]? +``` + +Git 仅向你提供了一个“大块”(即单个更改)以进行提交。不过,这太大了,让我们使用 `s` 命令将这个“大块”拆分成较小的部分。 + +``` +Split into 2 hunks. +@@ -1 +1,9 @@ ++#include ++ ++const char *get_name() { ++ static char buf[128]; ++ scanf("%s", buf); ++ return buf; ++} ++ + int main(int argc, char *argv[]) { +Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? +``` + +> **提示**:如果你对其他选项感到好奇,请按 `?` 汇总显示。 + +这个大块看起来更好:单一、独立的更改。让我们按 `y` 来回答问题(并暂存那个“大块”),然后按 `q` 以“退出”交互式会话并继续进行提交。会弹出编辑器,要求输入合适的提交消息。 + +``` +Add get_name function to C program + +# Please enter the commit message for your changes. Lines starting +# with '#' will be ignored, and an empty message aborts the commit. +# +# interactive rebase in progress; onto c785f47 +# Last commands done (2 commands done): +# pick 237b246 Add C program skeleton +# edit b3f188b Flesh out C program +# No commands remaining. +# You are currently splitting a commit while rebasing branch 'master' on 'c785f47'. +# +# Changes to be committed: +# modified: main.c +# +# Changes not staged for commit: +# modified: main.c +# +``` + +保存并关闭编辑器,然后我们进行第二次提交。我们可以执行另一次交互式提交,但是由于我们只想在此提交中包括其余更改,因此我们将执行以下操作: + +``` +git commit -a -m"Prompt user for their name" +git rebase --continue +``` + +最后一条命令告诉 Git 我们已经完成了此提交的编辑,并继续执行下一个变基命令。这样就行了!运行 `git log` 来查看你的劳动成果: + +``` +$ git log -3 --oneline +fe19cc3 (HEAD -> master) Prompt user for their name +659a489 Add get_name function to C program +237b246 Add C program skeleton +``` + +### 重新排序提交 + +这很简单。让我们从设置沙箱开始: + +``` +echo "Goodbye now!" >farewell.txt +git add farewell.txt +git commit -m"Add farewell.txt" + +echo "Hello there!" >greeting.txt +git add greeting.txt +git commit -m"Add greeting.txt" + +echo "How're you doing?" >inquiry.txt +git add inquiry.txt +git commit -m"Add inquiry.txt" +``` + +现在 `git log` 看起来应如下所示: + +``` +f03baa5 (HEAD -> master) Add inquiry.txt +a4cebf7 Add greeting.txt +90bb015 Add farewell.txt +``` + +显然,这都是乱序。让我们对过去的 3 个提交进行交互式变基来解决此问题。运行 `git rebase -i HEAD~3`,这个变基规划将出现: + +``` +pick 90bb015 Add farewell.txt +pick a4cebf7 Add greeting.txt +pick f03baa5 Add inquiry.txt + +# Rebase fe19cc3..f03baa5 onto fe19cc3 (3 commands) +# +# Commands: +# p, pick = use commit +# +# These lines can be re-ordered; they are executed from top to bottom. +``` + +现在,解决方法很简单:只需按照你希望提交出现的顺序重新排列这些行。应该看起来像这样: + +``` +pick a4cebf7 Add greeting.txt +pick f03baa5 Add inquiry.txt +pick 90bb015 Add farewell.txt +``` + +保存并关闭你的编辑器,而 Git 将为你完成其余工作。请注意,在实践中这样做可能会导致冲突,参看下面章节以获取解决冲突的帮助。 + +### git pull --rebase + +如果你一直在由上游更新的分支 ``(比如说原始远程)上做一些提交,通常 `git pull` 会创建一个合并提交。在这方面,`git pull` 的默认行为等同于: + +``` +git fetch origin +git merge origin/ +``` + +假设本地分支 `` 配置为从原始远程跟踪 `` 分支,即: + +``` +$ git config branch..remote +origin +$ git config branch..merge +refs/heads/ +``` +还有另一种选择,它通常更有用,并且会让历史记录更清晰:`git pull --rebase`。与合并方式不同,这基本上 [^4] 等效于以下内容: + +``` +git fetch origin +git rebase origin/ +``` + +合并方式更简单易懂,但是如果你了解如何使用 `git rebase`,那么变基方式几乎可以做到你想要做的任何事情。如果愿意,可以将其设置为默认行为,如下所示: + +``` +git config --global pull.rebase true +``` + +当你执行此操作时,从技术上讲,你在应用我们在下一节中讨论的过程……因此,让我们也解释一下故意执行此操作的含义。 + +### 使用 git rebase 来变基 + +具有讽刺意味的是,我最少使用的 Git 变基功能是它以之命名的功能:变基分支。假设你有以下分支: + +``` +A--B--C--D--> master + \--E--F--> feature-1 + \--G--> feature-2 +``` + +事实证明,`feature-2` 不依赖于 `feature-1` 的任何更改,它依赖于提交 E,因此你可以将其作为基础脱离 `master`。因此,解决方法是: + +``` +git rebase --onto master feature-1 feature-2 +``` + +非交互式变基对所有牵连的提交都执行默认操作(`pick`)[^5] ,它只是简单地将不在 `feature-1` 中的 `feature-2` 中提交重放到 `master` 上。你的历史记录现在看起来像这样: + +``` +A--B--C--D--> master + | \--G--> feature-2 + \--E--F--> feature-1 +``` + +### 解决冲突 + +解决合并冲突的详细信息不在本指南的范围内,将来请你注意另一篇指南。假设你熟悉通常的解决冲突的方法,那么这里是专门适用于变基的部分。 + +有时,在进行变基时会遇到合并冲突,你可以像处理其他任何合并冲突一样处理该冲突。Git 将在受影响的文件中设置冲突标记,`git status` 将显示你需要解决的问题,并且你可以使用 `git add` 或 `git rm` 将文件标记为已解决。但是,在 `git rebase` 的上下文中,你应该注意两个选项。 + +首先是如何完成冲突解决。解决由于 `git merge` 引起的冲突时,与其使用 `git commit` 那样的命令,更适当的变基命令是 `git rebase --continue`。但是,还有一个可用的选项:`git rebase --skip`。 这将跳过你正在处理的提交,它不会包含在变基中。这在执行非交互性变基时最常见,这时 Git 不会意识到它从“其他”分支中提取的提交是与“我们”分支上冲突的提交的更新版本。 + +### 帮帮我! 我把它弄坏了! + +毫无疑问,变基有时会很难。如果你犯了一个错误,并因此而丢失了所需的提交,那么可以使用 `git reflog` 来节省下一天的时间。运行此命令将向你显示更改一个引用(即分支和标记)的每个操作。每行显示你的旧引用所指向的内容,你可对你认为丢失的 Git 提交执行 `git cherry-pick`、`git checkout`、`git show` 或任何其他操作。 + +[^1]: 我们添加了一个空的初始提交以简化本教程的其余部分,因为要对版本库的初始提交进行变基需要特殊的命令(即` git rebase --root`)。 +[^2]: 如果要编译此程序,请运行 `cc -o main main.c`,然后运行 `./main` 查看结果。 +[^3]: 实际上,这是“混合重置”。“软重置”(使用 `git reset --soft` 完成)将暂存更改,因此你无需再次 `git add` 添加它们,并且可以一次性提交所有更改。这不是我们想要的。我们希望选择性地暂存部分更改,以拆分提交。 +[^4]: 实际上,这取决于上游分支本身是否已变基或删除/压扁了某些提交。`git pull --rebase` 尝试通过在 `git rebase` 和 `git merge-base` 中使用 “复刻点fork-point” 机制来从这种情况中恢复,以避免变基非本地提交。 +[^5]: 实际上,这取决于 Git 的版本。直到 2.26.0 版,默认的非交互行为以前与交互行为稍有不同,这种方式通常并不重要。 + +-------------------------------------------------------------------------------- + +via: https://git-rebase.io/ + +作者:[git-rebase][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://git-rebase.io/ +[b]: https://github.com/lujun9972 +[1]: https://git-scm.com/ +[2]: https://git-scm.com/docs/git-rebase + diff --git a/published/202006/20190814 How to install Python on Windows.md b/published/202006/20190814 How to install Python on Windows.md new file mode 100644 index 0000000000..b49ab0d1de --- /dev/null +++ b/published/202006/20190814 How to install Python on Windows.md @@ -0,0 +1,195 @@ +[#]: collector: (lujun9972) +[#]: translator: (011011100010110101101111) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12335-1.html) +[#]: subject: (How to install Python on Windows) +[#]: via: (https://opensource.com/article/19/8/how-install-python-windows) +[#]: author: (Seth Kenlon https://opensource.com/users/sethhttps://opensource.com/users/greg-p) + +如何在 Windows 上安装 Python +====== + +> 安装 Python,启动 IDE,然后你就可以在 Windows 系统下进行编程了。 + +![](https://img.linux.net.cn/data/attachment/album/202006/20/232632iggga8agp5gablg5.jpg) + +你是否想学习编程呢?可以从 [Python][2] 开始,它因为简洁的语法和面向对象的特性而非常受欢迎,是最常见的编程语言之一。而且 Python 是一门解释型语言,这意味着你无需知道如何把 Python 代码编译为机器语言 —— Python 会帮你做到这一点,从而使你能够在编写代码的同时立即进行测试。 + +但是你也不能仅仅因为 Python 学习起来简单而低估了它强大的潜能,无论是在[电影][4][工作室][5]、视频游戏工作室,还是在金融机构、IT 机构、制造业,都有 Python 的身影,甚至很多业余爱好者、[艺术家][6]、教师和许多其他人都使用 Python。 + +另一方面,Python 也是一门严肃的编程语言,学习它需要付出和实践。还有,你什么都不需要马上做,就几乎可以在任何计算机平台上安装并尝试使用 Python ,因此,如果你使用的是 Windows 操作系统,那本文正适合你。 + +如果你使用的是开源的 Linux 操作系统,那你可以 [在 Linux 上安装][7] 并 [尝试使用 Python][8]。 + +### 如何获取 Python + +你可以从 [Python 官方网站][9] 上去下载 Python。在 Python 官方网站下载页,可以将鼠标悬停在 “Downloads” 按钮上,待菜单展开后,再将鼠标悬停在 “Windows” 选项,最后点击按钮就可以下载最新版的 Python 了。 + +![Downloading Python on Windows][10] + +或者你也可以直接点击 “Downloads” 按钮,然后在下载页中选择特定的版本去下载。 + +### 安装 Python + +下载好安装包后,直接打开就可以启动安装程序了。 + +安装时,选择默认的安装路径比较好,最重要的是要将 Python 添加到搜索路径中,否则 Python 应用程序不知道它该从哪里找到 Python 必须的运行时环境;默认认安装时并没有选中这一项,需要手动勾选安装窗口的 “Add Python 3.7 to Path” ,然后点击继续。 + +![Select "Add Python 3 to PATH"][11] + +由于 Windows 需要经过你的批准才会允许安装非微软官方发行的应用程序,因此你必须要在弹出 “User Account Control”(UAC) 系统提示窗口的时候 点击 “Yes” 来继续完成安装。 + +![Windows UAC][12] + +这时候你就需要耐心等待,系统会自动将 Python 软件包分发到合适的位置,等待过后,也就意味着你已经成功的安装了 Python ,你就可以愉快的与 Python 玩耍了! + +### 安装一个 IDE + +虽然说你仅需要一个文本编辑器,就可以开始编写 Python 代码了,但是我依然建议你使用 IDE(集成开发环境)来进行开发,这样开发起来就会变得方便很多。IDE 会将文本编辑器和一些好用的 Python 功能集成到一起,使用起来非常友好。你可以考虑选择 IDLE 3 或者 NINJA-IDE 来作为你的 IDE。 + +#### IDLE 3 + +Python 自带一款 IDE,名字叫 IDLE。虽然你可以使用任何文本编辑器编写 Python 代码,但 IDE 通常会提供 [Notepad++][13] 之类的纯文本编辑器所没有的代码高亮、语法检测等功能,甚至在 IDE 里可以直接通过鼠标点击 “Run” 按钮就能快速运行 Python 代码。 + +想要启动 IDLE ,可以点击 Windows 的 “开始” (或者 “Windows”)按钮,然后输入 `python` 来进行搜索。这时候可能会搜索到多个选项,选择 IDLE 启动就好了。 + +![IDLE 3 IDE][14] + +如果在 “开始” 菜单中没有搜到,你也可以在 “开始” 菜单输入 `cmd` (或同时按下键盘 `win + R` 键) 来启动 Windows 命令提示符,然后输入下面命令来启动 IDLE : + +``` +C:\Windows\py.exe +``` + +如果还是无法启动的话,可是试着重新安装 Python ,安装时记得务必要在安装向导中选中 “Add Python to PATH”。详细说明,可以参考 [Python 官方文档][15] 。 + +#### Ninja-IDE + +如果你已经有一些编程经验,而且你觉得 IDLE 对你来说有些简陋的话,你也可以试试 [Ninja-IDE][16]。 Ninja-IDE 是一款非常出色的 Python IDE,它具有代码高亮功能,并且它会自动帮你检测诸如拼写错误、引号或括号缺失以及其他语法错误。而且它还可以显示行号(调试的时候会非常有用)、缩进标记甚至可以直接通过点击 “Run” 按钮来运行你的代码。 + +![Ninja-IDE][17] + +如果要安装 Ninja-IDE ,你可以访问 Ninja-IDE 的官网 [下载 Windows 安装程序][18] 。步骤跟安装 Python 大同小异:下载安装包、允许 Windows 安装非微软官方的应用程序,然后等待完成安装即可。 + +Ninja-IDE 安装完成后,双击 Windows 桌面或开始菜单下的 Ninja-IDE 就可以启动了。 + +### 告诉 Python 怎么做 + +关键字能让 Python 知道你想要做什么。在 IDLE 或者 Ninja-IDE ,打开 “文件” 菜单,创建一个新文件。 + +在 Ninja-IDE 中,不要创建一个新项目,而是单独创建一个新文件就可以了。 + +在你用 IDLE 或者 Ninja-IDE 新建的文件中,输入以下代码: + +``` +print("Hello world.") +``` + +* 如果你使用的是 IDLE ,请点击 “运行” 菜单,选择 “运行模块” 选项来运行你的程序。 +* 如果你使用的是 Ninja ,请单击左侧按钮栏中的 “运行文件” 按钮。 + +![Running code in Ninja-IDE][19] + +任何时间当你想要执行代码,IDE 都会提示你先保存当前正在处理的文件,然后再继续。 + +`print` 关键字会告诉 Python 打印出你在括号和引号中输入的所有文本。 + +但是别高兴地太早,Python 的核心库也就只能访问 `print` 和 `help` 之类的基本关键字、函数等。 + +如果想要使用更多的关键字和函数,你就需要使用 `import` 关键字去加载它们。好了,先在你的 IDLE 或者 Ninja 中新建一个文件,命名为 `pen.py` 。 + +**警告**:不要把你新建的文件命名为 `turtle.py` ,因为 `turtle.py` 是包含了你要控制的 turtle 程序的文件名称,使用 `turtle.py` 作为文件名会让 Python 感到困惑,因为它以为你想要引入你自己的文件。 + +在你新建的文件中输入一下代码,并运行: + +``` +import turtle +``` + +[Turtle][20] 是一个用起来非常有意思的模块. 把这段代码添加到你的文件内: + +``` +turtle.begin_fill() +turtle.forward(100) +turtle.left(90) +turtle.forward(100) +turtle.left(90) +turtle.forward(100) +turtle.left(90) +turtle.forward(100) +turtle.end_fill() +``` + +来看看你可以使用 turtle 模块来绘制出哪些图案。 + +想要清空 turtle 绘制的区域的话,你可以使用 `turtle.clear()` 函数。那你知道 `turtle.color("blue")` 是用来做什么的吗? + +我们来试一下更复杂点的程序: + +``` +import turtle as t +import time + +t.color("blue") +t.begin_fill() + +counter = 0 + +while counter < 4: +    t.forward(100) +    t.left(90) +    counter = counter+1 + +t.end_fill() +time.sleep(2) +``` + +给你个挑战,试试修改代码,让它得到下图所示的结果: + +![Example Python turtle output][21] + +当你完成这段代码后,你就可以继续学习更多有意思的模块了。这个 [入门级骰子游戏][22] 就是个不错的开始。 + +### 保持 Pythonic + +Python 是一门非常有趣的语言,它的模块几乎能实现所有你想要实现的功能。正如你所看到的,Python 入门很容易,只要你对自己有耐心,很快就会发现自己在理解和编写 Python 时能像写汉字一样流畅。你可以多阅读关于 [Python 的文章][23],试着自己编写一些小片段,然后看看 Python 会执行出什么结果。如果想要把 Python 真正融合到你实际工作中,你可以试试 Linux ,Linux 具有在本地可编写脚本的功能,而其他系统却没有。 + +祝你好运,记得保持 Pythonic。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/how-install-python-windows + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[LiuWenlong](https://github.com/011011100010110101101111) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sethhttps://opensource.com/users/greg-p +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) +[2]: https://www.python.org/ +[3]: https://opensource.com/article/19/7/get-modular-python-classes +[4]: https://github.com/edniemeyer/weta_python_db +[5]: https://www.python.org/about/success/ilm/ +[6]: https://opensource.com/article/19/7/rgb-cube-python-scribus +[7]: https://opensource.com/article/19/7/ways-get-started-linux +[8]: https://opensource.com/article/17/10/python-101 +[9]: https://www.python.org/downloads/ +[10]: https://opensource.com/sites/default/files/uploads/win-python-install.jpg (Downloading Python on Windows) +[11]: https://opensource.com/sites/default/files/uploads/win-python-path.jpg (Select "Add Python 3 to PATH") +[12]: https://opensource.com/sites/default/files/uploads/win-python-publisher.jpg (Windows UAC) +[13]: https://notepad-plus-plus.org/ +[14]: https://opensource.com/sites/default/files/uploads/idle3.png (IDLE 3 IDE) +[15]: http://docs.python.org/3/using/windows.html +[16]: http://ninja-ide.org/ +[17]: https://opensource.com/sites/default/files/uploads/win-python-ninja.jpg (Ninja-IDE) +[18]: http://ninja-ide.org/downloads/ +[19]: https://opensource.com/sites/default/files/uploads/ninja_run.png (Running code in Ninja-IDE) +[20]: https://opensource.com/life/15/8/python-turtle-graphics +[21]: https://opensource.com/sites/default/files/uploads/win-python-idle-turtle.jpg (Example Python turtle output) +[22]: https://opensource.com/article/17/10/python-101#python-101-dice-game +[23]: https://opensource.com/sitewide-search?search_api_views_fulltext=Python diff --git a/published/202006/20190816 Cockpit and the evolution of the Web User Interface.md b/published/202006/20190816 Cockpit and the evolution of the Web User Interface.md new file mode 100644 index 0000000000..779df7312d --- /dev/null +++ b/published/202006/20190816 Cockpit and the evolution of the Web User Interface.md @@ -0,0 +1,169 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12324-1.html) +[#]: subject: (Cockpit and the evolution of the Web User Interface) +[#]: via: (https://fedoramagazine.org/cockpit-and-the-evolution-of-the-web-user-interface/) +[#]: author: (Shaun Assam https://fedoramagazine.org/author/sassam/) + +Cockpit 及其网页用户界面的演变 +====== + +![][1] + +3 年多以前,Fedora 杂志发表了一篇题为《[Cockpit 概览][2]》的文章。从那时起,Cockit 的界面有了一些引人注目的变化。今天的 Cockpit 更加简洁,更大的字体更好地利用了屏幕的空间。 + +本文将介绍它的用户界面的一些变化。还将探讨一些在网页界面中可用的通用工具,以简化那些单调的系统管理员任务。 + +### Cockpit 驾驶舱安装 + +Cockpit 可以使用 `dnf install cockpit` 命令安装。这提供了一个最小的设置,提供了使用该界面所需的基本工具。 + +另一个选择是安装 “Headless Management” 组,这将安装用于扩展 Cockpit 功能的附加包。它包括用于 NetworkManager、软件包、磁盘和 SELinux 管理的扩展。 + +运行以下命令,在启动时启用 Web 服务并打开防火墙端口: + +``` +$ sudo systemctl enable --now cockpit.socket +Created symlink /etc/systemd/system/sockets.target.wants/cockpit.socket -> /usr/lib/systemd/system/cockpit.socket + +$ sudo firewall-cmd --permanent --add-service cockpit +success +$ sudo firewall-cmd --reload +success +``` + +### 登录网页界面 + +要访问网页界面,打开你最喜欢的浏览器,在地址栏中输入该服务器的域名或 IP,然后输入服务端口(9090)。由于 Cockpit 使用 HTTPS,安装过程中会创建一个自签证书来加密密码和其他敏感数据。你可以安全地接受这个证书,或者向你的系统管理员或受信任的来源请求 CA 证书。 + +一旦证书被接受,就会出现新改进的登录屏幕。长期使用的用户会注意到用户名和密码字段已被移到顶部。此外,凭证字段后面的白色背景会立即吸引用户的注意力。 + +![][3] + +自上一篇文章后,登录界面增加了一个功能,就是用 `sudo` 权限登录 —— 如果你的账号是 `wheel` 组的成员。勾选 “对于特权任务,重用我的密码” 旁边的方框,就可以提升你的权限。 + +登录界面的另一个版本是连接到同样运行 Cockpit Web 服务的远程服务器的选项。点击 “其他选项” 并输入远程机器的主机名或 IP 地址,从本地浏览器管理它。 + +### 主屏幕视图 + +一开始,我们就会看到基本概述,带有常见的系统信息,这包括机器的品牌和型号、操作系统、系统是否是最新的,等等。 + +![][4] + +点击系统的品牌/型号会显示硬件信息,如 BIOS/固件。它还包括与 `lspci` 中可以看到的组件的详情。 + +![][5] + +点击任何一个选项,右边都会显示该设备的详细信息。例如,“CPU 核心百分比” 选项显示了用户和内核使用了多少 CPU 核心的详细信息。此外,“内存和交换” 图表显示了系统内存的使用量、缓存量和交换分区的活动量。“磁盘 I/O” 和 “网络流量” 图表连到了 Cockpit 的 “存储和网络” 部分。这些内容将在接下来详细探讨系统工具的一篇文章中重新探讨。 + +#### SSH 密钥和认证 + +由于安全是系统管理员的关键因素,Cockpit 现在有了查看机器 MD5 和 SHA256 密钥指纹的选项。点击 “显示指纹” 选项可以显示服务器的 ECDSA、ED25519 和 RSA 指纹密钥。 + +![][6] + +你也可以通过点击右上角的用户名,选择“验证”,添加自己的密钥。点击 “添加密钥”,可以在其他系统上验证该机器。你也可以通过点击右侧的 “X” 按钮,撤销你在 Cockpit Web 服务中的权限。 + +![][7] + +#### 更改主机名和加入域 + +更改主机名可以在主页上一键解决。单击当前显示的主机名,并在“更改主机名”框中输入新名称。最新的功能之一是提供了一个 “简称” 的选项。 + +Cockpit 增加的另一个功能是可以连接到目录服务器。点击 “加入域”,会出现一个弹窗,要求提供域地址或名称、组织单位(可选)和域管理员的凭证。“Domain Membership” 组提供了加入 LDAP 服务器所需的所有包,包括 FreeIPA,以及流行的 Active Directory。 + +要退出域,请点击域名,然后点击 “离开域”。将会出现一个警告,解释一旦系统不再在域上将会发生的变化。要确认,点击红色的 “离开域” 按钮。 + +![][8] + +#### 配置 NTP 和系统日期和时间 + +使用命令行和编辑配置文件绝对可以完成最大限度的调整。然而,有些时候,一些更直接的方法就足够了。通过 Cockpit,你可以选择手动设置或使用 NTP 自动设置系统的日期和时间。一旦同步,右边的信息图标就会由红色变成蓝色。如果你手动设置日期和时间,该图标将消失。 + +要更改时区,请输入洲,下面会弹出城市列表。 + +![][9] + +#### 关机和重启 + +你可以在 Cockpit 的主屏幕上轻松关闭和重启服务器。你也可以延迟关机/重启,并发送消息警告用户。 + +![][10] + +#### 设置性能配置文件 + +如果安装了 `tuned` 和 `tuned-utils` 包,可以在主屏幕上更改性能配置文件。默认情况下,它被设置为推荐的配置文件。然而,如果服务器的用途需要更多的性能,我们可以在 Cockpit 中更改配置文件以满足这些需求。 + +![][11] + +### 网页版终端控制台 + +一个 Linux 系统管理员的工具箱如果不能访问终端,将毫无用处。终端使得管理员可以对服务器进行微调,而不仅仅是 Cockpit 中的内容。随着主题功能的加入,管理员可以根据自己的喜好快速调整文字和背景颜色。 + +另外,如果你错输入了 `exit` 命令,点击右上角的 “重置” 按钮,会提供一个闪烁着光标的新屏幕。 + +![][12] + +### 添加远程服务器和仪表板布局 + +“Headless Management” 组包括了仪表盘模块(`cockpit-dashboard`)。它以实时图表的形式提供了 CPU、内存、网络和磁盘性能的概览。远程服务器也可以通过同一界面进行添加和管理。 + +例如,要在仪表盘中添加远程计算机,请单击 “+” 按钮。输入服务器的名称或 IP 地址,并选择你要的颜色。这有助于你在图中区分服务器的统计数据。要在服务器之间进行切换,请点击主机名称(如下面的屏幕动画所示)。要从列表中删除一个服务器,点击勾选标记图标,然后点击红色垃圾桶图标。下面的例子演示了 Cockpit 如何管理一台名为 `server02.local.lan` 的远程机器。 + +![][13] + +### 文档和寻找帮助 + +一如既往,手册页是查找文档的好地方。在命令行结果中进行简单搜索即可找到与使用和配置该 Web 服务的不同方面有关的页面。 + +``` +$ man -k cockpit +cockpit (1) - Cockpit +cockpit-bridge (1) - Cockpit Host Bridge +cockpit-desktop (1) - Cockpit Desktop integration +cockpit-ws (8) - Cockpit web service +cockpit.conf (5) - Cockpit configuration file +``` + +Fedora 仓库中也有一个名为 `cockpit-doc` 的软件包。这个软件包的描述是最好的解释。 + +> 《Cockpit 部署和开发者指南》向系统管理员展示了如何在他们的机器上部署 Cockpit,并帮助开发者嵌入或扩展 Cockpit。 + +更多文档请访问 。 + +### 结论 + +本文只涉及 Cockpit 中的一些主要功能。管理存储设备、网络、用户账户和软件控制将在下一篇文章中介绍。此外,可选的扩展,如 389 目录服务,以及用于处理 Fedora Silverblue 中的软件包的`cockpit-ostree` 模块。 + +随着越来越多的用户采用 Cockpit,可选的功能会继续增加。这个界面对于想要一个轻量级界面来控制服务器的管理员来说是非常理想的。 + +你对 Cockpit 有什么看法?在下面的评论中分享你的经验和想法。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/cockpit-and-the-evolution-of-the-web-user-interface/ + +作者:[Shaun Assam][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sassam/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-816x345.jpg +[2]: https://fedoramagazine.org/cockpit-overview/ +[3]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-login-screen.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-home-screen.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-system-info.gif +[6]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-ssh-key-fingerprints.png +[7]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-authentication.png +[8]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-hostname-domain.gif +[9]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-date-time.png +[10]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-power-options.gif +[11]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-tuned.gif +[12]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-terminal.gif +[13]: https://fedoramagazine.org/wp-content/uploads/2019/08/cockpit-add-remote-servers.gif diff --git a/published/202006/20191125 My top 5 Ansible modules.md b/published/202006/20191125 My top 5 Ansible modules.md new file mode 100644 index 0000000000..f114d6ca59 --- /dev/null +++ b/published/202006/20191125 My top 5 Ansible modules.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12304-1.html) +[#]: subject: (My top 5 Ansible modules) +[#]: via: (https://opensource.com/article/19/11/ansible-modules) +[#]: author: (Mark Phillips https://opensource.com/users/markp) + +我最喜欢用的 5 个 Ansible 模块 +====== + +> 了解如何通过这些 Ansible 模块实现几乎任何事情。 + +![](https://img.linux.net.cn/data/attachment/album/202006/10/214614z2jv4zvet5kw322o.jpg) + +在我成长的时候,我爷爷在他的花园里有一个棚子。他经常会花几个小时在那里制作和修复东西。这是在我们有互联网之前的事情,所以我花了很多时间看他在那个棚子里创造东西。虽然棚子里有很多工具,从钻头到车床到电器配件,还有很多东西我至今都无法辨认,但他使用的只是他手头的一小部分。然而,他能做到的事情似乎永远没有极限。 + +我之所以告诉你这个故事,是因为我觉得我的职业生涯是在一个隐喻的棚子里度过的。计算机也是如此多的工具,都在一个狭小(虚拟?)的空间里。而工具棚中又有工具棚 —— 我最喜欢的是 Ansible。最近的 2.9 版本有 3,681 个模块! **3,681 个啊!**当我在 2013 年夏天第一次开始使用 Ansible 时,1.2.1 版本只有 113 个模块,然而,正如[我当时写的][2],我仍然可以实现任何我想象到的东西。 + +模块是 Ansible 的支柱,是让重任轻装上阵的齿轮。它们被设计为做好一项工作,从而实现了 [Unix 哲学][3]。我们就是这样来把这么多的模块捆绑在一起,作为乐团的指挥,Ansible 现在有很多乐器可以听从它的指挥。 + +回顾一下我多年来的 Ansible 剧本和角色的 Git 仓库,我发现我只用了 35 个模块。这个小的子集被用来构建大型基础设施。不过,我想知道如果用一个更小的子集可以实现什么?当我回顾这 35 个模块时,我在思考,我能否只用 5 个模块就能达到同样的效果。因此,以下是我最喜欢的五个模块,顺序无关。 + +### 5. authorized_key + +SSH 是 Ansible 的核心,至少对于除了 Windows 以外的几乎所有其他功能都是如此。在 Ansible 中高效使用 SSH 的关键(没有双关语)是……[密钥][5]!顺便提一下,你可以用 SSH 密钥为安全性做很多非常酷的事情。值得仔细阅读 [sshd 手册页][6]中的 “authorized_keys” 部分。如果你需要精细的用户访问控制,管理 SSH 密钥可能会变得很费力,尽管我可以用接下来的两个我最爱的模块中的任何一个,但我更喜欢使用 [authorized_key][4] 这个模块,因为它[可以通过变量轻松管理][7]。 + +### 4. file + +除了显而易见的将文件放置在某个地方的功能外,[file][8] 模块还可以设置所有权和权限。我想说的是,这样一个模块就能带来很多的好处。很大一部分安全问题也与设置权限有关,所以 [file][8] 模块和 [authorized_key][4] 可以很好地配合在一起使用。 + +### 3. template + +操作文件内容的方法太多了,我看到很多人都在使用 [lineinfile][10]。我自己也用它做过小任务。但是,[template][9] 模块就清晰多了,因为你维护了整个文件的上下文。我更喜欢以任何人都可以*轻松*理解的方式编写 Ansible 的内容 —— 对我而言,这意味着容易理解正在发生的事情。[template][9] 的使用意味着能够看到你正在放置内容的整个文件、全部你正在改变的变量。 + +### 2. uri + +当前发布版中的许多模块利用 Ansible 作为编排工具。它们与另一个服务对话,而不是做一些具体的事情,比如把一个文件放到一个地方。通常,这种对话也是通过 HTTP 进行的。在许多这样的模块出现之前,你*可以*直接使用 [uri][11] 模块对 API 进行编程。它是一个强大的访问工具,可以使你能够做很多事情。在我的 Ansible 虚拟棚子里,我不会少了它。 + +### 1. shell + +这是我们工具包里的王牌、瑞士军刀。如果你为如何控制其他东西而非常苦恼,别说,说就是 [shell][12]。有人会说,我们这样说是让 Ansible 成为了 Bash 脚本 —— 但是,我想说的是,这还是有点好处的,因为可以在你的剧本和角色中使用 `name` 参数记录下每一步。对我来说,这就像一个很大的奖励一样。早在我还在做咨询的时候,我曾经帮助一个数据库管理员(DBA)迁移到 Ansible。这位 DBA 并不喜欢改变,对改变工作方法也是推三阻四。于是,为了简化迁移到 Ansible 方式,我们在 Ansible 中使用 [shell][12] 模块调用了一些现有的数据库管理脚本。并在任务中附带了翔实的 `name` 声明。 + +通过这五个模块,你可以实现很多事情。是的,为完成特定任务而设计的模块会让你的生活更加轻松。但是,借助简单的工程设计,你几乎可以事半功倍。Ansible 开发者 Brian Coca 是这方面的大师,[他的技巧和窍门讲座][13]总是值得一看。 + +* * * + +你觉得我喜欢的五大模块怎么样?如果你也必须限制在这么多模块,你会选择哪五个,为什么?在下面的评论中告诉我吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/11/ansible-modules + +作者:[Mark Phillips][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/markp +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mandelbrot_set.png?itok=bmPc0np5 +[2]: http://probably.co.uk/post/puppet-vs-chef-vs-ansible/ +[3]: https://en.wikipedia.org/wiki/Unix_philosophy#Do_One_Thing_and_Do_It_Well +[4]: https://docs.ansible.com/ansible/latest/modules/authorized_key_module.html +[5]: https://linux.die.net/man/1/ssh-keygen +[6]: https://linux.die.net/man/8/sshd +[7]: https://github.com/phips/ansible-demos/blob/3bf59df1eb2390b31b5c42333197e2fbb7fec93f/roles/ansible-users/tasks/main.yml#L35 +[8]: https://docs.ansible.com/ansible/latest/modules/file_module.html +[9]: https://docs.ansible.com/ansible/latest/modules/template_module.html +[10]: https://docs.ansible.com/ansible/latest/modules/lineinfile_module.html +[11]: https://docs.ansible.com/ansible/latest/modules/uri_module.html +[12]: https://docs.ansible.com/ansible/latest/modules/shell_module.html +[13]: https://www.ansible.com/ansible-tips-and-tricks diff --git a/published/202006/20200304 Getting started with the Gutenberg editor in Drupal.md b/published/202006/20200304 Getting started with the Gutenberg editor in Drupal.md new file mode 100644 index 0000000000..55ad82e25a --- /dev/null +++ b/published/202006/20200304 Getting started with the Gutenberg editor in Drupal.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12273-1.html) +[#]: subject: (Getting started with the Gutenberg editor in Drupal) +[#]: via: (https://opensource.com/article/20/3/gutenberg-editor-drupal) +[#]: author: (MaciejLukianski https://opensource.com/users/maciejlukianski) + +Drupal 中的 Gutenberg 编辑器入门 +====== + +> 了解如何在 Drupal 中集成使用 WordPress 中流行的所见即所得编辑器。 + +![Text editor on a browser, in blue][1] + +自 2017 年以来,WordPress 的 [Gutenberg][2] 插件中的所见即所得编辑器就真的很不错。但是,Drupal 社区尚未就内容管理系统(CMS)编辑体验的最佳方法达成共识。但在社区的大量努力下,出现了一个强有力的新选择,将 [Gutenberg 与 Drupal 集成在一起][3]。 + +以前,Drupal 8 中有两种主要的内容创建方法: + +* 在[基于段落的方法][4]中,内容是由称为段落的实体组合而成。目前,大约有 100,000 个网站使用“段落”(Paragraphs)模块(根据 Drupal 说法)。 +* [Layout-Builder 方法][5]使用 Drupal 8.5 附带的编辑工具。它仍然在改进,但是它是下一个强有力的竞争者,因为它确实与 Drupal 内核很好地集成在一起。由于 Layout-Builder 是 Drupal 的一部分,因此无法获得使用情况的统计信息。 + +在 2018 年底,由 Fronkom(一家专注于开源解决方案的挪威数字机构)领导的 Drupal 社区将 WordPress Gutenberg 项目作为贡献模块移植到了 Drupal 中。让我们看一下 Gutenberg 在 Drupal 中的工作方式(包括一些很酷的 Drupal 特有的集成)。 + +### 安装 + +安装 [Gutenberg 模块][6]与安装任何 Drupal 模块一样简单,并且有良好的[安装文档][7]。 + +### 配置 + +Gutenberg 已集成到 Drupal 的默认内容实体创建工作流中。你可以将其用于你选择的任何内容类型,前提是内容类型至少有一个文本区域字段,它是 Gutenberg 编辑器输出的位置。 + +要在 Drupal 中的内容类型启用 Gutenberg 项目,你必须进入设置:“结构 -> 内容类型”,并且,从要你想使用 Gutenberg 的内容类型旁边的下拉框中单击“编辑”。 + +![Drupal settings][8] + +在出现的窗口中,向下滚动并选择左侧的“Gutenberg 体验”选项卡,你可以在其中找到下面描述的设置。选择“启用 Gutenberg 体验”。 + +![Drupal Gutenberg settings][9] + +#### 模板 + +这是 WordPress 开箱即用的很酷的功能之一。它能让你用 JSON 结构定义新页面模板。它将使用虚拟占位符内容预填充所有新创建的文章,这将有助于编辑者正确地构造内容。在上面的截图中,我添加了一个标题和一个段落。请注意,必须转义任何双引号。 + +#### 模板锁 + +此设置允许你定义是否允许用户删除占位符内容,添加新块或仅编辑现有的预填充内容。 + +#### 允许的 Gutenberg 和 Drupal 块 + +这是 Gutenberg Drupal 侧的另一个超酷功能。Drupal 允许用户创建各种类型的块来设计页面。例如,你可以创建一个块,其中包含五个最新博客的列表、最新评论或用于收集用户电子邮件的表单。 + +Gutenberg 与 Drupal 的深度集成允许用户在编辑时选择哪些 Drupal 块可供用户使用(例如,限制嵌入 YouTube),并将块用作内联内容。这是一个非常方便的功能,允许对用户体验进行精细控制。 + +在全新安装的 Drupal 中,没有太多的选择,但站点通常有许多提供各种功能的块。在下面的截图中,选择了“搜索表单”的 Drupal 块。 + +![Drupal Gutenberg blocks][10] + +完成配置后,点击“保存内容类型”。 + +### 使用 Drupal Gutenberg 发布内容 + +启用 Gutenberg 内容类型后,它将接管大部分编辑体验。 + +![Drupal Gutenberg content screen][11] + +在主窗口中,你可以看到我在上面的模板配置中添加的虚拟占位符内容。 + +#### 特定于 Drupal 的选项 + +在右侧,Drupal 提供了一些字段和设置。例如,“标题” 字段是 Drupal 中所需的单独字段,因此它不在主页面上。 + +在“标题”下面,根据在 Drupal 中安装的模块和设置的选项,其他设置可能有所不同。你可以看到“修订日志消息”、“菜单设置”、“评论设置”以及添加“URL 别名”。 + +通常,Drupal 内容类型由多个文本字段组成,如标记、类别、复选框、图像字段等。当你启用 Gutenberg 内容类型时,这些附加字段可在“更多设置”选项卡中提供。 + +你现在可以添加内容 —— 它的工作方式与 WordPress Gutenberg 中的相同,并有额外的添加 Drupal 块的选项。 + +在下面的截图中,你可以看到当我添加一些文本替换占位符文本、来自 Drupal 的搜索块、标题、标记和自定义 URL 别名后发生的情况。 + +![Drupal Gutenberg entering text][12] + +点击“保存”后,你的内容将发布。 + +![Drupal Gutenberg output][13] + +就是这样,它工作良好。 + +### 共同工作以获得更好的软件体验 + +Drupal 中的 Gutenberg 工作良好。这是一个可供选择的方式,允许编辑者控制网站的外观,直至最细微的细节。它的采用率正在增长,截至本文撰写时,已有 1,000 多个安装,每月有 50 个新安装。Drupal 集成添加了其他很酷的功能,如细粒度权限、占位符内容,以及内联包含 Drupal 块的功能,这些功能在 WordPress 插件中没有。 + +很高兴看到两个独立项目的社区共同努力实现为人们提供更好的软件的共同目标。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/3/gutenberg-editor-drupal + +作者:[MaciejLukianski][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/maciejlukianski +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue) +[2]: https://wordpress.org/plugins/gutenberg/ +[3]: https://drupalgutenberg.org/ +[4]: https://www.droptica.com/blog/flexible-and-easy-content-creation-drupal-paragraphs-module/ +[5]: https://www.droptica.com/blog/layout-builder-building-drupal-8-layouts/ +[6]: https://www.drupal.org/project/gutenberg +[7]: https://www.drupal.org/docs/8/extending-drupal-8/installing-drupal-8-modules +[8]: https://opensource.com/sites/default/files/uploads/gutenberg_edit.png (Drupal settings) +[9]: https://opensource.com/sites/default/files/uploads/gutenberg_settings.png (Drupal Gutenberg settings) +[10]: https://opensource.com/sites/default/files/uploads/gutenberg_blocks.png (Drupal Gutenberg blocks) +[11]: https://opensource.com/sites/default/files/uploads/gutenberg_contentwindow.png (Drupal Gutenberg content screen) +[12]: https://opensource.com/sites/default/files/uploads/gutenberg_entry.png (Drupal Gutenberg entering text) +[13]: https://opensource.com/sites/default/files/uploads/gutenberg-demo.png (Drupal Gutenberg output) diff --git a/published/202006/20200506 6 open source alternatives to Wunderlist.md b/published/202006/20200506 6 open source alternatives to Wunderlist.md new file mode 100644 index 0000000000..e79d80ac5d --- /dev/null +++ b/published/202006/20200506 6 open source alternatives to Wunderlist.md @@ -0,0 +1,123 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12314-1.html) +[#]: subject: (6 open source alternatives to Wunderlist) +[#]: via: (https://opensource.com/article/20/5/alternatives-list) +[#]: author: (Jen Wike Huger https://opensource.com/users/jen-wike) + +6 个开源的奇妙清单(Wunderlist)替代品 +====== + +> 喜欢列表?看看这个便捷的开源应用程序列表,以管理你所有的列表! + +![](https://img.linux.net.cn/data/attachment/album/202006/14/142722a639gqqrgg7x6hb5.jpg) + +奇妙清单(Wunderlist)是一款清单应用,受到很多人的喜爱,但从 2020 年 5 月 6 日起,它就永远停止了。它的网站鼓励现有用户下载并使用“微软待办”来代替它。这很诱人,因为它可以轻松导入你多年来制作的所有这些列表。不过话又说回来,也许这是个机会,可以“近藤麻理惠”一下这些列表,并削减一些事务。(你真的需要 30 个列表吗?很显然,我觉得我需要,所以我不做评判。) + +我有各种各样的清单,从“2020 年花园的植物”到“给丈夫的礼物”。有些是清单,有些是待办事项清单,有些是为了清单而清单。 + +对我和我丈夫来说,最有用的清单是我们共享的杂货清单。我们都有手机上的应用程序,我们都把东西添加到列表中,但在他去购物之前,我们分别在手机上审查它(是的,你没看错),他把东西放进购物车时,他就会勾掉它。这让整个过程变得出奇的高效,我想我们节省了一些钱,因为我们喜欢坚持按清单购物。 + +虽然奇妙清单的用户很喜欢它,但它并不是完全独一无二的。还有无数的列表应用。对于奇妙清单,我特别喜欢它将简洁性和设计感结合在一起,而且它成功实现了一些有用的功能,比如与他人分享和协作,列表的动态复选框,以及在移动和网页界面上的良好用户体验。我也很喜欢用它来做一个不“活跃”文档的列表:一个我不会每周都回顾或定期进展的列表,就像我用来进行头脑风暴的许多列表一样(包括我一直想写的小说...)。 + +从这些年来我们发表的许多精彩文章中,我整理了一系列奇妙清单的开源替代方案,从简单的任务管理和待办事项清单到复杂的笔记记录和流程管理,这些列表工具可能会满足你的需求。或者,如果你是那个在丢得到处都是的纸条和便签上书写任务和备注的人,这可能是尝试这些数字工具之一的好时机。 + +### Tasks:可与 OwnCloud 配合 + +Tasks 是一款自由开源的应用,你可以从 [F-droid][2] 安装。Tasks 是一款只适用于手机的应用,但它可以同步到各种地方,非常灵活。你可以将你的列表保存到 NextCloud 或 OwnCloud、Google Tasks、Apple Reminders 以及几乎所有你有账户的 CalDAV 服务器上。 + +Tasks 的默认视图是每日视图,所以你输入的任何任务都被假定为从今天开始的任务。如果你像我一样,想维护几个不同的列表,你可以用标签来实现。当你创建一个标签时,你就为任务创建了一个类别。你可以为它指定一种颜色和一个图标,这样每个任务列表都是独一无二的。 + +这需要一点时间来适应,但标签有很多优点。因为所有的任务都是有标签的,你可以通过点击你想过滤的标签来查看任务组,但你也可以按天甚至按地点过滤。这意味着,当你去采购杂货时,你的杂货列表会成为活跃的默认列表,而当你回到家时,你的日常生活列表又会成为活跃的列表。 + +通过将你的数据同步到你的一个在线账户,你可以与亲人、合作者和同事分享列表。 + +另一个伟大的功能是,如果你每天早上上班时都有相同的任务,或者每周杂货清单中有 20 个相同的项目,你可以创建定期重复的任务。 + +评测者:Seth Kenlon + +![Screenshot of Tasks interface][3] + +### OpenTasks:适于长列表 + +[OpenTasks][4] 是一款优秀的任务管理工具,可以创建带有各种设置的个人任务。它在创建任务时支持多种字段,从基本的东西,如名称和描述,到更复杂的项目,如选择任务是私人、公共还是机密。OpenTasks 与其他替代品最大的不同之处在于它在应用的主屏幕上使用了选项卡。这些选项卡可以让你快速看到到期的任务、即将开始的任务、按优先级排序的任务,以及按当前完成进度排序的任务。许多其他应用程序支持做这样的事情,但 OpenTasks 很快就能轻松访问这些列表。 + +[阅读完整的 OpenTasks 评测][5],作者:Joshua Allen Holm。 + +![OpenTasks in Google Play store][6] + +### Mirakel:嵌套列表的绝佳之选 + +[Mirakel][7] 是一款任务管理应用,它拥有现代化的用户界面,并支持你在这样一款程序中可能想要的几乎所有格式。Mirakel 在基础层面上支持多个被称为“元列表”的列表。创建一个单独的任务有大量的选项,有截止日期、提醒、进度跟踪、标签、备注、子任务和文件附件,所有这些都构成了任务条目的一部分。 + +[阅读完整的 Mirakel 评测][5],作者:Joshua Allen Holm。 + +![Screenshot from website of Mirakel app][8] + +### Todo:简单有效,随处可用 + +[Todo.txt][9] 是我不断反复推荐的两个待办事项和任务管理应用之一(另一个是 Org 模式)。而让我不断推荐的原因是,它简单、便携、易懂,而且有很多很棒的附加组件,即使一台机器有这个程序而其他机器上没有,也不会破坏它。而且由于它是一个 Bash shell 脚本,我从来没有发现不支持它的系统。阅读更多关于[如何安装和使用 Todo.txt][10]。 + +[阅读完整的 todo.txt 评测][10],作者:Kevin Sonney。 + +![Drop-down menu for Todo.txt][11] + +### Joplin:最佳私人列表 + +[Joplin][12] 是一个 NodeJS 应用程序,它可以在本地运行和存储信息,允许你加密任务,并支持多种同步方法。Joplin 可以作为控制台或图形应用程序在 Windows、Mac 和 Linux 上运行。Joplin 还拥有 Android 和 iOS 的移动应用,这意味着你的笔记随处可用,而不需要大费周章。Joplin 甚至允许你用 Markdown、HTML 或纯文本来格式化你的笔记。 + +[阅读完整的 Joplin 评测][13],作者:Kevin Sonney。 + +![Joplin graphical version ][14] + +### CherryTree:最好的 Evernote / OneNote / Keep 替代品 + +[CherryTree][15] 是一个 GPLv3 许可的应用程序,它以节点的形式组织信息。每个节点都可以有子节点,让你轻松组织你的列表和思想。而且,子节点可以有自己的子节点,具有独立的属性。 + +[阅读完整的 CherryTree 评测][16],作者:Ben Cotton。 + +![CherryTree's hierarchical note layout][17] + +### 附赠:Wekan,给看板粉丝 + +看板kanban是当今敏捷流程的主流。我们中的许多人(包括我自己)不仅用它们来组织我们的工作,还用它们来组织我们的个人生活。我认识一些艺术家,他们使用 Trello 这样的应用程序来跟踪他们的委托清单,以及正在进行和已经完成的工作。但这些应用往往与工作账户或商业服务挂钩。让我们看看 [Wekan][18],这是一个开源的看板,你可以在本地或你选择的服务上运行。Wekan 提供了与其他看板应用相同的功能,比如创建面板、列表、泳道和卡片,在列表之间拖放,分配给用户,给卡片贴标签,以及做几乎所有你在现代看板中期待的事情。 + +[阅读完整的 Wekan 评测][19],作者:Kevin Sonney。 + +![Wekan kanban board][20] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/alternatives-list + +作者:[Jen Wike Huger][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jen-wike +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk (a checklist for a team) +[2]: https://f-droid.org/en/packages/org.tasks/ +[3]: https://opensource.com/sites/default/files/uploads/screenshot_tasks_resized.jpg (Screenshot of Tasks interface) +[4]: https://play.google.com/store/apps/details?id=org.dmfs.tasks +[5]: https://opensource.com/article/17/1/task-management-time-tracking-android +[6]: https://opensource.com/sites/default/files/uploads/opentasks_rezied.jpg (OpenTasks in Google Play store) +[7]: https://mirakel.azapps.de/ +[8]: https://opensource.com/sites/default/files/uploads/mirakel_web_resized.jpg (Screenshot from website of Mirakel app) +[9]: http://todotxt.org/ +[10]: https://linux.cn/article-11835-1.html +[11]: https://opensource.com/sites/default/files/uploads/todo.txtmenu_3.png (Drop-down menu for Todo.txt) +[12]: https://joplin.cozic.net/ +[13]: https://linux.cn/article-10476-1.html +[14]: https://opensource.com/sites/default/files/uploads/joplin-1.png (Joplin graphical version ) +[15]: https://www.giuspen.com/cherrytree/ +[16]: https://opensource.com/article/19/5/cherrytree-notetaking +[17]: https://opensource.com/sites/default/files/uploads/cherrytree.png (CherryTree's hierarchical note layout) +[18]: https://wekan.github.io/ +[19]: https://linux.cn/article-10454-1.html +[20]: https://opensource.com/sites/default/files/uploads/wekan-board.png (Wekan kanban board) diff --git a/published/202006/20200507 Ubuntu Cinnamon Remix 20.04 Review- The Perfect Blend of Ubuntu With Cinnamon.md b/published/202006/20200507 Ubuntu Cinnamon Remix 20.04 Review- The Perfect Blend of Ubuntu With Cinnamon.md new file mode 100644 index 0000000000..322e26fa60 --- /dev/null +++ b/published/202006/20200507 Ubuntu Cinnamon Remix 20.04 Review- The Perfect Blend of Ubuntu With Cinnamon.md @@ -0,0 +1,157 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12316-1.html) +[#]: subject: (Ubuntu Cinnamon Remix 20.04 Review: The Perfect Blend of Ubuntu With Cinnamon) +[#]: via: (https://itsfoss.com/ubuntu-cinnamon-remix-review/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +Ubuntu Remix Cinnamon 20.04 评测:Ubuntu 与 Cinnamon 的完美融合 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/15/113226uq8ohzycrrc52q52.jpeg) + +推出于 2011 年的 GNOME 3,其 GNOME Shell 迎来了社区的赞扬的同时,也招致了一些人的反对。很多用户和开发者都很喜欢原来的 GNOME 界面,以至于有几个小组复刻了它,其中的一个小组 —— Linux Mint 团队创建了 [Cinnamon 桌面环境][1]。 + +Cinnamon 桌面成为了 Linux Mint 的标志型产品。多年来,Cinnamon 一直是 [Linux Mint][2] 的代名词。在过去的几年里,随着 Cinnamon 的普及,这种情况略有改变。现在其他发行版也开始提供 Cinnamon 桌面环境,[Manjaro][3] 就是这样一个例子。 + +几个月前,我们向大家介绍了一个[新 Ubuntu 变体][4],它提供了开箱即用的 Cinnamon 桌面体验,今天就让我们来深入了解一下 [Ubuntu Cinnamon Remix][5]。 + +### 为什么是 Ubuntu Cinnamon Remix 而不是 Linux Mint? + +的确,Linux Mint 是基于 Ubuntu 的,很多 Linux Mint 的用户都会有这样的疑问:既然 Linux Mint 已经如此成熟,而且用户体验也大致相同,那么换成 Ubuntu 有什么意义吗? + +Ubuntu Cinnamon Remix 与 Linux Mint 有很多小的区别,但有一个关键的区别是 Linux 爱好者不能忽视的。 + +Linux Mint 是基于 “LTS”(长期支持)版本的 Ubuntu,这意味着它一直落后于 Canonical 的 6 个月的更新节奏。Ubuntu Cinnamon Remix 则可以得益于较新的内核以及其他 6 个月周期内的功能升级和较新的软件。 + +另一个关键的区别是,Ubuntu Cinnamon Remix 将 “继承” [Snap 支持][6],而 Linux Mint 则拥抱 [FlatPak][7]。Ubuntu Cinnamon Remix 使用 Ubuntu 软件中心而不是 Mint 软件管理器。 + +我是 Cinnamon 的忠实粉丝,所以我选择了评测这款 Ubuntu 和 Cinnamon 的混合版,在这里我分享一下我的体验。 + +### 体验 Ubuntu Cinnamon Remix + +只要有机会,我总会提到 [Calamares 安装程序][8]有多快,感谢 Ubuntu Cinnamon Remix 团队如此选择。 + +![Calamares Installer][9] + +新安装的 Ubuntu Cinnamon Remix 会消耗大约 750 MB 的内存。这与 Linux Mint Cinnamon 非常相似。 + +![An idle Cinnamon takes 750 MB of RAM][10] + +美丽的 [Kimmo 主题][11]和橙色调的 Ubuntu 壁纸也给我留下了深刻的印象,看来这是一个非常细致的努力的结果。 + +![Ubuntu Cinammon Remix 20.04 Desktop][12] + +#### 足够让你开始的工具 + +和其他 Ubuntu 发行版一样,Ubuntu Cinnamon Remix 也包含了一些重要的生产力工具,下面是其中一些: + +* 火狐浏览器 +* Thunderbird - 电子邮件客户端 +* LibreOffice套件 +* Celluloid - 多媒体播放器 +* [GIMP][13] - 图像处理软件 +* Synaptic 软件包管理器 +* Gnome 软件中心 +* [Gparted][14] - 分区管理器 + +使用 Ubuntu Cinnamon Remix 作为我的主要平台已经有几天了,它满足了我的高期望。Ubuntu 稳定如磐石,速度非常快,在日常工作中我没有遇到任何问题。 + +#### 给 Linux Mint 爱好者的 Ubuntu + +你是否热衷于 Ubuntu Cinnamon,却习惯了 Linux Mint 主题?点击下面的内容,看看如何获得一个完整的 Linux Mint 主题包,以及如何配置它来保持 Ubuntu 的传统。 + +给 Ubuntu Cinnamon Remix 以真正的 Mint 感受: + +首先你必须下载并解压以下内容,通过终端很容易完成。 + +获取 Linux Mint-X 图标包: + +``` +wget http://packages.linuxmint.com/pool/main/m/mint-x-icons/mint-x-icons_1.5.5_all.deb +``` + +获取 Linux Mint-Y 图标包: + +``` +wget http://packages.linuxmint.com/pool/main/m/mint-y-icons/mint-y-icons_1.3.9_all.deb +``` + +获取 Linux Mint 主题: + +``` +wget http://packages.linuxmint.com/pool/main/m/mint-themes/mint-themes_1.8.4_all.deb +``` + +安装下载的软件包: + +``` +sudo dpkg -i ./mint-x-icons_1.5.5_all.deb ./mint-y-icons_1.3.9_all.deb ./mint-themes_1.8.4_all.deb +``` + +完成后,点击左下角的菜单按钮,输入 “themes”。你也可以在系统设置中找到“主题”功能。 + +![Accessing Themes][15] + +打开后更换 kimmo 图标和主题,如下图所示。Linux Mint 默认的“绿色”是普通的 Mint-Y,而橙色是 Ubuntu 的最佳选择。 + +![Linux Mint Theme Settings][16] + +#### 为 Cinnamon 迷们准备的美食 + +让我们承认吧,审美很重要。Cinnamon 拥有简洁优雅的外观、易于阅读的字体和漂亮的色彩对比主题。Cinnamon 提供了一个整洁的桌面,只需进入系统设置下的桌面菜单,即可轻松配置桌面图标。你也可以选择桌面图标只显示在主显示器上、只显示在副显示器上,或者同时显示在两个显示器上。这也适用于超过两台显示器的设置。 + +![Ubuntu Cinnamon Remix Desklets][17] + +桌面组件和小程序是一种小型的、单一用途的应用程序,可以分别添加到你的桌面或面板上。在众多的应用程序中,最常用的是 CPU 或资源监控器、天气小程序、便签和日历。 + +Cinnamon 控制中心集中提供许多桌面配置选项。通过访问 “主题” 部分,你可以选择桌面基本方案和图标、窗口边框、鼠标指针和控件外观。字体对桌面的整体外观有很大的影响,而 Cinnamon 让改变字体比以往任何时候都要容易。 + +Cinnamon 控制中心配置对新用户来说也足够简单,相比之下,KDE Plasma 会因为大量的配置选项而导致新用户感到困惑。 + +![][18] + +Cinnamon 面板包含用于启动程序的菜单、基本的系统托盘和应用程序选择器。面板的配置很简单,添加新的程序启动器只需在主菜单中找到你要添加的程序,右击图标,选择 “添加到面板” 即可。你也可以将启动程序图标添加到桌面,以及 Cinnamon 的 “收藏夹” 启动栏中。如果你不喜欢面板上图标的顺序,只需在面板栏上点击右键,进入面板的 “编辑” 模式,重新排列图标即可。 + +### 结论 + +无论你是决定给你的桌面 “加点料”,还是考虑从 [Windows 迁移到 Linux][19],Cinnamon 社区都为你制作了大量的香料。 + +传统而又优雅,可定制而又简单,Ubuntu Cinnamon Remix 是一个有趣的项目,前途无量,对于喜欢 Ubuntu 的 Cinnamon 桌面爱好者来说,这可能是一个不二之选。 + +你觉得 Ubuntu Cinnamon Remix 怎么样?你已经使用过它了吗? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-cinnamon-remix-review/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Cinnamon_(desktop_environment) +[2]: https://www.linuxmint.com/ +[3]: https://manjaro.org/ +[4]: https://itsfoss.com/ubuntudde/ +[5]: https://ubuntucinnamon.org/ +[6]: https://snapcraft.io/ +[7]: https://flatpak.org/ +[8]: https://calamares.io/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/Calamares-Installer.png?resize=800%2C426&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/htop-running-on-Ubuntu-Cinnamon-Remix-20.04.png?ssl=1 +[11]: https://github.com/Ubuntu-Cinnamon-Remix/kimmo-gtk-theme +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/Ubuntu-Cinammon-Remix-20.04-desktop.png?resize=800%2C450&ssl=1 +[13]: https://itsfoss.com/gimp-2-10-release/ +[14]: https://itsfoss.com/gparted/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/accessing-themes.png?ssl=1 +[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/Linux-Mint-theme-settings.png?ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-cinnamon-remix-desklets.jpg?fit=800%2C450&ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-cinnamon-control.jpg?fit=800%2C450&ssl=1 +[19]: https://itsfoss.com/windows-like-linux-distributions/ diff --git a/published/202006/20200511 How to manage network services with firewall-cmd.md b/published/202006/20200511 How to manage network services with firewall-cmd.md new file mode 100644 index 0000000000..6fcbfc11b9 --- /dev/null +++ b/published/202006/20200511 How to manage network services with firewall-cmd.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12276-1.html) +[#]: subject: (How to manage network services with firewall-cmd) +[#]: via: (https://fedoramagazine.org/how-to-manage-network-services-with-firewall-cmd/) +[#]: author: (dan01 https://fedoramagazine.org/author/dan01/) + +如何使用 firewall-cmd 管理网络服务 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/03/090806hcmc9cxcbbcuccbe.jpg) + +在上一篇文章中,我们探讨了如何在 Fedora 中[用命令行控制防火墙][2]。 + +现在你将看到如何“添加”、“删除”和“列出”服务、协议和端口,以便“阻止”或“允许”它们。 + +### 简短回顾 + +首先,最好检查一下防火墙的*状态*,看它是否正在运行。如我们先前所学,你可以使用状态选项(`firewall-cmd ‐‐state`)来得到。 + +下一步是获取网络接口适用的zone。例如,我使用的桌面有两个网络接口:一个*物理*接口(`enp0s3`),代表我实际的*网卡*,和*虚拟*接口(`virbr0`),它由 KVM 等虚拟化软件使用。要查看哪些域处于活动状态,请运行 `firewall-cmd ‐‐get-active-zones`。 + +现在,你知道了你感兴趣的域,可以使用 `firewall-cmd ‐‐info-zone=FedoraWorkstation` 这样的命令列出该域的规则。 + +### 读取区域信息 + +要显示*特定域*的信息,请运行 `firewall-cmd ‐‐zone=ZoneName ‐‐list-all`,或使用以下命令显示默认域的信息: + +``` +[dan@localhost ~]$ firewall-cmd --list-all +FedoraWorkstation (active) +target: default +icmp-block-inversion: no +interfaces: enp0s3 +sources: +services: dhcpv6-client mdns samba-client ssh +ports: 1025-65535/udp 1025-65535/tcp +protocols: +masquerade: no +forward-ports: +source-ports: +icmp-blocks: +rich rules: +``` + +现在,让我们查看输出。第一行表明以下信息关联的域以及该域当前是否在使用中。 + +`target: default`:告诉我们这是默认域。可以通过 `‐‐set-default-zone=ZoneName` 和 `‐‐get-default-zone` 设置或获取。 + +`icmp-block-inversion` 表明是否阻止 [ICMP][3] 请求。例如,如果机器响应来自网络上其他机器的 ping 请求。 + +`interfaces` 字段显示接受此域的所有接口。 + +### 处理服务、端口和协议 + +现在,重点关注 `services`、`ports` 和 `protocols` 所在行。默认情况下,防火墙将阻止所有端口、服务和协议,而只允许列出的。 + +在这里,你可以看到允许的服务是非常基本的客户端服务。例如,访问网络上的共享文件夹(`samba-client`)、与 DNS 服务器通信或通过 SSH(`ssh` 服务)连接到计算机。你可以将 `service` 视为与端口组合的协议,例如 `ssh` 服务使用 SSH 协议,并且按照惯例使用 22 端口。通过允许 `ssh` 服务,你实际上所做的就是允许传入的连接在默认 22 端口上使用 SSH 协议。 + +请注意,根据经验,名称中带有 `client` 字样的服务是指传出连接,也就是你使用你的 IP 作为源对外部的*连接*,与之相反的是 `ssh` 服务,比如,它将接受传入连接(监听来自外部的连接)。 + +你可以在文件 `/etc/services` 中查找服务。例如,如果你想知道这些服务使用什么端口和协议: + +``` +[dan@localhost ~]$ cat /etc/services | grep ssh +ssh 22/tcp # The Secure Shell (SSH) Protocol +ssh 22/udp # The Secure Shell (SSH) Protocol +``` + +你可以看到 SSH 同时使用 TCP 和 UDP 的 22 端口。此外,如果你希望查看所有可用的服务,只需使用 `firewall-cmd --get-services`。 + +#### 打开端口 + +如果要阻止端口、服务或协议,请确保在此处未列出它们。展开来说,如果要允许服务,那么需要将它添加到列表中。 + +假设你要打开 `5000` 端口用于 TCP 连接。为此,请运行: + +``` +sudo firewall-cmd --zone=FedorwaWorkstation --permanent --add-port=5000/tcp +``` + +请注意,你需要指定规则适用的域。添加规则时,还需要如上指定它是 `tcp` 还是 `udp` 端口。`--permanent` 参数将规则设置为即使系统重启后也可以保留。 + +再次查看你所在区域的信息: + +``` +[dan@localhost ~]$ firewall-cmd --list-all +FedoraWorkstation (active) +target: default +icmp-block-inversion: no +interfaces: enp0s3 +sources: +services: dhcpv6-client mdns samba-client ssh +ports: 1025-65535/udp 1025-65535/tcp 5000/tcp +protocols: +masquerade: no +forward-ports: +source-ports: +icmp-blocks: +rich rules: +``` + +类似地,如果你想从列表删除该端口,请运行: + +``` +sudo firewall-cmd --zone=FedorwaWorkstation --permanent --remove-port=5000/tcp +``` + +相同的 `remove` (`‐‐remove-protocol`、`‐‐remove-service`) 和 `add`(`‐‐add-protocol`、`‐‐add-service`)选项同样适用于*服务*和*协议*。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-manage-network-services-with-firewall-cmd/ + +作者:[dan01][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/dan01/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/05/services-firewall-cmd-816x345.jpg +[2]: https://linux.cn/article-12103-1.html +[3]: https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol +[4]: https://unsplash.com/@tkaiser?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[5]: https://unsplash.com/s/photos/poke-hole?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202006/20200511 Modify a disk image to create a Raspberry Pi-based homelab.md b/published/202006/20200511 Modify a disk image to create a Raspberry Pi-based homelab.md new file mode 100644 index 0000000000..256945adc4 --- /dev/null +++ b/published/202006/20200511 Modify a disk image to create a Raspberry Pi-based homelab.md @@ -0,0 +1,227 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12277-1.html) +[#]: subject: (Modify a disk image to create a Raspberry Pi-based homelab) +[#]: via: (https://opensource.com/article/20/5/disk-image-raspberry-pi) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +修改磁盘镜像来创建基于树莓派的家庭实验室 +====== + +> 使用树莓派或其它单板机创建一个“家庭私有云”。 + +![](https://img.linux.net.cn/data/attachment/album/202006/03/123435csm7ys7mkbw7ggjy.jpg) + +构建一个[家庭实验室][2]可以是一个有趣的方式,可以让你学习的新概念和实验新技术时还能自娱自乐。得益于以 [树莓派][3] 为首的单板计算机(SBC)的流行,在舒适的家里就可以轻松构建一个多计算机实验室。比起试图在主流的云服务商建立的相同配置,创建一个“家庭私有云”以花更少的钱来体验到云原生技术,也是一个极好的方法。 + +这篇文章阐述如何修改树莓派或其它的单板机的磁盘镜像,预配置主机的 SSH,并禁用首次启动时强制竞选交互配置的服务。这是一个让你的设备“即启动,即运行”的极好方法,类似于云端实例。之后,你可以使用自动化的流程通过 SSH 连接来进行更专业和更深入的配置。 + +此外, 当向你的实验室添加更多的树莓派时,修改磁盘镜像可以来让你只需要将该镜像写到一个 SD 卡、放入树莓派中就可以了! + +![Multiple Raspberry Pi computers, a switch, and a power bank][4] + +### 解压缩和挂载镜像 + +对于这个项目,你需要修改一个服务器磁盘镜像。在测试期间,我使用 [Fedora Server 31 ARM][5]。在你下载该磁盘镜像并[验证其校验和][6]之后,你需要将其解压缩并挂载其到宿主机的文件系统的某个位置上,以便你可以根据需要修改它。 + +你可以使用 [xz][7] 命令通过 `--decompress` 参数来解压缩 Fedora 服务器镜像: + + +``` +xz --decompress Fedora-Server-armhfp-X-y.z-sda.raw.xz +``` + +这会留下一个解压缩后的原始磁盘镜像(它会自动地替换 `.xz` 压缩文件)。这个原始磁盘镜像就像它听起来的那样:一个包含格式化后安装好的磁盘上的所有数据的文件。这包含分区信息、启动分区、root 分区以及其它分区。你需要挂载你打算在其中进行修改的分区,但是要做到这一点,你需要知道磁盘镜像中的分区起始位置和扇区大小,这样你才可以挂载该文件正确的扇区。 + +幸运的是,你可以在一个磁盘镜像上使用 [fdisk][8] 命令,就像在实际磁盘上使用一样容易。使用 `--list` 或 `-l` 参数来查看分区的列表和其信息: + +``` +# 使用 fdisk 来列出原始镜像文件的分区: +$ fdisk -l Fedora-Server-armhfp-31-1.9-sda.raw +Disk Fedora-Server-armhfp-X-y.z-sda.raw: 3.2 GiB, 3242196992 bytes, 6332416 sectors +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disklabel type: dos +Disk identifier: 0xdaad9f57 + +Device                               Boot   Start     End Sectors  Size Id Type +Fedora-Server-armhfp-X-y.z-sda.raw1         8192  163839  155648   76M  c W95 F +Fedora-Server-armhfp-X-y.z-sda.raw2 *     163840 1163263  999424  488M 83 Linux +Fedora-Server-armhfp-X-y.z-sda.raw3      1163264 6047743 4884480  2.3G 83 Linux +``` + +你需要的所有信息都可在上面的输出中获得。第 3 行表示扇区大小(包括逻辑和物理的):512 字节 / 512 字节。 + +设备列表显示的是原始磁盘镜像中的分区。第一个,`Fedora-Server-armhfp-X-y.z-sda.raw1` 毫无疑问是引导程序分区,因为它是第一个,很小(仅仅 76MB),而且类型被标识为 `c`,即 W95 FAT32(LBA),这是一个从 SD 卡启动的 FAT32 分区。 + +第二个分区也不是非常大,只有 488MB。这个分区是一个 Linux 原生类型分区(Id 83),它可能是包含内核和 [initramfs][9] 的 Linux 启动分区。 + +第三个分区可能是你需要的东西:它有 2.3GB 大小,所以在它其中应该有发行版的主要部分,并且它是一个 Linux 原生分区类型,这也是在预料之中的。这个分区应该包含了你需要修改的分区和数据。 + +第三个分区从扇区 1163264 开始(在 `fdisk` 的输出中被显示为 `Start` 列),所以你的挂载偏移量是 `595591168`,计算方法是将扇区大小(512)乘以起始扇区(1163264)(即 `512 * 1163264`)。这意味着你需要以偏移量 `595591168` 挂载该文件,才能挂载到正确位置。 + +装备了这些信息,现在你可以将第三个分区挂载到你的家目录中了: + +``` +$ mkdir ~/mnt +$ sudo mount -o loop,offset=595591168 Fedora-Server-armhfp-X-y.z-sda.raw ~/mnt +$ ls ~/mnt +``` + +### 直接在磁盘镜像中作业 + +在磁盘镜像被解压缩和被挂载到宿主机上的一个位置后,就可以修改镜像以符合你的需求。在我看来,对镜像进行更改的最简单的方法是使用 `chroot` 来将你会话的工作根目录更改为挂载镜像的工作根目录。不过,有点棘手。 + +在你改变了根目录后,你的会话将使用新的根目录下的二进制文件。除非你是在一个 ARM 系统做这些所有的操作,否则解压缩后的磁盘镜像的架构将与你正在使用的宿主机系统不同。即使在 chroot 环境中,宿主机系统也无法使用一个不同架构的二进制文件。至少,不能在本机使用。 + +幸运的是,这里有一个解决方案:qemu-user-static。来自 [Debian Wiki][10] 的说明: + +> “[qemu-user-static] 提供了用户模式的仿真二进制文件,是静态构建的。在这个模式中,QEMU 可以在一个 CPU 上启动为另一个 CPU 编译的 Linux 进程 …… 如果安装了 binfmt-support 软件包,qemu-user-static 软件包会注册提供的仿真器可以处理的二进制文件格式,以便其能够直接运行其他架构的二进制文件。” + +这正是你需要在 chroot 环境中非本地架构中工作所需的。如果宿主机系统是 Fedora,使用 DNF 来安装 `qemu-user-static` 软件包,并重新启动 `systemd-binfmt.service`: + +``` +# 使用 DNF 启用非本地的 arch chroot 环境,添加新的二进制文件格式信息 +# 输出镜像了精简 +$ dnf install qemu-user-static +$ systemctl restart systemd-binfmt.service +``` + +使用这种方法,你一个能够更改根目录到挂载的磁盘镜像,运行 `uname` 命令来验证一切都在正常: + +``` +sudo chroot ~/mnt/ /usr/bin/uname -a -r +Linux marvin 5.5.16-200.fc31.x86_64 #1 SMP Wed Apr 8 16:43:33 UTC 2020 armv7l armv7l armv7l GNU/Linux +``` + +在 chroot 环境中运行 `uname` 将在输出中显示 `armv7l`,这个原始磁盘镜像的架构, 而不是宿主机的架构。一切如预期,可以继续修改镜像了。 + +### 修改磁盘镜像 + +现在你可以直接切换到这个基于 ARM 的磁盘镜像中,并在该环境中工作了,你可以对镜像自身镜像修改了。你需要设置该镜像,以便它能够启动并可立即访问,而不需要在树莓派上做任何额外的设置。为此,你需要安装并启用 sshd(OpenSSH 守护进程),并为 SSH 访问添加授权密码。 + +为了使其表现得更像一个云环境,实现在家里建立私有云的梦想,添加一个本地用户,给予该用户 `sudo` 权限,并(为了像云端的重度用户一样)允许该用户无需密码就可以使用 `sudo`。 + +所以,你将做的事情是: + + * 安装并启用 SSHD(SSHD 已经在 Fedora ARM 镜像中安装并启用,但是你可能需要为你发行版手动执行这些工作) + * 设置一个本地用户 + * 允许本地用户来使用 `sudo`(无需密码,可选) + * 添加授权密钥 + * 允许 root 使用授权密码镜像 SSH(可选) + +我使用 GitHub 功能,它允许你上传你的 SSH 公钥,并在 [https://github.com/.keys][11] 处可访问。我发现这是一种很方便的分发公钥的方法,不过我生性多疑,我总是检查下载的密钥是否与我预期的匹配。如果你不想使用这种方法,你可以从你宿主机中复制你公钥到 chroot 环境中,或者你可以将公钥托管在你控制的 Web 服务器上以便使用相同的工作流。 + +要开始修改磁盘镜像,再次切换根目录到挂载的磁盘镜像中,这次启动一个 shell,以便可以运行多个命令: + +``` +# 为了简洁起见,省略了这些命令的输出(如果有的话) +$ sudo chroot ~/mnt /bin/bash + +# 安装 openssh-server ,并启用它 (在 Fedora 上已经完成) +$ dnf install -y openssh-server +$ systemctl enable sshd.service + +# 允许 root 使用授权密码访问 SSH +$ mkdir /root/.ssh + +# 下载或者另外添加授权密码文件,你的公共密码 +# 将 URL 替换为你自己公共密码的路径 +$ curl -o /root/.ssh/authorized_keys +$ chmod 700 /root/.ssh +$ chmod 600 /root/.ssh/authorized_keys + +# 添加一个本地用户,并放置他们到 wheel 组中 +# 将组和用户更改为您想要的一切 +useradd -g chris -G wheel -m -u 1000 chris + +# 下载并添加你的授权密码 +# 像你上面所做的那样更改 home 目录和URL +mkdir /home/chris/.ssh +curl -o /home/chris/.ssh/authorized_keys +chmod 700 /home/chris/.ssh +chmod 600 /home/chris/.ssh/authorized_keys +chown -R chris.chris /home/chris/.ssh/ + +# 允许 wheel 组( 使用你的本地用户) 不需要使用密码来使用 suso +echo "%wheel ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/91-wheel-nopasswd +``` + +这就是树莓派或其它单板机在首次启动时需要完成设置 SSH 的全部工作。不过,每个发行版都有自己的特点。例如,Raspbian 已经包含一个本地用户:`pi`,并且不使用 `wheel` 组。因此对于 Raspbian 来说,最好使用现有用户,或者删除 `pi` 用户,并使用另一个用户来替换它。 + +在 Fedora ARM 的情况下,镜像会在首次引导启动时提示你完成设置。这会破坏你在上面所做的修改的目的,尤其是在设置完成之前,它会完全阻止启动。你的目标是使树莓派的功能类似于私有云的基础设施的一部分一样运行,而这个工作流程包括在主机启动时通过 SSH 远程设置主机。 禁用初始化设置,它由 `initial-setup.service` 控制: + +``` +# 对多用户和图形目标禁用 initial-setup.service +unlink /etc/systemd/system/multi-user.target.wants/initial-setup.service +unlink /etc/systemd/system/graphical.target.wants/initial-setup.service +``` + +当你在 chroot 环境时,你可以对你系统做任何你想做的其它更改,或者就放在那里,在第一次启动后,按照云原生的工作流通过 SSH 进行配置。 + +### 重新压缩并安装修改后的镜像 + +完成了这些更改后,剩下的就是重新压缩磁盘镜像,并将其安装其到你的树莓派的 SD 卡上。 + +确保退出 chroot 环境,然后卸载磁盘镜像: + +``` +$ sudo umount ~/mnt/ +``` + +就像最初解压缩镜像一样,你可以再次使用 `xz` 命令来压缩镜像。通过使用 `--keep` 参数,`xz` 将保留原始的镜像,而不是清理掉它。虽然这会占用更多的磁盘空间,但保留下来的未压缩镜像将允许你对正在处理的镜像进行增量更改,而不需要每次都对其进行解压缩。这对于在测试和调整镜像时节省时间是非常好的。 + +``` +# 压缩压缩磁盘镜像为一个 .xz 文件,但保留原始磁盘镜像 +xz --compress Fedora-Server-armhfp-31-1.9-sda.raw --keep +``` + +压缩过程将花费一些时间,所以趁着这个时间站起来,舒展身体,让你的血液再次流动。 + +在压缩完成后,可以将新的、已修改过的磁盘镜像复制到 SD 卡上,以便与树莓派一起使用。标准的 `dd` 方法将镜像放置到 SD 卡上也很好用,但是我喜欢使用 Fedora 的 `arm-image-installer`,因为它因为它在处理未经编辑的镜像时提供了一些选项。它对编辑过的镜像也很好用,并且比 `dd` 命令更友好一些。 + +确保检查 SD 卡在哪个磁盘驱动器上,并用 `--media` 参数使用它: + +``` +# 使用 arm-image-installer 来复制已修改的磁盘镜像到 SD 卡上 +arm-image-installer --image=Fedora-Server-armhfp-X-y.z-sda.raw.xz --target=rpi3 --media=/dev/sdc --norootpass --resizefs -y +``` + +现在,你已经为树莓派或其它单板机准备好了一个新的、已修改的 Fedora Server ARM 镜像,准备好启动并立即 SSH 到你的修改镜像中。这种方法也可以用来做其它的修改,并且你也可以使用其它发行版的原始磁盘镜像,如果你更喜欢它们,而不是 Fedora 的话。这是一个开始构建家庭实验室私有云的良好基础。在以后的文章中,我将指导你使用云技术和自动化建立一个家庭实验室。 + +### 延伸阅读 + +为了学习如何做这篇文章中的事情,我做了很多研究。以下是我找到的两个对学习如何定制磁盘映像和使用非原生架构最有帮助的资料。它们对我从“不知道自己在做什么”到“我能够完成它!”非常有帮助。 + + * [如何修改你的自定义 Linux 发行版的原始磁盘镜像][12] + * [使用 DNF 维基][13] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/disk-image-raspberry-pi + +作者:[Chris Collins][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://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/science_experiment_beaker_lab.png?itok=plKWRhlU (Science lab with beakers) +[2]: https://opensource.com/article/19/3/home-lab +[3]: https://opensource.com/resources/raspberry-pi +[4]: https://opensource.com/sites/default/files/uploads/raspberrypi_homelab.jpg (Multiple Raspberry Pi computers, a switch, and a power bank) +[5]: https://arm.fedoraproject.org/ +[6]: https://arm.fedoraproject.org/verify.html +[7]: https://tukaani.org/xz/ +[8]: https://en.wikipedia.org/wiki/Fdisk +[9]: https://wiki.debian.org/initramfs +[10]: https://wiki.debian.org/RaspberryPi/qemu-user-static +[11]: https://github.com/%3Cyour_github_username%3E.keys +[12]: https://www.linux.com/news/how-modify-raw-disk-image-your-custom-linux-distro/ +[13]: https://wiki.mageia.org/en/Using_DNF#Setting_up_a_container_for_a_non-native_architectur diff --git a/published/202006/20200514 How IoT will rescue aviation.md b/published/202006/20200514 How IoT will rescue aviation.md new file mode 100644 index 0000000000..c6cd6c0ee8 --- /dev/null +++ b/published/202006/20200514 How IoT will rescue aviation.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12367-1.html) +[#]: subject: (How IoT will rescue aviation) +[#]: via: (https://www.networkworld.com/article/3543318/how-iot-will-rescue-aviation.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +物联网将如何拯救航空业 +====== + +> 为防止感染新冠病毒的乘客登机,欧洲飞机制造商,空中客车公司正在研究能够识别病毒的物联网传感器。 + +![Stéphan Valentin][1] + +一家开发传感器来探测飞机上和机场中的爆炸物和其他化学物品的生物技术公司正在和空中客车合作,一同开发一种可以检测已经感染新冠病毒乘客的传感器。 + +Koniku 的创始人兼首席执行管 Osh Agabi 在[一篇博文][3]中说,总部位于加州的 Konibu 公司和空中客车(Airbus)公司从 2017 年就开始合作共同开发能够探测出不同化学物质的非接触式设备。 + +他们希望通过识别从呼吸或者汗液中的气味来判断是否感染新冠病毒,因为这些气味可能是新冠病毒中化学物质的标记。“大多数感染和疾病都会或多或少的改变我们呼吸和汗液里的化学成分,也就会产生不同的气味,” Agabi 写道。“如果我们检测到这些气味,我们就可以检测是否存在感染。” + +这两家公司希望能够识别这种新冠病毒的特异性标记,并且能找到一种可以检测这些标记的物联网(IoT)传感器,这些传感器配备有通过基因工程改造过的受体,从而对病毒进行探测。“那些受体会过滤空气中的分子,并且当它们接触到已经提前被编程检测的存在威胁或危险的分子化合物的时候,就会产生一个信号,”他写道。 + +他说,乘客将通过走过一个装有传感器的封闭通道来进行筛选。“通过对构成这些受体细胞中的 DNA 进行编程,使其对出现在感染者呼吸或者汗液中的化合物作出反应,我们相信,我们将能够迅速且可靠地筛查新冠病毒,并且确定一个人是否已经被感染,”他写道。 + +其他类型的非接触检测器已经在使用中了,包括皮肤温度升高elevated-skin-temperature(EST)摄像头。 + +意大利的最主要的机场 Leonardo da Vinci 购置了三个热成像头盔来发现发烧的人。机场已经配备了固定的热感应扫描仪,并且订购了更多的这种设备。[根据当地媒体 Fiumicino Online 的报道][5],被发现潜在发烧的乘客被会要求做进一步的医学检查。 + +位于中国深圳制造这种头盔的 KC Wearable 公司表示,这种头盔可以由员工佩戴,并且可以与乘客保持一定的距离。 + +制造热感应摄像头的 FLIR Systems 公司在其本月的[财报][6]中表示,对 EST 系统的需求正在持续增加。 + +“尽管这些热感应摄像头不能检测或者诊断任何医疗状况,但这些摄像头可以作为识别皮肤温度升高的有效工具。”报告说。 + +FLIR 公司 CEO Jim Cannon 在本月的收入电话会议上表示,“许多公司都在寻求在他们的设施中安装这种技术,以便解除就地避难shelter-in-place法令”。[根据路透社报道][8],通用汽车就是其中之一。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3543318/how-iot-will-rescue-aviation.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2018/08/passenger-view_of_airplane_wing_above_clouds_travel_journey_transportation_by_stephan_valentin_cc0_via_unsplash_1200x800-100766542-large.jpg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.linkedin.com/pulse/what-happens-when-airports-open-back-up-osh-agabi/?src=aff-lilpar&veh=aff_src.aff-lilpar_c.partners_pkw.10078_plc.Skimbit%20Ltd._pcrid.449670_learning&trk=aff_src.aff-lilpar_c.partners_pkw.10078_plc.Skimbit%20Ltd._pcrid.449670_learning&clickid=WNmzMlyalxyOUI7wUx0Mo34HUkiwwpy%3APQ3X1Y0&irgwc=1 +[4]: https://www.networkworld.com/newsletters/signup.html +[5]: https://www.fiumicino-online.it/articoli/cronaca-2/fase-2-all-aeroporto-di-fiumicino-lo-smart-helmet-per-controllare-la-febbre-a-distanza +[6]: https://flir.gcs-web.com/news-releases/news-release-details/flir-systems-announces-first-quarter-2020-financial-results +[7]: https://www.fool.com/earnings/call-transcripts/2020/05/06/flir-systems-inc-flir-q1-2020-earnings-call-transc.aspx +[8]: https://uk.reuters.com/article/us-flir-systems-gm/general-motors-taps-flir-systems-for-fever-check-cameras-at-factories-idUKKBN22J02B +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/published/202006/20200525 How to Execute a Command or Script at Reboot or Startup.md b/published/202006/20200525 How to Execute a Command or Script at Reboot or Startup.md new file mode 100644 index 0000000000..f3e2a0e45d --- /dev/null +++ b/published/202006/20200525 How to Execute a Command or Script at Reboot or Startup.md @@ -0,0 +1,151 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12279-1.html) +[#]: subject: (How to Execute a Command or Script at Reboot or Startup) +[#]: via: (https://www.2daygeek.com/execute-run-linux-scripts-command-at-reboot-startup/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何在重启或启动时执行命令或脚本 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/04/091837g664qu0y206aqoo9.jpg) + +众总所周知 Linux 可以在启动时添加服务。例如,如果要在[启动时添加][1] Apache Httpd 服务,你可以在 `chkconfig` 和 `systemctl` 命令的帮助下完成此操作。 + +有时你需要在启动时添加自定义脚本、命令或服务,该怎么做?你可以使用以下三种方法来做到。 + +在本文中,我们将通过示例向你展示如何使用这些方法。 + +### 方法 1:如何使用 /etc/rc.d/rc.local 文件在重启或启动时运行脚本或命令 + +传统上,`/etc/rc.local` 文件是在切换到多用户运行级别的过程结束时,在所有正常的计算机服务启动之后执行的。 + +此方法也适用于 systemd 系统。 + +你需要将你的脚本位置添加到 `/etc/rc.d/rc.local` 文件中以在启动时运行。 + +确保该文件有运行权限: + +``` +# chmod +x /etc/rc.d/rc.local +``` + +作为演示,我们将创建一个简单的示例脚本。你可以根据需要创建任何脚本。 + +``` +# vi /opt/scripts/run-script-on-boot.sh + +#!/bin/bash +date > /root/on-boot-output.txt +hostname > /root/on-boot-output.txt +``` + +脚本完成后,设置可执行权限: + +``` +# chmod +x /opt/scripts/run-script-on-boot.sh +``` + +最后,将该脚本添加到文件底部: + +``` +# vi /etc/rc.d/rc.local + +/opt/scripts/run-script-on-boot.sh +``` + +[重启系统][2]进行检查: + +``` +# reboot +``` + +### 方法 2:如何使用 crontab 在重启或启动时执行命令或脚本 + +cron 在特定时间在后台自动执行计划的作业。可以在 [cron 任务][3]中使用特殊的字符串 `@reboot` 来完成。`@reboot` 是一个特殊的字符串,它允许用户在启动时运行任何命令或脚本。 + +此示例在系统重启时运行 `/opt/scripts/run-script-on-boot.sh` 文件。我们将使用与上面相同的脚本。 + +为此,只需在 crontab 文件中添加以下条目: + +``` +# crontab -e + +@reboot /opt/scripts/run-script-on-boot.sh +``` + +重启系统进行检查: + +``` +# reboot +``` + +### 方法 3:如何使用 systemd 服务单元在重启或启动时运行命令或脚本 + +此方法仅适用于 systemd 系统。该方法非常简单。 + +我们将使用上面相同的脚本进行演示。 + +为此,你需要创建一个 systemd 启动脚本并将其放在 `/etc/systemd/system/` 目录中。 + +这是我们的示例 systemd 启动单元脚本: + +``` +# vi sample-on-boot-script.service + +[Unit] +Description=Run a Custom Script at Startup +After=default.target + +[Service] +ExecStart=/opt/scripts/run-script-on-boot.sh + +[Install] +WantedBy=default.target +``` + +将单元脚本放置在 systemd 所在位置后,运行以下命令更新 systemd 配置文件并启用服务: + +``` +# systemctl daemon-reload +# systemctl enable sample-on-boot-script.service +``` + +重启系统进行检查: + +``` +# reboot +``` + +### 额外提示 + +如果你想在后台运行脚本,你需要在最后加上 `&` 符号 + +``` +/Path/To/My_Script & +``` + +如果你想以不同用户运行命令,使用以下格式: + +``` +su - $USER -c /Path/To/My_Script +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/execute-run-linux-scripts-command-at-reboot-startup/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/enable-disable-services-on-boot-linux-chkconfig-systemctl-command/ +[2]: https://www.2daygeek.com/6-commands-to-shutdown-halt-poweroff-reboot-the-linux-system/ +[3]: https://www.2daygeek.com/linux-crontab-cron-job-to-schedule-jobs-task/ diff --git a/published/202006/20200525 How to Make a GIF in GIMP -Simple Tutorial.md b/published/202006/20200525 How to Make a GIF in GIMP -Simple Tutorial.md new file mode 100644 index 0000000000..5d9f949b7f --- /dev/null +++ b/published/202006/20200525 How to Make a GIF in GIMP -Simple Tutorial.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12289-1.html) +[#]: subject: (How to Make a GIF in GIMP [Simple Tutorial]) +[#]: via: (https://itsfoss.com/make-gif-in-gimp/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +初级:如何在 GIMP 中制作 GIF +====== + +制作一个 GIF 可能是一件很有趣的事,很多用户可能都想如何制作一个 GIF。你可以使用功能强大的开源图像编辑软件 [GIMP][1] 创建一个非常简单的 GIF。 + +在这篇 GIMP 教程中,我将向你展示如何在 GIMP 中创建一个简单的 GIF。 + +### 在 GIMP 中制作一个 GIF + +![][2] + +使用 GIMP 作为一个动画制作工具需要你把每个图层都看作动画的一帧。在这篇教程中,我将创建一个简单的基于我们的徽标的网页横幅。我将使用 2 个图像作为我的图层,但当你制作自己的 GIF 时,你可以随意添加更多的图像。 + +我在这里使用的方法叫做“组合法”,在这个方法中,新的帧被添加到先前的帧中。我的想法是制作一个“频闪”的网页横幅,来在对一些重要的事情引起注意。 + +我假设你已经 [在 Ubuntu 或其它使用的操作系统中安装了 GIMP][3]。让我们开始制作 GIF 吧。 + +#### 步骤 1 + +从“文件”菜单中,单击“作为图层打开”,并选择你想包含在 GIF 中的所有图像。然后单击“打开”。 + +![][4] + +你可以排序图层标签页中的图像。GIF 的帧序列将从最下面的图层开始,从下到上运行每一层图层。 + +![][5] + +从主菜单中选择“滤镜”,接着选择“动画”,最后单击“优化(用于 GIF)”。 + +![][6] + +> “优化”做了什么? +> +> 优化会检查每一个图层,如果来自前一帧的信息在下一帧中没有改变,则重复使用这些信息。它只存储新更改的像素值,并清除任何重复的部分。 +> +> 如果一帧与前一帧完全相同,那么它将完全删除这一幅帧,并且前一帧将恰当地在屏幕上停留更长时间。 + +要查看该 GIF,从主菜单中单击“滤镜”,接着单击“动画”和“回放”。 + +![][7] + +按下“回放”按钮来启动 GIF。要保存该 GIF,在文件菜单上选择“文件”,单击“导出为”。 + +![][8] + +命名你的 GIF,并选择你想将其保存到的文件夹。在“选择文件类型”时,选择 “GIF 图像”。 + +![][9] + +当提示时,选择“作为动画”、“反复循环”,设置期望的延迟值,并单击“上面输入的延迟用于所有帧”来生效。 + +最重要的选项是设置帧处理动作为“累积各图层(组合)”,以便为我们的横幅获取“频闪”效果。单击“导出”作为最后一个步骤。 + +![][10] + +你的 GIF 已经准备好了! + +![][11] + +这是一个浅显易懂的示例,不过 GIMP 在动画创作方面有很多能力,需要大量的学习和实践才能掌握它。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/make-gif-in-gimp/ + +作者:[Dimitrios Savvopoulos][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/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://www.gimp.org/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/create-gif-in-gimp.jpg?ssl=1 +[3]: https://itsfoss.com/gimp-2-10-release/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/1.-open-as-layers.jpeg?ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/layers-order.jpg?ssl=1 +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/2.-optimize-for-gif-1.png?fit=800%2C647&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/3.-playback.png?fit=800%2C692&ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/4.-export-as.png?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/5.-save-as-gif.png?fit=800%2C677&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/6.-export-options-1.png?ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/its-foss-logo.gif?fit=800%2C417&ssl=1 +[12]: https://itsfoss.com/subscribe-to-newsletter/ diff --git a/published/202006/20200525 How to Manipulate an Ethernet Card Using the ethtool Command.md b/published/202006/20200525 How to Manipulate an Ethernet Card Using the ethtool Command.md new file mode 100644 index 0000000000..faf7eb196d --- /dev/null +++ b/published/202006/20200525 How to Manipulate an Ethernet Card Using the ethtool Command.md @@ -0,0 +1,304 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12290-1.html) +[#]: subject: (How to Manipulate an Ethernet Card Using the ethtool Command) +[#]: via: (https://www.2daygeek.com/linux-ethtool-command-view-change-ethernet-adapter-settings-nic-card/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何使用 ethtool 命令管理以太网卡 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/06/223359syh8n37luz8hhllh.jpg) + +`ethtool` 用于查看和修改网络设备(尤其是有线以太网设备)的驱动参数和硬件设置。你可以根据需要更改以太网卡的参数,包括自动协商、速度、双工和局域网唤醒等参数。通过对以太网卡的配置,你的计算机可以通过网络有效地进行通信。该工具提供了许多关于接驳到你的 Linux 系统的以太网设备的信息。 + +在这篇文章中,我们将告诉你如何更改以下的参数以及如何查看这些参数。这篇文章将帮助你在 Linux 系统中排除与以太网卡相关的问题。 + +下面的信息将帮助你了解以太网卡的工作原理。 + +* **半双工**:半双工模式允许设备一次只能发送或接收数据包。 +* **全双工**:全双工模式允许设备可以同时发送和接收数据包。 +* **自动协商**:自动协商是一种机制,允许设备自动选择最佳网速和工作模式(全双工或半双工模式)。 +* **速度**:默认情况下,它会使用最大速度,你可以根据自己的需要改变它。 +* **链接检测**:链接检测可以显示网卡的状态。如果显示为 `no`,请尝试重启网卡。如果链路检测仍显示 `no`,则检查交换机与系统之间连接的线缆是否有问题。 + +### 如何在 Linux 上安装 ethtool + +默认情况下,大多数系统上应该已经安装了 `ethtool`。如果没有,你可以从发行版的官方版本库中安装。 + +对于 RHEL/CentOS 6/7 系统,请使用 [yum 命令][1] 安装 `ethtool`: + +``` +$ sudo yum install -y ethtool +``` + +对于 RHEL/CentOS 8 和 Fedora 系统,请使用 [dnf 命令][2] 安装 `ethtool`: + +``` +$ sudo yum install -y ethtool +``` + +对于基于 Debian 的系统,请使用 [apt 命令][3] 或 [apt-get 命令][4] 安装 `ethtool`: + +``` +$ sudo apt-get install ethtool +``` + +对于 openSUSE 系统,使用 [zypper 命令][5] 安装 `ethtool`: + +``` +$ sudo zypper install -y ethtool +``` + +对于 Arch Linux 系统,使用 [pacman 命令][6] 安装 `ethtool`: + +``` +$ sudo pacman -S ethtool +``` + +### 如何检查 Linux 上的可用网络接口 + +你可以使用 [ip 命令][7]或 `ifconfig` 命令(在现代发行版中已被淘汰)来验证可用的、活动的网卡的名称和其他细节: + +``` +# ip a +或 +# ifconfig + +1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + valid_lft forever preferred_lft forever +2: eth0: mtu 1500 qdisc mq state UP group default qlen 1000 + link/ether 00:10:22:35:23:sf brd ff:ff:ff:ff:ff:ff + inet 192.164.23.100/24 brd 192.164.23.255 scope global eth0 + valid_lft forever preferred_lft forever +``` + +### 如何检查 Linux 上的网卡(NIC)信息 + +掌握了以太网卡名称后,就可以使用 `ethtool` 命令轻松查看其详细信息,如下所示。 + +在 Linux 系统中,每个网卡(NIC)都被分配了唯一的名称,如 ethX、enpXXX 等。 + +* 旧的 Linux 发行版使用的是 `eth[X]` 格式。例如,RHEL 6 和它们的旧版本。 +* 现代的 Linux 发行版使用 `enp[XXX]` 或 `ens[XXX]` 格式。例如,大多数现代 Linux 发行版都使用这种格式,包括 RHEL 7、Debian 10、Ubuntu 16.04 LTS。 + +``` +# ethtool eth0 + +Settings for eth0: + Supported ports: [ TP ] + Supported link modes: 1000baseT/Full + 10000baseT/Full + Supported pause frame use: No + Supports auto-negotiation: No + Supported FEC modes: Not reported + Advertised link modes: Not reported + Advertised pause frame use: No + Advertised auto-negotiation: No + Advertised FEC modes: Not reported + Speed: 10000Mb/s + Duplex: Full + Port: Twisted Pair + PHYAD: 0 + Transceiver: internal + Auto-negotiation: off + MDI-X: Unknown + Supports Wake-on: uag + Wake-on: d + Link detected: yes +``` + +### 如何检查以太网卡的驱动程序和固件版本 + +你可以使用 `ethtool` 命令的 `-i` 选项检查驱动程序版本、固件版本和总线的详细信息,如下所示: + +``` +# ethtool -i eth0 + +driver: vmxnet3 +version: 1.4.16.0-k-NAPI +firmware-version: +expansion-rom-version: +bus-info: 0000:0b:00.0 +supports-statistics: yes +supports-test: no +supports-eeprom-access: no +supports-register-dump: yes +supports-priv-flags: no +``` + +### 如何检查网络使用情况统计 + +你可以使用 `ethtool` 命令中的 `-S` 选项来查看网络使用情况统计。它可以显示传输的字节数、接收的字节数、错误数等。 + +``` +# ethtool -S eth0 + +NIC statistics: + Tx Queue#: 0 + TSO pkts tx: 2053 + TSO bytes tx: 7167572 + ucast pkts tx: 4028081 + ucast bytes tx: 399093197 + mcast pkts tx: 0 + mcast bytes tx: 0 + bcast pkts tx: 0 + bcast bytes tx: 0 + pkts tx err: 0 + pkts tx discard: 0 + drv dropped tx total: 0 + too many frags: 0 + giant hdr: 0 + hdr err: 0 + tso: 0 + ring full: 0 + pkts linearized: 0 + hdr cloned: 0 + giant hdr: 0 + Tx Queue#: 1 + TSO pkts tx: 1955 + TSO bytes tx: 6536945 + ucast pkts tx: 3711838 + ucast bytes tx: 346309662 + mcast pkts tx: 0 + mcast bytes tx: 0 + bcast pkts tx: 1186 + bcast bytes tx: 49812 + pkts tx err: 0 + pkts tx discard: 0 + drv dropped tx total: 0 + too many frags: 0 + giant hdr: 0 + hdr err: 0 + tso: 0 + ring full: 0 + pkts linearized: 0 + hdr cloned: 0 + giant hdr: 0 + Rx Queue#: 0 + LRO pkts rx: 0 + LRO byte rx: 0 + ucast pkts rx: 5084776 + ucast bytes rx: 4673133395 + mcast pkts rx: 0 + mcast bytes rx: 0 + bcast pkts rx: 154143 + bcast bytes rx: 45415676 + pkts rx OOB: 0 + pkts rx err: 0 + drv dropped rx total: 0 + err: 0 + fcs: 0 + rx buf alloc fail: 0 + Rx Queue#: 1 + LRO pkts rx: 0 + LRO byte rx: 0 + ucast pkts rx: 6346769 + ucast bytes rx: 4835534292 + mcast pkts rx: 0 + mcast bytes rx: 0 + bcast pkts rx: 3464 + bcast bytes rx: 714646 + pkts rx OOB: 0 + pkts rx err: 0 + drv dropped rx total: 0 + err: 0 + fcs: 0 + rx buf alloc fail: 0 + tx timeout count: 0 +``` + +### 如何改变以太网设备的速度 + +你可以根据需要改变以太网的速度。当你进行此更改时,网卡将自动掉线,你需要使用 [ifup 命令][8] 或 `ip` 命令或 `nmcli` 命令将其重新上。 + +``` +# ethtool -s eth0 speed 100 +# ip link set eth0 up +``` + +### 如何在 Linux 上启用/禁用以太网卡的自动协商? + +你可以使用 `ethtool` 命令中的 `autoneg` 选项启用或禁用自动协商,如下图所示: + +``` +# ethtool -s eth0 autoneg off +# ethtool -s eth0 autoneg on +``` + +### 如何同时更改多个参数 + +如果你想使用 `ethtool` 命令同时更改以太网卡的多个参数,请使用下面的格式: + +``` +Syntax: +ethtool –s [device_name] speed [10/100/1000] duplex [half/full] autoneg [on/off] +``` + +``` +# ethtool –s eth0 speed 1000 duplex full autoneg off +``` + +### 如何检查特定网卡的自动协商、RX 和 TX + +要查看关于特定以太网设备的自动协商等详细信息,请使用以下格式: + +``` +# ethtool -a eth0 +``` + +### 如何从多个设备中识别出特定的网卡(闪烁网卡上的 LED) + +如果你想识别一个特定的物理接口,这个选项非常有用。下面的 `ethtool` 命令会使 `eth0` 端口的 LED 灯闪烁: + +``` +# ethtool -p eth0 +``` + +### 如何在 Linux 中永久设置这些参数 + +在系统重启后,你使用 `ethtool` 所做的更改将被默认恢复。 + +要使自定义设置永久化,你需要更新网络配置文件中的值。根据你的 Linux 发行版,你可能需要将此值更新到正确的文件中。 + +对于基于 RHEL 的系统。你必须使用 `ETHTOOL_OPTS` 变量: + +``` +# vi /etc/sysconfig/network-scripts/ifcfg-eth0 + +ETHTOOL_OPTS="speed 1000 duplex full autoneg off" +``` + +对于基于 Debian 的系统: + +``` +# vi /etc/network/interfaces + +post-up ethtool -s eth0 speed 1000 duplex full autoneg off +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-ethtool-command-view-change-ethernet-adapter-settings-nic-card/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-yum-command-examples-manage-packages-rhel-centos-systems/ +[2]: https://www.2daygeek.com/linux-dnf-command-examples-manage-packages-fedora-centos-rhel-systems/ +[3]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[4]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[5]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[6]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[7]: https://www.2daygeek.com/ip-command-configure-network-interface-usage-linux/ +[8]: https://www.2daygeek.com/enable-disable-up-down-nic-network-interface-port-linux-using-ifconfig-ifdown-ifup-ip-nmcli-nmtui/ diff --git a/published/202006/20200525 How to Remove Files Older than N Days Using Tmpwatch-Tmpreaper on Linux.md b/published/202006/20200525 How to Remove Files Older than N Days Using Tmpwatch-Tmpreaper on Linux.md new file mode 100644 index 0000000000..5f0859154c --- /dev/null +++ b/published/202006/20200525 How to Remove Files Older than N Days Using Tmpwatch-Tmpreaper on Linux.md @@ -0,0 +1,182 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12284-1.html) +[#]: subject: (How to Remove Files Older than N Days Using Tmpwatch/Tmpreaper on Linux) +[#]: via: (https://www.2daygeek.com/how-to-remove-files-older-than-n-days-using-tmpwatch-tmpreaper-on-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +如何使用 Tmpwatch/Tmpreaper 删除旧文件 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/05/091806zrnwahdl9fdyznrw.jpg) + +你可能忘记了删除计算机上某个目录中不再需要的文件的操作。这可能是“下载”或任何其他目录。它可能已经增长了一段时间。 + +即便有足够的存储空间,你也应该删除它们,因为这会在列出文件时降低系统速度。同样,当一个目录中有成千上万个文件时,它可能很会很臃肿。 + +当你不知道要检查的文件名时,很难在特定目录中找到文件。 + +我们可以通过结合使用 `find` 命令和一些组合来做到这一点,我们过去已经写过一篇文章。 + +* [使用 Bash 脚本在 Linux 中删除早于 “X” 天的文件/文件夹][1] + +今天,我们将向你展示如何在 Linux 上使用 Tmpwatch 程序来实现这一目标。 + +### 什么是 tmpwatch + +`tmpwatch` 会在指定目录中递归删除指定时间段内未被访问的文件。通常,它用于自动清除临时文件系统目录,例如 `/tmp` 和 `/var/tmp`。 + +它只会删除空目录、常规文件和符号链接。它不会切换到其他文件系统,并避开了属于根用户的 `lost+found` 目录。 + +默认情况下,`tmpwatch` 会根据文件的 atime(访问时间)而不是 mtime(修改时间)删除文件。 + +你可以在 `tmpwatch` 命令中添加其他参数来更改这些行为。 + +**警告:** 请不要在 `/` 中运行 `tmpwatch` 或 `tmpreaper`,因为该程序中没有防止这种情况的机制。 + +### 如何在 Linux 上安装 tmpwatch + +可以在官方仓库中按以下方式安装 `tmpwatch`。 + +对于 RHEL/CentOS 6 系统,请使用 [yum 命令][2]安装 `tmpwatch`。 + +``` +$ sudo yum install -y tmpwatch +``` + +对于 Debian 和 Ubuntu 系统,请使用 [apt 命令][3] 或 [apt-get 命令][4] 安装 `tmpreaper`。 + +``` +$ sudo apt-get install tmpreaper +``` + +对于 openSUSE 系统,请使用 [zypper 命令][5] 安装 `tmpwatch`。 + +``` +$ sudo zypper install -y tmpwatch +``` + +对于 Fedora 系统,请使用 [dnf 命令][6] 安装 `tmpwatch`。 + +``` +$ sudo dnf install -y tmpwatch +``` + +**请注意:** 如果你使用的是基于 Debian 的系统,请使用 `tmpreaper` 而不是 `tmpwatch`。所有示例都可以如预期工作。 + +### 了解关键选项和参数 + +* `atime`(文件上次访问时间):显示命令或脚本等任意进程最后一次访问文件中数据的时间。 +* `mtime`(文件上次修改时间):显示修改文件内容或保存文件的时间。除非是更改文件属性,否则大多数情况下 `ctime` 和 `mtime` 会相同。 +* `ctime`(文件上次更改时间):显示文件元数据更改时间。这意味着更改文件属性的时间(如所有权或组等)。 +* `dirmtime`(目录的上次修改时间):显示目录的上一次修改时间。 + +时间参数定义删除文件的阈值。 + +* `d` – 天 +* `h` – 小时 +* `m` – 分钟 +* `s` – 秒 + +### 如何使用 tmpwatch 命令删除一段时间未访问的文件 + +正如我在本文开头所说,`tmpwatch` 默认根据文件访问时间(`atime`)来删除文件。另外,由于小时是默认参数,因此如果使用小时单位,那么无需在时间上添加后缀。 + +例如,运行以下命令以递归方式删除过去 5 个小时未访问的文件。 + +``` +# tmpwatch 5 /tmp +``` + +运行以下命令删除最近 10 个小时未修改的文件。如果要使用修改时间(`mtime`)来删除文件,那么需要在 `tmpwatch` 命令中添加 `-m` 选项。 + +``` +# tmpwatch -m 10 /home/daygeek/Downloads +``` + +### 如何使用 tmpwatch 命令删除超过 “X” 天未访问的文件 + +如果要使用天数删除文件,那么需要添加后缀 `d`。以下示例删除了 30 天以上的文件。 + +``` +# tmpwatch 30d /home/daygeek/Downloads +``` + +### 如何使用 tmpwatch 命令删除一段时间内未访问的所有文件 + +以下命令将基于修改时间(`mtime`)删除所有类型的文件,而不仅仅是常规文件、符号链接和目录。 + +``` +# tmpwatch -am 12 /tmp +``` + +### 如何在 tmpwatch 中排除目录 + +以下命令将删除过去 10 个小时未修改的所有文件,并排除目录。 + +``` +# tmpwatch -am 10 --nodirs /home/daygeek/Downloads +``` + +### 如何在 tmpwatch 中排除特定路径 + +以下命令将删除过去 10 个小时未被修改的所有文件,除了下面排除的文件夹。 + +``` +# tmpwatch -am 10 --exclude=/home/daygeek/Downloads/Movies /home/daygeek/Downloads +``` + +### 如何在 tmpwatch 中排除特定模式 + +以下命令将删除过去 10 小时未被修改的所有文件,除了满足下面列出的模式的文件。 + +``` +# tmpwatch -am 10 --exclude-pattern='*.pdf' /home/daygeek/Downloads +``` + +### 如何让 tmpwatch 命令空运行 + +如果要空运行,请运行以下命令。 + +``` +# tmpwatch -t 5h /home/daygeek/Downloads +``` + +### 如何设置 cronjob 来使用 tmpwatch 定期删除文件 + +默认情况下,它在 `/etc/cron.daily/tmpreaper` 目录下有一个 [cronjob][7] 文件。该 cronjob 根据位于 `/etc/timereaper.conf` 中的配置文件工作。你可以根据需要自定义文件。 + +它每天运行一次,并删除 7 天之前的文件。 + +另外,如果你希望常规执行某项操作,那么可以根据需要手动添加一个 cronjob。 + +``` +# crontab -e + +0 10 * * * /usr/sbin/tmpwatch 15d /home/daygeek/Downloads +``` + +上面的 cronjob 将在每天上午 10 点删除早于 15 天的文件。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-remove-files-older-than-n-days-using-tmpwatch-tmpreaper-on-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-11490-1.html +[2]: https://www.2daygeek.com/linux-yum-command-examples-manage-packages-rhel-centos-systems/ +[3]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[4]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[5]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[6]: https://www.2daygeek.com/linux-dnf-command-examples-manage-packages-fedora-centos-rhel-systems/ +[7]: https://www.2daygeek.com/linux-crontab-cron-job-to-schedule-jobs-task/ diff --git a/published/202006/20200525 Linux Mint 20- Release Date, Features and Everything Important Associated With it.md b/published/202006/20200525 Linux Mint 20- Release Date, Features and Everything Important Associated With it.md new file mode 100644 index 0000000000..77ec2ec8d7 --- /dev/null +++ b/published/202006/20200525 Linux Mint 20- Release Date, Features and Everything Important Associated With it.md @@ -0,0 +1,120 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12297-1.html) +[#]: subject: (Linux Mint 20: Release Date, Features and Everything Important Associated With it) +[#]: via: (https://itsfoss.com/linux-mint-20/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Linux Mint 20 发布前一窥 +====== + +[Ubuntu 20.04 LTS 版本发布了][1]。这对 Linux Mint 用户来说也是一个好消息。一个新的 Ubuntu LTS 版本意味着新的 Linux Mint 主要版本也将很快随之出现。 + +为什么这么说呢?因为 Linux Mint 是基于 Ubuntu 的长期支持(LTS)版本的。Mint 18 系列是基于 Ubuntu 16.04 LTS,Mint 19 是基于 Ubuntu 18.04 LTS 等等。 + +与 Ubuntu 不同,Linux Mint 没有固定的发布时间表。根据以往的趋势,我可以做出一个明智的猜测,[Linux Mint][2] 20 应该会在今年 6 月发布。 + +### Linux Mint 20 “Ulyana” 即将推出的新功能 + +![][3] + +让我们来看看代号为 Ulyana 的 Linux Mint 20 中提出的一些主要新功能和变化。 + +#### 1. 提高 Nemo 文件管理器的性能 + +Nemo 文件管理器计划中的性能改进之一是它处理缩略图的方式。你可能还没有意识到,但缩略图的生成需要相当多的系统资源(以及磁盘空间)。试着打开一个有几千张图片的文件夹,你会发现 CPU 的消耗会上升。 + +在 Linux Mint 20 中,其目标是优先考虑内容和导航,并尽可能地延迟缩略图的渲染。这意味着在缩略图渲染之前,文件夹的内容会以通用图标显示出来。这不会让人觉得赏心悦目,但你会注意到性能的改善。 + +#### 2. 两种焕然一新的颜色变体 + +默认情况下,Linux Mint 是绿色/薄荷色的风格。还有一些其它的颜色点缀。Linux Mint 20 新添加了两种可爱的的粉红色和青蓝色。 + +以及新的青蓝色风格: + +![Linux Mint Aqua][4] + +这里是新的粉红色风格: + +![Linux Mint Pink][5] + +#### 3. 没有过度偏重于 Snap 包 + +Ubuntu 20.04 将 snap 包的优先级放在了通常的 apt 包之前。事实上,如果你在 Ubuntu 20.04 中使用 `apt` 命令安装 Chromium 浏览器时,它会自动安装 snap 版本。 + +Linux Mint 团队显然对此不满意,他们确认 Mint 20 将不会安装 snaps 或 snapd。它还将禁止 `apt` 使用 snapd。 + +你仍然可以自己手动安装 snap 包。只是不会由 `apt` 来安装它们。 + +#### 4. 有了这个新工具,跨网络共享文件变得很简单。 + +Linux Mint 20 将提供一个[新的 GUI 工具][6],可以轻松地在本地网络上共享文件,而无需任何额外的配置。 + +![New tool for sharing files across the network][7] + +#### 5. 更好地整合了 Electron 应用程序的桌面 + +[Electron][8] 是一个开源框架,它允许使用 Web 技术构建跨平台的桌面应用程序。有些人称它为懒惰的方法,因为应用程序运行在 Chromium 浏览器之上。然而,这可以让开发人员轻松地将他们的应用程序提供给 Linux(和 macOS)。[Linux 上的 Slack][9] 就是众多这样的例子之一。 + +Linux Mint 20 将对 Electron 应用提供更好的支持,并改进系统托盘和桌面通知的集成。 + +#### 6. 改进的支持多显示器的比例缩放功能 + +![improved multi-monitor support][10] + +一个提议的改变是在 Linux Mint 20 中加入支持多显示器的比例缩放功能。如果你有一个 HiDPI 和非 HiDPI 显示器的组合,你可以为它们每一个选择不同的分辨率、刷新率和不同的分数缩放。 + +在 Mint 20 的登录屏幕,可以让你跨多个显示器拉伸显示背景。 + +#### 7. 改进对 Nvidia Optimus 的支持 + +在 Mint 20 中,Nvidia prime 小程序会显示 GPU 渲染器。你也可以直接从系统托盘中的菜单中选择切换到哪块卡。 + +![Switch between GPUs][12] + +你也可以使用 Nvidia “On-Demand” 模式。在这种模式下,将使用英特尔卡来渲染会话。而如视频播放器或视频编辑器这样的兼容应用程序可以在应用程序菜单中打开时使用 Nvidia GPU。 + +![Run an application with NVIDIA GPU][13] + +#### 8. 不再支持 32 位 + +虽然 Ubuntu 18.04 在两年前就放弃了 32 位 ISO,但 Linux Mint 19 系列一直提供 32 位 ISO 的下载和安装。 + +这种情况在 Linux Mint 20 中有所改变。Linux Mint 20 已经没有 32 位版本了。这是因为 32 位支持从 Ubuntu 20.04 中完全消失了。 + +#### 还有什么? + +Cinnamon 4.6 桌面版的发布带来了很多视觉上的变化。 + +在 Ubuntu 20.04 中,应该会有一些“引擎盖下”的变化,比如 Linux Kernel 5.4,取消了 Python 2 的支持,加入 [Wireguard VPN][11] 等。 + +随着开发的进展,我会在本文中更新更多的功能。敬请期待。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-mint-20/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ubuntu-20-04-release-features/ +[2]: https://www.linuxmint.com/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/Linux-Mint-20.png?ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/mint-20-aqua.jpg?ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/mint-20-pink-1.jpg?ssl=1 +[6]: https://blog.linuxmint.com/?p=3863 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/mint-20-warpinator-1.png?ssl=1 +[8]: https://www.electronjs.org/ +[9]: https://itsfoss.com/slack-use-linux/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/monitor_display_Linux_mint_20.png?ssl=1 +[11]: https://itsfoss.com/wireguard/ +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/nvidia-prime-applet-linux-mint-20.png?w=386&ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/nvidia-on-deman-feature-linux-mint-20.png?w=526&ssl=1 diff --git a/published/202006/20200525 Track Your Screen Time in Linux with ActivityWatch.md b/published/202006/20200525 Track Your Screen Time in Linux with ActivityWatch.md new file mode 100644 index 0000000000..e1b6cd5fa1 --- /dev/null +++ b/published/202006/20200525 Track Your Screen Time in Linux with ActivityWatch.md @@ -0,0 +1,129 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12302-1.html) +[#]: subject: (Track Your Screen Time in Linux with ActivityWatch) +[#]: via: (https://itsfoss.com/activitywatch/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +使用 ActivityWatch 跟踪你在 Linux 中的屏幕使用时间 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/10/104854yumcnhp8smmjxcht.jpg) + +> ActivityWatch 是一款开源的隐私友好型应用程序,可追踪你在台式电脑或移动设备上的使用时间。 + +### ActivityWatch: 一个追踪你在哪个应用程序上花了多少时间的开源应用程序 + +![ActivityWatch lets you check the time spent on various applications][1] + +[ActivityWatch][2] 是一款跨平台的开源应用,可以帮助你追踪使用时间,衡量你的工作效率。它可以追踪你花在应用程序、浏览器上的时间,以及你是否 AFK(远离键盘)或系统处于休眠状态。 + +不只是追踪时间,它还提供了一堆有用的功能,通过可视化的方式帮助你轻松分析你是如何花费时间的,从而有可能提高你的生产力。 + +![][3] + +它是 [RescueTime][4] 和 [ManicTime][5] 等专有产品的绝佳替代品。 + +ActivityWatch 可用于 Linux、Windows、macOS 和 [Android][6]。它还提供了 Chrome 和 Firefox 的浏览器扩展。截至目前,App Store 上还没有它的 iOS 版应用。 + +![][7] + +它刚刚进入该领域,正在积极开发,以解决任何现有的问题并引入新的功能,如在多个设备上同步你的活动数据的能力。 + +**对于注重隐私的用户来说,我应该提到,收集的数据被存储在你本地的设备上。这是一件好事,因为你可以跟踪你的花费时间,而不会被别人跟踪。** + +### ActivityWatch 的功能 + +![][8] + +基本上,ActivityWatch 可以让你监控你的活动,以分析不良的屏幕使用时间,或改善你在设备上工作的时间管理。 + +具体来说,它提供了几个有用的功能,主要有: + +* 摘要你的日常活动及按使用时间排序的应用和程序列表。 +* 追踪你的浏览器活动的时间,使用浏览器扩展来获得每个活动标签所花费时间的确切数据。 +* 追踪 AFK 和非 AFK 时间。(AFK - “Away From Keyboard” 的缩写,即不在电脑前) +* 提供不同的可视化时间线,以监测你的活动。 +* 能够使用 [watchers][9] 跟踪你在编辑器上写代码的时间。 +* 记录你的活动,以分析你的生产力。 +* 将花费的时间进行分类,可以帮助你详细分析。 +* 可以添加更多的类别和调整时间轴的持续时长。 +* 能够将数据导出/导入为 [JSON][10] 文件。 +* 实验性的秒表功能。 +* 本地存储数据,以尊重用户隐私。 + +### 在 Linux 上安装 ActivityWatch + +> 注:如果你的 Linux 发行版不支持系统托盘图标,你需要遵循这个[文档][11]来解决这个问题。 + +不幸的是,你找不到 AppImage、Flatpak 或 Snap 软件包。然而,对于 Manjaro 或 Arch Linux 有可以安装的 [AUR][12] 包。 + +对于所有其它的 Linux 发行版,你会得到一个 ZIP 文件,其中包括一个要运行的 `aw-qt` 应用程序。 + +要运行它,你需要[解压 zip 归档文件][13],然后通过双击 `aw-qt` 应用程序运行二进制文件来安装它。 + +![Aw Qt][14] + +你也可以使用终端: + +``` +cd activitywatch-v0.9.2-linux-x86_64 +sudo ./aw-qt +``` + +解压文件夹的位置和文件名可能会有所不同 —— 所以请确保你导航到正确的目录,然后使用上面的命令。完成后,你可以从系统托盘图标访问 ActivityWatch,或者直接前往 [localhost:5600][15] 访问它。 + +你也可以查看他们的 [GitHub 页面][16]或[官方网站][2]来探索更多关于它的信息。 + +- [下载 ActivityWatch][2] + +顺便提一句,如果你计划经常使用 ActivityWatch,你应该将下载的文件移动到 `/opt` 目录下,并在 `/usr/share/bin` 目录下创建一个链接到 `aw-qt` 可执行文件符号链接。这样一来,该应用程序可以作为一个常规命令供系统上的所有用户使用。类似的方法在 [PopcornTime 安装教程][17]中也有演示。 + +### 我对 ActivityWatch 的看法 + +![][18] + +在 [Pop!_OS 20.04][19] 上,时间跟踪功能可以完全正常地工作,也支持系统托盘图标。你可能会遇到一个错误,不能让你从系统托盘图标访问 ActivityWatch(这也是一个 [GitHub 上的已知问题][20])。在这种情况下,你需要通过 [localhost:5600][15] 来访问它。 + +就个人而言,考虑到我在桌面上使用它,并且没有计划在智能手机上使用它,我对提供的功能相当满意。 + +我必须得向你推荐尝试这个不错的开源项目,并一路支持他们。如果你喜欢这个项目,请随时通过添加星标或赞助[他们的 GitHub 仓库][21]来表示你的赞赏。 + +欢迎在下面的评论中告诉我你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/activitywatch/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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/2020/05/activitywatch.png?fit=800%2C607&ssl=1 +[2]: https://activitywatch.net/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-afk.jpg?ssl=1 +[4]: https://itsfoss.com/recommends/rescuetime/ +[5]: https://www.manictime.com/ +[6]: https://play.google.com/store/apps/details?id=net.activitywatch.android +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-timeline.jpg?ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-settings.jpg?ssl=1 +[9]: https://docs.activitywatch.net/en/latest/watchers.html +[10]: https://en.wikipedia.org/wiki/JSON +[11]: https://docs.activitywatch.net/en/latest/getting-started.html +[12]: https://aur.archlinux.org/packages/activitywatch-bin/ +[13]: https://itsfoss.com/unzip-linux/ +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/aw-qt.jpg?ssl=1 +[15]: https://itsfoss.com/activitywatch/5600 +[16]: https://github.com/ActivityWatch +[17]: https://itsfoss.com/popcorn-time-ubuntu-linux/ +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/activitywatch-screenshot.jpg?ssl=1 +[19]: https://itsfoss.com/pop-os-20-04-review/ +[20]: https://github.com/ActivityWatch/activitywatch/issues/208 +[21]: https://github.com/ActivityWatch/activitywatch diff --git a/published/202006/20200525 Ubuntu Budgie 20.04 Review- Smooth, Polished - Plenty of Changes.md b/published/202006/20200525 Ubuntu Budgie 20.04 Review- Smooth, Polished - Plenty of Changes.md new file mode 100644 index 0000000000..26bcd153cd --- /dev/null +++ b/published/202006/20200525 Ubuntu Budgie 20.04 Review- Smooth, Polished - Plenty of Changes.md @@ -0,0 +1,165 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12354-1.html) +[#]: subject: (Ubuntu Budgie 20.04 Review: Smooth, Polished & Plenty of Changes) +[#]: via: (https://itsfoss.com/ubuntu-budgie-20-04-review/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Ubuntu Budgie 20.04 LTS:平滑、精致和丰富的变化 +====== + +正如我们向读者承诺的那样,我们将对 [Ubuntu 20.04 LTS 版本][1]的所有主要特色版进行评测。在这个续篇中,我们将对 Ubuntu Budgie 进行评测。 + +![Ubuntu Budgie Desktop][2] + +顾名思义,[Ubuntu Budgie][3] 是使用 [Budgie 桌面环境][5]的 [Ubuntu 官方特色版][4]。这个版本是 Ubuntu 家族中较新的一位成员。Ubuntu Budgie 的第一个版本是 16.04,它在 17.04 版本时被接受为官方特色版。 + +他们的[目标][6]是“结合 Budgie 界面的简洁和优雅,以生产具有现代范式的面向桌面的传统发行版。” + +### Ubuntu Budgie 20.04 评测:哪些改变了,哪些没有! + +[自 18.04 LTS 发布以来,Ubuntu Budgie][7] 有了令人惊讶的更新和改进: + + * 苹果风格的新菜单 + * 默认采用基于 Budgie 的网络管理小程序 + * 新的 Window Shuffler 允许你通过快捷键平铺应用程序 + * 快速切换桌面布局的新工具 + * 支持 4k 分辨率 + * 新的默认应用程序:GNOME Firmware 和 Drawing + * 现在已经为 20.04 重构了向后移植包 + * 默认浏览器是火狐 + * 默认使用 Catfish 搜索文件和文本 + * 在 Budgie 中集成了 Nemo 文件管理器 + * 由于错误,系统托盘小程序被移除了 + * 默认情况下,事件警报声被禁用 + * 修复了键盘快捷键神秘失踪的问题 + * 更好的锁屏样式 + * 由于社区的需求,文件应用 Nautilus 已被 Nemo 取代 + * Plank 坞站现在已经切换到屏幕底部,是透明的,并且默认有弹跳动画 + * 快速笔记和热角小程序已从 Python 移植到 Vala,以提高速度 + * Celluloid 取代了 MPV + * 更新了 GNOME 的依赖性 + +![][8] + +Ubuntu Budgie 现在随附了 Budgie 桌面环境的最新版本(10.5.1)。改进包括: + + * 在 Budgie 桌面设置中新增 Raven 部分 + * Raven 通知可以分组,通知可以关闭 + * 重新打造了图标任务列表 + * 能够设置虚拟桌面的数量 + +Ubuntu Budgie 自带了大量的 Budgie 小程序applet微应用min-app。它们可以通过 Ubuntu Budgie “欢迎”应用来安装。 + +![Ubuntu Budgie Welcome][9] + + * WeatherShow:显示未来五天的天气预报,每 3 小时更新一次 + * Wallstreet:一个可以循环展示你的图像文件夹中的壁纸工具 + * Visual-space:一个紧凑的工作区切换器 + * Dropby:这个小程序可让你在面板上快速管理 U 盘 + * Kangaroo:从面板上快速浏览文件夹 + * 垃圾桶小程序:管理你的垃圾桶 + * Fuzzyclock:以模糊的方式显示时间 + * 工作区秒表:允许你跟踪在每个工作区花费的时间 + +完整的变更和更新列表,请访问[变更日志][10]。 + +#### 系统要求 + +Ubuntu Budgie 20.04 更新了[系统要求][11]: + + * 4GB 或以上的内存 + * 64 位的 Intel 和 AMD 处理器 + * 在 CSM 模式下启动的 UEFI 电脑 + * 基于英特尔的现代苹果电脑 + +如你所见,Budgie 并不是一个真正的轻量级选择。 + +#### 安装的应用 + +![][12] + +Ubuntu Budgie 中默认包含了以下有用的应用程序: + + * AisleRiot Solitaire + * Geary + * Catfish 搜索工具 + * Cheese 网络摄像头工具 + * GNOME Drawing + * GNOME 2048 + * GNOME Mahjongg + * GNOME Mines + * GNOME Sudoku + * Gthumb + * LibreOffice + * Maps + * Rhythmbox + * Tilix + * Ubuntu Budgie 欢迎应用 + * Evince 文档查看器 + * Plank + * Celluloid + +![Ubuntu Budgie Ram Usage][13] + +### 安装 + +起初,我无法让 Ubuntu Budgie 进入即用live环境来安装它。结果发现 Ubuntu Budgie 试图通过 EFI 来启动,我从 [Ubuntu Budgie 论坛][14]得到了解决方案。 + +当出现紫色的闪屏时,我必须按下 `ESC` 键并选择 `legacy`。之后,它就如常启动了,安装也没有问题了。我只在 Ubuntu Budgie 上遇到过这个问题。我下载并尝试了 Ubuntu MATE 20.04 ISO,但没有遇到类似的问题。 + +### Ubuntu Budgie 20.04 的体验 + +![][15] + +除了这个安装上的小问题,我使用 Ubuntu Budgie 的体验非常愉快。自 [Ikey][16] 第一次创建 Budgie 桌面以来,Budgie 桌面已经进步了很多,并且已经成为一个非常成熟的选择。Ubuntu Budgie 的目标是“生产一个面向桌面的传统发行版”。它确实做到了极致。他们所做的所有改变都在不断地为他们的产品增添更多的光彩。 + +总的来说,Ubuntu Budgie 是一个非常漂亮的发行版。从默认的主题到壁纸选择,你可以看出他们付出了很多努力,视觉体验非常吸引人。 + +需要注意的是,Ubuntu Budgie 并不适合低配置的系统。我在戴尔 Latitude D630 上运行它。在没有打开任何应用程序的情况下,它使用了大约 700MB 的内存。 + +在 Ubuntu Budgie 中,让我喜欢的部分超乎我的预期,其中一个部分是 [Tilix 终端模拟器][17]。Tilix 允许你在右侧或下方添加终端窗口。它有很多很多功能,我简直爱死了它,我打算在我的其他 Linux 系统上也安装它。 + +### 关于 Ubuntu Budgie 20.04 的最后感想 + +Ubuntu Budgie 是众多官方版本中一个很受欢迎的新版本。Budgie 给人的感觉非常流畅和精致。它不会让你觉得碍手碍脚,而是帮你完成工作。 + +如果你厌倦了当前的桌面环境,想体验一下新的东西,不妨来看看。如果你对当前的环境感到满意,那么就试试 Ubuntu Budgie 的即用 DVD。你可能会喜欢上它。 + +![关于 Ubuntu Budgie][18] + +你是否已经尝试过 Ubuntu 20.04 Budgie?你对它的使用体验如何?如果没有用过,你现在使用的是哪个版本的 Ubuntu 20.04? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-budgie-20-04-review/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/download-ubuntu-20-04/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-busgie-desktop.png?resize=800%2C500&ssl=1 +[3]: https://ubuntubudgie.org/ +[4]: https://itsfoss.com/which-ubuntu-install/ +[5]: https://en.wikipedia.org/wiki/Budgie_ +[6]: https://ubuntubudgie.org/about-us/ +[7]: https://itsfoss.com/ubuntu-budgie-18-review/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-budgie-desktop-settings.jpeg?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-budgie-welcome.png?resize=800%2C472&ssl=1 +[10]: https://ubuntubudgie.org/2020/04/21/ubuntu-budgie-20-04lts-release-notes-for-18-04-upgraders/ +[11]: https://ubuntubudgie.org/downloads/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-budgie-applications.jpeg?ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-budgie-ram-usage.png?resize=800%2C600&ssl=1 +[14]: https://discourse.ubuntubudgie.org/t/cant-get-ub-to-boot/3397 +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-budgie-20-04.jpg?ssl=1 +[16]: https://itsfoss.com/ikey-doherty-serpent-interview/ +[17]: https://gnunn1.github.io/tilix-web/ +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/ubuntu-budgie-about.png?resize=800%2C648&ssl=1 diff --git a/published/202006/20200525 Ubuntu MATE 20.04 LTS Review- Better Than Ever.md b/published/202006/20200525 Ubuntu MATE 20.04 LTS Review- Better Than Ever.md new file mode 100644 index 0000000000..86e6a6c6d2 --- /dev/null +++ b/published/202006/20200525 Ubuntu MATE 20.04 LTS Review- Better Than Ever.md @@ -0,0 +1,171 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12341-1.html) +[#]: subject: (Ubuntu MATE 20.04 LTS Review: Better Than Ever) +[#]: via: (https://itsfoss.com/ubuntu-mate-20-04-review/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Ubuntu MATE 20.04 LTS:士别三日,当刮目相待 +====== + +Ubuntu MATE 20.04 LTS 无疑是最流行的 [Ubuntu 官方特色版本][1]之一。 + +不仅仅是我,这份[Ubuntu 20.04 调查报告][2]也持同样观点。不过不管流行与否,它都是一个令人印象深刻的 Linux 发行版,尤其是用在较旧的硬件上时。事实上,它也是可用的[最轻量的 Linux 发行版][3]之一。 + +所以,我想在一个虚拟机中尝试一下,为你提供一个概览,这样你可以了解其中有何值得期盼的变化,以及是否值得尝试。 + +### 在 Ubuntu MATE 20.04 LTS 中有什么新功能? + +- [video](https://www.youtube.com/embed/WBZyXDHw4HA) + +Ubuntu MATE 20.04 LTS 的主要亮点应该是增加了 MATE Desktop 1.24。 + +你可以期待 MATE Desktop 1.24 中的所有新特色都被打包到 Ubuntu MATE 20.04 中。除此之外,还有很多重要的变化、改进和增补。 + +这是 Ubuntu MATE 20.04 中变化的概述: + + * 新增 MATE Desktop 1.24 + * 大量视觉改进 + * 数十处错误修复 + * 基于 [Linux 内核 5.4][5] 系列 + * 添加了实验性的 [ZFS][6] 支持 + * 添加了来自 [Feral Interactive][7] 的 GameMode + * 一些软件包更新 + +现在,为了更好地了解 Ubuntu MATE 20.04,我将给你提供更多的细节。 + +### 用户体验改善 + +![][8] + +考虑到越来越多的用户倾向于在桌面上使用 Linux,而用户体验在桌面中起着至关重要的作用。 + +如果有一些易于使用和令人愉悦的东西,那么第一印象就会有很大不同。 + +对于 Ubuntu MATE 20.04 LTS,我没有感到失望。就我个人而言,我是最新的 [GNOME 3.36][9] 的粉丝。我喜欢在我 [Pop!_OS 20.04][10] 上使用它,但是随着 [MATE 1.24][11] 的出现,使得 Ubuntu MATE 也同样具有很好的体验。 + +你会看到窗口管理器有一些重大更改,包括:增加了用于重新调整大小的隐形边框,HiDPI 图标渲染,重新设计了 `ALT+TAB` 工作区切换器的弹出窗口和一些其它的更改,这些是最新的 MATE 1.24 桌面环境的一部分。 + +![][12] + +此外, MATE Tweak 也得到了一些贴心的改进,即使你更改桌面的布局,也可以保留用户偏好。新的 MATE 欢迎屏幕也会告知用户更改桌面布局的能力,因此,用户无需不断摸索就能知道这个变化。 + +此外,我最喜欢的新增功能之一是可以预览最小化的应用程序。 + +例如,你已经最小化了一个应用程序,但是你想在拉起它之前看到它的预览 —— 现在你只需将鼠标悬停在任务栏上就可以做到这一点,如下图所示: + +![][13] + +不过,我必须指出,并不是每个应用程序都可以如预期般的工作。因此,这个功能是有缺陷的,还需要改进。 + +### 应用程序新增或升级 + +![][14] + +在 MATE 20.04 中,你会注意到有一个新的固件更新器,它是 [fwupd][15] 的 GTK 前端。你可以使用这个更新器来轻松地管理你的固件驱动。 + +这个版本也使用 Evolution 替换了 Thunderbird 电子邮件客户端。尽管 [Thunderbird][16] 是一个非常流行的电子邮件客户端,但是 [Evolution][17] 与 MATE 桌面集成得更好,并且证明它更有用。 + +![][18] + +考虑到我们已经搭载了 MATE 1.24,你也将发现一个新的时间和日期管理应用程序。不仅如此,如果你需要一个放大镜,Ubuntu MATE 20.04 还内置了 [Magnus][19]。 + +![][20] + +Ubuntu MATE 20.04 也包括了众多预安装的软件包/应用程序的升级包。 + +![][21] + +尽管这些是小的增补,但却能在很大程度上帮助发行版变得更有用。 + +### Linux Kernel 5.4 + +Ubuntu MATE 20.04 带有 2019 年最后一个主要的稳定版内核,即 [Linux 内核 5.4][5]。 + +使用该内核,你可以获得原生的 [exFAT 支持][22]、改进的硬件支持。更不用说,拥有 [WireGuard][23] VPN 的支持也是一件极好的事。 + +所以,你会注意到 Linux Kernel 5.4 的众多好处,包括内核锁定功能。如果你好奇,你可以阅读我们关于 [Linux Kernel 5.4][5] 的新闻报道来了解更多的细节。 + +### 增加了 Feral Interactive 的 GameMode + +以将游戏带到 Linux 平台而闻名的 Feral Interactive 带来了一款实用的命令行工具,即 [GameMode][7]。 + +它没有提供图形界面,但是在启动一个游戏前,你可以使用命令行请求临时性的系统优化。 + +虽然这可能不会给每个系统都带来很大的不同,而是给玩游戏提供了更多的资源,并且 GameMode 可以确保你获得必要的优化。 + +### 实验性的 ZFS 安装选项 + +你可以使用 ZFS 作为根文件系统了。值得注意的是,它是一个实验性的功能,如果你不确定自己在做什么,那么就不应该使用它。 + +要更好地了解 ZFS,我建议你阅读我们的一篇文章,[John Paul][24] 所写的《[ZFS 是什么][6]》的文章。 + +### 性能和其它的改进 + +Ubuntu MATE 是一款完美的轻量级发行版,同时也是一款适合现代台式机的发行版。 + +![][25] + +在这个评测中,我没有运行任何特殊的基准测试工具,以一个普通用户来说,我在虚拟机设置中没有发现任何性能问题。我在一台使用了一颗 i5-7400 处理器、配备 GTX 1050 显卡和 16 GB 内存的主机系统上进行了测试。并且,我将 7 GB 的内存 + 768 MB 的显存 + 2 个处理器核心分配给了虚拟机。 + +![][26] + +如果你要自己测试它,请随时告诉我你对它的感觉如何。 + +总的来说,除了所有主要的改进之外,还有一些细微的改变/修复/改进,使得 Ubuntu MATE 20.04 LTS 成为了一个很好的升级版本。 + +### 我应该升级吗? + +如果你正在运行 Ubuntu MATE 19.10,你应该立即升级它,因为它的支持将在 2020 年 6 月结束。 + +对于 Ubuntu MATE 18.04 用户(支持到 2021 年 4 月)来说,这取决于你的需求。如果你需要最新发布版本的功能,你应该选择立即升级它。 + +但是,如果你不一定需要新的功能,你可以查看[现存的错误列表][27] 并加入 [Ubuntu MATE 社区][28] 来了解更多最新发布版本的问题。 + +在你做完必要的研究后,你可以继续升级你的系统到 Ubuntu MATE 20.04 LTS,它将支持到 2023 年 4 月。 + +你试过最新的 Ubuntu MATE 20.04 吗?你认为它怎么样?在评论中让我知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-mate-20-04-review/ + +作者:[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://itsfoss.com/which-ubuntu-install/ +[2]: https://ubuntu.com/blog/ubuntu-20-04-survey-results +[3]: https://itsfoss.com/lightweight-linux-beginners/ +[4]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[5]: https://itsfoss.com/linux-kernel-5-4/ +[6]: https://itsfoss.com/what-is-zfs/ +[7]: https://github.com/FeralInteractive/gamemode +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-20-04.jpg?ssl=1 +[9]: https://itsfoss.com/gnome-3-36-release/ +[10]: https://linux.cn/article-12175-1.html +[11]: https://mate-desktop.org/blog/2020-02-10-mate-1-24-released/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-desktop-layout.png?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-minimized-app.png?ssl=1 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-20-04-firmware.png?ssl=1 +[15]: https://fwupd.org +[16]: https://www.thunderbird.net/en-US/ +[17]: https://wiki.gnome.org/Apps/Evolution +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-evolution.png?ssl=1 +[19]: https://kryogenix.org/code/magnus/ +[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-magnus.jpg?ssl=1 +[21]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-apps.png?ssl=1 +[22]: https://cloudblogs.microsoft.com/opensource/2019/08/28/exfat-linux-kernel/ +[23]: https://wiki.ubuntu.com/WireGuard +[24]: https://itsfoss.com/author/john/ +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-system-reosource.jpg?ssl=1 +[26]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/ubuntu-mate-focal-neofetch.png?ssl=1 +[27]: https://bugs.launchpad.net/ubuntu-mate +[28]: https://ubuntu-mate.community/ diff --git a/published/202006/20200527 How to Format a USB Disk as exFAT on Linux -Graphically and Command Line.md b/published/202006/20200527 How to Format a USB Disk as exFAT on Linux -Graphically and Command Line.md new file mode 100644 index 0000000000..9252d16b1c --- /dev/null +++ b/published/202006/20200527 How to Format a USB Disk as exFAT on Linux -Graphically and Command Line.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12294-1.html) +[#]: subject: (How to Format a USB Disk as exFAT on Linux [Graphically and Command Line]) +[#]: via: (https://itsfoss.com/format-exfat-linux/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +如何在 Linux 上将 USB 盘格式化为 exFAT +====== + +> 本教程教你如何在 Linux 系统上以 exFAT 格式格式化 USB 盘。同时包括 GUI 和命令行两种方法。 + +长期以来,[FAT][1] 是用于格式化磁盘文件系统的默认选择。它与几乎所有主要操作系统兼容。 + +FAT 文件系统的一个主要问题是你不能传输大于 4GB 的文件。这意味着即使你的 USB 盘有 32GB 的可用空间,如果你尝试传输 ISO 镜像或其他大于 4GB 的文件,传输也会失败。 + +这会[在 Linux 中创建 Windows 的可启动 USB 盘][2]的情况下造成问题。你不能使用 [NTFS][3],并且 FAT 文件系统有 4GB 的大小限制。 + +为了克服 FAT 文件系统的限制,微软推出了 [exFAT 文件系统][4]。在本教程中,我将向你展示如何使用 exFAT 文件系统中格式化 USB 盘。 + +### 先决条件 + +从 [Linux kernel 5.4][7] 开始,Linux 内核本身中启用了 exFAT 文件系统支持。[检查正在运行的 Linux 内核版本][8]。如果是内核 5.4 或更高版本,那么应该没问题。 + +不然,你必须[启用 exFAT 支持][9]。在基于 Ubuntu 的发行版中,你可以安装以下软件包: + +``` +sudo apt install exfat-fuse exfat-utils +``` + +### 方法 1:使用 GNOME 磁盘工具将磁盘格式化为 exFAT + +![][10] + +使用 “[GNOME 磁盘][11]” 格式化驱动器是一项简单的工作。它预装在许多 Linux 发行版中。 + +插入外部 USB 盘。在菜单中查找 “Disk”,然后打开 “GNOME 磁盘” 应用。第一步,选择要格式化的驱动器,然后按照我的步骤操作。 + +**警告:请注意你要选择格式化的磁盘。请勿意外格式化主磁盘。** + +![][12] + +诸如 Ext4、NTFS、FAT 之类的常用文件系统将首先出现。要使用 exFAT,请选择 “其它”,然后单击 “下一步”。 + +![][13] + +最后一步:在此页面上选择 exFAT 文件系统,然后单击 “创建”。完成了! + +![][14] + +看到在 Linux 中以图形方式创建 exFAT 磁盘有多么容易了吧?现在,让我向你展示终端方法。 + +### 方法 2:在 Linux 命令行中将磁盘格式化为 exFAT(适用于高级用户) + +[fdisk][15] 是一个交互式命令行程序,它可在硬盘上创建和操作分区表和分区。实际上,它被认为是 [Linux 最佳分区工具][16]之一。 + +插入外部硬盘,然后在终端中输入以下命令: + +``` +sudo fdisk -l +``` + +![][17] + +这将列出计算机中的所有硬盘和分区。识别出要在外部硬盘上格式化的分区。应该会提示磁盘大小。对我而言,USB 盘被标记为 `/dev/sdb1`。 + +识别出 USB 盘后,请使用以下命令将它格式化为 exfat。将 `/dev/sdXn` 替换为你的磁盘 ID。`LABEL` 是你要为磁盘命名的名称,例如 `Data`、`MyUSB` 等。 + +``` +sudo mkfs.exfat -n LABEL /dev/sdXn +``` + +![][18] + +可选地,运行 `fsck` 检查,以确保格式化正确。 + +``` +sudo fsck.exfat /dev/sdXn +``` + +就是这样。享受 exFAT 盘吧。 + +### 你是否成功创建了exFAT 盘? + +我希望你觉得本教程足够简单,并建立坚实的分区知识基础的第一步。 + +从长远来看,有时简单易用的技巧将让你拥有一个更好的 Linux。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/format-exfat-linux/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/File_Allocation_Table +[2]: https://itsfoss.com/bootable-windows-usb-linux/ +[3]: https://en.wikipedia.org/wiki/NTFS +[4]: https://en.wikipedia.org/wiki/ExFAT +[5]: tmp.YPwoWNgq9W#graphical-method +[6]: tmp.YPwoWNgq9W#command-line +[7]: https://itsfoss.com/linux-kernel-5-4/ +[8]: https://itsfoss.com/find-which-kernel-version-is-running-in-ubuntu/ +[9]: https://itsfoss.com/mount-exfat/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/format-exfat-linux.jpg?ssl=1 +[11]: https://wiki.gnome.org/Apps/Disks +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/1.-gnome-disks-2.png?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/2.-gnome-disks.jpg?ssl=1 +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/3.-gnome-disks.jpg?ssl=1 +[15]: https://www.tldp.org/HOWTO/Partition/fdisk_partitioning.html +[16]: https://itsfoss.com/partition-managers-linux/ +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/sudo-fdisk-l-1.jpg?ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/sdXn.jpg?ssl=1 diff --git a/published/202006/20200528 Simplify data visualization in Python with Plotly.md b/published/202006/20200528 Simplify data visualization in Python with Plotly.md new file mode 100644 index 0000000000..870947b3e2 --- /dev/null +++ b/published/202006/20200528 Simplify data visualization in Python with Plotly.md @@ -0,0 +1,353 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12356-1.html) +[#]: subject: (Simplify data visualization in Python with Plotly) +[#]: via: (https://opensource.com/article/20/5/plotly-python) +[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan) + +使用 Plotly 来简化 Python 中的数据可视化 +====== + +> Plotly 是一个数据绘图库,具有整洁的接口,它旨在允许你构建自己的 API。 + +![](https://img.linux.net.cn/data/attachment/album/202006/27/215314y0rkrz0e9zw7wd2o.jpg) + +Plotly 是一个绘图生态系统,可以让你在 [Python][2] 以及 JavaScript 和 R 中进行绘图。在本文中,我将重点介绍[使用 Python 库进行绘图][3]。 + +Plotly 有三种不同的 Python API,你可以选择不同的方法来使用它: + + * 类似于 Matplotlib 的面向对象的 API + * 数据驱动的 API,通过构造类似 JSON 的数据结构来定义绘图 + * 类似于 Seaborn 的高级绘图接口,称为 “Plotly Express” API + +我将通过使用每个 API 来绘制相同的图来探索它们:英国大选结果的分组柱状图。 + +在我们进一步探讨之前,请注意,你可能需要调整你的 Python 环境来让这段代码运行,包括以下内容: + +- 运行最新版本的Python([Linux][4]、[Mac][5] 和 [Windows][6] 的说明) +- 确认你运行的 Python 版本能与这些库一起工作 + +数据可在线获得,可以用 Pandas 导入。 + +``` +import pandas as pd +df = pd.read_csv('https://anvil.works/blog/img/plotting-in-python/uk-election-results.csv') +``` + +现在我们可以继续进行了。 + +### 使用图对象来绘制图 + +Plotly 面向对象的 API 被称为 `graph_objects`,它有点类似于 [Matplotlib 的面向对象 API][7]。 + +要创建一个柱状图,你可以构造一个包含四个柱状图的对象: + +``` +# 导入 Plotly 和数据 +import plotly.graph_objects as go +from votes import wide as df + +# 得到 x 列表 +years = df['year'] +x = list(range(len(years))) + +# 定义绘图 +bar_plots = [ +  go.Bar(x=x, y=df['conservative'], name='Conservative', marker=go.bar.Marker(color='#0343df')), +  go.Bar(x=x, y=df['labour'], name='Labour', marker=go.bar.Marker(color='#e50000')), +  go.Bar(x=x, y=df['liberal'], name='Liberal', marker=go.bar.Marker(color='#ffff14')), +  go.Bar(x=x, y=df['others'], name='Others', marker=go.bar.Marker(color='#929591')), +] + +# 指定样式 +layout = go.Layout( +  title=go.layout.Title(text="Election results", x=0.5), +  yaxis_title="Seats", +  xaxis_tickmode="array", +  xaxis_tickvals=list(range(27)), +  xaxis_ticktext=tuple(df['year'].values), +) +    +# 绘制柱状图 +fig = go.Figure(data=bar_plots, layout=layout) + +# 告诉 Plotly 去渲染 +fig.show() +``` + +与 Matplotlib 不同的是,你无需手动计算柱状图的 `x` 轴位置,Plotly 会帮你适配。 + +最终结果图: + +![A multi-bar plot made using Graph Objects][8] + +*A multi-bar plot made using Graph Objects (© 2019 [Anvil][9])* + +### 使用 Python 数据结构来绘图 + +你还可以使用 Python 基本数据结构来定义绘图,它与面对对象 API 具有相同的结构。这直接对应于 Plotly 的 JavaScript 实现的 JSON API。 + +``` +# 定义绘图数据 +fig = { +    'data': [ +        {'type': 'bar', 'x': x, 'y': df['conservative'], 'name': 'Conservative', 'marker': {'color': '#0343df'}}, +        {'type': 'bar', 'x': x, 'y': df['labour'], 'name': 'Labour', 'marker': {'color': '#e50000'}}, +        {'type': 'bar', 'x': x, 'y': df['liberal'], 'name': 'Liberal', 'marker': {'color': '#ffff14'}}, +        {'type': 'bar', 'x': x, 'y': df['others'], 'name': 'Others', 'marker': {'color': '#929591'}}, +    ], +    'layout': { +        'title': {'text': 'Election results', 'x': 0.5}, +        'yaxis': {'title': 'Seats'}, +        'xaxis': { +            'tickmode': 'array', +            'tickvals': list(range(27)), +            'ticktext': tuple(df['year'].values), +        } +    } +} + +# 告诉 Plotly 去渲染它 +pio.show(fig) +``` + +最终结果与上次完全相同: + +![A multi-bar plot made using JSON-like data structures][10] + +*A multi-bar plot made using JSON-like data structures (© 2019 [Anvil][9])* + +#### 使用 Plotly Express 进行绘图 + +[Plotly Express][11] 是对图对象进行封装的高级 API。 + +你可以使用一行代码来绘制柱状图: + +``` +# 导入 Plotly 和数据 +import plotly.express as px +from votes import long as df + +# 定义颜色字典获得自定义栏颜色 +cmap = { +    'Conservative': '#0343df', +    'Labour': '#e50000', +    'Liberal': '#ffff14', +    'Others': '#929591', +} + +# 生成图 +fig = px.bar(df, x="year", y="seats", color="party", barmode="group", color_discrete_map=cmap) +``` + +这里使用了[长表][12]Long Form 数据,也称为“整洁数据”。这些列代表年份、政党和席位,而不是按政党划分。这与在 [Seaborn][13] 中制作柱状图非常相似。 + +``` +>> print(long) +     year         party  seats +0    1922  Conservative    344 +1    1923  Conservative    258 +2    1924  Conservative    412 +3    1929  Conservative    260 +4    1931  Conservative    470 +..    ...           ...    ... +103  2005        Others     30 +104  2010        Others     29 +105  2015        Others     80 +106  2017        Others     59 +107  2019        Others     72 + +[108 rows x 3 columns] +``` + +你可以访问底层的图对象 API 进行详细调整。如添加标题和 `y` 轴标签: + +``` +# 使用图对象 API 来调整绘图 +import plotly.graph_objects as go +fig.layout = go.Layout( +    title=go.layout.Title(text="Election results", x=0.5), +    yaxis_title="Seats", +) +``` + +最后,让 Plotly 渲染: + +``` +fig.show() +``` + +这将在未使用的端口上运行一个临时 Web 服务器,并打开默认的 Web 浏览器来查看图像(Web 服务器将会马上被关闭)。 + +不幸的是,结果并不完美。`x` 轴被视为整数,因此两组之间的距离很远且很小,这使得我们很难看到趋势。 + +![使用 Plotly Express 制作的柱状图][14] + +*A multi-bar plot made using Plotly Express (© 2019 [Anvil][9])* + +你可能会尝试通过将 `x` 值转换为字符串来使 Plotly Express 将其视为字符串,这样它就会以均匀的间隔和词法顺序来绘制。不幸的是,它们的间隔还是很大,像在 `graph_objects`中那样设置 `xaxis_tickvals` 也不行。 + +与 [Seaborn][13] 中的类似示例不同,在这种情况下,抽象似乎没有提供足够的[应急方案][15]来提供你想要的东西,但是也许你可以编写*自己*的 API? + +### 构建自己的 Plotly API + +对 Plotly 的操作方式不满意?那就构建自己的 Plotly API! + +Plotly 的核心是一个 JavaScript 库,它使用 [D3][16] 和 [stack.gl][17] 进行绘图。JavaScript 库的接口使用指定的 JSON 结构来绘图。因此,你只需要输出 JavaScript 库喜欢使用的 JSON 结构就好了。 + +Anvil 这样做是为了创建一个完全在浏览器中工作的 Python Plotly API。 + +![Ployly 使用 JavaScript 库创建图形,由其它语言库通过 JSON 使用][18] + +*Plotly uses a JavaScript library to create plots, driven by libraries in other languages via JSON (© 2019 [Anvil][9])* + +在 Anvil 版本中,你可以同时使用图对象 API 和上面介绍的 Python 数据结构方法。运行完全相同的命令,将数据和布局分配给 Anvil 应用程序中的 [Plot 组件][19]。 + +这是用 Anvil 的客户端 Python API 绘制的多列柱状图: + +``` +# 导入 Anvil 库 +from ._anvil_designer import EntrypointTemplate +from anvil import * +import anvil.server + +# 导入客户端 Plotly +import plotly.graph_objs as go + +# 这是一个 Anvil 表单 +class Entrypoint(EntrypointTemplate): +  def __init__(self, **properties): +    # Set Form properties and Data Bindings. +    self.init_components(**properties) + +    # 从服务器获取数据 +    data = anvil.server.call('get_election_data') +    +    # 获取一个方便的 x 值列表 +    years = data['year'] +    x = list(range(len(years))) + +    # 定义绘图 +    bar_plots = [ +      go.Bar(x=x, y=data['conservative'], name='Conservative', marker=go.Marker(color='#0343df')), +      go.Bar(x=x, y=data['labour'], name='Labour', marker=go.Marker(color='#e50000')), +      go.Bar(x=x, y=data['liberal'], name='Liberal', marker=go.Marker(color='#ffff14')), +      go.Bar(x=x, y=data['others'], name='Others', marker=go.Marker(color='#929591')), +    ] +    # 规定布局 +    layout = { +      'title': 'Election results', +      'yaxis': {'title': 'Seats'}, +      'xaxis': { +        'tickmode': 'array', +        'tickvals': list(range(27)), +        'ticktext': data['year'], +      }, +    } + +    # 生成多列柱状图 +    self.plot_1.data = bar_plots +    self.plot_1.layout = layout +``` + +绘图逻辑与上面相同,但是它完全在 Web 浏览器中运行,绘图是由用户计算机上的 Plotly JavaScript 库完成的!与本系列的所有其它 [Python 绘图库][3]相比,这是一个很大的优势。因为其它 Python 库都需要在服务器上运行。 + +这是在 Anvil 应用中运行的交互式 Plotly 图: + +![The election plot on the web using Anvil's client-side-Python Plotly library][20] + +*The election plot on the web using Anvil's [client-side-Python][21] Plotly library (© 2019 [Anvil][9])* + +你可以[复制此示例][22]作为一个 Anvil 应用程序(注意:Anvil 需要注册才能使用)。 + +在前端运行 Plotly 还有另一个优势:它为自定义交互行为提供了更多选项。 + +### 在 Plotly 中自定义交互 + +Plotly 绘图不仅是动态的,你可以自定义它们的互动行为。例如,你可以在每个柱状图中使用 `hovertemplate` 自定义工具提示的格式: + +``` + go.Bar( + x=x, + y=df['others'], + name='others', + marker=go.bar.Marker(color='#929591'), + hovertemplate='Seats: %{y}', + ), +``` + +当你把这个应用到每个柱状图时,你会看到以下结果: + +![A multi-bar plot with custom tool-tips][23] + +*A multi-bar plot with custom tool-tips (© 2019 [Anvil][9])* + +这很有用,当你想要在某些事件发生时执行任何你想要的代码就更好了(例如,当用户将鼠标悬停在栏上,你想要显示一个相关选举的信息框)。在 Anvil 的 Plotly 库中,你可以将事件处理程序绑定到诸如悬停之类的事件,这使得复杂的交互成为可能。 + +![A multi-bar plot with a hover event handler][24] + +*A multi-bar plot with a hover event handler (© 2019 [Anvil][9])* + +你可以通过将方法绑定到绘图的悬停事件来实现: + +``` + def plot_1_hover(self, points, **event_args): + """This method is called when a data point is hovered.""" + i = points[0]['point_number'] + self.label_year.text = self.data['year'][i] + self.label_con.text = self.data['conservative'][i] + self.label_lab.text = self.data['labour'][i] + self.label_lib.text = self.data['liberal'][i] + self.label_oth.text = self.data['others'][i] + url = f"https://en.wikipedia.org/wiki/{self.data['year'][i]}_United_Kingdom_general_election" + self.link_more_info.text = url + self.link_more_info.url = url +``` + +这是一种相当极端的交互性,从开发人员的角度来看,也是一种极端的可定制性。这都要归功于 Plotly 的架构 —— 它有一个简洁的接口,明确的设计是为了让你建立自己的API。如果到处都能看到这种伟大的设计,那将会很有帮助! + +### 使用 Bokeh 进行自定义交互 + +现在你已经了解了 Plotly 如何使用 JavaScript 来创建动态图,并且可以使用 Anvil 的客户端编写 Python 代码在浏览器中实时编辑它们。 + +Bokeh 是另一个 Python 绘图库,它可以输出可嵌入 Web 应用程序的 HTML 文档,并获得与 Plotly 提供的功能类似的动态功能(如果你想知道如何发音,那就是 “BOE-kay”)。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/plotly-python + +作者:[Shaun Taylor-Morgan][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shaun-taylor-morgan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/colorful_sound_wave.png?itok=jlUJG0bM (Colorful sound wave graph) +[2]: https://opensource.com/resources/python +[3]: https://linux.cn/article-12327-1.html +[4]: https://opensource.com/article/20/4/install-python-linux +[5]: thttps://opensource.com/article/19/5/python-3-default-mac +[6]: https://opensource.com/article/19/8/how-install-python-windows +[7]: https://opensource.com/article/20/5/matplotlib-python +[8]: https://opensource.com/sites/default/files/uploads/plotly.png (A multi-bar plot made using Graph Objects) +[9]: https://anvil.works/blog/plotting-in-plotly +[10]: https://opensource.com/sites/default/files/uploads/plotly-pio.png (A multi-bar plot made using JSON-like data structures) +[11]: https://plot.ly/python/plotly-express/ +[12]: https://anvil.works/blog/tidy-data +[13]: https://opensource.com/article/20/5/seaborn-visualization-python +[14]: https://opensource.com/sites/default/files/uploads/plotly-express.png (A multi-bar plot made using Plotly Express) +[15]: https://anvil.works/blog/escape-hatches-and-ejector-seats +[16]: https://d3js.org/ +[17]: http://stack.gl/ +[18]: https://opensource.com/sites/default/files/uploads/plotly-arch.png (Plotly uses a JavaScript library to create plots, driven by libraries in other languages via JSON) +[19]: https://anvil.works/docs/client/components/plots +[20]: https://opensource.com/sites/default/files/uploads/plotting-in-anvil.gif (The election plot on the web using Anvil's client-side-Python Plotly library) +[21]: https://anvil.works/docs/client/python +[22]: https://anvil.works/login?app-name=Plotting%20in%20Plotly&app-author=shaun%40anvil.works +[23]: https://opensource.com/sites/default/files/uploads/plotly-tooltips.png (A multi-bar plot with custom tool-tips) +[24]: https://opensource.com/sites/default/files/uploads/plotly-event-handling.gif (A multi-bar plot with a hover event handler) diff --git a/published/202006/20200529 20 productivity tools for the Linux terminal.md b/published/202006/20200529 20 productivity tools for the Linux terminal.md new file mode 100644 index 0000000000..a373c3bb21 --- /dev/null +++ b/published/202006/20200529 20 productivity tools for the Linux terminal.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12274-1.html) +[#]: subject: (20 productivity tools for the Linux terminal) +[#]: via: (https://opensource.com/article/20/6/productivity-tools-linux-terminal) +[#]: author: (Alan Smithee https://opensource.com/users/alansmithee) + +20 个 Linux 终端下的生产力工具 +====== + +> 来试下这些开源工具。你的效率一定会提升。 + +![Computer screen with files or windows open][1] + +诚然,很多人使用计算机来娱乐。但是一些人会用来工作,他们的理论是计算机应当能帮我们更快、更好、更有条理地做事。实际应用中,如果没有根据每个人的工作风格来做一些小小的手动配置,计算机也不会提升我们的效率。 + +[Kevin Sonney][2] 喜欢设计系统,今年他在一个 20 篇文章的系列中介绍了 18 种不同的生产力工具,不仅涵盖了网络方面,也涉及了一些能提升他的工作效率的工具。Kevin 最喜欢的所有的工具都收集到了本文,下面概括介绍每种工具的用途。 + +### 文件同步 + +![][3] + +重要的文件应谨慎管理。 + + * [Syncthing][4] 能使不同设备上的文件彼此同步。*设备*可以是 Linux、Windows 或 Mac,也可以是服务器、Android 平板或手机,等等。文件可以是你期望在多台机器间同步的任意文件。Syncthing 是轻量级的点对点工具,因此你不需要支付服务费,你不需要第三方的服务器,而且它很快。 + * 同步是一件事,但有时你还需要帮忙处理你拥有的文件。假设你想要一个应用程序在作为一个图形化应用和作为控制台应用时表现不同行为,你可以通过修改符号链接指向的不同的配置文件来达成,如 `.foo-gui` 和 `.foo-term`。这完全可以手动修改,但也可以用脚本处理,或者你可以试试 [GNU Stow][5]。 + +### 邮件管理 + +![][6] + +我们都依赖于邮件和收件箱,但似乎很少有人对自己管理邮件的方式满意。如果你喜欢用终端工作,为什么不在终端里管理邮件呢?在终端里收发邮件是一件事,但是要能在终端里组织你的邮件就更棒了。如果你的职业是打字员或是天生写脚本的人,试试这类工具吧。 + + * 我每天用 [OfflineIMAP][7] 把工作邮件同步到笔记本,以便用 Mutt 看邮件。它是很特别的工具,只做一件事:保证本地的邮件副本与远程的收件箱完全同步。配置和用 [cron][8] 调度它都相当简单,然后你就可以忘了它的存在。它相当简单,你与 IMAP 打交道的每一刻时间都应该用它。 + * [Notmuch][9] 能为邮件消息建立索引、加标签以及搜索邮件。如果你的收件箱出了问题,它可以让你*不需要*花费很大精力去补救。 + * [Vim][10] 可以收发邮件和管理你的日历。 + * 当然,[Emacs][11] 可以收发邮件和管理你的日历。 + +### 日历和联系人 + +![][12] + +我用过的所有的 Linux 系统都预装了 `cal` 命令。这是一个在终端下用的便捷小日历,它也是个很好的速查工具。然而,它几乎不能被称为一个日历应用程序。[iCalendar][13] 规范(与 Apple 的旧桌面日历无关)中提供了丰富的共享日历功能,虽然 `.ics` 的约会和事件是纯文本的,但没有在终端中管理它们的工作流。至少,在 khal 和 vdirsyncer 出现之前不存在。 + + * [Khal][14] 是基于控制台的读写 `.ics` 文件的日历工具。 + * [Vdirsyncer][14] 是一个能把线上日历(和联系人)同步到本地的终端命令。Khal 在本地运行,vdirsyncer 在远程运行,这样远程的日历能与你管理的本地日历保持同步。 + * 管理联系人可能会很难,但是如果你用了 [Khard][15] 这个可以读写 vCard 格式文件的终端命令,就会变得简单。反过来,这些文件可以使用 vdirsyncer(你可能已经在使用 khal 日历)同步到远程服务器上。这使得日历和联系人管理变得简单,而且[搭建个人信息管理(PIM)服务器][16]也比以前容易得多。 + +### 待办清单 + +![][17] + + * 组织你每天的行程有很多种方式,但是最简单的一种是用 [todo.txt][18],一个简单、便携、易于理解的系统,即使设备上没有安装 todo.txt 也不会出现问题。todo.txt 能正常运行的原因是,它就是一个 Bash 脚本,能在几乎所有你能找到的的设备上运行。操作过程很简单:下载脚本,安装到家目录,用一个简单的命令开始调度任务。如果你的计算机上没有安装 `todo.sh` 命令,那么你的待办清单仍然可以作为纯文本文件来使用,你可以在需要时手动更新它。 + * [Jrnl][19] 是一个能追踪的你的日常议程和活动的数字笔记本。如果你要摘抄桌面上的报纸的片段或者把随意的想法写下来,那么这就是你要找的程序。 + +### 保持联络 + +![][20] + +沟通是关键,然而现在似乎比以往更多的是聊天平台的问题。这不仅仅是几个客户端,而是几个独立的网络。你怎么管理它们?这里有两个方案。 + + * 如果你有很多的联系人分布在太多的聊天网络中,那么你应该试试 [BitlBee][21],使用这个单一的聊天客户端就可以关联其他所有的聊天网络。 + * [Rainbow Stream][22] 是个推特客户端,能让你不被开放的网页浏览器分心,而又能紧跟时事。 + +### 消息通知 + +![][23] + +网页浏览器很好,但有时过犹不及。你希望能及时收到消息,但是你又不想全身心地陷入到互联网中。因为互联网是建立在开放的规范和大量的开源技术的基础上的,你不必在一个界面中做所有的事。对于不同的任务有不同的*客户端*,它们可以让你用自己喜欢的界面来获取你需要的信息。 + + * [Tuir][24] 是一个 Reddit 终端客户端。 + * [Newsboat][25] 是一个 RSS 阅读器。 + * [Wego][26] 是天气预报工具。 + * [Vim][27] 可以帮助你登录 Reddit 和 Twitter。 + * [Emacs][28] 能让你保持与 Reddit、Twitter 和聊天客户端的联系。 + +### 保持终端一直开启 + +![][29] + +如果你正在用终端工作,那么关闭它的意义是什么呢?摆脱 `exit` 和 `Ctrl+D` 的诱惑,让你的控制台一直开启着。 + + * [Tmux][30] 能分割你的终端,让一个终端窗口“分层"到另一个窗口之上,甚至从一台计算机离开到另一台计算机后,能保持相同的终端会话。 + * [DESQview][31] 是另一种方式:它本质上是一个终端窗口管理器。 + +### 未完待续 + +本文列出的工具只是 Linux 终端的神奇生产力工具中的一小部分。这个清单会结束,但你自己的清单可以继续。找到你喜欢的工具,学习它们,并将其发挥出最大的优势。当然,一个好的工具不一定要提高你的生产力:有时你最喜欢的命令也可以是能让你最快乐的命令。你的工作是找到自己喜欢的命令,用它们来改变世界。 + +玩得愉快! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/productivity-tools-linux-terminal + +作者:[Alan Smithee][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alansmithee +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_screen_windows_files.png?itok=kLTeQUbY (Computer screen with files or windows open) +[2]: https://opensource.com/users/ksonney +[3]: https://opensource.com/sites/default/files/uploads/productivity_2-1.png +[4]: https://linux.cn/article-11793-1.html +[5]: https://linux.cn/article-11796-1.html +[6]: https://opensource.com/sites/default/files/uploads/productivity_3-1.png +[7]: https://linux.cn/article-11804-1.html +[8]: https://opensource.com/article/17/11/how-use-cron-linux +[9]: https://linux.cn/article-11807-1.html +[10]: https://linux.cn/article-11908-1.html +[11]: https://linux.cn/article-11932-1.html +[12]: https://opensource.com/sites/default/files/uploads/productivity_5-1.png +[13]: https://tools.ietf.org/html/rfc5545 +[14]: https://linux.cn/article-11812-1.html +[15]: https://linux.cn/article-11834-1.html +[16]: https://opensource.com/alternatives/google-calendar +[17]: https://opensource.com/sites/default/files/uploads/productivity_7-1.png +[18]: https://linux.cn/article-11835-1.html +[19]: https://linux.cn/article-11846-1.html +[20]: https://opensource.com/sites/default/files/uploads/productivity_9-1.png +[21]: https://linux.cn/article-11856-1.html +[22]: https://linux.cn/article-11858-1.html +[23]: https://opensource.com/sites/default/files/uploads/productivity_13-1.png +[24]: https://linux.cn/article-11869-1.html +[25]: https://linux.cn/article-11876-1.html +[26]: https://linux.cn/article-11879-1.html +[27]: https://linux.cn/article-11912-1.html +[28]: https://linux.cn/article-11956-1.html +[29]: https://opensource.com/sites/default/files/uploads/productivity_14-1.png +[30]: https://linux.cn/article-11900-1.html +[31]: https://linux.cn/article-11892-1.html diff --git a/published/202006/20200529 Add interactivity to your Python plots with Bokeh.md b/published/202006/20200529 Add interactivity to your Python plots with Bokeh.md new file mode 100644 index 0000000000..87a6640ddd --- /dev/null +++ b/published/202006/20200529 Add interactivity to your Python plots with Bokeh.md @@ -0,0 +1,221 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12329-1.html) +[#]: subject: (Add interactivity to your Python plots with Bokeh) +[#]: via: (https://opensource.com/article/20/5/bokeh-python) +[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan) + +使用 Bokeh 为你的 Python 绘图添加交互性 +====== + +> 在 Bokeh 中绘图比其他一些绘图库要复杂一些,但付出额外的努力是有回报的。 + +![](https://img.linux.net.cn/data/attachment/album/202006/18/164708zz7tjxz7m7ax5lt3.jpg) + +在这一系列文章中,我通过在每个 Python 绘图库中制作相同的多条形绘图,来研究不同 Python 绘图库的特性。这次我重点介绍的是 [Bokeh][2](读作 “BOE-kay”)。 + +Bokeh 中的绘图比[其它一些绘图库][3]要复杂一些,但付出的额外努力是有回报的。Bokeh 的设计既允许你在 Web 上创建自己的交互式绘图,又能让你详细控制交互性如何工作。我将通过给我在这个系列中一直使用的多条形图添加工具提示来展示这一点。它绘制了 1966 年到 2020 年之间英国选举结果的数据。 + +![][4] + +*绘图的放大视图(©2019 年 [Anvil][5])* + +### 制作多条形图 + +在我们继续之前,请注意你可能需要调整你的 Python 环境来让这段代码运行,包括以下: + +- 运行最新版本的 Python (在 [Linux][11]、[Mac][12] 和 [Windows][13] 上的说明) +- 确认你运行的 Python 版本能与这些库一起工作。 + +数据可在线获得,可以用 Pandas 导入。 + +``` +import pandas as pd +df = pd.read_csv('https://anvil.works/blog/img/plotting-in-python/uk-election-results.csv') +``` + +现在我们可以继续进行了。 + +为了做出多条形图,你需要对你的数据进行一下调整。 + +原始数据是这样的: + +``` +>> print(long) + year party seats +0 1966 Conservative 253 +1 1970 Conservative 330 +2 Feb 1974 Conservative 297 +3 Oct 1974 Conservative 277 +4 1979 Conservative 339 +.. ... ... ... +103 2005 Others 30 +104 2010 Others 29 +105 2015 Others 80 +106 2017 Others 59 +107 2019 Others 72 + +[60 rows x 3 columns] +``` + +你可以把数据看成是每一个可能的 `(year, party)` 组合的一系列 `seats` 值。这正是 Bokeh 处理的方式。你需要做一个 `(year, party)` 元组的列表: + +``` +# 得到每种可能的 (year, party) 组合的元组 +x = [(str(r[1]['year']), r[1]['party']) for r in df.iterrows()] + +# This comes out as [('1922', 'Conservative'), ('1923', 'Conservative'), ... ('2019', 'Others')] +``` + +这些将是 `x` 值。`y` 值就是席位(`seats`)。 + +``` +y = df['seats'] +``` + +现在你的数据看起来应该像这样: + +``` +x                               y +('1966', 'Conservative')        253 +('1970', 'Conservative')        330 +('Feb 1974', 'Conservative')    297 +('Oct 1974', 'Conservative')    277 +('1979', 'Conservative')        339 + ...      ...                   ... +('2005', 'Others')              30 +('2010', 'Others')              29 +('2015', 'Others')              80 +('2017', 'Others')              59 +('2019', 'Others')              72 +``` + +Bokeh 需要你将数据封装在它提供的一些对象中,这样它就能给你提供交互功能。将你的 `x` 和 `y` 数据结构封装在一个 `ColumnDataSource` 对象中。 + +``` + from bokeh.models import ColumnDataSource + + source = ColumnDataSource(data={'x': x, 'y': y}) +``` + +然后构造一个 `Figure` 对象,并传入你用 `FactorRange` 对象封装的 `x` 数据。 + +``` +    from bokeh.plotting import figure +    from bokeh.models import FactorRange +    +    p = figure(x_range=FactorRange(*x), width=2000, title="Election results") +``` + +你需要让 Bokeh 创建一个颜色表,这是一个特殊的 `DataSpec` 字典,它根据你给它的颜色映射生成。在这种情况下,颜色表是一个简单的党派名称和一个十六进制值之间的映射。 + +``` +    from bokeh.transform import factor_cmap + +    cmap = { +        'Conservative': '#0343df', +        'Labour': '#e50000', +        'Liberal': '#ffff14', +        'Others': '#929591', +    } +    fill_color = factor_cmap('x', palette=list(cmap.values()), factors=list(cmap.keys()), start=1, end=2) +``` + +现在你可以创建条形图了: + +``` +    p.vbar(x='x', top='y', width=0.9, source=source, fill_color=fill_color, line_color=fill_color) +``` + +Bokeh 图表上数据的可视化形式被称为“字形glyphs”,因此你已经创建了一组条形字形。 + +调整图表的细节,让它看起来像你想要的样子。 + +``` +    p.y_range.start = 0 +    p.x_range.range_padding = 0.1 +    p.yaxis.axis_label = 'Seats' +    p.xaxis.major_label_orientation = 1 +    p.xgrid.grid_line_color = None +``` + +最后,告诉 Bokeh 你现在想看你的绘图: + +``` +   from bokeh.io import show + +   show(p) +``` + +这将绘图写入一个 HTML 文件,并在默认的 Web 浏览器中打开它。如下结果: + +![][6] + +*Bokeh 中的多条形绘图(©2019年[Anvil][5])* + +它已经有了一些互动功能,比如盒子缩放。 + +![][7] 。 + +*Bokeh 内置的盒子缩放(©2019[Anvil][5])* + +但 Bokeh 的厉害之处在于你可以添加自己的交互性。在下一节中,我们通过在条形图中添加工具提示来探索这个问题。 + +### 给条形图添加工具提示 + +要在条形图上添加工具提示,你只需要创建一个 `HoverTool` 对象并将其添加到你的绘图中。 + +``` +    h = HoverTool(tooltips=[ +        ('Seats', '@y'), +        ('(Year, Party)', '(@x)') +    ]) +    p.add_tools(h) +``` + +参数定义了哪些数据会显示在工具提示上。变量 `@y` 和 `@x` 是指你传入 `ColumnDataSource` 的变量。你还可以使用一些其他的值。例如,光标在图上的位置由 `$x` 和 `$y` 给出(与 `@x` 和 `@y` 没有关系)。 + +下面是结果: + +![][8] + +*选举图,现在带有工具提示(© 2019 [Anvil][5])* + +借助 Bokeh 的 HTML 输出,将绘图嵌入到 Web 应用中时,你可以获得完整的交互体验。你可以在[这里][9]把这个例子复制为 Anvil 应用(注:Anvil 需要注册才能使用)。 + +现在,你可以看到付出额外努力在 Bokeh 中将所有数据封装在 `ColumnDataSource` 等对象的原因了。作为回报,你可以相对轻松地添加交互性。 + +### 回归简单:Altair + +Bokeh 是四大最流行的绘图库之一,本系列将研究[它们各自的特别之处][3]。 + +我也在研究几个因其有趣的方法而脱颖而出的库。接下来,我将看看 [Altair][10],它的声明式 API 意味着它可以做出非常复杂的绘图,而不会让你头疼。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/bokeh-python + +作者:[Shaun Taylor-Morgan][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shaun-taylor-morgan +[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://bokeh.org/ +[3]: https://linux.cn/article-12327-1.html +[4]: https://opensource.com/sites/default/files/uploads/bokeh-closeup.png (A zoomed-in view on the plot) +[5]: https://anvil.works/blog/plotting-in-bokeh +[6]: https://opensource.com/sites/default/files/uploads/bokeh_0.png (A multi-bar plot in Bokeh) +[7]: https://opensource.com/sites/default/files/uploads/bokeh-box-zoom.gif (Bokeh's built-in box zoom) +[8]: https://opensource.com/sites/default/files/uploads/bokeh-tooltips.gif (The election graph, now with tooltips) +[9]: https://anvil.works/build#clone:CFRUWSM6PQ6JUUXH%3dSX4SACDSXBB4UOIVEVPWXH55%7cMYTOLCU2HM5WKJYM%3d6VJKGRSF74TCCVDG5CTVDOCS +[10]: https://altair-viz.github.io/ +[11]: https://opensource.com/article/20/4/install-python-linux +[12]: https://opensource.com/article/19/5/python-3-default-mac +[13]: https://opensource.com/article/19/8/how-install-python-windows \ No newline at end of file diff --git a/published/202006/20200529 How to find and remove broken symlinks on Linux.md b/published/202006/20200529 How to find and remove broken symlinks on Linux.md new file mode 100644 index 0000000000..0c67037b00 --- /dev/null +++ b/published/202006/20200529 How to find and remove broken symlinks on Linux.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12298-1.html) +[#]: subject: (How to find and remove broken symlinks on Linux) +[#]: via: (https://www.networkworld.com/article/3546252/how-to-find-and-remove-broken-symlinks-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何在 Linux 上查找和删除损坏的符号链接 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/09/095016y7ranx1tssxdsttd.jpg) + +> 符号链接是指向另一个文件的 Linux 文件。如果删除了被引用的文件,符号链接会保留,但不会显示有问题,除非你尝试使用它。以下是查找和删除指向文件已被删除的符号链接的简单方法。 + +符号链接symbolic link在 Linux 系统上扮演了非常有用的角色。它们可以帮助你记住重要文件在系统上的位置,使你更容易访问这些文件,并让你不必为了更方便访问大文件而复制它们,从而节省了大量的空间。 + +### 什么是符号链接? + +通常称它们为“符号链接”或“软链接”,符号链接是非常小的文件。实际上,符号链接真正包含的是它指向的文件的名称,通常包含路径(相对于当前位置或绝对路径)。如果有个名为 `ref1` 的文件指向名为 `/apps/refs/ref-2020` 的文件,那么 `ref1` 的长度将为 19 个字符,即使 `ref-202` 文件有 2TB。如果指向 `./ref-2020`,那么长度仅为 10 个字符。如果指向 `ref-2020`,那么只有 8 个字节。 + +如果你执行 `vi ref1` 之类的命令(其中 `ref1` 是符号链接的名称),你将编辑 `ref1` 指向的文件,而不是符号链接本身的内容。Linux 系统知道如何使用符号链接,并且可以做正确的事。同样,如果你使用诸如 `cat`、`more`、`head` 或 `tail` 之类的命令,那么将查看引用文件的内容。 + +另一方面,如果删除符号链接,你将删除该链接,而不是引用的文件。再说一次,Linux 知道怎么做。符号链接使得使用和共享文件更加容易,仅此而已。 + +#### 符号链接损坏时 + +当一个符号链接所指向的文件从系统中删除或重新命名时,符号链接将不再起作用。符号链接只不过是存储在某个特定目录中的引用而已,它不会随着指向它的文件发生变化而更新或删除。它一直指向被引用的文件,即使这个文件早已消失。 + +如果你尝试使用指向一个不存在的文件的符号链接,那么将出现如下错误: + +``` +$ tail whassup +tail: cannot open 'whassup' for reading: No such file or directory +``` + +如果你尝试访问指向自身的符号链接(是的,奇怪的事情发生了),你将看到类似以下的内容: + +``` +$ cat loopy +cat: loopy: Too many levels of symbolic links +$ ls -l loopy +lrwxrwxrwx 1 shs shs 5 May 28 18:07 loopy -> loopy +``` + +而且,如果(上面的)长列表的第一个字母没有引起你的注意,这表示该文件是符号链接。`rwxrwxrwx` 权限是标准权限,并不反映符号链接指向的文件的权限。 + +### 查找损坏的符号链接 + +`find` 命令有一个选项,能让你找到指向不再存在的文件的符号链接。此命令列出当前目录中的符号链接: + +``` +$ find . -type l +``` + +`l` (小写字母 `L`)告诉 `find` 命令查找符号链接。 + +另一方面,下面的命令在当前目录中查找指向*不存在*的文件的符号链接: + +``` +$ find . -xtype l +``` + +为了避免在该命令尝试查找你无权检查的文件或目录时发生错误,你可以将所有错误输出到 `/dev/null`,如下所示: + +``` +$ find . -xtype l 2>/dev/null +``` + +你也可以使用此命令找到损坏的符号链接。它比前面的更长,但做的是同样的事情: + +``` +$ find . -type l ! -exec test -e {} \; -print 2>/dev/null +``` + +### 如何处理损坏的符号链接 + +除非你知道符号链接引用的文件会被替换,否则最好的方法是直接删除损坏的链接。实际上,如果需要,你可以使用一条命令查找并删除损坏的符号链接,如: + +``` +$ find . -xtype l 2>/dev/null -exec rm {} \; +``` + +该命令的 `rm {}` 部分会变成“删除文件”的命令 + +如果你想将符号链接与不同的文件相关联,你必须先删除该符号链接,然后重新创建它,使其指向新文件。这是一个例子: + +``` +$ rm ref1 +$ ln -s /apps/data/newfile ref1 +``` + +### 总结 + +符号链接使引用的文件更易于查找和使用,但有时它会比那些宣传去年已经关闭的餐馆的路标还过分。`find` 命令可以帮助你摆脱损坏的符号链接,或者提醒你没有你可能仍然需要的文件。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3546252/how-to-find-and-remove-broken-symlinks-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.facebook.com/NetworkWorld/ +[2]: https://www.linkedin.com/company/network-world diff --git a/published/202006/20200529 What is the Difference Between Soft link vs Hard link in Linux.md b/published/202006/20200529 What is the Difference Between Soft link vs Hard link in Linux.md new file mode 100644 index 0000000000..da090386ec --- /dev/null +++ b/published/202006/20200529 What is the Difference Between Soft link vs Hard link in Linux.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12270-1.html) +[#]: subject: (What is the Difference Between Soft link vs Hard link in Linux?) +[#]: via: (https://www.2daygeek.com/difference-between-soft-link-vs-hard-link-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + + +Linux 中软链接和硬链接的区别 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/01/082717bilg8nmx808oxzgn.jpg) + +链接Link是一种快捷访问机制,它通过一个文件指向原始文件或目录的方式实现快捷访问,同时还记录了原始文件或目录的一些信息。 + +链接允许多个不同文件对同一个文件进行引用。 + +### 什么是软链接 + +符号链接Symbolic Link(symlink),又称软链接Soft Link,是一种特殊的文件,它指向 Linux 系统上的另一个文件或目录。 + +这和 Windows 系统中的快捷方式有点类似,链接文件中记录的只是原始文件的路径,并不记录原始文件的内容。 + +符号链接通常用于对库文件进行链接,也常用于链接日志文件和网络文件系统Network File System(NFS)上共享的目录。 + +### 什么是硬链接 + +硬链接是原始文件的一个镜像副本。创建硬链接后,如果把原始文件删除,链接文件也不会受到影响,因为此时原始文件和链接文件互为镜像副本。 + +为什么要创建链接文件而不直接复制文件呢? + +当你需要将同一个文件保存在多个不同位置,而且还要保持持续更新的时候,硬链接的重要性就体现出来了。 + +如果你只是单纯把文件复制到另一个位置,那么另一个位置的文件只会保存着复制那一刻的文件内容,后续也不会跟随着原始文件持续更新。 + +而使用硬链接时,各个镜像副本的文件内容都会同时更新。 + +### 软链接和硬链接的区别 + +下表列出了软链接和硬链接之间的区别。 + +\# | 软链接 | 硬链接 +---|---|--- +1 | 软链接类似于 Windows 系统中的快捷方式 | 硬链接是原始文件的一个镜像副本 +2 | 软链接又称符号链接 | 硬链接没有别名 +3 | 链接中任何一个文件发生改变,都会同步到连接中的其它文件 | 和软链接一样 +4 | 软链接可以跨文件系统进行创建 | 硬链接不可以跨文件系统进行创建 +5 | 软链接可以指向文件或目录 | 硬链接只能指向文件 +6 | 链接文件和原始文件之间的 inode 和文件权限不完全一致 | 链接文件和原始文件的 inode 和文件权限完全一致 +7 | 链接文件只记录原始文件的路径,不记录原始文件的内容 | 链接文件记录了原始文件的内容 +8 | 如果原始文件被移除,软链接就会因为指向不存在的文件而失效。这被称为“挂起链接hanging link” | 即使原始文件被移除,链接文件也不受影响。 +9 | 通过 `ln -s <原始文件> <链接文件>` 命令创建软链接 | 通过 `ln <原始文件> <链接文件>` 命令创建硬链接 +10 | 软链接文件的文件权限中有一个特殊标记 `l` | 硬链接文件没有特殊标记 +11 | 通过 `find / -type l` 命令可以查找软链接文件 | 通过 `find / -samefile <原始文件>` 命令可以查找硬链接文件 +12 | 通过 `symlinks <目录>` 命令可以查找失效的软链接 | 硬链接不存在失效链接 + + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/difference-between-soft-link-vs-hard-link-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 diff --git a/published/202006/20200531 Looking for Some Good Note Taking Apps on Linux- Here are the Best Notes Apps we Found for You.md b/published/202006/20200531 Looking for Some Good Note Taking Apps on Linux- Here are the Best Notes Apps we Found for You.md new file mode 100644 index 0000000000..f2fafaa32c --- /dev/null +++ b/published/202006/20200531 Looking for Some Good Note Taking Apps on Linux- Here are the Best Notes Apps we Found for You.md @@ -0,0 +1,290 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12307-1.html) +[#]: subject: (Looking for Some Good Note Taking Apps on Linux? Here are the Best Notes Apps we Found for You) +[#]: via: (https://itsfoss.com/note-taking-apps-linux/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +9 款 Linux 上的最佳笔记应用 +====== + +无论你做什么,做笔记总是一个好习惯。是的,有很多笔记应用可以帮助你实现这个目标。但是,Linux 上的开源笔记应用怎么样呢? + +别担心,你不需要无休止地在互联网上搜索,就能找到 Linux 下最好的笔记应用。在这里,我挑选了一些最令人印象深刻的开源笔记应用。 + +![][1] + +请注意,此列表没有特定的排名顺序。 + +### 1、Joplin + +![][2] + +主要功能: + +* 支持 Markdown +* 支持附件 +* 支持加密 +* 跨平台,包括 Android 应用 + +[Joplin][9] 是一款令人印象深刻的自由开源笔记应用,支持加密。凭借其提供的出色的功能,它也是目前[最好的 Evernote 替代品][3]之一。事实上,我就是因为它提供的功能才从 Evernote 转移到 Joplin。 + +你可以选择添加待办事项列表、普通笔记,或者把它作为一个 Markdown 编辑器来写东西。它适用于 Linux、Windows、macOS、Android 和 iOS。你还可以选择使用 [Dropbox][4]、OneDrive、[NextCloud][5] 或 WebDAV 来同步你的笔记。 + +如果你好奇,可以阅读我们关于 [Joplin][6] 的详细文章来了解更多。 + +#### 如何安装? + +你可以用一个 AppImage 文件来安装 Joplin。我已经在 Ubuntu 20.04 LTS 上试过了,和预期的一样没有问题。要找到该文件,你可以前往其官方网站或探索他们的 [GitHub 页面][7]。 + +如果你不知道如何安装它,请按照我们的[使用 AppImage 文件][8]指南来开始。 + +另外,如果你想使用终端,你可以键入下面的命令,通过脚本来安装它(在这个过程中还会添加一个桌面图标)。 + +``` +wget -O - https://raw.githubusercontent.com/laurent22/joplin/master/Joplin_install_and_update.sh | bash +``` + +### 2、Simplenote + +![][10] + +主要功能: + +* 支持 Markdown +* 简约的用户界面 +* 通过你的 Simplenote 帐户轻松地进行同步 +* 有 32 位软件包 +* 跨平台,包括移动应用程序 + +顾名思义,它是一款简约的自由开源笔记应用。 + +由 [Automattic][11](WordPress 背后的公司)开发,[Simplenote][13] 可以让你在多个设备上无缝同步你的笔记。它支持 Android、iOS、Windows、Linux,以及 macOS。 + +与其它一些笔记应用不同的是,你会注意到它的界面非常简单,可能不会提供很多功能。但是,你可以为你的笔记添加标签。 + +#### 如何安装? + +它提供了 .deb / .rpm 软件包以及一个 AppImage 文件。你可以在它的 [GitHub 发布部分][12]中找到这些文件。 + +### 3、Laverna + +**注:** 它已经不再积极开发了,但它仍然可以正常工作。 + +![][14] + +主要功能: + +* 支持 Markdown +* 支持加密 +* 支持同步 + +[Laverna][15] 是一个有趣的开源笔记应用程序,还提供加密(这是可选的)。 + +你可以把它作为一个基于 Web 的笔记应用,也可以作为电脑上的应用使用。它适用于 Linux、Mac 和 Windows。 + +虽然它除了支持加密外,还具有记事本应用的所有基本功能,但并没有一个可以使用的移动应用。所以,这是一个只有当你是一个桌面用户,并且在 Web 浏览器上完成大部分事情时才能使用的东西。 + +#### 如何安装? + +它提供了一个压缩文件,可在其[官方网站][15]上获得。下载之后,你需要解压并启动可执行文件来开始。 + +### 4、Standard Notes + +![][16] + +主要功能: + +* 支持 Markdown +* 支持加密 +* 支持同步 +* 笔记的版本历史(付费计划) +* 跨平台,包括移动应用程序 +* 提供了 32 位包。 +* 提供付费选择 + +又一款开源笔记应用,为你的笔记和附件提供加密。 + +与 Laverna 不同,[Standard Notes][18] 正在积极开发中。虽然它提供了大量的功能,但其中一些功能以“扩展功能”或扩展插件仅提供给付费用户,这是偏昂贵的(每月订阅)。你也可以参考我们另外一篇关于 [Standard Notes][17] 的文章来了解更多信息。 + +总的来说,你会得到 Markdown 支持、加密附件和笔记的能力、版本历史、备份支持(OneDrive、Google Drive 等)以及更多这样有用的功能。 + +#### 如何安装? + +它提供了一个 AppImage 文件,可以在你的 Linux 发行版上安装它。你只需要前往它的[官方网站][18]下载即可。如果你不知道如何使用这个文件,可以参考我们的 [AppImage 指南][8]。 + +对于其他可用的软件包或源代码,你可以参考他们的 [GitHub 页面][19]。 + +### 5、Boost Note + +![][20] + +主要功能: + +* 支持 Markdown +* 适用于开发者 +* 跨平台 + +[Boost Note][21] 是一款对使用 Linux 的程序员有用的笔记应用。你可以用它写你的代码,也可以用来写笔记、文档等等。 + +它提供了一个简洁直观的用户界面,并提供了 Linux 上笔记应用的所有基本功能。 + +#### 如何安装? + +你可以选择其[官网][22]上为 Ubuntu 提供的 .deb 文件。如果你想在其他 Linux 发行版上尝试,你还可以找到一个 AppImage 文件来开始使用。 + +如果你好奇,也可以查看他们的 [GitHub 页面][23]来探索更多关于它的内容或复刻它。 + +### 6、Tomboy Notes(新一代) + +![][24] + +主要功能: + +* 轻量级笔记应用 +* 支持同步 +* 跨平台 + +一款轻量级且极其简单的记事应用怎么样? + +好吧,你可能知道旧版的 [Tomboy Notes][25] 已经不再开发了。幸运的是,有一个新一代的 [Tomboy Notes NG][27] 版本。你可以配置存储笔记的路径,并快速开始记笔记。 + +这款应用仅仅只有约 2MB 的下载量。所以,如果你正在寻找一个轻量级的解决方案 —— 那就是它。它可能无法用于智能手机,但你肯定可以在 Windows、Linux 和 MacOS 上使用它。 + +#### 如何安装? + +你可以在他们的 [GitHub 发布部分][26]中找到 .deb / .rpm 和其他包。对于其他的 Linux 发行版,你可以关注他们 GitHub 页面的文档来了解更多。 + +### 7、RedNoteBook + +![][28] + +主要功能 + +* 传统的日记式记事应用 +* 有模板 +* 离线使用 + +对于想要在 Linux 上使用离线笔记应用的用户来说,[RedNotebook][30] 应该是一个不错的选择。 + +是的,它不支持同步,如果你是一个不想要同步功能的人,RedNoteBook 应该是一款传统风格的记事应用,侧边栏为日历。 + +它主要是为喜欢离线日记的用户量身定做的。它还为你提供了几个模板,方便你创建某些笔记。 + +#### 如何安装? + +如果你使用的是 Ubuntu(或者其他基于 Ubuntu 的发行版),你可以通过 PPA 来安装它。下面是你在终端中输入的安装方法: + +``` +sudo add-apt-repository ppa:rednotebook/stable +sudo apt-get update +sudo apt-get install rednotebook +``` + +对于其他的 Linux 发行版,你可以得到 [Flatpak 软件包][29]。 + +### 8、TagSpaces + +![][31] + +主要特点: + +* 丰富的用户界面 +* 支持管理文件 +* 支持同步 +* 提供付费选择 + +[TagSpaces][34] 是一款适用于 Linux 的精美笔记应用。不仅仅局限于创建笔记,你还可以管理照片和其他文档。 + +与其他一些可用的笔记应用不同,它不提供加密功能。所以,你可以尝试像 [Syncthing][32] 这样支持 Dropbox 和 Nextcloud 的工具来安全地同步你的数据。 + +如果你想要特定的功能和支持,你也可以选择它的付费计划。 + +#### 如何安装? + +你可以在他们的 [GitHub 发布区][33]中找到 .deb 文件和一个 AppImage 文件来安装。无论哪种情况,你都可以把它也构建起来。 + +### 9、Trilium Notes + +![][35] + +主要功能: + +* 分层记事应用 +* 支持加密 +* 支持同步 + +[Trilium Notes][39] 并不只是又一款笔记应用,它是一款专注于建立个人知识库的分层笔记应用。 + +是的,你也可以将它用于普通用途 —— 但它是为特定用户量身定制的,他们希望能够以分层方式管理笔记。 + +我个人还没有使用过 —— 除了测试。欢迎试用,多多探讨。 + +#### 如何安装? + +只需前往其 [GitHub 发布区][36],并抓取 [.deb 文件在 Ubuntu 上安装][37]。如果你正在寻找其他 Linux 发行版上可用的软件包,你也可以从源代码构建它,或者下载并[解压缩文件][38]。 + +### 总结 + +我对 Linux 上的笔记应用的推荐到此结束。我已经用过很多个,目前决定用 Simplenote 来做快速笔记,用 Joplin 来收集章节中的笔记。 + +你是否知道一些应该包括在这个列表中的其它 Linux 笔记应用程序?为什么不在评论区告诉我们呢? + +你更喜欢哪个笔记应用程序?我很想知道你通常在 Linux 上寻找的最好的笔记应用程序是什么。 + +欢迎在下面的评论部分分享你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/note-taking-apps-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/Note-Taking-Apps-linux.jpg?ssl=1 +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/joplin_ubuntu.jpg?ssl=1 +[3]: https://itsfoss.com/5-evernote-alternatives-linux/ +[4]: https://www.dropbox.com/ +[5]: https://nextcloud.com/ +[6]: https://linux.cn/article-11896-1.html +[7]: https://github.com/laurent22/joplin +[8]: https://itsfoss.com/use-appimage-linux/ +[9]: https://joplinapp.org/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/simplenote-new.jpg?ssl=1 +[11]: https://automattic.com/ +[12]: https://github.com/Automattic/simplenote-electron/releases/tag/v1.16.0 +[13]: https://simplenote.com +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/laverna.png?resize=800%2C623&ssl=1 +[15]: https://laverna.cc +[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/standard-notes-shot.jpg?resize=800%2C578&ssl=1 +[17]: https://itsfoss.com/standard-notes/ +[18]: https://standardnotes.org +[19]: https://github.com/standardnotes +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/10/boostnote.png?resize=800%2C579&ssl=1 +[21]: https://itsfoss.com/boostnote-linux-review/ +[22]: https://boostnote.io/ +[23]: https://github.com/BoostIO/Boostnote +[24]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/tomboy-notes-ng.jpg?ssl=1 +[25]: https://github.com/tomboy-notes/tomboy +[26]: https://github.com/tomboy-notes/tomboy-ng/releases +[27]: https://github.com/tomboy-notes/tomboy-ng +[28]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/rednotebook.png?ssl=1 +[29]: https://flathub.org/apps/details/app.rednotebook.RedNotebook +[30]: https://rednotebook.sourceforge.io +[31]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/10/tagspaces.png?resize=800%2C523&ssl=1 +[32]: https://itsfoss.com/syncthing/ +[33]: https://github.com/tagspaces/tagspaces/releases/ +[34]: https://www.tagspaces.org/ +[35]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/trilium-notes.png?ssl=1 +[36]: https://github.com/zadam/trilium/releases +[37]: https://itsfoss.com/install-deb-files-ubuntu/ +[38]: https://itsfoss.com/unzip-linux/ +[39]: https://github.com/zadam/trilium/ diff --git a/published/202006/20200601 How to write a VS Code extension.md b/published/202006/20200601 How to write a VS Code extension.md new file mode 100644 index 0000000000..366052a86a --- /dev/null +++ b/published/202006/20200601 How to write a VS Code extension.md @@ -0,0 +1,298 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12310-1.html) +[#]: subject: (How to write a VS Code extension) +[#]: via: (https://opensource.com/article/20/6/vs-code-extension) +[#]: author: (Ashique Hussain Ansari https://opensource.com/users/uidoyen) + +如何编写 VS Code 扩展 +====== + +> 通过为流行的代码编辑器编写自己的扩展来添加缺失的功能。 + +![](https://img.linux.net.cn/data/attachment/album/202006/13/105415w5u1d0z5bdoneb82.jpg) + +Visual Studio Code(VS Code)是微软为 Linux、Windows 和 macOS 创建的跨平台代码编辑器。遗憾的是,微软版本的 [VS Code][2] 是在 [Microsoft Software License][3] 下发布的,这不是一个开源的许可证。然而,它的源代码是开源的,在 MIT 许可证下由 [VSCodium][4] 项目发布。 + +VSCodium 和 VS Code一样,支持扩展、内嵌式 Git 控制、GitHub 集成、语法高亮、调试、智能代码补完、代码片段等。换句话说,对于大多数用户来说,使用 VS Code 和 VSCodium 没有什么区别,而且后者是完全开源的! + +### 什么是 VS Code 扩展? + +扩展extension可以让你为 VS Code 或 VSCodium 添加功能。你可以在 GUI 中或从终端安装扩展。 + +你也可以构建自己的扩展。有几个你可能想学习如何构建扩展的原因: + +1. **想要添加一些功能:** 如果缺失你想要的功能,你可以创建一个扩展来添加它。 +2. **为了乐趣和学习:** 扩展 API 允许你探索 VSCodium 是如何工作的,这是一件有趣的事情。 +3. **为了提高您的技能:** 创建扩展可以提高你的编程技能。 +4. **为了成名:** 创建一个对他人有用的扩展可以提高你的公众形象。 + +### 安装工具 + +在你开始之前,你必须已经安装了 [Node.js][5]、[npm][6] 和 VS Code 或 [VSCodium][4]。 + +要生成一个扩展,你还需要以下工具:[Yeoman][7],是一个开源的客户端脚手架工具,可以帮助你搭建新项目;以及 [vscode-generator-code][8],是 VS Code 团队创建的 Yeoman 生成器。 + +### 构建一个扩展 + +在本教程中,你将构建一个扩展,它可以为应用程序初始化一个 Docker 镜像。 + +#### 生成一个扩展骨架 + +要在全局范围内安装并运行 Yeoman 生成器,请在命令提示符或终端中输入以下内容: + +``` +npm install -g yo generator-code +``` + +导航到要生成扩展的文件夹,键入以下命令,然后按回车: + +``` +yo code +``` + +根据提示,你必须回答一些关于你的扩展的问题: + +* **你想创建什么类型的扩展?** 使用上下箭头选择其中一个选项。在本文中,我将只介绍第一个选项,`New Extension (TypeScript)`。 +* **你的扩展名称是什么?** 输入你的扩展名称。我的叫 `initdockerapp`。(我相信你会有一个更好的名字。) +* **你的扩展的标识符是什么?** 请保持原样。 +* **你的扩展的描述是什么?** 写一些关于你的扩展的内容(你可以现在填写或稍后编辑它)。 +* **初始化 Git 仓库?** 这将初始化一个 Git 仓库,你可以稍后添加 `set-remote`。 +* **使用哪个包管理器?** 你可以选择 `yarn` 或 `npm`;我使用 `npm`。 + +按回车键后,就会开始安装所需的依赖项。最后显示: + +> "Your extension **initdockerapp** has been created!" + +干的漂亮! + +### 检查项目的结构 + +检查你生成的东西和项目结构。导航到新的文件夹,并在终端中键入 `cd initdockerapp`。 + +一旦你进入该目录,键入 `.code`。它将在你的编辑器中打开,看起来像这样。 + +![Project file structure in VSCodium][9] + +(Hussain Ansari, [CC BY-SA 4.0][10]) + +最需要注意的两个文件是 `src` 文件夹内的 `package.json` 和 `extension.ts`。 + +#### package.json + +首先来看看 `package.json`,它应该是这样的。 + +``` +{ + "name": "initdockerapp", + "displayName": "initdockerapp", + "description": "", + "version": "0.0.1", + "engines": { + "vscode": "^1.44.0" + }, + "categories": [ + "Other" + ], + "activationEvents": [ + "onCommand:initdockerapp.initialize" + ], + "main": "./out/extension.js", + "contributes": { + "commands": [ + { + "command": "initdockerapp.initialize", + "title": "Initialize A Docker Application" + } + ] + }, + "scripts": { + "vscode:prepublish": "npm run compile", + "compile": "tsc -p ./", + "lint": "eslint src --ext ts", + "watch": "tsc -watch -p ./", + "pretest": "npm run compile && npm run lint", + "test": "node ./out/test/runTest.js" + }, + "devDependencies": { + "@types/vscode": "^1.44.0", + "@types/glob": "^7.1.1", + "@types/mocha": "^7.0.2", + "@types/node": "^13.11.0", + "eslint": "^6.8.0", + "@typescript-eslint/parser": "^2.26.0", + "@typescript-eslint/eslint-plugin": "^2.26.0", + "glob": "^7.1.6", + "mocha": "^7.1.1", + "typescript": "^3.8.3", + "vscode-test": "^1.3.0" + } +} +{ + "name": "initdockerapp", + "displayName": "initdockerapp", + "description": "", + "version": "0.0.1", + "engines": { + "vscode": "^1.44.0" + }, + "categories": [ + "Other" + ], + "activationEvents": [ + "onCommand:initdockerapp.initialize" + ], + "main": "./out/extension.js", + "contributes": { + "commands": [ + { + "command": "initdockerapp.initialize", + "title": "Initialize A Docker Application" + } + ] + }, + "scripts": { + "vscode:prepublish": "npm run compile", + "compile": "tsc -p ./", + "lint": "eslint src --ext ts", + "watch": "tsc -watch -p ./", + "pretest": "npm run compile && npm run lint", + "test": "node ./out/test/runTest.js" + }, + "devDependencies": { + "@types/vscode": "^1.44.0", + "@types/glob": "^7.1.1", + "@types/mocha": "^7.0.2", + "@types/node": "^13.11.0", + "eslint": "^6.8.0", + "@typescript-eslint/parser": "^2.26.0", + "@typescript-eslint/eslint-plugin": "^2.26.0", + "glob": "^7.1.6", + "mocha": "^7.1.1", + "typescript": "^3.8.3", + "vscode-test": "^1.3.0" + } +} +``` + +如果你是 Node.js 开发者,其中一些可能看起来很熟悉,因为 `name`、`description`、`version` 和 `scripts` 是 Node.js 项目的常见部分。 + +有几个部分是非常重要的: + +* `engines`:说明该扩展将支持哪个版本的 VS Code / VSCodium。 +* `categories`:设置扩展类型;你可以从 `Languages`、`Snippets`、`Linters`、`Themes`、`Debuggers`、`Formatters`、`Keymaps` 和 `Other` 中选择。 +* `contributes`:可用于与你的扩展一起运行的命令清单。 +* `main`:扩展的入口点。 +* `activationEvents`:指定激活事件发生的时间。具体来说,这决定了扩展何时会被加载到你的编辑器中。扩展是懒加载的,所以在激活事件触发之前,它们不会被激活。 + +#### src/extension.ts + +接下来看看 `src/extension.ts`,它应该是这样的: + +``` +// The module 'vscode' contains the VSCodium extensibility API +// Import the module and reference it with the alias vscode in your code below +import * as vscode from "vscode"; +const fs = require("fs"); +const path = require("path"); + +// this method is called when your extension is activated +// your extension is activated the very first time the command is executed +export function activate(context: vscode.ExtensionContext) { + + // Use the console to output diagnostic information (console.log) and errors (console.error) + // This line of code will only be executed once when your extension is activated + console.log('Congratulations, your extension "initdockerapp" is now active!'); + + // The command has been defined in the package.json file + // Now provide the implementation of the command with registerCommand + // The commandId parameter must match the command field in package.json + let disposable = vscode.commands.registerCommand('initdockerapp.initialize', () => { + // The code you place here will be executed every time your command is executed + + let fileContent =` + FROM node:alpine + WORKDIR /usr/src/app + + COPY package.json . + RUN npm install + + COPY . . + + EXPOSE 3000 + CMD ["npm", "start"] + `; + + fs.writeFile(path.join(vscode.workspace.rootPath, "Dockerfile"), fileContent, (err:any) => { + if (err) { + return vscode.window.showErrorMessage("Failed to initialize docker file!"); + } + vscode.window.showInformationMessage("Dockerfile has been created!"); + }); + }); + + context.subscriptions.push(disposable); +} + +// this method is called when your extension is deactivated +export function deactivate() {} +``` + +这是为你的扩展写代码的地方。已经有一些自动生成的代码了,我再来分析一下。 + +注意,`vscode.command.registerCommand` 里面的 `initdockerapp.initialize` 和 `package.json` 里面的命令是一样的。它需要两个参数。 + +1. 要注册的命令名称 +2. 执行命令的功能 + +另一个需要注意的函数是 `fs.writeFile`,这是你写在 `vscode.command.registerCommand` 函数里面的。这将在你的项目根目录下创建一个 Dockerfile,并在其中附加代码来创建一个 Docker 镜像。 + +### 调试扩展 + +现在你已经写好了扩展,是时候调试它了。点击“Run”菜单,选择“Start Debugging”(或者直接按 `F5`)打开调试窗口。 + +在调试窗口里面点击“Add Folder”或“Clone Repository”按钮,打开该项目。 + +接下来,用 `Ctrl+Shift+P`(在 macOS 上,用 `Command` 键代替 `Ctrl`)打开命令面板,运行 `Initialize A Docker Application`。 + +* 第一次运行此命令时,自 VSCodium 启动后,激活函数尚未执行。因此,调用激活函数,并由激活 函数注册该命令。 +* 如果命令已注册,那么它将被执行。 + +你会看到右下角有一条信息,上面写着:`Dockerfile has been created!`。这就创建了一个 Dockerfile,里面有一些预定义的代码,看起来是这样的: + +![Running the new extension command][11] + +(Hussain Ansari, [CC BY-SA 4.0][10]) + +### 总结 + +有许多有用的 API 可以帮助你创建你想要构建的扩展。VS Code 扩展 API 还有许多其他强大的方法可以使用。 + +你可以在 VS Code 扩展 API 文档中了解更多关于 VS Code API 的信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/vs-code-extension + +作者:[Ashique Hussain Ansari][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/uidoyen +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: https://code.visualstudio.com/ +[3]: https://code.visualstudio.com/license +[4]: https://vscodium.com/ +[5]: https://nodejs.org/en/ +[6]: https://www.npmjs.com/ +[7]: https://yeoman.io/ +[8]: https://github.com/Microsoft/vscode-generator-code +[9]: https://opensource.com/sites/default/files/uploads/vscode-tree.png (Project file structure in VSCodium) +[10]: https://creativecommons.org/licenses/by-sa/4.0/ +[11]: https://opensource.com/sites/default/files/uploads/vscode-run-command.png (Running the new extension command) diff --git a/published/202006/20200601 Use FastAPI to build web services in Python.md b/published/202006/20200601 Use FastAPI to build web services in Python.md new file mode 100644 index 0000000000..00dcf9cd0d --- /dev/null +++ b/published/202006/20200601 Use FastAPI to build web services in Python.md @@ -0,0 +1,188 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12280-1.html) +[#]: subject: (Use FastAPI to build web services in Python) +[#]: via: (https://fedoramagazine.org/use-fastapi-to-build-web-services-in-python/) +[#]: author: (Clément Verna https://fedoramagazine.org/author/cverna/) + +使用 Python FastAPI 构建 Web 服务 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/04/105930wr333sx3erz3k2ur.jpg) + +[FastAPI][2] 是一个使用 Python 编写的 Web 框架,还应用了 Python asyncio 库中最新的优化。本文将会介绍如何搭建基于容器的开发环境,还会展示如何使用 FastAPI 实现一个小型 Web 服务。 + +### 起步 + +我们将使用 Fedora 作为基础镜像来搭建开发环境,并使用 Dockerfile 为镜像注入 FastAPI、[Uvicorn][3] 和 [aiofiles][4] 这几个包。 + +``` +FROM fedora:32 +RUN dnf install -y python-pip \ + && dnf clean all \ + && pip install fastapi uvicorn aiofiles +WORKDIR /srv +CMD ["uvicorn", "main:app", "--reload"] +``` + +在工作目录下保存 `Dockerfile` 之后,执行 `podman` 命令构建容器镜像。 + +``` +$ podman build -t fastapi . +$ podman images +REPOSITORY TAG IMAGE ID CREATED SIZE +localhost/fastapi latest 01e974cabe8b 18 seconds ago 326 MB +``` + +下面我们可以开始创建一个简单的 FastAPI 应用程序,并通过容器镜像运行。 + +``` +from fastapi import FastAPI + +app = FastAPI() + +@app.get("/") +async def root(): + return {"message": "Hello Fedora Magazine!"} +``` + +将上面的代码保存到 `main.py` 文件中,然后执行以下命令开始运行: + +``` +$ podman run --rm -v $PWD:/srv:z -p 8000:8000 --name fastapi -d fastapi +$ curl http://127.0.0.1:8000 +{"message":"Hello Fedora Magazine!" +``` + +这样,一个基于 FastAPI 的 Web 服务就跑起来了。由于指定了 `--reload` 参数,一旦 `main.py` 文件发生了改变,整个应用都会自动重新加载。你可以尝试将返回信息 `"Hello Fedora Magazine!"` 修改为其它内容,然后观察效果。 + +可以使用以下命令停止应用程序: + +``` +$ podman stop fastapi +``` + +### 构建一个小型 Web 服务 + +接下来我们会构建一个需要 I/O 操作的应用程序,通过这个应用程序,我们可以看到 FastAPI 自身的特点,以及它在性能上有什么优势(可以在[这里][5]参考 FastAPI 和其它 Python Web 框架的对比)。为简单起见,我们直接使用 `dnf history` 命令的输出来作为这个应用程序使用的数据。 + +首先将 `dnf history` 命令的输出保存到文件。 + +``` +$ dnf history | tail --lines=+3 > history.txt +``` + +在上面的命令中,我们使用 `tail` 去除了 `dnf history` 输出内容中无用的表头信息。剩余的每一条 `dnf` 事务都包括了以下信息: + + * `id`:事务编号(每次运行一条新事务时该编号都会递增) + * `command`:事务中运行的 `dnf` 命令 + * `date`:执行事务的日期和时间 + +然后修改 `main.py` 文件将相关的数据结构添加进去。 + +``` +from fastapi import FastAPI +from pydantic import BaseModel + +app = FastAPI() + +class DnfTransaction(BaseModel): + id: int + command: str + date: str +``` + +FastAPI 自带的 [pydantic][6] 库让你可以轻松定义一个数据类,其中的类型注释对数据的验证也提供了方便。 + +再增加一个函数,用于从 `history.txt` 文件中读取数据。 + +``` +import aiofiles + +from fastapi import FastAPI +from pydantic import BaseModel + +app = FastAPI() + +class DnfTransaction(BaseModel): + id: int + command: str + date: str + + +async def read_history(): + transactions = [] + async with aiofiles.open("history.txt") as f: + async for line in f: + transactions.append(DnfTransaction( + id=line.split("|")[0].strip(" "), + command=line.split("|")[1].strip(" "), + date=line.split("|")[2].strip(" "))) + return transactions +``` + +这个函数中使用了 `aiofiles` 库,这个库提供了一个异步 API 来处理 Python 中的文件,因此打开文件或读取文件的时候不会阻塞其它对服务器的请求。 + +最后,修改 `root` 函数,让它返回事务列表中的数据。 + +``` +@app.get("/") +async def read_root(): + return await read_history() +``` + +执行以下命令就可以看到应用程序的输出内容了。 + +``` +$ curl http://127.0.0.1:8000 | python -m json.tool +[ +{ +"id": 103, +"command": "update", +"date": "2020-05-25 08:35" +}, +{ +"id": 102, +"command": "update", +"date": "2020-05-23 15:46" +}, +{ +"id": 101, +"command": "update", +"date": "2020-05-22 11:32" +}, +.... +] +``` + +### 总结 + +FastAPI 提供了一种使用 asyncio 构建 Web 服务的简单方法,因此它在 Python Web 框架的生态中日趋流行。要了解 FastAPI 的更多信息,欢迎查阅 [FastAPI 文档][2]。 + +本文中的代码可以在 [GitHub][7] 上找到。 + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-fastapi-to-build-web-services-in-python/ + +作者:[Clément Verna][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cverna/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/05/fastapi-python-816x345.jpg +[2]: https://fastapi.tiangolo.com/ +[3]: https://www.uvicorn.org/ +[4]: https://github.com/Tinche/aiofiles +[5]: https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=composite&l=z8kflr-v&a=2&f=jz8cg-0-3s-0-3k-6bo-0-0-18y74-8s5c-0 +[6]: https://pydantic-docs.helpmanual.io/ +[7]: https://github.com/cverna/fastapi_app +[8]: https://unsplash.com/@jankubita?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[9]: https://unsplash.com/s/photos/fast-snake?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/published/202006/20200601 When to choose C or Python for a command-line interface.md b/published/202006/20200601 When to choose C or Python for a command-line interface.md new file mode 100644 index 0000000000..868894f61f --- /dev/null +++ b/published/202006/20200601 When to choose C or Python for a command-line interface.md @@ -0,0 +1,247 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12286-1.html) +[#]: subject: (When to choose C or Python for a command-line interface) +[#]: via: (https://opensource.com/article/20/6/c-python-cli) +[#]: author: (Erik O'Shaughnessy https://opensource.com/users/jnyjny) + +用 Python 解析命令行参数 +====== + +> 借鉴 C 语言的历史,学习如何用 Python 编写有用的 CLI 程序。 + +![](https://img.linux.net.cn/data/attachment/album/202006/05/231539dyinqzceci4ci8vv.jpg) + +本文的目标很简单:帮助新的 Python 开发者了解一些关于[命令行接口][2](CLI)的历史和术语,并探讨如何在 Python 中编写这些有用的程序。 + +### 最初…… + +首先,从 [Unix][3] 的角度谈谈命令行界面设计。 + +Unix 是一种计算机操作系统,也是 Linux 和 macOS(以及许多其他操作系统)的祖先。在图形用户界面之前,用户通过命令行提示符与计算机进行交互(想想如今的 [Bash][4] 环境)。在 Unix 下开发这些程序的主要语言是 [C][5],它的[功能][6]非常强大。 + +因此,我们至少应该了解 [C 程序][7]的基础知识。 + +假设你没有读过上面那个链接的内容,C 程序的基本架构是一个叫做 `main` 的函数,它的签名是这样的。 + +``` +   int main(int argc, char **argv) +   { +   ... +   } +``` + +对于 Python 程序员来说,这应该不会显得太奇怪。C 函数首先有一个返回类型、一个函数名,然后是括号内的类型化参数。最后,函数的主体位于大括号之间。函数名 `main` 是[运行时链接器][8](构造和运行程序的程序)如何决定从哪里开始执行你的程序。如果你写了一个 C 程序,而它没有包含一个名为 `main` 的函数,它将什么也做不了。伤心。 + +函数参数变量 `argc` 和 `argv` 共同描述了程序被调用时用户在命令行输入的字符串列表。在典型的 Unix 命名传统中,`argc` 的意思是“参数计数argument count”,`argv` 的意思是“参数向量argument vector”。向量听起来比列表更酷,而 `argl` 听起来就像一个要勒死的求救声。我们是 Unix 系统的程序员,我们不求救。我们让*其他人*哭着求救。 + +#### 再进一步 + +``` +$ ./myprog foo bar -x baz +``` + +如果 `myprog` 是用 C 语言实现的,则 `argc` 的值是 5,而 `argv` 是一个有五个条目的字符指针数组。(不要担心,如果这听起来过于技术,那换句话说,这是一个由五个字符串组成的列表。)向量中的第一个条目 `argv[0]` 是程序的名称。`argv` 的其余部分包含参数。 + +``` +   argv[0] == "./myprog" +   argv[1] == "foo" +   argv[2] == "bar" +   argv[3] == "-x" +   argv[4] == "baz" +    +   /* 注:不是有效的 C 代码 */ +``` + +在 C 语言中,你有很多方法来处理 `argv` 中的字符串。你可以手动地循环处理数组 `argv`,并根据程序的需要解释每个字符串。这相对来说比较简单,但会导致程序的接口大相径庭,因为不同的程序员对什么是“好”有不同的想法。 + +``` +include + +/* 一个打印 argv 内容的简单 C 程序。 */ + +int main(int argc, char **argv) { + int i; + + for(i=0; i +#include + +#define OPTSTR "b:f:" + +extern char *optarg; + +int main(int argc, char **argv) { + int opt; + char *bar = NULL; + char *foo = NULL; + + while((opt=getopt(argc, argv, OPTSTR)) != EOF) + switch(opt) { + case 'b': + bar = optarg; + break; + case 'f': + foo = optarg; + break; + case 'h': + default': + fprintf(stderr, "Huh? try again."); + exit(-1); + /* NOTREACHED */ + } + printf("%s\n", foo ? foo : "Empty foo"); + printf("%s\n", bar ? bar : "Empty bar"); +} +``` + +就个人而言,我*希望* Python 有*开关*,但这[永远][12]、永远不会[发生][13]。 + +#### GNU 时代 + +[GNU][14] 项目出现了,并为他们实现的传统 Unix 命令行工具引入了更长的格式参数,比如`--file-format foo`。当然,我们这些 Unix 程序员很讨厌这样,因为打字太麻烦了,但是就像我们这些旧时代的恐龙一样,我们输了,因为用户*喜欢*更长的选项。我从来没有写过任何使用 GNU 风格选项解析的代码,所以这里没有代码示例。 + +GNU 风格的参数也接受像 `-f foo` 这样的短名,也必须支持。所有这些选择都给程序员带来了更多的工作量,因为他们只想知道用户要求的是什么,然后继续进行下去。但用户得到了更一致的用户体验:长格式选项、短格式选项和自动生成的帮助,使用户不必再试图阅读臭名昭著的难以解析的[手册][15]页面(参见 [ps][16] 这个特别糟糕的例子)。 + +### 但我们正在讨论 Python? + +你现在已经接触了足够多(太多?)的命令行的历史,对如何用我们最喜欢的语言来编写 CLI 有了一些背景知识。Python 在命令行解析方面给出了类似的几个选择:自己解析,自给自足batteries-included的方式,以及大量的第三方方式。你选择哪一种取决于你的特定情况和需求。 + +#### 首先,自己解析 + +你可以从 [sys][17] 模块中获取程序的参数。 + +``` +import sys + +if __name__ == '__main__': +   for value in sys.argv: +       print(value) +``` + +#### 自给自足 + +在 Python 标准库中已经有几个参数解析模块的实现:[getopt][18]、[optparse][19],以及最近的 [argparse][20]。`argparse` 允许程序员为用户提供一致的、有帮助的用户体验,但就像它的 GNU 前辈一样,它需要程序员做大量的工作和“[模板代码][21]”才能使它“奏效”。 + +``` +from argparse import ArgumentParser + +if __name__ == "__main__": + +   argparser = ArgumentParser(description='My Cool Program') +   argparser.add_argument("--foo", "-f", help="A user supplied foo") +   argparser.add_argument("--bar", "-b", help="A user supplied bar") +    +   results = argparser.parse_args() +   print(results.foo, results.bar) +``` + +好处是当用户调用 `--help` 时,有自动生成的帮助。但是[自给自足][22]batteries included的优势呢?有时,你的项目情况决定了你对第三方库的访问是有限的,或者说是没有,你不得不用 Python 标准库来“凑合”。 + +#### CLI 的现代方法 + +然后是 [Click][23]。`Click` 框架使用[装饰器][24]的方式来构建命令行解析。突然间,写一个丰富的命令行界面变得有趣而简单。在装饰器的酷炫和未来感的使用下,很多复杂的东西都消失了,用户惊叹于自动支持关键字补完以及上下文帮助。所有这些都比以前的解决方案写的代码更少。任何时候,只要你能写更少的代码,还能把事情做好,就是一种胜利。而我们都想要胜利。 + +``` +import click + +@click.command() +@click.option("-f", "--foo", default="foo", help="User supplied foo.") +@click.option("-b", "--bar", default="bar", help="User supplied bar.") +def echo(foo, bar): +    """My Cool Program +    +    It does stuff. Here is the documentation for it. +    """ +    print(foo, bar) +    +if __name__ == "__main__": +    echo() +``` + +你可以在 `@click.option` 装饰器中看到一些与 `argparse` 相同的模板代码。但是创建和管理参数分析器的“工作”已经被抽象化了。现在,命令行参数被解析,而值被赋给函数参数,从而函数 `echo` 被*魔法般地*调用。 + +在 `Click` 接口中添加参数就像在堆栈中添加另一个装饰符并将新的参数添加到函数定义中一样简单。 + +### 但是,等等,还有更多! + +[Typer][25] 建立在 `Click` 之上,是一个更新的 CLI 框架,它结合了 `Click` 的功能和现代 Python [类型提示][26]。使用 `Click` 的缺点之一是必须在函数中添加一堆装饰符。CLI 参数必须在两个地方指定:装饰符和函数参数列表。`Typer` [免去你造轮子][27] 去写 CLI 规范,让代码更容易阅读和维护。 + +``` +import typer + +cli = typer.Typer() + +@cli.command() +def echo(foo: str = "foo", bar: str = "bar"): +    """My Cool Program +    +    It does stuff. Here is the documentation for it. +    """ +    print(foo, bar) +    +if __name__ == "__main__": +    cli() +``` + +### 是时候开始写一些代码了 + +哪种方法是正确的?这取决于你的用例。你是在写一个只有你才会使用的快速而粗略的脚本吗?直接使用 `sys.argv` 然后继续编码。你需要更强大的命令行解析吗?也许 `argparse` 就够了。你是否有很多子命令和复杂的选项,你的团队是否会每天使用它?现在你一定要考虑一下 `Click` 或 `Typer`。作为一个程序员的乐趣之一就是魔改出替代实现,看看哪一个最适合你。 + +最后,在 Python 中有很多用于解析命令行参数的第三方软件包。我只介绍了我喜欢或使用过的那些。你喜欢和/或使用不同的包是完全可以的,也是我们所期望的。我的建议是先从这些包开始,然后看看你最终的结果。 + +去写一些很酷的东西吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/c-python-cli + +作者:[Erik O'Shaughnessy][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jnyjny +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://en.wikipedia.org/wiki/Command-line_interface +[3]: https://en.wikipedia.org/wiki/Unix +[4]: https://www.gnu.org/software/bash/ +[5]: https://en.wikipedia.org/wiki/C_(programming_language) +[6]: https://www.toptal.com/c/after-all-these-years-the-world-is-still-powered-by-c-programming +[7]: https://opensource.com/article/19/5/how-write-good-c-main-function +[8]: https://en.wikipedia.org/wiki/Dynamic_linker +[9]: http://www.opengroup.org/onlinepubs/009695399/functions/printf.html +[10]: https://en.wikipedia.org/wiki/C_standard_library +[11]: http://man7.org/linux/man-pages/man3/getopt.3.html +[12]: https://www.python.org/dev/peps/pep-0275/ +[13]: https://www.python.org/dev/peps/pep-3103/ +[14]: https://www.gnu.org +[15]: https://en.wikipedia.org/wiki/Man_page +[16]: http://man7.org/linux/man-pages/man1/ps.1.html +[17]: https://docs.python.org/3/library/sys.html +[18]: https://docs.python.org/2/library/getopt.html +[19]: https://docs.python.org/2/library/optparse.html +[20]: https://docs.python.org/3/library/argparse.html +[21]: https://en.wikipedia.org/wiki/Boilerplate_code +[22]: https://www.python.org/dev/peps/pep-0206/ +[23]: https://click.palletsprojects.com/en/7.x/ +[24]: https://wiki.python.org/moin/PythonDecorators +[25]: https://typer.tiangolo.com +[26]: https://docs.python.org/3/library/typing.html +[27]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself +[28]: https://pybit.es/guest-exploring-python-clis.html diff --git a/published/202006/20200602 Linux Lite 5.0 Released With UEFI Support - Other Major Improvements.md b/published/202006/20200602 Linux Lite 5.0 Released With UEFI Support - Other Major Improvements.md new file mode 100644 index 0000000000..f17baf1796 --- /dev/null +++ b/published/202006/20200602 Linux Lite 5.0 Released With UEFI Support - Other Major Improvements.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12287-1.html) +[#]: subject: (Linux Lite 5.0 Released With UEFI Support & Other Major Improvements) +[#]: via: (https://itsfoss.com/linux-lite-5-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Linux Lite 5.0 发布,带有 UEFI 支持和其他重大改进 +====== + +Linux Lite 是[适合 Windows 用户的最佳 Linux 发行版][1]之一。 不仅限于此,它还是最受欢迎的[轻量级 Linux 发行版][2]之一。 + +基于 Ubuntu 18.04 的 Linux Lite 4.x 系列虽然不错,但没有 [UEFI 支持][3]。 但是现在基于 [Ubuntu 20.04][4] 的 Linux Lite 5.0 终于来了,我很高兴看到这些变化! + +在本文中,我们将介绍 Linux Lite 5.0 的新增功能。 + +### Linux Lite 5.0:关键变更 + +![][5] + +即使 Linux Lite 从 2.x 就开始支持 UEFI,但他们总是默认发布非 UEFI 的。 + +但是,在 Linux Lite 5.0 中,他们终于增加了开箱即用的 [UEFI][3] 默认支持以及许多重大改进。让我们看看发生了什么变化: + +#### UEFI 支持 + +Linux Lite 5.0 支持开箱即用的 UEFI。但是,他们建议禁用[安全启动][6],即使该功能可以工作。 + +![][7] + +你可以看看他们的[论坛文章][8],以了解更多信息。此外,你还可以在新的内置**帮助手册**中找到有关此的更多信息。 + +#### 基于 Ubuntu 的发行版,没有隐藏的遥测 + +如果你正在寻找基于 Ubuntu 的 Linux 发行版,且没有任何隐藏的遥测功能,那么 Linux Lite 5.0 似乎是理想的选择。 + +在[发布公告][9]中,他们在变更日志中提到了它,并提供了截图: + +![][10] + +#### GUFW 防火墙替换为 firewalld + +你可能已经读过[在 Linux 上使用 GUFW 设置防火墙][11],但从 Linux Lite 5.0 开始,它已由 [firewalld][12] 取代。 + +![][13] + +似乎 [GUFW][14] 不能像 firewalld 那样配置。因此,他们决定替换它。 + +默认情况下,它是禁用的。但是,你可以按照**帮助手册**中的教程选择启用它。 + +#### 新的 Whisker 菜单 + +![][15] + +[Whisker 菜单][16]已更新至最新可用的软件包(v2.4.4)。 除了更新之外,你还可以注意到**安装更新**现在被固定在收藏夹。 + +#### HiDPI 设置 + +![][17] + +如果需要,你会发现从**设置菜单**中设置 HiDPI 非常容易。 + +#### 已添加 XFCE 屏幕保护程序 + +在 Linux Lite 5.0 中,你还将注意到添加了 [XFCE 屏幕保护程序][18],默认情况下它处于禁用状态。 + +![][19] + +这是一个简单的补充,对于一直想要屏幕保护程序并能够对其进行调整的用户而言,这将很有用。 + +### 其他重要改进 + +除了上面提到的关键要点外,还有其他一些改进对于 Linux Lite 5.0 用户而言应该是很方便的。我在这里列出其中一些: + + * [Mousepad][20] 替换 [Leafpad][21] + * 新的更新通知 + * 在即时启动时进行完整性检查 + * 对**帮助手册**的重大改进 + * Lite 软件中用 Chrome 取代了 Chromium + * 新的布局选项 + * Lite 欢迎页面和 Lite 用户管理器现在更新到 GTK3 和 Python3。 + * 欢迎页面添加了新的选择:**选择深色或浅色主题、UEFI 和安全启动、反馈** + * 改进的 Lite 小部件 + +如果你想进一步了解更改,可以在其[官方公告][9]中找到详细的更改列表。 + +### 总结 + +我认为 Linux Lite 5.0 比以往任何时候要好,并且随着最近新增的功能,对于许多新 Linux 用户来说,它也是一个绝佳的选择。 + +你如何看待 Linux Lite 5.0?在下面的评论中让我知道你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-lite-5-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://itsfoss.com/windows-like-linux-distributions/ +[2]: https://itsfoss.com/lightweight-linux-beginners/ +[3]: https://help.ubuntu.com/community/UEFI +[4]: https://itsfoss.com/ubuntu-20-04-release-features/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-lite-5.jpg?ssl=1 +[6]: https://en.wikipedia.org/wiki/Hardware_restriction#Secure_boot +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-lite-uefi.png?ssl=1 +[8]: https://www.linuxliteos.com/forums/uefi-secure-boot/ +[9]: https://www.linuxliteos.com/forums/release-announcements/linux-lite-5-0-final-released/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-lite-5-telemetry.png?ssl=1 +[11]: https://itsfoss.com/set-up-firewall-gufw/ +[12]: https://firewalld.org/ +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-lite-5-firewall.jpg?ssl=1 +[14]: http://gufw.org/ +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/whisker-menu-linux-lite.jpg?ssl=1 +[16]: https://gottcode.org/xfce4-whiskermenu-plugin/ +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-lite-5-hidpi.png?ssl=1 +[18]: https://docs.xfce.org/apps/screensaver/start +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-lite-5-screensaver.jpg?ssl=1 +[20]: https://salsa.debian.org/xfce-team/apps/mousepad +[21]: https://tarot.freeshell.org/leafpad/ diff --git a/published/202006/20200602 Using pandas to plot data in Python.md b/published/202006/20200602 Using pandas to plot data in Python.md new file mode 100644 index 0000000000..f51dd2f1e1 --- /dev/null +++ b/published/202006/20200602 Using pandas to plot data in Python.md @@ -0,0 +1,133 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12333-1.html) +[#]: subject: (Using pandas to plot data in Python) +[#]: via: (https://opensource.com/article/20/6/pandas-python) +[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan) + +使用 Pandas 在 Python 中绘制数据 +====== + +> Pandas 是一个非常流行的 Python 数据操作库。学习怎样使用它的 API 绘制数据。 + +![](https://img.linux.net.cn/data/attachment/album/202006/19/231720ed0jd9s99h9cute7.jpg) + +在有关基于 Python 的绘图库的系列文章中,我们将对使用 Pandas 这个非常流行的 Python 数据操作库进行绘图进行概念性的研究。Pandas 是 Python 中的标准工具,用于对进行数据可扩展的转换,它也已成为[从 CSV 和 Excel 格式导入和导出数据][2]的流行方法。 + +除此之外,它还包含一个非常好的绘图 API。这非常方便,你已将数据存储在 Pandas DataFrame 中,那么为什么不使用相同的库进行绘制呢? + +在本系列中,我们将在每个库中制作相同的多条形柱状图,以便我们可以比较它们的工作方式。我们使用的数据是 1966 年至 2020 年的英国大选结果: + +![Matplotlib UK election results][3] + +### 自行绘制的数据 + +在继续之前,请注意你可能需要调整 Python 环境来运行此代码,包括: + +* 运行最新版本的 Python(用于 [Linux][4]、[Mac][5] 和 [Windows][6] 的说明) +* 确认你运行的是与这些库兼容的 Python 版本 + +数据可在线获得,并可使用 Pandas 导入: + +``` +import pandas as pd +df = pd.read_csv('https://anvil.works/blog/img/plotting-in-python/uk-election-results.csv') +``` + +现在我们已经准备好了。在本系列文章中,我们已经看到了一些令人印象深刻的简单 API,但是 Pandas 一定能夺冠。 + +要在 x 轴上绘制按年份和每个党派分组的柱状图,我只需要这样做: + +``` +import matplotlib.pyplot as plt +ax = df.plot.bar(x='year') +plt.show() +``` + +只有四行,这绝对是我们在本系列中创建的最棒的多条形柱状图。 + +我以[宽格式][7]使用数据,这意味着每个党派都有一列: + +``` + year conservative labour liberal others +0 1966 253 364 12 1 +1 1970 330 287 6 7 +2 Feb 1974 297 301 14 18 +.. ... ... ... ... ... +12 2015 330 232 8 80 +13 2017 317 262 12 59 +14 2019 365 202 11 72 +``` + +这意味着 Pandas 会自动知道我希望如何分组,如果我希望进行不同的分组,Pandas 可以很容易地[重组 DataFrame][8]。 + +与 [Seaborn][9] 一样,Pandas 的绘图功能是 Matplotlib 之上的抽象,这就是为什么要调用 Matplotlib 的 `plt.show()` 函数来实际生成绘图的原因。 + +看起来是这样的: + +![pandas unstyled data plot][10] + +看起来很棒,特别是它又这么简单!让我们对它进行样式设置,使其看起来像 [Matplotlib][11] 的例子。 + +#### 调整样式 + +我们可以通过访问底层的 Matplotlib 方法轻松地调整样式。 + +首先,我们可以通过将 Matplotlib 颜色表传递到绘图函数来为柱状图着色: + +``` +from matplotlib.colors import ListedColormap +cmap = ListedColormap(['#0343df', '#e50000', '#ffff14', '#929591']) +ax = df.plot.bar(x='year', colormap=cmap) +``` + +我们可以使用绘图函数的返回值设置坐标轴标签和标题,它只是一个 [Matplotlib 的 Axis 对象][12]。 + +``` +ax.set_xlabel(None) +ax.set_ylabel('Seats') +ax.set_title('UK election results') +``` + +这是现在的样子: + +![pandas styled plot][13] + +这与上面的 Matplotlib 版本几乎相同,但是只用了 8 行代码而不是 16 行!我内心的[代码高手][14]非常高兴。 + +### 抽象必须是可转义的 + +与 Seaborn 一样,向下访问 Matplotlib API 进行细节调整的能力确实很有帮助。这是给出抽象[紧急出口][15]使其既强大又简单的一个很好的例子。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/pandas-python + +作者:[Shaun Taylor-Morgan][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shaun-taylor-morgan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/panda.png?itok=0lJlct7O (Two pandas sitting in bamboo) +[2]: https://anvil.works/docs/data-tables/csv-and-excel +[3]: https://opensource.com/sites/default/files/uploads/matplotlib_2.png (Matplotlib UK election results) +[4]: https://opensource.com/article/20/4/install-python-linux +[5]: https://opensource.com/article/19/5/python-3-default-mac +[6]: https://opensource.com/article/19/8/how-install-python-windows +[7]: https://anvil.works/blog/tidy-data +[8]: https://anvil.works/blog/tidy-data#converting-between-long-and-wide-data-in-pandas +[9]: https://anvil.works/blog/plotting-in-seaborn +[10]: https://opensource.com/sites/default/files/uploads/pandas-unstyled.png (pandas unstyled data plot) +[11]: https://opensource.com/article/20/5/matplotlib-python +[12]: https://matplotlib.org/api/axis_api.html#axis-objects +[13]: https://opensource.com/sites/default/files/uploads/pandas_3.png (pandas styled plot) +[14]: https://en.wikipedia.org/wiki/Code_golf +[15]: https://anvil.works/blog/escape-hatches-and-ejector-seats +[16]: https://anvil.works/blog/plotting-in-pandas \ No newline at end of file diff --git a/published/202006/20200602 Using the Lightweight Apt Package Manager Synaptic in Ubuntu and Other Debian-based Linux Distributions.md b/published/202006/20200602 Using the Lightweight Apt Package Manager Synaptic in Ubuntu and Other Debian-based Linux Distributions.md new file mode 100644 index 0000000000..3a33690599 --- /dev/null +++ b/published/202006/20200602 Using the Lightweight Apt Package Manager Synaptic in Ubuntu and Other Debian-based Linux Distributions.md @@ -0,0 +1,174 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12353-1.html) +[#]: subject: (Using the Lightweight Apt Package Manager Synaptic in Ubuntu and Other Debian-based Linux Distributions) +[#]: via: (https://itsfoss.com/synaptic-package-manager/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 Ubuntu 中使用轻量的 Apt 软件包管理器 Synaptic +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/26/220622uh75qnmmzgh58lpv.jpg) + +这周推荐的开源软件是 Synaptic。学习这个经过时光积淀的软件包管理器能做哪些现代软件管理器做不到的事情。 + +### Synaptic 软件包管理器是什么? + +[Synaptic][1] 是一个轻量级的 [apt 软件包管理器系统][2]的 GUI 前端,使用在 Debian、Ubuntu、Linux Mint 以及其它很多基于 Debian/Ubuntu 发行版中。 + +总的来说,所有你可以 [在终端中使用 apt-get 命令][3] 来做的事,都可以通过 Synaptic 来实现。 + +![][4] + +曾几何时,Synaptic 几乎是所有基于 Debian Linux 发行版的默认图形化软件包管理器。它被认为是一种用户友好的、易于使用的管理应用程序的方法。 + +随着像 [GNOME “软件”][5] 和 [KDE “发现”][6] 等现代软件包管理器工具带来更现代和直观的图形用户界面,事情发生了变化。这些软件包管理器有更好的界面,以一种更友好的方式显示软件包信息,带有缩略图、评分和评论。 + +最后,Synaptic [的使用被局限于在大多数的轻量级 Linux 发行版][7] 中。 + +#### 为什么你要使用像 Synaptic 软件包管理器这样的 “古老的” 软件? + +当然,在多大数的情况下,你没有必要这样做。 + +但是,Synaptic 仍然比 GNOME “软件” 的功能要很多。记住,它基本上是 `apt` 的 GUI 前端,这意味着它(几乎)可以做任何你能够 [在终端中使用 apt 命令][8] 所做的事。 + +例如,如果你想 [在 Ubuntu 中阻止特定的软件包更新][9],你可以在 Synaptic 中做到这一点,但是你却不能 GNOME/Ubuntu 的软件中心中实现。 + +![][10] + +另外,我注意到 Ubuntu 20.04 的软件中心存在一些问题。它加载速度缓慢,它搜索软件包时缓慢,并且它充满了 snap 应用程序(不是每个人都喜欢)。 + +Synaptic 也是 [Ubuntu 中一个轻量级应用程序][7],使用可以可以让你感觉你的系统快一点。 + +#### Synaptic 软件包管理器的功能 + +下面是对 Synaptic 的概况: + + * 更新软件包缓存 + * 升级整个系统 + * 管理软件包包存储库 + * 通过名称、描述、维护者、版本、依赖项等搜索软件包 + * 通过组、状态(安装与否)、源或更多信息列出软件包 + * 通过名称、状态、大小或版本排序软件包 + * 获取与软件包相关的信息 + * 锁定软件包版本 + * 安装指定版本的软件包 + +还有很多功能,大家可以自己去探索。 + +### 如何在 Ubuntu 上安装 Synaptic 软件包管理器 + +Synaptic 软件包管理器可在 Ubuntu 的 Universe 存储库中获得。如果 Universe 存储库未启用,你可以在软件中心中找到Synaptic: + +![Synaptic 在 Ubuntu 软件中心][11] + +你也可以通过命令行来安装 Synaptic 。先确保启用 universe 存储库: + +``` +sudo add-apt-repository univers +``` + +然后更新缓存(在 Ubuntu 18.04 及更高版本中不需要): + +``` +sudo apt update +``` + +现在,使用下面的命令来安装 synaptic 软件包管理器: + +``` +sudo apt install synaptic +``` + +这就是所有的安装过程。 + +### 如何使用 Synaptic 软件包管理器 + +在安装后,你可以在菜单中开始搜索 Synaptic 并启动它: + +![][12] + +可以看到,这个界面不是最好看的界面之一。注意复选框的颜色。白色意味着软件包未安装,绿色意味软件包已安装。 + +![][4] + +你可以搜索一个应用程序并单击复选框将标记其为安装。它也将(以绿色的形式)高亮将被作为依赖关系项目的软件包。单击应用来安装选择的软件包: + +![][13] + +你可以使用 Synaptic [查看在 Ubuntu 中安装的所有软件包][14] 。你也可以从这个视图中选择移除软件包。 + +![][15] + +你可以根据源显示各个存储库中可用的软件包。这是查看 [哪个 PPA 提供什么软件包][16]的好方法。你可以通过如上所述的方法来安装或移除软件包。 + +![][17] + +通常,当你更新 Ubuntu 时,所有的软件包都会同时更新。使用 Synaptic,你可以轻松地选择你需要更新/升级到较新版本的软件包。 + +![][18] + +你也可以锁定软件包的版本,以便它们就不会随着系统更新而被更新。 + +![][10] + +你也可以使用 Synaptic 搜索软件包。这类似于 [使用 apt-cache search 命令搜索软件包][19]。 + +![][20] + +如果你认为你做了错误的选择,你可以从“编辑”菜单中单击撤销。 + +你可以使用 Synaptic 做很多事,我无法涵盖所有可能的用法。我在这里已经涵盖了最常见的一些方法,如果你将要去使用 Synaptic 的话,我留给你去探索。 + +### Synaptic 并不适合所有的人 + +如果你不喜欢 Synaptic,你可以在软件中心中移除它,或在终端中使用这个命令: + +``` +sudo apt remove synaptic +``` + +Ubuntu 还有另一个被称为 [AppGrid][21] 的轻量级软件包管理器。据我所知,它已经有一段时间没有更新了。 + +Synaptic 当然并不适合所有的人。它列出了你在常规软件中心中看不到的库和包。如果你移除了一个你不知道的库,那么它可能会引起问题。 + +我认为 Synaptic 更适合于中高级用户,他们既想更好地控制软件包管理器又不想使用命令行方法。 + +你有什么要说的吗?你使用过 Synaptic 软件包管理器吗?你是使用软件中心还是你只在终端中探索?请在评论区中分享你的喜好。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/synaptic-package-manager/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[robsean](https://github.comrobsean) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.nongnu.org/synaptic/ +[2]: https://en.wikipedia.org/wiki/APT_(software) +[3]: https://itsfoss.com/apt-get-linux-guide/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/synaptic-interface.png?ssl=1 +[5]: https://wiki.gnome.org/Apps/Software +[6]: https://userbase.kde.org/Discover +[7]: https://itsfoss.com/lightweight-alternative-applications-ubuntu/ +[8]: https://itsfoss.com/apt-command-guide/ +[9]: https://itsfoss.com/prevent-package-update-ubuntu/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/lock-version-synaptic.png?ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/synaptic-ubuntu-software-center.png?ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/synaptic-package-manager-ubuntu.jpg?ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/install-packages-in-synaptic.png?ssl=1 +[14]: https://itsfoss.com/list-installed-packages-ubuntu/ +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/remove-packages-using-synaptic.png?ssl=1 +[16]: https://itsfoss.com/ppa-guide/ +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/see-packages-by-repositories-synaptic.png?ssl=1 +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/upgrade-packages-synaptic.png?ssl=1 +[19]: https://itsfoss.com/apt-search-command/ +[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/search-results-synaptic.png?ssl=1 +[21]: https://itsfoss.com/app-grid-lighter-alternative-ubuntu-software-center/ diff --git a/published/202006/20200604 Devuan Beowulf 3.0 is the Latest Stable Release Based on Debian 10.4 Buster (and Free From systemd).md b/published/202006/20200604 Devuan Beowulf 3.0 is the Latest Stable Release Based on Debian 10.4 Buster (and Free From systemd).md new file mode 100644 index 0000000000..14d4670ffe --- /dev/null +++ b/published/202006/20200604 Devuan Beowulf 3.0 is the Latest Stable Release Based on Debian 10.4 Buster (and Free From systemd).md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12308-1.html) +[#]: subject: (Devuan Beowulf 3.0 is the Latest Stable Release Based on Debian 10.4 Buster) +[#]: via: (https://itsfoss.com/devuan-3-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +没有 systemd 的 Devuan Beowulf 3.0 发布 +====== + +[Devuan GNU+Linux][1] 是 [Debian][2] 的分支,它不含有 [systemd][3]。如果你想知道 systemd 有什么问题,我们可以改天再讨论这个话题。 + +不过,如果你想要一个没有 systemd 的 Linux 发行版,那么 Devuan Beowulf 3.0 的发布对你来说应该是个好消息。 + +### Devuan Beowulf 3.0 有什么新增功能? + +![](https://img.linux.net.cn/data/attachment/album/202006/12/112455y003411l1k8yykp0.jpg) + +Devuan 通常因其提供了替代性的[初始化][5]系统(如 [SysV][6])而受到喜爱。 + +在本文中,我们将介绍 Devuan Beowulf 3.0 中的主要亮点。 + +#### 基于 Debian 10.4 Buster + +[Debian 10 Buster][7] 无疑是一款令人印象深刻的发行版系列,它的最新版本是 Debian 10.4。 + +而 Devuan Beowulf 3.0,是基于最新的 Debian 10.4 Buster 更新版本的。如果你不了解,可以查看 [Debian 10.4 Buster 的官方公告][8],以了解更多信息。 + +#### Linux Kernel 4.19 + +在它的最新版本中装有 [Linux Kernel 4.19 LTS][9] 也是一个很好的加分项。 + +当然,这不是最新的内核,因为我们身处 “Debian 领域”,这里的事物并非总是最新的,但更加稳定。这个新内核应该可以解决以前版本中可能遇到的几个问题。 + +#### 支持 ppc64el 架构 + +对 [ppc64el][10] 的支持在大多数时候都不是大事,但支持 PowerPC 和 Power ISA 处理器是一个优势。 + +顺便提一句,Devuan GNU+Linux 已经支持 i386、amd64、armel、armhf 和 arm64 架构。 + +#### 添加 runit 和 OpenRC 作为可选项 + +想要更多替代的的初始化系统吗?现在最新版本中可选 [runit][11] 和 [openrc][12]。 + +#### 其他变化 + +除了上面的这样亮点外,你还可以发现它添加了独立守护进程 [eudev][13] 和 [elogind][14]。 + +启动页面、显示管理器和桌面主题也有了细微的变化。例如,启动菜单显示的是 “Debian” 而不是 “Devuan”。 + +如果你想了解有关 Devuan Beowulf 3.0.0 变更的更多技术详细信息,那么可以查看[官方发行说明][15]。 + +> 花絮 +> +> Devuan 的发布版本以小行星命名。Beowulf 是一个[编号为 38086 的小行星][16]。 + +### 总结 + +最新稳定版本的 Devuan Beowulf 3.0 是提供无 systemd 的发行版的很好的进展。 + +如果你想支持 Devuan 项目,请[在财务上为他们的项目捐款][17]或[通过其他方式][18]。 + +你觉得这个版本怎么样?请在下面评论让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/devuan-3-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://devuan.org +[2]: https://www.debian.org +[3]: https://en.wikipedia.org/wiki/Systemd +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/devuan-beowulf.jpg?ssl=1 +[5]: https://en.wikipedia.org/wiki/Init +[6]: https://wiki.archlinux.org/index.php/SysVinit +[7]: https://itsfoss.com/debian-10-buster/ +[8]: https://www.debian.org/News/2020/20200509 +[9]: https://itsfoss.com/linux-kernel-4-19-lts-release/ +[10]: https://en.wikipedia.org/wiki/Ppc64 +[11]: https://en.wikipedia.org/wiki/Runit +[12]: https://en.wikipedia.org/wiki/OpenRC +[13]: https://wiki.gentoo.org/wiki/Eudev +[14]: https://wiki.gentoo.org/wiki/Elogind +[15]: https://files.devuan.org/devuan_beowulf/Release_notes.txt +[16]: https://en.wikipedia.org/wiki/Meanings_of_minor_planet_names:_38001%E2%80%9339000#086 +[17]: https://devuan.org/os/donate +[18]: https://dev1galaxy.org/viewtopic.php?pid=1380#p1380 diff --git a/published/202006/20200604 How to Install Nvidia Drivers on Fedora Linux.md b/published/202006/20200604 How to Install Nvidia Drivers on Fedora Linux.md new file mode 100644 index 0000000000..724a854583 --- /dev/null +++ b/published/202006/20200604 How to Install Nvidia Drivers on Fedora Linux.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12301-1.html) +[#]: subject: (How to Install Nvidia Drivers on Fedora Linux) +[#]: via: (https://itsfoss.com/install-nvidia-drivers-fedora/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +如何在 Fedora Linux 中安装 Nvidia 驱动 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/10/094702c7of7scjyucmc5f1.jpg) + +与大多数 Linux 发行版一样,[Fedora][1] 并未默认安装专有的 [Nvidia][2] 驱动。 + +默认的开源 [Nouveau 驱动][3]在大多数情况下都可以使用,但是你可能会遇到屏幕撕裂等问题。 + +![Display issue in Fedora with Nouveau graphics driver][4] + +如果遇到此类图形/视频问题,那么可能需要在 Fedora 中安装官方专有的 Nvidia 驱动。让我告诉你如何安装。 + +### 在 Fedora 中安装 Nvidia 驱动 + +我在本教程中使用 [Fedora 32][5],但它应适用于其他 Fedora 版本。 + +#### 步骤 1 + +在做其他任何操作之前,请先确保你的系统是最新的。你可以使用软件中心,也可以在终端中使用以下命令: + +``` +sudo dnf update +``` + +#### 步骤 2 + +由于 Fedora 没有提供 Nvidia 驱动,因此你需要在系统中添加 [RPMFusion 仓库][6]。你可以在终端中使用以下命令: + +``` +sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm +``` + +> 不喜欢终端么?那使用 GUI 的方法添加 RPMFusion 仓库。 +> +> 如果你使用 Firefox,那么还可以从浏览器添加 RPMFusion 仓库。进入这个[配置页面][7],然后向下滚动到 “Graphical Setup via Firefox web browser”。单击自由和非自由仓库的链接。这将下载 .rpm 文件,并安装仓库。 +> +> ![RPMFusion Browser Installation][8] +> +> 你可以双击下载的 RPM 文件进行安装。 +> +> ![RPMFusion in the Software Center][9] + +#### 步骤 3 + +现在,你需要确定 [Linux 系统中有哪些显卡(或芯片)][10]。打开终端并输入以下命令: + +``` +lspci -vnn | grep VGA +``` + +![Video Card Lookup in Fedora][11] + +接下来,你需要查找与该芯片对应的驱动。你可以在[此处][12]找到 Nvidia 芯片的列表。你也可以使用[此工具][13]搜索设备。 + +**注意**:请记住,即使 Nvidia 列表显示了更多驱动,但也只有三个驱动可以安装。Nvidia 驱动支持最新的显卡。nvidia-390 和 nvidia-340 驱动支持旧设备。 + +#### 步骤 4 + +要安装所需的驱动,请在终端中输入以下一个命令。下面的命令是用于我的显卡的命令。根据你的系统相应调整。 + +``` +sudo dnf install akmod-nvidia sudo dnf install xorg-x11-drv-nvidia-390xx akmod-nvidia-390xx sudo dnf install xorg-x11-drv-nvidia-340xx akmod-nvidia-340xx +``` + +![Nvidia terminal installation][14] + +#### 步骤 5 + +要使更改生效,请重启系统。你的系统重启可能需要比较长的时间,因为它将 Nvidia 驱动注入到 Linux 内核中。 + +重启并登录系统后,你会看到更好的视觉效果,并且不会出现屏幕撕裂的情况。 + +![Fedora with Nvidia drivers][15] + +### 额外的提示 + +这是可选步骤,但建议这样做。添加 RPMFusion 仓库时,你可以访问常规仓库中不可用的多媒体包。 + +此命令将为使用 [gstreamer][16] 的应用安装软件包: + +``` +sudo dnf groupupdate multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin +``` + +此命令将安装声音和视频软件包所需的包: + +``` +sudo dnf groupupdate sound-and-video +``` + +希望本教程对在 Fedora 上安装 Nvidia 驱动很有用。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-nvidia-drivers-fedora/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://getfedora.org/ +[2]: https://www.nvidia.com/en-us/ +[3]: https://en.wikipedia.org/wiki/Nouveau_(software) +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/fedora-nouveau.jpg?resize=800%2C500&ssl=1 +[5]: https://itsfoss.com/fedora-32/ +[6]: https://rpmfusion.org/RPM%20Fusion +[7]: https://rpmfusion.org/Configuration +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/rpmfusion-gui-install.png?resize=800%2C500&ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/rpmfusion-gui-install2.png?resize=800%2C500&ssl=1 +[10]: https://itsfoss.com/check-graphics-card-linux/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/video-card-lookup-fedora.png?ssl=1 +[12]: https://us.download.nvidia.com/XFree86/Linux-x86/367.57/README/supportedchips.html +[13]: https://www.nvidia.com/Download/index.aspx?lang=en-us +[14]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/nvidia-cli-install.png?resize=800%2C500&ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/fedora-nvidia.jpg?resize=800%2C500&ssl=1 +[16]: https://en.wikipedia.org/wiki/GStreamer diff --git a/published/202006/20200604 How to generate an EPUB file on Fedora.md b/published/202006/20200604 How to generate an EPUB file on Fedora.md new file mode 100644 index 0000000000..021271376f --- /dev/null +++ b/published/202006/20200604 How to generate an EPUB file on Fedora.md @@ -0,0 +1,112 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12313-1.html) +[#]: subject: (How to generate an EPUB file on Fedora) +[#]: via: (https://fedoramagazine.org/how-to-generate-an-epub-file-on-fedora/) +[#]: author: (John Paul Wohlscheid https://fedoramagazine.org/author/johnblood/) + +如何在 Fedora 上生成 EPUB 电子书 +====== + +![][1] + +在智能手机上阅读内容正在变得越来越流行。每一部手机都有它自己的电子书阅读器。可能你不知道,在 Fedora 创建你自己的电子书文件是非常容易的。 + +这篇文章展示了使用两种不同的方法来创建一个 [EPUB][2] 文件。EPUB 格式是最流行的格式之一,并且被很多开源软件所支持。 + +绝大数的人们将会询问 “在很容易创建 PDF 文件的情况下,为什么要花费时间和精力来创建 EPUB 文件?” 答案是: “你曾经尝试看过每次只能看到一张纸的一小部分的吗?”为阅读一个 PDF 文件,你不得不经常缩放和移动文档,或者将其缩放到一个小尺寸来适合屏幕大小。在另一方面,EPUB 文件则被设计成可以适合很多不同的屏幕类型。 + +### 方法 1: ghostwriter 和 pandoc + +第一种方法创建一个速成版的电子书文件。它使用一个名为 [ghostwriter][3] 的 Markdown 编辑器,和一个名为 [pandoc][4] 的命令行文档转换工具。 + +你可以从软件中心搜查和安装它们,也可以从终端中安装它们。如果你使用终端来安装它们,运行这个命令: + +``` +sudo dnf install pandoc ghostwriter +``` + +对于那些不知道 [Markdown][5] 是什么的人们来说,在这里有一个简要的解释:它是一个大约在 15 年前创建的简单的标记语言。它使用简单的语法来格式化纯文本。Markdown 文件可以随后转换成很多其它文档格式的文件。 + +![ghostwriter][6] + +对于工具,ghostwriter 是一个跨平台的易于使用的 Markdown 编辑器。pandoc 是一个非常易于使用的文档转换工具,可以处理数百种不同的格式。 + +要创建你的电子书,打开 ghostwriter,开始编写你的文档。如果你以前使用过 Markdown,你可能习惯于在文档的“标题 1”的前面放置一个 `#` 符号来作为标题。像这样: `# My Man Jeeves`。然而,pandoc 将不会识别其为标题,并将在你的电子书的顶部放置一个一个大的 “UNTITLED” 。相反地在你的标题前放置一个 `%` 来作为标题。例如,`% My Man Jeeves` 。章节应该被格式为“标题 2”,例如,`## Leave It to Jeeves`。如果你有子章节,使用“标题 3”(`###`)。 + +![][7] + +在你的文档完成后,单击“文件 -> 导出”(或按 `Ctrl+E` 键)。在对话框中,在几个 Markdown 转换器中进行选择。如果这是你第一次使用 ghostwriter ,默认选择的是 Sundown 转换器。从对话框中,选择 pandoc 。接下来单击“导出”。现在你的 EPUB 文件已经创建好了。 + +![ghostwriter 导出对话框][8] + +注意: 如果你得到一个与 pandoc 有关的错误,关闭“智能排版”,并再试一次。 + +### 方法 2: calibre + +如果你想要一个更完美的电子书,那这就是你正在寻找的方法。它需要更多的步骤,但是是值得的。 + +![][9] + +首先,安装一个名为 [calibre][10] 的应用程序。calibre 不仅仅是一个电子书阅读器,它也是一个电子书管理器系统。你可以从软件中心安装它,也可以从终端安装它: + +``` +sudo dnf install calibre +``` + +在这个方法中,你可以在 LibreOffice、ghostwriter,或者其它你选择的编辑器中编写你的文档。确保书籍的标题被格式为“标题 1”,章节被格式为“标题 2”,子章节被格式为“标题 3”。 + +接下来,导出你的文档为一个 HTML 文件。 + +现在添加该文件到 calibre 。打开 calibre ,并单击 “添加书籍”。calibre 会用几秒钟来添加文件。 + +![][11] + +在文件导入后,通过单击 “编辑元数据” 按钮来编辑文件的元数据。在这里你可以填写书的标题和作者的姓名。你也可以上传一个封面图片(如果你有的话),或者 calibre 将为你生成一个封面。 + +![][12] + +接下来,单击 “转换书籍” 按钮。在新的对话框中,选择 “界面与外观” 部分的 “布局” 标签页。勾选 “删除段间空行” 选项。这将更加严格地缩进每一段的内容。 + +![][13] + +现在,设置目录。选择 “内容目录” 部分。这里有三个需要注意的选项: “一级目录”、“二级目录” 和 “三级目录”。对于每一个选项点击其末尾处的魔法棒按钮。在新的对话框中,选择应用于目录表项的 HTML 标记。例如,为“一级目录”选择 “h1”。 + +![][14] + +接下来,告诉 calibre 包含内容目录。选择 “输出 EPUB” 部分并勾选 “插入内联目录”。单击“确定“ 创建 epub 文件。 + +![][15] + +现在,你有了一个看起来很专业的电子书文件。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/how-to-generate-an-epub-file-on-fedora/ + +作者:[John Paul Wohlscheid][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://fedoramagazine.org/author/johnblood/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/05/epub-how_to-816x345.png +[2]: https://en.wikipedia.org/wiki/EPUB +[3]: https://github.com/wereturtle/ghostwriter +[4]: https://pandoc.org/ +[5]: https://fedoramagazine.org/applications-for-writing-markdown/ +[6]: https://fedoramagazine.org/wp-content/uploads/2020/05/ghostwriter-1024x640.jpg +[7]: https://fedoramagazine.org/wp-content/uploads/2020/05/ghostwriter-menu-1024x640.jpg +[8]: https://fedoramagazine.org/wp-content/uploads/2020/05/ghostwriter-export-1024x640.jpg +[9]: https://fedoramagazine.org/wp-content/uploads/2020/05/calibre-pre-1024x640.jpg +[10]: https://calibre-ebook.com/ +[11]: https://fedoramagazine.org/wp-content/uploads/2020/05/calibre-metadata-1024x640.jpg +[12]: https://fedoramagazine.org/wp-content/uploads/2020/05/calibre-lookandfeel-1024x640.jpg +[13]: https://fedoramagazine.org/wp-content/uploads/2020/05/calibre-toc2-1024x640.jpg +[14]: https://fedoramagazine.org/wp-content/uploads/2020/05/calibre-epub-output-1024x640.jpg +[15]: https://fedoramagazine.org/wp-content/uploads/2020/05/calibre-post-1024x640.jpg diff --git a/published/202006/20200604 Now You Can Buy Linux Certified Lenovo ThinkPad and ThinkStation (for the Best Possible Out of The Box Linux Experience).md b/published/202006/20200604 Now You Can Buy Linux Certified Lenovo ThinkPad and ThinkStation (for the Best Possible Out of The Box Linux Experience).md new file mode 100644 index 0000000000..7fed915dff --- /dev/null +++ b/published/202006/20200604 Now You Can Buy Linux Certified Lenovo ThinkPad and ThinkStation (for the Best Possible Out of The Box Linux Experience).md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12283-1.html) +[#]: subject: (Now You Can Buy Linux Certified Lenovo ThinkPad and ThinkStation (for the Best Possible Out of The Box Linux Experience)) +[#]: via: (https://itsfoss.com/lenovo-linux-certified/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +现在你可以购买通过 Linux 认证的联想 ThinkPad 和 ThinkStation +====== + +曾经有一段时间,[ThinkPad][1] 是 Linux 用户的首选系统。但那是在 ThinkPad 还是 [IBM][2] 的产品的时候。当[联想在 2005 年收购了 IBM 的个人电脑业务][3]之后,(我觉得)事情开始发生了变化。 + +ThinkPad 曾经是一个令人惊叹的系列笔记本电脑,稳定可靠、值得信赖、坚如磐石,你只要问问 2010 年代以前用过它的人就知道了。 + +但在 2010 年前后,联想 ThinkPad 开始失去了它的魅力。它充满了一个又一个的问题,消费者们抱怨性能不佳。 + +而对于 Linux 用户来说,情况就更糟糕了。它的安全启动与 UEFI [给 Linux 用户带来了问题][4]。[与 Linux 的争论][5]就这样没完没了。 + +我为什么要回忆起这些?因为联想似乎正在努力提高 Linux 的兼容性。对于 Linux 爱好者来说,联想的最新公告是一个极好的消息。 + +### 联想 ThinkPad 和 ThinkStation 全系产品将通过 Linux 认证 + +![][6] + +联想[宣布][7],将对**全部工作站产品进行 Ubuntu 和红帽等顶级 Linux 发行版的认证**,这包括所有机型和配置。 + +作为 Linux 用户,这对你来说意味着什么?它意味着,如果你购买了联想电脑,你将获得**最好的开箱即用的 Linux 体验**。 + +等一下?不是可以随便在任何电脑上安装 Linux 吗,不管是联想还是幻想?当然,你可以。但是,当你把现有的(Windows)操作系统清除掉,自己安装 Linux 时,你可能会遇到硬件兼容性的问题,如没有声音、Wi-Fi 无法工作等。 + +开箱即用的体验很重要,因为并不是每个人都愿意花时间去修复声音、显卡、Wi-Fi 和蓝牙等问题,而不是专注于自己的实际工作,因为他们买电脑的目的就是为了这个。 + +来自 [Ubuntu][8] 和 Red Hat 的开发人员会对联想系统的每一个硬件组件进行测试和验证,以确保联想系统的每一个硬件组件都能正常工作。 + +### Ubuntu、Red Hat 以及更多 + +![][9] + +为此,联想选择了两款顶级 Linux 发行版。Red Hat 是企业级 Linux 桌面和服务器的热门选择。而 Ubuntu 当然是普遍流行的。 + +这意味着,联想的计算机在使用 Ubuntu LTS 版本和 Red Hat Linux 时,会以最佳状态工作。联想甚至会在其中预装 Ubuntu 和 Red Hat 两种版本的系统。 + +但是,这还没有结束。Fedora 是 Red Hat 的一个社区项目,联想也会在 ThinkPad P53 和 P1 Gen 2 系统上预装 Fedora。 + +有很多基于 Ubuntu LTS 版本的 Linux 发行版。大多数情况下,这些发行版在外观、应用和其他图形化的东西上都不一样,但它们使用的是与 Ubuntu 相同的基础。 + +这应该意味着,基于 Ubuntu 的发行版,如 Linux Mint、Elementary OS 等也会与联想的设备有更好的硬件兼容性。 + +联想还将这些设备驱动直接发送给上游的 Linux 内核中,帮助它们的系统在整个生命周期内都保持稳定性和兼容性。这一点是非常棒的。 + +### 它能帮助增加 Linux 用户群吗? + +开箱即用的体验很重要。它可以让你专注于系统上应该做的重要任务,而不是故障排除。 + +我有一台[预装了 Ubuntu 的戴尔 XPS 笔记本][10]。这是唯一一台几乎不需要从我这一端进行硬件故障排除的设备,即使我手动安装了其它基于 Ubuntu 的发行版,也不需要进行硬件故障排除。 + +我很高兴看到联想为提高 Linux 的兼容性做出了更多努力。现在在[预装 Linux 的电脑列表][11]中有了更多的选择。 + +我不知道联想在其计算机产品中提供 Linux 是否有助于增加 Linux 用户群。大多数时候人们都会要 Windows,Linux 不会成为首要关注点。 + +但联想在设备上让自己的计算机产品更多的使用 Linux,这一点还是值得称赞的。我希望其他厂商也能这样做。希望没有什么坏处:) + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/lenovo-linux-certified/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/ThinkPad +[2]: https://www.ibm.com/ +[3]: https://in.pcmag.com/laptops/38093/10-years-later-looking-back-at-the-ibm-lenovo-pc-deal +[4]: https://www.phoronix.com/scan.php?page=news_item&px=mtiyotg +[5]: https://www.engadget.com/2016-09-21-lenovo-pc-linux-trouble.html +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/lenevo-linux-certified-systems.jpg?ssl=1 +[7]: https://news.lenovo.com/pressroom/press-releases/lenovo-brings-linux-certification-to-thinkpad-and-thinkstation-workstation-portfolio-easing-deployment-for-developers-data-scientists/ +[8]: https://ubuntu.com/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/thinkpad-ubuntu.jpg?resize=800%2C582&ssl=1 +[10]: https://itsfoss.com/dell-xps-13-ubuntu-review/ +[11]: https://itsfoss.com/get-linux-laptops/ diff --git a/published/202006/20200604 Using AppImage for Linux package management.md b/published/202006/20200604 Using AppImage for Linux package management.md new file mode 100644 index 0000000000..ea7908af31 --- /dev/null +++ b/published/202006/20200604 Using AppImage for Linux package management.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12317-1.html) +[#]: subject: (Using AppImage for Linux package management) +[#]: via: (https://opensource.com/article/20/6/appimages) +[#]: author: (David Clinton https://opensource.com/users/dbclinton) + +使用 AppImage 进行 Linux 软件包管理 +====== + +> AppImage 在自足的环境中分发应用, 它适用于任何 Linux 发行版。 + +![](https://img.linux.net.cn/data/attachment/album/202006/15/140050aazux37axew7e0xk.jpg) + +管理 Linux 机器(尤其是远程机器)的一个重要分就是管理和安装软件。当本地应用程序出现问题时,或者文件系统上的某些文件损坏需要修复时,你通常会希望推送更新,而不必走很多路坐在物理屏幕前。正如我在 Pluralsight 课程《[Linux 系统维护和故障排除][2]》中所解释的那样,许多问题当然可以通过 Bash 脚本解决,但是仍有很多情况下,除了老式的二进制文件外,没有其他选择。 + +想象一下,你的某些远程系统需要安装新的应用程序,这样使用这些计算机的团队成员就能够执行某些业务。能够利用 Debian 或 RPM 之类的主要 Linux 仓库系统的集成和自动化,可以使你的管理任务变得更加容易。 + +正如 Linus Torvalds 永不厌倦地提醒我们的那样,太多的 Linux 软件管理系统的问题是 [Linux 软件管理系统太多了][3]。多年来,应用开发甚至是 Linux 的采用都变得愈加复杂起来,因为你为了提供你的软件(比如,放到 Debian 仓库)而投入的所有时间和工作,对于你想让它们进入 RPM 系统并没有什么帮助,对于 SUSE 的 Zypper 管理器也一样,没有什么帮助。 + +解决软件孤岛问题的一种有前途的方案是分发具有自足环境的应用,它们可以在任何 Linux 发行版上运行。在这个年轻且不断发展的领域中,选择之一是 [AppImage][4]。 + +### 使用 AppImage + +我全面投入到了 AppImage。就像我提到的其他软件包管理系统一样,如果你需要的话,有很多复杂的功能可以使用。但是,从本质上讲,AppImage 非常简单。AppImage 不像大多数其他包管理器一样通过仓库工作,它使用单个、独立的文件,可以直接发送或通过网站共享。 + +下面是个展示它的美妙之处的例子。当我在用 AppImage 时,我在一个技术论坛上看到了一个很老的讨论,它让我找到了一个同样久远且废弃的 GitHub 项目以及相关的 YAML 和配方文件。它们旨在自动构建准备生成 AppImage 包所需的相当复杂的基础架构。尽管该基础架构全部是在 5 年前的 Ubuntu 版本上构建的,但是当我将它们放在一起并运行 `appimagetool` 命令时,它创建了一个 AppImage 文件,它可在我当前的桌面上无缝运行。我不认为有很多有五年历史的 GitHub 复杂项目可以使用其他技术运行,而无需认真重做。 + +但是这里我我不会介绍这个案例。相反,我将用一个简单的 Hello World 程序向你展示它是如何工作的。首先,请确保本地已安装 AppStream 包。 + +对于基于 Debian 的系统,运行: + +``` +$ sudo apt install appstream +``` + +对于 RPM 系统,请使用: + +``` +$ sudo dnf install appstream +``` + +克隆[这篇文章][5]中提及的 Git 仓库,我会基于它示例: + +``` +$ git clone +$ cd appimage-resources +$ ls hello-world-appimage +``` + +接下来,使用 `cd` 进入 Git 新创建的目录。这里有两个目录。请使用 `hello-world-appimage`。另一个是更复杂的项目,你也应该考虑尝试一下。 + +Linux GUI 系统会读取 `helloworld.desktop` 文件来知道如何呈现桌面图标。事实证明,当前的这个文件会在以后给你带来点麻烦,因此请进行一些小修改:添加 `Categories=` 这行并为其赋予值 `GNOME`。不要忘记最后的分号: + + +``` +$ nano hello-world-appimage/helloworld.desktop +        add Categories=GNOME; +``` + +从 [AppImage GitHub 项目][6]下载 `appimagetool` 预编译的二进制文件。访问 GitHub 的原因之一:那里有很多出色的文档和资源。下载二进制文件后,使文件可执行,并将 `hello-world-appimage` 目录传给它。但是首先,你需要告诉它你想要的架构。由于某些原因,一个名字以 x86\_64 结尾的工具都不能自行确定是否该使用 x86\_64 来构建应用程序(我不知道这是怎么回事)。 + +``` +$ wget +$ chmod +x appimagetool-x86_64.AppImage +$ ARCH=x86_64 ./appimagetool-x86_64.AppImage hello-world-appimage +``` + +如果你没有看到任何错误消息,那么表示完成了,请运行: + +``` +$ ls +$ ./hello-world-appimage-x86_64.AppImage +``` + +### 总结 + +AppImage 是软件包管理的非常有效的选择。当你探索它时,我想你会发现它是 Linux 发行版默认软件包系统的很好的替代品。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/appimages + +作者:[David Clinton][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dbclinton +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://pluralsight.pxf.io/VMKQj +[3]: https://itsfoss.com/desktop-linux-torvalds/ +[4]: https://appimage.org/ +[5]: https://www.booleanworld.com/creating-linux-apps-run-anywhere-appimage/ +[6]: https://github.com/AppImage/AppImageKit/releases diff --git a/published/202006/20200607 5 ways to boost your Kubernetes knowledge.md b/published/202006/20200607 5 ways to boost your Kubernetes knowledge.md new file mode 100644 index 0000000000..8912c4aa92 --- /dev/null +++ b/published/202006/20200607 5 ways to boost your Kubernetes knowledge.md @@ -0,0 +1,89 @@ +[#]: collector: "lujun9972" +[#]: translator: "lxbwolf" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-12320-1.html" +[#]: subject: "5 ways to boost your Kubernetes knowledge" +[#]: via: "https://opensource.com/article/20/6/kubernetes-anniversary" +[#]: author: "Seth Kenlon https://opensource.com/users/seth" + +提升你 Kubernetes 技能的 5 种方式 +====== + +> 值此周年纪念之际,来通过这些深度文章和实践项目了解下 Kubernetes。 + +![](https://img.linux.net.cn/data/attachment/album/202006/16/191023lqq0d5zv5vggr2vg.png) + +在云原生的成长期,开发者们发现在一个小型的、原子化的、精简的 Linux 镜像里编写应用程序很方便,这些镜像与它们所运行的服务器共享资源。从技术上讲,这些基于内核命名空间的小环境定义被称为[容器][2]。随着容器的激增,系统管理员们很快意识到,开发一个不仅能帮助他们管理容器,还能帮助他们管理下面的虚拟化基础设施的工具变得至关重要。于是,[Kubernetes][3] 应运而生。 + +Kubernetes 是一个可扩展开源平台,用于管理容器。它可以帮助管理员和开发者们围绕容器管理工作负载、服务和进程。它促进了声明式配置,更容易实现自动化。在它相对较短的生命周期中,它已经催生了一个迅速成长的生态系统,其中包括来自大量公司和项目的服务、支持和工具。 + +如果你想对这项重要的云技术有更多的了解,这里有一些能帮忙你更深入学习的文章。还有 5 个项目可以帮你把学到的东西付诸实践。 + +### 遏制容器乱象 + +2016 年,我们发布了《[使用 Kubernetes 遏制容器乱象][4]》,这是一篇由 Terry Ryan 写的关于 Kubernetes 的介绍性文章,讲述了 Kubernetes 如何帮助管理员和架构师们努力应对容器。如果你想找一篇从底层介绍容器是做什么的以及 Kubernetes 是如何实现容器管理的,那么你应该先读下本文。本文适合零基础的读者,解释了所有重要的概念,因此你能迅速了解相关技术。 + +如果想进阶了解内核层面发生的一些神奇的事情,请阅读 Jessica Cherry 对 [Kubernetes 命名空间][5]的解释。 + +延伸阅读: + +- [一文了解 Kubernetes 是什么?](https://linux.cn/article-8800-1.html) +- [Kubernetes 是什么?](https://linux.cn/article-8858-1.html) + +### Kubernetes:为什么它很重要? + +Kubernetes 提供了基础设施即服务Infrastructure-as-a-Service(IaaS)解决方案(类似 OpenStack)的便利和一个完整的平台即服务Platform as a Service(PaaS)。它为你提供了管理基础设施的抽象能力,以及在裸金属基础层面进行故障排除所需的工具。如果你执着于使用单一的裸金属服务器,你可能需要阅读下 Tim Potter 写的《[你为什么需要 Kubernetes][6]》。他的文章对比了 IaaS 和 PaaS,解释了为什么 Kubernetes 如此广泛地被使用。你可能并不是一定需要 Kubernetes 或容器,但是重要的是知道什么情况下需要。 + +延伸阅读: + +- [使用 Kubernetes 的 5 个理由](https://linux.cn/article-10973-1.html) +- [你(多半)不需要 Kubernetes](https://linux.cn/article-10469-1.html) + +### 在树莓派上运行 Kubernetes + +熟悉 Kubernetes 的最好方法莫过于自己运行它。不幸的是,不是每个人都有一个云服务基层设施(或者有足够的钱来租用一个)可供其支配。而幸运的是,Chris Collins 提供了《[在树莓派上运行 Kubernetes][7]》的教程。结合他的另外几篇关于《[Cloud-init][8]》和《[Cloud-init 服务][9]》的教程(也是在树莓派上运行),你可以搭建任何你想要的家庭实验室,这样你就可以学习如何管理属于自己的开放混合云。 + +### Kubernetes 命令 + +一旦你运行起 Kubernetes 后,可以看看 Jessica Cherry 的文章和附带的备忘清单,这个清单列出了所有的[基本的 Kubernetes 命令][10]。在她的文章中,她解释了 `kubectl` 命令的语法,简单讲述了每个命令和子命令是用来做什么的。 + +### 有趣的 Kubernetes 项目 + +没有什么比拥有技术却不知道该怎么用它更令人沮丧的了。例如,在你的办公桌上有一个树莓派是一回事,但是决定它的 CPU 应该用来做什么工作却完全是另一回事。我们发布了很多教程,来指导你完成你的 Kubernetes 之路的探索: + + * [Helm][11] 是一个 Kubernetes 的包管理器。你可以在它的帮助下,很快熟悉 Kubernetes 环境。 + * 学习下 [Operator SDK][12] 的所有内容,来熟悉 Kubernetes 的对象和操作器。 + * [在 Kubernetes 之上搭建网络文件系统(NFS)][13] + * 学习如何使用 [Skipper][14] 或 [Traefik][15] 进行流量调度。 + +最重要的,花点时间来熟悉容器和 Kubernetes。不论你先把容器化的应用放到服务器、云上还是桌面,它们都是能帮助你理解的重要的范例,因为它们是一个强大的构造,可以让 Linux 的应用变得更好、更健壮、鲁棒性更好、更简单。一定要投入精力去学习它们,你不会后悔的。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/kubernetes-anniversary + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/ship_captain_devops_kubernetes_steer.png?itok=LAHfIpek "Ship captain sailing the Kubernetes seas" +[2]: https://opensource.com/article/18/11/behind-scenes-linux-containers +[3]: https://opensource.com/resources/what-is-kubernetes +[4]: https://opensource.com/life/16/9/containing-container-chaos-kubernetes +[5]: https://linux.cn/article-11749-1.html +[6]: https://linux.cn/article-8902-1.html +[7]: https://linux.cn/article-8499-1.html +[8]: https://opensource.com/article/20/5/cloud-init-raspberry-pi-homelab +[9]: https://opensource.com/article/20/5/create-simple-cloud-init-service-your-homelab +[10]: https://opensource.com/article/20/5/kubectl-cheat-sheet +[11]: https://linux.cn/article-12007-1.html +[12]: https://opensource.com/article/20/3/kubernetes-operator-sdk +[13]: https://opensource.com/article/20/6/kubernetes-nfs-client-provisioning +[14]: https://opensource.com/article/20/4/http-kubernetes-skipper +[15]: https://opensource.com/article/20/3/kubernetes-traefik diff --git a/published/202006/20200609 Style your data plots in Python with Pygal.md b/published/202006/20200609 Style your data plots in Python with Pygal.md new file mode 100644 index 0000000000..89fc30a3a1 --- /dev/null +++ b/published/202006/20200609 Style your data plots in Python with Pygal.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12364-1.html) +[#]: subject: (Style your data plots in Python with Pygal) +[#]: via: (https://opensource.com/article/20/6/pygal-python) +[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan) + +使用 Pygal 在 Python 中设置数据图的样式 +====== + +> 介绍一种更时尚的 Python 绘图库。 + +![](https://img.linux.net.cn/data/attachment/album/202006/30/120650hlf8lm0em3l1m8zd.jpg) + +[Python][2] 有很多可以将数据可视化的库。其中一个互动性较强的库是 Pygal,我认为这个库适合喜欢漂亮事物的人。它可以生成用户可以与之交互的漂亮的 SVG(可缩放矢量图形)文件。SVG 是交互式图形的标准格式,仅使用几行 Python 就可以带来丰富的用户体验。 + +### 使用 Pygal 进行时尚的 Python 绘图 + +在本文中,我们要重新创建多柱状图,用来表示 1966 年至 2020 年英国大选的结果: + +![Pygal plot][3] + +在继续之前,请注意你可能需要调整 Python 环境以使此代码运行,包括: + + * 运行最新版本的 Python([Linux][4]、[Mac][5] 和 [Windows][6] 的说明) + * 确认你运行的是与这些库兼容的 Python 版本 + +数据可在线获得,并可使用 pandas 导入: + +``` +import pandas as pd +df = pd.read_csv('https://anvil.works/blog/img/plotting-in-python/uk-election-results.csv') +``` + +现在我们可以继续进行了。。数据如下所示: + +``` +        year  conservative  labour  liberal  others +0       1966           253     364       12       1 +1       1970           330     287        6       7 +2   Feb 1974           297     301       14      18 +..       ...           ...     ...      ...     ... +12      2015           330     232        8      80 +13      2017           317     262       12      59 +14      2019           365     202       11      72 +``` + +在 Pygal 中进行绘制会以一种易于阅读的方式显示。首先,我们以一种简化柱状图定义的方式定义样式对象。然后我们将自定义样式以及其他元数据传递给 `Bar` 对象: + +``` +import pygal +from pygal.style import Style + +custom_style = Style( + colors=('#0343df', '#e50000', '#ffff14', '#929591'), + font_family='Roboto,Helvetica,Arial,sans-serif', + background='transparent', + label_font_size=14, +) + +c = pygal.Bar( + title="UK Election Results", + style=custom_style, + y_title='Seats', + width=1200, + x_label_rotation=270, +) +``` + +然后,我们将数据添加到 `Bar` 对象中: + +``` +c.add('Conservative', df['conservative']) +c.add('Labour', df['labour']) +c.add('Liberal', df['liberal']) +c.add('Others', df['others']) + +c.x_labels = df['year'] +``` + +最后,我们将图另存为 SVG 文件: + +``` +c.render_to_file('pygal.svg') +``` + +结果是一个交互式 SVG 图,你可以在此 gif 中看到: + +![The Python pygal library can generate rich SVG files as seen here][7] + +精美简单,并且效果漂亮。 + +### 总结 + +Python 中的某些绘图工具需要非常详细地构建每个对象,而 Pygal 从一开始就为你提供这些。如果你手边有数据并且想做一个干净、漂亮、简单的交互式图表,请尝试一下 Pygal。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/pygal-python + +作者:[Shaun Taylor-Morgan][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shaun-taylor-morgan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_python.jpg?itok=G04cSvp_ (Python in a coffee cup.) +[2]: https://opensource.com/article/20/4/plot-data-python +[3]: https://opensource.com/sites/default/files/uploads/pygal_1.png (Pygal plot) +[4]: https://opensource.com/article/20/4/install-python-linux +[5]: https://opensource.com/article/19/5/python-3-default-mac +[6]: https://opensource.com/article/19/8/how-install-python-windows +[7]: https://opensource.com/sites/default/files/uploads/pygal-interactive_3.gif (The Python pygal library can generate rich SVG files as seen here) +[8]: https://anvil.works/blog/plotting-in-pygal diff --git a/published/202006/20200610 5 ways to examine the content of files on Linux.md b/published/202006/20200610 5 ways to examine the content of files on Linux.md new file mode 100644 index 0000000000..90f1db340d --- /dev/null +++ b/published/202006/20200610 5 ways to examine the content of files on Linux.md @@ -0,0 +1,241 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12340-1.html) +[#]: subject: (5 ways to examine the content of files on Linux) +[#]: via: (https://www.networkworld.com/article/3561490/5-ways-to-examine-the-content-of-files-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +在 Linux 上查看文件内容的 5 种方法 +====== + +> 如何使用 cat、more、head 和 tail 命令查看 Linux 文件的内容,而不仅仅是文本文件。 + +![](https://img.linux.net.cn/data/attachment/album/202006/23/121047zz9gwx9dwz155m2w.jpg) + +Linux 提供了许多命令来查看文件的内容,包 括 `cat`、`more`、`head` 和 `tail`,但这只是一个开始。 + +一方面,即使是最显而易见的命令也有很多许多用户不会去使用的选项。还有一些普普通通的命令提供了一些独特的功能。在本文中,我们将介绍查看文件内容的命令,以及如何定制这些视图以更好地满足你的需求的选项。 + +### cat + +`cat` 命令将文本文件的全部内容发送到终端窗口以供查看。实际上,如果你输入 `cat`,然后输入包含数千行内容的文件名,那么这些行将以极快的速度在你的窗口中滚动,你将无法看到除了最后一屏外的其他文本。对于 Linux 用户来说 `cat` 命令很熟悉,但即使是这个基本命令也提供了许多有用的选项,例如对输出中的行进行编号,这是我们许多人可能从未使用过的。更进一步,你不仅可以对行进行编号,还可以选择如何编号。 + +对每行进行编号就像这样: + +``` +$ cat -n msg + 1 Hello -- + 2 + 3 I hope you are having a wonderful day! + 4 + 5 + 6 That's it for ... now + 7 + 8 bye! + 9 + 10 s. +``` + +你也可以只对有内容的行编号。请注意,对于此命令,仅包含空格的行不被视为“空”,而是会被编号。 + +``` +$ cat -b msg + 1 Hello -- + + 2 I hope you are having a wonderful day! + + + 3 That's it for ... now + + 4 bye! + + 5 s. +``` + +`cat` 命令允许你使用 `-s` 选项忽略重复的空白行,但是要完全忽略空白行你必须添加另一个命令。 + +``` +$ cat -s msg +Hello -- + +I hope you are having a wonderful day! + +That's it for ... now + +bye! + +s. +``` + +要忽略所有空白行,只需如下将 `cat` 的输出通过管道传递给 `grep` 命令。 点(`.`)匹配包含任意字符的文本,因此它将显示任意非空的行,用于结束一行的回车换行做匹配(LCTT 译注:此处原文有误,径改)。 + +``` +$ cat msg | grep . +Hello -- +I hope you are having a wonderful day! +That's it for ... now +bye! +s. +``` + +`-E` 选项通过在每行末尾加 `$` 符提供视觉提示,来显示行尾是否还有多余的空格。 + +``` +$ cat -E msg +Hello --$ +$ +I hope you are having a wonderful day! $ +$ +$ +That's it for ... now$ +$ +bye!$ +$ +s.$ +``` + +使用 `-A` 时,既可以在每行的末尾显示 `$` 字符,并且制表符会显示为 `^I` 而不是空白。 + +``` +$ cat -A msg +Hello --$ +$ +I hope you are having a wonderful day!$ +$ +$ +That’s it for ...^Inow$ +$ +bye!$ +$ +s.$ +``` + +### 使用 head 和 tail 显示文件部分内容 + +`head` 和 `tail` 显示文件的头部或尾部,默认为十行。 你可以使用 `-3`(显示 3 行)或 `-11`(显示 11 行)之类的字符串来指定要查看的其它行数。`tail` 命令与 `head` 的工作方式相同,但是显示文件的尾部而不是头部。 + +``` +$ head -3 msg +Hello -- +I hope you are having a wonderful day! +$ tail -3 msg +bye! + +s. +``` + +你还可以结合使用 `head` 和 `tail` 命令来查看文件中间的文本。你只需要选择起点和想要查看行数即可。在此例中,命令将在文件中显示第二个一百行,并在 `cat` 的帮助下为这些行编号。 + +``` +$ cat -b mybigfile | head -200 | tail -100 + 101 Invoice #2020-06-07a sent to vendor + ... +``` + +### 使用 more 或者 less 浏览一屏文本 + +`more` 命令是一次浏览一屏内容的自然之选,而 `less` 通过使用上下键盘箭头增加了在文件中上下移动的能力,这样你就可以遍历内容,然后在文件中回退。 + +### 使用 od 查看文本的两种方法 + +`od`(八进制转储)命令能够以常规文本和一系列 ASCII 值(即该文本在文件中的实际编码方式)的形式查看文件。在下面的例子中可以看到,带编号的行显示了 ASCII 数字值,而其他行则显示了文本和不可打印的字符。 + +``` +$ od -bc msg +0000000 110 145 154 154 157 040 055 055 012 012 111 040 150 157 160 145 + H e l l o - - \n \n I h o p e +0000020 040 171 157 165 040 141 162 145 040 150 141 166 151 156 147 040 + y o u a r e h a v i n g +0000040 141 040 167 157 156 144 145 162 146 165 154 040 144 141 171 041 + a w o n d e r f u l d a y ! +0000060 012 012 012 124 150 141 164 047 163 040 151 164 040 146 157 162 + \n \n \n T h a t ' s i t f o r +0000100 040 056 056 056 011 156 157 167 012 012 142 171 145 041 012 012 + . . . \t n o w \n \n b y e ! \n \n +0000120 163 056 012 + s . \n +``` + +请注意,换行符显示为 `\n`(八进制 `012`),而制表符显示为 `\t`(八进制 `011`)。 + +`od` 命令特别有用的用途之一是查看非文本文件以获取可以标识文件类型的信息。在这里,我们看到 `JFIF`(JPEG 文件交换格式)标签,该标签让 `file` 之类报告文件类型的命令将它标示为 jpg 文件。这里还有很多其他有用的信息,特别是如果你对这些文件的格式感到好奇的话。 + +在接下来的命令中,我们查看 jpg 文件的开始部分。 + +``` +$ od -bc arrow.jpg | head -12 +0000000 377 330 377 340 000 020 112 106 111 106 000 001 001 000 000 001 + 377 330 377 340 \0 020 J F I F \0 001 001 \0 \0 001 +0000020 000 001 000 000 377 333 000 103 000 003 002 002 002 002 002 003 + \0 001 \0 \0 377 333 \0 C \0 003 002 002 002 002 002 003 +0000040 002 002 002 003 003 003 003 004 006 004 004 004 004 004 010 006 + 002 002 002 003 003 003 003 004 006 004 004 004 004 004 \b 006 +0000060 006 005 006 011 010 012 012 011 010 011 011 012 014 017 014 012 + 006 005 006 \t \b \n \n \t \b \t \t \n \f 017 \f \n +0000100 013 016 013 011 011 015 021 015 016 017 020 020 021 020 012 014 + \v 016 \v \t \t \r 021 \r 016 017 020 020 021 020 \n \f +0000120 022 023 022 020 023 017 020 020 020 377 333 000 103 001 003 003 + 022 023 022 020 023 017 020 020 020 377 333 \0 C 001 003 003 +``` + +如果我们要 `file` 命令提供有关此图像的信息,我们可能会看到类似下面这样的信息。`file` 命令从文件开头的数据中提取了所有这些描述性信息: + +``` +$ file arrow.jpg +arrow.png: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 500x375, components 3 +``` + +### 使用 jp2a 将文件视为基于文本的图像 + +如果你只能在命令行工作,并且想了解特定图像包含的内容,那么可以使用 `jp2a`(jpeg to ascii)之类的工具提供字符渲染。图像在这种格式下的识别程度取决于文件。不要有太多期待,因为你将看到的图像版本是“低分辨率”下的测试!这是一只分辨率很低的帝王企鹅。(请离远点看) + +``` +$ jp2a Emperor_Penguin.jpg +MMMMMMMMWOdkNMMMMMMMMMMMMMMMMMMM +MMMXK0kc.... ,OKMMMMMMMMMMMMMMMM +MMNK0Ol... :Xx'dNMMMMMMMMMMMMM +MMMMMMMd;lx00Oo. ..xMMMMMMMMMMMM +MMMMMMK.OXMMMMMN,...lMMMMMMMMMMM +MMMMMMx'KXNNMMMMK....0MMMMMMMMMM +MMMMMMx:kkKNWWMMMl.. 'NMMMMMMMMM +MMMMMMddx0NNNWMMMK'...;NMMMMMMMM +MMMMMMck0NNWWWWWMMd ..lMMMMMMMM +MMMMMM.d0KXNWWWWMMo ...WMMMMMMM +MMMMMM.xOXNNWNMMMW. ....KMMMMMMM +MMMMMM'kKNKWXWMMMK ..'.0MMMMMMM +MMMMMMxckXNNNNMMMX .:..XMMMMMMM +MMMMMMW;xKNWWWMMMM. .;. NMMMMMMM +MMMMMMMok0NNWNWMMMx .l..MMMMMMMM +MMMMMMMkxOKXWXNMMMMl.:'dMMMMMMMM +MMMMMMM0dKOdKXXNMMMMNx,WMMMMMMMM +MMMMMMMWoKxldXKNNMMMMM;MMMMMMMMM +MMMMMMMMxxxxdNWNXNMMMM;MMMMMMMMM +MMMMMMMMxOcoo0XOOOOWMW,kMMMMMMMM +MMMMMMM0xK;.cO0dNX:0XXd;NMMMMMMM +MMMNkdd:,'ldXXO0xl;x0kx:;lKMMMMM +MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM +``` + +### 总结 + +Linux 上有很多命令可以通过各种方式查看文件的内容。其中一些选项在你需要处理文件内容时可能会非常有用。其它的只是……有趣。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3561490/5-ways-to-examine-the-content-of-files-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://unsplash.com/photos/q65bNe9fW-w +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202006/20200610 How to Change Folder Color in Ubuntu 20.04.md b/published/202006/20200610 How to Change Folder Color in Ubuntu 20.04.md new file mode 100644 index 0000000000..42f0043ab2 --- /dev/null +++ b/published/202006/20200610 How to Change Folder Color in Ubuntu 20.04.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12311-1.html) +[#]: subject: (How to Change Folder Color in Ubuntu 20.04) +[#]: via: (https://itsfoss.com/folder-color-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 20.04 中更改文件夹颜色 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/13/133146y1bjzb73jj141143.jpg) + +[Ubuntu 20.04][1] 中默认的 Yaru 主题赋予它优美、现代的外观。默认 Yaru 主题中的文件夹是紫色的外观,以与 Ubuntu 的品牌保持一致。 + +如果你不喜欢紫色,可以在 Ubuntu 中自由更改颜色主题。你可以更改 Ubuntu 的主题以使其有不同的颜色,但这将意味着放弃 Yaru 主题。 + +如果你只想在 Ubuntu 20.04 中更改文件夹的颜色,可以有两种方法: + +* 为选定的文件夹赋予不同的颜色和标志(以便更好地组织文件和文件夹) +* 通过更改 Yaru 颜色主题来更改所有文件夹的颜色 + +让我向你展示两种方法。 + +### 更改所选文件和文件夹的颜色和标志 + +![][2] + +我知道有些人将他们的文件夹使用不同的颜色或放在不同的位置,来表示工作正在进行中还是待处理或已完成。 + +如果你也是这样的,那么可以使用 [Folder Color 工具][3]更改文件夹的颜色。你还可以在文件夹中添加标志(绿色的勾号表示完成,加号表示新的,感叹号表示重要等)。你可以在上一张图片中看到一些例子。 + +你还可以在文件上使用 “Folder Color” 工具。你不能更改文件图标的颜色,但可以添加标志。 + +如果你在 Ubuntu 20.04 中[使用 Yaru 主题][4],你可以使用[官方 PPA][5]: + +``` +sudo add-apt-repository ppa:costales/yaru-colors-folder-color +``` + +现在,使用 Yaru 兼容包安装 Folder Color。 + +``` +sudo apt install folder-color yaru-colors-folder-color +``` + +安装后,你必须使用 `nautilus -q` 命令重启 Nautilus 文件管理器。之后,你可以进入文件管理器,右键单击文件夹或文件。你会在上下文菜单中看到 Folder Color 的选项。你将在此处看到颜色和标志选项。 + +![][6] + +你还可以通过在菜单**通过选择“默认”恢复原始文件夹颜色**。 + +对于 Ubuntu 18.04 或更早版本,可以从软件中心安装 Folder Color。它还可用于 Linux Mint/Cinnamon 桌面的 Nemo 文件管理器和 MATE 桌面的 [Caja 文件管理器][7]。 + +#### 如何删除 Folder Color? + +如果你不想使用 Folder Color,你可以删除应用并删除 PPA。首先删除该应用: + +``` +sudo apt remove folder-color yaru-colors-folder-color +``` + +现在[删除 PPA][8]: + +``` +sudo add-apt-repository -r ppa:costales/yaru-colors-folder-color +``` + +### Yaru Colors 主题包更改 Yaru 主题颜色 + +![Yaru Colors Blue Theme Variant][9] + +如果你想继续使用 Yaru 主题但使用不同的颜色,那么需要[Yaru Colors 主题包][10]。 + +Yaru Colors 由 12 种 Yaru 颜色变体组成。它们浅绿色、蓝色、棕色、深蓝色、绿色、灰色、MATE 绿、橙色、粉红色、紫色、红色和黄色。 + +主题包括 GTK 主题、图标、光标和 GNOME Shell 主题。 + + * 图标:更改文件夹的强调色 + * GTK 主题:更改应用窗口的强调色 + * 光标主题:向光标添加几乎可以忽略的色彩轮廓 + * GNOME Shell 主题:更改消息托盘和系统托盘中的强调色 + +你可以从它的 GitHub 仓库下载 Yaru Colors 主题包: + +#### 下载 Yaru Colors 主题包 + +在提取内容时,你会发现图标、主题文件夹,这两个文件夹都包含上述十二种颜色。你可以分别在 `~/.local/share/.icons` 和 `~/.local/share/themes` 文件夹中复制图标和主题文件夹。 + +如果你不想亲自复制,那么你可以在解压文件夹中找到 `install.sh` 脚本。你可以运行它来通过交互式终端会话安装全部或选定的几个主题。 + +![][11] + +要更改 GNOME Shell 主题,你必须[使用 GNOME Tweak 工具][12]。你也可以使用 GNOME Tweak 将图标和主题更改回默认。 + +![][13] + +享受为你的 Ubuntu 生活增色 :) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/folder-color-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/download-ubuntu-20-04/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/folder-colors-yaru-ubuntu.png?ssl=1 +[3]: https://foldercolor.tuxfamily.org/ +[4]: https://itsfoss.com/ubuntu-community-theme/ +[5]: https://launchpad.net/folder-color +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/change-folder-color-ubuntu.png?ssl=1 +[7]: https://github.com/mate-desktop/caja +[8]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/yaru-colors-blue-theme-variant.jpg?ssl=1 +[10]: https://github.com/Jannomag/Yaru-Colors +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/yaru-colors-theme-install.png?resize=800%2C513&ssl=1 +[12]: https://itsfoss.com/gnome-tweak-tool/ +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/restore-yaru-gnome-tweak.png?resize=800%2C557&ssl=1 diff --git a/published/202006/20200610 How to write functions in Bash.md b/published/202006/20200610 How to write functions in Bash.md new file mode 100644 index 0000000000..1df7f0efc2 --- /dev/null +++ b/published/202006/20200610 How to write functions in Bash.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12323-1.html) +[#]: subject: (How to write functions in Bash) +[#]: via: (https://opensource.com/article/20/6/bash-functions) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何在 Bash 中编写函数 +====== + +> 通过编写函数来减少代码的冗余和维护。 + +![](https://img.linux.net.cn/data/attachment/album/202006/17/125913hf1efce5c48cebrc.jpg) + +在编程时,实际上是在定义要由计算机执行的过程procedure例程routine。一个简单的类比是将计算机编程与烤面包进行比较:你一次列出了要组建工作环境的配料,然后列出了烤面包所必须采取的步骤。在编程和烘烤中,必须以不同的间隔重复执行某些步骤。例如,在烤面包中,这可能是酵母培养的过程: + +``` +STIR=100 +SNOOZE=86400 + +function feed_culture { +  remove_from(pantry) +  add(flour, water) +  stir($STIR) +  sleep($SNOOZE) +} +``` + +然后,揉面和醒发面团: + +``` +KNEAD=600 +SNOOZE=7200 + +function process_dough { +  remove_from(proofing_drawer) +  knead($KNEAD) +  return_to_drawer($SNOOZE) +} +``` + +在编程中,这些子例程subroutines可以表示为函数function。函数对程序员很重要,因为它们有助于减少代码中的冗余,从而减少了所需的维护量。例如,在以编程方式烤制面包的假想场景中,如果你需要更改面团醒发的用时,只要你之前使用函数,那么你只需更改一次用时,或使用变量(在示例代码中为 `SNOOZE`)或直接在处理面团的子程序中更改用时。这样可以节省你很多时间,因为你不必通过你的代码库遍历每个可能正在醒发的面团,更不用说担心错过一个。许多 bug 是由未更改的缺失的值或执行不正确的 `sed` 命令引起的,它们希望捕获所有可能而不必手动寻找。 + +在 [Bash][2] 中,无论是在编写的脚本或在独立的文件中,定义函数和使用它们一样简单。如果将函数保存到独立的文件中。那么可以将它 `source` 到脚本中,就像 `include` C 语言或 C++ 中的库或将模块 `import` 到 Python 中一样。要创建一个 Bash 函数,请使用关键字 `function`: + +``` +function foo { +# code here +} +``` + +这是一个如何在函数中使用参数的例子(有些人为设计,因此可能会更简单): + +``` +#!/usr/bin/env bash +ARG=$1 + +function mimic { +  if [[ -z $ARG ]]; then +    ARG='world' +  fi +  echo "hello $ARG" +} + +mimic $ARG +``` + +结果如下: + +``` +$ ./mimic +hello world +$ ./mimic everybody +hello everybody +``` + +请注意脚本的最后一行,它会执行该函数。对于编写脚本的新手来说,这是一个普遍的困惑点:函数不会自动执行。它们作为*潜在的*例程存在,直到被调用。 + +如果没有调用该函数,那么函数只是被定义,并且永远不会运行。 + +如果你刚接触 Bash,请尝试在包含最后一行的情况下执行示例脚本一次,然后在注释掉最后一行的情况下再次执行示例脚本。 + +### 使用函数 + +即使对于简单的脚本,函数也是很重要的编程概念。你越适应函数,在面对一个不仅需要声明性的命令行,还需要更多动态的复杂问题时,你就会越容易。将通用函数保存在单独的文件中还可以节省一些工作,因为它将帮助你建立常用的程序,以便你可以在项目间重用它们。看看你的脚本习惯,看是否适合使用函数。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/bash-functions + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: https://opensource.com/resources/what-bash diff --git a/published/202006/20200611 How I stream video with OBS and WebSockets.md b/published/202006/20200611 How I stream video with OBS and WebSockets.md new file mode 100644 index 0000000000..56e391979e --- /dev/null +++ b/published/202006/20200611 How I stream video with OBS and WebSockets.md @@ -0,0 +1,137 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12347-1.html) +[#]: subject: (How I stream video with OBS and WebSockets) +[#]: via: (https://opensource.com/article/20/6/obs-websockets-streaming) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +如何用 OBS 和 WebSockets 播放视频流 +====== + +> 用这些简化了 WebSockets 的开源支持工具来控制你的流媒体。 + +![](https://img.linux.net.cn/data/attachment/album/202006/25/105128sdod30qqu4z5oooo.jpg) + +[OBS][2] 是现在视频直播的主流之一。它是直播流媒体到 Twitch 的首选软件,Twitch 是近来最受欢迎的视频直播网站之一。有一些非常好的附加组件,可以让流媒体人从他们的手机或另一个屏幕上进行控制,而不影响正在运行的视频。事实证明,使用 [Node-RED][3] 和 [obs-websockets][4] 插件来构建自己的控制面板真的很容易。 + +![My OBS Control Dashboard][5] + +*我的 OBS 控制仪表盘* + +我知道你们很多人在想什么 —— “他在同一句话中提到了 WebSockets 和简单?”很多人在设置和使用 WebSockets 时遇到了困难,WebSockets 允许通过 Web 服务器的单一连接进行双向通信。Node-RED 内置了对 WebSockets 的支持,是让这一切变得简单的原因之一,至少与编写自己的客户端/服务器相比是如此。 + +在开始之前,请确保你已经安装和配置了 OBS。首先下载并安装[最新稳定版的 obs-websockets][6]插件。对于本文来说,默认的设置就可以了,但我强烈建议你之后按照说明来保护 obs-websockets 的安全。 + +接下来,[下载并安装 Node-RED][7],可以在同一个系统上,也可以在不同的系统上(比如树莓派)。同样,默认的安装对我们这篇文章来说是够了,但最好按照他们网站上的指示进行安全安装。 + +现在是有趣的部分。启动 Node-RED,打开网页界面(默认在 ),你有了一个空白的画布。打开右边的“汉堡”菜单,选择“管理口味Manage Palate”。然后点击“安装”标签,搜索 `node-red-contrib-dashboard` 和 `node-red-contrib-rbe` 模块。 + +安装好这些模块后,点击右侧列表,将以下模块拖拽到画布上。 + + * 1 Websocket Out + * 1 Websocket In + * 1 Debug + * 1 Inject + * 1 Switch + * 1 Change + * 2 JSON + * 1 Catch + +以下列顺序连接它们: + +``` +Inject->Button->Change->JSON->Websocket Out + +Websocket In->JSON->Switch->RBE->Debug + +Catch->Debug +``` + +![The basic flows][8] + +*基本流程* + +当 “Button” 被按下时(或 “Inject” 节点发送一个时间戳),有效载荷通过 “change” 节点发送,从 JSON 对象转换为字符串,然后发送到 “WebSocket Out” 节点。当 “WebSocket In” 节点收到消息后,会将其转换为 JSON 对象,如果不是重复的,则发送到 “Debug” 节点进行输出。而 “Catch” 节点会捕捉到任何错误,并将其放入 “Debug” 面板中。 + +那有效载荷里有什么呢?让我们设置好一切,一探究竟。 + +首先,双击 “Button” 打开设置对话框。先使用下拉菜单将有效载荷改为 “JSON”。在该字段中,添加以下内容: + +``` +{"request-type":"GetVersion"} +``` + +启用 “If msg arrives on input, emulate a button click” 复选框,然后点击 “Done” 关闭 “Button” 配置。当消息从 “Inject” 节点传来时,或者 UI 中的 “Button” 被按下,它将把 JSON 有效载荷发送到下一个节点。 + +![Setting up the button][9] + +*设置 “Button”* + +现在打开 “Change” 节点。我们要将 `msg.payload.message-id` 设置为 `msg._msgid`,方法是将第一个字段从 `payload` 改为 `payload.message-id`,然后使用第二个字段的下拉菜单将类型从 `String` 改为 `msg.`,然后我们将 `_msgid` 放入该字段。这样就会把唯一的消息 ID 复制到 JSON 对象的有效载荷中,这样每个请求就有一个唯一的 ID 进行跟踪。 + +然后将其发送到 “JSON” 节点,以便将 JSON 对象转换为字符串,然后传递给 “Websocket Out” 节点。打开 “Websocket Out” 节点,配置到 OBS 的连接。首先,将 `Type` 更改为 `Connect to`,然后单击铅笔图标以创建新的连接 URL。将其设置为 `ws://OBSMachine:4444/`,然后关闭对话框进行保存。`OBSMachine` 是 OBS 和 obs-websocket 运行的机器名称。例如,如果 Node-RED 运行在同一台机器上,则为 `ws://localhost:4444`,如果是在名为 `luxuria.local` 的机器上,则为 `ws://luxuria.local:4444`。关闭并更新 “Websocket Out” 节点。这将向 OBS 中的 WebSocket 发送有效载荷文本字符串。 + +![Websocket Out Node configuration][10] + +*“Websocket Out” 节点配置* + +进入 “WebSocket In” 流程!打开 “WebSocket In” 节点,并对其设置 `Type` 为 `Connect to` 和我们之前定义的连接的 URL(应自动填充)。接下来是第二个 “JSON” 节点,我们可以不用管它。它接受 OBS 的输出,并将其转换为有效载荷对象。 + +接下来,我们将从中过滤出常规的心跳和状态更新。打开 “Switch”,将 `Property` 值设置为 `payload["update-type"]`。现在从它下面的下拉菜单中选择 `Is Not Null`。点击 `+` 添加第二个选项,并从下拉菜单中选择 `otherwise`。 + +![Switch Node configuration][11] + +*“Switch” 节点配置* + +将 “Switch” 上的新输出直接连接到 “Debug” 节点的输入。 + +RBE 节点将过滤掉重复的内容,需要告诉它要观察什么字段。由于它应该连接到 “Switch” 的输出,而它只发送状态更新,所以这一点很重要,因为 obs-websocket 每隔几秒钟就会发送更新。默认情况下,RBE 会比较整个有效载荷对象,它将不断变化。打开 RBE 节点,将 `Property` 从 `payload` 改为 `payload.streaming`。如果 `payload` 的 `streaming` 值发生了变化,那么就把消息传递过去,否则就丢弃。 + +最后一步是将 “Debug” 节点的输出从 `msg.payload` 改为完整的 `msg` 对象。这使我们能够看到整个对象,有时在 `payload` 之外还有有用的信息。 + +现在,单击 “Deploy” 以激活更改。希望 WebSocket 节点下面会有绿色的 `Connected` 消息。如果它们是红色或黄色的,则连接 URL 可能不正确,需要更新,或者连接被阻止。请确保远程机器上的 4444 端口是开放的、可用的,并且 OBS 正在运行! + +如果没有 RBE 节点对 `streaming` 值的过滤,调试面板(点击画布右侧的“虫子”图标)大约现在就会被心跳消息填满。点击 “Inject” 节点左边的按钮,发送一个模拟按钮点击的信号。如果一切顺利,你应该会看到一个对象到达,它有一个 `obs-websocket` 可以做的所有事情的列表。 + +![The response to "GetVersion"][12] + +*对 “GetVersion” 的回应* + +现在在另一个标签或窗口中打开 `http://localhost:1880/ui`。它应该显示一个单一的按钮。按下它! 调试面板应该会显示和之前一样的信息。 + +恭喜你!你已经发送了你的第一个(希望不是最后一个)WebSocket 消息! + +这只是使用 obs-websockets 和 Node-RED 可以做的事情的起步。支持的完整文档记录在 obs-websockets 的 GitHub 仓库的 `protocol.md` 文件中。通过一点点的实验,你可以创建一个功能齐全的控制面板来启动和停止流媒体、改变场景,以及更多。如果你和我一样,在意识到之前,你就可以设置好各种控件了。 + +![OBS Websocket][13] + +*如此多的能力让我有点疯* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/obs-websockets-streaming + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [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/LIFE_film.png?itok=aElrLLrw (An old-fashioned video camera) +[2]: https://obsproject.com/ +[3]: https://nodered.org/ +[4]: https://github.com/Palakis/obs-websocket +[5]: https://opensource.com/sites/default/files/uploads/obscontrol-img1.png.jpg (My OBS Control Dashboard) +[6]: https://github.com/palakis/obs-websocket/releases +[7]: https://nodered.org/docs/getting-started/ +[8]: https://opensource.com/sites/default/files/uploads/obscontrol-img2.png.jpg (The basic flows) +[9]: https://opensource.com/sites/default/files/uploads/obscontrol-img3.png.jpg (Setting up the button) +[10]: https://opensource.com/sites/default/files/uploads/obscontrol-img4.png.jpg (Websocket Out Node configuration) +[11]: https://opensource.com/sites/default/files/uploads/obscontrol-img5.png.jpg (Switch Node configuration) +[12]: https://opensource.com/sites/default/files/uploads/obscontrol-img6.png.jpg (The response to "GetVersion") +[13]: https://opensource.com/sites/default/files/uploads/obscontrol-img7.png.jpg (OBS Websocket) diff --git a/published/202006/20200612 Import functions and variables into Bash with the source command.md b/published/202006/20200612 Import functions and variables into Bash with the source command.md new file mode 100644 index 0000000000..f8dc02f78e --- /dev/null +++ b/published/202006/20200612 Import functions and variables into Bash with the source command.md @@ -0,0 +1,126 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12346-1.html) +[#]: subject: (Import functions and variables into Bash with the source command) +[#]: via: (https://opensource.com/article/20/6/bash-source-command) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 source 命令将函数和变量导入 Bash +====== + +> source 就像 Python 的 import 或者 Java 的 include。学习它来扩展你的 Bash 能力。 + +![](https://img.linux.net.cn/data/attachment/album/202006/24/235417tbzjpdbpbzkbjeul.jpg) + +登录 Linux shell 时,你将继承特定的工作环境。对于 shell 而言,“环境environment”意味着已经为你设置了某些变量,以确保你的命令可以按预期工作。例如,[PATH][2] 环境变量定义 shell 从哪里查找命令。没有它,几乎在 Bash 中尝试执行的所有操作都会因“命令未发现” 错误而失败。在执行日常任务时,环境对你几乎是不可见的,但它很重要。 + +有多种方法可以影响你的 shell 环境。你可以在配置文件中进行修改,例如 `~/.bashrc` 和 `~/.profile`,你可以在启动时运行服务,还可以创建自己的自定义命令或编写自己的 [Bash 函数][3] 。 + +### 通过 source 添加到你的环境 + +Bash(以及其他一些 shell)有一个称为 `source` 的内置命令。这就是令人困惑的地方:`source` 执行与命令 `.` 相同的功能(是的,那只是一个点),而与 `Tcl` 命令的 `source` 不是同一个(如果你输入 `man source`,也许在屏幕上显示的是它)。实际上,内置的 `source` 命令根本不在你的 `PATH` 中。这是 Bash 附带的命令,要获取有关它的更多信息,可以输入 `help source`。 + +`.` 命令兼容 [POSIX][4]。 但 `source` 命令不是 POSIX 定义的,但可以与 `.` 命令互换使用。 + +根据 Bash `help`,`source` 命令在你当前的 shell 中执行一个文件。 “在你当前的 shell 中” 这句很重要,因为它表示它不会启动子 shell。因此,用 `source` 执行的任何操作都发生在内部并影响*当前*环境。 + +在探讨 `source` 对环境的影响之前,请用 `source` 命令导入一个测试文件,以确保其按预期执行代码。首先,创建一个简单的 Bash 脚本并将其保存为 `hello.sh`: + +``` +#!/usr/bin/env bash +echo "hello world" +``` + +使用 `source`,即使该脚本不设置可执行也可以运行: + +``` +$ source hello.sh +hello world +``` + +你也可以使用内置的 `.` 命令获得相同的结果: + +``` +$ . hello.sh +hello world +``` + +`source` 和 `.` 命令成功地执行了测试文件的内容。 + +### 设置变量和导入函数 + + 你可以使用 `source` 将文件 “导入” 到 shell 环境中,就像你可以在 C 或 C++ 中使用 `include` 关键字引用一个库,或者在 Python 中使用 `import` 关键字引入一个模块一样。这是 `source` 的最常见用法之一,它也是 `.bashrc` 中的一个默认包含方式,通过 `source` 导入 `.bash_aliases`,以便将任何你自定义的别名在登录时导入到你的环境。 + +这是导入 Bash 函数的示例。首先,在名为 `myfunctions` 的文件中创建一个函数。它将打印你的公共 IP 地址和本地 IP 地址: + +``` +function myip() { +        curl       + +        ip addr | grep inet$IP | \ +        cut -d"/" -f 1 | \ +        grep -v 127\\.0 | \ +        grep -v \:\:1 | \ +        awk '{$1=$1};1' +} +``` + +将该函数导入你的 shell: + +``` +$ source myfunctions +``` + +测试新函数: + +``` +$ myip +93.184.216.34 +inet 192.168.0.23 +inet6 fbd4:e85f:49c:2121:ce12:ef79:0e77:59d1 +inet 10.8.42.38 +``` + +### source 的搜索 + +当你在 Bash 中使用 `source` 时,它将在当前目录中搜索你引用的文件。但并非所有 shell 都这样,因此,如果你不使用 Bash,请查看文档。 + +如果 Bash 找不到要执行的文件,它将搜索你的 `PATH`。同样,这并不是所有 shell 的默认设置,因此,如果你不使用 Bash,请查看文档。 + +这些都是 Bash 中不错的便利功能。这种出奇地强大,因为它允许你将常用函数保存在磁盘上的一个集中的位置,然后将你的环境视为集成开发环境 (IDE)。你不必担心函数的存储位置,因为你知道它们在你的本地位置等同于在 `/usr/include` 下,因此无论你在哪,当你导入它们时,Bash 都可以找到它们。 + +例如,你可以创建一个名为 `~/.local/include` 的目录作为常见函数存储区,然后将此代码块放入 `.bashrc` 文件中: + +``` +for i in $HOME/.local/include/*; +  do source $i +done +``` + +这会将 `~/.local/include` 中所有包含自定义函数的文件“导入”到 shell 环境中。 + +当你使用 `source` 或 `.` 命令时,Bash 是唯一搜索当前目录和 `PATH` 的 shell。 + +### 将 source 用于开源 + +使用 `source` 或 `.` 来执行文件是影响环境同时保持变更模块化的一种便捷方法。在下次考虑将大量代码复制并粘贴到 `.bashrc` 文件中时,请考虑将相关函数或别名组放入专用文件中,然后使用 `source` 导入它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/bash-source-command + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bash_command_line.png?itok=k4z94W2U (bash logo on green background) +[2]: https://opensource.com/article/17/6/set-path-linux +[3]: https://opensource.com/article/20/6/how-write-functions-bash +[4]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains diff --git a/published/202006/20200615 How to use Bash history commands.md b/published/202006/20200615 How to use Bash history commands.md new file mode 100644 index 0000000000..f410a9ff13 --- /dev/null +++ b/published/202006/20200615 How to use Bash history commands.md @@ -0,0 +1,154 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12344-1.html) +[#]: subject: (How to use Bash history commands) +[#]: via: (https://opensource.com/article/20/6/bash-history-commands) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +如何使用 Bash history 命令 +====== + +> Bash 的 history 命令在它提供的功能数量上超过了所有其他 Linux Shell 历史接口。 + +![](https://img.linux.net.cn/data/attachment/album/202006/24/101620c0uj0dgg0buo9nib.jpg) + +Bash 有丰富的历史。也就是说,它是一个古老的的 shell,还有一个更古老的 Shell (Bourne shell)的前辈,但是它还有一个很棒的 `history` 命令,它提供的功能数量超过了所有其他 shell 的历史接口。 [Bash][2] 版本的 `history` 可进行反向搜索、快速调用、重写历史记录等。 + +`history` 命令与许多其他命令不同。你可能习惯于将命令作为可执行文件放在常见的系统级位置,例如 `/usr/bin`、`/usr/local/bin` 或者 `~/bin`。 内置的 `history` 命令不在你的 `PATH` 中并且没有物理位置: + + +``` +$ which history + +which: no history in [PATH] +``` + +相反,`history` 是 shell 本身的内置函数: + +``` +$ type history +history is a shell builtin +$ help history +history: history [-c] [-d offset] [n] or +history -anrw [filename] or +history -ps arg [arg...] + +Display or manipulate the history list. +[...] +``` + +出于这个原因,每个 shell 中的历史功能都是独特的,因此你在 Bash 中使用的功能可能无法在 Tcsh 或 Fish 或 Dash 中使用,而在这些 shell 中使用的功能可能也无法在 Bash 中使用。在某些情况下,了解 Bash 可以做什么可能会激发其他 shell 的用户创建有趣的改造来复制 Bash 行为,并且可能会解锁你从未知道的 Bash 功能。 + +### 查看你的 Bash 历史 + +`history` 命令最基本、最频繁的用法是查看 shell 会话的历史记录: + + +``` +$ echo "hello" +hello +$ echo "world" +world +$ history +  1  echo "hello" +  2  echo "world" +  3  history +``` + +### 事件指示器 + +事件指示器Event designator按事件搜索你的历史记录。在这里,“事件”是指记录在历史中的命令,以换行符划定。换句话说,一行一个事件,以索引号来标记。 + +事件指示器大多以感叹号开头,有时也称为 “bang”(`!`)。 + +要从你的历史记录中重新运行命令,请使用感叹号,之后紧跟(之间没有空格)所需命令的索引号。例如,假设第 1 行包含命令 `echo "hello"`,你想要想再次运行它: + + +``` +$ !1 +echo "hello" +hello +``` + +你可以使用相对定位,提供基于你历史中当前位置向后的负数行号。例如,返回到历史中倒数第三个条目: + +``` +$ echo "foo" +foo +$ echo "bar" +bar +$ echo "baz" +baz +$ !-3 +echo "foo" +foo +``` + +如果只想回去一行,那么可以使用速记 `!!` 代替 `!-1`。这节省了按键时间! + +``` +$ echo "foo" +$ !! +echo "foo" +foo +``` + +### 字符串搜索 + +你也可以对条目搜索特定的字符串,反过来搜索要运行命令。要搜索以指定字符串*开始*的命令,请使用感叹号,之后紧跟(没有空格)要搜索的字符串: + +``` +$ echo "foo" +$ true +$ false +$ !echo +echo "foo" +foo +``` + +你还可以在任意位置(不仅是开头)搜索包含该字符串的命令。为此,请像之前一样使用 `!` 加上要搜索的字符串,但在字符串的两端都用问号(`?`)围绕起来。如果你知道该字符串后紧跟一个换行符,那么可以省略最后的问号(就是在按*回车*之前输入的最后字符): + +``` +$ echo "foo" +$ true +$ false +$ !?foo? +echo "foo" +foo +``` + +### 字符串替换 + +类似于在行首搜索字符串,你可以搜索字符串并用新字符串替换它,以更改命令: + +``` +$ echo "hello" +hello +$ echo "world" +world +$ ^hello^foo +echo "foo" +foo +``` + +### 让 history 有用 + +在 Bash 中,`history` 命令的功能远远超过此处介绍的内容,但这是一个很好的开始, 可以让你习惯使用你的历史记录, 而不是仅仅把它当作一个参考。经常使用 `history` 命令,并试试无需输入命令即可执行的操作。你可能会感到惊讶! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/bash-history-commands + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/1980s-computer-yearbook.png?itok=eGOYEKK- (Person typing on a 1980's computer) +[2]: https://opensource.com/resources/what-bash diff --git a/published/202006/20200615 Introduction to Homebrew- the painless way to install anything on a Mac.md b/published/202006/20200615 Introduction to Homebrew- the painless way to install anything on a Mac.md new file mode 100644 index 0000000000..7253cba52c --- /dev/null +++ b/published/202006/20200615 Introduction to Homebrew- the painless way to install anything on a Mac.md @@ -0,0 +1,221 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12338-1.html) +[#]: subject: (Introduction to Homebrew: the painless way to install anything on a Mac) +[#]: via: (https://opensource.com/article/20/6/homebrew-mac) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) + + +Homebrew :在 Mac 上无痛安装软件 +====== + +> Homebrew 软件包管理器可以让你轻松地在 Mac 上安装和更新应用程序和实用程序。 + +![](https://img.linux.net.cn/data/attachment/album/202006/22/102739xum6zqmoh6sso0n6.jpg) + +在我追求“万物自动化”的过程中,我一直坚持走在用代码来管理我的 Mac 笔记本电脑的路上。与其用鼠标或触控板手动管理我的应用程序和实用程序,我更喜欢使用软件包管理软件来安装、更新和删除不需要的软件。 + +这对 Mac 用户来说是个挑战。Mac 的操作系统 macOS 始终落后于 Linux 的一个地方就是在包管理方面。Mac 用户没有默认的软件包管理器,而 Linux 用户则有很多选择 —— 从熟悉的 `yum` 和 `apt` 到现代的 [Flatpak][2]。但 Mac 呢? + +这就是 [Homebrew][3] 的作用。Homebrew(自酿)填补了 MacOS 事实上的软件包管理器的空白(它也是 Linux 上的又一个可选的包管理器)。它为任何熟悉命令行的人提供了令人难以置信的流畅而直接的体验,如果你是新手,它是学习命令行的好方法。 + +(LCTT 译注:Homebrew 系统中采用了大量针对自酿啤酒相关的比喻,大家在使用过程中会发现这些有趣的形容。) + +如果你在 Mac 上还没有 Homebrew,你可以这样来安装: + +``` +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" +``` + +该命令将执行 Homebrew 团队提供的安装程序脚本。如果你喜欢谨慎一点,可以 `curl` 下来这个文件,审核后再手动运行。 + +``` +$ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh --output homebrew_installer.sh +$ more homebrew_installer.sh # 审核该脚本,直到你觉得没问题了 +$ bash homebrew_installer.sh +``` + +### 使用“酿造”来管理你的命令行实用程序 + +Homebrew 号称它“可以安装苹果(或你的 Linux 系统)默认没有安装的必需之物”。安装是通过 `brew`(酿造)命令进行的,它使我们能够访问成千上万的命令行实用程序,但不是更复杂的应用程序。 + +对于我们这些搞技术的人来说,符合“必需之物”类别的实用工具包括显示目录结构的方便的 `tree` 命令和我用来 [管理多个 Python 版本][4] 的 `pyenv`。 + +你可以用 `search` 子命令看到 Homebrew 中所有的“秘方formula”,我用 `wc` 命令显示有多少个“秘方”。 + +``` +# -l 统计行数 +$ brew search | wc -l +    5013 +``` + +有 5000 多个“秘方”,这是一个不可思议的软件数量。所以,在搜索那个庞大的清单之前,最好先对自己想要的东西有个概念。值得庆幸的是,浏览起来很方便。“秘方”被编入并集中存储到核心库中,核心库按操作系统划分(Mac 在 [Homebrew Core][5],Linux 在 [Linux Core][6])。它们也可以通过 Homebrew API 和[网站][7]列出。 + +口碑是另一个寻找实用工具的好方法。考虑到这一点,如果你正在寻找灵感,这里有一些我的最爱: + +* `pyenv`、`rbenv` 和 `nodenv` 分别用于管理 Python、Ruby 和 Node.js 的版本 +* `imagemagick` 用于可脚本化的图像编辑 +* `pandoc` 用于可脚本化的文件转换(我经常从 .docx 切换到 .md 或 .html) +* `hub` 为 GitHub 用户提供了[更好的 Git 体验][8]。 +* `tldr` 提供了解如何使用命令行工具的例子 + +举个例子,看看 [tldr 页面][9],这是一个用户友好的替代方式,可以滚动浏览应用程序的手册页。你可以通过再次运行 `search` 来确认它是否可用: + +``` +$ brew search tldr +==> Formulae +tldr ✔ +``` + +成功了!这个对勾让你知道它是可用的。现在你可以安装它了: + +``` +$ brew install tldr +==> Downloading https://homebrew.bintray.com/bottles/tldr-1.3.0_2.catalina.bottle.tar.gz +Already downloaded: /Users/mbbroberg/Library/Caches/Homebrew/downloads/901bc14594a9283e9ab20aec942dc5a9a2befb7e96e1b0fcccb4e3257918813c--tldr-1.3.0_2.catalina.bottle.tar.gz +==> Installing tldr +==> Pouring tldr-1.3.0_2.catalina.bottle.tar.gz +🍺 /usr/local/Cellar/tldr/1.3.0_2: 6 files, 35.5KB +``` + +值得庆幸的是,Homebrew 预先构建了二进制文件,所以你不必在本地机器上从源代码构建。这样就节省了很多时间,并免除了 CPU 风扇的噪音。我对 Homebrew 赞赏的另一件事是,你可以在不完全了解其含义的情况下欣赏此功能。 + +但如果你喜欢,看看复杂的东西也是很有趣的。对 `tldr` 运行 `info` 子命令,你可以看到所有的依赖管理、源代码,甚至公共分析。 + +``` +$ brew info tldr +tldr: stable 1.3.0 (bottled), HEAD +Simplified and community-driven man pages +https://tldr.sh/ +Conflicts with: + tealdeer (because both install `tldr` binaries) +/usr/local/Cellar/tldr/1.3.0_2 (6 files, 35.5KB) * + Poured from bottle on 2020-05-20 at 15:12:12 +From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/tldr.rb +==> Dependencies +Build: pkg-config ✔ +Required: libzip ✔ +==> Options +--HEAD + Install HEAD version +==> Analytics +install: 2,811 (30 days), 7,875 (90 days), 27,105 (365 days) +install-on-request: 2,806 (30 days), 7,860 (90 days), 27,080 (365 days) +build-error: 0 (30 days) +``` + +最后,和其他优秀的软件包管理器一样,Homebrew 的 `brew uninstall` 子命令可用于快速清理和删除未使用的实用程序。 + +### 用“酒桶”管理你的应用程序 + +命令行实用程序是一匹孤狼,但完整的应用程序呢?Homebrew 保持了其标准命令的简单性,只通过其默认的 `brew` 命令行界面安装单文件应用。而应用程序不符合这种结构。它们的目录层次比较复杂,比单一的二进制要复杂得多。 + +幸运的是,Mac 上的 Homebrew 包含了一个名为 `cask`(酒桶)的子命令,用于处理更复杂的多目录结构。特别好的是,`cask` 使用了与标准 `brew` 命令类似的命令结构,所以你可以使用类似的 `search`、`install` 和 `info` 子命令: + +``` +brew search --cask | wc -l +    4772 +``` + +哇,有近 5000 个应用程序,在 [Homebrew 的网站][10]上浏览更方便。 + +我将用我新喜欢的一款应用来引导你完成 `cask`。[Meld][11](我[在 Opensource.com 上读到的][12])。这是一个功能丰富的编辑器,可以帮助管理合并冲突。在它的网站上有下载的链接,我可以运行安装程序,并将其拖放到我的应用程序文件夹中。但我不想再这样做了,我用的是 Homebrew。 + +首先,我可以通过稍微不同的语法确认它可以使用: + +``` +$ brew search --casks meld +==> Casks +meld +``` + +然后我使用 `cask` 子命令来安装它: + +``` +$ brew cask install meld +==> Downloading https://github.com/yousseb/meld/releases/download/osx-19/meldmerge.dmg +==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/28624006/66cb25 +######################################################################## 100.0% +==> Verifying SHA-256 checksum for Cask 'meld'. +==> Installing Cask meld +==> Moving App 'Meld.app' to '/Applications/Meld.app'. +==> Linking Binary 'meld.wrapper.sh' to '/usr/local/bin/meld'. +🍺 meld was successfully installed! +``` + +Homebrew 不仅安装了应用程序,而且还在我当前的路径 `/usr/local/bin/` 下提供了它。现在,我可以从命令行运行 `meld` 或从应用程序文件夹中启动应用程序。 + +### 更新一切的“酿造升级” + +我一直使用软件包管理器的主要原因是,我可以不断升级我的软件,以避免已知的安全漏洞,并确保我总是有最新的功能。如果我手工安装所有的东西,我必须关注每一个工具和应用程序,以了解它是否有自动更新程序,如果没有,就得自己拉回最新的版本。 + +升级功能是优秀的软件包管理的闪光点。由于我没有什么特殊的版本要求,所以我只需要运行一个命令就可以顺利更新一切: + +``` +$ brew upgrade +==> Upgrading 6 outdated packages: +helm 3.2.1 -> 3.2.2 +python@3.8 3.8.2_4 -> 3.8.3 +ipython 7.14.0 -> 7.15.0 +go 1.14.2_1 -> 1.14.3 +libzip 1.6.1 -> 1.6.1_1 +sqlite 3.31.1 -> 3.32.1 +``` + +如果你有更复杂的需求,或者想在安装升级前关注一下升级情况,有很多功能标志可供选择。例如,`-n` 提供了一个 “模拟运行”,列出了可用的升级,而不会进行安装。你也可以 “[钉][13]” 住应用程序版本来防止它升级。 + +### 备份你的安装 + +当该工具允许你像其它[点文件的版本控制方案][14]一样备份你的安装环境时,命令行实用程序和应用程序的管理就跳到了一个全新的水平。Homebrew 就有这样的功能,可以在 `dump` 子命令下使用。它会生成一个 `Brewfile`,这是一个可重复使用的当前所有安装的工具的列表。要从你的安装的环境中生成一个,进入你的合适的文件夹并运行: + +``` +$ cd ~/Development/dotfiles # 这是我的点文件的文件夹 +$ brew bundle dump +``` + +当我换了机器,想用 Homebrew 安装相同的应用程序时,我就会进入装有 `Brewfile` 的文件夹并运行。 + +``` +$ brew bundle +``` + +它将在我的新机器上安装所有列出的“秘方”和“酒桶”。 + +### 用 Homebrew 进行软件包管理 + +Homebrew 是我常用的命令行工具和应用程序的管理器。它可以让我保持有条理和及时更新,它的设计在易用性和功能深度之间取得了美丽的平衡。Homebrew 将软件包管理的细节最小化到只需要你知道的程度,大多数用户都会从中受益。 + +如果你对 Linux 软件包管理器已经驾轻就熟,你可能会认为 Homebrew 太简单了,但不要误以为 Homebrew 的易用性是功能的缺乏。稍微深入一点看,就会发现很多高级选项,远远超出了我在这里向你展示的范围。将 `-h` 添加到任何 `brew` 子命令中,会显示可用来升级、删除、故障排除,甚至使用模板贡献新 “秘方” 的丰富功能。 + +总的来说,Homebrew 可以让一个重度命令行的 Mac 用户变得很开心。此外,它是开源的,所以如果你愿意,你可以[贡献代码][15]。尝试一下它,让我知道你的想法,在下面留下评论。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/homebrew-mac + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1 (Gift box opens with colors coming out) +[2]: https://opensource.com/article/19/10/how-build-flatpak-packaging +[3]: https://brew.sh +[4]: https://opensource.com/article/20/4/pyenv +[5]: https://github.com/Homebrew/homebrew-core +[6]: https://github.com/Homebrew/linuxbrew-core +[7]: https://formulae.brew.sh/formula/ +[8]: https://opensource.com/article/20/3/github-hub +[9]: https://github.com/tldr-pages/tldr +[10]: https://formulae.brew.sh/cask/ +[11]: https://meldmerge.org/ +[12]: https://opensource.com/article/20/3/meld +[13]: https://docs.brew.sh/FAQ#how-do-i-stop-certain-formulae-from-being-updated +[14]: https://opensource.com/article/19/3/move-your-dotfiles-version-control +[15]: https://github.com/Homebrew/brew diff --git a/published/202006/20200619 How to dump the GOSSAFUNC graph for a method.md b/published/202006/20200619 How to dump the GOSSAFUNC graph for a method.md new file mode 100644 index 0000000000..36c75fc7af --- /dev/null +++ b/published/202006/20200619 How to dump the GOSSAFUNC graph for a method.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12350-1.html) +[#]: subject: (How to dump the GOSSAFUNC graph for a method) +[#]: via: (https://dave.cheney.net/2020/06/19/how-to-dump-the-gossafunc-graph-for-a-method) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +在 Go 中如何转储一个方法的 GOSSAFUNC 图 +====== + +![](https://img.linux.net.cn/data/attachment/album/202006/26/083943vymvmc67p7s3oman.jpg) + +Go 编译器的 SSA 后端包含一种工具,可以生成编译阶段的 HTML 调试输出。这篇文章介绍了如何为函数*和*方法打印 SSA 输出。 + +让我们从一个包含函数、值方法和指针方法的示例程序开始: + +``` +package main + +import ( + "fmt" +) + +type Numbers struct { + vals []int +} + +func (n *Numbers) Add(v int) { + n.vals = append(n.vals, v) +} + +func (n Numbers) Average() float64 { + sum := 0.0 + for _, num := range n.vals { + sum += float64(num) + } + return sum / float64(len(n.vals)) +} + + +func main() { + var numbers Numbers + numbers.Add(200) + numbers.Add(43) + numbers.Add(-6) + fmt.Println(numbers.Average()) +} +``` + +通过 `GOSSAFUNC` 环境变量控制 SSA 调试输出。此变量含有要转储的函数的名称。这*不是*函数的完全限定名。对于上面的 `func main`,函数名称为 `main` *而不是* `main.main`。 + +``` +% env GOSSAFUNC=main go build +runtime +dumped SSA to ../../go/src/runtime/ssa.html +t +dumped SSA to ./ssa.html +``` + +在这个例子中,`GOSSAFUNC=main` 同时匹配了 `main.main` 和一个名为 `runtime.main` 的函数。[^1]这有点不走运,但是实际上可能没什么大不了的,因为如果你要对代码进行性能调整,它就不会出现在 `func main` 中的巨大的意大利面块中。 + +你的代码更有可能在*方法*中,你可能已经看到这篇文章,并寻找能够转储方法的 SSA 输出。 + +要为指针方法 `func (n *Numbers) Add` 打印 SSA 调试,等效函数名为 `(*Numbers).Add`:[^2] + +``` +% env "GOSSAFUNC=(*Numbers).Add" go build +t +dumped SSA to ./ssa.html +``` + +要为值方法 `func (n Numbers) Average` 打印 SSA 调试,等效函数名为 `(*Numbers).Average`,*即使这是一个值方法*: + +``` +% env "GOSSAFUNC=(*Numbers).Average" go build +t +dumped SSA to ./ssa.html +``` + +[^1]: 如果你没有从源码构建 Go,那么 `runtime` 软件包的路径可能是只读的,并且可能会收到错误消息。请不要使用 `sudo` 来解决此问题。 +[^2]: 请注意 shell 引用 + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2020/06/19/how-to-dump-the-gossafunc-graph-for-a-method + +作者:[Dave Cheney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 + diff --git a/published/202006/20200621 How to Make Ubuntu Look Like macOS in 5 Easy Steps.md b/published/202006/20200621 How to Make Ubuntu Look Like macOS in 5 Easy Steps.md new file mode 100644 index 0000000000..9d5d5f7cf6 --- /dev/null +++ b/published/202006/20200621 How to Make Ubuntu Look Like macOS in 5 Easy Steps.md @@ -0,0 +1,240 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12361-1.html) +[#]: subject: (How to Make Ubuntu Look Like macOS in 5 Easy Steps) +[#]: via: (https://itsfoss.com/make-ubuntu-look-like-macos/) +[#]: author: (Community https://itsfoss.com/author/itsfoss/) + +5 个简单步骤使你的 Ubuntu 看起来像 macOS +====== + +定制是 [我为什么使用 Linux][1] 的一个主要原因。定制桌面 Linux 的道路是永无止境的。你可以更改图标、主题、字体、终端、添加屏幕小工具、[指示器小程序][2]、扩展等诸如此类的东西。 + +我们已经介绍了很多桌面环境定制的建议和技巧。在这篇文章中,我将向你展示如何使 Ubuntu 看起来像 macOS。 + +很多人使用 macOS,是因为它的简单和优雅的外观。你可能不同意这一点,但这仍然是一个流行的观点。甚至有的 Linux 发行版也有类似 macOS 外观和感觉。 + +一位读者要求我们展示如何使 Ubuntu 看起来像 macOS,因此我们写了这篇教程。事实上,这是一个用来展示桌面 Linux 定制能力的很好的示例。 + +不过,你没有必要为定制外观而安装一个新的发行版。你可以在你自己的系统上做一些调整来给予你一个类似 macOS 的外观。 + +### 如何给你的 Ubuntu Linux 进行 macOS 改造 + +![][3] + +尽管这篇文章是对 Ubuntu 的建议,但是你也可以在其它使用 GNOME 桌面环境的发行版中使用这些建议,几乎可以不做任何改动。请确保[检查一下你的桌面环境][4]。 + +说实话,即使你使用的是其它的桌面环境,你仍然可以得到一些关于要做哪些更改的提示。但是你必须确保使用你的桌面环境的工具按照步骤进行。 + +#### 必要条件: GNOME Tweaks 和 GNOME 扩展 + +请确保 [安装 GNOME Tweaks 工具][5]。你需要它来更改主题和图标。 + +你也需要 [启用 GNOME 扩展][6] 来更改 GNOME Shell 和添加重要的要点。 + +在你启用 GNOME 扩展后,你需要从 [GNOME 扩展][7] 网站安装“用户主题” 扩展,或者只需要转到 [这个超链接][8] ,并单击开关来将其打开。 + +我也希望你对 [在 Ubuntu 上安装主题][9] 有一定的了解。不过,我还是简单的谈了一下这个主题。 + +让我们依次看看每个步骤。 + +#### 步骤 1: 安装一个 macOS 风格的 GTK 主题 + +因为重点是使 GNOME 看起来像 macOS,所以你应该选择一个像 macOS 一样的主题。有很多主题都是像 macOS 一样的。 + +##### 下载一个你选择的主题 + +你可以转到 [Gnome-look][10] 站点,并搜索关于 GTK3 的主题。如果你在 Gnome-look 网站上看到 “Pling” 字样,不用担心,它们都是来自同一个供应商。 + +你可以选择任何你想要的主题。下面是一些我认为你应该看看的macOS主题: + +- [mcOS 11][11] +- [McHigh Sierra][12] +- [Catalina][13] +- [McMojave][14] + +在这篇文章中,我将使用 “[McMojave][14]”。你可以选择任何你想要的主题。你将在网站的右侧找到下拉式的下载按钮,单击它。 + +![McMojave 暗黑主题][15] + +在这里你可以找到各种 “.tar.xz” 文件。这些不同的文件包含了相同的主题,但有一些小的差异。像在 “McMojave” 中,我们有像暗黑主题和明亮主题的变体。你可以尝试所有的主题,或者从之间随意选择一个你喜欢的。 + +##### 设置下载的主题 + +提取下载的主题,并复制这些提取的主题文件夹到 `.local/share/themes` 文件夹下。 + +打开 GNOME Tweak 工具,并更改应用程序和 Shell 的主题。在你更改主题的同时,你可以看到黄色、绿色和红色三个按钮,以及左上角的苹果标志。你也可以看到在面板项上的一些更改。 + +![McMojave GTK 和 Shell 主题][16] + +#### 步骤 2: 安装像 macOS 一样的图标 + +macOS 外观改造的下一步骤是使用像 macOS 一样的图标。 + +##### 下载图标集合 + +这里有一些我建议使用的图标集合,你可以从 Gnome-look 网站下载: + +- [McMojave-circle][17] +- [Mojave CT-icons][18] +- [Cupertino icons][19] + +在这篇文章中,我将使用 “[McMojave-circle][17]” ,你可以随意使用任何你喜欢的图标。 + +就像主题一样,你可以从右侧的下拉式的 “下载” 按钮下载图标集合。在这里你也可以找到同一种图标的不同版本。 + +![Mcmojave Circle][20] + +##### 设置图标 + +现在设置下载的图标。为此,提取下载文件中的文件夹并复制它到你的家目录下的 `.icons` 文件夹。 查看这篇关于 [在 Ubuntu 中安装图标主题][9] 的文章。 + +这是这种图标看起来的样子: + +![McMojave Circle 图标外观][21] + +#### 步骤 3: 添加类似 macOS 样子的坞站 + +没有类似 macOS 样子的坞站dock,你的 Ubuntu 就看起来不像 macOS。在 Linux 上有很多可用的坞站。我喜欢 “[Dash to Dock][22]”,我会在这里使用它。 + +“Dash to Dock” 是一个 GNOME 扩展。到现在为止,你已经熟悉 GNOME 扩展。只需要转到 [这个超链接][23] ,并单击切换按钮来安装它。你的原本的坞站将自动被 “Dash to Dock” 所替换。 + +你可以通过右键单击 “show applications” 按钮(最右边的菜单按钮)并选择 “Dash to dock settings” 来更改设置。 + +![Dash To Dock][24] + +#### 步骤 4: 使用 macOS 壁纸 + +大多数复杂的东西已经完成。现在是时候设置 macOS 壁纸了。你可以从下面的超链接下载 macOS 默认壁纸: + +- [下载 macOS 壁纸][25] + +##### 更改桌面背景 + +我将使用 “Mojave Day” 壁纸。右键单击已下载的的图像,并选择 “设置为壁纸” 选项来更改壁纸。 + +在设置这个壁纸后,这是我系统外观的样子: + +![][26] + +##### 更改锁屏壁纸 + +锁屏壁纸选项已经从 [Ubuntu 20.04][27] 的设置中移除。现在它使用一个模糊的桌面壁纸作为锁屏壁纸。 + +要设置一个自定义锁屏壁纸,你可以使用 “[Lock screen background][28]” 扩展。 + +打开 “Lock screen background” 扩展设置,并设置锁屏壁纸。 + +![锁屏背景设置][29] + +这是锁屏现在的样子。如果你感到好奇话,这里是 [如何在 Ubuntu 中截图锁屏][30]。 + +![锁屏][31] + +![登录屏幕][32] + +#### 步骤 5: 更改系统字体 + +这几年,macOS 的主要系统字体是 “San Francisco” 。但是,这个字体并不是公共领域的,而是像苹果生态系统中的许多其他东西一样,是专有字体。基于这个原因,你不能使用这种字体。 + +你能做的就是使用一种看起来像 San Francisc 字体一样的开源字体。我建议使用 Google 的 [Roboto][33] 字体,或 Adobe 的 [Source Sans Pro][34] 。 + +[在 Ubuntu 中安装字体是很简单的][35] 。下载 字体的 zip 文件,只需要在提取出来的文件夹中双击 ttf 文件。它会给你一个选项来逐一安装字体。 + +如果你想节省时间并一次安装所有的字体,提取其中所有的字体到你的家目录(`~/.fonts`)下的 `.fonts` 目录中。 + +![安装字体][36] + +在你安装字体后,你可以使用 GNOME Tweaks 工具来更改系统字体。 + +![设置字体][37] + +#### 额外提示:Spotlight 式的应用程序启动器(如果你像更进一步的话) + +如果你是 macOS Spotlight 启动器的粉丝,那么你在 Linux 上也能找到类似的东西。我最喜欢的这类启动器的软件包是 “[Albert][38]”。 + +你可以 [在 Albert 网站上找到它的安装说明][39] 。 + +安装完成后,打开 Albert 并设置快捷键(你想打开该启动器的组合键)就可以了。我想,在 macOS 中 `Command + Space` 键是来启动 Spotlight;在 Ubuntu 中,你可以设置 `Super+Space` [快捷键][40]。 + +你会会得到很多内置的主题,在下面的图片中,我使用 “Spotlight dark” 主题。 + +Albert 不能直接启动应用程序,你必须授予它在哪里可以进行搜索的权限。 + +![Albert 设置][41] + +在设置后,这是它看起来的样子: + +![Albert 暗黑主题][42] + +这是我的 Ubuntu 20.04 在完成所有定制后的样子。它看起来像 macOS 吗? 仁者见仁,智者见智。 + +![macOS 主题][43] + +![Ubuntu 使用 macOS 外观改造][44] + +如此,这就是你如何使你的 GNOME 桌面看起来像 macOS 一样的步骤。正如我在开始时所说的,这是一个很好的 Linux 桌面定制功能的示例。 + +如果你有新的注意或有任何疑问;评论区全是你的地盘。 + +本文由 Sumeet 编写,并由 Abhishek Prakash 提供补充输入信息。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/make-ubuntu-look-like-macos/ + +作者:[Sumeet][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/itsfoss/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/why-use-linux/ +[2]: https://itsfoss.com/best-indicator-applets-ubuntu/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/Make-Ubuntu-Look-like-MacOS.png?ssl=1 +[4]: https://linux.cn/article-12124-1.html +[5]: https://itsfoss.com/gnome-tweak-tool/ +[6]: https://linux.cn/article-9447-1.html +[7]: https://extensions.gnome.org/ +[8]: https://extensions.gnome.org/extension/19/user-themes/ +[9]: https://itsfoss.com/install-themes-ubuntu/ +[10]: https://www.gnome-look.org/ +[11]: https://www.pling.com/p/1220826 +[12]: https://www.pling.com/p/1013714 +[13]: https://www.pling.com/p/1226871 +[14]: https://www.pling.com/p/1275087 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/McMojave-dark-theme.png?ssl=1 +[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/McMojave-Desktop.png?ssl=1 +[17]: https://www.gnome-look.org/p/1305429/ +[18]: https://www.gnome-look.org/p/1210856/ +[19]: https://www.gnome-look.org/p/1102582/ +[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/McMojave-circle-.png?ssl=1 +[21]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/McMojave-circle-icons-look.png?fit=800%2C494&ssl=1 +[22]: https://github.com/micheleg/dash-to-dock +[23]: https://extensions.gnome.org/extension/307/dash-to-dock/ +[24]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Dash-to-dock-1.png?ssl=1 +[25]: https://oswallpapers.com/category/mac-os/ +[26]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Wallpaper.png?fit=800%2C450&ssl=1 +[27]: https://itsfoss.com/ubuntu-20-04-release-features/ +[28]: https://extensions.gnome.org/extension/1476/unlock-dialog-background/ +[29]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/Lock-screen-background-setting.png?ssl=1 +[30]: https://itsfoss.com/screenshot-login-screen-ubuntu-linux/ +[31]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Lock-screen-1.png?ssl=1 +[32]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/Login-screen-1.png?ssl=1 +[33]: https://fonts.google.com/specimen/Roboto?query=robot +[34]: https://adobe-fonts.github.io/source-sans-pro/ +[35]: https://itsfoss.com/install-fonts-ubuntu/ +[36]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Fonts.png?ssl=1 +[37]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Set-fonts.png?ssl=1 +[38]: https://albertlauncher.github.io/ +[39]: https://albertlauncher.github.io/docs/installing/ +[40]: https://itsfoss.com/ubuntu-shortcuts/ +[41]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Albert-settings.png?ssl=1 +[42]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Albert-look.png?ssl=1 +[43]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/macOS-theme.png?fit=800%2C450&ssl=1 +[44]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/macOS-theme-2.png?fit=800%2C450&ssl=1 diff --git a/published/202006/20200623 Make the switch from Mac to Linux easier with Homebrew.md b/published/202006/20200623 Make the switch from Mac to Linux easier with Homebrew.md new file mode 100644 index 0000000000..f28c5fbf98 --- /dev/null +++ b/published/202006/20200623 Make the switch from Mac to Linux easier with Homebrew.md @@ -0,0 +1,263 @@ +[#]: collector: (lujun9972) +[#]: translator: (nophDog) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12358-1.html) +[#]: subject: (Make the switch from Mac to Linux easier with Homebrew) +[#]: via: (https://opensource.com/article/20/6/homebrew-linux) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) + +Homebrew 让你从 Mac 切换到 Linux 更轻松 +====== + +> 不管你是想要更舒服地从 Mac 搬到 Linux,还是不满意常规的 Linux 包管理器,都可以试试 Homebrew。 + +![](https://img.linux.net.cn/data/attachment/album/202006/28/091127an02f8oae0pln3as.jpg) + +[Homebrew][2] 项目最初是为了给 Mac 用户提供一个非官方的 Linux 式的包管理器。用户很快就爱上了它友好的界面以及帮助性的提示,而且,它已经被移植到 Linux 系统 —— 这看起来像是一个奇怪的命运转折。 + +一开始,有两个分开的项目分别针对 macOS 和 Linux (Homebrew 与 Linuxbrew),但是现在是由 Homebrew 核心管理着这两个操作系统。由于我正 [从 Mac 切换到 Linux][3],所以一直在研究我在 macOS 最常用的开源软件在 Linux 表现如何,最终,我很高兴地发现 Homebrew 对 Linux 的支持太赞了! + +### 为什么要在 Linux 使用 Homebrew 呢? + +长期使用 Linux 的用户对 Homebrew 的第一反应是:“为什么不直接使用……呢”,省略号代表他们喜欢的某个 Linux 包管理器。基于 Debian 的系统早就有了 `apt`,基于 Fedora 的系统则有 `dnf` 和 `yum`,并且像 Flatpak 跟 AppImage 这样的项目,在两种系统上都能流畅运行。我花了不少时间尝试这些技术,不得不说,它们都有其强大之处。 + +那我为什么还要 [坚持使用 Homebrew][4] 呢?首先,我对它非常熟悉。在为我过去使用的专有软件寻找开源替代品的过程中,我已经学会了许多使用方法,而保持一些熟悉的东西,比如 Homebrew,可以让我专注于一次学习一件事情,而不是被不同系统间的差异搞垮。 + +此外,我没有看到哪一个包管理器像 Homebrew 一样,对用户如此友好。正如默认的帮助命令一样,命令井然有序: + +``` +$ brew -h +Example usage: +  brew search [TEXT|/REGEX/] +  brew info [FORMULA...] +  brew install FORMULA... +  brew update +  brew upgrade [FORMULA...] +  brew uninstall FORMULA... +  brew list [FORMULA...] + +Troubleshooting: +  brew config +  brew doctor +  brew install --verbose --debug FORMULA + +Contributing: +  brew create [URL [--no-fetch]] +  brew edit [FORMULA...] + +Further help: +  brew commands +  brew help [COMMAND] +  man brew +  +``` + +过于简短的输出可能会被误解为它功能局限,但是你简单看看每一个子命令,都有很丰富的功能。虽然上面的列表只有短短 23 行,但对高级用户来说,光是子命令 `install` 就包含整整 79 行的帮助信息: + +``` +$ brew --help | wc -l +23 +$ brew install --help | wc -l +79 +``` + +它可以选择忽略或者安装依赖关系,也可以选择用源代码编译以及用什么编译器来编译某个确切的上游 Git 提交,或者选择应用的官方 “灌装” 版。总而言之,Homebrew 即适合新手,也同样能满足老鸟。 + +### 开始在 Linux 使用 Homebrew + +如果你想要试着使用 Homebrew,可以用这个单行脚本在 Mac 或者 Linux 上进行安装: + +``` +$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" +``` + +这条命令会立即开始安装 Homebrew。如果你比较谨慎,可以使用 `curl` 将该文件下载到本地,检查完毕之后再运行。 + +``` +$ curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh --output homebrew_installer.sh +$ more homebrew_installer.sh # 审核该脚本,直到你觉得没问题了 +$ bash homebrew_installer.sh +``` + +对 Linux 的安装步骤还包括如何配置点文件,对于 Debian 系统来说是 `~/.profile`,对于 Fedora 系统是 `~/.bash_profile`。 + +``` +$ test -d /home/linuxbrew/.linuxbrew && eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) +$ test -r ~/.bash_profile && echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.bash_profile +$ echo "eval \$($(brew --prefix)/bin/brew shellenv)" >>~/.profile +``` + +为了确认已经安装好,Homebrew 团队提供一个空的 `hello` “秘方” 供测试: + +``` +$ brew install hello +==> Downloading https://linuxbrew.bintray.com/bottles/hello-2.10.x86_64_linux.bottle.tar.gz +######################################################################## 100.0% +==> Pouring hello-2.10.x86_64_linux.bottle.tar.gz +🍺 /home/linuxbrew/.linuxbrew/Cellar/hello/2.10: 52 files, 595.6KB +``` + +看起来安装毫无问题,让我来试试更多操作。 + +### 命令行工具 Brew + +Homebrew 宣称自己是一款默认只 “安装你需要而 [Linux] 没有的东西”的应用程序。 + +你可以用 `brew` 命令安装任何打包在 Homebrew 中的命令行软件。这些包的定义文件叫做 “秘方formula”,而且它们通过“瓶子bottle”来编译并分享。在 Homebrew 的世界里,还有许多 “啤酒方面” 的术语,但这个包管理器主要目的是让软件便于使用。 + +都有些什么样的软件呢?对我这样的技术玩家(既然你已经在读这篇文章,估计你也是)来说最方便的东西。例如,便利的 `tree` 命令,可以展示目录结构,或者 `pyenv`,我用它来 [在 Mac 管理不同版本 Python][5]。 + +你可以用 `search` 命令查看所有可以安装的“秘方”,在后面加上 `wc` 命令看看一共有多少: + +``` +# -l 选项统计行数 +$ brew search | wc -l +    5087 +``` + +迄今为止,一共有 5000 多个 “秘方”,这囊括了很多软件。需要注意的是:并非所有 “秘方” 都能在 Linux 运行。在 `brew search --help` 输出中有一节提到可以按软件运行的操作系统来筛选软件。它会在浏览器打开用于每个操作系统的软件仓库。我运行的是 Fedora,所以我会用它来试一试: + +``` +$ brew search --fedora tree +``` + +浏览器打开了网址 `https://apps.fedoraproject.org/packages/s/tree`,向我展示了所有 Fedora 的可用选项。你也可以通过其它方法进行浏览。“秘方” 被集中整理到由操作系统划分的核心仓库当中(Mac 在 [Homebrew Core][6],Linux 在 [Linux Core][7])。同样也可以通过 Homebrew API [在网页显示][8]。 + +即使有这些选择,我还是通过其它用户的推荐找到很多新工具。我列出一些我最喜欢的工具,你可以在里面找点灵感: + + * `pyenv`、`rbenv` 和 `nodenv` 用来管理(相应的) Python、Ruby 和 Node.js 版本 + * `imagemagick` 用于脚本化编辑图片 + * `pandoc` 用于脚本化转换文档格式(我通常将 .docx 文件转成 .md 或者 .html) + * `hub` 为 GitHub 用户提供 [更好的 Git 体验][9] + * `tldr` 展示了命令工具的使用范例 + +想要深入了解 Homebrew,可以去 [trldr 页面][10] 看看,比起应用的 man 页面,它要友好得多。使用 `search` 命令确认你可以安装: + +``` +$ brew search tldr +==> Formulae +tldr ✔ +``` + +太好了!对勾说明你可以安装。那么继续吧: + +``` +$ brew install tldr +==> Downloading https://linuxbrew.bintray.com/bottles/tldr-1.3.0_2.x86_64_linux.bottle.1.tar.gz +######################################################################## 100.0% +==> Pouring tldr-1.3.0_2.x86_64_linux.bottle.1.tar.gz +🍺 /home/linuxbrew/.linuxbrew/Cellar/tldr/1.3.0_2: 6 files, 63.2KB +``` + +Homebrew 提供了编译好的二进制文件,所以你不必在本地机器上从源码编译。这能节省很多时间,也不用听 CPU 风扇的噪声。我很欣赏 Homebrew 的另外一点是,你不完全理解每一个选项的含义也不会影响正常使用。若你想自己编译,可以在 `brew install` 命令后面加上 `-s` 或者 `--build-from-source` 标识,这样就能从源码编译 “秘方”(即便已经有一个 “瓶子” 存在)。 + +同样,软件底层的复杂性也很有意思。使用 `info` 可以查看 `tldr` 软件的依赖管理,“秘方” 的源代码存放在磁盘上的何处,甚至还能查看公开分析。 + +``` +$ brew info tldr +tldr: stable 1.3.0 (bottled), HEAD +Simplified and community-driven man pages +https://tldr.sh/ +Conflicts with: + tealdeer (because both install `tldr` binaries) +/home/linuxbrew/.linuxbrew/Cellar/tldr/1.3.0_2 (6 files, 63.2KB) * + Poured from bottle on 2020-06-08 at 15:56:15 +From: https://github.com/Homebrew/linuxbrew-core/blob/master/Formula/tldr.rb +==> Dependencies +Build: pkg-config ✔ +Required: libzip ✔, curl ✔ +==> Options +--HEAD + Install HEAD version +==> Analytics +install: 197 (30 days), 647 (90 days), 1,546 (365 days) +install-on-request: 197 (30 days), 646 (90 days), 1,546 (365 days) +build-error: 0 (30 days) +``` + +### 从 Mac 到 Linux 的一点不足 + +在 macOS,Homebrew 的 `cask`(“酒桶”)子命令可以让用户使用命令行安装、管理整个应用软件。不幸的是,`cask` 还不能在任何 Linux 发行版上使用。我在安装一个开源工具时发现了这点: + +``` +$ brew cask install tusk +Error: Installing casks is supported only on macOS +``` + +我在 [论坛上][11] 问了一下,很快得到其他用户的反馈。总结一下,方案如下: + +* 复刻 Homebrew 项目,构建这个特性,然后像别人展示其价值 +* 给该软件写一个 “秘方”,然后从源代码编译 +* 为该软件创建一个第三方仓库 + +最后一个是我最感兴趣的。Homebrew 通过 [创建并维护 “水龙头tap”][12] (另一个受啤酒影响的术语)管理第三方仓库。随着你对系统越来越熟悉,并想加入生态系统, “水龙头” 是值得研究的。 + +### 备份 Homebrew 的安装记录 + +我最中意的 Homebrew 特性之一就是你可以像其它任何 [用版本控制工具来备份点文件][13] 一样备份你的安装记录。为了实现这个目的,Homebrew 提供 `bundle`(“捆扎”)子命令,它可以控制一个叫 `dump`(“倾倒”)的子命令生成一个 `Brewfile`。这个文件包含你目前所有安装的工具列表,可以重复使用。进入你想使用的目录然后运行命令,它会根据你所安装的软件生成 `Brewfile`: + +``` +$ cd ~/Development/dotfiles # This is my dotfile folder +$ brew bundle dump +$ ls Brewfile +Brewfile +``` + +当我换了一台机器,想要安装一样的软件时,进入含有 `Brewfile` 的文件夹,然后重新安装: + +``` +$ ls Brewfile +Brewfile +$ brew bundle +``` + +它会在我的新机器上安装所有列出的 “秘方”。 + +#### 在 Mac 和 Linux 同时管理 Brewfile + +`Brewfile` 非常适合备份你目前的安装记录,但是如果某些在 Mac 上运行的软件无法运行在 Linux 呢?或者刚好相反?我发现不管是 Mac 还是 Linux,如果软件无法在当前操作系统运行,Homebrew 会优雅地忽略那一行。如果它遇到不兼容的请求(比如使用 `brew` 在 Linux 安装 “酒桶cask” 时),它会选择跳过,继续安装过程: + +``` +$ brew bundle --file=Brewfile.example + +Skipping cask licecap (on Linux) +Skipping cask macdown (on Linux) +Installing fish +Homebrew Bundle complete! 1 Brewfile dependency now installed. +``` + +为了保持配置文件的简洁,我在两个操作系统上使用同一份 `Brewfile`,因为它只安装与操作系统相关的版本,所以我一直没有遇到任何问题。 + +### 使用 Homebrew 管理软件包 + +Homebrew 已经成了我必备的命令行工具,由于我很熟悉它,所以在 Linux 上的体验也充满乐趣。Homebrew 让我的工具井然有序,并且时刻保持更新,我愈发欣赏它在实用性与功能上找到的平衡点。我更喜欢将软件包管理的细节保持在用户需要了解的最小程度,大多数人都会从中受益。如果你已经很熟悉 Linux 包管理器了,Homebrew 可能会让你觉得很基础,但稍微深入一点看,就会发现它的高级选项远远超过本文的内容。 + +对 Linux 用户来说,他们有很多包管理器可以选择。如果你来自 MacOS,Homebrew 会让你宾至如归。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/homebrew-linux + +作者:[Matthew Broberg][a] +选题:[lujun9972][b] +译者:[nophDog](https://github.com/nophDog) +校对:[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/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop) +[2]: https://brew.sh/ +[3]: https://opensource.com/article/19/10/why-switch-mac-linux +[4]: https://opensource.com/article/20/6/homebrew-mac +[5]: https://opensource.com/article/20/4/pyenv +[6]: https://github.com/Homebrew/homebrew-core +[7]: https://github.com/Homebrew/linuxbrew-core +[8]: https://formulae.brew.sh/formula/ +[9]: https://opensource.com/article/20/3/github-hub +[10]: https://github.com/tldr-pages/tldr +[11]: https://discourse.brew.sh/t/add-linux-support-to-existing-cask/5766 +[12]: https://docs.brew.sh/How-to-Create-and-Maintain-a-Tap +[13]: https://opensource.com/article/19/3/move-your-dotfiles-version-control diff --git a/published/202006/20200624 Customize your Raspberry Pi operating system for everyday use.md b/published/202006/20200624 Customize your Raspberry Pi operating system for everyday use.md new file mode 100644 index 0000000000..52fc766db8 --- /dev/null +++ b/published/202006/20200624 Customize your Raspberry Pi operating system for everyday use.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12365-1.html) +[#]: subject: (Customize your Raspberry Pi operating system for everyday use) +[#]: via: (https://opensource.com/article/20/6/custom-raspberry-pi) +[#]: author: (Patrick H. Mullins https://opensource.com/users/pmullins) + +定制用于日常使用的树莓派系统 +====== + +> 安装精简版树莓派系统,让你的树莓派更加轻盈。 + +![](https://img.linux.net.cn/data/attachment/album/202006/30/133836pfm4u3sq073ffmbf.jpg) + +你有一个运行[树莓派系统][2]Raspberry Pi OS(以前称为 Raspbian)操作系统的树莓派Raspberry Pi,你肯定知道,它是一个非常棒的小型电脑,有一个很好的操作系统,对于初学者来说,它包括了你可能想要的一切。然而,一旦你熟悉了它,并且想用它干一些别的事情的时候,你可能不想要那个默认囊括了一切组件的操作系统。 + +在这种情况下,你两个选择:要么你可以绞尽脑汁地把所有你不需要的东西都删干净,要么你还可以用精简版树莓派系统Raspberry Pi OS Lite来构建专门为你的需求而定制的轻量级操作系统。我的建议是,用第二种方法,既简便又节省时间。 + +### Raspberry Pi OS Lite + +“精简版Lite”的树莓派系统Raspberry Pi OS其实没什么特别的,就是一个基于最新版本的 [Debian][3] 的最小化镜像。这个镜像仅包含了操作系统核心和启动到命令行的部分,而不会进入图形桌面。可以将这个作为你的定制树莓派系统的基础。这之后的所有东西都是建立在这个核心之上的。 + +前往树莓派基金会的网站上[下载][2]这个轻量级镜像。下载完成后,查看详细的[安装指南][4],这里面介绍了在 Linux、Windows 或者 macOS 下如何烧制树莓派操作系统的 SD 卡。 + +如果你计划用树莓派作为一个极简系统来运行一些脚本和服务的话,差不多这么多就够了。如果你还想干更多事,那继续往下读。 + +### X Window + +首先,如果偶尔需要通过图形用户界面(GUI)连接到你的树莓派,安装一个窗口系统还是不错的。 + +[X Window 系统][5],有时候称为 X11,是 Unix 操作系统上一个常见的基本窗口系统。X11 提供了一套 GUI 桌面环境的基本框架。它可以让你通过窗口、鼠标和键盘与计算机交互。 + +#### 安装 X Window + +下面这一行安装了能让 X11 运行的最少的包。 + +``` +sudo apt install -y --no-install-recommends xserver-xorg-core xserver-xorg xfonts-base xinit +``` + +如果使用 `--no-install-recommends`,则只安装了主要的一些依赖(`Depends` 字段中的包)。这样可以节省很多空间,因为没有安装那些建议却不一定需要的包。 + +### 进阶:使用 Xfce 桌面环境 + +如果你愿意,可以就此停下了,然后开始使用 X Window 作为你的桌面。不过,我并不建议这么做。X Window 自带的这种最小化的窗口管理工具走的是极简主义风格,某种程度上让人感觉过时了。相反,我建议安装现代化的桌面环境,比如说像 Xfce、GNOME 或者 KDE。当用在微型计算机上时,我更倾向于 [Xfce][6] 而不是其他的,因为它就是为资源有限的系统设计的,而且你可以通过主题、图标或者其他东西对它进行定制。 + +#### 安装 Xfce + +安装 Xfce 桌面环境相当简单。只需要: + +``` +sudo apt install -y --no-install-recommends xfce4 desktop-base lightdm +``` + +这就够了。你现在安装了 X Window(X11)和 Xfce 了。现在是时候来定制一下环境并且安装一些核心应用了。 + +### 核心应用 + +目前为止,你已经安装了 X Window(X11)、Xfce 桌面环境和 LightDM(一个 Xfce 自带的显示管理器)。现在,你已经有了一个可以启动并且正常使用的轻量级的完整系统。不过,在彻底完成之前,我还是喜欢装一些核心应用。 + +下面这条命令安装了一个终端程序、[Audacious][7] 音频播放器、[Ristretto][8] 图像浏览器、[Mousepad][9] 文本编辑器、[File Roller][10] 存档管理器和 [Thunar][11] 容量管理器。 + +``` +sudo apt install -y --no-install-recommends xfce4-terminal audacious ristretto +sudo apt install -y --no-install-recommends mousepad file-roller thunar-volman +``` + +#### 其他可选项 + +其他一些你可能想安装的东西,包括一个好的网络管理器、任务管理器、PDF 阅读器和通知工具,以及桌面背景管理器、截图工具、一些新的图标和光标主题。简单来说,如果树莓派是你的首选系统,这些都算是日常工作的一些补充。 + +``` +sudo apt install -y --no-install-recommends network-manager xfce4-taskmanager xfce4-notifyd +sudo apt install -y --no-install-recommends  xpdf gnome-icon-theme dmz-cursor-theme +``` + +### 下一步该做什么? + +如果一切都正常工作的话,你现在就有一个基于 Xfce 和 Debian Lite 超轻量级操作系统的树莓派了。我建议现在你去 Xfce 网站上查看其它很酷的好东西,这些你都可以安装并使用。下一步做什么完全由你决定! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/custom-raspberry-pi + +作者:[Patrick H. Mullins][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/pmullins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi_cartoon.png?itok=m3TcBONJ (Cartoon graphic of Raspberry Pi board) +[2]: https://www.raspberrypi.org/downloads/raspberry-pi-os/ +[3]: https://www.debian.org/ +[4]: https://www.raspberrypi.org/documentation/installation/installing-images/README.md +[5]: https://en.wikipedia.org/wiki/X_Window_System +[6]: http://xfce.org +[7]: https://audacious-media-player.org/ +[8]: https://docs.xfce.org/apps/ristretto/start +[9]: https://github.com/codebrainz/mousepad +[10]: https://gitlab.gnome.org/GNOME/file-roller +[11]: https://docs.xfce.org/xfce/thunar/thunar-volman +[12]: https://goodies.xfce.org/ diff --git a/published/20200610 Concise data plotting in Python with Altair.md b/published/20200610 Concise data plotting in Python with Altair.md new file mode 100644 index 0000000000..9f68890aa5 --- /dev/null +++ b/published/20200610 Concise data plotting in Python with Altair.md @@ -0,0 +1,185 @@ +[#]: collector: (lujun9972) +[#]: translator: (silentdawn-zz) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12493-1.html) +[#]: subject: (Concise data plotting in Python with Altair) +[#]: via: (https://opensource.com/article/20/6/altair-python) +[#]: author: (Shaun Taylor-Morgan https://opensource.com/users/shaun-taylor-morgan) + +Python 下使用 Altair 数据制图 +====== + +> Altair 作为一个 Python 数据制图库,提供了优雅的接口及自有的绘图语言。 + +![](https://img.linux.net.cn/data/attachment/album/202008/06/110441imrz9ajtpshtfq1i.jpg) + +Python 中的 [绘图库][2] 提供了呈现数据的多种方式,可以满足你不同的偏好,如灵活性、布局、易用性,或者特殊的风格。 + +和其它方式相比,我发现,Altair 提供的是一种不同的解决方案,且总体而言使用起来更为简单。得益于声明式的绘图语言 [Vega][3],Altair 拥有一套优雅的接口,可以直接定义要绘的图应该是什么样子,而不是通过写一大堆循环和条件判断去一步步构建。 + +### 绘图流程 + +我通过绘制同一个多柱状图比较了多个 Python 绘图库的差异。正式开始之前,你需要将你的 Python 环境调整到能运行下面代码的状态。具体就是: + +* 安装最新版的 Python( [Linux][4]、[Mac][5] 和 [Windows][6] 系统下的安装方法) +* 确认该版本 Python 可以运行本教程所使用的库 + +演示用数据可从网络下载,并且可以用 pandas 直接导入: + +``` +import pandas as pd +df = pd.read_csv('https://anvil.works/blog/img/plotting-in-python/uk-election-results.csv') +``` + +准备开始吧。为了做个比较,先看下面这个用 [Matplotlib][7] 做的图: + +![Matplotlib UK election results][8] + +使用 Matplotlib 需要 16 行代码,图柱的位置需要自己计算。 + +使用 Altair 绘制相似的图,代码如下: + +``` +    import altair as alt + +    chart = alt.Chart(df).mark_bar().encode( +        x='party', +        y='seats', +        column='year', +        color='party', +    ) + +    chart.save('altair-elections.html') +``` + +真是简洁多了!与 [Seaborn][9] 类似,Altair 所用数据的组织形式是每个变量一列(即 [数据列][10] )。这种方式下可以将每个变量映射到图的一个属性上 —— Altair 称之为“通道”。在上例中,我们期望每个 “党派” 在 `x` 轴上显示为一组图柱, 其 “席位” 显示在 `y` 轴,且将图柱按照 “年份” 分开为 “列”。我们还想根据 “党派” 给图柱使用不同的 “颜色”。用语言表述需求的话就是上面这个样子,而这也正是代码所要表述的! + +现在把图画出来: + +![Altair plot with default styling][11] + +### 调整样式 + +这和我们期待的效果有点接近了。与 Matplotlib 方案相比,主要区别在于 Altair 方案中,每个 `year` 组显示的时候,内部之间都有个小空白 —— 这不是问题,这只是 Altair 多柱状图显示的一个特性。 + +所以说呢,还需要对显示样式再做一些改进。 + +#### 非整形数据 + +两个不是整数的年份名称(`Feb 1974` 和 `Oct 1974`)显示为 `NaN` 了。这可以通过将年份数值 `year` 转换为字符串来解决: + + +``` +    df['year'] = df['year'].astype(str) +``` + +#### 指定数据排序方法 + +还需要让 Altair 知道如何对数据进行排序。Altair 允许通过传给它一个 `Column` 对象,来设定 `Column` 通道的更多细节。现在让 Altair 按照数据在数据集中出现的顺序排列: + +``` +    chart = alt.Chart(df).mark_bar().encode( +        # ... +        column=alt.Column('year', sort=list(df['year']), title=None), +        # ... +    ) +``` + +#### 移除坐标轴标签 + +我们通过设置 `title=None` 移除了图顶的 "year" 标签。下面再一处每列数据的 "party" 标签: + + +``` +    chart = alt.Chart(df).mark_bar().encode( +        x=alt.X('party', title=None), +        # ... +    ) +``` + +#### 指定颜色图 + +最后,我们还想自己指定图柱的颜色。Altair 允许建立 `domain` 中数值与 `range` 中颜色的映射来实现所需功能,太贴心了: + +``` +    cmap = { +        'Conservative': '#0343df', +        'Labour': '#e50000', +        'Liberal': '#ffff14', +        'Others': '#929591', +    } + +    chart = alt.Chart(df).mark_bar().encode( +        # ... +        color=alt.Color('party', scale=alt.Scale(domain=list(cmap.keys()), range=list(cmap.values()))) +    ) +``` + +#### 样式调整后的最终代码 + +应用上述样式调整之后,代码看起来不那么悦目了,但我们仍然是用声明的方式实现的,这正是 Altair 如此有弹性的原因所在。实现过程中,仍然是使用的异于显示数据的独立变量来分离图中不同属性的,而不是像在 Matplotlib 中那样直接对显示数据做复杂的操作。唯一的不同是,我们的变量名字封装在类似 `alt.X()` 的对象中,从而实现对显示效果的控制: + +``` +    import altair as alt +    from votes import long as df + +    cmap = { +        'Conservative': '#0343df', +        'Labour': '#e50000', +        'Liberal': '#ffff14', +        'Others': '#929591', +    } + +    df['year'] = df['year'].astype(str) + +    # We're still assigning, e.g. 'party' to x, but now we've wrapped it +    # in alt.X in order to specify its styling +    chart = alt.Chart(df).mark_bar().encode( +        x=alt.X('party', title=None), +        y='seats', +        column=alt.Column('year', sort=list(df['year']), title=None), +        color=alt.Color('party', scale=alt.Scale(domain=list(cmap.keys()), range=list(cmap.values()))) +    ) + +    chart.save('altair-elections.html') +``` + +现在与 Matplotlib 方案扯平了,代码数量达到了 16 行! + +下图是使用我们的样式调整方案之后的 Altair 效果图: + +![The Altair plot with our custom styling][12] + +### 结论 + +尽管在代码数量上,使用 Altair 绘图没有表现出优势,但它的声明式绘图语言使得对图层的操控更为精密,这是我比较欣赏的。Altair 还提供了清晰而独立的方式来调校显示样式,这使得 相关代码与绘图的代码块分离开来。Altair 确实是使用 Python 绘图时又一个很棒的工具库。 + +本文首次发布于 [这里][13],蒙允编辑后再次发布。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/altair-python + +作者:[Shaun Taylor-Morgan][a] +选题:[lujun9972][b] +译者:[silentdawn-zz](https://github.com/silentdawn-zz) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/shaun-taylor-morgan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://linux.cn/article-12327-1.html +[3]: https://vega.github.io/vega/ +[4]: https://opensource.com/article/20/4/install-python-linux +[5]: https://opensource.com/article/19/5/python-3-default-mac +[6]: https://opensource.com/article/19/8/how-install-python-windows +[7]: https://opensource.com/article/20/5/matplotlib-python +[8]: https://opensource.com/sites/default/files/uploads/matplotlib_1_1.png (Matplotlib UK election results) +[9]: https://anvil.works/blog/plotting-in-seaborn +[10]: https://anvil.works/blog/tidy-data +[11]: https://opensource.com/sites/default/files/uploads/altair-first-try.png (Altair plot with default styling) +[12]: https://opensource.com/sites/default/files/uploads/altair_3.png (The Altair plot with our custom styling.) +[13]: https://anvil.works/blog/plotting-in-altair diff --git a/published/20200611 Never forget your password with this Python encryption algorithm.md b/published/20200611 Never forget your password with this Python encryption algorithm.md new file mode 100644 index 0000000000..5d236b50d9 --- /dev/null +++ b/published/20200611 Never forget your password with this Python encryption algorithm.md @@ -0,0 +1,254 @@ +[#]: collector: (lujun9972) +[#]: translator: (silentdawn-zz) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12474-1.html) +[#]: subject: (Never forget your password with this Python encryption algorithm) +[#]: via: (https://opensource.com/article/20/6/python-passwords) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +国王的秘密:如何保护你的主密码 +====== + +> 这种使用 Python 和 Shamir 秘密共享的独特算法可以保护你的主密码,可以有效避免黑客窃取和自己不经意忘记引发的风险和不便。 + +![](https://img.linux.net.cn/data/attachment/album/202008/01/105831kzxididbld8kdhdb.jpg) + +很多人使用密码管理器来保密存储自己在用的各种密码。密码管理器的关键环节之一是主密码,主密码保护着所有其它密码。这种情况下,主密码本身就是风险所在。任何知道你的主密码的人,都可以视你的密码保护若无物,畅行无阻。自然而然,为了保证主密码的安全性,你会选用很难想到的密码,把它牢记在脑子里,并做[所有其他][2]你应该做的事情。 + +但是万一主密码泄露了或者忘记了,后果是什么?也许你去了个心仪的岛上旅行上个把月,没有现代技术覆盖,在开心戏水之后享用美味菠萝的时刻,突然记不清自己的密码是什么了。是“山巅一寺一壶酒”?还是“一去二三里,烟村四五家”?反正当时选密码的时候感觉浑身都是机灵,现在则后悔当初何必作茧自缚。 + +![XKCD comic on password strength][3] + +*([XKCD][4], [CC BY-NC 2.5][5])* + +当然,你不会把自己的主密码告诉其它任何人,因为这是密码管理的首要原则。有没有其它变通的办法,免除这种难以承受的密码之重? + +试试 [Shamir 秘密共享算法][6]Shamir's Secret Sharing,这是一种可以将保密内容进行分块保存,且只能将片段拼合才能恢复保密内容的算法。 + +先分别通过一个古代的和一个现代的故事,看看 Shamir 秘密共享算法究竟是怎么回事吧。 + +这些故事的隐含前提是你对密码学有起码的了解,必要的话,你可以先温习一下 [密码学与公钥基础设施引论][7]. + +### 一个古代关于加解密的故事 + +古代某国,国王有个大秘密,很大很大的秘密: + +``` +def int_from_bytes(s): +    acc = 0 +    for b in s: +        acc = acc * 256 +        acc += b +    return acc + +secret = int_from_bytes("terrible secret".encode("utf-8")) +``` + +大到连他自己的孩子都不能轻易信任。他有五个子女,但他知道前路危机重重。他的孩子需要在他百年之后用这个秘密来保卫国家,而国王又不能忍受自己的孩子在他们还记得自己的时候就知道这些秘密,尤其是这种状态可能要持续几十年。 + +所以,国王动用大力魔术,将这个秘密分为了五个部分。他知道,可能有一两个孩子不会遵从他的遗嘱,但绝对不会同时有三个或三个以上会这样: + +``` +from mod import Mod +from os import urandom +``` + +国王精通 [有限域][8] 和 *随机* 魔法,当然,对他来说,使用巨蟒分割这个秘密也是小菜一碟。 + +第一步是选择一个大质数——第 13 个 [梅森质数][9](`2**521 - 1`),他让人把这个数铸造在巨鼎上,摆放在大殿上: + +``` +P = 2**521 - 1 +``` + +但这不是要保密的秘密:这只是 *公开数据*。 + +国王知道,如果 `P` 是一个质数,用 `P` 对数字取模,就形成了一个数学 [场][10]:在场中可以自由进行加、减、乘、除运算。当然,做除法运算时,除数不能为 0。 + +国王日理万机,方便起见,他在做模运算时使用了 PyPI 中的 [mod][11] 模块,这个模块实现了各种模数运算算法。 + +他确认过,自己的秘密比 `P` 要短: + +``` +secret < P +``` +``` +TRUE +``` + +将秘密转换为 `P` 的模,`mod P`: + +``` +secret = mod.Mod(secret, P) +``` + +为了使任意三个孩子掌握的片段就可以重建这个秘密,他还得生成另外两个部分,并混杂到一起: + +``` +polynomial = [secret] +for i in range(2): + polynomial.append(Mod(int_from_bytes(urandom(16)), P)) +len(polynomial) +``` +``` +3 +``` + +下一步就是在随机选择的点上计算某 [多项式][12] 的值,即计算 `polynomial[0] + polynomial[1]*x + polynomial[2]*x**2 ...`。 + +虽然有第三方模块可以计算多项式的值,但那并不是针对有限域内的运算的,所以,国王还得亲自操刀,写出计算多项式的代码: + +``` +def evaluate(coefficients, x): +    acc = 0 +    power = 1 +    for c in coefficients: +        acc += c * power +        power *= x +    return acc +``` + +再下一步,国王选择五个不同的点,计算多项式的值,并分别交给五个孩子,让他们各自保存一份: + +``` +shards = {} +for i in range(5): +    x = Mod(int_from_bytes(urandom(16)), P) +    y = evaluate(polynomial, x) +    shards[i] = (x, y) +``` + +正如国王所虑,不是每个孩子都正直守信。其中有两个孩子,在他尸骨未寒的时候,就想从自己掌握的秘密片段中窥出些什么,但穷极所能,终无所获。另外三个孩子听说了这个事,合力将这两人永远驱逐: + +``` +del shards[2] +del shards[3] +``` + +二十年弹指一挥间,奉先王遗命,三个孩子将合力恢复出先王的大秘密。他们将各自的秘密片段拼合在一起: + +``` +retrieved = list(shards.values()) +``` + +然后是 40 天没日没夜的苦干。这是个大工程,他们虽然都懂些 Python,但都不如前国王精通。 + +最终,揭示秘密的时刻到了。 + +用于反算秘密的代码基于 [拉格朗日差值][13],它利用多项式在 `n` 个非 0 位置的值,来计算其在 `0` 处的值。前面的 `n` 指的是多项式的阶数。这个过程的原理是,可以为一个多项式找到一个显示方程,使其满足:其在 `t[0]` 处的值是 `1`,在 `i` 不为 `0` 的时候,其在 `t[i]` 处的值是 `0`。因多项式值的计算属于线性运算,需要计算 *这些* 多项式各自的值,并使用多项式的值进行插值: + +``` +from functools import reduce +from operator import mul + +def retrieve_original(secrets): +    x_s = [s[0] for s in secrets] +    acc = Mod(0, P) +    for i in range(len(secrets)): +        others = list(x_s) +        cur = others.pop(i) +        factor = Mod(1, P) +        for el in others: +            factor *= el * (el - cur).inverse() +        acc += factor * secrets[i][1] +    return acc +``` + +这代码是在太复杂了,40 天能算出结果已经够快了。雪上加霜的是,他们只能利用五个秘密片段中的三个来完成这个运算,这让他们万分紧张: + +``` +retrieved_secret = retrieve_original(retrieved) +``` + +后事如何? + +``` +retrieved_secret == secret +``` +``` +TRUE +``` + +数学这个魔术的优美之处就在于它每一次都是那么靠谱,无一例外。国王的孩子们,曾经的孩童,而今已是壮年,足以理解先王的初衷,并以先王的锦囊妙计保卫了国家,并继之以繁荣昌盛! + +### 关于 Shamir 秘密共享算法的现代故事 + +现代,很多人都对类似的大秘密苦不堪言:密码管理器的主密码!几乎没有谁能有足够信任的人去完全托付自己最深的秘密,好消息是,找到至少有三个不会串通起来搞鬼的五人组不是个太困难的事。 + +同样是在现代,比较幸运的是,我们不必再像国王那样自己动手分割要守护的秘密。拜现代 *开源* 技术所赐,这都可以使用现成的软件完成。 + +假设你有五个不敢完全信任,但还可以有点信任的人:张三、李四、王五、赵六和钱大麻子。 + +安装并运行 `ssss` 分割密钥: + +``` +$ echo 'long legs travel fast' | ssss-split -t 3 -n 5 +Generating shares using a (3,5) scheme with dynamic security level. +Enter the secret, at most 128 ASCII characters: Using a 168 bit security level. +1-797842b76d80771f04972feb31c66f3927e7183609 +2-947925f2fbc23dc9bca950ef613da7a4e42dc1c296 +3-14647bdfc4e6596e0dbb0aa6ab839b195c9d15906d +4-97c77a805cd3d3a30bff7841f3158ea841cd41a611 +5-17da24ad63f7b704baed220839abb215f97d95f4f8 +``` + +这确实是个非常牛的主密码:`long legs travel fast`,绝不能把它完整的托付给任何人!那就把五个片段分别交给还比较可靠的伙伴,张三、李四、王五、赵六和钱大麻子。 + + * 把 `1` 给张三。 + * 把 `2` 给李四。 + * 把 `3` 给王五。 + * 把 `4` 给赵六。 + * 把 `5` 给钱大麻子。 + +然后,你开启你的惬意之旅,整整一个月,流连于海边温暖的沙滩,整整一个月,没碰过任何电子设备。没用多久,把自己的主密码忘到了九霄云外。 + +李四和王五也在和你一起旅行,你托付给他们保管的密钥片段保存的好好的,在他们各自的密码管理器中,但不幸的是,他们和你一样,也忘了自己的 *主密码*。 + +没关系。 + +联系张三,他保管的密钥片段是 `1-797842b76d80771f04972feb31c66f3927e7183609`;赵六,一直替你的班,很高兴你能尽快重返岗位,把自己掌握的片段给了你,`4-97c77a805cd3d3a30bff7841f3158ea841cd41a611`;钱大麻子,收到你给的跑腿费才将自己保管的片段翻出来发给你,`5-17da24ad63f7b704baed220839abb215f97d95f4f8`。 + +有了这三个密钥片段,运行: + +``` +$ ssss-combine -t 3 +Enter 3 shares separated by newlines: +Share [1/3]: 1-797842b76d80771f04972feb31c66f3927e7183609 +Share [2/3]: 4-97c77a805cd3d3a30bff7841f3158ea841cd41a611 +Share [3/3]: 5-17da24ad63f7b704baed220839abb215f97d95f4f8 +Resulting secret: long legs travel fast +``` + +就这么简单,有了 *开源* 技术加持,你也可以活的像国王一样滋润! + +### 自己的安全不是自己一个人的事 + +密码管理是当今网络生活必备技能,当然要选择复杂的密码,来保证安全性,但这不是全部。来用 Shamir 秘密共享算法,和他人共同安全的存储你的密码吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/python-passwords + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[silentdawn-zz](https://github.com/silentdawn-zz) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_python_programming.png?itok=ynSL8XRV (Searching for code) +[2]: https://monitor.firefox.com/security-tips +[3]: https://opensource.com/sites/default/files/uploads/password_strength-xkcd.png (XKCD comic on password strength) +[4]: https://imgs.xkcd.com/comics/password_strength.png +[5]: https://creativecommons.org/licenses/by-nc/2.5/ +[6]: https://en.wikipedia.org/wiki/Secret_sharing#Shamir's_scheme +[7]: https://opensource.com/article/18/5/cryptography-pki +[8]: https://en.wikipedia.org/wiki/Finite_field +[9]: https://en.wikipedia.org/wiki/Mersenne_prime +[10]: https://en.wikipedia.org/wiki/Field_(mathematics) +[11]: https://pypi.org/project/mod/ +[12]: https://en.wikipedia.org/wiki/Polynomial +[13]: https://www.math.usm.edu/lambers/mat772/fall10/lecture5.pdf diff --git a/published/20200623 Jitsi Meet- A Free - Open Source Video Conferencing Solution That is Also Free to Use Without Any Set Up.md b/published/20200623 Jitsi Meet- A Free - Open Source Video Conferencing Solution That is Also Free to Use Without Any Set Up.md new file mode 100644 index 0000000000..48a344eca5 --- /dev/null +++ b/published/20200623 Jitsi Meet- A Free - Open Source Video Conferencing Solution That is Also Free to Use Without Any Set Up.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12484-1.html) +[#]: subject: (Jitsi Meet: A Free & Open Source Video Conferencing Solution That is Also Free to Use Without Any Set Up) +[#]: via: (https://itsfoss.com/jitsi-meet/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Jitsi Meet:自由开源的视频会议解决方案,无需设置即可免费使用 +====== + +> Jitsi Meet 是一个开源视频会议服务,你可以免费使用它来组织在线课程、会议和聚会。你也可以在自己的服务器上托管 Jitsi。 + +在 COVID-19 大流行期间,远程工作趋势显著增长。无论你是否喜欢,视频会议对于个人和企业都是一个很好的解决方案。 + +在过去的几个月中,非常流行的视频会议服务之一就是 Zoom。但是,[关于 Zoom 视频通话][1]存在很多安全和隐私问题。 + +因此,选择一个安全且易于使用的视频会议应用来完成工作是很重要的。我敢肯定有很多选择,但是在这里,让我们看一下开源选项 [Jitsi Meet][2]。 + +### Jitsi Meet:免费使用的开源视频会议服务 + +![][3] + +Jitsi Meet 是开源语音、视频会议和即时消息服务 [Jitsi][4] 集合的一部分。 + +通过 Jitsi Meet,你可以即刻主持群组视频通话(即视频会议),你甚至都不需要建立帐户。 + +对于桌面端,它是基于浏览器的,但它以 AppImage 的形式为 Linux 提供了一个基于 Electron 的桌面应用。它也可以用在 Windows 和 macOS 上。 + +对于智能手机,它提供了 iOS 和 Android 应用,你可以分别从 App Store 和 Play Store 进行安装。除了这些,你还可以在开源 Android 应用商店 [F-Droid][5] 中找到它。 + +如果你想更进一步,你可以在你的服务器上部署 Jitsi Meet。对于那些不想使用第三方服务器的企业来说,这是理想的选择,即使该服务器来自软件开发商。 + +### Jitsi Meet 的功能 + +![][6] + +Jitsi Meet 简单但功能丰富。这是你将获得的功能: + + * 不需要用户注册 + * 使用 Etherpad 共同编辑文档 + * 能够自己部署 + * 支持集成 Slack 和 Rocket.chat + * 如果需要,提供密码保护 + * 端到端加密(beta 版) + * 背景模糊(beta 版) + * 录音选项 + * 直播流支持 + * YouTube 视频分享 + * 查看用户的网络状态 + * 集成 Google 和 Microsoft 日历 + * 聊天功能 + * 屏幕共享 + * 支持国际连接拨入 + * 你可以稍后继续视频通话,而无需会议代码 + * 低带宽模式选项 + * Jitsi 可选的桌面版本 + +![][7] + +出于显而易见的原因,你在移动应用上只能找到较少的功能。 + +请注意,[端到端加密仍处于 beta 阶段][8]。但是,即使没有它,Jitsi Meet 也应该是一个隐私友好且安全的视频会议解决方案。 + +在移动设备上,我只希望它有屏幕共享功能。除此之外,其他所有功能都很好。 + +### 如何使用 Jitsi Meet? + +![][9] + +要使它在 Linux 上运行,你不需要做任何其他事情。你只需要前往它的[官方 Jitsi Meet 实例][2],然后输入会议名称即可创建或加入。 + +如果您使用的是基于 Electron的应用程序,则完全一样。 使用桌面应用程序时的外观如下: + +![](https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-meet-electron.png?w=800&ssl=1) + +如你在上面的截图中所见,你还可以找到你最近使用的会议室的列表,这样就不必再次输入或创建会议室。 + +![][10] + +如果你要创建它,那么最好使用唯一的名称,并且如果你不需要其他任何人意外加入,那么还应为其添加密码保护。 + +![][11] + +如果你要参加其他人的会议,只需询问会议名称或会议链接即可使用台式机或智能手机轻松加入。 + +除了少一些功能,它与桌面端的工作方式相同。我已经使用了一段时间,并且还鼓励和培训了我父亲的单位(我们的附近学校)使用 Jitsi Meet 主持在线课程。 + +即使有最多 75 名参与者的限制,它的表现也很好,而且工作良好。 + +[Jitsi Meet][12] + +### 总结 + +如果你希望托管自己的 Jitsi 实例,建议你遵循它的[官方自托管指南][13]来启动并运行它。你还可以在[它的 GitHub 页面中找到实例列表][14]。 + +Jitsi Meet 是个了不起的开源视频会议应用。它是 Zoom 和其他此类视频通话服务的一种隐私保护替代方案。 + +我还建议查看 [NextCloud,它是 MS Office 365 的开源替代方案][15]。 + +你如何看待 Jitsi Meet?你尝试过了吗?你最喜欢的视频会议工具是什么? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/jitsi-meet/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://www.tomsguide.com/news/zoom-security-privacy-woes +[2]: https://meet.jit.si/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-meet-screenshot.png?ssl=1 +[4]: https://jitsi.org/ +[5]: https://f-droid.org/en/packages/org.jitsi.meet/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-meet-smartphones.jpg?ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-options-desktop.png?ssl=1 +[8]: https://jitsi.org/blog/e2ee/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-meet-use.resized.png?ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-meet-browser-screenshot.png?ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-meet-password.png?ssl=1 +[12]: https://meet.jit.si +[13]: https://jitsi.github.io/handbook/docs/devops-guide/devops-guide-quickstart +[14]: https://github.com/jitsi/jitsi-meet/wiki/Jitsi-Meet-Instances +[15]: https://itsfoss.com/nextcloud/ diff --git a/published/202007/20180730 50 Best Ubuntu Apps You Should Be Using Right Now.md b/published/202007/20180730 50 Best Ubuntu Apps You Should Be Using Right Now.md new file mode 100644 index 0000000000..3c9039e20f --- /dev/null +++ b/published/202007/20180730 50 Best Ubuntu Apps You Should Be Using Right Now.md @@ -0,0 +1,501 @@ +50 个绝佳的必备 Ubuntu 应用 +====== + +> 摘要:这是一份详尽清单,给所有用户的优秀的 Ubuntu 应用。这些应用将帮助你获得更好的 Linux 桌面使用体验。 + +过去,我已经多次写过关于 [安装 Ubuntu 之后该做什么][1]。每次我都建议在 Ubuntu 上安装某些关键的应用程序。 + +那么问题来了,什么是关键的 Ubuntu 应用程序?没有绝对的答案。这取决于你的需要和你在 Ubuntu 上要做的工作。 + +然而还是有很多读者请我推荐一些优秀的 Ubuntu 应用。这就是为什么我创建了这个全面的Ubuntu应用程序列表,你可以经常使用。 + +为了方便阅读和理解,清单划分为不同应用种类。 + +### 提供更好使用体验的优秀 Ubuntu 应用 + +![优秀 Ubuntu 应用][2] + +当然,你不必使用以下全部应用。只须浏览这份 Ubuntu 关键应用清单,阅读描述并安装你需要或想要的应用。将这篇文章保存在你的浏览器收藏夹以备将来参考或者通过搜索引擎搜索即可。 + +这份 Ubuntu 优秀应用清单是准备给普通 Ubuntu 用户的,因此这些应用不全是开源的。我也标记了某些可能不适合新手的稍微复杂的应用。清单适用于 Ubuntu 16.04、18.04 和其他版本。 + +除非特别声明,所有列出的软件都可以在 Ubuntu 软件中心获得。 + +如果你没有在软件中心找到应用或者缺失安装说明,请告知我,我会补充安装步骤。 + +话不多说!让我们看看有哪些优秀 Ubuntu 应用。 + +#### 浏览器 + +Ubuntu 以 Firefox 为默认浏览器。自从 Quantum 版本发布以来,Firefox 已有显著提升。就个人而言,我经常使用多个浏览器来应对不同的工作。 + +##### Google Chrome + +![Google Chrome Logo][3] + +由于某种原因,Google Chrome 是最为广泛使用的浏览器。使用 Google 账号,你可以在不同设备无缝同步。大量拓展和应用进一步增强 Chrome 的能力。你可以 [点击此处在 Ubuntu 上安装 Chrome][4]。 + +##### Brave + +![brave browser][5] + +Google Chrome 可能是最广泛使用的浏览器,但也是隐私窥探者。一个 [替代浏览器][6] 是 [Brave][7],它可以默认拦截广告和追踪脚本。它为你提供了更快、更安全的浏览体验。 + +#### 音乐应用 + +![Ubuntu 优秀音乐应用][8] + +Ubuntu 将 Rhythmbox 作为默认音乐播放器,这是个相当不坏的选择。不过,你当然可以安装更好的音乐播放器。 + +##### Sayonara + +[Sayonara][9] 是一个小型、轻量并具备漂亮的深色用户界面的音乐播放器。它拥有所有你期望的标准音乐播放器应有的关键功能。它与 Ubuntu 桌面环境整合良好并且不会大量消耗你的内存。 + +##### Audacity + +[Audacity][10] 与其说是音频播放器,不如说是音频编辑器。你可以使用这款自由且开源的工具录制和编辑音频。它支持 Linux、Windows 和 macOS。你可以从软件中心安装它。 + +##### MusicBrainz Picard + +[Picard][11] 不是一个音乐播放器,而是个音乐标签软件。如果你有大量本地音乐文件,Picard 可以帮助你自动更新音乐文件的正确的曲目、专辑、艺人资料和专辑封面。 + +#### 流媒体音乐应用 + +![Streaming Music app Ubuntu][12] + +在这个时代的互联网,听音乐的方式显然发生了改变。现在的人更依赖于流媒体音乐播放器而不是收藏上百首本地音乐文件。让我们看看你可以用于收听流媒体音乐的一些应用吧。 + +##### Spotify + +[Spotify][13] 是流媒体音乐之王。好消息是它具有官方 Linux 版本。[Ubuntu 上的 Spotify 应用][14] 与媒体键和声音菜单以及桌面通知中心整合良好。请注意,Spotify 服务可能在你的国家有,也可能没有。 + +##### Nuvola 音乐播放器 + +[Nuvola][15] 不是像 Spotify 那样的流媒体音乐服务。它是一款在单一应用内支持多个流媒体音乐服务的桌面音乐播放器。你可以使用 Spotify、Deezer、Google Play Music、Amazon Cloud Player 和更多类似服务。 + +#### 视频播放器 + +![Linux 视频播放器][16] + +Ubuntu 有默认的 GNOME 视频播放器(从前名为 Totem),表现尚可,但不支持多种视频编码。当然有很多播放器比 GNOME 视频播放器更优秀。 + +##### VLC + +自由开源的 [VLC][17] 摘得视频播放器桂冠。它几乎支持全部的视频编码。它还允许你将音量增至最高的 200%。它也支持从最后一个已知位置继续播放。有很多 [VLC 使用技巧][18] 供你参考以尽兴使用。 + +##### MPV + +[MPV][19] 是款值得更多关注的视频播放器。别致轻量的界面和丰富的功能,MPV 拥有你对一个好的视频播放器的一切期望。你甚至可以在命令行使用它。如果你对 VLC 不够满意,你完全可以尝试 MPV。 + +#### 云端存储服务 + +本地备份很好,但云端存储给你更多维度的自由。使用云存储,你再也不必总是随身携带 U 盘或担心硬盘故障。 + +##### Dropbox + +![Dropbox logo][20] + +[Dropbox][21] 是最流行的云存储提供商之一。你会获得 2GB 免费存储空间,并通过推介给他人得到更多存储空间。Dropbox 提供了一个原生的 Linux 客户端,你可以从官网下载获得。它会在你的系统创建一个本地文件夹,以和云端服务器同步。 + +##### pCloud + +![pCloud icon][22] + +[pCloud][23] 是另一个优秀的 Linux 云存储提供商。它也拥有原生的 Linux 客户端,你可以从官网下载。你可以获得高达 20GB 的免费存储空间,如果你需要更多,价格也比 Dropbox 实惠。pCloud 总部位于瑞士,这个国家以严格的数据隐私法而闻名。 + +#### 图片编辑器 + +我相信你一定会在某个时间点上需要一个照片编辑器。这里有些优秀的 Ubuntu 图片编辑应用。 + +##### GIMP + +![gimp icon][24] + +[GIMP][25] 是一个自由开源的图片编辑器,它支持 Linux、Windows 和 macOS。它是 Adobe Photoshop 在 Linux 上最优秀的替代软件。你可以使用它执行任何图片编辑。网上有许多资源帮助你使用 GIMP。 + +##### Inkscape + +![inkscape icon][26] + +[Inkscape][27] 也是一个自由开源的图片编辑器,专用于矢量图形编辑。你可以在 Inkscape 上设计矢量图形和徽标。你可以把它比做 Adobe Illustrator。与 GIMP 一样,网上也有诸多 Inkscape 教程。 + +#### 绘图应用 + +![Painting apps for Ubuntu Linux][28] + +绘图应用和图片编辑器不完全等同,尽管它们有时功能重叠。以下是你能在 Ubuntu 使用的一些绘图应用。 + +##### Krita + +[Krita][29] 是一款自由开源的数字绘图应用。你可以用它创建数字绘画、漫画和动画。这是款专业软件,甚至被美术学校作为主要软件使用。 + +##### Pinta + +[Pinta][30] 虽然不像 Krita 功能强大,但也可圈可点。你可以把它视为 Linux 端的微软画图软件。你可以绘制、画图、添加文字和执行绘图应用可行的其他诸如此类的小任务。 + +#### 摄影应用 + +摄影爱好者还是专家?你将随手获得大量 [摄影工具][31],以下是一些推荐应用。 + +##### digiKam + +![digikam][32] + +使用开源软件 [digKam][33],你可以专业地处理你的高品质摄影作品。digKam 提供用于查看、管理、编辑、增强、组织、标记和分享照片所需的所有工具。 + +##### Darktable + +![Darktable icon][34] + +[darktable][35] 是一款开源的摄影工作流应用程序,特别是专注于 raw 图像的开发。这会是你取代 Adobe Lightroom 的最佳替代品。它同样支持 Windows 和 macOS。 + +#### 视频编辑器 + +![Video editors Ubuntu][36] + +[Linux 上的视频编辑器][37] 并不匮乏,毋庸赘述。看看 Ubuntu 中一些功能丰富但相对简单的视频编辑器。 + +##### Kdenlive + +[Kdenlive][38] 是 Linux 端最好的全能型视频编辑器。它与 iMovie 或 Movie Maker 相比功能毫不逊色。 + +##### Shotcut + +[Shotcut][39] 是视频编辑的另一个好选择。它是一款开源软件,拥有标准视频编辑器的所有功能。 + +#### 图片和视频格式转换器 + +如果你需要为你的图片和视频 [转换文件格式][40],这些是我的推荐。 + +##### Xnconvert + +![xnconvert logo][41] + +[Xnconvert][42] 是一款优秀的批量图像转换工具。你可以批量调整图片尺寸、转换文件类型并重命名。 + +##### Handbrake + +![Handbrake Logo][43] + +[HandBrake][44] 是一款易用的开源工具,用于将多种格式的视频转换为一些现代流行的格式。 + +#### 截图和录屏工具 + +![Screenshot and recorders Ubuntu][45] + +以下是截图和录屏的优秀 Ubuntu 应用。 + +##### Shutter + +[Shutter][46] 是我截图的常用工具。你也可以对这些截图进行一些快速编辑,比如添加箭头、文字或调整图片尺寸。你在我们网站看到的截图都是用 Shutter 编辑的。绝对是 Ubuntu 上最好的应用程序之一。 + +##### Kazam + +[Kazam][47] 是我最喜欢的 [Linux 上的录屏工具][48]。这个是小巧的工具,可以让你录制全屏、某个应用程序窗口或选定区域。你也可以使用快捷键暂停或恢复录屏。[我们的 YouTube 频道][49] 上的教程都是用 Kazam 录制的。 + +#### 办公套件 + +我无法想象你在使用计算机时没有文档编辑器。又何必把自己局限在一个文档编辑器上呢?去寻找一个完整的办公套件吧。 + +##### LibreOffice + +![LibreOffice logo][50] + +Ubuntu 预装了 [LibreOffice][51],它无疑是 [最佳的开源办公软件][52]。它是个组件完整的办公软件,包括文档编辑器、电子表格工具、演示软件、数学工具和作图工具。你甚至可以用它编辑部分 PDF 文件。 + +##### WPS Office + +![WPS Office logo][53] + +[WPS Office][54] 因酷似微软 Office 而广受欢迎。它的界面与微软 Office 几乎一样并且号称与微软 Office 更加兼容。如果你正在寻找类似微软 Office 的办公软件,WPS Office 是个好选择。 + +#### 下载工具 + +![Downloading software Ubuntu][55] + +如果你经常从网上下载视频或其他大型文件,这些工具会帮助你。 + +##### youtube-dl + +这是本清单少有的基于命令行的 Ubuntu 应用之一。如果你想从 YouTube、DailyMotion 或其他视频网站下载视频,youtube-dl 是个绝好的选择。它提供了大量 [视频下载高级选项][56]。 + +##### uGet + +[uGet][57] 是一款功能丰富的 [Linux 下载管理器][58]。它允许你暂停和恢复下载、定时下载、监控剪贴板上的可下载内容。如果你的网络速度很慢、不稳定,或者每天的流量有限,这是一个完美的应对工具。 + +#### 代码编辑器 + +![Coding apps for Ubuntu][59] + +如果你喜欢编程,默认的 Gedit 文本编辑器可能无法满足你的编程需求。下面就为你介绍一些比较好用的代码编辑器。 + +##### Atom + +[Atom][60] 是一款由 GitHub 推出的 [自由开源的代码编辑器][61]。早在它推出第一个稳定版之前,它就因其用户界面、功能和海量插件而成为程序员的至宠。 + +##### Visual Studio Code + +[VS Code][62] 是一款微软出品的开源代码编辑器。别忌惮微软之名,VS Code 是款很棒的 Web 开发编辑器,它还支持许多其他编程语言。 + +#### PDF 和电子书相关应用 + +![eBook Management tools in Ubuntu][63] + +在这个数字时代,你不能只依靠真正的纸质书籍,特别是当有大量的免费电子书唾手可得。这里有一些 Ubuntu 应用以供管理 PDF 和电子书。 + +##### Calibre + +如果你是个书虫,并收集电子书,你应该使用 [Calibre][64]。它是一个电子书管理器,拥有 [创建电子书][65]、转换电子书格式和管理电子书库的所有必要组件。 + +##### Okular + +Okular 主要是一个 PDF 查看器,有编辑 PDF 文件的选项。你可以用 Okular 在 Linux 上做一些基本的 [PDF 编辑][66],如添加弹出式备注、内联式备注、手绘、荧光笔、印章等。 + +#### 通讯应用 + +![Messaging apps for Ubuntu][67] + +我相信你在 Linux 上使用至少一款 [通讯应用][68]。以下是我的推荐。 + +##### Skype + +[Skype][69] 是最流行的视频通讯应用。它也被许多公司和企业用于面试和会议。这使得 Skype 成为 Ubuntu 必备的应用程序之一。 + +##### Rambox + +[Rambox][70] 本身不是一个通讯应用,但它允许你从单一窗口中使用 Skype、Viber、Facebook Messanger、WhatsApp、Slack 和其他一些通讯应用。 + +#### 笔记和待办事项应用 + +需要一个待办事项应用或简单的应用来做笔记吗?看看这些吧。 + +##### Simplenote + +![Simplenote logo][71] + +[Simplenote][72] 是 WordPress 创建者 [Automattic][73] 推出的一款自由开源的笔记应用。它适用于 Windows、Linux、macOS、iOS 和 Android。你的笔记会同步到云服务器上,你可以在任何设备上访问它们。你可以从官网下载 DEB 文件。 + +##### Remember The Milk + +![Remember The Milk logo][74] + +[Remember The Milk][75] 是一款流行的待办事项应用。它适用于 Windows、Linux、macOS、iOS 和 Android。你可以在拥有的所有设备上访问你的待办事项。你也可以从浏览器访问它。它还有一个官方的 Linux 原生版本,你可以从官网下载。 + +#### 密码保护和加密 + +![Encryption software Ubuntu][76] + +如果有其他人经常使用你的电脑,也许你会考虑通过密码保护文件和文件夹来增加额外的安全。 + +##### EncryptPad + +[EncryptPad][77] 是一个开源文本编辑器,它允许你用密码锁定你的文件。你可以选择加密的类型。这个工具也有一个命令行版本。 + +##### Gnome Encfs Manager + +Gnome Encfs Manager 允许你 [在 Linux 中用密码锁定文件夹][78]。你可以将任何你想要的文件保存在一个加密文件夹中,然后用密码锁定它。 + +#### 游戏 + +![Gaming on Ubuntu][79] + +[Linux 上的游戏][80] 体验比几年前改进很多。你可以在 Linux 上畅玩大量游戏,而不用回到 Windows 了。 + +##### Steam + +[Steam][81] 是一个数字发行平台,允许你购买游戏(如果需要的话)。Steam 拥有超过 1500 款 [Linux 游戏][82]。你可以从软件中心下载 Steam 客户端。 + +##### PlayOnLinux + +[PlayOnLinux][83] 允许你在 Linux 上通过 WINE 兼容层运行 Windows 游戏。不要对它抱有太高的期望,因为并不是每个游戏都能在 PlayOnLinux 下完美运行。 + +#### 软件包管理工具 [中高级用户] + +![Package Management tools Ubuntu][84] + +Ubuntu 软件中心满足普通 Ubuntu 用户的软件需求,但你可以使用以下应用程序对其进行更多的深入操作。 + +##### Gdebi + +Gedbi 是一款小巧的软件包管理器,你可以用它来安装 DEB 文件。它比软件中心更快,而且还能处理依赖问题。 + +##### Synaptic + +十年前,Synaptic 是大多数 Linux 发行版的默认 GUI 软件包管理器。在一些 Linux 发行版中,它仍然是默认的软件包管理器。这个强大的软件包管理器在 [查找已安装的应用程序并删除它们][85] 方面特别有用。 + +#### 备份和恢复工具 + +![Backup and data recovery tools for Ubuntu][86] + +任何操作系统都应该有备份和恢复工具。让我们来看看 Ubuntu 上有哪些软件是你必须拥有的。 + +##### Timeshift + +Timeshift 是一个帮助你 [对系统进行快照][87] 的工具。这可以让你在系统配置混乱的情况下,在发生不幸的事时将系统恢复到以前的状态。不过要注意的是,它并不是你个人数据备份的最佳工具。对此,你可以使用U buntu 默认的 Deja Dup(也叫做“备份”)。 + +##### TestDisk [中级用户] + +这是本清单里另一个命令行工具。[TestDisk][88] 可以让你 [恢复 Linux 上的数据][89]。如果你不小心删除了文件,使用 TestDisk 还有机会找回来。 + +#### 系统调整和管理工具 + +![System Maintenance apps Ubuntu][90] + +##### GNOME/Unity Tweak Tool + +这些调整工具是每个 Ubuntu 用户必备的。它们允许你访问一些高级系统设置。最重要的是,你可以使用这些调整工具 [改变 Ubuntu 的主题][91]。 + +##### UFW Firewall + +[UFW][92] 意指“不复杂的防火墙”,这一点是贴切的。UFW 为家庭、工作和公共网络预先定义了防火墙设置。 + +##### Stacer + +如果你想释放 Ubuntu 的存储空间,可以试试 Stacer。这个图形化工具可以让你通过删除不必要的文件和完全卸载软件来 [优化你的 Ubuntu 系统][93]。可以从 [官网][94] 下载 Stacer。 + +#### 其他工具 + +![Utilities Ubuntu][95] + +最后,我会列一些其他我很喜欢但无法归类的 Ubuntu 应用。 + +##### Neofetch + +又多了一个命令行工具!Neofetch 可以显示你的系统信息,如 [Ubuntu 版本][96]、桌面环境、主题、图标、内存和其他信息,并附有 [发行版的 ASCII 徽标][97]。使用以下命令安装 Neofetch。 + +``` +sudo apt install neofetch +``` + +##### Etcher + +Ubuntu 已经带有一个即用 USB 创建工具,但 Etcher 能更好地完成这项任务。它同样支持 Windows 和 macOS。你可以 [点击这里][98] 下载 Etcher。 + +##### gscan2pdf + +我使用这个小工具的唯一目的是 [将图片转换为 PDF][99]。你也可以用它将多张图片合并成一个 PDF 文件。 + +##### 音频记录器 + +另一个小巧而又必不可少的 Ubuntu 应用,用于 [在 Ubuntu 上录制音频][100]。你可以用它来录制来自系统麦克风、音乐播放器或任何其他来源的声音。 + +### 你对 Ubuntu 关键应用的建议? + +我想在这里结束我的优秀 Ubuntu 应用清单。我知道你可能不需要或使用所有的应用,但我确信你会喜欢这里列出的大部分应用。 + +你是否找到几款以前从未知道的应用呢?如果要你推荐最爱的 Ubuntu 应用,你会选择哪个呢? + +最后,如果你觉得这篇文章有用,请把它分享到社交媒体或其他你常访问的社区或论坛。这样,你也帮助了我们的成长 :) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/best-ubuntu-apps/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[LikChung](https://github.com/LikChung) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/abhishek/ +[1]:https://linux.cn/article-12183-1.html +[2]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/best-ubuntu-apps-featured.jpeg +[3]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/google-chrome.jpeg +[4]:https://www.google.com/chrome/ +[5]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/brave-browser-icon.jpeg +[6]:https://itsfoss.com/open-source-browsers-linux/ +[7]:https://brave.com/ +[8]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/music-apps-ubuntu.jpeg +[9]:https://itsfoss.com/sayonara-music-player/ +[10]:https://www.audacityteam.org/ +[11]:https://itsfoss.com/musicbrainz-picard/ +[12]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/streaming-music-apps-ubuntu.jpeg +[13]:https://www.spotify.com// +[14]:https://linux.cn/article-9415-1.html +[15]:https://tiliado.eu/nuvolaplayer/ +[16]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/Video-Players-linux.jpg +[17]:https://www.videolan.org/index.html +[18]:https://linux.cn/article-11776-1.html +[19]:https://mpv.io/ +[20]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/dropbox-icon.jpeg +[21]:https://www.dropbox.com/ +[22]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/pcloud-icon.jpeg +[23]:https://itsfoss.com/recommends/pcloud/ +[24]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/gimp-icon.jpeg +[25]:https://www.gimp.org/ +[26]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/inkscape-icon.jpeg +[27]:https://inkscape.org/en/ +[28]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/paint-apps-ubuntu.jpeg +[29]:https://krita.org/en/ +[30]:https://pinta-project.com/pintaproject/pinta/ +[31]:https://itsfoss.com/image-applications-ubuntu-linux/ +[32]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/digikam-icon.jpeg +[33]:https://www.digikam.org/ +[34]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/darktable-icon.jpeg +[35]:https://www.darktable.org/ +[36]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/video-editing-apps-ubuntu.jpeg +[37]:https://linux.cn/article-10185-1.html +[38]:https://kdenlive.org/en/ +[39]:https://shotcut.org/ +[40]:https://itsfoss.com/format-factory-alternative-linux/ +[41]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/xnconvert-logo.jpeg +[42]:https://www.xnview.com/en/xnconvert/ +[43]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/handbrake-logo.jpeg +[44]:https://handbrake.fr/ +[45]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/screen-recording-ubuntu-apps.jpeg +[46]:http://shutter-project.org/ +[47]:https://launchpad.net/kazam +[48]:https://itsfoss.com/best-linux-screen-recorders/ +[49]:https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[50]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/libre-office-logo.jpeg +[51]:https://www.libreoffice.org/download/download/ +[52]:https://linux.cn/article-9379-1.html +[53]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/wps-office-logo.jpeg +[54]:http://wps-community.org/ +[55]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/download-apps-ubuntu.jpeg +[56]:https://linux.cn/article-9244-1.html +[57]:http://ugetdm.com/ +[58]:https://itsfoss.com/4-best-download-managers-for-linux/ +[59]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/coding-apps-ubuntu.jpeg +[60]:https://atom.io/ +[61]:https://linux.cn/article-7468-1.html +[62]:https://itsfoss.com/install-visual-studio-code-ubuntu/ +[63]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/pdf-management-apps-ubuntu.jpeg +[64]:https://calibre-ebook.com/ +[65]:https://linux.cn/article-7977-1.html +[66]:https://itsfoss.com/pdf-editors-linux/ +[67]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/messaging-apps-ubuntu.jpeg +[68]:https://itsfoss.com/best-messaging-apps-linux/ +[69]:https://www.skype.com/en/ +[70]:https://rambox.pro/ +[71]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/simplenote-logo.jpeg +[72]:http://simplenote.com/ +[73]:https://automattic.com/ +[74]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/remember-the-milk-logo.jpeg +[75]:https://itsfoss.com/remember-the-milk-linux/ +[76]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/encryption-apps-ubuntu.jpeg +[77]:https://linux.cn/article-9377-1.html +[78]:https://itsfoss.com/password-protect-folder-linux/ +[79]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/gaming-ubuntu.jpeg +[80]:https://linux.cn/article-7316-1.html +[81]:https://store.steampowered.com/ +[82]:https://itsfoss.com/free-linux-games/ +[83]:https://www.playonlinux.com/en/ +[84]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/package-management-apps-ubuntu.jpeg +[85]:https://itsfoss.com/how-to-add-remove-programs-in-ubuntu/ +[86]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/backup-recovery-tools-ubuntu.jpeg +[87]:https://linux.cn/article-11619-1.html +[88]:https://www.cgsecurity.org/wiki/TestDisk +[89]:https://linux.cn/article-7974-1.html +[90]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/system-maintenance-apps-ubuntu.jpeg +[91]:https://itsfoss.com/install-themes-ubuntu/ +[92]:https://wiki.ubuntu.com/UncomplicatedFirewall +[93]:https://itsfoss.com/optimize-ubuntu-stacer/ +[94]:https://github.com/oguzhaninan/Stacer +[95]:https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/utilities-apps-ubuntu.jpeg +[96]:https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[97]:https://itsfoss.com/display-linux-logo-in-ascii/ +[98]:https://etcher.io/ +[99]:https://itsfoss.com/convert-multiple-images-pdf-ubuntu-1304/ +[100]:https://itsfoss.com/record-streaming-audio/ diff --git a/published/202007/20190213 How to build a WiFi picture frame with a Raspberry Pi.md b/published/202007/20190213 How to build a WiFi picture frame with a Raspberry Pi.md new file mode 100644 index 0000000000..6e66448709 --- /dev/null +++ b/published/202007/20190213 How to build a WiFi picture frame with a Raspberry Pi.md @@ -0,0 +1,131 @@ +[#]: collector: (lujun9972) +[#]: translator: (this-is-name-right) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12448-1.html) +[#]: subject: (How to build a WiFi picture frame with a Raspberry Pi) +[#]: via: (https://opensource.com/article/19/2/wifi-picture-frame-raspberry-pi) +[#]: author: (Manuel Dewald https://opensource.com/users/ntlx) + +如何用树莓派制作 WiFi 相框 +====== + +> DIY一个数码相框,图片流来自云端。 + +![](https://img.linux.net.cn/data/attachment/album/202007/24/212836agkae2776gude1cb.jpg) + +数码相框真的很好,因为它可以让你查看你自己的相片而不必打印出来。更棒的是,当你想要展示一张新的相片的时候,增加和删除数字图片要比打开传统的相框然后替换里面的相框更简单。不过,这还是需要一点手动的操作,比如从数字相框取出 SD 卡、U 盘或者其他的存储介质,然后把存储介质接入电脑,接着再复制图片进入存储介质。 + +一个更简单的选项是数字相框通过 WiFi 获得图片,例如从云端服务器获得。下面就是如何制作这样的一个数字相框。 + +### 需要使用的材料 + + * 老式 [TFT][1] 的 LCD 显示屏 + * HDMI 到 DVI 的转接线(因为 TFT 屏幕支持 DVI) + * 树莓派 3 + * Micro SD 卡 + * 树莓派的电源 + * 键盘 + * 鼠标(可选) + +使用线缆连接树莓派到显示器,并连接电源。 + +### 安装 Raspbian + +按照以下[指示][2]下载并将 Raspbian 烧录到 Micro SD 卡中。将 Micro SD 卡插入树莓派,启动它,并配置你的 WiFi。在安装完 Raspbian 后,我的第一个操作通常是运行 `sudo raspi-config`。在那里,我在网络选项中更改主机名(例如,改为 `picframe`),并在接口选项中启用 SSH 以远程连接到树莓派。使用(例如)`ssh pi@picframe` 连接到树莓派。 + +### 建立并安装云客户端 + +我使用 [Nextcloud][3] 来同步我的图片,但是你可以使用 NFS、[Dropbox][4],或者其他的适合你的需求的方式上传图片到相框。 + +如果你使用 Nextcloud,请按照[以下说明][5]在 Raspbian 上安装客户端。这可以很方便的放图片到你的相框,并且你可能很熟悉安装在台式机的这个客户端应用。当连接客户端到 Nextcloud 服务器上的时候,请确保只选择存储你要在相框上显示的图片的文件夹。 + +### 设置幻灯片放映 + +我发现设置幻灯片放映最简单的方式是使用一个专门为这个目的建立的[轻量级的幻灯片项目][6]。还有一些备用方案,像是配置屏保,这个应用似乎是最最简单设置幻灯片放映的方式了。 + +在你的树莓派上下载最新的二进制程序,解包并移动到一个可执行的文件夹里: + +``` +wget https://github.com/NautiluX/slide/releases/download/v0.9.0/slide_pi_stretch_0.9.0.tar.gz +tar xf slide_pi_stretch_0.9.0.tar.gz +mv slide_0.9.0/slide /usr/local/bin/ +``` + +安装依赖关系: + +``` +sudo apt install libexif12 qt5-default +``` + +通过执行下面的命令播放幻灯片(不要忘记修改图片的路径)。如果你通过 SSH 访问你树莓派,设置 `DISPLAY` 变量来在连接到树莓派显示屏上开始播放幻灯片。 + +``` +DISPLAY=:0.0 slide -p /home/pi/nextcloud/picframe +``` + +### 自动播放幻灯片 + +为了在 Raspbian Stretch 上自动播放幻灯片,建立如下的文件夹并且添加一个 `autostart` 文件到里面: + +``` +mkdir -p /home/pi/.config/lxsession/LXDE/ +vi /home/pi/.config/lxsession/LXDE/autostart +``` + +在文件中输入如下的命令来自动开启幻灯片。`slide` 命令可以调整到你需要的地方: + +``` +@xset s noblank +@xset s off +@xset -dpms +@slide -p -t 60 -o 200 -p /home/pi/nextcloud/picframe +``` + +禁止屏幕空白,树莓派通常会在 10 分钟后这样做,通过编辑下面的文件修改: + +``` +vi /etc/lightdm/lightdm.conf +``` + +添加这两行到文件末尾: + +``` +[SeatDefaults] +xserver-command=X -s 0 -dpms +``` + +### 配置上电时间 + +你可以安排你的相框什么时候打开和关闭通过使用两个简单的定时任务。例如,你想在上午 7 点自动打开,在晚上 11 点自动关闭。运行 `crontab -e` 并且输入下面的两行: + +``` +0 23 * * * /opt/vc/bin/tvservice -o +0 7 * * * /opt/vc/bin/tvservice -p && sudo systemctl restart display-manager +``` + +注意这不会打开或关闭树莓派的电源;这只会关闭 HDMI,它会关闭屏幕。第一行命令将在晚上 11 点关闭 HDMI。第二行将在早上 7 点打开显示屏并重启显示器管理器。 + +### 附言 + +通过这些简单的步骤,你创建了你自己 WiFi 相框。如果你想要让它更好看,为显示屏做一个木质相框吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/wifi-picture-frame-raspberry-pi + +作者:[Manuel Dewald][a] +选题:[lujun9972][b] +译者:[this-is-name-right](https://github.com/this-is-name-right) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ntlx +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Thin-film-transistor_liquid-crystal_display +[2]: https://www.raspberrypi.org/documentation/installation/installing-images/README.md +[3]: https://nextcloud.com/ +[4]: http://dropbox.com/ +[5]: https://github.com/nextcloud/client_theming#building-on-debian +[6]: https://github.com/NautiluX/slide/releases/tag/v0.9.0 diff --git a/published/202007/20190624 Book Review- A Byte of Vim.md b/published/202007/20190624 Book Review- A Byte of Vim.md new file mode 100644 index 0000000000..d0cbb158b6 --- /dev/null +++ b/published/202007/20190624 Book Review- A Byte of Vim.md @@ -0,0 +1,86 @@ +[#]: collector: (lujun9972) +[#]: translator: (JonnieWayy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12441-1.html) +[#]: subject: (Book Review: A Byte of Vim) +[#]: via: (https://itsfoss.com/book-review-a-byte-of-vim/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +《A Byte of Vim》书评 +====== + +[Vim][1] 是一个简单而又强大的文本编辑工具。大多数新用户都会被它吓倒,因为它不像常规的图形化文本编辑器那样“工作”。Vim “不寻常”的键盘快捷键让人不知道[如何保存并退出 Vim][2]。但一旦你掌握了 Vim,就没有什么能比得上它了。 + +网上有大量的 [Vim 资源][3]。我们也在介绍了一些 Vim 技巧。除了线上资源,也有很多书致力于介绍这个编辑器。今天,我们要介绍的是一本旨在使大多数用户轻松理解 Vim 的书。我们将讨论的书是 [Swaroop C H][5] 撰写的《[A Byte of Vim][4]》。 + +本书作者 [Swaroop C H][5] 已经在计算机领域工作了十余年,他曾在 Yahoo 和 Adobe 工作过。大学毕业后,他卖过 Linux CD,也曾多次创业,也是一个创建了一个名为 ion 的 iPod 充电器的团队的联合创始人。他目前是 [Helpshift][7] AI 团队的工程经理。 + +### 《A Byte of Vim》 + +![][8] + +像所有好书一样,《A Byte of Vim》一开始就谈到了什么是 Vim:“一个用于写各类文本的计算机程序。”他接着说:“Vim 之所以与众不同,是因为它是为数不多的既简单又强大的软件之一。” + +在深入讲解如何使用 Vim 之前,Swaroop 先告诉读者如何在 Windows、Mac、Linux 和 BSD 上安装 Vim。安装完成后,他进而指导读者完成如何启动 Vim,以及如何创建第一个文件。 + +接着,Swaroop 讨论了 Vim 的不同模式,以及如何通过 Vim 的键盘快捷键来浏览文档。接着是使用 Vim 编辑文档的基础知识,包括如何在 Vim 中剪切/复制/粘帖以及撤销/重做。 + +在介绍了编辑基础知识后,Swaroop 介绍了如何使用 Vim 来编辑单个文档的多个部分。你也可以使用多个标签和窗口来同时编辑多个文档。 + +本书还涵盖了通过编写脚本和安装插件来扩展 Vim 的功能。在 Vim 中使用脚本有两种方法,一种是使用 Vim 的内置脚本语言,另一种是使用 Python 或 Perl 等编程语言来访问 Vim 的内核。可以编写或下载五种类型的 Vim 插件:vimrc、全局插件、文件类型插件、语法高亮插件和编译器插件。 + +在一个单独的章节中,Swaroop C H 介绍了使 Vim 更适合编程的特点。这些功能包括语法高亮、智能缩进、对 Shell 命令的支持、全局补全以及可用作 IDE 使用的功能。 + +#### 获取《A Byte of Vim》一书并为之贡献 + +《A Byte of Vim》按照 [共创协议 4.0][10]授权。读者可以在[作者的主页][4]上免费阅读其在线版本。你也可以免费下载其 [PDF][11]、[Epub][12] 或者 [Mobi][13] 版本。 + +- [免费获取《A Byte of Vim》][4] + +如果你更喜欢阅读[纸质版本][14],你也可以选择该方式。 + +请注意,**《A Byte of Vim》的初始版本写于 2008**,并转换为 PDf。不幸的是,Swaroop CH丢失了原始源文件。他正在努力将该书转换为 [Markdown][15]。如果你想提供帮助,请访问[该书的 GitHub 页面][16]。 + +#### 结语 + +当我初次对着 Vim 生气时,我不知道该怎么办。我希望那时候我就知道《A Byte of Vim》这本书。对于任何学习 Linux 的人来说,这本书都是不错的资源,特别是当你开始学习命令行的时候。 + +你读过 Swaroop C H 的《[A Byte of Vim][4]》吗?如果读过,你是如何找到它的?如果不是,那么你最喜欢关于开源主题的是哪本书?请在下方评论区告诉我们。 + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/book-review-a-byte-of-vim/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[JonnieWayy](https://github.com/JonnieWayy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://www.vim.org/ +[2]: https://itsfoss.com/how-to-exit-vim/ +[3]: https://linuxhandbook.com/basic-vim-commands/ +[4]: https://vim.swaroopch.com/ +[5]: https://swaroopch.com/ +[6]: https://swaroopch.com/about/ +[7]: https://www.helpshift.com/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/06/Byte-of-vim-book.png?resize=800%2C450&ssl=1 +[9]: https://itsfoss.com/4mlinux-review/ +[10]: https://creativecommons.org/licenses/by/4.0/ +[11]: https://www.gitbook.com/download/pdf/book/swaroopch/byte-of-vim +[12]: https://www.gitbook.com/download/epub/book/swaroopch/byte-of-vim +[13]: https://www.gitbook.com/download/mobi/book/swaroopch/byte-of-vim +[14]: https://swaroopch.com/buybook/ +[15]: https://itsfoss.com/best-markdown-editors-linux/ +[16]: https://github.com/swaroopch/byte-of-vim#status-incomplete +[17]: https://i2.wp.com/images-na.ssl-images-amazon.com/images/I/41itW8furUL._SL160_.jpg?ssl=1 +[18]: https://www.amazon.com/Mastering-Vim-Quickly-WTF-time/dp/1983325740?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=1983325740 (Mastering Vim Quickly: From WTF to OMG in no time) +[19]: https://www.amazon.com/gp/prime/?tag=chmod7mediate-20 (Amazon Prime) +[20]: https://www.amazon.com/Mastering-Vim-Quickly-WTF-time/dp/1983325740?SubscriptionId=AKIAJ3N3QBK3ZHDGU54Q&tag=chmod7mediate-20&linkCode=xm2&camp=2025&creative=165953&creativeASIN=1983325740 (Buy on Amazon) +[21]: https://itsfoss.com/iridium-browser-review/ +[22]: http://reddit.com/r/linuxusersgroup diff --git a/published/202007/20190702 One CI-CD pipeline per product to rule them all.md b/published/202007/20190702 One CI-CD pipeline per product to rule them all.md new file mode 100644 index 0000000000..b093c265ef --- /dev/null +++ b/published/202007/20190702 One CI-CD pipeline per product to rule them all.md @@ -0,0 +1,133 @@ +[#]: collector: (lujun9972) +[#]: translator: (chunibyo-wly) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12392-1.html) +[#]: subject: (One CI/CD pipeline per product to rule them all) +[#]: via: (https://opensource.com/article/19/7/cicd-pipeline-rule-them-all) +[#]: author: (Willy-Peter Schaub https://opensource.com/users/wpschaub/users/bclaster/users/matt-micene/users/barkerd427) + +使用一条 CI/CD 流水线管理所有的产品 +====== + +> 统一的持续集成与持续交付的流水线的构想是一种梦想吗? + +![](https://img.linux.net.cn/data/attachment/album/202007/07/224752iib7xgh7icr8478f.jpg) + +当我加入 WorkSafeBC 负责云端运维和工程流程优化的云端运维团队时,我和大家分享了我的梦想,那就是一个工具化的流水线,每一个产品都可以持续集成和持续交付。 + +根据 Lukas Klose 的说法,[流程][2]flow(在软件工程的语境内)是“软件系统以稳定和可预测的速度创造价值的状态”。我认为这是最大的挑战和机遇之一,特别是在复杂的新兴解决方案领域。我力求通过一种持续、高效和优质的解决方案,提供一种持续交付模式,并且能够构建正确的事物让我们的用户感到满意。想办法把我们的系统分解成更小的碎片,这些碎片本身是有价值的,使团队能够渐进式地交付价值。这需要业务和工程部门改变思维方式。 + +### 持续集成和持续交付的(CI/CD)流水线 + +CI/CD 流水线是一种 DevOps 实践,用于更频繁、一致、可靠的地交付代码变更。它可以帮助敏捷开发团队提高**部署频率**,减少**变更准备时间**、**变更失败率**和关键绩效指标(KPI)的**平均恢复时间**,从而提高质量并且实现更快的交付。唯一的先决条件就是坚实的开发流程、对质量的心态和对需求从构想到废弃的责任心,以及一个全面的流水线(如下图所示)。 + +![Prerequisites for a solid development process][3] + +它简化了工程流程和产品,以稳定基础架构环境;优化工作流程;并创建一致的、可重复的、自动化的任务。正如 Dave Snowden 的 [Cynefin Sensemaking][4] 模型所说的那样,这样就允许我们将复杂不可解决的任务变成了复杂可解决的任务,降低了维护成本,提高了质量和可靠性。 + +精简流程的一部分是将 [浪费实践类型][5]wasteful practice types Muri(过载)、Mura(变异)和 Muda(浪费)的浪费降低最低。 + + * **Muri(过载)**:避免过度工程化,避免与商业价值不相关的功能以及过多的文档。 + * **Mura(变异)**:改善审批和验证流程(比如,安全签批);推动 [左移提前][6]shift-left 策略以推行单元测试、安全漏洞扫描与代码质量检查;并改进风险评定。 + * **Muda(浪费)**:避免技术债、错误或前期的详细文档等浪费。 + +看起来 80% 的重点都集中在提供一种可以集成和协作的工程产品上,这些系统可以采用一个创意和计划、开发、测试和监控你的解决方案。然而,一个成功的转型和工程系统是由 5% 的产品、15% 的过程和 80% 的开发人员组成的。 + +我们可以使用的产品有很多。比如,Azure DevOps 为持续集成(CI)、持续交付(CD)和可扩展性提供了丰富支持,并与 Stryker、SonarQube、WhiteSource、Jenkins 和 Octopus 等开源集成和商用成品(COTS)软件即服务(SaaS)进行集成。对于工程师来说,关注产品总是一种诱惑,但请记住,它们只是我们旅程的 5%。 + +![5% about products, 15% about process, 80% about people][7] + +最大的挑战是打破数十年的规则、规定和已经步入舒适区的流程:“*我们一直都是这样做的;为什么需要改变呢?*” + +开发和运维人员之间的摩擦导致了各种支离破碎的、重复的、不间断的集成和交付流水线。开发人员希望能访问所有东西,以便持续迭代,让用户使用起来和持续地快速发布。运维人员希望将所有东西锁起来,保护业务、用户和品质。这些矛盾在不经意间导致了很难做到一种自动化的流程,进而导致发布周期晚于预期。 + +让我们使用最近的一次白板讨论中的片段来探索流水线。 + +想要支持流水线的变化是一项困难并且花费巨大的工作;版本和可追溯性的不一致使得这个问题变得更加复杂,因此不断精简开发流程和流水线是一项挑战。 + +![Improving quality and visibility of pipelines][8] + +我主张一些原则使得每个产品都能使用通用流水线: + + * 使一切可自动化的东西都自动化 + * 一次构建 + * 保持持续集成和持续交付 + * 保持持续精简和改进 + * 保持一个构建的定义 + * 保持一个发布流水线的定义 + * 尽早、频繁地扫描漏洞,并且*尽快失败* + * 尽早、频繁地进行测试,并且*尽快失败* + * 保持已发布版本的可追踪和监控 + +但是,如果我要打破这些,最重要的原则就是*保持简单*。如果你不能说明流水线化的原因(是什么、为什么)和过程(如何),你或许是不了解自己的软件过程的。我们大多数人想要的不是最好的、超现代的和具有革命意义的流水线 —— 我们仅仅是需要一个功能强大的、有价值的和能促进工程的流水线。首先需要解决的是那 80% —— 文化、人员和他们的心态。请你的 CI/CD 骑士们穿上闪亮的盔甲,在他们的盾牌上贴上 TLA(两个/三个字母的缩写two/three-lettered acronym)符号,加入到实践和经验工程的力量中来。 + +### 统一流水线 + +让我们逐步完成我们的白板会议实践。 + +![CI build/CD release pipeline][9] + +每个应用使用一套构建定义来定义一个 CI/CD 流水线,用来触发*拉取请求的预合并验证*与*持续集成*的构建。生成一个带有调试信息的*发布*的构建,并且将其上传到 [符号服务器][10]。这使开发人员可以在本地和远程生产环境进行调试,而在不用考虑需要加载哪个构建和符号,符号服务器为我们施展了这样的魔法。 + +![Breaking down the CI build pipeline][11] + +在构建过程中进行尽可能多的验证(*左移提前*),这允许开发新特性的团队可以尽快失败,不断的提高整体的产品质量,并在拉取请求中为代码审核人员提供宝贵证据。你喜欢有大量提交的拉取请求吗?还是一个带有少数提交和提供了漏洞检查、测试覆盖率、代码质量检查和 [Stryker][12] 突变残余等支持的拉取请求?就我个人而言,我投后者的票。 + +![Breaking down the CD release pipeline][13] + +不要使用构建转换来生成多个特定环境的构建。通过一个构建实现*发布时转换*、*标记化*和 XML/JSON 的*值替换*。换句话说,*右移滞后*具体环境的配置。 + +![Shift-right the environment-specific configuration][14] + +安全存储发布配置数据,并且根据数据的*信任度*和*敏感度*,让开发和运维都能使用。使用开源的密钥管理工具、Azure 密钥保险库、AWS 密钥管理服务或者其他产品,记住你的工具箱中有很多方便的工具。 + +![Dev-QA-production pipeline][15] + +使用*用户组*而不是*用户*,将审批人管理从跨多个流水线的多个阶段移动到简单的组成员。 + +![Move approver management to simple group membership][16] + +创建一条流水线并且对赋予特定的交付阶段的权限,而不是重复流水线让团队进入他们感兴趣的地方。 + +![Pipeline with access to specific delivery stages][17] + +最后,但并非最不重要的是,拥抱拉取请求,以帮助提高对代码仓库的洞察力和透明度,增进整体质量、协作,并将预验证构建发布到选定的环境,比如,开发环境。 + +这是整个白板更正式的视图。 + +![The full pipeline][18] + +所以,你对 CI/CD 流水线有什么想法和经验?我的通过*一条流水线来管理它们*的这个梦想是空想吗? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/7/cicd-pipeline-rule-them-all + +作者:[Willy-Peter Schaub][a] +选题:[lujun9972][b] +译者:[chunibyo-wly](https://github.com/chunibyo-wly) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/wpschaub/users/bclaster/users/matt-micene/users/barkerd427 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe (An intersection of pipes.) +[2]: https://continuingstudies.sauder.ubc.ca/courses/agile-delivery-methods/ii861 +[3]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-2.png (Prerequisites for a solid development process) +[4]: https://en.wikipedia.org/wiki/Cynefin_framework +[5]: https://www.lean.org/lexicon/muda-mura-muri +[6]: https://en.wikipedia.org/wiki/Shift_left_testing +[7]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-3.png (5% about products, 15% about process, 80% about people) +[8]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-4_0.png (Improving quality and visibility of pipelines) +[9]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-5_0.png (CI build/CD release pipeline) +[10]: https://en.wikipedia.org/wiki/Microsoft_Symbol_Server +[11]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-6.png (Breaking down the CI build pipeline) +[12]: https://stryker-mutator.io/ +[13]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-7.png (Breaking down the CD release pipeline) +[14]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-8.png (Shift-right the environment-specific configuration) +[15]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-9.png (Dev-QA-production pipeline) +[16]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-10.png (Move approver management to simple group membership) +[17]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-11.png (Pipeline with access to specific delivery stages) +[18]: https://opensource.com/sites/default/files/uploads/devops_pipeline_pipe-12.png (The full pipeline) diff --git a/published/202007/20190808 Sending custom emails with Python.md b/published/202007/20190808 Sending custom emails with Python.md new file mode 100644 index 0000000000..d27fc38226 --- /dev/null +++ b/published/202007/20190808 Sending custom emails with Python.md @@ -0,0 +1,268 @@ +[#]: collector: (lujun9972) +[#]: translator: (silentdawn-zz) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12452-1.html) +[#]: subject: (Sending custom emails with Python) +[#]: via: (https://opensource.com/article/19/8/sending-custom-emails-python) +[#]: author: (Brian "bex" Exelbierd https://opensource.com/users/bexelbie) + +使用 Mailmerge 发送定制邮件 +====== + +> Mailmerge 是一个可以定制群发邮件的命令行程序,它可以处理简单和复杂的邮件。 + +![](https://img.linux.net.cn/data/attachment/album/202007/25/233710lqkvko0jdbh1jzul.jpg) + +电子邮件还是生活的一部分,尽管有种种不足,它仍然是大多数人发送信息的最佳方式,尤其是在按队列将邮件发送给收件人的自动化方式中。 + +作为 [Fedora 社区行动和影响协调员][2],我的工作之一就是给人们发送资助旅行相关的好消息,我经常通过电子邮件做这些事。这里,我将给你展示如何使用 [Mailmerge][3] 向一群人发送定制邮件的,Mailmerge 是一个可以处理简单和复杂的邮件的命令行程序。 + +### 安装 Mailmerge + +在 Fedora 中,Mailmerge 已经打包可用,你可以通过在命令行中运行 `sudo dnf install python3-mailmerge` 来安装它。你还可以使用 `pip` 命令从 PyPi 中安装,具体可以参阅该项目的 [README][4]。 + +### 配置 Mailmerge + +三个配置文件控制着 Mailmerge 的工作模式。运行 `mailmerge --sample`,将生成配置文件模板。这些文件包括: + + * `mailmerge_server.conf:` 这里保存着 SMTP 服务端邮件发送相关详细配置,但你的密码 *不* 在这里保存。 + * `mailmerge_database.csv:` 这里保存每封邮件的定制数据,包括收件人的电子邮件地址。 + * `mailmerge_template.txt:` 这里保存电子邮件的文本,文本中包含占位符,这些占位符会使用 `mailmerge_database.csv` 中的数据替换。 + +#### Server.conf + +配置模板文件 `mailmerge_server.conf` 包含几个大家应该很熟悉的例子。如果你曾经往手机上添加过电子邮件或者设置过桌面电子邮件客户端,那你就应该看到过这些数据。需要提醒的是要记得把你的用户名更新到这个文件中,尤其是在你使用模板所提供的配置时。 + +#### Database.csv + +`mailmerge_database.csv` 这个配置文件稍微有点复杂。最起码要将邮件接收者的电子邮件地址保存在这里,其它在电子邮件中任何需要替换的定制信息也要保存在这里。推荐在创建本文件的占位符列表时,同步编辑 `mailmerge_template.txt` 文件。我发现一个有效的做法是,使用电子表格软件录入这些数据,完成后导出为 CSV 文件。使用下面的示例文件: + +``` +email,name,number +myself@mydomain.com,"Myself",17 +bob@bobdomain.com,"Bob",42 +``` + +可以你向这两个人发送电子邮件,使用他们的名字并告诉他们一个数字。这个示例文件虽然不是特别有趣,但应用了一个重要的原则,那就是:始终让自己处于邮件接收列表的首位。这样你可以在向列表全员发送邮件之前,先给自己发送一个测试邮件,以验证邮件的效果是否如你预期。 + +任何包含半角逗号的值,都 **必须** 以半角双引号(`"`)封闭。如果恰好在半角双引号封闭的区域需要有一个半角双引号,那就在同一行中连续使用两个半角双引号。引号的规则比较有趣,去 [Python 3 中关于 CSV 的内容中][7] 一探究竟吧。 + +#### Template.txt + +我的工作之一,就是为我们 Fedora 贡献者会议 [Flock][8] 发送与旅行基金有关的信息。通过简单的邮件告诉有关的人,他被选中为旅行基金支持的幸运者,以及相应基金支持的详细信息。与接收者相关的具体信息之一就是我们可以为他的旅行提供多少资助。下面是一份我的节略后的模板文件(为了简洁,已经移除大量的文本): + +``` +$ cat mailmerge_template.txt +TO: {{Email}} +SUBJECT: Flock 2019 Funding Offer +FROM: Brian Exelbierd + + +Hi {{Name}}, + + +I am writing you on behalf of the Flock funding committee. You requested funding for your attendance at Flock. After careful consideration we are able to offer you the following funding: + + +Travel Budget: {{Travel_Budget}} + + +<> +``` + +模板的起头定义了邮件的接收者、发送者和主题。在空行之后,是邮件的内容。该邮件需要从 `database.csv` 文件中获取接收者的 `Email` 、`Name` 和 `Travel_Budget` 。注意,上述这些占位符是由双大括弧( `{{`、`}}` )封闭的。相应的 `mailmerge_database.csv` 如下: + +``` +$ cat mailmerge_database.csv +Name,Email,Travel_Budget +Brian,bexelbie@redhat.com,1000 +PersonA,persona@fedoraproject.org,1500 +PèrsonB,personb@fedoraproject.org,500 +``` + +注意,我把自己的信息放在了首条,这是为了测试方便。除了我,还有另外两个人的信息在文档中。列表中的第二个人 PèrsonB,他的名字中有一个包含变音符号的字母,Mailmerge 会对这类字母自动编码。 + +以上包含了模板的全部知识点:写上你自己的电子邮件信息,并编写好以双大括弧封闭的占位符。接下来创建用来提供前述占位符具体值的数据文件。现在测试一下电子邮件的效果。 + +### 测试并发送简单邮件 + +#### 试运行 + +测试从邮件的试运行开始,试运行就是讲邮件内容显示出来,所有的占位符都会被具体值取代。默认情况下,如果你运行不带参数的命令 `mailmerge`,它将对收件列表中的第一个人进行试运行: + +``` +$ mailmerge +>>> encoding ascii +>>> message 0 +TO: bexelbie@redhat.com +SUBJECT: Flock 2019 Funding Offer +FROM: Brian Exelbierd +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +Date: Sat, 20 Jul 2019 18:17:15 -0000 + + +Hi Brian, + + +I am writing you on behalf of the Flock funding committee. You requested funding for your attendance at Flock. After careful consideration we are able to offer you the following funding: + + +Travel Budget: 1000 + + +<> + + +>>> sent message 0 DRY RUN +>>> No attachments were sent with the emails. +>>> Limit was 1 messages. To remove the limit, use the --no-limit option. +>>> This was a dry run. To send messages, use the --no-dry-run option. +``` + +从试运行生成的邮件中(列表中的 `message 0` ,和计算机中很多计数场景一样,计数从 0 开始),可以看到我的名字及旅行预算是正确的。如果你想检视所有的邮件,运行 `mailmerge --no-limit`,告诉 Mailmerge 不要仅仅处理第一个收件人的信息。下面是第三个收件人邮件的试运行结果,用来测试特殊字符的编码: + +``` +>>> message 2 +TO: personb@fedoraproject.org +SUBJECT: Flock 2019 Funding Offer +FROM: Brian Exelbierd +MIME-Version: 1.0 +Content-Type: text/plain; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable +Date: Sat, 20 Jul 2019 18:22:48 -0000 + + +Hi P=E8rsonB, +``` + +没有问题,`P=E8rsonB` 是 `PèrsonB` 的编码形式。 + +#### 发送测试信息 + +现在,运行 `mailmerge --no-dry-run`,Mailmerge 将向收件人列表中的第一个人发送电子邮件: + +``` +$ mailmerge --no-dry-run +>>> encoding ascii +>>> message 0 +TO: bexelbie@redhat.com +SUBJECT: Flock 2019 Funding Offer +FROM: Brian Exelbierd +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +Date: Sat, 20 Jul 2019 18:25:45 -0000 + + +Hi Brian, + + +I am writing you on behalf of the Flock funding committee. You requested funding for your attendance at Flock. After careful consideration we are able to offer you the following funding: + + +Travel Budget: 1000 + + +<> + + +>>> Read SMTP server configuration from mailmerge_server.conf +>>> host = smtp.gmail.com +>>> port = 587 +>>> username = bexelbie@redhat.com +>>> security = STARTTLS +>>> password for bexelbie@redhat.com on smtp.gmail.com: +>>> sent message 0 +>>> No attachments were sent with the emails. +>>> Limit was 1 messages. To remove the limit, use the --no-limit option. +``` + +在倒数第 4 行,它将要求你输入你的密码。如果你使用的是双因素认证或者域控制登录,那就需要创建应用密码来绕过这些控制。如果你使用的是 Gmail 或者类似的系统,可以直接在界面上完成密码验证。如果不行的话,联系你的邮件系统管理员。上述这些操作不会影响邮件系统的安全性,但是仍然有必要采用复杂的安全性好的密码。 + +我在我的邮件收件箱中,看到了这封格式美观的测试邮件。如果测试邮件看起来没有问题,那就可以运行 `mailmerge --no-dry-run --no-limit` 发送所有的邮件了。 + +### 发送复杂邮件 + +只有充分了解了 [Jinja2 模板][12] ,你才可能充分领略 Mailmerge 真正的威力。在邮件模板中使用条件语句及附带附件,是很有用的。下面就是一个复杂邮件的模板及对应的数据文件: + +``` +$ cat mailmerge_template.txt +TO: {{Email}} +SUBJECT: Flock 2019 Funding Offer +FROM: Brian Exelbierd +ATTACHMENT: attachments/{{File}} + + +Hi {{Name}}, + + +I am writing you on behalf of the Flock funding committee. You requested funding for your attendance at Flock. After careful consideration we are able to offer you the following funding: + + +Travel Budget: {{Travel_Budget}} +{% if Hotel == "Yes" -%} +Lodging: Lodging in the hotel Wednesday-Sunday (4 nights) +{%- endif %} + + +<> + + +$ cat mailmerge_database.csv +Name,Email,Travel_Budget,Hotel,File +Brian,bexelbie@redhat.com,1000,Yes,visa_bex.pdf +PersonA,persona@fedoraproject.org,1500,No,visa_person_a.pdf +PèrsonB,personb@fedoraproject.org,500,Yes,visa_person_b.pdf +``` + +在这个邮件中有两项新内容。首先是附件,我需要向参加国际旅行的人发送签证邀请信,帮助他们来 Flock,文件头的 `ATTACHMENT` 部分说明了要包含什么文件;为了保持我的文档目录清晰,我将所有需要作为附件的文档保存于附件子目录下。其次是包含了关于宾馆的条件信息,因为有些人的旅行资金包含了住宿费用,我需要对涉及住宿的人员诉及相关信息,而这是通过 `if` 判断实现的: + +``` +{% if Hotel == "Yes" -%} +Lodging: Lodging in the hotel Wednesday-Sunday (4 nights) +{%- endif %} +``` + +这和大多数编程语言中的 `if` 判断是一样的。Jinja2 实力非凡,可以实现多级判断。通过包含数据元素控制邮件内容,能大大简化相关的日常工作。空格的正确使用对邮件的易读性很重要。`if` 和 `endif` 语句中的短线( `-` )是 Jinja2 控制 [空白字符][13] 的一部分。这里面选项很多,所以还是要通过试验找到最适合自己的方式。 + +在上面的例子中,我在数据文件扩充了 `Hotel` 和 `File` 两个字段,这些字段的值控制着宾馆信息和附件文件名。另外,在上例中,我和 PèrsonB 有住宿资助,但 PersonA 没有。 + +对于简单邮件和复杂邮件而言,试运行及正式发送邮件的操作都是相同的。快去试试吧! + +你还可以尝试在邮件头中使用条件判断( `if` … `endif` ),比如你可以使发送给在数据库中的某人的邮件包含附件,或者改变对部分人改变发送人的信息。 + +### Mailmerge 的优点 + +Mailmerge 是用来批量发送定制邮件的简洁而高效的工具。每个人只接受到他需要的信息,其它额外的操作和细节都是透明的。 + +我还发现,即使是在发送简单的集团邮件时,相对于使用 CC 或者 BCC 向一组受众发送一封邮件,采用 Mailmerge 也是非常高效的。很多人使用了邮件过滤,那些不是直接发给他们的邮件,他们一律不会立刻处理。使用 Mailmerge 保证了每名接收者收到的就是自己的邮件。所有的信息会对接收者进行正确过滤,再也不会有人无意间回复到整个邮件组。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/8/sending-custom-emails-python + +作者:[Brian "bex" Exelbierd][a] +选题:[lujun9972][b] +译者:[silentdawn-zz](https://github.com/silentdawn-zz) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bexelbie +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_chat_communication_message.png?itok=LKjiLnQu (Chat via email) +[2]: https://docs.fedoraproject.org/en-US/council/fcaic/ +[3]: https://github.com/awdeorio/mailmerge +[4]: https://github.com/awdeorio/mailmerge#install +[5]: mailto:myself@mydomain.com +[6]: mailto:bob@bobdomain.com +[7]: https://docs.python.org/3/library/csv.html +[8]: https://flocktofedora.org/ +[9]: mailto:bexelbie@redhat.com +[10]: mailto:persona@fedoraproject.org +[11]: mailto:personb@fedoraproject.org +[12]: http://jinja.pocoo.org/docs/latest/templates/ +[13]: http://jinja.pocoo.org/docs/2.10/templates/#whitespace-control diff --git a/published/202007/20191031 4 Python tools for getting started with astronomy.md b/published/202007/20191031 4 Python tools for getting started with astronomy.md new file mode 100644 index 0000000000..e197bd3721 --- /dev/null +++ b/published/202007/20191031 4 Python tools for getting started with astronomy.md @@ -0,0 +1,70 @@ +[#]: collector: (lujun9972) +[#]: translator: (silentdawn-zz) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12459-1.html) +[#]: subject: (4 Python tools for getting started with astronomy) +[#]: via: (https://opensource.com/article/19/10/python-astronomy-open-data) +[#]: author: (Gina Helfrich, Ph.D. https://opensource.com/users/ginahelfrich) + +开启天文之路的 4 个 Python 工具 +====== + +> 使用 NumPy、SciPy、Scikit-Image 和 Astropy 探索宇宙 + +![](https://img.linux.net.cn/data/attachment/album/202007/27/223146sjfgbj9jfu9m1z2c.jpg) + +### 天文学与 Python + +对科学界而言,尤其是对天文学界来说,Python 是一种伟大的语言工具。各种软件包,如 [NumPy][5]、[SciPy][6]、[Scikit-Image][7] 和 [Astropy][8],(仅举几例) ,都充分证明了 Python 对天文学的适用性,而且有很多用例。(NumPy、Astropy 和 SciPy 是 NumFOCUS 提供资金支持的项目;Scikit-Image 是个隶属项目)。我在十几年前脱离天文研究领域,成为了软件开发者之后,对这些工具包的演进一直很感兴趣。我的很多前天文界同事在他们的研究中,使用着前面提到的大部分甚至是全部工具包。以我为例,我也曾为位于智利的超大口径望远镜(VLT)上的仪器编写过专业天文软件工具包。 + +最近令我吃惊的是,Python 工具包竟然演进到如此好用,任何人都可以轻松编写 [数据还原][9]data reduction 脚本,产生出高质量的数据产品。天文数据易于获取,而且大部分是可以公开使用的,你要做的只是去寻找相关数据。 + +比如,负责 VLT 运行的 ESO,直接在他们的网站上提供数据下载服务,只要访问 [www.eso.org/UserPortal][10] 并在首页创建用户就可以享有数据下载服务。如果你需要 SPHERE 数据,可以下载附近任何一个包含系外行星exoplanet或者原恒星盘proto-stellar discs的恒星的全部数据集。对任何 Python 高手而言,通过还原数据发现深藏于噪声中的行星或者原恒星盘,实在是件令人兴奋的事。 + +我鼓励你下载 ESO 或其它天文影像数据,开启你的探索历程。这里提供几条建议: + +1. 首先要有一个高质量的数据集。看一些有关包含系外行星或者原恒星盘的较近恒星的论文,然后在 之类的网站检索数据。需要注意的是,前述网站上的数据有的标注为红色,有的标注为绿色,标注为红色的数据是尚未公开的,在相应的“发布日期”处会注明数据将来公开的时间。 +2. 了解一些用于获取你所用数据的仪器的信息。尽量对数据的获取有一个基本的理解,对标准的数据还原之后应该是什么样子做到心中有数。所有的望远镜和仪器都有这方面的文档供公开获取。 +3. 必须考虑天文数据的标准问题,并予以校正: + + 1. 数据以 FITS 格式文件保存。需要使用 `pyfits` 或者 `astropy` (包含 `pyfits` )将其读入到 `NumPy` 数组。有些情况下,数据是三维的,需要沿 z 轴使用 `numpy.median` 将数据转换为二维数组。有些 SPHERE 数据在同一幅影像中包含了同一片天空的两份拷贝(各自使用了不同的滤波器),这时候需要使用 **索引** 和 **切片** 将它们分离出来。 + 2. 全黑图master dark坏点图bad pixel map。所有仪器都有快门全关(完全无光)状态拍摄的特殊图片,使用 **NumPy 掩膜数组** 从中分离出坏点图。坏点图非常重要,你在合成最终的清晰图像过程中,需要持续跟踪坏点。有些情况下,这还有助于你从原始科学数据中扣除暗背景的操作。 + 3. 一般情况下,天文仪器还要拍标准响应图master flat frame。这是对均匀的单色标准光源拍摄的一张或者一组图片。你需要将所有的原始数据除以标准响应之后再做后续处理(同样,使用 Numpy 掩膜数组实现的话,这仅仅是一个简单的除法运算)。 + 4. 对行星影像,为了使行星在明亮恒星背景下变得可见,需要仰仗日冕仪coronagraph角差分成像angular differential imaging技术。这一步需要识别影像的光学中心,这是比较棘手的环节之一,过程中要使用 `skimage.feature.blob_dog` 从原始影像中寻找一些人工辅助影像作为帮助。 +4. 要有耐心。理解数据格式并弄清如何操作需要一些时间,绘出像素数据曲线图或者统计图有助于你的理解。贵在坚持,必有收获!你会从中学到很多关于图像数据及其处理的知识。 + +综合应用 NumPy、SciPy、Astropy、scikit-image 及其它工具,结合耐心和恒心,通过分析大量可用的天文数据分析实现重大的发现是非常有可能的。说不定,你会成为某个之前被忽略的系外行星的第一发现者呢。祝你好运! + +--- + +NumFOCUS 是个非盈利组织,维护着一套科学计算与数据科学方面的杰出开源工具集。如果想了解我们的任务及代码,可以访问 [numfocus.org][3]。如果你有兴趣以个人身份加入 NumFOCUS 社区,可以关注你所在地区的 [PyData 活动][4]。 + +本文基于 Pivigo CTO [Ole Moeller-Nilsson][12] 的一次 [谈话][11],最初发布于 NumFOCUS 的博客,蒙允再次发布。如果你有意支持 NumFOCUS,可以 [捐赠][13],也可以参与遍布全球的 [PyData 活动][4] 中你身边的那些。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/python-astronomy-open-data + +作者:[Gina Helfrich, Ph.D.][a] +选题:[lujun9972][b] +译者:[silentdawn-zz](https://github.com/silentdawn-zz) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ginahelfrich +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/space_stars_cosmos_person.jpg?itok=XUtz_LyY (Person looking up at the stars) +[2]: https://numfocus.org/blog +[3]: https://numfocus.org +[4]: https://pydata.org/ +[5]: http://numpy.scipy.org/ +[6]: http://www.scipy.org/ +[7]: http://scikit-image.org/ +[8]: http://www.astropy.org/ +[9]: https://en.wikipedia.org/wiki/Data_reduction +[10]: http://www.eso.org/UserPortal +[11]: https://www.slideshare.net/OleMoellerNilsson/pydata-lonon-finding-planets-with-python +[12]: https://twitter.com/olly_mn +[13]: https://numfocus.org/donate diff --git a/published/202007/20200103 What you need to know about Rust in 2020.md b/published/202007/20200103 What you need to know about Rust in 2020.md new file mode 100644 index 0000000000..50a2b02f43 --- /dev/null +++ b/published/202007/20200103 What you need to know about Rust in 2020.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (JonnieWayy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12469-1.html) +[#]: subject: (What you need to know about Rust in 2020) +[#]: via: (https://opensource.com/article/20/1/rust-resources) +[#]: author: (Ryan Levick https://opensource.com/users/ryanlevick) + +2020 年关于 Rust 你所需要知道的 +====== + +> 尽管许多程序员长期以来一直将 Rust 用于业余爱好项目,但正如许多有关 Rust 的热门文章所解释的那样,该语言在 2019 年吸引了主要技术公司的支持。 + +![](https://img.linux.net.cn/data/attachment/album/202007/31/001101fkh88966ktvvee99.jpg) + +一段时间以来, [Rust][2] 在诸如 Hacker News 之类的网站上引起了程序员大量的关注。尽管许多人一直喜欢在业余爱好项目中[使用该语言][3],但直到 2019 年它才开始在业界流行,直到那会儿情况才真正开始有所转变。 + +在过去的一年中,包括[微软][4]、 [Facebook][5] 和 [Intel][6] 在内的许多大公司都出来支持 Rust,许多[较小的公司][7]也注意到了这一点。2016 年,作为欧洲最大的 Rust 大会 [RustFest][8] 的第一任主持人,除了 Mozilla,我没见到任何一个人在工作中使用 Rust。三年后,似乎我在 RustFest 2019 所交流的每个人都在不同的公司的日常工作中使用 Rust,无论是作为游戏开发人员、银行的后端工程师、开发者工具的创造者或是其他的一些岗位。 + +在 2019 年, Opensource.com 也通过报道 Rust 日益增长的受欢迎程度而发挥了作用。万一你错过了它们,这里是过去一年里 Opensource.com 上关于 Rust 的热门文章。 + +### 《使用 rust-vmm 构建未来的虚拟化堆栈》 + +Amazon 的 [Firecracker][9] 是支持 AWS Lambda 和 Fargate 的虚拟化技术,它是完全使用 Rust 编写的。这项技术的作者之一 Andreea Florescu 在 《[使用 rust-vmm 构建未来的虚拟化堆栈][10]》中对 Firecracker 及其相关技术进行了深入探讨。 + +Firecracker 最初是 Google [CrosVM][11] 的一个分支,但是很快由于两个项目的不同需求而分化。尽管如此,在这个项目与其他用 Rust 所编写的虚拟机管理器(VMM)之间仍有许多得到了很好共享的通用片段。考虑到这一点,[rust-vmm][12] 项目起初是以一种让 Amazon 和 Google、Intel 和 Red Hat 以及其余开源社区去相互共享通用 Rust “crates” (即程序包)的方式开始的。其中包括 KVM 接口(Linux 虚拟化 API)、Virtio 设备支持以及内核加载程序。 + +看到软件行业的一些巨头围绕用 Rust 编写的通用技术栈协同工作,实在是很神奇。鉴于这种和其他[使用 Rust 编写的技术堆栈][13]之间的伙伴关系,到了 2020 年,看到更多这样的情况我不会感到惊讶。 + +### 《为何选择 Rust 作为你的下一门编程语言》 + +采用一门新语言,尤其是在有着建立已久技术栈的大公司,并非易事。我很高兴写了《[为何选择 Rust 作为你的下一门编程语言][14]》,书中讲述了微软是如何在许多其他有趣的编程语言没有被考虑的情况下考虑采用 Rust 的。 + +选择编程语言涉及许多不同的标准——从技术上到组织上,甚至是情感上。其中一些标准比其他的更容易衡量。比方说,了解技术变更的成本(例如适应构建系统和构建新工具链)要比理解组织或情感问题(例如高效或快乐的开发人员将如何使用这种新语言)容易得多。此外,易于衡量的标准通常与成本相关,而难以衡量的标准通常以收益为导向。这通常会导致成本在决策过程中变得越来越重要,即使这不一定就是说成本要比收益更重要——只是成本更容易衡量。这使得公司不太可能采用新的语言。 + +然而,Rust 最大的好处之一是很容易衡量其编写安全且高性能系统软件的能力。鉴于微软 70% 的安全漏洞是由于内存安全问题导致的,而 Rust 正是旨在防止这些问题的,而且这些问题每年都使公司付出了几十亿美元的代价,所以很容易衡量并理解采用这门语言的好处。 + +是否会在微软全面采用 Rust 尚待观察,但是仅凭着相对于现有技术具有明显且可衡量的好处这一事实,Rust 的未来一片光明。 + +### 2020 年的 Rust + +尽管要达到 C++ 等语言的流行度还有很长的路要走。Rust 实际上已经开始在业界引起关注。我希望更多公司在 2020 年开始采用 Rust。Rust 社区现在必须着眼于欢迎开发人员和公司加入社区,同时确保将推动该语言发展到现在的一切都保留下来。 + +Rust 不仅仅是一个编译器和一组库,而是一群想要使系统编程变得容易、安全而且有趣的人。即将到来的这一年,对于 Rust 从业余爱好语言到软件行业所使用的主要语言之一的转型至关重要。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/1/rust-resources + +作者:[Ryan Levick][a] +选题:[lujun9972][b] +译者:[JonnieWayy](https://github.com/JonnieWayy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ryanlevick +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: http://rust-lang.org/ +[3]: https://insights.stackoverflow.com/survey/2019#technology-_-most-loved-dreaded-and-wanted-languages +[4]: https://youtu.be/o01QmYVluSw +[5]: https://youtu.be/kylqq8pEgRs +[6]: https://youtu.be/l9hM0h6IQDo +[7]: https://oxide.computer/blog/introducing-the-oxide-computer-company/ +[8]: https://rustfest.eu +[9]: https://firecracker-microvm.github.io/ +[10]: https://opensource.com/article/19/3/rust-virtual-machine +[11]: https://chromium.googlesource.com/chromiumos/platform/crosvm/ +[12]: https://github.com/rust-vmm +[13]: https://bytecodealliance.org/ +[14]: https://opensource.com/article/19/10/choose-rust-programming-language diff --git a/published/202007/20200428 Open source has room for everyone.md b/published/202007/20200428 Open source has room for everyone.md new file mode 100644 index 0000000000..38fe8f56fd --- /dev/null +++ b/published/202007/20200428 Open source has room for everyone.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12399-1.html) +[#]: subject: (Open source has room for everyone) +[#]: via: (https://opensource.com/article/20/4/interview-Megan-Byrd-Sanicki) +[#]: author: (Jay Barber https://opensource.com/users/jaybarber) + +开源代码广阔天地造福人类 +====== + +> 了解 2020 年开源社区女性奖获得者 Megan Byrd-Sanicki 如何将人们聚集在一起。 + +![蒲公英般浮于水面][1] + +“在成长的过程中,我曾经有点像陆军元帅,” 2020 年[开源社区女性奖获得者][2] Megan Byrd-Sanicki 笑着说。“我总是那个把同学们拉到一起的人。‘大家来吧,我们告诉你们规则。’我也会注意旁听,尝试找出没有被接纳进来的人,并把他们拉进圈子。” + +![Megan Sanicki 的照片, 已经许可使用][3] + +这种将人们聚集在一起,并为他们建立一个组织,让他们表现出色的动力贯穿了她的大部分职业生涯和社区工作。“我回想起二年级体育课上的我,不得不承认,今天的我依然是这样的人。” + +作为第一任 [Drupal 协会][4]执行主任,Megan 十年来活跃于开源社区,现在是谷歌开源项目办公室的研发和运营主管。“我很幸运能担任这个职位,因为它可以让我看到谷歌 2000 多个不同目标、不同治理结构、不同策略的开源项目。这个也是难得的学习机会。” Megan 最近被推选为 [开源代码促进会][5]的董事会成员,她努力加强该组织为全球项目和企业提供的开源领导力。 + +### 从地下室台阶上学到的知识 + +Megan 原以为她会从商,远离循规的技术。坐在地下室台阶上,耳濡目染父亲的销售电话,到 16 岁时候就知道父亲的所有产品系列,也熟悉了其他知识。 + +“我从父亲学到了做生意就是解决问题和帮助别人” Megan 说。“在我的职业生涯这个信念我始终放在第一位。在某些角度看选择这条路我并不觉得奇怪;这是我个人选择的自然延伸,但它也把我带到了我从未梦想过的地方。” + +开源事业对 Megan 不仅仅是一个职业;她在她的社区活动中也使用同样的理念。“现在,我正在与 [Covid Act Now][6] 的一大群优秀的工程师、数据科学家以及流行病科学家合作。团队成员是义务提供他们的专业知识,公开合作,为政府公共人员提供数据建模,以便他们快速的做出有效的决策。” + +她也活跃于 [FOSS Responders][7],这是一个为受 COVID-19 事件影响的开源项目和社区成员点亮温暖的组织。“在疫情期间,项目很难得到他们需要的帮助。我们可以帮忙需要帮忙的组织和个人扩散他们的请求。”这个组织的一个重要的事务是管理 [FOSS Responders 基金][7],这是一个寻求开源项目基金的融资需求的机制,避免社区衰亡。 + +### 在这不断变化的世界中一群可爱的人 + +影响 Megan 参与到社区的两个宗旨分别是对开源的明确承诺和把大家团结在一起的动力。“人们有梦想的时候,他们就积极的去实现它,这就造就了共同的信念和强烈的 ‘为什么’。人们很容易围绕着‘为什么’参与其中。我知道我是这样做的。” Megan 在被问到她这么努力时说到。 + +“不管是帮助 Drupal 基金会筹集资金的任务还是赋能开源项目可持续发展,都会对人类产生真正的影响。帮助人们达到他们的目标,实现他们的梦想和愿景,而我也实实在在感受到收获这种蝴蝶效应般的热情。” + +开源技术在技术领域占的比重越来越大,Megan 对未来抱有很大希望。“令人兴奋的是故事还没有结束。作为一个社区,我们还在摸索,”她说:“关于开源,我们需要学习的东西太多了,我们的外部环境不断发生变化,它可以以多种方式发展,同时我们周围的环境也在变化。我们需要正确的对话,并找出如何共同发展的方法。确保每个人都有一席之地。” + +用她的话说,这些都是经常从她的父亲生意电话里听到的感悟,做生意就是解决问题并帮助别人。“帮助更多的人学习如何使用和贡献开源来解决问题,的确是一件有益的事情。不管是推动创新,提升效率,还是实现业务目标,有很多方法可以从开源中获得价值。” + +### 属于你的荣耀 + +当被问到对其他想参与到开源社区的女性有哪些建议时,Megan 兴奋的说:“请记住,在开源社区,所有人都有一席之地。这可能会让人望而生畏,但是从我的经验来看,人们都想帮忙。当你需要帮助的时候,就寻求帮助,但也要清楚你能在哪里做出贡献,如何做出贡献,以及你的需求是什么。” + +她也认识到,在开源领域的所有声音中,有时会感觉到缺乏集中的领导力,但她提醒不要把它看成是一种只留给少数人的特权角色。“做你期望的领导者。当社区领导角色空缺时,每个个体可以自己填补空缺。每一个开源的贡献者都是领导者,不管是领导他人,领导社区,甚至领导自己。不要等待被动赋予属于你的权力和精彩。” + +对 Megan 来说,开源之旅就如:一个前途不明朗的心路之旅。尽管如此,对风险和未来的不确定性她从不逃避。“我把生命看作一张你正在编织的美丽挂毯,日复一日,你仅仅看到后面的线头。如果你可以看到全貌,你将意识到,你只要每天尽自己最大的努力,就会以无数的方式为这个美好的作品做出贡献。” + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/4/interview-Megan-Byrd-Sanicki + +作者:[Jay Barber][a] +选题:[lujun9972][b] +译者:[guevaraya](https://github.com/guevaraya) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jaybarber +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dandelion_blue_water_hand.jpg?itok=QggW8Wnw (Dandelion held out over water) +[2]: https://www.redhat.com/en/about/women-in-open-source +[3]: https://opensource.com/sites/default/files/uploads/megan_sanicki_headshot_small_0.png (Photo by Megan Sanicki, Used with permission) +[4]: https://www.drupal.org/association +[5]: https://opensource.org/ +[6]: https://www.covidactnow.org/ +[7]: https://fossresponders.com/ +[8]: https://opensource.com/article/20/4/interview-Netha-Hussain diff --git a/published/202007/20200514 What is IoT- The internet of things explained.md b/published/202007/20200514 What is IoT- The internet of things explained.md new file mode 100644 index 0000000000..00ed2a05ef --- /dev/null +++ b/published/202007/20200514 What is IoT- The internet of things explained.md @@ -0,0 +1,155 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12411-1.html) +[#]: subject: (What is IoT? The internet of things explained) +[#]: via: (https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html) +[#]: author: (Josh Fruhlinger https://www.networkworld.com/author/Josh-Fruhlinger/) + +物联网(IoT)简介 +====== + +> 物联网(IoT)是一个由智能设备连接起来的网络,并提供了丰富的数据,但是它也有可能是一场安全领域的噩梦。 + +![](https://img.linux.net.cn/data/attachment/album/202007/13/144427tnrjnnh686n5kgtn.jpg) + +物联网Internet of Things(IoT)是一个统称,指的是越来越多不属于传统计算设备,但却连接到互联网接收或发送数据,或既接收也发送的电子设备组成的网络。 + +现在有数不胜数的东西可以归为这一类:可以联网的“智能”版传统设备,比如说电冰箱和灯泡;那些只能运行于有互联网环境的小设备,比如像 Alexa 之类的电子助手;与互联网连接的传感器,它们正在改变着工厂、医疗、运输、物流中心和农场。 + +### 什么是物联网? + +物联网将互联网、数据处理和分析的能力带给了现实的实物世界。对于消费者来说,这就意味着不需要键盘和显示器这些东西,就能和这个全球信息网络进行互动;他们的日常用品当中,很多都可以通过该网络接受操作指令,而只需很少的人工干预。 + +互联网长期以来为知识工作提供了便利,在企业环境当中,物联网也能为制造和分销带来同样的效率。全球数以百万计甚至数十亿计的嵌入式具有互联网功能的传感器正在提供令人难以置信丰富的数据集,企业可以利用这些数据来保证他们运营的安全、跟踪资产和减少人工流程。研究人员也可以使用物联网来获取人们的喜好和行为数据,尽管这些行为可能会严重影响隐私和安全。 + +### 它有多大? + +一句话:非常庞大。[Priceonomics 对此进行了分析][2]:在 2020 年的时候,有超过 50 亿的物联网设备,这些设备可以生成 4.4 泽字节zettabyte(LCTT 译注:1 zettabyte = 109 terabyte = 1012 gigabyte)的数据。相比较,物联网设备在 2013 年仅仅产生了 1000 亿千兆字节gigabyte的数据。在物联网市场上可能挣到的钱也同样让人瞠目;到 2025 年,这块市场的价值可以达到 1.6 万亿美元到 14.4 万亿美元不等。 + +### 物联网的历史 + +一个联网设备和传感器无处不在的世界,是科幻小说中最经典的景象之一。物联网传说中将 1970 年 [卡耐基•梅隆大学的一台连接到 APRANET 的自动贩卖机][3] 称之为世界上第一个物联网设备,而且许多技术都被吹捧为可以实现 “智能” 的物联网式特征,使其颇具有未来主义的光彩。但是“物联网”这个词是由英国的技术专家 [Kevin Ashton][4] 于 1999 年提出来的。 + +一开始,技术是滞后于当时对未来的憧憬的。每个与互联网相连的设备都需要一个处理器和一种能和其他东西通信的方式,无线的最好,这些因素都增加了物联网大规模实际应用的成本和性能要求,这种情况至少一直持续到 21 世纪头十年中期,直到摩尔定律赶上来。 + +一个重要的里程碑是 [RFID 标签的大规模使用][5],这种价格低廉的极简转发器可以被贴在任何物品上,然后这些物品就可以连接到更大的互联网上了。对于设计者来说,无处不在的 Wi-Fi 和 4G 让任何地方的无线连接都变得非常简单。而且,IPv6 的出现再也不用让人们担心把数十亿小设备连接到互联网上会将 IP 地址耗尽。(相关报道:[物联网网络可以促进 IPv6 的使用吗?][6]) + +### 物联网是如何工作的? + +物联网的基本元素是收集数据的设备。广义地说,它们是和互联网相连的设备,所以每一个设备都有 IP 地址。它们的复杂程度不一,这些设备涵盖了从工厂运输货物的自动驾驶车辆到监控建筑温度的简单传感器。这其中也包括每天统计步数的个人手环。为了让这些数据变得有意义,就需要对其收集、处理、过滤和分析,每一种数据都可以通过多种方式进行处理。 + +采集数据的方式是将数据从设备上传输到采集点。可以通过各种无线或者有线网络进行数据的转移。数据可以通过互联网发送到具有存储空间或者计算能力的数据中心或者云端,或者这些数据也可以分段进行传输,由中间设备汇总数据后再沿路径发送。 + +处理数据可以在数据中心或者云端进行,但是有时候这不太可行。对于一些非常重要的设备,比如说工业领域的关停设备,从设备上将数据发送到远程数据中心的延迟太大了。发送、处理、分析数据和返回指令(在管道爆炸之前关闭阀门)这些操作,来回一趟的时间可能要花费非常多的时间。在这种情况下,边缘计算edge-computing就可以大显身手了,智能边缘设备可以汇总数据、分析数据,在需要的时候进行回应,所有这些都在相对较近的物理距离内进行,从而减少延迟。边缘设备可以有上游连接,这样数据就可以进一步被处理和储存。 + +![][7] + +*物联网是如何工作的。* + +### 物联网设备的一些例子 + +本质上,任何可以搜集来自于真实世界数据,并且可以发送回去的设备都可以参与到物联网生态系统中。典型的例子包括智能家居设备、射频识别标签(RFID)和工业传感器。这些传感器可以监控一系列的因素,包括工业系统中的温度和压力、机器中关键设备的状态、患者身上与生命体征相关的信号、水电的使用情况,以及其它许许多多可能的东西。 + +整个工厂的机器人可以被认为是物联网设备,在工业环境和仓库中移动产品的自主车辆也是如此。 + +其他的例子包括可穿戴设备和家庭安防系统。还有一些其它更基础的设备,比如说[树莓派][8]和[Arduino][9],这些设备可以让你构建你自己的物联网终端节点。尽管你可能会认为你的智能手机是一台袖珍电脑,但它很可能也会以非常类似物联网的方式将你的位置和行为数据传送到后端服务。 + +#### 设备管理 + +为了能让这些设备一起工作,所有这些设备都需要进行验证、分配、配置和监控,并且在必要时进行修复和更新。很多时候,这些操作都会在一个单一的设备供应商的专有系统中进行;要么就完全不会进行这些操作,而这样也是最有风险的。但是整个业界正在向[标准化的设备管理模式][10]过渡,这使得物联网设备之间可以相互操作,并保证设备不会被孤立。 + +#### 物联网通信标准和协议 + +当物联网上的小设备和其他设备通信的时候,它们可以使用各种通信标准和协议,这其中许多都是为这些处理能力有限和电源功率不大的设备专门定制的。你一定听说过其中的一些,尽管有一些设备使用的是 Wi-Fi 或者蓝牙,但是更多的设备是使用了专门为物联网世界定制的标准。比如,ZigBee 就是一个低功耗、远距离传输的无线通信协议,而 MQTT(消息队列遥测传输Message Queuing Telemetry Transport)是为连接在不可靠或者易发生延迟的网络上的设备定制的一个发布/订阅信息协议。(参考 Network World 的词汇表:[物联网标准和协议](11)。) + +物联网也会受益于 5G 为蜂窝网络带来的高速度和高带宽,尽管这种使用场景会[滞后于普通的手机][12]。 + +### 物联网、边缘计算和云 + +![][13] + +*边缘计算如何使物联网成为可能。* + +对于许多物联网系统来说,大量的数据会以极快的速度涌来,这种情况催生了一个新的科技领域,[边缘计算][14]edge computing,它由放置在物联网设备附近的设备组成,处理来自那些设备的数据。这些机器对这些数据进行处理,只将相关的素材数据发送到一个更集中的系统系统进行分析。比如,想象一个由几十个物联网安防摄像头组成的网络,边缘计算会直接分析传入的视频,而且只有当其中一个摄像头检测到有物体移动的时候才向安全操作中心(SoC)发出警报,而不会是一下子将所有的在线数据流全部发送到建筑物的 SoC。 + +一旦这些数据已经被处理过了,它们又去哪里了呢?好吧,它也许会被送到你的数据中心,但是更多情况下,它最终会进入云。 + +对于物联网这种间歇或者不同步的数据来往场景来说,具有弹性的云计算是再适合不过的了。许多云计算巨头,包括[谷歌][15]、[微软][16]和[亚马逊][17],都有物联网产品。 + +### 物联网平台 + +云计算巨头们正在尝试出售的,不仅仅是存放传感器搜集的数据的地方。他们正在提供一个可以协调物联网系统中各种元素的完整平台,平台会将很多功能捆绑在一起。本质上,物联网平台作为中间件,将物联网设备和边缘网关与你用来处理物联网数据的应用程序连接起来。也就是说,每一个平台的厂商看上去都会对物联网平台应该是什么这个问题有一些稍微不同的解释,以更好地[与其他竞争者拉开差距][18]。 + +### 物联网和数据 + +正如前面所提到的,所有这些物联网设备收集了 ZB 级的数据,这些数据通过边缘网关被发送到平台上进行处理。在很多情况下,这些数据就是要部署物联网的首要原因。通过从现实世界中的传感器搜集来的数据,企业就可以实时的作出灵活的决定。 + +例如,Oracle 公司[假想了一个这样的场景][19],当人们在主题公园的时候,会被鼓励下载一个可以提供公园信息的应用。同时,这个程序会将 GPS 信号发回到公园的管理部门来帮助他们预测排队时间。有了这些信息,公园就可以在短期内(比如通过增加员工数量来提升景点的一些容量)和长期内(通过了解哪些设施最受欢迎,那些最不受欢迎)采取行动。 + +这些决定可以在没有人工干预的情况作出。比如,从化工厂管道中的压力传感器收集的数据可以通过边缘设备的软件进行分析,从而发现管道破裂的威胁,这样的信息可以触发关闭阀门的信号,从而避免泄漏。 + +### 物联网和大数据分析 + +主题公园的例子可以让你很容易理解,但是和许多现实世界中物联网收集数据的操作相比,就显得小菜一碟了。许多大数据业务都会使用到来自物联网设备收集的信息,然后与其他数据关联,这样就可以分析预测到人类的行为。Software Advice 给出了[一些例子][20],其中包括由 Birst 提供的一项服务,该服务将从联网的咖啡机中收集的咖啡冲泡的信息与社交媒体上发布的帖子进行匹配,看看顾客是否在网上谈论咖啡品牌。 + +另一个最近才发生的戏剧性的例子,X-Mode 发布了一张基于位置追踪数据的地图,地图上显示了在 2020 年 3 月春假的时候,正当新冠病毒在美国加速传播的时候,人们在劳德代尔堡Ft. Lauderdale聚会完[最终都去了哪里][21]。这张地图令人震撼,不仅仅是因为它显示出病毒可能的扩散方向,更是因为它说明了物联网设备是可以多么密切地追踪我们。(更多关于物联网和分析的信息,请点击[此处][22]。) + +### 物联网数据和 AI + +物联网设备能够收集的数据量远远大于任何人类能够以有效的方式处理的数据量,而且这肯定也不是能实时处理的。我们已经看到,仅仅为了理解从物联网终端传来的原始数据,就需要边缘计算设备。此外,还需要检测和处理可能就是[完全错误的数据][23]。 + +许多物联网供应商也同时提供机器学习和人工智能的功能,可以用来理解收集来的数据。比如,IBM 的 Jeopardy!-winning Watson 平台就可以在[物联网数据集上进行训练][24],这样就可以在预测性维护领域产生有用的结果 —— 比如说,分析来自无人机的数据,可以区分桥梁上轻微的损坏和需要重视的裂缝。同时,ARM 也在研发[低功耗芯片][25],它可以在物联网终端上提供 AI 的能力。 + +### 物联网和商业 + +物联网的商业用途包括跟踪客户、库存和重要部件的状态。[IoT for All][26] 列举了四个已经被物联网改变的行业: + +* **石油和天然气**:与人工干预相比,物联网传感器可以更好的检测孤立的钻井现场。 +* **农业**:通过物联网传感器获得的田间作物的数据,可以用来提高产量。 +* **采暖通风**:制造商可以监控全国各地的气候控制系统。 +* **实体零售**:当顾客在商店的某些地方停留的时候,可以通过手机进行微目标定位,提供优惠信息。 + +更普遍的情况是,企业正在寻找能够在[四个领域][27]上获得帮助的物联网解决方案:能源使用、资产跟踪、安全领域和客户体验。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html + +作者:[Josh Fruhlinger][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Josh-Fruhlinger/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/category/internet-of-things/ +[2]: https://priceonomics.com/the-iot-data-explosion-how-big-is-the-iot-data/ +[3]: https://www.machinedesign.com/automation-iiot/article/21836968/iot-started-with-a-vending-machine +[4]: https://www.visioncritical.com/blog/kevin-ashton-internet-of-things +[5]: https://www.networkworld.com/article/2319384/rfid-readers-route-tag-traffic.html +[6]: https://www.networkworld.com/article/3338106/can-iot-networking-drive-adoption-of-ipv6.html +[7]: https://images.idgesg.net/images/article/2020/05/nw_how_iot_works_diagram-100840757-orig.jpg +[8]: https://www.networkworld.com/article/3176091/10-killer-raspberry-pi-projects-collection-1.html +[9]: https://www.networkworld.com/article/3075360/arduino-targets-the-internet-of-things-with-primo-board.html +[10]: https://www.networkworld.com/article/3258812/the-future-of-iot-device-management.html +[11]: https://www.networkworld.com/article/3235124/internet-of-things-definitions-a-handy-guide-to-essential-iot-terms.html +[12]: https://www.networkworld.com/article/3291778/what-s-so-special-about-5g-and-iot.html +[13]: https://images.idgesg.net/images/article/2017/09/nw_how_edge_computing_works_diagram_1400x1717-100736111-orig.jpg +[14]: https://www.networkworld.com/article/3224893/what-is-edge-computing-and-how-it-s-changing-the-network.html +[15]: https://cloud.google.com/solutions/iot +[16]: https://azure.microsoft.com/en-us/overview/iot/ +[17]: https://aws.amazon.com/iot/ +[18]: https://www.networkworld.com/article/3336166/why-are-iot-platforms-so-darn-confusing.html +[19]: https://blogs.oracle.com/bigdata/how-big-data-powers-the-internet-of-things +[20]: https://www.softwareadvice.com/resources/iot-data-analytics-use-cases/ +[21]: https://www.cnn.com/2020/04/04/tech/location-tracking-florida-coronavirus/index.html +[22]: https://www.networkworld.com/article/3311919/iot-analytics-guide-what-to-expect-from-internet-of-things-data.html +[23]: https://www.networkworld.com/article/3396230/when-iot-systems-fail-the-risk-of-having-bad-iot-data.html +[24]: https://www.networkworld.com/article/3449243/watson-iot-chief-ai-can-broaden-iot-services.html +[25]: https://www.networkworld.com/article/3532094/ai-everywhere-iot-chips-coming-from-arm.html +[26]: https://www.iotforall.com/4-unlikely-industries-iot-changing/ +[27]: https://www.networkworld.com/article/3396128/the-state-of-enterprise-iot-companies-want-solutions-for-these-4-areas.html diff --git a/published/202007/20200522 Turn your Raspberry Pi homelab into a network filesystem.md b/published/202007/20200522 Turn your Raspberry Pi homelab into a network filesystem.md new file mode 100644 index 0000000000..cff0ca4ee7 --- /dev/null +++ b/published/202007/20200522 Turn your Raspberry Pi homelab into a network filesystem.md @@ -0,0 +1,286 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12413-1.html) +[#]: subject: (Turn your Raspberry Pi homelab into a network filesystem) +[#]: via: (https://opensource.com/article/20/5/nfs-raspberry-pi) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +把你的树莓派家庭实验室变成一个网络文件系统 +====== + +> 使用 NFS 服务器将共享文件系统添加到你的家庭实验室。 + +![](https://img.linux.net.cn/data/attachment/album/202007/14/154349bgrgrwzexluuvzev.jpg) + +共享文件系统是为家庭实验室增加通用性和功能性的好方法。在实验室中为客户端共享一个集中的文件系统,使得组织数据、进行备份和共享数据变得相当容易。这对于在多个服务器上进行负载均衡的 Web 应用和 [Kubernetes][2] 使用的持久化卷来说,尤其有用,因为它允许在任何数量的节点上用持久化数据来轮转 Pod。 + +无论你的家庭实验室是由普通计算机、多余的企业服务器,还是树莓派或其他单板计算机(SBC)组成,共享文件系统都是一种有用的资产,而网络文件系统(NFS)服务器是创建共享文件系统的好方法。 + +我之前写过关于[建立“家庭私有云”][3]的文章,这是一个由树莓派或其他 SBC 组成的家庭实验室,也许还有其他一些消费类硬件或台式 PC。NFS 服务器是这些组件之间共享数据的理想方式。由于大多数 SBC 的操作系统是通过 SD 卡运行的,所以存在一些挑战。尤其是在用作计算机的操作系统磁盘时,SD 卡的故障率会增加,它们并不是用来不断地读写的。你实际需要的是一个真正的硬盘:它们通常比 SD 卡的每 GB 价格便宜,特别是对于较大的磁盘,而且它们不太可能持续发生故障。树莓派 4 现在带有 USB 3.0 接口,而 USB 3.0 硬盘无处不在,价格也很实惠。这是一个完美的搭配。在这个项目中,我将使用一个 2TB 的 USB 3.0 外置硬盘插入到运行 NFS 服务器的树莓派 4 中。 + +![Raspberry Pi with a USB hard disk][4] + +### 安装 NFS 服务器软件 + +我在树莓派上运行 Fedora 服务器,但这个项目也可以在其他发行版上运行。要在 Fedora 上运行 NFS 服务器,你需要 `nfs-utils` 包,幸运的是它已经安装好了(至少在 Fedora 31 中是这样)。如果你打算运行 NFSv3 服务,你还需要 `rpcbind` 包,但它不是 NFSv4 的严格要求。 + +如果你的系统中还没有这些软件包,请使用 `dnf` 命令安装它们。 + +``` +# 安装 nfs-utils 和 rpcbind +$ sudo dnf install nfs-utils rpcbind +``` + +Raspbian 是另一个与树莓派一起使用的流行操作系统,设置几乎完全相同。软件包名称不同而已,但这是唯一的主要区别。要在运行 Raspbian 的系统上安装 NFS 服务器,你需要以下软件包。 + + * `nfs-common`:这些文件是 NFS 服务器和客户端的通用文件。 + * `nfs-kernel-server`:主要的 NFS 服务器软件包。 + +Raspbian 使用 `apt-get` 来管理软件包(而不是像 Fedora 那样使用 `dnf`),所以用它来安装软件包。 + +``` +# 对于 Raspbian 系统,使用 apt-get 来安装 NFS 软件包 +$ sudo apt-get install nfs-common nfs-kernel-server +``` + +### 准备一个 USB 硬盘作为存储设备 + +正如我上面提到的,USB 硬盘是为树莓派或其他 SBC 提供存储的好选择,尤其是用于操作系统磁盘镜像的 SD 卡并不适合这个用途。对于家庭私有云,你可以使用廉价的 USB 3.0 硬盘进行大规模存储。插入磁盘,使用 `fdisk` 找出分配给它的设备 ID,就可以使用它工作了。 + +``` +# 使用 fdisk 找到你的硬盘 +# 无关的硬盘信息已经省略 +$ sudo fdisk -l + +Disk /dev/sda: 1.84 TiB, 2000398933504 bytes, 3907029167 sectors +Disk model: BUP Slim BK +Units: sectors of 1 * 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disklabel type: dos +Disk identifier: 0xe3345ae9 + +Device     Boot Start        End    Sectors  Size Id Type +/dev/sda1        2048 3907028991 3907026944  1.8T 83 Linux +``` + +为了清楚起见,在上面的例子输出中,除了我感兴趣的那个磁盘,我省略了所有其它磁盘的信息。你可以看到我想使用的 USB 磁盘被分配了设备 `/dev/sda`,你可以看到一些关于型号的信息(`Disk model: BUP Slim BK`),这有助于我识别正确的磁盘。该磁盘已经有了一个分区,它的大小也证实了它就是我要找的磁盘。 + +注意:请确保正确识别你的设备的磁盘和分区。它可能与上面的例子不同。 + +在驱动器上创建的每个分区都有一个特殊的通用唯一标识符(UUID)。计算机使用 UUID 来确保它使用 `/etc/fstab` 配置文件将正确的分区挂载到正确的位置。你可以使用 `blkid` 命令检索分区的 UUID。 + +``` +# 获取该分区的块设备属性 +# 确保你使用了合适的分区,它应该有所不同。 +$ sudo blkid /dev/sda1 + +/dev/sda1: LABEL="backup" UUID="bd44867c-447c-4f85-8dbf-dc6b9bc65c91" TYPE="xfs" PARTUUID="e3345ae9-01" +``` + +在这里,`/dev/sda1` 的 UUID 是 `bd44867c-447c-4f85-8dbf-dc6b9bc65c91`。你的 UUID 会有所不同,所以要记下来。 + +### 配置树莓派在启动时挂载这个磁盘,然后挂载它 + +现在你已经确定了要使用的磁盘和分区,你需要告诉计算机如何挂载它,每次启动时都要这样做。现在就去挂载它。因为这是一个 USB 磁盘,可能会被拔掉,所以你还要配置树莓派在启动时如果磁盘没有插入或有其它不可用情况时不要等待。 + +在 Linux 中,通过将分区添加到 `/etc/fstab` 配置文件中,包括你希望它被挂载的位置和一些参数来告诉计算机如何处理它。这个例子将把分区挂载到 `/srv/nfs`,所以先创建这个路径: + +``` +# 创建该磁盘分区的挂载点 +$ sudo mkdir -p /srv/nfs +``` + +接下来,使用以下语法格式修改 `/etc/fstab` 文件: + +``` +                   +``` + +使用你之前确定的 UUID 作为磁盘 ID。正如我在上一步提到的,挂载点是 `/srv/nfs`。对于文件系统类型,通常最好选择其实际的文件系统,但是因为这是一个 USB 磁盘,所以使用 `auto`。 + +对于选项值,使用 `nosuid,nodev,nofail`。 + +#### 关于手册页的一个旁白 + +其实,有*很多*可能的选项,手册页(`man`)是查看它们的最好方法。查看 `fstab` 的手册页是一个很好的开始。 + +``` +# 打开 fstab 的手册页 +$ man fstab +``` + +这将打开与 `fstab` 命令相关的手册/文档。在手册页中,每个选项都被分解成了不同的内容,以显示它的作用和常用的选择。例如,“第四个字段(fs_mntopts)”给出了该字段中可用选项的一些基本信息,并引导你到 `man 8 mount` 中获取 `mount` 选项更深入的描述。这是有道理的,因为 `/etc/fstab` 文件,本质上是告诉计算机如何自动挂载磁盘,就像你手动使用 `mount` 命令一样。 + +你可以从 `mount` 的手册页中获得更多关于你将使用的选项的信息。数字 8 表示手册页的章节。在这里,第 8 章节是*系统管理工具和守护进程*。 + +你可以从 `man` 的手册页中得到标准章节的列表。 + +回到挂载磁盘,让我们看看 `man 8 mount`。 + +``` +# 打开第 8 章节的 mount 手册页 +$ man 8 mount +``` + +在这个手册页中,你可以查看上面列出的选项的作用。 + + * `nosuid`:不理会 suid/guid 位。不允许放在 U 盘上的任何文件以 root 身份执行。这是一个良好的安全实践。 + * `nodev`:不识别文件系统中的字符或块特殊设备,即不理会在 U 盘上的任何设备节点。另一个良好的安全实践。 + * `nofail`:如果设备不存在,不要记录任何错误。这是一个 U 盘,可能没有插入,所以在这种情况下,它将被忽略。 + +回到你正在添加到 `/etc/fstab` 文件的那一行,最后还有两个选项:`fs_freq` 和 `fs_passno`。它们的值与一些过时的选项有关,*大多数*现代系统对这两个选项都只用 `0`,特别是对 USB 磁盘上的文件系统而言。`fs_freq` 的值与 `dump` 命令和文件系统的转储有关。`fs_passno` 的值定义了启动时要 `fsck` 的文件系统及其顺序,如果设置了这个值,通常根分区是 `1`,其他文件系统是 `2`,将该值设置为 `0` 以跳过在该分区上使用 `fsck`。 + +在你喜欢的编辑器中,打开 `/etc/fstab` 文件,添加 U 盘上分区的条目,将这里的值替换成前面步骤中得到的值。 + +``` +# With sudo, or as root, add the partition info to the /etc/fstab file +UUID="bd44867c-447c-4f85-8dbf-dc6b9bc65c91"    /srv/nfs    auto    nosuid,nodev,nofail,noatime 0 0 +``` + +### 启用并启动 NFS 服务器 + +安装好软件包,并将分区添加到你的 `/etc/fstab` 文件中,现在你可以开始启动 NFS 服务器了。在 Fedora 系统中,你需要启用和启动两个服务:`rpcbind` 和 `nfs-server`。使用 `systemctl` 命令来完成这项工作。 + +``` +# 启动 NFS 服务器和 rpcbind +$ sudo systemctl enable rpcbind.service +$ sudo systemctl enable nfs-server.service +$ sudo systemctl start rpcbind.service +$ sudo systemctl start nfs-server.service +``` + +在 Raspbian 或其他基于 Debian 的发行版上,你只需要使用 `systemctl` 命令启用并启动 `nfs-kernel-server` 服务即可,方法同上。 + +#### RPCBind + +rpcbind 工具用于将远程过程调用(RPC)服务映射到其监听的端口。根据 rpcbind 手册页: + +> “当一个 RPC 服务启动时,它会告诉 rpcbind 它正在监听的地址,以及它准备服务的 RPC 程序号。当客户机想对给定的程序号进行 RPC 调用时,它首先与服务器机器上的 rpcbind 联系,以确定 RPC 请求应该发送到哪里的地址。” + +在 NFS 服务器这个案例中,rpcbind 会将 NFS 的协议号映射到 NFS 服务器监听的端口上。但是,NFSv4 不需要使用 rpcbind。如果你*只*使用 NFSv4 (通过从配置中删除版本 2 和版本 3),则不需要使用 rpcbind。我把它放在这里是为了向后兼容 NFSv3。 + +### 导出挂载的文件系统 + +NFS 服务器根据另一个配置文件 `/etc/exports` 来决定与哪些远程客户端共享(导出)哪些文件系统。这个文件只是一个 IP(或子网)与要共享的文件系统的映射,以及一些选项(只读或读写、root 去除等)。该文件的格式是: + +``` +<目录>     <主机>(选项) +``` + +在这个例子中,你将导出挂载到 `/srv/nfs` 的分区。这是“目录”部分。 + +第二部分,主机,包括你要导出这个分区的主机。这些主机可以是单个主机:使用具有完全限定域名(FQDN)或主机名、主机的 IP 地址来指定;也可以是一组主机:使用通配符字符来匹配域(如 *.example.org)、IP 网络(如无类域间路由 CIDR 标识)或网组表示。 + +第三部分包括应用于该导出的选项。 + + * `ro/rw`:将文件系统导出为只读或读写。 + * `wdelay`:如果即将进行另一次写入,则推迟对磁盘的写入,以提高性能(如果你使用的是固态 USB 磁盘,这*可能*没有那么有用) + * `root_squash`:防止客户机上的任何 root 用户在主机上有 root 权限,并将 root UID 设置为 `nfsnobody` 作为安全防范措施。 + +测试导出你挂载在 `/srv/nfs` 处的分区到一个客户端 —— 例如,一台笔记本电脑。确定你的客户机的 IP 地址(我的笔记本是 `192.168.2.64`,但你的可能会不同)。你可以把它共享到一个大的子网,但为了测试,请限制在单个 IP 地址上。这个 IP 的 CIDR 标识是 `192.168.2.64/32`,`/32` 子网代表一个 IP。 + +使用你喜欢的编辑器编辑 `/etc/exports` 文件,写上你的目录、主机 CIDR 以及 `rw` 和 `root_squash` 选项。 + +``` +# 像这样编辑你的 /etc/exports 文件,替换为你的系统上的信息 +/srv/nfs    192.168.2.64/32(rw,root_squash) +``` + +注:如果你从另一个地方复制了 `/etc/exports` 文件,或者用副本覆盖了原文件,你可能需要恢复该文件的 SELinux 上下文。你可以使用 `restorecon` 命令来恢复。 + +``` +# 恢复 /etc/exports 文件的 SELinux 上下文 +$ sudo restorecon /etc/exports +``` + +完成后,重新启动 NFS 服务器,以接收对 `/etc/exports` 文件的更改。 + +``` +# 重新启动 NFS 服务器 +$ sudo systemctl restart nfs-server.service +``` + +### 给 NFS 服务打开防火墙 + +有些系统,默认不运行[防火墙服务][6]。比如 Raspbian,默认是开放 iptables 规则,不同服务打开的端口在机器外部立即就可以使用。相比之下,Fedora 服务器默认运行的是 firewalld 服务,所以你必须为 NFS 服务器(以及 rpcbind,如果你将使用 NFSv3)打开端口。你可以通过 `firewall-cmd` 命令来实现。 + +检查 firewalld 使用的区域并获取默认区域。对于 Fedora 服务器,这是 `FedoraServer` 区域。 + +``` +# 列出区域 +# 出于简洁省略了部分输出 +$ sudo firewall-cmd --list-all-zones + +# R获取默认区域信息 +# 记下默认区域 +$ sudo firewall-cmd --get-default-zone + +# 永久加入 nfs 服务到允许端口列表 +$ sudo firewall-cmd --add-service=nfs --permanent + +# 对于 NFSv3,我们需要再加一些端口: nfsv3、 rpc-mountd、 rpc-bind +$ sudo firewall-cmd --add-service=(nfs3,mountd,rpc-bind) + +# 查看默认区域的服务,以你的系统中使用的默认区域相应替换 +$ sudo firewall-cmd --list-services --zone=FedoraServer + +# 如果一切正常,重载 firewalld +$ sudo firewall-cmd --reload +``` + +就这样,你已经成功地将 NFS 服务器与你挂载的 U 盘分区配置在一起,并将其导出到你的测试系统中进行共享。现在你可以在你添加到导出列表的系统上测试挂载它。 + +### 测试 NFS 导出 + +首先,从 NFS 服务器上,在 `/srv/nfs` 目录下创建一个文件来读取。 + +``` +# 创建一个测试文件以共享 +echo "Can you see this?" >> /srv/nfs/nfs_test +``` + +现在,在你添加到导出列表中的客户端系统上,首先确保 NFS 客户端包已经安装好。在 Fedora 系统上,它是 `nfs-utils` 包,可以用 `dnf` 安装。Raspbian 系统有 `libnfs-utils` 包,可以用 `apt-get` 安装。 + +安装 NFS 客户端包: + +``` +# 用 dnf 安装 nfs-utils 软件包 +$ sudo dnf install nfs-utils +``` + +一旦安装了客户端包,你就可以测试 NFS 的导出了。同样在客户端,使用带有 NFS 服务器 IP 和导出路径的 `mount` 命令,并将其挂载到客户端的一个位置,在这个测试中是 `/mnt` 目录。在这个例子中,我的 NFS 服务器的 IP 是 `192.168.2.109`,但你的可能会有所不同。 + +``` +# 挂载 NFS 服务器的输出到客户端主机 +# 确保替换为你的主机的相应信息 +$ sudo mount 192.168.2.109:/srv/nfs /mnt + +# 查看 nfs_test 文件是不是可见 +$ cat /mnt/nfs_test +Can you see this? +``` + +成功了!你现在已经有了一个可以工作的 NFS 服务器,可以与多个主机共享文件,允许多个读/写访问,并为你的数据提供集中存储和备份。家庭实验室的共享存储有很多选择,但 NFS 是一种古老的、高效的、可以添加到你的“家庭私有云”家庭实验室中的好选择。本系列未来的文章将扩展如何在客户端上自动挂载 NFS 共享,以及如何将 NFS 作为 Kubernetes 持久卷的存储类。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/nfs-raspberry-pi + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_cloud21x_cc.png?itok=5UwC92dO (Blue folders flying in the clouds above a city skyline) +[2]: https://opensource.com/resources/what-is-kubernetes +[3]: https://linux.cn/article-12277-1.html +[4]: https://opensource.com/sites/default/files/uploads/raspberrypi_with_hard-disk.jpg (Raspberry Pi with a USB hard disk) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: https://opensource.com/article/18/9/linux-iptables-firewalld diff --git a/published/202007/20200525 Foliate- A Modern eBook Reader App for Linux.md b/published/202007/20200525 Foliate- A Modern eBook Reader App for Linux.md new file mode 100644 index 0000000000..39fc680f6e --- /dev/null +++ b/published/202007/20200525 Foliate- A Modern eBook Reader App for Linux.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12462-1.html) +[#]: subject: (Foliate: A Modern eBook Reader App for Linux) +[#]: via: (https://itsfoss.com/foliate-ebook-viewer/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Foliate:适用于 Linux 的现代电子书阅读器应用 +====== + +> Foliate 是一款简洁、优雅的开源电子书阅读器,可在 Linux 桌面上提供类似 Kindle 的阅读体验。 + +![](https://img.linux.net.cn/data/attachment/album/202007/28/230931vpsyu25yua8855u3.jpg) + +虽然我们已经有了一个 [Linux 最佳电子书阅读器][2]的列表,但最近我遇到了另一个 Linux 电子书阅读器。它叫 [Foliate][3]。 + +![][1] + +Foliate 是一个现代的 GTK 电子书查看器,它有许多基本功能。如果你拥有亚马逊 Kindle 或其他电子书阅读器,那么你可能会想念那种在桌面上阅读的体验。 + +![](https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/07/foliate-library-view.jpg?w=800&ssl=1) + +Foliate 解决了那些抱怨。Foliate 会显示书的估计剩余阅读时间和页数。你可以添加书签、高亮文本和添加注释。你可以导出数据,也可以轻松同步它们。 + +![Foliate Ebook Viewer Features][4] + +你也可以使用维基词典和维基百科查询单词。你可以在页面视图和滚动视图之间切换。它还有几个主题,以满足你的阅读偏好。 + +![][5] + +最棒的是,它正在积极维护和开发。 + +### Foliate 的功能 + +![][6] + +让我们来看看 Foliate 提供的所有功能: + + * 支持 .epub、.mobi、.azw、未打包的 EPUB 文件、文本文件、漫画存档(cbr、.cbz、.cbt、.cb7),小说书(.fb2、.fb2.zip)和 .azw3 文件。它不支持 PDF 文件。 + * 它让你可以在双页浏览模式下阅读电子书,并提供滚动查看模式。 + * 能够自定义字体、行距、边距和亮度。 + * 图书馆视图,显示最近的书籍和阅读进度。 + * 默认主题包括浅色、棕褐色、深色、Solarized 深色/浅色、Gruvbox 浅色/深色、灰色、Nord 和反转模式。 + * 你还可以添加自定义主题调整电子书浏览器的外观。 + * 带有章节标记的阅读进度滑块。 + * 书签和注释支持。 + * 能够在书中查找文本。 + * 能够放大和缩小。 + * 启用/禁用侧边栏进行导航。 + * 使用 [维基词典][7] 和 [维基百科][8] 快速查找字典 + * 使用谷歌翻译翻译文字 + * 触摸板手势,使用两指滑动即可翻页 + * 使用 [eSpeak NG][9] 和 [Festival][10] 支持文字转语音 + +### 在 Linux 上安装 Foliate + +对于基于 Ubuntu 和 Debian 的 Linux 发行版,你可以从它的 [GitHub 发布页面][13]获取 .deb 文件。只需双击即可[从 deb 文件安装应用][14]。 + +对于 Fedora、Arch、SUSE 等其他 Linux 发行版。Foliate 可提供 [Flatpak][15] 和 [Snap][16] 包。如果你不知道如何使用它们,那么你可以按照我们[使用 flatpak][17] 和[使用 snap 包][18]指南来开始使用。 + +如果需要,你可以浏览它的 [GitHub 页面][19]以从源代码开始构建。 + +- [下载 Foliate 应用][20] + +### 总结 + +我使用 GitHub 上提供的最新 .deb 文件在 Pop!_OS 19.10 上进行了尝试,并且效果很好。我不喜欢在桌面上阅读很久,但我喜欢它的功能。 + +你是否尝试过 Foliate?请随时分享你的经验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/foliate-ebook-viewer/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/foliate-app.jpg?ssl=1 +[2]: https://linux.cn/article-10383-1.html +[3]: https://johnfactotum.github.io/foliate/ +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/foliate-ebook-viewer-features.jpg?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/foliate-screenshot.jpg?ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/foliate-options.jpg?ssl=1 +[7]: https://en.wiktionary.org/wiki/Wiktionary:Main_Page +[8]: https://en.wikipedia.org/wiki/Main_Page +[9]: https://github.com/espeak-ng/espeak-ng +[10]: http://www.cstr.ed.ac.uk/projects/festival/ +[13]: https://github.com/johnfactotum/foliate/releases +[14]: https://itsfoss.com/install-deb-files-ubuntu/ +[15]: https://flathub.org/apps/details/com.github.johnfactotum.Foliate +[16]: https://snapcraft.io/foliate +[17]: https://itsfoss.com/flatpak-guide/ +[18]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ +[19]: https://github.com/johnfactotum/foliate +[20]: tmp.6FO70BtAuy \ No newline at end of file diff --git a/published/202007/20200525 How Cloud-init can be used for your Raspberry Pi homelab.md b/published/202007/20200525 How Cloud-init can be used for your Raspberry Pi homelab.md new file mode 100644 index 0000000000..e297ca2521 --- /dev/null +++ b/published/202007/20200525 How Cloud-init can be used for your Raspberry Pi homelab.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12371-1.html) +[#]: subject: (How Cloud-init can be used for your Raspberry Pi homelab) +[#]: via: (https://opensource.com/article/20/5/cloud-init-raspberry-pi-homelab) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +在你的树莓派家庭实验室中使用 Cloud-init +====== + +> 了解了云行业的标准,该向你的家庭实验室自动添加新设备和用户了。 + +![](https://img.linux.net.cn/data/attachment/album/202007/01/203559wt8tnnnxnc6jcnn8.jpg) + +[Cloud-init][2](可以说)是一个标准,云提供商用它来为云实例提供初始化和配置数据。它最常用于新实例的首次启动,以自动完成网络设置、账户创建和 SSH 密钥安装等使新系统上线所需的任何事情,以便用户可以访问它。 + +在之前的一篇文章《[修改磁盘镜像来创建基于树莓派的家庭实验室][3]》中,我展示了如何为像树莓派这样的单板计算机定制操作系统镜像以实现类似的目标。有了 Cloud-init,就不需要向镜像中添加自定义数据。一旦在镜像中启用了它,你的虚拟机、物理服务器,甚至是小小的树莓派都可以表现得像你自己的 “家庭私有云” 中的云计算实例。新机器只需插入、打开,就可以自动成为你的[家庭实验室][4]的一部分。 + +说实话,Cloud-init 的设计并没有考虑到家庭实验室。正如我所提到的,你可以很容易地修改给定的一套系统磁盘镜像,以启用 SSH 访问并在第一次启动后对它们进行配置。Cloud-init 是为大规模的云提供商设计的,这些提供商需要容纳许多客户,维护一组小的镜像,并为这些客户提供访问实例的机制,而无需为每个客户定制一个镜像。拥有单个管理员的家庭实验室则不会面临同样的挑战。 + +不过,Cloud-init 在家庭实验室中也不是没有可取之处。教育是我的家庭私有云项目的目标之一,而为你的家庭实验室设置 Cloud-init 是一个很好的方式,可以获得大大小小的云提供商大量使用的技术的经验。Cloud-init 也是其他初始配置选项的替代方案之一。与其为家庭实验室中的每台设备定制每个镜像、ISO 等,并在你要进行更改时面临繁琐的更新,不如直接启用 Cloud-init。这减少了技术债务 —— 还有什么比*个人*技术债务更糟糕的吗?最后,在你的家庭实验室中使用 Cloud-init 可以让你的私有云实例与你拥有的或将来可能拥有的任何公有云实例表现相同 —— 这是真正的[混合云][5]。 + +### 关于 Cloud-init + +当为 Cloud-init 配置的实例启动并且服务开始运行时(实际上是 systemd 中的四个服务,以处理启动过程中的依赖关系),它会检查其配置中的[数据源][6],以确定其运行在什么类型的云中。每个主要的云提供商都有一个数据源配置,告诉实例在哪里以及如何检索配置信息。然后,实例使用数据源信息检索云提供商提供的配置信息(如网络信息和实例识别信息)和客户提供的配置数据(如要复制的授权密钥、要创建的用户账户以及许多其他可能的任务)。 + +检索数据后,Cloud-init 再对实例进行配置:设置网络、复制授权密钥等,最后完成启动过程。然后,远程用户就可以访问它,准备好使用 [Ansible][7] 或 [Puppet][8] 等工具进行进一步的配置,或者准备好接收工作负载并开始分配任务。 + +### 配置数据 + +如上所述,Cloud-init 使用的配置数据来自两个潜在来源:云提供商和实例用户。在家庭实验室中,你扮演着这两种角色:作为云提供商提供网络和实例信息,作为用户提供配置信息。 + +#### 云提供商元数据文件 + +在你的云提供商角色中,你的家庭实验室数据源将为你的私有云实例提供一个元数据文件。这个[元数据][9]文件包含实例 ID、云类型、Python 版本(Cloud-init 用 Python 编写并使用 Python)或要分配给主机的 SSH 公钥等信息。如果你不使用 DHCP(或 Cloud-init 支持的其他机制,如镜像中的配置文件或内核参数),元数据文件还可能包含网络信息。 + +#### 用户提供的用户数据文件 + +Cloud-init 的真正价值在于用户数据文件。[用户数据][10]文件由用户提供给云提供商,并包含在数据源中,它将实例从一台普通的机器变成了用户舰队的一员。用户数据文件可以以可执行脚本的形式出现,与正常情况下脚本的工作方式相同;也可以以云服务配置 YAML 文件的形式出现,利用 [Cloud-init 的模块][11] 来执行配置任务。 + +### 数据源 + +数据源是由云提供商提供的服务,它为实例提供了元数据和用户数据文件。实例镜像或 ISO 被配置为告知实例正在使用什么数据源。 + +例如,亚马逊 AWS 提供了一个 [link-local][12] 文件,它将用实例的自定义数据来响应实例的 HTTP 请求。其他云提供商也有自己的机制。幸运的是,对于家庭私有云项目来说,也有 NoCloud 数据源。 + +[NoCloud][13] 数据源允许通过内核命令以键值对的形式提供配置信息,或通过挂载的 ISO 文件系统以用户数据和元数据文件的形式提供。这些对于虚拟机来说很有用,尤其是与自动化搭配来创建虚拟机。 + +还有一个 NoCloudNet 数据源,它的行为类似于 AWS EC2 数据源,提供一个 IP 地址或 DNS 名称,通过 HTTP 从这里检索用户数据和元数据。这对于你的家庭实验室中的物理机器来说是最有帮助的,比如树莓派、[NUC][14] 或多余的服务器设备。虽然 NoCloud 可以工作,但它需要更多的人工关注 —— 这是云实例的反模式。 + +### 家庭实验室的 Cloud-init + +我希望这能让你了解到 Cloud-init 是什么,以及它对你的家庭实验室有何帮助。它是一个令人难以置信的工具,被主要的云提供商所接受,在家里使用它可以是为了教育和乐趣,并帮助你自动向实验室添加新的物理或虚拟服务器。之后的文章将详细介绍如何创建简单的静态和更复杂的动态 Cloud-init 服务,并指导你将它们纳入你的家庭私有云。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/cloud-init-raspberry-pi-homelab + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/innovation_lightbulb_gears_devops_ansible.png?itok=TSbmp3_M (gears and lightbulb to represent innovation) +[2]: https://cloudinit.readthedocs.io/ +[3]: https://linux.cn/article-12277-1.html +[4]: https://opensource.com/article/19/3/home-lab +[5]: https://www.redhat.com/en/topics/cloud-computing/what-is-hybrid-cloud +[6]: https://cloudinit.readthedocs.io/en/latest/topics/datasources.html +[7]: https://www.ansible.com/ +[8]: https://puppet.com/ +[9]: https://cloudinit.readthedocs.io/en/latest/topics/instancedata.html# +[10]: https://cloudinit.readthedocs.io/en/latest/topics/format.html +[11]: https://cloudinit.readthedocs.io/en/latest/topics/modules.html +[12]: https://en.wikipedia.org/wiki/Link-local_address +[13]: https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html +[14]: https://en.wikipedia.org/wiki/Next_Unit_of_Computing diff --git a/published/202007/20200527 Add nodes to your private cloud using Cloud-init.md b/published/202007/20200527 Add nodes to your private cloud using Cloud-init.md new file mode 100644 index 0000000000..1f0939e103 --- /dev/null +++ b/published/202007/20200527 Add nodes to your private cloud using Cloud-init.md @@ -0,0 +1,315 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12407-1.html) +[#]: subject: (Add nodes to your private cloud using Cloud-init) +[#]: via: (https://opensource.com/article/20/5/create-simple-cloud-init-service-your-homelab) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +使用 Cloud-init 将节点添加到你的私有云中 +====== + +> 像主流云提供商的处理方式一样,在家中添加机器到你的私有云。 + +![](https://img.linux.net.cn/data/attachment/album/202007/12/100823rj096h3ax4hhehey.jpg) + +[Cloud-init][2] 是一种广泛使用的行业标准方法,用于初始化云实例。云提供商使用 Cloud-init 来定制实例的网络配置、实例信息,甚至用户提供的配置指令。它也是一个可以在你的“家庭私有云”中使用的很好的工具,可以为你的家庭实验室的虚拟机和物理机的初始设置和配置添加一点自动化 —— 并了解更多关于大型云提供商是如何工作的信息。关于更多的细节和背景,请看我之前的文章《[在你的树莓派家庭实验室中使用 Cloud-init][3]》。 + +![A screen showing the boot process for a Linux server running Cloud-init ][4] + +*运行 Cloud-init 的 Linux 服务器的启动过程(Chris Collins,[CC BY-SA 4.0][5])* + +诚然,Cloud-init 对于为许多不同客户配置机器的云提供商来说,比对于由单个系统管理员运行的家庭实验室更有用,而且 Cloud-init 解决的许多问题对于家庭实验室来说可能有点多余。然而,设置它并了解它的工作原理是了解更多关于这种云技术的好方法,更不用说它是首次启动时配置设备的好方法。 + +本教程使用 Cloud-init 的 NoCloud 数据源,它允许 Cloud-init 在传统的云提供商环境之外使用。本文将向你展示如何在客户端设备上安装 Cloud-init,并设置一个运行 Web 服务的容器来响应客户端的请求。你还将学习如何审查客户端从 Web 服务中请求的内容,并修改 Web 服务的容器,以提供基本的、静态的 Cloud-init 服务。 + +### 在现有系统上设置 Cloud-init + +Cloud-init 可能在新系统首次启动时最有用,它可以查询配置数据,并根据指令对系统进行定制。它可以[包含在树莓派和单板计算机的磁盘镜像中][6],也可以添加到用于配给provision虚拟机的镜像中。对于测试用途来说,无论是在现有系统上安装并运行 Cloud-init,还是安装一个新系统,然后设置 Cloud-init,都是很容易的。 + +作为大多数云提供商使用的主要服务,大多数 Linux 发行版都支持 Cloud-init。在这个例子中,我将使用 Fedora 31 Server 来安装树莓派,但在 Raspbian、Ubuntu、CentOS 和大多数其他发行版上也可以用同样的方式来完成。 + +#### 安装并启用云计算初始服务 + +在你想作为 Cloud-init 客户端的系统上,安装 Cloud-init 包。如果你使用的是 Fedora: + +``` +# Install the cloud-init package +dnf install -y cloud-init +``` + +Cloud-init 实际上是四个不同的服务(至少在 systemd 下是这样),这些服务负责检索配置数据,并在启动过程的不同阶段进行配置更改,这使得可以做的事情更加灵活。虽然你不太可能直接与这些服务进行太多交互,但在你需要排除一些故障时,知道它们是什么还是很有用的。它们是: + + * cloud-init-local.service + * cloud-init.service + * cloud-config.service + * cloud-final.service + +启用所有四个服务: + +``` +# Enable the four cloud-init services +systemctl enable cloud-init-local.service +systemctl enable cloud-init.service +systemctl enable cloud-config.service +systemctl enable cloud-final.service +``` + +#### 配置数据源以查询 + +启用服务后,请配置数据源,客户端将从该数据源查询配置数据。有[许多数据源类型][7],而且大多数都是为特定的云提供商配置的。对于你的家庭实验室,请使用 NoCloud 数据源,(如上所述)它是为在没有云提供商的情况下使用 Cloud-init 而设计的。 + +NoCloud 允许以多种方式包含配置信息:以内核参数中的键/值对,用于在启动时挂载的 CD(或虚拟机中的虚拟 CD);包含在文件系统中的文件中;或者像本例中一样,通过 HTTP 从指定的 URL(“NoCloud Net” 选项)获取配置信息。 + +数据源配置可以通过内核参数提供,也可以在 Cloud-init 配置文件 `/etc/cloud/cloud.cfg` 中进行设置。该配置文件对于使用自定义磁盘镜像设置 Cloud-init 或在现有主机上进行测试非常方便。 + +Cloud-init 还会合并在 `/etc/cloud/cloud.cfg.d/` 中找到的任何 `*.cfg` 文件中的配置数据,因此为了保持整洁,请在 `/etc/cloud/cloud.cfg.d/10_datasource.cfg` 中配置数据源。Cloud-init 可以通过使用以下语法从 `seedfrom` 键指向的 HTTP 数据源中读取数据。 + +``` +seedfrom: http://ip_address:port/ +``` + +IP 地址和端口是你将在本文后面创建的 Web 服务。我使用了我的笔记本电脑的 IP 和 8080 端口。这也可以是 DNS 名称。 + +创建 `/etc/cloud/cloud.cfg.d/10_datasource.cfg` 文件: + +``` +# Add the datasource: +# /etc/cloud/cloud.cfg.d/10_datasource.cfg + +# NOTE THE TRAILING SLASH HERE! +datasource: +  NoCloud: +    seedfrom: http://ip_address:port/ +``` + +客户端设置就是这样。现在,重新启动客户端后,它将尝试从你在 `seedfrom` 键中输入的 URL 检索配置数据,并进行必要的任何配置更改。 + +下一步是设置一个 Web 服务器来侦听客户端请求,以便你确定需要提供的服务。 + +### 设置网络服务器以审查客户请求 + +你可以使用 [Podman][8] 或其他容器编排工具(如 Docker 或 Kubernetes)快速创建和运行 Web 服务器。这个例子使用的是 Podman,但同样的命令也适用于 Docker。 + +要开始,请使用 `fedora:31` 容器镜像并创建一个容器文件(对于 Docker 来说,这会是一个 Dockerfile)来安装和配置 Nginx。从该容器文件中,你可以构建一个自定义镜像,并在你希望提供 Cloud-init 服务的主机上运行它。 + +创建一个包含以下内容的容器文件: + +``` +FROM fedora:31 + +ENV NGINX_CONF_DIR "/etc/nginx/default.d" +ENV NGINX_LOG_DIR "/var/log/nginx" +ENV NGINX_CONF "/etc/nginx/nginx.conf" +ENV WWW_DIR "/usr/share/nginx/html" + +# Install Nginx and clear the yum cache +RUN dnf install -y nginx \ + && dnf clean all \ + && rm -rf /var/cache/yum + +# forward request and error logs to docker log collector +RUN ln -sf /dev/stdout ${NGINX_LOG_DIR}/access.log \ + && ln -sf /dev/stderr ${NGINX_LOG_DIR}/error.log + +# Listen on port 8080, so root privileges are not required for podman +RUN sed -i -E 's/(listen)([[:space:]]*)(\[\:\:\]\:)?80;$/\1\2\38080 default_server;/' $NGINX_CONF +EXPOSE 8080 + +# Allow Nginx PID to be managed by non-root user +RUN sed -i '/user nginx;/d' $NGINX_CONF +RUN sed -i 's/pid \/run\/nginx.pid;/pid \/tmp\/nginx.pid;/' $NGINX_CONF + +# Run as an unprivileged user +USER 1001 + +CMD ["nginx", "-g", "daemon off;"] +``` + +注:本例中使用的容器文件和其他文件可以在本项目的 [GitHub 仓库][9]中找到。 + +上面容器文件中最重要的部分是改变日志存储方式的部分(写到 STDOUT 而不是文件),这样你就可以在容器日志中看到进入该服务器的请求。其他的一些改变使你可以在没有 root 权限的情况下使用 Podman 运行容器,也可以在没有 root 权限的情况下运行容器中的进程。 + +在 Web 服务器上的第一个测试并不提供任何 Cloud-init 数据;只是用它来查看 Cloud-init 客户端的请求。 + +创建容器文件后,使用 Podman 构建并运行 Web 服务器镜像: + +``` +# Build the container image +$ podman build -f Containerfile -t cloud-init:01 . + +# Create a container from the new image, and run it +# It will listen on port 8080 +$ podman run --rm -p 8080:8080 -it cloud-init:01 +``` + +这会运行一个容器,让你的终端连接到一个伪 TTY。一开始看起来什么都没有发生,但是对主机 8080 端口的请求会被路由到容器内的 Nginx 服务器,并且在终端窗口中会出现一条日志信息。这一点可以用主机上的 `curl` 命令进行测试。 + +``` +# Use curl to send an HTTP request to the Nginx container +$ curl http://localhost:8080 +``` + +运行该 `curl` 命令后,你应该会在终端窗口中看到类似这样的日志信息: + +``` +127.0.0.1 - - [09/May/2020:19:25:10 +0000] "GET / HTTP/1.1" 200 5564 "-" "curl/7.66.0" "-" +``` + +现在,有趣的部分来了:重启 Cloud-init 客户端,并观察 Nginx 日志,看看当客户端启动时, Cloud-init 向 Web 服务器发出了什么请求。 + +当客户端完成其启动过程时,你应该会看到类似的日志消息。 + +``` +2020/05/09 22:44:28 [error] 2#0: *4 open() "/usr/share/nginx/html/meta-data" failed (2: No such file or directory), client: 127.0.0.1, server: _, request: "GET /meta-data HTTP/1.1", host: "instance-data:8080" +127.0.0.1 - - [09/May/2020:22:44:28 +0000] "GET /meta-data HTTP/1.1" 404 3650 "-" "Cloud-Init/17.1" "-" +``` + +注:使用 `Ctrl+C` 停止正在运行的容器。 + +你可以看到请求是针对 `/meta-data` 路径的,即 `http://ip_address_of_the_webserver:8080/meta-data`。这只是一个 GET 请求 —— Cloud-init 并没有向 Web 服务器发送任何数据。它只是盲目地从数据源 URL 中请求文件,所以要由数据源来识别主机的要求。这个简单的例子只是向任何客户端发送通用数据,但一个更大的家庭实验室应该需要更复杂的服务。 + +在这里,Cloud-init 请求的是[实例元数据][10]信息。这个文件可以包含很多关于实例本身的信息,例如实例 ID、分配实例的主机名、云 ID,甚至网络信息。 + +创建一个包含实例 ID 和主机名的基本元数据文件,并尝试将其提供给 Cloud-init 客户端。 + +首先,创建一个可复制到容器镜像中的 `meta-data` 文件。 + +``` +instance-id: iid-local01 +local-hostname: raspberry +hostname: raspberry +``` + +实例 ID(`instance-id`)可以是任何东西。但是,如果你在 Cloud-init 运行后更改实例 ID,并且文件被送达客户端,就会触发 Cloud-init 再次运行。你可以使用这种机制来更新实例配置,但你应该意识到它是这种工作方式。 + +`local-hostname` 和 `hostname` 键正如其名,它们会在 Cloud-init 运行时为客户端设置主机名信息。 + +在容器文件中添加以下行以将 `meta-data` 文件复制到新镜像中。 + +``` +# Copy the meta-data file into the image for Nginx to serve it +COPY meta-data ${WWW_DIR}/meta-data +``` + +现在,用元数据文件重建镜像(使用一个新的标签以方便故障排除),并用 Podman 创建并运行一个新的容器。 + +``` +# Build a new image named cloud-init:02 +podman build -f Containerfile -t cloud-init:02 . + +# Run a new container with this new meta-data file +podman run --rm -p 8080:8080 -it cloud-init:02 +``` + +新容器运行后,重启 Cloud-init 客户端,再次观察 Nginx 日志。 + +``` +127.0.0.1 - - [09/May/2020:22:54:32 +0000] "GET /meta-data HTTP/1.1" 200 63 "-" "Cloud-Init/17.1" "-" +2020/05/09 22:54:32 [error] 2#0: *2 open() "/usr/share/nginx/html/user-data" failed (2: No such file or directory), client: 127.0.0.1, server: _, request: "GET /user-data HTTP/1.1", host: "instance-data:8080" +127.0.0.1 - - [09/May/2020:22:54:32 +0000] "GET /user-data HTTP/1.1" 404 3650 "-" "Cloud-Init/17.1" "-" +``` + +你看,这次 `/meta-data` 路径被提供给了客户端。成功了! + +然而,客户端接着在 `/user-data` 路径上寻找第二个文件。该文件包含实例所有者提供的配置数据,而不是来自云提供商的数据。对于一个家庭实验室来说,这两个都是你自己提供的。 + +你可以使用[许多 user-data 模块][11]来配置你的实例。对于这个例子,只需使用 `write_files` 模块在客户端创建一些测试文件,并验证 Cloud-init 是否工作。 + +创建一个包含以下内容的用户数据文件: + +``` +#cloud-config + +# Create two files with example content using the write_files module +write_files: + - content: | +    "Does cloud-init work?" +   owner: root:root +   permissions: '0644' +   path: /srv/foo + - content: | +   "IT SURE DOES!" +   owner: root:root +   permissions: '0644' +   path: /srv/bar +``` + +除了使用 Cloud-init 提供的 `user-data` 模块制作 YAML 文件外,你还可以将其制作成一个可执行脚本供 Cloud-init 运行。 + +创建 `user-data` 文件后,在容器文件中添加以下行,以便在重建映像时将其复制到镜像中: + +``` +# Copy the user-data file into the container image +COPY user-data ${WWW_DIR}/user-data +``` + +重建镜像,并创建和运行一个新的容器,这次使用用户数据信息: + +``` +# Build a new image named cloud-init:03 +podman build -f Containerfile -t cloud-init:03 . + +# Run a new container with this new user-data file +podman run --rm -p 8080:8080 -it cloud-init:03 +``` + +现在,重启 Cloud-init 客户端,观察 Web 服务器上的 Nginx 日志: + +``` +127.0.0.1 - - [09/May/2020:23:01:51 +0000] "GET /meta-data HTTP/1.1" 200 63 "-" "Cloud-Init/17.1" "-" +127.0.0.1 - - [09/May/2020:23:01:51 +0000] "GET /user-data HTTP/1.1" 200 298 "-" "Cloud-Init/17.1" "- +``` + +成功了!这一次,元数据和用户数据文件都被送到了 Cloud-init 客户端。 + +### 验证 Cloud-init 已运行 + +从上面的日志中,你知道 Cloud-init 在客户端主机上运行并请求元数据和用户数据文件,但它用它们做了什么?你可以在 `write_files` 部分验证 Cloud-init 是否写入了你在用户数据文件中添加的文件。 + +在 Cloud-init 客户端上,检查 `/srv/foo` 和 `/srv/bar` 文件的内容: + +``` +# cd /srv/ && ls +bar foo +# cat foo +"Does cloud-init work?" +# cat bar +"IT SURE DOES!" +``` + +成功了!文件已经写好了,并且有你期望的内容。 + +如上所述,还有很多其他模块可以用来配置主机。例如,用户数据文件可以配置成用 `apt` 添加包、复制 SSH 的 `authorized_keys`、创建用户和组、配置和运行配置管理工具等等。我在家里的私有云中使用它来复制我的 `authorized_keys`、创建一个本地用户和组,并设置 sudo 权限。 + +### 你接下来可以做什么 + +Cloud-init 在家庭实验室中很有用,尤其是专注于云技术的实验室。本文所演示的简单服务对于家庭实验室来说可能并不是超级有用,但现在你已经知道 Cloud-init 是如何工作的了,你可以继续创建一个动态服务,可以用自定义数据配置每台主机,让家里的私有云更类似于主流云提供商提供的服务。 + +在数据源稍显复杂的情况下,将新的物理(或虚拟)机器添加到家中的私有云中,可以像插入它们并打开它们一样简单。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/create-simple-cloud-init-service-your-homelab + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop) +[2]: https://cloudinit.readthedocs.io/ +[3]: https://linux.cn/article-12371-1.html +[4]: https://opensource.com/sites/default/files/uploads/cloud-init.jpg (A screen showing the boot process for a Linux server running Cloud-init ) +[5]: https://creativecommons.org/licenses/by-sa/4.0/ +[6]: https://linux.cn/article-12277-1.html +[7]: https://cloudinit.readthedocs.io/en/latest/topics/datasources.html +[8]: https://podman.io/ +[9]: https://github.com/clcollins/homelabCloudInit/tree/master/simpleCloudInitService/data +[10]: https://cloudinit.readthedocs.io/en/latest/topics/instancedata.html#what-is-instance-data +[11]: https://cloudinit.readthedocs.io/en/latest/topics/modules.html diff --git a/published/202007/20200605 Build a Kubernetes cluster with the Raspberry Pi.md b/published/202007/20200605 Build a Kubernetes cluster with the Raspberry Pi.md new file mode 100644 index 0000000000..3055c80de0 --- /dev/null +++ b/published/202007/20200605 Build a Kubernetes cluster with the Raspberry Pi.md @@ -0,0 +1,424 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12421-1.html) +[#]: subject: (Build a Kubernetes cluster with the Raspberry Pi) +[#]: via: (https://opensource.com/article/20/6/kubernetes-raspberry-pi) +[#]: author: (Chris Collins https://opensource.com/users/clcollins) + +用树莓派构建 Kubernetes 集群 +====== + +> 将 Kubernetes 安装在多个树莓派上,实现自己的“家庭私有云”容器服务。 + +![](https://img.linux.net.cn/data/attachment/album/202007/15/234152ivw1y2wwhmhmpuvo.jpg) + +[Kubernetes][2] 从一开始就被设计为云原生的企业级容器编排系统。它已经成长为事实上的云容器平台,并由于接受了容器原生虚拟化和无服务器计算等新技术而继续发展。 + +从微型的边缘计算到大规模的容器环境,无论是公有云还是私有云环境,Kubernetes 都可以管理其中的容器。它是“家庭私有云”项目的理想选择,既提供了强大的容器编排,又让你有机会了解一项这样的技术 —— 它的需求如此之大,与云计算结合得如此彻底,以至于它的名字几乎就是“云计算”的代名词。 + +没有什么比 Kubernetes 更懂“云”,也没有什么能比树莓派更合适“集群起来”!在廉价的树莓派硬件上运行本地的 Kubernetes 集群是获得在真正的云技术巨头上进行管理和开发的经验的好方法。 + +### 在树莓派上安装 Kubernetes 集群 + +本练习将在三个或更多运行 Ubuntu 20.04 的树莓派 4 上安装 Kubernetes 1.18.2 集群。Ubuntu 20.04(Focal Fossa)提供了针对 64 位 ARM(ARM64)的树莓派镜像(64 位内核和用户空间)。由于目标是使用这些树莓派来运行 Kubernetes 集群,因此运行 AArch64 容器镜像的能力非常重要:很难找到 32 位的通用软件镜像乃至于标准基础镜像。借助 Ubuntu 20.04 的 ARM64 镜像,可以让你在 Kubernetes 上使用 64 位容器镜像。 + +#### AArch64 vs. ARM64;32 位 vs. 64 位;ARM vs. x86 + +请注意,AArch64 和 ARM64 实际上是同一种东西。不同的名称源于它们在不同社区中的使用。许多容器镜像都标为 AArch64,并能在标为 ARM64 的系统上正常运行。采用 AArch64/ARM64 架构的系统也能够运行 32 位的 ARM 镜像,但反之则不然:32 位的 ARM 系统无法运行 64 位的容器镜像。这就是 Ubuntu 20.04 ARM64 镜像如此有用的原因。 + +这里不会太深入地解释不同的架构类型,值得注意的是,ARM64/AArch64 和 x86\_64 架构是不同的,运行在 64 位 ARM 架构上的 Kubernetes 节点无法运行为 x86\_64 构建的容器镜像。在实践中,你会发现有些镜像没有为两种架构构建,这些镜像可能无法在你的集群中使用。你还需要在基于 Arch64 的系统上构建自己的镜像,或者跳过一些限制以让你的常规的 x86\_64 系统构建 Arch64 镜像。在“家庭私有云”项目的后续文章中,我将介绍如何在常规系统上构建 AArch64 镜像。 + +为了达到两全其美的效果,在本教程中设置好 Kubernetes 集群后,你可以在以后向其中添加 x86\_64 节点。你可以通过使用 [Kubernetes 的污点taint容忍toleration][3] 能力,由 Kubernetes 的调度器将给定架构的镜像调度到相应的节点上运行。 + +关于架构和镜像的内容就不多说了。是时候安装 Kubernetes 了,开始吧! + +#### 前置需求 + +这个练习的要求很低。你将需要: + +* 三台(或更多)树莓派 4(最好是 4GB 内存的型号)。 +* 在全部树莓派上安装 Ubuntu 20.04 ARM64。 + +为了简化初始设置,请阅读《[修改磁盘镜像来创建基于树莓派的家庭实验室][4]》,在将 Ubuntu 镜像写入 SD 卡并安装在树莓派上之前,添加一个用户和 SSH 授权密钥(`authorized_keys`)。 + +### 配置主机 + +在 Ubuntu 被安装在树莓派上,并且可以通过 SSH 访问后,你需要在安装 Kubernetes 之前做一些修改。 + +#### 安装和配置 Docker + +截至目前,Ubuntu 20.04 在 base 软件库中提供了最新版本的 Docker,即 v19.03,可以直接使用 `apt` 命令安装它。请注意,包名是 `docker.io`。请在所有的树莓派上安装 Docker: + +``` +# 安装 docker.io 软件包 +$ sudo apt install -y docker.io +``` + +安装好软件包后,你需要做一些修改来启用 [cgroup][5](控制组)。cgroup 允许 Linux 内核限制和隔离资源。实际上,这可以让 Kubernetes 更好地管理其运行的容器所使用的资源,并通过让容器彼此隔离来增加安全性。 + +在对所有树莓派进行以下修改之前,请检查 `docker info` 的输出: + +``` +# 检查 `docker info` +# 省略了某些输出 +$ sudo docker info +(...) + Cgroup Driver: cgroups +(...) +WARNING: No memory limit support +WARNING: No swap limit support +WARNING: No kernel memory limit support +WARNING: No kernel memory TCP limit support +WARNING: No oom kill disable support +``` + +上面的输出突出显示了需要修改的部分:cgroup 驱动和限制支持。 + +首先,将 Docker 使用的默认 cgroup 驱动从 `cgroups` 改为 `systemd`,让 systemd 充当 cgroup 管理器,确保只有一个 cgroup 管理器在使用。这有助于系统的稳定性,这也是 Kubernetes 所推荐的。要做到这一点,请创建 `/etc/docker/daemon.json` 文件或将内容替换为: + +``` +# 创建或替换 /etc/docker/daemon.json 以启用 cgroup 的 systemd 驱动 + +$ sudo cat > /etc/docker/daemon.json <容器网络接口Container Network Interface(CNI)加载项使用。本练习使用的是 [Flannel][7] CNI。你选择的 CIDR 不应该与你的家庭网络中当前使用的任何 CIDR 重叠,也不应该与你的路由器或 DHCP 服务器管理的 CIDR 重叠。确保使用一个比你预期需要的更大的子网:**总是**有比你最初计划的更多的 Pod!在这个例子中,我将使用 CIDR 地址 `10.244.0.0/16`,但你可以选择一个适合你的。 + +有了这些决定,你就可以初始化控制平面节点了。用 SSH 或其他方式登录到你为控制平面指定的节点。 + +#### 初始化控制平面 + +Kubernetes 使用一个引导令牌来验证被加入集群的节点。当初始化控制平面节点时,需要将此令牌传递给 `kubeadm init` 命令。用 `kubeadm token generate` 命令生成一个令牌: + +``` +# 生成一个引导令牌来验证加入集群的节点 +$ TOKEN=$(sudo kubeadm token generate) +$ echo $TOKEN +d584xg.xupvwv7wllcpmwjy +``` + +现在你可以使用 `kubeadm init` 命令来初始化控制平面了: + +``` +# 初始化控制平面 +#(输出略) +$ sudo kubeadm init --token=${TOKEN} --kubernetes-version=v1.18.2 --pod-network-cidr=10.244.0.0/16 +``` + +如果一切顺利,你应该在输出的最后看到类似这样的东西: + +``` +Your Kubernetes control-plane has initialized successfully! + +To start using your cluster, you need to run the following as a regular user: + + mkdir -p $HOME/.kube + sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config + sudo chown $(id -u):$(id -g) $HOME/.kube/config + +You should now deploy a pod network to the cluster. +Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: + https://kubernetes.io/docs/concepts/cluster-administration/addons/ + +Then you can join any number of worker nodes by running the following on each as root: + +kubeadm join 192.168.2.114:6443 --token zqqoy7.9oi8dpkfmqkop2p5 \ + --discovery-token-ca-cert-hash sha256:71270ea137214422221319c1bdb9ba6d4b76abfa2506753703ed654a90c4982b +``` + +注意两点:第一,Kubernetes 的 `kubectl` 连接信息已经写入到 `/etc/kubernetes/admin.conf`。这个 kubeconfig 文件可以复制到用户的 `~/.kube/config` 中,可以是主节点上的 root 用户或普通用户,也可以是远程机器。这样你就可以用 `kubectl` 命令来控制你的集群。 + +其次,输出中以 `kubernetes join` 开头的最后一行是你可以运行的命令,你可以运行这些命令加入更多的节点到集群中。 + +将新的 kubeconfig 复制到你的用户可以使用的地方后,你可以用 `kubectl get nodes` 命令来验证控制平面是否已经安装: + +``` +# 显示 Kubernetes 集群中的节点 +# 你的节点名称会有所不同 +$ kubectl get nodes +NAME         STATUS   ROLES    AGE     VERSION +elderberry   Ready    master   7m32s   v1.18.2 +``` + +#### 安装 CNI 加载项 + +CNI 加载项负责 Pod 网络的配置和清理。如前所述,这个练习使用的是 Flannel CNI 加载项,在已经设置好 `podCIDR` 值的情况下,你只需下载 Flannel YAML 并使用 `kubectl apply` 将其安装到集群中。这可以用 `kubectl apply -f -` 从标准输入中获取数据,用一行命令完成。这将创建管理 Pod 网络所需的 ClusterRoles、ServiceAccounts 和 DaemonSets 等。 + +下载并应用 Flannel YAML 数据到集群中: + +``` +# 下载 Flannel YAML 数据并应用它 +# (输出略) +$ curl -sSL https://raw.githubusercontent.com/coreos/flannel/v0.12.0/Documentation/kube-flannel.yml | kubectl apply -f - +``` + +#### 将计算节点加入到集群中 + +有了 CNI 加载项,现在是时候将计算节点添加到集群中了。加入计算节点只需运行 `kube init` 命令末尾提供的 `kubeadm join` 命令来初始化控制平面节点。对于你想加入集群的其他树莓派,登录主机,运行命令即可: + +``` +# 加入节点到集群,你的令牌和 ca-cert-hash 应各有不同 +$ sudo kubeadm join 192.168.2.114:6443 --token zqqoy7.9oi8dpkfmqkop2p5 \ +    --discovery-token-ca-cert-hash sha256:71270ea137214422221319c1bdb9ba6d4b76abfa2506753703ed654a90c4982b +``` + +一旦你完成了每个节点的加入,你应该能够在 `kubectl get nodes` 的输出中看到新节点: + +``` +# 显示 Kubernetes 集群中的节点 +# 你的节点名称会有所不同 +$ kubectl get nodes +NAME         STATUS   ROLES    AGE     VERSION +elderberry   Ready    master   7m32s   v1.18.2 +gooseberry    Ready    <none>   2m39s   v1.18.2 +huckleberry   Ready    <none>   17s     v1.18.2 +``` + +#### 验证集群 + +此时,你已经拥有了一个完全正常工作的 Kubernetes 集群。你可以运行 Pod、创建部署和作业等。你可以使用[服务][8]从集群中的任何一个节点访问集群中运行的应用程序。你可以通过 NodePort 服务或入口控制器实现外部访问。 + +要验证集群正在运行,请创建一个新的命名空间、部署和服务,并检查在部署中运行的 Pod 是否按预期响应。此部署使用 `quay.io/clcollins/kube-verify:01` 镜像,这是一个监听请求的 Nginx 容器(实际上,与文章《[使用 Cloud-init 将节点添加到你的私有云][9]》中使用的镜像相同)。你可以在[这里][10]查看镜像的容器文件。 + +为部署创建一个名为 `kube-verify` 的命名空间: + +``` +# 创建一个新的命名空间 +$ kubectl create namespace kube-verify +# 列出命名空间 +$ kubectl get namespaces +NAME              STATUS   AGE +default           Active   63m +kube-node-lease   Active   63m +kube-public       Active   63m +kube-system       Active   63m +kube-verify       Active   19s +``` + +现在,在新的命名空间创建一个部署: + +``` +# 创建一个新的部署 +$ cat < + + + +``` + +成功了!你的服务正在运行,容器内的 Nginx 正在响应你的请求。你的服务正在运行,容器内的 Nginx 正在响应你的请求。 + +此时,你的树莓派上有一个正在运行的 Kubernetes 集群,安装了一个 CNI 加载项(Flannel),并有一个运行 Nginx Web 服务器的测试部署和服务。在大型公有云中,Kubernetes 有不同的入口控制器来与不同的解决方案交互,比如最近报道的 [Skipper][12] 项目。同样,私有云也有与硬件负载均衡器设备(如 F5 Networks 的负载均衡器)交互的入口控制器,或用于处理进入节点的流量的 Nginx 和 HAProxy 控制器。 + +在以后的文章中,我将通过安装自己的入口控制器来解决将集群中的服务暴露给外界的问题。我还将研究动态存储供应器和 StorageClasses,以便为应用程序分配持久性存储,包括利用你在上一篇文章《[将树莓派家庭实验室变成网络文件系统][13]》中设置的 NFS 服务器来为你的 Pod 创建按需存储。 + +### 去吧,Kubernetes + +“Kubernetes”(κυβερνήτης)在希腊语中是飞行员的意思 —— 但这是否意味着驾驶船只以及引导船只的人?诶,不是。“Kubernan”(κυβερνάω)是希腊语“驾驶”或“引导”的意思,因此,去吧,Kubernan,如果你在会议上或其它什么活动上看到我,请试着给我一个动词或名词的通行证,以另一种语言 —— 我不会说的语言。 + +免责声明:如前所述,我不会读也不会讲希腊语,尤其是古希腊语,所以我选择相信我在网上读到的东西。你知道那是怎么一回事。我对此有所保留,放过我吧,因为我没有开“对我来说都是希腊语”这种玩笑。然而,只是提一下,虽然我可以开玩笑,但是实际上没有,所以我要么偷偷摸摸,要么聪明,要么两者兼而有之。或者,两者都不是。我并没有说这是个好笑话。 + +所以,去吧,像专业人员一样在你的家庭私有云中用自己的 Kubernetes 容器服务来试运行你的容器吧!当你越来越得心应手时,你可以修改你的 Kubernetes 集群,尝试不同的选项,比如前面提到的入口控制器和用于持久卷的动态 StorageClasses。 + +这种持续学习是 [DevOps][14] 的核心,持续集成和新服务交付反映了敏捷方法论,当我们学会了处理云实现的大规模扩容,并发现我们的传统做法无法跟上步伐时,我们就接受了这两种方法论。 + +你看,技术、策略、哲学、一小段希腊语和一个可怕的原始笑话,都汇聚在一篇文章当中。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/kubernetes-raspberry-pi + +作者:[Chris Collins][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clcollins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi_cartoon.png?itok=m3TcBONJ (Cartoon graphic of Raspberry Pi board) +[2]: https://opensource.com/resources/what-is-kubernetes +[3]: https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ +[4]: https://linux.cn/article-12277-1.html +[5]: https://en.wikipedia.org/wiki/Cgroups +[6]: https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing +[7]: https://github.com/coreos/flannel +[8]: https://kubernetes.io/docs/concepts/services-networking/service/ +[9]: https://linux.cn/article-12407-1.html +[10]: https://github.com/clcollins/homelabCloudInit/blob/master/simpleCloudInitService/data/Containerfile +[11]: http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" +[12]: https://opensource.com/article/20/4/http-kubernetes-skipper +[13]: https://linux.cn/article-12413-1.html +[14]: https://opensource.com/tags/devops diff --git a/published/202007/20200608 How to Create Curve Text in GIMP in 5 Simple Steps -GIMP Beginner-s Tutorial.md b/published/202007/20200608 How to Create Curve Text in GIMP in 5 Simple Steps -GIMP Beginner-s Tutorial.md new file mode 100644 index 0000000000..3a6c0a44d4 --- /dev/null +++ b/published/202007/20200608 How to Create Curve Text in GIMP in 5 Simple Steps -GIMP Beginner-s Tutorial.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12396-1.html) +[#]: subject: (How to Create Curve Text in GIMP in 5 Simple Steps [GIMP Beginner’s Tutorial]) +[#]: via: (https://itsfoss.com/curve-text-gimp/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +GIMP 教程:如何在 GIMP 中创建曲线文本 +====== + +当你在 GIMP 中制作一个徽章、海报或其它任何作品时,你需要扭曲或弯曲一些文本。多功能的 [GIMP][1] 工具提供了一些创建弯曲文本的方法。取决于你将如何使用它和你想给予文本的弧度,有一些适合不同情况的方法。 + +在本篇教程中,我将向你展示我最喜欢的创建曲线文本的方法。 + +### 如何在 GIMP 中创建曲线文本 + +![][2] + +请确保你已经在你的系统上安装了 GIMP。 + +#### 步骤 1: 创建一个你想要的匹配曲线的路径 + +创建一个新的图像或打开一个现有的图像。选择 “工具 -> 路径”,然后大致考虑曲线文本的位置,通过分别单击路径点的开始点和结束点来创建路径。 + +![创建一个路径][3] + +**然后给你的路径一个曲率。**首先向上或向下拖动中间的直线,然后通过移动调整点进行微调。这将给予它一个拱形结构。 + +![弯曲路径][4] + +#### 步骤 2: 创建你想弯曲的文本 + +当你对自己的曲线路径满意时,你可以移动到接下来的步骤,并 **创建你的文本**。 + +你可能想更改字体及其大小。我的选择只是为了演示用途。 + +![创建一个文本][5] + +#### 步骤 3: 创建一个新的图层 + +我强烈建议分割 GIMP 图像中的每个不同的元素到不同的图层中,以便很容易地控制它们,像移动,打开/关闭一个元素等等。 + +遵循这一规则,我们要弯曲的文本将被放置到一个新的图层中。建议使用像 “Curved Text” 一样的名字来命名你的新的图层,或者一些类似的东西来很容易地识别它。 + +![为弯曲的文本创建一个新的图层][6] + +#### 步骤 4: 弯曲文本 + +现在你需要在你的文本图层上单击,接下来在其上右击,并单击“文字对齐路径”来折弯你的文本。弯曲的文本将被放置到新创建的图层。 + +![文字对齐路径][7] + +你把文本弯曲了!让我们使用颜色填充文本来使其更令人满意。 + +### 步骤 5: 最后的修饰和导出 + +单击弯曲的文本图层,然后转到路径选项卡来选择文本边界。 + +![路径选择][8] + +最后,选择油漆桶工具,选择一种颜色,并如下应用你的选择区。 + +![][9] + +随着最后一步的到来,打开不需要的层的可见性,只保留曲线文本。接下来,需要导出你的文件为你喜欢的图像格式。 + +![][10] + +#### 额外提示:创建阴影效果 + +我还有一个作为一次挑战的额外的步骤,如果你想更进一步的话。让我们在 [GIMP 中勾勒文本][11]以创建一个弯曲文本的阴影效果。 + +我将给予你一些提示: + + * 重新启用所有图层 + * 单击弯曲文本图层,并使用移动工具来到处移动文本 + * 创建另一个图层,并使用黑色来重复油漆桶填充程序 + * 以一种模拟一种阴影位置的方式覆盖图层(你可能需要更改图层顺序) + * 关闭辅助图层 + +最终结果: + +![][12] + +让我在评论区知道你们对这篇 GIMP 教程的想法,以及有多少人尝试了这一额外的步骤。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/curve-text-gimp/ + +作者:[Dimitrios Savvopoulos][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/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://www.gimp.org/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/Curve-text-in-GIMP.jpg?ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/1image-1.png?fit=800%2C508&ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/2.png?fit=800%2C500&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/3.png?fit=800%2C503&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/new-layer.png?fit=800%2C637&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/text-along-path.png?fit=800%2C625&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/path-to-selection.png?ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/6.png?fit=800%2C539&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/4.png-copy.png?ssl=1 +[11]: https://itsfoss.com/gimp-text-outline/ +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/its-foss-curved.jpg?fit=800%2C409&ssl=1 +[13]: https://itsfoss.com/subscribe-to-newsletter/ diff --git a/published/202007/20200611 Stop debugging Go with Println and use Delve instead.md b/published/202007/20200611 Stop debugging Go with Println and use Delve instead.md new file mode 100644 index 0000000000..ed93db45b4 --- /dev/null +++ b/published/202007/20200611 Stop debugging Go with Println and use Delve instead.md @@ -0,0 +1,552 @@ +[#]: collector: (lujun9972) +[#]: translator: (lxbwolf) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12400-1.html) +[#]: subject: (Stop debugging Go with Println and use Delve instead) +[#]: via: (https://opensource.com/article/20/6/debug-go-delve) +[#]: author: (Gaurav Kamathe https://opensource.com/users/gkamathe) + +使用 Delve 代替 Println 来调试 Go 程序 +====== + +> Delve 是能让调试变成轻而易举的事的万能工具包。 + +![](https://img.linux.net.cn/data/attachment/album/202007/09/234357pavw88sbxab0makj.jpg) + +你上次尝试去学习一种新的编程语言时什么时候?你有没有持之以恒,你是那些在新事物发布的第一时间就勇敢地去尝试的一员吗?不管怎样,学习一种新的语言也许非常有用,也会有很多乐趣。 + +你尝试着写简单的 “Hello, world!”,然后写一些示例代码并执行,继续做一些小的修改,之后继续前进。我敢保证我们都有过这个经历,不论我们使用哪种技术。假如你尝试用一段时间一种语言,并且你希望能够精通它,那么有一些事物能在你的进取之路上帮助你。 + +其中之一就是调试器。有些人喜欢在代码中用简单的 “print” 语句进行调试,这种方式很适合代码量少的简单程序;然而,如果你处理的是有多个开发者和几千行代码的大型项目,你应该使用调试器。 + +最近我开始学习 Go 编程语言了,在本文中,我们将探讨一种名为 Delve 的调试器。Delve 是专门用来调试 Go 程序的工具,我们会借助一些 Go 示例代码来了解下它的一些功能。不要担心这里展示的 Go 示例代码;即使你之前没有写过 Go 代码也能看懂。Go 的目标之一是简单,因此代码是始终如一的,理解和解释起来都很容易。 + +### Delve 介绍 + +Delve 是托管在 [GitHub][2] 上的一个开源项目。 + +它自己的文档中写道: + +> Delve 是 Go 编程语言的调试器。该项目的目标是为 Go 提供一个简单、全功能的调试工具。Delve 应该是易于调用和易于使用的。当你使用调试器时,事情可能不会按你的思路运行。如果你这样想,那么你不适合用 Delve。 + +让我们来近距离看一下。 + +我的测试系统是运行着 Fedora Linux 的笔记本电脑,Go 编译器版本如下: + +``` +$ cat /etc/fedora-release +Fedora release 30 (Thirty) +$ +$ go version +go version go1.12.17 linux/amd64 +$ +``` + +### Golang 安装 + +如果你没有安装 Go,你可以运行下面的命令,很轻松地就可以从配置的仓库中获取。 + +``` +$ dnf install golang.x86_64 +``` + +或者,你可以在[安装页面][3]找到适合你的操作系统的其他安装版本。 + +在开始之前,请先确认已经设置好了 Go 工具依赖的下列各个路径。如果这些路径没有设置,有些示例可能不能正常运行。你可以在 SHELL 的 RC 文件中轻松设置这些环境变量,我的机器上是在 `$HOME/bashrc` 文件中设置的。 + +``` +$ go env | grep GOPATH +GOPATH="/home/user/go" +$ +$ go env | grep GOBIN +GOBIN="/home/user/go/gobin" +$ +``` + +### Delve 安装 + +你可以像下面那样,通过运行一个简单的 `go get` 命令来安装 Delve。`go get` 是 Golang 从外部源下载和安装需要的包的方式。如果你安装过程中遇到了问题,可以查看 [Delve 安装教程][4]。 + +``` +$ go get -u github.com/go-delve/delve/cmd/dlv +$ +``` + +运行上面的命令,就会把 Delve 下载到你的 `$GOPATH` 的位置,如果你没有把 `$GOPATH` 设置成其他值,那么默认情况下 `$GOPATH` 和 `$HOME/go` 是同一个路径。 + +你可以进入 `go/` 目录,你可以在 `bin/` 目录下看到 `dlv`。 + +``` +$ ls -l $HOME/go +total 8 +drwxrwxr-x. 2 user user 4096 May 25 19:11 bin +drwxrwxr-x. 4 user user 4096 May 25 19:21 src +$ +$ ls -l ~/go/bin/ +total 19596 +-rwxrwxr-x. 1 user user 20062654 May 25 19:17 dlv +$ +``` + +因为你把 Delve 安装到了 `$GOPATH`,所以你可以像运行普通的 shell 命令一样运行它,即每次运行时你不必先进入它所在的目录。你可以通过 `version` 选项来验证 `dlv` 是否正确安装。示例中安装的版本是 1.4.1。 + +``` +$ which dlv +~/go/bin/dlv +$ +$ dlv version +Delve Debugger +Version: 1.4.1 +Build: $Id: bda606147ff48b58bde39e20b9e11378eaa4db46 $ +$ +``` + +现在,我们一起在 Go 程序中使用 Delve 来理解下它的功能以及如何使用它们。我们先来写一个 `hello.go`,简单地打印一条 `Hello, world!` 信息。 + +记着,我把这些示例程序放到了 `$GOBIN` 目录下。 + +``` +$ pwd +/home/user/go/gobin +$ +$ cat hello.go +package main + +import "fmt" + +func main() { +        fmt.Println("Hello, world!") +} +$ +``` + +运行 `build` 命令来编译一个 Go 程序,它的输入是 `.go` 后缀的文件。如果程序没有语法错误,Go 编译器把它编译成一个二进制可执行文件。这个文件可以被直接运行,运行后我们会在屏幕上看到 `Hello, world!` 信息。 + +``` +$ go build hello.go +$ +$ ls -l hello +-rwxrwxr-x. 1 user user 1997284 May 26 12:13 hello +$ +$ ./hello +Hello, world! +$ +``` + +### 在 Delve 中加载程序 + +把一个程序加载进 Delve 调试器有两种方式。 + +#### 在源码编译成二进制文件之前使用 debug 参数 + +第一种方式是在需要时对源码使用 `debug` 命令。Delve 会为你编译出一个名为 `__debug_bin` 的二进制文件,并把它加载进调试器。 + +在这个例子中,你可以进入 `hello.go` 所在的目录,然后运行 `dlv debug` 命令。如果目录中有多个源文件且每个文件都有自己的主函数,Delve 则可能抛出错误,它期望的是单个程序或从单个项目构建成单个二进制文件。如果出现了这种错误,那么你就应该用下面展示的第二种方式。 + +``` +$ ls -l +total 4 +-rw-rw-r--. 1 user user 74 Jun  4 11:48 hello.go +$ +$ dlv debug +Type 'help' for list of commands. +(dlv) +``` + +现在打开另一个终端,列出目录下的文件。你可以看到一个多出来的 `__debug_bin` 二进制文件,这个文件是由源码编译生成的,并会加载进调试器。你现在可以回到 `dlv` 提示框继续使用 Delve。 + +``` +$ ls -l +total 2036 +-rwxrwxr-x. 1 user user 2077085 Jun  4 11:48 __debug_bin +-rw-rw-r--. 1 user user      74 Jun  4 11:48 hello.go +$ +``` + +#### 使用 exec 参数 + +如果你已经有提前编译好的 Go 程序或者已经用 `go build` 命令编译完成了,不想再用 Delve 编译出 `__debug_bin` 二进制文件,那么第二种把程序加载进 Delve 的方法在这些情况下会很有用。在上述情况下,你可以使用 `exec` 命令来把整个目录加载进 Delve 调试器。 + +``` +$ ls -l +total 4 +-rw-rw-r--. 1 user user 74 Jun  4 11:48 hello.go +$ +$ go build hello.go +$ +$ ls -l +total 1956 +-rwxrwxr-x. 1 user user 1997284 Jun  4 11:54 hello +-rw-rw-r--. 1 user user      74 Jun  4 11:48 hello.go +$ +$ dlv exec ./hello +Type 'help' for list of commands. +(dlv) +``` + +### 查看 delve 帮助信息 + +在 `dlv` 提示符中,你可以运行 `help` 来查看 Delve 提供的多种帮助选项。命令列表相当长,这里我们只列举一些重要的功能。下面是 Delve 的功能概览。 + +``` +(dlv) help +The following commands are available: + +Running the program: + +Manipulating breakpoints: + +Viewing program variables and memory: + +Listing and switching between threads and goroutines: + +Viewing the call stack and selecting frames: + +Other commands: + +Type help followed by a command for full documentation. +(dlv) +``` + +#### 设置断点 + +现在我们已经把 hello.go 程序加载进了 Delve 调试器,我们在主函数处设置断点,稍后来确认它。在 Go 中,主程序从 `main.main` 处开始执行,因此你需要给这个名字提供个 `break` 命令。之后,我们可以用 `breakpoints` 命令来检查断点是否正确设置了。 + +不要忘了你还可以用命令简写,因此你可以用 `b main.main` 来代替 `break main.main`,两者效果相同,`bp` 和 `breakpoints` 同理。你可以通过运行 `help` 命令查看帮助信息来找到你想要的命令简写。 + +``` +(dlv) break main.main +Breakpoint 1 set at 0x4a228f for main.main() ./hello.go:5 +(dlv) breakpoints +Breakpoint runtime-fatal-throw at 0x42c410 for runtime.fatalthrow() /usr/lib/golang/src/runtime/panic.go:663 (0) +Breakpoint unrecovered-panic at 0x42c480 for runtime.fatalpanic() /usr/lib/golang/src/runtime/panic.go:690 (0) +        print runtime.curg._panic.arg +Breakpoint 1 at 0x4a228f for main.main() ./hello.go:5 (0) +(dlv) +``` + +#### 程序继续执行 + +现在,我们用 `continue` 来继续运行程序。它会运行到断点处中止,在我们的例子中,会运行到主函数的 `main.main` 处中止。从这里开始,我们可以用 `next` 命令来逐行执行程序。请注意,当我们运行到 `fmt.Println("Hello, world!")` 处时,即使我们还在调试器里,我们也能看到打印到屏幕的 `Hello, world!`。 + +``` +(dlv) continue +> main.main() ./hello.go:5 (hits goroutine(1):1 total:1) (PC: 0x4a228f) +     1: package main +     2: +     3: import "fmt" +     4: +=>   5:      func main() { +     6:         fmt.Println("Hello, world!") +     7: } +(dlv) next +> main.main() ./hello.go:6 (PC: 0x4a229d) +     1: package main +     2: +     3: import "fmt" +     4: +     5: func main() { +=>   6:              fmt.Println("Hello, world!") +     7: } +(dlv) next +Hello, world! +> main.main() ./hello.go:7 (PC: 0x4a22ff) +     2: +     3: import "fmt" +     4: +     5: func main() { +     6:         fmt.Println("Hello, world!") +=>   7:      } +(dlv) +``` + +#### 退出 Delve + +你随时可以运行 `quit` 命令来退出调试器,退出之后你会回到 shell 提示符。相当简单,对吗? + +``` +(dlv) quit +$ +``` + +### Delve 的其他功能 + +我们用其他的 Go 程序来探索下 Delve 的其他功能。这次,我们从 [golang 教程][5] 中找了一个程序。如果你要学习 Go 语言,那么 Golang 教程应该是你的第一站。 + +下面的程序,`functions.go` 中简单展示了 Go 程序中是怎样定义和调用函数的。这里,我们有一个简单的把两数相加并返回和值的 `add()` 函数。你可以像下面那样构建程序并运行它。 + +``` +$ cat functions.go +package main + +import "fmt" + +func add(x int, y int) int { +        return x + y +} + +func main() { +        fmt.Println(add(42, 13)) +} +$ +``` + +你可以像下面那样构建和运行程序。 + +``` +$ go build functions.go  && ./functions +55 +$ +``` + +#### 进入函数 + +跟前面展示的一样,我们用前面提到的一个选项来把二进制文件加载进 Delve 调试器,再一次在 `main.main` 处设置断点,继续运行程序直到断点处。然后执行 `next` 直到 `fmt.Println(add(42, 13))` 处;这里我们调用了 `add()` 函数。我们可以像下面展示的那样,用 Delve 的 `step` 命令从 `main` 函数进入 `add()` 函数。 + +``` +$ dlv debug +Type 'help' for list of commands. +(dlv) break main.main +Breakpoint 1 set at 0x4a22b3 for main.main() ./functions.go:9 +(dlv) c +> main.main() ./functions.go:9 (hits goroutine(1):1 total:1) (PC: 0x4a22b3) +     4: +     5: func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +=>   9:      func main() { +    10:         fmt.Println(add(42, 13)) +    11: } +(dlv) next +> main.main() ./functions.go:10 (PC: 0x4a22c1) +     5: func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +     9: func main() { +=>  10:              fmt.Println(add(42, 13)) +    11: } +(dlv) step +> main.add() ./functions.go:5 (PC: 0x4a2280) +     1: package main +     2: +     3: import "fmt" +     4: +=>   5:      func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +     9: func main() { +    10:         fmt.Println(add(42, 13)) +(dlv) +``` + +#### 使用`文件名:行号`来设置断点 + +上面的例子中,我们经过 `main` 函数进入了 `add()` 函数,但是你也可以在你想加断点的地方直接使用“文件名:行号”的组合。下面是在 `add()` 函数开始处加断点的另一种方式。 + +``` +(dlv) break functions.go:5 +Breakpoint 1 set at 0x4a2280 for main.add() ./functions.go:5 +(dlv) continue +> main.add() ./functions.go:5 (hits goroutine(1):1 total:1) (PC: 0x4a2280) +     1: package main +     2: +     3: import "fmt" +     4: +=>   5:      func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +     9: func main() { +    10:         fmt.Println(add(42, 13)) +(dlv) +``` + +#### 查看当前的栈信息 + +现在我们运行到了 `add()` 函数,我们可以在 Delve 中用 `stack` 命令查看当前栈的内容。这里在 `0` 位置展示了栈顶的函数 `add()` ,紧接着在 `1` 位置展示了调用 `add()` 函数的 `main.main`。在 `main.main` 下面的函数属于 Go 运行时,是用来处理加载和执行该程序的。 + +``` +(dlv) stack +0  0x00000000004a2280 in main.add +   at ./functions.go:5 +1  0x00000000004a22d7 in main.main +   at ./functions.go:10 +2  0x000000000042dd1f in runtime.main +   at /usr/lib/golang/src/runtime/proc.go:200 +3  0x0000000000458171 in runtime.goexit +   at /usr/lib/golang/src/runtime/asm_amd64.s:1337 +(dlv) +``` + +#### 在帧之间跳转 + +在 Delve 中我们可以用 `frame` 命令实现帧之间的跳转。在下面的例子中,我们用 `frame` 实现了从 `add()` 帧跳到 `main.main` 帧,以此类推。 + +``` +(dlv) frame 0 +> main.add() ./functions.go:5 (hits goroutine(1):1 total:1) (PC: 0x4a2280) +Frame 0: ./functions.go:5 (PC: 4a2280) +     1: package main +     2: +     3: import "fmt" +     4: +=>   5:      func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +     9: func main() { +    10:         fmt.Println(add(42, 13)) +(dlv) frame 1 +> main.add() ./functions.go:5 (hits goroutine(1):1 total:1) (PC: 0x4a2280) +Frame 1: ./functions.go:10 (PC: 4a22d7) +     5: func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +     9: func main() { +=>  10:              fmt.Println(add(42, 13)) +    11: } +(dlv) +``` + +#### 打印函数参数 + +一个函数通常会接收多个参数。在 `add()` 函数中,它的入参是两个整型。Delve 有个便捷的 `args` 命令,它能打印出命令行传给函数的参数。 + +``` +(dlv) args +x = 42 +y = 13 +~r2 = 824633786832 +(dlv) +``` + +#### 查看反汇编码 + +由于我们是调试编译出的二进制文件,因此如果我们能查看编译器生成的汇编语言指令将会非常有用。Delve 提供了一个 `disassemble` 命令来查看这些指令。在下面的例子中,我们用它来查看 `add()` 函数的汇编指令。 + +``` +(dlv) step +> main.add() ./functions.go:5 (PC: 0x4a2280) +     1: package main +     2: +     3: import "fmt" +     4: +=>   5:      func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +     9: func main() { +    10:         fmt.Println(add(42, 13)) +(dlv) disassemble +TEXT main.add(SB) /home/user/go/gobin/functions.go +=>   functions.go:5  0x4a2280   48c744241800000000   mov qword ptr [rsp+0x18], 0x0 +        functions.go:6  0x4a2289   488b442408           mov rax, qword ptr [rsp+0x8] +        functions.go:6  0x4a228e   4803442410           add rax, qword ptr [rsp+0x10] +        functions.go:6  0x4a2293   4889442418           mov qword ptr [rsp+0x18], rax +        functions.go:6  0x4a2298   c3                   ret +(dlv) +``` + +#### 单步退出函数 + +另一个功能是 `stepout`,这个功能可以让我们跳回到函数被调用的地方。在我们的例子中,如果我们想回到 `main.main` 函数,我们只需要简单地运行 `stepout` 命令,它就会把我们带回去。在我们调试大型代码库时,这个功能会是一个非常便捷的工具。 + +``` +(dlv) stepout +> main.main() ./functions.go:10 (PC: 0x4a22d7) +Values returned: +        ~r2: 55 + +     5: func add(x int, y int) int { +     6:         return x + y +     7: } +     8: +     9: func main() { +=>  10:              fmt.Println(add(42, 13)) +    11: } +(dlv) +``` + +#### 打印变量信息 + +我们一起通过 [Go 教程][6] 的另一个示例程序来看下 Delve 是怎么处理 Go 中的变量的。下面的示例程序定义和初始化了一些不同类型的变量。你可以构建和运行程序。 + +``` +$ cat variables.go +package main + +import "fmt" + +var i, j int = 1, 2 + +func main() { +        var c, python, java = true, false, "no!" +        fmt.Println(i, j, c, python, java) +} +$ + +$ go build variables.go &&; ./variables +1 2 true false no! +$ +``` + +像前面说过的那样,用 `delve debug` 在调试器中加载程序。你可以在 Delve 中用 `print` 命令通过变量名来展示他们当前的值。 + +``` +(dlv) print c +true +(dlv) print java +"no!" +(dlv) +``` + +或者,你还可以用 `locals` 命令来打印函数内所有的局部变量。 + +``` +(dlv) locals +python = false +c = true +java = "no!" +(dlv) +``` + +如果你不知道变量的类型,你可以用 `whatis` 命令来通过变量名来打印它的类型。 + +``` +(dlv) whatis python +bool +(dlv) whatis c +bool +(dlv) whatis java +string +(dlv) +``` + +### 总结 + +现在我们只是了解了 Delve 所有功能的皮毛。你可以自己去查看帮助内容,尝试下其它的命令。你还可以把 Delve 绑定到运行中的 Go 程序上(守护进程!),如果你安装了 Go 源码库,你甚至可以用 Delve 导出 Golang 库内部的信息。勇敢去探索吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/debug-go-delve + +作者:[Gaurav Kamathe][a] +选题:[lujun9972][b] +译者:[lxbwolf](https://github.com/lxbwolf) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gkamathe +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug_software_issue_tracking_computer_screen.jpg?itok=6qfIHR5y (Bug tracking magnifying glass on computer screen) +[2]: https://github.com/go-delve/delve +[3]: https://golang.org/doc/install +[4]: https://github.com/go-delve/delve/blob/master/Documentation/installation/linux/install.md +[5]: https://tour.golang.org/basics/4 +[6]: https://tour.golang.org/basics/9 diff --git a/published/202007/20200616 How to know if you-re ready to switch from Mac to Linux.md b/published/202007/20200616 How to know if you-re ready to switch from Mac to Linux.md new file mode 100644 index 0000000000..271caf1707 --- /dev/null +++ b/published/202007/20200616 How to know if you-re ready to switch from Mac to Linux.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (nophDog) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12375-1.html) +[#]: subject: (How to know if you're ready to switch from Mac to Linux) +[#]: via: (https://opensource.com/article/20/6/mac-to-linux) +[#]: author: (Marko Saric https://opensource.com/users/markosaric) + +你是否已经准备好从 Mac 切换到 Linux 了? +====== + +> 你几乎可以在 Linux 上做任何你在 Mac 上可以做的事情 —— 这是你拥有一个开源操作系统的自由。 + +![](https://img.linux.net.cn/data/attachment/album/202007/02/222534g8bdabsllplnzl6c.jpg) + +我[从 Mac 转到 Linux][2] 已经两年了。在使用 Linux 之前,我用的 Apple 的系统用了 15 年,而当我在 2018 年安装第一个 Linux 发行版时,还只是一个纯粹的新手。 + +这些日子以来,我只用 Linux,我可以用它完成任何任务。浏览网页、观看 Netflix 影片、写作以及编辑我的 Wordpress [博客][3],甚至还在上面跑我的[开源网页分析项目][4]。 + +我甚至还不是一个开发者!Linux 被认为不适合日常使用,对非技术人员也不够友好的日子已经一去不返了。 + +最近有很多关于 Mac 的讨论,越来越多的人已经在考虑转到 Linux。我打算分享我的切换过程中的一些经验,帮助其它新手也能从容转移。 + +### 你该不该换? + +在换系统之前,最好想清楚,因为有时候 Linux 可能跟你预期不一样。如果你仍希望跟 Apple Watch 无缝配对、可以用 FaceTime 给朋友打电话、或者你想打开 iMovie 看视频,那最好还是不要换了。这些都是 Apple 的专有产品,你只能在 Apple 的“围墙花园”里面使用。如果离不开 Apple 的生态系统,那么 Linux 可能不太适合你。 + +我对 Apple 生态没有太多挂念,我不用 iPhone,所以跟手机的协作没那么必要。我也不用 iCloud、FaceTime,当然也包括 Siri。我早就对开源充满兴趣,只是一直没有行动。 + +### 检查你的必备软件清单 + +我还在使用 Mac 的时候,就已经开始探索开源软件,我发现大部分在 Mac 上使用的软件,在 Linux 也可以运行。 + +很熟悉用火狐浏览网页吗?在 Linux 上它也可以运行。想用 VLC 看视频?它也有 Linux 版本。喜欢用 Audacity 录制、编辑音频?它正在 Linux 上等着你呢。你用 OBS Studio 直播?在 Linux 直接下载安装吧。一直用 Telegram 跟朋友和家人保持联系吗?Linux 上当然少不了它。 + +此外,Linux 不仅仅意味着开源软件。你最喜欢的大部分(也可能是所有)非 Apple 专有软件,都能在 Linux 见到它们的身影。Spotify、Slack、Zoom、Stream、Discord、Skype、Chrome 以及很多闭源软件,都可以使用。而且,在你 Mac 浏览器里面运行的任何东西,同样能够运行在 Linux 浏览器。 + +你能在 Linux 找到你的必备软件,或者更好的替代品吗?请再三确认,做到有备无患。用你最常用的搜索引擎,在网上检索一下。搜索“软件名 + Linux” 或者“软件名 + Linux 替代品”,然后再去 [Flathub][5] 网站查看你能在 Linux 用 Flatpak 安装的专有软件有哪些。 + +### 请牢记:Linux 不等于 Mac + +如果你希望能够从 Mac 轻松转移到 Linux,我相信有一点很重要,你需要保持包容的思想以及愿意学习新操作系统的心态。Linux 并不等于 Mac,所以你需要给自己一些时间去接触并了解它。 + +如果你想让 Linux 用起来、看起来跟你习惯的 macOS 一模一样,那么 Linux 可能也不适合你。尽管你可以通过各种方法[把 Linux 桌面环境打造得跟 macOS 相似][14],但我觉得要想成功转移到 Linux,最好的办法是从拥抱 Linux 开始。 + +试试新的工作流,该怎么用就怎么用。不要总想着把 Linux 变成其它东西。你会跟我一样,像享受 Mac 一样享受 Linux,甚至能有更好的体验感。 + +还记得你第一次使用 Mac 吧:你肯定花了不少时间去习惯它的用法。那么请给 Linux 同样多的时间和关怀。 + +### 选择一个 Linux 发行版 + +有别于 Windows 和 macOS,Linux 不止一个单一的操作系统。不同的 Linux 操作系统被称作发行版,开始使用 Linux 之后,我尝试过好几个不同的发行版。我也用过不同的桌面环境,或者图形界面。在美观度、易用性、工作流以及集成软件上,它们有很大差异。 + +尽管作为 Mac 的替代品,被提及最多的是 [ElementaryOS][6] 和 [Pop!_OS][7],但我仍建议从 [Fedora 工作站][8] 开始,理由如下: + +- 使用 [Fedora 介质写入器][9],容易安装 +- 几乎可以支持你所有的硬件,开箱即用 +- 支持最新的 Linux 软件 +- 运行原生无改动的 GNOME 桌面环境 +- 有一个大型开发团队以及一个庞大的社区在背后支持 + +在我看来,对从 macOS 过来的新手来说,[GNOME][10] 是易用性、一致性、流畅性和用户体验最好的桌面环境。它拥有 Linux 世界中最多的开发资源和用户基数,所以你的使用体验会很好。 + +Fedora 可以为你打开一扇 Linux 的大门,当你适应之后,就可以开始进一步探索各个发行版、桌面环境,甚至窗口管理器之类的玩意了。 + +### 熟悉 GNOME + +GNOME 是 Fedora 和许多其它 Linux 发行版的默认窗口管理器。它最近 [升级到 GNOME 3.36][11],带来了 Mac 用户会喜欢的现代设计。 + +一定要做好心理准备,Linux、Fedora 工作站和 GNOME 并不是 Apple 和 macOS。GNOME 非常干净、简约、现代、独创。它不会分散你的注意力,没有桌面图标,没有可见的坞站,窗口上甚至没有最小化和最大化按钮。但是不要慌张,如果你去尝试,它会证明这是你用过最好、最有生产力的操作系统。 + +GNOME 不会给你带来困扰。启动之后,你唯一能看到的东西只有顶栏和背景图片。顶栏由这几样东西组成,“活动”在左边,时间和日期在中间(这也是你的通知中心),右边是网络、蓝牙、VPN、声音、亮度、电池等托盘图标之类的东西。 + +#### 为什么 GNOME 像 Mac + +你会注意到一些跟 macOS 的相似之处,例如窗口吸附、空格预览(用起来跟 “Quick Look” 一模一样)。 + +如果你把鼠标光标移动到左上角,点击顶栏的“活动”,或者按下键盘上超级键(`Super` 键,也就是 Mac 上的 `ஐ` 键),你会看到“活动概览”。它有点像 macOS 系统上“调度中心”和“聚焦搜索”的结合体。它会在屏幕中间展示已打开软件和窗口的概览。在左手边,你可以看到坞站,上面有你打开的软件和常用软件。所有打开的软件下面会有一个指示标志,在右手边,你可以看到不同的工作区。 + +在顶栏中间,有一个搜索框。只要你开始输入,焦点就会转移到搜索框。它能搜索你已经安装的软件和文件内容,可以在软件中心搜索指定的软件、进行计算、向你展示时间或者天气,当然它能做的还有很多。它就像“聚焦”一样。只需开始输入你要搜索的内容,按下回车就可以打开软件或者文件。 + +你也能看到一列安装好的软件(更像 Mac 上的“启动台”),点击坞站中的“显示应用”图标,或者按 `Super + A` 就行。 + +总体来说,Linux 是一个轻量级的系统,即使在很老的硬件上也能跑得很顺畅,跟 macOS 比起来仅仅占用很少的磁盘空间。并且不像 macOS,你可以删除任何你不想要或不需要的预装软件。 + +#### 自定义你的 GNOME 设置 + +浏览一下 GNOME 设置,熟悉它的选项,做一些更改,让它用起来更舒服。下面是一些我装好 GNOME 必做的事情。 + +- 在“鼠标和触摸板”中,我禁用“自然滚动”、启用“轻触点击”。 +- 在“显示”中,我打开“夜光”功能,在晚上,屏幕会让颜色变暖,减少眼睛疲劳。 +- 我也安装了 [GNOME 优化][12],因为它可以更改额外的设置选项。 +- 在“GNOME 优化”中,我启用了 “Over-Amplification” 设置,这样就能获得更高的音量。 +- 在“GNOME 优化”中,相比默认的亮色主题,我更喜欢 “Adwaita Dark” 主题。 + +#### 习惯使用键盘操作 + +GNOME 是以一个极度以键盘为中心的操作系统,所以尽量多使用键盘。在 GNOME 设置中的“键盘快捷键”部分,你可以找到各个快捷键。 + +你也可以根据自己的理想工作流程来设置键盘快捷键。我将我最常用的应用程序设置为使用超级键打开。比如说,`Super + B` 打开我的浏览器,`Super + F` 打开“文件”,`Super + T` 打开终端。我还把 `Ctrl + Q` 设置成关闭窗口。 + +我使用 `Super + Tab` 在打开的应用程序之间切换,`Super + H` 隐藏一个窗口,`F11` 全屏打开软件,`Super + Left` 把窗口吸附到屏幕左边,`Super + Right` 把窗口吸附到屏幕左边,等等。 + +### 在 Mac 上尝试 Linux 之后再做决定 + +在完全安装 Linux 之前,在你的 Mac 上先尝试 Fedora。从 [Fefora 官网][9]下载 ISO 镜像。使用 [Etcher][13] 将 ISO 镜像写入 USB 驱动器,然后在启动时点击 `Option` 键,这样你就可以在即用模式下尝试了。 + +现在您无需在 Mac 上安装任何东西就可以探索 Fedora 工作站了。试试各种东西,能否正常工作:能不能连接 WiFi?触控板是否正常?有没有声音?等等。 + +也记得花时间来尝试 GNOME。测试我上面提到的不同功能。打开一些安装好的软件。如果一切看起来都还不错,如果你喜欢这样的 Fedora 工作站和 GNOME,并且很肯定这就是你想要的,那么把它安装到你的 Mac 吧。 + +尽情探索 Linux 世界吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/mac-to-linux + +作者:[Marko Saric][a] +选题:[lujun9972][b] +译者:[nophDog](https://github.com/nophDog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/markosaric +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_browser_web_desktop.png?itok=Bw8ykZMA (Digital images of a computer desktop) +[2]: https://markosaric.com/linux/ +[3]: https://markosaric.com/how-start-blog/ +[4]: https://plausible.io/open-source-website-analytics +[5]: https://flathub.org/apps +[6]: https://opensource.com/article/20/2/macbook-linux-elementary +[7]: https://support.system76.com/articles/pop-basics/ +[8]: https://getfedora.org/ +[9]: https://getfedora.org/en/workstation/download/ +[10]: https://www.gnome.org/ +[11]: https://www.gnome.org/news/2020/03/gnome-3-36-released/ +[12]: https://wiki.gnome.org/Apps/Tweaks +[13]: https://www.balena.io/etcher/ +[14]: https://linux.cn/article-12361-1.html \ No newline at end of file diff --git a/published/202007/20200616 How to loop forever in bash on Linux.md b/published/202007/20200616 How to loop forever in bash on Linux.md new file mode 100644 index 0000000000..756836f72f --- /dev/null +++ b/published/202007/20200616 How to loop forever in bash on Linux.md @@ -0,0 +1,143 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12368-1.html) +[#]: subject: (How to loop forever in bash on Linux) +[#]: via: (https://www.networkworld.com/article/3562576/how-to-loop-forever-in-bash-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何在 Linux 的 bash 中永远循环 +====== + +![tine ivanic][1] + +在 Linux 中有很多永远循环(或直到你决定停止)的方法,你可以在命令行或脚本中执行此操作。 + +`for` 和 `while` 命令使这件事非常容易。关于相应的语法和策略,只有几件事要牢记。 + +### 使用 while + +最简单的永远循环之一是使用 `while` 命令,后面跟上条件 `true`。 你不必使用诸如 `while [ 1 -eq 1 ]` 之类的逻辑或类似的测试。 `while true` 测试表示循环将一直运行,直到你使用 `CTRL-C` 停止循环、关闭终端窗口或注销为止。这是一个例子: + +``` +$ while true +> do +> echo Keep running +> sleep 3 +> done +Keep running +Keep running +Keep running +^C +``` + +你也可以使用 `while :` 做同样的事情。这里的关键是 `:` 总是返回成功,因此就像 `while true` 一样,此测试永远不会失败,并且循环会继续运行: + +``` +$ while : +> do +> echo Keep running +> sleep 3 +> done +Keep running +Keep running +^C +``` + +如果你在脚本中插入了无限循环,并想提醒使用它的人如何退出脚本,那么可以使用 `echo` 命令添加提示: + +``` +while : +do + echo Keep running + echo "Press CTRL+C to exit" + sleep 1 +done +``` + +### 使用 for + +`for` 命令还提供了一种永远循环的简便方法。虽然不如 `while true` 明显,但语法相当简单。你只需要在有界循环中替换参数即可,它通常类似于 “c 从等于 1 开始递增,直到 5”: + +``` +$ for (( c=1; c<=5; c++ )) +``` + +不指定任何参数的情况下: + +``` +$ for (( ; ; )) +``` + +没有起始值、增量或退出测试,此循环将永远运行或被强制停止: + +``` +$ for (( ; ; )) +> do +> echo Keep running +> echo “Press CTRL+C to exit” +> sleep 2 +> done +Keep your spirits up +Keep your spirits up +Keep your spirits up +``` + +### 为什么要永远循环? + +在现实中,你不会想永远循环下去,但一直运行直到想要回家、工作完成或者遇到问题才退出并不罕见。任何构造为无限循环的循环都可以设置为根据各种情况退出。 + +该脚本将一直处理数据直到下午 5 点,或者说检查发现第一次超过 5 点的时间: + +``` +#!/bin/bash + +while true +do + if [ `date +%H` -ge 17 ]; then + exit # exit script + fi + echo keep running + ~/bin/process_data # do some work +done +``` + +如果要退出循环而不是退出脚本,请使用 `break` 命令而不是 `exit`。 + +``` +#!/bin/bash + +while true +do + if [ `date +%H` -ge 17 ]; then + break # exit loop + fi + echo keep running + ~/bin/process_data +done +… run other commands here … +``` + +### 总结 + +永远循环很容易。指定要停止循环的条件却需要花费一些额外的精力。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3562576/how-to-loop-forever-in-bash-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2020/06/nw_circular-staircase_loop_infinity_nautilus_by-tine-ivanic-via-unsplash-100848725-large.jpg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/202007/20200617 4 essential tools to set up your Python environment for success.md b/published/202007/20200617 4 essential tools to set up your Python environment for success.md new file mode 100644 index 0000000000..26309e20ba --- /dev/null +++ b/published/202007/20200617 4 essential tools to set up your Python environment for success.md @@ -0,0 +1,104 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12369-1.html) +[#]: subject: (4 essential tools to set up your Python environment for success) +[#]: via: (https://opensource.com/article/20/6/python-tools) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +建立成功的 Python 环境的 4 个基本工具 +====== + +> 选择的这些工具将简化你的 Python 环境,以实现顺畅和一致的开发实践。 + +![](https://img.linux.net.cn/data/attachment/album/202007/01/123009yolmlzp1yu1y88ew.jpg) + +Python 是一门出色的通用编程语言,经常作为第一门编程语言来教授。二十年来,我为它撰写了很多本书,而它仍然是[我的首选语言][2]。虽然通常来说这门语言是简洁明了的,但是(正如 [xkcd][3] 讽刺的),从来没有人说过配置 Python 环境也是一样的简单。 + +![xkcd python illustration][4] + +*一个复杂的Python环境。 [xkcd][3]* + +在日常生活中有很多使用 Python 的方法。我将解释我是如何使用这些 Python 生态系统工具的。但坦诚的说,我仍在寻找更好的替代品。 + +### 使用 pyenv 来管理 Python 版本 + +我发现在机器上运行一个特定版本的 Python 的最好方法是使用 `pyenv`。这个软件可以在 Linux、Mac OS X 和 WSL2 上工作:这是我通常关心的三个 “类 UNIX” 环境。 + +安装 `pyenv` 本身有时会有点棘手。一种方法是使用专用的 [pyenv 安装程序][5],它使用 `curl | bash` 方法来进行(详见其说明)。 + +如果你是在 Mac 上(或者你运行 Homebrew 的其他系统),你可以按照[这里][6]的说明来安装和使用 `pyenv`。 + +按照说明安装和设置了 `pyenv` 之后,你可以使用 `pyenv global` 来设置一个 “默认的” Python 版本。一般来说,你会选择你的 “首选” 版本。这通常是最新的稳定版本,但如果有其他考虑因素也可能做出不同的选择。 + +### 使用 virtualenvwrapper 让虚拟环境更简单 + +使用 `pyenv` 安装 Python 的一个好处是,你所有后继安装的 Python 解释器环境都是你自己的,而不是操作系统层面的。 + +虽然在 Python 本身内部安装东西通常不是最好的选择,但有一个例外:在上面选择的 “首选” Python 中,安装并配置 `virtualenvwrapper`。这样你就可以瞬间创建和切换到虚拟环境。 + +我在[这篇文章中][7]具体介绍了如何安装和使用 `virtualenvwrapper`。 + +这里我推荐一个独特的工作流程:你可以制作一个可以大量重复运行的虚拟环境,用来做运行器runner。在这个环境中,可以安装你最喜欢的运行器 —— 也就是你会经常用来运行其他软件的软件。就目前而言,我的首选是 `tox`。 + +### 使用 tox 作为 Python 运行器 + +[tox][8] 是一个很好的工具,可以让你的 Python 测试自动化。在每个 Python 环境中,我都会创建一个 `tox.ini` 文件。无论我使用什么系统做持续集成,都可以运行它,我可以用上面文章中描述的 `virtualenvwrapper` 的 `workon` 语法在本地运行同样的东西: + +``` +$ workon runner +$ tox +``` + +这个工作流程之所以重要,是因为我要在多个版本的 Python 和多个版本的依赖库中测试我的代码。这意味着在 `tox` 运行器中会有多个环境。一些会尝试在最新的依赖关系中运行,一些会尝试在冻结的依赖关系中运行(接下来会有更多的介绍),我也可能会用 `pip-compile` 在本地生成这些环境。 + +附注:我目前正在[研究使用 nox][9] 作为 `tox` 的替代品。原因超出了本文的范畴,但值得一试。 + +### 使用 pip-compile 进行 Python 依赖性管理 + +Python 是一种动态编程语言,这意味着它在每次执行代码时都会加载其依赖关系。能否确切了解每个依赖项的具体运行版本可能意味着是平稳运行代码还是意外崩溃。这意味着我们必须考虑依赖管理工具。 + +对于每个新项目,我都会包含一个 `requirements.in` 文件,(通常)只有以下内容: + +``` +. +``` + +是的,没错。只有一个点的单行。我在 `setup.py` 文件中记录了 “宽松” 的依赖关系,比如 `Twisted>=17.5`。这与 `Twisted==18.1` 这样的确切依赖关系形成了鲜明对比,后者在需要一个特性或错误修复时,难以升级到新版本的库。 + +`.` 的意思是 “当前目录”,它使用当前目录下的 `setup.py` 作为依赖关系的来源。 + +这意味着使用 `pip-compile requirements.in > requirements.txt` 会创建一个冻结的依赖文件。你可以在 `virtualenvwrapper` 创建的虚拟环境中或者 `tox.ini` 中使用这个依赖文件。 + +有时,也可以从 `requirements-dev.in`(内容:`.[dev]`)生成 `requirements-dev.txt`,或从 `requirements-test.in`(内容:`.[test]`)生成 `requirements-test.txt`。 + +我正在研究在这个流程中是否应该用 [dephell][10] 代替 `pip-compile`。`dephell` 工具有许多有趣的功能,比如使用异步 HTTP 请求来下载依赖项。 + +### 结论 + +Python 的功能既强大又赏心悦目。为了编写这些代码,我依靠了一个对我来说很有效的特定工具链。工具 `pyenv`、`virtualenvwrapper`、`tox` 和 `pip-compile` 都是独立的。但是,它们各有各的作用,没有重叠,它们一起打造了一个强大的 Python 工作流。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/python-tools + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python_programming_question.png?itok=cOeJW-8r (Python programming language logo with question marks) +[2]: https://opensource.com/article/19/10/why-love-python +[3]: https://xkcd.com/1987/ +[4]: https://opensource.com/sites/default/files/uploads/python_environment_xkcd_1.png (xkcd python illustration) +[5]: https://github.com/pyenv/pyenv-installer +[6]: https://linux.cn/article-12241-1.html +[7]: https://linux.cn/article-11086-1.html +[8]: https://opensource.com/article/19/5/python-tox +[9]: https://nox.thea.codes/en/stable/ +[10]: https://github.com/dephell/dephell diff --git a/published/202007/20200622 7 open source alternatives to VS Code.md b/published/202007/20200622 7 open source alternatives to VS Code.md new file mode 100644 index 0000000000..6526252de9 --- /dev/null +++ b/published/202007/20200622 7 open source alternatives to VS Code.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (nophDog) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12382-1.html) +[#]: subject: (7 open source alternatives to VS Code) +[#]: via: (https://opensource.com/article/20/6/open-source-alternatives-vs-code) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +VS Code 的 7 个开源替代品 +====== + +> 为了避免使用微软版本的 VS Code,我们需要另行选择一个开源的代码编辑器。 + +![](https://img.linux.net.cn/data/attachment/album/202007/05/112348n834svpa48v08vsa.png) + +Visual Studio Code,也叫 VS Code,是一个跨平台代码编辑器,通用于 Linux、Windows 以及 macOS。它既能编辑简单文本,也能像集成开发环境(IDE)一样管理整个代码库。它可以通过插件进行扩展,并且已经被证明是一个可靠的文本编辑器,很轻松地就击败了非开源的强大竞品编辑器。 + +微软以开源的方式发布了 VS Code,但是你从微软下载的版本其实并不是开源的。然而,你仍有办法以开源的方式使用 VS Code,或者直接选择其它的开源替代品。 + +### 以开源的方式构建 VS Code + +你可以在 [GitHub][2] 获得 VS Code 的源代码。然而当你 [从微软][3] 下载 VS Code 时,你会发现它是基于 [微软软件许可证][4] 授权的。这并不是一个开源许可证。其区别在于构建过程。 + +Chris Dias 是微软 VS Code 项目开发者之一,他对 VS Code [作了一个对比][5],就像 Chrome 浏览器和其开源的“上游”项目 [Chromium][6] 一样。VS Code 确实是基于开源代码库构建的。微软官方发布的版本带有一些与微软相关的功能,包括一项商标、一个插件库、一个 C# 调试器以及遥测。但如果你克隆仓库然后自行编译,这些东西都不会被加入,所以你会得到一个名为 Code - OSS 的“干净”版本(OSS 代表开源软件)。 + +实际上,VS Code 与 Code - OSS 之间的差异很小。最值得注意的是,VS Code 包含遥测功能,它会记录使用数据。微软不可能监控你的一举一动,而且目前越来越多软件都在收集使用数据。是否在乎 VS Code 的遥测功能,完全取决于你自己。如果你不希望它追踪你的使用情况,这里有一些很棒的 VS Code(开源)替代品。 + +### VSCodium + +![Code OSS screenshot][7] + +最简单的替代方案就是构建不带微软附属功能的 VS Code 版本。[VSCodium][9] 项目提供了可下载的 Code-OSS 可执行文件,它基于 VS Code 代码库编译,没有配置微软的 `product.json` 中的改变。VSCodium 的开发者还竭尽全力禁用了所有难以寻找的遥测选项,除非你自行编译,否则这已经是你能找到的最干净的 VS Code 版本了。 + +VSCodium 提醒说,VS Code 悄悄地包含了一些专有工具,这些工具无法与开源版本一起提供。这包括一个 C# 调试器和部分插件。如果你需要它们,可以在 [文档中] 找到解决办法。假如你依赖 VS Code 中某些特定的功能,你应该验证它在 VSCodium 中是否可以发挥功用。 + +此外,你还应该验证是否已禁用所有的遥测功能。 + +### Code - OSS + +如果不想用 VSCodium 的版本,你可以自己 [从头编译 VS Code][12],得到一样的版本。可执行文件叫做 `Code - OSS`,而不是 `VSCode`,适用于 VSCodium 的许可证限制也适用于你的构建,而工作方式也是一样。 + +如果通过编译源码构建应用,首次启动时你要确保 [所有遥测都已经被禁用]。 + +### Atom + +![Atom screenshot][13] + +[Atom][14] 是一个类似于 IDE 的文本编辑器,当微软收购 Github 的同时也收购了它。和 VS Code 一样,你可以使用插件,扩展 Atom 编辑器,此外,你还能通过自己的工具和主题实现定制。它开源且与 Github 集成。简而言之,只要你能找到你想用的插件,或者你愿意自己动手写,那么 Atom 几乎可以满足你的一切需求。 + +跟 VS Code 一样,Atom 也 [默认包含遥测][15]。你可以禁用这个功能,而且跟 VS Code 不同的是,使用插件不受任何限制,所以不必再因为隐私改变你的工作流。对写代码的人来说,毫无疑问 Atom 是很有用的工具,而对于 [使用电脑的任何人][16],它同样会是一个很赞的编辑器。如果你需要一个顺手的通用文本编辑器,请试试 Atom。 + +### GNOME Builder + +![GNOME Builder screenshot][17] + +为 GNOME 桌面而开发的 IDE,[GNOME Builder][18] 是一个 Linux 平台的代码编辑器,专门用于构建 GNOME 应用。如果你为 Linux 构建应用程序,希望轻松解决兼容性问题,那么 Builder 就是最简单的选择。从 [Flathub.org][19] 安装 Builder;当你开启一个新项目,如果没有安装 GNOME SDK,它会提醒你。这意味着当维护你的应用时,你不必刻意关注 GNOME 的状态,因为 Builder 在替你做这件事。 + +然而,Builder 不仅能构建 GNOME 程序。它还支持各种各样的编程语言,包括 Python、Rust、C/C++、Java、Go、JavaScript、TypeScript、VB.NET、Markdown 和几种标记语言等等。它对部分语言有全面的支持,包括自动补全以及弹出式函数定义,但是其它语言仅仅含有一些比较方便的功能,例如语法高亮跟自动匹配括号。不管你是不是一个专门的程序员,或者你只想要一个给力的 HTML 和 CSS 编辑器,这个 IDE 都能让你舒心使用。 + +### Geany + +![Geany screenshot][20] + +[Geany][21] 是一个强大、稳定而轻量级的编辑器,它有很多有用的特性,能帮你写 Bash、Python、Lua、XML、HTML、LaTex,当然远不止这些。对 50 种各种编程及脚本语言、标记语言和各种文件类型(比如 .diff 和 .po),Geany 都有很好的支持。退一万步讲,Geany 还有括号匹配和语法高亮 —— 通常来说,它包含更多功能。 + +Geany 是一个小型编辑器,但是通过插件,你可以为它添加特性,例如项目视图面板、文件系统树、调试、终端等,直到它看起来像一个 IDE。当然,萝卜白菜各有所爱,你也可以尽量使它保持简洁易用。如果因为电脑 CPU 或者内存的限制而无法使用 VS Code,那么很明显 Geany 可以作为你的选择。它只占用少量内存,而且启动迅速。即便跟运行在终端里的 Vim 相比,Geany 稍显笨重,但就算在树莓派,它也能做到快速、灵活。 + +### Brackets + +![Brackets screenshot][22] + +[Brackets][23] 是一款面向网页开发者的文本编辑器和 IDE。对于 HTML、CSS、JavaScript、PHP 甚至 Python,它都有很强大的支持。而且跟 VS Code 一样,它也有一个很丰富的插件生态,所以你可以最大限度地扩展它,以适应你所有编程语言的工作。 + +有的插件用于辅助解析语言、运行脚本,甚至编译执行代码。Brackets 有一个传统的界面,不管你是否熟悉 IDE 或者像记事本一样简单的文本编辑器,都能驾轻就熟。如果稍微花点时间,添加几个相关插件,然后熟悉它们,你会发现 Brackets 真的是一个很精妙、很有用的编辑器,不管你输入什么,它都能通过自动补全、提示帮你避免低级错误。假如你是程序员,它能帮你加快测验和调试周期。 + +### Che + +![Che screenshot][24] + +如果你喜欢新技术,那你应当尝试 [Che][25] 编辑器。这是一个基于云的 IDE,所以它默认以软件即服务(SaaS)的形式运行,但它是完全开源的,如果你有 Kubernetes 实例,那就可以运行为*你自己的* SaaS。 + +Che 不仅是一个在线 IDE,而且是一个为云开发而构建的 IDE。在 Che 的概念里,用户无需查看本地文件系统。由于它在云端工作,所以你也可以这么做。事实上,如果你有一台 Git 服务器,那就可以直接把它当作你的文件系统,在它的仓库中完成你的项目。当然,你也可以下载所有文件做本地备份。 + +但 Che 的主要特点,也是云开发者最为兴奋的一点,它是一个功能全面、带有 Kubernetes 感知功能的开源 IDE。如果你正在为云构建应用、网站或容器(或三者的组合),那么 Che 是一个你需要尝试的编辑器。 + +### 那么你的选择是? + +你有没有在使用这些 VS Code 替代品中的某一个呢?想不想挑一个试试呢?欢迎在评论中分享你的见解。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/open-source-alternatives-vs-code + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[nophDog](https://github.com/nophDog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/laptop_screen_desk_work_chat_text.png?itok=UXqIDRDD (Person using a laptop) +[2]: https://github.com/microsoft/vscode +[3]: https://code.visualstudio.com/ +[4]: https://code.visualstudio.com/license +[5]: https://github.com/Microsoft/vscode/issues/60#issuecomment-161792005 +[6]: https://www.chromium.org/ +[7]: https://opensource.com/sites/default/files/uploads/code-oss.png (Code OSS screenshot) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: https://vscodium.com/ +[10]: https://github.com/VSCodium/vscodium/blob/master/DOCS.md +[11]: https://code.visualstudio.com/docs/supporting/faq#_how-to-disable-telemetry-reporting +[12]: https://github.com/Microsoft/vscode/wiki/How-to-Contribute#build-and-run +[13]: https://opensource.com/sites/default/files/uploads/atom.jpg (Atom screenshot) +[14]: http://atom.io +[15]: https://discuss.atom.io/t/how-do-i-disable-the-metrics-or-tracking/24520 +[16]: https://opensource.com/article/19/4/write-git +[17]: https://opensource.com/sites/default/files/uploads/builder.png (GNOME Builder screenshot) +[18]: https://wiki.gnome.org/Apps/Builder +[19]: https://flathub.org/apps/details/org.gnome.Builder +[20]: https://opensource.com/sites/default/files/uploads/geany.png (Geany screenshot) +[21]: https://www.geany.org/ +[22]: https://opensource.com/sites/default/files/uploads/brackets.jpg (Brackets screenshot) +[23]: http://brackets.io/ +[24]: https://opensource.com/sites/default/files/uploads/che-cpp.jpg (Che screenshot) +[25]: https://www.eclipse.org/che/extend/ diff --git a/published/202007/20200622 Linux tools for improving your time management.md b/published/202007/20200622 Linux tools for improving your time management.md new file mode 100644 index 0000000000..af35552fa3 --- /dev/null +++ b/published/202007/20200622 Linux tools for improving your time management.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12388-1.html) +[#]: subject: (Linux tools for improving your time management) +[#]: via: (https://opensource.com/article/20/6/linux-time-management) +[#]: author: (Sudeshna Sur https://opensource.com/users/sudeshna-sur) + +时间管理专家的 Linux 工具 +====== + +> 无论你是需要帮助来保持专注、保持及时性,还是为了找到避免重复的捷径,这些 Linux 工具能够帮助你。 + +![](https://img.linux.net.cn/data/attachment/album/202007/07/084943stbchr65ke6r1cqh.jpg) + +生产力是一个主观术语,但从本质上讲,它是衡量特定任务完成效率的标准。每个人都有不同的方式来提高他们的生产力:有些人需要帮助专注于任务里、有些人需要特殊的工作环境、有些人需要警报和提醒以避免错过截止日期,还有些人需要协助处理重复的手工活。幸运的是,有多种工具和技术可为你提供所需的特定支持。特别地,如果你是 Linux 用户,有一些调整可以帮助你提高生产力。这是我经常使用的两个。 + +### 剪贴板指示器 + +你是否在日常使用中,在多个文档之间的大量使用复制和粘贴?如果是这样,那么 [剪贴板指示器][2] 应该成为你的首选方案之一。将剪贴板指示器作为 GNOME 扩展安装到 Linux 发行版中。以我的经验,它对 GNOME Shell 的性能影响很小,至少比我尝试过的其他方案要小。 + +该工具添加了一个指示器菜单到顶部面板,并缓存剪贴板历史。你可以设置历史记录大小、要预览的字符数量。它可以在复制时显示通知,并充当保存任意复制内容的临时空间。 + +![Clipboard indicator menu on GNOME desktop][3] + +安装扩展程序和连接器的最简单方法是使用发行版的包管理器。 + +对于 Fedora、CentOS 或 RHEL,请使用: + +``` +$ sudo dnf install chrome-gnome-shell +``` + +在 Ubuntu 或 Debian 上,请改用 `apt install`。 + +安装完成后,进入 并查看已安装的扩展。 + +如果你使用的是 Firefox,请使用 Firefox 浏览器附加组件并安装 “GNOME Shell integration”。你将在 Firefox 工具栏中看到一个很小的脚印图标,它将带你进入“扩展”页面。在该页面上,搜索 “Clipboard Indicator” 扩展并启用它。 + +现在,按照提示下载 GNOME 扩展并激活它。你可以查看 `~/.local/share/gnome-shell/extensions` 来浏览你的扩展。 + +好了!你将在 GNOME 桌面的右上角看到一个新图标。复制任意内容并尝试其设置。 + +也可以使用以下命令通过 Git 进行快速安装:将仓库克隆到本地的 gnome-shell 扩展目录中: + +``` +$ git clone https://github.com/Tudmotu/gnome-shell-extension-clipboard-indicator.git ~/.local/share/gnome-shell/extensions/clipboard-indicator@tudmotu.com +``` + +进入 GNOME Tweaks 工具,然后从“扩展”页面激活它。 + +### 番茄计时器(Pomodoro) + +![Using the pomodoro timer on GNOME][4] + +Pomodoro 技术是一种时间管理理念,旨在为用户提供最大注意力。每个 25 分钟的工作时间称为“pomodoro”(意大利语的“番茄”);每个番茄之后,你需要休息五分钟。每四个番茄时间,即每 100 分钟,你就要休息 15 至 20 分钟。如果你有大量的待办事项,那么使用 Pomodoro 技术可以通过强迫你遵守严格的时间安排来帮助你更快地完成项目。 + +可以通过 GNOME Tweaks 网页 (extensions.gnome.org)或通过命令行来管理安装过程。对于后者,请根据你的 Linux 发行版和版本,并使用以下命令进行安装: + +``` +$ sudo dnf install gnome-shell-extension-pomodoro +``` + +或者,如果你希望从源代码构建: + +``` +$ git clone -b gnome-3.34 https://github.com/codito/gnome-pomodoro.git +$ cd gnome-pomodoro +``` + +源码有许多依赖关系,其中许多可能已经安装。为了确保这点,请安装以下内容。 + +``` +$ sudo dnf install autoconf-archive gettext vala vala-tools pkg-config desktop-file-utils glib2-devel gtk3-devel libappstream-glib-devel libappindicator-gtk3-devel libcanberra-devel libpeas-devel sqlite-devel gom-devel gobject-introspection-devel gsettings-desktop-schemas-devel gstreamer1-devel +``` + +在源代码的解压目录中,完成构建。 + +``` +$ ./autogen.sh --prefix=/usr --datadir=/usr/share  +$ make  +$ sudo make install  +``` + +不管是怎么安装的,请进入 GNOME Tweaks 并打开番茄计时器。如果你还没有 GNOME Tweaks,请通过包管理器或所选的软件安装程序进行安装。例如,在 Fedora 上: + +``` +$ sudo dnf install gnome-tweaks +``` + +在 Ubuntu 或 Debian上,请改用 `apt install`。 + +Pomodoro 桌面集成当前可在 GNOME Shell 中使用,并且它们计划在将来支持更多桌面。 查看 获取有关该项目的最新信息。同时,对于 KDE 用户,还有一个名为 [Fokus][5] 的替代品。 + +### Linux 上的生产力 + +生产力是个人的,但这是我们所有人都在以某种方式追求的东西。这些工具中的每一个要么节省了我的时间,要么使我的工作效率提高了,它们可以与 Linux 快速集成。 + +你是否有喜欢的生产力工具?请在评论中分享! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/linux-time-management + +作者:[Sudeshna Sur][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sudeshna-sur +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-concentration-focus-windows-office.png?itok=-8E2ihcF (Woman using laptop concentrating) +[2]: https://extensions.gnome.org/extension/779/clipboard-indicator/ +[3]: https://opensource.com/sites/default/files/uploads/gnome-tweaks-productivity_0.png (Clipboard indicator menu on GNOME desktop) +[4]: https://opensource.com/sites/default/files/uploads/pomodoro-timer-fedora-opensourcecom.png (Using the pomodoro timer on GNOME) +[5]: https://store.kde.org/p/1308861/ diff --git a/published/202007/20200622 Missing Photoshop on Linux- Use PhotoGIMP and Convert GIMP into Photoshop.md b/published/202007/20200622 Missing Photoshop on Linux- Use PhotoGIMP and Convert GIMP into Photoshop.md new file mode 100644 index 0000000000..0b75d249c9 --- /dev/null +++ b/published/202007/20200622 Missing Photoshop on Linux- Use PhotoGIMP and Convert GIMP into Photoshop.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12373-1.html) +[#]: subject: (Missing Photoshop on Linux? Use PhotoGIMP and Convert GIMP into Photoshop) +[#]: via: (https://itsfoss.com/photogimp/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +在 Linux 上缺少 Photoshop?使用 PhotoGIMP 将 GIMP 变为 Photoshop +====== + +[Adobe Photoshop][1] 不适用于桌面 Linux。GIMP 是 [Linux 上 Adobe Photoshop 的最佳替代品][2]。 + +如果你使用过 Photoshop,那么你会注意到 [GIMP][3] 和 Photoshop 相比有不同的设置、键盘快捷键和布局。 + +这没有错。毕竟,它们都是两种不同的软件,而且它们不必看起来相同。 + +但是,习惯了 Photoshop 的人们发现在切换到 GIMP 的时很难忘记他们反复学习的肌肉记忆。这可能会使某些人感到沮丧,因为使用新的界面意味着要学习大量的键盘快捷键,并花时间在查找工具位于何处。 + +为了帮助从 Photoshop 切换到 GIMP 的人,[Diolinux][4] 推出了一个在 GIMP 中模仿 Adobe Photoshop 的工具。 + +### PhotoGIMP:在 Linux 中为 GIMP 提供 Adobe Photoshop 的外观 + +![][5] + +[PhotoGIMP][6] 不是独立的图形软件。它是 GIMP 2.10 的补丁。你需要在系统上安装 GIMP 才能使用 PhotoGIMP。 + +当你应用 PhotoGIMP 补丁时,它将更改 GIMP 布局以模仿 Adobe Photoshop。 + + * 默认安装数百种新字体 + * 安装新的 Python 过滤器,例如 “heal selection” + * 添加新的启动画面 + * 添加新的默认设置以最大化画布空间 + * 添加类似于 Adobe Photoshop 的键盘快捷键 + +PhotoGIMP 还在自定义 `.desktop` 文件中添加新的图标和名称。让我们看看如何使用它。 + +### 在 Linux 上安装 PhotoGIMP (适合中级到专业用户) + +PhotoGIMP 本质是一个补丁。在 Linux 中下载并[解压 zip 文件][7]。你将在解压的文件夹中找到以下隐藏的文件夹: + + * `.icons`:其中包含新的 PhotoGIMP 图标 + * `.local`:包含个性化的 `.desktop` 文件,以便你在系统菜单中看到的是 PhotoGIMP 而不是 GIMP + * `.var`:包含 GIMP 补丁的主文件夹 + +你应该[使用 Ctrl+H 快捷键在 Ubuntu 中显示隐藏文件][8]。 + +警告:建议你备份 GIMP 配置文件,以便在不喜欢 PhotoGIMP 时可以还原。只需将 GIMP 配置文件复制到其他位置即可备份。 + +目前,PhotoGIMP 主要与通过 [Flatpak][9] 安装的 GIMP 兼容。如果你使用 Flatpak 安装了 GIMP,那么只需将这些隐藏的文件夹复制粘贴到家目录中,它将 GIMP 转换为 Adobe Photoshop 类似的设置。 + +但是,如果你通过 apt、snap 或发行版的包管理器安装了 GIMP,那么必须找到 GIMP 的配置文件夹,然后粘贴 PhotoGIMP 的 `.var` 目录的内容。当出现询问时,请选择合并选项并替换同名的现有文件。 + +我[使用 apt 在 Ubuntu 20.04 中安装了 GIMP][10]。对我来说,GIMP 配置文件在 `~/.config/GIMP/2.10`。我复制了 `.var/app/org.gimp.GIMP/config/GIMP/2.10` 目录,并启动 GIMP 查看 PhotoGIMP 的启动页。 + +这是打了 PhotoGIMP 补丁后的 GIMP 界面: + +![][11] + +我尝试了几个 Photoshop 快捷键来检查它所做的更改,一切似乎可以正常工作。 + +- [下载 PhotoGIMP][12] + +我还找到了 [Snap 包形式的 PhotoGIMP][13],但它是 2019 年的,我不确定它是否可以在所有地方使用,或者仅适用于 snap 安装。 + +### 总结 + +这不是类似的第一个项目。几年前,我们有一个类似的项目叫 Gimpshop。Gimpshop 项目在过去的几年中没有任何进展,可以肯定地认为该项目已经死亡。有一个名为 Gimpshop 的网站,但该网站来自冒名者试图以 Gimpshop 的名义获利。 + +我不是 Adobe Photoshop 用户。我甚至不是 GIMP 专家,这就是为什么我们的 [GIMP 教程][14] 用 Dimitrios 的原因。 + +因此,我无法评论 PhotoGIMP 项目的实用性。如果你熟悉这两种软件,那么应该能够比我更好地进行判断。 + +如果你尝试使用 PhotoGIMP,请与他人分享你的经验,并告诉我们是否值得安装。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/photogimp/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.adobe.com/in/products/photoshop.html +[2]: https://itsfoss.com/open-source-photoshop-alternatives/ +[3]: https://www.gimp.org/ +[4]: https://diolinux.com.br/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/photogimp-feature.jpg?ssl=1 +[6]: https://github.com/Diolinux/PhotoGIMP +[7]: https://itsfoss.com/unzip-linux/ +[8]: https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/ +[9]: https://flatpak.org/ +[10]: https://itsfoss.com/gimp-2-10-release/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/photogimp-editor-interface.jpg?resize=800%2C538&ssl=1 +[12]: https://github.com/Diolinux/PhotoGIMP/releases +[13]: https://snapcraft.io/photogimp +[14]: https://itsfoss.com/tag/gimp-tips/ diff --git a/published/202007/20200622 Protect your system with fail2ban and firewalld blacklists.md b/published/202007/20200622 Protect your system with fail2ban and firewalld blacklists.md new file mode 100644 index 0000000000..4cd9c9c586 --- /dev/null +++ b/published/202007/20200622 Protect your system with fail2ban and firewalld blacklists.md @@ -0,0 +1,339 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12417-1.html) +[#]: subject: (Protect your system with fail2ban and firewalld blacklists) +[#]: via: (https://fedoramagazine.org/protect-your-system-with-fail2ban-and-firewalld-blacklists/) +[#]: author: (hobbes1069 https://fedoramagazine.org/author/hobbes1069/) + +使用 fail2ban 和 FirewallD 黑名单保护你的系统 +====== + +![][1] + +如果你运行的服务器有面向公众的 SSH 访问,你可能遇到过恶意登录尝试。本文介绍了如何使用两个实用程序来防止入侵者进入我们的系统。 + +为了防止反复的 ssh 登录尝试,我们来看看 fail2ban。而且,如果你不经常旅行,基本上停留在一两个国家,你可以将 FirewallD 配置为只允许[从你选择的国家访问][2]。 + +首先,让我们为不熟悉这些应用程序的人员介绍一些术语,以完成这项工作: + +**fail2ban**:一个守护进程,用于禁止发生多次认证错误的主机。fail2ban 将监控 SystemD 日志,以查找对任何已启用的“监狱jail”的失败的验证尝试。在达到指定失败次数后,它将添加一个防火墙规则,在配置的时间内阻止该特定 IP 地址。 + +**FirewallD**:一个带有 D-Bus 接口的防火墙守护进程,提供动态防火墙。除非你另行决定使用传统的 iptables,否则你已经在所有支持的 Fedora 和 CentOS 上安装了 FirewallD。 + +### 假定前提 + +* 主机系统有一个互联网连接,并且要么是直接暴露在互联网上,要么是通过 DMZ(这两个都是非常糟糕的想法,除非你知道你在做什么),要么是有一个端口从路由器转发过来。 +* 虽然大部分的内容可能适用于其他系统,但本文假设当前系统是 Fedora(31 及以上)或 RHEL/CentOS 8 版本。在 CentOS 上,你必须用 `sudo dnf install epel-release` 启用 Fedora EPEL 仓库。 + +### 安装与配置 + +#### Fail2Ban + +很有可能已经有某个 Firewalld 区已经允许 SSH 访问,但 sshd 服务本身默认没有启用。要手动启动它,并且不在启动时永久启用它: + +``` +$ sudo systemctl start sshd +``` + +或者在系统启动时启用,并同时启动它: + +``` +$ sudo systemctl enable --now sshd +``` + +下一步就是安装、配置、启用 fail2ban。和往常一样,安装可以通过命令行完成: + +``` +$ sudo dnf install fail2ban +``` + +安装完毕后,下一步就是配置“监狱”(你要以设置的任何阈值监视并禁止的服务)。默认情况下,IP 会被禁止 1 小时(这其实不够长)。最好的做法是使用 `*.local` 文件覆盖系统默认值,而不是直接修改 `*.config` 文件。如果我们查看我的 `jail.local`,我们可以看到: + +``` +# cat /etc/fail2ban/jail.local +[DEFAULT] + +# "bantime" is the number of seconds that a host is banned. +bantime = 1d + +# A host is banned if it has generated "maxretry" during the last "findtime" +findtime = 1h + +# "maxretry" is the number of failures before a host get banned. +maxretry = 5 +``` + +换成通俗的语言讲,就是在过去一小时内尝试 5 次后,该 IP 将被封禁 1 天。对于多次被封的 IP,也可以选择增加封禁时间,但这是另一篇文章的主题。 + +下一步是配置“监狱”。在本教程中显示的是 `sshd`,但其他服务的步骤大致相同。在 `/etc/fail2ban/jail.d` 中创建一个配置文件。这是我的文件: + +``` +# cat /etc/fail2ban/jail.d/sshd.local +[sshd] +enabled = true +``` + +就这么简单! 很多配置已经在为 Fedora 构建的软件包中处理了(提示:我是当前的维护者)。接下来启用并启动 fail2ban 服务: + +``` +$ sudo systemctl enable --now fail2ban +``` + +希望没有立即出错,如果没有,请使用下面的命令检查 fail2ban 的状态: + +``` +$ sudo systemctl status fail2ban +``` + +如果它没有错误地启动,应该是这样的: + +``` +$ systemctl status fail2ban +● fail2ban.service - Fail2Ban Service +Loaded: loaded (/usr/lib/systemd/system/fail2ban.service; disabled; vendor preset: disabled) +Active: active (running) since Tue 2020-06-16 07:57:40 CDT; 5s ago +Docs: man:fail2ban(1) +Process: 11230 ExecStartPre=/bin/mkdir -p /run/fail2ban (code=exited, status=0/SUCCESS) +Main PID: 11235 (f2b/server) +Tasks: 5 (limit: 4630) +Memory: 12.7M +CPU: 109ms +CGroup: /system.slice/fail2ban.service +└─11235 /usr/bin/python3 -s /usr/bin/fail2ban-server -xf start +Jun 16 07:57:40 localhost.localdomain systemd[1]: Starting Fail2Ban Service… +Jun 16 07:57:40 localhost.localdomain systemd[1]: Started Fail2Ban Service. +Jun 16 07:57:41 localhost.localdomain fail2ban-server[11235]: Server ready +``` + +如果是刚刚启动的,fail2ban 不太可能显示任何有意思的信息,但要检查 fail2ban 的状态,并确保“监狱”被启用,请输入: + +``` +$ sudo fail2ban-client status +Status +|- Number of jail: 1 +`- Jail list: sshd +``` + +sshd “监狱”的上级状态也会显示出来。如果启用了多个“监狱”,它们会在这里显示出来。 + +要查看一个“监狱”的详细状态,只需在前面的命令中添加“监狱”名称。下面是我的系统的输出,它已经运行了一段时间。我已经从输出中删除了被禁止的 IP: + +``` +$ sudo fail2ban-client status sshd +Status for the jail: sshd +|- Filter +| |- Currently failed: 8 +| |- Total failed: 4399 +| `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd +`- Actions + |- Currently banned: 101 + |- Total banned: 684 + `- Banned IP list: ... +``` + +监控 fail2ban 日志文件是否有入侵尝试,可以通过“尾随”日志来实现: + +``` +$ sudo tail -f /var/log/fail2ban.log +``` + +`tail` 是一个很好的命令行工具,默认情况下,它可以显示一个文件的最后 10 行。添加 `-f` 告诉它尾随文件,这是个观察一个仍在被写入的文件的很好方式。 + +由于输出的内容中有真实的 IP,所以这里不会提供样本,但它的可读性很高。`INFO` 行通常是登录的尝试。如果从一个特定的 IP 地址进行了足够多的尝试,你会看到一个 `NOTICE` 行显示一个 IP 地址被禁止。在达到禁止时间后,你会看到一个 `NOTICE` 解禁行。 + +注意几个警告行。最常见的情况是,当添加了一个禁止后,fail2ban 发现该 IP 地址已经在其禁止数据库中,这意味着禁止可能无法正常工作。如果是最近安装的 fail2ban 包,它应该被设置为 FirewallD 的富规则。这个包在 fail2ban-0.11.1-6 版本时从 ipset 方式切换到了富规则方式,所以如果你的 fail2ban 安装时间较早,它可能还在尝试使用 ipset 方式,这种方式使用的是传统的 iptables,不是很可靠。 + +#### FirewallD 配置 + +##### 被动还是主动? + +有两种策略可以分开或一起使用:**被动**地将单个 IP 地址或**主动**地根据来源国将子网永久列入黑名单。 + +对于被动方式,一旦 fail2ban 运行了一段时间,最好再运行 `sudo fail2ban-client status sshd` 来看看有哪些坏蛋。很可能会有很多被禁止的 IP 地址。选择一个,然后试着对它运行 `whois`。在输出结果中可能会有很多有趣的信息,但是对于这个方法来说,只有来源国是重要的。为了保持简单,让我们过滤掉除了国家以外的所有信息。 + +在这个例子中,我们将使用一些著名的域名: + +``` +$ whois google.com | grep -i country +Registrant Country: US +Admin Country: US +Tech Country: US +``` + +``` +$ whois rpmfusion.org | grep -i country +Registrant Country: FR +``` + +``` +$ whois aliexpress.com | grep -i country +Registrant Country: CN +``` + +使用 `grep -i` 的原因是为了使 `grep` 不区分大小写,而大多数条目都使用的是 “Country”,而有些条目则是全小写的 “country”,所以这种方法无论如何都能匹配。 + +现在知道了尝试入侵的来源国,问题是,“是否有来自这个国家的人有合法的理由连接到这台计算机?”如果答案是否定的,那么封锁整个国家应该是可以接受的。 + +从功能上看,主动式方法它与被动式方法没有太大区别,然而,来自有些国家的入侵企图是非常普遍的。如果你的系统既不放在这些国家里,也没有任何源自这些国家的客户,那么为什么不现在就把它们加入黑名单而是等待呢?(LCTT 译注:我的经验是,动辄以国家的范畴而列入黑名单有些过于武断。建议可以将该 IP 所属的 WHOIS 网段放入到黑名单,因为这些网段往往具有相同的使用性质,如都用于用户接入或 IDC 托管,其安全状况也大致相同,因此,如果有来自该网段的某个 IP 的恶意尝试,可以预期该网段内的其它 IP 也可能被利用来做这样的尝试。) + +##### 黑名单脚本和配置 + +那么如何做到这一点呢?用 FirewallD ipset。我开发了下面的脚本来尽可能地自动化这个过程: + +``` +#!/bin/bash +# Based on the below article +# https://www.linode.com/community/questions/11143/top-tip-firewalld-and-ipset-country-blacklist + +# Source the blacklisted countries from the configuration file +. /etc/blacklist-by-country + +# Create a temporary working directory +ipdeny_tmp_dir=$(mktemp -d -t blacklist-XXXXXXXXXX) +pushd $ipdeny_tmp_dir + +# Download the latest network addresses by country file +curl -LO http://www.ipdeny.com/ipblocks/data/countries/all-zones.tar.gz +tar xf all-zones.tar.gz + +# For updates, remove the ipset blacklist and recreate +if firewall-cmd -q --zone=drop --query-source=ipset:blacklist; then + firewall-cmd -q --permanent --delete-ipset=blacklist +fi + +# Create the ipset blacklist which accepts both IP addresses and networks +firewall-cmd -q --permanent --new-ipset=blacklist --type=hash:net \ + --option=family=inet --option=hashsize=4096 --option=maxelem=200000 \ + --set-description="An ipset list of networks or ips to be dropped." + +# Add the address ranges by country per ipdeny.com to the blacklist +for country in $countries; do + firewall-cmd -q --permanent --ipset=blacklist \ + --add-entries-from-file=./$country.zone && \ + echo "Added $country to blacklist ipset." +done + +# Block individual IPs if the configuration file exists and is not empty +if [ -s "/etc/blacklist-by-ip" ]; then + echo "Adding IPs blacklists." + firewall-cmd -q --permanent --ipset=blacklist \ + --add-entries-from-file=/etc/blacklist-by-ip && \ + echo "Added IPs to blacklist ipset." +fi + +# Add the blacklist ipset to the drop zone if not already setup +if firewall-cmd -q --zone=drop --query-source=ipset:blacklist; then + echo "Blacklist already in firewalld drop zone." +else + echo "Adding ipset blacklist to firewalld drop zone." + firewall-cmd --permanent --zone=drop --add-source=ipset:blacklist +fi + +firewall-cmd -q --reload + +popd +rm -rf $ipdeny_tmp_dir +``` + +这个应该安装到 `/usr/local/sbin`,不要忘了让它可执行! + +``` +$ sudo chmod +x /usr/local/sbin/firewalld-blacklist +``` + +然后创建一个配置文件 `/etc/blacklist-by-country`: + +``` +# Which countries should be blocked? +# Use the two letter designation separated by a space. +countries="" +``` + +而另一个配置文件 `/etc/blacklist-by-ip`,每行只有一个 IP,没有任何额外的格式化。 + +在这个例子中,从 ipdeny 的区文件中随机选择了 10 个国家: + +``` +# ls | shuf -n 10 | sed "s/\.zone//g" | tr '\n' ' ' +nl ee ie pk is sv na om gp bn +``` + +现在只要在配置文件中加入至少一个国家,就可以运行了! + +``` +$ sudo firewalld-blacklist + % Total % Received % Xferd Average Speed Time Time Time Current + Dload Upload Total Spent Left Speed +100 142 100 142 0 0 1014 0 --:--:-- --:--:-- --:--:-- 1014 +100 662k 100 662k 0 0 989k 0 --:--:-- --:--:-- --:--:-- 989k +Added nl to blacklist ipset. +Added ee to blacklist ipset. +Added ie to blacklist ipset. +Added pk to blacklist ipset. +Added is to blacklist ipset. +Added sv to blacklist ipset. +Added na to blacklist ipset. +Added om to blacklist ipset. +Added gp to blacklist ipset. +Added bn to blacklist ipset. +Adding ipset blacklist to firewalld drop zone. +success +``` + +要验证 FirewallD 黑名单是否成功,请检查 `drop` 区和 `blacklist` ipset。 + +``` +$ sudo firewall-cmd --info-zone=drop +drop (active) + target: DROP + icmp-block-inversion: no + interfaces: + sources: ipset:blacklist + services: + ports: + protocols: + masquerade: no + forward-ports: + source-ports: + icmp-blocks: + rich rules: + +$ sudo firewall-cmd --info-ipset=blacklist | less +blacklist + type: hash:net + options: family=inet hashsize=4096 maxelem=200000 + entries: +``` + +第二条命令将输出所有的子网,这些子网是基于被封杀的国家而添加的,可能会相当长。 + +### 那么现在我该怎么做? + +虽然在开始的时候,监控的频率会比较高,但随着时间的推移,入侵尝试的次数应该会随着黑名单的增加而减少。那么目标应该是维护而不是主动监控。 + +为此,我创建了一个 SystemD 服务文件和定时器,这样每月都会刷新由 ipdeny 维护的每个国家的子网。事实上,这里讨论的所有内容都可以从我的 [pagure.io](https://pagure.io/firewalld-blacklist) 项目中下载。 + +是不是很高兴你看完了整篇文章?现在只要把服务文件和定时器下载到 `/etc/systemd/system/`,并启用定时器就行了: + +``` +$ sudo systemctl daemon-reload +$ sudo systemctl enable --now firewalld-blacklist.timer +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/protect-your-system-with-fail2ban-and-firewalld-blacklists/ + +作者:[hobbes1069][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/hobbes1069/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/06/fail2ban-and-firewalld-816x345.png +[2]: https://www.linode.com/community/questions/11143/top-tip-firewalld-and-ipset-country-blacklist diff --git a/published/202007/20200624 How to Disable Dock on Ubuntu 20.04 and Gain More Screen Space.md b/published/202007/20200624 How to Disable Dock on Ubuntu 20.04 and Gain More Screen Space.md new file mode 100644 index 0000000000..3ca4e2946f --- /dev/null +++ b/published/202007/20200624 How to Disable Dock on Ubuntu 20.04 and Gain More Screen Space.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12414-1.html) +[#]: subject: (How to Disable Dock on Ubuntu 20.04 and Gain More Screen Space) +[#]: via: (https://itsfoss.com/disable-ubuntu-dock/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何在 Ubuntu 20.04 上禁用坞站(dock) +====== + +左侧的启动器已成为 [Ubuntu][1] 桌面的标识。它是在 [Unity 桌面][2]中引入的,甚至在 [Ubuntu 切换到 GNOME][3]时就有了,它复刻了 “Dash to Panel”,以在 [GNOME][4] 上创建一个类似的坞站dock。 + +就个人而言,我发现它对于快速访问常用应用非常方便,但并非所有人都希望它额外占用屏幕上的一些空间。 + +从 [Ubuntu 20.04][5] 开始,你可以轻松禁用坞站。在本教程中,让我向你展示如何以图形和命令的方式执行此操作。 + +![][6] + +### 通过扩展应用禁用 Ubuntu Dock + +[Ubuntu 20.04 的主要功能][7]之一是引入“扩展Extension”应用来管理系统上的 GNOME 扩展。只需在 GNOME 菜单中查找它(按下 Windows 键并输入): + +![Look for Extensions app in the menu][8] + +> 没有找到扩展应用? +> +> 如果尚未安装,你应该启用 GNOME Shell 扩展,“扩展” GUI 是此软件包的一部分。 +> +> ``` +> sudo apt install gnome-shell-extensions +> ``` +> +> 这仅对 [GNOME 3.36][9] 或 Ubuntu 20.04(或更高版本) 中的更高版本有效。 + +启动“扩展”应用,你应该在“内置”扩展下看到 Ubuntu Dock。你只需要关闭即可禁用坞站。 + +![Disable Ubuntu Dock][10] + +更改是即时的,你会看到坞站立即消失。 + +你可以用相同的方式恢复。只需打开它,它就会立即显示。 + +在 Ubuntu 20.04 中非常容易隐藏坞站,不是吗? + +### 替代方法:通过命令行禁用 Ubuntu 坞站 + +如果你是终端爱好者,并且喜欢在终端中做事,那么我有一个对你而言的好消息。你可以从命令行禁用 Ubuntu 坞站。 + +使用 `Ctrl+Alt+T` 打开终端。你可能已经知道 [Ubuntu 中的键盘快捷键][11]。 + +在终端中,使用以下命令列出所有可用的 GNOME 扩展: + +``` +gnome-extensions list +``` + +这将显示类似于以下的输出: + +![List GNOME Extensions][12] + +默认的 Ubuntu 坞站扩展是 `ubuntu-dock@ubuntu.com`。你可以使用以下命令将其禁用: + +``` +gnome-extensions disable ubuntu-dock@ubuntu.com +``` + +屏幕上不会显示任何输出,但是你会注意到启动器(坞站)从左侧消失了。 + +如果需要,你可以使用与上面相同的命令再次启用它,但使用启用选项: + +``` +gnome-extensions enable ubuntu-dock@ubuntu.com +``` + +### 总结 + +在 Ubuntu 18.04 中也有禁用坞站的方法。但是,如果你尝试在 18.04 中删除它,这可能会导致不想要的结果。删除此软件包也会删除 ubuntu-desktop 包,最终可能会导致系统崩溃,例如没有应用菜单。 + +这就是为什么我不建议在 Ubuntu 18.04 上删除它的原因。 + +好消息是 Ubuntu 20.04 提供了一种隐藏任务栏的方法。用户拥有更大的自由度和更多的屏幕空间。说到更多的屏幕空间,你是否知道可以[从 Firefox 移除顶部标题栏并获得更多的屏幕空间][14]? + +我想知道你喜欢怎样的 Ubuntu 桌面?要坞站,不要坞站,还是不要 GNOME? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/disable-ubuntu-dock/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://ubuntu.com/ +[2]: https://itsfoss.com/keeping-ubuntu-unity-alive/ +[3]: https://itsfoss.com/ubuntu-unity-shutdown/ +[4]: https://www.gnome.org/ +[5]: https://itsfoss.com/download-ubuntu-20-04/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/disable-dock-in-ubuntu.png?ssl=1 +[7]: https://itsfoss.com/ubuntu-20-04-release-features/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/GNOME-extensions-app-ubuntu.jpg?ssl=1 +[9]: https://itsfoss.com/gnome-3-36-release/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/disable-ubuntu-dock.png?ssl=1 +[11]: https://itsfoss.com/ubuntu-shortcuts/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/list-gnome-extensions.png?ssl=1 +[13]: https://itsfoss.com/cdn-cgi/l/email-protection +[14]: https://itsfoss.com/remove-title-bar-firefox/ diff --git a/published/202007/20200625 How to stress test your Linux system.md b/published/202007/20200625 How to stress test your Linux system.md new file mode 100644 index 0000000000..a9cc40f818 --- /dev/null +++ b/published/202007/20200625 How to stress test your Linux system.md @@ -0,0 +1,208 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12389-1.html) +[#]: subject: (How to stress test your Linux system) +[#]: via: (https://www.networkworld.com/article/3563334/how-to-stress-test-your-linux-system.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何对你的 Linux 系统进行压力测试 +====== + +> 如果你想了解 Linux 服务器在重压之下的运行情况,那么给 Linux 服务器施加压力是个不错的主意。在这篇文章中,我们将看一些工具,可以帮助你增加服务器压力并衡量结果。 + +![](https://images.idgesg.net/images/article/2020/06/stress-test2_linux-penguin-stress-ball_hand-squeezing_by-digitalsoul-getty-images_1136841639-100850120-large.jpg) + +为什么你会想给你的 Linux 系统施加压力呢?因为有时你可能想知道当一个系统由于大量运行的进程、繁重的网络流量、过多的内存使用等原因而承受很大的压力时,它的表现如何。这种压力测试可以帮助确保系统已经做好了 “上市” 的准备。 + +如果你需要预测应用程序可能需要多长时间才能做出反应,以及哪些(如果有的话)进程可能会在重负载下失败或运行缓慢,那么在前期进行压力测试是一个非常好的主意。 + +幸运的是,对于那些需要能够预测 Linux 系统在压力下的反应的人来说,你可以采用一些有用的技术和工具来使这个过程更容易。在这篇文章中,我们将研究其中的一些。 + +### 自己动手做个循环 + +第一种技术是在命令行上运行一些循环,观察它们对系统的影响。这种方式可以大大增加 CPU 的负荷。使用 `uptime` 或类似的命令可以很容易地看到结果。 + +在下面的命令中,我们启动了四个无尽循环。你可以通过添加数字或使用 bash 表达式,如 `{1...6}` 来代替 `1 2 3 4` 以增加循环次数: + +``` +for i in 1 2 3 4; do while : ; do : ; done & done +``` + +在命令行上输入后,将在后台启动四个无尽循环: + +``` +$ for i in 1 2 3 4; do while : ; do : ; done & done +[1] 205012 +[2] 205013 +[3] 205014 +[4] 205015 +``` + +在这种情况下,发起了作业 1-4,作业号和进程号会相应显示出来。 + +要观察对平均负载的影响,请使用如下所示的命令。在本例中,`uptime` 命令每 30 秒运行一次: + +``` +$ while true; do uptime; sleep 30; done +``` + +如果你打算定期运行这样的测试,你可以将循环命令放入脚本 `watch-it` 中。 + +``` +#!/bin/bash + +while true +do + uptime + sleep 30 +done +``` + +在输出中,你可以看到平均负载是如何增加的,然后在循环结束后又开始下降。 + +``` + 11:25:34 up 5 days, 17:27, 2 users, load average: 0.15, 0.14, 0.08 + 11:26:04 up 5 days, 17:27, 2 users, load average: 0.09, 0.12, 0.08 + 11:26:34 up 5 days, 17:28, 2 users, load average: 1.42, 0.43, 0.18 + 11:27:04 up 5 days, 17:28, 2 users, load average: 2.50, 0.79, 0.31 + 11:27:34 up 5 days, 17:29, 2 users, load average: 3.09, 1.10, 0.43 + 11:28:04 up 5 days, 17:29, 2 users, load average: 3.45, 1.38, 0.54 + 11:28:34 up 5 days, 17:30, 2 users, load average: 3.67, 1.63, 0.66 + 11:29:04 up 5 days, 17:30, 2 users, load average: 3.80, 1.86, 0.76 + 11:29:34 up 5 days, 17:31, 2 users, load average: 3.88, 2.06, 0.87 + 11:30:04 up 5 days, 17:31, 2 users, load average: 3.93, 2.25, 0.97 + 11:30:34 up 5 days, 17:32, 2 users, load average: 3.64, 2.35, 1.04 <== 循环停止 + 11:31:04 up 5 days, 17:32, 2 users, load average: 2.20, 2.13, 1.01 11:31:34 up 5 days, 17:33, 2 users, load average: 1.40, 1.94, 0.98 +``` + +因为所显示的负载分别代表了 1、5 和 15 分钟的平均值,所以这些值需要一段时间才能恢复到系统接近正常的状态。 + +要停止循环,请发出像下面这样的 `kill` 命令 —— 假设作业号是 1-4,就像本篇文章前面显示的那样。如果你不确定,可以使用 `jobs` 命令来确认作业号。 + +``` +$ kill %1 %2 %3 %4 +``` + +### 增加压力的专用工具 + +另一种方法是使用专门为你制造系统压力的工具。其中一种叫做 `stress`(压力),可以以多种方式对系统进行压力测试。`stress` 工具是一个工作负载生成器,提供 CPU、内存和磁盘 I/O 压力测试。 + +在使用 `--cpu` 选项时,`stress` 命令使用平方根函数强制 CPU 努力工作。指定的 CPU 数量越多,负载上升的速度就越快。 + +下面第二个脚本(`watch-it-2`)可以用来衡量对系统内存使用的影响。请注意,它使用 `free` 命令来查看加压的效果。 + +``` +$ cat watch-it-2 +#!/bin/bash + +while true +do + free + sleep 30 +done +``` + +发起任务并观察压力: + +``` +$ stress --cpu 2 + +$ ./watch-it + 13:09:14 up 5 days, 19:10, 2 users, load average: 0.00, 0.00, 0.00 + 13:09:44 up 5 days, 19:11, 2 users, load average: 0.68, 0.16, 0.05 + 13:10:14 up 5 days, 19:11, 2 users, load average: 1.20, 0.34, 0.12 + 13:10:44 up 5 days, 19:12, 2 users, load average: 1.52, 0.50, 0.18 + 13:11:14 up 5 days, 19:12, 2 users, load average: 1.71, 0.64, 0.24 + 13:11:44 up 5 days, 19:13, 2 users, load average: 1.83, 0.77, 0.30 +``` + +在命令行中指定的 CPU 越多,负载就增加的越快。 + +``` +$ stress --cpu 4 +$ ./watch-it + 13:47:49 up 5 days, 19:49, 2 users, load average: 0.00, 0.00, 0.00 + 13:48:19 up 5 days, 19:49, 2 users, load average: 1.58, 0.38, 0.13 + 13:48:49 up 5 days, 19:50, 2 users, load average: 2.61, 0.75, 0.26 + 13:49:19 up 5 days, 19:50, 2 users, load average: 3.16, 1.06, 0.38 + 13:49:49 up 5 days, 19:51, 2 users, load average: 3.49, 1.34, 0.50 + 13:50:19 up 5 days, 19:51, 2 users, load average: 3.69, 1.60, 0.61 +``` + +`stress` 命令也可以通过 `--io`(输入/输出)和 `--vm`(内存)选项增加 I/O 和内存的负载来给系统施加压力。 + +在接下来的这个例子中,运行这个增加内存压力的命令,然后启动 `watch-it-2` 脚本。 + +``` +$ stress --vm 2 + +$ watch-it-2 + total used free shared buff/cache available +Mem: 6087064 662160 2519164 8868 2905740 5117548 +Swap: 2097148 0 2097148 + total used free shared buff/cache available +Mem: 6087064 803464 2377832 8864 2905768 4976248 +Swap: 2097148 0 2097148 + total used free shared buff/cache available +Mem: 6087064 968512 2212772 8864 2905780 4811200 +Swap: 2097148 0 2097148 +``` + +`stress` 的另一个选项是使用 `--io` 选项为系统添加输入/输出活动。在这种情况下,你可以使用这样的命令: + +``` +$ stress --io 4 +``` + +然后你可以使用 `iotop` 观察受压的 I/O。注意,运行 `iotop` 需要 root 权限。 + +之前: + +``` +$ sudo iotop -o +Total DISK READ: 0.00 B/s | Total DISK WRITE: 19.36 K/s +Current DISK READ: 0.00 B/s | Current DISK WRITE: 27.10 K/s + TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND + 269308 be/4 root 0.00 B/s 0.00 B/s 0.00 % 1.24 % [kworker~fficient] + 283 be/3 root 0.00 B/s 19.36 K/s 0.00 % 0.26 % [jbd2/sda1-8] +``` + +之后: + +``` +Total DISK READ: 0.00 B/s | Total DISK WRITE: 0.00 B/s +Current DISK READ: 0.00 B/s | Current DISK WRITE: 0.00 B/s + TID PRIO USER DISK READ DISK WRITE SWAPIN IO> COMMAND + 270983 be/4 shs 0.00 B/s 0.00 B/s 0.00 % 51.45 % stress --io 4 + 270984 be/4 shs 0.00 B/s 0.00 B/s 0.00 % 51.36 % stress --io 4 + 270985 be/4 shs 0.00 B/s 0.00 B/s 0.00 % 50.95 % stress --io 4 + 270982 be/4 shs 0.00 B/s 0.00 B/s 0.00 % 50.80 % stress --io 4 + 269308 be/4 root 0.00 B/s 0.00 B/s 0.00 % 0.09 % [kworker~fficient] +``` + +`stress` 只是给系统增加压力的若干工具之一。另一个较新的工具,`stress-ng`,将在以后的文章中介绍。 + +### 总结 + +用于系统压力测试的各种工具可以帮助你预测系统在真实世界的情况下如何响应,在这些情况下,它们受到增加的流量和计算需求。 + +虽然我们在文章中展示的是创建和测量各种类型的压力的方法,但最终的好处是压力如何帮助确定你的系统或应用程序对它的反应。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3563334/how-to-stress-test-your-linux-system.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/newsletters/signup.html +[2]: https://www.facebook.com/NetworkWorld/ +[3]: https://www.linkedin.com/company/network-world diff --git a/published/202007/20200625 Make Bash history more useful with these tips.md b/published/202007/20200625 Make Bash history more useful with these tips.md new file mode 100644 index 0000000000..1757367d61 --- /dev/null +++ b/published/202007/20200625 Make Bash history more useful with these tips.md @@ -0,0 +1,146 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12381-1.html) +[#]: subject: (Make Bash history more useful with these tips) +[#]: via: (https://opensource.com/article/20/6/bash-history-control) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +这些技巧让 Bash 命令历史更加有用 +====== + +> 告诉 Bash 你想要它记住什么,甚至删除不需要的记录重写历史。 + +![](https://img.linux.net.cn/data/attachment/album/202007/05/091205hkg0egl2gge2gx9z.jpg) + +运行 [Bash][2] 的 Linux 终端有内置的历史记录,你可以用来跟踪最近的操作。要查看你的 Bash 会话的历史记录,请使用内置命令 `history`: + +``` +$ echo "foo" +foo +$ echo "bar" +bar +$ history +  1  echo "foo" +  2  echo "bar" +  3  history +``` + +与大多数命令不一样,`history` 命令不是文件系统上的可执行文件,而是 Bash 的功能。你可以使用 `type` 命令来验证: + +``` +$ type history +history is a shell builtin +``` + +### 历史控制 + +shell 历史记录的行数上限由 `HISTSIZE` 变量定义。你可以在 `.bashrc` 文件中设置此变量。以下将你的历史记录设置为 3,000 行,之后将最早的行删除以为最新命令腾出空间,该命令位于列表的底部: + +``` +export HISTSIZE=3000 +``` + +还有其他与历史相关的变量。 `HISTCONTROL` 变量控制哪些历史被记录。你可以在 `.bashrc` 中写入下面的行来强制 Bash 排除以空格开头的命令: + +``` +export HISTCONTROL=$HISTCONTROL:ignorespace +``` + +现在,如果你输入以空格开头的命令,那么它将不会记录在历史记录中: + +``` +$ echo "hello" +$     mysql -u bogus -h badpassword123 mydatabase +$ echo "world" +$ history +  1  echo "hello" +  2  echo "world" +  3  history +``` + +你也可以避免重复的条目: + +``` +export HISTCONTROL=$HISTCONTROL:ignoredups +``` + +现在,如果你一个接着一个输入两个命令,历史记录中只会显示一个: + +``` +$ ls +$ ls +$ ls +$ history +  1  ls +  2  history +``` + +如果你喜欢这两个忽略功能,那么可以使用 `ignoreboth`: + +``` +export HISTCONTROL=$HISTCONTROL:ignoreboth +``` + +### 从历史记录中删除命令 + +有时你会犯一个错误,在 shell 中输入了一些敏感内容,或者你​​只是想清理历史记录,以便它更准确地表示让某件事正常工作所采取的步骤。如果要从 Bash 的历史记录中删除命令,请在要删除的项目的行号上使用 `-d` 选项: + +``` +$ echo "foo" +foo +$ echo "bar" +bar +$ history | tail +  535  echo "foo" +  536  echo "bar" +  537  history | tail +$ history -d 536 +$ history | tail +  535  echo "foo" +  536  history | tail +  537  history -d 536 +  538  history | tail +``` + +要停止添加 `history` 条目,只要在 `HISTCONTROL` 环境变量中有 `ignorespace`,就可以在命令前添加空格: + +``` +$  history | tail +  535  echo "foo" +  536  echo "bar" +$  history -d 536 +$  history | tail +  535  echo "foo" +``` + +你可以使用 `-c` 选项清除所有会话历史记录: + +``` +$ history -c +$  history +$ +``` + +### history 命令的经验 + +操纵历史通常没有听起来那么危险,尤其是当你有目标地管理它时。例如,如果你要记录一个复杂的问题,通常最好使用会话历史来记录命令,因为通过将命令插入历史记录,你能运行它们并从而测试过程。很多时候,不执行历史命令会导致忽略小的步骤或写错小细节。 + +按需使用历史会话,并明智地控制历史记录。享受历史修改吧! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/bash-history-control + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming) +[2]: https://opensource.com/resources/what-bash diff --git a/published/202007/20200626 Docker and Fedora 32.md b/published/202007/20200626 Docker and Fedora 32.md new file mode 100644 index 0000000000..51d9073614 --- /dev/null +++ b/published/202007/20200626 Docker and Fedora 32.md @@ -0,0 +1,120 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12433-1.html) +[#]: subject: (Docker and Fedora 32) +[#]: via: (https://fedoramagazine.org/docker-and-fedora-32/) +[#]: author: (Kevin "Eonfge" Degeling https://fedoramagazine.org/author/eonfge/) + +在 Fedora 32 上运行 Docker +====== + +![][1] + +随着 Fedora 32 的发布,[Docker][2] 的普通用户面临着一个小挑战。在编写本文时,Fedora 32 不支持 Docker。虽然还有其他选择,例如 [Podman][3] 和 [Buildah][4],但是对于许多现有用户而言,现在切换可能不是最佳时机。因此,本文可以帮助你在 Fedora 32 上设置 Docker 环境。 + +### 步骤 0:消除冲突 + +此步骤适用于从 Fedora 30 或 31 升级的任何用户。如果全新安装的 Fedora 32,那么可以跳到步骤 1。 + +删除 docker 及其所有相关组件: + +``` +sudo dnf remove docker-* +sudo dnf config-manager --disable docker-* +``` + +### 步骤 1:系统准备 + +在 Fedora 的最后两个版本中,操作系统已迁移到两项新技术: CGroups 和用于防火墙的 NFTables。尽管这些新技术的详细信息不在本教程的讨论范围之内,但是令人遗憾的是,Docker 还不支持这些新技术。因此,你必须进行一些更改才能在 Fedora 上使用 Docker。 + +#### 启用旧的 CGroups + +Fedora 仍然支持 CGroups 的先前实现,可以使用以下命令启用它: + +``` +sudo grubby --update-kernel=ALL --args="systemd.unified_cgroup_hierarchy=0" +``` + +#### 在防火墙中将 Docker 列入白名单 + +为了让 Docker 具有网络访问权限,需要两个命令: + +``` +sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0 +sudo firewall-cmd --permanent --zone=FedoraWorkstation --add-masquerade +``` + +第一个命令将 Docker 接口添加到受信任的环境,它允许 Docker 建立远程连接。第二个命令将允许 Docker 建立本地连接。当有多个 Docker 容器作为开发环境时,这特别有用。 + +### 步骤 2:安装 Moby + +[Moby][5] 是 Docker 的开源白牌版本。它基于相同的代码,但不带商标。它包含在 Fedora 的主仓库中,因此很容易安装: + +``` +sudo dnf install moby-engine docker-compose +``` + +这将安装 `moby-engine`、`docker-compose`、`containerd` 和其他一些相关的库。安装完成后,你必须启用系统级守护程序才能运行 Docker: + +``` +sudo systemctl enable docker +``` + +### 步骤 3:重新启动并测试 + +为了确保正确处理所有系统和设置,你现在必须重启计算机: + +``` +sudo systemctl reboot +``` + +之后,你可以使用 Docker hello-world 包来验证安装: + +``` +sudo docker run hello-world +``` + +除非遇到问题,不然你就会看到来自 Docker 的问候! + +#### 以管理员身份运行 + +可选地,你现在还可以将用户添加到 Docker 的组帐户中,以便无需输入 `sudo` 即可启动 Docker 镜像: + +``` +sudo groupadd docker +sudo usermod -aG docker $USER +``` + +注销并登录以使更改生效。如果以管理员权限运行容器的想法让你有所顾虑,那么你应该研究 Podman。 + +### 总结 + +从现在起,Docker 将按照你的习惯工作,包括 `docker-compose` 和所有与 `docker` 相关的工具。不要忘记查看官方文档,这在很多情况下可以为你提供帮助。 + +Fedora 32 上 Docker 的当前状态并不理想。缺少官方软件包可能会困扰一些人,有一个[上游问题][6]对此进行了讨论。对 [CGroups][7] 和 [NFTables][8] 缺少支持更多是技术问题,但是你可以查看它们在其公共问题上的进展。 + +这些指导应可以让你就像什么都没有发生一样继续工作。如果这不能满足你的需求,请不要忘记到 Moby 或 Docker Github 页面去寻求解决你的技术问题,或者看看 Podman,长期来看,它可能会更加强大。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/docker-and-fedora-32/ + +作者:[Kevin "Eonfge" Degeling][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/eonfge/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/06/f32-04-twilight-816x459.png +[2]: https://docs.docker.com/ +[3]: https://podman.io/getting-started/ +[4]: https://buildah.io/ +[5]: https://mobyproject.org/ +[6]: https://github.com/docker/for-linux/issues/955 +[7]: https://github.com/moby/moby/issues/40360 +[8]: https://github.com/moby/moby/issues/26824 diff --git a/published/202007/20200626 Open source tools for translating British to American English.md b/published/202007/20200626 Open source tools for translating British to American English.md new file mode 100644 index 0000000000..a2f1f35abb --- /dev/null +++ b/published/202007/20200626 Open source tools for translating British to American English.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12430-1.html) +[#]: subject: (Open source tools for translating British to American English) +[#]: via: (https://opensource.com/article/20/6/british-american-cli-translator) +[#]: author: (Jeff Macharyas https://opensource.com/users/jeffmacharyas) + +将英式英语翻译成美式英语的开源工具 +====== + +> 使用这些命令行翻译器将英式英语转换为美式英语(或反之)。 + +![Red telephone booth on a street in England][1] + +去年圣诞节,我和我的妻子去了家乡佛罗里达的皮尔斯堡,并且经常光顾海滩上的一家当地人场所。在那儿,我们遇到了一对来自英国中部地区的夫妇。音乐很响,喝酒也很闹,所以很难听清楚。另外,即使他们“似乎”在说英语,但有时理解他们在说什么仍然是一个挑战。我以为我在澳大利亚的时光会给我足够的语言能力,但是,可惜,很多东西都超出了我的想象。不止是一般的 “soccer 是 football” 或 “trunk是 boot” 之类的困惑。 + +幸运的是,有开源方案可以将“英式”翻译成“美式”。我们可能使用相同的语言,但是我们共同的言语却比多塞特郡沙夫茨伯里的之字形山要曲折得多! + +如果你碰巧在酒吧有 Linux 笔记本,那么你可以使用方便的开源命令行程序,它就叫 [美英英语翻译器][2](MIT 许可证)。 + +我在我的改造运行 Linux 的 MacBook 上安装这个翻译器: + +``` +$ npm install -g american-british-english-translator +``` + +这需要我首先[安装 Node.js][3]。 + +### 声明! + +除了翻译单词和短语,美英英语翻译器还能分析(嗯,剖析)文档。我用一个叫《独立宣言》的流行文件试了一下。它分析并返回了许多结果。其中一个比较有趣的是: + +``` +fall: +issue: Different meanings(意思不同) +details: +American English: autumn(秋天) +British English: +""" +to become pregnant. (Either as in 'I fell pregnant' or as in 'She fell for a baby.');(怀孕 —— 无论是“我怀孕了”还是“她怀孕了”) +``` + +并非如《宣言》作者所指控的“在公海俘虏”(taken captive on the high seas): + +> ”他在公海上俘虏我们的同胞,强迫他们拿起武器来反对自己的国家,成为残杀自己亲人和朋友的刽子手,或是死于自己的亲人和朋友的手下。“(He has constrained our fellow Citizens taken Captive on the high Seas to bear Arms against their Country, to become the executioners of their friends and Brethren, or to fall themselves by their Hands.) + +### 还有一个 + +对于简单的单词替换,你可以尝试 [Common_Language][4],这是一个开源(MIT 许可)Python 脚本。 + +当然,要与同伴一起喝几杯,你也许需要实际交流,并能理解他们。这就是需要用到 MARY 了。 + +[MaryTTS][5] 是一个使用 Java(GNU 许可)编写的开源多语言文本到语音合成平台。方便的[基于浏览器的界面][6]使你可以轻松地将美国酒吧谈话内容转换为男声或女声的正确英语(或其他语言)。 + +现在我可以和我的英国朋友们见面了(可以安全地再来一次),喝几杯!像当地人一样讲英语!大家干杯! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/british-american-cli-translator + +作者:[Jeff Macharyas][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jeffmacharyas +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/england-telephone-booth-street.jpg?itok=JQsc_piX (Red telephone booth on a street in England) +[2]: https://github.com/hyperreality/American-British-English-Translator +[3]: https://nodejs.org/en/download/ +[4]: https://github.com/willettk/common_language +[5]: https://github.com/marytts/marytts +[6]: http://mary.dfki.de:59125/ diff --git a/published/202007/20200627 An open source browser extension to zoom in on images.md b/published/202007/20200627 An open source browser extension to zoom in on images.md new file mode 100644 index 0000000000..bc056c0938 --- /dev/null +++ b/published/202007/20200627 An open source browser extension to zoom in on images.md @@ -0,0 +1,51 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12384-1.html) +[#]: subject: (An open source browser extension to zoom in on images) +[#]: via: (https://opensource.com/article/20/6/hoverzoom) +[#]: author: (Jeff Macharyas https://opensource.com/users/jeffmacharyas) + +一个可放大图像的开源的浏览器扩展 +====== + +> 想细看网络图像并不总是那么简单,但是 Hover Zoom+ 让它像鼠标滑动一样容易。 + +![Digital images of a computer desktop][1] + +你是否曾经在访问网站时希望查看更大的图像?我经常遇到这种情况,而要做到这点并不总是那么容易。 + +有时,我在源码中筛选,使用 `Ctrl + F` 搜索图像,复制图像源地址并将其粘贴到新窗口中,以便以全尺寸查看图像。或者,另一个选择是右键单击,复制图像地址,然后粘贴到新选项卡中。 + +![Example image source code ][2] + +Hover Zoom+ 让这个过程更加简单。Hover Zoom+ 是一个简单 Chrome 扩展程序,在 MIT 许可证下发布,可在 Chrome 商店中找到,它的源码可在 [GitHub][3] 上获得。它也适用于 Firefox。 + +这个应用使得该过程更加容易。只需将鼠标悬停在图像上,你将看到一个弹出窗口来显示该图像的全部内容,它会匹配你的浏览器窗口,无论图像是否被裁剪(或者图像尺寸适当,它看上去会是一样的)。这可能很有趣,因为有时可能会裁剪原始图像,以适应空间或聚焦于图像的特定部分。但是,你无法右键单击并直接从弹出窗口中保存图像。 + +根据加州圣何塞的开发人员 Oleg Anashkin 的说法,“这是原始 HoverZoom 扩展的开源版本,现已被恶意软件所占领,并被从商店中删除。在此版本中,所有间谍软件均已删除,许多 bug 已被修复,并添加了新功能。它默认不会收集任何统计信息。” + +我在 Windows 10 笔记本上的 Chrome 中安装了此扩展,然后试用了一下。安装扩展后,我将鼠标悬停在图像上,它在弹出窗口中显示了比实际更大的图像。 + +但是,Hover Zoom+ 不适用于所有网站或所有图像。它适用于 Facebook 和 Twitter,但不适用于这些网站上的赞助内容。用户可以轻松切换该应用以针对特定站点启用或禁用它。使用 Hover Zoom+ 可以很容易地看到 Instagram 上的这只可爱小猫而无需实际阅读帖子(方便!): + +![Zoomed-in image of a kitten from Facebook][4] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/hoverzoom + +作者:[Jeff Macharyas][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jeffmacharyas +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_browser_web_desktop.png?itok=Bw8ykZMA (Digital images of a computer desktop) +[2]: https://opensource.com/sites/default/files/uploads/source.jpg (Example image source code) +[3]: https://github.com/extesy/hoverzoom/ +[4]: https://opensource.com/sites/default/files/uploads/fb-cat.jpg (HoverZoom+ enlarged image) diff --git a/published/202007/20200627 Learn Shell Scripting for Free With These Resources -PDF, Video Courses and Interactive Websites.md b/published/202007/20200627 Learn Shell Scripting for Free With These Resources -PDF, Video Courses and Interactive Websites.md new file mode 100644 index 0000000000..a4bcd85506 --- /dev/null +++ b/published/202007/20200627 Learn Shell Scripting for Free With These Resources -PDF, Video Courses and Interactive Websites.md @@ -0,0 +1,178 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12379-1.html) +[#]: subject: (Learn Shell Scripting for Free With These Resources [PDF, Video Courses and Interactive Websites]) +[#]: via: (https://itsfoss.com/shell-scripting-resources/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +学习 Shell 脚本编程的免费资源 +====== + +> 你想学习 shell 脚本编程吗?或者你想提升现有的 bash 知识?我收集了以下免费的资源来帮助你学习 shell 脚本编程。 + +(LCTT 译注:毫无疑问,这些都是英文的) + +shell 是一个命令行解释器,它允许你输入命令并获得输出。当你在使用终端的时候,你就已经在看 shell 了。 + +是的,shell 是一个你可以和它进行交互的命令行界面,你可以通过它给操作系统某种指令。虽然有不同类型的 shell,但是 [bash][1](GNU Bourne-Again Shell)是在各 Linux 发行版中最流行的。 + +当谈到 shell 脚本编程的时候,也就意味着 —— 用户希望使用脚本来执行多条命令来获得一个输出。 + +也许你需要学习 shell 脚本编程作为你的课程或者工作的一部分。了解 shell 脚本编程也可以帮助你在 Linux 中自动化某些重复的任务。 + +不管出于什么原因学习 shell 脚本编程,都可以看看这些我给你展示的资源。 + +### 最好的免费学习 shell 脚本编程的资源 + +![][2] + +还没在你的系统上安装 Linux?不用担心。有很多种方法[在 Windows 上使用 Linux 终端][3]。你也可以在某些情况下[使用在线 Linux 终端][4]来练习 shell 脚本编程。 + +#### 1、学习 Shell —— 互动网站 + +![][5] + +如果你正在找一个互动网站来学习 shell 脚本编程,并且还可以在线试试,“[学习 Shell][6]” 是一个不错的起点。 + +它涵盖了基础知识,并且也提供了一些高级的练习。通常,内容还是简明扼要的 —— 因此,我建议你看看这个网站。 + +#### 2、Shell 脚本编程教程 —— 门户网站 + +![][7] + +“[Shell 脚本编程教程][8]” 是一个完全专注于 shell 脚本编程的网站。你可以选择免费阅读其中的资源,也可以购买 PDF、实体书籍和电子书来支持他们。 + +当然,花钱买纸质的版本或者电子书不是强制的。但是,这些免费资源查看起来还是很方便的。 + +#### 3、Udemy:Shell 脚本 —— 免费视频课程 + +![][9] + +毫无疑问,[Udemy][10] 是最受欢迎的在线课程平台之一。而且,除了付费认证课程之外,它还提供了不包含证书的免费内容。 + +“[Shell 脚本][11]” 是 Udemy 上推荐度最高的免费课程之一。你不需要花费任何费用就可以注册这门课。 + +#### 4、Udemy:Bash Shell 脚本编程 —— 免费视频课程 + +![][12] + +Udemy 上另一个专注于 [bash shell 脚本编程][29]的有趣且免费的课程。与前面提到的课程相比,这个资源似乎更受欢迎。所以,你可以注册这门课,看看它都教些什么。 + +别忘了 Udemy 的免费课程不能提供证书。但是,它确实是一个让人印象深刻的免费 shell 脚本编程学习资源。 + +#### 5、Bash 研究院 —— 互动游戏在线门户 + +![][13] + +顾名思义,“[Bash 研究院][15]” 专注于向用户提供 bash shell 的教学。 + +尽管它没有很多的内容,它还是非常适合初学者和有一定经验的用户。不仅仅局限于指导 —— 它也可以提供交互式的游戏来练习,不过目前已经不能用了。 + +因此,如果这个足够有趣,你可以去看看这个 [Github 页面][14],并且如果你愿意的话,还可以复刻它并对现有资源进行改进。 + +#### 6、LinkedIn:学习 Bash 脚本编程 —— 免费视频课程 + +![][16] + +LinkedIn 提供了大量免费课程来帮助你提成技能,并且为更多工作做好准备。你还可以找到一些专注于 shell 脚本编程的课程,这些课程有助于重温基本技能或者这个过程中获得一些高级技能。 + +在这里,我提供一个 [学习 Bash 脚本编程][17] 的课程链接,你还可以发现其他类似的免费课程。 + +#### 7、高级 Bash 脚本编程指南 —— 免费 PDF 书籍 + +![][18] + +这是一个令人印象深刻的《[高级 Bash 脚本编程指南][19]》,并且可以免费获得到它的 PDF 版本。这个 PDF 资源没有版权限制,在公开领域是完全免费的。 + +尽管这个资源主要是提供高级的知识,通过参考这个 PDF 并且开始学习 shell 脚本编程,它还是很适合初学者的。 + +#### 8、专业 Bash 笔记 —— 免费 PDF 书籍 + +![][20] + +如果你已经对 Bash Shell 脚本编程比较熟悉或者只是想快速总结一下,那这是一个很好的参考。 + +这个《[专业 Bash 笔记][21]》可以免费下载的书有 100 多页,通过简单的描述和例子,这本书涵盖了各种各样的主题。 + +#### 9、Tutorialspoint —— 门户网站 + +![][22] + +“[Tutorialspoint][24]” 是一个非常流行的学习各种编程语言的门户网站。我想说这对于初学者学习基础知识非常好。 + +也许这不太适合作为一个详细的资源——但是它应该是不错的免费资源。 + +#### 10、旧金山城市学院:在线笔记 —— 门户网站 + +![][25] + +也许这不是最好的免费资源 —— 但是如果你已经为学习 shell 脚本编程做好了探索每种资源的准备,为什么不看看旧金山城市学院的 “[在线笔记][26]” 呢? + +当我在网上随便搜索关于 shell 脚本编程的资源的时候,我偶然遇到到了这个资源。 + +同样需要注意的是,这个在线笔记可能会有点过时。但是,这应该还是一个值得探索的有趣资源。 + +#### 荣誉奖: Linux 手册 + +![][27] + +不要忘记,bash 手册也应该是一个相当不错的免费资源,可以用它来查看命令和使用方法。 + +尽管它不是专门为你掌握 shell 脚本编程而量身打造的,它依然是一个你可以免费使用的重要网络资源。你可以选择访问在线手册,或者直接打开终端然后输入以下命令: + +``` +man bash +``` + +### 总结 + +有很多很受欢迎的付费资源,比如这些[最好的 Linux 书籍][28]。从网络上的一些免费资源开始学习 shell 脚本编程还是很方便的。 + +除了我提到的这些,我敢肯定网上还有不计其数的资源可以帮助你学习 shell 脚本编程。 + +你喜欢换上面提到的资源吗?如果你知道我可能错过的非常棒的免费资源,记得在下面评论区告诉我。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/shell-scripting-resources/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[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://en.wikipedia.org/wiki/Bash_(Unix_shell) +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Learn-Shell-Scripting.png?ssl=1 +[3]: https://itsfoss.com/run-linux-commands-in-windows/ +[4]: https://itsfoss.com/online-linux-terminals/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/learnshell.png?ssl=1 +[6]: https://www.learnshell.org/ +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/shell-scripting-tutorial.png?ssl=1 +[8]: https://www.shellscript.sh/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/shell-scripting-udemy.png?ssl=1 +[10]: https://www.udemy.com +[11]: https://www.udemy.com/course/shell-scripting-i/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/bash-shell-scripting.png?ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/the-bash-academy.png?ssl=1 +[14]: https://github.com/lhunath/guide.bash.academy +[15]: https://guide.bash.academy/ +[16]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/learn-bash-scripting-linkedin.png?ssl=1 +[17]: https://www.linkedin.com/learning/learning-bash-scripting +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/advanced-bash-scripting-pdf.png?ssl=1 +[19]: http://tldp.org/LDP/abs/abs-guide.pdf +[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Bash-Notes-for-Professional.jpg?ssl=1 +[21]: https://goalkicker.com/BashBook/ +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/tutorialspoint-shell.png?ssl=1 +[23]: https://en.wikipedia.org/wiki/Programming_language +[24]: https://www.tutorialspoint.com/unix/shell_scripting.htm +[25]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/scripting-notes-ccsf.png?ssl=1 +[26]: https://fog.ccsf.edu/~gboyd/cs160b/online/index.html +[27]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/bash-linux-man-page.png?ssl=1 +[28]: https://itsfoss.com/best-linux-books/ +[29]: https://www.udemy.com/course/complete-bash-shell-scripting/ \ No newline at end of file diff --git a/published/202007/20200628 How to crop images in GIMP -Quick Tip.md b/published/202007/20200628 How to crop images in GIMP -Quick Tip.md new file mode 100644 index 0000000000..df99b3db25 --- /dev/null +++ b/published/202007/20200628 How to crop images in GIMP -Quick Tip.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12427-1.html) +[#]: subject: (How to crop images in GIMP [Quick Tip]) +[#]: via: (https://itsfoss.com/crop-images-gimp/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +GIMP 教程:如何使用 GIMP 裁剪图像 +====== + +你可能想在 [GIMP][1] 中裁剪图像的原因有很多。例如,你可能希望删除无用的边框或信息来改善图像,或者你可能希望最终图像的焦点是在一个特定细节上。 + +在本教程中,我将演示如何在 GIMP 中快速裁剪图像而又不影响精度。让我们一起来看看吧。 + +### 如何在 GIMP 中裁剪图像 + +![][2] + +#### 方法 1 + +裁剪只是一种将图像修整成比原始图像更小区域的操作。裁剪图像的过程很简单。 + +你可以通过“工具”面板访问“裁剪工具”,如下所示: + +![Use Crop Tool for cropping images in GIMP][3] + +你还可以通过菜单访问裁剪工具:“工具 → 变形工具 → 裁剪Tools → Transform Tools → Crop”。 + +激活该工具后,你会注意到画布上的鼠标光标会发生变化,以表示正在使用“裁剪工具”。 + +现在,你可以在图像画布上的任意位置单击鼠标左键,并将鼠标拖到某个位置以创建裁剪边界。此时你不必担心精度,因为你可以在实际裁剪之前修改最终选区。 + +![Crop Selection][4] + +此时,将鼠标光标悬停在所选内容的四个角上会更改鼠标光标并高亮显示该区域。现在,你可以微调裁剪的选区。你可以单击并拖动任何边或角来移动部分选区。 + +选定完区域后,你只需按键盘上的回车键即可进行裁剪。 + +如果你想重新开始或者不裁剪,你可以按键盘上的 `Esc` 键。 + +#### 方法 2 + +裁剪图像的另一种方法是使用“矩形选择工具”进行选择:“工具 → 选择工具 → 选择矩形Tools → Selection Tools → Rectangle Select”。 + +![][5] + +然后,你可以使用与“裁剪工具”相同的方式高亮选区,并调整选区。选择好后,可以通过以下方式裁剪图像来适应选区:“图像 → 裁剪为选区Image → Crop to Selection”。 + +![][6] + +### 总结 + +对于 GIMP 用户而言,精确裁剪图像可以视为一项基本功能。你可以选择哪种方法更适合你的需求并探索其潜力。 + +如果你对过程有任何疑问,请在下面的评论中告诉我。如果你“渴望”更多 [GIMP 教程][7],请确保在你喜欢的社交媒体平台上订阅! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/crop-images-gimp/ + +作者:[Dimitrios Savvopoulos][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://www.gimp.org/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Crop-images-in-GIMP.png?ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/Crop-tool.png?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/Crop-selection.jpg?ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/select-1.gif?ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/crop.gif?ssl=1 +[7]: https://itsfoss.com/tag/gimp-tips/ diff --git a/published/202007/20200628 Linux Mint 20 is Officially Available Now- The Performance and Visual Improvements Make it an Exciting New Release.md b/published/202007/20200628 Linux Mint 20 is Officially Available Now- The Performance and Visual Improvements Make it an Exciting New Release.md new file mode 100644 index 0000000000..2ad86e500c --- /dev/null +++ b/published/202007/20200628 Linux Mint 20 is Officially Available Now- The Performance and Visual Improvements Make it an Exciting New Release.md @@ -0,0 +1,110 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12376-1.html) +[#]: subject: (Linux Mint 20 is Officially Available Now! The Performance and Visual Improvements Make it an Exciting New Release) +[#]: via: (https://itsfoss.com/linux-mint-20-download/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Linux Mint 20 正式发布了!你该升级吗? +====== + +![](https://img.linux.net.cn/data/attachment/album/202007/03/083110avnb4rwi0rwzh56r.jpg) + +Linux Mint 20 “Ulyana” 终于发布了,可以下载了。 + +Linux Mint 19 基于 Ubuntu 18.04 LTS,而 [Mint 20][1] 则基于 [Ubuntu 20.04 LTS][2] —— 所以你会发现很多不同的地方、改进的地方,可能更棒了。 + +既然它来了,让我们来看看它的新功能,在哪里下载它,以及如何升级你的系统。 + +### Linux Mint 20:有什么新东西? + +我们制作了一段关于 Linux Mint 20 的初步视觉印象的视频,让大家更好地了解。 + +- [video](https://youtu.be/7knHfN-NUZk) + +说到 Linux Mint 20 的发布,有很多事情要谈。虽然我们已经介绍了 Linux Mint 20 的新的关键[功能][1],但我还是在这里提几点,让大家一目了然。 + + * Nemo 文件管理器在生成缩略图方面的性能提升 + * 一些重新设计的颜色主题 + * Linux Mint 20 将禁止 APT 使用 Snapd + * 一个新的图形用户界面工具,用于通过本地网络共享文件 + * 改进对多显示器的支持 + * 改进对笔记本电脑的混合图形支持 + * 不再有 32 位版本 + +除了这些变化之外,你还会注意到 Cinnamon 4.6 桌面更新后的一些视觉变化。 + +以下是 Linux Mint 20 Cinnamon 版的一些截图。 + +![Mint 20 Welcome Screen][4] + +![Mint 20 Color Themes][5] + +![Mint 20 Nemo File Manager][6] + +![Mint 20 Nemo File Manager Blue Color Theme][7] + +![Mint 20 Wallpapers][8] + +![Mint 20 Redesigned Gdebi Installer][9] + +![Mint 20 Warpinator Tool for Sharing Files on Local Network][10] + +![Mint 20 Terminal][11] + +### 升级到 Linux Mint 20:你需要知道什么? + +如果你已经在使用 Linux Mint,你可以选择升级到 Linux Mint 20。 + + * 如果你使用的是 Linux Mint 20 测试版,你可以升级到 Mint 20 稳定版。 + * 如果你正在使用 Linux Mint 19.3(这是 Mint 19 的最新迭代),你可以将系统升级到 Linux Mint 20,而不需要进行重新安装 + * Linux Mint 20 没有 32 位版本。如果你**使用 32 位的 Mint 19 系列,你将无法升级到 Mint 20** + * 如果你使用的是 Linux Mint 18 系列,你必须先通过 Mint 19 系列升级。在我看来,重新安装 Mint 20 会比较省时省事 + * 如果你使用的是 Linux Mint 17、16、15 或更低版本,你一定不要再使用它们了。这些版本已经不支持了 + +我们有一个详细的指南,展示了从 18.3 到 19 [升级 Linux Mint 版本][12]的步骤。我猜测 Mint 20 的步骤应该也是一样的。我们的团队会对 Mint 19.3 到 Mint 20 的升级做一些测试,并在适用的情况下更新这个指南。 + +在你继续升级之前,请确保备份你的数据和[使用 Timeshift 创建系统快照][13]。 + +### 下载Linux Mint 20 + +你可以简单地前往其官方下载页面,为自己抓取最新的稳定 ISO。你会发现官方支持的桌面环境的 ISO,即 Cinnamon、MATE 和 Xfce。 + +此外,还为那些网络连接缓慢或不稳定的用户提供了 Torrent链接。 + +- [下载 Linux Mint 20][14] + +如果你只是想在不更换主系统的情况下试一试,我建议先[在 VirtualBox 中安装 Linux Mint 20][15],看看这是不是你喜欢的东西。 + +你试过 Linux Mint 20 了吗?你对这个版本有什么看法?请在下面的评论区告诉我你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-mint-20-download/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[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://linux.cn/article-12297-1.html +[2]: https://itsfoss.com/download-ubuntu-20-04/ +[3]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-welcome-screen.png?fit=800%2C397&ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-color-themes.png?fit=800%2C396&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-nemo-file-manager.png?fit=800%2C397&ssl=1 +[7]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-nemo-file-manager-blue-color-theme.png?fit=800%2C450&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-wallpapers.png?fit=800%2C450&ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-redesigned-gdebi-installer.png?fit=800%2C582&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-warpinator.png?fit=800%2C397&ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/mint-20-terminal.png?fit=800%2C540&ssl=1 +[12]: https://itsfoss.com/upgrade-linux-mint-version/ +[13]: https://itsfoss.com/backup-restore-linux-timeshift/ +[14]: https://linuxmint.com/download.php +[15]: https://itsfoss.com/install-linux-mint-in-virtualbox/ diff --git a/published/202007/20200628 entr- rerun your build when files change.md b/published/202007/20200628 entr- rerun your build when files change.md new file mode 100644 index 0000000000..6fd30b30d8 --- /dev/null +++ b/published/202007/20200628 entr- rerun your build when files change.md @@ -0,0 +1,109 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12403-1.html) +[#]: subject: (entr: rerun your build when files change) +[#]: via: (https://jvns.ca/blog/2020/06/28/entr/) +[#]: author: (Julia Evans https://jvns.ca/) + +entr:文件更改时重新运行构建 +====== + +![](https://img.linux.net.cn/data/attachment/album/202007/11/094223uct6386d9iwctmbh.jpg) + +这是一篇简短的文章。我是最近才发现 [entr][1] 的,我很惊奇从来没有人告诉过我?!因此,如果你和我一样,那么我告诉你它是什么。 + +[entr 的网站][1]上对它已经有很好的解释,也有很多示例。 + +总结在其头部:`entr` 是一个命令行工具,当每次更改一组指定文件中的任何一个时,都能运行一个任意命令。你在标准输入给它传递要监控的文件列表,如下所示: + +``` +git ls-files | entr bash my-build-script.sh +``` + +或者 + +``` +find . -name *.rs | entr cargo test +``` + +或者任何你希望的。 + +### 快速反馈很棒 + +就像世界上的每个程序员一样,我发现每次更改代码时都必须手动重新运行构建/测试非常烦人。 + +许多工具(例如 hugo 和 flask)都有一个内置的系统,可以在更改文件时自动重建,这很棒! + +但是通常我会自己编写一些自定义的构建过程(例如 `bash build.sh`),而 `entr` 让我有了一种神奇的构建经验,我只用一行 bash 就能得到即时反馈,知道我的改变是否修复了那个奇怪的 bug。万岁! + +### 重启服务器(entr -r) + +但是如果你正在运行服务器,并且每次都需要重新启动服务器怎么办?如果你传递 `-r`,那么 `entr` 会帮你的 + +``` +git ls-files | entr -r python my-server.py +``` + +### 清除屏幕(entr -c) + +另一个简洁的标志是 `-c`,它让你可以在重新运行命令之前清除屏幕,以免被前面构建的输出分散注意力。 + +### 与 git ls-files 一起使用 + +通常,我要跟踪的文件集和我在 git 中的文件列表大致相同,因此将 `git ls-files` 传递给 `entr` 是很自然的事情。 + +我现在有一个项目,有时候我刚创建的文件还没有在 git 里。那么如果你想包含未被跟踪的文件怎么办呢?这些 `git` 命令行参数就可以做到(我是从一个读者的邮件中得到的,谢谢你!): + +``` +git ls-files -cdmo --exclude-standard | entr your-build-script +``` + +有人给我发了邮件,说他们做了一个 `git-entr` 命令,可以执行: + +``` +git ls-files -cdmo --exclude-standard | entr -d "$@" +``` + +我觉得这真是一个很棒的主意。 + +### 每次添加新文件时重启:entr -d + +`git ls-files` 的另一个问题是有时候我添加一个新文件,当然它还没有在 git 中。`entr` 为此提供了一个很好的功能。如果你传递 `-d`,那么如果你在 `entr` 跟踪的任何目录中添加新文件,它就会退出。 + +我将它与一个 `while` 循环配合使用,它将重启 `entr` 来包括新文件,如下所示: + +``` +while true +do +{ git ls-files; git ls-files . --exclude-standard --others; } | entr -d your-build-scriot +done +``` + +### entr 在 Linux 上的工作方式:inotify + +在 Linux 中,`entr` 使用 `inotify`(用于跟踪文件更改这样的文件系统事件的系统)工作。如果用 `strace` 跟踪它,那么你会看到每个监控文件的 `inotify_add_watch` 系统调用,如下所示: + +``` +inotify_add_watch(3, "static/stylesheets/screen.css", IN_ATTRIB|IN_CLOSE_WRITE|IN_CREATE|IN_DELETE_SELF|IN_MOVE_SELF) = 1152 +``` + +### 就这样了 + +我希望这可以帮助一些人了解 `entr`! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2020/06/28/entr/ + +作者:[Julia Evans][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://jvns.ca/ +[b]: https://github.com/lujun9972 +[1]: http://eradman.com/entrproject/ diff --git a/published/202007/20200630 Painless file extraction on Linux.md b/published/202007/20200630 Painless file extraction on Linux.md new file mode 100644 index 0000000000..4cd4d39c8c --- /dev/null +++ b/published/202007/20200630 Painless file extraction on Linux.md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12410-1.html) +[#]: subject: (Painless file extraction on Linux) +[#]: via: (https://www.networkworld.com/article/3564265/painless-file-extraction-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux 上无痛文件提取 +====== + +![](https://img.linux.net.cn/data/attachment/album/202007/12/233401zickd110d2dl6u6f.jpg) + +从 Linux 系统的存档中提取文件没有拔牙那么痛苦,但有时看起来更复杂。在这篇文章中,我们将看看如何轻松地从 Linux 系统中可能遇到的几乎所有类型的存档中提取文件。 + +它们有很多格式,从 .gz 到 .tbz2,这些文件的命名方式都各有一些不同。当然,你可以记住所有从存档中提取文件的各种命令以及它们的选项,但是你也可以将所有经验保存到脚本中,而不再担心细节。 + +在本文中,我们将一系列提取命令组合成一个脚本,它会调用适当的命令根据文档名提取文件的内容。该脚本首先以一些命令来验证是否已经提供了一个文件名作为参数,或要求运行脚本的人提供文件名。 + +``` +#!/bin/bash + +if [ $# -eq 0 ]; then + echo -n "filename> " + read filename +else + filename=$1 +fi + +if [ ! -f "$filename" ]; then + echo "No such file: $filename" + exit $? +fi +``` + +了解了么?如果未提供任何参数,脚本将提示输入文件名,如果存在则使用它。然后,它验证文件是否实际存在。如果不是,那么脚本退出。 + +下一步是使用 bash 的 `case` 语句根据存档文件的名称调用适当的提取命令。对于其中某些文件类型(例如 .bz2),也可以使用除 `tar` 之外的其它命令,但是对于每种文件命名约定,我们仅包含一个提取命令。因此,这是带有各种存档文件名的 `case` 语句: + +``` + case $filename in + *.tar) tar xf $filename;; + *.tar.bz2) tar xjf $filename;; + *.tbz) tar xjf $filename;; + *.tbz2) tar xjf $filename;; + *.tgz) tar xzf $filename;; + *.tar.gz) tar xzf $filename;; + *.gz) gunzip $filename;; + *.bz2) bunzip2 $filename;; + *.zip) unzip $filename;; + *.Z) uncompress $filename;; + *) echo "No extract option for $filename" +esac +``` + +如果提供给脚本的文件扩展名与脚本已知的扩展名都不匹配,那么会发出 “No extract option for $filename” 的消息。如果缺少你使用的任何存档类型,只需将它们与所需的提取命令一起添加即可。 + +将 bash 头添加到脚本顶部,使其可执行,然后就可以开始了。 + +``` +#!/bin/bash + +if [ $# -eq 0 ]; then + echo -n "filename> " + read filename +else + filename=$1 +fi + +if [ ! -f "$filename" ]; then + echo "No such file: $filename" + exit $? +fi + +case $filename in + *.tar) tar xf $filename;; + *.tar.bz2) tar xjf $filename;; + *.tbz) tar xjf $filename;; + *.tbz2) tar xjf $filename;; + *.tgz) tar xzf $filename;; + *.tar.gz) tar xzf $filename;; + *.gz) gunzip $filename;; + *.bz2) bunzip2 $filename;; + *.zip) unzip $filename;; + *.Z) uncompress $filename;; + *.rar) rar x $filename ;; + *) +``` + +如果你希望脚本在提取文件时显示内容,请将详细选项(`-v`)添加到每个命令参数字符串中: + +``` +#!/bin/bash + +if [ $# -eq 0 ]; then + echo -n "filename> " + read filename +else + filename=$1 +fi + +if [ ! -f "$filename" ]; then + echo "No such file: $filename" + exit $? +fi + +case $filename in + *.tar) tar xvf $filename;; + *.tar.bz2) tar xvjf $filename;; + *.tbz) tar xvjf $filename;; + *.tbz2) tar xvjf $filename;; + *.tgz) tar xvzf $filename;; + *.tar.gz) tar xvzf $filename;; + *.gz) gunzip -v $filename;; + *.bz2) bunzip2 -v $filename;; + *.zip) unzip -v $filename;; + *.Z) uncompress -v $filename;; + *) echo "No extract option for $filename" +esac +``` + +### 总结 + +虽然可以为每个可能用到的提取命令创建别名,但是让脚本为遇到的每种文件类型提供命令要比自己停下来编写每个命令和选项容易。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3564265/painless-file-extraction-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.facebook.com/NetworkWorld/ +[2]: https://www.linkedin.com/company/network-world diff --git a/published/202007/20200630 Read and write data from anywhere with redirection in the Linux terminal.md b/published/202007/20200630 Read and write data from anywhere with redirection in the Linux terminal.md new file mode 100644 index 0000000000..b55f7d8875 --- /dev/null +++ b/published/202007/20200630 Read and write data from anywhere with redirection in the Linux terminal.md @@ -0,0 +1,134 @@ +[#]: collector: (lujun9972) +[#]: translator: (nophDog) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12385-1.html) +[#]: subject: (Read and write data from anywhere with redirection in the Linux terminal) +[#]: via: (https://opensource.com/article/20/6/redirection-bash) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +通过重定向在 Linux 终端任意读写数据 +====== + +> 重定向是一种十分高效的数据流动方式,它能帮你减少很多鼠标和键盘上的操作。 + +![](https://img.linux.net.cn/data/attachment/album/202007/06/005419nh6mzxkmmmbsslbb.jpg) + +对于任何编程或脚本语言,输入与输出重定向都是很自然的功能。严格来说,当你使用电脑时,数据自然而然地在发生着重定向。从 `stdin`(标准输入,通常是你的键盘或者鼠标)读取输入,输入则发往 `stdout`(标准输出,一段文本或者数据流),最后错误信息送至 `stderr`。如果你使用 [Bash][2] 或 [Zsh][3] 之类的 shell,那么理解这些数据流能够让你更好地控制信息流向。 + +标准输入、标准输出以及标准错误输出都存在于 Linux 文件系统中。你可以在 `/dev` 查看: + +``` +$ ls /dev/std* +/dev/stderr@  /dev/stdin@  /dev/stdout@ +``` + +你可能没法直接使用它们,但将它们想象成你能传递数据的元位置,会很有帮助。 + +重定向的基础很简单:用一些 `>` 符号重定向输出,然后用另外一些 `<` 符号重定向输入。 + +### 重定向输出 + +将 [ls][4] 命令的输出写入一个文件: + +``` +$ ls > list.txt +``` + +你没法像平常那样看到 `ls` 的输出,因为它们并没有被发送到屏幕,而是被写入 `list.txt` 文件了,这个功能用处太多了,事实上,你甚至可以用它来将文件内容拷贝到另一个文件。不一定是文本文件,你也可以用将重定向用于二进制数据: + +``` +$ cat image.png > picture.png +``` + +(你可能会好奇为什么要这样做,有时候对于 [文件权限信息][5] 而间接有用。) + +### 重定向输入 + +你也能将输入重定向“到”一个命令。可以说,它没有重定向输出那么有用,因为许多命令已经被硬编码,只从你的参数中接收输入。但是,如果某个命令需要一系列参数,而且你把这些参数写在文件里,想要快速“复制粘贴”到终端的时候(除非你并不想复制粘贴),它就帮得上忙了。 + +``` +$ sudo dnf install $(嵌入文档here-document(简写成 here-doc)和嵌入字符串here-string 技巧。这种输入方法将一整块文本重定向至标准输入流,直到碰见一个特殊的文件结束标记(许多人习惯用 `EOF`,实际上你可以使用任何字符串,只要它是唯一的)。试着把这些(在第二个 `EOF` 标记之前)敲进你的终端: + +``` +$ echo << EOF +> foo +> bar +> baz +> EOF +``` + +输出结果: + +``` +foo +bar +baz +``` + +使用 [Bash][2] 编写脚本的人常常用这个技巧,将数行文本一次性写入文件或者打印到屏幕上。只要你别忘了末尾的文件结束标记,这会是一个帮你避免大量繁琐 `echo` 或 `printf` 语句的好办法。 + +嵌入字符串类似于嵌入文档,但是它只含有一个字符串(或者用引号包裹的几个字符串,同样会被当成一个字符串) + +``` +$ cat <<< "foo bar baz" +foo bar baz +``` + +### 重定向错误信息 + +错误信息流叫做 `stderr`,通过 `2>` 实现这个目的。下面这个命令把错误信息定向到 `output.log` 文件: + +``` +$ ls /nope 2> output.log +``` + +### 将数据送往 /dev/null + +既然标准输入、标准输出和错误输出都有自己的位置,那么“空空如也”也应该在 Linux 文件系统占有一席之地。没错,它叫做 `null`,位于 `/dev`,频繁使用的人懒得说 “slash dev slash null”,于是索性叫它 “devnull”。 + +通过重定向,你可以把数据发送到 `/dev/null`。比如,`find` 命令常常会输出很多具体信息,而且在搜索文件遇到权限冲突时,会事无巨细地报告: + +``` +$ find ~ -type f +/home/seth/actual.file +find: `/home/seth/foggy': Permission denied +find: `/home/seth/groggy': Permission denied +find: `/home/seth/soggy': Permission denied +/home/seth/zzz.file +``` + +`find` 命令把那些当作错误,所以你可以只把错误信息重定向至 `/dev/null`: + + +``` +$ find ~ -type f 2>; /dev/null +/home/seth/actual.file +/home/seth/zzz.file +``` + +### 使用重定向 + +在 Bash 中,重定向是转移数据的有效方法。你可能不会频繁使用重定向,但是学会如何使用它,能帮你在打开文件、复制粘贴数据这类需要移动鼠标、大量按键操作上,节省很多不必要的时间。不要做如此浪费时间的事情。使用重定向,好好享受生活。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/6/redirection-bash + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[nophDog](https://github.com/nophDog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop.png?itok=pGfEfu2S (Hands programming) +[2]: https://opensource.com/resources/what-bash +[3]: https://opensource.com/article/19/9/getting-started-zsh +[4]: https://opensource.com/article/19/7/master-ls-command +[5]: https://opensource.com/article/19/8/linux-permissions-101 diff --git a/published/202007/20200701 13 Things To Do After Installing Linux Mint 20.md b/published/202007/20200701 13 Things To Do After Installing Linux Mint 20.md new file mode 100644 index 0000000000..eda69868ad --- /dev/null +++ b/published/202007/20200701 13 Things To Do After Installing Linux Mint 20.md @@ -0,0 +1,215 @@ +[#]: collector: (lujun9972) +[#]: translator: (robsean) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12404-1.html) +[#]: subject: (13 Things To Do After Installing Linux Mint 20) +[#]: via: (https://itsfoss.com/things-to-do-after-installing-linux-mint-20/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +安装 Linux Mint 20 后需要做的 13 件事 +====== + +![](https://img.linux.net.cn/data/attachment/album/202007/11/113643ich99s7y7kw7ckw9.jpg) + +Linux Mint 毫无疑问是 [最佳 Linux 发行版][1] 之一,特别是考虑到 [Linux Mint 20][2] 的功能,我确信你也会同意这一说法。 + +假设你错过了我们的新闻报道,[Linux Mint 20 终于可以下载了][3]。 + +当然,如果你使用 Linux Mint 有一段时间了,你可能知道最好做一些什么。但是,对于新用户来说,在安装 Linux Mint 20 后,你需要做一些事,让你的体验更比以往任何时候都好。 + +### 在安装 Linux Mint 20 后建议做的事 + +在这篇文章中,我将列出其中一些要做的事来帮助你改善 Linux Mint 20 的用户体验。 + +#### 1、执行一次系统更新 + +![][4] + +安装后首先应该马上检查的是 —— 使用更新管理器进行系统更新,如上图所示。 + +为什么?因为你需要构建可用软件的本地缓存。更新所有软件包的更新也是一个好主意。 + +如果你喜欢使用终端,只需输入下面的命令来执行系统更新: + +``` +sudo apt update && sudo apt upgrade -y +``` + +#### 2、使用 Timeshift 来创建系统快照 + +![][5] + +如果你想在意外更改或错误更新后快速地恢复系统状态,有一个系统快照总是很有用的。 + +因此,如果你希望能够随时备份你的系统状态,那么使用 Timeshift 配置和创建系统快照是超级重要的。 + +如果你还不知道如何使用它的话,你可以遵循我们 [使用 Timeshift][6] 的详细指南。 + +#### 3、安装有用的软件 + +尽管在 Linux Mint 20 中已经安装有一些有用的预安装应用程序,你可能需要安装一些没有随之一起出炉的必不可少的应用程序。 + +你可以简单地使用软件包管理器或 synaptic 软件包管理器来查找和安装所需要的软件。 + +对于初学者来说,如果你想探索各种各样的工具,那么你可以遵循我们的 [必不可少的 Linux 应用程序][7] 的列表。 + +也参见: + +- [75 个最常用的 Linux 应用程序(2018 年)](https://linux.cn/article-10099-1.html) +- 100 个最佳 Ubuntu 应用([上](https://linux.cn/article-11044-1.html)、[中](https://linux.cn/article-11048-1.html)、[下](https://linux.cn/article-11057-1.html)) + +这里是一个我最喜欢的软件包列表,我希望你也来尝试一下: + + * [VLC 多媒体播放器][8] 用于视频播放 + * [FreeFileSync][9] 用来同步文件 + * [Flameshot][10] 用于截图 + * [Stacer][11] 用来优化和监控系统 + * [ActivityWatch][12] 用来跟踪你的屏幕时间并保持高效唤醒 + +#### 4、自定义主题和图标 + +![][13] + +当然,这在技术上不是必不可少的事,除非你想更改 Linux Mint 20 的外观和感觉。 + +但是,[在 Linux Mint 中更改主题和图标是非常容易的][14] ,而不需要安装任何额外的东西。 + +你会在欢迎屏幕中获得优化外观的选项。或者,你只需要进入 “主题”,并开始自定义主题。 + +![][15] + +为此,你可以搜索它或在系统设置中如上图所示找到它。 + +根据你正在使用的桌面环境,你也可以看看可用的 [最佳图标主题][16]。 + +#### 5、启用 Redshift 来保护你的眼睛 + +![][17] + +你可以在 Linux Mint 上搜索 “[Redshift][18]”,并启用它以在晚上保护你的眼睛。如你在上面的截图所见,它将根据时间自动地调整屏幕的色温。 + +你可能想启用自动启动选项,以便它在你重新启动计算机时自动启动。它可能与 [Ubuntu 20.04 LTS][19] 的夜光功能不太一样,但是如果你不需要自定义时间表或微调色温的能力,那么它就足够好了。 + +#### 6、启用 snap(如果需要的话) + +尽管 Ubuntu 比前所未有的更倾向于推崇使用 Snap,但是 Linux Mint 团队却反对使用它。因此,它禁止 APT 使用 snapd。 + +因此,你将无法获得 snap 开箱即用的支持。然而,你迟早会意识到一些软件包只以 Snap 的格式打包。在这种情况下,你将不得不在 Mint 上启用对 snap 的支持。 + +``` +sudo apt install snapd +``` + +在你完成后,你可以遵循我们的指南来了解更多关于 [在 Linux 上安装和使用 snap][20] 的信息。 + +#### 7、学习使用 Flatpak + +默认情况下,Linux Mint 带有对 Flatpak 的支持。所以,不管你是讨厌使用 snap 或只是更喜欢使用 Flatpak,在系统中保留它是个好主意。 + +现在,你只需要遵循我们关于 [在 Linux 上使用 Flatpak][21] 的指南来开始吧! + +#### 8、清理或优化你的系统 + +优化或清理系统总是好的,以避免不必要的垃圾文件占用存储空间。 + +你可以通过在终端机上输入以下内容,快速删除系统中不需要的软件包: + +``` +sudo apt autoremove +``` + +除此之外,你也可以遵循我们 [在 Linux Mint 上释放空间的一些建议][22] 。 + +#### 9、使用 Warpinator 通过网络发送/接收文件 + +Warpinator 是 Linux Mint 20 的一个新功能,可以让你在连接到网络的多台电脑上共享文件。这里是它看起来的样子: + +![][23] + +你只需要在菜单中搜索它就可以开始了! + +#### 10、使用驱动程序管理器 + +![驱动器管理器][24] + +如果你正在使用需要驱动程序的 Wi-Fi 设备、NVIDIA 显卡或 AMD 显卡,以及其它设备(如果适用的话)时,驱动程序管理器是一个重要的部分。 + +你只需要找到驱动程序管理器并启用它。它应该可以检测到正在使用的任何专有驱动程序,或者你也可以使用驱动程序管理器来利用 DVD 来安装驱动程序。 + +#### 11、设置防火墙 + +![][25] + +在大多数情况下,你可能已经保护了你的家庭网络。但是,如果你想在 Linux Mint 上有一些特殊的防火墙设置,你可以通过在菜单中搜索 “Firewall” 来实现。 + +正如你在上述截图中所看到的,你可以为家庭、企业和公共设置不同的配置文件。你只需要添加规则,并定义什么是允许访问互联网的,什么是不允许的。 + +你可以阅读我们关于 [使用 UFW 配置防火墙][26] 的详细指南。 + +#### 12、学习管理启动应用程序 + +如果你是一个有经验的用户,你可能已经知道这一点了。但是,新用户经常忘记管理他们的启动应用程序,最终影响了系统启动时间。 + +你只需要从菜单中搜索 “Startup Applications” ,你可以启动它来查找像这样的东西: + +![][27] + +你可以简单地切换你想要禁用的那些启动应用程序,添加一个延迟计时器,或从启动应用程序的列表中完全地移除它。 + +#### 13、安装必不可少的游戏应用程序 + +当然,如果你对游戏感兴趣,你可能想去阅读我们关于 [在 Linux 上的游戏][28] 的文章来探索所有的选择。 + +但是,对于初学者来说,你可以尝试安装 [GameHub][29]、[Steam][30] 和 [Lutris][31] 来玩一些游戏。 + +### 总结 + +就是这样,各位!在大多数情况下,如果你在安装 Linux Mint 20 后按照上面的要点进行操作,使其发挥出最好的效果,应该就可以了。 + +我确信你还能够做更多的事。我想知道你喜欢在安装 Linux Mint 20 后马上做了什么。在下面的评论中告诉我你的想法吧! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/things-to-do-after-installing-linux-mint-20/ + +作者:[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://itsfoss.com/best-linux-distributions/ +[2]: https://linux.cn/article-12297-1.html +[3]: https://linux.cn/article-12376-1.html +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-mint-20-system-update.png?ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/07/snapshot-linux-mint-timeshift.jpeg?ssl=1 +[6]: https://linux.cn/article-11619-1.html +[7]: https://linux.cn/article-10165-1.html +[8]: https://www.videolan.org/vlc/ +[9]: https://itsfoss.com/freefilesync/ +[10]: https://itsfoss.com/flameshot/ +[11]: https://itsfoss.com/optimize-ubuntu-stacer/ +[12]: https://itsfoss.com/activitywatch/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-mint-20-theme.png?ssl=1 +[14]: https://itsfoss.com/install-icon-linux-mint/ +[15]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-mint-20-system-settings.png?ssl=1 +[16]: https://itsfoss.com/best-icon-themes-ubuntu-16-04/ +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-mint-20-redshift-1.png?ssl=1 +[18]: https://itsfoss.com/install-redshift-linux-mint/ +[19]: https://itsfoss.com/ubuntu-20-04-release-features/ +[20]: https://itsfoss.com/install-snap-linux/ +[21]: https://itsfoss.com/flatpak-guide/ +[22]: https://itsfoss.com/free-up-space-ubuntu-linux/ +[23]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/mint-20-warpinator-1.png?ssl=1 +[24]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2013/12/Additional-Driver-Linux-Mint-16.png?ssl=1 +[25]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-mint-20-firewall.png?ssl=1 +[26]: https://itsfoss.com/set-up-firewall-gufw/ +[27]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/06/linux-mint-20-startup-applications.png?ssl=1 +[28]: https://itsfoss.com/linux-gaming-guide/ +[29]: https://itsfoss.com/gamehub/ +[30]: https://store.steampowered.com +[31]: https://lutris.net diff --git a/published/202007/20200701 Back up your phone-s storage with this Linux utility.md b/published/202007/20200701 Back up your phone-s storage with this Linux utility.md new file mode 100644 index 0000000000..c7c9c67789 --- /dev/null +++ b/published/202007/20200701 Back up your phone-s storage with this Linux utility.md @@ -0,0 +1,214 @@ +[#]: collector: (lujun9972) +[#]: translator: (summer2233) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12415-1.html) +[#]: subject: (Back up your phone's storage with this Linux utility) +[#]: via: (https://opensource.com/article/20/7/gphoto2-linux) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +使用 Linux 实用程序 gPhoto2 备份手机存储 +====== + +> 尽情地拍照吧,gphoto2 能够方便、快速地将照片从你的设备传输到 Linux 计算机上。 + +![](https://img.linux.net.cn/data/attachment/album/202007/14/170729pzljppapojy44ro4.jpg) + +移动设备的最大缺点之一就是其将数据从设备传输到计算机很困难。移动设备在这一缺点上有着悠久的历史。早期的移动设备,如 Pilot 和掌上电脑 PDA 设备,需要使用特殊的同步软件来传输数据(你必须小心翼翼地做这件事,因为你的设备可能会因为电池耗尽而导致数据永久丢失);旧版 iPod 只提供特定平台的界面。现代移动设备默认将你的数据发送到在线帐户,以便你可以在计算机上再次下载。 + +好消息——如果你正在运行 Linux,你可以使用 `gphoto2` 命令与移动设备进行连接。`gphoto2` 最初是作为一种与数码相机通信的方式而开发的,那时的数码相机只有传统的相机功能,现在的 `gphoto2` 可以和许多不同种类的移动设备通讯。别让这个名字骗了你,它可以处理所有类型的文件,而不仅仅是照片。更棒的是,它可以编写脚本、很灵活、并且比大多数 GUI 界面功能强大得多。 + +如果你曾经为在计算机和移动设备之间同步数据而苦恼,请了解一下 `gphoto2`。 + +### 安装 gPhoto2 + +很可能你的 Linux 系统已经安装了 libgphoto2,因为它是与移动设备连接的一个关键库,但你可能还需要安装命令 `gphoto2`,该命令可能在你的存储库中。 + +在 Fedora 或 RHEL 上: + +``` +$ sudo dnf install gphoto2 +``` + +在 Debian 或 Ubuntu 上: + +``` +$ sudo apt install gphoto2 +``` + +### 验证兼容性 + +若要确认你的移动设备是否受支持,请使用 `--list-cameras`,通过管道传输到 `less`: + +``` +$ gPhoto2 --list-cameras | less +``` + +或者你可以通过管道把它传送到 `grep` 来搜索一个词。例如,如果你有三星 Galaxy,则使用 `grep`,并通过选项 `-i` 关闭区分大小写: + +``` +$ gphoto2 --list-cameras | grep -i galaxy +  "Samsung Galaxy models (MTP)" +  "Samsung Galaxy models (MTP+ADB)" +  "Samsung Galaxy models Kies mode" +``` + +这证实了三星 Galaxy 设备支持通过 MTP 连接和通过 ADB 连接 MTP。 + +如果你没有在列表中找到自己的移动设备,你仍然可以尝试使用 `gphoto2`,可能你的设备在列表中使用了不同的称呼。 + +### 查找移动设备 + +要使用 gPhoto2,首先必须将移动设备插入计算机,设置为 MTP 模式,并且授予计算机与它交互的权限。这通常需要在你的移动设备上操作,往往是在屏幕上按下一个按钮,以允许其文件系统被刚刚连接的计算机访问。 + +![Screenshot of allow access message][2] + +如果你不授权电脑访问移动设备,那么 gPhoto2 可以检测到你的移动设备,但它不能与之交互。 + +要确保计算机检测到你连接的移动设备,请使用 `--auto-detect` 选项: + +``` +$ gphoto2 --auto-detect +Model                       Port +--------------------------------------- +Samsung Galaxy models (MTP) usb:002,010 +``` + +如果你的移动设备没有被检测到,请先检查数据线,然后检查你的设备是否配置为通过 MTP、ADB 或其它 gPhoto2 支持的协议连接,如 `--list-cameras` 所示。 + +### 查询你的设备支持的特性 + +对于现代设备,通常有过多的潜在功能,但并非所有移动设备都支持这些功能。你可以用 `--abilities` 选项来确定自己的移动设备支持哪些功能。我觉得结果看起来直观。 + +``` +$ gphoto2 --abilities +Abilities for camera            : Samsung Galaxy models (MTP) +Serial port support             : no +USB support                     : yes +Capture choices                 : Capture not supported by driver +Configuration support           : no +Delete selected files on camera : yes +Delete all files on camera      : no +File preview (thumbnail) support: no +File upload support             : yes +``` + +如果只连接一个设备,那么不需要指定查询的设备。但是,如果连接了多个 gPhoto2 可以与之交互的设备,则可以通过端口、相机型号或 usbid 指定设备。 + +### 与你的移动设备交互 + +如果你的设备支持拍摄功能,则可以从计算机调用你的摄像头来获取媒体。例如,要拍摄照片: + +``` +$ gphoto2 --capture-image +``` + +要拍摄照片并立即将其传输到连接的计算机: + +``` +$ gphoto2 --capture-image-and-download +``` + +你也可以录制视频和声音。如果连接了多个拍摄设备,可以按端口、相机型号或 usbid 指定要使用的设备: + +``` +$ gphoto2 --camera "Samsung Galaxy models (MTP)" \ +--capture-image-and-download +``` + +### 文件和文件夹 + +要想更加智能地管理移动设备上的文件,你需要了解 gPhoto2 连接的文件系统的结构。 + +你可以使用 `--get-folders` 选项查看可用文件夹: + +``` +$ gphoto2 --list-folders +There are 2 folders in folder '/'.                                             + - store_00010001 + - store_00020002 +There are 0 folders in folder '/store_00010001'. +There are 0 folders in folder '/store_00020002'. +``` + +每个文件夹代表设备上的一个存储单元。在本例中,`store_00010001` 是内部存储器,`store_00020002` 是 SD 卡,这可能与你的设备的结构不同。 + +### 获取文件 + +现在你知道了设备的文件夹布局,就可以从设备获取照片了。你可以使用许多不同的选项,具体取决于你想从设备中获取什么。 + +如果你知道绝对路径,则可以获取指定的文件: + +``` +$ gphoto2 --get-file IMG_0001.jpg --folder /store_00010001/myphotos +``` + +你可以同时获得所有的文件: + +``` +$ gphoto2 --get-all-files --folder /store_00010001/myfiles +``` + +你可以只获取音频文件: + +``` +gphoto2 --get-all-audio-data --folder /store_00010001/mysounds +``` + +gPhoto2 还有其他的选择,其中大多数取决于你连接的设备和使用协议是否支持。 + +### 上传文件 + +现在你知道了潜在的目标文件夹,就可以将文件从计算机上传到你的设备。例如,假设有一个名为 `example.epub` 的文件在当前目录中,你可以使用 `--upload-file` 选项和 `--folder` 选项将文件发送到设备并指定要上传到的目录: + +``` +$ gphoto2 --upload file example.epub \ +--folder store_00010001 +``` + +如果你希望将多个文件上传到同一个位置,你可以在设备上创建一个目录: + + +``` +$ gphoto2 --mkdir books \ +--folder store_00010001 +$ gphoto2 --upload-file *.epub \ +--folder store_00010001/books +``` + +### 列出文件 + +若要查看设备上的文件,请使用 `--list-files` 选项: + +``` +$ gphoto2 --list-files --folder /store_00010001 +There is 1 file in folder '/store_00010001' +#1     example.epub 17713 KB application/x-unknown +$ gphoto2 --list-files --folder /store_00010001/books +There is 1 file in folder '/store_00010001' +#1    example0.epub 17713 KB application/x-unknown +#2    example1.epub 12264 KB application/x-unknown +[...] +``` + +### 探索你的使用方式 + +gPhoto2 的大部分功能取决于你的设备,因此不同用户的体验可能不尽相同。在 `gphoto2 --help` 中列出了许多操作供你探索。使用gPhoto2,再也不用费劲把文件从你的设备传输到电脑上了! + +这些开源图片库能够帮助你组织文件,并让的图片看起来很棒。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/gphoto2-linux + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[summer2233](https://github.com/summer2233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_mobile_phone.png?itok=RqVtvxkd (A person looking at a phone) +[2]: https://opensource.com/sites/default/files/uploads/gphoto2-mtp-allow.jpg (Screenshot of allow access message) diff --git a/published/202007/20200701 Customizing Bash.md b/published/202007/20200701 Customizing Bash.md new file mode 100755 index 0000000000..547ae50180 --- /dev/null +++ b/published/202007/20200701 Customizing Bash.md @@ -0,0 +1,277 @@ +[#]: collector: (lujun9972) +[#]: translator: (nophDog) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12429-1.html) +[#]: subject: (Customizing Bash) +[#]: via: (https://fedoramagazine.org/customizing-bash/) +[#]: author: (Stephen Snow https://fedoramagazine.org/author/jakfrost/) + +深入了解定制 Bash +====== + +![](https://img.linux.net.cn/data/attachment/album/202007/19/110018bl392bj3g3g41a23.jpg) + +操作系统的最外层 —— 也就是跟你直接打交道的 —— 叫做 [shell][2](“外壳”)。Fedora 预装了好几种不同的 shell。shell 可以是图形界面,或者字符界面。在文档中,你常常能见到两个母缩写词 GUI (图形用户界面Graphical User Interface)跟 CLI(命令行界面Command-Line Interface),它们用来区分图形和基于字符的 shell/界面。[GNOME][5] 和 [Bash][6] 分别是 Fedora 默认的图形和命令行界面,不过你也可以使用其它 [GUI][3] 或者 [CLI][4] shell。 + +接下来在这篇文章中,我们会讨论一些比较推荐的 Bash 字符界面的点文件配置。 + +### Bash 概览 + +Bash 参考手册中写道: + +> 根本上来说,shell 只是一个能执行命令的宏处理器。宏处理器这个词意味着通过扩展文本跟符号,从而构成更复杂的表达式。 +> +> **Bash 参考手册** +> **第五版,Bash 5.0** +> **2019 年 5 月** + +除了能使用其它程序之外,Bash shell 还含有一些内置命令和关键字。Bash 内置功能很强大,甚至能够作为一门 [高级语言][7] 独当一面。Bash 的几个关键字和操作符类似于 [C 语言][8]。 + +Bash 能够以交互式或非交互式模式启动。Bash 的交互模式是一个很多人都熟悉的典型的终端/命令行界面。[GNOME 终端][9] 默认以交互模式打开 Bash。Bash 在非交互模式下运行的例子是,当命令和数据从文件或 shell 脚本通过 [管道][10] 传送到 Bash 时。其它 Bash 可以运行的模式包括:登录login非登录non-login远程remote、POSIX、Unix sh、受限restricted,以及使用与用户不同的 UID/GID 模式。各种模式是可以相互组合的。比如,交互式 + 受限 + POSIX 或者非交互式 + 非登录 + 远程。不同的启动模式,决定着 Bash 所读取的启动文件。理解这些操作模式,有助于帮助我们修改启动文件。 + +根据 Bash 参考手册,它会: + +> 1. 从文件中...、从作为 `-c` 调用选项传入参数的字符...,或者从用户的终端中读取输入。 +> 2. 将输入分解成单词和操作符,遵循 [它的] 引用规则。...这些标记使用元字符隔开。这一步执行别名展开。 +> 3. 将标记解析成简单与复合命令。 +> 4. 执行各种 shell 展开...,将展开之后的标记分解成文件名...以及命令和参数的列表。 +> 5. 执行必要的重定向...并从参数列表中去除重定向操作符及其操作数。 +> 6. 执行命令。 +> 7. 必要时等待命令完成,并收集退出状态。 +> +> **Bash 参考文档** +> **第五版,Bash 版本 5.0** +> **2019 年 5 月** + +当用户开启终端模拟器进入命令行环境时,便启动了一次交互式 shell 会话。GNOME 终端默认以非登录模式为用户打开 Shell。你可以在 “编辑 → 首选项 → 配置文件 → 命令Edit → Preferences → Profilles → Command” 中配置 GNOME 终端以何种模式(登录与非登录式)启动。也可以在 Bash 启动时通过向其传递 `-login` 标志来要求进入登录模式。要注意一点,Bash 的登录模式与非交互模式并不互斥。可以让 Bash 同时以登录模式和非交互模式运行。 + +### 启动 Bash + +除非传入 `-noprofile` 选项,否则登录模式的 Bash shell 会默认读取并执行某些初始化文件中命令。如果 `/etc/profile` 存在,它会是第一个被执行的文件,紧接着是按 `~/.bash_profile`、`~/.bash_login` 或 `~/.profile` 顺序找到的第一个文件。当用户退出登录模式的 shell 时,或者有脚本在非交互式登录模式的 shell 中调用了内置 `exit` 命令,Bash 会读取并执行 `~/.bash_logout` 中的命令,如果 `/etc/bash_logout` 存在的话,会紧接着执行它。通常来说,`/etc/profile` 会援引source `/etc/bashrc` 文件,读取并执行其中的命令,然后查找并读取执行 `/etc/profile.d` 目录中以 `.sh` 结尾的文件。同样的,`~/.bash_profile` 通常也会援引source `~/.bashrc` 文件。`/etc/bashrc` 和 `~/.bashrc` 都会进行检查,避免重复援引source。 + +(LCTT 译注:在 Bash 中,脚本会通过 `source` 或 `.` 命令来将另外一个脚本引入其中,这个行为称之为 “source”、“sourcing”,但是该行为一直没有公认且常用的翻译方法。经过多番斟酌,我认为可以译做“援引”,理由如下:1、“援引”具有“引用、引入”的意思,符合该行为;2、“援”这个词的发音和“source” 常见的汉语意思“源”同音,便于记忆。以上是我们的愚见,供大家参考讨论。—— 老王,2020/7/19) + +一个交互式的 shell,如果不是登录 shell,那么当它第一次被调用的时候,会执行 `~/.bashrc` 文件。这是用户在 Fedora 上打开终端时通常会进入的 shell 类型。当 Bash 以非交互模式启动 —— 就像运行脚本时那样 —— 它会寻找 `BASH_ENV` 环境变量。如果找到了,就会展开它的值作为文件名,接着读取并执行该文件。效果跟执行以下命令相同: + +``` +if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi +``` + +值得注意的是,不会使用 `PATH` 环境变量的值来搜索该文件名(LCTT 译注:意即不会检索搜索路径)。 + +### 重要的用户点文件 + +Bash 最广为人知的用户点文件是 `~/.bashrc`。通过编辑该文件,可以设置大多数个性化选项。由于我们常常需要设置一些选项,会改动上面提及甚至没有提及的文件,所以大部分自定义选项会成为一个麻烦事。Bash 环境具有很高的可定制性,正是为了适应不同用户的不同需求。 + +![][11] + +当登录 shell 正常退出时,如果 `~/.bash_logout` 和 `/etc/bash_logout` 存在,它们会被调用。下一幅图展示了 Bash 作为交互式 shell 启动时的过程。例如,当用户从桌面环境打开终端模拟器时,会按照以下顺序进行。 + +![][12] + +我们已经知道,在不同的启动模式下,Bash 会执行不同的命令,所以很明显,只有几种最需要关注的典型启动模式。分别是非交互、交互式登录 shell,和非交互式、交互式非登录 shell。如果想定义某些全局环境,那么需要将一个具有唯一名称、以 `.sh` 为后缀的文件(例如 `custom.sh`)放置在 `/etc/profile.d` 目录。 + +对于非交互式非登录启动方式,需要特别注意。在这种模式下,Bash 会检查 `BASH_ENV` 变量。如果定义了该变量,Bash 会援引它所指向的文件。另外,处理 `BASH_ENV` 时并不会使用 `PATH` 变量所存储的值(LCTT 译注:意即不会检索搜索路径),所以它必须包含执行文件的绝对路径。比如说,如果有人希望非交互式执行脚本时,shell 能读取 `~/.bashrc` 文件中的设置,那么他可以把类似下面这样的内容放在一个名为 `/etc/profile.d/custom.sh` 的文件中... + +``` +# custom.sh +. +. +. +# 如果使用 Fedora Workstation +BASH_ENV="/home/username/.bashrc" +. +. +. +# 如果使用 Fedora Silverblue Workstation +BASH_ENV="/var/home/username/.bashrc" + +export BASH_ENV +``` + +上面这份脚本会让每个 shell 脚本在运行之前先执行该用户的 `~/.bashrc`。 + +用户一般都会自定义他们的系统环境,以便契合他们自己的工作习惯与偏好。举例来说,用户可以通过别名来实现这种程度的自定义。拥有相同起始参数、需要频繁使用的命令是制作别名的最佳选择。以下展示了一些来自 `~/.bashrc` 文件中定义的别名。 + +``` +# .bashrc +# 执行全局文件 +if [ -f /etc/bashrc ]; + then . /etc/bashrc +fi +. +. +. +# 用户别名和函数 +alias ls='ls -hF --color=auto' +alias la='ls -ahF --color=auto' + +# 让 dir 命令用起来像在 Windows 那样 +alias dir='ls --color=auto --format=long' + +# 用颜色高亮 grep 结果 +alias grep='grep --color=auto' +``` + +在系统中,别名是一种自定义各种命令的方法。它能减少击键次数,而且让命令用起来更方便。针对用户级别的别名通常存放在该用户的 `~/.bashrc` 文件中。 + +如果你发现自己经常要去历史中查找曾经执行过的某条命令,那可能需要改改历史设置了。你依然可以在 `~/.bashrc` 文件中设置针对用户级别的历史选项。比如说,如习惯同时使用多个终端,那你可能要启用 `histappend` 选项。某些 Bash 相关的 shell 选项本质上是布尔值(接收 `on` 或 `off`),通常可以用内置命令 `shopt` 启用或禁用。接收更复杂的值的 Bash 选项(如 `HISTTIMEFORMAT`),常常通过赋值给环境变量来达到配置目的。以下演示如何以 shell 选项和环境变量定制 Bash。 + +``` +# 配置 Bash 历史 + +# 用制表符扩展目录环境变量,并设置 histappend +shopt -s direxpand histappend + +# ignoreboth 等同于 ignorespace 和 ignoredup +HISTCONTROL='ignoreboth' + +# 控制 `history` 输出中的时间格式 +HISTTIMEFORMAT="[%F %T] " + +# 无限历史记录 +# NB:在新版 Bash 中,任何 < 0 的写法都有效,但是在 CentOS/RHEL 中,只有这样才行得通 +HISTSIZE= +HISTFILESIZE= + +# 或者对于使用新版 Bash 的人 +HISTSIZE=-1 +HISTFILESIZE=-1 +``` + +上面例子中的 `direxpand` 选项,可以让 Bash 在文件名补全时,用单词展开结果替换目录名。它会改变 readline 编辑缓冲区的内容,所以你所输入的东西已经被补全得到的结果替换了。 + +`HISTCONTROL` 变量用于启用或禁用命令历史的某些过滤选项。重复行、以空白打头的行,都能通过该选项将它们从命令历史中过滤掉。引用自 Dusty Mabe,这是我从他那儿得到的技巧: + +> `ignoredup` 可以让历史不记录重复条目(如果你反复执行同一条命令)。`ignorespace` 会忽略前面有空白的条目,当你在设置一个包含敏感信息的环境变量或者执行一条不想被记录进磁盘的命令时,这就很有用。`ignoreboth` 相当于这两条选项的结合体。 +> +> **Dusty Mabe – Redhat 首席软件工程师,2020.6.19** + +对于命令行重度用户,Bash 有一个 `CDPATH` 环境变量。如果 `CDPATH` 包含一系列供 `cd` 命令搜索的目录,且提供一个相对路径作为第一个参数,那么它会按顺序检查所有列出的目录,寻找匹配的子目录并切换到第一个匹配结果目录。 + +``` +# .bash_profile + +# 设置 CDPATH +CDPATH="/var/home/username/favdir1:/var/home/username/favdir2:/var/home/username/favdir3" + +# 也可以写成这样 +CDPATH="/:~:/var:~/favdir1:~/favdir2:~/favdir3" + +export CDPATH +``` + +`CDPATH` 通常像 `PATH` 一样的方式进行更新 —— 通过在赋值右侧引用自身来保留原来的值。 + +``` +# .bash_profile + +# 设置 CDPATH +CDPATH="/var/home/username/favdir1:/var/home/username/favdir2:/var/home/username/favdir3" + +# 或者写成这样 +CDPATH="/:~:/var:~/favdir1:~/favdir2:~/favdir3" + +CDPATH="$CDPATH:~/favdir4:~/favdir5" + +export CDPATH +``` + +`PATH` 是另一个极其重要的变量。它是系统上的命令的搜索路径。注意,有些应用要求将它们自己的目录加入 `PATH` 变量,这样才能正常使用。跟 `CDPATH` 一样,通过在赋值右侧引用原值来追加新值到 `PATH` 变量。如果你希望将新值前置,只需要把原来的值(`$PATH`)放到列表末尾即可。还有注意的是在 Fedora,这一列值通过冒号分隔(`:`)。 + +``` +# .bash_profile + +# 添加 PATH 值到 PAHT 环境变量 +PATH="$PATH:~/bin:~:/usr/bin:/bin:~/jdk-13.0.2:~/apache-maven-3.6.3" + +export PATH +``` + +命令提示符是另一个流行的自定义选项。它有七个可定制的参数: + +> - `PROMPT_COMMAND`:如果设置了,会在每一个主提示符(`$PS1`)出现之前执行该值。 +> - `PROMPT_DIRTRIM`:如果设置成大于零的数,则该值用作展开 `\w` 和 `\W` 提示符字符串转义符时保留的尾随目录组件数量。删除的字符将替换为省略号。 +> - `PS0`:这个参数的值像 `PS1` 一样展开,在交互式 shell 读取命令之后、执行命令之前展示。 +> - `PS1`:主提示符字符串。默认值是 `\s-\v\$ `。 +> - `PS2`:次提示符字符串。默认是 `> `。在显示之前,`PS2` 像 `PS1` 那样展开。 +> - `PS3`:这个参数的值用作 `select` 命令的提示符。如果这个变量没有设置,`select` 命令会用 `#? ` 作为提示符。 +> - `PS4`:这个参数的值像 `PS1` 那样展开,如果设置了 `-x` 选项,这个展开值会在命令行被回显之前作为提示符显示。展开后的值的第一个字符在必要时会复制数次,指示间接层数。默认值是 `+ `。 +> +> **Bash 参考文档** +> **第五版,Bash 版本 5.0** +> **2019 年 5 月** + + Bash 的这一个方面就可以用整篇文章来讨论。你可以找到许许多多信息和例子。在本文末尾链接的存储库中提供了一些点文件范例,包括提示符重新配置。你可以随意使用该存储库中的例子进行学习和体验。 + +### 总结 + +既然你已经掌握了一些 Bash 的工作原理,那就可以轻松修改你的 Bash 点文件,满足你自己的需求和习惯。美化你的提示符,制作一些别名,这样你的电脑才真的属于你。查看 `/etc/profile`、`/etc/bashrc` 和 `/etc/profile.d/` 这些文件的内容,获得一些启发。 + +你也可以在这里写一些关于终端模拟器的评论。有很多办法可以将你最喜欢的终端,完全配置成你想要的样子。你或许早就想到了,但是通常可以通过……嗯……用户家目录的点文件实现这个目的。终端模拟器也可以作为登录会话启动,有些人总喜欢用登录环境。你使用终端和电脑的姿势,取决于你如何修改(或不修改)你的点文件。 + +如果你很好奇自己的命令行处于什么会话状态,使用下面这个脚本来判断一下。 + +``` +#!/bin/bash + +case "$-" in + (*i*) echo This shell is interactive ;; + (*) echo This shell is not interactive ;; +esac +``` + +把这几行放到一个文件里,加上可执行权限,然后运行,就能看到你当前处于何种类型的 shell。`$-` 在 Bash 中是一个变量,如果是交互式 shell,它会包含字母 `i`。此外,你可以直接输出 `$-` 变量然后检查它的输出中是否含有 `i` 标记。 + +``` +$ echo $- +``` + +### 参考信息 + +可以参考以下资料以获取更多信息和示例。Bash 手册也是一个很好的信息来源。请注意,确保你的本地手册页记录了你当前运行的 Bash 版本的特性,因为在网上找到的信息有时可能太老(过时了)或太新(你的系统还没有安装)。 + +- +- (在该网站中,你必须要输入一个有效的电子邮箱地址,或者注册,才能下载。) +- + +对本文有各种形式(点文件示例、提示,以及脚本文件)贡献的社区成员: + + * Micah Abbott – 首席质量工程师 + * John Lebon – 首席软件工程师 + * Dusty Mabe – 首席软件工程师 + * Colin Walters – 高级首席软件工程师 + +示例点文件和脚本可以在这个存储库中找到: + +- + +请仔细检查上面所提供的存储库中的信息。有些可能已经过时了。里面还包含很多开发中的自定义脚本和宠物容器pet container配置例子,那些不是点文件。我推荐从 John Lebon 的点文件开始学习,从头到尾都含有完善的解说,它们是我见过的最详细的,并且包含了非常好的描述。祝你学得开心! + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/customizing-bash/ + +作者:[Stephen Snow][a] +选题:[lujun9972][b] +译者:[nophDog](https://github.com/nophDog) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/jakfrost/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/05/bashenvironment-816x346.png +[2]: https://en.wikipedia.org/wiki/Shell_(computing) +[3]: https://fedoramagazine.org/fedoras-gaggle-of-desktops/ +[4]: https://en.wikipedia.org/wiki/Comparison_of_command_shells +[5]: https://en.wikipedia.org/wiki/GNOME +[6]: https://en.wikipedia.org/wiki/Bash_(Unix_shell) +[7]: https://en.wikipedia.org/wiki/High-level_programming_language +[8]: https://en.wikipedia.org/wiki/C_(programming_language) +[9]: https://en.wikipedia.org/wiki/GNOME_Terminal +[10]: https://en.wikipedia.org/wiki/Pipeline_(Unix) +[11]: https://fedoramagazine.org/wp-content/uploads/2020/06/bash-initialization-1-1024x711.png +[12]: https://fedoramagazine.org/wp-content/uploads/2020/06/bash-initialization-2-1024x544.png +[13]: https://en.wikipedia.org/wiki/Boolean_data_type diff --git a/published/202007/20200701 How to install Java on a Mac.md b/published/202007/20200701 How to install Java on a Mac.md new file mode 100644 index 0000000000..0e59880994 --- /dev/null +++ b/published/202007/20200701 How to install Java on a Mac.md @@ -0,0 +1,193 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12393-1.html) +[#]: subject: (How to install Java on a Mac) +[#]: via: (https://opensource.com/article/20/7/install-java-mac) +[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) + +如何在 Mac 上安装 Java +====== + +> macOS 用户可以运行 Java 的开源版本,以及用于云原生cloud native开发的新框架。 + +![](https://img.linux.net.cn/data/attachment/album/202007/08/123211djuaz9io7l9dlpd7.jpg) + +五月底,Java 庆祝了它的 25 周年纪念日,为了纪念这一时刻,世界各地的开发人员使用 [#MovedByJava][3] 这一标签分享他们使用这一编程语言的成就、记忆以及愿景。 + +> 我的时间线: +> +> * 1999 开始学习 Java +> * 2007 创建 [@grailsframework][4] +> * 2008 共同创建 G20ne +> * 2009 被 SpringSource 收购 +> * 2015 加入 [@ObjectComputing][5] +> * 2018 创建 [@micronautfw][6] / 获得 [@groundbreakers][7] 奖 +> * 2019 成为 [@Java_Champions][8] +> +> 感谢你 [@java][9]![#MovedByJava][10] +> +> — Graeme Rocher (@graemerocher) [2020年5月21日][11] + +多年来,许多技术和趋势都促进了 Java 堆栈的开发、部署和在标准应用程序服务器上运行多个应用的能力。为 [Kubernetes][12] 构建容器镜像使得 Java 开发者可以在多个云环境中打包和部署[微服务][13]microservices,而不是在虚拟机上运行几个应用程序服务器。 + +![Timeline of technology contributions to Java][14] + +有了这些技术,Java 应用程序栈被优化为运行更大的堆和可以在运行时做出决策的高动态框架。然而不幸的是,这些努力还不足以使 Java 成为开发人员为无服务器serverless和事件驱动平台开发云原生cloud native Java 应用程序的首选编程语言。其他语言填补了这部分空缺,特别是 JavaScript、Python 和 Go,而 Rust 和 WebAssembly 也成了新的选择。 + +尽管存在这种竞争,[云原生 Java][16]cloud native Java 正在对以云为中心的软件开发产生影响。好在,新的 Java 框架(比如,[Quarkus][17]、[Micronaut][18] 和 [Helidon][19])最近已经战胜了这些挑战,它们提供了编译速度更快而且更小的应用,同时它们在设计之初就将分布式系统考虑了进去。 + +### 如何在 macOS 上安装 Java + +Java 开发的未来将从更多人安装和使用 Java 开始。因此,我将介绍如何在 macOS 上安装并开始使用 Java 开发环境。(如果你运行的是 Linux,请查看 Seth Kenlon 的文章《[如何在 Linux 上安装 Java][20]》) + +#### 通过 Brew 仓库安装 OpenJDK + +Homebrew 是 macOS 事实上的标准软件包管理器。如果你还没有安装的话,Matthew Broberg 的文章《[Homebrew 简介][21]》将带你完成这些步骤。 + +当你在 Mac 上安装好 Homebrew 后,使用 `brew` 命令安装 [OpenJDK][22],这是编写 Java 应用程序的开源方式: + +``` +$ brew cask install java +``` + +不到一分钟就能看到: + +``` +🍺 java was successfully installed! +``` + +通过 `java -version` 命令确认 OpenJDK 已经正确安装: + +``` +$ java -version +openjdk version "14.0.1" 2020-04-14 +OpenJDK Runtime Environment (build 14.0.1+7) +OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing +``` + +从输出中可以确认 OpenJDK 14 (本文撰写时的最新版本)已经安装。 + +#### 从二进制文件安装 OpenJDK + +如果你并不热衷于包管理器,并且更愿意自己来管理 Java 的话,那么你总是可以选择下载并且手动安装。 + +我在 OpenJDK 主页上找到了最新版本的下载链接。下载 OpenJDK 14 的二进制文件: + +``` +$ wget https://download.java.net/java/GA/jdk14.0.1/664493ef4a6946b186ff29eb326336a2/7/GPL/openjdk-14.0.1_osx-x64_bin.tar.gz +``` + +移动到你保存二进制文件的目录,然后解压: + +``` +$ tar -xf openjdk-14.0.1_osx-x64_bin.tar.gz +``` + +接下来,将 Java 加入到你的 PATH: + +``` +$ export PATH=$PWD/jdk-14.0.1.jdk/Contents/Home/bin:$PATH +``` + +同时,将这条命令加到你的点文件中,`.bash_profile` 还是 `.zshrc` 取决于你运行的 shell。你可以在《[如何在 Linux 中设置你的 $PATH 变量][23]》一文中了解更多关于配置 `$PATH` 变量的内容。 + +最后,验证你安装的 OpenJDK 14: + +``` +$ java -version +openjdk version "14.0.1" 2020-04-14 +OpenJDK Runtime Environment (build 14.0.1+7) +OpenJDK 64-Bit Server VM (build 14.0.1+7, mixed mode, sharing) +``` + +### 在 Mac 上编写你的第一个[微服务][13]microservices + +现在,你已经准备好在 maxOS 上使用 OpenJDK 堆栈开发云原生cloud native Java 应用程序了。在本教程中,你将在 [Quarkus][17] 上创建一个新的 Java 项目,这个项目使用依赖注入dependency injection来公布 REST API。 + +你需要 [Maven][24] 启动,它是一个非常流行的 Java 依赖管理器。从 Maven 的网站[安装][25]它,或者通过 Homebrew 使用 `brew install maven` 命令。 + +执行以下 Maven 命令来配置 Quarkus 项目,并且创建一个简单的 web 应用: + +``` +$ mvn io.quarkus:quarkus-maven-plugin:1.5.1.Final:create \ +    -DprojectGroupId=com.example \ +    -DprojectArtifactId=getting-started \ +    -DclassName="com.example.GreetingResource" \ +    -Dpath="/hello" +cd getting-started +``` + +运行这个应用: + +``` +$ ./mvnw quarkus:dev +``` + +当应用程序运行的时候,你可以看到这个输出: + +``` +__  ____  __  _____   ___  __ ____  ______ + --/ __ \/ / / / _ | / _ \/ //_/ / / / __/ + -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \   +\--\\___\\_\\____/_/ |_/_/|_/_/|_|\\____/___/   +2020-06-13 00:03:06,413 INFO  [io.quarkus] (Quarkus Main Thread) getting-started 1.0-SNAPSHOT on JVM (powered by Quarkus 1.5.1.Final) started in 1.125s. Listening on: +2020-06-13 00:03:06,416 INFO  [io.quarkus] (Quarkus Main Thread) Profile dev activated. Live Coding activated. +2020-06-13 00:03:06,416 INFO  [io.quarkus] (Quarkus Main Thread) Installed features: [cdi, resteasy] +``` + +使用 `curl` 命令访问 REST 端点: + +``` +$ curl -w "\n" http://localhost:8080/hello +hello +``` + +恭喜!通过使用 Mavan 和 Quarkus,你很快从没有安装 Java 的环境里创建了第一个 web 应用。 + +### 接下来用 Java 做什么 + +Java 是一个成熟的编程语言,通过专门为云原生cloud native应用程序开发设计的新框架,Java 的热度会一直持续下去。 + +如果你正走在这样构建未来应用的路上,你可能会对更多实用的 Quarkus 开发课程或其他现代化框架感兴趣。无论你在构建什么,下一步是配置你的文本编辑器。阅读我关于《[在 VS Code 用 Quarkus 编写 Java][26]》的教程,然后再看看你能做什么。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/install-java-mac + +作者:[Daniel Oh][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/daniel-oh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o (Coffee and laptop) +[2]: https://opensource.com/resources/java +[3]: https://twitter.com/search?q=%23MovedByJava&src=typed_query +[4]: https://twitter.com/grailsframework?ref_src=twsrc%5Etfw +[5]: https://twitter.com/ObjectComputing?ref_src=twsrc%5Etfw +[6]: https://twitter.com/micronautfw?ref_src=twsrc%5Etfw +[7]: https://twitter.com/groundbreakers?ref_src=twsrc%5Etfw +[8]: https://twitter.com/Java_Champions?ref_src=twsrc%5Etfw +[9]: https://twitter.com/java?ref_src=twsrc%5Etfw +[10]: https://twitter.com/hashtag/MovedByJava?src=hash&ref_src=twsrc%5Etfw +[11]: https://twitter.com/graemerocher/status/1263484918157410304?ref_src=twsrc%5Etfw +[12]: https://opensource.com/resources/what-is-kubernetes +[13]: https://opensource.com/resources/what-are-microservices +[14]: https://opensource.com/sites/default/files/uploads/javatimeline.png (Timeline of technology contributions to Java) +[15]: https://creativecommons.org/licenses/by-sa/4.0/ +[16]: https://opensource.com/article/20/1/cloud-native-java +[17]: https://quarkus.io/ +[18]: https://micronaut.io/ +[19]: https://helidon.io/#/ +[20]: https://linux.cn/article-11614-1.html +[21]: https://linux.cn/article-12338-1.html +[22]: https://openjdk.java.net/ +[23]: https://opensource.com/article/17/6/set-path-linux +[24]: https://maven.apache.org/index.html +[25]: https://maven.apache.org/install.html +[26]: https://opensource.com/article/20/4/java-quarkus-vs-code diff --git a/published/202007/20200702 Customizing my Linux terminal with tmux and Git.md b/published/202007/20200702 Customizing my Linux terminal with tmux and Git.md new file mode 100644 index 0000000000..127da8332b --- /dev/null +++ b/published/202007/20200702 Customizing my Linux terminal with tmux and Git.md @@ -0,0 +1,67 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12450-1.html) +[#]: subject: (Customizing my Linux terminal with tmux and Git) +[#]: via: (https://opensource.com/article/20/7/tmux-git) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +使用 tmux 和 Git 自定义我的 Linux 终端 +====== + +> 设置你的控制台,以便你能知道身处哪个目录和该做什么 + +![](https://img.linux.net.cn/data/attachment/album/202007/25/102841u8u6ns4tp9z8bnha.jpg) + +我使用 GNOME 终端,主要是因为它是我的发行版的默认设置。但是我终端内远非“默认值”。在我开始解释如何自定义它之前,它现在是这个样子: + +![Moshe Zadka's terminal][2] + +### 从底部开始 + +我使用终端多路复用技术 [tmux][4] 管理我的终端体验。 + +在上图的底部,你可以看到我的绿色 tmux 栏。底部的 `[3]` 表示它是第三个终端:每个终端都运行自己的 tmux 会话。(我创建了一个新会话来放大字体,这样可在截图中更容易看到;这是它与其他终端之间的唯一区别。) + +提示符看起来也很有趣,对吧?在提示符中塞入了太多信息后,我喜欢插上一个换行符,这样一来,如果我想即兴进行 shell 编程或编写一个传递了五次的管道,也不会超出屏幕界限。这样做的代价是简单的命令序列(新建、复制、移动)会更快地滚动出我的屏幕。 + +行末是 [阿列夫零][5]Aleph null 字符,它是最小的[无穷基数][6]。我希望内容行的结束很明显,并且当我意识到“阿列夫”和下标 0 都是 Unicode 字符时,我无法抗拒使用“阿列夫零”作为提示符的一部分的诱惑。(数学极客们,团结起来!) + +在此之前是我的用户名。由于我在不同用户名的多台计算机上使用相同的[点文件][7](保存在 Git 中),因此这个还算有用。 + +在我的用户名之前,是我所在目录的最后一部分。完整路径通常太长且无用,而当前目录对于像我这样的经常忘记在做什么人来说是很有用的。在此之前是机器的名称。我所有的机器都以我喜欢的电视节目命名。我的旧笔记本是 `mcgyver`。 + +提示符中的第一位是我最喜欢的:一个让我知道目录的 Git 状态的字母。如果目录为“不在 Git 中”,那么是 `G`。如果目录为“没有问题”(OK),且无需任何操作,那么是 `K`。如果有 Git 未知的文件需要添加或忽略,那么是 `!`。如果需要提交,那么是 `C`。如果没有上游,那么是 `U`。如果存在上游,但我没有推送,那么是 `P`。该方案不是基于当前状态,而是描述了我要做的*下一个动作*。(要回顾 Git 术语,请阅读[本文][8]。) + +终端功能是通过一个有趣的 Python 程序完成的。它运行 `python -m howsit`(在我把 [howsit][9] 安装在虚拟环境中之后)。 + +你可以在上图中看到渲染效果,但是为了完整起见,这是我的 `PS1`: + +``` +[$(~/.virtualenvs/howsit/bin/python -m howsit)]\h:\W \u ℵ₀   +$ +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/tmux-git + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: https://opensource.com/sites/default/files/uploads/terminal-tmux-moshezadka.png (Moshe Zadka's terminal) +[3]: https://creativecommons.org/licenses/by-sa/4.0/ +[4]: https://opensource.com/article/20/1/tmux-console +[5]: https://simple.wikipedia.org/wiki/Aleph_null +[6]: https://gizmodo.com/a-brief-introduction-to-infinity-5809689 +[7]: https://opensource.com/article/19/3/move-your-dotfiles-version-control +[8]: https://opensource.com/article/19/2/git-terminology +[9]: https://pypi.org/project/howsit/ diff --git a/published/202007/20200702 Ex-Solus Dev is Now Creating a Truly Modern Linux Distribution Called Serpent Linux.md b/published/202007/20200702 Ex-Solus Dev is Now Creating a Truly Modern Linux Distribution Called Serpent Linux.md new file mode 100644 index 0000000000..a8c6507f06 --- /dev/null +++ b/published/202007/20200702 Ex-Solus Dev is Now Creating a Truly Modern Linux Distribution Called Serpent Linux.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12401-1.html) +[#]: subject: (Ex-Solus Dev is Now Creating a Truly Modern Linux Distribution Called Serpent Linux) +[#]: via: (https://itsfoss.com/serpent-os-announcement/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Solus Linux 创始人正在开发一个没有 GNU 的“真正现代”的 Linux 发行版 +====== + +曾经创建独立 Linux 发行版 Solus 的开发人员 [Ikey Doherty][1] 宣布了他的新项目:Serpent OS。 + +[Serpent OS][2] 是一个**不想**被归类为“轻量级、用户友好、注重隐私的 Linux 桌面发行版”。 + +相反,Serpent OS 具有“与主流产品不同的目标”。具体怎么样?请继续阅读。 + +### Serpent OS:制作“真正现代”的 Linux 发行版 + +![][3] + +Serpent 采用发行版优先,兼容靠后的方法。这使他们可以做出一些非常大胆的决定。 + +Ikey 表示,这个项目不会对阻碍 Linux 的负面角色容忍。例如,不会容忍 NVIDIA 在其 GPU 上缺乏对 Wayland 加速的支持,并将 NVIDIA 专有驱动加入发行版黑名单。 + +这是 Serpent Linux 项目的拟议计划(摘自[其网站][4]): + + * 不再分割 usrbin + * 100% clang 构建(包括内核) + * musl 作为 libc,依靠编译器优化而不是内联 asm + * 使用 libc++ 而不是 libstdc++ + * LLVM 的 binutils 变体(lld、as 等) + * 混合源代码/二进制分发 + * 从 x86\_64 通用基线转移到更新的 CPU,包括针对 Intel 和 AMD 的优化 + * 包管理器中基于功能的订阅(硬件/用户选择等) + * 只支持 UEFI。不支持老式启动方式 + * 完全开源,包括引导程序/重建脚本 + * 针对高工作负载进行了认真的优化 + * 第三方应用仅依赖于容器。没有兼容性修改 + * 仅支持 Wayland。将调查通过容器的 X11 兼容性 + * 完全无状态的管理工具和上游补丁 + +Ikey 大胆地宣称 Serpent Linux 不是 Serpent GNU/Linux,因为它不再依赖于 GNU 工具链或运行时。 + +Serpent OS 项目的开发将于 7 月底开始。没有确定最终稳定版本的时间表。 + +### 要求过高?但是 Ikey 过去做到了 + +你可能会怀疑 Serpent OS 是否会出现,是否能够兑现其所作的所有承诺。 + +但是 Ikey Doherty 过去已经做到了。如果我没记错的话,他首先基于 Debian 创建了 SolusOS。他于 2013 年停止了基于 [Debian 的 SolusOS][5] 的开发,甚至它还没有进入 Beta 阶段。 + +然后,他从头开始创建 [evolve OS][6],而不是使用其他发行版作为基础。由于某些命名版权问题,项目名称已更改为 Solus(是的,相同的旧名称)。[Ikey 在 2018 年退出了 Solus 项目][7],其他开发人员现在负责该项目。 + +Solus 是一个独立的 Linux 发行版,它为我们提供了漂亮的 Budgie 桌面环境。 + +Ikey 过去做到了(当然,在其他开发人员的帮助下)。他现在也应该能够做到。 + +### 看好还是不看好? + +你如何看待这个 Serpent Linux?你是否认为是时候让开发人员采取大胆的立场,并着眼于未来开发操作系统,而不是坚持过去?请分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/serpent-os-announcement/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ikey-doherty-serpent-interview/ +[2]: https://www.serpentos.com/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/07/serpent-linux.png?ssl=1 +[4]: https://www.serpentos.com/about/ +[5]: https://distrowatch.com/table.php?distribution=solusos +[6]: https://itsfoss.com/beta-evolve-os-released/ +[7]: https://itsfoss.com/ikey-leaves-solus/ diff --git a/published/202007/20200703 openSUSE Leap 15.2 Released With Focus on Containers, AI and Encryption.md b/published/202007/20200703 openSUSE Leap 15.2 Released With Focus on Containers, AI and Encryption.md new file mode 100644 index 0000000000..522ce76e8c --- /dev/null +++ b/published/202007/20200703 openSUSE Leap 15.2 Released With Focus on Containers, AI and Encryption.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12425-1.html) +[#]: subject: (openSUSE Leap 15.2 Released With Focus on Containers, AI and Encryption) +[#]: via: (https://itsfoss.com/opensuse-leap-15-2-release/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +openSUSE Leap 15.2 发布:重点关注容器、AI 和加密 +====== + +![](https://img.linux.net.cn/data/attachment/album/202007/16/230428vklhwrzllll2eu82.jpg) + +[openSUSE][1] Leap 15.2 最终带来了一些有用的变化和改进。 + +同时,我想到 SUSE 这篇让人激动的公告《[消除 Leap 差异][2]》,openSUSE Leap 15.2 的发布使我们下一步将 SLE([SUSE Linux Enterprise][3])二进制文件集成到 openSUSE Leap 15.3 更加近了一步。 + +让我们看一下 openSUSE Leap 15.2 中发生了哪些变化和改进。 + +### openSUSE Leap 15.2:关键变化 + +![][4] + +总体而言,openSUSE Leap 15.2 发行版涉及安全更新、新的主要软件包、bug 修复以及其他改进。 + +该项目的开发人员 Marco Varlese 在新闻稿中提到: + +>“ Leap 15.2 代表了人工智能领域的巨大进步,我很高兴 openSUSE 用户现在终于可以通过我们的仓库使用机器学习/深度学习框架和应用,以享受稳定和最新的生态系统。” + +尽管这暗示了可能涉及的一些变化,以下是 openSUSE Leap 15.2 中的新功能: + +#### 添加人工智能(AI)和机器学习包 + +毫无疑问,人工智能(AI)和机器学习是最具颠覆性的技术。 + +为了向用户提供便利,openSUSE Leap 15.2 为新的开源技术添加了许多重要的软件包: + + * [Tensorflow][5] + * [PyTorch][6] + * [ONNX][7] + * [Grafana][8] + * [Prometheus][9] + +#### 引入实时内核 + +![][10] + +在 openSUSE Leap 15.2 中,将引入实时内核来管理[微处理器][11]的时序,以有效处理时间关键的事件。 + +实时内核的添加对于现实意义重大。项目委员会主席 Gerald Pfeifer 的讲话如下: + +>“将实时内核添加到 openSUSE Leap 开启了新的可能性。想想边缘计算、嵌入式设备、数据抓取,所有这些都在飞速发展。从历史上看,其中很多都是专有领域。现在,openSUSE 为有兴趣测试实时功能的开发者、研究人员和公司甚至贡献者将打开了通道。这是另一个开源帮助开放的领域!” + +#### 纳入容器技术 + +在最新版本中,你会注意到 [Kubernetes][12] 作为官方包而纳入其中。这让用户可以轻松地自动化部署、扩展和管理容器化的应用。 + +[Helm][13](Kubernetes 的包管理器)也是内置的。不仅于此,你还可以在此找到其他一些附加功能,从而可以更轻松地保护和部署容器化应用。 + +#### 更新的 openSUSE 安装程序 + +![][14] + +openSUSE 的安装程序已经非常不错。但是,在最新的 Leap 15.2 版本中,它们添加了更多信息,兼容从右至左语言(如阿拉伯语)以及一些小的更改,从而在安装时更容易选择。 + +#### YaST 改进 + +尽管 [YaST][15] 已经是一个非常强大的安装和配置工具,但是此发行版增加了创建和管理 Btrfs 文件系统以及实施高级加密技术的能力。 + +当然,你肯定知道 [openSUSE 在 WSL][16] 的可用性。因此,根据 Leap 15.2 的发行说明,YaST 与 WSL 的兼容性得到了改善。 + +#### 桌面环境改进 + +![][17] + +可用的桌面环境已更新为最新版本,包括 [KDE Plasma 5.18 LTS][18] 和 [GNOME 3.34][19]。 + +你还能发现更新的 [XFCE 4.14][20] 桌面在 openSUSE Leap 15.2 上也是可用的。 + +如果你想知道最新版本的所有详细信息,可以参考[官方发布公告][21]。 + +### 下载和可用性 + +目前,你可以找到 Leap 15.2 的 Linode 云镜像。另外,你会注意到其他云托管服务(如 AWS、Azure 和其他服务)也提供了它。 + +你还可以从官方网站获取 DVD ISO 或网络镜像文件。 + +要升级你当前的安装,我建议按照[官方说明][22]操作。 + +- [openSUSE Leap 15.2][23] + +你尝试过 openSUSE Leap 15.2 了么?请随时让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/opensuse-leap-15-2-release/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://www.opensuse.org/ +[2]: https://www.suse.com/c/sle-15-sp2-schedule-and-closing-the-opensuse-leap-gap/ +[3]: https://www.suse.com/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/07/opensuse-leap-15-2-gnome.png?ssl=1 +[5]: https://www.tensorflow.org +[6]: https://pytorch.org +[7]: https://onnx.ai +[8]: https://grafana.com +[9]: https://prometheus.io/docs/introduction/overview/ +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/opensuse-leap-15-2-terminal.png?ssl=1 +[11]: https://en.wikipedia.org/wiki/Microprocessor +[12]: https://kubernetes.io +[13]: https://helm.sh +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/07/opensuse-leap-15-2.png?ssl=1 +[15]: https://yast.opensuse.org/ +[16]: https://itsfoss.com/opensuse-bash-on-windows/ +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/07/opensue-leap-15-2-kde.png?ssl=1 +[18]: https://itsfoss.com/kde-plasma-5-18-release/ +[19]: https://itsfoss.com/gnome-3-34-release/ +[20]: https://www.xfce.org/about/news/?post=1565568000 +[21]: https://en.opensuse.org/Release_announcement_15.2 +[22]: https://en.opensuse.org/SDB:System_upgrade +[23]: https://software.opensuse.org/distributions/leap diff --git a/published/202007/20200706 Project OWL- IoT trying to hold connectivity together in disasters.md b/published/202007/20200706 Project OWL- IoT trying to hold connectivity together in disasters.md new file mode 100644 index 0000000000..bd52eec6e3 --- /dev/null +++ b/published/202007/20200706 Project OWL- IoT trying to hold connectivity together in disasters.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12435-1.html) +[#]: subject: (Project OWL: IoT trying to hold connectivity together in disasters) +[#]: via: (https://www.networkworld.com/article/3564980/project-owl-iot-trying-to-hold-connectivity-together-in-disasters.html) +[#]: author: (Jon Gold https://www.networkworld.com/author/Jon-Gold/) + +OWL 项目:物联网正尝试在灾难中让一切保持联络 +====== + +> 当自然灾害破坏了传统的通信连接时,配置在多跳网络mesh network的物联网设备可以迅速部署以提供基本的连接。 + +![](https://img.linux.net.cn/data/attachment/album/202007/21/135614mwr8rxr6lw5xefjs.jpg) + +OWL 项目负责人在最近的开源峰会上说,一个以多跳网络、物联网和 LoRa 连接为中心的开源项目可以帮助急救和受灾人员在自然灾害之后保持联系。 + +OWL 项目的应用场景是当在自然灾害之后频繁发生的通信中断时。无论是蜂窝网络还是有线网络,大范围的中断会频繁阻碍急救服务、供应和在暴风雨或其他重大灾难后必须解决关键问题的信息流。 + +该项目通过一大群“鸭子duck”(便宜、易于部署且不需要现有基础设施支持的小型无线模块)实现这个目的。一些“鸭子”是太阳能的,其它一些则用的是耐用电池。每只“鸭子”配备一个 LoRa 无线电,用于在网络上和其它“鸭子”进行通信,同时还配备有 Wi-Fi,而且可能配备蓝牙和 GPS 来实现其他功能。 + +这个想法是这样的,当网络瘫痪时,用户可以使用他们的智能手机或者笔记本电脑与“鸭子”建立一个 Wi-Fi 连接,这个“鸭子”可以将小块的信息传递到网络的其他部分。信息向网络后端传递,直到到达“鸭子爸爸papaduck”,“鸭子爸爸”装备了可以与云上的 OWL 数据管理系统连接的卫星系统(OWL 代表 ”组织organization位置whereabouts物流logistics”)。信息可以通过云在智能手机或者网页上进行可视化,甚至可以通过 API 插入到现有的系统中。 + +秘密在于“鸭群ClusterDuck” 协议,这是一个开源固件,即使在一些模块不能正常工作的网络中,它仍然能保持信息流通。它就是设计用来工作在大量便宜且容易获取的计算硬件上,类似树莓派的硬件,这样可以更容易且更快捷的建立一个“鸭群”网络。 + +创始人 Bryan Knouse 表示,这个项目的创建,是因为在 2017 年和 2018 年的毁灭性飓风中,要与受影响社区进行有效的通信而采取救援措施,面临着巨大的困难。 + +“我们的一些创始成员经历了这些灾难,然后我们会问‘我们该做些什么?’”,他说道。 + +在马亚圭斯,该项目有一批来自波多黎各大学的学生和教授,大多数的系统测试都在那里进行。Knouse 说,校园中目前有 17 个太阳能“鸭子”,分布在屋顶和树上,并且计划增加数量。 + +他说,“这种关系实际上创建了一个开源社区,这些学生和教授正在帮助我们开发这个项目。” + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3564980/project-owl-iot-trying-to-hold-connectivity-together-in-disasters.html + +作者:[Jon Gold][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Jon-Gold/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/01/owl-face-100785829-large.jpg +[2]: https://creativecommons.org/licenses/by/2.0/legalcode +[3]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html +[4]: https://www.networkworld.com/article/3356838/how-to-determine-if-wi-fi-6-is-right-for-you.html +[5]: https://www.networkworld.com/article/3250268/what-is-mu-mimo-and-why-you-need-it-in-your-wireless-routers.html +[6]: https://www.networkworld.com/article/3402316/when-to-use-5g-when-to-use-wi-fi-6.html +[7]: https://www.networkworld.com/article/3306720/mobile-wireless/how-enterprises-can-prep-for-5g.html +[8]: https://www.networkworld.com/article/3560993/what-is-wi-fi-and-why-is-it-so-important.html +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world diff --git a/published/202007/20200707 What you need to know about hash functions.md b/published/202007/20200707 What you need to know about hash functions.md new file mode 100644 index 0000000000..062179dd21 --- /dev/null +++ b/published/202007/20200707 What you need to know about hash functions.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12408-1.html) +[#]: subject: (What you need to know about hash functions) +[#]: via: (https://opensource.com/article/20/7/hash-functions) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +关于哈希(散列)函数你应该知道的东西 +====== + +> 从输出的哈希值反推回输入,这从计算的角度是不可行的。 + +![](https://img.linux.net.cn/data/attachment/album/202007/12/145709d3ne3vee330oh3lv.jpg) + +无论安全从业人员用计算机做什么,有一种工具对他们每个人都很有用:加密哈希(散列)hash函数。这听起来很神秘、很专业,甚至可能有点乏味,但是, 在这里,关于什么是哈希函数以及它们为什么对你很重要,我会作出一个简洁的解释。 + +加密哈希函数,比如 SHA-256 或者 MD5,接受一组二进制数据(通常是字节)作为输入,并且对每个可能的输入集给出一个希望唯一hopefully unique的输出。对于任意模式的输入,给定的哈希函数的输出(“哈希值”)的长度都是一样的(对于 SHA-256,是 32 字节或者 256 比特,这从名字中就能看出来)。最重要的是:从输出的哈希值反推回输入,这从计算的角度是不可行的implausible(密码学家讨厌 “不可能impossible” 这个词)。这就是为什么它们有时候被称作单向哈希函数one-way hash function。 + +但是哈希函数是用来做什么的呢?为什么“唯一”的属性如此重要? + +### 唯一的输出 + +在描述哈希函数的输出时,“希望唯一hopefully unique”这个短语是至关重要的,因为哈希函数就是用来呈现完全唯一的输出。比如,哈希函数可以用于验证 *你* 下载的文件副本的每一个字节是否和 *我* 下载的文件一样。你下载一个 Linux 的 ISO 文件或者从 Linux 的仓库中下载软件时,你会看到使用这个验证过程。没有了唯一性,这个技术就没用了,至少就通常的目的而言是这样的。 + +如果两个不同的输入产生了相同的输出,那么这样的哈希过程就称作“碰撞collision”。事实上,MD5 算法已经被弃用,因为虽然可能性微乎其微,但它现在可以用市面上的硬件和软件系统找到碰撞。 + +另外一个重要的特性是,消息中的一个微小变化,甚至只是改变一个比特位,都可能会在输出中产生一个明显的变化(这就是“雪崩效应avalanche effect”)。 + +### 验证二进制数据 + +哈希函数的典型用途是当有人给你一段二进制数据,确保这些数据是你所期望的。无论是文本、可执行文件、视频、图像或者一个完整的数据库数据,在计算世界中,所有的数据都可以用二进制的形式进行描述,所以至少可以这么说,哈希是广泛适用的。直接比较二进制数据是非常缓慢的且计算量巨大,但是哈希函数在设计上非常快。给定两个大小为几 M 或者几 G 的文件,你可以事先生成它们的哈希值,然后在需要的时候再进行比较。 + +通常,对哈希值进行签名比对大型数据集本身进行签名更容易。这个特性太重要了,以至于密码学中对哈希值最常见的应用就是生成“数字”签名。 + +由于生成数据的哈希值很容易,所以通常不需要有两套数据。假设你想在你的电脑上运行一个可执行文件。但是在你运行之前,你需要检查这个文件就是你要的文件,没有被黑客篡改。你可以方便快捷的对文件生成哈希值,只要你有一个这个哈希值的副本,你就可以相当肯定这就是你想要的文件。 + +下面是一个简单的例子: + +``` +$ shasum -a256 ~/bin/fop +87227baf4e1e78f6499e4905e8640c1f36720ae5f2bd167de325fd0d4ebc791c  /home/bob/bin/fop +``` + +如果我知道 `fop` 这个可执行文件的 SHA-256 校验和,这是由供应商(这个例子中是 Apache 基金会)提供的: + +``` +87227baf4e1e78f6499e4905e8640c1f36720ae5f2bd167de325fd0d4ebc791c +``` + +然后我就可以确信,我驱动器上的这个可执行文件和 Apache 基金会网站上发布的文件是一模一样的。这就是哈希函数难以发生碰撞(或者至少是 *很难通过计算得到碰撞*)这个性质的重要之处。如果黑客能将真实文件用哈希值相同的文件轻易的进行替换,那么这个验证过程就毫无用处。 + +事实上,这些性质还有更技术性的名称,我上面所描述的将三个重要的属性混在了一起。更准确地说,这些技术名称是: + +1. 抗原像性pre-image resistance:给定一个哈希值,即使知道用了什么哈希函数,也很难得到用于创建它的消息。 +2. 抗次原像性second pre-image resistance:给定一个消息,很难找到另一个消息,使得这个消息可以产生相同的哈希值。 +3. 抗碰撞性collision resistance:很难得到任意两个可以产生相同哈希值的消息。 + +*抗碰撞性* 和 *抗次原像性* 也许听上去是同样的性质,但它们具有细微而显著的不同。*抗次原像性* 说的是如果 *已经* 有了一个消息,你也很难得到另一个与之哈希值相匹配的消息。*抗碰撞性* 使你很难找到两个可以生成相同哈希值的消息,并且要在哈希函数中实现这一性质则更加困难。 + +让我回到黑客试图替换文件(可以通过哈希值进行校验)的场景。现在,要在“外面”使用加密哈希算法(除了使用那些在现实世界中由独角兽公司开发的完全无 Bug 且安全的实现之外),还有一些重要且困难的附加条件需要满足。认真的读者可能已经想到了其中一些,特别需要指出的是: + +1. 你必须确保自己所拥有的哈希值副本也没有被篡改。 +2. 你必须确保执行哈希算法的实体能够正确执行并报告了结果。 +3. 你必须确保对比两个哈希值的实体确实报告了这个对比的正确结果。 + +确保你能满足这些条件绝对不是一件容易的事。这就是可信平台模块Trusted Platform Modules(TPM)成为许多计算系统一部分的原因之一。它们扮演着信任的硬件基础,可以为验证重要二进制数据真实性的加密工具提供保证。TPM 对于现实中的系统来说是有用且重要的工具,我也打算将来写一篇关于 TPM 的文章。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/hash-functions + +作者:[Mike Bursell][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [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/osdc_OpenData_CityNumbers.png?itok=lC03ce76 +[2]: https://aliceevebob.com/2020/06/16/whats-a-hash-function/ diff --git a/published/202007/20200708 How to decipher Linux release info.md b/published/202007/20200708 How to decipher Linux release info.md new file mode 100644 index 0000000000..55a2d68d8c --- /dev/null +++ b/published/202007/20200708 How to decipher Linux release info.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12418-1.html) +[#]: subject: (How to decipher Linux release info) +[#]: via: (https://www.networkworld.com/article/3565432/how-to-decipher-linux-release-info.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何解密 Linux 版本信息 +====== + +> 显示和解释有关 Linux 版本的信息比看起来要复杂一些。 + +![christin hume / Linux / Modified by IDG Comm.][1] + +与引用一个简单的版本号不同,识别 Linux 版本有很多种方法。即使只是快速查看一下 `uname` 命令的输出,也可以告诉你一些信息。这些信息是什么,它告诉你什么? + +在本文中,我们将认真研究 `uname` 命令的输出以及其他一些命令和文件提供的版本说明。 + +### 使用 uname + +每当在 Linux 系统终端窗口中执行命令 `uname -a` 时,都会显示很多信息。那是因为这个小小的 `a` 告诉 `uname` 命令你想查看该命令能提供的*全部*输出。结果显示的内容将告诉你许多有关该系统的各种信息。实际上,显示的每一块信息都会告诉你一些关于系统的不同信息。 + +例如,`uname -a` 输出看起来像这样: + +``` +$ uname -a +Linux dragonfly 5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux +``` + +尽管这可能不太重要,但你可以使用一个按适当的顺序包含 `uname` 所有选项来显示相同的信息: + +``` +$ uname -snmrvpio +Linux dragonfly 5.4.0-37-generic #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux +``` + +要将这一长串信息分解为单独的块,可以使用类似这样的 `for` 循环来遍历每个选项: + +``` +$ for option in s n m r v p i o; do echo -n "$option: "; uname -$option; done +s: Linux +n: dragonfly +m: x86_64 +r: 5.4.0-37-generic +v: #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 +p: x86_64 +i: x86_64 +o: GNU/Linux +``` + +该循环显示了该选项提供了哪些信息。`uname` 手册页提供了每个选项的描述。以下是清单: + +- Linux –- 内核名称(选项 `s`) +- dragonfly –- 节点名(选项 `n`) +- x86_64 –- 机器硬件名(选项 `m`) +- 5.4.0-37-generic –- 内核发布版本(选项 `r`) +- #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 -- 内核版本(选项 `v`) +- x86_64 –- 处理器(选项 `p`) +- x86_64 –- 硬件平台(选项 `i`) +- GNU/Linux –- 操作系统(选项 `o`) + +要更深入地研究显示的信息,请认真查看显示的内核发行数据。第四行中的 `5.4.0-37` 不仅仅是一串任意数字。每个数字都很重要。 + + * `5` 表示内核版本 + * `4` 表示主要版本 + * `0` 表示次要版本 + * `37` 表示最新补丁 + +此外,在上面的循环中输出的第 5 行(内核版本)中的 `#41` 表示此发布版本已编译 41 次。 + +如果你只想显示所有信息中的一项,那么单个选项可能很有用。例如,命令 `uname -n` 可以仅告诉你系统名称,而 `uname -r` 仅可以告诉你内核发布版本。在盘点服务器或构建脚本时,这些和其他选项可能很有用。 + +在 Red Hat 系统时,`uname -a` 命令将提供相同种类的信息。这是一个例子: + +``` +$ uname -a +Linux fruitfly 4.18.0-107.el8.x86_64 #1 SMP Fri Jun 14 13:46:34 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux +``` + +### 发行版信息 + +如果你需要了解运行的发行版是什么,那么 `uname` 的输出不会对你有太大帮助。毕竟,内核版本与发行版不同。关于这个信息,你可以在 Ubuntu 和其他基于 Debian 的系统上使用 `lsb_release -r` 命令,而在 Red Hat 上可以显示 `/etc/redhat-release` 文件的内容。 + +对于 Debian 系统: + +``` +$ lsb_release -r +Release: 20.04 +``` + +对于 Red Hat 及相关系统: + +``` +$ cat /etc/redhat-release +Red Hat Enterprise Linux release 8.1 Beta (Ootpa) +``` + +### 使用 /proc/version + +`/proc/version` 文件还可以提供有关 Linux 版本的信息。该文件中提供的信息与 `uname -a` 输出有很多共同点。以下是例子。 + +在 Ubuntu 上: + +``` +$ cat /proc/version +Linux version 5.4.0-37-generic (buildd@lcy01-amd64-001) (gcc version 9.3.0 (Ubuntu 9.3.0-10ubuntu2)) #41-Ubuntu SMP Wed Jun 3 18:57:02 UTC 2020 +``` + +在 RedHat 上: + +``` +$ cat /proc/version +Linux version 4.18.0-107.el8.x86_64 (mockbuild@x86-vm-09.build.eng.bos.redhat.com) (gcc version 8.3.1 20190507 (Red Hat 8.3.1-4) (GCC)) #1 SMP Fri Jun 14 13:46:34 UTC 2019 +``` + +### 总结 + +Linux 系统提供了很多关于内核和发行版安装的信息。你只需要知道在哪里或如何寻找并理解它的含义。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3565432/how-to-decipher-linux-release-info.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2020/07/linux_woman-with-laptop_keyboard_code_programmer_devops_by-christin-hume-via-unsplash_linux_-100850842-large.jpg +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/202007/20200708 Program IoT systems using Python with this VSCode plugin for RTOS.md b/published/202007/20200708 Program IoT systems using Python with this VSCode plugin for RTOS.md new file mode 100644 index 0000000000..a59350cf87 --- /dev/null +++ b/published/202007/20200708 Program IoT systems using Python with this VSCode plugin for RTOS.md @@ -0,0 +1,153 @@ +[#]: collector: (lujun9972) +[#]: translator: (silentdawn-zz) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12463-1.html) +[#]: subject: (Program IoT systems using Python with this VSCode plugin for RTOS) +[#]: via: (https://opensource.com/article/20/7/python-rt-thread) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +通过 VSCode RTOS 插件使用 Python 为物联网系统编写程序 +====== + +> RTOS 之类的实时嵌入式操作系统使嵌入式系统的编程更简单 + +![](https://img.linux.net.cn/data/attachment/album/202007/29/001132c37u7u5qp284wef2.jpg) + +物联网(IoT)无处不在,它意味着几乎所有的产品,从冰箱到口袋手表,都可以连网。为了实现这个目标,每个产品都需要拥有一个嵌入式计算机来运行网络栈,有些产品几乎是小的不可思议。这就是嵌入式软件出现的场景:现代科技打造的非常小的计算机,硬编码到硬件芯片,不需要任何板外处理器、内存或者存储盘。 + +就传统视角而言,这种场景意味着没有操作系统可用,但是因为种种 [原因][2],开发者发现,类似于 RTOS 之类的实时嵌入式操作系统能让嵌入式系统的编程变得非常简单。 + +虽然 RT-Thread 嵌入式操作系统致力于鼓励程序员新手进入物联网领域,但并非所有的人都具备使用 C 语言硬编码微芯片的能力。幸运的是,MicroPython 通过让开发者创建运行于嵌入式系统的 Python 代码的方式,逐渐填补了这个鸿沟。为了让整个过程更简单,RT-Thread 有一个可以用于 VSCode 和 [VSCodium][4] 的插件,为开发者提供了物联网方面的开发环境。其部分特性包括: + + * 方便的连接方式,可以很容易的通过串口、网络或者 USB 连接到开发板(如果你使用过 Arduino,肯定会很熟悉这个流程)。 + * 支持上传文件或目录到开发板。 + * 支持基于 MicroPython 的代码,而且具有智能的代码补完、语法检查功能。 + * 支持 MicroPython REPL 交互式环境。 + * 丰富的示例代码和演示程序。 + * 完整的工程同步功能。 + * 快速运行内存中的程序代码。 + * 运行函数的代码片段。 + * 支持主流的 MicroPython 开发板。 + * 支持 Linux 和 Windows 操作系统,并经过充分测试。 + +### 准备 + +在开始之前,如果你使用的是 Windows 操作系统,那么必须保证 VSCode 的默认终端是 [PowerShell][5]。运行 VSCodium,从 “Terminal” 菜单项启动一个终端. 在显示在 VSCodium 窗口底部的终端界面,从下拉菜单顶端选择 “PowerShell”。 +不论你是在 [Windows][6] 还是 Linux 系统下工作,必须保证安装了 Python 3(在 Linux 上,它可能已经安装了,否则可以通过软件库安装它)。 + +还要安装的是微软提供的通用 VSCode Python 插件。安装方法是点击 “File” 菜单,找到 “Preferences” 子菜单,从中打开 “Extensions” 面板。在扩展中,搜索 “Python”,找到来自微软的 Python 插件。 + +![VSCodium Python plugin][7] + +当然,在上述操作之前,你要先正确安装 [VSCodium][9] 或 [VSCode][10]。 + +### 安装插件 + +安装 MicroPython 开发插件的方法与安装 Python 插件一样,点击 “File” 菜单,找到 “Preferences” 子菜单,选择 “Extensions”。 + +在扩展中,搜索 “MicroPython”,安装 RT-Thread 插件。 + +![MicroPython plugin for RT-Thread][11] + +### 使用插件 + +你的开发板必须能访问串口,这需要组策略的允许。你可能需要将自己的账户加入该组,通常在默认情况下你的账户可能并不在该组。首先,确认你的账户不在 “dialout” 组: + +``` +$ groups +tux users +``` + +本例中,用户“tux”只是“tux”组和“users”组的成员,所以需要将用户“tux”添加到“dialout”组: + + +``` +$ sudo usermod --append --groups dialout tux +``` + +退出登录或重启以载入你新的组权限。 + +### 创建 MicroPython 工程 + +MicroPython 开发的第一步是创建 MicroPython 工程用来编写和运行代码。使用 MicroPython 插件创建工程的方法是,点击左下方的 “Create MicroPython project” 按钮。 + +![Create MicroPython project][12] + +之后会有一些提示,让你选择创建空白工程还是包含例程的工程。 + +### 连接到开发板 + +点击 VSCodium 左下方的 “Connection” 按钮,进行 VSCodium 与开发板的连接,在弹出的列表中,选择要连接的物理设备。 + +### 查看例程 + +MicroPython 插件提供了许多例程和例库,供学习和调用。获取例程的过程是,激活 MicroPython 之后,VSCodium 左侧按钮条会出现“新建”快捷图标,点击该图标就可以了。点击“文档”快捷图标,会显示例程文件列表;点击“文件夹”快捷图标,会显示例库列表。 + +![MicroPython examples][13] + +### 直接在开发板上运行 MicroPython 文件 + +在 VSCodium 中可以通过在开发板上运行单个程序文件,很方便快捷的进行程序调试。快捷键 `Alt+Q` 会触发一个特定的插件,该插件会将当前的 Python 文件上传到开发板内存中。你还可以在当前 Python 文档界面点击右键,然后选择 “Run the MicroPython file directly on the device” 实现同样的功能。 + +![Running code on your device][14] + +如果你需要以不上传代码的方式检查一组代码,可以使用“代码片段”功能。要运行 MicroPython REPL 环境中的代码片段,在编辑器中选中要运行的片段,右键菜单中点击 “Execute the selected MicroPython code on the device” (也可以使用 `Alt+Q` 快捷键)。 + +### 加载文件和目录到开发板 + +如果需要加载文件或目录到开发板,有现成的方法可用:选中工程中要加载到开发板的文件或目录,在选中的对象上右键,点击右键菜单中的 “Download the file/folder to the device”。 + +注意,如果开发板中已有与要加载的文件或目录同名者,加载操作将导致开发板原有的内容被覆盖。 + +在 REPL 环境中运行 `os.listdir()` 命令,可以检查文件和目录是否成功加载。当然,也可以通过相应的命令删除 REPL 中的文件或目录。 + +删除文件的命令如下: + +``` +os.remove('file_to_delete') +``` + +删除目录的命令如下: + +``` +os.rmdir('folder_to_delete') +``` + +### 工程的同步 + +点击左下角“同步”按钮可以启动工程同步,该操作将把本地工程中所有的文件和目录同步到开发板的文件系统。建议在完成程序调试之后进行该操作,调试过程中不需要频繁进行同步操作。 + +工程的同步操作完成后,开发板上的文件列表可以在 “Device Files List” 列看到。 + +### 放手尝试 + +RT-Thread 以开源的方式发布 MicroPython 插件,意在为新老开发者提供帮助,它的很多特性,如代码自动补全等,与开源插件之间互有影响和促进。你如果想为嵌入式系统或物联网系统编写软件,这就是最简单的方式,没有之一。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/python-rt-thread + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[silentdawn-zz](https://github.com/silentdawn-zz) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/containers_modules_networking_hardware_parts.png?itok=rPpVj92- (Parts, modules, containers for software) +[2]: https://opensource.com/article/20/6/open-source-rtos +[3]: https://www.rt-thread.io/ +[4]: https://opensource.com/article/20/6/open-source-alternatives-vs-code +[5]: https://opensource.com/article/18/2/powershell-people +[6]: https://opensource.com/article/19/8/how-install-python-windows +[7]: https://opensource.com/sites/default/files/uploads/vscodium-python-plugin.jpg (VSCodium Python plugin) +[8]: https://creativecommons.org/licenses/by-sa/4.0/ +[9]: http://vscodium.com +[10]: https://github.com/microsoft/vscode +[11]: https://opensource.com/sites/default/files/uploads/vscodium-micropython.jpg (MicroPython plugin for RT-Thread) +[12]: https://opensource.com/sites/default/files/uploads/vscodium-micropython-create.jpg (Create MicroPython project) +[13]: https://opensource.com/sites/default/files/uploads/vscodium-micropython-examples.jpg (MicroPython examples) +[14]: https://opensource.com/sites/default/files/uploads/vscodium-micropython-run.jpg (Running code on your device) diff --git a/published/202007/20200709 Btrfs to be the Default Filesystem on Fedora- Fedora 33 Starts Testing Btrfs Switch.md b/published/202007/20200709 Btrfs to be the Default Filesystem on Fedora- Fedora 33 Starts Testing Btrfs Switch.md new file mode 100644 index 0000000000..e360444220 --- /dev/null +++ b/published/202007/20200709 Btrfs to be the Default Filesystem on Fedora- Fedora 33 Starts Testing Btrfs Switch.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12455-1.html) +[#]: subject: (Btrfs to be the Default Filesystem on Fedora? Fedora 33 Starts Testing Btrfs Switch) +[#]: via: (https://itsfoss.com/btrfs-default-fedora/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Fedora 33 开始测试切换到 Btrfs +====== + +尽管距离 Fedora 的下一个稳定版本([Fedora 33][1])还有几个月的距离,但仍有一些值得关注的变化。 + +在所有其他 [Fedora 33 接受的系统范围的更改][1]中,最有趣的提议是将 Btrfs 作为桌面的默认文件系统,这个提议现在已经被批准了。 + +这是 Fedora 对该提案的评价: + +> 对于安装 Fedora 的笔记本电脑和工作站,我们希望以透明的方式向用户提供文件系统功能。我们希望添加新功能,同时减少处理磁盘空间不足之类的情况所需的专业知识。Btrfs 它的设计理念非常适合这个角色,让我们将其设为默认设置。 + +值得注意的是,在测试的最终投票结果出来之前,这不是系统范围内的更改。 + +但是,现在测试已经成功完成,投票结果也是赞成的 —— Fedora 33 版本已经接受了这个改动。 + +那么,为什么 Fedora 提出这一更改?这会有什么用么?这是糟糕的举动吗?对 Fedora 的发行有何影响?让我们在这里谈论下。 + +![][3] + +### 它会影响哪些 Fedora 版本? + +根据提议,如果测试成功,那么 Fedora 33 的所有桌面版本、spins 和 labs 都受此影响。 + +因此,你可以期望[工作站版本][4]将 Btrfs 作为 Fedora 33 上的默认文件系统。 + +### 实施此更改的潜在好处 + +为了改进 Fedora 在笔记本和工作站的使用,Btrfs 文件系统提供了一些好处。 + +现在 Fedora 33 将成为默认文件系统 —— 让我来指出使用 Btrfs 作为默认文件系统的好处: + + * 延长存储硬件的使用寿命 + * 提供一个简单的方案来解决用户耗尽根目录或主目录上的可用空间的情况 + * 不易造成数据损坏,易于恢复 + * 提供更好的调整文件系统大小的功能 + * 通过强制 I/O 限制来确保桌面在高内存压力下的响应能力 + * 使复杂的存储设置易于管理 + +如果你感到好奇,你可能想更深入地了解 [Btrfs][5] 及其总体优点。 + +不要忘记,Btrfs 已经是受支持的选项,它只是不是默认的文件系统而已。 + +但是,总的来说,感觉在Fedora 33上引入Btrfs作为默认文件系统是一个有用的变化。 + +### Red Hat Enterprise Linux 会不会实现它? + +很明显,Fedora 被认为是 [Red Hat Enterprise Linux][6] 的前沿版本。 + +因此,如果 Fedora 拒绝更改,那么 Red Hat 将不会实施。另一方面,如果你希望 RHEL 使用 Btrfs,那么 Fedora 应该首先同意更改。 + +为了让你更加清楚,Fedora 对其进行了详细介绍: + +> Red Hat 在许多方面都很好地支持 Fedora。但是 Fedora 已经与上游紧密合作,并依赖上游。这将是其中之一。这是该提案的重要考虑因素。社区有责任确保它得到支持。如果 Fedora 拒绝,那么 Red Hat 将永远不会支持 Btrfs。Fedora 必然需要成为第一个,并提出令人信服的理由,说明它比替代方案能解决更多的问题。它的负责人相信它确实如此,毫无疑问。 + +另外,值得注意的是,如果你不想在 Fedora 中使用 btrfs,你应该看看 [OpenSUSE][7] 和 [SUSE Linux Enterprise][8]。 + +### 总结 + +即使这个更改看起来不会影响任何升级或兼容性,你也可以在 [Fedora 项目的 Wiki 页面][9]中找到有关 Btrfs 的更改的更多信息。 + +你对针对 Fedora 33 发行版的这一更改有何看法?你是否要将 btrfs 文件系统作为默认文件系统? + +请在下面的评论中让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/btrfs-default-fedora/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://fedoraproject.org/wiki/Releases/33/ChangeSet +[2]: https://fedoraproject.org/wiki/Test_Day:2020-07-08_Btrfs_default?rd=Test_Day:F33_btrfs_by_default_2020-07-08 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/07/btrfs-default-fedora.png?ssl=1 +[4]: https://getfedora.org/en/workstation/ +[5]: https://en.wikipedia.org/wiki/Btrfs +[6]: https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux +[7]: https://www.opensuse.org +[8]: https://www.suse.com +[9]: https://fedoraproject.org/wiki/Changes/BtrfsByDefault diff --git a/published/202007/20200709 What you need to know about automation testing in CI-CD.md b/published/202007/20200709 What you need to know about automation testing in CI-CD.md new file mode 100644 index 0000000000..d5b7f7dd3a --- /dev/null +++ b/published/202007/20200709 What you need to know about automation testing in CI-CD.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12458-1.html) +[#]: subject: (What you need to know about automation testing in CI/CD) +[#]: via: (https://opensource.com/article/20/7/automation-testing-cicd) +[#]: author: (Taz Brown https://opensource.com/users/heronthecli) + +CI/CD 中的自动化测试的概要知识 +====== + +> 持续集成和持续交付是由测试驱动的。以下是如何做到的。 + +![](https://img.linux.net.cn/data/attachment/album/202007/27/210026blobu65f77accbob.jpg) + +> “如果一切似乎都在控制之中,那只是你走的不够快而已。” —Mario Andretti + +测试自动化是指在软件开发过程中尽可能早、尽可能快地持续关注检测缺陷、错误和 bug。这是通过使用那些追求质量为最高价值的工具完成的,它们旨在*确保*质量,而不仅仅是追求质量。 + +持续集成/持续交付(CI/CD)解决方案(也称为 DevOps 管道)最引人注目的功能之一是可以更频繁地进行测试,而又不会给开发人员或操作人员增加更多的手动工作。让我们谈谈为什么这很重要。 + +### 为什么要在 CI/CD 中实现自动化测试? + +敏捷团队要更快的迭代,以更高的速度交付软件和客户满意度,而这些压力可能会危及质量。全球竞争制造了对缺陷的*低容忍度*,同时也增加了敏捷团队的压力,要求软件交付的*迭代更快*。减轻这种压力的行业解决方案是什么?是 [DevOps][2]。 + +DevOps 是一个大概念,有很多定义,但是对 DevOps 成功至关重要的一项技术是 CI/CD。通过软件开发流程设计一个连续的改进循环,可以为测试带来新的机会。 + +### 这对测试人员意味着什么? + +对于测试人员,这通常意味着他们必须: + + * 更早且更频繁地进行测试(使用自动化) + * 持续测试“真实世界”的工作流(自动和手动) + +更具体地说,任何形式的测试,无论是由编写代码的开发人员运行还是由质量保证工程师团队设计,其作用都是利用 CI/CD 基础架构在快速推进的同时提高质量。 + +### 测试人员还需要做什么? + +具体点说,测试人员负责: + + * 测试新的和现有的软件应用 + * 根据系统要求评估软件来验证和确认功能 + * 利用自动化测试工具来开发和维护可重复使用的自动化测试 + * 与 scrum 团队的所有成员合作,了解正在开发的功能以及实施的技术设计,以设计和开发准确、高质量的自动化测试 + * 分析记录在案的用户需求,并针对中等到高度复杂的软件或 IT 系统制定或协助设计测试计划 + * 开发自动化测试,并与功能团队一起审查和评估测试方案 + * 与技术团队合作,确定在开发环境中自动化测试的正确方法 + * 与团队合作,通过自动化测试来了解和解决软件问题,并回应有关修改或增强的建议 + * 参与需求梳理、估算和其他敏捷 scrum 仪式 + * 协助制定标准和流程,以支持测试活动和材料(例如脚本、配置、程序、工具、计划和结果) + +测试是一项艰巨的工作,但这是有效构建软件的重要组成部分。 + +### 哪些持续测试很重要? + +你可以使用多种测试。不同的类型并不是学科之间的牢固界限。相反,它们是表示如何测试的不同方式。比较测试类型不太重要,更重要的是对每一种测试类型都要有覆盖率。 + + * **功能测试:** 确保软件具有其要求的功能 + * **单元测试:** 独立测试软件的较小单元/组件以检查其功能 + * **负载测试:** 测试软件在重负载或使用期间的性能 + * **压力测试:** 确定软件承受压力(最大负载)时的断点 + * **集成测试:** 测试组合或集成的一组组件的输出 + * **回归测试:** 当修改任意组件(无论多么小),测试整个应用的功能 + +### 总结 + +任何包含持续测试的软件开发过程都将朝着建立关键反馈环路的方向发展,以实现快速和构建有效的软件。最重要的是,该实践将质量内置到 CI/CD 管道中,并意味着了解在软件开发生命周期中提高速度同时减少风险和浪费之间的联系。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/automation-testing-cicd + +作者:[Taz Brown][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/heronthecli +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_analytics_cloud.png?itok=eE4uIoaB (Net catching 1s and 0s or data in the clouds) +[2]: https://opensource.com/resources/devops diff --git a/published/202007/20200713 My Linux story- From Linux user to contributor.md b/published/202007/20200713 My Linux story- From Linux user to contributor.md new file mode 100644 index 0000000000..0d8c6d5d62 --- /dev/null +++ b/published/202007/20200713 My Linux story- From Linux user to contributor.md @@ -0,0 +1,86 @@ +[#]: collector: (lujun9972) +[#]: translator: (Yufei-Yan) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12438-1.html) +[#]: subject: (My Linux story: From Linux user to contributor) +[#]: via: (https://opensource.com/article/20/7/linux-user-contributor) +[#]: author: (Taz Brown https://opensource.com/users/heronthecli) + +我的 Linux 故事:从用户到贡献者 +====== + +> 开源社区欢迎来自不同背景和技能的贡献者。 + +![](https://img.linux.net.cn/data/attachment/album/202007/22/114140tfuubuvcfgujrcab.jpg) + +我是一名 IT 专业人士,拥有超过 15 年经验,担任过不同职位 —— 包括系统管理员、高级 Linux 管理员、DevOps 工程师、自动化顾问和高级敏捷专家scrum master。我开始是在 Ubuntu 上学习 Linux,但是后来作为系统管理员转到 CentOS,然后我又转到 Fedora 作为个人使用。但是我对技术的喜爱要远比我使用第一个 Linux 发行版要早的多,而且是来自于一部电影。 + +我最喜欢的电影是《黑客Hackers》。最精彩的一幕发生在电影的开头。电影一开始,一群特工冲进一所房子抓捕臭名昭著的黑客 Zero Cool。我们马上发现 Zero Cool 其实是 11 岁的 Dade Murphy,他在一天之内成功瘫痪了 1507 台计算机系统。他被指控犯罪,他的家人被处以重罚。而且,在他 18 岁之前,他都被禁止使用电脑或按键式电话。 + +劳伦斯·梅森Laurence Mason扮演的 Paul Cook,又名 Nikon 勋爵,是我最喜欢角色。其中一个主要原因是,我从没有看过一个黑客电影里面的人物长的像我,所以我被他的形象深深吸引了。他很神秘。这让我耳目一新,并且感到自豪,我对 IT 充满了热情,我也是一个和他很像的极客。 + +![Taz with astronaut][2] + +### 成为一个 Linux 贡献者 + +15 年前,我开始使用 Linux。当我成为一个 Linux 管理员的时候,Linux 就成了我的激情所在。我一直尝试找到某种方式能够为开源作出贡献,当时我还不知道该从哪开始。因为这个社区实在是太大了,我不知道自己能否真正成为一个有影响力的人,但当我发现一些人认可我的兴趣,还对我进行指导,我开始彻底打开心扉,问各种问题,并且从社区中学习。自从那以后,Fedora 社区一直是我做贡献的最主要社区。 + +我现在对于向开源做贡献还是有点稚嫩。当我意识到我可以用代码以外的方式来贡献时,我对开源的想法发生了改变。我更喜欢通过文档做一些贡献,因为我本质上不是一个软件开发人员,而且社区里面最迫切的需求正是文档。请记住:用户的技能和开发人员的技能同样重要。 + +### 我的硬件是什么? + +硬件也很重要,而且现在几乎所有东西都可以运行 Linux。现在,我家里的配置包括: + + * 联想 Thinksever TS140,64 GB 内存,4 x 1 TB SSD 和一个存储数据的 1 TB 机械硬盘 + * 使用 RAID 5 配置的 164 TB Synology NAS + * 输入输出使用罗技 MX Master 和 MX Master 2S + * 一个定制的并且符合人体工学的 Kinesis Advantage 2 键盘 + * 两个 38 寸 LG 超宽曲面显示器和一个 34 寸 LG 超宽显示器 + * 一台配备 i7 六核十二线程 CPU 和 16.1 英寸 IPS 显示器的 System76 笔记本 + +我很喜欢 Fedora 处理外置设备的方式,比如说我的鼠标和键盘。一切都完美融合。即插即用工作正常,性能从来不受影响。 + +![Fedora double monitor setup][4] + +### 软件是什么? + +使用开源软件对我的工作非常重要。我依赖于: + + * Fedora 30 作为我日常使用的 Linux 发行版 + * Wekan 作为我的项目的开源看板kanban + * [Atom][5] 作为我的文本编辑器 + * Terminator 作为我日常使用的终端,因为它的网格布局以及丰富的键盘快捷键 + * Neofetch 用来显示每次登录到终端时的系统信息 + +最后同样重要的是,我把 Powerline、Powerlevel9k 和 Vim-Powerline 搞到我的终端上来跟别人装酷。 + +![Multiple fedora screens][7] + +### Linux 让我们走到一起 + +美国是个大熔炉,我也是这么看待 Linux 和像 Fedora 项目这样的特定社区的。在每个 Linux 社区中,对于不同的贡献都有很大的空间。也有很多方式可以参与进来,而且对于新的想法,也总是有发挥的空间。通过分享我过去 15 年在开源方面的经验,我希望帮助更多在科技领域的少数族裔体会到来自开源社区对多样性和包容性的认同感。 + +*编者注:这篇文章改编自[“Taz Brown:你怎么搞 Fedora?”][8],并得到许可重新发布* + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/linux-user-contributor + +作者:[Taz Brown][a] +选题:[lujun9972][b] +译者:[Yufei-Yan](https://github.com/Yufei-Yan) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/heronthecli +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/contributor_spotlight_penguin.jpg?itok=azJA5Cj8 (Penguin, stylized, contributor spotlight) +[2]: https://opensource.com/sites/default/files/uploads/taz_with_astronaut_0.png (Taz with astronaut) +[3]: https://getfedora.org/ +[4]: https://opensource.com/sites/default/files/uploads/fedora_double_monitor_setup.jpg (Fedora double monitor setup) +[5]: https://fedoramagazine.org/install-atom-fedora/ +[6]: https://fedoramagazine.org/add-power-terminal-powerline/ +[7]: https://opensource.com/sites/default/files/uploads/fedora_screens.jpg (Multiple fedora screens) +[8]: https://fedoramagazine.org/taz-brown-how-do-you-fedora/ diff --git a/published/202007/20200713 My feature-rich and minimal Linux terminal.md b/published/202007/20200713 My feature-rich and minimal Linux terminal.md new file mode 100644 index 0000000000..301fb64e95 --- /dev/null +++ b/published/202007/20200713 My feature-rich and minimal Linux terminal.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12439-1.html) +[#]: subject: (My feature-rich and minimal Linux terminal) +[#]: via: (https://opensource.com/article/20/7/minimal-linux-terminal) +[#]: author: (Sumantro Mukherjee https://opensource.com/users/sumantro) + +我的功能丰富却又保持简约的 Linux 终端 +====== + +> 这些应用和主题可以你真正拥有你的终端。 + +![](https://img.linux.net.cn/data/attachment/album/202007/22/123206g5t5mmz5ozdt5f5m.jpg) + +每个人都喜欢以特定的方式设置他们的工作区:它可以帮助你提高效率,并使生活更容易以一种感觉有机的方式组织事物,并拥有一个对你来说感觉良好的环境。这也绝对适用于终端。这可能就是为什么有这么多可用终端的原因。 + +在使用新的计算机时,我做的第一件事就是设置我的终端,让它成为我自己的终端。 + +我最喜欢的终端应用是 [Terminator][2],因为它的设计简约,并且内置了窗口选项。但从这里开始变得更加复杂。我将自己喜欢的终端风格描述为“功能丰富却又保持简约”。这种平衡是我经常在微调的。 + +我使用 zsh 作为默认 shell,并使用 Ohmyzsh 来提供额外的功能。可以下载它的安装脚本来安装 Ohmyzsh: + +``` +$ curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh --output install-zsh.sh +``` + +查看一遍脚本了解它做什么,并确保你有信心在计算机上运行该脚本。完成后,运行脚本: + +``` +$ sh ./install-zsh.sh +``` + +我最喜欢的主题/提示符是 [Powerlevel 10k][3],它是一个非常详细的环境视图。它包含了从命令的颜色高亮到运行时间的时间戳等所有内容。所有细节都集成到一个优雅的、具有上下文感知的提示符中。 + +要安装 Powerlevel10k,请先在 `.oh-my-zsh/` 自定义主题目录中下载源码。 + +``` +git clone --depth=1 https://github.com/romkatv/powerlevel10k.git +${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k +``` + +但是,为了让 Powerlevel10k 看起来如其存储库中所示,我们需要添加一些默认不包括的字体。它们是: + + * [MesloLGS NF Regular.ttf][4] + * [MesloLGS NF Bold.ttf][5] + * [MesloLGS NF Italic.ttf][6] + * [MesloLGS NF Bold Italic.ttf][7] + +这将产生一个美观且具有上下文感知的终端(如 [screenfetch][8] 所示): + +![terminator terminal shot via screenFetch][9] + +我已经习惯了这个特殊的设置,但是,把工作环境变成自己的环境固然重要,但这也并不是一个固执地尝试新事物的理由。新终端的出现,是为了满足新一代用户的需求和要求。这意味着,即使一开始不熟悉,但最近开发的一种终端可能比你的老旧备用机更适合当今的环境和职责。 + +我最近一直在考虑其他选择。我开始关注 [Starship][10] 的开发情况,它将自己描述为简约的、快速的、可无限定制的提示符,适用于任何 shell。它仍然有很多在视觉上可以身临其境的细节,而不会像 Powerlevel10k 那样使人分心。 + +你最喜欢的终端是什么?为什么?请在评论栏分享! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/minimal-linux-terminal + +作者:[Sumantro Mukherjee][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sumantro +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_desk_home_laptop_browser.png?itok=Y3UVpY0l (Digital images of a computer desktop) +[2]: https://terminator-gtk3.readthedocs.io/en/latest/ +[3]: https://github.com/romkatv/powerlevel10k +[4]: https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf +[5]: https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf +[6]: https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf +[7]: https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf +[8]: https://github.com/KittyKatt/screenFetch +[9]: https://opensource.com/sites/default/files/uploads/osdc00_edit.png (terminator terminal shot via screenFetch ) +[10]: https://starship.rs/ diff --git a/published/202007/20200713 Top 5 Open Source Video Conferencing Tools for Remote Working and Online Meetings.md b/published/202007/20200713 Top 5 Open Source Video Conferencing Tools for Remote Working and Online Meetings.md new file mode 100644 index 0000000000..3c7727f220 --- /dev/null +++ b/published/202007/20200713 Top 5 Open Source Video Conferencing Tools for Remote Working and Online Meetings.md @@ -0,0 +1,145 @@ +[#]: collector: (lujun9972) +[#]: translator: (this-is-name-right) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12453-1.html) +[#]: subject: (Top 5 Open Source Video Conferencing Tools for Remote Working and Online Meetings) +[#]: via: (https://itsfoss.com/open-source-video-conferencing-tools/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +5 个流行的用于远程工作和在线会议的开源视频会议工具 +====== + +你会发现网上有一些视频会议工具。一些是为专业用户量身定制的,另一些是为了日常闲聊的。 + +然而面对着成百上千的选择,当选择视频会议应用或服务时,安全和隐私是往往是一个重要的点。在众多选择中,哪些是最好最安全的? + +所有这些(或大多数)都宣称要提供最好的安全和隐私。但是,你要知道这可不能只看表面。 + +幸运的是在这里,我们专注于开源和隐私友好的解决方案,所以,让我们看看你可以使用的开源视频会议工具列表。 + +### 顶级开源视频会议解决方案 + +![](https://img.linux.net.cn/data/attachment/album/202007/26/104947gyzs2eb5ybeneg5y.jpg) + +如果你是商企用户,大多数视频会议解决方案可以被安装在你自己的服务器上。 + +对于不是系统管理员的普通人来说,其中一些解决方案还提供了现成的、免费的、基于 Web 的视频会议服务。我将在列表中每个项目的描述中提及此信息。 + +**备注:** 列表中的排名不分先后。 + +#### 1、Jitsi Meet + +![][2] + +Jitsi Meet 是一个令人印象深刻的开源视频会议服务。你可以在我们关于 [Jitsi Meet][3] 的单独报道中轻松找到更多信息。 + +为了给你一个好的开始,Jitsi Meet 提供免费[官方公共实例][4]来测试它,只要你需要,就可以免费使用它。 + +如果你需要将其托管在你的服务器上,同时根据你的需求定制一些选项,你可以从它的[官网][5]下载到你的服务器。 + +尽管他们在 Linux 上提供了一个基于 Electron 的应用,其实你不必下载一个应用到你的桌面上来设置它。你只需要一个浏览器就足够了。在移动端,安卓和 iOS 都有应用。 + +- [Jitsi Meet][5] + +#### 2、Jami + +![][6] + +Jami 是一个基于点对点的开源视频会议解决方案。很高兴看到分布式的服务,这意味着不依靠服务器,而只是点对点的连接。 + +当然了,分布式的服务有优点也有缺点。但是它是自由而开源的,那才是最重要的。 + +Jami 之前被称为 Ring messenger,但它改了名字,现在是一个 GNU 项目。 + +Jami 有 Linux、Windows、macOS、Android 和 iOS 的版本,所以它是一个完全跨平台的安全传送信息和视频会议的解决方案。你可以看看他们的 [GitLab 页面][7]浏览更多信息。 + +- [Jami][8] + +#### 3、Nextcloud Talk + +![][9] + +[Nextcloud][10] 毫无疑问是开源远程办公工具的瑞士军刀。我们就在使用 Nextcloud。所以如果你已经配置了服务器,[Nextcloud Talk][11] 显然是一个优秀的视频会议和聊天工具。 + +当然了,如果你还没有自己的 Nextcloud 服务器,你需要一些技术知识来进行设置它,然后才能开始使用 Nextcloud Talk。 + +- [Nextcloud Talk][11] + +#### 4、Riot.im + +![][12] + +Riot.im(不久会更名)已经是 Slack [最好的开源替代品][13]之一。 + +它能让你可以创建社区、发送信息,并在一个小组/社区中开始视频会议。你可以通过任何可用的公共 [Matrix 服务器][14]来免费使用它。 + +如果你想要自己专用的去中心化的 Matrix 网络,你也可以在 [Modular.im][15] 上选择付费托管计划。 + +- [Riot.im][16] + +#### 5、BigBlueButton + +![][17] + +BigBlueButton 是一个有趣的开源视频会议方案,专门为线上学习打造。 + +如果你是老师或者经营着一个学校,你也许会想试试。虽然你可以免费试用,但免费演示使用会有一定的限制。所以,最好将其托管到自己的服务器上,并且,如果你有其他的产品/服务的话,你也可以把它整合进其中。 + +它提供了一套很好的功能,能让你很轻松的教学生。你可以浏览它的 [GitHub 页面][18]以了解更多信息。 + +- [BigBlueButton][19] + +#### 补充:Wire + +![][20] + +Wire 是一个十分流行的开源的安全消息平台,为商企用户量身打造。它也提供视频电话或者网络会议选项。 + +如果你想要一个为你的企业或团队提供的商业开源方案,你可以试试 Wire,并在试用 30 天后决定是否升级它。 + +就个人而言,我喜欢它的用户体验,但它是要付费的。所以我建议你决定之前,先试试看并浏览它的 [GitHub 页面][21]。 + +- [Wire][22] + +### 总结 + +现在你知道一些流行开源网络视频会议方案了,你更喜欢使用哪一个? + +我是否错过了任何你的最爱?请在下面的评论中告诉我你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/open-source-video-conferencing-tools/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[this-is-name-right](https://github.com/this-is-name-right) +校对:[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/2020/07/open-source-video-conferencing-tools.jpg?ssl=1 +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/06/jitsi-meet-browser-screenshot.png?ssl=1 +[3]: https://itsfoss.com/jitsi-meet/ +[4]: https://meet.jit.si/ +[5]: https://jitsi.org/jitsi-meet/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/jami-screenshot.png?ssl=1 +[7]: https://git.jami.net/savoirfairelinux/ring-project +[8]: https://jami.net/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/nextcloud-talk.png?ssl=1 +[10]: https://itsfoss.com/nextcloud/ +[11]: https://nextcloud.com/talk/ +[12]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/07/riot-communication-video.png?ssl=1 +[13]: https://itsfoss.com/open-source-slack-alternative/ +[14]: https://matrix.org/ +[15]: https://modular.im/ +[16]: https://about.riot.im/ +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/big-blue-button.png?ssl=1 +[18]: https://github.com/bigbluebutton/bigbluebutton +[19]: https://itsfoss.com/open-source-video-conferencing-tools/bigbluebutton.org/ +[20]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/07/wire-video-conferencing.png?ssl=1 +[21]: https://github.com/wireapp +[22]: https://wire.com/en/ diff --git a/published/202007/20200714 My Linux story- breaking language barriers with open source.md b/published/202007/20200714 My Linux story- breaking language barriers with open source.md new file mode 100644 index 0000000000..53f2611c0a --- /dev/null +++ b/published/202007/20200714 My Linux story- breaking language barriers with open source.md @@ -0,0 +1,57 @@ +[#]: collector: (lujun9972) +[#]: translator: (JonnieWayy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12466-1.html) +[#]: subject: (My Linux story: breaking language barriers with open source) +[#]: via: (https://opensource.com/article/20/7/linux-bengali) +[#]: author: (Dr Anirban Mitra https://opensource.com/users/mitradranirban) + +我的 Linux 故事:用开源打破语言壁垒 +====== + +> 开源项目可以通过消除语言和其他障碍来帮着改变世界。 + +![](https://img.linux.net.cn/data/attachment/album/202007/29/230730e4mb18km1nwn4ibm.jpg) + +相较于我的许多同行和同事,我的开源之旅开始得着实很晚。 + +2000 年,我实现了我从高中开始的梦想 —— 买一台属于我自己的个人计算机,当时我正在攻读医学研究生学位。在那之前,我对计算机的唯一接触是偶尔在图书馆或网吧上网,当时这些地方电脑使用的收费都相当高昂。所以我省下了一部分研究生津贴,设法买了一台 Pentium III 550 Mhz、128MB 内存的电脑,并且像当时大多数印度电脑的标准配置一样,装着盗版的 Windows 98 系统。 + +我的宿舍房间上不了网。我不得不去附近的网吧,在那里下载软件,然后随身带着几十张软盘。 + +当我终于拥有了自己的计算机,我非常高兴,但有一点也让我感到困扰,那就是我无法用我的母语孟加拉语写东西。我碰到了 CDAC 提供的资源,CDAC 是一个政府机构,它提供的印度语言工具是基于 ISCII 的,ISCII 是一个较早的国家标准,而印度语的 Unicode 标准就是基于这个标准。很难学习它的键盘布局。 + +### 我的第一次贡献 + +不久后,我遇到了一款名叫 [Yudit][2] 的软件,它使用标准的 QWERTY 键盘布局来提供印地语的拼音输入。正是在通过 Yudit,我第一次遇到了诸如开源和自由软件、GNU 和 Linux 之类的术语。Yudit 也允许我把 UI 组件翻译成孟加拉语,当我将翻译提交给开发人员时,他很高兴地将它们合并到了下一个版本中,并在软件的 README 文件中称赞了我的功劳。 + +第一次看到一款应用程序的用户元素以我的母语呈现,我感到十分兴奋。此外,尽管对写代码的知识几乎为零,我依然能够为软件开发做出贡献。我继续为 Yudit 创建了一个从 ISCII 到 Unicode 的转换器,这个转换器还可以用于各种印度语言之间的直译。我还买了本 Linux 杂志,随刊附赠了一张 Knoppix 的免费 live CD,正是通过它我体验到了 Linux 桌面。 + +我面临的另一个问题是缺乏与 Unicode 兼容的 OpenType Bangla 字体。我使用的字体是共享软件,我需要为它支付许可费用。我在想,“为什么不尝试亲自开发呢?”在此过程中,我通过 bengalinux.org(后来更名为 Ankur 小组)接触到了分散在世界各地的孟加拉语使用者,他们正试图在 Linux 操作系统中使用孟加拉语。 + +我加入了他们的邮件列表,我们在内部与当局之间讨论了孟加拉语的 Unicode 和 OpenType 规范中的各种缺陷,然后在适当的时候进行了纠正。我的贡献是将传统的孟加拉字体转换为兼容 Unicode 的 OpenType 字体,翻译 UI 等。这个小组还发行了世界上第一张带有孟加拉语 UI 的 Live Linux CD。 + +2003 年,我搬家到了一个无法访问互联网的地方。我只有在周日去加尔各答时才能联系到小组。当时,Linux 的孟加拉语本地化已经成为了主流。我们的一些志愿者加入了 Red Hat 从事翻译和字体开发工作。我也忙于我的医疗工作,几乎没时间去进行开源开发。 + +如今,我觉得使用 Linux 做日常工作比其他任何操作系统都要舒服。我也为能与一个能让人们用自己的语言交流的项目联系在一起而感到自豪。它也为长期以来由于不会说英语而被认为处于“数字鸿沟digital divide”另一端的人们带来了计算能力。孟加拉语实际上是世界上使用最广泛的语言之一,这个项目消除了全球人口中很大一部分人接触数字科技的主要语言壁垒。 + +### 加入开源 + +加入到开源运动中来很容易。主动做一些对自己有用的事情,然后思索一下所做的事情如何能对他人也有帮助。关键在于使它免费可用,它可以给世界带来难以估量的价值。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/linux-bengali + +作者:[Dr Anirban Mitra][a] +选题:[lujun9972][b] +译者:[JonnieWayy](https://github.com/JonnieWayy) +校对:[wxy](https://github.com/wxy ) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mitradranirban +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/india-globe-map.jpg?itok=6sSEL5iO (India on the globe) +[2]: http://www.yudit.org/ diff --git a/published/202007/20200715 What-s the difference between DevSecOps and agile software development.md b/published/202007/20200715 What-s the difference between DevSecOps and agile software development.md new file mode 100644 index 0000000000..38b9f14c28 --- /dev/null +++ b/published/202007/20200715 What-s the difference between DevSecOps and agile software development.md @@ -0,0 +1,96 @@ +[#]: collector: (lujun9972) +[#]: translator: (windgeek) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12449-1.html) +[#]: subject: (What's the difference between DevSecOps and agile software development) +[#]: via: (https://opensource.com/article/20/7/devsecops-vs-agile) +[#]: author: (Sam Bocetta https://opensource.com/users/sambocetta) + +DevSecOps 和敏捷软件开发有什么不同? +====== + +> 你更专注于安全性还是软件交付,还是可以两者兼得? + +![](https://img.linux.net.cn/data/attachment/album/202007/24/225337mb44xoe2byvz4x4o.jpg) + +技术社区中存在一种趋势,经常互换地使用 DevSecOps 和敏捷软件开发这两个术语。尽管它们有一些相似性,例如都旨在更早地检测风险,但在改变团队的[工作方式层面有很大不同][2]。 + +DevSecOps 建立在敏捷开发建立的一些原则上。但是,DevSecOps 特别专注于[集成安全功能][3],而敏捷开发则专注于交付软件。 + +知道如何保护你们的网站或应用程序免受勒索程序和其他威胁的侵害,实际上取决于你使用的软件和系统开发。这可能会影响你选择使用 DevSecOps、敏捷软件开发还是两者兼而有之。 + +### DevSecOps 和敏捷软件开发的不同之处 + +两者的主要区别可以归结为一个简单的概念:安全性。这取决于你的软件开发实践,你们公司的安全措施 —— 以及何时、何地以及由谁实施,都可能会有很大不同。 + +每个企业都[需要 IT 安全][4]来保护其重要数据。如果企业真正重视 IT 安全,一般都会采取虚拟专用网(VPN)、数字证书、防火墙保护、多因子身份验证、安全的云存储,包括向员工介绍基本的网络安全措施。 + +当你信任 DevSecOps 时,你就会把公司的安全问题,本质上使其等同于持续集成和交付。 DevSecOps 方法论在开发之初就强调安全性,并使其成为整体软件质量不可或缺的组成部分。 + +基于 DevSecOps 安全性的三大原则: + + * 平衡用户访问难易程度及数据安全性 + * 使用 VPN 和 SSL [加密数据][5]可防止数据在传输过程中受到入侵者的攻击 + * 使用可以扫描新代码的安全漏洞并能通知开发人员该漏洞的工具来预测防范未来的风险 + +尽管 DevOps 一直打算包含安全性,但并非每个实践 DevOps 的组织都牢记这一点。DevSecOps 在 DevOps 的演进形式中,可以提供更加清晰的信息。尽管它们的名称相似,但这两个[不应混淆] [6]。在 DevSecOps 模型中,安全性是团队的主要驱动力。 + +同时,敏捷开发更专注于迭代开发周期,这意味着反馈意见会不断融入到持续的软件开发中。[敏捷的关键原则][7]是拥抱不断变化的环境,为客户和使用者提供竞争优势,让开发人员和利益相关者紧密合作,并在整个过程中始终保持关注技术卓越,以提升效率。换句话说,除非敏捷团队在其定义中包括安全性,否则安全性在敏捷软件开发中算是事后思考。 + +### 国防机构面临的挑战 + +如果要说专门致力于最大程度地提高安全性的组织,美国国防部(DoD)就是其中之一。在 2018 年,美国国防部发布了针对软件开发中的“假敏捷”或“以敏捷为名”的[指南][8]。该指南旨在警告美国国防部高管注意不良编程的问题,并说明如何发现它以避免风险。 + +使用这些方法不仅可以使美国国防部受益。医疗保健和金融部门也[保存着][9]必须保证安全的大量敏感数据。 + +美国国防部通过其现代化战略(包括采用 DevSecOps)来改变防范形式至关重要。尤其在这个连美国国防部容易受到黑客攻击和数据泄露的时代,这一点在 2020 年 2 月的[大规模数据泄露][10]中已经得到了证明。 + +将网络安全最佳实践转化为现实生活中的开发仍然还存在固有的风险。事情不可能 100% 完美地进行。最好的状况是稍微有点不舒服,最坏的情况下,它们可能会带来全新的风险。 + +开发人员,尤其是那些为军用软件编写代码的开发人员,可能对[所有应该采用 DevSecOps 的情境][11]没有透彻的了解。学习曲线会很陡峭,但是为了获得更大的安全性,必须承受这些必不可少的痛苦。 + +### 自动化时代的新模式 + +为了解决对先前安全措施日益增长的担忧,美国国防部承包商已开始评估 DevSecOps 模型。关键是将该方法论部署到持续的服务交付环境中。 + +应对这个问题,出现了三个方向。第一种涉及到自动化,自动化已在大多数隐私和安全工具中[广泛使用][12],包括 VPN 和增强隐私的移动操作系统。大型云基础架构中的自动化无需依赖于人为的检查和平衡,可以自动处理持续的维护和进行安全评估。 + +第二种专注于对于过渡到 DevSecOps 很重要的安全检查点。而传统上,系统设计初期对于数据在各个组件之间移动时依旧可以访问是不做期望的。 + +第三种也是最后一种涉及将企业方式用于军用软件开发。国防部的许多承包商和雇员来自商业领域,而不是军事领域。他们的背景为他们提供了为大型企业[提供网络安全][13]的知识和经验,他们可以将其带入政府部门职位中。 + +### 值得克服的挑战 + +转向基于 DevSecOps 的方法论也提出了一些挑战。在过去的十年中,许多组织已经完全重新设计了其开发生命周期,以适应敏捷开发实践,在不久之后进行再次转换看起来令人生畏。 + +企业应该安下心来,因为即使美国国防部也遇到了这种过渡带来的麻烦,他们在应对推出新流程使得商业技术和工具广泛可用的挑战上并不孤独。 + +展望一下未来,其实切换到 DevSecOps 不会比切换到敏捷软件开发更痛苦。而且通过将[创建安全性的价值][4]添加到开发工作流程中,以及利用现有敏捷开发的优势,企业可以获得很多收益。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/devsecops-vs-agile + +作者:[Sam Bocetta][a] +选题:[lujun9972][b] +译者:[windgeek](https://github.com/windgeek) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sambocetta +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/devops_confusion_wall_questions.png?itok=zLS7K2JG (Brick wall between two people, a developer and an operations manager) +[2]: https://tech.gsa.gov/guides/understanding_differences_agile_devsecops/ +[3]: https://www.redhat.com/en/topics/devops/what-is-devsecops +[4]: https://www.redhat.com/en/topics/security +[5]: https://surfshark.com/blog/does-vpn-protect-you-from-hackers +[6]: https://www.infoq.com/articles/evolve-devops-devsecops/ +[7]: https://enterprisersproject.com/article/2019/9/agile-project-management-explained +[8]: https://www.governmentciomedia.com/defense-innovation-board-issues-guide-detecting-agile-bs +[9]: https://www.redhat.com/en/solutions/financial-services +[10]: https://www.military.com/daily-news/2020/02/25/dod-agency-suffers-data-breach-potentially-compromising-ssns.html +[11]: https://fcw.com/articles/2020/01/23/dod-devsecops-guidance-williams.aspx +[12]: https://privacyaustralia.net/privacy-tools/ +[13]: https://www.securitymagazine.com/articles/88301-cybersecurity-is-standard-business-practice-for-large-companies diff --git a/published/202007/20200718 Ubuntu 19.10 Reaches End of Life. Upgrade to Ubuntu 20.04 As Soon As Possible.md b/published/202007/20200718 Ubuntu 19.10 Reaches End of Life. Upgrade to Ubuntu 20.04 As Soon As Possible.md new file mode 100644 index 0000000000..a3e48b4bb3 --- /dev/null +++ b/published/202007/20200718 Ubuntu 19.10 Reaches End of Life. Upgrade to Ubuntu 20.04 As Soon As Possible.md @@ -0,0 +1,106 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12446-1.html) +[#]: subject: (Ubuntu 19.10 Reaches End of Life. Upgrade to Ubuntu 20.04 As Soon As Possible!) +[#]: via: (https://itsfoss.com/ubuntu-19-10-end-of-life/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Ubuntu 19.10 产品寿命结束,尽快升级到 Ubuntu 20.04! +====== + +> Ubuntu 19.10 Eoan Ermine 产品寿命结束。这意味着它不会获得任何安全或维护更新。继续使用 Ubuntu 19.10 将很危险,因为你的系统将来可能会因为缺少安全更新而变得脆弱。你应该升级到 Ubuntu 20.04。 + +[2019 年 10 月发布的 Ubuntu 19.10][1] 带来了一些为 [Ubuntu 20.04][2] 做准备的新功能。 + +作为非 LTS 版本,它有 9 个月的寿命。截至 2020 年 7 月 17 日,它的生命周期结束,并不会再收到任何更新。 + +### Ubuntu 19.10 生命周期结束 + +![][3] + +我之前已经[详细解释了 Ubuntu 的发布周期和产品寿命结束][4]。如果此后继续使用 Ubuntu 19.10,我会重申这对你和你的系统意味着什么。 + +[软件通常有预定义的生命周期][5],一旦软件版本到达生命周期结束,它将停止获取更新和支持。生命周期结束后,Ubuntu 19.10 不再会从 Ubuntu 获得系统更新、安全更新或应用更新。 + +如果你继续使用它,你的系统可能会成为潜在的网络攻击的受害者,因为黑客往往会利用脆弱的系统。 + +之后,你可能无法使用 `apt` 命令安装新软件,因为 Ubuntu 将归档 19.10 的仓库。 + +### 如果你使用的是 Ubuntu 19.10,该怎么办? + +首先,[检查你使用的 Ubuntu 版本][6]。这可以在终端中输入此命令完成: + +``` +lsb_release -a +``` + +``` +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 19.10 +Release: 19.10 +Codename: Eoan +``` + +如果你看到 Ubuntu 19.10,你应该做以下两项工作之一: + +* 如果你有良好、稳定的互联网连接,从 Ubuntu 19.10 升级到 20.04。你的个人文件和大多数软件保持不变。 +* 如果你有着缓慢或不稳定的互联网连接,你应该[全新安装的 Ubuntu 20.04][7]。你的文件和磁盘上的所有内容将被擦除,因此你应该在外部磁盘上备份重要数据。 + +#### 如何从 19.10 升级到 20.04 (如果你有良好的互联网连接) + +我之前已经详细讨论了 Ubuntu 版本升级。我会在这里快速说下步骤。 + +首先,请确保在“软件和更新”中已设置接收新版本通知。 + +进入“软件和更新”: + +![][8] + +进入“更新”选项卡,将“通知我新的 Ubuntu 版本”设置为“对于任何新版本”: + +![][9] + +现在,安装所有挂起的更新。 + +现在,再次运行更新管理器工具。你应该可以选择升级到 Ubuntu 20.04。点击升级按钮并按照说明操作。 + +它会安装大约 1.2GB 的软件包。这就是为什么你需要一个良好和稳定的互联网连接。 + +![][10] + +这样的升级会保持你的家目录。不过,仍建议在外部磁盘进行备份。 + +### 你仍在使用 Ubuntu 19.10 吗? + +如果你仍在使用 Ubuntu 19.10,那么必须为升级或全新安装做好准备。你不能忽视它。 + +如果你不喜欢这样的频繁版本升级,你应该使用支持五年的 LTS 版本。当前的 LTS 版本是 Ubuntu 20.04,你无论如何都应该升级到它。 + +你是否正在使用 Ubuntu 19.10?你是否已升级到 Ubuntu 20.04?如果你面临任何问题,或者如果你有任何问题,请让我知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-19-10-end-of-life/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [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/ubuntu-19-10-released/ +[2]: https://itsfoss.com/download-ubuntu-20-04/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/07/ubuntu-19-10-end-of-life.jpg?ssl=1 +[4]: https://itsfoss.com/end-of-life-ubuntu/ +[5]: https://en.wikipedia.org/wiki/Systems_development_life_cycle +[6]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[7]: https://itsfoss.com/install-ubuntu/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/03/upgrade-ubuntu-1.jpeg?ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2017/11/software-update-any-new-version.jpeg?resize=800%2C378&ssl=1 +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/software-updater-focal.jpg?ssl=1 diff --git a/published/202007/20200720 Why People Are Crazy About Arch Linux- What-s so Special About it.md b/published/202007/20200720 Why People Are Crazy About Arch Linux- What-s so Special About it.md new file mode 100644 index 0000000000..5f4ad27495 --- /dev/null +++ b/published/202007/20200720 Why People Are Crazy About Arch Linux- What-s so Special About it.md @@ -0,0 +1,132 @@ +[#]: collector: (lujun9972) +[#]: translator: (Mikedkmilk) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12445-1.html) +[#]: subject: (Why People Are Crazy About Arch Linux? What’s so Special About it?) +[#]: via: (https://itsfoss.com/why-arch-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +为什么人们对 Arch Linux 如此着迷?它有什么特别之处? +====== + +顺便说一句(利益相关),我用 Arch! + +你或许已经在 Linux 论坛、朋友相互讨论或表情包里看到过这个术语。 + +你可能想知道为什么 Arch Linux 如此受欢迎,为什么人们这么喜欢它?因为有更容易使用,甚至更好的[基于 Arch 的发行版][1]。 + +在本文中,我将列出 Linux 用户喜欢使用 [Arch Linux][2] 的一些原因。 + +### 人们喜欢使用 Arch Linux 的六个原因 + +![][3] + +这些只是我的看法,当然,为什么你应该使用 Arch Linux 并没有固定的原因。这是我在十多年里与 Linux 用户和社区打交道的经验中观察到的。 + +让我们一起看看为什么 Arch Linux 如此受欢迎。 + +#### 1、DIY 的方式可以让你掌控操作系统的各个方面 + +我一直认为 Arch Linux 是一个可以让你自己动手打造的操作系统。从安装到管理,Arch Linux 放手让你处理一切。 + +你可以自己决定使用哪种桌面环境、安装哪些组件和服务。这种精细化的控制能够赋予你一个精简的操作系统,可以让你自由选择所需的组件来构建属于你自己的系统。 + +如果你是一个 DIY 爱好者,你会喜欢 Arch Linux 的。 + +#### 2、通过 Arch Linux,可以更好地理解 Linux 的工作原理 + +![Installing Arch Linux by creating partition and making filesystem via command line][4] + +如果你曾经尝试过安装 Arch Linux,你就会知道它的复杂性。 + +但这种复杂性同时也意味着你将被迫学习一些在其他发行版中可能永远不会费心学习的东西。 + +比如说在安装 Arch Linux 过程中配置网络本身就是一个很好的学习课程。 + +如果开始你有感到有困惑不懂的时候,Arch Linux 的[维基][5]可以帮助你。它是互联网上最广泛和最棒的由社区管理的文档。仅仅只是浏览 Arch Linux 的维基,就可以学到很多东西。 + +#### 3、滚动发行模式可以为你提供最新的内核和软件 + +![System update in Arch Linux][6] + +Arch Linux 是一个滚动发行版,这意味着新的内核和应用程序版本一经发布,就会立即向你推送。 + +当大多数其他 [Linux 发行版还在提供旧的 Linux 内核版本][7]时,Arch 会迅速向你提供最新的内核。 + +而软件也是如此。如果 Arch 资源库中的软件发布了新版本,Arch 用户通常会比其他用户先获得新版本。 + +在滚动发行模式下,一切都是新鲜和前沿的。你不必把操作系统从一个版本升级到另一个版本,只要使用 [pacman 命令][8],你会始终保持最新的版本。 + +#### 4、Arch 用户资源库,即 AUR + +![][9] + +Arch Linux 的资源库中有大量的软件。AUR 扩展了 Arch Linux 的软件产品。在 Arch Linux 中,你可以通过 [AUR][10] 得到相当多的软件。 + +AUR 是采用社区驱动的方式来提供更新的应用程序。你可以在 [AUR 辅助工具][11]的帮助下搜索和安装应用程序。 + +#### 5、成就感 + +![][12] + +正如 James Clear 在他的书《原子习惯Atomic Habits》中提到的那样,**人类的大脑喜欢挑战,但前提是在一个最理想的困难区域**。 + +还记得你第一次安装成功 Linux 时的感觉吗?即便你安装的是 Linux Mint。这给了你一种成就感:你成功安装了 Linux! + +如果你已经使用 Ubuntu、Fedora 或其他发行版一段时间了,现在开始感到舒适(或厌倦),你可以尝试安装一下 Arch Linux。 + +对于一个有一定经验的 Linux 用户来说,[成功安装 Arch Linux][13]本身就会给你一种成就感。 + +这是一个挑战,但却是可以实现的。如果你建议一个新的 Linux 用户尝试 Arch Linux 或者更复杂的 Linux 发行版比如 [Linux From Scratch(LFS)][14],这个挑战就太难实现了。 + +这种成功完成挑战的感觉也是人们使用 Arch Linux 的原因之一。 + +#### 6、没有企业的参与!Arch 是由社区创建、支持和拥有的 + +Ubuntu 由 Canonical 支持,Fedora 来自 Red Hat(现在是 IBM 的一部分),openSUSE 来自 SUSE。所有这些主流发行版都是企业支持的。 + +这本身并不是坏事或过错,但是有一些人不喜欢企业参与开源项目。 + +正如 Debian 一样,Arch Linux 是为数不多的仅由社区参与的 Linux 发行项目之一。 + +你可能会指出,许多其他发行版如 Linux Mint 等不是由企业赞助的。好吧,这可能是真的,但 Linux Mint 本身就是基于 Ubuntu 的,并且使用 Ubuntu 的资源库。而 Arch Linux 不是另一个发行版的衍生物。 + +从这个意义上说,[Debian][15] 和 Arch Linux 是更纯粹的社区驱动项目。这对很多人来说可能无关紧要,但确实有一些人在意这些事情。 + +#### 对你来说,为什么 Arch Linux 如此受欢迎? + +现在你可能不同意我提出的所有观点,那没关系。我想知道你是怎么看待 Arch Linux 在 Linux 用户中如此受欢迎,并具有崇拜的地位的? + +当你写评论时,让我分享一下“我用 Arch”的表情包 :) + +![](https://scontent-fml2-1.xx.fbcdn.net/v/t1.0-0/p526x296/109618601_1759578370849589_736435313539592753_o.jpg?_nc_cat=100&_nc_sid=8024bb&_nc_ohc=MYp_pidAMBMAX8z24Mc&_nc_ht=scontent-fml2-1.xx&_nc_tp=6&oh=9c2bf18b620cf90edb2dd32625b03b41&oe=5F3E8F39) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/why-arch-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[Mikedkmilk](https://github.com/Mikedkmilk) +校对:[wxy](https://github.com/wxy) + +本文由 [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/arch-based-linux-distros/ +[2]: https://www.archlinux.org/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/07/why-arch-linux.jpg?ssl=1 +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/01/efi_system_partition-1.png?ssl=1 +[5]: https://wiki.archlinux.org/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/sudo-pacman-Syu.png?ssl=1 +[7]: https://itsfoss.com/why-distros-use-old-kernel/ +[8]: https://itsfoss.com/pacman-command/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/01/AUR.png?resize=800%2C451&ssl=1 +[10]: https://itsfoss.com/aur-arch-linux/ +[11]: https://itsfoss.com/best-aur-helpers/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/installed-arch-linux.png?ssl=1 +[13]: https://itsfoss.com/install-arch-linux/ +[14]: http://www.linuxfromscratch.org/ +[15]: https://www.debian.org/ diff --git a/published/202007/20200727 Getting started as an open source builder and more industry trends.md b/published/202007/20200727 Getting started as an open source builder and more industry trends.md new file mode 100644 index 0000000000..769f5a9af1 --- /dev/null +++ b/published/202007/20200727 Getting started as an open source builder and more industry trends.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12461-1.html) +[#]: subject: (Getting started as an open source builder and more industry trends) +[#]: via: (https://opensource.com/article/20/7/open-source-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +每周开源点评:开源建设者入门,以及更多的行业趋势 +====== + +> 每周关注开源社区和行业趋势。 + +![](https://img.linux.net.cn/data/attachment/album/202007/28/175317mgsvgtvstvcggsch.jpg) + +我在一家采用开源软件开发模型的企业软件公司任高级产品营销经理,我的一部分职责是为产品营销人员、经理和其他相关人定期发布有关开源社区、市场和业界发展趋势的更新。以下是该更新中我和他们最喜欢的五篇文章。 + +### 《[开放源码建设者:入门][2]》 + +> "最后,我发现自己想要自己修改代码,"Liz 说。她的第一个贡献是为 Django 框架做了一个授权扩展。她补充说:"我记得当时我很担心维护者可能不希望一个完全陌生的人做的改动,所以当它被接受时,我感到很兴奋,也很欣慰……得到认可,甚至感谢你的贡献,这种感觉总是很好。" + +**分析:** 这一系列对开源维护者的采访(引自 [Liz Rice][3])交汇了跳入开源领域的动机和经验。这也是对天才独狼开发者神话的一个点赞,你可以自己走很远的路,但如果你知道如何与其他人很好地合作,你会走得更远,建立更好的东西。如果你知道如何说服和激励他们,你会走得更远。 + +### 《[Fluent Bit v1.5:轻量级和高性能日志处理器][4]》 + +> 本次主要版本的最大亮点之一是不同公司与 Fluent Bit 核心维护者的联合工作,为 Google、Amazon、LogDNA、New Relic 和 Sumo Logic 等公司内部提供的可观察性云服务带来了改进和新的连接器。 + +**分析:** “从不同来源收集数据/日志,统一并将其发送到多个目的地”是一项繁琐的任务,但这是超大规模企业及其客户共同的任务。证据 A:一个开源工作完全如其预期的典型例子。祝贺 Fluent Bit 团队的这次发布! + +### 《[Kubernetes 如何让 Nubank 工程师每周部署 700 次][5]》 + +> 因此,生产环境的部署时间从 90 分钟变成了 15 分钟。而 Nobre 说,这是“最主要的好处,因为它有助于开发人员的体验”。如今,Nubank 的工程师每周部署 700 次。“对于一家银行来说,你会说这太疯狂了,”Capaverde 笑着说。“但这并不疯狂,因为有了 Kubernetes 和金丝雀部署,回滚变化更容易,因为部署速度也更快。人们的出货频率更高,更有信心。” + +**分析:** 我觉得这是个赢家,也是个输家。当然,他们降低了做出改变的成本,以一种让人们更有信心去尝试的方式。但他们的开发人员不能再在等待部署完成的同时跑 10 公里,现在只能在一次 TED 演讲中凑合。 + +希望你喜欢这个列表,下周再见。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/open-source-industry-trends + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://idk.dev/open-source-builders-getting-started/ +[3]: https://twitter.com/lizrice +[4]: https://www.cncf.io/blog/2020/07/14/fluent-bit-v1-5-lightweight-and-high-performance-log-processor/ +[5]: https://www.cncf.io/blog/2020/07/10/how-kubernetes-empowered-nubank-engineers-to-deploy-200-times-a-week/ diff --git a/published/202007/20200730 Defining cloud native, expanding the ecosystem, and more industry trends.md b/published/202007/20200730 Defining cloud native, expanding the ecosystem, and more industry trends.md new file mode 100644 index 0000000000..d5a52e2a1b --- /dev/null +++ b/published/202007/20200730 Defining cloud native, expanding the ecosystem, and more industry trends.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12473-1.html) +[#]: subject: (Defining cloud native, expanding the ecosystem, and more industry trends) +[#]: via: (https://opensource.com/article/20/7/cloud-native-expanding-and-more-industry-trends) +[#]: author: (Tim Hildred https://opensource.com/users/thildred) + +每周开源点评:定义云原生、拓展生态系统,以及更多的行业趋势 +====== + +> 每周关注开源社区和行业趋势。 + +![](https://img.linux.net.cn/data/attachment/album/202007/31/235751f5zd9l3rejd2tjss.jpg) + +我在一家采用开源软件开发模型的企业软件公司任高级产品营销经理,我的一部分职责是为产品营销人员、经理和其他相关人定期发布有关开源社区、市场和业界发展趋势的更新。以下是该更新中我和他们最喜欢的几篇文章。 + +### 《随着云原生计算的兴起,它和代码一样在改变文化》 + +- [文章链接][2] + +> 现在是围绕一套云原生计算的共同原则进行行业整合的时候了,因为许多企业已经意识到,他们最初进入云计算的回报有限。国际数据公司去年的一项调查发现,[80% 的受访者曾将工作负载从公有云环境遣返到企业内部][3],平均而言,他们预计在未来两年内将一半的公有云应用转移到私有场所。 + +**分析**:在云端的第一次运行主要是大量的“提升和转移”尝试,以提取工作负载并将其投放到云端。第二次运行将涉及更多的工作,以确定转移什么以及如何转移,但随着开发人员对理所当然的事情越来越满意,最终应该会带来更多价值。 + +### 《为什么云原生基础设施的自动化是所有参与者的胜利》 + +- [文章链接][4] + +> 开发的圣杯是创建和维护安全的应用程序,产生强大的投资回报率和满意的客户。但如果这种开发不是高效、高速和可扩展的,那么这个圣杯很快就会变得遥不可及。如果你发现自己对当前的基础设施有更高的期望,那么可能是时候考虑云原生了。它不仅可以检查所有这些机器,而且为云原生基础设施进行自动化可以提高效率和结果。 + +**分析**:我还要补充一点,如果没有大量的自动化,真正采用云原生方法是不可能的;涉及的移动部件数量太多,不可能用人的头脑来处理。 + +### 《Linkerd 案例研究:满足安全要求、减少延迟和从 Istio 迁移》 + +- [文章链接][5] + +> 最后,Subspace 分享了其使用 Linkerd 提供“光速”多人游戏的经验。虽然在超低延迟环境中使用服务网状物起初似乎有悖常理,但 Subspace 发现 Linkerd 的战略使用实际上降低了总延迟 —— 服务网状物是如此轻巧,以至于它增加的最小延迟被它通过可观察性降低的延迟所掩盖。简而言之,Linkerd 的这一独特用例使 Subspace 在运营结果上获得了巨大的净收益。[阅读完整的用户故事][6]。 + +**分析**:我听说过这样一个观点:你并不能真正降低一个系统的复杂性,你只是把它抽象化,改变它的接触对象。似乎对延迟也有类似的观察:如果你仔细选择你接受延迟的地方,你可以因此减少系统中其他地方的延迟。 + +### 一位高层管理人员解释了 IBM 的“重要支点”,以赢得开发者、初创企业和合作伙伴的青睐,这是其从微软等竞争对手手中赢得混合云市场计划的一部分 + +- [文章链接][7] + +> 蓝色巨人正在转向一个新的战略,专注于建立一个由开发者、合作伙伴和初创公司组成的生态系统。“我们的服务组织无法接触到所有客户。获取这些客户的唯一方法是激活一个生态系统。” + +**分析**:越来越多的公司开始接受这样的理念:有些客户的问题,他们没有帮助就无法解决。也许这可以减少从每个单独客户身上赚到的钱,因为它扩大了更广泛地参与更多问题空间的机会。 + +希望你喜欢这个列表,下周再见。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/cloud-native-expanding-and-more-industry-trends + +作者:[Tim Hildred][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/thildred +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://siliconangle.com/2020/07/18/cloud-native-computing-rises-transforming-culture-much-code/ +[3]: https://www.networkworld.com/article/3400872/uptick-in-cloud-repatriation-fuels-rise-of-hybrid-cloud.html +[4]: https://thenewstack.io/why-automating-for-cloud-native-infrastructures-is-a-win-for-all-involved/ +[5]: https://www.cncf.io/blog/2020/07/21/linkerd-case-studies-meeting-security-requirements-reducing-latency-and-migrating-from-istio/ +[6]: https://buoyant.io/case-studies/subspace/ +[7]: https://www.businessinsider.com/ibm-developers-tech-ecosystem-red-hat-hybrid-cloud-bob-lord-2020-7?r=AU&IR=T diff --git a/published/202007/20200731 Beginner-friendly Terminal-based Text Editor GNU Nano Version 5.0 Released.md b/published/202007/20200731 Beginner-friendly Terminal-based Text Editor GNU Nano Version 5.0 Released.md new file mode 100644 index 0000000000..c5b64697b1 --- /dev/null +++ b/published/202007/20200731 Beginner-friendly Terminal-based Text Editor GNU Nano Version 5.0 Released.md @@ -0,0 +1,66 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12471-1.html) +[#]: subject: (Beginner-friendly Terminal-based Text Editor GNU Nano Version 5.0 Released) +[#]: via: (https://itsfoss.com/nano-5-release/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +适于初学者的基于终端的文本编辑器 GNU Nano 5.0 版发布 +====== + +> 开源文本编辑器 GNU nano 已经达到了 5.0 版本的里程碑。看看这个新版本带来了哪些功能。 + +Linux 上有很多[基于终端的文本编辑器][1]。像 Emacs 和 Vim 这样的编辑器需要经历陡峭的学习曲线和掌握一堆不寻常的键盘快捷键,但公认 GNU nano 更容易使用。 + +也许这就是为什么 Nano 是 Ubuntu 和许多其他发行版中默认的基于终端的文本编辑器的原因,而即将发布的 [Fedora 33 版本][2]也将把 Nano 设置为终端的默认文本编辑器。 + +### GNU nano 5.0 的新功能 + +![][3] + +在 GNU nano 5.0 的[变更日志][4]中提到的一些主要亮点是: + +* `-indicator` 选项将在屏幕右侧显示一种滚动条,以指示视口在缓冲区中的位置和覆盖范围。 +* 可以用 `Alt+Insert` 键标记行,你可以用 `Alt+Page` 和 `Alt+PageDown` 键跳转到这些标记的行。 +* 执行命令提示符现在可以直接从主菜单中访问。 +* 在支持至少 256 种颜色的终端上,有新的颜色可用。 +* 新的 `-bookstyle` 模式,任何以空格开头的行都会被认为是一个段落的开始。 +* 用 `^L` 刷新屏幕现在在每个菜单中都可以使用。它还会将行与光标居中。 +* 可绑定函数 `curpos` 已经改名为 `location`,长选项 `-tempfile` 已经改名为 `-saveonexit`,短选项 `-S` 现在是 `-softwrap` 的同义词。 +* 备份文件将保留其组的所有权(如果可能的话)。 +* 数据会在显示 “……行写入” 之前同步到磁盘。 +* 增加了 Markdown、Haskell 和 Ada 语法的支持。 + +### 获取 GNU nano 5.0 + +目前 Ubuntu 20.04 中的 nano 版本是 4.8,而在这个 LTS 版本中,你不太可能在短时间内获得新版本。如果 Ubuntu 有新版本的话,你应该会通过系统更新得到它。 + +Arch 用户应该会比其他人更早得到它,就像往常一样。其他发行版也应该迟早会提供新版本。 + +如果你是少数喜欢[从源代码安装软件][5]的人,你可以从它的[下载页面][6]中获得。 + +如果你是新手,我强烈推荐这篇 [Nano 编辑器初学者指南][1]。 + +你喜欢这个新版本吗?你期待使用 Nano 5 吗? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/nano-5-release/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [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/nano-editor-guide/ +[2]: https://itsfoss.com/fedora-33/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/09/Nano.png?ssl=1 +[4]: https://www.nano-editor.org/news.php +[5]: https://itsfoss.com/install-software-from-source-code/ +[6]: https://www.nano-editor.org/download.php diff --git a/published/20200710 Use DNS over TLS.md b/published/20200710 Use DNS over TLS.md new file mode 100644 index 0000000000..9b55039cf6 --- /dev/null +++ b/published/20200710 Use DNS over TLS.md @@ -0,0 +1,171 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12483-1.html) +[#]: subject: (Use DNS over TLS) +[#]: via: (https://fedoramagazine.org/use-dns-over-tls/) +[#]: author: (Thomas Bianchi https://fedoramagazine.org/author/thobianchi/) + +使用 DNS over TLS +====== + +![][1] + +现代计算机用来在互联网种查找资源的[域名系统(DNS)][2] 是在 [35 年前][3]设计的,没有考虑用户隐私。它会面临安全风险和攻击,例如 [DNS 劫持][4]。它还能让 [ISP][5] 拦截查询。 + +幸运的是,现在有 [DNS over TLS][6] 和 [DNSSEC][7] 两种技术。DNS over TLS 和 DNSSEC 允许创建从计算机到它配置的 DNS 服务器之间的安全且加密的端到端隧道。在 Fedora 上,部署这些技术的步骤很容易,并且所有必要的工具也很容易获得。 + +本指南将演示如何使用 `systemd-resolved` 在 Fedora 上配置 DNS over TLS。有关 `systemd-resolved` 服务的更多信息,请参见[文档][8]。 + +### 步骤 1:设置 systemd-resolved + +类似于下面所示修改 `/etc/systemd/resolved.conf`。确保启用 DNS over TLS 并配置要使用的 DNS 服务器的 IP 地址。 + +``` +$ cat /etc/systemd/resolved.conf +[Resolve] +DNS=1.1.1.1 9.9.9.9 +DNSOverTLS=yes +DNSSEC=yes +FallbackDNS=8.8.8.8 1.0.0.1 8.8.4.4 +#Domains=~. +#LLMNR=yes +#MulticastDNS=yes +#Cache=yes +#DNSStubListener=yes +#ReadEtcHosts=yes +``` + +关于选项的简要说明: + + * `DNS`:以空格分隔的 IPv4 和 IPv6 地址列表,用作系统 DNS 服务器。 + * `FallbackDNS`:以空格分隔的 IPv4 和 IPv6 地址列表,用作后备 DNS 服务器。 + * `Domains`:在解析单标签主机名时,这些域名用于搜索后缀。 `~.` 代表对于所有域名,优先使用 `DNS=` 定义的系统 DNS 服务器。 + * `DNSOverTLS`:如果启用,那么将加密与服务器的所有连接。请注意,此模式要求 DNS 服务器支持 DNS-over-TLS,并具有其 IP 的有效证书。 + +> 注意:上面示例中列出的 DNS 服务器是我个人的选择。你要确定要使用的 DNS 服务器。要注意你要向谁请求 IP。 + +### 步骤 2:告诉 NetworkManager 将信息推给 systemd-resolved + +在 `/etc/NetworkManager/conf.d` 中创建一个名为 `10-dns-systemd-resolved.conf` 的文件。 + +``` +$ cat /etc/NetworkManager/conf.d/10-dns-systemd-resolved.conf +[main] +dns=systemd-resolved +``` + +上面的设置(`dns=systemd-resolved`)让 `NetworkManager` 将从 DHCP 获得的 DNS 信息推送到 `systemd-resolved` 服务。这将覆盖*步骤 1* 中配置的 DNS 设置。这在受信任的网络中没问题,但是也可以设置为 `dns=none` 从而使用 `/etc/systemd/resolved.conf` 中配置的 DNS 服务器。 + +### 步骤 3: 启动和重启服务 + +若要使上述步骤中的配置生效,请启动并启用 `systemd-resolved` 服务。然后重启 `NetworkManager` 服务。 + +注意:在 `NetworkManager` 重启时,连接会中断几秒钟。 + +``` +$ sudo systemctl start systemd-resolved +$ sudo systemctl enable systemd-resolved +$ sudo systemctl restart NetworkManager +``` + +> 注意:目前,systemd-resolved 服务默认处于禁用状态,是可选使用的。[有计划][33]在 Fedora 33 中默认启用systemd-resolved。 + +### 步骤 4:检查是否一切正常 + +现在,你应该在使用 DNS over TLS。检查 DNS 解析状态来确认这一点: + +``` +$ resolvectl status +MulticastDNS setting: yes + DNSOverTLS setting: yes + DNSSEC setting: yes + DNSSEC supported: yes + Current DNS Server: 1.1.1.1 + DNS Servers: 1.1.1.1 + 9.9.9.9 +Fallback DNS Servers: 8.8.8.8 + 1.0.0.1 + 8.8.4.4 +``` + +`/etc/resolv.conf` 应该指向 `127.0.0.53`。 + +``` +$ cat /etc/resolv.conf +# Generated by NetworkManager +search lan +nameserver 127.0.0.53 +``` + +若要查看 `systemd-resolved` 发送和接收安全查询的地址和端口,请运行: + +``` +$ sudo ss -lntp | grep '\(State\|:53 \)' +State Recv-Q Send-Q Local Address:Port Peer Address:Port Process +LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:* users:(("systemd-resolve",pid=10410,fd=18)) +``` + +若要进行安全查询,请运行: + +``` +$ resolvectl query fedoraproject.org +fedoraproject.org: 8.43.85.67 -- link: wlp58s0 + 8.43.85.73 -- link: wlp58s0 + +[..] + +-- Information acquired via protocol DNS in 36.3ms. +-- Data is authenticated: yes +``` + +### 额外步骤 5:使用 Wireshark 验证配置 + +首先,安装并运行 [Wireshark][10]: + +``` +$ sudo dnf install wireshark +$ sudo wireshark +``` + +它会询问你在哪个设备上捕获数据包。在我这里,因为我使用无线接口,我用的是 `wlp58s0`。在 Wireshark 中设置筛选器,`tcp.port == 853`(853 是 DNS over TLS 协议端口)。在捕获 DNS 查询之前,你需要刷新本地 DNS 缓存: + +``` +$ sudo resolvectl flush-caches +``` + +现在运行: + +``` +$ nslookup fedoramagazine.org +``` + +你应该会看到你的计算机和配置的 DNS 服务器之间的 TLS 加密交换: + +![][11] + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/use-dns-over-tls/ + +作者:[Thomas Bianchi][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/thobianchi/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/06/use-dns-over-tls-816x345.jpg +[2]: https://en.wikipedia.org/wiki/Domain_Name_System +[3]: https://tools.ietf.org/html/rfc1035 +[4]: https://en.wikipedia.org/wiki/DNS_hijacking +[5]: https://en.wikipedia.org/wiki/Internet_service_provider +[6]: https://en.wikipedia.org/wiki/DNS_over_TLS +[7]: https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions +[8]: https://www.freedesktop.org/wiki/Software/systemd/resolved/ +[9]: https://fedoraproject.org/wiki/Changes/systemd-resolved +[10]: https://www.wireshark.org/ +[11]: https://fedoramagazine.org/wp-content/uploads/2020/06/1-1024x651.png diff --git a/published/20200717 How to configure an SSH proxy server with Squid.md b/published/20200717 How to configure an SSH proxy server with Squid.md new file mode 100644 index 0000000000..5062eb7245 --- /dev/null +++ b/published/20200717 How to configure an SSH proxy server with Squid.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12476-1.html) +[#]: subject: (How to configure an SSH proxy server with Squid) +[#]: via: (https://fedoramagazine.org/configure-ssh-proxy-server/) +[#]: author: (Curt Warfield https://fedoramagazine.org/author/rcurtiswarfield/) + +如何使用 Squid 配置 SSH 代理服务器 +====== + +![](https://img.linux.net.cn/data/attachment/album/202008/01/162730tx0czx60xs6wz00c.jpg) + +有时你无法从本地连接到 SSH 服务器。还有时,你可能想为 SSH 连接添加额外的安全层。在这些情况下,通过代理服务器连接到 SSH 服务器是一种解决方式。 + +[Squid][2] 是提供缓存和代理服务的全功能代理服务器应用。它通常用于在浏览过程中重用和缓存以前请求的网页来帮助缩短响应时间并减少网络带宽。 + +但是在本篇中,你将配置 Squid 作为 SSH 代理服务器,因为它是强大的受信任代理服务器,易于配置。 + +### 安装和配置 + +使用 [sudo][3] 安装 squid 软件包: + +``` +$ sudo dnf install squid -y +``` + +squid 配置文件非常庞大,但是我们只需要配置其中一些。Squid 使用访问控制列表来管理连接。 + +编辑 `/etc/squid/squid.conf` 文件,确保你有下面解释的两行。 + +首先,指定你的本地 IP 网络。默认配置文件已经列出了最常用的,但是如果没有,你需要添加你的配置。例如,如果你的本地 IP 网络范围是 192.168.1.X,那么这行会是这样: + +``` +acl localnet src 192.168.1.0/24 +``` + +接下来,添加以下行,将 SSH 端口添加为安全端口: + +``` +acl Safe_ports port 22 +``` + +保存该文件。现在启用并重启 squid 代理服务: + +``` +$ sudo systemctl enable squid +$ sudo systemctl restart squid +``` + +squid 代理默认监听 3128 端口。配置 firewalld 允许此服务: + +``` +$ sudo firewall-cmd --add-service=squid --perm +$ sudo firewall-cmd --reload +``` + +### 测试 ssh 代理连接 + +要通过 ssh 代理服务器连接到服务器,我们将使用 `netcat`。 + +如果尚未安装 `nmap-ncat`,请安装它: + +``` +$ sudo dnf install nmap-ncat -y +``` + +这是标准 ssh 连接示例: + +``` +$ ssh user@example.com +``` + +这是使用 squid 代理服务器作为网关连接到该服务器的方式。 + +此示例假定 squid 代理服务器的 IP 地址为 192.168.1.63。你还可以使用 squid 代理服务器的主机名或 FQDN: + +``` +$ ssh user@example.com -o "ProxyCommand nc --proxy 192.168.1.63:3128 %h %p" +``` + +以下是这些选项的含义: + + * `ProxyCommand` – 告诉 ssh 使用代理命令。 + * `nc` – 用于建立与代理服务器连接的命令。这是 netcat 命令。 + * `%h` – 代理服务器的主机名或 IP 地址的占位符。 + * `%p` – 代理服务器端口号的占位符。 + +有很多方法可以配置 SSH 代理服务器,但这是入门​​的简单方法。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/configure-ssh-proxy-server/ + +作者:[Curt Warfield][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/rcurtiswarfield/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/07/squid_ssh_proxy-816x345.png +[2]: http://www.squid-cache.org/ +[3]: https://fedoramagazine.org/howto-use-sudo/ diff --git a/published/20200720 Balloon-powered internet service goes live in Kenya.md b/published/20200720 Balloon-powered internet service goes live in Kenya.md new file mode 100644 index 0000000000..782f7bae60 --- /dev/null +++ b/published/20200720 Balloon-powered internet service goes live in Kenya.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (JonnieWayy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12485-1.html) +[#]: subject: (Balloon-powered internet service goes live in Kenya) +[#]: via: (https://www.networkworld.com/article/3566295/balloon-powered-internet-service-goes-live-in-kenya.html) +[#]: author: (Patrick Nelson https://www.networkworld.com/author/Patrick-Nelson/) + +气球驱动的互联网服务在肯尼亚上线 +====== + +> Alphabet 的衍生产品 [Loon][1] 使用气球创建了一个由蜂窝塔构成的漂浮网络。 + +![](https://images.idgesg.net/images/article/2020/07/loon-aerial-100852193-large.jpg) + +ISP [Telkom Kenya][2] 正在启动第一个使用气球的商业化 4G LTE 服务,气球的作用是在漂浮在平流层中作为蜂窝塔网络。 + +据 Alphabet 的衍生产品及底层技术提供商 [Loon][1] 的首席执行官 Alastair Westgarth 所说,这项服务起初将会覆盖肯尼亚接近 19000 平方英里的范围。 Westgarth 在 [Medium][3] 上的一篇文章中说,将会有大约 35 个或更多的气球组成编队,它们持续不断地移动,漂浮在地表上方大约 12 英里的平流层中。“我们将 Loon 称为漂浮的蜂窝塔网络。” Westgarth 说道。 + +Telkom Kenya 的首席执行官 Mugo Kibati 在一篇[新闻稿][4]中提到,传统互联网对肯尼亚的服务不足,这是采用这种输送装置的原因。“…… 具有互联网功能的气球能够为生活在偏远地区的许多肯尼亚人提供联系,这些地区服务不足或是完全没有服务,仍然处于不利地位。” Kibati 说道。远程医疗和在线教育是两个预期的用例。 + +在测试中, Loon 实现了 19 毫秒延迟的 18.9 Mbps 下行速度,以及 4.74 Mbps 的上行速度。 Westgarth 说,该服务能够用于“语音通话、视频通话、 YouTube、 WhatsApp、电子邮件、发短信、网页浏览”和其他应用程序。 + +从更大的角度看,从平流层提供互联网服务对于[物联网(IoT )][5]来说是一个诱人的主张。在高空,网络覆盖范围可能会更广泛,并且覆盖范围可以随着需求的变化而变化(例如,采矿区的移动)。此外,要建立或处理的地面基础设施更少。 比方说,开发人员可以避免铺设电缆所需的私有地产的纠纷。 + +可以想象,服务中断也更加可控。提供商可以发射另一台设备,而不必通过复杂的远程地面基础设施来跟踪故障。备用气球可随时备用。 + +### 基于无人机的互联网交付 + +另一家正在探索大气层互联网的组织是软银,它称其 260 英尺宽的 HAWK30 无人机是“平流层中的漂浮基站”。(参见相关故事:[软银计划到 2023 年实现无人机交付的物联网和互联网][6]) + +日本大型电信公司对平流层传输的互联网感兴趣的原因之一是,该群岛易于发生自然灾害,例如地震。与传统的基站相比,地球上空的浮动基站更容易移动,从而可以更快、更灵活地应对自然灾害。 + +实际上,Loon 的气球已经成功地用于在灾难后提供互联网服务:例如,在 2017 年波多黎各的飓风 Maria 之后,Loon 提供了连接。 + +Westgarth 说,自最初开发以来,Loon 的气球已经取得了长足的发展。现如今,发射是通过自动设备执行的,该设备可以每半小时一次将与地面站点相连的气球推到 60000 英尺高空,而不像以前那样人工进行。 + +机器学习算法会处理导航,以尝试向用户提供持续的服务。但是,这并非总是可能的,因为风(尽管在地面上没有那么大)和受限的空域都会影响覆盖范围,尽管 Westgarth 称之为“精心编排组织的气球舞蹈”。 + +此外,这些设备是太阳能供电的,这意味着它们只能够在白天工作并提供互联网(或重新定位自身,或向其他气球传输互联网)。出于上述原因和其他的一些原因, Westgarth 和 Kibati 指出,气球必须扩大现有的基础设施和计划,但这并不是一个完整的解决方案。 + +Westgarth 说:“为了连接现在和将来需要它的所有人员和事物,我们需要开阔我们的思维;我们需要在连通性生态系统中增加新的一层。” + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3566295/balloon-powered-internet-service-goes-live-in-kenya.html + +作者:[Patrick Nelson][a] +选题:[lujun9972][b] +译者:[JonnieWayy](https://github.com/JonnieWayy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Patrick-Nelson/ +[b]: https://github.com/lujun9972 +[1]: https://loon.com/ +[2]: https://www.telkom.co.ke/ +[3]: https://medium.com/loon-for-all/loon-is-live-in-kenya-259d81c75a7a +[4]: https://telkom.co.ke/telkom-and-loon-announce-progressive-deployment-loon-technology-customers-july +[5]: https://www.networkworld.com/article/3207535/what-is-iot-the-internet-of-things-explained.html +[6]: https://www.networkworld.com/article/3405170/softbank-plans-drone-delivered-iot-and-internet-by-2023.html +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/published/20200721 Video Trimmer- A No-nonsense, Simple Video Trimming Application for Linux Desktop.md b/published/20200721 Video Trimmer- A No-nonsense, Simple Video Trimming Application for Linux Desktop.md new file mode 100644 index 0000000000..1be71f5264 --- /dev/null +++ b/published/20200721 Video Trimmer- A No-nonsense, Simple Video Trimming Application for Linux Desktop.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12480-1.html) +[#]: subject: (Video Trimmer: A No-nonsense, Simple Video Trimming Application for Linux Desktop) +[#]: via: (https://itsfoss.com/video-trimmer/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Video Trimmer:Linux 桌面中的傻瓜级的视频修剪应用 +====== + +> 一个非常简单的工具,无需重新编码即可快速修剪视频。我们来看看它提供了什么。 + +你可能已经知道 Linux 的一些[最佳免费视频编辑器][1],但并不是每个人都需要它们提供的所有功能。 + +有时,你只想快速执行一项操作,例如修剪视频。你是选择探索功能完善的视频编辑器但只是执行简单的修剪操作,还是希望使用便捷工具来修剪视频? + +当然,这取决于你的个人喜好以及处理视频的方式。但是,对于大多数用户而言,首选是使用非常容易使用的修剪工具。 + +因此,我想重点介绍一个傻瓜级的开源工具,即 “[Video Trimmer][2]”,它可以快速修剪视频。 + +![][3] + +### Video Trimmer:一个用于快速修剪视频的傻瓜应用 + +Video Trimmer 是一个开源应用,它可帮助你修剪视频片段而无需重新编码。因此,基本上,你可以能够修剪视频而不会失去原始质量。 + +你要做的就是使用 Video Trimmer 打开视频文件,然后使用鼠标选择要修剪的时间区域。 + +你可以手动设置要修剪的时间范围,也可以仅使用鼠标拖动区域进行修剪。当然,如果视频文件很长,而且你不知道从哪里看,手动设置时间戳可能需要一段时间。 + +为了让你有个印象,请看下面的截图,看看在使用 Video Trimmer 时可用的选项: + +![][4] + +### 在 Linux 上安装 Video Trimmer + +Video Trimmer 仅作为 [Flathub][5] 上的 Flatpak 软件包提供。因此,你应该能够在 Flatpak 支持的任何 Linux 发行版上安装它,而不会出现任何问题。 + +以防你不了解 Flatpak,你可能想要参考我们的[使用和安装 Flatpak][6] 指南。 + +- [下载 Video Trimmer(Flathub)][5] + +### 总结 + +Video Trimmer 底层使用 [ffmpeg][7]。它所做的可以在终端中轻松[使用 ffmpeg 命令][8]完成。但是,并非所有人都希望使用终端来剪辑视频的一部分。Video Trimmer 之类的工具可以帮助像我这样的人。 + +由于某些原因,如果你想寻找一种替代方法,也可以尝试使用 [VidCutter][9]。当然,你始终可以依靠 [Linux 中的顶级视频编辑器][10](例如 [OpenShot][11]) 来修剪视频以及执行一些高级操作的能力。 + +你认为在 Linux 中使用 Video Trimmer 如何?你是否有其他喜欢的视频修剪工具?在下面的评论中让我知道你的想法! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/video-trimmer/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://itsfoss.com/open-source-video-editors/ +[2]: https://gitlab.gnome.org/YaLTeR/video-trimmer +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/video-trimmer.jpg?ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/video-trimmer-screenshot.jpg?ssl=1 +[5]: https://flathub.org/apps/details/org.gnome.gitlab.YaLTeR.VideoTrimmer +[6]: https://itsfoss.com/flatpak-guide/ +[7]: https://ffmpeg.org/ +[8]: https://itsfoss.com/ffmpeg/ +[9]: https://itsfoss.com/vidcutter-video-editor-linux/ +[10]: https://linux.cn/article-10185-1.html +[11]: https://itsfoss.com/openshot-video-editor-release/ diff --git a/published/20200722 The feature that makes D my favorite programming language.md b/published/20200722 The feature that makes D my favorite programming language.md new file mode 100644 index 0000000000..74ecc7473c --- /dev/null +++ b/published/20200722 The feature that makes D my favorite programming language.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12489-1.html) +[#]: subject: (The feature that makes D my favorite programming language) +[#]: via: (https://opensource.com/article/20/7/d-programming) +[#]: author: (Lawrence Aberba https://opensource.com/users/aberba) + +我最喜欢的 D 语言功能 +====== + +> UFCS 能让你能够编写自然的可重用代码而不会牺牲便利性。 + +![](https://img.linux.net.cn/data/attachment/album/202008/05/215524d9j62oui7mgm7ms9.jpg) + +早在 2017 年,我就写过为什么 [D 语言是开发的绝佳选择][2]的文章。但是 D 语言中有一个出色的功能我没有充分的展开介绍:[通用函数调用语法][3]Universal Function Call Syntax(UFCS)。UFCS 是 D 语言中的一种[语法糖][4],它可以在类型(字符串、数字、布尔值等)上链接任何常规函数,就像该类型的成员函数一样。 + +如果你尚未安装 D 语言,请[安装 D 语言编译器][5],以便你可以自己[运行 D 代码][6]。 + +看一下以下示例代码: + +``` +// file: ufcs_demo.d + +module ufcs_demo; + +import std.stdio : writeln; + +int[] evenNumbers(int[] numbers) +{ + import std.array : array; + import std.algorithm : filter; + + return numbers.filter!(n => n % 2 == 0).array; +} + +void main() +{ + writeln(evenNumbers([1, 2, 3, 4])); +} +``` + +使用你喜欢的 D 语言编译器进行编译,查看这个简单示例应用做了什么: + +``` +$ dmd ufcs_demo.d +$ ./ufcs_demo +[2, 4] +``` + +但是,使用作为 D 语言的内置功能的 UFCS ,你还可以自然方式编写代码: + +``` +... +writeln([1, 2, 3, 4].evenNumbers()); +... +``` + +或完全删除现在多余的括号,使 `evenNumbers` 看起来像是一个属性: + +``` +... +writeln([1, 2, 3, 4].evenNumbers); // prints 2, 4 +... +``` + +因此,完整的代码现在变为: + +``` +// file: ufcs_demo.d + +module ufcs_demo; + +import std.stdio : writeln; + +int[] evenNumbers(int[] numbers) +{ + import std.array : array; + import std.algorithm : filter; + + return numbers.filter!(n => n % 2 == 0).array; +} + +void main() +{ + writeln([1, 2, 3, 4].evenNumbers); +} +``` + +使用你最喜欢的 D 语言编译器进行编译,然后尝试一下。 如预期的那样,它产生相同的输出: + +``` +$ dmd ufcs_demo.d +$ ./ufcs_demo +[2, 4] +``` + +在编译过程中,编译器*自动地*将数组作为函数的第一个参数。这是一个常规模式,使得使用 D 语言成为一种乐趣,因此,它与你自然而然考虑代码的感觉非常相似。结果就是函数式编程。 + +你可能会猜出这打印的是什么: + +``` +//file: cool.d +import std.stdio : writeln; +import std.uni : asLowerCase, asCapitalized; + +void main() +{ +    string mySentence = "D IS COOL"; +    writeln(mySentence.asLowerCase.asCapitalized); +} +``` + +确认一下: + + +``` +$ dmd cool.d +$ ./cool +D is cool +``` + +结合[其他 D 语言的功能][7],UFCS 使你能够编写可重用的代码,并在不牺牲便利性的情况下自然地进行编写。 + +### 是时候尝试 D 语言了 + +就像我之前写的那样,D 语言是一种很棒的开发语言。从 [D 语言的下载页面][8]可以很容易地进行安装,因此请下载编译器,查看示例,并亲自体验 D 语言。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/d-programming + +作者:[Lawrence Aberba][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/aberba +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl (Coding on a computer) +[2]: https://opensource.com/article/17/5/d-open-source-software-development +[3]: http://ddili.org/ders/d.en/ufcs.html +[4]: https://en.wikipedia.org/wiki/Syntactic_sugar +[5]: https://tour.dlang.org/tour/en/welcome/install-d-locally +[6]: https://tour.dlang.org/tour/en/welcome/run-d-program-locally +[7]: https://dlang.org/comparison.html +[8]: https://dlang.org/download.html diff --git a/published/20200728 BigBlueButton- Open Source Software for Online Teaching.md b/published/20200728 BigBlueButton- Open Source Software for Online Teaching.md new file mode 100644 index 0000000000..846d64ff0a --- /dev/null +++ b/published/20200728 BigBlueButton- Open Source Software for Online Teaching.md @@ -0,0 +1,92 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12492-1.html) +[#]: subject: (BigBlueButton: Open Source Software for Online Teaching) +[#]: via: (https://itsfoss.com/bigbluebutton/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +BigBlueButton:开源在线教学软件 +====== + +> BigBlueButton 是一个为在线教学量身定制的开源视频会议工具。让我们来看看它提供了什么。 + +在 2020 年,在家远程工作是一种新常态。当然,你不可能远程完成所有事情,但是在线教学是可以的。 + +尽管许多老师和学校组织不熟悉那些所有的出色工具,但某些[最好的开源视频会议工具][1]在一定程度上满足了要求。 + +在我提到的视频通话软件中,[BigBlueButton][2] 引起了我的注意。在这里,我将为你简单介绍。 + +### BigBlueButton:用于在线教学的开源 Web 会议系统 + +![][3] + +BigBlueButton 是一个开源的网络会议方案,它旨在简化在线学习。 + +它是完全免费的,但是需要你在自己的服务器上安装才能将其用作成熟的在线学习解决方案。 + +BigBlueButton 提供了非常好的一组功能。你可以轻松地尝试[演示实例][4],并在学校的服务器上进行安装。 + +开始之前,请先了解以下功能: + +### BigBlueButton 的功能 + +BigBlueButton 为教师和学校的量身定制了一系列在线课堂的有用功能,你可以获得: + + * 现场白板 + * 给公共和私人发消息 + * 支持网络摄像头 + * 支持会话记录 + * 支持表情符号 + * 能够将用户分组以进行团队协作 + * 支持投票 + * 屏幕共享 + * 支持多用户白板 + * 能够自行托管 + * 提供用于轻松集成到 Web 应用中的 API + +除了提供的功能外,你还能看到易于使用的 UI,即 [Greenlight][5] (BigBlueButton 的前端界面),当你在服务器上配置时可以安装它。 + +你可以尝试演示实例来临时免费地教你的学生。但是,考虑到使用[演示实例][4]来尝试 BigBlueButton 的局限性(限制为 60 分钟),建议你将它托管在服务器上,以探索其提供的所有功能。 + +为了更清楚地了解这些功能是如何工作的,你可能需要看下它的[官方教程](https://www.youtube.com/embed/Q2tG2SS4gXA)。 + +### 在你的服务器上安装 BigBlueButton + +他们提供了[详细文档][6],它对每个开发人员都会有用。安装它最简单、最快捷的方法是使用 [bbb-install 脚本][7],但是如果不成功,你也可以探索其他选项。 + +对于刚接触的人,你需要一台至少运行 Ubuntu 16.04 LTS 的服务器。在为 BigBlueButton 部署服务器之前,你应该查看[最低要求][8]。 + +你可以在它的 [GitHub 页面][9]中进一步了解该项目。 + +- [试用 BigBlueButton][2] + +如果你正在为在线教学寻求解决方案,那么 BigBlueButton 是一个不错的选择。 + +它可能不提供原生的智能手机应用,但你肯定可以用手机上的网络浏览器来访问它。当然,最好找一台笔记本电脑/计算机来访问在线教学平台,但它也可以在移动设备上使用。 + +你认为 BigBlueButton 的在线教学如何?有没有更好的开源项目可以替代?在下面的评论中让我知道! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bigbluebutton/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[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://linux.cn/article-12453-1.html +[2]: https://bigbluebutton.org/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/07/big-blue-button.png?ssl=1 +[4]: http://demo.bigbluebutton.org/ +[5]: https://bigbluebutton.org/2018/07/09/greenlight-2-0/ +[6]: https://docs.bigbluebutton.org/ +[7]: https://github.com/bigbluebutton/bbb-install +[8]: https://docs.bigbluebutton.org/2.2/install.html#minimum-server-requirements +[9]: https://github.com/bigbluebutton diff --git a/published/20200730 10 cheat sheets for Linux sysadmins.md b/published/20200730 10 cheat sheets for Linux sysadmins.md new file mode 100644 index 0000000000..53e7766a2d --- /dev/null +++ b/published/20200730 10 cheat sheets for Linux sysadmins.md @@ -0,0 +1,128 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-12490-1.html) +[#]: subject: (10 cheat sheets for Linux sysadmins) +[#]: via: (https://opensource.com/article/20/7/sysadmin-cheat-sheets) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Linux 系统管理员的 10 份速查表 +====== + +> 这些快速参考指南让系统管理员的生活和日常工作变得更轻松,而且它们都是免费提供的。 + +![](https://img.linux.net.cn/data/attachment/album/202008/05/222202qildlyr1lnqwq0o4.jpg) + +作为一名系统管理员,你做所的不是一件工作,而是**全部**工作,而且往往每一件工作都是随时随地出现,毫无预兆。除非你每天都只做一项任务,否则当需要的时候,你可能并不总是都能将所有的命令和选项都记在脑海里。这就是为什么我喜欢速查表的原因。 + +速查表可以帮助你避免愚蠢的错误,它们可以让你不必翻阅数页的文档,并让你高效地完成任务。我为每位系统管理员挑选了我最喜欢的 10 个速查表,无论他的经验水平如何。 + +### 网络 + +我们的《[Linux 网络][2]》速查表是速查表界的的瑞士军刀,它包含了最常见的网络命令的简单提醒,包括 `nslookup`、`tcpdump`、`nmcli`、`netstat`、`traceroute` 等。最重要的是,它用了 `ip` 命令,所以你终于可以不用再默认使用 `ifconfig` 命令了! + +### 防火墙 + +系统管理员有两种:了解 `iptables` 的和使用前一类人编写的 `iptables` 配置文件的。如果你是第一类人,你可以继续使用你的 `iptables` 配置,有没有 [firewalld][3] 都无所谓。 + +如果你是第二类人,你终于可以放下你的 iptables 焦虑,拥抱 firewalld 的轻松。阅读《[用 firewall-cmd 保护你的 Linux 网络][4]》,然后下载我们的《[firewalld 速查表][5]》来记住你所学到的东西,保护你的网络端口从未如此简单。 + +### SSH + +许多系统管理员都用的是 [POSIX][6] shell,所以可以在别人的计算机上运行的远程 shell 是 Linux 上最重要的工具之一也就不足为奇了。任何学习服务器管理的人通常很早就学会了使用 SSH,但我们中的许多人只学习了基础知识。 + +当然,SSH 可以在远程机器上打开一个交互式的 shell,但它的功能远不止这些。比如说,你需要在远程机器上进行图形化登录。远程主机的用户要么不在键盘旁边,要么无法理解你启用 VNC 的指令。只要你有 SSH 权限,就可以为他们打开端口。 + +``` +$ ssh -L 5901:localhost:5901 +``` + +通过我们的《[SSH 速查表][7]》了解更多。 + +### Linux 用户和权限 + +传统的大型机和 UNIX 超级计算机风格的用户账户现在基本上已经被 Samba、LDAP 和 OpenShift等系统所取代。然而,这并没有改变对管理员和服务账户仔细管理的需求。为此,你仍然需要熟悉`useradd`、`usermod`、`chown`、`chmod`、`passwd`、`gpasswd`、`umask` 等命令。 + +把我的《[用户和权限速查表][8]》放在手边,你就可以随时对与用户管理有关的任务进行合理的概览,并有实例命令演示你需要做的任何事情的正确语法。 + +### 基本的 Linux 命令 + +并不是所有的系统管理员都会把所有的时间花在终端上。无论你是否喜欢在桌面上工作,还是刚开始使用 Linux,有时为常用的终端命令提供一个任务导向的参考是很好的。 + +对于一个为灵活性和即兴性而设计的界面来说,找到所有你可能需要的东西是很困难的,但我的《[常用命令速查表][9]》是相当全面的。这张速查表以任何技术型桌面用户的典型生活为蓝本,涵盖了用命令在计算机内导航、寻找文件的绝对路径、复制和重命名文件、建立目录、启动系统服务等内容。 + +### Git + +在计算机的历史上,版本控制曾经是只有开发者才需要的东西。但那是过去,而 Git 是现在。对于任何希望跟踪从 Bash 脚本到配置文件、文档和代码的变化的人来说,版本控制是一个重要的工具。Git 适用于每个人,包括程序员、网站可靠性工程师(SRE),甚至系统管理员。 + +获取我们的《[Git 速查表][10]》来学习要领、基本工作流程和最重要的 Git 标志。 + +### Curl + +Curl 不一定是系统管理员专用的工具,从技术上讲,它“只是”一个用于终端的非交互式 Web 浏览器。你可能几天都不用它一次。然而,你很有可能会发现 Curl 对你每天要做的事情很有用,不管是快速参考网站上的一些信息,还是排除网络主机的故障,或者是验证你运行或依赖的一个重要 API。 + +Curl 是一个向服务器传输数据的命令,它支持的协议包括 HTTP、FTP、IMAP、LDAP、POP3、SCP、SFTP、SMB、SMTP 等。它是一个重要的网络工具,所以下载我们的《[Curl 速查表][11]》,开始探索 Curl 吧。 + +### SELinux + +Linux 的安全策略在默认情况下是很好的,root 权限和用户权限之间有很强的分离,但 SELinux 使用标签系统对其进行了改进。在配置了 SELinux 的主机上,每个进程和每个文件对象(或目录、网络端口、设备等)都有一个标签。SELinux 提供了一套规则来控制进程标签对对象(如文件)标签的访问。 + +有时候你需要调整 SELinux 策略,或者调试一些安装时没有正确设置的东西,或者深入了解当前的策略。我们的《[SELinux 速查表][12]》可以提供帮助。 + +### Kubectl + +无论你是已经迁移到了开放的混合云、封闭的私有云,还是你还在研究这样的迁移需要准备什么,你都需要了解 Kubernetes。虽然云确实还需要人去摆弄物理服务器,但作为一个系统管理员,你的未来肯定会涉及到容器,而没有什么比 Kubernetes 更能做到这一点。 + +虽然 [OpenShift][13] 为 Kubernetes 提供了流畅的“仪表盘”体验,但有时需要一种直接的方法,这正是 `kubectl` 提供的。下一次当你不得不到处推送容器时,请确保你手头有我们的《[kubectl 速查表][14]》。 + +### awk + +近几年来,Linux 经历了很多创新,有虚拟机、容器、新的安全模型、新的初始化系统、云等等。然而有些东西似乎永远不会改变。尤其是,系统管理员需要从日志文件和其它无尽的数据流中解析和隔离信息。仍然没有比 Aho、Weinberger 和 Kernighan 的经典 `awk` 命令更适合这项工作的工具。 + +当然,自从 1977 年它被编写出来后,`awk` 已经走过了很长的路,新的选项和功能使它更容易使用。但如果你不是每天都在使用 `awk`,那么多的选项和语法可能会让你有点不知所措。下载我们的《[awk 速查表][15]》,了解 GNU awk 的工作原理。 + +### 赠品:Bash 脚本编程 + +速查表是有用的,但如果你想找更全面的东西,你可以下载我们的《[Bash 脚本编程手册][16]》。这本指南教你如何将你从速查表中了解到的所有命令和经验结合到脚本中,帮助你建立一个随时能用的自动化解决方案库来解决你的日常问题。本书内容丰富,详细讲解了 Bash 的工作原理、脚本与交互式命令的区别、如何捕捉错误等。 + +### 赋能系统管理员 + +你是一名系统管理员吗? + +你正在成为一名系统管理员的路上吗? + +你是否对系统管理员一天都在做什么感到好奇? + +如果是的话,请查看《[赋能系统管理员][17]》,这里有来自业界最勤奋的系统管理员的新文章,讲述他们的工作,以及 Linux 和开源如何让这一切成为可能。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/7/sysadmin-cheat-sheets + +作者:[Seth Kenlon][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR (People work on a computer server with devices) +[2]: https://opensource.com/downloads/cheat-sheet-networking +[3]: https://firewalld.org/ +[4]: https://www.redhat.com/sysadmin/secure-linux-network-firewall-cmd +[5]: https://opensource.com/downloads/firewall-cheat-sheet +[6]: https://opensource.com/article/19/7/what-posix-richard-stallman-explains +[7]: https://opensource.com/downloads/advanced-ssh-cheat-sheet +[8]: https://opensource.com/downloads/linux-permissions-cheat-sheet +[9]: https://opensource.com/downloads/linux-common-commands-cheat-sheet +[10]: https://opensource.com/downloads/cheat-sheet-git +[11]: https://opensource.com/downloads/curl-command-cheat-sheet +[12]: https://opensource.com/downloads/cheat-sheet-selinux +[13]: https://opensource.com/tags/openshift +[14]: https://opensource.com/downloads/kubectl-cheat-sheet +[15]: https://opensource.com/downloads/cheat-sheet-awk-features +[16]: https://opensource.com/downloads/bash-scripting-ebook +[17]: http://redhat.com/sysadmin diff --git a/sources/README.md b/sources/README.md new file mode 100644 index 0000000000..5615087474 --- /dev/null +++ b/sources/README.md @@ -0,0 +1 @@ +这里放待翻译的文件。 diff --git a/sources/news/20191207 New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news.md b/sources/news/20191207 New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news.md deleted file mode 100644 index 93297c4cad..0000000000 --- a/sources/news/20191207 New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news.md +++ /dev/null @@ -1,93 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news) -[#]: via: (https://opensource.com/article/19/12/news-december-7) -[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) - -New machine learning from Alibaba and Netflix, mimicking animal vision, and more open source news -====== -Catch up on the biggest open source headlines from the past two weeks. -![Weekly news roundup with TV][1] - -In this edition of our open source news roundup, we take a look an open source election auditing tool, new open source from Alibaba and Netflix, mimicking animal vision, and more! - -### Alibaba and Netflix share machine learning and data science software - -Two companies at the forefront of machine learning and data science have just released some of their tools under open source licenses. - -Chinese ecommerce giant Alibaba just [open sourced the algorithm libraries][2] for its Alink platform. The algorithms "are essential to support machine learning tasks such as online product recommendations and smart customer services." According to Jia Yangqing, president of Alibaba Cloud, Alink is a good fit for "developers seeking big data and machine-learning tools." You can find the source code for Alink (which is under an Apache 2.0 license) [on GitHub][3], with documentation in both Chinese and English. - -Not to be outdone, streaming service Netflix just released its [Metaflow Python library][4] under an Apache 2.0 license. Metaflow enables data scientists to "see early on whether a prototyped model would fail in production, allowing them to fix whatever the issue was". It also works with a number of Python data science libraries, like SciKit Learn, Pytorch, and Tensorflow. You can grab Metaflow's code from [its GitHub repository][5] or learn more about it at the [Metaflow website][6]. - -### Open source software to mimic animal vision - -Have you ever wondered how your dog or cat sees the world? Thanks to work by researchers at the University of Exeter in the UK and Australia's University of Queensland, you can find out. The team just released [software that allows humans to see the world as animals do][7]. - -Called micaToolbox, the software can interpret digital photos and process images of various environments by mimicking the limitations of animal vision. Anyone with a camera, a computer, or smartphone can use the software without knowing how to code. But micaToolbox isn't just a novelty. It's a serious scientific tool that can help "help biologists better understand a variety of animal behaviors, including mating systems, distance-dependent signalling and mimicry." And, according to researcher Jolyon Troscianko, the software can help identify "how an animal's camouflage works so that we can manage our land to protect certain species." - -You can [download micaBox][8] or [browse its source code][9] on GitHub. - -### New tool for post-election auditing - -More and more aspects of our lives and institutions are being automated. With that comes an increased danger of systems breaking down or malicious someones tampering with those systems. Open source gives us an opportunity to look at exactly how the automation works. - -Elections, in particular, are increasingly vulnerable. To combat election tampering, the US Cybersecurity and Infrastructure Security Agency (CISA) has joined forces with the non-profit organization VotingWorks to create a [web-based application for auditing ballots][10]. - -Called Arlo, the application is designed to ensure that "elections are secure, resilient, and transparent," said CISA's director Chris Krebs. Arlo works with a range of automated voting systems to help "officials compare audited votes to tabulated votes, and providing monitoring & reporting capabilities." Arlo was used to verify the results of recent state and local elections and is being further field-tested in the states of Georgia, Michigan, Missouri, Ohio, Pennsylvania, and Virginia. - -Arlo's source code, released under an AGPL-3.0 license, is [available on GitHub][11]. - -### Royal Navy debuts open source application development kit - -Consistency across user interfaces is key to a successful set of applications and services. The UK's Royal Navy understands the importance of this and has released the [open source NELSON standards toolkit][12] to help its developers and suppliers "save time and give users a consistent experience." - -Named after the legendary British admiral, NELSON is intended to "maintain high visual consistency and user-experience quality across the different applications developed or subcontracted by the Royal Navy." The toolkit consists of a set of components including visual styles, typographic elements, forms, elements like buttons and checkboxes, and notifications. - -NELSON has its own [GitHub repository][13], from which the Royal Navy encourages developers to make pull requests. - -#### In other news - - * [Council group plans for open source revenues and benefits platform][14] - * [Introducing Nebula, the open source global overlay network from Slack][15] - * [webOS Open Source Edition 2.0 keeps Palm's spirit alive in cars and IoT][16] - * [Duke University Introduces an Open Source Tool as an Alternative to a Monolithic LMS][17] - * [Open Source Technology Could Be a Boon to Farmers][18] - - - -_Thanks, as always, to Opensource.com staff members and moderators for their help this week._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/12/news-december-7 - -作者:[Scott Nesbitt][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/scottnesbitt -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) -[2]: https://www.zdnet.com/article/alibaba-cloud-publishes-machine-learning-algorithm-on-github/ -[3]: https://github.com/alibaba/alink -[4]: https://www.zdnet.com/article/netflix-our-metaflow-python-library-for-faster-data-science-is-now-open-source/ -[5]: https://github.com/Netflix/metaflow -[6]: https://metaflow.org/ -[7]: https://www.upi.com/Science_News/2019/12/03/Novel-software-helps-scientists-see-what-animals-see/5961575389734/ -[8]: http://www.empiricalimaging.com/download/micatoolbox/ -[9]: https://github.com/troscianko/micaToolbox -[10]: https://www.zdnet.com/article/cisa-and-votingworks-release-open-source-post-election-auditing-tool/ -[11]: https://github.com/votingworks/arlo -[12]: https://joinup.ec.europa.eu/collection/open-source-observatory-osor/news/open-source-royal-navy -[13]: https://github.com/Royal-Navy/standards-toolkit -[14]: https://www.ukauthority.com/articles/council-group-plans-for-open-source-revenues-and-benefits/ -[15]: https://slack.engineering/introducing-nebula-the-open-source-global-overlay-network-from-slack-884110a5579 -[16]: https://www.slashgear.com/webos-open-source-edition-2-0-keeps-palms-spirit-alive-in-cars-and-iot-25601309/ -[17]: https://iblnews.org/duke-university-introduces-an-open-source-tool-as-an-alternative-to-a-monolithic-lms/ -[18]: https://civileats.com/2019/12/02/open-source-technology-could-be-a-boon-to-farmers/ diff --git a/sources/news/20191209 First Ever Release of Ubuntu Cinnamon Distribution is Finally Here.md b/sources/news/20191209 First Ever Release of Ubuntu Cinnamon Distribution is Finally Here.md deleted file mode 100644 index 09af65568d..0000000000 --- a/sources/news/20191209 First Ever Release of Ubuntu Cinnamon Distribution is Finally Here.md +++ /dev/null @@ -1,85 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (First Ever Release of Ubuntu Cinnamon Distribution is Finally Here!) -[#]: via: (https://itsfoss.com/ubuntu-cinnamon/) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -First Ever Release of Ubuntu Cinnamon Distribution is Finally Here! -====== - -_**Brief: Ubuntu Cinnamon is a new distribution that utilizes Linux Mint’s Cinnamon desktop environment on top of Ubuntu code base. It’s first stable release is based on Ubuntu 19.10 Eoan Ermine.**_ - -[Cinnamon][1] is Linux Mint’s flagship desktop environment. Like [MATE desktop][2], Cinnamon is also a product of dissatisfaction with GNOME 3. With the GNOME Classic like user interface and relatively lower hardware requirements, Cinnamon soon gathered a dedicated userbase. - -Like any other desktop environment out there, you can [install Cinnamon on Ubuntu][3] and other distributions. - -Installing multiple [desktop environments][4] (DE) is not a difficult task but it often leads to conflicts (with other DE’s elements) and may not always provide the best experience. This is why major Linux distributions separate spins/flavors with various popular desktop environments. - -[Ubuntu also has various official flavors][5] featuring [KDE][6] (Kubuntu), [LXQt][7] (Lubuntu), Xfce (Xubuntu), Budgie ([Ubuntu Budgie][8]) etc. Cinnamon was not in this list but Ubuntu Cinnamon Remix project is trying to change that. - -### Ubuntu Cinnamon distribution - -![Ubuntu Cinnamon Desktop Screenshot][9] - -[Ubuntu Cinnamon][10] (website under construction) is a new Linux distribution that brings Cinnamon desktop to Ubuntu distribution. Joshua Peisach is the lead developer for the project and he is being helped by other volunteer contributors. The ex-developer of the now discontinued Ubuntu GNOME project and some members from Ubuntu team are also advising the team to help with the development. - -![Ubuntu Cinnamon Remix Screeenshot 1][11] - -Do note that Ubuntu Cinnamon is not an official flavor of Ubuntu. They are trying to get the flavorship but I think that will take a few more releases. - -The first stable release of Ubuntu Cinnamon is based on [Ubuntu 19.10 Eoan Ermine][12]. It uses Calamares installer from Lubuntu and features Cinnamon desktop version 4.0.10. Naturally, it uses Nemo file manager and LightDM. - -It supports EFI and UEFI and only comes with 64-bit support. - -You’ll get your regular goodies like LibreOffice, Firefox and some GNOME software and games. You can of course install more applications as per your need. - -### Download and install Ubuntu Cinnamon - -Do note that this is the first ever release of Ubuntu Cinnamon and the developers are not that experienced at this moment. - -If you don’t like troubleshooting, don’t use it on your main system. I expect this release to have a few bugs and issues which will be fixed eventually as more users test it out. - -You can download Ubuntu Cinnamon ISO from Sourceforge website: - -[Download Ubuntu Cinnamon][13] - -### What next from here? - -The dev team has a few improvements planned for the 20.04 release. The changes are mostly on the cosmetics though. There will be new GRUB and Plymouth theme, layout application and welcome screen. - -I downloaded it and tried it in a live session. Here’s what this distribution looks like: - -[Subscribe to our YouTube channel for more Linux videos][14] - -Meanwhile, if you manage to try it on your own, why not share your experience in the comments? If you use Linux Mint, will you switch to Ubuntu Cinnamon in near future? What are your overall opinion about this new project? Do share it in the comment section. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/ubuntu-cinnamon/ - -作者:[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://en.wikipedia.org/wiki/Cinnamon_(desktop_environment) -[2]: https://mate-desktop.org/ -[3]: https://itsfoss.com/install-cinnamon-on-ubuntu/ -[4]: https://itsfoss.com/best-linux-desktop-environments/ -[5]: https://itsfoss.com/which-ubuntu-install/ -[6]: https://kde.org/ -[7]: https://lxqt.org/ -[8]: https://itsfoss.com/ubuntu-budgie-18-review/ -[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/ubuntu_cinnamon_distribution_screenshot.jpg?ssl=1 -[10]: https://ubuntucinnamon.org/ -[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/ubuntu_cinnamon_remix_screeenshot_1.jpg?ssl=1 -[12]: https://itsfoss.com/ubuntu-19-10-released/ -[13]: https://sourceforge.net/projects/ubuntu-cinnamon-remix/ -[14]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 diff --git a/sources/news/20191209 KubeCon gets bigger, the kernel gets better, and more industry trends.md b/sources/news/20191209 KubeCon gets bigger, the kernel gets better, and more industry trends.md deleted file mode 100644 index 81b00a0ec9..0000000000 --- a/sources/news/20191209 KubeCon gets bigger, the kernel gets better, and more industry trends.md +++ /dev/null @@ -1,65 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (KubeCon gets bigger, the kernel gets better, and more industry trends) -[#]: via: (https://opensource.com/article/19/12/kubecon-bigger-kernel-better-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -KubeCon gets bigger, the kernel gets better, and more industry trends -====== -A weekly look at open source community, market, and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [KubeCon showed Kubernetes is big, but is it a Unicorn?][2] - -> It’s hard to remember now but there was a time when Kubernetes was a distant No. 3 in terms of container orchestrators being used in the market. It’s also eye opening to now realize that [the firms][3] that hatched the two platforms that [towered over][4] Kubernetes have had to completely re-jigger their business models under the Kubernetes onslaught. -> -> And full credit to the CNCF for attempting to diffuse some of that attention from Kubernetes by spending the vast majority of the KubeCon opening keynote address touting some of the nearly two dozen graduated, incubating, and sandbox projects it also hosts. But, it was really the Big K that stole the show. - -**The impact:** Open source is way more than the source code; governance is a big deal and can be the difference between longevity and irrelevance. Gathering, organizing, and maintaining humans is an entirely different skill set than doing the same for bits, but can have just as big an influence on the success of a project. - -## [Report: Kubernetes use on the rise][5] - -> At the same time, the Datadog report notes that container churn rates are approximately 10 times higher in orchestrated environments. Churn rates in container environments that lack an orchestration platform such as Kubernetes have increased in the last year as well. The average container lifespan at a typical company running infrastructure without orchestration is about two days, down from about six days in mid-2018. In 19% of those environments not running orchestration, the average container lifetime exceeded 30 days. That compares to only 3% of organizations running containers longer than 30 days in Kubernetes environments, according to the report’s findings. - -**The impact**: If your containers aren't churning, you're probably not getting the full benefit of the technology you've adopted. - -## [Upcoming Linux 5.5 kernel improves live patching, scheduling][6] - -> A new WFX Wi-Fi driver for the Silicon Labs WF200 ASIC transceiver is coming to Linux kernel 5.5. This particular wireless transceiver is geared toward low-power IoT devices and uses a 2.4 GHz 802.11b/g/n radio optimized for low power RF performance in crowded RF environments. This new driver can interface via both Serial Peripheral Interface (SPI) and Secure Digital Input Output (SDIO). - -**The impact**: The kernel's continued relevance is a direct result of the never-ending grind to keep being where people need it to be (i.e. basically everywhere). - -## [DigitalOcean Currents: December 2019][7] - -> In that spirit, this fall’s installment of our seasonal Currents report is dedicated to open source for the second year running. We surveyed more than 5800 developers around the world on the overall health and direction of the open source community. When we last checked in with the community in [2018][8], more than half of developers reported contributing to open source projects, and most felt the community was healthy and growing. - -**The impact**: While the good news outweighs the bad, there are a couple of things to keep an eye on: namely, making open source more inclusive and mitigating potential negative impact of big money. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/12/kubecon-bigger-kernel-better-more-industry-trends - -作者:[Tim Hildred][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/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://www.sdxcentral.com/articles/opinion-editorial/kubecon-showed-kubernetes-is-big-but-is-it-a-unicorn/2019/11/ -[3]: https://www.sdxcentral.com/articles/news/docker-unloads-enterprise-biz-to-mirantis/2019/11/ -[4]: https://www.sdxcentral.com/articles/news/mesosphere-is-now-d2iq-and-kubernetes-is-its-game/2019/08/ -[5]: https://containerjournal.com/topics/container-ecosystems/report-kubernetes-use-on-the-rise/ -[6]: https://thenewstack.io/upcoming-linux-5-5-kernel-improves-live-patching-scheduling/ -[7]: https://blog.digitalocean.com/digitalocean-currents-december-2019/ -[8]: https://www.digitalocean.com/currents/october-2018/ diff --git a/sources/news/20191214 Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates.md b/sources/news/20191214 Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates.md deleted file mode 100644 index 85aef63325..0000000000 --- a/sources/news/20191214 Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates.md +++ /dev/null @@ -1,75 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates) -[#]: via: (https://opensource.com/article/19/12/python-news-december) -[#]: author: (Christian Heimes https://opensource.com/users/christian-heimes) - -Annual release cycle for Python, new Python Software Foundation fellows from Africa, and more updates -====== -Find out what's going on in the Python community in December. -![Python in a coffee cup.][1] - -The Python Software Foundation (PSF) is a nonprofit organization behind the Python programming language. I am fortunate to be a PSF Fellow (honorable member for life,) a Python core developer, and the liaison between my company, Red Hat, and the PSF. Part of that liaison work is providing updates on what’s happening in the Python community. Here’s a look at what we have going on in December. - -### Upcoming events - -A significant part of the Python community is its in-person events. These events are where users and contributors intermingle and learn together. Here are the big announcements of upcoming opportunities to connect. - -#### PyCon US 2020 - -[PyCon US][2] is by far the largest annual Python event. The next PyCon is April 15-23, 2020, in Pittsburgh. The call for proposals is open to all until December 20, 2019. I’m planning to attend PyCon for the conference and its [famous post-con sprints][3]. - -#### EuroPython - -EuroPython is the largest Python conference in Europe with about 1,000 attendees in the last years. [EP20][4] will be held in Dublin, Ireland, July 20-26, 2020. As a liaison for Red Hat, I’m proud to say that Red Hat sponsored EP18 in Edinburgh and donated the sponsoring tickets to Women Who Code Scotland. - -#### PyData - -[PyData][5] is a separate nonprofit related to the Python community through a focus on data science. They host many international events throughout the year, with upcoming events in [Austin, Texas][6], and [Warsaw, Poland][7] before the end of the year. - -### New PSF fellows from Africa - -The PSF promotes a few members to fellow every quarter. Yesterday, twelve new PSF fellows were [announced][8]. - -I’d like to highlight the four new fellows from Ghana, who are also the organizers of the first pan-African [PyCon Africa][9], which took place in August 2019 in Accra, Ghana. The Python community in Africa is growing at an amazing speed. PyCon Africa 2020 will be in Accra again, and I’m planning to spend my summer vacation there. - -### Annual release cycle for Python - -Python used to release a new major version about every 18 months. This timeline will change with the Python 3.9 release. With [PEP 602,][10] a new major version of Python will be released annually in October. The new cadence means fewer changes between releases and more predictable release dates. October was chosen to align with Linux distribution releases such as Fedora. Miro Hrončok from the Python maintenance team joined the discussion and has helped to find a convenient release date for us; for more details, please see . - -### Steering council election - -The Python Steering Council governs the development of Python. It was established after [Guido van Rossum stepped down][11] as benevolent dictator for life. Python core developers elect a new steering council for every major Python release. For the upcoming term, nine candidates were nominated for five seats on the council (with Guido being nominated, but [withdrawing][12]). See for all the details. Election results are expected to be announced mid-December. - -That covers what’s new in the Python community for December. Stay tuned for more updates in the future and mark your calendars for the conferences mentioned above. - -So you have a great business idea for a wonderful IT product or service, and you want to build your... - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/12/python-news-december - -作者:[Christian Heimes][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/christian-heimes -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_python.jpg?itok=G04cSvp_ (Python in a coffee cup.) -[2]: https://us.pycon.org/2020/ -[3]: https://opensource.com/article/19/5/pycon-developer-sprints -[4]: https://www.europython-society.org/post/188741002380/europython-2020-venue-and-location-selected -[5]: https://pydata.org/ -[6]: https://pydata.org/austin2019/ -[7]: https://pydata.org/warsaw2019/ -[8]: https://pyfound.blogspot.com/2019/11/python-software-foundation-fellow.html -[9]: https://africa.pycon.org/ -[10]: https://www.python.org/dev/peps/pep-0602/ -[11]: https://opensource.com/article/19/6/command-line-heroes-python -[12]: https://discuss.python.org/t/steering-council-nomination-guido-van-rossum-2020-term/2657/11 diff --git a/sources/news/20191219 2020 technology must haves, a guide to Kubernetes etcd, and more industry trends.md b/sources/news/20191219 2020 technology must haves, a guide to Kubernetes etcd, and more industry trends.md deleted file mode 100644 index 198d4f8292..0000000000 --- a/sources/news/20191219 2020 technology must haves, a guide to Kubernetes etcd, and more industry trends.md +++ /dev/null @@ -1,63 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (2020 technology must haves, a guide to Kubernetes etcd, and more industry trends) -[#]: via: (https://opensource.com/article/19/12/gartner-ectd-and-more-industry-trends) -[#]: author: (Tim Hildred https://opensource.com/users/thildred) - -2020 technology must haves, a guide to Kubernetes etcd, and more industry trends -====== -A weekly look at open source community, market, and industry trends. -![Person standing in front of a giant computer screen with numbers, data][1] - -As part of my role as a senior product marketing manager at an enterprise software company with an open source development model, I publish a regular update about open source community, market, and industry trends for product marketers, managers, and other influencers. Here are five of my and their favorite articles from that update. - -## [Gartner's top 10 infrastructure and operations trends for 2020][2] - -> “The vast majority of organisations that do not adopt a shared self-service platform approach will find that their DevOps initiatives simply do not scale,” said Winser. "Adopting a shared platform approach enables product teams to draw from an I&O digital toolbox of possibilities, while benefiting from high standards of governance and efficiency needed for scale." - -**The impact**: The breakneck change of technology development and adoption will not slow down next year, as the things you've been reading about for the last two years become things you have to figure out to deal with every day. - -## [A guide to Kubernetes etcd: All you need to know to set up etcd clusters][3] - -> Etcd is a distributed reliable key-value store which is simple, fast and secure. It acts like a backend service discovery and database, runs on different servers in Kubernetes clusters at the same time to monitor changes in clusters and to store state/configuration data that should to be accessed by a Kubernetes master or clusters. Additionally, etcd allows Kubernetes master to support discovery service so that deployed application can declare their availability for inclusion in service. - -**The impact**: This is actually way more than I needed to know about setting up etcd clusters, but now I have a mental model of what that could look like, and you can too. - -## [How the open source model could fuel the future of digital marketing][4] - -> In other words, the broad adoption of open source culture has the power to completely invert the traditional marketing funnel. In the future, prospective customers could be first introduced to “late funnel” materials and then buy into the broader narrative — a complete reversal of how traditional marketing approaches decision-makers today. - -**The impact**: The SEO on this cuts two ways: It can introduce uninitiated marketing people to open source and uninitiated technical people to the ways that technology actually gets adopted. Neat! - -## [Kubernetes integrates interoperability, storage, waits on sidecars][5] - -> In a [recent interview][6], Lachlan Evenson, and was also a lead on the Kubernetes 1.16 release, said sidecar containers was one of the features that team was a “little disappointed” it could not include in their release. -> -> Guinevere Saenger, software engineer at GitHub and lead for the 1.17 release team, explained that sidecar containers gained increased focus “about a month ago,” and that its implementation “changes the pod spec, so this is a change that affects a lot of areas and needs to be handled with care.” She noted that it did move closer to completion and “will again be prioritized for 1.18.” - -**The impact**: You can read between the lines to understand a lot more about the Kubernetes sausage-making process. It's got governance, tradeoffs, themes, and timeframes; all the stuff that is often invisible to consumers of a project. - -_I hope you enjoyed this list of what stood out to me from last week and come back next Monday for more open source community, market, and industry trends._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/12/gartner-ectd-and-more-industry-trends - -作者:[Tim Hildred][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/thildred -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) -[2]: https://www.information-age.com/gartner-top-10-infrastructure-and-operations-trends-2020-123486509/ -[3]: https://superuser.openstack.org/articles/a-guide-to-kubernetes-etcd-all-you-need-to-know-to-set-up-etcd-clusters/ -[4]: https://www.forbes.com/sites/forbescommunicationscouncil/2019/11/19/how-the-open-source-model-could-fuel-the-future-of-digital-marketing/#71b602fb20a5 -[5]: https://www.sdxcentral.com/articles/news/kubernetes-integrates-interoperability-storage-waits-on-sidecars/2019/12/ -[6]: https://kubernetes.io/blog/2019/12/06/when-youre-in-the-release-team-youre-family-the-kubernetes-1.16-release-interview/ diff --git a/sources/news/20191219 Linux Mint 19.3 -Tricia- Released- Here-s What-s New and How to Get it.md b/sources/news/20191219 Linux Mint 19.3 -Tricia- Released- Here-s What-s New and How to Get it.md deleted file mode 100644 index 507915626b..0000000000 --- a/sources/news/20191219 Linux Mint 19.3 -Tricia- Released- Here-s What-s New and How to Get it.md +++ /dev/null @@ -1,165 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Linux Mint 19.3 “Tricia” Released: Here’s What’s New and How to Get it) -[#]: via: (https://itsfoss.com/linux-mint-19-3/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -Linux Mint 19.3 “Tricia” Released: Here’s What’s New and How to Get it -====== - -_**Linux Mint 19.3 “Tricia” has been released. See what’s new in it and learn how to upgrade to Linux Mint 19.3.**_ - -The Linux Mint team finally announced the release of Linux Mint 19.3 codenamed ‘Tricia’ with useful feature additions along with a ton of improvements under-the-hood. - -This is a point release based on the latest **Ubuntu 18.04.3** and it comes packed with the **Linux kernel 5.0**. - -I downloaded and quickly tested the edition featuring the [Cinnamon 4.4][1] desktop environment. You may also try the Xfce or MATE edition of Linux Mint 19.3. - -### Linux Mint 19.3: What’s New? - -![Linux Mint 19 3 Desktop][2] - -While being an LTS release that will be supported until 2023 – it brings in a couple of useful features and improvements. Let me highlight some of them for you. - -#### System Reports - -![][3] - -Right after installing Linux Mint 19.3 (or upgrading it), you will notice a warning icon on the right side of the panel (taskbar). - -When you click on it, you should be displayed a list of potential issues that you can take care of to ensure the best out of Linux Mint experience. - -For starters, it will suggest that you should create a root password, install a language pack, or update software packages – in the form of a warning. This is particularly useful to make sure that you perform important actions even after following the first set of steps on the welcome screen. - -#### Improved Language Settings - -Along with the ability to install/set a language, you will also get the ability to change the time format. - -So, the language settings are now more useful than ever before. - -#### HiDPI Support - -As a result of [HiDPI][4] support, the system tray icons will look crisp and overall, you should get a pleasant user experience on a high-res display. - -#### New Applications - -![Linux Mint Drawing App][5] - -With the new release, you will n longer find “**GIMP**” pre-installed. - -Even though GIMP is a powerful utility, they decided to add a simpler “**Drawing**” app to let users to easily crop/resize images while being able to tweak it a little. - -Also, **Gnote** replaces **Tomboy** as the default note-taking application on Linux Mint 19.3 - -In addition to both these replacements, Celluloid video player has also been added instead of Xplayer. In case you did not know, Celluloid happens to be one of the [best open source video players][6] for Linux. - -#### Cinnamon 4.4 Desktop - -![Cinnamon 4 4 Desktop][7] - -In my case, the new Cinnamon 4.4 desktop experience introduces a couple of new abilities like adjusting/tweaking the panel zones individually as you can see in the screenshot above. - -#### Other Improvements - -There are several other improvements including more customizability options in the file manager and so on. - -You can read more about the detailed changes in the [official release notes][8]. - -[Subscribe to our YouTube channel for more Linux videos][9] - -### Linux Mint 19 vs 19.1 vs 19.2 vs 19.3: What’s the difference? - -You probably already know that Linux Mint releases are based on Ubuntu long term support releases. Linux Mint 19 series is based on Ubuntu 18.04 LTS. - -Ubuntu LTS releases get ‘point releases’ on the interval of a few months. Point release basically consists of bug fixes and security updates that have been pushed since the last release of the LTS version. This is similar to the Service Pack concept in Windows XP if you remember it. - -If you are going to download Ubuntu 18.04 which was released in April 2018 in 2019, you’ll get Ubuntu 18.04.2. The ISO image of 18.04.2 will consist of 18.04 and the bug fixes and security updates applied till 18.04.2. Imagine if there were no point releases, then right after [installing Ubuntu 18.04][10], you’ll have to install a few gigabytes of system updates. Not very convenient, right? - -But Linux Mint has it slightly different. Linux Mint has a major release based on Ubuntu LTS release and then it has three minor releases based on Ubuntu LTS point releases. - -Mint 19 was based on Ubuntu 18.04, 19.1 was based on 18.04.1 and Mint 19.2 is based on Ubuntu 18.04.2. Similarly, Mint 19.3 is based on Ubuntu 18.04.3. It is worth noting that all Mint 19.x releases are long term support releases and will get security updates till 2023. - -Now, if you are using Ubuntu 18.04 and keep your system updated, you’ll automatically get updated to 18.04.1, 18.04.2 etc. That’s not the case in Linux Mint. - -Linux Mint minor releases also consist of _feature changes_ along with bug fixes and security updates and this is the reason why updating Linux Mint 19 won’t automatically put you on 19.1. - -Linux Mint gives you the option if you want the new features or not. For example, Mint 19.3 has Cinnamon 4.4 and several other visual changes. If you are happy with the existing features, you can stay on Mint 19.2. You’ll still get the necessary security and maintenance updates on Mint 19.2 till 2023. - -Now that you understand the concept of minor releases and want the latest minor release, let’s see how to upgrade to Mint 19.3. - -### Linux Mint 19.3: How to Upgrade? - -No matter whether you have Linux Mint 19.1 or 19, you can follow these steps to [upgrade Linux Mint version][11]. - -**Note**: _You should consider making a system snapshot (just in case) for backup. In addition, the Linux Mint team advises you to disable the screensaver and upgrade Cinnamon spices (if installed) from the System settings._ - -![][12] - - 1. Launch the Update Manager. - 2. Now, refresh it to load up the latest available updates (or you can change the mirror if you want). - 3. Once done, simply click on the Edit button to find “**Upgrade to Linux Mint 19.3 Tricia**” button similar to the image above. - 4. Finally, just follow the on-screen instructions to easily update it. - - - -Based on your internet connection, it should take anything between a couple of minutes to 30 minutes. - -### Don’t see Mint 19.3 update yet? Here’s what you can do - -If you don’t see the option to upgrade to Linux Mint 19.3 Tricia, don’t lose hope. Here are a couple of things you can do. - -#### **Step 1: Make sure to use mint-upgrade-info version 1.1.3** - -Make sure that mint-upgrade-info is updated to version 1.1.3. You can try the install command that will update it to a newer version (if there is any). - -``` -sudo apt install mint-upgrade-info -``` - -#### **Step 2: Switch to default software sources** - -Chances are that you are using a mirror closer to you to get faster software downloads. But this could cause a problem as the mirrors might not have the new upgrade info yet. - -Go to Software Source and change the sources to default. Now run the update manager again and see if Mint 19.3 upgrade is available. - -### Download Linux Mint 19.3 ‘Tricia’ - -If you want to perform a fresh install, you can easily download the latest available version from the official download page (depending on what edition you want). - -You will also find multiple mirrors available to download the ISOs – feel free to try the nearest mirror for potentially faster download. - -[Linux Mint 19.3][13] - -**Wrapping Up** - -Have you tried Linux Mint 19.3 yet? Let me know your thoughts in the comments down below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/linux-mint-19-3/ - -作者:[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://github.com/linuxmint/cinnamon/releases/tag/4.4.0 -[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/linux-mint-19-3-desktop.jpg?ssl=1 -[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/linux-mint-system-report.jpg?ssl=1 -[4]: https://wiki.archlinux.org/index.php/HiDPI -[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/12/linux-mint-drawing-app.jpg?ssl=1 -[6]: https://itsfoss.com/video-players-linux/ -[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/cinnamon-4-4-desktop.jpg?ssl=1 -[8]: https://linuxmint.com/rel_tricia_cinnamon.php -[9]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 -[10]: https://itsfoss.com/things-to-do-after-installing-ubuntu-18-04/ -[11]: https://itsfoss.com/upgrade-linux-mint-version/ -[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/08/mintupgrade.png?ssl=1 -[13]: https://linuxmint.com/download.php diff --git a/sources/news/20191221 Eliminating gender bias in open source software development, a database of microbes, and more open source news.md b/sources/news/20191221 Eliminating gender bias in open source software development, a database of microbes, and more open source news.md deleted file mode 100644 index 3cf9d05097..0000000000 --- a/sources/news/20191221 Eliminating gender bias in open source software development, a database of microbes, and more open source news.md +++ /dev/null @@ -1,76 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Eliminating gender bias in open source software development, a database of microbes, and more open source news) -[#]: via: (https://opensource.com/article/19/12/news-december-21) -[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) - -Eliminating gender bias in open source software development, a database of microbes, and more open source news -====== -Catch up on the biggest open source headlines from the past two weeks. -![Weekly news roundup with TV][1] - -In this edition of our open source news roundup, we take a look at eliminating gender bias in open source software development, an open source database of microbes, an open source index for cooperatives, and more! - -### Eliminating gender bias from open source development - -It's a sad fact that certain groups, among them women, are woefully underrepresented in open source projects. It's like a bug in the open source development process. Fortunately, there are initiatives to make that under representation a thing of the past. A study out of Oregon State University (OSU) intends to resolve the issue of the lack of women in open source development by "[finding these bugs and proposing redesigns around them][2], leading to more gender-inclusive tools used by software developers." - -The study will look at tools commonly used in open source development — including Eclipse, GitHub, and Hudson — to determine if they "significantly discourage newcomers, especially women, from joining OSS projects." According to Igor Steinmacher, one of the principal investigators of the study, the study will examine "how people use tools because the 'bugs' may be embedded in how the tool was designed, which may place people with different cognitive styles at a disadvantage." - -The developers of the tools being studied will walk through their software and answer questions based on specific personas. The researchers at OSU will suggest ways to redesign the software to eliminate gender bias and will "create a list of best practices for fixing gender-bias bugs in both products and processes." - -### Canadian university compiles open source microbial database - -What do you do when you have a vast amount of data but no way to effectively search and build upon it? You turn it into a database, of course. That's what researchers at Simon Fraser University in British Columbia, along with collaborators from around the globe, did with [information about chemical compounds created by bacteria and fungi][3]. Called the Natural Products Atlas, the database "holds information on nearly 25,000 natural compounds and serves as a knowledge base and repository for the global scientific community." - -Licensed under a Creative Commons Attribution 4.0 International License, the Natural Products Atlas "holds information on nearly 25,000 natural compounds and serves as a knowledge base and repository for the global scientific community." The [website for the Natural Products Atlas][4] hosts the database also includes a number of visualization tools and is fully searchable. - -Roger Linington, an associate professor at SFU who spearheaded the creation of the database, said that having "all the available data in one place and in a standardized format means we can now index natural compounds for anyone to freely access and learn more about." - -### Open source index for cooperatives - -Europe has long been a hotbed of both open source development and open source adoption. While European governments strongly advocate open source, non profits have been following suit. One of those is Cooperatives Europe, which is developing "[open source software to allow users to index co-op information and resources in a standardised way][5]." - -The idea behind the software, called Coop Starter, reinforces the [essential freedoms of free software][6]: it's intended to provide "education, training and information. The software may be used and repurposed by the public for their own needs and on their own infrastructure." Anyone can use it "to reference existing material on co-operative entrepreneurship" and can contribute "by sharing resources and information." - -The [code for Coop Starter][7], along with a related WordPress plugin, is available from Cooperative Europe's GitLab repository. - -#### In other news - - * [Nancy recognised as France’s top digital free and collaborative public service][8] - * [Open Source and AI: Ready for primetime in government?][9] - * [Open Software Means Kinder Science][10] - * [New Open-Source CoE to be launched by Wipro and Oman’s Ministry of Tech & Communication][11] - - - -_Thanks, as always, to Opensource.com staff members and [Correspondents][12] for their help this week._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/12/news-december-21 - -作者:[Scott Nesbitt][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/scottnesbitt -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/weekly_news_roundup_tv.png?itok=B6PM4S1i (Weekly news roundup with TV) -[2]: https://techxplore.com/news/2019-12-professors-gender-biased-bugs-open-source-software.html -[3]: https://www.sfu.ca/sfunews/stories/2019/12/sfu-global-collaboration-creates-world-s-first-open-source-datab.html -[4]: https://www.npatlas.org/joomla/ -[5]: https://www.thenews.coop/144412/sector/regional-organisations/cooperatives-europe-builds-open-source-index-for-the-co-op-movement/ -[6]: https://www.gnu.org/philosophy/free-sw.en.html -[7]: https://git.happy-dev.fr/startinblox/applications/coop-starter -[8]: https://joinup.ec.europa.eu/collection/open-source-observatory-osor/news/territoire-numerique-libre -[9]: https://federalnewsnetwork.com/commentary/2019/12/open-source-and-ai-ready-for-primetime-in-government/ -[10]: https://blogs.scientificamerican.com/observations/open-software-means-kinder-science/ -[11]: https://www.indianweb2.com/2019/12/11/new-open-source-coe-to-be-launched-by-wipro-and-omans-ministry-of-tech-communication/ -[12]: https://opensource.com/correspondent-program diff --git a/sources/news/20191226 Darktable 3 Released With GUI Rework and New Features.md b/sources/news/20191226 Darktable 3 Released With GUI Rework and New Features.md deleted file mode 100644 index 9463a07712..0000000000 --- a/sources/news/20191226 Darktable 3 Released With GUI Rework and New Features.md +++ /dev/null @@ -1,112 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Darktable 3 Released With GUI Rework and New Features) -[#]: via: (https://itsfoss.com/darktable-3-release/) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -Darktable 3 Released With GUI Rework and New Features -====== - -Here’s the Christmas gift for the photography enthusiasts. Darktable 3.0 has just released. - -[Darktable][1] is one of the [best applications for editing RAW images on Linux][2]. You can consider it as a [free and open source alternative to Adobe Lightroom][3]. - -Darktable 3 is a major new release with tons of feature improvements and a complete rework of the user interface. The GUI is now completely controlled by GTK+ CSS rules, which makes the whole GUI themable. There are eight themes available by default. - -With the help of over 3000 commits and 553 pull requests, the new release has fixed 66 bugs and added many new features. - -Let’s see what features this new release brings. - -### New features in Darktable 3.0 - -![Darktable 3.0 Screenshot][4] - -Here are the highlighted new features: - - * Reworked UI - * A new module for handling 3D RGB Lut transformations - * Many improvements to the ‘denoise (profiled)’ module - * A new ‘culling’ mode and timeline view added - * Many improvements to the ‘denoise (profiled)’ module - * New tone equalizer’ basic and filmic RGB modules - * Better 4K/5K display support - * Undo/redo support for more operations - * Many code optimizations for CPU and SSE paths - * Support for exporting to Google Photos - * More camera support, white balance presets, and noise profiles - * Plenty of bug fixes and feature improvements - - - -You can read about all the changes in the [release notes on GitHub][5]. - -### Installing Darktable 3.0 on Linux - -Let’s see how to get the latest Darktable release. - -#### Installing Darktable 3.0 on Ubuntu-based distributions - -Darktable is available in Ubuntu but you won’t get the latest release immediately. For the LTS version, it may take months before you have this version update. - -Worry not! Darktable provides its [own PPA][6] to install the latest release on Ubuntu-based distributions. - -Unfortuntaley, That Darktable PPA has not been updated with the new release. - -Worry not (again)! Thanks to our friend [Ji M of Ubuntu Handbook][7], we have an unofficial PPA for easily installing Darktable 3.0 on Ubuntu and other Ubuntu based distributions. - -Open a terminal and use these commands one by one: - -``` -sudo add-apt-repository ppa:ubuntuhandbook1/darktable -sudo apt update -sudo apt install darktable -``` - -#### Uninstall Darktable 3 - -To remove Darktable installed via this PPA, you can first uninstall the application: - -``` -sudo apt remove darktable -``` - -And then [remove the PPA][8] as well: - -``` -sudo add-apt-repository -r ppa:ubuntuhandbook1/darktable -``` - -#### Installing Darktable on other Linux distributions - -You may wait for your distribution to provide this new release through the software manager. - -You may also download the tarball or the entire source code from the GitHub release page (it’s at the bottom of the page). - -[Download Darktable 3.0][5] - -With Darktable 3, you can edit your holiday pictures better :) - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/darktable-3-release/ - -作者:[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.darktable.org/ -[2]: https://itsfoss.com/raw-image-tools-linux/ -[3]: https://itsfoss.com/open-source-photoshop-alternatives/ -[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/12/darktable_3_screenshot.jpg?ssl=1 -[5]: https://github.com/darktable-org/darktable/releases/tag/release-3.0.0 -[6]: https://launchpad.net/~pmjdebruijn/+archive/ubuntu/darktable-release -[7]: http://ubuntuhandbook.org/index.php/2019/12/install-darktable-3-0-0-ubuntu-18-04-19-10/ -[8]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ diff --git a/sources/news/README.md b/sources/news/README.md new file mode 100644 index 0000000000..98d53847b1 --- /dev/null +++ b/sources/news/README.md @@ -0,0 +1 @@ +这里放新闻类文章,要求时效性 diff --git a/sources/talk/20170717 The Ultimate Guide to JavaScript Fatigue- Realities of our industry.md b/sources/talk/20170717 The Ultimate Guide to JavaScript Fatigue- Realities of our industry.md deleted file mode 100644 index 923d4618a9..0000000000 --- a/sources/talk/20170717 The Ultimate Guide to JavaScript Fatigue- Realities of our industry.md +++ /dev/null @@ -1,221 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (The Ultimate Guide to JavaScript Fatigue: Realities of our industry) -[#]: via: (https://lucasfcosta.com/2017/07/17/The-Ultimate-Guide-to-JavaScript-Fatigue.html) -[#]: author: (Lucas Fernandes Da Costa https://lucasfcosta.com) - -The Ultimate Guide to JavaScript Fatigue: Realities of our industry -====== - -**Complaining about JS Fatigue is just like complaining about the fact that humanity has created too many tools to solve the problems we have** , from email to airplanes and spaceships. - -Last week I’ve done a talk about this very same subject at the NebraskaJS 2017 Conference and I got so many positive feedbacks that I just thought this talk should also become a blog post in order to reach more people and help them deal with JS Fatigue and understand the realities of our industry. **My goal with this post is to change the way you think about software engineering in general and help you in any areas you might work on**. - -One of the things that has inspired me to write this blog post and that totally changed my life is [this great post by Patrick McKenzie, called “Don’t Call Yourself a Programmer and other Career Advice”][1]. **I highly recommend you read that**. Most of this blog post is advice based on what Patrick has written in that post applied to the JavaScript ecosystem and with a few more thoughts I’ve developed during these last years working in the tech industry. - -This first section is gonna be a bit philosophical, but I swear it will be worth reading. - -### Realities of Our Industry 101 - -Just like Patrick has done in [his post][1], let’s start with the most basic and essential truth about our industry: - -Software solves business problems - -This is it. **Software does not exist to please us as programmers** and let us write beautiful code. Neither it exists to create jobs for people in the tech industry. **Actually, it exists to kill as many jobs as possible, including ours** , and this is why basic income will become much more important in the next few years, but that’s a whole other subject. - -I’m sorry to say that, but the reason things are that way is that there are only two things that matter in the software engineering (and any other industries): - -**Cost versus Revenue** - -**The more you decrease cost and increase revenue, the more valuable you are** , and one of the most common ways of decreasing cost and increasing revenue is replacing human beings by machines, which are more effective and usually cost less in the long run. - -You are not paid to write code - -**Technology is not a goal.** Nobody cares about which programming language you are using, nobody cares about which frameworks your team has chosen, nobody cares about how elegant your data structures are and nobody cares about how good is your code. **The only thing that somebody cares about is how much does your software cost and how much revenue it generates**. - -Writing beautiful code does not matter to your clients. We write beautiful code because it makes us more productive in the long run and this decreases cost and increases revenue. - -The whole reason why we try not to write bugs is not that we value correctness, but that **our clients** value correctness. If you have ever seen a bug becoming a feature you know what I’m talking about. That bug exists but it should not be fixed. That happens because our goal is not to fix bugs, our goal is to generate revenue. If our bugs make clients happy then they increase revenue and therefore we are accomplishing our goals. - -Reusable space rockets, self-driving cars, robots, artificial intelligence: these things do not exist just because someone thought it would be cool to create them. They exist because there are business interests behind them. And I’m not saying the people behind them just want money, I’m sure they think that stuff is also cool, but the truth is that if they were not economically viable or had any potential to become so, they would not exist. - -Probably I should not even call this section “Realities of Our Industry 101”, maybe I should just call it “Realities of Capitalism 101”. - -And given that our only goal is to increase revenue and decrease cost, I think we as programmers should be paying more attention to requirements and design and start thinking with our minds and participating more actively in business decisions, which is why it is extremely important to know the problem domain we are working on. How many times before have you found yourself trying to think about what should happen in certain edge cases that have not been thought before by your managers or business people? - -In 1975, Boehm has done a research in which he found out that about 64% of all errors in the software he was studying were caused by design, while only 36% of all errors were coding errors. Another study called [“Higher Order Software—A Methodology for Defining Software”][2] also states that **in the NASA Apollo project, about 73% of all errors were design errors**. - -The whole reason why Design and Requirements exist is that they define what problems we’re going to solve and solving problems is what generates revenue. - -> Without requirements or design, programming is the art of adding bugs to an empty text file. -> -> * Louis Srygley -> - - -This same principle also applies to the tools we’ve got available in the JavaScript ecosystem. Babel, webpack, react, Redux, Mocha, Chai, Typescript, all of them exist to solve a problem and we gotta understand which problem they are trying to solve, we need to think carefully about when most of them are needed, otherwise, we will end up having JS Fatigue because: - -JS Fatigue happens when people use tools they don't need to solve problems they don't have. - -As Donald Knuth once said: “Premature optimization is the root of all evil”. Remember that software only exists to solve business problems and most software out there is just boring, it does not have any high scalability or high-performance constraints. Focus on solving business problems, focus on decreasing cost and generating revenue because this is all that matters. Optimize when you need, otherwise you will probably be adding unnecessary complexity to your software, which increases cost, and not generating enough revenue to justify that. - -This is why I think we should apply [Test Driven Development][3] principles to everything we do in our job. And by saying this I’m not just talking about testing. **I’m talking about waiting for problems to appear before solving them. This is what TDD is all about**. As Kent Beck himself says: “TDD reduces fear” because it guides your steps and allows you take small steps towards solving your problems. One problem at a time. By doing the same thing when it comes to deciding when to adopt new technologies then we will also reduce fear. - -Solving one problem at a time also decreases [Analysis Paralysis][4], which is basically what happens when you open Netflix and spend three hours concerned about making the optimal choice instead of actually watching something. By solving one problem at a time we reduce the scope of our decisions and by reducing the scope of our decisions we have fewer choices to make and by having fewer choices to make we decrease Analysis Paralysis. - -Have you ever thought about how easier it was to decide what you were going to watch when there were only a few TV channels available? Or how easier it was to decide which game you were going to play when you had only a few cartridges at home? - -### But what about JavaScript? - -By the time I’m writing this post NPM has 489,989 packages and tomorrow approximately 515 new ones are going to be published. - -And the packages we use and complain about have a history behind them we must comprehend in order to understand why we need them. **They are all trying to solve problems.** - -Babel, Dart, CoffeeScript and other transpilers come from our necessity of writing code other than JavaScript but making it runnable in our browsers. Babel even lets us write new generation JavaScript and make sure it will work even on older browsers, which has always been a great problem given the inconsistencies and different amount of compliance to the ECMA Specification between browsers. Even though the ECMA spec is becoming more and more solid these days, we still need Babel. And if you want to read more about Babel’s history I highly recommend that you read [this excellent post by Henry Zhu][5]. - -Module bundlers such as Webpack and Browserify also have their reason to exist. If you remember well, not so long ago we used to suffer a lot with lots of `script` tags and making them work together. They used to pollute the global namespace and it was reasonably hard to make them work together when one depended on the other. In order to solve this [`Require.js`][6] was created, but it still had its problems, it was not that straightforward and its syntax also made it prone to other problems, as you can see [in this blog post][7]. Then Node.js came with `CommonJS` imports, which were synchronous, simple and clean, but we still needed a way to make that work on our browsers and this is why we needed Webpack and Browserify. - -And Webpack itself actually solves more problems than that by allowing us to deal with CSS, images and many other resources as if they were JavaScript dependencies. - -Front-end frameworks are a bit more complicated, but the reason why they exist is to reduce the cognitive load when we write code so that we don’t need to worry about manipulating the DOM ourselves or even dealing with messy browser APIs (another problem JQuery came to solve), which is not only error prone but also not productive. - -This is what we have been doing this whole time in computer science. We use low-level abstractions and build even more abstractions on top of it. The more we worry about describing how our software should work instead of making it work, the more productive we are. - -But all those tools have something in common: **they exist because the web platform moves too fast**. Nowadays we’re using web technology everywhere: in web browsers, in desktop applications, in phone applications or even in watch applications. - -This evolution also creates problems we need to solve. PWAs, for example, do not exist only because they’re cool and we programmers have fun writing them. Remember the first section of this post: **PWAs exist because they create business value**. - -And usually standards are not fast enough to be created and therefore we need to create our own solutions to these things, which is why it is great to have such a vibrant and creative community with us. We’re solving problems all the time and **we are allowing natural selection to do its job**. - -The tools that suit us better thrive, get more contributors and develop themselves more quickly and sometimes other tools end up incorporating the good ideas from the ones that thrive and becoming even more popular than them. This is how we evolve. - -By having more tools we also have more choices. If you remember the UNIX philosophy well, it states that we should aim at creating programs that do one thing and do it well. - -We can clearly see this happening in the JS testing environment, for example, where we have Mocha for running tests and Chai for doing assertions, while in Java JUnit tries to do all these things. This means that if we have a problem with one of them or if we find another one that suits us better, we can simply replace that small part and still have the advantages of the other ones. - -The UNIX philosophy also states that we should write programs that work together. And this is exactly what we are doing! Take a look at Babel, Webpack and React, for example. They work very well together but we still do not need one to use the other. In the testing environment, for example, if we’re using Mocha and Chai all of a sudden we can just install Karma and run those same tests in multiple environments. - -### How to Deal With It - -My first advice for anyone suffering from JS Fatigue would definitely be to stay aware that **you don’t need to know everything**. Trying to learn it all at once, even when we don’t have to do so, only increases the feeling of fatigue. Go deep in areas that you love and for which you feel an inner motivation to study and adopt a lazy approach when it comes to the other ones. I’m not saying that you should be lazy, I’m just saying that you can learn those only when needed. Whenever you face a problem that requires you to use a certain technology to solve it, go learn. - -Another important thing to say is that **you should start from the beginning**. Make sure you have learned enough about JavaScript itself before using any JavaScript frameworks. This is the only way you will be able to understand them and bend them to your will, otherwise, whenever you face an error you have never seen before you won’t know which steps to take in order to solve it. Learning core web technologies such as CSS, HTML5, JavaScript and also computer science fundamentals or even how the HTTP protocol works will help you master any other technologies a lot more quickly. - -But please, don’t get too attached to that. Sometimes you gotta risk yourself and start doing things on your own. As Sacha Greif has written in [this blog post][8], spending too much time learning the fundamentals is just like trying to learn how to swim by studying fluid dynamics. Sometimes you just gotta jump into the pool and try to swim by yourself. - -And please, don’t get too attached to a single technology. All of the things we have available nowadays have already been invented in the past. Of course, they have different features and a brand new name, but, in their essence, they are all the same. - -If you look at NPM, it is nothing new, we already had Maven Central and Ruby Gems quite a long time ago. - -In order to transpile your code, Babel applies the very same principles and theory as some of the oldest and most well-known compilers, such as the GCC. - -Even JSX is not a new idea. It E4X (ECMAScript for XML) already existed more than 10 years ago. - -Now you might ask: “what about Gulp, Grunt and NPM Scripts?” Well, I’m sorry but we can solve all those problems with GNU Make in 1976. And actually, there are a reasonable number of JavaScript projects that still use it, such as Chai.js, for example. But we do not do that because we are hipsters that like vintage stuff. We use `make` because it solves our problems, and this is what you should aim at doing, as we’ve talked before. - -If you really want to understand a certain technology and be able to solve any problems you might face, please, dig deep. One of the most decisive factors to success is curiosity, so **dig deep into the technologies you like**. Try to understand them from bottom-up and whenever you think something is just “magic”, debunk that myth by exploring the codebase by yourself. - -In my opinion, there is no better quote than this one by Richard Feinman, when it comes to really learning something: - -> What I cannot create, I do not understand - -And just below this phrase, [in the same blackboard, Richard also wrote][9]: - -> Know how to solve every problem that has been solved - -Isn’t this just amazing? - -When Richard said that, he was talking about being able to take any theoretical result and re-derive it, but I think the exact same principle can be applied to software engineering. The tools that solve our problems have already been invented, they already exist, so we should be able to get to them all by ourselves. - -This is the very reason I love [some of the videos available in Egghead.io][10] in which Dan Abramov explains how to implement certain features that exist in Redux from scratch or [blog posts that teach you how to build your own JSX renderer][11]. - -So why not trying to implement these things by yourself or going to GitHub and reading their codebase in order to understand how they work? I’m sure you will find a lot of useful knowledge out there. Comments and tutorials might lie and be incorrect sometimes, the code cannot. - -Another thing that we have been talking a lot in this post is that **you should not get ahead of yourself**. Follow a TDD approach and solve one problem at a time. You are paid to increase revenue and decrease cost and you do this by solving problems, this is the reason why software exists. - -And since we love comparing our role to the ones related to civil engineering, let’s do a quick comparison between software development and civil engineering, just as [Sam Newman does in his brilliant book called “Building Microservices”][12]. - -We love calling ourselves “engineers” or “architects”, but is that term really correct? We have been developing software for what we know as computers less than a hundred years ago, while the Colosseum, for example, exists for about two thousand years. - -When was the last time you’ve seen a bridge falling and when was the last time your telephone or your browser crashed? - -In order to explain this, I’ll use an example I love. - -This is the beautiful and awesome city of Barcelona: - -![The City of Barcelona][13] - -When we look at it this way and from this distance, it just looks like any other city in the world, but when we look at it from above, this is how Barcelona looks: - -![Barcelona from above][14] - -As you can see, every block has the same size and all of them are very organized. If you’ve ever been to Barcelona you will also know how good it is to move through the city and how well it works. - -But the people that planned Barcelona could not predict what it was going to look like in the next two or three hundred years. In cities, people come in and people move through it all the time so what they had to do was make it grow organically and adapt as the time goes by. They had to be prepared for changes. - -This very same thing happens to our software. It evolves quickly, refactors are often needed and requirements change more frequently than we would like them to. - -So, instead of acting like a Software Engineer, act as a Town Planner. Let your software grow organically and adapt as needed. Solve problems as they come by but make sure everything still has its place. - -Doing this when it comes to software is even easier than doing this in cities due to the fact that **software is flexible, civil engineering is not**. **In the software world, our build time is compile time**. In Barcelona we cannot simply destroy buildings to give space to new ones, in Software we can do that a lot easier. We can break things all the time, we can make experiments because we can build as many times as we want and it usually takes seconds and we spend a lot more time thinking than building. Our job is purely intellectual. - -So **act like a town planner, let your software grow and adapt as needed**. - -By doing this you will also have better abstractions and know when it’s the right time to adopt them. - -As Sam Koblenski says: - -> Abstractions only work well in the right context, and the right context develops as the system develops. - -Nowadays something I see very often is people looking for boilerplates when they’re trying to learn a new technology, but, in my opinion, **you should avoid boilerplates when you’re starting out**. Of course boilerplates and generators are useful if you are already experienced, but they take a lot of control out of your hands and therefore you won’t learn how to set up a project and you won’t understand exactly where each piece of the software you are using fits. - -When you feel like you are struggling more than necessary to get something simple done, it might be the right time for you to look for an easier way to do this. In our role **you should strive to be lazy** , you should work to not work. By doing that you have more free time to do other things and this decreases cost and increases revenue, so that’s another way of accomplishing your goal. You should not only work harder, you should work smarter. - -Probably someone has already had the same problem as you’re having right now, but if nobody did it might be your time to shine and build your own solution and help other people. - -But sometimes you will not be able to realize you could be more effective in your tasks until you see someone doing them better. This is why it is so important to **talk to people**. - -By talking to people you share experiences that help each other’s careers and we discover new tools to improve our workflow and, even more important than that, learn how they solve their problems. This is why I like reading blog posts in which companies explain how they solve their problems. - -Especially in our area we like to think that Google and StackOverflow can answer all our questions, but we still need to know which questions to ask. I’m sure you have already had a problem you could not find a solution for because you didn’t know exactly what was happening and therefore didn’t know what was the right question to ask. - -But if I needed to sum this whole post in a single advice, it would be: - -Solve problems. - -Software is not a magic box, software is not poetry (unfortunately). It exists to solve problems and improves peoples’ lives. Software exists to push the world forward. - -**Now it’s your time to go out there and solve problems**. - - --------------------------------------------------------------------------------- - -via: https://lucasfcosta.com/2017/07/17/The-Ultimate-Guide-to-JavaScript-Fatigue.html - -作者:[Lucas Fernandes Da Costa][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://lucasfcosta.com -[b]: https://github.com/lujun9972 -[1]: http://www.kalzumeus.com/2011/10/28/dont-call-yourself-a-programmer/ -[2]: http://ieeexplore.ieee.org/document/1702333/ -[3]: https://en.wikipedia.org/wiki/Test_Driven_Development -[4]: https://en.wikipedia.org/wiki/Analysis_paralysis -[5]: https://babeljs.io/blog/2016/12/07/the-state-of-babel -[6]: http://requirejs.org -[7]: https://benmccormick.org/2015/05/28/moving-past-requirejs/ -[8]: https://medium.freecodecamp.org/a-study-plan-to-cure-javascript-fatigue-8ad3a54f2eb1 -[9]: https://www.quora.com/What-did-Richard-Feynman-mean-when-he-said-What-I-cannot-create-I-do-not-understand -[10]: https://egghead.io/lessons/javascript-redux-implementing-store-from-scratch -[11]: https://jasonformat.com/wtf-is-jsx/ -[12]: https://www.barnesandnoble.com/p/building-microservices-sam-newman/1119741399/2677517060476?st=PLA&sid=BNB_DRS_Marketplace+Shopping+Books_00000000&2sid=Google_&sourceId=PLGoP4760&k_clickid=3x4760 -[13]: /assets/barcelona-city.jpeg -[14]: /assets/barcelona-above.jpeg -[15]: https://twitter.com/thewizardlucas diff --git a/sources/talk/20170911 What every software engineer should know about search.md b/sources/talk/20170911 What every software engineer should know about search.md deleted file mode 100644 index 474a63201f..0000000000 --- a/sources/talk/20170911 What every software engineer should know about search.md +++ /dev/null @@ -1,513 +0,0 @@ -What every software engineer should know about search -============================================================ - -![](https://cdn-images-1.medium.com/max/2000/1*5AlsVRQrewLw74uHYTZ36w.jpeg) - - -### Want to build or improve a search experience? Start here. - -Ask a software engineer: “[How would you add search functionality to your product?][78]” or “[How do I build a search engine?][79]” You’ll probably immediately hear back something like: “Oh, we’d just launch an ElasticSearch cluster. Search is easy these days.” - -But is it? Numerous current products [still][80] [have][81] [suboptimal][82] [search][83] [experiences][84]. Any true search expert will tell you that few engineers have a very deep understanding of how search engines work, knowledge that’s often needed to improve search quality. - -Even though many open source software packages exist, and the research is vast, the knowledge around building solid search experiences is limited to a select few. Ironically, [searching online][85] for search-related expertise doesn’t yield any recent, thoughtful overviews. - -#### Emoji Legend - -``` -❗ “Serious” gotcha: consequences of ignorance can be deadly -🔷 Especially notable idea or piece of technology -☁️ ️Cloud/SaaS -🍺 Open source / free software -🦏 JavaScript -🐍 Python -☕ Java -🇨 C/C++ -``` - -### Why read this? - -Think of this post as a collection of insights and resources that could help you to build search experiences. It can’t be a complete reference, of course, but hopefully we can improve it based on feedback (please comment or reach out!). - -I’ll point at some of the most popular approaches, algorithms, techniques, and tools, based on my work on general purpose and niche search experiences of varying sizes at Google, Airbnb and several startups. - -❗️Not appreciating or understanding the scope and complexity of search problems can lead to bad user experiences, wasted engineering effort, and product failure. - -If you’re impatient or already know a lot of this, you might find it useful to jump ahead to the tools and services sections. - -### Some philosophy - -This is a long read. But most of what we cover has four underlying principles: - -#### 🔷 Search is an inherently messy problem: - -* Queries are highly variable. The search problems are highly variablebased on product needs. - -* Think about how different Facebook search (searching a graph of people). - -* YouTube search (searching individual videos). - -* Or how different both of those are are from Kayak ([air travel planning is a really hairy problem][2]). - -* Google Maps (making sense of geo-spacial data). - -* Pinterest (pictures of a brunch you might cook one day). - -#### Quality, metrics, and processes matter a lot: - -* There is no magic bullet (like PageRank) nor a magic ranking formula that makes for a good approach. Processes are always evolving collection of techniques and processes that solve aspects of the problem and improve overall experience, usually gradually and continuously. - -* ❗️In other words, search is not just just about building software that does ranking or retrieval (which we will discuss below) for a specific domain. Search systems are usually an evolving pipeline of components that are tuned and evolve over time and that build up to a cohesive experience. - -* In particular, the key to success in search is building processes for evaluation and tuning into the product and development cycles. A search system architect should think about processes and metrics, not just technologies. - -#### Use existing technologies first: - -* As in most engineering problems, don’t reinvent the wheel yourself. When possible, use existing services or open source tools. If an existing SaaS (such as [Algolia][3] or managed Elasticsearch) fits your constraints and you can afford to pay for it, use it. This solution will likely will be the best choice for your product at first, even if down the road you need to customize, enhance, or replace it. - -#### ❗️Even if you buy, know the details: - -* Even if you are using an existing open source or commercial solution, you should have some sense of the complexity of the search problem and where there are likely to be pitfalls. - -### Theory: the search problem - -Search is different for every product, and choices depend on many technical details of the requirements. It helps to identify the key parameters of your search problem: - -1. Size: How big is the corpus (a complete set of documents that need to be searched)? Is it thousands or billions of documents? - -2. Media: Are you searching through text, images, graphical relationships, or geospatial data? - -3. 🔷 Corpus control and quality: Are the sources for the documents under your control, or coming from a (potentially adversarial) third party? Are all the documents ready to be indexed or need to be cleaned up and selected? - -4. Indexing speed: Do you need real-time indexing, or is building indices in batch is fine? - -5. Query language: Are the queries structured, or you need to support unstructured ones? - -6. Query structure: Are your queries textual, images, sounds? Street addresses, record ids, people’s faces? - -7. Context-dependence: Do the results depend on who the user is, what is their history with the product, their geographical location, time of the day etc? - -8. Suggest support: Do you need to support incomplete queries? - -9. Latency: What are the serving latency requirements? 100 milliseconds or 100 seconds? - -10. Access control: Is it entirely public or should users only see a restricted subset of the documents? - -11. Compliance: Are there compliance or organizational limitations? - -12. Internationalization: Do you need to support documents with multilingual character sets or Unicode? (Hint: Always use UTF-8 unless you really know what you’re doing.) Do you need to support a multilingual corpus? Multilingual queries? - -Thinking through these points up front can help you make significant choices designing and building individual search system components. - - ** 此处有Canvas,请手动处理 ** - -![](https://cdn-images-1.medium.com/max/1600/1*qTK1iCtyJUr4zOyw4IFD7A.jpeg) -A production indexing pipeline. - -### Theory: the search pipeline - -Now let’s go through a list of search sub-problems. These are usually solved by separate subsystems that form a pipeline. What that means is that a given subsystem consumes the output of previous subsystems, and produces input for the following subsystems. - -This leads to an important property of the ecosystem: once you change how an upstream subsystem works, you need to evaluate the effect of the change and possibly change the behavior downstream. - -Here are the most important problems you need to solve: - -#### Index selection: - -given a set of documents (e.g. the entirety of the Internet, all the Twitter posts, all the pictures on Instagram), select a potentially smaller subset of documents that may be worthy for consideration as search results and only include those in the index, discarding the rest. This is done to keep your indexes compact, and is almost orthogonal to selecting the documents to show to the user. Examples of particular classes of documents that don’t make the cut may include: - -#### Spam: - -oh, all the different shapes and sizes of search spam! A giant topic in itself, worthy of a separate guide. [A good web spam taxonomy overview][86]. - -#### Undesirable documents: - -domain constraints might require filtering: [porn][87], illegal content, etc. The techniques are similar to spam filtering, probably with extra heuristics. - -#### Duplicates: - -Or near-duplicates and redundant documents. Can be done with [Locality-sensitive hashing][88], [similarity measures][89], clustering techniques or even [clickthrough data][90]. A [good overview][91] of techniques. - -#### Low-utility documents: - -The definition of utility depends highly on the problem domain, so it’s hard to recommend the approaches here. Some ideas are: it might be possible to build a utility function for your documents; heuristics might work, or example an image that contains only black pixels is not a useful document; utility might be learned from user behavior. - -#### Index construction: - -For most search systems, document retrieval is performed using an [inverted index][92] — often just called the index. - -* The index is a mapping of search terms to documents. A search term could be a word, an image feature or any other document derivative useful for query-to-document matching. The list of the documents for a given term is called a [posting list][1]. It can be sorted by some metric, like document quality. - -* Figure out whether you need to index the data in real time.❗️Many companies with large corpora of documents use a batch-oriented indexing approach, but then find this is unsuited to a product where users expect results to be current. - -* With text documents, term extraction usually involves using NLP techniques, such as stop lists, [stemming][4] and [entity extraction][5]; for images or videos computer vision methods are used etc. - -* In addition, documents are mined for statistical and meta information, such as references to other documents (used in the famous [PageRank][6]ranking signal), [topics][7], counts of term occurrences, document size, entities A mentioned etc. That information can be later used in ranking signal construction or document clustering. Some larger systems might contain several indexes, e.g. for documents of different types. - -* Index formats. The actual structure and layout of the index is a complex topic, since it can be optimized in many ways. For instance there are [posting lists compression methods][8], one could target [mmap()able data representation][9] or use[ LSM-tree][10] for continuously updated index. - -#### Query analysis and document retrieval: - -Most popular search systems allow non-structured queries. That means the system has to extract structure out of the query itself. In the case of an inverted index, you need to extract search terms using [NLP][93] techniques. - -The extracted terms can be used to retrieve relevant documents. Unfortunately, most queries are not very well formulated, so it pays to do additional query expansion and rewriting, like: - -* [Term re-weighting][11]. - -* [Spell checking][12]. Historical query logs are very useful as a dictionary. - -* [Synonym matching][13]. [Another survey][14]. - -* [Named entity recognition][15]. A good approach is to use [HMM-based language modeling][16]. - -* Query classification. Detect queries of particular type. For example, Google Search detects queries that contain a geographical entity, a porny query, or a query about something in the news. The retrieval algorithm can then make a decision about which corpora or indexes to look at. - -* Expansion through [personalization][17] or [local context][18]. Useful for queries like “gas stations around me”. - -#### Ranking: - -Given a list of documents (retrieved in the previous step), their signals, and a processed query, create an optimal ordering (ranking) for those documents. - -Originally, most ranking models in use were hand-tuned weighted combinations of all the document signals. Signal sets might include PageRank, clickthrough data, topicality information and [others][94]. - -To further complicate things, many of those signals, such as PageRank, or ones generated by [statistical language models][95] contain parameters that greatly affect the performance of a signal. Those have to be hand-tuned too. - -Lately, 🔷 [learning to rank][96], signal-based discriminative supervised approaches are becoming more and more popular. Some popular examples of LtR are [McRank][97] and [LambdaRank][98] from Microsoft, and [MatrixNet][99] from Yandex. - -A new, [vector space based approach][100] for semantic retrieval and ranking is gaining popularity lately. The idea is to learn individual low-dimensional vector document representations, then build a model which maps queries into the same vector space. - -Then, retrieval is just finding several documents that are closest by some metric (e.g. Eucledian distance) to the query vector. Ranking is the distance itself. If the mapping of both the documents and queries is built well, the documents are chosen not by a fact of presence of some simple pattern (like a word), but how close the documents are to the query by  _meaning_ . - -### Indexing pipeline operation - -Usually, each of the above pieces of the pipeline must be operated on a regular basis to keep the search index and search experience current. - -❗️Operating a search pipeline can be complex and involve a lot of moving pieces. Not only is the data moving through the pipeline, but the code for each module and the formats and assumptions embedded in the data will change over time. - -A pipeline can be run in “batch” or based on a regular or occasional basis (if indexing speed does not need to be real time) or in a streamed way (if real-time indexing is needed) or based on certain triggers. - -Some complex search engines (like Google) have several layers of pipelines operating on different time scales — for example, a page that changes often (like [cnn.com][101]) is indexed with a higher frequency than a static page that hasn’t changed in years. - -### Serving systems - -Ultimately, the goal of a search system is to accept queries, and use the index to return appropriately ranked results. While this subject can be incredibly complex and technical, we mention a few of the key aspects to this part of the system. - -* Performance: users notice when the system they interact with is laggy. ❗️Google has done [extensive research][19], and they have noticed that number of searches falls 0.6%, when serving is slowed by 300ms. They recommend to serve results under 200 ms for most of your queries. A good article [on the topic][20]. This is the hard part: the system needs to collect documents from, possibly, many computers, than merge them into possible a very long list and then sort that list in the ranking order. To complicate things further, ranking might be query-dependent, so, while sorting, the system is not just comparing 2 numbers, but performing computation. - -* 🔷 Caching results: is often necessary to achieve decent performance. ❗️ But caches are just one large gotcha. The might show stale results when indices are updated or some results are blacklisted. Purging caches is a can of warm of itself: a search system might not have the capacity to serve the entire query stream with an empty (cold) cache, so the [cache needs to be pre-warmed][21] before the queries start arriving. Overall, caches complicate a system’s performance profile. Choosing a cache size and a replacement algorithm is also a [challenge][22]. - -* Availability: is often defined by an uptime/(uptime + downtime) metric. When index is distributed, in order to serve any search results, the system often needs to query all the shards for their share of results. ❗️That means, that if one shard is unavailable, the entire search system is compromised. The more machines are involved in serving the index — the higher the probability of one of them becoming defunct and bringing the whole system down. - -* Managing multiple indices: Indices for large systems may separated into shards (pieces) or divided by media type or indexing cadence (fresh versus long-term indices). Results can then be merged. - -* Merging results of different kinds: e.g. Google showing results from Maps, News etc. - - ** 此处有Canvas,请手动处理 ** - -![](https://cdn-images-1.medium.com/max/1600/1*M8WQu17E7SDziV0rVwUKbw.jpeg) -A human rater. Yeah, you should still have those. - -### Quality, evaluation, and improvement - -So you’ve launched your indexing pipeline and search servers, and it’s all running nicely. Unfortunately the road to a solid search experience only begins with running infrastructure. - -Next, you’ll need to build a set of processes around continuous search quality evaluation and improvement. In fact, this is actually most of the work and the hardest problem you’ll have to solve. - -🔷 What is quality? First, you’ll need to determine (and get your boss or the product lead to agree), what quality means in your case: - -* Self-reported user satisfaction (includes UX) - -* Perceived relevance of the returned results (not including UX) - -* Satisfaction relative to competitors - -* Satisfaction relative performance of the previous version of the search engine (e.g. last week) - -* [User engagement][23] - -Metrics: Some of these concepts can be quite hard to quantify. On the other hand, it’s incredibly useful to be able to express how well a search engine is performing in a single number, a quality metric. - -Continuously computing such a metric for your (and your competitors’) system you can both track your progress and explain how well you are doing to your boss. Here are some classical ways to quantify quality, that can help you construct your magic quality metric formula: - -* [Precision][24] and [recall][25] measure how well the retrieved set of documents corresponds to the set you expected to see. - -* [F score][26] (specifically F1 score) is a single number, that represents both precision and recall well. - -* [Mean Average Precision][27] (MAP) allows to quantify the relevance of the top returned results. - -* 🔷 [Normalized Discounted Cumulative Gain][28] (nDCG) is like MAP, but weights the relevance of the result by its position. - -* [Long and short clicks][29] — Allow to quantify how useful the results are to the real users. - -* [A good detailed overview][30]. - -🔷 Human evaluations: Quality metrics might seem like statistical calculations, but they can’t all be done by automated calculations. Ultimately, metrics need to represent subjective human evaluation, and this is where a “human in the loop” comes into play. - -❗️Skipping human evaluation is probably the most spread reason of sub-par search experiences. - -Usually, at early stages the developers themselves evaluate the results manually. At later point [human raters][102] (or assessors) may get involved. Raters typically use custom tools to look at returned search results and provide feedback on the quality of the results. - -Subsequently, you can use the feedback signals to guide development, help make launch decisions or even feed them back into the index selection, retrieval or ranking systems. - -Here is the list of some other types of human-driven evaluation, that can be done on a search system: - -* Basic user evaluation: The user ranks their satisfaction with the whole experience - -* Comparative evaluation: Compare with other search results (compare with search results from earlier versions of the system or competitors) - -* Retrieval evaluation: The query analysis and retrieval quality is often evaluated using manually constructed query-document sets. A user is shown a query and the list of the retrieved documents. She can then mark all the documents that are relevant to the query, and the ones that are not. The resulting pairs of (query, [relevant docs]) are called a “golden set”. Golden sets are remarkably useful. For one, an engineer can set up automatic retrieval regression tests using those sets. The selection signal from golden sets can also be fed back as ground truth to term re-weighting and other query re-writing models. - -* Ranking evaluation: Raters are presented with a query and two documents side-by-side. The rater must choose the document that fits the query better. This creates a partial ordering on the documents for a given query. That ordering can be later be compared to the output of the ranking system. The usual ranking quality measures used are MAP and nDCG. - -#### Evaluation datasets: - -One should start thinking about the datasets used for evaluation (like “golden sets” mentioned above) early in the search experience design process. How you collect and update them? How you push them to the production eval pipeline? Is there a built-in bias? - -Live experiments: - -After your search engine catches on and gains enough users, you might want to start conducting [live search experiments][103] on a portion of your traffic. The basic idea is to turn some optimization on for a group of people, and then compare the outcome with that of a “control” group — a similar sample of your users that did not have the experiment feature on for them. How you would measure the outcome is, once again, very product specific: it could be clicks on results, clicks on ads etc. - -Evaluation cycle time: How fast you improve your search quality is directly related to how fast you can complete the above cycle of measurement and improvement. It is essential from the beginning to ask yourself, “how fast can we measure and improve our performance?” - -Will it take days, hours, minutes or seconds to make changes and see if they improve quality? ❗️Running evaluation should also be as easy as possible for the engineers and should not take too much hands-on time. - -### 🔷 So… How do I PRACTICALLY build it? - -This blogpost is not meant as a tutorial, but here is a brief outline of how I’d approach building a search experience right now: - -1. As was said above, if you can afford it — just buy the existing SaaS (some good ones are listed below). An existing service fits if: - -* Your experience is a “connected” one (your service or app has internet connection). - -* Does it support all the functionality you need out of box? This post gives a pretty good idea of what functions would you want. To name a few, I’d at least consider: support for the media you are searching; real-time indexing support; query flexibility, including context-dependent queries. - -* Given the size of the corpus and the expected [QpS][31], can you afford to pay for it for the next 12 months? - -* Can the service support your expected traffic within the required latency limits? In case when you are querying the service from an app, make sure that the given service is accessible quickly enough from where your users are. - -2\. If a hosted solution does not fit your needs or resources, you probably want to use one of the open source libraries or tools. In case of connected apps or websites, I’d choose ElasticSearch right now. For embedded experiences, there are multiple tools below. - -3\. You most likely want to do index selection and clean up your documents (say extract relevant text from HTML pages) before uploading them to the search index. This will decrease the index size and make getting to good results easier. If your corpus fits on a single machine, just write a script (or several) to do that. If not, I’d use [Spark][104]. - - ** 此处有Canvas,请手动处理 ** - -![](https://cdn-images-1.medium.com/max/1600/1*lGw4kVVQyj8E5by2GWVoQg.jpeg) -You can never have too many tools. - -### ☁️ SaaS - -☁️ 🔷[Algolia][105] — a proprietary SaaS that indexes a client’s website and provides an API to search the website’s pages. They also have an API to submit your own documents, support context dependent searches and serve results really fast. If I were building a web search experience right now and could afford it, I’d probably use Algolia first — and buy myself time to build a comparable search experience. - -* Various ElasticSearch providers: AWS (☁️ [ElasticSearch Cloud)][32], ☁️[elastic.co][33] and from ☁️ [Qbox][34]. - -* ☁️[ Azure Search][35] — a SaaS solution from Microsoft. Accessible through a REST API, it can scale to billions of documents. Has a Lucene query interface to simplify migrations from Lucene-based solutions. - -* ☁️[ Swiftype][36] — an enterprise SaaS that indexes your company’s internal services, like Salesforce, G Suite, Dropbox and the intranet site. - -### Tools and libraries - -🍺☕🔷[ Lucene][106] is the most popular IR library. Implements query analysis, index retrieval and ranking. Either of the components can be replaced by an alternative implementation. There is also a C port — 🍺[Lucy][107]. - -* 🍺☕🔷[ Solr][37] is a complete search server, based on Lucene. It’s a part of the [Hadoop][38] ecosystem of tools. - -* 🍺☕🔷[ Hadoop][39] is the most widely used open source MapReduce system, originally designed as a indexing pipeline framework for Solr. It has been gradually loosing ground to 🍺[Spark][40] as the batch data processing framework used for indexing. ☁️[EMR][41] is a proprietary implementation of MapReduce on AWS. - -* 🍺☕🔷 [ElasticSearch][42] is also based on Lucene ([feature comparison with Solr][43]). It has been getting more attention lately, so much that a lot of people think of ES when they hear “search”, and for good reasons: it’s well supported, has [extensive API][44], [integrates with Hadoop][45] and [scales well][46]. There are open source and [Enterprise][47] versions. ES is also available as a SaaS on Can scale to billions of documents, but scaling to that point can be very challenging, so typical scenario would involve orders of magnitude smaller corpus. - -* 🍺🇨 [Xapian][48] — a C++-based IR library. Relatively compact, so good for embedding into desktop or mobile applications. - -* 🍺🇨 [Sphinx][49] — an full-text search server. Has a SQL-like query language. Can also act as a [storage engine for MySQL][50] or used as a library. - -* 🍺☕ [Nutch][51] — a web crawler. Can be used in conjunction with Solr. It’s also the tool behind [🍺Common Crawl][52]. - -* 🍺🦏 [Lunr][53] — a compact embedded search library for web apps on the client-side. - -* 🍺🦏 [searchkit][54] — a library of web UI components to use with ElasticSearch. - -* 🍺🦏 [Norch][55] — a [LevelDB][56]-based search engine library for Node.js. - -* 🍺🐍 [Whoosh][57] — a fast, full-featured search library implemented in pure Python. - -* OpenStreetMaps has it’s own 🍺[deck of search software][58]. - -### Datasets - -A few fun or useful data sets to try building a search engine or evaluating search engine quality: - -* 🍺🔷 [Commoncrawl][59] — a regularly-updated open web crawl data. There is a [mirror on AWS][60], accessible for free within the service. - -* 🍺🔷 [Openstreetmap data dump][61] is a very rich source of data for someone building a geospacial search engine. - -* 🍺 [Google Books N-grams][62] can be very useful for building language models. - -* 🍺 [Wikipedia dumps][63] are a classic source to build, among other things, an entity graph out of. There is a [wide range of helper tools][64] available. - -* [IMDb dumps][65] are a fun dataset to build a small toy search engine for. - -### References - -* [Modern Information Retrieval][66] by R. Baeza-Yates and B. Ribeiro-Neto is a good, deep academic treatment of the subject. This is a good overview for someone completely new to the topic. - -* [Information Retrieval][67] by S. Büttcher, C. Clarke and G. Cormack is another academic textbook with a wide coverage and is more up-to-date. Covers learn-to-rank and does a pretty good job at discussing theory of search systems evaluation. Also is a good overview. - -* [Learning to Rank][68] by T-Y Liu is a best theoretical treatment of LtR. Pretty thin on practical aspects though. Someone considering building an LtR system should probably check this out. - -* [Managing Gigabytes][69] — published in 1999, is still a definitive reference for anyone embarking on building an efficient index of a significant size. - -* [Text Retrieval and Search Engines][70] — a MOOC from Coursera. A decent overview of basics. - -* [Indexing the World Wide Web: The Journey So Far][71] ([PDF][72]), an overview of web search from 2012, by Ankit Jain and Abhishek Das of Google. - -* [Why Writing Your Own Search Engine is Hard][73] a classic article from 2004 from Anna Patterson. - -* [https://github.com/harpribot/awesome-information-retrieval][74] — a curated list of search-related resources. - -* A [great blog][75] on everything search by [Daniel Tunkelang][76]. - -* Some good slides on [search engine evaluation][77]. - -This concludes my humble attempt to make a somewhat-useful “map” for an aspiring search engine engineer. Did I miss something important? I’m pretty sure I did — you know, [the margin is too narrow][108] to contain this enormous topic. Let me know if you think that something should be here and is not — you can reach [me][109] at[ forwidur@gmail.com][110] or at [@forwidur][111]. - -> P.S. — This post is part of a open, collaborative effort to build an online reference, the Open Guide to Practical AI, which we’ll release in draft form soon. See [this popular guide][112] for an example of what’s coming. If you’d like to get updates on or help with with this effort, sign up [here][113]. - -> Special thanks to [Joshua Levy][114], [Leo Polovets][115] and [Abhishek Das][116] for reading drafts of this and their invaluable feedback! - -> Header image courtesy of [Mickaël Forrett][117]. The beautiful toolbox is called [The Studley Tool Chest][118]. - --------------------------------------------------------------------------------- - -作者简介: - -Max Grigorev -distributed systems, data, AI - -------------- - - -via: https://medium.com/startup-grind/what-every-software-engineer-should-know-about-search-27d1df99f80d - -作者:[Max Grigorev][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://medium.com/@forwidur?source=post_header_lockup -[1]:https://en.wikipedia.org/wiki/Inverted_index -[2]:http://www.demarcken.org/carl/papers/ITA-software-travel-complexity/ITA-software-travel-complexity.pdf -[3]:https://www.algolia.com/ -[4]:https://en.wikipedia.org/wiki/Stemming -[5]:https://en.wikipedia.org/wiki/Named-entity_recognition -[6]:http://ilpubs.stanford.edu:8090/422/1/1999-66.pdf -[7]:https://gofishdigital.com/semantic-topic-modeling/ -[8]:https://nlp.stanford.edu/IR-book/html/htmledition/postings-file-compression-1.html -[9]:https://deplinenoise.wordpress.com/2013/03/31/fast-mmapable-data-structures/ -[10]:https://en.wikipedia.org/wiki/Log-structured_merge-tree -[11]:http://orion.lcg.ufrj.br/Dr.Dobbs/books/book5/chap11.htm -[12]:http://norvig.com/spell-correct.html -[13]:http://nlp.stanford.edu/IR-book/html/htmledition/query-expansion-1.html -[14]:https://www.iro.umontreal.ca/~nie/IFT6255/carpineto-Survey-QE.pdf -[15]:https://en.wikipedia.org/wiki/Named-entity_recognition -[16]:http://www.aclweb.org/anthology/P02-1060 -[17]:https://en.wikipedia.org/wiki/Personalized_search -[18]:http://searchengineland.com/future-search-engines-context-217550 -[19]:http://services.google.com/fh/files/blogs/google_delayexp.pdf -[20]:http://highscalability.com/latency-everywhere-and-it-costs-you-sales-how-crush-it -[21]:https://stackoverflow.com/questions/22756092/what-does-it-mean-by-cold-cache-and-warm-cache-concept -[22]:https://en.wikipedia.org/wiki/Cache_performance_measurement_and_metric -[23]:http://blog.popcornmetrics.com/5-user-engagement-metrics-for-growth/ -[24]:https://en.wikipedia.org/wiki/Information_retrieval#Precision -[25]:https://en.wikipedia.org/wiki/Information_retrieval#Recall -[26]:https://en.wikipedia.org/wiki/F1_score -[27]:http://fastml.com/what-you-wanted-to-know-about-mean-average-precision/ -[28]:https://en.wikipedia.org/wiki/Discounted_cumulative_gain -[29]:http://www.blindfiveyearold.com/short-clicks-versus-long-clicks -[30]:https://arxiv.org/pdf/1302.2318.pdf -[31]:https://en.wikipedia.org/wiki/Queries_per_second -[32]:https://aws.amazon.com/elasticsearch-service/ -[33]:https://www.elastic.co/ -[34]:https://qbox.io/ -[35]:https://azure.microsoft.com/en-us/services/search/ -[36]:https://swiftype.com/ -[37]:http://lucene.apache.org/solr/ -[38]:http://hadoop.apache.org/ -[39]:http://hadoop.apache.org/ -[40]:http://spark.apache.org/ -[41]:https://aws.amazon.com/emr/ -[42]:https://www.elastic.co/products/elasticsearch -[43]:http://solr-vs-elasticsearch.com/ -[44]:https://www.elastic.co/guide/en/elasticsearch/reference/current/docs.html -[45]:https://github.com/elastic/elasticsearch-hadoop -[46]:https://www.elastic.co/guide/en/elasticsearch/guide/current/distributed-cluster.html -[47]:https://www.elastic.co/cloud/enterprise -[48]:https://xapian.org/ -[49]:http://sphinxsearch.com/ -[50]:https://mariadb.com/kb/en/mariadb/sphinx-storage-engine/ -[51]:https://nutch.apache.org/ -[52]:http://commoncrawl.org/ -[53]:https://lunrjs.com/ -[54]:https://github.com/searchkit/searchkit -[55]:https://github.com/fergiemcdowall/norch -[56]:https://github.com/google/leveldb -[57]:https://bitbucket.org/mchaput/whoosh/wiki/Home -[58]:http://wiki.openstreetmap.org/wiki/Search_engines -[59]:http://commoncrawl.org/ -[60]:https://aws.amazon.com/public-datasets/common-crawl/ -[61]:http://wiki.openstreetmap.org/wiki/Downloading_data -[62]:http://commondatastorage.googleapis.com/books/syntactic-ngrams/index.html -[63]:https://dumps.wikimedia.org/ -[64]:https://www.mediawiki.org/wiki/Alternative_parsers -[65]:http://www.imdb.com/interfaces -[66]:https://www.amazon.com/dp/0321416910 -[67]:https://www.amazon.com/dp/0262528878/ -[68]:https://www.amazon.com/dp/3642142664/ -[69]:https://www.amazon.com/dp/1558605703 -[70]:https://www.coursera.org/learn/text-retrieval -[71]:https://research.google.com/pubs/pub37043.html -[72]:https://pdfs.semanticscholar.org/28d8/288bff1b1fc693e6d80c238de9fe8b5e8160.pdf -[73]:http://queue.acm.org/detail.cfm?id=988407 -[74]:https://github.com/harpribot/awesome-information-retrieval -[75]:https://medium.com/@dtunkelang -[76]:https://www.cs.cmu.edu/~quixote/ -[77]:https://web.stanford.edu/class/cs276/handouts/lecture8-evaluation_2014-one-per-page.pdf -[78]:https://stackoverflow.com/questions/34314/how-do-i-implement-search-functionality-in-a-website -[79]:https://www.quora.com/How-to-build-a-search-engine-from-scratch -[80]:https://github.com/isaacs/github/issues/908 -[81]:https://www.reddit.com/r/Windows10/comments/4jbxgo/can_we_talk_about_how_bad_windows_10_search_sucks/d365mce/ -[82]:https://www.reddit.com/r/spotify/comments/2apwpd/the_search_function_sucks_let_me_explain/ -[83]:https://medium.com/@RohitPaulK/github-issues-suck-723a5b80a1a3#.yp8ui3g9i -[84]:https://thenextweb.com/opinion/2016/01/11/netflix-search-sucks-flixed-fixes-it/ -[85]:https://www.google.com/search?q=building+a+search+engine -[86]:http://airweb.cse.lehigh.edu/2005/gyongyi.pdf -[87]:https://www.researchgate.net/profile/Gabriel_Sanchez-Perez/publication/262371199_Explicit_image_detection_using_YCbCr_space_color_model_as_skin_detection/links/549839cf0cf2519f5a1dd966.pdf -[88]:https://en.wikipedia.org/wiki/Locality-sensitive_hashing -[89]:https://en.wikipedia.org/wiki/Similarity_measure -[90]:https://www.microsoft.com/en-us/research/wp-content/uploads/2011/02/RadlinskiBennettYilmaz_WSDM2011.pdf -[91]:http://infolab.stanford.edu/~ullman/mmds/ch3.pdf -[92]:https://en.wikipedia.org/wiki/Inverted_index -[93]:https://en.wikipedia.org/wiki/Natural_language_processing -[94]:http://backlinko.com/google-ranking-factors -[95]:http://times.cs.uiuc.edu/czhai/pub/slmir-now.pdf -[96]:https://en.wikipedia.org/wiki/Learning_to_rank -[97]:https://papers.nips.cc/paper/3270-mcrank-learning-to-rank-using-multiple-classification-and-gradient-boosting.pdf -[98]:https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/lambdarank.pdf -[99]:https://yandex.com/company/technologies/matrixnet/ -[100]:https://arxiv.org/abs/1708.02702 -[101]:http://cnn.com/ -[102]:http://static.googleusercontent.com/media/www.google.com/en//insidesearch/howsearchworks/assets/searchqualityevaluatorguidelines.pdf -[103]:https://googleblog.blogspot.co.uk/2008/08/search-experiments-large-and-small.html -[104]:https://spark.apache.org/ -[105]:https://www.algolia.com/ -[106]:https://lucene.apache.org/ -[107]:https://lucy.apache.org/ -[108]:https://www.brainyquote.com/quotes/quotes/p/pierredefe204944.html -[109]:https://www.linkedin.com/in/grigorev/ -[110]:mailto:forwidur@gmail.com -[111]:https://twitter.com/forwidur -[112]:https://github.com/open-guides/og-aws -[113]:https://upscri.be/d29cfe/ -[114]:https://twitter.com/ojoshe -[115]:https://twitter.com/lpolovets -[116]:https://www.linkedin.com/in/abhishek-das-3280053/ -[117]:https://www.behance.net/gallery/3530289/-HORIZON- -[118]:https://en.wikipedia.org/wiki/Henry_O._Studley diff --git a/sources/talk/20171030 Why I love technical debt.md b/sources/talk/20171030 Why I love technical debt.md deleted file mode 100644 index da071d370a..0000000000 --- a/sources/talk/20171030 Why I love technical debt.md +++ /dev/null @@ -1,69 +0,0 @@ -Why I love technical debt -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_lovemoneyglory1.png?itok=nbSRovsj) -This is not necessarily the title you'd expect for an article, I guess,* but I'm a fan of [technical debt][1]. There are two reasons for this: a Bad Reason and a Good Reason. I'll be upfront about the Bad Reason first, then explain why even that isn't really a reason to love it. I'll then tackle the Good Reason, and you'll nod along in agreement. - -### The Bad Reason I love technical debt - -We'll get this out of the way, then, shall we? The Bad Reason is that, well, there's just lots of it, it's interesting, it keeps me in a job, and it always provides a reason, as a security architect, for me to get involved in** projects that might give me something new to look at. I suppose those aren't all bad things. It can also be a bit depressing, because there's always so much of it, it's not always interesting, and sometimes I need to get involved even when I might have better things to do. - -And what's worse is that it almost always seems to be security-related, and it's always there. That's the bad part. - -Security, we all know, is the piece that so often gets left out, or tacked on at the end, or done in half the time it deserves, or done by people who have half an idea, but don't quite fully grasp it. I should be clear at this point: I'm not saying that this last reason is those people's fault. That people know they need security is fantastic. If we (the security folks) or we (the organization) haven't done a good enough job in making sufficient security resources--whether people, training, or visibility--available to those people who need it, the fact that they're trying is great and something we can work on. Let's call that a positive. Or at least a reason for hope.*** - -### The Good Reason I love technical debt - -Let's get on to the other reason: the legitimate reason. I love technical debt when it's named. - -What does that mean? - -We all get that technical debt is a bad thing. It's what happens when you make decisions for pragmatic reasons that are likely to come back and bite you later in a project's lifecycle. Here are a few classic examples that relate to security: - - * Not getting around to applying authentication or authorization controls on APIs that might, at some point, be public. - * Lumping capabilities together so it's difficult to separate out appropriate roles later on. - * Hard-coding roles in ways that don't allow for customisation by people who may use your application in different ways from those you initially considered. - * Hard-coding cipher suites for cryptographic protocols, rather than putting them in a config file where they can be changed or selected later. - - - -There are lots more, of course, but those are just a few that jump out at me and that I've seen over the years. Technical debt means making decisions that will mean more work later on to fix them. And that can't be good, can it? - -There are two words in the preceding paragraphs that should make us happy: they are "decisions" and "pragmatic." Because, in order for something to be named technical debt, I'd argue, it has to have been subject to conscious decision-making, and trade-offs must have been made--hopefully for rational reasons. Those reasons may be many and various--lack of qualified resources; project deadlines; lack of sufficient requirement definition--but if they've been made consciously, then the technical debt can be named, and if technical debt can be named, it can be documented. - -And if it's documented, we're halfway there. As a security guy, I know that I can't force everything that goes out of the door to meet all the requirements I'd like--but the same goes for the high availability gal, the UX team, the performance folks, etc. - -What we need--what we all need--is for documentation to exist about why decisions were made, because when we return to the problem we'll know it was thought about. And, what's more, the recording of that information might even make it into product documentation. "This API is designed to be used in a protected environment and should not be exposed on the public Internet" is a great piece of documentation. It may not be what a customer is looking for, but at least they know how to deploy the product, and, crucially, it's an opportunity for them to come back to the product manager and say, "We'd really like to deploy that particular API in this way. Could you please add this as a feature request?" Product managers like that. Very much.**** - -The best thing, though, is not just that named technical debt is visible technical debt, but that if you encourage your developers to document the decisions in code,***** then there's a decent chance that they'll record some ideas about how this should be done in the future. If you're really lucky, they might even add some hooks in the code to make it easier (an "auth" parameter on the API, which is unused in the current version, but will make API compatibility so much simpler in new releases; or cipher entry in the config file that currently only accepts one option, but is at least checked by the code). - -I've been a bit disingenuous, I know, by defining technical debt as named technical debt. But honestly, if it's not named, then you can't know what it is, and until you know what it is, you can't fix it.******* My advice is this: when you're doing a release close-down (or in your weekly standup--EVERY weekly standup), have an agenda item to record technical debt. Name it, document it, be proud, sleep at night. - -* Well, apart from the obvious clickbait reason--for which I'm (a little) sorry. - -** I nearly wrote "poke my nose into." - -*** Work with me here. - -**** If you're software engineer/coder/hacker, here's a piece of advice: Learn to talk to product managers like real people, and treat them nicely. They (the better ones, at least) are invaluable allies when you need to prioritize features or have tricky trade-offs to make. - -***** Do this. Just do it. Documentation that isn't at least mirrored in code isn't real documentation.****** - -****** Don't believe me? Talk to developers. "Who reads product documentation?" "Oh, the spec? I skimmed it. A few releases back. I think." "I looked in the header file; couldn't see it there." - -******* Or decide not to fix it, which may also be an entirely appropriate decision. - -This article originally appeared on [Alice, Eve, and Bob - a security blog][2] and is republished with permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/10/why-i-love-technical-debt - -作者:[Mike Bursell][a] -译者:[译者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 -[1]:https://en.wikipedia.org/wiki/Technical_debt -[2]:https://aliceevebob.wordpress.com/2017/08/29/why-i-love-technical-debt/ diff --git a/sources/talk/20171107 How to Monetize an Open Source Project.md b/sources/talk/20171107 How to Monetize an Open Source Project.md deleted file mode 100644 index ab51006101..0000000000 --- a/sources/talk/20171107 How to Monetize an Open Source Project.md +++ /dev/null @@ -1,86 +0,0 @@ -How to Monetize an Open Source Project -====== - -![](http://www.itprotoday.com/sites/itprotoday.com/files/styles/article_featured_standard/public/ThinkstockPhotos-629994230_0.jpg?itok=5dZ68OTn) -The problem for any small group of developers putting the finishing touches on a commercial open source application is figuring out how to monetize the software in order to keep the bills paid and food on the table. Often these small pre-startups will start by deciding which of the recognized open source business models they're going to adapt, whether that be following Red Hat's lead and offering professional services, going the SaaS route, releasing as open core or something else. - -Steven Grandchamp, general manager for MariaDB's North America operations and CEO for Denver-based startup [Drud Tech][1], thinks that might be putting the cart before the horse. With an open source project, the best first move is to get people downloading and using your product for free. - -**Related:** [Demand for Open Source Skills Continues to Grow][2] - -"The number one tangent to monetization in any open source product is adoption, because the key to monetizing an open source product is you flip what I would call the sales funnel upside down," he told ITPro at the recent All Things Open conference in Raleigh, North Carolina. - -In many ways, he said, selling open source solutions is the opposite of marketing traditional proprietary products, where adoption doesn't happen until after a contract is signed. - -**Related:** [Is Raleigh the East Coast's Silicon Valley?][3] - -"In a proprietary software company, you advertise, you market, you make claims about what the product can do, and then you have sales people talk to customers. Maybe you have a free trial or whatever. Maybe you have a small version. Maybe it's time bombed or something like that, but you don't really get to realize the benefit of the product until there's a contract and money changes hands." - -Selling open source solutions is different because of the challenge of selling software that's freely available as a GitHub download. - -"The whole idea is to put the product out there, let people use it, experiment with it, and jump on the chat channels," he said, pointing out that his company Drud has a public chat channel that's open to anybody using their product. "A subset of that group is going to raise their hand and go, 'Hey, we need more help. We'd like a tighter relationship with the company. We'd like to know where your road map's going. We'd like to know about customization. We'd like to know if maybe this thing might be on your road map.'" - -Grandchamp knows more than a little about making software pay, from both the proprietary and open source sides of the fence. In the 1980s he served as VP of research and development at Formation Technologies, and became SVP of R&D at John H. Harland after it acquired Formation in the mid-90s. He joined MariaDB in 2016, after serving eight years as CEO at OpenLogic, which was providing commercial support for more than 600 open-source projects at the time it was acquired by Rogue Wave Software. Along the way, there was a two year stint at Microsoft's Redmond campus. - -OpenLogic was where he discovered open source, and his experiences there are key to his approach for monetizing open source projects. - -"When I got to OpenLogic, I was told that we had 300 customers that were each paying $99 a year for access to our tool," he explained. "But the problem was that nobody was renewing the tool. So I called every single customer that I could find and said 'did you like the tool?'" - -It turned out that nearly everyone he talked to was extremely happy with the company's software, which ironically was the reason they weren't renewing. The company's tool solved their problem so well there was no need to renew. - -"What could we have offered that would have made you renew the tool?" he asked. "They said, 'If you had supported all of the open source products that your tool assembled for me, then I would have that ongoing relationship with you.'" - -Grandchamp immediately grasped the situation, and when the CTO said such support would be impossible, Grandchamp didn't mince words: "Then we don't have a company." - -"We figured out a way to support it," he said. "We created something called the Open Logic Expert Community. We developed relationships with committers and contributors to a couple of hundred open source packages, and we acted as sort of the hub of the SLA for our customers. We had some people on staff, too, who knew the big projects." - -After that successful launch, Grandchamp and his team began hearing from customers that they were confused over exactly what open source code they were using in their projects. That lead to the development of what he says was the first software-as-a-service compliance portal of open source, which could scan an application's code and produce a list of all of the open source code included in the project. When customers then expressed confusion over compliance issues, the SaaS service was expanded to flag potential licensing conflicts. - -Although the product lines were completely different, the same approach was used to monetize MariaDB, then called SkySQL, after MySQL co-founders Michael "Monty" Widenius, David Axmark, and Allan Larsson created the project by forking MySQL, which Oracle had acquired from Sun Microsystems in 2010. - -Again, users were approached and asked what things they would be willing to purchase. - -"They wanted different functionality in the database, and you didn't really understand this if you didn't talk to your customers," Grandchamp explained. "Monty and his team, while they were being acquired at Sun and Oracle, were working on all kinds of new functionality, around cloud deployments, around different ways to do clustering, they were working on lots of different things. That work, Oracle and MySQL didn't really pick up." - -Rolling in the new features customers wanted needed to be handled gingerly, because it was important to the folks at MariaDB to not break compatibility with MySQL. This necessitated a strategy around when the code bases would come together and when they would separate. "That road map, knowledge, influence and technical information was worth paying for." - -As with OpenLogic, MariaDB customers expressed a willingness to spend money on a variety of fronts. For example, a big driver in the early days was a project called Remote DBA, which helped customers make up for a shortage of qualified database administrators. The project could help with design issues, as well as monitor existing systems to take the workload off of a customer's DBA team. The service also offered access to MariaDB's own DBAs, many of whom had a history with the database going back to the early days of MySQL. - -"That was a subscription offering that people were definitely willing to pay for," he said. - -The company also learned, again by asking and listening to customers, that there were various types of support subscriptions that customers were willing to purchase, including subscriptions around capability and functionality, and a managed service component of Remote DBA. - -These days Grandchamp is putting much of his focus on his latest project, Drud, a startup that offers a suite of integrated, automated, open source development tools for developing and managing multiple websites, which can be running on any combination of content management systems and deployment platforms. It is monetized partially through modules that add features like a centralized dashboard and an "intelligence engine." - -As you might imagine, he got it off the ground by talking to customers and giving them what they indicated they'd be willing to purchase. - -"Our number one customer target is the agency market," he said. "The enterprise market is a big target, but I believe it's our second target, not our first. And the reason it's number two is they don't make decisions very fast. There are technology refresh cycles that have to come up, there are lots of politics involved and lots of different vendors. It's lucrative once you're in, but in a startup you've got to figure out how to pay your bills. I want to pay my bills today. I don't want to pay them in three years." - -Drud's focus on the agency market illustrates another consideration: the importance of understanding something about your customers' business. When talking with agencies, many said they were tired of being offered generic software that really didn't match their needs from proprietary vendors that didn't understand their business. In Drud's case, that understanding is built into the company DNA. The software was developed by an agency to fill its own needs. - -"We are a platform designed by an agency for an agency," Grandchamp said. "Right there is a relationship that they're willing to pay for. We know their business." - -Grandchamp noted that startups also need to be able to distinguish users from customers. Most of the people downloading and using commercial open source software aren't the people who have authorization to make purchasing decisions. These users, however, can point to the people who control the purse strings. - -"It's our job to build a way to communicate with those users, provide them value so that they'll give us value," he explained. "It has to be an equal exchange. I give you value of a tool that works, some advice, really good documentation, access to experts who can sort of guide you along. Along the way I'm asking you for pieces of information. Who do you work for? How are the technology decisions happening in your company? Are there other people in your company that we should refer the product to? We have to create the dialog." - -In the end, Grandchamp said, in the open source world the people who go out to find business probably shouldn't see themselves as salespeople, but rather, as problem solvers. - -"I believe that you're not really going to need salespeople in this model. I think you're going to need customer success people. I think you're going to need people who can enable your customers to be successful in a business relationship that's more highly transactional." - -"People don't like to be sold," he added, "especially in open source. The last person they want to see is the sales person, but they like to ply and try and consume and give you input and give you feedback. They love that." - --------------------------------------------------------------------------------- - -via: http://www.itprotoday.com/software-development/how-monetize-open-source-project - -作者:[Christine Hall][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.itprotoday.com/author/christine-hall -[1]:https://www.drud.com/ -[2]:http://www.itprotoday.com/open-source/demand-open-source-skills-continues-grow -[3]:http://www.itprotoday.com/software-development/raleigh-east-coasts-silicon-valley diff --git a/sources/talk/20171114 Why pair writing helps improve documentation.md b/sources/talk/20171114 Why pair writing helps improve documentation.md deleted file mode 100644 index ff3bbb5888..0000000000 --- a/sources/talk/20171114 Why pair writing helps improve documentation.md +++ /dev/null @@ -1,87 +0,0 @@ -Why pair writing helps improve documentation -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/doc-dish-lead-2.png?itok=lPO6tqPd) - -Professional writers, at least in the Red Hat documentation team, nearly always work on docs alone. But have you tried writing as part of a pair? In this article, I'll explain a few benefits of pair writing. -### What is pair writing? - -Pair writing is when two writers work in real time, on the same piece of text, in the same room. This approach improves document quality, speeds up writing, and allows writers to learn from each other. The idea of pair writing is borrowed from [pair programming][1]. - -When pair writing, you and your colleague work on the text together, making suggestions and asking questions as needed. Meanwhile, you're observing each other's work. For example, while one is writing, the other writer observes details such as structure or context. Often discussion around the document turns into sharing experiences and opinions, and brainstorming about writing in general. - -At all times, the writing is done by only one person. Thus, you need only one computer, unless you want one writer to do online research while the other person does the writing. The text workflow is the same as if you are working alone: a text editor, the documentation source files, git, and so on. - -### Pair writing in practice - -My colleague Aneta Steflova and I have done more than 50 hours of pair writing working on the Red Hat Enterprise Linux System Administration docs and on the Red Hat Identity Management docs. I've found that, compared to writing alone, pair writing: - - * is as productive or more productive; - * improves document quality; - * helps writers share technical expertise; and - * is more fun. - - - -### Speed - -Two writers writing one text? Sounds half as productive, right? Wrong. (Usually.) - -Pair writing can help you work faster because two people have solutions to a bigger set of problems, which means getting blocked less often during the process. For example, one time we wrote urgent API docs for identity management. I know at least the basics of web APIs, the REST protocol, and so on, which helped us speed through those parts of the documentation. Working alone, Aneta would have needed to interrupt the writing process frequently to study these topics. - -### Quality - -Poor wording or sentence structure, inconsistencies in material, and so on have a harder time surviving under the scrutiny of four eyes. For example, one of our pair writing documents was reviewed by an extremely critical developer, who was known for catching technical inaccuracies and bad structure. After this particular review, he said, "Perfect. Thanks a lot." - -### Sharing expertise - -Each of us lives in our own writing bubble, and we normally don't know how others approach writing. Pair writing can help you improve your own writing process. For example, Aneta showed me how to better handle assignments in which the developer has provided starting text (as opposed to the writer writing from scratch using their own knowledge of the subject), which I didn't have experience with. Also, she structures the docs thoroughly, which I began doing as well. - -As another example, I'm good enough at Vim that XML editing (e.g., tags manipulation) is enjoyable instead of torturous. Aneta saw how I was using Vim, asked about it, suffered through the learning curve, and now takes advantage of the Vim features that help me. - -Pair writing is especially good for helping and mentoring new writers, and it's a great way to get to know professionally (and have fun with) colleagues. - -### When pair writing shines - -In addition to benefits I've already listed, pair writing is especially good for: - - * **Working with[Bugzilla][2]** : Bugzillas can be cumbersome and cause problems, especially for administration-clumsy people (like me). - * **Reviewing existing documents** : When documentation needs to be expanded or fixed, it is necessary to first examine the existing document. - * **Learning new technology** : A fellow writer can be a better teacher than an engineer. - * **Writing emails/requests for information to developers with well-chosen questions** : The difficulty of this task rises in proportion to the difficulty of technology you are documenting. - - - -Also, with pair writing, feedback is in real time, as-needed, and two-way. - -On the downside, pair writing can be a faster pace, giving a writer less time to mull over a topic or wording. On the other hand, generally peer review is not necessary after pair writing. - -### Words of caution - -To get the most out of pair writing: - - * Go into the project well prepared, otherwise you can waste your colleague's time. - * Talkative types need to stay focused on the task, otherwise they end up talking rather than writing. - * Be prepared for direct feedback. Pair writing is not for feedback-allergic writers. - * Beware of session hijackers. Dominant personalities can turn pair writing into writing solo with a spectator. (However, it _can _ be good if one person takes over at times, as long as the less-experienced partner learns from the hijacker, or the more-experienced writer is providing feedback to the hijacker.) - - - -### Conclusion - -Pair writing is a meeting, but one in which you actually get work done. It's an activity that lets writers focus on the one indispensable thing in our vocation--writing. - -_This post was written with the help of pair writing with Aneta Steflova._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/17/11/try-pair-writing - -作者:[Maxim Svistunov][a] -译者:[译者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/maxim-svistunov -[1]:https://developer.atlassian.com/blog/2015/05/try-pair-programming/ -[2]:https://www.bugzilla.org/ diff --git a/sources/talk/20171115 Why and How to Set an Open Source Strategy.md b/sources/talk/20171115 Why and How to Set an Open Source Strategy.md deleted file mode 100644 index 79ec071b4d..0000000000 --- a/sources/talk/20171115 Why and How to Set an Open Source Strategy.md +++ /dev/null @@ -1,120 +0,0 @@ -Why and How to Set an Open Source Strategy -============================================================ - -![](https://www.linuxfoundation.org/wp-content/uploads/2017/11/open-source-strategy-1024x576.jpg) - -This article explains how to walk through, measure, and define strategies collaboratively in an open source community. - - _“If you don’t know where you are going, you’ll end up someplace else.” _ _—_  Yogi Berra - -Open source projects are generally started as a way to scratch one’s itch — and frankly that’s one of its greatest attributes. Getting code down provides a tangible method to express an idea, showcase a need, and solve a problem. It avoids over thinking and getting a project stuck in analysis-paralysis, letting the project pragmatically solve the problem at hand. - -Next, a project starts to scale up and gets many varied users and contributions, with plenty of opinions along the way. That leads to the next big challenge — how does a project start to build a strategic vision? In this article, I’ll describe how to walk through, measure, and define strategies collaboratively, in a community. - -Strategy may seem like a buzzword of the corporate world rather something that an open source community would embrace, so I suggest stripping away the negative actions that are sometimes associated with this word (e.g., staff reductions, discontinuations, office closures). Strategy done right isn’t a tool to justify unfortunate actions but to help show focus and where each community member can contribute. - -A good application of strategy achieves the following: - -* Why the project exists? - -* What the project looks to achieve? - -* What is the ideal end state for a project is. - -The key to success is answering these questions as simply as possible, with consensus from your community. Let’s look at some ways to do this. - -### Setting a mission and vision - - _“_ _Efforts and courage are not enough without purpose and direction.”_  — John F. Kennedy - -All strategic planning starts off with setting a course for where the project wants to go. The two tools used here are  _Mission_  and  _Vision_ . They are complementary terms, describing both the reason a project exists (mission) and the ideal end state for a project (vision). - -A great way to start this exercise with the intent of driving consensus is by asking each key community member the following questions: - -* What drove you to join and/or contribute the project? - -* How do you define success for your participation? - -In a company, you’d ask your customers these questions usually. But in open source projects, the customers are the project participants — and their time investment is what makes the project a success. - -Driving consensus means capturing the answers to these questions and looking for themes across them. At R Consortium, for example, I created a shared doc for the board to review each member’s answers to the above questions, and followed up with a meeting to review for specific themes that came from those insights. - -Building a mission flows really well from this exercise. The key thing is to keep the wording of your mission short and concise. Open Mainframe Project has done this really well. Here’s their mission: - - _Build community and adoption of Open Source on the mainframe by:_ - -* _Eliminating barriers to Open Source adoption on the mainframe_ - -* _Demonstrating value of the mainframe on technical and business levels_ - -* _Strengthening collaboration points and resources for the community to thrive_ - -At 40 words, it passes the key eye tests of a good mission statement; it’s clear, concise, and demonstrates the useful value the project aims for. - -The next stage is to reflect on the mission statement and ask yourself this question: What is the ideal outcome if the project accomplishes its mission? That can be a tough one to tackle. Open Mainframe Project put together its vision really well: - - _Linux on the Mainframe as the standard for enterprise class systems and applications._ - -You could read that as a [BHAG][1], but it’s really more of a vision, because it describes a future state that is what would be created by the mission being fully accomplished. It also hits the key pieces to an effective vision — it’s only 13 words, inspirational, clear, memorable, and concise. - -Mission and vision add clarity on the who, what, why, and how for your project. But, how do you set a course for getting there? - -### Goals, Objectives, Actions, and Results - - _“I don’t focus on what I’m up against. I focus on my goals and I try to ignore the rest.”_  — Venus Williams - -Looking at a mission and vision can get overwhelming, so breaking them down into smaller chunks can help the project determine how to get started. This also helps prioritize actions, either by importance or by opportunity. Most importantly, this step gives you guidance on what things to focus on for a period of time, and which to put off. - -There are lots of methods of time bound planning, but the method I think works the best for projects is what I’ve dubbed the GOAR method. It’s an acronym that stands for: - -* Goals define what the project is striving for and likely would align and support the mission. Examples might be “Grow a diverse contributor base” or “Become the leading project for X.” Goals are aspirational and set direction. - -* Objectives show how you measure a goal’s completion, and should be clear and measurable. You might also have multiple objectives to measure the completion of a goal. For example, the goal “Grow a diverse contributor base” might have objectives such as “Have X total contributors monthly” and “Have contributors representing Y different organizations.” - -* Actions are what the project plans to do to complete an objective. This is where you get tactical on exactly what needs done. For example, the objective “Have contributors representing Y different organizations” would like have actions of reaching out to interested organizations using the project, having existing contributors mentor new mentors, and providing incentives for first time contributors. - -* Results come along the way, showing progress both positive and negative from the actions. - -You can put these into a table like this: - -| Goals | Objectives | Actions | Results | -|:--|:--|:--|:--| -| Grow a diverse contributor base     | Have X total contributors monthly | Existing contributors mentor new mentors Providing incentives for first time contributors | | -| | Have contributors representing Y different organizations | Reach out to interested organizations using the project | | - - -In large organizations, monthly or quarterly goals and objectives often make sense; however, on open source projects, these time frames are unrealistic. Six- even 12-month tracking allows the project leadership to focus on driving efforts at a high level by nurturing the community along. - -The end result is a rubric that provides clear vision on where the project is going. It also lets community members more easily find ways to contribute. For example, your project may include someone who knows a few organizations using the project — this person could help introduce those developers to the codebase and guide them through their first commit. - -### What happens if the project doesn’t hit the goals? - - _“I have not failed. I’ve just found 10,000 ways that won’t work.”_  — Thomas A. Edison - -Figuring out what is within the capability of an organization — whether Fortune 500 or a small open source project — is hard. And, sometimes the expectations or market conditions change along the way. Does that make the strategy planning process a failure? Absolutely not! - -Instead, you can use this experience as a way to better understand your project’s velocity, its impact, and its community, and perhaps as a way to prioritize what is important and what’s not. - --------------------------------------------------------------------------------- - -via: https://www.linuxfoundation.org/blog/set-open-source-strategy/ - -作者:[ John Mertic][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxfoundation.org/author/jmertic/ -[1]:https://en.wikipedia.org/wiki/Big_Hairy_Audacious_Goal -[2]:https://www.linuxfoundation.org/author/jmertic/ -[3]:https://www.linuxfoundation.org/category/blog/ -[4]:https://www.linuxfoundation.org/category/audience/c-level/ -[5]:https://www.linuxfoundation.org/category/audience/developer-influencers/ -[6]:https://www.linuxfoundation.org/category/audience/entrepreneurs/ -[7]:https://www.linuxfoundation.org/category/campaigns/membership/how-to/ -[8]:https://www.linuxfoundation.org/category/campaigns/events-campaigns/linux-foundation/ -[9]:https://www.linuxfoundation.org/category/audience/open-source-developers/ -[10]:https://www.linuxfoundation.org/category/audience/open-source-professionals/ -[11]:https://www.linuxfoundation.org/category/audience/open-source-users/ -[12]:https://www.linuxfoundation.org/category/blog/thought-leadership/ diff --git a/sources/talk/20171116 Why is collaboration so difficult.md b/sources/talk/20171116 Why is collaboration so difficult.md deleted file mode 100644 index 6567b75dca..0000000000 --- a/sources/talk/20171116 Why is collaboration so difficult.md +++ /dev/null @@ -1,94 +0,0 @@ -Why is collaboration so difficult? -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_block_collaboration.png?itok=pKbXpr1e) - -Many contemporary definitions of "collaboration" define it simply as "working together"--and, in part, it is working together. But too often, we tend to use the term "collaboration" interchangeably with cognate terms like "cooperation" and "coordination." These terms also refer to some manner of "working together," yet there are subtle but important differences between them all. - -How does collaboration differ from coordination or cooperation? What is so important about collaboration specifically? Does it have or do something that coordination and cooperation don't? The short answer is a resounding "yes!" - -[This unit explores collaboration][1], a problematic term because it has become a simple buzzword for "working together." By the time you've studied the cases and practiced the exercises contained in this section, you will understand that it's so much more than that. - -### Not like the others - -"Coordination" can be defined as the ordering of a variety of people acting in an effective, unified manner toward an end goal or state - -In traditional organizations and businesses, people contributed according to their role definitions, such as in manufacturing, where each employee was responsible for adding specific components to the widget on an assembly line until the widget was complete. In contexts like these, employees weren't expected to contribute beyond their pre-defined roles (they were probably discouraged from doing so), and they didn't necessarily have a voice in the work or in what was being created. Often, a manager oversaw the unification of effort (hence the role "project coordinator"). Coordination is meant to connote a sense of harmony and unity, as if elements are meant to go together, resulting in efficiency among the ordering of the elements. - -One common assumption is that coordinated efforts are aimed at the same, single goal. So some end result is "successful" when people and parts work together seamlessly; when one of the parts breaks down and fails, then the whole goal fails. Many traditional businesses (for instance, those with command-and-control hierarchies) manage work through coordination. - -Cooperation is another term whose surface meaning is "working together." Rather than the sense of compliance that is part of "coordination," it carries a sense of agreement and helpfulness on the path toward completing a shared activity or goal. - -"Collaboration" also means "working together"--but that simple definition obscures the complex and often difficult process of collaborating. - -People tend to use the term "cooperation" when joining two semi-related entities where one or more entity could decide not to cooperate. The people and pieces that are part of a cooperative effort make the shared activity easier to perform or the shared goal easier to reach. "Cooperation" implies a shared goal or activity we agree to pursue jointly. One example is how police and witnesses cooperate to solve crimes. - -"Collaboration" also means "working together"--but that simple definition obscures the complex and often difficult process of collaborating. - -Sometimes collaboration involves two or more groups that do not normally work together; they are disparate groups or not usually connected. For instance, a traitor collaborates with the enemy, or rival businesses collaborate with each other. The subtlety of collaboration is that the two groups may have oppositional initial goals but work together to create a shared goal. Collaboration can be more contentious than coordination or cooperation, but like cooperation, any one of the entities could choose not to collaborate. Despite the contention and conflict, however, there is discourse--whether in the form of multi-way discussion or one-way feedback--because without discourse, there is no way for people to express a point of dissent that is ripe for negotiation. - -The success of any collaboration rests on how well the collaborators negotiate their needs to create the shared objective, and then how well they cooperate and coordinate their resources to execute a plan to reach their goals. - -### For example - -One way to think about these things is through a real-life example--like the writing of [this book][1]. - -The editor, [Bryan][2], coordinates the authors' work through the call for proposals, setting dates and deadlines, collecting the writing, and meeting editing dates and deadlines for feedback about our work. He coordinates the authors, the writing, the communications. In this example, I'm not coordinating anything except myself (still a challenge most days!). - -The success of any collaboration rests on how well the collaborators negotiate their needs to create the shared objective, and then how well they cooperate and coordinate their resources to execute a plan to reach their goals. - -I cooperate with Bryan's dates and deadlines, and with the ways he has decided to coordinate the work. I propose the introduction on GitHub; I wait for approval. I comply with instructions, write some stuff, and send it to him by the deadlines. He cooperates by accepting a variety of document formats. I get his edits,incorporate them, send it back him, and so forth. If I don't cooperate (or something comes up and I can't cooperate), then maybe someone else writes this introduction instead. - -Bryan and I collaborate when either one of us challenges something, including pieces of the work or process that aren't clear, things that we thought we agreed to, or things on which we have differing opinions. These intersections are ripe for negotiation and therefore indicative of collaboration. They are the opening for us to negotiate some creative work. - -Once the collaboration is negotiated and settled, writing and editing the book returns to cooperation/coordination; that is why collaboration relies on the other two terms of joint work. - -One of the most interesting parts of this example (and of work and shared activity in general) is the moment-by-moment pivot from any of these terms to the other. The writing of this book is not completely collaborative, coordinated, or cooperative. It's a messy mix of all three. - -### Why is collaboration important? - -Collaboration is an important facet of contemporary organizations--specifically those oriented toward knowledge work--because it allows for productive disagreement between actors. That kind of disagreement then helps increase the level of engagement and provide meaning to the group's work. - -In his book, The Age of Discontinuity: Guidelines to our Changing Society, [Peter Drucker discusses][3] the "knowledge worker" and the pivot from work based on experience (e.g. apprenticeships) to work based on knowledge and the application of knowledge. This change in work and workers, he writes: - -> ...will make the management of knowledge workers increasingly crucial to the performance and achievement of the knowledge society. We will have to learn to manage the knowledge worker both for productivity and for satisfaction, both for achievement and for status. We will have to learn to give the knowledge worker a job big enough to challenge him, and to permit performance as a "professional." - -In other words, knowledge workers aren't satisfied with being subordinate--told what to do by managers as, if there is one right way to do a task. And, unlike past workers, they expect more from their work lives, including some level of emotional fulfillment or meaning-making from their work. The knowledge worker, according to Drucker, is educated toward continual learning, "paid for applying his knowledge, exercising his judgment, and taking responsible leadership." So it then follows that knowledge workers expect from work the chance to apply and share their knowledge, develop themselves professionally, and continuously augment their knowledge. - -Interesting to note is the fact that Peter Drucker wrote about those concepts in 1969, nearly 50 years ago--virtually predicting the societal and organizational changes that would reveal themselves, in part, through the development of knowledge sharing tools such as forums, bulletin boards, online communities, and cloud knowledge sharing like DropBox and GoogleDrive as well as the creation of social media tools such as MySpace, Facebook, Twitter, YouTube and countless others. All of these have some basis in the idea that knowledge is something to liberate and share. - -In this light, one might view the open organization as one successful manifestation of a system of management for knowledge workers. In other words, open organizations are a way to manage knowledge workers by meeting the needs of the organization and knowledge workers (whether employees, customers, or the public) simultaneously. The foundational values this book explores are the scaffolding for the management of knowledge, and they apply to ways we can: - - * make sure there's a lot of varied knowledge around (inclusivity) - * help people come together and participate (community) - * circulate information, knowledge, and decision making (transparency) - * innovate and not become entrenched in old ways of thinking and being (adaptability) - * develop a shared goal and work together to use knowledge (collaboration) - - - -Collaboration is an important process because of the participatory effect it has on knowledge work and how it aids negotiations between people and groups. As we've discovered, collaboration is more than working together with some degree of compliance; in fact, it describes a type of working together that overcomes compliance because people can disagree, question, and express their needs in a negotiation and in collaboration. And, collaboration is more than "working toward a shared goal"; collaboration is a process which defines the shared goals via negotiation and, when successful, leads to cooperation and coordination to focus activity on the negotiated outcome. - -Collaboration is an important process because of the participatory effect it has on knowledge work and how it aids negotiations between people and groups. - -Collaboration works best when the other four open organization values are present. For instance, when people are transparent, there is no guessing about what is needed, why, by whom, or when. Also, because collaboration involves negotiation, it also needs diversity (a product of inclusivity); after all, if we aren't negotiating among differing views, needs, or goals, then what are we negotiating? During a negotiation, the parties are often asked to give something up so that all may gain, so we have to be adaptable and flexible to the different outcomes that negotiation can provide. Lastly, collaboration is often an ongoing process rather than one which is quickly done and over, so it's best to enter collaboration as if you are part of the same community, desiring everyone to benefit from the negotiation. In this way, acts of authentic and purposeful collaboration directly necessitate the emergence of the other four values--transparency, inclusivity, adaptability, and community--as they assemble part of the organization's collective purpose spontaneously. - -### Collaboration in open organizations - -Traditional organizations advance an agreed-upon set of goals that people are welcome to support or not. In these organizations, there is some amount of discourse and negotiation, but often a higher-ranking or more powerful member of the organization intervenes to make a decision, which the membership must accept (and sometimes ignores). In open organizations, however, the focus is for members to perform their activity and to work out their differences; only if necessary would someone get involved (and even then would try to do it in the most minimal way that support the shared values of community, transparency, adaptability, collaboration and inclusivity.) This make the collaborative processes in open organizations "messier" (or "chaotic" to use Jim Whitehurst's term) but more participatory and, hopefully, innovative. - -This article is part of the [Open Organization Workbook project][1]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/17/11/what-is-collaboration - -作者:[Heidi Hess Von Ludewig][a] -译者:[译者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/heidi-hess-von-ludewig -[1]:https://opensource.com/open-organization/17/8/workbook-project-announcement -[2]:http://opensource.com/users/bbehrens -[3]:https://www.elsevier.com/books/the-age-of-discontinuity/drucker/978-0-434-90395-5 diff --git a/sources/talk/20171221 Changing how we use Slack solved our transparency and silo problems.md b/sources/talk/20171221 Changing how we use Slack solved our transparency and silo problems.md deleted file mode 100644 index d68bab55bf..0000000000 --- a/sources/talk/20171221 Changing how we use Slack solved our transparency and silo problems.md +++ /dev/null @@ -1,95 +0,0 @@ -Changing how we use Slack solved our transparency and silo problems -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_abstract_pieces.jpg?itok=tGR1d2MU) - -Collaboration and information silos are a reality in most organizations today. People tend to regard them as huge barriers to innovation and organizational efficiency. They're also a favorite target for solutions from software tool vendors of all types. - -Tools by themselves, however, are seldom (if ever), the answer to a problem like organizational silos. The reason for this is simple: Silos are made of people, and human dynamics are key drivers for the existence of silos in the first place. - -So what is the answer? - -Successful communities are the key to breaking down silos. Tools play an important role in the process, but if you don't build successful communities around those tools, then you'll face an uphill battle with limited chances for success. Tools enable communities; they do not build them. This takes a thoughtful approach--one that looks at culture first, process second, and tools last. - -Successful communities are the key to breaking down silos. - -However, this is a challenge because, in most cases, this is not the way the process works in most businesses. Too many companies begin their journey to fix silos by thinking about tools first and considering metrics that don't evaluate the right factors for success. Too often, people choose tools for purely cost-based, compliance-based, or effort-based reasons--instead of factoring in the needs and desires of the user base. But subjective measures like "customer/user delight" are a real factor for these internal tools, and can make or break the success of both the tool adoption and the goal of increased collaboration. - -It's critical to understand the best technical tool (or what the business may consider the most cost-effective) is not always the solution that drives community, transparency, and collaboration forward. There is a reason that "Shadow IT"--users choosing their own tool solution, building community and critical mass around them--exists and is so effective: People who choose their own tools are more likely to stay engaged and bring others with them, breaking down silos organically. - -This is a story of how Autodesk ended up adopting Slack at enterprise scale to help solve our transparency and silo problems. Interestingly, Slack wasn't (and isn't) an IT-supported application at Autodesk. It's an enterprise solution that was adopted, built, and is still run by a group of passionate volunteers who are committed to a "default to open" paradigm. - -Utilizing Slack makes transparency happen for us. - -### Chat-tastrophe - -First, some perspective: My job at Autodesk is running our [Open@ADSK][1] initiative. I was originally hired to drive our open source strategy, but we quickly expanded my role to include driving open source best practices for internal development (inner source), and transforming how we collaborate internally as an organization. This last piece is where we pick up our story of Slack adoption in the company. - -But before we even begin to talk about our journey with Slack, let's address why lack of transparency and openness was a challenge for us. What is it that makes transparency such a desirable quality in organizations, and what was I facing when I started at Autodesk? - -Every company says they want "better collaboration." In our case, we are a 35-year-old software company that has been immensely successful at selling desktop "shrink-wrapped" software to several industries, including architecture, engineering, construction, manufacturing, and entertainment. But no successful company rests on its laurels, and Autodesk leadership recognized that a move to Cloud-based solutions for our products was key to the future growth of the company, including opening up new markets through product combinations that required Cloud computing and deep product integrations. - -The challenge in making this move was far more than just technical or architectural--it was rooted in the DNA of the company, in everything from how we were organized to how we integrated our products. The basic format of integration in our desktop products was file import/export. While this is undoubtedly important, it led to a culture of highly-specialized teams working in an environment that's more siloed than we'd like and not sharing information (or code). Prior to the move to a cloud-based approach, this wasn't as a much of a problem--but, in an environment that requires organizations to behave more like open source projects do, transparency, openness, and collaboration go from "nice-to-have" to "business critical." - -Like many companies our size, Autodesk has had many different collaboration solutions through the years, some of them commercial, and many of them home-grown. However, none of them effectively solved the many-to-many real-time collaboration challenge. Some reasons for this were technical, but many of them were cultural. - -I relied on a philosophy I'd formed through challenging experiences in my career: "Culture first, tools last." - -When someone first tasked me with trying to find a solution for this, I relied on a philosophy I'd formed through challenging experiences in my career: "Culture first, tools last." This is still a challenge for engineering folks like myself. We want to jump immediately to tools as the solution to any problem. However, it's critical to evaluate a company's ethos (culture), as well as existing processes to determine what kinds of tools might be a good fit. Unfortunately, I've seen too many cases where leaders have dictated a tool choice from above, based on the factors discussed earlier. I needed a different approach that relied more on fitting a tool into the culture we wanted to become, not the other way around. - -What I found at Autodesk were several small camps of people using tools like HipChat, IRC, Microsoft Lync, and others, to try to meet their needs. However, the most interesting thing I found was 85 separate instances of Slack in the company! - -Eureka! I'd stumbled onto a viral success (one enabled by Slack's ability to easily spin up "free" instances). I'd also landed squarely in what I like to call "silo-land." - -All of those instances were not talking to each other--so, effectively, we'd created isolated islands of information that, while useful to those in them, couldn't transform the way we operated as an enterprise. Essentially, our existing organizational culture was recreated in digital format in these separate Slack systems. Our organization housed a mix of these small, free instances, as well as multiple paid instances, which also meant we were not taking advantage of a common billing arrangement. - -My first (open source) thought was: "Hey, why aren't we using IRC, or some other open source tool, for this?" I quickly realized that didn't matter, as our open source engineers weren't the only people using Slack. People from all areas of the company--even senior leadership--were adopting Slack in droves, and, in some cases, convincing their management to pay for it! - -My second (engineering) thought was: "Oh, this is simple. We just collapse all 85 of those instances into a single cohesive Slack instance." What soon became obvious was that was the easy part of the solution. Much harder was the work of cajoling, convincing, and moving people to a single, transparent instance. Building in the "guard rails" to enable a closed source tool to provide this transparency was key. These guard rails came in the form of processes, guidelines, and community norms that were the hardest part of this transformation. - -### The real work begins - -As I began to slowly help users migrate to the common instance (paying for it was also a challenge, but a topic for another day), I discovered a dedicated group of power users who were helping each other in the #adsk-slack-help channel on our new common instance of Slack. These power users were, in effect, building the roots of our transparency and community through their efforts. - -The open source community manager in me quickly realized these users were the path to successfully scaling Slack at Autodesk. I enlisted five of them to help me, and, together we set about fabricating the community structure for the tool's rollout. - -We did, however, learn an important lesson about transparency and company culture along the way. - -Here I should note the distinction between a community structure/governance model and traditional IT policies: With the exception of security and data privacy/legal policies, volunteer admins and user community members completely define and govern our Slack instance. One of the keys to our success with Slack (currently approximately 9,100 users and roughly 4,300 public channels) was how we engaged and involved our users in building these governance structures. Things like channel naming conventions and our growing list of frequently asked questions were organic and have continued in that same vein. Our community members feel like their voices are heard (even if some disagree), and that they have been a part of the success of our deployment of Slack. - -We did, however, learn an important lesson about transparency and company culture along the way. - -### It's not the tool - -When we first launched our main Slack instance, we left the ability for anyone to make a channel private turned on. After about three months of usage, we saw a clear trend: More people were creating private channels (and messages) than they were public channels (the ratio was about two to one, private versus public). Since our effort to merge 85 Slack instances was intended to increase participation and transparency, we quickly adjusted our policy and turned off this feature for regular users. We instead implemented a policy of review by the admin team, with clear criteria (finance, legal, personnel discussions among the reasons) defined for private channels. - -This was probably the only time in this entire process that I regretted something. - -We took an amazing amount of flak for this decision because we were dealing with a corporate culture that was used to working in independent units that had minimal interaction with each other. Our defining moment of clarity (and the tipping point where things started to get better) occurred in an all-hands meeting when one of our senior executives asked me to address a question about Slack. I stood up to answer the question, and said (paraphrased from memory): "It's not about the tool. I could give you all the best, gold-plated collaboration platform in existence, but we aren't going to be successful if we don't change our approach to collaboration and learn to default to open." - -I didn't think anything more about that statement--until that senior executive starting using the phrase "default to open" in his slide decks, in his staff meetings, and with everyone he met. That one moment has defined what we have been trying to do with Slack: The tool isn't the sole reason we've been successful; it's the approach that we've taken around building a self-sustaining community that not only wants to use this tool, but craves the ability it gives them to work easily across the enterprise. - -### What we learned - -The tool isn't the sole reason we've been successful; it's the approach that we've taken around building a self-sustaining community that not only wants to use this tool, but craves the ability it gives them to work easily across the enterprise. - -I say all the time that this could have happened with other, similar tools (Hipchat, IRC, etc), but it works in this case specifically because we chose an approach of supporting a solution that the user community adopted for their needs, not strictly what the company may have chosen if the decision was coming from the top of the organizational chart. We put a lot of work into making it an acceptable solution (from the perspectives of security, legal, finance, etc.) for the company, but, ultimately, our success has come from the fact that we built this rollout (and continue to run the tool) as a community, not as a traditional corporate IT system. - -The most important lesson I learned through all of this is that transparency and community are evolutionary, not revolutionary. You have to understand where your culture is, where you want it to go, and utilize the lever points that the community is adopting itself to make sustained and significant progress. There is a fine balance point between an anarchy, and a thriving community, and we've tried to model our approach on the successful practices of today's thriving open source communities. - -Communities are personal. Tools come and go, but keeping your community at the forefront of your push to transparency is the key to success. - -This article is part of the [Open Organization Workbook project][2]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/17/12/chat-platform-default-to-open - -作者:[Guy Martin][a] -译者:[译者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/guyma -[1]:mailto:Open@ADSK -[2]:https://opensource.com/open-organization/17/8/workbook-project-announcement diff --git a/sources/talk/20180109 How Mycroft used WordPress and GitHub to improve its documentation.md b/sources/talk/20180109 How Mycroft used WordPress and GitHub to improve its documentation.md deleted file mode 100644 index 9e35e0ede7..0000000000 --- a/sources/talk/20180109 How Mycroft used WordPress and GitHub to improve its documentation.md +++ /dev/null @@ -1,116 +0,0 @@ -How Mycroft used WordPress and GitHub to improve its documentation -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/doc-dish-lead-2.png?itok=lPO6tqPd) - -Image credits : Photo by Unsplash; modified by Rikki Endsley. CC BY-SA 4.0 - -Imagine you've just joined a new technology company, and one of the first tasks you're assigned is to improve and centralize the organization's developer-facing documentation. There's just one catch: That documentation exists in many different places, across several platforms, and differs markedly in accuracy, currency, and style. - -So how did we tackle this challenge? - -### Understanding the scope - -As with any project, we first needed to understand the scope and bounds of the problem we were trying to solve. What documentation was good? What was working? What wasn't? How much documentation was there? What format was it in? We needed to do a **documentation audit**. Luckily, [Aneta Šteflova][1] had recently [published an article on OpenSource.com][2] about this, and it provided excellent guidance. - -![mycroft doc audit][4] - -Mycroft documentation audit, showing source, topic, medium, currency, quality and audience - -Next, every piece of publicly facing documentation was assessed for the topic it covered, the medium it used, currency, and quality. A pattern quickly emerged that different platforms had major deficiencies, allowing us to make a data-driven approach to decommission our existing Jekyll-based sites. The audit also highlighted just how fragmented our documentation sources were--we had developer-facing documentation across no fewer than seven sites. Although search engines were finding this content just fine, the fragmentation made it difficult for developers and users of Mycroft--our primary audiences--to navigate the information they needed. Again, this data helped us make the decision to centralize our documentation on to one platform. - -### Choosing a central platform - -As an organization, we wanted to constrain the number of standalone platforms in use. Over time, maintenance and upkeep of multiple platforms and integration touchpoints becomes cumbersome for any organization, but this is exacerbated for a small startup. - -One of the other business drivers in platform choice was that we had two primary but very different audiences. On one hand, we had highly technical developers who we were expecting would push documentation to its limits--and who would want to contribute to technical documentation using their tools of choice--[Git][5], [GitHub][6], and [Markdown][7]. Our second audience--end users--would primarily consume technical documentation and would want to do so in an inviting, welcoming platform that was visually appealing and provided additional features such as the ability to identify reading time and to provide feedback. The ability to capture feedback was also a key requirement from our side as without feedback on the quality of the documentation, we would not have a solid basis to undertake continuous quality improvement. - -Would we be able to identify one platform that met all of these competing needs? - -We realised that two platforms covered all of our needs: - - * [WordPress][8]: Our existing website is built on WordPress, and we have some reasonably robust WordPress skills in-house. The flexibility of WordPress also fulfilled our requirements for functionality like reading time and the ability to capture user feedback. - * [GitHub][9]: Almost [all of Mycroft.AI's source code is available on GitHub][10], and our development team uses this platform daily. - - - -But how could we marry the two? - - -![](https://opensource.com/sites/default/files/images/life-uploads/wordpress-github-sync.png) - -### Integrating WordPress and GitHub with WordPress GitHub Sync - -Luckily, our COO, [Nate Tomasi][11], spotted a WordPress plugin that promised to integrate the two. - -This was put through its paces on our test website, and it passed with flying colors. It was easy to install, had a straightforward configuration, which just required an OAuth token and webhook with GitHub, and provided two-way integration between WordPress and GitHub. - -It did, however, have a dependency--on Markdown--which proved a little harder to implement. We trialed several Markdown plugins, but each had several quirks that interfered with the rendering of non-Markdown-based content. After several days of frustration, and even an attempt to custom-write a plugin for our needs, we stumbled across [Parsedown Party][12]. There was much partying! With WordPress GitHub Sync and Parsedown Party, we had integrated our two key platforms. - -Now it was time to make our content visually appealing and usable for our user audience. - -### Reading time and feedback - -To implement the reading time and feedback functionality, we built a new [page template for WordPress][13], and leveraged plugins within the page template. - -Knowing the estimated reading time of an article in advance has been [proven to increase engagement with content][14] and provides developers and users with the ability to decide whether to read the content now or bookmark it for later. We tested several WordPress plugins for reading time, but settled on [Reading Time WP][15] because it was highly configurable and could be easily embedded into WordPress page templates. Our decision to place Reading Time at the top of the content was designed to give the user the choice of whether to read now or save for later. With Reading Time in place, we then turned our attention to gathering user feedback and ratings for our documentation. - -![](https://opensource.com/sites/default/files/images/life-uploads/screenshot-from-2017-12-08-00-55-31.png) - -There are several rating and feedback plugins available for WordPress. We needed one that could be easily customized for several use cases, and that could aggregate or summarize ratings. After some experimentation, we settled on [Multi Rating Pro][16] because of its wide feature set, especially the ability to create a Review Ratings page in WordPress--i.e., a central page where staff can review ratings without having to be logged in to the WordPress backend. The only gap we ran into here was the ability to set the display order of rating options--but it will likely be added in a future release. - -The WordPress GitHub Integration plugin also gave us the ability to link back to the GitHub repository where the original Markdown content was held, inviting technical developers to contribute to improving our documentation. - -### Updating the existing documentation - -Now that the "container" for our new documentation had been developed, it was time to update the existing content. Because much of our documentation had grown organically over time, there were no style guidelines to shape how keywords and code were styled. This was tackled first, so that it could be applied to all content. [You can see our content style guidelines on GitHub.][17] - -As part of the update, we also ran several checks to ensure that the content was technically accurate, augmenting the existing documentation with several images for better readability. - -There were also a couple of additional tools that made creating internal links for documentation pieces easier. First, we installed the [WP Anchor Header][18] plugin. This plugin provided a small but important function: adding `id` content in GitHub using the `[markdown-toc][19]` library, then simply copied in to the WordPress content, where they would automatically link to the `id` attributes to each `

    `, `

    ` (and so on) element. This meant that internal anchors could be automatically generated on the command line from the Markdown content in GitHub using the `[markdown-toc][19]` library, then simply copied in to the WordPress content, where they would automatically link to the `id` attributes generated by WP Anchor Header. - -Next, we imported the updated documentation into WordPress from GitHub, and made sure we had meaningful and easy-to-search on slugs, descriptions, and keywords--because what good is excellent documentation if no one can find it?! A final activity was implementing redirects so that people hitting the old documentation would be taken to the new version. - -### What next? - -[Please do take a moment and have a read through our new documentation][20]. We know it isn't perfect--far from it--but we're confident that the mechanisms we've baked into our new documentation infrastructure will make it easier to identify gaps--and resolve them quickly. If you'd like to know more, or have suggestions for our documentation, please reach out to Kathy Reid on [Chat][21] (@kathy-mycroft) or via [email][22]. - -_Reprinted with permission from[Mycroft.ai][23]._ - -### About the author -Kathy Reid - Director of Developer Relations @MycroftAI, President of @linuxaustralia. Kathy Reid has expertise in open source technology management, web development, video conferencing, digital signage, technical communities and documentation. She has worked in a number of technical and leadership roles over the last 20 years, and holds Arts and Science undergraduate degrees... more about Kathy Reid - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/rocking-docs-mycroft - -作者:[Kathy Reid][a] -译者:[译者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/kathyreid -[1]:https://opensource.com/users/aneta -[2]:https://opensource.com/article/17/10/doc-audits -[3]:/file/382466 -[4]:https://opensource.com/sites/default/files/images/life-uploads/mycroft-documentation-audit.png (mycroft documentation audit) -[5]:https://git-scm.com/ -[6]:https://github.com/MycroftAI -[7]:https://en.wikipedia.org/wiki/Markdown -[8]:https://www.wordpress.org/ -[9]:https://github.com/ -[10]:https://github.com/mycroftai -[11]:http://mycroft.ai/team/ -[12]:https://wordpress.org/plugins/parsedown-party/ -[13]:https://developer.wordpress.org/themes/template-files-section/page-template-files/ -[14]:https://marketingland.com/estimated-reading-times-increase-engagement-79830 -[15]:https://jasonyingling.me/reading-time-wp/ -[16]:https://multiratingpro.com/ -[17]:https://github.com/MycroftAI/docs-rewrite/blob/master/README.md -[18]:https://wordpress.org/plugins/wp-anchor-header/ -[19]:https://github.com/jonschlinkert/markdown-toc -[20]:https://mycroft.ai/documentation -[21]:https://chat.mycroft.ai/ -[22]:mailto:kathy.reid@mycroft.ai -[23]:https://mycroft.ai/blog/improving-mycrofts-documentation/ diff --git a/sources/talk/20180111 The open organization and inner sourcing movements can share knowledge.md b/sources/talk/20180111 The open organization and inner sourcing movements can share knowledge.md deleted file mode 100644 index 272c1b03ae..0000000000 --- a/sources/talk/20180111 The open organization and inner sourcing movements can share knowledge.md +++ /dev/null @@ -1,121 +0,0 @@ -The open organization and inner sourcing movements can share knowledge -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/gov_collaborative_risk.png?itok=we8DKHuL) -Image by : opensource.com - -Red Hat is a company with roughly 11,000 employees. The IT department consists of roughly 500 members. Though it makes up just a fraction of the entire organization, the IT department is still sufficiently staffed to have many application service, infrastructure, and operational teams within it. Our purpose is "to enable Red Hatters in all functions to be effective, productive, innovative, and collaborative, so that they feel they can make a difference,"--and, more specifically, to do that by providing technologies and related services in a fashion that is as open as possible. - -Being open like this takes time, attention, and effort. While we always strive to be as open as possible, it can be difficult. For a variety of reasons, we don't always succeed. - -In this story, I'll explain a time when, in the rush to innovate, the Red Hat IT organization lost sight of its open ideals. But I'll also explore how returning to those ideals--and using the collaborative tactics of "inner source"--helped us to recover and greatly improve the way we deliver services. - -### About inner source - -Before I explain how inner source helped our team, let me offer some background on the concept. - -Inner source is the adoption of open source development practices between teams within an organization to promote better and faster delivery without requiring project resources be exposed to the world or openly licensed. It allows an organization to receive many of the benefits of open source development methods within its own walls. - -In this way, inner source aligns well with open organization strategies and principles; it provides a path for open, collaborative development. While the open organization defines its principles of openness broadly as transparency, inclusivity, adaptability, collaboration, and community--and covers how to use these open principles for communication, decision making, and many other topics--inner source is about the adoption of specific and tactical practices, processes, and patterns from open source communities to improve delivery. - -For instance, [the Open Organization Maturity Model][1] suggests that in order to be transparent, teams should, at minimum, share all project resources with the project team (though it suggests that it's generally better to share these resources with the entire organization). The common pattern in both inner source and open source development is to host all resources in a publicly available version control system, for source control management, which achieves the open organization goal of high transparency. - -Inner source aligns well with open organization strategies and principles. - -Another example of value alignment appears in the way open source communities accept contributions. In open source communities, source code is transparently available. Community contributions in the form of patches or merge requests are commonly accepted practices (even expected ones). This provides one example of how to meet the open organization's goal of promoting inclusivity and collaboration. - -### The challenge - -Early in 2014, Red Hat IT began its first steps toward making Amazon Web Services (AWS) a standard hosting offering for business critical systems. While teams within Red Hat IT had built several systems and services in AWS by this time, these were bespoke creations, and we desired to make deploying services to IT standards in AWS both simple and standardized. - -In order to make AWS cloud hosting meet our operational standards (while being scalable), the Cloud Enablement team within Red Hat IT decided that all infrastructure in AWS would be configured through code, rather than manually, and that everyone would use a standard set of tools. The Cloud Enablement team designed and built these standard tools; a separate group, the Platform Operations team, was responsible for provisioning and hosting systems and services in AWS using the tools. - -The Cloud Enablement team built a toolset, obtusely named "Template Util," based on AWS Cloud Formations configurations wrapped in a management layer to enforce certain configuration requirements and make stamping out multiple copies of services across environments easier. While the Template Util toolset technically met all our initial requirements, and we eventually provisioned the infrastructure for more than a dozen services with it, engineers in every team working with the tool found using it to be painful. Michael Johnson, one engineer using the tool, said "It made doing something relatively straightforward really complicated." - -Among the issues Template Util exhibited were: - - * Underlying cloud formations technologies implied constraints on application stack management at odds with how we managed our application systems. - * The tooling was needlessly complex and brittle in places, using multiple layered templating technologies and languages making syntax issues hard to debug. - * The code for the tool--and some of the data users needed to manipulate the tool--were kept in a repository that was difficult for most users to access. - * There was no standard process to contributing or accepting changes. - * The documentation was poor. - - - -As more engineers attempted to use the Template Util toolset, they found even more issues and limitations with the tools. Unhappiness continued to grow. To make matters worse, the Cloud Enablement team then shifted priorities to other deliverables without relinquishing ownership of the tool, so bug fixes and improvements to the tools were further delayed. - -The real, core issues here were our inability to build an inclusive community to collaboratively build shared tooling that met everyone's needs. Fear of losing "ownership," fear of changing requirements, and fear of seeing hard work abandoned all contributed to chronic conflict, which in turn led to poorer outcomes. - -### Crisis point - -By September 2015, more than a year after launching our first major service in AWS with the Template Util tool, we hit a crisis point. - -Many engineers refused to use the tools. That forced all of the related service provisioning work on a small set of engineers, further fracturing the community and disrupting service delivery roadmaps as these engineers struggled to deal with unexpected work. We called an emergency meeting and invited all the teams involved to find a solution. - -During the emergency meeting, we found that people generally thought we needed immediate change and should start the tooling effort over, but even the decision to start over wasn't unanimous. Many solutions emerged--sometimes multiple solutions from within a single team--all of which would require significant work to implement. While we couldn't reach a consensus on which solution to use during this meeting, we did reach an agreement to give proponents of different technologies two weeks to work together, across teams, to build their case with a prototype, which the community could then review. - -While we didn't reach a final and definitive decision, this agreement was the first point where we started to return to the open source ideals that guide our mission. By inviting all involved parties, we were able to be transparent and inclusive, and we could begin rebuilding our internal community. By making clear that we wanted to improve things and were open to new options, we showed our commitment to adaptability and meritocracy. Most importantly, the plan for building prototypes gave people a clear, return path to collaboration. - -When the community reviewed the prototypes, it determined that the clear leader was an Ansible-based toolset that would eventually become known, internally, as Ansicloud. (At the time, no one involved with this work had any idea that Red Hat would acquire Ansible the following month. It should also be noted that other teams within Red Hat have found tools based on Cloud Formation extremely useful, even when our specific Template Util tool did not find success.) - -This prototyping and testing phase didn't fix things overnight, though. While we had consensus on the general direction we needed to head, we still needed to improve the new prototype to the point at which engineers could use it reliably for production services. - -So over the next several months, a handful of engineers worked to further build and extend the Ansicloud toolset. We built three new production services. While we were sharing code, that sharing activity occurred at a low level of maturity. Some engineers had trouble getting access due to older processes. Other engineers headed in slightly different directions, with each engineer having to rediscover some of the core design issues themselves. - -### Returning to openness - -This led to a turning point: Building on top of the previous agreement, we focused on developing a unified vision and providing easier access. To do this, we: - - 1. created a list of specific goals for the project (both "must-haves" and "nice-to-haves"), - 2. created an open issue log for the project to avoid solving the same problem repeatedly, - 3. opened our code base so anyone in Red Hat could read or clone it, and - 4. made it easy for engineers to get trusted committer access - - - -Our agreement to collaborate, our finally unified vision, and our improved tool development methods spurred the growth of our community. Ansicloud adoption spread throughout the involved organizations, but this led to a new problem: The tool started changing more quickly than users could adapt to it, and improvements that different groups submitted were beginning to affect other groups in unanticipated ways. - -These issues resulted in our recent turn to inner source practices. While every open source project operates differently, we focused on adopting some best practices that seemed common to many of them. In particular: - - * We identified the business owner of the project and the core-contributor group of developers who would govern the development of the tools and decide what contributions to accept. While we want to keep things open, we can't have people working against each other or breaking each other's functionality. - * We developed a project README clarifying the purpose of the tool and specifying how to use it. We also created a CONTRIBUTING document explaining how to contribute, what sort of contributions would be useful, and what sort of tests a contribution would need to pass to be accepted. - * We began building continuous integration and testing services for the Ansicloud tool itself. This helped us ensure we could quickly and efficiently validate contributions technically, before the project accepted and merged them. - - - -With these basic agreements, documents, and tools available, we were back onto the path of open collaboration and successful inner sourcing. - -### Why it matters - -Why does inner source matter? - -From a developer community point of view, shifting from a traditional siloed development model to the inner source model has produced significant, quantifiable improvements: - - * Contributions to our tooling have grown 72% per week (by number of commits). - * The percentage of contributions from non-core committers has grown from 27% to 78%; the users of the toolset are driving its development. - * The contributor list has grown by 15%, primarily from new users of the tool set, rather than core committers, increasing our internal community. - - - -And the tools we've delivered through this project have allowed us to see dramatic improvements in our business outcomes. Using the Ansicloud tools, 54 new multi-environment application service deployments were created in 385 days (compared to 20 services in 1,013 days with the Template Util tools). We've gone from one new service deployment in a 50-day period to one every week--a seven-fold increase in the velocity of our delivery. - -What really matters here is that the improvements we saw were not aberrations. Inner source provides common, easily understood patterns that organizations can adopt to effectively promote collaboration (not to mention other open organization principles). By mirroring open source production practices, inner source can also mirror the benefits of open source code, which have been seen time and time again: higher quality code, faster development, and more engaged communities. - -This article is part of the [Open Organization Workbook project][2]. - -### about the author -Tom Benninger - Tom Benninger is a Solutions Architect, Systems Engineer, and continual tinkerer at Red Hat, Inc. Having worked with startups, small businesses, and larger enterprises, he has experience within a broad set of IT disciplines. His current area of focus is improving Application Lifecycle Management in the enterprise. He has a particular interest in how open source, inner source, and collaboration can help support modern application development practices and the adoption of DevOps, CI/CD, Agile,... - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/1/open-orgs-and-inner-source-it - -作者:[Tom Benninger][a] -译者:[译者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/tomben -[1]:https://opensource.com/open-organization/resources/open-org-maturity-model -[2]:https://opensource.com/open-organization/17/8/workbook-project-announcement diff --git a/sources/talk/20180112 in which the cost of structured data is reduced.md b/sources/talk/20180112 in which the cost of structured data is reduced.md deleted file mode 100644 index 992ad57a39..0000000000 --- a/sources/talk/20180112 in which the cost of structured data is reduced.md +++ /dev/null @@ -1,181 +0,0 @@ -in which the cost of structured data is reduced -====== -Last year I got the wonderful opportunity to attend [RacketCon][1] as it was hosted only 30 minutes away from my home. The two-day conference had a number of great talks on the first day, but what really impressed me was the fact that the entire second day was spent focusing on contribution. The day started out with a few 15- to 20-minute talks about how to contribute to a specific codebase (including that of Racket itself), and after that people just split off into groups focused around specific codebases. Each table had maintainers helping guide other folks towards how to work with the codebase and construct effective patch submissions. - -![lensmen chronicles][2] - -I came away from the conference with a great sense of appreciation for how friendly and welcoming the Racket community is, and how great Racket is as a swiss-army-knife type tool for quick tasks. (Not that it's unsuitable for large projects, but I don't have the opportunity to start any new large projects very frequently.) - -The other day I wanted to generate colored maps of the world by categorizing countries interactively, and Racket seemed like it would fit the bill nicely. The job is simple: show an image of the world with one country selected; when a key is pressed, categorize that country, then show the map again with all categorized countries colored, and continue with the next country selected. - -### GUIs and XML - -I have yet to see a language/framework more accessible and straightforward out of the box for drawing1. Here's the entry point which sets up state and then constructs a canvas that handles key input and display: -``` -(define (main path) - (let ([frame (new frame% [label "World color"])] - [categorizations (box '())] - [doc (call-with-input-file path read-xml/document)]) - (new (class canvas% - (define/override (on-char event) - (handle-key this categorizations (send event get-key-code))) - (super-new)) - [parent frame] - [paint-callback (draw doc categorizations)]) - (send frame show #t))) - -``` - -While the class system is not one of my favorite things about Racket (most newer code seems to avoid it in favor of [generic interfaces][3] in the rare case that polymorphism is truly called for), the fact that classes can be constructed in a light-weight, anonymous way makes it much less onerous than it could be. This code sets up all mutable state in a [`box`][4] which you use in the way you'd use a `ref` in ML or Clojure: a mutable wrapper around an immutable data structure. - -The world map I'm using is [an SVG of the Robinson projection][5] from Wikipedia. If you look closely there's a call to bind `doc` that calls [`call-with-input-file`][6] with [`read-xml/document`][7] which loads up the whole map file's SVG; just about as easily as you could ask for. - -The data you get back from `read-xml/document` is in fact a [document][8] struct, which contains an `element` struct containing `attribute` structs and lists of more `element` structs. All very sensible, but maybe not what you would expect in other dynamic languages like Clojure or Lua where free-form maps reign supreme. Racket really wants structure to be known up-front when possible, which is one of the things that help it produce helpful error messages when things go wrong. - -Here's how we handle keyboard input; we're displaying a map with one country highlighted, and `key` here tells us what the user pressed to categorize the highlighted country. If that key is in the `categories` hash then we put it into `categorizations`. -``` -(define categories #hash((select . "eeeeff") - (#\1 . "993322") - (#\2 . "229911") - (#\3 . "ABCD31") - (#\4 . "91FF55") - (#\5 . "2439DF"))) - -(define (handle-key canvas categorizations key) - (cond [(equal? #\backspace key) (swap! categorizations cdr)] - [(member key (dict-keys categories)) (swap! categorizations (curry cons key))] - [(equal? #\space key) (display (unbox categorizations))]) - (send canvas refresh)) - -``` - -### Nested updates: the bad parts - -Finally once we have a list of categorizations, we need to apply it to the map document and display. We apply a [`fold`][9] reduction over the XML document struct and the list of country categorizations (plus `'select` for the country that's selected to be categorized next) to get back a "modified" document struct where the proper elements have the style attributes applied for the given categorization, then we turn it into an image and hand it to [`draw-pict`][10]: -``` - -(define (update original-doc categorizations) - (for/fold ([doc original-doc]) - ([category (cons 'select (unbox categorizations))] - [n (in-range (length (unbox categorizations)) 0 -1)]) - (set-style doc n (style-for category)))) - -(define ((draw doc categorizations) _ context) - (let* ([newdoc (update doc categorizations)] - [xml (call-with-output-string (curry write-xml newdoc))]) - (draw-pict (call-with-input-string xml svg-port->pict) context 0 0))) - -``` - -The problem is in that pesky `set-style` function. All it has to do is reach deep down into the `document` struct to find the `n`th `path` element (the one associated with a given country), and change its `'style` attribute. It ought to be a simple task. Unfortunately this function ends up being anything but simple: -``` - -(define (set-style doc n new-style) - (let* ([root (document-element doc)] - [g (list-ref (element-content root) 8)] - [paths (element-content g)] - [path (first (drop (filter element? paths) n))] - [path-num (list-index (curry eq? path) paths)] - [style-index (list-index (lambda (x) (eq? 'style (attribute-name x))) - (element-attributes path))] - [attr (list-ref (element-attributes path) style-index)] - [new-attr (make-attribute (source-start attr) - (source-stop attr) - (attribute-name attr) - new-style)] - [new-path (make-element (source-start path) - (source-stop path) - (element-name path) - (list-set (element-attributes path) - style-index new-attr) - (element-content path))] - [new-g (make-element (source-start g) - (source-stop g) - (element-name g) - (element-attributes g) - (list-set paths path-num new-path))] - [root-contents (list-set (element-content root) 8 new-g)]) - (make-document (document-prolog doc) - (make-element (source-start root) - (source-stop root) - (element-name root) - (element-attributes root) - root-contents) - (document-misc doc)))) - -``` - -The reason for this is that while structs are immutable, they don't support functional updates. Whenever you're working with immutable data structures, you want to be able to say "give me a new version of this data, but with field `x` replaced by the value of `(f (lookup x))`". Racket can [do this with dictionaries][11] but not with structs2. If you want a modified version you have to create a fresh one3. - -### Lenses to the rescue? - -![first lensman][12] - -When I brought this up in the `#racket` channel on Freenode, I was helpfully pointed to the 3rd-party [Lens][13] library. Lenses are a general-purpose way of composing arbitrarily nested lookups and updates. Unfortunately at this time there's [a flaw][14] preventing them from working with `xml` structs, so it seemed I was out of luck. - -But then I was pointed to [X-expressions][15] as an alternative to structs. The [`xml->xexpr`][16] function turns the structs into a deeply-nested list tree with symbols and strings in it. The tag is the first item in the list, followed by an associative list of attributes, then the element's children. While this gives you fewer up-front guarantees about the structure of the data, it does work around the lens issue. - -For this to work, we need to compose a new lens based on the "path" we want to use to drill down into the `n`th country and its `style` attribute. The [`lens-compose`][17] function lets us do that. Note that the order here might be backwards from what you'd expect; it works deepest-first (the way [`compose`][18] works for functions). Also note that defining one lens gives us the ability to both get nested values (with [`lens-view`][19]) and update them. -``` -(define (style-lens n) - (lens-compose (dict-ref-lens 'style) - second-lens - (list-ref-lens (add1 (* n 2))) - (list-ref-lens 10))) -``` - -Our `` XML elements are under the 10th item of the root xexpr, (hence the [`list-ref-lens`][20] with 10) and they are interspersed with whitespace, so we have to double `n` to find the `` we want. The [`second-lens`][21] call gets us to that element's attribute alist, and [`dict-ref-lens`][22] lets us zoom in on the `'style` key out of that alist. - -Once we have our lens, it's just a matter of replacing `set-style` with a call to [`lens-set`][23] in our `update` function we had above, and then we're off: -``` -(define (update doc categorizations) - (for/fold ([d doc]) - ([category (cons 'select (unbox categorizations))] - [n (in-range (length (unbox categorizations)) 0 -1)]) - (lens-set (style-lens n) d (list (style-for category))))) -``` - -![second stage lensman][24] - -Often times the trade-off between freeform maps/hashes vs structured data feels like one of convenience vs long-term maintainability. While it's unfortunate that they can't be used with the `xml` structs4, lenses provide a way to get the best of both worlds, at least in some situations. - -The final version of the code clocks in at 51 lines and is is available [on GitLab][25]. - -๛ - --------------------------------------------------------------------------------- - -via: https://technomancy.us/185 - -作者:[Phil Hagelberg][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://technomancy.us/ -[1]:https://con.racket-lang.org/ -[2]:https://technomancy.us/i/chronicles-of-lensmen.jpg -[3]:https://docs.racket-lang.org/reference/struct-generics.html -[4]:https://docs.racket-lang.org/reference/boxes.html?q=box#%28def._%28%28quote._~23~25kernel%29._box%29%29 -[5]:https://commons.wikimedia.org/wiki/File:BlankMap-World_gray.svg -[6]:https://docs.racket-lang.org/reference/port-lib.html#(def._((lib._racket%2Fport..rkt)._call-with-input-string)) -[7]:https://docs.racket-lang.org/xml/index.html?q=read-xml#%28def._%28%28lib._xml%2Fmain..rkt%29._read-xml%2Fdocument%29%29 -[8]:https://docs.racket-lang.org/xml/#%28def._%28%28lib._xml%2Fmain..rkt%29._document%29%29 -[9]:https://docs.racket-lang.org/reference/for.html?q=for%2Ffold#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%2Ffold%29%29 -[10]:https://docs.racket-lang.org/pict/Rendering.html?q=draw-pict#%28def._%28%28lib._pict%2Fmain..rkt%29._draw-pict%29%29 -[11]:https://docs.racket-lang.org/reference/dicts.html?q=dict-update#%28def._%28%28lib._racket%2Fdict..rkt%29._dict-update%29%29 -[12]:https://technomancy.us/i/first-lensman.jpg -[13]:https://docs.racket-lang.org/lens/lens-guide.html -[14]:https://github.com/jackfirth/lens/issues/290 -[15]:https://docs.racket-lang.org/pollen/second-tutorial.html?q=xexpr#%28part._.X-expressions%29 -[16]:https://docs.racket-lang.org/xml/index.html?q=xexpr#%28def._%28%28lib._xml%2Fmain..rkt%29._xml-~3exexpr%29%29 -[17]:https://docs.racket-lang.org/lens/lens-reference.html#%28def._%28%28lib._lens%2Fcommon..rkt%29._lens-compose%29%29 -[18]:https://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Fprivate%2Flist..rkt%29._compose%29%29 -[19]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fcommon..rkt%29._lens-view%29%29 -[20]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fdata%2Flist..rkt%29._list-ref-lens%29%29 -[21]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fdata%2Flist..rkt%29._second-lens%29%29 -[22]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fdata%2Fdict..rkt%29._dict-ref-lens%29%29 -[23]:https://docs.racket-lang.org/lens/lens-reference.html?q=lens-view#%28def._%28%28lib._lens%2Fcommon..rkt%29._lens-set%29%29 -[24]:https://technomancy.us/i/second-stage-lensman.jpg -[25]:https://gitlab.com/technomancy/world-color/blob/master/world-color.rkt diff --git a/sources/talk/20180124 Security Chaos Engineering- A new paradigm for cybersecurity.md b/sources/talk/20180124 Security Chaos Engineering- A new paradigm for cybersecurity.md deleted file mode 100644 index 35c89150c8..0000000000 --- a/sources/talk/20180124 Security Chaos Engineering- A new paradigm for cybersecurity.md +++ /dev/null @@ -1,87 +0,0 @@ -Security Chaos Engineering: A new paradigm for cybersecurity -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_bank_vault_secure_safe.png?itok=YoW93h7C) - -Security is always changing and failure always exists. - -This toxic scenario requires a fresh perspective on how we think about operational security. We must understand that we are often the primary cause of our own security flaws. The industry typically looks at cybersecurity and failure in isolation or as separate matters. We believe that our lack of insight and operational intelligence into our own security control failures is one of the most common causes of security incidents and, subsequently, data breaches. - -> Fall seven times, stand up eight." --Japanese proverb - -The simple fact is that "to err is human," and humans derive their success as a direct result of the failures they encounter. Their rate of failure, how they fail, and their ability to understand that they failed in the first place are important building blocks to success. Our ability to learn through failure is inherent in the systems we build, the way we operate them, and the security we use to protect them. Yet there has been a lack of focus when it comes to how we approach preventative security measures, and the spotlight has trended toward the evolving attack landscape and the need to buy or build new solutions. - -### Security spending is continually rising and so are security incidents - -We spend billions on new information security technologies, however, we rarely take a proactive look at whether those security investments perform as expected. This has resulted in a continual increase in security spending on new solutions to keep up with the evolving attacks. - -Despite spending more on security, data breaches are continuously getting bigger and more frequent across all industries. We have marched so fast down this path of the "get-ahead-of-the-attacker" strategy that we haven't considered that we may be a primary cause of our own demise. How is it that we are building more and more security measures, but the problem seems to be getting worse? Furthermore, many of the notable data breaches over the past year were not the result of an advanced nation-state or spy-vs.-spy malicious advanced persistent threats (APTs); rather the principal causes of those events were incomplete implementation, misconfiguration, design flaws, and lack of oversight. - -The 2017 Ponemon Cost of a Data Breach Study breaks down the [root causes of data breaches][1] into three areas: malicious or criminal attacks, human factors or errors, and system glitches, including both IT and business-process failure. Of the three categories, malicious or criminal attacks comprises the largest distribution (47%), followed by human error (28%), and system glitches (25%). Cybersecurity vendors have historically focused on malicious root causes of data breaches, as it is the largest sole cause, but together human error and system glitches total 53%, a larger share of the overall problem. - -What is not often understood, whether due to lack of insight, reporting, or analysis, is that malicious or criminal attacks are often successful due to human error and system glitches. Both human error and system glitches are, at their root, primary markers of the existence of failure. Whether it's IT system failures, failures in process, or failures resulting from humans, it begs the question: "Should we be focusing on finding a method to identify, understand, and address our failures?" After all, it can be an arduous task to predict the next malicious attack, which often requires investment of time to sift threat intelligence, dig through forensic data, or churn threat feeds full of unknown factors and undetermined motives. Failure instrumentation, identification, and remediation are mostly comprised of things that we know, have the ability to test, and can measure. - -Failures we can analyze consist not only of IT, business, and general human factors but also the way we design, build, implement, configure, operate, observe, and manage security controls. People are the ones designing, building, monitoring, and managing the security controls we put in place to defend against malicious attackers. How often do we proactively instrument what we designed, built, and are operationally managing to determine if the controls are failing? Most organizations do not discover that their security controls were failing until a security incident results from that failure. The worst time to find out your security investment failed is during a security incident at 3 a.m. - -> Security incidents are not detective measures and hope is not a strategy when it comes to operating effective security controls. - -We hypothesize that a large portion of data breaches are caused not by sophisticated nation-state actors or hacktivists, but rather simple things rooted in human error and system glitches. Failure in security controls can arise from poor control placement, technical misconfiguration, gaps in coverage, inadequate testing practices, human error, and numerous other things. - -### The journey into Security Chaos Testing - -Our venture into this new territory of Security Chaos Testing has shifted our thinking about the root cause of many of our notable security incidents and data breaches. - -We were brought together by [Bruce Wong][2], who now works at Stitch Fix with Charles, one of the authors of this article. Prior to Stitch Fix, Bruce was a founder of the Chaos Engineering and System Reliability Engineering (SRE) practices at Netflix, the company commonly credited with establishing the field. Bruce learned about this article's other author, Aaron, through the open source [ChaoSlingr][3] Security Chaos Testing tool project, on which Aaron was a contributor. Aaron was interested in Bruce's perspective on the idea of applying Chaos Engineering to cybersecurity, which led Bruce to connect us to share what we had been working on. As security practitioners, we were both intrigued by the idea of Chaos Engineering and had each begun thinking about how this new method of instrumentation might have a role in cybersecurity. - -Within a short timeframe, we began finishing each other's thoughts around testing and validating security capabilities, which we collectively call "Security Chaos Engineering." We directly challenged many of the concepts we had come to depend on in our careers, such as compensating security controls, defense-in-depth, and how to design preventative security. Quickly we realized that we needed to challenge the status quo "set-it-and-forget-it" model and instead execute on continuous instrumentation and validation of security capabilities. - -Businesses often don't fully understand whether their security capabilities and controls are operating as expected until they are not. We had both struggled throughout our careers to provide measurements on security controls that go beyond simple uptime metrics. Our journey has shown us there is a need for a more pragmatic approach that emphasizes proactive instrumentation and experimentation over blind faith. - -### Defining new terms - -In the security industry, we have a habit of not explaining terms and assuming we are speaking the same language. To correct that, here are a few key terms in this new approach: - - * **(Security) Chaos Experiments** are foundationally rooted in the scientific method, in that they seek not to validate what is already known to be true or already known to be false, rather they are focused on deriving new insights about the current state. - * **Security Chaos Engineering** is the discipline of instrumentation, identification, and remediation of failure within security controls through proactive experimentation to build confidence in the system's ability to defend against malicious conditions in production. - - - -### Security and distributed systems - -Consider the evolving nature of modern application design where systems are becoming more and more distributed, ephemeral, and immutable in how they operate. In this shifting paradigm, it is becoming difficult to comprehend the operational state and health of our systems' security. Moreover, how are we ensuring that it remains effective and vigilant as the surrounding environment is changing its parameters, components, and methodologies? - -What does it mean to be effective in terms of security controls? After all, a single security capability could easily be implemented in a wide variety of diverse scenarios in which failure may arise from many possible sources. For example, a standard firewall technology may be implemented, placed, managed, and configured differently depending on complexities in the business, web, and data logic. - -It is imperative that we not operate our business products and services on the assumption that something works. We must constantly, consistently, and proactively instrument our security controls to ensure they cut the mustard when it matters. This is why Security Chaos Testing is so important. What Security Chaos Engineering does is it provides a methodology for the experimentation of the security of distributed systems in order to build confidence in the ability to withstand malicious conditions. - -In Security Chaos Engineering: - - * Security capabilities must be end-to-end instrumented. - * Security must be continuously instrumented to build confidence in the system's ability to withstand malicious conditions. - * Readiness of a system's security defenses must be proactively assessed to ensure they are battle-ready and operating as intended. - * The security capability toolchain must be instrumented from end to end to drive new insights into not only the effectiveness of the functionality within the toolchain but also to discover where added value and improvement can be injected. - * Practiced instrumentation seeks to identify, detect, and remediate failures in security controls. - * The focus is on vulnerability and failure identification, not failure management. - * The operational effectiveness of incident management is sharpened. - - - -As Henry Ford said, "Failure is only the opportunity to begin again, this time more intelligently." Security Chaos Engineering and Security Chaos Testing give us that opportunity. - -Would you like to learn more? Join the discussion by following [@aaronrinehart][4] and [@charles_nwatu][5] on Twitter. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/new-paradigm-cybersecurity - -作者:[Aaron Rinehart][a] -译者:[译者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/aaronrinehart -[1]:https://www.ibm.com/security/data-breach -[2]:https://twitter.com/bruce_m_wong?lang=en -[3]:https://github.com/Optum/ChaoSlingr -[4]:https://twitter.com/aaronrinehart -[5]:https://twitter.com/charles_nwatu diff --git a/sources/talk/20180131 How to write a really great resume that actually gets you hired.md b/sources/talk/20180131 How to write a really great resume that actually gets you hired.md deleted file mode 100644 index b54b3944ae..0000000000 --- a/sources/talk/20180131 How to write a really great resume that actually gets you hired.md +++ /dev/null @@ -1,395 +0,0 @@ -How to write a really great resume that actually gets you hired -============================================================ - - -![](https://cdn-images-1.medium.com/max/2000/1*k7HRLZAsuINP9vIs2BIh1g.png) - -This is a data-driven guide to writing a resume that actually gets you hired. I’ve spent the past four years analyzing which resume advice works regardless of experience, role, or industry. The tactics laid out below are the result of what I’ve learned. They helped me land offers at Google, Microsoft, and Twitter and have helped my students systematically land jobs at Amazon, Apple, Google, Microsoft, Facebook, and more. - -### Writing Resumes Sucks. - -It’s a vicious cycle. - -We start by sifting through dozens of articles by career “gurus,” forced to compare conflicting advice and make our own decisions on what to follow. - -The first article says “one page MAX” while the second says “take two or three and include all of your experience.” - -The next says “write a quick summary highlighting your personality and experience” while another says “summaries are a waste of space.” - -You scrape together your best effort and hit “Submit,” sending your resume into the ether. When you don’t hear back, you wonder what went wrong: - - _“Was it the single page or the lack of a summary? Honestly, who gives a s**t at this point. I’m sick of sending out 10 resumes every day and hearing nothing but crickets.”_ - - -![](https://cdn-images-1.medium.com/max/1000/1*_zQqAjBhB1R4fz55InrrIw.jpeg) -How it feels to try and get your resume read in today’s world. - -Writing resumes sucks but it’s not your fault. - -The real reason it’s so tough to write a resume is because most of the advice out there hasn’t been proven against the actual end goal of getting a job. If you don’t know what consistently works, you can’t lay out a system to get there. - -It’s easy to say “one page works best” when you’ve seen it happen a few times. But how does it hold up when we look at 100 resumes across different industries, experience levels, and job titles? - -That’s what this article aims to answer. - -Over the past four years, I’ve personally applied to hundreds of companies and coached hundreds of people through the job search process. This has given me a huge opportunity to measure, analyze, and test the effectiveness of different resume strategies at scale. - -This article is going to walk through everything I’ve learned about resumes over the past 4 years, including: - -* Mistakes that more than 95% of people make, causing their resumes to get tossed immediately - -* Three things that consistently appear in the resumes of highly effective job searchers (who go on to land jobs at the world’s best companies) - -* A quick hack that will help you stand out from the competition and instantly build relationships with whomever is reading your resume (increasing your chances of hearing back and getting hired) - -* The exact resume template that got me interviews and offers at Google, Microsoft, Twitter, Uber, and more - -Before we get to the unconventional strategies that will help set you apart, we need to make sure our foundational bases are covered. That starts with understanding the mistakes most job seekers make so we can make our resume bulletproof. - -### Resume Mistakes That 95% Of People Make - -Most resumes that come through an online portal or across a recruiter’s desk are tossed out because they violate a simple rule. - -When recruiters scan a resume, the first thing they look for is mistakes. Your resume could be fantastic, but if you violate a rule like using an unprofessional email address or improper grammar, it’s going to get tossed out. - -Our goal is to fully understand the triggers that cause recruiters/ATS systems to make the snap decisions on who stays and who goes. - -In order to get inside the heads of these decision makers, I collected data from dozens of recruiters and hiring mangers across industries. These people have several hundred years of hiring experience under their belts and they’ve reviewed 100,000+ resumes across industries. - -They broke down the five most common mistakes that cause them to cut resumes from the pile: - - -![](https://cdn-images-1.medium.com/max/1000/1*5Zbr3HFeKSjvPGZdq_LCKA.png) - -### The Five Most Common Resume Mistakes (According To Recruiters & Hiring Managers) - -Issue #1: Sloppiness (typos, spelling errors, & grammatical mistakes). Close to 60% of resumes have some sort of typo or grammatical issue. - -Solution: Have your resume reviewed by three separate sources — spell checking software, a friend, and a professional. Spell check should be covered if you’re using Microsoft Word or Google Docs to create your resume. - -A friend or family member can cover the second base, but make sure you trust them with reviewing the whole thing. You can always include an obvious mistake to see if they catch it. - -Finally, you can hire a professional editor on [Upwork][1]. It shouldn’t take them more than 15–20 minutes to review so it’s worth paying a bit more for someone with high ratings and lots of hours logged. - -Issue #2: Summaries are too long and formal. Many resumes include summaries that consist of paragraphs explaining why they are a “driven, results oriented team player.” When hiring managers see a block of text at the top of the resume, you can bet they aren’t going to read the whole thing. If they do give it a shot and read something similar to the sentence above, they’re going to give up on the spot. - -Solution: Summaries are highly effective, but they should be in bullet form and showcase your most relevant experience for the role. For example, if I’m applying for a new business sales role my first bullet might read “Responsible for driving $11M of new business in 2018, achieved 168% attainment (#1 on my team).” - -Issue #3: Too many buzz words. Remember our driven team player from the last paragraph? Phrasing like that makes hiring managers cringe because your attempt to stand out actually makes you sound like everyone else. - -Solution: Instead of using buzzwords, write naturally, use bullets, and include quantitative results whenever possible. Would you rather hire a salesperson who “is responsible for driving new business across the healthcare vertical to help companies achieve their goals” or “drove $15M of new business last quarter, including the largest deal in company history”? Skip the buzzwords and focus on results. - -Issue #4: Having a resume that is more than one page. The average employer spends six seconds reviewing your resume — if it’s more than one page, it probably isn’t going to be read. When asked, recruiters from Google and Barclay’s both said multiple page resumes “are the bane of their existence.” - -Solution: Increase your margins, decrease your font, and cut down your experience to highlight the most relevant pieces for the role. It may seem impossible but it’s worth the effort. When you’re dealing with recruiters who see hundreds of resumes every day, you want to make their lives as easy as possible. - -### More Common Mistakes & Facts (Backed By Industry Research) - -In addition to personal feedback, I combed through dozens of recruitment survey results to fill any gaps my contacts might have missed. Here are a few more items you may want to consider when writing your resume: - -* The average interviewer spends 6 seconds scanning your resume - -* The majority of interviewers have not looked at your resume until -  you walk into the room - -* 76% of resumes are discarded for an unprofessional email address - -* Resumes with a photo have an 88% rejection rate - -* 58% of resumes have typos - -* Applicant tracking software typically eliminates 75% of resumes due to a lack of keywords and phrases being present - -Now that you know every mistake you need to avoid, the first item on your to-do list is to comb through your current resume and make sure it doesn’t violate anything mentioned above. - -Once you have a clean resume, you can start to focus on more advanced tactics that will really make you stand out. There are a few unique elements you can use to push your application over the edge and finally get your dream company to notice you. - - -![](https://cdn-images-1.medium.com/max/1000/1*KthhefFO33-8tm0kBEPbig.jpeg) - -### The 3 Elements Of A Resume That Will Get You Hired - -My analysis showed that highly effective resumes typically include three specific elements: quantitative results, a simple design, and a quirky interests section. This section breaks down all three elements and shows you how to maximize their impact. - -### Quantitative Results - -Most resumes lack them. - -Which is a shame because my data shows that they make the biggest difference between resumes that land interviews and resumes that end up in the trash. - -Here’s an example from a recent resume that was emailed to me: - -> Experience - -> + Identified gaps in policies and processes and made recommendations for solutions at the department and institution level - -> + Streamlined processes to increase efficiency and enhance quality - -> + Directly supervised three managers and indirectly managed up to 15 staff on multiple projects - -> + Oversaw execution of in-house advertising strategy - -> + Implemented comprehensive social media plan - -As an employer, that tells me absolutely nothing about what to expect if I hire this person. - -They executed an in-house marketing strategy. Did it work? How did they measure it? What was the ROI? - -They also also identified gaps in processes and recommended solutions. What was the result? Did they save time and operating expenses? Did it streamline a process resulting in more output? - -Finally, they managed a team of three supervisors and 15 staffers. How did that team do? Was it better than the other teams at the company? What results did they get and how did those improve under this person’s management? - -See what I’m getting at here? - -These types of bullets talk about daily activities, but companies don’t care about what you do every day. They care about results. By including measurable metrics and achievements in your resume, you’re showcasing the value that the employer can expect to get if they hire you. - -Let’s take a look at revised versions of those same bullets: - -> Experience - -> + Managed a team of 20 that consistently outperformed other departments in lead generation, deal size, and overall satisfaction (based on our culture survey) - -> + Executed in-house marketing strategy that resulted in a 15% increase in monthly leads along with a 5% drop in the cost per lead - -> + Implemented targeted social media campaign across Instagram & Pintrest, which drove an additional 50,000 monthly website visits and generated 750 qualified leads in 3 months - -If you were in the hiring manager’s shoes, which resume would you choose? - -That’s the power of including quantitative results. - -### Simple, Aesthetic Design That Hooks The Reader - -These days, it’s easy to get carried away with our mission to “stand out.” I’ve seen resume overhauls from graphic designers, video resumes, and even resumes [hidden in a box of donuts.][2] - -While those can work in very specific situations, we want to aim for a strategy that consistently gets results. The format I saw the most success with was a black and white Word template with sections in this order: - -* Summary - -* Interests - -* Experience - -* Education - -* Volunteer Work (if you have it) - -This template is effective because it’s familiar and easy for the reader to digest. - -As I mentioned earlier, hiring managers scan resumes for an average of 6 seconds. If your resume is in an unfamiliar format, those 6 seconds won’t be very comfortable for the hiring manager. Our brains prefer things we can easily recognize. You want to make sure that a hiring manager can actually catch a glimpse of who you are during their quick scan of your resume. - -If we’re not relying on design, this hook needs to come from the  _Summary_ section at the top of your resume. - -This section should be done in bullets (not paragraph form) and it should contain 3–4 highlights of the most relevant experience you have for the role. For example, if I was applying for a New Business Sales position, my summary could look like this: - -> Summary - -> Drove quarterly average of $11M in new business with a quota attainment of 128% (#1 on my team) - -> Received award for largest sales deal of the year - -> Developed and trained sales team on new lead generation process that increased total leads by 17% in 3 months, resulting in 4 new deals worth $7M - -Those bullets speak directly to the value I can add to the company if I was hired for the role. - -### An “Interests” Section That’s Quirky, Unique, & Relatable - -This is a little “hack” you can use to instantly build personal connections and positive associations with whomever is reading your resume. - -Most resumes have a skills/interests section, but it’s usually parked at the bottom and offers little to no value. It’s time to change things up. - -[Research shows][3] that people rely on emotions, not information, to make decisions. Big brands use this principle all the time — emotional responses to advertisements are more influential on a person’s intent to buy than the content of an ad. - -You probably remember Apple’s famous “Get A Mac” campaign: - - -When it came to specs and performance, Macs didn’t blow every single PC out of the water. But these ads solidified who was “cool” and who wasn’t, which was worth a few extra bucks to a few million people. - -By tugging at our need to feel “cool,” Apple’s campaign led to a [42% increase in market share][4] and a record sales year for Macbooks. - -Now we’re going to take that same tactic and apply it to your resume. - -If you can invoke an emotional response from your recruiter, you can influence the mental association they assign to you. This gives you a major competitive advantage. - -Let’s start with a question — what could you talk about for hours? - -It could be cryptocurrency, cooking, World War 2, World of Warcraft, or how Google’s bet on segmenting their company under the Alphabet is going to impact the technology sector over the next 5 years. - -Did a topic (or two) pop into year head? Great. - -Now think about what it would be like to have a conversation with someone who was just as passionate and knew just as much as you did on the topic. It’d be pretty awesome, right?  _Finally, _ someone who gets it! - -That’s exactly the kind of emotional response we’re aiming to get from a hiring manager. - -There are five “neutral” topics out there that people enjoy talking about: - -1. Food/Drink - -2. Sports - -3. College - -4. Hobbies - -5. Geography (travel, where people are from, etc.) - -These topics are present in plenty of interest sections but we want to take them one step further. - -Let’s say you had the best night of your life at the Full Moon Party in Thailand. Which of the following two options would you be more excited to read: - -* Traveling - -* Ko Pha Ngan beaches (where the full moon party is held) - -Or, let’s say that you went to Duke (an ACC school) and still follow their basketball team. Which would you be more pumped about: - -* College Sports - -* ACC Basketball (Go Blue Devils!) - -In both cases, the second answer would probably invoke a larger emotional response because it is tied directly to your experience. - -I want you to think about your interests that fit into the five categories I mentioned above. - -Now I want you to write a specific favorite associated with each category in parentheses next to your original list. For example, if you wrote travel you can add (ask me about the time I was chased by an elephant in India) or (specifically meditation in a Tibetan monastery). - -Here is the [exact set of interests][5] I used on my resume when I interviewed at Google, Microsoft, and Twitter: - - _ABC Kitchen’s Atmosphere, Stumptown Coffee (primarily cold brew), Michael Lewis (Liar’s Poker), Fishing (especially fly), Foods That Are Vehicles For Hot Sauce, ACC Sports (Go Deacs!) & The New York Giants_ - - -![](https://cdn-images-1.medium.com/max/1000/1*ONxtGr_xUYmz4_Xe66aeng.jpeg) - -If you want to cheat here, my experience shows that anything about hot sauce is an instant conversation starter. - -### The Proven Plug & Play Resume Template - -Now that we have our strategies down, it’s time to apply these tactics to a real resume. Our goal is to write something that increases your chances of hearing back from companies, enhances your relationships with hiring managers, and ultimately helps you score the job offer. - -The example below is the exact resume that I used to land interviews and offers at Microsoft, Google, and Twitter. I was targeting roles in Account Management and Sales, so this sample is tailored towards those positions. We’ll break down each section below: - - -![](https://cdn-images-1.medium.com/max/1000/1*B2RQ89ue2dGymRdwMY2lBA.png) - -First, I want you to notice how clean this is. Each section is clearly labeled and separated and flows nicely from top to bottom. - -My summary speaks directly to the value I’ve created in the past around company culture and its bottom line: - -* I consistently exceeded expectations - -* I started my own business in the space (and saw real results) - -* I’m a team player who prioritizes culture - -I purposefully include my Interests section right below my Summary. If my hiring manager’s six second scan focused on the summary, I know they’ll be interested. Those bullets cover all the subconscious criteria for qualification in sales. They’re going to be curious to read more in my Experience section. - -By sandwiching my Interests in the middle, I’m upping their visibility and increasing the chance of creating that personal connection. - -You never know — the person reading my resume may also be a hot sauce connoisseur and I don’t want that to be overlooked because my interests were sitting at the bottom. - -Next, my Experience section aims to flesh out the points made in my Summary. I mentioned exceeding my quota up top, so I included two specific initiatives that led to that attainment, including measurable results: - -* A partnership leveraging display advertising to drive users to a gamified experience. The campaign resulted in over 3000 acquisitions and laid the groundwork for the 2nd largest deal in company history. - -* A partnership with a top tier agency aimed at increasing conversions for a client by improving user experience and upgrading tracking during a company-wide website overhaul (the client has ~20 brand sites). Our efforts over 6 months resulted in a contract extension worth 316% more than their original deal. - -Finally, I included my education at the very bottom starting with the most relevant coursework. - -Download My Resume Templates For Free - -You can download a copy of the resume sample above as well as a plug and play template here: - -Austin’s Resume: [Click To Download][6] - -Plug & Play Resume Template: [Click To Download][7] - -### Bonus Tip: An Unconventional Resume “Hack” To Help You Beat Applicant Tracking Software - -If you’re not already familiar, Applicant Tracking Systems are pieces of software that companies use to help “automate” the hiring process. - -After you hit submit on your online application, the ATS software scans your resume looking for specific keywords and phrases (if you want more details, [this article][8] does a good job of explaining ATS). - -If the language in your resume matches up, the software sees it as a good fit for the role and will pass it on to the recruiter. However, even if you’re highly qualified for the role but you don’t use the right wording, your resume can end up sitting in a black hole. - -I’m going to teach you a little hack to help improve your chances of beating the system and getting your resume in the hands of a human: - -Step 1: Highlight and select the entire job description page and copy it to your clipboard. - -Step 2: Head over to [WordClouds.com][9] and click on the “Word List” button at the top. Towards the top of the pop up box, you should see a link for Paste/Type Text. Go ahead and click that. - -Step 3: Now paste the entire job description into the box, then hit “Apply.” - -WordClouds is going to spit out an image that showcases every word in the job description. The larger words are the ones that appear most frequently (and the ones you want to make sure to include when writing your resume). Here’s an example for a data a science role: - - -![](https://cdn-images-1.medium.com/max/1000/1*O7VO1C9nhC9LZct7vexTbA.png) - -You can also get a quantitative view by clicking “Word List” again after creating your cloud. That will show you the number of times each word appeared in the job description: - -9 data - -6 models - -4 experience - -4 learning - -3 Experience - -3 develop - -3 team - -2 Qualifications - -2 statistics - -2 techniques - -2 libraries - -2 preferred - -2 research - -2 business - -When writing your resume, your goal is to include those words in the same proportions as the job description. - -It’s not a guaranteed way to beat the online application process, but it will definitely help improve your chances of getting your foot in the door! - -* * * - -### Want The Inside Info On Landing A Dream Job Without Connections, Without “Experience,” & Without Applying Online? - -[Click here to get the 5 free strategies that my students have used to land jobs at Google, Microsoft, Amazon, and more without applying online.][10] - - _Originally published at _ [_cultivatedculture.com_][11] _._ - --------------------------------------------------------------------------------- - -作者简介: - -I help people land jobs they love and salaries they deserve at CultivatedCulture.com - ----------- - -via: https://medium.freecodecamp.org/how-to-write-a-really-great-resume-that-actually-gets-you-hired-e18533cd8d17 - -作者:[Austin Belcak ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://medium.freecodecamp.org/@austin.belcak -[1]:http://www.upwork.com/ -[2]:https://www.thrillist.com/news/nation/this-guy-hides-his-resume-in-boxes-of-donuts-to-score-job-interviews -[3]:https://www.psychologytoday.com/blog/inside-the-consumer-mind/201302/how-emotions-influence-what-we-buy -[4]:https://www.businesswire.com/news/home/20070608005253/en/Apple-Mac-Named-Successful-Marketing-Campaign-2007 -[5]:http://cultivatedculture.com/resume-skills-section/ -[6]:https://drive.google.com/file/d/182gN6Kt1kBCo1LgMjtsGHOQW2lzATpZr/view?usp=sharing -[7]:https://drive.google.com/open?id=0B3WIcEDrxeYYdXFPVlcyQlJIbWc -[8]:https://www.jobscan.co/blog/8-things-you-need-to-know-about-applicant-tracking-systems/ -[9]:https://www.wordclouds.com/ -[10]:https://cultivatedculture.com/dreamjob/ -[11]:https://cultivatedculture.com/write-a-resume/ \ No newline at end of file diff --git a/sources/talk/20180206 UQDS- A software-development process that puts quality first.md b/sources/talk/20180206 UQDS- A software-development process that puts quality first.md deleted file mode 100644 index e9f7bb94ac..0000000000 --- a/sources/talk/20180206 UQDS- A software-development process that puts quality first.md +++ /dev/null @@ -1,99 +0,0 @@ -UQDS: A software-development process that puts quality first -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/build_structure_tech_program_code_construction.png?itok=nVsiLuag) - -The Ultimate Quality Development System (UQDS) is a software development process that provides clear guidelines for how to use branches, tickets, and code reviews. It was invented more than a decade ago by Divmod and adopted by [Twisted][1], an event-driven framework for Python that underlies popular commercial platforms like HipChat as well as open source projects like Scrapy (a web scraper). - -Divmod, sadly, is no longer around—it has gone the way of many startups. Luckily, since many of its products were open source, its legacy lives on. - -When Twisted was a young project, there was no clear process for when code was "good enough" to go in. As a result, while some parts were highly polished and reliable, others were alpha quality software—with no way to tell which was which. UQDS was designed as a process to help an existing project with definite quality challenges ramp up its quality while continuing to add features and become more useful. - -UQDS has helped the Twisted project evolve from having frequent regressions and needing multiple release candidates to get a working version, to achieving its current reputation of stability and reliability. - -### UQDS's building blocks - -UQDS was invented by Divmod back in 2006. At that time, Continuous Integration (CI) was in its infancy and modern version control systems, which allow easy branch merging, were barely proofs of concept. Although Divmod did not have today's modern tooling, it put together CI, some ad-hoc tooling to make [Subversion branches][2] work, and a lot of thought into a working process. Thus the UQDS methodology was born. - -UQDS is based upon fundamental building blocks, each with their own carefully considered best practices: - - 1. Tickets - 2. Branches - 3. Tests - 4. Reviews - 5. No exceptions - - - -Let's go into each of those in a little more detail. - -#### Tickets - -In a project using the UQDS methodology, no change is allowed to happen if it's not accompanied by a ticket. This creates a written record of what change is needed and—more importantly—why. - - * Tickets should define clear, measurable goals. - * Work on a ticket does not begin until the ticket contains goals that are clearly defined. - - - -#### Branches - -Branches in UQDS are tightly coupled with tickets. Each branch must solve one complete ticket, no more and no less. If a branch addresses either more or less than a single ticket, it means there was a problem with the ticket definition—or with the branch. Tickets might be split or merged, or a branch split and merged, until congruence is achieved. - -Enforcing that each branch addresses no more nor less than a single ticket—which corresponds to one logical, measurable change—allows a project using UQDS to have fine-grained control over the commits: A single change can be reverted or changes may even be applied in a different order than they were committed. This helps the project maintain a stable and clean codebase. - -#### Tests - -UQDS relies upon automated testing of all sorts, including unit, integration, regression, and static tests. In order for this to work, all relevant tests must pass at all times. Tests that don't pass must either be fixed or, if no longer relevant, be removed entirely. - -Tests are also coupled with tickets. All new work must include tests that demonstrate that the ticket goals are fully met. Without this, the work won't be merged no matter how good it may seem to be. - -A side effect of the focus on tests is that the only platforms that a UQDS-using project can say it supports are those on which the tests run with a CI framework—and where passing the test on the platform is a condition for merging a branch. Without this restriction on supported platforms, the quality of the project is not Ultimate. - -#### Reviews - -While automated tests are important to the quality ensured by UQDS, the methodology never loses sight of the human factor. Every branch commit requires code review, and each review must follow very strict rules: - - 1. Each commit must be reviewed by a different person than the author. - 2. Start with a comment thanking the contributor for their work. - 3. Make a note of something that the contributor did especially well (e.g., "that's the perfect name for that variable!"). - 4. Make a note of something that could be done better (e.g., "this line could use a comment explaining the choices."). - 5. Finish with directions for an explicit next step, typically either merge as-is, fix and merge, or fix and submit for re-review. - - - -These rules respect the time and effort of the contributor while also increasing the sharing of knowledge and ideas. The explicit next step allows the contributor to have a clear idea on how to make progress. - -#### No exceptions - -In any process, it's easy to come up with reasons why you might need to flex the rules just a little bit to let this thing or that thing slide through the system. The most important fundamental building block of UQDS is that there are no exceptions. The entire community works together to make sure that the rules do not flex, not for any reason whatsoever. - -Knowing that all code has been approved by a different person than the author, that the code has complete test coverage, that each branch corresponds to a single ticket, and that this ticket is well considered and complete brings a piece of mind that is too valuable to risk losing, even for a single small exception. The goal is quality, and quality does not come from compromise. - -### A downside to UQDS - -While UQDS has helped Twisted become a highly stable and reliable project, this reliability hasn't come without cost. We quickly found that the review requirements caused a slowdown and backlog of commits to review, leading to slower development. The answer to this wasn't to compromise on quality by getting rid of UQDS; it was to refocus the community priorities such that reviewing commits became one of the most important ways to contribute to the project. - -To help with this, the community developed a bot in the [Twisted IRC channel][3] that will reply to the command `review tickets` with a list of tickets that still need review. The [Twisted review queue][4] website returns a prioritized list of tickets for review. Finally, the entire community keeps close tabs on the number of tickets that need review. It's become an important metric the community uses to gauge the health of the project. - -### Learn more - -The best way to learn about UQDS is to [join the Twisted Community][5] and see it in action. If you'd like more information about the methodology and how it might help your project reach a high level of reliability and stability, have a look at the [UQDS documentation][6] in the Twisted wiki. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/uqds - -作者:[Moshe Zadka][a] -译者:[译者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/moshez -[1]:https://twistedmatrix.com/trac/ -[2]:http://structure.usc.edu/svn/svn.branchmerge.html -[3]:http://webchat.freenode.net/?channels=%23twisted -[4]:https://twisted.reviews -[5]:https://twistedmatrix.com/trac/wiki/TwistedCommunity -[6]:https://twistedmatrix.com/trac/wiki/UltimateQualityDevelopmentSystem diff --git a/sources/talk/20180207 Why Mainframes Aren-t Going Away Any Time Soon.md b/sources/talk/20180207 Why Mainframes Aren-t Going Away Any Time Soon.md deleted file mode 100644 index 7a1a837ff9..0000000000 --- a/sources/talk/20180207 Why Mainframes Aren-t Going Away Any Time Soon.md +++ /dev/null @@ -1,73 +0,0 @@ -Why Mainframes Aren't Going Away Any Time Soon -====== - -![](http://www.datacenterknowledge.com/sites/datacenterknowledge.com/files/styles/article_featured_standard/public/ibm%20z13%20mainframe%202015%20getty.jpg?itok=uB8agshi) - -IBM's last earnings report showed the [first uptick in revenue in more than five years.][1] Some of that growth was from an expected source, cloud revenue, which was up 24 percent year over year and now accounts for 21 percent of Big Blue's take. Another major boost, however, came from a spike in mainframe revenue. Z series mainframe sales were up 70 percent, the company said. - -This may sound somewhat akin to a return to vacuum tube technology in a world where transistors are yesterday's news. In actuality, this is only a sign of the changing face of IT. - -**Related:** [One Click and Voilà, Your Entire Data Center is Encrypted][2] - -Modern mainframes definitely aren't your father's punch card-driven machines that filled entire rooms. These days, they most often run Linux and have found a renewed place in the data center, where they're being called upon to do a lot of heavy lifting. Want to know where the largest instance of Oracle's database runs? It's on a Linux mainframe. How about the largest implementation of SAP on the planet? Again, Linux on a mainframe. - -"Before the advent of Linux on the mainframe, the people who bought mainframes primarily were people who already had them," Leonard Santalucia explained to Data Center Knowledge several months back at the All Things Open conference. "They would just wait for the new version to come out and upgrade to it, because it would run cheaper and faster. - -**Related:** [IBM Designs a “Performance Beast” for AI][3] - -"When Linux came out, it opened up the door to other customers that never would have paid attention to the mainframe. In fact, probably a good three to four hundred new clients that never had mainframes before got them. They don't have any old mainframes hanging around or ones that were upgraded. These are net new mainframes." - -Although Santalucia is CTO at Vicom Infinity, primarily an IBM reseller, at the conference he was wearing his hat as chairperson of the Linux Foundation's Open Mainframe Project. He was joined in the conversation by John Mertic, the project's director of program management. - -Santalucia knows IBM's mainframes from top to bottom, having spent 27 years at Big Blue, the last eight as CTO for the company's systems and technology group. - -"Because of Linux getting started with it back in 1999, it opened up a lot of doors that were closed to the mainframe," he said. "Beforehand it was just z/OS, z/VM, z/VSE, z/TPF, the traditional operating systems. When Linux came along, it got the mainframe into other areas that it never was, or even thought to be in, because of how open it is, and because Linux on the mainframe is no different than Linux on any other platform." - -The focus on Linux isn't the only motivator behind the upsurge in mainframe use in data centers. Increasingly, enterprises with heavy IT needs are finding many advantages to incorporating modern mainframes into their plans. For example, mainframes can greatly reduce power, cooling, and floor space costs. In markets like New York City, where real estate is at a premium, electricity rates are high, and electricity use is highly taxed to reduce demand, these are significant advantages. - -"There was one customer where we were able to do a consolidation of 25 x86 cores to one core on a mainframe," Santalucia said. "They have several thousand machines that are ten and twenty cores each. So, as far as the eye could see in this data center, [x86 server workloads] could be picked up and moved onto this box that is about the size of a sub-zero refrigerator in your kitchen." - -In addition to saving on physical data center resources, this customer by design would likely see better performance. - -"When you look at the workload as it's running on an x86 system, the math, the application code, the I/O to manage the disk, and whatever else is attached to that system, is all run through the same chip," he explained. "On a Z, there are multiple chip architectures built into the system. There's one specifically just for the application code. If it senses the application needs an I/O or some mathematics, it sends it off to a separate processor to do math or I/O, all dynamically handled by the underlying firmware. Your Linux environment doesn't have to understand that. When it's running on a mainframe, it knows it's running on a mainframe and it will exploit that architecture." - -The operating system knows it's running on a mainframe because when IBM was readying its mainframe for Linux it open sourced something like 75,000 lines of code for Linux distributions to use to make sure their OS's were ready for IBM Z. - -"A lot of times people will hear there's 170 processors on the Z14," Santalucia said. "Well, there's actually another 400 other processors that nobody counts in that count of application chips, because it is taken for granted." - -Mainframes are also resilient when it comes to disaster recovery. Santalucia told the story of an insurance company located in lower Manhattan, within sight of the East River. The company operated a large data center in a basement that among other things housed a mainframe backed up to another mainframe located in Upstate New York. When Hurricane Sandy hit in 2012, the data center flooded, electrocuting two employees and destroying all of the servers, including the mainframe. But the mainframe's workload was restored within 24 hours from the remote backup. - -The x86 machines were all destroyed, and the data was never recovered. But why weren't they also backed up? - -"The reason they didn't do this disaster recovery the same way they did with the mainframe was because it was too expensive to have a mirror of all those distributed servers someplace else," he explained. "With the mainframe, you can have another mainframe as an insurance policy that's lower in price, called Capacity BackUp, and it just sits there idling until something like this happens." - -Mainframes are also evidently tough as nails. Santalucia told another story in which a data center in Japan was struck by an earthquake strong enough to destroy all of its x86 machines. The center's one mainframe fell on its side but continued to work. - -The mainframe also comes with built-in redundancy to guard against situations that would be disastrous with x86 machines. - -"What if a hard disk fails on a node in x86?" the Open Mainframe Project's Mertic asked. "You're taking down a chunk of that cluster potentially. With a mainframe you're not. A mainframe just keeps on kicking like nothing's ever happened." - -Mertic added that a motherboard can be pulled from a running mainframe, and again, "the thing keeps on running like nothing's ever happened." - -So how do you figure out if a mainframe is right for your organization? Simple, says Santalucia. Do the math. - -"The approach should be to look at it from a business, technical, and financial perspective -- not just a financial, total-cost-of-acquisition perspective," he said, pointing out that often, costs associated with software, migration, networking, and people are not considered. The break-even point, he said, comes when at least 20 to 30 servers are being migrated to a mainframe. After that point the mainframe has a financial advantage. - -"You can get a few people running the mainframe and managing hundreds or thousands of virtual servers," he added. "If you tried to do the same thing on other platforms, you'd find that you need significantly more resources to maintain an environment like that. Seven people at ADP handle the 8,000 virtual servers they have, and they need seven only in case somebody gets sick. - -"If you had eight thousand servers on x86, even if they're virtualized, do you think you could get away with seven?" - --------------------------------------------------------------------------------- - -via: http://www.datacenterknowledge.com/hardware/why-mainframes-arent-going-away-any-time-soon - -作者:[Christine Hall][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.datacenterknowledge.com/archives/author/christine-hall -[1]:http://www.datacenterknowledge.com/ibm/mainframe-sales-fuel-growth-ibm -[2]:http://www.datacenterknowledge.com/design/one-click-and-voil-your-entire-data-center-encrypted -[3]:http://www.datacenterknowledge.com/design/ibm-designs-performance-beast-ai diff --git a/sources/talk/20180209 Arch Anywhere Is Dead, Long Live Anarchy Linux.md b/sources/talk/20180209 Arch Anywhere Is Dead, Long Live Anarchy Linux.md deleted file mode 100644 index c3c78e84ad..0000000000 --- a/sources/talk/20180209 Arch Anywhere Is Dead, Long Live Anarchy Linux.md +++ /dev/null @@ -1,127 +0,0 @@ -Arch Anywhere Is Dead, Long Live Anarchy Linux -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_main.jpg?itok=fyBpTjQW) - -Arch Anywhere was a distribution aimed at bringing Arch Linux to the masses. Due to a trademark infringement, Arch Anywhere has been completely rebranded to [Anarchy Linux][1]. And I’m here to say, if you’re looking for a distribution that will enable you to enjoy Arch Linux, a little Anarchy will go a very long way. This distribution is seriously impressive in what it sets out to do and what it achieves. In fact, anyone who previously feared Arch Linux can set those fears aside… because Anarchy Linux makes Arch Linux easy. - -Let’s face it; Arch Linux isn’t for the faint of heart. The installation alone will turn off many a new user (and even some seasoned users). That’s where distributions like Anarchy make for an easy bridge to Arch. With a live ISO that can be tested and then installed, Arch becomes as user-friendly as any other distribution. - -Anarchy Linux goes a little bit further than that, however. Let’s fire it up and see what it does. - -### The installation - -The installation of Anarchy Linux isn’t terribly challenging, but it’s also not quite as simple as for, say, [Ubuntu][2], [Linux Mint][3], or [Elementary OS][4]. Although you can run the installer from within the default graphical desktop environment (Xfce4), it’s still much in the same vein as Arch Linux. In other words, you’re going to have to do a bit of work—all within a text-based installer. - -To start, the very first step of the installer (Figure 1) requires you to update the mirror list, which will likely trip up new users. - -![Updating the mirror][6] - -Figure 1: Updating the mirror list is a necessity for the Anarchy Linux installation. - -[Used with permission][7] - -From the options, select Download & Rank New Mirrors. Tab down to OK and hit Enter on your keyboard. You can then select the nearest mirror (to your location) and be done with it. The next few installation screens are simple (keyboard layout, language, timezone, etc.). The next screen should surprise many an Arch fan. Anarchy Linux includes an auto partition tool. Select Auto Partition Drive (Figure 2), tab down to Ok, and hit Enter on your keyboard. - -![partitioning][9] - -Figure 2: Anarchy makes partitioning easy. - -[Used with permission][7] - -You will then have to select the drive to be used (if you only have one drive this is only a matter of hitting Enter). Once you’ve selected the drive, choose the filesystem type to be used (ext2/3/4, btrfs, jfs, reiserfs, xfs), tab down to OK, and hit Enter. Next you must choose whether you want to create SWAP space. If you select Yes, you’ll then have to define how much SWAP to use. The next window will stop many new users in their tracks. It asks if you want to use GPT (GUID Partition Table). This is different than the traditional MBR (Master Boot Record) partitioning. GPT is a newer standard and works better with UEFI. If you’ll be working with UEFI, go with GPT, otherwise, stick with the old standby, MBR. Finally select to write the changes to the disk, and your installation can continue. - -The next screen that could give new users pause, requires the selection of the desired installation. There are five options: - - * Anarchy-Desktop - - * Anarchy-Desktop-LTS - - * Anarchy-Server - - * Anarchy-Server-LTS - - * Anarchy-Advanced - - - - -If you want long term support, select Anarchy-Desktop-LTS, otherwise click Anarchy-Desktop (the default), and tab down to Ok. Click Enter on your keyboard. After you select the type of installation, you will get to select your desktop. You can select from five options: Budgie, Cinnamon, GNOME, Openbox, and Xfce4. -Once you’ve selected your desktop, give the machine a hostname, set the root password, create a user, and enable sudo for the new user (if applicable). The next section that will raise the eyebrows of new users is the software selection window (Figure 3). You must go through the various sections and select which software packages to install. Don’t worry, if you miss something, you can always installed it later. - - -![software][11] - -Figure 3: Selecting the software you want on your system. - -[Used with permission][7] - -Once you’ve made your software selections, tab to Install (Figure 4), and hit Enter on your keyboard. - -![ready to install][13] - -Figure 4: Everything is ready to install. - -[Used with permission][7] - -Once the installation completes, reboot and enjoy Anarchy. - -### Post install - -I installed two versions of Anarchy—one with Budgie and one with GNOME. Both performed quite well, however you might be surprised to see that the version of GNOME installed is decked out with a dock. In fact, comparing the desktops side-by-side and they do a good job of resembling one another (Figure 5). - -![GNOME and Budgie][15] - -Figure 5: GNOME is on the right, Budgie is on the left. - -[Used with permission][7] - -My guess is that you’ll find all desktop options for Anarchy configured in such a way to offer a similar look and feel. Of course, the second you click on the bottom left “buttons”, you’ll see those similarities immediately disappear (Figure 6). - -![GNOME and Budgie][17] - -Figure 6: The GNOME Dash and the Budgie menu are nothing alike. - -[Used with permission][7] - -Regardless of which desktop you select, you’ll find everything you need to install new applications. Open up your desktop menu of choice and select Packages to search for and install whatever is necessary for you to get your work done. - -### Why use Arch Linux without the “Arch”? - -This is a valid question. The answer is simple, but revealing. Some users may opt for a distribution like [Arch Linux][18] because they want the feeling of “elitism” that comes with using, say, [Gentoo][19], without having to go through that much hassle. With regards to complexity, Arch rests below Gentoo, which means it’s accessible to more users. However, along with that complexity in the platform, comes a certain level of dependability that may not be found in others. So if you’re looking for a Linux distribution with high stability, that’s not quite as challenging as Gentoo or Arch to install, Anarchy might be exactly what you want. In the end, you’ll wind up with an outstanding desktop platform that’s easy to work with (and maintain), based on a very highly regarded distribution of Linux. - -That’s why you might opt for Arch Linux without the Arch. - -Anarchy Linux is one of the finest “user-friendly” takes on Arch Linux I’ve ever had the privilege of using. Without a doubt, if you’re looking for a friendlier version of a rather challenging desktop operating system, you cannot go wrong with Anarchy. - -Learn more about Linux through the free ["Introduction to Linux" ][20]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/2/arch-anywhere-dead-long-live-anarchy-linux - -作者:[Jack Wallen][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://anarchy-linux.org/ -[2]:https://www.ubuntu.com/ -[3]:https://linuxmint.com/ -[4]:https://elementary.io/ -[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_1.jpg?itok=WgHRqFTf (Updating the mirror) -[7]:https://www.linux.com/licenses/category/used-permission -[9]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_2.jpg?itok=D7HkR97t (partitioning) -[10]:/files/images/anarchyinstall3jpg -[11]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_3.jpg?itok=5-9E2u0S (software) -[12]:/files/images/anarchyinstall4jpg -[13]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_4.jpg?itok=fuSZqtZS (ready to install) -[14]:/files/images/anarchyinstall5jpg -[15]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_5.jpg?itok=4y9kiC8I (GNOME and Budgie) -[16]:/files/images/anarchyinstall6jpg -[17]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/anarchy_install_6.jpg?itok=fJ7Lmdci (GNOME and Budgie) -[18]:https://www.archlinux.org/ -[19]:https://www.gentoo.org/ -[20]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md b/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md deleted file mode 100644 index 55618326c6..0000000000 --- a/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md +++ /dev/null @@ -1,149 +0,0 @@ -How writing can change your career for the better, even if you don't identify as a writer -====== -Have you read Marie Kondo's book [The Life-Changing Magic of Tidying Up][1]? Or did you, like me, buy it and read a little bit and then add it to the pile of clutter next to your bed? - -Early in the book, Kondo talks about keeping possessions that "spark joy." In this article, I'll examine ways writing about what we and other people are doing in the open source world can "spark joy," or at least how writing can improve your career in unexpected ways. - -Because I'm a community manager and editor on Opensource.com, you might be thinking, "She just wants us to [write for Opensource.com][2]." And that is true. But everything I will tell you about why you should write is true, even if you never send a story in to Opensource.com. Writing can change your career for the better, even if you don't identify as a writer. Let me explain. - -### How I started writing - -Early in the first decade of my career, I transitioned from a customer service-related role at a tech publishing company into an editing role on Sys Admin Magazine. I was plugging along, happily laying low in my career, and then that all changed when I started writing about open source technologies and communities, and the people in them. But I did _not_ start writing voluntarily. The tl;dr: of it is that my colleagues at Linux New Media eventually talked me into launching our first blog on the [Linux Pro Magazine][3] site. And as it turns out, it was one of the best career decisions I've ever made. I would not be working on Opensource.com today had I not started writing about what other people in open source were doing all those years ago. - -When I first started writing, my goal was to raise awareness of the company I worked for and our publications, while also helping raise the visibility of women in tech. But soon after I started writing, I began seeing unexpected results. - -#### My network started growing - -When I wrote about a person, an organization, or a project, I got their attention. Suddenly the people I wrote about knew who I was. And because I was sharing knowledge—that is to say, I wasn't being a critic—I'd generally become an ally, and in many cases, a friend. I had a platform and an audience, and I was sharing them with other people in open source. - -#### I was learning - -In addition to promoting our website and magazine and growing my network, the research and fact-checking I did when writing articles helped me become more knowledgeable in my field and improve my tech chops. - -#### I started meeting more people IRL - -When I went to conferences, I found that my blog posts helped me meet people. I introduced myself to people I'd written about or learned about during my research, and I met new people to interview. People started knowing who I was because they'd read my articles. Sometimes people were even excited to meet me because I'd highlighted them, their projects, or someone or something they were interested in. I had no idea writing could be so exciting and interesting away from the keyboard. - -#### My conference talks improved - -I started speaking at events about a year after launching my blog. A few years later, I started writing articles based on my talks prior to speaking at events. The process of writing the articles helps me organize my talks and slides, and it was a great way to provide "notes" for conference attendees, while sharing the topic with a larger international audience that wasn't at the event in person. - -### What should you write about? - -Maybe you're interested in writing, but you struggle with what to write about. You should write about two things: what you know, and what you don't know. - -#### Write about what you know - -Writing about what you know can be relatively easy. For example, a script you wrote to help automate part of your daily tasks might be something you don't give any thought to, but it could make for a really exciting article for someone who hates doing that same task every day. That could be a relatively quick, short, and easy article for you to write, and you might not even think about writing it. But it could be a great contribution to the open source community. - -#### Write about what you don't know - -Writing about what you don't know can be much harder and more time consuming, but also much more fulfilling and help your career. I've found that writing about what I don't know helps me learn, because I have to research it and understand it well enough to explain it. - -> "When I write about a technical topic, I usually learn a lot more about it. I want to make sure my article is as good as it can be. So even if I'm writing about something I know well, I'll research the topic a bit more so I can make sure to get everything right." ~Jim Hall, FreeDOS project leader - -For example, I wanted to learn about machine learning, and I thought narrowing down the topic would help me get started. My team mate Jason Baker suggested that I write an article on the [Top 3 machine learning libraries for Python][4], which gave me a focus for research. - -The process of researching that article inspired another article, [3 cool machine learning projects using TensorFlow and the Raspberry Pi][5]. That article was also one of our most popular last year. I'm not an _expert_ on machine learning now, but researching the topic with writing an article in mind allowed me to give myself a crash course in the topic. - -### Why people in tech write - -Now let's look at a few benefits of writing that other people in tech have found. I emailed the Opensource.com writers' list and asked, and here's what writers told me. - -#### Grow your network or your project community - -Xavier Ho wrote for us for the first time last year ("[A programmer's cleaning guide for messy sensor data][6]"). He says: "I've been getting Twitter mentions from all over the world, including Spain, US, Australia, Indonesia, the UK, and other European countries. It shows the article is making some impact... This is the kind of reach I normally don't have. Hope it's really helping someone doing similar work!" - -#### Help people - -Writing about what other people are working on is a great way to help your fellow community members. Antoine Thomas, who wrote "[Linux helped me grow as a musician][7]", says, "I began to use open source years ago, by reading tutorials and documentation. That's why now I share my tips and tricks, experience or knowledge. It helped me to get started, so I feel that it's my turn to help others to get started too." - -#### Give back to the community - -[Jim Hall][8], who started the [FreeDOS project][9], says, "I like to write ... because I like to support the open source community by sharing something neat. I don't have time to be a program maintainer anymore, but I still like to do interesting stuff. So when something cool comes along, I like to write about it and share it." - -#### Highlight your community - -Emilio Velis wrote an article, "[Open hardware groups spread across the globe][10]", about projects in Central and South America. He explains, "I like writing about specific aspects of the open culture that are usually enclosed in my region (Latin America). I feel as if smaller communities and their ideas are hidden from the mainstream, so I think that creating this sense of broadness in participation is what makes some other cultures as valuable." - -#### Gain confidence - -[Don Watkins][11] is one of our regular writers and a [community moderator][12]. He says, "When I first started writing I thought I was an impostor, later I realized that many people feel that way. Writing and contributing to Opensource.com has been therapeutic, too, as it contributed to my self esteem and helped me to overcome feelings of inadequacy. … Writing has given me a renewed sense of purpose and empowered me to help others to write and/or see the valuable contributions that they too can make if they're willing to look at themselves in a different light. Writing has kept me younger and more open to new ideas." - -#### Get feedback - -One of our writers described writing as a feedback loop. He said that he started writing as a way to give back to the community, but what he found was that community responses give back to him. - -Another writer, [Stuart Keroff][13] says, "Writing for Opensource.com about the program I run at school gave me valuable feedback, encouragement, and support that I would not have had otherwise. Thousands upon thousands of people heard about the Asian Penguins because of the articles I wrote for the website." - -#### Exhibit expertise - -Writing can help you show that you've got expertise in a subject, and having writing samples on well-known websites can help you move toward better pay at your current job, get a new role at a different organization, or start bringing in writing income. - -[Jeff Macharyas][14] explains, "There are several ways I've benefitted from writing for Opensource.com. One, is the credibility I can add to my social media sites, resumes, bios, etc., just by saying 'I am a contributing writer to Opensource.com.' … I am hoping that I will be able to line up some freelance writing assignments, using my Opensource.com articles as examples, in the future." - -### Where should you publish your articles? - -That depends. Why are you writing? - -You can always post on your personal blog, but if you don't already have a lot of readers, your article might get lost in the noise online. - -Your project or company blog is a good option—again, you'll have to think about who will find it. How big is your company's reach? Or will you only get the attention of people who already give you their attention? - -Are you trying to reach a new audience? A bigger audience? That's where sites like Opensource.com can help. We attract more than a million page views a month, and more than 700,000 unique visitors. Plus you'll work with editors who will polish and help promote your article. - -We aren't the only site interested in your story. What are your favorite sites to read? They might want to help you share your story, and it's ok to pitch to multiple publications. Just be transparent about whether your article has been shared on other sites when working with editors. Occasionally, editors can even help you modify articles so that you can publish variations on multiple sites. - -#### Do you want to get rich by writing? (Don't count on it.) - -If your goal is to make money by writing, pitch your article to publications that have author budgets. There aren't many of them, the budgets don't tend to be huge, and you will be competing with experienced professional tech journalists who write seven days a week, 365 days a year, with large social media followings and networks. I'm not saying it can't be done—I've done it—but I am saying don't expect it to be easy or lucrative. It's not. (And frankly, I've found that nothing kills my desire to write much like having to write if I want to eat...) - -A couple of people have asked me whether Opensource.com pays for content, or whether I'm asking someone to write "for exposure." Opensource.com does not have an author budget, but I won't tell you to write "for exposure," either. You should write because it meets a need. - -If you already have a platform that meets your needs, and you don't need editing or social media and syndication help: Congratulations! You are privileged. - -### Spark joy! - -Most people don't know they have a story to tell, so I'm here to tell you that you probably do, and my team can help, if you just submit a proposal. - -Most people—myself included—could use help from other people. Sites like Opensource.com offer one way to get editing and social media services at no cost to the writer, which can be hugely valuable to someone starting out in their career, someone who isn't a native English speaker, someone who wants help with their project or organization, and so on. - -If you don't already write, I hope this article helps encourage you to get started. Or, maybe you already write. In that case, I hope this article makes you think about friends, colleagues, or people in your network who have great stories and experiences to share. I'd love to help you help them get started. - -I'll conclude with feedback I got from a recent writer, [Mario Corchero][15], a Senior Software Developer at Bloomberg. He says, "I wrote for Opensource because you told me to :)" (For the record, I "invited" him to write for our [PyCon speaker series][16] last year.) He added, "And I am extremely happy about it—not only did it help me at my workplace by gaining visibility, but I absolutely loved it! The article appeared in multiple email chains about Python and was really well received, so I am now looking to publish the second :)" Then he [wrote for us][17] again. - -I hope you find writing to be as fulfilling as we do. - -You can connect with Opensource.com editors, community moderators, and writers in our Freenode [IRC][18] channel #opensource.com, and you can reach me and the Opensource.com team by email at [open@opensource.com][19]. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/career-changing-magic-writing - -作者:[Rikki Endsley][a] -译者:[译者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/rikki-endsley -[1]:http://tidyingup.com/books/the-life-changing-magic-of-tidying-up-hc -[2]:https://opensource.com/how-submit-article -[3]:http://linuxpromagazine.com/ -[4]:https://opensource.com/article/17/2/3-top-machine-learning-libraries-python -[5]:https://opensource.com/article/17/2/machine-learning-projects-tensorflow-raspberry-pi -[6]:https://opensource.com/article/17/9/messy-sensor-data -[7]:https://opensource.com/life/16/9/my-linux-story-musician -[8]:https://opensource.com/users/jim-hall -[9]:http://www.freedos.org/ -[10]:https://opensource.com/article/17/6/open-hardware-latin-america -[11]:https://opensource.com/users/don-watkins -[12]:https://opensource.com/community-moderator-program -[13]:https://opensource.com/education/15/3/asian-penguins-Linux-middle-school-club -[14]:https://opensource.com/users/jeffmacharyas -[15]:https://opensource.com/article/17/5/understanding-datetime-python-primer -[16]:https://opensource.com/tags/pycon -[17]:https://opensource.com/article/17/9/python-logging -[18]:https://opensource.com/article/16/6/getting-started-irc -[19]:mailto:open@opensource.com diff --git a/sources/talk/20180209 Why an involved user community makes for better software.md b/sources/talk/20180209 Why an involved user community makes for better software.md deleted file mode 100644 index 2b51023e44..0000000000 --- a/sources/talk/20180209 Why an involved user community makes for better software.md +++ /dev/null @@ -1,47 +0,0 @@ -Why an involved user community makes for better software -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_cubestalk.png?itok=Ozw4NhGW) - -Imagine releasing a major new infrastructure service based on open source software only to discover that the product you deployed had evolved so quickly that the documentation for the version you released is no longer available. At Bloomberg, we experienced this problem firsthand in our deployment of OpenStack. In late 2016, we spent six months testing and rolling out [Liberty][1] on our OpenStack environment. By that time, Liberty was about a year old, or two versions behind the latest build. - -As our users started taking advantage of its new functionality, we found ourselves unable to solve a few tricky problems and to answer some detailed questions about its API. When we went looking for Liberty's documentation, it was nowhere to be found on the OpenStack website. Liberty, it turned out, had been labeled "end of life" and was no longer supported by the OpenStack developer community. - -The disappearance wasn't intentional, rather the result of a development community that had not anticipated the real-world needs of users. The documentation was stored in the source branch along with the source code, and, as Liberty was superseded by newer versions, it had been deleted. Worse, in the intervening months, the documentation for the newer versions had been completely restructured, and there was no way to easily rebuild it in a useful form. And believe me, we tried. - -The disappearance wasn't intentional, rather the result of a development community that had not anticipated the real-world needs of users. ]After consulting other users and our vendor, we found that OpenStack's development cadence of two releases per year had created some unintended, yet deeply frustrating, consequences. Older releases that were typically still widely in use were being superseded and effectively killed for the purposes of support. - -Eventually, conversations took place between OpenStack users and developers that resulted in changes. Documentation was moved out of the source branch, and users can now build documentation for whatever version they're using—more or less indefinitely. The problem was solved. (I'm especially indebted to my colleague [Chris Morgan][2], who was knee-deep in this effort and first wrote about it in detail for the [OpenStack Superuser blog][3].) - -Many other enterprise users were in the same boat as Bloomberg—running older versions of OpenStack that are three or four versions behind the latest build. There's a good reason for that: On average it takes a reasonably large enterprise about six months to qualify, test, and deploy a new version of OpenStack. And, from my experience, this is generally true of most open source infrastructure projects. - -For most of the past decade, companies like Bloomberg that adopted open source software relied on distribution vendors to incorporate, test, verify, and support much of it. These vendors provide long-term support (LTS) releases, which enable enterprise users to plan for upgrades on a two- or three-year cycle, knowing they'll still have support for a year or two, even if their deployment schedule slips a bit (as they often do). In the past few years, though, infrastructure software has advanced so rapidly that even the distribution vendors struggle to keep up. And customers of those vendors are yet another step removed, so many are choosing to deploy this type of software without vendor support. - -Losing vendor support also usually means there are no LTS releases; OpenStack, Kubernetes, and Prometheus, and many more, do not yet provide LTS releases of their own. As a result, I'd argue that healthy interaction between the development and user community should be high on the list of considerations for adoption of any open source infrastructure. Do the developers building the software pay attention to the needs—and frustrations—of the people who deploy it and make it useful for their enterprise? - -There is a solid model for how this should happen. We recently joined the [Cloud Native Computing Foundation][4], part of The Linux Foundation. It has a formal [end-user community][5], whose members include organizations just like us: enterprises that are trying to make open source software useful to their internal customers. Corporate members also get a chance to have their voices heard as they vote to select a representative to serve on the CNCF [Technical Oversight Committee][6]. Similarly, in the OpenStack community, Bloomberg is involved in the semi-annual Operators Meetups, where companies who deploy and support OpenStack for their own users get together to discuss their challenges and provide guidance to the OpenStack developer community. - -The past few years have been great for open source infrastructure. If you're working for a large enterprise, the opportunity to deploy open source projects like the ones mentioned above has made your company more productive and more agile. - -As large companies like ours begin to consume more open source software to meet their infrastructure needs, they're going to be looking at a long list of considerations before deciding what to use: license compatibility, out-of-pocket costs, and the health of the development community are just a few examples. As a result of our experiences, we'll add the presence of a vibrant and engaged end-user community to the list. - -Increased reliance on open source infrastructure projects has also highlighted a key problem: People in the development community have little experience deploying the software they work on into production environments or supporting the people who use it to get things done on a daily basis. The fast pace of updates to these projects has created some unexpected problems for the people who deploy and use them. There are numerous examples I can cite where open source projects are updated so frequently that new versions will, usually unintentionally, break backwards compatibility. - -As open source increasingly becomes foundational to the operation of so many enterprises, this cannot be allowed to happen, and members of the user community should assert themselves accordingly and press for the creation of formal representation. In the end, the software can only be better. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/important-conversation - -作者:[Kevin P.Fleming][a] -译者:[译者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/kpfleming -[1]:https://releases.openstack.org/liberty/ -[2]:https://www.linkedin.com/in/mihalis68/ -[3]:http://superuser.openstack.org/articles/openstack-at-bloomberg/ -[4]:https://www.cncf.io/ -[5]:https://www.cncf.io/people/end-user-community/ -[6]:https://www.cncf.io/people/technical-oversight-committee/ diff --git a/sources/talk/20180214 Can anonymity and accountability coexist.md b/sources/talk/20180214 Can anonymity and accountability coexist.md deleted file mode 100644 index 8b15ed169c..0000000000 --- a/sources/talk/20180214 Can anonymity and accountability coexist.md +++ /dev/null @@ -1,79 +0,0 @@ -Can anonymity and accountability coexist? -========================================= - -Anonymity might be a boon to more open, meritocratic organizational cultures. But does it conflict with another important value: accountability? - -![Can anonymity and accountability coexist?](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/GOV_Transparency_B.png?itok=SkP1mUt5 "Can anonymity and accountability coexist?") - -Image by :opensource.com - -### Get the newsletter - -Join the 85,000 open source advocates who receive our giveaway alerts and article roundups. - -Whistleblowing protections, crowdsourcing, anonymous voting processes, and even Glassdoor reviews—anonymous speech may take many forms in organizations. - -As well-established and valued as these anonymous feedback mechanisms may be, anonymous speech becomes a paradoxical idea when one considers how to construct a more open organization. While an inability to discern speaker identity seems non-transparent, an opportunity for anonymity may actually help achieve a _more inclusive and meritocratic_ environment. - -More about open organizations - -* [Download free Open Org books](https://opensource.com/open-organization/resources/book-series?src=too_resource_menu1a) -* [What is an Open Organization?](https://opensource.com/open-organization/resources/open-org-definition?src=too_resource_menu2a) -* [How open is your organization?](https://opensource.com/open-organization/resources/open-org-maturity-model?src=too_resource_menu3a) -* [What is an Open Decision?](https://opensource.com/open-organization/resources/open-decision-framework?src=too_resource_menu4a) -* [The Open Org two years later](https://www.redhat.com/en/about/blog/open-organization-two-years-later-and-going-strong?src=too_resource_menu4b&intcmp=70160000000h1s6AAA) - -But before allowing outlets for anonymous speech to propagate, however, leaders of an organization should carefully reflect on whether an organization's "closed" practices make anonymity the unavoidable alternative to free, non-anonymous expression. Though some assurance of anonymity is necessary in a few sensitive and exceptional scenarios, dependence on anonymous feedback channels within an organization may stunt the normalization of a culture that encourages diversity and community. - -### The benefits of anonymity - -In the case of [_Talley v. California (1960)_](https://supreme.justia.com/cases/federal/us/362/60/case.html), the Supreme Court voided a city ordinance prohibiting the anonymous distribution of handbills, asserting that "there can be no doubt that such an identification requirement would tend to restrict freedom to distribute information and thereby freedom of expression." Our judicial system has legitimized the notion that the protection of anonymity facilitates the expression of otherwise unspoken ideas. A quick scroll through any [subreddit](https://www.reddit.com/reddits/) exemplifies what the Court has codified: anonymity can foster [risk-taking creativity](https://www.reddit.com/r/sixwordstories/) and the [inclusion and support of marginalized voices](https://www.reddit.com/r/MyLittleSupportGroup/). Anonymity empowers individuals by granting them the safety to speak without [detriment to their reputations or, more importantly, their physical selves.](https://www.psychologytoday.com/blog/the-compassion-chronicles/201711/why-dont-victims-sexual-harassment-come-forward-sooner) - -For example, an anonymous suggestion program to garner ideas from members or employees in an organization may strengthen inclusivity and enhance the diversity of suggestions the organization receives. It would also make for a more meritocratic decision-making process, as anonymity would ensure that the quality of the articulated idea, rather than the rank and reputation of the articulator, is what's under evaluation. Allowing members to anonymously vote for anonymously-submitted ideas would help curb the influence of office politics in decisions affecting the organization's growth. - -### The harmful consequences of anonymity - -Yet anonymity and the open value of _accountability_ may come into conflict with one another. For instance, when establishing anonymous programs to drive greater diversity and more meritocratic evaluation of ideas, organizations may need to sacrifice the ability to hold speakers accountable for the opinions they express. - -Reliance on anonymous speech for serious organizational decision-making may also contribute to complacency in an organizational culture that falls short of openness. Outlets for anonymous speech may be as similar to open as crowdsourcing is—or rather, is not. [Like efforts to crowdsource creative ideas](https://opensource.com/business/10/4/why-open-source-way-trumps-crowdsourcing-way), anonymous suggestion programs may create an organizational environment in which diverse perspectives are only valued when an organization's leaders find it convenient to take advantage of members' ideas. - -Anonymity and the open value of accountability may come into conflict with one another. - -A similar concern holds for anonymous whistle-blowing or concern submission. Though anonymity is important for sexual harassment and assault reporting, regularly redirecting member concerns and frustrations to a "complaints box" makes it more difficult for members to hold their organization's leaders accountable for acting on concerns. It may also hinder intra-organizational support networks and advocacy groups from forming around shared concerns, as members would have difficulty identifying others with similar experiences. For example, many working mothers might anonymously submit requests for a lactation room in their workplace, then falsely attribute a lack of action from leaders to a lack of similar concerns from others. - -### An anonymity checklist - -Organizations in which anonymous speech is the primary mode of communication, like subreddits, have generated innovative works and thought-provoking discourse. These anonymous networks call attention to the potential for anonymity to help organizations pursue open values of diversity and meritocracy. Organizations in which anonymous speech is _not_ the main form of communication should acknowledge the strengths of anonymous speech, but carefully consider whether anonymity is the wisest means to the goal of sustainable openness. - -Leaders may find reflecting on the following questions useful prior to establishing outlets for anonymous feedback within their organizations: - -1\. _Availability of additional communication mechanisms_: Rather than investing time and resources into establishing a new, anonymous channel for communication, can the culture or structure of existing avenues of communication be reconfigured to achieve the same goal? This question echoes the open source affinity toward realigning, rather than reinventing, the wheel. - -2\. _Failure of other communication avenues:_ How and why is the organization ill-equipped to handle the sensitive issue/situation at hand through conventional (i.e. non-anonymous) means of communication? - -Careful deliberation on these questions may help prevent outlets for anonymous speech from leading to a dangerous sense of complacency. - -3\. _Consequences of anonymity:_ If implemented, could the anonymous mechanism stifle the normalization of face-to-face discourse about issues important to the organization's growth? If so, how can leaders ensure that members consider the anonymous communication channel a "last resort," without undermining the legitimacy of the anonymous system? - -4\. _Designing the anonymous communication channel:_ How can accountability be promoted in anonymous communication without the ability to determine the identity of speakers? - -5\. _Long-term considerations_: Is the anonymous feedback mechanism sustainable, or a temporary solution to a larger organizational issue? If the latter, is [launching a campaign](https://opensource.com/open-organization/16/6/8-steps-more-open-communications) to address overarching problems with the organization's communication culture feasible? - -These five points build off of one another to help leaders recognize the tradeoffs involved in legitimizing anonymity within their organization. Careful deliberation on these questions may help prevent outlets for anonymous speech from leading to a dangerous sense of complacency with a non-inclusive organizational structure. - -About the author ----------------- - -[![](https://opensource.com/sites/default/files/styles/profile_pictures/public/osdc_default_avatar_1.png?itok=mmbfqFXm)](https://opensource.com/users/susiechoi) - -Susie Choi - Susie is an undergraduate student studying computer science at Duke University. She is interested in the implications of technological innovation and open source principles for issues relating to education and socioeconomic inequality. - -[More about me](https://opensource.com/users/susiechoi) - -* * * - -via: [https://opensource.com/open-organization/18/1/balancing-accountability-and-anonymity](https://opensource.com/open-organization/18/1/balancing-accountability-and-anonymity) - -作者: [Susie Choi](https://opensource.com/users/susiechoi) 选题者: [@lujun9972](https://github.com/lujun9972) 译者: [译者ID](https://github.com/译者ID) 校对: [校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 \ No newline at end of file diff --git a/sources/talk/20180216 Q4OS Makes Linux Easy for Everyone.md b/sources/talk/20180216 Q4OS Makes Linux Easy for Everyone.md deleted file mode 100644 index a868ed28d5..0000000000 --- a/sources/talk/20180216 Q4OS Makes Linux Easy for Everyone.md +++ /dev/null @@ -1,140 +0,0 @@ -Q4OS Makes Linux Easy for Everyone -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os-main.png?itok=WDatcV-a) - -Modern Linux distributions tend to target a variety of users. Some claim to offer a flavor of the open source platform that anyone can use. And, I’ve seen some such claims succeed with aplomb, while others fall flat. [Q4OS][1] is one of those odd distributions that doesn’t bother to make such a claim but pulls off the feat anyway. - -So, who is the primary market for Q4OS? According to its website, the distribution is a: - -“fast and powerful operating system based on the latest technologies while offering highly productive desktop environment. We focus on security, reliability, long-term stability and conservative integration of verified new features. System is distinguished by speed and very low hardware requirements, runs great on brand new machines as well as legacy computers. It is also very applicable for virtualization and cloud computing.” - -What’s very interesting here is that the Q4OS developers offer commercial support for the desktop. Said support can cover the likes of system customization (including core level API programming) as well as user interface modifications. - -Once you understand this (and have installed Q4OS), the target audience becomes quite obvious: Business users looking for a Windows XP/7 replacement. But that should not prevent home users from giving Q4OS at try. It’s a Linux distribution that has a few unique tools that come together to make a solid desktop distribution. - -Let’s take a look at Q4OS and see if it’s a version of Linux that might work for you. - -### What Q4OS all about - -Q4OS that does an admirable job of being the open source equivalent of Windows XP/7. Out of the box, it pulls this off with the help of the [Trinity Desktop][2] (a fork of KDE). With a few tricks up its sleeve, Q4OS turns the Trinity Desktop into a remarkably similar desktop (Figure 1). - -![default desktop][4] - -Figure 1: The Q4OS default desktop. - -[Used with permission][5] - -When you fire up the desktop, you will be greeted by a Welcome screen that makes it very easy for new users to start setting up their desktop with just a few clicks. From this window, you can: - - * Run the Desktop Profiler (which allows you to select which desktop environment to use as well as between a full-featured desktop, a basic desktop, or a minimal desktop—Figure 2). - - * Install applications (which opens the Synaptic Package Manager). - - * Install proprietary codecs (which installs all the necessary media codecs for playing audio and video). - - * Turn on Desktop effects (if you want more eye candy, turn this on). - - * Switch to Kickoff start menu (switches from the default start menu to the newer kickoff menu). - - * Set Autologin (allows you to set login such that it won’t require your password upon boot). - - - - -![Desktop Profiler][7] - -Figure 2: The Desktop Profiler allows you to further customize your desktop experience. - -[Used with permission][5] - -If you want to install a different desktop environment, open up the Desktop Profiler and then click the Desktop environments drop-down, in the upper left corner of the window. A new window will appear, where you can select your desktop of choice from the drop-down (Figure 3). Once back at the main Profiler Window, select which type of desktop profile you want, and then click Install. - -![Desktop Profiler][9] - -Figure 3: Installing a different desktop is quite simple from within the Desktop Profiler. - -[Used with permission][5] - -Note that installing a different desktop will not wipe the default desktop. Instead, it will allow you to select between the two desktops (at the login screen). - -### Installed software - -After selecting full-featured desktop, from the Desktop Profiler, I found the following user applications ready to go: - - * LibreOffice 5.2.7.2 - - * VLC 2.2.7 - - * Google Chrome 64.0.3282 - - * Thunderbird 52.6.0 (Includes Lightning addon) - - * Synaptic 0.84.2 - - * Konqueror 14.0.5 - - * Firefox 52.6.0 - - * Shotwell 0.24.5 - - - - -Obviously some of those applications are well out of date. Since this distribution is based on Debian, we can run and update/upgrade with the commands: -``` -sudo apt update - -sudo apt upgrade - -``` - -However, after running both commands, it seems everything is up to date. This particular release (2.4) is an LTS release (supported until 2022). Because of this, expect software to be a bit behind. If you want to test out the bleeding edge version (based on Debian “Buster”), you can download the testing image [here][10]. - -### Security oddity - -There is one rather disturbing “feature” found in Q4OS. In the developer’s quest to make the distribution closely resemble Windows, they’ve made it such that installing software (from the command line) doesn’t require a password! You read that correctly. If you open the Synaptic package manager, you’re asked for a password. However (and this is a big however), open up a terminal window and issue a command like sudo apt-get install gimp. At this point, the software will install… without requiring the user to type a sudo password. - -Did you cringe at that? You should. - -I get it, the developers want to ease away the burden of Linux and make a platform the masses could easily adapt to. They’ve done a splendid job of doing just that. However, in the process of doing so, they’ve bypassed a crucial means of security. Is having as near an XP/7 clone as you can find on Linux worth that lack of security? I would say that if it enables more people to use Linux, then yes. But the fact that they’ve required a password for Synaptic (the GUI tool most Windows users would default to for software installation) and not for the command-line tool makes no sense. On top of that, bypassing passwords for the apt and dpkg commands could make for a significant security issue. - -Fear not, there is a fix. For those that prefer to require passwords for the command line installation of software, you can open up the file /etc/sudoers.d/30_q4os_apt and comment out the following three lines: -``` -%sudo ALL = NOPASSWD: /usr/bin/apt-get * - -%sudo ALL = NOPASSWD: /usr/bin/apt-key * - -%sudo ALL = NOPASSWD: /usr/bin/dpkg * - -``` - -Once commented out, save and close the file, and reboot the system. At this point, users will now be prompted for a password, should they run the apt-get, apt-key, or dpkg commands. - -### A worthy contender - -Setting aside the security curiosity, Q4OS is one of the best attempts at recreating Windows XP/7 I’ve come across in a while. If you have users who fear change, and you want to migrate them away from Windows, this distribution might be exactly what you need. I would, however, highly recommend you re-enable passwords for the apt-get, apt-key, and dpkg commands… just to be on the safe side. - -In any case, the addition of the Desktop Profiler, and the ability to easily install alternative desktops, makes Q4OS a distribution that just about anyone could use. - -Learn more about Linux through the free ["Introduction to Linux" ][11]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/2/q4os-makes-linux-easy-everyone - -作者:[JACK WALLEN][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://q4os.org -[2]:https://www.trinitydesktop.org/ -[4]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os_1.jpg?itok=dalJk9Xf (default desktop) -[5]:/licenses/category/used-permission -[7]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os_2.jpg?itok=GlouIm73 (Desktop Profiler) -[9]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/q4os_3.jpg?itok=riSTP_1z (Desktop Profiler) -[10]:https://q4os.org/downloads2.html -[11]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/talk/20180220 4 considerations when naming software development projects.md b/sources/talk/20180220 4 considerations when naming software development projects.md deleted file mode 100644 index 1e1add0b68..0000000000 --- a/sources/talk/20180220 4 considerations when naming software development projects.md +++ /dev/null @@ -1,91 +0,0 @@ -4 considerations when naming software development projects -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/hello-name-sticker-badge-tag.png?itok=fAgbMgBb) - -Working on a new open source project, you're focused on the code—getting that great new idea released so you can share it with the world. And you'll want to attract new contributors, so you need a terrific **name** for your project. - -We've all read guides for creating names, but how do you go about choosing the right one? Keeping that cool science fiction reference you're using internally might feel fun, but it won't mean much to new users you're trying to attract. A better approach is to choose a name that's memorable to new users and developers searching for your project. - -Names set expectations. Your project's name should showcase its functionality in the ecosystem and explain to users what your story is. In the crowded open source software world, it's important not to get entangled with other projects out there. Taking a little extra time now, before sending out that big announcement, will pay off later. - -Here are four factors to keep in mind when choosing a name for your project. - -### What does your project's code do? - -Start with your project: What does it do? You know the code intimately—but can you explain what it does to a new developer? Can you explain it to a CTO or non-developer at another company? What kinds of problems does your project solve for users? - -Your project's name needs to reflect what it does in a way that makes sense to newcomers who want to use or contribute to your project. That means considering the ecosystem for your technology and understanding if there are any naming styles or conventions used for similar kinds of projects. Imagine that you're trying to evaluate someone else's project: Would the name be appealing to you? - -Any distribution channels you push to are also part of the ecosystem. If your code will be in a Linux distribution, [npm][1], [CPAN][2], [Maven][3], or in a Ruby Gem, you need to review any naming standards or common practices for that package manager. Review any similar existing names in that distribution channel, and get a feel for naming styles of other programs there. - -### Who are the users and developers you want to attract? - -The hardest aspect of choosing a new name is putting yourself in the shoes of new users. You built this project; you already know how powerful it is, so while your cool name may sound great, it might not draw in new people. You need a name that is interesting to someone new, and that tells the world what problems your project solves. - -Great names depend on what kind of users you want to attract. Are you building an [Eclipse][4] plugin or npm module that's focused on developers? Or an analytics toolkit that brings visualizations to the average user? Understanding your user base and the kinds of open source contributors you want to attract is critical. - -Great names depend on what kind of users you want to attract. - -Take the time to think this through. Who does your project most appeal to, and how can it help them do their job? What kinds of problems does your code solve for end users? Understanding the target user helps you focus on what users need, and what kind of names or brands they respond to. - -Take the time to think this through. Who does your project most appeal to, and how can it help them do their job? What kinds of problems does your code solve for end users? Understanding the target user helps you focus on what users need, and what kind of names or brands they respond to. - -When you're open source, this equation changes a bit—your target is not just users; it's also developers who will want to contribute code back to your project. You're probably a developer, too: What kinds of names and brands excite you, and what images would entice you to try out someone else's new project? - -Once you have a better feel of what users and potential contributors expect, use that knowledge to refine your names. Remember, you need to step outside your project and think about how the name would appeal to someone who doesn't know how amazing your code is—yet. Once someone gets to your website, does the name synchronize with what your product does? If so, move to the next step. - -### Who else is using similar names for software? - -Now that you've tried on a user's shoes to evaluate potential names, what's next? Figuring out if anyone else is already using a similar name. It sometimes feels like all the best names are taken—but if you search carefully, you'll find that's not true. - -The first step is to do a few web searches using your proposed name. Search for the name, plus "software", "open source", and a few keywords for the functionality that your code provides. Look through several pages of results for each search to see what's out there in the software world. - -The first step is to do a few web searches using your proposed name. - -Unless you're using a completely made-up word, you'll likely get a lot of hits. The trick is understanding which search results might be a problem. Again, put on the shoes of a new user to your project. If you were searching for this great new product and saw the other search results along with your project's homepage, would you confuse them? Are the other search results even software products? If your product solves a similar problem to other search results, that's a problem: Users may gravitate to an existing product instead of a new one. - -Unless you're using a completely made-up word, you'll likely get a lot of hits. The trick is understanding which search results might be a problem. Again, put on the shoes of a new user to your project. If you were searching for this great new product and saw the other search results along with your project's homepage, would you confuse them? Are the other search results even software products? If your product solves a similar problem to other search results, that's a problem: Users may gravitate to an existing product instead of a new one. - -Similar non-software product names are rarely an issue unless they are famous trademarks—like Nike or Red Bull, for example—where the companies behind them won't look kindly on anyone using a similar name. Using the same name as a less famous non-software product might be OK, depending on how big your project gets. - -### How big do you plan to grow your project? - -Are you building a new node module or command-line utility, but not planning a career around it? Is your new project a million-dollar business idea, and you're thinking startup? Or is it something in between? - -If your project is a basic developer utility—something useful that developers will integrate into their workflow—then you have enough data to choose a name. Think through the ecosystem and how a new user would see your potential names, and pick one. You don't need perfection, just a name you're happy with that seems right for your project. - -If you're planning to build a business around your project, use these tips to develop a shortlist of names, but do more vetting before announcing the winner. Use for a business or major project requires some level of registered trademark search, which is usually performed by a law firm. - -### Common pitfalls - -Finally, when choosing a name, avoid these common pitfalls: - - * Using an esoteric acronym. If new users don't understand the name, they'll have a hard time finding you. - - * Using current pop-culture references. If you want your project's appeal to last, pick a name that will last. - - * Failing to consider non-English speakers. Does the name have a specific meaning in another language that might be confusing? - - * Using off-color jokes or potentially unsavory references. Even if it seems funny to developers, it may fall flat for newcomers and turn away contributors. - - - - -Good luck—and remember to take the time to step out of your shoes and consider how a newcomer to your project will think of the name. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/choosing-project-names-four-key-considerations - -作者:[Shane Curcuru][a] -译者:[译者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/shane-curcuru -[1]:https://www.npmjs.com/ -[2]:https://www.cpan.org/ -[3]:https://maven.apache.org/ -[4]:https://www.eclipse.org/ diff --git a/sources/talk/20180221 3 warning flags of DevOps metrics.md b/sources/talk/20180221 3 warning flags of DevOps metrics.md deleted file mode 100644 index a103a2bbca..0000000000 --- a/sources/talk/20180221 3 warning flags of DevOps metrics.md +++ /dev/null @@ -1,42 +0,0 @@ -3 warning flags of DevOps metrics -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D) - -Metrics. Measurements. Data. Monitoring. Alerting. These are all big topics for DevOps and for cloud-native infrastructure and application development more broadly. In fact, acm Queue, a magazine published by the Association of Computing Machinery, recently devoted an [entire issue][1] to the topic. - -I've argued before that we conflate a lot of things under the "metrics" term, from key performance indicators to critical failure alerts to data that may be vaguely useful someday for something or other. But that's a topic for another day. What I want to discuss here is how metrics affect behavior. - -In 2008, Daniel Ariely published [Predictably Irrational][2] , one of a number of books written around that time that introduced behavioral psychology and behavioral economics to the general public. One memorable quote from that book is the following: "Human beings adjust behavior based on the metrics they're held against. Anything you measure will impel a person to optimize his score on that metric. What you measure is what you'll get. Period." - -This shouldn't be surprising. It's a finding that's been repeatedly confirmed by research. It should also be familiar to just about anyone with business experience. It's certainly not news to anyone in sales management, for example. Base sales reps' (or their managers'!) bonuses solely on revenue, and they'll discount whatever it takes to maximize revenue even if it puts margin in the toilet. Conversely, want the sales force to push a new product line—which will probably take extra effort—but skip the [spiffs][3]? Probably not happening. - -And lest you think I'm unfairly picking on sales, this behavior is pervasive, all the way up to the CEO, as Ariely describes in [a 2010 Harvard Business Review article][4]. "CEOs care about stock value because that's how we measure them. If we want to change what they care about, we should change what we measure," writes Ariely. - -Think developers and operations folks are immune from such behaviors? Think again. Let's consider some problematic measurements. They're not all bad or wrong but, if you rely too much on them, warning flags should go up. - -### Three warning signs for DevOps metrics - -First, there are the quantity metrics. Lines of code or bugs fixed are perhaps self-evidently absurd. But there are also the deployments per week or per month that are so widely quoted to illustrate DevOps velocity relative to more traditional development and deployment practices. Speed is good. It's one of the reasons you're probably doing DevOps—but don't reward people on it excessively relative to quality and other measures. - -Second, it's obvious that you want to reward individuals who do their work quickly and well. Yes. But. Whether it's your local pro sports team or some project team you've been on, you can probably name someone who was really a talent, but was just so toxic and such a distraction for everyone else that they were a net negative for the team. Moral: Don't provide incentives that solely encourage individual behaviors. You may also want to put in place programs, such as peer rewards, that explicitly value collaboration. [As Red Hat's Jen Krieger told me][5] in a podcast last year: "Having those automated pots of awards, or some sort of system that's tracked for that, can only help teams feel a little more cooperative with one another as in, 'Hey, we're all working together to get something done.'" - -The third red flag area is incentives that don't actually incent because neither the individual nor the team has a meaningful ability to influence the outcome. It's often a good thing when DevOps metrics connect to business goals and outcomes. For example, customer ticket volume relates to perceived shortcomings in applications and infrastructure. And it's also a reasonable proxy for overall customer satisfaction, which certainly should be of interest to the executive suite. The best reward systems to drive DevOps behaviors should be tied to specific individual and team actions as opposed to just company success generally. - -You've probably noticed a common theme. That theme is balance. Velocity is good but so is quality. Individual achievement is good but not when it damages the effectiveness of the team. The overall success of the business is certainly important, but the best reward systems also tie back to actions and behaviors within development and operations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/three-warning-flags-devops-metrics - -作者:[Gordon Haff][a] -译者:[译者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/ghaff -[1]:https://queue.acm.org/issuedetail.cfm?issue=3178368 -[2]:https://en.wikipedia.org/wiki/Predictably_Irrational -[3]:https://en.wikipedia.org/wiki/Spiff -[4]:https://hbr.org/2010/06/column-you-are-what-you-measure -[5]:http://bitmason.blogspot.com/2015/09/podcast-making-devops-succeed-with-red.html diff --git a/sources/talk/20180222 3 reasons to say -no- in DevOps.md b/sources/talk/20180222 3 reasons to say -no- in DevOps.md deleted file mode 100644 index 5f27fbaf47..0000000000 --- a/sources/talk/20180222 3 reasons to say -no- in DevOps.md +++ /dev/null @@ -1,105 +0,0 @@ -3 reasons to say 'no' in DevOps -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_DesirePath.png?itok=N_zLVWlK) - -DevOps, it has often been pointed out, is a culture that emphasizes mutual respect, cooperation, continual improvement, and aligning responsibility with authority. - -Instead of saying no, it may be helpful to take a hint from improv comedy and say, "Yes, and..." or "Yes, but...". This opens the request from the binary nature of "yes" and "no" toward having a nuanced discussion around priority, capacity, and responsibility. - -However, sometimes you have no choice but to give a hard "no." These should be rare and exceptional, but they will occur. - -### Protecting yourself - -Both Agile and DevOps have been touted as ways to improve value to the customer and business, ultimately leading to greater productivity. While reasonable people can understand that the improvements will take time to yield, and the improvements will result in higher quality of work being done, and a better quality of life for those performing it, I think we can all agree that not everyone is reasonable. The less understanding that a person has of the particulars of a given task, the more likely they are to expect that it is a combination of "simple" and "easy." - -"You told me that [Agile/DevOps] is supposed to be all about us getting more productivity. Since we're doing [Agile/DevOps] now, you can take care of my need, right?" - -Like "Agile," some people have tried to use "DevOps" as a stick to coerce people to do more work than they can handle. Whether the person confronting you with this question is asking in earnest or is being manipulative doesn't really matter. - -The biggest areas of concern for me have been **capacity** , **firefighting/maintenance** , **level of quality** , and **" future me."** Many of these ultimately tie back to capacity, but they relate to a long-term effort in different respects. - -#### Capacity - -Capacity is simple: You know what your workload is, and how much flex occurs due to the unexpected. Exceeding your capacity will not only cause undue stress, but it could decrease the quality of your work and can injure your reputation with regards to making commitments. - -There are several avenues of discussion that can happen from here. The simplest is "Your request is reasonable, but I don't have the capacity to work on it." This seldom ends the conversation, and a discussion will often run up the flagpole to clarify priorities or reassign work. - -#### Firefighting/maintenance - -It's possible that the thing that you're being asked for won't take long to do, but it will require maintenance that you'll be expected to perform, including keeping it alive and fulfilling requests for it on behalf of others. - -An example in my mind is the Jenkins server that you're asked to stand up for someone else, but somehow end up being the sole owner and caretaker of. Even if you're careful to scope your level of involvement early on, you might be saddled with responsibility that you did not agree to. Should the service become unavailable, for example, you might be the one who is called. You might be called on to help triage a build that is failing. This is additional firefighting and maintenance work that you did not sign up for and now must fend off. - -This needs to be addressed as soon and publicly as possible. I'm not saying that (again, for example) standing up a Jenkins instance is a "no," but rather a ["Yes, but"][1]—where all parties understand that they take on the long-term care, feeding, and use of the product. Make sure to include all your bosses in this conversation so they can have your back. - -#### Level of quality - -There may be times when you are presented with requirements that include a timeframe that is...problematic. Perhaps you could get a "minimum (cough) viable (cough) product" out in that time. But it wouldn't be resilient or in any way ready for production. It might impact your time and productivity. It could end up hurting your reputation. - -The resulting conversation can get into the weeds, with lots of horse-trading about time and features. Another approach is to ask "What is driving this deadline? Where did that timeframe come from?" Discussing the bigger picture might lead to a better option, or that the timeline doesn't depend on the original date. - -#### Future me - -Ultimately, we are trying to protect "future you." These are lessons learned from the many times that "past me" has knowingly left "current me" to clean up. Sometimes we joke that "that's a problem for 'future me,'" but don't forget that 'future you' will just be 'you' eventually. I've cursed "past me" as a jerk many times. Do your best to keep other people from making "past you" be a jerk to "future you." - -I recognize that I have a significant amount of privilege in this area, but if you are told that you cannot say "no" on behalf of your own welfare, you should consider whether you are respected enough to maintain your autonomy. - -### Protecting the user experience - -Everyone should be an advocate for the user. Regardless of whether that user is right next to you, someone down the hall, or someone you have never met and likely never will, you must care for the customer. - -Behavior that is actively hostile to the user—whether it's a poor user experience or something more insidious like quietly violating reasonable expectations of privacy—deserves a "no." A common example of this would be automatically including people into a service or feature, forcing them to explicitly opt-out. - -If a "no" is not welcome, it bears considering, or explicitly asking, what the company's relationship with its customers is, who the company thinks of as it's customers, and what it thinks of them. - -When bringing up your objections, be clear about what they are. Additionally, remember that your coworkers are people too, and make it clear that you are not attacking their character; you simply find the idea disagreeable. - -### Legal, ethical, and moral grounds - -There might be situations that don't feel right. A simple test is to ask: "If this were to become public, or come up in a lawsuit deposition, would it be a scandal?" - -#### Ethics and morals - -If you are asked to lie, that should be a hard no. - -Remember if you will the Volkswagen Emissions Scandal of 2017? The emissions systems software was written such that it recognized that the vehicle was operated in a manner consistent with an emissions test, and would run more efficiently than under normal driving conditions. - -I don't know what you do in your job, or what your office is like, but I have a hard time imagining the Individual Contributor software engineer coming up with that as a solution on their own. In fact, I imagine a comment along the lines of "the engine engineers can't make their product pass the tests, so I need to hack the performance so that it will!" - -When the Volkswagen scandal came public, Volkswagen officials blamed the engineers. I find it unlikely that it came from the mind and IDE of an individual software engineer. Rather, it's more likely indicates significant systemic problems within the company culture. - -If you are asked to lie, get the request in writing, citing that the circumstances are suspect. If you are so privileged, decide whether you may decline the request on the basis that it is fundamentally dishonest and hostile to the customer, and would break the public's trust. - -#### Legal - -I am not a lawyer. If your work should involve legal matters, including requests from law enforcement, involve your company's legal counsel or speak with a private lawyer. - -With that said, if you are asked to provide information for law enforcement, I believe that you are within your rights to see the documentation that justifies the request. There should be a signed warrant. You should be provided with a copy of it, or make a copy of it yourself. - -When in doubt, begin recording and request legal counsel. - -It has been well documented that especially in the early years of the U.S. Patriot Act, law enforcement placed so many requests of telecoms that they became standard work, and the paperwork started slipping. While tedious and potentially stressful, make sure that the legal requirements for disclosure are met. - -If for no other reason, we would not want the good work of law enforcement to be put at risk because key evidence was improperly acquired, making it inadmissible. - -### Wrapping up - -You are going to be your single biggest advocate. There may be times when you are asked to compromise for the greater good. However, you should feel that your dignity is preserved, your autonomy is respected, and that your morals remain intact. - -If you don't feel that this is the case, get it on record, doing your best to communicate it calmly and clearly. - -Nobody likes being declined, but if you don't have the ability to say no, there may be a bigger problem than your environment not being DevOps. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/3-reasons-say-no-devops - -作者:[H. "Waldo" Grunenwal][a] -译者:[译者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/gwaldo -[1]:http://gwaldo.blogspot.com/2015/12/fear-and-loathing-in-systems.html diff --git a/sources/talk/20180223 Plasma Mobile Could Give Life to a Mobile Linux Experience.md b/sources/talk/20180223 Plasma Mobile Could Give Life to a Mobile Linux Experience.md deleted file mode 100644 index 583714836e..0000000000 --- a/sources/talk/20180223 Plasma Mobile Could Give Life to a Mobile Linux Experience.md +++ /dev/null @@ -1,123 +0,0 @@ -Plasma Mobile Could Give Life to a Mobile Linux Experience -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/plasma-mobile_0.png?itok=uUIQFRcm) - -In the past few years, it’s become clear that, outside of powering Android, Linux on mobile devices has been a resounding failure. Canonical came close, even releasing devices running Ubuntu Touch. Unfortunately, the idea of [Scopes][1]was doomed before it touched down on its first piece of hardware and subsequently died a silent death. - -The next best hope for mobile Linux comes in the form of the [Samsung DeX][2] program. With DeX, users will be able to install an app (Linux On Galaxy—not available yet) on their Samsung devices, which would in turn allow them to run a full-blown Linux distribution. The caveat here is that you’ll be running both Android and Linux at the same time—which is not exactly an efficient use of resources. On top of that, most Linux distributions aren’t designed to run on such small form factors. The good news for DeX is that, when you run Linux on Galaxy and dock your Samsung device to DeX, that Linux OS will be running on your connected monitor—so form factor issues need not apply. - -Outside of those two options, a pure Linux on mobile experience doesn’t exist. Or does it? - -You may have heard of the [Purism Librem 5][3]. It’s a crowdfunded device that promises to finally bring a pure Linux experience to the mobile landscape. This device will be powered by a i.MX8 SoC chip, so it should run most any Linux operating system. - -Out of the box, the device will run an encrypted version of [PureOS][4]. However, last year Purism and KDE joined together to create a mobile version of the KDE desktop that could run on the Librem 5. Recently [ISOs were made available for a beta version of Plasma Mobile][5] and, judging from first glance, they’re onto something that makes perfect sense for a mobile Linux platform. I’ve booted up a live instance of Plasma Mobile to kick the tires a bit. - -What I saw seriously impressed me. Let’s take a look. - -### Testing platform - -Before you download the ISO and attempt to fire it up as a VirtualBox VM, you should know that it won’t work well. Because Plasma Mobile uses Wayland (and VirtualBox has yet to play well with that particular X replacement), you’ll find VirtualBox VM a less-than-ideal platform for the beta release. Also know that the Calamares installer doesn’t function well either. In fact, I have yet to get the OS installed on a non-mobile device. And since I don’t own a supported mobile device, I’ve had to run it as a live session on either a laptop or an [Antsle][6] antlet VM every time. - -### What makes Plasma Mobile special? - -This could be easily summed up by saying, Plasma Mobile got it all right. Instead of Canonical re-inventing a perfectly functioning wheel, the developers of KDE simply re-tooled the interface such that a full-functioning Linux distribution (complete with all the apps you’ve grown to love and depend upon) could work on a smaller platform. And they did a spectacular job. Even better, they’ve created an interface that any user of a mobile device could instantly feel familiar with. - -What you have with the Plasma Mobile interface (Figure 1) are the elements common to most Android home screens: - - * Quick Launchers - - * Notification Shade - - * App Drawer - - * Overview button (so you can go back to a previously used app, still running in memory) - - * Home button - - - - -![KDE mobile][8] - -Figure 1: The Plasma Mobile desktop interface. - -[Used with permission][9] - -Because KDE went this route with the UX, it means there’s zero learning curve. And because this is an actual Linux platform, it takes that user-friendly mobile interface and overlays it onto a system that allows for easy installation and usage of apps like: - - * GIMP - - * LibreOffice - - * Audacity - - * Clementine - - * Dropbox - - * And so much more - - - - -Unfortunately, without being able to install Plasma Mobile, you cannot really kick the tires too much, as the live user doesn’t have permission to install applications. However, once Plasma Mobile is fully installed, the Discover software center will allow you to install a host of applications (Figure 2). - - -![Discover center][11] - -Figure 2: The Discover software center on Plasma Mobile. - -[Used with permission][9] - -Swipe up (or scroll down—depending on what hardware you’re using) to reveal the app drawer, where you can launch all of your installed applications (Figure 3). - -![KDE mobile][13] - -Figure 3: The Plasma Mobile app drawer ready to launch applications. - -[Used with permission][9] - -Open up a terminal window and you can take care of standard Linux admin tasks, such as using SSH to log into a remote server. Using apt, you can install all of the developer tools you need to make Plasma Mobile a powerful development platform. - -We’re talking serious mobile power—either from a phone or a tablet. - -### A ways to go - -Clearly Plasma Mobile is still way too early in development for it to be of any use to the average user. And because most virtual machine technology doesn’t play well with Wayland, you’re likely to get too frustrated with the current ISO image to thoroughly try it out. However, even without being able to fully install the platform (or get full usage out of it), it’s obvious KDE and Purism are going to have the ideal platform that will put Linux into the hands of mobile users. - -If you want to test the waters of Plasma Mobile on an actual mobile device, a handy list of supported hardware can be found [here][14] (for PostmarketOS) or [here][15] (for Halium). If you happen to be lucky enough to have a device that also includes Wi-Fi support, you’ll find you get more out of testing the environment. - -If you do have a supported device, you’ll need to use either [PostmarketOS][16] (a touch-optimized, pre-configured Alpine Linux that can be installed on smartphones and other mobile devices) or [Halium][15] (an application that creates an minimal Android layer which allows a new interface to interact with the Android kernel). Using Halium further limits the number of supported devices, as it has only been built for select hardware. However, if you’re willing, you can build your own Halium images (documentation for this process is found [here][17]). If you want to give PostmarketOS a go, [here are the necessary build instructions][18]. - -Suffice it to say, Plasma Mobile isn’t nearly ready for mass market. If you’re a Linux enthusiast and want to give it a go, let either PostmarketOS or Halium help you get the operating system up and running on your device. Otherwise, your best bet is to wait it out and hope Purism and KDE succeed in bringing this oustanding mobile take on Linux to the masses. - -Learn more about Linux through the free ["Introduction to Linux" ][19]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/2/plasma-mobile-could-give-life-mobile-linux-experience - -作者:[JACK WALLEN][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://launchpad.net/unity-scopes -[2]:http://www.samsung.com/global/galaxy/apps/samsung-dex/ -[3]:https://puri.sm/shop/librem-5/ -[4]:https://www.pureos.net/ -[5]:http://blog.bshah.in/2018/01/26/trying-out-plasma-mobile/ -[6]:https://antsle.com/ -[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kdemobile_1.jpg?itok=EK3_vFVP (KDE mobile) -[9]:https://www.linux.com/licenses/category/used-permission -[11]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kdemobile_2.jpg?itok=CiUQ-MnB (Discover center) -[13]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kdemobile_3.jpg?itok=i6V8fgK8 (KDE mobile) -[14]:http://blog.bshah.in/2018/02/02/trying-out-plasma-mobile-part-two/ -[15]:https://github.com/halium/projectmanagement/issues?q=is%3Aissue+is%3Aopen+label%3APorts -[16]:https://postmarketos.org/ -[17]:http://docs.halium.org/en/latest/ -[18]:https://wiki.postmarketos.org/wiki/Installation_guide -[19]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/talk/20180223 Why culture is the most important issue in a DevOps transformation.md b/sources/talk/20180223 Why culture is the most important issue in a DevOps transformation.md deleted file mode 100644 index 8fe1b6f273..0000000000 --- a/sources/talk/20180223 Why culture is the most important issue in a DevOps transformation.md +++ /dev/null @@ -1,91 +0,0 @@ -Why culture is the most important issue in a DevOps transformation -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_community2.png?itok=1blC7-NY) - -You've been appointed the DevOps champion in your organisation: congratulations. So, what's the most important issue that you need to address? - -It's the technology—tools and the toolchain—right? Everybody knows that unless you get the right tools for the job, you're never going to make things work. You need integration with your existing stack (though whether you go with tight or loose integration will be an interesting question), a support plan (vendor, third party, or internal), and a bug-tracking system to go with your source code management system. And that's just the start. - -No! Don't be ridiculous: It's clearly the process that's most important. If the team doesn't agree on how stand-ups are run, who participates, the frequency and length of the meetings, and how many people are required for a quorum, then you'll never be able to institute a consistent, repeatable working pattern. - -In fact, although both the technology and the process are important, there's a third component that is equally important, but typically even harder to get right: culture. Yup, it's that touch-feely thing we techies tend to struggle with.1 - -### Culture - -I was visiting a midsized government institution a few months ago (not in the UK, as it happens), and we arrived a little early to meet the CEO and CTO. We were ushered into the CEO's office and waited for a while as the two of them finished participating in the daily stand-up. They apologised for being a minute or two late, but far from being offended, I was impressed. Here was an organisation where the culture of participation was clearly infused all the way up to the top. - -Not that culture can be imposed from the top—nor can you rely on it percolating up from the bottom3—but these two C-level execs were not only modelling the behaviour they expected from the rest of their team, but also seemed, from the brief discussion we had about the process afterwards, to be truly invested in it. If you can get management to buy into the process—and be seen buying in—you are at least likely to have problems with other groups finding plausible excuses to keep their distance and get away with it. - -So let's assume management believes you should give DevOps a go. Where do you start? - -Developers may well be your easiest target group. They are often keen to try new things and find ways to move things along faster, so they are often the group that can be expected to adopt new technologies and methodologies. DevOps arguably has been driven mainly by the development community. - -But you shouldn't assume all developers will be keen to embrace this change. For some, the way things have always been done—your Rick Parfitts of dev, if you will7—is fine. Finding ways to help them work efficiently in the new world is part of your job, not just theirs. If you have superstar developers who aren't happy with change, you risk alienating and losing them if you try to force them into your brave new world. What's worse, if they dig their heels in, you risk the adoption of your DevSecOps vision being compromised when they explain to their managers that things aren't going to change if it makes their lives more difficult and reduces their productivity. - -Maybe you're not going to be able to move all the systems and people to DevOps immediately. Maybe you're going to need to choose which apps start with and who will be your first DevOps champions. Maybe it's time to move slowly. - -### Not maybe: definitely - -No—I lied. You're definitely going to need to move slowly. Trying to change everything at once is a recipe for disaster. - -This goes for all elements of the change—which people to choose, which technologies to choose, which applications to choose, which user base to choose, which use cases to choose—bar one. For those elements, if you try to move everything in one go, you will fail. You'll fail for a number of reasons. You'll fail for reasons I can't imagine and, more importantly, for reasons you can't imagine. But some of the reasons will include: - - * People—most people—don't like change. - * Technologies don't like change (you can't just switch and expect everything to still work). - * Applications don't like change (things worked before, or at least failed in known ways). You want to change everything in one go? Well, they'll all fail in new and exciting9 ways. - * Users don't like change. - * Use cases don't like change. - - - -### The one exception - -You noticed I wrote "bar one" when discussing which elements you shouldn't choose to change all in one go? Well done. - -What's that exception? It's the initial team. When you choose your initial application to change and you're thinking about choosing the team to make that change, select the members carefully and select a complete set. This is important. If you choose just developers, just test folks, just security folks, just ops folks, or just management—if you leave out one functional group from your list—you won't have proved anything at all. Well, you might have proved to a small section of your community that it kind of works, but you'll have missed out on a trick. And that trick is: If you choose keen people from across your functional groups, it's much harder to fail. - -Say your first attempt goes brilliantly. How are you going to convince other people to replicate your success and adopt DevOps? Well, the company newsletter, of course. And that will convince how many people, exactly? Yes, that number.12 If, on the other hand, you have team members from across the functional parts or the organisation, when you succeed, they'll tell their colleagues and you'll get more buy-in next time. - -If it fails, if you've chosen your team wisely—if they're all enthusiastic and know that "fail often, fail fast" is good—they'll be ready to go again. - -Therefore, you need to choose enthusiasts from across your functional groups. They can work on the technologies and the process, and once that's working, it's the people who will create that cultural change. You can just sit back and enjoy. Until the next crisis, of course. - -1\. OK, you're right. It should be "with which we techies tend to struggle."2 - -2\. You thought I was going to qualify that bit about techies struggling with touchy-feely stuff, didn't you? Read it again: I put "tend to." That's the best you're getting. - -3\. Is percolating a bottom-up process? I don't drink coffee,4 so I wouldn't know. - -4\. Do people even use percolators to make coffee anymore? Feel free to let me know in the comments. I may pretend interest if you're lucky. - -5\. For U.S. readers (and some other countries, maybe?), please substitute "check" for "tick" here.6 - -6\. For U.S. techie readers, feel free to perform `s/tick/check/;`. - -7\. This is a Status Quo8 reference for which I'm extremely sorry. - -8\. For millennial readers, please consult your favourite online reference engine or just roll your eyes and move on. - -9\. For people who say, "but I love excitement," try being on call at 2 a.m. on a Sunday at the end of the quarter when your chief financial officer calls you up to ask why all of last month's sales figures have been corrupted with the letters "DEADBEEF."10 - -10\. For people not in the know, this is a string often used by techies as test data because a) it's non-numerical; b) it's numerical (in hexadecimal); c) it's easy to search for in debug files; and d) it's funny.11 - -11\. Though see.9 - -12\. It's a low number, is all I'm saying. - -This article originally appeared on [Alice, Eve, and Bob – a security blog][1] and is republished with permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/most-important-issue-devops-transformation - -作者:[Mike Bursell][a] -译者:[译者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 -[1]:https://aliceevebob.com/2018/02/06/moving-to-devops-whats-most-important/ diff --git a/sources/talk/20180301 How to hire the right DevOps talent.md b/sources/talk/20180301 How to hire the right DevOps talent.md deleted file mode 100644 index bcf9bb3d20..0000000000 --- a/sources/talk/20180301 How to hire the right DevOps talent.md +++ /dev/null @@ -1,48 +0,0 @@ -How to hire the right DevOps talent -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) - -DevOps culture is quickly gaining ground, and demand for top-notch DevOps talent is greater than ever at companies all over the world. With the [annual base salary for a junior DevOps engineer][1] now topping $100,000, IT professionals are hurrying to [make the transition into DevOps.][2] - -But how do you choose the right candidate to fill your DevOps role? - -### Overview - -Most teams are looking for candidates with a background in operations and infrastructure, software engineering, or development. This is in conjunction with skills that relate to configuration management, continuous integration, and deployment (CI/CD), as well as cloud infrastructure. Knowledge of container orchestration is also in high demand. - -In a perfect world, the two backgrounds would meet somewhere in the middle to form Dev and Ops, but in most cases, candidates lean toward one side or the other. Yet they must possess the skills necessary to understand the needs of their counterparts to work effectively as a team to achieve continuous delivery and deployment. Since every company is different, there is no single right or wrong since so much depends on a company’s tech stack and infrastructure, as well as the goals and the skills of other team members. So how do you focus your search? - -### Decide on the background - -Begin by assessing the strength of your current team. Do you have rock-star software engineers but lack infrastructure knowledge? Focus on closing the skill gaps. Just because you have the budget to hire a DevOps engineer doesn’t mean you should spend weeks, or even months, trying to find the best software engineer who also happens to use Kubernetes and Docker because they are currently the trend. Instead, look for someone who will provide the most value in your environment, and see how things go from there. - -### There is no “Ctrl + F” solution - -Instead of concentrating on specific tools, concentrate on a candidate's understanding of DevOps and CI/CD-related processes. You'll be better off with someone who understands methodologies over tools. It is more important to ensure that candidates comprehend the concept of CI/CD than to ask if they prefer Jenkins, Bamboo, or TeamCity. Don’t get too caught up in the exact toolchain—rather, focus on problem-solving skills and the ability to increase efficiency, save time, and automate manual processes. You don't want to miss out on the right candidate just because the word “Puppet” was not on their resume. - -### Check your ego - -As mentioned above, DevOps is a rapidly growing field, and DevOps engineers are in hot demand. That means candidates have great buying power. You may have an amazing company or product, but hiring top talent is no longer as simple as putting up a “Help Wanted” sign and waiting for top-quality applicants to rush in. I'm not suggesting that maintaining a reputation a great place to work is unimportant, but in today's environment, you need to make an effort to sell your position. Flaws or glitches in the hiring process, such as abruptly canceling interviews or not offering feedback after interviews, can lead to negative reviews spreading across the industry. Remember, it takes just a couple of minutes to leave a negative review on Glassdoor. - -### Contractor or permanent employee? - -Most recruiters and hiring managers immediately start searching for a full-time employee, even though they may have other options. If you’re looking to design, build, and implement a new DevOps environment, why not hire a senior person who has done this in the past? Consider hiring a senior contractor, along with a junior full-time hire. That way, you can tap the knowledge and experience of the contractor by having them work with the junior employee. Contractors can be expensive, but they bring invaluable knowledge—especially if the work can be done within a short timeframe. - -### Cultivate from within - -With so many companies competing for talent, it is difficult to find the right DevOps engineer. Not only will you need to pay top dollar to hire this person, but you must also consider that the search can take several months. However, since few companies are lucky enough to find the ideal DevOps engineer, consider searching for a candidate internally. You might be surprised at the talent you can cultivate from within your own organization. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-hire-right-des-talentvop - -作者:[Stanislav Ivaschenko][a] -译者:[译者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/ilyadudkin -[1]:https://www.glassdoor.com/Salaries/junior-devops-engineer-salary-SRCH_KO0,22.htm -[2]:https://squadex.com/insights/system-administrator-making-leap-devops/ diff --git a/sources/talk/20180302 Beyond metrics- How to operate as team on today-s open source project.md b/sources/talk/20180302 Beyond metrics- How to operate as team on today-s open source project.md deleted file mode 100644 index fb5454bbe4..0000000000 --- a/sources/talk/20180302 Beyond metrics- How to operate as team on today-s open source project.md +++ /dev/null @@ -1,53 +0,0 @@ -Beyond metrics: How to operate as team on today's open source project -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/diversity-women-meeting-team.png?itok=BdDKxT1w) - -How do we traditionally think about community health and vibrancy? - -We might quickly zero in on metrics related primarily to code contributions: How many companies are contributing? How many individuals? How many lines of code? Collectively, these speak to both the level of development activity and the breadth of the contributor base. The former speaks to whether the project continues to be enhanced and expanded; the latter to whether it has attracted a diverse group of developers or is controlled primarily by a single organization. - -The [Linux Kernel Development Report][1] tracks these kinds of statistics and, unsurprisingly, it appears extremely healthy on all counts. - -However, while development cadence and code contributions are still clearly important, other aspects of the open source communities are also coming to the forefront. This is in part because, increasingly, open source is about more than a development model. It’s also about making it easier for users and other interested parties to interact in ways that go beyond being passive recipients of code. Of course, there have long been user groups. But open source streamlines the involvement of users, just as it does software development. - -This was the topic of my discussion with Diane Mueller, the director of community development for OpenShift. - -When OpenShift became a container platform based in part on Kubernetes in version 3, Mueller saw a need to broaden the community beyond the core code contributors. In part, this was because OpenShift was increasingly touching a broad range of open source projects and organizations such those associated with the [Open Container Initiative (OCI)][2] and the [Cloud Native Computing Foundation (CNCF)][3]. In addition to users, cloud service providers who were offering managed services also wanted ways to get involved in the project. - -“What we tried to do was open up our minds about what the community constituted,” Mueller explained, adding, “We called it the [Commons][4] because Red Hat's near Boston, and I'm from that area. Boston Common is a shared resource, the grass where you bring your cows to graze, and you have your farmer's hipster market or whatever it is today that they do on Boston Common.” - -This new model, she said, was really “a new ecosystem that incorporated all of those different parties and different perspectives. We used a lot of virtual tools, a lot of new tools like Slack. We stepped up beyond the mailing list. We do weekly briefings. We went very virtual because, one, I don't scale. The Evangelist and Dev Advocate team didn't scale. We need to be able to get all that word out there, all this new information out there, so we went very virtual. We worked with a lot of people to create online learning stuff, a lot of really good tooling, and we had a lot of community help and support in doing that.” - -![diane mueller open shift][6] - -Diane Mueller, director of community development at Open Shift, discusses the role of strong user communities in open source software development. (Credit: Gordon Haff, CC BY-SA 4.0) - -However, one interesting aspect of the Commons model is that it isn’t just virtual. We see the same pattern elsewhere in many successful open source communities, such as the Linux kernel. Lots of day-to-day activities happen on mailings lists, IRC, and other collaboration tools. But this doesn’t eliminate the benefits of face-to-face time that allows for both richer and informal discussions and exchanges. - -This interview with Mueller took place in London the day after the [OpenShift Commons Gathering][7]. Gatherings are full-day events, held a number of times a year, which are typically attended by a few hundred people. Much of the focus is on users and user stories. In fact, Mueller notes, “Here in London, one of the Commons members, Secnix, was really the major reason we actually hosted the gathering here. Justin Cook did an amazing job organizing the venue and helping us pull this whole thing together in less than 50 days. A lot of the community gatherings and things are driven by the Commons members.” - -Mueller wants to focus on users more and more. “The OpenShift Commons gathering at [Red Hat] Summit will be almost entirely case studies,” she noted. “Users talking about what's in their stack. What lessons did they learn? What are the best practices? Sharing those ideas that they've done just like we did here in London.” - -Although the Commons model grew out of some specific OpenShift needs at the time it was created, Mueller believes it’s an approach that can be applied more broadly. “I think if you abstract what we've done, you can apply it to any existing open source community,” she said. “The foundations still, in some ways, play a nice role in giving you some structure around governance, and helping incubate stuff, and helping create standards. I really love what OCI is doing to create standards around containers. There's still a role for that in some ways. I think the lesson that we can learn from the experience and we can apply to other projects is to open up the community so that it includes feedback mechanisms and gives the podium away.” - -The evolution of the community model though approaches like the OpenShift Commons mirror the healthy evolution of open source more broadly. Certainly, some users have been involved in the development of open source software for a long time. What’s striking today is how widespread and pervasive direct user participation has become. Sure, open source remains central to much of modern software development. But it’s also becoming increasingly central to how users learn from each other and work together with their partners and developers. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-communities-are-evolving - -作者:[Gordon Haff][a] -译者:[译者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/ghaff -[1]:https://www.linuxfoundation.org/2017-linux-kernel-report-landing-page/ -[2]:https://www.opencontainers.org/ -[3]:https://www.cncf.io/ -[4]:https://commons.openshift.org/ -[5]:/file/388586 -[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/39369010275_7df2c3c260_z.jpg?itok=gIhnBl6F (diane mueller open shift) -[7]:https://www.meetup.com/London-OpenShift-User-Group/events/246498196/ diff --git a/sources/talk/20180303 4 meetup ideas- Make your data open.md b/sources/talk/20180303 4 meetup ideas- Make your data open.md deleted file mode 100644 index a431b8376a..0000000000 --- a/sources/talk/20180303 4 meetup ideas- Make your data open.md +++ /dev/null @@ -1,75 +0,0 @@ -4 meetup ideas: Make your data open -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_team_community_group.png?itok=Nc_lTsUK) - -[Open Data Day][1] (ODD) is an annual, worldwide celebration of open data and an opportunity to show the importance of open data in improving our communities. - -Not many individuals and organizations know about the meaningfulness of open data or why they might want to liberate their data from the restrictions of copyright, patents, and more. They also don't know how to make their data open—that is, publicly available for anyone to use, share, or republish with modifications. - -This year ODD falls on Saturday, March 3, and there are [events planned][2] in every continent except Antarctica. While it might be too late to organize an event for this year, it's never too early to plan for next year. Also, since open data is important every day of the year, there's no reason to wait until ODD 2019 to host an event in your community. - -There are many ways to build local awareness of open data. Here are four ideas to help plan an excellent open data event any time of year. - -### 1. Organize an entry-level event - -You can host an educational event at a local library, college, or another public venue about how open data can be used and why it matters for all of us. If possible, invite a [local speaker][3] or have someone present remotely. You could also have a roundtable discussion with several knowledgeable people in your community. - -Consider offering resources such as the [Open Data Handbook][4], which not only provides a guide to the philosophy and rationale behind adopting open data, but also offers case studies, use cases, how-to guides, and other material to support making data open. - -### 2. Organize an advanced-level event - -For a deeper experience, organize a hands-on training event for open data newbies. Ideas for good topics include [training teachers on open science][5], [creating audiovisual expressions from open data][6], and using [open government data][7] in meaningful ways. - -The options are endless. To choose a topic, think about what is locally relevant, identify issues that open data might be able to address, and find people who can do the training. - -### 3. Organize a hackathon - -Open data hackathons can be a great way to bring open data advocates, developers, and enthusiasts together under one roof. Hackathons are more than just training sessions, though; the idea is to build prototypes or solve real-life challenges that are tied to open data. In a hackathon, people in various groups can contribute to the entire assembly line in multiple ways, such as identifying issues by working collaboratively through [Etherpad][8] or creating focus groups. - -Once the hackathon is over, make sure to upload all the useful data that is produced to the internet with an open license. - -### 4. Release or relicense data as open - -Open data is about making meaningful data publicly available under open licenses while protecting any data that might put people's private information at risk. (Learn [how to protect private data][9].) Try to find existing, interesting, and useful data that is privately owned by individuals or organizations and negotiate with them to relicense or release the data online under any of the [recommended open data licenses][10]. The widely popular [Creative Commons licenses][11] (particularly the CC0 license and the 4.0 licenses) are quite compatible with relicensing public data. (See this FAQ from Creative Commons for more information on [openly licensing data][12].) - -Open data can be published on multiple platforms—your website, [GitHub][13], [GitLab][14], [DataHub.io][15], or anywhere else that supports open standards. - -### Tips for event success - -No matter what type of event you decide to do, here are some general planning tips to improve your chances of success. - - * Find a venue that's accessible to the people you want to reach, such as a library, a school, or a community center. - * Create a curriculum that will engage the participants. - * Invite your target audience—make sure to distribute information through social media, community events calendars, Meetup, and the like. - - - -Have you attended or hosted a successful open data event? If so, please share your ideas in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/celebrate-open-data-day - -作者:[Subhashish Panigraphi][a] -译者:[译者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/psubhashish -[1]:http://www.opendataday.org/ -[2]:http://opendataday.org/#map -[3]:https://openspeakers.org/ -[4]:http://opendatahandbook.org/ -[5]:https://docs.google.com/forms/d/1BRsyzlbn8KEMP8OkvjyttGgIKuTSgETZW9NHRtCbT1s/viewform?edit_requested=true -[6]:http://dattack.lv/en/ -[7]:https://www.eventbrite.co.nz/e/open-data-open-potential-event-friday-2-march-2018-tickets-42733708673 -[8]:http://etherpad.org/ -[9]:https://ssd.eff.org/en/module/keeping-your-data-safe -[10]:https://opendatacommons.org/licenses/ -[11]:https://creativecommons.org/share-your-work/licensing-types-examples/ -[12]:https://wiki.creativecommons.org/wiki/Data#Frequently_asked_questions_about_data_and_CC_licenses -[13]:https://github.com/MartinBriza/MediaWriter -[14]:https://about.gitlab.com/ -[15]:https://datahub.io/ diff --git a/sources/talk/20180314 How to apply systems thinking in DevOps.md b/sources/talk/20180314 How to apply systems thinking in DevOps.md deleted file mode 100644 index c35eb041bd..0000000000 --- a/sources/talk/20180314 How to apply systems thinking in DevOps.md +++ /dev/null @@ -1,89 +0,0 @@ -How to apply systems thinking in DevOps -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_kid_education.png?itok=3lRp6gFa) -For most organizations, adopting DevOps requires a mindset shift. Unless you understand the core of [DevOps][1], you might think it's hype or just another buzzword—or worse, you might believe you have already adopted DevOps because you are using the right tools. - -Let’s dig deeper into what DevOps means, and explore how to apply systems thinking in your organization. - -### What is systems thinking? - -Systems thinking is a holistic approach to problem-solving. It's the opposite of analytical thinking, which separates a problem from the "bigger picture" to better understand it. Instead, systems thinking studies all the elements of a problem, along with the interactions between these elements. - -Most people are not used to thinking this way. Since childhood, most of us were taught math, science, and every other subject separately, by different teachers. This approach to learning follows us throughout our lives, from school to university to the workplace. When we first join an organization, we typically work in only one department. - -Unfortunately, the world is not that simple. Complexity, unpredictability, and sometimes chaos are unavoidable and require a broader way of thinking. Systems thinking helps us understand the systems we are part of, which in turn enables us to manage them rather than be controlled by them. - -According to systems thinking, everything is a system: your body, your family, your neighborhood, your city, your company, and even the communities you belong to. These systems evolve organically; they are alive and fluid. The better you understand a system's behavior, the better you can manage and leverage it. You become their change agent and are accountable for them. - -### Systems thinking and DevOps - -All systems include properties that DevOps addresses through its practices and tools. Awareness of these properties helps us properly adapt to DevOps. Let's look at the properties of a system and how DevOps relates to each one. - -### How systems work - -The figure below represents a system. To reach a goal, the system requires input, which is processed and generates output. Feedback is essential for moving the system toward the goal. Without a purpose, the system dies. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/system.png?itok=UlqAf39I) - -If an organization is a system, its departments are subsystems. The flow of work moves through each department, starting with identifying a market need (the first input on the left) and moving toward releasing a solution that meets that need (the last output on the right). The output that each department generates serves as required input for the next department in the chain. - -The more specialized teams an organization has, the more handoffs happen between departments. The process of generating value to clients is more likely to create bottlenecks and thus it takes longer to deliver value. Also, when work is passed between teams, the gap between the goal and what has been done widens. - -DevOps aims to optimize the flow of work throughout the organization to deliver value to clients faster—in other words, DevOps reduces time to market. This is done in part by maximizing automation, but mainly by targeting the organization's goals. This empowers prioritization and reduces duplicated work and other inefficiencies that happen during the delivery process. - -### System deterioration - -All systems are affected by entropy. Nothing can prevent system degradation; that's irreversible. The tendency to decline shows the failure nature of systems. Moreover, systems are subject to threats of all types, and failure is a matter of time. - -To mitigate entropy, systems require constant maintenance and improvements. The effects of entropy can be delayed only when new actions are taken or input is changed. - -This pattern of deterioration and its opposite force, survival, can be observed in living organisms, social relationships, and other systems as well as in organizations. In fact, if an organization is not evolving, entropy is guaranteed to be increasing. - -DevOps attempts to break the entropy process within an organization by fostering continuous learning and improvement. With DevOps, the organization becomes fault-tolerant because it recognizes the inevitability of failure. DevOps enables a blameless culture that offers the opportunity to learn from failure. The [postmortem][2] is an example of a DevOps practice used by organizations that embrace inherent failure. - -The idea of intentionally embracing failure may sound counterintuitive, but that's exactly what happens in techniques like [Chaos Monkey][3]: Failure is intentionally introduced to improve availability and reliability in the system. DevOps suggests that putting some pressure into the system in a controlled way is not a bad thing. Like a muscle that gets stronger with exercise, the system benefits from the challenge. - -### System complexity - -The figure below shows how complex the systems can be. In most cases, one effect can have multiple causes, and one cause can generate multiple effects. The more elements and interactions a system has, the more complex the system. - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/system-complexity.png?itok=GYZS00Lm) - -In this scenario, we can't immediately identify the reason for a particular event. Likewise, we can't predict with 100% certainty what will happen if a specific action is taken. We are constantly making assumptions and dealing with hypotheses. - -System complexity can be explained using the scientific method. In a recent study, for example, mice that were fed excess salt showed suppressed cerebral blood flow. This same experiment would have had different results if, say, the mice were fed sugar and salt. One variable can radically change results in complex systems. - -DevOps handles complexity by encouraging experimentation—for example, using the scientific method—and reducing feedback cycles. Smaller changes inserted into the system can be tested and validated more quickly. With a "[fail-fast][4]" approach, organizations can pivot quickly and achieve resiliency. Reacting rapidly to changes makes organizations more adaptable. - -DevOps also aims to minimize guesswork and maximize understanding by making the process of delivering value more tangible. By measuring processes, revealing flaws and advantages, and monitoring as much as possible, DevOps helps organizations discover the changes they need to make. - -### System limitations - -All systems have constraints that limit their performance; a system's overall capacity is delimited by its restrictions. Most of us have learned from experience that systems operating too long at full capacity can crash, and most systems work better when they function with some slack. Ignoring limitations puts systems at risk. For example, when we are under too much stress for a long time, we get sick. Similarly, overused vehicle engines can be damaged. - -This principle also applies to organizations. Unfortunately, organizations can't put everything into a system at once. Although this limitation may sometimes lead to frustration, the quality of work usually improves when input is reduced. - -Consider what happened when the speed limit on the main roads in São Paulo, Brazil was reduced from 90 km/h to 70 km/h. Studies showed that the number of accidents decreased by 38.5% and the average speed increased by 8.7%. In other words, the entire road system improved and more vehicles arrived safely at their destinations. - -For organizations, DevOps suggests global rather than local improvements. It doesn't matter if some improvement is put after a constraint because there's no effect on the system at all. One constraint that DevOps addresses, for instance, is dependency on specialized teams. DevOps brings to organizations a more collaborative culture, knowledge sharing, and cross-functional teams. - -### Conclusion - -Before adopting DevOps, understand what is involved and how you want to apply it to your organization. Systems thinking will help you accomplish that while also opening your mind to new possibilities. DevOps may be seen as a popular trend today, but in 10 or 20 years, it will be status quo. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/how-apply-systems-thinking-devops - -作者:[Gustavo Muniz do Carmo][a] -译者:[译者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/gustavomcarmo -[1]:https://opensource.com/tags/devops -[2]:https://landing.google.com/sre/book/chapters/postmortem-culture.html -[3]:https://medium.com/netflix-techblog/the-netflix-simian-army-16e57fbab116 -[4]:https://en.wikipedia.org/wiki/Fail-fast diff --git a/sources/talk/20180315 6 ways a thriving community will help your project succeed.md b/sources/talk/20180315 6 ways a thriving community will help your project succeed.md deleted file mode 100644 index cf15b7f06f..0000000000 --- a/sources/talk/20180315 6 ways a thriving community will help your project succeed.md +++ /dev/null @@ -1,111 +0,0 @@ -6 ways a thriving community will help your project succeed -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_community_lead.jpg?itok=F9KKLI7x) -NethServer is an open source product that my company, [Nethesis][1], launched just a few years ago. [The product][2] wouldn't be [what it is today][3] without the vibrant community that surrounds and supports it. - -In my previous article, I [discussed what organizations should expect to give][4] if they want to experience the benefits of thriving communities. In this article, I'll describe what organizations should expect to receive in return for their investments in the passionate people that make up their communities. - -Let's review six benefits. - -### 1\. Innovation - -"Open innovation" occurs when a company sharing information also listens to the feedback and suggestions from outside the company. As a company, we don't just look at the crowd for ideas. We innovate in, with, and through communities. - -You may know that "[the best way to have a good idea is to have a lot of ideas][5]." You can't always expect to have the right idea on your own, so having different point of views on your product is essential. How many truly disruptive ideas can a small company (like Nethesis) create? We're all young, caucasian, and European—while in our community, we can pick up a set of inspirations from a variety of people, with different genders, backgrounds, skills, and ethnicities. - -So the ability to invite the entire world to continuously improve the product is now no longer a dream; it's happening before our eyes. Your community could be the idea factory for innovation. With the community, you can really leverage the power of the collective. - -No matter who you are, most of the smartest people work for someone else. And community is the way to reach those smart people and work with them. - -### 2\. Research - -A community can be your strongest source of valuable product research. - -First, it can help you avoid "ivory tower development." [As Stack Exchange co-founder Jeff Atwood has said][6], creating an environment where developers have no idea who the users are is dangerous. Isolated developers, who have worked for years in their high towers, often encounter bad results because they don't have any clue about how users actually use their software. Developing in an Ivory tower keeps you away from your users and can only lead to bad decisions. A community brings developers back to reality and helps them stay grounded. Gone are the days of developers working in isolation with limited resources. In this day and age, thanks to the advent of open source communities research department is opening up to the entire world. - -No matter who you are, most of the smartest people work for someone else. And community is the way to reach those smart people and work with them. - -Second, a community can be an obvious source of product feedback—always necessary as you're researching potential paths forward. If someone gives you feedback, it means that person cares about you. It's a big gift. The community is a good place to acquire such invaluable feedback. Receiving early feedback is super important, because it reduces the cost of developing something that doesn't work in your target market. You can safely fail early, fail fast, and fail often. - -And third, communities help you generate comparisons with other projects. You can't know all the features, pros, and cons of your competitors' offerings. [The community, however, can.][7] Ask your community. - -### 3\. Perspective - -Communities enable companies to look at themselves and their products [from the outside][8], letting them catch strengths and weaknesses, and mostly realize who their products' audiences really are. - -Let me offer an example. When we launched the NethServer, we chose a catchy tagline for it. We were all convinced the following sentence was perfect: - -> [NethServer][9] is an operating system for Linux enthusiasts, designed for small offices and medium enterprises. - -Two years have passed since then. And we've learned that sentence was an epic fail. - -We failed to realize who our audience was. Now we know: NethServer is not just for Linux enthusiasts; actually, Windows users are the majority. It's not just for small offices and medium enterprises; actually, several home users install NethServer for personal use. Our community helps us to fully understand our product and look at it from our users' eyes. - -### 4\. Development - -In open source communities especially, communities can be a welcome source of product development. - -They can, first of all, provide testing and bug reporting. In fact, if I ask my developers about the most important community benefit, they'd answer "testing and bug reporting." Definitely. But because your code is freely available to the whole world, practically anyone with a good working knowledge of it (even hobbyists and other companies) has the opportunity to play with it, tweak it, and constantly improve it (even develop additional modules, as in our case). People can do more than just report bugs; they can fix those bugs, too, if they have the time and knowledge. - -But the community doesn't just create code. It can also generate resources like [how-to guides,][10] FAQs, support documents, and case studies. How much would it cost to fully translate your product in seven different languages? At NethServer, we got that for free—thanks to our community members. - -### 5\. Marketing - -Communities can help your company go global. Our small Italian company, for example, wasn't prepared for a global market. The community got us prepared. For example, we needed to study and improve our English so we could read and write correctly or speak in public without looking foolish for an audience. The community gently forced us to organize [our first NethServer Conference][11], too—only in English. - -A strong community can also help your organization attain the holy grail of marketers everywhere: word of mouth marketing (or what Seth Godin calls "[tribal marketing][12]"). - -Communities ensure that your company's messaging travels not only from company to tribe but also "sideways," from tribe member to potential tribe member. The community will become your street team, spreading word of your organization and its projects to anyone who will listen. - -In addition, communities help organizations satisfy one of the most fundamental members needs: the desire to belong, to be involved in something bigger than themselves, and to change the world together. - -Never forget that working with communities is always a matter of giving and taking—striking a delicate balance between the company and the community. - -### 6\. Loyalty - -Attracting new users costs a business five times as much as keeping an existing one. So loyalty can have a huge impact on your bottom line. Quite simply, community helps us build brand loyalty. It's much more difficult to leave a group of people you're connected to than a faceless product or company. In a community, you're building connections with people, which is way more powerful than features or money (trust me!). - -### Conclusion - -Never forget that working with communities is always a matter of giving and taking—striking a delicate balance between the company and the community. - -And I wouldn't be honest with you if I didn't admit that the approach has some drawbacks. Doing everything in the open means moderating, evaluating, and processing of all the data you're receiving. Supporting your members and leading the discussions definitely takes time and resources. But, if you look at what a community enables, you'll see that all this is totally worth the effort. - -As my friend and mentor [David Spinks keeps saying over and over again][13], "Companies fail their communities when when they treat community as a tactic instead of making it a core part of their business philosophy." And [as I've said][4]: Communities aren't simply extensions of your marketing teams; "community" isn't an efficient short-term strategy. When community is a core part of your business philosophy, it can do so much more than give you short-term returns. - -At Nethesis we experience that every single day. As a small company, we could never have achieved the results we have without our community. Never. - -Community can completely set your business apart from every other company in the field. It can redefine markets. It can inspire millions of people, give them a sense of belonging, and make them feel an incredible bond with your company. - -And it can make you a whole lot of money. - -Community-driven companies will always win. Remember that. - -[Subscribe to our weekly newsletter][14] to learn more about open organizations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/3/why-build-community-3 - -作者:[Alessio Fattorini][a] -译者:[译者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/alefattorini -[1]:http://www.nethesis.it/ -[2]:https://www.nethserver.org/ -[3]:https://distrowatch.com/table.php?distribution=nethserver -[4]:https://opensource.com/open-organization/18/2/why-build-community-2 -[5]:https://www.goodreads.com/author/quotes/52938.Linus_Pauling -[6]:https://blog.codinghorror.com/ivory-tower-development/ -[7]:https://community.nethserver.org/tags/comparison -[8]:https://community.nethserver.org/t/improve-our-communication/2569 -[9]:http://www.nethserver.org/ -[10]:https://community.nethserver.org/c/howto -[11]:https://community.nethserver.org/t/nethserver-conference-in-italy-sept-29-30-2017/6404 -[12]:https://www.ted.com/talks/seth_godin_on_the_tribes_we_lead -[13]:http://cmxhub.com/article/community-business-philosophy-tactic/ -[14]:https://opensource.com/open-organization/resources/newsletter diff --git a/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md b/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md deleted file mode 100644 index 6ae7cbea2c..0000000000 --- a/sources/talk/20180315 Lessons Learned from Growing an Open Source Project Too Fast.md +++ /dev/null @@ -1,40 +0,0 @@ -Lessons Learned from Growing an Open Source Project Too Fast -====== -![open source project][1] - -Are you managing an open source project or considering launching one? If so, it may come as a surprise that one of the challenges you can face is rapid growth. Matt Butcher, Principal Software Development Engineer at Microsoft, addressed this issue in a presentation at Open Source Summit North America. His talk covered everything from teamwork to the importance of knowing your goals and sticking to them. - -Butcher is no stranger to managing open source projects. As [Microsoft invests more deeply into open source][2], Butcher has been involved with many projects, including toolkits for Kubernetes and QueryPath, the jQuery-like library for PHP. - -Butcher described a case study involving Kubernetes Helm, a package system for Kubernetes. Helm arose from a company team-building hackathon, with an original team of three people giving birth to it. Within 18 months, the project had hundreds of contributors and thousands of active users. - -### Teamwork - -“We were stretched to our limits as we learned to grow,” Butcher said. “When you’re trying to set up your team of core maintainers and they’re all trying to work together, you want to spend some actual time trying to optimize for a process that lets you be cooperative. You have to adjust some expectations regarding how you treat each other. When you’re working as a group of open source collaborators, the relationship is not employer/employee necessarily. It’s a collaborative effort.” - -In addition to focusing on the right kinds of teamwork, Butcher and his collaborators learned that managing governance and standards is an ongoing challenge. “You want people to understand who makes decisions, how they make decisions and why they make the decisions that they make,” he said. “When we were a small project, there might have been two paragraphs in one of our documents on standards, but as a project grows and you get growing pains, these documented things gain a life of their own. They get their very own repositories, and they just keep getting bigger along with the project.” - -Should all discussion surrounding a open source project go on in public, bathed in the hot lights of community scrutiny? Not necessarily, Butcher noted. “A minor thing can get blown into catastrophic proportions in a short time because of misunderstandings and because something that should have been done in private ended up being public,” he said. “Sometimes we actually make architectural recommendations as a closed group. The reason we do this is that we don’t want to miscue the community. The people who are your core maintainers are core maintainers because they’re experts, right? These are the people that have been selected from the community because they understand the project. They understand what people are trying to do with it. They understand the frustrations and concerns of users.” - -### Acknowledge Contributions - -Butcher added that it is essential to acknowledge people’s contributions to keep the environment surrounding a fast-growing project from becoming toxic. “We actually have an internal rule in our core maintainers guide that says, ‘Make sure that at least one comment that you leave on a code review, if you’re asking for changes, is a positive one,” he said. “It sounds really juvenile, right? But it serves a specific purpose. It lets somebody know, ‘I acknowledge that you just made a gift of your time and your resources.” - -Want more tips on successfully launching and managing open source projects? Stay tuned for more insight from Matt Butcher’s talk, in which he provides specific project management issues faced by Kubernetes Helm. - -For more information, be sure to check out [The Linux Foundation’s growing list of Open Source Guides for the Enterprise][3], covering topics such as starting an open source project, improving your open source impact, and participating in open source communities. - --------------------------------------------------------------------------------- - -via: https://www.linuxfoundation.org/blog/lessons-learned-from-growing-an-open-source-project-too-fast/ - -作者:[Sam Dean][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linuxfoundation.org/author/sdean/ -[1]:https://www.linuxfoundation.org/wp-content/uploads/2018/03/huskies-2279627_1920.jpg -[2]:https://thenewstack.io/microsoft-shifting-emphasis-open-source/ -[3]:https://www.linuxfoundation.org/resources/open-source-guides/ diff --git a/sources/talk/20180316 How to avoid humiliating newcomers- A guide for advanced developers.md b/sources/talk/20180316 How to avoid humiliating newcomers- A guide for advanced developers.md deleted file mode 100644 index e433e85d5f..0000000000 --- a/sources/talk/20180316 How to avoid humiliating newcomers- A guide for advanced developers.md +++ /dev/null @@ -1,119 +0,0 @@ -How to avoid humiliating newcomers: A guide for advanced developers -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) -Every year in New York City, a few thousand young men come to town, dress up like Santa Claus, and do a pub crawl. One year during this SantaCon event, I was walking on the sidewalk and minding my own business, when I saw an extraordinary scene. There was a man dressed up in a red hat and red jacket, and he was talking to a homeless man who was sitting in a wheelchair. The homeless man asked Santa Claus, "Can you spare some change?" Santa dug into his pocket and brought out a $5 bill. He hesitated, then gave it to the homeless man. The homeless man put the bill in his pocket. - -In an instant, something went wrong. Santa yelled at the homeless man, "I gave you $5. I wanted to give you one dollar, but five is the smallest I had, so you oughtta be grateful. This is your lucky day, man. You should at least say thank you!" - -This was a terrible scene to witness. First, the power difference was terrible: Santa was an able-bodied white man with money and a home, and the other man was black, homeless, and using a wheelchair. It was also terrible because Santa Claus was dressed like the very symbol of generosity! And he was behaving like Santa until, in an instant, something went wrong and he became cruel. - -This is not merely a story about Drunk Santa, however; this is a story about technology communities. We, too, try to be generous when we answer new programmers' questions, and every day our generosity turns to rage. Why? - -### My cruelty - -I'm reminded of my own bad behavior in the past. I was hanging out on my company's Slack when a new colleague asked a question. - -> **New Colleague:** Hey, does anyone know how to do such-and-such with MongoDB? -> **Jesse:** That's going to be implemented in the next release. -> **New Colleague:** What's the ticket number for that feature? -> **Jesse:** I memorize all ticket numbers. It's #12345. -> **New Colleague:** Are you sure? I can't find ticket 12345. - -He had missed my sarcasm, and his mistake embarrassed him in front of his peers. I laughed to myself, and then I felt terrible. As one of the most senior programmers at MongoDB, I should not have been setting this example. And yet, such behavior is commonplace among programmers everywhere: We get sarcastic with newcomers, and we humiliate them. - -### Why does it matter? - -Perhaps you are not here to make friends; you are here to write code. If the code works, does it matter if we are nice to each other or not? - -A few months ago on the Stack Overflow blog, David Robinson showed that [Python has been growing dramatically][1], and it is now the top language that people view questions about on Stack Overflow. Even in the most pessimistic forecast, it will far outgrow the other languages this year. - -![Projections for programming language popularity][2] - -If you are a Python expert, then the line surging up and to the right is good news for you. It does not represent competition, but confirmation. As more new programmers learn Python, our expertise becomes ever more valuable, and we will see that reflected in our salaries, our job opportunities, and our job security. - -But there is a danger. There are soon to be more new Python programmers than ever before. To sustain this growth, we must welcome them, and we are not always a welcoming bunch. - -### The trouble with Stack Overflow - -I searched Stack Overflow for rude answers to beginners' questions, and they were not hard to find. - -![An abusive answer on StackOverflow][3] - -The message is plain: If you are asking a question this stupid, you are doomed. Get out. - -I immediately found another example of bad behavior: - -![Another abusive answer on Stack Overflow][4] - -Who has never been confused by Unicode in Python? Yet the message is clear: You do not belong here. Get out. - -Do you remember how it felt when you needed help and someone insulted you? It feels terrible. And it decimates the community. Some of our best experts leave every day because they see us treating each other this way. Maybe they still program Python, but they are no longer participating in conversations online. This cruelty drives away newcomers, too, particularly members of groups underrepresented in tech who might not be confident they belong. People who could have become the great Python programmers of the next generation, but if they ask a question and somebody is cruel to them, they leave. - -This is not in our interest. It hurts our community, and it makes our skills less valuable because we drive people out. So, why do we act against our own interests? - -### Why generosity turns to rage - -There are a few scenarios that really push my buttons. One is when I act generously but don't get the acknowledgment I expect. (I am not the only person with this resentment: This is probably why Drunk Santa snapped when he gave a $5 bill to a homeless man and did not receive any thanks.) - -Another is when answering requires more effort than I expect. An example is when my colleague asked a question on Slack and followed-up with, "What's the ticket number?" I had judged how long it would take to help him, and when he asked for more help, I lost my temper. - -These scenarios boil down to one problem: I have expectations for how things are going to go, and when those expectations are violated, I get angry. - -I've been studying Buddhism for years, so my understanding of this topic is based in Buddhism. I like to think that the Buddha discussed the problem of expectations in his first tech talk when, in his mid-30s, he experienced a breakthrough after years of meditation and convened a small conference to discuss his findings. He had not rented a venue, so he sat under a tree. The attendees were a handful of meditators the Buddha had met during his wanderings in northern India. The Buddha explained that he had discovered four truths: - - * First, that to be alive is to be dissatisfied—to want things to be better than they are now. - * Second, this dissatisfaction is caused by wants; specifically, by our expectation that if we acquire what we want and eliminate what we do not want, it will make us happy for a long time. This expectation is unrealistic: If I get a promotion or if I delete 10 emails, it is temporarily satisfying, but it does not make me happy over the long-term. We are dissatisfied because every material thing quickly disappoints us. - * The third truth is that we can be liberated from this dissatisfaction by accepting our lives as they are. - * The fourth truth is that the way to transform ourselves is to understand our minds and to live a generous and ethical life. - - - -I still get angry at people on the internet. It happened to me recently, when someone posted a comment on [a video I published about Python co-routines][5]. It had taken me months of research and preparation to create this video, and then a newcomer commented, "I want to master python what should I do." - -![Comment on YouTube][6] - -This infuriated me. My first impulse was to be sarcastic, "For starters, maybe you could spell Python with a capital P and end a question with a question mark." Fortunately, I recognized my anger before I acted on it, and closed the tab instead. Sometimes liberation is just a Command+W away. - -### What to do about it - -If you joined a community with the intent to be helpful but on occasion find yourself flying into a rage, I have a method to prevent this. For me, it is the step when I ask myself, "Am I angry?" Knowing is most of the battle. Online, however, we can lose track of our emotions. It is well-established that one reason we are cruel on the internet is because, without seeing or hearing the other person, our natural empathy is not activated. But the other problem with the internet is that, when we use computers, we lose awareness of our bodies. I can be angry and type a sarcastic message without even knowing I am angry. I do not feel my heart pound and my neck grow tense. So, the most important step is to ask myself, "How do I feel?" - -If I am too angry to answer, I can usually walk away. As [Thumper learned in Bambi][7], "If you can't say something nice, don't say nothing at all." - -### The reward - -Helping a newcomer is its own reward, whether you receive thanks or not. But it does not hurt to treat yourself to a glass of whiskey or a chocolate, or just a sigh of satisfaction after your good deed. - -But besides our personal rewards, the payoff for the Python community is immense. We keep the line surging up and to the right. Python continues growing, and that makes our own skills more valuable. We welcome new members, people who might not be sure they belong with us, by reassuring them that there is no such thing as a stupid question. We use Python to create an inclusive and diverse community around writing code. And besides, it simply feels good to be part of a community where people treat each other with respect. It is the kind of community that I want to be a member of. - -### The three-breath vow - -There is one idea I hope you remember from this article: To control our behavior online, we must occasionally pause and notice our feelings. I invite you, if you so choose, to repeat the following vow out loud: - -> I vow -> to take three breaths -> before I answer a question online. - -This article is based on a talk, [Why Generosity Turns To Rage, and What To Do About It][8], that Jesse gave at PyTennessee in February. For more insight for Python developers, attend [PyCon 2018][9], May 9-17 in Cleveland, Ohio. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/avoid-humiliating-newcomers - -作者:[A. Jesse][a] -译者:[译者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/emptysquare -[1]:https://stackoverflow.blog/2017/09/06/incredible-growth-python/ -[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/projections.png?itok=5QTeJ4oe (Projections for programming language popularity) -[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/abusive-answer-1.jpg?itok=BIWW10Rl (An abusive answer on StackOverflow) -[4]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/abusive-answer-2.jpg?itok=0L-n7T-k (Another abusive answer on Stack Overflow) -[5]:https://www.youtube.com/watch?v=7sCu4gEjH5I -[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/i-want-to-master-python.png?itok=Y-2u1XwA (Comment on YouTube) -[7]:https://www.youtube.com/watch?v=nGt9jAkWie4 -[8]:https://www.pytennessee.org/schedule/presentation/175/ -[9]:https://us.pycon.org/2018/ diff --git a/sources/talk/20180320 Easily Fund Open Source Projects With These Platforms.md b/sources/talk/20180320 Easily Fund Open Source Projects With These Platforms.md deleted file mode 100644 index 8c02ca228b..0000000000 --- a/sources/talk/20180320 Easily Fund Open Source Projects With These Platforms.md +++ /dev/null @@ -1,96 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: subject: (Easily Fund Open Source Projects With These Platforms) -[#]: via: (https://itsfoss.com/open-source-funding-platforms/) -[#]: author: ([Ambarish Kumar](https://itsfoss.com/author/ambarish/)) -[#]: url: ( ) - -Easily Fund Open Source Projects With These Platforms -====== - -**Brief: We list out some funding platforms you can use to financially support open source projects. ** - -Financial support is one of the many ways to [help Linux and Open Source community][1]. This is why you see “Donate” option on the websites of most open source projects. - -While the big corporations have the necessary funding and resources, most open source projects are developed by individuals in their spare time. However, it does require one’s efforts, time and probably includes some overhead costs too. Monetary supports surely help drive the project development. - -If you would like to support open source projects financially, let me show you some platforms dedicated to open source and/or Linux. - -### Funding platforms for Open Source projects - -![Open Source funding platforms][2] - -Just to clarify, we are not associated with any of the funding platforms mentioned here. - -#### 1\. Liberapay - -[Gratipay][3] was probably the biggest platform for funding open source projects and people associated with the project, which got shut down at the end of the year 2017. However, there’s a fork – Liberapay that works as a recurrent donation platform for the open source projects and the contributors. - -[Liberapay][4] is a non-profit, open source organization that helps in a periodic donation to a project. You can create an account as a contributor and ask the people who would really like to help (usually the consumer of your products) to donate. - -To receive a donation, you will have to create an account on Liberapay, brief what you do and about your project, reasons for asking for the donation and what will be done with the money you receive. - -For someone who would like to donate, they would have to add money to their accounts and set up a period for payment that can be weekly, monthly or yearly to someone. There’s a mail triggered when there is not much left to donate. - -The currency supported are dollars and Euro as of now and you can always put up a badge on Github, your Twitter profile or website for a donation. - -#### 2\. Bountysource - -[Bountysource][5] is a funding platform for open source software that has a unique way of paying a developer for his time and work int he name of Bounties. - -There are basically two campaigns, bounties and salt campaign. - -Under the Bounties, users declare bounties aka cash prizes on open issues that they believe should be fixed or any new features which they want to see in the software they are using. A developer can then go and fix it to receive the cash prize. - -Salt Campaign is like any other funding, anyone can pay a recurring amount to a project or an individual working for an open source project for as long as they want. - -Bountysource accepts any software that is approved by Free Software Foundation or Open Source Initiatives. The bounties can be placed using PayPal, Bitcoin or the bounty itself if owned previously. Bountysource supports a no. of issue tracker currently like GitHub, Bugzilla, Google Code, Jira, Launchpad etc. - -#### 3\. Open Collective - -[Open Collective][6] is another popular funding initiative where a person who is willing to receive the donation for the work he is doing in Open Source world can create a page. He can submit the expense reports for the project he is working on. A contributor can add money to his account and pay him for his expenses. - -The complete process is transparent and everyone can track whoever is associated with Open Collective. The contributions are visible along with the unpaid expenses. There is also the option to contribute on a recurring basis. - -Open Collective currently has more than 500 collectives being backed up by more than 5000 users. - -The fact that it is transparent and you know what you are contributing to, drives more accountability. Some common example of collective include hosting costs, community maintenance, travel expenses etc. - -Though Open Collective keeps 10% of all the transactions, it is still a nice way to get your expenses covered in the process of contributing towards an open source project. - -#### 4\. Open Source Grants - -[Open Source Grants][7] is still in its beta stage and has not matured yet. They are looking for projects that do not have any stable funding and adds value to open source community. Most open source projects are run by a small community in a free time and they are trying to fund them so that the developers can work full time on the projects. - -They are equally searching for companies that want to help open source enthusiasts. The process of submitting a project is still being worked upon, and hopefully, in coming days we will see a working way of funding. - -### Final Words - -In the end, I would also like to mention [Patreon][8]. This funding platform is not exclusive to open source but is focused on creators of all kinds. Some projects like [elementary OS have created their accounts on Patreon][9] so that you can support the project on a recurring basis. - -Think Free Speech, not Free Beer. Your small contribution to a project can help it sustain in the long run. For the developers, the above platform can provide a good way to cover up their expenses. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/open-source-funding-platforms/ - -作者:[Ambarish Kumar][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/ambarish/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/help-linux-grow/ -[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/03/Fund-Open-Source-projects.png?resize=800%2C450&ssl=1 -[3]: https://itsfoss.com/gratipay-open-source/ -[4]: https://liberapay.com/ -[5]: https://www.bountysource.com/ -[6]: https://opencollective.com/ -[7]: https://foundation.travis-ci.org/grants/ -[8]: https://www.patreon.com/ -[9]: https://www.patreon.com/elementary diff --git a/sources/talk/20180321 8 tips for better agile retrospective meetings.md b/sources/talk/20180321 8 tips for better agile retrospective meetings.md deleted file mode 100644 index ec45bf17f0..0000000000 --- a/sources/talk/20180321 8 tips for better agile retrospective meetings.md +++ /dev/null @@ -1,66 +0,0 @@ -8 tips for better agile retrospective meetings -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_meeting.png?itok=4_CivQgp) -I’ve often thought that retrospectives should be called prospectives, as that term concerns the future rather than focusing on the past. The retro itself is truly future-looking: It’s the space where we can ask the question, “With what we know now, what’s the next experiment we need to try for improving our lives, and the lives of our customers?” - -### What’s a retro supposed to look like? - -There are two significant loops in product development: One produces the desired potentially shippable nugget. The other is where we examine how we’re working—not only to avoid doing what didn’t work so well, but also to determine how we can amplify the stuff we do well—and devise an experiment to pull into the next production loop to improve how our team is delighting our customers. This is the loop on the right side of this diagram: - - -![Retrospective 1][2] - -### When retros implode - -While attending various teams' iteration retrospective meetings, I saw a common thread of malcontent associated with a relentless focus on continuous improvement. - -One of the engineers put it bluntly: “[Our] continuous improvement feels like we are constantly failing.” - -The teams talked about what worked, restated the stuff that didn’t work (perhaps already feeling like they were constantly failing), nodded to one another, and gave long sighs. Then one of the engineers (already late for another meeting) finally summed up the meeting: “Ok, let’s try not to submit all of the code on the last day of the sprint.” There was no opportunity to amplify the good, as the good was not discussed. - -In effect, here’s what the retrospective felt like: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/retro_2.jpg?itok=HrDkppCG) - -The anti-pattern is where retrospectives become dreaded sessions where we look back at the last iteration, make two columns—what worked and what didn’t work—and quickly come to some solution for the next iteration. There is no [scientific method][3] involved. There is no data gathering and research, no hypothesis, and very little deep thought. The result? You don’t get an experiment or a potential improvement to pull into the next iteration. - -### 8 tips for better retrospectives - - 1. Amplify the good! Instead of focusing on what didn’t work well, why not begin the retro by having everyone mention one positive item first? - 2. Don’t jump to a solution. Thinking about a problem deeply instead of trying to solve it right away might be a better option. - 3. If the retrospective doesn’t make you feel excited about an experiment, maybe you shouldn’t try it in the next iteration. - 4. If you’re not analyzing how to improve, ([5 Whys][4], [force-field analysis][5], [impact mapping][6], or [fish-boning][7]), you might be jumping to solutions too quickly. - 5. Vary your methods. If every time you do a retrospective you ask, “What worked, what didn’t work?” and then vote on the top item from either column, your team will quickly get bored. [Retromat][8] is a great free retrospective tool to help vary your methods. - 6. End each retrospective by asking for feedback on the retro itself. This might seem a bit meta, but it works: Continually improving the retrospective is recursively improving as a team. - 7. Remove the impediments. Ask how you are enabling the team's search for improvement, and be prepared to act on any feedback. - 8. There are no "iteration police." Take breaks as needed. Deriving hypotheses from analysis and coming up with experiments involves creativity, and it can be taxing. Every once in a while, go out as a team and enjoy a nice retrospective lunch. - - - -This article was inspired by [Retrospective anti-pattern: continuous improvement should not feel like constantly failing][9], posted at [Podojo.com][10]. - -**[See our related story,[How to build a business case for DevOps transformation][11].]** - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/tips-better-agile-retrospective-meetings - -作者:[Catherine Louis][a] -译者:[译者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/catherinelouis -[1]:/file/389021 -[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/retro_1.jpg?itok=bggmHN1Q (Retrospective 1) -[3]:https://en.wikipedia.org/wiki/Scientific_method -[4]:https://en.wikipedia.org/wiki/5_Whys -[5]:https://en.wikipedia.org/wiki/Force-field_analysis -[6]:https://opensource.com/open-organization/17/6/experiment-impact-mapping -[7]:https://en.wikipedia.org/wiki/Ishikawa_diagram -[8]:https://plans-for-retrospectives.com/en/?id=28 -[9]:http://www.podojo.com/retrospective-anti-pattern-continuous-improvement-should-not-feel-like-constantly-failing/ -[10]:http://www.podojo.com/ -[11]:https://opensource.com/article/18/2/how-build-business-case-devops-transformation diff --git a/sources/talk/20180323 7 steps to DevOps hiring success.md b/sources/talk/20180323 7 steps to DevOps hiring success.md deleted file mode 100644 index cdea0c65ac..0000000000 --- a/sources/talk/20180323 7 steps to DevOps hiring success.md +++ /dev/null @@ -1,56 +0,0 @@ -7 steps to DevOps hiring success -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) -As many of us in the DevOps scene know, most companies are hiring, or, at least, trying to do so. The required skills and job descriptions can change entirely from company to company. As a broad overview, most teams are looking for a candidate from either an operations and infrastructure background or someone from a software engineering and development background, then combined with key skills relating to continuous integration, configuration management, continuous delivery/deployment, and cloud infrastructure. Currently in high-demand is knowledge of container orchestration. - -In the ideal world, the two backgrounds will meet somewhere in the middle to form Dev and Ops, but in most cases, there is a lean toward one side or the other while maintaining sufficient skills to understand the needs and demands of their counterparts to work collaboratively and achieve the end goal of continuous delivery/deployment. Every company is different and there isn’t necessarily a right or wrong here. It all depends on your infrastructure, tech stack, other team members’ skills, and the individual goals you hope to achieve by hiring this individual. - -### Focus your hiring - -Now, given the various routes to becoming a DevOps practitioner, how do hiring managers focus their search and selection process to ensure that they’re hitting the mark? - -#### Decide on the background - -Assess the strengths of your existing team. Do you already have some amazing software engineers but you’re lacking the infrastructure knowledge? Aim to close these gaps in skills. You may have been given the budget to hire for DevOps, but you don’t have to spend weeks/months searching for the best software engineer who happens to use Docker and Kubernetes because they are the current hot trends in this space. Find the person who will provide the most value in your environment and go from there. - -#### Contractor or permanent employee? - -Many hiring managers will automatically start searching for a full-time permanent employee when their needs may suggest that they have other options. Sometimes a contractor is your best bet or maybe contract-hire. If you’re aiming to design, implement and build a new DevOps environment, why not find a senior person who has done this a number of times already? Try hiring a senior contractor and bring on a junior full-time hire in parallel; this way, you’ll be able to retain the external contractor knowledge by having them work alongside the junior hire. Contractors can be expensive, but the knowledge they bring can be invaluable, especially if the work can be completed over a shorter time frame. Again, this is just another point of view and you might be best off with a full-time hire to grow the team. - -#### CTRL F is not the solution - -Focus on their understanding of DevOps and CI/CD-related processes over specific tools. I believe the best approach is to focus on finding someone who understands the methodologies over the tools. Does your candidate understand the concept of continuous integration or the concept of continuous delivery? That’s more important than asking whether your candidate uses Jenkins versus Bamboo versus TeamCity and so on. Try not to get caught up in the exact tool chain. The focus should be on the candidates’ ability to solve problems. Are they obsessed with increasing efficiency, saving time, automating manual processes and constantly searching for flaws in the system? They might be the person you were looking for, but you missed them because you didn’t see the word "Puppet" on the resume. - -#### Work closely with your internal talent acquisition team and/or an external recruiter - -Be clear and precise with what you’re looking for and have an ongoing, open communication with recruiters. They can and will help you if used effectively. The job of these recruiters is to save you time by sourcing candidates while you’re focusing on your day-to-day role. Work closely with them and deliver in the same way that you would expect them to deliver for you. If you say you will review a candidate by X time, do it. If they say they’ll have a candidate in your inbox by Y time, make sure they do it, too. Start by setting up an initial call to talk through your requirement, lay out a timeline in which you expect candidates by a specific time, and explain your process in terms of when you will interview, how many interview rounds, and how soon after you will be able to make a final decision on whether to offer or reject the candidates. If you can get this relationship working well, you’ll save lots of time. And make sure your internal teams are focused on supporting your process, not blocking it. - -#### $$$ - -Decide how much you want to pay. It’s not all about the money, but you can waste a lot of your and other people’s time if you don’t lock down the ballpark salary or hourly rate that you can afford. If your budget doesn’t stretch as far as your competitors’, you need to consider what else can help sell the opportunity. Flexible working hours and remote working options are some great ways to do this. Most companies have snacks, beer, and cool offices nowadays, so focus on the real value such as the innovative work your team is doing and how awesome your game-changing product might be. - -#### Drop the ego - -You may have an amazing company and/or product, but you also have some hot competition. Everyone is hiring in this space and candidates have a lot of the buying power. It is no longer as simple as saying, "We are hiring" and the awesome candidates come flowing in. You need to sell your opportunities. Maintaining a reputation as a great place to work is also important. A poor hiring process, such as interviewing without giving feedback, can contribute to bad rumors being spread across the industry. It only takes a few minutes to leave a sour review on Glassdoor. - -#### A smooth process is a successful One - -"Let’s get every single person within the company to do a one-hour interview with the new DevOps person we are hiring!" No, let’s not do that. Two or three stages should be sufficient. You have managers and directors for a reason. Trust your instinct and use your experience to make decisions on who will fit into your organization. Some of the most successful companies can do one phone screen followed by an in-person meeting. During the in-person interview, spend a morning or afternoon allowing the candidate to meet the relevant leaders and senior members of their direct team, then take them for lunch, dinner, or drinks where you can see how they are on a social level. If you can’t have a simple conversation with them, then you probably won’t enjoy working with them. If the thumbs are up, make the hire and don’t wait around. A good candidate will usually have numerous offers on the table at the same time. - -If all goes well, you should be inviting your shiny new employee or contractor into the office in the next few weeks and hopefully many more throughout the year. - -This article was originally published on [DevOps.com][1] and republished with author permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/7-steps-devops-hiring-success - -作者:[Conor Delanbanque][a] -译者:[译者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/cdelanbanque -[1]:https://devops.com/7-steps-devops-hiring-success/ diff --git a/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md b/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md deleted file mode 100644 index bac0819e74..0000000000 --- a/sources/talk/20180330 Meet OpenAuto, an Android Auto emulator for Raspberry Pi.md +++ /dev/null @@ -1,81 +0,0 @@ -Meet OpenAuto, an Android Auto emulator for Raspberry Pi -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lightbulb_computer_person_general_.png?itok=BRGJXU7e) - -In 2015, Google introduced [Android Auto][1], a system that allows users to project certain apps from their Android smartphones onto a car's infotainment display. Android Auto's driver-friendly interface, with larger touchscreen buttons and voice commands, aims to make it easier and safer for drivers to control navigation, music, podcasts, radio, phone calls, and more while keeping their eyes on the road. Android Auto can also run as an app on an Android smartphone, enabling owners of older-model vehicles without modern head unit displays to take advantage of these features. - -While there are many [apps][2] available for Android Auto, developers are working to add to its catalog. A new, open source tool named [OpenAuto][3] is hoping to make that easier by giving developers a way to emulate Android Auto on a Raspberry Pi. With OpenAuto, developers can test their applications in conditions similar to how they'll work on an actual car head unit. - -OpenAuto's creator, Michal Szwaj, answered some questions about his project for Opensource.com. Some responses have been edited for conciseness and clarity. - -### What is OpenAuto? - -In a nutshell, OpenAuto is an emulator for the Android Auto head unit. It emulates the head unit software and allows you to use Android Auto on your PC or on any other embedded platform like Raspberry Pi 3. - -Head unit software is a frontend for the Android Auto projection. All magic related to the Android Auto, like navigation, Google Voice Assistant, or music playback, is done on the Android device. Projection of Android Auto on the head unit is accomplished using the [H.264][4] codec for video and [PCM][5] codec for audio streaming. This is what the head unit software mostly does—it decodes the H.264 video stream and PCM audio streams and plays them back together. Another function of the head unit is providing user inputs. OpenAuto supports both touch events and hard keys. - -### What platforms does OpenAuto run on? - -My target platform for deployment of the OpenAuto is Raspberry Pi 3 computer. For successful deployment, I needed to implement support of video hardware acceleration using the Raspberry Pi 3 GPU (VideoCore 4). Thanks to this, Android Auto projection on the Raspberry Pi 3 computer can be handled even using 1080p@60 fps resolution. I used [OpenMAX IL][6] and IL client libraries delivered together with the Raspberry Pi firmware to implement video hardware acceleration. - -Taking advantage of the fact that the Raspberry Pi operating system is Raspbian based on Debian Linux, OpenAuto can be also built for any other Linux-based platform that provides support for hardware video decoding. Most of the Linux-based platforms provide support for hardware video decoding directly in GStreamer. Thanks to highly portable libraries like Boost and [Qt][7], OpenAuto can be built and run on the Windows platform. Support of MacOS is being implemented by the community and should be available soon. - -![][https://www.youtube.com/embed/k9tKRqIkQs8?origin=https://opensource.com&enablejsapi=1] - -### What software libraries does the project use? - -The core of the OpenAuto is the [aasdk][8] library, which provides support for all Android Auto features. aasdk library is built on top of the Boost, libusb, and OpenSSL libraries. [libusb][9] implements communication between the head unit and an Android device (via USB bus). [Boost][10] provides support for the asynchronous mechanisms for communication. It is required for high efficiency and scalability of the head unit software. [OpenSSL][11] is used for encrypting communication. - -The aasdk library is designed to be fully reusable for any purposes related to implementation of the head unit software. You can use it to build your own head unit software for your desired platform. - -Another very important library used in OpenAuto is Qt. It provides support for OpenAuto's multimedia, user input, and graphical interface. And the build system OpenAuto is using is [CMake][12]. - -Note: The Android Auto protocol is taken from another great Android Auto head unit project called [HeadUnit][13]. The people working on this project did an amazing job in reverse engineering the AndroidAuto protocol and creating the protocol buffers that structurize all messages. - -### What equipment do you need to run OpenAuto on Raspberry Pi? - -In addition to a Raspberry Pi 3 computer and an Android device, you need: - - * **USB sound card:** The Raspberry Pi 3 doesn't have a microphone input, which is required to use Google Voice Assistant - * **Video output device:** You can use either a touchscreen or any other video output device connected to HDMI or composite output (RCA) - * **Input device:** For example, a touchscreen or a USB keyboard - - - -### What else do you need to get started? - -In order to use OpenAuto, you must build it first. On the OpenAuto's wiki page you can find [detailed instructions][14] for how to build it for the Raspberry Pi 3 platform. On other Linux-based platforms, the build process will look very similar. - -On the wiki page you can also find other useful instructions, such as how to configure the Bluetooth Hands-Free Profile (HFP) and Advanced Audio Distribution Profile (A2DP) and PulseAudio. - -### What else should we know about OpenAuto? - -OpenAuto allows anyone to create a head unit based on the Raspberry Pi 3 hardware. Nevertheless, you should always be careful about safety and keep in mind that OpenAuto is just an emulator. It was not certified by any authority and was not tested in a driving environment, so using it in a car is not recommended. - -OpenAuto is licensed under GPLv3. For more information, visit the [project's GitHub page][3], where you can find its source code and other information. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/openauto-emulator-Raspberry-Pi - -作者:[Michal Szwaj][a] -译者:[译者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/michalszwaj -[1]:https://www.android.com/auto/faq/ -[2]:https://play.google.com/store/apps/collection/promotion_3001303_android_auto_all -[3]:https://github.com/f1xpl/openauto -[4]:https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC -[5]:https://en.wikipedia.org/wiki/Pulse-code_modulation -[6]:https://www.khronos.org/openmaxil -[7]:https://www.qt.io/ -[8]:https://github.com/f1xpl/aasdk -[9]:http://libusb.info/ -[10]:http://www.boost.org/ -[11]:https://www.openssl.org/ -[12]:https://cmake.org/ -[13]:https://github.com/gartnera/headunit -[14]:https://github.com/f1xpl/ diff --git a/sources/talk/20180403 3 pitfalls everyone should avoid with hybrid multicloud.md b/sources/talk/20180403 3 pitfalls everyone should avoid with hybrid multicloud.md deleted file mode 100644 index b128be62f0..0000000000 --- a/sources/talk/20180403 3 pitfalls everyone should avoid with hybrid multicloud.md +++ /dev/null @@ -1,87 +0,0 @@ -3 pitfalls everyone should avoid with hybrid multicloud -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_darwincloud_520x292_0311LL.png?itok=74DLgd8Q) - -This article was co-written with [Roel Hodzelmans][1]. - -We're all told the cloud is the way to ensure a digital future for our businesses. But which cloud? From cloud to hybrid cloud to hybrid multi-cloud, you need to make choices, and these choices don't preclude the daily work of enhancing your customers' experience or agile delivery of the applications they need. - -This article is the first in a four-part series on avoiding pitfalls in hybrid multi-cloud computing. Let's start by examining multi-cloud, hybrid cloud, and hybrid multi-cloud and what makes them different from one another. - -### Hybrid vs. multi-cloud - -There are many conversations you may be having in your business around moving to the cloud. For example, you may want to take your on-premises computing capacity and turn it into your own private cloud. You may wish to provide developers with a cloud-like experience using the same resources you already have. A more traditional reason for expansion is to use external computing resources to augment those in your own data centers. The latter leads you to the various public cloud providers, as well as to our first definition, multi-cloud. - -#### Multi-cloud - -Multi-cloud means using multiple clouds from multiple providers for multiple tasks. - -![Multi-cloud][3] - -Figure 1. Multi-cloud IT with multiple isolated cloud environments - -Typically, multi-cloud refers to the use of several different public clouds in order to achieve greater flexibility, lower costs, avoid vendor lock-in, or use specific regional cloud providers. - -A challenge of the multi-cloud approach is achieving consistent policies, compliance, and management with different providers involved. - -Multi-cloud is mainly a strategy to expand your business while leveraging multi-vendor cloud solutions and spreading the risk of lock-in. Figure 1 shows the isolated nature of cloud services in this model, without any sort of coordination between the services and business applications. Each is managed separately, and applications are isolated to services found in their environments. - -#### Hybrid cloud - -Hybrid cloud solves issues where isolation and coordination are central to the solution. It is a combination of one or more public and private clouds with at least a degree of workload portability, integration, orchestration, and unified management. - -![Hybrid cloud][5] - -Figure 2. Hybrid clouds may be on or off premises, but must have a degree of interoperability - -The key issue here is that there is an element of interoperability, migration potential, and a connection between tasks running in public clouds and on-premises infrastructure, even if it's not always seamless or otherwise fully implemented. - -If your cloud model is missing portability, integration, orchestration, and management, then it's just a bunch of clouds, not a hybrid cloud. - -The cloud environments in Fig. 2 include at least one private and public cloud. They can be off or on premises, but they have some degree of the following: - - * Interoperability - * Application portability - * Data portability - * Common management - - - -As you can probably guess, combining multi-cloud and hybrid cloud results in a hybrid multi-cloud. But what does that look like? - -### Hybrid multi-cloud - -Hybrid multi-cloud pulls together multiple clouds and provides the tools to ensure interoperability between the various services in hybrid and multi-cloud solutions. - -![Hybrid multi-cloud][7] - -Figure 3. Hybrid multi-cloud solutions using open technologies - -Bringing these together can be a serious challenge, but the result ensures better use of resources without isolation in their respective clouds. - -Fig. 3 shows an example of hybrid multi-cloud based on open technologies for interoperability, workload portability, and management. - -### Moving forward: Pitfalls of hybrid multi-cloud - -In part two of this series, we'll look at the first of three pitfalls to avoid with hybrid multi-cloud. Namely, why cost is not always the obvious motivator when determining how to transition your business to the cloud. - -This article is based on "[3 pitfalls everyone should avoid with hybrid multi-cloud][8]," a talk the authors will be giving at [Red Hat Summit 2018][9], which will be held May 8-10 in San Francisco. [Register by May 7][9] to save US$ 500 off of registration. Use discount code **OPEN18** on the payment page to apply the discount. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/pitfalls-hybrid-multi-cloud - -作者:[Eric D.Schabell][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者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/eschabell -[1]:https://opensource.com/users/roelh -[3]:https://opensource.com/sites/default/files/u128651/multi-cloud.png (Multi-cloud) -[5]:https://opensource.com/sites/default/files/u128651/hybrid-cloud.png (Hybrid cloud) -[7]:https://opensource.com/sites/default/files/u128651/hybrid-multicloud.png (Hybrid multi-cloud) -[8]:https://agenda.summit.redhat.com/SessionDetail.aspx?id=153892 -[9]:https://www.redhat.com/en/summit/2018 diff --git a/sources/talk/20180404 Is the term DevSecOps necessary.md b/sources/talk/20180404 Is the term DevSecOps necessary.md deleted file mode 100644 index 96b544e7c4..0000000000 --- a/sources/talk/20180404 Is the term DevSecOps necessary.md +++ /dev/null @@ -1,51 +0,0 @@ -Is the term DevSecOps necessary? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2) -First came the term "DevOps." - -It has many different aspects. For some, [DevOps][1] is mostly about a culture valuing collaboration, openness, and transparency. Others focus more on key practices and principles such as automating everything, constantly iterating, and instrumenting heavily. And while DevOps isn’t about specific tools, certain platforms and tooling make it a more practical proposition. Think containers and associated open source cloud-native technologies like [Kubernetes][2] and CI/CD pipeline tools like [Jenkins][3]—as well as native Linux capabilities. - -However, one of the earliest articulated concepts around DevOps was the breaking down of the “wall of confusion” specifically between developers and operations teams. This was rooted in the idea that developers didn’t think much about operational concerns and operators didn’t think much about application development. Add the fact that developers want to move quickly and operators care more about (and tend to be measured on) stability than speed, and it’s easy to see why it was difficult to get the two groups on the same page. Hence, DevOps came to symbolize developers and operators working more closely together, or even merging roles to some degree. - -Of course, calls for improved communications and better-integrated workflows were never just about dev and ops. Business owners should be part of conversations as well. And there are the actual users of the software. Indeed, you can write up an almost arbitrarily long list of stakeholders concerned with the functionality, cost, reliability, and other aspects of software and its associated infrastructure. Which raises the question that many have asked: “What’s so special about security that we need a DevSecOps term?” - -I’m glad you asked. - -The first is simply that it serves as a useful reminder. If developers and operations were historically two of the most common silos in IT organizations, security was (and often still is) another. Security people are often thought of as conservative gatekeepers for whom “no” often seems the safest response to new software releases and technologies. Security’s job is to protect the company, even if that means putting the brakes on a speedy development process. - -Many aspects of traditional security, and even its vocabulary, can also seem arcane to non-specialists. This has also contributed to the notion that security is something apart from mainstream IT. I often share the following anecdote: A year or two ago I was leading a security discussion at a [DevOpsDays][4] event in London in which we were talking about traditional security roles. One of the participants raised his hand and admitted that he was one of those security gatekeepers. He went on to say that this was the first time in his career that he had ever been to a conference that wasn’t a traditional security conference like RSA. (He also noted that he was going to broaden both his and his team’s horizons more.) - -So DevSecOps perhaps shouldn’t be a needed term. But explicitly calling it out seems like a good practice at a time when software security threats are escalating. - -The second reason is that the widespread introduction of cloud-native technologies, particularly those built around containers, are closely tied to DevOps practices. These new technologies are both leading to and enabling greater scale and more dynamic infrastructures. Static security policies and checklists no longer suffice. Security must become a continuous activity. And it must be considered at every stage of your application and infrastructure lifecycle. - -**Here are a few examples:** - -You need to secure the pipeline and applications. You need to use trusted sources for content so that you know who has signed off on container images and that they’re up-to-date with the most recent patches. Your continuous integration system must integrate automated security testing. You’ll sometimes hear people talking about “shifting security left,” which means earlier in the process so that problems can be dealt with sooner. But it’s actually better to think about embedding security throughout the entire pipeline at each step of the testing, integration, deployment, and ongoing management process. - -You need to secure the underlying infrastructure. This means securing the host Linux kernel from container escapes and securing containers from each other. It means using a container orchestration platform with integrated security features. It means defending the network by using network namespaces to isolate applications from other applications within a cluster and isolate environments (such as dev, test, and production) from each other. - -And it means taking advantage of the broader security ecosystem such as container content scanners and vulnerability management tools. - -In short, it’s DevSecOps because modern application development and container platforms require a new type of Dev and a new type of Ops. But they also require a new type of Sec. Thus, DevSecOps. - -**[See our related story,[Security and the SRE: How chaos engineering can play a key role][5].]** - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/devsecops - -作者:[Gordon Haff][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ghaff -[1]:https://opensource.com/resources/devops -[2]:https://kubernetes.io/ -[3]:https://jenkins.io/ -[4]:https://www.devopsdays.org/ -[5]:https://opensource.com/article/18/3/through-looking-glass-security-sre diff --git a/sources/talk/20180405 Rethinking -ownership- across the organization.md b/sources/talk/20180405 Rethinking -ownership- across the organization.md deleted file mode 100644 index d41a3a86dc..0000000000 --- a/sources/talk/20180405 Rethinking -ownership- across the organization.md +++ /dev/null @@ -1,125 +0,0 @@ -Rethinking "ownership" across the organization -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/chain.png?itok=sgAjswFf) -Differences in organizational design don't necessarily make some organizations better than others—just better suited to different purposes. Any style of organization must account for its models of ownership (the way tasks get delegated, assumed, executed) and responsibility (the way accountability for those tasks gets distributed and enforced). Conventional organizations and open organizations treat these issues differently, however, and those difference can be jarring for anyone hopping transitioning from one organizational model to another. But transitions are ripe for stumbling over—oops, I mean, learning from. - -Let's do that. - -### Ownership explained - -In most organizations (and according to typical project management standards), work on projects proceeds in five phases: - - * Initiation: Assess project feasibility, identify deliverables and stakeholders, assess benefits - * Planning (Design): Craft project requirements, scope, and schedule; develop communication and quality plans - * Executing: Manage task execution, implement plans, maintain stakeholder relationships - * Monitoring/Controlling: Manage project performance, risk, and quality of deliverables - * Closing: Sign-off on completion requirements, release resources - - - -The list above is not exhaustive, but I'd like to add one phase that is often overlooked: the "Adoption" phase, frequently needed for strategic projects where a change to the culture or organization is required for "closing" or completion. - - * Adoption: Socializing the work of the project; providing communication, training, or integration into processes and standard workflows. - - - -Examining project phases is one way contrast the expression of ownership and responsibility in organizations. - -### Two models, contrasted - -In my experience, "ownership" in a traditional software organization works like this. - -A manager or senior technical associate initiates a project with senior stakeholders and, with the authority to champion and guide the project, they bestow the project on an associate at some point during the planning and execution stages. Frequently, but not always, the groundwork or fundamental design of the work has already been defined and approved—sometimes even partially solved. Employees are expected to see the project through execution and monitoring to completion. - -Employees cut their teeth on a "starter project," where they prove their abilities to a management chain (for example, I recall several such starter projects that were already defined by a manager and architect, and I was assigned to help implement them). Employees doing a good job on a project for which they're responsible get rewarded with additional opportunities, like a coveted assignment, a new project, or increased responsibility. - -An associate acting as "owner" of work is responsible and accountable for that work (if someone, somewhere, doesn't do their job, then the responsible employee either does the necessary work herself or alerts a manager to the problem.) A sense of ownership begins to feel stable over time: Employees generally work on the same projects, and in the same areas for an extended period. For some employees, it means the development of deep expertise. That's because the social network has tighter integration between people and the work they do, so moving around and changing roles and projects is rather difficult. - -This process works differently in an open organization. - -Associates continually define the parameters of responsibility and ownership in an open organization—typically in light of their interests and passions. Associates have more agency to perform all the stages of the project themselves, rather than have pre-defined projects assigned to them. This places additional emphasis on leadership skills in an open organization, because the process is less about one group of people making decisions for others, and more about how an associate manages responsibilities and ownership (whether or not they roughly follow the project phases while being inclusive, adaptable, and community-focused, for example). - -Being responsible for all project phases can make ownership feel more risky for associates in an open organization. Proposing a new project, designing it, and leading its implementation takes initiative and courage—especially when none of this is pre-defined by leadership. It's important to get continuous buy-in, which comes with questions, criticisms, and resistance not only from leaders but also from peers. By default, in open organizations this makes associates leaders; they do much the same work that higher-level leaders do in conventional organizations. And incidentally, this is why Jim Whitehurst, in The Open Organization, cautions us about the full power of "transparency" and the trickiness of getting people's real opinions and thoughts whether we like them or not. The risk is not as high in a traditional organization, because in those organizations leaders manage some of it by shielding associates from heady discussions that arise. - -The reward in an Open Organization is more opportunity—offers of new roles, promotions, raises, etc., much like in a conventional organization. Yet in the case of open organizations, associates have developed reputations of excellence based on their own initiatives, rather than on pre-sanctioned opportunities from leadership. - -### Thinking about adoption - -Any discussion of ownership and responsibility involves addressing the issue of buy-in, because owning a project means we are accountable to our sponsors and users—our stakeholders. We need our stakeholders to buy-into our idea and direction, or we need users to adopt an innovation we've created with our stakeholders. Achieving buy-in for ideas and work is important in each type of organization, and it's difficult in both traditional and open systems—but for different reasons. - -Open organizations better allow highly motivated associates, who are ambitious and skilled, to drive their careers. But support for their ideas is required across the organization, rather than from leadership alone. - -Penetrating a traditional organization's closely knit social ties can be difficult, and it takes time. In such "command-and-control" environments, one would think that employees are simply "forced" to do whatever leaders want them to do. In some cases that's true (e.g., a travel reimbursement system). However, with more innovative programs, this may not be the case; the adoption of a program, tool, or process can be difficult to achieve by fiat, just like in an open organization. And yet these organizations tend to reduce redundancies of work and effort, because "ownership" here involves leaders exerting responsibility over clearly defined "domains" (and because those domains don't change frequently, knowing "who's who"—who's in charge, who to contact with a request or inquiry or idea—can be easier). - -Open organizations better allow highly motivated associates, who are ambitious and skilled, to drive their careers. But support for their ideas is required across the organization, rather than from leadership alone. Points of contact and sources of immediate support can be less obvious, and this means achieving ownership of a project or acquiring new responsibility takes more time. And even then someone's idea may never get adopted. A project's owner can change—and the idea of "ownership" itself is more flexible. Ideas that don't get adopted can even be abandoned, leaving a great idea unimplemented or incomplete. Because any associate can "own" an idea in an open organization, these organizations tend to exhibit more redundancy. (Some people immediately think this means "wasted effort," but I think it can augment the implementation and adoption of innovative solutions. By comparing these organizations, we can also see why Jim Whitehurst calls this kind of culture "chaotic" in The Open Organization). - -### Two models of ownership - -In my experience, I've seen very clear differences between conventional and open organizations when it comes to the issues of ownership and responsibility. - -In an traditional organization: - - * I couldn't "own" things as easily - * I felt frustrated, wanting to take initiative and always needing permission - * I could more easily see who was responsible because stakeholder responsibility was more clearly sanctioned and defined - * I could more easily "find" people, because the organizational network was more fixed and stable - * I more clearly saw what needed to happen (because leadership was more involved in telling me). - - - -Over time, I've learned the following about ownership and responsibility in an open organization: - - * People can feel good about what they are doing because the structure rewards behavior that's more self-driven - * Responsibility is less clear, especially in situations where there's no leader - * In cases where open organizations have "shared responsibility," there is the possibility that no one in the group identified with being responsible; often there is lack of role clarity ("who should own this?") - * More people participate - * Someone's leadership skills must be stronger because everyone is "on their own"; you are the leader. - - - -### Making it work - -On the subject of ownership, each type of organization can learn from the other. The important thing to remember here: Don't make changes to one open or conventional value without considering all the values in both organizations. - -Sound confusing? Maybe these tips will help. - -If you're a more conventional organization trying to act more openly: - - * Allow associates to take ownership out of passion or interest that align with the strategic goals of the organization. This enactment of meritocracy can help them build a reputation for excellence and execution. - * But don't be afraid sprinkle in a bit of "high-level perspective" in the spirit of transparency; that is, an associate should clearly communicate plans to their leadership, so the initiative doesn't create irrelevant or unneeded projects. - * Involving an entire community (as when, for example, the associate gathers feedback from multiple stakeholders and user groups) aids buy-in and creates beneficial feedback from the diversity of perspectives, and this helps direct the work. - * Exploring the work with the community [doesn't mean having to come to consensus with thousands of people][1]. Use the [Open Decision Framework][2] to set limits and be transparent about what those limits are so that feedback and participation is organized ad boundaries are understood. - - - -If you're already an open organization, then you should remember: - - * Although associates initiate projects from "the bottom up," leadership needs to be involved to provide guidance, input to the vision, and circulate centralized knowledge about ownership and responsibility creating a synchronicity of engagement that is transparent to the community. - * Ownership creates responsibility, and the definition and degree of these should be something both associates and leaders agree upon, increasing the transparency of expectations and accountability during the project. Don't make this a matter of oversight or babysitting, but rather [a collaboration where both parties give and take][3]—associates initiate, leaders guide; associates own, leaders support. - - - -Leadership education and mentorship, as it pertains to a particular organization, needs to be available to proactive associates, especially since there is often a huge difference between supporting individual contributors and guiding and coordinating a multiplicity of contributions. - -["Owning your own career"][4] can be difficult when "ownership" isn't a concept an organization completely understands. - -[Subscribe to our weekly newsletter][5] to learn more about open organizations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/4/rethinking-ownership-across-organization - -作者:[Heidi Hess von Ludewig][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/heidi-hess-von-ludewig -[1]:https://opensource.com/open-organization/17/8/achieving-alignment-in-openorg -[2]:https://opensource.com/open-organization/resources/open-decision-framework -[3]:https://opensource.com/open-organization/17/11/what-is-collaboration -[4]:https://opensource.com/open-organization/17/12/drive-open-career-forward -[5]:https://opensource.com/open-organization/resources/newsletter diff --git a/sources/talk/20180410 Microservices Explained.md b/sources/talk/20180410 Microservices Explained.md deleted file mode 100644 index 1d7e946a12..0000000000 --- a/sources/talk/20180410 Microservices Explained.md +++ /dev/null @@ -1,61 +0,0 @@ -Microservices Explained -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cloud-microservices.jpg?itok=GpoWiDeG) -Microservices is not a new term. Like containers, the concept been around for a while, but it’s become a buzzword recently as many companies embark on their cloud native journey. But, what exactly does the term microservices mean? Who should care about it? In this article, we’ll take a deep dive into the microservices architecture. - -### Evolution of microservices - -Patrick Chanezon, Chief Developer Advocate for Docker provided a brief history lesson during our conversation: In the late 1990s, developers started to structure their applications into monoliths where massive apps hadall features and functionalities baked into them. Monoliths were easy to write and manage. Companies could have a team of developers who built their applications based on customer feedback through sales and marketing teams. The entire developer team would work together to build tightly glued pieces as an app that can be run on their own app servers. It was a popular way of writing and delivering web applications. - -There is a flip side to the monolithic coin. Monoliths slow everything and everyone down. It’s not easy to update one service or feature of the application. The entire app needs to be updated and a new version released. It takes time. There is a direct impact on businesses. Organizations could not respond quickly to keep up with new trends and changing market dynamics. Additionally, scalability was challenging. - -Around 2011, SOA (Service Oriented Architecture) became popular where developers could cram multi-tier web applications as software services inside a VM (virtual machine). It did allow them to add or update services independent of each other. However, scalability still remained a problem. - -“The scale out strategy then was to deploy multiple copies of the virtual machine behind a load balancer. The problems with this model are several. Your services can not scale or be upgraded independently as the VM is your lowest granularity for scale. VMs are bulky as they carry extra weight of an operating system, so you need to be careful about simply deploying multiple copies of VMs for scaling,” said Madhura Maskasky, co-founder and VP of Product at Platform9. - -Some five years ago when Docker hit the scene and containers became popular, SOA faded out in favor of “microservices” architecture. “Containers and microservices fix a lot of these problems. Containers enable deployment of microservices that are focused and independent, as containers are lightweight. The Microservices paradigm, combined with a powerful framework with native support for the paradigm, enables easy deployment of independent services as one or more containers as well as easy scale out and upgrade of these,” said Maskasky. - -### What’s are microservices? - -Basically, a microservice architecture is a way of structuring applications. With the rise of containers, people have started to break monoliths into microservices. “The idea is that you are building your application as a set of loosely coupled services that can be updated and scaled separately under the container infrastructure,” said Chanezon. - -“Microservices seem to have evolved from the more strictly defined service-oriented architecture (SOA), which in turn can be seen as an expression object oriented programming concepts for networked applications. Some would call it just a rebranding of SOA, but the term “microservices” often implies the use of even smaller functional components than SOA, RESTful APIs exchanging JSON, lighter-weight servers (often containerized, and modern web technologies and protocols,” said Troy Topnik, SUSE Senior Product Manager, Cloud Application Platform. - -Microservices provides a way to scale development and delivery of large, complex applications by breaking them down that allows the individual components to evolve independently from each other. - -“Microservices architecture brings more flexibility through the independence of services, enabling organizations to become more agile in how they deliver new business capabilities or respond to changing market conditions. Microservices allows for using the ‘right tool for the right task’, meaning that apps can be developed and delivered by the technology that will be best for the task, rather than being locked into a single technology, runtime or framework,” said Christian Posta, senior principal application platform specialist, Red Hat. - -### Who consumes microservices? - -“The main consumers of microservices architecture patterns are developers and application architects,” said Topnik. As far as admins and DevOps engineers are concerned their role is to build and maintain the infrastructure and processes that support microservices. - -“Developers have been building their applications traditionally using various design patterns for efficient scale out, high availability and lifecycle management of their applications. Microservices done along with the right orchestration framework help simplify their lives by providing a lot of these features out of the box. A well-designed application built using microservices will showcase its benefits to the customers by being easy to scale, upgrade, debug, but without exposing the end customer to complex details of the microservices architecture,” said Maskasky. - -### Who needs microservices? - -Everyone. Microservices is the modern approach to writing and deploying applications more efficiently. If an organization cares about being able to write and deploy its services at a faster rate they should care about it. If you want to stay ahead of your competitors, microservices is the fastest route. Security is another major benefit of the microservices architecture, as this approach allows developers to keep up with security and bug fixes, without having to worry about downtime. - -“Application developers have always known that they should build their applications in a modular and flexible way, but now that enough of them are actually doing this, those that don’t risk being left behind by their competitors,” said Topnik. - -If you are building a new application, you should design it as microservices. You never have to hold up a release if one team is late. New functionalities are available when they're ready, and the overall system never breaks. - -“We see customers using this as an opportunity to also fix other problems around their application deployment -- such as end-to-end security, better observability, deployment and upgrade issues,” said Maskasky. - -Failing to do so means you would be stuck in the traditional stack, which means microservices won’t be able to add any value to it. If you are building new applications, microservices is the way to go. - -Learn more about cloud-native at [KubeCon + CloudNativeCon Europe][1], coming up May 2-4 in Copenhagen, Denmark. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/2018/4/microservices-explained - -作者:[SWAPNIL BHARTIYA][a] -译者:[runningwater](https://github.com/runningwater) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/arnieswap -[1]:https://events.linuxfoundation.org/events/kubecon-cloudnativecon-europe-2018/attend/register/ diff --git a/sources/talk/20180412 Management, from coordination to collaboration.md b/sources/talk/20180412 Management, from coordination to collaboration.md deleted file mode 100644 index 1262f88300..0000000000 --- a/sources/talk/20180412 Management, from coordination to collaboration.md +++ /dev/null @@ -1,71 +0,0 @@ -Management, from coordination to collaboration -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_consensuscollab2.png?itok=uMO9zn5U) - -Any organization is fundamentally a pattern of interactions between people. The nature of those interactions—their quality, their frequency, their outcomes—is the most important product an organization can create. Perhaps counterintuitively, recognizing this fact has never been more important than it is today—a time when digital technologies are reshaping not only how we work but also what we do when we come together. - - -And yet many organizational leaders treat those interactions between people as obstacles or hindrances to avoid or eliminate, rather than as the powerful sources of innovation they really are. - -That's why we're observing that some of the most successful organizations today are those capable of shifting the way they think about the value of the interactions in the workplace. And to do that, they've radically altered their approach to management and leadership. - -### Moving beyond mechanical management - -Simply put, traditionally managed organizations treat unanticipated interactions between stakeholders as potentially destructive forces—and therefore as costs to be mitigated. - -This view has a long, storied history in the field of economics. But it's perhaps nowhere more clear than in the early writing of Nobel Prize-winning economist[Ronald Coase][1]. In 1937, Coase published "[The Nature of the Firm][2]," an essay about the reasons people organized into firms to work on large-scale projects—rather than tackle those projects alone. Coase argued that when the cost of coordinating workers together inside a firm is less than that of similar market transactions outside, people will tend to organize so they can reap the benefits of lower operating costs. - -But at some point, Coase's theory goes, the work of coordinating interactions between so many people inside the firm actually outweighs the benefits of having an organization in the first place. The complexity of those interactions becomes too difficult to handle. Management, then, should serve the function of decreasing this complexity. Its primary goal is coordination, eliminating the costs associated with messy interpersonal interactions that could slow the firm and reduce its efficiency. As one Fortune 100 CEO recently told me, "Failures happen most often around organizational handoffs." - -This makes sense to people practicing what I've called "[mechanical management][3]," where managing people is the act of keeping them focused on specific, repeatable, specialized tasks. Here, management's key function is optimizing coordination costs—ensuring that every specialized component of the finely-tuned organizational machine doesn't impinge on the others and slow them down. Managers work to avoid failures by coordinating different functions across the organization (accounts payable, research and development, engineering, human resources, sales, and so on) to get them to operate toward a common goal. And managers create value by controlling information flows, intervening only when functions become misaligned. - -Today, when so many of these traditionally well-defined tasks have become automated, value creation is much more a result of novel innovation and problem solving—not finding new ways to drive efficiency from repeatable processes. But numerous studies demonstrate that innovative, problem-solving activity occurs much more regularly when people work in cross-functional teams—not as isolated individuals or groups constrained by single-functional silos. This kind of activity can lead to what some call "accidental integration": the serendipitous innovation that occurs when old elements combine in new and unforeseen ways. - -That's why working collaboratively has now become a necessity that managers need to foster, not eliminate. - -### From coordination to collaboration - -Reframing the value of the firm—from something that coordinated individual transactions to something that produces novel innovations—means rethinking the value of the relations at the core of our organizations. And that begins with reimagining the task of management, which is no longer concerned primarily with minimizing coordination costs but maximizing cooperation opportunities. - -Too few of our tried-and-true management practices have this goal. If they're seeking greater innovation, managers need to encourage more interactions between people in different functional areas, not fewer. A cross-functional team may not be as efficient as one composed of people with the same skill sets. But a cross-functional team is more likely to be the one connecting points between elements in your organization that no one had ever thought to connect (the one more likely, in other words, to achieve accidental integration). - -Working collaboratively has now become a necessity that managers need to foster, not eliminate. - -I have three suggestions for leaders interested in making this shift: - -First, define organizations around processes, not functions. We've seen this strategy work in enterprise IT, for example, in the case of [DevOps][4], where teams emerge around end goals (like a mobile application or a website), not singular functions (like developing, testing, and production). In DevOps environments, the same team that writes the code is responsible for maintaining it once it's in production. (We've found that when the same people who write the code are the ones woken up when it fails at 3 a.m., we get better code.) - -Second, define work around the optimal organization rather than the organization around the work. Amazon is a good example of this strategy. Teams usually stick to the "[Two Pizza Rule][5]" when establishing optimal conditions for collaboration. In other words, Amazon leaders have determined that the best-sized team for maximum innovation is about 10 people, or a group they can feed with two pizzas. If the problem gets bigger than that two-pizza team can handle, they split the problem into two simpler problems, dividing the work between multiple teams rather than adding more people to the single team. - -And third, to foster creative behavior and really get people cooperating with one another, do whatever you can to cultivate a culture of honest and direct feedback. Be straightforward and, as I wrote in The Open Organization, let the sparks fly; have frank conversations and let the best ideas win. - -### Let it go - -I realize that asking managers to significantly shift the way they think about their roles can lead to fear and skepticism. Some managers define their performance (and their very identities) by the control they exert over information and people. But the more you dictate the specific ways your organization should do something, the more static and brittle that activity becomes. Agility requires letting go—giving up a certain degree of control. - -Front-line managers will see their roles morph from dictating and monitoring to enabling and supporting. Instead of setting individual-oriented goals, they'll need to set group-oriented goals. Instead of developing individual incentives, they'll need to consider group-oriented incentives. - -Because ultimately, their goal should be to[create the context in which their teams can do their best work][6]. - -[Subscribe to our weekly newsletter][7] to learn more about open organizations. - --------------------------------------------------------------------------------- - -via: https://opensource.com/open-organization/18/4/management-coordination-collaboration - -作者:[Jim Whitehurst][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/remyd -[1]:https://news.uchicago.edu/article/2013/09/02/ronald-h-coase-founding-scholar-law-and-economics-1910-2013 -[2]:http://onlinelibrary.wiley.com/doi/10.1111/j.1468-0335.1937.tb00002.x/full -[3]:https://opensource.com/open-organization/18/2/try-learn-modify -[4]:https://enterprisersproject.com/devops -[5]:https://www.fastcompany.com/3037542/productivity-hack-of-the-week-the-two-pizza-approach-to-productive-teamwork -[6]:https://opensource.com/open-organization/16/3/what-it-means-be-open-source-leader -[7]:https://opensource.com/open-organization/resources/newsletter diff --git a/sources/talk/20180416 For project safety back up your people, not just your data.md b/sources/talk/20180416 For project safety back up your people, not just your data.md deleted file mode 100644 index 0dc6d41fa5..0000000000 --- a/sources/talk/20180416 For project safety back up your people, not just your data.md +++ /dev/null @@ -1,79 +0,0 @@ -For project safety back up your people, not just your data -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel) -The [FSF][1] was founded in 1985, Perl in 1987 ([happy 30th birthday, Perl][2]!), and Linux in 1991. The [term open source][3] and the [Open Source Initiative][4] both came into being in 1998 (and [turn 20 years old][5] in 2018). Since then, free and open source software has grown to become the default choice for software development, enabling incredible innovation. - -We, the greater open source community, have come of age. Millions of open source projects exist today, and each year the [GitHub Octoverse][6] reports millions of new public repositories. We rely on these projects every day, and many of us could not operate our services or our businesses without them. - -So what happens when the leaders of these projects move on? How can we help ease those transitions while ensuring that the projects thrive? By teaching and encouraging **succession planning**. - -### What is succession planning? - -Succession planning is a popular topic among business executives, boards of directors, and human resources professionals, but it doesn't often come up with maintainers of free and open source projects. Because the concept is common in business contexts, that's where you'll find most resources and advice about establishing a succession plan. As you might expect, most of these articles aren't directly applicable to FOSS, but they do form a springboard from which we can launch our own ideas about succession planning. - -According to [Wikipedia][7]: - -> Succession planning is a process for identifying and developing new leaders who can replace old leaders when they leave, retire, or die. - -In my opinion, this definition doesn't apply very well to free and open source software projects. I primarily object to the use of the term leaders. For the collaborative projects of FOSS, everyone can be some form of leader. Roles other than "project founder" or "benevolent dictator for life" are just as important. Any project role that is measured by bus factor is one that can benefit from succession planning. - -> A project's bus factor is the number of team members who, if hit by a bus, would endanger the smooth operation of the project. The smallest and worst bus factor is 1: when only a single person's loss would put the project in jeopardy. It's a somewhat grim but still very useful concept. - -I propose that instead of viewing succession planning as a leadership pipeline, free and open source projects should view it as a skills pipeline. What sorts of skills does your project need to continue functioning well, and how can you make sure those skills always exist in your community? - -### Benefits of succession planning - -When I talk to project maintainers about succession planning, they often respond with something like, "We've been pretty successful so far without having to think about this. Why should we start now?" - -Aside from the fact that the phrase, "We've always done it this way" is probably one of the most dangerous in the English language, and hearing (or saying) it should send up red flags in any community, succession planning provides plenty of very real benefits: - - * **Continuity** : When someone leaves, what happens to the tasks they were performing? Succession planning helps ensure those tasks continue uninterrupted and no one is left hanging. - * **Avoiding a power vacuum** : When a person leaves a role with no replacement, it can lead to confusion, delays, and often most damaging, political woes. After all, it's much easier to fix delays than hurt feelings. A succession plan helps alleviate the insecure and unstable time when someone in a vital role moves on. - * **Increased project/organization longevity** : The thinking required for succession planning is the same sort of thinking that contributes to project longevity. Ensuring continuity in leadership, culture, and productivity also helps ensure the project will continue. It will evolve, but it will survive. - * **Reduced workload/pressure on current leaders** : When a single team member performs a critical role in the project, they often feel pressure to be constantly "on." This can lead to burnout and worse, resignations. A succession plan ensures that all important individuals have a backup or successor. The knowledge that someone can take over is often enough to reduce the pressure, but it also means that key players can take breaks or vacations without worrying that their role will be neglected in their absence. - * **Talent development** : Members of the FOSS community talk a lot about mentoring these days, and that's great. However, most of the conversation is around mentoring people to contribute code to a project. There are many different ways to contribute to free and open source software projects beyond programming. A robust succession plan recognizes these other forms of contribution and provides mentoring to prepare people to step into critical non-programming roles. - * **Inspiration for new members** : It can be very motivational for new or prospective community members to see that a project uses its succession plan. Not only does it show them that the project is well-organized and considers its own health and welfare as well as that of its members, but it also clearly shows new members how they can grow in the community. An obvious path to critical roles and leadership positions inspires new members to stick around to walk that path. - * **Diversity of thoughts/get out of a rut** : Succession plans provide excellent opportunities to bring in new people and ideas to the critical roles of a project. [Studies show][8] that diverse leadership teams are more effective and the projects they lead are more innovative. Using your project's succession plan to mentor people from different backgrounds and with different perspectives will help strengthen and evolve the project in a healthy way. - * **Enabling meritocracy** : Unfortunately, what often passes for meritocracy in many free and open source projects is thinly veiled hostility toward new contributors and diverse opinions—hostility that's delivered from within an echo chamber. Meritocracy without a mentoring program and healthy governance structure is simply an excuse to practice subjective discrimination while hiding behind unexpressed biases. A well-executed succession plan helps teams reach the goal of a true meritocracy. What counts as merit for any given role, and how to reach that level of merit, are openly, honestly, and completely documented. The entire community will be able to see and judge which members are on the path or deserve to take on a particular critical role. - - - -### Why it doesn't happen - -Succession planning isn't a panacea, and it won't solve all problems for all projects, but as described above, it offers a lot of worthwhile benefits to your project. - -Despite that, very few free and open source projects or organizations put much thought into it. I was curious why that might be, so I asked around. I learned that the reasons for not having a succession plan fall into one of five different buckets: - - * **Too busy** : Many people recognize succession planning (or lack thereof) as a problem for their project but just "hadn't ever gotten around to it" because there's "always something more important to work on." I understand and sympathize with this, but I suspect the problem may have more to do with prioritization than with time availability. - * **Don't think of it** : Some people are so busy and preoccupied that they haven't considered, "Hey, what would happen if Jen had to leave the project?" This never occurs to them. After all, Jen's always been there when they need her, right? And that will always be the case, right? - * **Don't want to think of it** : Succession planning shares a trait with estate planning: It's associated with negative feelings like loss and can make people address their own mortality. Some people are uncomfortable with this and would rather not consider it at all than take the time to make the inevitable easier for those they leave behind. - * **Attitude of current leaders** : A few of the people with whom I spoke didn't want to recognize that they're replaceable, or to consider that they may one day give up their power and influence on the project. While this was (thankfully) not a common response, it was alarming enough to deserve its own bucket. Failure of someone in a critical role to recognize or admit that they won't be around forever can set a project up for failure in the long run. - * **Don't know where to start** : Many people I interviewed realize that succession planning is something that their project should be doing. They were even willing to carve out the time to tackle this very large task. What they lacked was any guidance on how to start the process of creating a succession plan. - - - -As you can imagine, something as important and people-focused as a succession plan isn't easy to create, and it doesn't happen overnight. Also, there are many different ways to do it. Each project has its own needs and critical roles. One size does not fit all where succession plans are concerned. - -There are, however, some guidelines for how every project could proceed with the succession plan creation process. I'll cover these guidelines in my next article. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/passing-baton-succession-planning-foss-leadership - -作者:[VM(Vicky) Brasseur][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/vmbrasseur -[1]:http://www.fsf.org -[2]:https://opensource.com/article/17/10/perl-turns-30 -[3]:https://opensource.com/article/18/2/coining-term-open-source-software -[4]:https://opensource.org -[5]:https://opensource.org/node/910 -[6]:https://octoverse.github.com -[7]:https://en.wikipedia.org/wiki/Succession_planning -[8]:https://hbr.org/2016/11/why-diverse-teams-are-smarter diff --git a/sources/talk/20180417 How to develop the FOSS leaders of the future.md b/sources/talk/20180417 How to develop the FOSS leaders of the future.md deleted file mode 100644 index a65dc9dabd..0000000000 --- a/sources/talk/20180417 How to develop the FOSS leaders of the future.md +++ /dev/null @@ -1,93 +0,0 @@ -How to develop the FOSS leaders of the future -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_paperclips.png?itok=j48op49T) -Do you hold a critical role in a free and open source software project? Would you like to make it easier for the next person to step into your shoes, while also giving yourself the freedom to take breaks and avoid burnout? - -Of course you would! But how do you get started? - -Before you do anything, remember that this is a free or open source project. As with all things in FOSS, your succession planning should happen in collaboration with others. The [Principle of Least Astonishment][1] also applies: Don't work on your plan in isolation, then spring it on the entire community. Work together and publicly, so no one is caught off guard when the cultural or governance changes start happening. - -### Identify and analyse critical roles - -As a project leader, your first step is to identify the critical roles in your community. While it can help to ask each community members what role they perform, it's important to realize that most people perform multiple roles. Make sure you consider every role that each community member plays in the project. - -Once you've identified the roles and determined which ones are critical to your project, the next step is to list all of the duties and responsibilities for each of those critical roles. Be very honest here. List the duties and responsibilities you think each role has, then ask the person who performs that role to list the duties the role actually has. You'll almost certainly find that the second list is longer than the first. - -### Refactor large roles - -During this process, have you discovered any roles that encompass a large number of duties and responsibilities? Large roles are like large methods in your code: They're a sign of a problem, and they need to be refactored to make them easier to maintain. One of the easiest and most effective steps in succession planning for FOSS projects is to split up each large role into two or more smaller roles and distribute these to other community members. With that one step, you've greatly improved the [bus factor][2] for your project. Even better, you've made each one of those new, smaller roles much more accessible and less intimidating for new community members. People are much more likely to volunteer for a role if it's not a massive burden. - -### Limit role tenure - -Another way to make a role more enticing is to limit its tenure. Community members will be more willing to step into roles that aren't open-ended. They can look at their life and work plans and ask themselves, "Can I take on this role for the next eighteen months?" (or whatever term limit you set). - -Setting term limits also helps those who are currently performing the role. They know when they can set aside those duties and move on to something else, which can help alleviate burnout. Also, setting a term limit creates a pool of people who have performed the role and are qualified to step in if needed, which can also mitigate burnout. - -### Knowledge transfer - -Once you've identified and defined the critical roles in your project, most of what remains is knowledge transfer. Even small projects involve a lot of moving parts and knowledge that needs to be where everyone can see, share, use, and contribute to it. What sort of knowledge should you be collecting? The answer will vary by project, needs, and role, but here are some of the most common (and commonly overlooked) types of information needed to implement a succession plan: - - * **Roles and their duties** : You've spent a lot of time identifying, analyzing, and potentially refactoring roles and their duties. Make sure this information doesn't get lost. - * **Policies and procedures** : None of those duties occur in a vacuum. Each duty must be performed in a particular way (procedures) when particular conditions are met (policies). Take stock of these details for every duty of every role. - * **Resources** : What accounts are associated with the project, or are necessary for it to operate? Who helps you with meetup space, sponsorship, or in-kind services? Such information is vital to project operation but can be easily lost when the responsible community member moves on. - * **Credentials** : Ideally, every external service required by the project will use a login that goes to an email address designated for a specific role (`sre@project.org`) rather than to a personal address. Every role's address should include multiple people on the distribution list to ensure that important messages (such as downtime or bogus "forgot password" requests) aren't missed. The credentials for every service should be kept in a secure keystore, with access limited to the fewest number of people possible. - * **Project history** : All community members benefit greatly from learning the history of the project. Collecting project history information can clarify why decisions were made in the past, for example, and reveal otherwise unexpressed requirements and values of the community. Project histories can also help new community members understand "inside jokes," jargon, and other cultural factors. - * **Transition plans** : A succession plan doesn't do much good if project leaders haven't thought through how to transition a role from one person to another. How will you locate and prepare people to take over a critical role? Since the project has already done a lot of thinking and knowledge transfer, transition plans for each role may be easier to put together. - - - -Doing a complete knowledge transfer for all roles in a project can be an enormous undertaking, but the effort is worth it. To avoid being overwhelmed by such a daunting task, approach it one role at a time, finishing each one before you move onto the next. Limiting the scope in this way makes both progress and success much more likely. - -### Document, document, document! - -Succession planning takes time. The community will be making a lot of decisions and collecting a lot of information, so make sure nothing gets lost. It's important to document everything (not just in email threads). Where knowledge is concerned, documentation scales and people do not. Include even the things that you think are obvious—what's obvious to a more seasoned community member may be less so to a newbie, so don't skip steps or information. - -Gather these decisions, processes, policies, and other bits of information into a single place, even if it's just a collection of markdown files in the main project repository. The "how" and "where" of the documentation can be sorted out later. It's better to capture key information first and spend time [bike-shedding][3] a documentation system later. - -Once you've collected all of this information, you should understand that it's unlikely that anyone will read it. I know, it seems unfair, but that's just how things usually work out. The reason? There is simply too much documentation and too little time. To address this, add an abstract, or summary, at the top of each item. Often that's all a person needs, and if not, the complete document is there for a deep dive. Recognizing and adapting to how most people use documentation increases the likelihood that they will use yours. - -Above all, don't skip the documentation process. Without documentation, succession plans are impossible. - -### New leaders - -If you don't yet perform a critical role but would like to, you can contribute to the succession planning process while apprenticing your way into one of those roles. - -For starters, actively look for opportunities to learn and contribute. Shadow people in critical roles. You'll learn how the role is done, and you can document it to help with the succession planning process. You'll also get the opportunity to see whether it's a role you're interested in pursuing further. - -Asking for mentorship is a great way to get yourself closer to taking on a critical role in the project. Even if you haven't heard that mentoring is available, it's perfectly OK to ask about it. The people already in those roles are usually happy to mentor others, but often are too busy to think about offering mentorship. Asking is a helpful reminder to them that they should be helping to train people to take over their role when they need a break. - -As you perform your own tasks, actively seek out feedback. This will not only improve your skills, but it shows that you're interested in doing a better job for the community. This commitment will pay off when your project needs people to step into critical roles. - -Finally, as you communicate with more experienced community members, take note of anecdotes about the history of the project and how it operates. This history is very important, especially for new contributors or people stepping into critical roles. It provides the context necessary for new contributors to understand what things do or don't work and why. As you hear these stories, document them so they can be passed on to those who come after you. - -### Succession planning examples - -While too few FOSS projects are actively considering succession planning, some are doing a great job of trying to reduce their bus factor and prevent maintainer burnout. - -[Exercism][4] isn't just an excellent tool for gaining fluency in programming languages. It's also an [open source project][5] that goes out of its way to help contributors [land their first patch][6]. In 2016, the project reviewed the health of each language track and [discovered that many were woefully maintained][7]. There simply weren't enough people covering each language, so maintainers were burning out. The Exercism community recognized the risk this created and pushed to find new maintainers for as many language tracks as possible. As a result, the project was able to revive several tracks from near-death and develop a structure for inviting people to become maintainers. - -The purpose of the [Vox Pupuli][8] project is to serve as a sort of succession plan for the [Puppet module][9] community. When a maintainer no longer wishes or is able to work on their module, they can bequeath it to the Vox Pupuli community. This community of 30 collaborators shares responsibility for maintaining all the modules it accepts into the project. The large number of collaborators ensures that no single person bears the burden of maintenance while also providing a long and fruitful life for every module in the project. - -These are just two examples of how some FOSS projects are tackling succession planning. Share your stories in the comments below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/succession-planning-how-develop-foss-leaders-future - -作者:[VM(Vicky) Brasseur)][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/vmbrasseur -[1]:https://en.wikipedia.org/wiki/Principle_of_least_astonishment -[2]:https://en.wikipedia.org/wiki/Bus_factor -[3]:https://en.wikipedia.org/wiki/Law_of_triviality -[4]:http://exercism.io -[5]:https://github.com/exercism/exercism.io -[6]:https://github.com/exercism/exercism.io/blob/master/CONTRIBUTING.md -[7]:https://tinyletter.com/exercism/letters/exercism-track-health-check-new-maintainers -[8]:https://voxpupuli.org -[9]:https://forge.puppet.com diff --git a/sources/talk/20180418 Is DevOps compatible with part-time community teams.md b/sources/talk/20180418 Is DevOps compatible with part-time community teams.md deleted file mode 100644 index e78b96959f..0000000000 --- a/sources/talk/20180418 Is DevOps compatible with part-time community teams.md +++ /dev/null @@ -1,73 +0,0 @@ -Is DevOps compatible with part-time community teams? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard.png?itok=kBeRTFL1) -DevOps seems to be the talk of the IT world of late—and for good reason. DevOps has streamlined the process and production of IT development and operations. However, there is also an upfront cost to embracing a DevOps ideology, in terms of time, effort, knowledge, and financial investment. Larger companies may have the bandwidth, budget, and time to make the necessary changes, but is it feasible for part-time, resource-strapped communities? - -Part-time communities are teams of like-minded people who take on projects outside of their normal work schedules. The members of these communities are driven by passion and a shared purpose. For instance, one such community is the [ALM | DevOps Rangers][1]. With 100 rangers engaged across the globe, a DevOps solution may seem daunting; nonetheless, they took on the challenge and embraced the ideology. Through their example, we've learned that DevOps is not only feasible but desirable in smaller teams. To read about their transformation, check out [How DevOps eliminates development bottlenecks][2]. - -> “DevOps is the union of people, process, and products to enable continuous delivery of value to our end customers.” - Donovan Brown - -### The cost of DevOps - -As stated above, there is an upfront "cost" to DevOps. The cost manifests itself in many forms, such as the time and collaboration between development, operations, and other stakeholders, planning a smooth-flowing process that delivers continuous value, finding the best DevOps products, and training the team in new technologies, to name a few. This aligns directly with Donovan's definition of DevOps, in fact—a **process** for delivering **continuous value** and the **people** who make that happen. - -Streamlined DevOps takes a lot of planning and training just to create the process, and that doesn't even consider the testing phase. We also can't forget the existing in-flight projects that need to be converted into the new system. While the cost increases the more pervasive the transformation—for instance, if an organization aims to unify its entire development organization under a single process, then that would cost more versus transforming a single pilot or subset of the entire portfolio—these upfront costs must be addressed regardless of their scale. There are a lot of resources and products already out there that can be implemented for a smoother transition—but again, we face the time and effort that will be necessary just to research which ones might work best. - -In the case of the ALM | DevOps Rangers, they had to halt all projects for a couple of sprints to set up the initial process. Many organizations would not be able to do that. Even part-time groups might have very good reasons to keep things moving, which only adds to the complexity. In such scenarios, additional cutover planning (and therefore additional cost) is needed, and the overall state of the community is one of flux and change, which adds risk, which—you guessed it—requires more cost to mitigate. - -There is also an ongoing "cost" that teams will face with a DevOps mindset: Simple maintenance of the system, training and transitioning new team members, and keeping up with new, improved technologies are all a part of the process. - -### DevOps for a part-time community - -Whereas larger companies can dedicate a single manager or even a team to the task over overseeing the continuous integration and continuous deployment (CI/CD) pipelines, part-time community teams don't have the bandwidth to give. With such a massive undertaking we must ask: Is it even worth it for groups with fewer resources to take on DevOps for their community? Or should they abandon the idea of DevOps altogether? - -The answer to that is dependent on a few variables, such as the ability of the teams to be self-managing, the time and effort each member is willing to put into the transformation, and the dedication of the community to the process. - -### Example: Benefits of DevOps in a part-time community - -Luckily, we aren't without examples to demonstrate just how DevOps can benefit a smaller group. Let's take a quick look at the ALM Rangers again. The results from their transformation help us understand how DevOps changed their community: - -![](https://opensource.com/sites/default/files/images/life-uploads/devops.png) - -As illustrated, there are some huge benefits for part-time community teams. Planning goes from long, arduous design sessions to a quick prototyping and storyboarding process. Builds become automated, reliable, and resilient. Testing and bug detection are proactive instead of reactive, which turns into a happier clientele. Multiple full-time program managers are replaced with self-managing teams with a single part-time manager to oversee projects. Teams become smaller and more efficient, which equates to higher production rates and higher-quality project delivery. With results like these, it's hard to argue against DevOps. - -Still, the upfront and ongoing costs aren't right for every community. The number-one most important aspect of any DevOps transformation is the mindset of the people involved. Adopting the idea of self-managing teams who work in autonomy instead of the traditional chain-of-command scheme can be a challenge for any group. The members must be willing to work independently without a lot of oversight and take ownership of their features and user experience, but at the same time, work in a setting that is fully transparent to the rest of the community. **The success or failure of a DevOps strategy lies on the team.** - -### Making the DevOps transition in 4 steps - -Another important question to ask: How can a low-bandwidth group make such a massive transition? The good news is that a DevOps transformation doesn’t need to happen all at once. Taken in smaller, more manageable steps, organizations of any size can embrace DevOps. - - 1. Determine why DevOps may be the solution you need. Are your projects bottlenecking? Are they running over budget and over time? Of course, these concerns are common for any community, big or small. Answering these questions leads us to step two: - 2. Develop the right framework to improve the engineering process. DevOps is all about automation, collaboration, and streamlining. Rather than trying to fit everyone into the same process box, the framework should support the work habits, preferences, and delivery needs of the community. Some broad standards should be established (for example, that all teams use a particular version control system). Beyond that, however, let the teams decide their own best process. - 3. Use the current products that are already available if they meet your needs. Why reinvent the wheel? - 4. Finally, implement and test the actual DevOps solution. This is, of course, where the actual value of DevOps is realized. There will likely be a few issues and some heartburn, but it will all be worth it in the end because, once established, the products of the community’s work will be nimbler and faster for the users. - - - -### Reuse DevOps solutions - -One benefit to creating effective CI/CD pipelines is the reusability of those pipelines. Although there is no one-size fits all solution, anyone can adopt a process. There are several pre-made templates available for you to examine, such as build templates on VSTS, ARM templates to deploy Azure resources, and "cookbook"-style textbooks from technical publishers. Once it identifies a process that works well, a community can also create its own template by defining and establishing standards and making that template easily discoverable by the entire community. For more information on DevOps journeys and tools, check out [this site][3]. - -### Summary - -Overall, the success or failure of DevOps relies on the culture of a community. It doesn't matter if the community is a large, resource-rich enterprise or a small, resource-sparse, part-time group. DevOps will still bring solid benefits. The difference is in the approach for adoption and the scale of that adoption. There are both upfront and ongoing costs, but the value greatly outweighs those costs. Communities can use any of the powerful tools available today for their pipelines, and they can also leverage reusability, such as templates, to reduce upfront implementation costs. DevOps is most certainly feasible—and even critical—for the success of part-time community teams. - -**[See our related story,[How DevOps eliminates development bottlenecks][4].]** - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/devops-compatible-part-time-community-teams - -作者:[Edward Fry][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者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/edwardf -[1]:https://github.com/ALM-Rangers -[2]:https://opensource.com/article/17/11/devops-rangers-transformation -[3]:https://www.visualstudio.com/devops/ -[4]:https://opensource.com/article/17/11/devops-rangers-transformation diff --git a/sources/talk/20180419 3 tips for organizing your open source project-s workflow on GitHub.md b/sources/talk/20180419 3 tips for organizing your open source project-s workflow on GitHub.md deleted file mode 100644 index 29e4ea2f48..0000000000 --- a/sources/talk/20180419 3 tips for organizing your open source project-s workflow on GitHub.md +++ /dev/null @@ -1,109 +0,0 @@ -3 tips for organizing your open source project's workflow on GitHub -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ) - -Managing an open source project is challenging work, and the challenges grow as a project grows. Eventually, a project may need to meet different requirements and span multiple repositories. These problems aren't technical, but they are important to solve to scale a technical project. [Business process management][1] methodologies such as agile and [kanban][2] bring a method to the madness. Developers and managers can make realistic decisions for estimating deadlines and team bandwidth with an organized development focus. - -At the [UNICEF Office of Innovation][3], we use GitHub project boards to organize development on the MagicBox project. [MagicBox][4] is a full-stack application and open source platform to serve and visualize data for decision-making in humanitarian crises and emergencies. The project spans multiple GitHub repositories and works with multiple developers. With GitHub project boards, we organize our work across multiple repositories to better understand development focus and team bandwidth. - -Here are three tips from the UNICEF Office of Innovation on how to organize your open source projects with the built-in project boards on GitHub. - -### 1\. Bring development discussion to issues and pull requests - -Transparency is a critical part of an open source community. When mapping out new features or milestones for a project, the community needs to see and understand a decision or why a specific direction was chosen. Filing new GitHub issues for features and milestones is an easy way for someone to follow the project direction. GitHub issues and pull requests are the cards (or building blocks) of project boards. To be successful with GitHub project boards, you need to use issues and pull requests. - - -![GitHub issues for magicbox-maps, MagicBox's front-end application][6] - -GitHub issues for magicbox-maps, MagicBox's front-end application. - -The UNICEF MagicBox team uses GitHub issues to track ongoing development milestones and other tasks to revisit. The team files new GitHub issues for development goals, feature requests, or bugs. These goals or features may come from external stakeholders or the community. We also use the issues as a place for discussion on those tasks. This makes it easy to cross-reference in the future and visualize upcoming work on one of our projects. - -Once you begin using GitHub issues and pull requests as a way of discussing and using your project, organizing with project boards becomes easier. - -### 2\. Set up kanban-style project boards - -GitHub issues and pull requests are the first step. After you begin using them, it may become harder to visualize what work is in progress and what work is yet to begin. [GitHub's project boards][7] give you a platform to visualize and organize cards into different columns. - -There are two types of project boards available: - - * **Repository** : Boards for use in a single repository - * **Organization** : Boards for use in a GitHub organization across multiple repositories (but private to organization members) - - - -The choice you make depends on the structure and size of your projects. The UNICEF MagicBox team uses boards for development and documentation at the organization level, and then repository-specific boards for focused work (like our [community management board][8]). - -#### Creating your first board - -Project boards are found on your GitHub organization page or on a specific repository. You will see the Projects tab in the same row as Issues and Pull requests. From the page, you'll see a green button to create a new project. - -There, you can set a name and description for the project. You can also choose templates to set up basic columns and sorting for your board. Currently, the only options are for kanban-style boards. - - -![Creating a new GitHub project board.][10] - -Creating a new GitHub project board. - -After creating the project board, you can make adjustments to it as needed. You can create new columns, [set up automation][11], and add pre-existing GitHub issues and pull requests to the project board. - -You may notice new options for the metadata in each GitHub issue and pull request. Inside of an issue or pull request, you can add it to a project board. If you use automation, it will automatically enter a column you configured. - -### 3\. Build project boards into your workflow - -After you set up a project board and populate it with issues and pull requests, you need to integrate it into your workflow. Project boards are effective only when actively used. The UNICEF MagicBox team uses the project boards as a way to track our progress as a team, update external stakeholders on development, and estimate team bandwidth for reaching our milestones. - - -![Tracking progress][13] - -Tracking progress with GitHub project boards. - -If you are an open source project and community, consider using the project boards for development-focused meetings. It also helps remind you and other core contributors to spend five minutes each day updating progress as needed. If you're at a company using GitHub to do open source work, consider using project boards to update other team members and encourage participation inside of GitHub issues and pull requests. - -Once you begin using the project board, yours may look like this: - - -![Development progress board][15] - -Development progress board for all UNICEF MagicBox repositories in organization-wide GitHub project boards. - -### Open alternatives - -GitHub project boards require your project to be on GitHub to take advantage of this functionality. While GitHub is a popular repository for open source projects, it's not an open source platform itself. Fortunately, there are open source alternatives to GitHub with tools to replicate the workflow explained above. [GitLab Issue Boards][16] and [Taiga][17] are good alternatives that offer similar functionality. - -### Go forth and organize! - -With these tools, you can bring a method to the madness of organizing your open source project. These three tips for using GitHub project boards encourage transparency in your open source project and make it easier to track progress and milestones in the open. - -Do you use GitHub project boards for your open source project? Have any tips for success that aren't mentioned in the article? Leave a comment below to share how you make sense of your open source projects. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/4/keep-your-project-organized-git-repo - -作者:[Justin W.Flory][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者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/jflory -[1]:https://en.wikipedia.org/wiki/Business_process_management -[2]:https://en.wikipedia.org/wiki/Kanban_(development) -[3]:http://unicefstories.org/about/ -[4]:http://unicefstories.org/magicbox/ -[5]:/file/393356 -[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-open-issues.png?itok=OcWPX575 (GitHub issues for magicbox-maps, MagicBox's front-end application) -[7]:https://help.github.com/articles/about-project-boards/ -[8]:https://github.com/unicef/magicbox/projects/3?fullscreen=true -[9]:/file/393361 -[10]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-project-boards-create-board.png?itok=pp7SXH9g (Creating a new GitHub project board.) -[11]:https://help.github.com/articles/about-automation-for-project-boards/ -[12]:/file/393351 -[13]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-issues-metadata.png?itok=xp5auxCQ (Tracking progress) -[14]:/file/393366 -[15]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/github-project-boards-overview.png?itok=QSbOOOkF (Development progress board) -[16]:https://about.gitlab.com/features/issueboard/ -[17]:https://taiga.io/ diff --git a/sources/talk/20180420 What You Don-t Know About Linux Open Source Could Be Costing to More Than You Think.md b/sources/talk/20180420 What You Don-t Know About Linux Open Source Could Be Costing to More Than You Think.md deleted file mode 100644 index 10511c3a7d..0000000000 --- a/sources/talk/20180420 What You Don-t Know About Linux Open Source Could Be Costing to More Than You Think.md +++ /dev/null @@ -1,39 +0,0 @@ -What You Don’t Know About Linux Open Source Could Be Costing to More Than You Think -====== - -If you would like to test out Linux before completely switching it as your everyday driver, there are a number of means by which you can do it. Linux was not intended to run on Windows, and Windows was not meant to host Linux. To begin with, and perhaps most of all, Linux is open source computer software. In any event, Linux outperforms Windows on all your hardware. - -If you’ve always wished to try out Linux but were never certain where to begin, have a look at our how to begin guide for Linux. Linux is not any different than Windows or Mac OS, it’s basically an Operating System but the leading different is the fact that it is Free for everyone. Employing Linux today isn’t any more challenging than switching from one sort of smartphone platform to another. - -You’re most likely already using Linux, whether you are aware of it or not. Linux has a lot of distinct versions to suit nearly any sort of user. Today, Linux is a small no-brainer. Linux plays an essential part in keeping our world going. - -Even then, it is dependent on the build of Linux that you’re using. Linux runs a lot of the underbelly of cloud operations. Linux is also different in that, even though the core pieces of the Linux operating system are usually common, there are lots of distributions of Linux, like different software alternatives. While Linux might seem intimidatingly intricate and technical to the ordinary user, contemporary Linux distros are in reality very user-friendly, and it’s no longer the case you have to have advanced skills to get started using them. Linux was the very first major Internet-centred open-source undertaking. Linux is beginning to increase the range of patches it pushes automatically, but several of the security patches continue to be opt-in only. - -You are able to remove Linux later in case you need to. Linux plays a vital part in keeping our world going. Linux supplies a huge library of functionality which can be leveraged to accelerate development. - -Even then, it’s dependent on the build of Linux that you’re using. Linux is also different in that, even though the core pieces of the Linux operating system are typically common, there are lots of distributions of Linux, like different software alternatives. While Linux might seem intimidatingly intricate and technical to the ordinary user, contemporary Linux distros are in fact very user-friendly, and it’s no longer the case you require to have advanced skills to get started using them. Linux runs a lot of the underbelly of cloud operations. Linux is beginning to increase the range of patches it pushes automatically, but several of the security patches continue to be opt-in only. Read More, open source projects including Linux are incredibly capable because of the contributions that all these individuals have added over time. - -### Life After Linux Open Source - -The development edition of the manual typically has more documentation, but might also document new characteristics that aren’t in the released version. Fortunately, it’s so lightweight you can just jump to some other version in case you don’t like it. It’s extremely hard to modify the compiled version of the majority of applications and nearly not possible to see exactly the way the developer created different sections of the program. - -On the challenges of bottoms-up go-to-market It’s really really hard to grasp the difference between your organic product the product your developers use and love and your company product, which ought to be, effectively, a different product. As stated by the report, it’s going to be hard for developers to switch. Developers are now incredibly important and influential in the purchasing procedure. Some OpenWrt developers will attend the event and get ready to reply to your questions! - -When the program is installed, it has to be configured. Suppose you discover that the software you bought actually does not do what you would like it to do. Open source software is much more common than you believe, and an amazing philosophy to live by. Employing open source software gives an inexpensive method to bootstrap a business. It’s more difficult to deal with closed source software generally. So regarding Application and Software, you’re all set if you are prepared to learn an alternate software or finding a means to make it run on Linux. Possibly the most famous copyleft software is Linux. - -Article sponsored by [Vegas Palms online slots][1] - - --------------------------------------------------------------------------------- - -via: https://linuxaria.com/article/what-you-dont-know-about-linux-open-source-could-be-costing-to-more-than-you-think - -作者:[Marc Fisher][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://linuxaria.com -[1]:https://www.vegaspalmscasino.com/casino-games/slots/ diff --git a/sources/talk/20180424 There-s a Server in Every Serverless Platform.md b/sources/talk/20180424 There-s a Server in Every Serverless Platform.md deleted file mode 100644 index 9bc935c06d..0000000000 --- a/sources/talk/20180424 There-s a Server in Every Serverless Platform.md +++ /dev/null @@ -1,87 +0,0 @@ -There’s a Server in Every Serverless Platform -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/servers.jpg?itok=i_gyObMP) -Serverless computing or Function as a Service (FaaS) is a new buzzword created by an industry that loves to coin new terms as market dynamics change and technologies evolve. But what exactly does it mean? What is serverless computing? - -Before getting into the definition, let’s take a brief history lesson from Sirish Raghuram, CEO and co-founder of Platform9, to understand the evolution of serverless computing. - -“In the 90s, we used to build applications and run them on hardware. Then came virtual machines that allowed users to run multiple applications on the same hardware. But you were still running the full-fledged OS for each application. The arrival of containers got rid of OS duplication and process level isolation which made it lightweight and agile,” said Raghuram. - -Serverless, specifically, Function as a Service, takes it to the next level as users are now able to code functions and run them at the granularity of build, ship and run. There is no complexity of underlying machinery needed to run those functions. No need to worry about spinning containers using Kubernetes. Everything is hidden behind the scenes. - -“That’s what is driving a lot of interest in function as a service,” said Raghuram. - -### What exactly is serverless? - -There is no single definition of the term, but to build some consensus around the idea, the [Cloud Native Computing Foundation (CNCF)][1] Serverless Working Group wrote a [white paper][2] to define serverless computing. - -According to the white paper, “Serverless computing refers to the concept of building and running applications that do not require server management. It describes a finer-grained deployment model where applications, bundled as one or more functions, are uploaded to a platform and then executed, scaled, and billed in response to the exact demand needed at the moment.” - -Ken Owens, a member of the Technical Oversight Committee at CNCF said that the primary goal of serverless computing is to help users build and run their applications without having to worry about the cost and complexity of servers in terms of provisioning, management and scaling. - -“Serverless is a natural evolution of cloud-native computing. The CNCF is advancing serverless adoption through collaboration and community-driven initiatives that will enable interoperability,” [said][3] Chris Aniszczyk, COO, CNCF. - -### It’s not without servers - -First things first, don’t get fooled by the term “serverless.” There are still servers in serverless computing. Remember what Raghuram said: all the machinery is hidden; it’s not gone. - -The clear benefit here is that developers need not concern themselves with tasks that don’t add any value to their deliverables. Instead of worrying about managing the function, they can dedicate their time to adding featured and building apps that add business value. Time is money and every minute saved in management goes toward innovation. Developers don’t have to worry about scaling based on peaks and valleys; it’s automated. Because cloud providers charge only for the duration that functions are run, developers cut costs by not having to pay for blinking lights. - -But… someone still has to do the work behind the scenes. There are still servers offering FaaS platforms. - -In the case of public cloud offerings like Google Cloud Platform, AWS, and Microsoft Azure, these companies manage the servers and charge customers for running those functions. In the case of private cloud or datacenters, where developers don’t have to worry about provisioning or interacting with such servers, there are other teams who do. - -The CNCF white paper identifies two groups of professionals that are involved in the serverless movement: developers and providers. We have already talked about developers. But, there are also providers that offer serverless platforms; they deal with all the work involved in keeping that server running. - -That’s why many companies, like SUSE, refrain from using the term “serverless” and prefer the term function as a service, because they offer products that run those “serverless” servers. But what kind of functions are these? Is it the ultimate future of app delivery? - -### Event-driven computing - -Many see serverless computing as an umbrella that offers FaaS among many other potential services. According to CNCF, FaaS provides event-driven computing where functions are triggered by events or HTTP requests. “Developers run and manage application code with functions that are triggered by events or HTTP requests. Developers deploy small units of code to the FaaS, which are executed as needed as discrete actions, scaling without the need to manage servers or any other underlying infrastructure,” said the white paper. - -Does that mean FaaS is the silver bullet that solves all problems for developing and deploying applications? Not really. At least not at the moment. FaaS does solve problems in several use cases and its scope is expanding. A good use case of FaaS could be the functions that an application needs to run when an event takes place. - -Let’s take an example: a user takes a picture from a phone and uploads it to the cloud. Many things happen when the picture is uploaded - it’s scanned (exif data is read), a thumbnail is created, based on deep learning/machine learning the content of the image is analyzed, the information of the image is stored in the database. That one event of uploading that picture triggers all those functions. Those functions die once the event is over. That’s what FaaS does. It runs code quickly to perform all those tasks and then disappears. - -That’s just one example. Another example could be an IoT device where a motion sensor triggers an event that instructs the camera to start recording and sends the clip to the designated contant. Your thermostat may trigger the fan when the sensor detects a change in temperature. These are some of the many use cases where function as a service make more sense than the traditional approach. Which also says that not all applications (at least at the moment, but that will change as more organizations embrace the serverless platform) can be run as function as service. - -According to CNCF, serverless computing should be considered if you have these kinds of workloads: - - * Asynchronous, concurrent, easy to parallelize into independent units of work - - * Infrequent or has sporadic demand, with large, unpredictable variance in scaling requirements - - * Stateless, ephemeral, without a major need for instantaneous cold start time - - * Highly dynamic in terms of changing business requirements that drive a need for accelerated developer velocity - - - - -### Why should you care? - -Serverless is a very new technology and paradigm, just the way VMs and containers transformed the app development and delivery models, FaaS can also bring dramatic changes. We are still in the early days of serverless computing. As the market evolves, consensus is created and new technologies evolve, and FaaS may grow beyond the workloads and use cases mentioned here. - -What is becoming quite clear is that companies who are embarking on their cloud native journey must have serverless computing as part of their strategy. The only way to stay ahead of competitors is by keeping up with the latest technologies and trends. - -It’s about time to put serverless into servers. - -For more information, check out the CNCF Working Group's serverless whitepaper [here][2]. And, you can learn more at [KubeCon + CloudNativeCon Europe][4], coming up May 2-4 in Copenhagen, Denmark. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/2018/4/theres-server-every-serverless-platform - -作者:[SWAPNIL BHARTIYA][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/arnieswap -[1]:https://www.cncf.io/ -[2]:https://github.com/cncf/wg-serverless/blob/master/whitepaper/cncf_serverless_whitepaper_v1.0.pdf -[3]:https://www.cncf.io/blog/2018/02/14/cncf-takes-first-step-towards-serverless-computing/ -[4]:https://events.linuxfoundation.org/events/kubecon-cloudnativecon-europe-2018/attend/register/ diff --git a/sources/talk/20180511 Looking at the Lispy side of Perl.md b/sources/talk/20180511 Looking at the Lispy side of Perl.md deleted file mode 100644 index 1fa51b314c..0000000000 --- a/sources/talk/20180511 Looking at the Lispy side of Perl.md +++ /dev/null @@ -1,357 +0,0 @@ -Looking at the Lispy side of Perl -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_cloud_database.png?itok=lhhU42fg) -Some programming languages (e.g., C) have named functions only, whereas others (e.g., Lisp, Java, and Perl) have both named and unnamed functions. A lambda is an unnamed function, with Lisp as the language that popularized the term. Lambdas have various uses, but they are particularly well-suited for data-rich applications. Consider this depiction of a data pipeline, with two processing stages shown: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/images/life-uploads/data_source.png?itok=OON2cC2R) - -### Lambdas and higher-order functions - -The filter and transform stages can be implemented as higher-order functions—that is, functions that can take a function as an argument. Suppose that the depicted pipeline is part of an accounts-receivable application. The filter stage could consist of a function named `filter_data`, whose single argument is another function—for example, a `high_buyers` function that filters out amounts that fall below a threshold. The transform stage might convert amounts in U.S. dollars to equivalent amounts in euros or some other currency, depending on the function plugged in as the argument to the higher-order `transform_data` function. Changing the filter or the transform behavior requires only plugging in a different function argument to the higher order `filter_data` or `transform_data` functions. - -Lambdas serve nicely as arguments to higher-order functions for two reasons. First, lambdas can be crafted on the fly, and even written in place as arguments. Second, lambdas encourage the coding of pure functions, which are functions whose behavior depends solely on the argument(s) passed in; such functions have no side effects and thereby promote safe concurrent programs. - -Perl has a straightforward syntax and semantics for lambdas and higher-order functions, as shown in the following example: - -### A first look at lambdas in Perl - -``` -#!/usr/bin/perl - -use strict; -use warnings; - -## References to lambdas that increment, decrement, and do nothing. -## $_[0] is the argument passed to each lambda. -my $inc = sub { $_[0] + 1 };  ## could use 'return $_[0] + 1' for clarity -my $dec = sub { $_[0] - 1 };  ## ditto -my $nop = sub { $_[0] };      ## ditto - -sub trace { -    my ($val, $func, @rest) = @_; -    print $val, " ", $func, " ", @rest, "\nHit RETURN to continue...\n"; -    <STDIN>; -} - -## Apply an operation to a value. The base case occurs when there are -## no further operations in the list named @rest. -sub apply { -    my ($val, $first, @rest) = @_; -    trace($val, $first, @rest) if 1;  ## 0 to stop tracing - -    return ($val, apply($first->($val), @rest)) if @rest; ## recursive case -    return ($val, $first->($val));                        ## base case -} - -my $init_val = 0; -my @ops = (                        ## list of lambda references -    $inc, $dec, $dec, $inc, -    $inc, $inc, $inc, $dec, -    $nop, $dec, $dec, $nop, -    $nop, $inc, $inc, $nop -    ); - -## Execute. -print join(' ', apply($init_val, @ops)), "\n"; -## Final line of output: 0 1 0 -1 0 1 2 3 2 2 1 0 0 0 1 2 2strictwarningstraceSTDINapplytraceapplyapply -``` - -The lispy program shown above highlights the basics of Perl lambdas and higher-order functions. Named functions in Perl start with the keyword `sub` followed by a name: -``` -sub increment { ... }   # named function - -``` - -An unnamed or anonymous function omits the name: -``` -sub {...}               # lambda, or unnamed function - -``` - -In the lispy example, there are three lambdas, and each has a reference to it for convenience. Here, for review, is the `$inc` reference and the lambda referred to: -``` -my $inc = sub { $_[0] + 1 }; - -``` - -The lambda itself, the code block to the right of the assignment operator `=`, increments its argument `$_[0]` by 1. The lambda’s body is written in Lisp style; that is, without either an explicit `return` or a semicolon after the incrementing expression. In Perl, as in Lisp, the value of the last expression in a function’s body becomes the returned value if there is no explicit `return` statement. In this example, each lambda has only one expression in its body—a simplification that befits the spirit of lambda programming. - -The `trace` function in the lispy program helps to clarify how the program works (as I'll illustrate below). The higher-order function `apply`, a nod to a Lisp function of the same name, takes a numeric value as its first argument and a list of lambda references as its second argument. The `apply` function is called initially, at the bottom of the program, with zero as the first argument and the list named `@ops` as the second argument. This list consists of 16 lambda references from among `$inc` (increment a value), `$dec` (decrement a value), and `$nop` (do nothing). The list could contain the lambdas themselves, but the code is easier to write and to understand with the more concise lambda references. - -The logic of the higher-order `apply` function can be clarified as follows: - - 1. The argument list passed to `apply` in typical Perl fashion is separated into three pieces: -``` -my ($val, $first, @rest) = @_; ## break the argument list into three elements - -``` - -The first element `$val` is a numeric value, initially `0`. The second element `$first` is a lambda reference, one of `$inc` `$dec`, or `$nop`. The third element `@rest` is a list of any remaining lambda references after the first such reference is extracted as `$first`. - - 2. If the list `@rest` is not empty after its first element is removed, then `apply` is called recursively. The two arguments to the recursively invoked `apply` are: - - * The value generated by applying lambda operation `$first` to numeric value `$val`. For example, if `$first` is the incrementing lambda to which `$inc` refers, and `$val` is 2, then the new first argument to `apply` would be 3. - * The list of remaining lambda references. Eventually, this list becomes empty because each call to `apply` shortens the list by extracting its first element. - - - -Here is some output from a sample run of the lispy program, with `%` as the command-line prompt: -``` -% ./lispy.pl - -0 CODE(0x8f6820) CODE(0x8f68c8)CODE(0x8f68c8)CODE(0x8f6820)CODE(0x8f6820)CODE(0x8f6820)... -Hit RETURN to continue... - -1 CODE(0x8f68c8) CODE(0x8f68c8)CODE(0x8f6820)CODE(0x8f6820)CODE(0x8f6820)CODE(0x8f6820)... -Hit RETURN to continue -``` - -The first output line can be clarified as follows: - - * The `0` is the numeric value passed as an argument in the initial (and thus non-recursive) call to function `apply`. The argument name is `$val` in `apply`. - * The `CODE(0x8f6820)` is a reference to one of the lambdas, in this case the lambda to which `$inc` refers. The second argument is thus the address of some lambda code. The argument name is `$first` in `apply` - * The third piece, the series of `CODE` references, is the list of lambda references beyond the first. The argument name is `@rest` in `apply`. - - - -The second line of output shown above also deserves a look. The numeric value is now `1`, the result of incrementing `0`: the initial lambda is `$inc` and the initial value is `0`. The extracted reference `CODE(0x8f68c8)` is now `$first`, as this reference is the first element in the `@rest` list after `$inc` has been extracted earlier. - -Eventually, the `@rest` list becomes empty, which ends the recursive calls to `apply`. In this case, the function `apply` simply returns a list with two elements: - - 1. The numeric value taken in as an argument (in the sample run, 2). - 2. This argument transformed by the lambda (also 2 because the last lambda reference happens to be `$nop` for do nothing). - - - -The lispy example underscores that Perl supports lambdas without any special fussy syntax: A lambda is just an unnamed code block, perhaps with a reference to it for convenience. Lambdas themselves, or references to them, can be passed straightforwardly as arguments to higher-order functions such as `apply` in the lispy example. Invoking a lambda through a reference is likewise straightforward. In the `apply` function, the call is: -``` -$first->($val)    ## $first is a lambda reference, $val a numeric argument passed to the lambda - -``` - -### A richer code example - -The next code example puts a lambda and a higher-order function to practical use. The example implements Conway’s Game of Life, a cellular automaton that can be represented as a matrix of cells. Such a matrix goes through various transformations, each yielding a new generation of cells. The Game of Life is fascinating because even relatively simple initial configurations can lead to quite complex behavior. A quick look at the rules governing cell birth, survival, and death is in order. - -Consider this 5x5 matrix, with a star representing a live cell and a dash representing a dead one: -``` - -----              ## initial configuration - --*-- - --*-- - --*-- - ----- -``` - -The next generation becomes: -``` - -----              ## next generation - ----- - -***- - ---- - ----- -``` - -As life continues, the generations oscillate between these two configurations. - -Here are the rules determining birth, death, and survival for a cell. A given cell has between three neighbors (a corner cell) and eight neighbors (an interior cell): - - * A dead cell with exactly three live neighbors comes to life. - * A live cell with more than three live neighbors dies from over-crowding. - * A live cell with two or three live neighbors survives; hence, a live cell with fewer than two live neighbors dies from loneliness. - - - -In the initial configuration shown above, the top and bottom live cells die because neither has two or three live neighbors. By contrast, the middle live cell in the initial configuration gains two live neighbors, one on either side, in the next generation. - -## Conway’s Game of Life -``` -#!/usr/bin/perl - -### A simple implementation of Conway's game of life. -# Usage: ./gol.pl [input file]  ;; If no file name given, DefaultInfile is used. - -use constant Dead  => "-"; -use constant Alive => "*"; -use constant DefaultInfile => 'conway.in'; - -use strict; -use warnings; - -my $dimension = undef; -my @matrix = (); -my $generation = 1; - -sub read_data { -    my $datafile = DefaultInfile; -    $datafile = shift @ARGV if @ARGV; -    die "File $datafile does not exist.\n" if !-f $datafile; -    open(INFILE, "<$datafile"); - -    ## Check 1st line for dimension; -    $dimension = <INFILE>; -    die "1st line of input file $datafile not an integer.\n" if $dimension !~ /\d+/; - -    my $record_count = 0; -    while (<INFILE>) { -        chomp($_); -        last if $record_count++ == $dimension; -        die "$_: bad input record -- incorrect length\n" if length($_) != $dimension; -        my @cells = split(//, $_); -        push @matrix, @cells; -    } -    close(INFILE); -    draw_matrix(); -} - -sub draw_matrix { -    my $n = $dimension * $dimension; -    print "\n\tGeneration $generation\n"; -    for (my $i = 0; $i < $n; $i++) { -        print "\n\t" if ($i % $dimension) == 0; -        print $matrix[$i]; -    } -    print "\n\n"; -    $generation++; -} - -sub has_left_neighbor { -    my ($ind) = @_; -    return ($ind % $dimension) != 0; -} - -sub has_right_neighbor { -    my ($ind) = @_; -    return (($ind + 1) % $dimension) != 0; -} - -sub has_up_neighbor { -    my ($ind) = @_; -    return (int($ind / $dimension)) != 0; -} - -sub has_down_neighbor { -    my ($ind) = @_; -    return (int($ind / $dimension) + 1) != $dimension; -} - -sub has_left_up_neighbor { -    my ($ind) = @_; -    ($ind) && has_up_neighbor($ind); -} - -sub has_right_up_neighbor { -    my ($ind) = @_; -    ($ind) && has_up_neighbor($ind); -} - -sub has_left_down_neighbor { -    my ($ind) = @_; -    ($ind) && has_down_neighbor($ind); -} - -sub has_right_down_neighbor { -    my ($ind) = @_; -    ($ind) && has_down_neighbor($ind); -} - -sub compute_cell { -    my ($ind) = @_; -    my @neighbors; - -    # 8 possible neighbors -    push(@neighbors, $ind - 1) if has_left_neighbor($ind); -    push(@neighbors, $ind + 1) if has_right_neighbor($ind); -    push(@neighbors, $ind - $dimension) if has_up_neighbor($ind); -    push(@neighbors, $ind + $dimension) if has_down_neighbor($ind); -    push(@neighbors, $ind - $dimension - 1) if has_left_up_neighbor($ind); -    push(@neighbors, $ind - $dimension + 1) if has_right_up_neighbor($ind); -    push(@neighbors, $ind + $dimension - 1) if has_left_down_neighbor($ind); -    push(@neighbors, $ind + $dimension + 1) if has_right_down_neighbor($ind); - -    my $count = 0; -    foreach my $n (@neighbors) { -        $count++ if $matrix[$n] eq Alive; -    } - -    if ($matrix[$ind] eq Alive) && (($count == 2) || ($count == 3)); ## survival -    if ($matrix[$ind] eq Dead)  && ($count == 3);                    ## birth -    ;                                                                  ## death -} - -sub again_or_quit { -    print "RETURN to continue, 'q' to quit.\n"; -    my $flag = <STDIN>; -    chomp($flag); -    return ($flag eq 'q') ? 1 : 0; -} - -sub animate { -    my @new_matrix; -    my $n = $dimension * $dimension - 1; - -    while (1) {                                       ## loop until user signals stop -        @new_matrix = map {compute_cell($_)} (0..$n); ## generate next matrix - -        splice @matrix;                               ## empty current matrix -        push @matrix, @new_matrix;                    ## repopulate matrix -        draw_matrix();                                ## display the current matrix - -        last if again_or_quit();                      ## continue? -        splice @new_matrix;                           ## empty temp matrix -    } -} - -### Execute -read_data();  ## read initial configuration from input file -animate();    ## display and recompute the matrix until user tires -``` - -The gol program (see [Conway’s Game of Life][1]) has almost 140 lines of code, but most of these involve reading the input file, displaying the matrix, and bookkeeping tasks such as determining the number of live neighbors for a given cell. Input files should be configured as follows: -``` - 5 - ----- - --*-- - --*-- - --*-- - ----- -``` - -The first record gives the matrix side, in this case 5 for a 5x5 matrix. The remaining rows are the contents, with stars for live cells and spaces for dead ones. - -The code of primary interest resides in two functions, `animate` and `compute_cell`. The `animate` function constructs the next generation, and this function needs to call `compute_cell` on every cell in order to determine the cell’s new status as either alive or dead. How should the `animate` function be structured? - -The `animate` function has a `while` loop that iterates until the user decides to terminate the program. Within this `while` loop the high-level logic is straightforward: - - 1. Create the next generation by iterating over the matrix cells, calling function `compute_cell` on each cell to determine its new status. At issue is how best to do the iteration. A loop nested inside the `while `loop would do, of course, but nested loops can be clunky. Another way is to use a higher-order function, as clarified shortly. - 2. Replace the current matrix with the new one. - 3. Display the next generation. - 4. Check if the user wants to continue: if so, continue; otherwise, terminate. - - - -Here, for review, is the call to Perl’s higher-order `map` function, with the function’s name again a nod to Lisp. This call occurs as the first statement within the `while` loop in `animate`: -``` -while (1) { -    @new_matrix = map {compute_cell($_)} (0..$n); ## generate next matrixcompute_cell -``` - -The `map` function takes two arguments: an unnamed code block (a lambda!), and a list of values passed to this code block one at a time. In this example, the code block calls the `compute_cell` function with one of the matrix indexes, 0 through the matrix size - 1. Although the matrix is displayed as two-dimensional, it is implemented as a one-dimensional list. - -Higher-order functions such as `map` encourage the code brevity for which Perl is famous. My view is that such functions also make code easier to write and to understand, as they dispense with the required but messy details of loops. In any case, lambdas and higher-order functions make up the Lispy side of Perl. - -If you're interested in more detail, I recommend Mark Jason Dominus's book, [Higher-Order Perl][2]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/5/looking-lispy-side-perl - -作者:[Marty Kalin][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者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/mkalindepauledu -[1]:https://trello-attachments.s3.amazonaws.com/575088ec94ca6ac38b49b30e/5ad4daf12f6b6a3ac2318d28/c0700c7379983ddf61f5ab5ab4891f0c/lispyPerl.html#gol (Conway’s Game of Life) -[2]:https://www.elsevier.com/books/higher-order-perl/dominus/978-1-55860-701-9 diff --git a/sources/talk/20180527 Whatever Happened to the Semantic Web.md b/sources/talk/20180527 Whatever Happened to the Semantic Web.md deleted file mode 100644 index 22d48c150a..0000000000 --- a/sources/talk/20180527 Whatever Happened to the Semantic Web.md +++ /dev/null @@ -1,106 +0,0 @@ -Whatever Happened to the Semantic Web? -====== -In 2001, Tim Berners-Lee, inventor of the World Wide Web, published an article in Scientific American. Berners-Lee, along with two other researchers, Ora Lassila and James Hendler, wanted to give the world a preview of the revolutionary new changes they saw coming to the web. Since its introduction only a decade before, the web had fast become the world’s best means for sharing documents with other people. Now, the authors promised, the web would evolve to encompass not just documents but every kind of data one could imagine. - -They called this new web the Semantic Web. The great promise of the Semantic Web was that it would be readable not just by humans but also by machines. Pages on the web would be meaningful to software programs—they would have semantics—allowing programs to interact with the web the same way that people do. Programs could exchange data across the Semantic Web without having to be explicitly engineered to talk to each other. According to Berners-Lee, Lassila, and Hendler, a typical day living with the myriad conveniences of the Semantic Web might look something like this: - -> The entertainment system was belting out the Beatles’ “We Can Work It Out” when the phone rang. When Pete answered, his phone turned the sound down by sending a message to all the other local devices that had a volume control. His sister, Lucy, was on the line from the doctor’s office: “Mom needs to see a specialist and then has to have a series of physical therapy sessions. Biweekly or something. I’m going to have my agent set up the appointments.” Pete immediately agreed to share the chauffeuring. At the doctor’s office, Lucy instructed her Semantic Web agent through her handheld Web browser. The agent promptly retrieved the information about Mom’s prescribed treatment within a 20-mile radius of her home and with a rating of excellent or very good on trusted rating services. It then began trying to find a match between available appointment times (supplied by the agents of individual providers through their Web sites) and Pete’s and Lucy’s busy schedules. - -The vision was that the Semantic Web would become a playground for intelligent “agents.” These agents would automate much of the work that the world had only just learned to do on the web. - -![][1] - -For a while, this vision enticed a lot of people. After new technologies such as AJAX led to the rise of what Silicon Valley called Web 2.0, Berners-Lee began referring to the Semantic Web as Web 3.0. Many thought that the Semantic Web was indeed the inevitable next step. A New York Times article published in 2006 quotes a speech Berners-Lee gave at a conference in which he said that the extant web would, twenty years in the future, be seen as only the “embryonic” form of something far greater. A venture capitalist, also quoted in the article, claimed that the Semantic Web would be “profound,” and ultimately “as obvious as the web seems obvious to us today.” - -Of course, the Semantic Web we were promised has yet to be delivered. In 2018, we have “agents” like Siri that can do certain tasks for us. But Siri can only do what it can because engineers at Apple have manually hooked it up to a medley of web services each capable of answering only a narrow category of questions. An important consequence is that, without being large and important enough for Apple to care, you cannot advertise your services directly to Siri from your own website. Unlike the physical therapists that Berners-Lee and his co-authors imagined would be able to hang out their shingles on the web, today we are stuck with giant, centralized repositories of information. Today’s physical therapists must enter information about their practice into Google or Yelp, because those are the only services that the smartphone agents know how to use and the only ones human beings will bother to check. The key difference between our current reality and the promised Semantic future is best captured by this throwaway aside in the excerpt above: “…appointment times (supplied by the agents of individual providers through **their** Web sites)…” - -In fact, over the last decade, the web has not only failed to become the Semantic Web but also threatened to recede as an idea altogether. We now hardly ever talk about “the web” and instead talk about “the internet,” which as of 2016 has become such a common term that newspapers no longer capitalize it. (To be fair, they stopped capitalizing “web” too.) Some might still protest that the web and the internet are two different things, but the distinction gets less clear all the time. The web we have today is slowly becoming a glorified app store, just the easiest way among many to download software that communicates with distant servers using closed protocols and schemas, making it functionally identical to the software ecosystem that existed before the web. How did we get here? If the effort to build a Semantic Web had succeeded, would the web have looked different today? Or have there been so many forces working against a decentralized web for so long that the Semantic Web was always going to be stillborn? - -### Semweb Hucksters and Their Metacrap - -To some more practically minded engineers, the Semantic Web was, from the outset, a utopian dream. - -The basic idea behind the Semantic Web was that everyone would use a new set of standards to annotate their webpages with little bits of XML. These little bits of XML would have no effect on the presentation of the webpage, but they could be read by software programs to divine meaning that otherwise would only be available to humans. - -The bits of XML were a way of expressing metadata about the webpage. We are all familiar with metadata in the context of a file system: When we look at a file on our computers, we can see when it was created, when it was last updated, and whom it was originally created by. Likewise, webpages on the Semantic Web would be able to tell your browser who authored the page and perhaps even where that person went to school, or where that person is currently employed. In theory, this information would allow Semantic Web browsers to answer queries across a large collection of webpages. In their article for Scientific American, Berners-Lee and his co-authors explain that you could, for example, use the Semantic Web to look up a person you met at a conference whose name you only partially remember. - -Cory Doctorow, a blogger and digital rights activist, published an influential essay in 2001 that pointed out the many problems with depending on voluntarily supplied metadata. A world of “exhaustive, reliable” metadata would be wonderful, he argued, but such a world was “a pipe-dream, founded on self-delusion, nerd hubris, and hysterically inflated market opportunities.” Doctorow had found himself in a series of debates over the Semantic Web at tech conferences and wanted to catalog the serious issues that the Semantic Web enthusiasts (Doctorow calls them “semweb hucksters”) were overlooking. The essay, titled “Metacrap,” identifies seven problems, among them the obvious fact that most web users were likely to provide either no metadata at all or else lots of misleading metadata meant to draw clicks. Even if users were universally diligent and well-intentioned, in order for the metadata to be robust and reliable, users would all have to agree on a single representation for each important concept. Doctorow argued that in some cases a single representation might not be appropriate, desirable, or fair to all users. - -Indeed, the web had already seen people abusing the HTML `` tag (introduced at least as early as HTML 4) in an attempt to improve the visibility of their webpages in search results. In a 2004 paper, Ben Munat, then an academic at Evergreen State College, explains how search engines once experimented with using keywords supplied via the `` tag to index results, but soon discovered that unscrupulous webpage authors were including tags unrelated to the actual content of their webpage. As a result, search engines came to ignore the `` tag in favor of using complex algorithms to analyze the actual content of a webpage. Munat concludes that a general-purpose Semantic Web is unworkable, and that the focus should be on specific domains within medicine and science. - -Others have also seen the Semantic Web project as tragically flawed, though they have located the flaw elsewhere. Aaron Swartz, the famous programmer and another digital rights activist, wrote in an unfinished book about the Semantic Web published after his death that Doctorow was “attacking a strawman.” Nobody expected that metadata on the web would be thoroughly accurate and reliable, but the Semantic Web, or at least a more realistically scoped version of it, remained possible. The problem, in Swartz’ view, was the “formalizing mindset of mathematics and the institutional structure of academics” that the “semantic Webheads” brought to bear on the challenge. In forums like the World Wide Web Consortium (W3C), a huge amount of effort and discussion went into creating standards before there were any applications out there to standardize. And the standards that emerged from these “Talmudic debates” were so abstract that few of them ever saw widespread adoption. The few that did, like XML, were “uniformly scourges on the planet, offenses against hardworking programmers that have pushed out sensible formats (like JSON) in favor of overly-complicated hairballs with no basis in reality.” The Semantic Web might have thrived if, like the original web, its standards were eagerly adopted by everyone. But that never happened because—as [has been discussed][2] on this blog before—the putative benefits of something like XML are not easy to sell to a programmer when the alternatives are both entirely sufficient and much easier to understand. - -### Building the Semantic Web - -If the Semantic Web was not an outright impossibility, it was always going to require the contributions of lots of clever people working in concert. - -The long effort to build the Semantic Web has been said to consist of four phases. The first phase, which lasted from 2001 to 2005, was the golden age of Semantic Web activity. Between 2001 and 2005, the W3C issued a slew of new standards laying out the foundational technologies of the Semantic future. - -The most important of these was the Resource Description Framework (RDF). The W3C issued the first version of the RDF standard in 2004, but RDF had been floating around since 1997, when a W3C working group introduced it in a draft specification. RDF was originally conceived of as a tool for modeling metadata and was partly based on earlier attempts by Ramanathan Guha, an Apple engineer, to develop a metadata system for files stored on Apple computers. The Semantic Web working groups at W3C repurposed RDF to represent arbitrary kinds of general knowledge. - -RDF would be the grammar in which Semantic webpages expressed information. The grammar is a simple one: Facts about the world are expressed in RDF as triplets of subject, predicate, and object. Tim Bray, who worked with Ramanathan Guha on an early version of RDF, gives the following example, describing TV shows and movies: - -``` -@prefix rdf: . - -@prefix ex: . - - -ex:vincent_donofrio ex:starred_in ex:law_and_order_ci . - -ex:law_and_order_ci rdf:type ex:tv_show . - -ex:the_thirteenth_floor ex:similar_plot_as ex:the_matrix . -``` - -The syntax is not important, especially since RDF can be represented in a number of formats, including XML and JSON. This example is in a format called Turtle, which expresses RDF triplets as straightforward sentences terminated by periods. The three essential sentences, which appear above after the `@prefix` preamble, state three facts: Vincent Donofrio starred in Law and Order, Law and Order is a type of TV Show, and the movie The Thirteenth Floor has a similar plot as The Matrix. (If you don’t know who Vincent Donofrio is and have never seen The Thirteenth Floor, I, too, was watching Nickelodeon and sipping Capri Suns in 1999.) - -Other specifications finalized and drafted during this first era of Semantic Web development describe all the ways in which RDF can be used. RDF in Attributes (RDFa) defines how RDF can be embedded in HTML so that browsers, search engines, and other programs can glean meaning from a webpage. RDF Schema and another standard called OWL allows RDF authors to demarcate the boundary between valid and invalid RDF statements in their RDF documents. RDF Schema and OWL, in other words, are tools for creating what are known as ontologies, explicit specifications of what can and cannot be said within a specific domain. An ontology might include a rule, for example, expressing that no person can be the mother of another person without also being a parent of that person. The hope was that these ontologies would be widely used not only to check the accuracy of RDF found in the wild but also to make inferences about omitted information. - -In 2006, Tim Berners-Lee posted a short article in which he argued that the existing work on Semantic Web standards needed to be supplemented by a concerted effort to make semantic data available on the web. Furthermore, once on the web, it was important that semantic data link to other kinds of semantic data, ensuring the rise of a data-based web as interconnected as the existing web. Berners-Lee used the term “linked data” to describe this ideal scenario. Though “linked data” was in one sense just a recapitulation of the original vision for the Semantic Web, it became a term that people could rally around and thus amounted to a rebranding of the Semantic Web project. - -Berners-Lee’s article launched the second phase of the Semantic Web’s development, where the focus shifted from setting standards and building toy examples to creating and popularizing large RDF datasets. Perhaps the most successful of these datasets was [DBpedia][3], a giant repository of RDF triplets extracted from Wikipedia articles. DBpedia, which made heavy use of the Semantic Web standards that had been developed in the first half of the 2000s, was a standout example of what could be accomplished using the W3C’s new formats. Today DBpedia describes 4.58 million entities and is used by organizations like the NY Times, BBC, and IBM, which employed DBpedia as a knowledge source for IBM Watson, the Jeopardy-winning artificial intelligence system. - -![][4] - -The third phase of the Semantic Web’s development involved adapting the W3C’s standards to fit the actual practices and preferences of web developers. By 2008, JSON had begun its meteoric rise to popularity. Whereas XML came packaged with a bunch of associated technologies of indeterminate purpose (XLST, XPath, XQuery, XLink), JSON was just JSON. It was less verbose and more readable. Manu Sporny, an entrepreneur and member of the W3C, had already started using JSON at his company and wanted to find an easy way for RDFa and JSON to work together. The result would be JSON-LD, which in essence was RDF reimagined for a world that had chosen JSON over XML. Sporny, together with his CTO, Dave Longley, issued a draft specification of JSON-LD in 2010. For the next few years, JSON-LD and an updated RDF specification would be the primary focus of Semantic Web work at the W3C. JSON-LD could be used on its own or it could be embedded within a `` +``` + +With: + + +``` +`` +``` + +Now the HTML5 version of your project runs in a web browser, whether the user is online or not. + +JClic also provides a reports function that can store test scores in an ODBC-compliant database. I have not explored this feature, as my tests and puzzles are mostly used for self-assessment and to prompt reflection by the learner, rather than as part of a formal scheme, so the scores are not very important. If you would like to learn about it, there is [documentation][14] on running JClic Reports Server with Tomcat and MySQL (or [mariaDB][15]). + +### Conclusion + +JClic offers a wide range of activity types that provide plenty of room to be creative in designing content to fit your subject area and type of learner. JClic is a valuable addition for anyone who needs a quick and easy way to develop educational resources. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/jclic-games-kids + +作者:[Peter Cheer][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/petercheer +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/family_learning_kids_night_reading.png?itok=6K7sJVb1 (Family learning and reading together at night in a room) +[2]: https://opensource.com/article/18/5/exelearning +[3]: https://clic.xtec.cat/legacy/en/jclic/index.html +[4]: https://clic.xtec.cat/legacy/en/index.html +[5]: https://github.com/projectestac/jclic +[6]: https://adoptopenjdk.net/installation.html +[7]: https://clic.xtec.cat/repo/ +[8]: https://github.com/projectestac/jclic/wiki/JClic_Guide +[9]: https://opensource.com/sites/default/files/uploads/metadata.png (JClic metadata) +[10]: https://opensource.com/sites/default/files/uploads/media.png (JClic media) +[11]: https://opensource.com/sites/default/files/uploads/activities.png (JClic activities) +[12]: https://opensource.com/sites/default/files/uploads/sequence.png (JClic timeline) +[13]: http://projectestac.github.io/jclic.js/ +[14]: https://github.com/projectestac/jclic/wiki/Jclic-Reports-Server-with-Tomcat-and-MySQL-on-Ubuntu +[15]: https://mariadb.org/ diff --git a/sources/tech/20200504 Define and optimize data partitions in Apache Cassandra.md b/sources/tech/20200504 Define and optimize data partitions in Apache Cassandra.md new file mode 100644 index 0000000000..d28f0daee0 --- /dev/null +++ b/sources/tech/20200504 Define and optimize data partitions in Apache Cassandra.md @@ -0,0 +1,150 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Define and optimize data partitions in Apache Cassandra) +[#]: via: (https://opensource.com/article/20/5/apache-cassandra) +[#]: author: (Anil Inamdar https://opensource.com/users/anil-inamdar) + +Define and optimize data partitions in Apache Cassandra +====== +Apache Cassandra is built for speed and scalability; here's how to get +the most out of those benefits. +![Person standing in front of a giant computer screen with numbers, data][1] + +Apache Cassandra is a database. But it's not just any database; it's a replicating database designed and tuned for scalability, high availability, low-latency, and performance. Cassandra can help your data survive regional outages, hardware failure, and what many admins would consider excessive amounts of data. + +Having a thorough command of data partitions enables you to achieve superior Cassandra cluster design, performance, and scalability. In this article, I'll examine how to define partitions and how Cassandra uses them, as well as the most critical best practices and known issues you ought to be aware of. + +To set the scene: partitions are chunks of data that serve as the atomic unit for key database-related functions like data distribution, replication, and indexing. Distributed data systems commonly distribute incoming data into these partitions, performing the partitioning with simple mathematical functions such as identity or hashing, and using a "partition key" to group data by partition. For example, consider a case where server logs arrive as incoming data. Using the "identity" partitioning function and the timestamps of each log (rounded to the hour value) for the partition key, we can partition this data such that each partition holds one hour of the logs. + +### Data partitions in Cassandra + +Cassandra operates as a distributed system and adheres to the data partitioning principles described above. With Cassandra, data partitioning relies on an algorithm configured at the cluster level, and a partition key configured at the table level. + +![Cassandra data partition][2] + +Cassandra Query Language (CQL) uses the familiar SQL table, row, and column terminologies. In the example diagram above, the table configuration includes the partition key within its primary key, with the format: Primary Key = Partition Key + [Clustering Columns]. + +A primary key in Cassandra represents both a unique data partition and a data arrangement inside a partition. Data arrangement information is provided by optional clustering columns. Each unique partition key represents a set of table rows managed in a server, as well as all servers that manage its replicas. + +### Defining primary keys in CQL + +The following four examples demonstrate how a primary key can be represented in CQL syntax. The sets of rows produced by these definitions are generally considered a partition. + +#### Definition 1 (partition key: log_hour, clustering columns: none) + + +``` +CREATE TABLE server_logs( +   log_hour TIMESTAMP PRIMARYKEY, +   log_level text, +   message text, +   server text +   ) +``` + +Here, all rows that share a **log_hour** go into the same partition. + +#### Definition 2 (partition key: log_hour, clustering columns: log_level) + + +``` +CREATE TABLE server_logs( +   log_hour TIMESTAMP, +   log_level text, +   message text, +   server text, +   PRIMARY KEY (log_hour, log_level) +   ) +``` + +This definition uses the same partition key as Definition 1, but here all rows in each partition are arranged in ascending order by **log_level**. + +#### Definition 3 (partition key: log_hour, server, clustering columns: none) + + +``` +CREATE TABLE server_logs( +   log_hour TIMESTAMP, +   log_level text, +   message text, +   server text, +   PRIMARY KEY ((log_hour, server)) +   ) +``` + +In this definition, all rows share a **log_hour** for each distinct **server** as a single partition. + +#### Definition 4 (partition key: log_hour, server, clustering columns: log_level) + + +``` +CREATE TABLE server_logs( +   log_hour TIMESTAMP, +   log_level text, +   message text, +   server text, +   PRIMARY KEY ((log_hour, server),log_level) +   )WITH CLUSTERING ORDER BY (column3 DESC); +``` + +This definition uses the same partition as Definition 3 but arranges the rows within a partition in descending order by **log_level**. + +### How Cassandra uses the partition key + +Cassandra relies on the partition key to determine which node to store data on and where to locate data when it's needed. Cassandra performs these read and write operations by looking at a partition key in a table, and using tokens (a long value out of range -2^63 to +2^63-1) for data distribution and indexing. These tokens are mapped to partition keys by using a partitioner, which applies a partitioning function that converts any partition key to a token. Through this token mechanism, every node of a Cassandra cluster owns a set of data partitions. The partition key then enables data indexing on each node. + +![Cassandra cluster with 3 nodes and token-based ownership][3] + +A Cassandra cluster with three nodes and token-based ownership. This is a simplistic representation: the actual implementation uses [Vnodes][4]. + +### Data partition impacts on Cassandra clusters + +Careful partition key design is crucial to achieving the ideal partition size for the use case. Getting it right allows for even data distribution and strong I/O performance. Partition size has several impacts on Cassandra clusters you need to be aware of: + + * Read performance—In order to find partitions in SSTables files on disk, Cassandra uses data structures that include caches, indexes, and index summaries. Partitions that are too large reduce the efficiency of maintaining these data structures – and will negatively impact performance as a result. Cassandra releases have made strides in this area: in particular, version 3.6 and above of the Cassandra engine introduce storage improvements that deliver better performance for large partitions and resilience against memory issues and crashes. + * Memory usage— Large partitions place greater pressure on the JVM heap, increasing its size while also making the garbage collection mechanism less efficient. + * Cassandra repairs—Large partitions make it more difficult for Cassandra to perform its repair maintenance operations, which keep data consistent by comparing data across replicas. + * Tombstone eviction—Not as mean as it sounds, Cassandra uses unique markers known as "tombstones" to mark data for deletion. Large partitions can make that deletion process more difficult if there isn't an appropriate data deletion pattern and compaction strategy in place. + + + +While these impacts may make it tempting to simply design partition keys that yield especially small partitions, the data access pattern is also highly influential on ideal partition size (for more information, read this in-depth guide to [Cassandra data modeling][5]). The data access pattern can be defined as how a table is queried, including all of the table's **select** queries. Ideally, CQL select queries should have just one partition key in the **where** clause—that is to say, Cassandra is most efficient when queries can get needed data from a single partition, instead of many smaller ones. + +### Best practices for partition key design + +Following best practices for partition key design helps you get to an ideal partition size. As a rule of thumb, the maximum partition size in Cassandra should stay under 100MB. Ideally, it should be under 10MB. While Cassandra versions 3.6 and newer make larger partition sizes more viable, careful testing and benchmarking must be performed for each workload to ensure a partition key design supports desired cluster performance. + +Specifically, these best practices should be considered as part of any partition key design: + + * The goal for a partition key must be to fit an ideal amount of data into each partition for supporting the needs of its access pattern. + * A partition key should disallow unbounded partitions: those that may grow indefinitely in size over time. For instance, in the **server_logs** examples above, using the server column as a partition key would create unbounded partitions as the number of server logs continues to increase. In contrast, using **log_hour** limits each partition to an hour of data. + * A partition key should also avoid creating a partition skew, in which partitions grow unevenly, and some are able to grow without limit over time. In the **server_logs** examples, using the server column in a scenario where one server generates considerably more logs than others would produce a partition skew. To avoid this, a useful technique is to introduce another attribute from the table to force an even distribution, even if it's necessary to create a dummy column to do so. + * It's helpful to partition time-series data with a partition key that uses a time element as well as other attributes. This protects against unbounded partitions, enables access patterns to use the time attribute in querying specific data, and allows for time-bound data deletion. The examples above each demonstrate this by using the **log_hour** time attribute. + + + +Several tools are available to help test, analyze, and monitor Cassandra partitions to check that a chosen schema is efficient and effective. By carefully designing partition keys to align well with the data and needs of the solution at hand, and following best practices to optimize partition size, you can utilize data partitions that more fully deliver on the scalability and performance potential of a Cassandra deployment. + +Dani and Jon will give a three hour tutorial at OSCON this year called: Becoming friends with... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/apache-cassandra + +作者:[Anil Inamdar][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/anil-inamdar +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr (Person standing in front of a giant computer screen with numbers, data) +[2]: https://opensource.com/sites/default/files/uploads/apache_cassandra_1_0.png (Cassandra data partition) +[3]: https://opensource.com/sites/default/files/uploads/apache_cassandra_2_0.png (Cassandra cluster with 3 nodes and token-based ownership) +[4]: https://www.instaclustr.com/cassandra-vnodes-how-many-should-i-use/ +[5]: https://www.instaclustr.com/resource/6-step-guide-to-apache-cassandra-data-modelling-white-paper/ diff --git a/sources/tech/20200504 Understanding systemd at startup on Linux.md b/sources/tech/20200504 Understanding systemd at startup on Linux.md new file mode 100644 index 0000000000..2d0a5ef7b6 --- /dev/null +++ b/sources/tech/20200504 Understanding systemd at startup on Linux.md @@ -0,0 +1,445 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Understanding systemd at startup on Linux) +[#]: via: (https://opensource.com/article/20/5/systemd-startup) +[#]: author: (David Both https://opensource.com/users/dboth) + +Understanding systemd at startup on Linux +====== +systemd's startup provides important clues to help you solve problems +when they occur. +![People at the start line of a race][1] + +In [_Learning to love systemd_][2], the first article in this series, I looked at systemd's functions and architecture and the controversy around its role as a replacement for the old SystemV init program and startup scripts. In this second article, I'll start exploring the files and tools that manage the Linux startup sequence. I'll explain the systemd startup sequence, how to change the default startup target (runlevel in SystemV terms), and how to manually switch to a different target without going through a reboot. + +I'll also look at two important systemd tools. The first is the **systemctl** command, which is the primary means of interacting with and sending commands to systemd. The second is **journalctl**, which provides access to the systemd journals that contain huge amounts of system history data such as kernel and service messages (both informational and error messages). + +Be sure to use a non-production system for testing and experimentation in this and future articles. Your test system needs to have a GUI desktop (such as Xfce, LXDE, Gnome, KDE, or another) installed. + +I wrote in my previous article that I planned to look at creating a systemd unit and adding it to the startup sequence in this article. Because this article became longer than I anticipated, I will hold that for the next article in this series. + +### Exploring Linux startup with systemd + +Before you can observe the startup sequence, you need to do a couple of things to make the boot and startup sequences open and visible. Normally, most distributions use a startup animation or splash screen to hide the detailed messages that would otherwise be displayed during a Linux host's startup and shutdown. This is called the Plymouth boot screen on Red Hat-based distros. Those hidden messages can provide a great deal of information about startup and shutdown to a sysadmin looking for information to troubleshoot a bug or to just learn about the startup sequence. You can change this using the GRUB (Grand Unified Boot Loader) configuration. + +The main GRUB configuration file is **/boot/grub2/grub.cfg**, but, because this file can be overwritten when the kernel version is updated, you do not want to change it. Instead, modify the **/etc/default/grub** file, which is used to modify the default settings of **grub.cfg**. + +Start by looking at the current, unmodified version of the **/etc/default/grub** file: + + +``` +[root@testvm1 ~]# cd /etc/default ; cat grub +GRUB_TIMEOUT=5 +GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" +GRUB_DEFAULT=saved +GRUB_DISABLE_SUBMENU=true +GRUB_TERMINAL_OUTPUT="console" +GRUB_CMDLINE_LINUX="resume=/dev/mapper/fedora_testvm1-swap rd.lvm. +lv=fedora_testvm1/root rd.lvm.lv=fedora_testvm1/swap rd.lvm.lv=fedora_ +testvm1/usr rhgb quiet" +GRUB_DISABLE_RECOVERY="true" +[root@testvm1 default]# +``` + +Chapter 6 of the [GRUB documentation][3] contains a list of all the possible entries in the **/etc/default/grub** file, but I focus on the following: + + * I change **GRUB_TIMEOUT**, the number of seconds for the GRUB menu countdown, from five to 10 to give a bit more time to respond to the GRUB menu before the countdown hits zero. + * I delete the last two parameters on **GRUB_CMDLINE_LINUX**, which lists the command-line parameters that are passed to the kernel at boot time. One of these parameters, **rhgb** stands for Red Hat Graphical Boot, and it displays the little Fedora icon animation during the kernel initialization instead of showing boot-time messages. The other, the **quiet** parameter, prevents displaying the startup messages that document the progress of the startup and any errors that occur. I delete both **rhgb** and **quiet** because sysadmins need to see these messages. If something goes wrong during boot, the messages displayed on the screen can point to the cause of the problem. + + + +After you make these changes, your GRUB file will look like: + + +``` +[root@testvm1 default]# cat grub +GRUB_TIMEOUT=10 +GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)" +GRUB_DEFAULT=saved +GRUB_DISABLE_SUBMENU=true +GRUB_TERMINAL_OUTPUT="console" +GRUB_CMDLINE_LINUX="resume=/dev/mapper/fedora_testvm1-swap rd.lvm. +lv=fedora_testvm1/root rd.lvm.lv=fedora_testvm1/swap rd.lvm.lv=fedora_ +testvm1/usr" +GRUB_DISABLE_RECOVERY="false" +[root@testvm1 default]# +``` + +The **grub2-mkconfig** program generates the **grub.cfg** configuration file using the contents of the **/etc/default/grub** file to modify some of the default GRUB settings. The **grub2-mkconfig** program sends its output to **STDOUT**. It has a **-o** option that allows you to specify a file to send the datastream to, but it is just as easy to use redirection. Run the following command to update the **/boot/grub2/grub.cfg** configuration file: + + +``` +[root@testvm1 grub2]# grub2-mkconfig > /boot/grub2/grub.cfg +Generating grub configuration file ... +Found linux image: /boot/vmlinuz-4.18.9-200.fc28.x86_64 +Found initrd image: /boot/initramfs-4.18.9-200.fc28.x86_64.img +Found linux image: /boot/vmlinuz-4.17.14-202.fc28.x86_64 +Found initrd image: /boot/initramfs-4.17.14-202.fc28.x86_64.img +Found linux image: /boot/vmlinuz-4.16.3-301.fc28.x86_64 +Found initrd image: /boot/initramfs-4.16.3-301.fc28.x86_64.img +Found linux image: /boot/vmlinuz-0-rescue-7f12524278bd40e9b10a085bc82dc504 +Found initrd image: /boot/initramfs-0-rescue-7f12524278bd40e9b10a085bc82dc504.img +done +[root@testvm1 grub2]# +``` + +Reboot your test system to view the startup messages that would otherwise be hidden behind the Plymouth boot animation. But what if you need to view the startup messages and have not disabled the Plymouth boot animation? Or you have, but the messages stream by too fast to read? (Which they do.) + +There are a couple of options, and both involve log files and systemd journals—which are your friends. You can use the **less** command to view the contents of the **/var/log/messages** file. This file contains boot and startup messages as well as messages generated by the operating system during normal operation. You can also use the **journalctl** command without any options to view the systemd journal, which contains essentially the same information: + + +``` +[root@testvm1 grub2]# journalctl +\-- Logs begin at Sat 2020-01-11 21:48:08 EST, end at Fri 2020-04-03 08:54:30 EDT. -- +Jan 11 21:48:08 f31vm.both.org kernel: Linux version 5.3.7-301.fc31.x86_64 ([mockbuild@bkernel03.phx2.fedoraproject.org][4]) (gcc version 9.2.1 20190827 (Red Hat 9.2.1-1) (GCC)) #1 SMP Mon Oct > +Jan 11 21:48:08 f31vm.both.org kernel: Command line: BOOT_IMAGE=(hd0,msdos1)/vmlinuz-5.3.7-301.fc31.x86_64 root=/dev/mapper/VG01-root ro resume=/dev/mapper/VG01-swap rd.lvm.lv=VG01/root rd> +Jan 11 21:48:08 f31vm.both.org kernel: x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers' +Jan 11 21:48:08 f31vm.both.org kernel: x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers' +Jan 11 21:48:08 f31vm.both.org kernel: x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers' +Jan 11 21:48:08 f31vm.both.org kernel: x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]:  256 +Jan 11 21:48:08 f31vm.both.org kernel: x86/fpu: Enabled xstate features 0x7, context size is 832 bytes, using 'standard' format. +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-provided physical RAM map: +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x0000000000100000-0x00000000dffeffff] usable +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x00000000dfff0000-0x00000000dfffffff] ACPI data +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x00000000fec00000-0x00000000fec00fff] reserved +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x00000000fee00000-0x00000000fee00fff] reserved +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x00000000fffc0000-0x00000000ffffffff] reserved +Jan 11 21:48:08 f31vm.both.org kernel: BIOS-e820: [mem 0x0000000100000000-0x000000041fffffff] usable +Jan 11 21:48:08 f31vm.both.org kernel: NX (Execute Disable) protection: active +Jan 11 21:48:08 f31vm.both.org kernel: SMBIOS 2.5 present. +Jan 11 21:48:08 f31vm.both.org kernel: DMI: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 +Jan 11 21:48:08 f31vm.both.org kernel: Hypervisor detected: KVM +Jan 11 21:48:08 f31vm.both.org kernel: kvm-clock: Using msrs 4b564d01 and 4b564d00 +Jan 11 21:48:08 f31vm.both.org kernel: kvm-clock: cpu 0, msr 30ae01001, primary cpu clock +Jan 11 21:48:08 f31vm.both.org kernel: kvm-clock: using sched offset of 8250734066 cycles +Jan 11 21:48:08 f31vm.both.org kernel: clocksource: kvm-clock: mask: 0xffffffffffffffff max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns +Jan 11 21:48:08 f31vm.both.org kernel: tsc: Detected 2807.992 MHz processor +Jan 11 21:48:08 f31vm.both.org kernel: e820: update [mem 0x00000000-0x00000fff] usable ==> reserved +Jan 11 21:48:08 f31vm.both.org kernel: e820: remove [mem 0x000a0000-0x000fffff] usable +<snip> +``` + +I truncated this datastream because it can be hundreds of thousands or even millions of lines long. (The journal listing on my primary workstation is 1,188,482 lines long.) Be sure to try this on your test system. If it has been running for some time—even if it has been rebooted many times—huge amounts of data will be displayed. Explore this journal data because it contains a lot of information that can be very useful when doing problem determination. Knowing what this data looks like for a normal boot and startup can help you locate problems when they occur. + +I will discuss systemd journals, the **journalctl** command, and how to sort through all of that data to find what you want in more detail in a future article in this series. + +After GRUB loads the kernel into memory, it must first extract itself from the compressed version of the file before it can perform any useful work. After the kernel has extracted itself and started running, it loads systemd and turns control over to it. + +This is the end of the boot process. At this point, the Linux kernel and systemd are running but unable to perform any productive tasks for the end user because nothing else is running, there's no shell to provide a command line, no background processes to manage the network or other communication links, and nothing that enables the computer to perform any productive function. + +Systemd can now load the functional units required to bring the system up to a selected target run state. + +### Targets + +A systemd target represents a Linux system's current or desired run state. Much like SystemV start scripts, targets define the services that must be present for the system to run and be active in that state. Figure 1 shows the possible run-state targets of a Linux system using systemd. As seen in the first article of this series and in the systemd bootup man page (man bootup), there are other intermediate targets that are required to enable various necessary services. These can include **swap.target**, **timers.target**, **local-fs.target**, and more. Some targets (like **basic.target**) are used as checkpoints to ensure that all the required services are up and running before moving on to the next-higher level target. + +Unless otherwise changed at boot time in the GRUB menu, systemd always starts the **default.target**. The **default.target** file is a symbolic link to the true target file. For a desktop workstation, this is typically going to be the **graphical.target**, which is equivalent to runlevel 5 in SystemV. For a server, the default is more likely to be the **multi-user.target**, which is like runlevel 3 in SystemV. The **emergency.target** file is similar to single-user mode. Targets and services are systemd units. + +The following table, which I included in the previous article in this series, compares the systemd targets with the old SystemV startup runlevels. The systemd target aliases are provided by systemd for backward compatibility. The target aliases allow scripts—and sysadmins—to use SystemV commands like **init 3** to change runlevels. Of course, the SystemV commands are forwarded to systemd for interpretation and execution. + +**systemd targets** | **SystemV runlevel** | **target aliases** | **Description** +---|---|---|--- +default.target | | | This target is always aliased with a symbolic link to either **multi-user.target** or **graphical.target**. systemd always uses the **default.target** to start the system. The **default.target** should never be aliased to **halt.target**, **poweroff.target**, or **reboot.target**. +graphical.target | 5 | runlevel5.target | **Multi-user.target** with a GUI +| 4 | runlevel4.target | Unused. Runlevel 4 was identical to runlevel 3 in the SystemV world. This target could be created and customized to start local services without changing the default **multi-user.target**. +multi-user.target | 3 | runlevel3.target | All services running, but command-line interface (CLI) only +| 2 | runlevel2.target | Multi-user, without NFS, but all other non-GUI services running +rescue.target | 1 | runlevel1.target | A basic system, including mounting the filesystems with only the most basic services running and a rescue shell on the main console +emergency.target | S | | Single-user mode—no services are running; filesystems are not mounted. This is the most basic level of operation with only an emergency shell running on the main console for the user to interact with the system. +halt.target | | | Halts the system without powering it down +reboot.target | 6 | runlevel6.target | Reboot +poweroff.target | 0 | runlevel0.target | Halts the system and turns the power off + +Each target has a set of dependencies described in its configuration file. systemd starts the required dependencies, which are the services required to run the Linux host at a specific level of functionality. When all of the dependencies listed in the target configuration files are loaded and running, the system is running at that target level. If you want, you can review the systemd startup sequence and runtime targets in the first article in this series, [_Learning to love systemd_][2]. + +### Exploring the current target + +Many Linux distributions default to installing a GUI desktop interface so that the installed systems can be used as workstations. I always install from a Fedora Live boot USB drive with an Xfce or LXDE desktop. Even when I'm installing a server or other infrastructure type of host (such as the ones I use for routers and firewalls), I use one of these installations that installs a GUI desktop. + +I could install a server without a desktop (and that would be typical for data centers), but that does not meet my needs. It is not that I need the GUI desktop itself, but the LXDE installation includes many of the other tools I use that are not in a default server installation. This means less work for me after the initial installation. + +But just because I have a GUI desktop does not mean it makes sense to use it. I have a 16-port KVM that I can use to access the KVM interfaces of most of my Linux systems, but the vast majority of my interaction with them is via a remote SSH connection from my primary workstation. This way is more secure and uses fewer system resources to run **multi-user.target** compared to **graphical.target.** + +To begin, check the default target to verify that it is the **graphical.target**: + + +``` +[root@testvm1 ~]# systemctl get-default +graphical.target +[root@testvm1 ~]# +``` + +Now verify the currently running target. It should be the same as the default target. You can still use the old method, which displays the old SystemV runlevels. Note that the previous runlevel is on the left; it is **N** (which means None), indicating that the runlevel has not changed since the host was booted. The number 5 indicates the current target, as defined in the old SystemV terminology: + + +``` +[root@testvm1 ~]# runlevel +N 5 +[root@testvm1 ~]# +``` + +Note that the runlevel man page indicates that runlevels are obsolete and provides a conversion table. + +You can also use the systemd method. There is no one-line answer here, but it does provide the answer in systemd terms: + + +``` +[root@testvm1 ~]# systemctl list-units --type target +UNIT                   LOAD   ACTIVE SUB    DESCRIPTION                 +basic.target           loaded active active Basic System               +cryptsetup.target      loaded active active Local Encrypted Volumes     +getty.target           loaded active active Login Prompts               +graphical.target       loaded active active Graphical Interface         +local-fs-pre.target    loaded active active Local File Systems (Pre)   +local-fs.target        loaded active active Local File Systems         +multi-user.target      loaded active active Multi-User System           +network-online.target  loaded active active Network is Online           +network.target         loaded active active Network                     +nfs-client.target      loaded active active NFS client services         +nss-user-lookup.target loaded active active User and Group Name Lookups +paths.target           loaded active active Paths                       +remote-fs-pre.target   loaded active active Remote File Systems (Pre)   +remote-fs.target       loaded active active Remote File Systems         +rpc_pipefs.target      loaded active active rpc_pipefs.target           +slices.target          loaded active active Slices                     +sockets.target         loaded active active Sockets                     +sshd-keygen.target     loaded active active sshd-keygen.target         +swap.target            loaded active active Swap                       +sysinit.target         loaded active active System Initialization       +timers.target          loaded active active Timers                     + +LOAD   = Reflects whether the unit definition was properly loaded. +ACTIVE = The high-level unit activation state, i.e. generalization of SUB. +SUB    = The low-level unit activation state, values depend on unit type. + +21 loaded units listed. Pass --all to see loaded but inactive units, too. +To show all installed unit files use 'systemctl list-unit-files'. +``` + +This shows all of the currently loaded and active targets. You can also see the **graphical.target** and the **multi-user.target**. The **multi-user.target** is required before the **graphical.target** can be loaded. In this example, the **graphical.target** is active. + +### Switching to a different target + +Making the switch to the **multi-user.target** is easy: + + +``` +`[root@testvm1 ~]# systemctl isolate multi-user.target` +``` + +The display should now change from the GUI desktop or login screen to a virtual console. Log in and list the currently active systemd units to verify that **graphical.target** is no longer running: + + +``` +`[root@testvm1 ~]# systemctl list-units --type target` +``` + +Be sure to use the **runlevel** command to verify that it shows both previous and current "runlevels": + + +``` +[root@testvm1 ~]# runlevel +5 3 +``` + +### Changing the default target + +Now, change the default target to the **multi-user.target** so that it will always boot into the **multi-user.target** for a console command-line interface rather than a GUI desktop interface. As the root user on your test host, change to the directory where the systemd configuration is maintained and do a quick listing: + + +``` +[root@testvm1 ~]# cd /etc/systemd/system/ ; ll +drwxr-xr-x. 2 root root 4096 Apr 25  2018  basic.target.wants +<snip> +lrwxrwxrwx. 1 root root   36 Aug 13 16:23  default.target -> /lib/systemd/system/graphical.target +lrwxrwxrwx. 1 root root   39 Apr 25  2018  display-manager.service -> /usr/lib/systemd/system/lightdm.service +drwxr-xr-x. 2 root root 4096 Apr 25  2018  getty.target.wants +drwxr-xr-x. 2 root root 4096 Aug 18 10:16  graphical.target.wants +drwxr-xr-x. 2 root root 4096 Apr 25  2018  local-fs.target.wants +drwxr-xr-x. 2 root root 4096 Oct 30 16:54  multi-user.target.wants +<snip> +[root@testvm1 system]# +``` + +I shortened this listing to highlight a few important things that will help explain how systemd manages the boot process. You should be able to see the entire list of directories and links on your virtual machine. + +The **default.target** entry is a symbolic link (symlink, soft link) to the directory **/lib/systemd/system/graphical.target**. List that directory to see what else is there: + + +``` +`[root@testvm1 system]# ll /lib/systemd/system/ | less` +``` + +You should see files, directories, and more links in this listing, but look specifically for **multi-user.target** and **graphical.target**. Now display the contents of **default.target**, which is a link to **/lib/systemd/system/graphical.target**: + + +``` +[root@testvm1 system]# cat default.target +#  SPDX-License-Identifier: LGPL-2.1+ +# +#  This file is part of systemd. +# +#  systemd is free software; you can redistribute it and/or modify it +#  under the terms of the GNU Lesser General Public License as published by +#  the Free Software Foundation; either version 2.1 of the License, or +#  (at your option) any later version. + +[Unit] +Description=Graphical Interface +Documentation=man:systemd.special(7) +Requires=multi-user.target +Wants=display-manager.service +Conflicts=rescue.service rescue.target +After=multi-user.target rescue.service rescue.target display-manager.service +AllowIsolate=yes +[root@testvm1 system]# +``` + +This link to the **graphical.target** file describes all of the prerequisites and requirements that the graphical user interface requires. I will explore at least some of these options in the next article in this series. + +To enable the host to boot to multi-user mode, you need to delete the existing link and create a new one that points to the correct target. Make the [PWD][5] **/etc/systemd/system**, if it is not already: + + +``` +[root@testvm1 system]# rm -f default.target +[root@testvm1 system]# ln -s /lib/systemd/system/multi-user.target default.target +``` + +List the **default.target** link to verify that it links to the correct file: + + +``` +[root@testvm1 system]# ll default.target +lrwxrwxrwx 1 root root 37 Nov 28 16:08 default.target -> /lib/systemd/system/multi-user.target +[root@testvm1 system]# +``` + +If your link does not look exactly like this, delete it and try again. List the content of the **default.target** link: + + +``` +[root@testvm1 system]# cat default.target +#  SPDX-License-Identifier: LGPL-2.1+ +# +#  This file is part of systemd. +# +#  systemd is free software; you can redistribute it and/or modify it +#  under the terms of the GNU Lesser General Public License as published by +#  the Free Software Foundation; either version 2.1 of the License, or +#  (at your option) any later version. + +[Unit] +Description=Multi-User System +Documentation=man:systemd.special(7) +Requires=basic.target +Conflicts=rescue.service rescue.target +After=basic.target rescue.service rescue.target +AllowIsolate=yes +[root@testvm1 system]# +``` + +The **default.target**—which is really a link to the **multi-user.target** at this point—now has different requirements in the **[Unit]** section. It does not require the graphical display manager. + +Reboot. Your virtual machine should boot to the console login for virtual console 1, which is identified on the display as tty1. Now that you know how to change the default target, change it back to the **graphical.target** using a command designed for the purpose. + +First, check the current default target: + + +``` +[root@testvm1 ~]# systemctl get-default +multi-user.target +[root@testvm1 ~]# systemctl set-default graphical.target +Removed /etc/systemd/system/default.target. +Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target. +[root@testvm1 ~]# +``` + +Enter the following command to go directly to the **graphical.target** and the display manager login page without having to reboot: + + +``` +`[root@testvm1 system]# systemctl isolate default.target` +``` + +I do not know why the term "isolate" was chosen for this sub-command by systemd's developers. My research indicates that it may refer to running the specified target but "isolating" and terminating all other targets that are not required to support the target. However, the effect is to switch targets from one run target to another—in this case, from the multi-user target to the graphical target. The command above is equivalent to the old init 5 command in SystemV start scripts and the init program. + +Log into the GUI desktop, and verify that it is working as it should. + +### Summing up + +This article explored the Linux systemd startup sequence and started to explore two important systemd tools, **systemctl** and **journalctl**. It also explained how to switch from one target to another and to change the default target. + +The next article in this series will create a new systemd unit and configure it to run during startup. It will also look at some of the configuration options that help determine where in the sequence a particular unit will start, for example, after networking is up and running. + +### Resources + +There is a great deal of information about systemd available on the internet, but much is terse, obtuse, or even misleading. In addition to the resources mentioned in this article, the following webpages offer more detailed and reliable information about systemd startup. + + * The Fedora Project has a good, practical [guide][6] [to systemd][6]. It has pretty much everything you need to know in order to configure, manage, and maintain a Fedora computer using systemd. + * The Fedora Project also has a good [cheat sheet][7] that cross-references the old SystemV commands to comparable systemd ones. + * For detailed technical information about systemd and the reasons for creating it, check out [Freedesktop.org][8]'s [description of systemd][9]. + * [Linux.com][10]'s "More systemd fun" offers more advanced systemd [information and tips][11]. + + + +There is also a series of deeply technical articles for Linux sysadmins by Lennart Poettering, the designer and primary developer of systemd. These articles were written between April 2010 and September 2011, but they are just as relevant now as they were then. Much of everything else good that has been written about systemd and its ecosystem is based on these papers. + + * [Rethinking PID 1][12] + * [systemd for Administrators, Part I][13] + * [systemd for Administrators, Part II][14] + * [systemd for Administrators, Part III][15] + * [systemd for Administrators, Part IV][16] + * [systemd for Administrators, Part V][17] + * [systemd for Administrators, Part VI][18] + * [systemd for Administrators, Part VII][19] + * [systemd for Administrators, Part VIII][20] + * [systemd for Administrators, Part IX][21] + * [systemd for Administrators, Part X][22] + * [systemd for Administrators, Part XI][23] + + + +Alison Chiaken, a Linux kernel and systems programmer at Mentor Graphics, offers a preview of her... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/systemd-startup + +作者:[David Both][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/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/start_line.jpg?itok=9reaaW6m (People at the start line of a race) +[2]: https://opensource.com/article/20/4/systemd +[3]: http://www.gnu.org/software/grub/manual/grub +[4]: mailto:mockbuild@bkernel03.phx2.fedoraproject.org +[5]: https://en.wikipedia.org/wiki/Pwd +[6]: https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html +[7]: https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet +[8]: http://Freedesktop.org +[9]: http://www.freedesktop.org/wiki/Software/systemd +[10]: http://Linux.com +[11]: https://www.linux.com/training-tutorials/more-systemd-fun-blame-game-and-stopping-services-prejudice/ +[12]: http://0pointer.de/blog/projects/systemd.html +[13]: http://0pointer.de/blog/projects/systemd-for-admins-1.html +[14]: http://0pointer.de/blog/projects/systemd-for-admins-2.html +[15]: http://0pointer.de/blog/projects/systemd-for-admins-3.html +[16]: http://0pointer.de/blog/projects/systemd-for-admins-4.html +[17]: http://0pointer.de/blog/projects/three-levels-of-off.html +[18]: http://0pointer.de/blog/projects/changing-roots +[19]: http://0pointer.de/blog/projects/blame-game.html +[20]: http://0pointer.de/blog/projects/the-new-configuration-files.html +[21]: http://0pointer.de/blog/projects/on-etc-sysinit.html +[22]: http://0pointer.de/blog/projects/instances.html +[23]: http://0pointer.de/blog/projects/inetd.html diff --git a/sources/tech/20200505 8 open source video games to play.md b/sources/tech/20200505 8 open source video games to play.md new file mode 100644 index 0000000000..ac0577d96b --- /dev/null +++ b/sources/tech/20200505 8 open source video games to play.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (8 open source video games to play) +[#]: via: (https://opensource.com/article/20/5/open-source-fps-games) +[#]: author: (Aman Gaur https://opensource.com/users/amangaur) + +8 open source video games to play +====== +These games are fun and free to play, a way to connect with friends, and +an opportunity to make an old favorite even better. +![Gaming on a grid with penguin pawns][1] + +Video games are a big business. That's great for the industry's longevity—not to mention for all the people working in programming and graphics. But it can take a lot of work, time, and money to keep up with all the latest gaming crazes. If you feel like playing a few quick rounds of a video game without investing in a new console or game franchise, then you'll be happy to know that there are plenty of open source combat games you can download, play, share, and even modify (if you're inclined to programming) for free. + +First-person shooters (FPS) are one of the most popular categories of video games. They are centered around the perspective of the protagonist (the player), and they often offer weapon-based advancement. As you get better at the game, you survive longer, you get better weapons, and you increase your power. FPS games have a distinct look and feel, which is reflected in the category's name: players see everything—their weapons and the game world—in first person, as if they're looking through their player character's eyes. + +If you want to give one a try, check out the following eight great open source FPS games. + +### Xonotic + +![Xonotic][2] + +[Xonotic][3] is a fast-paced, arena-based FPS game. It is a popular game in the open source world. One reason could be the fact that it has never been a mainstream game. It offers a variety of weapons and enemies that are thrown right at you mercilessly from the start. Demanding quick action and response, it is an experience that will keep you on the edge of your seats. The game is available under the GPLv3+ license. + +### Wolfenstein Enemy Territory + +![Wolfenstein Enemy Territory][4] + +Wolfenstein has been a major franchise in gaming for many years. If you are a fan of gore and glory, then you've probably already heard of this game (if not, you'll love it once you try it). [Wolfenstein Enemy Territory][5] is an early iteration of the popular World War II game. It became free to play in 2003, and its [source code][6] is provided under the GPLv3. To play, however, you must own the game data (or recreate it yourself) separately (which remains under its original EULA). + +### Doom + +![Doom][7] + +[Doom][8] is a wildly popular game that was also an early example of games on Linux—way back in 2004. There are many iterations of the game, many of which have been released as open source. The game is about acquiring a teleportation device that's been captured by demons, so the violence, while gory, is low on realism. The source code for the game was provided under the GPL, but many versions require that you own the game for the game assets. There are dozens of ports and adaptations, including [Freedoom][9] (with free assets), [Dhewm3][10], [RBDoom-3-BFG][11], and many more. Try a few and pick your favorite! + +### Smokin' Guns + +![Smokin' Guns][12] + +If you're a fan of the Old West and six-shooters, this FPS is for you. From cowboys to gunslingers and with a captivating background score, [Smokin' Guns][13] has it all. It's a semi-realistic simulation of the old spaghetti western. On your way through the game, you face multiple enemies and get multiple weapons, so there's always the promise of excitement and danger around the corner. The game is free and open source under the terms of the GPLv2. + +### Nexuiz + +![Nexuiz][14] + +[Nexuiz][15] (classic) is another great FPS that's free to play on multiple platforms. The game is based on the Quake engine and has been made open source under the GNU GPLv2. The game offers multiple modes, including online, LAN party, and bot training. The game features sophisticated weapons and fast action. It's brutal and exciting, with an objective: kill as many opponents as possible before they get you. + +Note that the open source version of Nexuiz is not the same as the version built on CryEngine3 that is sold on Steam. + +### .kkrieger + +![kkrieger][16] + +[.Kkrieger][17] was developed in 2004 by .theprodukkt, a German demogroup. The game was developed using an unreleased (at the time) engine known as Werkkzeug. This game might feel a little slow to many, but it still offers an intense experience. The approaching enemies are slow, but their sheer number makes it confusing to know which one to take down first. It's an onslaught, and you have to shoot through layers of enemies before you reach the final boss. It was released in a rather raw form on [GitHub][18] by its creators under a BSD license with some public domain components. + +### Warsow + +![Warsow][19] + +If you've ever played Borderlands 2, then imagine [Warsow][20] as an arena-style Borderlands. The game is built on a modernized Quake II engine, and its plot takes a simple approach: Kill as many opponents as possible. The team with the most number of kills wins. Despite its simplicity, it features amazing weaponry and lots of great trick moves, like circle jumping, bunny hopping, double jumping, ramp sliding, and so on. It makes for an engaging multiplayer session, and it's been recognized by multiple online leagues as a worthy game for their competitions. Get the source code from [GitHub][21] or install the game from your software repository. + +### World of Padman + +![World of Padman][22] + +[The World of Padman][23] may be the last game on this list, but it's one of the most unique. Designed by PadWorld Entertainment, World of Padman takes a different twist graphically and introduces you to quirky and whimsical characters in a colorful (albeit cartoonishly violent) world. It's based on the ioquake3 engine, and its unique style and uproarious gameplay have earned it a featured place in multiple gaming magazines. You can download the source code from [GitHub][24]. + +### Give one a shot + +A game that becomes open source can act as a template for something great, whether it's a wholly open source version of an old classic, a remix of a beloved game, or an entirely new platform built on an old reliable engine. + +Open source gaming is important for many reasons: it provides users with a fun diversion, a way to connect with friends, and an opportunity for programmers and designers to hack within an existing framework. If titles like Doom weren't made open source, a little bit of video game history would be lost. Instead, it endures and has the opportunity to grow even more. + +Try an open source game, and watch your six. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/open-source-fps-games + +作者:[Aman Gaur][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/amangaur +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/game_pawn_grid_linux.png?itok=4gERzRkg (Gaming on a grid with penguin pawns) +[2]: https://opensource.com/sites/default/files/uploads/xonotic.jpg (Xonotic) +[3]: https://www.xonotic.org/download/ +[4]: https://opensource.com/sites/default/files/uploads/wolfensteinenemyterritory.jpg (Wolfenstein Enemy Territory) +[5]: https://www.splashdamage.com/games/wolfenstein-enemy-territory/ +[6]: https://github.com/id-Software/Enemy-Territory +[7]: https://opensource.com/sites/default/files/uploads/doom.jpg (Doom) +[8]: https://github.com/id-Software/DOOM +[9]: https://freedoom.github.io/ +[10]: https://dhewm3.org/ +[11]: https://github.com/RobertBeckebans/RBDOOM-3-BFG/ +[12]: https://opensource.com/sites/default/files/uploads/smokinguns.jpg (Smokin' Guns) +[13]: https://www.smokin-guns.org/downloads +[14]: https://opensource.com/sites/default/files/uploads/nexuiz.jpg (Nexuiz) +[15]: https://sourceforge.net/projects/nexuiz/ +[16]: https://opensource.com/sites/default/files/uploads/kkrieger.jpg (kkrieger) +[17]: https://web.archive.org/web/20120204065621/http://www.theprodukkt.com/kkrieger +[18]: https://github.com/farbrausch/fr_public +[19]: https://opensource.com/sites/default/files/uploads/warsow.jpg (Warsow) +[20]: https://www.warsow.net/download +[21]: https://github.com/Warsow +[22]: https://opensource.com/sites/default/files/uploads/padman.jpg (World of Padman) +[23]: https://worldofpadman.net/en/ +[24]: https://github.com/PadWorld-Entertainment diff --git a/sources/tech/20200505 Analyzing data science code with R and Emacs.md b/sources/tech/20200505 Analyzing data science code with R and Emacs.md new file mode 100644 index 0000000000..ebcfadbe92 --- /dev/null +++ b/sources/tech/20200505 Analyzing data science code with R and Emacs.md @@ -0,0 +1,133 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Analyzing data science code with R and Emacs) +[#]: via: (https://opensource.com/article/20/5/r-emacs-data-science) +[#]: author: (Peter Prevos https://opensource.com/users/danderzei) + +Analyzing data science code with R and Emacs +====== +Emacs' versatility and extensibility bring the editor's full power into +play for writing data science code. +![metrics and data shown on a computer screen][1] + +Way back in 2012, _Harvard Business Review_ published an article that proclaimed "data scientist" to be the [sexiest job][2] of the 21st century. Interest in data science has exploded since then. Many great open source projects, such as [Python][3] and the [R language][4] for statistical computing, have facilitated the rapid developments in how we analyze data. + +I started my career using pencil and paper and moved to spreadsheets. Now the R language is my weapon of choice when I need to create value from data. Emacs is another one of my favorite tools. This article briefly explains how to use the [Emacs Speaks Statistics][5] (ESS) package to get started with developing R projects in this venerable editor. + +The vast majority of R developers use the [RStudio][6] IDE to manage their projects. RStudio is a powerful open source editor with specialized functionality to develop data science projects. RStudio is a great integrated development environment (IDE), but its editing functions are limited. + +Using Emacs to write data science code means that you have access to the full power of this extensible editor. I prefer using Emacs for my data science projects because I can do many other tasks within the same application, leveraging the multifunctionality of this venerable editor. If you are just getting started with Emacs, then please first read Seth Kenlon's [Emacs getting started][7] article. + +### Setting up Emacs for R + +Emacs is an almost infinitely extensible text editor, which unfortunately means that many things don't work the way you want them to out of the box. Before you can write and execute R scripts, you need to install some packages and configure them. The ESS package provides an interface between Emacs and R. Other packages, such as [Company][8] and [highlight-parentheses][9] help with completion and balancing parentheses. + +Emacs uses a version of Lisp for configuration. The lines of [Emacs Lisp][10] code below install the required extensions and define a minimal configuration to get you started. These lines were tested for GNU Emacs version 26.3. + +Copy these lines and save them in a file named **init.el** in your **.emacs.d** folder. This is the folder that Emacs uses to store configurations, including the [init file][11]. If you already have an init file, then you can append these lines to your config. This minimal configuration is enough to get you started. + + +``` +;; Elisp file for R coding with Emacs + +;; Add MELPA repository and initialise the package manager +(require 'package) +(add-to-list 'package-archives +             '("melpa" . "")) +(package-initialize) + +;; Install use-package,in case it does not exist yet +;; The use-package software will install all other packages as required +(unless (package-installed-p 'use-package) +  (package-refresh-contents) +  (package-install 'use-package)) + +;; ESS configurationEmacs Speaks Statistics +(use-package ess +  :ensure t +) + +;; Auto completion +(use-package company +  :ensure t +  :config +  (setq company-idle-delay 0) +  (setq company-minimum-prefix-length 2) +  (global-company-mode t) +) + +; Parentheses +(use-package highlight-parentheses +  :ensure t +  :config +  (progn +    (highlight-parentheses-mode) +    (global-highlight-parentheses-mode)) +  ) +``` + +### Using the R console + +To start an R console session, press **M-x R** and hit **Enter** (**M** is the Emacs way to denote the **Alt** or **Command** key). ESS will ask you to nominate a working directory, which defaults to the folder of the current buffer. You can use more than one console in the same Emacs session by repeating the R command. + +Emacs opens a new buffer for your new R console. You can also use the **Up** and **Down** arrow keys to go to previous lines and re-run them. Use the **Ctrl** and **Up/Down** arrow keys to recycle old commands. + +The Company ("complete anything") package manages autocompletion in both the console and R scripts. When entering a function, the mini-buffer at the bottom of the screen shows the relevant parameters. When the autocompletion dropdown menu appears, you can press **F1** to view the chosen option's Help file before you select it. + +The [highlight-parentheses][9] package does what its name suggests. Several other Emacs packages are available to help you balance parentheses and other structural elements in your code. + +### Writing R scripts + +Emacs recognizes R mode for any buffer with a **.R** extension (the file extension is case-sensitive). Open or create a new file with the **C-x C-f** shortcut and type the path and file name. You can start writing your code and use all of the powerful editing techniques that Emacs provides. + +Several functions are available to evaluate the code. You can evaluate each line separately with **C-<return>**, while **C-c C-c** will evaluate a contiguous region. Keying **C-c C-b** will evaluate the whole buffer. + +When you evaluate some code, Emacs will use any running console or ask you to open a new console to run the code. + +The output of any plotting functions appears in a window outside of Emacs. If you prefer to view the output within Emacs, then you need to save the output to disk and open the resulting file in a separate buffer. + +![Literate programming in Org mode, the ESS buffer, and graphics output.][12] + +Literate programming in Org mode, the ESS buffer, and graphics output. + +### Advanced use + +This article provides a brief introduction to using R in Emacs. Many parameters can be fine-tuned to make Emacs behave according to your preferences, but it would take too much space to cover them here. The [ESS manual][13] describes these in detail. You can also extend functionality with additional packages. + +Org mode can integrate R code, providing a productive platform for literate programming. If you prefer to use RMarkdown, the [Polymode][14] package has you covered. + +Emacs has various packages to make your editing experience more efficient. The best part of using Emacs to write R code is that the program is more than just an IDE; it is a malleable computer system that you can configure to match your favorite workflow. + +Learning how to configure Emacs can be daunting. The best way to learn quickly is to copy ideas from people who share their configurations. Miles McBain manages a [list of Emacs configurations][15] that could be useful if you want to explore using the R language in Emacs further. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/r-emacs-data-science + +作者:[Peter Prevos][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/danderzei +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_data_dashboard_system_computer_analytics.png?itok=oxAeIEI- (metrics and data shown on a computer screen) +[2]: https://hbr.org/2012/10/data-scientist-the-sexiest-job-of-the-21st-century +[3]: https://www.python.org/ +[4]: https://www.r-project.org/ +[5]: https://ess.r-project.org/ +[6]: https://opensource.com/article/18/2/getting-started-RStudio-IDE +[7]: https://opensource.com/article/20/3/getting-started-emacs +[8]: https://company-mode.github.io/ +[9]: https://github.com/tsdh/highlight-parentheses.el +[10]: https://en.wikipedia.org/wiki/Emacs_Lisp +[11]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Init-File.html +[12]: https://opensource.com/sites/default/files/uploads/r-ess-screenshot.jpg (Literate programming in Org mode, the ESS buffer, and graphics output.) +[13]: https://ess.r-project.org/index.php?Section=documentation&subSection=manuals +[14]: https://github.com/polymode/polymode +[15]: https://github.com/MilesMcBain/esscss diff --git a/sources/tech/20200507 Using the systemctl command to manage systemd units.md b/sources/tech/20200507 Using the systemctl command to manage systemd units.md new file mode 100644 index 0000000000..e305cee36c --- /dev/null +++ b/sources/tech/20200507 Using the systemctl command to manage systemd units.md @@ -0,0 +1,618 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Using the systemctl command to manage systemd units) +[#]: via: (https://opensource.com/article/20/5/systemd-units) +[#]: author: (David Both https://opensource.com/users/dboth) + +Using the systemctl command to manage systemd units +====== +Units are the basis of everything in systemd. +![woman on laptop sitting at the window][1] + +In the first two articles in this series, I explored the Linux systemd startup sequence. In the [first article][2], I looked at systemd's functions and architecture and the controversy around its role as a replacement for the old SystemV init program and startup scripts. And in the [second article][3], I examined two important systemd tools, systemctl and journalctl, and explained how to switch from one target to another and to change the default target. + +In this third article, I'll look at systemd units in more detail and how to use the systemctl command to explore and manage units. I'll also explain how to stop and disable units and how to create a new systemd mount unit to mount a new filesystem and enable it to initiate during startup. + +### Preparation + +All of the experiments in this article should be done as the root user (unless otherwise specified). Some of the commands that simply list various systemd units can be performed by non-root users, but the commands that make changes cannot. Make sure to do all of these experiments only on non-production hosts or virtual machines (VMs). + +One of these experiments requires the sysstat package, so install it before you move on. For Fedora and other Red Hat-based distributions you can install sysstat with: + + +``` +`dnf -y install sysstat` +``` + +The sysstat RPM installs several statistical tools that can be used for problem determination. One is [System Activity Report][4] (SAR), which records many system performance data points at regular intervals (every 10 minutes by default). Rather than run as a daemon in the background, the sysstat package installs two systemd timers. One timer runs every 10 minutes to collect data, and the other runs once a day to aggregate the daily data. In this article, I will look briefly at these timers but wait to explain how to create a timer in a future article. + +### systemd suite + +The fact is, systemd is more than just one program. It is a large suite of programs all designed to work together to manage nearly every aspect of a running Linux system. A full exposition of systemd would take a book on its own. Most of us do not need to understand all of the details about how all of systemd's components fit together, so I will focus on the programs and components that enable you to manage various Linux services and deal with log files and journals. + +### Practical structure + +The structure of systemd—outside of its executable files—is contained in its many configuration files. Although these files have different names and identifier extensions, they are all called "unit" files. Units are the basis of everything systemd. + +Unit files are ASCII plain-text files that are accessible to and can be created or modified by a sysadmin. There are a number of unit file types, and each has its own man page. Figure 1 lists some of these unit file types by their filename extensions and a short description of each. + +systemd unit | Description +---|--- +.automount | The **.automount** units are used to implement on-demand (i.e., plug and play) and mounting of filesystem units in parallel during startup. +.device | The **.device** unit files define hardware and virtual devices that are exposed to the sysadmin in the **/dev/directory**. Not all devices have unit files; typically, block devices such as hard drives, network devices, and some others have unit files. +.mount | The **.mount** unit defines a mount point on the Linux filesystem directory structure. +.scope | The **.scope** unit defines and manages a set of system processes. This unit is not configured using unit files, rather it is created programmatically. Per the **systemd.scope** man page, “The main purpose of scope units is grouping worker processes of a system service for organization and for managing resources.” +.service | The **.service** unit files define processes that are managed by systemd. These include services such as crond cups (Common Unix Printing System), iptables, multiple logical volume management (LVM) services, NetworkManager, and more. +.slice | The **.slice** unit defines a “slice,” which is a conceptual division of system resources that are related to a group of processes. You can think of all system resources as a pie and this subset of resources as a “slice” out of that pie. +.socket | The **.socket** units define interprocess communication sockets, such as network sockets. +.swap | The **.swap** units define swap devices or files. +.target | The **.target** units define groups of unit files that define startup synchronization points, runlevels, and services. Target units define the services and other units that must be active in order to start successfully. +.timer | The **.timer** unit defines timers that can initiate program execution at specified times. + +### systemctl + +I looked at systemd's startup functions in the [second article][3], and here I'll explore its service management functions a bit further. systemd provides the **systemctl** command that is used to start and stop services, configure them to launch (or not) at system startup, and monitor the current status of running services. + +In a terminal session as the root user, ensure that root's home directory ( **~** ) is the [PWD][5]. To begin looking at units in various ways, list all of the loaded and active systemd units. systemctl automatically pipes its [stdout][6] data stream through the **less** pager, so you don't have to: + + +``` +[root@testvm1 ~]# systemctl +UNIT                                       LOAD   ACTIVE SUB       DESCRIPTION               +proc-sys-fs-binfmt_misc.automount          loaded active running   Arbitrary Executable File> +sys-devices-pci0000:00-0000:00:01.1-ata7-host6-target6:0:0-6:0:0:0-block-sr0.device loaded a> +sys-devices-pci0000:00-0000:00:03.0-net-enp0s3.device loaded active plugged   82540EM Gigabi> +sys-devices-pci0000:00-0000:00:05.0-sound-card0.device loaded active plugged   82801AA AC'97> +sys-devices-pci0000:00-0000:00:08.0-net-enp0s8.device loaded active plugged   82540EM Gigabi> +sys-devices-pci0000:00-0000:00:0d.0-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda1.device loa> +sys-devices-pci0000:00-0000:00:0d.0-ata1-host0-target0:0:0-0:0:0:0-block-sda-sda2.device loa> +<snip – removed lots of lines of data from here> + +LOAD   = Reflects whether the unit definition was properly loaded. +ACTIVE = The high-level unit activation state, i.e. generalization of SUB. +SUB    = The low-level unit activation state, values depend on unit type. + +206 loaded units listed. Pass --all to see loaded but inactive units, too. +To show all installed unit files use 'systemctl list-unit-files'. +``` + +As you scroll through the data in your terminal session, look for some specific things. The first section lists devices such as hard drives, sound cards, network interface cards, and TTY devices. Another section shows the filesystem mount points. Other sections include various services and a list of all loaded and active targets. + +The sysstat timers at the bottom of the output are used to collect and generate daily system activity summaries for SAR. SAR is a very useful problem-solving tool. (You can learn more about it in Chapter 13 of my book [_Using and Administering Linux: Volume 1, Zero to SysAdmin: Getting Started_][7].) + +Near the very bottom, three lines describe the meanings of the statuses (loaded, active, and sub). Press **q** to exit the pager. + +Use the following command (as suggested in the last line of the output above) to see all the units that are installed, whether or not they are loaded. I won't reproduce the output here, because you can scroll through it on your own. The systemctl program has an excellent tab-completion facility that makes it easy to enter complex commands without needing to memorize all the options: + + +``` +`[root@testvm1 ~]# systemctl list-unit-files` +``` + +You can see that some units are disabled. Table 1 in the man page for systemctl lists and provides short descriptions of the entries you might see in this listing. Use the **-t** (type) option to view just the timer units: + + +``` +[root@testvm1 ~]# systemctl list-unit-files -t timer +UNIT FILE                    STATE   +[chrony-dnssrv@.timer][8]         disabled +dnf-makecache.timer          enabled +fstrim.timer                 disabled +logrotate.timer              disabled +logwatch.timer               disabled +[mdadm-last-resort@.timer][9]     static   +mlocate-updatedb.timer       enabled +sysstat-collect.timer        enabled +sysstat-summary.timer        enabled +systemd-tmpfiles-clean.timer static   +unbound-anchor.timer         enabled +``` + +You could do the same thing with this alternative, which provides considerably more detail: + + +``` +[root@testvm1 ~]# systemctl list-timers +Thu 2020-04-16 09:06:20 EDT  3min 59s left n/a                          n/a           systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service +Thu 2020-04-16 10:02:01 EDT  59min left    Thu 2020-04-16 09:01:32 EDT  49s ago       dnf-makecache.timer          dnf-makecache.service +Thu 2020-04-16 13:00:00 EDT  3h 57min left n/a                          n/a           sysstat-collect.timer        sysstat-collect.service +Fri 2020-04-17 00:00:00 EDT  14h left      Thu 2020-04-16 12:51:37 EDT  3h 49min left mlocate-updatedb.timer       mlocate-updatedb.service +Fri 2020-04-17 00:00:00 EDT  14h left      Thu 2020-04-16 12:51:37 EDT  3h 49min left unbound-anchor.timer         unbound-anchor.service +Fri 2020-04-17 00:07:00 EDT  15h left      n/a                          n/a           sysstat-summary.timer        sysstat-summary.service + +6 timers listed. +Pass --all to see loaded but inactive timers, too. +[root@testvm1 ~]# +``` + +Although there is no option to do systemctl list-mounts, you can list the mount point unit files: + + +``` +[root@testvm1 ~]# systemctl list-unit-files -t mount +UNIT FILE                     STATE     +-.mount                       generated +boot.mount                    generated +dev-hugepages.mount           static   +dev-mqueue.mount              static   +home.mount                    generated +proc-fs-nfsd.mount            static   +proc-sys-fs-binfmt_misc.mount disabled +run-vmblock\x2dfuse.mount     disabled +sys-fs-fuse-connections.mount static   +sys-kernel-config.mount       static   +sys-kernel-debug.mount        static   +tmp.mount                     generated +usr.mount                     generated +var-lib-nfs-rpc_pipefs.mount  static   +var.mount                     generated + +15 unit files listed. +[root@testvm1 ~]# +``` + +The STATE column in this data stream is interesting and requires a bit of explanation. The "generated" states indicate that the mount unit was generated on the fly during startup using the information in **/etc/fstab**. The program that generates these mount units is **/lib/systemd/system-generators/systemd-fstab-generator,** along with other tools that generate a number of other unit types. The "static" mount units are for filesystems like **/proc** and **/sys**, and the files for these are located in the **/usr/lib/systemd/system** directory. + +Now, look at the service units. This command will show all services installed on the host, whether or not they are active: + + +``` +`[root@testvm1 ~]# systemctl --all -t service` +``` + +The bottom of this listing of service units displays 166 as the total number of loaded units on my host. Your number will probably differ. + +Unit files do not have a filename extension (such as **.unit**) to help identify them, so you can generalize that most configuration files that belong to systemd are unit files of one type or another. The few remaining files are mostly **.conf** files located in **/etc/systemd**. + +Unit files are stored in the **/usr/lib/systemd** directory and its subdirectories, while the **/etc/systemd/** directory and its subdirectories contain symbolic links to the unit files necessary to the local configuration of this host. + +To explore this, make **/etc/systemd** the PWD and list its contents. Then make **/etc/systemd/system** the PWD and list its contents, and list the contents of at least a couple of the current PWD's subdirectories. + +Take a look at the **default.target** file, which determines which runlevel target the system will boot to. In the second article in this series, I explained how to change the default target from the GUI (**graphical.target**) to the command-line only (**multi-user.target**) target. The **default.target** file on my test VM is simply a symlink to **/usr/lib/systemd/system/graphical.target**. + +Take a few minutes to examine the contents of the **/etc/systemd/system/default.target** file: + + +``` +[root@testvm1 system]# cat default.target +#  SPDX-License-Identifier: LGPL-2.1+ +# +#  This file is part of systemd. +# +#  systemd is free software; you can redistribute it and/or modify it +#  under the terms of the GNU Lesser General Public License as published by +#  the Free Software Foundation; either version 2.1 of the License, or +#  (at your option) any later version. + +[Unit] +Description=Graphical Interface +Documentation=man:systemd.special(7) +Requires=multi-user.target +Wants=display-manager.service +Conflicts=rescue.service rescue.target +After=multi-user.target rescue.service rescue.target display-manager.service +AllowIsolate=yes +``` + +Note that this requires the **multi-user.target**; the **graphical.target** cannot start if the **multi-user.target** is not already up and running. It also says it "wants" the **display-manager.service** unit. A "want" does not need to be fulfilled in order for the unit to start successfully. If the "want" cannot be fulfilled, it will be ignored by systemd, and the rest of the target will start regardless. + +The subdirectories in **/etc/systemd/system** are lists of wants for various targets. Take a few minutes to explore the files and their contents in the **/etc/systemd/system/graphical.target.wants** directory. + +The **systemd.unit** man page contains a lot of good information about unit files, their structure, the sections they can be divided into, and the options that can be used. It also lists many of the unit types, all of which have their own man pages. If you want to interpret a unit file, this would be a good place to start. + +### Service units + +A Fedora installation usually installs and enables services that particular hosts do not need for normal operation. Conversely, sometimes it doesn't include services that need to be installed, enabled, and started. Services that are not needed for the Linux host to function as desired, but which are installed and possibly running, represent a security risk and should—at minimum—be stopped and disabled and—at best—should be uninstalled. + +The systemctl command is used to manage systemd units, including services, targets, mounts, and more. Take a closer look at the list of services to identify services that will never be used: + + +``` +[root@testvm1 ~]# systemctl --all -t service +UNIT                           LOAD      ACTIVE SUB        DESCRIPTION                             +<snip> +chronyd.service                loaded    active running    NTP client/server                       +crond.service                  loaded    active running    Command Scheduler                       +cups.service                   loaded    active running    CUPS Scheduler                           +dbus-daemon.service            loaded    active running    D-Bus System Message Bus                 +<snip> +● ip6tables.service           not-found inactive dead     ip6tables.service                   +● ipset.service               not-found inactive dead     ipset.service                       +● iptables.service            not-found inactive dead     iptables.service                     +<snip> +firewalld.service              loaded    active   running  firewalld - dynamic firewall daemon +<snip> +● ntpd.service                not-found inactive dead     ntpd.service                         +● ntpdate.service             not-found inactive dead     ntpdate.service                     +pcscd.service                  loaded    active   running  PC/SC Smart Card Daemon +``` + +I have pruned out most of the output from the command to save space. The services that show "loaded active running" are obvious. The "not-found" services are ones that systemd is aware of but are not installed on the Linux host. If you want to run those services, you must install the packages that contain them. + +Note the **pcscd.service** unit. This is the PC/SC smart-card daemon. Its function is to communicate with smart-card readers. Many Linux hosts—including VMs—have no need for this reader nor the service that is loaded and taking up memory and CPU resources. You can stop this service and disable it, so it will not restart on the next boot. First, check its status: + + +``` +[root@testvm1 ~]# systemctl status pcscd.service +● pcscd.service - PC/SC Smart Card Daemon +   Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled) +   Active: active (running) since Fri 2019-05-10 11:28:42 EDT; 3 days ago +     Docs: man:pcscd(8) + Main PID: 24706 (pcscd) +    Tasks: 6 (limit: 4694) +   Memory: 1.6M +   CGroup: /system.slice/pcscd.service +           └─24706 /usr/sbin/pcscd --foreground --auto-exit + +May 10 11:28:42 testvm1 systemd[1]: Started PC/SC Smart Card Daemon. +``` + +This data illustrates the additional information systemd provides versus SystemV, which only reports whether or not the service is running. Note that specifying the **.service** unit type is optional. Now stop and disable the service, then re-check its status: + + +``` +[root@testvm1 ~]# systemctl stop pcscd ; systemctl disable pcscd +Warning: Stopping pcscd.service, but it can still be activated by: +  pcscd.socket +Removed /etc/systemd/system/sockets.target.wants/pcscd.socket. +[root@testvm1 ~]# systemctl status pcscd +● pcscd.service - PC/SC Smart Card Daemon +   Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled) +   Active: failed (Result: exit-code) since Mon 2019-05-13 15:23:15 EDT; 48s ago +     Docs: man:pcscd(8) + Main PID: 24706 (code=exited, status=1/FAILURE) + +May 10 11:28:42 testvm1 systemd[1]: Started PC/SC Smart Card Daemon. +May 13 15:23:15 testvm1 systemd[1]: Stopping PC/SC Smart Card Daemon... +May 13 15:23:15 testvm1 systemd[1]: pcscd.service: Main process exited, code=exited, status=1/FAIL> +May 13 15:23:15 testvm1 systemd[1]: pcscd.service: Failed with result 'exit-code'. +May 13 15:23:15 testvm1 systemd[1]: Stopped PC/SC Smart Card Daemon. +``` + +The short log entry display for most services prevents having to search through various log files to locate this type of information. Check the status of the system runlevel targets—specifying the "target" unit type is required: + + +``` +[root@testvm1 ~]# systemctl status multi-user.target +● multi-user.target - Multi-User System +   Loaded: loaded (/usr/lib/systemd/system/multi-user.target; static; vendor preset: disabled) +   Active: active since Thu 2019-05-09 13:27:22 EDT; 4 days ago +     Docs: man:systemd.special(7) + +May 09 13:27:22 testvm1 systemd[1]: Reached target Multi-User System. +[root@testvm1 ~]# systemctl status graphical.target +● graphical.target - Graphical Interface +   Loaded: loaded (/usr/lib/systemd/system/graphical.target; indirect; vendor preset: disabled) +   Active: active since Thu 2019-05-09 13:27:22 EDT; 4 days ago +     Docs: man:systemd.special(7) + +May 09 13:27:22 testvm1 systemd[1]: Reached target Graphical Interface. +[root@testvm1 ~]# systemctl status default.target +● graphical.target - Graphical Interface +   Loaded: loaded (/usr/lib/systemd/system/graphical.target; indirect; vendor preset: disabled) +   Active: active since Thu 2019-05-09 13:27:22 EDT; 4 days ago +     Docs: man:systemd.special(7) + +May 09 13:27:22 testvm1 systemd[1]: Reached target Graphical Interface. +``` + +The default target is the graphical target. The status of any unit can be checked in this way. + +### Mounts the old way + +A mount unit defines all of the parameters required to mount a filesystem on a designated mount point. systemd can manage mount units with more flexibility than those using the **/etc/fstab** filesystem configuration file. Despite this, systemd still uses the **/etc/fstab** file for filesystem configuration and mounting purposes. systemd uses the **systemd-fstab-generator** tool to create transient mount units from the data in the **fstab** file. + +I will create a new filesystem and a systemd mount unit to mount it. If you have some available disk space on your test system, you can do it along with me. + +_Note that the volume group and logical volume names may be different on your test system. Be sure to use the names that are pertinent to your system._ + +You will need to create a partition or logical volume, then make an EXT4 filesystem on it. Add a label to the filesystem, **TestFS**, and create a directory for a mount point **/TestFS**. + +To try this on your own, first, verify that you have free space on the volume group. Here is what that looks like on my VM where I have some space available on the volume group to create a new logical volume: + + +``` +[root@testvm1 ~]# lsblk +NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT +sda             8:0    0  120G  0 disk +├─sda1          8:1    0    4G  0 part /boot +└─sda2          8:2    0  116G  0 part +  ├─VG01-root 253:0    0    5G  0 lvm  / +  ├─VG01-swap 253:1    0    8G  0 lvm  [SWAP] +  ├─VG01-usr  253:2    0   30G  0 lvm  /usr +  ├─VG01-home 253:3    0   20G  0 lvm  /home +  ├─VG01-var  253:4    0   20G  0 lvm  /var +  └─VG01-tmp  253:5    0   10G  0 lvm  /tmp +sr0            11:0    1 1024M  0 rom   +[root@testvm1 ~]# vgs +  VG   #PV #LV #SN Attr   VSize    VFree   +  VG01   1   6   0 wz--n- <116.00g <23.00g +``` + +Then create a new volume on **VG01** named **TestFS**. It does not need to be large; 1GB is fine. Then create a filesystem, add the filesystem label, and create the mount point: + + +``` +[root@testvm1 ~]# lvcreate -L 1G -n TestFS VG01 +  Logical volume "TestFS" created. +[root@testvm1 ~]# mkfs -t ext4 /dev/mapper/VG01-TestFS +mke2fs 1.45.3 (14-Jul-2019) +Creating filesystem with 262144 4k blocks and 65536 inodes +Filesystem UUID: 8718fba9-419f-4915-ab2d-8edf811b5d23 +Superblock backups stored on blocks: +        32768, 98304, 163840, 229376 + +Allocating group tables: done                             +Writing inode tables: done                             +Creating journal (8192 blocks): done +Writing superblocks and filesystem accounting information: done + +[root@testvm1 ~]# e2label /dev/mapper/VG01-TestFS TestFS +[root@testvm1 ~]# mkdir /TestFS +``` + +Now, mount the new filesystem: + + +``` +[root@testvm1 ~]# mount /TestFS/ +mount: /TestFS/: can't find in /etc/fstab. +``` + +This will not work because you do not have an entry in **/etc/fstab**. You can mount the new filesystem even without the entry in **/etc/fstab** using both the device name (as it appears in **/dev**) and the mount point. Mounting in this manner is simpler than it used to be—it used to require the filesystem type as an argument. The mount command is now smart enough to detect the filesystem type and mount it accordingly. + +Try it again: + + +``` +[root@testvm1 ~]# mount /dev/mapper/VG01-TestFS /TestFS/ +[root@testvm1 ~]# lsblk +NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT +sda               8:0    0  120G  0 disk +├─sda1            8:1    0    4G  0 part /boot +└─sda2            8:2    0  116G  0 part +  ├─VG01-root   253:0    0    5G  0 lvm  / +  ├─VG01-swap   253:1    0    8G  0 lvm  [SWAP] +  ├─VG01-usr    253:2    0   30G  0 lvm  /usr +  ├─VG01-home   253:3    0   20G  0 lvm  /home +  ├─VG01-var    253:4    0   20G  0 lvm  /var +  ├─VG01-tmp    253:5    0   10G  0 lvm  /tmp +  └─VG01-TestFS 253:6    0    1G  0 lvm  /TestFS +sr0              11:0    1 1024M  0 rom   +[root@testvm1 ~]# +``` + +Now the new filesystem is mounted in the proper location. List the mount unit files: + + +``` +`[root@testvm1 ~]# systemctl list-unit-files -t mount` +``` + +This command does not show a file for the **/TestFS** filesystem because no file exists for it. The command **systemctl status TestFS.mount** does not display any information about the new filesystem either. You can try it using wildcards with the **systemctl status** command: + + +``` +[root@testvm1 ~]# systemctl status *mount +● usr.mount - /usr +   Loaded: loaded (/etc/fstab; generated) +   Active: active (mounted) +    Where: /usr +     What: /dev/mapper/VG01-usr +     Docs: man:fstab(5) +           man:systemd-fstab-generator(8) + +<SNIP> +● TestFS.mount - /TestFS +   Loaded: loaded (/proc/self/mountinfo) +   Active: active (mounted) since Fri 2020-04-17 16:02:26 EDT; 1min 18s ago +    Where: /TestFS +     What: /dev/mapper/VG01-TestFS + +● run-user-0.mount - /run/user/0 +   Loaded: loaded (/proc/self/mountinfo) +   Active: active (mounted) since Thu 2020-04-16 08:52:29 EDT; 1 day 5h ago +    Where: /run/user/0 +     What: tmpfs + +● var.mount - /var +   Loaded: loaded (/etc/fstab; generated) +   Active: active (mounted) since Thu 2020-04-16 12:51:34 EDT; 1 day 1h ago +    Where: /var +     What: /dev/mapper/VG01-var +     Docs: man:fstab(5) +           man:systemd-fstab-generator(8) +    Tasks: 0 (limit: 19166) +   Memory: 212.0K +      CPU: 5ms +   CGroup: /system.slice/var.mount +``` + +This command provides some very interesting information about your system's mounts, and your new filesystem shows up. The **/var** and **/usr** filesystems are identified as being generated from **/etc/fstab**, while your new filesystem simply shows that it is loaded and provides the location of the info file in the **/proc/self/mountinfo** file. + +Next, automate this mount. First, do it the old-fashioned way by adding an entry in **/etc/fstab**. Later, I'll show you how to do it the new way, which will teach you about creating units and integrating them into the startup sequence. + +Unmount **/TestFS** and add the following line to the **/etc/fstab** file: + + +``` +`/dev/mapper/VG01-TestFS  /TestFS       ext4    defaults        1 2` +``` + +Now, mount the filesystem with the simpler **mount** command and list the mount units again: + + +``` +[root@testvm1 ~]# mount /TestFS +[root@testvm1 ~]# systemctl status *mount +<SNIP> +● TestFS.mount - /TestFS +   Loaded: loaded (/proc/self/mountinfo) +   Active: active (mounted) since Fri 2020-04-17 16:26:44 EDT; 1min 14s ago +    Where: /TestFS +     What: /dev/mapper/VG01-TestFS +<SNIP> +``` + +This did not change the information for this mount because the filesystem was manually mounted. Reboot and run the command again, and this time specify **TestFS.mount** rather than using the wildcard. The results for this mount are now consistent with it being mounted at startup: + + +``` +[root@testvm1 ~]# systemctl status TestFS.mount +● TestFS.mount - /TestFS +   Loaded: loaded (/etc/fstab; generated) +   Active: active (mounted) since Fri 2020-04-17 16:30:21 EDT; 1min 38s ago +    Where: /TestFS +     What: /dev/mapper/VG01-TestFS +     Docs: man:fstab(5) +           man:systemd-fstab-generator(8) +    Tasks: 0 (limit: 19166) +   Memory: 72.0K +      CPU: 6ms +   CGroup: /system.slice/TestFS.mount + +Apr 17 16:30:21 testvm1 systemd[1]: Mounting /TestFS... +Apr 17 16:30:21 testvm1 systemd[1]: Mounted /TestFS. +``` + +### Creating a mount unit + +Mount units may be configured either with the traditional **/etc/fstab** file or with systemd units. Fedora uses the **fstab** file as it is created during the installation. However, systemd uses the **systemd-fstab-generator** program to translate the **fstab** file into systemd units for each entry in the **fstab** file. Now that you know you can use systemd **.mount** unit files for filesystem mounting, try it out by creating a mount unit for this filesystem. + +First, unmount **/TestFS**. Edit the **/etc/fstab** file and delete or comment out the **TestFS** line. Now, create a new file with the name **TestFS.mount** in the **/etc/systemd/system** directory. Edit it to contain the configuration data below. The unit file name and the name of the mount point _must_ be identical, or the mount will fail: + + +``` +# This mount unit is for the TestFS filesystem +# By David Both +# Licensed under GPL V2 +# This file should be located in the /etc/systemd/system directory + +[Unit] +Description=TestFS Mount + +[Mount] +What=/dev/mapper/VG01-TestFS +Where=/TestFS +Type=ext4 +Options=defaults + +[Install] +WantedBy=multi-user.target +``` + +The **Description** line in the **[Unit]** section is for us humans, and it provides the name that's shown when you list mount units with **systemctl -t mount**. The data in the **[Mount]** section of this file contains essentially the same data that would be found in the **fstab** file. + +Now enable the mount unit: + + +``` +[root@testvm1 etc]# systemctl enable TestFS.mount +Created symlink /etc/systemd/system/multi-user.target.wants/TestFS.mount → /etc/systemd/system/TestFS.mount. +``` + +This creates the symlink in the **/etc/systemd/system** directory, which will cause this mount unit to be mounted on all subsequent boots. The filesystem has not yet been mounted, so you must "start" it: + + +``` +`[root@testvm1 ~]# systemctl start TestFS.mount` +``` + +Verify that the filesystem has been mounted: + + +``` +[root@testvm1 ~]# systemctl status TestFS.mount +● TestFS.mount - TestFS Mount +   Loaded: loaded (/etc/systemd/system/TestFS.mount; enabled; vendor preset: disabled) +   Active: active (mounted) since Sat 2020-04-18 09:59:53 EDT; 14s ago +    Where: /TestFS +     What: /dev/mapper/VG01-TestFS +    Tasks: 0 (limit: 19166) +   Memory: 76.0K +      CPU: 3ms +   CGroup: /system.slice/TestFS.mount + +Apr 18 09:59:53 testvm1 systemd[1]: Mounting TestFS Mount... +Apr 18 09:59:53 testvm1 systemd[1]: Mounted TestFS Mount. +``` + +This experiment has been specifically about creating a unit file for a mount, but it can be applied to other types of unit files as well. The details will be different, but the concepts are the same. Yes, I know it is still easier to add a line to the **/etc/fstab** file than it is to create a mount unit. But this is a good example of how to create a unit file because systemd does not have generators for every type of unit. + +### In summary + +This article looked at systemd units in more detail and how to use the systemctl command to explore and manage units. It also showed how to stop and disable units and create a new systemd mount unit to mount a new filesystem and enable it to initiate during startup. + +In the next article in this series, I will take you through a recent problem I had during startup and show you how I circumvented it using systemd. + +### Resources + +There is a great deal of information about systemd available on the internet, but much is terse, obtuse, or even misleading. In addition to the resources mentioned in this article, the following webpages offer more detailed and reliable information about systemd startup. + + * The Fedora Project has a good, practical [guide][10] [to systemd][10]. It has pretty much everything you need to know in order to configure, manage, and maintain a Fedora computer using systemd. + * The Fedora Project also has a good [cheat sheet][11] that cross-references the old SystemV commands to comparable systemd ones. + * For detailed technical information about systemd and the reasons for creating it, check out [Freedesktop.org][12]'s [description of systemd][13]. + * [Linux.com][14]'s "More systemd fun" offers more advanced systemd [information and tips][15]. + + + +There is also a series of deeply technical articles for Linux sysadmins by Lennart Poettering, the designer and primary developer of systemd. These articles were written between April 2010 and September 2011, but they are just as relevant now as they were then. Much of everything else good that has been written about systemd and its ecosystem is based on these papers. + + * [Rethinking PID 1][16] + * [systemd for Administrators, Part I][17] + * [systemd for Administrators, Part II][18] + * [systemd for Administrators, Part III][19] + * [systemd for Administrators, Part IV][20] + * [systemd for Administrators, Part V][21] + * [systemd for Administrators, Part VI][22] + * [systemd for Administrators, Part VII][23] + * [systemd for Administrators, Part VIII][24] + * [systemd for Administrators, Part IX][25] + * [systemd for Administrators, Part X][26] + * [systemd for Administrators, Part XI][27] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/systemd-units + +作者:[David Both][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/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/lenovo-thinkpad-laptop-window-focus.png?itok=g0xPm2kD (young woman working on a laptop) +[2]: https://opensource.com/article/20/4/systemd +[3]: https://opensource.com/article/20/4/systemd-startup +[4]: https://en.wikipedia.org/wiki/Sar_%28Unix%29 +[5]: https://en.wikipedia.org/wiki/Pwd +[6]: https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout) +[7]: http://www.both.org/?page_id=1183 +[8]: mailto:chrony-dnssrv@.timer +[9]: mailto:mdadm-last-resort@.timer +[10]: https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html +[11]: https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet +[12]: http://Freedesktop.org +[13]: http://www.freedesktop.org/wiki/Software/systemd +[14]: http://Linux.com +[15]: https://www.linux.com/training-tutorials/more-systemd-fun-blame-game-and-stopping-services-prejudice/ +[16]: http://0pointer.de/blog/projects/systemd.html +[17]: http://0pointer.de/blog/projects/systemd-for-admins-1.html +[18]: http://0pointer.de/blog/projects/systemd-for-admins-2.html +[19]: http://0pointer.de/blog/projects/systemd-for-admins-3.html +[20]: http://0pointer.de/blog/projects/systemd-for-admins-4.html +[21]: http://0pointer.de/blog/projects/three-levels-of-off.html +[22]: http://0pointer.de/blog/projects/changing-roots +[23]: http://0pointer.de/blog/projects/blame-game.html +[24]: http://0pointer.de/blog/projects/the-new-configuration-files.html +[25]: http://0pointer.de/blog/projects/on-etc-sysinit.html +[26]: http://0pointer.de/blog/projects/instances.html +[27]: http://0pointer.de/blog/projects/inetd.html diff --git a/sources/tech/20200508 A guide to setting up your Open Source Program Office (OSPO) for success.md b/sources/tech/20200508 A guide to setting up your Open Source Program Office (OSPO) for success.md new file mode 100644 index 0000000000..ea3aa01866 --- /dev/null +++ b/sources/tech/20200508 A guide to setting up your Open Source Program Office (OSPO) for success.md @@ -0,0 +1,193 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A guide to setting up your Open Source Program Office (OSPO) for success) +[#]: via: (https://opensource.com/article/20/5/open-source-program-office) +[#]: author: (J. Manrique Lopez de la Fuente https://opensource.com/users/jsmanrique) + +A guide to setting up your Open Source Program Office (OSPO) for success +====== +Learn how to best grow and maintain your open source communities and +allies. +![community team brainstorming ideas][1] + +Companies create Open Source Program Offices (OSPO) to manage their relationship with the open source ecosystems they depend on. By understanding the company's open source ecosystem, an OSPO is able to maximize the company's return on investment and reduce the risks of consuming, contributing to, and releasing open source software. Additionally, since the company depends on its open source ecosystem, ensuring its health and sustainability shall ensure the company's health, sustainable growth, and evolution. + +### How has OSPO become vital to companies and their open source ecosystem? + +Marc Andreessen has said that "software is eating the world," and more recently, it could be said that open source is eating the software world. But how is that process happening? + +Companies get involved with open source projects in several ways. These projects comprise the company's open source ecosystem, and their relationships and interactions can be seen through Open Source Software's (OSS) inbound and outbound processes. + +From the OSS inbound point of view, companies use it to build their own solutions and their own infrastructure. OSS gets introduced because it's part of the code their technology providers use, or because their own developers add open source components to the company's information technology (IT) infrastructure. + +From the OSS outbound point of view, some companies contribute to OSS projects. That contribution could be part of the company's requirements for their solutions that need certain fixes in upstream projects. For example, Samsung contributes to certain graphics-related projects to ensure its hardware has software support once it gets into the market. In some other cases, contributing to OSS is a mechanism to retain talent by allowing the people to contribute to projects different from their daily work. + +Some companies release their own open source projects as an outbound OSS process. For companies like Red Hat or GitLab, it would be expected. But, there are increasingly more non-software companies releasing a lot of OSS, like Lyft. + +![OSS inbound and outbound processes][2] + +OSS inbound and outbound processes + +Ultimately, all of these projects involved in the inbound and outbound OSS flow are the company's OSS ecosystem. And like any living being, the company's health and sustainability depend on the ecosystem that surrounds it. + +### OSPO responsibilities + +Following the species and their ecosystem, people working in the OSPO team could be seen as the rangers in the organization's OSS ecosystem. They take care of the ecosystem and its relationship with the company, to keep everything healthy and sustainable. + +When the company consumes open source software projects, they need to be aware of licenses and compliance, to check the project's health, to ensure there are no security flaws, and, in some cases, to identify talented community members for potential hiring processes. + +When the company contributes to open source software projects, they need to be sure there are no Intellectual Property (IP) issues, to ensure the company contributions' footprint and its leadership in the projects, and sometimes, also to help talented people stay engaged with the company through their contributions. + +And when the company releases and maintains open source projects, they are responsible for ensuring community engagement and growth, for checking there are no IP issues, that the company maintains its footprint and leadership, and perhaps, to attract new talent to the company. + +Have you realized the whole set of skills required in an OSPO team? When I've asked people working in OSPO about the size of their teams, the number is around 1 to 5 people per 1,000 developers in the company. That's a small team to monitor a lot of people and their potential OSS related activity. + +### How to manage an OSPO + +With all these activities in OSPO people's minds and all the resources they need to worry about, how are they able to manage all of this? + +There are at least a couple of open source communities with valuable knowledge and resources available for them: + + * The [TODO Group][3] is "an open group of companies who want to collaborate on practices, tools, and other ways to run successful and effective open source projects and programs." For example, they have a complete set of [guides][4] with best practices for and from companies running OSPOS. + * The [CHAOSS (Community Health Analytics for Open Source Software)][5] community develops metrics, methodologies, and software for managing open source project health and sustainability. (See more on CHAOSS' active communities and working groups below). + + + +OSPO managers need to report a lot of information to the rest of the company to answer many questions related to their OSS inbound and outbound processes, i.e., Which projects are we using in our organization? What's the health of those projects? Who are the key people in those projects? Which projects are we contributing to? Which projects are we releasing? How are we dealing with community contributions? Who are the key contributors? + +### Data-driven OSPO + +As William Edwards Deming said, "Without data, you are just a person with an opinion." + +Having opinions is not a bad thing, but having opinions based on data certainly makes it easier to understand, discuss, and determine the processes best suited to your company and its goals. CHAOSS is the recommended community to look to for guidance about metrics strategies and tools. + +Recently, the CHAOSS community has released [a new set of metric definitions][6]. These metrics are only subsets of all the ones being discussed in the focus areas of each working group (WG): + + * [Common WG][7]: Defines the metrics that are used by both working groups or are important for community health, but that do not cleanly fit into one of the other existing working groups. Areas of interest include organizational affiliation, responsiveness, and geographic coverage. + * [Diversity and Inclusion WG][8]: Gathers experiences regarding diversity and inclusion in open source projects with the goal of understanding, from a qualitative and quantitative point of view, how diversity and inclusion can be measured. + * [Evolution WG][9]: Refines the metrics that inform evolution and works with software implementations. + * [Risk WG][10]: Refines the metrics that inform risk and works with software implementations. + * [Value WG][11]: Focuses on industry-standard metrics for economic value in open source. Their main goal is to publish trusted industry-standard value metrics—a kind of S&P for software development and an authoritative source for metrics significance and industry norms. + + + +On the tooling side, projects like [Augur][12], [Cregit][13], and [GrimoireLab][14] are the reference tools that report these metrics, but also many others related to OSPO activities. They are also the seed for new tools and solutions provided by the OSS community like [Cauldron.io][15], a SaaS open source solution to ease OSS ecosystem analysis. + +![CHAOSS Metrics for 15 years of Unity OSS activity. Source: cauldron.io][16] + +CHAOSS Metrics for 15 years of Unity OSS activity. Source: cauldron.io + +All these metrics and data are useless without a metrics strategy. Usually, the first approach is to try to measure as much as possible, producing overwhelming reports and dashboards full of charts and data. What is the value of that? + +Experience has shown that a very valid approach is the [Goal, Questions, Metrics (GQM)][17] strategy. But how do we put that in practice in an OSPO? + +First of all, we need to understand the company's goals when using, consuming, contributing to, or releasing and maintaining OSS projects. The usual goals are related to market positioning, required upstream features development, and talent attraction or retention. Based on these goals, we should write down related questions that can be answered with numbers, like the following: + +#### Who/how many are the core maintainers of my OSS ecosystem projects? + +![Uber OSS code core, regular, and casual contributors evolution. Source: uber.biterg.io][18] + +Uber OSS code core, regular, and casual contributors evolution. Source: uber.biterg.io + +People contribute through different mechanisms or tools (code, issues, comments, tests, etc.). Measuring the core contributors (those that have done 80% of the contributions), the regular ones (those that have done 15% of the contributions), and the casual ones (those have made 5% of the contributions) can answer questions related to participation over time, but also how people move between the different buckets. Adding affiliation information helps to identify external core contributors. + +#### Where are the contributions happening? + +![Uber OSS activity based on location. Source: uber.biterg.io][19] + +Uber OSS activity based on location. Source: uber.biterg.io + +The growth of OSS ecosystems is also related to OSS projects spread across the world. Understanding that spread helps OSPO, and the company, to manage actions that improve support for people from different countries and regions. + +#### What is the company's OSS network? + +![Uber OSS network. Source: uber.biterg.io][20] + +Uber OSS network. Source: uber.biterg.io + +The company's OSS ecosystem includes those projects that the company's people contribute to. Understanding which projects they contribute to offers insight into which technologies or OSS components are interesting to people, and which companies or organizations the company collaborates with. + +#### How is the company dealing with contributions? + +![Github Pull Requests backlog management index and time to close analysis. Source: uber.biterg.io][21] + +Github Pull Requests backlog management index and time to close analysis. Source: uber.biterg.io + +One of the goals when releasing OSS projects is to grow the community around them. Measuring how the company handles contributions to its projects from outside its boundaries helps to understand how "welcoming" it is and identifies mentors (or bottlenecks) and opportunities to lower the barrier to contribute. + +#### Consumers vs. maintainers + +Over the last months, we have been hearing that corporations are taking OSS for free without contributing back. The typical arguments are that these corporations are making millions of dollars thanks to free work, plus the issue of OSS project maintainer burnout due to users' complaints and requests for free support. + +The system is unbalanced; usually, the number of users exceeds the number of maintainers. Is that good or bad? Having users for our software is (or should be) good. But we need to manage expectations on both sides. + +From the corporation's point of view, consuming OSS without care is very, very risky. + +OSPO can play an important role in educating the company about the risks they are facing, and how to reduce them by contributing back to their OSS ecosystem. Remember, a company's overall sustainability could rely heavily on its ecosystem sustainability. + +A good strategy is to start shifting your company from being pure OSS consumers to becoming contributors to their OSS inbound projects. From just submitting issues and asking questions to help solve issues, answering questions, and even sending patches, contributing helps grow and maintain the project while giving back to the community. It doesn't happen immediately, but over time, the company will be perceived as an OSS ecosystem citizen. Eventually, some people from the company could end up helping to maintain those projects too. + +And what about money? There are plenty of ways to support the OSS ecosystem financially. Some examples: + + * Business initiatives like [Tidelift][22], or [OpenCollective][23] + * Foundations and their supporting mechanisms, like [Software Freedom Conservancy][24], or [CommunityBridge][25] from the Linux Foundation + * Self-funding programs (like [Indeed][26] and [Salesforce][27] have done) + * Emerging gig development approaches like [Github Sponsors][28] or [Patreon][29] + + + +Last but not least, companies need to avoid the "not invented here" syndrome. For some OSS projects, there might be companies providing consulting, customization, maintenance, and/or support services. Instead of taking OSS and spending time and people to self-host, self-customize, or try to bring those kinds of services in-house, it might be smarter and more efficient to hire some of those companies to do the thought work. + +As a final remark, I would like to emphasize the importance of an OSPO for a company to succeed and grow in the current market. As shepherds of the company's OSS ecosystem, they are the best people in the organization to understand how the ecosystem works and flows, and they should be empowered to manage, monitor, and make recommendations and decisions to ensure sustainability and growth. + +Does your organization have an OSPO yet? + +Six common traits of successful open source programs, and a look back at how the open source... + +Why would a company not in the business of software development create an open source program... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/open-source-program-office + +作者:[J. Manrique Lopez de la Fuente][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/jsmanrique +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/meeting_discussion_brainstorm.png?itok=7_m4CC8S (community team brainstorming ideas) +[2]: https://opensource.com/sites/default/files/uploads/ospo_1.png (OSS inbound and outbound processes) +[3]: https://todogroup.org/ +[4]: https://todogroup.org/guides/ +[5]: https://chaoss.community/ +[6]: https://chaoss.community/metrics/ +[7]: https://github.com/chaoss/wg-common +[8]: https://github.com/chaoss/wg-diversity-inclusion +[9]: https://github.com/chaoss/wg-evolution +[10]: https://github.com/chaoss/wg-risk +[11]: https://github.com/chaoss/wg-value +[12]: https://github.com/chaoss/augur +[13]: https://github.com/cregit +[14]: https://chaoss.github.io/grimoirelab/ +[15]: https://cauldron.io/ +[16]: https://opensource.com/sites/default/files/uploads/ospo_2.png (CHAOSS Metrics for 15 years of Unity OSS activity. Source: cauldron.io) +[17]: https://en.wikipedia.org/wiki/GQM +[18]: https://opensource.com/sites/default/files/uploads/ospo_3.png (Uber OSS code core, regular, and casual contributors evolution. Source: uber.biterg.io) +[19]: https://opensource.com/sites/default/files/uploads/ospo_4.png (Uber OSS activity based on location. Source: uber.biterg.io) +[20]: https://opensource.com/sites/default/files/uploads/ospo_5_0.png (Uber OSS network. Source: uber.biterg.io) +[21]: https://opensource.com/sites/default/files/uploads/ospo_6.png (Github Pull Requests backlog management index and time to close analysis. Source: uber.biterg.io) +[22]: https://tidelift.com/ +[23]: https://opencollective.com/ +[24]: https://sfconservancy.org/ +[25]: https://funding.communitybridge.org/ +[26]: https://engineering.indeedblog.com/blog/2019/02/sponsoring-osi/ +[27]: https://sustain.codefund.fm/23 +[28]: https://help.github.com/en/github/supporting-the-open-source-community-with-github-sponsors +[29]: https://www.patreon.com/ diff --git a/sources/tech/20200510 Open source underpins coronavirus IoT and robotics solutions.md b/sources/tech/20200510 Open source underpins coronavirus IoT and robotics solutions.md new file mode 100644 index 0000000000..5ce9ce0a1f --- /dev/null +++ b/sources/tech/20200510 Open source underpins coronavirus IoT and robotics solutions.md @@ -0,0 +1,86 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Open source underpins coronavirus IoT and robotics solutions) +[#]: via: (https://opensource.com/article/20/5/robotics-covid19) +[#]: author: (Sam Bocetta https://opensource.com/users/sambocetta) + +Open source underpins coronavirus IoT and robotics solutions +====== +From sanitization of equipment and facilities to plotting the spread of +the virus, robots are playing an active role in combating COVID-19. +![Three giant robots and a person][1] + +The tech sector is quietly having a boom during the COVID-19 pandemic. Open source developers are getting involved with many aspects of the fight against the coronavirus, [using Python to visualize its spread][2] and helping to repurpose data acquisition systems to perform contact tracing. + +However, one of the most exciting areas of current research is the use of robotics to contain the spread of the coronavirus. In the last few weeks, robots have been deployed in critical environments—particularly in hospitals and on airplanes—to help staff sterilize surfaces and objects. + +Most of these robots are produced by tech startups, who have seen an opportunity to prove the worth of their proprietary systems. Many of them, however, rely on [open source cloud and IoT tools][3] that have been developed by the open source community. + +In this article, we'll take a look at how robotics are being used to fight the disease, the IoT infrastructure that underpins these systems, and finally, the security and privacy concerns that their increased use is highlighting. + +### Robots and COVID-19 + +Around the world, robots are being deployed to help the fight against COVID-19. The most direct use of robots has been in healthcare facilities, and China has taken the lead when it comes to deploying robots in hospitals. + +For example, a field hospital that recently opened in Wuhan—where the virus originated—is [making extensive use of robots][4] to help healthcare workers care for patients. Some of these robots provide food, drink, and medicine to patients, and others are used to clean parts of the hospital. + +Other companies, such as the Texas startup Xenex Disinfection Services, are using robots and UV light to deactivate viruses, bacteria, and spores on surfaces in airports. Still others, like Dimer UVC Innovations, are focusing on making robots that can [improve aircraft hygiene][5]. + +Not all of the "robots" deployed against the disease are anthropomorphic, though. The same field hospital in Wuhan that is using human-like robots is also making extensive use of less obviously "robotic" IoT devices. + +Patients entering the hospital are screened by networked 5G thermometers to alert staff for anyone showing a high fever, and patients wear smart bracelets and rings equipped with sensors. These are synced with CloudMinds' AI platform, and patients' vital signs, including temperature, heart rate, and blood oxygen levels, can be monitored. + +### Robots and the IoT + +Even when these robots appear to be independent entities, they make [extensive use of the IoT][6]. In other words, although patients may feel that they are being cared for by a robot that can make its own decisions, in reality, these robots are controlled by large, distributed sensing and data processing systems. + +Although many of the robots being deployed are the proprietary property of the tech firms who produce their hardware, their functioning is based on an ecosystem of software that is largely open source. + +This observation is an important one because it overturns one of the primary misconceptions about the [way that AI is used today][7][,][7] whether in a healthcare setting or elsewhere. Most research into robotics today does not seek to embed fully intelligent AI systems into robots themselves but, instead, uses centralized AI systems to control a wide variety of far less "smart" IoT devices. + +This observation, in turn, highlights two key points about the robots currently being developed and used to fight COVID-19. One is that they rely on a software ecosystem—much of it open source—that has been developed in a truly collaborative process involving thousands of engineers. The second is that the networked nature of these robots makes them vulnerable to exploitation. + +### Security and privacy + +This vulnerability to cybersecurity threats has led some analysts to raise questions about the wisdom of widespread deployment of IoT-driven robotics, whether in the healthcare system or anywhere else. Spyware in the IoT [remains a huge problem][8], and some fear that by integrating IoT systems into healthcare, we may be exposing more data—and more sensitive data—to intruders. + +Even where developers are careful to build security into these devices, the sheer number of components they rely on makes DevSecOps processes difficult to implement. Especially in this current time of crisis, many software engineers have been forced to accelerate the release of new components, and this could lead to them being vulnerable. If a company is rushing to bring a healthcare robot onto the market in response to COVID-19, it's unlikely that the open source code that these devices run on will be [properly audited][9]. + +And even if companies are able to maintain the integrity of their DevSecOps processes while still accelerating development, it's far from certain that patients themselves understand the privacy implications of delegating their care to IoT devices. Many lack the open source privacy tools [necessary to keep their data private][10] when browsing the internet, let alone those that should be deployed to protect sensitive healthcare data. + +### The future + +In short, the deployment of robots in the fight against COVID-19 is highlighting long-standing concerns about the integrity, security, and privacy of IoT systems more generally. Professionals in this field have long argued that [IoT audits][11] and [embedded Linux systems][12] should be the standard for IoT development, but in the current crisis, their warnings are likely to be ignored. + +This is worrying because it's likely that IoT systems will be increasingly used in healthcare in the coming decade. So whilst the COVID-19 pandemic will provide a proof of their utility in this sector, it should also not be used as an excuse to roll out poorly secured, poorly audited IoT software in highly sensitive environments. + +Open source isn’t just changing the way we interact with the world, it’s changing the way the world... + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/robotics-covid19 + +作者:[Sam Bocetta][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/sambocetta +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_robots.png?itok=TOZgajrd (Three giant robots and a person) +[2]: https://opensource.com/article/20/4/python-data-covid-19 +[3]: https://opensource.com/article/18/7/digital-transformation-strategy-think-cloud +[4]: https://www.cnbc.com/2020/03/18/how-china-is-using-robots-and-telemedicine-to-combat-the-coronavirus.html +[5]: https://www.therobotreport.com/company-offers-germ-killing-robot-to-airports-to-address-coronavirus-outbreak/ +[6]: https://www.cloudwards.net/what-is-the-internet-of-things/ +[7]: https://opensource.com/article/17/3/5-big-ways-ai-rapidly-invading-our-lives +[8]: https://blog.eccouncil.org/spyware-in-the-iot-what-does-it-mean-for-your-online-privacy/ +[9]: https://opensource.com/article/17/10/doc-audits +[10]: https://privacyaustralia.net/privacy-tools/ +[11]: https://opensource.com/article/19/11/how-many-iot-devices +[12]: https://opensource.com/article/17/3/embedded-linux-iot-ecosystem diff --git a/sources/tech/20200511 How I track my home-s energy consumption with open source.md b/sources/tech/20200511 How I track my home-s energy consumption with open source.md new file mode 100644 index 0000000000..10dfaa5f8e --- /dev/null +++ b/sources/tech/20200511 How I track my home-s energy consumption with open source.md @@ -0,0 +1,144 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How I track my home's energy consumption with open source) +[#]: via: (https://opensource.com/article/20/5/energy-monitoring) +[#]: author: (Stephan Avenwedde https://opensource.com/users/hansic99) + +How I track my home's energy consumption with open source +====== +These open source components help you find ways to save money and +conserve resources. +![lightbulb drawing outline][1] + +An important step towards optimizing energy consumption is knowing your actual consumption. My house was built during the oil crisis in the 1970s, and due to the lack of a natural gas connection, the builders decided to use electricity to do all of the heating (water and home heating). This is not unusual for this area of Germany, and it remains an appropriate solution in countries that depend highly on nuclear power. + +Electricity prices here are quite high (around € 0.28/kWh), so I decided to monitor my home's energy consumption to get a feel for areas where I could save some energy. + +I used to work for a company that sold energy-monitoring systems for industrial customers. While this company mostly used proprietary software, you can set up a similar smart monitoring and logging solution for your home based on open source components. This article will show you how. + +In Germany, the grid operator owns the electricity meter. The grid operator is obliged to provide an interface on its metering device to enable the customer to access the meter reading. Here is the metering device on my home: + +![Actaris ACE3000 electricity meter][2] + +Actaris ACE3000 Type 110 (dry contact located behind the marked cover) + +Generally, almost every metering device has at least a [dry contact][3]—as my electricity meter does—that you can use to log metering. As you can see, my electricity meter has two counters: The upper one is for the day tariff (6am to 10pm), and the lower one is for the night tariff (10pm to 6am). The night tariff is a bit cheaper. Two-tariff meters are usually found only in houses with electric heating. + +### Design + +A reliable energy-monitoring solution for private use should meet the following requirements: + + * Logging of metering impulses (dry contact) + * 24/7 operation + * Energy-saving operation + * Visualization of consumption data + * Long-term recording of consumption data + * Connectivity (e.g., Ethernet, USB, WiFi, etc.) + * Affordability + + + +I choose the Siemens SIMATIC IOT2020 as my hardware platform. This industrial-proven device is based on an Intel Quark x86 CPU, has programmable interrupts, and is compatible with many Arduino shields. + +![Siemens SIMATIC IOT2020][4] + +Siemens SIMATIC IOT2020 + +The Siemens device comes without an SD card and, therefore, without an operating system. Luckily, you can find a current Yocto-based Linux OS image and instructions on how to flash the SD card in the [Siemens forum][5]. + +In addition to the hardware platform, you also need some accessories. The following materials list shows the minimum components you need. Each item includes links to the parts I purchased, so you can get a sense of the project's costs. + +#### Materials list + + * [Siemens SIMATIC IoT2020 unit][6] + * [Siemens I/O Shield for SIMATIC IoT2000 series][7] + * [microSD card][8] (2GB or more) + * [CSL 300Mbit USB-WLAN adapter][9] + * 24V power supply (I used a 2.1A [TDK-Lambda DRB50-24-1][10], which I already owned). You could use a less expensive power supply with less power: the SIMATIC IOT2020 has a maximum current of 1.4A, and the dry contact needs an additional 0.1A (24V / 220Ω). + * 5 terminal blocks ([Weidmueller WDU 2.5mm][11]) + * 2 terminal cross-connecting bridges ([Weidmueller WQV][12]) + * [DIN rail][13] (~300 mm) + * [220Ω / 3W resistor][14] + * Wire + + + +Here is the assembled result: + +![Mounted and hooked up energy logger][15] + +Energy logger mounted and hooked up + +Unfortunately, I didn't have enough space at the rear wall of the cabinet; therefore, the DIN rail with the mounted parts lies on the ground. + +The connections between the meter and the Siemens device look like this: + +![Wiring between meter and energy logger][16] + +### How it works + +A dry contact is a current interface. When the electricity meter triggers, a current of 0.1A starts flowing between **s0+** and **s0-**. On **DI0**, the voltage rises to 24V and triggers an interrupt. When the electricity meter disconnects **s0+** and **s0-**, **DI0** is grounded over the resistor. + +On my device, the contact closes 1,000 times per kWh (this value varies between metering devices). + +To count these peaks reliably, I created [a C program][17] that registers an interrupt service routine on the DI0 input and counts upwards in memory. Once a minute, the values from memory are written to an [SQLite][18] database. + +The overall meter reading is also written to a text file and can be preset with a starting value. This acts as a copy of the overall metering value of the meter in the cabinet. + +![Energy logger architecture][19] + +Energy logger architecture + +The data is visualized using [Node-RED][20], and I can access overviews, like the daily consumption dashboard below, over a web-based GUI. + +![Node-RED based GUI][21] + +Daily overview in the Node-RED GUI + +For the daily overview, I calculate the hourly costs based on the consumption data (the large bar chart). On the top-left of the dashboard you can see the actual power; below that is the daily consumption (energy and costs). The water heater for the shower causes the large peak in the bar chart. + +### A reliable system + +Aside from a lost timestamp during a power failure (the real-time clock in the Siemens device is not backed by a battery by default), everything has been working fine for more than one-and-a-half years. + +If you can set up the whole Linux system completely from the command line, you'll get a reliable and flexible system with the ability to link interrupt service routines to the I/O level. + +Because the I/O Shield runs on standard control voltage (24V), you can extend its functionality with the whole range of standardized industrial components (e.g., relays, sensors, actors, etc.). And, due to its open architecture, this system can be extended easily and applied to other applications, like for monitoring gas or water consumption or as a weather station, a simple controller for tasks, and more. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/energy-monitoring + +作者:[Stephan Avenwedde][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/hansic99 +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/Collaboration%20for%20health%20innovation.png?itok=s4O5EX2w (lightbulb drawing outline) +[2]: https://opensource.com/sites/default/files/uploads/openenergylogger_1_electricity_meter.jpg (Actaris ACE3000 electricity meter) +[3]: https://en.wikipedia.org/wiki/Dry_contact +[4]: https://opensource.com/sites/default/files/uploads/openenergylogger_2_siemens_device.jpg (Siemens SIMATIC IOT2020) +[5]: https://support.industry.siemens.com/tf/ww/en/posts/new-example-image-version-online/189090/?page=0&pageSize=10 +[6]: https://de.rs-online.com/web/p/products/1244037 +[7]: https://de.rs-online.com/web/p/products/1354133 +[8]: https://de.rs-online.com/web/p/micro-sd-karten/7582584/ +[9]: https://www.amazon.de/300Mbit-WLAN-Adapter-Hochleistungs-Antennen-Dual-Band/dp/B00LLIOT34 +[10]: https://de.rs-online.com/web/p/products/8153133 +[11]: https://de.rs-online.com/web/p/din-schienenklemmen-ohne-sicherung/0425190/ +[12]: https://de.rs-online.com/web/p/din-schienenklemmen-zubehor/0202574/ +[13]: https://de.rs-online.com/web/p/din-schienen/2835729/ +[14]: https://de.rs-online.com/web/p/widerstande-durchsteckmontage/2142673/ +[15]: https://opensource.com/sites/default/files/uploads/openenergylogger_3_assembled_device.jpg (Mounted and hooked up energy logger) +[16]: https://opensource.com/sites/default/files/uploads/openenergylogger_4_wiring.png (Wiring between meter and energy logger) +[17]: https://github.com/hANSIc99/OpenEnergyLogger +[18]: https://www.sqlite.org/index.html +[19]: https://opensource.com/sites/default/files/uploads/openenergylogger_5_architecure.png (Energy logger architecture) +[20]: https://nodered.org/ +[21]: https://opensource.com/sites/default/files/uploads/openenergylogger_6_dashboard.png (Node-RED based GUI) diff --git a/sources/tech/20200511 Start using systemd as a troubleshooting tool.md b/sources/tech/20200511 Start using systemd as a troubleshooting tool.md new file mode 100644 index 0000000000..372be7660e --- /dev/null +++ b/sources/tech/20200511 Start using systemd as a troubleshooting tool.md @@ -0,0 +1,269 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Start using systemd as a troubleshooting tool) +[#]: via: (https://opensource.com/article/20/5/systemd-troubleshooting-tool) +[#]: author: (David Both https://opensource.com/users/dboth) + +Start using systemd as a troubleshooting tool +====== +While systemd is not really a troubleshooting tool, the information in +its output points the way toward solving problems. +![Magnifying glass on code][1] + +No one would really consider systemd to be a troubleshooting tool, but when I encountered a problem on my webserver, my growing knowledge of systemd and some of its features helped me locate and circumvent the problem. + +The problem was that my server, yorktown, which provides name services, DHCP, NTP, HTTPD, and SendMail email services for my home office network, failed to start the Apache HTTPD daemon during normal startup. I had to start it manually after I realized that it was not running. The problem had been going on for some time, and I recently got around to trying to fix it. + +Some of you will say that systemd itself is the cause of this problem, and, based on what I know now, I agree with you. However, I had similar types of problems with SystemV. (In the [first article][2] in this series, I looked at the controversy around systemd as a replacement for the old SystemV init program and startup scripts. If you're interested in learning more about systemd, read the [second][3] and [third][4] articles, too.) No software is perfect, and neither systemd nor SystemV is an exception, but systemd provides far more information for problem-solving than SystemV ever offered. + +### Determining the problem + +The first step to finding the source of this problem is to determine the httpd service's status: + + +``` +[root@yorktown ~]# systemctl status httpd +● httpd.service - The Apache HTTP Server +   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) +   Active: failed (Result: exit-code) since Thu 2020-04-16 11:54:37 EDT; 15min ago +     Docs: man:httpd.service(8) +  Process: 1101 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE) + Main PID: 1101 (code=exited, status=1/FAILURE) +   Status: "Reading configuration..." +      CPU: 60ms + +Apr 16 11:54:35 yorktown.both.org systemd[1]: Starting The Apache HTTP Server... +Apr 16 11:54:37 yorktown.both.org httpd[1101]: (99)Cannot assign requested address: AH00072: make_sock: could not bind to address 192.168.0.52:80 +Apr 16 11:54:37 yorktown.both.org httpd[1101]: no listening sockets available, shutting down +Apr 16 11:54:37 yorktown.both.org httpd[1101]: AH00015: Unable to open logs +Apr 16 11:54:37 yorktown.both.org systemd[1]: httpd.service: Main process exited, code=exited, status=1/FAILURE +Apr 16 11:54:37 yorktown.both.org systemd[1]: httpd.service: Failed with result 'exit-code'. +Apr 16 11:54:37 yorktown.both.org systemd[1]: Failed to start The Apache HTTP Server. +[root@yorktown ~]# +``` + +This status information is one of the systemd features that I find much more useful than anything SystemV offers. The amount of helpful information here leads me easily to a logical conclusion that takes me in the right direction. All I ever got from the old **chkconfig** command is whether or not the service is running and the process ID (PID) if it is. That is not very helpful. + +The key entry in this status report shows that HTTPD cannot bind to the IP address, which means it cannot accept incoming requests. This indicates that the network is not starting fast enough to be ready for the HTTPD service to bind to the IP address because the IP address has not yet been set. This is not supposed to happen, so I explored my network service systemd startup configuration files; all appeared to be correct with the right "after" and "requires" statements. Here is the **/lib/systemd/system/httpd.service** file from my server: + + +``` +# Modifying this file in-place is not recommended, because changes                                                                                     +# will be overwritten during package upgrades.  To customize the                                                                                       +# behaviour, run "systemctl edit httpd" to create an override unit.                                                                                   +                                                                                                                                                      +# For example, to pass additional options (such as -D definitions) to                                                                                 +# the httpd binary at startup, create an override unit (as is done by                                                                                 +# systemctl edit) and enter the following:                                                                                                             +                                                                                                                                                      +#       [Service]                                                                                                                                     +#       Environment=OPTIONS=-DMY_DEFINE                                                                                                               +                                                                                                                                                      +[Unit]                                                                                                                                                 +Description=The Apache HTTP Server                                                                                                                     +Wants=httpd-init.service                                                                                                                               +After=network.target remote-fs.target nss-lookup.target httpd-init.service                                                                             +Documentation=man:httpd.service(8)                                                                                                                     +                                                                                                                                                      +[Service]                                                                                                                                             +Type=notify                                                                                                                                           +Environment=LANG=C                                                                                                                                     +                                                                                                                                                      +ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND                                                                                                       +ExecReload=/usr/sbin/httpd $OPTIONS -k graceful                                                                                                       +# Send SIGWINCH for graceful stop                                                                                                                     +KillSignal=SIGWINCH                                                                                                                                   +KillMode=mixed                                                                                                                                         +PrivateTmp=true                                                                                                                                       +                                                                                                                                                      +[Install]                                                                                                                                             +WantedBy=multi-user.target +``` + +The **httpd.service** unit file explicitly specifies that it should load after the **network.target** and the **httpd-init.service** (among others). I tried to find all of these services using the **systemctl list-units** command and searching for them in the resulting data stream. All were present and should have ensured that the httpd service did not load before the network IP address was set. + +### First solution + +A bit of searching on the internet confirmed that others had encountered similar problems with httpd and other services. This appears to happen because one of the required services indicates to systemd that it has finished its startup—but it actually spins off a child process that has not finished. After a bit more searching, I came up with a circumvention. + +I could not figure out why the IP address was taking so long to be assigned to the network interface card. So, I thought that if I could delay the start of the HTTPD service by a reasonable amount of time, the IP address would be assigned by that time. + +Fortunately, the **/lib/systemd/system/httpd.service** file above provides some direction. Although it says not to alter it, it does indicate how to proceed: Use the command **systemctl edit httpd**, which automatically creates a new file (**/etc/systemd/system/httpd.service.d/override.conf**) and opens the [GNU Nano][5] editor. (If you are not familiar with Nano, be sure to look at the hints at the bottom of the Nano interface.) + +Add the following text to the new file and save it: + + +``` +[root@yorktown ~]# cd /etc/systemd/system/httpd.service.d/ +[root@yorktown httpd.service.d]# ll +total 4 +-rw-r--r-- 1 root root 243 Apr 16 11:43 override.conf +[root@yorktown httpd.service.d]# cat override.conf +# Trying to delay the startup of httpd so that the network is +# fully up and running so that httpd can bind to the correct +# IP address +# +# By David Both, 2020-04-16 + +[Service] +ExecStartPre=/bin/sleep 30 +``` + +The **[Service]** section of this override file contains a single line that delays the start of the HTTPD service by 30 seconds. The following status command shows the service status during the wait time: + + +``` +[root@yorktown ~]# systemctl status httpd +● httpd.service - The Apache HTTP Server +   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) +  Drop-In: /etc/systemd/system/httpd.service.d +           └─override.conf +           /usr/lib/systemd/system/httpd.service.d +           └─php-fpm.conf +   Active: activating (start-pre) since Thu 2020-04-16 12:14:29 EDT; 28s ago +     Docs: man:httpd.service(8) +Cntrl PID: 1102 (sleep) +    Tasks: 1 (limit: 38363) +   Memory: 260.0K +      CPU: 2ms +   CGroup: /system.slice/httpd.service +           └─1102 /bin/sleep 30 + +Apr 16 12:14:29 yorktown.both.org systemd[1]: Starting The Apache HTTP Server... +Apr 16 12:15:01 yorktown.both.org systemd[1]: Started The Apache HTTP Server. +[root@yorktown ~]# +``` + +And this command shows the status of the HTTPD service after the 30-second delay expires. The service is up and running correctly: + + +``` +[root@yorktown ~]# systemctl status httpd +● httpd.service - The Apache HTTP Server +   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) +  Drop-In: /etc/systemd/system/httpd.service.d +           └─override.conf +           /usr/lib/systemd/system/httpd.service.d +           └─php-fpm.conf +   Active: active (running) since Thu 2020-04-16 12:15:01 EDT; 1min 18s ago +     Docs: man:httpd.service(8) +  Process: 1102 ExecStartPre=/bin/sleep 30 (code=exited, status=0/SUCCESS) + Main PID: 1567 (httpd) +   Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec" +    Tasks: 213 (limit: 38363) +   Memory: 21.8M +      CPU: 82ms +   CGroup: /system.slice/httpd.service +           ├─1567 /usr/sbin/httpd -DFOREGROUND +           ├─1569 /usr/sbin/httpd -DFOREGROUND +           ├─1570 /usr/sbin/httpd -DFOREGROUND +           ├─1571 /usr/sbin/httpd -DFOREGROUND +           └─1572 /usr/sbin/httpd -DFOREGROUND + +Apr 16 12:14:29 yorktown.both.org systemd[1]: Starting The Apache HTTP Server... +Apr 16 12:15:01 yorktown.both.org systemd[1]: Started The Apache HTTP Server. +``` + +I could have experimented to see if a shorter delay would work as well, but my system is not that critical, so I decided not to. It works reliably as it is, so I am happy. + +Because I gathered all this information, I reported it to Red Hat Bugzilla as Bug [1825554][6]. I believe that it is much more productive to report bugs than it is to complain about them. + +### The better solution + +A couple of days after reporting this as a bug, I received a response indicating that systemd is just the manager, and if httpd needs to be ordered after some requirements are met, it needs to be expressed in the unit file. The response pointed me to the **httpd.service** man page. I wish I had found this earlier because it is a better solution than the one I came up with. This solution is explicitly targeted to the prerequisite target unit rather than a somewhat random delay. + +From the [**httpd.service** man page][7]: + +> **Starting the service at boot time** +> +> The httpd.service and httpd.socket units are _disabled_ by default. To start the httpd service at boot time, run: **systemctl enable httpd.service**. In the default configuration, the httpd daemon will accept connections on port 80 (and, if mod_ssl is installed, TLS connections on port 443) for any configured IPv4 or IPv6 address. +> +> If httpd is configured to depend on any specific IP address (for example, with a "Listen" directive) which may only become available during start-up, or if httpd depends on other services (such as a database daemon), the service _must_ be configured to ensure correct start-up ordering. +> +> For example, to ensure httpd is only running after all configured network interfaces are configured, create a drop-in file (as described above) with the following section: +> +> [Unit] +> After=network-online.target +> Wants=network-online.target + +I still think this is a bug because it is quite common—at least in my experience—to use a **Listen** directive in the **httpd.conf** configuration file. I have always used **Listen** directives, even on hosts with only a single IP address, and it is clearly necessary on hosts with multiple network interface cards (NICs) and internet protocol (IP) addresses. Adding the lines above to the **/usr/lib/systemd/system/httpd.service** default file would not cause problems for configurations that do not use a **Listen** directive and would prevent this problem for those that do. + +In the meantime, I will use the suggested solution. + +### Next steps + +This article describes a problem I had with starting the Apache HTTPD service on my server. It leads you through the problem determination steps I took and shows how I used systemd to assist. I also covered the circumvention I implemented using systemd and the better solution that followed from my bug report. + +As I mentioned at the start, it is very likely that this is the result of a problem with systemd, specifically the configuration for httpd startup. Nevertheless, systemd provided me with the tools to locate the likely source of the problem and to formulate and implement a circumvention. Neither solution really resolves the problem to my satisfaction. For now, the root cause of the problem still exists and must be fixed. If that is simply adding the recommended lines to the **/usr/lib/systemd/system/httpd.service** file, that would work for me. + +One of the things I discovered during this is process is that I need to learn more about defining the sequences in which things start. I will explore that in my next article, the fifth in this series. + +### Resources + +There is a great deal of information about systemd available on the internet, but much is terse, obtuse, or even misleading. In addition to the resources mentioned in this article, the following webpages offer more detailed and reliable information about systemd startup. + + * The Fedora Project has a good, practical [guide][8] [to systemd][8]. It has pretty much everything you need to know in order to configure, manage, and maintain a Fedora computer using systemd. + * The Fedora Project also has a good [cheat sheet][9] that cross-references the old SystemV commands to comparable systemd ones. + * For detailed technical information about systemd and the reasons for creating it, check out [Freedesktop.org][10]'s [description of systemd][11]. + * [Linux.com][12]'s "More systemd fun" offers more advanced systemd [information and tips][13]. + + + +There is also a series of deeply technical articles for Linux sysadmins by Lennart Poettering, the designer and primary developer of systemd. These articles were written between April 2010 and September 2011, but they are just as relevant now as they were then. Much of everything else good that has been written about systemd and its ecosystem is based on these papers. + + * [Rethinking PID 1][14] + * [systemd for Administrators, Part I][15] + * [systemd for Administrators, Part II][16] + * [systemd for Administrators, Part III][17] + * [systemd for Administrators, Part IV][18] + * [systemd for Administrators, Part V][19] + * [systemd for Administrators, Part VI][20] + * [systemd for Administrators, Part VII][21] + * [systemd for Administrators, Part VIII][22] + * [systemd for Administrators, Part IX][23] + * [systemd for Administrators, Part X][24] + * [systemd for Administrators, Part XI][25] + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/systemd-troubleshooting-tool + +作者:[David Both][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/dboth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0 (Magnifying glass on code) +[2]: https://opensource.com/article/20/4/systemd +[3]: https://opensource.com/article/20/4/systemd-startup +[4]: https://opensource.com/article/20/4/understanding-and-using-systemd-units +[5]: https://www.nano-editor.org/ +[6]: https://bugzilla.redhat.com/show_bug.cgi?id=1825554 +[7]: https://www.mankier.com/8/httpd.service#Description-Starting_the_service_at_boot_time +[8]: https://docs.fedoraproject.org/en-US/quick-docs/understanding-and-administering-systemd/index.html +[9]: https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet +[10]: http://Freedesktop.org +[11]: http://www.freedesktop.org/wiki/Software/systemd +[12]: http://Linux.com +[13]: https://www.linux.com/training-tutorials/more-systemd-fun-blame-game-and-stopping-services-prejudice/ +[14]: http://0pointer.de/blog/projects/systemd.html +[15]: http://0pointer.de/blog/projects/systemd-for-admins-1.html +[16]: http://0pointer.de/blog/projects/systemd-for-admins-2.html +[17]: http://0pointer.de/blog/projects/systemd-for-admins-3.html +[18]: http://0pointer.de/blog/projects/systemd-for-admins-4.html +[19]: http://0pointer.de/blog/projects/three-levels-of-off.html +[20]: http://0pointer.de/blog/projects/changing-roots +[21]: http://0pointer.de/blog/projects/blame-game.html +[22]: http://0pointer.de/blog/projects/the-new-configuration-files.html +[23]: http://0pointer.de/blog/projects/on-etc-sysinit.html +[24]: http://0pointer.de/blog/projects/instances.html +[25]: http://0pointer.de/blog/projects/inetd.html diff --git a/sources/tech/20200511 Tips and tricks for optimizing container builds.md b/sources/tech/20200511 Tips and tricks for optimizing container builds.md new file mode 100644 index 0000000000..0a4fbed8cb --- /dev/null +++ b/sources/tech/20200511 Tips and tricks for optimizing container builds.md @@ -0,0 +1,201 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Tips and tricks for optimizing container builds) +[#]: via: (https://opensource.com/article/20/5/optimize-container-builds) +[#]: author: (Ravi Chandran https://opensource.com/users/ravichandran) + +Tips and tricks for optimizing container builds +====== +Try these techniques to minimize the number and length of your container +build iterations. +![Toolbox drawing of a container][1] + +How many iterations does it take to get a container configuration just right? And how long does each iteration take? Well, if you answered "too many times and too long," then my experiences are similar to yours. On the surface, creating a configuration file seems like a straightforward exercise: implement the same steps in a configuration file that you would perform if you were installing the system by hand. Unfortunately, I've found that it usually doesn't quite work that way, and a few "tricks" are handy for such DevOps exercises. + +In this article, I'll share some techniques I've found that help minimize the number and length of iterations. In addition, I'll outline a few good practices beyond the [standard ones][2]. + +In the [tutorial repository][3] from my previous article about [containerizing build systems][4], I've added a folder called **/tutorial2_docker_tricks** with an example covering some of the tricks that I'll walk through in this post. If you want to follow along and you have Git installed, you can pull it locally with: + + +``` +`$ git clone https://github.com/ravi-chandran/dockerize-tutorial` +``` + +The tutorial has been tested with Docker Desktop Edition, although it should work with any compatible Linux container system (like [Podman][5]). + +### Save time on container image build iterations + +If the Dockerfile involves downloading and installing a 5GB file, each iteration of **docker image build** could take a lot of time even with good network speeds. And forgetting to include one item to be installed can mean rebuilding all the layers after that point. + +One way around that challenge is to use a local HTTP server to avoid downloading large files from the internet multiple times during **docker image build** iterations. To illustrate this by example, say you need to create a container image with Anaconda 3 under Ubuntu 18.04. The Anaconda 3 installer is a ~0.5GB file, so this will be the "large" file for this example. + +Note that you don't want to use the **COPY** instruction, as it creates a new layer. You should also delete the large installer after using it to minimize the container image size. You could use [multi-stage builds][6], but I've found the following approach sufficient and quite effective. + +The basic idea is to use a Python-based HTTP server locally to serve the large file(s) and have the Dockerfile **wget** the large file(s) from this local server. Let's explore the details of how to set this up effectively. As a reminder, you can access the [full example][7]. + +The necessary contents of the folder **tutorial2_docker_tricks/** in this example repository are: + + +``` +tutorial2_docker_tricks/ +├── build_docker_image.sh                   # builds the docker image +├── run_container.sh                        # instantiates a container from the image +├── install_anaconda.dockerfile             # Dockerfile for creating our target docker image +├── .dockerignore                           # used to ignore contents of the installer/ folder from the docker context +├── installer                               # folder with all our large files required for creating the docker image +│   └── Anaconda3-2019.10-Linux-x86_64.sh   # from +└── workdir                                 # example folder used as a volume in the running container +``` + +The key steps of the approach are: + + * Place the large file(s) in the **installer/** folder. In this example, I have the large Anaconda installer file **Anaconda3-2019.10-Linux-x86_64.sh**. You won't find this file if you clone my [Git repository][8] because only you, as the container image creator, need this source file. The end users of the image don't. [Download the installer][9] to follow along with the example. + * Create the **.dockerignore** file and have it ignore the **installer/** folder to avoid Docker copying all the large files into the build context. + * In a terminal, **cd** into the **tutorial2_docker_tricks/** folder and execute the build script as **./build_docker_image.sh**. + * In **build_docker_image.sh**, start the Python HTTP server to serve any files from the **installer/** folder: [code] cd installer +python3 -m http.server --bind 10.0.2.15 8888 & +cd .. +``` +* If you're wondering about the strange internet protocol (IP) address, I'm working with a VirtualBox Linux VM, and **10.0.2.15** shows up as the address of the Ethernet adapter when I run **ifconfig**. This IP seems to be the convention used by VirtualBox. If your setup is different, you'll need to update this IP address to match your environment and then update **build_docker_image.sh** and **install_anaconda.dockerfile**. The server's port number is set to **8888** for this example. Note that the IP and port numbers could be passed in as build arguments, but I've hard-coded them for brevity. +* Since the HTTP server is set to run in the background, stop the server near the end of the script with the **kill -9** command using an [elegant approach][10] I found: [code]`kill -9 `ps -ef | grep http.server | grep 8888 | awk '{print $2}'` +``` + * Note that this same **kill -9** is also used earlier in the script (before starting the HTTP server). In general, when I iterate on any build script that I might deliberately interrupt, this ensures a clean start of the HTTP server each time. + * In the [Dockerfile][11], there is a **RUN wget** instruction that downloads the Anaconda installer from the local HTTP server. It also deletes the installer file and cleans up after the installation. Most importantly, all these actions are performed within the same layer to keep the image size to a minimum: [code] # install Anaconda by downloading the installer via the local http server +ARG ANACONDA +RUN wget --no-proxy -O ~/anaconda.sh \ +    && /bin/bash ~/anaconda.sh -b -p /opt/conda \ +    && rm ~/anaconda.sh \ +    && rm -fr /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/* +``` + * This file runs the wrapper script, **anaconda.sh**, and cleans up large files by removing them with **rm**. + * After the build is complete, you should see an image **anaconda_ubuntu1804:v1**. (You can list the images with **docker image ls**.) + * You can instantiate a container from this image using **./run_container.sh** at the terminal while in the folder **tutorial2_docker_tricks/**. You can verify that Anaconda is installed with: [code] $ ./run_container.sh +$ python --version +Python 3.7.5 +$ conda --version +conda 4.8.0 +$ anaconda --version +anaconda Command line client (version 1.7.2) +``` + * You'll note that **run_container.sh** sets up a volume **workdir**. In this example repository, the folder **workdir/** is empty. This is a convention I use to set up a volume where I can have my Python and other scripts that are independent of the container image. + + + +### Minimize container image size + +Each **RUN** command is equivalent to executing a new shell, and each **RUN** command creates a layer. The naive approach of mimicking installation instructions with separate **RUN** commands may eventually break at one or more interdependent steps. If it happens to work, it will typically result in a larger image. Chaining multiple installation steps in one **RUN** command and including the **autoremove**, **autoclean**, and **rm** commands (as in the example below) is useful to minimize the size of each layer. Some of these steps may not be needed, depending on what's being installed. However, since these steps take an insignificant amount of time, I always throw them in for good measure at the end of **RUN** commands invoking **apt-get**: + + +``` +RUN apt-get update \ +    && DEBIAN_FRONTEND=noninteractive \ +       apt-get -y --quiet --no-install-recommends install \ +       # list of packages being installed go here \ +    && apt-get -y autoremove \ +    && apt-get clean autoclean \ +    && rm -fr /var/lib/apt/lists/{apt,dpkg,cache,log} /tmp/* /var/tmp/* +``` + +Also, ensure that you have a **.dockerignore** file in place to ignore items that don't need to be sent to the Docker build context (such as the Anaconda installer file in the earlier example). + +### Organize the build tool I/O + +For software build systems, the build inputs and outputs—all the scripts that configure and invoke the tools—should be outside the image and the eventually running container. The container itself should remain stateless so that different users will have identical results with it. I covered this extensively in my [previous article][4] but wanted to emphasize it because it's been a useful convention for my work. These inputs and outputs are best accessed by setting up container volumes. + +I've had to use a container image that provides data in the form of source code and large pre-built binaries. As a software developer, I was expected to edit the code in the container. This was problematic, because containers are by default stateless: they don't save data within the container, because they're designed to be disposable. But I worked on it, and at the end of each day, I stopped the container and had to be careful not to remove it, because the state had to be maintained so I could continue work the next day. The disadvantage of this approach was that there would be a divergence of development state had there been more than one person working on the project. The value of having identical build systems across developers is somewhat lost with this approach. + +### Generate output as non-root user + +An important aspect of I/O concerns the ownership of the output files generated when running the tools in the container. By default, since Docker runs as **root**, the output files would be owned by **root**, which is unpleasant. You typically want to work as a non-root user. Changing the ownership after the build output is generated can be done with scripts, but it is an additional and unnecessary step. It's best to set the [**USER**][12] argument in the Dockerfile at the earliest point possible: + + +``` +ARG USERNAME +# other commands... +USER ${USERNAME} +``` + +The **USERNAME** can be passed in as a build argument (**\--build-arg**) when executing the **docker image build**. You can see an example of this in the example [Dockerfile][11] and corresponding [build script][13]. + +Some portions of the tools may also need to be installed as a non-root user. So the sequence of installations in the Dockerfile may need to be different from the way it's done if you are installing manually and directly under Linux. + +### Non-interactive installation + +Interactivity is the opposite of container automation. I've found the + + +``` +`DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends` +``` + +options for the **apt-get install** instruction (as in the example above) necessary to prevent the installer from opening dialog boxes. Note that these options should be used as part of the **RUN** instruction. The **DEBIAN_FRONTEND=noninteractive** should not be set as an environment variable (**ENV**) in the Dockerfile, as this [FAQ explains][14], as it will be inherited by the containers. + +### Log your build and run output + +Debugging why a build failed is a common task, and logs are a great way to do this. Save a TypeScript of everything that happened during the container image build or container run session using the **tee** utility in a Bash script. In other words, add **|& tee $BASH_SOURCE.log** to the end of the **docker image build** and the **docker image run** commands in your scripts. See the examples in the [image build][13] and [container run][15] scripts. + +What this **tee**-ing technique does is generate a file with the same name as the Bash script but with a **.log** extension appended to it so that you know which script it originated from. Everything you see printed to the terminal when running the script will get logged to this file with a similar name. + +This is especially valuable for users of your container images to report issues to you when something doesn't work. You can ask them to send you the log file to help diagnose the issue. Many tools generate so much output that it easily overwhelms the default size of the terminal's buffer. Relying only on the terminal's buffer capacity to copy-paste error messages may not be sufficient for diagnosing issues because earlier errors may have been lost. + +I've found this to be useful, even in the container image-building scripts, especially when using the Python-based HTTP server discussed above. The server generates so many lines during a download that it typically overwhelms the terminal's buffer. + +### Deal with proxies elegantly + +In my work environment, proxies are required to reach the internet for downloading the resources in **RUN apt-get** and **RUN wget** commands. The proxies are typically inferred from the environment variables **http_proxy** or **https_proxy**. While **ENV** commands can be used to hard-code such proxy settings in the Dockerfile, there are multiple issues with using **ENV** for proxies directly. + +If you are the only one who will ever build the container, then perhaps this will work. But the Dockerfile couldn't be used by someone else at a different location with a different proxy setting. Another issue is that the IT department could change the proxy at some point, resulting in a Dockerfile that won't work any longer. Furthermore, the Dockerfile is a precise document specifying a configuration-controlled system, and every change will be scrutinized by quality assurance. + +One simple approach to avoid hard-coding the proxy is to pass your local proxy setting as a build argument in the **docker image build** command: + + +``` +docker image build \ +    --build-arg MY_PROXY= +``` + +And then, in the Dockerfile, set the environment variables based on the build argument. In the example shown here, you can still set a default proxy value that can be overridden by the build argument above: + + +``` +# set a default proxy +ARG MY_PROXY=MY_PROXY= +ENV http_proxy=$MY_PROXY +ENV https_proxy=$MY_PROXY +``` + +### Summary + +These techniques have helped me significantly reduce the time it takes to create container images and debug them when they go wrong. I continue to be on the lookout for additional best practices to add to my list. I hope you find the above techniques useful. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/optimize-container-builds + +作者:[Ravi Chandran][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/ravichandran +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/toolbox-learn-draw-container-yearbook.png?itok=xDbwz1pP (Toolbox drawing of a container) +[2]: https://docs.docker.com/develop/develop-images/dockerfile_best-practices/ +[3]: https://github.com/ravi-chandran/dockerize-tutorial +[4]: https://opensource.com/article/20/4/how-containerize-build-system +[5]: https://podman.io/getting-started/installation +[6]: https://docs.docker.com/develop/develop-images/multistage-build/ +[7]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/tutorial2_docker_tricks/ +[8]: https://github.com/ravi-chandran/dockerize-tutorial/ +[9]: https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh +[10]: https://stackoverflow.com/a/37214138 +[11]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/tutorial2_docker_tricks/install_anaconda.dockerfile +[12]: https://docs.docker.com/engine/reference/builder/#user +[13]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/tutorial2_docker_tricks/build_docker_image.sh +[14]: https://docs.docker.com/engine/faq/ +[15]: https://github.com/ravi-chandran/dockerize-tutorial/blob/master/tutorial2_docker_tricks/run_container.sh diff --git a/sources/tech/20200515 How to examine processes running on Linux.md b/sources/tech/20200515 How to examine processes running on Linux.md new file mode 100644 index 0000000000..0659ab04f9 --- /dev/null +++ b/sources/tech/20200515 How to examine processes running on Linux.md @@ -0,0 +1,232 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to examine processes running on Linux) +[#]: via: (https://www.networkworld.com/article/3543232/how-to-examine-processes-running-on-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +How to examine processes running on Linux +====== + +Thinkstock + +There are quite a number of ways to look at running processes on Linux systems – to see what’s running, the resources that processes are using, how the system is affected by the load and how memory is being used. Each command gives you a different view, and the range of details is considerable. In this post, we’ll run through a series of commands that can help you view process details in a number of different ways. + +### ps + +While the **ps** command is the most obvious command for examining processes, the arguments that you use when running **ps** will make a big difference in how much information will be provided. With no arguments, **ps** will only show processes associated with your current login session. Add a **-u** and you'll see extended details. + +Here is a comparison: + +``` +nemo$ ps + PID TTY TIME CMD + 45867 pts/1 00:00:00 bash + 46140 pts/1 00:00:00 ps +nemo$ ps -u +USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND +nemo 45867 0.0 0.0 11232 5636 pts/1 Ss 19:04 0:00 -bash +nemo 46141 0.0 0.0 11700 3648 pts/1 R+ 19:16 0:00 ps -u +``` + +Using **ps -ef** will display details on all of the processes running on the system but **ps -eF** will add some additional details. + +``` +$ ps -ef | head -2 +UID PID PPID C STIME TTY TIME CMD +root 1 0 0 May10 ? 00:00:06 /sbin/init splash +$ ps -eF | head -2 +UID PID PPID C SZ RSS PSR STIME TTY TIME CMD +root 1 0 0 42108 12524 0 May10 ? 00:00:06 /sbin/init splash +``` + +Both commands show who is running the process, the process and parent process IDs, process start time, accumulated run time and the task being run. The additional fields shown when you use **F** instead of **f** include: + + * SZ: the process **size** in physical pages for the core image of the process + * RSS: the **resident set size** which shows how much memory is allocated to those parts of the process in RAM. It does not include memory that is swapped out, but does include memory from shared libraries as long as the pages from those libraries are currently in memory. It also includes stack and heap memory. + * PSR: the **processor** the process is using + + + +##### ps -fU + +You can list processes for some particular user with a command like "ps -ef | grep USERNAME", but with **ps -fU** command, you’re going to see considerably more data. This is because details of processes that are being run on the user's behalf are also included. In fact, nearly all these processes shown have been kicked off by system simply to support this user’s online session. Nemo has only just logged in and is not yet running any commands or scripts. + +``` +$ ps -fU nemo +UID PID PPID C STIME TTY TIME CMD +nemo 45726 1 0 19:04 ? 00:00:00 /lib/systemd/systemd --user +nemo 45732 45726 0 19:04 ? 00:00:00 (sd-pam) +nemo 45738 45726 0 19:04 ? 00:00:00 /usr/bin/pulseaudio --daemon +nemo 45740 45726 0 19:04 ? 00:00:00 /usr/libexec/tracker-miner-f +nemo 45754 45726 0 19:04 ? 00:00:00 /usr/bin/dbus-daemon --sessi +nemo 45829 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfsd +nemo 45856 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfsd-fuse /run +nemo 45862 45706 0 19:04 ? 00:00:00 sshd: nemo@pts/1 +nemo 45864 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfs-udisks2-vo +nemo 45867 45862 0 19:04 pts/1 00:00:00 -bash +nemo 45878 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfs-afc-volume +nemo 45883 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfs-goa-volume +nemo 45887 45726 0 19:04 ? 00:00:00 /usr/libexec/goa-daemon +nemo 45895 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfs-mtp-volume +nemo 45896 45726 0 19:04 ? 00:00:00 /usr/libexec/goa-identity-se +nemo 45903 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfs-gphoto2-vo +nemo 45946 45726 0 19:04 ? 00:00:00 /usr/libexec/gvfsd-metadata +``` + +Note that the only process with an assigned TTY is Nemo's shell and that the parent of all of the other processes is **systemd**. + +You can supply a comma-separated list of usernames instead of a single name. Just be prepared to be looking at quite a bit more data. + +#### top and ntop + +The **top** and **ntop** commands will help when you want to get an idea which processes are using the most resources and allow you to reorder your view depending on what criteria you want to use to rank the processes (e.g., highest CPU or memory use). + +``` +top - 11:51:27 up 1 day, 21:40, 1 user, load average: 0.08, 0.02, 0.01 +Tasks: 211 total, 1 running, 210 sleeping, 0 stopped, 0 zombie +%Cpu(s): 5.0 us, 0.5 sy, 0.0 ni, 94.3 id, 0.2 wa, 0.0 hi, 0.0 si, 0.0 st +MiB Mem : 5944.4 total, 3527.4 free, 565.1 used, 1851.9 buff/cache +MiB Swap: 2048.0 total, 2048.0 free, 0.0 used. 5084.3 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 999 root 20 0 394660 14380 10912 S 8.0 0.2 0:46.54 udisksd + 65224 shs 20 0 314268 9824 8084 S 1.7 0.2 0:00.34 gvfs-ud+ + 2034 gdm 20 0 314264 9820 7992 S 1.3 0.2 0:06.25 gvfs-ud+ + 67909 root 20 0 0 0 0 I 0.3 0.0 0:00.09 kworker+ + 1 root 20 0 168432 12532 8564 S 0.0 0.2 0:09.93 systemd + 2 root 20 0 0 0 0 S 0.0 0.0 0:00.02 kthreadd +``` + +Use **shift+m** to sort by memory use and **shift+p** to go back to sorting by CPU usage (the default). + +#### /proc + +A tremendous amount of information is available on running processes in the **/proc** directory. In fact, if you haven't visited **/proc** quite a few times, you might be astounded by the amount of details available. Just keep in mind that **/proc** is a very different kind of file system. As an interface to kernel data, it provides a view of process details that are currently being used by the system. + +Some of the more useful **/proc** files for viewing include **cmdline**, **environ**, **fd**, **limits** and **status**. The following views provide some samples of what you might see. + +The **status** file shows the process that is running (bash), its status, the user and group ID for the person running bash, a full list of the groups the user is a member of and the process ID and parent process ID. + +``` +$ head -11 /proc/65333/status +Name: bash +Umask: 0002 +State: S (sleeping) +Tgid: 65333 +Ngid: 0 +Pid: 65333 +PPid: 65320 +TracerPid: 0 +Uid: 1000 1000 1000 1000 +Gid: 1000 1000 1000 1000 +FDSize: 256 +Groups: 4 11 24 27 30 46 118 128 500 1000 +... +``` + +The **cmdline** file shows the command line used to start the process. + +``` +$ cat /proc/65333/cmdline +-bash +``` + +The **environ** file shows the environment variables that are in effect. + +``` +$ cat environ +USER=shsLOGNAME=shsHOME=/home/shsPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/gamesSHELL=/bin/bashTERM=xtermXDG_SESSION_ID=626XDG_RUNTIME_DIR=/run/user/1000DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/busXDG_SESSION_TYPE=ttyXDG_SESSION_CLASS=userMOTD_SHOWN=pamLANG=en_US.UTF-8SSH_CLIENT=192.168.0.19 9385 22SSH_CONNECTION=192.168.0.19 9385 192.168.0.11 22SSH_TTY=/dev/pts/0$ +``` + +The **fd** file shows the file descriptors. Note how they reflect the pseudo-tty that is being used (pts/0). + +``` +$ ls -l /proc/65333/fd +total 0 +lrwx------ 1 shs shs 64 May 12 09:45 0 -> /dev/pts/0 +lrwx------ 1 shs shs 64 May 12 09:45 1 -> /dev/pts/0 +lrwx------ 1 shs shs 64 May 12 09:45 2 -> /dev/pts/0 +lrwx------ 1 shs shs 64 May 12 09:56 255 -> /dev/pts/0 +$ who +shs pts/0 2020-05-12 09:45 (192.168.0.19) +``` + +The **limits** file contains information about the limits imposed on the process. + +``` +$ cat limits +Limit Soft Limit Hard Limit Units +Max cpu time unlimited unlimited seconds +Max file size unlimited unlimited bytes +Max data size unlimited unlimited bytes +Max stack size 8388608 unlimited bytes +Max core file size 0 unlimited bytes +Max resident set unlimited unlimited bytes +Max processes 23554 23554 processes +Max open files 1024 1048576 files +Max locked memory 67108864 67108864 bytes +Max address space unlimited unlimited bytes +Max file locks unlimited unlimited locks +Max pending signals 23554 23554 signals +Max msgqueue size 819200 819200 bytes +Max nice priority 0 0 +Max realtime priority 0 0 +Max realtime timeout unlimited unlimited us +``` + +#### pmap + +The **pmap** command takes you in an entirely different direction when it comes to memory use. It provides a detailed map of a process’s memory usage. To make sense of this, you need to keep in mind that processes do not run entirely on their own. Instead, they make use of a wide range of system resources. The truncated **pmap** output below shows a portion of the memory map for a single user’s bash login along with some memory usage totals at the bottom. + +``` +$ pmap -x 43120 +43120: -bash +Address Kbytes RSS Dirty Mode Mapping +000055887655b000 180 180 0 r---- bash +0000558876588000 708 708 0 r-x-- bash +0000558876639000 220 148 0 r---- bash +0000558876670000 16 16 16 r---- bash +0000558876674000 36 36 36 rw--- bash +000055887667d000 40 28 28 rw--- [ anon ] +0000558876b96000 1328 1312 1312 rw--- [ anon ] +00007f0bd9a7e000 28 28 0 r---- libpthread-2.31.so +00007f0bd9a85000 68 68 0 r-x-- libpthread-2.31.so +00007f0bd9a96000 20 0 0 r---- libpthread-2.31.so +00007f0bd9a9b000 4 4 4 r---- libpthread-2.31.so +00007f0bd9a9c000 4 4 4 rw--- libpthread-2.31.so +00007f0bd9a9d000 16 4 4 rw--- [ anon ] +00007f0bd9aa1000 20 20 0 r---- libnss_systemd.so.2 +00007f0bd9aa6000 148 148 0 r-x-- libnss_systemd.so.2 +... +ffffffffff600000 4 0 0 --x-- [ anon ] +---------------- ------- ------- ------- +total kB 11368 5664 1656 + +Kbytes: size of map in kilobytes +RSS: resident set size in kilobytes +Dirty: dirty pages (both shared and private) in kilobytes +``` +``` + +``` + +Join the Network World communities on [Facebook][1] and [LinkedIn][2] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3543232/how-to-examine-processes-running-on-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.facebook.com/NetworkWorld/ +[2]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20200515 The pieces of Fedora Silverblue.md b/sources/tech/20200515 The pieces of Fedora Silverblue.md new file mode 100644 index 0000000000..04bd4e1643 --- /dev/null +++ b/sources/tech/20200515 The pieces of Fedora Silverblue.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (The pieces of Fedora Silverblue) +[#]: via: (https://fedoramagazine.org/pieces-of-fedora-silverblue/) +[#]: author: (Nick Hardiman https://fedoramagazine.org/author/nickhardiman/) + +The pieces of Fedora Silverblue +====== + +![][1] + +Fedora Silverblue provides a useful workstation build on an immutable operating system. In “[What is Silverblue?][2]“, you learned about the benefits that an immutable OS provides. But what pieces go into making it? This article examines some of the technology that powers Silverblue. + +### The filesystem + +Fedora Workstation users may find the idea of an immutable OS to be the most brain-melting part of Silverblue. What does that mean? Find some answers by taking a look at the filesystem. + +At first glance, the layout looks pretty much the same as a regular Fedora file system. It has some differences, like making _/home_ a symbolic link to _/var/home_. And you can get more answers by looking at how libostree works. libostree treats the whole tree like it’s an object, checks it into a code repository, and checks out a copy for your machine to use. + +#### libostree + +The [libostree project][3] supplies the goods for managing Silverblue’s file system. It is an upgrade system that the user can control using [rpm-ostree commands][4]. + +libostree knows nothing about packages—an upgrade means replacing one complete file system with another complete file system. libostree treats the file system tree as one atomic object (an unbreakable unit). In fact, the forerunner to Silverblue was named [Project Atomic][5]. + +The libostree project provides a library and set of tools. It’s an upgrade system that carries out these tasks. + + 1. Pull in a new file system + 2. Store the new file system + 3. Deploy the new file system + + + +##### Pull in a new file system + +Pulling in a new file system means copying an object (the entire file system) from a remote source to its own store. If you’ve worked with virtual machine image files, you already understand the concept of a file system object that you can copy. + +##### Store the new file system + +The libostree store has some source code control qualities—it stores many file system objects, and checks one out to be used as the root file system. libostree’s store has two parts: + + * a repository database at _/sysroot/ostree/repo/_ + * file systems in _/sysroot/ostree/deploy/fedora/deploy/_ + + + +libostree keeps track of what’s been checked in using commit IDs. Each commit ID can be found in a directory name, nested deep inside _/sysroot_ .A libostree commit ID is a long checksum, and looks similar to a git commit ID. + +``` +$ ls -d /sysroot/ostree/deploy/fedora/deploy/*/ +/sysroot/ostree/deploy/fedora/deploy/c4bf7a6339e6be97d0ca48a117a1a35c9c5e3256ae2db9e706b0147c5845fac4.0/ +``` + +_rpm-ostree status_ gives a little more information about that commit ID. The output is a little confusing; it can take a while to see this file system is Fedora 31. + +``` +$ rpm-ostree status +State: idle +AutomaticUpdates: disabled +Deployments: +● ostree://fedora:fedora/31/x86_64/silverblue + Version: 31.1.9 (2019-10-23T21:44:48Z) + Commit: c4bf7a6339e6be97d0ca48a117a1a35c9c5e3256ae2db9e706b0147c5845fac4 + GPGSignature: Valid signature by 7D22D5867F2A4236474BF7B850CB390B3C3359C4 +``` + +##### Deploy the new filesystem + +libostree deploys a new file system by checking out the new object from its store. libostree doesn’t check out a file system by copying all the files—it uses hard links instead. If you look inside the commit ID directory, you see something that looks suspiciously like the root directory. That’s because it _is_ the root directory. You can see these two directories are pointing to the same place by checking their inodes. + +``` +$ ls -di1 / /sysroot/ostree/deploy/fedora/deploy/*/ +260102 / +260102 /sysroot/ostree/deploy/fedora/deploy/c4bf7a6339e6be97d0ca48a117a1a35c9c5e3256ae2db9e706b0147c5845fac4.0/ +``` + +This is a fresh install, so there’s only one commit ID. After a system update, there will be two. If more copies of the file system are checked into libostree’s repo, more commit IDs appear here. + +##### Upgrade process + +Putting the pieces together, the update process looks like this: + + 1. libostree checks out a copy of the file system object from the repository + 2. DNF installs packages into the copy + 3. libostree checks in the copy as a new object + 4. libostree checks out the copy to become the new file system + 5. You reboot to pick up the new system files + + + +In addition to more safety, there is more flexibility. You can do new things with libostree’s repo, like store a few different file systems and check out whichever one you feel like using. + +#### Silverblue’s root file system + +Fedora keeps its system files in all the usual Linux places, such as _/boot_ for boot files, _/etc_ for configuration files, and _/home_ for user home directories. The root directory in Silverblue looks much like the root directory in traditional Fedora, but there are some differences. + + * The filesystem has been checked out by libostree + * Some directories are now symbolic links to new locations. For example, _/home_ is a symbolic link to _/var/home_ + * _/usr_ is a read-only directory + * There’s a new directory named _/sysroot_. This is libostree’s new home + + + +#### Juggling file systems + +You can store many file systems and switch between them. This is called _rebasing_, and it’s similar to git rebasing. In fact, upgrading Silverblue to the next Fedora version is not a big package install—it’s a pull from a remote repository and a rebase. + +You could store three copies with three different desktops: one KDE, one GNOME, and one XFCE. Or three different OS versions: how about keeping the current version, the nightly build, and an old classic? Switching between them is a matter of rebasing to the appropriate file system object. + +Rebasing is also how you upgrade from one Fedora release to the next. See “[How to rebase to Fedora 32 on Silverblue][6]” for more information. + +### Flatpak + +The [Flatpak project][7] provides a way of installing applications like LibreOffice. Applications are pulled from remote repositories like [Flathub][8]. It’s a kind of package manager, although you won’t find the word _package_ in the [docs][9]. Traditional Fedora variants like Fedora Workstation can also use Flatpak, but the sandboxed nature of flatpaks make it particularly good for Silverblue. This way you do not have to do the entire ostree update process every time you wish to install an application. + +Flatpak is well-suited to desktop applications, but also works for command line applications. You can install the [vim][10] editor with the command _flatpak install flathub org.vim.Vim_ and run it with _flatpak run org.vim.Vim_. + +### toolbox + +The [toolbox project][11] provides a traditional operating system inside a container. The idea is that you can mess with the mutable OS inside your toolbox (the Fedora container) as much as you like, and leave the immutable OS outside your toolbox untouched. You pack as many toolboxes as you want on your system, so you can keep work separated. Behind the scenes, the executable _/usr/bin/toolbox_ is a shell script that uses [podman][12]. + +A fresh install does not include a default toolbox. The _toolbox create_ command checks the OS version (by reading _/usr/lib/os-release_), looks for a matching version at the Fedora container registry, and downloads the container. + +``` +$ toolbox create +Image required to create toolbox container. +Download registry.fedoraproject.org/f31/fedora-toolbox:31 (500MB)? [y/N]: y +Created container: fedora-toolbox-31 +Enter with: toolbox enter +``` + +Hundreds of packages are installed inside the toolbox. The _dnf_ command and the usual Fedora repos are set up, ready to install more. The _ostree_ and _rpm-ostree_ commands are not included – no immutable OS here. + +Each user’s home directory is mounted on their toolbox, for storing content files outside the container. + +### Put the pieces together + +Spend some time exploring Fedora Silverblue and it will become clear how these components fit together. Like other Fedora variants, all these of tools come from open source projects. You can get as up close and personal as you want, from reading their docs to contributing code. Or you can [contribute to Silverblue][13] itself. + +Join the Fedora Silverblue conversations on [discussion.fedoraproject.org][14] or in [#silverblue on Freenode IRC][15]. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/pieces-of-fedora-silverblue/ + +作者:[Nick Hardiman][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://fedoramagazine.org/author/nickhardiman/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/04/silverblue-pieces-816x345.png +[2]: https://fedoramagazine.org/what-is-silverblue/ +[3]: https://ostree.readthedocs.io/en/latest/ +[4]: https://rpm-ostree.readthedocs.io/en/latest/manual/administrator-handbook/#administering-an-rpm-ostree-based-system +[5]: https://www.projectatomic.io/ +[6]: https://fedoramagazine.org/how-to-rebase-to-fedora-32-on-silverblue/ +[7]: https://github.com/flatpak/flatpak +[8]: https://flathub.org/ +[9]: http://docs.flatpak.org/en/latest/index.html +[10]: https://www.vim.org/ +[11]: https://github.com/containers/toolbox +[12]: https://github.com/containers/libpod +[13]: https://silverblue.fedoraproject.org/contribute +[14]: https://discussion.fedoraproject.org/c/desktop/silverblue +[15]: https://webchat.freenode.net/#silverblue diff --git a/sources/tech/20200516 Fatih-s question.md b/sources/tech/20200516 Fatih-s question.md new file mode 100644 index 0000000000..1225c624a8 --- /dev/null +++ b/sources/tech/20200516 Fatih-s question.md @@ -0,0 +1,214 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fatih’s question) +[#]: via: (https://dave.cheney.net/2020/05/16/fatihs-question) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Fatih’s question +====== + +A few days ago Fatih posted [this question][1] on twitter. + +I’m going to attempt to give my answer, however to do that I need to apply some simplifications as my previous attempts to answer it involved a lot of phrases like _a pointer to a pointer_, and other unhelpful waffling. Hopefully my simplified answer can be useful in building a mental framework to answer Fatih’s original question. + +### Restating the question + +Fatih’s original tweet showed [four different variations][2] of `json.Unmarshal`. I’m going to focus on the last two, which I’ll rewrite a little: + +``` +package main + +import ( + "encoding/json" + "fmt" +) + +type Result struct { + Foo string `json:"foo"` +} + +func main() { + content := []byte(`{"foo": "bar"}`) + var result1, result2 *Result + + err := json.Unmarshal(content, &result1) + fmt.Println(result1, err) // &{bar} + + err = json.Unmarshal(content, result2) + fmt.Println(result2, err) // json: Unmarshal(nil *main.Result) +} +``` + +Restated in words, `result1` and `result2` are the same type; `*Result`. Decoding into `result1` works as expected, whereas decoding into `result2` causes the `json` package to complain that the value passed to `Unmarshal` is `nil`. However, both values were declared without an initialiser so both would have taken on the type’s zero value, `nil`. + +Eagle eyed readers will have spotted that the reason for the difference is the first` `invocation is passed `&result1`, while the second is passed `result2`, but this explanation is unsatisfactory because the documentation for `json.Unmarshal` states: + +> Unmarshal parses the JSON-encoded data and stores the result in the value pointed to by v. **If v is nil or not a pointer**, Unmarshal returns an InvalidUnmarshalError. + +Which is confusing because `result1` and `result2` _are_ pointers. Furthermore, without initialisation, both _are_ `nil`. Now, the documentation is correct (as you’d expect from a package that has been hammered on for a decade), but explaining _why_ takes a little more investigation. + +### Functions receive a copy of their arguments + +Every assignment in Go is a copy, this includes function arguments and return values. + +``` +package main + +import ( + "fmt" +) + +func increment(v int) { + v++ +} + +func main() { + v := 1 + increment(v) + fmt.Println(v) // 1 +} +``` + +In this example, `increment` is operating on a _copy_ of `main`‘s `v`. This is because the `v` declared in `main` and `increment`‘s `v` parameter have different addresses in memory. Thus changes to `increment`‘s `v` cannot affect the contents of `main`‘s `v`. + +``` +package main + +import ( + "fmt" +) + +func increment(v *int) { + *v++ +} + +func main() { + v := 1 + increment(&v) + fmt.Println(v) // 2 +} +``` + +If we wanted to write `increment` in a way that it could affect the contents of its caller we would need to pass a reference, a pointer, to `main.v`.[1][3] This example demonstrates why `json.Unmarshal` needs a pointer to the value to decode JSON into. + +### Pointers to pointers + +Returning to the original question, both `result1` and `result2` are declared as `*Result`, that is, pointers to a `Result` value. We established that you have to pass the address of caller’s value to `json.Unmarshal` otherwise it won’t be able to alter the contents of the caller’s value. Why then must we pass the address of `result1`, a `**Result`, a pointer to a pointer to a `Result`, for the operation to succeed. + +To explain this another detour is required. Consider this code: + +``` +package main + +import ( + "encoding/json" + "fmt" +) + +type Result struct { + Foo *string `json:"foo"` +} + +func main() { + content := []byte(`{"foo": "bar"}`) + var result1 *Result + + err := json.Unmarshal(content, &result1) + fmt.Printf("%#v %v", result1, err) // &main.Result{Foo:(*string)(0xc0000102f0)} +} +``` + +In this example `Result` contains a pointer typed field, `Foo *string`. During JSON decoding `Unmarshal` allocated a new `string` value, stored the value `bar` in it, then placed the address of the string in `Result.Foo`. This behaviour is quite handy as it frees the caller from having to initialise `Result.Foo` and makes it easier to detect when a field was not initialised because the JSON did not contain a value. Beyond the convenience this offers for simple examples it would be prohibitively difficult for the caller to properly initialise all the reference type fields in a structure before decoding unknown JSON without first inspecting the incoming JSON which itself may be problematic if the input is coming from an `io.Reader` without the ability to rewind the input. + +> To unmarshal JSON into a pointer, Unmarshal first handles the case of the JSON being the JSON literal null. In that case, Unmarshal sets the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into the value pointed at by the pointer. **If the pointer is nil, Unmarshal allocates a new value for it to point to**. + +`json.Unmarshal`‘s handling of pointer fields is clearly documented, and works as you would expect, allocating a new value whenever there is a need to decode into a pointer shaped field. It is this behaviour that gives us a hint to what is happening in the original example. + +We’ve seen that when `json.Unmarshal` encounters a field which points to `nil` it will allocate a new value of the correct type and assign its address the field before proceeding. Not only is does behaviour is applied recursively–for example in the case of a complex structure which contains pointers to other structures–but it also applies to the _value passed to `Unmarshal`._ + +``` +package main + +import ( + "encoding/json" + "fmt" +) + +func main() { + content := []byte(`1`) + var result *int + + err := json.Unmarshal(content, &result) + fmt.Println(*result, err) // 1 +} +``` + +In this example `result` is not a struct, but a simple `*int` which, lacking an initialiser, defaults to `nil`. After JSON decoding, `result` now points to an `int` with the value `1`. + +### Putting the pieces together + +Now I think I’m ready to take a shot at answering Fatih’s question. + +`json.Unmarshal` requires the address of the variable you want to decode into, otherwise it would decode into a temporary copy which would be discard on return. Normally this is done by declaring a value, then passing its address, or explicitly initialising the the value + +``` +var result1 Result +err := json.Unmarshal(content, &result1) // this is fine + +var result2 = new(Result) +err = json.Unmarshal(content, result2) // and this + +var result3 = &Result{} +err = json.Unmarshal(content, result3) // this is also fine +``` + +In all three cases the address that the `*Result` points too is not `nil`, it points to initialised memory that `json.Unmarshal` decodes into. + +Now consider what happens when `json.Unmarshal` encounters this + +``` +var result4 *Result +err = json.Unmarshal(content, result4) // err json: Unmarshal(nil *main.Result) +``` + +`result2`, `result3`, and the expression `&result1` point to a `Result`. However `result4`, even though it has the same type as the previous three, does not point to initialised memory, it points to `nil`. Thus, according to the examples we saw previously, before `json.Unmarshal` can decode into it, the memory `result4` points too must be initialised. + +However, because each function receives a copy of its arguments, the caller’s `result4` variable and the copy inside `json.Unmarshal` are unique. `json.Unmarshal` can allocate a new `Result` value and decode into it, but it cannot alter `result4` to point to this new value because it was not provided with a reference to `result4`, only a copy of its contents. + + 1. This does not violate the _everything is a copy_ rule, a copy of a pointer to `main.v` still points to `main.v`.[][4] + + + +#### Related posts: + + 1. [Should methods be declared on T or *T][5] + 2. [Ice cream makers and data races][6] + 3. [Understand Go pointers in less than 800 words or your money back][7] + 4. [Slices from the ground up][8] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2020/05/16/fatihs-question + +作者:[Dave Cheney][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://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://twitter.com/fatih/status/1260683136842608640 +[2]: https://play.golang.org/p/g2yUIYrV67F +[3]: tmp.dRxkHxYRQS#easy-footnote-bottom-1-4153 (This does not violate the everything is a copy rule, a copy of a pointer to main.v still points to main.v.) +[4]: tmp.dRxkHxYRQS#easy-footnote-1-4153 +[5]: https://dave.cheney.net/2016/03/19/should-methods-be-declared-on-t-or-t (Should methods be declared on T or *T) +[6]: https://dave.cheney.net/2014/06/27/ice-cream-makers-and-data-races (Ice cream makers and data races) +[7]: https://dave.cheney.net/2017/04/26/understand-go-pointers-in-less-than-800-words-or-your-money-back (Understand Go pointers in less than 800 words or your money back) +[8]: https://dave.cheney.net/2018/07/12/slices-from-the-ground-up (Slices from the ground up) diff --git a/sources/tech/20200518 Using Fedora to implement REST API in JavaScript- part 2.md b/sources/tech/20200518 Using Fedora to implement REST API in JavaScript- part 2.md new file mode 100644 index 0000000000..b02822c4fa --- /dev/null +++ b/sources/tech/20200518 Using Fedora to implement REST API in JavaScript- part 2.md @@ -0,0 +1,208 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Using Fedora to implement REST API in JavaScript: part 2) +[#]: via: (https://fedoramagazine.org/using-fedora-to-implement-rest-api-in-javascript-part-2/) +[#]: author: (Vaclav Keil https://fedoramagazine.org/author/vaclavk/) + +Using Fedora to implement REST API in JavaScript: part 2 +====== + +![][1] + +In [part 1][2] previously, you saw how to quickly create a simple API service using Fedora Workstation, Express, and JavaScript. This article shows you the simplicity of how to create a new API. This part shows you how to: + + * Install a DB server + * Build a new route + * Connect a new datasource + * Use Fedora terminal to send and receive data + + + +### Generating an app + +Please refer to the [previous article][2] for more details. But to make things simple, change to your work directory and generate an app skeleton. +``` + +``` + +$ cd our-work-directory +$ npx express-generator –no-view –git /myApp +$ cd myApp +$ npm i +``` + +``` + +### Installing a database server + +In this part, we’ll install MariaDB database. MariaDB is the Fedora default database. + +``` +$ dnf module list mariadb | sort -u ## lists the streams available +$ sudo dnf module install mariadb:10.3 ##10.4 is the latest +``` + +_Note: the default profile is mariadb/server_. + +For those who need to spin up a Docker container a ready made container with Fedora 31 is available. + +``` +$ docker pull registry.fedoraproject.org/f31/mariadb +$ docker run -d --name mariadb_database -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 registry.fedoraproject.org/f31/mariadb +``` + +Now start the MariaDB service. + +``` +$ sudo systemctl start mariadb +``` + +If you’d like the service to start at boot, you can also enable it in systemd: + +``` +$ sudo systemctl enable mariadb ## start at boot +``` + +Next, setup the database as needed: + +``` +$ mysql -u root -p ## root password is blank +MariaDB> CREATE DATABASE users; +MariaDB> create user dbuser identified by ‘123456‘; +MariaDB> grant select, insert, update, create, drop on users.* to dbuser; +MariaDB> show grants for dbuser; +MariaDB> \q +``` + +A database connector is needed to use the database with Node.js. + +``` +$ npm install mariadb ## installs MariaDB Node.js connector +``` + +We’ll leverage Sequelize in this sample API. Sequelize is a promise-based Node.js ORM (Object Relational Mapper) for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. + +``` +$ npm install sequelize ## installs Sequelize +``` + +### Connecting a new datasource + +Now, create a new _db_ folder and create a new file _sequelize.js_ there: + +``` +const Sequelize = require('sequelize'), + sequelize = new Sequelize(process.env.db_name || 'users', process.env.db_user || 'dbuser', process.env.db_pass || '123456', { + host: 'localhost', + dialect: 'mariadb', + ssl: true +}) + +module.exports = sequelize +``` + +_Note: For the sake of completeness I‘m including a link to the related Github repo: _ + +Let‘s create a new file _models/user.js_. A nice feature of a Sequelize model is that it helps us to create the necessary tables and colums automatically. The code snippet responsible for doing this is seen below: + +``` +sequelize.sync({ +force: false +}) +``` + +Note: never switch to true with a production database – it would _drop your tables at app start_! + +We will refer to the earlier created sequelize.js this way: + +``` +const sequelize = require('../db/sequelize') +``` + +### Building new routes + +Next, you’ll create a new file _routes/user.js_. You already have _routes/users.js_ from the previous article. You can copy and paste the code in and proceed with editing it. + +You’ll also need a reference to the previously created model. + +``` +const User = require('../models/user') +``` + +Change the route path to _/users_ and also create a new **post** method route. + +Mind the async – await keywords there. An interaction with a database will take some time and this one will do the trick. Yes, an async function returns a promise and this one makes promises easy to use. + +_Note: This code is not production ready, since it would also need to include an authentication feature._ + +We‘ll make the new route working this way: + +``` +const userRouter = require('./routes/user') +app.use(userRouter) +``` + +Let‘s also remove the existing _usersRouter_. The _routes/users.js_ can be deleted too. + +``` +$ npm start +``` + +With the above command, you can launch your new app. + +### Using the terminal to send and retrieve data + +Let’s create a new database record through the post method: + +``` +$ curl -d 'name=Adam' http://localhost:3000/users +``` + +To retrieve the data created through the API, do an HTTP GET request: + +``` +$ curl http://localhost:3000/users +``` + +The console output of the curl command is a JSON array containing data of all the records in the _Users_ table. + +_Note: This is not really the usual end result — an application consumes the API finally. The API will usually also have endpoints to update and remove data._ + +### More automation + +Let‘s assume we might want to create an API serving many tables. It‘s possible and very handy to automatically generate models for Sequelize from our database. Sequelize-auto will do the heavy lifting for us. The resulting files (_models.js_) would be placed and imported within the _/models_ directory. + +``` +$ npm install sequelize-auto +``` + +A node.js connector is needed to use this one and we have it already installed for MariaDB. + +### Conclusion + +It‘s possible to develop and run an API using Fedora, Fedora default MariaDB, JavaScript and efficiently develop a solution like with a noSQL database. For those used to working with MongoDB or a similar noSQL database, Fedora and MariaDB are important open-source enablers. + +* * * + +_Photo by [Mazhar Zandsalimi][3] on [Unsplash][4]._ + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/using-fedora-to-implement-rest-api-in-javascript-part-2/ + +作者:[Vaclav Keil][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://fedoramagazine.org/author/vaclavk/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/05/javascript-api-2-816x345.jpg +[2]: https://fedoramagazine.org/using-fedora-to-quickly-implement-rest-api-with-javascript/ +[3]: https://unsplash.com/@m47h4r?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[4]: https://unsplash.com/s/photos/javascript?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText diff --git a/sources/tech/20200519 How to use Windows Subsystem for Linux to open Linux on Windows 10 machines.md b/sources/tech/20200519 How to use Windows Subsystem for Linux to open Linux on Windows 10 machines.md new file mode 100644 index 0000000000..e610f7eb2f --- /dev/null +++ b/sources/tech/20200519 How to use Windows Subsystem for Linux to open Linux on Windows 10 machines.md @@ -0,0 +1,153 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use Windows Subsystem for Linux to open Linux on Windows 10 machines) +[#]: via: (https://www.networkworld.com/article/3543845/how-to-use-windows-subsystem-for-linux-to-open-linux-on-windows-10-machines.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +How to use Windows Subsystem for Linux to open Linux on Windows 10 machines +====== +Opening a Linux terminal on a Windows 10 desktop can help you practice your Linux skills and explore Windows from an entirely different point of view. In this post, we look at Ubuntu 18.04 running through Windows Subsystem for Linux (WSL). +[Nicolas Solerieu modified by IDG Comm. / Linux][1] [(CC0)][2] + +Believe it or not, it's possible to open a Linux terminal on a Windows 10 system and you might be surprised how much Linux functionality you’ll be able to get by doing so. + +You can run Linux commands, traipse around the provided Linux file system and even take a novel look at Windows files. The experience isn’t altogether different than opening a terminal window on a Linux desktop, with a few interesting exceptions. + +[[Get regularly scheduled insights by signing up for Network World newsletters.]][3] + +What is needed to make this happen is something called the Windows Subsystem for Linux (WSL) and a Windows 10 x86 PC. + +### Linux versions for WSL + +There are a number of options for running Linux on top of Windows. The Linux OS choices include: + + * [Ubuntu 16.04 LTS][4] + * [Ubuntu 18.04 LTS][5] + * [openSUSE Leap 15.1][6] + * [SUSE Linux Enterprise Server 12 SP5][7] + * [SUSE Linux Enterprise Server 15 SP1][8] + * [Kali Linux][9] + * [Debian GNU/Linux][10] + * [Fedora Remix for WSL][11] + * [Pengwin][12] + * [Pengwin Enterprise][13] + * [Alpine WSL][14] + + + +Ubuntu 18.04 LTS is just one option and, in this post, we’ll take a look at how the terminal runs on Windows using this particular distribution and how much it feels like working on a Linux system directly. + +If you want to look into the process of putting an Ubuntu distribution on your Windows system, you can start with this page: + + + +As part of the initial setup of installing your Linux on Windows terminal, you’ll be asked to create your user account. Once you do that and open the terminal, you can start to explore. One of the most noticeable differences between your Linux-on-Windows terminal and a terminal window on a Linux system is that examining processes isn’t going to show you much. After all, Windows will be providing the bulk of the required OS support. You’re likely to see something like this: + +``` +myacct@hostname:~$ ps -ef +UID PID PPID C STIME TTY TIME CMD +root 1 0 0 12:45 ? 00:00:00 /init +root 7 1 0 12:45 tty1 00:00:00 /init +shs 8 7 0 12:45 tty1 00:00:00 -bash +shs 166 8 0 13:32 tty1 00:00:00 ps -ef +``` + +Yes, that's it. + +If you’re anything like me, one of your next moves might be to get a handle on the available commands. If you just count the files in the **/bin** and **/usr/bin** directories, you should see that there are a lot of commands: + +``` +myacct@hostname:~$ ls /bin | wc -l +171 +myacct@hostname:~$ ls /usr/bin | wc -l +707 +``` + +You can list available commands with commands like these (output truncated for this post): + +``` +myacct@hostname:~$ ls /bin | head -25 | column +bash btrfs-map-logical bunzip2 bzegrep bzip2recover +btrfs btrfs-select-super busybox bzexe bzless +btrfs-debug-tree btrfs-zero-log bzcat bzfgrep bzmore +btrfs-find-root btrfsck bzcmp bzgrep cat +btrfs-image btrfstune bzdiff bzip2 chacl + +myacct@hostname:~$ ls /usr/bin | head -25 | column +NF aa-exec apport-cli apt apt-extracttempl* +VGAuthService acpi_listen apport-collect apt-add-repository apt-ftparchive +X11 add-apt-repository apport-unpack apt-cache apt-get +[ addpart appres apt-cdrom apt-key +aa-enabled apport-bug apropos apt-config apt-mark +``` + +You can update the system with **apt** commands (sudo apt update, sudo apt upgrade). You can even use Linux commands to move to the Windows disk partitions as you like and . Notice the last three entries in the output below. These represent several drives on the system. + +``` +myacct@hostname:~$ df -k +Filesystem 1K-blocks Used Available Use% Mounted on +rootfs 973067784 326920584 646147200 34% / +none 973067784 326920584 646147200 34% /dev +none 973067784 326920584 646147200 34% /run +none 973067784 326920584 646147200 34% /run/lock +none 973067784 326920584 646147200 34% /run/shm +none 973067784 326920584 646147200 34% /run/user +cgroup 973067784 326920584 646147200 34% /sys/fs/cgroup +C:\ 973067784 326920584 646147200 34% /mnt/c <== C drive +I:\ 976760000 231268208 745491792 24% /mnt/I <== external drive +L:\ 409599996 159240 409440756 1% /mnt/l <== USB thumb drive +``` + +If you’re interested in moving out of the Linux space and into the Windows portion of the file system within your **WSL** session, you can do that easily. Replace “myname” with your Windows account name and a **cd /mnt/c/Users/_myname_/Desktop** will take you to your Windows desktop. From there, don’t be surprised if in listing your files you see **WRL####.tmp** files that don’t seem to exist when you look at your desktop and don’t show up if you look at your files by opening a command prompt. These appear to be temporary files used by Windows for document management. You might also see files listed that look like **‘~$nux notes.docx’** – perhaps ghosts of files that were once located on your desktop. You won’t see those files when you look at your desktop on Windows – even using a **cmd** window. + +Note that you’ll also see Windows directories such as **‘Program Files’** in single quotes when listed in your Linux terminal as you would any file with blanks included in their names. You can even start a Windows executable from your Linux terminal. For example: + +``` +myacct@hostname: $ cd /mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0 +myacct@hostname: $ powershell.exe +``` + +If you do this, type **exit** when you want to end the **powershell** session. + +Linux commands all seem to work as expected, though I don’t get any output when I run the **who** command. + +Windows **.txt** files will display with **cat** commands, but the last line in a file will likely be displayed on the same line as the following shell prompt. This is because these files won’t end with a linefeed as Linux text files do. + +You can create other accounts and switch user to them (e.g., **su – nemo**) if you like, but not log into them directly. + +You can also update the system with apt commands (**sudo apt update**, **sudo apt upgrade**). + +Join the Network World communities on [Facebook][15] and [LinkedIn][16] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3543845/how-to-use-windows-subsystem-for-linux-to-open-linux-on-windows-10-machines.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://unsplash.com/photos/4gRNmhGzYZE +[2]: https://creativecommons.org/publicdomain/zero/1.0/ +[3]: https://www.networkworld.com/newsletters/signup.html +[4]: https://www.microsoft.com/store/apps/9pjn388hp8c9 +[5]: https://www.microsoft.com/store/apps/9N9TNGVNDL3Q +[6]: https://www.microsoft.com/store/apps/9NJFZK00FGKV +[7]: https://www.microsoft.com/store/apps/9MZ3D1TRP8T1 +[8]: https://www.microsoft.com/store/apps/9PN498VPMF3Z +[9]: https://www.microsoft.com/store/apps/9PKR34TNCV07 +[10]: https://www.microsoft.com/store/apps/9MSVKQC78PK6 +[11]: https://www.microsoft.com/store/apps/9n6gdm4k2hnc +[12]: https://www.microsoft.com/store/apps/9NV1GV1PXZ6P +[13]: https://www.microsoft.com/store/apps/9N8LP0X93VCP +[14]: https://www.microsoft.com/store/apps/9p804crf0395 +[15]: https://www.facebook.com/NetworkWorld/ +[16]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20200520 Fedora Silverblue, an introduction for developers.md b/sources/tech/20200520 Fedora Silverblue, an introduction for developers.md new file mode 100644 index 0000000000..a112f4ca6d --- /dev/null +++ b/sources/tech/20200520 Fedora Silverblue, an introduction for developers.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fedora Silverblue, an introduction for developers) +[#]: via: (https://fedoramagazine.org/fedora-silverblue-brings-future-tech-to-the-desktop/) +[#]: author: (Nick Hardiman https://fedoramagazine.org/author/nickhardiman/) + +Fedora Silverblue, an introduction for developers +====== + +![][1] + +The Fedora [Silverblue project][2] takes Fedora workstation, libostree and podman, puts them in a blender, and creates a new Immutable Fedora Workstation. Fedora Silverblue is an OS that stops you from changing the core system files arbitrarily, and readily allows you to change the environment system files. The article [What is Silverblue][3] describes the big picture, and this article drills down into details for the developer. + +Fedora Silverblue ties together a few different projects to make a system that is a git-like object, capable of layering packages, and has a container focused work flow. Silverblue is not the only distribution going down this road. It is the desktop equivalent of [CoreOS][4], the server OS used by [Red Hat Openshift][5]. + +Silverblue’s idea of ‘immutable’ has nothing to do with immutable layers in a container. Silverblue keeps system files immutable by making them read-only. + +### Why immutable? + +Has an upgrade left your system in an unusable state? Have you wondered why one server in a pool of identical machines is being weird? These problems can happen when one system library – one tiny little file out of hundreds – is corrupted, badly configured or the wrong version. Or maybe your upgrade works fine but it’s not what you’d hoped for, and you want to roll back to the previous state. + +An immutable OS is intended to stop problems like these biting you. This is not an easy thing to achieve – simple changes, like flipping the file system between read-write and read-only, may only change a fault-finding headache to a maintenance headache. + +Freezing the system is good news for sysadmins, but what about developers? Setting up a development environment means heavily customizing the system, and filling it with living code that changes over time. The answer is partly a case of combining components, and partly the ability to swap between OS versions. + +### How it works + +So how do you get the benefits of immutability without losing the ability to do your work? If you’re thinking ‘containers’, good guess – part of the solution uses [podman][6]. But much of the work happens underneath the container layer, at the OS level. + +Fedora Silverblue ties together a few different projects to turn an immutable OS into a usable workstation. Silverblue uses libostree to provide the base system, lets you edit config files in /etc/, and provides three different ways to install packages. + + * [rpm-ostree][7] installs RPM packages, similar to DNF in the traditional Fedora workstation. Use this for things that shouldn’t go in containers, like KVM/libvirt. + * [flatpak][8] installs packages from a central flathub repo. This is the one-stop shop for graphical desktop apps like LibreOffice. + * The traditional _dnf install_ still works, but only inside a [toolbox][9] (a Fedora container). A developer’s workbench goes in a toolbox. + + + +If you want to know more about these components, check out [Pieces of Silverblue][10]. + +### Rolling back and pinning upgrades + +All operating systems need upgrades. Features are added, security holes are plugged and bugs are squashed. But sometimes an upgrade is not a developer’s friend. + +A developer depends on many things to get the job done. A good development environment is stuffed with libraries, editors, toolchains and apps that are controlled by the OS, not the developer. An upgrade may cause trouble. Have any of these situations happened to you? + + * A new encryption library is too strict, and an upgrade stopped an API working. + * Code works well, but has deprecated syntax. An upgrade brought error-throwing misery. + * The development environment is lovingly hand-crafted. An upgrade broke dependencies and added conflicts. + + + +In a traditional environment, unpicking a troublesome upgrade is hard. In Silverblue, it’s easy. Silverblue keeps two copies of the OS – your current upgrade and your previous version. Point the OS at the previous version, reboot, and you’ve got your old system files back. + +You aren’t limited to two copies of your file system – you can keep more by pinning your favorite versions. Dusty Mabe, one of the engineers who has been working on the system since the [Project Atomic][11] days, describes how to pin extra copies of the OS in his article [Pinning Deployments in OSTree Based Systems][12]. + +Your home directory is not affected by rolling back. Rpm-ostree does not touch /etc/ and /var/. + +### System updates and package installs + +Silverblue’s rpm-ostree treats all the files as one object, stored in a repository. The working file system is a checked-out copy of this object. After a system update, you get two objects in that repository – one current object and one updated object. The updated object is checked out and becomes the new file system. + +You install your workhorse applications in toolboxes, which provide container isolation. And you install your desktop applications using Flatpak. + +This new OS requires a shift in approach. For instance, you don’t have to keep only one copy of your system files – you can store a few and select which one you use. That means you can swap back and forth between an old Fedora release and the rawhide (development) version in a matter of minutes. + +### Build your own Silverblue VM + +You can safely install Fedora Silverblue in a VM on your workstation. If you’ve got a hypervisor and half an hour to spare (10 minutes for ISO download, and 20 minutes for the build), you can see for yourself. + + 1. Download Fedora Silverblue ISO from + 2. (not Fedora workstation from ). + 3. Boot a VM with the Fedora Silverblue ISO. You can squeeze Fedora into compute resources of 1 CPU, 1024MiB of memory and 12GiB of storage, but bigger is better. + 4. Answer [Anaconda][13]’s questions. + 5. Wait for the [Gnome][14] desktop to appear. + 6. Answer [Initial Setup][15]’s questions. + + + +Then you’re ready to set up your developer’s tools. If you’re looking for an IDE, check these out. Use flatpak on the desktop to install them. + + * [Gnome Builder][16] (Gnome’s official IDE) + * [Eclipse][17] + * [Code::Blocks][18] + + + +Finally, use the CLI to create your first toolbox. Load it with modules using [npm][19], [gem][20], [pip][21], [git][22] or your other favorite tools. + +### Help! + +If you get stuck, ask questions at the [forum][23]. + +If you’re looking for ideas about how to use Silverblue, read articles in the [magazine][24]. + +### Is Silverblue for you? + +Silverblue is full of shiny new tech. That in itself is enough to attract the cool kids, like moths to a flame. But this OS is not for everyone. It’s a young system, so some bugs will still be lurking in there. And pioneering tech requires a change of habit – that’s extra cognitive load that the new user may not want to take on. + +The OS brings immutable benefits, like keeping your system files safe. It also brings some drawbacks, like the need to reboot after adding system packages. Silverblue also enables new ways of working. If you want to explore new directions in the OS, find out if Silverblue brings benefits to your work. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/fedora-silverblue-brings-future-tech-to-the-desktop/ + +作者:[Nick Hardiman][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://fedoramagazine.org/author/nickhardiman/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2020/04/silverblue-introfordev-816x345.png +[2]: https://silverblue.fedoraproject.org/ +[3]: https://fedoramagazine.org/what-is-silverblue/ +[4]: http://coreos.com/ +[5]: https://www.openshift.com/products/container-platform +[6]: https://github.com/containers/libpod +[7]: https://rpm-ostree.readthedocs.io/en/latest/ +[8]: https://docs.flatpak.org/en/latest/ +[9]: https://github.com/containers/toolbox +[10]: https://fedoramagazine.org/pieces-of-fedora-silverblue/ +[11]: https://www.projectatomic.io/ +[12]: https://www.projectatomic.io/blog/2018/05/pinning-deployments-ostree-based-systems/ +[13]: https://fedoraproject.org/wiki/Anaconda +[14]: https://www.gnome.org/ +[15]: https://fedoraproject.org/wiki/InitialSetup +[16]: https://wiki.gnome.org/Apps/Builder +[17]: https://www.eclipse.org/ide/ +[18]: http://www.codeblocks.org/ +[19]: https://www.npmjs.com/package/package +[20]: https://rubygems.org/ +[21]: https://pypi.org/ +[22]: https://git-scm.com/ +[23]: https://discussion.fedoraproject.org/c/desktop/silverblue/6 +[24]: https://fedoramagazine.org/?s=silverblue diff --git a/sources/tech/20200521 Glico (Weighted Rock Paper Scissors).md b/sources/tech/20200521 Glico (Weighted Rock Paper Scissors).md new file mode 100644 index 0000000000..77e3cfb5ed --- /dev/null +++ b/sources/tech/20200521 Glico (Weighted Rock Paper Scissors).md @@ -0,0 +1,141 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Glico (Weighted Rock Paper Scissors)) +[#]: via: (https://theartofmachinery.com/2020/05/21/glico_weighted_rock_paper_scissors.html) +[#]: author: (Simon Arneaud https://theartofmachinery.com) + +Glico (Weighted Rock Paper Scissors) +====== + +This still isn’t the blog post I said I was going to write about now, but I figured some game theory would make a good post at the moment, especially when a lot of people I know are working at home with kids who need entertaining. Here’s some stuff about a traditional Japanese kids’ game called Glico, a form of weighted Rock Paper Scissors (RPS). + +### Glico + +I’ll assume you’re familiar with regular RPS. It’s pretty obvious how to play well: the three plays, “rock”, “paper” and “scissors”, are equally strong, so the only trick is to play them unpredictably enough. + +But what happens if the three plays have different values? Weighted RPS, under the name “Glico”, has been a well-known Japanese children’s game since at least before WWII, but let me explain an English adaptation. Traditionally it’s played starting at the bottom of a flight of stairs, and the aim is to get to the top first. Players can climb up steps by winning rounds of RPS. The trick is that the number of steps depends on the winning hand in each round. A player who wins with “rock” gets to climb up four steps by spelling out R-O-C-K, and similarly “paper” is worth five steps and “scissors” worth eight. This simple twist to the game creates whole new layers of offence and defence as players struggle to win with “scissors” as much as possible, without being too predictable and vulnerable. + +(The rules for the Japanese version vary by region, but usually “rock” is worth 3 steps, while “paper” and “scissors” are worth 6. The mnemonic is that “rock”, “paper” and “scissors” are referred to as グー, パー and チョキ respectively, and the words spelled out when playing are グリコ (“Glico”, a food/confectionary brand), パイナップル (pineapple) and チョコレート (chocolate).) + +Just a few notes before getting into the maths: The game works best with two players, but in the traditional rules for three or more players, each round is handled by having multiple rematches. Each time there’s a clear winning hand (e.g., two players with “paper” beating one with “rock”) the losers are eliminated until there’s one winner. That can take a long time, so cycling systematically between pairs of players might be faster for several players. (I’ll assume two players from now on.) Also, older kids sometimes add an extra challenge by requiring an exact landing at the top of the stairs to win. For example, if you’re five steps from the top, only “paper” will win; “scissors” will overshoot by three steps, and you’ll end up three steps back down from the top. Be warned: that makes gameplay a lot harder. + +### Calculating the optimal strategy + +Simple strategies like “just play rock” are what game theorists call “pure strategies”. By design, no pure strategy in RPS is better than all others, and an adaptive opponent can quickly learn to exploit any pure strategy (e.g., by always playing “paper” against someone who always plays “rock”). Any decent player will play RPS with something like a “mixed strategy” (selecting from the pure strategies at random, maybe with different probabilities). Game theory tells us that finite, two-player, zero-sum games always have optimal mixed strategies — i.e., a mixed strategy that’s as good or better than any other, even against an adaptive opponent. You might do better by exploiting a weak opponent, but you can’t do better against a perfect one. In plain RPS, the statistically unbeatable strategy is to play each hand with equal probability (\frac{1}{3}). + +Glico is made up of multiple rounds of weighted RPS. A truly optimal player won’t just use one set of probabilities (p_{r}), (p_{p}) and (p_{s}) for playing “rock”, “paper” and “scissors” each round. The optimal probabilities will vary depending the position of both players on the stairs. For example, a player who is four steps from winning is either happy with any winning hand, or only wants “rock”, depending on the rules, and (theoretically) both players should recognise that and adapt their probabilities accordingly. However, it’s more practical to play with an optimal greedy strategy — i.e., assuming everyone is just trying to get the maximum step value each round. + +I’ll calculate an optimal greedy strategy for weighted RPS in two ways. One way is longer but uses nothing but high school algebra and logical thinking, while the other way uses the power of linear programming. + +#### The longer way + +The greedy version of Glico has no end goal; the players are just trying to win points. It helps with solving the game if we make it zero sum — any time you win (N) points, your opponent loses (N) points, and vice versa. That just scales and shifts the score per round, so it doesn’t change the optimal strategy. Why do it? We know that optimal players can’t get any advantage over each other because the game is symmetric. If the game is zero sum, that means that no strategy can have an expected value of more than 0 points. That lets us write some equations. For example, playing “rock” might win you 4 points against “scissors”, or lose you 5 against “paper”. Against an optimal opponent, we can say + +[4p_{s} - 5p_{p} \leq 0] + +Is the inequality necessary? When would a pure strategy have a negative value against a non-adaptive but optimal player? Imagine if we added a fourth pure strategy, “bomb”, that simply gave 1000 points to the opponent. Obviously no optimal player would ever play “bomb”, so (p_{b} = 0). Playing “bomb” against an optimal player would have expected value -1000. We can say that some pure strategies are just _bad_: they have suboptimal value against an optimal opponent, and an optimal player will never play them. Other pure strategies have optimal value against an optimal opponent, and they’re reasonable to include in an optimal strategy. + +Bad pure strategies aren’t always as obvious as “bomb”, but we can argue that none of the pure strategies in RPS are bad. “Rock” is the only way to beat “scissors”, and “paper” is the only way to beat “rock”, and “scissors” is the only way to beat “paper”. At least one must be in the optimal strategy, so we can expect them all to be. So let’s make that (\leq) into (=), and add the equations for playing “paper” and “scissors”, plus the fact that these are probabilities that add up to 1: + +[\begin{matrix} {4p_{s} - 5p_{p}} & {= 0} \ {5p_{r} - 8p_{s}} & {= 0} \ {8p_{p} - 4p_{r}} & {= 0} \ {p_{r} + p_{p} + p_{s}} & {= 1} \ \end{matrix}] + +That’s a system of linear equations that can be solved algorithmically using Gaussian elimination — either by hand or by using any good numerical algorithms software. I won’t go into the details, but here’s the solution: + +[\begin{matrix} p_{r} & {= 0.4706} \ p_{p} & {= 0.2353} \ p_{s} & {= 0.2941} \ \end{matrix}] + +Even though it’s worth the least, an optimal player will play “rock” almost half the time to counterattack “scissors”. The rest of the time is split between “paper” and “scissors”, with a slight bias towards “scissors”. + +#### The powerful way + +The previous solution needed special-case analysis: it exploited the symmetry of the game, and made some guesses about how good/bad the pure strategies are. What about games that are more complex, or maybe not even symmetric (say, because one player has a handicap)? There’s a more general solution using what’s called linear programming (which dates to when “programming” just meant “scheduling” or “planning”). + +By the way, linear programming (LP) has a funny place in computer science. There are some industries and academic circles where LP and generalisations like mixed integer programming are super hot. Then there are computer science textbooks that never even mention them, so there are industries where the whole topic is pretty much unheard of. It might be because it wasn’t even known for a long time if LP problems can be solved in polynomial time (they can), so LP doesn’t have the same theoretical elegance as, say, shortest path finding, even if it has a lot of practical use. + +Anyway, solving weighted RPS with LP is pretty straightforward. We just need to describe the game using a bunch of linear inequalities in multiple variables, and express strategic value as a linear function that can be optimised. That’s very similar to what was done before, but this time we won’t try to guess at the values of any strategies. We’ll just assume we’re choosing values (p_{r}), (p_{p}) and (p_{s}) to play against an opponent who scores an average (v) against us each round. The opponent is smart enough to choose a strategy that’s as least as good as any pure strategy, so we can say + +[\begin{matrix} {4p_{s} - 5p_{p}} & {\leq v} \ {5p_{r} - 8p_{s}} & {\leq v} \ {8p_{p} - 4p_{r}} & {\leq v} \ \end{matrix}] + +The opponent can only play some combination of “rock”, “paper” and “scissors”, so (v) can’t be strictly greater than all of them — at least one of the inequalities above must be tight. To model the gameplay fully, the only other constraints we need are the rules of probability: + +[\begin{matrix} {p_{r} + p_{p} + p_{s}} & {= 1} \ p_{r} & {\geq 0} \ p_{p} & {\geq 0} \ p_{s} & {\geq 0} \ \end{matrix}] + +Now we’ve modelled the problem, we just need to express what needs to be optimised. That’s actually dead simple: we just want to minimise (v), the average score the opponent can win from us. An LP solver can find a set of values for all variables that minimises (v) within the constraints, and we can read off the optimal strategy directly. + +I’ve tried a few tools, and the [Julia][1] library [JuMP][2] has my current favourite FOSS API for throwaway optimisation problems. Here’s some code: + +``` +# You might need Pkg.add("JuMP"); Pkg.add("GLPK") +using JuMP +using GLPK + +game = Model(GLPK.Optimizer) + +@variable(game, 0 <= pr <= 1) +@variable(game, 0 <= pp <= 1) +@variable(game, 0 <= ps <= 1) +@variable(game, v) + +@constraint(game, ptotal, pr + pp + ps == 1) +@constraint(game, rock, 4*ps - 5*pp <= v) +@constraint(game, paper, 5*pr - 8*ps <= v) +@constraint(game, scissors, 8*pp - 4*pr <= v) + +@objective(game, Min, v) + +println(game) +optimize!(game) + +println("Opponent's value: ", value(v)) +println("Rock: ", value(pr)) +println("Paper: ", value(pp)) +println("Scissors: ", value(ps)) +``` + +Here’s the output: + +``` +Min v +Subject to + ptotal : pr + pp + ps = 1.0 + rock : 4 ps - 5 pp - v ≤ 0.0 + paper : 5 pr - 8 ps - v ≤ 0.0 + scissors : 8 pp - 4 pr - v ≤ 0.0 + pr ≥ 0.0 + pp ≥ 0.0 + ps ≥ 0.0 + pr ≤ 1.0 + pp ≤ 1.0 + ps ≤ 1.0 + +Opponent's value: 0.0 +Rock: 0.47058823529411764 +Paper: 0.23529411764705882 +Scissors: 0.29411764705882354 +``` + +As argued in the previous solution, the best value the opponent can get against the optimal player is 0. + +### What does optimality mean? + +The optimal solution was calculated assuming an all-powerful opponent. It guarantees that even the best weighted RPS player can’t get an advantage over you, but it turns out you can’t get an advantage over a terrible player, either, if you insist on playing this “optimal” strategy. That’s because weighted RPS has no bad plays, in the sense that “bomb” is bad. _Any_ strategy played against the above “optimal” strategy will have expected value of 0, so it’s really a defensive, or “safe” strategy. To play truly optimally and win against a bad player, you’ll have to adapt your strategy. For example, if your opponent plays “scissors” too often and “paper” not enough, you should adapt by playing “rock” more often. Of course, your opponent might just be pretending to be weak, and could start taking advantage of your deviation from the safe strategy. + +Games don’t always work out like that. For example, in theory, you could derive an optimal safe strategy for more complex games like poker. Such a strategy would tend to win against normal humans because even the best normal humans make bad poker plays. On the other hand, a “shark” at the table might be able to win against the “fish” faster by exploiting their weaknesses more aggressively. If you’re thinking of using LP to directly calculate a strategy for Texas Hold’em, though, sorry, but you’ll hit a combinatorial explosion of pure strategies as you account for all the cases like “if I’m dealt AJ on the big blind and I call a four-blind raise from the button preflop and then the flop is a rainbow 3K9…”. Only heavily simplified toy poker games are solvable with the general approach. + +-------------------------------------------------------------------------------- + +via: https://theartofmachinery.com/2020/05/21/glico_weighted_rock_paper_scissors.html + +作者:[Simon Arneaud][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://theartofmachinery.com +[b]: https://github.com/lujun9972 +[1]: https://julialang.org/ +[2]: https://github.com/JuliaOpt/JuMP.jl diff --git a/sources/tech/20200521 Use the internet from the command line with curl.md b/sources/tech/20200521 Use the internet from the command line with curl.md new file mode 100644 index 0000000000..c580ea0879 --- /dev/null +++ b/sources/tech/20200521 Use the internet from the command line with curl.md @@ -0,0 +1,186 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Use the internet from the command line with curl) +[#]: via: (https://opensource.com/article/20/5/curl-cheat-sheet) +[#]: author: (Seth Kenlon https://opensource.com/users/seth) + +Use the internet from the command line with curl +====== +Download our new curl cheat sheet. Curl is a fast and efficient way to +pull the information you need from the internet without using a +graphical interface. +![Cheat Sheet cover image][1] + +Curl is commonly considered a non-interactive web browser. That means it's able to pull information from the internet and display it in your terminal or save it to a file. This is literally what web browsers, such as Firefox or Chromium, do except they _render_ the information by default, while curl downloads and displays raw information. In reality, the curl command does much more and has the ability to transfer data to or from a server using one of many supported protocols, including HTTP, FTP, SFTP, IMAP, POP3, LDAP, SMB, SMTP, and many more. It's a useful tool for the average terminal user, a vital convenience for the sysadmin, and a quality assurance tool for microservices and cloud developers. + +Curl is designed to work without user interaction, so unlike Firefox, you must think about your interaction with online data from start to finish. For instance, if you want to view a web page in Firefox, you launch a Firefox window. After Firefox is open, you type the website you want to visit into the URL field or a search engine. Then you navigate to the site and click on the page you want to see. + +The same concepts apply to curl, except you do it all at once: you launch curl at the same time you feed it the internet location you want and tell it whether you want to the data to be saved in your terminal or to a file. The complexity increases when you have to interact with a site that requires authentication or with an API, but once you learn the **curl** command syntax, it becomes second nature. To help you get the hang of it, we collected the pertinent syntax information in a handy [cheat sheet][2]. + +### Download a file with curl + +You can download a file with the **curl** command by providing a link to a specific URL. If you provide a URL that defaults to **index.html**, then the index page is downloaded, and the file you downloaded is displayed on your terminal screen. You can pipe the output to less or tail or any other command: + + +``` +$ curl "" | tail -n 4 +    <h1>Example Domain</h1> +    <p>This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.</p> +    <p><a href="[https://www.iana.org/domains/example"\>More][3] information...</a></p> +</div></body></html> +``` + +Because some URLs contain special characters that your shell normally interprets, it's safest to surround your URL in quotation marks. + +Some files don't translate well to being displayed in a terminal. You can use the **\--remote-name** option to cause the file to be saved according to what it's called on the server: + + +``` +$ curl --remote-name "" +$ ls +linux-distro.iso +``` + +Alternatively, you can use the **\--output** option to name your download whatever you want: + + +``` +`curl "http://example.com/foo.html" --output bar.html` +``` + +### List contents of a remote directory with curl + +Because curl is non-interactive, it's difficult to browse a page for downloadable elements. Provided that the remote server you're connecting to allows it, you can use **curl** to list the contents of a directory: + + +``` +`$ curl --list-only "https://example.com/foo/"` +``` + +### Continue a partial download + +If you're downloading a very large file, you might find that you have to interrupt the download. Curl is intelligent enough to determine where you left off and continue the download. That means the next time you're downloading a 4GB Linux distribution ISO and something goes wrong, you never have to go back to the start. The syntax for **\--continue-at** is a little unusual: if you know the byte count where your download was interrupted, you can provide it; otherwise, you can use a lone dash (**-**) to tell curl to detect it automatically: + + +``` +`$ curl --remote-name --continue-at - "https://example.com/linux-distro.iso"` +``` + +### Download a sequence of files + +If you need to download several files—rather than just one big file—curl can help with that. Assuming you know the location and file-name pattern of the files you want to download, you can use curl's sequencing notation: the start and end point between a range of integers, in brackets. For the output filename, use **#1** to indicate the first variable: + + +``` +`$ curl "https://example.com/file_[1-4].webp" --output "file_#1.webp"` +``` + +If you need to use another variable to represent another sequence, denote each variable in the order it appears in the command. For example, in this command, **#1** refers to the directories **images_000** through **images_009**, while **#2** refers to the files **file_1.webp** through **file_4.webp**: + + +``` +$ curl "" \ +\--output "file_#1-#2.webp" +``` + +### Download all PNG files from a site + +You can do some rudimentary web scraping to find what you want to download, too, using only **curl** and **grep**. For instance, say you need to download all images associated with a web page you're archiving. First, download the page referencing the images. Pipe the page to grep with a search for the image type you're targeting (PNG in this example). Finally, create a **while** loop to construct a download URL and to save the files to your computer: + + +``` +$ curl |\ +grep --only-matching 'src="[^"]*.[png]"' |\ +cut -d\" -f2 |\ +while read i; do \ +curl " -o "${i##*/}"; \ +done +``` + +This is just an example, but it demonstrates how flexible curl can be when combined with a Unix pipe and some clever, but basic, parsing. + +### Fetch HTML headers + +Protocols used for data exchange have a lot of metadata embedded in the packets that computers send to communicate. HTTP headers are components of the initial portion of data. It can be helpful to view these headers (especially the response code) when troubleshooting your connection to a site: + + +``` +curl --head "" +HTTP/2 200 +accept-ranges: bytes +age: 485487 +cache-control: max-age=604800 +content-type: text/html; charset=UTF-8 +date: Sun, 26 Apr 2020 09:02:09 GMT +etag: "3147526947" +expires: Sun, 03 May 2020 09:02:09 GMT +last-modified: Thu, 17 Oct 2019 07:18:26 GMT +server: ECS (sjc/4E76) +x-cache: HIT +content-length: 1256 +``` + +### Fail quickly + +A 200 response is the usual HTTP indicator of success, so it's what you usually expect when you contact a server. The famous 404 response indicates that a page can't be found, and 500 means there was a server error. + +To see what errors are happening during negotiation, add the **\--show-error** flag: + + +``` +`$ curl --head --show-error "http://opensource.ga"` +``` + +These can be difficult for you to fix unless you have access to the server you're contacting, but curl generally tries its best to resolve the location you point it to. Sometimes when testing things over a network, seemingly endless retries just waste time, so you can force curl to exit upon failure quickly with the **\--fail-early** option: + + +``` +`curl --fail-early "http://opensource.ga"` +``` + +### Redirect query as specified by a 3xx response + +The 300 series of responses, however, are more flexible. Specifically, the 301 response means that a URL has been moved permanently to a different location. It's a common way for a website admin to relocate content while leaving a "trail" so people visiting the old location can still find it. Curl doesn't follow a 301 redirect by default, but you can make it continue on to a 301 destination by using the **\--location** option: + + +``` +$ curl "" | grep title +<title>301 Moved Permanently</title> +$ curl --location "" +<title>Internet Assigned Numbers Authority</title> +``` + +### Expand a shortened URL + +The **\--location** option is useful when you want to look at shortened URLs before visiting them. Shortened URLs can be useful for social networks with character limits (of course, this may not be an issue if you use a [modern and open source social network][4]) or for print media in which users can't just copy and paste a long URL. However, they can also be a little dangerous because their destination is, by nature, concealed. By combining the **\--head** option to view just the HTTP headers and the **\--location** option to unravel the final destination of a URL, you can peek into a shortened URL without loading the full resource: + + +``` +$ curl --head --location \ +"" +``` + +### [Download our curl cheat sheet][2] + +Once you practice thinking about the process of exploring the web as a single command, curl becomes a fast and efficient way to pull the information you need from the internet without bothering with a graphical interface. To help you build it into your usual workflow, we've created a [curl cheat sheet][2] with common curl uses and syntax, including an overview of using it to query an API. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/curl-cheat-sheet + +作者:[Seth Kenlon][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/seth +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coverimage_cheat_sheet.png?itok=lYkNKieP (Cheat Sheet cover image) +[2]: https://opensource.com/downloads/curl-command-cheat-sheet +[3]: https://www.iana.org/domains/example"\>More +[4]: https://opensource.com/article/17/4/guide-to-mastodon diff --git a/sources/tech/20200522 A beginner-s guide to web scraping with Python.md b/sources/tech/20200522 A beginner-s guide to web scraping with Python.md new file mode 100644 index 0000000000..010744161b --- /dev/null +++ b/sources/tech/20200522 A beginner-s guide to web scraping with Python.md @@ -0,0 +1,493 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A beginner's guide to web scraping with Python) +[#]: via: (https://opensource.com/article/20/5/web-scraping-python) +[#]: author: (Julia Piaskowski https://opensource.com/users/julia-piaskowski) + +A beginner's guide to web scraping with Python +====== +Get some hands-on experience with essential Python tools to scrape +complete HTML sites. +![HTML code][1] + +There are plenty of great books to help you learn Python, but who actually reads these A to Z? (Spoiler: not me). + +Many people find instructional books useful, but I do not typically learn by reading a book front to back. I learn by doing a project, struggling, figuring some things out, and then reading another book. So, throw away your book (for now), and let's learn some Python. + +What follows is a guide to my first scraping project in Python. It is very low on assumed knowledge in Python and HTML. This is intended to illustrate how to access web page content with Python library [requests][2] and parse the content using [BeatifulSoup4][3], as well as JSON and [pandas][4]. I will briefly introduce [Selenium][5], but I will not delve deeply into how to use that library—that topic deserves its own tutorial. Ultimately I hope to show you some tricks and tips to make web scraping less overwhelming. + +### Installing our dependencies + +All the resources from this guide are available at my [GitHub repo][6]. If you need help installing Python 3, check out the tutorials for [Linux][7], [Windows][8], and [Mac][9]. + + +``` +$ python3 -m venv +$ source venv/bin/activate +$ pip install requests bs4 pandas +``` + +If you like using JupyterLab, you can run all the code using this [notebook][10]. There are a lot of ways to [install JupyterLab][11], and this is one of them: + + +``` +# from the same virtual environment as above, run: +$ pip install jupyterlab +``` + +### Setting a goal for our web scraping project + +Now we have our dependencies installed, but what does it take to scrape a webpage?  + +Let's take a step back and be sure to clarify our goal. Here is my list of requirements for a successful web scraping project. + + * We are gathering information that is worth the effort it takes to build a working web scraper. + * We are downloading information that can be legally and ethically gathered by a web scraper. + * We have some knowledge of how to find the target information in HTML code. + * We have the right tools: in this case, it's the libraries **BeautifulSoup** and **requests**. + * We know (or are willing to learn) how to parse JSON objects. + * We have enough data skills to use **pandas**. + + + +A comment on HTML: While HTML is the beast that runs the Internet, what we mostly need to understand is how tags work. A tag is a collection of information sandwiched between angle-bracket enclosed labels. For example, here is a pretend tag, called "pro-tip": + + +``` +<pro-tip> All you need to know about html is how tags work </pro-tip> +``` + +We can access the information in there ("All you need to know…") by calling its tag "pro-tip." How to find and access a tag will be addressed further in this tutorial. For more of a look at HTML basics, check out [this article][12]. + +### What to look for in a web scraping project + +Some goals for gathering data are more suited for web scraping than others. My guidelines for what qualifies as a good project are as follows. + +There is no public API available for the data. It would be much easier to capture structured data through an API, and it would help clarify both the legality and ethics of gathering the data. There needs to be a sizable amount of structured data with a regular, repeatable format to justify this effort. Web scraping can be a pain. BeautifulSoup (bs4) makes this easier, but there is no avoiding the individual idiosyncrasies of websites that will require customization. Identical formatting of the data is not required, but it does make things easier. The more "edge cases" (departures from the norm) present, the more complicated the scraping will be. + +Disclaimer: I have zero legal training; the following is not intended to be formal legal advice. + +On the note of legality, accessing vast troves of information can be intoxicating, but just because it's possible doesn't mean it should be done. + +There is, thankfully, public information that can guide our morals and our web scrapers. Most websites have a [robots.txt][13] file associated with the site, indicating which scraping activities are permitted and which are not. It's largely there for interacting with search engines (the ultimate web scrapers). However, much of the information on websites is considered public information. As such, some consider the robots.txt file as a set of recommendations rather than a legally binding document. The robots.txt file does not address topics such as ethical gathering and usage of the data. + +Questions I ask myself before beginning a scraping project: + + * Am I scraping copyrighted material? + * Will my scraping activity compromise individual privacy? + * Am I making a large number of requests that may overload or damage a server? + * Is it possible the scraping will expose intellectual property I do not own? + * Are there terms of service governing use of the website, and am I following those? + * Will my scraping activities diminish the value of the original data? (for example, do I plan to repackage the data as-is and perhaps siphon off website traffic from the original source)? + + + +When I scrape a site, I make sure I can answer "no" to all of those questions. + +For a deeper look at the legal concerns, see the 2018 publications [Legality and Ethics of Web Scraping by Krotov and Silva][14] and [Twenty Years of Web Scraping and the Computer Fraud and Abuse Act by Sellars][15]. + +### Now it's time to scrape! + +After assessing the above, I came up with a project. My goal was to extract addresses for all Family Dollar stores in Idaho. These stores have an outsized presence in rural areas, so I wanted to understand how many there are in a rather rural state. + +The starting point is the [location page for Family Dollar][16]. + +![Family Dollar Idaho locations page][17] + +To begin, let's load up our prerequisites in our Python virtual environment. The code from here is meant to be added to a Python file (_scraper.py_ if you're looking for a name) or be run in a cell in JupyterLab. + + +``` +import requests # for making standard html requests +from bs4 import BeautifulSoup # magical tool for parsing html data +import json # for parsing data +from pandas import DataFrame as df # premier library for data organization +``` + +Next, we request data from our target URL. + + +``` +page = requests.get("") +soup = BeautifulSoup(page.text, 'html.parser') +``` + +BeautifulSoup will take HTML or XML content and transform it into a complex tree of objects. Here are several common object types that we will use. + + * **BeautifulSoup**—the parsed content + * **Tag**—a standard HTML tag, the main type of bs4 element you will encounter + * **NavigableString**—a string of text within a tag + * **Comment**—a special type of NavigableString + + + +There is more to consider when we look at **requests.get()** output. I've only used **page.text()** to translate the requested page into something readable, but there are other output types: + + * **page.text()** for text (most common) + * **page.content()** for byte-by-byte output + * **page.json()** for JSON objects + * **page.raw()** for the raw socket response (no thank you) + + + +I have only worked on English-only sites using the Latin alphabet. The default encoding settings in **requests** have worked fine for that. However, there is a rich internet world beyond English-only sites. To ensure that **requests** correctly parses the content, you can set the encoding for the text: + + +``` +page = requests.get(URL) +page.encoding = 'ISO-885901' +soup = BeautifulSoup(page.text, 'html.parser') +``` + +Taking a closer look at BeautifulSoup tags, we see: + + * The bs4 element **tag** is capturing an HTML tag + * It has both a name and attributes that can be accessed like a dictionary: **tag['someAttribute']** + * If a tag has multiple attributes with the same name, only the first instance is accessed. + * A tag's children are accessed via **tag.contents**. + * All tag descendants can be accessed with **tag.contents**. + * You can always access the full contents as a string with: **re.compile("your_string")** instead of navigating the HTML tree. + + + +### Determine how to extract relevant content + +Warning: this process can be frustrating. + +Extraction during web scraping can be a daunting process filled with missteps. I think the best way to approach this is to start with one representative example and then scale up (this principle is true for any programming task). Viewing the page's HTML source code is essential. There are a number of ways to do this. + +You can view the entire source code of a page using Python in your terminal (not recommended). Run this code at your own risk: + + +``` +print(soup.prettify()) +``` + +While printing out the entire source code for a page might work for a toy example shown in some tutorials, most modern websites have a massive amount of content on any one of their pages. Even the 404 page is likely to be filled with code for headers, footers, and so on. + +It is usually easiest to browse the source code via **View Page Source** in your favorite browser (right-click, then select "view page source"). That is the most reliable way to find your target content (I will explain why in a moment). + +![Family Dollar page source code][18] + +  + +In this instance, I need to find my target content—an address, city, state, and zip code—in this vast HTML ocean. Often, a simple search of the page source (**ctrl + F**) will yield the section where my target location is located. Once I can actually see an example of my target content (the address for at least one store), I look for an attribute or tag that sets this content apart from the rest. + +It would appear that first, I need to collect web addresses for different cities in Idaho with Family Dollar stores and visit those websites to get the address information. These web addresses all appear to be enclosed in a **href** tag. Great! I will try searching for that using the **find_all** command: + + +``` +dollar_tree_list = soup.find_all('href') +dollar_tree_list +``` + +Searching for **href** did not yield anything, darn. This might have failed because **href** is nested inside the class **itemlist**. For the next attempt, search on **item_list**. Because "class" is a reserved word in Python, **class_** is used instead. The bs4 function **soup.find_all()** turned out to be the Swiss army knife of bs4 functions. + + +``` +dollar_tree_list = soup.find_all(class_ = 'itemlist') +for i in dollar_tree_list[:2]: +  print(i) +``` + +Anecdotally, I found that searching for a specific class was often a successful approach. We can learn more about the object by finding out its type and length. + + +``` +type(dollar_tree_list) +len(dollar_tree_list) +``` + +The content from this BeautifulSoup "ResultSet" can be extracted using **.contents**. This is also a good time to create a single representative example. + + +``` +example = dollar_tree_list[2] # a representative example +example_content = example.contents +print(example_content) +``` + +Use **.attr** to find what attributes are present in the contents of this object. Note: **.contents** usually returns a list of exactly one item, so the first step is to index that item using the bracket notation. + + +``` +example_content = example.contents[0] +example_content.attrs +``` + +Now that I can see that **href** is an attribute, that can be extracted like a dictionary item: + + +``` +example_href = example_content['href'] +print(example_href) +``` + +### Putting together our web scraper + +All that exploration has given us a path forward. Here's the cleaned-up version of the logic we figured out above. + + +``` +city_hrefs = [] # initialise empty list + +for i in dollar_tree_list: +    cont = i.contents[0] +    href = cont['href'] +    city_hrefs.append(href) + +#  check to be sure all went well +for i in city_hrefs[:2]: +  print(i) +``` + +The output is a list of URLs of Family Dollar stores in Idaho to scrape. + +That said, I still don't have address information! Now, each city URL needs to be scraped to get this information. So we restart the process, using a single, representative example. + + +``` +page2 = requests.get(city_hrefs[2]) # again establish a representative example +soup2 = BeautifulSoup(page2.text, 'html.parser') +``` + +![Family Dollar map and code][19] + +The address information is nested within **type= "application/ld+json"**. After doing a lot of geolocation scraping, I've come to recognize this as a common structure for storing address information. Fortunately, **soup.find_all()** also enables searching on **type**. + + +``` +arco = soup2.find_all(type="application/ld+json") +print(arco[1]) +``` + +The address information is in the second list member! Finally! + +I extracted the contents (from the second list item) using **.contents** (this is a good default action after filtering the soup). Again, since the output of contents is a list of one, I indexed that list item: + + +``` +arco_contents = arco[1].contents[0] +arco_contents +``` + +Wow, looking good. The format presented here is consistent with the JSON format (also, the type did have "**json**" in its name). A JSON object can act like a dictionary with nested dictionaries inside. It's actually a nice format to work with once you become familiar with it (and it's certainly much easier to program than a long series of RegEx commands). Although this structurally looks like a JSON object, it is still a bs4 object and needs a formal programmatic conversion to JSON to be accessed as a JSON object: + + +``` +arco_json =  json.loads(arco_contents) + +[/code] [code] + +type(arco_json) +print(arco_json) +``` + +In that content is a key called **address** that has the desired address information in the smaller nested dictionary. This can be retrieved thusly: + + +``` +arco_address = arco_json['address'] +arco_address +``` + +Okay, we're serious this time. Now I can iterate over the list store URLs in Idaho: + + +``` +locs_dict = [] # initialise empty list + +for link in city_hrefs: +  locpage = requests.get(link)   # request page info +  locsoup = BeautifulSoup(locpage.text, 'html.parser') +      # parse the page's content +  locinfo = locsoup.find_all(type="application/ld+json") +      # extract specific element +  loccont = locinfo[1].contents[0]   +      # get contents from the bs4 element set +  locjson = json.loads(loccont)  # convert to json +  locaddr = locjson['address'] # get address +  locs_dict.append(locaddr) # add address to list +``` + +### Cleaning our web scraping results with pandas + +We have loads of data in a dictionary, but we have some additional crud that will make reusing our data more complex than it needs to be. To do some final data organization steps, we convert to a pandas data frame, drop the unneeded columns "**@type**" and "**country**"), and check the top five rows to ensure that everything looks alright. + + +``` +locs_df = df.from_records(locs_dict) +locs_df.drop(['@type', 'addressCountry'], axis = 1, inplace = True) +locs_df.head(n = 5) +``` + +Make sure to save results!! + + +``` +df.to_csv(locs_df, "family_dollar_ID_locations.csv", sep = ",", index = False) +``` + +We did it! There is a comma-separated list of all the Idaho Family Dollar stores. What a wild ride. + +### A few words on Selenium and data scraping + +[Selenium][5] is a common utility for automatic interaction with a webpage. To explain why it's essential to use at times, let's go through an example using Walgreens' website. **Inspect Element** provides the code for what is displayed in a browser: + +![Walgreens location page and code][20] + +  + +While **View Page Source** provides the code for what **requests** will obtain: + +![Walgreens source code][21] + +When these two don't agree, there are plugins modifying the source code—so, it should be accessed after the page has loaded in a browser. **requests** cannot do that, but **Selenium** can. + +Selenium requires a web driver to retrieve the content. It actually opens a web browser, and this page content is collected. Selenium is powerful—it can interact with loaded content in many ways (read the documentation). After getting data with **Selenium**, continue to use **BeautifulSoup** as before: + + +``` +url = "[https://www.walgreens.com/storelistings/storesbycity.jsp?requestType=locator\&state=ID][22]" +driver = webdriver.Firefox(executable_path = 'mypath/geckodriver.exe') +driver.get(url) +soup_ID = BeautifulSoup(driver.page_source, 'html.parser') +store_link_soup = soup_ID.find_all(class_ = 'col-xl-4 col-lg-4 col-md-4') +``` + +I didn't need Selenium in the case of Family Dollar, but I do keep it on hand for those times when rendered content differs from source code. + +### Wrapping up + +In conclusion, when using web scraping to accomplish a meaningful task: + + * Be patient + * Consult the manuals (these are very helpful) + + + +If you are curious about the answer: + +![Family Dollar locations map][23] + +There are many many Family Dollar stores in America. + +The complete source code is: + + +``` +import requests +from bs4 import BeautifulSoup +import json +from pandas import DataFrame as df + +page = requests.get("") +soup = BeautifulSoup(page.text, 'html.parser') + +# find all state links +state_list = soup.find_all(class_ = 'itemlist') + +state_links = [] + +for i in state_list: +    cont = i.contents[0] +    attr = cont.attrs +    hrefs = attr['href'] +    state_links.append(hrefs) + +# find all city links +city_links = [] + +for link in state_links: +    page = requests.get(link) +    soup = BeautifulSoup(page.text, 'html.parser') +    familydollar_list = soup.find_all(class_ = 'itemlist') +    for store in familydollar_list: +        cont = store.contents[0] +        attr = cont.attrs +        city_hrefs = attr['href'] +        city_links.append(city_hrefs) +# to get individual store links +store_links = [] + +for link in city_links: +    locpage = requests.get(link) +    locsoup = BeautifulSoup(locpage.text, 'html.parser') +    locinfo = locsoup.find_all(type="application/ld+json") +    for i in locinfo: +        loccont = i.contents[0] +        locjson = json.loads(loccont) +        try: +            store_url = locjson['url'] +            store_links.append(store_url) +        except: +            pass + +# get address and geolocation information +stores = [] + +for store in store_links: +    storepage = requests.get(store) +    storesoup = BeautifulSoup(storepage.text, 'html.parser') +    storeinfo = storesoup.find_all(type="application/ld+json") +    for i in storeinfo: +        storecont = i.contents[0] +        storejson = json.loads(storecont) +        try: +            store_addr = storejson['address'] +            store_addr.update(storejson['geo']) +            stores.append(store_addr) +        except: +            pass + +# final data parsing +stores_df = df.from_records(stores) +stores_df.drop(['@type', 'addressCountry'], axis = 1, inplace = True) +stores_df['Store'] = "Family Dollar" + +df.to_csv(stores_df, "family_dollar_locations.csv", sep = ",", index = False) +``` + +\-- +_Author's note: This article is an adaptation of a [talk I gave at PyCascades][24] in Portland, Oregon on February 9, 2020._ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/web-scraping-python + +作者:[Julia Piaskowski][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/julia-piaskowski +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_html_code.png?itok=VjUmGsnl (HTML code) +[2]: https://requests.readthedocs.io/en/master/ +[3]: https://beautiful-soup-4.readthedocs.io/en/latest/ +[4]: https://pandas.pydata.org/ +[5]: https://www.selenium.dev/ +[6]: https://github.com/jpiaskowski/pycas2020_web_scraping +[7]: https://opensource.com/article/20/4/install-python-linux +[8]: https://opensource.com/article/19/8/how-install-python-windows +[9]: https://opensource.com/article/19/5/python-3-default-mac +[10]: https://github.com/jpiaskowski/pycas2020_web_scraping/blob/master/example/Familydollar_location_scrape-all-states.ipynb +[11]: https://jupyterlab.readthedocs.io/en/stable/getting_started/installation.html +[12]: https://opensource.com/article/20/4/build-websites +[13]: https://www.contentkingapp.com/academy/robotstxt/ +[14]: https://www.researchgate.net/publication/324907302_Legality_and_Ethics_of_Web_Scraping +[15]: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3221625 +[16]: https://locations.familydollar.com/id/ +[17]: https://opensource.com/sites/default/files/uploads/familydollar1.png (Family Dollar Idaho locations page) +[18]: https://opensource.com/sites/default/files/uploads/familydollar2.png (Family Dollar page source code) +[19]: https://opensource.com/sites/default/files/uploads/familydollar3.png (Family Dollar map and code) +[20]: https://opensource.com/sites/default/files/uploads/walgreens1.png (Walgreens location page and code) +[21]: https://opensource.com/sites/default/files/uploads/walgreens2.png (Walgreens source code) +[22]: https://www.walgreens.com/storelistings/storesbycity.jsp?requestType=locator\&state=ID +[23]: https://opensource.com/sites/default/files/uploads/family_dollar_locations.png (Family Dollar locations map) +[24]: https://2020.pycascades.com/talks/adventures-in-babysitting-webscraping-for-python-and-html-novices/ diff --git a/sources/tech/20200522 Fast data modeling with JavaScript.md b/sources/tech/20200522 Fast data modeling with JavaScript.md new file mode 100644 index 0000000000..9c565d6e90 --- /dev/null +++ b/sources/tech/20200522 Fast data modeling with JavaScript.md @@ -0,0 +1,452 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Fast data modeling with JavaScript) +[#]: via: (https://opensource.com/article/20/5/data-modeling-javascript) +[#]: author: (Szymon https://opensource.com/users/schodevio) + +Fast data modeling with JavaScript +====== +This tutorial showcases a method to model data in just a few minutes. +![Analytics: Charts and Graphs][1] + +As a backend developer at the [Railwaymen][2], a software house in Kraków, Poland, some of my tasks rely on models that manipulate and customize data retrieved from a database. When I wanted to improve my skills in frontend frameworks, I [chose Vue][3], and I thought it would be good to have a similar way to model data in a store. I started with some libraries that I found through [NPM][4], but they offered many more features than I needed. + +So I decided to build my own solution, and I was very surprised that the base took less than 15 lines of code and is very flexible. I implemented this solution in an open source application which I developed and called [Evally][5] - a web app that helps businesses keep track of their employees' performance reviews and professional development. It reminds managers or HR representatives about employees' upcoming evaluations and gathers all of the data needed to assess their performance in the fairest way. + +### Model and list + +The only things you need to do are to create a class and use the defaultsDeep function in the [Lodash][6] JavaScript library: + + +``` +`_.defaultsDeep(object, [sources])` +``` + +Arguments: + + * `object (Object)`: The destination object + * `[sources] (...Object)`: The source objects + + + +Returns: + + * `(Object)`: Returns object + + + +This helper function: [Lodash Docs][7] + +> "Assigns recursively own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined. Source objects are applied from left to right. Once a property is set, additional values of the same property are ignored." + +For example: + + +``` +_.defaultsDeep({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }) + // => { 'a': { 'b': 2, 'c': 3 } } +``` + +That's all! To try it out, create a file called **base.js** and import the defaultsDeep function from the Lodash package: + + +``` + // base.js + import defaultsDeep from "lodash/defaultsDeep"; +``` + +Next, create and export the Model class, where constructor will use the Lodash helper function to assign values to all passed attributes and initialize the attributes that were not received with default values: + + +``` + // base.js + // ... + + export class Model { +   constructor(attributes = {}) { +     defaultsDeep(this, attributes, this.defaults); +   } + } +``` + +Now, create your first real model, Employee, with attributes for firstName, lastName, position and hiredAt where "position" defines "Programmer" as the default value: + + +``` + // employee.js + import { Model } from "./base.js"; + + export class Employee extends Model { +   get defaults() { +     return { +       firstName: "", +       lastName: "", +       position: "Programmer", +       hiredAt: "" +     }; +   } + } +``` + +Next, begin creating employees: + + +``` +// app.js + import { Employee } from "./employee.js"; + + const programmer = new Employee({ +   firstName: "Will", +   lastName: "Smith" + }); + + // => Employee { + //   firstName: "Will", + //   lastName: "Smith", + //   position: "Programmer", + //   hiredAt: "", + //   constructor: Object + // } + + const techLeader = new Employee({ +   firstName: "Charles", +   lastName: "Bartowski", +   position: "Tech Leader" + }); + + // => Employee { + //   firstName: "Charles", + //   lastName: "Bartowski", + //   position: "Tech Leader", + //   hiredAt: "", + //   constructor: Object + // } +``` + +You have two employees, and the first one's position is assigned from the defaults. Here's how multiple employees can be defined: + + +``` + // base.js + + // ... + + export class List { +   constructor(items = []) { +     this.models = items.map(item => new this.model(item)); +   } + } + +[/code] [code] + + // employee.js + import { Model, List } from "./base.js"; + + // … + + export class EmployeesList extends List { +   get model() { +     return Employee; +   } + } +``` + +The List class constructor maps an array of received items into an array of desired models. The only requirement is to provide a correct model class name: + + +``` + // app.js + import { Employee, EmployeesList } from "./employee.js"; + + // … + + const employees = new EmployeesList([ +   { +     firstName: "Will", +     lastName: "Smith" +   }, +   { +     firstName: "Charles", +     lastName: "Bartowski", +     position: "Tech Leader" +   } + ]); + + // => EmployeesList {models: Array[2], constructor: Object} + //  models: Array[2] + //   0: Employee + //     firstName: "Will" + //     lastName: "Smith" + //     position: "Programmer" + //     hiredAt: "" + //     <constructor>: "Employee" + //   1: Employee + //     firstName: "Charles" + //     lastName: "Bartowski" + //     position: "Tech Leader" + //     hiredAt: "" + //     <constructor>: "Employee" + //   <constructor>: "EmployeesList" +``` + +### Ways to use this approach + +This simple solution allows you to keep your data structure in one place and avoid code repetition. The [DRY][8] principle rocks! You can also customize your models as needed, such as in the following examples. + +#### Custom getters + +Do you need one attribute to be dependent on the others? No problem; you can do this by improving your Employee model: + + +``` +// employee.js + import { Model } from "./base.js"; + + export class Employee extends Model { +   get defaults() { +     return { +       firstName: "", +       lastName: "", +       position: "Programmer", +       hiredAt: "" +     }; +   } + +   get fullName() { +     return [this.firstName, this.lastName].join(' ') +   } + + } + +[/code] [code] + +// app.js + import { Employee, EmployeesList } from "./employee.js"; + + // … + + console.log(techLeader.fullName); + // => Charles Bartowski +``` + +Now you don't have to repeat the code to do something as simple as displaying the employee's full name. + +#### Date formatting + +Model is a good place to define other formats for given attributes. The best examples are dates: + + +``` +// employee.js + import { Model } from "./base.js"; + import moment from 'moment'; + + export class Employee extends Model { +   get defaults() { +     return { +       firstName: "", +       lastName: "", +       position: "Programmer", +       hiredAt: "" +     }; +   } + +   get formattedHiredDate() { +     if (!this.hiredAt) return "---"; + +     return moment(this.hiredAt).format('MMMM DD, YYYY'); +   } + } + +[/code] [code] + +// app.js + import { Employee, EmployeesList } from "./employee.js"; + + // … + + techLeader.hiredAt = "2020-05-01"; + + console.log(techLeader.formattedHiredDate); + // => May 01, 2020 +``` + +Another case related to dates (which I discovered developing the Evally app) is the ability to operate with different date formats. Here's an example that uses datepicker: + + 1. All employees fetched from the database have the hiredAt date in the format: +YEAR-MONTH-DAY, e.g., 2020-05-01 + 2. You need to display the hiredAt date in a more friendly format: +MONTH DAY, YEAR, e.g., May 01, 2020 + 3. A datepicker uses the format: +DAY-MONTH-YEAR, e.g., 01-05-2020 + + + +Resolve this issue with: + + +``` +// employee.js + import { Model } from "./base.js"; + import moment from 'moment'; + + export class Employee extends Model { + +   // … + +   get formattedHiredDate() { +     if (!this.hiredAt) return "---"; + +     return moment(this.hiredAt).format('MMMM DD, YYYY'); +   } + +   get hiredDate() { +     return ( +       this.hiredAt +         ? moment(this.hiredAt).format('DD-MM-YYYY') +         : '' +     ); +   } + +   set hiredDate(date) { +     const mDate = moment(date, 'DD-MM-YYYY'); +  +     this.hiredAt = ( +       mDate.isValid() +         ? mDate.format('YYYY-MM-DD') +         : '' +     ); +   } + } +``` + +This adds getter and setter functions to handle datepicker's functionality. + + +``` + // Get date from server + techLeader.hiredAt = '2020-05-01'; + console.log(techLeader.formattedHiredDate); + // => May 01, 2020 + + // Datepicker gets date + console.log(techLeader.hiredDate); + // => 01-05-2020 + + // Datepicker sets new date + techLeader.hiredDate = '15-06-2020'; + + // Display new date + console.log(techLeader.formattedHiredDate); + // => June 15, 2020 +``` + +This makes it very simple to manage multiple date formats. + +#### Storage for model-related information + +Another use for a model class is storing general information related to the model, like paths for routing: + + +``` +// employee.js + import { Model } from "./base.js"; + import moment from 'moment'; + + export class Employee extends Model { + +   // … + +   static get routes() { +     return { +       employeesPath: '/api/v1/employees', +       employeePath: id => `/api/v1/employees/${id}` +     } +   } + + } + +[/code] [code] + + // Path for POST requests + console.log(Employee.routes.employeesPath) + + // Path for GET request + console.log(Employee.routes.employeePath(1)) +``` + +### Customize the list of models + +Don't forget about the List class, which you can customize as needed: + + +``` +// employee.js + import { Model, List } from "./base.js"; + + // … + + export class EmployeesList extends List { +   get model() { +     return Employee; +   } + +   findByFirstName(val) { +     return this.models.find(item => item.firstName === val); +   } + +   filterByPosition(val) { +     return this.models.filter(item => item.position === val); +   } + } + +[/code] [code] + + console.log(employees.findByFirstName('Will')) + // => Employee { + //   firstName: "Will", + //   lastName: "Smith", + //   position: "Programmer", + //   hiredAt: "", + //   constructor: Object + // } + + console.log(employees.filterByPosition('Tech Leader')) + // => [Employee] + //     0: Employee + //       firstName: "Charles" + //       lastName: "Bartowski" + //       position: "Tech Leader" + //       hiredAt: "" + //       <constructor>: "Employee" +``` + +### Summary + +This simple structure for data modeling in JavaScript should save you some development time. You can add new functions whenever you need them to keep your code cleaner and easier to maintain. All of this code is available in my [CodeSandbox][9], so try it out and let me know how it goes by leaving a comment below. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/data-modeling-javascript + +作者:[Szymon][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/schodevio +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/analytics-graphs-charts.png?itok=sersoqbV (Analytics: Charts and Graphs) +[2]: https://railwaymen.org/ +[3]: https://blog.railwaymen.org/vue-vs-react-which-one-is-better-for-your-app-similarities-differences +[4]: https://www.npmjs.com/ +[5]: https://github.com/railwaymen/evally +[6]: https://lodash.com/ +[7]: https://lodash.com/docs/4.17.15 +[8]: https://en.wikipedia.org/wiki/Don%27t_repeat_yourself +[9]: https://codesandbox.io/s/02jsdatamodels-1mhtb diff --git a/sources/tech/20200524 Diamond interface composition in Go 1.14.md b/sources/tech/20200524 Diamond interface composition in Go 1.14.md new file mode 100644 index 0000000000..611bb2c39e --- /dev/null +++ b/sources/tech/20200524 Diamond interface composition in Go 1.14.md @@ -0,0 +1,124 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Diamond interface composition in Go 1.14) +[#]: via: (https://dave.cheney.net/2020/05/24/diamond-interface-composition-in-go-1-14) +[#]: author: (Dave Cheney https://dave.cheney.net/author/davecheney) + +Diamond interface composition in Go 1.14 +====== + +Per the [overlapping interfaces proposal][1], Go 1.14 now permits embedding of interfaces with overlapping method sets. This is a brief post explain what this change means: + +Let’s start with the definition of the three key interfaces from the `io` package; `io.Reader`, `io.Writer`, and `io.Closer`: + +``` +package io + +type Reader interface { + Read([]byte) (int, error) +} + +type Writer interface { + Write([]byte) (int, error) +} + +type Closer interface { + Close() error +} +``` + +Just as embedding a type inside a struct allows the embedded type’s fields and methods to be accessed as if it were declared on the embedding type[1][2], the process is true for interfaces. Thus there is no difference between explicitly declaring + +``` +type ReadCloser interface { + Read([]byte) (int, error) + Close() error +} +``` + +and using embedding to compose the interface + +``` +type ReadCloser interface { + Reader + Closer +} +``` + +You can even mix and match + +``` +type WriteCloser interface { + Write([]byte) (int, error) + Closer +} +``` + +However, prior to Go 1.14, if you continued to compose interface declarations in this manner you would likely find that something like this, + +``` +type ReadWriteCloser interface { + ReadCloser + WriterCloser +} +``` + +would fail to compile + +``` +% go build interfaces.go +command-line-arguments +./interfaces.go:27:2: duplicate method Close +``` + +Fortunately, with Go 1.14 this is no longer a limitation, thus solving problems that typically occur with diamond-shaped embedding graphs. + +However, there is a catch that I ran into attempting to demonstrate this feature to the local user group–this feature is only enabled when the Go compiler uses the 1.14 (or later) spec. + +As near as I can make out the rules for which version of the Go spec is used during compilation appear to be: + + 1. If your source code is stored inside `GOPATH` (or you have _disabled_ modules with `GO111MODULE=off`) then the version of the Go spec used to compile with matches the version of the compiler you are using. Said another way, if you have Go 1.13 installed, your Go version is 1.13. If you have Go 1.14 installed, your version is 1.14. No surprises here. + 2. If your source code is stored outside `GOPATH` (or you have forced modules on with `GO111MODULE=on`) then the `go` tool will take the Go version from the `go.mod` file. + 3. If there is no Go version listed in `go.mod` then the version of the spec will be the version of Go installed. This is identical to point 1. + 4. If you are in module mode, either by being outside `GOPATH` or with `GO111MODULE=on`, but there is no `go.mod` file in the current, or any parent, directory then the version of the Go spec used to compile your code defaults to Go 1.13. + + + +The last point caught me out. + + 1. It is said that embedding promotes the type’s fields and methods.[][3] + + + +### Related posts: + + 1. [Struct composition with Go][4] + 2. [term: low level serial with a high level interface][5] + 3. [Accidental method value][6] + 4. [How does the go build command work ?][7] + + + +-------------------------------------------------------------------------------- + +via: https://dave.cheney.net/2020/05/24/diamond-interface-composition-in-go-1-14 + +作者:[Dave Cheney][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://dave.cheney.net/author/davecheney +[b]: https://github.com/lujun9972 +[1]: https://github.com/golang/proposal/blob/master/design/6977-overlapping-interfaces.md +[2]: tmp.nUQHg5BP9T#easy-footnote-bottom-1-4179 (It is said that embedding promotes the type’s fields and methods.) +[3]: tmp.nUQHg5BP9T#easy-footnote-1-4179 +[4]: https://dave.cheney.net/2015/05/22/struct-composition-with-go (Struct composition with Go) +[5]: https://dave.cheney.net/2014/05/08/term-low-level-serial-with-a-high-level-interface (term: low level serial with a high level interface) +[6]: https://dave.cheney.net/2014/05/19/accidental-method-value (Accidental method value) +[7]: https://dave.cheney.net/2013/10/15/how-does-the-go-build-command-work (How does the go build command work ?) diff --git a/sources/tech/20200525 CopyQ Clipboard Manager for Keeping a Track of Clipboard History.md b/sources/tech/20200525 CopyQ Clipboard Manager for Keeping a Track of Clipboard History.md new file mode 100644 index 0000000000..616ee5971a --- /dev/null +++ b/sources/tech/20200525 CopyQ Clipboard Manager for Keeping a Track of Clipboard History.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (CopyQ Clipboard Manager for Keeping a Track of Clipboard History) +[#]: via: (https://itsfoss.com/copyq-clipboard-manager/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +CopyQ Clipboard Manager for Keeping a Track of Clipboard History +====== + +How do you copy-paste text? Let me guess. You either use the right click menu to copy-paste or use Ctrl+C to copy a text and Ctrl+V to paste the text. The text copied this way is saved to ‘clipboard’. The [clipboard][1] is a special location in the memory of your system that stores cut or copied text (and in some cases images). + +But have you ever been in a situation where you had a text copied and then you copy another text and then realize you needed the text you copied earlier? Trust me, it happens a lot. + +Instead of wondering about finding the previous text to copy again, you can use a clipboard manager. + +A clipboard manager is a handy little tool that keeps a history of the text you had copied. If you need to use the earlier copied text, you can use the clipboard manager to copy it again. + +![Clipboard][2] + +There are several clipboard managers available for Linux. In this article, I’ll cover one such tool that goes by the name CopyQ. + +### CopyQ Clipboard Manager + +[CopyQ][3] is nifty clipboard manager that has plenty of features to manage your system’s clipboard. It is an open source software available for free for major Linux distributions. + +Like any other clipboard manager, CopyQ monitors the system clipboard and saves its content. It can save both text and images from the clipboard. + +CopyQ sits in the system tray and you can easily access it from there. From the system tray, just click on the text that you want. It will automatically copy this text and you would notice that the copied text moves on to the top of the saved clipboards. + +![][4] + +In the system tray, it shows only the five recent clips. You can open the main window using the “Show/hide main window” option in the system tray. CopyQ saves up to 200 clips. You may edit the clipboard items here. + +![][5] + +You may also set a keyboard shortcut to bring the clipboard with a few key combination. This option is available in Preferences->Shortcuts. + +![][6] + +If you decide to use it, I advise enabling the autostart so that CopyQ runs automatically when you start your system. By default, it saves 200 items in the history and that’s a lot in my opinion. You may want to change that as well. + +![][7] + +CopyQ is an advanced clipboard manager with plenty of additional features. You can search for text in the saved clipboard items. You can sort, create, edit or change the order of the clipboard items. + +You can ignore clipboard copied from some windows or containing some text. You can also temporarily disable clipboard saving. CopyQ also supports [Vim][8]-like editor and shortcut for Vim fans. + +There are many more features that you may explore on your own. For me, the most notable feature is that it gives me easy access to older copied text, and I am happy with that. + +### Installing CopyQ on Linux + +CopyQ is available for Linux, Windows and macOS. You can get the executable file for Windows and macOS [from its website][3]. + +For Linux, CopyQ is available in the repositories of all major Linux distributions. Which means that you can find it in your software center or install it using your distribution’s package manager. + +Ubuntu users may find it in the software center if [universe repository is enabled][9]. + +![CopyQ in Ubuntu Software Center][10] + +Alternatively, you can use the apt command to install it: + +``` +sudo apt install copyq +``` + +Ubuntu users also have the option to [use the official PPA][11] and always get the latest stable CopyQ version. For example, at the time of writing this article, CopyQ version in Ubuntu 20.04 is 3.10 while [PPA has newer version][12] 3.11. It’s your choice really. + +``` +sudo add-apt-repository ppa:hluk/copyq +sudo apt update +sudo apt install copyq +``` + +You may also want to know [how to remove PPA][13] later. + +### Do you use a clipboard manager? + +I find it surprising that many people are not even aware of an essential utility like clipboard manager. For me, it’s one of the [essential productivity tools on Linux][14]. + +As I mentioned at the beginning of the article, there are several clipboard managers available for Linux. CopyQ is one of such tools. Do you use or know of some other similar clipboard tool? Why not let us know in the comments? + +If you started using CopyQ after reading this article, do share your experience with it. What you liked and what you didn’t like? The comment section is all yours. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/copyq-clipboard-manager/ + +作者:[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.computerhope.com/jargon/c/clipboar.htm +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/clipboard.png?ssl=1 +[3]: https://hluk.github.io/CopyQ/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/copyq-system-tray.png?ssl=1 +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/copyq-main-window.png?ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/copyq-shortcuts.png?ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/copyq-auto-start.png?ssl=1 +[8]: https://itsfoss.com/vim-8-release-install/ +[9]: https://itsfoss.com/ubuntu-repositories/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/copyq-software-center.png?resize=800%2C474&ssl=1 +[11]: https://itsfoss.com/ppa-guide/ +[12]: https://launchpad.net/~hluk/+archive/ubuntu/copyq +[13]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ +[14]: https://itsfoss.com/productivity-tips-ubuntu/ diff --git a/sources/tech/20200525 Debian-s Decision to Drop Old Drivers has Upset Vintage Hardware Users.md b/sources/tech/20200525 Debian-s Decision to Drop Old Drivers has Upset Vintage Hardware Users.md new file mode 100644 index 0000000000..fb2b9005ea --- /dev/null +++ b/sources/tech/20200525 Debian-s Decision to Drop Old Drivers has Upset Vintage Hardware Users.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Debian’s Decision to Drop Old Drivers has Upset Vintage Hardware Users) +[#]: via: (https://itsfoss.com/debian-dropping-old-drivers/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Debian’s Decision to Drop Old Drivers has Upset Vintage Hardware Users +====== + +It is always a tough decision to drop support for older hardware for the latest Linux distribution releases. Just like [Ubuntu decided to drop support for 32-bit systems][1], Debian’s X Strike Force (XFS) team decided to drop a list of input and video drivers. + +### Debian is considering to drop support for really old hardware + +![][2] + +In case you didn’t know, the XFS team is responsible for maintaining packages the [X Window System][3] in [Debian][4]. And, the list of drivers that [they want to remove][5] are: + + * xserver-xorg-input-aiptek + * xserver-xorg-input-elographics + * xserver-xorg-input-mtrack + * xserver-xorg-input-mutouch + * xserver-xorg-input-void + * server-xorg-video-ast + * xserver-xorg-video-mach64 + + + * xserver-xorg-video-neomagic + * xserver-xorg-video-r128 + * xserver-xorg-video-savage + * xserver-xorg-video-siliconmotion + * xserver-xorg-video-sisusb + * xserver-xorg-video-tdfx + * xserver-xorg-video-trident + + + +So, Mach 64, [ATI Rage R128][6], Savage, Silicon Motion, SiS, Trident, and NeoMagic are some of the graphics chipsets that would be affected. The reason (as stated by them) to drop these drivers is: + +> They are either unmaintained upstream or provide no value to the distribution. + +Now, that could make sense, if the packages are no longer maintained. But, upstream some of these X.org drivers are still **maintained** even if there are no frequent updates to them. For instance, in 2018, a [new display driver update was released for the ATI RAGE 128][7], as reported by Phoronix. + +### Vintage hardware owners are going to be upset + +Obviously, the vintage hardware users aren’t quite happy with the decision because a handful of people still own (or actively use) old hardware i.e. around 20 years older. + +From the original list of drivers mentioned in the [bug report][5], **Geode display driver** was initially decided to be removed but wasn’t dropped. + +It was also reported that the “**xserver-xorg-video-r128**” driver is required for older Apple hardware (iMac). And, a user reported about the missing video driver on his iMac. + +For most of the users, this decision may not actually affect any “production” systems because I don’t think anyone is probably going to utilize 20-year old hardware for commercial purposes. + +The hobbyists and collectors who like to preserve older tech are surely going to be impacted by this decision. + +### Wrapping Up + +In my opinion, dropping the support for incredibly dated hardware is not entirely a bad move. + +But, if there is a demand for the support of vintage hardware, the fair share of users who want the drivers to be added in Debian should help maintain those packages. If not, I don’t think it won’t be a wise choice to have an unmaintained piece of code in Debian. + +What do you think about this? Feel free to share your thoughts in the comments below! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/debian-dropping-old-drivers/ + +作者:[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://itsfoss.com/ubuntu-drops-32-bit-desktop/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/debian-bug-report-driver-drop.jpg?ssl=1 +[3]: https://en.wikipedia.org/wiki/X_Window_System +[4]: https://www.debian.org/ +[5]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=955603 +[6]: https://en.wikipedia.org/wiki/ATI_Rage_series +[7]: https://www.phoronix.com/scan.php?page=news_item&px=ATI-RAGE-128-DDX-6.11.0 diff --git a/sources/tech/20200525 EU Parliament Strongly Recommends Developing and Using Open Source Software.md b/sources/tech/20200525 EU Parliament Strongly Recommends Developing and Using Open Source Software.md new file mode 100644 index 0000000000..bfeb5635ce --- /dev/null +++ b/sources/tech/20200525 EU Parliament Strongly Recommends Developing and Using Open Source Software.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (EU Parliament Strongly Recommends Developing and Using Open Source Software) +[#]: via: (https://itsfoss.com/eu-parliament-recommends-open-source/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +EU Parliament Strongly Recommends Developing and Using Open Source Software +====== + +Europe is choosing open source more than ever. Not just limited to [EU Commissions’ decision to use Signal messaging app][1] but also [open science][2] and the [adoption of open source software by European universities][3]. + +Now, in a recent [press release][4] by the [European Pirate Party][5], it looks like the EU Parliament is urging EU institutions to use open-source software. All thanks to the Pirate amendments for encouraging the use of open-source software. + +The EU Parliament not just encourages the use of open-source software, but they have also advised to prioritize development of open-source software by the EU institutions. + +So, not just aiming to adopt using open-source software but to develop open-source software. And, that’s definitely good news! + +More use of open-source software, why not? To give you some more details, here’s what they mentioned in the press release: + +> **In practice, from now on, all IT solutions developed by and for the EU institutions will first need to be assessed against the possibility of using Open Source solutions. Assessments will then have to be reported back to the Budgetary Control Committee of the Parliament on an annual basis, during the discharge procedure. This is a strong call for enhancing our important citizens right to transparent and trustworthy information.** + +### Important decision to remove vendor lock-ins + +![Public Money Public Code Campaign][6] + +No matter who made this happen — this decision of preferring open-source software over proprietary will not just help the open-source community but also helps the EU institutions in a variety of ways. + +Especially, relying on open-source software removes the overhead of vendor lock-ins. In other words, an EU institution does not have to rely on vendor to manage/maintain the software. + +The press release also addressed this by mentioning: + +> It is essential for the European institutions to retain control over its own technical systems, especially in a context of disinformation and foreign interference. Open Source promotes local technical support, leads to rapid development of software and helps to avoid dependency on specific suppliers or vendor lock-in effects, which exist when only one company is in charge of software or even the entire IT infrastructure supply. + +Any responsible local organization can take up the task while the community can still help in any way it can. This could also reduce the cost of maintaining the software among other things like improving the security of a software in a collaborative manner. + +### Is this a big win for open-source community? + +![][7] + +Yes, and no. We’ve seen a lot of recommendations made by the governments (or the EU government in general) to choose open-source software to keep things more secure yet transparent. + +Pirate’s Vice-President of EU Parliament, **Marcel Kolaja**, mentions some advantages of this decision as well: + +_It’s a milestone for transparent and open digitization of the European institutions. From now on, the Open Source ecosystem has a stepping ground for offering Open Source solutions and the Pirates will gladly play the role of the guardians and will try to solve and highlight any attempt to bypass this strong recommendation. It’s a really important step to remove vendor lock-ins in the Parliament“_ + +So, this will definitely help them earn trust of their citizens by providing digital transparency while also encouraging public participation to improve the software as well. Of course, this will also help introduce the concept of open-source software to many who were unaware of it in some way. + +Also, ensuring open-source software for publicly financed software will enhance the meaning of freedom of speech/privacy/press. + +In a nutshell, these decisions do have a positive impact in one way or the other. + +But, the implementations of these decisions will decide how effective it’s going to be to put the words in action. + +### Wrapping Up + +I’m happy with the decision by EU Parliament here — even though I’m not a European. I guess, this should encourage other government bodies to take similar decisions or steps to ensure digital transparency while earning the trust of their citizens. + +To get more details on the decision, you can refer to the [official press release by the European Pirate Party][4]. + +What do you think about it? Let me know your thoughts in the comments below! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/eu-parliament-recommends-open-source/ + +作者:[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://itsfoss.com/eu-commission-switches-to-signal/ +[2]: https://ec.europa.eu/research/openscience/index.cfm?pg=openaccess +[3]: https://opensource.com/article/20/5/open-source-higher-education +[4]: https://european-pirateparty.eu/european-parliament-strongly-recommends-any-software-developed-by-and-for-the-eu-institutions-to-be-made-publicly-available-under-free-and-open-source-software-licence/ +[5]: https://en.wikipedia.org/wiki/European_Pirate_Party +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/public-money-public-code.png?resize=800%2C420&ssl=1 +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/eu-parliament-open-source.jpg?ssl=1 diff --git a/sources/tech/20200525 Encrypt Your Files Before Uploading it to Cloud With Cryptomator.md b/sources/tech/20200525 Encrypt Your Files Before Uploading it to Cloud With Cryptomator.md new file mode 100644 index 0000000000..eda3a2990e --- /dev/null +++ b/sources/tech/20200525 Encrypt Your Files Before Uploading it to Cloud With Cryptomator.md @@ -0,0 +1,184 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Encrypt Your Files Before Uploading it to Cloud With Cryptomator) +[#]: via: (https://itsfoss.com/cryptomator/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Encrypt Your Files Before Uploading it to Cloud With Cryptomator +====== + +_**Open source software highlight of this week is Cryptomator. It is a unique free and open-source encryption software that lets you encrypt your data before uploading it to the cloud.**_ + +There are several [cloud services available for Linux][1] and almost all of them do not offer [end to end encryption][2], at least not by default. + +Usually, the connection between your device and the server is secure. But your data stored on the server is not encrypted. Employees with direct access to the infrastructure at your cloud service providers may access this data. + +Of course, these companies have strict policies against such intrusion but a rogue employee can do a lot of damage. Remember the incident when a [departing Twitter employee deactivated the account of US President Donald Trump][3]. + +If you are one of the privacy cautious people, you would want the ease of cloud storage but with the added security layer of encrypted storage. + +Now some [services like pCloud do provide end to end encryption][4] but that comes at an additional cost. If you could afford that, well and good. If not, you can use a free and open source tool like [Cryptomator][5]. + +Cryptomator helps you secure your data by encrypting it before uploading it to any cloud storage services. In this article, I’m going to highlight the key features of Cryptomator along with instructions to use it. + +### Cryptomator: Add an encryption layer to your cloud data + +![][6] + +Cryptomator is a solution to encrypt your data locally before uploading it to the cloud. + +With this, you can create vaults locally and sync them to the cloud storage services you use. + +It’s very easy to use and you don’t need to have any specific technical knowledge to encrypt your data – that’s what Cryptomator is tailored for. + +### Features of Cryptomator + +Cryptomator is a simple encryption tool with the essential features. Here’s what it offers: + + * [AES][7] and 256-bit Encryption for files. + * Ability to create a vault and sync it with the cloud storage service + * Optional recovery key for your master password of the vault + * Cross-platform support (Linux, Windows, macOS, Android, and iOS) + * Supports the dark theme for a one-time license fee. + * Supports [WebDAV][8], [FUSE][9], and [Dokany][10] for easy integration with your operating system. + + + +Do note that the [Android][11] and [iOS][12] apps are paid apps that you have to purchase separately while the desktop program is completely free to use. Also, you need to purchase a one-time license to unlock the dark mode. Don’t blame them please. They need to make some money in order to develop this open source software. + +### Installing Cryptomator on Linux + +Cryptomater provides an AppImage file that you can download to get started on any Linux distribution. + +You can get it from its [official download page][13]. In case you don’t know, please read [how to use an AppImage file][14] to get started. + +[Download Cryptomator][5] + +### How To Use Cryptomator? + +Attention! + +Encryption is a double-edged sword. It can protect you and it can hurt you as well. +If you are encrypting your data and you forgot your encryption key, you’ll lose access to that data forever. +Cryptomator provides a recovery key option so please be careful with both password and the recovery key. Don’t forget it or lose the recovery key. + +Once you have installed Cryptomator, it’s really easy to use it following the user interface or the [official documentation][15]. + +But, to save you some time, I’ll highlight a few important things that you should know: + +#### Setup Your Vault + +![][16] + +After launching Cryptomator, you need to create the vault where you want to have your encrypted data. + +This can be an existing location or a new custom directory as per your requirements. + +Now that you proceed creating a new vault, you will also observe that you can open an existing vault as well (if you had one already). So, always have a backup of your vault, just in case. + +![][17] + +Here, I am assuming that you are a new user. So, obviously, proceed to create a new vault and give it a name: + +![][18] + +Next, you need to specify a storage location. If you already use OneDrive, Dropbox, Google Drive, or something similar, it might detect it automatically. + +![][19] + +However, if it doesn’t, like in my case (I use [pCloud][20]), you can select the cloud-synced directory or any other custom location manually. + +Once you select the location, you just need to create a password for it. It’s best to create a strong password that you can remember. + +![][21] + +Also, I’d suggest you to opt for the recovery key and store it in a separate USB drive or just print it on a paper. + +![][22] + +And, that’s it. You’re done creating your secure vault that you can sync with the cloud. + +![][23] + +Now, how do you add files to it? Let’s take a look: + +#### Adding Files To A Vault + +_**Note:** You can’t just go into the folder that you created from the file manager and files there. Follow the steps below to add files properly in your encrypted vault._ + +Once you’ve created your vault, you just need to unlock it by typing the password as shown in the image below. If you’re on your personal computer, you can choose to save the password without needing to enter it every time you access the vault. However, I advise not to do that. Manually entering the password help in remembering it. + +![][24] + +Next, after unlocking the vault, you just need to click on “**Reveal Vault**” or reveal drive to open it using **File Manager** where you can access/modify or add files to it. + +#### Backup / Recover Your Vault + +You should simply copy-paste the folder you create to another USB drive or somewhere else other than your cloud storage folder to ensure that you have a backup of your vault. + +![][25] + +It’s important to have the **masterkey.cryptomator** file of the vault in order to open it. + +#### Upgrades, Preferences & Settings + +Note + +You should enable the auto-updates feature to ensure that you will have the most stable and error-free version automatically. + +Apart from the most important functions of the Cryptomator app, you will get a couple of other features to tweak, such as: + + * Change the type of your virtual drive + * Tweak the vault to read-only mode + + + +You can explore the **Vault options** and the settings on Cryptomator to know about what else you can do. + +**Wrapping Up** + +Now that you know about Cryptomator, you can easily encrypt your important data locally before uploading them to the cloud. + +What do you think about Cryptomator? Let us know your thoughts in the comments down below! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/cryptomator/ + +作者:[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://itsfoss.com/cloud-services-linux/ +[2]: https://en.wikipedia.org/wiki/End-to-end_encryption +[3]: https://www.theverge.com/2017/11/2/16600732/donald-trump-twitter-account-gone-realdonaldtrump +[4]: https://partner.pcloud.com/r/22317 +[5]: https://cryptomator.org/ +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-ft.jpg?ssl=1 +[7]: https://en.wikipedia.org/wiki/Advanced_Encryption_Standard +[8]: https://en.wikipedia.org/wiki/WebDAV +[9]: https://en.wikipedia.org/wiki/Filesystem_in_Userspace +[10]: https://en.wikipedia.org/wiki/Dokan_Library +[11]: https://play.google.com/store/apps/details?id=org.cryptomator&hl=en_US +[12]: https://apps.apple.com/us/app/cryptomator/id953086535 +[13]: https://cryptomator.org/downloads/ +[14]: https://itsfoss.com/use-appimage-linux/ +[15]: https://docs.cryptomator.org +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-add-vault.jpg?ssl=1 +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-create-open-vault.jpg?ssl=1 +[18]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-add-vault-name.jpg?ssl=1 +[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-vault-location.jpg?ssl=1 +[20]: https://itsfoss.com/recommends/pcloud/ +[21]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-pass.jpg?ssl=1 +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-recovery.jpg?ssl=1 +[23]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-vault-success.jpg?ssl=1 +[24]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-unlock.jpg?ssl=1 +[25]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/cryptomator-master.jpg?ssl=1 diff --git a/sources/tech/20200525 How to Assign Static IP Address on Ubuntu Linux.md b/sources/tech/20200525 How to Assign Static IP Address on Ubuntu Linux.md new file mode 100644 index 0000000000..87ddb6b839 --- /dev/null +++ b/sources/tech/20200525 How to Assign Static IP Address on Ubuntu Linux.md @@ -0,0 +1,179 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Assign Static IP Address on Ubuntu Linux) +[#]: via: (https://itsfoss.com/static-ip-ubuntu/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +How to Assign Static IP Address on Ubuntu Linux +====== + +_**Brief: In this tutorial, you’ll learn how to assign static IP address on Ubuntu and other Linux distributions. Both command line and GUI methods have been discussed.**_ + +IP addresses on Linux Systems in most cases are assigned by [Dynamic Host Configuration Protocol][1] (DHCP) servers. IP addresses assigned this way are dynamic which means that the IP address might change when you [restart your Ubuntu system][2]. It’s not necessary but it may happen. + +_**Dynamic IP is not an issue for normal desktop Linux users in most cases**_. It could become an issue if you have employed some special kind of networking between your computers. + +For example, you can [share your keyboard and mouse between Ubuntu and Raspberry Pi][3]. The configuration uses IP addresses of both system. If the IP address changes dynamically, then your setup won’t work. + +Another use case is with servers or remotely administered desktops. It is easier to set static addresses on those systems for connection stability and consistency between the users and applications. + +In this tutorial, I’ll show you how to set up static IP address on Ubuntu based Linux distributions. Let me show you the command line way first and then I’ll show the graphical way of doing it on desktop. + +### Method 1: Assign static IP in Ubuntu using command line + +![][4] + +**Note for desktop users**: Use static IP only when you need it. Automatic IP saves you a lot of headache in handling network configuration. + +#### Step 1: Get the name of network interface and the default gateway + +The first thing you need to know is the name of the network interface for which you have to set up the static IP. + +You can either use ip command or the network manager CLI like this: + +``` +nmcli d +``` + +In my case, it shows my Ethernet (wired) network is called enp0s25: + +``` +Ubuntu> nmcli d +DEVICE TYPE STATE CONNECTION +enp0s25 ethernet unmanaged -- +lo loopback unmanaged -- +``` + +Next, you should note the [default gateway IP using the Linux command][5] **ip route**: + +``` +ip route +default via 192.168.31.1 dev enp0s25 proto dhcp metric 600 +169.254.0.0/16 dev enp0s25 scope link metric 1000 +192.168.31.0/24 dev enp0s25 proto kernel scope link src 192.168.31.36 metric 600 +``` + +As you can guess, the default gateway is 192.168.31.1 for me. + +#### Step 2: Locate Netplan configuration + +Ubuntu 18.04 LTS and later versions use [Netplan][6] for managing the network configuration. Netplan configuration are driven by .yaml files located in **/etc/netplan** directory. + +By default, you should see a .yaml file named something like 01-network-manager-all.yaml, 50-cloud-init.yaml, 01-netcfg.yaml. + +Whatever maybe the name, its content should look like this: + +``` +# Let NetworkManager manage all devices on this system +network: + version: 2 + renderer: NetworkManager +``` + +You need to edit this file for using static IP. + +#### Step 3: Edit Netplan configuration for assigning static IP + +_**Just for the sake of it, make a backup of your yaml file.**_ + +Please make sure to use the correct yaml file name in the commands from here onward. + +Use nano editor with sudo to open the yaml file like this: + +``` +sudo nano /etc/netplan/01-netcfg.yaml +``` + +Please note that _**yaml files use spaces for indentation**_. If you use tab or incorrect indention, your changes won’t be saved. + +You should edit the file and make it look like this by providing the actual details of your IP address, gateway, interface name etc. + +``` +network: + version: 2 + renderer: networkd + ethernets: + enp0s25: + dhcp4: no + addresses: + - 192.168.31.16/24 + gateway4: 192.168.31.1 + nameservers: + addresses: [8.8.8.8, 1.1.1.1] +``` + +In the above file, I have set the static IP to 192.168.31.16. + +Save the file and apply the changes with this command: + +``` +sudo netplan apply +``` + +You can verify it by [displaying your ip address in the terminal][7] with ‘ip a’ command. + +Revert the changes and go back to dynamic IP + +If you don’t want to use the static IP address anymore, you can revert easily. + +If you have backed up the original yaml file, you can delete the new one and use the backup one. + +Otherwise, you can change the yaml file again and make it look like this: + +``` +network: + version: 2 + renderer: networkd + ethernets: + enp0s25: + dhcp4: yes +``` + +### Method 2: Switch to static IP address in Ubuntu graphically + +If you are on desktop, using the graphical method is easier and faster. + +Go to the settings and look for network settings. Click the gear symbol adjacent to your network connection. + +![][8] + +Next, you should go to the IPv4 tab. Under the IPv4 Method section, click on Manual. + +In the Addresses section, enter the IP static IP address you want, netmask is usually 24 and you already know your gateway IP with the ip route command. + +You may also change the DNS server if you want. You can keep Routes section to Automatic. + +![][9] + +Once everything is done, click on Apply button. See, how easy it is to set a static IP address graphically. + +If you haven’t read my previous article on [how to change MAC Address][10], you may want to read in conjunction with this one. + +More networking related articles will be rolling out, let me know your thoughts at the comments below and stay connected to our social media. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/static-ip-ubuntu/ + +作者:[Dimitrios Savvopoulos][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/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol +[2]: https://itsfoss.com/schedule-shutdown-ubuntu/ +[3]: https://itsfoss.com/keyboard-mouse-sharing-between-computers/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/static-ip-ubuntu.jpg?ssl=1 +[5]: https://linuxhandbook.com/find-gateway-linux/ +[6]: https://netplan.io/ +[7]: https://itsfoss.com/check-ip-address-ubuntu/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/assign-static-ip-1.jpg?ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/assign-static-ip-2.jpg?ssl=1 +[10]: https://itsfoss.com/change-mac-address-linux/ diff --git a/sources/tech/20200525 How to Compress PDF in Linux -GUI - Terminal.md b/sources/tech/20200525 How to Compress PDF in Linux -GUI - Terminal.md new file mode 100644 index 0000000000..eba596bcb9 --- /dev/null +++ b/sources/tech/20200525 How to Compress PDF in Linux -GUI - Terminal.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Compress PDF in Linux [GUI & Terminal]) +[#]: via: (https://itsfoss.com/compress-pdf-linux/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +How to Compress PDF in Linux [GUI & Terminal] +====== + +_**Brief: Learn how to reduce the size of a PDF file in Linux. Both command line and GUI methods have been discussed.**_ + +I was filling some application form and it asked to upload the necessary documents in PDF format. Not a big issue. I gathered all the [scanned images and combined them in one PDF using gscan2pdf tool][1]. + +The problem came when I tried to upload this PDF file. The upload failed because it exceeded the maximum file size limit. This only meant that I needed to somehow reduce the size of the PDF file. + +Now, you may use an online PDF compressing website but I don’t trust them. A file with important documents uploading to an unknown server is not a good idea. You could never be sure that they don’t keep a copy your uploaded PDF document. + +This is the reason why I prefer compressing PDF files on my system rather than uploading it to some random server. + +In this quick tutorial, I’ll show you how to reduce the size of PDF files in Linux. I’ll show both command line and GUI methods. + +### Method 1: Reduce PDF file size in Linux command line + +![][2] + +You can use [Ghostscript][3] command line tool for compressing a PDF file. Most Linux distributions include the open source version of Ghostscript already. However, you can still try to install it just to make sure. + +On Debian/Ubuntu based distributions, use the following command to install Ghostscript: + +``` +sudo apt install ghostscript +``` + +Now that you have made sure that Ghostscript is installed, you can use the following command to reduce the size of your PDF file: + +``` +gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_PDF_file.pdf input_PDF_file.pdf +``` + +In the above command, you should add the correct path of the input and out PDF file. + +The command looks scary and confusing. I advise copying and pasting most of it. What you need to know is the dPDFSETTINGS parameter. This is what determines the compression level and thus the quality of your compressed PDF file. + +dPDFSETTINGS | Description +---|--- +/prepress (default) | Higher quality output (300 dpi) but bigger size +/ebook | Medium quality output (150 dpi) with moderate output file size +/screen | Lower quality output (72 dpi) but smallest possible output file size + +Do keep in mind that some PDF files may not be compressed a lot or at all. Applying compression on some PDF files may even produce a file bigger than the original. There is not much you can do in such cases. + +### Method 2: Compress PDF files in Linux using GUI tool + +I understand that not everyone is comfortable with command line tool. The [PDF editors in Linux][4] doesn’t help much with compression. This is why we at It’s FOSS worked on creating a GUI version of the Ghostscript command that you saw above. + +[Panos][5] from It’s FOSS team [worked on creating a Python-Qt based GUI wrapper for the Ghostscript][6]. The tool gives you a simple UI where you can select your input file, select a compression level and click on the compress button to compress the PDF file. + +![][7] + +The compressed PDF file is saved in the same folder as the original PDF file. Your original PDF file remains untouched. The compressed file is renamed by appending -compressed to the original file name. + +If you are not satisfied with the compression, you can choose another compression level and compress the file again. + +You may find the source code of the PDF Compressor on our GitHub repository. To let you easily use the tool, we have packaged it in AppImage format. Please [refer to this guide to know how to use AppImage][8]. + +[Download PDF Compressor (AppImage)][9] + +Please keep in mind that the tool is in early stages of developments. You may experience some issues. If you do, please let us know in the comments or even better, [file a bug here][10]. + +We’ll try to add more packages (Snap, Deb, PPAs etc) in the future releases. If you have experience with the development and packaging, please feel free to give us a hand. + +Would you like It’s FOSS team to work on creating more such small desktop tools in future? Your feedback and suggestions are welcome. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/compress-pdf-linux/ + +作者:[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/convert-multiple-images-pdf-ubuntu-1304/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/compress-pdf-linux.jpg?ssl=1 +[3]: https://www.ghostscript.com/ +[4]: https://itsfoss.com/pdf-editors-linux/ +[5]: https://github.com/libreazer +[6]: https://github.com/itsfoss/compress-pdf +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/compress-PDF.jpg?fit=800%2C448&ssl=1 +[8]: https://itsfoss.com/use-appimage-linux/ +[9]: https://github.com/itsfoss/compress-pdf/releases/download/0.1/compress-pdf-v0.1-x86_64.AppImage +[10]: https://github.com/itsfoss/compress-pdf/issues diff --git a/sources/tech/20200525 How to Install Linux Mint in VirtualBox -Screenshot Tutorial.md b/sources/tech/20200525 How to Install Linux Mint in VirtualBox -Screenshot Tutorial.md new file mode 100644 index 0000000000..1fc324e817 --- /dev/null +++ b/sources/tech/20200525 How to Install Linux Mint in VirtualBox -Screenshot Tutorial.md @@ -0,0 +1,194 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install Linux Mint in VirtualBox [Screenshot Tutorial]) +[#]: via: (https://itsfoss.com/install-linux-mint-in-virtualbox/) +[#]: author: (Dimitrios Savvopoulos https://itsfoss.com/author/dimitrios/) + +How to Install Linux Mint in VirtualBox [Screenshot Tutorial] +====== + +_**Brief: One of safest and easiest ways to try Linux Mint is inside a virtual machine. Your real system doesn’t change at all. Learn how to install Linux Mint in VirtualBox in this tutorial.**_ + +[Linux Mint][1] is considered one of the [best distributions for new Linux users][2]. Its flagship Cinnamon DE is one of the most popular desktop environment giving your system a look and feel of classic Window-styled desktop. + +If you want to try Linux Mint and see if it fits your need, you could try installing it in a virtual machine. This way, you run Linux Mint inside your current system without changing your system’s partition or boot order. One of the safest way out there as you get to run Linux like a regular desktop application inside your current operating system. + +![][3] + +Oracle’s open source virtualization tool [VirtualBox][4] is available for free on all major desktop operating systems i.e. Windows, Linux and macOS. + +In this beginner’s tutorial, I’ll show you the steps for installing Linux Mint in VirtualBox. I am including the screenshots for each step so that you can easily follow the tutorial. + +### Installing Linux Mint in VirtualBox + +You can follow the steps on any operating system be it Windows, Linux or macOS. You just need to install VirtualBox on your operating system and rest of the steps remain the same. + +**Step 1:** [Download VirtualBox from its website][4] and install it by double-clicking on the downloaded file. + +![][5] + +Next, install the latest version of Linux Mint’s ISO file from its website. + +[Download Linux Mint ISO][6] + +**Step 2:** Once your virtual Box is up & running we are ready to get started. Click the New button, click Next on the virtual machine wizard. + +![Create a new Virtual Machine][7] + +Initially you need to specify the following: + + * Name: Any preferred name for your VM like Linux Mint + * Type: Linux + * Version: Ubuntu (64 bit) as Linux Mint is an Ubuntu-based distribution + + + +Before configuring any hardware resource value, please make sure that are aware of the [system requirements][8]. + +2 GB RAM would be okay but won’t give you a good experience. 3 GB is a comfortable amount if your system has 8 GB of RAM. I choose to set my Virtual Machine to 4096 MB (4 GB) because my system has plenty of RAM. + +RAM consumption + +One of the common confusion is regarding the RAM consumption. Let’s say your Windows system has 8 GB of RAM and you assign 3 GB of RAM to Linux Mint in VirtualBox. + +If you are running Linux Mint inside VirtualBox, your real system (called host system) will have 5 GB of RAM available for consumption. + +If you are not running Linux Mint inside VirtualBox, at that moment, the entire 8 GB will be available to the host system. + +**Step 3:** Next, choose a Virtual Hard disk now option and click create. + +Choose the virtual storage allocation method (Recommended Dynamically allocated). Set your storage location for virtual hard disk by browsing drive and then specify the size of virtual hard disk (it could be anything from 12-20 GB). + +![Dynamic allocation can save you space if you don’t need the maximum allowance][9] + +**Step (4 (optional advanced settings):** Once Virtual machine has been created, click on the settings button in menu: + +![][10] + +Now, go to the Display section. Specify the Video memory (128 MB) and check “Enable 3D Acceleration”. + +![Don’t forget to enable the 3D Acceleration][11] + +Then click on System Tab → Processor and choose how many threads would you like to allocate. + +My system is a 4 core/4 thread system and I choose to assign half of the CPU capability i.e. 2 threads. + +![Select CPU cores as per the distribution requirements][12] + +Once you have configured everything click ok. + +**Step 5:** In the System settings, go to Storage (from the left sidebar). Click on the [Optical Drive] Empty as shown in the image below. + +You’ll be asked to browse to the Linux Mint ISO file you had downloaded earlier. + +![][13] + +Once you select your ISO, click on the start button and that’s it! Now the ISO will start running as if you are booting from a live USB. + +Next, you need to press enter whilst your option is start Linux Mint as per the picture below. + +![][14] + +**Step 6:** Let’s start the installation procedure. + +Choose the language you want for your Linux Mint virtual machine. + +![Choose your native language][15] + +I’m based in the UK, so I have a UK keyboard layout. You can choose the one you want. + +![Choose your keyboard layout according to your hardware configuration][16] + +You may check the box to download and install any third-party software during the installation. + +![You may install media codecs while installing Linux Mint][17] + +You can proceed to erase the disk and install Linux Mint. + +Erase disk? Really? + +This step may seem scary because you may think that it will harm your real system. + +Let me assure you that it won’t do any damage to your actual disk. Remember you created 10-20 GB of virtual disk in step 3? Now you are inside that disk. + +When it asks for erasing the disk, it is erasing the virtual disk created for it. It doesn’t impact your real system disk and its data. + +![It is safe to erase your disk only at a Virtual Machine level][18] + +Next, select your time zone and click continue. You may [change time zone in Linux][19] later as well. + +![][20] + +You will be prompted to create your user account, your host name (computer’s name) and to choose a password. Once done, click continue to finalize the installation. + +![][21] + +Please wait a few minutes for the process to complete. + +![Wait a few minutes for the process to finish][22] + +The installation has now finished. Click on “Restart now”. + +![Well done! You have successfully installed Linux Mint][23] + +When you reach this step, Linux Mint will be installed and ready to use! + +![][24] + +You don’t have an installation medium so just power off the virtual machine. + +![][25] + +Now to use your virtual machine, click on the start button. + +![][26] + +You can explore a fully functional system, and at this time if you shut down Linux Mint like it was physically installed, it will automatically power off the virtual machine. + +![][27] + +Enjoy Linux Mint in VirtualBox. I hope you were able to install Linux Mint in VirtualBox. If you face any issues, please let me know in the comment section. I’ll try to help you out. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-linux-mint-in-virtualbox/ + +作者:[Dimitrios Savvopoulos][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/dimitrios/ +[b]: https://github.com/lujun9972 +[1]: https://www.linuxmint.com/ +[2]: https://itsfoss.com/best-linux-beginners/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/install-linux-mint-in-virtualbox.png?ssl=1 +[4]: https://www.virtualbox.org/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/download-virtulabox.jpg?ssl=1 +[6]: https://www.linuxmint.com/download.php +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/1.-Create-new.jpg?ssl=1 +[8]: https://blog.linuxmint.com/?p=3832 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/2.-Create-virtual-hard-disk.jpg?resize=800%2C472&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/3.-settings.jpg?resize=800%2C470&ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/4.-display.jpg?resize=800%2C472&ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/5.-cpu.jpg?resize=800%2C468&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/6.-choose-iso.jpg?resize=800%2C472&ssl=1 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/7.-boot.jpg?resize=800%2C459&ssl=1 +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/8.-choose-language.png?resize=800%2C679&ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/9.-English-UK.png?resize=800%2C679&ssl=1 +[17]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/10.-install-third-party-software.png?resize=800%2C679&ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/11.-installation-type.png?resize=800%2C679&ssl=1 +[19]: https://itsfoss.com/change-timezone-ubuntu/ +[20]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/12.-timezone.png?resize=800%2C679&ssl=1 +[21]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/13.-user-account.png?resize=800%2C679&ssl=1 +[22]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/04/14.-installation-screen.png?resize=800%2C679&ssl=1 +[23]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/15.-installation-finish.png?resize=800%2C679&ssl=1 +[24]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/16.-remove-the-media.png?resize=800%2C679&ssl=1 +[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/17.-power-off.png?resize=800%2C678&ssl=1 +[26]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/18.-init-the-fresh-installed-mint.png?resize=800%2C476&ssl=1 +[27]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/04/19.-Linux-mint-19.3-final.png?resize=800%2C469&ssl=1 diff --git a/sources/tech/20200525 LanguageTool Review- Free and Open Source Grammar Checker.md b/sources/tech/20200525 LanguageTool Review- Free and Open Source Grammar Checker.md new file mode 100644 index 0000000000..afd1a08e49 --- /dev/null +++ b/sources/tech/20200525 LanguageTool Review- Free and Open Source Grammar Checker.md @@ -0,0 +1,155 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (LanguageTool Review: Free and Open Source Grammar Checker) +[#]: via: (https://itsfoss.com/languagetool-review/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +LanguageTool Review: Free and Open Source Grammar Checker +====== + +This week’s open source software highlight is [LanguageTool][1]. It is a proofreading software that checks the grammar, style and spelling in more than 20 languages. + +I have been using it for past several days and I feel confident enough to review it and share my experience with it. I have used the popular proofreading tool [Grammarly][2] in the past and I’ll make some comparison between these two tools. + +### LanguageTool: Open source proofreading software + +![][3] + +[LanguageTool][1] grammar checker is available in [multiple formats][4]: + + * You can copy-paste your text on its website. + * You can install browser extension that will check for errors as you type anything, anywhere in the web browser. + * You can install a Java-based desktop application for offline usage. + * You can install add-on for LibreOffice and MS Office. + * Add-ons are also [available for a number of other software][5] like Sublime Text, Thunderbird, Vim, Visual Studio Code etc. + * [Android app][6] is also available. + * API is also available if you want to use LanguageTool in your software or service. API offering comes under premium services. + + + +You can find source code of LanguageTool and its related assets on [their GitHub repository][7]. + +[LanguageTool also has a premium version][8] that you can purchase. The premium version offers additional error checks. + +I am using LanguageTool premium version as a browser extension. Almost all the writing I do is online and thus the browser extension is perfect for me. + +The most convenient way to try LanguageTool is by using its browser extension. Install the browser add-on and next time you type anything in the browser, LanguageTool will start checking your text for grammatical and spelling errors. It will also check for styling errors. + +### Experience with LanguageTool: How good is it? + +LanguageTool leaves a good first impression. It starts checking for errors as you start typing. + +Different types of errors have different color codes. Spelling mistakes are highlighted in red color, grammatical mistakes are in yellow colors and styling errors have a blueish shade. + +Clicking on the error suggestion replaces your text with the suggested one. You may also ignore the suggestion. You’ll also see number of issues identified by LanguageTool in the current text check. + +![Spelling mistake identified by LanguageTool][9] + +#### Personal dictionary + +You can also create your personal directory and add words in it. This is helpful because no proofreading tool can give a green light to technical terms like systemd, iptables and brand names like [WireGuard][10]. To avoid these words labeled as spelling mistakes, add them to your personal dictionary. + +You may edit your personal dictionary from your LanguageTool account. + +![LanguageTool Personal Dictionary][11] + +#### Details on the error suggestion + +If it finds grammatical errors, it also gives a quick explanation of the error. You can get more details by clicking the tool tip which takes you to a reputable external source. + +![You can get additional details on the errors][12] + +#### Synonym suggestion (in beta) + +If you double-click on a word, it will also suggest synonyms. + +![][13] + +#### Are there any privacy issues? + +If you use the online services of LanguageTool, your text is sent to their servers over an **encrypted** connection. All their servers are hosted at Hetzner Online GmbH in Germany. + +LanguageTool states that it doesn’t store any text that you check using its services. You can read their privacy policy [here][14]. + +The free to use languagetool.org website shows ads (there are no third-party ads in the browser add-on). To test their claim of “sending text over an encrypted server”, I typed sample text containing words like vacuum cleaner, laptop etc. + +Thankfully, the displayed ad on their website was nothing related to the text I typed. I haven’t noticed any vacuum cleaner ads on the websites I visit or on Facebook. That’s a good thing. + +#### It doesn’t work flawlessly all the time + +No software is perfect and LanguageTool is not an exception. While it is helpful in finding obvious spelling and grammatical mistakes, it struggles in some simple scenario. + +For example, if a sentence contains several blank spaces together, LanguageTool failed to find an issue with that. + +![Too many whitespaces and yet it went undetected][15] + +This is weird because if I look at their ‘error rules’, I can see a [whitespace repetition rule][16]. I think this rule is applicable only for the Java-based LanguageTool apps, not the browser add-on I am using. + +I also found some other cases where LanguageTool should have identified errors but it didn’t. For example, it didn’t alert for the missing ‘to’ in the text below: + +![LanguageTool fails to find the missing “to”][17] + +When I checked it against the [Grammarly free version][2], it was able to point it out. + +![Grammarly was quick to identify it][18] + +I also found an infinite loop of suggestion. It first suggests using syntaxes as plural of syntax. + +![Suggestion for using ‘syntaxes’][19] + +And then it doesn’t accept ‘syntaxes’ as a valid word. + +![And then it doesn’t accept ‘syntaxes’][20] + +I have seen such “infinite error loop” with Grammarly as well in the past, so I won’t be too hard on LanguageTool for such issues. + +### Conclusion + +Despite some hiccups, I am satisfied with LanguageTool proofreading tool. Both free and premium version are good enough for finding obvious spelling mistakes and grammatical errors. + +The premium version offers over 2500 additional error checks and it costs around $15-$70 per year depending on your geographical region. This is a lot cheaper than [Grammarly][2] which costs $140 per year. + +I opted for the premium version because it will help this open-source project. Premium users also get email support. + +You are not forced to go premium, of course. You can use the free version and if you have some questions or need support, there is a [community forum][21] that you can join for free. + +LanguageTool can certainly be considered one of the [essential open-source tools for writers][22]. I am going to continue using LanguageTool. If you find grammatical or spelling mistakes in It’s FOSS articles in the future, blame LanguageTool, not me. Just kidding :) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/languagetool-review/ + +作者:[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://languagetool.org/ +[2]: https://itsfoss.com/recommends/grammarly/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool.png?fit=800%2C593&ssl=1 +[4]: https://languagetool.org/compare +[5]: http://wiki.languagetool.org/software-that-supports-languagetool-as-a-plug-in-or-add-on +[6]: https://play.google.com/store/apps/details?id=org.softcatala.corrector +[7]: https://github.com/languagetool-org/ +[8]: https://languagetoolplus.com/ +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/langaugetool-error-detection.png?ssl=1 +[10]: https://itsfoss.com/wireguard/ +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-personal-dictionary.png?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-error-explanation.png?ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-synonym-suggestion.png?ssl=1 +[14]: https://languagetoolplus.com/legal/privacy +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-whitespaces.png?ssl=1 +[16]: https://community.languagetool.org/rule/show/WHITESPACE_RULE?lang=en +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-suggestion-3.jpg?fit=800%2C219&ssl=1 +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-suggestion-grammarly.jpg?fit=800%2C272&ssl=1 +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-suggestion.png?ssl=1 +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/languagetool-suggestion-1.png?ssl=1 +[21]: https://forum.languagetool.org/ +[22]: https://itsfoss.com/open-source-tools-writers/ diff --git a/sources/tech/20200525 Using ‘apt search- and ‘apt show- Commands to Search and Find Details of Packages in Ubuntu.md b/sources/tech/20200525 Using ‘apt search- and ‘apt show- Commands to Search and Find Details of Packages in Ubuntu.md new file mode 100644 index 0000000000..d1d80bcb5d --- /dev/null +++ b/sources/tech/20200525 Using ‘apt search- and ‘apt show- Commands to Search and Find Details of Packages in Ubuntu.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Using ‘apt search’ and ‘apt show’ Commands to Search and Find Details of Packages in Ubuntu) +[#]: via: (https://itsfoss.com/apt-search-command/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Using ‘apt search’ and ‘apt show’ Commands to Search and Find Details of Packages in Ubuntu +====== + +_**This is a detailed beginners guide to apt search command. Using apt search and apt show commands, you can get details of the available versions, dependencies, repositories and other important information about packages in Ubuntu.**_ + +Have you ever wondered if a certain package is available to install via [apt package manager][1]? + +Have you wondered if the package offered by [Ubuntu repositories][2] are the latest one or not? + +The apt package manager in [Ubuntu][3] and many other distribution provides two handy [apt command options][4] for this purpose. + +The apt search command looks for the provided string in the name and description of the packages. + +``` +apt search package_name +``` + +The apt show command provides detailed information on a package: + +``` +apt show package_name +``` + +The commands don’t require you to [be root in Ubuntu][5]. Here’s an example of these commands: + +![][6] + +### Why would you want to use apt search or apt show command? + +Let’s say you want to [install Gambas programming language in Ubuntu][7]. You are happy with your knowledge of the apt command so you decided to use the command line for installing application. + +You open a terminal and use the apt command to install gambas but it results in [unable to locate package error][8]. + +``` +sudo apt install gambas +Reading package lists... Done +Building dependency tree +Reading state information... Done +E: Unable to locate package gambas +``` + +Why did Ubuntu not find the gambas package? Because there is no such package called gambas. Instead, it is available as gambas3. This is a situation where you could take the advantage of the apt search command. + +Let’s move to apt show command. This command provides detailed information about a package, its repository, dependencies and a lot more. + +Knowing what version of a package is available from the official repository could help you in deciding whether you should install it from some other sources. + +Quick recall + +The apt package manager works on a local database/cache of available packages from various repositories. This database contains the information about the available package version, dependencies etc. It doesn’t contain the entire package itself. The packages are downloaded from the remote repositories. + +When you run the sudo apt update command, this cache is created/updated in the /var/lib/apt/lists/ directory. The apt search and apt show commands utilize this cache. + +The term package is used for an application, program, software. + +### Search for available packages using apt search command + +![][9] + +Let me continue the gambas example. Say, you search for + +``` +apt search gambas +``` + +It will give you a huge list of packages that have “gambas” in its name or description. This output list is in alphabetical order. + +Now, you’ll of course have to make some intelligent prediction about the package you want. In this example, the first result says “Complete visual development environment for Gambas”. This gives you a good hint that this is the main package you are looking for. + +![][10] + +Why so many packages associated with gambas? Because a number of these gambas packages are probably dependencies that will installed automatically if you install the gambas3 package. If you use the _‘apt show gambas3_‘ command, it will show all the dependencies that will be installed with gambas3 package. + +Some of these listed packages could be libraries that a developer may need in some special cases while developing her/his software. + +#### Use apt search for package name only + +By default, apt search command looks for the searched term in both the name of the package and its description. + +You may narrow down the search by instructing the apt command to search for package names only. + +``` +apt search --names-only search_term +``` + +If you are following this as a tutorial, give it a try. Check the output with search term ‘transitional’ with and without –names-only option and you’ll see how the output changes. + +``` +apt search transitional +apt search --names-only transitional +``` + +**Bonus Tip**: You can use ‘apt list –installed’ command to [look for installed packages in Ubuntu][11]. + +### Get detailed information on a package using apt show command + +The output of the apt search commands a brief introduction of the packages. If you want more details, use the apt show command. + +``` +apt show exact_package_name +``` + +The apt show command works on the exact package name and it gives you a lot more information on the package. You get: + + * Version information + * Repository information + * Origin and maintainer of the package information + * Where to file a bug + * Download and installation size + * Dependencies + * Detailed description of the package + * And a lot more + + + +Here’s an example: + +![][12] + +You need to give the exact package name otherwise the apt show won’t work. The good thing is that tab completion works apt show command. + +As you can see in the previous image, you have plenty of information that you may found helpful. + +The apt show command also works on installed packages. In that case, you can see which source the package was installed from. Was it a PPA or some third-party repository or universe or the main repository itself? + +Personally, I use apt show a lot. This helps me know if the package version provided by Ubuntu is the latest or not. Pretty handy tool! + +### Conclusion + +If you read my detailed [guide on the difference between apt and apt-get commands][13], you would know that this ‘apt search’ command works similar to ‘apt-cache search’. There is no such command as “apt-get search”. + +The purpose of creating apt command is to give you one tool with only enough option to manage the packages in your Debian/Ubuntu system. The apt-get, apt-cache and other apt tools still exist, and they can be used in scripting for more complex scenarios. + +I hope you found this introduction to **apt search** and **apt show** commands useful. I welcome your questions and suggestions on this topic. + +If you liked it, please share it on various Linux forums and communities you frequent. That helps us a lot. Thank you. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/apt-search-command/ + +作者:[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://wiki.debian.org/Apt +[2]: https://itsfoss.com/ubuntu-repositories/ +[3]: https://ubuntu.com/ +[4]: https://itsfoss.com/apt-command-guide/ +[5]: https://itsfoss.com/root-user-ubuntu/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/apt-search-apt-show-example-800x493.png?resize=800%2C493&ssl=1 +[7]: https://itsfoss.com/install-gambas-ubuntu/ +[8]: https://itsfoss.com/unable-to-locate-package-error-ubuntu/ +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/apt-search-command.png?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/apt-search-command-example.png?fit=800%2C297&ssl=1 +[11]: https://itsfoss.com/list-installed-packages-ubuntu/ +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/apt-show-command-example-800x474.png?resize=800%2C474&ssl=1 +[13]: https://itsfoss.com/apt-vs-apt-get-difference/ diff --git a/sources/tech/20200525 What to do When You See -Repository does not have a release file- Error in Ubuntu.md b/sources/tech/20200525 What to do When You See -Repository does not have a release file- Error in Ubuntu.md new file mode 100644 index 0000000000..6cfd9f34de --- /dev/null +++ b/sources/tech/20200525 What to do When You See -Repository does not have a release file- Error in Ubuntu.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What to do When You See “Repository does not have a release file” Error in Ubuntu) +[#]: via: (https://itsfoss.com/repository-does-not-have-release-file-error-ubuntu/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +What to do When You See “Repository does not have a release file” Error in Ubuntu +====== + +One of the [several ways of installing software in Ubuntu][1] is by using PPA or adding third-party repositories. A few magical lines give you easy access to a software or its newer version that is not available by default in [Ubuntu][2]. + +All thing looks well and good until you get habitual of adding additional third-party repositories and one day, you see an error like this while [updating Ubuntu][3]: + +**E: The repository ‘ focal Release’ does not have a Release file. +N: Updating from such a repository can’t be done securely, and is therefore disabled by default. +N: See apt-secure(8) manpage for repository creation and user configuration details.** + +In this tutorial for Ubuntu beginners, I’ll explain what does this error mean, why do you see it and what can you do to handle this error? + +### Understanding “Repository does not have a release file” error + +![][4] + +Let’s go step by step here. The error message is: + +**E: The repository ‘ focal release’ does not have a release file** + +The important part of this error message is “focal release”. + +You probably already know that [each Ubuntu release has a codename][5]. For Ubuntu 20.04, the codename is Focal Fossa. The “focal” in the error message indicates Focal Fossa which is Ubuntu 20.04. + +The error is basically telling you that though you have added a third-party repository to your system’s sources list, this new repository is not available for your current Ubuntu version. + +_**Why so? Because probably you are using a new version of Ubuntu and the developer has not made the software available for this new version.**_ + +At this point, I highly recommend reading my detailed guides on [PPA][6] and [Ubuntu repositories][7]. These two articles will give you a better, in-depth knowledge of the topic. Trust me, you won’t be disappointed. + +### How to know if the PPA/third party is available for your Ubuntu version [Optional] + +First you should [check your Ubuntu version and its codename][8] using ‘lsb_release -a’ command: + +``` +[email protected]:~$ lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 20.04 LTS +Release: 20.04 +Codename: focal +``` + +As you can see, the codename it shows is focal. Now the next thing you can do is to go to the website of the software in question. + +This could be the tricky part but you can figure it out with some patience and effort. + +In the example here, the error complained about ****. It is a PPA repository and you may easily find its webpage. How, you may ask. + +Use Google or a [Google alternative search engine][9] like Duck Duck Go and search for “ppa numix”. This should give you the first result from [launchpad.net][10] which is the website used for hosting PPA related code. + +On the webpage of the PPA, you can go to the “Overview of published packages” and filter it by the codename of your Ubuntu version: + +![][11] + +For non-PPA third-party repository, you’ll have to check of the official website of the software and see if the repository is available for your Ubuntu version or not. + +### What to do if the repository is not available for your Ubuntu version + +In case when the repository in question is not available for your Ubuntu version, here’s what you can do: + + * Delete the troublesome repository from your list of repository so that you don’t see the error every time you run the update. + * Get the software from another source (if it is possible). + + + +To delete the troublesome repository, start Software & Updates tool: + +![][12] + +Go to the Other Software tab and look for the repository in question. Highlight it and then click on Remove button to delete it from your system. + +![Remove Ppa][13] + +This will [delete the PPA][14] or the repository in question. + +Next step is to get the software from some other source and that’s totally subjective. In some cases, you can still download the DEB file from the PPA website and use the software (I have explained the steps in the [PPA guide][6]). Alternatively, you can check the project’s website if there is a Snap/Flatpak or Python version of the software available. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/repository-does-not-have-release-file-error-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/install-remove-software-manjaro/ +[2]: https://ubuntu.com/ +[3]: https://itsfoss.com/update-ubuntu/ +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/Repository-does-not-have-a-release-file.png?ssl=1 +[5]: https://itsfoss.com/linux-code-names/ +[6]: https://itsfoss.com/ppa-guide/ +[7]: https://itsfoss.com/ubuntu-repositories/ +[8]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[9]: https://itsfoss.com/privacy-search-engines/ +[10]: https://launchpad.net/ +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/check-repo-version.png?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/04/software-updates-settings-ubuntu-20-04.jpg?ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/remove-ppa.jpg?ssl=1 +[14]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ diff --git a/sources/tech/20200526 Create interactive content in WordPress with the H5P plugin.md b/sources/tech/20200526 Create interactive content in WordPress with the H5P plugin.md new file mode 100644 index 0000000000..871439e73a --- /dev/null +++ b/sources/tech/20200526 Create interactive content in WordPress with the H5P plugin.md @@ -0,0 +1,130 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Create interactive content in WordPress with the H5P plugin) +[#]: via: (https://opensource.com/article/20/5/h5p-wordpress) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +Create interactive content in WordPress with the H5P plugin +====== +Turn your WordPress site into an interactive learning management system +with this open source plugin. +![Family learning and reading together at night in a room][1] + +WordPress is best known as a website content management system, but it also a great [learning management system][2] (LMS) for delivering online courses. If that is what you are looking for out of WordPress, then [H5P][3] should be the top plugin on your list. + +H5P is a way to create and share interactive HTML5 content, including presentations, games, quizzes, forms, and more, in a browser. You can download a wide variety of content types from H5P's [Examples and Downloads][4] page, or you can create unique content to embed in your WordPress site. + +H5P provides plugins and integrations for WordPress, Moodle, Drupal, Canvas, Brightspace, Blackboard, and more. In this article, I will show how to use H5P in WordPress to create a reading comprehension quiz for students. + +### Install the H5P plugin + +The first step is to install the plugin. Log into your WordPress admin panel, go to **Plugins**, select **Add New**, and search for **H5P** in the Plugins field. When you find it, select **Install Now**. + +![Adding the H5P plugin][5] + +(Don Watkins, [CC BY-SA 4.0][6]) + +H5P should now appear in the list of installed plugins. Be sure to **Activate** the plugin by going to the H5P menu at the bottom of your WordPress admin panel and clicking the button. You will see the following display—be sure to consent so you can connect to the H5P Hub. + +![H5P consent option][7] + +(Don Watkins, [CC BY-SA 4.0][6]) + +Now you can begin adding H5P content to your WordPress installation. + +### Create a quiz + +One of my favorite poems is Robert Frost's "The Road Not Taken." Suppose you are teaching a class that is studying this poem, and one of your objectives is for your students to remember the poem's author. First, create a new WordPress post on your site that contains the poem's text and its author. + +![Creating a WordPress post][8] + +(Don Watkins, [CC BY-SA 4.0][6]) + +Now you want to test your students' comprehension with an HTML5 interactive content embedded below the poem. + +In the WordPress admin panel, look near the bottom for the **H5P Content** menu and select it. In the menu that appears, click **Add New**. + +![H5P Content menu][9] + +(Don Watkins, [CC BY-SA 4.0][6]) + +You will see an array of content options that are available. Since you want to create a multiple-choice quiz, look for the **Multiple Choice** option and click **Get** to its right. + +![H5P content types][10] + +(Don Watkins, [CC BY-SA 4.0][6]) + +A form will open for you to start creating the quiz. Fill in the required fields (marked with a red asterisk)—give your quiz a title (e.g., "Road Not Taken Quiz"), enter a question (e.g., "Who wrote, 'The Road Not Taken'?") and correct and incorrect answers, and select the correct answer in the dialog box. When you finish creating the quiz, save the content. + +![H5P quiz][11] + +(Don Watkins, [CC BY-SA 4.0][6]) + +### Embed the quiz in a post + +Now you're ready to insert the quiz exactly where you want it to appear in your post. Open the post where you want to put the quiz (e.g., "The Road Not Taken" post) in your WordPress editor, and you should see an **Add H5P** button near the top of the interface. Place your cursor wherever you want the quiz to appear in the post, and click **Add H5P**. Your H5P content will appear in a dialog box like this: + +![H5P list of interactive content][12] + +(Don Watkins, [CC BY-SA 4.0][6]) + +Select the content you want, and H5P will insert an embed code (e.g., `[h5p id="1"]`) in the post, like this: + +![H5P embed code in a post][13] + +(Don Watkins, [CC BY-SA 4.0][6]) + +Save your post, then open it in your browser. The quiz is exactly where you wanted it to appear in the post: + +![H5P quiz shown in the post][14] + +(Don Watkins, [CC BY-SA 4.0][6]) + +When a student answers this question correctly, they get pleasant visual feedback: + +![Correct answer selection][15] + +(Don Watkins, [CC BY-SA 4.0][6]) + +### The possibilities are endless + +H5P offers a wide range of options to add interactivity to WordPress posts. In this example, you could have created a more complex set of multiple-choice questions. H5P also has lots of other content types, including interactive video, arithmetic quizzes, an audio recorder, image hotspots, fill-in-the-blank quizzes, and [many more][4]. + +H5P also provides [excellent documentation][16] and [great tutorials][17] to help anyone who wants to use the plugin on their WordPress site. H5P software is open source under the [MIT License][18] with the code available on [GitHub][19]. H5P also welcomes contributions to the community; check out the [developer guide][20] for more information. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/20/5/h5p-wordpress + +作者:[Don Watkins][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/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/family_learning_kids_night_reading.png?itok=6K7sJVb1 (Family learning and reading together at night in a room) +[2]: https://en.wikipedia.org/wiki/Learning_management_system +[3]: https://h5p.org/ +[4]: https://h5p.org/content-types-and-applications +[5]: https://opensource.com/sites/default/files/uploads/addplugins-h5p.png (Adding the H5P plugin) +[6]: https://creativecommons.org/licenses/by-sa/4.0/ +[7]: https://opensource.com/sites/default/files/uploads/h5p-consent.png (H5P consent option) +[8]: https://opensource.com/sites/default/files/uploads/wordpress-post.png (WordPress post) +[9]: https://opensource.com/sites/default/files/uploads/h5p-content-menu.png (H5P Content menu) +[10]: https://opensource.com/sites/default/files/uploads/h5p-content-types.png (H5P content types) +[11]: https://opensource.com/sites/default/files/uploads/h5p-multiple-choice-quiz.png (H5P quiz) +[12]: https://opensource.com/sites/default/files/uploads/h5p-insert-interactive-content.png (H5P list of interactive content) +[13]: https://opensource.com/sites/default/files/uploads/h5p-embedded-content.png (H5P embed code in a post) +[14]: https://opensource.com/sites/default/files/uploads/h5p-quiz.png (H5P quiz shown in the post) +[15]: https://opensource.com/sites/default/files/uploads/h5p-correct-answer.png (Correct answer selection) +[16]: https://h5p.org/documentation/setup/wordpress +[17]: https://h5p.org/documentation/for-authors/tutorials +[18]: https://h5p.org/MIT-licensed +[19]: https://github.com/h5p +[20]: https://h5p.org/developers diff --git a/sources/tech/20200526 FreeFileSync- Open Source File Synchronization Tool.md b/sources/tech/20200526 FreeFileSync- Open Source File Synchronization Tool.md new file mode 100644 index 0000000000..549751e002 --- /dev/null +++ b/sources/tech/20200526 FreeFileSync- Open Source File Synchronization Tool.md @@ -0,0 +1,140 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (FreeFileSync: Open Source File Synchronization Tool) +[#]: via: (https://itsfoss.com/freefilesync/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +FreeFileSync: Open Source File Synchronization Tool +====== + +_**Brief: FreeFileSync is an open-source folder comparison and sync tool with which you can back up your data to an external disk, a cloud service like Google Drive or any other storage path.**_ + +### FreeFileSync: A Free & Open-Source Tool To Sync Files + +![][1] + +[FreeFileSync][2] is an impressive open-source tool that can help you back up your data to a different location. + +This different location can be an external USB disk, Google Drive or to any of your cloud storage locations using **SFTP or FTP** connections. + +You might have read our tutorial on [how to use Google Drive on Linux][3] before. Unfortunately, there’s no proper FOSS solution to use Google Drive natively on Linux. There is [Insync][4] but it is a premium, non open source software. + +FreeFileSync can be used to sync files with your Google Drive account. In fact, I’m using it to sync my files to Google Drive and to a separate hard drive. + +### Features of FreeFileSync + +![][5] + +Even though the UI of FreeFileSync might look old school — it offers a ton of useful features for average users and advanced users as well. + +I’ll highlight all the features I can here: + + * Cross-platform support (Windows, macOS & Linux) + * Compare folders before synchronizing + * Supports Google Drive, [SFTP][6], and FTP connections + * Offers the ability to sync your files on a different storage path (or an external storage device) + * Multiple synchronization options available (Update files to the target from source or Mirror the files between target and source) + * Two-way synchronization supported (changes will be synced if there’s any modification on the target folder or the source folder) + * Version control available for advanced users + * Real-Time Sync option available + * Ability to schedule batch jobs + * Get notified via email when sync completes (paid) + * Portable edition (paid) + * Parallel file copy (paid) + + + +So, if you take a look at the features it offers, it’s not just any ordinary sync tool but offers so much more for free. + +Also, to give you an idea, you can also tweak how to compare the files before syncing them. For instance, you can compare the file content / file time or simply compare the file size of both source and target folder. + +![][7] + +You also get numerous synchronization options to mirror or update your data. Here’s how it looks like: + +![][8] + +However, it does give you the option to opt for a donation key which unlocks some special features like the ability to notify you via email when the sync completes and so on. + +Here’s what different between the free and paid version: + +![][9] + +So, most of the essential features is available for free. The premium features are mostly for advanced users and of course, if you want to support them (please do if you find it useful). + +Also, do note that the donation edition can be used by a single user on up to 3 devices. So, that is definitely not bad! + +### Installing FreeFileSync on Linux + +You can simply head on to its [official download page][10] and grab the **tar.gz** file for Linux. If you like you can download the source as well. + +![][11] + +Next, you just need to extract the archive and run the executable file to get started (as shown in the image above) + +[Download FreeFileSync][2] + +### How To Get Started With FreeFileSync? + +While I haven’t tried successfully creating an automatic sync job, it is pretty easy to use. + +The [official documentation][12] should be more than enough to get what you want using the software. + +But, just to give you a head start, here are a few things that you should keep in mind. + +![][13] + +As you can see in the screenshot above, you just have to select a source folder and the target folder to sync. You can choose a local folder or a cloud storage location. + +Once you do that, you need to tweak the type of folder comparison you want to do (usually the file time & size) for the synchronization process and on the right-side, you get to tweak the type of sync that you want to perform. + +#### Types of synchronization in FreeFileSync + +When you select **“Update” method for sync**, it simply copies your new data from the source folder to the target folder. So, even if you delete something from your source folder, it won’t get deleted on your target folder. + +In case you want the target folder to have the same file copies of your same folder, you can choose the **“Mirror”** **synchronization method**. So, here, if you delete something from your source, it gets deleted from your target folder as well. + +There’s also a **“Two-way” sync method** which detects changes on both source and target folder (instead of monitoring just the source folder). So, if you make any changes on the source/target folder, the modification will be synchronized. + +For more advanced usage, I suggest you to refer the [documentation][12] available. + +### Wrapping Up + +Another [open source file synchronization tool is Syncthing][14] that you might want to look at. + +FreeFileSync is a pretty underrated folder comparison and sync tool available for Linux users who utilize Google Drive, SFTP, or FTP connections along with separate storage locations for backup. + +And, all of that — with cross-platform support for Windows, macOS, and Linux available for free. + +Isn’t that exciting? Let me know your thoughts on FreeFileSync in the comments down below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/freefilesync/ + +作者:[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://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/free-file-sync.jpg?ssl=1 +[2]: https://freefilesync.org/ +[3]: https://itsfoss.com/use-google-drive-linux/ +[4]: https://itsfoss.com/recommends/insync/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/FreeFileSync.jpg?ssl=1 +[6]: https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol +[7]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-comparison.png?ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-synchronization.png?ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/free-file-sync-donation-edition.jpg?ssl=1 +[10]: https://freefilesync.org/download.php +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-run.jpg?ssl=1 +[12]: https://freefilesync.org/manual.php +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/05/freefilesync-tips.jpg?ssl=1 +[14]: https://itsfoss.com/syncthing/ diff --git a/sources/tech/20200527 Manage startup using systemd.md b/sources/tech/20200527 Manage startup using systemd.md new file mode 100644 index 0000000000..c0ff18a13d --- /dev/null +++ b/sources/tech/20200527 Manage startup using systemd.md @@ -0,0 +1,567 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Manage startup using systemd) +[#]: via: (https://opensource.com/article/20/5/manage-startup-systemd) +[#]: author: (David Both https://opensource.com/users/dboth) + +Manage startup using systemd +====== +Learn how systemd determines the order services start, even though it is +essentially a parallel system. +![Penguin with green background][1] + +While setting up a Linux system recently, I wanted to know how to ensure that dependencies for services and other units were up and running before those dependent services and units start. Specifically, I needed more knowledge of how systemd manages the startup sequence, especially in determining the order services are started in what is essentially a parallel system. + +You may know that SystemV (systemd's predecessor, as I explained in the [first article][2] in this series) orders the startup sequence by naming the startup scripts with an SXX prefix, where XX is a number from 00 to 99. SystemV then uses the sort order by name and runs each start script in sequence for the desired runlevel. + +But systemd uses unit files, which can be created or modified by a sysadmin, to define subroutines for not only initialization but also for regular operation. In the [third article][3] in this series, I explained how to create a mount unit file. In this fifth article, I demonstrate how to create a different type of unit file—a service unit file that runs a program at startup. You can also change certain configuration settings in the unit file and use the systemd journal to view the location of your changes in the startup sequence. + +### Preparation + +Make sure you have removed `rhgb` and `quiet` from the `GRUB_CMDLINE_LINUX=` line in the `/etc/default/grub` file, as I showed in the [second article][4] in this series. This enables you to observe the Linux startup message stream, which you'll need for some of the experiments in this article. + +### The program + +In this tutorial, you will create a simple program that enables you to observe a message during startup on the console and later in the systemd journal. + +Create the shell program `/usr/local/bin/hello.sh` and add the following content. You want to ensure that the result is visible during startup and that you can easily find it when looking through the systemd journal. You will use a version of the "Hello world" program with some bars around it, so it stands out. Make sure the file is executable and has user and group ownership by root with [700 permissions][5] for security: + + +``` +#!/usr/bin/bash +# Simple program to use for testing startup configurations +# with systemd. +# By David Both +# Licensed under GPL V2 +# +echo "###############################" +echo "######### Hello World! ########" +echo "###############################" +``` + +Run this program from the command line to verify that it works correctly: + + +``` +[root@testvm1 ~]# hello.sh +############################### +######### Hello World! ######## +############################### +[root@testvm1 ~]# +``` + +This program could be created in any scripting or compiled language. The `hello.sh` program could also be located in other places based on the [Linux filesystem hierarchical structure][6] (FHS). I place it in the `/usr/local/bin` directory so that it can be easily run from the command line without having to prepend a path when I type the command. I find that many of the shell programs I create need to be run from the command line and by other tools such as systemd. + +### The service unit file + +Create the service unit file `/etc/systemd/system/hello.service` with the following content. This file does not need to be executable, but for security, it does need user and group ownership by root and [644][7] or [640][8] permissions: + + +``` +# Simple service unit file to use for testing +# startup configurations with systemd. +# By David Both +# Licensed under GPL V2 +# + +[Unit] +Description=My hello shell script + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/hello.sh + +[Install] +WantedBy=multi-user.target +``` + +Verify that the service unit file performs as expected by viewing the service status. Any syntactical errors will show up here: + + +``` +[root@testvm1 ~]# systemctl status hello.service +● hello.service - My hello shell script +     Loaded: loaded (/etc/systemd/system/hello.service; disabled; vendor preset: disabled) +     Active: inactive (dead) +[root@testvm1 ~]# +``` + +You can run this "oneshot" service type multiple times without problems. The oneshot type is intended for services where the program launched by the service unit file is the main process and must complete before systemd starts any dependent process. + +There are seven service types, and you can find an explanation of each (along with the other parts of a service unit file) in the [systemd.service(5)][9] man page. (You can also find more information in the [resources][10] at the end of this article.) + +As curious as I am, I wanted to see what an error might look like. So, I deleted the "o" from the `Type=oneshot` line, so it looked like `Type=neshot`, and ran the command again: + + +``` +[root@testvm1 ~]# systemctl status hello.service +● hello.service - My hello shell script +     Loaded: loaded (/etc/systemd/system/hello.service; disabled; vendor preset: disabled) +     Active: inactive (dead) + +May 06 08:50:09 testvm1.both.org systemd[1]: /etc/systemd/system/hello.service:12: Failed to parse service type, ignoring: neshot +[root@testvm1 ~]# +``` + +These results told me precisely where the error was and made it very easy to resolve the problem. + +Just be aware that even after you restore the `hello.service` file to its original form, the error will persist. Although a reboot will clear the error, you should not have to do that, so I went looking for a method to clear out persistent errors like this. I have encountered service errors that require the command `systemctl daemon-reload` to reset an error condition, but that did not work in this case. The error messages that can be fixed with this command always seem to have a statement to that effect, so you know to run it. + +It is, however, recommended that you run `systemctl daemon-reload` after changing a unit file or creating a new one. This notifies systemd that the changes have been made, and it can prevent certain types of issues with managing altered services or units. Go ahead and run this command. + +After correcting the misspelling in the service unit file, a simple `systemctl restart hello.service` cleared the error. Experiment a bit by introducing some other errors into the `hello.service` file to see what kinds of results you get. + +### Start the service + +Now you are ready to start the new service and check the status to see the result. Although you probably did a restart in the previous section, you can start or restart a oneshot service as many times as you want since it runs once and then exits. + +Go ahead and start the service (as shown below), and then check the status. Depending upon how much you experimented with errors, your results may differ from mine: + + +``` +[root@testvm1 ~]# systemctl start hello.service +[root@testvm1 ~]# systemctl status hello.service +● hello.service - My hello shell script +     Loaded: loaded (/etc/systemd/system/hello.service; disabled; vendor preset: disabled) +     Active: inactive (dead) + +May 10 10:37:49 testvm1.both.org hello.sh[842]: ######### Hello World! ######## +May 10 10:37:49 testvm1.both.org hello.sh[842]: ############################### +May 10 10:37:49 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:37:49 testvm1.both.org systemd[1]: Finished My hello shell script. +May 10 10:54:45 testvm1.both.org systemd[1]: Starting My hello shell script... +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ######### Hello World! ######## +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +May 10 10:54:45 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:54:45 testvm1.both.org systemd[1]: Finished My hello shell script. +[root@testvm1 ~]# +``` + +Notice in the status command's output that the systemd messages indicate that the `hello.sh` script started and the service completed. You can also see the output from the script. This display is generated from the journal entries of the most recent invocations of the service. Try starting the service several times, and then run the status command again to see what I mean. + +You should also look at the journal contents directly; there are multiple ways to do this. One way is to specify the record type identifier, in this case, the name of the shell script. This shows the journal entries for previous reboots as well as the current session. As you can see, I have been researching and testing for this article for some time now: + + +``` +[root@testvm1 ~]# journalctl -t hello.sh +<snip> +\-- Reboot -- +May 08 15:55:47 testvm1.both.org hello.sh[840]: ############################### +May 08 15:55:47 testvm1.both.org hello.sh[840]: ######### Hello World! ######## +May 08 15:55:47 testvm1.both.org hello.sh[840]: ############################### +\-- Reboot -- +May 08 16:01:51 testvm1.both.org hello.sh[840]: ############################### +May 08 16:01:51 testvm1.both.org hello.sh[840]: ######### Hello World! ######## +May 08 16:01:51 testvm1.both.org hello.sh[840]: ############################### +\-- Reboot -- +May 10 10:37:49 testvm1.both.org hello.sh[842]: ############################### +May 10 10:37:49 testvm1.both.org hello.sh[842]: ######### Hello World! ######## +May 10 10:37:49 testvm1.both.org hello.sh[842]: ############################### +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ######### Hello World! ######## +May 10 10:54:45 testvm1.both.org hello.sh[1380]: ############################### +[root@testvm1 ~]# +``` + +To locate the systemd records for the `hello.service` unit, you can search on systemd. You can use **G+Enter** to page to the end of the journal entries and then scroll back to locate the ones you are interested in. Use the `-b` option to show only the entries for the most recent startup: + + +``` +[root@testvm1 ~]# journalctl -b -t systemd +<snip> +May 10 10:37:49 testvm1.both.org systemd[1]: Starting SYSV: Late init script for live image.... +May 10 10:37:49 testvm1.both.org systemd[1]: Started SYSV: Late init script for live image.. +May 10 10:37:49 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:37:49 testvm1.both.org systemd[1]: Finished My hello shell script. +May 10 10:37:50 testvm1.both.org systemd[1]: Starting D-Bus System Message Bus... +May 10 10:37:50 testvm1.both.org systemd[1]: Started D-Bus System Message Bus. +``` + +I copied a few other journal entries to give you an idea of what you might find. This command spews all of the journal lines pertaining to systemd—109,183 lines when I wrote this. That is a lot of data to sort through. You can use the pager's search facility, which is usually `less`, or you can use the built-in `grep` feature. The `-g` (or `--grep=`) option uses Perl-compatible regular expressions: + + +``` +[root@testvm1 ~]# journalctl -b -t systemd -g "hello" +[root@testvm1 ~]# journalctl -b -t systemd -g "hello" +\-- Logs begin at Tue 2020-05-05 18:11:49 EDT, end at Sun 2020-05-10 11:01:01 EDT. -- +May 10 10:37:49 testvm1.both.org systemd[1]: Starting My hello shell script... +May 10 10:37:49 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:37:49 testvm1.both.org systemd[1]: Finished My hello shell script. +May 10 10:54:45 testvm1.both.org systemd[1]: Starting My hello shell script... +May 10 10:54:45 testvm1.both.org systemd[1]: hello.service: Succeeded. +May 10 10:54:45 testvm1.both.org systemd[1]: Finished My hello shell script. +[root@testvm1 ~]# +``` + +You could use the standard GNU `grep` command, but that would not show the log metadata in the first line. + +If you do not want to see just the journal entries pertaining to your `hello` service, you can narrow things down a bit by specifying a time range. For example, I will start with the beginning time of `10:54:00` on my test VM, which was the start of the minute the entries above are from. ****Note that the `--since=` option must be enclosed in quotes and that this option can also be expressed as `-S "