Merge branch 'master' of https://github.com/LCTT/TranslateProject into translating

This commit is contained in:
geekpi 2022-07-15 08:42:15 +08:00
commit 603794f089
16 changed files with 1864 additions and 1277 deletions

View File

@ -3,135 +3,106 @@
[#]: author: "Tomasz Waraksa https://opensource.com/users/tomasz"
[#]: collector: "lujun9972"
[#]: translator: "mcfd"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-14826-1.html"
从 Linux 终端发送桌面通知与提醒
如何从 Linux 终端发送桌面通知与提醒
======
本 Linux 教程演示如何使用脚本命令来发送
自己的桌面通知与提醒。
![Person using a laptop][1]
> 这篇教程演示如何使用脚本命令来发送自己的桌面通知与提醒。
![](https://img.linux.net.cn/data/attachment/album/202207/14/145103vawkhy6w506thy6h.jpg)
有时候,来自脚本的视觉回馈是很有用的。例如,当一个脚本或计划任务完成时,一个长期运行的构建任务失败时,或者当脚本执行中出现了紧急问题时。桌面应用程序可以通过弹出通知来做到这一点,但脚本也可以做到这一点!你可以使用脚本命令来给自己发送桌面通知与提醒。
![Example notification][2]
(Tomasz Waraksa, CC BY-SA 4.0)
下面的代码是在 Linux 上编写和测试的。它也可以在 macOS 上运行,只需花点功夫。请参见最后一节 [提示与技巧][3]。
### 从 Linux 终端发送通知
要从 Linux 终端发送通知,请使用 [`notify-send`][4] 命令。运行 `which ``notify-send`  命令来查看它是否在于你的系统中。如果没有,请使用包管理器来安装它。
要从 Linux 终端发送通知,请使用 [notify-send][4] 命令。运行 `which notify-send` 命令来查看它是否在于你的系统中。如果没有,请使用包管理器来安装它。
在 Fedora 上,输入:
```
`$ sudo dnf install notify-send`
$ sudo dnf install notify-send
```
在基于 Debian 的发行版上,输入:
```
`$ sudo apt install notify-send`
$ sudo apt install notify-send
```
几个简单的通知示例:
```
$ notify-send "Dinner ready!"
$ notify-send "Tip of the Day" "How about a nap?"
```
你可以用紧急程度、自定义图标等选项来自定义通知。过 `man notify-send` 了解更多。你也可以在通知正文中使用一小组 HTML 标记以使消息有一个棒的视觉感受。最重要的是URL 被呈现为可点击的。例如:
```
$ notify-send -u critical \
  "Build failed!" \
  "There were &lt;b&gt;123&lt;/b&gt; errors. Click here to see the results: <http://buildserver/latest>"
"Build failed!" \
"There were <b>123</b> errors. Click here to see the results: http://buildserver/latest"
```
![Build fail notification][5]
(Tomasz Waraksa, CC BY-SA 4.0)
发送的通知会被桌面环境接收,并像其他通知一样显示。它们将具有相同的外观、交互和行为。
### 将 notify-send 与 at 结合使用
计划任务通常被用来定期安排命令。`at` 命令安排在一个指定的时间执行一条命令。 如果你像这样运行它,它会以交互模式启动,你可以在其中输入要在指定时间执行的命令:
计划任务通常被用来定期安排命令。`at` 命令安排在一个指定的时间执行一条命令。如果你像这样运行它,它会以交互模式启动,你可以在其中输入要在指定时间执行的命令:
```
`$ at 12:00`
$ at 12:00
```
这对脚本来说并不有用。幸运的是, `at` 接受来自标准输入的参数,所以我们可以这样使用它:
这对脚本来说并不有用。幸运的是 `at` 接受来自标准输入的参数,所以我们可以这样使用它:
```
$ echo "npm run build" | at now + 1 minute
$ echo "backup-db" | at 13:00
```
有许多指定时间的方法。 从绝对时间,如 `10:00`,到相对时间,如 `now + 2 hours` ,再特殊时间,如`noon` 或 `midnight`。我们可以把它和 `notify-send` 结合起来,在未来的某个时间向自己发送提醒。例如:
```
`$ echo "notify-send 'Stop it and go home now?' 'Enough work for today.' -u critical" | at now`
$ echo "notify-send 'Stop it and go home now?' 'Enough work for today.' -u critical" | at now
```
![Stop for the day notification][6]
(Tomasz Waraksa, CC BY-SA 4.0)
### 提醒的命令
现在,建立一个自定义的 Bash 命令来给自己发送提醒信息。像这样简单且人性化的命令:
```
$ remind "I'm still here" now
$ remind "Time to wake up!" in 5 minutes
$ remind "Dinner" in 1 hour
$ remind "Take a break" at noon
$ remind "It's Friday pints time!" at 17:00
```
这比 Alexa 更好!该怎样做?
请看下面的代码。它定义了一个名为 **remind** 的函数,它支持上述语法。实际工作是在最后两行完成的。其余的部分负责显示帮助信息、参数校验等,这与任何大型应用程序中有用的代码与必要的白噪声的比例大致相同。
请看下面的代码。它定义了一个名为 `remind` 的函数,它支持上述语法。实际工作是在最后两行完成的。其余的部分负责显示帮助信息、参数校验等,这与任何大型应用程序中有用的代码与必要的白噪声的比例大致相同。
把代码保存在某个地方,例如,在 `~/bin/remind` 文件中,并在你的 `.bashrc` 配置文件写入该函数,以便在你登录时加载它:
```
`$ source ~/bin/remind`
$ source ~/bin/remind
```
重新打开终端,然后输入 remind 来查看语法。尽情享受吧!
重新打开终端,然后输入 `remind` 来查看语法。尽情享受吧!
```
#!/usr/bin/env bash
function remind () {
  local COUNT="$#"
@ -201,7 +172,9 @@ function remind () {
* * *
_本文经作者许可改编自原文详情见[此处][7]。_
(文内图片来自 Tomasz Waraksa, CC BY-SA 4.0
本文经作者许可改编自 [原文][7]。
--------------------------------------------------------------------------------
@ -210,7 +183,7 @@ via: https://opensource.com/article/22/1/linux-desktop-notifications
作者:[Tomasz Waraksa][a]
选题:[lujun9972][b]
译者:[mcfd](https://github.com/mcfd)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -3,29 +3,32 @@
[#]: author: "Ankush Das https://itsfoss.com/author/ankush/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-14827-1.html"
massCode一个免费和开源的代码片段管理器
massCode一个自由开源的代码片段管理器
======
简介:一个开源的代码片段管理器,使你能够涉足代码,提高生产力,并节省时间。
![](https://img.linux.net.cn/data/attachment/album/202207/14/151504ti9twf2u5kft2wh2.jpg)
> massCode 是一个开源的代码片段管理器,使你能够涉足代码,提高生产力,并节省时间。
如果一个工具能让事情变得更快、更有效率,那对许多开发者来说就是救命稻草。
虽然有不同的服务和平台试图使编码体验更快,但你仍然有其他几个选择可以考虑。
虽然有各种服务和平台试图使编码体验更快,但你仍然有其他几个选择可以考虑。
例如,一个代码片段管理器。使用代码片段管理器,你的目的是保存你想快速访问的代码部分。它更像是指定快捷方式,在你的程序中添加所需的代码。
例如,代码片段管理器。使用代码片段管理器,你的目的是保存你想快速访问的代码片段。它更像是指定快捷方式,在你的程序中添加所需的代码。
这不是一个新的概念,但可用于这项工作的工具可能不完全是开源的。
幸运的是,我偶然发现了一个不错的项目,它为你提供了一个免费的、开源的片段管理器,即 massCode。
幸运的是,我偶然发现了一个不错的项目,它为你提供了一个自由开源的片段管理器,即 massCode。
### massCode跨平台的开源片段管理器
![masscode][1]
massCode 是一个有用的片段管理器,具有一些基本功能。
massCode 是一个有用的代码片段管理器,具有一些基本功能。
它支持广泛的编程语言,还包括对 Markdown 的支持。你可以使用文件夹组织你的代码片段,添加标签等。
@ -37,30 +40,30 @@ massCode 可用于 Linux、Windows 或 macOS。让我们来看看一些主要功
massCode 包括许多有用的功能。其中一些是:
* 多层次的文件夹组织者
* 多层次的文件夹结构
* 每个片段都可以存储在片段(标签)中
* 集成编码编辑器,即 [Ace][3]
* 代码格式化或高亮显示
* 支持带预览的 Markdown
* 能够搜索一个片段
* 给你的代码段添加描述,以了解它的用途
* 各种深色/浅色主题可用
* 能够从 [SnippetsLab][4] 迁移
* 自动保存以帮助你保留你的工作
* 将其与云同步文件夹整合
* 对 VSCode、Raycast 和 Alfred 的扩展支持。
* 集成编码编辑器 [Ace][3]
* 代码格式化或高亮显示
* 支持带预览的 Markdown
* 能够搜索片段
* 给你的代码段添加描述,以了解它的用途
* 各种深色/浅色主题可用
* 能够从 [SnippetsLab][4] 迁移
* 自动保存以帮助你保留你的工作
* 将其与云同步文件夹整合
* 支持 VSCode、Raycast 和 Alfred 的扩展
除了上述所有功能外,你还可以轻松地复制保存代码片段,只需点击一下。
对于自定义,你可以调整字体大小和系列、切换自动换行、高亮显示行、使用单引号或添加尾随命令,这要归功于 [Prettier][5]。
此外,一份片段可以有多个片 因此,它使你有机会将其用于各种用例。
此外,一份片段可以有多个片。因此,它使你有机会将其用于各种用例。
如前所述,你也可以通过改变同步文件夹的存储位置将其与你的任何云同步服务整合。
![masscode migrate preferences][6]
总的来说,它工作得很好,有一些局限性,比如将嵌套文件夹从 SnippetsLab 迁移到 masCode 的能力。
总的来说,它工作得很好,有一些局限性,比如缺乏将嵌套文件夹从 SnippetsLab 迁移到 masCode 的能力。
### 在 Linux 上安装 massCode
@ -70,13 +73,13 @@ massCode 有 [Snap 包][7],但不在 Snap 商店中。你可以直接下载该
sudo snap install --dangerous ~/Downloads/masscode_2.6.1_amd64.snap
```
我们的一份故障排除指南可以帮助你了解更多关于 [dangerous snap 选项][8]。
我们的一份故障排除指南可以帮助你了解 [snap 的 dangerous 选项][8]。
你可以通过其[官方网站][9]或 [GitHub 发布区][10]下载 Windows/MacOS 版。
你可以通过其 [官方网站][9] 或 [GitHub 发布区][10] 下载 Windows/MacOS 版。
[massCode][11]
> **[massCode][11]**
你试过 massCode 吗?还有其他可用于 Linux 的代码片段管理器吗?请在下面的评论中告诉我你的想法。
你试过 massCode 吗?还有其他可用于 Linux 的代码片段管理器吗?请在下面的评论中告诉我你的想法。
--------------------------------------------------------------------------------
@ -85,7 +88,7 @@ via: https://itsfoss.com/masscode/
作者:[Ankush Das][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -3,31 +3,32 @@
[#]: author: "Don Watkins https://opensource.com/users/don-watkins"
[#]: collector: "lkxed"
[#]: translator: "MjSeven"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-14823-1.html"
检查 Linux 磁盘使用情况
======
du 和 ncdu 两个命令提供了相同信息的两种不同视图,便于我们跟踪存储在计算机上的内容。
![Data stack in blue][1]
> du 和 ncdu 两个命令提供了相同信息的两种不同视图,便于我们跟踪存储在计算机上的内容。
![](https://img.linux.net.cn/data/attachment/album/202207/13/111729faleyal2gmappykc.jpg)
无论你有多少存储空间,了解文件占用了多少磁盘空间都是一个重要的考虑事项。我的笔记本有一个相对较小的 250GB NVME 驱动器,大多数时候都没什么问题,但几年前我开始探索 Linux 上的游戏,情况变得有所不同,安装 Steam 和其他游戏使存储管理更加重要。
### du 命令
检查磁盘驱动器上剩余存储空间最简单的方法是 [du 命令][2]。它会估计文件空间使用情况,像其他所有 Linux 工具一样,`du` 非常强大,但知道如何根据你的特定需求使用它会很有帮助。我总是查阅 man 页面来获取实用程序。du 有几个选项,可以为你提供文件存储的最佳快照,以及它们在系统上消耗多少空间。
检查磁盘驱动器上剩余存储空间最简单的方法是 [du 命令][2]。它会估计文件空间使用情况,像其他所有 Linux 工具一样,`du` 非常强大,但学会如何根据你的特定需求使用它会很有帮助。我总是查阅手册页来掌握实用程序的用法。`du` 有几个选项,可以为你提供文件存储的最佳快照,以及它们在系统上消耗多少空间。
`du` 命令有很多选项,以下是一些常见的:
* -a - 包括文件夹和文件在内的存储信息
* --apparent-size - 打印自身大小而不是占用磁盘量
* -h - 人类可读的格式
* -b - 字节
* -c -总计
* -k - 块大小
* -m - 以兆字节为单位的大小
* `-a` - 包括文件夹和文件在内的存储信息
* `--apparent-size` - 打印自身大小而不是占用磁盘量
* `-h` - 人类可读的格式
* `-b` - 字节为单位
* `-c` - 总计
* `-k` - 以块为单位
* `-m` - 以兆字节为单位的大小
务必查看 `du` 手册页获取完整帮助列表。
@ -41,15 +42,15 @@ du 和 ncdu 两个命令提供了相同信息的两种不同视图,便于我
$ du -a ~/Downloads
4923    ./UNIX_Driver_5-0/UNIX Driver 50
4923    ./UNIX_Driver_5-0
20     ./epel-release-latest-9.noarch.rpm
12    ./rpmfusion-free-release-9.noarch.rpm
20     ./epel-release-latest-9.noarch.rpm
12     ./rpmfusion-free-release-9.noarch.rpm
2256    ./PZO9297 000 Cover.pdf
8    ./pc.md
8     ./pc.md
2644    ./geckodriver-v0.31.0-linux64.tar.gz
466468
```
最左边的数字是以字节为单位的文件大小。我想要一些对我更有帮助的东西,所以我将人类可读格式的选项添加到命令中,结果是 4.8G(千兆字节),这对我来说是一种更有用的数字格式。(to 校正:这个 4.8G 不知道从何而来)
最左边的数字是以字节为单位的文件大小。我想要一些对我更有帮助的东西,所以我将人类可读格式的选项添加到命令中,结果是 456M兆字节),这对我来说是一种更有用的数字格式。
```
$ du -ah ~/Downloads
@ -65,21 +66,15 @@ $ du -ah ~/Downloads
与大多数 Linux 命令一样,你可以组合选项,要以人类可读的格式查看 `Downloads` 目录,使用 `du -ah ~/Downloads` 命令。
**[[ 另请阅读:检查可用磁盘空间的 5 个 Linux 命令 ]][3]**
#### 总和
`-c` 选项在最后一行提供了磁盘使用总和。我可以使用 `du -ch /home/don` 来显示主目录中的每个文件和目录。这里有很多信息,我只想知道最后一行的信息,所以我将磁盘使用命令通过管道传输给 `tail`。命令是 `du -ch /home/don | tail`to 校正:这条命令似乎没卵用,在 Ubuntu 试验过
`-c` 选项在最后一行提供了磁盘使用总和。我可以使用 `du -ch /home/don` 来显示主目录中的每个文件和目录。这里有很多信息,我只想知道最后一行的信息,所以我将 `du` 命令通过管道传输给 `tail` 来显示最后几行。命令是 `du -ch /home/don | tail`LCTT 校注:可以使用 `tail -1` 来仅显示最后一行汇总行。
![将 du 命令输出通过管道传输到 tail][4]
Image by:
(Don Watkins, CC BY-SA 4.0)
### ncdu 命令
对存储在驱动器上内容感兴趣的 Linux 用户,另一个选择是 [ncdu 命令][5],它代表 *NCurses 磁盘使用情况*。基于你的 Linux 发行版,你可能需要下载并安装它。
对存储在驱动器上内容感兴趣的 Linux 用户,另一个选择是 [ncdu 命令][5],它代表 “NCurses 磁盘使用情况”。基于你的 Linux 发行版,你可能需要下载并安装它。
在 Linux Mint、Elementary、Pop_OS! 或其它基于 Debian 的发行版上:
@ -99,37 +94,27 @@ $ sudo dnf install ncdu
$ sudo pacman -S ncdu
```
安装后,你可以使用 ncdu 来分析你的文件系统。以下是在我的主目录中发出 `ncdu` 后的示例输出。`ncdu` 的 man 页面指出“ncduNCurses Disk Usage是众所周知的 `du` 基于 curses 的版本,它提供了一种快速查看哪些目录正在使用磁盘空间的方法。”
安装后,你可以使用 `ncdu` 来分析你的文件系统。以下是在我的主目录中发出 `ncdu` 后的示例输出。`ncdu` 的手册页指出 “ncduNCurses Disk Usage是众所周知的 `du` 基于 curses 的版本,它提供了一种快速查看哪些目录正在使用磁盘空间的方法。”
![du 命令输出][6]
Image by:
(Don Watkins, CC BY-SA 4.0)
我可以使用方向键上下导航,按下 **Enter** 键进入目录。有趣的是,`du` 报告我的主目录中的总磁盘使用量为 12GB`ncdu` 显示为 11GB。你可以在 `ncdu` 手册页中找到更多信息。
我可以使用方向键上下导航,按下回车键进入目录。有趣的是,`du` 报告我的主目录中的总磁盘使用量为 12GB`ncdu` 显示为 11GB。你可以在 `ncdu` 手册页中找到更多信息。
你可以将 `ncdu` 指向某个目录来探索特定目录。例如,`ncdu /home/don/Downloads`。
![ncdu 命令输出][7]
Image by:
(Don Watkins, CC BY-SA 4.0)
**?** 键显示帮助菜单。
`?` 键显示帮助菜单。
![ncdu 帮助][8]
Image by:
(Don Watkins, CC BY-SA 4.0)
### 总结
`du``ncdu` 两个命令提供了相同信息的两种不同视图,便于我们跟踪存储在计算机上的内容。
如果你不习惯使用终端,或者只是在寻找此类信息的另一种试图,查看 [GNOME 磁盘使用分析器][9]。如果你的系统上还没有它,你可以轻松安装和使用它。检查你的发行版是否有 `baobab`,如果你想进行尝试,去安装它。
如果你不习惯使用终端,或者想寻找此类信息的另一种查看方式,可以看看 [GNOME 磁盘使用分析器][9]。如果你的系统上还没有它,你可以轻松安装和使用它。检查你的发行版是否有 baobab 开发的这个软件,如果你想试试,那就去安装它吧。
(文内图片来自于 Don Watkins, CC BY-SA 4.0
--------------------------------------------------------------------------------
@ -138,7 +123,7 @@ via: https://opensource.com/article/22/7/check-disk-usage-linux
作者:[Don Watkins][a]
选题:[lkxed][b]
译者:[MjSeven](https://github.com/MjSeven)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -3,17 +3,18 @@
[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/"
[#]: collector: "lkxed"
[#]: translator: "lkxed"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-14822-1.html"
怀念 Firefox Send 吗?不妨试试 Internxt Send 吧
======
Internxt 发布了一个新产品,它可以让你快速地将加密文件发送给任何人,同时保持你的隐私。嗯,我们只能希望它不会像 Firefox Send 那样关闭吧……
> Internxt 发布了一个新产品,它可以让你快速地将加密文件发送给任何人,同时保持你的隐私。嗯,我们只能希望它不会像 Firefox Send 那样关闭吧……
![Internxt][1]
[Internxt][2] 是一个相当新的开源加密云服务,旨在取代大型科技公司的产品。例如,你可以把它作为 Google Photos 和 Drive 的替代品。
[Internxt][2] 是一个相当新的开源加密云服务,旨在取代大型科技公司的产品。例如,你可以把它作为谷歌的相册和云端硬盘的替代品。
它免费提供 10 GB 的容量。所以,如果感兴趣的话,你可以注册个账号试一试。
@ -29,7 +30,7 @@ Internxt 发布了一个新产品,它可以让你快速地将加密文件发
我在 GitHub 上找不到 Internxt Send 的存储库,但我已经要求他们澄清了。
*LCTT 译注:虽然 Internxt 是在 GitHub 上开源的,但是 GitHub 上没有 Internxt Send 这个产品的存储库,产品的介绍里也没有声称它是开源的。*
LCTT 译注:虽然 Internxt 是在 GitHub 上开源的,但是 GitHub 上没有 Internxt Send 这个产品的存储库,产品的介绍里也没有声称它是开源的。
正如你所期望的那样,你无需创建帐户即可将文件上传到 Internxt Send。
@ -54,7 +55,7 @@ via: https://news.itsfoss.com/internxt-send/
作者:[Ankush Das][a]
选题:[lkxed][b]
译者:[lkxed](https://github.com/lkxed)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,85 +0,0 @@
[#]: subject: "Why use a Raspberry Pi to power your business"
[#]: via: "https://opensource.com/article/22/1/raspberry-pi-business"
[#]: author: "Giuseppe Cassibba https://opensource.com/users/peppe8o"
[#]: collector: "lujun9972"
[#]: translator: " void-mori"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Why use a Raspberry Pi to power your business
======
Why small, single-board computers can be the future for smart working
and small offices.
![A chair in a field.][1]
With the pandemic changing the way we're working, job decentralization is becoming an important challenge for all companies.
### Smart offices
Even if every factory approached smart working only as remoting the employee notebook through a VPN, adding evolution brings some basic office services as nearest as possible to people. This could drastically reduce the datacenter's load and improve people's working experience. An additional effect is removing many single-point-of-failures from information and communications technology (ICT) in this scenario.
Instead of hundreds or thousands of workplaces outside the company, it's like having hundreds or thousands of small offices/branches around the world. It's what one might call **smart offices**.
This statement may frighten many ICT experts because of the culture, which associates a big machine (server) to each office, even if the advantages of spreading computing resources are clear.
### A different perspective
What if you could deliver the services of a big server from a tiny US$ 50 board? What if this tiny board requires only an SD card and an ordinary USB power supply? Here's where the [Raspberry Pi][2] is the most flexible solution.
Raspberry Pi computer boards are very small form factor computers running Linux. They have an OS delivered and maintained from Raspberry Pi Foundation—the Raspberry Pi OS. Based on Debian, it shares many software packages with the most known Linux distributions. Moreover, many Raspberry Pi boards can flawlessly run the most famous Ubuntu server. They include ARM processors, which grant low energy consumption.
**[ Read next: [7 ways to use Raspberry Pi in enterprise IT][3] ]**
But Raspberry Pi computer boards are a great opportunity also for small companies, bringing tons of (open source) services at affordable costs. Here, you have to consider data loss risks, as you have all your services in small consumer-grade hardware. But setting up the right backup/restore procedures can reduce these risks.
### What services can you provide from a Raspberry Pi board?
Most services usually get delivered from more expensive servers. The "most" attribute depends on some restrictions:
* **ARM processor:** Some packages are available only for X86/X64 processors. This is one of the hardest challenges to overcome. On the other hand, the increasing market share for ARM processors keeps programmers having ARM-compatible versions of their software.
* **RAM amount:** This is a problem limited to some complex applications running complex calculations in a sophisticated manner. Many times, it's just a matter of revisiting the code, splitting steps, and keeping it simple and efficient. Moreover, if a service requires a lot of RAM/CPU for a few users, this may also mean that the service is not working correctly, and it could be an opportunity for you to remove old problems that are wasting resources. Finally, the latest Raspberry Pi computer boards upgraded the RAM amount up to 8GB, which is a lot.
* **Users who are inexperienced with servers:** This is another problem you can approach with base images inside the micro-SD cards on which Raspberry Pi stores the OS and running data.
That said, you can do many interesting things with a Raspberry Pi. In [my blog][4], I've tested this by running all kinds of services—from a basic LAMP server to a complex CRM. Passing through some complex systems, all open source, like:
* Proxy server (also capable to add ad-blocker services)
* Email server
* Printing server
* [Hotel management][5]
* Contact relations management
* [Private social network][6]
* Private forum
* Private Git web portal
* Network monitoring server
* [And many other useful services][7]
Another interesting opportunity for Raspberry Pi in your remote office is to get a WiFi hotspot offering advanced services and control from its Ethernet port. 
Finally, [Raspberry Pi can also run containers][8], an additional tool to get a world of services available from this incredible board.
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/1/raspberry-pi-business
作者:[Giuseppe Cassibba][a]
选题:[lujun9972][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/peppe8o
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_WorkInPublic_4618517_1110_CS_A.png?itok=RwVrWArk "A chair in a field."
[2]: https://opensource.com/resources/raspberry-pi
[3]: https://enterprisersproject.com/article/2020/11/raspberry-pi-7-enterprise-it-uses
[4]: https://peppe8o.com
[5]: https://opensource.com/article/20/4/qloapps-raspberry-pi
[6]: https://opensource.com/article/20/3/raspberry-pi-open-source-social
[7]: https://peppe8o.com/category/raspberrypi/
[8]: https://opensource.com/article/20/8/kubernetes-raspberry-pi

View File

@ -66,7 +66,7 @@ via: https://opensource.com/article/22/7/meet-fsf-executive-director-zoe-kooyman
作者:[Seth Kenlon][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
译者:[Peaksol](https://github.com/TravinDreek)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -2,7 +2,7 @@
[#]: via: "https://itsfoss.com/firefox-containers/"
[#]: author: "Hunter Wittenborn https://itsfoss.com/author/hunter/"
[#]: collector: "lujun9972"
[#]: translator: " "
[#]: translator: "hanszhao80"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
@ -108,7 +108,7 @@ via: https://itsfoss.com/firefox-containers/
作者:[Hunter Wittenborn][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
译者:[hanszhao80](https://github.com/hanszhao80)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -2,7 +2,7 @@
[#]: via: "https://opensource.com/article/21/11/observability-python"
[#]: author: "Moshe Zadka https://opensource.com/users/moshez"
[#]: collector: "lujun9972"
[#]: translator: " "
[#]: translator: "MCGA"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "

View File

@ -1,312 +0,0 @@
[#]: subject: "10 Necessary Ubuntu Apps For Everyone [Part 3]"
[#]: via: "https://www.debugpoint.com/necessary-ubuntu-apps-2022"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
10 Necessary Ubuntu Apps For Everyone [Part 3]
======
This article lists the top 10 necessary Ubuntu apps for your daily workflow.
We often forget that thousands of free and open-source applications can compete with other commercial counterparts in their category. Moreover, if you are a Windows user and thinking about getting rid of Windows completely, you should also be aware of such apps beforehand.
Hence, in this article series of “necessary Ubuntu apps”, we are featuring ten apps for much-needed awareness among Linux users.
This is part 3 of this Ubuntu Apps series. If you missed the earlier parts, you can read them here, Or navigate from the Menu above.
* [Part 1][1]
* [Part 2][2]
### Best Ubuntu Apps in 2022 Part 3
#### Guake
Ever wanted to quickly open a terminal with a quick keyboard shortcut while you are middle of a vital workflow? This Top-Down terminal app Guake helps you to do that. If you are busy working on an essay, editing a video, debugging a code in your favourite code editor and want to quickly check something in the terminal and then go back to work Guake can help you do that. Just press F12 and a terminal will pop up, and press F12 again, and it will go away—no need to launch/close a separate terminal instance.
![Guake Running in Ubuntu][3]
For Ubuntu and other related distros, you can run the below command to install. For further download options, visit [this page][4].
```
sudo apt install guake
```
**More information about Guake:**
* [Home page][5]
* [Source code][6]
#### Safe Eyes
Eyes are precious, and if you are a user with long work hours on Laptop/Desktop, you should also take care of your eyes. While there are other methods, this app, Safe Eyes, can help reduce and prevent repetitive strain injury.
Safe Eyes app gives you pop-up instruction with activities such as rotate your eyes clockwise for 10 seconds during your work.
I think it is one of the necessary Ubuntu apps everyone should try.
![Safe Eyes][7]
Installing safe eyes is easy to install in Ubuntu via PPA. You can open a terminal prompt and run the following commands to install this app.
```
sudo add-apt-repository ppa:slgobinath/safeeyessudo apt updatesudo apt install safeeyes
```
For other download, options visit [this page][8].
**More details:**
* [Home page][9]
* [Source code][10]
#### Tusk
Note-taking apps are plenty. Moreover, all the Linux distributions, including Ubuntu, always bring a basic text editor. But for advanced note-taking, you need a specialized app.
Tusk is a modern Evernote desktop app available for Ubuntu/Linux. It comes with plenty of themes such as Light, Sepia, and Dark it is loaded with features such as:
* Local and global customizable keyboard shortcuts
* Update notification
* A cross-platform app built on electron
* Scalable interface (zoom-in and out)
* Black, light and sepia themes
* Focus mode and auto night mode
* Export options of notes to HTML, PDF, and mark down files
![Tusk][11]
This application is available as AppImage, Deb and RPM files for Linux distributions. You can download the deb file from the below link and run it to install it in Ubuntu. For other download options, visit [this page][12].
[Download Tusk][13]
**More information about Tusk**:
* [Home page][14]
* [Source code][15]
#### Krita
If you are an artist or learning to draw in Linux, your must-have application is Krita. Krita brings a vast selection of drawing tools, including advanced modes such as pressure-sensitive drawing. In addition, you can also use Krita on touch-based tablet devices. Some of its unique features include:
* Customizable toolbar and docks
* Save your workspace as a file
* Light and dark theme
* Built-in vector engine, a vast set of brushes
* Brush engine with stabilization
* Support for PhotoShop Document (PSD)
* Full-colour support
* Extend your workflow with Python script
![Krita Drawing Program][16]
Installing Krita is easy because it is available for all Linux distributions official repo. For Ubuntu, you can search in Software and install it. If you prefer the terminal, you can also run the following command for installation.
```
sudo apt install krita
```
For more details about Krita, visit the following pages:
* [Home page][17]
* [Documentation and learning][18]
* [Source code][19]
#### Foliate
When you think about e-book readers, always Calibre comes to mind. But there is another stunning GNOME app Foliate. Foliate is a modern e-book reader written in GTK which brings exciting features such as custom colours of your pages, brightness, multicolumn support and more. In addition, it supports epub, Amazon Kindle, Fiction book, comic book archive and Mobipocket formats to give you complete control of your collection.
Its a must-have app if you want a nice and sleek e-book reader.
![Foliate][20]
Installing Foliate is easy, using Flatpak for all Linux distros. First, you need to [set up Flatpak][21] and click on the below button to install.
[Download Foliate][22]
**More information**:
* [Home page][23]
* [Source code][24]
#### Bitwarden
On average, every person has at least 10+ online accounts and passwords. And the more you are tech-savvy, the number of passwords you have to manage increases. Using a password manager is always recommended to protect your data and passwords. Hence the next app in this list is the best password manager available today, i.e. Bitwarden.
Bitwarden is a free and open-source password manager that helps you generate, store and protect your online credentials easily. Backed by AES-256 encryption, Bitwarden also syncs passwords among multiple devices such as mobile phones and tabs.
![Bitwarden Password Manager desktop client][25]
You can download the self-contained executable AppImage file from [this page][26]. Also, if you plan to access it in your favourite browser, you can get it there.
More information about Bitwarden:
* [Home page][27]
* [Help and documentation][28]
#### Brave Browser
Brave is a Chromium-based privacy-centric web browser. It is perfect for users who want complete control of their online activities. Brave comes with a built-in ad blocker, incognito browsing, VPN, and Tor mode for more anonymous browsing.
Recently, Brave browser also introduced an email service, which you can access right from the browser itself. Furthermore, it brings some advantages over Firefox, Google Chrome and Safari.
![Brave Browser][29]
Installing the Brave browser requires additional commands from the terminal for Ubuntu Linux. You can find the detailed download instructions [here][30].
For more details, visit the official [home page][31].
#### Mailspring
If you are looking for a friendly and productive desktop email client for Linux which supports all email protocols, then try Mailspring.
Mailspring brings multiple account support, a unified mailbox, and touch and gesture support. In addition, it supports Microsoft Office 365, one of the best advantages of this email client in Linux systems. Moreover, features such as fast search, translations, undo send (recall), and built-in spell-check make it one of the best email clients.
It also comes with a paid version with a minimal monthly fee and additional features such as company profile creation, link tracking, read receipt, templates and insights. The insights feature in the pro version gives details about when you receive more emails during the day.
![Mailspring Email Client][32]
This application is available as a Snap and Deb file for Ubuntu and related Linux.
For the Snap package, visit the official Snapcraft page [here][33] and install it.
And for the deb package, click here to download it. After download, you can double-click the deb package to install via Software in Ubuntu.
For more details, refer to the following pages.
* [Home page][34]
* [Other download options][35] (Fedora Linux, Windows and macOS)
#### Blender
Im sure you have heard about Blender. Blender is one of the free and open-source professional-grade graphic design software which is capable of doing almost everything that you need for your graphics project.
![Blender Video Editor][36]
You can create animated films, visual effects, art, 3D printed models, motion graphics, interactive 3D applications, and computer games. Blenders features include 3D modelling, UV unwrapping, texturing, raster graphics editing, rigging and skinning, fluid and smoke simulation, particle simulation, soft body simulation, sculpting, animating, match moving, rendering, motion graphics, video editing, and compositing.
It is a professional-grade application which is still free and open-source.
For easy installation in Ubuntu, open Software, search for Blender, and then hit install. Alternatively, you can also open a terminal window and run the following command to install.
```
sudo apt install blender
```
This software is available for Windows, macOS and other platforms. You can visit the [official download page][37] for more details.
**More information:**
* [Home page][38]
* [Detailed Feature highlights][39]
* [Documentation][40]
#### Ungoogled Chromium
If you want a clean browser free from Google apps and services, you should try out the Ungoogled Chromium browser. Its a drop-in replacement for the stock Chromium experience without the Google integrated services.
For example, it is free of all pre-compiled binaries from the code and all Google integration and also disables features requiring manual enabling for better control.
Perhaps a well-suited browser is the best Chromium experience.
![Ungoogled-Chromium][41]
Installing Ungoogled Chromium is easy using Flatpak. First, set up[Flatpak][42] and install this browser using the following command.
```
flatpak install flathub com.github.Eloston.UngoogledChromium
```
To learn more, visit the [official GitHub page][43] of this browser.
#### Tilix
![Tilix Terminal Window][44]
The final app in this necessary Ubuntu apps list is Tilix. Tilix is a tiling window-based terminal emulator which is based on GTK. It comes with custom titles, additional notification support (for command completion) and transparent background image support. In addition, Tilix also enables you to add a custom image background in the terminal window. Finally, you can create multiple terminal panes side-by-side in a single window.
An advanced terminal is written in GTK, which you may find productive.
Installation packages are available for all Linux distributions. For Ubuntu and related distros, run the following command to install.
```
sudo apt install tilix
```
For more details, visit the Tilix [home page][45].
### Closing Notes
This completes part 3 of a 5-part series of best Ubuntu Apps in 2022. I hope you get to install and use some of these applications in Ubuntu and other distros for your daily productive output. Also, let me know which apps you pick from this list as your best in the comment box below.
Finally, stay tuned for part 4 of this Ubuntu apps series. If you missed the other parts, you could read them here:
* [Part 1][46]
* [Part 2][47]
Cheers.
*Some image credits: Respected app developers/teams.*
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/necessary-ubuntu-apps-2022
作者:[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/essential-ubuntu-apps-2022-part-1/
[2]: https://www.debugpoint.com/best-ubuntu-apps-2022-part2/
[3]: https://www.debugpoint.com/wp-content/uploads/2018/09/Guake-Running-in-Ubuntu.gif
[4]: https://guake.readthedocs.io/en/latest/user/installing.html#system-wide-installation
[5]: http://guake-project.org/
[6]: https://github.com/Guake/guake
[7]: https://www.debugpoint.com/wp-content/uploads/2018/09/Safe-Eyes.gif
[8]: https://slgobinath.github.io/SafeEyes/
[9]: https://slgobinath.github.io/SafeEyes/
[10]: https://github.com/slgobinath/SafeEyes
[11]: https://www.debugpoint.com/wp-content/uploads/2018/09/Tusk.gif
[12]: https://github.com/klaussinani/tusk/releases/
[13]: https://github.com/klaussinani/tusk/releases/download/v0.23.0/tusk_0.23.0_amd64.deb
[14]: https://klaussinani.github.io/tusk/
[15]: https://github.com/klaussinani/tusk
[16]: https://www.debugpoint.com/wp-content/uploads/2022/07/Krita-Drawing-Program.jpg
[17]: https://krita.org/en/
[18]: https://docs.krita.org/en/
[19]: https://invent.kde.org/graphics/krita
[20]: https://www.debugpoint.com/wp-content/uploads/2022/07/Foliate.jpg
[21]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/
[22]: https://dl.flathub.org/repo/appstream/com.github.johnfactotum.Foliate.flatpakref
[23]: https://johnfactotum.github.io/foliate/
[24]: https://github.com/johnfactotum/foliate
[25]: https://www.debugpoint.com/wp-content/uploads/2022/07/Bitwarden-Password-Manager-desktop-client.jpg
[26]: https://bitwarden.com/download/
[27]: https://bitwarden.com/help/
[28]: https://bitwarden.com/help/
[29]: https://www.debugpoint.com/wp-content/uploads/2022/07/Brave-Browser.jpg
[30]: https://brave.com/linux/#release-channel-installation
[31]: https://brave.com
[32]: https://www.debugpoint.com/wp-content/uploads/2022/07/Mailspring-Email-Client.jpg
[33]: https://snapcraft.io/mailspring
[34]: https://getmailspring.com/
[35]: https://getmailspring.com/download
[36]: https://www.debugpoint.com/wp-content/uploads/2019/09/Blender-Video-Editor.jpg
[37]: https://www.blender.org/download/
[38]: https://www.blender.org/
[39]: https://www.blender.org/features/
[40]: https://www.blender.org/get-involved/documenters/
[41]: https://www.debugpoint.com/wp-content/uploads/2022/07/Ungoogled-Chromium.jpg
[42]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/
[43]: https://github.com/ungoogled-software/ungoogled-chromium#feature-overview
[44]: https://www.debugpoint.com/wp-content/uploads/2022/07/Tilix-Terminal-Window.jpg
[45]: https://gnunn1.github.io/tilix-web/
[46]: https://www.debugpoint.com/essential-ubuntu-apps-2022-part-1/
[47]: https://www.debugpoint.com/best-ubuntu-apps-2022-part2/

View File

@ -1,749 +0,0 @@
[#]: subject: "Docker Commands Tutorial | Getting Started With Docker In Linux"
[#]: via: "https://ostechnix.com/getting-started-with-docker/"
[#]: author: "sk https://ostechnix.com/author/sk/"
[#]: collector: "lkxed"
[#]: translator: "MCGA"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Docker Commands Tutorial | Getting Started With Docker In Linux
======
Essential Docker Commands For beginners
This detailed Docker tutorial covers the essential **Docker commands**, such as how to create a new container, run the container, remove a container and so on. In addition, this guide also explains how to build your own custom Docker image from an existing container and how to remove containers and images. Without further ado, let us **get started with Docker basics usage**!
### Docker Installation Steps
Docker can be installed in most modern Linux operating systems. If you haven't installed Docker yet, refer the following guides:
* [Install Docker Engine And Docker Compose In AlmaLinux, CentOS, Rocky Linux][1]
* [How to Install Docker And Docker Compose In Ubuntu][2]
### What Is Docker Image And Docker Container?
Before getting started with Docker, let me clarify what is a **Docker image** and a **Docker Container**.
A Docker Image is the file that decides how a Container should behave, and Docker Container is the running or stopped stage of a Docker image.
The containers are isolated from the rest of host's files.
When we run a Docker container, it uses an isolated filesystem which provided by a Docker image. The Docker image consists of everything needed to run an application - all dependencies, configuration, scripts, binaries, etc.
The image also contains other configuration for the container, such as environment variables, a default command to run, and other metadata.
### Getting Started With Docker In Linux
All steps given below are tested in Ubuntu 22.04, 20.04 and 18.04 LTS server edition. However, the steps provided in the subsequent sections are common to all Linux platforms. For example, you can run the same commands in a RHEL-based system(E.g. AlmaLinux) too.
#### 1. Search Docker Images
We can get the images from either from the official docker library called [Docker hub][3], or create our own.
For those wondering, Docker hub is an online central repository where all Docker users build, test, and save their Docker images. Docker hub has tens of thousands of Docker images and the number of images is growing everyday.
You can search for the any Docker images with **"docker search"** command from command line.
For instance, to search for docker images based on **Alpine** Linux, run:
```
$ sudo docker search alpine
```
**Sample Output:**
![Search Docker Images][4]
To search images based on **Ubuntu**, run:
```
$ sudo docker search ubuntu
```
You can even search images for any application, for example **Nginx**, like below:
```
$ sudo docker search nginx
```
Docker hub has a wide range of images. Be it an operating system, application, or combination of multiple applications (E.g. LAMP stack), you will find pre-built Docker images for everything in Docker hub.
If something you're looking for is not available, you can build it and make it available for public via Docker hub or keep it private for your own use.
#### 2. Download Docker Images
To download Docker image for Ubuntu OS, run the following command from the Terminal:
```
$ sudo docker pull ubuntu
```
The above command will download the latest Ubuntu image from the **Docker hub**.
**Sample Output:**
```
Using default tag: latest
latest: Pulling from library/ubuntu
405f018f9d1d: Pull complete
Digest: sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
```
You can also download a specific version of Ubuntu image using command:
```
$ sudo docker pull ubuntu:20.04
```
Docker allows us to download any images and start the container based on that image regardless of the host OS.
For example, to download Alpine OS image, run:
```
$ sudo docker pull alpine
```
![Download Docker Images][5]
#### 3. List Docker Images
All downloaded Docker images will be saved in **/var/lib/docker/** directory.
To view the list of downloaded Docker images, run:
```
$ sudo docker images
```
**Sample Output:**
```
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 27941809078c 3 weeks ago 77.8MB
ubuntu 20.04 20fffa419e3a 3 weeks ago 72.8MB
alpine latest e66264b98777 5 weeks ago 5.52MB
```
![List Docker Images][6]
As you see above, I have downloaded three Docker images - **Ubuntu** **latest**, **Ubuntu 20.04** and **Alpine Linux**.
Now, let us go ahead and see how to start or run the containers based on the downloaded images.
#### 4. Run Docker Containers
We can start a container in two ways - either using its Docker **Image** **TAG** or **Image ID**.
**TAG** refers to a particular snapshot of the image and the **IMAGE ID** is the corresponding unique identifier for that image.
Take a look at the following screenshot:
![Docker Image Tag and ID][7]
As you see in the above results, the tags are **"latest"** and **"20.04"**.
* 27941809078c is the IMAGE ID of Ubuntu latest Docker image,
* 20fffa419e3a is the image id of Ubuntu 20.04 Docker image
* and `e66264b98777` is the image id of Alpine latest Docker image.
##### 4.1. Run Containers Using Tag
Once you downloaded the Docker images of your choice, run the following command to start a Docker container and connect to it by using its TAG.
```
$ sudo docker run -t -i ubuntu:latest /bin/bash
```
Or,
```
$ sudo docker run -it ubuntu:latest /bin/bash
```
Here,
* -t : Assigns a new Pseudo Terminal inside the Ubuntu container.
* -i : Allows us to make an interactive connection by grabbing the standard in (STDIN) of the container.
* ubuntu:latest : Ubuntu docker image with Tag "latest".
* /bin/bash : BASH shell for the new container. This is optional. If you don't mention the shell, the default shell will be assigned to the container.
After starting the container, you'll be automatically landed into the Container's shell (Command prompt):
![Run Containers Using Tag][8]
The new container based on the Ubuntu latest image has been started now. A unique ID and a name will be given to all the newly containers. As you can see in the above output, the Ubuntu container ID is **2f2a5b826762**. We will see where to find the name of the container in a minute.
You can now start working in the container. Once you're done with the Container, you can return back to the host system's Terminal (In my case, it is Ubuntu 22.04 LTS) without terminating the Container (guest os).
##### 4.2. Detach From Running Containers
To detach from a running container (without terminating it), press **CTRL+P** followed by **CTRL+Q**.
Now, you are back to your original host computer's terminal window. Please note that the container is still running in the background and we didn't terminate it yet.
##### 4.3. Run Containers Using IMAGE Id
The another way to start a container and connect to it is by using the IMAGE ID as shown below:
```
$ sudo docker run -it 20fffa419e3a /bin/bash
```
Here,
* 20fffa419e3a - Image id
To detach from the container and return back to the host system's Terminal, press **CTRL+P** and **CTRL+Q**. Again, we only detached from the container but didn't stop it. The container is still running in the background.
##### 4.4. Run Containers In Detached Mode
In the previous sections, we started a container and attached to it immediately. And then we detached from the container once our work with that container is completed.
You can also start container in detached mode (without automatically attaching it).
To run a container in the background, run:
```
$ sudo docker run -it -d alpine:latest
```
**Sample Output:**
```
d74f2ceb5f3ad2dbddb0b26e372adb14efff91e75e7763418dbd12d1d227129d
```
The first 12 letters in the above output indicates the container ID.
You can verify if the container is running using `docker ps` command:
```
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d74f2ceb5f3a alpine:latest "/bin/sh" 3 seconds ago Up 2 seconds zen_pascal
```
![Run Containers In Background][9]
As you can see in the above output, we have a created an Alpine container but didn't attach to it.
If you want to attach it to the container, simply, run:
```
$ sudo docker attach d74f2ceb5f3a
```
#### 5. View Running Containers
To view the list running of containers, run the following command:
```
$ sudo docker ps
```
**Sample Output:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f7e04eed577e 20fffa419e3a "/bin/bash" 6 minutes ago Up 6 minutes brave_mclean
2f2a5b826762 ubuntu:latest "/bin/bash" 18 minutes ago Up 18 minutes hungry_leavitt
```
![View Running Containers][10]
Here,
* f7e04eed577e is the ID of the Ubuntu container that is created with image "2f2a5b826762". And, "brave_mclean" is the name of this container.
* 2f2a5b826762 is the ID of the Ubuntu container that is created with image "ubuntu:latest". And, "hungry_leavitt" is the name of this container.
Whenever a new container is created, a unique ID and name will be given to it, so we can access the container using either its ID or name.
**Heads Up:** Please note that **Container ID and Docker image ID are different**.
To list all available (either running or stopped) containers, run:
```
$ sudo docker ps -a
```
#### 6. Attach To Or Detach From Running Containers
First, find the name or ID of the container with `docker ps` command.
```
$ sudo docker ps
```
Next, attach to the running container using `docker attach` command.
```
$ sudo docker attach <container-id>
```
For instance, I am going to attach to the container that has the ID "f7e04eed577e" like below:
```
$ sudo docker attach f7e04eed577e
```
You can also attach to a container using its name as well.
```
$ sudo docker attach brave_mclean
```
Now you're logged in to the container.
To detach from the container, simply press **CTRL+P** followed by **CTRL+Q**.
#### 7. Start, Restart, Pause, And Stop Containers
You can start, restart, pause or stop a Docker container using its name or container ID.
First, find the name or ID of the container with `docker ps -a` command.
![Find Container ID And Name][11]
Now you can start a container using `docker start` command with name or ID like below.
```
$ sudo docker start modest_cray
```
```
$ sudo docker start 10615254bb45
```
You can **start multiple containers** with space-separated like below.
```
$ sudo docker start 24b5ee8c3d3a 56faac6d20ad d74f2ceb5f3a
```
To gracefully restart a running container, do:
```
$ sudo docker start 10615254bb45
```
To pause processes in a running container:
```
$ sudo docker pause 10615254bb45
```
To Unpause processes in a running container:
```
$ sudo docker unpause 10615254bb45
```
To block a container until others stop:
```
$ sudo docker wait 10615254bb45
```
Similarly we can stop a docker container using its name or ID. If you're already inside the container's shell, you can stop the container by simply running the following command:
```
# exit
```
You can also stop (power off the container) from the Docker host system using the following command:
```
$ sudo docker stop 10615254bb45
```
You can exit multiple containers with space-separated as shown below.
```
$ sudo docker stop 35b5ee8c3d3a 10615254bb45
```
After exiting the container, verify if it is really stopped by listing the running containers with command:
```
$ sudo docker ps
```
#### 8. Kill Docker Containers
The docker stop command will gracefully turn off a running container. Sometimes, you may stuck with an unresponsive container or you want to forcibly shutdown a container.
To kill a container by sending a `SIGKILL` to a running container, run:
```
$ sudo docker kill 10615254bb45
```
#### 9. Automatically Delete Containers After Closing Them
You may want to test a Container and then delete it once you're done with the Container. If so, you can automatically delete the Container after closing it by using `--rm` flag:
```
$ sudo docker run -it --rm debian:latest
```
Once you exit from the Container, it will be automatically deleted.
![Automatically Delete Containers][12]
As you see in the above output, I created a new Debian container. Once I exit from the container, it is automatically deleted. The `docker ps -a` output shows that the Debian container doesn't exist.
#### 10. Assign Name To Containers
If you closely look into the output of previous commands, each container is given a random name when you start a container. If you don't name your Containers, Docker will name them for you automatically.
Have a look at the following example.
```
$ sudo docker run -it -d alpine:latest
2af79e97a825c91bf374b4862b9e7c22fc22acd1598005e8bea3439805ec335d
```
```
$ sudo docker run -it -d alpine:latest
80b53b7e661d33696b65c78267fc3f067b6100799c925910db4721963e3fae0a
```
```
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80b53b7e661d alpine:latest "/bin/sh" 3 seconds ago Up 2 seconds bold_margulis
2af79e97a825 alpine:latest "/bin/sh" 6 seconds ago Up 5 seconds recursing_taussig
```
As you see in the above output, even though I have created two containers using the same docker image, they both gets different ID and name.
If you want to assign a static name to the container, use `--name` flag like below:
```
$ sudo docker run -it -d --name ostechnix_alpine alpine:latest
```
The above command will create run a new Container called **ostechnix_alpine** in detached mode.
let us view list of the running Containers:
```
$ sudo docker ps
```
**Sample Output:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
397111fac537 alpine:latest "/bin/sh" 2 seconds ago Up 2 seconds ostechnix_alpine
80b53b7e661d alpine:latest "/bin/sh" 7 minutes ago Up 7 minutes bold_margulis
2af79e97a825 alpine:latest "/bin/sh" 7 minutes ago Up 7 minutes recursing_taussig
```
![Assign Name To Containers][13]
Did you notice the name of the first Container in the above output? Yes, we've assigned a custom name (i.e. `ostechnix_alpine` ) to the Container.
Assigning custom names to containers gives us a benefit. We can easily identify what is installed in that container by looking at the name of the container name.
#### 11. Build Custom Docker Images
Docker is not just for downloading and using the existing containers. You can create your own custom docker image as well.
Let us start an Ubuntu container:
```
$ sudo docker run -it ubuntu:latest
```
Now, you will be in the container's shell.
Then, install any software or do whatever you want in the container.
For example, let us install **Apache web server** in the container.
```
# apt update
# apt install apache2
```
Similarly, install and test any software of your choice in the Container.
Once you're done, detach from the container (don't exit it) and return back to the host system's shell. Please do not stop or power-off the Container. To detach from the container without stopping it, press `CTRL+P` followed by `CTRL+Q`.
From your Docker host terminal, run the following command to find the container ID:
```
$ sudo docker ps
```
Finally, create a Docker image of the running Container using command:
```
$ sudo docker commit 377e6d77ebb5 ostechnix/ubuntu_apache
```
**Sample Output:**
```
sha256:bc5e5f95ca592a3585fda2c5a40ec30c98e292046ef70390a2c3b7863cc6f7c1
```
Here,
* 377e6d77ebb5  Ubuntu container ID.
* ostechnix  Name of the user who created the container.
* ubuntu_apache Name of the docker image created by user ostechnix.
Let us check whether the new Docker image is created or not with command:
```
$ sudo docker images
```
**Sample Output:**
```
ostechnix/ubuntu_apache
```
![Build Custom Docker Images][14]
As you see in the above output, the new Docker image has been created in our Docker host system from the running Container.
Now, you can create a new Container from the newly created Docker image as usual with command:
```
$ sudo docker run -it ostechnix/ubuntu_apache
```
#### 12. Removing Containers
Once you're done all R&D with Docker containers, you can delete if you don't want them anymore.
To do so, First we have to stop (power off) the running Containers.
Let us find out the running containers with command:
```
$ sudo docker ps
```
**Sample Output:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
377e6d77ebb5 ubuntu:latest "bash" 7 minutes ago Up 7 minutes elegant_beaver
```
Stop the running container by using it's ID:
```
$ sudo docker stop 377e6d77ebb5
```
Now, delete the container using command:
```
$ sudo docker rm 377e6d77ebb5
```
Similarly, stop all containers and delete them if they are no longer required.
Deleting multiple containers one by one can be a tedious task. So, we can delete all stopped containers in one go, just run:
```
$ sudo docker container prune
```
Type **"Y"** and hit `ENTER` key to delete the containers.
```
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
397111fac5374921b974721ee646b2d5fbae61ca9c6e8b90fbf47952f382a46b
80b53b7e661d33696b65c78267fc3f067b6100799c925910db4721963e3fae0a
[...]
Total reclaimed space: 176B
```
![Delete Containers][15]
This command will work only with latest Docker versions.
Verify if all the containers are deleted using the command:
```
$ sudo docker ps -a
```
If you don't see any output, all containers are deleted.
#### 13. Removing Docker Images
Remember, first you should remove all the containers before removing all the images from which those containers were created.
Once you removed containers, you can delete the Docker images that you no longer need.
To find the list of the Downloaded Docker images:
```
$ sudo docker images
```
**Sample Output:**
```
REPOSITORY TAG IMAGE ID CREATED SIZE
ostechnix/ubuntu_apache latest bc5e5f95ca59 14 minutes ago 229MB
debian latest d2780094a226 11 days ago 124MB
ubuntu latest 27941809078c 3 weeks ago 77.8MB
ubuntu 20.04 20fffa419e3a 3 weeks ago 72.8MB
alpine latest e66264b98777 5 weeks ago 5.52MB
```
As you see above, we have 5 Docker images in our host system.
Let us delete them by using their IMAGE id:
```
$ sudo docker rmi ce5aa74a48f1
```
**Sample Output:**
```
Untagged: ostechnix/ubuntu_apache:latest
Deleted: sha256:bc5e5f95ca592a3585fda2c5a40ec30c98e292046ef70390a2c3b7863cc6f7c1
Deleted: sha256:a8e4797160a2b2d33d8bd1bd67e008260c022b3a53fbcc198b2b74d9eae5961d
```
Similarly, delete all other Docker images.
To remove all stopped containers, all images, build cache, all networks, run:
```
$ sudo docker system prune -a
```
Be careful while using this command. It will delete all unused containers, networks, images (both dangling and unreferenced).
![Delete Everything In Docker][16]
By default, volumes are not removed to prevent important data from being deleted even if there is currently no container using the volume.
If you want to delete everything including the Volumes, use the `--volumes` flag.
```
$ sudo docker system prune -a --volumes
```
### Docker Troubleshooting
Docker won't let you to delete the Docker images if they are used by any running or stopped containers.
For example, when I try to delete a Docker Image with ID **b72889fa879c**, from one of my old Ubuntu server. I got the following error:
```
Error response from daemon: conflict: unable to delete b72889fa879c (must be forced) - image is being used by stopped container dde4dd285377
```
This is because the Docker image that you want to delete is currently being used by another Container.
So, let us check the running Container using command:
```
$ sudo docker ps
```
**Sample Output:**
![Show running docker containers][17]
Oops! There is no running container.
Let us again check for all containers (running and stopped) with command:
```
$ sudo docker ps -a
```
**Sample Output:**
![Show running and stopped docker containers][18]
As you see, there are still some stopped containers are using one of the Docker images. So, let us delete all of the containers.
**Example:**
```
$ sudo docker rm 12e892156219
```
Similarly, remove all containers as shown above using their respective container's ID.
Once you deleted all containers, finally remove the Docker images.
**Example:**
```
$ sudo docker rmi b72889fa879c
```
That's it. Now verify if there are any other Docker images in the host with command:
```
$ sudo docker images
```
You will now probably won't have any docker images.
### Conclusion
In this comprehensive **getting started with Docker tutorial**, we explained Docker basics such as creating, running, searching, removing containers and also building own Docker image from a Container. We also explained how to delete Docker containers and images when they are no longer necessary.
Hope you a got the basic idea about **Docker usage**.
For more details, refer the official resource links given at the end of this guide or drop a comment in the comment section below.
**Resources:**
* [Docker website][19]
* [Docker Documentation][20]
--------------------------------------------------------------------------------
via: https://ostechnix.com/getting-started-with-docker/
作者:[sk][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://ostechnix.com/author/sk/
[b]: https://github.com/lkxed
[1]: https://ostechnix.com/install-docker-almalinux-centos-rocky-linux/
[2]: https://ostechnix.com/install-docker-ubuntu/
[3]: https://hub.docker.com/
[4]: https://ostechnix.com/wp-content/uploads/2022/07/Search-Docker-Images.png
[5]: https://ostechnix.com/wp-content/uploads/2022/07/Download-Docker-Images.png
[6]: https://ostechnix.com/wp-content/uploads/2022/07/List-Docker-Images.png
[7]: https://ostechnix.com/wp-content/uploads/2022/07/Docker-Image-Tag-and-ID.png
[8]: https://ostechnix.com/wp-content/uploads/2022/07/Run-Containers-Using-Tag-1.png
[9]: https://ostechnix.com/wp-content/uploads/2022/07/Run-Containers-In-Background-1.png
[10]: https://ostechnix.com/wp-content/uploads/2022/07/View-Running-Containers.png
[11]: https://ostechnix.com/wp-content/uploads/2022/07/Find-Container-ID-And-Name.png
[12]: https://ostechnix.com/wp-content/uploads/2022/07/Automatically-Delete-Containers.png
[13]: https://ostechnix.com/wp-content/uploads/2022/07/Assign-Name-To-Containers.png
[14]: https://ostechnix.com/wp-content/uploads/2022/07/Build-Custom-Docker-Images.png
[15]: https://ostechnix.com/wp-content/uploads/2022/07/Delete-Containers.png
[16]: https://ostechnix.com/wp-content/uploads/2022/07/Delete-Everything-In-Docker.png
[17]: https://ostechnix.com/wp-content/uploads/2016/04/sk@sk-_005-1-1.jpg
[18]: https://ostechnix.com/wp-content/uploads/2016/04/sk@sk-_006-1.jpg
[19]: https://www.docker.com/
[20]: https://docs.docker.com/

View File

@ -0,0 +1,275 @@
[#]: subject: "9 Rather Unknown Ways of Using Neofetch in Linux"
[#]: via: "https://itsfoss.com/using-neofetch/"
[#]: author: "Abhishek Prakash https://itsfoss.com/author/abhishek/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
9 Rather Unknown Ways of Using Neofetch in Linux
======
Neofetch is a simple command-line tool that [displays an ASCII logo of the distribution][1] along with a few system information in the terminal. It looks beautiful and you can easily show which distribution, desktop environment, and themes you are using when you share the screenshots of your desktop in various Linux communities.
![KDE Neon Neofetch][2]
For most users, thats all there is to Neofetch.
But Neofetch is highly customizable. You can display any ASCII logo instead of the distributions, filter out the information to display or replace the logos with cowsay messages.
Interesting, isnt it? Before I show you how to customize Neofetch, let me quickly go on installing it first, if you havent installed it already.
### Installing Neofetch
[Neofetch][3] is available in the official repo of all major Linux distributions. To install it in Ubuntu and [Debian-based distros][4], use:
```
sudo apt install neofetch
```
Fedora and Red Hat users can use the DNF package manager:
```
sudo dnf install neofetch
```
Arch and Manjaro users can [use the pacman command][5]:
```
sudo pacman -S neofetch
```
openSUSE users can use the Zypper command:
```
sudo zypper install neofetch
```
Once you have it installed, lets see how to use it.
### Using Neofetch
In its simplest form, enter the neofetch command in the terminal:
```
neofetch
```
And it will show you the default output that consists of the ASCII logo of your distribution and some system information.
![Neofetch output in Ubuntu][6]
Thats simple. But you can configure it to show some additional information or hide some.
#### 1. Display logo of another distro
By default neofetch shows the logo of the current distribution. No surprises there.
But you can have the ASCII logo of a different distribution than yours. Surprise!
Here is the Pop!OS logo in Kubuntu system.
![Displaying Logo of Pop!_OS in Kubuntu][7]
To do that, you have to use the ascii_distro flag.
```
neofetch --ascii_distro distroname
```
You know what! You can even display ASCII logo of Windows in Neofetch.
![neofetch windows logo][8]
#### 2. Show a smaller logo
The list of distros having ASCII art is listed in the man page of Neofetch. Now, there also exists a sublist of distros, which has a small ASCII art. That list can also be found in its man page.
![neofetch small logo][9]
To achieve this:
```
neofetch --ascii_distro <distroname>_small
```
You can make it permanent by editing the respective line on the config file.
If a distro logo doesnt have a small version, it displays the bigger one. And if you made a typo, it shows the Tux logo.
![Tux logo with Neofetch][10]
#### 3. Hiding Multiple Infos from view
In Neofetch, there is a lot of information is shown by default. You dont have to stick to them if you dont want to.
You can hide some information from the display. You can do that in two ways: either by providing options through the command line or by editing the configuration file.
I will prefer editing the config file, because it is one time and will take effect immediately, and no need to type it repeatedly.
Open neofetch config with [Vim or Nano][11] or your favorite editor using:
```
nano .config/neofetch/config.conf
```
![neofetch config file][12]
Here you can find multiple lines referring to “info”. Comment those that you want to hide and uncomment those to show. To comment, just add # at the beginning of a line.
Save the file and exit. Next, Neofetch run will be the modified one.
The same config file can be tweaked to show users in the system, CPU temperatures, battery information, etc.
![customised neofetch][13]
#### 4. Hide the logo or the info
You can tweak Neofetch to display only the system information and hide the ASCII logo.
```
neofetch --off
```
![neofetch without ascii logo][14]
Also, you can have Neofetch with only the ASCII logo, without system information:
```
neofetch -L
```
![neofetch with only ascii logo][15]
#### 5. Use a custom image as ASCII logo
Neofetch supports custom images to be applied to the ASCII logo part. This is achieved by several backends. Images can be applied through jp2a, caca, sixel, w3m backends.
By using jp2a, you can have your own image as an ascii art in neofetch.
![custom ascii logo in neofetch with jp2a backend][16]
To do this, use Neofetch like this:
```
neofetch --jp2a /path/to/image
```
Another type of output that is supported is the caca backend. On the terminal, enter:
```
neofetch --caca /path/to/image
```
![neofetch image with caca backend][17]
There are other backends also, which can be found on its man page.
#### 6. Add gradient colors by using lolcat with Neofetch
With lolcat, you can have a colorful neofetch. Install lolcat using your distributions package manager first:
```
sudo apt install lolcat
```
Once lolcat is installed, pipe neofetch to lolcat to get a rainbow effect:
```
neofetch | lolcat
```
![neofetch with lolcat][18]
#### 7. Use cowsay and fortune instead of logo
With the latest releases of Neofetch, you can now display cowsay and fortune in place of the ascii logo. For more fancy, the same output can be piped to lolcat.
```
neofetch --ascii "$(fortune | cowsay -W 30)" | lolcat
```
Cowsay program can also display other animal figures by specifying the cowfile with `-f` flag.
![neofetch with cowsay and lolcat][19]
For more fun and if you have some time to invest, type the below code and see an animated neofetch appearing:
```
neofetch --ascii "$(fortune | cowsay -f dragon -W 30)" | lolcat -ats 60
```
#### 8. Animate it
Speaking of animation, you can animate the entire Neofetch output with the pv command. It consumes a lot of time but if you are doing a screencast and want to amuse people, this could do the trick.
![A Video from YouTube][20]
With pv command installed on your system, use it in conjugation with Neofetch:
```
neofetch | pv -qL 100
```
This will begin typing character by character the neofetch art and info. Adjust the animation speed by changing the value from 100. Higher the value, faster is the animation.
#### 9. Custom colors for the title, underline and info panel
You can change the colors for the informational part. The parts of the informational panel are in the order: title, @, underline, subtitle, colon, info.
You can give a different part to each one of them by adding a color code in their position like this:
```
neofetch --colors 3 4 5 6 2 1
```
![neofetch custom color scheme one][21]
![neofetch custom color scheme two][22]
### Wrapping Up
There are many more ways to tweak Neofetch. You can always look into its man page.
As I said earlier, for most users Neoetch is just a simple, no-option command to pretty display system information and distribution logo in the terminal.
Even I never bothered to look into customizing Neofetch. It was my teammate Sreenath who likes experimenting with these things and he came up with the idea and I had a feeling that Its FOSS readers like you might find it amusing.
Over to you now. Did you find some surprising new usage of Neofetch? Do you know some other cool trick? Share it with us in the comments.
--------------------------------------------------------------------------------
via: https://itsfoss.com/using-neofetch/
作者:[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/author/abhishek/
[b]: https://github.com/lkxed
[1]: https://itsfoss.com/display-linux-logo-in-ascii/
[2]: https://itsfoss.com/wp-content/uploads/2021/01/kde-neon-neofetch.png
[3]: https://github.com/dylanaraps/neofetch
[4]: https://itsfoss.com/debian-based-distros/
[5]: https://itsfoss.com/pacman-command/
[6]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-output.png
[7]: https://itsfoss.com/wp-content/uploads/2022/07/Changed-logo-of-distribution.png
[8]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-windows-logo-800x490.png
[9]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-small-logo-800x306.png
[10]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-tux-logo.png
[11]: https://itsfoss.com/vim-vs-nano/
[12]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-config-file-800x419.png
[13]: https://itsfoss.com/wp-content/uploads/2022/07/customised-neofetch-800x164.png
[14]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-without-ascii-logo.png
[15]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-with-only-ascii-logo.png
[16]: https://itsfoss.com/wp-content/uploads/2022/07/custom-ascii-logo-in-neofetch-with-jp2a-backend-800x314.png
[17]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-image-with-caca-backend-800x278.png
[18]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-with-lolcat-800x303.png
[19]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-with-cowsay-and-lolcat-800x240.png
[20]: https://player.vimeo.com/video/727286686
[21]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-custom-color-scheme-one.png
[22]: https://itsfoss.com/wp-content/uploads/2022/07/neofetch-custom-color-scheme-two.png

View File

@ -0,0 +1,124 @@
[#]: subject: "A guide to productivity management in open source projects"
[#]: via: "https://opensource.com/article/22/7/productivity-management-open-source-projects"
[#]: author: "Thabang Mashologu https://opensource.com/users/tmashologu"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
A guide to productivity management in open source projects
======
Enhance productivity by applying the SPACE framework to open source teams.
![Working on a team, busy worklife][1]
Image by: opensource.com
Open source is one of the most important technology trends of our time. Its the lifeblood of the digital economy and the preeminent way that software-based innovation happens today. In fact, its estimated that over 90% of software released today contains open source libraries.
There's no doubt the open source model is effective and impactful. But is there still room for improvement? When comparing the broader software industrys processes to that of open source communities, one big gap stands out: productivity management.
By and large, open source project leads and maintainers have been slow to adopt modern productivity and project management practices and tools commonly embraced by startups and enterprises to drive the efficiency and predictability of software development processes. Its time we examine how the application of these approaches and capabilities can improve the management of open source projects for the better.
### Understanding productivity in open source software development
The open source model, at its heart, is community-driven. There is no single definition of success for different communities, so a one-size-fits-all approach to measuring success does not exist. And what we have traditionally thought of as productivity measures for software development, like commit velocity, the number of pull requests approved and merged, and even the lines of code delivered, only tell part of the story.
Open source projects are people-powered. We need to take a holistic and humanistic approach to measuring productivity that goes beyond traditional measures. I think this new approach should focus on the fact that great open source is about communication and coordination among a diverse community of contributors. The level of inclusivity, openness, and transparency within communities impacts how people feel about their participation, resulting in more productive teams.
These and other dimensions of what contributes to productivity on open source teams can be understood and measured with the SPACE framework, which was developed based on learnings from the proprietary world and research conducted by GitHub, the University of Victoria in Canada, and Microsoft. I believe that the SPACE framework has the potential to provide a balanced view of what is happening in open source projects, which would help to drive and optimize collaboration and participation among project team members.
### A more accurate productivity framework
The SPACE framework acronym stands for:
* Satisfaction and well-being
* Performance
* Activity
* Communication and collaboration
* Efficiency and flow
Satisfaction and well-being refer to how fulfilled developers feel with the team, their tools, and the environment, as well as how healthy and happy they are. Happiness is somewhat underrated as a factor in the success of teams. Still, there is strong evidence of a direct correlation between the way people feel and their productivity. In the open source industry, surveying contributors, committers, and maintainers about their attitudes, preferences, and priorities about what is being done and how is essential to understanding attitudes and opinions.
Performance in this context is about evaluating productivity in terms of the outcomes of processes instead of output. Team-level examples are code-review velocity (which captures the speed of reviews) and story points shipped. More holistic measures focus on quality and reliability. For example, was the code written in a way that ensures it will reliably do what it is supposed to do? Are there a lot of bugs in the software? Is industry adoption of the software growing?
Open source activity focuses on measuring design and development and CI/CD metrics, like build, test, deployments, releases, and infrastructure utilization. Example metrics for open source projects are the number of pull requests, commits, code reviews completed, build releases, and project documents created.
Communication and collaboration capture how people and teams work together, communicate, and coordinate efforts with high transparency and awareness within and between teams. Metrics in this area focus on the vibrancy of forums, as measured by the number of posts, messages, questions asked and answered, and project meetings held.
Finally, efficiency and flow refer to the ability to complete work and progress towards it with minimal interruptions and delays. At the individual developer level, this is all about getting into a flow that allows complex tasks to be completed with minimal distractions, interruptions, or context switching. At the project team level, this is about optimizing flow to minimize the delays and handoffs that take place in the steps needed to take software from an idea or feature request to being written into code. Metrics are built around process delays, handoffs, time on task, and the ease of project contributions and integrations.
### Applying the SPACE framework to open source teams
Here are some sample metrics to illustrate how the SPACE framework could be used for an open source project.
#### Satisfaction and well-being
* Contributor satisfaction
* Community sentiment
* Community growth & diversity
#### Performance
* Code review velocity
* Story points shipped
* Absence of bugs
* Industry adoption
#### Activity
* number of pull requests
* number of commits
* number of code reviews
* number of builds
* number of releases
* number of docs created
#### Communication and collaboration
* Forum posts
* Messages
* Questions asked & answered
* Meetings
#### Efficiency and flow
* Code review timing
* Process delays & handoffs
* Ease of contributions/integration
### Tools for managing open source projects must be fit for purpose
There is an opportunity to leverage the tools and approaches startups and high-growth organizations use to understand and improve open source development efficiency. All while putting open sources core tenets, like openness and transparency, into practice.
Tools used by open source teams should enable maintainers and contributors to be productive and successful, while allowing the projects to be open and welcoming to everyone, including developers who may work in multiple organizations and even competing companies. It is also critical to provide an excellent onboarding experience for new contributors and accelerate their time-to-understanding and time-to-contribution.
Tools for managing open source projects should transparently manage data and accurately reflect project progress based on where the collaboration happens: in the codebase and repositories. Open source teams should be able to see real-time updates based on updates to issues and pull requests. And, project leads and maintainers should have the flexibility to decide whether access to the project should be completely public or if it should be limited to trusted individuals for issues or information of a more sensitive nature.
Ideally, tools should allow self-governed project teams to streamline coordination, processes, and workflows and eliminate repetitive tasks through automation. This reduces human friction and empowers maintainers and contributors to focus on what really matters: contributing to the ecosystem or community and delivering releases faster and more reliably.
The tools teams use should also support collaboration from people wherever they are. Since open source teams work in a remote and asynchronous world, tools should be able to integrate everyones contributions wherever and whenever they occur. These efforts should be enabled by great documentation stored in a central and easily accessible place. And finally, the tools should enable continuous improvement based on the types of frameworks and measures of productivity outlined above.
Features that allow for increased transparency are especially important for open source projects. Tools should help keep community members aligned and working towards a common goal with a project roadmap that shows work is in flight, progress updates, and predicted end dates.
### Conclusion
Open source projects are a benefit to us all, and as such, it benefits everyone to make the processes that exist within these projects as productive as possible.
By leveraging concepts like the SPACE framework and modern tools, we can ditch the spreadsheets and manual ways of tracking, measuring, and improving productivity. We can adapt approaches that power software development in the proprietary world and leverage modern tools that can help increase the quality, reliability, and predictability of open source software releases. Open source is far too important to leave to anything less.
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/7/productivity-management-open-source-projects
作者:[Thabang Mashologu][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/tmashologu
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/team_dev_email_chat_video_work_wfm_desk_520.png

View File

@ -0,0 +1,216 @@
[#]: subject: "How I create music playlists on Linux"
[#]: via: "https://opensource.com/article/22/7/c-linux-mp3"
[#]: author: "Rikard Grossman-Nielsen https://opensource.com/users/rikardgn"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How I create music playlists on Linux
======
Use this C program I made on Linux to listen to your favorite songs on the go.
![Open source software helps artists create music][1]
Image by: Opensource.com
I recently wrote a C program in Linux to create a smaller random selection of MP3 files from my extensive MP3 library. The program goes through a directory containing my MP3 library, and then creates a directory with a random, smaller selection of songs. I then copy the MP3 files to my smartphone to listen to them on the go.
Sweden is a sparsely populated country with many rural areas where you don't have full cell phone coverage. That's one reason for having MP3 files on a smartphone. Another reason is that I don't always have the money for a streaming service, so I like to have my own copies of the songs I enjoy.
You can download my application from its [Git repository][2]. I wrote it for Linux specifically in part because it's easy to find well-tested file I/O routines on Linux. Many years ago, I tried writing the same program on Windows using proprietary C libraries, and I got stuck trying to get the file copying routing to work. Linux gives the user easy and direct access to the file system.
In the spirit of open source, it didn't take much searching before I found file I/O code for Linux to inspire me. I also found some code for allocating memory which inspired me. I wrote the code for random number generation.
The program works as described here:
1. It asks for the source and destination directory.
2. It asks for the number of files in the directory of MP3 files.
3. It searches for the percentage (from 1.0 to 88.0 percent) of your collection that you wish to copy. You can also enter a number like 12.5%, if you have a collection of 1000 files and wish to copy 125 files from your collection rather than 120 files. I put the cap at 88% because copying more than 88% of your library would mostly generate a collection similar to your base collection. Of course, the code is open source so you can freely modify it to your liking.
4. It allocates memory using pointers and malloc. Memory is required for several actions, including the list of strings representing the files in your music collection. There is also a list to hold the randomly generated numbers.
5. It generates a list of random numbers in the range of all the files (for example, 1 to 1000, if the collection has 1000 files).
6. It copies the files.
Some of these parts are simpler than others, but the code is only about 100 lines:
```
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h> /* include necessary header files */
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#define BUF_SIZE 4096 /* use buffer of 4096 bytes */
#define OUTPUT_MODE 0700 /*protect output file */
#define MAX_STR_LEN 256
int main(void) {
DIR *d;
struct dirent *dir;
char strTemp[256], srcFile[256],
dstFile[256], srcDir[256], dstDir[256];
char **ptrFileLst;
char buffer[BUF_SIZE];
int nrOfStrs=-1, srcFileDesc,
dstFileDesc, readByteCount,
writeByteCount, numFiles;
int indPtrFileAcc, q;
float nrFilesCopy;
// vars for generatingRandNumList
int i, k, curRanNum, curLstInd,
numFound, numsToGen, largNumRange;
int *numLst;
float procFilesCopy;
printf("Enter name of source Directory\n");
scanf("%s", srcDir);
printf("Enter name of destionation Directory\n");
scanf("%s", dstDir);
printf("How many files does the directory with mp3 files contain?\n");
scanf("%d", &numFiles);
printf("What percent of the files do you wish to make a random selection of\n");
printf("enter a number between 1 and 88\n");
scanf("%f", &procFilesCopy);
// allocate memory for filesList, list of random numbers
ptrFileLst= (char**) malloc(numFiles * sizeof(char*));
for (i = 0; i < numFiles; i++) {
ptrFileLst[i] = (char*)malloc(MAX_STR_LEN * sizeof(char));
}
largNumRange = numFiles;
nrFilesCopy = (procFilesCopy / 100) * numFiles;
numsToGen = (int)((procFilesCopy / 100) * numFiles);
printf("nrFilesCopy=%f", nrFilesCopy);
printf("NumsToGen=%d", numsToGen);
numLst = malloc(numsToGen * sizeof(int));
srand(time(0));
numLst[0] = rand() % largNumRange + 1;
numFound=0;
do {
curRanNum = (int)rand() % largNumRange + 1;
if (numLst[0] == curRanNum) {
numFound=1;
}
} while(numFound == 1);
numLst[1] = curRanNum;
getchar();
curLstInd = 1;
i = 0;
while(1) {
do {
numFound = 0;
curRanNum = (int)rand() % largNumRange + 1;
for (int k = 0; k <= curLstInd; k++){
if (numLst[k] == curRanNum)
numFound = 1;
}
} while(numFound == 1);
numLst[curLstInd+1] = curRanNum;
curLstInd++;
i++;
// numsToGen=Total numbers to generate minus two
// already generated by the code above this loop
if (i == (numsToGen-2))
break;
}
d = opendir(srcDir);
if (d) {
while ( (dir = readdir(d)) != NULL ) {
strcpy(strTemp, dir->d_name);
if (strTemp[0] != '.') {
nrOfStrs++;
strcpy(ptrFileLst[nrOfStrs], strTemp);
}
}
closedir(d);
}
for (q = 0; q <= curLstInd; q++) {
indPtrFileAcc = numLst[q];
strcpy(srcFile, srcDir);
strcat(srcFile, "/");
strcat(srcFile, ptrFileLst[indPtrFileAcc]);
strcpy(dstFile, dstDir);
strcat(dstFile, "/");
strcat(dstFile, ptrFileLst[indPtrFileAcc]);
srcFileDesc = open(srcFile, O_RDONLY);
dstFileDesc = creat(dstFile, OUTPUT_MODE);
while(1) {
readByteCount = read(srcFileDesc, buffer, BUF_SIZE);
if (readByteCount <= 0)
break;
writeByteCount = write(dstFileDesc, buffer, readByteCount);
if(writeByteCount <= 0)
exit(4);
}
//close the files
close(srcFileDesc);
close(dstFileDesc);
}
}
```
This code is possibly the most complex:
```
while(1) {
readByteCount = read(srcFileDesc, buffer, BUF_SIZE);
if (readByteCount <= 0)
break;
writeByteCount = write(dstFileDesc, buffer, readByteCount);
if (writeByteCount <= 0)
exit(4);
}
```
This reads a number of bytes (readByteCount) from a file specified into the character buffer. The first parameter to the function is the file name (srcFileDesc). The second parameter is a pointer to the character buffer, declared previously in the program. The last parameter of the function is the size of the buffer.
The program returns the number of the bytes read (in this case, 4 bytes). The first `if` clause breaks out of the loop if a number of 0 or less is returned.
If the number of read bytes is 0, then all of the writing is done, and the loop breaks to write the next file. If the number of bytes read is less than 0, then an error has occurred and the program exits.
When the 4 bytes are read, it will write to them.The write function takes three arguments.The first is the file to write to, the second is the character buffer, and the third is the number of bytes to write (4 bytes). The function returns the number of bytes written.
If 0 bytes are written, then a write error has occurred, so the second `if` clause exits the program.
The `while` loop reads and copies the file, 4 bytes at a time, until the file is copied. When the copying is done, you can copy the directory of randomly generated mp3 files to your smartphone.
The copy and write routine are fairly efficient because they use file system calls in Linux.
### Improving the code
This program is simple and it could be improved in terms of its user interface, and how flexible it is. You can implement a function that calculates the number of files in the source directory so you don't have to enter it manually, for instance. You can add options so you can pass the percentage and path non-interactively.nBut the code does what I need it to do, and it's a demonstration of the simple efficiency of the C programming language.
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/7/c-linux-mp3
作者:[Rikard Grossman-Nielsen][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/rikardgn
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/LIFE_musicinfinity.png
[2]: https://github.com/rikardgn/learnC/blob/main/randMp3Copy.c

View File

@ -0,0 +1,84 @@
[#]: subject: "Why use a Raspberry Pi to power your business"
[#]: via: "https://opensource.com/article/22/1/raspberry-pi-business"
[#]: author: "Giuseppe Cassibba https://opensource.com/users/peppe8o"
[#]: collector: "lujun9972"
[#]: translator: " void-mori"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
为何要使用树莓派为你的业务提供动力
======
为何小小的单板机是智能工作以及小型办公室的未来
![A chair in a field.][1]
随着疫情的大流行,我们的工作方式也正在发生着改变。工作的分散化正在成为所有公司需要面临的一项重要挑战。
### 智能办公室
即使所有的工厂都能和智能工作搭上一点边哪怕仅仅是通过VPN来对员工的笔记本电脑进行远程控制添加evolution而带来一些基本办公服务尽可能的拉近人与人之间的距离这些都能够极大降低数据中心的负载并且提高人们的工作体验。这个方案还有一个额外的影响就是从信息和通信技术上来说消除了许多单点故障。
和在公司外部有成百上千的工作场地不同,更像是在世界范围内有着成百上千的小型办公室/分支,这就是所谓的“智能办公室”。
这种表述可能会让许多的ICT专家感到恐慌因为这种文化使得一台大机器即服务器关联了每个办公室即使摊开计算资源的优势非常明显。
### 一个不同的角度
如果你能够通过一个50美金的小开发板在大服务器上交付服务会怎么样如果这个小板子只需要一张SD卡和一个普通的USB电源支持那又会怎么样呢这就是[Raspberry Pi][2]是最灵活的解决方案的原因所在。
树莓派开发板是尺寸非常小的运行Linux的计算机。它有一个由树莓派基金会提供和维护的操作系统—Raspberry Pi OS。它基于Debian和最知名的Linux发行版共享许多软件包。此外许多树莓派的开发板能够完美运行最知名的Ubuntu Server它涵盖了ARM处理器给予了对低功耗处理器的支持。
**[ 阅读下一篇: [在enterprise IT中使用树莓派的7种方式][3] ]**
但树莓派开发板对小公司来说也是一个很好的机会,以能够承担得起的代价获得大量的(开源)服务。这种情况下,你必须考虑数据丢失的风险,因为你把所有的服务运行在一个小的,消费级的硬件上。不过设置正确的备份/还原程序能够降低这些风险。
### 你能从树莓派开发板上提供什么服务?
大多数服务通常由更昂贵的服务器提供。“大多数”属性取决于一些限制:
* **ARM处理器:** 一些软件包只支持X86/X64处理器。这是最难克服的挑战之一。另一方面ARM处理器的市场份额不断增长使得程序员让他们的软件有兼容ARM处理器的版本。
* **内存容量:** 这是一个仅限于在复杂应用以复杂的方式进行复杂的计算的情况下讨论的问题。很多时候,只不过是关于重新访问代码,拆分步骤,并保持简单高效的问题。此外,如果一个服务因为少数几个用户而需要大量的内存/CPU这大概也意味着此服务没有正常工作。这可能是你消除浪费资源的旧问题的一个机会。 最后最新的树莓派开发板把内存容量升级到了8GB是一个很大的提升。
* **对服务器没有经验的用户:** 这是另一个问题你可以在存储了系统和运行数据的树莓派上使用micro-SD卡中的基础镜像。
咱就是说,你能够用树莓派做很多有趣的事情。在[我的博客][4]里我通过运行各种服务进行了测试—从基本的LAMP服务器到复杂的CRM。从简单到复杂系统全部都是开源的例如
* 代理服务器(也能够添加广告拦截服务)
* 电子邮件服务器
* 打印服务器
* [酒店管理][5]
* 联系人关系管理
* [私人社交网络][6]
* 私人论坛
* 私有Git门户网站
* 网络监控服务器
* [许多其他有用的服务][7]
对树莓派来说另一个有趣的机会是在你的远程办公室获得提供高级服务的wifi热点并且可以从它的以太网端口进行控制。 
最后,[树莓派也能够运行容器][8],这是一个额外的工具,从这个不可思议的开发板中获得一个可用的服务世界。
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/1/raspberry-pi-business
作者:[Giuseppe Cassibba][a]
选题:[lujun9972][b]
译者:[void-mori](https://github.com/void-mori)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/peppe8o
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_WorkInPublic_4618517_1110_CS_A.png?itok=RwVrWArk "A chair in a field."
[2]: https://opensource.com/resources/raspberry-pi
[3]: https://enterprisersproject.com/article/2020/11/raspberry-pi-7-enterprise-it-uses
[4]: https://peppe8o.com
[5]: https://opensource.com/article/20/4/qloapps-raspberry-pi
[6]: https://opensource.com/article/20/3/raspberry-pi-open-source-social
[7]: https://peppe8o.com/category/raspberrypi/
[8]: https://opensource.com/article/20/8/kubernetes-raspberry-pi

View File

@ -0,0 +1,321 @@
[#]: subject: "10 Necessary Ubuntu Apps For Everyone [Part 3]"
[#]: via: "https://www.debugpoint.com/necessary-ubuntu-apps-2022"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: "Donkey"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
10 大必备 Ubuntu 应用——第三篇
======
本文列出了 2022 年可以用于日常工作的 10 个 Ubuntu 必备应用。
我们经常忘记在有成千上万的免费和开源应用能够与同类商业产品相媲美。此外,若你是 Windows 用户并且想完全摆脱 Windows ,你应该提前想到这些应用。
因此,在这一“必备 Ubuntu 应用”文章中,我们为急需的 Linux 用户列举了 10 款应用。
这是这个系列的第三篇文章,如果你错过了之前的文章,可以通过以下链接阅读:
* [Part 1][1]
* [Part 2][2]
#### Guake
你是否想要在重要工作中使用快捷键打开一个终端?这款自上而下的终端程序 Guake 能够帮你实现。如果你正忙于写文章、剪辑视频、在你最喜欢的代码编辑器中写代码,并想要快速用终端检查一些东西并返回到工作中, Guake 能够帮助你。只用按 F12 终端就会立即出现,再次按 F12 它会消失,不用打开或关闭不同的终端。
![Guake Running in Ubuntu][3]
在 Ubuntu 或其他发行版,你可以使用以下命令安装。如需更多下载选项,请访问 [此页面][4]。
```
sudo apt install guake
```
**关于 Guake 的更多信息:**
* [主页][5]
* [源码][6]
#### Safe Eyes
眼睛很宝贵,如果你是长时间使用平板或电脑的用户,你应该保护好眼睛。这里有一款可以帮助你保护眼睛的应用—— Safe Eyes ,能够帮你减少并预防用眼过度。
Safe Eyes 这款应用会在你的工作期间为你提供“顺时针转动眼睛 10 秒”等活动的弹出式指令。
我认为它是每个人都应该尝试使用的一款 Ubuntu 应用。
![Safe Eyes][7]
通过 PPA 很容易在 Ubuntu 上安装 Safe Eyes 。你可以打开终端并使用以下命令安装这款应用。
```
sudo add-apt-repository ppa:slgobinath/safeeyessudo apt updatesudo apt install safeeyes
```
更多下载选项,请访问 [此页面][8]。
**关于 Safe Eyes 的更多信息**
* [主页][9]
* [源码][10]
#### Tusk
记笔记的应用有很多。虽然,包括 Ubuntu 在内的所有 Linux 发行版,都带有一个基础文本编辑器,但是想要高级的笔记功能,你需要一个专业应用。
Tusk 是适用于 Ubuntu/Linux 的新款印象笔记桌面应用程序。它带有大量主题,例如浅色、深褐色和深色。它具有以下功能:
* 局部和全局自定义快捷键
* 更新提示
* 基于 Electron 的跨平台应用
* 可扩展的界面(放大和缩小)
* 浅色、深褐色和深色主题
* 对焦模式和自动夜间模式
* 将笔记导出为 HTML、PDF 和 Markdown 格式
![Tusk][11]
该应用有 Linux 发行版的 AppImage 、Deb 和 RPM 文件等格式。你可以从以下链接下载 deb 文件并运行它以在 Ubuntu 中安装它。有关其他下载选项,请访问 [此页面][12]。
[下载 Tusk][13]
**关于 Tusk 的更多信息**:
* [主页][14]
* [源码][15]
#### Krita
如果你是一个艺术家并学着在 Linux 上绘画,那你一定要用 Krita 。Krita 拥有众多绘画工具,包含诸如压敏绘画等高级模式。此外,你也可以在触屏设备上使 Krita 。它包含一些独特的功能:
* 自定义工具栏和停靠栏
* 将工作区另存为文件
* 明暗主题
* 内置矢量引擎,海量画笔
* 带稳定功能的刷子引擎
* 支持 PhotoShop 文件 (PSD)
* 全彩支持
* 支持 Python 脚本扩展
![Krita Drawing Program][16]
在所有的 Linux 发行版的官方仓库都有 Krita ,所以很容易安装。在 Ubuntu 中,你可以在应用商店里搜索并安装。如果你更喜欢使用终端安装,可以运行如下指令:
```
sudo apt install krita
```
浏览以下链接了解 Krita 的更多信息:
* [主页][17]
* [学习文件][18]
* [源码][19]
#### Foliate
当你想要一个电子书阅读器时,你会情不自禁地想到 Calibre 。不过还有一款杰出的 GNOME 应用—— Foliate 。Foliate 是用 GTK 编写的新颖的电子书阅读器,它带来了令人惊奇的功能,例如页面的自定义颜色、亮度、多列支持等等。此外,它还支持 epub、Amazon Kindle、小说、漫画书存档和 Mobipocket 格式,让你完全控制自己的收藏。
如果你想要一个漂亮而优美的电子书阅读器,非它莫属。
![Foliate][20]
使用 Linux 发行版的 Flatpak 安装 Foliate 很容易。首先,你需要 [设置 Flatpak][21] 并单击下方链接进行安装。
[下载 Foliate][22]
**更多信息**:
* [主页][23]
* [源码][24]
#### Bitwarden
平均每个人至少有十个账号和密码。若你精通技术那么你管理密码的数量肯定会增加。使用密码管理器能够更好的保护你的数据以及密码。那么接下来这款应用Bitwarden ,是当今管理密码最好的应用
Bitwarden 是一款免费开源的密码管理器,能够轻松帮助你生成、存储并保存密码。基于 AES-256 加密方案, Bitwarden 能够在不同设备,比如手机和平板自动同步密码。
![Bitwarden Password Manager desktop client][25]
你可以从 [此页面][26] 下载可执行安装包文件。此外,如果你打算在你最喜欢的浏览器中使用它,也可以在该页面中获取。
关于 Bitwarden 更多信息:
* [主页][27]
* [帮助文档][28]
#### Brave Browser
Brave 是基于 Chromium 的以隐私为中心的浏览器。它非常适合希望完全控制其在线活动的用户。Brave 带有内置广告拦截器、隐身浏览、VPN 和 Tor 模式,可实现更多匿名浏览。
最近Brave 推出了电子邮件服务,你可以直接从浏览器访问邮件。此外,它具备一些 Firefox 、 Google Chrome 以及 Safari 没有的优点。
![Brave Browser][29]
在 Ubuntu 终端上安装这款浏览器需要额外的命令。你可以 [在此][30] 找到相信的下载教程。
更多详细信息,浏览官方 [主页][31] 。
#### Mailspring
如果你在找一款友好的并且高效的 Linux 桌面电子邮件客户端,并且想要它支持所有的电子邮件协议,那你应该试试 Mailspring 。
Mailspring 支持多个账户、统一邮箱并且支持触控和手势。它还支持 Microsoft Office 365 ,这是此电子邮件客户端在 Linux 系统中的最大优势之一。此外,具有快速检索、翻译、取消发送(邮件召回)以及内置的拼写检查等特征,使得它是最好的邮件客户端之一。
它还配备了每月最低费用的付费版本和附加功能,例如公司资料创建、链接跟踪、阅读回执、模板和见解。专业版中的洞察功能提供了有关你在白天何时收到更多电子邮件的详细信息。
![Mailspring Email Client][32]
这款应用可以通过 Snap 和 Deb 文件在 Ubuntu 或其他相关 Linux 上安装。
访问官方 [Snapcraft 页面][33] 获取 Snap 包并安装。
点击 [这里] **这里缺少链接(译注)** 下载 deb 包。下载后,你可以双击 deb 文件通过 Ubuntu 应用商店程序安装。
更多信息请参考以下链接:
* [主页][34]
* [其他下载选项][35] (Fedora Linux, Windows 以及 macOS)
#### Blender
我确信你听说过 Blender 。 Blender 是一款免费并开源的专业级图形设计软件,几乎可以完成图形项目所需的一切。
![Blender Video Editor][36]
你可以创建动画电影、视觉效果、艺术作品、3D 打印模型、动态图形、交互式 3D 应用程序和计算机游戏。 Blender 的功能包括 3D 建模、UV 展开、纹理、光栅图形编辑、绑定和蒙皮、流体和烟雾模拟、粒子模拟、柔体模拟、雕刻、动画、匹配移动、渲染、运动图形、视频编辑和合成。
它是一个专业级的应用程序,还是免费和开源的。
想要在 Ubuntu 中轻松安装,打开应用商店,搜索 Blender然后点击安装。或者你也可以打开终端窗口并运行以下命令进行安装。
```
sudo apt install blender
```
该软件适用于 Windows、macOS 和其他平台。你可以访问 [官方下载页面][37] 了解更多详情。
**更多信息:**
* [主页][38]
* [详细功能亮点][39]
* [文档][40]
#### Ungoogled Chromium
如果你想要一个没有 Google 应用和服务的干净浏览器,你应该尝试使用 Ungoogled Chromium 浏览器。在没有 Google 集成服务的情况下,它可以替代现有的 Chromium 体验。
例如,它没有代码中的所有预编译二进制文件和所有 Google 集成,并且还禁用了需要手动启用以获得更好控制的功能。
或许一个合适的浏览器,才会有最好的 Chromium 体验。
![Ungoogled-Chromium][41]
使用 Flatpak 安装 Ungoogled Chromium 很容易。首先设置 [Flatpak][42] 然后使用下列命令安装该浏览器:
```
flatpak install flathub com.github.Eloston.UngoogledChromium
```
浏览 [官方 GitHub 页面][43] 获取该浏览器更多信息。
#### Tilix
![Tilix Terminal Window][44]
必备 Ubuntu 应用程序列表中的最后一个应用程序是 Tilix 。Tilix 是一个基于 GTK 的基于平铺窗口的终端仿真器。它带有自定义标题、附加通知支持用于命令完成和透明背景图像支持。此外Tilix 还允许你在终端窗口中添加自定义图像背景。最后,你可以在一个窗口中并排创建多个终端窗口。
这是一个用 GTK 编写的高级终端,你可能会发现它很有用。
所有 Linux 发行版都有安装包。在 Ubuntu 或相关版本,运行以下命令进行安装:
```
sudo apt install tilix
```
更多信息请浏览 Tilix [主页][45] 。
### 结语
这是 2022 年 5 篇系列的必备 Ubuntu 应用程序的第 3 篇。我希望你能够在 Ubuntu 或者其他 Linux 发行版上安装,并在你的日常工作中使用这些应用程序。同时,欢迎在下方评论,让我知道你最喜欢哪一款应用。
最后,请继续关注本 Ubuntu 应用程序系列的第 4 部分。如果你错过了其他部分,你可以在这里阅读它们:
* [第一篇][46]
* [第二篇][47]
干杯!
*一些图片来源:令人尊敬的应用开发人员或团队*
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/necessary-ubuntu-apps-2022
作者:[Arindam][a]
选题:[lkxed][b]
译者:[Donkey](https://github.com/Donkey-Hao)
校对:[校对者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/essential-ubuntu-apps-2022-part-1/
[2]: https://www.debugpoint.com/best-ubuntu-apps-2022-part2/
[3]: https://www.debugpoint.com/wp-content/uploads/2018/09/Guake-Running-in-Ubuntu.gif
[4]: https://guake.readthedocs.io/en/latest/user/installing.html#system-wide-installation
[5]: http://guake-project.org/
[6]: https://github.com/Guake/guake
[7]: https://www.debugpoint.com/wp-content/uploads/2018/09/Safe-Eyes.gif
[8]: https://slgobinath.github.io/SafeEyes/
[9]: https://slgobinath.github.io/SafeEyes/
[10]: https://github.com/slgobinath/SafeEyes
[11]: https://www.debugpoint.com/wp-content/uploads/2018/09/Tusk.gif
[12]: https://github.com/klaussinani/tusk/releases/
[13]: https://github.com/klaussinani/tusk/releases/download/v0.23.0/tusk_0.23.0_amd64.deb
[14]: https://klaussinani.github.io/tusk/
[15]: https://github.com/klaussinani/tusk
[16]: https://www.debugpoint.com/wp-content/uploads/2022/07/Krita-Drawing-Program.jpg
[17]: https://krita.org/en/
[18]: https://docs.krita.org/en/
[19]: https://invent.kde.org/graphics/krita
[20]: https://www.debugpoint.com/wp-content/uploads/2022/07/Foliate.jpg
[21]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/
[22]: https://dl.flathub.org/repo/appstream/com.github.johnfactotum.Foliate.flatpakref
[23]: https://johnfactotum.github.io/foliate/
[24]: https://github.com/johnfactotum/foliate
[25]: https://www.debugpoint.com/wp-content/uploads/2022/07/Bitwarden-Password-Manager-desktop-client.jpg
[26]: https://bitwarden.com/download/
[27]: https://bitwarden.com/help/
[28]: https://bitwarden.com/help/
[29]: https://www.debugpoint.com/wp-content/uploads/2022/07/Brave-Browser.jpg
[30]: https://brave.com/linux/#release-channel-installation
[31]: https://brave.com
[32]: https://www.debugpoint.com/wp-content/uploads/2022/07/Mailspring-Email-Client.jpg
[33]: https://snapcraft.io/mailspring
[34]: https://getmailspring.com/
[35]: https://getmailspring.com/download
[36]: https://www.debugpoint.com/wp-content/uploads/2019/09/Blender-Video-Editor.jpg
[37]: https://www.blender.org/download/
[38]: https://www.blender.org/
[39]: https://www.blender.org/features/
[40]: https://www.blender.org/get-involved/documenters/
[41]: https://www.debugpoint.com/wp-content/uploads/2022/07/Ungoogled-Chromium.jpg
[42]: https://www.debugpoint.com/how-to-install-flatpak-apps-ubuntu-linux/
[43]: https://github.com/ungoogled-software/ungoogled-chromium#feature-overview
[44]: https://www.debugpoint.com/wp-content/uploads/2022/07/Tilix-Terminal-Window.jpg
[45]: https://gnunn1.github.io/tilix-web/
[46]: https://www.debugpoint.com/essential-ubuntu-apps-2022-part-1/
[47]: https://www.debugpoint.com/best-ubuntu-apps-2022-part2/

View File

@ -0,0 +1,751 @@
[#]: subject: "Docker Commands Tutorial | Getting Started With Docker In Linux"
[#]: via: "https://ostechnix.com/getting-started-with-docker/"
[#]: author: "sk https://ostechnix.com/author/sk/"
[#]: collector: "lkxed"
[#]: translator: "MCGA"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Docker 命令教程 | 在 Linux 中入门 Docker
======
初学者的 Docker 基本命令
这篇详细的 Docker 教程覆盖了核心的 **Docker 命令**,比如,如何创建新容器,运行容器,删除容器等。另外,这篇教程也解释了如何从已有的容器构建你自己的 Docker 镜像,如何移除容器和镜像。言归正传,现在开始 Docker 的基本用法。
### Docker 安装步骤
大多数现代 Linux 操作系统都可以安装 Docker。如果还没安装过 Docker请参考下面的步骤
* [在 AlmaLinuxCentOSRocky Linux 上安装 Docker Engine 和 Docker Compose][1]
* [如何在 Ubuntu 上安装 Docker 和 Docker Compose][2]
### 什么是 Docker 镜像和 Docker 容器?
在开始 Docker 之前,我先说明一下 Docker 镜像和 Docker 容器是什么。
Docker 镜像是一个描述容器如何运行的的文件Docker 容器是 Docker 镜像在运行或被终止时的一个阶段。
容器和主机上的其他文件是隔离的。
当我们运行一个 Docker 容器的时候,它会使用一个被隔离出来的文件系统,这个文件系统是由一个 Docker 镜像提供的。Docker 镜像包含了运行应用程序所需要的一切东西 - 所有的依赖,配置,脚本,二进制文件等等。
镜像也包含容器所需要的其他配置项,比如说环境变量,运行的默认命令,以及其他元数据。
### Linux 下的 Docker 入门
下面的所有步骤都已在 Ubuntu 22.0420.04 以及 18.04 LTS 服务器版本中测试通过。后续小节中提供的步骤对于所有 Linux 平台都是通用的。比如,在基于 RHEL 的系统中(比如 AlmaLinux可以运行相同的命令。
#### 1. 搜索 Docker 镜像
我们可以从叫做 [Docker hub][3] 的 docker 官方库获得镜像,或者我们也可以制作自己的镜像。
有些人可能不清楚Docker hub 是一个线上的中心化仓库,所有的 Docker 用户在上面构建,测试,然后保存他们的 Docker 镜像。Docker hub 有数以万计的 Docker 镜像,而且这个数字还在每天增长。
你可以从命令行通过 **“docker search”** 命令搜索任意 Docker 镜像。
比如要搜索基于 **Alpine** Linux 的 docker 镜像,运行:
```
$ sudo docker search alpine
```
**输出结果:**
![Search Docker Images][4]
搜索基于 **Ubuntu** 的镜像,运行:
```
$ sudo docker search ubuntu
```
你还可以搜索其他任意的应用,比如 **Nginx**,像下面这样:
```
$ sudo docker search nginx
```
Docker hub 有各种各样的镜像。你能在 Docker hub 上找到一切已构建好的 Docker 镜像,比如说操作系统,应用,或者多个应用的合体(比如 LAMP 栈)。
如果你找的东西不在上面,你还可以构建一个镜像,然后通过 Docker hub 向其他人开放,或者只是自己用。
#### 2. 下载 Docker 镜像
从终端运行下面的命令可以下载 Ubuntu OS 的 Docker 镜像:
```
$ sudo docker pull ubuntu
```
上面的这个命令会从 Docker hub 下载最新的 Ubuntu 镜像。
**输出结果:**
```
Using default tag: latest
latest: Pulling from library/ubuntu
405f018f9d1d: Pull complete
Digest: sha256:b6b83d3c331794420340093eb706a6f152d9c1fa51b262d9bf34594887c2c7ac
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
```
你也可以用下面的命令下载指定版本的 Ubuntu 镜像:
```
$ sudo docker pull ubuntu:20.04
```
Docker 允许我们下载任何镜像,并且在那个镜像上创建容器,这些操作与主机的操作系统无关。
比如要下载 Alpine 系统的镜像,运行:
```
$ sudo docker pull alpine
```
![Download Docker Images][5]
#### 3. 列出 Docker 镜像
所有已下载的 Docker 镜像都保存在 **/var/lib/docker** 路径下。
要查看所有已下载的 Docker 镜像,运行:
```
$ sudo docker images
```
**输出结果:**
```
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 27941809078c 3 weeks ago 77.8MB
ubuntu 20.04 20fffa419e3a 3 weeks ago 72.8MB
alpine latest e66264b98777 5 weeks ago 5.52MB
```
![List Docker Images][6]
从上面可以看出来,我已经下载了三个 Docker 镜像 - **Ubuntu** **lates****Ubuntu 20.04** 和 **Alpine Linux**
现在,我们看一下接下来如何从下载的镜像启动或者运行容器。
#### 4. 运行 Docker 容器
有两种方法我们可以启动一个容器 - 使用 Docker **镜像** **TAG** 或者 **<ruby>镜像 ID<rt>Image ID</rt></ruby>**。
**TAG** 指的是一个特定的镜像快照,**<ruby>镜像 ID<rt>Image ID</rt></ruby>** 是那个镜像对应的唯一识别码。
可以查看下面这个截图:
![Docker Image Tag and ID][7]
从上面的解脱可以看到,<ruby>标签<rt>tags</rt></ruby>**latest****“20.04”**。
* 27941809078c is the IMAGE ID of Ubuntu latest Docker image,
* 27941809078c 是 Ubuntu latest 的 Docker 镜像的<ruby>镜像 ID<rt>IMAGE ID</rt></ruby>
* 20fffa419e3a is the image id of Ubuntu 20.04 Docker image
* 20fffa419e3a 是 Ubuntu 20.04 的 Docker 镜像的镜像 ID
* and `e66264b98777` is the image id of Alpine latest Docker image.
* 而 `e66264b98777` 是 Alpine latest 的 Docker 镜像的镜像 ID。
##### 4.1. 使用<ruby>标签<rt>Tag</rt></ruby>运行容器
下载选择好的 Docker 镜像后,运行下面的命令来启动 Docker 容器,并且通过它的<ruby>标签<rt>TAG</rt></ruby>进行连接。
```
$ sudo docker run -t -i ubuntu:latest /bin/bash
```
或者,
```
$ sudo docker run -it ubuntu:latest /bin/bash
```
这里,
* -t在 Ubuntu 容器内分配一个伪终端。
* -i通过从容器获取一个便准输入STDIN允许我们创建一个可交互的连接。
* ubuntu:latest标签为“latest”的 Ubuntu docker 镜像。
* /bin/bash新容器的 BASH shell。这个是可选项。如果你不加 shell 的话,默认的 shell 会被分配给容器。
启动容器后,会自动进入容器的 shell命令行
![Run Containers Using Tag][8]
基于最新 Ubuntu 镜像的容器现在已经启动了。所有的新容器都会被赋予一个名字和唯一的 ID。从上面的输出可以看到那个 Ubuntu 容器的 ID 是 **2f2a5b826762**。一会儿我们会看到从哪找到容器的名字。
现在就可以在容器里面工作了。当你完成容器内的工作后,你可以回到主机操作系统的终端(在我这个例子中,操作系统是 Ubuntu 22.04 LTS而不需要关掉容器客户机
##### 4.2. 从运行中的容器中分离
使用 **CTRL+P** 然后 **CTRL+Q** 就可以从运行中的容器分离(不需要关闭)。
现在,你就回到了你原来的主机的终端窗口。请注意,容器还在后台运行中,我们并没有关掉它。
##### 4.3. 使用镜像 ID 运行容器
另一种启动容器并且连接进去的方式是通过使用镜像 ID像下面这样
```
$ sudo docker run -it 20fffa419e3a /bin/bash
```
这里,
* 20fffa419e3a - 镜像 id
**CTRL+P** 然后 **CTRL+Q** 可以从当前容器中分离回到主机系统的终端。我们只是从容器中分离,但是没有让它停止。容器仍然在后台运行中。
##### 4.4. 在分离模式中运行容器
在前面的小结中,我们启动了一个容器并且立刻连接了进去。然后当容器中的工作结束后,我们从容器中分离了出来
你也可以在分离模式(不需要自动连接进去)中启动容器
在后台运行一个容器,输入命令:
```
$ sudo docker run -it -d alpine:latest
```
**输出结果:**
```
d74f2ceb5f3ad2dbddb0b26e372adb14efff91e75e7763418dbd12d1d227129d
```
上面输出结果的前 12 字符代表的是容器的 ID
通过 `docker ps` 命令,你可以验证容器是否在运行:
```
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d74f2ceb5f3a alpine:latest "/bin/sh" 3 seconds ago Up 2 seconds zen_pascal
```
![Run Containers In Background][9]
从上面个的输出结果中可以看到,我们创建了一个 Alpine 容器,但是还没有连接进去。
如果你想连接进去,很简单,运行:
```
$ sudo docker attach d74f2ceb5f3a
```
#### 5. 查看运行中的容器
查看运行中的容器,运行下面的命令:
```
$ sudo docker ps
```
**输出结果:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f7e04eed577e 20fffa419e3a "/bin/bash" 6 minutes ago Up 6 minutes brave_mclean
2f2a5b826762 ubuntu:latest "/bin/bash" 18 minutes ago Up 18 minutes hungry_leavitt
```
![View Running Containers][10]
这里,
* f7e04eed577e 是由镜像 “2f2a5b826762” 创建的 Ubuntu 容器的 ID。并且“brave_mclean”是这个容器的名字。
* 2f2a5b826762 是由镜像 “ubuntulatest” 创建的 Ubuntu 容器的 ID。并且“hungry_leavitt” 是这个容器的名字。
当一个新容器被创建后,一个唯一的 ID 和名字会赋给它,这样我们就能通过它的 ID 和名字来连接它。
**注意:** 请注意**容器 ID 和 Docker 镜像 ID 是不同的**。
列出所有可用的(运行或者停止)容器,运行:
```
$ sudo docker ps -a
```
#### 6. 从运行中的容器分离或连接
首先,通过 `docker ps` 命令找到容器的 ID。
```
$ sudo docker ps
```
然后,运行 `docker attach` 命令连接到运行中的容器。
```
$ sudo docker attach <container-id>
```
比如像下面这样,我要连接到 ID 为 “f7e04eed577e” 的容器:
```
$ sudo docker attach f7e04eed577e
```
你也可以通过使用它的名字连接到一个容器。
```
$ sudo docker attach brave_mclean
```
现在你就登录到这个容器了。
想要从容器分离,只要按 **CTRL+P** 然后 **CTRL+Q**
#### 7. 启动,重启,暂停和终止容器。
你可以使用容器的名字或 ID 来启动,重启,暂停或者终止一个 Docker 容器。
首先,通过 `docker ps -a` 命令找到容器的名字或 ID。
![Find Container ID And Name][11]
现在,通过使用 `docker start` 命令,加上名字或 ID你可以启动一个容器像下面这样
```
$ sudo docker start modest_cray
```
```
$ sudo docker start 10615254bb45
```
用空格隔开,就可以**启动多个容器**,像下面这样:
```
$ sudo docker start 24b5ee8c3d3a 56faac6d20ad d74f2ceb5f3a
```
优雅的重启一个运行中的容器,运行:
```
$ sudo docker start 10615254bb45
```
暂停一个运行中的容器:
```
$ sudo docker pause 10615254bb45
```
把暂停的容器恢复过来:
```
$ sudo docker unpause 10615254bb45
```
直到其它容器都停止前,阻塞一个容器:
```
$ sudo docker wait 10615254bb45
```
我们可以很容易地通过使用它的名字或 ID 来终止一个容器。如果你已经在容器的 shell 里了,只需要运行下面的命令就可以非常简单的终止:
```
# exit
```
你也可以使用下面的命令从 Docker 的主机系统中终止(关闭容器)容器:
```
$ sudo docker stop 10615254bb45
```
用空格隔开,你可以退出多个容器,像下面这样。
```
$ sudo docker stop 35b5ee8c3d3a 10615254bb45
```
在退出容器之后,通过列出所有容器的命令来确保它确实被终止了:
```
$ sudo docker ps
```
#### 8. <ruby>强行关闭<rt>Kill</rt></ruby> Docker 容器
docker stop 命令可以非常优雅的关掉运行中的容器。有时候,你可能卡在一个没有响应的容器,或者你想强制关掉容器。
通过给一个运行中的容器发送 `SIGKILL` 来强行关闭容器,运行:
```
$ sudo docker kill 10615254bb45
```
#### 9. 在关闭容器后自动删除他们
也许你想测试一个容器,然后当你完成在容器中的工作就把它删掉。如果是这样,通过使用 `--rm` 标签在关闭后自动删掉容器:
```
$ sudo docker run -it --rm debian:latest
```
当你从容器中退出,它会自动被删掉。
![Automatically Delete Containers][12]
从上面的结果可以看到,我先创建了一个新的 Debian 容器。当我退出这个容器的时候,它就被自动删掉了。`docker ps -a` 命令的输出结果显示Debian 容器现在不存在。
#### 10. 给容器命名
如果你再看一下之前命令的输出结果当你启动一个容器的时候每个容器都被赋予了一个随机的名字。如果你不命名你的容器Docker 会自动替你给他们命名。
现在看一下下面的例子:
```
$ sudo docker run -it -d alpine:latest
2af79e97a825c91bf374b4862b9e7c22fc22acd1598005e8bea3439805ec335d
```
```
$ sudo docker run -it -d alpine:latest
80b53b7e661d33696b65c78267fc3f067b6100799c925910db4721963e3fae0a
```
```
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
80b53b7e661d alpine:latest "/bin/sh" 3 seconds ago Up 2 seconds bold_margulis
2af79e97a825 alpine:latest "/bin/sh" 6 seconds ago Up 5 seconds recursing_taussig
```
从上面的结果可以看到,尽管我用同一个 docker image 创建了两个容器,它们获得了不同的 ID 和名字。
如果你想给容器赋一个不变的名字,使用 `--name` 标签,像下面这样:
```
$ sudo docker run -it -d --name ostechnix_alpine alpine:latest
```
上面的命令会在分离模式中创建一个叫做 **ostechnix_alpine** 的新容器。
我们看一下当前运行的容器列表:
```
$ sudo docker ps
```
**输出结果:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
397111fac537 alpine:latest "/bin/sh" 2 seconds ago Up 2 seconds ostechnix_alpine
80b53b7e661d alpine:latest "/bin/sh" 7 minutes ago Up 7 minutes bold_margulis
2af79e97a825 alpine:latest "/bin/sh" 7 minutes ago Up 7 minutes recursing_taussig
```
![Assign Name To Containers][13]
注意到上面输出结果中的第一个容器的名字了吗?对了,我们给这个容器分配了一个自定义的名字(也就是 `ostechnix_alpine`)。
给容器分配自定义的名字可以给我们带来其他好处。只要看一下容器的名字,我们就能很容易的确定那个容器里面安装了什么。
#### 11. 构建自定义 Docker 镜像
Docker 不仅仅是下载和使用已存在的容器。你也可以创建自己的自定义 docker 镜像。
现在我们开始一个 Ubuntu 容器:
```
$ sudo docker run -it ubuntu:latest
```
现在,你会进入到容器的 shell。
然后,在容器中,你可以安装任何的软件或者做你想做的事情。
比如,我们在容器中安装 “Apache web server**。
```
# apt update
# apt install apache2
```
相似地,在容器中,可以根据自己的需要安装和测试软件。
完成以后,从容器分离(不要退出)回到主机系统的 shell。不要终止或者关闭容器。使用 **CTRL+P** 然后 **CTRL+Q** 从容器中分离,这样不会关闭容器。
在你的 Docker 主机的终端,运行下面的命令来找到容器 ID
```
$ sudo docker ps
```
最后,创建一个当前运行中的容器的 Docker image使用命令
```
$ sudo docker commit 377e6d77ebb5 ostechnix/ubuntu_apache
```
**输出结果**
```
sha256:bc5e5f95ca592a3585fda2c5a40ec30c98e292046ef70390a2c3b7863cc6f7c1
```
这里,
* 377e6d77ebb5  Ubuntu 容器的 ID。
* ostechnix  创建容器的用户的名字。
* ubuntu_apache 用户 ostechnix 创建的 docker image 的名字。
现在我们查看一下新的 Docker 镜像是否被创建了,使用下面的命令:
```
$ sudo docker images
```
**输出结果:**
```
ostechnix/ubuntu_apache
```
![Build Custom Docker Images][14]
从上面给的结果中可以看到,从运行中的容器创建的新 Docker 镜像已经在我们的 Docker 主机系统中了。
现在你就可以从这个新的 Docker 镜像创建行容器了,用之前的命令:
```
$ sudo docker run -it ostechnix/ubuntu_apache
```
#### 12. 移除容器
当你在 Docker 容器中完成所有开发后,如果你不需要他们了,你可以删掉他们。
为此,首先我们需要终止(关闭)运行中的容器。
用这个命令来看一下运行中的容器:
```
$ sudo docker ps
```
**输出结果:**
```
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
377e6d77ebb5 ubuntu:latest "bash" 7 minutes ago Up 7 minutes elegant_beaver
```
通过使用它的 ID 来终止运行中的容器:
```
$ sudo docker stop 377e6d77ebb5
```
现在,使用这个命令删除容器:
```
$ sudo docker rm 377e6d77ebb5
```
同样,如果不再需要所有的容器,关闭并删除它们。
一个一个的删除多个容器会是一项繁琐的工作。所以,我们可以把所有停止的容器一次性删掉,运行:
```
$ sudo docker container prune
```
**Y** 然后回车键,这些容器就被删掉了。
```
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Deleted Containers:
397111fac5374921b974721ee646b2d5fbae61ca9c6e8b90fbf47952f382a46b
80b53b7e661d33696b65c78267fc3f067b6100799c925910db4721963e3fae0a
[...]
Total reclaimed space: 176B
```
![Delete Containers][15]
这个命令只有在最新版中有效。
使用下面的命令来验证是否所有容器都被删除了:
```
$ sudo docker ps -a
```
如果看不到任何结果,说明所有容器被删掉了。
#### 13. 删除 Docker 镜像
记住,在删除所有镜像之前,首先要删掉所有从那些镜像创建的容器。
当你删掉容器后,你可以删掉你不需要的 Docker 镜像。
列出所有下载的 Docker 镜像:
```
$ sudo docker images
```
**输出结果:**
```
REPOSITORY TAG IMAGE ID CREATED SIZE
ostechnix/ubuntu_apache latest bc5e5f95ca59 14 minutes ago 229MB
debian latest d2780094a226 11 days ago 124MB
ubuntu latest 27941809078c 3 weeks ago 77.8MB
ubuntu 20.04 20fffa419e3a 3 weeks ago 72.8MB
alpine latest e66264b98777 5 weeks ago 5.52MB
```
从上面可以看到,在我们的主机上有 5 个 Docker 镜像。
通过使用镜像 ID 来删掉它们:
```
$ sudo docker rmi ce5aa74a48f1
```
**输出结果:**
```
Untagged: ostechnix/ubuntu_apache:latest
Deleted: sha256:bc5e5f95ca592a3585fda2c5a40ec30c98e292046ef70390a2c3b7863cc6f7c1
Deleted: sha256:a8e4797160a2b2d33d8bd1bd67e008260c022b3a53fbcc198b2b74d9eae5961d
```
同样,删除其他所有 Docker 镜像。
删掉所有未运行的容器,所有镜像,构建的缓存,所有网络,运行:
```
$ sudo docker system prune -a
```
使用这个命令的时候要注意,它会删掉所有没有使用的容器,网络,镜像(<ruby>挂起<rt>dangling</rt></ruby><ruby>未使用<rt>unreferenced</rt></ruby>
![Delete Everything In Docker][16]
默认情况下,即使当前没有容器在使用<ruby>磁盘容量<rt>volumes</rt></ruby>,为防止重要数据被删除,<ruby>磁盘容量<rt>volumes</rt></ruby>也不会被删除
如果你想删掉所有东西,包括分配的容量,使用 `--volumes` 标签。
```
$ sudo docker system prune -a --volumes
```
### Docker 问题汇总
Docker 不会允许你删除 Docker 镜像,如果这些镜像正在被运行或停止的容器使用。
比如,当我尝试从一个以前的 Ubuntu 服务器上删除 ID 为 **b72889fa879c** 的 Docker 镜像。我会得到下面的错误:
```
Error response from daemon: conflict: unable to delete b72889fa879c (must be forced) - image is being used by stopped container dde4dd285377
```
这是因为你想删除的 Docker 镜像正在被另一个容器使用。
所以,我们先查看一下运行中的容器,使用命令:
```
$ sudo docker ps
```
**输出结果:**
![Show running docker containers][17]
噢,没有运行中的容器。
我们在看一下所有的容器(运行和停止的),用这个命令:
```
$ sudo docker ps -a
```
**输出结果:**
![Show running and stopped docker containers][18]
可以看到,仍然有停止的容器在使用其中一个 Docker 镜像。所以,我们先把所有容器删掉。
**比如:**
```
$ sudo docker rm 12e892156219
```
类似地,向上面那样,用对应容器的 ID 将他们都删除。
当把所有容器删掉后,移除掉 Docker 镜像。
**比如:**
```
$ sudo docker rmi b72889fa879c
```
就这么简单。现在确认是否还有其他 Docker 镜像在主机上,使用命令:
```
$ sudo docker images
```
你现在应该不再有任何 docker 镜像了。
### 总结
在这篇全面的 Docker 入门教程中,我们解释了 Docker 的基本操作,比如创建,运行,搜索,删除容器,还有从 Docker 镜像构建你自己的容器。同时,我们也解释了如何在不需要 Docker 容器和镜像的时候删除它们。
希望你现在对 **Docker 的使用** 有一个基本的了解
更多细节,请参考这篇教程最下面的官方资源链接,或者在下面的评论区进行评论。
**相关资料:**
* [Docker 官网][19]
* [Docker 文档][20]
--------------------------------------------------------------------------------
via: https://ostechnix.com/getting-started-with-docker/
作者:[sk][a]
选题:[lkxed][b]
译者:[MCGA](https://github.com/Yufei-Yan)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://ostechnix.com/author/sk/
[b]: https://github.com/lkxed
[1]: https://ostechnix.com/install-docker-almalinux-centos-rocky-linux/
[2]: https://ostechnix.com/install-docker-ubuntu/
[3]: https://hub.docker.com/
[4]: https://ostechnix.com/wp-content/uploads/2022/07/Search-Docker-Images.png
[5]: https://ostechnix.com/wp-content/uploads/2022/07/Download-Docker-Images.png
[6]: https://ostechnix.com/wp-content/uploads/2022/07/List-Docker-Images.png
[7]: https://ostechnix.com/wp-content/uploads/2022/07/Docker-Image-Tag-and-ID.png
[8]: https://ostechnix.com/wp-content/uploads/2022/07/Run-Containers-Using-Tag-1.png
[9]: https://ostechnix.com/wp-content/uploads/2022/07/Run-Containers-In-Background-1.png
[10]: https://ostechnix.com/wp-content/uploads/2022/07/View-Running-Containers.png
[11]: https://ostechnix.com/wp-content/uploads/2022/07/Find-Container-ID-And-Name.png
[12]: https://ostechnix.com/wp-content/uploads/2022/07/Automatically-Delete-Containers.png
[13]: https://ostechnix.com/wp-content/uploads/2022/07/Assign-Name-To-Containers.png
[14]: https://ostechnix.com/wp-content/uploads/2022/07/Build-Custom-Docker-Images.png
[15]: https://ostechnix.com/wp-content/uploads/2022/07/Delete-Containers.png
[16]: https://ostechnix.com/wp-content/uploads/2022/07/Delete-Everything-In-Docker.png
[17]: https://ostechnix.com/wp-content/uploads/2016/04/sk@sk-_005-1-1.jpg
[18]: https://ostechnix.com/wp-content/uploads/2016/04/sk@sk-_006-1.jpg
[19]: https://www.docker.com/
[20]: https://docs.docker.com/