mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-28 23:20:10 +08:00
commit
532308c47a
@ -3,44 +3,43 @@
|
||||
[#]: author: "Joël Krähemann https://opensource.com/users/joel2001k"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "Donkey-Hao"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: reviewer: " wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-15065-1.html"
|
||||
|
||||
使用开源库提升 C 语言编程能力
|
||||
使用开源库 GObject 和 libsoup 提升 C 语言编程能力
|
||||
======
|
||||
开源库 GObject 和 libsoup 已经做了很多工作,因此你可以专注于使用 C 语言开发神奇的应用。
|
||||
|
||||
![Why and how to handle exceptions in Python Flask][1]
|
||||
(图源: Unsplash.com, Creative Commons Zero)
|
||||
![](https://img.linux.net.cn/data/attachment/album/202209/24/145218s1s1xk6s1mm2kg1x.jpg)
|
||||
|
||||
[GLib Object System (GObject)][2] 是为 C 语言提供了灵活且可扩展的面向对象框架的库。在这篇文章中,我将使用该库的 2.4 版本进行演示。
|
||||
> 开源库 GObject 和 libsoup 做了很多工作,因此你可以专注于使用 C 语言开发神奇的应用。
|
||||
<ruby>[GLib 对象系统][2]<rt>Object System</rt></ruby>(GObject)是一个为 C 语言提供灵活且可扩展的面向对象框架的库。在这篇文章中,我将使用该库的 2.4 版本进行演示。
|
||||
|
||||
GObject 库继承了 ANSI C 标准,拥有一些常见的数据类型,例如:
|
||||
|
||||
* gchar: 字符型
|
||||
* guchar: 无符号字符型
|
||||
* gunichar: 宽为 32 比特的 Unicode 字符型
|
||||
* gboolean: 布尔型
|
||||
* gint8, gint16, gint32, gint64: 8, 16, 32 和 64 比特有符号整数
|
||||
* guint8, guint16, guint32, guint64: 无符号 8, 16, 32 和 64 比特整数
|
||||
* gfloat: IEEE 754 标准单精度浮点数
|
||||
* gdouble: IEEE 754 标准 双精度浮点数
|
||||
* gpointer: 泛指针
|
||||
* `gchar`:字符型
|
||||
* `guchar`:无符号字符型
|
||||
* `gunichar`:32 位定宽 Unicode 字符型
|
||||
* `gboolean`:布尔型
|
||||
* `gint8`、`gint16`、`gint32`、`gint64`:有符号 8、16、32 和 64 位整数
|
||||
* `guint8`、`guint16`、`guint32`、`guint64`:无符号 8、16、32 和 64 位整数
|
||||
* `gfloat`:IEEE 754 标准单精度浮点数
|
||||
* `gdouble`:IEEE 754 标准双精度浮点数
|
||||
* `gpointer`:泛指针
|
||||
|
||||
### 函数指针
|
||||
|
||||
GObject 库还引入了类和接口的类型和对象体系。这是可能的,因为 ANSI C 语言理解函数指针。
|
||||
GObject 库还引入了类和接口的类型和对象体系。之所以可以,是因为 ANSI C 语言可以理解函数指针。
|
||||
|
||||
你可以这样做来声明函数指针:
|
||||
|
||||
```c
|
||||
```
|
||||
void (*my_callback)(gpointer data);
|
||||
```
|
||||
|
||||
首先,你需要给变量 `my_callback` 赋值:
|
||||
|
||||
```c
|
||||
```
|
||||
void my_callback_func(gpointer data)
|
||||
{
|
||||
//do something
|
||||
@ -51,7 +50,7 @@ my_callback = my_callback_func;
|
||||
|
||||
函数指针 `my_callback` 可以这样来调用:
|
||||
|
||||
```c
|
||||
```
|
||||
gpointer data;
|
||||
data = g_malloc(512 * sizeof(gint16));
|
||||
my_callback(data);
|
||||
@ -59,11 +58,11 @@ my_callback(data);
|
||||
|
||||
### 对象类
|
||||
|
||||
GObject 基类由 2 个结构(`GObject` 和 `GObjectClass`)组成,你可以继承它们以实现你自己的对象。
|
||||
`GObject` 基类由 2 个结构(`GObject` 和 `GObjectClass`)组成,你可以继承它们以实现你自己的对象。
|
||||
|
||||
你需要在结构体中先嵌入 `GObject` 和 `GObjectClass` :
|
||||
你需要在结构体中先嵌入 `GObject` 和 `GObjectClass`:
|
||||
|
||||
```c
|
||||
```
|
||||
struct _MyObject
|
||||
{
|
||||
GObject gobject;
|
||||
@ -79,11 +78,11 @@ struct _MyObjectClass
|
||||
GType my_object_get_type(void);
|
||||
```
|
||||
|
||||
对象的实现包含了公有成员。GObject 也提供了私有成员的方法。这实际上是 C 源文件中的一个结构,而不是头文件。该类通常只包含函数指针。
|
||||
对象的实现包含了公有成员。GObject 也提供了私有成员的方法。这实际上是 C 源文件中的一个结构,而不是在头文件。该类通常只包含函数指针。
|
||||
|
||||
一个接口不能派生自另一个接口,比如:
|
||||
|
||||
```c
|
||||
```
|
||||
struct _MyInterface
|
||||
{
|
||||
GInterface ginterface;
|
||||
@ -93,7 +92,7 @@ struct _MyInterface
|
||||
|
||||
通过调用 `g_object_get()` 和 `g_object_set()` 函数来访问属性。若要获取属性,你必须提供特定类型的返回位置。建议先初始化返回位置:
|
||||
|
||||
```c
|
||||
```
|
||||
gchar *str
|
||||
|
||||
str = NULL;
|
||||
@ -105,7 +104,7 @@ g_object_get(gobject,
|
||||
|
||||
或者你想要设置属性:
|
||||
|
||||
```c
|
||||
```
|
||||
g_object_set(gobject,
|
||||
"my-name", "Anderson",
|
||||
NULL);
|
||||
@ -113,9 +112,11 @@ g_object_set(gobject,
|
||||
|
||||
### libsoup HTTP 库
|
||||
|
||||
`libsoup` 项目为 GNOME 提供了 HTTP 客服端和服务端使用的库。它使用 GObjects 和 glib 主循环与 GNOME 应用融合,并且还具有用于命令行的同步 API。首先,创建一个特定身份验证回调的 `libsoup` 会话。你也可以使用 cookie。
|
||||
`libsoup` 项目为 GNOME 提供了 HTTP 客服端和服务端使用的库。它使用 GObjects 和 glib 主循环与集成到 GNOME 应用,并且还具有用于命令行的同步 API。
|
||||
|
||||
```c
|
||||
首先,创建一个特定身份验证回调的 `libsoup` 会话。你也可以使用 cookie。
|
||||
|
||||
```
|
||||
SoupSession *soup_session;
|
||||
SoupCookieJar *jar;
|
||||
|
||||
@ -133,7 +134,7 @@ g_signal_connect(soup_session, "authenticate",
|
||||
|
||||
然后你可以像这样创建一个 HTTP GET 请求:
|
||||
|
||||
```c
|
||||
```
|
||||
SoupMessage *msg;
|
||||
SoupMessageHeaders *response_headers;
|
||||
SoupMessageBody *response_body;
|
||||
@ -180,8 +181,7 @@ if(status == 200){
|
||||
|
||||
这是一个函数签名:
|
||||
|
||||
|
||||
```c
|
||||
```
|
||||
#define MY_AUTHENTICATE_LOGIN "my-username"
|
||||
#define MY_AUTHENTICATE_PASSWORD "my-password"
|
||||
|
||||
@ -200,11 +200,11 @@ void my_authenticate_callback(SoupSession *session,
|
||||
|
||||
### 一个 libsoup 服务器
|
||||
|
||||
想要基础的 HTTP 身份认证能够运行,你需要指定回调函数和服务器内容路径。然后再添加一个带有另一个回调的处理程序。
|
||||
想要基础的 HTTP 身份认证能够运行,你需要指定回调函数和服务器上下文路径。然后再添加一个带有另一个回调的处理程序。
|
||||
|
||||
下面这个例子展示了在 8080 端口监听任何 IPv4 地址的消息:
|
||||
|
||||
```c
|
||||
```
|
||||
SoupServer *soup_server;
|
||||
SoupAuthDomain *auth_domain;
|
||||
GSocket *ip4_socket;
|
||||
@ -248,9 +248,9 @@ soup_server_listen_socket(soup_server,
|
||||
|
||||
示例代码中,有两个回调函数。一个处理身份认证,另一个处理对它的请求。
|
||||
|
||||
假设你想要网页服务器运行一个用户名为 **my-username** 和口令为 **my-password** 的用户登录,并且用一个随机且唯一的用户 ID 字符串设置会话 cookie。
|
||||
假设你想要网页服务器允许用户名为 `my-username` 和口令为 `my-password` 的凭证登录,并且用一个随机且唯一的用户 ID 字符串设置会话 cookie。
|
||||
|
||||
```c
|
||||
```
|
||||
gboolean my_xmlrpc_server_auth_callback(SoupAuthDomain *domain,
|
||||
SoupMessage *msg,
|
||||
const char *username,
|
||||
@ -285,9 +285,9 @@ gboolean my_xmlrpc_server_auth_callback(SoupAuthDomain *domain,
|
||||
}
|
||||
```
|
||||
|
||||
对内容路径 **my-xmlrpc** 进行处理的函数:
|
||||
对上下文路径 `my-xmlrpc` 进行处理的函数:
|
||||
|
||||
```c
|
||||
```
|
||||
void my_xmlrpc_server_callback(SoupServer *soup_server,
|
||||
SoupMessage *msg,
|
||||
const char *path,
|
||||
@ -303,7 +303,7 @@ void my_xmlrpc_server_callback(SoupServer *soup_server,
|
||||
|
||||
### 更加强大的 C 语言
|
||||
|
||||
希望我的示例展现了 GObject 和 libsoup 项目给 C 语言带来了真正的提升。像这样在字面意义上扩展 C 语言,可以使 C 语言更易于使用。他们已经为你做了许多工作,这样你可以专注于用 C 语言开发简单、直接的应用程序了。
|
||||
希望我的示例展现了 GObject 和 libsoup 项目给 C 语言带来了真正的提升。像这样在字面意义上扩展 C 语言,可以使 C 语言更易于使用。它们已经为你做了许多工作,这样你可以专注于用 C 语言开发简单、直接的应用程序了。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -312,7 +312,7 @@ via: https://opensource.com/article/22/5/libsoup-gobject-c
|
||||
作者:[Joël Krähemann][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[Donkey-Hao](https://github.com/Donkey-Hao)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -3,25 +3,30 @@
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "geekpi"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-15067-1.html"
|
||||
|
||||
在 Arch Linux 和其他发行版中使用终端连接到 WiFi
|
||||
======
|
||||
本快速指南介绍了在 Arch Linux 和其他发行版中使用终端设置和连接 WiFi 所需的步骤。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202209/24/185145fcas1rje3f8pr8sa.jpg)
|
||||
|
||||
> 本快速指南介绍了在 Arch Linux 和其他发行版中使用终端设置和连接 WiFi 所需的步骤。
|
||||
|
||||
本指南非常适合没有 GUI 只有终端且没有其他有线互联网连接可用的情况。这些步骤可帮助你手动检测无线网卡和设备,并通过终端密码验证连接到 WiFi 热点。
|
||||
|
||||
本指南使用 [iwd][1] (Net Wireless Daemon) 通过终端连接到 WiFi。
|
||||
本指南使用 [iwd][1](Net Wireless Daemon)通过终端连接到 WiFi。
|
||||
|
||||
### 在 Arch Linux 和其他发行版中使用终端连接到 WiFi
|
||||
|
||||
#### 1. 设置 iwd
|
||||
#### 1、设置 iwd
|
||||
|
||||
`iwd` 包有三个主要模块:
|
||||
|
||||
**iwctl**:无线客户端,**iwd**:守护进程,**iwmon**:监控工具
|
||||
- `iwctl`:无线客户端
|
||||
- `iwd`:守护进程
|
||||
- `iwmon`:监控工具
|
||||
|
||||
在终端中输入:
|
||||
|
||||
@ -31,35 +36,35 @@ iwctl
|
||||
|
||||
![iwctl 提示符][2]
|
||||
|
||||
如果找不到命令,那么需要从[此处][3]下载安装包。
|
||||
如果找不到该命令,那么需要从 [此处][3] 下载安装包。
|
||||
|
||||
从任何其他具有 Internet 连接的系统/笔记本电脑获取帮助,以通过安装 USB 下载和安装软件包。
|
||||
从任何其他具有互联网连接的系统/笔记本电脑获取帮助,以通过安装 USB 下载和安装软件包。
|
||||
|
||||
或者,如果你有一个可连接互联网的 USB 适配器,那么将其插入你的系统。并通过以下命令安装。
|
||||
或者,如果你有一个可连接互联网的 USB 网卡,那么将其插入你的系统。并通过以下命令安装。
|
||||
|
||||
USB 适配器应该在 Arch 和当今大多数 Linux 系统中开箱即用,以连接到互联网。
|
||||
USB 网卡应该可以在 Arch 和当今大多数 Linux 系统中开箱即用,连接到互联网。
|
||||
|
||||
**Arch**
|
||||
**Arch:**
|
||||
|
||||
```
|
||||
pacman -S iwd
|
||||
```
|
||||
|
||||
**Debian、Ubuntu 和其他类似发行版**
|
||||
**Debian、Ubuntu 和其他类似发行版:**
|
||||
|
||||
```
|
||||
sudo apt-get install iwd
|
||||
```
|
||||
|
||||
**Fedora**
|
||||
**Fedora:**
|
||||
|
||||
```
|
||||
sudo dnf install iwd
|
||||
```
|
||||
|
||||
如果你收到 `iwctl` 提示符(如下所示),那么继续下一步。
|
||||
如果你看到了 `iwctl` 提示符(如下所示),那么继续下一步。
|
||||
|
||||
#### 2. 配置
|
||||
#### 2、配置
|
||||
|
||||
运行以下命令以获取系统的**无线设备名称**。
|
||||
|
||||
@ -79,15 +84,15 @@ station wlan0 get-networks
|
||||
|
||||
该命令为你提供具有安全类型和信号强度的可用 WiFi 网络列表。
|
||||
|
||||
#### 连接
|
||||
#### 3、连接
|
||||
|
||||
要**连接到 WiFi 网络**,请使用上述 “get-networks” 命令中的 WiFi 接入点名称运行以下命令。
|
||||
要**连接到 WiFi 网络**,请使用上述 `get-networks` 命令中的 WiFi 接入点名称运行以下命令。
|
||||
|
||||
```
|
||||
station wlan0 connect
|
||||
```
|
||||
|
||||
出现提示符时输入你的 WiFi 密码。
|
||||
出现提示时输入你的 WiFi 密码。
|
||||
|
||||
![使用 iwctl 连接到 WiFi][6]
|
||||
|
||||
@ -95,27 +100,25 @@ station wlan0 connect
|
||||
|
||||
### 使用指南
|
||||
|
||||
* 如下所示,你可以使用简单的 ping 命令检查连接。ping 回复成功的数据包传输表示连接稳定。
|
||||
如下所示,你可以使用简单的 `ping` 命令检查连接。`ping` 回复成功的数据包传输表示连接稳定。
|
||||
|
||||
```
|
||||
ping -c 3 google.com
|
||||
```
|
||||
|
||||
* 你还可以使用以下命令检查连接状态。
|
||||
你还可以使用以下命令检查连接状态。
|
||||
|
||||
```
|
||||
station wlan0 show
|
||||
```
|
||||
|
||||
* iwd 在 `/var/lib/iwd` 中保存 `.psk` 后缀的配置文件,其中带有你的接入点名称。
|
||||
`iwd` 在 `/var/lib/iwd` 中保存 `.psk` 后缀的配置文件,其中带有你的接入点名称。此文件包含使用你的 WiFi 网络的密码和 SSID 生成的哈希文件。
|
||||
|
||||
* 此文件包含使用你的 WiFi 网络的密码和 SSID 生成的哈希文件。
|
||||
|
||||
* 按 `CTRL+D` 退出 `iwctl` 提示符。
|
||||
按 `CTRL+D` 退出 `iwctl` 提示符。
|
||||
|
||||
### 总结
|
||||
|
||||
我希望本指南可以帮助你通过终端连接到互联网。当你没有其他方式连接到 WiFi 时,这会有所帮助。例如,如果你在独立系统(不是 VM)中安装 Arch Linux,那么需要连接到 Internet 以通过终端使用 pacman 下载软件包。
|
||||
我希望本指南可以帮助你通过终端连接到互联网。当你没有其他方式连接到 WiFi 时,这会有所帮助。例如,如果你在独立系统(不是 VM)中安装 Arch Linux,那么需要连接到互联网以通过终端使用 `pacman` 下载软件包。
|
||||
|
||||
如果你遇到任何问题,请在下面的评论栏中指出错误消息。
|
||||
|
||||
@ -126,7 +129,7 @@ via: https://www.debugpoint.com/connect-wifi-terminal-linux/
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][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/) 荣誉推出
|
||||
|
114
published/20220923 Systemd is Now Available in WSL.md
Normal file
114
published/20220923 Systemd is Now Available in WSL.md
Normal file
@ -0,0 +1,114 @@
|
||||
[#]: subject: "systemd is Now Available in WSL"
|
||||
[#]: via: "https://news.itsfoss.com/systemd-wsl/"
|
||||
[#]: author: "Sourav Rudra https://news.itsfoss.com/author/sourav/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "vvvbbbcz"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-15068-1.html"
|
||||
|
||||
systemd 已可用于 WSL
|
||||
======
|
||||
|
||||
> 微软的 WSL 现已支持 systemd,为用户提供了更好的体验。你可阅读此文了解更多。
|
||||
|
||||
![systemd 已可用于 WSL][1]
|
||||
|
||||
WSL(<ruby>Windows 的 Linux 子系统<rt>Windows Subsystem for Linux</rt></ruby>)终于拥有了对 systemd 的支持,这是在 systemd 的创建者加入微软的几个月后实现的。
|
||||
|
||||
> **[更多 Linux 开发者们加入微软,systemd 的创建者也加入这一行列][2]**
|
||||
|
||||
而这已通过微软和 Cannonical 的合作成为可能。
|
||||
|
||||
> **如果你好奇 systemd 是什么**:
|
||||
>
|
||||
> systemd 是一套 Linux 系统的基本组成模块。它提供了一个系统和服务管理器,作为 PID 1 运行,并启动系统的其他部分。
|
||||
>
|
||||
> 来自:systemd.io
|
||||
|
||||
它作为一个初始化系统,启动并维持用户空间其他服务的正常运行。
|
||||
|
||||
让我们看看它是如何被引入 WSL 的。
|
||||
|
||||
### systemd 增强 WSL 的体验
|
||||
|
||||
![WSL: 与 Cannonical 合作以支持 systemd][4]
|
||||
|
||||
在 WSL 中引入 systemd,主要是为改善 Windows 机器上的 Linux 工作流程。
|
||||
|
||||
像 Debian、Ubuntu、Fedora 等,都是默认运行 systemd 的。因此,这项整合将使这些发行版的用户更方便地在 WSL 上做更多工作。
|
||||
|
||||
很多关键的 Linux 程序也是靠 systemd 实现的。例如 snap、microk8s 和 LXD 都依赖它。
|
||||
|
||||
即使我们有 [不含 systemd 的发行版][5] 可用,它们也并不适合所有人。因此,在 WSL 上添加对 systemd 的支持是很有意义的。
|
||||
|
||||
systemd 的存在也使得在 Windows 中使用更多工具来测试和运行成为可能,从而带来更好的 WSL 体验。
|
||||
|
||||
### 它是如何实现的
|
||||
|
||||
WSL 背后的团队必须修改其架构,它们让 WSL 的初始化进程在 Linux 发行版中以 systemd 的一个子进程启动。
|
||||
|
||||
正如其 [官方公告][7] 所述,这样做使得 WSL 初始化程序能够为 Windows 和 Linux 子系统之间的通讯提供必要的基础。
|
||||
|
||||
它们还做了额外的修改,通过防止 systemd 保持 WSL 实例的活动以确保系统的干净关机。
|
||||
|
||||
你亦可访问他们的 [官方文档][8] 以了解更多。
|
||||
|
||||
### 在 WSL 上使用 systemd
|
||||
|
||||
> 现有的 WSL 用户必须在他们的系统上手动启用 systemd,以防止由于 systemd 的引入而导致的启动问题。
|
||||
|
||||
首先,你必须确保你的系统运行的是 **0.67.6** 或更高版本的 WSL。
|
||||
|
||||
你可以通过以下命令检查你的 WSL 版本。
|
||||
|
||||
```
|
||||
wsl --version
|
||||
```
|
||||
|
||||
如果你正在运行旧版本,你可以通过 <ruby>微软应用商店<rt>Microsoft Store</rt></ruby> 或者以下命令更新它。
|
||||
|
||||
```
|
||||
wsl --update
|
||||
```
|
||||
|
||||
此外,如果你不是 <ruby>Windows 预览体验成员<rt>Windows Insider</rt></ruby>,你可以到 [WSL 发行页面][9] 下载它来体验。
|
||||
|
||||
为了让 systemd 在你的系统上运行,你需要修改 [wsl.conf][10] 这个文件以确保 systemd 在启动时运行。
|
||||
|
||||
在 `wsl.conf` 添加以下几行以使 WSL 在启动时运行 systemd
|
||||
|
||||
```
|
||||
[boot]
|
||||
systemd=true
|
||||
```
|
||||
|
||||
最后,重启你的 WSL 实例以见证更改。
|
||||
|
||||
随着对 systemd 的支持,微软在 WSL 的发展又前进了一大步,这将使得 WSL 吸引更多用户。
|
||||
|
||||
*💬 是否对 WSL 支持 systemd 感到兴奋?或是你更喜欢无 systemd 的发行版?*
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/systemd-wsl/
|
||||
|
||||
作者:[Sourav Rudra][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[vvvbbbcz](https://github.com/vvvbbbcz)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/sourav/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://news.itsfoss.com/content/images/size/w1200/2022/09/systemd-now-available-on-wsl.png
|
||||
[2]: https://news.itsfoss.com/systemd-creator-microsoft/
|
||||
[3]: https://news.itsfoss.com/systemd-creator-microsoft/
|
||||
[4]: https://youtu.be/Ja3qikzd-as
|
||||
[5]: https://itsfoss.com/systemd-free-distros/
|
||||
[6]: https://itsfoss.com/systemd-free-distros/
|
||||
[7]: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
|
||||
[8]: https://learn.microsoft.com/en-in/windows/wsl/
|
||||
[9]: https://github.com/microsoft/WSL/releases
|
||||
[10]: https://learn.microsoft.com/en-in/windows/wsl/wsl-config#wslconf
|
@ -1,114 +0,0 @@
|
||||
[#]: subject: "Systemd is Now Available in WSL"
|
||||
[#]: via: "https://news.itsfoss.com/systemd-wsl/"
|
||||
[#]: author: "Sourav Rudra https://news.itsfoss.com/author/sourav/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Systemd is Now Available in WSL
|
||||
======
|
||||
Microsoft's WSL now supports systemd making the experience better for users.
|
||||
Learn more about it here.
|
||||
|
||||
![Systemd is Now Available in WSL][1]
|
||||
|
||||
WSL (Windows Subsystem for Linux) has finally received support for Systemd, this comes in a few months after its creator joined Microsoft.
|
||||
|
||||
[More Linux Developers Joining Microsoft, Systemd Creator Adds to the List][2]
|
||||
|
||||
And this has been made possible with a partnership between Microsoft and Canonical.
|
||||
|
||||
**In case you're curious**:
|
||||
|
||||
It acts as an init system that starts up and keeps user space services in running order.
|
||||
|
||||
Let's see how it has been introduced to WSL.
|
||||
|
||||
### Systemd Enhancing the WSL Experience
|
||||
|
||||
![WSL: Partnering with Canonical to support systemd][4]
|
||||
|
||||
The main focus of introducing systemd to WSL is to improve the Linux workflow on Windows machines.
|
||||
|
||||
The likes of Debian, Ubuntu, Fedora, and more run systemd by default. So, this integration will now make it even more straightforward for users of those distros to conveniently do more with WSL.
|
||||
|
||||
Even though we have systemd-free distros available, it is not meant for everyone. So, the support for systemd on WSL makes sense.
|
||||
|
||||
A lot of critical Linux applications also rely on systemd to be functional. For instance, '**snap**', '**microk8s**' and '**LXD**' are dependent on it.
|
||||
|
||||
The presence of systemd also makes it possible to use more tools to test and run from within Windows, resulting in a better WSL experience.
|
||||
|
||||
#### Suggested Read 📖
|
||||
|
||||
[14 Best Systemd-Free Linux Distributions][5]
|
||||
|
||||
### Here's How It Was Made Possible
|
||||
|
||||
The team behind WSL had to make changes to the architecture, they made the WSL init process start within the Linux distro as a child process under systemd.
|
||||
|
||||
Doing so enabled the WSL init process to provide the necessary foundation for communication between the Windows and Linux sub-systems, as explained in their [official announcement][7].
|
||||
|
||||
They also did additional modifications to ensure a clean system shutdown by preventing systemd from keeping the WSL instance active.
|
||||
|
||||
You can also visit their official [documentation][8] website for more information.
|
||||
|
||||
### Get Started With Systemd on WSL
|
||||
|
||||
> Existing WSL users will have to opt in to enable systemd on their systems, this step was taken to avoid any booting issues that might occur due to the introduction of systemd.
|
||||
|
||||
First and foremost, you have to ensure that your system is running WSL: **Version 0.67.6** or above.
|
||||
|
||||
You can check your WSL version by running the following command
|
||||
|
||||
```
|
||||
wsl --version
|
||||
```
|
||||
|
||||
If you are running the older version, you can update it via the **Microsoft Store** or by running this command.
|
||||
|
||||
```
|
||||
wsl --update
|
||||
```
|
||||
|
||||
Furthermore, if you are not a part of Windows Insiders, you can go to the [WSL release page][9] and download it to test it out.
|
||||
|
||||
For systemd to work on your system, you will have to edit the '[wsl.conf][10]' file to ensure that systemd starts up on boot.
|
||||
|
||||
Add the following lines to make WSL run systemd on boot.
|
||||
|
||||
```
|
||||
[boot]
|
||||
systemd=true
|
||||
```
|
||||
|
||||
Finally, restart your WSL instance to see the changes.
|
||||
|
||||
Microsoft has taken a big step forward in the development of WSL with the implementation of systemd, this should result in more users being attracted to WSL.
|
||||
|
||||
*💬 Excited to run WSL with systemd? Or do you prefer systemd-free distros?*
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/systemd-wsl/
|
||||
|
||||
作者:[Sourav Rudra][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/sourav/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://news.itsfoss.com/content/images/size/w1200/2022/09/systemd-now-available-on-wsl.png
|
||||
[2]: https://news.itsfoss.com/systemd-creator-microsoft/
|
||||
[3]: https://news.itsfoss.com/systemd-creator-microsoft/
|
||||
[4]: https://youtu.be/Ja3qikzd-as
|
||||
[5]: https://itsfoss.com/systemd-free-distros/
|
||||
[6]: https://itsfoss.com/systemd-free-distros/
|
||||
[7]: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
|
||||
[8]: https://learn.microsoft.com/en-in/windows/wsl/
|
||||
[9]: https://github.com/microsoft/WSL/releases
|
||||
[10]: https://learn.microsoft.com/en-in/windows/wsl/wsl-config#wslconf
|
@ -1,66 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (MareDevi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How open source builds distributed trust)
|
||||
[#]: via: (https://opensource.com/article/21/1/open-source-distributed-trust)
|
||||
[#]: author: (Mike Bursell https://opensource.com/users/mikecamel)
|
||||
|
||||
How open source builds distributed trust
|
||||
======
|
||||
Trust in open source is a positive feedback loop.
|
||||
![Trust][1]
|
||||
|
||||
This is an edited excerpt from my forthcoming book on _Trust in Computing and the Cloud_ for [Wiley][2] and leads on from a previous article I wrote called [_Trust & choosing open source_][3].
|
||||
|
||||
In that article, I asked the question: What are we doing when we say, "I trust open source software"? In reply, I suggested that what we are doing is making a determination that enough of the people who have written and tested it have similar requirements to mine, and that their expertise, combined, is such that the risk to my using the software is acceptable. I also introduced the idea of _distributed trust_.
|
||||
|
||||
The concept of distributing trust across a community is an application of the _wisdom of the crowd_ theory posited by Aristotle, where the assumption is that the opinions of many typically show more wisdom than the opinion of one or a few. While demonstrably false in its simplest form in some situations—the most obvious example being examples of popular support for totalitarian regimes—this principle can provide a very effective mechanism for establishing certain information.
|
||||
|
||||
This distillation of collective experience allows what we refer to as _distributed trust_ and is collected through numerous mechanisms on the internet. Some, like TripAdvisor or Glassdoor, record information about organisations or the services they provide, while others, like UrbanSitter or LinkedIn, allow users to add information about specific people (see, for instance, LinkedIn's Recommendations and Skills & Endorsements sections in individuals' profiles). The benefits that can accrue from these examples are significantly increased by the network effect, as the number of possible connections between members increases exponentially as the number of members increases.
|
||||
|
||||
Other examples of distributed trust include platforms like Twitter, where the number of followers that an account receives can be seen as a measure of its reputation and even of its trustworthiness, a calculation which we should view with a strong degree of scepticism. Indeed, Twitter felt that it had to address the social power of accounts with large numbers of followers and instituted a "verified accounts" mechanism to let people know that "an account of public interest is authentic." Interestingly, the company had to suspend the service after problems related to users' expectations of exactly what "verified" meant or implied: a classic case of differing understanding of context between different groups.
|
||||
|
||||
Where is the relevance to open source, then? The community aspect of open source is actually a driver towards building distributed trust. This is because, once you become a part of the community around an open source project, you assume one or more of the roles that you start trusting once you say that you "trust" an open source project (see my previous article). Examples include architect, designer, developer, reviewer, technical writer, tester, deployer, bug reporter, or bug fixer. The more involvement you have in a project, the more you become part of the community, which can, in time, become a _community of practice_.
|
||||
|
||||
Jean Lave and Etienne Wenger introduced the concept of communities of practice in the book _[Situated Learning: Legitimate Peripheral Participation][4]_, where groups evolve into communities as their members share a passion and participate in shared activities, leading to improving their skills and knowledge together. The core concept here is that as participants learn _around_ a community of practice, they become members of it at the same time:
|
||||
|
||||
> "Legitimate peripheral participation refers both to the development of knowledgeably skilled identities in practice and to the reproduction and transformation of communities of practice."
|
||||
|
||||
Wenger further explored the concept of communities of practice, how they form, requirements for their health, and how they encourage learning in _[Communities of Practice: Learning, Meaning, and Identity][5]_. He identified _negotiability of meaning_ ("why are we working together, what are we trying to achieve?") as core to a community of practice and noted that without _engagement_, _imagination_, and _alignment_ by individuals, communities of practice will not be robust.
|
||||
|
||||
We can align this with our views of how distributed trust is established and built: when you realise that your impact on open source can be equal to that of others, the distributed trust relationships that you hold to members of a community become less transitive (second- or third-hand or even more remote) and more immediate. You understand that the impact you can have on the creation, maintenance, requirements, and quality of the software you are running can be the same as all of the other, previously anonymous contributors with whom you are now forming a community of practice or whose existing community of practice you are joining. Then you become part of a network of trust relationships that are distributed but less removed from what you experience when buying and operating proprietary software.
|
||||
|
||||
The process does not stop there; as a common property of open source projects is cross-pollination, where developers from one project also work on others. This increases as the network effect of multiple open source projects allows reuse and dependencies on other projects to rise and leads to greater take-up across the entire set of projects.
|
||||
|
||||
It is easy to see why many open source contributors become open source enthusiasts or evangelists, not just for a single project but for open source as a whole. In fact, work by Stanford sociologist [Mark Granovetter][6] suggests that too many strong ties within communities can lead to cliques and stagnation, but weak ties provide movement of ideas and trends around communities. This awareness of other projects and the communities that exist around them and the flexibility of ideas across projects leads to distributed trust being able to be extended (albeit with weaker assurances) beyond the direct or short-chain indirect relationships that contributors experience within projects where they have immediate experience and out towards other projects where external observation or peripheral involvement shows that similar relationships exist between contributors.
|
||||
|
||||
Put simply, the act of being involved in an open source project and building trust relationships through participation leads to stronger distributed trust towards similar open source projects or just to other projects that are similarly open source.
|
||||
|
||||
What does this mean for each of us? It means that the more we get involved in open source, the more trust we can have in open source, as there will be a corresponding growth in the involvement—and therefore trust—of other people in open source. Trust in open source isn't just a network effect: it's a positive feedback loop!
|
||||
|
||||
* * *
|
||||
|
||||
_This article was originally published on [Alice, Eve, and Bob][7] and is reprinted with the author's permission._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/open-source-distributed-trust
|
||||
|
||||
作者:[Mike Bursell][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/mikecamel
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_trust.png?itok=KMfi0Rdo (Trust)
|
||||
[2]: https://wiley.com/
|
||||
[3]: https://aliceevebob.com/2019/06/18/trust-choosing-open-source/
|
||||
[4]: https://books.google.com/books/about/Situated_Learning.html?id=CAVIOrW3vYAC
|
||||
[5]: https://books.google.com/books?id=Jb8mAAAAQBAJ&dq=Communities%20of%20Practice:%20Learning,%20meaning%20and%20identity&lr=
|
||||
[6]: https://en.wikipedia.org/wiki/Mark_Granovetter
|
||||
[7]: https://aliceevebob.com/2020/11/17/how-open-source-builds-distributed-trust/
|
@ -0,0 +1,67 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (MareDevi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How open source builds distributed trust)
|
||||
[#]: via: (https://opensource.com/article/21/1/open-source-distributed-trust)
|
||||
[#]: author: (Mike Bursell https://opensource.com/users/mikecamel)
|
||||
|
||||
开源如何构建分布式信任
|
||||
======
|
||||
对开源的信任是一个积极的反馈循环。
|
||||
![信任][1]
|
||||
|
||||
这是我即将为[Wiley][2]出版的《计算和云计算中的信任》(Trust in Computing and the Cloud)一书中经过编辑的节选,也是我之前写的一篇文章[_《信任与选择开源》_][3](_Trust & choosing open source_)的延伸。
|
||||
|
||||
在那篇文章中,我提出了一个问题。当我们说 "我相信开放源码软件 "时,我们在做什么?作为回答,我认为,我们正在做的是确定有足够多的编写和测试该软件的人与我有类似的要求,而且他们的专业知识加在一起,使我使用该软件的风险可以接受。我同时也介绍了 "分布式信任 "的概念。
|
||||
|
||||
|
||||
在社区内分配信任的概念是亚里士多德提出的“人群智慧理论”的应用,其中的假设是,许多人的意见通常比一个人或少数人的意见更有明智。虽然在某些情况下,最简单的形式显然是错误的——最明显的例子是民众对极权主义政权的支持——但这一原则可以提供一个非常有效的机制来建立某些信息。
|
||||
|
||||
我们称这种集体经验的提炼为“分布式信任”,它通过互联网上的许多机制收集。如TripAdvisor或Glassdoor,记录了关于组织或其提供的服务的信息,还有像UrbanSitter或LinkedIn,允许用户添加关于特定人的信息(例如,见LinkedIn的推荐和技能与个人档案中的认可部分)。从这些例子中可以获得的利益因网络效应而大大增加,因为随着成员数量的增加,成员之间可能的联系数量也成倍增加。
|
||||
|
||||
分布式信任的例子还包括像Twitter这样的平台,一个账户的追随者数量可以被视为衡量其声誉,甚至是衡量其可信度的标准,我们应该以强烈的怀疑态度去看待这种计算。 事实上,Twitter认为它必须解决拥有大量追随者的账户的社会力量问题,并建立了一个为 "验证账户 "机制,让人们知道 "一个具有公共利益的账户是真实的"。但是有趣的是,该公司不得不暂停这项服务,因为用户对 "验证 "的确切含义或暗示的期望出现了问题:这就是不同群体之间对内容理解不同的典型案例。
|
||||
|
||||
那么,开源的相关性在哪里呢?开源的社区方面实际上就是建立分布式信任的一个驱动力。因为一旦你成为一个开源项目周围社区的一部分,你就会承担一个或多个角色,一旦你说你 "信任 "一个开源项目,你就会开始信任这些角色(见我之前的文章)。例如,建筑师、设计师、开发人员、审查员、技术作家、测试员、部署员、错误报告者或错误修复者。你对一个项目的参与越多,你就越是社区的一部分,久而久之,这就可以成为一个“实践社区”(community of practice)。
|
||||
|
||||
Jean Lave和Etienne Wenger在[_《情境学习:正当的外围参与》_][4](_Situated Learning: Legitimate Peripheral Participation_)一书中提出了实践社区的概念,团体在成员热情分享和参与共同活动的过程中演变成社区,导致他们的技能和知识共同提高。这里的核心概念是:当参与者在实践社区周围学习时,他们同时也成为社区的成员。
|
||||
|
||||
> “正当的的外围参与既指在实践中知识,技能,身份的发展,也指实践社区的再生产和转化。”
|
||||
|
||||
Wenger在[_《实践社区:学习、意义和身份》_][5](_Communities of Practice: Learning, Meaning, and Identity_)中进一步探讨了实践社区的概念:它们如何形成、对其健康的要求,以及它们如何鼓励学习。他认为,意义的可协商性("我们为什么要一起工作,我们要实现什么?")是实践社区的核心,并指出,如果没有个人的参与、想象力和一致性,实践社区将不会有活力。
|
||||
|
||||
我们可以把这一点与我们对分布式信任如何建立和构建的看法结合起来:当你意识到你对开源的影响可以与其他人的影响相同时,你对社区成员的分布式信任关系就变得不那么具有传递性(第二或第三手甚至更遥远),而是更加直接。你明白,你对你所运行的软件的创建、维护、需求和质量所能产生的影响,可以与所有其他以前匿名的贡献者一样,你现在正在与他们形成一个实践社区,或者你正在加入他们的现有实践社区。然后,你就会成为一个信任关系网络的一部分,这个网络是分布式的,但与你购买和操作专利软件时的经历相差不大。
|
||||
|
||||
这个过程并不会停止:因为开源项目的一个共同属性是“交叉授粉”,即一个项目的开发者也在其他项目上工作。由于多个开源项目之间的网络效应,使得对其他项目的重用和依赖性上升,导致整个项目的吸收量增加。
|
||||
|
||||
这就很容易理解为什么许多开源贡献者会成为开源爱好者或传道者,不仅仅是为单个项目,而是为整个开源项目。事实上,斯坦福大学社会学家[Mark Granovetter][6]的工作表明,社区内太多的强关系会导致小团体和停滞不前,但弱关系会使思想和趋势在社区内流动。这种对其他项目和围绕它们存在的社区的认识,以及想法在项目间的灵活性,导致分布式信任能够被扩展(尽管保证比较弱),超越贡献者在他们有直接经验的项目中所经历的直接或短链间接关系,并向其他项目扩展,因为外部观察或外围参与显示贡献者之间存在类似关系。
|
||||
|
||||
简单地说,参与开源项目并通过参与建立信任关系的行为会导致对类似的开源项目或只是对其他类似的开源项目产生更强的分布式信任。
|
||||
|
||||
这对我们每个人来说意味着什么?它意味着我们越是参与开源,我们对开源的信任度就越高,而其他人对开源的参与度也会相应提高,从而对开源的信任度也会提高。对开源的信任不仅仅是一个网络效应:它是一个积极的反馈循环!
|
||||
|
||||
* * *
|
||||
|
||||
_本文最初发表于[Alice, Eve, and Bob][7],经作者许可转载。_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/21/1/open-source-distributed-trust
|
||||
|
||||
作者:[Mike Bursell][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[MareDevi](https://github.com/MareDevi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/mikecamel
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_trust.png?itok=KMfi0Rdo (Trust)
|
||||
[2]: https://wiley.com/
|
||||
[3]: https://aliceevebob.com/2019/06/18/trust-choosing-open-source/
|
||||
[4]: https://books.google.com/books/about/Situated_Learning.html?id=CAVIOrW3vYAC
|
||||
[5]: https://books.google.com/books?id=Jb8mAAAAQBAJ&dq=Communities%20of%20Practice:%20Learning,%20meaning%20and%20identity&lr=
|
||||
[6]: https://en.wikipedia.org/wiki/Mark_Granovetter
|
||||
[7]: https://aliceevebob.com/2020/11/17/how-open-source-builds-distributed-trust/
|
Loading…
Reference in New Issue
Block a user