當前位置:
首頁 > 知識 > Fedora 中的 Toolbox 簡介

Fedora 中的 Toolbox 簡介

Fedora 中的 Toolbox 簡介


Toolbox 使你可以在容器中分類和管理開發環境,而無需 root 許可權或手動添加卷。-- Ryan Walter(作者)

Toolbox 使你可以 在容器中分類和管理開發環境 ,而無需 root 許可權或手動添加卷。它創建一個容器,你可以在其中安裝自己的命令行工具,而無需在基礎系統中安裝它們。當你沒有 root 許可權或無法直接安裝程序時,也可以使用它。本文會介紹 Toolbox 及其功能。

安裝 Toolbox

Silverblue 默認包含 Toolbox。對於 Workstation 和 Server 版本,你可以使用 dnf install toolbox 從默認倉庫中獲取它。


創建 Toolbox

打開終端並運行 toolbox enter。程序將自動請求許可來下載最新的鏡像,創建第一個容器並將你的 shell 放在該容器中。

$ toolbox enter
No toolbox containers found. Create now? [y/N] y
Image required to create toolbox container.
Download registry.fedoraproject.org/f30/fedora-toolbox:30 (500MB)? [y/N]: y

當前,Toolbox 和你的基本系統之間沒有區別。你的文件系統和軟體包未曾改變。下面是一個使用倉庫的示例,它包含 ~/src/resume 文件夾下的簡歷的文檔源文件。簡歷是使用 pandoc 工具構建的。

$ pwd
/home/rwaltr
$ cd src/resume/
$ head -n 5 Makefile
all: pdf html rtf text docx

pdf: init
pandoc -s -o BUILDS/resume.pdf markdown/*

$ make pdf
bash: make: command not found
$ pandoc -v
bash: pandoc: command not found

這個 toolbox 沒有構建簡歷所需的程序。你可以通過使用 dnf 安裝工具來解決此問題。由於正在容器中運行,因此不會提示你輸入 root 密碼。

$ sudo dnf groupinstall "Authoring and Publishing" -y && sudo dnf install pandoc make -y
...
$ make all #Successful builds
mkdir -p BUILDS
pandoc -s -o BUILDS/resume.pdf markdown/*
pandoc -s -o BUILDS/resume.html markdown/*
pandoc -s -o BUILDS/resume.rtf markdown/*
pandoc -s -o BUILDS/resume.txt markdown/*
pandoc -s -o BUILDS/resume.docx markdown/*
$ ls BUILDS/
resume.docx resume.html resume.pdf resume.rtf resume.txt

運行 exit 可以退出 toolbox。

$ cd BUILDS/
$ pandoc --version || ls
pandoc 2.2.1
Compiled with pandoc-types 1.17.5.4, texmath 0.11.1.2, skylighting 0.7.5
...
for a particular purpose.
resume.docx resume.html resume.pdf resume.rtf resume.txt
$ exit
logout
$ pandoc --version || ls
bash: pandoc: command not found...
resume.docx resume.html resume.pdf resume.rtf resume.txt

你會在主目錄中得到由 toolbox 創建的文件。而在 toolbox 中安裝的程序無法在外部訪問。


提示和技巧

本介紹僅涉及 toolbox 的表面。還有一些其他提示,但是你也可以查看 官方文檔 。

  • toolbox –help 會顯示 Toolbox 的手冊頁。
  • 你可以一次有多個 toolbox。使用 toolbox create -c Toolboxname 和 toolbox enter -c Toolboxname。
  • Toolbox 使用 Podman 來完成繁重的工作。使用 toolbox list 可以查找 Toolbox 創建的容器的 ID。Podman 可以使用這些 ID 來執行 rm 和 stop 之類的操作。 (你也可以在 此文章 中閱讀有關 Podman 的更多信息。)

via: https://fedoramagazine.org/a-quick-introduction-to-toolbox-on-fedora/

作者: Ryan Walter 選題: lujun9972 譯者: geekpi 校對: wxy

本文由 LCTT 原創編譯, Linux中國 榮譽推出

點擊「了解更多」可訪問文內鏈接

喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!


請您繼續閱讀更多來自 Linux技術 的精彩文章:

5 個用於在 Linux 終端中查找域名 IP 地址的命令