id
int64
2.05k
16.6k
title
stringlengths
5
75
fromurl
stringlengths
19
185
date
timestamp[s]
tags
sequencelengths
0
11
permalink
stringlengths
20
37
content
stringlengths
342
82.2k
fromurl_status
int64
200
526
status_msg
stringclasses
339 values
from_content
stringlengths
0
229k
13,912
MX Linux 21 稳定版发布
https://news.itsfoss.com/mx-linux-21-release/
2021-10-23T10:35:27
[ "MXLinux" ]
https://linux.cn/article-13912-1.html
> > 基于 Debian 的 MX Linux 21 现已经推出,带来了一些不错的改进。 > > > ![](/data/attachment/album/202110/23/103528cbbbubhvmw7bbpm7.png) [MX Linux](https://mxlinux.org/) 是一个基于 Debian 的 Linux/GNU 发行版,旨在追求优雅、稳定和性能。 我们之前报道过它的 [尚处于测试阶段的新 Fluxbox 版](https://news.itsfoss.com/mx-linux-21-fluxbox-beta-release/),但现在稳定版出来了。让我们来探讨一下 MX Linux 21 “Wildflower” 的新内容。 ### MX Linux 21 主要亮点 ![](/data/attachment/album/202110/23/103531myocjbvv8eih2err.png) MX Linux 21 基于 Debian 11 “Bullseye”,运行 Linux 5.10LTS 内核。在这次的新更新中,你可以发现一些新的应用和对当前应用的升级。 ![](/data/attachment/album/202110/23/103532kcn7myc78np88s8h.png) “Wildflower” 系列包括一个带有 Fluxbox 1.3.7 的新版本,它可以使旧电脑重新焕发活力。补充一下,Fluxbox 是一个窗口管理器,可以在高端计算机上无缝工作,但资源占用很少。 它的安装程序有一个新的分区选择区,支持 LVM(逻辑卷管理器)。 ![MX Linux 21 有一个漂亮的图形化安装程序](/data/attachment/album/202110/23/103531myocjbvv8eih2err.png) 当启动系统时,无论你是使用<ruby> 临时启动 <rt> live boot </rt></ruby>还是持久化使用,你都可以选择使用新的 UEFI 临时系统启动菜单,而不是旧的控制台菜单。 对于桌面环境,Xfce 4.16 和 KDE Plasma 5.20 都是最新版本。 然而,还没有 Xfce 版。 它新提供的一个方便的工具是在管理任务中默认使用管理员密码。然而,如果你不需要它,你可以把它关掉。 ### 其他改进 * 安装程序和临时系统已经更新到最新版本。 * 大部分的翻译仍在进行中。另一方面,有些部分的翻译工作完成的很好的。 * 默认软件包集现在包括 [Mesa Vulkan](https://www.mesa3d.org/) 驱动。 * 对某些 Realtek 硬件的 Wi-Fi 有了更好的支持。 * 已默认启用 Debian 安全库。 * Xfce 有了一些改进,其中之一是为 Thunar 文件管理器增加了一个 samba 共享插件。 * KDE 对其文件管理器 Dolphin 进行了修复。 ![](/data/attachment/album/202110/23/103531myocjbvv8eih2err.png) ### 总结 MX Linux 21 是它目前最新的稳定版本。更加优雅,性能更强,因此更加适合作为日常使用。 尽管与其他流行的选择相比,MX Linux 是一个相对较新的 Linux/GNU 发行版,但它在提供一个由 Debian、MX 存储库和 [antiX Linux](https://antixlinux.com/) 支持的完整操作系统方面有很大的潜力。 你可以参考 [官方公告](https://mxlinux.org/blog/mx-21-wildflower-released/) 了解更多细节。 * [下载 MX Linux 21](https://mxlinux.org/download-links/) 你对这个版本有什么看法?你碰巧在使用 MX Linux 吗?请在下面的评论中分享你的想法。 --- via: <https://news.itsfoss.com/mx-linux-21-release/> 作者:[Omar Maarof](https://news.itsfoss.com/author/omar/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) [MX Linux](https://mxlinux.org/?ref=news.itsfoss.com) is a Debian-based Linux/GNU distribution aiming at elegance, stability, and performance. We previously covered its [new Fluxbox edition in the beta phase](https://news.itsfoss.com/mx-linux-21-fluxbox-beta-release/), but now the stable release is out. Let us explore what’s new with MX Linux 21 “Wildflower”. ## MX Linux 21 Key Highlights ![](https://news.itsfoss.com/content/images/wordpress/2021/09/MX_Linux_21-1-1024x576.png) MX Linux 21 is based on Debian 11 “Bullseye” running Linux Kernel 5.10LTS, and with the new update, you can find some new applications and upgrades to the current list. ![](https://news.itsfoss.com/content/images/wordpress/2021/08/mx-linux-21-fluxbox.png) The “Wildflower” series included a new edition with **Fluxbox 1.3.7**, which will bring older computers back to life. In case you did not know, Fluxbox is a window manager that works seamlessly on high-end computers but is light on resources. For the installer, there is a new partition selection area. It comes with support for LVM(Logical Volume Manager). ![](https://news.itsfoss.com/content/images/wordpress/2021/09/MX_Linux_21_installer-1024x576.png) When booting your system, whether you are going with live boot or persistence, you can choose using the updated UEFI live system boot menu instead of the older console menus. For desktop environments, Xfce 4.16 and KDE Plasma 5.20 are the latest versions available. However, the Xfce “ahs” edition is not yet available. A new handy utility that is presented is using the admin’s password by default for administrative tasks. However, you can turn it off if you do not need it. ## Other Improvements - The installer and live system have been updated to the latest versions. - Most of the translation functionality is still in progress. On the other hand, some parts of the translation are working flawlessly. - The default package set now includes the [Mesa Vulkan](https://www.mesa3d.org/?ref=news.itsfoss.com)drivers. - There is better support for Wifi for some Realtek hardware. - The Debian security repository is enabled by default. - Xfce has seen some improvements. One of which is an added samba shares plugin for the Thunar file manager. - KDE has seen a fix regarding its file manager Dolphin. ![](https://news.itsfoss.com/content/images/wordpress/2021/09/MX_Linux_21_sharing-1024x576.png) ## Summing Up MX Linux 21 is currently the latest stable release. It is more elegant and more performant, so it is becoming more popular as a daily driver. Even though MX Linux is a relatively new Linux/GNU distribution compared to other popular options, it has a lot of potential for providing a complete operating system backed by Debian, the MX repository, and [antiX Linux](https://antixlinux.com/?ref=news.itsfoss.com). You can refer to the [official announcement](https://mxlinux.org/blog/mx-21-wildflower-released/?ref=news.itsfoss.com) for more details. What do you think of this release? Do you happen to use MX Linux? Share your thoughts in the comments down below. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,913
4 个用来擦除数据的 Linux 工具
https://opensource.com/article/21/10/linux-tools-erase-data
2021-10-23T11:39:27
[ "数据", "擦除", "删除" ]
https://linux.cn/article-13913-1.html
> > 用这些开源工具从你的硬盘驱动器中擦除数据。 > > > ![](/data/attachment/album/202110/23/113918sdojp6sj0odgis16.jpg "Tools in a cloud") 保持数据安全的最好方法之一是只向加密的硬盘驱动器写入数据。在一个标准的硬盘上,只要把硬盘挂载就可以查看数据,就像 U 盘一样,甚至可以用 [Scalpel](https://www.redhat.com/sysadmin/find-lost-files-scalpel) 和 [Testdisk](https://www.redhat.com/sysadmin/recover-partition-files-testdisk) 等工具显示和恢复已删除的数据。但是在一个加密的驱动器上,如果没有解密密钥(通常是你在挂载驱动器时输入的密码),数据是无法被读取的。 加密可以在你安装操作系统时建立,有些操作系统甚至可以在安装后的任何时候激活加密功能。 但是,当你卖掉一台电脑或更换一个一开始就没有被加密的驱动器时,你该怎么办呢? 与从一开始就加密你的数据相比,最好的办法是在你用完硬盘后删除数据。 ### 负责任的看管者 我经常被要求帮助客户升级一台旧电脑。无一例外,他们更愿意帮助我回收它们,使它们能被别人使用。我很乐意翻新这些旧电脑,用较新的固态驱动器来改装它们,极大地提高性能。 然而,把一个旧驱动器扔进垃圾桶并不是一个好主意。它需要被擦除,然后被妥善处理。我没有把硬盘留在原来的电脑里,而是把它们取出来,放在一个硬盘盒里,然后把它们连接到我的 Linux 电脑上。有几个 Linux 工具可以很容易地完成这个任务。其中一个是 **Gnu Shred**。 ### GNU Shred ``` $ sudo shred -vfz /dev/sdX ``` Shred 有许多选项: * `-n` - 覆盖的次数。默认是三次。 * `-u` - 覆盖并删除。 * `-s` - 要粉碎的字节数。 * `-v` - 显示扩展信息。 * `-f` - 必要时强制改变权限以允许写入。 * `-z` - 最后用 0 覆盖来隐藏粉碎。 使用 `shred --help` 获取更多信息 ### ShredOS ShredOS 是一个<ruby> 即用 <rt> Live </rt></ruby> Linux 发行版,它的唯一目的是清除驱动器的全部内容。它是在一个名为 DBAN 的类似发行版停止维护后开发的。它使用 `nwipe` 应用,它是 DBAN 的 `dwipe` 的一个分叉。你可以通过下载 32 位或 64 位镜像,并在 Linux 和 macOS 上使用 `dd` 命令将其写入驱动器来制作一个可启动的 USB 驱动器: ``` $ sudo dd if=shredos.img of=/dev/sdX bs=4M status=progress ``` 另外,你可以在 Linux、macOS 和 Windows 上使用 [Etcher](https://opensource.com/article/18/7/getting-started-etcherio) 工具烧录。 ### dd 命令 清除驱动器的一个常见方法是使用 Linux 的 `dd` 命令。几乎所有的 Linux 安装都安装了 `dd` 工具。确保该驱动器没有被挂载。 ``` $ sudo umount /dev/sdXY -l ``` 如果你想在整个目标磁盘上写零,执行以下命令。这可能需要一个整个通宵。 ``` $ sudo dd if=/dev/urandom of=/dev/sdX bs=10M ``` **警告**:请确保你知道你在系统中的位置,并以正确的驱动器为目标,这样你就不会意外地删除自己的数据。 ### Nvme-cli 如果你的计算机包含一个较新的 NVMe 驱动器,你可以安装 [nvme-cli](https://opensource.com/article/21/9/nvme-cli) 程序,并使用 `sanitize` 选项来清除你的驱动器。 `nvme sanitize help` 命令提供了选项列表: * `--no-dealloc`、`-d` - 净化后不解除分配。 * `--oipbp`、`-i` - 每次覆写后反转模式。 * `--owpass=`、`-n` - 覆写次数。 * `--ause`、`-u` - 允许无限制净化退出。 * `--sanact=`、`-a` - 净化动作。 * `--ovrpat=`、`-p` - 覆写模式。 下面是我使用的命令: ``` $ sudo nvme sanitize /dev/nvme0nX ``` 这里的警告与格式化过程相同:首先备份重要的数据,因为这个命令会擦除这些数据! ### 信息管理 你保存在计算机上的信息是很重要的。它属于你,也属于其他任何人。当你卖掉一台电脑或处理一个硬盘时,确保你已经用这些很棒的工具之一清除了你的数据。 --- via: <https://opensource.com/article/21/10/linux-tools-erase-data> 作者:[Don Watkins](https://opensource.com/users/don-watkins) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
One of the best ways to keep your data secure is by only writing data to an encrypted hard drive. On a standard drive, it's possible to view data just by mounting the drive as if it were a thumb drive, and it's even possible to display and recover even deleted data with tools like [Scalpel](https://www.redhat.com/sysadmin/find-lost-files-scalpel) and [Testdisk](https://www.redhat.com/sysadmin/recover-partition-files-testdisk). But on an encrypted drive, data is unreadable without a decryption key (usually a passphrase you enter when mounting the drive.) Encryption can be established when you install your OS, and some operating systems even make it possible to activate encryption any time after installation. What do you do when you're selling a computer or replacing a drive that never got encrypted in the first place, though? The next best thing to encrypting your data from the start is by erasing the data when you're finished with the drive. ## Responsible caretaker I'm frequently called on to help clients upgrade an old computer. Invariably, they're more than willing to help me recycle them so that they can be used by someone else. I'm happy to refurbish these older computers and refit them with a newer solid-state drive, dramatically improving performance. However, it's not a good idea to just throw an old drive in the trash. It needs to be erased and then disposed of properly. Rather than leave the drives in the original computer, I remove them, place them in a drive enclosure, and connect them to my Linux computer. Several Linux utilities can easily accomplish this. One of them is the **Gnu Shred** tool. ## GNU Shred `$ sudo shred -vfz /dev/sdX` Shred has many options: - n - the number of overwrites. The default is three. - u - overwrite and delete. - s - the number of bytes to shred. - v - show extended information. - f - force the change of permissions to allow writing if necessary. - z - add a final overwrite with zeros to hide shredding. Use `shred --help` for more information ## ShredOS ShredOS is a live Linux distribution with the sole purpose of erasing the entire contents of a drive. It was developed after a similar distribution, called DBAN, was discontinued. It uses the `nwipe` application, which is a fork of DBAN's `dwipe` . You can make a bootable USB drive by downloading the 32 bit or 64 bit image and writing it to a drive with the `dd` command on Linux and macOS: `$ sudo dd if=shredos.img of=/dev/sdX bs=4M status=progress` Alternately, you can use the [Etcher](https://opensource.com/article/18/7/getting-started-etcherio) tool on Linux, macOS, and Windows. ## The dd command A common method for erasing drives is with the Linux `dd` command. Nearly every Linux installation comes with the `dd` utility installed. Make sure that the drive is not mounted. `$ sudo umount /dev/sdXY -l` If you want to write zeros over your entire target disk, issue the following command. It will probably be an overnight job. `$ sudo dd if=/dev/urandom of=/dev/sdX bs=10M` **Warning**: Be sure that you know where you are on your system and target the correct drive so that you don't accidentally erase your own data. ## Nvme-cli If your computer contains one of the newer NVMe drives, you can install the [nvme-cli](https://opensource.com/article/21/9/nvme-cli) utilities and use the `sanitize` option to erase your drive. The command `nvme sanitize help` command provides you with a list of sanitize options, which include the following: - --no-dealloc, -d - No deallocate after sanitize. - --oipbp, -i - Overwrite invert pattern between passes. - --owpass=, -n - Overwrite pass count. - --ause, -u - Allow unrestricted sanitize exit. - --sanact=, -a - Sanitize action. - --ovrpat=, -p - Overwrite pattern. Here is the command I use: `$ sudo nvme sanitize /dev/nvme0nX` The same warnings apply here as with the format process: back up important data first because this command erases it! ## Information management The information you keep on your computer is important. It belongs to you and to know one else. When you're selling off a computer or disposing of a hard drive, make sure you've cleared it of your data with one of these great tools. ## 1 Comment
13,915
helloSystem:一款类似 Mac 的 FreeBSD 系统
https://news.itsfoss.com/hellosystem-towards-first-release/
2021-10-24T10:45:03
[ "MacOS", "helloSystem" ]
https://linux.cn/article-13915-1.html
![](/data/attachment/album/202110/24/104504nee2uo4mcez2oece.jpg) 最近,helloSystem 的开发者发布了他们操作系统的最新版本。helloSystem 是一个较新的项目,希望以 FreeBSD 为基础创建一个简单易用的操作系统。让我们来看看这对你我意味着什么。 ### helloSystem 简介 ![helloSystem 的关于屏幕](/data/attachment/album/202110/24/104504ih0wsrk37sfrutfs.jpg) 你们中的大多数人可能以前从未听说过 [helloSystem](https://github.com/helloSystem/hello)。该项目是由 [AppImage 的创建者](https://itsfoss.com/appimage-interview/) [Simon Peter](https://github.com/probonopd) 在去年年初启动的。Simon 的目标是创建一个“友好的 [自由桌面](https://medium.com/@probonopd/bring-back-the-ease-of-80s-and-90s-personal-computing-393738c5e2a1) 操作系统,重点是简单、简约优雅和可用性。” Simon 从上世纪 80 、90 年代更为简单的操作系统中获得了灵感,特别是 **早期的 MacOS**,比如 [System 1](https://github.com/helloSystem/hello/wiki#design-principles)。如果你只是看一下系统运行的截图,你可能会想说,“我不明白这有什么好大惊小怪的。有一堆 Linux 发行版或主题,看起来就像 MacOS。” 该项目不仅仅是看起来像 MacOS,它想回归到更简单、更容易使用的设计。据 [其网站](https://hellosystem.github.io/docs/) 上讲,“helloSystem 是一个面向创作者的桌面系统,注重简单、优雅和实用性。它的设计遵循 ‘少而精’ 的理念。它的目的是为 ‘普通人’ 提供一个系统,欢迎从 Mac 切换过来的人”。你可以通过观看 Simon 在 [FOSDEM 21](https://fosdem.org/2021/schedule/event/hello_bsd/) 上的演讲,了解更多关于他对 helloSystem 计划的想法。 就像 [Suckless 项目](https://suckless.org/sucks/) 一样,Simon 创建了一个 “[欢迎和不欢迎的技术](https://github.com/helloSystem/hello/wiki/Welcome-and-unwelcome-technologies)” 列表。被批准的技术清单包括: * Qt * mDNSResponder * Python * Go ![helloSystem 的欢迎屏幕](/data/attachment/album/202110/24/104505vz7s807k3x7saff5.jpg) “不受欢迎的技术”清单包括 Simon 认为“太复杂或被认为不美观”的东西。这些技术包括: * 触摸 * btrfs * Gnome * GTK * 客户端窗口装饰 * Wayland * Pipewire * XDG 桌面规范 * 与原始字体在度量上兼容的字体,但不试图在视觉上与原始字体相似 * 最终用户应用程序的包管理器 * 配置文件、IP 地址 * D-Bus * 通过限制用户或应用程序可以做的事情而提供的安全性 * Polkit * 大写锁定键 * 本地文件的 URI ![在 helloSystem 上安装 Inkscape](/data/attachment/album/202110/24/104505e1xd1501nheknd1x.jpg) ### helloSystem 如何工作 我最好解释一下 helloSystem 的工作方式。就像 MacOS 一样,桌面在屏幕顶部有一个全局菜单,底部有一个 Dock。与 MacOS 的 Finder 一样,helloSystem 也有一个文件管理器(名为 Filer),它也负责窗口管理。 在左上方,你会发现一个 “<ruby> 系统 <rt> System </rt></ruby>” 菜单,你可以用它来访问应用程序。(你也可以在左上角的搜索框中输入应用程序的名称。)helloSystem 只安装了几个开箱即用的基本应用程序。如果你点击一个未安装的应用程序,helloSystem 会下载并安装该应用程序的 AppImage。 helloSystem 基于 FreeBSD 12.2。它默认启用了 ZFS。它没有密码或用户账户系统,但这并不意味着他们无视安全。据 [其网站](https://github.com/helloSystem/hello/wiki/Welcome-and-unwelcome-technologies) 讲,“这并不是说一般的安全问题不重要。而是说它需要以一种不会限制设备的合法用户(所有者)真正 ‘拥有’ 该设备的方式来实现。” ### 最新版本中的新功能 ![helloSystem 的实用程序窗口](/data/attachment/album/202110/24/104506gfwb77elz3xub7zb.jpg) 最新版本的 helloSystem 包括不少图形方面的更新和小的变化,包括: * 从 Openbox 切换到 KWin 窗口管理器 * 合理的窗口标题居中 * 当窗口被拖到屏幕边缘时,会缩放到一定大小,类似于 “Aero Snap”。 * 简化了 “<ruby> 桌面设置 <rt> Desktop Settings </rt></ruby>” 的用户界面;现在更改会立即应用 * 移除文件管理器中的标签以简化用户界面 * 为菜单添加新的电池小程序,以显示电池充电量 * 桌面上的垃圾箱图标不再有 “<ruby> 移动到垃圾箱 <rt> Move to Trash </rt></ruby>” 的上下文菜单项 * 最小化窗口和取消最小化窗口时的动画 * 窗口大小调整时的动画 * 调整内核配置以优化声音 * 简化了文件管理器中的 “<ruby> 获取信息 <rt> Get Info </rt></ruby>” 对话框 你可以在 [这里](https://github.com/helloSystem/ISO/releases/tag/r0.6.0) 看到其余的变化。你也可以从同一个链接下载最新的 .iso 文件。试一试,让我们知道你的想法。 --- via: <https://news.itsfoss.com/hellosystem-towards-first-release/> 作者:[John Paul Wohlscheid](https://news.itsfoss.com/author/john/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Recently, the helloSystem devs released the newest version of their operating system. helloSystem is a newer project that wants to create a simple and easy to use operating system and is based on FreeBSD. Let’s take a look at what that means to you and me. ## What is helloSystem? ![helloSystem's About screen](https://news.itsfoss.com/content/images/wordpress/2021/10/hello-about.jpg) Most of you have probably never heard of [helloSystem](https://github.com/helloSystem/hello?ref=news.itsfoss.com) before. The project was started by the [creator of AppImage](https://itsfoss.com/appimage-interview/?ref=news.itsfoss.com), [Simon Peter](https://github.com/probonopd?ref=news.itsfoss.com), early last year. Simon’s goal is to create a “friendly [Libre Desktop](https://medium.com/@probonopd/bring-back-the-ease-of-80s-and-90s-personal-computing-393738c5e2a1?ref=news.itsfoss.com) operating system with focus on simplicity, minimalist elegance, and usability”. Simon takes inspiration from the simpler operating system of the 80s and 90s, specifically **early MacOS**, specifically [System 1](https://github.com/helloSystem/hello/wiki?ref=news.itsfoss.com#design-principles). If you just look at screenshots of the system in action, you may be tempted to say, “I don’t see what the fuss is all about. There are a bunch of Linux distros or themes that look just like MacOS.” The project goes beyond merely looking like MacOS, it wants to return to a simpler, easier to use design. According to the [website](https://hellosystem.github.io/docs/?ref=news.itsfoss.com), “helloSystem is a desktop system for creators with a focus on simplicity, elegance, and usability. Its design follows the “Less, but better” philosophy. It is intended as a system for “mere mortals”, welcoming to switchers from the Mac.” You can find out more about Simon’s thoughts on what he plans for helloSystem by watching his presentation at [FOSDEM 21](https://fosdem.org/2021/schedule/event/hello_bsd/?ref=news.itsfoss.com). Just like the [suckless project](https://suckless.org/sucks/?ref=news.itsfoss.com), Simon created a list of “[Welcome and unwelcome technologies](https://github.com/helloSystem/hello/wiki/Welcome-and-unwelcome-technologies?ref=news.itsfoss.com)“. The approved list of technologies include: - Qt - mDNSResponder - Python - Go ![helloSystem's Welcome screen](https://news.itsfoss.com/content/images/wordpress/2021/10/hello-welcome.jpg) The list of “unwelcome technologies” includes stuff that Simon considers “too complex or deemed aesthetically unpleasant”. These include: - Touch - btrfs - Gnome - GTK - Client-side window decorations - Wayland - Pipewire - XDG Desktop spec - Fonts that are metrically compatible to, but make no attempt at being visually similar to, original typefaces - Package managers for end-user applications - Configuration files, IP addresses - D-Bus - Security that restricts what the user or applications can do - polkit - Caps Lock key - URIs for local files ![Installing Inkscape on helloSystem](https://news.itsfoss.com/content/images/wordpress/2021/10/hello-install.jpg) ## How helloSystem Works I’d better explain a little about how helloSystem works. Just like MacOS, the desktop has a global menu at the top of the screen and a dock at the bottom. Also like MacOS’s Finder, helloSystem has a file manager (named Filer) that also handles window management. In the upper left, you’ll find a “System” menu that you can use to access applications. (You can also type the name of an application in the search box in the upper left corner.) helloSystem only has a couple of basic applications installed out of the box. If you click on an application that is not installed, helloSystem will download and install an AppImage of that application. Under the hood, helloSystem is based on FreeBSD 12.2. It has ZFS enable by default. It does not have a passwords or user account system. This doesn’t mean that they are disregarding security. According to the [site](https://github.com/helloSystem/hello/wiki/Welcome-and-unwelcome-technologies?ref=news.itsfoss.com), “This is NOT to say that Security in general is not important. It is to say that it needs to be implemented in a way that it doesn’t restrict the legitimate user (owner) of the device from truly “owning” the device”. ## New Features in the Latest Release ![helloSystem's Utilities window](https://news.itsfoss.com/content/images/wordpress/2021/10/hello-utillities.jpg) This latest release of helloSystem includes quite a few graphical and minor changes and updates, including: - Switched from Openbox to the KWin window manager - Properly centered window titles - Windows snap to certain sizes when dragged to the edge of the screen, similar to “Aero Snap” - Simplified user interface for Desktop Settings; changes are now applied immediately - Remove tabs in file manager to simplify user interface - New Battery applet for the Menu to show the battery fill level - The Trash icon on the Desktop no longer has a “Move to Trash” context menu item - Animation when minimizing and un-minimizing windows - Animations on window resize - Tuned kernel configuration for optimized sound - Simplified “Get Info” dialog in file manager You can see the rest of the changes [here](https://github.com/helloSystem/ISO/releases/tag/r0.6.0?ref=news.itsfoss.com). You can also download the latest .iso file from the same link. Give it a try and let us know what you think. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,918
用 smem 命令获取内存使用统计信息
https://opensource.com/article/21/10/memory-stats-linux-smem
2021-10-25T10:18:51
[ "smem", "内存" ]
https://linux.cn/article-13918-1.html
> > smem 命令允许你快速查看你的网页应用的内存使用情况。 > > > ![](/data/attachment/album/202110/25/101843emjjkmvk88gvyqgv.jpg "Programming at a browser, orange hands") 在我的编程工作中,我经常需要了解网页应用的内存使用情况。在深入研究细节和浏览器剖析工具之前,一个粗略的估计通常就足够了。 为了了解 Linux 或 macOS 上的内存使用情况,人们通常使用 [top](https://linux.die.net/man/1/top) 或 [htop](https://linux.die.net/man/1/htop)。我很想看到一个单一的数字:一个进程占用了多少内存。但这些工具所显示的统计数据可能很难理解。对于网页浏览器来说,它甚至更加复杂,因为它们经常运行许多独立的进程。它们在 `top` 输出中显示为一个长长的列表,每一个都有自己的单独指标。 ![Memory usage using htop](/data/attachment/album/202110/25/101853izcyy0bttz1ltbx2.png "Memory usage using htop") ### smem 命令 幸运的是有 [smem](https://linux.die.net/man/8/smem),另一个用于查看内存使用统计的命令行工具。用你选择的包管理器安装它,例如: ``` sudo apt install smem ``` 要获得 [Firefox](https://www.mozilla.org/en-US/firefox/) 的总内存使用量,请执行: ``` smem -c pss -P firefox -k -t | tail -n 1 ``` 这些开关做了什么? * `-c` 开关指定要显示的列。我只对 `pss` 列感兴趣,它显示一个进程分配的内存。 * `-P` 开关过滤进程,只包括那些名字里有 `firefox` 的进程。 * `-k` 开关显示以 MB/GB 为单位的内存使用情况,而不是单纯的字节数。 * `-t` 开关显示总数。 * `tail -n 1` 过滤器只输出最后一行,也就是总数的地方。 输出是非常简单的: ``` $ smem -t -k -c pss -P firefox | tail -n 1 4.9G ``` 开门见山!而且,经过又一天忙碌的工作,打开了 50 多个选项卡,Firefox 仍然只使用 5 GB。看看吧,Google Chrome。 #### 用一个脚本更容易 为了方便起见,我创建一个名为 `memory-use` 的小脚本,它将进程名称作为参数。我把所有的脚本都放在 `~/bin` 里,所以: ``` echo 'smem -c pss -P "$1" -k -t | tail -n 1' > ~/bin/memory-use && chmod +x ~/bin/memory-use ``` 现在我可以很容易地测量任何应用的内存使用: ``` memory-use firefox memory-use chrome memory-use slack ``` #### 还有更多! 该工具不仅可以显示总的内存使用情况。它甚至可以生成图形输出。 比如: ``` smem --pie name -c pss ``` 显示类似这样的内容: ![Pie chart output from smem](/data/attachment/album/202110/25/101854lvgfcmc3ikkeb6mh.png "Pie chart output from smem") 关于更多的细节,我建议查看 [smem 手册页](https://linux.die.net/man/8/smem)。 你可以在 <https://linoxide.com/memory-usage-reporting-smem/> 上找到另一个很棒的教程。 希望你喜欢! 本文最初发表在[作者的博客](https://letsdebug.it/post/26-measure-application-memory-use-on-linux/)上,并经许可转载。 --- via: <https://opensource.com/article/21/10/memory-stats-linux-smem> 作者:[Tomasz Waraksa](https://opensource.com/users/tomasz) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
In my programming work, I often need to know the memory used by web applications. A rough estimate is usually enough before getting down to details and browser profiling tools. To interrogate memory use on Linux or macOS, people typically use [top](https://linux.die.net/man/1/top) or [htop](https://linux.die.net/man/1/htop). I'd love to see a single number: How much RAM did a process take. But statistics shown by these utilities can be hard to understand. With web browsers, it's even more complicated because they often run many separate processes. They all show up in top output as a long list, each with its own individual metrics. ![Memory usage using htop Memory usage using htop](https://opensource.com/sites/default/files/uploads/1_htop.png) (Tomasz Waraksa, CC BY-SA 4.0) # Enter smem command Luckily there is [smem](https://linux.die.net/man/8/smem), another command-line utility for viewing memory use statistics. Install it with your package manager of choice, for example: `sudo apt install smem` To get total memory use by [Firefox](https://www.mozilla.org/en-US/firefox/), do: `smem -c pss -P firefox -k -t | tail -n 1` What happens here? `-c` switch specifies columns to show. I'm only interested in*the pss*column, which shows memory allocated by a process.`-P` switch filters processes to include only those with*firefox*in the name`-k` switch tells to show memory use in mega/gigabytes instead of plain bytes`-t` switch displays the totals`tail -n 1` filter outputs only the last line, just where the totals are The output is as simple as it gets: ``` $ smem -t -k -c pss -P firefox | tail -n 1 4.9G ``` Straight to the point! And, after another busy day of work, with over fifty opened tabs, Firefox still uses only 5 GB. Take that, Google Chrome ;-) ## Even easier with a script For convenience, create a little script named `memory-use` , which takes the process name as a parameter. I keep all my scripts in `~/bin` , so: `echo 'smem -c pss -P "$1" -k -t | tail -n 1' > ~/bin/memory-use && chmod +x ~/bin/memory-use` Now I can measure memory use of any application as easy as: ``` memory-use firefox memory-use chrome memory-use slack ``` ## And there is even more! The utility can do much more than show the total memory use. It can even generate graphic output. For example: `smem --pie name -c pss` Shows something like this: ![Pie chart output from htop Pie chart output from smem](https://opensource.com/sites/default/files/uploads/2_smem-pie-chart.png) (Tomasz Waraksa, CC BY-SA 4.0) For more details, I recommend looking into [smem man pages](https://linux.die.net/man/8/smem). You can find another great tutorial at [https://linoxide.com/memory-usage-reporting-smem/](https://linoxide.com/memory-usage-reporting-smem/). Enjoy! *This article originally appeared on the author's blog and is republished with permission.* ## 1 Comment
13,919
如何找到并杀掉 Linux 系统中的僵尸进程
https://itsfoss.com/kill-zombie-process-linux/
2021-10-25T11:02:21
[ "僵尸进程" ]
https://linux.cn/article-13919-1.html
![](/data/attachment/album/202110/25/110222ygkl8gutsl8s6o6l.jpg) > > 这是一个关于如何寻找 Linux 系统僵尸进程并杀死它们的小知识。你也可以从中了解到关于进程和僵尸进程的一些知识。 > > > 在了解僵尸进程之前,让我们来复习一下什么是 Linux 进程。 简而言之,[进程](https://tldp.org/LDP/tlk/kernel/processes.html) 是一个程序的运行实例。它可能运行在前端(比如有交互的进程),也可能运行在后端(比如无交互或自动运行的进程)。它可能是一个父进程(运行期间创建了其他进程),也可能是一个子进程(由其他进程所创建)。 在 Linux 系统中,除 PID 为 0 的第一个 `init` 进程(或 `systemd`)外,其余进程都有父进程。进程也可以拥有自己的子进程。 不相信?可以试试在终端中使用 `pstree` 命令查看进程的树型结构,你能看到系统各个进程的“家族树”。 ### Linux系统里的僵尸进程是什么? 子进程死亡后,它的父进程会接收到通知去执行一些清理操作,如释放内存之类。然而,若父进程并未察觉到子进程死亡,子进程就会进入到“<ruby> 僵尸 <rt> zombie </rt></ruby>”状态。从父进程角度看,子进程仍然存在,即使子进程实际上已经死亡。这就是“<ruby> 僵尸进程 <rt> zombie process </rt></ruby>”(也被称为“<ruby> 已消失进程 <rt> defunct process </rt></ruby>”)是如何产生并存在于系统中的。 这里有一个来自 [Turnoff.us](https://turnoff.us/geek/zombie-processes/) 的关于僵尸进程的非常有趣的看法: ![Image credit: Turnoff.us](/data/attachment/album/202110/25/110223e8pmlipzlfuj3fc8.jpg) ### 你真的需要关心僵尸进程吗? 重点要说的是,僵尸进程并没有像它的名称那样看起来可怕。 但如果系统的内存已经所剩不多或者有太多的僵尸进程在吃掉内存,问题会变得糟糕。同样,大部分 Linux 系统进程最大 PID 设置为 32768,如果过多僵尸进程导致其他重要任务没有 PID 可用,你的系统会发生崩溃。 这是真实可能发生的,它有一定的概率,特别当存在一个编码糟糕的程序开始大量产生僵尸进程的时候。 在这种情况下,找到并杀死僵尸进程是一个明智的做法。 ### 如何找到僵尸进程 Linux 系统中的进程可能处于如下状态中的一种: * `D` = 不可中断的休眠 * `I` = 空闲 * `R` = 运行中 * `S` = 休眠 * `T` = 被调度信号终止 * `t` = 被调试器终止 * `Z` = 僵尸状态 那如何查看进程和它的当前状态呢?一个简单的方法是在终端中使用 [top 命令](https://linuxhandbook.com/top-command/)。 ![Top command show processes and their status](/data/attachment/album/202110/25/110223ofb9ha7vf65eeqbe.png) 正如你在上面截图中看到的,截图中共有 250 个任务(进程),其中 1 个处在 “<ruby> 运行中 <rt> running </rt></ruby>” 状态,248 个进程处于 “<ruby> 休眠 <rt> sleep </rt></ruby>” 状态,还有一个处于 “<ruby> 僵尸 <rt> zombie </rt></ruby>” 状态。 现在问题进入下一步,如何杀死 “僵尸” 进程? ### 如何找到并杀死一个僵尸进程?僵尸进程能被杀死吗? 僵尸进程已经死了,要如何才能杀死一个已经死亡的进程呢? 在僵尸电影中,你可以射击僵尸的头部或烧掉它们,但在这里是行不通的。你可以一把火烧了系统来杀死僵尸进程,但这并不是一个可行的方案。 一些人建议发送 `SIGCHLD` 给父进程,但这个信号很可能会被忽略。还有一个方法是杀死父进程来杀死僵尸进程,这听起来很野蛮,但它却是唯一能确保杀死僵尸进程的方法。 首先,通过在终端中 [使用 ps 命令](https://linuxhandbook.com/ps-command/) 我们列举僵尸进程,得到它们的进程 ID: ``` ps ux | awk '{if($8=="Z+") print}' ``` `ps ux` 命令输出的第 8 列显示了进程状态。上述命令只会打印所有处在 Z+ 状态(表示僵尸状态)的进程。 确认了进程 ID 后,我们可以得到它的父进程 ID: ``` ps -o ppid= -p <child_id> ``` 你也可以将上述两个命令结合在一起,直接得到僵尸进程的 PID 及其父进程的 PID: ``` ps -A -ostat,pid,ppid | grep -e '[zZ]' ``` 现在你得到了父进程 ID,使用命令行和得到的 ID 号 [终于可以杀死进程了](https://itsfoss.com/how-to-find-the-process-id-of-a-program-and-kill-it-quick-tip/): ``` kill -9 <parent_process_ID> ``` ![Killing parent process](/data/attachment/album/202110/25/110224zd2sx1odn2n747x2.png) 再次运行 `ps` 命令或 `top` 命令,你可以验证僵尸进程是否已经被杀死。 恭喜!现在你知道怎么清理僵尸进程了。 --- via: <https://itsfoss.com/kill-zombie-process-linux/> 作者:[Marco Carmona](https://itsfoss.com/author/marco/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[zengyi1001](https://github.com/zengyi1001) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Before you learn about Zombie process, let me recall what is a process in Linux. In a few words, a [process](https://tldp.org/LDP/tlk/kernel/processes.html?ref=itsfoss.com) is a running instance of a program in performance. It can be foreground (interactive process) or background (not interactive or automatic process). It can be a parent (creator of other processes during run-time) or child (process created by others) process. In Linux, except for the first init (or systemd) process with PID 0, every other process has a parent process. Processes also have their own child processes. Don’t believe me? Use the `pstree` command in terminal to look at the process tree to see the ‘family tree’ of your system’s processes. ## What is a Zombie process in Linux? When a child process dies, the parent process is informed so that it can do some clean up like freeing up memory etc. However, child process goes into zombie state if the parent process is not aware of its death. For the parent, the child still exists but the child process is actually dead. This is how zombie processes (also known as defunct processes) are created and stay in the system. Here’s an excellent funny take on the zombie process by Turnoff.us: ![zombies turnoff](https://itsfoss.com/content/images/wordpress/2021/10/zombies-turnoff-800x467.webp) [Turnoff.us](https://turnoff.us/geek/zombie-processes/?ref=itsfoss.com) ## Do you really need to worry about Zombie processes? Here is important to say that zombie processes are not as dangerous as its name can sound. The problem may arise if your system has limited RAM or if there are too many zombie processes eating up RAM. Also, most Linux processes can have maximum PID set to 32768. If there are no available IDs for other productive tasks, your system may crash. This rarely happens, but it’s a possibility, specially if a poorly coded program starts inducing numerous zombie processes. In such case, it would be a good idea to find and kill zombie process. ## How to find zombie processes? A process in Linux can have one of the following states: - D = uninterruptible sleep - I = idle - R = running - S = sleeping - T = stopped by job control signal - t = stopped by debugger during trace - Z = zombie But where can you see the processes and their respective status? One easy way is to use the terminal and the [top command](https://linuxhandbook.com/top-command/?ref=itsfoss.com). ![top command view](https://itsfoss.com/content/images/wordpress/2021/10/top-command-view-800x474.png) As you can see in the screenshot above, there are 250 total tasks (or processes), 1 is running, 248 processes are sleeping and 1 is in zombie state. Now, the question arises, how to kill the zombie process? ## How to find and kill a zombie process? Can a zombie process be killed? A zombie process is already dead. How do you kill an already dead process? In the zombie movies, you shoot the zombies in the head or burn it. That’s not an option here. You can burn your system for killing the zombie process but that’s not a feasible solution ;) Some people suggests sending SIGCHLD signal to the parent process. But it is more likely to be ignored. The other option to kill the zombie process is to kill its parent process. That sounds brutal but that’s the only sure shot way of killing zombie processes. So, first, let’s list the zombie processes to know their ID. It can be achieved by [using the ps command](https://linuxhandbook.com/ps-command/?ref=itsfoss.com) like this in the terminal. `ps aux | awk '$8 ~ /^[Zz]/'` The 8th column in the output of the ps aux command displays the state of a process. You are asking to print all the matching lines where the state of a process starts with Z or z. Once you have identified its process ID, let’s get its parent’s process ID. `ps -o ppid= -p <child_id>` Alternatively, you can combine the above two commands in the following fashion where it directly provides the PID of the zombie process and the PID of its parent process. `ps -A -ostat,pid,ppid | grep -e '[zZ]'` Here you get the parent process ID, so [finally kill the process](https://itsfoss.com/how-to-find-the-process-id-of-a-program-and-kill-it-quick-tip/) by typing the command line with its respective ID process obtained before. `kill -9 <parent_process_ID>` ![killing parent process](https://itsfoss.com/content/images/wordpress/2021/10/killing-parent-process-800x180.png) You can verify if the zombie process is killed or not by running the ps command again or even the top command. Congrats! Now you know how to eliminate zombie processes.
13,921
使用 Rust 进行嵌入式开发
https://opensource.com/article/21/10/rust-embedded-development
2021-10-26T10:38:56
[ "Rust", "嵌入式" ]
https://linux.cn/article-13921-1.html
> > Rust 的高性能、高可靠性和高生产力使它适合于嵌入式系统。 > > > ![](/data/attachment/album/202110/26/103848djcdhjk0d2z1hc52.jpg "Ferris the crab under the sea, unofficial logo for Rust programming language") 在过去的几年里,Rust 在程序员中获得了热情的追捧。技术潮流来来去去,所以很难将仅仅因为某项新技术而产生的兴奋与对某项技术的优点的兴奋区分开来,但我认为 Rust 是一种真正设计良好的语言。它的目标是帮助开发者建立可靠和高效的软件,而且它从一开始就是为这个目的设计的。你可能听过一些 Rust 的关键特性,在这篇文章中,我会证明这些特性正是 Rust 也恰好适合嵌入式系统的原因。比如: * 高性能:它速度快,内存利用率高 * 可靠性:在编译过程中可以消除内存错误 * 生产力:很棒的文档,友好的编译器,有用的错误信息,以及一流的工具化。它有一个集成的包管理器和构建工具,智能的多编辑器支持自动补完和类型检查、自动格式化等等。 ### 为什么使用 Rust 进行嵌入式开发? Rust 的设计是为了保证安全和高性能。嵌入式软件会出现的问题主要是内存的问题。从某种程度上说,Rust 是一种面向编译器的语言,所以你可以确保在编译时安全使用内存。以下是使用 Rust 在嵌入式设备上开发的一些好处: * 强大的静态分析 * 灵活的内存 * 无畏的并发性 * 互操作性 * 可移植性 * 社区驱动 在这篇文章中,我使用开源的 [RT-Thread 操作系统](https://github.com/RT-Thread/rt-thread) 来演示如何使用 Rust 进行嵌入式开发。 ### 如何在 C 语言中调用 Rust 在 C 代码中调用 Rust 代码时,你必须将 Rust 源代码打包成静态库文件。当 C 代码编译时,将其链接进去。 #### 用 Rust 创建一个静态库 在这个过程中,有两个步骤: 1、使用 `cargo init --lib rust_to_c` 在 Clion 中建立一个 `lib` 库。在 `lib.rs` 中加入以下代码。下面的函数计算两个类型为 `i32` 的值的总和并返回结果: ``` #![no_std] use core::panic::PanicInfo; #[no_mangle] pub extern "C" fn sum(a: i32, b: i32) -> i32 { a + b } #[panic_handler] fn panic(_info:&PanicInfo) -> !{ loop{} } ``` 2、在你的 `Cargo.toml` 文件中添加以下代码,以告诉 Rustc 要生成什么类型的库: ``` [lib] name = "sum" crate-type = ["staticlib"] path = "src/lib.rs" ``` #### 交叉编译 你可以针对你的目标平台进行交叉编译。假设你的嵌入式系统是基于 Arm 的,步骤很简单: ``` $ rustup target add armv7a-none-eabi ``` 生成静态库文件: ``` $ cargo build --target=armv7a-none-eabi --release --verbose Fresh rust_to_c v0.1.0 Finished release [optimized] target(s) in 0.01s ``` #### 生成头文件 你也需要头文件: 1、安装 [cbindgen](https://github.com/eqrion/cbindgen)。`cbindgen` 工具会从 Rust 库中生成一个 C 或 C++11 的头文件: ``` $ cargo install --force cbindgen ``` 2、在你的项目文件夹下创建一个新的 `cbindgen.toml` 文件。 3、生成一个头文件: ``` $ cbindgen --config cbindgen.toml --crate rust_to_c --output sum.h ``` #### 调用 Rust 库文件 现在你可以对你的 Rust 库进行调用了。 1、把生成的 `sum.h` 和 `sum.a` 文件放到 `rt-thread/bsp/qemu-vexpress-a9/applications` 目录下。 2、修改 `SConscript` 文件并添加一个静态库: ``` from building import * cwd = GetCurrentDir() src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] LIBS = ["libsum.a"] LIBPATH = [GetCurrentDir()] group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, LIBS = LIBS, LIBPATH = LIBPATH) Return('group') ``` 3、在主函数中调用 `sum` 函数,得到返回值,并 `printf` 该值: ``` #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <rtthread.h> #include "sum.h" int main(void) { int32_t tmp; tmp = sum(1, 2); printf("call rust sum(1, 2) = %d\n", tmp); return 0; } ``` 4、在 RT-Thread [Env](https://www.rt-thread.io/download.html?download=Env) 环境中,使用 `scons` 来编译项目并运行: ``` $ scons -j6 scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... [...] scons: done building targets. $ qemu.sh \ | / - RT - Thread Operating System / | \ 4.0.4 build Jul 28 2021 2006 - 2021 Copyright by rt-thread team lwIP-2.1.2 initialized! [...] call rust sum(1, 2) = 3 ``` ### 加、减、乘、除 你可以在 Rust 中实现一些复杂的数学运算。在 `lib.rs` 文件中,使用 Rust 语言来实现加、减、乘、除: ``` #![no_std] use core::panic::PanicInfo; #[no_mangle] pub extern "C" fn add(a: i32, b: i32) -> i32 { a + b } #[no_mangle] pub extern "C" fn subtract(a: i32, b: i32) -> i32 { a - b } #[no_mangle] pub extern "C" fn multiply(a: i32, b: i32) -> i32 { a * b } #[no_mangle] pub extern "C" fn divide(a: i32, b: i32) -> i32 { a / b } #[panic_handler] fn panic(_info:&PanicInfo) -> !{ loop{} } ``` 构建你的库文件和头文件,并把它们放在应用程序目录中。使用 `scons` 来编译。如果在链接过程中出现错误,请在官方 [Github 页面](https://github.com/rust-lang/compiler-builtins/issues/353) 中找到解决方案。 修改 `rtconfig.py` 文件,并添加链接参数 `--allow-multiple-definition`: ``` DEVICE = ' -march=armv7-a -marm -msoft-float' CFLAGS = DEVICE + ' -Wall' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__ -I.' LINK_SCRIPT = 'link.lds' LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors,--allow-multiple-definition'+\ ' -T %s' % LINK_SCRIPT CPATH = '' LPATH = '' ``` 编译并运行 QEMU 来看看你的工作。 ### 在 Rust 中调用 C 语言 Rust 可以在 C 代码中调用,但是如何在你的 Rust 代码中调用 C 呢?下面是一个在 Rust 代码中调用 `rt_kprintf` C 函数的例子。 首先,修改 `lib.rs` 文件: ``` // The imported rt-thread functions list extern "C" { pub fn rt_kprintf(format: *const u8, ...); } #[no_mangle] pub extern "C" fn add(a: i32, b: i32) -> i32 { unsafe { rt_kprintf(b"this is from rust\n" as *const u8); } a + b } ``` 接下来,生成库文件: ``` $ cargo build --target=armv7a-none-eabi --release --verbose Compiling rust_to_c v0.1.0 Running `rustc --crate-name sum --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type staticlib --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C metadata=a Finished release [optimized] target(s) in 0.11s ``` 而现在,要运行代码,将 Rust 生成的库文件复制到应用程序目录中,然后重新构建: ``` $ scons -j6 scons: Reading SConscript files ... scons: done reading SConscript files. [...] scons: Building targets ... scons: done building targets. ``` 再次运行 QEMU,可以在你的嵌入式镜像中看到结果。 ### 你可以拥有这一切 在你的嵌入式开发中使用 Rust,你可以获得 Rust 的所有功能,而不需要牺牲灵活性或稳定性。今天就在你的嵌入式系统上试试 Rust 吧。关于嵌入式 Rust 的过程(以及 RT-Thread 本身)的更多信息,请查看 RT-Thread 项目的 [YouTube 频道](https://www.youtube.com/channel/UCdDHtIfSYPq4002r27ffqP)。请记住,嵌入式也可以是开放的。 --- via: <https://opensource.com/article/21/10/rust-embedded-development> 作者:[Alan Smithee](https://opensource.com/users/alansmithee) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Over the past several years, Rust has gained a passionate following among programmers. Tech trends come and go, so it can be difficult to separate excitement just because something is new versus excitement over the merits of a technology, but [RT-Thread](https://opensource.com/article/21/7/rt-thread-smart) community developer Liu Kang believes that Rust is a truly well-designed language. Kang says that Rust aims to help developers build reliable and efficient software, and it was designed for that purpose from the ground up. There are key features you'll hear about Rust, and in this article, Kang demonstrates that many of these features are exactly why Rust also happens to be great for embedded systems. Here are some examples: - High performance: It's fast, with high memory utilization - Reliability: Memory errors can be eliminated during compilation - Productivity: Great documentation, a friendly compiler with useful error messages, and top-notch tooling. There's an integrated package manager and build tool, smart multi-editor support with auto-completion and type inspections, an auto-formatter, and more. ## Why use Rust for embedded development? Rust is designed to guarantee both security and high performance. Embedded software can have problems, mostly due to memory. Rust is, in a way, a compiler-oriented language, so you can be sure that you're using memory safely while compiling. Here are some of the benefits of using Rust to develop on embedded devices: - Powerful static analysis - Flexible memory - Fearless concurrency - Interoperability - Portability - Community-driven In this article, I use the open source [RT-Thread operating system](https://github.com/RT-Thread/rt-thread) to demonstrate how to use Rust for embedded development. ## How to call Rust in C When calling Rust code in C code, you must package the Rust source code as a static library file. When the C code compiles, link it in. ### Creating a static library with Rust There are two steps in this process. 1. Use `cargo init --lib rust_to_c ` to build a lib library in Clion. Add the following code to the `lib.rs` . The following function evaluates the sum of two values of type **i32** and returns the result: ``` #![no_std] use core::panic::PanicInfo; #[no_mangle] pub extern "C" fn sum(a: i32, b: i32) -> i32 { a + b } #[panic_handler] fn panic(_info:&PanicInfo) -> !{ loop{} } ``` 2. Add the following code to your `Cargo.toml` file to tell Rustc what type of library to generate: ``` [lib] name = "sum" crate-type = ["staticlib"] path = "src/lib.rs" ``` ### Cross-compilation You can cross-compile for your target. Assuming your embedded system is Arm-based, the steps are simple: `$ rustup target add armv7a-none-eabi` 2. Generate the static library file: ``` $ cargo build --target=armv7a-none-eabi --release --verbose Fresh rust_to_c v0.1.0 Finished release [optimized] target(s) in 0.01s ``` ### Generate Header File You need header files, too. 1. Install [cbindgen](https://github.com/eqrion/cbindgen). The `cbindgen` tool generates a C or C++11 header file from the Rust library: `$ cargo install --force cbindgen` 2. Create a new `cbindgen.toml` file under your project folder. 3. Generate a header file: `$ cbindgen --config cbindgen.toml --crate rust_to_c --output sum.h` ### Call the Rust library file Now you can make calls to your Rust libraries. 1. Put the generated `sum.h` and `sum.a` files into the `rt-thread/bsp/qemu-vexpress-a9/applications` directory. 2. Modify the `SConscript` file and add a static library: ``` from building import * cwd = GetCurrentDir() src = Glob('*.c') + Glob('*.cpp') CPPPATH = [cwd] LIBS = ["libsum.a"] LIBPATH = [GetCurrentDir()] group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH, LIBS = LIBS, LIBPATH = LIBPATH) Return('group') ``` 3. Call the **sum** function in the main function, get the return value, and `printf` the value. ``` #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <rtthread.h> #include "sum.h" int main(void) { int32_t tmp; tmp = sum(1, 2); printf("call rust sum(1, 2) = %d\n", tmp); return 0; } ``` 4. In the RT-Thread [Env](https://www.rt-thread.io/download.html?download=Env) environment, use `scons` to compile the project and run: ``` $ scons -j6 scons: Reading SConscript files ... scons: done reading SConscript files. scons: Building targets ... [...] scons: done building targets. $ qemu.sh \ | / - RT - Thread Operating System / | \ 4.0.4 build Jul 28 2021 2006 - 2021 Copyright by rt-thread team lwIP-2.1.2 initialized! [...] call rust sum(1, 2) = 3 ``` ## Add, subtract, multiply, and divide You can implement some complicated math in Rust. In the `lib.rs` file, use the Rust language to implement add, subtract, multiply, and divide: ``` #![no_std] use core::panic::PanicInfo; #[no_mangle] pub extern "C" fn add(a: i32, b: i32) -> i32 { a + b } #[no_mangle] pub extern "C" fn subtract(a: i32, b: i32) -> i32 { a - b } #[no_mangle] pub extern "C" fn multiply(a: i32, b: i32) -> i32 { a * b } #[no_mangle] pub extern "C" fn divide(a: i32, b: i32) -> i32 { a / b } #[panic_handler] fn panic(_info:&PanicInfo) -> !{ loop{} } ``` Build your library files and header files and place them in the application directory. Use `scons` to compile. If errors appear during linking, find the solution on the official [Github page](https://github.com/rust-lang/compiler-builtins/issues/353). Modify the `rtconfig.py` file, and add the link parameter `--allow-multiple-definition` : ``` DEVICE = ' -march=armv7-a -marm -msoft-float' CFLAGS = DEVICE + ' -Wall' AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__ -I.' LINK_SCRIPT = 'link.lds' LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors,--allow-multiple-definition'+\ ' -T %s' % LINK_SCRIPT CPATH = '' LPATH = '' ``` Compile and run QEMU to see your work. ## Call C in Rust Rust can be called in C code, but what about calling C in your Rust code? The following is an example of calling the `rt_kprintf` C function in Rust code. First, modify the `lib.rs` file: ``` // The imported rt-thread functions list extern "C" { pub fn rt_kprintf(format: *const u8, ...); } #[no_mangle] pub extern "C" fn add(a: i32, b: i32) -> i32 { unsafe { rt_kprintf(b"this is from rust\n" as *const u8); } a + b } ``` Next, generate the library file: ``` $ cargo build --target=armv7a-none-eabi --release --verbose Compiling rust_to_c v0.1.0 Running `rustc --crate-name sum --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type staticlib --emit=dep-info,link -C opt-level=3 -C embed-bitcode=no -C metadata=a Finished release [optimized] target(s) in 0.11s ``` And now, to run the code, copy the library files generated by Rust into the application directory and rebuild: ``` $ scons -j6 scons: Reading SConscript files ... scons: done reading SConscript files. [...] scons: Building targets ... scons: done building targets. ``` Run QEMU again to see the results in your embedded image. ## You can have it all Using Rust for your embedded development gives you all the features of Rust without the need to sacrifice flexibility or stability. Try Rust on your embedded system today. For more information about the process of embedded Rust (and about RT-Thread itself), check out the RT-Thread project's [YouTube channel](https://www.youtube.com/channel/UCdDHtIfSYPq4002r27ffqP). And remember, embedded can be open, too. Special thanks to Liu Kang for providing this article, and for his tireless work on making embedded programming easy for everyone! ## Comments are closed.
13,922
GitUI: 用 Rust 编写的 Git 的快速命令行客户端
https://itsfoss.com/gitui/
2021-10-26T11:16:00
[ "Git" ]
https://linux.cn/article-13922-1.html
![](/data/attachment/album/202110/26/111605achvngqr6ix6vv0p.jpg) [基本的 Git 命令](https://itsfoss.com/basic-git-commands-cheat-sheet/) 对于通常的克隆、添加、提交推送已经足够好了。 但如果你在一个有多个贡献者的大型项目上工作,你可能需要将事情可视化。GUI 工具可以让你更好地了解 `diff`、`stash` 和 `blame` 的情况。 但是,如果你常用终端,又想要 Git 的舒适性,我为你准备了一个好工具。 它叫 GitUI,它提供了类似于 Git GUI 的用户体验和舒适度,但就在你的终端中。它是可移植的、快速的、自由而开源的。 ### GitUI:一个基于终端的 Git 工具 [GitUI](https://github.com/Extrawurst/gitui) 并不是第一个用于 Linux 终端的 Git 客户端。那么,是什么让 GitUI 与其他类似项目如 [lazygit](https://github.com/jesseduffield/lazygit) 或 [tig](https://jonas.github.io/tig/) 不同? GitUI 的开发者在项目的 README 文件中分享了一些基准数据。 | 名称 | 时间 | 内存(GB) | 二进制(MB) | 冻结 | 崩溃 | | --- | --- | --- | --- | --- | --- | | gitui | 24 s | 0.17 | 1.4 | 否 | 否 | | lazygit | 57 s | 2.6 | 16 | 是 | 有时 | | tig | 4 m 20 s | 1.3 | 0.6 | 有时 | 否 | *GitUI、LazyGit 和 Tig 之间的比较。* 这种优化大部分来自于 Rust 语言的使用。 **注意:该程序处于早期开发阶段,还没有为生产做好准备。** ### 在 Linux 上安装 GitUI 不用说,你应该已经 [在你的系统上安装了 Git](https://itsfoss.com/install-git-ubuntu/)。 要使用 GitUI,首先需要 [为你的 Linux 发行版安装 Rust 支持](https://itsfoss.com/install-rust-cargo-ubuntu-linux/)。 在终端中,使用以下命令: ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ![Installing Rust on Linux](/data/attachment/album/202110/26/111616fygydi5uwwiyyrnr.png) 当你被要求选择时,请选择选项 1。当脚本完成安装后,用这个命令正确设置配置: ``` source $HOME/.cargo/env ``` 现在你已经安装了 Rust 和它的包管理器 Cargo,使用 Cargo 命令来安装 GitUI: ``` cargo install gitui ``` 然后你就可以使用 GitUI了,只需在终端输入 `gitui` 就可以运行了。我做了一些示例文件来测试 Git 和 GitUI。 ![Starting gitui on terminal](/data/attachment/album/202110/26/111617b8l00of2zay9egoy.png) 值得一提的是,这个界面有一个快速而直观的纯键盘控制。一切都很简单,只需输入正确的字母即可将文件暂存、提交、分支或推送到 git 仓库中。 真正让我兴奋的是,你不仅可以做之前的四个动作,还可以**编辑**每个文件,**拉取**它,**追溯** 它,在其中**导航**等等,这一切都无需退出界面。 很棒,不是吗? ![More functions inside the interface](/data/attachment/album/202110/26/111617ioe13ez64fsv764s.png) 祝贺你! 现在你知道了如何安装 GitUI 以及它在你的终端中的样子。 如果你喜欢这个项目,请在 [GitHub](https://github.com/Extrawurst/gitui) 上点赞它的仓库。如果你使用其他工具来管理 Git,请在评论区提出你的建议。 --- via: <https://itsfoss.com/gitui/> 作者:[Marco Carmona](https://itsfoss.com/author/marco/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
The [basic Git commands](https://itsfoss.com/basic-git-commands-cheat-sheet/) are good enough for the usual clone, add, commit push. But if you are working on a large project with multiple contributors, you may need to visualize things. A GUI tool gives a better view on the diff, stash and blame. But then, if you are a terminal dweller, who wants the comfort of GUI with Git, I have got a good tool for you. It is called GitUI and it provides user experience and comfort similar to a git GUI but right in your terminal. It is portable, fast, free and open source. ## GitUI: A terminal based tool for Git [GitUI](https://github.com/Extrawurst/gitui) is not the first Git client for Linux terminal. So, what makes GitUI different than other similar projects like [lazygit](https://github.com/jesseduffield/lazygit) or [tig](https://jonas.github.io/tig/)? GitUI developer has shared some benchmark in the README file of the project. Time | Memory (GB) | Binary (MB) | Freezes | Crashes | | gitui | 24 s | 0.17 | 1.4 | No | No | lazygit | 57 s | 2.6 | 16 | Yes | Sometimes | tig | 4 m 20 s | 1.3 | 0.6 | Sometimes | No | Most of this optimization comes from the use of Rust programming language. *Note: This program is in early stages of development and is not production ready yet.* ## Installing GitUI on Linux Needless to say, you should have [Git installed on your system](https://itsfoss.com/install-git-ubuntu/) already. To use GitUI, you need to [install Rust support for your Linux distribution](https://itsfoss.com/install-rust-cargo-ubuntu-linux/) first. In a terminal, use the following command: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` ![Installing rust on Linux](https://itsfoss.com/content/images/wordpress/2021/10/Installing-Rust-step-1-800x471.png) Go with option 1 when you are asked for a choice. When script finishes installation, set the configuration right with this command: `source $HOME/.cargo/env` Now that you have Rust and its package manager Cargo installed, use the Cargo command to install GitUI: `cargo install gitui` And you’re ready to use GitUI, for that just type `gitui` in the terminal to run it. I made some sample files to play with Git and GitUI. ![starting gitui on terminal](https://itsfoss.com/content/images/wordpress/2021/10/Starting-GitUI-on-terminal-800x471.png) It’s important to mention that the interface has a fast and intuitive keyboard-only control. Everything is as easy as type the correct letter to stage, commit, branch, or push your files into your git repository. Something that really gets me excited was that you can not only do the four actions before, but you can also **edit** each file, **pull** it, **blame** it, **navigate** inside it, and more things; everything without existing from the interface. Awesome, isn’t it? ![more functions inside the interface](https://itsfoss.com/content/images/wordpress/2021/10/More-functions-inside-the-interface-800x471.png) Felicitations! Now you know how to install GitUI and how it looks like in your terminal. If you like the project, start its repository on [GitHub](https://github.com/Extrawurst/gitui). If you use some other tool to manage Git, please suggest your favorite in the comment section.
13,924
在 OpenTTD 中玩模型火车
https://opensource.com/article/21/9/model-trains-openttd
2021-10-27T10:03:39
[ "OpenTTD", "火车" ]
https://linux.cn/article-13924-1.html
> > 想玩实体模型火车,却没有足够大的空间?试试 OpenTTD 中的虚拟火车吧。 > > > ![](/data/attachment/album/202110/27/100255emc3x33icci0cacc.jpg "Old train") 我父亲一直很喜欢火车模型,我记得我小时候,曾看着他在圣诞树周围建了一整条轨道。当 [乐高](https://opensource.com/article/20/6/open-source-virtual-lego) 火车套装发布时,因其便利性和固有可扩展性,我们转而投向了乐高火车的怀抱。多年来,我们热衷于建造和改装乐高火车及单轨轨道。我经常想象,未来我会有一个车库或地下室,专门用于微型景观和电动汽笛火车。强调一下,我沉迷于另一个爱好的可能性非常低,所以当发现 *虚拟* 模型铁路可以为我提供相同的满足感时,我很开心。我的虚拟爱好引擎是 [OpenTTD](http://openttd.org),这是一款基于名为 **Transport Tycoon Deluxe** 的 90 年代老游戏的开源模拟游戏。 ### 安装 OpenTTD 你可以在 [openttd.org/downloads](https://www.openttd.org/downloads/openttd-releases/latest.html) 下载适用于 Linux、macOS 和 Windows 的 OpenTTD。 如果你正使用 Debian Linux 或其衍生产品,甚至是[在使用 Chromebook](https://opensource.com/article/21/2/chromebook-linux),你可以下载 `.deb` 包。使用 `apt` 命令安装它: ``` $ sudo apt install ./openttd*deb ``` 如果你在使用其他 Linux 发行版,请下载通用安装程序,并使用 [tar 命令](https://opensource.com/article/17/7/how-unzip-targz-file)解压缩包: ``` $ tar xvf openttd-x.yy.z-linux*.tar.xz ``` OpenTTD 已经在 Linux、macOS 和 Windows 的 [Steam](https://store.steampowered.com/app/1536610/OpenTTD/) 中上架(Steam 是一个非开源的,但是很常见的跨平台游戏客户端)。 ### 启动 OpenTTD 如果你安装了 OpenTTD,可以从应用程序菜单启动它。 如果你是下载了通用包,可以切换到游戏目录,使用本地的 `openttd` 命令启动游戏: ``` $ cd openttd* $ ./openttd &amp; ``` 首次启动 OpenTTD 时,游戏会提示必须下载图像集,在 Steam 版中会自动安装,但在独立应用程序中需要单击一下鼠标。无论如何,因为 OpenTTD 是开源的,经过了很好的改进,所以在默认图像之外,你最终还会下载的还有很多其他图像。 下载图像集后,你会看到一个古色古香的小型界面。我觉得 640x480 的界面有点小,虽然旧图像界面确实更有年代感(那时计算能力还比较弱),但一些适配现代屏幕的轻度升级还是很好用的。因此,你的第一步操作就是点击“<ruby> 检查在线内容 <rt> Check online content </rt></ruby>”按钮。 ### 加载模组 “<ruby> 内容下载 <rt> Content downloading </rt></ruby>”界面是一个查看已通过审查的 OpenTTD <ruby> 模组 <rt> mod </rt></ruby>的窗口,可以提供个性化的改进图像界面、全新音乐、火车模型和地图名称。我使用了新西兰全套配置,所以对我来说,生成的所有城市都很熟悉,尽管 2020 年我转而开始使用“辐射 3”套装了。模组 *非常多*,可以使用右上角的搜索栏来缩小选择范围。 下面是一些个人认为必备的模组: * **abase** - 高分辨率图像。将近 300 MB,这可能是你玩此游戏需要的最大一次下载(游戏本身只有 50 MB)。 * **OpenSFX** - 一个声音合集。让你能听到城市中的交通声、船运的喇叭声以及很棒的火车汽笛声。 * **Town names** - 城镇名称。默认的城市名称很有趣,但我认为记一些本地化的名称更容易。 * **Trains** - 火车模组。OpenTTD 有一组运行良好的默认火车模型,但如果你已经是一名火车观察员,那你可能会喜欢下载一些额外的火车模型。我使用的是 NZR 火车合集,但还有很多火车也是可用的,包括来自英国、美国、奥地利、比利时、捷克共和国的车,以及按字母表顺序排列的许多其他火车。 * **Beginner tutorial** - 新手教程。是一个帮你学习游戏及界面的引导场景。 ### 游戏引擎默认值 下载新素材后,你需要将它们设置为默认值。有两个设置的地方:游戏引擎默认值、游戏内脚本与素材。 ![OpenTTD main menu](/data/attachment/album/202110/27/100341hk4b55r5kfdzfzbj.jpg "OpenTTD menu") *OpenTTD 菜单(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 单击“<ruby> 游戏选项 <rt> Game Options </rt></ruby>”按钮。 在游戏选项屏幕中,调整以下设置: * 将<ruby> 屏幕分辨率 <rt> screen resolution </rt></ruby>设置为你喜欢的界面尺寸。 * 将<ruby> 基础图像集 <rt> base graphics set </rt></ruby>设置为 **abase**。 * 将<ruby> 基础声音设置 <rt> base sounds set </rt></ruby>设置为 **OpenSFX**。 关闭游戏选项屏幕。你的改动会自动保存。 ### 游戏选项 在主菜单界面,单击“<ruby> NewGRF 设置 <rt> NewGRF Settings </rt></ruby>”按钮。 ![NewGRF settings window](/data/attachment/album/202110/27/100342pk0gntaosokdtczd.jpg "The NewGRF settings menu") *NewGRF 设置菜单(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 未活动的模组显示在 NewGRF 设置窗口的下半部分。要激活一个未活动的模组,请选择它并单击左下角的“<ruby> 添加 <rt> Add </rt></ruby>”按钮。选择要激活的模组后,再单击“<ruby> 应用 <rt> Apply </rt></ruby>”按钮。 ### 教程 如果你下载了“<ruby> 初学者教程 <rt> Beginner tutorial </rt></ruby>”场景,可以通过它来学习 OpenTTD。开始教程请单击主菜单屏幕顶部附近的“<ruby> 播放场景 <rt> Play scenario </rt></ruby>” 按钮,然后选择该教程并开始。 初学者教程有着游戏界面的完整浏览流程,全部完成需要花费一些时间。 ### 快速开始 现在我们快速介绍一下,此处你要了解以下内容:车辆出自仓库,一切活动都需要时间表。记住这两条规则,你可以立即开始建造火车(以及道路、海港和机场)。 #### 建造车站 要在两个城市之间建立一条简单的铁路线,请单击顶部图标栏中的铁路轨道图标。 ![New icon bar - railway option](/data/attachment/album/202110/27/100342ebb8el38xngbba4d.jpg "The new icon bar - railway option") *新建图标栏——铁路选项(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 铁路以车站开始和结束,所以我通常在预定线路的两端各放置一个车站。单击火车站图标(将鼠标悬停在其上方可查看其标签)。一个火车站要服务于一个地区,其作用范围必须与该地区尽量多地重叠。要查看车站的覆盖范围,请通过单击车站对话框底部的“<ruby> 开启 <rt> On </rt></ruby>”按钮以启用<ruby> 覆盖区域高亮 <rt> Coverage area highlight </rt></ruby>功能。 ![Station coverage window](/data/attachment/album/202110/27/100342juxo12xukct1ho1k.jpg "Station coverage information window") *车站覆盖信息窗口(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 黑色网格表示覆盖范围,而白色网格显示车站的物理占据范围。当你将鼠标悬停在一个区域上时,车站的覆盖范围所需耗材会在弹出窗口中列出。从简单的开始,创建一个单轨 4 辆车的站台。在地图上的两个城市之间重复执行此操作两次。 ![create station menu](/data/attachment/album/202110/27/100343g08qpqozjztjj3sz.jpg "The create station menu") *创建车站菜单(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* ### 铺设铁轨 接下来,用铁轨连接车站。 OpenTTD 的等距视图需要一些时间来适应,但是在单击铁路图标并在地图上单击拖动之后,你就开始大概有所了解了。X-rail 图标提供了“自动轨道”模式,该模式会根据用户单击的方块位置对齐轨道。 铺设导轨时要细心。OpenTTD 是不可撤回的,所以一旦点击一个正方形,轨道就会被构造出来。你必须使用炸药图标来移除导轨。和现实生活中一样,没有撤消按钮。 ### 火车车库 火车来自<ruby> 车库 <rt> depot </rt></ruby>。因此,要在铁路上添加火车,必须在沿线的某处添加一个车库。单击车库图标并在现有铁路附近放置。将车库连接到现有轨道,以确保你的火车可以从车库到达适当线路的(在此简单示例中,线路是唯一的)。 ![create depot menu](/data/attachment/album/202110/27/100343tko4e84ie94oj4ot.jpg "Create depot menu") *建造车库菜单(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* ### 模型火车 终于,你可以将虚拟模型火车添加到虚拟铁路中了。要创建火车,请单击车库。 单击站点窗口底部的“<ruby> 新建车辆 <rt> New Vehicle </rt></ruby>”按钮,会列出可用的火车引擎和汽车。列表会部分取决于你从可下载内容中添加的模型。一般来说,发动机分为三种:蒸汽发动机、柴油发动机和电动发动机。游戏内时间从 1950 年开始,所以早期你只有蒸汽可选。随着时间推进,你会获得可用于升级的创新型新模型。 ![create train menu](/data/attachment/album/202110/27/100343z5iit6yeye5r75v6.jpg "The create train menu") *创建火车菜单(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 现在创建一个简单的火车,其中包括一节引擎、一节客车和一节邮车。如果想添加其他类型的车厢,请单击站点以确认它们的可提供车型(由其覆盖区域决定) ### 创建火车时刻表 现在有了铁路和火车,还需要创建一个火车时刻表。时间表与车辆关联,因此无论何时添加新车,都要记得添加时间表,以让新车投入使用。 要为火车添加时刻表,请单击其车库列表中列车左侧的编号。这样可以打开火车视口,窗口右侧会有按钮。单击箭头图标即可查看该列车的时刻表。 ![create schedule menu](/data/attachment/album/202110/27/100344dnd729bub6cxb652.png "The create schedule menu") *创建时刻表菜单(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 要创建时间表,请单击时间表窗口底部的“<ruby> 前往 <rt> Go To </rt></ruby>”按钮,然后单击要设置成第一个目的地的车站。然后点击下一站。你可以在时间表中选择一个停靠点,浏览“<ruby> 满载 <rt> Full load </rt></ruby>”和“<ruby> 卸载 <rt> Unload </rt></ruby>”下拉菜单中的选项,以此调整装卸要求,并且可以在“<ruby> 无停靠 <rt> Non-stop </rt></ruby>”下拉菜单中调整路线(如果开发了新路线)。选项有很多,随着城市发展和地图完善,你可能需要随时调整策略。 但是现在,单击火车视口底部的红色“<ruby> 已停止 <rt> Stopped </rt></ruby>”按钮,让火车投入使用吧! ![train moving from station to station](/data/attachment/album/202110/27/100344p5xt8ulqqdtrdxdz.jpg "Train in service") *在役中的火车(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* ### 试试 OpenTTD 吧 OpenTTD 是一个模拟器,同时也是一个游戏,所以确实会有一些限制,比如你可能想要优化的预算和参数。例如,你可以单击一个城市、农场或工厂,了解其可接受的进出口类型。你可以通过单击 OpenTTD 窗口右下角的预算按钮来借钱。它不仅仅是一个虚拟的火车集合游戏。你还可以建造道路、机场、海港等。记得所有车辆都需要车库和时间表,你就在实现虚拟企业的路上成功了一半。 OpenTTD 有着活跃而热情的社区,以及[详细的维基](https://wiki.openttd.org/en/),并且有大量的资源和教程在线可用。下载游戏并试试吧! --- via: <https://opensource.com/article/21/9/model-trains-openttd> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[unigeorge](https://github.com/unigeorge) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
My father has always been fond of model trains, and I remember watching him building a track around the Christmas tree when I was young. When [Lego](https://opensource.com/article/20/6/open-source-virtual-lego) train sets were released, he and I transitioned to them for their convenience and inherent extensibility. We built and operated Lego trains and monorail tracks over the course of many years. I've often imagined a possible future in which I have a garage or a basement dedicated to miniature landscapes and electric whistling trains. Then again, the probability of me diving that severely into yet another hobby is pretty low, so I was very happy to discover that *virtual* model railways can provide me with much of the same satisfaction. The engine for my virtualized hobby is [OpenTTD](http://openttd.org), an open source simulation game based on an old '90s game called **Transport Tycoon Deluxe**. ## Installing OpenTTD You can download OpenTTD for Linux, macOS, and Windows from [openttd.org/downloads](https://www.openttd.org/downloads/openttd-releases/latest.html). If you're running Debian Linux or one of its derivatives, or even [running it on a Chromebook](https://opensource.com/article/21/2/chromebook-linux), you can download the `.deb` package. Install it with `apt` : `$ sudo apt install ./openttd*deb` If you're using any other Linux distribution, download the generic installer and extract the package with [the tar command](https://opensource.com/article/17/7/how-unzip-targz-file): `$ tar xvf openttd-x.yy.z-linux*.tar.xz` OpenTTD is also available on [Steam](https://store.steampowered.com/app/1536610/OpenTTD/) for Linux, macOS, and Windows (Steam isn't open source, but it's a common cross-platform gaming client). ## Launch OpenTTD If you installed OpenTTD, you can launch it from your application menu. If you're downloaded the generic package, change into the directory and launch the game using the local `openttd` command: ``` $ cd openttd* $ ./openttd & ``` The first time you launch OpenTTD, it alerts you that you must download a graphic set. This is automatically installed in the Steam edition, but it's a single-click in the stand-alone app. And anyway, because OpenTTD is open source, it's well modded, so you'll end up downloading a lot more than just the default graphics. After the graphics have been downloaded, you're presented with the quaintly diminutive interface. I find a 640x480 interface a little small, and while the old graphics do hearken back to simpler computing days, a slight upgrade for modern screens is helpful. For that reason, your first stop is the **Check online content** button. ## Loading mods The **Content downloading** screen provides you with a window to approved OpenTTD mods, giving improved graphics, new music, train models, and map names appropriate to your location or interests. I use the New Zealand set, so all of my generated cities sound familiar, although, since 2020, I've started using the Fallout 3 set. There are *a lot* of mods, so use the search bar in the top right to narrow your choices. Here are the mods I consider essential: **abase**- High res graphics. At nearly 300 MB, this is the largest download you're likely to need (the game itself is barely 50 MB).**OpenSFX**- A sound set so you can hear the traffic in cities, the horns of the boating industry, and the very satisfying whistles of trains.**Town names**- The default names of cities are fun, but I find it easier to remember names that feel local.**Trains**- OpenTTD has a default set of train models that work perfectly well, but if you're a trainspotter already, then you might enjoy downloading some additional train sets. I use the NZR set, but there are many trains available, including trains from the UK, the USA, Austria, Belgium, Czech Republic, and on and on down the alphabet.**Beginner tutorial**- A scenario to help you learn the game and its interface. ## Game engine defaults Once you download your new assets, you must set them as your defaults. There are two places for this: Game engine defaults and in-game scripts and assets. ![OpenTTD menu OpenTTD main menu](https://opensource.com/sites/default/files/openttd-menu.jpg) The OpenTTD menu Click the **Game Options** button. In the **Game Options** screen, adjust these settings: - Set the **screen resolution**to your preferred interface size. - Set **base graphics set**to**abase.** - Set **base sounds set**to**OpenSFX.** Close the **Game Options** screen. Your changes are saved automatically. ## Game options From the main menu screen, click the **NewGRF Settings **button. ![The NewGRF settings menu NewGRF settings window](https://opensource.com/sites/default/files/openttd-newgrf.jpg) The NewGRF settings menu Inactive mods are listed at the bottom of the **NewGRF Settings** window. To activate one, select it and click the **Add** button in the bottom left. Once you've chosen the mods to activate, click the **Apply** button. ## Tutorial If you downloaded the **Beginner tutorial** scenario, you could learn OpenTTD by playing through it. To start the tutorial, click the **Play scenario** button near the top of the main menu screen. Select the tutorial and begin. The tutorial gives you a full tour of the game's interface, and it takes some time to get through it. ## Quickstart By way of a quicker introduction, here's what you need to know: vehicles come from depots, and everything needs a schedule. By remembering those two rules, you can start building trains (and roads and seaports and airports) right away. **Build stations** To build a simple rail line between two cities, click the railway track icon in the top icon bar. ![The new icon bar - railway option New icon bar - railway option](https://opensource.com/sites/default/files/openttd-iconbar-railway.jpg) The new icon bar - railway option Railways start and end with stations, so I usually place a station at each end of my intended line. Click the train station icon (mouse over it to see its label). For a train station to serve a region, its area of effect must overlap with as much of the region as possible. To see a station's coverage, enable **Coverage area highlight** by clicking the **On** button at the bottom of the station dialog box. ![Station coverage information window Station coverage window](https://opensource.com/sites/default/files/openttd-window-station.jpg) Station coverage information window The dark grid overlay represents coverage, while the white grid overlay shows the physical footprint of the station. As you hover over an area, the supplies that a station's coverage enables are listed in the station popup window. Start simple and create a single-track, 4-car platform. Do this twice between two cities on the map. ![The create station menu create station menu](https://opensource.com/sites/default/files/openttd-create-station.jpg) The create station menu ## Lay the rails Next, connect the stations with rails. The isometric view of OpenTTD takes some getting used to, but after clicking on the rail icons and clicking and dragging on the map, you start to get a feel for it. The X-rail icon provides an "autorail" mode, which aligns the track based on where in a square you click. Be careful as you lay your rails. OpenTTD is rather unforgiving, so once you click in a square, rails are constructed. You must use the dynamite icon to remove rails. Just like in real life, there's no undo button. ## Train depot Trains come from a depot. So to add a train to your railway, you must add a depot somewhere along the line. Click the depot icon and place a depot near an existing rail. Connect the depot to an existing track to ensure your trains can get from the depot to the appropriate (in this simple example, the only) line. ![Create depot menu create depot menu](https://opensource.com/sites/default/files/openttd-create-depot.jpg) The create depot menu ## Model trains At long last, you get to add a virtual model train to your virtual railway. To create a train, click on your depot. Click the **New Vehicle** button at the bottom of the depot window to list available train engines and cars. The list you get depends partly on what models you've added from the downloadable content. Generally, there are three types of engines: Steam, diesel, and electric. Early in the game, which starts in the year 1950, you have only steam. As the years progress, you get innovative new models you can use as upgrades. ![The create train menu create train menu](https://opensource.com/sites/default/files/openttd-create-train.jpg) The create train menu For now, create a simple train that includes an engine, a passenger car, and a mail car. If you want to add other kinds of cars, click on your stations to confirm the types of supplies they're able to accept (as determined by its area of coverage). ## Create a train schedule Now that you have a railway and a train, you must create a train schedule. Schedules are attached to vehicles, so any time you add a new vehicle of any kind, you must add a schedule for it to be useful. To add a schedule to your train, click the number to the left of the train in its depot listing. This opens a viewport for the train, with buttons along the right side of the window. Click the arrow icon to see that train's schedule. ![The create schedule menu create schedule menu](https://opensource.com/sites/default/files/openttd-create-schedule.png) The create schedule menu To create a schedule, click the **Go To** button at the bottom of the schedule window, and then click on the station you want to set as the first destination. Then click the next station. You can adjust loading and unloading requirements by selecting a stop in the schedule and browsing the options in the **Full load** and **Unload** drop-down menus, and you can adjust routes (should you develop new routes) in the **Non-stop** drop-down menu. The options are plentiful, and as cities grow and your map becomes more developed, you may have to adjust your strategy. But for now, click the red **Stopped** button at the bottom of your train viewport to put your train into service! ![Train in service train moving from station to station](https://opensource.com/sites/default/files/openttd-train.jpg) Train in service ## Try OpenTTD OpenTTD is a simulator, but it's also a game, so you do have constraints, including a budget and parameters you might want to optimize. For instance, you can click on a city, farm, or factory to discover what kind of imports and exports are acceptable to it. You can borrow money by clicking the budget button in the bottom right corner of the OpenTTD window. And it's not just a virtual train set. You can build roads, airports, seaports, and more. Just remember that all vehicles need depots and schedules, and you're halfway to a successful virtual enterprise. OpenTTD has an active and enthusiastic community, [an extensive wiki](https://wiki.openttd.org/en/), and there are lots of resources and tutorials available online. Download the game and give it a try! ## 4 Comments
13,926
Mark Text:我最喜欢的 Markdown 编辑器
https://opensource.com/article/21/10/mark-text-markdown-editor
2021-10-27T14:13:16
[ "Markdown" ]
/article-13926-1.html
> > Mark Text 拥有的工具使得撰写 Markdown 变得容易,同时又提供了一个不会打扰我的简单的界面。 > > > ![](/data/attachment/album/202110/27/141244m9os557ss7au6oas.jpg "Typewriter keys in multicolor") 几年前,当我开始使用 Jupyter 笔记本时,我接触到了 Markdown 格式。许多作者都知道 Markdown,但这是我不熟悉的一种技能。 Markdown 是一种标准的文本写作方式,在这种方式中,你可以用精简的符号来标记你想要的文本样式。例如,你不用点击一个按钮来使一个词变粗体,而是用两个星号(`**word**`)包围这个词。这有两种效果: * 当作为纯文本查看时,视觉上显示出强调的文本 * 如果有一个好的文本转换器或渲染器(如 Pandoc 或一个好的 Markdown 文本编辑器),就会显示为加粗。 Markdown 最大的优点之一是它的大部分符号都是直观的,并且来自我们大多数人已有的习惯。它使得用星号强调单词,用字符标记标题以区分它们等等变得很自然。 每个人都对它评价很高,但我不确定为什么我需要学习和使用 Markdown。然而,我是一个好奇的人,我开始探索 Markdown,以及它如何在我的写作中发挥作用。 ### 学习 Markdown 我很喜欢在学习时使用 [Markdown 速查表](https://opensource.com/downloads/cheat-sheet-markdown)。我发现 Markdown 是一个很好的工具,可以写任何内容,而且我很喜欢甚至不需要一个专门的 Markdown 编辑器这一点。任何文本编辑器都可以写 Markdown,因为 Markdown 使用标准文本来表示样式。我开始使用简单的编辑器,如 Vim 或 gedit(或任何其他编辑器),并查阅这个速查表以记住简单的格式化规则。 今年我一直在写日记,作为组织我的想法和学习更多关于 Markdown 的方法。我最近尝试了 [Ghostwriter](https://wereturtle.github.io/ghostwriter/) 文本编辑器,这是一个优秀的编辑器,有一些额外的 Markdown 特定功能。Markdown 现在已经变得非常流行了,许多编辑器都加入了语法高亮、提示和其他使 Markdown 编写变得容易的功能,或者将其作为重点。它们不是必须的功能,但当你拥有它们时,还是很好的。 ### 尝试 Mark Text 在阅读一个博客时,我发现了 [Mark Text](https://marktext.app/)。Mark Text 使写 Markdown 变得很容易,同时提供了一个简单的界面,而且又不影响我。Mark Text 有六个主题,三个浅色和三个深色主题。深色主题对我来说更容易使用。它的 [用户文档](https://github.com/marktext/marktext/blob/master/docs/README.md) 非常好,而且也提供了 Markdown 的 [语法帮助](https://github.com/marktext/marktext/blob/master/docs/MARKDOWN_SYNTAX.md)。 ### Markdown 的实时预览 Mark Text 以简洁的界面提供了实时预览功能。它支持 [Commonmark](https://commonmark.org/) 规范、Github 风格的 Markdown 规范,以及 Pandoc Markdown。据其网站说,Mark Text 还支持 KaTex、front matter 和 emoji 等 Markdown 扩展。它还可以输出 HTML 和 PDF 文件。 Mark Text 有各种编辑模式,如打字模式、源代码模式和专注模式。添加图片是一件很容易的事,因为你可以简单地从剪贴板上复制和粘贴它们。 在 Mark Text 窗口的左上方有一个弹出窗口,显示迄今为止输入的字符和段落数量。作为一个作家,这真的很有帮助。 从 Mark Text 窗口左上方的菜单或使用 `Ctrl+S` 保存文件很容易。事实上,Mark Text 的菜单对任何习惯于基本文本编辑器或文字处理器的人来说都是友好和熟悉的。 ![Mark Text 文件菜单](/data/attachment/album/202110/27/141318ya6p3ppzkq1w83mb.png "Mark Text file menu") 我喜欢 Mark Text 用简单的快捷键支持各种格式,包括表格块、图表、行内格式、数学公式块和其他代码块。 你可以从以下链接中为你的操作系统下载 Mark Text: * [Linux](https://github.com/marktext/marktext/releases/latest/download/marktext-x86_64.AppImage) * [macOS](https://github.com/marktext/marktext/releases/latest/download/marktext.dmg) * [Windows](https://github.com/marktext/marktext/releases/latest/download/marktext-setup.exe) Mark Text 以 [MIT](https://github.com/marktext/marktext/blob/develop/LICENSE) 许可证开源。你可以随时 [下载](https://github.com/marktext/marktext/releases) 最新的版本。 另外,你可以用 `brew install --cask mark-text` 在 macOS 上安装 Mark Text,在 Windows 上用 [Chocolatey](https://chocolatey.org/) 输入 `choco install marktext` 来安装它。 Mark Text 一直在寻找赞助商和开发者。该项目有一个给贡献者的 [指南](https://github.com/marktext/marktext/blob/develop/CONTRIBUTING.md)。此外,你可以在 Patreon 和 Open Collective 上支持该项目。 --- via: <https://opensource.com/article/21/10/mark-text-markdown-editor> 作者:[Don Watkins](https://opensource.com/users/don-watkins) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
13,928
如何在 Linux 下将网页转换为 PDF 文件
https://itsfoss.com/convert-webpage-pdf-linux/
2021-10-28T11:18:07
[ "PDF" ]
https://linux.cn/article-13928-1.html
![](/data/attachment/album/202110/28/111738tncncbml6jwcz6s8.jpg) 当你将某些资源存档或用于教育目的时,将网页保存为 PDF 是很方便的。 但是,你如何在 Linux 中把一个网页转换成 PDF? 你可以选择使用每个 Linux 发行版上的网页浏览器(GUI),或者使用终端将网页变成 PDF 文件。 在这里,我将提到这两种方法来帮助你完成工作。 ### 方法 1:使用网页浏览器将网页转换为 PDF 文件 尽管我在本教程中使用的是 Mozilla Firefox,但你也可以用任何 [可用于 Linux 的最佳浏览器](https://itsfoss.com/best-browsers-ubuntu-linux/) 做同样的事情。 ![](/data/attachment/album/202110/28/111807iuvumpvtfgm5rrmr.png) 1、加载你想转换的网页。 2、在浏览器菜单中找到“**打印**”选项,或使用键盘快捷键 `Ctrl + P`。 3、默认情况下,它应该让你把它保存为 PDF。你需要点击“保存”,然后选择目的地并保存网页。 ![Save webpage as PDF in Mozilla Firefox](/data/attachment/album/202110/28/111808uwjawr8u91ajfbo1.png) 这种简单方法的一个主要问题是,它包括页面上的所有元素。这可能包括评论、页脚等。你可以用一个 PDF 编辑器来删除部分内容,但这是一个额外的任务。 更好的选择是利用一个浏览器扩展,如 [Print Friendly](https://www.printfriendly.com/)。它允许你在下载 PDF 之前编辑和删除网页的部分内容。 ### 方法 2:使用终端将网页转换为 PDF 或图片 你可能已经知道,你可以 [在 Linux 终端浏览互联网](https://itsfoss.com/terminal-web-browsers/),甚至 [使用命令行下载文件](https://itsfoss.com/download-files-from-linux-terminal/)。这并不奇怪,因为你可以在终端中做更多的事情,包括将网页下载为 PDF。 一个灵巧的开源命令行工具 `wkhtmltopdf` 和 `wkhtmltoimage` 可以帮到你,让你把任何 HTML 网页转换成 PDF 或图像文件。 它使用 Qt WebKit 渲染引擎来完成这个任务。你可以浏览它的 [GitHub页面](https://github.com/wkhtmltopdf/wkhtmltopdf) 了解更多信息。 你应该能够从你的 Linux 发行版的默认仓库中安装它。对于基于 Ubuntu 的发行版,你可以输入以下命令: ``` sudo apt install wkhtmltopdf ``` 无论你想把它转换为 PDF 还是图像文件,它的使用都是非常直接的: ![](/data/attachment/album/202110/28/111808nmympbkwrgl3lwzv.png) 要将一个网页转换成 PDF,请输入: ``` wkhtmltopdf URL/domain filename.pdf ``` 比如,类似于这样: ``` wkhtmltopdf linuxmint.com mint.pdf ``` 你可以选择使用 `https://linuxmint.com` 这样完整的 URL 或使用域名,如上面的例子所示。 默认情况下,生成的文件将保存在主目录下。 在转换网页时,你还可以得到一些好玩的选项。 例如,你可以**对 PDF 文件应用灰度过滤器**,在同一文件中**制作多个页面副本**,以及在转换过程中**排除**图像。 灰度过滤器不一定对每个网页都有效,但你可以用命令试试: ``` wkhtmltopdf -g google.com googlepage.pdf ``` 要在同一个 PDF 文件中复制多个页面,命令是: ``` wkhtmltopdf --copies 2 linuxmint.com mint.pdf ``` 而且,如果你想排除网页中的图像,只需输入: ``` wkhtmltopdf --no-images linuxmint.com mint.pdf ``` 此外,如果你想把一个网页转换为图像,命令是这样的: ``` wkhtmltoimage linuxmint.com mint.png ``` 注意,与使用浏览器的 GUI 方法不同,通过终端使用这些工具有其局限性。它似乎不能成功转换利用任何 `<iframe>` 代码片段的网页。 像我们的网站,甚至 DuckDuckGo 都没有转换为 PDF 或图像。然而,简单的 HTML 网站,如 [Linuxmint.com](http://Linuxmint.com)、[Ubuntu.com](http://Ubuntu.com)、[Google.com](http://Google.com) 则非常有效。 ### 总结 使用浏览器将网页保存为 PDF 似乎是个好办法。但是,如果你想有更多的选择并通过终端,`wkhtmltopdf` 工具应该会派上用场。 你喜欢如何在 Linux 中把网页转换为 PDF?欢迎在评论中分享你的想法。 --- via: <https://itsfoss.com/convert-webpage-pdf-linux/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Saving a webpage as a PDF comes in handy when you archive certain resources or use them for educational purposes. But, how do you convert a webpage to PDF in Linux? *You can either choose to go the easy way out using the web browser (GUI) on every Linux distribution or use the terminal to turn a webpage into a PDF file.* Here, I shall mention both the methods to help you get the job done. ## Method 1: Converting a Webpage to PDF Using Web Browser Even though I use Mozilla Firefox for this tutorial, you can do the same thing with any of the [best browsers available for Linux.](https://itsfoss.com/best-browsers-ubuntu-linux/) ![mozilla save webpage pdf](https://itsfoss.com/content/images/wordpress/2021/10/mozilla-save-webpage-pdf.png) 1. Load up the webpage you want to convert. 2. Head to the browser menu to find the “**Print**” option or use the keyboard shortcut “**Ctrl + P**.” 3. By default, it should let you save it as a PDF. You need to hit “Save,” and choose the destination and save the webpage. ![Save webpage as PDF in Mozilla Firefox](https://itsfoss.com/content/images/wordpress/2021/10/mozilla-firefox-print-pdf-1.png) The one major problem with this simple approach is that it includes all the elements on the page. This may include comments, footer etc. You may use a PDF editor to remove parts of it but that’s an additional task. *A better option is to utilize a browser extension like Print Friendly. It allows you to edit and remove parts of the webpage before downloading the PDF.* ## Method 2: Converting a Webpage to PDF or Images Using the Terminal You probably already know that you can [browse internet in Linux terminal](https://itsfoss.com/terminal-web-browsers/) and even [download files using the command line](https://itsfoss.com/download-files-from-linux-terminal/). That’s not surprising considering you can do a lot more in the terminal, including downloading a webpage as PDF. A nifty open-source command-line tools **wkhtmltopdf** and **wkhtmltoimage** come to the rescue that lets you convert any HTML webpage to a PDF or image file. It utilizes the Qt WebKit rendering engine to get the task done. You can explore its [GitHub page](https://github.com/wkhtmltopdf/wkhtmltopdf) for more information. You should be able to install it from the default repository of your Linux distribution. For Ubuntu-based distros, you can type in the command: `sudo apt install wkhtmltopdf` It is pretty straightforward to use no matter whether you want to convert it to a PDF or image file: ![htmltopdf mint](https://itsfoss.com/content/images/wordpress/2021/10/htmltopdf-mint.png) To convert a webpage into a PDF, type in: `wkhtmltopdf URL/domain filename.pdf` As an example, here’s how it would look: `wkhtmltopdf linuxmint.com mint.pdf` You can choose to use the complete URL as “**https://linuxmint.com**” or use the domain name as shown in the example above. The file generated will be saved in the home directory by default. You also get a few exciting options when converting a webpage. For instance, you can **apply a grayscale filter to the PDF file**, **make multiple copies of the page** in the same file, and **exclude images** during conversion. The grayscale filter may not work on every webpage, but you can try that using the command: `wkhtmltopdf -g google.com googlepage.pdf` To make multiple copies of pages in the same PDF file, the command would be: `wkhtmltopdf --copies 2 linuxmint.com mint.pdf` And, if you want to exclude images from the web pages, just type: `wkhtmltopdf --no-images linuxmint.com mint.pdf` Additionally, if you want to convert a webpage as an image, the command would look like this: `wkhtmltoimage linuxmint.com mint.png` Note that unlike the GUI method using a browser, using these tools via the terminal has its limitation. It does not seem to convert web pages utilizing any <iframe> code snippets successfully. Sites like ours and even DuckDuckGo didn’t convert to PDF or an image. However, simple HTML sites like Linuxmint.com, Ubuntu.com, Google.com, worked like charm. ## Wrapping Up To get the best results, saving a webpage as a PDF using a browser seems to be the way to go. But, if you want more options and go through the terminal, the **wkhtmltopdf** utility should come in handy. How do you prefer to convert web pages to PDF in Linux? Feel free to share your thoughts in the comments.
13,929
有哪些 Linux 平板电脑可供选择
https://itsfoss.com/linux-tablets/
2021-10-28T17:27:00
[ "Linux", "平板" ]
https://linux.cn/article-13929-1.html
![](/data/attachment/album/202110/28/180114mism33m44sibmsc9.jpg) 有很多 [基于 Linux 的笔记本电脑](/article-13672-1.html),也有 [预装了 Linux 的迷你 PC](https://itsfoss.com/linux-based-mini-pc/),而市场上还有一些 [基于 Linux 的智能手机](/article-13711-1.html)。 那平板电脑呢?有没有一些不错的基于 Linux 的平板电脑?这可能不能用一句话说清楚。 许多仅使用 Linux 的系统制造商专注于制造台式电脑。这主要是由于触摸设备上的 Linux 体验与安卓和 iOS 提供的体验相距甚远。 但这是否意味着你不能在平板电脑上使用 Linux?并非如此。对于早期尝试用户和 DIY 爱好者来说,还有一些选择的。让我们来看看在这些 Linux 平板电脑中,你有哪些选择。 ### Ubuntu Touch ![BQ 平板电脑上的 Ubuntu Touch 操作系统](/data/attachment/album/202110/28/172722ryjylnnfjdmx3nia.jpg) 好吧!这不是一个平板电脑,而是一个操作系统。但它确实让你可以在一些旧的安卓平板电脑上安装一个适合触摸操作的 Ubuntu 版本。 注意“一些”这个词。Ubuntu Touch 官方 [支持](https://devices.ubuntu-touch.io/) Nexus 7、联想 M10、Xperia Z4 和 BQ Aquaris 平板。你甚至可以尝试在你的其他平板电脑上安装 Ubuntu Touch。它可能无法 100% 工作,但仍然非常有用。 [Ubuntu Touch](https://ubuntu-touch.io/) 是 Ubuntu 团队的一个项目,但是他们 [在 2017 年中止了它](https://itsfoss.com/ubuntu-unity-shutdown/)。[UBports](https://ubports.com/) 承担了继续这个项目的责任,他们在有限的资源下做的很棒。 总而言之,如果你喜欢各种实验,想让你的旧安卓平板电脑获得新生,Ubuntu Touch 可能是你的周末项目。 ### PineTab ![PineTab](/data/attachment/album/202110/28/172723lwqchszh6oisigbh.jpg) Pine64 始于其单板计算机 Pine A64,以作为 [树莓派的替代品](https://itsfoss.com/raspberry-pi-alternatives/)。随着时间的推移,它推出了几个 Pine 品牌的产品。这份名单里包括低调的 [PineTime 智能手表](https://itsfoss.com/pinetime-linux-smartwatch/)、PineBook 笔记本电脑、PinePhone 智能手机和 PineTab 平板电脑。 这些 Pine 设备通常价格低廉,并允许用户对这些小设备进行完全控制。这种可魔改的特性帮助它聚集了一大批开源 DIY 爱好者的粉丝。 [PineTab](https://pine64.com/product/pinetab-10-1-linux-tablet-with-detached-backlit-keyboard/?v=0446c16e2e66) 基本上使用了与带有触摸屏和键盘的 Pine64 单板计算机相同的组件。它不是看起来最漂亮的平板电脑,也不打算成为这样的。 它的规格很一般,有一个高清 IPS 电容式触摸屏、全志 A64 芯片组、四核 CPU 和 2GB 内存。 它无法与 iPad 或 Galaxy Tab 竞争,但它允许你安装你选择的发行版,并按你的要求进行配置。 请记住,Pine 的库存有限,所以如果你能看到这个设备可以购买,那你很幸运。 ### PineNote ![PineNote](/data/attachment/album/202110/28/172724eh0plmm9bg0ql27g.jpg) 另一个 Pine 设备,与你在上一节看到的 PineTab 略有不同。 PineTab 是一款用于浏览互联网、使用应用程序和玩游戏的 Linux 平板电脑,而 [PineNote](https://www.pine64.org/pinenote/) 是用来做笔记和阅读书籍和文件的。 它有一个电子墨水显示屏,你可能在 Kindle 等电子书阅读器上见过。除了电子书阅读器之外,PineNote 还可以你用 Wacom 笔做笔记。 PineNote 拥有四核 Rockchip、多点触控电子墨水面板、4GB 内存和 128GB eMMC 存储。它也是为数不多的价格高于通常的 399 美元的平板点之一。 请记住,PineNote 正处于早期开发阶段,只接受开发者的订单。 ### RasPad ![RasPad](/data/attachment/album/202110/28/172725ecwcc4ccnwc4vdnq.jpg) [RasPad](https://raspad.com/products/raspadv3) 是一个用于树莓派设备的套件,可以把它变成一个基于触摸功能的设备。与普通的平板不同,这不是一个扁平的设备,而是有一个楔形的身体。这使得它更容易在办公桌上使用。 RasPad 是专门为树莓派设备创建的,你可以轻松使用它的大部分端口。它有一个专门的 RasPad 操作系统,但你可以自由使用常规的树莓派操作系统或 Ubuntu 或任何其他适合树莓派的操作系统。在选择操作系统时请考虑触控友好性。 请记住,树莓派设备不包括在套件中。你必须要单独购买。 ### 你的选择是什么? 我知道我们离一个优秀的 Linux 平板电脑还很远,但它们至少可以和市场上的安卓平板电脑竞争。至少我们有一些可用的选择,这也是一线希望。 你是否已经拥有以上列出的设备之一了?你的体验如何? 如果你只能选择其中之一,那么你选择哪一款 Linux 平板电脑? --- via: <https://itsfoss.com/linux-tablets/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) There are plenty of [Linux-based laptops available](https://itsfoss.com/get-linux-laptops/). Also, several [mini-PCs preloaded with Linux](https://itsfoss.com/linux-based-mini-pc/). Not to forget, a few [Linux-based smartphones](https://itsfoss.com/linux-phones/) are also present in the market. **How about tablets? Are there some good Linux-based tablets? ** The answer is not straightforward. Many Linux-only system manufacturers focus on creating desktop computers. This is primarily because the Linux experience on touch devices is nowhere close to what Android and iOS provide. Does this mean you cannot use Linux on a tablet? **Not really**. There are a few options available for the early adapters and DIY tinkerers. Let’s see what options we have for Linux tablets. ## Juno Tab 3 ![juno tab 3](https://itsfoss.com/content/images/2024/09/juntab3-gnome.png) Juno computers is one of the well-known manufacturers of Linux-only machines. One of their offerings includes the Juno tablet 3, which features an Intel **quad-core N100 processor** with an **12.1-inch 2K IPS touchscreen** display, **12 GB** 4800 MHz LPDDR5 RAM, and **512 GB** SSD (expandable option up to 2 TB). The operating system choices include Mobian Phosh, Kubuntu 24.04 LTS, and Ubuntu 24.04 LTS. The price for the tablet starts at **$699.** ## Librem 11 ![librem tablet](https://itsfoss.com/content/images/2023/09/Librem-11.jpg) Librem 11 is a Linux-powered tablet by Purism. The company known for manufacturing privacy-focused hardware running on its customized Linux distro, i.e., PureOS. The distribution also features PureBoot for a secure experience with the tablet. The tablet features an 11.5-inch AMOLED 2K display, 8 GB RAM, and 1 TB of NVMe storage. You also get a pressure-sensitive pen, a detachable keyboard, and a protective sleeve as part of the offering. The price of the tablet is **$999**. ## Ubuntu Touch ![ubuntu touch](https://itsfoss.com/content/images/wordpress/2021/10/ubuntu-touch.jpg) **This is not a gadget but an operating system**. But this does give you the option to install a touch-friendly version of Ubuntu on some old Android tablets. Mind the word ‘some’. Officially, Ubuntu Touch [supports](https://devices.ubuntu-touch.io/) limited devices, but there are plenty of options if you check the list. You may even try to install Ubuntu Touch on some other tablet of yours. It may not work 100%, but it could still be mostly useable. Ubuntu Touch was a project by the Ubuntu team, but they [discontinued it in 2017](https://itsfoss.com/ubuntu-unity-shutdown/). [UBports](https://ubports.com/) is now responsible for the project, and they are doing an excellent job at it with their limited resources. If you have an experimental temperament and want to give another life to your old Android tablet, **Ubuntu Touch could be your weekend project**. ## PineTab2 ![pinetab](https://itsfoss.com/content/images/2023/11/PINETAB2.jpg) Pine64 started with its single-board computer Pine A64 as a [Raspberry Pi alternative](https://itsfoss.com/raspberry-pi-alternatives/). It launched several Pine-branded products over time. The list includes a low cost [PineTime smartwatch](https://itsfoss.com/pinetime-linux-smartwatch/), Pinebook laptop, PinePhone smartphone, and **PineTab tablet**. These Pine devices are often inexpensive and allow the user full control of the gadget. This tinkering attitude has helped it gather a considerable fan following of open-source DIY enthusiasts. The PineTab2 uses the same components as the Pine64 single-board computers, with a touchscreen and keyboard. It’s not the prettiest looking gadget out there, but then, it does not intend to be one. The specifications are basic, with an HD IPS capacitive touchscreen**, Rockchip RK3566**,** Quad-core Cortex A-55 ARM CPU**, and** available in either 4 GB or 8 GB of RAM**. It is not something that can compete with an iPad or Galaxy Tab, but it allows you to install a distribution of your choice and configure it as you want. The availability (stock) for PineTab2 is limited. So, you might want to keep an eye on their developments to get one. ## PineNote Developer Edition ![pinenote](https://itsfoss.com/content/images/wordpress/2021/10/PineNote-tab-800x615.jpg) Another Pine device, but slightly differs from the PineTab. The PineTab is a Linux tablet for browsing the internet, using applications, and playing games. The **PineNote is for taking notes and reading books and documents.** It has an Eink display that you may have seen on e-book readers like Kindle. Apart from letting you experience an e-book reader, PineNote also allows you to take notes with a Wacom Pen. PineNote has Quad-core Rockchip, multi-touch Eink panel, 4 GB RAm and 128 GB eMMC storage. It is also one of the rare few gadgets that has a higher-than-usual price tag of **$399.** ## fydetab Duo ![fydetab duo](https://itsfoss.com/content/images/2023/11/fydetab_Duo.png) “Born to do great things”, that is what the tagline for the fydetab Duo says. It focuses on providing a simple and minimal experience that is powered by [FydeOS](https://fydeos.io). Some of its **key selling points** are fast boot speeds, effortless updates, up to 10 hours of battery life, and a built-in security mechanism. The tab is powered by a **Rockchip RK3588S** chip that has an **8-core CPU**,** a 4-core GPU**, and an **AI Neural Network Engine** that can deliver up to 6 Tops of compute power. ## RasPad ![raspad](https://itsfoss.com/content/images/wordpress/2021/10/raspad-800x614.webp) RasPad is a kit for Raspberry Pi devices to turn them into a functional touch-based device. Unlike the regular tabs, this is not a flat device but has a wedge-shaped body. This makes it easier to use at desks. RasPad is created especially for Raspberry Pi devices, and you can use most of its ports easily. There is a dedicated RasPad OS, but you are free to use the regular Raspbian OS or Ubuntu, or any other [Raspberry Pi operating system](https://itsfoss.com/raspberry-pi-os/). Do consider touch friendliness while choosing the OS. Please keep in mind that the Raspberry Pi device is NOT included in the kit. You’ll have to buy it separately. ## StarLite ![starlite](https://itsfoss.com/content/images/2023/11/StarLite.png) One of the manufacturers known for mini Linux PCs, [Star Labs](https://starlabs.systems), offers Starlite as** a pretty powerful Linux tablet** featuring **open-source firmware** powered by coreboot and edk II. The hardware on offer is pretty neat too, it features **a large 12.5 inch IPS display**, a quad-core **Intel Alder Lake N200 CPU**,** 16 GB of 4800MHz LPDDR5 RAM**, and** up to 2 TB Gen3 PCIe SSD** storage. ## CutiePi ![cutiepi tablet](https://itsfoss.com/content/images/2023/01/cutiepi-tablet.png) A tablet based on Raspberry Pi 4 that features an 8-inch touch screen, 5000 mAh battery, and the Raspberry Pi Compute Module 4. It is powered by the **CutiePi shell**, turning Raspberry Pi OS into a functional tablet. ## PineTab-V ![pinetab v](https://itsfoss.com/content/images/2023/11/PINETAB-V.jpg) And for the final one, we have yet another option from Pine64. Called the PineTab-V, it is **an experimental RISC-V powered Linux tablet** that comes equipped with a detachable keyboard. As for what's under the hood, the PineTab-V is powered by a **StarFive JH7110** chip featuring a** quad-core SiFive U74 RISC-V CPU**, and an** Imagination Technology BXE-4-32 GPU**. ## What’s your choice? We are still far from a good alternative Linux tablet that could compete with at least the Android tablets in the market. But at least we have some options available, and that’s a silver lining. *💬* *Do you already own any of the above-listed devices? What is your experience with it? If you had to pick only one of them, which one would you go with?*
13,931
树莓派 Zero 2 W 来了!
https://news.itsfoss.com/raspberry-pi-zero-2-w-launch/
2021-10-29T09:57:19
[ "树莓派" ]
https://linux.cn/article-13931-1.html
> > 树莓派 Zero W 的继任者来了!仅售 15 美元,它包括一些承诺的升级和改进。 > > > ![](/data/attachment/album/202110/29/095720ccva6ffj4yf7sn64.png) 树莓派 Zero W 是最实惠的包括了无线和蓝牙连接的单板计算机之一。 虽然 [树莓派 Zero 与树莓派 Zero W](https://itsfoss.com/raspberry-pi-zero-vs-zero-w/) 之间有一些区别,但考虑到它们分别以 5 美元和 10 美元的价格推出,两者都是靠谱的选择。 现在,树莓派在大约 6 年后推出了这个系列的继任者,即树莓派 Zero 2 W,售价为 **$15**。 即使 [树莓派提高了价格](https://news.itsfoss.com/raspberry-pi-price-hike/),我想说 15 美元买一块改进了多线程性能的新一代电路板应该是个不错的选择。 让我们来看看它有什么优点和新的东西。 ### 树莓派 Zero 2 W 的规格 ![](/data/attachment/album/202110/29/095721eozkvt121vze300e.jpg) 树莓派 Zero 2 W 使用了在树莓派 3 发布版中使用的相同芯片。 虽然频率略微降低到了 1GHz,它仍然能够保证其性能是原来树莓派 Zero 的 5 倍。 下面是它的规格: * 博通 BCM2710A1,四核 64 位SoC(Arm Cortex-A53 @ 1GHz) * 512MB LPDDR2 SDRAM * 2.4GHz IEEE 802.11b/g/n 无线网络、蓝牙 4.2,BLE * 1×USB 2.0 接口,带 OTG * 与 HAT 兼容的 40 针 I/O 针脚 * MicroSD 卡插槽 * mini HDMI 接口 * 复合的视频和复位引脚焊点 * CSI-2 相机连接器 * H.264,MPEG-4 解码(1080p30),H.264 编码(1080p30) * OpenGL ES 1.1,2.0 图形 看看这些规格,考虑到它的外形尺寸,它足够令人印象深刻。不要忘了,他们增加了更多的铜覆层来处理升级后的处理器产生的热量。 ![](/data/attachment/album/202110/29/095721fh39945ja0j4bk3j.jpg) 此外,无线电路是用金属屏蔽密封的,这应该使它容易用于商业终端产品。 如果你已经有了树莓派 Zero 的外壳,那么它应该很有可能适用于 Zero 2 W。 根据 [官方公告](https://www.raspberrypi.com/news/new-raspberry-pi-zero-2-w-2/),树莓派提到: > > 与 Zero 相比,确切的性能提升因工作负载而异,但对于多线程的 [sysbench](https://github.com/akopytov/sysbench) 来说,它几乎正好是五倍的速度。 > > > 小巧的外形和性能的提升应该使它成为安全摄像机和许多其他物联网项目的理想板卡。你可以了解一下我们的 [树莓派 Zero W 的 DIY 项目](https://itsfoss.com/raspberry-pi-zero-projects/) 清单,看看有什么灵感。 ### 一个新的 USB 电源 ![](/data/attachment/album/202110/29/095722r6oy9b9kveycbts2.png) 除了新的电路板,树莓派还推出了一个改进的 USB 电源,峰值电流为 2.5A。 该电源配备了一个 micro USB 接口,而不是 USB-C。尽管这不是为新的 Zero 2 W 准备的,而是为树莓派 3B 或 3B+ 准备的。 ### 可用性 & 价格 ![](/data/attachment/album/202110/29/095723a6p9r1fr9quwrrrf.jpg) 树莓派基金会已经澄清,他们在 2026 年 1 月之前不会停产树莓派 Zero 和 Zero W。 因此,如果你想省钱做实验,你可以继续使用旧板。 新的 Zero 2 W 将在官方经销商处以 15 美元的价格出售。目前供货范围仅限于英国、欧盟、美国、加拿大和香港。 它应该在 11 月在澳大利亚和新西兰上市,在接下来的几个月里会有更多国家加入。 * [树莓派 Zero 2 W](https://www.raspberrypi.com/products/raspberry-pi-zero-2-w/) 你对最新的微型树莓派 Zero 2 W 有什么看法?欢迎在下面的评论中分享你的想法。 --- via: <https://news.itsfoss.com/raspberry-pi-zero-2-w-launch/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Raspberry Pi Zero W is one of the most affordable single-board computers that include wireless and Bluetooth connectivity. While there are some differences between the [Raspberry Pi Zero vs. Raspberry Pi Zero W](https://itsfoss.com/raspberry-pi-zero-vs-zero-w/?ref=news.itsfoss.com), both were pretty solid deals considering they launched for $5 and $10, respectively. Now, Raspberry Pi has unveiled the successor to this lineup after about six years, i.e., Raspberry Pi Zero 2 W priced at **$15**. Even with [Raspberry Pi increasing its price](https://news.itsfoss.com/raspberry-pi-price-hike/), I’d say $15 for a new-gen board for improved multi-threaded performance should be a good buy. Let us take a look at what it has to offer and what’s new. ## Raspberry Pi Zero 2 W: Specifications ![](https://news.itsfoss.com/content/images/wordpress/2021/10/Raspberry-Pi-Zero-2-W.jpg) Raspberry Pi Zero 2 W is powered by the same chip used in the launch version of Raspberry Pi 3. With the frequency slightly clocked down to 1 GHz, it still manages to promise up to 5x times the performance of the original Raspberry Pi Zero. Here’s what it comes packed with: - Broadcom BCM2710A1, quad-core 64-bit SoC (Arm Cortex-A53 @ 1GHz) - 512MB LPDDR2 SDRAM - 2.4GHz IEEE 802.11b/g/n wireless LAN, Bluetooth 4.2, BLE - 1 × USB 2.0 interface with OTG - HAT-compatible 40 pin I/O header footprint - MicroSD card slot - Mini HDMI port - Composite video and reset pin solder points - CSI-2 camera connector - H.264, MPEG-4 decode (1080p30); H.264 encode (1080p30) - OpenGL ES 1.1, 2.0 graphics Looking at the specifications, it is impressive enough when you consider the zero form factor it comes with. Not to forget, they have added more copper layers to manage the heat generated from the upgraded processor. ![](https://news.itsfoss.com/content/images/wordpress/2021/10/raspberry-pi-zero-2-w-wireless.jpg) Furthermore, the wireless circuitry is sealed with a metal shield can that should make it easy for use in a commercial end-product. If you already have a case for Raspberry Pi Zero, it should most likely work with Zero 2 W. As per the [official announcement](https://www.raspberrypi.com/news/new-raspberry-pi-zero-2-w-2/?ref=news.itsfoss.com), Raspberry Pi mentions: The exact performance uplift over Zero varies across workloads, but for multi-threaded [sysbench]it is almost exactly five times faster. The tiny form factor and the performance uplift should make it an ideal board for security cameras and many other IoT projects. You may take a look at our list of [DIY projects for Raspberry Pi Zero W](https://itsfoss.com/raspberry-pi-zero-projects/?ref=news.itsfoss.com) for ideas. ## A New USB Power Supply ![](https://news.itsfoss.com/content/images/wordpress/2021/10/rp-power-supply.png) Along with a new board, Raspberry Pi also introduced an improved USB power supply with a peak current rating of 2.5A. The power supply comes with a micro-USB connector instead of USB-C. Even though this isn’t meant for the new Zero 2 W, it is geared for Raspberry Pi 3B or 3B+. ## Availability & Pricing ![](https://news.itsfoss.com/content/images/wordpress/2021/10/Raspberry-Pi-Zero-2-W-Lifestyle.jpg) The Raspberry Pi foundation has clarified that they won’t discontinue Raspberry Pi Zero and Zero W until January 2026. So, if you want to save money for an experiment, you can proceed with the older boards. The new Zero 2 W will be available at $15 from official resellers. The availability is limited to the UK, EU, United States, Canada, and Hong Kong. It should be available for Australia and New Zealand in November, and more countries will be added in the next few months. What do you think about the latest tiny Raspberry Pi Zero 2 W? Feel free to share your thoughts in the comments below. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,932
如何在使用 Xfce 桌面环境的 Xubuntu 上安装主题
https://itsfoss.com/install-themes-xfce-xubuntu/
2021-10-29T10:40:03
[ "Xfce", "主题" ]
https://linux.cn/article-13932-1.html
> > 这是一个循序渐进的初学者教程,展示了如何在 Xubuntu 和其他使用 Xfce 桌面环境的 Linux 发行版中安装主题和图标。 > > > ![](/data/attachment/album/202110/29/103958hrv6vruu163zrtvr.png) 在 Xubuntu 上安装主题与 Ubuntu 或其他 Linux 发行版类似。你把主题文件放在 `~/.themes` 文件夹中,然后用一个工具来改变它。 然而,考虑到 Xubuntu 使用 [Xfce 桌面环境](https://xfce.org/),一些选项或用户界面看起来会有所不同。这就是为什么我创建了这个教程,用适当的截图来展示步骤。 ### 在 Xubuntu(Xfce)中安装新主题 开始前,你需要在主目录下创建一个 `.themes` 文件夹。注意文件夹名称前的点(`.`)。它很重要,可以从正常的视图中隐藏该文件夹。 要检查你是否已经有了它,你可以 [启用查看隐藏文件](https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/),然后在它不存在的时候创建它。 ![](/data/attachment/album/202110/29/104003n1opsjln1blpbj1d.png) 完成后,你需要下载一个主题。 1、你可以在 [Xfce-look](https://www.xfce-look.org/browse?cat=138&ord=latest) 门户网站上浏览 XFCE 主题。你所要做的就是下载存档(压缩)文件。 2、接下来,你需要 [解压缩文件](https://itsfoss.com/unzip-linux/),如下面的截图所示。 ![](/data/attachment/album/202110/29/104003y53gti52bo2pt2m2.png) 3、解压后,你会发现出现一个文件夹,你要复制它。 ![](/data/attachment/album/202110/29/104004agawwgwgfvy712jy.png) 4、然后你要把这个文件夹粘贴到你最初创建的 `.themes` 目录中。 ![](/data/attachment/album/202110/29/104004lm9xmderk91mam1e.png) 5、最后,你需要到外观设置中找到它,并选择它/应用它以使其生效。 ![](/data/attachment/album/202110/29/104004pbnbzhrfonu0n0cz.png) 正如你在下面的截图中注意到的,新的主题已经被添加和应用: ![](/data/attachment/album/202110/29/104004tytgaaa0tmkbpje6.png) 除了主题之外,如果你需要定制你的 Xubuntu 桌面的图标,你需要在主目录中创建另一个 `.icons` 文件夹。 就像你安装主题一样,你将不得不遵循一个类似的过程来应用图标主题。 为了给你一个例子,让我在这里强调这些步骤: ### 在 Xubuntu(Xfce) 中添加图标主题 你可以浏览同样的 [xfce-look portal](https://www.xfce-look.org/browse?cat=132&ord=latest) 来寻找完整的图标主题。 或者,你可以寻找一些最好的 [可用于 Ubuntu 的图标主题](https://itsfoss.com/best-icon-themes-ubuntu-16-04/),它们应该也适用于 Xubuntu。 一旦你找到了你喜欢的,就下载它,并按下面的方式解压。 ![](/data/attachment/album/202110/29/104005j2yc9pz5cclcoolo.png) 接下来,你需要把这个文件夹复制并粘贴到 `.icons` 文件夹中。 ![](/data/attachment/album/202110/29/104005cjv9jgzj68vf996x.png) 现在,你可以回到外观设置中,找到列在“图标”下的可用图标。 为了向你展示区别,**我把默认的 Xubuntu 主题改为 adwaita-dark**,你可以在这里看到: ![](/data/attachment/album/202110/29/104007sog1tb04e7xxb1xz.png) **注意**:一些图标或主题文件可能包含有不同变体的嵌套文件夹。你会注意到它们并没有出现在外观工具中。如果是这种情况,直接将内部文件夹复制到 `~/.themes` 或 `~/.icons` 文件夹中。 ### 总结 通过对风格和图标的调整,你可以 [定制你的 Xubuntu 体验](https://itsfoss.com/customize-xfce/) 以融入你的品味。 你是喜欢默认的 Xubuntu 外观还是使用不同的主题/图标来定制它的外观?请在评论中告诉我你的想法。 --- via: <https://itsfoss.com/install-themes-xfce-xubuntu/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
*Brief: This is a step-by-step beginner’s tutorial to show how to install themes and icons in Xubuntu and other Linux distributions that use Xfce desktop environment.* Installing themes on Xubuntu is similar to Ubuntu or any other Linux distribution. You put the theme files in the ~/.themes folder and then use a tool to change it. However, some options or the user interface will look different considering Xubuntu uses the [Xfce desktop environment](https://xfce.org/). This is why I created this specific tutorial to show the steps with proper screenshots. ## Install new themes in Xubuntu (Xfce) To get started, you need to create a **.themes **folder in the home directory. Mind the dot (.) before the folder name. It’s important and hides the folder from normal view. To check if you already have it, you can [enable viewing hidden files](https://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/) and then create it if it isn’t present. ![xubuntu hidden files](https://itsfoss.com/content/images/wordpress/2021/10/xubuntu-hidden-files.png) Once done, you need to download a theme. 1. You can browse for XFCE themes on the [Xfce-look](https://www.xfce-look.org/browse?cat=138&ord=latest) portal. All you have to do is download the archive (compressed) file. 2. Next, you need to [extract the zip file](https://itsfoss.com/unzip-linux/), as shown in the screenshot below. ![extract xubuntu theme](https://itsfoss.com/content/images/wordpress/2021/10/extract-xubuntu-theme.png) 3. Once you extract it, you will notice a folder appear, and you will have to copy it. ![extracted xubuntu theme](https://itsfoss.com/content/images/wordpress/2021/10/extracted-xubuntu-theme.png) 4. You will have to then paste this folder into the **.themes** directory that you created initially. ![copy theme xubuntu](https://itsfoss.com/content/images/wordpress/2021/10/copy-theme-xubuntu.png) 5. Finally, you need to head to the Appearance setting to find it listed and select it/apply it for it to take effect. ![appearance xfce](https://itsfoss.com/content/images/wordpress/2021/10/appearance-xfce.png) As you notice in the screenshot below, the new theme has been added and applied: ![xpro xubuntu theme](https://itsfoss.com/content/images/wordpress/2021/10/xpro-xubuntu-theme.png) In addition to the theme, if you need to customize the icons of your Xubuntu desktop, you need to create another .icons folder in the home directory. Like you installed the theme, you will have to follow a similar process to apply the icon themes. To give you an example, let me highlight those steps here: ## Adding icon themes in Xubuntu (Xfce) You can browse through the same [xfce-look portal](https://www.xfce-look.org/browse?cat=132&ord=latest) to look for complete icon themes. Or, you can explore some of the best [icon themes available for Ubuntu](https://itsfoss.com/best-icon-themes-ubuntu-16-04/) that should work for Xubuntu as well. Once you find the one you like, download it, and extract it as shown below. ![xubuntu icon theme](https://itsfoss.com/content/images/wordpress/2021/10/xubuntu-icon-theme.png) Next, you will have to copy and paste the folder into the .**icons** folder. ![xubuntu icon theme selection](https://itsfoss.com/content/images/wordpress/2021/10/xubuntu-icon-theme-selection.png) Now, you can head back to the Appearance settings and find the icon listed under the “Icons” available. To show you the difference, **I changed the default Xubuntu theme to adwaita-dark**, as you can see here: ![xubuntu icon theme change](https://itsfoss.com/content/images/wordpress/2021/10/xubuntu-icon-theme-change.png) **Note**: Some icon or theme files may contain nested folders with different variants in it. You’ll notice that they do not appear in the appearance tool. If that’s the case, copy the inner folder directly in ~/.themes or ~/.icons folder. ## Wrapping Up With both the style and icons tweaked, you can [customize your Xubuntu experience](https://itsfoss.com/customize-xfce/) to blend in with your taste. Do you prefer the default Xubuntu look or customize the look of it using different themes/icons? Let me know your thoughts in the comments.
13,935
现可下载微软 Edge 的 Linux 稳定版了
https://news.itsfoss.com/microsoft-edge-stable-release/
2021-10-30T08:56:43
[ "Edge", "浏览器" ]
https://linux.cn/article-13935-1.html
![](/data/attachment/album/202110/30/085644x57izzq4kqeq7zi4.png) > > 微软 Edge 的 Linux 最终版本终于亮相了。对于涉足 Linux 的 Windows 用户来说,这似乎是一个值得考虑的选择。 > > > 早在 5 月,[微软就启动了 Linux 版的 Edge 的公开测试](https://news.itsfoss.com/microsoft-edge-beta/)。 现在,就在正式宣布之前,其稳定版已经被推送到官方仓库。 ![](/data/attachment/album/202110/30/085645mapwoip1j1px3wk1.png) 注意:微软 Edge 不是一个开源的浏览器,但它基于开源的组件。我们报道这个是因为它可以用于 Linux。 ### 微软 Edge 的 Linux 版本:有什么值得喜欢的? ![](/data/attachment/album/202110/30/085645h2ckykmnmxx722c0.png) 微软 Edge 基于开源的 Chromium,这一点并不奇怪。所以,是的,它只是又一个 [基于 Chromium 的 Linux 浏览器](https://news.itsfoss.com/chrome-like-browsers-2021/)。 然而,与谷歌 Chrome 浏览器相比,微软 Edge 提供了良好的用户体验和一些对 Windows 用户来说可能很方便的额外功能。 根据我在 Windows 10 上的经验,与谷歌 Chrome 浏览器相比,微软 Edge 似乎性能更好,但我还没有为此比较过任何基准。 那么,它对 Linux 是否有用?有什么理由让你去尝试吗? 当然,如果你不喜欢使用微软的服务,那就完全是另一回事了。但是,总的来说,微软 Edge 看起来是一个有前途的基于 Chromium 的浏览器,具有一些有用的功能。 一些可用于 Linux 的关键功能包括: * 睡眠标签(以节省资源) * 垂直标签 * 收藏 * 防止跟踪 ![](/data/attachment/album/202110/30/085646c8qsaszua5c5a58u.png) 虽然它在配置你的微软账户时也支持家庭安全选项,但并不是每项功能都适用于 Linux。 此外,我没有发现可以派上用场的 Linux 的“儿童模式”。 而且,如果你在使用 Linux 的同时还使用其他桌面平台,微软 Edge 可以是跨平台冒险的一个好选择。 但如果你只想在 Linux 上试用它,你可能想在作出决定之前将它与其他浏览器进行比较。 ### 下载微软 Edge Linux 版 想知道 [如何在 Linux 上安装微软 Edge 浏览器](https://itsfoss.com/microsoft-edge-linux/)?尽管 [微软 Edge 的官方网站](https://www.microsoft.com/en-us/edge) 没有列出 Linux 版本,但你可以在他们的官方资源库中找到它。 DEB 和 RPM 两种软件包都是可用的。你可以使用下面的链接下载这些软件包: * [微软 Edge (deb)](https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/) * [微软 Edge (rpm)](https://packages.microsoft.com/yumrepos/edge/) Via: [Sophos](https://nakedsecurity.sophos.com/2021/10/29/microsoft-edge-finally-arrives-on-linux-official-build-lands-in-repos/) --- via: <https://news.itsfoss.com/microsoft-edge-stable-release/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) **Update:** Microsoft officially [announced](https://blogs.windows.com/msedgedev/2021/11/02/edge-ignite-nov-2021/?ref=news.itsfoss.com) the general availability of Microsoft Edge for Linux. You should be able to download the browser (deb/rpm) directly on its [official website](https://www.microsoft.com/en-us/edge?ref=news.itsfoss.com#linux). Back in May, [Microsoft kicked off the public beta testing of Microsoft Edge](https://news.itsfoss.com/microsoft-edge-beta/) for Linux. Now, right before the official announcement, the stable release was pushed to the official repos. ![](https://news.itsfoss.com/content/images/wordpress/2021/10/microsoft-edge-download.png) **Note:** Microsoft Edge is not an open-source browser but based on open-source components. We’re covering this because it’s available for Linux. ## Microsoft Edge for Linux: What’s There to Like? ![](https://news.itsfoss.com/content/images/wordpress/2021/10/microsoft-edge-linux.png) It is no surprise that Microsoft Edge is based on open-source Chromium. So, yes, it is just another [Chromium-based browser for Linux](https://news.itsfoss.com/chrome-like-browsers-2021/). However, when compared to Google Chrome, Microsoft Edge offers a good user experience and some extra functionalities that may come in handy for Windows users. As per my experience on Windows 10, Microsoft Edge seems to offer better performance compared to Google Chrome, but I haven’t compared any benchmarks for that matter. So, would it be useful for Linux? Is there any reason that you should try it out? Of course, if you do not prefer using Microsoft services, that is an entirely different story. But, overall, Microsoft Edge looks like a promising Chromium-based browser with some useful features. Some of the key features available for Linux include: - Sleeping tabs (to save resources) - Vertical tabs - Collections - Tracking Prevention ![](https://news.itsfoss.com/content/images/wordpress/2021/10/microsoft-edge-linux-privacy-1024x638.png) While it also supports the family safety option when configured with your Microsoft account, not every feature is available for Linux. Moreover, I did not find the “Kids Mode” for Linux, which can come in handy. And, if you use other desktop platforms along with Linux, Microsoft Edge can be a good pick for cross-platform adventure. If you want to try it only for Linux, you may want to compare it with other browsers before you conclude with a decision. ## Download Microsoft Edge for Linux Wondering about [installing Microsoft Edge browser on Linux](https://itsfoss.com/microsoft-edge-linux/?ref=news.itsfoss.com)? Even though the [official site for Microsoft Edge](https://www.microsoft.com/en-us/edge?ref=news.itsfoss.com) does not reflect the option for Linux, you can find it in their official repositories. Both **DEB/RPM** packages are available. You can find the packages using the link below. **Original Report** **Via:** [Sophos](https://nakedsecurity.sophos.com/2021/10/29/microsoft-edge-finally-arrives-on-linux-official-build-lands-in-repos/?ref=news.itsfoss.com) ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,936
修复在 Ubuntu 上 “Unable to acquire dpkg frontend lock. Are You Root?” 的错误
https://itsfoss.com/fixed-are-you-root-error/
2021-10-30T09:24:58
[ "sudo" ]
https://linux.cn/article-13936-1.html
![](/data/attachment/album/202110/30/092452w21q1lyl1ntyy7t3.jpg) 我假设你对 Linux 很陌生。 你按照网上的一些教程,告诉你要安装某个程序或运行某个命令。可能是与服务器有关的东西。 但当你运行这个命令时,你遇到了这个错误: ``` E: Could not open lock file /var/lib/dpkg/lock-frontend – open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root? ``` 或者类似的错误: ``` dpkg: error: required read/write access to the dpkg database directory /var/lib/dpkg E: Sub-process dpkg –set-selections returned an error code (2) E: Executing dpkg failed. Are you root? ``` 这两个错误都在问你同一个问题:你是 root 吗?而这就是这个问题的答案。成为 root。 ### 成为 root 以避免这个错误 你如何 [在 Ubuntu](https://itsfoss.com/root-user-ubuntu/) 或 Debian 中成为 root?你使用 `sudo` 命令。 是的,就是这样。无论你在运行什么命令,只要在它前面加上 `sudo` 即可。 ``` sudo your_command ``` ![Running command with sudo](/data/attachment/album/202110/30/092459i09yzz9fv0zfyyhl.jpg) 它将要求你输入你的用户账户密码。请记住,当你输入密码时,屏幕上不会显示任何东西,这也没关系。 你的系统没有任何问题。在大多数 Linux 系统中,输入密码时不会显示通常的星号或其他东西是一种“安全特性”。 只要输入密码,并在密码后按下回车键即可。如果密码输入正确,你现在应该可以运行该命令了。 你甚至可以使用这个方便的 [Linux 命令行技巧](https://itsfoss.com/linux-command-tricks/),用 `sudo` 运行以前的命令: ``` sudo !! ``` 这很简单,而且立即生效,除非你没有 sudo 权限。然后,你会看到一个不同的错误。 ### 看到一个 “User is not in sudoer file” 的错误? ![Some users cannot run commands with sudo](/data/attachment/album/202110/30/092459qq8msap7999u5opu.png) 当你 [安装 Ubuntu](https://itsfoss.com/install-ubuntu/) 时,你必须创建一个用户账户。这个用户被自动授予 `sudo` 权限,在需要时以 root 身份运行命令。 这发生在 Ubuntu 桌面上,而不是服务器上。大多数服务器发行版会有一个单独的 root 账户。如果你单独创建了一个普通账户,你就必须把这个用户添加到 `sudoer` 中,以便这个普通用户可以使用 `sudo`。 在上面的截图中,我已经创建了这个额外的用户,但没有将其添加到 sudo 组中。这意味着这里的用户 `prakash` 没有使用 `sudo` 命令的权限,因此系统抱怨 “prakash is not in sudoers file”。 #### 该事件在哪里报告? 错误的 `sudo` 尝试会被添加到系统日志中。它记录了用户名、虚拟终端号、运行命令的位置和运行的命令。 ![Incorrect sudo attempts are logged into the system](/data/attachment/album/202110/30/092459pr3b2jo3rsoqso7l.png) 这些日志的位置在不同的发行版中有所不同。 通常,在 Ubuntu 中你可以在 `journalctl` 日志或 `/var/log/auth.log` 文件中找到它,在 Fedora 中可以在 `/var/log/audit/audit.log` 文件中找到它。 #### 如果一个用户不在 sudoer 列表中,你能做什么? 当你不能用当前的用户账户使用 `sudo` 时,你能做什么?首先,[验证该用户是否有 sudo 权限。如果没有,你可以有一些选择](https://linuxhandbook.com/check-if-user-has-sudo-rights/): * 以 root 身份登录或切换 root 身份(如果你有 root 密码)。 * [将该用户加入 sudoer 列表](https://linuxhandbook.com/create-sudo-user/) (如果你有其他用户账户的管理或 `sudo` 权限)。 * 如果你在多用户的 Linux 系统中,自己没有 root 或 `sudo` 权限,请你的系统管理员授予你的用户 sudo 权限或安装你想安装的应用。 ### 这有帮助吗? `sudo` 是一个非常全面的安全机制,它不仅仅是允许一个普通用户成为 root。它有助于对系统进行审计,了解哪个用户用 `sudo` 运行了哪个命令。它还可以被配置为只允许某个用户用 `sudo` 运行某些命令。 你不会在桌面 Linux 上看到如此细化的 `sudo` 配置,在桌面 Linux 上,它被预先配置为允许 `sudo` 组中的任何用户以 `root` 的身份运行任何命令。关于 `sudo` 的更多信息,请参见其他文章。 我希望在解决这个经典的初学者问题时,你能对 `sudo` 命令有一些初步的了解。如果你对这个主题有进一步的问题,请在评论区告诉我。 --- via: <https://itsfoss.com/fixed-are-you-root-error/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) I am presuming you are quite new to Linux. You follow some tutorial on the internet that tells you to install a certain program or run some command. Probably it is something to do with a server. But when you run the command, you encounter this error: **E: Could not open lock file /var/lib/dpkg/lock-frontend – open (13: Permission denied)E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?** A similar error is this one: **dpkg: error: required read/write access to the dpkg database directory /var/lib/dpkgE: Sub-process dpkg –set-selections returned an error code (2)E: Executing dpkg failed. Are you root?** Both errors ask you the same question: are you root? And that’s the answer to this problem. Become root. ## Become root to avoid this error How do you [become root in Ubuntu](https://itsfoss.com/root-user-ubuntu/) or Debian? You use the sudo command. Yes, that’s it. Whatever command you were running, just add sudo before it. `sudo your_command` ![running commands with sudo](https://itsfoss.com/content/images/wordpress/2021/10/running-commands-with-sudo.webp) It will ask you to enter your user account password. **Please keep in mind that nothing gets displayed on the screen when you type the password and that’s okay**. There is nothing wrong with your system. In most Linux systems, password typing doesn’t show the usual asterisks or anything of that sort as a ‘security feature’. Just type your password and press enter after it. If the password was typed correctly, you should be able to run the command now. You can even use this handy [Linux command line trick](https://itsfoss.com/linux-command-tricks/) to run a previous command with sudo: `sudo !!` That was simple and works immediately, unless you do not have sudo access. Then, you’ll see a different error. ## Seeing a ‘User is not in sudoer file’ error? ![not in sudoer file error](https://itsfoss.com/content/images/wordpress/2021/10/not-in-sudoer-file-error-800x289.png) When you [install Ubuntu](https://itsfoss.com/install-ubuntu/), you have to create a user account. This user is automatically granted sudo power to run commands as root when required. This happens on Ubuntu desktop, not servers. Most server distributions will have a separate root account. If you create a regular account separately, you’ll have to add the user to sudoer so that this normal user can use sudo. In the screenshot above, I had created this additional user but did not add it to the sudo group. This means that user ‘prakash’ here does not have rights to use the sudo command and hence the system complains that ‘prakash is not in sudoers file’. ### Where is the incident reported? An incorrect sudo attempt is added to the system logs. It logs the user name, the virtual terminal number, location from where the command was run and which command was run. ![sudo incident reported](https://itsfoss.com/content/images/wordpress/2021/10/sudo-incident-reported-800x339.png) The location of these logs differ from distribution to distribution. Normally, you may find it in journalctl logs or /var/log/auth.log file in Ubuntu, /var/log/audit/audit.log file in Fedora. ### What can you do if a user is not in sudoer list? What can you do when you cannot use sudo with the current user account? First, [verify if the user has sudo rights or not. If not, here are some options for](https://linuxhandbook.com/check-if-user-has-sudo-rights/?ref=itsfoss.com) you: - Log in as root or switch to root (if you have root password). [Add the user into sudoer list](https://linuxhandbook.com/create-sudo-user/?ref=itsfoss.com)(if you have admin/sudo rights from some other user account).- If you are in multi-user Linux system and do not have root or sudo access yourself, ask your sytem administrator to either grant your user sudo access or install the application you wanted to install. ## Did this help? Sudo is a very comprehensive security mechanism, and it is much more than just allowing a normal user to become root. It helps in auditing the system to know which user ran which command with sudo. It can also be configured to allow a certain user to run only certain commands with sudo. You won’t see such granular sudo configuration on desktop Linux where it is preconfigured to allow any user in the sudo group to run any command as root with sudo. More on sudo in some other article. I hope while solving this classic beginner problem, you get some initial insights into the sudo command. Let me know if you have further questions on this topic in the comment section.
13,938
如何在 Ubuntu 和其它的 Linux 发行版安装 Rust 和 Cargo
https://itsfoss.com/install-rust-cargo-ubuntu-linux/
2021-10-31T15:00:35
[ "Rust", "Cargo" ]
https://linux.cn/article-13938-1.html
> > 了解在 Linux 上安装 Rust 编程语言及其包管理器 Cargo 的各种方法。 > > > ![](/data/attachment/album/202110/31/150031j9e0xgeg9jpxeip0.jpg) 自从 Mozilla 贡献了 [Rust](https://www.rust-lang.org/) 语言之后,它就获得了更加突出和受欢迎的地位。口说无凭。[Rust 将被使用在 Linux 内核中](https://www.zdnet.com/article/rust-in-the-linux-kernel-why-it-matters-and-whats-happening-next/),它是继 C 语言之后的第二种编程语言。 许多开发人员也开始使用 Rust 语言制作很棒的基于命令行的工具。这些工具通常可以通过 [Cargo 包管理器](https://crates.io/) 获得。 这就是为什么在 Linux 中安装 Rust 支持对程序员和最终用户都很重要的原因。 官方 Rust 文档建议通过以下这种方式下载并执行安装程序脚本在 Linux 中安装 Rust: ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` 这是可行的。但是,你的发行版可能已经打包了 Rust。使用你的发行版的 [包管理器](https://itsfoss.com/package-manager/) 也是一种选择。 让我向你介绍官方 Rust 方式和包管理器方式的 Rust 安装步骤。 ### 方法1:使用官方方法在任意的 Linux 上安装 Rust 这种方法有几个优点: * 你可以获取最新的 Rust 和 Cargo 版本 * Rust 仅仅是为当前的用户安装,并不是所有用户 * 你并不需要 root 用户或者 `sudo` 权限就可以为自己安装 Rust 一些人不喜欢从互联网下载并 [运行 shell](https://itsfoss.com/run-shell-script-linux/) 脚本,即使它来自官方。但是,由于它不需要 root 访问权限并且脚本来自官方,因此以这种方式安装它应该是安全的。 首先,确保你已经安装了 `curl`。如果没安装,使用你的发行版的包管理器安装它。你可以使用 `apt` 命令在 [Ubuntu 和 Debian 上安装 Curl](https://itsfoss.com/install-curl-ubuntu/)。 ``` sudo apt install curl ``` 接下来,使用这条命令下载脚本并运行它: ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` ![](/data/attachment/album/202110/31/150036mba1shcjwihv7xsk.png) 它会询问你输入所需的安装类型。选择选项 `1`: ![](/data/attachment/album/202110/31/150036o1igbiwb46f66i44.png) 脚本完成安装后,你需要获取配置文件的来源,以使更改应用于你的 shell。 ![](/data/attachment/album/202110/31/150036jad8dbuydb7f43d3.png) 应用文件: ``` source $HOME/.cargo/env ``` 完成后,通过检查已安装的版本来验证 Rust 是否可用: ``` rustc --version ``` ![Verifying Rust installation](/data/attachment/album/202110/31/150036kc0coytuqdbt9ydc.png) 太酷了。如果 Rust 发布了新版本,你可以使用如下命令更新已安装的版本: ``` rustup update ``` 在你看到其它安装方法之前,让我快速展示如何移除以这种方式安装的 Rust。 #### 删除以官方方式安装的 Rust 在终端中,使用如下的命令从系统中移除 Rust: ``` rustup self uninstall ``` 询问时按 `Y`,你将从系统中删除 Rust。 ![Removing Rust from Linux](/data/attachment/album/202110/31/150037tsyyz4us55ooudsg.png) 官方方式安装已经完成。让我们看看如何使用 `apt` 命令在 Ubuntu 上安装 Rust。 ### 方法2:使用 apt 命令在 Ubuntu 上安装 Rust 为什么要使用包管理器? * 它在整个系统范围内安装 Rust,可供系统上的所有用户使用 * 它与其它系统更新一起集中更新(如果你的发行版添加了新版本的 Rust) Ubuntu 中有两个主要的 Rust 包: * `rustc`:用于 Rust 编程语言的 Rust 编译器 * `cargo`:Cargo 是 Rust 的包管理器,它会自动安装 `rustc` 作为一个普通用户,你将使用 Cargo 来安装基于 Rust 的应用程序。作为程序员,你需要 Cargo 来获取其它 Rust 包或创建自己的包。 由于 `cargo` 包含 `rustc`,所以我建议安装它,以便一次性安装所有必需的软件包。 ``` sudo apt install cargo ``` 系统会要求你输入账号密码。 ![](/data/attachment/album/202110/31/150037fz271l9qblfllldf.png) 当然,你可以自由使用 `apt install rustc`,只安装 Rust。这取决于你的选择。 你可以验证是否为你和所有其他用户安装了 Rust(如果你愿意): ![](/data/attachment/album/202110/31/150037s4330z0m3gx63mzz.png) 很好。让我也快速展示卸载步骤。 #### 使用 apt remove 移除 Rust 要移除 Rust,你可以先移除 Cargo,然后使用 `autoremove` 命令移除随它安装的依赖项。 ``` sudo apt remove cargo ``` 现在运行 `autoremove`: ``` sudo apt autoremove ``` 就是这样。你现在了解了在 Ubuntu 和其它 Linux 发行版上安装 Rust 的所有基本知识。随时欢迎提出问题和建议。 --- via: <https://itsfoss.com/install-rust-cargo-ubuntu-linux/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[perfiffer](https://github.com/perfiffer) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) *Brief: Learn various ways of installing Rust programming language on Linux along with its package manager Cargo.* Ever since Mozilla dumped [Rust](https://www.rust-lang.org/?ref=itsfoss.com), it has gained even more prominence and popularity. Don’t just take my words for it. [Rust is going to be included in the Linux kernel](https://www.zdnet.com/article/rust-in-the-linux-kernel-why-it-matters-and-whats-happening-next/?ref=itsfoss.com), only the second programming language after C. Many developers have also started making awesome command line based tools in Rust. These tools are often available through the [Cargo package manager](https://crates.io/?ref=itsfoss.com). This is why it matters to install Rust support in Linux, both for the programmers and the end users. Officially, Rust documents suggest installing Rust in Linux by downloading and executing the installer script in this manner: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` That could work. However, your distribution probably already packages Rust. Using your distribution’s [package manager](https://itsfoss.com/package-manager/) is also an option. Let me walk you through the Rust installation steps for both official Rust way and package manager way. ## Method 1: Installing Rust on any Linux using the official method *There are a few advantages of this method:* - You get the latest Rust and Cargo version - Rust is only installed for the current user, not system-wide - You do not need to be root or have sudo access to install Rust for yourself this way A few people dislike downloading and [running shell scripts](https://itsfoss.com/run-shell-script-linux/) off the internet, even if it is coming from the official sources. However, since it does not need root access and the script is coming from the official sources, it should be safe to install it this way. First, **make sure that you have Curl installed**. Use your distribution’s package manager to install it, if it is not already installed. You can [install Curl on Ubuntu](https://itsfoss.com/install-curl-ubuntu/) and Debian using the apt command: `sudo apt install curl` Next, use this command to download the script and run it: `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` ![Run the installer script provided in the official website to start the installation process](https://itsfoss.com/content/images/2023/03/installing-rust-linux.webp) It will ask for your input on the kind of installation you want. **Go with option 1**: ![Select the default install option, which is number 1, when asked to select the method of installation](https://itsfoss.com/content/images/2023/03/installing-rust-linux-2.webp) Once the script finishes the installation process, you need to source the configuration file to make the changes available for your shell. ![Execute the command that sorces the configuration, once the installation is finished](https://itsfoss.com/content/images/2023/03/installing-rust-linux-3.webp) Source the file: `source $HOME/.cargo/env` Once it is done, verify that rust is available for you by checking the installed version: `rustc --version` ![Verify the instaaltion of Rust by checing the version of rust installed in the terminal](https://itsfoss.com/content/images/2023/03/verify-rust-version.webp) Here's a replay of the Rust installation (click to enlarge): `rustup update` Let me quickly show how to remove rust installed this way before you see the other installation method. ### Removing Rust installed the official way In a terminal, use the following command to remove Rust from your system: `rustup self uninstall` Press Y when asked and you’ll have Rust removed from the system. ![Remove the installed rust through Shell script](https://itsfoss.com/content/images/2023/03/remove-rust-linux.webp) Here's a replay of removing Rust installed the official way. That’s settled then. Let’s see how to use the apt command to install Rust on Ubuntu. ## Method 2: Installing Rust support on Ubuntu using apt *Why would you want to use the package manager?* - It installs Rust system-wide and thus makes it available for all the users on the system - It gets updated centrally with other system updates (if your distribution adds a new version of Rust) There are two main Rust packages available in Ubuntu: - rustc: The rust compiler used for Rust programming language - cargo: Cargo is the Rust package manager and it automatically installs rustc As a regular user, you would be using Cargo for installing Rust-based applications. As a programmer, you’ll need Cargo to get other Rust packages or create your own. Since Cargo includes `rustc` , I would advise installing it so that all required packages are installed in one go. `sudo apt install cargo` You’ll be asked to enter your account’s password. ![Install Rust using th APT packag manager. Provide the password one asked.](https://itsfoss.com/content/images/2023/03/install-rust-using-apt-ubuntu.webp) You are, of course, free to use `apt install rustc` and install only Rust. That choice lies with you. You may verify that Rust is installed for you and all the other users (if you want to): ![Verify the installed Rust by checking version. (Both the per user and system-wide)](https://itsfoss.com/content/images/2023/03/verify-rust-install-ubuntu.webp) Here's a replay of Rust installation with apt in Ubuntu. That’s good. Let me quickly show the uninstall step as well. ### Removing Rust using apt remove To remove Rust, you can remove Cargo first and then use the autoremove command to remove the dependencies installed with it. `sudo apt remove cargo` Now run the autoremove: `sudo apt autoremove` Here's the replay uninstall Rust with apt command: That’s it. You now know all the essentials about installing Rust on Ubuntu and other Linux distributions. Questions and suggestions are always welcome.
13,939
在 Linux 上用 ASCII 艺术打印万圣节问候语
https://opensource.com/article/21/10/ascii-linux-halloween
2021-10-31T15:43:47
[ "ASCII艺术" ]
/article-13939-1.html
> > 使用 Linux 或 FreeDOS 从一个 C 程序中生成彩色的 ASCII 艺术。 > > > ![FreeDOS 上的庆祝万圣节 ASCII 艺术](/data/attachment/album/202110/31/154349n1rmy3h09q399goo.jpg "Happy Halloween ASCII art on FreeDOS") 利用扩展 ASCII 字符集和它的绘画元素集合的全彩 ASCII 艺术在 DOS 上曾经相当流行。你可以在你的下一个 FreeDOS 程序中加入 ASCII 艺术,作为一个很酷的“欢迎”屏幕,或者作为一个提供了更多程序信息的彩色“退出”屏幕,来增加一点视觉上的乐趣。 但是,这种 ASCII 艺术的风格并不仅仅局限于 FreeDOS 程序。你可以在 Linux 终端模式的程序中使用同样的方法。虽然 Linux 使用 [ncurses](https://opensource.com/article/21/8/ncurses-linux) 来控制屏幕,而不是 DOS 的 [conio](https://opensource.com/article/21/9/programming-dos-conio),但相关的概念也适用于 Linux 程序。本文探讨了如何从 C 语言程序中生成彩色 ASCII 艺术。 ### ASCII 艺术文件 你可以使用各种工具来绘制你的 ASCII 艺术。在这个例子中,我使用了一个叫做 TheDraw 的老式 DOS 应用程序,但是你可以在 Linux 上找到现代的开源 ASCII 艺术程序,比如 [Moebius](https://blocktronics.github.io/moebius/)(Apache 许可证)或者 [PabloDraw](https://github.com/blocktronics/pablodraw)(MIT 许可证)。只要你知道保存的数据是什么样子的,你使用什么工具并不重要。 下面是一个 ASCII 艺术文件样本的一部分,以 C 源代码保存。请注意,这个代码片段定义了几个值。`IMAGEDATA_WIDTH` 和 `IMAGEDATA_DEPTH` 定义了屏幕上的列数和行数。在这里,它是一个 80x25 的 ASCII 艺术“图像”。`IMAGEDATA_LENGTH` 定义了 `IMAGEDATA` 数组中的条目数量。ASCII 艺术画面中的每个字符可以用两个字节的数据表示。要显示的字符和包含该字符的前景和背景颜色的颜色属性。对于一个 80x25 的屏幕,每个字符都与一个属性配对,该数组包含 4000 个条目(即 `80*25*2=4000`)。 ``` #define IMAGEDATA_WIDTH 80 #define IMAGEDATA_DEPTH 25 #define IMAGEDATA_LENGTH 4000 unsigned char IMAGEDATA [] = { '.', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, '.', 0x0F, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, '.', 0x0F, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ' ', 0x08, ``` 数组的其它部分依此类推。 为了在屏幕上显示这种 ASCII 艺术,你需要写一个小小的程序来读取数组并以正确的颜色打印每个字符。 ### 设置一个颜色属性 这个 ASCII 艺术文件中的颜色属性在一个字节中定义了背景和前景的颜色,用十六进制的值表示,如 `0x08` 或 `0x6E`。十六进制是适合表达这样的颜色“对”的紧凑方式。 像 Linux 上的 ncurses 或 DOS 上的 conio 这样的字符模式系统 [只能显示 16 种颜色](https://opensource.com/article/21/6/freedos-sixteen-colors)。这就是十六种可能的文本颜色和八种背景颜色。用二进制计算十六个值(从 0 到 15)只需要四个二进制位。 > > `1111` 是二进制的 15 > > > 而且方便的是,十六进制可以用一个字符表示 0 到 15:`0`、`1`、`2`、`3`、`4`、`5`、`6`、`7`、`8`、`9`、`A`、`B`、`C`、`D`、`E` 和 `F`。所以十六进制的值 `F` 是数字 15,或二进制的 `1111`。 通过颜色对,你可以用一个八位的字节来编码背景和前景的颜色。这就是文本颜色的四个二进制位(十六进制中的 0 到 15 或 0 到 F)和背景颜色的三个二进制位(十六进制中的 0 到 7 或 0 到 E)。字节中剩余的二进制位在这里没有使用,所以我们可以忽略它。 为了将颜色对或属性转换成你的程序可以使用的颜色值,你需要 [使用位掩码](https://opensource.com/article/21/8/binary-bit-fields-masks),只指定用于文字颜色或背景颜色的位。使用 FreeDOS 上的 OpenWatcom C 编译器,你可以编写这个函数,从颜色属性中适当地设置颜色。 ``` void textattr(int newattr) { _settextcolor(newattr & 15); /* 0000xxxx */ _setbkcolor((newattr >> 4) & 7); /* 0xxx0000 */ } ``` `_settextcolor` 函数只设置文本颜色,`_setbkcolor` 函数设置背景颜色。两者都定义在 `graph.h` 中。注意,由于颜色属性在一个字节值中包括了背景色和前景色,`textattr` 函数使用 `&`(二进制的“与”运算)来设置一个位掩码,只隔离了属性中的最后四个位。这就是颜色对存储前景颜色的值 0 到 15 的地方。 为了得到背景色,该函数首先执行了一个位移,将位“推”到右边。这就把“上”位放到了“下”位范围,所以任何像 `0xxx0000` 这样的位都变成了 `00000xxx`。我们可以用另一个的位掩码 7(二进制 `0111`)来挑选出背景颜色值。 ### 显示 ASCII 艺术 `IMAGEDATA` 数组包含整个 ASCII 艺术屏幕和每个字符的颜色值。为了在屏幕上显示 ASCII 艺术,你的程序需要扫描该数组,设置颜色属性,然后一次在屏幕上显示一个字符。 让我们在屏幕的底部留出空间,以便向用户提供单独的信息或提示。也就是说,我不想显示一个 80 列 ASCII 屏幕的所有 25 行,而只想显示前 24 行。 ``` /* print one line less than the 80x25 that's in there: 80 x 24 x 2 = 3840 */ for (pos = 0; pos < 3840; pos += 2) { ... } ``` 在 `for` 循环里面,我们需要设置颜色,然后打印字符。OpenWatcom C 编译器提供了一个函数 `_outtext` 来显示带有当前颜色值的文本。然而,这需要传递一个字符串,如果我们需要一个一个地处理每个字符,在一行中的每个字符需要不同颜色的情况下,效率就会很低。 相反,OpenWatcom 有一个类似的函数,叫做 `_outmem`,允许你指示要显示多少个字符。对于一次一个字符,我们可以在 `IMAGEDATA` 数组中提供一个字符值的指针,并告诉 `_outtext` 只显示一个字符。这将使用当前的颜色属性显示该字符,这就是我们需要的。 ``` for (pos = 0; pos < 3840; pos += 2) { ch = &IMAGEDATA[pos]; /* pointer assignment */ attr = IMAGEDATA[pos + 1]; textattr(attr); _outmem(ch, 1); } ``` 这个更新的 `for` 循环通过向 `IMAGEDATA` 数组分配一个指针来设置字符 `ch`。接下来, 循环设置文本属性, 然后用 `_outmem` 显示字符. ### 整合起来 有了 `textattr` 函数和处理数组的 `for` 循环, 我们可以编写一个完整的程序来显示 ASCII 艺术文件的内容。对于这个例子,将 ASCII 艺术文件保存为 `imgdata.inc`,并用 `#include` 语句将其包含在源文件中。 ``` #include <stdio.h> #include <conio.h> #include <graph.h> #include "imgdata.inc" void textattr(int newattr) { _settextcolor(newattr & 15); /* 0000xxxx */ _setbkcolor((newattr >> 4) & 7); /* 0xxx0000 */ } int main() { char *ch; int attr; int pos; if (_setvideomode(_TEXTC80) == 0) { fputs("Error setting video mode", stderr); return 1; } /* draw the array */ _settextposition(1, 1); /* top left */ /* print one line less than the 80x25 that's in there: 80 x 24 x 2 = 3840 */ for (pos = 0; pos < 3840; pos += 2) { ch = &IMAGEDATA[pos]; /* pointer assignment */ attr = IMAGEDATA[pos + 1]; textattr(attr); _outmem(ch, 1); } /* done */ _settextposition(25, 1); /* bottom left */ textattr(0x0f); _outtext("Press any key to quit"); getch(); textattr(0x00); return 0; } ``` 在 FreeDOS 上使用 OpenWatcom C 编译器编译该程序,你会得到一个显示这个节日信息的新程序。 ![ASCII艺术中的万圣节信息](/data/attachment/album/202110/31/154350gte33qlh6tcqmhmg.png) *万圣节快乐(Jim Hall, [CC-BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 万圣节快乐,各位! * [在此下载 inc 代码文件](https://opensource.com/sites/default/files/uploads/imgdata.inc_.txt) * [在此下载 C 代码文件](https://opensource.com/sites/default/files/uploads/hallown.c.txt) --- via: <https://opensource.com/article/21/10/ascii-linux-halloween> 作者:[Jim Hall](https://opensource.com/users/jim-hall) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
13,941
如何在 Linux 上杀死一个僵尸进程
https://opensource.com/article/21/10/linux-zombie-process
2021-11-01T09:50:00
[ "僵尸" ]
/article-13941-1.html
> > 要杀死一个僵尸进程,你必须从进程列表中删除其名称。 > > > ![](/data/attachment/album/202111/01/095024jyrvo8ss5jnxysqo.jpg "Full moon on a hazy night") 这里有一个和 Unix 纪元一样古老的故事。自从有了 C 和 Unix,以及(后来的)Linux,我们就有了“<ruby> 僵尸 <rt> zombie </rt></ruby>”。具体来说,有一些进程被标记为“<ruby> 僵尸进程 <rt> zombie process </rt></ruby>”。一些人误解它,另一些人忽视它,而它对我们许多人试图 “杀死” 这些进程的努力免疫,没有什么成效。这是为什么呢? ### Linux 中的进程是什么? 这一切始于执行 Linux 中的一个程序时,当它被执行时,它的运行实例被称为进程。你可以用 [ps 命令](https://opensource.com/article/21/8/linux-procps-ng) 查看你的 Linux 环境中的所有进程: ``` $ ps -ax PID TTY STAT TIME COMMAND 1 ? Ss 0:01 /usr/lib/systemd/systemd rhgb --switched-root --sys 2 ? S 0:00 [kthreadd] 3 ? I< 0:00 [rcu_gp] 4 ? I< 0:00 [rcu_par_gp] ``` 有时一个进程启动另一个进程,使第一个进程成为第二个进程的父进程。`pstree` 命令是一个很好的工具,可以让你看到系统中进程的“家谱”: ``` $ pstree -psn systemd(1)─┬─systemd-journal(952) ├─systemd-udevd(963) ├─systemd-oomd(1137) ├─systemd-resolve(1138) ├─systemd-userdbd(1139)─┬─systemd-userwor(12707) │ ├─systemd-userwor(12714) │ └─systemd-userwor(12715) ├─auditd(1140)───{auditd}(1141) ├─dbus-broker-lau(1164)───dbus-broker(1165) ├─avahi-daemon(1166)───avahi-daemon(1196) ├─bluetoothd(1167) ``` 每个进程在系统中都会被分配一个编号。进程编号(PID)1 被分配给启动过程中执行的第一个进程,PID 1 之后的每一个进程都是它的子孙。PID 1 进程是初始化进程,在大多数新版本的 Linux 中,它只是一个指向 `systemd` 程序的符号链接。 ### 用 kill 命令结束一个进程 你可以用 `kill` 命令来终止 Linux 系统中的进程。尽管名字叫 “杀死”,但 `kill` 命令和其他一些命令,如 `pkill` 和 `killall`,都是为向一个或多个进程发送信号而编写/设计的。当没有指定信号时,它发送的默认信号是 `SIGTERM` 信号,以终止进程。 当一个父进程死亡或被杀死,而其子进程没有跟随其父进程的死亡,我们称该进程为“<ruby> 孤儿进程 <rt> orphan process </rt></ruby>”。 ### 如何杀死一个僵尸进程 另一方面,僵尸进程是不能被“杀死”的!你可能会问为什么?因为它们已经死了! 每一个子进程,当被终止时,都会成为一个僵尸进程,然后被父进程删除。当进程退出并释放它所使用的资源时,它的名字仍然在操作系统的进程表中。这时,父进程的工作就是把它的名字从进程表中删除。如果没有删除,我们就有了僵尸进程,它不再是一个真正的进程,而只是操作系统进程表上的一个条目。 这就是为什么试图对一个<ruby> 失效的 <rt> defunct </rt></ruby>(僵尸)进程执行 “杀死” 命令,即使使用 `-9`(`SIGKILL`)选项也不起作用,因为没有什么可以杀死的。 因此,要杀死一个僵尸进程,比如从进程列表(进程表)中删除其名称,你必须杀死其父进程。例如,如果 PID 5878 是一个僵尸进程,而它的父进程是 PID 4809,那么要杀死僵尸进程(5878),就必须结束父进程(4809): ``` $ sudo kill -9 4809 # 4809 是父进程,而非僵尸 ``` 我对僵尸的最后一句警告:在杀死父进程时要非常小心。如果一个进程的父进程是 PID 1,而你杀了它,你就会重新启动自己! 而这将是一个更可怕的故事! --- via: <https://opensource.com/article/21/10/linux-zombie-process> 作者:[Anderson Silva](https://opensource.com/users/ansilva) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
13,942
Annotator:为 Linux 图片添加基本注解
https://itsfoss.com/annotator/
2021-11-01T10:26:58
[ "注解", "图片" ]
https://linux.cn/article-13942-1.html
![](/data/attachment/album/202111/01/102651ic6c6azacc8m8jxa.jpg) > > 一款令人兴奋和有用的注解工具,为 Linux 系统提供额外的功能。 > > > 谈及图像处理和编辑,有很多工具可用。然而,像 GIMP 这样的工具不一定能解决所有问题。 GIMP 确实为初学者和高级用户提供了大量的功能,但要学习一些东西并对图像进行视觉增强功能的应用可能很费时。 Annotator 是一个令人印象深刻的开源工具,可以让你能轻松完成很多事情。 ### Annotator:开源图像注解工具 ![](/data/attachment/album/202111/01/102658bvowiwip0yronxr8.png) Annotator 帮你快速添加形状、文本和其他视觉元素。这对各种使用情况都很有用。 这个工具提供了一个简单的用户界面并且易于使用。而且,你还可以通过各种你想要的功能来增强图像。 ### Annotator 的功能 ![Adding icons to images](/data/attachment/album/202111/01/102659s99t2ic9iu87cwps.png) 不局限于图片增强,你还可以通过 Annotator 获得一些其他功能。其中的一些主要功能是: * 能够添加文本 * 自定义文本的颜色,调整大小,调整高亮的颜色等 * 使用放大镜工具来关注图像中的某个特定点 * 调整放大镜以改变角度和大小 * 添加视觉图标来表达一些东西 * 使用铅笔来书写,这对触控板用户很有用 * 模糊工具来模糊重要或不必要的细节 * 计数器图标来突出图像中重要的任何种类的顺序 * 支持多种字体 * 调整形状和文本的边界宽度和线条 * 可用各种形状,如箭头、圆圈和星星 * 能够调整图像的大小和裁剪图像 ![](/data/attachment/album/202111/01/102659nfcszp6hgl9jqklq.png) ### 在 Linux 中安装 Annotator Annotator 通常可在 elementaryOS 的应用中心找到。但幸运的是,它是一个 Flatpak 包,所以你可以在任何 Linux 发行版上安装它。 你所需要做的就是前往应用中心商店的链接,然后使用软件安装程序下载/打开 **Flatpak ref** 文件。如果你需要帮助,我们的 [Flatpak 指南](https://itsfoss.com/flatpak-guide/) 中有更多相关信息。 [Annotator](https://appcenter.elementary.io/com.github.phase1geo.annotator/) 要从源代码构建或探索更多关于它的信息,你可以查看它的 [GitHub 页面](https://github.com/phase1geo/Annotator)。 ### 关于使用 Annotator 的想法 我发现它对我的工作很有用,因为我们每天都需要处理各种截图。而且,描述性越详细,图片就越能让我们的读者理解。 通常情况下,我使用 Flameshot 作为我的截图工具,并通过它添加可用的注解。还有其他 [可用于 Linux 的截图工具](https://itsfoss.com/take-screenshot-linux/),但我更喜欢 Flameshot 的快速注解功能。 然而,你不能使用 Flameshot 或其他任何截图工具来为现有的图片添加注解。 因此,Annotator 在编辑现有的截图或任何其他所需的图像时就显得非常方便。 在我短暂的使用过程中,它的所有功能都运行良好,不过我希望可以编辑和调整文字的大小,使之更加直观。 如果你需要为系统上的图像添加高亮/注解,我建议你试一试。请在下面的评论中告诉我你的想法。 --- via: <https://itsfoss.com/annotator/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[turbokernel](https://github.com/turbokernel) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
**Brief:***An exciting and useful annotation tool with additional features for Linux systems.* When it comes to image manipulation and editing, there are many tools available. However, options like GIMP are not necessarily the solution to everything. Yes, GIMP offers plenty of features for beginners and advanced users, but it could be time-consuming to learn something and apply visual enhancements to any image you want. Annotator is an impressive open-source tool that lets you do a lot of things in a couple of clicks. ## Annotator: Open-Source Image Annotation Tool ![annotator](https://itsfoss.com/content/images/wordpress/2021/10/annotator.png) Annotator lets you quickly add shapes, texts, and other visual elements. This is useful for a variety of use-cases. The tool is easy to use and offers a simple user interface. And, you also get a variety of features to enhance the images you want. ## Features of Annotator ![annotator screenshot](https://itsfoss.com/content/images/wordpress/2021/10/annotator-screenshot.png) Not just limited to adding enhancements to an image, but you also get some other functionalities with Annotator. Some of the key features are: - Ability to add a text - Customize the text color, adjust the size, tweak the highlight color, and more - Use magnifying tool to focus on a particular point in image - Tweak the magnifier to change the angle, and size - Add visual icons to express something - Use pencil to write, useful for trackpad users - Blur tool to obfuscate important or unnecessary details - Counter icons to highlight important any sort of order in an image - Supports multiple fonts - Adjust the border width and lines for shapes and texts - Various shapes like arrow, circle, and star available - Ability to resize and crop images ![annotator resize](https://itsfoss.com/content/images/wordpress/2021/10/annotator-resize.png) ## Installing Annotator in Linux Primarily, Annotator is available on AppCenter for elementaryOS. But, fortunately, it is a Flatpak package, so that you can install it on any Linux distribution. All you need to do is head to the AppCenter store’s link and then download/open the **Flatpak ref** file using the software installer. We have more information on this in our [Flatpak guide](https://itsfoss.com/flatpak-guide/), if you need help. To build from the source or explore more about it, you can check out its [GitHub page](https://github.com/phase1geo/Annotator). ## Thoughts on Using Annotator I find it useful for my work, considering we need to deal with various screenshots every day. And, the more descriptive, the better the images for our readers to understand. Usually, I use Flameshot as my screenshot tool and add annotations available through it. There are other [screenshot tools available for Linux](https://itsfoss.com/take-screenshot-linux/), but I prefer Flameshot for its quick annotation features. However, you cannot use Flameshot to add annotations to existing images. Hence, Annotator came in handy to edit existing screenshots or any other images needed. All of its features worked well in my brief usage, but I’d want to edit and re-size the text to be more intuitive. Other than that, I have no complaints. I’d recommend you give this a try if you need to add highlights/annotations to the images on your system. Let me know your thoughts in the comments down below.
13,944
VS Code 还是 Atom?你应该选择哪个
https://itsfoss.com/visual-studio-code-vs-atom/
2021-11-01T23:18:12
[ "VSCode", "Atom" ]
https://linux.cn/article-13944-1.html
![](/data/attachment/album/202111/01/231806jk4mky6gjmrw4mgm.png) 如今,找到一个 [好的开源代码编辑器](https://itsfoss.com/best-modern-open-source-code-editors-for-linux/) 并不难,随便选择一个就可以了。 微软的 [VS Code](https://code.visualstudio.com/) 和 GitHub 的 [Atom](https://atom.io/) 是两个最流行的、功能丰富的、类似于 IDE 的代码编辑器,都拥有庞大的用户群和粉丝。 VS Code 和 Atom 现在都属于微软,因为 Atom 的原开发者 GitHub 现在属于微软。这两个都有一个有吸引力的、现代的 UI,有一个漂亮的原生黑暗主题。两个编辑器都使用 [Electron](https://www.electronjs.org/) 作为用户界面。 相似的地方很多,这就是为什么你很容易在它们中间选择时感到迷惑。 如果你不能下定决心,想在 VS Code 和 Atom 之间进行一番比较和选择,这篇文章应该可以帮助你。 ### VS Code ![VS Code 的用户界面与拥挤的项目界面](/data/attachment/album/202111/01/231812onun5juacaxjuyxt.png) [VS Code](https://code.visualstudio.com/) 是开源的现代编辑器之一。它的用户群爆炸性地增长,因为它具有类似 IDE 的功能,但仍然保持相对较轻的资源占用。 VS Code 是由微软制作的,可用于 Linux、macOS 和 Windows。微软于 2015 年 11 月 18 日在 [GitHub](https://github.com/microsoft/vscode) 上根据 MIT 许可发布了 VS Code 的 *大部分* 源代码。 VS Code 的开发者对 Electron 进行了一些奇妙的优化,使其尽可能的轻量级和高效。由于 Electron 应用程序可以在大多数操作系统上运行,Linux、macOS 和 Windows 的用户都可以从这些优化中受益。 [在 Linux 上安装 VS Code](https://itsfoss.com/install-visual-studio-code-ubuntu/) 也相当简单。事实上,它在许多发行版的软件中心都有。 #### 为什么你应该选择 VS Code? * 那些从一开始就想获得接近 IDE 的功能,而又不想摆弄他们的代码编辑器的人,[通常] 会选择 VS Code 。 * 即使是基于 Electron,VS Code 与其他 Electron 应用(如 GitHub 的 Atom)相比,开销也非常小。 * 更多开箱即用的功能,如微软的 IntelliSense 自动补完、Git 集成、Markdown 支持等等。 * 插件可以只用来增加功能、主题和支持新的语言;而这种插件约束确保编辑器的核心在增加新插件后仍保持熟悉。 [由微软分发的](https://code.visualstudio.com/Download) 二进制版本仍然是专有的免费软件。[VSCodium](https://vscodium.com/) 建立在 VS Code 的公开源代码之上。然而,关于 VSCodium 的讨论超出了本文的范围,如果你想获得 VS Code 提供的功能,而又没有任何专有元素的话,可以考虑将其作为 VS Code 的一个可行的替代品。 Atom ---- ![Atom 编辑器的用户界面](/data/attachment/album/202111/01/231813o76i0qih0ot7ixsw.png) [GitHub 的 Atom](https://atom.io/) 是另一个自由开源的代码编辑器,可用于 Linux、macOS 和 Windows。Atom 是一个使用 JavaScript 通过 Electron 制作的桌面应用程序,用于轻松开发软件包。 Atom 的源代码是根据 MIT 许可发布 [在 GitHub 上](https://github.com/atom/atom) 的。由于 Atom 是 GitHub 的产品,因此它嵌入了 Git Control。 Atom 被称为“<ruby> 可魔改的 <rt> hackable </rt></ruby> 21 世纪文本编辑器”,因为它可以使用 HTML、CSS 和 JS 完全定制。 像 VS Code 一样,你可以轻松地在其他平台和 [Linux 上安装 Atom](https://itsfoss.com/install-atom-ubuntu/) 。 #### 选择 Atom 的理由 * Atom 是那些想要一个基础的编辑器,并希望在其上进行开发的人的首选,因为 Atom 的可魔改性质。 * 内置了 Git 和完整的 GitHub 集成;考虑到它是由 GitHub 开发的,这并不令人惊讶。 * 从应用程序中非常容易搜索、安装和升级 [Atom 的插件](https://itsfoss.com/install-packages-in-atom/)。 * 可用的 Atom 插件是非常可扩展的,甚至可以完全改变编辑器的功能,并最终创造出几乎一个新的编辑器;它确实是“可魔改”的。 * Atom 的二进制版本和它的源代码是完全开源的(不像 VS Code 的二进制版本包含专有部分+遥测)。 * 你可以 [把 Atom 从一个代码编辑器变成 IDE](https://ide.atom.io/),有更智能的上下文自动完成、代码导航功能、文档格式化等。 ### 总结 Atom 和 VS Code 都是建立在 Electron 之上的。但是微软在 VS Code 上做了更多的优化,使其尽可能的轻量化。 在这一点上,VS Code 就像 Ubuntu,几乎所有的东西都开箱即用。而 Atom 就像 Arch,精简,而极易魔改(可扩展)。 Atom 和 VS Code 在技术上都隶属于微软,最终它们会殊途同归。因此,最好是使用你的社区(网页开发/软件开发)所倾向的编辑器,并铺平前进的道路。也许你最终会选择 Vim! --- via: <https://itsfoss.com/visual-studio-code-vs-atom/> 作者:[Pratham Patel](https://itsfoss.com/author/pratham/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Finding a [good open source code editor](https://itsfoss.com/best-modern-open-source-code-editors-for-linux/) is not hard these days, choosing one can be. Microsoft’s [Visual Studio Code](https://code.visualstudio.com/?ref=itsfoss.com) and GitHub’s [Atom](https://atom.io/?ref=itsfoss.com) are two of the most popular, feature-rich, IDE-like code editors that have a huge user base and fan following. Both VS Code and Atom belong to Microsoft now because Atom’s original developer GitHub is now owned by Microsoft. They have an interesting, modern UI with a pretty looking native dark theme. Both editors use [Electron](https://www.electronjs.org/?ref=itsfoss.com) for the user interface. The similarities are plenty and this is why it is easy to get confused between choosing one of them for your coding set up. If you cannot make up your mind and want to compare and choose between one VS Code and Atom, this article should help you decide for yourself. ## Visual Studio Code ![04 visual studio code](https://itsfoss.com/content/images/wordpress/2021/10/04_visual_studio_code-800x544.png) Visual Studio Code’s User Interface with a busy project interface [Visual Studio Code](https://code.visualstudio.com/?ref=itsfoss.com) (A.K.A. VS Code) is one of the modern open source code editors. Its user-base explode because of its IDE-like features but still remaining relatively light on resources. Visual Studio Code was made by Microsoft and is available on Linux, macOS and Windows. Microsoft released *most* of the source code of Visual Studio Code on [GitHub](https://github.com/microsoft/vscode?ref=itsfoss.com) under the MIT License on 18th November 2015. VS Code developers have done some fantastic optimizations with Electron to make it as lightweight and efficient as possible. And since Electron apps work on a majority of operating systems, users of Linux, macOS and Windows can all benefit from these optimizations. [Installing VS Code on Linux](https://itsfoss.com/install-visual-studio-code-ubuntu/) is pretty simple too. It is in fact available in the software center of many distributions. ### Why you should opt for Visual Studio Code - Visual Studio Code is [generally] chosen by folks who want a near-IDE functionality from the start and do not want to fiddle with their code editor. - Visual Studio Code, even though based on Electron, has very little overhead compared to other Electron apps (GitHub’s Atom). - More out-of-the-box functionality like Microsoft’s IntelliSense auto-complete, Git integration, Markdown support. - Plug-ins can only add features, themes and add support for new languages; and this plug-in constraint ensures the editor’s core stays familiar even after adding new plug-ins. The binary releases [distributed by Microsoft](https://code.visualstudio.com/Download?ref=itsfoss.com) are still proprietary freeware. [VSCodium](https://vscodium.com/?ref=itsfoss.com) builds upon the publicly open source code of Visual Studio Code. However, the discussion on VSCodium is beyond the scope of this article, except for considering it as a viable alternative to Visual Studio Code if you want the functionality Visual Studio Code offers, but without any proprietary elements to it. ## Atom ![05 atom](https://itsfoss.com/content/images/wordpress/2021/10/05_atom-800x527.png) User Interface of the Atom editor [GitHub’s Atom](https://atom.io/?ref=itsfoss.com) is another free and open source code editor available for Linux, macOS and Windows. Atom is a desktop application made with Electron for easy package development using JavaScript. Atom’s source code was released under the MIT License [on GitHub](https://github.com/atom/atom?ref=itsfoss.com). Since Atom is a GitHub product, it has Git Control embedded in it. Atom is dubbed as the “hackable text editor for the 21st Century” because of it complete customizability using HTML, CSS and JS. Like VS Code, you can easily [install Atom on Linux](https://itsfoss.com/install-atom-ubuntu/) and other platforms. ### Reasons to choose Atom - Atom is preferred by people who want a bare-bones editor and want to build upon it because of Atom’s hackable nature. - In-built Git and complete GitHub integration; not surprising considering it is developed by GitHub [Atom’s plug-ins](https://itsfoss.com/install-packages-in-atom/)are very easy to search, install and upgrade, from the app itself.- Plug-ins available for Atom are very extensible, and can end up completely changing the editor’s functionality and end up creating almost a new editor; It truly is “hackable”. - Atom’s binary releases and its source code are fully open source (unlike Visual Studio Code’s binary releases containing proprietary parts + telemetry). - You can [turn Atom from a code editor to IDE](https://ide.atom.io/?ref=itsfoss.com)with smarter context-aware auto-completion, code navigation features, document formatting and more. ## Conclusion Both Atom and VS Code are built on Electron. But Microsoft has done more optimization on VS Code to make it as lightweight as possible. At this point, VS Code is like Ubuntu, ships with almost everything out of the box. While Atom is like Arch, minimal and extremely hackable (extendable). Both, Atom and VS Code technically are under Microsoft and eventually will reach feature parity. Hence, it is best to go with the editor your community (Web dev/Soft dev) leans towards and pave the path ahead. Maybe you end up with Vim!
13,946
Ferdi:Franz 和 Rambox 的自由开源替代品
https://itsfoss.com/ferdi/
2021-11-03T17:12:26
[ "Ferdi", "Franz" ]
https://linux.cn/article-13946-1.html
> > Ferdi 是一个很有前途的开源应用,是 Franz 和 Rambox 的替代品,免费提供了更多功能。让我们来探索一下它的更多信息。 > > > ![](/data/attachment/album/202111/03/171216dxojy2xuivii4xii.jpg) 有一个可以帮助你管理多个服务的应用会方便,这样你就不用什么事情都要打开一个浏览器去做了,虽然从技术上讲,你可以这样,但这肯定不是最有条理的做事方式。 因此,像 [Rambox](https://itsfoss.com/rambox/) 和 [Franz](https://itsfoss.com/franz-messaging-app/) 这样的跨平台解决方案是相当流行的,它可以登录到几个服务,并一目了然地访问所有的服务。 尽管它们都可用于 Linux(而且我们已经单独介绍过它们),但它们免费提供的功能有限。 相比之下,Ferdi 是 Franz 的一个复刻,旨在提供更好的体验,同时免费提供了许多高级功能。 ### Ferdi: 一处管理多个应用 ![](/data/attachment/album/202111/03/171227xk6ek2wv2zuwmujp.png) Ferdi 是一个自由开源应用,让你在一个地方添加多个应用,包括各种消息服务。 它还可以让你定制应用的各个方面和它的行为。如果你喜欢像 Rambox 和 Franz 这样的应用,你更应该看看 Ferdi。 ### Ferdi 的特点 ![](/data/attachment/album/202111/03/171227tn81k5cemcpnguen.png) 你可以发现它有大量的功能,而不需要支付额外费用。在这里,我将重点提到一些关键的功能: * 跨平台支持(Linux、Windows 和 macOS)。 * 包含丰富的信息服务(Slack、WhatsApp、Element 等)。 * 支持用 Franz 账户登录 * 能够对信息进行密码保护 * 可以选择使用你的自定义服务器 * 快速访问待办事项列表,可选择使用 Franz Todo、Todoist、Microsoft To Do、[Any.do](http://Any.do) 等 * 通过在不使用时卸载应用(休眠)来调整性能 * 私密通知,以隐藏你的信息 * 支持“请勿打扰”模式 * 可为每个应用单独切换黑暗模式 * 云同步 * 对账户数量没有限制 * 能够设置一个代理,并通过它进行连接 * 可以添加多个工作空间 ### 关于使用 Ferdi 的想法 ![](/data/attachment/album/202111/03/171227p2uooudd3z30fdff.png) 就像 Rambox 和 Franz 一样,Ferdi 不可避免的会消耗大量资源。所以,你需要知道你是否有足够的内存来让几个应用在 Ferdi 中活动。 在不使用时,能够卸载应用是件好事。因此,如果你的资源不足,你可能想利用休眠选项。 ![](/data/attachment/album/202111/03/171228b06ge00tl6hn86e2.png) Ferdi 还提供一些高级选项,如 GPU 加速、通用黑暗模式、隐私切换、外观定制等。你甚至可以添加没有列出的自定义服务。 ![](/data/attachment/album/202111/03/171228u9ll48lm0409agcg.png) 总的来说,在 Ferdi 中你会得到许多功能和选择,你可以用这些选项组合有效地将多个应用有条理地组织起来。 ### 在 Linux 中安装 Ferdi Ferdi 提供了多个软件包,便于在 Linux 上安装。你可以找到一个适用于 Ubuntu/Fedora 的 DEB/RPM 包,以及一个适用于所有其他 Linux 发行版的 [AppImage 文件](https://itsfoss.com/appimage-interview/)。 他们还提供了一个 snap 包,并且也可以通过 [AUR](https://itsfoss.com/aur-arch-linux/) 安装。所以,你有很多选择来让它安装在你的 Linux 电脑上。 你可以探索他们的 [GitHub 页面](https://github.com/getferdi/ferdi) 并前往其发布页下载,或者访问其官方网站。 * [下载 Ferdi](https://getferdi.com/) 你试过 Ferdi 了吗?它是否达到了取代 Franz 或 Rambox 的目的?它是否更好?请在下面的评论中分享你的经验。 --- via: <https://itsfoss.com/ferdi/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
*Brief: **Ferdi is a promising open-source application with more free features as an alternative to Franz and Rambox. Let us explore more about it.* A single application to help you manage multiple services comes in handy when you do not want to do everything on your browser. While technically, you can, it may not be the most organized way of doing things. Hence, options like [Rambox](https://itsfoss.com/rambox/) and [Franz](https://itsfoss.com/franz-messaging-app/) are pretty popular cross-platform solutions to sign in to several services and access all of them at a glance. Even though they both are available for Linux (and we’ve covered them separately), they offer limited features for free. In contrast, Ferdi is a fork of Franz offering many premium functionalities for free while aiming to provide a better experience. ## Ferdi: Dabble With Multiple Applications in One Place ![ferdi screenshot](https://itsfoss.com/content/images/wordpress/2021/10/ferdi-screenshot.png) Ferdi is a free and open-source application that lets you add multiple applications, including various messaging services, in one place. It also lets you customize various aspects of the application and its behavior. If you like applications like Rambox and Franz, you should explore more about Ferdi. ## Features of Ferdi ![ferdi screenshot 1](https://itsfoss.com/content/images/wordpress/2021/10/ferdi-screenshot-1.png) You can find tons of features available without needing to pay a premium. Here, I shall highlight some key features: - Cross-platform support (Linux, Windows, and macOS) - Wide range of messaging services included (Slack, WhatsApp, Element, etc.) - Supports signing in with Franz account - Ability to password-protect messages - Option to use your custom server - Quick to-do list access with the option to use Franz Todo, Todoist, Microsoft To Do, Any.do, and more. - Tweak performance by unloading applications when not in use (Hibernation) - Private notification to hide your messages - Do not disturb mode support - Dark mode with the option to toggle every app added separately - Cloud sync - No restrictions on the number of accounts - Ability to set up a proxy and connect through it - Add multiple workspaces ## Thoughts on Using Ferdi ![ferdi custom services](https://itsfoss.com/content/images/wordpress/2021/10/ferdi-custom-services.png) Just like Rambox and Franz, Ferdi won’t shy away from consuming a good chunk of your resources. So, you need to keep in mind whether you have enough memory (RAM) to have several applications active within Ferdi. It is good to have the option to unload applications when not in use. So, in case you are low on resources, you might want to utilize the Hibernation option. ![ferdi workspaces](https://itsfoss.com/content/images/wordpress/2021/10/ferdi-workspaces.png) Ferdi also offers some advanced options like GPU acceleration, universal dark mode, privacy toggles, appearance customization, and more. You can even add custom services that you do not find listed. ![ferdi advanced options](https://itsfoss.com/content/images/wordpress/2021/10/ferdi-advanced-options.png) Overall, you get many features and choices when it comes to Ferdi. You should be able to organize multiple applications efficiently with the available set of options. ## Installing Ferdi in Linux Ferdi offers multiple packages for easy installation on Linux. You can find a DEB/RPM package for Ubuntu/Fedora, an [AppImage file](https://itsfoss.com/appimage-interview/) for all other Linux distributions. They also provide a snap package along with the ability to install it via [AUR](https://itsfoss.com/aur-arch-linux/). So, you have plenty of options to get it installed on your Linux computer. You can explore their [GitHub page](https://github.com/getferdi/ferdi) and head to its releases section to download them or visit the official site. Have you tried Ferdi yet? Does it serve the purpose of replacing Franz or Rambox? Is it better? Share your experience in the comments down below.
13,947
如何更改 Ubuntu 的终端的颜色
https://itsfoss.com/change-terminal-color-ubuntu/
2021-11-03T17:31:58
[ "终端", "颜色" ]
https://linux.cn/article-13947-1.html
![](/data/attachment/album/202111/03/173150n4wjwgi4iii4662z.jpg) 如果你只是想完成一些工作,默认的终端已经看起来足够好了。 但是,如果你想要一个独一无二的的终端体验或者符合你自身品位的一些东西,你也可以改变你的 Ubuntu 的终端的颜色。 在这篇速成教程中,我将专注于调整 Ubuntu 中的颜色方案。由于 Ubuntu 使用 GNOME 的终端,因此这些步骤可能也对大多数的使用 GNOME 桌面环境的其它的发行版有效。 ### 更改你的 Ubuntu 的终端的颜色 这些步骤类似于 [如何更改终端的字体和大小](https://itsfoss.com/change-terminal-font-ubuntu/)。你必须找到自定义颜色的选项,就是这样的简单。 让我们快速指出你需要找到什么: **步骤 1**:[在 Ubuntu 中打开终端窗口](https://itsfoss.com/open-terminal-ubuntu/),方法是按 `Ctrl+Alt+T` 组合键。 **步骤 2**:打开终端<ruby> 首选项 <rt> Preferences </rt></ruby>。你可以单击菜单按钮或者右击终端屏幕的任意位置来访问首选项。 ![](/data/attachment/album/202111/03/173200krrlbl201sqnqv51.png) 针对你的自定义选项,创建一个独立的配置文件将会是一个好主意,因为这样做不会更改默认的设置。 ![](/data/attachment/album/202111/03/173202ap0j190lp6xppnmi.jpg) **步骤 3**:现在,你可以找到一些调整字体大小和样式的选项。但是,在这里,你需要前往 “<ruby> 颜色 <rt> Colors </rt></ruby>” 选项卡,如下面的屏幕截图所示。 ![](/data/attachment/album/202111/03/173204iwy2wtvi2iriwjoe.png) **步骤 4**:在默认情况下,你将会注意到:它使用来自系统主题的颜色。如果你想融入你自己的系统主题,这应该是首选的方式。 但是,如果你想要自定义,你需要先取消系统的颜色的选项,然后再开始选择颜色。 ![](/data/attachment/album/202111/03/173206ngr7zrogrogqnp97.jpg) 如你在上面的屏幕截图中能够注意到的那样,你可以选择使用一些内置的颜色方案,也可以 **通过更改文本和背景的默认颜色选项** 来完成自定义颜色方案。 如果你选择一种“自定义”内置方案,那么你可以自定义从文本到光标的各个层面的终端的屏幕颜色。 ![](/data/attachment/album/202111/03/173208tub25gg2xgzdp26e.png) 再强调一次!如果你想快速地访问终端的不同的自定义版本,请创建一个单独的配置,否则,每次当你想要一种独特的颜色组合方案时,你都将需要重新自定义。 ### 更改终端的颜色的其它的方法 这里有其它的几种更改 Ubuntu 的终端的颜色的方法: #### 更改主题 大多数的 Ubuntu 主题都有它们自己的终端的颜色的实现,并且其中的一些实现看起来非常漂亮。这里是如何针对 Ant 和 Orchis 主题进行更改终端的颜色方案: ![](/data/attachment/album/202111/03/173210gogo7mwb5939y7no.png) 你可以选择一种黑暗主题,接下来你的主题将会变成黑色。不需要担心选择颜色方案的问题。 #### 依据你的壁纸选择终端颜色 如果你不想手动自定义你的终端的颜色,你可以使用 Pywal 。使用这个方便的 Python 工具,你的计算机能够随着你的每一张壁纸来 [更改你的终端的颜色方案](https://itsfoss.com/pywal/) 。 它将自动地适配你所使用的壁纸。因此,你不需要费心地自定义终端。 ### 针对你的终端的自定义选项 如果你是一个更高级的玩家,你可能会热衷于更多的自定义终端的外貌的选项。你可以通读我们关于 [调整终端的外貌的不同的方法](https://itsfoss.com/customize-linux-terminal/) 的资源来探索更多的信息。 你更喜欢自定义终端吗?在下面的评论区,让我们知道你的经历! --- via: <https://itsfoss.com/change-terminal-color-ubuntu/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[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/) 荣誉推出
200
OK
The default terminal looks good enough if you want to get things done. But, if you want a unique terminal experience or something that suits your taste, you can also change the color of your Ubuntu terminal. In this quick tutorial, I shall focus on tweaking the color scheme of the terminal in Ubuntu. Ubuntu uses GNOME Terminal so the steps should be valid for most other distributions using GNOME desktop environment. ## Changing the color of your Ubuntu terminal The steps are similar to how you [change the font and size of the terminal](https://itsfoss.com/change-terminal-font-ubuntu/). You have to find the option for customizing colors, that’s it. Let me quickly highlight what you need to go through to find it: **Step 1**. [Open the terminal window in Ubuntu](https://itsfoss.com/open-terminal-ubuntu/) by pressing Ctrl+Alt+T. **Step 2**. Head to the terminal preferences. You can click on the menu button to access the **Preferences** or right-click anywhere on the terminal screen. ![terminal preference](https://itsfoss.com/content/images/wordpress/2021/09/terminal-preference.png) It will be a good idea to create a separate profile for your customization so that the default settings do not change. ![Terminal Profiles](https://itsfoss.com/content/images/wordpress/2021/02/terminal-profiles-800x619.jpg) **Step 3**. Now, you can find the options to tweak the font size and style. But, here, you need to head to the “**Colors**” tab, as shown in the screenshot below. ![terminal colors option](https://itsfoss.com/content/images/wordpress/2021/09/terminal-colors-option.png) **Step 4**. By default, you will notice that it uses colors from the system theme. If you want to blend in with your system theme, that should be the preferred choice. But, if you want to customize, you need to deselect the option and then start choosing the colors. ![changing colors ubuntu terminal](https://itsfoss.com/content/images/wordpress/2021/09/changing-colors-ubuntu-terminal.webp) As you can notice in the screenshot above, you can choose to use some of the built-in color schemes and also get to customize them to your liking *by changing the default color option for the text and background.* You can customize every aspect of the terminal screen color, starting from the texts to the cursor, if you select a “custom” built-in scheme. ![ubuntu terminal color customize](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-terminal-color-customize-800x550.png) Again! Create separate profiles if you want to access different customized versions of the terminal quickly or else you will end up customizing every time you want a specific color combination. ## Other ways to change the terminal color Here are a couple of other ways to change the terminal color in Ubuntu: ### Change the theme Most Ubuntu themes have their own implementation of terminal colors and some of them actually look very nice. Here is how the terminal color scheme is changed for Ant and Orchis themes. ![terminal ant theme](https://itsfoss.com/content/images/wordpress/2021/09/terminal-ant-theme.png) ![terminal orchis theme](https://itsfoss.com/content/images/wordpress/2021/09/terminal-orchis-theme.png) You choose a dark theme and your terminal turns black. No need to wonder about selecting color schemes. ### Change terminal color based on your wallpaper If you do not want to customize the colors of your terminal manually, you can utilize Pywal. With this handy Python tool, you can [change the color scheme of your terminal](https://itsfoss.com/pywal/) as per your wallpaper. It will automatically adapt to any of your active wallpapers. So, you do not have to bother customizing the terminal. ## More Customization Options for Your Terminal If you are more of a tinkerer, you would love to know that you have more options to customize the look of the terminal. You can read through our resource on [different ways to tweak the look of the terminal](https://itsfoss.com/customize-linux-terminal/) to explore more about it. *How do you prefer to customize the terminal? Let me know your experiences in the comments below!*
13,949
Fedora 35 登场:带来了 GNOME 41 和一个新的 KDE 变体
https://news.itsfoss.com/fedora-35-release/
2021-11-04T09:21:17
[ "Fedora" ]
https://linux.cn/article-13949-1.html
> > Fedora 35 发布了,带来了 GNOME 41,并有一个专注于可靠性的基于 KDE 的新变体。 > > > ![](/data/attachment/album/202111/04/092117daga2ccxul4f4xq2.png) 在测试版发布几周后,Fedora 35 稳定版终于来了!这个版本带来了一些关键性的改进,我们将在这里介绍它们。 这些改进中最值得注意的是加入了最近发布的 GNOME 41,同时还有一些小的升级,如 Linux 内核 5.14 和完成向 PipeWire 的过渡。 现在,让我们来简要看一下这些变化,以及 Fedora 35 引入的一些改进。 ### Fedora 35 的关键升级 下面是 Fedora 35 中一些比较有影响的升级和新增功能。 ### 桌面环境 Fedora 因其对最新桌面环境的支持而闻名,而这一点在这个版本中似乎没有改变。 #### GNOME 41 ![](/data/attachment/album/202111/04/092118f49lzud4yy354033.png) Fedora 35 工作站现在搭载了目前最受欢迎的 GNOME 41。这意味着它有了新的“<ruby> 连接 <rt> Connections </rt></ruby>”应用、显著改进的软件中心,以及一些很棒的多任务控制。 它还对笔记本用户有所帮助,因为它改进了触摸板手势、电源配置文件和移动数据设置。 如果你想看看还有什么新东西,你可以看看我们的 [GNOME 41 发布报道](https://news.itsfoss.com/gnome-41-release/)。 #### KDE Plasma 5.22 ![](/data/attachment/album/202111/04/092120q6vdb7nl7ve6d74d.png) 不过,这个版本并不包括最近发布的 Plasma 5.23,而是选择了 [Plasma 5.22](https://news.itsfoss.com/kde-plasma-5-22-release/)。不过,这是可以理解的,因为 Fedora 团队只有一周的时间。 虽然是一个相当小的升级,Plasma 5.22 确实带来了自适应透明功能,以及改进的 Krunner 和系统设置。如果你有兴趣,你可以看看 [KDE Plasma 5.22](https://news.itsfoss.com/kde-plasma-5-22-release/) 的更多信息。 ### 新的 KDE 版本:Fedora Kinoite ![](/data/attachment/album/202111/04/092121paw9vsfi5n8wsbev.jpg) Fedora Kinoite 采用 KDE Plasma 桌面,并且它是基于 rpm-ostree 技术的。你可以得到开箱即用的 Flatpak 应用程序支持,以轻松安装软件。 根据其官方的描述: > > “Kinoite 提供原子更新和一个不可变操作系统,以提高可靠性。” > > > 因此,它可能是一个值得尝试的选择,可以作为你的 Linux 桌面操作系统用于日常工作,而不存在因更新而破坏用户体验的风险。 截至目前,它支持 X86\_64 和 AArch64 架构。你可以去它的 [项目网站](https://kinoite.fedoraproject.org/) 了解一下。 ### Linux 5.14 内核 早在八月份,我就介绍了 [新的 Linux 5.14](https://news.itsfoss.com/kernel-5-14-release/) 内核,它现在已经出现在了 Fedora 35 中。这对那些基于 ARM 的系统来说是个好消息,因为 Linux 5.14 带来了许多针对 ARM 的改进。 如果你没有使用 ARM 计算机,你仍然会从 Linux 5.14 的一些其他改进中受益。这些改进主要与 GPU 有关,以及对 USB 4 的改进支持。 #### DNS over TLS 支持 随着隐私变得越来越重要,像 DNS over TLS(DoT)这样的技术正在成为我们隐私的一个关键部分。现在,Fedora 35 带来了对这项技术的支持,它有助于加密你进出 DNS 服务器的互联网流量。 这意味着你的 ISP 不能监视你的浏览习惯,我相信每个人都会喜欢这一点。 ### 其他改进 除了前面提到的那些,Fedora 35 还带来了对以下新功能的支持。 * Firewalld 软件包更新 * GNU 工具链更新 * 支持第三方软件库中的 Flathub 应用程序 * Fedora Cloud 默认采用 btrfs 文件系统 * 过渡到 Pipewire 如果你想看完整的变化列表,可以在 [官方更新列表](https://fedoraproject.org/wiki/Releases/35/ChangeSet) 或 [官方公告](https://fedoramagazine.org/announcing-fedora-35/) 中找到。 ### 总结 虽然这个版本没有像 Fedora 34 那样带来很多突破性的改进,但我认为用户会对它更加满意。在 GNOME 41 和 Linux 5.14 之间,用户应该会发现他们的系统有了不错的改进。 如果你想亲自尝试一下 Fedora 35,请随时从下面的链接中下载它。 * [下载Fedora 35](https://getfedora.org/) 你对 Fedora 35 中引入的变化有什么看法?请在下面的评论中告诉我! --- via: <https://news.itsfoss.com/fedora-35-release/> 作者:[Jacob Crume](https://news.itsfoss.com/author/jacob/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) A couple of weeks after the beta release, Fedora 35 stable version has finally arrived! This version brings a few key improvements, many of which we will be looking at here. Most notable of these improvements is the inclusion of the recently-released Gnome 41, accompanied by smaller upgrades such as Linux Kernel 5.14 and the completion of the transition to PipeWire. Now, let’s have a look at some of these changes in brief along with some improvements introduced with Fedora 35. ## Key Upgrades in Fedora 35 Here are some of the more impactful upgrades and additions in Fedora 35. ## Desktop Environments Fedora is well known for its incredible support for the latest desktop environments, and this doesn’t seem to be changing with this release. ### GNOME 41 ![](https://news.itsfoss.com/content/images/wordpress/2021/10/Gnome-41-Fedora-1024x576.png) By far the most popular version, Fedora 35 Workstation now ships with GNOME 41. This means that it gains the new Connections app, significantly improved software center, and some awesome multitasking controls. It should also help laptop users, with its improved touchpad gestures, power profiles, and mobile data settings. If you want to see what else is new, you can take a look at our [GNOME 41 release coverage](https://news.itsfoss.com/gnome-41-release/). ### KDE Plasma 5.22 ![](https://news.itsfoss.com/content/images/wordpress/2021/10/KDE-5.22-Fedora-1024x576.png) Unfortunately, this release doesn’t include the recently released Plasma 5.23, instead opting for [Plasma 5.22](https://news.itsfoss.com/kde-plasma-5-22-release/). This is understandable, however, given that the Fedora team would only have had about a week to get it working. While a pretty minor upgrade, Plasma 5.22 does bring in the adaptive transparency feature, along with the improved Krunner and system settings. You might want to explore more about [KDE Plasma 5.22](https://news.itsfoss.com/kde-plasma-5-22-release/) if you are curious. ## New KDE Edition: Fedora Kinoite ![](https://news.itsfoss.com/content/images/wordpress/2021/10/kde-kinoite-1024x576.jpg) Fedora Kinoite features the KDE Plasma desktop and is based on rpm-ostree technology. You get Flatpak application support out-of-the-box to easily install the software. As per the official description: “ Kinoite provides atomic updates and an immutable operating system for increased reliability.“ So, it could be an interesting option to use as your Linux desktop operating system for everyday tasks without the risk of breaking the user experience with updates. As of now, it is available for X86_64 and AArch64. You can head to its [project website](https://kinoite.fedoraproject.org/?ref=news.itsfoss.com) to get started. ## Linux Kernel 5.14 Back in August, I looked at the [new Linux 5.14 k](https://news.itsfoss.com/kernel-5-14-release/)ernel, which has now found its way into Fedora 35. This is great news for those on ARM-based systems, as Linux 5.14 brought many ARM-specific improvements. If you’re not using an ARM computer, you will still benefit from some of the other improvements in Linux 5.14. These improvements are primarily related to GPUs, as well as improved support for USB 4. ### DNS Over TLS Support With privacy becoming more and more important, technologies such as DNS over TLS (DoT) are becoming a critical part of our privacy. Now, Fedora 35 brings support for this technology, which aids in encrypting your internet traffic to and from the DNS server. This means that your ISP shouldn’t be able to spy on your browsing habits, which I’m sure everyone will appreciate. ## Other Improvements Aside from the ones previously mentioned, Fedora 35 brings support for the following new features: - Firewalld package update - GNU Toolchain update - Flathub applications included with third-party repositories - Default btrfs filesystem for Fedora cloud - The transition to Pipewire If you want to see a full list of changes, they can be found in the [official changelist](https://fedoraproject.org/wiki/Releases/35/ChangeSet?ref=news.itsfoss.com) or in the [official announcement](https://fedoramagazine.org/announcing-fedora-35/?ref=news.itsfoss.com). ## Wrapping Up While this release doesn’t bring as many ground-breaking improvements as Fedora 34, I think users will be more than satisfied with it. Between Gnome 41 and Linux 5.14, users should notice a nice improvement to their systems. If you want to try Fedora 35 out for yourself, feel free to download it from the button below. *What do you think about the changes introduced in Fedora 35? Let me know in the comment below!* ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,950
一个深色模式的简单 CSS 技巧
https://opensource.com/article/21/10/dark-themes-websites
2021-11-04T10:12:09
[ "深色模式", "CSS" ]
/article-13950-1.html
> > 让你的网站根据用户选择的主题进行调整的能力是一个很棒的辅助功能。 > > > ![](/data/attachment/album/202111/04/101203a19wb2ptlcmwmmnl.jpg "Text editor on a browser, in blue") 你可能已经熟悉<ruby> 媒体查询 <rt> media query </rt></ruby>了。它们被广泛地用于使网站具有响应性。`width` 和 `height` 属性包含视区的尺寸。然后,你可以使用 CSS 在不同的尺寸下呈现不同的布局。 [prefers-color-scheme 媒体查询](https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme) 的工作方式与此相同。用户可以将他们的操作系统配置为使用浅色或深色主题。`prefers-color-scheme` 包含这个值。该值是 `light` 或 `dark` ,尽管 W3C 规范指出它可能支持未来的值,如 `sepia`。我为这两种模式指定不同的 CSS 变量值,让用户的操作系统来决定。 ### prefers-color-scheme 媒体查询 `prefers-color-scheme` 媒体查询的两种变化是: ``` /* Light mode */ @media (prefers-color-scheme: light) { :root { --body-bg: #FFFFFF; --body-color: #000000; } } /* Dark mode */ @media (prefers-color-scheme: dark) { :root { --body-bg: #000000; --body-color: #FFFFFF; } } ``` 在上面的 CSS 中,`--body-bg` 和 `--body-color` 是 [CSS 变量](https://www.w3.org/TR/css-variables-1/)。正如你所看到的,它们对两种模式都包含不同的值。在浅色主题中,我设置了一个白色背景和黑色文本。在深色主题中,我设置了黑色背景和白色文本。 因为[规范](https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme)说 W3C 可能会引入未来的值,所以把这个 CSS 转换为默认值是有意义的。 ``` /* Light mode */ :root { --body-bg: #FFFFFF; --body-color: #000000; } /* Dark mode */ @media (prefers-color-scheme: dark) { :root { --body-bg: #000000; --body-color: #FFFFFF; } } ``` 在上面的代码中,我默认定义了一个浅色主题,如果媒体查询是 `dark`,则将其转换为深色主题。这样一来,以后任何添加到媒体查询的值都会默认设置为浅色主题。 ### 使用 CSS 变量 现在我为不同的主题设置了不同的值,我需要实际使用它们来设计页面。 ``` body { background: var(--body-bg); color: var(--body-color); } ``` [var() 语法](https://www.w3.org/TR/css-variables-1/) 是 CSS 使用变量的方式。在上面的代码中,我是说把 `background` 设置为 `--body-bg` 的值,把 `color` 设置为 `--body-color` 的值。注意,这些变量的值来自媒体查询。这意味着背景和前景的颜色是根据操作系统的设置而改变的! 这就是媒体查询的真正能力。提供一个从操作系统到网页的一致的用户体验。 如果你进入 [findmymastodon.com](https://findmymastodon.com/),并切换你的操作系统的主题,你会看到从一个主题到另一个主题的过渡。 [CSS 工作组](https://drafts.csswg.org/mediaqueries-5/#prefers-color-scheme) 网站也使用同样的媒体查询。改变你的操作系统主题,网站就会切换主题来进行调整。 ### 结论 请注意,使用 `prefers-color-scheme` 与使用普通的编程语言没有什么不同。我定义了一些变量,这些变量的值根据一些逻辑而改变。而这些变量然后被用于进一步的操作。 让你的网站根据用户选择的主题进行调整的能力是一个很棒的辅助功能。而且,为了用户的利益,它进一步模糊了桌面和网络之间的界限。最新的浏览器版本 [支持 prefers-color-scheme](https://caniuse.com/prefers-color-scheme),所以你今天就可以开始实验了。 编码愉快。 这篇文章最初发表在 [作者的网站](https://ayushsharma.in/2021/10/creating-light-and-dark-themes-for-websites-correctly-using-prefers-color-scheme) 上,经许可后重新发表。 --- via: <https://opensource.com/article/21/10/dark-themes-websites> 作者:[Ayush Sharma](https://opensource.com/users/ayushsharma) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
13,953
构建基础包的基础知识
https://itsfoss.com/build-essential-ubuntu/
2021-11-05T11:32:50
[ "构建", "编译" ]
https://linux.cn/article-13953-1.html
![](/data/attachment/album/202111/05/113250t7q20dqqzdgges05.png) > > 这是一篇快速提示,旨在给 Ubuntu 的新用户解释构建基础包是什么、它的用处和安装步骤。 > > > 在 Ubuntu 中安装构建基础包(`build-essential`),只需要在终端中简单输入这个命令: ``` sudo apt update && sudo apt install build-essential ``` 但围绕它有几个问题,你可能想知道答案: * 什么是构建基础包? * 它包含什么内容? * 为什么要安装它(如果安装的话)? * 如何安装它? * 如何删除它? ### 什么是 Ubuntu 中的构建基础包? 构建基础包(`build-essential`)实际上是属于 Debian 的。在它里面其实并不是一个软件。它包含了创建一个 Debian 包(`.deb`)所需的软件包列表。这些软件包包括 `libc`、`gcc`、`g++`、`make`、`dpkg-dev` 等。构建基础包包含这些所需的软件包作为依赖,所以当你安装它时,你只需一个命令就能安装所有这些软件包。 请不要认为构建基础包是一个可以在一个命令中神奇地安装从 Ruby 到 Go 的所有开发工具的超级软件包。它包含一些开发工具,但不是全部。 #### 你为什么要安装构建基础包? 它用来从应用的源代码创建 DEB 包。一个普通用户不会每天都去创建 DEB 包,对吗? 然而,有些用户可能会使用他们的 Ubuntu Linux 系统进行软件开发。如果你想 [在 Ubuntu 中运行 c 程序](https://itsfoss.com/run-c-program-linux/),你需要 gcc 编译器。如果你想 [在 Ubuntu 中运行 C++ 程序](https://itsfoss.com/c-plus-plus-ubuntu/),你需要 g++ 编译器。如果你要使用一个不寻常的、只能从源代码中获得的软件,你的系统会抛出 “[make 命令未找到的错误](https://itsfoss.com/make-command-not-found-ubuntu/)”,因为你需要先安装 `make` 工具。 当然,所有这些都可以单独安装。然而,利用构建基础包的优势,一次性安装所有这些开发工具要容易得多。这就是你得到的好处。 这就像 [ubuntu-restricted-extras 包允许你一次安装几个媒体编解码器](https://itsfoss.com/install-media-codecs-ubuntu/)。 现在你知道了这个包的好处,让我们看看如何安装它。 ### 在 Ubuntu Linux 中安装构建基础包 在 Ubuntu 中按 `Ctrl+Alt+T` 快捷键打开终端,输入以下命令: ``` sudo apt update ``` 使用 `sudo` 命令,你会被要求输入你的账户密码。当你输入时,屏幕上没有任何显示。这没问题。这在大多数 Linux 系统中都是这样的。盲打输入你的密码,然后按回车键。 ![](/data/attachment/album/202111/05/113252lrl36w1z6p1zowoz.png) `apt update` 命令刷新了本地软件包的缓存。这对于一个新安装的 Ubuntu 来说是必不可少的。 之后,运行下面的命令来安装构建基础包: ``` sudo apt install build-essential ``` 它应该显示所有要安装的软件包。当要求确认时按 `Y`: ![](/data/attachment/album/202111/05/113253nnns3nwvpvp3wy03.png) 等待安装完成。就好了。 ### 从 Ubuntu 中删除构建基础包 保留这些开发工具不会损害你的系统。但如果你的磁盘空间不足,你可以考虑删除它。 在 Ubuntu 中,由于有 `apt remove` 命令,删除软件很容易: ``` sudo apt remove build-essential ``` 运行 `autoremove` 命令来删除剩余的依赖包也是一个好主意: ``` sudo apt autoremove ``` 你现在知道了所有关于构建基础包的基础(双关语)。请享受它吧~ --- via: <https://itsfoss.com/build-essential-ubuntu/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Installing build-essential package in Ubuntu is as simple as typing this command in the terminal: `sudo apt update && sudo apt install build-essential` But there are several questions around it that you may want answers to: - What is build essential package? - What does it contain? - Why should you install it (if install at all)? - How to install it? - How to remove it? ## What is build-essential package in Ubuntu? The build-essential package actually belongs to Debian. It is not a piece of software in itself. It contains a list of packages that are required to create a Debian package (deb). These packages are libc, gcc, g++, make, dpkg-dev etc. The build-essential package contains those required packages as dependencies, so when you install build-essential, you install all those packages in one single command. Please do NOT consider build-essential to be a super package that will magically install all kind of development tools from Ruby to Go for you in a single command. It has some development tool but not all. ### Why would you want to install build-essential package? It is used for creating DEB packages from the source code of an application. An average user does not go around creating DEB packages everyday, right? However, some users may use their Ubuntu Linux system for software development. You want to [run c program in Ubuntu](https://itsfoss.com/run-c-program-linux/), you need gcc compiler. You want to [run C++ programs in Ubuntu](https://itsfoss.com/c-plus-plus-ubuntu/), you need g++ compiler. If you have to use an unusual software that is only available from the source code, your system will throw [make command not found error](https://itsfoss.com/make-command-not-found-ubuntu/) because you need to install make tool first. All this can be installed individually, of course. However, it is much easier to take advantage of the build-essential package and install all these development tools at once. That’s the benefit you get. It is like the [ubuntu-restricted-extras package that allows you to install several media codecs](https://itsfoss.com/install-media-codecs-ubuntu/) at once. Now that you know the advantage of this package, let’s see how to install it. ## Installing build-essential package in Ubuntu Linux ![build essential ubuntu](https://itsfoss.com/content/images/wordpress/2021/10/Build-Essential-Ubuntu.png) Open a terminal in Ubuntu by pressing the Ctrl+Alt+T shortcut and enter the following command: `sudo apt update` With sudo command, you’ll be asked to enter your account’s password. When you type it, nothing is displayed on the screen. That is fine. That’s how it works in most Linux systems. Type your password blindly and press enter. ![apt update](https://itsfoss.com/content/images/wordpress/2021/10/apt-update-800x467.png) The apt update command refreshes the local package cache. This is essential for a fresh Ubuntu install. After that, run the following command to install build-essential tool: `sudo apt install build-essential` It should show all the packages it is going to install. Press Y when asked for confirmation: ![install build essential ubuntu](https://itsfoss.com/content/images/wordpress/2021/10/install-build-essential-ubuntu-800x434.png) Wait a bit for the installation to complete. That’s it. ## Removing build-essential tool from Ubuntu Keeping those development tools won’t harm your system. but if you are running low on the disk space, you may consider removing it. Removing software is easy in Ubuntu thanks to the apt remove command: `sudo apt remove build-essential` It will be a good idea to run the autoremove command to remove the residual dependency packages as well: `sudo apt autoremove` You know all the essential about build-essential package now (pun intended). Enjoy it :)
13,954
如何在 Ubuntu Linux 中正确地设置 JAVA_HOME 变量
https://itsfoss.com/set-java-home-ubuntu/
2021-11-05T12:20:28
[ "JAVA_HOME", "Java" ]
https://linux.cn/article-13954-1.html
![](/data/attachment/album/202111/05/122020qr5pys4p851sf1zs.jpg) 如果你 [在 Ubuntu 上运行 Java 程序](https://itsfoss.com/run-java-program-ubuntu/) ,使用 Eclipse、[Maven](https://maven.apache.org/) 或 Netbeans 等等,你将需要将 `JAVA_HOME` 环境变量设置为正确的路径。否则,你的系统将会向你控诉 “java\_home 环境变量没有设置”。 在这篇初学者教程中,我将向你展示在 Ubuntu 上正确地设置 `JAVA_HOME` 变量的步骤。这些步骤应该也适用于大多数的其它的 Linux 发行版。 设置过程包含这些步骤: * 确保已安装 Java 开发工具包(JDK)。 * 查找 JDK 可执行文件的正确的位置。 * 设置 `JAVA_HOME` 环境变量,并永久更改它。 ### 步骤 1: 核查 JDK 是否已经安装 核查 Java 开发工具包(JDK)是否已经安装在你的 Linux 系统上的最简单的方法是运行这个命令: ``` javac --version ``` 上面的命令将核查 Java 编译器的版本。如果已经安装了 Java 编译器,它将显示 Java 版本: ![Java Compiler is installed](/data/attachment/album/202111/05/122030h1rrrrgu1e1iwwyu.png) 如果上面的命令显示像这样未找到 `javac` 命令的错误信息,你得先安装 JDK : ![Java Compiler is not installed](/data/attachment/album/202111/05/122032eml7apli9zfh0sbh.png) 如果在你的系统上并没有安装 Java 编译器,使用这条命令来安装 Java 开发工具包 (JDK): ``` sudo apt install default-jdk ``` 这将在你当前的 Ubuntu 版本中安装默认的 Java 版本。如果你需要一些其它版本的 Java 版本,那么你必须 [在 Ubuntu 中安装 Java 时](https://itsfoss.com/install-java-ubuntu/) 具体指出它的版本。 在你确保 Java 编译器存在于你的系统之中后,接下来就到了查找其位置的时候了。 ### 步骤 2: 获取 JDK 可执行文件(Java 编译器)的位置 可执行文件通常位于 `/usr/lib/jvm` 目录之中。但我不会让你来玩一个猜谜游戏,让我们来找出 Java 可执行文件的路径。 [使用 which 命令](https://linuxhandbook.com/which-command/) 来获取 Java 编译器可执行文件的位置: ``` which javac ``` 在这里的问题是,它给出的位置实际上是一个 [符号链接](https://linuxhandbook.com/symbolic-link-linux/) 。你将需要按照下图执行几次: ![](/data/attachment/album/202111/05/122033acijqffqnqdz70j8.png) 最简单的方法是直接使用下面这条命令跟随符号链接来以获取实际的可执行文件: ``` readlink -f `which java` ``` `readlink` 命令会跟随一个符号链接。我在 `which java` 的外侧使用 `readlink` 将会使用 `which java` 的输出来替换要检查的符号链接,这被称之为命令替换。因此,在这个实例中,上面的命令大体上相当于 `readlink -f /usr/bin/java` 。 在我的示例中,可执行文件的位置是 `/usr/lib/jvm/java-11-openjdk-amd64/bin/java` 。对你来说可能会不一样。在你的系统中,复制上述命令所获取的正确的路径。你知道,你可以 [在 Ubuntu 的终端中复制和粘贴](https://itsfoss.com/copy-paste-linux-terminal/) 。 ### 步骤 3: 设置 JAVA\_HOME 变量 现在,你已经获取了位置,使用它来设置 `JAVA_HOME` 环境变量: ``` export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin/java ``` 核查 `JAVA_HOME` 目录的值: ``` echo $JAVA_HOME ``` ![](/data/attachment/album/202111/05/122035biq3fdoffdafzo6r.png) 尝试在同一个终端中运行你的 Java 程序或工程,并查看它是否工作。 这尚未结束。你刚刚声明的 `JAVA_HOME` 环境变量是临时的。如果你关闭这个终端或开始一个新的会话,它将会再次变成空的。 为了“永久地”设置 `JAVA_HOME` 变量,你应该将其添加到你的家目录中的 `.bashrc` 文件中。 你可以 [在 Linux 终端中使用 Nano 编辑器来编辑文件](https://itsfoss.com/nano-editor-guide/)。 如果你不想使用它,并想采取一种简单的复制和粘贴的方法,使用下面的命令: 首先备份你的 `.bashrc` 文件(以防万一你把它弄坏了,你还可以将其再恢复回来): ``` cp ~/.bashrc ~/.bashrc.bak ``` 接下来,[使用 echo 命令来追加](https://linuxhandbook.com/echo-command/) 在这一节开头使用的 `export` 命令。**你应该适当地更改下面的命令,以便其正确地使用你的系统所显示的路径**。 ``` echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin/java" >> ~/.bashrc ``` 验证它已经被正确地添加到文件的结尾处: ``` tail -3 ~/.bashrc ``` 上面的 [tail 命令](https://linuxhandbook.com/tail-command/) 将显示所具体指定文件的最后 3 行。 这里是上面的三个命令的全部的输出: ![](/data/attachment/album/202111/05/122036bfook1kj4zkj6848.png) 现在,即使你退出会话或重新启动系统,`JAVA_HOME` 环境变量都仍将设置为你所具体指定的值。这就是你所想要的,对吧? 注意,如果你将来更改默认的 Java 版本,你将需要更改 `JAVA_HOME` 环境变量的值并将其指向正确的可执行文件的路径。 我希望这篇教程不仅会帮助你设置 `JAVA_HOME` 环境变量,也会教会你如何完成这项工作。 如果你仍然面临难题或者有一些疑问或建议,请在评论区告诉我。 --- via: <https://itsfoss.com/set-java-home-ubuntu/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[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/) 荣誉推出
200
OK
If you are [running Java programs on Ubuntu](https://itsfoss.com/run-java-program-ubuntu/) using Eclipse, [Maven](https://maven.apache.org/) or Netbeans etc, you’ll need to set JAVA_HOME to your path. Otherwise, your system will complain that “java_home environment variable is not set”. In this beginner’s tutorial, I’ll show the steps to correctly set Java Home variable on Ubuntu. The steps should be valid for most other Linux distributions as well. The process consists of these steps: - Making sure Java Development Kit (JDK) is installed. - Finding the correct location of JDK executable. - Setting the JAVA_HOME variable and making the change permanent. ## Step 1: Check if JDK is installed The simplest way to check if Java Development Kit (JDK) is installed on your Linux system is by running this command: `javac --version` The above command checks the version of Java compiler. If it is installed, it will show the Java version. ![check java compiler ubuntu](https://itsfoss.com/content/images/wordpress/2021/09/check-java-compiler-ubuntu.png) If the command shows an error like javac command not found, you’ll have to install JDK. ![java compiler check ubuntu](https://itsfoss.com/content/images/wordpress/2021/09/java-compiler-check-ubuntu-800x328.png) If Java Compiler is not installed on your system, install Java Development Kit using this command: `sudo apt install default-jdk` This will install the default Java version in your current Ubuntu version. If you need some other specific Java version, you’ll have to specify it while [installing Java on Ubuntu](https://itsfoss.com/install-java-ubuntu/). Once you have made sure that Java Compiler is present on your system, it’s time to find its location. ## Step 2: Get the location of JDK executable (Java Compiler) The executable is usually located in the /usr/lib/jvm directory. I won’t left you on your own for a guessing game. Instead, let’s find out the path of the Java executable. [Use the which command](https://linuxhandbook.com/which-command/) to get the location of Java Compiler executable: `which javac` The problem here is that the location it gives is actually a [symbolic link](https://linuxhandbook.com/symbolic-link-linux/). You’ll have to follow it a couple of times: ![get java home path ubuntu](https://itsfoss.com/content/images/wordpress/2021/09/get-java-home-path-ubuntu-800x283.png) And when you find a path like /usr/lib/jvm/java-11-openjdk-amd64/bin/javac, you **remove the /bin/javac** from it to get something like **/usr/lib/jvm/java-11-openjdk-amd64** An easier method is to follow the symbolic link and get to the actual executable file directly using this command: `readlink -f `which javac` | sed "s:/bin/javac::"` The readlink command follows a symbolic link. I have used ` around *which java*. This is called command substitution and it replaces the command with its output. Sed is then used to replace /bin/javac by nothing and thus removing it altogether. In my example, the location of the executable file is **/usr/lib/jvm/java-11-openjdk-amd64**. It could be different for you. Copy the correct path you got from the above command in your system. You know, you can [copy paste in the Ubuntu terminal](https://itsfoss.com/copy-paste-linux-terminal/). ## Step 3: Setting JAVA_HOME variable Now that you have got the location, use it to set the JAVA_HOME environment variable: `export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/bin/java` Check the value of JAVA_HOME directory: `echo $JAVA_HOME` ![set java home ubuntu linux](https://itsfoss.com/content/images/wordpress/2021/09/set-java-home-ubuntu-linux-800x259.png) Try to run your program or project in the SAME TERMINAL and see if it works. This is not over yet. The JAVA_HOME variable you just declared is temporary. If you close the terminal or start a new session, it will be empty again. To set JAVA_HOME variable ‘permanently’, you should add it to the bashrc file in your home directory. You can [use the Nano editor for editing files in the Linux terminal](https://itsfoss.com/nano-editor-guide/). If you do not want that and take a simple copy-paste approach, use the following commands: Back up your bashrc file (in case you mess it, you can get it back): `cp ~/.bashrc ~/.bashrc.bak` Next, [use the echo command to append](https://linuxhandbook.com/echo-command/) the export command you used at the beginning of this section. ** Change the command below to use the correct path as displayed by your system in**. `echo "export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64" >> ~/.bashrc` Verify that it has been correctly added to the end of the file: `tail -3 ~/.bashrc` The above [tail command](https://linuxhandbook.com/tail-command/) will show the last 3 lines of the specified file. Here’s the entire output of the above three commands. ![setting java home bashrc](https://itsfoss.com/content/images/wordpress/2021/09/setting-java-home-bashrc-800x280.png) Now, even if you exit the session or restart the system, the JAVA_HOME variable will still be set to the value you specified. That’s what you want, right? Do note that if you change the default Java version in the future, you’ll have to change the value of JAVA_HOME and point it to the correct executable path. I hope this tutorial not only helped you to set Java Home, it also taught you how you are doing it. If you are still facing issues or have any questions or suggestions, please let me know in the comments.
13,956
多达 5 万美元,谷歌将奖励利用 Linux 内核提权的安全专家
https://news.itsfoss.com/google-linux-kernel-bounty/
2021-11-06T17:02:03
[ "谷歌", "安全" ]
https://linux.cn/article-13956-1.html
> > 成功利用内核漏洞以实现提权的安全研究人员将获得 31,337 美元至 50,337 美元的奖金。 > > > ![](/data/attachment/album/202111/06/170203tai0bxn0f6d4xvtv.jpg) 谷歌的平台大量使用了 Linux,尤其是在安卓及其庞大的服务器方面。多年来,谷歌一直青睐开源项目和计划。 最近,这家科技巨头赞助了 100 万美元,用于资助 Linux 基金会开展的一个以安全为重点的开源项目,更多细节参见我们 [原来的报道](https://news.itsfoss.com/google-sos-sponsor/)。 而现在,谷歌将在未来三个月内将赏金奖励增加两倍,以奖励那些致力于寻找有助于实现提权(即,当攻击者利用一个错误/缺陷获得管理员权限)的内核漏洞的安全研究人员。 毫无疑问,总会有某种形式的错误和缺陷困扰着内核的安全和开发。幸运的是,来自各个组织和个人的数百名安全研究人员致力于改善其安全状态,这就是为什么这些漏洞不一定会在野外被利用。 谷歌在奖励安全研究人员方面有着良好的记录,但它在接下来的三个月里加大了力度,宣布了 \*\*31,377 美元的基本奖励,最高可达 50,377 美元。 ### 计划细节和奖励 这些漏洞利用可以针对目前已修补的漏洞和未修补的新漏洞,以及采用新的技术。 **31,337 美元** 的基本奖励用于利用已公开了补丁的漏洞进行提权的技术。如果发现未修补的漏洞或新的利用技术,奖励可高达 **50,337 美元**。 此外,该计划还可以与 Android VRP 和“补丁奖励”计划一起使用。这意味着,如果该漏洞在安卓系统上发挥作用,除了这个计划之外,你还可以获得高达 25 万美元的奖励。 如果你希望了解更多关于安卓系统的信息,你可以在他们的 [官方门户网站](https://bughunters.google.com/about/rules/6171833274204160) 上了解。 增加的奖励将在未来三个月内开放,也就是说,直到 2022 年 1 月 31 日。 安全研究人员可以通过他们的 [官方博文](https://security.googleblog.com/2021/11/trick-treat-paying-leets-and-sweets-for.html) 来设置实验室环境,并在他们的 [GitHub 官方网页](https://google.github.io/kctf/vrp) 上阅读更多关于要求的内容。 ### 总结 这项计划是谷歌的一项出色的举措。毫无疑问,它将吸引并惠及许多安全专家和研究人员。 不要忘记,Linux 内核的安全状况将最终受益。 --- via: <https://news.itsfoss.com/google-linux-kernel-bounty/> 作者:[Rishabh Moharir](https://news.itsfoss.com/author/rishabh/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Google makes good use of Linux across its platforms, especially when it comes to Android and its massive servers. Over the years, Google has been inclining more towards open-source projects and programs. Recently, the tech giant sponsored $1 million to fund a security-focused open-source program run by The Linux Foundation, more details in our [original coverage. ](https://news.itsfoss.com/google-sos-sponsor/) And, now, Google just tripled its bounty rewards for the next three months for security researchers working on finding kernel exploits that help achieve privilege escalation (i.e., when an attacker gains administrator access using a bug/flaw) It’s no surprise that there will always be some form of bugs and flaws that plague the security and development of the kernel. Fortunately, hundreds of security researchers from various organizations and individuals-alike work to improve its state of security, which is why the vulnerabilities are not necessarily exploited in the wild. Even though Google has a good track record of rewarding security researchers, it stepped up the game for the next three months by announcing a base reward of **$30,377 to $50,377** as the upper limit. ## Program Details and Rewards The exploits can be responding to currently patched vulnerabilities, new unpatched vulnerabilities, and new techniques. The base reward of **$31,337** holds for exploiting publicly patched vulnerabilities that exploit privilege escalation. If it identifies unpatched vulnerabilities or new exploit techniques, the reward can go up to **$50,337**. Moreover, this program also goes along with the Android VRP and Patch Reward programs. This means if the exploit works on Android, you can be eligible for rewards up to 250,000 USD in addition to this program. You can read more about this on their [official portal](https://bughunters.google.com/about/rules/6171833274204160?ref=news.itsfoss.com) if you are curious about Android. The hike in reward will be open for the next three months, that is, until January 31, 2022. Security researchers can go through their [official blog post](https://security.googleblog.com/2021/11/trick-treat-paying-leets-and-sweets-for.html?ref=news.itsfoss.com) to set up the lab environment and read more about the requirements on their [official GitHub webpage.](https://google.github.io/kctf/vrp?ref=news.itsfoss.com) ## Wrapping Up This program is an excellent initiative by Google. It is undoubtedly going to attract and benefit many security professionals and researchers alike. Not to forget, the state of security for Linux Kernel should get the ultimate benefit. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,957
如何动态生成 Jekyll 配置文件
https://opensource.com/article/21/11/jekyll-config-files
2021-11-06T17:27:29
[ "Jekyll" ]
https://linux.cn/article-13957-1.html
> > 使用 Python 或 Bash 将动态数据插入 Jekyll 静态网站中,并且避免创建一个 API 后端。 > > > ![](/data/attachment/album/202111/06/172709dqcv65spvl363fav.jpg "Digital creative of a browser on the internet") 静态网站生成器 [Jekyll](https://opensource.com/article/21/9/build-website-jekyll) 使用 `_config.yml` 进行配置。这些配置都是 Jekyll 特有的。但你也可以在这些文件中 [用我们自己的内容定义变量](https://ayushsharma.in/2021/08/using-variables-in-jekyll-to-define-custom-content),并在整个网站中使用它们。在本文中,我将重点介绍动态创建 Jekyll 配置文件的一些优势。 在我的本地笔记本电脑上,我使用以下命令来服务我的 Jekyll 网站进行测试: ``` bundle exec jekyll serve --incremental --config _config.yml ``` ### 结合多个配置文件 在本地测试中,有时需要覆盖配置选项。我的网站的 [当前 \_config.yml](https://gitlab.com/ayush-sharma/ayushsharma-in/-/blob/2.0/_config.yml) 有以下设置: ``` # Jekyll Configuration # Site Settings url: "https://notes.ayushsharma.in" website_url: "https://notes.ayushsharma.in/" title: ayush sharma's notes ☕ + ? + ?️ email: [email protected] images-path: /static/images/ videos-path: /static/videos/ js-path: /static/js/ baseurl: "" # the subpath of your site, e.g. /blog ``` 由于本地的 `jekyll serve` URL 是 `http://localhost:4000`,上面定义的 URL 就不能用了。我可以创建一个 `_config.yml` 的副本 `_config-local.yml` 并替换所有的值。但还有一个更简单的选择。 Jekyll 允许[指定多个配置文件](https://jekyllrb.com/docs/configuration/options/#build-command-options),后面的声明覆盖前面的声明。这意味着我可以用以下代码定义一个新的 `_config-local.yml`: ``` url:"" ``` 然后我可以把上述文件和我的主 `_config.yml` 结合起来,像这样: ``` bundle exec jekyll serve --incremental --config _config.yml,_config-local.yml ``` 通过合并这两个文件,这个 `jekyll serve` 的 `url` 的最终值将是空白。这就把我网站中定义的所有 URL 变成了相对的 URL,并使它们在我的本地笔记本电脑上工作。 ### C结合动态配置文件 一个简单的例子,假设你想在你的网站上显示当前日期。它的 bash 命令是: ``` &gt; date '+%A, %d %B %Y' Saturday, 16 October 2021 ``` 我知道我也可以 [使用 Jekyll 的 \_config.yml 的自定义内容](https://ayushsharma.in/2021/08/using-variables-in-jekyll-to-define-custom-content)。我将上述日期输出到一个新的 Jekyll 配置文件中。 ``` my_date=`date '+%A, %d %B %Y'`; echo 'my_date: "'$my_date'"' > _config-data.yml ``` 现在 `_config-data.yml` 包含: ``` my_date: "Saturday, 16 October 2021" ``` 我可以把我的新配置文件和其他文件结合起来,在我的网站上使用 `my_date` 变量。 ``` bundle exec jekyll serve --incremental --config _config.yml,_config-local.yml,_config-data.yml ``` 在运行上述命令时,`{{ site.my_date }}` 输出其配置的值。 ### 结论 上面的例子很简单,但可能性是无穷的。Bash、Python 和其他编程语言可以动态地生成 Jekyll 配置文件。然后我可以在 `build` 或 `serve` 过程中结合这些文件。 对于 [findmymastodon.com](https://findmymastodon.com/),[我使用 Python 来获取 Mastodon 的用户统计数据](https://gitlab.com/ayush-sharma/find-my-mastodon/-/blob/1.0/src/fetch-instance-data/fetch_data.py#L252)。然后我把这些写进一个新的 [\_config-data.yml 文件](https://gitlab.com/ayush-sharma/find-my-mastodon/-/blob/1.0/_config-data.yml)(目前是手动)。最后,[主页和其他页面从配置文件中显示这些](https://gitlab.com/ayush-sharma/find-my-mastodon/-/blob/1.0/index.md#L16)。这样,我就可以利用一个动态的后台,并且仍然保持我所喜欢的所有静态网站的优点。 我希望这能为你自己的静态网站激发一些想法。Jamstack 对于静态网站是很好的,但你可以避免为动态内容创建整个 API 后台。为什么不使用一个构建作业来创建带有更新内容的配置文件呢?这可能不适合每一种情况,但少一个 API 意味着更少的基础设施移动部件。 我希望这能在你的下一个静态网站项目中给你一些帮助。继续阅读,并祝你编码愉快。 这篇文章最初发布在 [作者的网站](https://ayushsharma.in/2021/10/inserting-dynamic-data-into-jekyll-static-sites-using-python-or-bash) 上,并经授权转载。 --- via: <https://opensource.com/article/21/11/jekyll-config-files> 作者:[Ayush Sharma](https://opensource.com/users/ayushsharma) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
[Jekyll](https://opensource.com/article/21/9/build-website-jekyll), the static site generator, uses the `_config.yml` for configuration. The configurations are all Jekyll-specific. But you can also [define variables with our own content](https://ayushsharma.in/2021/08/using-variables-in-jekyll-to-define-custom-content) in these files and use them throughout your website. In this article, I'll highlight some advantages of dynamically creating Jekyll config files. On my local laptop, I use the following command to serve my Jekyll website for testing: `bundle exec jekyll serve --incremental --config _config.yml` ## Combining many configuration files During local testing, it's sometimes necessary to override configuration options. My website's [current _config.yml](https://gitlab.com/ayush-sharma/ayushsharma-in/-/blob/2.0/_config.yml) has the following settings: ``` # Jekyll Configuration # Site Settings url: "https://notes.ayushsharma.in" website_url: "https://notes.ayushsharma.in/" title: ayush sharma's notes ☕ + ? + ?️ email: [email protected] images-path: /static/images/ videos-path: /static/videos/ js-path: /static/js/ baseurl: "" # the subpath of your site, e.g. /blog ``` Since the local `jekyll serve` URL is http : //localhost:4000, the URL defined above won’t work. I can always create a copy of `_config.yml` as `_config-local.yml` and replace all the values. But there is an easier option. Jekyll allows [specifying many configuration files](https://jekyllrb.com/docs/configuration/options/#build-command-options) with later declarations overriding previous ones. This means I can define a new `_config-local.yml` with the following code: `url:""` Then I can combine the above file with my main `_config.yml` like this: `bundle exec jekyll serve --incremental --config _config.yml,_config-local.yml` By combining both files, the final value of `url` for this `jekyll serve` will be blank. This turns all URLs defined in my website into relative URLs and makes them work on my local laptop. ## Combining dynamic config files As a simple example, suppose you want to display the current date on your website. The bash command for this is: ``` > date '+%A, %d %B %Y' Saturday, 16 October 2021 ``` I know I can [use Jekyll's _config.yml's for custom content](https://ayushsharma.in/2021/08/using-variables-in-jekyll-to-define-custom-content) as well. I'll output the above date into a new Jekyll config file. `my_date=`date '+%A, %d %B %Y'`; echo 'my_date: "'$my_date'"' > _config-data.yml` Now `_config-data.yml` contains: `my_date: "Saturday, 16 October 2021"` I can combine my new config file with the others and use the `my_date` variable on my website. `bundle exec jekyll serve --incremental --config _config.yml,_config-local.yml,_config-data.yml` On running the above command, `{{ site.my_date }}` outputs its configured value. ## Conclusion The example above is quite simple, but the possibilities are endless. Bash, Python, and other programming languages can dynamically generate Jekyll config files. I can then combine these during the `build` or `serve` process. For [findmymastodon.com](https://findmymastodon.com/), [I'm using Python to fetch Mastodon user statistics](https://gitlab.com/ayush-sharma/find-my-mastodon/-/blob/1.0/src/fetch-instance-data/fetch_data.py#L252). I'm then writing these into a new [_config-data.yml file](https://gitlab.com/ayush-sharma/find-my-mastodon/-/blob/1.0/_config-data.yml) (currently manually). Finally, the [home page and others display these from the configuration file](https://gitlab.com/ayush-sharma/find-my-mastodon/-/blob/1.0/index.md#L16). This way, I can leverage a dynamic backend and still keep all the static website goodness I'm so fond of. I hope this has sparked some ideas for your own static websites. Jamstack is great for static websites, but you can avoid creating an entire API backend for dynamic content. Why not instead use a build job to create config files with updated content? It might not suit every use case, but one less API means fewer infrastructure moving parts. I hope this helps you in some way during your next static website project. Keep reading, and happy coding. *This article originally appeared on the author's website and is republished with permission.* ## Comments are closed.
13,960
从 FreeBSD 转到 Void Linux 后,Trident 项目终于结束了
https://news.itsfoss.com/project-trident-discontinues/
2021-11-07T16:27:00
[ "BSD", "Lumina", "Trident" ]
https://linux.cn/article-13960-1.html
> > Trident 项目为我们提供了与操作系统无关的 Lumina 桌面。 > > > ![](/data/attachment/album/202111/07/162742xrpinzp8r15trcns.png) 令人遗憾,[Trident 项目](https://project-trident.org/) 团队宣布将结束他们的 Linux 发行版的开发。 ### 那段故事 你或许没有听说过 Trident 项目,让我来讲点关于它的一点回忆。那是在 2005 年,Kris Moore 推出了 [PC-BSD](https://en.wikipedia.org/wiki/TrueOS),提供了一种用桌面界面来设置 FreeBSD 的简单方法。次年,它被 [iXsystems](http://ixsystems.com/) 收购。十年后,2016 年 9 月,这个项目被改名为 TrueOS。这个项目也变成了基于 FreeBSD Current 分支的滚动发行版。两年后,TrueOS [宣布](https://itsfoss.com/trueos-plan-change/) 他们将取消其操作系统的桌面版本,而专注于商业和服务器市场。其桌面元素被 [剥离](https://itsfoss.com/project-trident-interview/) 到一个新项目:Trident。 有一段时间,Trident 开发团队尽力在 FreeBSD 之上打造良好的桌面体验。可是,由于 [FreeBSD 的问题](https://project-trident.org/post/os_migration/),包括 “硬件兼容性、通信标准,或软件包的可用性一直限制着 Trident 项目的用户”,他们决定将其建立在其他基础之上。他们的解决方案是在 2019 年将其项目重新构建在 [Void Linux](https://voidlinux.org/) 之上。有那么一段时间,看起来 Trident 项目似乎有了未来。然后,2020 年来了。 ![Trident 桌面](/data/attachment/album/202111/07/162742wqiueexebuobuczu.png) ### 项目的终止 10 月 29 号,Trident 项目团队发布了以下 [公告](https://project-trident.org/post/2021-10-29_sunset/): > > 我们非常悲伤地宣布,Trident 项目将从 2021 年 11 月 1 号起进入“夕阳”阶段,并将于 2022 年 3 月关掉商店。项目的核心团队共同做出了这个决定。随着过去两年中,生活、工件和家庭等方面的事情和变故;我们个人的优先事项也发生了改变。 > > > 我们将保持 Trident 项目的软件包存储库和网站的运行,直到 2022 年 3 月 1 日的终止期,但是我们强烈推荐用户在即将到来的新年假期中开始寻找其他桌面系统替代。 > > > 感谢大家的支持和鼓励!过去几年中,该项目得以良好运转,我们也非常高兴在这些年里结识了你们中的许多人。 > > > ### Lumina 项目继续 贯穿 PC-BSD/TrueOS/Trident 项目传奇故事的一个永恒主题是桌面环境。2012 年,[Ken Moore](https://github.com/beanpole135)(Kris 的弟弟)开始开发一个基于 Qt 的桌面环境 [Lumina](https://lumina-desktop.org/)。2014 年,它成为 PC-BSD 的默认桌面环境,并一直保持到 Trident 项目出现。Lumina 不同于其他桌面环境,因为它的设计与操作系统无关。其他桌面系统像 KDE 和 GNOME 都具有 Linux 特定代码,这使得它们难以移植到 BSD。 ![Lumina 桌面环境](/data/attachment/album/202111/07/162743a5a0m3sr8bs5omk7.png) 今年 6 月,Ken 把 [Lumina 的领导权](https://lumina-desktop.org/post/2021-06-23/) 交给了 Trident 的开发者 [JT Pennington](https://github.com/q5sys)(也因 [BSDNow](https://www.bsdnow.tv/) 知名)。 [公告](https://lumina-desktop.org/post/2021-06-23/) 中说: > > 经过长达 7 年的工作,我决定是时候让其他人接手 Lumina 桌面项目的开发了。这是个难以置信的任务,推动我进入之前从未考虑过的开发领域。可是,由于工作和生活的变化,我几乎没有为 Lumina 开发新功能的时间了,特别是即将在明年或者晚些时候到来的 Qt5->Qt6 升级。通过把火炬传递给 JT (GitHub 昵称是 q5sys),我希望这个项目能获得更及时的更新,以造福每个人。 > > > 感谢大家,我希望 Lumina 桌面项目能继续成功!! > > > ### 总结 我一直对 Trident 项目抱有很高的期望。与我们介绍的许多发行版相比,它很小巧。它不是只增加了一两个新工具的、对 Arch 或 Ubuntu 的翻版。不仅如此,他们还努力改进一个与他们理念相同的发行版 Void Linux。可是,生活会发生变故,即使是我们中最好的人也难以避免遇到变故。我祝愿 Ken、JT 和其他人一切顺利,他们已经在这个项目上花费了很多时间。希望,我们未来能看到他们的更多作品。 --- via: <https://news.itsfoss.com/project-trident-discontinues/> 作者:[John Paul](https://news.itsfoss.com/author/john/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[zd200572](https://github.com/zd200572) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Sadly, the [Project Trident](https://project-trident.org/?ref=news.itsfoss.com) team announced that they will be ending development of their Linux distro. ## Story Time!!! For those of you who have not heard of Project Trident, let me give you a little ride down memory lane. Back in 2005, Kris Moore introduced [PC-BSD](https://en.wikipedia.org/wiki/TrueOS?ref=news.itsfoss.com) as an easy way to set up FreeBSD with a desktop interface. It was acquired the following year by [iXsystems](http://ixsystems.com/?ref=news.itsfoss.com). In September of 2016, the name of the project was changed to TrueOS. The project also became a rolling release based on the Current branch of FreeBSD. Two years later, TrueOS [announced](https://itsfoss.com/trueos-plan-change/?ref=news.itsfoss.com) that they would be doing away with the desktop version of their operating system and focusing on the enterprise and server market. The desktop elements [were spun off](https://itsfoss.com/project-trident-interview/?ref=news.itsfoss.com) to a new project: Project Trident. For a time, the dev team at Project Trident tried their best to create a good desktop experience on top of FreeBSD. However, due to [issues with FreeBSD](https://project-trident.org/post/os_migration/?ref=news.itsfoss.com) including “hardware compatibility, communications standards, or package availability continue to limit Project Trident users” they decide to base it on something else. Their solution was to rebase their project on [Void Linux](https://voidlinux.org/?ref=news.itsfoss.com) in 2019. For a while, it looked like the future of Project Trident was set. Then 2020 happened. ![Project Trident desktop](https://news.itsfoss.com/content/images/wordpress/2021/11/project-trident.png) ## The End of a Project On October 29th, the Project Trident team posted the following [announcement](https://project-trident.org/post/2021-10-29_sunset/?ref=news.itsfoss.com): It is with great sadness that we are announcing that Project Trident will be entering is “sunset” period starting Nov 1 of 2021 and will be closing up shop in March of 2022. The core team of the project has come to this decision together. With changes and events over the past two years in life, jobs, family, etc; our individual priorities have changed as well. We will keep the Project Trident package repository and websites up and running until the EOL date of March 1, 2022, but we strongly encourage users to begin looking for alternative desktop OS solutions over the coming new year holiday. Thank you all for your support and encouragement! The project had a good run and we thoroughly enjoyed getting to know many of you over the years. ## The Lumina Project Continues One constant throughout the PC-BSD/TrueOS/Project Trident saga is the desktop environment in use. In 2012, [Ken Moore](https://github.com/beanpole135?ref=news.itsfoss.com) (Kris’ younger brother) started working on a Qt-based desktop environment named [Lumina](https://lumina-desktop.org/?ref=news.itsfoss.com). In 2014, it became the default desktop environment of PC-BSD and has stayed that way down to Project Trident. Lumina stands apart from other desktop environment because it was designed to be operating system agnostic. Other desktop environments like KDE and GNOME have Linux specific code that makes it hard to port to BSD. ![Lumina desktop environment](https://news.itsfoss.com/content/images/wordpress/2021/11/lumina.png) June of this year, Ken [handed the reigns of Lumina](https://lumina-desktop.org/post/2021-06-23/?ref=news.itsfoss.com) to a fellow Project Trident developer [JT Pennington](https://github.com/q5sys?ref=news.itsfoss.com) (also of [BSDNow](https://www.bsdnow.tv/?ref=news.itsfoss.com) fame). The [announcement](https://lumina-desktop.org/post/2021-06-23/?ref=news.itsfoss.com) states: After more than 7 years of work, I have decided that it is time to let others take over the development of the Lumina Desktop project going forward. It has been an incredible task which has pushed me into areas of development that I had never previously considered. However, with work and life changes, my time for developing new functionality for Lumina has become nearly non-existent, particularly for the Qt5 -> Qt6 change that will be coming within the next year or so. By passing the torch over to JT (q5sys on GitHub), I am hoping that the project might receive more timely updates, for the benefit of everyone. Thank you all, and I hope for the continued success of the Lumina Desktop project!! ## Final Thoughts I always had high hopes for Project Trident. They were small compared to many of the distros that we cover. They weren’t just a reskin of Arch or Ubuntu with one or two new tools. Not only that, but they were working to improve a distro (Void) that shared their ideals. However, life happens, even to the best of us. I wish Ken, JT and the others well as they sunset a project that they have spent many hours working on. Hopefully, we’ll be seeing more from them in the future. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,961
只有 4MB?如何修复 Etcher 和 Rufus 创建 Linux USB 后“破坏”的 USB
https://itsfoss.com/format-live-linux-usb/
2021-11-07T16:56:21
[ "USB", "Live" ]
https://linux.cn/article-13961-1.html
![](/data/attachment/album/202111/07/165254zlhgz6an6vgpv2qd.jpg) 情况是这样的。你用 Etcher 或者 Rufus 工具在 Windows 或者 Linux 中创建了一个可启动的、Live Linux USB。 你用它来安装 Linux,USB 的目的已经达到了。现在你想格式化这个 USB,用它来进行常规的数据传输或存储。 你把它插入你的 Windows 系统,令你吃惊的是,这个 USB 的磁盘容量只有 4MB。 ![](/data/attachment/album/202111/07/165622zmsd1hzhhci1d7v1.jpg) 你试图格式化它,但它可能不会让你这么做。即使你设法格式化它,USB 的大小现在也从通常的 8GB、16GB 或 32GB 缩减到只有 4MB。 你失去了你的 USB 吗?并非如此。你的 USB 并没有完全被破坏。你仍然可以用一个小技巧来格式化它,并舒适地使用它。 让我告诉你如何在 Windows 和 Linux 中把可启动的 USB 恢复到可用的状态。 ### 格式化由 Rufus 或 Etcher 创建的 Live Linux USB (在 Windows 下) 你在 Windows 中看到只有 4MB 的磁盘空间。你知道为什么吗?因为在创建 Live Linux USB 时,该工具在 FAT32 文件系统中创建了一个 4MB 的 EFI 分区。其他的分区是在 Linux 的 Ext4 文件系统中,而这是不被 Windows 识别的。 这就是为什么你的 Windows 系统只看到 4MB 的 EFI 分区,并显示 USB 大小为 4MB。 ![Windows only see the EFI partition on the USB](/data/attachment/album/202111/07/165622g7933v93xo07pj7p.jpg) 总而言之,你需要做的是删除 USB 盘上的所有分区,用删除现有分区后得到的空闲空间创建一个新的 NTFS 或 FAT32 分区。这就行了。 让我展示一下详细的步骤。 #### 步骤 1: 进入 Windows 菜单,寻找“磁盘管理”工具。 ![Start disk management tool](/data/attachment/album/202111/07/165622a2k50tz3c0075c5y.jpg) 启动这个工具,它将显示你电脑上存在的所有磁盘。当然,这包括插入的 USB。 **选择正确的磁盘是非常重要的**。从 U 盘的大小或“可移动”的标签中辨别出它是哪一个。 ![](/data/attachment/album/202111/07/165623mi6f9gfgxgggf7ti.jpg) #### 步骤 2: 我们的想法是删除 U 盘上的任何现有分区。未分配的空间不能被删除,但这也没关系。 在该分区上点击右键,然后点击“<ruby> 删除卷 <rt> Delete Volume </rt></ruby>”。 ![Delete partitions on the USB disk](/data/attachment/album/202111/07/165623vwnel0jjaa18xdyv.jpg) 当要求你确认时,按“<ruby> 是 <rt> Yes </rt></ruby>”。 ![Confirm deletion of partition](/data/attachment/album/202111/07/165623r2fyws70zizseg81.jpg) 你的目标是只有一个未分配的空间块。当你看到它时,右击它并点击“<ruby> 新建简单卷…… <rt> New Simple Volume... </rt></ruby>”来创建一个分区。 ![Create New Simple Volume ](/data/attachment/album/202111/07/165624d7cbzlbjuv9ljgul.jpg) 接下来的步骤很简单。点击“<ruby> 下一步 <rt> Next &gt; </rt></ruby>”,选择整个可用空间,给它分配一个字母,选择文件系统(FAT32 或 NTFS),并将其格式化。 ![Click Next](/data/attachment/album/202111/07/165624gr1hg1rywrtu23cz.png) ![Use entire available space](/data/attachment/album/202111/07/165625lkyx55k3br4eek1k.png) ![Give it a drive letter](/data/attachment/album/202111/07/165625w18ut2svl3v2gzzv.png) ![Use FAT 32 or NTFS, Name the USB if you want](/data/attachment/album/202111/07/165626v29vu9xcn9u9v0te.png) ![Revise all the changes](/data/attachment/album/202111/07/165626n4gg32xx34ggepxi.png) 完成后,你会看到 USB 已经恢复到正常状态,你可以开始向它复制粘贴数据。 ![USB is back to normal state](/data/attachment/album/202111/07/165627wp48gu04ttt0dwdy.jpg) 你现在可以像以前一样使用你的 USB 了。 这些步骤是针对 Windows 的。如果你使用 Linux 呢? ### 在 Linux 上格式化 Live USB 我注意到,由 Etcher 和这类工具创建的 Live USB 经常拒绝被文件管理器中的右键格式化选项正确格式化。 除此之外,你可以像在 Windows 中那样做:删除现有的分区,用整个可用空间创建一个新的分区。 这里使用 GNOME “磁盘” 工具。它已经安装在 Ubuntu 和许多其他 Linux 发行版上。 ![Start disk app](/data/attachment/album/202111/07/165627x4k5dkr7ox0digc5.jpg) **同样,确保你在这里选择了外部 USB 盘。** 你会看到 U 盘上的各种分区。试着从上面的菜单中格式化该磁盘。 ![Format disk](/data/attachment/album/202111/07/165627izcrrumkbrcrw0w7.jpg) **如果这不起作用,逐个删除分区**,然后把整个 USB 作为自由空间。 当你创建了整个自由空间后,点击 “+” 号,在上面创建一个 NTFS 或 FAT32 文件系统的分区。 ![](/data/attachment/album/202111/07/165627li257zom2mcpmm17.jpg) 用 NTFS(或 FAT32)创建分区,给它起个合适的名字,然后你就可以像以前一样使用这个 USB 了。 ### 总结 像 Rufus 和 Etcher 这样的工具并没有真正破坏你的 USB。这就是它们的功能,通过在磁盘上创建一个不同的文件系统。但这样一来,Windows 操作系统就不能正确理解它。 好在只需付出一点努力就可以修复。我希望你也能够修复它。如果没有,请与我分享你的问题,我将尽力帮助你。 --- via: <https://itsfoss.com/format-live-linux-usb/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Here’s the scenario. You [used Etcher](https://itsfoss.com/install-etcher-linux/) or Rufus tools to create a bootable, live Linux USB in Windows or perhaps in Linux. You used it to install Linux and the purpose of the USB is accomplished. Now you want to format this USB and use it for regular data transfer or storage. You plug it in your Windows system and to your surprise, the disk capacity of the USB is just 4 MB. ![usb drive 4mb space only](https://itsfoss.com/content/images/wordpress/2021/10/usb-drive-4mb-space-only-800x324.webp) You try to format it and it probably won’t let you do that. Even if you manage to format it, the size of the USB is now shrunk to just 4 MB from the usual 8 GB, 16 GB or 32 GB. Have you lost your USB? Not really. Your USB is not completely destroyed. You can still format it with a little trick and use it comfortably. Let me show how to restore the bootable USB to a usable state in both Windows and Linux. ## Formatting the live Linux USB created by Rufus or Etcher [In Windows] You see only 4 MB of disk space in Windows. Do you know why? Because while creating the live Linux USB, the tool creates a 4 MB of EFI partition in FAT 32 filesystem. The other partition(s) is in Linux’s Ext4 filesystem which Windows do not recognize. This is why your Windows system only sees the EFI partition of 4 MB and shows the USB size as 4 MB. ![mystery behind 4 mb linux live usb](https://itsfoss.com/content/images/wordpress/2021/10/mystery-behind-4-mb-linux-live-usb-800x400.webp) All in all, what you need to do is to delete all the partition on the USB disk, create a new NTFS or FAT32 partition from the free space you got from deleting the existing partitions. That’s it. Let me show the steps in detail. ### Step 1: Go to the Windows menu and look for the Disk Management tool. ![Start disk management tool in Windows](https://itsfoss.com/content/images/wordpress/2021/10/start-disk-management-tool-windows-800x694.webp) Start this tool and it will show all the disks present on your computer. This includes the plugged-in USB, of course. **This is very important to select the correct disk**. Identify which one it is from the size of the USB disk or from the ‘Removable’ tag. ![identify usb disk in windows](https://itsfoss.com/content/images/wordpress/2021/10/identify-usb-disk-in-windows-800x509.webp) ### Step 2: The idea is to delete any existing partition present on the USB disk. The unallocated space cannot be deleted but that’s okay. Right click on the partition and click **Delete Volume**. ![delete partitions on usb disk](https://itsfoss.com/content/images/wordpress/2021/10/delete-partitions-on-usb-disk-800x464.webp) When asked for your confirmation, press Yes. ![confirm deletion of partition](https://itsfoss.com/content/images/wordpress/2021/10/confirm-deletion-of-partition-800x357.webp) Your aim is to have only a single block of unallocated space. When you see that, right click on it and click on “New Simple Volume” to create a partition. ![create new partition](https://itsfoss.com/content/images/wordpress/2021/10/Create-New-Partition-800x471.webp) The next steps are simple. Click on Next, select the entire available space, assign a letter to it, select the file system (FAT 32 or NTFS) and format it. ![creating new simple volume 1](https://itsfoss.com/content/images/wordpress/2021/10/creating-new-simple-volume-1.png) Once that is done, you’ll see that the USB has returned to normal state and you can start copy-pasting data to it. ![live linux usb formatted successfully](https://itsfoss.com/content/images/wordpress/2021/10/live-Linux-USB-formatted-successfully-800x571.webp) You can use your USB as before now. These steps were for Windows. What if you cannot [format the USB on Linux](https://itsfoss.com/format-usb-drive-sd-card-ubuntu/)? ## Formatting live Linux USB on Linux I have noticed that live USB created by Etcher and such tools often create refuse to be formatted properly by the right click format option in the file manager. As an alternative, you can do what you did in Windows: delete existing partitions and create a new partition with the entire free space. Use the GNOME Disks tool here. It is already installed on Ubuntu and many other Linux distributions. ![start disk app](https://itsfoss.com/content/images/wordpress/2021/10/start-disk-app.webp) *Again, make sure that you have selected the external USB disk here.* You’ll see various partitions on the USB disk. Try and format the disk from the menu above. ![format usb in disks tool](https://itsfoss.com/content/images/wordpress/2021/10/format-usb-in-disks-tool-800x434.webp) **If that does not work, delete the partitions individually** one by one and then make the entire USB as free space. When you have the entire free space created, click on the + sign to create a partition on it in NTFS or FAT32 filesystem. ![create partition on usb](https://itsfoss.com/content/images/wordpress/2021/10/create-partition-on-usb-800x418.webp) Create the partition with NTFS (or FAT 32), name it something appropriate and then you can enjoy the USB like it was before. ## Conclusion Tools like Rufus and Etcher don’t really destroy your USB. This is how they function, by creating a different filesystem on the disk. But then the operating system doesn’t understand it properly. The good thing is that it can be fixed with only a little effort. I hope you too were able to fix it. If not, share your issue with me and I’ll try to help.
13,963
Linux 内核的发布时间表是什么?它的支持时间是多久?
https://itsfoss.com/linux-kernel-release-support/
2021-11-08T10:47:01
[ "内核", "Linux" ]
https://linux.cn/article-13963-1.html
![](/data/attachment/album/202111/08/104610egbqhs8lbldgd6ad.png) Linux 内核很复杂。我说的甚至不是代码的问题。 Linux 内核的代码本身很复杂,但你不需要为这个问题而烦恼。我说的是 Linux 内核的发布时间表。 一年内多久发布一个新的内核版本?内核被支持多长时间?还有一些 LTS(长期支持)内核,LTS Linux 内核的支持时间有多长? 问题是,虽然这些问题看起来很简单,但答案却不简单。 这些问题没有一个直接明了的答案,需要做一些解释,这就是我在这篇文章中要做的。 ### Linux 内核发布时间表:有吗? ![](/data/attachment/album/202111/08/104701jnwsqvunkhskqbvl.jpg) 短的回答是,每两到三个月就有一个新的内核版本发布。长的回答是,这不是一个硬性规定。 这个意思是,你经常会看到每两到三个月就有一个新的内核版本发布。这是内核维护者团队的目标,但并没有规定新版本必须在前一个版本的 8 周后准时发布的期限。 新的内核版本(通常)是由 Linus Torvalds 在它准备好的时候发布的。通常是每 2 到 3 个月发布一次。该版本被宣布为“稳定”,一般以 X.Y 的格式编号。 但这并不是 X.Y 开发的结束。稳定版会有更多的小版本以进行错误的修复。这些小版本在稳定版的内核上又增加了一个点,就像是 X.Y.Z。 虽然 X.Y(通常)是由 Linux 创造者 Linus Torvalds 发布的,但是维护稳定的 X.Y 内核、合并错误修复和发布 X.Y.Z 版本的责任是由另外的内核开发者负责的。 ### 一个内核版本支持多长时间? ![](/data/attachment/album/202111/08/104702trkzqlvzidcv6di2.png) 和发布一样,一个内核版本支持多长时间也没有固定的日期和时间表。 一个普通的稳定内核版本通常会被支持两个半月到三个月,这取决于下一个稳定内核版本的发布时间。 例如,稳定版内核 5.14 会在稳定版内核 5.15 发布后的几周内达到 [生命末期](https://itsfoss.com/end-of-life-ubuntu/)。结束支持是由该稳定内核版本的维护者在 Linux 内核邮件列表中宣布的。用户和贡献者会被要求切换到新发布的稳定版本。 但这只适用于正常的稳定内核版本,还有 LTS(长期支持)内核版本,它们的支持期要比 3 个月长得多。 ### LTS 内核:它支持多长时间? LTS 内核也没有固定的发布时间表。通常,每年都有一个 LTS 内核版本,一般是当年的最后一个版本,它至少会被支持两年。但同样,这里也没有固定的规则。 LTS 内核的维护者可以同意某个 LTS 内核的维护时间超过通常的两年。这个协议是根据必要性和参与的人员来达成的。 这种情况经常发生在 Android 项目中。由于两年的时间不足以让制造商结束对他们的硬件和软件功能的支持,你经常会发现一些 LTS 内核会被支持六年之久。 ![Linux LTS 内核计划支持日期](/data/attachment/album/202111/08/104702q7swhiybninishib.png) 你可以 [在 Linux 内核网站上](https://www.kernel.org/category/releases.html) 找到这个信息。 ### 你的发行版可能没有跟随通常的 Linux 内核版本 如果你检查你的 Linux 内核版本,你可能会发现 [你的发行版使用了一个旧的内核](https://itsfoss.com/why-distros-use-old-kernel/)。也有可能该发行版提供的内核已经在内核网站上被标记为到达了生命末期。 不要惊慌。你的发行版会负责修补内核的错误和漏洞。除非你真的在使用一个不知名的 Linux 发行版,否则你可以相信你的发行版会保持它的安全和健全。 如果你有足够的理由,比如为了支持更新的硬件,你可以自由地在你使用的任何发行版或 [Ubuntu 中安装最新的 Linux 内核](https://itsfoss.com/upgrade-linux-kernel-ubuntu/) 。 如果你想了解更多细节,我已经 [在这里解释了为什么你的发行版使用过时的 Linux 内核](https://itsfoss.com/why-distros-use-old-kernel/)。 ![](/data/attachment/album/202111/08/104702chpqrm8mm0k00psk.png) ### 没有直接明了的答案 正如你所看到的,对于 Linux 内核发布时间表的问题,没有直接明了的答案。一切都是暂定的。 在我看来,好的方面是,如果你使用一个常规的 Linux 发行版,你不需要为 Linux 内核版本的发布或终止而烦恼。那是由你的发行版处理的事情。 我希望你对 Linux 内核的发布周期有了更多的了解,或者是我把你搞糊涂了。无论是哪种情况,请在评论区告诉我你的观点。 --- via: <https://itsfoss.com/linux-kernel-release-support/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Linux kernel is complicated. And I am not even talking about the code. The code itself is complicated but you do not need to bother with that. I am talking about the release schedule of a Linux kernel. How often a new kernel version is released in a year? How long a kernel is supported? There are LTS (Long Term Support) kernels. How long the LTS Linux kernels are supported? The thing is that while these questions may seem simple, the answer is not. There is no one answer to these questions and it needs some explaining to do and that’s what I am going to do in this article. ## Linux kernel release schedule: is there any? ![torvalds kernel release](https://itsfoss.com/content/images/wordpress/2021/11/torvalds-kernel-release.webp) The short answer is that a new kernel version is release every two to three months. The long answer is that it’s not a hard and fast rule. What it means is that you’ll often see a new kernel version release every two to three months. That’s what the kernel maintainer team targets but there is no set deadline that the new version has to be released exactly 8 weeks from the previous release. A new kernel version is released (often) by Linus Torvalds when it is ready. This typically happens every 2 to 3 months. The release is declared ‘stable’ and is usually numbered in the format of X.Y. But this is not the end of X.Y development. The stable release gets further smaller releases to accommodate bug fixes. These small releases add one more point to the stable kernel to make it like X.Y.Z. While X.Y is (often) released by Linux creator Linus Torvalds, the responsibility to maintain the stable X.Y kernel, merge bug fixes and release X.Y.Z versions is handled by a kernel developer. ## How long a kernel version is supported? ![kernel release](https://itsfoss.com/content/images/wordpress/2021/11/kernel-release.png) Like the release, there is no fixed dates and schedule for how long a kernel version will be supported. A regular stable kernel release is usually supported for two and a half months to three months, depending on the release of the next stable kernel release. For example, stable kernel 5.14 would reach [end of life](https://itsfoss.com/end-of-life-ubuntu/) a couple of weeks after the release of stable kernel 5.15. The end of support is announced by the maintainer of that particular stable kernel version in the Linux kernel mailing list. Users and contributors are asked to switch to the newly released stable version. This is applicable to the normal stable kernel versions only. There are LTS (long term support) kernel versions as well and they are supported for a much longer period than just 3 months. ## The LTS Kernel: How long is it supported? There is no set release schedule for LTS kernel as well. Usually, there is one LTS kernel release every year, usually the last release of the year and it is supported for at least two years. But again, there is no set rules here as well. The maintainer of a LTS kernel may agree to maintain a certain LTS kernel for longer than the usual period of two years. The agreement is done based on the necessity and the players involved. This often happens for the Android projects. Since two years is not long enough for the manufacturers to bring support for their hardware and software features, you’ll often find some LTS kernels to be supported for six years. ![linux lts kernel end of life](https://itsfoss.com/content/images/wordpress/2021/11/linux-lts-kernel-end-of-life.png) You can find this information [available on Linux Kernel website](https://www.kernel.org/category/releases.html). ## Your distribution may not follow the usual Linux kernel releases If you check your Linux kernel version, you may find that [your distribution uses an old kernel](https://itsfoss.com/why-distros-use-old-kernel/). It could also be possible that the kernel offered by the distribution has reached end of life as per the kernel website. Don’t panic. Your distribution takes care of patching the kernel for bug fixes and vulnerabilities. Unless you are really using an obscure Linux distribution, you can trust your distro to keep it safe and sound. You are free to [install the latest Linux kernel in Ubuntu](https://itsfoss.com/upgrade-linux-kernel-ubuntu/) or whichever distribution you use if you have good enough reasons such as support for newer hardware. If you want more details, I have e[xplained why your distribution uses an outdated Linux kernel here](https://itsfoss.com/why-distros-use-old-kernel/). ![Keep Calm And Trust Your Distribution](https://itsfoss.com/content/images/wordpress/2019/12/Keep_Calm_and_Trust_Your_Distribution.png) ## No straight forward answers As you can see, there are no straight forwards answers to the Linux kernel release schedule questions. Everything is tentative. The good thing, in my opinion, is that if you use a regular Linux distribution, you don’t need to bother a lot about the release or end of life of Linux kernel versions. That is something handled by your distribution. I hope you have a little bit better idea on the Linux kernel release cycle or perhaps I confused you more than ever. In either case, let me know your views in the comment section.
13,964
在 Linux 命令行上编辑照片的 4 种方法
https://opensource.com/article/21/11/edit-photos-linux-command-line
2021-11-08T11:44:57
[ "ImageMagick" ]
https://linux.cn/article-13964-1.html
![](/data/attachment/album/202111/08/114427mq12hqvqiixv1j1b.jpg) > > 这里有一些我最喜欢的 ImageMagick 技巧,以及如何在没有 GUI 的情况下使用它们。 > > > Linux 对摄影师和图形艺术家很有用。它提供了许多工具来编辑包括照片在内的不同类型的图像文件和格式。这表明你甚至不需要一个图形界面来处理你的照片。这里有四种你可以在命令行中编辑图像的方法。 ### 给你的图片应用效果 几年前,Seth Kenlon 写过一篇文章,[4 个有趣的(半无用的)Linux 玩具](https://opensource.com/life/16/6/fun-and-semi-useless-toys-linux),其中包括对 ImageMagick 编辑工具套件的介绍。在 2021 年的今天,ImageMagick 甚至更有意义。 这篇文章让我们了解了 Fred 的 ImageMagick 脚本,这些脚本真的很有用。Fred Weinhaus 维护着 200 多个脚本,用于对你的图像文件应用各种效果。Seth 向我们展示了 Fred 的 `vintage3` 脚本的一个例子,该脚本使图像变得怀旧。 ### 创建照片拼贴画 今年,Jim Hall 用他的文章 [从 Linux 命令行创建照片拼贴](https://opensource.com/article/21/9/photo-montage-imagemagick) 向我们展示了如何从照片中创建拼贴画。 拼贴画在小册子和手册中使用得很多。它们是一种在一张照片中展示几张图片的有趣方式。可以应用效果来将它们进一步融合在一起。事实上,我以他的文章为指导,创造了上面的图片拼贴。这是我小时候的样子。以下是我使用的命令: ``` $ montage Screenshot-20211021114012.png \ Screenshot-20211021114220.png \ Screenshot-20211021114257.png \ Screenshot-20211021114530.png \ Screenshot-20211021114639.png \ Screenshot-20211021120156.png \ -tile 3x2 -background black \ screenshot-montage.png ``` ### 调整图像大小 Jim 发表了另一篇文章,[从 Linux 终端调整图像的大小](https://opensource.com/article/21/9/resize-image-linux)。这个教程演示了如何使用 ImageMagick 改变一个图像文件的尺寸并将其保存为一个新的文件。例如,上面的 `montage` 命令所产生的拼贴画没有达到要求的尺寸。学习如何调整尺寸,使我能够调整宽度和高度,从而使它能够被包括在内。这是我用来调整这张图片大小的命令。 ![Montage of Alan as a Kid](/data/attachment/album/202111/08/114459k47octy41om41so4.png "Montage of Alan as a Kid") ``` $ convert screenshot-montage.png -resize 520x292\! alanfd-kid-montage.png ``` ### 自动化图像处理 最近,我决定自己看一下 ImageMagick 套件。这一次,我把它的工具组合成一个 Bash 脚本。文章的题目是 [用这个 bash 脚本自动处理图像](https://opensource.com/article/21/10/image-processing-bash-script)。这个例子是一个简单的脚本,可以自动为我的文章制作图片。它是根据 [Opensource.com](http://Opensource.com) 上的要求定制的。如果你想使用这个脚本,我在文章中提供了一个 Git 仓库连接。它很容易修改和扩展,可以满足任何人的需要。 ### 总结 我希望你喜欢这些文章并在你的艺术创作中使用 Linux。如果你想看看更多的 Linux 图像软件,可以看看 Fedora [Design Suite](https://labs.fedoraproject.org/en/design-suite/) Spin。它是一个完整的操作系统,包括许多不同的开源多媒体制作和发布工具,例如: * GIMP * Inkscape * Blender * Darktable * Krita * Scribus * 等等 --- via: <https://opensource.com/article/21/11/edit-photos-linux-command-line> 作者:[Alan Formy-Duval](https://opensource.com/users/alanfdoss) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/%E6%A0%A1%E5%AF%B9%E8%80%85ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Linux is useful to photographers and graphic artists. It provides many tools for editing different types of image files and formats, including photographs. This roundup shows that you do not even need a graphical interface to work with your photos. Here are four ways that you can edit images at the command line. ## Apply effects to your images A couple of years ago, Seth Kenlon wrote the article, [4 fun (and semi-useless) Linux toys](https://opensource.com/life/16/6/fun-and-semi-useless-toys-linux) which included an introduction to the ImageMagick suite of editing tools. ImageMagick is even more relevant today in 2021. This article taught us about Fred's ImageMagick scripts, which really are useful. Fred Weinhaus maintains over 200 scripts for applying all sorts of effects to your image files. Seth shows us an example of Fred's `vintage3` script that gives an image an old-time appearance. ## Create photo collages This year, Jim Hall showed us how to create a collage from photos with his article, [Create a photo collage from the Linux command line](https://opensource.com/article/21/9/photo-montage-imagemagick). Collages are used a lot in pamphlets and brochures. They are a fun way to display several images within a single picture. Effects can be applied to blend them further together. As a matter of fact, I used his article as a guide to create the collage of pictures above. That is me when I was a kid! Here is the command I used: ``` $ montage Screenshot-20211021114012.png \ Screenshot-20211021114220.png \ Screenshot-20211021114257.png \ Screenshot-20211021114530.png \ Screenshot-20211021114639.png \ Screenshot-20211021120156.png \ -tile 3x2 -background black \ screenshot-montage.png ``` ## Resize images Jim delivered another article, [Resize an image from the Linux terminal](https://opensource.com/article/21/9/resize-image-linux). This tutorial demonstrates how to change the dimensions of an image file and save it as a new file using ImageMagick. For example, the collage that resulted from the montage command above did not have the required dimensions. Learning how to resize allowed me to adjust the width and height so that it could be included. This is the command I used to resize the lead image of this article: `$ convert screenshot-montage.png -resize 520x292\! alanfd-kid-montage.png` ## Automate image processing Recently, I decided to take a look at the ImageMagick suite for myself. This time, I combined its tools into a Bash script. The article is entitled [Automate image processing with this bash script](https://opensource.com/article/21/10/image-processing-bash-script). This example is a simple script that automates the production of images for my articles. It is tailored to the requirements here on Opensource.com. I provided a Git repo link in the article if you would like to use the script. It is easily modified and extensible for anyone's needs. ## Wrap up I hope you enjoy these articles and use Linux in your artistic endeavors. If you would like to check out more Linux image software, take a look at the Fedora [Design Suite](https://labs.fedoraproject.org/en/design-suite/) Spin. It is a complete operating system installation that includes many different open source multimedia production and publishing tools, such as: - GIMP - Inkscape - Blender - Darktable - Krita - Scribus - and more... ## Comments are closed.
13,966
openSUSE Leap 与 Tumbleweed,我该选择哪一个
https://itsfoss.com/opensuse-leap-vs-tumbleweed/
2021-11-09T10:28:05
[ "openSUSE", "发行版" ]
https://linux.cn/article-13966-1.html
![](/data/attachment/album/202111/09/102806oc65ntea3ner8q55.png) [openSUSE 是一个非常受欢迎的 Linux 发行版](https://itsfoss.com/why-use-opensuse/),尤其是在企业界。[SUSE](https://en.wikipedia.org/wiki/SUSE_Linux) 从 1996 年起就以这样或那样的形式出现了。很久以来,他们只有一个分支版本。 然后,在 2015 年,他们改变了现状,决定提供两个分支:Leap 和 Tumbleweed。 如果你是 [openSUSE](https://www.opensuse.org/) 的新手,很容易把 Tumbleweed 和 Leap 搞混。最近有位读者要求我们解释这两者之间的异同,这正是我们今天要做的。 ### Leap 和 Tumbleweed 之间有什么区别? 两者之间最重要的区别是发布时间表。openSUSE Leap (LCTT 译注:leap => “飞跃”)每隔几年就会按照固定的时间表发布一个新版本,类似于 Ubuntu 和 Fedora。另一方面,Tumbleweed (LCTT 译注:tumbleweed => “风滚草”)是一个紧密跟随 openSUSE 开发时间表的滚动发布,就像 Arch 或 Void。 ![openSUSE Tumbleweed vs Leap](/data/attachment/album/202111/09/102806i8huubpu59e3k1kh.jpg) 你知道 [滚动发行版](https://itsfoss.com/rolling-release/) 的优势吧?它为你提供了最新的软件版本,你不需要为一个重大版本发布而升级你的系统,因为你的系统会定期得到更新。 所以,在 openSUSE Tumbleweed 中,你会得到更新的桌面环境版本、内核版本等等,你会得到一个最先进的、新鲜的系统。 另一方面,openSUSE Leap 坚持使用较早的、LTS 版本的桌面环境和 Linux 内核,给你一个可靠的系统。当然也会有系统和安全的补丁,并且每隔几年会有一个重大版本,为你的系统提供更新的软件和内核。 #### 快速回顾一下 openSUSE 发布模式的变化历史 ![OpenSUSELeap 安装程序](/data/attachment/album/202111/09/102806gjvv3azv5isaa1fv.png) 从提供一个发行版分支到两个似乎是一个很大的飞跃,所以让我给你介绍一下历史背景。Tumblewee 项目是由 [Greg Kroah-Hartman](https://en.wikipedia.org/wiki/Greg_Kroah-Hartman) 在 2010 年 11 月宣布的。其目的是创建一个 “滚动更新版本的 openSUSE 存储库,包含供人们使用的最新‘稳定’版软件包”。这个项目并不是一个新的发行版,而是对现有 openSUSE 系统的附加部分。 这在 2014 年发生了变化,当时 openSUSE 背后的团队决定将下一个版本基于 SUSE Linux Enterprise Server(SLES)开发。他们将这个新版本命名为 “Leap 42”(解释一下,“42” 这个数字来自《<ruby> 银河系漫游指南 <rt> Hitchhiker’s Guide to the Galaxy </rt></ruby>》,其中 “42” 被认为是生命、宇宙和一切的答案)。( LCTT 译注:在瞎飙了版本后之后,它们又回到了 15.x 这种按部就班的版本号)目前 openSUSE Leap 的版本是 15.2。 随着这一变化,Tumbleweed 成为 openSUSE 的官方发行版。有趣的是,根据 openSUSE 2020 年底的 [社区调查](https://en.opensuse.org/End-of-year-surveys/2020/Data#Uses_Tumbleweed_as_Desktop_on_a_regular_basis),越来越多的人选择使用 Tumbleweed。 ### 你应该使用 Leap 还是 Tumbleweed? 下一个问题是,“如果底层技术基本相同,那么应该使用这两个中的哪一个?”让我为你分析一下。 openSUSE Leap 是稳定的,经过高度测试的。它应该用于较旧的系统和需要长期无问题运行的计算机。这是因为所提供的软件不是最新和最好的,而是最稳定的。因为新的版本每 3 年才会发布一次,所以你安排的任何工作流程都是相对安全的。(一定要记得备份。)Leap 在其整个发布周期中坚持使用同一个 Linux 内核。 ![OpenSUSE Leap 桌面](/data/attachment/album/202111/09/102807uzbcaraa5gr15ocz.png) 使用 Leap,你不会收到最新版本的软件。你也将以较慢的速度获得硬件支持。你将需要每年至少更新一次你的系统以继续获得更新。Leap 就像 Ubuntu LTS 一样。 另一方面,openSUSE Tumbleweed 拥有所有软件的最新版本,包括内核、驱动程序和桌面环境。由于它是一个滚动发行版,所以你所使用的版本基本上没有寿命结束的可能。 Tumbleweed 不断接受更新的事实也会导致一些问题,比如工作流程或工具的损坏,一般来说,它打磨得比较粗糙。如果发生这种情况,Tumbleweed 确实有工具可以回滚到以前的状态,以避免这些问题。Tumbleweed 非常紧跟 Linux 内核的发布。 ![openSUSE Tumbleweed 桌面](/data/attachment/album/202111/09/102808zy600rbjii1b00b7.png) 让我为你总结一下,以帮助你做出决定。 如果: * 稳定性对你来说很重要 * 你是 openSUSE 的新手 * 你的硬件较旧 * 你在运行一个生产服务器 * 如果你正在为一个不懂技术的朋友或家人建立一个系统 那么你应该使用 Leap。 如果: * 你想尝试最新、最棒的软件 * 你的硬件较新 * 你对 Linux 比较有经验 * 你是一个软件开发者 * 你需要专有的硬件驱动,比如 Nvidia 或 Radeon 显卡,或者 Broadcom 的 Wi-Fi 适配器 * 你想要最新的内核版本 那么你应该使用 Tumbleweed。 我希望能为你解开疑惑。如果你已经在使用 Leap 或 Tumbleweed,请在评论区告诉我们你的偏好和建议。 --- via: <https://itsfoss.com/opensuse-leap-vs-tumbleweed/> 作者:[John Paul](https://itsfoss.com/author/john/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
[openSUSE is a very popular Linux distros](https://itsfoss.com/why-use-opensuse/), especially in the enterprise world. [SUSE](https://en.wikipedia.org/wiki/SUSE_Linux) has been around in one form or another since 1996. During most of that time, they have only had one version. Then, in 2015, they changed things up and decided to offer two versions: Leap and Tumbleweed. If you are new to [openSUSE](https://www.opensuse.org/), it is easy to get confused between Tumbleweed and Leap. A reader recently asked us to explain the similarities and difference between the two, that’s just what we’ll do today. ## What is the difference between openSUSE Leap and Tumbleweed? The most significant difference between the two is release schedule. openSUSE Leap releases a new version every few years on a set schedule, similar to Ubuntu and Fedora. Tumbleweed on the other hand is a rolling release that closely follows the openSUSE development cycle, just like Arch or Void. ![opensuse leap vs tumbleweed](https://itsfoss.com/content/images/wordpress/2021/11/opensuse-leap-vs-tumbleweed-800x264.webp) You know the advantages of a [rolling release distribution](https://itsfoss.com/rolling-release/), don’t you? It gives you the latest software versions and you don’t have to upgrade your system for a major release because your system keeps on getting updates regularly. So, you get newer desktop environment releases, kernel versions and more in openSUSE Tumbleweed. You get a cutting edge, fresh system. Tumbleweed is one of the [best rolling release distros](https://itsfoss.com/best-rolling-release-distros/). On the other hand, openSUSE Leap sticks to older, LTS versions of desktop environments, Linux kernels to give you a rock solid system. There will be system and security patches of course and a major release after every few years to provide your system newer software and kernel. ### A quick look back at the history of openSUSE release model change ![openSUSE Leap installer](https://itsfoss.com/content/images/wordpress/2021/11/opensuse-leap-installer-800x600.png) Going from offering one distro option to two might seem like a big leap, so let me give you a little historical background. The Tumbleweed project was [announced](https://lists.opensuse.org/archives/list/[email protected]/message/NNRPP2KJ6TJ3QLLYJC2E62JADHT5GWMY/) in November of 2010 by [Greg Kroah-Hartman](https://en.wikipedia.org/wiki/Greg_Kroah-Hartman). The goal was to create a “repo that is a rolling updated version of openSUSE containing the latest “stable” versions of packages for people to use”. This project wasn’t a new distro, but an add-on for an existing openSUSE install. This changed in 2014 when the team behind openSUSE decided to base the next release on SUSE Linux Enterprise Server. They named this new release “Leap 42”. (For those unaware, 42 is a reference to the Hitchhiker’s Guide to the Galaxy, where 42 is said to be the answer to life, the universe and everything.) The current version of openSUSE Leap is 15.2. With this change, Tumbleweed became an official openSUSE distribution Interestingly, according to the openSUSE End of the Year 2020 [Community Survey](https://en.opensuse.org/End-of-year-surveys/2020/Data#Uses_Tumbleweed_as_Desktop_on_a_regular_basis), more people use Tumbleweed as their distro of choice. ## Should you use Leap or Tumbleweed? ![opensuse leap vs tumbleweed](https://itsfoss.com/content/images/wordpress/2021/11/opensuse-leap-vs-tumbleweed.png) The next question is, “If the underlying technology is pretty much the same, who should use either of the two options?” Let me break that down for you. openSUSE Leap is stable and highly tested. It should be used for older systems and computers that needs to run for a long time without any issue. This is because the software available is not the latest and greatest, but the most stable. Because a new revision is only released every 3 years, any workflow you put in place is relatively safe. (Always remember to back up.) ![openSUSE Leap desktop](https://itsfoss.com/content/images/wordpress/2021/11/opensuse-leap-deaktop-800x600.png) With Leap, you will not receive the latest versions of software. You will also receive hardware support at a slower rate. You will need to update your system at least once a year to continue to get updates. openSUSE Tumbleweed on the other hand has the latest version of all software, including kernels, drivers, and desktop environments. It is [based](https://en.opensuse.org/Portal:Tumbleweed) on Factory, openSUSE’s main development codebase. Unlike the majority of rolling distros, “Tumbleweed is updated once Factory’s bleeding edge software has been integrated, stabilized and tested.” Tumbleweed undergoes a number of tests to make sure it is stable. Since it is a rolling distro, there is theoretically no end of life for the version you are using. The fact that Tumbleweed is constantly receiving updates can also lead to problems, like workflow or tool breakage, and is generally rough around the edges. If this occurs, Tumbleweed does have tools to roll back to a previous state to avoid these issues. Tumbleweed follows Linux kernel releases very closely. Strangely, only Tumbleweed is available in 32-bit. ![openSUSE Tumbleweed desktop](https://itsfoss.com/content/images/wordpress/2021/11/opensuse-tumbleweed-deaktop-800x603.png) Let me summarize things for you to help you make a decision. You should use Leap if: - Stability is important to you - You are new to openSUSE - You have older hardware - You run a server in production - If you are setting up a system for a non-technical friend or family member - You depend on “3rd party kernel driver modules including graphic drivers” You should use Tumbleweed if: - You want to try out the latest and greatest software - You have newer hardware - You are more experienced with Linux - You are a software developer - You need proprietary hardware drivers, such as for Nvidia or Radeon display adapters, or Broadcom Wi-Fi adapters - You want the latest kernel version - You have a 32-bit computer Note: Neither Leap nor Tumbleweed come with the codecs needed to play audio and video. They have to downloaded separately from a community site. I hope this cleared the air for you. If you are already using either Leap or Tumbleweed, please let us know your preference and recommendation in the comment section.
13,970
在 FreeDOS 上使用 BAT 文件自动执行任务
https://opensource.com/article/21/6/automate-tasks-bat-files-freedos
2021-11-10T10:44:00
[ "FreeDOS", "批处理" ]
https://linux.cn/article-13970-1.html
> > FreeDOS 下批处理文件的实用指南。 > > > ![](/data/attachment/album/202111/10/104345whfjagaahm9nb2j3.jpg "Tips and gears turning") 即使你以前没有使用过 DOS,你也可能知道它的命令行 shell,即 `COMMAND.COM`。它已经成为 DOS 的同义词,FreeDOS 为此也实现了一个类似的 shell,称为 “FreeCOM”,但也命名为 `COMMAND.COM`,就像在其他 DOS 系统上一样。 但是 FreeCOM shell 可以做的不仅仅是为你提供一个命令行提示符让你在其中运行命令,如果你需要在 FreeDOS 上自动执行任务,你可以使用 *批处理文件*,也称为 “BAT 文件”,因为这些脚本使用 `.BAT` 扩展名。 批处理文件可能比你在 Linux 编写的脚本要简单得多。因为在很久以前,这个功能最初被添加到 DOS 时,它是为了让 DOS 用户“批量处理”某些命令。它的条件分支没有太大的灵活性,也不支持更高级的功能,例如算术扩展、标准输出和错误消息的重定向、后台进程、测试、循环(这项支持)和 Linux 脚本中常见的其他结构。 本文是 FreeDOS 下批处理文件的实用指南。记住通过用百分号(`%`)包裹变量名称来引用环境变量,例如 `%PATH%`。但是,请注意,由于历史原因,`FOR` 循环的构造略有不同。 ### 打印输出 批处理文件可能需要向用户打印消息,让用户知道发生了什么。使用 `ECHO` 语句打印消息。例如,一个批处理文件可能使用以下语句表明它已完成了任务: ``` ECHO Done ``` `ECHO` 语句不需要引号。FreeCOM `ECHO` 语句不会以任何特殊方式处理引号,它会像普通文本一样打印它们。 通常,FreeDOS 在执行批处理文件时会打印每一行。这在一个非常短的批处理文件中通常不是问题,它只为用户定义了几个环境变量。但是对于执行更多工作的较长批处理文件而言,批处理行的这种一直显示可能会变得很麻烦。要阻止此输出,在 `ECHO` 语句中使用 `OFF` 关键字,如下所示: ``` ECHO OFF ``` 使用 `ON` 关键字在 FreeDOS 运行时恢复显示批处理行。 ``` ECHO ON ``` 大多数批处理文件在第一行包含一个 `ECHO OFF` 语句,以阻止消息,但是 shell 在执行语句时仍然会在屏幕上打印 `ECHO OFF`。为了隐藏该语句,批处理文件通常在前面使用 `@` 符号。这样,任何以这个特殊字符开头的行都不会打印,即使打开了 `ECHO`。 ``` @ECHO OFF ``` ### 注释 编写较长批处理文件时,大多数程序员都喜欢使用 *注释* 来提醒自己这个批处理文件的用途。在批处理文件中注释,使用 `REM`(remark)关键字。`REM` 之后的任何内容都会被 FreeCOM shell 忽略。 ``` @ECHO OFF REM This is a comment ``` ### 执行“辅助”批处理文件 通常,FreeCOM 一次只运行一个批处理文件。但是,你可能需要使用另一个批处理文件来执行其他操作,例如为多个批处理文件设置公共环境变量。 如果你从"正在运行"的批处理文件中直接调用第二个批处理文件,FreeCOM 将完全切换到第二个批处理文件,并停止处理第一个。要改为在第一个批处理文件“内部”运行第二个批处理文件,你需要告诉 FreeDOS shell 使用 `CALL` 关键字去 *调用* 第二个批处理文件。 ``` @ECHO OFF CALL SETENV.BAT ``` ### 条件分支 批处理文件确实支持使用 `IF` 语句的简单条件分支。它有三种基本形式: 1. 测试上一条命令的返回状态 2. 测试一个变量是否等于一个值 3. 测试文件是否存在 `IF` 语句的一个常见用途是测试程序是否成功返回。如果它们正常运行,大多数程序将返回零值,或者在出现错误时返回一些其他值。在 DOS 中,这称为 *错误级别*,这是 `IF` 测试的特例。 测试名为 `MYPROG` 的程序是否成功退出,实际上是检查程序是否返回“零”。使用 `ERRORLEVEL` 关键字来测试特定值。例如: ``` @ECHO OFF MYPROG IF ERRORLEVEL 0 ECHO Success ``` 使用 `ERRORLEVEL` 测试错误级别是检查程序退出状态的笨拙方法。检查 DOS 程序的不同返回值,更有用的方法是使用 FreeDOS 为你定义的特殊变量,称为 `ERRORLEVEL`。它存储了最近执行程序的错误级别,然后你可以使用 `==` 测试不同的值。 你可以使用 `==` 和 `IF` 语句来测试变量是否等于某个值。就像一些编程语言,你可以使用 `==` 直接比较两个值。通常,在一侧引用一个环境变量,在另一侧引用一个值,但你也可以比较两个变量的值以查看它们是否相同。例如,你可以使用此批处理文件重写上面的 `ERRORLEVEL` 代码: ``` @ECHO OFF MYPROG IF %ERRORLEVEL%==0 ECHO Success ``` `IF` 语句的另一个常见用途是测试文件是否存在,如果存在则采取操作。你可以使用 `EXIST` 关键字来测试。例如,要删除名为 `TEMP.DAT` 的临时文件,你可以在批处理文件中使用以下行: ``` @ECHO OFF IF EXIST TEMP.DAT DEL TEMP.DAT ``` 对于任何 `IF` 语句,你都可以使用 `NOT` 关键字来 *否定* 测试。在文件 *不* 存在时打印消息,你可以这样写: ``` @ECHO OFF IF NOT EXIST TEMP.DAT ECHO No file ``` ### 分支执行 利用 `IF` 测试的一种方法是跳转到批处理文件中完全不同的部分,这取决于 `IF` 测试的结果。在最简单的情况下,如果一个关键命令失败,你可能希望跳到批处理文件的末尾。或者,如果某些环境变量设置不正确,你可能想要执行其他语句。 你可以使用 `GOTO` 指令跳转到批处理文件的其他部分。它会跳转到批处理文件中称为 *标签* 的特定行。注意,这是一个严格的 “go-to” 跳转:批处理文件执行将在新标签处启动。 假设程序需要一个现有的空文件来存储临时数据,如果文件不存在,则需要在运行程序之前创建一个文件。你可以将这些动作添加到批处理文件中,这样你的程序始终有一个临时文件可供使用: ``` @ECHO OFF IF EXIST temp.dat GOTO prog ECHO Creating temp file... TOUCH temp.dat :prog ECHO Running the program... MYPROG ``` 当然,这是一个非常简单的例子。对于这种情况,你可以重写批处理文件,将创建临时文件作为 `IF` 语句的一部分: ``` @ECHO OFF IF NOT EXIST temp.dat TOUCH temp.dat ECHO Running the program... MYPROG ``` ### 迭代 如果你需要对一组文件执行相同的任务怎么办?你可以使用 `FOR` 循环 *迭代* 一组文件。这是一个单行循环,每次使用不同的文件运行单个命令。 `FOR` 循环对迭代变量使用一种特殊的语法,它的用法与其他 DOS 环境变量不同。要循环编辑一组文本文件,可以使用以下语句:(LCTT 译注:原文此处写错了,少写了一个 `%`) ``` @ECHO OFF FOR %%F IN (*.TXT) DO EDIT %%F ``` 注意,如果在命令行中运行此循环,而不是在批处理文件中,那么迭代变量仅需要指定一个百分号(`%`): ``` C:\> FOR %F IN (*.TXT) DO EDIT %F ``` ### 命令行处理 在运行批处理文件时,FreeDOS 提供了一种简单的方法来检测用户可能提供的命令行选项。FreeDOS 解析命令行输入,并将前九个选项存储在特殊变量 `%1`、`%2` ..... 等中,直到 `%9`。注意,无法通过这种方式直接访问第十一个(及之后)选项。特殊变量 `%0` 存储批处理文件的名称。 如果你的批处理文件需要处理 9 个以上的选项,你可以使用 `SHIFT` 语句移除第一个选项,并将每个选项向下 *移动* 一个值。所以第二个选项变成了 `%1`,第十个选项变成了 `%9`。 大多数批处理文件只需要移动一个值。但是,如果你需要以其他增量进行移位,可以将参数提供给 `SHIFT` 语句。例如: ``` SHIFT 2 ``` 下面是一个简单的批处理文件,演示了移位操作: ``` @ECHO OFF ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9 ECHO Shift by one .. SHIFT 1 ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9 ``` 执行带有十个选项的批处理文件显示了 `SHIFT` 语句如何重新排列命令行选项,因此批处理文件现在可以用 `%9` 访问第十个参数: ``` C:\SRC>args 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 Shift by one .. 2 3 4 5 6 7 8 9 10 C:\SRC> ``` --- via: <https://opensource.com/article/21/6/automate-tasks-bat-files-freedos> 作者:[Jim Hall](https://opensource.com/users/jim-hall) 选题:[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/) 荣誉推出
200
OK
Even if you haven't used DOS before, you are probably aware of its command-line shell, named simply `COMMAND.COM` . The `COMMAND.COM` shell has become synonymous with DOS, and so it's no surprise that FreeDOS also implements a similar shell called "FreeCOM"—but named `COMMAND.COM` just as on other DOS systems. But the FreeCOM shell can do more than just provide a command-line prompt where you run commands. If you need to automate tasks on FreeDOS, you can do that using *batch files*, also called "BAT files" because these scripts use the `.BAT` extension. Batch files are much simpler than scripts you might write on Linux. That's because when this feature was originally added to DOS, long ago, it was meant as a way for DOS users to "batch up" certain commands. There's not much flexibility for conditional branching, and batch files do not support more advanced features such as arithmetic expansion, separate redirection for standard output vs error messages, background processes, tests, loops, and other scripting structures that are common in Linux scripts. Here's a helpful guide to batch files under FreeDOS. Remember to reference environment variables by wrapping the variable name with percent signs (`%` ) such as `%PATH%` . However, note that `FOR` loops use a slightly different construct for historical reasons. ## Printing output Your batch file might need to print messages to the user, to let them know what's going on. Use the `ECHO` statement to print messages. For example, a batch file might indicate it is done with a task with this statement: `ECHO Done` You don't need quotes in the `ECHO` statement. The FreeCOM `ECHO` statement will not treat quotes in any special way and will print them just like regular text. Normally, FreeDOS prints out every line in the batch file as it executes them. This is usually not a problem in a very short batch file that only defines a few environment variables for the user. But for longer batch files that do more work, this constant display of the batch lines can become bothersome. To suppress this output, use the `OFF` keyword to the `ECHO` statement, as: `ECHO OFF` To resume displaying the batch lines as FreeDOS runs them, use the `ON` keyword instead: `ECHO ON` Most batch files include an `ECHO OFF` statement on the first line, to suppress messages. But the shell will still print `ECHO OFF` to the screen as it executes that statement. To hide that message, batch files often use an at sign (`@` ) in front. This special character at the start of any line in a batch file suppresses printing that line, even if `ECHO` is turned on. `@ECHO OFF` ## Comments When writing any long batch file, most programmers prefer to use *comments* to remind themselves about what the batch file is meant to do. To enter a comment in a batch file, use the `REM` (for *remark*) keyword. Anything after `REM` gets ignored by the FreeCOM shell. ``` @ECHO OFF REM This is a comment ``` ## Executing a "secondary" batch file Normally, FreeCOM only runs one batch file at a time. However, you might need to use another batch file to do certain things, such as set environment variables that are common across several batch files. If you simply call the second batch file from a "running" batch file, FreeCOM switches entirely to that second batch file and stops processing the first one. To instead run the second batch file "inside" the first batch file, you need to tell the FreeCOM shell to *call* the second batch file with the `CALL` keyword. ``` @ECHO OFF CALL SETENV.BAT ``` ## Conditional evaluation Batch files do support a simple conditional evaluation structure with the `IF` statement. This has three basic forms: - Testing the return status of the previous command - Testing if a variable is equal to a value - Testing if a file exists A common use of the `IF` statement is to test if a program returned successfully to the operating system. Most programs will return a zero value if they completed normally, or some other value in case of an error. In DOS, this is called the *error level* and is a special case to the `IF` test. To test if a program called `MYPROG` exited successfully, you actually want to examine if the program returned a "zero" error level. Use the `ERRORLEVEL` keyword to test for a specific value, such as: ``` @ECHO OFF MYPROG IF ERRORLEVEL 0 ECHO Success ``` Testing the error level with `ERRORLEVEL` is a clunky way to examine the exit status of a program. A more useful way to examine different possible return codes for a DOS program is with a special variable FreeDOS defines for you, called `ERRORLEVEL` . This stores the error level of the most recently executed program. You can then test for different values using the `==` test. You can test if a variable is equal to a value using the `==` test with the `IF` statement. Like some programming languages, you use `==` to directly compare two values. Usually, you will reference an environment variable on one side and a value on the other, but you could also compare the values of two variables to see if they are the same. For example, you could rewrite the above `ERRORLEVEL` code with this batch file: ``` @ECHO OFF MYPROG IF %ERRORLEVEL%==0 ECHO Success ``` And another common use of the `IF` statement is to test if a file exists, and take action if so. You can test for a file with the `EXIST` keyword. For example, to delete a temporary file called `TEMP.DAT` , you might use this line in your batch file: ``` @ECHO OFF IF EXIST TEMP.DAT DEL TEMP.DAT ``` With any of the `IF` statements, you can use the `NOT` keyword to *negate* a test. To print a message if a file *does not* exist, you could write: ``` @ECHO OFF IF NOT EXIST TEMP.DAT ECHO No file ``` ## Branched execution One way to leverage the `IF` test is to jump to an entirely different part of the batch file, depending on the outcome of a previous test. In the simplest case, you might want to skip to the end of the batch file if a key command fails. Or you might want to execute other statements if certain environment variables are not set up correctly. You can skip around to different parts of a batch file using the `GOTO` instruction. This jumps to a specific line, called a *label*, in the batch file. Note that this is a strict "go-to" jump; batch file execution picks up at the new label. Let's say a program needed an existing empty file to store temporary data. If the file did not exist, you would need to create a file before running the program. You might add these lines to a batch file, so your program always has a temporary file to work with: ``` @ECHO OFF IF EXIST temp.dat GOTO prog ECHO Creating temp file... TOUCH temp.dat :prog ECHO Running the program... MYPROG ``` Of course, this is a very simple example. For this one case, you might instead rewrite the batch file to create the temporary file as part of the `IF` statement: ``` @ECHO OFF IF NOT EXIST temp.dat TOUCH temp.dat ECHO Running the program... MYPROG ``` ## Iteration What if you need to perform the same task over a set of files? You can *iterate* over a set of files with the `FOR` loop. This is a one-line loop that runs a single command with a different file each time. The `FOR` loop uses a special syntax for the iteration variable, which is used differently than other DOS environment variables. To loop through a set of text files so you can edit each one, in turn, use this statement in your batch file: ``` @ECHO OFF FOR %%F IN (*.TXT) DO EDIT %%F ``` Note that the iteration variable is specified with only one percent sign (`%` ) if you run this loop at the command line, without a batch file: `C:\> FOR %F IN (*.TXT) DO EDIT %F` ## Command-line processing FreeDOS provides a simple method to evaluate any command-line options the user might have provided when running batch files. FreeDOS parses the command line, and stores the first nine batch file options in the special variables `%1` , `%2` , .. and so on until `%9` . Notice that the eleventh option (and beyond) are not directly accessible in this way. (The special variable `%0` stores the name of the batch file.) If your batch file needs to process more than nine options, you can use the `SHIFT` statement to remove the first option and *shift* every option down by one value. So the second option becomes `%1` , and the tenth option becomes `%9` . Most batch files need to shift by one value. But if you need to shift by some other increment, you can provide that parameter to the `SHIFT` statement, such as: `SHIFT 2` Here's a simple batch file that demonstrates shifting by one: ``` @ECHO OFF ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9 ECHO Shift by one .. SHIFT 1 ECHO %1 %2 %3 %4 %5 %6 %7 %8 %9 ``` Executing this batch file with ten arguments shows how the `SHIFT` statement reorders the command line options, so the batch file can now access the tenth argument as `%9` : ``` C:\SRC>args 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 Shift by one .. 2 3 4 5 6 7 8 9 10 C:\SRC> ``` ## Comments are closed.
13,972
exa:一个 ls 命令的现代替代品
https://itsfoss.com/exa/
2021-11-10T15:57:00
[ "ls", "exa" ]
https://linux.cn/article-13972-1.html
![](/data/attachment/album/202111/10/155648vf7iwcwsetitqfuw.jpg) 我敢打赌你使用过 [Linux 上的 ls 命令](https://linuxhandbook.com/ls-command/),它是你 [学习 Linux](https://itsfoss.com/free-linux-training-courses/) 时首次接触到的命令之一。 这个简单的 `ls` 命令列出目录的内容十分方便,但是直到我发现 `exa` 之前从来没想过会有命令能替代它。 ### exa 命令简介 [exa](https://the.exa.website/) 是一个命令行工具,可以列出指定路径(如未指定则是当前目录)的目录和文件。这也许听起来很熟悉,因为这就是 `ls` 命令所做的事情。 `exa` 被视作从 UNIX 旧时代延续至今的古老的 `ls` 命令的一个现代替代品。如其所声称的那样,它有比 `ls` 命令更多的功能、更好的默认行为。 ![exa 功能](/data/attachment/album/202111/10/155702mm72rrjvmpz9kprh.png) 以下是一些你应该使用 `exa` 替代 `ls` 的原因: * `exa` 像 `ls` 一样可移植(在所有主流 Linux 发行版、\*BSD 和 macOS 上可用) * 默认彩色输出 * `exa` 不同格式化的“详细”输出也许会吸引 Linux/BSD 新手 * 文件查询是并行进行的,这使得 `exa` 与 `ls` 的性能相当 * 显示单个文件的 git 暂存或未暂存状态 `exa` 的另外一个不同的地方是它是用 Rust 编写的。顺便说一句,Rust 与 C 语言的执行速度相近,但在编译时减少了内存错误,使你的软件可以快速而安全地执行。 ### 在 Linux 系统上安装 exa `exa` 最近很流行,因为许多发行版开始将其包括在其官方软件库中。也就是说,你应该可以使用你的 [发行版的包管理器] 来安装它。 从 Ubuntu 20.10 开始,你可以使用 `apt` 命令来安装它: ``` sudo apt install exa ``` Arch Linux 已经有了它,你只需要 [使用 pacman 命令](https://itsfoss.com/pacman-command/) 即可: ``` sudo pacman -S exa ``` 如果它无法通过你的包管理器安装,请不要担心。毕竟它是一个 Rust 包,你可以很容易地用 Cargo 安装它。请确保在你使用的任何发行版 [或 Ubuntu 上安装了 Rust 和 Cargo](https://itsfoss.com/install-rust-cargo-ubuntu-linux/)。 安装 Rust 和 Cargo 后,使用此命令安装 `exa`: ``` cargo install exa ``` ### 使用 exa `exa` 有很多命令选项,主要是为了更好的格式化输出和一些提高舒适度的改进,比如文件的 git 暂存或未暂存状态等等。 下面是一些屏幕截图,展示了 `exa` 是如何在你的系统上工作的。 简单地使用 `exa` 命令将产生类似于 `ls` 但带有颜色的输出。这种彩色的东西可能没有那么吸引人,因为像 Ubuntu 这样的发行版至少在桌面版本中已经提供了彩色的 `ls` 输出。不过,`ls` 命令本身默认没有彩色输出。 ``` exa ``` ![exa 命令的输出截图,没有任何额外的标志](/data/attachment/album/202111/10/155702nwcizcfc5c1q1ug9.jpg) 请注意,`exa` 和 `ls` 命令的选项不尽相同。例如,虽然 `-l` 选项在 `exa` 和 `ls` 中都给出了长列表,但 `-h` 选项添加了一个列标题,而不是 `ls` 的人类可读选项。 ``` exa -lh ``` ![正如我之前提到的,exa 有列标题以获得更好的“详细”输出](/data/attachment/album/202111/10/155702k8226p6c3ra2fafn.jpg) 我前面说过,`exa` 已经内置了 Git 集成。下面的屏幕截图给出了 `–git` 标志的演示。请注意 `test_file` 在 `git` 的 `tracked` 列中显示 `-N` ,因为它尚未添加到存储库中。 ``` exa --git -lh ``` ![演示 git 标志如何与 exa 一起工作](/data/attachment/album/202111/10/155703wdr02s72rex3b29q.jpg) 下面的例子不是我的猫键入的。它是各种选项的组合。`exa` 有可供你尝试和探索的很多选项。 ``` exa -abghHliS ``` ![一个非常丰富多彩和详细的输出,具有用户友好的详细输出](/data/attachment/album/202111/10/155703j81475lb746bbrb8.jpg) 你可以通过在终端中运行以下命令来获取完整的选项列表: ``` exa --help ``` 但是,如果你想了解 `exa` 所提供的功能,可以查看其 [Git 存储库](https://github.com/ogham/exa) 上的 [官方文档](https://github.com/ogham/exa#command-line-options)。 ### 值得从 ls 切换到 exa 吗? 对于类 UNIX 操作系统的新手来说,`exa` 可能是用户友好的,它牺牲了在脚本中容易使用的能力,以换取“易用性”和外观。其中,显示得更清楚并不是一件坏事。 无论如何,`ls` 就像通用命令。你可以将 `exa` 用于个人用途,但在编写脚本时,请坚持使用 `ls`。当预期输出与任一命令中的实际输出不匹配时,`ls` 和 `exa` 之间一个 [或多个] 标志的差异可能会让你发疯。 我想知道你对 `exa` 的看法。你已经尝试过了吗?你对它的体验如何? --- via: <https://itsfoss.com/exa/> 作者:[Pratham Patel](https://itsfoss.com/author/pratham/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
I bet you have used the [ls command in Linux](https://linuxhandbook.com/ls-command/). It’s one of the first command you use while [learning Linux](https://itsfoss.com/free-linux-training-courses/) commands. The simple ls command is quite handy for listing directory content. I never really though any command could replace it until I discovered exa. ## What is exa command? [exa](https://the.exa.website/) is a command line tool that lists directories and files in the specified path (or in the current directory if not specified). This might sound familiar to you because it is exactly ls command also does. exa is supposed to be a modern replacement for the venerable ls command from the good old UNIX days. It has more features and better default than the ls command, so it claims. ![exa features](https://itsfoss.com/content/images/wordpress/2021/11/exa-features-800x331.png) [exa project website](https://the.exa.website/) Here are some reasons why you would want to use the exa command instead of ls: - exa is just as portable as ls (available on all major Linux distributions, *BSD and macOS) - Has colorful output by default - The differently formatted “verbose-ness” of exa might attract users who are new to Linux/BSDs - File querying is done in parallel, making exa equivalent or on par to the performance of ls - Shows git staged or un-staged status for individual files One of the other aspect of exa is that it is written in the Rust programming language. In case you don’t know about the Rust language, it has similar execution speed compared to C while cutting down memory related errors at compile time itself; making your software fast *and* secure. ## Installing exa on your Linux system exa has gained quite some popularity lately and thus many distributions have started including it in the official repositories. In other words, you should be able to install it using your [distribution’s package manager](https://itsfoss.com/package-manager/). Starting with Ubuntu 20.10, you can install it using the apt command: `sudo apt install exa` Arch Linux already has it so just [use the pacman command](https://itsfoss.com/pacman-command/): `sudo pacman -S exa` If it is not available through your package manager, don’t fret. It’s a Rust package after all and you can easily install it with Cargo. Please make sure to [install Rust and Cargo on Ubuntu](https://itsfoss.com/install-rust-cargo-ubuntu-linux/) or whichever distribution you are using. Once you have Rust and Cargo installed, use this command to install exa: `cargo install exa` ## Using exa exa has a lot of command options, mostly aimed at a better formatted output and some quality of life improvements like git status for staged or unstaged file, and much more. Below are a few screenshots demonstrating how exa will work on your system. Simply using the exa command will produce an output similar to ls but with color. This color thing may not be that attractive because distributions like Ubuntu already provide colored ls output at least in desktop version. However, the ls command doesn’t have colored output by default. `exa` ![01 exa](https://itsfoss.com/content/images/wordpress/2021/11/01_exa-800x600.webp) Please note that exa and ls command do not have all the same options. For example, while the -l option gives long list in both exa and ls, the -h option adds a column header instead of the human readable option like ls. `exa -lh` ![02 exa lh](https://itsfoss.com/content/images/wordpress/2021/11/02_exa_lh-800x600.webp) I told you that exa has built in git integration. The screenshot below gives the demonstration of the –git flag. Notice how the test_file shows -N in tracked column of git because it has not been added to the repository sources yet. `exa --git -lh` ![03 exa git](https://itsfoss.com/content/images/wordpress/2021/11/03_exa_git-800x600.webp) The example below is not something my cat typed. It’s a combination of various options. Exa has even more options for you to try and explore. `exa -abghHliS` ![04 exa all flags](https://itsfoss.com/content/images/wordpress/2021/11/04_exa_all_flags-800x600.webp) You can get the full list of options by running the following command in your terminal: `exa --help` However, if you want to see what exa has to offer, you can view the [official documentation](https://github.com/ogham/exa#command-line-options) on its [git repository](https://github.com/ogham/exa). ## Worth switching to exa from ls? As user friendly as exa might be to someone who is new to UNIX like Operating Systems, it trades the ability of being easily used in a script for “easy-ness” and appearance. Which, to be clear is not a bad thing. In any case, ls is like the universal command. You may use exa for personal use but when it comes to scripting, stick to ls. The difference of one [or many] flags between ls and exa might drive you crazy when the expected output does not match the actual output in either command. I would like to know your views on exa. Have you already tried it? How’s your experience with it?
13,974
成为为开源做贡献的技术写手的四个建议
https://opensource.com/article/21/11/technical-writing-open-source
2021-11-11T10:08:11
[ "贡献", "写作" ]
/article-13974-1.html
> > 你的开源贡献将会向潜在雇主表明,你会主动寻求学习、成长和挑战自我的机会。 > > > ![](/data/attachment/album/202111/11/100737uebjijhwz0l4zhoo.jpg "A person writing.") 不管你是一个对技术写作有所涉足的技术爱好者,还是一个想要转职为职业技术写手的成熟技术专家,你都可以构建你的技术写作作品集,并将你的开源贡献作为作品集的一部分。为开源项目写作是一件有趣、灵活且低风险的事情。按照自己的时间安排来为你感兴趣的项目做贡献,你将会为社区是多么热情或你对社区产生影响的速度而感到惊喜。 你的开源贡献将会向潜在雇主表明,你会主动寻求学习、成长和挑战自我的机会。和任何事情一样,你需要从某个地方开始。为开源项目做贡献可以让你在展示你的才华的同时学到新技巧、新技术。另外,为开源项目写作能让你接触到新的社区、跨越时区与新鲜面孔合作,并建立你的社交网络。当你挖掘到新的开源机会后,你的简历将更抢眼,让你在其他候选人中脱颖而出。以下是为开源做出贡献的四个建议,这可以让你走向技术写作的职业生涯。 ### 学习行业工具 作为开始,我建议先熟悉 [Git](https://git-scm.com/),并建立 [GitLab](https://about.gitlab.com/) 和 [GitHub](https://github.com/) 帐号,然后寻找一个趁手的文本编辑器。我个人喜欢使用开源工具 [Atom](https://atom.io/)。关于 Git,它能从网络上获取到丰富的免费学习资源,包括一些优秀的互动教程。你不需要成为一个 Git 高手才能深入开源世界。我建议先学习一些基本操作,然后让你的技能随着你的贡献逐渐成长。 ### 找到一个项目 为开源做贡献最难的部分大概是找到一个项目来做贡献。你可以查看 [Up For Grabs](https://up-for-grabs.net/#/) 并找一些感兴趣的项目。[First Timers Only](https://www.firsttimersonly.com/) 有更多的起步资源。别犹豫,联系项目维护者来了解更多有关于项目的东西,并了解他们在何处需要帮助。请坚持下去。找到一个适合你的项目可能会花费一些时间。 ### 告别“冒充者综合症” 一个常见的误区是你必须是一个程序员才能为开源项目做贡献。作为一个没有工程或计算机科学领域有关证书的、自学成材的贡献者,我能保证事实并非如此。文档往往开发项目中最价值但最被忽视的部分。这些项目经常缺少人手和资源来建立完善的、高质量的文档。这给你展现了一个绝佳机会来参与提交拉取请求或归档该项目的议题。你可以做到的! (LCTT 译注:<ruby> 冒充者综合症 <rt> Impostor Syndrome </rt></ruby>,又称自我能力否定倾向,指个体按照客观标准评价为已经获得了成功或取得成就,但是其本人却认为这是不可能的,他们没有能力取得成功,感觉是在欺骗他人,并且害怕被他人发现此欺骗行为的一种现象。) ### 从小处开始 查看你感兴趣的项目的仓库,找到可能存在的贡献指南并遵循。然后,寻找更新 README 文档或提交修改错别字的机会。没有什么贡献是微不足道的。项目维护者可能会为这些帮助感到高兴,而你也将会因把你提交的第一个的拉取请求收录进你的技术写作作品集而感到愉悦。 --- via: <https://opensource.com/article/21/11/technical-writing-open-source> 作者:[Ashley Hardin](https://opensource.com/users/ashleyhardin) 选题:[lujun9972](https://github.com/lujun9972) 译者:[yingmanwumen](https://github.com/yingmanwumen) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
13,975
用开源工具将任何网站变成 Linux 桌面应用
https://opensource.com/article/21/11/linux-apps-nativefier
2021-11-11T11:53:10
[ "Electron", "桌面应用" ]
https://linux.cn/article-13975-1.html
> > 使用 Nativefier 和 Electron 从任何网站创建桌面应用。 > > > ![](/data/attachment/album/202111/11/115302e25o5laz8sex5ea6.jpg "Text editor on a browser, in blue") Mastodon 是一个很好的开源、去中心化的社交网络。我每天都在使用 Mastodon,通过它的网页界面使用 Mastodon 可能是最常见的方式(尽管因为开源,它有许多不同的交互方式,包括基于终端的应用和移动应用),但我更喜欢专门的应用窗口。 最近,我发现了 [Nativefier](https://github.com/nativefier/nativefier),现在我可以在我的 Linux 桌面上把 Mastodon 或其他任何网页应用作为桌面应用来使用。Nativefier 将一个 URL 用 Electron 框架包装起来,它将开源的 Chromium 浏览器作为后端,但使用自己的可执行程序运行。Nativefier 采用 MIT 许可证,可用于 Linux、Windows 和 MacOS。 ### 安装 Nativefier Nativefier 需要 Node.js。 安装 Nativefier 只需运行: ``` $ sudo npm install -g nativefier ``` 在我的 Ubuntu 桌面上,我必须先升级 NodeJS,所以当你安装 Nativefier 时,一定要检查需要哪个 Node 版本。 安装完毕后,你可以检查你的 Nativefier 的版本,以验证它是否已经安装: ``` $ nativefier --version 45.0.4 ``` 运行 `nativefier --help` 列出了应用支持的所有选项。 ### 设置 我建议你在开始用 Nativefier 创建应用之前,创建一个名为 `~/NativeApps` 的新文件夹。这有助于保持你的应用有序。 ``` $ mkdir ~/NativeApps cd ~/NativeApps ``` ### 为 Mastodon 创建一个应用程序 我将首先为 [mastodon.technology](https://mastodon.technology/) 创建一个应用。 使用以下命令: ``` $ nativefier --name Mastodon \ --platform linux --arch x64 \ --width 1024 --height 768 \ --tray --disable-dev-tools \ --single-instance https://mastodon.technology ``` 这个例子中的选项做了以下工作: * `--name`:设置应用的名称为 Mastodon * `--platform`:设置应用程序的平台为 Linux * `--arch x64`:设置架构为 x64 * `--width 1024 --height 768`:设置应用启动时的大小 * `--tray`:为应用创建一个托盘图标 * `--disable-dev-tools`:禁用 Chrome 开发工具 * `--single-instance`:只允许应用有一个实例 运行这条命令会显示以下输出: ``` Preparing Electron app... Converting icons... Packaging... This will take a few seconds, maybe minutes if the requested Electron isn't cached yet... Packaging app for platform linux x64 using electron v13.4.0 Finalizing build... App built to /home/tux/NativeApps/Mastodon-linux-x64, move to wherever it makes sense for you and run the contained executable file (prefixing with ./ if necessary) Menu/desktop shortcuts are up to you, because Nativefier cannot know where you're going to move the app. Search for "linux .desktop file" for help, or see https://wiki.archlinux.org/index.php/Desktop_entries ``` 输出显示,文件被放置在 `/home/tux/NativeApps/Mastodon-linux-x64`。当你 `cd` 进入这个文件夹,你会看到一个名为 `Mastodon` 的文件。这是启动该应用的主要可执行文件。在你启动它之前,你必须给它适当的权限。 ``` $ cd Mastodon-linux-x64 chmod +x Mastodon ``` 现在,执行 `./Mastodon` 就可以看到你的 Linux 应用启动了! ![Mastodon app launched](/data/attachment/album/202111/11/115312j6cfxlx9fl90tbje.png "Mastodon app launched") ### 为我的博客创建一个应用 为了好玩,我也要为我的博客创建一个应用。如果没有 Linux 应用,拥有一个技术博客有什么用? ![Ayush Sharma blog](/data/attachment/album/202111/11/115313r07k5ll6d2gmsm5l.png "Ayush Sharma blog") 命令是: ``` $ nativefier -n ayushsharma \ -p linux -a x64 \ --width 1024 --height 768 \ --tray --disable-dev-tools \ --single-instance https://ayushsharma.in $ cd ayushsharma-linux-x64 chmod +x ayushsharma ``` ### 为 [findmymastodon.com](http://findmymastodon.com) 创建一个应用 最后,这是为我的宠物项目 [findmymastodon.com](https://findmymastodon.com/) 制作的应用。 ![Find my mastodon website](/data/attachment/album/202111/11/115313vdggkfxsk2wiyfb7.png "Find my mastodon website") 命令是: ``` $ nativefier -n findmymastodon \ -p linux -a x64 \ --width 1024 --height 768 \ --tray --disable-dev-tools \ --single-instance https://findmymastodon.com $ cd findmymastodon-linux-x64 chmod +x findmymastodon ``` ### 创建 Linux 桌面图标 应用已经创建并可以执行了,现在是创建桌面图标的时候了。 作为示范,以下是如何为 Mastodon 启动器创建一个桌面图标。首先,下载一个 [Mastodon](https://icons8.com/icons/set/mastodon) 的图标。将该图标放在其 Nativefier 应用目录下,名为 `icon.png`。 然后创建一个名为 `Mastodon.desktop` 的文件并输入以下文本: ``` [Desktop Entry] Type=Application Name=Mastodon Path=/home/tux/NativeApps/Mastodon-linux-x64 Exec=/home/tux/NativeApps/Mastodon-linux-x64/Mastodon Icon=/home/tux/NativeApps/Mastodon-linux-x64/icon.png ``` 你可以把 `.desktop` 文件移到你的 Linux 桌面上,把它作为一个桌面启动器。你也可以把它复制到 `~/.local/share/applications` 中,这样它就会出现在你的应用菜单或活动启动器中。 ### 总结 我喜欢为我经常使用的工具配备专门的应用。我最喜欢的一个 Mastodon 应用特点是,当我登录到 Mastodon 之后,我就不必再次登录了! Nativefier 在底层运行 Chromium。所以它能够像其他浏览器一样记住你的会话。我想特别感谢 Nativefier 团队,他们让 Linux 桌面离完美更近了一步。 本文最初发表在 [作者的网站](https://ayushsharma.in/2021/10/make-linux-apps-for-notion-mastodon-webapps-using-nativefier) 上,并经授权转载。 --- via: <https://opensource.com/article/21/11/linux-apps-nativefier> 作者:[Ayush Sharma](https://opensource.com/users/ayushsharma) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Mastodon is a great open source, decentralised social network. I use Mastodon every day, and it's probably most common to use Mastodon through its web interface (although being open source, there are many different ways to interact with it, including terminal-based applications and mobile apps), but I prefer dedicated application windows. Recently, I discovered [Nativefier](https://github.com/nativefier/nativefier), and I can now enjoy Mastodon, or any other web app, as a desktop application on my Linux desktop. Nativefier takes a URL and wraps it with the Electron framework, which runs the open source Chromium browser as its backend but runs as its own executable application. Nativefier is licensed under the MIT license and is available for Linux, Windows, and macOS. ## Installing Nativefier Nativefier requires Node.js Installing Nativefier is as simple as running: `$ sudo npm install -g nativefier` On my Ubuntu desktop, I had to upgrade NodeJS first, so be sure to check what versions of Node is required when you install Nativefier. Once installed, you can check your version of Nativefier to verify that it's been installed: ``` $ nativefier --version 45.0.4 ``` Running `nativefier --help` lists all options the app supports. ## Setup I recommend that you create a new folder called `~/NativeApps ` before you start creating apps with Nativefier. This helps keep your applications nice and organized. ``` $ mkdir ~/NativeApps cd ~/NativeApps ``` ## Creating an app for Mastodon I'll start by creating an app for [mastodon.technology](https://mastodon.technology/). Use the command: ``` $ nativefier --name Mastodon \ --platform linux --arch x64 \ --width 1024 --height 768 \ --tray --disable-dev-tools \ --single-instance https://mastodon.technology ``` The options in this example do the following: `--name` : Sets the app name to Mastodon`--platform` : Sets the app's platform to Linux- --arch x64: Sets the architecture to x64 `--width 1024 --height 768` : Sets the apps' dimensions on launch`--tray` : Creates a tray icon for the app`--disable-dev-tools` : Disables Chrome dev tools`--single-instance` : Only allows one instance of the app Running that single command shows the following output: ``` Preparing Electron app... Converting icons... Packaging... This will take a few seconds, maybe minutes if the requested Electron isn't cached yet... Packaging app for platform linux x64 using electron v13.4.0 Finalizing build... App built to /home/tux/NativeApps/Mastodon-linux-x64, move to wherever it makes sense for you and run the contained executable file (prefixing with ./ if necessary) Menu/desktop shortcuts are up to you, because Nativefier cannot know where you're going to move the app. Search for "linux .desktop file" for help, or see https://wiki.archlinux.org/index.php/Desktop_entries ``` The output shows that the files get placed in `/home/tux/NativeApps/Mastodon-linux-x64` . When you `cd` into this folder, you see a file named Mastodon. This is the main executable that launches the app. Before you can launch it, you must give it the appropriate permissions. ``` $ cd Mastodon-linux-x64 chmod +x Mastodon ``` Now, execute `./Mastodon` to see your Linux app launch! ![Mastodon app launched Mastodon app launched](https://opensource.com/sites/default/files/uploads/2_launch-mastodon-app.png) (Ayush Sharma, C C BY-SA 4.0) ## Creating an app for my blog For fun, I'm going to create an app for my blog website as well. What good is having a tech blog if there's no Linux app for it? ![Ayush Sharma blog Ayush Sharma blog](https://opensource.com/sites/default/files/uploads/3_ayush-shama-blog.png) (Ayush Sharma, C C BY-SA 4.0) The command: ``` $ nativefier -n ayushsharma \ -p linux -a x64 \ --width 1024 --height 768 \ --tray --disable-dev-tools \ --single-instance https://ayushsharma.in $ cd ayushsharma-linux-x64 chmod +x ayushsharma ``` ## Creating an app for findmymastodon.com And finally, here's an app for my pet project, [findmymastodon.com](https://findmymastodon.com/). ![Find my mastodon website Find my mastodon website](https://opensource.com/sites/default/files/uploads/4_find-my-mastodon-app.png) (Ayush Sharma, CC BY-SA 4.0) The command: ``` $ nativefier -n findmymastodon \ -p linux -a x64 \ --width 1024 --height 768 \ --tray --disable-dev-tools \ --single-instance https://findmymastodon.com $ cd findmymastodon-linux-x64 chmod +x findmymastodon ``` ## Creating Linux desktop icons With the apps created and the executables ready to go, it's time to create desktop icons. As a demonstration, here's how to create a desktop icon for the Mastodon launcher. First, download an icon for [Mastodon](https://icons8.com/icons/set/mastodon). Place the icon in its Nativefier app directory as `icon.png` . Then create a file called `Mastodon.desktop` and enter this text: ``` [Desktop Entry] Type=Application Name=Mastodon Path=/home/tux/NativeApps/Mastodon-linux-x64 Exec=/home/tux/NativeApps/Mastodon-linux-x64/Mastodon Icon=/home/tux/NativeApps/Mastodon-linux-x64/icon.png ``` You can move the `.desktop` file to your Linux desktop to have it as a desktop launcher. You can also place a copy of it in `~/.local/share/applications` so it shows up in your application menu or activity launcher. ## Conclusion I love having dedicated apps for tools I use often. My favorite feature about having an app for Mastodon is that once I log in to Mastodon, I don't have to log in again! Nativefier runs Chromium underneath. So it's able to remember your session just like any browser does. I'd like to give a special thanks to the Nativefier team for taking the Linux desktop one step closer to perfection. *This article originally appeared on the author's website and is republished with permission.* ## 1 Comment
13,977
使用 Linux cowsay 命令制作丰富多彩的节日问候
https://opensource.com/article/21/11/linux-cowsay
2021-11-12T10:15:47
[ "cowsay" ]
https://linux.cn/article-13977-1.html
> > 用这个有趣的 Linux 命令行工具来庆祝节日吧。 > > > ![](/data/attachment/album/202111/12/101540nq1nut3gzkzz1qus.jpg "Pumpkins painted for Day of the Dead") 你可能听说过这样一个小程序:它能接受输入信息(比如你通过键盘输入的消息),并输出一张引用了输入消息的牛的图像。这个小程序被称为 `cowsay`,之前我们已经 [介绍](https://opensource.com/article/18/12/linux-toy-cowsay) 过了。 所以,为了搞点有趣的事,我想用它来庆祝 <ruby> 亡灵节 <rt> Día de los Muertos </rt></ruby>(LCTT 译注:墨西哥传统的鬼节,著名动画电影《<ruby> 寻梦环游记 <rt> Coco </rt></ruby>》即以此为背景)。 除了牛之外,其实还有一些其他的可用图像。当安装 `cowsay` 时,程序会自动安装其他几个图像,并存储在 `/user/share/cowsay` 目录中。你可以用 `-l` 参数来获取图像列表。 ``` $ sudo dnf install cowsay $ cowsay -l ``` 实际上还有很多与 `cowsay` 或类似程序相关的开发活动。你可以创建自己的图像文件,也可以下载其他人制作的图像。例如,GitHub 上就有 [Charc0al 的 cowsay 文件转换器](https://charc0al.github.io/cowsay-files/converter/)。你可以用这一工具将自己的图片转换为 `cowsay` 所需的特殊 ASCII 格式文件。根据 Linux 或 FreeBSD 终端设置不同,你可能会启用颜色支持,而 `cowsay` 也可以显示彩色图像。Charc0al 的转换器也提供了许多现成的颜色文件。 我选择了“<ruby> 甲壳虫汁 <rt> Beetlejuice </rt></ruby>”(LCTT 译注:同名美国奇幻喜剧电影中的主角大法师)文件来开展我的“庆祝活动”。首先,我将 [beetlejuice.cow](https://raw.githubusercontent.com/charc0al/cowsay-files/master/cows/beetlejuice.cow) 文件保存到了 `/usr/share/cowsay` 目录。这个目录权限属于 root 用户,你可以先将该文件保存到家目录,然后再复制过去。此外我们还需要将该文件的读取权限赋予所有用户。 ``` $ sudo cp beetlejuice.cow /usr/share/cowsay $ sudo chmod o+r /usr/share/cowsay/beetlejuice.cow ``` 关注一下图像是如何生成的(过程很有趣)。首先将各种 ASCII 颜色控制代码设置为变量,然后用这些变量,以传统的 ASCII 艺术风格绘制图像。生成的图像几乎是全身的,并且在不滚动屏幕的情况下,不适配我的终端的高度,所以我编辑了一下该文件,删除了最后 15 行以降低高度。 这个图像也可以被 `cowsay` 程序检测到,并展示在列表中。 ``` $ cowsay -l Cow files in /usr/share/cowsay: beavis.zen beetlejuice blowfish bud-frogs bunny cheese cower default dragon ... ``` 现在,只要运行程序,并使用 `-f` 选项指定该图像就可以了。别忘了提供要输出的信息。 ``` $ cowsay -f beetlejuice "Happy Day of the Dead!" ``` ![ASCII display of Beetlejuice via cowsay](/data/attachment/album/202111/12/101550f36433zeeaq757qe.png) *“甲壳虫汁”祝你亡灵节快乐 (CC BY-SA 4.0)* `cowsay` 是 Linux 中一个有趣的搞怪小玩意。发挥你的创意,探索一下 `cowsay` 以及 ASCII 的艺术吧。 --- via: <https://opensource.com/article/21/11/linux-cowsay> 作者:[Alan Formy-Duval](https://opensource.com/users/alanfdoss) 选题:[lujun9972](https://github.com/lujun9972) 译者:[unigeorge](https://github.com/unigeorge) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
You may have heard of a small program that takes input, such as a message that you type, and outputs a picture of a cow quoting your message. It is called **cowsay**. It has been written about before here on [Opensource.com](https://opensource.com/article/18/12/linux-toy-cowsay). So, to have a little fun with it, I thought I'd use it to celebrate Día de los Muertos (Day of the Dead). In addition to a cow, there are other images available. When you install `cowsay ` it includes several other images, which the install stores in `/user/share/cowsay` . You can use the `-l` argument to get a list. ``` $ sudo dnf install cowsay $ cowsay -l ``` There's actually quite a bit of development activity related to `cowsay` and similar programs. It is possible to create your own image files or download images others have made. For instance, [Charc0al's cowsay file converter](https://charc0al.github.io/cowsay-files/converter/) is located on GitHub. You can use this tool to convert your own pictures to the special ASCII format file required by `cowsay` . Depending on your Linux or FreeBSD terminal settings, you may have color support enabled. The `cowsay` utility can display color images, as well. Charc0al's converter provides many ready-to-go color files. I chose to use the Beetlejuice file for my celebration. First, I saved the [beetlejuice.cow](https://raw.githubusercontent.com/charc0al/cowsay-files/master/cows/beetlejuice.cow) file to `/usr/share/cowsay` . This directory is owned by root, so you may have to save the file to your home directory first and then copy it. I also needed to give all users read access. ``` $ sudo cp beetlejuice.cow /usr/share/cowsay $ sudo chmod o+r /usr/share/cowsay/beetlejuice.cow ``` It is interesting to notice how the image is generated. The top sets various ASCII color control codes to variables. These variables are then used to draw the image in the traditional ASCII art style. The image is almost full-body and did not fit my terminal height without scrolling off the screen, so I edited the file and removed the last 15 lines to shorten it. The image is also detected by the `cowsay` program and appears in the list. ``` $ cowsay -l Cow files in /usr/share/cowsay: beavis.zen beetlejuice blowfish bud-frogs bunny cheese cower default dragon ... ``` Now, simply run the program and specify the image using the `-f` option. Don't forget to provide a message. `$ cowsay -f beetlejuice "Happy Day of the Dead!"` ![ASCII display of Beetlejuice via cowsay](https://opensource.com/sites/default/files/cowsay_beetlejuice.png) Beetlejuice says Happy Day of the Dead (CC BY-SA 4.0) The `cowsay` command is just another way to have some command-line fun with your Linux computer. Experiment with `cowsay` and ASCII art—get creative. ## 2 Comments
13,978
在苹果 M1 上运行 Linux 虚拟机变得容易了
https://news.itsfoss.com/canonical-multipass-linux-m1/
2021-11-12T15:55:27
[ "M1", "Multipass" ]
https://linux.cn/article-13978-1.html
![](/data/attachment/album/202111/12/155528mimf4ts44rpiiqdf.png) > > Canonical 使用户可以借助 Multipass(一个免费的虚拟机程序)在苹果 M1 上运行 Linux 虚拟机。 > > > 自从苹果推出 M1 芯片以来,人们为在其上运行 Linux 做出了许多努力。 尽管这项工作仍在进行中,但 Canonical 似乎已经实现了在苹果 M1 上以虚拟机(VM)形式运行 Linux(Ubuntu)。 ### 苹果 M1 上的 Linux 虚拟机 对大多数开发者来说,启动一个 Linux 虚拟机实例,并继续在他们的系统上工作是很方便的,这样不会中断任何工作。 不幸的是,在 M1 设备上启动和运行 Linux 实例不是一项轻松的任务。 虽然你可以用像 VMware 和 VirtualBox 这样的工具来创建虚拟机,但它们并不能在基于 ARM 的苹果 M1 芯片上工作。 截至目前,VMware 正在慢慢增加对其产品的支持,使其能够在苹果 M1 上工作。然而,这仍处于封闭测试阶段,对用户来说并不可行。 而 VirtualBox 还不支持 ARM 平台,也没有这方面的计划。 因此,你运行虚拟机的最佳选择是在 macOS 上使用 parallels 或 [UTM](https://github.com/utmapp/UTM)(免费)。因此,跨平台支持的选择相当有限。 此外,要使用 parallels 你需要购买许可证,这可能很昂贵。 ### Canonical 的 Multipass 1.8 是一个支持 M1 的免费虚拟机程序 [Multipass](https://multipass.run/) 是一个免费的虚拟机软件,旨在帮助你在苹果 M1 上创建 Linux 实例,而没有任何麻烦。 Canonical [宣布](https://ubuntu.com/blog/canonical-transforms-linux-on-mac) 发布了他们最新的 Multipass 1.8,终于增加了对苹果 M1 的支持,使其成为唯一可行的选择。它作为一个跨平台的虚拟机软件,可以帮助你运行 Ubuntu Linux。 在公告中,Canonical 产品经理 Nathan Hart 提到。 > > “Canonical 希望比市场上的其他选择更快地让开发者运行起来 Linux,而 Multipass 团队帮助实现了这一点。” > > > 在增加支持的同时,Multipass 1.8 还带来了一些有用的功能,包括。 * 别名,可以将虚拟机上的命令与主机操作系统关联起来。换句话说,你可以在虚拟机中无缝地直接从主机操作系统中运行一个软件。 * 统一的跨平台体验,支持 Windows、Linux、Mac OS(Intel/AMD 和 ARM 平台)。 Multipass 应该可以处理好配置问题,让你轻松地在苹果 M1 上创建/维护虚拟机。因此,你不需要任何人工干预,就可以让 Linux 在搭载 M1 的 macOS 机器内工作。 你可以在他们的 [官方网站](https://multipass.run/) 上了解到更多信息。 ### 总结 既然现在你可以使用 Canonical 的 Multipass 在苹果 M1 上启动一个 Linux 实例,你会考虑买一台苹果 M1 系统用于你的开发工作吗? 或者,还是你更喜欢使用 parallels 来在 M1 上运行 Linux?请在下面的评论中告诉我你的想法。 --- via: <https://news.itsfoss.com/canonical-multipass-linux-m1/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Ever since Apple introduced its M1 chips, numerous efforts have been made to run Linux on it. Even though that is still in progress, Canonical seems to have made it possible to run Linux (Ubuntu) as virtual machines (VMs) on Apple M1. ## Linux VMs on Apple M1 It is convenient for most developers to spin up a Linux VM instance and continue working on their system without interruptions. Unfortunately, getting a Linux instance up and running on M1 devices is not a straightforward task. While you have tools like VMware and VirtualBox to create virtual machines, it does not work on ARM-based Apple M1 silicon. As of now, VMware is slowly adding support for its products to work on Apple M1. However, that is still in closed beta and not feasible for users. And, when it comes to VirtualBox, it does not support the ARM platform yet and has no plans for it. So, your best bet to run virtual machines is using parallels or [UTM](https://github.com/utmapp/UTM?ref=news.itsfoss.com) (free) on macOS. Hence, pretty limited options that give you cross-platform support. Moreover, you need to purchase a license to use parallels, which could be expensive. ## Canonical’s Multipass 1.8 is a Free Virtual Machine Program With M1 Support [Multipass](https://multipass.run/?ref=news.itsfoss.com) is a free VM software that aims to help you create Linux instances on Apple M1 without any hassle. Canonical [announced](https://ubuntu.com/blog/canonical-transforms-linux-on-mac?ref=news.itsfoss.com) the release of their latest Multipass 1.8 that finally adds support for Apple M1, making it the only viable choice as a cross-platform virtual machine software that helps you run Ubuntu Linux. In the announcement, Canonical product manager Nathan Hart mentions: “Canonical wants to get developers running on Linux faster than any other option on the market, and the Multipass team has helped accomplish that.” Along with the addition of support, Multipass 1.8 also brings in some useful features that include: - Aliases to tie commands on the virtual machine to the host OS. In other words, you can run a software in the VM directly from your host OS seamlessly. - Unified cross-platform experience with Windows, Linux, mac OS (Intel/AMD and ARM platform) support. Multipass should handle the configuration and let you easily create/maintain a virtual machine on Apple M1. So, you wouldn’t need any manual intervention to make Linux work within an M1-powered macOS machine. You can find out more about it on their official website. ## Wrapping Up Considering now that you can use Canonical’s Multipass to spin up a Linux instance on Apple M1, would you consider getting an Apple M1 system for your development work? Or, do you prefer using parallels to run Linux on M1? Let me know your thoughts in the comments below. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,980
《极限竞速:地平线 5》登陆 Linux 了吗?有可能你已经玩起来了
https://news.itsfoss.com/forza-horizon-5-linux/
2021-11-13T11:54:00
[ "游戏", "Steam" ]
https://linux.cn/article-13980-1.html
> > 《极限竞速:地平线 5》是一款非常受欢迎的赛车游戏。虽然它还没有发布 Linux 版,但看起来 Valve 的 Proton 可能就是让它跑起来的答案! > > > ![](/data/attachment/album/202111/13/115411d3gqygmk202f9wyy.jpg) 《极限竞速:地平线 5》是一款新的赛车电子游戏,由 Playground Games 开发,Xbox 游戏工作室发行。 在正式发布之前,已经有大约 100 万玩家通过高级版提前进入了游戏。 虽然该游戏的视觉效果和对旧硬件的优化令人叹为观止,但它是又一款只在 Windows 平台上运行的游戏。 幸运的是,它也可以在 Steam 上玩。因此,有可能在 Linux 上使用 Proton 兼容层来尝试它。 ### Linux 上的《极限竞速:地平线 5》似乎成为现实 最初,在 Linux 上运行的《极限竞速:地平线 4》的状态很差。根据 ProtonDB 上的报告,它是不可玩的。 随着 Proton(或 [SteamPlay for Linux](https://itsfoss.com/steam-play/))的改进,现在有了一个银色评价。仍然不令人满意,但总比没有好。 而且,到了《极限竞速:地平线 5》并没有变得更好,它在 [ProtonDB](https://www.protondb.com/app/1551360) 上有一个不可玩的评价。 不过,我注意到有几个人在尝试运行《极限竞速:地平线 5》时获得了成功。 Jeremy Soller(System76 的工程师)分享了一条推特,可以看到他在 Pop!\_OS 21.10 Beta 上玩《极限竞速:地平线 5》: > > 炸裂了! > > > 《极限竞速:地平线 5》 > > > Proton 前沿实验版 > > > Pop!\_OS 21.10 Beta > > > 正式发布后,你们今晚就能玩了 > > > ![](/data/attachment/album/202111/13/115447spm01um079t1j6dg.jpg) > > > -- Jeremy Soller(@jeremy\_soller)[2021 年 11 月 10 日](https://twitter.com/jeremy_soller/status/1458568707798536200?ref_src=twsrc%5Etfw) > > > 而且,并不是只是他一个人,Win-staging 维护者和 Proton-GE 开发者 Tom(又名 GloriousEggroll)也分享了一条在 Linux 上玩《极限竞速:地平线 5》的推特: > > 对于一个 5 天前发布的游戏来说,Linux 的表现还不错 \o/ < 插入它运行的样子 gif> > > > ![](/data/attachment/album/202111/13/115454xojhllgyy30j4hhp.jpg) > > > -- GloriousEggroll(@GloriousEggroll)[2021 年 11 月 11 日](https://twitter.com/GloriousEggroll/status/1458590821075361794?ref_src=twsrc%5Etfw) > > > 此外,GloriousEggroll 在推特上提到: > > Paul(wine 的开发者之一)向 Proton 实验版推送了修正,此外还有 vkd3d 中需要的修正。我已经把它们移植到了 proton-ge 上(还有 battleye 补丁和 CEG drm 补丁)。 > > > 所以,看起来你可以使用 Proton 的最新的前沿实验版玩《地平线5》了。 当然,这对每个人来说都不是一个理想的解决方案。但是,很高兴知道,最新的 Proton 前沿实验版使(在 Steam 上)玩《极限竞速:地平线 5》成为可能。 ### 你应该在 Steam 上为 Linux 购买《极限竞速:地平线 5》吗? 如果你的目标是专门在 Linux 上玩这个游戏,你或许应该等一等。 根据 Proton 上的 [GitHub 议题讨论](https://github.com/ValveSoftware/Proton/issues/5285),该游戏似乎存在一些问题,即使你使用 Proton 的前沿实验版。 但是,如果你想帮助提交 bug 报告并进行测试,那么请尝试一下。 当然,如果你配置了 Windows 的双启动,或者有另一个 Windows 系统,如果你喜欢,你可以购买这个游戏。 希望随着下一个 Proton 实验版或稳定版的发布,我们可能会得到对 Forza Horizon 5 的必要支持。 你对 Linux 上的《极限竞速:地平线 5》有什么看法?自己测试过吗? --- via: <https://news.itsfoss.com/forza-horizon-5-linux/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Forza Horizon 5 is a new racing video game developed by Playground Games and published by Xbox Game Studios. Before its official launch, it already had **~1 million players** via the premium edition, which enabled early access to the game. While the game is breathtaking with its visuals and optimization for older hardware, it is yet another Windows-only game. Fortunately, it is also available on Steam. So, there is a possibility of trying it out using the proton compatibility layer on Linux. ## Forza Horizon 5 on Linux Seems Like a Reality Initially, the state of Forza Horizon 4 running on Linux was poor. It was unplayable as per the reports on ProtonDB. With improvements to Proton (or [SteamPlay for Linux](https://itsfoss.com/steam-play/?ref=news.itsfoss.com)), now there’s a silver rating to it. It’s still not satisfactory, but better than nothing. And, the story doesn’t get better with Forza Horizon 5, with an unplayable rating on [ProtonDB](https://www.protondb.com/app/1551360?ref=news.itsfoss.com). However, I noticed a few individuals have succeeded in their attempts to run Forza Horizon 5. **Jeremy Soller** (a System76 engineer) shared a tweet where he can be seen playing Forza Horizon 5 on Pop!_OS 21.10 Beta: And, he wasn’t alone; Tom (aka GloriousEggroll), Wine-staging maintainer and Proton-GE developer, also shared a tweet playing Forza Horizon 5 on Linux: Furthermore, GloriousEggroll mentions in the tweet thread: Paul (one of the wine devs) pushed fixes to proton experimental, in addition to a fix that was needed in vkd3d. I ported them over to proton-ge already (along with the battleye patches -and- CEG drm patches). So, it looks like you can play Forza Horizon 5 using Proton’s latest experimental bleeding-edge version. Of course, this is not an ideal solution for everyone. But, it is good to know that the latest Proton Experimental bleeding-edge makes it possible to play Forza Horizon 5 (on Steam). ## Should You Get Forza Horizon 5 on Steam for Linux? If you are aiming to play it on Linux exclusively, you may want to wait it out. As per a [GitHub issue thread](https://github.com/ValveSoftware/Proton/issues/5285?ref=news.itsfoss.com) on Proton, it appears that there are some issues with the game, even if you use the bleeding-edge version of Proton Experimental. But, if you want to help generate a bug report and test it out, feel free to try it out! Of course, if you have dual-boot configured with Windows or have another Windows-powered system, you can purchase the game if you like. Hopefully, with the next Proton Experimental or Stable release, we may get the necessary support for Forza Horizon 5! *What do you think about Forza Horizon 5 on Linux? Have you tested it for yourself? * ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,981
如何更新 Linux 的符号链接
https://opensource.com/article/21/11/update-linux-file-system-link
2021-11-13T18:56:33
[ "链接", "符号链接" ]
https://linux.cn/article-13981-1.html
> > 链接一直是 UNIX 文件系统的一个独特的高级功能。 > > > ![](/data/attachment/album/202111/13/185626ubb832pphjhlpmly.jpg "Links") UNIX 和 Linux 用户发现链接有很多用途,特别是符号链接。我喜欢使用符号链接的一种方式是管理各种 IT 设备的配置备份。 我有一个目录结构,用来存放我的文档、更新及网络上其他和计算机和设备有关的文件。设备可以包括路由器、接入点、NAS 服务器和笔记本电脑,通常有不同的品牌和版本。配置备份本身可能在目录树的深处,例如 `/home/alan/Documents/network/device/NetgearRL5000/config`。 为了简化备份过程,我在主目录中有一个名为 `Configuration` 的目录。我使用这个目录的符号链接来指向特定的设备目录: ``` :~/Configuration/ $ ls -F1 Router@ Accesspoint@ NAS@ ``` **注意**:`ls` 命令的 `-F` 选项在每个文件名上附加特殊字符以表示其类型。如上所示,`@` 符号表示这些是链接。 ### 创建一个链接 符号链接 `Router` 指向我的 Netgear RL5000 的 `config` 目录。创建它的命令是 `ln -s`: ``` $ ln -s /home/alan/Documents/network/device/NetgearRL5000/config Router ``` 然后,用 `ls -l` 看一下并确认: ``` :~/Configuration/ $ ls -l Router -> /home/alan/Documents/network/device/NetgearRL5000/config NAS -> /home/alan/Documents/network/device/NFSBox/config ... ``` 这样做的好处是,当对这个设备进行维护时,我只需进入 `~/Configuration/Router`。 如果我决定用一个新的型号替换这个路由器,使用符号链接的第二个好处就很明显了。我可能会把旧的路由器改成一个接入点。因此,它的目录并没有被删除。相反,我有一个新的目录,对应于新的路由器,也许是华硕 DF-3760。我创建这个目录并确认它的存在: ``` $ mkdir -p ~/Documents/network/device/ASUSDF-3760/config ``` ``` :~/Documents/network/device/ $ ls NetgearRL5000 ASUSDF-3760 NFSBox ... ``` 另一个例子是,如果你的办公室里有几个接入点。你可以使用符号链接在逻辑上代表每一个,用一个通用的名字,如 `ap1`,`ap2`,等等,或者你可以使用描述性的词语,如 `ap_floor2`,`ap_floor3`,等等。这样,当物理设备随时间变化时,你不必持续更新任何可能管理它们的进程,因为它们是在处理链接而不是实际的设备目录。 ### 更新一个链接 由于我的主路由器已经改变,我想让路由器的符号链接指向它的目录。我可以使用 `rm` 和 `ln` 命令来删除和创建一个新的符号链接,但是有一种方法可以只用 `ln` 命令和几个选项就可以一步完成: ``` :~/Configuration/ $ ln -vfns ~/Documents/network/device/ASUSDF-3760/config/ Router 'Router' -> '/home/alan/Documents/network/device/ASUSDF-3760/config/' :~/Configuration/ $ ls -l Router -> /home/alan/Documents/network/device/ASUSDF-3760/config NAS -> /home/alan/Documents/network/device/NFSBox/config ``` 根据手册页,这些选项如下: * `-v`、`--verbose`:打印每个链接文件的名称 * `-f`、`--force`:删除目标文件(有必要,因为已经存在一个链接) * `-n`、`--no-dereference`:如果链接名是一个目录的符号链接,就把它当作一个正常的文件 * `-s`、`--symbolic`:制作符号链接而不是硬链接 ### 总结 链接是 UNIX 和 Linux 文件系统中最强大的功能之一。其他操作系统也曾试图模仿这种能力,但由于他们的文件系统缺乏基本的链接设计,这些系统从来没有工作得那么好,也没有那么可用。 上面的演示只是利用链接在生活生产环境中无缝浏览不断变化的目录结构的众多可能性中的一种。链接提供了一个永远不会长期静态的组织所需的灵活性。 --- via: <https://opensource.com/article/21/11/update-linux-file-system-link> 作者:[Alan Formy-Duval](https://opensource.com/users/alanfdoss) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
UNIX and Linux users find many uses for links, particularly symbolic links. One way that I like to use symbolic links is to manage configuration backups of various IT equipment. I have a directory structure to hold everything related to documentation, updates, and other files for the computers and devices on my network. Devices can include routers, access points, NAS servers, and laptops, often of different brands and versions. The configuration backups themselves might be deep within the directory tree, e.g. `/home/alan/Documents/network/device/NetgearRL5000/config` . To simplify the backup process, I have a directory in my home called `Configuration` . I use symbolic links from this directory to point to the specific device directory: ``` :~/Configuration/ $ ls -F1 Router@ Accesspoint@ NAS@ ``` **Note**: The `-F` option of the `ls` command appends special characters to each file name to represent its type. As shown above, the `@` symbol indicates that these are links. ## Creating a link The symbolic link **Router** points to the `config` directory of my Netgear RL5000. The command to create it is `ln -s:` `$ ln -s /home/alan/Documents/network/device/NetgearRL5000/config Router` Then, take a look and confirm with `ls -l:` ``` :~/Configuration/ $ ls -l Router -> /home/alan/Documents/network/device/NetgearRL5000/config NAS -> /home/alan/Documents/network/device/NFSBox/config ... ``` The advantage is that when performing maintenance on this device, I simply browse to `~/Configuration/Router` . The second advantage of using a symbolic link becomes evident if I decide to replace this router with a new model. I might re-task the old router to be an access point. Therefore, its directory does not get deleted. Instead, I have a new directory that corresponds to the new router, perhaps an ASUS DF-3760. I create the directory and confirm its existence: `$ mkdir -p ~/Documents/network/device/ASUSDF-3760/config` ``` :~/Documents/network/device/ $ ls NetgearRL5000 ASUSDF-3760 NFSBox ... ``` Another example could be if you have several access points throughout your offices. You can use symbolic links to represent each one logically with either a generic name, such as `ap1` , `ap2` , and so on, or you can use descriptive words such as `ap_floor2` , `ap_floor3` , etc. This way, as the physical devices change over time, you do not have to continuously update any processes that might be managing them as they are addressing the links rather than the actual device directories. ## Updating a link Since my main router has changed, I want the router's symbolic link to point to its directory. I could use the `rm` and `ln` commands to remove and create a new symbolic link, but there is a way to do this in one step using only the `ln` command with a few options: ``` :~/Configuration/ $ ln -vfns ~/Documents/network/device/ASUSDF-3760/config/ Router 'Router' -> '/home/alan/Documents/network/device/ASUSDF-3760/config/' :~/Configuration/ $ ls -l Router -> /home/alan/Documents/network/device/ASUSDF-3760/config NAS -> /home/alan/Documents/network/device/NFSBox/config ``` The options, according to the man page, are as follow: **-v, --verbose** print name of each linked file **-f, --force** remove destination file (necessary since a link already exists) **-n, --no-dereference** treat LINK_NAME as a normal file if it is a symbolic link to a directory **-s, --symbolic** make symbolic links instead of hard links ## Wrap up Links are one of the most powerful features of UNIX and Linux file systems. Other operating systems have tried to mimic this capability, but those never worked as well or were as usable due to the lack of a fundamental link design in their file systems. The demonstration above is only one possibility of many to take advantage of links for seamlessly navigating an ever-changing directory structure in a living production environment. Links provides the flexibility needed in an organization that is never static for long. ## 2 Comments
13,983
扩展一个 GraphQL 网站
https://theartofmachinery.com/2020/06/29/scaling_a_graphql_site.html
2021-11-14T11:34:20
[ "GraphQL", "扩展", "伸缩" ]
https://linux.cn/article-13983-1.html
![](/data/attachment/album/202111/14/113411shrp6jpp3a8x1cjq.jpg) 我通常会抽象地总结我为他人所做的工作(出于显而易见的原因),但是我被允许公开谈论一个网站:[Vocal](https://vocal.media) 。我去年为它做了一些 SRE 工作。实际上早在 2 月份,我就在 [GraphQL 悉尼会议上做过一次演讲](https://www.meetup.com/en-AU/GraphQL-Sydney/events/267681845/),不过这篇博客推迟了一点才发表。 Vocal 是一个基于 GraphQL 的网站,它获得了人们的关注,然后就遇到了可扩展性问题,而我是来解决这个问题的。这篇文章会讲述我的工作。显然,如果你正在扩展一个 GraphQL 站点,你会发现这篇文章很有用,但其中大部分内容讲的都是当一个站点获得了足够的流量而出现的必须解决的技术问题。如果你对站点可扩展性有兴趣,你可能想先阅读 [最近我发表的一系列关于可扩展性的文章](https://theartofmachinery.com/2020/04/21/what_is_high_traffic.html)。 ### Vocal ![](/data/attachment/album/202111/14/113422w9hzcf9iwus149qe.png) Vocal 是一个博客平台,内容包括日记、电影评论、文章评论、食谱、专业或业余摄影、美容和生活小贴士以及诗歌,当然,还有可爱的猫猫和狗狗照片。 ![](/data/attachment/album/202111/14/113423a9cagfxz9okaz70z.png) Vocal 的不同之处在于,它允许人们制作观众感兴趣的作品而获得报酬。作者的页面每次被浏览都可以获得一小笔钱,还能获得其他用户的捐赠。有很多专业人士在这个平台上展示他们的工作,但对于大多数普通用户来说,他们只是把 Vocal 当作一个兴趣爱好,碰巧还能赚些零花钱作为奖励。 Vocal 是新泽西初创公司 ~~[Jerrick Media](https://jerrick.media)~~ 的产品,更新:Jerrick Media 已经更名为 Creatd,在纳斯达克上市。2015 年,他们与 [Thinkmill](https://www.thinkmill.com.au/) 合作一起开发,Thinkmill 是一家悉尼中型软件开发咨询公司,擅长 JavaScript、React 和 GraphQL 开发。 ### 剧透 不幸的是,有人告诉我,由于法律原因,我不能提供具体的流量数字,但公开的信息可以说明。Alexa 对所有网站按照流量进行排名。这是我演讲中展示的 Alexa 排名图,从 2019 年 11 月到今年 2 月,Vocal 流量增长到全球排名第 5567 位。 ![去年 11 月到今年 2 月 Vocal 的全球排名从 9574 名增长到 5567 名](/data/attachment/album/202111/14/113423fmzgl6g665y2bedl.png) 曲线增长变慢是正常的,因为它需要越来越多的流量来赢得每个位置。Vocal 现在排名 4900 名左右,显然还有很长的路要走,但对于一家初创公司来说,这一点也不寒酸。大多数初创公司都很乐意与 Vocal 互换排名。 在网站升级后不久,Creatd 开展了一项营销活动,使流量翻了一番。在技术方面,我们要做的就是观察仪表盘上的上升的数字。自发布以来的 9 个月里,只有两个平台问题需要员工干预:[3 月份每五年一次的 AWS RDS 证书轮换](https://aws.amazon.com/blogs/database/amazon-rds-customers-update-your-ssl-tls-certificates-by-february-5-2020/),以及一款应用推出时遇到的 Terraform 错误。作为一名 SRE,我很高兴看到 Vocal 不需要太多的平台工作来保持运行。更新:该系统也抗过了 2020 年的美国大选,没有任何意外。 以下是本文技术内容的概述: * 技术和历史背景 * 从 MongoDB 迁移到 Postgres * 部署基础设施的改造 * 使应用程序兼容扩展措施 * 让 HTTP 缓存发挥作用 * 其他一些性能调整 ### 一些背景信息 Thinkmill 使用 [Next.js](https://github.com/vercel/next.js)(一个基于 React 的 Web 框架)构建了一个网站,和 [Keystone](https://www.keystonejs.com/) 在 MongoDB 前面提供的 GraphQL API 进行交互。Keystone 是一个基于 GraphQL 的无头 CMS 库:在 JavaScripy 中定义一个模式,将它与一些数据存储挂钩,并获得一个自动生成的 GraphQL API 用于数据访问。这是一个自由开源软件项目,由 Thinkmill 提供商业支持。 #### Vocal V2 Vocal 的第一版就受到了关注,它找到了一个喜欢它的用户群,并不断壮大,最终 Creatd 请求 Thinkmill 帮助开发 V2,并于去年 9 月成功推出。Creatd 员工避免了 [第二个系统效应](https://wiki.c2.com/?SecondSystemEffect),他们一般都是根据用户的反馈进行改变,所以他们 [主要是 UI 和功能更改,我就不赘述了](https://vocal.media/resources/vocal-2-0)。相反,我将讨论下我的工作内容:使新站点更加健壮和可扩展。 声明:我很感谢能与 Creatd 以及 Thinkmill 在 Vocal 上的合作,并且他们允许我发表这个故事,但 [我仍然是一名独立顾问](https://theartofmachinery.com/about.html),我写这篇文章没有报酬,甚至没有被要求写它,这仍然是我自己的个人博客。 ### 迁移数据库 Thinkmill 在使用 MongoDB 时遇到了几个可扩展性问题,因此决定升级到 Keystone 5 以利用其新的 Postgres 支持。 如果你从事技术工作的时间足够长,那你可能还记得 00 年代末的 “NOSQL” 营销,这可能听起来很有趣。NoSQL 的一个重要特点是,像 Postgres 这样的关系数据库(SQL)不像 MongoDB 这样“网站级规模”的 NoSQL 数据库那样具有可扩展性。从技术上将,这种说法是正确的,但 NoSQL 数据库的可扩展性来自它可以有效处理各种查询的折衷。简单的非关系数据库(如文档数据库和键值数据库)有其一席之地,但当它们用作应用的通用后端时,应用程序通常会在超出关系数据库的理论扩展限制之前,就超出了数据库的查询限制。Vocal 的原本的大多数数据库查询在 MongoDB 上运行良好,但随着时间推移,越来越多的查询需要特殊技巧才能工作。 在技术要求方面,Vocal 与维基百科非常相似。维基百科是世界上最大的网站之一,它运行在 MySQL(或者说它的分支 MariaDB)上。当然,这需要一些重要的工程来实现,但在可预见的未来,我认为关系数据库不会对 Vocal 的扩展构成严重威胁。 我做过一个比较,托管的 AWS RDS Postgres 实例的成本不到旧 MongoDB 实例的五分之一,但 Postgres 实例的 CPU 使用率仍然低于 10%,尽管它提供的流量比旧站点多。这主要是因为一些重要的查询在文档数据库架构下一直效率很低。 迁移的过程可以新写一篇博客文章来讲述,但基本上是 Thinkmill 开发人员构建了一个 [ETL 管道](https://en.wikipedia.org/wiki/Extract,_transform,_load),使用 [MoSQL](https://github.com/stripe/mosql) 来完成这项繁重的工作。由于 Keystone 对于 Postgres 支持仍然比较基础,但它是一个 FOSS 项目,所以我能够解决在 SQL 生成性能方面遇到的问题。对于这类事情,我总是推荐 Markys Winand 的 SQL 博文:[使用 Luke 索引](https://use-the-index-luke.com/) 和 [现代 SQL](https://modern-sql.com/)。他的文章很友好,甚至对那些暂时不太关注 SQL 人来说也是容易理解的,但他拥有你大多数需要的理论知识。如果你仍然有问题,一本好的、专注于即可性能的书可以帮助你。 ### 平台 #### 架构 V1 是几个 Node.js 应用,运行在 Cloudflare(作为 CDN)背后的单个虚拟专用服务器(VPS)上。我喜欢把避免过度工程化作为一个高度优先事项,所以我对这一架构竖起了大拇指。然而,在 V2 开始开发时,很明显,Vocal 已经超越了这个简单的架构。在处理巨大峰值流量时,它没有给 Thinkmill 开发人员提供很多选择,而且它很难在不停机情况下安全部署更新。 这是 V2 的新架构: ![Vocal V2 的技术架构,请求从 CDN 进入,然后经过 AWS 的负载均衡。负载均衡将流量分配到两个应用程序 “Platform” 和 “Website”。“Platform” 是一款 Keystone 应用程序,将数据存储在 Redis 和 Postgres 中。](/data/attachment/album/202111/14/113424grhvqzqr1kprjytr.svg) 基本上就是两个 Node.js 应用程序复制放在负载均衡器后面,非常简单。有些人认为可扩展架构要比这复杂得多,但是我曾经在一些比 Vocal 规模大几个数量级的网站工作过,它们仍然只是在负载均衡器后面复制服务,带有 DB 后端。你仔细想想,如果平台架构需要随着站点的增长而变得越来越复杂,那么它就不是真正“可扩展的”。网站可扩展性主要是解决那些破坏可扩展的实现细节。 如果流量增长得足够多,Vocal 的架构可能需要一些补充,但它变得更加复杂的主要原因是新功能。例如,如果(出于某种原因)Vocal 将来需要处理实时地理空间数据,那将是一个与博客文章截然不同的技术,所以我预期它会进行架构上的更改。大型网站架构的复杂性主要来自于复杂的功能。 不知道未来的架构应该是什么样子很正常,所以我总是建议你尽可能从简单开始。修复一个简单架构要比复杂架构更容易,成本也更低。此外,不必要的复杂架构更有可能出现错误,而这些错误将更难调试。 顺便说一下,Vocal 分成了两个应用程序,但这并不重要。一个常见的扩展错误是,以可扩展的名义过早地将应用分割成更小的服务,但将应用分割在错误的位置,从而导致更多的可扩展性问题。作为一个单体应用,Vocal 可以扩展的很好,但它的分割做的也很好。 #### 基础设施 Thinkmill 有一些人有使用 AWS 经验,但它主要是一个开发车间,需要一些比之前的 Vocal 部署更容易上手的东西。我最终在 AWS Fargate 上部署了新的 Vocal,这是弹性容器服务(ECS)的一个相对较新的后端。在过去,许多人希望 ECS 作为一个“托管服务运行 Docker 容器”的简单产品,但人们仍然必须构建和管理自己的服务器集群,这让人感到失望。使用 ECS Fargate,AWS 就可以管理集群了。它支持运行带有复制、健康检查、滚动更新、自动缩放和简单警报等基本功能的 Docker 容器。 一个好的替代方案是平台即服务(PaaS),比如 App Engine 或 Heroku。Thinkmill 已经在简单的项目中使用它们,但通常在其他项目中需要更大的灵活性。在 PaaS 上运行的网站规模要大得多,但 Vocal 的规模决定了使用自定义云部署是有经济意义的。 另一个明显的替代方案是 Kubernetes。Kubernetes 比 ECS Fargate 拥有更多的功能,但它的成本要高得多 —— 无论是资源开销还是维护(例如定期节点升级)所需的人员。一般来说,我不向任何没有专门 DevOps 员工的地方推荐 Kubernetes。Fargate 具有 Vocal 需要的功能,使得 Thinkmill 和 Creatd 能专心于网站改进,而不是忙碌于搭建基础设施。 另一种选择是“无服务器”功能产品,例如 AWS Lambda 或 Google 云。它们非常适合处理流量很低或很不规则的服务,但是 ECS Fargate 的自动伸缩功能足以满足 Vocal 的后端。这些产品的另一个优点是,它们允许开发人员在云环境中部署东西,但无需了解很多关于云环境的知识。权衡的结果是,无服务器产品与开发过程、测试以及调试过程紧密耦合。Thinkmill 内部已经有足够的 AWS 专业知识来管理 Fargate 的部署,任何知道如何开发 Node.js 简单的 Hello World 应用程序的开发人员都可以在 Vocal 上工作,而无需了解无服务器功能或 Fargate 的知识。 ECS Fargate 的一个明显缺点是供应商锁定。但是,避免供应商锁定是一种权衡,就像避免停机一样。如果你担心迁移,那么在平台独立性花费比迁移上更多的钱是没有意义的。在 Vocal 中,依赖于 Fargate 的代码总量小于 500 行 [Terraform](https://theartofmachinery.com/2019/02/16/talks.html)。最重要的是 Vocal 应用程序代码本身与平台无关,它可以在普通开发人员的机器上运行,然后打包成一个 Docker 容器,几乎可以运行在任何可以运行 Docker 容器的地方,包括 ECS Fargate。 Fargate 的另一个缺点是设置复杂。与 AWS 中的大多数东西一样,它处于一个 VPC、子网、IAM 策略世界中。幸运的是,这类东西是相对静态的(不像服务器集群一样需要维护)。 ### 制作一个可扩展的应用程序 如果你想轻松地运行一个大规模的应用程序,需要做一大堆正确的事情。如果你遵循 <ruby> <a href="https://12factor.net/"> 应用程序设计的十二个守则 </a> <rt> the Twelve-Factor App design </rt></ruby>,事情会变得容易,所以我不会在这里赘述。 如果员工无法规模化操作,那么构建一个“可扩展”系统就毫无意义 —— 就像在独轮车上安装喷气式发动机一样。使 Vocal 可扩展的一个重要部分是建立 CI/CD 和 [基础设施即代码](https://theartofmachinery.com/2019/02/16/talks.html) 之类的东西。同样,有些部署的思路也不值得考虑,因为它们使生产与开发环境相差太大(参阅 [应用程序设计守则第十守则](https://12factor.net/dev-prod-parity))。生产和开发之间的任何差异都会降低应用程序的开发速度,并且(在实践中)最终可能会导致错误。 ### 缓存 缓存是一个很大的话题 —— 我曾经做过 [一个关于 HTTP 缓存的演讲](https://www.meetup.com/en-AU/Port80-Sydney/events/lwcdjlyvjblb/),相对比较基础。我将在这里谈论缓存对于 GraphQL 的重要性。 首先,一个重要的警告:每当遇到性能问题时,你可能会想:“我可以将这个值放入缓存中吗,以便再次使用时速度更快?”**微基准测试 *总是* 告诉你:是的。** 然而,由于缓存一致性等问题,随处设置缓存往往会使整个系统 **变慢**。以下是我对于缓存的检查表: 1. 是否需要通过缓存解决性能问题 2. 再仔细想想(非缓存的性能往往更加健壮) 3. 是否可以通过改进现有的缓存来解决问题 4. 如果所有都失败了,那么可以考虑添加新的缓存 在 Web 系统中,你经常使用的一个缓存是 HTTP 缓存系统,因此,在添加额外缓存之前,试着使用 HTTP 缓存是一个好主意。我将在这篇文章中重点讨论这一点。 另一个常见的陷阱是使用哈希映射或应用程序内部其他东西进行缓存。[它在本地开发中效果很好,但在扩展时表现糟糕](https://theartofmachinery.com/2016/07/30/server_caching_architectures.html)。最好的办法是使用支持显式缓存库,支持 Redis 或 Memcached 这样的可插拔后端。 #### 基础知识 HTTP 规范中有两种类型缓存:私有和公共。私有缓存不会和多个用户共享数据 —— 实际上就是用户的浏览器缓存。其余的就是公共缓存。它们包括受你控制的(例如 CDN、Varnish 或 Nginx 等服务器)和不受你控制的(代理)。代理缓存在当今的 HTTPS 世界中很少见,但一些公司网络会有。 ![](/data/attachment/album/202111/14/113424b3d67sz63f86lbxf.svg) 缓存查找键通常基于 URL,因此如果你遵循“相同的内容,相同的 URL;不同的内容,不同的 URL” 规则,即,给每个页面一个规范的 URL,避免从同一个 URL 返回不同的内容这样“聪明”的技巧,缓存就会强壮一点。显然,这对 GraphQL API 端点有影响(我将在后面讨论)。 你的服务器可以采用自定义配置,但配置 HTTP 缓存的主要方法是在 Web 响应上设置 HTTP 头。最重要的标头是 `cache-control`。下面这一行说明所有缓存都可以缓存页面长达 3600 秒(一小时): ``` cache-control: max-age=3600, public ``` 对于针对用户的页面(例如用户设置页面),重要的是使用 `private` 而不是 `public` 来告诉公共缓存不要存储响应,防止其提供给其他用户。 另一个常见的标头是 `vary`,它告诉缓存,响应是基于 URL 之外的一些内容而变化。(实际上,它将 HTTP 头和 URL 一起添加到缓存键中。)这是一个非常生硬的工具,这就是为什么尽可能使用良好 URL 结构的原因,但一个重要的用例是告诉浏览器响应取决于登录的 cookie,以便在登录或注销时更新页面。 ``` vary: cookie ``` 如果页面根据登录状态而变化,你需要 `cache-control:private`(和 `vary:cookie`),即使是在公开的、已登出的页面版本上,以确保响应不会混淆。 其他有用的标头包括 `etag` 和 `last-modified`,但我不会在这里介绍它们。你可能仍然会看到一些诸如 `expires` 和 `pragma:cache` 这种老旧的 HTTP 标头。它们早在 1997 年就被 HTTP/1.1 淘汰了,所以我只在我想禁用缓存或者我感到偏执时才使用它们。 #### 客户端标头 鲜为人知的是,HTTP 规范允许在客户端请求中使用 `cache-control` 标头以减少缓存时间并获得最新响应。不幸的是,似乎大多数浏览器都不支持大于 0 的 `max-age` ,但如果你有时在更新后需要一个最新响应,`no-cache` 会很有用。 #### HTTP 缓存和 GraphQL 如上,正常的缓存键是 URL。但是 GraphQL API 通常只使用一个端点(比如说 `/api/`)。如果你希望 GraphQL 查询可以缓存,你需要查询参数出现在 URL 路径中,例如 `/api/?query={user{id}}&variables={"x":99}`(忽略了 URL 转义)。诀窍是将 GraphQL 客户端配置为使用 HTTP GET 请求进行查询(例如,[将 `apollo-link-http` 设置为 `useGETForQueries`](https://www.apollographql.com/docs/link/links/http/#options) )。 Mutation 不能缓存,所以它们仍然需要使用 HTTP POST 请求。对于 POST 请求,缓存只会看到 `/api/` 作为 URL 路径,但缓存会直接拒绝缓存 POST 请求。请记住,GET 用于非 Mutation 查询(即幂等),POST 用于 Mutation(即非幂等)。在一种情况下,你可能希望避免使用 GET 查询:如果查询变量包含敏感信息。URL 经常出现在日志文件、浏览器历史记录和聊天中,因此 URL 中包含敏感信息通常是一个坏主意。无论如何,像身份验证这种事情应该作为不可缓存的 Mutation 来完成,这是一个特殊的情况,值得记住。 不幸的是,有一个问题:GraphQL 查询往往比 REST API URL 大得多。如果你简单地切换到基于 GET 的查询,你会得到一些非常长的 URL,很容易超过 2000 字节的限制,目前一些流行的浏览器和服务器还不会接受它们。一种解决方案是发送某种查询 ID,而不是发送整个查询,即类似于 `/api/?queryId=42&variables={"x":99}`。Apollo GraphQL 服务器对此支持两种方式: 一种方法是 [从代码中提取所有 GraphQL 查询,并构建一个服务器端和客户端共享的查询表](https://www.apollographql.com/blog/persisted-graphql-queries-with-apollo-client-119fd7e6bba5)。缺点之一是这会使构建过程更加复杂,另一个缺点是它将客户端项目与服务器项目耦合,这与 GraphQL 的一个主要卖点背道而驰。还有一个缺点是 X 版本和 Y 版本的代码可能识别一组不同的查询,这会成为一个问题,因为 1:复制的应用程序将在更新推出或回滚期间提供多个版本,2:客户端可能会使用缓存的 JavaScript,即使你升级或降级服务器。 另一种方式是 Apollo GraphQL 所宣称的 [自动持久查询(APQ)](https://www.apollographql.com/blog/improve-graphql-performance-with-automatic-persisted-queries-c31d27b8e6ea)。对于 APQ 而言,查询 ID 是查询的哈希值。客户端向服务器发出请求,通过哈希查询。如果服务器无法识别该查询,则客户端会在 POST 请求中发送完整的查询,服务器会保存此次查询的散列值,以便下次识别。 ![](/data/attachment/album/202111/14/113424e8rono4j00ra8uwh.png) #### HTTP 缓存和 Keystone 5 如上所述,Vocal 使用 Keystone 5 生成 GraphQL API,而 Keystone 5 和 Apollo GraphQL 服务器配合一起工作。那么我们是如何设置缓存标头的呢? Apollo 支持 GraphQL 模式的<ruby> 缓存提示 <rt> cache hint </rt></ruby>。巧妙地是,Apollo 会收集查询涉及的所有内容的所有缓存提示,然后它会自动计算适当的缓存标头值。例如,以这个查询为例: ``` query userAvatarUrl { authenticatedUser { name avatar_url } } ``` 如果 `name` 的最长期限为 1 天,而 `avatar_url` 的最长期限为 1 小时,则整体缓存最长期限将是最小值,即 1 小时。`authenticatedUser` 取决于登录 cookie,因此它需要一个 `private` 提示,它会覆盖其他字段的 `public`,因此生成的 HTTP 头将是 `cache-control:max-age=3600,private`。 我 [对 Keystone 列表和字段添加了缓存提示支持](https://www.keystonejs.com/api/create-list/#cachehint)。以下是一个简单例子,在文档的待办列表演示中给一个字段添加缓存提示: ``` const keystone = new Keystone({ name: 'Keystone To-Do List', adapter: new MongooseAdapter(), }); keystone.createList('Todo', { schemaDoc: 'A list of things which need to be done', fields: { name: { type: Text, schemaDoc: 'This is the thing you need to do', isRequired: true, cacheHint: { scope: 'PUBLIC', maxAge: 3600, }, }, }, }); ``` #### 另一个问题:CORS 令人沮丧的是,<ruby> 跨域资源共享 <rt> Cross-Origin Resource Sharing </rt></ruby>(CORS)规则会与基于 API 网站中的缓存产生冲突。 在深入问题细节之前,让我们跳到最简单的解决方案:将主站点和 API 放在一个域名上。如果你的站点和 API 位于同一个域名上,就不必担心 CORS 规则(但你可能需要考虑 [限制 cookie](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Define_where_cookies_are_sent))。如果你的 API 专门用于网站,这是最简单的解决方案,你可以愉快地跳过这一节。 在 Vocal V1 中,网站(Next.js)和平台(Keystone GraphQL)应用程序处于不同域(`vocal.media` 和 `api.vocal.media`)。为了保护用户免受恶意网站的侵害,现代浏览器不会随便让一个网站与另一个网站进行交互。因此,在允许 `vocal.media` 向 `api.vocal.media` 发出请求之前,浏览器会对 `api.vocal.media` 进行“预检”。这是一个使用 `OPTIONS` 方法的 HTTP 请求,主要是询问跨域资源共享是否允许。预检通过后,浏览器会发出最初的正常请求。 令人沮丧的是,预检是针对每个 URL 的。浏览器为每个 URL 发出一个新的 `OPTIONS` 请求,服务器每次都会响应。[服务器没法说 `vocal.media` 是所有 `api.vocal.media` 请求的可信来源](https://lists.w3.org/Archives/Public/public-webapps/2012AprJun/0236.html) 。当所有内容都是对一个 API 端点的 POST 请求时,这个问题并不严重,但是在为每个查询提供 GET 式 URL 后,每个查询都因预检而延迟。更令人沮丧的是,HTTP 规范说 `OPTIONS` 请求不能被缓存,所以你会发现你所有的 GraphQL 数据都被完美地缓存在用户身旁的 CDN 中,但浏览器仍然必须向源服务器发出所有的预检请求。 如果你不能只使用一个共享的域,有几种解决方案。 如果你的 API 足够简单,你或许可以利用 [CORS 规则的例外](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests)。 某些缓存服务器可以配置为忽略 HTTP 规范,任何情况都会缓存 `OPTIONS` 请求。例如,基于 Varnish 的缓存和 AWS CloudFrone。这不如完全避免预检那么有效,但比默认的要好。 另一个很魔改的选项是 [JSONP](https://en.wikipedia.org/wiki/JSONP)。当心:如果做错了,那么可能会创建安全漏洞。 #### 让 Vocal 更好地利用缓存 让 HTTP 缓存在底层工作之后,我需要让应用程序更好地利用它。 HTTP 缓存的一个限制是它在响应级别上要么是全有要么是全无的。大多数响应都可以缓存,但如果一个字节不能缓存,那整个页面就无法缓存。作为一个博客平台,大多数 Vocal 数据都是可缓存的,但在旧网站上,由于右上角的菜单栏,几乎没有页面可以缓存。对于匿名用户,菜单栏将显示邀请用户登录或创建账号的链接。对于已登录用户,它会变成用户头像和用户个人资料菜单,因为页面会根据用户登录状态而变化,所以无法在 CDN 中缓存任何页面。 ![Vocal 的一个典型页面。该页面的大部分内容都是高度可缓存的内容,但在旧网站中,由于右上角有一个小菜单,实际上没有一个内容是可缓存的。](/data/attachment/album/202111/14/113424jvrh45z5eqaprh3a.png) 这些页面是由 React 组件的服务器端渲染(SSR)的。解决方法是将所有依赖于登录 cookie 的 React 组件,强制它们 [只在客户端进行延迟呈现](https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr)。现在,服务器会返回完全通用的页面,其中包含用于个性化组件(如登录菜单栏)的占位符。当页面在浏览器中加载时,这些占位符将通过调用 GraphQL API 在客户端填充。通用页面可以安全地缓存到 CDN 中。 这一技巧不仅提高了缓存命中率,还帮助改善了人们感知的页面加载时间。空白屏幕和旋转动画让我们不耐烦,但一旦第一个内容出现,它会分散我们几百毫秒的注意力。如果人们在社交媒体上点击一个 Vocal 帖子的链接,主要内容就会立即从 CDN 中出现,很少有人会注意到,有些组件直到几百毫秒后才会完全出现。 顺便说一下,另一个让用户更快地看到第一个内容的技巧是 [流式渲染](https://medium.com/the-thinkmill/progressive-rendering-the-key-to-faster-web-ebfbbece41a4),而不是等待整个页面渲染完成后再发送。不幸的是,[Node.js 还不支持这个功能](https://github.com/vercel/next.js/issues/1209)。 拆分响应来提高可缓存性也适用于 GraphQL。通过一个请求查询多个数据片段的能力通常是 GraphQL 的一个优势,但如果响应的不同部分具有差别很大的缓存,那么最好将它们分开。举个简单的例子,Vocal 的分页组件需要知道当前页面的页数和内容。最初,组件在一个查询中同时获取两个页面,但由于页面的总数是所有页面的一个常量,所有我将其设置为一个单独的查询,以便缓存它。 #### 缓存的好处 缓存的明显好处是它减轻了 Vocal 后端服务器的负载。这很好。但是依赖缓存来获得容量是危险的,你仍然需要一个备份计划,以便当有一天你不可避免地放弃缓存。 提高页面响应速度是使用缓存是一个更好的理由。 其他一些好处可能不那么明显。峰值流量往往是高度本地化的。如果一个有很多社交媒体粉丝的人分享了一个页面的链接,那么 Vocal 的流量就会大幅上升,但主要是指向分享的那个页面及其元素。这就是为什么缓存擅长吸收最糟糕的流量峰值,它使后端流量模式相对更平滑,更容易被自动伸缩处理。 另一个好处是<ruby> 优雅的退化 <rt> graceful degradation </rt></ruby>。即使后端由于某些原因出现了严重的问题,站点最受欢迎的部分仍然可以通过 CDN 缓存来提供服务。 ### 其他的性能调整 正如我常说的,可扩展的秘诀不是让事情变得更复杂。它只是让事情变得不比需要的更复杂,然后彻底解决所有阻碍扩展的东西。扩展 Vocal 的规模涉及到许多小事,在这篇文章中无法一一说明。 一个经验:对于分布式系统中难以调试的问题,最困难的部分通常是获取正确的数据,从而了解发生的原因。我能想到很多时候,我被困住了,只能靠猜测来“即兴发挥”,而不是想办法找到正确的数据。有时这行得通,但对复杂的问题却不行。 一个相关技巧是,你可以通过获取系统中每个组件的实时数据(甚至只是 `tail -F` 的日志),在不同的窗口中显示,然后在另一个窗口中单击网站来了解很多信息。比如:“为什么切换这个复选框会在后台产生这么多的 DB 查询?” 这里有个修复的例子。有些页面需要几秒钟以上的时间来呈现,但这个情况只会在部署环境中使用 SSR 时会出现。监控仪表盘没有显示任何 CPU 使用量峰值,应用程序也没有使用磁盘,所以这表明应用程序可能正在等待网络请求,可能是对后端的请求。在开发环境中,我可以使用 [sysstat 工具](https://github.com/sysstat/sysstat/)来记录 CPU、RAM、磁盘使用情况,以及 Postgres 语句日志和正常的应用日志来观察应用程序是如何工作的。[Node.js 支持探测跟踪 HTTP 请求](https://github.com/sysstat/sysstat/),比如使用 [bpftrace](https://theartofmachinery.com/2019/04/26/bpftrace_d_gc.html),但处于某些无聊的原因,它们不能在开发环境中工作,所以我在源代码中找到了探针,并创建了一个带有请求日志的 Node.js 版本。我使用 [tcpdump](https://danielmiessler.com/study/tcpdump/) 记录网络数据,这让我找到了问题所在:对于网站发出的每一个 API 请求,都要创建一个新的网络连接到 “Platform”。(如果这都不起作用,我想我会在应用程序中添加请求跟踪功能。) 网络连接在本地机器上速度很快,但在现实网络上却不可忽略。建立加密连接(比在生产环境中)需要更长时间。如果你向一个服务器(比如一个 API)发出大量请求,保持连接打开并重用它是很重要的。浏览器会自动这么做,但 Node.js 默认不会,因为它不知道你是否发出了很多请求,所以这个问题只出现在 SSR 上。与许多漫长的调试过程一样,修复却非常简单:只需将 SSR 配置为 [保持连接存活](https://www.npmjs.com/package/agentkeepalive),这样会使页面的呈现时间大幅下降。 如果你想了解更多这方面的知识,我强烈建议你阅读《[高性能浏览器网络](https://hpbn.co/)》这本书(可免费在线阅读),并跟进 [Brendan Gregg 发表的指南](http://www.brendangregg.com/)。 ### 你的站点呢? 实际上,我们还可以做很多事情来提升 Vocal 的速度,但我们没有全做。这是因为在初创公司和在大公司身为一个固定员工做 SRE 工作还是有很大区别的。我们的目标、预算和发布日期都很紧张,但最终我们的网站得到了很大改善,给了用户他们想要的东西。 同样的,你的站点有它自己的目标,并且可能与 Vocal 有很大的不同。然而,我希望这篇文章和它的链接至少能给你一些有用的思路,为用户创造更好的东西。 --- via: <https://theartofmachinery.com/2020/06/29/scaling_a_graphql_site.html> 作者:[Simon Arneaud](https://theartofmachinery.com) 选题:[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/) 荣誉推出
200
OK
I normally write abstractly about work I’ve done for other people (for obvious reasons), but I’ve been given permission to write about a website, [Vocal](https://vocal.media), that I did some SRE work on last year. I actually gave [a presentation at GraphQL Sydney back in February](https://www.meetup.com/en-AU/GraphQL-Sydney/events/267681845/), but this blog post got delayed a bit. Vocal is a GraphQL-based website that got traction and hit scaling problems that I got called in to fix. Here’s what I did. Obviously, you’ll find this post useful if you’re scaling another GraphQL website, but most of it’s representative of what you have to deal with when a site first gets enough traffic to cause technical problems. If website scalability is a key interest of yours, you might want to read [my recent post about scalability](/2020/04/21/what_is_high_traffic.html) first. ## Vocal ![Vocal home page](/images/scaling_a_graphql_site/vocal1.jpg) Vocal is a blogging platform publishing everything from diaries to movie reviews to opinion pieces to recipes to professional and amateur photography to beauty and lifestyle tips and poetry and (of course) cute dog and cat pictures. ![Vocal cats and dogs](/images/scaling_a_graphql_site/vocal2.jpg) One thing that’s a bit different about Vocal is that it lets people get paid for producing works that viewers find interesting. Authors get a small amount of money per page view, and can also receive donations from other users. There are many professionals using the platform to show off their work, but most users are everyday people using Vocal as a fun hobby that happens to make some extra pocket money as a bonus. Vocal is the product of ~~Jerrick Media~~, a New Jersey startup. Update: Jerrick Media has rebranded to [Creatd](https://creatd.com/) and is now listed on the NASDAQ. Development started in 2015 in collaboration with [Thinkmill](https://www.thinkmill.com.au/), a medium-sized Sydney software development consultancy that specialises in JavaScript, React and GraphQL. ## Some spoilers for the rest of this post I was told that unfortunately I can’t give hard traffic numbers for legal reasons, but publicly available information can give an idea. Alexa ranks all websites it knows of by traffic level. Here’s a plot of Alexa rank I showed in my talk, showing growth from November 2019 up to getting ranked number 5,567 in the world by February. ![Vocal Alexa rank](/images/scaling_a_graphql_site/alexa.png) ![Vocal Alexa rank](/images/scaling_a_graphql_site/alexa.png) It’s normal for the curve to slow down because it requires more and more traffic to win each position. Vocal is now at around #4,900. Obviously there’s a long way to go, but that’s not shabby at all for a startup. Most startups would gladly swap their Alexa rank with Vocal. Shortly after the site was upgraded, Creatd ran a marketing campaign that doubled traffic. All we had to do on the technical side was watch numbers go up in the dashboards. In the past 9 months since launch, there have only been two platform issues needing staff intervention: [the once-in-five-years AWS RDS certificate rotation that landed in March](https://aws.amazon.com/blogs/database/amazon-rds-customers-update-your-ssl-tls-certificates-by-february-5-2020/), and an app rollout hitting a Terraform bug. As an SRE, I’ve been very happy with how little platform busywork Vocal needs to keep running. Update: The system also handled the 2020 US election without drama, too. Here’s an overview of the technical stuff I’ll talk about in this post: - Technical and historical background - Database migration from MongoDB to Postgres - Deployment infrastructure revamp - Making the app compatible with scaling - Making HTTP caching work - Miscellaneous performances tweaks ## Some background Thinkmill built a website using [Next.js](https://github.com/vercel/next.js) (a React-based web framework), talking to a GraphQL API provided by [Keystone](https://www.keystonejs.com/) in front of MongoDB. Keystone is a GraphQL-based headless CMS library: you define a schema in JavaScript, hook it up to some data storage, and get an automatically generated GraphQL API for data access. It’s a free and open-source software project that’s commercially backed by Thinkmill. ### Vocal V2 The version 1 of Vocal got traction. It found a userbase that liked the product, and it grew, and eventually Creatd asked Thinkmill to help develop a version 2, which was successfully launched in September last year. The Creatd staff avoided the [second system effect](https://wiki.c2.com/?SecondSystemEffect) by generally basing changes on user feedback, so they were [mostly UI and feature changes that I won’t go into](https://vocal.media/resources/vocal-2-0). Instead, I’ll talk about the stuff I was brought in for: making the new site more robust and scalable. For the record, I’m thankful that I got to work with Creatd and Thinkmill on Vocal, and that they let me present this story, but [I’m still an independent consultant](/about.html). I wasn’t paid or even asked to write this post, and this is still my own personal blog. ## The database migration Thinkmill suffered several scalability problems with using MongoDB for Vocal, and decided to upgrade Keystone to version 5 to take advantage of its new Postgres support. If you’ve been in tech long enough to remember the “NoSQL” marketing from the end of the 00s, that might sound funny. A major theme of NoSQL marketing was that relational (SQL) databases like Postgres aren’t as scalable as “webscale” NoSQL databases like MongoDB. Technically that’s true, but the scalability of NoSQL databases comes from compromises in the variety of queries that can be efficiently handled. There are places for simple, non-relational databases (like document and key-value databases). However, when they’re used as general-purpose backends for apps, the apps often outgrow the querying limitations of the database before they outgrow the theoretical scaling limit of a relational database. Most of Vocal’s DB original queries worked just fine with MongoDB, but over time more and more queries needed hacks to work at all. In terms of technical requirements, Vocal is very similar to Wikipedia, one of the biggest sites in the world. Wikipedia runs on MySQL (or rather, its fork, MariaDB). Sure, some significant engineering is needed to make that work, but relational databases aren’t a serious threat to Vocal’s scaling in the foreseeable future. I did a comparison at one time, and the managed AWS RDS Postgres instances cost less than a fifth of the old MongoDB instances, yet CPU usage of the Postgres instances was still under 10%, despite serving more traffic than the old site. That’s mostly because of a few important queries that just never were efficient under the document database architecture. The migration could be a blog post of its own, but basically a Thinkmill dev built an [ETL pipeline](https://en.wikipedia.org/wiki/Extract,_transform,_load) using [MoSQL](https://github.com/stripe/mosql) to do the heavy lifting. Keystone support for Postgres was still new, but it’s a FOSS project so I was able to fix the problems we had with its SQL generation performance. For that kind of stuff, I always recommend Markus Winand’s SQL blogs: [Use the Index Luke](https://use-the-index-luke.com/) and [Modern SQL](https://modern-sql.com/). His writing is friendly and accessible even to people who have more important things than SQL to worry about, yet it has most of the theory you need most of the time. A good, DB-specific book on performance gives you the rest if you still have problems. ## The platform ### The architecture V1 was a couple of Node.js apps running on a single virtual private server (VPS) behind Cloudflare as a CDN. I’m a fan of avoiding overengineering as a high priority, so that gets a thumbs up from me. However, by the time V2 development started, it was obvious that Vocal had outgrown that simple architecture. It didn’t give Thinkmillers many options when handling big traffic spikes, and it made updates hard to deploy safely and without downtime. Here’s the new architecture for V2: ![Vocal V2 architecture](/images/scaling_a_graphql_site/architecture.svg) Basically, the two Node.js apps have been replicated and put behind a load balancer. Yes, that’s it. Some people expect scalable architecture to be more complicated than that, but I’ve worked on sites that are orders of magnitude bigger than Vocal but are still just replicated services behind load balancers, with DB backends. If you think about it, if the platform architecture needs to keep getting more complicated to serve more traffic, it’s not really “scalable”. Website scalability is mostly about fixing the many little implementation details that prevent scaling. Vocal’s architecture might need a few additions if traffic grows enough, but the main reason it would get more complicated is new features. For example, if (for some reason) Vocal needed to handle real-time geospatial data in future, that would be a very different technical beast from blog posts, so I’d expect architectural changes for it. Most of the complexity in big site architecture is because of feature complexity. It’s normal to not know what the future architecture needs to look like, so I always recommend starting as simple as you can. Fixing an architecture that’s too simple is easier and cheaper than fixing an architecture that’s too complex. Also, an unnecessarily complex architecture is more likely to have mistakes, and those mistakes will be harder to debug. By the way, Vocal happened to be split into two apps, but that’s not important. A common scaling mistake is to prematurely split an app into smaller services in the name of scalability, but split the app in the wrong place and cause more scalability problems overall. Vocal could have scaled okay as a monolithic app, but the split is also in a good place. ### The infrastructure Thinkmill has a few people who have experience working with AWS, but it’s primarily a dev shop and needed something more hands off than the old Vocal deployment. I ended up deploying the new Vocal on [AWS Fargate](https://aws.amazon.com/fargate/), which is a relatively new backend to Elastic Container Service (ECS). In the old days, many people wanted ECS to be a simple “run my Docker container as a managed service” product, and were disappointed that they still had to build and manage their own server cluster. With ECS Fargate, AWS manages the cluster. It supports running Docker containers with the basic nice things like replication, health checking, rolling updates, autoscaling and simple alerting. A good alternative would have been a managed Platform-as-a-Service (PaaS) like App Engine or Heroku. Thinkmill was already using them for simple projects, but often needed more flexibility with other projects. There are much bigger sites running on PaaSes, but Vocal is at a scale where a custom cloud deployment can make sense economically. Another obvious alternative would have been Kubernetes. Kubernetes has a lot more features than ECS Fargate, but it’s a lot more expensive — both in resource overhead, and the staffing needed for maintenance (such as regular node upgrades). As a rule, I don’t recommend Kubernetes to any place that doesn’t have dedicated DevOps staff. Fargate has the features Vocal needs, and has let Thinkmill and Creatd focus on website improvements, not infrastructure busywork. Yet another option was “Serverless” function products like AWS Lambda or Google Cloud Functions. They’re great for handling services with very low or highly irregular traffic, but (as I’ll explain) ECS Fargate’s autoscaling is enough for Vocal’s backend. Another plus of these products is that they allow developers to deploy things in cloud environments without needing to learn a lot about cloud environments. The tradeoff is that the Serverless product becomes tightly coupled to the development process, and to the testing and debugging processes. Thinkmill already had enough AWS expertise in-house to manage a Fargate deployment, and any dev who knows how to make a Node.js Express Hello World app can work on Vocal without learning anything about either Serverless functions or Fargate. An obvious downside of ECS Fargate is vendor lock-in. However, avoiding vendor lock-in is a tradeoff like avoiding downtime. If you’re worried about migrating, it doesn’t make sense to spend more on platform independence than you would on a migration. The total amount of Fargate-specific code in Vocal is <500 lines of [Terraform](https://www.terraform.io/docs/providers/aws/r/ecs_task_definition.html). The most important thing is that the Vocal app code itself is platform agnostic. It can run on normal developer machines, and then be packaged up into a Docker container that can run practically anywhere a Docker container can, including ECS Fargate. Another downside of Fargate is that it’s not trivial to set up. Like most things in AWS, it’s in a world of VPCs, subnets, IAM policies, etc. Fortunately, that kind of stuff is quite static (unlike a server cluster that requires maintenance). ## Making a scaling-ready app There’s a bunch of stuff to get right if you want to run an app painlessly at scale. You’re doing well if you follow [the Twelve-Factor App design](https://12factor.net/), so no need to repeat that stuff here. There’s no point building a “scalable” system if staff can’t operate it at scale — that’s like putting a jet engine on a unicycle. An important part of making Vocal scalable was setting up stuff like CI/CD and [infrastructure as code](/2019/02/16/talks.html). Similarly, some deployment ideas aren’t worth it because they make production too different from the development environment (see also [point #10 of the Twelve-Factor App](https://12factor.net/dev-prod-parity)). Every difference between production and development slows app development and (in practice) will lead to a bug eventually. ## Caching Caching is a really big topic — I once gave [a talk on just HTTP caching](https://www.meetup.com/en-AU/Port80-Sydney/events/lwcdjlyvjblb/), but that was still relatively basic. I’ll stick to the essentials for GraphQL here. First, an important warning: Whenever you have performance problems, you might wonder, “Can I make this faster by putting this value into a cache for future reuse?” **Microbenchmarks will practically always tell you the answer is “yes”.** However, putting caches everywhere will tend to make your overall system **slower**, thanks to problems like cache coherency. Here’s my mental checklist for caching: - Ask if the performance problem needs to be solved with caching - Really ask (non-caching performance wins tend to be more robust) - Ask if the problem can be solved by improving existing caches - If all else fails, maybe add a new cache One cache system you’ll always have in the Web is the HTTP caching system, so a corollary is that it’s a good idea to use HTTP caching effectively before trying to add extra caches. I’ll focus on that in this post. Another very common trap is using a hash map or something inside the app for caching. [It works great in local development but performs badly when scaled.](/2016/07/30/server_caching_architectures.html) The best thing is to use an explicit caching library that supports pluggable backends like Redis or Memcached. ### The basics There are two types of caches in the HTTP spec: private and public. Private caches are caches that don’t share data with multiple users — in practice, the user’s browser cache. Public caches are all the rest. They include ones under your control (such as CDNs or servers like Varnish or Nginx) and ones that aren’t (proxies). Proxy caches are rarer in today’s HTTPS world, but some corporate networks have them. ![Typical caches in a HTTP connection](/images/scaling_a_graphql_site/http_caches.svg) Caching lookup keys are normally based on URLs, so caching is less painful if you stick to a “same content, same URL; different content, different URL” rule. I.e., give each page a canonical URL, and avoid “clever” tricks returning varying content from one URL. Obviously, this has implications for GraphQL API endpoints (that I’ll discuss later). Your own servers can take custom configuration, but the primary way to configure HTTP caching is through HTTP headers you set on web responses. The most important header is `cache-control` . The following says that all caches down the line may cache the page for up to 3600 seconds (one hour): ``` cache-control: max-age=3600, public ``` For user-specific pages (such as user settings pages), it’s important to use `private` instead of `public` to tell public caches not to store the response and serve it to other users. Another common header is `vary` . This tells caches that the response varies based on some things other than the URL. (Effectively it adds HTTP headers to the the cache key, alongside the URL.) It’s a very blunt tool, which is why it’s better to use a good URL structure instead if possible, but an important use case is telling browsers that the response depends on the login cookie, so that they update pages on login/logout. ``` vary: cookie ``` If a page can vary based on login status, you need ``` cache-control: private ``` (and `vary: cookie` ) even on the public, logged out version, to make sure responses don’t get mixed up. Other useful headers include `etag` and `last-modified` , but I won’t cover them here. You might still see some old headers like `expires` and `pragma: cache` . They were made obsolete by HTTP/1.1 back in 1997, so I only use them if I want to disable caching and I’m feeling paranoid. ### Clientside headers Less well known is that the HTTP spec allows `cache-control` headers to be used in client requests to reduce the cache time and get a fresher response. Unfortunately `max-age` greater than 0 doesn’t seem to be widely supported by browsers, but `no-cache` can be useful if you sometimes need a fresh response after an update. ### HTTP caching and GraphQL As above, the normal cache key is the URL. But GraphQL APIs often use just one endpoint (let’s call it `/api/` ). If you want a GraphQL query to be cachable, you need the query and its parameters to appear in the URL path, like `/api/?query={user{id}}&variables={"x":99}` (ignoring URL escaping). The trick is to configure your GraphQL client to use HTTP GET requests for queries (e.g., [set useGETForQueries for apollo-link-http](https://www.apollographql.com/docs/link/links/http/#options)). Mutations mustn’t be cached, so they still need to use HTTP POST requests. With POST requests, caches will only see `/api/` as the URL path, but caches will refuse to cache POST requests outright. Remember: GET for non-mutating queries, POST for mutations. There’s a case where you might want to avoid GET for a query: if the query variables contain sensitive information. URLs have a habit of appearing in log files, browser history and chat channels, so sensitive information in URLs is usually a bad idea. Things like authentication should be done as non-cachable mutations, anyway, so this is a rare case, but one worth remembering. Unfortunately, there’s a problem: GraphQL queries tend to be much larger than REST API URLs. If you simply switch on GET-based queries, you’ll get some pretty big URLs, easily bigger than the ~2000 byte limit before some popular browsers and servers just won’t accept them. A solution is to send some kind of query ID, instead of sending the whole query. (I.e., something like `/api/?queryId=42&variables={"x":99}` .) Apollo GraphQL server supports two ways of doing this. One way is to [extract all the GraphQL queries from the code and build a lookup table that’s shared serverside and clientside](https://www.apollographql.com/blog/persisted-graphql-queries-with-apollo-client-119fd7e6bba5). One downside is that it makes the build process more complicated. Another downside is that it couples the client project to the server project, which defeats a major selling point of GraphQL. Yet another downside is that version X of your code might recognise a different set of queries from version Y of your code. This is a problem because 1) your replicated app will serve multiple versions during an update rollout, or rollback, and 2) clients might use cached JavaScript, even as you upgrade or downgrade the server. Another way is what Apollo GraphQL calls [Automatic Persisted Queries (APQs)](https://www.apollographql.com/blog/improve-graphql-performance-with-automatic-persisted-queries-c31d27b8e6ea). With APQs, the query ID is a hash of the query. The client optimistically makes a request to the server, referring to the query by hash. If the server doesn’t recognise the query, the client sends the full query in a POST request. The server stores that query by hash so that it can be recognised in future. ![Automatic persisted queries](/images/scaling_a_graphql_site/apq.png) ![Automatic persisted queries](/images/scaling_a_graphql_site/apq.png) ### HTTP caching and Keystone 5 As above, Vocal uses Keystone 5 for generating its GraphQL API, and Keystone 5 works with Apollo GraphQL server. How do we actually set the caching headers? Apollo supports cache hints on GraphQL schemas. The neat thing is that Apollo gathers all the hints for everything that’s touched by a query, and then it automatically calculates the appropriate overall cache header values. For example, take this query: ``` query userAvatarUrl { authenticatedUser { name avatar_url } } ``` If `name` has a max age of one day, and the `avatar_url` has a max age of one hour, the overall cache max age would be the minimum, one hour. `authenticatedUser` depends on the login cookie, so it needs a `private` hint, which overrides the `public` on the other fields, so the resulting header would be `cache-control: max-age=3600, private` . I added [cache hint support to Keystone lists and fields](https://www.keystonejs.com/api/create-list/#cachehint). Here’s a simple example of adding a cache hint to a field in the to-do list demo from the docs: ``` const keystone = new Keystone({ name: 'Keystone To-Do List', adapter: new MongooseAdapter(), }); keystone.createList('Todo', { schemaDoc: 'A list of things which need to be done', fields: { name: { type: Text, schemaDoc: 'This is the thing you need to do', isRequired: true, cacheHint: { scope: 'PUBLIC', maxAge: 3600, }, }, }, }); ``` ### One more problem: CORS Cross-Origin Resource Sharing (CORS) rules create a frustrating conflict with caching in an API-based website. Before getting stuck into the problem details, let me jump to the easiest solution: putting the main site and API onto one domain. If your site and API are served from one domain, you won’t have to worry about CORS rules (but you might want to consider [restricting cookies](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Define_where_cookies_are_sent)). If your API is specifically for the website, this is the cleanest solution, and you can happily skip this section. In Vocal V1, the Website (Next.js) and Platform (Keystone GraphQL) apps were on different domains (`vocal.media` and `api.vocal.media` ). To protect users from malicious websites, modern browsers don’t just let one website interact with another. So, before allowing `vocal.media` to make requests to `api.vocal.media` , the browser would make a “pre-flight” check to `api.vocal.media` . This is an HTTP request using the `OPTIONS` method that essentially asks if the cross-origin sharing of resources is okay. After getting the okay from the pre-flight check, the browser makes the normal request that was originally intended. The frustrating thing about pre-flight checks is that they are per-URL. The browser makes a new `OPTIONS` request for each URL, and the server response applies to that URL. [The server can’t say that vocal.media is a trusted origin for all api.vocal.media requests](https://lists.w3.org/Archives/Public/public-webapps/2012AprJun/0236.html). This wasn’t a serious problem when everything was a POST request to the one api endpoint, but after giving every query its own GET-able URL, every query got delayed by a pre-flight check. For extra frustration, the HTTP spec says `OPTIONS` requests can’t be cached, so you can find that all your GraphQL data is beautifully cached in a CDN right next to the user, but browsers still have to make pre-flight requests all the way to the origin server every time they use it.There are a few solutions (if you can’t just use a shared domain). If your API is simple enough, you might be able to exploit the [exceptions to the CORS rules](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Simple_requests). Some cache servers can be configured to ignore the HTTP spec and cache `OPTIONS` requests anyway (e.g., Varnish-based caches and AWS CloudFront). This isn’t as efficient as avoiding the pre-flight requests completely, but it’s better than the default. Another (really hacky) option is [JSONP](https://en.wikipedia.org/wiki/JSONP). Beware: you can create security bugs if you don’t get this right. ### Making Vocal more cachable After making HTTP caching work at the low level, I needed to make the app take better advantage of it. A limitation of HTTP caching is that it’s all-or-nothing at the response level. Most of a response can be cachable, but if a single byte isn’t, all bets are off. As a blogging platform, most Vocal data is highly cachable, but in the old site almost no *pages* were cachable at all because of a menu bar in the top right corner. For an anonymous user, the menu bar would show links inviting the user to log in or create an account. That bar would change to a user avatar and profile menu for signed-in users. Because the page varied based on user login status, it wasn’t possible to cache any of it in CDNs. ![Cachability of an example Vocal page](/images/scaling_a_graphql_site/cachablepage.png) These pages are generated by Server-Side Rendering (SSR) of React components. The fix was to take all the React components that depended on the login cookie, and force them to be [lazily rendered clientside only](https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr). Now the server returns completely generic pages with placeholders for personalised components like the login menu bar. When a page loads in the user’s browser, these placeholders are filled in clientside by making calls to the GraphQL API. The generic pages can be safely cached in CDNs. Not only does this trick improve cache hit ratios, it helps improve perceived page load time thanks to human psychology. Blank screens and even spinner animations make us impatient, but once the first content appears, it distracts us for several hundred milliseconds. If people click a Vocal post link from social media and the main content appears immediately from a CDN, very few will ever notice (or care) that some components aren’t fully interactive until a few hundred milliseconds later. By the way, another trick for getting the first content in front of the user faster is to [stream render the SSR response as it’s generated](https://medium.com/the-thinkmill/progressive-rendering-the-key-to-faster-web-ebfbbece41a4), instead of waiting for the whole page to be rendered before sending it. Unfortunately, [Next.js doesn’t support that yet](https://github.com/vercel/next.js/issues/1209). The idea of splitting responses for improved cachability also applies to GraphQL. The ability to query multiple pieces of data with one request is normally an advantage of GraphQL, but if the different parts of the response have very different cachability, it can be better overall to split them. As a simple example, Vocal’s pagination component needs to know the number of pages plus the content for the current page. Originally the component fetched both in one query, but because the total number of pages is a constant across all pages, I made it a separate query so it can be cached. ### Benefits of caching The obvious benefit of caching is that it reduces the load on Vocal’s backend servers. That’s good, but it’s dangerous to rely on caching for capacity, though, because you still need a backup plan for when you inevitably drop the cache one day. The improved responsiveness is a better reason for caching. A couple of other benefits might be less obvious. Traffic spikes tend to be highly localised. If someone with a lot of social media followers shares a link to a page, Vocal will get a big surge of traffic, but mostly to that one page and its assets. That’s why caches are good at absorbing the worst traffic spikes, making the backend traffic patterns relatively smoother and easier for autoscaling to handle. Another benefit is graceful degradation. Even if the backends are in serious trouble for some reason, the most popular parts of the site can still be served from the CDN cache. ## Other performance tweaks As I always say, the secret to scaling isn’t making things complicated. It’s making things no more complicated than needed, and then thoroughly fixing all the things that prevent scaling. Scaling Vocal involved a lot of little things that won’t fit in this post. Here’s one tip: for the difficult debugging problems in distributed systems, the hardest part is usually getting the right data to see what’s going on. I can think of plenty of times that I’ve got stuck and tried to just “wing it” by guessing instead of figuring out how to find the right data. Sometimes that works, but not for the hard problems. A related tip is that you can learn a lot by getting real-time data (even just log files under [ tail -F](https://linux.die.net/man/1/tail)) on each component in a system, displaying it in various windows in one monitor, and just clicking around the site in another. I’m talking about things like, “Hey, why does toggling this one checkbox generate dozens of DB queries in the backend?” Here’s an example of one fix. Some pages were taking more than a couple of seconds to render, but only in the deployment environment, and only with SSR. The monitoring dashboards didn’t show any CPU usage spikes, and the apps weren’t using disk, so it suggested that maybe the app was waiting on network requests, probably to a backend. In a dev environment I could watch how the app worked using [the sysstat tools](https://github.com/sysstat/sysstat/) to record CPU/RAM/disk usage, along with Postgres statement logging and the usual app logs. [Node.js supports probes for tracing HTTP requests](http://www.brendangregg.com/blog/2016-10-12/linux-bcc-nodejs-usdt.html) using something like [bpftrace](/2019/04/26/bpftrace_d_gc.html), but boring reasons meant they didn’t work in the dev environment, so instead I found the probes in the source code and made a custom Node.js build with request logging. I used [tcpdump](https://danielmiessler.com/study/tcpdump/) to record network data. That let me find the problem: for every API request made by Website, a new network connection was being created to Platform. (If that hadn’t worked, I guess I would have added request tracing to the apps.) Network connections are fast on a local machine, but take non-negligible time on a real network. Setting up an encrypted connection (like in the production environment) takes even longer. If you’re making lots of requests to one server (like an API), it’s important to keep the connection open and reuse it. Browsers do that automatically, but Node.js doesn’t by default because it can’t know if you’re making more requests. That’s why the problem only appeared with SSR. Like many long debugging sessions, the fix was very simple: just configure SSR to [keep connections alive](https://www.npmjs.com/package/agentkeepalive). The rendering time of the slower pages dropped dramatically. If you want to know more about this kind of stuff, I highly recommend reading [the High Performance Browser Networking book](https://hpbn.co/) (free to read online) and following up with [guides Brendan Gregg has published](http://www.brendangregg.com/). ## What about your site? There’s actually a lot more stuff we could have done to improve Vocal, but we didn’t do it all. That’s a big difference between doing SRE work for a startup and doing it for a big company as a permanent employee. We had tights goals, budget and launch date. But we ended up with an improved site that’s giving users something they want. Similarly, your site will have its own goals, and is likely quite different from Vocal. However, I hope this post and its links give you at least some useful ideas to make something better for users.
13,984
Motrix:一个漂亮的跨平台开源下载管理器
https://itsfoss.com/motrix/
2021-11-14T11:49:57
[ "下载", "下载管理器" ]
https://linux.cn/article-13984-1.html
![](/data/attachment/album/202111/14/114909gwv5jbe0055tc6b6.jpg) > > 一个开源的下载管理器,提供了一个简洁的用户界面,同时提供了跨平台操作的所有基本功能。在这里了解关于它的更多信息。 > > > Linux 下有大量的下载管理器。如果你想下载一些东西并可以管理它们,你可以选择任何一个可用的下载管理器。 然而,如果你想要一个好看的下载管理器,提供现代的用户体验,同时又不影响功能设置,我有个软件你可能会喜欢。 ### 看看 Motrix:一个功能丰富的开源下载管理器 ![](/data/attachment/album/202111/14/114957fy784p9p56wdc7m7.png) Motrix 是一个不折不扣的下载管理器,开箱即用,外观简洁。它是自由开源软件。 你可以选择在 Linux、Windows 和 macOS 中使用。 它也可以成为一些 [Linux 中的 torrent 客户端](https://itsfoss.com/best-torrent-ubuntu/) 的潜在替代品。 让我强调一些关键的功能以及安装说明。 ### Motrix 的特点 ![](/data/attachment/album/202111/14/114958ccw1zyww402bbwuw.png) 你应该能找到所有你通常在下载管理器中期待的功能。下面是它们的列表: * 跨平台支持 * 易于使用的界面 * BitTorrent 的选择性下载 * 自动更新 tracker 列表 * UPnP 及 NAT-PMP 端口映射 * 多个下载任务(最多 10 个) * 在一个任务中最多支持 64 个线程 * 能够设置速度限制 * 可选择改变用户代理 * 支持系统托盘 * 黑暗模式 * 支持多国语言 ![](/data/attachment/album/202111/14/114958phdr8zxrhrl2iyli.png) 总的来说,它在处理 torrent 文件时工作得很好,也能从剪贴板上检测到下载链接。在下载文件之前可以直接访问高级选项,所以这应该是很方便的。 ![](/data/attachment/album/202111/14/114959hwnnn0nntucj59nw.png) 在我短暂的测试中,我在 Ubuntu 上以 Snap 包使用它时没有发现任何问题。 ### 在 Linux 中安装 Motrix 你有多种安装 Motrix 的选项。因此,你应该能够在你选择的任何 Linux 发行版上安装它。 它主要提供了一个 AppImage 供下载。但是,它还有 [Flatpak 包](https://itsfoss.com/what-is-flatpak/),并可在 [Snap 商店](https://itsfoss.com/enable-snap-support-linux-mint/)找到它。 如果你使用的是 Ubuntu,你可以通过软件中心找到它。 除了这些,它也在 [AUR](https://itsfoss.com/aur-arch-linux/) 中提供给 Arch Linux 用户。在任何一种情况下,你都可以从他们的 [GitHub 发布栏](https://github.com/agalwood/Motrix/releases) 获得 DEB/RPM 包。 你可以在他们的[官方网站](https://motrix.app/)和 [GitHub 页面](https://github.com/agalwood/Motrix)上找到下载链接和更多安装的信息。 * [Motrix](https://motrix.app/) ### 总结 Motrix 提供了所有你想要的下载管理器中的好东西,额外还有一个现代的用户体验。 我建议你试试把它作为你的下载管理器,看看它是否能取代你目前的工具。我很想知道你的 Linux 系统上常用的下载管理器。请在下面的评论中告诉我更多关于它的信息。 --- via: <https://itsfoss.com/motrix/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
**Brief:** An open-source download manager that*provides a clean user interface while offering all the essential features to operate cross-platform. Explore more about it here.* There are plenty of download managers available for Linux. If you want to download something and have the ability to manage them, you can choose any of the download managers available. However, if you want a good-looking download manager that offers a modern user experience without compromising on the feature set, I’ve something that you might like. ## Meet Motrix: A Feature-Rich Open Source Download Manager ![motrix download manager](https://itsfoss.com/content/images/wordpress/2021/11/motrix-download-manager.png) Motrix is a no-nonsense download manager that provides a clean look out of the box. It is free and open-source software. You can choose to use it for Linux, Windows, and macOS as well. It could be a potential replacement for some [torrent clients available for Linux](https://itsfoss.com/best-torrent-ubuntu/) as well. Let me highlight some key features along with the installation instructions. ## Features of Motrix ![motrix dm setting](https://itsfoss.com/content/images/wordpress/2021/11/motrix-dm-setting.png) You should find all the features that you would typically expect in a download manager. Here’s a list of them: - Cross-platform support - Easy to use interface - BitTorrent selective download - Automatic tracker list update - UPnP & NAT-PMP Port Mapping - Parallel download tasks (up to 10) - Support for up to 64 threads in a single task - Ability to set a speed limit - Option to change the user-agent - System tray support - Dark mode - Multiple languages supported ![motrix dm white](https://itsfoss.com/content/images/wordpress/2021/11/motrix-dm-white.png) Overall, it worked well with torrent files and detected the download links from the clipboard as well. The advanced options can be accessed right before downloading a file, so that should come in handy. ![motrix dm options](https://itsfoss.com/content/images/wordpress/2021/11/motrix-dm-options.png) I did not find any issues while using it on Ubuntu as a snap package in my brief testing. ## Install Motrix in Linux You get a variety of installation options for Motrix. So, you should be able to install it on any Linux distribution of your choice. Primarily, it offers an AppImage for download. But, you can also find it available as a [Flatpak package](https://itsfoss.com/what-is-flatpak/) and [Snap](https://itsfoss.com/enable-snap-support-linux-mint/)[ ](https://itsfoss.com/enable-snap-support-linux-mint/)[store](https://itsfoss.com/enable-snap-support-linux-mint/). If you are using Ubuntu, you should find it listed through the software center. In addition to these, it is also available in [AUR](https://itsfoss.com/aur-arch-linux/) for Arch Linux users. In either case, you can always get the DEB/RPM packages from their [GitHub releases section](https://github.com/agalwood/Motrix/releases). You can find the links to download and more information on installation on their [official website](https://motrix.app/) and the [GitHub page](https://github.com/agalwood/Motrix). ## Wrapping Up Motrix offers all the goodies that you’d want in a download manager with a modern UX as a bonus. I recommend you try this out as your download manager and see if it replaces your current tool. I’d be curious to know your active download manager on your Linux system; feel free to tell me more about it in the comments below!
13,986
Python 中使用 argparse 解析命令行参数
https://opensource.com/article/21/8/python-argparse
2021-11-15T11:01:45
[ "Python", "参数" ]
https://linux.cn/article-13986-1.html
> > 使用 argparse 模块为应用程序设置命令行选项。 > > > ![](/data/attachment/album/202111/15/110139bakkfdt4zoadqiv0.jpg "Python options") 有一些第三方库用于命令行解析,但标准库 `argparse` 与之相比也毫不逊色。 无需添加很多依赖,你就可以编写带有实用参数解析功能的漂亮命令行工具。 ### Python 中的参数解析 使用 `argparse` 解析命令行参数时,第一步是配置一个 `ArgumentParser` 对象。这通常在全局模块内完成,因为单单\_配置\_一个解析器没有副作用。 ``` import argparse PARSER = argparse.ArgumentParser() ``` `ArgumentParser` 中最重要的方法是 `.add_argument()`,它有几个变体。默认情况下,它会添加一个参数,并期望一个值。 ``` PARSER.add_argument("--value") ``` 查看实际效果,调用 `.parse_args()`: ``` PARSER.parse_args(["--value", "some-value"]) ``` ``` Namespace(value='some-value') ``` 也可以使用 `=` 语法: ``` PARSER.parse_args(["--value=some-value"]) ``` ``` Namespace(value='some-value') ``` 为了缩短在命令行输入的命令,你还可以为选项指定一个短“别名”: ``` PARSER.add_argument("--thing", "-t") ``` 可以传入短选项: ``` PARSER.parse_args("-t some-thing".split()) ``` ``` Namespace(value=None, thing='some-thing') ``` 或者长选项: ``` PARSER.parse_args("--thing some-thing".split()) ``` ``` Namespace(value=None, thing='some-thing') ``` ### 类型 有很多类型的参数可供你使用。除了默认类型,最流行的两个是布尔类型和计数器。布尔类型有一个默认为 `True` 的变体和一个默认为 `False` 的变体。 ``` PARSER.add_argument("--active", action="store_true") PARSER.add_argument("--no-dry-run", action="store_false", dest="dry_run") PARSER.add_argument("--verbose", "-v", action="count") ``` 除非显式传入 `--active`,否则 `active` 就是 `False`。`dry-run` 默认是 `True`,除非传入 `--no-dry-run`。无值的短选项可以并列。 传递所有参数会导致非默认状态: ``` PARSER.parse_args("--active --no-dry-run -vvvv".split()) ``` ``` Namespace(value=None, thing=None, active=True, dry_run=False, verbose=4) ``` 默认值则比较单一: ``` PARSER.parse_args("".split()) ``` ``` Namespace(value=None, thing=None, active=False, dry_run=True, verbose=None) ``` ### 子命令 经典的 Unix 命令秉承了“一次只做一件事,并做到极致”,但现代的趋势把“几个密切相关的操作”放在一起。 `git`、`podman` 和 `kubectl` 充分说明了这种范式的流行。`argparse` 库也可以做到: ``` MULTI_PARSER = argparse.ArgumentParser() subparsers = MULTI_PARSER.add_subparsers() get = subparsers.add_parser("get") get.add_argument("--name") get.set_defaults(command="get") search = subparsers.add_parser("search") search.add_argument("--query") search.set_defaults(command="search") ``` ``` MULTI_PARSER.parse_args("get --name awesome-name".split()) ``` ``` Namespace(name='awesome-name', command='get') ``` ``` MULTI_PARSER.parse_args("search --query name~awesome".split()) ``` ``` Namespace(query='name~awesome', command='search')` ``` ### 程序架构 使用 `argparse` 的一种方法是使用下面的结构: ``` ## my_package/__main__.py import argparse import sys from my_package import toplevel parsed_arguments = toplevel.PARSER.parse_args(sys.argv[1:]) toplevel.main(parsed_arguments) ``` ``` ## my_package/toplevel.py PARSER = argparse.ArgumentParser() ## .add_argument, etc. def main(parsed_args): ... # do stuff with parsed_args ``` 在这种情况下,使用 `python -m my_package` 运行。或者,你可以在包安装时使用 [console\_scprits](https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point) 入口点。 ### 总结 `argparse` 模块是一个强大的命令行参数解析器,还有很多功能没能在这里介绍。它能实现你想象的一切。 --- via: <https://opensource.com/article/21/8/python-argparse> 作者:[Moshe Zadka](https://opensource.com/users/moshez) 选题:[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/) 荣誉推出
200
OK
There are several third-party libraries for command-line argument parsing, but the standard library module `argparse` is no slouch either. Without adding any more dependencies, you can write a nifty command-line tool with useful argument parsing. ## Argument parsing in Python When parsing command-line arguments with `argparse` , the first step is to configure an `ArgumentParser` object. This is often done at the global module scope since merely *configuring* the parser has no side effects. ``` import argparse PARSER = argparse.ArgumentParser() ``` The most important method on `ArgumentParser` is `.add_argument()` . It has a few variants. By default, it adds an argument that expects a value. `PARSER.add_argument("--value")` To see it in action, call the method `.parse_args()` : `PARSER.parse_args(["--value", "some-value"])` `Namespace(value='some-value')` It's also possible to use the syntax with `=` : `PARSER.parse_args(["--value=some-value"])` `Namespace(value='some-value')` You can also specify a short "alias" for a shorter command line when typed into the prompt: `PARSER.add_argument("--thing", "-t")` It's possible to pass either the short option: `PARSER.parse_args("-t some-thing".split())` `Namespace(value=None, thing='some-thing')` or the long one: `PARSER.parse_args("--thing some-thing".split())` `Namespace(value=None, thing='some-thing')` ## Types There are more types of arguments available. The two most popular ones, after the default, are boolean and counting. The booleans come with a variant that defaults to true, and one that defaults to false. ``` PARSER.add_argument("--active", action="https://opensource.com/store_true") PARSER.add_argument("--no-dry-run", action="https://opensource.com/store_false", dest="dry_run") PARSER.add_argument("--verbose", "-v", action="https://opensource.com/count") ``` This means that `active` is `False` unless `--active` is passed, and `dry_run` is `True` unless `--no-dry-run` is passed. Short options without value can be juxtaposed. Passing all the arguments results in a non-default state: `PARSER.parse_args("--active --no-dry-run -vvvv".split())` `Namespace(value=None, thing=None, active=True, dry_run=False, verbose=4)` The default is somewhat less exciting: `PARSER.parse_args("".split())` `Namespace(value=None, thing=None, active=False, dry_run=True, verbose=None)` ## Subcommands Though classic Unix commands "did one thing, and did it well," the modern tendency is to do "several closely related actions." The examples of `git` , `podman` , and `kubectl` can show how popular the paradigm is. The `argparse` library supports that too: ``` MULTI_PARSER = argparse.ArgumentParser() subparsers = MULTI_PARSER.add_subparsers() get = subparsers.add_parser("get") get.add_argument("--name") get.set_defaults(command="get") search = subparsers.add_parser("search") search.add_argument("--query") search.set_defaults(command="search") ``` `MULTI_PARSER.parse_args("get --name awesome-name".split())` `Namespace(name='awesome-name', command='get')` `MULTI_PARSER.parse_args("search --query name~awesome".split())` `Namespace(query='name~awesome', command='search')` ## Anatomy of a program One way to use `argparse` is to structure the program as follows: ``` ## my_package/__main__.py import argparse import sys from my_package import toplevel parsed_arguments = toplevel.PARSER.parse_args(sys.argv[1:]) toplevel.main(parsed_arguments) ``` ``` ## my_package/toplevel.py PARSER = argparse.ArgumentParser() ## .add_argument, etc. def main(parsed_args): ... # do stuff with parsed_args ``` In this case, running the command is done with `python -m my_package` . Alternatively, you can use the [ console_scripts](https://python-packaging.readthedocs.io/en/latest/command-line-scripts.html#the-console-scripts-entry-point) entry points in the package's setup. ## Summary The `argparse` module is a powerful command-line argument parser. There are many more features that have not been covered here. The limit is your imagination. ## 1 Comment
13,987
GIMP 3.0 中值得期待的 8 项新功能和改进
https://news.itsfoss.com/gimp-3-0-features/
2021-11-15T18:13:00
[ "GIMP" ]
https://linux.cn/article-13987-1.html
> > 将带来重大改进的 GIMP 3.0 是最令人期待的版本之一。根据它最近的开发版本,这是一个预期的功能列表。 > > > ![](/data/attachment/album/202111/15/181326g97bbdzapwnsqudz.jpg) [GIMP](https://www.gimp.org/) 是可在 Linux 上使用的 [最佳免费图像编辑器](https://itsfoss.com/image-applications-ubuntu-linux/) 之一。不仅仅适用于那些想要 Adobe 套件的免费替代品的用户,许多专业人士也使用 GIMP 进行艺术创作、设计和照片编辑。 尽管 GIMP 提供了许多必要的功能和选项,但在各种平台上已经出现了许多现代替代品,其中在一些方面已经超过了 GIMP。 不过,GIMP 3.0 可能是一个扭转局面的版本,它将使 GIMP 成为最好的现代产品之一,可与现有的商业对手相竞争。 本文将讨论预期出现在 GIMP 3.0 版本的功能。 ### GIMP 3.0 值得期待的顶级功能 随着 GIMP 3.0 的版本发布,其开发版本增加了很多改进。 你或许想看到早期开发版本中的所有功能/变化,但我们将在本文中只能介绍其中重要的亮点。 ### 1、基于 GTK3 的用户界面 ![来源:GIMP 博客](/data/attachment/album/202111/15/181327r3u32nfk03nbdzfn.png) GIMP 3.0 将带来基于 GTK3 的用户界面的重新打造的视觉享受。除了改进的外观和感受,你还可以看到一些新的小工具。 别忘了,[爱德华•斯诺登也认为 GIMP 需要进行 UI 大修](https://news.itsfoss.com/gimp-ui-edward-snowden/)。所以,GIMP 3.0 即使最终没有成为一种视觉享受,也应该在某种形式上有所改善。 在以前的 GIMP 版本中,它并不支持高像素密度的显示器。虽然可以使用,但如果你有一个更高分辨率的屏幕,GIMP 看起来就不够好。 现在,随着 GTK3 的加入,它增加了对高像素密度显示器的支持。你所要做的就是设置你的操作系统的首选缩放/分辨率,GIMP 应该可以支持它了。 ### 2、Wayland 支持 向 GTK3 的过渡应该能提供更好的 Wayland 支持。因此,如果你开始使用 Wayland 桌面会话,GIMP 3.0 应该可以让你毫无问题地使用该应用程序。 ### 3、多层选择 ![来源:GIMP 博客](/data/attachment/album/202111/15/181328y61jbjlwlbjb2ytw.png) 最关键的新增功能之一是可以选择多个图层。 虽然这是一个需要很长时间才能完成的功能,但它终于在 GIMP 3.0 版本中实现了。 有了这个功能,人们可以轻松地管理和组织他们的工程中的几个图层。 根据现有的信息,他们正式提到了这个变化: > > 可停靠的图层现在完全可以进行多选,使用通常的交互方式进行多项目选择(“`Shift` + 点击”用于选择一系列图层,“`Ctrl` + 点击”用于选择或取消选择不相邻的层)。组织操作现在可以对所有选定的图层起作用,即你可以一次性移动、重新排序、删除、复制、合并(以及更多...)所有选定的图层。 > > > 换句话说,你可以选择多个图层,并同时对它们进行批量操作。 例如,你可以裁剪、移动、使用合并的图层中的颜色选择工具,并使用这个功能执行更多操作。 在发表这篇文章时,我注意到,根据他们的开发博客,这是一个正在进行的工作,有一些限制。希望在稳定版中,多层选择可以完美地工作。 ### 4、新的插件 API 插件 API 保留了所有的基本功能,但也引入了一些新的改进。 因此,新的插件 API 应该不会对开发者造成任何破坏,而应该可以让他们把插件轻松地移植到 GIMP 3.0 应用程序上。 他们的开发版本中提到了一些改进: * 摆脱了对象 ID,转而使用真实的对象。特别是在 GIMP 3 中,`GimpImage`、`GimpItem`、`GimpDrawable`、`GimpLayer`、`GimpVectors`、`GimpChannel` 和 `GimpPDB` 都是对象(其他类别的对象已经存在或以后可能加入)。 * 路径现在被当作 `GFile` 来处理,这意味着使用 GLib/GIO API。 * GIMP API 应该可以完全支持各种语言(Python 3、JavaScript、Lua、Vala 等)。 ### 5、绘画选择工具 ![来源:GIMP 博客](/data/attachment/album/202111/15/181329rz05v777euxvd0ei.png) 前景选择工具不会消失。然而,他们正在开发一个新的实验性的“绘画选择”工具,它可以让你逐步选择和绘制使用画笔的区域。 绘画选择工具的目的还在于克服前景选择工具对大图像的限制,并解决内存/稳定性问题。 考虑到它被列为实验性工具,我们不能确定它是否能进入稳定版,但它已经有了新的图标,你可以找到这个工具。 ### 6、Windows Ink 支持 ![来源:GIMP 博客](/data/attachment/album/202111/15/181330qtwz8475bbwwtwc8.png) 当然,我们在这里讨论的都是 Linux。但是,GIMP 是一个流行的跨平台工具。 所以,为了吸引更多的用户,最好为专业人士或设计师使用的工具提供硬件支持。 GIMP 3.0 现在支持 Windows Ink 开箱即用,这要归功于它引入的 GTK3。你会从管理输入设备的设置中找到使用 Windows Ink API 的选项。 ### 7、改进手势支持 GIMP 并不是笔记本电脑用户的最佳选择,或者更准确地说,不是触摸板/触摸屏用户的最佳选择。 然而,随着 GIMP 3.0 增加了手势支持,可以捏住画布放大/缩小,这种情况可能会有所改善。 我们还可能在最终版本中看到更多的手势支持,但截至 2.99.8 版本,也就是最新的开发版本,还没有新的手势。 ### 8、改进的文件格式支持 GIMP 3.0 现在支持 JPEG-XL 文件格式,能够加载/导出带有灰度和 RGB 颜色配置文件的 .jxl 文件。 对 Adobe Photoshop 工程文件的支持也得到了改进。它现在可以处理大于 4GB 的 PSD 文件,同时加载多达 99 个通道。 除此以外,对 WebP 和 16 位 SGI 图像的支持也得到了改进。 ### 总结 看看 [GIMP 的开发博客](https://www.gimp.org/news/2021/10/20/gimp-2-99-8-released/),看起来他们几乎已经完成了最终版本。然而,他们并没有透露任何特定的发布日期时间表。 所以,一旦他们解决了错误并完成了改进,它就会到来。 你期待 GIMP 3.0 吗?它看起来是一个有希望的下一代版本吗? --- via: <https://news.itsfoss.com/gimp-3-0-features/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) [GIMP](https://www.gimp.org/?ref=news.itsfoss.com) is one of the [best free image editors](https://itsfoss.com/image-applications-ubuntu-linux/?ref=news.itsfoss.com) available for Linux. Not just for users who want a free alternative to Adobe suite, but many professionals use GIMP for artwork, design, and photo editing. Even though GIMP offers many essential features and options to work with, many modern alternatives (irrespective of the platform) have popped up that outshine GIMP in several ways. And, GIMP 3.0 could be the release that turns the table by putting GIMP as one of the best modern offerings to compete with commercial options available out there. This article will discuss the expected features to arrive with GIMP 3.0 release. ## Top Features to Expect With GIMP 3.0 Following the road to GIMP 3.0 release, the development versions have added a lot of improvements. It does make sense to expect all the features/changes you see in its early developer builds, but we will stick to significant highlights for this article. ## 1. GTK3 based UI ![](https://news.itsfoss.com/content/images/wordpress/2021/11/gimp-2-99-2-gtk3-1024x559.png) GIMP 3.0 will bring in a visual overhaul with GTK3-based UI. Along with the improved look and feel, you can also expect new widgets. Not to forget, [Edward Snowden also thinks that GIMP needs a UI overhaul](https://news.itsfoss.com/gimp-ui-edward-snowden/). So, GIMP 3.0 should make a difference in some form if it does not end up being a visual treat. With previous GIMP releases, it did not support high pixel density displays. It was manageable, but GIMP did not look good enough if you had a higher resolution screen. Now with GTK3 onboard, it adds support for high pixel density displays. All you have to do is set your operating system’s preferred scaling/resolution, and GIMP should support it. ## 2. Wayland Support The transition to GTK3 should ensure better Wayland support. So, if you are starting to use Wayland desktop sessions, GIMP 3.0 should let you use the app without any issues. ## 3. Multiple Layer Selection ![](https://news.itsfoss.com/content/images/wordpress/2021/11/gimp-2.99.2-multi-layer-selection.png) One of the most crucial feature addition is the ability to select multiple layers. While this was a much-needed feature due for a long time, it is finally coming together for GIMP 3.0 release. With this feature, one can easily manage and organize several layers in their projects. As per the available information, they officially mention more about the change: The Layers dockable is now fully multi-selection aware, using the usual interaction for multi-items selection ( `Shift+click` for selecting a range of layers and`Ctrl+click` for selecting or deselecting non-contiguous layers). Organizational operations now work on all selected layers, i.e. that you can move, reorder, delete, duplicate, merge (and more…) all selected layers at once. In other words, you can select multiple layers and perform batch operations on all of them at once. For instance, you can crop, move, use the color picker tool from merged layers, and do more things with this feature. When publishing this article, I noticed that it is a work in progress with some limitations, as per their development blog. Hopefully, with the stable release, the multi-layer selection works flawlessly. ## 4. New Plugin API The plugin API retains all the essential functionalities but also introduces several new improvements. So, the new plugin API shouldn’t break anything for developers but should allow them to port their plugins to GIMP 3.0 app easily. Some improvements as mentioned in their development releases: - Moved away from object IDs to real objects. In particular in GIMP 3, `GimpImage` ,`GimpItem` ,`GimpDrawable` ,`GimpLayer` ,`GimpVectors` ,`GimpChannel` and`GimpPDB` are objects (other classes of objects already exist or may be added later). - Paths are now handled as `GFile` , which implies using the GLib/GIO API. - GIMP API should be fully usable in a wide range of language bindings (Python 3, JavaScript, Lua, Vala, etc) ## 5. Paint Select Tool ![](https://news.itsfoss.com/content/images/wordpress/2021/11/gimp-paint-select-tool.png) The Foreground Select tool isn’t going anywhere. However, a new experimental “Paint Select” tool is being worked on that lets you progressively select and paint the region where you use the brush. The Paint Select tool also aims to overcome the limitations with the Foreground Select tool for big images and resolve memory/stability issues. We can’t be sure if it makes it to the stable release, considering it was listed as experimental, but it already has new icons to help you identify the tool. ## 6. Windows Ink Support ![](https://news.itsfoss.com/content/images/wordpress/2021/11/gimp-windows-ink.png) Of course, we discuss all things Linux here. But, GIMP is a popular cross-platform tool. So, to appeal to more users, it is good to have hardware support for tools that professionals or designers use. GIMP 3.0 now supports Windows Ink out-of-the-box, thanks to its addition to GTK3. You would get the option to use the Windows Ink API from the settings for managing input devices. ## 7. Improved Gesture Support GIMP wasn’t the best candidate for laptop users or, more accurately, touchpad/touchscreen users. However, this could change with GIMP 3.0 adding gesture support to pinch to zoom in/out of the canvas. We could also see more gesture support in the final release, but there are no new gestures as of version 2.99.8, which is the latest development release. ## 8. **Improved File Format Support** GIMP 3.0 now supports JPEG-XL file format, with the ability to load/export .jxl files with grayscale and RGB color profiles. The support for Adobe Photoshop project files has been improved as well. It can now handle PSD files larger than 4 GB while loading up to 99 channels. In addition to these, support for WebP, and 16-bit SGI images were also improved. ## Wrapping Up Looking at [GIMP’s development blog](https://www.gimp.org/news/2021/10/20/gimp-2-99-8-released/?ref=news.itsfoss.com), it looks like they’re almost done for the final release. However, they haven’t shared any particular timeline for a release date. So, it should arrive as soon as they squash the bugs and finalize the improvements. *Are you looking forward to GIMP 3.0? Does it look like a promising next-gen release?* ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
13,989
如何用 JavaScript 构建命令行应用
https://opensource.com/article/21/11/javascript-command-line-apps
2021-11-16T11:45:06
[ "JavaScript", "命令行", "参数" ]
https://linux.cn/article-13989-1.html
> > 为你的用户提供选项是任何应用的一个重要功能,而 Commander.js 使它变得容易做到。你最喜欢的 JavaScript 命令行构建器是什么? > > > ![](/data/attachment/album/202111/16/114501u11upndpphhu2uhh.jpg "Javascript code close-up with neon graphic overlay") JavaScript 是一种为 Web 开发的语言,但它的用处已经远远超出了互联网的范畴。由于 Node.js 和 Electron 这样的项目,JavaScript 既是一种通用的脚本语言,也是一种浏览器组件。有专门设计的 JavaScript 库来构建命令行界面。是的,你可以在你的终端中运行 JavaScript。 现在,当你在终端中输入一个命令时,一般都有 [选项](https://opensource.com/article/21/8/linux-terminal),也叫 *开关* 或 *标志*,你可以用来修改命令的运行方式。这是由 [POSIX 规范](https://opensource.com/article/19/7/what-posix-richard-stallman-explains) 定义的一个有用的惯例,所以作为一个程序员,知道如何检测和解析这些选项是很有帮助的。要从 JavaScript 获得此功能,使用旨在简化构建命令行界面的库很有用。我最喜欢的是 [Commander.js](https://github.com/tj/commander.js)。它很简单,很灵活,而且很直观。 ### 安装 node 要使用 Commander.js 库,你必须安装 Node.js。在 Linux 上,你可以用你的包管理器安装 Node。例如,在 Fedora、CentOS、Mageia 和其他系统上: ``` $ sudo dnf install nodejs ``` 在 Windows 和 macOS 上,你可以 [从 nodejs.org 网站下载安装程序](https://nodejs.org/en/download)。 ### 安装 Commander.js 要安装 Commander.js,请使用 `npm` 命令: ``` $ npm install commander ``` ### 在你的 JavaScript 代码中添加一个库 在 JavaScript 中,你可以使用 `require` 关键字在你的代码中包含(或者导入,如果你习惯于 Python)一个库。创建一个名为 `example.js` 的文件,并在你喜欢的文本编辑器中打开它。在顶部添加这一行,以包括 Commander.js 库: ``` const { program } = require('commander'); ``` ### JavaScript 中的选项解析 要解析选项,你必须做的第一件事是定义你的应用可以接受的有效选项。Commander.js 库可以让你定义短选项和长选项,同时还有一个有用的信息来澄清每个选项的目的。 ``` program .description('A sample application to parse options') .option('-a, --alpha', 'Alpha') .option('-b, --beta <VALUE>', 'Specify a VALUE', 'Foo'); ``` 第一个选项,我称之为 `--alpha`(简写 `-a`),是一个布尔型开关:它要么存在,要么不存在。它不需要任何参数。第二个选项,我称之为 `--beta`(简写 `-b`),接受一个参数,甚至在你没有提供任何参数的情况下指定一个默认值。 ### 访问命令行数据 当你定义了有效的选项,你就可以使用长的选项名称来引用这些值: ``` program.parse(); const options = program.opts(); console.log('Options detected:'); if (options.alpha) console.log('alpha'); const beta = !options.beta ? 'no' : options.beta; console.log('beta is: %s', beta); ``` ### 运行应用 试着用 `node` 命令来运行它,首先不使用选项: ``` $ node ./example.js Options detected: beta is: Foo ``` 在用户没有覆盖的情况下,`beta` 的默认值被使用。 再次运行它,这次使用选项: ``` $ node ./example.js --beta hello --alpha Options detected: alpha beta is: hello ``` 这次,测试脚本成功检测到了选项 `--alpha`,以及用户提供的 `--beta` 选项的值。 ### 选项解析 下面是完整的演示代码供你参考: ``` const { program } = require('commander'); program .description('A sample application to parse options') .option('-a, --alpha', 'Alpha') .option('-b, --beta <VALUE>', 'Specify a VALUE', 'Foo'); program.parse(); const options = program.opts(); console.log('Options detected:'); console.log(typeof options); if (options.alpha) console.log(' * alpha'); const beta = !options.beta ? 'no' : options.beta; console.log(' * beta is: %s', beta); ``` 在该项目的 [Git 仓库](https://github.com/tj/commander.js) 中还有更多例子。 对任何应用来说,包括用户的选项都是一个重要的功能,而 Commander.js 使它很容易做到。除了 Commander.js,还有其他库,但我觉得这个库使用起来很方便快捷。你最喜欢的 JavaScript 命令行构建器是什么? --- via: <https://opensource.com/article/21/11/javascript-command-line-apps> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
JavaScript is a language developed for the web, but its usefulness has gone far beyond just the Internet. Thanks to projects like Node.js and Electron, JavaScript is as much a general-purpose scripting language as a browser component. There are JavaScript libraries specially designed to build command-line interfaces. Yes, you can run JavaScript in your terminal. Now, when you enter a command into your terminal, there are generally [options](https://opensource.com/article/21/8/linux-terminal), also called *switches* or *flags*, that you can use to modify how the command runs. This is a useful convention defined by the [POSIX specification](https://opensource.com/article/19/7/what-posix-richard-stallman-explains), so as a programmer, it's helpful to know how to detect and parse the options. To get this functionality from JavaScript, it's useful to use a library designed to make it easy to build command-line interfaces. My favorite is [Commander.js](https://github.com/tj/commander.js). It's easy, it's flexible, and it's intuitive. ## Installing node To use the Commander.js library, you must have Node.js installed. On Linux, you can install Node using your package manager. For example, on Fedora, CentOS, Mageia, and others: `$ sudo dnf install nodejs` On Windows and macOS, you can [download installers from the nodejs.org website](https://nodejs.org/en/download). ## Installing Commander.js To install Commander.js, use the `npm` command: `$ npm install commander` ## Adding a library to your JavaScript code In JavaScript, you can use the `require` keyword to include (or import, if you're used to Python) a library into your code. Create a file called `example.js` and open it in your favorite text editor. Add this line to the top to include the Commander.js library: `const { program } = require('commander');` ## Option parsing in JavaScript The first thing you must do to parse options is to define the valid options your application can accept. The Commander.js library lets you define both short and long options, along with a helpful message to clarify the purpose of each. ``` program .description('A sample application to parse options') .option('-a, --alpha', 'Alpha') .option('-b, --beta <VALUE>', 'Specify a VALUE', 'Foo'); ``` The first option, which I've called `--alpha` (`-a` for short), is a Boolean switch: It either exists or it doesn't. It takes no arguments. The second option, which I've called `--beta` (`-b` for short), accepts an argument and even specifies a default value when you've provided nothing. ## Accessing the command-line data Once you've defined valid options, you can reference the values using the long option name: ``` program.parse(); const options = program.opts(); console.log('Options detected:'); if (options.alpha) console.log('alpha'); const beta = !options.beta ? 'no' : options.beta; console.log('beta is: %s', beta); ``` ## Run the application Try running it with the `node` command, first with no options: ``` $ node ./example.js Options detected: beta is: Foo ``` The default value for `beta ` gets used in the absence of an override from the user. Run it again, this time using the options: ``` $ node ./example.js --beta hello --alpha Options detected: alpha beta is: hello ``` This time, the test script successfully detected the option `--alpha` , and the `--beta` option with the value provided by the user. ## Option parsing Here's the full demonstration code for your reference: ``` const { program } = require('commander'); program .description('A sample application to parse options') .option('-a, --alpha', 'Alpha') .option('-b, --beta <VALUE>', 'Specify a VALUE', 'Foo'); program.parse(); const options = program.opts(); console.log('Options detected:'); console.log(typeof options); if (options.alpha) console.log(' * alpha'); const beta = !options.beta ? 'no' : options.beta; console.log(' * beta is: %s', beta); ``` There are further examples in the project's [Git repository](https://github.com/tj/commander.js). Including options for your users is an important feature for any application, and Commander.js makes it easy to do. There are other libraries aside from Commander.js, but I find this one easy and quick to use. What's your favorite JavaScript command-line builder? ## Comments are closed.
13,990
7 个好玩的 Linux 命令
https://opensource.com/article/21/11/fun-linux-commands
2021-11-16T16:48:44
[ "玩具", "命令" ]
https://linux.cn/article-13990-1.html
> > 这些好玩的 Linux 命令也有它的用处。 > > > ![](/data/attachment/album/202111/16/164838m35s5q81t353sxq3.jpg "Woman sitting in front of her laptop") Linux 的命令行可以说是资深用户和系统管理员的小窝。然而,Linux 不仅仅是大量的枯燥工作。Linux 是由爱玩的人开发的,他们还创造了一系列搞笑的命令。当你想轻松一下的时候,就可以自己试着这些。 ### 蒸汽机车 随便什么时候,你可以使用 `sl` 命令使一辆<ruby> 蒸汽机车 <rt> Steam Locomotive </rt></ruby>在你的终端上跑过。可以用你的软件包管理器安装这辆蒸汽机车。例如,在 Fedora 上可以这样: ``` $ sudo dnf install sl ``` ![由符号和字符组成的蒸汽机车引擎图](/data/attachment/album/202111/16/164846dtk5uxc1u4l1xkmt.png "Steam locomotive") #### 实际用途 据我所知,`sl` 命令确实只是为了好玩。你对 `sl` 有什么有趣的用途吗?请在评论中告诉我。 (LCTT 译注:`sl` 的实际用途就是提醒你 `ls` 打错了。?) ### 壁炉 点燃一座壁炉来温暖你的心和你的终端吧,`aafire` 命令会播放一段壁炉的动画。你可以用你的软件包管理器安装 `aafire`。在 Debian、Mint、 Elementary 之类的发行版上: ``` $ sudo apt install libaa-bin ``` 在 Fedora、CentOS 之类的发行版: ``` $ sudo dnf install aalib ``` ![由文字符号和字符组成的火的黑白图像](/data/attachment/album/202111/16/164846hwa9qabggbtbtwgj.png "fireside") #### 实际用途 这个动画是向你的团队或老板传达一切即将化为乌有的微妙方式。 ### 是的 你可以使用 `yes` 命令打印出一串文字,直到用 `Ctrl+C` 强行停止。例如,我是一个 Buffalo Bills 的球迷,所以我选择用 `yes` 命令打印出一串无尽的 “Buffalo Bills”: ``` $ yes Buffalo Bills ``` ![画面上重复显示的是一行行 Buffalo Bills(左侧边缘略微被切断)](/data/attachment/album/202111/16/164847beg25y5da7dag4im.png "Yes command") #### 实际用途 你可以用这个命令来向脚本输送确认信息,这样,当脚本停顿下来要求确认时,它就会自动收到 `yes`。例如,想象一下,你运行的一个脚本经常停下来问你确认: ``` $ foo Are you sure you want to do this? Y/n Y Are you really sure? y/N Y But are you really? y/N ``` 你可以通过向命令传递 `yes` 来自动接受这些信息: ``` $ yes | foo ``` 另外,你也可以用 `yes` 来自动拒绝信息: ``` $ yes no | foo ``` ### 命运 通过安装 `fortune` 命令,你可以就可以得到命运的指点。`fortune` 会打印出一段随机的、可能有意义的话语(LCTT 译注:来自命运的指点)。 用你的软件包管理器安装 `fortune`: ``` $ sudo apt install fortune ``` 在 Fedora 上: ``` $ sudo dnf install fortune-mod ``` 命运命令有许多数据集,它可以从中提取各种话语。例如,你可以从文学作品或科幻电视节目 《Firefly》中获得名人名言,或者从笑话、关于 Linux 的技巧等中选择。在你的资源库中搜索 `fortune`,看看你的发行版提供了哪些数据集。 ``` $ fortune Johnson's law: Systems resemble the organizations that create them. ``` #### 实际用途 你可以用命运来生成一个伪随机数。没有足够的熵来使它在密码学上安全,但当你需要一个意外的数字时,你可以用来计算字符或单词: ``` $ fortune | wc --chars 38 $ fortune | wc --words 8 $ fortune | wc --chars 169 ``` ### 彩虹猫 彩虹猫(`lolcat`)是一个将文件或标准输入连接到标准输出的程序(就像一般的 `cat` 命令),并在其中加入彩虹色。你可以用管道将其他命令的输出连接到 `lolcat`,这样就可以为结果加上彩虹色。 下面是 `lolcat -h` 的帮助输出的结果。 ![屏幕上的文字被染成了彩虹的渐变色](/data/attachment/album/202111/16/164847mnzrh0rnhz0llenq.png "lolcat") (LCTT 译注:我知道 `cat` 是 `catch`。) ### “FIG 来信”和横幅 “FIG 来信”(FIGlet)来源于 Frank、Ian 和 Glenn 信件中的签名艺术。这个命令(`figlet`)和横幅命令(`banner`)可以帮你创建简单的 ASCII 文本横幅。下面是一个 CentOS 系统的文本横幅: ``` $ figlet centos.com ``` ![由符号和字符组成的阅读 “centos.com” 的文本横幅](/data/attachment/album/202111/16/164847yu3vwh3242pv5m18.png "figlet text banner") 将 `figlet` 连接到 `lolcat`,可以得到一个彩色的横幅: ``` $ figlet centos.com | lolcat ``` ![用 lolcat 将 “centos.com” 的文字横幅渲染成彩虹色](/data/attachment/album/202111/16/164848ykcl3zl2kjs9cx34.png "Figlet with lolcat effects") ``` $ banner Hello World ``` ![用英镑符号拼出的 “Hello World” 横幅](/data/attachment/album/202111/16/164848c0y2sqif4sqza3ia.png "Hello World banner") #### 实际用途 `figlet` 和 `banner` 都是提醒用户他们正在登录的系统的简单方法。就像许多系统管理员、网页设计师和云开发人员一样,当你和几十台服务器一起工作时,这很有帮助。 ### 电子语音 你可以通过安装电子语音(`espeak`)来为你的命令行添加语音功能。 一旦 `espeak` 安装完毕,调高你的电脑的音量,听你的机器和你说话,会有一些乐趣。电子语音是一个软件语音合成器,有几个不同的语音库可用: ``` $ espeak "Linux is the best operating system.” ``` ### 有趣的命令 请查阅所有这些命令的手册,以探索所有的可能性和变化。你最喜欢哪些好玩的命令,它们在现实世界中是否也有用途?请在评论中分享你的最爱。 --- via: <https://opensource.com/article/21/11/fun-linux-commands> 作者:[Don Watkins](https://opensource.com/users/don-watkins) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
The Linux command line can be the home of power users and sysadmins. However, Linux is more than just a lot of hard work. Linux was developed by fun-loving people who created an array of comical commands. Try playing around with these yourself when you want a smile. ## Steam locomotive (sl) For no reason whatsoever, you can cause a steam locomotive to zip across your terminal using the `sl` command. Install Steam Locomotive with your package manager. For example, on Fedora: `$ sudo dnf install sl` ![Steam locomotive A steam locomotive engine drawing made from symbols and characters](https://opensource.com/sites/default/files/uploads/locomotive_0.png) ### Real uses As far as I know, the `sl` command is truly just for fun. Do you have an interesting use for `sl` ? Let me know in the comments. ## Fireplace (aafire) Warm your heart and your terminal with `aafire` command, which causes a fireplace animation to play. You can install aafire with your package manager. On Debian, Mint, Elementary, and similar: `$ sudo apt install libaa-bin` On Fedora, CentOS, and others: `$ sudo dnf install aalib` ![fireside A black and white image of a fire made from text symbols and characters](https://opensource.com/sites/default/files/uploads/fireside.png) Don Watkins, CC BY-SA 4.0 ### Real uses This image is a subtle way to communicate to your team or boss that everything's about to go up in smoke. ## Yes You can use the` yes` command to print out a string of text until it is forcibly stopped with **Ctrl+C**. For example, I am a Buffalo Bills fan, so I chose to print out an endless series of Buffalo Bills with the `yes` command: `$ yes Buffalo Bills` ![Yes command A screenshot showing repeated lines of Buffalo Bills (left edge slightly cut off)](https://opensource.com/sites/default/files/uploads/bills.png) Don Watkins, CC BY-SA 4.0 ### Real uses You can use this command to pipe confirmation to scripts so that when a script pauses to ask for confirmation, it automatically receives `yes` . For example, imagine there's a script you run that often stops to ask you for confirmation: ``` $ foo Are you sure you want to do this? Y/n Y Are you really sure? y/N Y But are you really? y/N ``` You can auto-accept such messages by passing `yes ` to the command: `$ yes | foo` Alternatively, you can auto-deny messages using yes as well: `$ yes no | foo` ## Fortune You can have your fortune told on the command line by installing Fortune. Fortune prints a random and possibly meaningful message. Install Fortune with your package manager: `$ sudo apt install fortune` On Fedora: `$ sudo dnf install fortune-mod` The `fortune` command has many datasets it can draw from. For instance, you can get famous quotes from literature or the science-fiction TV show *Firefly*, or choose from jokes, tips about Linux, and much more. Search your repository for "fortune" to see what options your distribution provides. ``` $ fortune Johnson's law: Systems resemble the organizations that create them. ``` ### Real uses You can use Fortune to generate a pseudo-random number. There's not enough entropy to make it cryptographically secure, but when you need an unexpected number, you can count characters or words: ``` $ fortune | wc --chars 38 $ fortune | wc --words 8 $ fortune | wc --chars 169 ``` ## Lolcat Lolcat is a program that concatenates files, or standard input, to standard output (like the generic cat) and adds rainbow coloring to it. You can pipe the output of other commands to `lolcat,` which provides a rainbow hue to the result. Here's the result of `lolcat -h` for its help output: ![lolcat onscreen text colored in a rainbow gradient](https://opensource.com/sites/default/files/uploads/lolcat_rainbow.png) Don Watkins, CC BY-SA 4.0 ## Figlet and banner The `figlet` and `banner` commands let you create simple ASCII text banners. Here's a text banner for a CentOS system: `$ figlet centos.com` ![figlet text banner Text banner reading "centos.com" composed from symbols and characters](https://opensource.com/sites/default/files/uploads/figlet_centos.png) Don Watkins, CC BY-SA 4.0 Pipe `figlet` to `lolcat` for a colorful banner: `$ figlet centos.com | lolcat` ![Figlet with lolcat effects A text banner reading "centos.com" made rainbow colored with lolcat](https://opensource.com/sites/default/files/uploads/lolcat_figlet_centos.png) Don Watkins, CC BY-SA 4.0 `$ banner Hello World` ![Hello World banner A banner reading "Hello World" spelled out with pound symbols](https://opensource.com/sites/default/files/uploads/hello_world_0.png) Don Watkins, CC BY-SA 4.0 ### Real use Both `figlet` and `banner` are easy ways to remind users what system they're logging on to, which can be helpful when you work with dozens of servers, as many sysadmins, web designers, and cloud developers do. ## Espeak You can add speech capabilities to your command line funnies by installing `espeak` . Once `espeak` is installed, turn up the volume on your computer and have some fun listening to your machine talk to you. Espeak is a software speech synthesizer, and there are a few different voice libraries available. `$ espeak "Linux is the best operating system."` ## Fun commands Be sure to consult the man pages of all these commands to explore all the possibilities and iterations. What are your favorite silly commands, and do they have real-world uses as well? Share your favorites in the comments. ## 11 Comments
13,992
入门:如何更改 Ubuntu 的终端的字体和大小
https://itsfoss.com/change-terminal-font-ubuntu/
2021-11-17T13:27:01
[ "字体" ]
https://linux.cn/article-13992-1.html
![](/data/attachment/album/202111/17/132645otre44u7ge68tzzb.jpg) 如果你在 Ubuntu 上使用终端的时间很长,你可能会希望调整终端的字体和大小以获取一种良好的体验。 更改字体是一种最简单但最直观的 [Linux 的终端自定义](https://itsfoss.com/customize-linux-terminal/) 的方法。让我向你展示在 Ubuntu 中更改终端的字体的详细步骤,以及一些字体选择的提示和建议。 注意:这些步骤可能也对大多数的其它的 [Linux 的终端模拟器](https://itsfoss.com/linux-terminal-emulators/) 有效,但是你访问选项的方法可能会有所不同。 ### 使用 GUI 更改 Ubuntu 的终端的字体和大小 **步骤 1.** [在 Ubuntu 中打开终端窗口](https://itsfoss.com/open-terminal-ubuntu/) ,方法是按 `Ctrl+Alt+T` 组合键。 **步骤 2.** 打开终端“<ruby> 首选项 <rt> Preferences </rt></ruby>”。你可以单击菜单按钮来找到它。 ![](/data/attachment/album/202111/17/132703fn9cbztcnxkcz9nb.png) 你也可以右击终端屏幕的任意位置来访问首选项,如下图所示。 ![](/data/attachment/album/202111/17/132703hutffu35dt33y2dn.png) **步骤 3.** 现在,你应该能够访问针对终端的设置。在默认情况下,在这里将会有一个未命名的配置文件。这就是默认的配置文件。**我建议创建一个新的配置文件**,以便你的更改不会影响默认的设置。 ![](/data/attachment/album/202111/17/132705njh4ng0qzq40iex2.png) **步骤 4.** 为了更改字体,你需要启用“<ruby> 自定义字体 <rt> Custom font </rt></ruby>” 选项,接下来单击 “**Monospace Regular**” 。 ![](/data/attachment/album/202111/17/132707ityaczde00izm5qi.png) 它将显示针对这个选项的可用的一个字体列表。 ![](/data/attachment/album/202111/17/132709utjbejwrz9ziddw8.png) 在这里,你可以在字体列表的底部快速预览字体,也可以调整你的 Ubuntu 的终端的字体大小。 在默认情况下,字体的大小是 **12** ,字体的样式是 **Ubuntu mono** 。 **步骤 5.** 最后,你也可以搜索你喜欢的字体样式,并在查看预览和调整字体大小后,通过点击 “<ruby> 选择 <rt> Select </rt></ruby>” 来完成更改字体。 ![](/data/attachment/album/202111/17/132710tcc4xlbc1dp9ccel.png) 这就是全部的步骤。你已经成功地更改字体。在下面的图像中查看更改。移动划款来查看不同点。 ![Ubuntu terminal font change](/data/attachment/album/202111/17/132711bouvync3nbbilcx3.png) ### 获取针对 Ubuntu 的终端的新字体的提示 你可以中从因特网上下载 TTF 格式的字体文件,右击这些 TTF 文件 [可以很容易在 Ubuntu 中安装这些新的字体](https://itsfoss.com/install-fonts-ubuntu/) 。 ![](/data/attachment/album/202111/17/132713n22572i7gdi274ii.png) 你可以打开一个新的终端窗口来加载新安装的字体。 不过,请记住,**Ubuntu 不会在终端中显示所有新安装的字体**。为什么?因为终端已经被分配使用 monospaced 字体。如果字体中字母间靠得很近的,那看起来就很诡异了。一些字体不能清晰区分字母 “o” 和数字 “0” 。同样,你也可能面临区分小写字母 “l” 和小写字母 “i” 的难题。 这就是为什么你会在终端中所看到的字体的名称中通常会带有 “mono” 的原因。 一般来说,在字体方面可能会有很多可读性难题,这可能会造成更加混乱的局面。因此,最好选择一种不会在终端上使人难易阅读的字体。 你还应该检查在你增大/减少字体大小期间该字体是否看起来良好/诡异,以确保在你自定义你的终端时没有问题。 ### 针对终端自定义的字体建议 Free mono 和 Noto mono 是默认字体选择列表中可用的一些好字体,可应用于你的终端。 你可以尝试 [在 Linux 中安装新的字体](https://itsfoss.com/install-fonts-ubuntu/) ,像 **JetBrains Mono** 、**Robo Mono** 、Larabiefont 、Share Tech Mono 以及来自 Google 和其它来源的字体。 你喜欢在 Ubuntu 的终端上使用什么样的字体和大小?请在下面的评论区告诉我们! --- via: <https://itsfoss.com/change-terminal-font-ubuntu/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[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/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) If you are spending a lot of time using the terminal on Ubuntu, you may want to adjust the font and size to get a good experience. Changing the font is one of the simplest but most visual ways of [Linux terminal customization](https://itsfoss.com/customize-linux-terminal/). Let me show you the detailed steps for changing the terminal fonts in Ubuntu along with some tips and suggestions on font selection. [Linux terminal emulator](https://itsfoss.com/linux-terminal-emulators/)but the way you access the option can differ. ## Change Ubuntu Terminal font and size using GUI **Step 1.** [Launch the terminal on your Ubuntu](https://itsfoss.com/open-terminal-ubuntu/) system by using Ctrl+Alt+T keys. **Step 2.** Head to the “**Preferences**” option that you can find when you click on the menu. ![terminal preference](https://itsfoss.com/content/images/wordpress/2021/09/terminal-preference.png) You can also perform a right-click anywhere on the terminal to access the option as shown below. ![terminal right click menu](https://itsfoss.com/content/images/wordpress/2021/09/terminal-right-click-menu.png) **Step 3.** Now, you should be able to access the settings for the terminal. By default, there will be an unnamed profile. This is the default profile. **I suggest creating a new profile** so that your changes do not impact the default settings. ![ubuntu terminal preference option](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-terminal-preference-option-800x303.png) **Step 4**. To change the font, you need to enable the “**Custom font**” option and then click on “**Monospace Regular**” ![enable font change ubuntu terminal](https://itsfoss.com/content/images/wordpress/2021/09/enable-font-change-ubuntu-terminal.png) It will show a list of fonts available for selection. ![monospace font default](https://itsfoss.com/content/images/wordpress/2021/09/monospace-font-default.png) Here, you get a quick preview of the font at the bottom of the font listing and also the ability to tweak the font size of your Ubuntu terminal. By default, it uses a size of **12** for the font and **Ubuntu mono** style. **Step 5**. Finally, you can search for your preferred font style and hit “**Select**” to finalize it after looking at the preview and adjusting the font size. ![ubuntu custom font selection](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-custom-font-selection.png) That’s it. You have successfully changed the fonts. See the changes in the image below. Move the slider to see the difference. ![ubuntu terminal font 2](https://itsfoss.com/content/images/wordpress/2021/09/ubuntu-terminal-font-2.png) ## Tips on getting new fonts for Ubuntu terminal You can download fonts from the internet in TTF file format and [easily install these new fonts in Ubuntu](https://itsfoss.com/install-fonts-ubuntu/) by double-clicking the TTF file. ![Install New Fonts Ubuntu](https://itsfoss.com/content/images/wordpress/2020/12/install-new-fonts-ubuntu-800x463.png) You should open a new terminal window to load the newly installed fonts. However, keep in mind that **Ubuntu will not show ALL the newly installed fonts in the terminal**. Why? Because the terminal is designed to use monospaced fonts. Fonts that have letters too close to each other may look weird. Some fonts do not offer proper clarity between the alphabet O and the number 0. Similarly, you may face issues in differentiating the lowercase l and i. This is why you’ll see the available fonts in the terminal are often have ‘mono’ in their name. Overall, there can be plenty of readability issues that could create more confusion. Hence, it is best to select a font that does not make the terminal hard to read. You should also check if a font looks good/weird when you increase/decrease the size of the font to ensure that you do not have a problem when customizing the look of your terminal. ## Font suggestions for terminal customization Free mono and Noto mono are some of the good fonts available from the default list of font selections to apply on your terminal. You can try [installing new fonts in Linux](https://itsfoss.com/install-fonts-ubuntu/) like **JetBrains Mono**, and **Robo Mono**, Larabiefont, Share Tech Mono and more from Google Fonts and other sources. [5 Tweaks to Customize the Look of Your Linux TerminalWant a beautiful-looking Linux terminal? Here are several ways to tweak the look and feel of your current terminal and make it look beautiful.](https://itsfoss.com/customize-linux-terminal/)![](https://itsfoss.com/content/images/wordpress/2021/02/linux-terminal-customization.jpg) ![](https://itsfoss.com/content/images/wordpress/2021/02/linux-terminal-customization.jpg) *What font style/size do you prefer to use with the Ubuntu terminal? Let us know in the comments below!*
13,993
如何打包你的 Python 代码
https://opensource.com/article/21/11/packaging-python-setuptools
2021-11-17T18:02:56
[ "Python", "打包" ]
https://linux.cn/article-13993-1.html
> > 使用 setuptools 来向用户交付 Python 代码。 > > > ![](/data/attachment/album/202111/17/180249s8s1cnnn18gh3fsk.jpg "Python programming language logo with question marks") 你花了几周的时间来完善你的代码。你已经对它进行了测试,并把它发送给一些亲近的开发者朋友以保证质量。你已经将所有的源代码发布在 [你的个人 Git 服务器](https://opensource.com/life/16/8/how-construct-your-own-git-server-part-6) 上,并且从一些勇敢的早期使用者收到了一些有用的错误报告。现在你已经准备好将你的 Python 代码提供给全世界。 就在这时你遇到一个问题。你不知道如何交付产品。 将代码交付给它的目标用户是一件大事。这是软件开发的一个完整的分支,是 CI/CD 中的 “D”,但很多人都忘记了,至少到最后才知道。我写过关于 [Autotools](https://opensource.com/article/19/7/introduction-gnu-autotools) 和 [Cmake](https://opensource.com/article/21/5/cmake) 的文章,但有些语言有自己的方法来帮助你将你的代码提供给用户。对于 Python 来说,向用户提供代码的一个常见方法是使用 `setuptools`。 ### 安装 setuptools 安装和更新 `setuptools` 的最简单方法是使用 `pip`: ``` $ sudo python -m pip install --upgrade setuptools ``` ### 示例库 我创建了一个简单的 Python 库,名为 `myhellolib`,来作为需要打包的示例代码。这个库接受一个字符串,然后用大写字母打印出这个字符串。 它只有两行代码,但项目结构很重要,所以首先创建目录树: ``` $ mkdir -p myhellolib.git/myhellolib ``` 为了确认这个项目是一个可导入的库(即 Python “模块”),在代码目录中创建一个空文件 `__init__.py`,同时创建一个包含代码的文件: ``` $ touch myhellolib.git/myhellolib/__init__.py $ touch myhellolib.git/myhellolib/myhellolib.py ``` 在 `myhellolib.py` 文件中,输入简单的 Python 代码: ``` def greeter(s): print(s.upper()) ``` 这就是写好的库。 ### 测试它 在打包之前,测试一下你的库。创建一个 `myhellolib.git/test.py` 文件并输入以下代码: ``` import myhellolib.myhellolib as hello hello.greeter("Hello Opensource.com.") ``` 运行该脚本: ``` $ cd myhellolib.git $ python ./test.py HELLO OPENSOURCE.COM ``` 它可以工作,所以现在你可以把它打包了。 ### Setuptools 要用 `setuptools` 打包一个项目,你必须创建一个 `.toml` 文件,将 `setuptools` 作为构建系统。将这段文字放在项目目录下的 `myhellolib.toml` 文件中。 ``` [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" ``` 接下来,创建一个名为 `setup.py` 的文件,包含项目的元数据: ``` from setuptools import setup setup( name='myhellolib', version='0.0.1', packages=['myhellolib'], install_requires=[ 'requests', 'importlib; python_version == "3.8"', ], ) ``` 不管你信不信,这就是 `setuptools` 需要的所有设置。你的项目已经可以进行打包。 ### 打包 Python 要创建你的 Python 包,你需要一个构建器。一个常见的工具是 `build`,你可以用 `pip` 安装它: ``` $ python -m pip install build --user ``` 构建你的项目: ``` $ python -m build ``` 过了一会儿,构建完成了,在你的项目文件夹中出现了一个新的目录,叫做 `dist`。这个文件夹包含一个 `.tar.gz` 和一个 `.whl` 文件。 这是你的第一个 Python 包! 下面是包的内容: ``` $ tar --list --file dist/myhellolib-0.0.1.tar.gz myhellolib-0.0.1/ myhellolib-0.0.1/PKG-INFO myhellolib-0.0.1/myhellolib/ myhellolib-0.0.1/myhellolib/__init__.py myhellolib-0.0.1/myhellolib/myhellolib.py myhellolib-0.0.1/myhellolib.egg-info/ myhellolib-0.0.1/myhellolib.egg-info/PKG-INFO myhellolib-0.0.1/myhellolib.egg-info/SOURCES.txt myhellolib-0.0.1/myhellolib.egg-info/dependency_links.txt myhellolib-0.0.1/myhellolib.egg-info/requires.txt myhellolib-0.0.1/myhellolib.egg-info/top_level.txt myhellolib-0.0.1/setup.cfg myhellolib-0.0.1/setup.py $ unzip -l dist/myhellolib-0.0.1-py3-none-any.whl Archive: dist/myhellolib-0.0.1-py3-none-any.whl Name ---- myhellolib/__init__.py myhellolib/myhellolib.py myhellolib-0.0.1.dist-info/METADATA myhellolib-0.0.1.dist-info/WHEEL myhellolib-0.0.1.dist-info/top_level.txt myhellolib-0.0.1.dist-info/RECORD ------- 6 files ``` ### 让它可用 现在你知道了打包你的 Python 包是多么容易,你可以使用 Git 钩子、GitLab Web 钩子、Jenkins 或类似的自动化工具来自动完成这个过程。你甚至可以把你的项目上传到 PyPi,这个流行的 Python 模块仓库。一旦它在 PyPi 上,用户就可以用 `pip` 来安装它,就像你在这篇文章中安装 `setuptools` 和 `build` 一样! 当你坐下来开发一个应用或库时,打包并不是你首先想到的事情,但它是编程的一个重要方面。Python 开发者在程序员如何向世界提供他们的工作方面花了很多心思,没有比 `setuptools` 更容易的了。试用它,使用它,并继续用 Python 编码! --- via: <https://opensource.com/article/21/11/packaging-python-setuptools> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
You've spent weeks perfecting your code. You've tested it and sent it to some close developer friends for quality assurance. You've posted all the source code on [your personal Git server](https://opensource.com/life/16/8/how-construct-your-own-git-server-part-6), and you've received helpful bug reports from a few brave early adopters. And now you're ready to make your Python code available to the world. And that's when it hits you. You have no idea how to deliver the product. Delivering code to its target is a big deal. It's a whole branch of software development, it's the "D" in CI/CD, and yet many people forget all about, at least until the end. I've written articles about [Autotools](https://opensource.com/article/19/7/introduction-gnu-autotools) and [Cmake](https://opensource.com/article/21/5/cmake), but some languages have their own methods to help you make your code readily available to users. For Python, a common way to deliver code to users is with `setuptools` . ## Install setuptools The easiest way to install and update `setuptools` is with `pip` : `$ sudo python -m pip install --upgrade setuptools` ## Example library Create a simple Python library called `myhellolib` for some example code in need of packaging. This library accepts a string and then prints the string in capital letters. It's two lines of code, but project structure is important, so first create the directory tree: `$ mkdir -p myhellolib.git/myhellolib` To confirm that this project is an importable library (a Python "module"), create the empty file `__init__.py` in the code directory, along with the file that contains the code: ``` $ touch myhellolib.git/myhellolib/__init__.py $ touch myhellolib.git/myhellolib/myhellolib.py ``` In the `myhellolib.py` file, enter this simple Python code: ``` def greeter(s): print(s.upper()) ``` That's the library written. ## Test it Before packaging it up, test your library. Create a `myhellolib.git/test.py` file and enter this code: ``` import myhellolib.myhellolib as hello hello.greeter("Hello Opensource.com.") ``` Run the script: ``` $ cd myhellolib.git $ python ./test.py HELLO OPENSOURCE.COM ``` It works, so now you can package it up. ## Setuptools To package a project with `setuptools` , you must create a `.toml` file identifying `setuptools` as the build system. Place this text in a file called `myhellolib.toml` in your project directory: ``` [build-system] requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" ``` Next, create a file called `setup.py` , containing metadata about your project: ``` from setuptools import setup setup( name='myhellolib', version='0.0.1', packages=['myhellolib'], install_requires=[ 'requests', 'importlib; python_version == "3.8"', ], ) ``` Believe it or not, that's all the setup `setuptools` requires. Your project is ready for packaging. ## Packaging Python To create your Python package, you need a builder. A common tool is `build` , which you can install with `pip` : `$ python -m pip install build --user` Build your project: `$ python -m build` After a few moments, the build completes, and there's a new directory in your project folder called `dist` . This folder contains a `.tar.gz` and a `.whl` file. Your very first Python package! Here's what each one contains: ``` $ tar --list --file dist/myhellolib-0.0.1.tar.gz myhellolib-0.0.1/ myhellolib-0.0.1/PKG-INFO myhellolib-0.0.1/myhellolib/ myhellolib-0.0.1/myhellolib/__init__.py myhellolib-0.0.1/myhellolib/myhellolib.py myhellolib-0.0.1/myhellolib.egg-info/ myhellolib-0.0.1/myhellolib.egg-info/PKG-INFO myhellolib-0.0.1/myhellolib.egg-info/SOURCES.txt myhellolib-0.0.1/myhellolib.egg-info/dependency_links.txt myhellolib-0.0.1/myhellolib.egg-info/requires.txt myhellolib-0.0.1/myhellolib.egg-info/top_level.txt myhellolib-0.0.1/setup.cfg myhellolib-0.0.1/setup.py $ unzip -l dist/myhellolib-0.0.1-py3-none-any.whl Archive: dist/myhellolib-0.0.1-py3-none-any.whl Name ---- myhellolib/__init__.py myhellolib/myhellolib.py myhellolib-0.0.1.dist-info/METADATA myhellolib-0.0.1.dist-info/WHEEL myhellolib-0.0.1.dist-info/top_level.txt myhellolib-0.0.1.dist-info/RECORD ------- 6 files ``` ## Making it available Now that you know how easy it is to package up your Python package, you can either automate the process using Git hooks, GitLab webhooks, Jenkins, or a similar automation tool. You can even upload your project to PyPi, the popular repository for Python modules. Once it's on PyPi, users can install it using `pip` , the same way you installed `setuptools` and `build` for this article! It's not often the first thing you think about when sitting down to develop an application or library, but packaging code is an important aspect of programming. Python developers put a lot of thought into how programmers can make their work available to the world, and it doesn't get much easier than `setuptools` . Try it out, use it, and keep coding in Python! ## Comments are closed.
13,995
在 FreeDOS 中设置和使用环境变量
https://opensource.com/article/21/6/freedos-environment-variables
2021-11-18T15:22:02
[ "FreeDOS", "环境变量" ]
https://linux.cn/article-13995-1.html
> > 环境变量几乎在每种命令行环境中都是很有帮助的,自然包括 FreeDOS 。 > > > ![](/data/attachment/album/202111/18/152155twzasgwwrzsmmvs2.jpg) 几乎在每个命令行环境中的一个有用的功能是 *环境变量*。其中的一些变量允许你控制命令行的行为或功能,其它的变量仅允许你存储可能稍后需要的数据,在 FreeDOS 中也使用了环境变量。 ### 在 Linux 上的变量 在 Linux 上,你可能已经熟悉其中的一些重要的环境变量。在 Linux 上的 [Bash](https://opensource.com/article/19/8/using-variables-bash) shell 中,`PATH` 变量标示着 shell 可以在哪里找到程序和命令。例如,在我的 Linux 系统上,我的 `PATH` 值如下: ``` bash$ echo $PATH /home/jhall/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin ``` 这意味着,当我输入一个像 `cat` 这样的命令的名称时,Bash 将会按顺序检查我在 `PATH` 变量中所列出的每个目录: 1. `/home/jhall/bin` 2. `/usr/lib64/ccache` 3. `/usr/local/bin` 4. `/usr/local/sbin` 5. `/usr/bin` 6. `/usr/sbin` 在我的实例中,`cat` 命令位于 `/usr/bin` 目录,因此,完整的路径是 `/usr/bin/cat` 。 为在 Linux 上设置一个环境变量,你可以输入一个变量的名称,接着输入一个等于符号(`=`),接着输入一个要存储在变量中的值。为了随后使用 Bash 引用这个值,你需要在变量的名称前输入一个美元符号(`$`)。 ``` bash$ var=Hello bash$ echo $var Hello ``` ### 在 FreeDOS 上的变量 在 FreeDOS 上,环境变量提供一种类似的功能。一些变量控制 DOS 系统的行为,另一些变量用于存储一些临时值。 为在 FreeDOS 上设置一个环境变量,你需要使用 `SET` 关键字。FreeDOS 是 *不区分大小写的* ,因此你可以输入大写字母也可以使用小写字母。接下来,像你在 Linux 上一样设置变量,使用变量名称,一个等于符号(`=`),你想要存储的值。 不过,在 FreeDOS 中引用或 *扩展* 一个环境变量的值的方法,与你在 Linux 上所使用的方法是完全不同的。在 FreeDOS 中,你不能使用美元符号(`$`)来引用一个变量。你反而需要使用百分符号 (`%`)来包围变量的名称。 ![Use % (not $) to reference a variable's value](/data/attachment/album/202111/18/152204xathvo7cvtazbo31.png) 在名称前后使用百分符号是非常重要,因为这就是 FreeDOS 知悉变量名称在哪里开始和结束的方式。这是非常有用的,因为它会允许你引用一个变量的值,与此同时,它会立即附加(或预置)其它的文本到值中。让我通过设置一个新的名称为 `reply` 的值为 `yes` 的变量,然后在 “11” 之前和 “22” 之后引用这个值来演示这一点: ![Set and reference an environment variable](/data/attachment/album/202111/18/152204y41040a4xgj1l6zu.png) 因为 FreeDOS 是不区分大小写的,所以你可以使用大写字母称或小写字母的变量名称以及 `SET` 关键字。不过,变量的值将使用你在命令行中所输入的字母。 最后,你可以看到当前在 FreeDOS 中定义的所有的环境变量。不使用任何参数的 `SET` 关键字将显示所有的变量,因此你可以一目了然: ![Show all variables at once with SET](/data/attachment/album/202111/18/152205m43j0jxxo4jcboiz.png) 环境变量是一个有用的基本的命令行环境,同样适用于 FreeDOS 。你可以设置你自己的变量以满足你自己的需要,但是要仔细地更改 FreeDOS 使用的一些变量。这些变量会更改你正在运行的 FreeDOS 系统的行为: * `DOSDIR`:FreeDOS 安装目录的位置,通常是 `C:\FDOS` * `COMSPEC`:FreeDOS 的 shell 的当前实例,通常是 `C:\COMMAND.COM` 或 `%DOSDIR%\BIN\COMMAND.COM` * `LANG`:用户的首选语言 * `NLSPATH`:系统语言文件的位置,通常是 `%DOSDIR%\NLS` * `TZ`:系统的时区 * `PATH`:一个目录列表,FreeDOS 可以在其中找到要运行的程序,例如 `%DOSDIR%\BIN` * `HELPPATH`:系统文档文件的位置,通常是 `%DOSDIR%\HELP` * `TEMP`:一个临时目录,FreeDOS 在其中存储来自每个命令的输出,如同它在命令行上的程序之间的 “管道” 数据 * `DIRCMD`:一个控制 `DIR` 命令如何显示文件和目录的变量,通常设置 `/OGNE` 来排序(`O`)内容,先通过分组(`G`)目录,接下来按照名称(`N`) 、扩展名(`E`)来排序条目 如果你偶然间更改了任意的 FreeDOS 的 “内部” 变量,你可能会阻碍 FreeDOS 的一些部分的正常工作。在这种情况下,只需要简单地重新启动你的计算机,FreeDOS 将会按照系统默认值重新设置变量。 --- via: <https://opensource.com/article/21/6/freedos-environment-variables> 作者:[Jim Hall](https://opensource.com/users/jim-hall) 选题:[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/) 荣誉推出
200
OK
A useful feature in almost every command-line environment is the *environment variable*. Some of these variables allow you to control the behavior or features of the command line, and other variables simply allow you to store data that you might need to reference later. Environment variables are also used in FreeDOS. ## Variables on Linux On Linux, you may already be familiar with several of these important environment variables. In the [Bash](https://opensource.com/article/19/8/using-variables-bash) shell on Linux, the `PATH` variable identifies where the shell can find programs and commands. For example, on my Linux system, I have this `PATH` value: ``` bash$ echo $PATH /home/jhall/bin:/usr/lib64/ccache:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin ``` That means when I type a command name like `cat` , Bash will check each of the directories listed in my `PATH` variable, in order: `/home/jhall/bin` `/usr/lib64/ccache` `/usr/local/bin` `/usr/local/sbin``/usr/bin` `/usr/sbin` And in my case, the `cat` command is located in the `/usr/bin` directory, so the full path to that command is `/usr/bin/cat` . To set an environment variable on Linux, you type the name of the variable, then an equals sign (`=` ) and then the value to store in the variable. To reference that value later using Bash, you type a dollar sign (`$` ) in front of the variable name. ``` bash$ var=Hello bash$ echo $var Hello ``` ## Variables on FreeDOS On FreeDOS, environment variables serve a similar function. Some variables control the behavior of the DOS system, and others are useful to store some temporary value. To set an environment variable on FreeDOS, you need to use the `SET` keyword. FreeDOS is *case insensitive*, so you can type that using either uppercase or lowercase letters. Then set the variable as you might on Linux, using the variable name, an equals sign (`=` ), and the value you want to store. However, referencing or *expanding* an environment variable's value in FreeDOS is quite different from how you do it on Linux. You can't use the dollar sign (`$` ) to reference a variable in FreeDOS. Instead, you need to surround the variable's name with percent signs (`%` ). ![Use % (not $) to reference a variable's value Use % (not $) to reference a variable's value](https://opensource.com/sites/default/files/uploads/env-path.png) Image by Jim Hall, CC-BY SA 4.0 It's important to use the percent signs both before and after the name because that's how FreeDOS knows where the variable name begins and ends. This is very useful, as it allows you to reference a variable's value while immediately appending (or prepending) other text to the value. Let me demonstrate this by setting a new variable called `reply` with the value `yes` , then referencing that value with the text "11" before and "22" after it: ![Set and reference an environment variable Set and reference an environment variable](https://opensource.com/sites/default/files/uploads/env-vars.png) Image by Jim Hall, CC-BY SA 4.0 Because FreeDOS is case insensitive you can also use uppercase or lowercase letters for the variable name, as well as the `SET` keyword. However, the variable's value will use the letter case as you typed it on the command line. Finally, you can see a list of all the environment variables currently defined in FreeDOS. Without any arguments, the `SET` keyword will display all variables, so you can see everything at a glance: ![Show all variables at once with SET Show all variables at once with SET](https://opensource.com/sites/default/files/uploads/env-set.png) Image by Jim Hall, CC-BY SA 4.0 Environment variables are a useful staple in command-line environments, and the same applies to FreeDOS. You can set your own variables to serve your own needs, but be careful about changing some of the variables that FreeDOS uses. These can change the behavior of your running FreeDOS system: **DOSDIR**: The location of the FreeDOS installation directory, usually`C:\FDOS` **COMSPEC**: The current instance of the FreeDOS shell, usually`C:\COMMAND.COM` or`%DOSDIR%\BIN\COMMAND.COM` **LANG**: The user's preferred language**NLSPATH**: The location of the system's language files, usually`%DOSDIR%\NLS` **TZ**: The system's time zone**PATH**: A list of directories where FreeDOS can find programs to run, such as`%DOSDIR%\BIN` **HELPPATH**: The location of the system's documentation files, usually`%DOSDIR%\HELP` **TEMP**: A temporary directory where FreeDOS stores output from each command as it "pipes" data between programs on the command line**DIRCMD**: A variable that controls how the`DIR` command displays files and directories, typically set to`/OGNE` to order (O) the contents by grouping (G) directories first, then sorting entries by name (N) then extension (E) If you accidentally change any of the FreeDOS "internal" variables, you could prevent some parts of FreeDOS from working properly. In that case, simply reboot your computer, and FreeDOS will reset the variables from the system defaults. ## Comments are closed.
13,997
树莓派 3 还是 4:你应该买哪一个?
https://itsfoss.com/raspberry-pi-3-vs-4/
2021-11-18T17:19:00
[ "树莓派" ]
https://linux.cn/article-13997-1.html
![](/data/attachment/album/202111/18/171924sg0bk3iu43bwi3x4.jpg) 树莓派是一种物美价廉的单板计算机,在很多场景都很有用。不过,在树莓派 4 之前,它作为快速的桌面替代品并不是一个特别合适的选择。 所以,树莓派 4 以其新的功能改变了游戏规则。但是,它与树莓派 3 相比如何? 树莓派 3 仍然值得考虑吗?或者,你应该去买最新和更强大的树莓派 4? 在这篇文章中,我们试图通过强调两者之间的一些关键差异来为你提供一些答案。 首先,让我们看一下两者提供的规格: ### 树莓派 3 的规格 ![](/data/attachment/album/202111/18/171951z7pqdplqq0k9kpqg.jpg) 树莓派 3 满足了一个基本入门 DIY 项目的所有要求。如果 [树莓派 Zero 或 树莓派 Zero W](https://itsfoss.com/raspberry-pi-zero-vs-zero-w/) 不符合你的要求,那么树莓派 3 是一个物美价廉的选择: * 四核 1.2GHz 博通 BCM2837 64 位 CPU * 1GB 内存 * 无线局域网和低功耗蓝牙(BLE) * 以太网 * 40 针扩展 GPIO * 4 个 USB 2 端口 * 4 极立体声输出和复合视频端口 * 全尺寸的 HDMI * CSI 摄像机端口 * DSI 显示端口 * 用于操作系统和存储数据的微型 SD 端口 * 升级后的开关式微型 USB 电源,最高可达 2.5A 电流 ### 树莓派 4 的规格 ![](/data/attachment/album/202111/18/171952dkeq6eq9yvzrvllm.jpg) * 博通 BCM2711,四核 Cortex-A72(ARM v8)64 位 SoC @ 1.5GHz * 2GB、4GB 或 8GB LPDDR4-3200 * 2.4 GHz 和 5.0 GHz IEEE 802.11ac 无线,蓝牙 5.0,BLE * 千兆位以太网 * 2 个 USB 3.0 端口 * 2 个 USB 2.0 端口 * 40 针 GPIO 接头(向后兼容) * 2 个微型 HDMI 端口(最多可支持 4kp60) * 2 线 MIPI DSI 显示端口 * 2 线 MIPI CSI 摄像头端口 * 4 极立体声音频和复合视频端口 * H.265(4kp60 解码),H264(1080p60 解码,1080p30 编码) * OpenGL ES 3.1,Vulkan 1.0 * 用于操作系统和存储数据的 MicroSD 卡插槽 * 通过 USB-C 接口的 5V 直流电 * 通过 GPIO 接头的 5V 直流电 * 通过以太网供电 ### 内存(RAM)选项 对于树莓派机型,通常情况下,你会得到一个包括 1 或 2GB 内存的单一产品阵容。 树莓派 3B+ 就是这种情况。如果你不需要更多的内存,树莓派 3 可以就是一个不错的解决方案,可以满足所有常规 DIY 项目的需求。 然而,对于树莓派 4,你可以选择 2GB、4GB 和 8GB 的版本。所以,如果你想完成更多的事情,或者在你的树莓派板上实现多个任务,树莓派 4 应该是一个不错的选择。 ### 性能差异 尽管这两块板子都采用了博通公司的芯片,但树莓派 4 的性能明显更快。 如果你想把它作为你的迷你桌面的替代品,或者想为你的任务获得更好的计算能力,树莓派 4 将是明显的选择。 说到树莓派 3,它配备了一个四核 1.2GHz 的博通 BCM2837 64 位 CPU。它是一个能够完成各种任务的芯片。 #### 连接能力 两块树莓派板都提供了一个 40 针的扩展 GPIO 接头。 然而,说到 USB 连接时,树莓派 4 提供了两个 USB 3.0 端口以及另外两个 USB 2 端口。而树莓派 3 只限于两个 USB 2 端口。 因此,如果你需要更快的数据传输速度,USB 3.0 端口应该会有帮助。例如,如果你要使用任何 [媒体服务器软件](https://itsfoss.com/best-linux-media-server/),这可以派上用场。 除此之外,树莓派 4 上还有 USB-C 的存在,如果 USB 配件需要,它可以用来给电路板供电(5V DC)。 #### 双显示器与相机支持 虽然树莓派 3 提供了一个全尺寸的 HDMI 端口、DSI 端口和 CS 端口,但它并不具有双显示器支持。 有了树莓派 4,你可以得到两个微型 HDMI 端口,一个双通道 DSI 端口和一个双通道 CSI 摄像头端口。 ### 你应该买哪一个? | 规格 | 树莓派 3 | 树莓派 4 | | --- | --- | --- | | **处理器** | 四核 1.2GHz 博通 BCM2837 | 四核 1.5GHz 博通BCM2711 | | **RAM** | 1 GB | 高达 8 GB | | **蓝牙** | BLE | 蓝牙 5.0 | | **USB端口** | 4 x USB 2.0 | 2 x USB 3.0,2 x USB 2.0 | | **无线连接** | 是 | 是,2.4 GHz & 5 GHz 频段支持 | | **显示端口** | 1 x HDMI,1 x DSI | 2 x micro-HDMI,1 个 DSI | | **电源** | microUSB 和 GPIO,高达 2.5 A | 5V DC,通过 USB-C 和GPIO(3 A) | | **MicroSD 插槽** | 是 | 是 | | **价格** | 35 美元 | 35 美元(1 GB 内存)、45 美元(2 GB 内存)、55 美元(4 GB 内存)、75 美元(8 GB 内存) | 如果你想要更快的数据传输,支持双显示器,以及更好的性能,树莓派 4 是一个很好的选择。 考虑到 2GB 内存的树莓派 4 基本型号的价格约为 35 美元。以几乎相同的价格选择 1GB 的树莓派 3 型号,实在是毫无意义。 当然,除非你能得到一个更便宜的价格,并且有特定的要求。树莓派 4 总体上是一个明确的选择。 然而,有一些事情,如板子发热和其他潜在的问题,你可能想在决定之前探讨一下。树莓派 3 已被证明能在许多项目中发挥作用,而树莓派 4 是相当新的,可能还没有经过各种项目的测试。 一旦你确定了这一点,你就可以继续得到它们中的任何一个。 你喜欢用什么?你都试过了吗?请在下面的评论中告诉我们。 --- via: <https://itsfoss.com/raspberry-pi-3-vs-4/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Raspberry Pi is an inexpensive single-board computer useful for many things. And, until Raspberry Pi 4, it was not an impressive option as a quick desktop replacement. So, yes, Raspberry Pi 4 changed the game with its new capabilities. But, how does it compare to Raspberry Pi 3? Is Raspberry Pi 3 still worth considering? Or, should you go for the latest and greatest Raspberry Pi 4? In this article, we try to get you some answers to that by highlighting some key differences between the two. First, let us look at the specifications both offer. ## Raspberry Pi 3 specifications ![raspberry pi 3](https://itsfoss.com/content/images/wordpress/2021/11/raspberry-pi-3.jpg) Raspberry Pi 3 checks all the boxes for a basic starter DIY project. If [Raspberry Pi Zero or Raspberry Pi Zero W](https://itsfoss.com/raspberry-pi-zero-vs-zero-w/) does not suit your requirements, Raspberry Pi 3 is a sweet spot without spending a lot. - Quad Core 1.2GHz Broadcom BCM2837 64bit CPU - 1GB RAM - Wireless LAN and Bluetooth Low Energy (BLE) - Ethernet - 40-pin extended GPIO - 4 x USB 2 ports - 4 Pole stereo output and composite video port - Full size HDMI - CSI camera port - DSI display port - Micro SD port for operating system and storing data - Upgraded switched Micro USB power source up to 2.5A ## Raspberry Pi 4 Specifications ![raspberry pi 4](https://itsfoss.com/content/images/wordpress/2021/09/raspberry-pi-4.jpg) - Broadcom BCM2711, Quad core Cortex-A72 (ARM v8) 64-bit SoC @ 1.5GHz - 2 GB, 4 GB or 8 GB LPDDR4-3200 - 2.4 GHz and 5.0 GHz IEEE 802.11ac wireless, Bluetooth 5.0, BLE - Gigabit Ethernet - 2 x USB 3.0 ports - 2 x USB 2.0 ports. - 40 pin GPIO header (backwards compatible) - 2 × micro-HDMI ports (up to 4kp60 supported) - 2-lane MIPI DSI display port - 2-lane MIPI CSI camera port - 4-pole stereo audio and composite video port - H.265 (4kp60 decode), H264 (1080p60 decode, 1080p30 encode) - OpenGL ES 3.1, Vulkan 1.0 - Micro-SD card slot for operating system and storing data - 5V DC via USB-C connector - 5V DC via GPIO header - Power over Ethernet ## Memory (RAM) options With Raspberry Pi models, usually, you get a single product lineup including 1 or 2 GB of RAM. And, that is the case with Raspberry Pi 3 B+. If you do not need more memory, Raspberry Pi 3 can prove to be a decent solution for all the usual DIY projects you used it with. However, with Raspberry Pi 4, you get the choices of a 2 GB, 4 GB, and 8 GB variant. So, if you want to get more things done, or achieve multiple tasks on your Raspberry Pi board, the Raspberry Pi 4 should be a great option. ## Performance differences Even though both the boards feature chips from Broadcom, Raspberry Pi 4 offers significantly faster performance. If you want to use it as your mini-desktop replacement or want better computing power for your tasks, Raspberry Pi 4 will be the obvious pick. When it comes to Raspberry Pi 3, it packs in a Quad-Core 1.2GHz Broadcom BCM2837 64-bit CPU. It is a capable chip for a variety of tasks. ### Connectivity capabilities Both the Raspberry Pi boards provide a 40-pin extended GPIO header. However, when it comes to USB connectivity, Raspberry Pi 4 provides two USB 3.0 ports along with two more USB 2 ports. And, the Raspberry Pi 3 limits to two USB 2 ports. So, if you require faster data transfer speeds, USB 3.0 ports should be of help. For instance, if you are going to use any [media server software](https://itsfoss.com/best-linux-media-server/), this could come in handy. In addition to this, there’s also the presence of USB-C on Raspberry Pi 4 which can be used to power up (5V DC) the board if the USB accessories need it. ### Dual-Monitor & camera support While the Raspberry Pi 3 offers a full-size HDMI port, DSI port, and CSI port, it does not feature dual-monitor support. With Raspberry Pi 4, you get two micro-HDMI ports, a two-lane DSI port, and a two-lane CSI camera port. ### Awesome Raspberry Pi Projects to Check Out 25 Raspberry Pi projects anyone can follow! ## Which one should you get? Specifications | Raspberry Pi 3 | Raspberry Pi 4 | Processor | Quad-Core 1.2GHz Broadcom BCM2837 | Quad-Core 1.5 GHz Broadcom BCM2711 | RAM | 1 GB | Up to 8 GB | Bluetooth | BLE | Bluetooth 5.0 | USB Ports | 4 x USB 2.0 | 2 x USB 3.0 2 x USB 2.0 | Wireless Connectivity | Yes | Yes, 2.4 GHz & 5 GHz band support | Display Ports | 1 x HDMI 1 x DSI | 2 x micro-HDMI 1 x DSI | Power Supply | microUSB & GPIO up to 2.5 A | 5V DC via USB-C and GPIO (3 A) | MicroSD Slot | Yes | Yes | Price | $35 | $35 (1 GB RAM), $45 (2 GB RAM), $55 (4 GB RAM), $75 (8 GB RAM) | Raspberry Pi 4 is an excellent choice if you want faster data transfer, dual-monitor support, and better performance. Considering the price for a Raspberry Pi 4 base variant with 2 GB RAM costs about $35. It just does not make sense to opt for the 1 GB Raspberry Pi 3 model at nearly the same price. Of course, unless you get a cheaper deal and have a specific requirement. Raspberry Pi 4 is a clear choice overall. However, there are a few things like board heating and other potential issues that you may want to explore before deciding. Raspberry Pi 3 has proven to work with many projects and Raspberry Pi 4 is fairly new that may not have been tested with various projects. Once you’re sure about this, you can proceed to get any of them. What do you prefer to use? Have you tried both? Let us know in the comments below.
13,998
利用基于 QEMU 的 Quickgui 轻松创建虚拟机
https://itsfoss.com/quickgui/
2021-11-19T10:45:21
[ "QEMU", "虚拟机" ]
https://linux.cn/article-13998-1.html
> > Quickgui 旨在成为 VirtualBox 的一个更简单的替代品,帮助你快速创建虚拟机。让我们来看看它。 > > > ![](/data/attachment/album/202111/19/104431xwh8h8hw228e77hh.jpg) 目前,借助 VirtualBox、VMware 和其他一些程序,创建虚拟机相当容易。 你当然可以 [在你的 Linux 系统中安装 VirtualBox](https://itsfoss.com/install-virtualbox-ubuntu/) 来创建虚拟机。但是,在这篇文章中,我把重点放在一个令人兴奋的工具上,即 Quickgui,它使用简单,运行速度快,能帮助你快速启动虚拟机。 ### Quickgui:Quickemu 的图形用户界面前端 ![](/data/attachment/album/202111/19/104521zufbsdx6ouysbutf.png) Quickemu 是一个基于终端的工具,可以让你创建优化的桌面虚拟机并轻松地管理它们。该工具专注于消除配置虚拟机的所有细微差别。相反,它根据虚拟机的可用系统资源选择最佳配置以使其正常工作。 不仅限于配置,它还会下载操作系统的镜像(使用 quickget 包)。 因此,你所要做的就是像通常那样安装操作系统,然后开始工作。 Quickemu 以 [QEMU](https://www.qemu.org/) 为核心,旨在用 Bash 和 QEMU 取代 VirtualBox。 QEMU 是一个开源的机器仿真器和虚拟化器。 Quickemu 是一个有趣的项目,由 [Martin Wimpress](https://twitter.com/m_wimpress)(Ubuntu MATE 负责人)在一些贡献者的帮助下完成。 作为对这个工具的补充,Quickgui 是一个使用 [Flutter](https://itsfoss.com/install-flutter-linux/) 开发的前端,由另一组开发人员开发,以帮助在没有终端的情况下使用 Quickemu。 在此,我们重点介绍使用 Quickemu 创建和管理虚拟机的前端 Quickgui。 ### Quickgui 的特点 ![在 Zorin OS 16 上使用 Quickgui 运行虚拟机](/data/attachment/album/202111/19/104522ojzr1nc8jij8said.png) 如上所述,Quickgui 作为一个前端,其核心利用的是 Quickemu。因此,你可以期待其具有同样的功能。 你可以用它做的一些事情包括: * 搜索操作系统并下载它们以创建虚拟机。 * 管理你现有的虚拟机。 * 当你建立一个虚拟机时,创建默认配置。 * 提供黑暗模式。 * 开箱即用地创建 Windows 和 macOS 虚拟机。 * 支持各种 Linux 发行版,包括 elementaryOS、ZorinOS、Ubuntu 等。 * 支持 FreeBSD 和 OpenBSD。 * 支持 EFI 和传统的 BIOS。 * 不需要提升权限就能工作。 * 默认情况下,宿主机/访客机共享剪贴板。 * 可以选择镜像压缩方法。 * 能够禁用输入。 * 能够切换虚拟机中宿主机/访客机的可用 USB 设备。 * 包括对 [SPICE 连接](https://www.spice-space.org/index.html) 的支持。 * 网络端口转发。 * Samba 文件共享。 * VirGL 加速。 * 智能卡直通。 鉴于它是如此简单和容易使用,其功能集令人印象深刻。让我给你提供一些使用的技巧。 ### Quickgui 入门 用户界面非常简单,你可以选择 “<ruby> 管理现有机器 <rt> Manage existing machines </rt></ruby>” 和 “<ruby> 创建新机器 <rt> Create new machines </rt></ruby>”。 你需要点击“<ruby> 创建 <rt> Create </rt></ruby>”来开始制作虚拟机。 ![Quickgui VM Creation](/data/attachment/album/202111/19/104523wpm9csdvejpi3vcd.png) 选择操作系统,你应该看到一个列表。如果你找不到目标操作系统,只需搜索一下,它应该会出现。 ![](/data/attachment/album/202111/19/104523xxwwdw3ax9nxsg2w.png) 你会看到各种各样的操作系统。在接下来的选择中,选择所需的操作系统及其版本。然后,点击 “<ruby> 下载 <rt> Download </rt></ruby>”。 它应该会下载恢复镜像或 ISO,这取决于你正在尝试的操作系统。下载将取决于你的互联网连接,但它工作得很完美。 如果你想自己下载 ISO,你将就得为它创建配置并进行设置。看看 [Quickemu 的 GitHub 页面](https://github.com/wimpysworld/quickemu),了解一下它的说明。 ![](/data/attachment/album/202111/19/104523j6m1qq3rl6dx2df1.png) 你只需要在下载完成后点击 “<ruby> 去除 <rt> Dismiss </rt></ruby>”。 在这篇文章中,我测试了启动一个 Linux 虚拟机([elementary OS 6](https://news.itsfoss.com/elementary-os-6-features/))、一个 macOS 实例,以及一个 Windows 虚拟机。 我成功地以虚拟机方式运行了 Linux 和 macOS 。然而,我在快速建立一个 Windows 虚拟机时遇到了一些问题。我在 Quickemu 的 GitHub 页面上找不到任何相关信息,所以我没有费心去排除故障。 如果你需要使用 Windows 虚拟机,可以自己试试,并在他们的 [Discord 服务器](https://discord.com/invite/sNmz3uw) 中联系他们寻求帮助。 你不一定需要改变虚拟机的配置来使其工作。因此,它变成了一个节省时间的工具。 ### 在 Linux 中安装 Quickgui 要使用 Quickgui,你需要先安装 Quickemu。 对于基于 Ubuntu 的发行版,你可以使用 PPA 来安装它: ``` sudo apt-add-repository ppa:flexiondotorg/quickemu sudo apt update sudo apt install quickemu ``` 它应该安装了你需要的所有东西(连同 quickget 包),使其发挥作用。 完成后,你可以使用另一个 PPA 继续安装 Quickgui: ``` sudo add-apt-repository ppa:yannick-mauray/quickgui sudo apt update sudo apt install quickgui ``` 如果你使用的是其他 Linux 发行版,你可以参考 [Quickemu 的 GitHub 页面](https://github.com/wimpysworld/quickemu) 和查看 [Quickgui 的 GitHub 页面](https://github.com/quickgui/quickgui),以获得更多说明。 ### 总结 Quickgui 使人们能够方便地利用 Quickemu 的能力,快速创建和管理多个虚拟机,而不需要进行任何配置。 更有好的是,你不需要提升权限就能让它工作。 因此,如果你正在寻找 VirtualBox 的替代品,这可能就是答案。或者,你也可以试试 [GNOME Boxes](https://help.gnome.org/users/gnome-boxes/stable/) 作为一个更简单的替代品。 你对 Quickgui 有什么看法?请在下面的评论中告诉我你的想法。 --- via: <https://itsfoss.com/quickgui/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) At present, it is fairly easy to create virtual machines thanks to programs like VirtualBox, VMware, and a few others. You can still [install VirtualBox in your Linux system](https://itsfoss.com/install-virtualbox-ubuntu/) to proceed. But, in this article, I put my focus on an exciting tool that’s simple to use, works fast, and quickly helps you to spin up a virtual machine, i.e., Quickgui. ## Quickgui: A GUI Front-End to Quickemu ![quickgui emu](https://itsfoss.com/content/images/wordpress/2021/11/quickgui-emu.png) Quickemu is a terminal-based tool that lets you create optimized desktop virtual machines and manage them with ease. The tool focuses on getting rid of all the nuances to configure the virtual machine. Instead, it chooses the best configuration as per available system resources for the virtual machine to work. Not just limited to the configuration, but it will also download the image for the operating system (using quickget package). So, all you have to do is install the operating system as you would normally do and get started. Quickemu utilizes [QEMU](https://www.qemu.org/) at its core, with the aim to replace VirtualBox with Bash and QEMU. QEMU is an open-source machine emulator and virtualizer. Quickemu is an interesting project by [Martin Wimpress](https://twitter.com/m_wimpress) (Ubuntu MATE Lead) with the help of several contributors. And, to complement this tool, Quickgui is a front-end that uses [Flutter](https://itsfoss.com/install-flutter-linux/) by another set of developers to help facilitate the use of Quickemu without the terminal. Here, we focus on the front-end Quickgui that uses Quickemu to create and manage virtual machines. ## Features of Quickgui ![quickgui vms](https://itsfoss.com/content/images/wordpress/2021/11/quickgui-vms.png) As mentioned above, Quickgui as a front-end utilizes Quickemu at its core. So, you can expect the same functionality here. Some of the things that you can do with it include: - Search for operating systems and download them to create virtual machines. - Manage your existing virtual machines. - Creates default configurations when you set up a virtual machine. - Dark mode available. - Supports creating Windows and macOS virtual machines out of the box. - Support for various Linux distributions including elementaryOS, ZorinOS, Ubuntu, and more. - FreeBSD and OpenBSD support. - EFI and Legacy BIOS. - Does not need elevated permissions to work. - Host/Guest clipboard sharing by default. - Select image compression method. - Ability to disable input. - Toggle available USB devices from host/guest in a virtual machine. - Includes the support for [SPICE connections](https://www.spice-space.org/index.html). - Network port forwarding. - Samba file sharing. - VirGL acceleration. - Smartcard pass-through. The feature set is impressive given how simple and easy it is to use. Let me give you some pointers to get started. ## Getting Started With Quickgui The user interface is really straightforward, you get the options to “**Manage existing machines**” and “**Create new machines**“. You need to hit create to start making a virtual machine. ![quickgui select](https://itsfoss.com/content/images/wordpress/2021/11/quickgui-select.png) Select the operating system, you should get a list of it. If you can’t find the target OS, simply search for it, and it should show up. ![quickgui quickemu selection](https://itsfoss.com/content/images/wordpress/2021/11/quickgui-quickemu-selection.png) You get a wide variety of options. Select the desired OS, and its version, in the next selection. And, hit “**Download**“. It should download the recovery image or the ISO, depending on the OS you’re trying. The download will depend on your internet connection, but it worked flawlessly. If you want to download the ISO yourself, you will have to create the configuration for it and set it up. Take a look at [Quickemu’s GitHub page](https://github.com/wimpysworld/quickemu) to explore instructions for it. ![quickemu gui mac](https://itsfoss.com/content/images/wordpress/2021/11/quickemu-gui-mac.png) You just need to click on “**Dismiss**” once the download’s complete. For this article, I tested spinning up a Linux virtual machine ([elementary OS 6](https://news.itsfoss.com/elementary-os-6-features/)), a macOS instance, and a Windows VM. I was successful running Linux and macOS as VMs. However, I had some issues setting up a Windows VM quickly. I could not find any information regarding that on Quickemu’s GitHub page, so I didn’t bother troubleshooting much. If you require using Windows VMs, you might want to try it for yourself and reach out to them in their [Discord se](https://discord.com/invite/sNmz3uw)[r](https://discord.com/invite/sNmz3uw)[ver](https://discord.com/invite/sNmz3uw) for help. You do not necessarily need to change the configuration of a VM to make it work. Hence, it turns out to be a time-saver. ## Installing Quickgui in Linux To use Quickgui, you need to have Quickemu installed first. For Ubuntu-based distros, you can install it using a PPA: ``` sudo apt-add-repository ppa:flexiondotorg/quickemu sudo apt update sudo apt install quickemu ``` It should install everything you require (along with quickget package) to make it work. Once done, you can proceed installing Quickgui using another PPA: ``` sudo add-apt-repository ppa:yannick-mauray/quickgui sudo apt update sudo apt install quickgui ``` If you are using other Linux distributions, you can refer to [Quickemu’s GitHub page](https://github.com/wimpysworld/quickemu) and explore [Quickgui’s GitHub](https://github.com/quickgui/quickgui) for more instructions. ## Wrapping Up Quickgui makes it convenient to utilize Quickemu’s abilities to quickly create and manage multiple VMs without needing to configure anything. What’s more interesting: you do not need elevated privileges to make it work. If [you have used Qemu](https://itsfoss.com/qemu-ubuntu/), you would understand those issues. [How to Install and Use Qemu on UbuntuLearn how to properly install Qemu in Ubuntu and then configure a Linux distro in VM.](https://itsfoss.com/qemu-ubuntu/)![](https://itsfoss.com/content/images/2023/04/install-qemu-on-ubuntu.png) ![](https://itsfoss.com/content/images/2023/04/install-qemu-on-ubuntu.png) So, if you are looking for a VirtualBox replacement, this could be the answer. Or, you could also try [GNOME Boxes](https://help.gnome.org/users/gnome-boxes/stable/) as a simpler alternative. What do you think about Quickgui? Let me know your thoughts in the comments down below.
13,999
使用 qrcp 在你的手机和 Linux 之间传输文件
https://opensource.com/article/21/11/transfer-files-phone-linux
2021-11-19T11:41:30
[ "传输文件" ]
https://linux.cn/article-13999-1.html
> > qrcp 项目提供了一种快速地从你的 iPhone 或 Android 设备中复制文件到你的 Linux 电脑的方法,反之也可。 > > > ![](/data/attachment/album/202111/19/114121wt40ilipix1oo1zh.jpg "A person looking at a phone") 你是否在寻找一种快速复制文件的方法,从你的 iPhone 或 Android 移动设备到你的 Linux 电脑,或者从你的 Linux 电脑到你的设备?我最近发现了一个开源的应用,它很容易安装,并且传输文件只需一个二维码。 `qrcp` 项目提供了一个命令,可以在你的终端生成一个二维码,让你通过网络向你的电脑发送或接收文件。 ### 在 Linux、Windows 或 Mac 上安装 qrcp 开发者 Claudio d'Angelis 以 MIT 许可证发布了 `qrcp` 应用。我发现它很容易安装,也很容易使用。它适用于 Linux、Windows 和 macOS,可以作为 RPM、DEB 或 tarball 下载。它为几乎所有的平台做了构建,包括树莓派。 如果你想在 Linux 上安装它,下载 RPM 或 DEB,并使用你的包管理器进行本地安装。例如,在 Fedora、CentOS 或 Mageia,或类似的平台上: ``` $ sudo dnf install ./qrcp*rpm ``` 如果你只是想试试,你可以下载 tar.gz 压缩包并在本地运行它: ``` $ tar --extract --file qrcp*tar.gz $ ./qrcp version qrcp 0.x.y ``` ### 设置 qrcp 你可以通过使用 `--help` 选项查看所有可用的 `qrcp` 选项: ``` $ qrcp --help $ ./qrcp --help Usage: qrcp [flags] qrcp [command] Available Commands: completion Generate completion script config Configure qrcp help Help about any command receive Receive one or more files send Send a file(s) or directories from this host version Print version number and build information. [...] ``` 默认配置文件位于 `~/.config/qrcp/config.json` ,你可以使用你喜欢的编辑器编辑,或从命令行调用配置向导来配置应用。 ``` $ qrcp config ``` 第一步是创建一个配置文件。`qrcp config` 命令将带你完成这个过程,但会问你几个问题。 第一个问题是要求你提供一个“完全限定域名”。如果你在一个不使用完全限定域名的本地网络上使用 `qrcp`(或者你不知道哪种方式),那么就把这个留空。`qrcp` 命令将使用你的本地 IP 地址代替。 下一个问题是提示你选择端口。大多数防火墙会阻止非标准的端口,但会将 8080 端口作为互联网流量的情况并不少见。如果你的防火墙屏蔽了 8080 端口,那么你还是要添加一个例外。假设你的系统使用 `firewalld`,你可以用这个命令允许 8080 端口的流量: ``` $ sudo firewall-cmd --add-port 8080/tcp --permanent ``` 拒绝在“传输完成后保持网络连接”的选项,让 `qrcp` 生成一个随机路径。 假设你在一个可信的网络上,使用 HTTP(而不是 HTTPS)连接,那么你不必配置 TLS。 配置保存在 `~/.config/qrcp/config.json` 中,并且之后可以编辑,所以如果你想改变设置,它很容易更新。 更新后的配置看起来像这样: ``` { "fqdn": "", "interface": "wlp0s20f3", "port": 8080, "keepAlive": false, "path": "", "secure": false, "tls-key": "", "tls-cert": "", "output": "/home/don" } ``` ### 用 qrcp 传输文件 现在你已经准备好从你的 Linux 电脑向你的移动设备发送一个文件。在这个例子中,我使用了我的 iPhone,它完全不支持 Linux,这是臭名昭著的。这个过程在安卓设备上是完全一样的。 我是这样做的。首先,我在我的电脑上创建一个示例文件: ``` $ echo "Hello world"> ~/example.txt ``` 接下来,我使用 `send` 子命令将文件从我的 Linux 电脑发送到我的手机: ``` Linux~$ qrcp send example.txt ``` ![example of sending a file](/data/attachment/album/202111/19/114132b34rz3t3hctxxlnp.png) *使用 `qrcp send example.txt` 发送文件的例子(CC BY-SA 4.0)* 我打开我的相机应用(在 Android 上,我使用一个保护隐私的专用二维码扫描器),iPhone 扫描二维码并在我的手机上启动 Safari 浏览器。最后,我点击“下载”按钮。 ![example download](/data/attachment/album/202111/19/114133xdpd6iad56sairah.png) *下载示例 .txt 文件(CC BY-SA 4.0)* ### 用 qrcp 接收文件 接收文件也一样简单,只是命令略有不同: ``` $ qrcp receive ``` ![example of receiving a file](/data/attachment/album/202111/19/114133qsyvfssqc8sq3dym.png) *使用 `qrcp receive` 命令接收一个文件(CC BY-SA 4.0)* 我扫描了二维码,它再次启动了我手机上的 Safari 浏览器,但这次出现了一些不同,因为我正在将文件从我的 iPhone 发送到 Linux 电脑上。 ![example of selecting a file](/data/attachment/album/202111/19/114133zll8zq77s5sosubn.jpg) *选择一个要传输的文件(CC BY-SA 4.0)* 我点击“选择文件”,它让我选择想发送的文件。 ![file appears in default location](/data/attachment/album/202111/19/114134tfr3drodlrecn232.png) *文件被下载到默认位置(CC BY-SA 4.0)* 发送文件后,是在我的配置中指定的默认位置找到了文件。 ### 尝试 qrcp 项目文档很简短但已足够,除了最初提出这个想法的 Claudio d'Angelis 之外,它还有开发者社区的支持。社区欢迎你加入他们,该应用将改变你对移动设备之间文件传输的看法。试试吧! --- via: <https://opensource.com/article/21/11/transfer-files-phone-linux> 作者:[Don Watkins](https://opensource.com/users/don-watkins) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Are you looking for a way to quickly copy files from your iPhone or Android mobile device to your Linux computer or from your Linux computer to your devices? I recently discovered an open source application that's easy to install and makes transferring files as simple as a QR code. The `qrcp` project provides a command that generates a QR code in your terminal that allows you to send or receive files to your computer over the network. ## Install qrcp on Linux, Windows, or Mac The developer, Claudio d'Angelis, has released the `qrcp` application with an MIT license [on GitHub](https://github.com/claudiodangelis/qrcp). I found it easy to install and easy to use. It's available for Linux, Windows, and macOS, and can be downloaded as an RPM, DEB, or tarball. There are builds for nearly every platform, including the Raspberry Pi. If you want to install it on Linux, download either the RPM or DEB and use your package manager to perform a local install. For example, on Fedora, CentOS, or Mageia, or similar: ``` ````$ sudo dnf install ./qrcp*rpm` If you just want to try it, you can download the tar.gz archive and run it locally: ``` `````` $ tar --extract --file qrcp*tar.gz $ ./qrcp version qrcp 0.x.y ``` ## Set up qrcp You can view all of the available `qrcp` options by using the `--help` option: ``` `````` $ qrcp --help $ ./qrcp --help Usage: qrcp [flags] qrcp [command] Available Commands: completion Generate completion script config Configure qrcp help Help about any command receive Receive one or more files send Send a file(s) or directories from this host version Print version number and build information. [...] ``` You can configure the application by editing the default configuration file located at `~/.config/qrcp/config.json` using your favorite editor or invoking the configuration wizard from the command line: ``` ````$ qrcp config` The first step is to create a configuration file. The `qrcp config` command takes you through this process, but there are a few tricky questions. The first question asks you for a fully-qualified domain name. If you're using `qrcp` on a local network that doesn't use fully-qualified domain names (or if you don't know one way or the other), then leave this blank. The `qrcp` command will use your local IP address instead. The next question prompts you for a port. Most firewalls block non-standard ports, but it's not uncommon to recognize port 8080 as Internet traffic. If your firewall blocks port 8080, then you'll still have to add an exception. Assuming your system uses `firewalld` , you can allow traffic on port 8080 with this command: ``` ````$ sudo firewall-cmd --add-port 8080/tcp --permanent` Decline the option to keep the network connection alive after the transfer is complete and let `qrcp` generate a random path. Assuming you're on a trusted network, use an HTTP (not HTTPS) connection, so you don't have to configure TLS. The configuration is stored in `~/.config/qrcp/config.json` and is editable after the fact, so if you change your mind about any setting, it's easy to update. The updated configuration looks like this: ``` `````` { "fqdn": "", "interface": "wlp0s20f3", "port": 8080, "keepAlive": false, "path": "", "secure": false, "tls-key": "", "tls-cert": "", "output": "/home/don" ``` ## Transfer files with qrcp Now you're ready to send a file from your Linux computer to your mobile device. In this example, I used my iPhone, which infamously offers no support Linux at all. The process is exactly the same on an Android device. Here's how I do it. First, I create an example file on my computer: ``` ````$ echo "Hello world"> ~/example.txt` Next, I use the `send` subcommand to send the file from my Linux computer to my mobile: ``` ````Linux~$ qrcp send example.txt` ![example of sending a file](https://opensource.com/sites/default/files/send-example.png) Example of sending a file using qrcp send example.txt (CC BY-SA 4.0) I open my camera application (on Android, I use a privacy-friendly dedicated QR scanner) and the iPhone scans the QR code and launches Safari on my phone. Finally, I click on the **Download** button. ![example download](https://opensource.com/sites/default/files/download-example.png) Download the example.txt file (CC BY-SA 4.0) ## Receiving files with qrcp Receiving files is just as easy, except the command is slightly different: ``` ````$ qrcp receive` ![example of receiving a file](https://opensource.com/sites/default/files/receive-file.png) Receive a file using the grcp receive command (CC BY-SA 4.0) I scan the QR code, and it once again launches the Safari browser on my phone, but this time it appears a bit different because I'm sending files from my iPhone to the Linux computer. ![example of selecting a file](https://opensource.com/sites/default/files/select-file.jpg) Select a file to transfer (CC BY-SA 4.0) I click on **Choose Files**, which allows me to choose the file I want to send. ![file appears in default location](https://opensource.com/sites/default/files/default-location.png) The file is downloaded to the default location (CC BY-SA 4.0) After sending the file, it's found in the default location specified in my configuration. ## Try qrcp The project documentation is brief but adequate, and it's supported by a community of developers in addition to Claudio d'Angelis, who originally came up with the idea. The community welcomes you to join them, and the application will change the way you look at file transfers to and from your mobile devices. Try it out! ## 8 Comments
14,001
vifm:为铁杆 Vim 爱好者提供的终端文件浏览器
https://itsfoss.com/vifm-terminal-file-manger/
2021-11-20T10:33:04
[ "Vim", "vifm", "文件管理器" ]
https://linux.cn/article-14001-1.html
> > 让我们探索一个基于终端的文件浏览器,可以使用 Vim 风格的键绑定。 > > > ![](/data/attachment/album/202111/20/103256stau7uhetccj7uun.png) 当在命令行中浏览 [Linux 目录结构](https://linuxhandbook.com/linux-directory-structure/) 时,人们经常依赖 [cd 命令](https://linuxhandbook.com/cd-command-examples/)。 这也没什么不好,因为你登录到任何一个 Linux 系统上都有 `cd` 命令。 然而,如果系统是由你维护的,你想更直观地看到目录,那么文件管理器比 `cd` 或 `tree` 命令要好得多。 是的,你也可以在终端中找到文件管理器。它们可能不如 Nautilus 这样的图形界面应用,但仍然比普通的老命令好。 有几个 [TUI](https://itsfoss.com/gui-cli-tui/) 文件浏览器,我们已经介绍了其中的几个。今天,我们来看看 `vifm`。 ### vifm 简介 ![](/data/attachment/album/202111/20/103304e318nfadf21c8aqg.png) [vifm](https://github.com/vifm/vifm) 是一个命令行工具,它是一个文件管理器,导航和操作文件系统对象的键绑定与 Vim 类似。如果你不清楚我所说的“文件系统对象”是什么意思,它们是文件、目录、符号链接、硬链接等。 除了非常直观的 Vim 交互键绑定外,下面是 `vifm` 为你提供的一系列功能: * 一个就在你的终端中的快速文件管理器 * 从文件管理器内编辑文本文件 * `vifm` 使用 curses 界面 * `vifm` 是跨平台的(在 Cygwin 的帮助下甚至可以在 Windows 上工作;它应该可以,但我没有测试过) * 支持 Vim 风格的键绑定输入,如 `dd`、`j`、`k`、`h`、`l` 等 * [vifm 插件](https://github.com/vifm/vifm.vim) 可以在 Vim 中使用,这样就可以通过 Vim 打开文件 * 支持 Vim 命令的自动补完 * 支持多个面板 * 可以使用 [或不使用] 正则表达式进行批量重命名 ### 在 Linux 上安装 vifm `vifm` 软件包并不算新,因此在默认情况下,即使是“稳定”发行版(如 Debian)的软件库中也很容易找到它。 在 Debian 和基于 Debian 的发行版(如 Ubuntu、Pop!\_OS、Mint 等)之上,你可以 [使用 apt 软件包管理器](https://itsfoss.com/apt-command-guide/) 来安装 `vifm`: ``` sudo apt install vifm ``` 使用 [pacman 软件包管理器](https://itsfoss.com/pacman-command/) 在 [基于 Arch 的 Linux 发行版](https://itsfoss.com/arch-based-linux-distros/)上安装 `vifm`: ``` sudo pacman -S vifm ``` `vifm` 在 Fedora 和 RHEL 仓库中也有;用 DNF 软件包管理器安装它: ``` sudo dnf install vifm ``` 安装好了 `vifm`,你可以简单地在终端输入 `vifm`,像下面这样,然后启动它: ``` vifm ``` ### vifm 的用户界面 当你第一次启动 `vifm` 时,默认情况下,它启动时显示你当前所在的目录的概览。你还会注意到,`vifm` 默认使用两个窗格。 ![默认的 vifm 界面,包括一个正常的视图(隐藏的文件不可见)和两个默认打开的窗格](/data/attachment/album/202111/20/103304an2qml4oqhi52iol.jpg) 如果你对界面感到困惑,只需尝试按 `j` 键将光标向下移动一行,按 `k` 键将光标向上移动一行。你可以通过按 `h` 键向上移动一级目录。就像 Vim 中一样! 如果你的光标目前在一个文件上,按 `l` 键将在 Vim 中打开该文件(如果没有另外说明的话)。但如果你的光标在一个目录上,按 `l` 键将导航到该目录并显示其内容。 你也可以通过按 `Ctrl + g` 键绑定,从文件管理器中获得关于文件或目录的详细信息。 ![ 键绑定如何显示目录/文件信息的屏幕截图](/data/attachment/album/202111/20/103305b5p4p733botb4u42.jpg) 你可以按 `za` 键来显示被隐藏的文件和目录(开头有 `.` 的文件和目录默认是隐藏的)。如果这些特殊的文件和目录没有被隐藏,按 `za` 键将会隐藏它们。 你可以用 `zo` 键绑定一直显示隐藏的文件和目录,或用 `zm` 键绑定使这些项目一直不可见。 ![举例说明,当你按下 键绑定时的情况](/data/attachment/album/202111/20/103305u29fgcchgcuvt9vu.jpg) ### 总结 由于它是基于 Vim 的,你可以用 vifmrc 文件来配置它。在 [vifm wiki](https://wiki.vifm.info/index.php/Main_Page) 上有最新的默认绑定键的速查表,在 [这里](https://vifm.info/cheatsheets.shtml)。这个项目的文档非常好。 ![vifm 默认按键绑定](/data/attachment/album/202111/20/103305eojv43boujj1dqy3.jpg) `vifm` 是一个了不起的文件管理器,特别是对于 Vim 用户来说,因为它与 Vim 生态系统整合得非常好。它将许多 Vim 的功能和按键绑定整合到一个文件管理器中。默认的双窗格布局使其更具生产力。 不要犹豫,尝试一下 `vifm`。它真的是一个了不起的命令行工具。 --- via: <https://itsfoss.com/vifm-terminal-file-manger/> 作者:[Pratham Patel](https://itsfoss.com/author/pratham/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) When it comes to navigating through the [Linux directory structure](https://linuxhandbook.com/linux-directory-structure/) in the command line, people often rely on the [cd command](https://linuxhandbook.com/cd-command-examples/). And nothing wrong with it because you’ll get the cd command on any Linux system you log in. However, if the system is maintained by you and you want to have a better view of the directories, a file manager does a lot better than the cd or tree command. Yes, you can get file managers in the terminal as well. They may not be as good as the GUI ones like Nautilus but still better than the plain old commands. There are several [TUI](https://itsfoss.com/gui-cli-tui/) file browsers and we have covered a few of them on It’s FOSS. Today, we look at vifm. ## What is vifm? ![vifm screenshot](https://itsfoss.com/content/images/wordpress/2021/11/vifm-screenshot-800x309.png) [vifm](https://github.com/vifm/vifm) is a command line tool that is a file manager with key bindings for navigation and file system object manipulation that are similar to vim. In case you are wondering what I meant by “file system objects”, they are files, directories, symbolic links, hard links etc. Along with the very intuitive vim interaction key bindings, below is the set of features that vifm offers you - A fast file manager right in your terminal - Edit the text file from the file manager itself - vifm uses the curses interface - vifm is cross platform (can even work on Windows with the help of Cygwin; it should work but I have not tested it) - Supports vim style key binding inputs like dd, j, k, h, l etc - The [vifm plugin](https://github.com/vifm/vifm.vim)is available to be used inside vim for opening file(s) through vim - Auto complete support for the vim commands - Support for more than one panes - Allows batch rename with [or without] regex ## Installing vifm on Linux The vifm package isn’t new and therefore is readily available in even the “stable” distributions’ (like Debian) repositories by default. On Debian and Debian based distros (like Ubuntu, Pop!_OS, Mint etc), you can [use the apt package manager](https://itsfoss.com/apt-command-guide/) to install vifm: `sudo apt install vifm` Use the [pacman package manager](https://itsfoss.com/pacman-command/) to install vifm on [Arch-based Linux distributions](https://itsfoss.com/arch-based-linux-distros/): `sudo pacman -S vifm` vifm is also available in the Fedora and RHEL repositories; install vifm with the DNF package manager: `sudo dnf install vifm` Once you have vifm installed, you can simply type vifm your terminal – like below – and start vifm `vifm` ## The vifm user interface When you launch vifm for the first time, by default, it will launch with the overview of the directory that you are currently in. You will also notice, that vifm uses two panes by default. ![01 two panes 1](https://itsfoss.com/content/images/wordpress/2021/11/01_two_panes-1-800x600.webp) If you find yourself confused at the interface, simply try pressing the j key to move the cursor down one row, and press the k key to move the cursor up one row. You can move up one directory by pressing the h key. Just like vim! If your cursor is currently on a file, pressing the l key will open the file in vim (if not stated otherwise). But if your cursor is on a directory, pressing the l key will navigate in the directory and show you the directory contents. You can also get details about a file or directory from the file manager by pressing the Ctrl + g key binding. ![02 ctrl g info](https://itsfoss.com/content/images/wordpress/2021/11/02_ctrl_g_info-800x600.webp) You can press the keys “za” to either show files and directories that are hidden (files and directories with a period at beginning are hidden by default). If these special files and directories are not hidden, pressing za will hide them. ![03 toggle dotfile visibility](https://itsfoss.com/content/images/wordpress/2021/11/03_toggle_dotfile_visibility-800x600.webp) You can either permanently show hidden files and directories with the “zo” key binding and never make these items visible with the “zm” key binding. ## Conclusion Since it is based on Vim, you can configure it using the vifmrc file. The [vifm wiki](https://wiki.vifm.info/index.php/Main_Page) has the latest default keybinding cheatsheet located [here](https://vifm.info/cheatsheets.shtml). The project is very well documented. ![vifm key binding cheatsheet](https://itsfoss.com/content/images/wordpress/2021/11/vifm-key-binding-cheatsheet-800x561.webp) vifm is an amazing file manager, specially for Vim users because it integrates so well with the Vim ecosystem. It incorporates many vim features and key bindings into a file manager. The default two-pane layout makes it more productive. Do not hesitate to give vifm a try. It really is an amazing command line tool!
14,002
入门:如何在 Fedora Linux 中切换到深色模式
https://itsfoss.com/fedora-dark-mode/
2021-11-20T11:44:21
[ "深色", "暗黑", "主题" ]
https://linux.cn/article-14002-1.html
![](/data/attachment/album/202111/20/114412oqqw4mdnxbwfbprb.jpg) 与 Ubuntu 不同,Fedora 提供的是真正的、原生般的 GNOME 体验,而且体验很好,横向布局、三指滑动,一切都很好。 我不喜欢的一点是默认的标准主题,它是 Adwaita Light(默认)主题和深色的 GNOME Shell 的混合体。 因此,虽然通知和通知区是深色的,但系统和应用的其他部分是浅色主题。老实说,对我来说,这看起来很不协调。 ![Fedora GNOME standard theme](/data/attachment/album/202111/20/114421ke95enbn5pe60mu5.jpg) 另一方面,深色主题让它看起来更好。 ![Fedora GNOME dark theme](/data/attachment/album/202111/20/114422ep2qrv8yvcqqvvv8.jpg) 让我告诉你如何在 Fedora 或其他任何使用 GNOME 桌面环境的发行版中开启深色模式。 ### 在 Fedora 中切换到深色模式 好了!我将分享命令行的方法,因为它更快。打开一个终端,使用这个命令: ``` gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark ``` 完成了。这很容易,对吗?但我也要展示一下 GUI 的方法。 因为我主要使用 Ubuntu,所以我始终参照 Ubuntu。Ubuntu 在系统设置中本身就提供了在浅色和深色主题之间切换的选项。 然而,在原生 GNOME 中却没有这样的设置。你必须先 [在 Fedora 上安装 GNOME Tweaks 工具](https://itsfoss.com/install-gnome-tweaks-fedora/),然后用它来切换主题。 你可以在软件中心搜索它并点击“<ruby> 安装 <rt> Install </rt></ruby>”按钮: ![Install GNOME Tweaks from the software center in Fedora](/data/attachment/album/202111/20/114423l9r4r47w33xn4wg9.jpg) 或者,你在终端输入以下命令: ``` sudo dnf install gnome-tweaks ``` 安装完成后,按 `Super` 键(`Windows` 键)在系统菜单中搜索它: ![Start GNOME Tweaks](/data/attachment/album/202111/20/114425v3thjckr5qisc03i.png) 点击左侧边栏的“<ruby> 外观 <rt> Appearance </rt></ruby>”标签,点击主题部分下的应用。 ![Changing theme in Fedora](/data/attachment/album/202111/20/114425qa9yxqgiyx7ppxy7.jpg) 你会看到这里有几个可用的主题。你应该在这里选择 “Adwaita-dark”。当你选择了它,应用就会切换到深色主题。 ![Selecting the Adwaita-dark theme](/data/attachment/album/202111/20/114427iz356d3dpqd858ps.png) 就是你在 Fedora 中切换到深色模式所需要做的一切。由于 GNOME Shell 已经在使用深色主题,你不需要明确地将它设置为深色模式。所有的通知、信息栏等都是在深色模式下的。 ### 总结 你可以找到各种深色 GTK 主题并安装它们来给你的 Fedora 带来不同的深色外观。然而,我注意到,只有系统自己的深色主题才能被网页浏览器识别。 所以,如果你访问一个根据你的系统主题自动启用深色模式的网站,它将与 Adwaita-dark 兼容,但可能与其他深色 GTK 主题不兼容。 这就是使用系统提供的深色主题的一个优势。 如你所见,在 Fedora 中启用深色模式并不是什么火箭科学。它只是一个了解和发现的过程。 享受深色色彩吧! --- via: <https://itsfoss.com/fedora-dark-mode/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Unlike Ubuntu, Fedora offers the actual, vanilla GNOME experience. And that works pretty well. The horizontal layout, the three finger swipe, it’s all good. The one thing I don’t like is the default standard theme which is a mix of Adwaita Light (default) theme and the dark shell. So, while the notifications and notification area are dark, rest of the system and applications have light theme. And quite honestly, it looks dull for my taste. ![fedora gnome standard theme](https://itsfoss.com/content/images/wordpress/2021/11/fedora-gnome-standard-theme.webp) On the other side, the dark theme makes it look better. ![fedora gnome dark theme](https://itsfoss.com/content/images/wordpress/2021/11/fedora-gnome-dark-theme.webp) Let me show you how to turn the dark mode on in Fedora or any other distribution that uses GNOME desktop environment. ## Switch to dark mode in Fedora Alright! I’ll share the command line method because it is quicker. Open a terminal and use this command: `gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark` That’s it. It was easy, right? But I’ll also show the GUI method. Since I use Ubuntu primarily, my reference point is always Ubuntu. Ubuntu provides the option to switch between the light and dark theme in the system settings itself. However, there is no such settings in the vanilla GNOME. You’ll have to [install GNOME Tweaks tool on Fedora](https://itsfoss.com/install-gnome-tweaks-fedora/) first and then use it to switch themes. You could either search for it in the software center and click the ‘Install’ button: ![install gnome tweaks fedora](https://itsfoss.com/content/images/wordpress/2021/11/install-gnome-tweaks-fedora-800x448.webp) Or, you type the following command in the terminal: `sudo dnf install gnome-tweaks` Once installed, search for it in the system menu by pressing the super key (Windows key): ![start gnome tweaks tool in fedora](https://itsfoss.com/content/images/wordpress/2021/11/start-gnome-tweaks-tool-in-Fedora-800x271.png) Click on the **Appearance** tab in the left sidebar and click on the Applications under the Themes section. ![change gtk theme fedora](https://itsfoss.com/content/images/wordpress/2021/11/change-GTK-theme-Fedora-800x532.webp) You’ll see a few available themes here. You should select Adwaita-dark here. As soon as you select it, the application will switch to dark theme. ![switching dark mode fedora](https://itsfoss.com/content/images/wordpress/2021/11/switching-dark-mode-fedora-800x515.png) And that’s all you need to do to switch to dark mode in Fedora. Since the GNOME Shell is already using dark theme, you don’t need to explicitly set it to dark mode. All the notifications, message tray etc. are in dark mode always. ## Conclusion You can find various dark GTK themes and install them to give your Fedora a different dark look. However, I have noticed that it is only the system’s own dark theme that is recognized by web browsers. So, if you visit a website that automatically enables dark mode based on your system theme, it will work with Adwaita-dark but may not work with other dark GTK themes. That’s one sure shot advantage of using dark theme provided by the system. As you can see, it’s not a rocket science to enable dark mode in Fedora. It’s just a matter of knowing and finding things. Enjoy the dark colors!
14,004
自由之狼:一个没有遥测的开源火狐复刻
https://itsfoss.com/librewolf/
2021-11-21T12:11:42
[ "LibreWolf", "火狐" ]
https://linux.cn/article-14004-1.html
> > LibreWolf 是一个火狐浏览器的复刻,它关注于隐私和安全,消除了遥测并增加了其他好处。让我们来了解一下它。 > > > ![](/data/attachment/album/202111/21/121135e2mmb6ym53hxzlmj.jpg) <ruby> 火狐 <rt> Firefox </rt></ruby> 是 Linux 上最好的网页浏览器之一。然而,一些用户并不喜欢其中的遥测机制。 除此之外,有些人更喜欢一个开箱即用的、为最佳隐私和安全而调整过的浏览器,即使火狐浏览器是提供了最好的定制功能的浏览器之一。 如果你不想要火狐浏览器的干扰功能,想要一个无需你亲自调整的私密网络体验,LibreWolf(自由之狼)或许就是答案。 ### LibreWolf:更好的火狐? ![](/data/attachment/album/202111/21/121142gnxn4e4neukwnwnp.png) 假设你想使用火狐,而不使用火狐的帐户同步的能力和其他一些火狐特有的功能,如 “添加到 Pocket” 按钮。在这种情况下,LibreWolf 可以是一个不错的选择。 不同于其他火狐浏览器的复刻(例如,[Basilisk 浏览器](https://itsfoss.com/basilisk-browser/)),它是定期更新的。而且,它只专注于提供私密的网页浏览体验,而不影响你在火狐中所希望得到的用户体验。 ![](/data/attachment/album/202111/21/121143too1lbezgkd1sosc.png) ### LibreWolf 的特点 LibreWolf 为安全的网页浏览体验提供了一套相当有用的开箱即用的功能。让我强调其中的一些特点: * 移除遥测功能 * 不使用火狐账户进行云同步 * 私密搜索供应商,如 Searx、Qwant(DuckDuckGo 被设置为默认) * 包含 uBlock Origin 以阻止脚本/广告 * 没有 “添加到 Pocket” 按钮 * 主页上默认没有赞助/推荐的内容 * 从设置中删除火狐<ruby> 状态条 <rt> snippets </rt></ruby>,它用于在新标签中添加新闻/提示 * 没有赞助的快捷提示 * 追踪保护默认设置为“严格”模式 * Cookies 和历史记录设置为关闭浏览器时删除 * 默认启用 HTTPS-only 模式 正如你所注意到的,LibreWolf 的目标是提供一个更清洁和有利于隐私的体验,而不需要调整任何东西。 ![](/data/attachment/album/202111/21/121143s126nzgj61uo9eut.png) 如果你不想反复登录网络服务和浏览历史记录来回忆你的浏览活动,一些选项如退出时清除 cookies/历史记录可能会很不方便。 所以,如果你想从火狐切换到 LibreWolf,你可能想在决定之前测试一下网页浏览体验。 ![](/data/attachment/album/202111/21/121143d6r1ohzevwczorwj.png) ### 在 Linux 中安装 LibreWolf 对于任何 Linux 发行版,你可以使用 AppImage 文件或 Flathub 的 Flatpak 包。 如果你不知道,你可以参考我们关于 [使用 AppImage](https://itsfoss.com/use-appimage-linux/) 的指南和 [Flatpak 的资源](https://itsfoss.com/flatpak-guide/) 。 对于 Arch Linux 用户,它也可以在 [Arch 用户仓库(AUR)](https://itsfoss.com/aur-arch-linux/) 中找到。 也可以在他们的 [官方网站](https://librewolf-community.gitlab.io/install/) 或 [GitLab 页面](https://gitlab.com/librewolf-community) 中找到其他安装说明。 你试过 LibreWolf 吗?你喜欢用什么作为你的网页浏览器?请在下面的评论中分享你的想法! --- via: <https://itsfoss.com/librewolf/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
**Brief:** LibreWolf is a Firefox fork that focuses on privacy and security by eliminating telemetry and adding other perks. Let us find out more about it. Firefox is one of the best web browsers for Linux. However, some users do not appreciate the presence of telemetry. In addition to that, some prefer a browser that’s tuned for the best possible privacy and security out-of-the-box, even if Firefox offers one of the best customization capabilities. LibreWolf is the answer for all those users if you do not want distracting features of Firefox and want a private web experience without tweaking anything from your side. ## LibreWolf: Firefox, but better? ![librewolf about](https://itsfoss.com/content/images/wordpress/2021/11/librewolf-about.png) Suppose you want to use Firefox without the ability to sync using a Firefox account and a few other Firefox-specific features like the “**Add to Pocket**” button. In that case, LibreWolf can be a good option. Unlike other Firefox forks (for instance- [Basilisk browser](https://itsfoss.com/basilisk-browser/)), it is regularly updated. And, it only focuses on providing a private web experience without affecting the user experience you’d expect with Mozilla Firefox. ![librewolf firefox](https://itsfoss.com/content/images/wordpress/2021/11/librewolf-firefox.png) ## Features of LibreWolf LibreWolf offers a pretty useful set of features out-of-the-box for a secure web experience. Let me highlight some of them. - Removes telemetry - No cloud sync using Firefox account - Private search providers like Searx, Qwant (DuckDuckGo set as the default) - uBlock Origin included to block scripts/advertisements - No “Add to Pocket” button - No sponsored/recommended content in the homepage out-of-the-box - Firefox’s snippets to add news/tips in a new tab removed from the Settings - No sponsored shortcuts - Tracking Protection set to “ **Strict**” mode by default - Cookies and History set to delete when you close the browser - Enable HTTPS-only mode by default As you can notice, LibreWolf aims to provide a cleaner and privacy-friendly experience without needing to tweak anything. ![librewolf tracking](https://itsfoss.com/content/images/wordpress/2021/11/librewolf-tracking.png) Some options like clearing cookies/history upon exit may be inconvenient if you do not want to repeatedly sign in to web services and browse the history to recall your browsing activity. So, if you want to switch from Firefox to LibreWolf, you may want to test the web browsing experience before you decide. ![librewolf addon](https://itsfoss.com/content/images/wordpress/2021/11/librewolf-addon.png) ## Installing LibreWolf in Linux For any Linux distribution, you can use the AppImage file or the Flatpak package from Flathub. You can refer to our guide on [using AppImage](https://itsfoss.com/use-appimage-linux/) and the [resource on Flatpak](https://itsfoss.com/flatpak-guide/), in case you didn’t know. It is also available in [Arch User Repository (AUR)](https://itsfoss.com/aur-arch-linux/) for Arch Linux users. You can find other installation instructions on their [official](https://librewolf-community.gitlab.io/install/)[ ](https://librewolf-community.gitlab.io/install/)[website](https://librewolf-community.gitlab.io/install/) or its [GitLab page](https://gitlab.com/librewolf-community). Have you tried LibreWolf yet? What do you prefer as your web browser? Share your thoughts in the comments down below!
14,005
Kubernetes 网络策略基础
https://opensource.com/article/21/10/kubernetes-networkpolicy
2021-11-21T13:02:25
[ "Kubernetes", "防火墙" ]
/article-14005-1.html
> > 在你通过 Kubernetes 部署一个应用之前,了解 Kubernetes 的网络策略是一个基本的要求。 > > > ![](/data/attachment/album/202111/21/130217ocykri3zbv37i6ou.jpg "Parts, modules, containers for software") 随着越来越多的云原生应用程序通过 Kubernetes 部署到生产环境,安全性是你必须在早期就需要考虑的一个重要检查项。在设计云原生应用程序时,预先嵌入安全策略非常重要。不这样做会导致后续的安全问题,从而导致项目延迟,并最终给你带来不必要的压力和金钱投入。 这么多年来,人们总是把安全留到最后,直到他们的部署即将发布到生产环境时才考虑安全。这种做法会导致项目交付的延迟,因为每个组织都有要遵守的安全标准,这些规定被绕过或不遵守,并承受大量的风险才得以实现可交付成果。 对于刚开始学习 Kubernetes 实施的人来说,理解 Kubernetes <ruby> 网络策略 <rt> NetworkPolicy </rt></ruby> 可能会令人生畏。但这是在将应用程序部署到 Kubernetes 集群之前必须了解的基本要求之一。在学习 Kubernetes 和云原生应用程序时,请把“不要把安全抛在脑后!”定为你的口号。 ### NetworkPolicy 概念 <ruby> <a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/"> 网络策略 </a> <rt> NetworkPolicy </rt></ruby> 取代了你所知道的数据中心环境中的防火墙设备 —— 如<ruby> 吊舱 <rt> Pod </rt></ruby>之于计算实例、网络插件之于路由器和交换机,以及卷之于存储区域网络(SAN)。 默认情况下,Kubernetes 网络策略允许 <ruby> <a href="https://kubernetes.io/docs/concepts/workloads/pods/"> 吊舱 </a> <rt> Pod </rt></ruby> 从任何地方接收流量。如果你不担心吊舱的安全性,那么这可能没问题。但是,如果你正在运行关键工作负载,则需要保护吊舱。控制集群内的流量(包括入口和出口流量),可以通过网络策略来实现。 要启用网络策略,你需要一个支持网络策略的网络插件。否则,你应用的任何规则都将变得毫无用处。 [Kubernetes.io](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/) 上列出了不同的网络插件: * CNI 插件:遵循 <ruby> <a href="https://github.com/containernetworking/cni"> 容器网络接口 </a> <rt> Container Network Interface </rt></ruby>(CNI)规范,旨在实现互操作性。 + Kubernetes 遵循 CNI 规范的 [v0.4.0](https://github.com/containernetworking/cni/blob/spec-v0.4.0/SPEC.md) 版本。 * Kubernetes 插件:使用桥接器和主机本地 CNI 插件实现基本的 `cbr0`。 ### 应用网络策略 要应用网络策略,你需要一个工作中的 Kubernetes 集群,并有支持网络策略的网络插件。 但首先,你需要了解如何在 Kubernetes 的环境使用网络策略。Kubernetes 网络策略允许 [吊舱](https://kubernetes.io/docs/concepts/workloads/pods/) 从任何地方接收流量。这并不是理想情况。为了吊舱安全,你必须了解吊舱是可以在 Kubernetes 架构内进行通信的端点。 1、使用 `podSelector` 进行吊舱间的通信: ``` - namespaceSelector: matchLabels: project: myproject ``` 2、使用 `namespaceSelector` 和/或 `podSelector` 和 `namespaceSelector` 的组合进行命名空间之间的通信和命名空间到吊舱的通信。: ``` - namespaceSelector: matchLabels: project: myproject - podSelector: matchLabels: role: frontend ``` 3、对于吊舱的 IP 块通信,使用 `ipBlock` 定义哪些 IP CIDR 块决定源和目的。 ``` - ipBlock: cidr: 172.17.0.0/16 except: - 172.17.1.0/24 ``` 注意吊舱、命名空间和基于 IP 的策略之间的区别。对于基于吊舱和命名空间的网络策略,使用选择器来控制流量,而对基于 IP 的网络策略,使用 IP 块(CIDR 范围)来定义控制。 把它们放在一起,一个网络策略应如下所示: ``` apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: test-network-policy namespace: default spec: podSelector: matchLabels: app: backend policyTypes: - Ingress - Egress ingress: - from: - ipBlock: cidr: 172.17.0.0/16 except: - 192.168.1.0/24 - namespaceSelector: matchLabels: project: myproject - podSelector: matchLabels: role: frontend ports: - protocol: TCP port: 6379 egress: - to: - ipBlock: cidr: 10.0.0.0/24 ports: - protocol: TCP port: 5978 ``` 参考上面的网络策略,请注意 `spec` 部分。在此部分下,带有标签 `app=backend` 的 `podSelector` 是我们的网络策略的目标。简而言之,网络策略保护给定命名空间内称为 `backend` 的应用程序。 此部分也有 `policyTypes` 定义。此字段指示给定策略是否适用于选定吊舱的入口流量、选定吊舱的出口流量,或两者皆有。 ``` spec: podSelector: matchLabels: app: backend policyTypes: - Ingress - Egress ``` 现在,请看 `Ingress`(入口)和 `Egress`(出口)部分。该定义规定了网络策略的控制。 首先,检查 `ingress from` 部分。 此实例中,网络策略允许从以下位置进行吊舱连接: * `ipBlock` + 允许 172.17.0.0/16 + 拒绝 192.168.1.0/24 * `namespaceSelector` + `myproject`: 允许来自此命名空间并具有相同标签 project=myproject 的所有吊舱。 * `podSelector` + `frontend`: 允许与标签 `role=frontend` 匹配的吊舱。 ``` ingress: - from: - ipBlock: cidr: 172.17.0.0/16 except: - 192.168.1.0/24 - namespaceSelector: matchLabels: project: myproject - podSelector: matchLabels: role: frontend ``` 现在,检查 `egress to` 部分。这决定了从吊舱出去的连接: * `ipBlock` + 10.0.0.0/24: 允许连接到此 CIDR + Ports: 允许使用 TCP 和端口 5978 进行连接 ``` egress: - to: - ipBlock: cidr: 10.0.0.0/24 ports: - protocol: TCP port: 5978 ``` ### 网络策略的限制 仅靠网络策略无法完全保护你的 Kubernetes 集群。你可以使用操作系统组件或 7 层网络技术来克服已知限制。你需要记住,网络策略只能解决 IP 地址和端口级别的安全问题 —— 即开放系统互联(OSI)中的第 3 层或第 4 层。 为了解决网络策略无法处理的安全要求,你需要使用其它安全解决方案。以下是你需要知道的一些 [用例](https://kubernetes.io/docs/concepts/services-networking/network-policies/#what-you-can-t-do-with-network-policies-at-least-not-yet),在这些用例中,网络策略需要其他技术的增强。 ### 总结 了解 Kubernetes 的网络策略很重要,因为它是实现(但不是替代)你通常在数据中心设置中使用的防火墙角色的一种方式,但适用于 Kubernetes。将此视为容器安全的第一层,仅仅依靠网络策略并不是一个完整的安全解决方案。 网络策略使用选择器和标签在吊舱和命名空间上实现安全性。此外,网络策略还可以通过 IP 范围实施安全性。 充分理解网络策略是在 Kubernetes 环境中安全采用容器化的一项重要技能。 --- via: <https://opensource.com/article/21/10/kubernetes-networkpolicy> 作者:[Mike Calizo](https://opensource.com/users/mcalizo) 选题:[lujun9972](https://github.com/lujun9972) 译者:[perfiffer](https://github.com/perfiffer) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
14,007
七个使用 wget 命令的技巧
https://opensource.com/article/21/10/linux-wget-command
2021-11-22T10:29:34
[ "wget" ]
/article-14007-1.html
> > 用你的 Linux 终端中从互联网上下载文件。 > > > ![](/data/attachment/album/202111/22/102927pjuji5juxzuikkg6.jpg "Computer screen with files or windows open") `wget` 是一个下载网页文件的免费工具。它将互联网上的数据保存到一个文件或展示在终端上。实际上这也是像 Firefox 或 Chromium 这样的网页浏览器的工作原理。有一个区别是,网页浏览器默认将网页 <ruby> 渲染 <rt> render </rt></ruby>在图形窗口中,并且通常需要用户主动来操作它们。而 `wget` 工具是无交互的使用方式,也就是说你可以使用脚本或定期使用 `wget` 来下载文件,不论你人是否在电脑面前。 ### 使用 wget 下载文件 你可以通过提供一个特定 URL 的链接,用 `wget` 下载一个文件。如果你提供一个默认为 `index.html` 的 URL,那么就会下载该索引页。默认情况下,文件会被下载到你当前的工作目录,并保持原来的名字。 ``` $ wget http://example.com --2021-09-20 17:23:47-- http://example.com/ Resolving example.com... 93.184.216.34, 2606:2800:220:1:248:1893:25c8:1946 Connecting to example.com|93.184.216.34|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 1256 (1.2K) [text/html] Saving to: 'index.html' ``` 通过使用 `--output-document` 和 `-` 符号,你可以指示 `wget` 将数据发送到 <ruby> 标准输出 <rt> stdout </rt></ruby>: ``` $ wget http://example.com --output-document - | head -n4 <!doctype html> <html> <head> <title>Example Domain</title> ``` 你可以使用 `--output-document` 选项(简写为 `-O`)将下载文件命名为任何你想要的名称: ``` $ wget http://example.com --output-document foo.html ``` ### 断点续传 如果你正在下载一个超大文件,你可能会遇到中断下载的情况。使用 `--continue`(简写为 `-c`),`wget` 可以确定从文件的哪个位置开始继续下载。也就是说,下次你在下载一个 4 GB 的 Linux 发行版 ISO 时,如果出现了错误导致中断,你不必重新从头开始。 ``` $ wget --continue https://example.com/linux-distro.iso ``` ### 下载一系列的文件 如果你要下载的不是单个大文件,而是一系列的文件,`wget` 也能提供很好的帮助。假如你知道要下载文件的路径以及文件名的通用范式,你可以使用 Bash 语法指示一个数字范围的起始和终点来表示这一系列文件名: ``` $ wget http://example.com/file_{1..4}.webp ``` ### 镜像整个站点 使用 `--mirror` 选项你可以下载整个站点,包括它的目录结构。这与使用选项 `--recursive --level inf --timestamping --no-remove-listing` 的效果是一样的,该选项表明可以进行无限制的递归,得到你指定域下的所有内容。但你也可能会得到比预期多得多的内容,这取决于站点本身的老旧程度。 如果你正在使用 `wget` 来打包整个站点,选项 `--no-cookies --page-requisites --convert-links` 非常有用,它可以确保打包的站点是全新且完整的,站点副本或多或少是<ruby> 自包含的 <rt> self-contained </rt></ruby>。 ### 修改 HTML 标头 在计算机发送的通信报文里含有大量用于数据交换的<ruby> 元数据 <rt> metadata </rt></ruby>。HTTP 标头是初始数据的组成部分。当你浏览某个站点时,你的浏览器会发送 HTTP 请求标头。使用 `--debug` 选项可以查看 `wget` 为每个请求发送了什么样的标头信息: ``` $ wget --debug example.com ---request begin--- GET / HTTP/1.1 User-Agent: Wget/1.19.5 (linux-gnu) Accept: */* Accept-Encoding: identity Host: example.com Connection: Keep-Alive ---request end--- ``` 你可以使用 `--header` 选项修改请求标头。实际上经常使用这种方式来模仿某特定浏览器,来测试或兼容某些编码糟糕、只能与特定代理通信的站点。 让请求被识别为来自 Windows 系统的 Microsoft Edge: ``` $ wget --debug --header="User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36 Edg/91.0.864.59" http://example.com ``` 你也可以假装为某个移动设备: ``` $ wget --debug --header="User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Mobile/15E148 Safari/604.1" http://example.com ``` ### 查看响应标头 与浏览器发送请求标头的方式一样,响应也包含有标头信息。你可以使用 `--debug` 选项来查看响应中的标头信息: ``` $ wget --debug example.com [...] ---response begin--- HTTP/1.1 200 OK Accept-Ranges: bytes Age: 188102 Cache-Control: max-age=604800 Content-Type: text/html; charset=UTF-8 Etag: "3147526947" Server: ECS (sab/574F) Vary: Accept-Encoding X-Cache: HIT Content-Length: 1256 ---response end--- 200 OK Registered socket 3 for persistent reuse. URI content encoding = 'UTF-8' Length: 1256 (1.2K) [text/html] Saving to: 'index.html' ``` ### 处理 301 响应 200 响应码意味着一切都在预料之中。而 301 响应则表示 URL 已经被永久迁移到了另外一个地方。这是站点管理员的一种常用手段,内容迁移后,为访问旧地址的用户留下寻找新地址的“线索”。`wget` 会默认跟随<ruby> 重定向 <rt> redirect </rt></ruby>,这也是大部分情况下用户所希望的。 当然,你可以使用 `--max-redirect` 选项,用于控制 `wget` 默认处理 301 响应重定向的次数。设置为 `0` 意味着不会自动重定向到新的地址: ``` $ wget --max-redirect 0 http://iana.org --2021-09-21 11:01:35-- http://iana.org/ Resolving iana.org... 192.0.43.8, 2001:500:88:200::8 Connecting to iana.org|192.0.43.8|:80... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: https://www.iana.org/ [following] 0 redirections exceeded. ``` 同时,你也可以设置为其他的数值来控制 `wget` 能重定向多少次。 ### 展开 URL 缩写 使用`--max-redirect` 选项用于在实际访问之前查看 <ruby> URL 缩写 <rt> shortened URL </rt></ruby>非常有用。缩写 URL 可用于用户无法完整拷贝和粘贴一个长 URL 时的<ruby> 印刷媒体 <rt> print media </rt></ruby>,或是具有字数限制的社交网络(在类似 [Mastondon](https://opensource.com/article/17/4/guide-to-mastodon) 这种现代开源的社交网络上这并不是一个问题)。这种缩写具有一定的风险,因为本质上这些目的地是隐藏的。组合使用 `--head` 选项和 `--location` 选项来来查看 HTTP 头部并解开最终的目的地,你可以在不加载整个资源的情况下查看到缩写 URL 的完整内容: ``` $ wget --max-redirect 0 "https://bit.ly/2yDyS4T" --2021-09-21 11:32:04-- https://bit.ly/2yDyS4T Resolving bit.ly... 67.199.248.10, 67.199.248.11 Connecting to bit.ly|67.199.248.10|:443... connected. HTTP request sent, awaiting response... 301 Moved Permanently Location: http://example.com/ [following] 0 redirections exceeded. ``` 从 `Location` 开始的倒数第二行输出,展示了实际的目的地。 ### 使用 wget 若你开始考虑使用单个命令来实现整个网站访问的过程,`wget` 可以快速高效的帮你获取互联网上的信息,而不用在图形界面上耗费精力。为了帮你将它构造在你平常的工作流中,我们创建了一个 `wget` 常用使用方式和语法清单,包括使用它来查询 API 的概述。[在这里下载 Linux wget 速查表](https://opensource.com/downloads/linux-wget-cheat-sheet)。 --- 来源: <https://opensource.com/article/21/10/linux-wget-command> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[zengyi1001](https://github.com/zengyi1001) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
14,008
如何在 Linux 中挂载 Bitlocker 加密的 Windows 分区
https://itsfoss.com/mount-encrypted-windows-partition-linux/
2021-11-22T14:41:46
[ "加密", "分区", "Windows" ]
https://linux.cn/article-14008-1.html
> > 情况是这样的。我的系统自带 Windows 10 Pro,并且带有 BitLocker 加密功能。我 [甚至在 Windows 启用了 BitLocker 加密的情况下,以双启动模式安装了 Ubuntu](https://itsfoss.com/dual-boot-ubuntu-windows-bitlocker/)。 > > > ![](/data/attachment/album/202111/22/144133k6n9xsnnt46t0z94.jpg) 你可以轻松地从 Linux 中访问 Windows 文件。没有什么高科技的东西。只要进入文件管理器,点击通常位于“<ruby> 其他位置 <rt> Other Locations </rt></ruby>”标签下的 Windows 分区。 ![Mounting Windows partition through the file manager in Linux desktop](/data/attachment/album/202111/22/144146t9qo6pytmpqdpu2t.png) 对于 BitLocker 加密的 Windows 分区来说,这个过程也不是太复杂。只是当你试图挂载 Windows 分区时,它会要求你输入密码。 ![Password required for encrypted Windows drive mount in Linux](/data/attachment/album/202111/22/144147a3u888k89c88oes8.png) 这是能工作的。在我的情况中,我输入了 48 位 BitLocker 恢复密码,它解密了 Windows 分区,并在带有 GNOME 40 的 Ubuntu 21.10 中毫无问题地挂载了它。 试试你的 BitLocker 密码。如果这不起作用,试试恢复密码。对于普通的 Windows 10 Pro 用户,恢复密码存储在你的微软账户中。 [BitLocker Recovery Password in Micrsoft Account](https://account.microsoft.com/devices/recoverykey?refd=support.microsoft.com) 输入恢复密码,你会看到 Windows 分区和它的文件现在可以访问。勾选“<ruby> 记住密码 <rt> Remember Password </rt></ruby>”框也是为了进一步使用而节省时间。 ![Encrypted Windows partition now mounted in Linux](/data/attachment/album/202111/22/144147hb5zs8kjuu5uv5pj.png) 如果上述方法对你不起作用,或者你不熟悉命令行,还有一个替代方法。 这个方法包括使用一个叫做 [Dislocker](https://github.com/Aorimn/dislocker) 的工具。 ### 使用 Dislocker 在 Linux 中挂载 BotLocker 加密的 Windows 分区(命令行方法) 使用 Dislocker 分为两部分。第一部分是解开 BitLocker 的加密,并给出一个名为 `dislocker-file` 的文件。这基本上是一个虚拟的 NTFS 分区。第二部分是挂载你刚刚得到的虚拟 NTFS 分区。 你需要 BitLocker 密码或恢复密码来解密加密的驱动器。 让我们来看看详细的步骤。 #### 步骤 1:安装 Disclocker 大多数 Linux 发行版的仓库中都有 Dislocker。请使用你的发行版的包管理器来安装它。 在基于 Ubuntu 和 Debian 的发行版上,使用这个命令: ``` sudo apt install dislocker ``` ![Installing Dislocker in Ubuntu](/data/attachment/album/202111/22/144148y36p9e9ztz699l9u.png) #### 步骤 2:创建挂载点 你需要创建两个挂载点。一个是 Dislocker 生成 `dislocker-file` 的地方,另一个是将这个 `dislocker-file`(虚拟文件系统)作为一个回环设备挂载。 没有命名限制,你可以给这些挂载目录起任何你想要的名字。 逐一使用这些命令: ``` sudo mkdir -p /media/decrypt sudo mkdir -p /media/windows-mount ``` ![Creating mount points for dislocker](/data/attachment/album/202111/22/144148v100x4xd0bvidzre.png) #### 步骤 3:获取需要解密的分区信息 你需要 Windows 分区的名称。你可以使用文件资源管理器或像 Gparted 这样的 GUI 工具。 ![Get the partition name](/data/attachment/album/202111/22/144148c5dmmedf16ef9m5t.png) 在我的例子中,Windows 分区是 `/dev/nvme0n1p3`。对你的系统来说,这将是不同的。你也可以使用命令行来达到这个目的。 ``` sudo lsblk ``` #### 步骤 4:解密分区并挂载 你已经设置好了一切。现在是真正的部分。 **如果你有 BitLocker 密码**,以这种方式使用 `dislocker` 命令(用实际值替换 `<partition_name>` 和 `<password>`): ``` sudo dislocker <partition_name> -u<password> -- /media/decrypt ``` 如果你只有恢复密码,请以这种方式使用该命令用实际值替换 `<partition_name>` 和 `<password>`): ``` sudo dislocker <partition_name> -p<recovery_password> -- /media/decrypt ``` 在解密该分区时,应该不会花很长时间。你应该在指定的挂载点看到 `dislocker-file`,在我们的例子中是 `/media/decrypt`。现在挂载这个 dislocker-file: ``` sudo mount -o loop /media/decrypt/dislocker-file /media/windows-mount ``` ![](/data/attachment/album/202111/22/144149mye8qve8hirmxqjv.png) 完成了。你的 BitLocker 加密的 Windows 分区已经被解密并挂载到 Linux 中。你也可以从文件资源管理器中访问它。 ![Mounting Dislocker decrypted Windows partition with file manager](/data/attachment/album/202111/22/144149lqqvg3gvgk5r44sd.png) #### 文件系统类型错误的故障排除提示 如果你遇到这样的错误: ``` mount: /media/windows-mount: wrong fs type, bad option, bad superblock on /dev/loop35, missing codepage or helper program, or other error. ``` 你应该在挂载时指定文件系统。 对于NTFS,使用: ``` sudo mount -t ntfs-3g -o loop /media/decrypt/dislocker-file /media/windows-mount ``` 对于 exFAT,使用: ``` sudo mount -t exFAT-fuse -o loop /media/decrypt/dislocker-file /media/windows-mount ``` #### 解除对 Windows 分区的挂载 你可以从文件管理器中取消挂载的分区。只要**点击名为 windows-mount 的分区旁边的卸载符号**。 或者,你可以使用卸载命令: ``` sudo umount /media/decrypt sudo umount /media/windows-mount ``` 我希望这对你有帮助。如果你还有问题或建议,请在评论中告诉我。 --- via: <https://itsfoss.com/mount-encrypted-windows-partition-linux/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Here’s the scenario. My system came with Windows 10 Pro and that came with BitLocker encryption. I [installed Ubuntu in the dual boot mode even with the BitLocker encryption](https://itsfoss.com/dual-boot-ubuntu-windows-bitlocker/) enabled for Windows. You can easily access the Windows files from within Linux. No hi-fi stuff here. Just go to the file manager and click on the Windows partition which is located usually under the “Other Locations” tab. ![mount encrypted windows partition in linux](https://itsfoss.com/content/images/wordpress/2021/11/mount-encrypted-windows-partition-in-linux-800x476.png) The process is not too complicated with BitLocker encrypted Windows partition as well. It’s just that when you try to mount the Windows partition, it will ask for the password. ![password needed for encrypted windows drive mount in linux](https://itsfoss.com/content/images/wordpress/2021/11/password-needed-for-encrypted-windows-drive-mount-in-Linux.png) It works though. In my case, I entered the 48 digit BitLocker recovery password and it decrypted the Windows partition and mounted it without any issue in Ubuntu 21.10 with GNOME 40. Try your BitLocker password. If that does not work, try the recovery password. For normal Windows 10 Pro users, the recovery password is stored in your Microsoft account. [BitLocker Recovery Password in Micrsoft Account](https://account.microsoft.com/devices/recoverykey?refd=support.microsoft.com&ref=itsfoss.com) Enter the recovery and you’ll see that Windows partition and its files are accessible now. Checking the “Remember Password” box is also a time saver for further usage. ![encrypted windows partition mounted in linux](https://itsfoss.com/content/images/wordpress/2021/11/encrypted-windows-partition-mounted-in-Linux-800x491.png) If the above does not work for you or if you are stuck with the command line, there is an alternative method. This method involves using a tool called [Dislocker](https://github.com/Aorimn/dislocker?ref=itsfoss.com). ## Mount BotLocker encrypted Windows partition in Linux with Dislocker [Command Line Method] Dislocker process works in two parts. The first part decrypts the BitLocker encryption and gives a file named dislocker-file. This is basically a virtual NTFS partition. The second part is basically mounting the virtual NTFS partition you just got. You’ll need either the BitLocker password or the recovery password to decrypt the encrypted drive. Let’s see the steps in details. ### Step 1: Install Disclocker Dislocker is available in the repositories of most Linux distributions. Please use your distribution’s package manager to install it. On Ubuntu and Debian based distributions, use this command: `sudo apt install dislocker` ![install dislocker ubuntu](https://itsfoss.com/content/images/wordpress/2021/11/install-dislocker-ubuntu.png) ### Step 2 : Create mount points You’ll need to create two mount points. One for where Dislocker will generate the dislocker-file and the other one which will mount this dislocker-file (virtual filesystem) as a loop device. There is no naming restrictions and you may name these mount directories anything you want. Use these commands one by one: ``` sudo mkdir -p /media/decrypt sudo mkdir -p /media/windows-mount ``` ![creating mount points for dislocker](https://itsfoss.com/content/images/wordpress/2021/11/creating-mount-points-for-dislocker.png) ### Step 3: Get the partition info which needs to be decrypted You need the name of the Windows partition. You can use the file explorer or GUI tools like Gparted. ![show device name gparted](https://itsfoss.com/content/images/wordpress/2021/11/show-device-name-gparted-800x416.png) In my case, the Windows partition is /dev/nvme0n1p3. It will be different for your system. You may also use command line for this purpose. `sudo lsblk` ### Step 4: Decrypt the partition and mount You have everything set up. Now comes the real part. I**f you have the BitLocker password**, use the dislocker command in this fashion (replace <partition_name> and <password> with actual values): `sudo dislocker <partition_name> -u<password> -- /media/decrypt` Please note that **there is no space between u and password**. If you only have the recovery password, use the command in this fashion (replace <partition_name> and <recovery_password> with actual values): `sudo dislocker <partition_name> -p<recovery_password> -- /media/decrypt` Again, there is **no space between p and password**. It should not take a long time in decrypting the partition. You should see the dislocker-file in the designated mount point, /media/decrypt in our case. Now mount this dislocker-file: `sudo mount -o loop /media/decrypt/dislocker-file /media/windows-mount` ![mount dislocker decrypted windows partition](https://itsfoss.com/content/images/wordpress/2021/11/mount-dislocker-decrypted-windows-partition.png) You are done. Your BitLocker encrypted Windows partition is decrypted and mounted in Linux. You can access it from the file explorer as well. ![discloker mount encrypted windows partition](https://itsfoss.com/content/images/wordpress/2021/11/discloker-mount-encrypted-windows-partition-800x483.png) ### Troubleshooting tips for wrong fs type error If you get an error like this: `mount: /media/windows-mount: wrong fs type, bad option, bad superblock on /dev/loop35, missing codepage or helper program, or other error.` You should specify the filesystem while mounting. For NTFS, use: `sudo mount -t ntfs-3g -o loop /media/decrypt/dislocker-file /media/windows-mount` For exFAT, use: `sudo mount -t exFAT-fuse -o loop /media/decrypt/dislocker-file /media/windows-mount` ### Unmount the Windows partition You can unmount the mounted partition from the file manager. Just **click the unmount symbol** beside the partition named windows-mount. Otherwise, unmount command is always there for you. ``` sudo umount /media/decrypt sudo umount /media/windows-mount ``` I hope it helps you. If you still have questions or suggestions, please let me know in the comments.
14,011
使用 Powershell 来自动化 Linux、macOS 以及 Windows 流程
https://opensource.com/article/20/2/devops-automation
2021-11-23T12:30:08
[ "DevOps", "自动化", "Powershell" ]
https://linux.cn/article-14011-1.html
> > 自动化是 DevOps 的关键,但是,是否任何事都可以自动化? > > > ![](/data/attachment/album/202111/23/123000eexe7iez7wsew72e.jpg "CICD with gears") 自动化控制了那些手工的、费力的和容易出错的过程,用运行自动化脚本的计算机代替了执行手工任务的工程师。每个人都认同手工流程是健康的 DevOps 模式的敌人。一些人认为自动化不是一件好事,因为它取代了辛勤工作的工程师,而另一些人则意识到它提高了一致性、可靠性和效率,节省了时间,(最重要的是)使工程师能够聪明地工作。 > > “DevOps 并不只是自动化或者基础架构即代码。” — [Donovan Brown](http://www.donovanbrown.com/post/what-is-devops) > > > 自从上个世纪 80 年代早期开始使用自动化流程和工具链以来,每当我听到或读到“自动化一切”的建议时,我总是会激动不已。虽然在技术上可以实现一切自动化,但自动化是复杂的,并且需要付出开发、调试和维护方面的代价。如果你曾经重新启用一个许久不用的 Azure 资源管理器(ARM)模板或很久以前编写的宝贵维护脚本,并期望它在几个月或几年之后仍然能够完美地执行,那么你就会明白,自动化就像任何其他代码一样,是脆弱的,需要持续的维护和培养。 所以,你应该对什么进行自动化并在何时进行自动化? * 当你手动执行自动化流程超过一两次 * 当你需要经常地持续地执行自动化流程 * 自动化任何可被自动化的 更重要的是,什么是你不应该自动化的? * 不要自动化一次性的流程,因为不值得投入,除非你会重新使用它作为参考文档,并定期验证它的可用性 * 不要自动化高度不稳定的流程,因为太复杂且昂贵 * 不要自动化有问题的流程,在自动化前先修复它们 举例来说,我的团队使用我们通用的协作和工程系统来不断的监控数百个用户活动。如果一个用户在三个月或者更长时间处于非活动状态,并且这个用户被分配了一个昂贵的许可证,我们就会重分配这个用户一个功能少一些但是免费的许可证。 如图 1 所示,这是一个没有技术挑战性的流程。这是一个令人费解且容易出错的过程,尤其是在执行上下文时与其他开发和运维任务切换时。 ![Manual process to switch user license](/data/attachment/album/202111/23/123009p8u8ouddseevsugr.png "Manual process to switch user license") *图 1 手工流程切换用户许可证* 顺带的,这里有一个用简单三步创建的价值流图的例子: 1. 可视化所有活动: 列出用户、过滤用户、重置许可证。 2. 确定利益相关者,即运营和授权团队。 3. 措施: ``` * 总交货时间(TLT)= 13 小时 * 总周期时间(TCT) = 1.5 小时 * 总效率百分比 = TLT/TCT*100 = 11.5% ``` 如果你在人群流量大和容易看到的区域挂一个这些可视化的副本,比如在你的团队的讨论区、餐厅,或在去洗手间的路上,你将引发大量的讨论和主动反馈。例如,从视觉上看,很明显,手工任务是一种浪费,主要是由于漫长的流程等待时间造成的。 让我们研究一个简单的 PowerShell 脚本,它可以自动化该流程,如图 2 所示,将总交付时间从 13 小时减少到 4 小时加 60 秒,并将总体效率从 11.5 提高到 12.75%。 ![Semi-automated PowerShell-based process to switch user license](/data/attachment/album/202111/23/123010owwfcklwsk4ywse4.png "Semi-automated PowerShell-based process to switch user license") *图 2 半自动化的 PowerShell 脚本切换用户许可* [PowerShell](https://opensource.com/article/19/8/variables-powershell) 是一种开源的基于任务的脚本语言。它可以在 [GitHub](https://github.com/powershell/powershell) 上找到。它构建在 .NET 上,允许你自动化 Linux、macOS 和 Windows 流程。具有开发背景的用户,特别是 C# 用户,将享受到 PowerShell 的全部好处。 下面的 PowerShell 脚本示例通过它的服务 [REST API](https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1) 与 [Azure DevOps](https://docs.microsoft.com/en-us/azure/devops/user-guide/what-is-azure-devops?view=azure-devops) 进行通信。脚本结合了在图 1 中的手动列表用户和过滤用户任务,识别了 Demo 组织中的所有两个月没有活动的、使用基本许可证或更昂贵的基本+测试许可证的用户,并将用户的详细信息输出到控制台。很简单! 首先,设置认证标头和其他变量,这些变量将在稍后的初始化脚本中使用: ``` param( [string] $orgName = "DEMO", [int] $months = "-2", [string] $patToken = "<PAT>" ) # Basic authentication header using the personal access token (PAT) $basicAuth = ("{0}:{1}" -f "",$patToken) $basicAuth = [System.Text.Encoding]::UTF8.GetBytes($basicAuth) $basicAuth = [System.Convert]::ToBase64String($basicAuth) $headers = @{Authorization=("Basic {0}" -f $basicAuth)} # REST API Request to get all entitlements $request_GetEntitlements = "https://vsaex.dev.azure.com/" + $orgName + "/_apis/userentitlements?top=10000&api-version=5.1-preview.2"; # Initialize data variables $members = New-Object System.Collections.ArrayList [int] $count = 0; [string] $basic = "Basic"; [string] $basicTest = "Basic + Test Plans"; ``` 接下来,使用此脚本查询所有授权,以识别不活动用户: ``` # Send the REST API request and initialize the members array list. $response = Invoke-RestMethod -Uri $request_GetEntitlements -headers $headers -Method Get $response.items | ForEach-Object { $members.add($_.id) | out-null } # Iterate through all user entitlements $response.items | ForEach-Object { $name = [string]$_.user.displayName; $date = [DateTime]$_.lastAccessedDate; $expired = Get-Date; $expired = $expired.AddMonths($months); $license = [string]$_.accessLevel.AccountLicenseType; $licenseName = [string]$_.accessLevel.LicenseDisplayName; $count++; if ( $expired -gt $date ) { # Ignore users who have NEVER or NOT YET ACTIVATED their license if ( $date.Year -eq 1 ) { Write-Host " **INACTIVE** " " Name: " $name " Last Access: " $date "License: " $licenseName } # Look for BASIC license elseif ( $licenseName -eq $basic ) { Write-Host " **INACTIVE** " " Name: " $name " Last Access: " $date "License: " $licenseName } # Look for BASIC + TEST license elseif ( $licenseName -eq $basicTest ) { Write-Host " **INACTIVE** " " Name: " $name " Last Access: " $date "License: " $licenseName } } } ``` 当你运行脚本时,你将得到以下输出,你可以将其转发给授权团队,以重置用户许可证: ``` **INACTIVE** Name: Demo1 Last Access: 2019/09/06 11:01:26 AM License: Basic **INACTIVE** Name: Demo2 Last Access: 2019/06/04 08:53:15 AM License: Basic **INACTIVE** Name: Demo3 Last Access: 2019/09/26 12:54:57 PM License: Basic **INACTIVE** Name: Demo4 Last Access: 2019/06/07 12:03:18 PM License: Basic **INACTIVE** Name: Demo5 Last Access: 2019/07/18 10:35:11 AM License: Basic **INACTIVE** Name: Demo6 Last Access: 2019/10/03 09:21:20 AM License: Basic **INACTIVE** Name: Demo7 Last Access: 2019/10/02 11:45:55 AM License: Basic **INACTIVE** Name: Demo8 Last Access: 2019/09/20 01:36:29 PM License: Basic + Test Plans **INACTIVE** Name: Demo9 Last Access: 2019/08/28 10:58:22 AM License: Basic ``` 如果你将最后一步自动化,自动将用户许可设置为一个自由的利益相关方许可,如图3所示,你可以进一步将总体交付时间减少到65秒,并将总体效率提高到77%。 ![Fully automated PowerShell-based process to switch user license](/data/attachment/album/202111/23/123010rujao3maq8aonx3j.png "Fully automated PowerShell-based process to switch user license") *图 3 完全自动化的基于 Powershell 的流程来切换用户许可证。* 这个 PowerShell 脚本的核心价值不仅在于能够实现 *自动化*,还在于能够 *定期*、*持续* 和 *快速地* 执行这个流程。进一步的改进是使用 Azure 管道等调度器每周或每天触发脚本,但我将把程序化的许可证重置和脚本调度保留在未来的文章中。 这里有一个图表,可以直观地看到进展情况: ![Graph to visualize progress](/data/attachment/album/202111/23/123010rqt8zwttdvevtnmv.png "Graph to visualize progress") *图 4,措施,措施,措施* 我希望你能喜欢这个简短的关于自动化、PowerShell、REST API 和价值流图的介绍。请在评论中分享你的想法和反馈。 --- via: <https://opensource.com/article/20/2/devops-automation> 作者:[Willy-Peter Schaub](https://opensource.com/users/wpschaub) 选题:[lujun9972](https://github.com/lujun9972) 译者:[FigaroCao](https://github.com/FigaroCao) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Automation takes control of manual, laborious, and error-prone processes and replaces engineers performing manual tasks with computers running automation scripts. Everyone agrees that manual processes are a foe of a healthy DevOps mindset. Some argue that automation is not a good thing because it replaces hard-working engineers, while others realize that it boosts consistency, reliability, and efficiency, saves time, and (most importantly) enables engineers to work smart. " DevOps is not just automation or infrastructure as code" —[Donovan Brown]. Having used automated processes and toolchains since the early '80s, I always twitch when I hear or read the recommendation to "automate everything." While it is technically possible to automate everything, automation is complex and comes at a price in terms of development, debugging, and maintenance. If you have ever dusted off an inviable Azure Resource Manager (ARM) template or a precious maintenance script you wrote a long time ago, expecting it to execute flawlessly months or years later, you will understand that automation, like any other code, is brittle and needs continuous maintenance and nurture. So, what and when should you automate? - Automate processes you perform manually more than once or twice. - Automate processes you will perform regularly and continuously. - Automate everything automatable. More importantly, what should you *not* automate? - Don't automate processes that are a one-off—it is not worth the investment unless you reuse it as reference documentation and regularly validate to ensure it remains functional. - Don't automate highly volatile processes—it is too complex and expensive. - Don't automate broken processes—fix them before automating. For example, my team continuously inspects hundreds of user activities on our common collaboration and engineering system, looking for inactivity that is wasting precious dollars. If a user has been inactive for three or more months and has been assigned an expensive license, we revert the user to a less functional and free license. As Fig. 1 shows, it is not a technically challenging process. It is a mind-numbing and error-prone process, especially when it's performed while context switching with other development and operational tasks. ![Manual process to switch user license Manual process to switch user license](https://opensource.com/sites/default/files/uploads/devops_quest_to_automate_1.png) Incidentally, this is an example of a value stream map created in three easy steps: - Visualize all activities: list users, filter users, and reset licenses. - Identify stakeholders, namely operations and licensing teams. - Measure: - Total lead time (TLT) = 13 hours - Total cycle time (TCT) = 1.5 hours - Total efficiency percentage = TLT/TCT*100 = 11.5% If you hang a copy of these visualizations in high-traffic and high-visibility areas, such as your team's breakout area, cafeteria, or on the way to your washrooms, you will trigger lots of discussions and unsolicited feedback. For example, looking at the visual, it is evident that the manual tasks are a waste, caused primarily by long process wait times. Let us explore a simple PowerShell script that automates the process, as shown in Figure 2, reducing the total lead-time from 13 to 4 hours and 60 seconds, and raising the overall efficiency from 11.5 to 12.75%. ![Semi-automated PowerShell-based process to switch user license Semi-automated PowerShell-based process to switch user license](https://opensource.com/sites/default/files/uploads/the_devops_quest_to_automate_everything_automatable_using_powershell_picture_2.png) [PowerShell](https://opensource.com/article/19/8/variables-powershell) is an open source task-based scripting language. It is found [on GitHub](https://github.com/powershell/powershell), is built on .NET, and allows you to automate Linux, macOS, and Windows processes. Users with a development background, especially C#, will enjoy the full benefits of PowerShell. The PowerShell script example below communicates with [Azure DevOps](https://docs.microsoft.com/en-us/azure/devops/user-guide/what-is-azure-devops?view=azure-devops) via its service [REST API](https://docs.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.1). The script combines the manual list users and filter users tasks in Fig. 1, identifies all users in the **DEMO** organization that have not been active for two months and are using either a **Basic** or a more expensive **Basic + Test** license, and outputs the user's details to the console. Simple! First, set up the authentication header and other variables that will be used later with this initialization script: ``` param( [string] $orgName = "DEMO", [int] $months = "-2", [string] $patToken = "<PAT>" ) # Basic authentication header using the personal access token (PAT) $basicAuth = ("{0}:{1}" -f "",$patToken) $basicAuth = [System.Text.Encoding]::UTF8.GetBytes($basicAuth) $basicAuth = [System.Convert]::ToBase64String($basicAuth) $headers = @{Authorization=("Basic {0}" -f $basicAuth)} # REST API Request to get all entitlements $request_GetEntitlements = "https://vsaex.dev.azure.com/" + $orgName + "/_apis/userentitlements?top=10000&api-version=5.1-preview.2"; # Initialize data variables $members = New-Object System.Collections.ArrayList [int] $count = 0; [string] $basic = "Basic"; [string] $basicTest = "Basic + Test Plans"; ``` Next, query all the entitlements with this script to identify inactive users: ``` # Send the REST API request and initialize the members array list. $response = Invoke-RestMethod -Uri $request_GetEntitlements -headers $headers -Method Get $response.items | ForEach-Object { $members.add($_.id) | out-null } # Iterate through all user entitlements $response.items | ForEach-Object { $name = [string]$_.user.displayName; $date = [DateTime]$_.lastAccessedDate; $expired = Get-Date; $expired = $expired.AddMonths($months); $license = [string]$_.accessLevel.AccountLicenseType; $licenseName = [string]$_.accessLevel.LicenseDisplayName; $count++; if ( $expired -gt $date ) { # Ignore users who have NEVER or NOT YET ACTIVATED their license if ( $date.Year -eq 1 ) { Write-Host " **INACTIVE** " " Name: " $name " Last Access: " $date "License: " $licenseName } # Look for BASIC license elseif ( $licenseName -eq $basic ) { Write-Host " **INACTIVE** " " Name: " $name " Last Access: " $date "License: " $licenseName } } # Look for BASIC + TEST license elseif ( $licenseName -eq $basicTest ) { Write-Host " **INACTIVE** " " Name: " $name " Last Access: " $date "License: " $licenseName } } } ``` When you run the script, you get the following output, which you can forward to the licensing team to reset the user licenses: ``` **INACTIVE** Name: Demo1 Last Access: 2019/09/06 11:01:26 AM License: Basic **INACTIVE** Name: Demo2 Last Access: 2019/06/04 08:53:15 AM License: Basic **INACTIVE** Name: Demo3 Last Access: 2019/09/26 12:54:57 PM License: Basic **INACTIVE** Name: Demo4 Last Access: 2019/06/07 12:03:18 PM License: Basic **INACTIVE** Name: Demo5 Last Access: 2019/07/18 10:35:11 AM License: Basic **INACTIVE** Name: Demo6 Last Access: 2019/10/03 09:21:20 AM License: Basic **INACTIVE** Name: Demo7 Last Access: 2019/10/02 11:45:55 AM License: Basic **INACTIVE** Name: Demo8 Last Access: 2019/09/20 01:36:29 PM License: Basic + Test Plans **INACTIVE** Name: Demo9 Last Access: 2019/08/28 10:58:22 AM License: Basic ``` If you automate the final step, automatically setting the user licenses to a free stakeholder license, as in Fig. 3, you can further reduce the overall lead time to 65 seconds and raise the overall efficiency to 77%. ![Fully automated PowerShell-based process to switch user license Fully automated PowerShell-based process to switch user license](https://opensource.com/sites/default/files/uploads/devops_quest_to_automate_3.png) Fully automated PowerShell-based process to switch user license The core value of this PowerShell script is not just the ability to *automate* but also to perform the process *regularly*, *consistently*, and *quickly*. Further improvements would trigger the script weekly or daily using a scheduler such as an Azure pipeline, but I will hold the programmatic license reset and script scheduling for a future article. Here is a graph to visualize the progress: ![Graph to visualize progress Graph to visualize progress](https://opensource.com/sites/default/files/uploads/devops_quest_to_automate_4.png) Measure, measure, measure I hope you enjoyed this brief journey through automation, PowerShell, REST APIs, and value stream mapping. Please share your thoughts and feedback in the comments. ## 4 Comments
14,012
一个正在开发中的类似 Notion 的开源 APP
https://news.itsfoss.com/appflowy-development/
2021-11-23T16:24:00
[ "生产力", "Notion" ]
https://linux.cn/article-14012-1.html
> > 它被称为“Notion 的开源替代品”,AppFlowy 旨在让你可以完全控制你的数据和定制选项。 > > > ![](/data/attachment/album/202111/23/162933pedqtdm73tk7tp49.jpg) Notion 是深受团队和个人欢迎的生产力应用之一,而现在我们似乎有希望获得一个有前途的开源替代品。 这里为还没用过 Notion 的人介绍一下,Notion 是一个多功能合一的生产力应用,可以用于创建/管理任务、笔记、项目、数据,以及组建维基。 换句话说,它能让你自由组织你的<ruby> 工作流 <rt> workflow </rt></ruby>,让你在一个地方就能集中完成所有事情。更进一步,Notion 还支持连接团队或邀请他人的协作功能。 那么,如果有一个可以提供类似 UI 和功能的开源应用会怎么样? 这就是 AppFlowy。 ![](/data/attachment/album/202111/23/162421he83atti25ya8zxr.png) ### 什么是 AppFlowy ![Source: AppFlowy.io](/data/attachment/album/202111/23/162422n2ex16ujxk6escwe.png) AppFlowy 和 Notion 非常相像,但有一个巨大的区别,那就是它是 100% 开源的。 虽然它还处在一个积极开发中的状态,但已经吸引到了不少的关注。至少可以说,尽管它是一个全新的东西,但任何开源替代项目都是令人兴奋的! 正如他们 GitHub 页面的表述,说明了为什么开发者们想要创造一个 Notion 的替代品: > > 我们都知道 Notion 有其局限性。比如说脆弱的数据安全性和糟糕的移动设备端兼容性。同样,其它一些协作工作管理工具替代品也具有各自的局限性。 > > > 因此,他们希望他们的的用户既拥有 Notion 的功能特性,又具备良好的数据安全性和由社区驱动的良好的原生体验。 他们也明确表示不想在功能特性和设计上与 Notion 相竞争。 > > 坦率的讲,我们并没有声称在功能和设计上要优于 Notion,至少现在还是如此。此外,我们当前的首要任务也不在于提供更多的功能。相反,我们期望培养一个社区,使制作复杂工作场所管理工具的知识和设施民主化,同时通过为个人和企业配备一个多功能积木工具箱,使他们能够自己创造美好的事物。 > > > 听起来很吸引我! 继续关于 **AppFlowy** 的更多信息: AppFlowy 的首个 macOS 版本已经在几天前发布了。它是用 Flutter 和 Rust 构建的。 它的目标是让用户和团队能够完整控制他们的数据和定制。他们还表示,他们希望提供包括移动设备在内的跨平台的原生体验。除此之外,你还可以离线访问你的工作区,这一点是与 Notion 不同的。 别忘了,社区可以发布定制主题和模板给他人使用,你可以按照你的需求任意定制。用户对它的发展能产生直接的影响。 它还将支持插件以扩展应用的功能。因此,即使你不具有任何编程经验,你也仍然可以选择使用这些插件来增强你工作空间的功能。并且,由于它的 UI 和 Notion 本身非常相似,如果你以后想要在两者之间切换,也不会让你感觉有太大的改变。 ### 是否仅支持 macOS ? 到目前为止只有 macOS 的用户可以尝鲜使用 AppFlowy。但 Linux 和 Windows 客户端也在开发之中。你可以持续关注它的 [GitHub 主页](https://github.com/AppFlowy-IO/appflowy) 或订阅官网的最新通知。 开发者还希望能带来更多视觉上的改变和优化。 当然,它仍然处在开发阶段。所以也别期望它现在就能替代 Notion。一些类似于<ruby> 拖放模式 <rt> drag/drop </rt> <ruby> 和离线模式的功能仍然还在它的 <a href="https://trello.com/b/NCyXCXXh/appflowy-roadmap"> 路线图 </a> 之中。 </ruby></ruby> 如果你有兴趣的话,可以访问它的官方网站或 GitHub 页面获取更多的信息,以及为其发展做出贡献。 * [AppFlowy](https://www.appflowy.io) ### 总而言之 有了社区的支持,AppFlowy 可能是 Notion 的可靠替代品。基于免费和开源的事实让它一开始就吸引大量个人和团队来试用它。 我也开始期待它尽快增加对 Linux 的支持,我知道它已经在开发中了。 你如何看待 AppFlowy? 你会计划试用它吗? --- via: <https://news.itsfoss.com/appflowy-development/> 作者:[Rishabh Moharir](https://news.itsfoss.com/author/rishabh/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[zengyi1001](https://github.com/zengyi1001) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) [Notion](https://notion.grsm.io/itsfoss?ref=news.itsfoss.com) is one of the most popular productivity apps for teams and individuals alike. And, it looks like we could be getting a promising open-source alternative to it. For those who don’t know or haven’t used Notion-it is an all-in-one productivity app to create/manage tasks, notes, projects, databases, and build wikis. In other words, it gives you the freedom to organize your workflow and lets you do everything in a single place. Moreover, Notion also supports collaboration features to connect with your team or invite guests. So, how about an open-source application that offers a similar UI and feature set? That’s where** AppFlowy** comes in. ## What is AppFlowy? ![A sceenshot of AppFlowy](https://news.itsfoss.com/content/images/wordpress/2021/11/welcome-1024x729.png) AppFlowy is very similar to Notion, except for one huge difference. It is 100% open-source. Although still actively under development, it has managed to grab some attention. While it is fairly new, an open-source alternative for anything is exciting, to say the very least! As per their GitHub page, here’s why the developers want to create an alternative to Notion: We all know Notion has its limitations. These include weak data security and poor compatibility with mobile devices. Likewise, alternative collaborative workplace management tools also have their constraints. So, they want their users to have the features of Notion but with better data security and a genuine native experience with a community-driven approach. They’ve also made it clear that they do not want to compete with Notion in terms of features/design: To be honest, we do not claim to outperform Notion in terms of functionality and design, at least for now. Besides, our priority doesn’t lie in more functionality at the moment. Instead, we would like to cultivate a community to democratize the knowledge and wheels of making complex workplace management tools, while enabling people and businesses to create beautiful things on their own by equipping them with a versatile toolbox of building blocks. Sounds good to me! Moving on, more about the app, **AppFlowy**: AppFlowy’s first version for macOS was released a few days back. It is built using Flutter and Rust. It aims to give users and teams total control of their data and customizations. They also state that they want to provide a native experience cross-platform, including mobile devices. In addition to that, it should enable you offline access to your workspace, unlike Notion. Not to forget, communities can publish custom-made themes and templates for others to use, and you get to customize as much as you want. And users can make a direct impact on its development as well. It will also support plugins to extend the functionality of the app. So, if you do not have any coding experience, you can still choose to enhance your workspace using these plugins. Moreover, the UI is quite similar to that of Notion, so if you plan to switch in the future, it should not feel like a drastic change. [Notion – One workspace. Every team.We’re more than a doc. Or a table. Customize Notion to work the way you do.](https://notion.grsm.io/itsfoss?ref=news.itsfoss.com)![](https://www.notion.so/front-static/meta/default.png) ![](https://www.notion.so/front-static/meta/default.png) ## Is it Only Available for macOS? As of now, only macOS users can try out AppFlowy. However, a Linux and Windows client is also in development. You can keep an eye on its [GitHub page](https://github.com/AppFlowy-IO/appflowy?ref=news.itsfoss.com) or subscribe to the newsletter on the official website. The developers are also looking to bring more visual changes and enhancements. Of course, it is still in the early stages of development. So, you should not expect it to replace Notion just yet. Some of the features like drag/drop and offline mode are still in its [roadmap](https://trello.com/b/NCyXCXXh/appflowy-roadmap?ref=news.itsfoss.com). You can visit the official website or the GitHub page to explore more about it and contribute to its development if you are interested. ## Wrapping Up AppFlowy could be a solid alternative to Notion with proper community support. The fact that it is free and open-source should give it a massive head start to attract individuals and teams to try it out. I also wish it adds the support for Linux soon, knowing that it’s already in development. *What do you think about AppFlowy? Are you planning on trying it out?* ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,014
如何将 FreeDOS 作为嵌入式系统使用
https://opensource.com/article/21/6/freedos-embedded-system
2021-11-24T13:47:46
[ "FreeDOS", "嵌入式" ]
https://linux.cn/article-14014-1.html
> > 现在,很多嵌入式系统都是在 Linux 上运行的。但是,在很久很久以前,嵌入式系统要么在一个定制的专有的平台上运行,要么在 DOS 上运行。 > > > ![](/data/attachment/album/202111/24/134734s6zuftzjgtt8herp.jpg "Computer laptop in space") [FreeDOS 网站](https://www.freedos.org/) 宣称,大多数人使用 FreeDOS 来完成三项主要任务: 1. 玩经典的 DOS 游戏 2. 运行老式的 DOS 软件 3. 运行一款嵌入式系统 但是,运行一个“嵌入式”系统的意义是什么呢? 嵌入式系统基本上是一款非常小的系统,专用于运行一个特定的任务。你可以把现在的嵌入式系统当作是 *物联网*(IoT)的一部分,这包括传感器、恒温器和门铃摄像头。现在,很多嵌入式系统都是在 Linux 上运行的。 但是,在很久很久以前,嵌入式系统要么在一个定制的专有的平台上运行,要么在 DOS 系统上运行。在现在,一些基于 DOS 的嵌入式系统仍然在运行,例如,收银机或电话专用交换机(PBX)系统。举个例子来说,在 2017 年,酷爱列车的人发现一个正在运行 FreeDOS 的俄罗斯的电动列车控制系统 (俄语: *САВПЭ*),它使用特殊的软件来控制和监控郊区列车的线路,并发布乘客通告。 在 DOS 上建立一个嵌入式系统需要定义一个最小化的 DOS 环境来运行单个应用程序。幸运的是,设置一个最小化的 FreeDOS 环境是非常容易的。从技术上来说,启动 FreeDOS 并运行 DOS 应用程序仅需要内核和一个 `FDCONFIG.SYS` 配置文件。 ### 安装一款最小化的系统 我们可以使用 QEMU 仿真器来模拟一个专用的、最小化的 FreeDOS 系统,并给它分配很少的资源。为了更准确地反映一个嵌入式系统,我将定义一个只有 8 MB 的存储器和仅仅有 2 MB 的硬盘驱动器的虚拟机。 为创建这个微小的虚拟硬盘,我将使用这个 `qemu-img` 命令来定义一个 2M 的文件: ``` $ qemu-img create tiny.img 2M Formatting 'tiny.img', fmt=raw size=2097152 ``` 下面的这行命令定义了一个 32 位的 “i386” CPU、8MB 的存储器,使用 2MB 的 `tiny.img` 文件作为硬盘驱动器镜像,使用 FreeDOS 1.3 RC4 LiveCD 作为 CD-ROM 介质。我们也将机器设置为从 CD-ROM 驱动器启动(`-boot order=d`),尽管我们只需要用它来安装系统。在我们完成所有的设置后,我们将从该硬盘启动完成的嵌入式系统: ``` qemu-system-i386 -m 8 -hda tiny.img -cdrom FD13LIVE.iso -boot order=d ``` 使用 “<ruby> 现场环境模式 <rt> Live Environment mode </rt></ruby>” 来启动系统,这将为我们提供一个正在运行的 FreeDOS 系统,我们可以使用它来将一个最小化的 FreeDOS 转移到硬盘上。 ![embedded setup](/data/attachment/album/202111/24/134748ddur1k49tzrj1ruk.png "Boot into the LiveCD environment") *启动到 LiveCD 环境之中(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 我们需要在虚拟硬盘驱动器上为我们的程序创建一个分区。为此,从命令行中运行 `FDISK` 程序。`FDISK` 是 FreeDOS 上的一个标准的 *磁盘分区* 实用程序。使用 `FDISK` 来创建一个单个硬盘驱动器分区,占用整个(2 MB)硬盘驱动器。 ![embedded setup](/data/attachment/album/202111/24/134748oihhkbbyszibsb8e.png "FDISK, after creating the 2 megabyte partition") *FDISK,在创建 2 MB 分区后(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 但是,在你重新启动 FreeDOS 之前,FreeDOS 不会看到新的硬盘驱动器分区 — FreeDOS 仅在启动时读取硬盘详细信息。退出 `FDISK` ,并重新启动 FreeDOS 。 在重新启动后,你需要在新的硬盘驱动器上创建一个 DOS 文件系统。因为这里只有一个虚拟硬盘,FreeDOS 将识别其为 `C:` 驱动器。你可以使用 `FORMAT` 命令来在 `C:` 驱动器上创建一个 DOS 文件系统。使用 `/S` 选项将把操作系统文件(内核,外加一个 `COMMAND.COM` shell 的副本)转移到新的驱动器上。 ![embedded setup](/data/attachment/album/202111/24/134748ebaai9w9vinpn09e.png "Format the new drive to create a DOS filesystem") *格式化新的驱动器来创建一个 DOS 文件系统(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 你已经创建了硬盘驱动器并将其格式化,现在,你可以安装应用程序,这些应用程序是将会在新安装的嵌入式系统上运行的。 ### 安装专用的应用程序 嵌入式系统实际上只是一个运行在一个专用系统上的单一用途的应用程序。这些应用程序通常是为其将要控制的系统而自定义构建的,例如,一台收银机、显示终端、或控制环境。在这个演示中,让我们使用一个来自 FreeDOS 1.3 RC4 安装光盘中的程序。它需要足够小,以适应我们为其创建的 2 MB 微型硬盘驱动器。这可以是任何东西,所以,为了好玩,让我们把它变成一个游戏。 FreeDOS 1.3 RC4 包含一些有趣的游戏。我喜欢的一个游戏是一个名称为 “Simple Senet” 的棋类游戏。它是一个基于 Senet 的古埃及棋类游戏。游戏的细节对这个演示并不重要,我们将安装它,并将其设置为嵌入式系统的专业应用程序。 为安装应用程序,在 FreeDOS 1.3 RC4 LiveCD 上,进入 `\PACKAGES\GAMES` 目录。你将在其中看到一个很长的软件包列表,而我们想要的 `SENET.ZIP` 。 ![embedded setup](/data/attachment/album/202111/24/134748s4caqvbowzvn4ggq.png "A list of game packages from FreeDOS 1.3 RC4") *来自 FreeDOS 1.3 RC4 的一个游戏软件包列表(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 为解压缩 “Simple Senet” 软件包到虚拟硬盘上,使用 `UNZIP` 命令。所有的 FreeDOS 软件包都是 Zip 文件,因此,你可以使用任意与 Zip 兼容的档案实用程序来管理它们。FreeeDOS 1.3 RC4 包含创建 Zip 档案文件的 `ZIP` 和提取 Zip 档案文件的 `UNZIP` 。它们都来自 [Info-Zip 项目](http://infozip.sourceforge.net/) 。 ``` UNZIP SENET.ZIP -d C:\FDOS ``` 通常,使用 `UNZIP` 来提取 Zip 文件到当前目录中。在命令行结尾的 `-d C:\FDOS` 选项将告诉 `UNZIP` 来提取 Zip 文件到 `C:\FDOS` 目录之中。(`-d` 指的是“目的地”) ![embedded setup](/data/attachment/album/202111/24/134749h89nfgt9y9qqyntt.png "Unzipping the Simple Senet game") *解压缩 Simple Senet 游戏(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 为了让嵌入式系统启动时运行 “Simple Senet” 游戏,我们需要告诉 FreeDOS 来使用 Senet 作为系统的 “shell” 。 默认的 FreeDOS 的 shell 是 `COMMAND.COM` 程序,但是,你可以在 `FDCONFIG.SYS` 内核配置文件中使用 `SHELL=` 指令来定义一个不同的 shell 程序。我们可以使用 FreeDOS 的 Edit 来创建新的 `C:\FDCONFIG.SYS` 文件。 ![Embedded edit senet](/data/attachment/album/202111/24/134749af8lji8lfcz3jp7n.png "Embedded edit senet") *(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 如果你需要定义其它的参数来支持嵌入式系统,你可以将其添加到 `FDCONFIG.SYS` 文件之中。例如,你可能需要使用 `SET` 动作来设置环境变量,或者使用 `FILES=` 或 `BUFFERS=` 语句来调整 FreeDOS 内核。 ### 运行嵌入式系统 在全面地完成嵌入式系统的定义之后,现在,我们可以重新启动计算机来运行嵌入式应用程序。运行一个嵌入式系统通常仅需要有限的资源,因此,在这个演示中,我们需要调整 QEMU 命令行来只从硬盘驱动器(`-boot order=c`)中启动,而不再定义一个 CD-ROM 驱动器: ``` qemu-system-i386 -m 8 -hda tiny.img -boot order=c ``` 当 FreeDOS 内核启动时,它将读取 `FDCONFIG.SYS` 文件以获取启动参数。然后,它将使用 `SHELL=` 行的定义来运行 shell 。这将自动地运行 “Simple Senet” 游戏。 ![embedded setup](/data/attachment/album/202111/24/134749ys2znchnc333s307.png "Running Simple Senet as an embedded system") *作为一个嵌入式系统运行 Simple Senet(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 我们已经使用了 “Simple Senet” 来演示如何在 FreeDOS 上设置一个嵌入式系统。根据你的需要,你可以使用任何你喜欢的独立应用程序。在 `FDCONFIG.SYS` 中使用 `SHELL=` 行将其定义为 DOS 的 shell ,FreeDOS 将在启动时自动地启动该应用程序。 不过,在这里有一个限制。嵌入式系统通常不需要退回到一个命令行提示符之中,因此这些专用应用程序通常不允许用户退出到 DOS 之中。如果你设法退出了嵌入式应用程序,你可能会看到一个 “Bad or missing Command Interpreter” 的提示,你将需要在其中输入一个新的 shell 的完整路径。对于一个以用户为中心的桌面系统来说,这将是一个问题。但是在一个嵌入式系统上,它只专注执行一种工作的,那么,你也永远不需要退出嵌入式应用程序。 --- via: <https://opensource.com/article/21/6/freedos-embedded-system> 作者:[Jim Hall](https://opensource.com/users/jim-hall) 选题:[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/) 荣誉推出
200
OK
The [FreeDOS website](https://www.freedos.org/) says that most people use FreeDOS for three main tasks: - Playing classic DOS games - Running legacy DOS software - Running an embedded system But what does it mean to run an "embedded" system? An embedded system is basically a very minimal system that is dedicated to run a specific task. You might think of embedded systems today as part of the *Internet of Things* (IoT) including sensors, thermostats, and doorbell cameras. Many embedded systems today run on Linux. But once upon a time, embedded systems either ran on a custom, proprietary platform or ran on DOS. Some of these DOS-based embedded systems still run today, such as cash registers or phone private branch exchange (PBX) systems. In one example as recently as 2017, trainspotters discovered a Russian electric train control system (Russian: *САВПЭ*) running FreeDOS with special software to control and monitor the route of suburban trains and to make passenger announcements. Setting up an embedded system on DOS requires defining a minimal DOS environment that runs a single application. Fortunately, setting up a minimal FreeDOS environment is pretty easy. Technically, all you need to boot FreeDOS and run DOS applications is the kernel and a `FDCONFIG.SYS` configuration file. ## Installing a minimal system We can simulate a dedicated, minimal FreeDOS system by using the QEMU emulator with very small allocations. To reflect an embedded system more accurately, I'll define a virtual machine with only 8 megabytes of memory and a mere 2 megabytes for a virtual hard drive. To create the tiny virtual hard drive, I'll use this `qemu-img` command to define a 2-megabyte file: ``` `````` $ qemu-img create tiny.img 2M Formatting 'tiny.img', fmt=raw size=2097152 ``` This command line defines a 32-bit "i386" CPU with 8 megabytes of memory, using the 2-megabyte `tiny.img` file as the hard drive image and the FreeDOS 1.3 RC4 LiveCD as the CD-ROM media. We'll also set the machine to boot from the CD-ROM drive (`-boot order=d` ) although we only need that to install. We'll boot the completed embedded system from the hard disk after we've set everything up: ``` `````` qemu-system-i386 -m 8 -hda tiny.img -cdrom FD13LIVE.iso -boot order=d ``` Boot the system using the "Live Environment mode"—this provides us with a running FreeDOS system that we can use to transfer a minimal FreeDOS to the hard disk. ![Boot into the LiveCD environment embedded setup](https://opensource.com/sites/default/files/uploads/embedded-setup02.png) Boot into the LiveCD environment (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) We'll need to create a partition on the virtual hard drive for our programs. To do that, run the FDISK program from the command line. FDISK is the standard *fixed disk* utility on FreeDOS. Use FDISK to create a single hard drive partition that spans the entire (2-megabyte) hard drive. ![FDISK, after creating the 2 megabyte partition embedded setup](https://opensource.com/sites/default/files/uploads/embedded-setup09.png) FDISK, after creating the 2 megabyte partition (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) But FreeDOS won't see the new hard drive partition until you reboot—FreeDOS only reads the hard disk details at startup. Exit FDISK and reboot, and you'll be ready for the next step. After rebooting, you need to create a DOS filesystem on the new hard drive. Since there's just the one virtual hard disk, FreeDOS will identify it as the `C:` drive. You can create a DOS filesystem on `C:` with the FORMAT command. The `/S` option transfers the operating system files (the kernel, plus a copy of the `COMMAND.COM` shell) to the new drive. ![Format the new drive to create a DOS filesystem embedded setup](https://opensource.com/sites/default/files/uploads/embedded-setup19.png) Format the new drive to create a DOS filesystem (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) Now that you've created the drive and formatted it, you can install the application that will run on the embedded system. ## Installing the dedicated application An embedded system is really just a single-purpose application running on a dedicated system. Such applications are usually custom-built for the system it will control, such as a cash register, display terminal, or control environment. For this demonstration, let's use a program from the FreeDOS 1.3 RC4 installation CD-ROM. It needs to be small enough to fit in the tiny 2-megabyte hard drive we've created for it. This can be anything—so just for fun, let's make it a game. FreeDOS 1.3 RC4 includes several fun games. One game that I like is a board game called Simple Senet. It's based on Senet, an ancient Egyptian board game. The details of the game aren't important for this demonstration, except that we'll install it and set it up as the dedicated application for the embedded system. Note: Paths have changed in FreeDOS 1.3. This article was written when FreeDOS 1.3 Release Candidate 4 was current, but FreeDOS 1.3 (not RC4) changed a few paths, including the path to the `SENET.EXE` program.If you want to try the steps from this article on FreeDOS 1.3, you must update your paths. In FreeDOS 1.3 RC4, the `SENET.EXE` binary was in the`BIN` directory. In FreeDOS 1.3,`SENET.EXE` is in the`GAMES\SENET` directory.That is, if you unzip Simple Senet using `unzip senet.zip -d C:\FDOS` then use`SHELL=C:\FDOS\GAMES\SENET\SENET.EXE` in your`FDCONFIG.SYS` file. To install the application, go into the `\PACKAGES\GAMES` directory on the FreeDOS 1.3 RC4 LiveCD. You'll see a long list of packages there, and the one we want is `SENET.ZIP` . ![A list of game packages from FreeDOS 1.3 RC4 embedded setup](https://opensource.com/sites/default/files/uploads/games-dir.png) A list of game packages from FreeDOS 1.3 RC4 (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) To unzip the Simple Senet package onto the virtual hard drive, use the `UNZIP` command. All FreeDOS packages are Zip files, so you can use any Zip-compatible archive utility to manage them. FreeDOS 1.3 RC4 includes `ZIP` to create Zip archives, and `UNZIP` to extract Zip archives. Both are from the [Info-Zip Project](http://infozip.sourceforge.net/). ``` ````UNZIP SENET.ZIP -d C:\FDOS` Normally, using `UNZIP` will extract a Zip file in the current directory. The `-d C:\FDOS` option at the end of the command line tells `UNZIP` to extract the Zip file to the `C:\FDOS` directory. (`-d` means "destination.") ![Unzipping the Simple Senet game embedded setup](https://opensource.com/sites/default/files/uploads/senet-unzip.png) Unzipping the Simple Senet game (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) To run the Simple Senet game whenever the embedded system boots, we need to tell FreeDOS to use Senet as the system "shell." The default FreeDOS shell is the `COMMAND.COM` program, but you can define a different shell program using the `SHELL=` directive in the `FDCONFIG.SYS` kernel configuration file. We can use FreeDOS Edit to create the new `C:\FDCONFIG.SYS` file. ![Embedded edit senet Embedded edit senet](https://opensource.com/sites/default/files/pictures/embedded-edit-senet.png) (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) If you need to define other parameters to support the embedded system, you can add those to the `FDCONFIG.SYS` file. For example, you might need to set environment variables using the `SET` action, or tune the FreeDOS kernel with `FILES=` or `BUFFERS=` statements. ## Run the embedded system With the embedded system fully defined, we can now reboot the machine to run the embedded application. Running an embedded system usually requires only limited resources, so for this demonstration, we'll tweak the QEMU command line to only boot from the hard drive (`-boot order=c` ) and not define a CD-ROM drive: ``` `````` qemu-system-i386 -m 8 -hda tiny.img -boot order=c ``` When the FreeDOS kernel starts up, it reads the `FDCONFIG.SYS` file for its startup parameters. Then it runs the shell using the `SHELL=` line. That runs the Simple Senet game automatically. ![Running Simple Senet as an embedded system embedded setup](https://opensource.com/sites/default/files/uploads/senet.png) Running Simple Senet as an embedded system (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) We've used Simple Senet to demonstrate how to set up an embedded system on FreeDOS. Depending on your needs, you can use whatever standalone application you like. Define it as the DOS shell using the `SHELL=` line in `FDCONFIG.SYS` and FreeDOS will automatically launch the application at boot-time. However, there's one limitation here. Embedded systems do not usually need to exit back to a command prompt, so these dedicated applications don't usually allow the user to quit to DOS. If you manage to exit the embedded application, you'll likely see a "Bad or missing Command Interpreter" prompt, where you'll need to enter the full path to a new shell. For a user-focused desktop system, this would be a problem. But on an embedded system that's dedicated to doing only one job, you should never need to exit anyway. ## Comments are closed.
14,015
开发中的 KDE Plasma 5.24 新变化:增加 GNOME 式概览、防删功能
https://news.itsfoss.com/kde-plasma-5-24-dev/
2021-11-24T17:29:45
[ "KDE" ]
https://linux.cn/article-14015-1.html
> > KDE Plasma 正在升级中,以改善类似于 GNOME shell 的概览,并为非技术用户提供更多的可用性改进。 > > > ![](/data/attachment/album/202111/24/172946sdxdebf0zq67wrp7.png) 自从 2011 年 GNOME 3 以来,活动概览在与 GNOME 的互动中起到了关键作用。尽管它在发布时受到了严厉的批评,但许多用户现在已经爱上了它,导致其他一些桌面环境也在考虑实现类似的功能。 而且,看起来 KDE Plasma 正在添加类似的东西,它就像是一个全新的类似 GNOME 的概览。让我们来仔细了解一下。 ### 新的 Plasma 概览 ![Image: Vlad Zahorodnii / KDE Developer](/data/attachment/album/202111/24/172948k7kbpp4jbu77747u.png) 当我偶然看到 KDE 开发者 [Nate Graham 的博文](https://pointieststick.com/2021/11/19/this-week-in-kde-most-of-gnome-shell-in-the-overview-effect/) 时,我注意到了一个与 GNOME 活动概览非常相似的东西。 如上面的截图所示,当你在 KDE 上按 `Windows`/`Super` 键进入概览界面时,你就会看到它。 然而,值得注意的是,它仍然处在开发版本中。而且,它已经被合并到 KDE Plasma 5.24 中去了。 但是它和 GNOME 活动概览相似吗? 它看起来确实相似,但有一些关键的区别,其中包括: * 在概览中,你可以完全访问底部面板。 * 搜索功能是由 KRunner 提供的,用来寻找应用程序和活动窗口。 #### 可以完全访问底部面板 如果你正在使用 KDE,你肯定知道底部面板。到目前为止,它与 GNOME 的概览效果最显著的区别是有任务栏。这使得用户可以访问一个统一的地方来打开应用程序,访问快速设置,并查看通知。 作为一个拥有任务栏的传统桌面理念的粉丝,这对于 Plasma 这样的传统桌面环境来说感觉非常完美。 #### 使用 KRunner 进行强大的搜索(新增加的功能) ![](/data/attachment/album/202111/24/172948k7kbpp4jbu77747u.png) 多年来,KRunner 无疑是 Linux 中最强大的应用程序启动器之一。它的一些神奇功能包括可以搜索: * 文件 * 设置 * 应用程序 * 打开浏览器标签 * 打开现有窗口 因此,KRunner 已被整合到 KWin 的概览效果中,可以让你搜索现有窗口或启动新的应用程序。 我相信很多用户会非常高兴地看到这个整合,特别是那些已经使用 KRunner 的用户。 ### 防止用户卸载 KDE 为了改善非技术用户的用户体验,Discover(KDE 的软件中心)现在会阻止任何删除任何关键软件包的行为,比如桌面环境。 ![来自 PointiestStick 博客](/data/attachment/album/202111/24/172950d4pp4t4004b3tust.png) 你可能知道,这个问题是由 Linus Sebastian(Linus Tech Tips)强调的,当他在 Pop!\_OS 上安装 Steam 时,结果却删除了 GNOME、Xorg 和其他重要软件包。 所以,接下来的改进是为了解决这个问题,这对 KDE Plasma 5.24 来说是一个很好的补充。 ### 其他改进 除了关键的亮点之外,KDE Plasma 5.24 旨在提高性能、响应速度和用户体验。 此外,也有一些细微的用户界面调整和小程序改进。要想了解更多,你应该浏览一下 [Nate 的博文](https://pointieststick.com/2021/11/19/this-week-in-kde-most-of-gnome-shell-in-the-overview-effect/) 以及与上述功能相关的 [合并请求](https://invent.kde.org/plasma/kwin/-/merge_requests/1688)。 ### 总结 根据我对 KDE Plasma 的体验,它是一个非常注重生产力的桌面。KDE 在改善桌面环境的概览效果和可用性的同时,将包括一个同样具有生产力和专注性的用户界面,这是很有意义的。 如果你想尝试新的改进,恐怕你必须等待 Plasma 5.24 发布。虽然这对现在来说是要等待相当长的时间(2022 年 2 月),但我相信这将是值得的。 --- via: <https://news.itsfoss.com/kde-plasma-5-24-dev/> 作者:[Jacob Crume](https://news.itsfoss.com/author/jacob/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Ever since Gnome 3 in 2011, the activities overview has played a key role in interacting with it. Despite its heavy criticism at launch, many users have now come to love it, leading to some other desktop environments looking at implementing similar features. And, it looks like KDE Plasma is adding something like it, more like a brand new Gnome-like overview feature. Let us take a closer look. ## The New Plasma Overview ![kwin kde](https://news.itsfoss.com/content/images/wordpress/2021/11/kwin-kde-gnome-overview-effect-1024x576.png) **/ KDE Developer** [Vlad Zahorodnii](https://invent.kde.org/vladz?ref=news.itsfoss.com)When I stumbled upon the [blog post by Nate Graham](https://pointieststick.com/2021/11/19/this-week-in-kde-most-of-gnome-shell-in-the-overview-effect/?ref=news.itsfoss.com) (KDE Dev), I noticed something very similar to the GNOME Activities overview. You will notice it when you get to the overview screen on KDE by pressing the windows/super key, as shown in the screenshot above. However, it is worth noting that it is still in the development version. And, it has been merged to ship with KDE Plasma 5.24. But is it similar to the GNOME Activities overview? It does look similar, but there are quite a few key differences, some of which include: - You get full access to the bottom panel while in the overview. - The search is powered by KRunner to look for applications and active windows. ### Full Access to the Bottom Panel If you are using KDE, you already know this, but by far, the most significant difference to GNOME’s overview effect is the availability of the taskbar. This allows the user to access a unified place to open applications, access quick settings, and view notifications. As a fan of the traditional desktop philosophy of having a taskbar, its inclusion here feels perfect for a traditional desktop environment like Plasma. ### Powerful Search Using KRunner (New Addition) ![](https://news.itsfoss.com/content/images/wordpress/2021/11/Plasma-overview-KRunner1.jpg) For many years, KRunner has undoubtedly been one of the most powerful application launchers for Linux. Some of its incredible features include the ability to search: - Files - Settings - Applications - Open browser tabs - Open existing windows Hence, KRunner has been integrated into KWin’s overview effect to let you search for existing windows or launch new applications. I am sure many users will be extremely pleased to see this inclusion, especially those that already use KRunner. ## Preventing Users from Uninstalling KDE To improve the user experience for non-technical users, Discover (KDE’s software center) will now prevent anything that removes any crucial packages like the desktop environment. ![](https://news.itsfoss.com/content/images/wordpress/2021/11/cant-remove-plasma-1.png) You probably know that this issue was highlighted by Linus Sebastian (Linus Tech Tips) when he ended up removing gnome, Xorg, and other vital packages when installing Steam on Pop!_OS. So, improvements have followed to address that, and this is an excellent addition to KDE Plasma 5.24. ## Other Improvements In addition to the key highlights, KDE Plasma 5.24 aims to improve performance, responsiveness, and user experience. There are some subtle user interface tweaks and applet improvements as well. To learn more, you should explore the [blog post by Nate](https://pointieststick.com/2021/11/19/this-week-in-kde-most-of-gnome-shell-in-the-overview-effect/?ref=news.itsfoss.com) and the [merge requests](https://invent.kde.org/plasma/kwin/-/merge_requests/1688?ref=news.itsfoss.com) associated with the features mentioned above. ## Final Thoughts From my experience with KDE Plasma, it is a very productivity-focused desktop. It makes a lot of sense that KDE will include a UI as productive and focused while improving the desktop environment’s overview effects and usability. If you want to try out the new improvements, I’m afraid you will have to wait for Plasma 5.24 to release. While that is quite a long wait for now (February 2022), I’m sure it will be worth it. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,018
Kubernetes 复制控制器如何工作
https://opensource.com/article/21/11/kubernetes-replicationcontroller
2021-11-25T13:11:08
[ "Kubernetes" ]
https://linux.cn/article-14018-1.html
> > 复制控制器负责管理吊舱的生命周期并确保在任何时候运行着所需的指定数量的吊舱。 > > > ![Ships at sea on the web](/data/attachment/album/202111/25/131052ltjaz53jqkfamthh.jpg "Ships at sea on the web") 你有没有想过,谁负责监督和管理 Kubernetes 集群内运行的“<ruby> 吊舱 <rt> pod </rt></ruby>”的确切数量?Kubernetes 可以通过多种方式做到这一点,但一个常见的方法是使用 “<ruby> 复制控制器 <rt> ReplicationController </rt></ruby>(RC)”。RC 负责管理吊舱的生命周期,并确保在任何时候运行着所需的指定数量的吊舱。但另一方面,它不负责高级的集群能力,如执行自动扩展、准备度和活跃探测以及其他高级的复制能力。Kubernetes 集群中的其他组件可以更好地执行这些功能。 简而言之,RC 的职责有限,通常用于不需要复杂逻辑就能达到某些要求的具体实现(例如,确保所需的吊舱数量总是与指定的数量相符)。如果超过了所需的数量,RC 会删除多余的,并确保即使在节点故障或吊舱终止的情况下,也有相同数量的存在。 简单的事情不需要复杂的解决方案,对我来说,这就是 RC 如何被使用的一个完美的比喻。 ### 如何创建一个 RC 像大多数 Kubernetes 资源一样,你可以使用 YAML 或 JSON 格式创建一个 RC,然后将其发布到 Kubernetes API 端点。 ``` $ kubectl create -f rcexample.yaml replicationcontroller/rcexample created ``` 现在,我将深入一下 `rcexample.yaml` 的样子。 ``` apiVersion: v1 kind: ReplicationController → RC 描述符 metadata: name: rcexample → 复制控制器名字 spec: replicas: 3 → 预期的吊舱数量 selector: → 这个 RC 的吊舱选择器 app: nginx template: → 用于创建新吊舱的模板 metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ``` 进一步解释,这个文件在执行时创建了一个名为 `rcexample` 的 RC,确保三个名为 `nginx` 的吊舱实例一直在运行。如果一个或所有的 `app=nginx` 吊舱没有运行,新的吊舱将根据定义的吊舱模板创建。 一个 RC 有三个部分: * 复制品:`3` * 吊舱模板:`app=nginx` * 吊舱选择器:`app=nginx` 注意,吊舱模板要与吊舱选择器相匹配,以防止 RC 一直创建吊舱。如果你创建的 RC 的吊舱选择器与模板不匹配,Kubernetes API 服务器会给你一个错误。 为了验证 RC `rcexample` 是否被创建: ``` $ kubectl get po NAME READY STATUS RESTARTS AGE rcexample-53thy 0/1 Running 0 10s rcexample-k0xz6 0/1 Running 0 10s rcexample-q3vkg 0/1 Running 0 10s ``` 要删除 RC: ``` $ kubectl delete rc rcexample replicationcontroller "rcexample" deleted ``` 注意,你可以对 RC 中的服务使用 [滚动更新](https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/) 策略,逐个替换吊舱。 ### 其他复制容器的方法 在 Kubernetes 部署中,有多种方法可以实现容器的复制。Kubernetes 成为容器平台的主要选择的主要原因之一是复制容器以获得可靠性、负载平衡和扩展的原生能力。 我在上面展示了你如何轻松地创建一个 RC,以确保在任何时候都有一定数量的吊舱可用。你可以通过更新副本的数量来手动扩展吊舱。 另一种可能的方法是通过使用 “<ruby> <a href="https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/"> 复制集 </a> <rt> ReplicaSet </rt></ruby>(RS)”来达到复制的目的。 ``` (kind: ReplicaSet) ``` RS 的功能几乎与 RC 相同。主要区别在于,RS 不允许滚动更新策略。 另一种实现复制的方法是通过使用 “<ruby> <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/"> 部署 </a> <rt> Deployments </rt></ruby>”。 ``` (kind: Deployment) ``` 部署是一种更高级的容器复制方法。从功能上讲,部署提供了相同的功能,但在需要时可以推出和回滚变化。这种功能之所以能够实现,是因为部署有 “<ruby> 策略类型 <rt> StrategyType </rt></ruby>” 规范来用新的吊舱替换旧的吊舱。你可以定义两种类型的部署策略:“<ruby> 重新创建 <rt> Recreate </rt></ruby>” 和 “<ruby> 滚动更新 <rt> RollingUpdate </rt></ruby>”。你可以如下指定部署策略: ``` StrategyType: RollingUpdate ``` ### 总结 容器的复制功能是大多数企业考虑采用 Kubernetes 的主要原因之一。复制可以让你达到大多数关键应用程序需要的可靠性和可扩展性,作为生产的最低要求。 了解在 Kubernetes 集群中使用哪些方法来实现复制,对于决定哪种方法最适合你的应用架构考虑非常重要。 --- via: <https://opensource.com/article/21/11/kubernetes-replicationcontroller> 作者:[Mike Calizo](https://opensource.com/users/mcalizo) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Have you ever wondered what is responsible for supervising and managing just the exact number of pods running inside the Kubernetes cluster? Kubernetes can do this in multiple ways, but one common approach is using ReplicationController (rc). A ReplicationController is responsible for managing the pod lifecycle and ensuring that the specified number of pods required are running at any given time. On the other hand, it is not responsible for the advanced cluster capabilities like performing auto-scaling, readiness and liveliness probes, and other advanced replication capabilities. Other components within the Kubernetes cluster better perform those capabilities. In short, the ReplicationController has limited responsibility and gets typically used for specific implementations that do not require complex logic to attain certain requirements (for example, ensuring that the desired number of pods always matches the specified number). If there are more than the desired number, the ReplicationController removes the excess ones and ensures the same number of pods exist even in the event of node failure or pod termination Simple things do not require complex solutions, and this is, for me, a perfect metaphor of how a ReplicationController gets used. ## How to Create a ReplicationController Like most Kubernetes resources, you can create a ReplicationController using YAML or JSON format then post it to the Kubernetes API endpoint. ``` $ kubectl create -f rcexample.yaml replicationcontroller/rcexample created ``` Now, I'll dig a bit deeper into what `rcexample.yaml` looks like. ``` apiVersion: v1 kind: ReplicationController → rc descriptor metadata: name: rcexample → Name of the replication controller spec: replicas: 3 → Desired number of pods selector: → The pod selector for this rc app: nginx template: → The template for creating a new pod metadata: labels: app: nginx spec: containers: - name: nginx image: nginx ``` To explain further, this file, when executed to create a ReplicationController called `rcexample` ensures that three instances of pods called `nginx` are running all the time. If one or all the pods `app=nginx` are not running, new pods are created based on the defined pod template. A ReplicationController has three parts: - Replica: 3 - Pod Template: app=nginx - Pod Selector: app=nginx Notice that Pod Template matches with Pod Selector to prevent the ReplicationController from indefinitely creating pods. If you create a ReplicationController with a pod selector not matching the template, the Kubernetes API server gives you an error. To verify that the ReplicationController `rcexample` got created: ``` $ kubectl get po NAME READY STATUS RESTARTS AGE rcexample-53thy 0/1 Running 0 10s rcexample-k0xz6 0/1 Running 0 10s rcexample-q3vkg 0/1 Running 0 10s ``` To delete the ReplicationController: ``` $ kubectl delete rc rcexample replicationcontroller "rcexample" deleted ``` Note that you can use a [rolling update](https://kubernetes.io/docs/tutorials/kubernetes-basics/update/update-intro/) strategy to the service in the ReplicationController by replacing pods one by one. ## Other methods to replicate containers In a Kubernetes deployment, there are multiple ways you that can attain replication of containers. One of the main reasons Kubernetes is the main choice for container platforms is the native ability to replicate containers to attain reliability, load balancing, and scaling. I have shown above how you can easily create a ReplicationController to make sure that a certain number of pods is available at any given time. You can manually scale pods by updating the number of replicas. The other possible approach to attain replication is by using [ReplicaSet](https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/). `(kind: ReplicaSet)` ReplicaSet (rs) functions are almost identical to ReplicationController. The main difference is that a ReplicaSet does not allow a rolling-update strategy. Another approach to attain replication is by using [Deployments](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/). `(kind: Deployment)` Deployments is a more advanced container replication approach. Functionality-wise, Deployments provide the same functionality but can roll out and roll back changes if needed. This functionality is possible because Deployments has StrategyType specification to replace old pods with new ones. There are two types of deployment strategies that you can define—Recreate and RollingUpdate. You specify the deployment strategy as shown below: `StrategyType: RollingUpdate` ## Conclusion Replication of containers is one of the main reasons why Kubernetes gets considered for most enterprise container adoption. Replication allows you to attain the reliability and scalability that most critical applications need as minimum requirements for production. Understanding which methods to use to attain replication in a Kubernetes cluster is important to decide which one is the best for you to incorporate in your application architecture consideration. ## Comments are closed.
14,019
亚马逊自己的 Linux 发行版现在完全基于 Fedora 了
https://news.itsfoss.com/amazon-linux-2022-preview/
2021-11-25T14:21:43
[ "亚马逊", "Linux" ]
https://linux.cn/article-14019-1.html
> > 亚马逊已经发布了 Amazon Linux 2022 的公开预览版,并有了新的发布模式。 > > > ![](/data/attachment/album/202111/25/142143j9xw8dtrty09ox30.png) 如果你还不知道,亚马逊有自己的通用 Linux 发行版,自然而然,它被称为 Amazon Linux。 它的目的是在 AWS 服务器上使用。当你部署服务器时,你可以选择使用 Amazon Linux,或其他流行的选择,如 Ubuntu、Debian 等。由于它来自亚马逊,所以没有许可费,而且亚马逊对软件库和软件包进行控制。你可以期待它与 AWS 工具紧密结合,并通过它获得新的 AWS 创新。 Amazon Linux 2022(AL2022)是其版本 1 和 2 之后的下一个版本,它将在 2022 年发布(你可以从版本号上猜到)。 ### 即将发布的 Amazon Linux 2022 只基于 Fedora 到目前为止,Amazon Linux 的发布是基于红帽 Linux 和 Fedora 两者的组合。从 AL2022 开始,它将明确使用 Fedora 作为上游。 此举意在为 AWS 客户“提供各种最新软件,如更新的语言运行时,作为季度发布的一部分”。 为了提高安全性,减少攻击面,AL2022 还将启用 [SELinux](https://linuxhandbook.com/selinux/) 并默认执行。 ### 与 Ubuntu 相似的新发布模式 Amazon Linux 还选择了一个更可预测的发布时间表。每两年将发布一个新的 Amazon Linux 主要版本,并将支持五年。这样,用户就会知道何时以及如何升级他们的操作系统。 这种“每两年一个新的 LTS 版本和 5 年的支持”与 Ubuntu 如今的特点非常相似。 ### 还有什么? AL2022 也能锁定到亚马逊 Linux 软件包库的特定版本。这使得用户可以控制如何以及何时吸收更新。 Amazon Linux 2022 在所有的地理区域都可以作为预览版(即 beta 版)体验。你可以访问他们的 GitHub 页面了解更多关于 AL2022 的信息。 --- via: <https://news.itsfoss.com/amazon-linux-2022-preview/> 作者:[Abhishek](https://news.itsfoss.com/author/root/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) In case you did not know already, Amazon has its own general purpose Linux distribution, unsurprisingly called Amazon Linux. It is intended to be used on AWS servers. When you are deploying a server, you have the choice to use Amazon Linux along with other popular choices of Ubuntu, Debian etc. Since it is from Amazon, there is no licensing fee and Amazon controls on repositories and packages. You can expect a tight integration with AWS tools and access to new AWS innovations with Amazon Linux. Amazon Linux 2022 (AL2022) in the next release in the line of Amazon Linux 1 and 2 and it will be released in 2022 (you can guess that from the version number). ## Upcoming Amazon Linux 2022 uses only Fedora Until now, Amazon Linux releases were based on a combination of Red Hat and Fedora both. Starting with AL2022, it will be explicitly using Fedora as upstream. The move intends to provide the AWS customers “with a wide variety of the latest software, such as updated language runtimes, as part of quarterly releases”. In order to improve the security, reduce attack surface, AL2022 will also have [SELinux](https://linuxhandbook.com/selinux/?ref=news.itsfoss.com) enabled and enforced by default. ## New release model similar to Ubuntu Amazon Linux is also opting for a more predictable release schedule. A new major Amazon Linux version will be released every two years and will be supported for five years. This way users would know when and how to upgrade their operating system. This “new LTS version every 2 years and 5 years support” is very similar to what Ubuntu features today. ## What else? AL2022 also has the ability to lock to a specific version of the Amazon Linux package repository. This gives the user control over how and when they absorb updates. Amazon Linux 2022 is available as preview (read beta) in all geographical regions. You can visit their GitHub page for more information on AL2022. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,021
使用 cowsay 命令的 3 种有趣方式
https://opensource.com/article/21/11/linux-cowsay-command
2021-11-25T23:25:02
[ "cowsay" ]
https://linux.cn/article-14021-1.html
> > 想试一个只是好玩的应用吗?试试 cowsay。 > > > ![](/data/attachment/album/202111/25/232451f6v8fnne2np8e22e.jpg "Cow on parade.") 大多数时候,终端是一个生产力的动力源。但是,终端的作用不止是命令和配置。在所有杰出的开源软件中,有些是 [为了好玩而写的](https://opensource.com/life/16/6/fun-and-semi-useless-toys-linux)。我以前介绍过一些 [有趣的命令](https://opensource.com/article/21/11/fun-linux-commands),但这篇文章只讲一个:古老的 `cowsay` 命令。 `cowsay` 是一只可配置的会说话(或思考)的牛。它接受一个文本字符串,并输出一个牛说话的图形。下面是一头牛在说它喜欢 Linux: ``` < I love Linux > -------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || ``` 要得到这个结果,我只需输入: ``` $ cowsay "I love Linux" ``` ### 在 Linux 上安装 cowsay 你可以用你的包管理器安装 `cowsay`。在 Debian、Mint、Elementary 和类似的发行版上: ``` $ sudo apt install cowsay ``` 在 Fedora 上: ``` $ sudo apt install cowsay-beefymiracle ``` ### Cowsay 命令选项 `cowsay` 是一个简单又有点傻的应用。除了为你的终端机提供一些不同样式外,它并没有什么实际用途。例如,与其让一头普通的牛说一个有趣短语,你可以让一头长着古怪眼睛的牛说一个有趣的短语。输入: ``` $ cowsay -e @@ Hello ``` 你会看到: ``` < Hello > ------- \ ^__^ \ (@@)\_______ (__)\ )\/\ ||----w | || || ``` 或者你可以让它伸出舌头。输入: ``` $ cowsay -T U Hello ``` 你会看到: ``` < Hello > ------- \ ^__^ \ (oo)\_______ (__)\ )\/\ U ||----w | || || ``` 更好的是,你可以将 `fortune` 命令与 `cowsay` 结合起来: ``` $ fortune | cowsay ``` 现在你有了一头特别睿智的牛: ``` _______________________________________ / we: \ | | | The single most important word in the | \ world. / --------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || ``` ### “结实的奇迹” 在 Fedora 上,有一个额外的 `cowsay` 选项,也是一个非官方的项目吉祥物。多年来,Fedora 安装程序一直在展示宣传开源贡献的幻灯片。因为它们是根据汽车电影院的插曲设计的,所以幻灯片中常见的卡通人物是拟人化的热狗。 为了与这个主题保持一致,你可以用 Fedora 版本的 `cowsay` 调用一个所谓的“<ruby> 结实的奇迹 <rt> beefy miracle </rt></ruby>”。(LCTT 译注:Fedora 17 的开发代号。) ``` $ cowsay -f beefymiracle Hello Fedora ``` 你会得到一个非常傻的输出: ``` < Hello Fedora > -------------- .---. __ , \ / \ \ |||| \\\\ |O___O | | \\|||| \ // | \_/ | | \ / '--/----/| / | |-' // // / -----' // \\ / / // // / / // \\ / / // // / / /| ' / / //\___/ / // ||\ / \\_ || '---' /' / \\_.- / / --| | '-' | | '-' ``` ### 图形化的 cowsay 如果你发现自己需要用图形化的牛来传递信息,可以使用 `xcowsay` 命令。这是一个类似于 `cowsay` 的图形程序,它接受一个由用户输入的文本字符串,或从另一个应用(如 Fortune)输送过来的文本字符串。 ![A cartoon cow has a speech bubble that reads "I love Linux"](/data/attachment/album/202111/25/232504dx3txxf473gssvcf.png "graphical cowsay") ### 有趣的 Linux 命令 虽然 `cowsay` 不是一个有用的命令,但它是一个有趣的命令,相当于你终端的桌面小工具。它很适合用来分散注意力和进行有趣的管道命令实验(尝试将 `ifconfig` 管道到 `cowsay`,或 `lsblk` 或 `mount`,或任何东西!)。如果你想让你的终端更有趣,试试 `cowsay`。 --- via: <https://opensource.com/article/21/11/linux-cowsay-command> 作者:[Don Watkins](https://opensource.com/users/don-watkins) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Most of the time, a terminal is a productivity powerhouse. But there's more to the terminal than commands and configurations. Among all the outstanding open source software out there, some of it has been [written just for fun](https://opensource.com/life/16/6/fun-and-semi-useless-toys-linux). I've written about [fun commands](https://opensource.com/article/21/11/fun-linux-commands) before, but this article is about just one: the venerable `cowsay` command. Cowsay is a configurable talking (or thinking) cow. It accepts a text string and outputs a graphic of a cow talking. Here's a cow saying it loves Linux: ``` < I love Linux > -------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || ``` To get that result, all I have to type is: `$ cowsay "I love Linux"` ## Install cowsay on Linux You can install cowsay with your package manager. On Debian, Mint, Elementary, and similar distributions: `$ sudo apt install cowsay` On Fedora: `$ sudo apt install cowsay-beefymiracle` ## Cowsay command options Cowsay is a simple and silly application. There's no actual use for it except to provide some diverting styling for your terminal. For instance, rather than just making a cow say a fun phrase, you can make a cow with wonky eyes say a fun phrase. Type: `$ cowsay -e @@ Hello` You'll get: ``` < Hello > ------- \ ^__^ \ (@@)\_______ (__)\ )\/\ ||----w | || || ``` Or you can make it stick out its tongue. Type: `$ cowsay -T U Hello` You'll see: ``` < Hello > ------- \ ^__^ \ (oo)\_______ (__)\ )\/\ U ||----w | || || ``` Better still, you can combine the `fortune` command with `cowsay` : `$ fortune | cowsay` Now you'll have an especially smart cow: ``` _______________________________________ / we: \ | | | The single most important word in the | \ world. / --------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || ``` ## Beefy miracle On Fedora, there's an extra option for cowsay that's also an unofficial project mascot. For years, the Fedora installer has displayed slides promoting open source contributions. Because they were styled after the interludes at drive-in movie theaters, a common cartoon character in the slides is an anthropomorphic hot dog. In keeping with that theme, you can invoke a so-called beefy miracle with the Fedora version of cowsay: `$ cowsay -f beefymiracle Hello Fedora` You'll end up with a perfectly silly result: ``` < Hello Fedora > -------------- .---. __ , \ / \ \ |||| \\\\ |O___O | | \\|||| \ // | \_/ | | \ / '--/----/| / | |-' // // / -----' // \\ / / // // / / // \\ / / // // / / /| ' / / //\___/ / // ||\ / \\_ || '---' /' / \\_.- / / --| | '-' | | '-' ``` ## Graphical cowsay If you find yourself needing to have messages delivered to you from a graphical cow, there's the `xcowsay` command. It's a graphical program similar to cowsay, and it accepts a text string that's entered by the user or piped from another application like Fortune. ![graphical cowsay A cartoon cow has a speech bubble that reads "I love Linux"](https://opensource.com/sites/default/files/uploads/graphical_cowsay.png) Don Watkins, CC BY-SA 4.0 ## Fun Linux commands While `cowsay` is not a useful command, it is a fun command—the equivalent of desktop widgets for your terminal. It's great for a momentary distraction and fun experiments with piping commands (try piping `ifconfig` to cowsay, or `lsblk` , or `mount` , or anything!). If you want to make your terminal more fun, try cowsay. ## Comments are closed.
14,022
不使用安装程序安装 FreeDOS
https://opensource.com/article/21/6/install-freedos-without-installer
2021-11-25T23:56:52
[ "FreeDOS" ]
https://linux.cn/article-14022-1.html
> > 这里是如何在不使用安装程序的情况下来手动设置你的 FreeDOS 系统。 > > > ![](/data/attachment/album/202111/25/235643wvmciyy2f8y3mi73.jpg "FreeDOS fish logo and command prompt on computer") 大多数的人应该能够使用安装程序来非常容易地安装 FreeDOS 1.3 RC4 。FreeDOS 安装程序会先询问几个问题,然后处理剩余的工作,包括为 FreeDOS 制作安装空间和使系统可启动。 但是,如果安装程序不适合你怎么办?或者,你更喜欢 *手动* 设置你的 FreeDOS 系统,而不喜欢使用安装程序怎么办?使用 FreeDOS ,你也可以做到这些!让我们在不使用安装程序的情况下逐步走完安装 FreeDOS 的步骤。我将使用 QEMU 虚拟机的一个空白的硬盘驱动器镜像来完成所有的步骤。我使用这个 Linux 命令来创建了一个 100 MB 的硬盘驱动器镜像: ``` $ qemu-img create freedos.img 100M ``` 我下载了 FreeDOS 1.3 RC4 的 LiveCD ,并将其命名为 `FD13LIVE.iso` ,它提供了一个 “身临其境” 的环境,我可以在其中运行 FreeDOS ,包括所有的标准工具。大多数用户也使用 LiveCD 自带的常规安装程序来安装 FreeDOS 。但是,在这里我将仅使用 LiveCD ,并从其命令行中使用某些类型的命令来安装 FreeDOS 。 我使用这个相当长的 QEMU 命令来启动虚拟机,并选择 “Use FreeDOS 1.3 in Live Environment mode” 启动菜单项: ``` $ qemu-system-x86_64 -name FreeDOS -machine pc-i440fx-4.2,accel=kvm,usb=off,dump-guest-core=off -enable-kvm -cpu host -m 8 -overcommit mem-lock=off -no-user-config -nodefaults -rtc base=utc,driftfix=slew -no-hpet -boot menu=on,strict=on -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on -hda freedos.img -cdrom FD13LIVE.iso -device sb16 -device adlib -soundhw pcspk -vga cirrus -display sdl -usbdevice mouse ``` ![manual install](/data/attachment/album/202111/25/235654a06h0ihi1pl4p011.png "Select \"Use FreeDOS 1.3 in Live Environment mode\" to boot the LiveCD") *选择 "Use FreeDOS 1.3 in Live Environment mode" 来启动 LiveCD(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 这个 QEMU 命令行包含大量的选项,乍看可能会让你迷糊。因为你完全使用命令行选项配置 QEMU ,所以在这里有很多东西需要审查。但是,我将简单地重点说明几个重要的选项: * `-m 8`:设置系统存储器(RAM)为 8 MB * `-boot menu=on,strict=on`:使用一个启动菜单,这样,我可以选择从 CD-ROM 镜像或硬盘驱动器镜像启动 * `-hda freedos.img`:使用 `freedos.img` 作为硬盘驱动器镜像 * `-cdrom FD13LIVE.iso`:使用 `FD13LIVE.iso` 作为 CD-ROM 镜像 * `-device sb16 -device adlib -soundhw pcspk`:定义计算机带有一个 SoundBlaster16 声卡、AdLib 数字音乐卡、PC 扬声器模拟器(如果你想玩 DOS 游戏的话,这些模拟器很有用) * `-usbdevice mouse`:将用户的鼠标识别为一个 USB 鼠标(在 QEMU 窗口中单击以使用鼠标) ### 对硬盘驱动器进行分区 你可以从 LiveCD 使用 FreeDOS 1.3 RC4 ,但是,如果你想安装 FreeDOS 到你的计算机中,你需要先在硬盘驱动器上制作安装空间。这需要使用 FDISK 程序来创建一个 *分区* 。 从 DOS 命令行中,输入 `FDISK` 来运行 *分区* 设置程序。FDISK 是一个全屏交互式程序,你只需要输入数字来选择菜单项。从 FDISK 的主菜单中,输入 `1` 来在驱动器上创建一个 DOS 分区,然后在接下来的屏幕上输入 `1` 来创建一个 “主” DOS 分区。 ![using fdisk](/data/attachment/album/202111/25/235654dmpy9nrembmnrrun.png "Select \"1\" to create a partition") *选择 `1` 来创建一个分区(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* ![using fdisk](/data/attachment/album/202111/25/235654rj0bgbwvr8xbk7rw.png "Select \"1\" on the next menu to make a primary partition") *在接下来的菜单上选择 `1` 来制作一个主分区(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* `FDISK` 会询问你是否想要使用全部的硬盘空间大小来创建分区。除非你需要在这个硬盘驱动器上和另外一个操作系统(例如 Linux)共享硬盘空间,否则,对于这个提示,你应该回答 `Y` 。 在 `FDISK` 创建新的分区后,在 DOS 能够识别新的分区信息前,你将需要重新启动 DOS 。像所有的 DOS 操作系统一样,FreeDOS 仅在其启动时识别硬盘驱动器信息。因此,如果你创建或删除任何的磁盘分区的话,你都将需要重新启动 FreeDOS ,只有这样做,FreeDOS 才能识别到更改的分区信息。`FDISK` 会提醒你重新启动,因此,你是不会忘记的。 ![using fdisk](/data/attachment/album/202111/25/235655q84x4zawri0uiw8r.png "You need to reboot to recognize the new partition") *你需要重新启动以识别新的分区(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 你可以通过停止或重新启动 QEMU 虚拟机来重新启动 FreeDOS,但是我更喜欢在 FreeDOS 命令行中使用 FreeDOS 的高级电源管理(`FDADPM`)工具来重新启动 FreeDOS 。为了重新启动,输入命令 `FDADPM /WARMBOOT` ,FreeDOS 将自动重新启动。 ### 对硬盘驱动器进行格式化 在 FreeDOS 重新启动后,你可以继续设置硬盘驱动器。创建磁盘分区是这个过程的“第一步”;现在你需要在分区上创建一个 DOS *文件系统* ,以便 FreeDOS 可以使用它。 DOS 系统使用字母 `A` 到 `Z` 来识别“驱动器”。FreeDOS 将识别第一个硬盘驱动器的第一个分区为 `C` 驱动器,依此论推。你经常使用字母和一个冒号(`:`)来表示驱动器,因此我们在上面创建的新分区实际上是 `C:` 驱动器。 你可以在新的分区上使用 `FORMAT` 命令来创建一个 DOS 文件系统。这个命令带有一些选项,但是,我们将仅使用 `/S` 选项来告诉 `FORMAT` 来使新的文件系统可启动: `S` 意味着安装 FreeDOS “系统” 文件。输入 `FORMAT /S C:` 来在 `C:` 驱动器上制作一个新的 DOS 文件系统。 ![formatting the disk](/data/attachment/album/202111/25/235655sxvjmbccmg3c3mss.png "Format the partition to create the DOS filesystem") *格式化分区来创建 DOS 文件系统(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 使用 `/S` 选项,`FORMAT` 将运行 `SYS` 程序来传输系统文件。你将看到这是从 `FORMAT` 输出的一部分: ![formatting the disk](/data/attachment/album/202111/25/235655x4ylu4yuzu37pm4e.png "FORMAT /S will use SYS to make the disk bootable") *`FORMAT /S` 将使用 SYS 来使磁盘可启动(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* ### 安装软件 在使用 `FDISK` 创建了一个新的分区,并使用 `FORMAT` 创建了一个新的文件系统后, 新的 `C:` 驱动器基本上是空的。此时,`C:` 驱动器仅包含一份内核和 `COMMAND.COM` 命令行 shell 的副本。为使新的磁盘可以执行一些有用的操作,我们需要在其上安装软件。这是手动安装过程的最后步骤。 FreeDOS 1.3 RC4 LiveCD 包含所有的你可能希望在新的系统上所要安装的软件。每个 FreeDOS 程序都是一个单独的 “软件包” ,它实际上只是一个 Zip 档案文件。建立标准 DOS 环境的软件包存储在 LiveCD 上 `PACKAGES` 目录下的 `BASE` 目录之中。 你可以一次一个的将其中的每一个软件包都 “解压缩” 到硬盘驱动器来完成安装。在 `Base` 组中有 62 个单独的软件包,如果每次安装一个软件包,这可能会花费非常多的时间。不过,你可以运行一个只有一行的 `FOR` “循环” 命令来 `UNZIP` 每个程序。接下来 FreeDOS 可以为你 “解压缩” 所有的软件包。 `FOR` 循环的基本用法中提及的一个单个字母变量(让我们使用 `%F`),稍后,FreeDOS 将使用该字母变量来 “填充” 文件名称。`FOR` 还需要括号中的一个文件列表,这个命令会对每个文件都运行一次。用来解压一系列的 Zip 文件的语法看起来像这样: ``` FOR %F IN (*.ZIP) DO UNZIP %F ``` 这将提取所有的 Zip 文件到当前目录之中。为提取或 `UNZIP` 文件到一个不同的位置,在 `UNZIP` 命令行结尾处使用 `-d` (“目的地”) 选项。对于大多数的 FreeDOS 系统来说,你应该安装软件包到 `C:\FDOS` 目录中: ![installing the software](/data/attachment/album/202111/25/235656tu8yewenxfr52qnk.png "Unzip all of the Base packages to finish installing FreeDOS") *解压缩所有的基本软件包来完成安装 FreeDOS(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* FreeDOS 会处理剩余的工作,安装所有的 62 个软件包到你的系统之中。这可能会花费几分钟的时间,因为 DOS 在处理很多单个的文件时会很慢,这个命令需要提取 62 个 Zip 文件。如果我们使用单个的 `BASE.ZIP` 档案文件的话,安装过程可能会运行地更快,但是使用软件包的话,在你选择想要安装或不安装软件包时会提供更多的灵活性。 ![installing the software](/data/attachment/album/202111/25/235656hprgxww8tui7ib8i.png "After installing all the Base packages") *在安装所有的基本软件包后(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 在我们安装完所有的东西后,使用 `FDADPM /WARMBOOT` 来重新启动你的系统。手动安装意味着你的新 FreeDOS 系统没有常见的 `FDCONFIG.SYS` 配置文件,因此,当 FreeDOS 在启动时,它将假设一些典型的默认值。因为没有 `AUTOXEC.BAT` 文件,FreeDOS 也会提示你时间和日期。 ![rebooting FreeDOS](/data/attachment/album/202111/25/235656b5dv4vah1ni77vin.png "Rebooting FreeDOS after a manual install") *在手动安装后,重新启动 FreeDOS(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 大多数的用户应该能够使用比较用户友好的过程来在一台新的计算机上安装 FreeDOS 。但是如果你想自己使用“古老的”方法来安装它,那么你可以手动运行安装步骤。这会提供一些额外的灵活性和控制权,因为是你自己安装的一切。现在你知道如何安装它了。 --- via: <https://opensource.com/article/21/6/install-freedos-without-installer> 作者:[Jim Hall](https://opensource.com/users/jim-hall) 选题:[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/) 荣誉推出
200
OK
Most people should be able to install FreeDOS 1.3 RC4 very easily using the installer. The FreeDOS installer asks a few questions, then takes care of the rest—including making space for FreeDOS and making the system bootable. But what if the installer doesn't work for you? Or what if you prefer to set up your FreeDOS system *manually*, without using the installer? With FreeDOS, you can do that too! Let's walk through the steps to install FreeDOS without using the installer. I'll do all of these steps using the QEMU virtual machine, using a blank hard drive image. I created a one hundred megabyte ("100M") hard drive image with this Linux command: ``` ````$ qemu-img create freedos.img 100M` I downloaded the FreeDOS 1.3 RC4 installation LiveCD as FD13LIVE.iso, which provides a "live" environment where I can run FreeDOS, including all the standard tools. Most users also use the LiveCD to install FreeDOS with the regular installer, but here I'll only use the LiveCD to install FreeDOS using individual commands from the command line. I started the virtual machine with this rather long QEMU command, and selected the "Use FreeDOS 1.3 in Live Environment mode" boot menu entry: ``` ````$ qemu-system-x86_64 -name FreeDOS -machine pc-i440fx-4.2,accel=kvm,usb=off,dump-guest-core=off -enable-kvm -cpu host -m 8 -overcommit mem-lock=off -no-user-config -nodefaults -rtc base=utc,driftfix=slew -no-hpet -boot menu=on,strict=on -sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny -msg timestamp=on -hda freedos.img -cdrom FD13LIVE.iso -device sb16 -device adlib -soundhw pcspk -vga cirrus -display sdl -usbdevice mouse` ![Select "Use FreeDOS 1.3 in Live Environment mode" to boot the LiveCD manual install](https://opensource.com/sites/default/files/uploads/manual-install3.png) Select "Use FreeDOS 1.3 in Live Environment mode" to boot the LiveCD (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) That QEMU command line includes a bunch of options that may seem confusing at first. You configure QEMU entirely with command-line options, so there is a lot to examine here. But I'll briefly highlight a few important options: Set the system memory ("RAM") to 8 megabytes**-m 8**:Use a boot menu, so I can select if I want to boot from the CD-ROM image or the hard drive image`-boot menu=on,strict=on:` Use`-hda freedos.img` :**freedos.img**as the hard drive image Use**-cdrom FD13LIVE.iso:****FD13LIVE.iso**as the CD-ROM imageDefine the machine with a SoundBlaster16 sound card, AdLib digitial music card, and PC speaker emulation (these are useful if you want to play DOS games)`-device sb16 -device adlib -soundhw pcspk` :Recognize the user's mouse as a USB mouse (click in the QEMU window to use the mouse)`-usbdevice mouse` : ## Partition the hard drive You can use FreeDOS 1.3 RC4 from the LiveCD, but if you want to install FreeDOS to your computer, you'll first need to make space on the hard drive. This requires creating a *partition* with the FDISK program. From the DOS command line, type `FDISK` to run the *fixed disk* setup program. FDISK is a full-screen interactive program, and you only need to type a number to select a menu item. From the main FDISK menu, enter "1" to create a DOS partition on the drive, then enter "1" on the next screen to create a *primary* DOS partition. ![Select "1" to create a partition using fdisk](https://opensource.com/sites/default/files/uploads/manual-install6.png) Select "1" to create a partition (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) ![Select "1" on the next menu to make a primary partition using fdisk](https://opensource.com/sites/default/files/uploads/manual-install7.png) Select "1" on the next menu to make a primary partition (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) FDISK asks you if you wish to use the full size of the hard disk to create the partition. Unless you need to share space on this hard drive with another operating system, such as Linux, you should answer "Y" to this prompt. After FDISK creates the new partition, you'll need to reboot before DOS can recognize the new partition information. Like all DOS operating systems, FreeDOS identifies the hard drive information only when it boots up. So if you create or delete any disk partitions, you'll need to reboot so FreeDOS recognizes the changed partition information. FDISK reminds you to reboot, so you don't forget. ![You need to reboot to recognize the new partition using fdisk](https://opensource.com/sites/default/files/uploads/manual-install10.png) You need to reboot to recognize the new partition (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) You can reboot by stopping and restarting the QEMU virtual machine, but I prefer to reboot FreeDOS from the FreeDOS command line, using the FreeDOS Advanced Power Management (FDAPM) tool. To reboot, type the command `FDAPM /WARMBOOT` and FreeDOS reboots itself. ## Formatting the hard drive After FreeDOS restarts, you can continue setting up the hard drive. Creating the disk partition was "step 1" in this process; now you need to make a DOS *filesystem* on the partition so FreeDOS can use it. DOS systems identify "drives" using the letters `A` through `Z` . FreeDOS recognizes the first partition on the first hard drive as the `C` drive, and so on. You often indicate the drive with the letter and a colon (`:` ) so the new partition we created above is actually the `C:` drive. You can create a DOS filesystem on the new partition with the FORMAT command. This command takes a few options, but we'll only use the `/S` option to tell FORMAT to make the new filesystem bootable—the "S" means to install the FreeDOS "System" files. Type `FORMAT /S C:` to make a new DOS filesystem on the `C:` drive. ![Format the partition to create the DOS filesystem formatting the disk](https://opensource.com/sites/default/files/uploads/manual-install13.png) Format the partition to create the DOS filesystem (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) With the `/S` option, FORMAT will run the SYS program to transfer the system files. You'll see this as part of the output from FORMAT: ![FORMAT /S will use SYS to make the disk bootable formatting the disk](https://opensource.com/sites/default/files/uploads/manual-install14.png) FORMAT /S will use SYS to make the disk bootable (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) ## Installing software Having created a new partition with FDISK and a new filesystem with FORMAT, the new `C:` drive is basically empty. At this point, the `C:` drive only contains a copy of the kernel and the `COMMAND.COM` command-line shell. To do anything useful with the new disk, we need to install software on it. This is the last step for the manual install process. The FreeDOS 1.3 RC4 LiveCD contains all of the software you might want to install on the new system. Each FreeDOS program is available as a separate "package," which is really just a Zip archive file. The packages that set up the standard DOS environment are stored in the `BASE` directory, under the `PACKAGES` directory on the LiveCD. You could install the packages by "unzipping" each of them to the hard drive, one at a time. With 62 individual packages in the "Base" group, installing each package individually would take a very long time. However, you can run a one-line `FOR` "loop" command to "unzip" each program. Then FreeDOS can "unzip" all of the packages for you. The basic usage of the `FOR` loop indicates a single-letter variable (let's use `%F` ) that FreeDOS uses to "fill in" the filename later. The `FOR` also requires a list of files in brackets and the command that it should run against each of the files. The syntax to unzip a list of Zip files looks like this: ``` ````FOR %F IN (*.ZIP) DO UNZIP %F` This extracts all of the Zip files into the current directory. To extract or "unzip" the files into a different location, use the `-d` ("destination") option at the end of the `UNZIP` command line. For most FreeDOS systems, you will want to install the software packages to the `C:\FDOS` directory: ![Unzip all of the Base packages to finish installing FreeDOS installing the software](https://opensource.com/sites/default/files/uploads/manual-install18.png) Unzip all of the Base packages to finish installing FreeDOS (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) FreeDOS takes care of the rest, installing all 62 packages to your system. This may take several minutes because DOS can be slow when working with lots of individual files—and this command needs to extract 62 Zip files. The installation process would run a lot faster if we used a single `BASE.ZIP` archive file, but using packages provides more flexibility in what software you might want to install versus what you choose to leave out. ![After installing all the Base packages installing the software](https://opensource.com/sites/default/files/uploads/manual-install24.png) After installing all the Base packages (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) After you've installed everything, reboot your system with `FDADPM /WARMBOOT` . Installing manually means your new FreeDOS system won't have the usual `FDCONFIG.SYS` configuration file, so FreeDOS will assume a few typical default values when it starts up. Without the `AUTOXEC.BAT` file, FreeDOS also prompts you for the time and date. ![Rebooting FreeDOS after a manual install rebooting FreeDOS](https://opensource.com/sites/default/files/uploads/manual-install28.png) Rebooting FreeDOS after a manual install (Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) Most users should be able to use the more user-friendly process to install FreeDOS on a new computer. But if you want to install it yourself the "old school" way, you can also run the installation steps manually. This can provide some additional flexibility and control because you install everything yourself. And now you know how to do it. ## Comments are closed.
14,024
没有终点的操作系统 Endless OS 发布 4.0 LTS
https://news.itsfoss.com/endless-os-4-0-lts/
2021-11-27T09:22:57
[ "EndlessOS" ]
https://linux.cn/article-14024-1.html
> > Endless OS 4.0 是一个长期支持版本,带有大量必要的改进,默认的应用程序以 Flatpak 包的形式提供。 > > > ![](/data/attachment/album/202111/27/092257ly9y9pg2u94pr8g8.jpg) Endless OS 是一个基于 Debian 的 Linux 发行版,重点捆绑提供几个重要的应用程序和资源,以帮助充分利用你的计算机,而不需要互联网连接。(LCTT 译注:因此,在互联网的“终点”之外也可使用。) 它主要是为教育和不能经常访问互联网的用户定制的。而如果你连接到互联网,也有一些工具可以帮助你浏览网页并与朋友/家人保持联系。 他们最新发布的 Endless OS 4.0 是一个长期支持的版本,带有一些改进。让我们简单了解一下。 ### Endless OS 4.0 的新内容 澄清一下,这是一个 LTS 版本,将被维护若干年(具体不清楚),即使是在 Endless OS 5.0 版本发布之后,它也会得到更新。 除了 LTS 的好处之外,其他变化还包括: #### 改进的应用程序网格导航 ![来源:Endlessos.org](/data/attachment/album/202111/27/092259xyyxkqzwy3zcv7yg.png) 在以前的版本中,列出的应用程序散落在多个页面之间。由于这个原因,用户可能不会注意到它们。 因此,在 Endless OS 4.0 中,增加了额外的箭头和图标,以突出多页面和应用程序网格的存在。你应该看到,如果你在桌面上切换页面,可以探索到更多的应用程序。 #### 快速切换用户 在一个用户已经登录时,你现在有两种不同的方式来快速切换到另一个用户。 ![来源:Endlessos.org](/data/attachment/album/202111/27/092300s5g55bv2v7n7d7vh.png) 传统上,你可以在用户菜单中找到它(和注销选项一起)。或者,你也可以使用新的多用户图标从锁屏上直接切换。 ![来源:Endlessos.org](/data/attachment/album/202111/27/092301xfjjgffjhgxkfhrp.png) #### 新的默认墙纸 每当有重大的版本升级时,新的墙纸总是让人耳目一新。 如果你想在任何其他系统中尝试它们,你可以在 [Unsplash](https://unsplash.com/photos/WeYamle9fDM) 上找到列出的这些壁纸。 #### 免驱动打印 你不再需要依靠讨厌的打印机驱动程序来检测连接的打印设备。有了 Endless OS 4.0,任何在本地网络中支持 [互联网打印协议](https://en.wikipedia.org/wiki/Internet_Printing_Protocol)(IPP)的设备都可以自动检测并连接。 当你升级时,会删除任何已配置的打印机。然而,如果需要的话,你可以手动将它们添加回来。 ### 其他改进措施 除了基本的变化之外,你还会发现更新的图形驱动、升级的 Linux 内核等等。其中一些包括: * [Linux 内核 5.11](https://news.itsfoss.com/linux-kernel-5-11-release/) * NVIDIA 驱动程序 460.91.03 * 支持 8GB 版树莓派 4B * 一些默认的应用程序,如 Rythmbox,以 Flatpak 软件包的方式安装 你还会注意到,作为升级的一部分,移除了一些功能。关于全部细节,你可以参考 [官方发布说明](https://support.endlessos.org/en/endless-os/release-notes/4-0)。 --- via: <https://news.itsfoss.com/endless-os-4-0-lts/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Endless OS is a Debian-based Linux distro that focuses on bundling several important applications and resources to help make the most out of your computer without needing an internet connection. It is primarily tailored for education and for users who do not have constant access to the internet. And, if you are connected to the internet, there are tools to help you browse the web and stay in touch with friends/family. And, their latest release, Endless OS 4.0, is a Long-Term Support version that comes with several improvements. Let us take a brief look at it. ## Endless OS 4.0: What’s New? To clarify, it is an LTS release that will be maintained for a number of years (no clarity exactly), but it will be getting updates even after the Endless OS 5.0 release. In addition to the LTS benefit, other changes include: ### Improved App Grid Navigation ![](https://news.itsfoss.com/content/images/wordpress/2021/11/endless-os-4-app-grid-1024x579.png) In previous releases, the applications listed were scattered around between multiple pages. For that reason, a user could not always notice that. So, with Endless OS 4.0, additional arrows and icons have been added to highlight the presence of multiple pages and app grids. You should see that there are more apps to explore if you switch pages on your desktop. ### Fast User Switching You now get two different ways to quickly switch to another user while a user is logged in. ![](https://news.itsfoss.com/content/images/wordpress/2021/11/release-notes-4.0-switch-user-menu.png) Traditionally, you can find it in the user menu (along with the Log Out option). Or, you can also switch right from the lock screen using the new multi-user icon. ![](https://news.itsfoss.com/content/images/wordpress/2021/11/release-notes-4.0-switch-user-lock-screen.png) ### New Default Wallpaper It is always a refreshing experience when there is a new wallpaper with a significant version upgrade. You can find the wallpaper listed on [Unsplash](https://unsplash.com/photos/WeYamle9fDM?ref=news.itsfoss.com) if you want to try it in any other system. ### Driverless Printing You no longer need to rely on pesky printer drivers to detect the printing devices connected. With Endless OS 4.0, any devices that support [Internet Printing Protocol](https://en.wikipedia.org/wiki/Internet_Printing_Protocol?ref=news.itsfoss.com) will be automatically detected in the local network and connected. Any existing configured printers will be removed when you upgrade. However, you can manually add them back if needed. ## Other Improvements Along with the fundamental changes, you will also find a newer graphics stack, upgraded Linux Kernel, and more. Some of them include: [Linux Kernel 5.11](https://news.itsfoss.com/linux-kernel-5-11-release/)- NVIDIA driver 460.91.03 - Raspberry Pi 4B 8 GB RAM Support - Some default applications like Rythmbox installed as Flatpak packages You will also notice some features being removed as a part of the upgrade. For full details, you can refer to the [official release notes](https://support.endlessos.org/en/endless-os/release-notes/4-0?ref=news.itsfoss.com). ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,025
如何在 Fedora Linux 上安装 Discord
https://itsfoss.com/install-discord-fedora/
2021-11-27T11:55:09
[ "Discord" ]
https://linux.cn/article-14025-1.html
![](/data/attachment/album/202111/27/115501g3oiuirvzk4nvu3k.jpg) [Discord](https://discord.com/) 是一个流行的消息收发应用,可用于文字和语音信息传递。 它是一些社区的福音,可以帮助他们扩大项目,接触更多的人,并维持一个粉丝和关注者的社区。而 Discord 最初是为游戏玩家设计的,这很令人惊讶。 Discord 可用于各种平台,包括 Linux。在本教程中,我将引导你完成在 Fedora 中安装 Discord 的步骤。 * 使用 DNF 和 RPM Fusion 仓库安装 Discord * 通过 Flatpak 安装Discord Flatpak 软件包是沙盒的,因此需要更多的磁盘空间和时间来启动。然而,他们会相当快地更新到新的版本。 无论你想使用 Flatpak 还是 DNF,选择权在你手上。我将向你展示这两种方法。 > > 非 FOSS 警报! > > > Discord 并不是开源的。但由于他们提供了一个 Linux 客户端,而且许多 Linux 用户都依赖它,所以我们会在这里介绍它。 > > > ### 方法 1:通过 RPM Fusion 仓库安装 Discord Discord 可以通过添加非自由的 RPM Fusion 仓库来安装,这是大多数 Fedora 用户的首选方法,因为更新很容易,而且应用的启动速度比 Flatpak 版本快。 打开终端,使用下面的命令来添加 RPM-fusion 非自由仓库: ``` sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm ``` 完成后,更新仓库列表(应该不需要,但只是为了它): ``` sudo dnf update ``` 然后通过 `dnf` 命令安装 Discord,像这样: ``` sudo dnf install discord ``` ![Installing Discord using DNF](/data/attachment/album/202111/27/115509j7lklake7bavrlwh.png) 如果被要求导入 GPG 密钥,只要按 `Y` 就可以授权了。 ![Authorize GPG key](/data/attachment/album/202111/27/115509jaj23hvw2vwkhnal.png) 这就完成了!现在你可以从应用菜单中启动 Discord。你的登录页面将看起来像这样: ![Launch Discord application](/data/attachment/album/202111/27/115510g5pux8putqvsplww.png) #### 通过 DNF 删除 Discord 如果你不想再使用 Discord,你可以从你的系统中删除它。要做到这一点,在终端运行以下命令: ``` sudo dnf remove discord ``` 这真的很简单,不是吗?还有一种简单的安装 Discord 的方法,那就是使用 Flatpak 软件包。 ### 方法 2:通过 Flatpak 安装 Discord Discord 可以使用 Flatpak 轻松安装,因为它在 Fedora 中是默认可用的。 首先,你需要在 Fedora 中启用 Flatpak 仓库: ``` flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo ``` 接下来,通过这个命令安装 Discord: ``` flatpak install discord ``` ![Install Discord via Flatpak](/data/attachment/album/202111/27/115510i00o2c35zcqh2hea.png) 如果你想删除 Discord,那么只需运行: ``` flatpak remove discord ``` 这就超级简单了。如果你在 Fedora Linux 上安装 Discord 需要任何帮助,请告诉我。 --- via: <https://itsfoss.com/install-discord-fedora/> 作者:[Pranav Krishna](https://itsfoss.com/author/pranav/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) [Discord](https://discord.com/?ref=itsfoss.com) is a popular messaging application, which can be used for text and voice messaging. It is a boon to several communities, which helps them to expand their projects, reach out to more people, and maintain a community of fans and followers. It’s surprising considering that Discord was originally meant for gamers. Discord is available for various platforms, including Linux. In this tutorial, I’ll walk you through the steps for installing Discord in Fedora. - Installing Discord using DNF and RPM Fusion Repository - Installing Discord via Flatpak The Flatpak packages are sandboxed and hence take more disk space and time to start. However, they get updated for newer version releases fairly quickly. The choice is really yours if you want to use Flatpak or DNF. I’ll show both methods to you. **Non-FOSS Warning!**Discord application is not open source. But since they provide a Linux client and many Linux users rely on it, it’s been covered here. ## Method 1: Installing Discord via RPM Fusion Repository Discord can be installed by adding the nonfree RPM Fusion repository, which is the preferred method of most Fedora users, since updating is easy and the application starts up faster than the Flatpak version. Open a terminal and use the following command to add the RPM-fusion non-free repository: `sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm` Once you’re done with it, update the repository list (should not be needed but just for the sake of it): `sudo dnf update` Then install Discord via DNF command like this: `sudo dnf install discord` ![install discord dnf](https://itsfoss.com/content/images/wordpress/2021/11/install-discord-dnf-800x525.png) If asked for importing a GPG key, just authorize it by pressing ‘Y’ ![authorize gpg key 1](https://itsfoss.com/content/images/wordpress/2021/11/authorize-gpg-key-1-800x573.png) That is it! Now you can launch Discord from the app menu. Your login screen will look like this: ![discord 2](https://itsfoss.com/content/images/wordpress/2021/11/Discord-2-800x432.png) ### Remove Discord via DNF If you don’t want to use Discord anymore, you can remove it from your system. To do that, run the following command in the terminal: `sudo dnf remove discord` It’s really simple, isn’t it? There is another simple way of installing Discord and that is to use Flatpak packages. ## Method 2: Installing Discord via Flatpak Discord can be installed easily using Flatpak since it is available by default in Fedora. First, you need to enable Flatpak repository in Fedora: `flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo` Next, install Discord via this command: `flatpak install discord` ![install discord flatpak](https://itsfoss.com/content/images/wordpress/2021/11/install-discord-flatpak-800x545.png) If you want to remove Discord, then just run: `flatpak remove discord` That’s super easy. Let me know if you need any more help for installing Discord on Fedora Linux. And if you manage Discord servers, check out these [Discord bots](https://itsfoss.com/open-source-discord-bots/). [10 Best Open Source Bots for Your Discord ServerLooking for open-source Discord bots to boost the functionality of your Discord server? We have curated this list for you.](https://itsfoss.com/open-source-discord-bots/)![](https://itsfoss.com/content/images/wordpress/2022/11/best-open-source-discord-bots.png) ![](https://itsfoss.com/content/images/wordpress/2022/11/best-open-source-discord-bots.png)
14,027
C++ 控制台格式化打印技巧
https://opensource.com/article/21/11/c-stdcout-cheat-sheet
2021-11-28T10:05:00
[ "格式化" ]
https://linux.cn/article-14027-1.html
> > 下次当你为控制台输出的格式而苦恼时,请参考这篇文章及其速查表。 > > > ![](/data/attachment/album/202111/28/100548utbax4o4ttwcgyjz.jpg) 我写文章主要是为了给自己写文档。我在编程时非常健忘,所以我经常会写下有用的代码片段、特殊的特性,以及我使用的编程语言中的常见错误。这篇文章完全切合我最初的想法,因为它涵盖了从 C++ 控制台格式化打印时的常见用例。 像往常一样,这篇文章带有大量的例子。除非另有说明,代码片段中显示的所有类型和类都是 `std` 命名空间的一部分。所以当你阅读这段代码时,你必须在类型和类的前面加上`using namespace std;`。当然,该示例代码也可以在 [GitHub](https://github.com/hANSIc99/cpp_output_formatting) 上找到。 ### 面向对象的流 如果你曾经用过 C++ 编程,你肯定使用过 [cout](https://en.cppreference.com/w/cpp/io/cout)。当你包含 `<iostream>` 时,[ostream](https://en.cppreference.com/w/cpp/io/basic_ostream) 类型的 `cout` 对象就进入了作用域。这篇文章的重点是 `cout`,它可以让你打印到控制台,但这里描述的一般格式化对所有 [ostream](https://en.cppreference.com/w/cpp/io/basic_ostream) 类型的流对象都有效。`ostream` 对象是 `basic_ostream` 的一个实例,其模板参数为 `char` 类型。头文件 `<iosfwd>` 是 `<iostream>` 的包含层次结构的一部分,包含了常见类型的前向声明。 类 `basic_ostream` 继承于 `basic_ios`,该类型又继承于 `ios_base`。在 [cppreference.com](https://en.cppreference.com/w/cpp/io) 上你可以找到一个显示不同类之间关系的类图。 `ios_base` 类是所有 I/O 流类的基类。`basic_ios` 类是一个模板类,它对常见的字符类型进行了<ruby> 模板特化 <rt> specialization </rt></ruby>,称为 `ios`。因此,当你在标准 I/O 的上下文中读到 `ios` 时,它是 `basic_ios` 的 `char` 类型的模板特化。 ### 格式化流 一般来说,基于 `ostream` 的流有三种格式化的方法。 1. 使用 `ios_base` 提供的格式标志。 2. 在头文件 `<iomanip>` 和 `<ios>` 中定义的流修改函数。 3. 通过调用 `<<` 操作符的 [特定重载](https://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt)。 所有这些方法都有其优点和缺点,通常取决于使用哪种方法的情况。下面显示的例子混合使用所有这些方法。 #### 右对齐 默认情况下,`cout` 占用的空间与要打印的数据所需的空间一样大。为了使这种右对齐的输出生效,你必须定义一个行允许占用的最大宽度。我使用格式标志来达到这个目的。 右对齐输出的标志和宽度调整只适用于其后的行。 ``` cout.setf(ios::right, ios::adjustfield); cout.width(50); cout << "This text is right justified" << endl; cout << "This text is left justified again" << endl; ``` 在上面的代码中,我使用 `setf` 配置了右对齐的输出。我建议你将位掩码 `ios::adjustfield` 应用于 `setf`,这将使位掩码指定的所有标志在实际的 `ios::right` 标志被设置之前被重置,以防止发生组合碰撞。 #### 填充空白 当使用右对齐输出时,默认情况下,空的地方会用空白字符填充。你可以通过使用 `setfill` 指定填充字符来改变它: ``` cout << right << setfill('.') << setw(30) << 500 << " pcs" << endl; cout << right << setfill('.') << setw(30) << 3000 << " pcs" << endl; cout << right << setfill('.') << setw(30) << 24500 << " pcs" << endl; ``` 代码输出如下: ``` ...........................500 pcs ..........................3000 pcs .........................24500 pcs ``` #### 组合 想象一下,你的 C++ 程序记录了你的储藏室库存。不时地,你想打印一份当前库存的清单。要做到这一点,你可以使用以下格式。 下面的代码是左对齐和右对齐输出的组合,使用点作为填充字符,可以得到一个漂亮的列表: ``` cout << left << setfill('.') << setw(20) << "Flour" << right << setfill('.') << setw(20) << 0.7 << " kg" << endl; cout << left << setfill('.') << setw(20) << "Honey" << right << setfill('.') << setw(20) << 2 << " Glasses" << endl; cout << left << setfill('.') << setw(20) << "Noodles" << right << setfill('.') << setw(20) << 800 << " g" << endl; cout << left << setfill('.') << setw(20) << "Beer" << right << setfill('.') << setw(20) << 20 << " Bottles" << endl; ``` 输出: ``` Flour...............................0.70 kg Honey..................................2 Glasses Noodles..............................800 g Beer..................................20 Bottles ``` ### 打印数值 当然,基于流的输出也能让你输出各种变量类型。 #### 布尔型 `boolalpha` 开关可以让你把布尔型的二进制解释转换为字符串: ``` cout << "Boolean output without using boolalpha: " << true << " / " << false << endl; cout << "Boolean output using boolalpha: " << boolalpha << true << " / " << false << endl; ``` 以上几行产生的输出结果如下: ``` Boolean output without using boolalpha: 1 / 0 Boolean output using boolalpha: true / false ``` #### 地址 如果一个整数的值应该被看作是一个地址,那么只需要把它投到 `void*` 就可以了,以便调用正确的重载。下面是一个例子: ``` unsigned long someAddress = 0x0000ABCD; cout << "Treat as unsigned long: " << someAddress << endl; cout << "Treat as address: " << (void*)someAddress << endl; ``` 该代码产生了以下输出: ``` Treat as unsigned long: 43981 Treat as address: 0000ABCD ``` 该代码打印出了具有正确长度的地址。一个 32 位的可执行文件产生了上述输出。 #### 整数 打印整数是很简单的。为了演示,我使用 `setf` 和 `setiosflags` 来指定数字的基数。应用流修改器 `hex`/`oct` 也有同样的效果。 ``` int myInt = 123; cout << "Decimal: " << myInt << endl; cout.setf(ios::hex, ios::basefield); cout << "Hexadecimal: " << myInt << endl; cout << "Octal: " << resetiosflags(ios::basefield) << setiosflags(ios::oct) << myInt << endl; ``` **注意:** 默认情况下,没有指示所使用的基数,但你可以使用 `showbase` 添加一个。 ``` Decimal: 123 Hexadecimal: 7b Octal: 173 ``` #### 用零填充 ``` 0000003 0000035 0000357 0003579 ``` 你可以通过指定宽度和填充字符得到类似上述的输出: ``` cout << setfill('0') << setw(7) << 3 << endl; cout << setfill('0') << setw(7) << 35 << endl; cout << setfill('0') << setw(7) << 357 << endl; cout << setfill('0') << setw(7) << 3579 << endl; ``` #### 浮点值 如果我想打印浮点数值,我可以选择“固定”和“科学”格式。此外,我还可以指定精度: ``` double myFloat = 1234.123456789012345; int defaultPrecision = cout.precision(); // == 2 cout << "Default precision: " << myFloat << endl; cout.precision(4); cout << "Modified precision: " << myFloat << endl; cout.setf(ios::scientific, ios::floatfield); cout << "Modified precision & scientific format: " << myFloat << endl; /* back to default */ cout.precision(defaultPrecision); cout.setf(ios::fixed, ios::floatfield); cout << "Default precision & fixed format: " << myFloat << endl; ``` 上面的代码产生以下输出: ``` Default precision: 1234.12 Modified precision: 1234.1235 Modified precision & scientific format: 1.2341e+03 Default precision & fixed format: 1234.12 ``` #### 时间和金钱 通过 `put_money`,你可以用正确的、与当地有关的格式来打印货币单位。这需要你的控制台能够输出 UTF-8 字符集。请注意,变量 `specialOffering` 以美分为单位存储货币价值。 ``` long double specialOffering = 9995; cout.imbue(locale("en_US.UTF-8")); cout << showbase << put_money(specialOffering) << endl; cout.imbue(locale("de_DE.UTF-8")); cout << showbase << put_money(specialOffering) << endl; cout.imbue(locale("ru_RU.UTF-8")); cout << showbase << put_money(specialOffering) << endl; ``` `ios` 的 `imbue` 方法让你指定一个地区。通过命令 `locale -a`,你可以得到你系统中所有可用的地区标识符的列表。 ``` $99.95 99,950€ 99,950₽ ``` (不知道出于什么原因,在我的系统上,它打印的欧元和卢布有三个小数位,对我来说看起来很奇怪,但这也许是官方的格式。) 同样的原则也适用于时间输出。函数 `put_time` 可以让你以相应的地区格式打印时间。此外,你可以指定时间对象的哪些部分被打印出来。 ``` time_t now = time(nullptr); tm localtm = *localtime(&now); cout.imbue(locale("en_US.UTF-8")); cout << "en_US : " << put_time(&localtm, "%c") << endl; cout.imbue(locale("de_DE.UTF-8")); cout << "de_DE : " << put_time(&localtm, "%c") << endl; cout.imbue(locale("ru_RU.UTF-8")); cout << "ru_RU : " << put_time(&localtm, "%c") << endl; ``` 格式指定符 `%c` 会打印一个标准的日期和时间字符串: ``` en_US : Tue 02 Nov 2021 07:36:36 AM CET de_DE : Di 02 Nov 2021 07:36:36 CET ru_RU : Вт 02 ноя 2021 07:36:36 ``` ### 创建自定义的流修改器 你也可以创建你自己的流。下面的代码在应用于 `ostream` 对象时插入了一个预定义的字符串: ``` ostream& myManipulator(ostream& os) { string myStr = ">>>Here I am<<<"; os << myStr; return os; } ``` **另一个例子:** 如果你有重要的事情要说,就像互联网上的大多数人一样,你可以使用下面的代码在你的信息后面根据重要程度插入感叹号。重要程度被作为一个参数传递: ``` struct T_Importance { int levelOfSignificance; }; T_Importance importance(int lvl){ T_Importance x = {.levelOfSignificance = lvl }; return x; } ostream& operator<<(ostream& __os, T_Importance t){ for(int i = 0; i < t.levelOfSignificance; ++i){ __os.put('!'); } return __os; } ``` 这两个修饰符现在都可以简单地传递给 `cout`: ``` cout << "My custom manipulator: " << myManipulator << endl; cout << "I have something important to say" << importance(5) << endl; ``` 产生以下输出: ``` My custom manipulator: >>>Here I am<<< I have something important to say!!!!! ``` ### 结语 下次你再纠结于控制台输出格式时,我希望你记得这篇文章及其 [速查表](https://opensource.com/downloads/cout-cheat-sheet)。 在 C++ 应用程序中,`cout` 是 [printf](https://opensource.com/article/20/8/printf) 的新邻居。虽然使用 `printf` 仍然有效,但我可能总是喜欢使用 `cout`。特别是与定义在 `<ios>` 中的修改函数相结合,会产生漂亮的、可读的代码。 --- via: <https://opensource.com/article/21/11/c-stdcout-cheat-sheet> 作者:[Stephan Avenwedde](https://opensource.com/users/hansic99) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
When I started writing, I did it primarily for the purpose of documenting for myself. When it comes to programming, I'm incredibly forgetful, so I began to write down useful code snippets, special characteristics, and common mistakes in the programming languages I use. This article perfectly fits the original idea as it covers common use cases of formatting when printing to console from C++. **[Download the C++ std::cout cheat sheet]** As usual, this article comes with a lot of examples. Unless otherwise stated, all types and classes shown in the code snippets are part of the `std` namespace. So while you are reading this code, you have to put `using namespace std;` in front of types and classes. Of course, the example code is also available on [GitHub](https://github.com/hANSIc99/cpp_output_formatting). ## Object-oriented stream If you've ever programmed in C++, you've certainly already used [cout](https://en.cppreference.com/w/cpp/io/cout). The *cout* object of type [ostream](https://en.cppreference.com/w/cpp/io/basic_ostream) comes into scope when you include <iostream>. This article focuses on *cout*, which lets you print to the console but the general formatting described here is valid for all stream objects of type [ostream](https://en.cppreference.com/w/cpp/io/basic_ostream). An *ostream* object is an instance of basic_ostream with the template parameter of type char. The header <iosfwd>, which is part of the include hierarchy of <iostream>, contains forward declarations for common types. The class *basic_ostream* inherits from basic_ios and this type, in turn, inherits from ios_base. On [cppreference.com](https://en.cppreference.com/w/cpp/io) you find a class diagram that shows the relationship between the different classes. The class ios_base is the base class for all I/O stream classes. The class basic_ios is a template class that has a specialization for common character types called **ios**. So when you read about *ios* in the context of standard I/O, it is the char-type specialization of basic_ios. ## Formatting streams In general, there are three ways of formatting ostream-based streams: - Using the format flags provided by ios_base. - Stream modifying functions defined in the header <iomanip> and <ios>. - By invoking a [specific overload](https://en.cppreference.com/w/cpp/io/basic_ostream/operator_ltlt)of the*<<*-operator. All methods have their pros and cons, and it usually depends on the situation when which method is used. The following examples show a mixture of all methods. ### Right justified By default, *cout* occupies as much space as the data to print requires. To allow that right-justified output to take effect, you have to define the maximum width that a line is allowed to occupy. I use the format flags to reach the goal. The flag for right-justified output and the width adjustment only applies to the subsequent line: ``` cout.setf(ios::right, ios::adjustfield); cout.width(50); cout << "This text is right justified" << endl; cout << "This text is left justified again" << endl; ``` In the above code, I configure the right-justified output using setf. I recommend you apply the bitmask *ios::adjustfield* to *setf*, which causes all flags the bitmask specifies to be reset before the actual *ios::right* flag gets set to prevent colliding combinations. ### Fill white space When using right-justified output, the empty space is filled with blanks by default. You can change it by specifying the fill character using setfill: ``` cout << right << setfill('.') << setw(30) << 500 << " pcs" << endl; cout << right << setfill('.') << setw(30) << 3000 << " pcs" << endl; cout << right << setfill('.') << setw(30) << 24500 << " pcs" << endl; ``` The code produces the following output: ``` ...........................500 pcs ..........................3000 pcs .........................24500 pcs ``` ### Combine Imagine your C++ program keeps track of your pantry inventory. From time to time, you want to print a list of the current stock. To do so, you could use the following formatting. The following code is a combination of left- and right-justified output using dots as fill characters to get a nice looking list: ``` cout << left << setfill('.') << setw(20) << "Flour" << right << setfill('.') << setw(20) << 0.7 << " kg" << endl; cout << left << setfill('.') << setw(20) << "Honey" << right << setfill('.') << setw(20) << 2 << " Glasses" << endl; cout << left << setfill('.') << setw(20) << "Noodles" << right << setfill('.') << setw(20) << 800 << " g" << endl; cout << left << setfill('.') << setw(20) << "Beer" << right << setfill('.') << setw(20) << 20 << " Bottles" << endl; ``` Output: ``` Flour...............................0.70 kg Honey..................................2 Glasses Noodles..............................800 g Beer..................................20 Bottles ``` ## Printing values Of course, stream-based output also offers a multitude of possibilities to output all kinds of variable types. ### Boolean The boolalpha switch lets you convert the binary interpretation of a bool to a string: ``` cout << "Boolean output without using boolalpha: " << true << " / " << false << endl; cout << "Boolean output using boolalpha: " << boolalpha << true << " / " << false << endl; ``` The lines above produce the following output: ``` Boolean output without using boolalpha: 1 / 0 Boolean output using boolalpha: true / false ``` ### Addresses If the value of an integer should be treated as an address, it is sufficient to cast it to *void** in order to invoke the correct overload. Here is an example: ``` unsigned long someAddress = 0x0000ABCD; cout << "Treat as unsigned long: " << someAddress << endl; cout << "Treat as address: " << (void*)someAddress << endl; ``` The code produces the following output: ``` Treat as unsigned long: 43981 Treat as address: 0000ABCD ``` The code prints the address with the correct length. A 32-bit executable produced the above output. ### Integers Printing integers is straightforward. For demonstration purpose I specify the base of the number using setf and setiosflags. Applying the stream modifiers hex/oct would have the same effect: ``` int myInt = 123; cout << "Decimal: " << myInt << endl; cout.setf(ios::hex, ios::basefield); cout << "Hexadecimal: " << myInt << endl; cout << "Octal: " << resetiosflags(ios::basefield) << setiosflags(ios::oct) << myInt << endl; ``` **Note:** There is no indicator for the used base by default, but you can add one using showbase. ``` Decimal: 123 Hexadecimal: 7b Octal: 173 ``` ### Padding with zeros ``` 0000003 0000035 0000357 0003579 ``` You can get an output like the above by specifying the width and the fill character: ``` cout << setfill('0') << setw(7) << 3 << endl; cout << setfill('0') << setw(7) << 35 << endl; cout << setfill('0') << setw(7) << 357 << endl; cout << setfill('0') << setw(7) << 3579 << endl; ``` ### Floating-point values If I want to print floating-point values, I can choose between the *fixed*- and *scientific*-format. Additionally, I can specify the precision. ``` double myFloat = 1234.123456789012345; int defaultPrecision = cout.precision(); // == 2 cout << "Default precision: " << myFloat << endl; cout.precision(4); cout << "Modified precision: " << myFloat << endl; cout.setf(ios::scientific, ios::floatfield); cout << "Modified precision & scientific format: " << myFloat << endl; /* back to default */ cout.precision(defaultPrecision); cout.setf(ios::fixed, ios::floatfield); cout << "Default precision & fixed format: " << myFloat << endl; ``` The code above produces the following output: ``` Default precision: 1234.12 Modified precision: 1234.1235 Modified precision & scientific format: 1.2341e+03 Default precision & fixed format: 1234.12 ``` ### Time and Money With put_money, you can print currency units in the correct, locale-dependent formatting. This requires that your console can output UTF-8 charset. Note that the variable *specialOffering* stores the monetary value in cents: ``` long double specialOffering = 9995; cout.imbue(locale("en_US.UTF-8")); cout << showbase << put_money(specialOffering) << endl; cout.imbue(locale("de_DE.UTF-8")); cout << showbase << put_money(specialOffering) << endl; cout.imbue(locale("ru_RU.UTF-8")); cout << showbase << put_money(specialOffering) << endl; ``` The imbue-method of *ios* lets you specify a locale. With the command `locale -a` , you can get a list of all available locale identifiers on your system. ``` $99.95 99,950€ 99,950₽ ``` *(For whatever reason, it prints euro and ruble with three decimal places on my system, which looks strange for me, but maybe this is the official formatting.)* The same principle applies to time output. The function put_time lets you print the time in the corresponding locale format. Additionally, you can specify which parts of a time object get printed. ``` time_t now = time(nullptr); tm localtm = *localtime(&now); cout.imbue(locale("en_US.UTF-8")); cout << "en_US : " << put_time(&localtm, "%c") << endl; cout.imbue(locale("de_DE.UTF-8")); cout << "de_DE : " << put_time(&localtm, "%c") << endl; cout.imbue(locale("ru_RU.UTF-8")); cout << "ru_RU : " << put_time(&localtm, "%c") << endl; ``` The format specifier *%c* causes to print a standard date and time string: ``` en_US : Tue 02 Nov 2021 07:36:36 AM CET de_DE : Di 02 Nov 2021 07:36:36 CET ru_RU : Вт 02 ноя 2021 07:36:36 ``` ## Creating custom stream modifiers You can also create your own stream. The following code inserts a predefined string when applied to an *ostream* object: ``` ostream& myManipulator(ostream& os) { string myStr = ">>>Here I am<<<"; os << myStr; return os; } ``` **Another example:** If you have something important to say, like most people on the internet, you could use the following code to insert exclamation marks after your message depending on the level of importance. The level of importance gets passed as an argument: ``` struct T_Importance { int levelOfSignificance; }; T_Importance importance(int lvl){ T_Importance x = {.levelOfSignificance = lvl }; return x; } ostream& operator<<(ostream& __os, T_Importance t){ for(int i = 0; i < t.levelOfSignificance; ++i){ __os.put('!'); } return __os; } ``` Both modifiers can now be simply passed to *cout*: ``` cout << "My custom manipulator: " << myManipulator << endl; cout << "I have something important to say" << importance(5) << endl; ``` Producing the following output: ``` My custom manipulator: >>>Here I am<<< I have something important to say!!!!! ``` ## Conclusion Next time you struggle with console output formatting, I hope you remember this article or the related [cheat sheet](https://opensource.com/downloads/cout-cheat-sheet). In C++ applications, *cout* is the new neighbor of [printf](https://opensource.com/article/20/8/printf). While using *printf* is still valid, I would probably always prefer using *cout*. Especially the combination with the modifying function defined in *<ios>* results in nice, readable code. ## Comments are closed.
14,028
如何在 Fedora Linux 上安装 Brave 浏览器
https://itsfoss.com/install-brave-browser-fedora/
2021-11-28T10:24:29
[ "Brave", "浏览器" ]
https://linux.cn/article-14028-1.html
![](/data/attachment/album/202111/28/102349idh316xz3bslr6ps.jpg) [Brave](https://brave.com/) 是一个越来越 [流行于 Linux](https://itsfoss.com/best-browsers-ubuntu-linux/) 和其他操作系统的网页浏览器。对默认情况下阻止广告和跟踪的关注,以及对 Chrome 扩展的支持,使 Brave 成为 Linux 用户的热门选择。 在本教程中,你将学习如何在 Fedora Linux 上安装 Brave。你还将学习如何更新和删除它。 本教程已经在 Fedora 上进行了测试,但它也应该适用于基于 Red Hat 的其他发行版,如 CentOS、Alma Linux 和 Rocky Linux。 ### 在 Fedora Linux 上安装 Brave 浏览器 你需要在这里用命令行的方式来安装 Brave。 作为先决条件,请确保 `dnf-plugin-core` 已经安装。 ``` sudo dnf install dnf-plugins-core ``` 下一步是将 Brave 仓库添加到你的系统中: ``` sudo dnf config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/x86_64/ ``` 你还应该导入并添加仓库密钥,这样你的系统就会信任来自这个新添加的仓库的软件包: ``` sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc ``` ![Adding Brave Browser repository in Fedora Linux](/data/attachment/album/202111/28/102429eb6b4c4tv5q3ibqv.png) 现在可以开始了。用这个命令安装 Brave: ``` sudo dnf install brave-browser ``` **当被要求确认你的选择时按 `Y`**。根据你的网速,这应该需要几秒钟或几分钟的时间。如果 DNF 的缓存最近没有更新,甚至可能需要更长时间。 ![Installing Brave Browser in Fedora](/data/attachment/album/202111/28/102430jbr4vx74x79j4329.png) 安装完成后,在系统菜单中寻找 Brave 并从那里启动。 ![Start Brave browser in Fedora Linux](/data/attachment/album/202111/28/102430bd7wvbqikxpokbb1.png) ### 在 Fedora Linux 上更新 Brave 浏览器 你已经为浏览器添加了一个仓库,并且导入了它的密钥。你的系统信任来自这个仓库的软件包。 因此,当有新的 Brave 浏览器发布并提供给这个仓库时,你会通过常规的系统升级得到它。 换句话说,你不需要做任何特别的事情。只要保持你的 Fedora 系统更新,如果有 Brave 的新版本,它应该会随着系统更新自动安装。 ### 从 Fedora Linux 中删除 Brave 浏览器 ![Brave Browser in Fedora Linux](/data/attachment/album/202111/28/102430ajdp7a2dgixq20ja.png) 如果你因为某些原因不喜欢 Brave,你可以从你的系统中删除它。只需使用 `dnf remove` 命令: ``` sudo dnf remove brave-browser ``` 当询问时按 `Y`: ![Removing Brave browser from Fedora Linux](/data/attachment/album/202111/28/102430n5343h98b6c9gye0.png) 你也可以选择禁用 `brave-browser-rpm-release.s3.brave.com_x86_64_.repo` 或者从 `/etc/yum/repos.d` 中完全删除这个文件,虽然这并不是必须的。 我希望这个快速提示对你有帮助。如果你有任何问题或建议,请让我知道。 --- via: <https://itsfoss.com/install-brave-browser-fedora/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) [Brave](https://brave.com/?ref=itsfoss.com) is an increasingly [popular web browser for Linux](https://itsfoss.com/best-browsers-ubuntu-linux/) and other operating systems. The focus on blocking ads and tracking by default, along with Chrome extension support, has made Brave a popular choice among Linux users. In this tutorial, you’ll learn to install Brave on Fedora Linux. You’ll also learn about updating it and removing it. The tutorial has been tested on Fedora but it should also be valid for other distributions in the Red Hat domain such as CentOS, Alma Linux and Rocky Linux. ## Install Brave browser on Fedora Linux You’ll have to go to the command line way for installing Brave here. As a prerequisite, please ensure that dnf-plugin-core is installed. `sudo dnf install dnf-plugins-core` The next step is to add the Brave repository to your system: `sudo dnf config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/x86_64/` You should also import and add the repository key so that your system trusts the packages coming from this newly added repository: `sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc` ![adding brave browser repository in fedora](https://itsfoss.com/content/images/wordpress/2021/11/adding-Brave-browser-repository-in-Fedora-800x300.png) You are all set to go now. Install Brave with this command: `sudo dnf install brave-browser` **Press Y when asked to confirm** your choice. It should take a few seconds or a couple of minutes based on your internet speed. If the DNF cache was not updated recently, it may even take longer. ![Installing Brave Browser in Fedora](https://itsfoss.com/content/images/wordpress/2021/11/Installing-Brave-Browser-Fedora-800x428.png) Here's a screencast of Brave installation on Fedora. Once the installation finishes, look for Brave in the system menu and start from there. ![Start Brave browser in Fedora Linux](https://itsfoss.com/content/images/wordpress/2021/11/start-brave-fedora-linux.png) ## Updating Brave browser on Fedora Linux You have added a repository for the browser and also imported its key. Your system trusts the packages coming from this repository. So, when there is a new Brave browser release and it is made available to this repository, you’ll get it through regular system upgrades. ![](https://itsfoss.com/content/images/2023/05/image-11.png) In other words, you don’t have to do anything special. Just keep your Fedora system updated and if there is a new version from Brave, it should be automatically installed with system updates. ## Removing Brave browser from Fedora Linux ![brave browser in fedora linux](https://itsfoss.com/content/images/wordpress/2021/11/Brave-Browser-in-Fedora-Linux-800x530.png) If you do not like Brave for some reasons, you can remove it from your system. Just use the dnf remove command: `sudo dnf remove brave-browser` Press Y when asked: ![removing brave browser fedora linux](https://itsfoss.com/content/images/wordpress/2021/11/removing-Brave-browser-Fedora-Linux-800x399.png) You may also choose to disable the `brave-browser-rpm-release.s3.brave.com_x86_64_.repo` or delete this file completely from the `/etc/yum/repos.d` . Though it’s not really mandatory. Optionally again, you may choose to remove browsing data and cache to completely eliminate any remaining traces of Brave from your system. These are located in `~/.config/BraveSoftware` and `/.cache/BraveSoftware` . You can use the command line or the file explorer to [delete these folders](https://itsfoss.com/delete-files-folders-linux/). ``` rm -rf ~/.config/BraveSoftware rm -rf ~/.cache/BraveSoftware ``` ## Get more out of Brave browser Since you have installed Brave on Fedora, how about learning about a few tips and tweaks? For instance, you can [save downloaded files automatically in Brave Browser](https://itsfoss.com/save-files-automatically-brave-browser/). [How to Save Downloaded Files Automatically in Brave BrowserThe excellent Brave browser asks where to save the downloaded files by default. Here’s how to change this behavior and save downloaded files automatically.](https://itsfoss.com/save-files-automatically-brave-browser/)![](https://itsfoss.com/content/images/wordpress/2021/04/Brave-Browser-tweaks-tips.png) ![](https://itsfoss.com/content/images/wordpress/2021/04/Brave-Browser-tweaks-tips.png) Brave has a Picture-in-Picture mode. You probably didn't know about it because it is sort of hidden. Here's how to use it. [How to Use Picture in Picture Mode in Brave BrowserBrave has picture-in-picture mode but it’s so hidden that you feel like there is no PIP support at all. Here’s how to enable and use it.](https://itsfoss.com/picture-in-picture-brave/)![](https://itsfoss.com/content/images/wordpress/2022/09/enable-pip-mode-in-brave.png) ![](https://itsfoss.com/content/images/wordpress/2022/09/enable-pip-mode-in-brave.png) Go dark by enabling the dark mode in Brave. [How to Save Downloaded Files Automatically in Brave BrowserThe excellent Brave browser asks where to save the downloaded files by default. Here’s how to change this behavior and save downloaded files automatically.](https://itsfoss.com/save-files-automatically-brave-browser/)![](https://itsfoss.com/content/images/wordpress/2021/04/Brave-Browser-tweaks-tips.png) ![](https://itsfoss.com/content/images/wordpress/2021/04/Brave-Browser-tweaks-tips.png) Last but not least, you might want to try Brave Search considering Brave Browser is your primary web browser. The experience should be seamless, and you get many good search [features in Brave Search](https://itsfoss.com/brave-search-features/). [10 Features in Brave Search That Make it a Great Google Search AlternativeBrave Search is an ambitious initiative by Brave Software based on the open-source project Tailcat, which tries to take on the big tech by introducing the ability to search anonymously. Brave Search itself is not open source at the moment. Of course, there are various other private search engin…](https://itsfoss.com/brave-search-features/)![](https://itsfoss.com/content/images/wordpress/2021/06/brave-search-features.png) ![](https://itsfoss.com/content/images/wordpress/2021/06/brave-search-features.png) I hope you find this quick tip helpful. If you have any questions or suggestions, please let me know.
14,030
PHP 终于摆脱了危险的公共汽车系数 2
https://thenewstack.io/php-gets-a-foundation-to-work-on-php-core/
2021-11-29T00:12:00
[ "PHP", "公共汽车系数" ]
https://linux.cn/article-14030-1.html
![](/data/attachment/album/202111/29/001252kxgqy38q4h439qxe.jpg) 鉴于最近发生的事件,它也许没有 [维基百科上关于这个想法的文章](https://en.wikipedia.org/wiki/Bus_factor) 中所说的那么“黑色幽默”,但理论仍然是一样的 —— 你目前的团队中要有多少成员突然消失才能使你的组织或项目陷入停顿?这个数字被称为“<ruby> <a href="https://en.wikipedia.org/wiki/Bus_factor"> 公共汽车系数 </a> <rp> ( </rp> <rt> bus factor </rt> <rp> ) </rp></ruby>”,也就是说,有多少人被公共汽车撞到才会导致项目停止运作。今年早些时候,[PHP 贡献者 Joe Watkins](https://github.com/krakjoe) 认为,[PHP 的公共汽车系数是一个惊人的数字,即 2!](https://blog.krakjoe.ninja/2021/05/avoiding-busses.html) Watkins 当时写道:“也许只要有两个人一觉醒来决定干点别的事情,PHP 项目就会缺乏足够的专业技术和资源,从而无法以目前的形式和速度向前发展,”他点名了 [Dmitry Stogov](https://twitter.com/dstogov?lang=en) 和 [Nikita Popov](https://twitter.com/nikita_ppv?lang=en)。 上周,幸好 Nikita Popov 没有被公共汽车撞到,但他确实决定不再担任 PHP 相关的职务,而是将他的活动集中在 [LLVM](https://llvm.org/) 上。 > > PHP 太大了,不能失败,特别是由于 WordPress 继续依赖它。所以很高兴看到这个新的基金会形成。 > > > —— Richard MacManus (@ricmac) [2021 年 11 月 22 日](https://t.co/3wulgfM0eq) > > > 同样值得庆幸的是,Watkins 在今年早些时候的文章让一些人看到了眼前的情况,正如他在本周的 [后续文章](https://blog.krakjoe.ninja/2021/11/2-1.html) 中写到的,JetBrains(Popov 的雇主)当时就启动 PHP 基金会的问题联系了他。 本周,随着 Popov 的离职,[PHP 基金会](https://opencollective.com/phpfoundation) [正式启动](https://blog.jetbrains.com/phpstorm/2021/11/the-php-foundation/),目标是资助兼职/全职开发人员在 2022 年从事 [PHP 核心](https://github.com/php/php-src) 的开发工作。 在启动时,将会有 10 家公司([Automattic](https://automattic.com/)、[Laravel](https://laravel.com/)、[Acquia](https://www.acquia.com/)、[Zend](https://www.zend.com/)、[Private Packagist](https://packagist.com/)、[Symfony](https://symfony.com/)、[Craft CMS](https://craftcms.com/)、[Tideways](https://tideways.com/)、[PrestaShop](https://www.prestashop.com/) 和 [JetBrains](https://www.jetbrains.com/))作为其支持者加入 PHP 基金会 ,预计每年将筹集 30 万美元,JetBrains 每年出资 10 万美元。同时,该基金会是通过“<ruby> 基金会即服务 <rp> ( </rp> <rt> foundation-as-a-service </rt> <rp> ) </rp></ruby>”供应商 [Open Collective](https://opencollective.com/) 发起的,只有不到 700 名捐款人就已经为该基金会筹集了 4 万多美元。 创建基金会而不是坚持现状的主要好处之一,不仅仅是增加了公共汽车系数 —— 基金会将使对 PHP 的影响多样化。Watkins 指出,在 PHP 的大部分历史中,Dmitry Stogov 的雇主 Zend 一直是主要的财务支持者,因此对该语言的发展方向有一定的影响。同样,JetBrains 在雇用 Popov 开发 PHP 的时候,也增加了影响力。 “说他们没有影响到整个语言的发展方向是不正确的。事实上,他们影响了。语言的许多部分和它的内部结构都是由 Zend 推动的,由他们的预算和专门的工程师促成的,”Watkins 写道。“同样,在 Nikita 为 JetBrains 工作的相对较短的时间内,他们也有某种影响,如果说他们没有,那就是说 Nikita 在受雇于 JetBrains 之前和期间的产出没有区别。” 虽然 Watkins 说,所有的事情都是光明正大的,并且经过了标准的程序来确保如此,但影响力还是不容置疑的,“基金会代表了一种推动语言发展的新方式。它为我们提供了提高公共汽车系数的机制,使我们永远不会再面临我们今天面临的问题,以及过去面临的问题。” 基金会以 [临时管理机构](https://blog.jetbrains.com/phpstorm/2021/11/the-php-foundation/#foundation_administration) 启动,成员包括 Popov、Stogov 和 Watkins。而且 JetBrains 写道,[php-src](https://github.com/php/php-src) 的任何贡献者都可以向基金会 [申请](https://forms.gle/mk52v6FphaYr6yMS8) 资助,申请期立即开始,持续 28 天。至于未来会发生什么,PHP 基金会将在前两年把工作重点放在雇用开发人员从事 PHP 核心工作上。至于目前的 RFC 流程,JetBrains 写道,“不会改变,语言的决定将始终留给 PHP 内部社区。” > > 我为 PHP 基金会做出了贡献,如果你能做到的话,一定会鼓励你也这样做。每一点都能让基金会更强大,并帮助我们的语言和社区!#phpc > > > —— Matt Trask (@matthewtrask) [2021 年 11 月 22 日](https://t.co/rWyWC5Dz50) > > > --- via: <https://thenewstack.io/php-gets-a-foundation-to-work-on-php-core/> 作者:[Mike Melanson](https://thenewstack.io/author/mike-melanson/) 选题:[wxy](https://github.com/wxy) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](/article-14028-1.html) 荣誉推出
200
OK
# PHP Gets a Foundation to Work on PHP Core ![Featued image for: PHP Gets a Foundation to Work on PHP Core](https://cdn.thenewstack.io/media/2021/11/c7cbb688-this_week_in_programming.png) Given recent events, it’s perhaps less “darkly humorous” than the [Wikipedia article on the idea](https://en.wikipedia.org/wiki/Bus_factor) suggests, but the theory remains the same — how many members of your current team would need to suddenly disappear to grind your organization or project to a halt? That number is known as your [bus factor](https://en.wikipedia.org/wiki/Bus_factor), as in, how many people would need to be hit by a bus for everything to stop working, and earlier this year, [PHP contributor Joe Watkins](https://github.com/krakjoe) argued that [the bus factor for PHP was a shocking number two](https://blog.krakjoe.ninja/2021/05/avoiding-busses.html). “Maybe as few as two people would have to wake up this morning and decide they want to do something different with their lives in order for the PHP project to lack the expertise and resources to move it forward in its current form, and at current pace,” Watkins wrote at the time, naming [Dmitry Stogov](https://twitter.com/dstogov?lang=en) and [Nikita Popov](https://twitter.com/nikita_ppv?lang=en) as those two. Well, last week, Nikita Popov was thankfully not hit by a bus, but he did decide to move on from his role with PHP to instead focus his activities on [LLVM](https://llvm.org/). PHP is too big to fail, especially due to WordPress continuing to rely on it. So it’s good to see this new foundation forming. [https://t.co/3wulgfM0eq]— Richard MacManus (@ricmac) [November 22, 2021] Also thankfully, Watkins’ article earlier this year opened some eyes to the situation at hand and, as he writes in a [follow-up article](https://blog.krakjoe.ninja/2021/11/2-1.html) this week, JetBrains (Popov’s employer) reached out to him at the time regarding starting a PHP Foundation. This week, with Popov’s departure, the [PHP Foundation](https://opencollective.com/phpfoundation) was [officially launched](https://blog.jetbrains.com/phpstorm/2021/11/the-php-foundation/) with the goal of funding part/full-time developers to work on the [PHP core](https://github.com/php/php-src) in 2022. At launch, the PHP Foundation will count 10 companies — [Automattic](https://automattic.com/), [Laravel](https://laravel.com/), [Acquia](https://www.acquia.com/), [Zend](https://www.zend.com/), [Private Packagist](https://packagist.com/), [Symfony](https://symfony.com/), [Craft CMS](https://craftcms.com/), [Tideways](https://tideways.com/), [PrestaShop](https://www.prestashop.com/), and [JetBrains](https://www.jetbrains.com/) — among its backers, with an expectation to raise $300,000 per year, and with JetBrains contributing $100,000 annually. Alongside that, the foundation is being launched using foundation-as-a-service provider [Open Collective](https://opencollective.com/), and just under 700 contributors have already raised more than $40,000 for the foundation. One of the key benefits to creating a foundation, rather than sticking with the status quo, goes beyond increasing the bus factor — it diversifies the influences on PHP. Watkins points out that, for much of the history of PHP, Zend, the employer of Dmitry Stogov, has been a primary financial backer, and as such has had some amount of influence on the language’s direction. Similarly, JetBrains had increased influence during its time employing Popov on PHP. “To say they have not influenced the direction of the language as a whole would just not be true. Indeed, they have: Many parts of the language and its internals have been shaped by the fact that Zend pushed for them, enabled by their budget and dedicated engineer or engineers,” writes Watkins. “It’s also true that in the relatively short time that Nikita was with JetBrains, they too had some kind of influence, to say they didn’t would be to say there has been no difference between Nikita’s output before and during his employment with JetBrains.” While Watkins says that everything has been above board and gone through standard processes to ensure so, influence is nonetheless indisputable, and that “The Foundation represents a new way to push the language forward. It provides us the mechanism by which to raise the bus factor, so that we never face the problems we face today, and have faced in the past.” The foundation launches with a [temporary administration](https://blog.jetbrains.com/phpstorm/2021/11/the-php-foundation/#foundation_administration'), counting Popov, Stogov, and Watkins among the members, and JetBrains writes that any contributor to [php-src](https://github.com/php/php-src) may [apply](https://forms.gle/mk52v6FphaYr6yMS8) to the Foundation for funding, with the application period beginning immediately and lasting for 28 days. As for what will happen moving forward, the PHP Foundation will focus its efforts over the first two years on hiring developers to work on PHP core. The current RFC process, JetBrains writes, “will not change, and language decisions will always be left to the PHP Internals community.” I contributed to the PHP Foundation, and would definitely encourage you to do the same if you can. Every little bit makes the foundation stronger and helps our language and community! [#phpc][https://t.co/rWyWC5Dz50]— matt trask (@matthewtrask) [November 22, 2021] ## This Week in Programming **.NET and Open Source at re:Invent 2021:**With Amazon’s[re:Invent 2021](https://reinvent.awsevents.com/)conference coming up first thing next week, the company has put out a couple of guides to the event that we thought might be worth mentioning this week. First, there has been a lot of talk about .NET lately, with the[recent .NET 6 release](https://thenewstack.io/visual-studio-2022-and-net-6-finally-arrive/), and AWS has written up a blog post about all things[.NET at re:Invent 2021](https://aws.amazon.com/blogs/developer/net-at-reinvent-2021/). The post lists the various breakout sessions that will be available to both in-person and virtual attendees, such as “What’s new with .NET development and deployment on AWS” and “Build high-performance .NET serverless architectures on AWS” among several others. The[AWS attendee guide for Open Source at re:Invent 2021](https://aws.amazon.com/blogs/opensource/aws-attendee-guide-for-open-source-at-reinvent-2021/), meanwhile, takes a similar approach and lists out the various breakout sessions concerning open source, such as an “Introduction to GraphQL” or “Using Rust to minimize environmental impact”. The in-person event runs from Nov. 29 to Dec. 3, but the virtual event continues on for another week until December 10 and is entirely free to attend. Let’s talk about the Rust moderation team resigning. I don’t know anything about it beyond [https://t.co/V8y8v0roC2]– so let’s get meta.— Adam Jacob (@adamhjk) [November 22, 2021] **Amazon Previews Amazon Linux 2022:**Amazon has[previewed](https://aws.amazon.com/about-aws/whats-new/2021/11/preview-amazon-linux-2022/)a new, general-purpose Linux distribution for AWS called[Amazon Linux 2022 (AL2022)](https://aws.amazon.com/linux/amazon-linux-2022/), which it says is “designed to provide a secure, stable, and high-performance execution environment to develop and run your cloud applications.” The company has committed to providing a new major version every two years, with support for five years following, with quarterly updates for the latest software — although how you update will be entirely up to you. Right now, Amazon users choose between Amazon Linux 1 and Amazon Linux 2, but AL2022 will combine their benefits while offering “a predictable, two-year release cycle, so customers can plan for operating system upgrades as part of their product lifecycles.” AL2022 is based on upstream Fedora, has SELinux enabled and enforced by default, and is now available in preview at no additional charge. Head on over to the[documentation](https://docs.aws.amazon.com/linux/al2022/ug/)for more information.**In Case You’re Still Confused About Docker Business:**By now, you’ve heard all about[Docker’s changes to its fee structure](https://thenewstack.io/docker-defends-desktop-pricing-says-support-led-to-faster-features/), especially regarding Docker Desktop, but you might still have some questions. Well, Docker recently held a[webinar](https://www.docker.com/events/webinars/management-security-at-scale-docker-business)and was left with some questions, and has now put out a blog post to[answer your remaining Docker Business questions](https://www.docker.com/blog/your-docker-business-questions-answered/). For example, will you need to pay for Docker Desktop? Even if you don’t use the Docker Desktop UI? What do you have to do by Jan. 31, 2022? Click through for the answers to those questions and more, or check out the[Docker subscription cheat sheet](https://www.docker.com/sites/default/files/d8/2021-11/Docker__Which_Subscription_Is_Right_For_You_111721_V5.pdf?utm_campaign=2021-11-16-pricing-cheat-sheet&utm_medium=blog&utm_source=cheat-sheet)or[FAQ](https://www.docker.com/pricing/faq). The moment when you mention PHP in your new employer’s Slack and you draw out all the PHP haters. — Jeremy Lindblom (@jeremeamia) [November 23, 2021] [ YOUTUBE.COM/THENEWSTACK Tech moves fast, don't miss an episode. Subscribe to our YouTube channel to stream all our podcasts, interviews, demos, and more. ](https://youtube.com/thenewstack?sub_confirmation=1)
14,031
在 FreeDOS 上安装和移除软件包
https://opensource.com/article/21/6/freedos-package-manager
2021-11-29T12:28:29
[ "FreeDOS", "软件包管理器" ]
https://linux.cn/article-14031-1.html
> > 熟悉 FreeDOS 软件包管理器 FDIMPLES 。 > > > ![](/data/attachment/album/202111/29/122823yhv0mg03v3mhr0cc.jpg) 在 Linux 上,你可能已经使用过 “软件包管理器” 来安装或移除软件包。例如,在 Debian Linux 上的默认软件包管理器是 `deb` 命令,在 Fedora Linux 上的默认软件包管理器是 `dnf` 命令。 但是你知道 FreeDOS 也有一个软件包管理器吗? ### 安装软件包 FreeDOS 1.3 RC4 发行版包含了很多极好的你可以使用的程序和应用程序。不过,我们不会默认安装其中的全部的程序 —— 我们不想过度地填充你的硬盘驱动器空间,尤其是在一个较老的系统上,可能仅有几百兆字节容量的硬盘驱动器。当你安装 FreeDOS 时,如果你选择 “Plain DOS system” 选项,你将发现你的 FreeDOS 系统是非常小的(大约 20 MB 大小)。 不过,要安装新的软件包很容易。在命令行中运行 `FDIMPLES` 程序。因为 DOS 是 *不区分大小写* 的,所以,你可以使用大写字母或小写字母来输入这个命令: `fdimples` 。(`fdimples` 与 `FDIMPLES` 或 `FDImples` 等同) ![fdimples](/data/attachment/album/202111/29/122831r9jpp49pxpccz1pe.png) *在 FreeDOS 1.3 RC4 上的 FDIMPLES 软件包管理器(运行在 QEMU 之中)(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* FDIMPLES 是 "**F**ree**D**OS **I**nstaller - **M**y **P**ackage **L**ist **E**ditor **S**oftware" 的首字母缩略词,是一个交互式软件包管理器。FDIMPLES 读取安装介质来识别可以安装或移除的软件包。如果你看到一个不同的菜单,它显示 “Installed!” ,但是,不让你安装其它的软件的话,请检查你系统中是否有 FreeDOS 的 CD-ROM 的安装介质。在物理机器上,你将需要将 CD-ROM 插入 CD-ROM 驱动器;在诸如 QEMU 或 VirtualBox 之类的虚拟机器上,你需要将安装 FreeDOS 的 CD-ROM 的安装介质与虚拟机器关联在一起。 ![fdimples installed](/data/attachment/album/202111/29/122832zsm9z0r8a855i806.png) *如果你仅看到一条 “Installed!” 的信息,检查 CD-ROM 是否已经加载(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 让我们假设你想安装一些可以让你听音乐文件或其它声音文件的软件。使用向上箭头和向下箭头按键来导航到菜单中的 **声音工具** 项。这是一个针对声音和音乐程序的 *软件包组* 。 ![fdimples sound](/data/attachment/album/202111/29/122832a0tto6k058o1582k.png) *在 FDIMPLES 中突出显示声音软件包组(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 要选择这个组中的所有软件包,在你的键盘上按下空格键。如果你决定安装这个组中的某个软件包,按下 `Tab` 按键来移动到 *软件包列表* 方框面板,接下来使用空格键来选择每个软件包。 ![fdimples sound select](/data/attachment/album/202111/29/122832elapbes6e8g6lgos.png) *通过按下空格键来选择一个组中的所有的软件包(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 你可以继续选择你想要安装的其它的软件包或软件包组。当你选择好一切的东西后,使用 “Tab” 按键来高亮显示 “OK” 按键,并按下空格键按键。 ![fdimples sound select ok](/data/attachment/album/202111/29/122833h2haav0lh7ie1irr.png) *当你准备好安装时,突出显示 “Ok” 按钮(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* `FDIMPLES` 接下来会安装你所选择的所有的软件包。如果你仅选择几个小型的软件包,这可能只需要花费片刻的时间,或者,如果你要求安装很多大型的软件包,它可能会花费数分钟的时间。当 `FDIMPLES` 安装每个软件包时,`FDIMPLES` 会输出安装状态。在安装完后,`FDIMPLES` 退出到命令行之中,以便你可以回去继续工作。 ![fdimples sound install done](/data/attachment/album/202111/29/122833o7ss2mzejeeqblc5.png) *当 FDIMPLES 安装软件包时,FDIMPLES 会显示安装过程,并在完成安装后自动地退出(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* ### 移除软件包 如果你安装了一个软件包,但是后来发现你不想要它了怎么办?在 `FDIMPLES` 中移除软件包也同样容易。 就像安装软件包一样,启动 `FDIMPLES` ,使用箭头键导航到包含你想要移除的软件包的组。例如,如果我想卸载一些我先前安装的音乐播放器软件包,我将导航到 “Sound Tools” 软件包组。 ![fdimples sound select](/data/attachment/album/202111/29/122833qz6922ohv5so5935.png) *导航到你想要移除的软件包组(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 为一次移除整个软件包组,你可以在你想要移除的软件包组上按下空格键来取消选择它们。但是,在这里让我们假设我只是想移除几个我不需要的软件包,像音频 CD 播放器 “CDP”。(我没有任何的真实的音乐 CD 光盘)。为移除 CDP ,敲击 `Tab` 按键来移动到软件包列表方框面板,接下来使用空格键来取消选择 CDP 软件包。这会在该软件包上移除 “X” 标志。 ![fdimples unselect cdp](/data/attachment/album/202111/29/122833nxjcmxvfbjzfwmm8.png) *取消选择一个软件包来移除它(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 你可以继续取消选择你想要移除的其它的软件包或软件包组。当你选择一切的东西后,使用 `Tab` 按键来突出显示 “OK” 按钮,并按下空格键按键。`FDIMPLES` 将移除你取消选择的软件包,然后自动地返回到命令行之中。 ![fdimples cdp removed](/data/attachment/album/202111/29/122834dwwq364hqc2w4q3q.png) *FDIMPLES 移除软件包,然后返回到命令行之中(Jim Hall, [CC-BY SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))* 在 FreeDOS 中。我们包含很多的软件包,遍及各种各样的软件包组。使用 `FDIMPLES` 来安装你需要的软件。请随意实验!如果你决定你不想要保留一个软件包了,你可以移除它,并为其它的软件包来释放所占用的磁盘空间。 --- via: <https://opensource.com/article/21/6/freedos-package-manager> 作者:[Jim Hall](https://opensource.com/users/jim-hall) 选题:[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/) 荣誉推出
200
OK
On Linux, you may have used a *package manager* to install or remove packages. For example, the default package manager on Debian Linux is the `deb` command, and the default package manager on Fedora Linux is the `dnf` command. But did you know that FreeDOS has a package manager, too? ## Installing packages The FreeDOS 1.3 RC4 distribution includes lots of great programs and applications you can use. However, we don't install all of them by default—we don't want to fill your hard drive space unnecessarily, especially on older systems that may have hard drive capacities of only a few hundred megabytes. And if you selected the "Plain DOS system" option when you installed FreeDOS, you will find your FreeDOS system is quite small (about 20 megabytes). However, it's easy to install new packages. From the command line, run the `FDIMPLES` program. Because DOS is *case insensitive*, you can type this command using uppercase or lowercase letters: `fdimples` is the same as `FDIMPLES` or `FDImples` . ![The FDIMPLES package manager on FreeDOS 1.3 RC4 (running in QEMU) fdimples](https://opensource.com/sites/default/files/uploads/fdimples.png) The FDIMPLES package manager on FreeDOS 1.3 RC4 (running in QEMU) Jim Hall, CC-BY SA 4.0 FDIMPLES is an acronym for "**F**ree**D**OS **I**nstaller - **M**y **P**ackage **L**ist **E**ditor **S**oftware," and is an interactive package manager. FDIMPLES reads the installation media to identify packages that it can install or remove. If you see a different menu that says "Installed" but does not let you install other software, check that the FreeDOS install CD-ROM is loaded on your system. On a physical machine, you'll need to insert the CD-ROM into the CD-ROM drive; on a virtual machine like QEMU or VirtualBox, you'll need to associate the install CD-ROM image with the virtal machine. ![If you only see an "Installed" message, check that the CD-ROM is loaded fdimples installed](https://opensource.com/sites/default/files/uploads/fdimples-installed.png) Jim Hall, CC-BY SA 4.0 Let's say you wanted to install software that lets you play music and other sound files. Use the `Up `and `Down `arrow keys to navigate to the **Sound Tools** entry in the menu. This is called a *package group* for the sound and music programs. ![Highlighting the Sound package group in FDIMPLES fdimples sound](https://opensource.com/sites/default/files/uploads/fdimples-sound.png) Highlighting the Sound package group in FDIMPLES Jim Hall, CC-BY SA 4.0 To select all of the packages in this group, press the spacebar on your keyboard. Should you decide to install individual packages in this group, press the `Tab` key to move into the *package list* pane, then select each package with the spacebar. ![Select all the packages in a group by pressing the spacebar fdimples sound select](https://opensource.com/sites/default/files/uploads/fdimples-sound-select.png) Select all the packages in a group by pressing the spacebar Jim Hall, CC-BY SA 4.0 You can continue to select other packages or package groups that you want to install. When you have selected everything, use the `Tab` key to highlight the **OK** button, and press the spacebar. ![Highlight the "Ok" button when you're ready to install fdimples sound select ok](https://opensource.com/sites/default/files/uploads/fdimples-sound-select-ok.png) Highlight the "Ok" button when you're ready to install Jim Hall, CC-BY SA 4.0 FDIMPLES then installs all of the packages you selected. This may only take a few moments if you selected only a couple of small packages, or it could take minutes if you asked to install many larger packages. As it installs each package, FDIMPLES prints the status. Afterward, FDIMPLES exits to the command line, so you can get back to work. ![FDIMPLES shows the progress as its installs packages, and automatically exits when done fdimples sound install done](https://opensource.com/sites/default/files/uploads/fdimples-sound-select-ok-install4.png) FDIMPLES shows the progress as its installs packages, and automatically exits when done Jim Hall, CC-BY SA 4.0 ## Removing packages What if you install a package, only to discover afterward that you don't want it? Removing packages is just as easy in FDIMPLES. Just as when installing packages, start FDIMPLES, and use the arrow keys to navigate to the group that contains the packages you want to remove. For example, if I wanted to uninstall a few of the music-player packages I installed earlier, I would navigate to the **Sound Tools** package group. ![Navigate to the group with the packages you want to remove fdimples sound select](https://opensource.com/sites/default/files/uploads/fdimples-sound-select_0.png) Navigate to the group with the packages you want to remove Jim Hall, CC-BY SA 4.0 To remove the entire package group at once, you can press the spacebar on the group you want to remove to unselect it. But let's say I only wanted to remove a few packages that I didn't need, like the **CDP** audio CD player. (I don't have any physical music CDs.) To remove CDP, hit the `Tab` key to move into the package list pane, then use the spacebar to unselect the CDP package. This removes the **X** on that package. ![Unselect a package to remove it fdimples unselect cdp](https://opensource.com/sites/default/files/uploads/fdimples-unselect-cdp.png) Unselect a package to remove it Jim Hall, CC-BY SA 4.0 You can continue to unselect other packages or package groups that you want to remove. When you have selected everything, use the `Tab` key to highlight the **OK** button, and press the spacebar. FDIMPLES will remove the packages you unselected, then automatically returns you to the command line. ![FDIMPLES removes the package, then returns to the command line fdimples cdp removed](https://opensource.com/sites/default/files/uploads/fdimples-unselect-cdp-removed.png) FDIMPLES removes the package, then returns to the command line Jim Hall, CC-BY SA 4.0 We include many packages in FreeDOS, across a variety of package groups. Use FDIMPLES to install the software you need. Feel free to experiment! If you decide you don't want to keep a package, you can remove it and free up your disk space for other things. ## Comments are closed.
14,033
任何人都可以通过这三个简单的步骤编译开源代码
https://opensource.com/article/21/11/compiling-code
2021-11-30T13:37:14
[ "编译", "安装" ]
https://linux.cn/article-14033-1.html
> > 你不需要知道如何写或读代码就可以编译它。 > > > ![](/data/attachment/album/202111/30/133708wgq4rkecgbre93e1.jpg "Developing code.") 安装软件的方法有很多,但开源让你有了一个其他地方所没有的选择:你可以自己编译代码。编译源代码的经典三步流程是: ``` $ ./configure $ make $ sudo make install ``` 由于有了这些命令,你可能会惊讶地发现,你不需要知道如何写代码,甚至不需要读代码就可以编译它。 ### 安装用来构建软件的命令 由于这是你第一次进行编译,所以有一个一次性的准备步骤,即安装用于构建软件的命令。具体来说,你需要一个编译器。编译器(比如 GCC 或 LLVM)可以将像这样的源代码: ``` #include <iostream> using namespace std; int main() { cout << "hello world"; } ``` 变成 *机器语言*,即 CPU 用来处理信息的指令。你可以看一下机器代码,但它对你来说没有任何意义(除非你是一个 CPU)。 你可以使用你的软件包管理器安装 GNU 编译器集合(GCC)和 LLVM 编译器,以及其他在 Fedora、CentOS、Mageia 和类似发行版上进行编译的基本命令: ``` $ sudo dnf install @development clang ``` 在 Debian、Elementary、Mint 和类似发行版上命令如下: ``` $ sudo apt install build-essential clang ``` 在你的系统设置好后,有几项你每次编译软件时都要重复进行的任务: 1. 下载源代码 2. 展开源代码的存档文件 3. 编译 你已经有了所有你需要的命令,所以现在你需要一些软件来编译。 ### 1、下载源代码 获得一个应用程序的源代码和获得任何可下载的软件一样。你得去一个网站或一个代码管理网站,如 GitLab、SourceForge 或 GitHub。 通常情况下,开源软件既有正在进行的工作(“<ruby> 当前 <rt> current </rt></ruby>”或 “<ruby> 每夜 <rt> nightly </rt></ruby>”)的构建版本,也有打包的“<ruby> 稳定 <rt> stable </rt></ruby>”发布版本。在可能的情况下,使用稳定版本,除非你有理由相信,或者对代码有足够的了解,能够在出现故障时修复。术语“稳定版”表明这些代码经过了测试,而且该应用程序的程序员对代码有足够的信心,从而将其打包成 `.zip` 或 `.tar` 归档,给了它一个官方编号,有时还有一个发布名称,然后提供给一般的非程序员公众下载。 在这个练习中,我使用 [Angband](https://rephial.org/),一个开源的(GPLv2)ASCII 地牢猎手游戏。这是一个简单的应用程序,其复杂程度刚好可以说明你在自己编译软件时需要考虑的问题。 从 [网站](https://rephial.org/) 上下载其源代码。 ### 2、展开源代码的存档文件 源代码通常是以存档的形式交付的,因为源代码通常由多个文件组成的。在与之交互之前,你必须先解压,不管它是一个 tarball、一个 zip 文件、一个 7z 文件,还是其他完全不同的东西。 ``` $ tar --extract --file Angband-x.y.z.tar.gz ``` 一旦解压缩后,就把目录切换到解压缩的目录,然后看一看。通常在目录的顶层有一个 `README` 文件。这个文件,一般会包含你需要做什么来编译代码的指导。`README` 通常包含关于代码的这些重要方面的信息: * **语言**:代码使用的是什么语言(例如,C、C++、Rust、Python)。 * **依赖性**:你需要在你的系统上安装其他什么的软件,以便这个应用程序能够构建和运行。 * **说明**:你构建该软件所需要采取的明确步骤。偶尔,他们会在一个专门的文件中包含这些信息,这个文件被直观地称为 `INSTALL`。 如果 `README` 文件中不包含这些信息,可以考虑向开发者提交一份错误报告。你不是唯一需要介绍一下源代码的人。不管他们有多么丰富的经验,每个人都会对从未见过的源代码感到陌生,而文档是很重要的! Angband 的维护者给出了在线说明的链接,描述了如何编译代码。这份文件还描述了你需要安装哪些其他软件,尽管它并没有确切地说明这一点。该网站说,“有几个不同的可选构建的前端(GCU、SDL、SDL2 和 X11),你可以使用诸如 `--enable-sdl`,`--disable-x11` 的参数配置。”这可能对你来说看起来像天书,但你经常编译代码后就会习惯。无论你是否理解 X11 或 SDL2 是什么,它们都是你经过几个月定期编译代码后经常看到的要求。你会对大多数软件需要其他软件库的想法感到适应,因为它们建立在其他技术之上。不过在这种情况下,Angband 非常灵活,无论是否有这些可选的依赖,都可以进行编译,所以现在,你可以假装没有额外的依赖。 ### 3、编译代码 构建代码的典型步骤是: ``` $ ./configure $ make $ sudo make install ``` 这些是使用 [Autotools](https://opensource.com/article/19/7/introduction-gnu-autotools) 构建的项目的步骤,该框架是为了规范源代码的交付方式而创建的。然而,还有一些其他框架(如 [Cmake](https://opensource.com/article/21/5/cmake)),它们需要不同的步骤。当项目没有遵循 Autotools 或 Cmake 框架时,它们往往会在 `README` 文件中提醒你。 ### 配置 Angband 使用 Autotools,所以现在是编译代码的时候了! 在 Angband 目录中,首先,运行随源码一起提供的配置脚本: ``` $ ./configure ``` 这一步将扫描你的系统,找到 Angband 正确构建所需的依赖性。有些依赖是非常基本的,没有它们你的电脑就无法运行,而有些则是专门的。在这一过程结束时,该脚本会给你一份关于它所发现的东西的报告: ``` [...] configure: creating ./config.status config.status: creating mk/buildsys.mk config.status: creating mk/extra.mk config.status: creating src/autoconf.h Configuration: Install path: /usr/local binary path: /usr/local/games config path: /usr/local/etc/angband/ lib path: /usr/local/share/angband/ doc path: /usr/local/share/doc/angband/ var path: (not used) (save and score files in ~/.angband/Angband/) -- Frontends -- - Curses Yes - X11 Yes - SDL2 Disabled - SDL Disabled - Windows Disabled - Test No - Stats No - Spoilers Yes - SDL2 sound Disabled - SDL sound Disabled ``` 有些输出可能对你有意义,有些可能没有。无论如何,你可能注意到 SDL2 和 SDL 被标记为 “Disabled”,Test 和 Stats 都被标记为 “None”。虽然这些信息是负面的,但这并不一定是一件坏事。从本质上讲,这就是**警告**和**错误**之间的区别。如果配置脚本遇到了会阻止它构建代码的东西,它就会用一个错误来提醒你。 如果你想稍微优化一下你的构建,你可以选择解决这些负面信息。通过搜索 Angband 文档,你可能会确定 Test 和 Stats 实际上并不是你感兴趣的(它们是 Angband 专用于开发者的选项)。然而,通过在线研究,你可能会发现 SDL2 将是一个很好的功能。 要解决编译代码时的依赖问题,你需要安装缺少的组件和该缺少的组件的 *开发库*。换句话说,Angband 需要 SDL2 来播放声音,但它需要 `SDL2-devel`(在 Debian 系统上称为 `libsdl2-dev`)来构建。用你的软件包管理器安装这两个组件: ``` $ sudo dnf install sdl2 sdl2-devel ``` 再试一下配置脚本: ``` $ ./configure --enable-sdl2 [...] Configuration: [...] - Curses Yes - X11 Yes - SDL2 Yes - SDL Disabled - Windows Disabled - Test No - Stats No - Spoilers Yes - SDL sound Disabled - SDL2 sound Yes ``` ### 制作(编译) 一旦一切配置完毕,运行 `make` 命令: ``` $ make ``` 这通常需要一段时间,但它提供了很多视觉反馈,所以你会知道代码正在被编译。 ### 安装 最后一步是安装你刚刚编译的代码。安装代码并没有什么神奇之处。所做的就是复制很多文件到非常具体的目录中。无论你是从源代码编译还是运行花哨的图形安装向导,都是如此。由于这些代码会被复制到系统级目录,你必须有 root(管理)权限,这是由 `sudo` 命令授予的。 ``` $ sudo make install ``` ### 运行该应用程序 一旦应用程序被安装,你就可以运行它。根据 Angband 文档,启动游戏的命令是 `angband`,所以可以试试: ``` $ angband ``` ![Compile code lead image](/data/attachment/album/202111/30/133717f5i4kfb0wvllwv5l.jpg "Compile code lead image") ### 编译代码 无论是在我的 Slackware 台式电脑上,还是在我的 CentOS 笔记本电脑上,我都会使用 NetBSD 的 [pkgsrc](https://opensource.com/article/19/11/pkgsrc-netbsd-linux) 系统编译我自己的大部分应用程序。我发现,通过自己编译软件,我可以对应用程序中包含的功能、如何配置、使用的库版本等有自己的想法。这很有意义,它帮助我跟上了新的版本,而且因为我有时会在这个过程中发现错误,它帮助我参与了很多不同的开源项目。 你很少会只有编译软件的一种方式可选,大多数开源项目同时提供源代码(这就是为什么它被称为“开源”)和可安装包。是否从源代码编译是你自己的选择,也许是因为你想要最新版本中还没有的新功能,或者只是因为你喜欢自己编译代码。 ### 家庭作业 Angband 可以使用 Autotools 或 Cmake,所以如果你想体验另一种构建代码的方式,可以试试这个: ``` $ mkdir build $ cd build $ cmake .. $ make $ sudo make install ``` 你也可以尝试用 LLVM 编译器而不是 GNU 编译器集合(GCC)进行编译。现在,我把这个问题留给你自己去研究(提示:尝试设置 `CC` [环境变量](https://opensource.com/article/19/8/what-are-environment-variables))。 一旦你完成了对 Angband 的源代码和至少几个地牢的探索(你已经赢得了一些休息时间),可以看看其他一些代码库。很多人都会使用 Autotools 或 Cmake,而其他人可能会使用不同的东西。看看你能构建的成果! --- via: <https://opensource.com/article/21/11/compiling-code> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
There are many ways to install software, but you get an option not available elsewhere with open source: You can compile the code yourself. The classic three-step process to compile source code: ``` $ ./configure $ make $ sudo make install ``` Thanks to these commands, you might be surprised to find that you don't need to know how to write or even read code to compile it. ## Install commands to build software As this is your first time compiling, there's a one-time preparatory step to install the commands for building software. Specifically, you need a compiler. A compiler, such as GCC or LLVM, turns source code that looks like this: ``` #include <iostream> using namespace std; int main() { cout << "hello world"; } ``` Into *machine language*, the instructions that a CPU uses to process information. You can look at machine code, but it wouldn't make any sense to you (unless you're a CPU.) You can get the GNU C compiler (GCC) and the LLVM compiler, along with other essential commands for compiling on Fedora, CentOS, Mageia, and similar distributions, using your package manager: `$ sudo dnf install @development clang` On Debian, Elementary, Mint, and similar distributions: `$ sudo apt install build-essential clang` With your system set up, there are a few tasks that you'll repeat each time you want to compile your software: - Download the source code - Unarchive the source code - Compile You have all the commands you need, so now you need some software to compile. ## 1. Download source code Obtaining source code for an application is much like getting any downloadable software. You go to a website or a code management site like GitLab, SourceForge, or GitHub. Typically, open source software is available in both a work-in-progress ("current" or "nightly") form as well as a packaged "stable" release version. Use the stable version when possible unless you have reason to believe otherwise or are good enough with code to fix things when they break. The term **stable** suggests the code got tested and that the programmers of the application feel confident enough in the code to package it into a `.zip` or `.tar` archive, give it an official number and sometimes a release name, and offer it for download to the general non-programmer public. For this exercise, I'm using [Angband](https://rephial.org/), an open source (GPLv2) ASCII dungeon crawler. It's a simple application with just enough complications to demonstrate what you need to consider when compiling software for yourself. Download the source code from the website. ## 2. Unarchive the source code Source code is often delivered as an archive because source code usually consists of multiple files. You have to extract it before interacting with it, whether it's a tarball, a zip file, a 7z file, or something else entirely. `$ tar --extract --file Angband-x.y.z.tar.gz` Once you've unarchived it, change the directory into the extracted directory and have a look around. There's usually a `README` file at the top level of the directory. This file, ideally, contains guidance on what you need to do to compile the code. The `README` often contains information on these important aspects of the code: **Language:**What language the code is in (for instance, C, C++, Rust, Python).**Dependencies:**What other software you need to have installed on your system for this application to build and run.**Instructions:**The literal steps you need to take to build the software. Occasionally, they include this information within a dedicated file intuitively entitled`INSTALL` . If the `README` file doesn't contain that information, consider filing a bug report with the developer. You're not the only one who needs an introduction to source code. Regardless of how experienced they are, everyone is new to source code they've never seen before, and documentation is important! Angband's maintainers link to online instructions to describe how to compile the code. This document also describes what other software you need to have installed, although it doesn't exactly spell it out. The site says, "There are several different front ends that you can optionally build (GCU, SDL, SDL2, and X11) using arguments to configure such as `--enable-sdl` , `--disable-x11` , etc." This may mean something to you or look like a foreign language, but this is the kind of stuff you get used to after compiling code frequently. Whether or not you understand what X11 or SDL2 is, they're both requirements that you see pretty often after regularly compiling code over a few months. You get comfortable with the idea that most software needs other software libraries because they build upon other technologies. In this case, though, Angband is very flexible and compiles with or without these optional dependencies, so for now, you can pretend that there are no additional dependencies. ## 3. Compile the code The canonical steps to build code are: ``` $ ./configure $ make $ sudo make install ``` Those are the steps for projects built with [Autotools](https://opensource.com/article/19/7/introduction-gnu-autotools), which is a framework created to standardize how source code is delivered. Other frameworks (such as [Cmake](https://opensource.com/article/21/5/cmake)) exist, however, and they require different steps. When projects stray from Autotools or Cmake, they tend to warn you in the `README` file. ## Configure Angband uses Autotools, so it's time to compile code! In the Angband directory, first, run the configuration script included with the source: `$ ./configure` This step scans your system to find the dependencies that Angband requires to build correctly. Some dependencies are so basic that your computer wouldn't be running without them, while others are specialized. At the end of the process, the script gives you a report on what it has found: ``` [...] configure: creating ./config.status config.status: creating mk/buildsys.mk config.status: creating mk/extra.mk config.status: creating src/autoconf.h Configuration: Install path: /usr/local binary path: /usr/local/games config path: /usr/local/etc/angband/ lib path: /usr/local/share/angband/ doc path: /usr/local/share/doc/angband/ var path: (not used) (save and score files in ~/.angband/Angband/) -- Frontends -- - Curses Yes - X11 Yes - SDL2 Disabled - SDL Disabled - Windows Disabled - Test No - Stats No - Spoilers Yes - SDL2 sound Disabled - SDL sound Disabled ``` Some of that output may make sense to you, some of it may not. Either way, you probably notice that SDL2 and SDL are marked as `Disabled` , and both Test and Stats are marked with `No` . Although negative, this isn't necessarily a bad thing. This, essentially, is the difference between a **Warning** and an **Error**. Had the configure script encountered something that would prevent it from building the code, it would have alerted you with an error. If you want to optimize your build a little, you can choose to resolve these negative messages. By searching through the Angband documentation, you might decide that Test and Stats aren't actually of interest to you (they're developer options, specific to Angband). However, with a little online research, you might discover that SDL2 would be a nice feature to have. To resolve a dependency when compiling code, you need to install the missing component and the *development libraries* for that missing component. In other words, Angband needs SDL2 to play sound, but it needs `SDL2-devel` (called `libsdl2-dev` , on Debian systems) to build. Install both with your package manager: `$ sudo dnf install sdl2 sdl2-devel` Try the configuration script again: ``` $ ./configure --enable-sdl2 [...] Configuration: [...] - Curses Yes - X11 Yes - SDL2 Yes - SDL Disabled - Windows Disabled - Test No - Stats No - Spoilers Yes - SDL sound Disabled - SDL2 sound Yes ``` ## Make Once everything's configured, run the `make` command: `$ make` This usually takes a while, but it provides lots of visual feedback, so you'll know code is getting compiled. ## Install The final step is to install the code you've just compiled. There's nothing magical about installing code. All that happens is that lots of files get copied to very specific directories. That's true whether you're compiling from source code or running a fancy graphical install wizard. Because the code is getting copied to system-level directories, you must have root (administrative) privileges, which get granted by the `sudo` command. `$ sudo make install` ## Run the application Once the application gets installed, you can run it. According to the Angband documentation, the command to start the game is `angband` , so try it out: `$ angband` ## (Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)) ![Compile code lead image Compile code lead image](https://opensource.com/sites/default/files/uploads/angband.jpg) (Seth Kenlon, CC BY-SA 4.0) ## Compiling code I compile most of my own applications, whether on my Slackware desktop computer or my CentOS laptop using NetBSD's [pkgsrc](https://opensource.com/article/19/11/pkgsrc-netbsd-linux) system. I find that by compiling software myself, I can be as particular as I want to be about the features included in the application, how it's configured, which library version it uses, and so on. It's rewarding, and it helps me keep up to date with new releases and, because I sometimes find bugs in the process, it helps me get involved with lots of different open source projects. It's rare that you have no other option but to compile software. Most open source projects provide both the source code (that's why it's called "open source") and installable packages. Compiling from source code is a choice you get to make for yourself, maybe because you want new features not yet available in the latest release or just because you prefer to compile code yourself. ## Homework Angband can use either Autotools or Cmake, so if you want to experience another way of building code, try this: ``` $ mkdir build $ cd build $ cmake .. $ make $ sudo make install ``` You can also try compiling with the LLVM compiler instead of the GNU C compiler. For now, I'll leave that as an exercise for you to investigate on your own (hint: try setting the CC [environment variable](https://opensource.com/article/19/8/what-are-environment-variables).) Once you finish exploring the source code of Angband and at least a few of its dungeons (you've earned some downtime), have a look at some other codebases. Many will use Autotools or Cmake, while others may use something different. See what you can build! ## 2 Comments
14,034
用 Flatseal 图形化管理 Flatpak 应用的权限
https://itsfoss.com/flatseal/
2021-11-30T13:52:14
[ "Flatpak", "权限" ]
https://linux.cn/article-14034-1.html
![](/data/attachment/album/202111/30/135209fbcvqnvnzidvg2hw.jpg) 新版本的安卓系统让你对单个应用的访问和权限有了更精细的控制。这一点至关重要,因为许多应用曾经(正在)滥用系统权限。下载一个天气应用,它将要求访问你的通话记录,好像这与天气有什么关系一样。 为什么我在说安卓应用的权限?因为这可能与此应用的功能有关。 你可能已经知道 [什么是 Flatpak](https://itsfoss.com/what-is-flatpak/)。这些都是沙盒应用,可以选择访问系统资源,如文件存储、网络接口等。 就像 Android 一样,你可以控制 Flatpak 应用对系统资源的访问。默认情况下,这要用 [Flatpak 命令](https://itsfoss.com/flatpak-guide/),不是每个人都能适应它。 因此,有一个叫做 Flatseal 的小工具,可以让你在应用层面上管理和控制 Flatpak 的权限。 ### Flatseal ![Flatseal](/data/attachment/album/202111/30/135215vcsnss571odozi5s.png) [Flatseal](https://flathub.org/apps/details/com.github.tchx84.Flatseal) 是一个图形化的工具,用于审查和修改你的 Flatpak 应用的权限。这使得事情比通过命令要容易得多。 Flatseal 会列出所有已安装的 Flatpak 应用。当你选择一个应用,你可以看到所有的权限。很容易发现已启用的权限,如果你愿意,你可以禁用它。 例如,Ksnip 是一个屏幕截图工具,但它也有联网权限,可以用 Imgur 等在线服务分享截图。如果你不需要它,你可以禁用它。 ![Control permissions of individual Flatpak apps](/data/attachment/album/202111/30/135215n96c39uocu5tdffa.png) 如果不出意外,看看一个应用有什么样的权限是很有趣的。例如,你可以看到 ksnip 有在后台运行的能力(这样你就可以用键盘快捷键进行截图)。 ![](/data/attachment/album/202111/30/135215ged2v2bvtivsg4tj.png) ### 安装 Flatseal 既然管理的都是 Flatpak,那么 Flatseal 作为一个 Flatpak 包来使用也是合理的。 在 Fedora 上,如果已经添加 Flathub 仓库,你可以从软件中心安装它。 ![Installing Flatseal from the software center](/data/attachment/album/202111/30/135216vg3r7yn55r9y5ssn.png) 否则,命令行总是可以帮助你。 ``` flatpak install flathub com.github.tchx84.Flatseal ``` ### 你真的需要控制权限吗? 这是一个主观的问题,完全取决于你。值得庆幸的是,到目前为止,桌面 Linux 应用并不像 Android 应用那样滥用权限。 一个普通用户通常不会去管这些事情,这完全没问题。 然而,如果你对这些事情过于谨慎,或者你找到一个很好的理由,Flatseal 提供了一个简单的选择。 你还应该小心你所改变的权限。如果你禁用了对应用的运作至关重要的权限,在使用应用时肯定会造成麻烦。 所以,总的来说,这不是一个普通用户要使用的东西。 --- via: <https://itsfoss.com/flatseal/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
The newer versions of Android give you more granular control over the access and permission an individual app can have. This is vital because many applications were (are) abusing the system permissions. Download a weather app and it will ask to access your call logs as if that has anything to do with the weather. Why am I talking about Android app permissions? Because that is something you could relate with this application’s functioning. You probably already know [what Flatpak is](https://itsfoss.com/what-is-flatpak/). These are sandboxed applications with selected access to system resources like file storage, network interface etc. Just like Android, you can control the access to system resources by Flatpak applications. By default, that happens with [Flatpak commands](https://itsfoss.com/flatpak-guide/) and not everyone can be comfortable with it. And hence, there is this tiny utility called Flatseal that allows you to manage and control the Flatpak permissions at application level. ## Flatseal [Flatseal](https://flathub.org/apps/details/com.github.tchx84.Flatseal) is a graphical utility to review and modify permissions your Flatpak applications have got. This makes things a lot easier than going through the commands. Flatseal lists all the installed Flatpak applications. When you select one, you can see all the permissions. The enabled permissions can be easily spotted and if you want, you can disable them. For example, Ksnip is a screenshot utility and it also has networking access to share the screenshots with online services like Imgur. If you do not need it, you can disable it. If nothing else, it is interesting to see what kind of permissions an application has. For example, you can see that ksnip has the ability to run in the background (so that you can use it for taking screenshots with keyboard shortcuts). ## Installing Flatseal Since it’s all about Flatpak, it only makes sense that Flatseal is available as a Flatpak package. On Fedora, if the Flathub repo is added, you can install it from the software center. Otherwise, the command line is always there to help you. `flatpak install flathub com.github.tchx84.Flatseal` ## Do you need to control permissions? That’s a subjective question and it totally depends on you. Thankfully, the desktop Linux apps are not as abusive as Android apps so far. An average user usually does not bother with these things, which is fine. However, if you are overly cautious about these things or you find a good reason, Flatseal provides the easy option. You should also be careful about what permissions you are changing. If you disable a permission crucial to the functioning of the application, it will surely cause trouble while using the application. So, overall, this is not something an average user is going to use.
14,037
使用 Linux 的 diff 和 patch 对文件进行协作
https://opensource.com/article/21/11/linux-diff-patch
2021-12-01T10:26:00
[ "diff", "patch" ]
https://linux.cn/article-14037-1.html
> > 如果你曾经试图通过电子邮件或聊天来协作处理文件,并且发现自己试图描述需要修改的地方,那么你会喜欢 `diff` 和 `patch` 的。 > > > ![](/data/attachment/album/202112/01/102607jmjbpu1jk1as61j1.jpg) 我编辑过很多文本文件。有时是代码。其他时候是角色扮演游戏(RPG)、编程书籍或一般信件的书面文字。有时候,做一个修改,而能让我的协作者把我的修改和他们原来写的东西进行比较就更好了。许多人默认使用办公套件(如 [LibreOffice](https://opensource.com/article/21/9/libreoffice-tips))的注释或更改跟踪功能。不过有时更简单的工具更有意义,为此,你可以看看像 `diff` 和 `patch` 这样的工具的编程历史,它们为跟踪和应用共享文件的变化提供了标准化的格式。 即使对于简单的文件,在同步两个文件时也有复杂性。一些项目被改变,另一些被保留,新的内容被添加,还有一些保持不变,但被移到文件的不同位置。如果接受所有的变化,并且用新文件替换旧文件,就很难复制变化。它也是整体不透明的。如果变化很多,就很难挑出到底发生了什么变化。 通过 `diff` 命令,你可以创建一个文件变化的记录,通过 `patch` 你可以在旧版本上“重放”这些变化,使其与新版本保持一致。 ### 设置 假设你和我正在合作编写一个描述如何泡茶的文件。 到目前为止,文件 `tea.md` 包含原始的复制粘贴来的内容: ``` 烧开水。 加热茶壶。 在茶壶中加入茶和水。 在茶壶上放置一个茶叶滤网。 浸泡 6 分钟。 将茶倒入杯中。 加入牛奶。 ``` 这似乎很合理,但总有一些优化可以做,所以你把文件发给我改进。为了澄清泡茶过程,我把文件复制为`tea-revision.md`,并进行编辑,最后是这样的: ``` 在烤箱的抽屉中加热茶壶。 烧开水。 将茶叶放入茶叶滤网。 将滤网和水加入茶壶。 浸泡 6 分钟。用茶壶罩保温。 将茶倒入杯中。 可以选择加入温牛奶。 ``` 正如预期的那样,一些项目(“烧开水”和“将茶倒入杯中”)没有变化,而其他行(“加热茶壶”)则有增加。有些行是全新的,有些行是相同的,但顺序不同。 ### 创建一个差异 `diff` 工具会显示两个文件之间的差异。有几种不同的方法来查看结果,但我认为最清楚的是 `—unified`(简写为 `-u`)视图,它显示哪些行被增加或减少了。以任何方式改变的行都被视为先减后增的行。默认情况下,`diff` 将其输出打印到终端。 向 `diff` 提供旧文件,然后是新文件: ``` $ diff --unified tea.md tea-revised.md --- tea.md 2021-11-13 10:26:25.082110219 +1300 +++ tea-revised.md 2021-11-13 10:26:32.049110664 +1300 @@ -1,7 +1,7 @@ +在烤箱的抽屉中加热茶壶。 烧开水。 -加热茶壶。 -在茶壶中加入茶和水。 -在茶壶上放置一个茶叶滤网。 -浸泡 6 分钟。 +将茶叶放入茶叶滤网。 +将滤网和水加入茶壶。 +浸泡 6 分钟。用茶壶罩保温。 将茶倒入杯中。 -加入牛奶。 +可以选择加入温牛奶。 ``` 行首的加号(`+`)表示在旧文件中增加了一些内容。行首的减号(`-`)表示被删除或改变的行。 ### 用 diff 创建一个补丁 补丁文件就是将 `diff —unified` 命令的输出放到一个文件中。你可以用标准的 Bash 重定向来做这件事: ``` $ diff -u tea.md tea-revised.md > tea.patch ``` 该文件的内容与输出到终端的内容完全相同。我喜欢在 [Emacs](https://opensource.com/article/20/12/emacs) 中查看补丁文件,它对每一行进行颜色编码,取决于它是被添加还是被减去。 ![Emacs中的补丁文件](/data/attachment/album/202112/01/102615lyxryrxdetb3nr6r.jpg "A patch file in Emacs") ### 用补丁应用修改 一旦我有了补丁文件,我就可以把它发给你,让你审查,并且可以选择应用到你的旧文件中。你可以用 `patch` 命令来应用一个补丁。 ``` $ patch tea.md tea.patch ``` 增加了一些行,减少了一些行,最后,你得到了一个与我的版本相同的文件: ``` $ cat tea.md 在烤箱的抽屉中加热茶壶。 烧开水。 将茶叶放入茶叶滤网。 将滤网和水加入茶壶。 浸泡 6 分钟。用茶壶罩保温。 将茶倒入杯中。 可以选择加入温牛奶。 ``` 你可以给一个文件打多少次补丁,这是没有限制的。你可以对我的修改进行迭代,生成一个新的补丁,然后发给我审核。发送修改内容而不是结果,可以让每个贡献者审查修改的内容,决定他们要保留或删除的内容,并准确地记录过程。 ### 安装 在 Linux 和 macOS 上,你已经有了 `diff` 和 `patch` 命令。在 Windows 上,你可以通过 [Cygwin](https://cygwin.com) 获得 `diff` 和 `patch`,或者使用 Chocolatey 搜索 [diffutils](https://community.chocolatey.org/packages/diffutils) 和 [patch](https://community.chocolatey.org/packages/patch)。 如果你曾经试图通过电子邮件或聊天来协作处理文件,并且发现自己需要 *描述* 需要修改的地方,那么你会喜欢 `diff` 和 `patch`。一个结构严谨的文件,如代码或以行为单位的 [Markdown](https://opensource.com/article/19/9/introduction-markdown),很容易进行差异比较、补丁和维护。 --- via: <https://opensource.com/article/21/11/linux-diff-patch> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
I edit a lot of text files. Sometimes it's code. Other times it's the written word for role-playing games (RPGs), programming books, or general correspondence. Sometimes it's nice to make a change, but for my collaborator to compare my change with what they originally had written. Many people default to office suites, like [LibreOffice](https://opensource.com/article/21/9/libreoffice-tips), using comments or change tracking features. Sometimes a simpler tool makes more sense, though, and for that, you can look at programming history for tools like `diff` and `patch` , which provide standardized formatting for tracking and applying changes to shared files. Even with a simple file, there's complexity in synchronizing two documents. Some items get changed, others are left alone, new content gets added, and some stay the same but are moved to different places in the document. It's difficult to replicate changes without blissfully accepting that all changes are equally valid, and replacing the old file with the new one. It's also monolithically opaque. There are so many changes that it's difficult to pick out exactly what's changed. With the `diff` command, you can create a record of how the file has changed, and with `patch` you can "replay" those changes over the old version to bring it up to date with the new version. ## Setup Suppose you and I are collaborating on a file describing how to make a cup of tea. So far, the file `tea.md` contains raw copy-paste: ``` Boil water. Warm the teapot. Add tea and water to the teapot. Place a tea cosy over the teapot. Steep for 6 minutes. Pour tea into cup. Add milk. ``` It seems reasonable, but there are always optimizations you can make, so you send the file to me for improvement. In an effort to clarify the tea-making process, I copy the file as `tea-revision.md` and edit it, ending up with this: ``` Warm a teapot in the proving drawer of your oven. Boil water. Add tea leaves to a tea strainer. Add strainer and water to teapot. Steep for 6 minutes. Keep it warm with a tea cosy. Pour tea into cup. Optionally, add warm milk. ``` As expected, some items (`Boil water` and `Pour tea into cup` ) are unchanged, while other lines (`Warm the teapot` ) have had additions. Some lines are completely new, and some lines are the same but in a different order. ## Create a diff The `diff` tool displays the difference between two files. There are a few different ways to view the results, but I think the clearest one is the `--unified` (`-u` for short) view, which shows which lines got added or subtracted. A line that's changed in any way is treated as a line that got subtracted and then added. By default, `diff` prints its output to the terminal. Provide `diff` with the old file and then the new file: ``` $ diff --unified tea.md tea-revised.md --- tea.md 2021-11-13 10:26:25.082110219 +1300 +++ tea-revised.md 2021-11-13 10:26:32.049110664 +1300 @@ -1,7 +1,7 @@ +Warm a teapot in the proving drawer of your oven. Boil water. -Warm the teapot. -Add tea and water to the teapot. -Place a tea cosy over the teapot. -Steep for 6 minutes. +Add tea leaves to a tea strainer. +Add strainer and water to teapot. +Steep for 6 minutes. Keep it warm with a tea cosy. Pour tea into cup. -Add milk. +Optionally, add warm milk. ``` A plus sign (`+` ) at the beginning of a line indicates something that's gotten added to the old file. A minus sign (`-` ) at the beginning of a line indicates a line that's gotten removed or changed. ## Create a patch with diff A patch file is just the output of the `diff --unified` command placed into a file. You can do this using standard Bash redirection: `$ diff -u tea.md tea-revised.md > tea.patch` The contents of the file are exactly the same as what was output to the terminal. I like to view patch files in [Emacs](https://opensource.com/article/20/12/emacs), which color-codes each line depending on whether it's gotten added or subtracted. ![A patch file in Emacs A patch file in Emacs](https://opensource.com/sites/default/files/uploads/emacs_0_1.jpg) Seth Kenlon, CC BY-SA 4.0) ## Applying changes with patch Once I have a patch file, I could send it to you for you to review and, optionally, apply to your old file. You apply a patch with the `patch` command: `$ patch tea.md tea.patch` Lines got added, lines got subtracted, and in the end, you end up with a file identical to my version: ``` $ cat tea.md Warm a teapot in the proving drawer of your oven. Boil water. Add tea leaves to a tea strainer. Add strainer and water to teapot. Steep for 6 minutes. Keep it warm with a tea cosy. Pour tea into cup. Optionally, add warm milk. ``` There's no limit to how many times you can patch a file. You could iterate on my changes, generate a new patch, and send that to me for review. Sending changes rather than results lets each contributor review what changed, decide what they want to keep or eliminate, and accurately document the process. ## Install On Linux and macOS, you already have both the `diff` and `patch` commands. On Windows, you can obtain `diff` and `patch` through [Cygwin](https://cygwin.com), or use Chocolatey to search for [diffutils](https://community.chocolatey.org/packages/diffutils) and [patch](https://community.chocolatey.org/packages/patch). If you've ever tried to collaborate on files over email or chat, and you've found yourself trying to *describe* where you need a change made, then you'll love `diff` and `patch` . A carefully structured file, such as code or line-delimited [Markdown](https://opensource.com/article/19/9/introduction-markdown), is easy to diff, patch, and maintain. ## 2 Comments
14,038
创建节日问候的 4 种开源方式
https://opensource.com/article/21/11/open-source-holiday-greetings
2021-12-01T11:36:47
[ "节日", "开源" ]
/article-14038-1.html
> > 开源工具和资源为任何节日提供了创造性的可能性。 > > > ![](/data/attachment/album/202112/01/113447fkk2du1udmdu2n0d.jpg "Painting art on a computer screen") 节日再次来临,今年我决定用 [开源方式](https://opensource.com/open-source-way) 来庆祝。就像一个特别有名的假期忙人一样,我有一个长长的节日任务清单(我打算再三检查):制作一张贺卡(带地址的明信片)寄给家人和朋友,用合适的节日歌曲制作照片蒙太奇或视频,并装饰我的虚拟办公室。有很多开源的应用和资源使我的工作更容易。以下是我使用的东西。 ### Inkscape 和剪贴画 我最喜欢的资源之一是 [FreeSVG.org](http://freesvg.org)(前身是 [Openclipart.org](http://Openclipart.org))。这里很容易找到你喜欢的节日,包括光明节、圣诞节、新年等等。这些剪贴画都是由像你我这样的用户贡献的,并且是 CC0 版权,所以你甚至不需要提供署名。当然,在可能的情况下,我还是会注明出处,以确保 FreeSVG 和它的艺术家们获得知名度。 下面是 FreeSVG 的一些剪贴画的例子: ![一幅棕色玉米棒的漫画,上面有红色的苹果、橙色的南瓜和棕色的坚果溢出来。](/data/attachment/album/202112/01/113649kx2ghzw1h1q33hov.png "cornucopia") [openclipart.com](http://openclipart.com), [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/) 使用 [Inkscape](https://opensource.com/article/18/1/inkscape-absolute-beginners) 的文本路径工具,我在图片上添加了我自己的文字,我把它用在卡片上。如果再做些工作,我还可以把这个图形用在一些定制的杯子或餐垫上。 ![一幅棕色玉米棒的漫画,上面有红色的苹果、橙色的南瓜和棕色的坚果溢出来,上面有一个拱门形的“我们感谢”的字样。](/data/attachment/album/202112/01/113650npexe5qt80xtyq08.png "We Give Thanks") Don Watkins, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/) ### 文字处理 [LibreOffice](https://opensource.com/article/21/9/libreoffice-tips) Writer 可以用来制作贺卡和海报,然后在你的家中使用或分发给你的朋友和家人。使用 LibreOffice Calc 创建一个关于你的家人和朋友的数据库,然后利用这一资源,用邮件合并功能简化制作邮件标签的过程。 ### 创作共用的图片和图形 [search.creativecommons.org](https://search.creativecommons.org/) 上也有艺术品。注意许可证类型:对任何需要署名的东西给予适当的致谢。这张图片([“Thanksgiving Dealies”](https://www.flickr.com/photos/34067077@N00/4014605524))来自创作共用图片搜索。它的作者是 [Martin Cathrae](https://www.flickr.com/photos/34067077@N00),并在 [CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/?ref=ccsearch&atype=rich) 下授权,因此它可以在相同的许可证下被改编、重复使用和分享。 ![用南瓜壳做花架,摆放红色和黄色小花束的烛光中心装饰。](/data/attachment/album/202112/01/113650tayos9syxpvsta94.png "Holiday table") [Martin Cathrae](https://www.flickr.com/photos/34067077@N00), [CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/?ref=ccsearch&atype=rich) 我拿着这张相同的图片,用 [GIMP](https://opensource.com/content/cheat-sheet-gimp) 在上面添加了一些我自己的文字。你可以用 Inkscape 来做同样的事情。 ![用南瓜壳作为花架,放置红色和黄色的小花束的烛光中心作品,图片左上方有“节日快乐”字样。](/data/attachment/album/202112/01/113651nlclfz482twcw1tf.png "Happy Holidays") Don Watkins,[CC BY-SA 4.0](https://creativecommons.org/licenses/by/4.0/) <ruby> 创作共用 <rt> Creative Commons </rt></ruby>提供了大量的图片,在你的下一次 [视频会议](https://opensource.com/article/20/5/open-source-video-conferencing) 期间,可以这些图片作为一个节日背景。 ### 视频和实时流媒体 你也可以把这些图片与你自己的一些图片结合起来,用 [OpenShot](https://opensource.com/article/17/5/using-openshot-video-editor) 视频编辑器创建一个简短的视频剪辑。你可以通过使用 Audacity 录制一个单独的音轨,轻松添加旁白。可以在 Audacity 中添加声音效果,保存到文件中,并导入到 OpenShot 视频编辑器的配乐中。寻找 [合法的背景音乐](https://opensource.com/article/20/1/what-creative-commons) 来添加到你的视频中。 使用 [开源广播软件(OBS)](https://opensource.com/article/21/4/obs-youtube) 来直播你的假期聚会。使用 OBS 可以轻松地为你的朋友和家人呈现引人入胜的假期节目,或者你可以将节目另存为 Matroska 或 MP4 文件以供日后观看。 ### 阅读材料 <ruby> 古腾堡计划 <rt> Project Gutenberg </rt></ruby>是一个用来分享免费节日阅读材料的很好的来源。[狄更斯的《圣诞颂歌》](https://www.gutenberg.org/ebooks/19337) 就是这样一种资源,它可以在网上轻松阅读,也可以下载成 EPUB 或你最喜欢的电子阅读器的格式。你还可以找到免版税的阅读材料,如 [Librivox](https://librivox.org/the-feast-of-lights-by-emma-lazarus/) 的“光的盛宴”,采用 MP3 格式,因此可以下载并在你喜欢的浏览器或媒体播放器中播放。 ### 节日乐趣 节日里最重要的一点是,它们是与朋友和家人一起的放松和欢乐时光。如果你有家人对计算机感到好奇,花点时间与他们分享一些你最喜欢的开源资源。 (题图来自:[creativecommons.org](https://search.creativecommons.org/photos/388c71f3-0419-4e4b-a6a7-2db7e1a8bbc8),作者:Sunny M5) --- via: <https://opensource.com/article/21/11/open-source-holiday-greetings> 作者:[Don Watkins](https://opensource.com/users/don-watkins) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
14,041
Chrome 与 Chromium 有何不同?
https://itsfoss.com/chrome-vs-chromium/
2021-12-02T10:05:00
[ "浏览器", "Chrome", "Chromium" ]
https://linux.cn/article-14041-1.html
![](/data/attachment/album/202112/02/100436xj1u51jhrjuwhjfw.jpg) Chrome 浏览器是最流行的网页浏览器。无论你是否喜欢使用它,Chrome 都能提供良好的用户体验。 尽管它可以在 Linux 上使用,但它不是一个开源的网页浏览器。 而且,如果你喜欢 Chrome 的外观和感觉,但又想使用一个开源的解决方案,Chromium 是一个选择。 但是,Chrome 浏览器不是基于 Chromium 的吗?(是的。)而且,它也是由谷歌开发的吧?(也是的。) 那么,Chrome 和 Chromium 之间有什么区别呢?在这篇文章中,我们将深入了解它们,并介绍一些对它们进行比较的基准。 ### 用户界面 ![Chrome 和 Chromium 在 Zorin OS 16 上并排运行](/data/attachment/album/202112/02/100559cppcz4jff541e646.png) Chrome 和 Chromium 的用户界面非常相似,除了一些细微的区别。 例如,我注意到 Chrome 的系统标题栏和边框一开始就被默认禁用了。相比之下,在我测试的时候,Chromium 默认启用了它们。 你还可以注意到在 Chrome 的地址栏里有一个分享按钮,而在 Chromium 上却没有。 这并不是大的视觉差异,而只是根据现有的功能进行了一系列的 UI 调整。所以,你可以预期它们的用户体验类似,而在底层有所不同。如果你在意用户界面,这两款浏览器应该都很适合你。 ### 开源与专有代码 ![](/data/attachment/album/202112/02/100559sv86z75f762667zm.png) Chromium 是完全开源的,这意味着任何人都可以(根据许可证)按照自己的意愿使用和修改代码。你可以在其 [GitHub 镜像](https://github.com/chromium/chromium) 上查看其源代码。 这就是为什么你会发现有许多 [基于 Chromium 的浏览器](https://news.itsfoss.com/chrome-like-browsers-2021/),如 Brave、Vivaldi 和 Edge。 有这么多的选择,你可以选择你最喜欢的那个。 另一方面,Chrome 在 Chromium 中加入了刚刚专有的代码,使 Chrome 成为了专有浏览器。例如,人们可以复刻 Brave,但不能复刻谷歌 Chrome,而限制使用其中的谷歌特定代码/工作。 对于终端用户来说,开源与否并不影响用户体验。然而,对于一个开源项目,你可以得到更多的透明度,而不需要依靠公司来沟通他们打算改变什么,以及他们在浏览器上做什么。 所以,是的,如果你不喜欢专有代码,Chromium 就是你的选择。 ### 功能差异 谷歌不希望其竞争对手拥有类似的能力,这并不奇怪。因此,谷歌一直在 [锁定 Chromium 并在其中禁用了很多谷歌特有的能力](https://news.itsfoss.com/is-google-locking-down-chrome/)。 因此,你会发现这两个浏览器的能力有一些差异。 不仅如此,由于 Chromium 是开源的,你可能会注意到一些不便之处。别担心,我将在下面指出其中的关键差异。 | Chrome | Chromium | | --- | --- | | 有签到和同步功能 | 无签到和同步功能 | | 支持媒体编解码器以使用 Netflix | 需要手动安装编解码器 | 对于初学者来说,在 Chromium 中不再能使用由谷歌支持的登录/同步功能。它曾经支持签到和同步,直到谷歌决定将其从开源项目中删除。 接下来,Chrome 内置了对高质量媒体编解码器的支持。因此,你可以加载来自 Netflix 的内容。但是,在 Chromium 中没有这些。 ![Netflix 在 Chromium 中默认不能工作](/data/attachment/album/202112/02/100600p4jwvh2hxj723hjr.png) 从技术上讲,Chromium 并不包括 *Widevine 内容解密模块*。因此,你需要手动安装所需的编解码器,以使大部分东西都能工作。 不过,你在这两个浏览器上你都可以播放苹果音乐等平台的内容,应该不会有任何问题。 ### 安装及最新更新 你可以在几乎任何平台上安装 Chrome。Linux 也不例外。只需前往其官方网站,抓取 DEB/RPM 包即可快速安装。安装后的应用程序也会自动更新。 ![](/data/attachment/album/202112/02/100601qmgu1kjgmm1tp021.png) 有几个平台上安装 Chromium 并不那么简单。曾经有一段时间,一些 Linux 发行版将 Chromium 作为默认浏览器。那是过去的日子了。 即使在 Windows 上,Chromium 的安装和更新也不像 Chrome 那样顺利。 在 Linux 上,安装 Chromium 则完全是另一回事。像 Ubuntu 这样的流行发行版把它打包成一个沙盒式的 Snap 应用程序。 即使你试图用终端安装它,希望能从 APT 库中得到它,但它又是一个 Snap。 ![](/data/attachment/album/202112/02/100601vpn1ncn2z722vop8.png) 使用 Snap 软件包,你可能会面临与你的自定义桌面主题相融合的问题。Snap 应用程序的启动时间也会更长。 ![](/data/attachment/album/202112/02/100602byuyrwra91orh911.png) 而且,如果你构建它并手动安装 Chromium,你就得手动更新它。 ### 隐私角度 Chrome 对大多数用户来说应该足够好了。但是,如果你担心你的隐私,Chrome 会追踪使用信息和一些与浏览有关的信息。 最近,[谷歌推出了一个新的 Chrome API](https://www.forbes.com/sites/zakdoffman/2021/10/02/stop-using-google-chrome-on-windows-10-android-and-apple-iphones-ipads-and-macs/),可以让网站检测到你什么时候闲着,什么时候不闲着。虽然这是一个巨大的隐私问题,但并不是唯一的问题。 谷歌不断试验新的追踪用户的方法;例如,正如 [EFF](https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea) 所指出的那样,谷歌的 FLoC 实验并不受欢迎。 从技术上讲,他们声称他们想增强用户的隐私,而同时仍然提供广告机会。然而,就目前而言,这是一个不可能实现的任务。 相比之下,Chromium 在隐私方面的表现应该要好得多。然而,如果你讨厌你的浏览器中有任何与谷歌有关的东西,即使是最轻微的遥测,你应该试试 [UnGoogled Chromium](https://github.com/Eloston/ungoogled-chromium)。 它是 Chromium,但没有任何谷歌组件。 ### 浏览器性能 有各种各样的浏览器基准,可以让你了解到一个浏览器处理任务的能力如何。 考虑到网站上的高级网站应用和资源密集型的 JavaScript,如果一个网页浏览器的性能不好,当你打开许多活动的标签时,你的体验就会明显很糟糕。 [JetStream 2](https://webkit.org/blog/8685/introducing-the-jetstream-2-benchmark-suite/) 和 [Speedometer 2](https://webkit.org/blog/8063/speedometer-2-0-a-benchmark-for-modern-web-app-responsiveness/) 是两个流行的基准,可以给你处理各种任务和响应能力的性能估计。 除此之外,我还试用了 [Basemark Web 3.0](https://web.basemark.com/),它也是测试各种指标并给你一个综合分数。 ![](/data/attachment/album/202112/02/100602p9nz0rert9i49uem.png) 总体而言,Chrome 在此获胜。 但是,值得注意的是,在运行浏览器时,你的系统资源和后台进程会对性能产生不同的影响。因此,也要考虑到这一点。 ### 你应该选择哪个? 之所以存在对浏览器的选择,是因为用户喜欢不同的东西。Chrome 提供了一个良好的功能集和用户体验。如果你以某种形式使用由谷歌提供的服务,Chrome 是一个简单的推荐。 然而,如果你担心隐私和专有代码,Chromium 或 UnGoogled Chromium,或任何其他基于 Chromium 的浏览器,如 Brave,可以是一个不错的选择。 这就是我在比较 Chrome 和 Chromium 时的全部看法。我愿意接受你的意见。评论区都是你的。 --- via: <https://itsfoss.com/chrome-vs-chromium/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Google Chrome is the most popular web browser. No matter whether you prefer to use it, Chrome manages to offer a good user experience. Even though it is available for Linux, it is not an open-source web browser. And, if you need the look and feel of Google Chrome but want to use an open-source solution, Chromium can be your answer. But isn’t Google Chrome based on Chromium? (that’s a Yes.) And, it’s also developed by Google? (Also, Yes.) So, what are the differences between Chrome and Chromium? The major difference is that Chromium is the open source project and Chrome, Edge, Brave and many other web browsers are based on it. Unlike Chrome, Chromium doesn't have easy to install binaries available and the Google's account sync option is missing here. Altogether, Chrome is the mainstream, end-user ready product. In this article, we shall take an in-depth look at both of them and compare them while presenting some benchmarks. ## User Interface ![chrome chromium ui](https://itsfoss.com/content/images/wordpress/2021/11/chrome-chromium-ui.png) The user interfaces for both Google Chrome and Chromium remain very similar, with minor noticeable differences. For instance, I noticed that the system title bar and borders were disabled by default for Google Chrome out of the box. In contrast, it was enabled by default for Chromium at the time of my tests. You can also notice a share button in the address bar of Google Chrome, which is absent on Chromium. It isn’t a big visual difference, but just a set of UI tweaks as per the available features. So, yes, you can expect a similar user experience with under-the-hood tweaks. If you are in for the UI, both the browsers should suit you well. ## Open-Source & Proprietary Code ![open source proprietary](https://itsfoss.com/content/images/wordpress/2021/11/open-source-proprietary.png) Chromium is entirely open-source, meaning anyone can use and modify the code to their heart’s intent. You can check out its source code on its [GitHub mirror](https://github.com/chromium/chromium?ref=itsfoss.com). This is why you will find many [Chromium-based browsers](https://news.itsfoss.com/chrome-like-browsers-2021/?ref=itsfoss.com) available such as Brave, Vivaldi and Edge. You end up getting so many choices, so you can choose what you like the best. On the other hand, Google Chrome adds proprietary code to Chromium, making Chrome a proprietary browser. For example, one can fork Brave, but one cannot fork Google Chrome, restricting the usage of their Google-specific code/work. For end-users, the license does not affect the user experience. However, with an open-source project, you get more transparency without relying on the company to communicate what they intend to change and what they’re doing with the browser. So, yes, if you’re not a fan of proprietary code, Chromium is the answer. ## Feature Differences It’s no surprise that Google does not want its competitors to have similar capabilities. So, Google has been [locking up Chromium and disabling a lot of Google-specific abilities](https://news.itsfoss.com/is-google-locking-down-chrome/?ref=itsfoss.com). Hence, you will find some differences in capabilities between both browsers. Not just limited to that, but because Chromium is open-source, you may notice some inconvenience. Fret not; I’ll point out the crucial differences below: Google Chrome | Chromium | Sign-in and Sync Available | No Sign-in and Sync | Media codec support to use Netflix | Manual codec installation is required | For starters, the Google-powered sign-in/sync feature is no longer available in Chromium. It supported sign-in and sync until Google decided to remove it from the open-source project. Next, Google Chrome comes with built-in support for high-quality media codecs. So, you can load up content from Netflix. But, it won’t work with Chromium. ![chromium netflix](https://itsfoss.com/content/images/wordpress/2021/11/chromium-netflix.png) Technically, Chromium does not include the *Widevine Content Decryption module*. So, you will have to install the required codecs manually to make most of the things work. However, you should not have any issues playing content from platforms like Apple Music and others on both browsers out of the box. ## Installation & Availability of Latest update You can install Google Chrome on virtually any platform. Linux is not an exception. Just head to its official website and grab the DEB/RPM package to install it quickly. The installed application also gets updated automatically. ![google chrome version](https://itsfoss.com/content/images/wordpress/2021/11/google-chrome-version.png) Installing Chromium is not that straightforward on several platforms. There was a time when some Linux distributions included Chromium as the default browser. Those were the days of the past. Even on Windows, Chromium installation and update is not as smooth as Chrome. On Linux, it’s entirely a different story for installing Chromium. Popular distribution like Ubuntu packages it as a sandboxed Snap application. Even if you are trying to install it using the terminal, hoping that you would get it from the APT repositories, it’s Snap again. Some distributions like Linux Mint have disabled Snap, so you can use APT as usual. You can [enable the support](https://itsfoss.com/enable-snap-support-linux-mint/) for it if you prefer. ![install chromium](https://itsfoss.com/content/images/wordpress/2021/11/install-chromium.png) With the Snap package, you may face issues with blending in with your custom desktop theme. Snap applications take longer to start as well. ![chromium version](https://itsfoss.com/content/images/wordpress/2021/11/chromium-version.png) And, if you proceed to build it and install Chromium manually, you will have to update it manually. ## The Privacy Angle Google Chrome should be good enough for most users. However, if you are worried about your privacy, Google Chrome tracks usage info and some browsing-related information. Recently, [Google introduced a new Chrome API](https://www.forbes.com/sites/zakdoffman/2021/10/02/stop-using-google-chrome-on-windows-10-android-and-apple-iphones-ipads-and-macs/?ref=itsfoss.com) that lets sites detect when you are idle and when you are not. While this is a massive privacy concern, it isn’t the only thing. Google constantly experiments with new ways of tracking users; for instance, Google’s FLoC experiment wasn’t well-received, as pointed out by [EFF](https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea?ref=itsfoss.com). Technically, they claim that they want to enhance users’ privacy while still providing advertising opportunities. However, that is one impossible task to achieve as of now. In comparison, Chromium should fare way better concerning privacy. However, if you hate anything Google-related in your browser, even the slightest telemetry, you should try [UnGoogled Chromium](https://github.com/Eloston/ungoogled-chromium?ref=itsfoss.com) instead. It is Chromium, but without any Google components. ## Browser Performance There are a variety of browser benchmarks that give you an idea of how well a browser can handle tasks. Considering the advanced web applications and resource-intensive JavaScript found on websites, if a web browser does not perform well, you will get a noticeably bad experience when you dabble with many active tabs. [JetStream 2](https://webkit.org/blog/8685/introducing-the-jetstream-2-benchmark-suite/?ref=itsfoss.com) and [Speedometer 2](https://webkit.org/blog/8063/speedometer-2-0-a-benchmark-for-modern-web-app-responsiveness/?ref=itsfoss.com) are two popular benchmarks that give you a performance estimate of handling various tasks and responsiveness, respectively. In addition to that, I also tried out [Basemark Web 3.0](https://web.basemark.com/?ref=itsfoss.com), which also tests a variety of things and gives you an aggregate score. ![chrome chromium benchmarks 1](https://itsfoss.com/content/images/wordpress/2021/11/chrome-chromium-benchmarks-1.png) Overall, Google Chrome wins here. But, it is worth noting that your system resources and background processes while running a browser will affect performance differently. So, take that into account as well. ## What should you choose? The choices for browsers exist because users prefer different things. Google Chrome offers a good feature set and user experience. If you use Google-powered services in some form, Google Chrome is an easy recommendation. However, if you are concerned about privacy practices and proprietary code, Chromium or UnGoogled Chromium, or any other Chromium-based browser like Brave can be a good pick. That’s all I had in mind when debating Chrome and Chromium. I am open to receive your views now. The comment section is all yours.
14,042
最佳 Linux 桌面 DAW(数字音频工作站)
https://itsfoss.com/best-daw-linux/
2021-12-02T12:38:52
[ "DAW", "音乐" ]
https://linux.cn/article-14042-1.html
![](/data/attachment/album/202112/02/123844cydiigpj23zgi7z7.jpg) <ruby> 数字音频工作站 <rt> Digital Audio Workstation </rt></ruby>(DAW)可以让你录音、混音和制作音乐。对于商业用途,有几个主流的选择可以考虑,它们通常被认为是行业标准。 像 Steinberg 的 Nuendo/Cubase、ProTools、Ableton Live 和 FL Studio 这样成熟的音乐 DAW 是最流行(也是最昂贵)的解决方案。然而,它们并不能用于 Linux。 因此,当用在 Linux 上时,你只能根据现有的选项做出不同的选择。而在这里,我的目的是帮助你找出 Linux 上最好的音乐 DAW。 ### 在使用 Linux 上的 DAW 之前要记住的事情 尽管你可以达到与 Windows/MacOS 系统相同的效果,但在选择使用 Linux 的 DAW 之前,你应该知道一些要点。 如果你是专业人士,并且使用过 Linux,你可能已经知道了这些。但是,对于新的 Linux 用户,这可以帮助你做出决定: * 许多音频接口没有正式支持 Linux。所以,你可能要在开始之前检查一下兼容性和音频设置过程。 * 流行的音频插件可能无法直接工作。你必须得寻找替代品或尝试使用 Wine(这是一个耗时的过程)。 * 即插即用的情况可能不存在。各种任务都需要手动设置。 总的来说,在 Linux 中使用 DAW 时,有一些先决条件。它可能不能简单地安装然后就能开始制作音乐。所以,在选择 Linux 作为 DAW 的首选平台之前,你需要了解这些。 请注意,有几个 [可用于 Linux 的音频编辑器](https://itsfoss.com/best-audio-editors-linux/),但不是所有的都可以作为一个成熟的 DAW 使用。 现在你知道了这些注意事项,让我提一下目前最好的 Linux DAW。 > > 非 FOSS 警报! > > > 这里提到的应用并不全是开源的。它们被列在这里是因为它们在 Linux 上可用,而这篇文章的重点是 Linux。 > > > 虽然可用于 Linux 的 DAW 可能有许多,但为了确保你得到最好的硬件/软件兼容性,以及易于使用的界面,我们将我们的列表限制在流行的选项上。 ### 1、Ardour ![](/data/attachment/album/202112/02/123852ki3qbslpskckf9r2.png) [Ardour](https://ardour.org/) 是最流行的开源 DAW,可用于 Linux。它也可用于 Windows 和 macOS。 它是音乐家、音频工程师和作曲家的一个合适选择。你可以获得编辑乐谱和录制/混合歌曲的所有基本能力。 它自带几个插件支持。但是,你需要通过在插件管理器中手动添加它们到混音器中。另外,你可以选择通过指定路径来添加外部 VST3 插件。如果你想从中提取音频或同步,Ardour 还支持视频时间线。 #### 在 Linux 中安装 Ardour 与其他付费版 DAW 不同,你不需要支付高昂的价格就可以使用它。你所需要做的就是购买一个低至 1 美元/月的订阅,只要你的订阅是有效的,你就可以继续访问这个程序和它的更新。 如果你对订阅不感兴趣,你可以选择一次性付款,这可以让你获得小版本更新和下一个主要版本(取决于你支付的金额)。 最重要的是,如果你喜欢测试即将到来的功能和改进,你还可以访问其开发(或每日)构建版本。 对于 Linux 发行版,它提供了一个 `.run` 文件,你可以轻松地从终端启动。 ### 2、LMMS ![](/data/attachment/album/202112/02/123853ki0loy0zyis00p8h.png) [LMMS](https://lmms.io/lsp/) 是一个自由开源的 DAW,可用于 Linux 和其他平台。 与其他一些 DAW 相比,LMMS 在专业人员所需的专业方面可能有所欠缺。 然而,如果你刚刚开始创作音乐,或者需要一些无需购买/订阅就可以使用的东西,它应该可以满足你的一些功能需求。换句话说,它是一个合适的歌曲编辑 DAW。 如果你是从另一个平台上的 DAW 迁移来的,它的用户界面可能不太容易熟悉。但是,当你习惯了它,它就很容易使用了。 它还支持钢琴音符标签,以帮助你获得音乐制作体验。 #### 在 Linux 中安装 LMMS 你可以选择下载一个 AppImage 文件,它可以在你选择的任何 Linux 发行版上工作。它的配置相当简单,所以你只需要指定一个工作目录就可以开始了。 ### 3、Bitwig Studio ![](/data/attachment/album/202112/02/123853zku25kfx5a6ui2u0.png) [Bitwig Studio](https://www.bitwig.com/) 是流行的主流音乐 DAW 之一,也支持 Linux。与本列表中的其他 DAW 相比,Bitwig 提供了更好的跨平台支持和硬件集成。 即使你可能坚持使用 Linux 进行音乐制作,但拥有跨平台的支持,以便在你出门在外也可以继续你的工作,对一些人来说这也是一个重要的因素。 Bitwig 包括各种创意工具来处理音频文件和信号。所以,它完全可以满足专业要求。 ### 在 Linux 中安装 Bitwig Studio 它提供了一个传统的 DEB 包用于安装。你可以在“演示模式”下免费使用它,但它不允许你保存和导出任何东西。Bitwig Studio 在 [Flathub](https://flathub.org/apps/details/com.bitwig.BitwigStudio) 上还有一个 [Flatpak](https://itsfoss.com/what-is-flatpak/) 包。 要解锁所有的功能,你需要以 **$399** 的价格购买它。 ### 4、REAPER ![](/data/attachment/album/202112/02/123854to93nh7znenyadsh.png) [Reaper](https://www.reaper.fm) 是一个可用于 Linux 的经济型 DAW。它提供了一个简单的用户界面和所有的基本功能。 和 Bitwig Studio 相比,它可能没有提供很多开箱即用的插件和功能,但它应该足以满足大多数通常的需求,如调制、自动化、使用 VST 插件等等。 尽管我没有亲自使用过它,但 Reaper 声称它是高度可定制的,并提供了与各种硬件的良好兼容性。 #### 在 Linux 中安装 Reaper 与其他选择不同,Reaper 提供了一个 tar 包,你需要解压和安装。它包括一个脚本文件。因此,当你解压后,在该文件夹中打开终端或在终端中进入该文件夹,然后用以下命令执行该脚本: ``` ./install-reaper.sh ``` 当你安装它时,该脚本也会生成一个用于卸载的脚本。所以,在安装时一定要仔细选择文件夹,并确保在需要时能找到它。 在你需要购买它之前,你可以没有任何限制的免费使用它,最长可达 60 天。所以,如果你想在购买 DAW 之前彻底测试一下,我觉得这是一件非常好的事情。 个人使用的费用是 **$60**,如果你需要用于商业用途,则需要 **$225**。 ### 总结 不幸的是,找不到太多可用于 Linux 的 DAW 。你可以尝试用 Wine 来运行一些流行的音乐 DAW,但我不确定成功率有多少。 无论是哪种情况,这里提到的这些对于大多数用户来说应该是绰绰有余了。 你喜欢哪种 DAW 用于音乐制作?请在下面的评论中告诉我你的想法。 --- via: <https://itsfoss.com/best-daw-linux/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) A Digital Audio Workstation (DAW) lets you record, mix, and make music. For commercial usage, there are several mainstream options to consider, which are often regarded as industry-standard. Full-fledged music DAWs like Steinberg’s Nuendo/Cubase, ProTools, Ableton Live, and FL Studio are the most popular (and expensive) solutions. However, they are not available for Linux. As a result, when it comes to Linux, you will have to make a different set of choices as per the available options. And, here, I aim to help you point out the best music DAWs for Linux. **Please note that while I enjoy singing cover songs and recording them, my first-hand experience with DAWs and audio editors is limited.**## Things to Keep in Mind Before Using a DAW for Linux Even though you can achieve the same result as you would on a Windows/macOS machine, there are a few pointers that you should know before you decide to use a DAW for Linux. If you are a professional and have used Linux, you may be already aware of them. But, for new Linux users, this could help you make a decision: - Many audio interfaces do not officially support Linux. So, you may want to check the compatibility and the audio setup process before starting. - Popular audio plugins may not work directly. You will have to look for alternatives or try using Wine (which is a time-consuming process). - Plug and play may not be the case. Manual setup is needed for a variety of tasks Overall, there are some prerequisites when it comes to using a DAW in Linux. It may not be as simple as installing it and getting started making music. So, you need to be aware of these before choosing Linux as your preferred platform for a DAW. Note that there are several [audio editors available for Linux](https://itsfoss.com/best-audio-editors-linux/), but not all of them can be used as a full-fledged DAW. Now that you know the caveats, let me mention the best Linux DAWs available. **Some applications mentioned here are not open source. They have been included in the context of Linux usage.** **Non-FOSS Warning!**While there could be multiple DAWs available for Linux, to make sure that you get the best hardware/software compatibility along with an easy-to-use interface, we have limited our list to popular options. ## 1. Ardour ![a screenshot of ardour](https://itsfoss.com/content/images/2024/05/Ardour.png) [Ardour](https://ardour.org/?ref=itsfoss.com) is the most popular open-source DAW available for Linux. It is also available for Windows and macOS. It is a suitable option for musicians, audio engineers, and composers. You get all the essential abilities to edit a score, and record/mix a song. It comes with several plugin support out of the box. But, you need to manually add them to the mixer by adding them from the plugin manager. Also, you can choose to add external VST3 plugins by specifying the path for them. Ardour also supports a video timeline if you are looking to extract audio from it or sync. ### Installing Ardour in Linux Unlike any other premium DAWs, you do not need to pay a hefty price to get access to it. All you need to do is get a subscription of as low as $1/month, and you can continue access to the program and its updates as long as your subscription is active. If you are not interested in a subscription, you can choose to opt for one-time payments that should give you access to minor updates along with the next major version (*depending on the amount you pay*). The best thing—you also get access to its development (or nightly) builds if you are fond of testing upcoming features and improvements. For Linux distributions, it provides a .run file, which you can easily start from the terminal. ## 2. LMMS ![a screenshot of lmms](https://itsfoss.com/content/images/wordpress/2021/09/lmms-daw.png) [LMMS](https://lmms.io/download) is a free and open-source DAW available for Linux and other platforms. When compared to some other DAWs, LMMS might fall short on the specialties needed by a professional. However, it should offer some features if you are starting out to create music, or need something without needing to purchase/subscribe to anything. In other words, it is a suitable song editor DAW. If you are coming from another DAW on another platform, the user interface may not be comfortable to get acquainted with. But, it is easy to use when you get used to it. It also supports piano notes labels to help you with your music-making experience. ### Installing LMMS in Linux You get the option to download an AppImage file to work on any Linux distribution of your choice. It is rather easy to configure, so you only need to specify a working directory to get started. ## 3. Bitwig Studio ![a screenshot of bitwig studio](https://itsfoss.com/content/images/wordpress/2021/10/bitwig-studio-linux.png) [Bitwig Studio](https://www.bitwig.com/?ref=itsfoss.com) is one of the popular mainstream music DAWs that also supports Linux. When compared to other DAWs in this list, Bitwig offers better cross-platform support and hardware integration. Even though you may stick to Linux for music production, having cross-platform support to carry on your work where you left is an important criterion for some as well. Bitwig includes a variety of creative tools to manipulate audio files and signals. So, it is perfectly suitable for a professional requirement. ### Installing Bitwig Studio in Linux It offers a traditional DEB package for installation. You can use it for free in a “Demo mode” which does not let you save and export anything. Bitwig Studio is also available as a [Flatpak](https://itsfoss.com/what-is-flatpak/) on [Flathub](https://flathub.org/apps/details/com.bitwig.BitwigStudio?ref=itsfoss.com). To unlock all the features, you need to purchase it for **$399**. ## 4. REAPER ![a screenshot of reaper](https://itsfoss.com/content/images/wordpress/2021/10/reaper-linux.png) [Reaper](https://www.reaper.fm/?ref=itsfoss.com) is an affordable DAW available for Linux. It offers a simple user interface with all the essential features. It may not offer many out-of-the-box plugins and functionalities compared to Bitwig Studio, but it should be good enough for most of the usual needs like modulation, automation, using VST plugins, and more. Even though I haven’t personally used it, Reaper claims that it is highly customizable and offers good compatibility with a variety of hardware. ### Installing Reaper in Linux Unlike other options, Reaper offers a tar archived package that you need to extract and install. It includes a script file. So, once you extract it, open the terminal in that folder or navigate to the folder in the terminal and then execute the script with the following command: `./install-reaper.sh` When you install it, the script generates another script to let you uninstall as well. So, make sure to carefully choose the folder when installing and make sure you can find it when required. You can use it for free without any limitations for up to 60 days before you need to purchase it. So, I’d say that is a pretty good thing if you want to thoroughly test things before purchasing a DAW. The cost for personal use is **$60** and if you need it for commercial use, it will cost you **$225**. ## 5. Waveform ![a screenshot of waveform](https://itsfoss.com/content/images/2024/05/Waveform.png) [Waveform](https://www.tracktion.com/products/waveform-free?ref=itsfoss.com) is yet another popular mainstream DAW available for Linux in its full glory. Compared to several others, Waveform offers an intuitive user experience along with all the essential features. With the pro version, you can unlock more plugins and loop collections that you use to easily make music. Some advanced features like track editing, plugin macros, Melodyne, multi-sampler instrument and arrange tracks are only accessible with the premium upgrade. However, the free version should be enough to give you a head start for a variety of use-cases, excluding full-fledged post-production work. ### Install Waveform in Linux Waveform offers a DEB package. So, you just be able to install it on any Ubuntu-based distribution. For any other Linux distribution, you can utilize the [Flatpak package](https://flathub.org/apps/details/com.tracktion.Waveform?ref=itsfoss.com) available. ## 6. Rosegarden ![a screenshot of rosegarden](https://itsfoss.com/content/images/wordpress/2021/11/rosegarden-daw.png) [Rosegarden](https://www.rosegardenmusic.com/?ref=itsfoss.com) is an interesting DAW, and may not be suitable for everyone. It focuses on helping you compose music, and edit music notations, while offering an easy-to-use interface. If you are working with a MIDI device and want a DAW that is based around a MIDI sequencer, this is for you. But, if you are a singer looking to mix or polish your recordings using VST plugins, you may want to try Reaper instead. ### Installing Rosegarden in Linux Rosegarden should be available in the distribution repositories. You can find it using the software center or just opt for the [Flatpak package](https://flathub.org/apps/details/com.rosegardenmusic.rosegarden?ref=itsfoss.com) suitable for any Linux distro. ## 7. Zrythm ![a screenshot of zrythm](https://itsfoss.com/content/images/2024/05/Zrythm.png) [Zrythm](https://www.zrythm.org/) was a FOSS suggestion by one of our readers, it is an eye-catching DAW that claims to offer limitless automation with the help of automation events. With this, you get access to a wide range of mixing tools, such as FX tracks, MIDI effect, pre/post-fader aux sends, and more. It also has support for major audio plugin formats like LV2, VST2, VST3, AU, CLAP, and JSFX. You can also use the timeline to divide your work neatly into multiple layers in the same track. The free version lets you add up to 25 tracks at a time, with access to a few basic plugins. There are paid plans too with different features being unlocked according to the amount you pay. ### Installing Zrythm in Linux The [official website](https://www.zrythm.org/en/download.html) will let you try out the free version, just download the archive and follow the README instructions (*for Linux*). If that doesn't work for you, then you can get it from the [Flathub store](https://flathub.org/apps/org.zrythm.Zrythm). ## 8. Renoise [Renoise](https://www.renoise.com), created by a small group of dedicated coders, it is a cross-platform DAW that can be used to create production-quality audio without much hassle. Some of its key features include, support for plugins, ReWire compatibility, a novel pattern matrix feature, a capable sampler, and over 26 Native FX effects being pre-installed. Advanced users could also write custom Lua scripts to extend the functionality of Renoise, and the user interface can be completely controlled by a computer keyboard. ### Installing Renoise in Linux There is a free demo available on the [official website](https://www.renoise.com/download) that lets you test out Renoise on platforms like Linux, Windows, and macOS, with a few restrictions in place. ## 9. Tenacity ![a screenshot of tenacity](https://itsfoss.com/content/images/2024/05/Tenacity.png) [Tenacity](https://tenacityaudio.org) is a community-built multi-track audio editor that initially started off as a fork of Audacity, but grew into a proper alternative with many features that set it apart from its base. You can look forward to taking advantage of a modern interface, support for popular audio plugins like VST, LV2 and AU, import/export support for a wide variety of audio formats, 32-bit float audio, and more. ### Installing Tenacity in Linux For Linux, they provide an [AppImage](https://itsfoss.com/use-appimage-linux/) file for easy running. You can get the package of your choice from the [Codeberg repo](https://codeberg.org/tenacityteam/tenacity/releases), which also hosts packages for Windows and macOS. ## 10. Mixbus 10 [Mixbus 10](https://store.harrisonaudio.com/all-products/mixbus-10) is a proprietary DAW that was recently made available. Developed by a known name in the audio production industry, it has been built with Harrison's True Analog Mix Engine (TAME) in mind, and has some really useful features. For starters, there is support for native Dolby Atmos mixing, a dedicated multitrack recorder for live shows, support for unlimited audio and MIDI tracks, 32C Equalizer, and clip launching in real-time. ### Installing Mixbus 10 in Linux As this is a paid tool, you can only check out the demo for free, which has some [bothersome limitations](https://support.harrisonaudio.com/hc/en-gb/articles/18268719120541-What-are-the-Demo-limitations-when-evaluating-Mixbus). In any case, you can get the demo, or the paid plan by visiting the [official website](https://store.harrisonaudio.com/all-products/mixbus-10). ## 11. Audacity ![a screenshot of audacity](https://itsfoss.com/content/images/2024/05/Audacity.png) [Audacity](https://www.audacityteam.org), an audio editor is not technically a DAW, but can come in handy for some of the abilities a DAW has to offer. As a free offering, Audacity is known globally for its adaptability for audio production. It is a cross-platform app that supports popular plugins such as VST3, Nyquist, LADSPA, LV2, and more. You can also make use of various tools such as noise reduction, equalizers, time streching, non-destructive pitch shifting, automatic tempo detection, and cloud saves via audio.com. ### Installing Audacity in Linux You can grab the AppImage file for Linux from the [official website](https://www.audacityteam.org/download/), where there are other packages for Windows and macOS too. ## Honorable Mentions Many of our readers pointed out some exciting choices that you can try on Linux. However, considering that some of them are new, niche-focused, do not offer proper support, lacks several features, or are still in development, I did not add them to the primary list. You can choose to explore them: ## Wrapping Up Unfortunately, you will not find all the popular Digital Audio Workstation options in the music industry available for Linux. You can try running some popular music DAWs using [Wine](https://www.winehq.org), but I’m not sure of the success rate. In either case, the ones mentioned here should be more than enough for the majority of users. *💬 What DAW do you prefer for music production? Let me know your thoughts in the comments below.*
14,044
Vivaldi 5.0 发布!
https://news.itsfoss.com/vivaldi-5-0-release/
2021-12-03T12:34:16
[ "Vivaldi", "浏览器" ]
https://linux.cn/article-14044-1.html
![](/data/attachment/album/202112/03/123416pl0pt3xtzbyxkub1.jpg) > > 对于那些喜欢在桌面和安卓系统上进行定制和增加功能的用户来说,Vivaldi 5.0 是一个令人兴奋的版本。 > > > Vivaldi 是一个基于 Chromium 的网页浏览器,可用于 Linux(及其他平台)。它因其增强功能和多任务特性而广为人知。这使它成为 [Linux 上最好的网页浏览器](https://itsfoss.com/best-browsers-ubuntu-linux/#:~:text=Mozilla%20Firefox&text=Firefox%20is%20the%20default%20web%20browser%20for%20most%20Linux%20distributions.) 之一,特别是对于高级用户来说。 随着 Vivaldi 5.0 的发布(以纪念其 5 周年),它推出了一系列重大功能增加和改进。 让我们来看看 Vivaldi 的新版本有什么特点。 ### Vivaldi 5.0 的新功能 请注意,Vivaldi 除了其用户界面之外大部分是 [开源](https://vivaldi.com/source/) 的。然而,他们倾向于把重点放在 Linux 平台的改进上肯定是件好事。 以下是你可以在 Vivaldi 5.0 发现的变化: #### Vivaldi 主题 ![致谢:Vivaldi 博客](/data/attachment/album/202112/03/123417wp82bm8p9b8bb85b.png) 主题一直是 Vivaldi 最好的功能之一,不仅仅是因为它有各种预装的主题,而是你可以定制你的主题或编辑预装的主题。 它的主题编辑器已经更新,有更多可以定制的选项。你现在可以编辑颜色、边角、背景和设置来定制主题。以前,你必须单独编辑背景图片,而现在新的主题编辑器应该很方便使用。 而且,并不止于此,你已经创建好了你的主题? 现在,你可以使用新的“<ruby> 导出主题 <rt> Export Theme </rt></ruby>”选项轻松地生成一个 ZIP 文件,与任何人分享你的主题。同样地,你也可以导入一个主题。 ![致谢:Vivaldi 博客](/data/attachment/album/202112/03/123419ormhujm5b9mobnmh.png) 更进一步地,你可以把你新设计的主题提交到他们的 [社区画廊](https://themes.vivaldi.net)。你也可以从那里找到其他用户的主题,并安装它们。 #### 新的翻译面板 在 [Vivaldi 4.0 发布时](https://news.itsfoss.com/vivaldi-4-0-release/),他们引入了由 [Lingvanex](https://lingvanex.com) 提供的内置翻译功能。 现在,通过侧边栏中新的“<ruby> 翻译面板 <rt> Translate Panel </rt></ruby>”,你可以快速添加一个文本片段并进行翻译,而无需翻译整个网页。 Vivaldi 的侧面板以提高多任务处理能力而闻名,而这个功能的增加应该会加强这一点。 如果你想翻译更多的片段呢?当然,你肯定不想一直继续复制粘贴它们! 对于这个特殊的需求,Vivaldi 还引入了一个“<ruby> 一步自动翻译 <rt> one-step auto-translate </rt></ruby>”选项。一旦启用该选项,突出显示你在网页中想要的文本,它的翻译将立即出现在侧面板上。这听起来很酷! #### 在弹出式窗口中查看下载 ![致谢:Vivaldi博客](/data/attachment/album/202112/03/123423uvv1s7uhlsefs1k1.png) 虽然 Vivaldi 在很多方面都令人印象深刻,但对于用户来说,其关注下载进度的能力并不那么直观。你必须到侧面板(或“下载”)中去检查下载的进度。 相比之下,在其他网页浏览器中,你可以在你的扩展程序旁边找到一个按钮。 在 Vivaldi 5.0 中,你终于可以使用地址栏中的一个按钮来检查下载进度,点击该按钮将打开一个弹出窗口来显示你的下载进度。 #### 为安卓用户提供的增强功能 Vivaldi 的安卓版也有了重大更新和期待已久的功能。 安卓用户现在可以使用桌面用户已经在使用的 “<ruby> 两级标签堆栈 <rt> Two-level Tab Stacks </rt></ruby>”。 也许,这对任何安卓手机浏览器来说都是第一次! 对于那些不知道的人来说,这个功能有助于将标签页组合在一起,产生两级。这有助于避免多个标签挤在一起。 ![致谢:Vivaldi](/data/attachment/album/202112/03/123425knzcqvqg4ecj962e.png) 可配置的“<ruby> 标签栏 <rt> Tab Bar </rt></ruby>”现在多了两个选项。例如,背景标签上用于关闭的“X”按钮可以被移除(为更多的标签腾出空间)。用户还可以将标签简单地显示为收藏夹,因此没有标题,也没有“X”按钮。 因此,你有很多管理你的安卓移动设备上的标签的方法。 虽然这很有趣,但我不太确定对用户来说,在小屏幕上掺杂两级标签堆栈的感觉如何。 平板电脑和 Chromebook 用户也将享受到用户界面更新的待遇。平板电脑和 Chromebook 用户现在可以使用经典的“<ruby> 侧面板 <rt> Side Panel </rt></ruby>”,以组织浏览器的布局,尽量减少杂乱。 这一功能的增加可以使 Vivaldi 成为平板电脑用户的有力选择。 #### 其他改进 除了关键的亮点之外,你可以发现速度的改进和错误的修复。 要探索更多,你可以查看其 [桌面版](https://vivaldi.com/blog/vivaldi-5-0-desktop-themes-translate-panel/) 和 [安卓版](https://vivaldi.com/blog/vivaldi-on-android-gets-worlds-first-two-rows-of-mobile-browser-tabs/) 的官方博客文章。 ### 总结 Vivaldi 无疑是一个会关注其用户需求和网页体验的浏览器。对于喜欢更多定制和功能的用户来说,最新的版本听起来很令人感兴趣。 你可以从官方网站下载可用的 DEB/RPM 包并进行安装。 * [下载 Vivaldi 5.0](https://vivaldi.com/download/) --- via: <https://news.itsfoss.com/vivaldi-5-0-release/> 作者:[Rishabh Moharir](https://news.itsfoss.com/author/rishabh/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Vivaldi is a Chromium-based web browser available for Linux (and other platforms). It is popularly known for its enhanced functionalities and multitasking features. This makes it one of the [best web browsers available on Linux](https://itsfoss.com/best-browsers-ubuntu-linux/?ref=news.itsfoss.com#:~:text=Mozilla%20Firefox&text=Firefox%20is%20the%20default%20web%20browser%20for%20most%20Linux%20distributions.), especially for power users. With the Vivaldi 5.0 release (marking its 5th anniversary), you can expect significant feature additions and improvements. Let us take a look at what Vivaldi’s new release has to offer. ## What’s New in Vivaldi 5.0? Note that Vivaldi is mostly open-source ([source](https://vivaldi.com/source/?ref=news.itsfoss.com)), except its UI. However, they tend to focus on improvements on the Linux platform, which is a good thing. Here’s what you can expect with Vivaldi 5.0: ### Vivaldi Themes ![](https://news.itsfoss.com/content/images/wordpress/2021/12/Theme-v2_Editor-1024x576.png) Themes have been one of the best features of Vivaldi, not just because you get to choose from a variety of pre-installed ones. It’s because you get to customize your theme or edit pre-installed ones. The theme editor has been updated with more options to play around. You can now edit the colors, corner-rounding, background, and settings to customize the theme. Previously, you had to edit the background image separately. So, the new theme editor should be convenient to use. And, this doesn’t stop here. Done creating your themes? Now, you can easily share your themes with anyone using the new **Export Theme** option that generates a ZIP file. Similarly, you can import themes as well. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/vivaldi-5-export-1024x576.png) To go even further, you can submit your newly designed themes to their [community gallery](https://themes.vivaldi.net/?ref=news.itsfoss.com). You can also find themes from other users and install them for yourself. ### A New Translate Panel With [Vivaldi 4.0 release](https://news.itsfoss.com/vivaldi-4-0-release/), they introduced a built-in translate feature powered by [Lingvanex](https://lingvanex.com/?ref=news.itsfoss.com). Now, with the new **Translate Panel** in the sidebar, you can quickly add a snippet of text and translate it without translating the entire webpage. Vivaldi’s side panels are known for improving multitasking capabilities. And, this feature addition should enhance that. What if you want to translate more snippets? Surely, you can’t just go on copy-pasting them! For this particular reason, Vivaldi has also introduced a **one-step auto-translate** option. Once the option is enabled, highlight the text you want in a webpage, and its translation will appear in the side panel right away. Well, that sounds cool! ### View Downloads in a Pop-out ![](https://news.itsfoss.com/content/images/wordpress/2021/12/Download-popup-1024x576.png) While Vivaldi has been impressive on many grounds, the ability to keep an eye on downloads was not as intuitive for every user. You had to go to the side panel (or Downloads) to check the progress of a download. In comparison, you get a button right next to your extensions in other web browsers. With Vivaldi 5.0, you can finally check download progress using a button in the address bar that would open a pop-up to show your downloads. ### Enhancements for Android Users The Android version of Vivaldi has also received significant updates and much-awaited features. Android users can now make use of **Two-level Tab Stacks** that have been available for desktop users. Perhaps, a first for any Android mobile browser! For those unaware, this feature helps group tabs together, producing a second level. This helps avoid cramming multiple tabs. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/android_double-line-tab-stack-new-blog-1024x576.png) The configurable **Tab Bar** now comes with two more options. For instance, the **X** button on background tabs that’s used for closing can be removed (freeing up space for more tabs). Users also can show tabs simply as favicons, so no titles and no X button. So, you have got plenty of options to manage your tabs on your Android mobile device. While this is interesting, I am not too sure how it would feel like dabbling with a two-level tab stack on a small screen for a user. Tablet and Chromebook users are in for a treat as the UI has undergone a refresh. The classic **Side Panel** is now available to tablet and Chromebook users to organize the browser layout and minimize clutter. This feature addition could make Vivaldi a powerful choice for tablet users. ### Other Improvements In addition to the key highlights, you can expect speed improvements and bug fixes. To explore more, you can check out its [official blog post for desktop](https://vivaldi.com/blog/vivaldi-5-0-desktop-themes-translate-panel/?ref=news.itsfoss.com) and [Android](https://vivaldi.com/blog/vivaldi-on-android-gets-worlds-first-two-rows-of-mobile-browser-tabs/?ref=news.itsfoss.com). ## Wrapping Up Vivaldi is a browser that certainly pays attention to its users’ needs and web experience. The latest release sounds exciting for users who prefer more customization and features. You can download the available DEB/RPM package from the official website and get it installed. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,045
用 Flatpak 在 Linux 上安装应用
https://opensource.com/article/21/11/install-flatpak-linux
2021-12-03T13:36:01
[ "Flatpak" ]
https://linux.cn/article-14045-1.html
> > Flatpak 简化了 Linux 上应用的安装。 > > > ![](/data/attachment/album/202112/03/133555dxzijlzjp0ibglk0.jpg "Flatpak") 计算机应用由许多小文件组成,它们被链接在一起以执行一系列的任务。因为它们以“应用”的形式出现,在菜单或桌面上有彩色的图标,我们大多数人认为应用是一个单一的、几乎是有形的东西。在某种程度上,这样想是令人欣慰的,因为它们感觉是可以管理的。如果一个应用实际上是散落在你的计算机上的数百个小库和资源文件的组合,那么应用在哪里?撇开存在危机不谈,当一个应用需要一个版本的库,而另一个应用需要一个不同的版本时,会发生什么? 在云计算的世界里,[容器](https://opensource.com/article/21/7/linux-podman) 正变得越来越流行,因为它们为应用提供了隔离和整合。你可以在一个“容器”中安装一个应用需要的所有文件。这样一来,它的库就不会受到其他应用的影响,它所占用的内存也不会将数据泄露到另一个内存空间。所有的东西最后都感觉非常像一个单一的、几乎是 *有形的* 东西。在 Linux 桌面上,提供了类似的技术的 Flatpak,是一个跨发行版、无守护进程、去中心化的应用交付系统。 ### 在 Linux 上安装 Flatpak 你的 Linux 系统可能已经安装了 Flatpak。如果没有,你可以从你的包管理器中安装它: 在 Fedora、Mageia 和类似的发行版上: ``` $ sudo dnf install flatpak ``` 在 Elementary、Mint 和其他基于 Debian 的发行版上: ``` $ sudo apt install flatpak ``` 在 Slackware 上,Flatpak 可以从 [SlackBuilds.org](http://slackbuilds.org) 获得。 ### 选择一个 Flatpak 仓库 你可以通过在你的发行版的软件中心(如 GNOME 上的“软件”)添加一个 Flatpak 仓库,将一个应用安装为 Flatpak。Flatpak 是一个去中心化的系统,意味着任何开发软件的人都可以托管他们自己的仓库。尽管如此,在实践中,[Flathub](http://flathub.org) 是 Flatpak 格式的最大和最流行的应用集合。要将 Flathub 添加到 GNOME “<ruby> 软件 <rt> Software </rt></ruby>” 或者 KDE “<ruby> 发现 <rt> Discover </rt></ruby>” 中,请浏览 <https://flatpak.org/setup> ,找到适合你的发行版的说明,从第二步开始,或者直接下载 [Flatpakrepo](https://flathub.org/repo/flathub.flatpakrepo) 文件。根据你的网络情况,你的软件中心可能需要几分钟的时间来与 Flathub(或另一个 Flatpak 仓库)同步。Flathub 有很多软件,但你的系统上有多少个 Flatpak 仓库是没有限制的,所以如果你发现一个有你想尝试的软件,不要害怕添加一个新的仓库。 ![Software Repositories](/data/attachment/album/202112/03/133602cdu2u90t0pbd2z9k.jpg "Software Repositories") 如果你喜欢在终端工作,你可以用 `flatpak` 命令直接添加到仓库: ``` $ flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo ``` ### 安装一个应用 只要你在软件中心添加了 Flatpak 仓库,你就可以像往常一样浏览应用了。 ![GNOME Software](/data/attachment/album/202112/03/133603fkh6o67i2rpokwh2.jpg "GNOME Software") 点击一个看起来很吸引人的应用,阅读它,当你准备好时点击**安装**按钮。 ### 在终端中安装 flatpak 如果你喜欢在终端工作,你可以把 Flatpak 当作一个专门的包管理器。你可以使用 `flatpak search` 命令来搜索一个应用程序: ``` $ flatpak search paint Name Description Application ID CorePaint A simple painting tool org.cubocore.CorePaint Pinta Edit images and paint digitally com.github.PintaProject.Pinta Glimpse Create images and edit photographs org.glimpse_editor.Glimpse Tux Paint A drawing program for children org.tuxpaint.Tuxpaint Krita Digital Painting, Creative Freedom org.kde.krita ``` 用 `flatpak install` 安装: ``` $ flatpak install krita ``` 安装后,应用就会与系统中的所有其他应用一起出现在你的应用菜单或活动页上。 ### 应用变得简单 Flatpak 通过消除版本冲突,可以使用户轻松安装应用。他们通过在自托管的平台或像 Flathub 这样的公共平台上只需要针对一种软件包格式提供应用,使分发软件变得简单。我在 Fedora Silverblue、CentOS 和 Slackware 上使用 Flatpak,我无法想象现在没有它的生活。在你的下一个应用安装中试试 Flatpak 吧! --- via: <https://opensource.com/article/21/11/install-flatpak-linux> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Computer applications consist of many small files that are linked together to perform a set of tasks. Because they get presented as "apps," colorful icons in the menu or on a desktop, most of us think of applications as a single, almost tangible thing. And in a way, it's comforting to think of them that way because they feel manageable that way. If an application is actually the amalgamation of hundreds of little library and asset files scattered throughout your computer, where's the application? And existential crisis aside, what happens when one application needs one version of a library while another application demands a different version? In the world of cloud computing, [containers](https://opensource.com/article/21/7/linux-podman) are becoming more and more popular because they offer isolation and consolidation for applications. You can install all the files an application needs in a "container." That way, its libraries stay out of the way of other applications, and the memory it occupies doesn't leak data into the memory space of another. Everything ends up feeling very much like a single, almost tangible *thing*. On the Linux desktop, Flatpak, a cross-distribution, daemon-less, decentralized application delivery system, provides a similar technology. ## Install Flatpak on Linux Your Linux system may already have Flatpak installed. If not, you can install it from your package manager: On Fedora, Mageia, and similar distributions: `$ sudo dnf install flatpak` On Elementary, Mint, and other Debian-based distributions: `$ sudo apt install flatpak` On Slackware, Flatpak is available from [SlackBuilds.org](http://slackbuilds.org). ## Select a Flatpak repo You can install an application as a Flatpak by adding a Flatpak repository to your distribution's software center (such as **Software** on GNOME). Flatpak is a decentralized system, meaning anyone developing software can host their own repository. Still, in practice, [Flathub](http://flathub.org) is the biggest and most popular aggregation of applications in the Flatpak format. To add Flathub to **GNOME Software** or **KDE Discover**, navigate to flatpak.org/setup and find the instructions for your distribution and start with step #2, or just download the [Flatpakrepo](https://flathub.org/repo/flathub.flatpakrepo) file. Depending on your network, it may take a few minutes for your software center to synchronize with Flathub or another Flatpak repository. Flathub has a lot of software, but there's no limit to how many Flatpak repositories you have on your system, so don't be afraid to add a new repository if you find one that has the software you want to try. ![Software Repositories Software Repositories](https://opensource.com/sites/default/files/uploads/repo.jpg) (Seth Kenlon, CC BY-SA 4.0) If you prefer to work in the terminal, you can add repositories directly with the `flatpak` command: ``` $ flatpak remote-add --if-not-exists flathub \ https://flathub.org/repo/flathub.flatpakrepo ``` ## Install an application As long as you've added a Flatpak repository to your software center, you can browse through applications as usual. ![GNOME Software GNOME Software](https://opensource.com/sites/default/files/uploads/software.jpg) (Seth Kenlon, CC BY-SA 4.0) Click on an application that looks appealing, read up on it, and click the **Install** button when you're ready. ## Installing flatpaks in the terminal If you prefer to work in the terminal, you can treat Flatpak as a dedicated package manager. You can search for an application using the `flatpak search` command: ``` $ flatpak search paint Name Description Application ID CorePaint A simple painting tool org.cubocore.CorePaint Pinta Edit images and paint digitally com.github.PintaProject.Pinta Glimpse Create images and edit photographs org.glimpse_editor.Glimpse Tux Paint A drawing program for children org.tuxpaint.Tuxpaint Krita Digital Painting, Creative Freedom org.kde.krita ``` Install with `flatpak install` : `$ flatpak install krita` Once installed, applications appear in your application menu or Activities screen along with all the other applications on your system. ## Apps made easy Flatpak makes installing applications easy for the user by eliminating version conflicts. They make distributing software easy for developers by targeting just one package format on either a self-hosted platform or a communal one like Flathub. I use Flatpaks on Fedora Silverblue, CentOS, and Slackware, and I can't quite imagine life without it now. Try Flatpak for your next app install! ## Comments are closed.
14,047
5 个去谷歌化的安卓操作系统
https://itsfoss.com/android-distributions-roms/
2021-12-04T14:32:00
[ "谷歌", "安卓" ]
https://linux.cn/article-14047-1.html
![](/data/attachment/album/202112/04/143224d46wb5bqsw7xbsw7.jpg) > > 让你的智能手机摆脱谷歌和其他科技巨头。 > > > 随着谷歌和 Facebook 等广告巨头对你的个人和私密设备(如手机和平板电脑)的监控不断增加,现在是时候处理这个问题了。 最有效的方法之一是安装注重隐私/安全的安卓 ROM。 你可能想知道,为什么要在你的手机上安装一个与预装系统不同的、基于安卓的操作系统。让我给你几个理由: * 你的手机制造商与 Facebook 等实体合作,[在你的手机上预装了各种应用程序](https://9to5google.com/2020/08/05/oneplus-phones-will-ship-with-facebook-services-that-cant-be-removed/),仅仅是卸载这些应用程序可能无法摆脱它们(当操作系统有新的更新时,它们往往会被重新安装)。 * 通常,安卓设备制造商会提供三到四年的更新。其中大部分仅限于各种奇怪的安全补丁,以及一些安卓系统的升级。使用定制 ROM,你可以通过接收更多更新来延长设备的使用寿命。 * 由于这些现成的安卓 ROM 除了必要的东西外没有捆绑任何东西,你的手机不会太臃肿,反应更敏捷。 * 较少的预装软件也意味着在后台运行的服务较少,从而可提升性能并延长电池使用时间。 * 大量的定制选项。 * 容易回滚更新(因为以前的版本在 ROM 的网站上可以找到)。 > > **警告** > > > 如果你决定在实际设备上使用这些操作系统之一,请小心。在你的设备上刷入任何第三方 ROM 将使其保修失效,如果操作不当,甚至可能使你的设备失去作用。安装定制的 ROM 也需要一定的专业知识,即使如此,你也可能遇到问题,特别是如果你选择的操作系统不支持该设备。对你的设备造成的任何损害,我们概不负责。 > > > 参考了上述重要信息之后,如果你仍想进行实验,我们建议你始终在备用设备上进行尝试。 除此之外,你还应该记住以下几点: * 安装自定义的安卓 ROM 可以增强开箱即用的安全性。但是,你必须确保自己采取了必要的措施。 * 你手机的所有硬件功能可能在定制 ROM 上不工作。 * 解锁引导加载程序是一个必要步骤,但这样做可能会带来安全问题。 这个列表特别关注基于安卓的发行版和定制 ROM。我们有一个另外单独的 [开源移动操作系统](https://itsfoss.com/open-source-alternatives-android/) 列表,包括 Ubuntu Touch 和 PureOS 等选项。 注:名单排名不分先后。你应该选择更多地了解所提到的选项,并决定什么最适合你。 ### 1、LineageOS ![Lineage OS 用户界面的几张截图](/data/attachment/album/202112/04/143239c5uutworurr9tx5o.jpg) [LineageOS](https://lineageos.org/) 可以说是最受欢迎的安卓 ROM 之一,它是非常流行的([但自 2016 年以来已经消亡](https://www.androidauthority.com/cyanogenmod-lineageos-654810/)])的 CyanogenMod 的一个复刻。由于 LineageOS 很流行,你可能会发现很多设备支持该操作系统。 换句话说,与其他定制安卓 ROM 相比,你可以更快地获得对新设备的支持,以及对各种旧设备的支持。 如果你有的话,LineageOS 甚至支持你的 Nvidia Shield 电视机和 Jetson Nano([用于 AI 和深度学习项目的最佳单板计算机](https://itsfoss.com/best-sbc-for-ai/) 之一)。 * [获取 LineageOS](https://lineageos.org/) #### 优点 * 优秀的官方和第三方文档 * 支持设备的及时更新 * LineageOS 非常紧跟 AOSP 树(适用于想要最原始安卓体验的人) * 与原厂固件相比,“预装软件”更少。 #### 缺点 * LineageOS 项目是一个社区项目,所以并非你手机上所有的硬件功能都能开箱即用。 * 没有提供很多开箱即用的安全/隐私功能。 ### 2、CalyxOS ![CalyxOS 的主页以及他们的用户界面一瞥](/data/attachment/album/202112/04/143239rteywv45h8xee82o.jpg) [CalyOS](https://calyxos.org/) 是一个相当有趣的、基于 [安卓开源项目(AOSP)](https://www.androidauthority.com/aosp-explained-1093505/) 的安卓操作系统。CalyxOS 没有提供谷歌移动服务(GMS),而是让用户自己去想办法(可以刷入谷歌应用),但是它提供了 [microG](https://microg.org/),你可以选择启用/禁用它,从而完全控制你的手机。 CalyxOS 得到了 [Calyx Institute](https://calyxinstitute.org/projects/calyx-os) 的支持,这是一个非营利组织,旨在促进个人权利,如言论自由、隐私权等。 它内置了一些注重隐私的应用程序,如 Signal、Tor 浏览器等。尽管对 CalyxOS 的支持仅限于 Pixel 手机,但在大多数情况下,它为用户提供了大量开箱即用的隐私功能,让用户具有领先优势。 * [获取 CalyxOS](https://calyxos.org/install/) #### 优点 * 使用 [microG](https://microg.org/)。 * 带有 [F-Droid](https://www.f-droid.org/en/about/) 和 [Aurora 商店](https://auroraoss.com/) 而不是谷歌应用商店。 * Datura 防火墙允许你阻止每个应用程序的互联网访问。 * 使用 [Mozilla 定位服务](https://location.services.mozilla.com/) 而不是谷歌的定位服务。 * 每月一次的在线安全更新。 * 经过验证的启动程序,以提高安全性。 * 开箱即用的以安全为中心的应用程序和功能。 #### 缺点 * 只适用于 Pixel 手机([但这背后有一个很好的理由](https://calyxos.org/docs/guide/device-support/#requirements-for-supporting-a-new-device))。 ### 3、GrapheneOS ![GrapheneOS 安装在 Pixel 设备上的照片](/data/attachment/album/202112/04/143240jdlwlddaz55l35ay.jpg) [GrapheneOS](https://grapheneos.org/) 是一个基于安卓的 ROM,专注于安全和隐私。虽然人们可能会争论说,他们的努力更多的是为了提高安全性,但这样做也有利于你的隐私。 如果你想安装带有开箱即用的、特殊安全调整过的定制 ROM,GrapheneOS 应该是一个不错的选择。 与其他一些定制 ROM 不同,它没有包括启用/禁用 microG 的功能,这恰好为依赖于 Google Play 服务的应用程序提供了更好的支持。但是,GrapheneOS 可以 [对 Google Play 服务进行沙箱处理](https://twitter.com/grapheneos/status/1445572173389725709),这应该可以让你使某些功能正常工作。但是,截至目前,它仍然是实验性的。 * [获取 GrapheneOS](https://grapheneos.org/) #### 优点 * 提供比 AOSP 更强大、加固过的应用程序沙盒。 * 使用自己 [加固过的 malloc](https://github.com/GrapheneOS/hardened_malloc)(具有加固了安全性的内存分配器)。 * Linux 内核经过了加固,安全性更高。 * 提供及时的安全更新。 * 具备全盘加密功能(对移动设备来说非常重要)。 * 不包括任何谷歌应用程序或谷歌服务。 #### 缺点 * 有限的硬件支持;仅适用于谷歌 Pixels。 * 以安全为中心的调整可能不会转化为对新手友好的用户体验。 ### 4、/e/OS ![看一下 /e/OS 中的应用启动器,以及对 /e/OS 的应用商店评级的概述](/data/attachment/album/202112/04/143241q1ezwh4hm5mq1ikl.png) 你可能认为 [/e/OS](https://e.foundation/e-os/) 只不过是又一个安卓操作系统,这 *一定程度上* 是对的。先别急着否定这个安卓 ROM。它远超于任何现成的基于安卓的操作系统。 最大的特点是 [eFoundation](https://e.foundation/)(在 /e/OS 背后的基金会)为你提供了一个免费的 [ecould 账户](https://e.foundation/ecloud/)(有 1GB 的存储空间),而不需要使用谷歌账户。 像任何尊重隐私的安卓 ROM 一样,/e/OS 将每一个与谷歌相关的模块或应用都替换成了自由软件替代品。 旁注:eFoundation 也销售预装了 /e/OS 的手机。[请看这里](https://esolutions.shop/)。 * [获取 /e/OS](https://e.foundation/e-os/) #### 优点 * /e/OS 上的应用程序商店根据需要的权限以及对隐私的友好程度来对应用程序进行评级。 * 提供了一个 [ecloud 账户](https://e.foundation/ecloud/)(带有 @e.email 后缀;免费级提供 1GB)作为同步账户。 * 配备了 [microG](https://microg.org/) 框架。 * 谷歌 DNS 服务器(8.8.8.8 和 8.8.4.4)被替换为 [Quad9](https://www.quad9.net/) 的 DNS 服务器。 * DuckDuckGo 是替代谷歌的默认搜索引擎。 * 使用由 [Mozilla](https://location.services.mozilla.com/) 提供的位置服务。 #### 缺点 * 设备兼容性非常有限。 * 从安卓系统推出新功能需要一段时间。 ### 5、CopperheadOS ![CopperheadOS 网站上关于手机安全和隐私的标语](/data/attachment/album/202112/04/143241q0pucrxgeqhcxpr6.jpg) > > **警告** > > > 这不是一个开源项目。列在这里只是为感兴趣的用户提供的附加选项。 > > > [CopperheadOS](https://copperhead.co/) 是另一个有趣的安卓 ROM。它是由一个只有两个人的团队开发的。 与其他选项不同,CopperheadOS 不是开源项目,你可能无法在你的手机上使用它。 它面向企业部署。因此,如果你想为你的员工购买安卓设备并调整安全性,那么这值得考虑。 * [获得 CopperheadOS](https://copperhead.co/android/docs/install/) #### 优点 * 与其他安卓 ROM 文档相比 [更优良的文档](https://copperhead.co/android/docs/)。 * CopperheadOS 在 AOSP 之前就有许多面向安全的功能。 * 使用 Cloudfare DNS(1.1.1.1 和 1.0.0.1)而不是谷歌的 DNS(8.8.8.8 和 8.8.4.4)。 * 包括一个用于控制每个应用程序权限的互联网防火墙。 * 使用开源应用程序,而不是过时的 AOSP 应用程序(日历、短信、画廊等)。 * 包括 [F-Droid](https://www.f-droid.org/en/about/) 和 [Aurora 应用商店](https://auroraoss.com/)。 #### 缺点 * [在主要的开发者出走之后](https://twitter.com/DanielMicay/status/1068641901157511168),CopperheadOS 的安全性存在质疑 。 * 仅适用于预装 CopperheadOS 的手机。 * 没有迹象表明 SafetyNet 会在 CopperheadOS 上工作。 ### 荣誉提名:LineageOS for microG ![LineageOS for microG 中包含的应用程序列表](/data/attachment/album/202112/04/143242wcw5cn7m3358ly57.jpg) [LineageOS for microG](https://lineage.microg.org/) 项目是官方 LineageOS 项目的一个复刻,默认包含 [microG](https://microg.org/) 和谷歌应用。这个项目负责确保 microG 在你的手机上完美运行(这对初学者来说可能是一个复杂的过程)。 * [获取 LineageOS for MicroG](https://download.lineage.microg.org/) #### 优点 * 提供了 GMS 的 microG 实现,没有任何不便之处。 * 提供 [F-Droid](https://www.f-droid.org/en/about/) 作为默认的应用商店。 * 提供每周/每月一次的在线更新。 * 可以选择使用由 [Mozilla](https://location.services.mozilla.com/) 或 [Nominatim](https://nominatim.org/) 提供的定位服务。 #### 缺点 * 启用签名欺骗以启用 microG 支持,从安全角度来看,可能是一个攻击方向。 * 尽管这个 ROM 是基于 LineageOS 的,但在写这篇文章时,并不是所有的 LineageOS 设备都支持。 * 包括谷歌应用程序,而不是提供开源的替代品。 * 无法确认谷歌的 SafetyNet 是否工作。 ### 附加信息 你可能想知道为什么一些有趣的基于安卓的 ROM(CalyxOS、GrapheneOS 等)只限于支持谷歌的手机。这不是很讽刺吗? 嗯,这是因为大多数手机都支持解锁引导器,但只有谷歌 Pixels 支持再次锁定引导器。当你为关注隐私和/或安全的人群开发基于安卓的 ROM 时,这是一个考虑因素。如果启动器被解锁,它就是一个你尚未修补的攻击方向。 另一个具有讽刺意味的原因是,只有谷歌才及时向公众提供他们手机的设备树和内核源代码。如果没有设备树和内核源代码,你就无法为该手机开发 ROM。 无论你选择何种 ROM,我都会推荐以下 FOSS 应用程序。它们将被证明是对你的隐私友好应用程序工具包的一个很好的补充。 * [Signal Messenger](https://signal.org/) * [K-9 邮件](https://k9mail.app/) * [DuckDuckGo 浏览器](https://duckduckgo.com/app) * [Tor 浏览器](https://www.torproject.org/)。 * [F-Droid](https://www.f-droid.org/en/about/) * [Aurora 商店](https://auroraoss.com/) * [OpenKeychain](https://www.openkeychain.org/) ### 总结 在我看来,如果你有一部谷歌 Pixel 手机,我建议你尝试一下 CalyxOS、GrapheneOS 或 CopperheadOS。这些安卓 ROM 有出色的功能,可以帮助你的手机远离谷歌的监视,同时还可以让你的手机(可以说是)更加安全。 如果你没有谷歌 Pixel,你仍然可以尝试一下 LineageOS for MicroG。这是一项很好的社区贡献,在不侵犯你的隐私的情况下,它把谷歌的专有功能带给大众。 如果你的手机不被上述任何一个操作系统支持,那么 LineageOS 就是你的朋友。由于它对手机的支持广泛,毫无疑问,无论是官方还是非官方,你的手机都可以得到支持。 --- via: <https://itsfoss.com/android-distributions-roms/> 作者:[Pratham Patel](https://itsfoss.com/author/pratham/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) With the ever-growing surveilling presence of advertisement giants like Google and Facebook on your personal devices (including smartphones), it is time you do something about it. One of the most effective ways to do that is by installing a privacy/security-focused Android ROM. You might wonder why you should install a different Android-based OS on your phone than what is already included. Let me give you a few reasons: - Your [phone manufacturer partners with entities like Facebook to pre-install the apps](https://9to5google.com/2020/08/05/oneplus-phones-will-ship-with-facebook-services-that-cant-be-removed/)on your phone, and simply uninstalling these apps may not get rid of them (they tend to get reinstalled when there is a new OS update). - Usually, Android device manufacturers provide three-four years of updates (with flagship devices). If it is not a flagship phone, you get limited updates. With a custom ROM, you can extend the longevity of your devices by receiving more updates. - Since these off-the-shelf Android ROMs don’t bundle anything apart from what is necessary, your phone can feel more responsive due to less bloat. - Less pre-installed software means fewer services run in the background, resulting in a potential performance uplift and increased battery life. - A lot of customization options. - Easy to roll back updates (because previous versions are available on the website of ROM). With the critical information out of the way, we suggest you always try it on a spare device if you want to experiment. In addition to that, there are a few more pointers that you should keep in mind: **Installing a custom Android ROM may enhance security out of the box. But, you will have to ensure you take the necessary measures yourself.****All the hardware features on your phone may not work on custom ROMs.****Some apps may not work well with custom ROMs.****Unlocking the bootloader is a necessary step, and doing so can pose security issues.** This list focuses explicitly only on Android custom ROMs. We have a separate list of [open source mobile operating systems](https://itsfoss.com/open-source-alternatives-android/) that include options such as Ubuntu Touch and PureOS. ## 1. LineageOS ![01 lineageos](https://itsfoss.com/content/images/wordpress/2021/11/01_lineageos-800x400.webp) [LineageOS](https://lineageos.org/) is arguably one of the most popular Android ROM, a fork of the very popular [[but dead since 2016](https://www.androidauthority.com/cyanogenmod-lineageos-654810/)] CyanogenMod. Due to the popularity of LineageOS, you may find more devices supporting the OS. In other words, you can expect support for newer devices sooner, along with a wide range of old devices, when compared to other custom Android ROMs. LineageOS even supports Nvidia Shield TV and Jetson Nano (one of the [best single board computers for AI and Deep Learning projects](https://itsfoss.com/best-sbc-for-ai/)), if you have one. **Pros** - Good first-party and third-party documentation - Timely updates for supported devices - LineageOS follows the AOSP tree very closely (for people who want the most stock Android experience) - Less “preinstalled bloatware” compared to your stock factory firmware **Cons** - The LineageOS project is a community effort, so not all hardware features of your phone may work right out of the box - It does not offer a lot of security/privacy features out of the box ## 2. CalyxOS [CalyOS](https://calyxos.org/) is a rather interesting custom ROM based on the [Android Open Source Project (AOSP)](https://www.androidauthority.com/aosp-explained-1093505/). Instead of not shipping the Google Mobile Services (GMS) and leaving users to figure stuff out by themselves (flashing gapps etc), CalyxOS ships with [microG](https://microg.org/). However, you can choose to enable/disable it, thus, giving you total control. ![02 calyx 1](https://itsfoss.com/content/images/wordpress/2021/11/02_calyx-1-800x449.webp) CalyxOS is backed by the [Calyx Institute](https://calyxinstitute.org/projects/calyx-os), a non-profit organization promoting individual rights like free speech, privacy rights, etc. It comes with privacy-focused applications like Signal, Tor Browser, and more. Even though the support for CalyxOS is limited to Pixel phones, for the most part, it provides plenty of out-of-the-box privacy features for a user to get a head start with a degoogled android phone. **Pros** - Uses [microG](https://microg.org/) - Ships with [F-Droid](https://www.f-droid.org/en/about/)and the[Aurora Store](https://auroraoss.com/) - Datura Firewall allows you to block internet access per app - Uses [Mozilla Location Services](https://location.services.mozilla.com/)instead of Google’s Location Services - Monthly over-the-air security updates - Has verified boot for increased security - Security-focused apps and features out of the box **Cons** - Only available on Pixel phones ( [but there is a good reason behind this](https://calyxos.org/docs/guide/device-support/#requirements-for-supporting-a-new-device)) **Suggested Read 📖** [12 Simple Tools to Protect Your PrivacyQuick ways to enhance online privacy? Use these simple tools to take control of your data easily.](https://itsfoss.com/privacy-tools/)![](https://itsfoss.com/content/images/wordpress/2022/02/privacy-tools-ft.jpg) ![](https://itsfoss.com/content/images/wordpress/2022/02/privacy-tools-ft.jpg) ## 3. /e/OS You may think that [/e/OS](https://e.foundation/e-os/) is yet another Android Operating System. You would be *partially* correct. Don’t dismiss this Android ROM just yet. It packs so much more than any off-the-shelf Android-based Operating System. ![06 eos 1](https://itsfoss.com/content/images/wordpress/2021/11/06_eos-1.webp) The most significant outstanding feature is that the [eFoundation](https://e.foundation/) (which is behind /e/OS) provides you with a free [ecloud account](https://e.foundation/ecloud/) (with 1GB of storage), instead of needing to use your Google account. Like any privacy-respecting Android ROM, /e/OS replaces every Google-related module or app with a FOSS alternative. While it is a de-googled operating system, it offers all the usable replacements baked right in. So, it can be a suitable candidate for new users looking for an easy replacement. [Check it out here](https://esolutions.shop/). **Pros** - The App store on /e/OS rates apps based on how many permissions they need and privacy-friendliness - Provides an [ecloud account](https://e.foundation/ecloud/)(with a @e.email; 1GB in free tier) as a synchronization account - Ships with [microG](https://microg.org/)framework - Google DNS servers (8.8.8.8 and 8.8.4.4) are replaced with [Quad9](https://www.quad9.net/)DNS servers - DuckDuckGo is the default search engine, replacing Google - Uses location services provided by [Mozilla](https://location.services.mozilla.com/) **Cons** - Limited devices support with Easy Installer - Roll-out of new features from Android takes a while ## 4. CopperheadOS **This is not an open-source project. It has been listed as an additional option for users interested.** **Non-FOSS Warning!**[CopperheadOS](https://copperhead.co/) is another interesting Android ROM. A team of just two people developed it. CopperheadOS is not an open-source project, unlike other options, and you probably cannot get your hands on it. It is geared towards enterprise deployment. So, if you want to purchase Android devices for your employees with security tuned in, this can be worth considering. ![04 copperheados](https://itsfoss.com/content/images/wordpress/2021/11/04_copperheados-800x420.webp) **Pros:** [Good documentation](https://copperhead.co/android/docs/), compared to any other Android ROM documentation- CopperheadOS has had many of the security-oriented features before AOSP itself - Uses Cloudflare DNS (1.1.1.1 and 1.0.0.1) instead of Google’s DNS (8.8.8.8 and 8.8.4.4) - Includes an internet firewall for per-app permission - Uses Open Source apps instead of obsolete AOSP apps (Calendar, SMS, Gallery etc) - Includes [F-Droid](https://f-droid.org/en/about/)and the[Aurora App Store](https://auroraoss.com/) **Cons:** [Questionable claims about the security of CopperheadOS after the main dev went different ways](https://twitter.com/DanielMicay/status/1068641901157511168)- Only available with phones pre-loaded with CopperheadOS - No indication of SafetyNet working on CopperheadOS ## 5. iodé iodé is an open-source Android-based operating system that gets rid of Google trackers. ![iode os on a smartphone](https://itsfoss.com/content/images/2023/02/iode-os.png) In addition, it offers a feature to analyze real-time data requests from your apps. So, you can keep track of the apps that want to collect your data and get control if you allow/prevent them from tracking your data. They also offer [new and refurbished phones](https://iode.tech/en/#new-phones) (including Fairphone, Pixel refurbished, and more) that come loaded with iodé OS. **Pros:** - Easy-to-use OS that provides access to privacy insights - The company promotes eco-friendly tech by selling a variety of refurbished phones powered by the OS **Cons:** - Nothing extraordinary about the OS for users who want more in terms of control and customization **Suggested Read 📖** [40+ Best Open Source Android AppsThe best open source Android apps. Replace the proprietary options to enjoy a potentially better experience!](https://itsfoss.com/open-source-android-apps/)![](https://itsfoss.com/content/images/2023/02/best-foss-android-apps.png) ![](https://itsfoss.com/content/images/2023/02/best-foss-android-apps.png) ## Honourable mention: LineageOS for microG The [LineageOS for microG](https://lineage.microg.org/) project is a fork of the official LineageOS with [microG](https://microg.org/) and Google Apps (GApps) included by default. This project ensures that microG works flawlessly on your phone (which can be a complicated process for a beginner). ![05 losmicrog](https://itsfoss.com/content/images/wordpress/2021/11/05_losmicrog-450x800.webp) **Pros:** - Provides the microG implementation of GMS without any inconveniences - It comes with [F-Droid](https://f-droid.org/en/about/)as the default App Store - Provides weekly/monthly over-the-air updates - Has option to use location service provided by either [Mozilla](https://location.services.mozilla.com/), or by[Nominatim](https://nominatim.org/) **Cons:** - Enabling signature spoofing to enable microG support can be an attack vector from a security POV - Even though this ROM is based on LineageOS, as of writing this, not all of the LineageOS devices are supported - Includes Google Apps (GApps) instead of providing Open Source alternatives - No confirmation if Google’s SafetyNet is working or not ## Here's Something Interesting... You may be wondering why some of the interesting Android-based ROMs (CalyxOS etc.) are only restricted to supporting Google’s Phones. Isn’t *that* ironic? Well, that is because most phones support unlocking a bootloader, but only Google Pixels support locking the bootloader again. This is a consideration when developing an Android-based ROM for privacy and security-focused crowd. If the bootloader is unlocked, it is an attack vector you haven’t patched yet. Another reason for this irony is that only Google makes their phones’ **Device Tree and Kernel Source Code** available to the public on time. You cannot develop a ROM for the said phone without its Device Tree and Kernel Source Code. To complement your choice of an operating system, you can also check out some of the best [open source Android apps](https://itsfoss.com/open-source-android-apps/) to get started. ## Concluding Thoughts In my opinion, if you have a Google Pixel phone, I recommend giving a try to either CalyxOS, CopperheadOS or Lineage. These Android ROMs have excellent features to help you keep your phone out of Google’s spying eyes while also keeping your phone [arguably] more secure. If you do not have a Google Pixel, you can still try LineageOS for microG. It is a reasonable community effort to bring Google’s proprietary features without invading your privacy to the masses. If your phone isn’t supported by either of the operating systems mentioned above, LineageOS is your friend. Due to the wide range of supported phones, yours will undoubtedly be supported in any capacity, officially or unofficially.
14,048
如何在 Ubuntu 和其他 Linux 上安装 Apache Cassandra
https://itsfoss.com/apache-cassandra-ubuntu/
2021-12-04T15:20:44
[ "Cassandra" ]
https://linux.cn/article-14048-1.html
![](/data/attachment/album/202112/04/151942ihpizylzk0i3pt0i.jpg) [Apache Cassandra](https://cassandra.apache.org/_/index.html) 是一个自由开源的 NoSQL 数据库管理系统,用于在许多服务器上操作大量信息,提供无单点故障的高可用性。 我不打算讨论 NoSQL 数据库的细节。我将会告诉你如何在基于 Ubuntu 的 Linux 发行版上安装 Apache Cassandra。 请注意,这更多是为了实践。 ### 在 Linux 上安装 Apache Cassandra 有多种方法可以在 Ubuntu 和其他 Linux 发行版上安装 Cassandra: * 使用 Apache 的官方 deb 仓库安装:适合并推荐给基于 Debian 和 Ubuntu 的发行版。如果有更新的版本,会得到自动更新。 * 使用 Docker 安装:适用于所有 Linux 发行版。 * 从 tarball 安装:适用于所有 Linux,但不会自动更新到新版本。 这仅仅是为了练习和体验 Apache Cassandra。如果你要在一个项目中使用它和其他服务,你必须遵循该服务的完整配置和设置指南。 我将展示前两种方法。 #### 方法 1:使用官方仓库在 Ubuntu 和 Debian 上安装 Cassandra 在你安装和使用 Cassandra 之前,你需要在你的系统上安装 Python 和 Java。你可能需要 [在 Ubuntu 上安装 Java](https://itsfoss.com/install-java-ubuntu/),但 Python 通常是预装的。 你可以用下面这行来检查先决条件: ``` java -version && python --version ``` 所有先决条件都安装好了?那就好。让我们来安装 Cassandra。这里的方法与 [在 Ubuntu 中添加任意外部仓库](https://itsfoss.com/adding-external-repositories-ubuntu/) 相同。 首先,将 Apache Cassandra 仓库添加到你的源列表中。下面这个添加最新的主要版本(在写这篇文章的时候)4.0 系列。 ``` echo "deb http://www.apache.org/dist/cassandra/debian 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list ``` ![Add Apache Cassandra repository](/data/attachment/album/202112/04/152044finw2ccwbw6k2cgw.png) 现在,下载并将 Apache Cassandra 仓库的密钥添加到服务器上的受信任密钥列表中。这样,你的系统就会信任来自你在上一步添加的仓库的软件包。 你应该确保 `apt` 可以通过 https 使用。 ``` sudo apt install apt-transport-https ``` 然后添加密钥: ``` wget https://www.apache.org/dist/cassandra/KEYS && sudo apt-key add KEYS ``` ![Add Apache Cassandra repository key](/data/attachment/album/202112/04/152045vxulruzhrljzrigl.png) 你已经添加了仓库。更新本地缓存,使你的系统知道这个新仓库的存在。 ``` sudo apt update ``` 最后,用以下命令安装 Cassandra: ``` sudo apt install cassandra ``` ![Installing Apache Cassandra on Ubuntu](/data/attachment/album/202112/04/152045ddlpwv9xpxzyiv5l.png) 安装完成后,Cassandra 服务会自动开始运行。如果你想的话,你仍然可以验证它: ``` sudo systemctl status cassandra.service ``` ![Check if Cassandra is running](/data/attachment/album/202112/04/152046evhex7bux0ep0fbn.png) 你可以输入 `cqlsh` 连接到数据库。输入 `exit` 来退出这个 shell。 ![Entering cqlsh](/data/attachment/album/202112/04/152046dztbntmrnz66a4tx.png) 这是非常基本和默认的设置。你可能需要根据你的需求来配置它。请查看 [官方文档中的配置部分](https://cassandra.apache.org/doc/latest/cassandra/getting_started/configuring.html)。 #### 方法 2:使用 Docker 安装 Apache Cassandra 这个方法适用于任何 Linux 发行版,只要你打算在 Docker 设置中使用它。 当然,你需要在你的系统上安装 Docker 来实现这个方法。这是这个方法的前提条件,我让你处理这件事情。 如果你有 Docker,使用下面的命令来拉取 Apache Cassandra 的 Docker 镜像: ``` sudo docker pull cassandra:latest ``` ![Pulling Apache Cassandra docker image](/data/attachment/album/202112/04/152046swkwzc0zrczswxr0.png) 完成后,你可以用 [docker run 命令](https://linuxhandbook.com/docker-run-vs-start-vs-create/)来启动 Cassandra,像这样: ``` sudo docker run --name cass_cluster cassandra:latest ``` ![Running Cassandra in a container](/data/attachment/album/202112/04/152047xnahi625am9vi6z6.png) **注意:** `--name` 选项指的是创建的 Cassandra 集群的名称。 要与之前启动的 Cassandra 节点交互,你需要初始化 CQL shell,你可以用 Docker `exec` 命令这样做: ``` sudo docker exec -it cass_cluster cqlsh ``` ![Access the cqlsh running in Docker.](/data/attachment/album/202112/04/152047b9w7977af7xsvahs.png) **恭喜!** 现在你至少知道了在你的系统中安装 Apache Cassandra 的两种不同方法。 请记住,这篇文章只是一个介绍。如果你有兴趣了解更多关于 Apache Cassandra 的信息,请阅读 [文档](https://cassandra.apache.org/doc/latest/index.html),在那里你可以找到更多关于这个神奇的 NoSQL 数据库管理系统的信息。如果这篇文章对你有帮助,请阅读并分享它。下一篇见。 --- via: <https://itsfoss.com/apache-cassandra-ubuntu/> 作者:[Marco Carmona](https://itsfoss.com/author/marco/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
[Apache Cassandra](https://cassandra.apache.org/_/index.html) is a free and open-source NoSQL database management system drawn to manipulate large amounts of information across many servers, providing high availability with no single point of failure. I am not going into the details of NoSQL database. I am going to so you how you can install Apache Cassandra on Ubuntu based Linux distributions. Please note that it is more for practicing ## Installing Apache Cassandra on Linux There are multiple ways you can install Cassandra on Ubuntu and other Linux distributions: - Install it using the official deb repositories from Apache: suitable and recommended for Debian and Ubuntu-based distributions. Gets automatic update if a newer version is available. - Install it using Docker: works for all Linux distributions - Install it from the tarball: works with all Linux but it won’t get updated to a new version automatically. This is merely for practicing and experiencing Apache Cassandra. If you are going to use it in a project with other services, you’ll have to follow the complete configuration and setting guide of that service. I’ll show the first two methods. ### Method 1: Install Cassandra on Ubuntu and Debian using the official repository Before you could install and use Cassandra, you need to have Python and Java installed on your system. You may have to [install Java on Ubuntu](https://itsfoss.com/install-java-ubuntu/) however Python usually comes preinstalled. You can check the prerequisite with the next line: `java -version ; python --version` All prerequisites well installed? That’s good. Let’s install Cassandra. The method here is the same as [adding any external repository in Ubuntu](https://itsfoss.com/adding-external-repositories-ubuntu/). First, add the Apache Cassandra repository to your sources list. This one adds the latest major version (at the time of writing it) 4.0 series. `echo "deb http://www.apache.org/dist/cassandra/debian 40x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list` ![installing the debian packages step 1](https://itsfoss.com/content/images/wordpress/2021/11/Installing_the_Debian_packages_step_1-800x123.png) Now, download and add the Apache Cassandra repository keys to the list of trusted keys on the server. This way, your system will trust the packages coming from the repository you added in the previous step. You should make sure that apt can be used over https. `sudo apt install apt-transport-https` And then add the key: `wget https://www.apache.org/dist/cassandra/KEYS && sudo apt-key add KEYS` ![installing the debian packages step 2](https://itsfoss.com/content/images/wordpress/2021/11/Installing_the_Debian_packages_step_2-800x490.png) You have added the repository. Update the local cache so that your system is aware of the presence of this new repository. `sudo apt update` And lastly, install Cassandra with the following command: `sudo apt install cassandra` ![installing the debian packages step 3](https://itsfoss.com/content/images/wordpress/2021/11/Installing_the_Debian_packages_step_3-800x490.png) Once the installation finishes, Cassandra service starts running automatically. You could still verify it if you want: `sudo systemctl status cassandra.service` ![verify cassandra](https://itsfoss.com/content/images/wordpress/2021/11/verify-cassandra-800x443.png) You can connect to the database by typing cqlsh. Type exit to exit this shell. ![installing the debian packages step 4](https://itsfoss.com/content/images/wordpress/2021/11/Installing_the_Debian_packages_step_4-800x164.png) This was the very basic and default set up. You’ll probably need to configure it based on your requirement. Please the [official document for the configuration part](https://cassandra.apache.org/doc/latest/cassandra/getting_started/configuring.html). ### Method 2: Install Apache Cassandra using Docker This method will work with any Linux distribution as long as you are going to use it in a Docker setup. Of course, you need to have Docker installed on your system for this method. That’s a prerequisite for this method and I let you handle that. If you have Docker, use the command below to pull the docker image of Apache Cassandra. `sudo docker pull cassandra:latest` ![using docker images step 2](https://itsfoss.com/content/images/wordpress/2021/11/Using_Docker_images_step_2-800x275.png) Once that’s done, you can start Cassandra with the [docker run command](https://linuxhandbook.com/docker-run-vs-start-vs-create/) like this: `sudo docker run --name cass_cluster cassandra:latest` ![using docker images step 3](https://itsfoss.com/content/images/wordpress/2021/11/Using_Docker_images_step_3-800x490.png) **Note:** the `--name` option will be the name of the Cassandra cluster created. To interact with the Cassandra node started before, you need to initialize the CQL shell, and you can do it with the Docker exec command like this: `sudo docker exec -it cass_cluster cqlsh` ![using docker images step 4](https://itsfoss.com/content/images/wordpress/2021/11/Using_Docker_images_step_4-800x225.png) * Congrats! *Now you know at least two different ways to install Apache Cassandra in your system. Please keep in mind that this post is only an introduction. If you are interested in knowing more about Apache Cassandra, read the [documentation](https://cassandra.apache.org/doc/latest/index.html) where you can find out more about this amazing NoSQL database management system. **Enjoy it and share this post if it was interesting and helpful for you! See you in the next one.**
14,050
13 个 Linux 桌面的最佳深色 GTK 主题
https://itsfoss.com/dark-gtk-themes/
2021-12-05T11:04:11
[ "深色", "主题" ]
https://linux.cn/article-14050-1.html
![](/data/attachment/album/202112/05/110404dh7d463771gn6833.jpg) 在任何的 Linux 发行版上,你都有近乎无限的定制选项,在视觉上最明显的区别就是定制的主题。让我们来看看一些具有深色模式的 GTK 主题。 是的,我们在过去曾介绍过 [最佳 Linux 主题](https://itsfoss.com/best-gtk-themes/),但这一篇是专门介绍深色主题的。曾几何时,只有程序员和系统管理员喜欢深色模式,但现在已经不是这样了。深色模式也受到了普通人的喜爱,因此我为像你这样的 Linux 桌面用户编制了这个深色主题列表。 如果你不熟悉设置桌面环境的主题,你可以看看我们的 [在 GNOME 中安装主题](https://itsfoss.com/install-switch-themes-gnome-shell/) 指南。 本文仅供参考,这并不是一个排名列表。 ### 1、McMojave ![The stock image of how McMojave looks ](/data/attachment/album/202112/05/110412vyy2h2my6bz5d33d.jpg) [McMojave](https://github.com/vinceliuice/Mojave-gtk-theme) 是一个 GTK 主题,其灵感来自于 macOS 风格的用户界面。显然这个主题是提供给深色模式的,但它也有浅色模式,嗯……,提供给任何可能想要它的人。 McMojave GTK 主题显然支持基于 GTK 的桌面环境,如 Pantheon、Gnome、XFCE、Mate 等。但是,这个主题也 [适用于 KDE 用户](https://github.com/vinceliuice/McMojave-kde)。 为了让你的桌面环境看起来与 macOS 非常相似,你还可以安装 [McMojave 圆形图标主题](https://github.com/vinceliuice/McMojave-circle) 以获得更完整的体验。 ### 2、Yaru ![A screenshot of the default Yaru theme on Ubuntu 21.10](/data/attachment/album/202112/05/110412d85kbbe5de11e4dr.jpg) [Yaru](https://github.com/ubuntu/yaru) 是 [Ubuntu](https://ubuntu.com/) 的默认 GTK(GNOME)主题。该主题的深灰色点缀着橙色,及少许黑色让我觉得很有吸引力。 现在,你可以让 Arch Linux 上的 GNOME 看起来像 Ubuntu。( ͡° ͜ʖ ͡°) ### 3、Pop ![A look at how the Pop GTK theme looks on Pop!_OS](/data/attachment/album/202112/05/110412n796c0fmbfvhdtkb.jpg) [Pop GTK 主题](https://github.com/pop-os/gtk-theme) 是由 [System76](https://system76.com/) 为他们基于 Ubuntu 的 Linux 发行版 [Pop!\_OS](https://pop.system76.com/) 创建的主题。 如果你喜欢 System76 对 GNOME 在深色模式下的表现,你可以在你选择的 Linux 发行版中试用 [Pop GTK 主题](https://github.com/pop-os/gtk-theme)。 如果想获得完整的 Pop-esque 的外观和感觉,在安装主题的同时,还可以安装 System76 提供的 [Pop 图标](https://github.com/pop-os/icon-theme)。 ### 4、Nordic ![Nordic GTK theme preview](/data/attachment/album/202112/05/110412bbmobm4mynb4mo6t.jpg) 你是一个喜欢简单的、有点扁平化的设计方法以及一些灰色或更多灰色的人吗?不妨看看这个基于 [北欧风调色板](https://github.com/arcticicestudio/nord) 的主题。 [Nordic](https://github.com/EliverLara/Nordic) GTK 主题给你的正是这样的感觉。一个基于北欧风调色板的 GTK 主题,设计简单。 ### 5、Ultimate-Maia ![Stock screenshot of the Ultimate-Maia theme](/data/attachment/album/202112/05/110413uddqzr95gg0d0d5v.jpg) [Ultimate-Maia](https://github.com/bolimage/Ultimate-Maia) 是一个基于 [Google 的 Material 主题](https://material.io/) 设计理念的 GTK 主题。这个主题有一个精细而独特的外观和感觉,特别是有各种不同的强调色可供选择。 ### 6、Graphite ![A look at Graphite’s flat, rounded and gray characteristic](/data/attachment/album/202112/05/110413d6j6jnpjmmsl3zff.jpg) [Graphite](https://github.com/vinceliuice/Graphite-gtk-theme) 是一个 GTK 主题,它为你的桌面环境(尤其是 GNOME)提供了一个完全独特的外观,同时保持了你的桌面环境的独特性,就像以前一样。这是一个值得一看的东西。 ### 7、Qogir ![Customization options available with Qogir GTK theme](/data/attachment/album/202112/05/110413e7u948iucju9nanu.jpg) [Qogir](https://github.com/vinceliuice/Qogir-theme) 是一个采用了扁平化设计的 GTK 主题。Qogir 主题为你提供的不仅仅是标题按钮、复选框、单选按钮、开关等自定义选项。 ### 8、Layan ![Lyan – A very rounded-corners GTK theme](/data/attachment/album/202112/05/110413f12429hkmnoo1r1h.jpg) 你会很高兴知道,这个列表中还包括 [Layan](https://github.com/vinceliuice/Layan-gtk-theme),这是一个强调平滑、圆角的 GTK 主题,带有气泡的美感。Layan 主题也继承了 [Google 的 Material 设计](https://material.io/) 指导方针的设计理念。 ### 9、Juno ![](/data/attachment/album/202112/05/110414h1pu9oiri99p4ipo.jpg) [Juno](https://github.com/EliverLara/Juno) 是我发现的另一个最好的对深色模式友好的 GTK 主题之一。有些人可能喜欢它的漆黑本质,有些人可能不喜欢。但是,如果你有一台 OLED 笔记本或电脑显示屏,Juno 感觉是为你而生的。 ### 10、Ant 主题 ![Ant themes’ available options for customization of window appearance](/data/attachment/album/202112/05/110414yfo8nikjo1ffha0a.jpg) [Ant](https://github.com/EliverLara/Ant) 是一个 GTK 主题,它从 macOS 的布局和用户界面元素中获得了一些灵感,在我看来,Ant 主题很好地实现了这一切。 ### 11、Equilux ![](/data/attachment/album/202112/05/110414mtjjjqnjjt9k9qn5.jpg) [Equilux](https://github.com/ddnexus/equilux-theme) 主题给你一个漂亮的主题,带有精细的深色模式。这个主题能很好地与 GNOME 及 GNOME 的复刻融合在一起。我不会太多地描述这个主题,它简单而优雅。 ### 12、Orchis-dark ![Orchis Dark](/data/attachment/album/202112/05/110415qb8ba29lbuqa2bca.jpg) [Orchis Orchis-dark](https://www.gnome-look.org/s/Gnome/p/1357889) 是超酷的 Orchis 主题的深色变体。它为桌面提供了带有圆角和流畅界面的 iOS/macOS 触感。只需看一眼,你就可以立即猜到。 ### 13、Elementary X ![A look at Elementary X GTK theme with the settings panel open](/data/attachment/album/202112/05/110415ara5claaak22zckd.jpg) [Elementary X](https://github.com/surajmandalcell/elementary-x) 是基于 [elementary OS](https://elementary.io/) 团队为定制 GNOME 外观而开发的 GTK 主题。顺便说一句,elementary OS 是一个基于 Ubuntu 的 Linux 发行版。 ### 总结 这篇文章中列出的主题都是非常漂亮的,而且你的选择也不限于这里列出的那些。还有其他成千上万的主题。 如果你喜欢一个主题,请在下面评论。如果你正在使用一个我没有提到的主题,也请留下评论。 --- via: <https://itsfoss.com/dark-gtk-themes/> 作者:[Pratham Patel](https://itsfoss.com/author/pratham/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) **With the near infinite customization options you have on any given Linux distribution, the most visually noticeable difference is customizing the theme. Let’s take a look at some of the GTK themes with dark mode.** Yeah, we have covered the [best Linux themes](https://itsfoss.com/best-gtk-themes/) in the past but this one is specifically dedicated to the dark themes. There was a time when only programmers and sysadmins preferred dark mode but that’s not the case anymore. Dark mode is loved by normal people as well and hence I compiled this list of dark themes for desktop Linux users like you. If you are new to theme-ing your desktop environment, you can take a look at our guide to [install themes in GNOME](https://itsfoss.com/install-switch-themes-gnome-shell/). Just FYI, this is not a ranking list. ## 1. McMojave ![01 mojave](https://itsfoss.com/content/images/wordpress/2021/11/01_mojave-800x450.webp) [McMojave](https://github.com/vinceliuice/Mojave-gtk-theme?ref=itsfoss.com) is a GTK theme which takes inspiration from the macOS style user interface. This theme is offered in dark mode, obviously, but also in light mode, for… umm… whoever may want it. The McMojave GTK theme obviously supports GTK based Desktop Environments like Pantheon, Gnome, XFCE, Mate etc; but, this theme is also [available for KDE users](https://github.com/vinceliuice/McMojave-kde?ref=itsfoss.com). To compliment your Desktop Environment, which is now looking very similar to macOS, you can also install the [McMojave circle icon theme](https://github.com/vinceliuice/McMojave-circle?ref=itsfoss.com) for an even more complete experience. ## 2. Yaru ![02 yaru](https://itsfoss.com/content/images/wordpress/2021/11/02_yaru-800x403.webp) [Yaru](https://github.com/ubuntu/yaru?ref=itsfoss.com) is the default GTK (GNOME) theme that ships with [Ubuntu](https://ubuntu.com/?ref=itsfoss.com). The theme’s orange accent with darkened gray and hints of black is something that I feel is attractive. Now, you can make GNOME on Arch Linux look like Ubuntu. ( ͡° ͜ʖ ͡°) ## 3. Pop ![pop gtk](https://itsfoss.com/content/images/wordpress/2021/11/pop_gtk-800x450.webp) [Pop GTK theme](https://github.com/pop-os/gtk-theme?ref=itsfoss.com) is a theme created by the people at [System76](https://system76.com/?ref=itsfoss.com) for their Ubuntu based Linux distribution, [Pop!_OS](https://pop.system76.com/?ref=itsfoss.com). If you liked System76’s take on how GNOME should look in dark mode, you can try out the [Pop GTK theme](https://github.com/pop-os/gtk-theme?ref=itsfoss.com) in your Linux distribution of choice. To complete the Pop-esque look and feel, install the System76 provided [Pop icon](https://github.com/pop-os/icon-theme?ref=itsfoss.com) alongside their theme as well. ## 4. Nordic ![nordic](https://itsfoss.com/content/images/wordpress/2021/11/nordic-800x450.webp) Are you someone who loves simple and a somewhat flat design approach along with some gray, well, a lot of gray? Look no further than this theme that is based on the [Nord color palette](https://github.com/arcticicestudio/nord?ref=itsfoss.com). The Nordic GTK theme gives you exactly that. A GTK theme with simplistic design based on the Nord color palette. ## 5. Ultimate-Maia ![05 ultimate maia](https://itsfoss.com/content/images/wordpress/2021/11/05_ultimate_maia-800x450.webp) Ultimate-Maia is a GTK theme based on [Google’s Material theme](https://material.io/?ref=itsfoss.com) design philosophy. This theme has a subtle yet unique look and feel to itself, especially with all the different options available for the accent color. ## 6. Graphite ![06 graphite](https://itsfoss.com/content/images/wordpress/2021/11/06_graphite-800x450.webp) Graphite is a GTK theme that offers a completely unique appearance to your Desktop Environment (especially GNOME) while keeping the uniqueness of your DE just as same as before. It is something to take a look at. ## 7. Qogir ![qogir](https://itsfoss.com/content/images/wordpress/2021/11/Qogir-800x500.webp) Qogir is a GTK theme with flat design in mind. The Qogir theme goes above and beyond to provide you with customization options for title buttons, checkbox, radio buttons, switches and more. ## 8. Layan ![07 layan](https://itsfoss.com/content/images/wordpress/2021/11/07_layan-800x450.webp) You will be delighted to know that this list also includes Layan, a GTK theme with emphasis on smooth, rounded corners with a bubbly aesthetic to it. The Layan theme also inherits design philosophies from [Google’s Material design](https://material.io/?ref=itsfoss.com) guidelines. ## 9. Juno ![08 juno](https://itsfoss.com/content/images/wordpress/2021/11/08_juno-800x533.webp) Juno is another one of the best dark mode friendly GTK themes I found on my radar. Some may like it’s pitch black nature, some might not. But, if you have an OLED laptop or computer display, Juno feels like it was made for you to use. ## 10. Ant Themes ![ant](https://itsfoss.com/content/images/wordpress/2021/11/ant.webp) Ant is a GTK theme that takes some inspiration from the macOS layout and user interface elements, and in my opinion, the Ant theme implements it all nicely. ## 11. Equilux ![equilux](https://itsfoss.com/content/images/wordpress/2021/11/equilux-800x450.webp) Equilux theme gives you a nice theme with a subtle dark mode. This theme blends very well with GNOME and GNOME forks. I don’t have much to describe this theme, it is simple and elegant. ## 12. Orchis-dark ![orchis dark](https://itsfoss.com/content/images/wordpress/2021/11/orchis-dark-800x463.webp) Orchis-dark is the dark variant of the super cool Orchis theme. It gives the desktop an iOS/macOS sort of touch with rounded corners and fluid interface. You can guess that immediately by just glancing at it. ## 13. Elementary X ![elementary](https://itsfoss.com/content/images/wordpress/2021/11/elementary-800x450.webp) Elementary X is a GTK theme based on the efforts made by the [elementary OS](https://elementary.io/?ref=itsfoss.com) team to customize GNOME’s appearance. If you did not know, elementary OS is a Linux distribution that is based on Ubuntu. ## Conclusion Themes listed in this article piece are nothing short of beautiful and neither are your options limited to the ones listed here. There are thousands more out in the wild. Comment down below if you liked a theme. If you are using a theme that I haven’t mentioned, please comment down below.
14,051
如何使用 dig
https://jvns.ca/blog/2021/12/04/how-to-use-dig/
2021-12-05T19:26:00
[ "DNS", "dig" ]
https://linux.cn/article-14051-1.html
![](/data/attachment/album/202112/05/192530gj36ttdwz16azu6w.jpg) 你好!最近我和几个朋友聊天,他们提到希望知道如何使用 `dig` 来进行 DNS 查询,所以这是一篇关于它的速读博文。 当我第一次使用 `dig` 时,我发现它有点吓人 —— 有这么多的选项!我打算把大部分的选项省略。在这篇文章中,我打算不谈 `dig` 的大部分选项,只谈我实际使用的选项。 我最近还了解到,你可以设置一个 `.digrc` 配置文件,让它的输出更容易阅读,这让它的使用变得更加轻松。 几年前我还画了一个关于 `dig` 的 [zine 页](https://wizardzines.com/comics/dig/),但我想写这篇文章来包括更多的信息。 ### 两种类型的 dig 参数:查询和格式化 有两种主要的参数可以传递给 `dig`: 1. 告诉 `dig` **要进行什么 DNS 查询的参数**。 2. 告诉 `dig` 如何 **格式化响应的参数**。 首先,让我们看一下查询选项。 ### 主要的查询选项 你通常想控制 DNS 查询的 3 件事是: 1. **名称**(如 `jvns.ca`)。默认情况下,查询的是空名称(`.`)。 2. **DNS 查询类型**(如 `A` 或 `CNAME`)。默认是 `A`。 3. 发送查询的 **服务器**(如 `8.8.8.8`)。默认是 `/etc/resolv.conf` 中的内容。 其格式是: ``` dig @server name type ``` 这里有几个例子: * `dig @8.8.8.8 jvns.ca` 向谷歌的公共 DNS 服务器(`8.8.8.8`)查询 `jvns.ca`。 * `dig ns jvns.ca` 对 `jvns.ca` 进行类型为 `NS` 的查询。 ### `-x`:进行反向 DNS 查询 我偶尔使用的另一个查询选项是 `-x`,用于进行反向 DNS 查询。下面是输出结果的样子。 ``` $ dig -x 172.217.13.174 174.13.217.172.in-addr.arpa. 72888 IN PTR yul03s04-in-f14.1e100.net。 ``` `-x` 不是魔术。`dig -x 172.217.13.174` 只是对 `174.13.217.172.in-addr.arpa.` 做了一个 `PTR` 查询。下面是如何在不使用 `-x’ 的情况下进行完全相同的反向 DNS 查询。 ``` $ dig ptr 174.13.217.172.in-addr.arpa. 174.13.217.172.in-addr.arpa. 72888 IN PTR yul03s04-in-f14.1e100.net。 ``` 我总是使用 `-x`,因为它可以减少输入。 ### 格式化响应的选项 现在,让我们讨论一下你可以用来格式化响应的参数。 我发现 `dig` 默认格式化 DNS 响应的方式对初学者来说是很难接受的。下面是输出结果的样子: ``` ; <<>> DiG 9.16.20 <<>> -r jvns.ca ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28629 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ; COOKIE: d87fc3022c0604d60100000061ab74857110b908b274494d (good) ;; QUESTION SECTION: ;jvns.ca. IN A ;; ANSWER SECTION: jvns.ca. 276 IN A 172.64.80.1 ;; Query time: 9 msec ;; SERVER: 192.168.1.1#53(192.168.1.1) ;; WHEN: Sat Dec 04 09:00:37 EST 2021 ;; MSG SIZE rcvd: 80 ``` 如果你不习惯看这个,你可能需要花点时间来筛选,找到你要找的 IP 地址。而且大多数时候,你只对这个响应中的一行感兴趣(`jvns.ca. 180 IN A 172.64.80.1`)。 下面是我最喜欢的两种方法,可以使 `dig` 的输出更容易管理: #### 方式 1 : +noall +answer 这告诉 `dig` 只打印 DNS 响应中的“答案”部分的内容。下面是一个查询 `google.com` 的 `NS` 记录的例子: ``` $ dig +noall +answer ns google.com google.com. 158564 IN NS ns4.google.com. google.com. 158564 IN NS ns1.google.com. google.com. 158564 IN NS ns2.google.com. google.com. 158564 IN NS ns3.google.com. ``` 这里的格式是: ``` NAME TTL TYPE CONTENT google.com 158564 IN NS ns3.google.com. ``` 顺便说一下:如果你曾经想知道 `IN` 是什么意思,它是指“查询类”,代表“<ruby> 互联网 <rt> internet </rt></ruby>”。它基本上只是上世纪 80、90 年代的遗物,当时还有其他网络与互联网竞争,如“<ruby> 混沌网络 <rt> chaosnet </rt></ruby>”。 #### 方式 2:+short 这就像 `dig +noall +answer`,但更短:它只显示每条记录的内容。比如说: ``` $ dig +short ns google.com ns2.google.com. ns1.google.com. ns4.google.com. ns3.google.com. ``` ### 你可以在 `digrc` 中设置格式化选项 如果你不喜欢 `dig` 的默认格式(我就不喜欢!),你可以在你的主目录下创建一个 `.digrc` 文件,告诉它默认使用不同的格式。 我非常喜欢 `+noall +answer` 格式,所以我把 `+noall +answer` 放在我的 `~/.digrc` 中。下面是我使用该配置文件运行 `dig jvns.ca` 时的情况。 ``` $ dig jvns.ca jvns.ca. 255在172.64.80.1中 ``` 这样读起来就容易多了! 如果我想回到所有输出的长格式(我有时会这样做,通常是因为我想看响应的权威部分的记录),我可以通过运行再次得到一个长答案。 ``` $ dig +all jvns.ca ``` ### dig +trace 我使用的最后一个 `dig` 选项是 `+trace`。`dig +trace` 模仿 DNS 解析器在查找域名时的做法 —— 它从根域名服务器开始,然后查询下一级域名服务器(如 `.com`),以此类推,直到到达该域名的权威域名服务器。因此,它将进行大约 30 次 DNS 查询。(我用 `tcpdump` 检查了一下,对于每个根域名服务器的 `A` / `AAAA` 记录它似乎要进行 2 次查询,所以这已经是 26 次查询了。我不太清楚它为什么这样做,因为它应该已经有了这些 IP 的硬编码,但它确实如此。) 我发现这对了解 DNS 的工作原理很有用,但我不认为我用它解决过问题。 ### 为什么要用 dig 尽管有一些更简单的工具来进行 DNS 查询(如 `dog` 和 `host`),我发现自己还是坚持使用 `dig`。 我喜欢 `dig` 的地方实际上也是我 **不喜欢** `dig` 的地方 —— 它显示了大量的细节! 我知道,如果我运行 `dig +all`,它将显示 DNS 响应的所有部分。例如,让我们查询 `jvns.ca` 的一个根名称服务器。响应有 3 个部分,我可能会关心:回答部分、权威部分和附加部分。 ``` $ dig @h.root-servers.net. jvns.ca +all ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18229 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 9 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ;; QUESTION SECTION: ;jvns.ca. IN A ;; AUTHORITY SECTION: ca. 172800 IN NS c.ca-servers.ca. ca. 172800 IN NS j.ca-servers.ca. ca. 172800 IN NS x.ca-servers.ca. ca. 172800 IN NS any.ca-servers.ca. ;; ADDITIONAL SECTION: c.ca-servers.ca. 172800 IN A 185.159.196.2 j.ca-servers.ca. 172800 IN A 198.182.167.1 x.ca-servers.ca. 172800 IN A 199.253.250.68 any.ca-servers.ca. 172800 IN A 199.4.144.2 c.ca-servers.ca. 172800 IN AAAA 2620:10a:8053::2 j.ca-servers.ca. 172800 IN AAAA 2001:500:83::1 x.ca-servers.ca. 172800 IN AAAA 2620:10a:80ba::68 any.ca-servers.ca. 172800 IN AAAA 2001:500:a7::2 ;; Query time: 103 msec ;; SERVER: 198.97.190.53#53(198.97.190.53) ;; WHEN: Sat Dec 04 11:23:32 EST 2021 ;; MSG SIZE rcvd: 289 ``` `dog` 也显示了 “附加” 部分的记录,但它没有明确指出哪个是哪个(我猜 `+` 意味着它在附加部分?) ,但它似乎没有显示“权威”部分的记录。 ``` $ dog @h.root-servers.net. jvns.ca NS ca. 2d0h00m00s A "c.ca-servers.ca." NS ca. 2d0h00m00s A "j.ca-servers.ca." NS ca. 2d0h00m00s A "x.ca-servers.ca." NS ca. 2d0h00m00s A "any.ca-servers.ca." A c.ca-servers.ca. 2d0h00m00s + 185.159.196.2 A j.ca-servers.ca. 2d0h00m00s + 198.182.167.1 A x.ca-servers.ca. 2d0h00m00s + 199.253.250.68 A any.ca-servers.ca. 2d0h00m00s + 199.4.144.2 AAAA c.ca-servers.ca. 2d0h00m00s + 2620:10a:8053::2 AAAA j.ca-servers.ca. 2d0h00m00s + 2001:500:83::1 AAAA x.ca-servers.ca. 2d0h00m00s + 2620:10a:80ba::68 AAAA any.ca-servers.ca. 2d0h00m00s + 2001:500:a7::2 ``` 而 `host` 似乎只显示“答案”部分的记录(在这种情况下没有得到记录): ``` $ host jvns.ca h.root-servers.net Using domain server: Name: h.root-servers.net Address: 198.97.190.53#53 Aliases: ``` 总之,我认为这些更简单的 DNS 工具很好(我甚至自己做了一个 [简单的网络 DNS 工具](https://dns-lookup.jvns.ca/)),如果你觉得它们更容易,你绝对应该使用它们,但这就是为什么我坚持使用 `dig` 的原因。`drill` 的输出格式似乎与 `dig` 的非常相似,也许 `drill` 更好!但我还没有真正试过它。 ### 就这些了 我最近才知道 `.digrc`,我非常喜欢使用它,所以我希望它能帮助你们中的一些人花更少的时间来整理 `dig` 的输出! 有人在 Twitter 上指出,如果有办法让 `dig` 显示响应的简短版本,其中也包括响应的状态(如 `NOERROR`、`NXDOMAIN`、`SERVFAIL` 等),那就更好了!我同意这个观点!不过我在手册中没有找到这样的选项。 --- via: <https://jvns.ca/blog/2021/12/04/how-to-use-dig/> 作者:[Julia Evans](https://jvns.ca/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Hello! I talked to a couple of friends recently who mentioned they wished they knew how to use `dig` to make DNS queries, so here’s a quick blog post about it. When I first started using `dig` I found it a bit intimidating – there are so many options! I’m going to leave out most of dig’s options in this post and just talk about the ones I actually use. Also I learned recently that you can set up a `.digrc` configuration file to make its output easier to read and it makes it SO MUCH nicer to use. I also drew a [zine page about dig](https://wizardzines.com/comics/dig/) a few years ago, but I wanted to write this post to include a bit more information. ### 2 types of dig arguments: query and formatting There are 2 main types of arguments you can pass to `dig` : - arguments that tell dig **what DNS query to make** - arguments that tell dig how to **format the response** First, let’s go through the query options. ### the main query options The 3 things you usually want to control about a DNS query are: - the **name**(like`jvns.ca` ). The default is a query for the empty name (`.` ). - the **DNS query type**(like`A` or`CNAME` ). The default is`A` . - the **server**to send the query to (like`8.8.8.8` ). The default is what’s in`/etc/resolv.conf` . The format for these is: ``` dig @server type name ``` Here are a couple of examples: `dig @8.8.8.8 jvns.ca` queries Google’s public DNS server (`8.8.8.8` ) for`jvns.ca` .`dig ns jvns.ca` makes an query with type`NS` for`jvns.ca` `-x` : make a reverse DNS query One other query option I use occasionally is `-x` , to make a reverse DNS query. Here’s what the output looks like. ``` $ dig -x 172.217.13.174 174.13.217.172.in-addr.arpa. 72888 IN PTR yul03s04-in-f14.1e100.net. ``` `-x` isn’t magic – `dig -x 172.217.13.174` just makes a `PTR` query for `174.13.217.172.in-addr.arpa.` . Here’s how to make exact the same reverse DNS query without using `-x` . ``` $ dig ptr 174.13.217.172.in-addr.arpa. 174.13.217.172.in-addr.arpa. 72888 IN PTR yul03s04-in-f14.1e100.net. ``` I always use `-x` though because it’s less typing. ### options for formatting the response Now, let’s talk about arguments you can use to format the response. I’ve found that the way `dig` formats DNS responses by default is pretty overwhelming to beginners. Here’s what the output looks like: ``` ; <<>> DiG 9.16.20 <<>> -r jvns.ca ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28629 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ; COOKIE: d87fc3022c0604d60100000061ab74857110b908b274494d (good) ;; QUESTION SECTION: ;jvns.ca. IN A ;; ANSWER SECTION: jvns.ca. 276 IN A 172.64.80.1 ;; Query time: 9 msec ;; SERVER: 192.168.1.1#53(192.168.1.1) ;; WHEN: Sat Dec 04 09:00:37 EST 2021 ;; MSG SIZE rcvd: 80 ``` If you’re not used to reading this, it might take you a while to sift through it and find the IP address you’re looking for. And most of the time, you’re only interested in one line of this response (`jvns.ca. 276 IN A 172.64.80.1` ). Here are my 2 favourite ways to make dig’s output more manageable. **way 1: +noall +answer** This tells dig to just print what’s in the “Answer” section of the DNS response. Here’s an example of querying for the `NS` records for `google.com` . ``` $ dig +noall +answer ns google.com google.com. 158564 IN NS ns4.google.com. google.com. 158564 IN NS ns1.google.com. google.com. 158564 IN NS ns2.google.com. google.com. 158564 IN NS ns3.google.com. ``` The format here is: ``` NAME TTL TYPE CONTENT google.com 158564 IN NS ns3.google.com. ``` By the way: if you’ve ever wondered what `IN` means, it’s the “query class” and stands for “internet”. It’s basically just a relic from the 80s and 90s when there were other networks competing with the internet like “chaosnet”. **way 2: +short** This is like `dig +noall +answer` , but even shorter – it just shows the content of each record. For example: ``` $ dig +short ns google.com ns2.google.com. ns1.google.com. ns4.google.com. ns3.google.com. ``` ### you can put formatting options in `digrc` If you don’t like dig’s default format (I don’t!), you can tell it to use a different format by default by creating a `.digrc` file in your home directory. I really like the `+noall +answer` format, so I put `+noall +answer` in my `~/.digrc` . Here’s what it looks like for me when I run `dig jvns.ca` using that configuration file. ``` $ dig jvns.ca jvns.ca. 255 IN A 172.64.80.1 ``` So much easier to read! And if I want to go back to the long format with all of the output (which I do sometimes, usually because I want to look at the records in the Authority section of the response), I can get a long answer again by running: ``` $ dig +all jvns.ca ``` ### dig +trace The last dig option that I use is `+trace` . `dig +trace` mimics what a DNS resolver does when it looks up a domain – it starts at the root nameservers, and then queries the next level of nameservers (like `.com` ), and so on until it reaches the authoritative nameserver for the domain. So it’ll make about 30 DNS queries. (I checked using tcpdump, it seems to make 2 queries to get A/AAAA records for each of the root nameservers so that’s already 26 queries. I’m not really sure *why* it does this because it should already have those IPs hardcoded, but it does.) I find this mostly useful for understanding how DNS works though, I don’t think that I’ve used it to solve a problem. ### why dig? Even though there are simpler tools to make DNS queries (like `dog` and `host` ), I find myself sticking with dig. What I like about dig is actually the same thing I **don’t** like about dig – it shows a lot of detail! I know that if I run `dig +all` , it’ll show me all of the sections of the DNS response. For example, let’s query one of the root nameservers for `jvns.ca` . The response has 3 sections I might care about – Answer, Authority, and Additional. ``` $ dig @h.root-servers.net. jvns.ca +all ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18229 ;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 9 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ;; QUESTION SECTION: ;jvns.ca. IN A ;; AUTHORITY SECTION: ca. 172800 IN NS c.ca-servers.ca. ca. 172800 IN NS j.ca-servers.ca. ca. 172800 IN NS x.ca-servers.ca. ca. 172800 IN NS any.ca-servers.ca. ;; ADDITIONAL SECTION: c.ca-servers.ca. 172800 IN A 185.159.196.2 j.ca-servers.ca. 172800 IN A 198.182.167.1 x.ca-servers.ca. 172800 IN A 199.253.250.68 any.ca-servers.ca. 172800 IN A 199.4.144.2 c.ca-servers.ca. 172800 IN AAAA 2620:10a:8053::2 j.ca-servers.ca. 172800 IN AAAA 2001:500:83::1 x.ca-servers.ca. 172800 IN AAAA 2620:10a:80ba::68 any.ca-servers.ca. 172800 IN AAAA 2001:500:a7::2 ;; Query time: 103 msec ;; SERVER: 198.97.190.53#53(198.97.190.53) ;; WHEN: Sat Dec 04 11:23:32 EST 2021 ;; MSG SIZE rcvd: 289 ``` `dog` also shows the records in the “additional” section , but it’s not super explicit about which is which (I guess the `+` means it’s in the additional section?). It doesn’t seem to show the records in the “Authority” section. ``` $ dog @h.root-servers.net. jvns.ca NS ca. 2d0h00m00s A "c.ca-servers.ca." NS ca. 2d0h00m00s A "j.ca-servers.ca." NS ca. 2d0h00m00s A "x.ca-servers.ca." NS ca. 2d0h00m00s A "any.ca-servers.ca." A c.ca-servers.ca. 2d0h00m00s + 185.159.196.2 A j.ca-servers.ca. 2d0h00m00s + 198.182.167.1 A x.ca-servers.ca. 2d0h00m00s + 199.253.250.68 A any.ca-servers.ca. 2d0h00m00s + 199.4.144.2 AAAA c.ca-servers.ca. 2d0h00m00s + 2620:10a:8053::2 AAAA j.ca-servers.ca. 2d0h00m00s + 2001:500:83::1 AAAA x.ca-servers.ca. 2d0h00m00s + 2620:10a:80ba::68 AAAA any.ca-servers.ca. 2d0h00m00s + 2001:500:a7::2 ``` And `host` seems to only show the records in the “answer” section (in this case no records) ``` $ host jvns.ca h.root-servers.net Using domain server: Name: h.root-servers.net Address: 198.97.190.53#53 Aliases: ``` Anyway, I think that these simpler DNS tools are great (I even made my own [simple web DNS tool](https://dns-lookup.jvns.ca/)) and you should absolutely use them if you find them easier but that’s why I stick with dig. `drill` ’s output format seems very similar to `dig` ’s though, and maybe `drill` is better! I haven’t really tried it. ### that’s all! I only learned about `.digrc` recently and I love using it so much, so I hope it helps some of you spend less time sorting though dig output! Someone on Twitter pointed out that it would be nice if there were a way to tell dig to show a short version of the response which also included the response’s status (like `NOERROR` , `NXDOMAIN` , `SERVFAIL` , etc), and I agree! I couldn’t find an option in the man page that does that though.
14,053
是时候让更多 Linux 发行版和桌面环境接受“老莱暴捶”了
https://news.itsfoss.com/more-linux-distros-become-linus-proof/
2021-12-06T10:33:46
[ "桌面", "Steam" ]
https://linux.cn/article-14053-1.html
![](/data/attachment/album/202112/06/103347wzayg7tcgt3falq2.png) > > “老莱” 体验 Pop!\_OS 的视频狠狠地给桌面 Linux 社区上了一课。 > > > 过去的几周,整个 Linux 桌面社区沸腾了。 知名 YouTube 创作者 Linus(LCTT 译注:不是 Linux 之父 Torvalds,是 Linus Tech Tips 的 Sebastian,“老莱”是国内网友对 Linus Sebastian 的称呼。)决定在一个月内挑战日常使用 Linux 桌面。“老莱” 想了解 Linux 是否已经达到了对用户友好的程度,乃至于“技术呆”级别的用户都能轻松上手。他的专注点同样也放在了 [Linux 游戏](https://itsfoss.com/linux-gaming-guide/) 上,毕竟电脑游戏确实也是 “老莱” 关注的一个领域。 这是一个有趣的概念,Linux 社区的许多人也十分兴奋,毕竟它向更广泛的技术受众群体免费宣传了桌面 Linux 平台。 唯一美中不足的是,这个日用 Linux 挑战 [从一开始就出了大乱子](https://www.youtube.com/watch?v=0506yDSgU7M&t=788s)。(LCTT 译注:[B 站](https://www.bilibili.com/video/BV1Fh411b7q3?t=769) 中也有相应的中文字幕视频。) ### “老莱”的 Pop!\_OS 名(或者说是“冥”)场面 (LCTT 译注:原文标题使用的是 (in)famous,同时指代“著名”和“臭名昭著”,此处的“冥场面”偏向事件悲剧性。) “老莱” 决定 [安装 Pop!\_OS](https://itsfoss.com/install-pop-os/),因为 Pop!\_OS 经常在社区中作为适合游戏的主流发行版出现。接下来,他尝试在软件中心(即 Pop!\_Shop)安装 Steam,但软件中心未能成功安装 Steam。 ![Sebastian 安装 Steam 时遇到了问题](/data/attachment/album/202112/06/103348rtsytyy4c445qsnd.jpg) 既然没能通过图形化方式安装,他接下来做了其他所有 Linux 用户都会做的事情。他打开了终端,运行了神奇的 `sudo apt-get install` 命令。 ![Sebastian 换用命令行方式安装 Steam](/data/attachment/album/202112/06/103349m88u8z1mxfxb88x1.jpg) 无论是图形化方式还是终端方式,Pop!\_OS 都显示了一条警告,提示用户正濒临卸载关键软件包的危险。 命令行方式清晰明了地警告:“***您的操作有潜在的危害性。若要继续,请输入下面的短句“是,按我说的做!(Yes, do as I say!)”***。” ![忽略移除关键软件包的警告](/data/attachment/album/202112/06/103349i0oigtugmvkuo0m7.jpg) 对于大部分 Linux 用户来说,到这一步就真的得停下来,深思熟虑了。输出的内容明确显示,接下来即将删除 `gdm3`、`pop-desktop` 和其他许多桌面环境要素。 但人们一般不会在意警告。于是 “老莱” 直接继续安装,最终就剩下了一个不能登录图形界面的损坏系统。 ![意识到他的 Pop!_OS 彻底出乱子后的 Linus Sebastian(不是 Torvalds)](/data/attachment/album/202112/06/103350zs99qt3qi1ay7n8y.jpg) ### 给桌面 Linux 开发者的深刻教训 对于开发者来说,这里有两点教训值得注意: * 安装 Steam 或任何其他常规软件时,不能导致关键的图形界面软件包被删除。 * 在一款常规的、主流的发行版中,用户不应该能删除关键软件包。 Pop!\_OS 迅速修复了 Steam 的问题,并增加了防御机制以阻止删除关键的桌面要素。 > > 出于某些原因,i386 版的软件包不能在 Launchpad 上发布。Steam 是一个 i386 软件包,在尝试安装 Steam 时不得不将该软件包降级到 Ubuntu 版本以解决依赖问题,然后就删除了 Pop!\_OS 的软件包。 > > > — Jeremy Soller (@jeremy\_soller) [2021 年 10 月 26 日](https://twitter.com/jeremy_soller/status/1453008808314351628?ref_src=twsrc%5Etfw) > > > 为避免此类事故,Pop!\_OS 为 APT 包管理器制作了补丁。现在,用户无法在 Pop!\_OS 通过输入“**是,按我说的做!(Yes, do as I say!)**”来删除关键软件包了。相反,用户将需要添加一个特殊文件来启用该功能(如果某个人真的想把这些关键软件包删掉的话)。(LCTT 译注:APT 2.3.12 上游已经彻底禁用卸载关键软件包的功能。) 对于 Pop!\_OS 来说,这确实是一个好举措。但,这并不仅仅是 Pop!\_OS 单方面的教训。大多数 Linux 发行版都可能会遇到这种情况,并最终删除掉桌面环境和显示服务器。 KDE 已经注意到了这一点,并在即将发布的 Plasma 5.24 中 [添加了禁止卸载 Plasma 桌面的功能](/article-14015-1.html)。 ![KDE Plasma 不允许用户卸载 Plasma 桌面](/data/attachment/album/202112/06/103351yy69caz4jgzk2sqy.png) 许多人责怪 “老莱” 不顾清晰明确的警告,直接继续并走向灾难。但问题在于,许多用户真的不会在意 “警告” 这种东西,不管他们技术水平如何。人们只是觉得按 “Y” 或者其他东西就是程序正常的部分,也不会去多想。一些 Linux 用户之前已经踩过这种坑了,但未来可能还会有更多人重蹈覆辙。 这就是为什么添加故障保护措施才是明智之举。这是所有主流发行版都应该做的事。 --- via: <https://news.itsfoss.com/more-linux-distros-become-linus-proof/> 作者:[Abhishek](https://news.itsfoss.com/author/root/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[imgradeone](https://github.com/imgradeone) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) The past few weeks have rattled the desktop Linux community. Popular tech YouTuber Linus, not Torvalds but Sebastian, decided to use Linux on desktop for a month. Linus Sebastian wanted to see if Linux has gotten to the point where it is user friendly enough that any tech nerd can pick it up and run? His focus was also on [gaming on Linux](https://itsfoss.com/linux-gaming-guide/?ref=news.itsfoss.com) because PC gaming is an area Sebastian covers a lot. That’s an interesting concept and many in the Linux community got excited because it was free publicity for desktop Linux to a wider tech audience. Only, it went [horribly wrong in the very first part of the Linux Daily Driver Challenge](https://www.youtube.com/watch?v=0506yDSgU7M&t=788s&ref=news.itsfoss.com). ## Linus Sebastian’s (in)famous Pop!OS moment Linus Sebastian decided to [install Pop!_OS](https://itsfoss.com/install-pop-os/?ref=news.itsfoss.com) because it is often considered a good mainstream distribution for gaming. He then tried to install Steam from the software center but the software center failed to install it. ![](https://news.itsfoss.com/content/images/wordpress/2021/11/pop-os-failed-steam-install-1024x456.webp) When it did not work graphically, he went on to do what any other Linux user would have done. He turned to the terminal and ran the magical sudo apt-get install command. ![](https://news.itsfoss.com/content/images/wordpress/2021/11/pop-os-failed-steam-install-1-1024x505.webp) In both graphical and terminal method, Pop!_OS showed a warning that the user was on the verge of removing some essential packages. The command line method clearly warned, “** You are about to do something potentially harmful. To continue type in the phrase ‘Yes, do as I say**‘”. ![](https://news.itsfoss.com/content/images/wordpress/2021/11/pop-os-failed-steam-install-2-1024x496.webp) For many Linux users, this could have been the point to pause and reflect. The output clearly shows that it is going to delete gdm3, pop-desktop and many other desktop environment elements. But people often do not care about warnings. Linus Sebastian went ahead with it and ended up with a broken system that cannot be logged in graphically. ![](https://news.itsfoss.com/content/images/wordpress/2021/11/linus-sebastian-nukes-pop-os-while-installing-steam-os-1024x475.webp) ## Lesson for the desktop Linux developers There are two lessons to learn here for the developers: - Installing Steam or any other regular software should never have resulted in removal of critical graphical elements. - A user should not be able to remove the critical piece of software from a regular, mainstream distribution. Pop!_OS quickly fixed the bug with Steam and also added a defensive mechanism to disable removal of critical desktop elements. To prevent such incidents in the future, Pop!_OS patched the APT package manager. Now, POP!_OS won’t be able to enter “Yes, do as I Say”. Instead, they will have to add a special a file to enable it (if someone really wants to remove the packages). That’s a good move by Pop!_OS. But this is not just a lesson for Pop!_OS. Most Linux distributions could encounter similar situation and end up deleting the desktop environment and display server itself. KDE took a note and adds a feature to [disable the removal of Plasma desktop in the upcoming Plasma 5.24 release](https://news.itsfoss.com/kde-plasma-5-24-dev/). ![KDE Plasma disables removal of Plasma desktop](https://news.itsfoss.com/content/images/wordpress/2021/11/cant-remove-plasma-1.png) Many people blamed Linus Sebastian for going ahead with the disaster despite clear warning. But here’s the thing, many users won’t care for “warnings”, no matter how technically advanced they are. People just assume that pressing Y or other similar stuff is just part of the procedure without thinking twice. Some other Linux users have encountered it in the past and many will encounter it in the future. This is why adding failsafe is the wise step here. This is something all mainstream distributions should do. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,054
如何在 Linux 上安装和设置 Flutter 开发环境
https://itsfoss.com/install-flutter-linux/
2021-12-06T11:59:07
[ "Flutter" ]
https://linux.cn/article-14054-1.html
![](/data/attachment/album/202112/06/115835fdjlxmd55mxew1nn.jpg) 谷歌的 UI 工具包 Flutter 在创建移动、网页和桌面的跨平台应用程序方面越来越受欢迎。 [Flutter](https://flutter.dev/) 不是一种编程语言,而是一个软件开发工具包。[Dart](https://dart.dev/) 是 Flutter SDK 下面使用的编程语言。 Flutter 是谷歌开源的 Fuchsia OS、谷歌 STADIA 以及许多其他软件和移动应用背后的主要框架。 如果你想使用 Flutter 进行开发,本教程将帮助你在 Ubuntu 和其他类似 Linux 发行版上搭建好你的环境。 ### 在 Ubuntu 和其他 Linux 上用 Snap 安装 Flutter 在 Linux 上安装 Flutter 最简单的方法是使用 Snap。如果你使用的是 Ubuntu,你已经有了 Snap。**对于其他发行版,请确保 [启用 Snap 支持](https://itsfoss.com/install-snap-linux/)**。 [打开终端](https://itsfoss.com/open-terminal-ubuntu/) 并在终端中使用以下命令来安装 Flutter: ``` sudo snap install flutter --classic ``` 你会在你的终端上看到类似这样的东西: ![](/data/attachment/album/202112/06/115908c0guz15670d06d6x.png) 一旦安装完成,就是验证它的时候了。不仅仅是 Flutter 的安装,还要验证 Flutter 正常运行所需满足的每一个依赖关系。 #### 验证 Flutter 的依赖项 为了验证 Flutter 正确工作所需的每一个依赖项,Flutter 有一个内置选项: ``` Flutter doctor ``` 这个过程开始看起来像这样: ![](/data/attachment/album/202112/06/115909pjh5fiivvxi5vcfi.png) 而它完成时像这样: ![](/data/attachment/album/202112/06/115910der0s2p332p2n0j1.png) 正如你所看到的,我们需要 Android Studio 来工作。所以让我们来安装它。我们该怎么做呢?用 Snap [在 Linux 上安装 Android Studio](https://itsfoss.com/install-android-studio-ubuntu-linux/) 也是毫不费力的。 #### 安装并设置好 Android Studio 在终端中,使用下面的命令来安装 Android Studio: ``` sudo snap install android-studio --classic ``` ![](/data/attachment/album/202112/06/115911oket1ntw0bsfsbfq.png) 安装完毕后,从我们的操作系统菜单中打开 Android Studio。 ![](/data/attachment/album/202112/06/115912igijeqg1pgdy4yoy.jpg) 就快完成了。现在是配置 Android Studio 的时候了。 ![](/data/attachment/album/202112/06/115913k0ofnntswfnfnkno.png) 点击下一步,如果你不想让事情复杂化,就选择“<ruby> 标准 <rt> standard </rt></ruby>”。 ![](/data/attachment/album/202112/06/115914asshz8cahdan0yh4.png) 选择你喜欢的主题(我喜欢“<ruby> 暗色 <rt> Darcula </rt></ruby>”的)。 ![](/data/attachment/album/202112/06/115915w44g54cl7nyfuklz.png) 确认一切正常,然后点击“<ruby> 下一步 <rt> Next </rt></ruby>”。 ![](/data/attachment/album/202112/06/115917i7fwrcfxcxzffq2x.png) 最后,点击“<ruby> 完成 <rt> Finish </rt></ruby>”按钮。 ![](/data/attachment/album/202112/06/115918ex78nrr9yyz4lygi.png) 然后等待,直到下载完成。 ![](/data/attachment/album/202112/06/115920rexuef3soxfbu3cu.png) ### 创建一个 Hello World Flutter 应用样本 在 Android Studio 中,进入项目,选择“<ruby> 新建 Flutter 项目 <rt> New Flutter Project </rt></ruby>”。Flutter SDK 路径会默认设置。 ![](/data/attachment/album/202112/06/115921w4hockzas77ocxc4.png) 在这里,神奇的事情开始出现了,这是你设置你的项目名称的地方,在这个例子中,它将被称为 “hello\_world”。 让我们选择三个可用的平台。**Android、iOS 和 Web**。最后,点击“<ruby> 完成 <rt> Finish </rt></ruby>”。 ![](/data/attachment/album/202112/06/115922tmauzq7h71lhku7a.png) 项目中的主文件位于 `lib/main.dart`,如下图所示: ![](/data/attachment/album/202112/06/115925g25vmr5drd5rrar2.png) 选定后,擦除文件中包含的所有内容,并将其改为本示例代码: ``` // Copyright 2018 The Flutter team. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: const Text('Welcome to Flutter'), ), body: const Center( child: Text('Hello World'), ), ), ); } } ``` 重要的是,这只是向你展示 Flutter 是如何工作的,如果你确信要学习这种美丽而不可思议的语言,这里有 [文档](https://flutter.dev/docs) 可以看到更多关于它的信息。**尝试**它! 最后,选择 “Chome Web” 设备,并点击“<ruby> 运行 <rt> Run </rt></ruby>”按钮,如下图所示;并看到神奇的效果! ![](/data/attachment/album/202112/06/115927nm9n4wtyzgqh6mv6.png) 你可以如此快速地创建一个 Flutter 项目,真是不可思议。跟你的 Hello World 项目打个招呼吧。 ![](/data/attachment/album/202112/06/115927c2k8uv05guph8fth.png) ### 最后... 如果你想在短时间内做出漂亮的移动和网页界面的贡献,Flutter 和 Dart 是完美的。 现在你知道了如何在 Ubuntu Linux 上安装 Flutter,以及如何用它创建你的第一个应用程序。我很高兴可以为你写这篇文章,希望对你有所帮助,如果你有任何问题,请通过留言或给我发邮件来告诉我,祝你好运! 本教程由 Marco Antonio Carmona Galván 提供,他是物理学和数据科学专业的学生。 --- via: <https://itsfoss.com/install-flutter-linux/> 作者:[Marco Antonio Carmona Galván](https://itsfoss.com/author/itsfoss/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Google’s UI toolkit Flutter is getting increasingly popular for creating cross-platform applications for the mobile, web and desktop. [Flutter](https://flutter.dev/) is not a programming language but a software development kit. [Dart](https://dart.dev/) is the programming language used underneath the Flutter SDK. Flutter is the main framework behind Google’s open source Fuchsia OS, Google STADIA and many other software and mobile apps. If you want to start developing with Flutter, this tutorial will help you to get your set-up ready on Ubuntu and hopefully other Linux distributions. ## Installing Flutter on Ubuntu and other Linux with Snap The easiest way to install Flutter on Linux is by using Snap. If you are using Ubuntu, you already have got Snap. *For other distributions, please make sure to enable Snap support.* [Open a terminal](https://itsfoss.com/open-terminal-ubuntu/) and use the following command in a terminal to install Flutter: `sudo snap install flutter --classic` You’ll see something like this on your terminal: ![installing Flutter on ubuntu](https://itsfoss.com/content/images/wordpress/2021/09/installing-flutter-ubuntu.png) Once the installation completes, it is time to verify it. Not just Flutter installation but also verify every dependency that needs to be satisfied for Flutter to function properly. ### Verify Flutter dependencies To verify that every dependency, for the correct work of Flutter, is installed, Flutter has a built-in option: `flutter doctor` The process will start, looking like this: ![Verify Flutter Install](https://itsfoss.com/content/images/wordpress/2021/09/verify-flutter-install.png) And it will be finishing like this: ![Flutter verification completes](https://itsfoss.com/content/images/wordpress/2021/09/Flutter-verification-completes.png) As you can see, we need Android Studio for working. So let’s install it. How do we do that? [Installing Android Studio on Linux](https://itsfoss.com/install-android-studio-ubuntu-linux/) is also effortless with Snap. ### Install and set up Android Studio In a terminal, use the following command to get Android Studio installed: `sudo snap install android-studio --classic` ![Install Android Studio in Linux with Snap](https://itsfoss.com/content/images/wordpress/2021/09/install-android-studio-linux-snap.png) Once installed, open Android Studio from our operating system menu. ![open android studio](https://itsfoss.com/content/images/wordpress/2021/09/Open_Android_Studio.webp) You are almost done. It’s time for configuring Android Studio. ![Setting up Android Studio](https://itsfoss.com/content/images/wordpress/2021/09/Setting-Up-Android-Studio-1-800x603.png) Click next and select standard if you don’t want to complicate things. ![Setting up Android Studio](https://itsfoss.com/content/images/wordpress/2021/09/Setting-Up-Android-Studio-2-800x603.png) Select your preferred theme (I like the Dark one). ![Setting up Android Studio](https://itsfoss.com/content/images/wordpress/2021/09/Setting-Up-Android-Studio-3-800x603.png) Verify that everything is OK and click on Next. ![Setting up Android Studio](https://itsfoss.com/content/images/wordpress/2021/09/Setting-Up-Android-Studio-4-800x603.png) Finally, hit the Finish button. ![Setting up Android Studio](https://itsfoss.com/content/images/wordpress/2021/09/Setting-Up-Android-Studio-5-800x603.png) And wait until the download is finished. ![Setting up Android Studio](https://itsfoss.com/content/images/wordpress/2021/09/Setting-Up-Android-Studio-6-800x603.png) ## Creating a sample Hello World Flutter app In Android Studio, go to Projects and select New Flutter Project. Flutter SDK path will be set by default. ![new flutter project](https://itsfoss.com/content/images/wordpress/2021/09/New_flutter_project-800x639.png) And here is where the magic starts to appear because this is where you set your project name, which in this case it will be called hello_world. Let’s select the three available platforms: **Android, iOS, and Web**. And finally, click on Finish. ![Sample Flutter project](https://itsfoss.com/content/images/wordpress/2021/09/sample-flutter-project-800x751.png) The principal file in the projects is located in `lib/main.dart` , as is shown in the next image. ![Sample Flutter projects](https://itsfoss.com/content/images/wordpress/2021/09/sample-flutter-project-1-800x435.png) Once selected, erase everything contained inside the file and change it for this sample code: ``` // Copyright 2018 The Flutter team. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Welcome to Flutter', home: Scaffold( appBar: AppBar( title: const Text('Welcome to Flutter'), ), body: const Center( child: Text('Hello World'), ), ), ); } } ``` It’s important to say that this is only for showing you how Flutter works, in case you’re convinced about learning this beautiful and incredible language, here is the [Documentation](https://flutter.dev/docs) to see more about it. **Try** it! Finally, select **Chome Web** device and do click on the **Run** button, as is shown below; and see the magic! ![Sample Flutter project in Ubuntu](https://itsfoss.com/content/images/wordpress/2021/09/sample-flutter-project-2-800x450.png) It’s incredible how fast you can create a Flutter project. Say hello to your Hello World project. ![Running a sample Flutter project](https://itsfoss.com/content/images/wordpress/2021/09/sample-flutter-project-3-800x549.png) ## In the end… Flutter and Dart are perfect if you want to contribute with beautiful mobile and Web interfaces in a short time. Now you know how to install Flutter on Ubuntu Linux and how to create your first app with it. I really enjoyed writing this post for you, hoping this helps you and if you have any questions, please let me know by leaving a comment or sending me an email to [[email protected]](/cdn-cgi/l/email-protection). Good luck! *Tutorial contributed by Marco Antonio Carmona Galván, a student of physics and data science.*
14,058
即将推出的 CutefishOS 可能取代深度成为最漂亮的 Linux 发行版
https://news.itsfoss.com/cutefishos-intro/
2021-12-07T10:40:34
[ "CutefishOS", "桌面" ]
https://linux.cn/article-14058-1.html
> > CutefishOS 能否以其美丽而简单的方式提供良好的 Linux 桌面体验? > > > ![](/data/attachment/album/202112/07/104017u0wx6s8mfgl4xlhu.png) CutefishOS 是一个相对较新的 Linux 发行版,捆绑了它自己的桌面环境(即 CutefishDE)。 它还不是一个稳定的版本,尚处在测试阶段。 然而,随着其最新的测试版(v0.6)的发布,它似乎正在成为现有 Linux 发行版的一个有前途的替代方案,专注于简单和美丽。 在这里,我将在你自己尝试之前强调一些关于它的事情。 ### CutefishOS 概览 ![](/data/attachment/album/202112/07/104035xx04sbm60s44zz5t.png) 请注意,它仍然处于早期开发阶段。因此,如果你打算稍后尝试,你应该对有错误和故障有心理准备。 CutefishOS 基于 [Debian 11 “Bullseye”](https://news.itsfoss.com/debian-11-feature/),因此,它应该适用于各种用户,包括 Linux 新用户。 值得注意的是,CutefishOS 并不是是专门针对资深用户的。因此,如果你正在寻找一个能提供精细控制和马上就可以定制的发行版,这并不适合你。 重要的是,CutefishOS 的开发者希望呈现一个令人耳目一新、无需费心的 Linux 发行版。 当然,如果你想要一个融合了可靠性和独特桌面体验的 Linux,我们会推荐你安装 [elementary OS](https://news.itsfoss.com/elementary-os-6-release/)、[Pop!\_OS](https://pop.system76.com)、[Zorin OS](https://news.itsfoss.com/zorin-os-16-release/) 或 [深度操作系统](https://news.itsfoss.com/deepin-linux-20-2-2-release/)。 而且,CutefishOS 计划成为同一类选择中的产品之一,这是一件好事。 我们有大量的 Linux 发行版,但并非所有的发行版都在现代 UI 和可用性方面处于同一水平。因此,如果 CutefishOS 能够达成其目标,这可能会成为 Linux 桌面用户的一个有用选择。 ### 它有什么不同? **用户体验不同。** 是的,与 Windows 和 macOS 相比,Linux 发行版一直试图成为最好的桌面体验之一。 ![](/data/attachment/album/202112/07/104035aizliie73vppgi33.png) 而且,CutefishOS 试图通过引入受到 macOS 启发的桌面体验(它不是第一个这样做的发行版)来加入这场比赛,但方式不同。 它的桌面环境(DE)是使用 Qt 和基本的 KDE 框架构建的,以此搭建出来了一个好看且资源高效的 DE。 CutefishOS 还提供了一个开箱即用的全局菜单功能。换句话说,你的应用程序的每一个选项都可以直接从状态栏中找到,这使得你的应用程序窗口看起来很干净,并有可能节省一些屏幕空间。 ![](/data/attachment/album/202112/07/104036cp932k3bk91p33pv.png) 虽然你也有可能在 GNOME 或其他桌面环境上实现这种功能,但你得投入一些时间来使其工作。 默认情况下,它呈现出细微的动画效果,但你可以选择使用魔法灯效果,这与 [Zorin OS 16 引入的 Jelly 模式](https://news.itsfoss.com/zorin-os-16-features/) 相似。CutefishOS 的应用程序,如计算器、屏幕截图、文件和视频播放器,都是为该桌面环境量身定做的,给你提供了统一的体验。 你还可以选择深色/浅色模式的主题,同时可以禁用系统效果,以尽量减少对性能的影响(如果你使用的是旧电脑)。 说到定制,你可以定制 Dock 的位置,将其转换为一个完整的 Dockbar,并选择在暗色模式下调暗墙纸。我想说的是,这些基本的定制选项,不会破坏你的体验,但可以让你调整一些东西。 你还可以在状态栏中找到切换开关(类似于 iOS 或其他手机)来启用/禁用 Wi-Fi / 蓝牙和暗色模式。 ![](/data/attachment/album/202112/07/104036p3341y73hk8h68y9.png) 至于功能,它目前已经提供了基本的功能,如文件管理器的拖放支持、电源管理、锁屏中的媒体控制,以及其他一些功能。 考虑到他们的目标是一个简单和易于使用的发行版,你不应该期望太多。 ![](/data/attachment/album/202112/07/104037dlnxi3ulv6rnxinv.png) ### 要不要试试 CutefishOS ? 我测试了 0.6 测试版,它大部分工作正常,直到我启动了预装的 Chromium 浏览器,整个显示都出现了问题。 这可能只是我在我的虚拟机上的问题。所以,如果你有兴趣尝试,我建议在虚拟机或测试机上测试一下,而不是想把它作为日常驱动使用。 * [CutefishOS](https://en.cutefishos.com) 不知何故,CutefishOS 很像 [JingOS](https://en.jingos.com/),这是一个为 Linux 平板电脑 [JingPad](https://itsfoss.com/jingpad-a1-review/) 开发的新发行版。但是他们并不是同一个开发商,尽管 CutefishOS 的网站提到 JingOS 是朋友。 它可能是 “又一个漂亮的发行版” 吗?只有时间才能证明。 它从一开始就看起来很有不错,如果开发者有能力提供一个有竞争力的桌面体验,我们或许可以在未来几年看到它作为 [最漂亮的 Linux 发行版之一](https://itsfoss.com/beautiful-linux-distributions/) 冒出来。 毕竟,我们都想真正看到 “Linux 桌面之年”,对吗?让我们看看是什么发行版为我们做到了这一点! 你对 CutefishOS 有什么看法?请在下面的评论中告诉我你的想法。 --- via: <https://news.itsfoss.com/cutefishos-intro/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) CutefishOS is a relatively new Linux distribution that comes bundled with its own desktop environment (i.e., CutefishDE). It is not yet a stable release, but in its beta phase. However, with its latest beta release (v0.6), it seems to be shaping up as a promising alternative to the available Linux distributions focusing on simplicity and beauty. Here, I shall highlight a few things about it before you get to try it yourself. ## CutefishOS: Overview ![](https://news.itsfoss.com/content/images/wordpress/2021/12/cutefish-os-1024x580.png) Note that it is still in its early stages of development. So, you should expect bugs and glitches if you are planning to try it later on. CutefishOS is based on [Debian 11 “Bullseye”](https://news.itsfoss.com/debian-11-feature/). Hence, it should be suitable for a variety of users, including new Linux users. It is worth noting that CutefishOS does not target advanced users. So, if you are looking for a distro that offers fine-grained controls and customizations out-of-the-box, this isn’t for you. Primarily, CutefishOS developers want to present a refreshing and hassle-free Linux distribution. Of course, we would recommend you to install [elementary OS](https://news.itsfoss.com/elementary-os-6-release/), [Pop!_OS](https://pop.system76.com/?ref=news.itsfoss.com), [Zorin OS](https://news.itsfoss.com/zorin-os-16-release/), or [Deepin ](https://news.itsfoss.com/deepin-linux-20-2-2-release/)Linux if you want a blend of reliability with a unique desktop experience. And, CutefishOS plans to be one of the offerings in the same category of choice, which is a good thing. We have loads of Linux distributions, but not all of them focus on a modern UI and usability at the same level. So, if CutefishOS manages to provide what it aims for, this could turn out to be a useful option for Linux desktop users. ## What’s Different About It? **User experience.** Yes, Linux distributions have been trying their best to provide one of the best desktop experiences when compared to Windows and macOS. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/cutefish-os-appearance.png) And, CutefishOS tries to get in the game by introducing a macOS-inspired desktop experience (not the first time), but in a different way. Its desktop environment (DE) is built using Qt and basic KDE frameworks. This makes up for a good-looking and resource-efficient DE. CutefishOS also provides a global menu feature out of the box. In other words, every option that you get with your app is accessible directly from the status bar, which makes your application window look clean and potentially saves some screen space. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/cutefish-os-global-menu.png) While it is possible to implement it for GNOME or other desktop environments, you will have to invest some time to get it right. By default, it presents subtle animation effects, but you can choose to use the magic lamp effect, which is similar to the [Jelly Mode introduced with Zorin OS 16](https://news.itsfoss.com/zorin-os-16-features/). The CutefishOS applications like calculator, screenshot, files, and video player have been tailored for the desktop environment to give you a uniform experience. You can also choose between a dark/light mode theme, along with the ability to disable the system effects to minimize the impact on performance (if you are using an older computer). When it comes to customization, you can customize the dock placement, convert it to a full dockbar and choose to dim the wallpaper in dark mode. I would say, you get essential customization options that does not break your experience but lets you tweak a few things. You also get toggle switches (similar to iOS or other mobile phones) in the status bar to enable/disable Wi-Fi/Bluetooth and dark mode. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/system-tray-toggles.png) If we talk about the functionalities, it currently provides basic features like drag and drop support for file manager, power management, media controls in lock screen, and a few more. You should not expect much, considering they aim for a simple and easy-to-use distro. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/cutefish-os-about.png) ## Should You Try CutefishOS? I tested the 0.6 beta release, which works mostly fine until I launched the Chromium browser (pre-installed) and the entire display went for a toss. It could just be me on my virtual machine. So, if you are interested to try it out, I recommend testing things out on a VM or a test machine instead of thinking to use it as a daily driver. Somehow, CutefishOS resembles the [JingOS](https://en.jingos.com/?ref=news.itsfoss.com), a new distro developed for Linux tablet [JingPad](https://itsfoss.com/jingpad-a1-review/?ref=news.itsfoss.com). But they are not the same developers though CutefishOS’ website mentions JingOS as friends. Could it be “**yet another pretty distro**“? Only time will tell. It looks useful from the get-go, and if the developers are capable of providing a competing desktop experience, we could see it pop up as [one of the most beautiful Linux disros](https://itsfoss.com/beautiful-linux-distributions/?ref=news.itsfoss.com) in the coming years. After all, we all want to see “the year of Linux desktop” in its full glory, right? Let’s see what distro does that for us! What do you think about CutefishOS? Let me know your thoughts in the comments down below. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,060
GNOME 有了一个全新的“文本编辑器”,它会成为默认编辑器吗?
https://news.itsfoss.com/gnome-text-editor-to-replace-gedit/
2021-12-08T11:44:54
[ "GNOME", "Gedit" ]
https://linux.cn/article-14060-1.html
> > GNOME 新的“文本编辑器”正在增加新的功能,有可能在下一个 GNOME 桌面版本中取代 Gedit。 > > > ![](/data/attachment/album/202112/08/114455pnwafw8n1niwn222.jpg) Gedit 是 GNOME 桌面环境的默认文本编辑器。它是一个受欢迎的编辑器,也是一个便捷的文本编辑器,以简单的用户界面提供了所有的基本功能。 但是,随着 GNOME 的发展,有了一个新的“文本编辑器”(LCTT 译注:没错,就叫“<ruby> 文本编辑器 <rt> Text Editor </rt></ruby>”),虽然它还没有取代 Gedit。但让我们来看看它的下一个版本,在即将到来的 GNOME 42 版本中,它进行了大量改进,有可能取代 Gedit。 [Christian Hergert](https://twitter.com/hergertme) 在他的 [博文](https://blogs.gnome.org/chergert/2021/12/03/text-editor-happenings/) 和 Twitter 上分享了它的很多细节。 在这篇文章中,让我介绍一下 GNOME 文本编辑器的那些新改进。 ### 偏好设置对话框卷土重来 作为其上一个版本中的实验的一部分,偏好设置对话框被移到了侧边栏, ![](/data/attachment/album/202112/08/114455suxxxljjxqnuvcqj.png) 但是,事实证明,它并不那么方便和好看。 因此,偏好设置对话框又回来了(如下图所示),其目的是与其他 GNOME 应用程序的设计语言相融合,而不显得笨拙。 ![鸣谢:Christian Hergert](/data/attachment/album/202112/08/114456gv57p22j2oi3om2h.png) 在我看来,这很不错,与侧边栏的实施相比,应该用户体验更好。 ### 改进的 “弹出式” 打开功能 ![鸣谢:Christian Hergert](/data/attachment/album/202112/08/114458u9zosqwt3707vgv4.jpg) 当你试图打开一个最近的文件或搜索某个东西时,会出现一个弹出式窗口来快速查找任何最近的文件,而不需要启动一个新的对话框。 这节省了时间,是一个不错的功能。在即将发布的“文本编辑器”中还进行了一些细微的改进,显得更苗条、更便捷。 换句话说,你会发现它改进了键盘导航,只需按下 `Ctrl + K`,就可以寻找你想要的文件。 ### 引入重新着色支持 即将发布的 GNOME 文本编辑器可以让你轻松地应用不同的风格模式(或主题),而改变整个应用程序。 博文中提到了更多关于它的内容: > > 本周最直观的工作是引入了重新着色支持。它建立在 [libadwaita](https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/) 之上,并使用一个 CSS 提供者来覆盖主题中的颜色。我希望在不远的将来,libadwaita 会有一个重新着色的 API,为我们提供这个功能。 > > > 下面是一个应用样式表时的例子: ![鸣谢:Christian Hergert](/data/attachment/album/202112/08/114459knlx7dsian6fas4a.png) 它有一些自带的主题,而且你还可以找到更多的主题。你可以在 Christian 的博客文章中找到更多截图: ![鸣谢:Christian Hergert](/data/attachment/album/202112/08/114500z0ahakwhwhaage9g.png) 你可以看看 [博客文章中的更多内容](https://blogs.gnome.org/chergert/2021/12/03/text-editor-happenings/),还可以发现一些其他的技术变化,和一个由 Christian 设计的 vim 仿真的复活节彩蛋。 ### GNOME “文本编辑器”会取代 Gedit 吗? 到现在为止,官方还没有确认这一点。然而,看一下 [Gedit 的开发活动](https://gitlab.gnome.org/GNOME/gedit)(目前有 41 个 alpha 版本),在过去的几个版本中没有明显增加变化,这可能意味着新的 GNOME “文本编辑器”将在GNOME 42 中取代 Gedit。 事实上,正如其 [GitLab 页面](https://gitlab.gnome.org/GNOME/gnome-text-editor) 中所提到的,GNOME 的新文本编辑器计划正式取代 Gedit,但它会在 GNOME 42 中发生吗?它的开发者 Christian Hergert 在他的博客中提到: > > 随着我们为 GNOME 42 的准备工作而进行的竞赛,[文本编辑器](https://gitlab.gnome.org/GNOME/gnome-text-editor) 在过去的几周里已经成型。 > > > 这可以被认为是一个暗示,GNOME 42 可能会包含这个新的文本编辑器。 不仅仅是 GNOME,[KDE 也对 Kate 进行了改造](https://news.itsfoss.com/kate/),增加了针对开发者的功能。你将会有很多 [开源的文本编辑器](https://itsfoss.com/best-modern-open-source-code-editors-for-linux/) 可以选择。 当它发布时,我们将继续关注它。你怎么看? --- via: <https://news.itsfoss.com/gnome-text-editor-to-replace-gedit/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) Gedit is the default text editor for the GNOME desktop environment. It is a popular option and an effective text editor that offers all the essentials with a simple user interface. But, with GNOME evolving, there is a new text editor that hasn’t yet replaced gedit. And, looking at its next release, it might just be ready to replace gedit in the upcoming GNOME 42 release with a bunch of improvements. [Christian Hergert](https://twitter.com/hergertme?ref=news.itsfoss.com) shares more details about it in his [blog post](https://blogs.gnome.org/chergert/2021/12/03/text-editor-happenings/?ref=news.itsfoss.com) and on Twitter. In this article, let me highlight those new improvements to GNOME Text Editor. ## Preferences Dialogue Makes a Comeback The preferences setting was moved to the sidebar as part of an experiment in its previous release. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/gnome-text-editor-old-preferences.png) But, it did not prove to be as convenient and good-looking. So, the preferences dialogue is coming back (as shown in the screenshot below) that aims to blend in with the design language of other GNOME apps without being clunky. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/gnome-text-editor-preferences-677x1024.png) Looks pretty sweet to me and should give a better user experience compared to the sidebar implementation for sure! ## Improved Open ‘Popover’ Feature ![](https://news.itsfoss.com/content/images/wordpress/2021/12/gnome-text-editor-popover-1024x685.jpg) When you try to open a recent file or search for something, a popover appears to quickly look for any recent files without launching a new dialogue box. This saves time and is a nice feature to have. With the upcoming release for text editor, this has received some slight improvements to appear slimmer and more effective. In other words, you will find it improved for keyboard navigation by simply hitting Ctrl + K and then looking for the file you want. ## Introducing Recoloring Support The upcoming release for GNOME’s text editor will let you easily apply different style-scheme (or themes) that affects the entire application. The blog post mentions more about it: The most visual piece of work this week was in introducing recoloring support. It builds atop [libadwaita]and uses a CSS provider to override the colors in the theme. I expect there will be a recoloring API in the not-too distant future for libadwaita which will provide this for us. Here’s a sample of what it looks like when you apply a style-scheme: ![](https://news.itsfoss.com/content/images/wordpress/2021/12/gnome-text-editor-style-scheme-1024x757.png) You can find some of the themes bundled and can look for more as you explore. You can find more screenshot in Christian’s blog post. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/gnome-text-editor-style-scheme-1-1024x757.png) You can also find some other technical changes and a vim emulation easter egg by Christian as you explore the [blog post for more details](https://blogs.gnome.org/chergert/2021/12/03/text-editor-happenings/?ref=news.itsfoss.com). ## Will GNOME Text Editor Replace Gedit? As of now, there is no official confirmation on this. However, looking at the [development activity for gedit](https://gitlab.gnome.org/GNOME/gedit?ref=news.itsfoss.com) (currently as 41 alpha version) with no significant additions in the past few releases, it could mean that the new GNOME Text Editor will replace gedit in GNOME 42. In fact, GNOME’s new text editor plans to officially replace gedit as mentioned in its [GitLab page](https://gitlab.gnome.org/GNOME/gnome-text-editor?ref=news.itsfoss.com), but will it happen with GNOME 42? Its developer, Christian Hergert, mentions in his blog [Text Editor]has really been shaping up in the past couple weeks as we race towards getting things ready for GNOME 42. This could be taken as a hint that GNOME 42 may seem the inclusion of this new text editor. It’s not just GNOME. [KDE also has revamped Kate](https://news.itsfoss.com/kate/) by adding features for developers. You’ve got plenty of [open source text editors](https://itsfoss.com/best-modern-open-source-code-editors-for-linux/?ref=news.itsfoss.com) to choose from. We shall keep an eye on it when it releases. What do you think? ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,061
FreeDOS 配置指南
https://opensource.com/article/21/6/freedos-fdconfigsys
2021-12-08T12:46:00
[ "FreeDOS" ]
/article-14061-1.html
> > 学习如何使用 FDCONFIG.SYS 来配置 FreeDOS 。 > > > ![](/data/attachment/album/202112/08/124646wahca435y60acpha.jpg "Person using a laptop") FreeDOS 是主配置文件是在根目录中的名称为 `FDCONFIG.SYS` 的文件。这个文件包含一系列的行,每行都设置一个诸如 `LASTDRIVE=Z` 或 `FILES=40` 的值。例如,在 FreeDOS 1.3 RC4 中的默认 `FDCONFIG.SYS` ,看起来像这样: ``` SET DOSDIR=C:\FDOS !COUNTRY=001,858,C:\FDOS\BIN\COUNTRY.SYS !LASTDRIVE=Z !BUFFERS=20 !FILES=40 !MENUCOLOR=7,0 MENUDEFAULT=1,5 MENU 1 - Load FreeDOS with JEMMEX, no EMS (most UMBs), max RAM free MENU 2 - Load FreeDOS with JEMM386 (Expanded Memory) MENU 3 - Load FreeDOS low with some drivers (Safe Mode) MENU 4 - Load FreeDOS without drivers (Emergency Mode) 12?DOS=HIGH 12?DOS=UMB 12?DOSDATA=UMB 1?DEVICE=C:\FDOS\BIN\JEMMEX.EXE NOEMS X=TEST I=TEST NOVME NOINVLPG 234?DEVICE=C:\FDOS\BIN\HIMEMX.EXE 2?DEVICE=C:\FDOS\BIN\JEMM386.EXE X=TEST I=TEST I=B000-B7FF NOVME NOINVLPG 34?SHELL=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT 12?SHELLHIGH=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT ``` 但是,这些指令行都表示什么意思?为什么一些指令行有一个问号(`?`)或一个叹号(`!`),而其它的命令行却没有? ### 一个简单的配置 让我们从一个简单的配置开始,像这样,我们就可以看到我们的配置做了什么。做出这个非常简单的 `FDCONFIG.SYS` 文件: ``` LASTDRIVE=Z BUFFERS=20 FILES=40 DEVICE=C:\FDOS\BIN\HIMEMX.EXE SHELL=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT ``` 这个配置文件仅包含几个指令: 1. `LASTDRIVE=Z` 2. `BUFFERS=20` 3. `FILES=40` 4. `DEVICE=C:\FDOS\BIN\HIMEMX.EXE` 5. `SHELL=C:\FDOS\BIN\COMMAND.COM C:\FDOS\BIN /E:1024 /P=C:\FDAUTO.BAT` 第一行指令告诉 FreeDOS 在存储器中保留多少驱动器字母。(DOS 使用字母来表示附属于系统的每个驱动器,`LASTDRIVE=Z` 表示预留从 `A` 到 `Z` 的所有驱动器字母)。 `LASTDRIVE` 会影响系统可以识别的 *逻辑驱动器* 的数量。你可能没有任何的逻辑驱动器;FreeDOS 安装器不会默认设置这些逻辑驱动器。在任何情况下,在任何 FreeDOS 系统上设置 `LASTDRIVE=Z` 都是没有害处的。 `BUFFERS` 行设置文件缓冲区预留存储器。*缓冲区* 有助于加速某些需要存储空间的进程,例如复制文件。如果你为 `BUFFERS` 设置一个较大的值,那么 FreeDOS 将预留更多的存储器。同理反之。大多数的用户将会设置其为 `BUFFERS=20` 或 `BUFFERS=40` ,取决于他们在系统上读写文件的频率。 `FILES` 设置决定 DOS 允许你一次打开多少文件。如果你运行的一个应用程序需要一次打开很多文件,例如打开一个谱系数据库,你可能需要为 `FILES` 设置一个较大的值。对于大多数的用户来说,`FILES=40` 是一个合理的值。 `DEVICE` 是一个特殊的指令,用于加载 *设备驱动器* 。DOS 需要针对某些硬件或配置文件的设备驱动器。这行 `DEVICE=C:\FDOS\BIN\HIMEMX.EXE` 来加载 *HimemX* 设备驱动,这样,DOS 可以利用超出前 640 KB 的扩展存储器。 最后的指令行告诉 FreeDOS 的内核在哪里找到命令行 shell 。默认情况下,内核将从 `COMMAND.COM` 开始查找 shell ,但是你可以使用 `SHELL` 指令来更改它。在这个示例中, `SHELL=C:\FDOS\BIN\COMMAND.COM` 说明 shell 是 `COMMAND.COM` 程序,位于 `C` 驱动器上的 `\FDOS\BIN` 目录之中。 在 `SHELL` 结尾处的其它文件表示选项为 `COMMAND.COM` 的 shell 。FreeDOS 的 `COMMAND.COM` 支持一些启动选项来修改它的行为,包括: * `C:\FDOS\BIN`:`COMMAND.COM` 程序的完整的路径 * `/E:1024`:环境(`E`)大小,以字节为单位。`/E:1024` 告诉 `COMMAND.COM` 来预留 1024 字节,或者说是 1 KB ,来存储它的环境变量。 * `/P=C:\FDAUTO.BAT`:`/P` 选项表示 shell 是一个永久性的(`P`)shell ,因此用户不能通过输入 `EXIT` 来退出 shell(附加文本 `=C:\FDAUTO.BAT` 告诉 `COMMAND.COM` 在启动时执行 `C:\FDAUTO.BAT` 文件,而不再执行默认的 `AUTOEXEC.BAT` 文件) 通过这个简单的配置文件,你应该能够理解 FreeDOS 1.3 RC4 安装的 `FDCONFIG.SYS` 文件中的一些东西。 ### 启动菜单 FreeDOS 支持一种有序的功能:在一个系统上使用多个配置文件,使用一个“启动菜单”来选择你想要的配置。`FDCONFIG.SYS` 文件包含一些定义菜单的行: ``` !MENUCOLOR=7,0 MENUDEFAULT=1,5 MENU 1 - Load FreeDOS with JEMMEX, no EMS (most UMBs), max RAM free MENU 2 - Load FreeDOS with JEMM386 (Expanded Memory) MENU 3 - Load FreeDOS low with some drivers (Safe Mode) MENU 4 - Load FreeDOS without drivers (Emergency Mode) ``` `MENUCOLOR` 指令定义启动菜单的文本颜色和背景颜色。这些值通常在 0 到 7 的范围之内, 并代表这些颜色: * 0 黑色 * 1 蓝色 * 2 绿色 * 3 品蓝 * 4 红色 * 5 品红 * 6 棕色 * 7 白色 因此,`MENUCOLOR=7,0` 的定义意味着显示一个黑色背景(`0`)白色文本(`7`)的菜单。如果你想使用一个蓝色背景白色文本,你可以将其定义为 `MENUCOLOR=7,1` 。 在行头部的叹号(`!`)意味着:不管你选择哪个菜单,这个指令都将会执行。 `MENUDEFAULT=1,5` 行告诉内核等待用户多长时间来选择启动菜单项,或者如果用户没有选择的话,使用那个默认菜单项。`MENUDEFAULT=1,5` 标示着系统将等待 `5` 秒钟;如果用户不在这段时间内尝试选择一个菜单的话,内核将选择启动菜单 “1” 。 ![boot menu](/data/attachment/album/202112/08/124701q7b8e9uzd7hbhe55.png "The boot menu waits for 5 seconds before assuming menu item 1") 在其后的 `MENU` 行至不同启动菜单配置的标签。它们是按顺序排列的,因此,菜单项目 “1” 是第一个,接下来的 “2” 是第二个,以此类推。 ![menu select 4](/data/attachment/album/202112/08/124701lygglgf0zgl0fy1l.png "Use the arrow keys to select a boot menu configuration") 在 `FDCONFIG.SYS` 中的接下来的一行中,你将在一个问号(`?`)前看到一些数字。这标示“针对这几个数字的启动菜单项,使用这行命令”。例如,如果用户选择启动菜单项 “2”、“3” 或 “4” 的话,那么带有 `234?` 的这行命令才将加载 HimemX 设备驱动器。 ``` 234?DEVICE=C:\FDOS\BIN\HIMEMX.EXE ``` 这里有很多方法来使用 `FDCONFIG.SYS` 以配置你的 FreeDOS 系统。我们在这里只介绍基本的东西,最重用的方法是定义你的 FreeDOS 内核设置。更多的信息,探索 FreeDOS 帮助系统(在命令行中输入 `HELP`)来学习如何使用 FreeDOS 的 `FDCONFIG.SYS` 选项: * `SWITCHES`:启动时处理过程行为 * `REM` 和 `;`:注释(在 `FDCONFIG.SYS` 中将被忽略) * `MENUCOLOR`:启动菜单文本颜色和背景颜色 * `MENUDEFAULT`:启动菜单默认值 * `MENU`:启动菜单选项 * `ECHO` 和 `EECHO`:显示信息 * `BREAK`:设置打开或关闭扩展的 `Ctrl+C` 检查 * `BUFFERS` 或 `BUFFERSHIGH`:分配多少磁盘缓冲区 * `COUNTRY`:设置国际化行为 * `DOS`:告诉 FreeDOS 内核如何将其自身加载到存储器之中 * `DOSDATA`:告诉 FreeDOS 加载内核到上位存储器之中 * `FCBS`:设置文件控制块(FCB)的数量 * `KEYBUF`:在存储器中重新指定键盘缓冲区 * `FILES` 或 `FILESHIGH`:一次可以打开多少个文件 * `LASTDRIVE` 或 `LASTDRIVEHIGH`:设置可以使用的最后一个驱动器字母 * `NUMLOCK`:设置打开或关闭键盘数字锁 * `SHELL`、`SHELLHIGH` 或 `COMMAND`:设置命令行 shell * `STACKS` 或 `STACKSHIGH`:添加堆栈以处理硬件中断 * `SWITCHAR`:重新定义命令行选项开关字符 * `SCREEN`:设置在屏幕上的行数 * `VERSION`:设置向程序报告的 DOS 版本 * `IDLEHALT`:激活节能功能,在某些系统上有用 * `DEVICE` 和 `DEVICEHIGH`:加载一个驱动程序到存储器之中 * `INSTALL` 和 `INSTALLHIGH`:加载一个 “存储器驻留”(TSR)程序 * `SET`:设置一个 DOS 环境变量 ### 以纯文本方式配置 FreeDOS 像 Linux 和 BSD 一样,FreeDOS 配置以纯文本的方式进行。不需要特殊指定的编辑工具,因此,深入研究,看看哪些选项最适合你。它很简单,但是功能很强大! --- via: <https://opensource.com/article/21/6/freedos-fdconfigsys> 作者:[Jim Hall](https://opensource.com/users/jim-hall) 选题:[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/) 荣誉推出
null
HTTPSConnectionPool(host='opensource.com', port=443): Read timed out. (read timeout=10)
null
14,064
关于 Ubnutu Linux 终端的必知必会的 19 件超简单的事情
https://itsfoss.com/basic-terminal-tips-ubuntu/
2021-12-09T07:55:20
[ "终端" ]
https://linux.cn/article-14064-1.html
终端常常让新用户感到害怕。然而,一旦你了解了它,你就会逐渐开始喜欢上它。好吧,这事往往发生在大多数 Linux 用户身上。 即使你使用 Ubuntu 作为桌面系统,你可能有时也要进入终端。新用户往往对很多事情毫无头绪,在这种情况下,一些基本的 Linux 命令的知识总是有帮助的,但这篇文章不是关于这个。 这篇文章的重点是解释关于使用终端的一些小的、基本的、经常被忽视的东西。这应该可以帮助 Ubuntu 桌面的新用户了解终端,并以更高的效率使用它。 ![](/data/attachment/album/202112/09/075520x7a4zkaplokrowd8.png) 你看到的“<ruby> 终端 <rt> terminal </rt></ruby>”只是 [各种终端应用程序](https://itsfoss.com/linux-terminal-emulators/) 中的一个。毕竟终端只是一个 GUI 工具,它可以让你进入一个可以运行命令的 Shell 。 不同的终端应用程序(正确地应该被称为“<ruby> 终端仿真器</ruby>”)看起来有些稍微不同的功能和特点(如不同的键盘快捷键、颜色组合、字体等)。 本文特别关注 Ubuntu 的默认终端,它是 “GNOME 终端”的一个实现。 ### 1、用键盘快捷方式打开终端 你可以 [在 Ubuntu 中打开终端](https://itsfoss.com/open-terminal-ubuntu/),在系统菜单中寻找到它。然而,我最喜欢的方式是使用 [Ubuntu 中的键盘快捷键](https://itsfoss.com/ubuntu-shortcuts/):`Ctrl+Alt+T` 。 ### 2、终端、Shell、提示符和命令行 在你看其他内容之前,你应该知道这些不同术语之间的区别,这些术语经常被(不正确地)互换使用。 ![终端、提示符和命令](/data/attachment/album/202112/09/075520qwzi6dkubru56sw6.png) “终端”是图形化的应用程序,默认情况下运行 Shell。 Shell 很难与终端分开进行可视化。终端运行着一个 Shell,在 Ubuntu 中通常默认为 Bash shell。和终端一样,也有各种 Shell。Bash 是其中最受欢迎的,也是大多数 Linux 发行版上的默认 Shell。 你输入的命令是由 Shell 解释的。通常人们认为他们在终端看到的屏幕就是 Shell。这适合理解这个概念。 “提示符”是你在输入命令的空格前看到的东西。对于提示符没有固定的标准。在一些旧的终端中,只是在你可以输入命令的地方有一个闪烁的光标而已。在 Ubuntu 终端中,提示符给了你一些信息,你会在本文后面的章节中看到这些信息的细节。 “命令行”不是 Linux 特有的东西。很多操作系统都有一个命令行界面。许多编程语言也都有命令行界面。它是一个术语,用来指你可以运行和执行命令的界面。 Luke Smith 的 [这个视频](https://www.youtube.com/embed/hMSByvFHOro) 用例子详细解释了它。言归正传,我在这里就不多说了。 ### 3、了解提示符 你现在已经知道了。你在输入命令的空格前看到的东西叫做“提示符”。它是可配置的,在不同的发行版、终端应用程序和 Shell 中提示符看起来是不同的。 Ubuntu 终端对提示符进行了配置,让你看到一些东西。你可以一目了然地得到以下信息: * 用户名 * 主机名(计算机的名称) * 当前工作目录 还有一些你可能想知道的惯例。 提示符中的冒号(`:`)是一个分隔符,常用来区分主机名和当前位置。 波浪号(`~`)表示当前用户的主目录。 对于普通用户,提示符以美元(`$`)符号结束。对于 root 用户来说,它以英镑或哈希(`#`)符号结束。因此有一个笑话说,英镑比美元强。 ![](/data/attachment/album/202112/09/075521trvbni5lnfo4lzvb.png) 你是否注意到,当我切换到 root 用户时,命令提示符看起来不一样,没有任何颜色?这又一次提醒了我,提示符不是一个标准,是要明确配置的。对于普通用户来说,Ubuntu 对提示符的配置与 root 用户不同。 像这样的简单信息间接地帮助了我们。在一个多用户环境中,你可以很容易地弄清楚你现在使用的是哪个用户,以及它是否是 root 用户。其显示的路径位置也是有帮助的。 ![](/data/attachment/album/202112/09/075521uxx7m654smyx1yu5.png) ### 4、目录和文件 在 Linux 中你听到最多的两个术语是目录和文件。 你可能知道什么是文件,但你可能会对“<ruby> 目录 <rt> directory </rt></ruby>”这个术语感到困惑。目录就是“<ruby> 文件夹 <rt> folder </rt></ruby>”。它把文件和文件夹放在里面。 你可以进入目录,但你不能进入文件。当然,你可以读取文件。 ![](/data/attachment/album/202112/09/075521zsxzs8idnvkrvxxr.png) 你可以用“文件夹”这个词来表示目录,应该没有问题。然而,最好使用“目录”,因为你会在各种教程、文件等中看到引用这个词。你甚至会发现像 `rmdir`、`mkdir` 这样的命令,暗示它们是处理目录的。 补充说明:在 Linux 中,所有东西都是文件。甚至目录也是一种特殊的文件,里面有文件和目录的地址。我已经在我的关于 [硬链接的文章](https://linuxhandbook.com/hard-link/) 中解释了这一点。如果你想了解更多关于这个主题的信息,可以参考一下。 ### 5、路径:绝对路径和相对路径 [Linux 中的目录结构](https://linuxhandbook.com/linux-directory-structure/) 类似于一棵树的根。所有的东西都从根部开始,并从那里向外扩散。 如果你要访问一个文件或目录,你需要通过提供它的“路径”来说明如何到达它的位置。这个路径是由目录名和分隔符(`/`)组成的。如果一个路径以 `/`(即根)开头,它就是一个绝对路径,否则就是一个相对路径。 ![路径](/data/attachment/album/202112/09/075521qbhfjjlsjuljlsbs.png) 绝对路径从根开始,可以很容易地从系统的任何地方引用。相对路径则取决于你在目录结构中的当前位置。 ![绝对路径与相对路径](/data/attachment/album/202112/09/075522dld5ibd4hd7ddi7v.png) 如果你在 `/home/abhishek` 这个位置,有一个名为 `scripts` 的目录,里面有一个文件 `my_script.sh`,你想知道这个文件的路径,它的绝对路径将是: ``` /home/abhishek/scripts/my_script.sh ``` 它的相对路径将是: ``` scripts/my_script.sh ``` 如果你改变所在位置,文件的绝对路径保持不变。但是,相对路径会改变,因为它是相对于你当前的路径而言的。 ![相对路径随位置变化但绝对路径保持不变的真实例子](/data/attachment/album/202112/09/075522arweykynkkxy2epx.png) ### 6、 . 和 .. 在使用 Linux 终端时,你可能经常会遇到 `.`和 `..` 符号。 单点(`.`)表示当前目录。 双点(`..`)表示父目录(比当前位置高一个目录)。 你经常在相对路径中使用双点(`..`),或者用于改变目录。单点(`.`)也用于相对路径中,但更重要的是,你可以在指定当前位置的命令中使用它。 ![ . 和 .. 的使用](/data/attachment/album/202112/09/075522rf69ykrt1otoiri7.png) ### 7、理解命令的结构 一个典型的 Linux 命令由一个命令名和选项及参数组成。 ``` 命令名 [选项] 参数 ``` “选项”,顾名思义,是可选的。当使用时,它们可能会根据其属性来改变输出。 例如,`cat` 命令是用来查看文件的。你可以添加选项 `-n`,它也会显示行数。 选项不是标准化的。通常情况下,它们是由单字母和单破折号(`-`)组成的。它们也可能是两个破折号(`--`)和一个单词的形式。 同样的选项在不同的命令中可能有不同的含义。如果你在 `head` 命令中使用 `-n`,表明你想看行数,而不是行号。 ![同样的选项 -n 在 cat 和 head 命令中有不同的用途](/data/attachment/album/202112/09/075522suyzuja4aydp5hzs.png) 在命令文档中,**如果你看到方括号(`[]`)之间有什么东西,它表示括号中的内容是可选的**。 同样地,“参数”也没有标准化。有些命令希望用文件名作为参数,有些则希望用目录名或正则表达式。 ### 8、获得帮助 当你开始使用命令时,你可能会记住一些经常使用的命令的选项,但你根本不可能记住所有命令的所有选项。 为什么呢?因为一条命令可能有十多个或二十多个选项。 那么,当你无法记住所有的选项时,你该怎么办呢?你需要“帮助”。我所说的帮助,并不是指在 [Linux 论坛](https://itsfoss.community/) 上提问。我指的是使用命令的帮助选项。 每个标准的 Linux 命令都有一个快速帮助页面,可以用 `-h` 或 `—help` 来访问。 ``` 命令名 -h ``` 它可以让你快速了解命令的语法、常用选项及其含义,在某些情况下还有命令的例子。 ![cat 命令的帮助页](/data/attachment/album/202112/09/075523e6zih8m6u68f6eti.png) 如果你需要更多的帮助,你可以参考 [手册页](https://itsfoss.com/linux-man-page-guide/),即命令的手册。 ``` man 命令名 ``` 它涉及到所有的细节,阅读和理解起来可能会让人难以承受。另外,你也可以在网上搜索 “Linux 中 xyz 命令的例子”。 ### 9、Linux 是区分大小写的 Linux 是区分大小写的。你在终端中输入的所有东西都是区分大小写的。如果你不考虑这一点,你会经常遇到 “[bash: command not found](https://itsfoss.com/bash-command-not-found/)” 或 “file not found” 的错误。 在主目录中,你的所有文件夹名称以大写字母开头的。如果你要切换到 `Documents` 目录,你必须把第一个字母保持为 `D`,而不是 `d`。 ![Linux 是区分大小写的](/data/attachment/album/202112/09/075523kgmcdr6hzr5rhebr.png) 你可以有两个分别名为 `file.txt` 和 `File.txt` 的文件,因为对于 Linux 来说,`file` 和 `File` 是不一样的。 ### 10、运行 Shell 脚本 你可以通过指定 Shell 来 [运行一个 Shell 脚本](https://itsfoss.com/run-shell-script-linux/): ``` bash script.sh ``` 或者你可以像这样执行 Shell 脚本。 ``` ./script.sh ``` 第二种方法只有在文件有执行权限时才会起作用。更多关于 [Linux 文件权限参考这里](https://linuxhandbook.com/linux-file-permissions/)。 ![运行bash脚本](/data/attachment/album/202112/09/075523jr8gtoawxgnrrome.png) ### 11、使用制表符补完而不是全部输入 Ubuntu 的终端已经预先配置了制表符补完功能。这意味着如果你开始在终端上输入,然后点击 `tab` ,它会尝试自动完成它,或者在有多个可能的匹配时提供选项。 它既适用于命令,也适用于参数和文件名。 ![Tab 完成示例](/data/attachment/album/202112/09/075523amoaddkdskm6tiea.png) 这可以节省大量的时间,因为你不需要把所有的东西都写完整。 ### 12、Ctrl+C 和 Ctrl+V 不是用来在终端复制粘贴的。 `Ctrl+C`、`Ctrl+V` 可能是复制粘贴的“通用”键盘快捷键,但它在 Linux 终端中不行。 Linux 继承了 UNIX 的很多东西,在 UNIX 中,`Ctrl+C` 被用来停止一个正在运行的进程。 由于 `Ctrl+C` 已经被用于停止一个命令或进程,所以它不能再用于复制粘贴。 ### 13、你当然可以在终端复制粘贴 别担心。你仍然可以 [在终端中复制粘贴](https://itsfoss.com/copy-paste-linux-terminal/)。同样,复制-粘贴的键盘快捷键没有固定的规则,因为它取决于你使用的终端程序或你的配置。 在 Ubuntu 终端中,复制的默认键盘快捷键是 `Ctrl+Shift+C`,粘贴则是 `Ctrl+Shift+V`。 你可以使用 `Ctrl+C` 从终端外(如网页浏览器)复制文本和命令,并使用 `Ctrl+Shift+V` 将其粘贴。同样,你可以高亮显示文本,用 `Ctrl+Shift+C` 从终端复制文本,用 `Ctrl+V` 粘贴到编辑器或其他应用程序。 ### 14、避免在终端中使用 Ctrl+S 另一个初学者常犯的错误是使用“通用”的 `Ctrl+S` 键盘快捷键来保存。如果你在终端中使用 `Ctrl+S`,你的终端会被“冻结”。 这来自于传统的计算机,在那里没有向上滚动的滚动条。因此,如果有大量的输出行,`Ctrl+S` 被用来停止屏幕,以便可以阅读屏幕上的文字。 你可以用 `Ctrl+Q` 来解除终端的冻结。但还是要避免在终端中使用 `Ctrl+S`。 ### 15、注意命令例子中的 $ 和 <> 如果你参考一些在线教程或文档,你会看到一些命令例子中的文本在 `<>` 内。这表明你需要用一个合适的值来替换与 `<` 和 `>` 一起的内容。 例如,如果你看到一个这样的命令: ``` grep -i <搜索内容> <文件名> ``` 你应该把 `<搜索内容>` 和 `<文件名>` 换成各自的实际值。(LCTT 译注:不要输入 `<` 和 `>`) 这表明该命令只是一个例子,你必须用实际值来完成它。 这里需要注意的另一件事是,有些教程显示的命令例子是以 `$` 开头的,比如这样: ![命令开头的美元符号](/data/attachment/album/202112/09/075524mbhgjg5cgtebe8bj.png) 这是表明它们是命令(而不是命令输出)的一种方式。但是,许多新的 Linux 用户把前面的 `$` 和实际的命令一起复制,当他们把它粘贴到终端时,显然会出现错误。 所以,当你复制一些命令时,如果开头有 `$`,就不要复制它。你也应该避免复制随机网站的随机命令,特别是当你不了解它的作用时。 既然你正在阅读关于复制命令的文章,当你看到多行的命令在一起时,你应该一次复制一行,然后逐一运行。 ![避免将多个命令复制在一起](/data/attachment/album/202112/09/075524lsrqtheestfr0tke.png) 下一节将告诉你如何一次性运行多个命令。 ### 16、你可以同时运行多个命令 你可以 [一次运行多个命令](https://itsfoss.com/run-multiple-commands-linux/) 而不需要用户干预。作为 Ubuntu 用户,你可能已经在这个命令的形式中看到了它: ``` sudo apt update && sudo apt upgrade ``` 在终端中,有三种不同的方法来组合命令: | `;` | `命令 1 ; 命令 2` | 先运行命令 1,再运行命令 2 | | --- | --- | --- | | `&&` | `命令 1 && 命令 2` | 只有命令 1 成功结束才运行命令 2 | | `||` | `命令 1 || 命令 2` | 只有命令 1 失败时才运行命令 2 | ### 17、停止一个正在运行的 Linux 命令 如果一个 Linux 命令在前台运行,也就是说,它正在显示输出,或者说你不能输入任何其他命令,你可以用 `Ctrl+C` 键停止它。 我以前讨论过它。它来自于 UNIX 的传统计算时代。 所以,下次你看到像 `top` 或 `ping` 这样的命令在持续运行,而你想恢复终端控制,只需使用这两个键:`Ctrl+C`。 ![在 Linux 中用 Ctrl+C 停止一个正在运行的程序](/data/attachment/album/202112/09/075524v9g3fvtfav1l8p5p.png) ### 18、清除终端 当我发现我的屏幕被不同类型的输出弄得太杂乱时,我会在开始其他工作之前清除终端屏幕。这只是一种习惯,但我发现它很有帮助。 要清除终端,请使用以下命令: ``` clear ``` 你也可以使用 [终端快捷键](https://linuxhandbook.com/linux-shortcuts/) `Ctrl+L`。 ### 19、退出终端 在少数情况下,我看到有人关闭终端程序来退出会话。你可以这样做,但退出终端的正确方法是使用退出命令: ``` exit ``` 你也可以使用 Ubuntu 终端的键盘快捷键 `Ctrl+D`。 ### 总结 即使你对终端完全陌生,你也可以在终端中做很多额外的事情。你可以: * [运行有趣的 Linux 命令](https://itsfoss.com/funny-linux-commands/) * [在终端中浏览互联网](https://itsfoss.com/terminal-web-browsers/) * [在终端中玩游戏](https://itsfoss.com/best-command-line-games-linux/) 如果你想了解更多,[看看这些 Linux 命令技巧,可以像专家一样使用终端](https://itsfoss.com/linux-command-tricks/)。 说实话,要谈的东西太多了。很难确定哪些应该被认为是绝对的基础知识,哪些应该被排除在外。例如,我想避免包括关于路径的信息,因为它需要详细的解释,但在一个地方讲得太详细可能会让人不知所措。 我已经过了在终端中的小东西曾经让我困惑的阶段。如果你是 Linux 终端的新手,或者你还记得你最初使用 Linux 时的挣扎,请随时提出建议对列表进行补充。我可能会根据你的意见更新这个列表。 如果你学到了新的东西,请在评论中提及。我想看看这篇文章是否值得一读 ? --- via: <https://itsfoss.com/basic-terminal-tips-ubuntu/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Terminal often intimidates new users. However, you gradually start liking it once you get to know it. Well, that happens with most Linux users. Even if you are using Ubuntu as a desktop system, you may sometimes have to enter the terminal. New users are often clueless about many things. Some knowledge of basic Linux commands always helps in such cases but this article is not about that. This article focuses on explaining small, basic, and often ignored things about using the terminal. This should help new Ubuntu desktop users know the terminal and use it more efficiently. ![ubuntu terminal basic tips](https://itsfoss.com/content/images/wordpress/2021/12/ubuntu-terminal-basic-tips.png) The terminal you see is just one of the [various terminal applications](https://itsfoss.com/linux-terminal-emulators/) available. After all, the terminal is just a GUI tool that gives you access to a shell where you can run the commands. Different terminal applications (properly called terminal emulators) look different and have slightly different functions and features (like different keyboard shortcuts, color combinations, fonts, etc). This article specifically focuses on the default Ubuntu terminal, which implements the GNOME terminal. ## 1. Open the terminal with a keyboard shortcut You can [open the terminal in Ubuntu](https://itsfoss.com/open-terminal-ubuntu/) by looking for it in the system menu. However, my favorite way is to use the Ctrl+Alt+T [keyboard shortcut in Ubuntu](https://itsfoss.com/ubuntu-shortcuts/). `Ctrl+Alt+T` ## 2. Terminal vs shell vs prompt vs command line Before you see anything else, you should know the difference between different terminologies that are often (incorrectly) used interchangeably. ![linux terminal introduction](https://itsfoss.com/content/images/wordpress/2021/12/linux-terminal-introduction.png) The terminal is a graphical application that runs a shell by default. Shell is difficult to visualize separately from the terminal. The terminal runs a shell, usually Bash shell by default in Ubuntu. Like terminals, there are various shells as well. Bash is the most popular of them all and the default shell on most Linux distributions. The commands you type are interpreted by the shell. Often people think that screen they see in the terminal is the shell. That’s fine for understanding. Prompt is what you see before the space where you type the commands. There is no set standard for the prompt. In some old terminals, you would just have a blinking cursor to the place where you can type the commands. In the Ubuntu terminal, prompt gives you some information which you’ll see in detail in the later sections of this article. The Command line is not something specific to Linux. Every operating system has a command line interface. Many programming languages have command line interfaces. It’s a term for the interface where you can run and execute commands. This video by Luke Smith explains it in detail with examples. I won’t go into details anymore to keep things on track. ## 3. Understanding the prompt You know it by now. What you see before the space where you type the command is called the prompt. It is configurable and looks different in different distributions, terminal applications and shells. Ubuntu terminal has configured the prompt to show you a few things. You can get the following information at a glance: - User name - Hostname (name of the computer) - Current working directory A few more things you may wonder about. The colon (:) in the prompt is a separator to distinguish between the hostname and the current location. Tilde (~) means the home directory of the present user. For regular users, the prompt ends with dollar ($) symbol. For the root user, it ends with pound or hash (#) symbol. And hence the joke that pound is stronger than dollar. ![understanding prompt ubuntu terminal](https://itsfoss.com/content/images/wordpress/2021/12/understanding-prompt-ubuntu-terminal-800x346.png) Did you notice that when I switched to the root user, the command prompt looked different without any colors? This is another reminder that prompt is not a standard and is configured explicitly. For regular users, Ubuntu has a different configuration of the prompt than the root. Simple information like this helps indirectly. In a multi-user environment, you can easily figure out which user you are using and if it is a root user. The displayed location is also helpful. ![learning prompt ubuntu terminal](https://itsfoss.com/content/images/wordpress/2021/12/learning-prompt-ubuntu-terminal-800x346.png) ## 4. Directory and files The two terms you hear the most in Linux are directory and files. You probably know what a file is but you may get confused with the term ‘directory’. The directory is nothing but a folder. It keeps files and folders inside it. You can go inside the directories but you cannot enter files. You can read files of course. ![directory files linux](https://itsfoss.com/content/images/wordpress/2021/12/directory-files-linux-800x346.png) You can use the term ‘folder’ for the directory, which should be fine. However, it is better to use ‘directory’ because this is what you’ll see referenced in various tutorials, documents etc. You’ll even find commands like rmdir, mkdir hinting that they deal with directories. Additional note: Everything is a file in Linux. Even directory is a special kind of file that has the memory address of files and directories inside it. I have explained it in my [article on hard links](https://linuxhandbook.com/hard-link/). You may refer to that if you want to know more on this topic. ## 5. Path: Absolute and relative The [directory structure in Linux resembles](https://linuxhandbook.com/linux-directory-structure/) the root of a tree. Everything starts at root and spreads out from there. If you have to access a file or directory, you need to tell how to reach its location by providing its ‘path’. This path is composed of directory names and separators (/). If a path starts with / (i.e., root), it is an absolute path otherwise it is a relative path. ![path linux](https://itsfoss.com/content/images/wordpress/2021/12/path-linux.webp) The absolute path starts from the root and can be easily referenced from anywhere in the system. The relative path depends upon your current location in the directory structure. ![absolute vs relative path linux](https://itsfoss.com/content/images/wordpress/2021/12/absolute-vs-relative-path-linux.webp) If you are in the location /home/abhishek which has a directory named scripts containing a file my_script.sh and you want the path for this file, its absolute path will be: `/home/abhishek/scripts/my_script.sh` Its relative path will be: `scripts/my_script.sh` If you change the location, the file's absolute path remains the same. However, the relative path changes because it is relative to your current path. ![absolute relative path real examples](https://itsfoss.com/content/images/wordpress/2021/12/absolute-relative-path-real-examples-800x346.png) ## 6. . and .. You may often come across . and .. notations while using the Linux terminal. Single dot (.) means the current directory. Double dots (..) mean the parent directory (one directory above the current location). You’ll often use the double dot (..) in the relative path or for changing the directory. Single dot (.) is also used in relative path; more importantly, you can use it in the commands to specify the current locations. ![use of single and double dot in linux](https://itsfoss.com/content/images/wordpress/2021/12/use-of-single-and-double-dot-in-Linux.png) ## 7. Understand the command structure A typical Linux command consists of a command name followed by options and arguments. `command [options] argument` Option, as the name suggests, are optional. When used, they might change the output based on their properties. For example, the cat command is used for viewing files. You can add option -n, which will also display line numbers. Options are not standardized. Usually, they are used as a single letter with single dash (-). They may also have two dashes (--) and a word. Same options may have different meanings in a different command. If you use -n with head command, you specify the number of lines you want to see, not the lines with numbers. ![command structure example](https://itsfoss.com/content/images/wordpress/2021/12/command-structure-example.png) In command documentation, **if you see something between brackets ([]), it indicates that the contents of the bracket are optional.** Similarly, arguments are also not standardized. Some commands expect filenames as arguments and some may expect a directory name or regular expression. ## 8. Getting help As you start using commands, you may remember some of the options of frequently used commands but it is simply impossible for you to remember all the options of any command. Why? Because a single command may have more than ten or twenty options. So, what do you do when you cannot recall all the options? You take help. And with help, I do not mean asking a question in It’s FOSS [Linux forum](https://itsfoss.community/). I ask to use the help option of the command. Every standard Linux command has a quick help page that can be accessed with -h or –help or both. `command_name -h` It gives you a quick glimpse of the command syntax, common options with their meaning, and command examples in some cases. ![cat command help page](https://itsfoss.com/content/images/wordpress/2021/12/cat-command-help-page.png) If you need more help, you can refer to the [manpage](https://itsfoss.com/linux-man-page-guide/) i.e. manual of a command: `man command_name` It goes into all the details and could be overwhelming to read and understand. Alternatively, you can always search on the internet for ‘examples of xyz commands in Linux’. ## 9. Linux is case-sensitive Linux is case-sensitive. Everything you type in the terminal is case-sensitive. If you do not take that into account, you’ll often run into [bash: command not found](https://itsfoss.com/bash-command-not-found/) or file not found errors. In the home directory, you have all the folders' names starting with the upper case. If you have to switch to the Documents directory, keep the first letter as D and not d. Otherwise, the terminal will complain. ![linux is case sensitive](https://itsfoss.com/content/images/wordpress/2021/12/linux-is-case-sensitive.png) You can have two separate files named file.txt and File.txt because file and File are not the same for Linux. ## 10. Running shell scripts You can [run a shell script](https://itsfoss.com/run-shell-script-linux/) by specifying the shell: `bash script.sh` Or you can execute the shell script like this: `./script.sh` The second one will only work when the file has the execute permission. More on [Linux file permission here](https://linuxhandbook.com/linux-file-permissions/). ![run bash script](https://itsfoss.com/content/images/wordpress/2021/12/run-bash-script.png) ## 11. Use tab completion instead of typing it all The Ubuntu terminal is pre-configured with tab completion. This means that if you start writing something in the terminal and then hit tab, it tries to automatically complete it or provide options if there is more than one possible match. It works for both commands as well as arguments and filenames. ![tab completion ubuntu](https://itsfoss.com/content/images/wordpress/2021/12/tab-completion-ubuntu.png) This saves a great time because you don’t have to write everything completely. ## 12. Ctrl+C and Ctrl+V is not for copy pasting in terminal Ctrl+C, Ctrl+V might be the ‘universal’ keyboard shortcuts for copy paste but it doesn’t work in the Linux terminal. Linux inherits a lot of stuff from UNIX and in UNIX, Ctrl+C was used for stopping a running process. Since the Ctrl+C was already taken for stopping a command or process, it cannot be used for copy-paste any more. ## 13. You can surely copy paste in the terminal Don’t worry. You can still [copy paste in the terminal](https://itsfoss.com/copy-paste-linux-terminal/). Again, there is no fixed rule for the copy-paste keyboard shortcuts because it depends on the terminal application you are using or the configuration you have in place. In the Ubuntu terminal, the default keyboard shortcut for copying is Ctrl+Shift+C; for pasting, it is Ctrl+Shift+V. You can use Ctrl+C to copy text and commands from outside the terminal (like a web browser) and paste it using Ctrl+Shift+V. Similarly, you can highlight the text and use Ctrl+Shift+C to copy the text from the terminal and paste it to an editor or other applications using Ctrl+V. ## 14. Avoid using Ctrl+S in the terminal Another common mistake beginners do is to use the ‘universal’ Ctrl+S keyboard shortcut for save. If you use Ctrl+S in the terminal, your terminal ‘freezes’. This comes from legacy computing where there was no scope for scrolling back up. Hence, if there were many output lines, Ctrl+S was used to stop the screen so that text on the screen could be read. You can unfreeze your terminal with Ctrl+Q. But again, avoid using Ctrl+S in the terminal. ## 15. Pay attention to $ and <> in command examples If you are referring to some online tutorial or documentation, you’ll see some command examples with text inside <>. This indicates that you need to replace the content along with < and > with a suitable value. For example, if you see a command like this: `grep -i <search_term> <file_name>` You should replace the <search_term> and <file_name> with their respective actual values. It is an indication that the command is just an example and you have to complete it with actual values. Another thing to note here is that some tutorials show command examples that start with $ like this: ![dollar symbol at the beginning of command](https://itsfoss.com/content/images/wordpress/2021/12/dollar-symbol-at-the-beginning-of-command.png) This is a way for them to indicate that it is command (not command output). But many new Linux users copy the preceding $ along with the actual command and when they paste it in the terminal, it throws an error, obviously. So, when copying some commands, don’t copy the $ if it is at the beginning. You should also avoid copying random commands for random websites specially when you do not understand what it does. Since you are reading about copying commands, when you see commands in multiple lines together, you should copy one line at a time and run them one by one: ![avoid copying multiple commands](https://itsfoss.com/content/images/wordpress/2021/12/avoid-copying-multiple-commands.png) The following section tells you how to run multiple commands in one go. ## 16. You can run multiple commands at once You can [run multiple commands at once](https://itsfoss.com/run-multiple-commands-linux/) without user intervention. You might have seen it already as an Ubuntu user in the form of this command: `sudo apt update && sudo apt upgrade` There are three different ways to combine commands in the terminal: ; | Command 1 ; Command 2 | Run command 1 first and then command 2 | && | Command 1 && Command 2 | Run command 2 only if command 1 ends sucessfully | || | Command 1 || Command 2 | Run command 2 only if command 1 fails | ## 17. Stop a running Linux command If a Linux command is running in the foreground, i.e., it is showing output or you cannot enter any other command, you can stop it using the Ctrl+C keys. I discussed it previously. It comes from the legacy computing days of UNIX. So, the next time you see a command like top or ping running continuously and you want the terminal control back, just use these two keys: `Ctrl+C` ![stop running program linux](https://itsfoss.com/content/images/wordpress/2021/12/stop-running-program-linux-800x385.png) ## 18. Clear the terminal When I find that my screen is too cluttered with different kinds of output, I clear the terminal screen before starting some other work. It is just a habit but I find it helpful. To clear the terminal, use the command: `clear` You may also use Ctrl+L [terminal shortcut](https://linuxhandbook.com/linux-shortcuts/). ## 19. Exiting the terminal In a few cases, I have seen people closing the terminal application to exit the session. You could do that but the proper way to exit a terminal is to use the exit command: `exit` You may also use the keyboard shortcut Ctrl+D for Ubuntu terminal. ## Conclusion There are so many additional stuff you can do in the terminal even if you are new to the entire terminal thing. You can: And if you are looking for more, [take a look at](https://itsfoss.com/linux-command-tricks/)[ these Linux command tips and use the terminal like a pro](https://itsfoss.com/linux-command-tricks/). [21 Super Handy Linux Command Tips and Tricks That Will Save you a lot of Time and Increase Your ProductivityBrief: Here are some tiny but useful Linux commands, terminal tricks and shortcuts that will save you a lot of time while working with Linux command line. Have you ever encountered a moment when you see your colleague using some simple Linux commands for tasks that took you several keystrokes?](https://itsfoss.com/linux-command-tricks/)![](https://itsfoss.com/content/images/wordpress/2021/07/linux-command-tips.png) ![](https://itsfoss.com/content/images/wordpress/2021/07/linux-command-tips.png) Getting familiar with the basic commands is also highly recommended. [31 Linux Commands Every Ubuntu User Should KnowWhat are the essential Ubuntu commands? I have been asked this question several times by regular readers, and I have tried to avoid answering it. Why? Don’t I know Ubuntu commands? Nope. That’s not the reason. It is because it is difficult to categorize them. What’s essential](https://itsfoss.com/essential-ubuntu-commands/)![](https://itsfoss.com/content/images/wordpress/2022/11/must-know-linux-commands-for-ubuntu-user.png) ![](https://itsfoss.com/content/images/wordpress/2022/11/must-know-linux-commands-for-ubuntu-user.png) Honestly speaking, there is way too much to talk about. It is difficult to determine what should be considered absolute basics and what should be left out. For example, I wanted to avoid including the information about paths because it needs detailed explanation but going too much into detail on a single could be overwhelming. I have passed the stage where small things used to baffle me in the terminal. If you are new to the Linux terminal or remember the struggle from your initial Linux days, feel free to suggest any additions to the list. I might update the list with your input. And if you learned something new, please do mention it in the comments. I would like to see if this article was worth the effort :)
14,065
在 Linux 上安装和使用 Homebrew 包管理器
https://itsfoss.com/homebrew-linux/
2021-12-09T09:06:20
[ "Homebrew", "brew" ]
https://linux.cn/article-14065-1.html
![](/data/attachment/album/202112/09/090614sptwo73z73f7fw7u.jpg) Homebrew(家酿),也被称为 Brew,是一个主要为 macOS 创建的命令行包管理器。 [Homebrew](https://brew.sh/) 在 macOS 用户中相当流行,因为更多的开发者创造了可以用 Homebrew 轻松安装的命令行工具。 这种流行导致了 Linuxbrew 的诞生,它是 Homebrew 的一个 Linux 移植版。由于它主要是 Git 和 Ruby 组成的,而 Linux 和 macOS 都是类 Unix 的系统,所以 Brew 在两种操作系统上都能很好地工作。 Linuxbrew 项目最终与 Homebrew 项目合并,现在只有一个 Brew 项目,叫做 Homebrew。 为什么我叫它 Brew,而不是 Homebrew?因为命令以 `brew` 开头。你会在后面的章节中看到它的详细内容。 ### 当你已经有了 apt、dnf、snap 时,为什么还要在 Linux 上使用 Homebrew 包管理器? 我知道这种感觉。你已经有一个由你的发行版提供的好的 [包管理器](https://itsfoss.com/package-manager/)。除此之外,你还有 Snap、Flatpak 和其他通用软件包系统。 在你的 Linux 系统上你真的需要 Homebrew 包管理器吗?答案取决于你的需求。 你看,除了发行版的包管理器和通用包管理器,你会遇到需要其他包管理器的情况,比如 [Pip](https://itsfoss.com/install-pip-ubuntu/) (用于 Python 应用)和 [Cargo](https://itsfoss.com/install-rust-cargo-ubuntu-linux/) (用于 Rust 软件包)。 想象一下,你遇到了一个很好的命令行工具,想试试。它的软件库提到它可以使用 `brew` 或源代码来安装。在这种情况下,在你的系统上有 `brew` 可能会有帮助。毕竟,都 2021 了,[从源代码安装](https://itsfoss.com/install-software-from-source-code/) 并不时髦(也不舒服)。 换句话说,如果你遇到一些有趣的命令行工具只提供 `brew` 安装选项,你会有一个额外的选择。 ### 在 Ubuntu 和其他 Linux 发行版上安装 Homebrew 安装是相当容易的。你只需要确保你已经有了所有的依赖项。 #### 步骤 1:安装依赖项 你需要有相对较新版本的 gcc 和 glibc。你可以 [在 Ubuntu 上安装 build-essential 包](https://itsfoss.com/build-essential-ubuntu/) 来获得它们。除此之外,你还需要 [安装 Git](https://itsfoss.com/install-git-ubuntu/)、Curl 和 procps(用于监控系统进程)。 在基于 Ubuntu 和 Debian 的系统中,你可以像这样一起安装所有这些东西: ``` sudo apt-get install build-essential procps curl file git ``` ![Iinstall dependencies for Homebrew in Ubuntu/Debian](/data/attachment/album/202112/09/090620wou7fktsevo2fntd.png) 对于其他发行版,请使用你的包管理器并安装这些依赖项。 #### 步骤 2:安装 Homebrew 你可以看到为什么你需要 [安装 Curl](https://itsfoss.com/install-curl-ubuntu/)。它允许你 [在终端下载安装脚本文件](https://itsfoss.com/download-files-from-linux-terminal/)。 只要输入这个命令: ``` /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` 当要求输入回车键时,请按下回车。 ![Installing Homebrew on Ubuntu](/data/attachment/album/202112/09/090620wl63mhoxxhywiyqr.png) 在脚本最后,它建议运行几个命令,将其添加到 `PATH` 变量中。Homebrew 实际上是安装在你的主目录中,然后软链接到 `/usr/local` 目录中。 ![Run the suggested command under Next steps to add Homebrew to PATh variable](/data/attachment/album/202112/09/090621p12c1vjvsv2vzovz.png) 你可以 [在终端方便地复制和粘贴](https://itsfoss.com/copy-paste-linux-terminal/)。只要选择它所建议的命令,按 `Ctrl+Shift+C` 复制,按 `Ctrl+Shift+V` 粘贴。 或者,你也可以直接复制粘贴这个命令: ``` echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> $HOME/.bash_profile ``` 然后是这个: ``` eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" ``` ![Adding brew commands to the PATH](/data/attachment/album/202112/09/090621as5lrr2m7zlrodpx.png) #### 步骤 3:验证 brew 的安装 就快完成了。只需通过使用 `brew doctor` 命令来验证 `brew` 命令是否可以运行: ``` brew doctor ``` `brew doctor` 命令会告诉你是否有任何问题。 你可以通过安装示例 hello 项目再次验证: ``` brew install hello ``` 如果你没有看到任何错误,你可以在 Linux 上享用家酿了。 ### 使用 brew 命令来安装、删除和管理软件包 让我快速告诉你几个可以用来安装、删除和管理软件包的 `brew` 命令。 由于 Homebrew 安装在你的主目录中,你不需要 `sudo` 来运行它(就像 Pip 和 Cargo)。 要用 `brew` 安装一个软件包,请使用安装选项: ``` brew install package_name ``` 这里没有自动完成软件包名称的功能。你需要知道确切的软件包名称。 要删除一个 `brew` 软件包,你可以使用 `remove` 或 `uninstall` 选项。两者的作用是一样的。 ``` brew remove package_name ``` 你也可以用这个命令列出已安装的 `brew` 软件包: ``` brew list ``` 你也可以用 `autoremove` 选项删除不需要的依赖: ``` brew autoremove ``` 在下一张截图中,我只用 `brew` 安装了两个软件包,但它也显示了这些软件包的依赖关系。即使在移除软件包后,依赖关系仍然存在。`autoremove` 终于把它们删除了。 ![Listing and removing brew apckages](/data/attachment/album/202112/09/090621cwwe2evtsnj68tv8.png) 还有很多 `brew` 命令选项,但这不在本教程的范围内。你可以随时 [翻阅它的文档](https://docs.brew.sh/Manpage) 并进一步探索。 ### 从 Linux 中删除 Homebrew 如果不加入从你的 Linux 系统中删除 Homebrew 的步骤,本教程就不完整。 根据 [GitHub 仓库中提到的步骤](https://github.com/homebrew/install#uninstall-homebrew),你必须下载并使用这个命令运行卸载脚本: ``` /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" ``` 你会被要求输入 `Y` 键来确认删除。 ![Removing Homebrew from Linux](/data/attachment/album/202112/09/090621ry044mh0ukyht3gj.png) 当 Homebrew 的卸载完成后,它会列出它所遗留的文件和目录: ![Remaining files after Homebrew removal](/data/attachment/album/202112/09/090622mh1h1dhavo7zvshd.png) 让你自己去删除这些文件和目录。 ### 总结 正如我前面解释的,Homebrew 为你已经有的东西提供了一个扩展。如果你偶然发现一个只有 `brew` 安装方式的应用,在你的 Linux 系统上安装 Homebrew 会很方便。 你对这个话题有什么要补充的,或者分享你的问题或意见?请在评论区留言。 --- via: <https://itsfoss.com/homebrew-linux/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) Homebrew, also known as Brew, is a command line package manager primarily created for macOS. [Homebrew](https://brew.sh/?ref=itsfoss.com) grew quite popular among macOS users as more developers created command line tools that could be easily installed with Homebrew. This popularity resulted in the creation of Linuxbrew, a Linux port for Homebrew. Since it is primarily Git and Ruby, and Linux and macOS are both Unix-like systems, Brew works good on both kind of operating systems. Linuxbrew project eventually merged with Homebrew project and now you just have one Brew project called Homebrew. Why am I calling it brew, instead of Homebrew? Because the command starts with brew. You’ll see it in detail in a later section. ## Why use Homebrew package manager on Linux when you have got apt, dnf, snap etc? I know the feeling. You already have a good [package manager](https://itsfoss.com/package-manager/) provided by your distribution. In addition to that, you have Snap, Flatpak and other universal package system. Do you really need Homebrew package manager on your Linux system? The answer depends on your requirement, really. See, apart from the distribution’s package manager and universal packages, you’ll come across situations where you need other package managers like [Pip](https://itsfoss.com/install-pip-ubuntu/) (for Python applications) and [Cargo](https://itsfoss.com/install-rust-cargo-ubuntu-linux/) (for Rust packages). Imagine you came across a good command line utility and want to try it. It’s repository mentions that it can be installed using brew or source code only. In such a case, having brew on your system could be helpful. After all, [installing from source code](https://itsfoss.com/install-software-from-source-code/) in the 2020s is not fashionable (and comfortable). In other words, you’ll have an additional option in case you come across some interesting CLI tool that provides only brew installation option. ## Install Homebrew on Ubuntu and other Linux distributions The installation is quite easy. You just have to make sure that you have got all the dependencies. ### Step 1: Install dependencies You need to have relatively newer version of gcc and glibc. You can [install build-essential package on Ubuntu](https://itsfoss.com/build-essential-ubuntu/) to get them. Apart from that, you also need to [install Git](https://itsfoss.com/install-git-ubuntu/), Curl and procps (used for monitoring system process). You can install all of them together like this in Ubuntu and Debian based systems: `sudo apt-get install build-essential procps curl file git` ![install dependencies for homebrew linux](https://itsfoss.com/content/images/wordpress/2021/11/install-dependencies-for-homebrew-linux-800x493.png) For other distributions, please use your package manager and install these dependencies. ### Step 2: Install Homebrew You can see why you needed to [install Curl](https://itsfoss.com/install-curl-ubuntu/). It allows you to [download the installation script file in the terminal](https://itsfoss.com/download-files-from-linux-terminal/). Just enter this command: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"` When asked for RETURN key, press enter: ![installing homebrew ubuntu](https://itsfoss.com/content/images/wordpress/2021/11/installing-homebrew-ubuntu-800x453.png) At the end of the script competition, it recommends to run a few commands to add it to the PATH variable. Homebrew is actually installed in your home directory and then soft linked to the /usr/local directory. ![adding homebrew to path linux](https://itsfoss.com/content/images/wordpress/2021/11/adding-homebrew-to-path-Linux-800x442.png) You can [copy and paste in terminal](https://itsfoss.com/copy-paste-linux-terminal/) easily. Just select the command it suggests and press Ctrl+Shift+C to copy and Ctrl+Shift+V to paste. Alternatively, you can just copy paste this command: `echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> $HOME/.bash_profile` And then this: `eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"` ![post installation steps for brew](https://itsfoss.com/content/images/wordpress/2021/11/post-installation-steps-for-brew.png) ### Step 3: Verify brew installation You are almost done. Just verify that brew command is ready to run by using the brew doctor command: `brew doctor` The brew doctor command will tell you if there is any issue. You may double verify by installing the sample hello project: `brew install hello` If you see no errors, you can enjoy the Homebrew package manager on Linux. ## Using brew command for installing, removing and managing packages Let me quickly tell you a few brew commands you can use for installing, removing and managing packages. Since Homebrew is installed in your home directory, you do not need sudo to run it (just like Pip and Cargo). To install a package with brew, use the install option: `brew install package_name` There is no autocompletion for the package name here. You need to know the exact package name. To remove a brew package, you can use either **remove** or **uninstall** option. Both works the same. `brew remove package_name` You can also list the installed brew packages with this command: `brew list` You can also remove the unneeded dependencies with the autoremove option: `brew autoremove` In the next screenshot, I had only two packages installed with brew but it also shows the dependencies installed for those packages. Even after removing the package, dependencies remained. The autoremove finally removed them. ![brew remove packages](https://itsfoss.com/content/images/wordpress/2021/11/brew-remove-packages-800x572.png) There are a lot more brew command options but that is out of scope for this tutorial. You can always [go through their documentation](https://docs.brew.sh/Manpage?ref=itsfoss.com) and explore it further. ## Removing Homebrew from Linux This tutorial won’t complete without adding the steps for removing Homebrew from your Linux system. As per the [steps mentioned on its GitHub repository](https://github.com/homebrew/install?ref=itsfoss.com#uninstall-homebrew), you have to download and run the uninstall script using this command: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"` You’ll be asked to confirm the removal by entering the Y key. ![removing homebrew from linux](https://itsfoss.com/content/images/wordpress/2021/11/removing-homebrew-from-Linux-800x539.png) When the uninstallation of Homebrew completes, it lists the files and directories it has leftover: ![remaining files after homebrew removal](https://itsfoss.com/content/images/wordpress/2021/11/remaining-files-after-homebrew-removal-800x464.png) I let you remove the files and directories on your own. ## Conclusion As I explained earlier, Homebrew provides an extension to what you have already got. If you stumble upon an application that has only brew as installation method, having Homebrew installed on your Linux system will come handy. Anything you want to add to this topic or share your question or opinion? Please use the comment section.
14,068
Zorin OS 16 Lite 版终于来了
https://news.itsfoss.com/zorin-os-16-lite-release/
2021-12-10T10:07:03
[ "Zorin" ]
https://linux.cn/article-14068-1.html
> > Zorin OS 16 Lite 带来了 Zorin OS 16 的所有优点和 Xfce 桌面环境。让我们来了解一下。 > > > ![](/data/attachment/album/202112/10/100703m0r10v1e2515zzra.jpg) [Zorin OS 16](https://news.itsfoss.com/zorin-os-16-release/) 是一个令人印象深刻的版本。但是,如果你正在寻找一个轻量级的发行版或适合旧电脑的东西,这不是一个好的选择。 Zorin OS 为每个版本都提供了一个由 Xfce 桌面环境驱动的 Lite 版本,以供资源有限的计算机使用。然而,直到刚刚之前,Zorin OS 16 还没有这个 Lite 版。 是的,终于,Zorin OS 16 Lite 现在可以和 Pro 版一起下载了。 请注意,如果你已经购买了 Zorin OS 16 Pro,那么 Lite 版也包括在内。 (LCTT 译注:Zorin OS 的 Pro 版是收费的,其 Core 版和 Lite 版是免费的。) ### Zorin OS 16 Lite: 有什么新内容? ![](/data/attachment/album/202112/10/100704i7xfq7u8fufl0x5l.jpg) 在这个版本中,Zorin OS 16 Lite 旨在通过保持最小的资源使用量,带来所有 [Zorin OS 16 中引入的改进](https://news.itsfoss.com/zorin-os-16-features/)。 我为了制作的视频点评而简要地测试了该发行版,对它留下了相当深刻的印象。 有趣的是,Zorin OS 16 Lite 设法提供了类似于 Xfce 的用户体验和精美的桌面环境。通常情况下,我不喜欢 Xfce 桌面环境(只是一种审美选择),但 Zorin OS 16 Lite 不同。 我做了一个 Zorin OS 16 Lite 专业版的视频,你可以看到它的运行情况。 #### 视觉大修 ![](/data/attachment/album/202112/10/100705ktx53zfffuiemm6e.png) 带有 Xfce 4.16 的 Zorin OS 16 Lite 提供了令人耳目一新的用户体验,其精美的主题与 Zorin OS 16(GNOME 版)非常相近。 你可以调整主题,切换暗色模式,并从外观菜单中选择一种重点颜色。外观选项也得到了刷新,可以让你在 Zorin OS 16 Lite 上轻松定制体验。 不幸的是,你在这里找不到像 Zorin OS 16 一样的果冻模式。因此,如果你需要眼花缭乱的动画,Lite 版可能不是你的合适选择。 除了新的视觉变化和功能之外,你还会发现新的可以填补你的桌面的背景。有些壁纸可能只限于 Pro 版。 ![](/data/attachment/album/202112/10/100706y1yeqeigdyb22c2g.png) #### Pro 版的桌面布局 虽然在 Core 版和 Lite 版中有一些桌面布局的选择,但 Pro 版又为你提供了两个额外的桌面布局。 ![](/data/attachment/album/202112/10/100707lkvuqpauzjgsjfov.jpg) 其中一个布局类似于经典的 Windows 设计,另一个布局看起来接近于 ChromeOS。 ![](/data/attachment/album/202112/10/100708go8yfgdj0yqr0lhr.jpg) 你还可以在类似 macOS、GNOME 2 和类似 Windows 列表的布局之间进行选择。 请注意,作为 [Windows 用户的最佳发行版之一](https://itsfoss.com/windows-like-linux-distributions/),其默认的布局类似 Windows,这应该是一个很好的体验。 #### 带有窗口预览的任务栏 ![](/data/attachment/album/202112/10/100709ir8y0ypxyttyiryu.png) 桌面功能有一个重要的改进,也就是说,现在当你从任务栏悬停在一个活动窗口上时,你可以很容易地查看该窗口的预览。 在用预先发布的 ISO 进行测试时,这个体验并不流畅。但是,考虑到他们已经消除了一些错误,这是 Zorin OS 16 Lite 中的一个很好的功能。 #### 默认启用的 Flathub 应用中心(软件中心)也提供了 Flathub 集成,开箱即用。你应该可以从软件中心很快地找到 Flatpak 应用程序,如果你不喜欢 Flatpak 软件包,可以改变软件包源。 #### 其他改进 ![](/data/attachment/album/202112/10/100710awt66zd55zx5bmt4.png) 除了关键的变化外,你还会发现一些改进,如禁用遥测的 Firefox 浏览器、新的声音记录器应用、高分辨率显示器的小数点级缩放以及 Rythmbox 应用。 Thunar 文件管理器有一些常规的微小改进,并与其他设计融为一体。你应该能够使用 parole 视频播放器来播放视频了。 [Linux 内核 5.11](https://news.itsfoss.com/linux-kernel-5-11-release/) 也改进了一些技术兼容性。 总的来说,Zorin OS 团队在将 Zorin OS 16 的漂亮设计和易用性延续到其 Lite 版方面做得很好。大部分时间,你甚至可能没有意识到你在使用 Xfce 桌面环境。 ### 下载 Zorin OS 16 Lite 你可以前往其下载页面获取 Zorin OS 16 Lite 的 ISO。如果你已经购买了 Zorin OS 16 Pro 版,你可以使用电子邮件中的链接来下载 Lite 版。 * [Zorin OS 16 Lite](https://zorin.com/os/download/) 你对 Zorin OS 16 Lite 有什么看法?欢迎在评论中告诉我们你的想法。 --- via: <https://news.itsfoss.com/zorin-os-16-lite-release/> 作者:[Ankush Das](https://news.itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![](/assets/images/pikapods-banner-v3.webp) ![](/assets/images/pikapods-banner-v3.webp) [Zorin OS 16](https://news.itsfoss.com/zorin-os-16-release/) was an impressive release. But, if you were looking for a lightweight distro or something for older computers, this wasn’t the option. Zorin OS provides a lite edition for every release powered by Xfce desktop environment for computers with limited resources. However, it wasn’t available for Zorin OS 16 until now. Yes, finally, Zorin OS 16 Lite is now available to download along with the Pro edition! Note that if you have already purchased Zorin OS 16 Pro, the Pro Lite edition is included. ## Zorin OS 16 Lite: What’s New? ![](https://news.itsfoss.com/content/images/wordpress/2021/12/zorin-os-desktop-16-lite-1024x576.jpg) With this release, Zorin OS 16 Lite aims to bring all the [improvements introduced in Zorin OS 16](https://news.itsfoss.com/zorin-os-16-features/) by keeping the resource usage minimal. I briefly tested the distribution for our video review and was pretty impressed. Interestingly, Zorin OS 16 Lite has managed to offer a similar level of user experience and polish with Xfce as its desktop environment. Usually, I do not like the Xfce desktop environment (just an aesthetic choice), but Zorin OS 16 Lite is different. I have made a video of Pro edition of Zorin OS 16 Lite and you can see it in action: ### Visual Overhaul ![zorin os](https://news.itsfoss.com/content/images/wordpress/2021/12/desktop-look.png) Zorin OS 16 Lite with Xfce 4.16 offers a refreshing user experience with a polished theme that resonates closely with Zorin OS 16 (GNOME edition). You can tweak the theme, toggle dark mode, and choose an accent color from the appearance menu. The appearance options also received a refresh to let you easily customize the experience on Zorin OS 16 Lite. Unfortunately, you do not get a jelly mode here, like in Zorin OS 16. So, if you need eye-candy animations, the lite edition may not be a suitable choice for you. In addition to the new visual changes, and features, you will also find new backgrounds to complement your desktop. Some wallpapers could be limited to the Pro edition. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/wallpapers.png) ### Desktop Layouts for Pro Edition While you already get some choices for desktop layouts in the free version, the Pro edition gives you two more additional desktop layouts. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/chrome-os-like-desktop.jpg) One of the layouts resembles a classic Windows design and the other manages to look close to ChromeOS. ![](https://news.itsfoss.com/content/images/wordpress/2021/12/windows-classic-like.jpg) You also get to choose between a macOS-like layout, GNOME 2, and a Windows list-like layout. Note that the default layout is Windows-like and should be a great experience as [one of the best distributions for Windows users](https://itsfoss.com/windows-like-linux-distributions/?ref=news.itsfoss.com). ### Taskbar With Window Previews ![](https://news.itsfoss.com/content/images/wordpress/2021/12/window-previews.png) There has been an important addition to the desktop functionality, i.e., you can now easily view the preview of an active window when you hover over it from the taskbar. At the time of testing this with the pre-released ISO, it was not a smooth experience. But, considering they iron out the bugs, it is an excellent feature to have in Zorin OS 16 Lite. ### Flathub Enabled by Default The application center (or software center) also offers Flathub integration out of the box. You should quickly find Flatpak apps from the software center and choose to change sources if you do not prefer Flatpak packages. ### Other Improvements ![](https://news.itsfoss.com/content/images/wordpress/2021/12/zorin-os-16-lite-neofetch.png) In addition to the key changes, you will also find improvements like Firefox browser baked in with telemetry disabled, a new sound recorder app, fractional scaling for high-resolution displays, and the Rythmbox app. Thunar file manager has received usual subtle improvements and blends in with the rest of the design. You should be able to play videos out-of-the-box using the parole video player. The presence of [Linux Kernel 5.11](https://news.itsfoss.com/linux-kernel-5-11-release/) should make sure of some technical compatibility improvements. Overall, the Zorin OS team has done a wonderful job in carrying over the beautiful design and ease of use from Zorin OS 16 to its lite edition. You may not even realize that you are using the Xfce desktop environment for the most part. ## Download Zorin OS 16 Lite You can head to its download page to get Zorin OS 16 Lite ISO. If you have already purchased Zorin OS 16 Pro, you can use the link from your email to download the Pro Lite edition. What do you think about Zorin OS 16 Lite? Feel free to let us know your thoughts in the comments. ## More from It's FOSS... - Support us by opting for [It's FOSS Plus](https://itsfoss.com/#/portal/signup)membership. - Join our [community forum](https://itsfoss.community/). - 📩 Stay updated with the latest on Linux and Open Source. Get our [weekly Newsletter](https://itsfoss.com/newsletter/).
14,069
系统监控中心:一个理想的 Linux 任务管理器和资源监视器
https://itsfoss.com/system-monitoring-center/
2021-12-10T13:05:00
[ "监控" ]
https://linux.cn/article-14069-1.html
> > “系统监控中心”是一个多合一的开源应用,不用使用多种工具就可以监控基本的系统资源情况。 > > > ![](/data/attachment/album/202112/10/131211ng09sz76u2b7gbaw.jpg) 在 Linux 上以图形方式监控系统资源可能体验不是很好,这些与你的桌面环境相配套的系统监控工具可能细节有限。 例如,GNOME 的系统监视器不显示 CPU 频率和温度。 此外,Linux 的默认系统监控程序通常以简单为目标,而不是提供详细的信息。 “<ruby> 系统监控中心 <rt> System Monitoring Center </rt></ruby>” 是一个有用的 GUI 工具,它提供了大量必要的信息。在这篇文章中,让我给你详细介绍一下它。 ### 系统监控中心:显示基本系统统计信息的 Linux 应用 ![](/data/attachment/album/202112/10/130511vfll2v5lmlxo555b.png) 系统监控中心是一个基于 GTK3 和 Python 3 的外观时尚的应用,它为你提供了你想要的所有资源使用数据。 在我的例子中,我想在使用系统监控工具时关注 CPU 的频率,但 GNOME 的系统监控工具提供不了帮助。所以,这个应用就非常有用了。 ![](/data/attachment/album/202112/10/130511n2ov5gvx2r04kzuv.png) 该应用的用户体验良好,并提供了大量的信息和功能。让我重点介绍一下它的主要功能。 > > 写这篇文章时,该应用程序仍处于测试阶段。因此,你可能会遇到一些错误。然而,我在简短的测试中没有注意到任何问题。 > > > ### 系统监控中心的功能 ![](/data/attachment/album/202112/10/130512o8nrr11i8hrjjqyr.png) 首先,它可以让你查看 CPU、内存、磁盘、网络、GPU 和传感器的单独统计数据。 你可以在该工具中看到以下细节信息: * 显示 CPU 状态,包括频率 * 能够显示平均使用率或每个核心的使用率 * 可以选择 CPU 频率和其他统计的精度 * 能够改变图表的颜色 * 按用户过滤系统进程并轻松管理它们 * 切换一个浮动的摘要小部件,以快速获得信息 * 显示磁盘使用信息和连接的驱动器 * 在同一个应用中显示详细的系统信息 * 控制启动服务和程序 * 能够控制状态更新的时间间隔 * 应用本身的系统资源使用率较低 * 适应系统主题 虽然它为每个标签(或组件)提供了大量的选项和自定义功能,但我希望它能在未来的更新中包括 RAM 频率等东西。 ![](/data/attachment/album/202112/10/130512tdrxkgvvhghtdr8l.png) 然而,考虑到它可以同时取代磁盘使用分析器和 `neofetch` 等终端工具,其余的数据似乎非常有用。 ![](/data/attachment/album/202112/10/130512locqks6lrky7117c.png) 请注意,如果你有多个机箱风扇、独立的排风扇或 AIO,你可能无法得到风扇的数据。温度也可能有或没有,但 CPU 的温度应该是可见的。 ### 在 Linux 中安装系统监控中心 你可以使用可用的 deb 包在任何基于 Ubuntu 的发行版上轻松安装它。 不幸的是,没有可用的其他软件包,只有一个 ZIP 文件,你得手动构建和编译才能安装它。你在 ZIP 文件中可以找到一个脚本来构建 RPM 包。 deb 文件可以通过 SourceForge 获得。你点击下面的按钮来下载它,或者在他们的 [GitLab 页面](https://kod.pardus.org.tr/Hakan/system-monitoring-center) 找到。 * [下载系统监控中心](https://sourceforge.net/projects/system-monitoring-center/files/latest/download) ### 总结 系统监控中心是一个开源应用,可以让用户详细了解他们的系统资源,并帮助管理进程。 对于许多 Linux 用户来说,这是一个非常需要的应用,不需要使用单独的终端/GUI 程序就可以提供详细的信息。 --- via: <https://itsfoss.com/system-monitoring-center/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) [Graphically monitoring the system resources](https://itsfoss.com/linux-system-monitoring-tools/) may not be the best experience on Linux. The system monitoring tool that comes baked in with your desktop environment might limit the details. For instance, GNOME’s system monitor does not display the CPU frequency and temperatures. In addition, the default system monitor applications available for Linux usually aim for simplicity instead of providing detailed insights. System Monitoring Center is a useful GUI tool that provides plenty of necessary insights. In this article, let me give you a closer look at it. ## System Monitoring Center: Linux App to Display Essential System Stats ![system monitoring center](https://itsfoss.com/content/images/wordpress/2021/11/system-monitoring-center.png) System Monitoring Center is a GTK3 and Python 3 based sleek-looking app that gives you all the resource usage data that you would want. In my case, I wanted to keep an eye on the CPU frequency when using a system monitoring tool, but GNOME’s system monitoring tool didn’t help. So, this came in pretty handy. ![system monitoring center full info](https://itsfoss.com/content/images/wordpress/2021/11/system-monitoring-center-full-info.png) The application provides a good user experience and offers plenty of insights and features. Let me highlight the key features that you can expect with it. The application is still in the beta phase when writing this. So, you can expect to encounter bugs. However, I did not notice any issues in my brief testing. ## Features of System Monitoring Center ![system monitoring center options](https://itsfoss.com/content/images/wordpress/2021/11/system-monitoring-center-options.png) To start with, it lets you view separate stats for your CPU, RAM, Disk, Network, GPU, and sensors. You can expect the following details with the tool: - Displays CPU status including the frequency - Ability to display average usage or usage per core - Select the precision points for CPU frequency and other stats - Ability to change the graph color - Filter system processes by user and easily manage them - Toggle a floating summary widget to quickly get insights - Shows disk usage info and connected drives - Detailed system info in the same app - Control startup services and programs - Ability to control the state update interval - Low system resource usage for the app itself - Adapts to system theme While it offers a ton of options and customizations per tab (or component), I wish that it would include the RAM frequency, among other things, in a future update. ![system cpu monitoring](https://itsfoss.com/content/images/wordpress/2021/11/system-cpu-monitoring.png) However, the rest of the data seem incredibly helpful, considering it could replace the use of a disk usage analyzer and a terminal tool like neofetch at the same time. ![system monitoring center process](https://itsfoss.com/content/images/wordpress/2021/11/system-monitoring-center-process.png) Do note that you may not get the data for fans if you have multiple case fans, a separate exhaust fan, or an AIO. The temperatures can be a hit or miss, but the CPU temperature should be visible. ## Install System Monitoring Center in Linux You can easily install it on any Ubuntu-based distros using the deb package available. Unfortunately, there are no available packages except a ZIP file that you will have to manually build and compile to get it installed. You should find a script to build the RPM package within the ZIP file. The deb file is available through SourceForge; you should click the button below to download it or choose to explore their [GitLab instance page](https://kod.pardus.org.tr/Hakan/system-monitoring-center?ref=itsfoss.com). [Download System Monitoring Center](https://sourceforge.net/projects/system-monitoring-center/files/latest/download?ref=itsfoss.com) ## Wrapping Up System Monitoring Center is an open-source app that lets users get detailed insights about their system resources and help manage processes. This is a much-needed app that provides detailed insights without dabbling through separate terminal/GUI programs for many Linux users.
14,071
使用 find 命令在 Linux 上查找文件和目录
https://opensource.com/article/21/9/linux-find-command
2021-12-11T08:39:18
[ "find" ]
https://linux.cn/article-14071-1.html
> > 学习 find 命令的原因有很多。 > > > ![](/data/attachment/album/202112/11/083907eapzsopvcoc0ooro.jpg) 不管我决心如何组织文件,似乎总有无法找到文件的时候。有时是因为我不记得最初的文件名,其他时候,我知道名字,但我不记得在哪里保存它了。甚至有时我需要一个我最初就没有创建的文件。但是,无论遇到什么困难,我知道在 [POSIX 系统](https://opensource.com/article/19/7/what-posix-richard-stallman-explains) 上,总是有 `find` 命令可以帮助我。 ### 安装 find `find` 命令由 [POSIX 规范](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/) 定义,它创建了一个用于衡量 POSIX 系统的开放标准,这包括 Linux、BSD 和 macOS。简而言之,只要你运行的是 Linux、BSD 或 macOS,那么 `find` 已经安装了。 但是,并非所有的 `find` 命令都完全相同。例如,GNU 的 `find` 命令有一些 BSD、Busybox 或 Solaris 上 `find` 命令可能没有或有但实现方式不同的功能。本文使用 [findutils](https://www.gnu.org/software/findutils/) 包中的 GNU `find`,因为它很容易获得且非常流行。本文演示的大多数命令都适用于 `find` 的其他实现,但是如果你在 Linux 以外的平台上尝试命令并得到非预期结果,尝试下载并安装 GNU 版本。 ### 按名称查找文件 你可以借助正则表达式使用完整或部分的文件名来定位文件。`find` 命令需要你给出想搜索的目录;指定搜索属性选项,例如,`-name` 用于指定区分大小写的文件名;然后是搜索字符串。默认情况下,搜索字符串按字面意思处理:除非你使用正则表达式语法,否则 `find` 命令搜索的文件名正是你在引号之间输入的字符串。 假设你的 `Documents` 目录包含四个文件:`Foo`、`foo`、`foobar.txt` 和 `foo.xml`。以下是对 `foo` 的字面搜索: ``` $ find ~ -name "foo" /home/tux/Documents/examples/foo ``` 你可以使用 `-iname` 选项使其不区分大小写来扩大搜索范围: ``` $ find ~ -iname "foo" /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo ``` ### 通配符 你可以使用基本的 shell 通配符来扩展搜索。例如,`*` 表示任意数量的字符: ``` $ find ~ -iname "foo*" /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo /home/tux/Documents/examples/foo.xml /home/tux/Documents/examples/foobar.txt ``` `?` 表示单个字符: ``` $ find ~ -iname "foo*.???" /home/tux/Documents/examples/foo.xml /home/tux/Documents/examples/foobar.txt ``` 这不是正则表达式语法,因此 `.` 在示例中只表示字母“点”。 ### 正则表达式 你还可以使用正则表达式。与 `-iname` 和 `-name` 一样,也有区分大小写和不区分大小写的选项。但不一样的是,`-regex` 和 `-iregex` 搜索应用于整个路径,而不仅仅是文件名。这意味着,如果你搜索 `foo`,你不会得到任何结果,因为 `foo` 与 `/home/tux/Documents/foo` 不匹配。相反,你必须要么搜索整个路径,要么在字符串的开头使用通配符: ``` $ find ~ -iregex ".*foo" /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo ``` ### 查找近一周修改过的文件 要查找近一周修改的文件,使用 `-mtime` 选项以及过去的天数(负数): ``` $ find ~ -mtime -7 /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo /home/tux/Documents/examples/foo.xml /home/tux/Documents/examples/foobar.txt ``` ### 查找近几天修改的文件 你可以结合使用 `-mtime` 选项来查找近几天范围内修改的文件。对于第一个 `-mtime` 参数,表示上一次修改文件的最近天数。第二个参数表示最大天数。例如,搜索修改时间超过 1 天但不超过 7 天的文件: ``` $ find ~ -mtime +1 -mtime -7 ``` ### 按文件类型限制搜索 指定查找文件的类型来优化 `find` 的结果是很常见的。如果你不确定要查找的内容,则不应该使用此选项。但如果你知道要查找的是文件而不是目录,或者是目录而不是文件,那么这可能是一个很好的过滤器。选项是 `-type`,它的参数是代表不同类型数据的字母代码。最常见的是: * `d` - 目录 * `f` - 文件 * `l` - 链接文件 * `s` - 套接字 * `p` - 命名管道(用于 FIFO) * `b` - 块设备(通常是硬盘) 下面是一些例子: ``` $ find ~ -type d -name "Doc*" /home/tux/Documents $ find ~ -type f -name "Doc*" /home/tux/Downloads/10th-Doctor.gif $ find /dev -type b -name "sda*" /dev/sda /dev/sda1 ``` ### 调整范围 `find` 命令默认是递归的,这意味着它会在指定的目录中层层搜索结果。这在大型文件系统中可能会变得不堪重负,但你可以使用 `-maxdepth` 选项来控制搜索深度: ``` $ find /usr -iname "*xml" | wc -l 15588 $ find /usr -maxdepth 2 -iname "*xml" | wc -l 15 ``` 也可以使用 `-mindepth` 设置最小递归深度: ``` $ find /usr -mindepth 8 -iname "*xml" | wc -l 9255 ``` ### 下载速查表 本文仅介绍 `find` 的基本功能,它是一个很好的搜索工具,但对于强大的 [Parallel](https://opensource.com/article/18/5/gnu-parallel) 命令来说,它也是一个非常有用的前端。学习 `find` 的原因有很多,所以 [下载我们免费的 `find` 速查表](https://opensource.com/downloads/linux-find-cheat-sheet) 吧,它可以帮助你了解有关该命令的更多信息。 --- via: <https://opensource.com/article/21/9/linux-find-command> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[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/) 荣誉推出
200
OK
Regardless of how organized I resolve to be, it seems there are always times when I just can't locate a file. Sometimes it's because I can't remember the name of the file in the first place. Other times, I know the name, but I can't recall where I decided to save it. There are even times when I need a file that I didn't create in the first place. No matter what the quandary, though, I know that on a [POSIX system](https://opensource.com/article/19/7/what-posix-richard-stallman-explains), I always have the `find` command. ## Installing find The `find` command is defined by the [POSIX specification](https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/), which creates the open standard by which POSIX systems (including Linux, BSD, and macOS) are measured. Simply put, you already have `find` installed as long as you're running Linux, BSD, or macOS. However, not all `find` commands are exactly alike. The GNU `find` command, for instance, has features that the BSD or Busybox or Solaris `find` command might not have or does have but implements differently. This article uses GNU `find` from the [findutils](https://www.gnu.org/software/findutils/) package because it's readily available and pretty popular. Most commands demonstrated in this article work with other implementations of `find` , but should you try a command on a platform other than Linux and get unexpected results, try downloading and installing the GNU version. ## Find a file by name You can locate a file by its filename by providing the full file name or parts of the file name using regular expressions. The `find` command requires the path to the directory you want to search in, options to specify what attribute you're searching (for instance, -`name` for a case-sensitive file name), and then the search string. By default, your search string is treated literally: The `find` command searches for a filename that is exactly the string you enter between quotes unless you use regular expression syntax. Assume your Documents directory contains four files: `Foo` , `foo` , `foobar.txt` , and `foo.xml` . Here's a literal search for a file with the name "foo": ``` $ find ~ -name "foo" /home/tux/Documents/examples/foo ``` You can broaden your search by making it case-insensitive with the `-iname` option: ``` $ find ~ -iname "foo" /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo ``` ## Wildcards You can use basic shell wildcard characters to broaden your search. For instance, the asterisk (`*` ) represents any number of characters: ``` $ find ~ -iname "foo*" /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo /home/tux/Documents/examples/foo.xml /home/tux/Documents/examples/foobar.txt ``` A question mark (`?` ) represents a single character: ``` $ find ~ -iname "foo*.???" /home/tux/Documents/examples/foo.xml /home/tux/Documents/examples/foobar.txt ``` This isn't regular expression syntax, so the dot (`.` ) represents a literal dot in this example. ## Regular expressions You can also use regular expressions. As with `-iname` and `-name` , there's both a case-sensitive and a case-insensitive option. Unlike the `-name` and `-iname` options, though, a `-regex` and `-iregex` search is applied to the *whole path*, not just the file name. That means if you search for `foo` , you get no results because `foo` doesn't match `/home/tux/Documents/foo` . Instead, you must either search for the entire path, or else use a wildcard sequence at the beginning of your string: ``` $ find ~ -iregex ".*foo" /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo ``` ## Find a file modified within the last week To find a file you last modified last week, use the `-mtime` option along with a (negative) number of days in the past: ``` $ find ~ -mtime -7 /home/tux/Documents/examples/foo /home/tux/Documents/examples/Foo /home/tux/Documents/examples/foo.xml /home/tux/Documents/examples/foobar.txt ``` ## Find a file modified within a range of days You can combine `-mtime` options to locate a file within a range of days. For the first `-mtime` argument, provide the most recent number of days you could have modified the file, and for the second, give the greatest number of days. For instance, this search looks for files with modification times more than one day in the past, but no more than seven: `$ find ~ -mtime +1 -mtime -7` ## Limit a search by file type It's common to optimize the results of `find` by specifying the file type you're looking for. You shouldn't use this option if you're not sure what you're looking for, but if you know you're looking for a file and not a directory, or a directory but not a file, then this can be a great filter to use. The option is `-type` , and its arguments are a letter code representing a few different kinds of data. The most common are: `d` - directory`f` - file`l` - symbolic link`s` - socket`p` - named pipe (used for FIFO)`b` - block special (usually a hard drive designation) Here are some examples: ``` $ find ~ -type d -name "Doc*" /home/tux/Documents $ find ~ -type f -name "Doc*" /home/tux/Downloads/10th-Doctor.gif $ find /dev -type b -name "sda*" /dev/sda /dev/sda1 ``` ## Adjust scope The `find` command is recursive by default, meaning that it searches for results in the directories of directories contained in directories (and so on). This can get overwhelming in a large filesystem, but you can use the `-maxdepth` option to control how deep into your folder structure you want `find` to descend: ``` $ find /usr -iname "*xml" | wc -l 15588 $ find /usr -maxdepth 2 -iname "*xml" | wc -l 15 ``` You can alternately set the minimum depth of recursion with `-mindepth` : ``` $ find /usr -mindepth 8 -iname "*xml" | wc -l 9255 ``` ## Download the cheat sheet This article only covers the basic functions of `find` . It's a great tool for searching through your system, but it's also a really useful front-end for the powerful [Parallel](https://opensource.com/article/18/5/gnu-parallel) command. There are many reasons to learn `find` , so ** download our free ** to help you learn more about the command. `find` cheat sheet ## 3 Comments
14,072
在 Linux 上用 SoundConverter 分批转换音频
https://opensource.com/article/21/12/soundconverter-linux
2021-12-11T09:03:06
[ "音频", "转换" ]
https://linux.cn/article-14072-1.html
> > SoundConverter 是一个有用的应用,它不仅能做到它的名字所说的那样,而且它是分批和并行地做的。 > > > ![](/data/attachment/album/202112/11/090248gqt2hwqtyft51qwh.jpg "radio communication signals") 有许多用于存储数字音频的文件格式,它们适用于不同的目的。当然,数字音频只是声音的一种表现形式,是一种声波的呈现,它由解码器和一组扬声器转化为声音。一些音频格式,一般被称为 <ruby> 无损 <rt> lossless </rt></ruby> 格式,旨在将音频编码为接近其原始模拟形式。然而,在现实世界中有大量的数据,而迄今为止,数字形式只能对其进行近似处理,而且需要非常大的文件。其他的音频格式,被称 <ruby> 有损 <rt> lossy </rt></ruby> 格式,可以在文件大小与声音的合理表现之间取得平衡。 有很多很好的终端命令可以用于音频转换:有 `sox` 和 `ffmpeg`,以及一些特定格式的编码器,如 `opusenc`、`flac`、`oggenc`、`fdkaac`、`wavpack` 和无数的其他编码器。 ### 在 Linux 上安装 SoundConverter SoundConverter 在大多数 Linux 发行版上都可以通过你的包管理器获得。在 Fedora、Mageia 和类似的发行版上: ``` $ sudo dnf install kdenlive ``` 在 Elementary、Mint 和其他基于 Debian 的发行版上: ``` $ sudo apt install kdenlive ``` 然而,我使用使用 [Flatpak](https://opensource.com/article/21/11/install-flatpak-linux) 安装 SoundConverter。 ### 转换音频 一旦你把音频编码成有损格式,你就丢失了数据。这些数据是否重要取决于其听众的耳朵。有些人听不出低比特率的 MP3 和全质量的 FLAC 文件之间的区别,即使那些能听出来的人,也常常注意不到 320kbps 的 Ogg Vorbis 播客和 128kbps 的 Ogg Vorbis 播客之间的区别。将音频从压缩格式转换为非压缩格式并不能恢复丢失的数据,但需要将音频从一种格式转换为另一种格式的情况并不少见。你可能想把文件上传到只接受特定格式的网站,或者你的移动设备可能只能播放特定的格式,或者用电子邮件发送一个对你的邮件主机来说太大的文件,或者你可能只是想节省硬盘上的空间。 SoundConverter 可以让你轻松地分批转换音频。要用 SoundConverter 转换音频: 1. 从你的应用或活动菜单中启动 SoundConverter。 2. 点击 SoundConverter 窗口左上角的“<ruby> 添加文件 <rt> Add Files </rt></ruby>”按钮,并选择你要转换的文件。 3. 添加了文件后,点击窗口右上角的“<ruby> 偏好 <rt> Preferences </rt></ruby>”按钮(齿轮图标),并选择你想转换的格式。你还可以设置文件命名规则、目标文件夹和其他选项。 4. 当你准备好了,点击左上角的“<ruby> 转换 <rt> Convert </rt></ruby>”按钮。 ![SoundConverter window](/data/attachment/album/202112/11/090308hodhy4ekkhornhgl.jpg "SoundConverter window") ### 并行处理 SoundConverter 是一个有用的应用,它不仅完全做了它的名字所说的事情,而且它是分批和并行地做的。因为现代计算机不仅仅有一个 CPU 核心,把每个文件放在一个队列中逐一编码,是对能源和时间的浪费。SoundConverter 可以同时处理几个文件,并对它们进行编码,这意味着转换 12 个文件所需的时间和通常一个接一个地转换两个文件所需的时间是一样的。你可以用一个好的终端命令做同样的事情,但前提是你要了解如何 [启动并行进程](https://opensource.com/article/18/5/gnu-parallel)。 ![SoundConverter preferences](/data/attachment/album/202112/11/090308sytt0b1mjm1s9109.jpg "SoundConverter preferences") 你也可以将立体声音频转换为单声道文件。这对播客和有声读物特别有用。这些通常由一个人从一个单一的位置(麦克风)说话组成,不需要空间位置感。事实上,将立体声文件减少到单声道,如果你只有一个耳塞,就能更容易听到音频,并将文件大小减半。 ### SoundConverter 的优势 为音频提供不同的文件格式是一个很好的功能,但似乎每当我以一种格式保存音频时,我都不可避免地需要另一种格式。有几个很棒的 Linux 命令可以 [转换音频文件](https://opensource.com/article/17/6/ffmpeg-convert-media-file-formats),但有时你可能想要一个可以在桌面上打开并拖放文件的应用,这就是 [SoundConverter](https://soundconverter.org/) 的用场。SoundConverter 是一个简单的而用途单一的应用程序,它的作用和它的名字一样:把声音从一种格式转换为另一种格式。 --- via: <https://opensource.com/article/21/12/soundconverter-linux> 作者:[Seth Kenlon](https://opensource.com/users/seth) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
There are many file formats used to store digital audio, and they're good for different purposes. Digital audio is, of course, only a representation of sound, a rendering of soundwaves that get translated into sound by a decoder and a set of speakers. Some audio formats, generically called *lossless* formats, aim to encode audio close to its original analog form. Still, there's a lot of data in the real world, and as yet, digital can only approximate it in very large files. Other audio formats, called *lossy* formats, balance file size with a reasonable representation of sound. There are plenty of great terminal commands for audio conversion. There's `sox` and `ffmpeg` and a handful of format-specific encoders, like `opusenc` , `flac` , `oggenc` , `fdkaac` , `wavpack` , and countless others. ## Install SoundConverter on Linux SoundConverter is available on most Linux distributions from your package manager. On Fedora, Mageia, and similar distributions: `$ sudo dnf install soundconverter` On Elementary, Mint, and other Debian-based distributions: `$ sudo apt install soundconverter` However, I use SoundConverter as a [Flatpak](https://opensource.com/article/21/11/install-flatpak-linux). ## Converting audio Once you encode audio into a lossy format, you've lost data. Whether that data matters or not depends on the ears of its audience. Some people can't hear the difference between a low-bitrate MP3 and a full quality FLAC file, and even those who can often don't notice the difference between a 320kbps Ogg Vorbis podcast and a 128 kbps Ogg Vorbis podcast. Converting audio from a compressed format to an uncompressed format doesn't recover lost data, but it's not uncommon to need to convert audio from one format to another. You might want to upload a file to a website that accepts only a specific format, or your mobile device might only play a specific format, or to email a file that's too large for your host, or you might just want to save space on your drive. SoundConverter lets you convert audio in batches with ease. To convert audio with SoundConverter: - Launch SoundConverter from your Applications or Activities menu. - Click the **Add Files**button in the top left corner of the SoundConverter window, and select the files you want to convert. - Once you've added files, click the **Preferences**button (the gear icon) in the top right corner of the window, and select the format you want to convert to. You can also set the file naming convention, the destination folder, and other options. - When you're ready, click the **Convert**button in the top left corner. ![SoundConverter window SoundConverter window](https://opensource.com/sites/default/files/uploads/soundconverter_0.jpg) (Seth Kenlon, CC BY-SA 4.0) ## Parallel processing SoundConverter is a useful application not just because it does exactly what its name says it does, but because it does it in batches and in parallel. Because modern computers have more than just CPU core, it's a waste of power and time to place each file in a queue to encode them one by one. SoundConverter can take several files at once and encode them simultaneously, meaning that converting 12 files can take the same time it would normally take to convert two—one after the other. You can do the same thing with a good terminal command, but only if you understand how to [launch parallel processes](https://opensource.com/article/18/5/gnu-parallel). ![SoundConverter preferences SoundConverter preferences](https://opensource.com/sites/default/files/uploads/soundconvert-preferences.jpg) (Seth Kenlon, CC BY-SA 4.0) You can also convert stereo audio into mono files. This can be especially useful for podcasts and audiobooks. These usually consist of a person speaking from a singular location (the microphone) and don't require a sense of spatial location. In fact, reducing stereo files to mono makes the audio easier to hear should you have just one earbud and cuts the file size in half. ## The SoundConverter advantage It's a great feature to have different file formats for audio, and yet it seems that whenever I've saved audio in one format, I inevitably need it in another format. There are several great Linux commands to [convert audio files](https://opensource.com/article/17/6/ffmpeg-convert-media-file-formats), but sometimes you might want an application you can leave open on your desktop and drag and drop files to, and so there's [SoundConverter](https://soundconverter.org/). A simple, single-purpose application, SoundConverter does exactly, and only, what its name says: It converts sound from one format to another. ## Comments are closed.
14,074
FreeDOS 操作目录和文件的基本命令
https://opensource.com/article/21/4/freedos-commands
2021-12-12T10:03:58
[ "FreeDOS" ]
https://linux.cn/article-14074-1.html
> > 学习如何在 FreeDOS 中对目录和文件执行创建、移除、复制等任务。 > > > ![](/data/attachment/album/202112/12/100340gffegjttbn0n7iox.jpg "young woman working on a laptop") DOS 的开源实现 [FreeDOS](https://www.freedos.org/) 提供了一个轻量级的操作系统,可以在现代硬件(或模拟器)上用于运行历史遗留下来的应用程序,可以更新硬件供应商不兼容于 Linux 的固件闪存。熟悉 FreeDOS 不仅是一种对旧计算机时代的有趣考古,也是一种获取有用的计算机技能的投入。在这篇文章中,我将介绍一些在 FreeDOS 系统上工作所需要知道的基本命令。 ### 基本的命令和文件命令 FreeDOS 在硬盘驱动器上使用目录来组织文件。这意味着你需要使用目录命令来创建一个结构,用于存储和查找你在其中存储的文件。你所需要的用于管理目录结构的命令有: * `MD` (或 `MKDIR`) 创建一个新的目录或子目录。 * `RD` (或 `RMDIR`) 移除(删除) 一个目录或子目录。 * `CD` (或 `CHDIR`) 从当前工作目录更改到另一个命令。 * `DELTREE` 删除一个目录,包括其包含的任意文件或子目录。 * `DIR` 列出当前工作目录的内容。 因为使用目录是 FreeDOS 的主要工作,所有的这些命令(除 DELTREE 以外)是包含在 `COMMAND.COM` 中的内部命令。因此,它们将被加载到内存之中,并在你启动(即使是从启动盘启动)时随时可用。前三个命令有两个版本:一个版本是两个字母的短名,一个版本是长名。在实践中没有区别,因此,我将在这篇文章中使用短名。 ### 使用 MD 创建一个目录 FreeDOS 的 `MD` 命令会创建一个新的目录或子目录。(实际上,由于 `\` 是根目录,从技术上讲,所有的目录都是子目录,因此,我更喜欢在所有的示例中使用“子目录”的说法)。有一个可选的参数是你所想要创建目录的路径,但是如果不包含路径,将在当前工作子目录中创建子目录。 例如,为在你的当前位置创建一个名称为 `letters` 的子目录: ``` C:\HOME\>MD LETTERS ``` 这会创建子目录 `C:\letters` 。 通过包含一个路径,你可以在任意位置创建一个子目录: ``` C:\>MD C:\HOME\LETTERS\LOVE ``` 这和先移动到 `C:\HOME\LETTERS` ,然后在其中创建一个子目录的结果相同: ``` C:\CD HOME\LETTERS C:\HOME\LETTERS\>MD LOVE C:\HOME\LETTERS\>DIR LOVE ``` 一个路径描述不能超过 63 个字符,包括反斜杠在内。 ### 使用 RD 移除一个目录 FreeDOS 的 `RD` 命令会移除一个子目录。这个子目录必须是空的。如果它包含文件或其它是子目录,你将会得到错误信息。它也有一个可选的路径参数,语法与 `MD` 的相同。 你不能移除你的当前工作子目录。为移除此目录,你必须 `CD` 到其父目录,然后再移除不需要的子目录。 ### 使用 DELTREE 删除文件和目录 `RD` 命令可能会让人有点迷糊,因为在该命令中内置了保护 FreeDOS 的措施。例如,你不能删除一个包含内容的子目录是一种安全措施。`DELTREE` 就是解决方案。 `DELTREE` 命令会删除整个子目录“树”(子目录)、其包含的所有的文件,以及其包含的所有的子目录及其包含的所有的文件等等,上述的一切都在一个简单的命令中完成。有时,它可能有点 *太* 容易了,因为它可以如此快速地擦除数据。它是忽略文件属性的,因此你可以擦除隐藏、只读,和未知的系统文件。 你甚至可以在命令中具体指定多个目录树来擦除它们。这条命令将在一个命令中擦除这两个目录中的所有子目录: ``` C:\>DELTREE C:\FOO C:\BAR ``` 这是那些使用前需要三思的命令中的其中一个。毫无疑问,它自然有其价值。我仍然对转到每个子目录,删除个别文件,检查每个子目录的内容,一次删除一个子目录, 然后再跳转到上一层目录,重复上述过程的乏味而记忆犹新。`DELTREE` 在你需要时是非常省时。但是我从不会将其用于日常维护,因为一此失误都能造成重大的损失。 ### 格式化一个硬盘驱动器 `FORMAT` 命令也可以用于准备一个空白的硬盘驱动器来将文件写入其中。这将格式化 `D:` 驱动器: ``` C:\>FORMAT D: ``` ### 复制文件 `COPY` 命令,顾名思义,将文件从一个位置复制到另一个位置。所需要的参数是:将要被复制的文件、要将其复制到的路径和文件。开关选项包含: * `/Y` 当一个文件要被覆盖时,避免出现提示。 * `/-Y` 当一个文件要被覆盖时,需要出现提示。 * `/V` 验证副本的内容。 这将从 `C:` 上的工作目录中复制文件 `MYFILE.TXT` 到 `D:` 驱动器的根目录,并将其重命名为 `EXAMPLE.TXT` : ``` C:\>COPY MYFILE.TXT D:\EXAMPLE.TXT ``` 这将从 `C:` 上的工作目录中复制文件 `EXAMPLE.TXT` 到 `C:\DOCS\` 目录,接下来验证文件的内容来确保副本是完整的: ``` C:\>COPY EXAMPLE.TXT C:\DOCS\EXAMPLE.TXT /V ``` 你也可以使用 `COPY` 命名来合并和追加文件。这个命令将合并两个文件 `MYFILE1.TXT` 和 `MYFILE2.TXT` ,并将其放置到一个新的名称为 `MYFILE3.TXT` 的文件之中: ``` C:\>COPY MYFILE1.TXT+MYFILE2.TXT MYFILE3.TXT ``` ### 使用 XCOPY 复制目录 `XCOPY` 命令将复制整个目录以及它们的所有的子目录和这些子目录中包含的所有的文件。参数是将要复制的文件和其路径,以及将要复制到的目的地。重要的开关选项是: * `/S` 复制当前目录及其子目录中的所有文件。 * `/E` 复制子目录,即使它们是空的。这个选项必须和 `/S` 一起使用。 * `/V` 验证其所制作的副本。 这是一个非常强大和有用的命令,尤其是用于备份目录或整个硬盘驱动器。 这个命令将复制目录 `C:\DOCS` 的全部内容,包括所有的子目录及其内容(除了空的子目录以外),并将其放置到驱动器 `D:` 的目录 `D:\BACKUP\DOCS\` 之中: ``` C:\>XCOPY C:\DOCS D:\BACKUP\DOCS\ /S ``` ### 使用 FreeDOS FreeDOS 是一个有趣的、轻量的、开源的操作系统。不管你正在使用它来更新你的主板的固件,还是给予旧计算机新生,它都能提供很多有用的实用程序,可以使你能够很好地使用它工作。学习 FreeDOS 的基本知识。你都可能会被它的多才多艺所惊讶。 --- via: <https://opensource.com/article/21/4/freedos-commands> 作者:[Kevin O'Brien](https://opensource.com/users/ahuka) 选题:[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/) 荣誉推出
200
OK
[FreeDOS](https://www.freedos.org/), the open source implementation of DOS, provides a lightweight operating system for running legacy applications on modern hardware (or in an emulator) and for updating hardware vendor fails with a Linux-compatible firmware flasher. Getting familiar with FreeDOS is not only a fun throwback to the computing days of the past, it's an investment into gaining useful computing skills. In this article, I'll look at some of the essential commands you need to know to work on a FreeDOS system. ## Essential directory and file commands FreeDOS uses directories to organize files on a hard drive. That means you need to use directory commands to create a structure to store your files and find the files you've stored there. The commands you need to manage your directory structure are relatively few: `MD` (or`MKDIR` ) creates a new directory or subdirectory.`RD` (or`RMDIR` ) removes (or deletes) a directory or subdirectory.`CD` (or`CHDIR` ) changes from the current working directory to another directory.`DELTREE` erases a directory, including any files or subdirectories it contains.`DIR` lists the contents of the current working directory. Because working with directories is central to what FreeDOS does, all of these (except DELTREE) are internal commands contained within COMMAND.COM. Therefore, they are loaded into RAM and ready for use whenever you boot (even from a boot disk). The first three commands have two versions: a two-letter short name and a long name. There is no difference in practice, so I'll use the short form in this article. ## Make a directory with MD FreeDOS's `MD` command creates a new directory or subdirectory. (Actually, since the *root* is the main directory, all directories are technically subdirectories, so I'll refer to *subdirectories* in all examples.) An optional argument is the path to the directory you want to create, but if no path is included, the subdirectory is created in the current working subdirectory. For example, to create a subdirectory called `letters` in your current location: `C:\HOME\>MD LETTERS` This creates the subdirectory `C:\letters` . By including a path, you can create a subdirectory anywhere: `C:\>MD C:\HOME\LETTERS\LOVE` This has the same result as moving into `C:\HOME\LETTERS` first and then creating a subdirectory there: ``` C:\CD HOME\LETTERS C:\HOME\LETTERS\>MD LOVE C:\HOME\LETTERS\>DIR LOVE ``` A path specification cannot exceed 63 characters, including backslashes. ## Remove a directory with RD FreeDOS's `RD` command removes a subdirectory. The subdirectory must be empty. If it contains files or other subdirectories, you get an error message. This has an optional path argument with the same syntax as `MD` . You cannot remove your current working subdirectory. To do that, you must `CD` to the parent subdirectory and then remove the undesired subdirectory. ## Delete files and directories with DELTREE The `RD` command can be a little confusing because of safeguards FreeDOS builds into the command. That you cannot delete a subdirectory that has contents, for instance, is a safety measure. `DELTREE` is the solution. `DELTREE` deletes an entire subdirectory "tree" (a subdirectory), plus all of the files it contains, plus all of the subdirectories those contain, and all of the files *they* contain, and so on, all in one easy command. Sometimes it can be a little *too* easy because it can wipe out so much data so quickly. It ignores file attributes, so you can wipe out hidden, read-only, and system files without knowing it. You can even wipe out multiple trees by specifying them in the command. This would wipe out both of these subdirectories in one command: `C:\>DELTREE C:\FOO C:\BAR` This is one of those commands where you really ought to think twice before you use it. It has its place, definitely. I can still remember how tedious it was to go into each subdirectory, delete the individual files, check each subdirectory for contents, delete each subdirectory one at a time, then jump up one level and repeat the process. `DELTREE` is a great timesaver when you need it. But I would never use it for ordinary maintenance because one false move can do so much damage. ## Format a hard drive The `FORMAT` command can also be used to prepare a blank hard drive to have files written to it. This formats the `D:` drive: `C:\>FORMAT D:` ## Copy files The `COPY` command, as the name implies, copies files from one place to another. The required arguments are the file to be copied and the path and file to copy it to. Switches include: `/Y` prevents a prompt when a file is being overwritten.`/-Y` requires a prompt when a file is being overwritten.`/V` verifies the contents of the copy. This copies the file `MYFILE.TXT` from the working directory on `C:` to the root directory of the `D:` drive and renames it `EXAMPLE.TXT` : `C:\>COPY MYFILE.TXT D:\EXAMPLE.TXT` This copies the file `EXAMPLE.TXT` from the working directory on `C:` to the `C:\DOCS\` directory and then verifies the contents of the file to ensure that the copy is complete: `C:\>COPY EXAMPLE.TXT C:\DOCS\EXAMPLE.TXT /V` You can also use the `COPY` command to combine and append files. This combines the two files `MYFILE1.TXT` and `MYFILE2.TXT` and places them in a new file called `MYFILE3.TXT` : `C:\>COPY MYFILE1.TXT+MYFILE2.TXT MYFILE3.TXT` ## Copy directories with XCOPY The `XCOPY` command copies entire directories, along with all of their subdirectories and all of the files contained in those subdirectories. Arguments are the files and path to be copied and the destination to copy them to. Important switches are: `/S` copies all files in the current directory and any subdirectory within it.`/E` copies subdirectories, even if they are empty. This option must be used with the`/S` option.`/V` verifies the copies that were made. This is a very powerful and useful command, particularly for backing up directories or an entire hard drive. This command copies the entire contents of the directory `C:\DOCS` , including all subdirectories and their contents (except empty subdirectories) and places them on drive `D:` in the directory `D:\BACKUP\DOCS\` : `C:\>XCOPY C:\DOCS D:\BACKUP\DOCS\ /S` ## Using FreeDOS FreeDOS is a fun, lightweight, open source operating system. It provides lots of great utilities to enable you to get work done on it, whether you're using it to update the firmware of your motherboard or to give new life to an old computer. Learn the basics of FreeDOS. You might be surprised at how versatile it is. *Some of the information in this article was previously published in DOS lesson 8: Format; copy; diskcopy; Xcopy; DOS lesson 10: Directory commands (both CC BY-SA 4.0); and How to work with DOS.* ## Comments are closed.
14,075
适用于 Linux 的最佳网页浏览器
https://itsfoss.com/best-browsers-ubuntu-linux/
2021-12-12T15:08:01
[ "浏览器" ]
https://linux.cn/article-14075-1.html
没有所谓的完美的网页浏览器。这完全取决于你喜欢什么以及你用它来做什么。 但对于 Linux 上的网页浏览器,你有哪些最佳选择呢? 在这篇文章中,我试图给出你在 Ubuntu 和其他 Linux 系统上使用的最佳网页浏览器。 > > **注:** 我们已经在 Ubuntu 上尝试和测试了这些浏览器。但是,你应该能够在你选择的任何 Linux 发行版上安装它。 > > > ### Linux 上的顶级网页浏览器 ![](/data/attachment/album/202112/12/150802ba8l8j48mgi4jzau.png) 每个浏览器都有其独特之处。而且,对于 Linux 平台,也有一些有趣的独家选择。 在你看到这个列表之前,请注意这不是一个排名列表。列在第 1 位的浏览器不应该被认为比第 2 位、第 3 位或第 10 位的更好。 > > **非自由开源软件警报!** > > > 这里提到的一些应用程序不是开源的。它们被列在这里是因为它们在 Linux 上可用,而文章的重点是 Linux。我们也有一个单独的 [开源的网页浏览器的专门列表](https://itsfoss.com/open-source-browsers-linux/)。 > > > ### 1、Vivaldi ![](/data/attachment/album/202112/12/150804b6b63v7n0b3nv130.png) **优点** * 可快速访问网页应用程序的侧边栏 * 集成了日历和电子邮件 * 独特的标签管理 * Pomodoro 功能(时钟计时器) * 有移动应用程序 **缺点** * 当使用各种功能时,资源占用很重 * 不是 100% 开源的 [Vivaldi](https://vivaldi.com) 是一个令人印象深刻的浏览器,它越来越多地得到了 Linux 用户的关注。 虽然它不是 100% 开源的,但你可以在网上找到它的大部分源代码(除了它的用户界面)。 随着 [Vivaldi 4.0 的发布](https://news.itsfoss.com/vivaldi-4-0-release/),他们更加注重改善 Linux 用户的体验。你可以设置时钟计时器以提高你的工作效率,使用内置翻译来翻译网页,跟踪你的日历活动,为网页应用程序添加快捷方式,并通过这个浏览器为多种任务发挥到极致。 即使它是一个快速的网页浏览器,我也不会觉得它是“最快”或最轻量级的。你需要大量的内存,才能在你工作时发挥它的所有的功能。 总之,它是一个功能丰富的网页浏览器。因此,如果你需要有尽可能多的功能来完成多种任务,Vivaldi 可以是你的选择。 #### 如何在 Linux 上安装 Vivaldi? Vivaldi 提供了 **.deb** 和 **.rpm** 两种软件包,让你可以直接在 Linux 系统中安装它。 如果你是 Linux 的新手,你可以参考我们的资源来 [安装 Deb 文件](https://itsfoss.com/install-deb-files-ubuntu/) 和 [安装 RPM 文件](https://itsfoss.com/install-rpm-files-fedora/)。 ### 2、Mozilla Firefox ![](/data/attachment/album/202112/12/150806sc22aiccw86iq7hl.png) **优点** * 隐私保护 * 不基于 Chrome 引擎 * 开源 * Firefox 帐户服务 **缺点** * 用户体验会随着重大更新而改变 [Firefox](https://www.mozilla.org/en-US/firefox/new/) 是大多数 Linux 发行版的默认网页浏览器。因此,它显然是一个开箱即用的浏览器。 除了是开源的,它还提供一些最好的隐私保护功能。而且,通过正确的设置,你可以把它变成类似于 Tor 浏览器(它也是基于 Firefox 的)这样的最安全的浏览器之一。 不仅仅是它的安全性,当你用你的 Firefox 账户登录时,它还集成了有用的功能,如 Pocket(保存网页并稍后阅读)、VPN、电子邮件别名、漏洞监控等。 #### 如何在 Linux 上安装 Firefox? 它应该已经预装在你的 Linux 发行版中了。但是,如果它不存在,你可以在软件中心搜索它,或者用终端的以下命令来安装它: ``` sudo apt install firefox ``` ### 3、Chromium ![](/data/attachment/album/202112/12/150807q9l7m4h927nhnhjh.png) **优点** * Chrome 浏览器的开源替代品 * 与 Chrome 浏览器的功能相似 **缺点** * 缺少 Chrome 浏览器提供的某些功能 [Chromium](https://www.chromium.org) 是 Chrome 浏览器的开源替代品,也是许多其他基于 Chrome 的浏览器的基础。 如果你不想使用 Chrome 浏览器,Chromium 是你在 Linux 上获得相同体验的最佳选择。 尽管谷歌控制着 Chromium,并且 [一直锁定着 Chrome](https://news.itsfoss.com/is-google-locking-down-chrome/),但对于 Linux 系统来说,它是一个不错的选择。 #### 如何在 Linux 上安装 Chromium? 你应该可以在软件中心轻松找到它。但是,如果你需要帮助,可以参考我们的 [Chromium 安装指南](https://itsfoss.com/install-chromium-ubuntu/)。 ### 4、谷歌 Chrome ![](/data/attachment/album/202112/12/150808mji3vrl3iglpp9hr.png) **优点** * 与谷歌服务的无缝整合 **缺点** * 不是开源的 [Chrome 浏览器](https://www.google.com/chrome/) 是一个优秀的网页浏览器,除非你不想选择谷歌的专有解决方案或产品。 你可以得到所有的基本功能,并且能够整合所有的谷歌服务。如果你喜欢在安卓系统上使用 Chrome 浏览器,并希望在多个平台上进行同步,那么它是桌面 Linux 的明显选择。 如果你在使用谷歌服务的同时寻找一个简单而强力的网页浏览器,Chrome 浏览器可以是一个不错的选择。 #### 如何在 Linux 上安装 Chrome 浏览器? Chrome 浏览器提供 Deb 和 RPM 包,可以让你在任何基于 Ubuntu 或 Fedora/openSUSE 发行版上安装。 如果你在安装方面需要帮助,我应该向你指出我们关于 [在 Linux 上安装 Chrome 浏览器](https://itsfoss.com/install-chrome-ubuntu/) 的指南。 ### 5、Brave ![](/data/attachment/album/202112/12/150809iwav63kpke51qps6.jpg) **优点** * 隐私保护功能 * 性能 **缺点** * 没有基于账户的同步 [Brave](https://brave.com/its979) 浏览器是最受欢迎的 Linux 浏览器之一。 它是一个开源项目,基于 Chromium。它提供几个有用的隐私保护功能,并以其极快的性能而闻名。 与其他浏览器不同的是,即使你屏蔽了网站上的广告,你也可以获得奖励。你收集的奖励只能用于回馈你喜欢的网站。这样一来,你在屏蔽广告的同时也得到了对网站的支持。 你可以期待以最小的资源占用获得更快的用户体验。 如果你需要在两者之间做出决定,我们也有一篇详细的 [关于 Brave 和 Firefox 的比较文章](https://itsfoss.com/brave-vs-firefox/)。 #### 如何在 Linux 上安装 Brave? 与其他一些网页浏览器不同,你不能直接在软件中心找到软件包。你需要在终端输入一些命令来安装该浏览器。 不用担心,你可以按照我们的 [安装 Brave 浏览器的说明](https://itsfoss.com/brave-web-browser/) 来进行。 ### 6、Opera ![](/data/attachment/album/202112/12/150810hcbh9qvfsgivgfzq.png) **优点** * 内置免费的 VPN * 额外的功能 **缺点** * 不是开源的 虽然 [Opera](https://www.opera.com/) 不是最流行的选择,但它对 Linux 用户来说绝对是一个有用的浏览器。 它有一个内置的 VPN 和广告拦截器。因此,在 Opera 浏览器的帮助下,你应该会得到基本的隐私保护。 你可以直接从侧边栏快速访问流行的聊天信使,而不需要启动单独的应用程序或窗口。这种侧边栏的聊天信使网页应用与 Vivaldi 类似,但用户体验明显不同。 总的来说,如果你想要一个免费的 VPN 作为其他基本浏览功能之外的奖励,它是一个不错的选择。 值得注意的是,Opera 提供了一个独特的 [Opera GX](https://www.opera.com/gx) 浏览器,让你在使用浏览器并同时进行游戏活动时可以调整或强制限制系统资源。在写这篇文章的时候,该功能还在开发 Linux 版本,如果在你读到这篇文章的时候,它已经可以使用了,这可能是一个很好的选择。 #### 如何安装 Opera? Opera 为 Linux 提供了 Deb 包。你只需前往其官方网站下载并安装即可。 ### 7、微软 Edge ![](/data/attachment/album/202112/12/150811tkowyzy4qsnwypwo.png) **优点** * 为同时也使用 Linux 的 Windows 用户提供了方便的选择。 **缺点** * 不是开源的 [微软 Edge](https://www.microsoftedgeinsider.com/en-us/) 在受欢迎程度上已经超过了 Mozilla Firefox。不仅仅是因为它是默认的 Windows 浏览器,而是它在基于 Chrome 浏览器的同时,还提供了很有前景的网页体验。 微软 Edge 已经发布了面向 Linux 的稳定版。它目前运行良好,但缺乏一些的通常可用于 Windows 的功能。 总的来说,你应该会发现大部分的基本功能都是可用的。 如果你使用 Windows 和 Linux 作为你的桌面平台,微软 Edge 可以考虑作为首选的网页浏览器。 #### 如何在 Linux 上安装微软 Edge? 现在,你可以通过微软 Edge 的官方网页获得 Deb/RPM 文件并安装它。 你也可以看看我们关于 [在 Linux 上安装微软 Edge](https://itsfoss.com/microsoft-edge-linux/) 的方法。 ### Linux 独有的网页浏览器 考虑到安全更新和未来升级,大多数用户喜欢坚持使用主流选项,但也有一些不同的选项。而且,有些是 Linux 用户专属的。 ### 8、GNOME Web(Epiphany) ![](/data/attachment/album/202112/12/150812e9np1hhf1aabnanq.png) **优点** * 精简 * 开源 **缺点** * 缺少许多功能 * 没有跨平台支持 [Epiphany 浏览器](https://apps.gnome.org/en-GB/app/org.gnome.Epiphany/) 是 GNOME 的默认浏览器。elementary OS 也将其作为默认的网页浏览器。 它是一个精简的浏览器,提供了一个干净和优雅的用户体验。你不能同步你的书签或历史记录,所以如果你想备份或转移到其他浏览器,你需要手动导出它们。 #### 如何安装 GNOME Web? 你可能会发现它预装在一些 Linux 发行版中。如果没有,你可以用它的 [Flatpak 包](https://flathub.org/apps/details/org.gnome.Epiphany) 来在任何 Linux 发行版上安装最新版本。 ### 9、Falkon ![](/data/attachment/album/202112/12/150813qb6cq6w41dj19bka.png) **优点** * 基于 Firefox 的替代品 **缺点** * 不能替代 Firefox * 没有跨平台支持 [Falkon](https://www.falkon.org) 是一个基于 Firefox 的浏览器,考虑到了隐私问题。它对于基本的网页浏览应该是足够好的,但它可能不是你日常使用的解决方案。 你可以在我们专门的 [关于 Falkon 浏览器的文章](https://itsfoss.com/falkon-browser/) 中了解更多关于它的信息并获得安装说明。 ### 10、Nyxt ![](/data/attachment/album/202112/12/150815pyd47cwlvsy8dqsv.png) **优点** * 高度的可定制性 * 重点关注键盘操作 **缺点** * 适用于某些用户 * 缺乏跨平台支持 [Nyxt](https://nyxt.atlas.engineer/) 是一个有趣的网页浏览器,为资深的键盘用户而建立。你可以使用键盘快捷键来浏览和导航网页。 要了解更多关于它的信息和安装说明,请浏览我们关于 [Nyxt 浏览器](https://itsfoss.com/nyxt-browser/) 的详细文章。 ### 总结 说到 Linux,你会有很多选择可供挑选。我在这里特意跳过了 [如 Lynx 这样的基于命令行的网页浏览器](https://itsfoss.com/terminal-web-browsers/)。 那么,你会选择什么样的网页浏览器呢? 此外,我很想知道,你在为你的系统安装网页浏览器时会考虑什么? 欢迎在下面的评论中分享你的想法。 --- via: <https://itsfoss.com/best-browsers-ubuntu-linux/> 作者:[Ankush Das](https://itsfoss.com/author/ankush/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
![Warp Terminal](/assets/images/warp-terminal.webp) ![Warp Terminal](/assets/images/warp-terminal.webp) There is no such thing as the perfect web browser. It all depends on what you prefer and what you use it for. 😎 But, what are your best options regarding web browsers for Linux? In this article, I highlight the best web browsers you can pick for Ubuntu and other Linux. ![Illustration for web browser running in Ubuntu Linux](https://itsfoss.com/content/images/wordpress/2021/09/web-browser-ubuntu.png) Every browser offers something unique. And, when it comes to the Linux platform, there are some interesting exclusive choices as well. *Before you see this list, please note that it is not a ranking list. The browser listed at number 1 should not be considered better than the ones at 2, 3 or 10.* **Some applications mentioned here are not open source. They are listed here because they are available on Linux and the article focuses on Linux. We have a separate** **Non-FOSS Warning!**[dedicated list of open source web browsers](https://itsfoss.com/open-source-browsers-linux/)as well. ## 1. Vivaldi ![vivaldi screenshot](https://itsfoss.com/content/images/wordpress/2021/08/vivaldi-screenshot.png) **Pros** - Sidebar for quick web application access - Calendar and Email integration - Unique tab management - Pomodoro (clock timer) feature - Mobile app available **Cons** - Resource-heavy when using various features - Not 100% open-source Vivaldi is an impressive browser that has been getting more attention from Linux users more than ever. While it is not 100% open-source, you can find most of its source code (except for its UI) online. With newer releases, they have been focusing more on improving the experience for Linux users. You can set clock timers to increase your work productivity, use the built-in translation for web pages, track your calendar, add shortcuts to web applications, and multitask at its peak with this browser. Even though it is a fast web browser, I wouldn’t bet on it as the lightest or the fastest. You need a good amount of memory (RAM) to make use of all the features while you work on stuff. Overall, it is a feature-rich web browser. So, if you require something with as many features as possible to multitask, Vivaldi can be your choice. ### How to Install Vivaldi on Linux? [Vivaldi can be easily installed on Ubuntu](https://itsfoss.com/install-vivaldi-ubuntu-linux/) and Debian thanks to the official .deb file available. There is also .rpm packages available for Fedora, Red Hat and SUSE Linux. You can grab the packages from its [download page](https://vivaldi.com/download/). Refer to our resources to [install Deb files](https://itsfoss.com/install-deb-files-ubuntu/) and [install RPM files](https://itsfoss.com/install-rpm-files-fedora/) in case you are new to Linux. ## 2. Mozilla Firefox ![firefox proton](https://itsfoss.com/content/images/wordpress/2021/08/firefox-proton.png) **Pros** - Privacy protection - Not based on Chrome engine - Open Source - Firefox Account services **Cons** - User Experience changes with major updates Firefox is the default web browser for most Linux distributions. Hence, it is an obvious choice to start with. In addition to being open-source, it offers some of the best privacy protection features. And, with the right settings, you can turn it into one of the most secure browsers similar to Tor Browser (which is also based on Firefox). Not just limited to its security, but Firefox also offers useful integrated features like Pocket (to save web pages and read later), VPN, email alias, breach monitor, and more when you sign in with your Mozilla account. ### How to Install Firefox on Linux? It should already come pre-installed in your Linux distribution. But, if it is not present, you can search for it in the software center or refer to our [installation guide for Firefox](https://itsfoss.com/firefox-quantum-ubuntu/): [How to Install Latest Firefox on Ubuntu LinuxThis step-by-step tutorial shows how to install Firefox on Ubuntu or any other Linux distribution you use.](https://itsfoss.com/firefox-quantum-ubuntu/)![](https://itsfoss.com/content/images/2023/11/install-firefox-in-linux.png) ![](https://itsfoss.com/content/images/2023/11/install-firefox-in-linux.png) ## 3. Chromium ![chromium screenshot](https://itsfoss.com/content/images/wordpress/2021/08/chromium-screenshot.png) **Pros** - Open Source Chrome alternative - Similar features to Google Chrome **Cons** - Lacks certain features that Google Chrome offers Chromium is the open-source alternative and the base for Google Chrome and many other chrome-based browsers. If you would rather not use Google Chrome, Chromium’s your best bet to get the same experience on Linux. Even though Google controls Chromium and [has been locking down Chrome](https://news.itsfoss.com/is-google-locking-down-chrome/), it is a viable option for Linux systems. ### How to Install Chromium on Linux? You should be able to find it easily in the software center. But, if you need help, refer to our [installation guide for Chromium](https://itsfoss.com/install-chromium-ubuntu/). [Install Chromium Browser in Ubuntu Linux [Deb and Snap]Learn to install Chromium browser in Ubuntu, both Snap and Deb version methods have been covered.](https://itsfoss.com/install-chromium-ubuntu/)![](https://itsfoss.com/content/images/2023/10/install-chromium-ubuntu.png) ![](https://itsfoss.com/content/images/2023/10/install-chromium-ubuntu.png) ## 4. Google Chrome ![google chrome screenshot](https://itsfoss.com/content/images/wordpress/2021/08/google-chrome-screenshot.png) **Pros** - Seamless integration with Google services **Cons** - Not open-source Google Chrome is an excellent web browser unless you do not want to opt for a proprietary solution or products by Google. You get all the essential features and the ability to integrate Google services. If you prefer using Google Chrome on Android and want to sync across multiple platforms, it is an obvious choice for desktop Linux. If you were looking for a simple and capable web browser while using Google services, Google Chrome can be a great pick. ### How to Install Google Chrome on Linux? Google Chrome offers both Deb and RPM packages to let you install on any Ubuntu-based or Fedora/openSUSE distribution. If you require help with the installation, I should point you to our guide on [installing Google Chrome on Linux](https://itsfoss.com/install-chrome-ubuntu/). [How to Install Google Chrome on Ubuntu [GUI & Terminal]A step-by-step screenshot guide for beginners that shows how to install Google Chrome on Ubuntu. Learn both the GUI and command line methods.](https://itsfoss.com/install-chrome-ubuntu/)![](https://itsfoss.com/content/images/wordpress/2019/01/install-chrome-ubuntu-linux.jpeg) ![](https://itsfoss.com/content/images/wordpress/2019/01/install-chrome-ubuntu-linux.jpeg) ## 5. Brave Browser ![brave ui new](https://itsfoss.com/content/images/wordpress/2021/07/brave-ui-new.jpg) **Pros** - Privacy protection features - Performance **Cons** - No account-based (cloud) sync Brave browser is one of the most popular Linux browsers. It is an open-source project, which is based on Chromium. It offers several useful privacy protection features and is known for its blazing-fast performance. Unlike any other browser, you can get rewards even if you block advertisements on websites. The rewards you collect can only be used to give back to your favorite websites. This way, you get to block ads and also support the website. You can expect a faster user experience with minimum resource usage. It offers sync capabilities, but you need to have one of the connected devices, considering it lacks a cloud-based sync feature. We also have a detailed [comparison article on Brave vs Firefox](https://itsfoss.com/brave-vs-firefox/), if you need to decide between the two. [Comparing Brave vs. Firefox: Which one Should You Use?The evergreen open-source browser Firefox compared to Brave. What would you pick?](https://itsfoss.com/brave-vs-firefox/)![](https://itsfoss.com/content/images/2023/07/brave-vs-firefox-1.png) ![](https://itsfoss.com/content/images/2023/07/brave-vs-firefox-1.png) ### How to Install Brave on Linux? Unlike some other web browsers, you cannot directly find a package or in the software center. You must enter some commands in the terminal to install the browser. Fret not, you can follow our [instructions to install brave browser](https://itsfoss.com/brave-web-browser/) to proceed. [Installing Brave Browser on Ubuntu & Other Linux DistrosWant to get started using Brave on Linux? This guide will help you with installation, removal and update process of the Brave browser.](https://itsfoss.com/brave-web-browser/)![](https://itsfoss.com/content/images/2023/05/installing-brave-browser-on-linux.png) ![](https://itsfoss.com/content/images/2023/05/installing-brave-browser-on-linux.png) ## 6. Opera ![opera screenshot](https://itsfoss.com/content/images/wordpress/2021/08/opera-screenshot-800x543.png) **Pros** - Free VPN in-built - Extra features **Cons** - Not open source While Opera is not the most popular choice, it is definitely a useful browser for Linux users. It comes with a built-in VPN and ad blocker. So, you should have the basic privacy protection sorted with the help of the Opera web browser. You can quickly access popular chat messengers from the sidebar without launching a separate app or window. This is similar to Vivaldi considering the side chat messenger web apps, but the user experience is significantly different. Overall, it is a good pick if you want a free VPN as an added bonus to other essential browsing features. It is worth noting that Opera offers a unique [Opera GX](https://www.opera.com/gx) browser that lets you tweak/enforce limits on system resources when using a browser along with gaming activities. This was still in development for Linux at the time of writing, if it is available by the time you read it, that could be a fantastic option! ### How to Install Opera? Opera provides Deb package for Ubuntu Linux distributions. You just head to its official website to download and install it. You cannot find it in the software center. ## 7. Microsoft Edge ![microsoft edge on linux](https://itsfoss.com/content/images/wordpress/2021/04/microsoft-edge-on-linux-800x439.png) **Pros** - Convenient option for Windows users who also use Linux **Cons** - Not open-source Microsoft Edge has surpassed Mozilla Firefox in terms of its popularity. Not just because it’s the default Windows browser, but it also offers a promising web experience while based on Chrome. Yes, Microsoft Edge is available for Linux users, if you did not know. Overall, you should find most of the essential features available with it. If you use Windows and Linux as your desktop platforms, Microsoft Edge can come in handy as the preferred web browser. ### How to install Microsoft Edge on Linux? You can find the Deb/RPM file available on its official website. For additional help, take a look at our how-to article on [installing Microsoft Edge on Linux](https://itsfoss.com/microsoft-edge-linux/). [Install Microsoft Edge Browser on Ubuntu and Other LinuxMicrosoft has overhauled its Edge web browser which is now based on the open source Chromium browser. And the stable version is finally available on Linux.](https://itsfoss.com/microsoft-edge-linux/)![](https://itsfoss.com/content/images/wordpress/2019/11/microsoft_edge-browser_linux.jpg) ![](https://itsfoss.com/content/images/wordpress/2019/11/microsoft_edge-browser_linux.jpg) ## Unique Web Browsers for Linux Most users prefer to stick with the mainstream options because of security updates and future upgrades, but there are also some different options. And, some exclusive to Linux users. ## 8. GNOME Web or Epiphany ![gnome web](https://itsfoss.com/content/images/wordpress/2021/08/gnome-web.png) **Pros** - Minimal - Open Source **Cons** - Lacks many features - No cross-platform support Epiphany is the default GNOME browser and like the [GNOME OS](https://itsfoss.com/gnome-os/), not many people are aware of GNOME’s browser. elementary OS utilizes it as its default web browser. It is a minimal browser that offers a clean and elegant user experience. You cannot sync your bookmarks or history, so you need to manually export them if you want to back them up or transfer to another browser. ### How to Install GNOME Web? You may find it pre-installed in some Linux distros. If not, you can install its [Flatpak package](https://flathub.org/apps/details/org.gnome.Epiphany) to get the latest version on any distro. Refer to our [Flatpak guide](https://itsfoss.com/flatpak-guide/) if you are new to it. ## 9. Falkon ![Falkon Browser](https://itsfoss.com/content/images/wordpress/2019/12/falkon-browser-1.png) **Pros** - Uses lightweight QtWebEngine rendering engine **Cons** - Lacks many features Falkon is a QtWebEngine based browser with privacy in mind. It should be good enough for basic web browsing, but it may not be a solution for your daily driver. It is available for Windows and Linux. You can explore more about it and get the installation instructions in our dedicated [article on Falkon browser](https://itsfoss.com/falkon-browser/). ### How to Install Falkon? You can find the package in the default repositories. If not, you can install it using its [Flatparef file](https://www.falkon.org/download/) or the [Snap](https://snapcraft.io/falkon) package. ## 10. Nyxt ![nyxt browser settings](https://itsfoss.com/content/images/wordpress/2021/05/nyxt-browser-settings-800x617.png) **Pros** - Highly customizable - Keyboard use focused **Cons** - Suitable for certain users - Lack of cross-platform support Nyxt is an interesting web browser built for power keyboard users. You can browse and navigate the web using keyboard shortcuts. To know more about it and the installation instructions, go through our detailed article on [Nyxt browser](https://itsfoss.com/nyxt-browser/). ### How to Install Nyxt? It is available in the extra repositories for Arch Linux. For other distros, you can install the [Flatpak package](https://flathub.org/apps/engineer.atlas.Nyxt). ## Wrapping Up When it comes to Linux, you get various choices available to pick. I have deliberately skipped [command line based web browsers like Lynx](https://itsfoss.com/terminal-web-browsers/) here. So, what would be your selection for the best web browser? Moreover, I’d be curious to know what do you look for when installing a web browser for your system? *Feel free to share your thoughts in the comments below.*
14,077
使用 Sonic Pi 像写代码一样编曲
https://opensource.com/article/20/3/sonic-pi
2021-12-13T09:55:48
[ "编曲", "音乐" ]
https://linux.cn/article-14077-1.html
> > 有了这个易于使用的开源程序,不需要掌握乐器,就可以把你变成一个音乐大师。 > > > ![](/data/attachment/album/202112/13/095540zigm4pzopgrdevvz.jpg "Bird singing and music notes") 也许你和我一样,在上学的时候学过一种乐器。对我来说,那是钢琴,后来是中提琴。然而,我一直认为,随着我童年的兴趣转向计算机和编码,我后来忽略了音乐练习。我确实想知道,如果我年轻时有 Sonic Pi 这样的东西,我会怎么样。Sonic Pi 是一个开源程序,可以让你通过代码来创作和演奏音乐。它是这两个世界的完美结合。 我们对 Sonic Pi 并不陌生,早在 2015 年就对其创造者 Sam Aaron 博士 [进行了采访](https://opensource.com/life/15/10/interview-sam-aaron-sonic-pi)。从那时起,Sonic Pi 在很多方面都有了很大的发展。它达到了一个重要的新版本里程碑,期待已久的 v3.2 版本已于 2020 年 2 月 28 日公开发布。一个不断壮大的开发者社区正积极为其 [GitHub 项目](https://github.com/samaaron/sonic-pi/) 做出贡献,而在 [官方论坛](https://in-thread.sonic-pi.net/) 中有一个同样繁荣的作曲家社区可以分享想法和提供支持。该项目现在还通过 [赞助活动](https://www.patreon.com/samaaron) 获得了资金支持,而 Sam 本人也在世界各地的学校、会议和研讨会中传播 Sonic Pi 的信息。 Sonic Pi 真正的闪光点在于它的平易近人。它的版本适用于许多主要的操作系统,包括 Windows、macOS、Linux,当然也包括树莓派本身。事实上,在树莓派上学习使用 Sonic Pi 再简单不过了。它预装在 [Raspbian](https://www.raspberrypi.org/downloads/raspbian/) 中,所以如果你有一个基于 Raspbian 的现有环境,你会发现它位于编程菜单中。 第一次加载 Sonic Pi 时,你会看到一个简单的界面,有两个主要的区域:一个编辑器,可以写你的代码,还有一个区域专用于 Sonic Pi 丰富的教程。对于新手来说,教程是学习基础知识的重要资源,它有配套的音乐程序来巩固所学的每个概念。 如果你跟着学习,让我们为自己编写一段简单的音乐,探索现场编码音乐的潜力。将以下代码输入或粘贴到 Sonic Pi 编辑器中: ``` live_loop :beat do sample :drum_heavy_kick sleep 1 end ``` 即使你是一个 Sonic Pi 的新手,许多程序员可能马上就会明白这里发生了什么。我们正在播放一个<ruby> 踏板鼓 <rt> drum kick </rt></ruby>采样,停止一秒钟,然后重复。点击运行按钮或按 `ALT+R`(macOS 上为 `meta+R`),你应该听到它开始播放。 这不是一首非常激动人心的歌曲,所以让我们用一个在不合拍的<ruby> 小鼓 <rt> snare </rt></ruby>来使它生动起来。用下面的代码块替换现有的代码,然后再次运行。你可以在做这个的时候让现有的节拍继续播放;你会注意到你的改动会自然地应用,与节拍同步: ``` live_loop :beat do sample :drum_heavy_kick sleep 0.5 sample :drum_snare_soft sleep 0.5 end ``` 我们在做这个的时候,让我们在每四拍之前添加一个<ruby> 踩镲 <rt> hi-hat </rt></ruby>,让声音变得有趣一些。在现有的程序块下面添加新的程序块,然后再次运行: ``` live_loop :hihat do sleep 3.9 sample :drum_cymbal_closed sleep 0.1 end ``` 我们现在已经有了我们的节拍,所以让我们来添加一个<ruby> 低音声线 <rt> bassline </rt></ruby>!Sonic Pi 内置了各种合成器,还有混响和失真等效果滤波器。我们将使用 “dsaw” 和 “tech\_saw” 合成器的组合,使其具有电子复古合成器的感觉。将下面的块添加到你现有的程序中,运行,并听一听: ``` live_loop :bass do use_synth :dsaw play :a2, attack: 1, release: 2, amp: 0.3 sleep 2.5 use_synth :tech_saws play :a1, attack: 1, release: 1.5, amp: 0.8 sleep 1.5 end ``` 你会注意到上面的内容,当播放音符时,我们可以完全控制 [ADSR](https://en.wikipedia.org/wiki/Envelope_(music)) <ruby> 包络 <rt> envelope </rt></ruby>,所以我们可以决定每个声音何时达到峰值和衰减。 最后,让我们添加一个<ruby> 主音合成器 <rt> lead synth </rt></ruby>,试试那些被称为“<ruby> 切片器 <rt> slicer </rt></ruby>”的效果特征。为了使事情更有趣,我们还将引入一个伪随机的元素,让 Sonic Pi 从一系列潜在的<ruby> 和弦 <rt> chord </rt></ruby>中挑选。这就是一些有趣的即兴创作和“快乐的意外”可以开始发生的地方。在你现有的程序中加入下面的程序块并运行: ``` live_loop :lead do with_fx :slicer do chords = [(chord :A4, :minor7), (chord :A4, :minor), (chord :D4, :minor7), (chord :F4, :major7)] use_synth :blade play chords.choose, attack: 1, release: 2, amp: 1 sleep 2 end end ``` 很好!现在,我们当然不会很快与 Daft Punk 竞争,但希望通过这个过程,你已经看到我们如何通过添加一些简单的代码,实时地从一个单一节拍变成更大的东西。YouTube 上 Sam Aaron 的 [现场编码表演](https://www.youtube.com/watch?v=JEHpS1aTKp0) 非常值得一看,它展示了 Sonic Pi 可以让你有多大的创造力和适应力。 ![Sonic Pi composition example](/data/attachment/album/202112/13/095550u8ssua4l00c2zli8.png "Sonic Pi composition example") *我们完成的作品,完整版* 如果你曾经想学习一种乐器,但又觉得被“我没有节奏感”或“我的手不够灵活”这样的想法所束缚,Sonic Pi 是一种多功能的乐器,这些都不重要。你所需要的只是想法和灵感,以及一台便宜的电脑,如简陋的树莓派。其余的都在你的指尖上(实际意义上的)。 这里有几个方便的链接可以让你开始: * 官方 Sonic Pi [网站](https://sonic-pi.net/) 和 [教程](https://sonic-pi.net/tutorial.html) * [Sonic Pi 入门](https://projects.raspberrypi.org/en/projects/getting-started-with-sonic-pi) * Sonic Pi 的 [GitHub 项目](https://github.com/samaaron/sonic-pi/) --- via: <https://opensource.com/article/20/3/sonic-pi> 作者:[Matt Bargenquast](https://opensource.com/users/mbargenquast) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Maybe you're like me, and you learned a musical instrument when you were in school. For me, it was the piano, and later, the viola. However, I've always held that, as my childhood interests shifted towards computers and coding, I subsequently neglected my music practice. I do wonder what I would have done if I'd had something like Sonic Pi when I was younger. Sonic Pi is an open source program that lets you compose and perform music through code itself. It's the perfect marriage of those two worlds. Opensource.com is no stranger to Sonic Pi—we [featured an interview](https://opensource.com/life/15/10/interview-sam-aaron-sonic-pi) with the creator, Dr. Sam Aaron, back in 2015. Since that time, a lot has changed, and Sonic Pi has grown substantially in many ways. It's reached a major new version milestone, with the long-awaited v3.2 release made publically available on February 28, 2020. A growing community of developers is actively contributing to its [GitHub project](https://github.com/samaaron/sonic-pi/), while an equally thriving community of composers shares ideas and support in the [official forums](https://in-thread.sonic-pi.net/). The project is now also financially assisted through a [Patreon campaign](https://www.patreon.com/samaaron), and Sam himself has been spreading the word of Sonic Pi through schools, conferences, and workshops worldwide. What really shines about Sonic Pi is its approachability. Releases are available for many major flavors of OS, including Windows, macOS, Linux, and of course, the Raspberry Pi itself. In fact, getting started with Sonic Pi on a Raspberry Pi couldn't be simpler; it comes pre-installed with [Raspbian](https://www.raspberrypi.org/downloads/raspbian/), so if you have an existing Raspbian-based setup, you'll find it situated in the programming menu. Upon loading Sonic Pi for the first time, you'll be greeted with a simple interface with two main areas: an editor in which to write your code, and a section devoted to Sonic Pi's expansive tutorial. For newcomers, the tutorial is an essential resource for learning the basics, featuring accompanying music programs to reinforce each concept being taught. If you're following along, let's code ourselves a simple bit of music and explore the potential of live-coding music. Type or paste the following code into the Sonic Pi editor: ``` live_loop :beat do sample :drum_heavy_kick sleep 1 end ``` Even if you're a Sonic Pi novice, many coders may immediately understand what's going on here. We're playing a drum kick sample, sleeping for a second, and then repeating. Click the Run button or press ALT+R (meta+R on macOS), and you should hear it begin to play. This isn't a very exciting song yet, so let's liven it up with a snare playing on the off-beat. Replace the existing code with the block below and Run again. You can leave the existing beat playing while you do this; you'll notice that your changes will be applied naturally, in time with the beat: ``` live_loop :beat do sample :drum_heavy_kick sleep 0.5 sample :drum_snare_soft sleep 0.5 end ``` While we're at it, let's add a hi-hat right before every fourth beat, just to make things a little interesting. Add this new block below our existing one and Run again: ``` live_loop :hihat do sleep 3.9 sample :drum_cymbal_closed sleep 0.1 end ``` We've got our beat going now, so let's add a bassline! Sonic Pi comes with a variety of synths built-in, along with effects filters such as reverb and distortion. We'll use a combination of the "dsaw" and "tech_saw" synths to give it an electronic retro-synth feel. Add the block below to your existing program, Run, and have a listen: ``` live_loop :bass do use_synth :dsaw play :a2, attack: 1, release: 2, amp: 0.3 sleep 2.5 use_synth :tech_saws play :a1, attack: 1, release: 1.5, amp: 0.8 sleep 1.5 end ``` You'll note above that we have full control over the [ADSR](https://en.wikipedia.org/wiki/Envelope_(music)) envelope when playing notes, so we can decide when each sound should peak and fade. Lastly, let's add a lead synth and try out one of those effects features known as the "slicer." To spice things up, we'll also introduce an element of pseudo-randomness by letting Sonic Pi pick from a series of potential chords. This is where some of the fun improvisation and "happy accidents" can begin to occur. Add the block below to your existing program and Run: ``` live_loop :lead do with_fx :slicer do chords = [(chord :A4, :minor7), (chord :A4, :minor), (chord :D4, :minor7), (chord :F4, :major7)] use_synth :blade play chords.choose, attack: 1, release: 2, amp: 1 sleep 2 end end ``` Great! Now, we're certainly not going to be competing with Daft Punk any time soon, but hopefully, through this process, you've seen how we can go from a bare beat to something much bigger, in real-time, by adding some simple morsels of code. It is well worth watching one of Sam Aaron's [live coding performances](https://www.youtube.com/watch?v=JEHpS1aTKp0) on YouTube for a demonstration of how creative and adaptive Sonic Pi can let you be. ![Sonic Pi composition example Sonic Pi composition example](https://opensource.com/sites/default/files/uploads/sonicpi.png) Our finished piece, in full If you've ever wanted to learn a musical instrument, but felt held back by thoughts like "I don't have rhythm" or "my hands aren't nimble enough," Sonic Pi is a versatile instrument for which none of those things matter. All you need are the ideas, the inspiration, and an inexpensive computer such as the humble Raspberry Pi. The rest is at your fingertips—literally! Here are a few handy links to get you started: - The Official Sonic Pi [website](https://sonic-pi.net/)and[tutorial](https://sonic-pi.net/tutorial.html) [Getting Started with Sonic Pi](https://projects.raspberrypi.org/en/projects/getting-started-with-sonic-pi)([projects.raspberrypi.org](http://projects.raspberrypi.org))- Sonic Pi [Github project](https://github.com/samaaron/sonic-pi/) ## Comments are closed.
14,079
Gaphor:开源的图形化建模工具
https://itsfoss.com/gaphor-modeling-tool/
2021-12-13T23:15:39
[ "UML" ]
https://linux.cn/article-14079-1.html
![](/data/attachment/album/202112/13/231534fobo72taxam7f2ma.jpg) Gaphor 是一个自由开源的建模应用,支持各种建模语言,如 UML、[SysML](https://sysml.org/)、RAAML 和 C4。 不知道“<ruby> 建模语言 <rt> modeling language </rt></ruby>”这个词?基本上,它是一组可以用来创建设计和构造结构的指令。它可以是文字的,也可以是图形的。 图形化的更容易看,也更容易弄清楚项目的各个组成部分是如何相互关联的。 你见过流程图或顺序图吗?那些也是一种最简单形式的图形建模。 ![Sequence diagram example](/data/attachment/album/202112/13/231539gvrlrfy9fl06ilij.png) 有各种建模语言,它们被用于软件开发、系统工程、物理学、项目管理等方面。 ### 用于 UML、SysML 等的 Gaphor [Gaphor](https://gaphor.org/) 使用 UML、SysML 和 RAAML OMG 标准。它还包括对 C4 模型的支持,用于软件架构的可视化。 它不仅仅是一个 [绘图工具](https://itsfoss.com/open-source-paint-apps/)。它实现了一个完全兼容的 UML 2 数据模型。你可以用 Gaphor 创建高度复杂的模型。 ![](/data/attachment/album/202112/13/231540df0uton1nnxbkyaa.jpg) 用 Python 编写的 Gaphor 在 Apache 2 许可证下是完全开源的。你可以在 [其 GitHub 仓库](https://github.com/gaphor) 找到它的所有源代码。它是一个跨平台的工具,可以安装在 Linux、Windows 和 macOS 上。 你可以以 PDF、PNG、SVG 和 XML 格式导出你的图表。你还可以插入一个代码生成器。 Gaphor 网站提到它有深色模式,但我在下载的 AppImage 版本中没有看到任何选项可以启用它。 ### 在 Linux 上安装 Gaphor ![Gaphor user interface](/data/attachment/album/202112/13/231540y3yy0uqmuor5msuy.png) Arch 用户可以在 AUR 中找到 Gaphor。对于其他发行版,你可以选择 [AppImage](https://itsfoss.com/use-appimage-linux/) 和 Flatpak。 你可以从其 [下载页面](https://gaphor.org/download.html#linux) 下载 AppImage。 如果你想使用 Flatpak 版本,请先添加 Flathub 仓库: ``` flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo ``` 然后再安装它: ``` flatpak install --user flathub org.gaphor.Gaphor ``` 由于 Gaphor 本质上是一个 Python 应用,你也可以 [使用 Pip](https://itsfoss.com/install-pip-ubuntu/) 安装它。 ``` pip install gaphor ``` 当我还是一名软件工程师工作时,我使用 UML 和序列图。在过去的几年里,我没有使用它。看看 Gaphor,我认为如果你必须为你的项目创建 UML 和其他图表,它是一个相当不错的应用。 欢迎试一试,并在评论中分享你的经验。 --- via: <https://itsfoss.com/gaphor-modeling-tool/> 作者:[Abhishek Prakash](https://itsfoss.com/author/abhishek/) 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
200
OK
Gaphor is a free and open source modeling application with support for various modeling languages such as UML, [SysML](https://sysml.org/), RAAML and C4. Not aware of the term “modeling language”? Basically, it’s a set of instructions that can be used to create the design and constructions of structures. It could be textual and graphical, both. The graphical one is easier to look at and figure out how various components of the project are related to each other. Have you seen a flowchart or sequence diagrams? Those are also a type of graphical modeling in the simplest form. ![sequence diagram example](https://itsfoss.com/content/images/wordpress/2021/12/sequence-diagram-example-800x364.png) There are various modeling languages and they are used for software development, system engineering, physics, project management and more. ## Gaphor for UML, SysML and more [Gaphor](https://gaphor.org/) works with the UML, SysML, and RAAML OMG standards. It also includes support for the C4 model for visualizing software architectures. It’s not just a [drawing tool](https://itsfoss.com/open-source-paint-apps/). It implements a fully-compliant UML 2 data model. You can create highly complex models with Gaphor. ![gaphor uml screenshot](https://itsfoss.com/content/images/wordpress/2021/12/gaphor-uml-screenshot-800x570.jpg) Written in Python, Gaphor is completely open source under Apache 2 license. You can find all its source code on [its GitHub repository](https://github.com/gaphor). It is a cross-platform tool and available to install on Linux, Windows and macOS. You can export your diagrams in PDF, PNG, SVG and XML formats. You can also plug-in a code generator. Gaphor website mentions that it has dark mode but I didn’t see any options to enable it in the AppImage version I downloaded. ## Installing Gaphor on Linux ![gaphor example](https://itsfoss.com/content/images/wordpress/2021/12/gaphor-example-800x445.png) Arch users can find Gaphor in the AUR. For other distributions, you have the choice of choosing between [AppImage](https://itsfoss.com/use-appimage-linux/) and Flatpak. You can download the AppImage from its download page. If you want to use the Flatpak version, add the Flathub repository first: `flatpak remote-add --user --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo` And then install it: `flatpak install --user flathub org.gaphor.Gaphor` Since Gaphor is essentially a Python application, you can install it [using Pip](https://itsfoss.com/install-pip-ubuntu/) as well. `pip install gaphor` I used UML and sequence diagrams when I worked as a software engineer. I haven’t used it in the last few years. Looking at Gaphor, I think it’s a pretty cool app to have if you have to create UML and other diagrams for your projects. Feel free to give it a try and share your experience in the comments.