使用 KDE 的 Ark 在 Linux 桌面上归档文件
归档 压缩

> 
> 在 KDE 上创建、检查和扩展压缩的档案。
> 
> 
> 


![](/data/attachment/album/202204/10/110019yfqsy4hel2jqhs8h.jpg "Hand putting a Linux file folder into a drawer")


当我完成一个项目时，我经常喜欢把为这个项目创建的所有文件放到一个档案中。这不仅可以 [节省空间](https://opensource.com/article/21/11/linux-commands-convert-files)，而且可以让这些文件远离我的视线，防止它们在我使用 [find](https://opensource.com/article/21/9/linux-find-command) 和 [grep](https://opensource.com/article/21/3/grep-cheat-sheet) 搜索我当前想要的文件时作为结果出现。一旦文件被归档，它们就会被你的文件系统视为一个单独的对象，这意味着你不能像浏览普通文件夹那样来浏览它们。你可以把它们解压缩来列出档案的内容，或者打开一个终端，运行适当的归档命令，比如 [tar](https://opensource.com/article/17/7/how-unzip-targz-file) 命令。又或者你可以使用一个像 Ark 这样的应用程序来列出、预览、修改和管理你的档案。


### 在 Linux 上安装 Ark


KDE Plasma 桌面预装了 Ark，你也可以从软件包管理器中获取。在 Fedora、Mageia 和类似的系统中，你可以运行：



```
$ sudo dnf install ark

```

在 Debian、Elementary 和类似的系统中，你可以运行：



```
$ sudo apt install ark

```

你也可以从 [Flathub](https://flathub.org/apps/details/org.kde.ark) 上 [获取并安装它的 Flatpak 包](https://opensource.com/article/21/11/install-flatpak-linux)。


### 创建一个档案


熟悉归档的最好方法就是自己创建一个档案，然后探索它。所有的这些都可以通过 Ark 来完成。


首先，从你的应用程序菜单中启动 Ark，然后进入“<ruby> 档案 <rt>  Archive </rt></ruby>”菜单，选择“<ruby> 新建 <rt>  New </rt></ruby>”。


![用 Ark 创建一个新的档案](/data/attachment/album/202204/10/110030bnqqlkaaanlziall.jpg "Creating a new archive in Ark")


（图源 Seth Kenlon / [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)）


给你的档案设置一个文件名，使用默认的压缩设置，并将档案保存到你的主目录。


Ark 不会自动创建空的档案，但在你设置好名称和位置后，只要你向其中添加文件，Ark 就会立即创建一个档案。


要向即将建立的档案中添加文件，只需将该文件拖入 Ark 窗口即可。


![档案中的内容](/data/attachment/album/202204/10/110030xfedf9hnxkfe9yhe.jpg "Items in an archive")


（图源 Seth Kenlon / [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)）


归档有两个好处：合并和压缩。通过把文件添加到档案里，你将许多文件整合到了同一个地方。因为它们已经存在于档案中，所以，如果你想要摆脱这些文件的干扰，你完全以把原始的副本删除掉。


要查看你通过压缩文件节省了多少磁盘空间，你可以进入“<ruby> 档案 <rt>  Archive </rt></ruby>”菜单，选择“<ruby> 属性 <rt>  Properties </rt></ruby>”。它会显示出文件在归档前/后的大小，同时还有很多其他有用的元数据。


![档案的属性和元数据](/data/attachment/album/202204/10/110031r88zum6lialz7aqm.jpg "Archive properties and metadata")


（图源 Seth Kenlon / [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)）


Ark 可以做的事情还有很多，但是现在先关闭 Ark，假装你已经使用完毕。你的档案会存放在你声明保存它的位置（在这个例子中，它的名字是 `example.tar.gz`，位于我的用户主目录中。）


### 查看档案中的文件


Ark 可以打开任何档案，就像打开一个普通的文件夹一样。要在 Ark 中打开一个档案，只需在文件管理器中左键点击它（单击/双击，取决于你的系统设置）。你也可以右键点击它，并选择“<ruby> 用 Ark 打开 <rt>  Open with Ark </rt></ruby>”。


一旦档案在 Ark 中打开，你就可以在文件管理器中进行大部分操作，包括删除文件、添加新文件、预览文件内容等等。


### 从档案中删除文件


有时候，你会把一个文件放到一个你不需要的档案中。此时，当你想从档案中删除一个文件时，你可以右键单击该文件并选择“<ruby> 删除 <rt>  Delete </rt></ruby>”。


![右键菜单](/data/attachment/album/202204/10/110031uxhn9hhlsnlxhnnh.jpg "Right-click menu")


（图源 Seth Kenlon / [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)）


### 向档案中添加文件


向档案中添加文件是更加容易的。你只需从文件管理器中把该文件拖拽到 Ark 里。另外，你也可以选择 Ark 右键菜单中“<ruby> 添加文件 <rt>  Add Files </rt></ruby>”。


### 从档案中提取单个文件


当处理一个档案时，许多人会选择解开整个档案，然后寻找他们真正需要的一两个文件。对于小型档案，这勉强说得过去，但对于大型档案来说，这会占用你大量的时间和磁盘空间，哪怕只是暂时的。


有了 Ark，你可以只提取你需要的文件，只要把它们从 Ark 窗口拖到你要保存的地方就行。另外，你也可以选择右键菜单中的“<ruby> 提取 <rt>  Extract </rt></ruby>”。


### 预览档案中的文件


事实上，你并不总是需要提取文件。如果你只是需要快速查看一个文件，Ark 或许可以向你展示一个文件的预览，而不需要将其解压到你的硬盘上。


要预览一个文件，在 Ark 中双击它即可。


![在 Ark 中预览一个文件](/data/attachment/album/202204/10/110032iza1ep55e0iqbzjq.jpg "Previewing a file in Ark")


（图源 Seth Kenlon / [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)）


### 开始归档吧


在 Linux 桌面上管理档案是非常简单和直观的。Ark 是一个很好的归档工具，许多其他的 Linux 桌面也有类似的工具。因此，即使你不使用 Ark，其他类似的工具也能帮助到你。对我来说，归档很大程度上让我保持了文件的有条不紊、节约了磁盘空间。Ark 的存在使得我们可以很方便地和档案打交道。




---


via: <https://opensource.com/article/22/2/archives-files-linux-ark-kde>


作者：[Seth Kenlon](https://opensource.com/users/seth) 选题：[lujun9972](https://github.com/lujun9972) 译者：[lkxed](https://github.com/lkxed) 校对：[wxy](https://github.com/wxy)


本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译，[Linux中国](https://linux.cn/) 荣誉推出


OK
When I finish with a project, I often like to take all the files I've created for the project and put them into an archive. It not only [saves space](https://opensource.com/article/21/11/linux-commands-convert-files), but it gets those files out of my way, and prevents them from turning up as results when I use [find](https://opensource.com/article/21/9/linux-find-command) and [grep](https://opensource.com/article/21/3/grep-cheat-sheet) to search through files I consider current. Once files are in an archive, they're treated as a single object by your filesystem, which means that you can't browse them the way you can a normal folder. You could unarchive them, or you could open a terminal and run the appropriate archive command, such as [tar](https://opensource.com/article/17/7/how-unzip-targz-file), to list the contents of the archive. Or you can use an application like Ark to list, preview, modify, and manage your archives.

## Install Ark on Linux

If you're running the KDE Plasma Desktop, you already have Ark installed, but if not then it's available from your package manager. On Fedora, Mageia, and similar:

`$ sudo dnf install ark`


On Debian, Elementary, and similar:

`$ sudo apt install ark`


You can [install it as a Flatpak](https://opensource.com/article/21/11/install-flatpak-linux) from [Flathub](https://flathub.org/apps/details/org.kde.ark), too.

## Create an archive

The best way to get comfortable with archives is to create one for yourself, and then explore it. All of this can be done with just Ark.

First, launch Ark from your application menu, and then go to the **Archive** menu and select **New**.

![Creating a new archive in Ark Creating a new archive with Ark](https://opensource.com/sites/default/files/ark-new.jpg)

(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))

Give your archive a filename, accept the default compression settings, and save it to your home directory.

Ark won't create an empty archive, but after you've set a name and location, Ark is poised to create an archive as soon as you add a file to it.

To add a file to your soon-to-be archive, just drag and drop a file into the Ark window.

![Items in an archive Items in an archive](https://opensource.com/sites/default/files/ark-items.jpg)

(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))

There are two benefits to archiving: consolidation and compression. By adding files to the archive, you've consolidated files into one place. They exist in the archive now, so you can throw the original copies in the trash if it's part of your goal to get files out of the way.

To see how much disk space you've saved by compressing your files, go to the **Archive** menu and select **Properties**. This shows you the size of the unpacked archive as well as the size of the packed archive, and a lot of other useful metadata.

![Archive properties and metadata Archive properties and metadata](https://opensource.com/sites/default/files/ark-properties.jpg)

(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))

There's a lot more that Ark can do, but for now close Ark as if you were finished. Your achive now exists in the location where you saved it (in this example, it's **example.tar.gz** in my home folder.)

## Viewing files in an archive

Any archive can be opened in Ark, just as if it were a normal folder. To open an archive in Ark, just click on it in your file manager, or right-click on it and select **Open with Ark**.

Once the archive is open in Ark, you can perform most actions you could do from a file manager, including removing files, adding new files, previewing the contents of a file, and more.

## Removing a file from an archive

Sometimes you put a file into an archive you don't need. When you want to remove a file from an archive, right-click on the file and select **Delete**.

![Right-click menu Right-click menu](https://opensource.com/sites/default/files/ark-menu-click-right.jpg)

(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))


## Adding files to an archive

Adding a file to an archive is even easier. You can just drag and drop a file from your file manager into Ark. Alternately, you can select **Add Files** from the right-click menu in Ark.

## Extracting just one file from an archive

When faced with an archive, many people just unarchive the entire thing and then fish for the one or two files they actually need. For small archives, that's fine, but for big archives that takes time and disk space, even if only temporarily.

With Ark, you can extract only the files you need by dragging them from the Ark window to the destination you want to save them to. Alternately, select **Extract **from the right-click menu.

## Previewing files in an archive

You don't always need to extract a file. If you just need to refer to a file quickly, Ark may be able to show you a preview of the file without extracting it to your drive.

To preview a file, double-click on it in Ark.

![Previewing a file in Ark Previewing a file in Ark](https://opensource.com/sites/default/files/ark-preview.jpg)

(Seth Kenlon, [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/))

## Archive it

Managing archives on a Linux desktop is easy and intuitive. Ark is a great archive tool, and many other Linux desktops have similar tools, so even if you're not using Ark you might find something similar to it equally as useful. For me, archiving has been an important part of keeping my files organized, and conserving disk space. As for Ark, it makes interacting with those archives convenient.

## 2 Comments