From 23bc8f09da733c0ef516875531816cbbad6b88d9 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sat, 19 Oct 2019 22:50:40 +0800 Subject: [PATCH 01/10] PRF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lnrCoder 恭喜你完成了第一篇翻译! --- ...tall and Configure PostgreSQL on Ubuntu.md | 88 +++++++++---------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/translated/tech/20190805 How to Install and Configure PostgreSQL on Ubuntu.md b/translated/tech/20190805 How to Install and Configure PostgreSQL on Ubuntu.md index 3da0f81114..6d91dcedef 100644 --- a/translated/tech/20190805 How to Install and Configure PostgreSQL on Ubuntu.md +++ b/translated/tech/20190805 How to Install and Configure PostgreSQL on Ubuntu.md @@ -1,6 +1,6 @@ [#]: collector: (lujun9972) [#]: translator: (lnrCoder) -[#]: reviewer: ( ) +[#]: reviewer: (wxy) [#]: publisher: ( ) [#]: url: ( ) [#]: subject: (How to Install and Configure PostgreSQL on Ubuntu) @@ -10,19 +10,19 @@ 如何在 Ubuntu 上安装和配置 PostgreSQL ====== -_**本教程中,你将学习如何在 Ubuntu Linux 上安装和使用开源数据库 PostgreSQL。**_ +> 本教程中,你将学习如何在 Ubuntu Linux 上安装和使用开源数据库 PostgreSQL。 -[PostgreSQL][1] (又名 Postgres) 是一个功能强大的,免费的开源关系型数据库管理系统 ([RDBMS][2]) 其 在可靠性、稳定性、性能方面获得了业内极高的声誉 。它旨在处理各种规模的任务。它是跨平台的,而且是 [macOS Server][3] 的默认数据库。 +[PostgreSQL][1] (又名 Postgres) 是一个功能强大的自由开源的关系型数据库管理系统 ([RDBMS][2]) ,其在可靠性、稳定性、性能方面获得了业内极高的声誉。它旨在处理各种规模的任务。它是跨平台的,而且是 [macOS Server][3] 的默认数据库。 如果你喜欢简单易用的 SQL 数据库管理器,那么 PostgreSQL 将是一个正确的选择。PostgreSQL 对标准的 SQL 兼容的同时提供了额外的附加特性,同时还可以被用户大量扩展,用户可以添加数据类型、函数并执行更多的操作。 -之前我曾论述过 [在 Ubuntu 上安装 MySQL][4]。在本文中,我将向你展示如何安装和配置 PostgreSQL,以便你随时可以使用它来满足你的任何需求。 +之前我曾论述过 [在 Ubuntu 上安装 MySQL][4]。在本文中,我将向你展示如何安装和配置 PostgreSQL,以便你随时可以使用它来满足你的任何需求。 ![][5] ### 在 Ubuntu 上安装 PostgreSQL -PostgreSQL 可以从 Ubuntu 主存储库中获取。然而,和许多其他开发工具一样,它可能不是最新版本。 +PostgreSQL 可以从 Ubuntu 主存储库中获取。然而,和许多其它开发工具一样,它可能不是最新版本。 首先在终端中使用 [apt 命令][7] 检查 [Ubuntu 存储库][6] 中可用的 PostgreSQL 版本: @@ -30,7 +30,7 @@ PostgreSQL 可以从 Ubuntu 主存储库中获取。然而,和许多其他开 apt show postgresql ``` -在我的 Ubuntu 18.04 中,它显示 PostgreSQL 的可用版本是 10 (10+190 表示版本 10) 而 PostgreSQL 版本 11 已经发布。 +在我的 Ubuntu 18.04 中,它显示 PostgreSQL 的可用版本是 10(10+190 表示版本 10)而 PostgreSQL 版本 11 已经发布。 ``` Package: postgresql @@ -47,24 +47,22 @@ Origin: Ubuntu #### 方法一:通过 Ubuntu 存储库安装 PostgreSQL -在终端中,使用以下命令安装 PostgreSQL +在终端中,使用以下命令安装 PostgreSQL: ``` sudo apt update sudo apt install postgresql postgresql-contrib ``` -根据提示输入你的密码,依据于你的网速情况,程序将在几秒到几分钟安装完成。 说到这一点 ,随时检查 [Ubuntu 中的各种网络带宽][8]。 +根据提示输入你的密码,依据于你的网速情况,程序将在几秒到几分钟安装完成。说到这一点,随时检查 [Ubuntu 中的各种网络带宽][8]。 -什么是 postgresql-contrib? +> 什么是 postgresql-contrib? -postgresql-contrib 或者说 contrib 包,包含一些不属于 PostgreSQL 核心包的实用工具和功能。在大多数情况下,最好将 contrib 包与 PostgreSQL 核心一起安装。 - -推荐阅读 [解决 gvfsd-smb-browser 在 Ubuntu 16.04 中占用 100% CPU][9] +> postgresql-contrib 或者说 contrib 包,包含一些不属于 PostgreSQL 核心包的实用工具和功能。在大多数情况下,最好将 contrib 包与 PostgreSQL 核心一起安装。 #### 方法二:在 Ubuntu 中安装最新版本的 PostgreSQL 11 -要安装 PostgreSQL 11, 你需要在 sources.list 中添加官方 PostgreSQL 存储库和证书,然后从那里安装它。 +要安装 PostgreSQL 11, 你需要在 `sources.list` 中添加官方 PostgreSQL 存储库和证书,然后从那里安装它。 不用担心,这并不复杂。 只需按照以下步骤。 @@ -74,7 +72,7 @@ postgresql-contrib 或者说 contrib 包,包含一些不属于 PostgreSQL 核 wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - ``` -现在,使用以下命令添加存储库。如果你使用的是 Linux Mint,则必须手动替换你的 Mint 所基于的 Ubuntu 版本号 +现在,使用以下命令添加存储库。如果你使用的是 Linux Mint,则必须手动替换你的 Mint 所基于的 Ubuntu 版本号: ``` sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list' @@ -87,47 +85,47 @@ sudo apt update sudo apt install postgresql postgresql-contrib ``` -PostgreSQL GUI 应用程序 +> PostgreSQL GUI 应用程序 -你也可以安装用于管理 PostgreSQL 数据库的 GUI 应用程序 (pgAdmin): +> 你也可以安装用于管理 PostgreSQL 数据库的 GUI 应用程序(pgAdmin): -_sudo apt install pgadmin4_ +> `sudo apt install pgadmin4` ### PostgreSQL 配置 -你可以通过执行以下命令来检查 **PostgreSQL** 是否正在运行: +你可以通过执行以下命令来检查 PostgreSQL 是否正在运行: ``` service postgresql status ``` -通过 **service** 命令,你可以 **启动**, **关闭** 或 **重启** **postgresql**。输入 **service postgresql** 并按 **回车** 将列出所有选项。现在,登录用户。 +通过 `service` 命令,你可以启动、关闭或重启 `postgresql`。输入 `service postgresql` 并按回车将列出所有选项。现在,登录该用户。 -默认情况下,PostgreSQL 会创建一个拥有所权限的特殊用户 postgres 。要实际使用 PostgreSQL,你必须先登录该账户: +默认情况下,PostgreSQL 会创建一个拥有所权限的特殊用户 `postgres`。要实际使用 PostgreSQL,你必须先登录该账户: ``` sudo su postgres ``` -你的提示应更改为类似于以下的内容: +你的提示符会更改为类似于以下的内容: ``` postgres@ubuntu-VirtualBox:/home/ubuntu$ ``` -现在,使用 **psql** 来启动 **PostgreSQL Shell** : +现在,使用 `psql` 来启动 PostgreSQL Shell: ``` psql ``` -你应该会收到如下提示: +你应该会看到如下提示符: ``` postgress=# ``` -你可以输入 **\q** 以**退出**,输入 **\?** 获取**帮助**。 +你可以输入 `\q` 以退出,输入 `\?` 获取帮助。 要查看现有的所有表,输入如下命令: @@ -135,59 +133,59 @@ postgress=# \l ``` -输出内容类似于下图所示 (单击 **q** 键退出该视图): +输出内容类似于下图所示(单击 `q` 键退出该视图): ![PostgreSQL Tables][10] -使用 **\du** 命令,你可以查看 **PostgreSQL 用户**: +使用 `\du` 命令,你可以查看 PostgreSQL 用户: ![PostgreSQLUsers][11] -你可以使用以下命令更改任何用户(包括 postgres)的密码: +你可以使用以下命令更改任何用户(包括 `postgres`)的密码: ``` ALTER USER postgres WITH PASSWORD 'my_password'; ``` -**注意:** _将 **postgres** 替换为用户名 **my_password** 替换为所需要的密码。_ 另外,不要忘记每条命令后面的 **;** (分号)。 +**注意:**将 `postgres` 替换为你要更改的用户名,`my_password` 替换为所需要的密码。另外,不要忘记每条命令后面的 `;`(分号)。 -建议你另外创建一个用户(不建议使用默认的 **postgres** 用户)。为此,请使用一下命令: +建议你另外创建一个用户(不建议使用默认的 `postgres` 用户)。为此,请使用以下命令: ``` CREATE USER my_user WITH PASSWORD 'my_password'; ``` -运行 **\du**,你将看到该用户,但是,**my_user** 用户没有任何的属性。来让我们将它添加到**超级用户**: +运行 `\du`,你将看到该用户,但是,`my_user` 用户没有任何的属性。来让我们给它添加超级用户权限: ``` ALTER USER my_user WITH SUPERUSER; ``` -你可以使用以下命令 **删除用户** : +你可以使用以下命令删除用户: ``` DROP USER my_user; ``` -要使用其他用户登录,使用 **\q** 命令退出,然后使用以下命令登录: +要使用其他用户登录,使用 `\q` 命令退出,然后使用以下命令登录: ``` psql -U my_user ``` -你可以使用 **-d** 参数直接连接数据库: +你可以使用 `-d` 参数直接连接数据库: ``` psql -U my_user -d my_db ``` -你可以使用其他已存在的用户调用 PostgreSQL。例如,我使用 **ubuntu**。要登录,从终端执行以下命名: +你可以使用其他已存在的用户调用 PostgreSQL。例如,我使用 `ubuntu`。要登录,从终端执行以下命名: ``` psql -U ubuntu -d postgres ``` -**注意:** _你必须指定一个数据库(默认情况下,它将尝试将你连接到与登录的用户名相同的数据库)。_ +**注意:**你必须指定一个数据库(默认情况下,它将尝试将你连接到与登录的用户名相同的数据库)。 如果遇到如下错误: @@ -195,13 +193,13 @@ psql -U ubuntu -d postgres psql: FATAL: Peer authentication failed for user "my_user" ``` -确保以正确的用户身份登录,并使用管理员权限编辑 **/etc/postgresql/11/main/pg_hba.conf** +确保以正确的用户身份登录,并使用管理员权限编辑 `/etc/postgresql/11/main/pg_hba.conf`: ``` sudo vim /etc/postgresql/11/main/pg_hba.conf ``` -**注意:** _用你的版本替换 **11** (例如 **10**)._ +**注意:**用你的版本替换 `11`(例如 `10`)。 对如下所示的一行进行替换: @@ -215,23 +213,19 @@ local all postgres peer local all postgres md5 ``` -然后重启 **PostgreSQL**: +然后重启 PostgreSQL: ``` sudo service postgresql restart ``` -使用 **PostgreSQL** 与使用其他 **SQL** 类型的数据库相同。由于本文旨在帮助你进行初步的设置,因此不涉及具体的命令。不过,这里有个 [非常有用的要点][12] 可供参考! 另外, 手册 (**man psql**) 和 [文档][13] 也非常有用。 +使用 PostgreSQL 与使用其他 SQL 类型的数据库相同。由于本文旨在帮助你进行初步的设置,因此不涉及具体的命令。不过,这里有个 [非常有用的要点][12] 可供参考! 另外, 手册(`man psql`)和 [文档][13] 也非常有用。 -建议阅读 [如何][14] 在 Ubuntu 中与 Dropbox 共享和同步任何文件夹。 +### 总结 -**总结** +阅读本文有望指导你完成在 Ubuntu 系统上安装和准备 PostgreSQL 的过程。如果你不熟悉 SQL,你应该阅读 [基本的 SQL 命令][15]。 -阅读本文有望指导你完成在 Ubuntu 系统上安装和准备 PostgreSQL 的过程。如果你不熟悉 SQL,你应该阅读 [基本的 SQL 命令][15] - -[基本的 SQL 命令][15] - -如果您有任何问题或疑惑,请随时在评论部分提出。 +如果你有任何问题或疑惑,请随时在评论部分提出。 -------------------------------------------------------------------------------- @@ -240,7 +234,7 @@ via: https://itsfoss.com/install-postgresql-ubuntu/ 作者:[Sergiu][a] 选题:[lujun9972][b] 译者:[lnrCoder](https://github.com/lnrCoder) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e671b3759a323c00e1f86153862def7c88bcd055 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sat, 19 Oct 2019 22:52:31 +0800 Subject: [PATCH 02/10] PUB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lnrCoder 本文首发地址: https://linux.cn/article-11480-1.html 你的 LCTT 专页地址: https://linux.cn/lctt/lnrCoder 请注册以领取你的 LCCN : https://lctt.linux.cn/ --- ...90805 How to Install and Configure PostgreSQL on Ubuntu.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/tech => published}/20190805 How to Install and Configure PostgreSQL on Ubuntu.md (99%) diff --git a/translated/tech/20190805 How to Install and Configure PostgreSQL on Ubuntu.md b/published/20190805 How to Install and Configure PostgreSQL on Ubuntu.md similarity index 99% rename from translated/tech/20190805 How to Install and Configure PostgreSQL on Ubuntu.md rename to published/20190805 How to Install and Configure PostgreSQL on Ubuntu.md index 6d91dcedef..e89257812d 100644 --- a/translated/tech/20190805 How to Install and Configure PostgreSQL on Ubuntu.md +++ b/published/20190805 How to Install and Configure PostgreSQL on Ubuntu.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (lnrCoder) [#]: reviewer: (wxy) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11480-1.html) [#]: subject: (How to Install and Configure PostgreSQL on Ubuntu) [#]: via: (https://itsfoss.com/install-postgresql-ubuntu/) [#]: author: (Sergiu https://itsfoss.com/author/sergiu/) From 16cb6d0dfe8856f42ef5f736291af5cc41c04530 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sat, 19 Oct 2019 23:23:37 +0800 Subject: [PATCH 03/10] PRF @geekpi --- ... 10 open source video players for Linux.md | 81 +++++++------------ 1 file changed, 31 insertions(+), 50 deletions(-) diff --git a/translated/talk/20191009 Top 10 open source video players for Linux.md b/translated/talk/20191009 Top 10 open source video players for Linux.md index 67eab29960..8735a7b408 100644 --- a/translated/talk/20191009 Top 10 open source video players for Linux.md +++ b/translated/talk/20191009 Top 10 open source video players for Linux.md @@ -1,8 +1,8 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-11481-1.html) [#]: subject: (Top 10 open source video players for Linux) [#]: via: (https://opensourceforu.com/2019/10/top-10-open-source-video-players-for-linux/) [#]: author: (Stella Aldridge https://opensourceforu.com/author/stella-aldridge/) @@ -10,15 +10,15 @@ Linux 中的十大开源视频播放器 ====== -[![][1]][2] +![][1] -_选择合适的视频播放器有助于确保你获得最佳的观看体验,并为你提供[创建视频网站][3]的工具。你甚至可以根据个人喜好自定义正在观看的视频。_ +> 选择合适的视频播放器有助于确保你获得最佳的观看体验,并为你提供[创建视频网站][3]的工具。你甚至可以根据个人喜好自定义正在观看的视频。 -因此,为了帮助你挑选适合你需求的最佳播放器,我们列出了 Linux 中十大开源播放器。 +因此,为了帮助你挑选适合你需求的最佳播放器,我们列出了 Linux 中的十大开源播放器。 让我们来看看: -**1\. XBMC – Kodi 媒体中心** +### 1、XBMC – Kodi 媒体中心 这是一个灵活的跨平台播放器,核心使用 C++ 编写,并提供 Python 脚本作为附加组件。使用 Kodi 的好处包括: @@ -28,11 +28,9 @@ _选择合适的视频播放器有助于确保你获得最佳的观看体验, * 有很多不错的附加组件,如视频和音频流插件、主题、屏幕保护程序等 * 它支持多种格式,如 MPEG-1、2、4、RealVideo、HVC、HEVC 等 +### 2、VLC 媒体播放器 - -**2\. VLC 媒体播放器** - -由于该播放器在一系列操作系统上具有令人印象深刻的功能和可用性,他在列表上是理所当然的。它使用 C、C++ 和 Objective C 编写,用户无需使用插件,这要归功于它对解码库的广泛支持。VLC 媒体播放器的优势包括: +由于该播放器在一系列操作系统上具有令人印象深刻的功能和可用性,它出现在列表上是理所当然的。它使用 C、C++ 和 Objective C 编写,用户无需使用插件,这要归功于它对解码库的广泛支持。VLC 媒体播放器的优势包括: * 在 Linux 上支持 DVD 播放器 * 能够播放 .iso 文件 @@ -40,54 +38,45 @@ _选择合适的视频播放器有助于确保你获得最佳的观看体验, * 可以直接从 U 盘或外部驱动器运行 * API 支持和浏览器支持(通过插件) - - -**3\. Bomi(CMPlayer)** +### 3、Bomi(CMPlayer) 这个灵活和强大的播放器被许多普通用户选择,它的优势有: - * 易于使用的图形用户界面 (GUI) + * 易于使用的图形用户界面(GUI) * 令人印象深刻的播放能力 - * 恢复播放的选项 + * 可以恢复播放 * 支持字幕,可以渲染多个字幕文件 +![][4] +### 4、Miro 音乐与视频播放器 -**[![][4]][5] -4\. Miro Music and Video Player** - -以前被称为 Democracy Player (DTV), Miro 由分享文化基金会(Participatory Culture Foundation)重新开发,是一个不错的跨平台音频视频播放器。令人印象深刻,因为: +以前被称为 Democracy Player(DTV),Miro 由参与文化基金会Participatory Culture Foundation重新开发,是一个不错的跨平台音频视频播放器。令人印象深刻,因为: * 支持一些高清音频和视频 * 提供超过 40 种语言版本 - * 可以播放多种文件格式,例如,QuickTime、WMV、MPEG 文件、音频视频接口 (AVI)、XVID + * 可以播放多种文件格式,例如,QuickTime、WMV、MPEG 文件、AVI、XVID * 一旦可用,可以自动通知用户并下载视频 +### 5、SMPlayer - -**5\. SMPlayer** - -这个跨平台的媒体播放器,只使用 C++ 的 Qt 库编写,它是一个强大的,多功能播放器。我们喜欢它,因为: +这个跨平台的媒体播放器,只使用 C++ 的 Qt 库编写,它是一个强大的多功能播放器。我们喜欢它,因为: * 有多语言选择 * 支持所有默认格式 - * 支持 EDL 文件,你可以配置从 Internet 获取的字幕 + * 支持 EDL 文件,你可以配置从互联网获取的字幕 * 可从互联网下载的各种皮肤 * 倍速播放 - - -**6\. MPV Player** +### 6、MPV 播放器 它用 C、Objective-C、Lua 和 Python 编写,免费、易于使用,并且有许多新功能,便于使用。主要加分是: * 可以编译为一个库,公开客户端 API,从而增强控制 * 允许媒体编码 - * 平滑运动 + * 平滑动画 - - -**7\. Deepin Movie** +### 7、Deepin Movie 此播放器是开源媒体播放器的一个极好的例子,它有很多优势,包括: @@ -95,45 +84,37 @@ _选择合适的视频播放器有助于确保你获得最佳的观看体验, * 各种格式的视频文件可以通过这个播放器轻松播放 * 流媒体功能能让用户享受许多在线视频资源 +### 8、Gnome 视频 +以前称为 Totem,这是 Gnome 桌面环境的播放器。 -**8\. Gnome Videos** - -以前称为 Totem,这是 Gnome 桌面环境选择的播放器。 -完全用 C 编写,使用 GStreamer 多媒体框架构建,另外的版本(>2.7.1)使用 xine 作为后端。它是很棒的,因为: +完全用 C 编写,使用 GStreamer 多媒体框架构建,高于 2.7.1 的版本使用 xine 作为后端。它是很棒的,因为: 它支持大量的格式,包括: - * Supports for direct video playback from Internet channels such as Apple * SHOUTcast、SMIL、M3U、Windows 媒体播放器格式等 * 你可以在播放过程中调整灯光设置,如亮度和对比度 * 加载 SubRip 字幕 * 支持从互联网频道(如 Apple)直接播放视频 - - -**9\. Xine Multimedia Player** +### 9、Xine 多媒体播放器 我们列表中用 C 编写的另外一个跨平台多媒体播放器。这是一个全能播放器,因为: - * 它支持物理媒体以及视频设备。3gp, Matroska(MKV)、 MOV, Mp4、音频格式, + * 它支持物理媒体以及视频设备。3gp、MKV、 MOV、Mp4、音频格式 * 网络协议,V4L、DVB 和 PVR 等 * 它可以手动校正音频和视频流的同步 +### 10、ExMPlayer - -**10\. ExMPlayer** - -最后单同样重要的一个,ExMPlayer 是一个惊人的、强大的 MPlayer 的 GUI 前端。它的优点包括: +最后但同样重要的一个,ExMPlayer 是一个惊人的、强大的 MPlayer 的 GUI 前端。它的优点包括: * 可以播放任何媒体格式 * 支持网络流和字幕 * 易于使用的音频转换器 * 高品质的音频提取,而不会影响音质 - - -上面的视频播放器在 Linux 上工作得很好。我们建议你尝试一下,选择一个最适合你的播放器。 +上面这些视频播放器在 Linux 上工作得很好。我们建议你尝试一下,选择一个最适合你的播放器。 -------------------------------------------------------------------------------- @@ -142,7 +123,7 @@ via: https://opensourceforu.com/2019/10/top-10-open-source-video-players-for-lin 作者:[Stella Aldridge][a] 选题:[lujun9972][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/) 荣誉推出 From db547d0f5d951f3455263c0e3be70913e347b5e4 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Sat, 19 Oct 2019 23:23:53 +0800 Subject: [PATCH 04/10] PUB @geekpi https://linux.cn/article-11481-1.html --- .../20191009 Top 10 open source video players for Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20191009 Top 10 open source video players for Linux.md (100%) diff --git a/translated/talk/20191009 Top 10 open source video players for Linux.md b/published/20191009 Top 10 open source video players for Linux.md similarity index 100% rename from translated/talk/20191009 Top 10 open source video players for Linux.md rename to published/20191009 Top 10 open source video players for Linux.md From b40eb56900e3319a4aca8eba3bcaabbf69e3183c Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sun, 20 Oct 2019 00:54:24 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020191020=20Project?= =?UTF-8?q?=20Trident=20Ditches=20BSD=20for=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20191020 Project Trident Ditches BSD for Linux.md --- ...0 Project Trident Ditches BSD for Linux.md | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 sources/tech/20191020 Project Trident Ditches BSD for Linux.md diff --git a/sources/tech/20191020 Project Trident Ditches BSD for Linux.md b/sources/tech/20191020 Project Trident Ditches BSD for Linux.md new file mode 100644 index 0000000000..1197c440e2 --- /dev/null +++ b/sources/tech/20191020 Project Trident Ditches BSD for Linux.md @@ -0,0 +1,85 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Project Trident Ditches BSD for Linux) +[#]: via: (https://itsfoss.com/bsd-project-trident-linux/) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Project Trident Ditches BSD for Linux +====== + +Recently a BSD distribution announced that it was going to rebase on Linux. Yep, you heard me correctly. Project Trident is moving to Void Linux. + +### What is Going on with Project Trident? + +Recently, Project Trident [announced][1] that they had been working behind the scenes to move away from FreeBSD. This is quite a surprising move (and an unprecedented one). + +According to a [later post][2], the move was motivated by long-standing issues with FreeBSD. These issues include “hardware compatibility, communications standards, or package availability continue to limit Project Trident users”. According to a conversation on [Telegram][3], FreeBSD has just updated its build of the Telegram client and it was nine release behind everyone else. + +The lead dev of Project Trident, [Ken Moore][4], is also the main developer of the Lumina Desktop. The [Lumina Desktop][5] has been on hold for a while because the [Project Trident][6] team had to do so much work just to keep their packages updated. (Once they complete the transition to Void Linux, Ken will start working on Lumina again.) + +After much searching and testing, the Project Trident team decided to use [Void Linux][7] as their new base. + +According to the Project Trident team, the move to Void Linux will have the [following benefits][2]: + + * Better GPU support + * Better sound card and streaming support + * Better wireless support + * Bluetooth support for the first time + * Up to date versions of applications + * Faster boot times + * Hybrid EFI/Legacy installation and boot support + + + +### Moving Plans + +![][8] + +Project Trident currently has two different versions available: Trident-stable and Trident-release. Trident-stable is based on FreeBSD 12 and will continue to get updates until January of 2020 with the ports repo being deleted in April of 2020. On the other hand, Trident-release (which is based on FreeBSD 13) will receive no further updates. That ports repo will be deleted in January of 2020. + +The first Void Linux-based releases should be available in January of 2020. Ken said that they might issue an alpha iso or two to show off their progress, but they would be for testing purposes only. + +Currently, Ken said that they are working to port all of their “in-house utilities over to work natively on Void Linux”. Void Linux does not support ZFS-on-root, which is a big part of the BSDs. However, Project Trident is planning to use their knowledge of ZFS to add support for it to Void. + +There will not be a migration path from the FreeBSD-based version to the Void-based version. If you are currently using Project Trident, you will need to backup your `/home/*` directory before performing a clean install of the new version. + +### Final Thoughts + +I’m looking forward to trying out the new Void Linux-based Project Trident. I have installed and used Void Linux in the past. I have also tried out [TrueOS][9] (the precursor of Project Trident). However, I could never get Project Trident to work on my laptop. + +When I was using Void Linux, I ran into two main issues: installing a desktop environment was a pain and the GUI package manager wasn’t that great. Project Trident plans to address these issues. Their original goal was to find an operating system that didn’t come with a desktop environment as default and their distro would add desktop support out-of-the-box. They won’t be able to port the AppCafe package manager to Void because it is a part of TrueOS’ SysAdm utility. They do plan to “develop a new graphical front-end to the XBPS package manager for Void Linux”. + +Interestingly, Void Linux was created by a former NetBSD developer. I asked Ken if that fact influenced their decision. He said, “Actually none! I liked the way that Void Linux was set up and that most/all of the utilities were either MIT or BSD licensed, but I never guessed that it was created by a former NetBSD developer. That definitely helps to explain why Void Linux “feels” more comfortable to me since I have been using FreeBSD exclusively for the last 7 or more years.” + +I’ve seen some people on the web speaking disparagingly of the move to Void Linux. They mentioned that the name changes (from PC-BSD to TrueOS to Project Trident) and the changes in architecture (from FreeBSD to TrueOS/FreeBSD to Void Linux) show that the developers don’t know what they are doing. On the other hand, I believe that Project Trident has finally found its niche where it will be able to grow and blossom. I will be watching the future of Project Trident with much anticipation. You will probably be reading a review of the new version when it is released. + +Have you ever used Project Trident? What is your favorite BSD? Please let us know in the comments below. + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][10]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/bsd-project-trident-linux/ + +作者:[John Paul][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://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://project-trident.org/post/train_changes/ +[2]: https://project-trident.org/post/os_migration/ +[3]: https://t.me/ProjectTrident +[4]: https://github.com/beanpole135 +[5]: https://lumina-desktop.org/ +[6]: https://itsfoss.com/project-trident-interview/ +[7]: https://voidlinux.org/ +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/10/bsd-linux.jpg?resize=800%2C450&ssl=1 +[9]: https://itsfoss.com/trueos-bsd-review/ +[10]: https://reddit.com/r/linuxusersgroup From b4de29153f86543dd2065f0b926e31b582d32cea Mon Sep 17 00:00:00 2001 From: DarkSun Date: Sun, 20 Oct 2019 00:55:16 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E9=80=89=E9=A2=98:=2020191019=20To=20spa?= =?UTF-8?q?ce=20and=20beyond=20with=20open=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sources/tech/20191019 To space and beyond with open source.md --- ...19 To space and beyond with open source.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 sources/tech/20191019 To space and beyond with open source.md diff --git a/sources/tech/20191019 To space and beyond with open source.md b/sources/tech/20191019 To space and beyond with open source.md new file mode 100644 index 0000000000..8bbb552e15 --- /dev/null +++ b/sources/tech/20191019 To space and beyond with open source.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (To space and beyond with open source) +[#]: via: (https://opensource.com/article/19/10/open-source-space-exploration) +[#]: author: (Jaouhari Youssef https://opensource.com/users/jaouhari) + +To space and beyond with open source +====== +Open source projects are helping to satisfy our curiosity about what +lies far beyond Earth's atmosphere. +![Person looking up at the stars][1] + +Carl Sagan once said, "The universe is a pretty big place. If it's just us, seems like an awful waste of space." In that vast desert of seeming nothingness hides some of the most mysterious and beautiful creations humankind ever has—or ever will—witness. + +Our ancient ancestors looked up into the night sky and dreamed about space, just as we do today. Starting with simple, naked-eye observations of the sky and progressing to create [space telescopes][2] that uncover far reaches of the universe, we've come a long way toward understanding and redefining the concepts of time, space, and matter. Our exploration has provided some answers to humanity's enduring questions about the existence of extraterrestrial life, about the finite or infinite nature and origin of the universe, and so much more. And we still have so much to discover. + +### Curiosity, a crucial component for space exploration + +The Cambridge Dictionary defines [curiosity][3] as "an eager wish to know or learn about something." It's curiosity that fuels our drive to acquire knowledge about outer space, but what drives our curiosity, our "eager wish," in the first place? + +I believe that our curiosity is driven by the desire to escape the unpleasant feeling of uncertainty that is triggered by acknowledging our lack of knowledge. The intrinsic reward that comes from escaping uncertainty pushes us to find a correct (or at least a less wrong) answer to whatever question is at hand. + +If we want space discovery to advance at a faster pace, we need more people to become aware of the rewards that are waiting for them when they make the effort and discover answers for their questions about the universe. Space discovery is admittedly not an easy task, because finding correct answers requires following rigorous methods on a long-term scale. + +Luckily, open source initiatives are emerging that make it easier for people to get started exploring and enjoying the beauty of outer space. + +### Two open source initiatives for space discovery + +#### OpenSpace Project + +One of the most beautiful tools for exploring space is [OpenSpace][4], an open source visualization tool of the entire known universe. It is an incredible way to visualize the environment of other planets, such as Mars and Jupiter, galaxies, and more. + +![The Moon visualized by the OpenSpace project][5] + +To enjoy a smooth experience from the OpenSpace simulation (e.g., a minimum 30fps), you need a powerful GPU; check the [GitHub repository][6] for more information. + +#### Libre Space Foundation + +The [Libre Space Foundation][7]'s mission is "to promote, advance, and develop libre (free and open source) technologies and knowledge for space." Among other things, the project is working to create an open source network of satellite ground stations that can communicate with satellites, spaceships, and space stations. It also supports the [UPSat project][8], which aspires to be the first completely open source satellite launched. + +### Advancing the human species + +I believe that the efforts made by these open source initiatives are contributing to the advancement of the human species in space. By increasing our interest in space, we are creating opportunities to upgrade our civilization's technological level, moving further up on the [Kardashev scale][9] and possibly becoming a multi-planetary species. Maybe one day, we will build a [Dyson sphere][10] around the sun to capture energy emissions, thereby harnessing an energy resource that exceeds any found on Earth and opening up a whole new world of possibilities. + +### Satisfy your curiosity + +Our solar system is only a tiny dot swimming in a universe of gems, and the outer space environment has never stopped amazing and intriguing us. + +If your curiosity is piqued and you want to learn more about outer space, check out [Kurzgesagt's][11] YouTube videos, which cover topics ranging from the origin of the universe to the strangest stars in a beautiful and concise manner. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/10/open-source-space-exploration + +作者:[Jaouhari Youssef][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/jaouhari +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/space_stars_cosmos_person.jpg?itok=XUtz_LyY (Person looking up at the stars) +[2]: https://en.wikipedia.org/wiki/List_of_space_telescopes +[3]: https://dictionary.cambridge.org/us/dictionary/english/curiosity +[4]: https://www.openspaceproject.com/ +[5]: https://opensource.com/sites/default/files/uploads/moon.png (The Moon visualized by the OpenSpace project) +[6]: https://github.com/OpenSpace/OpenSpace +[7]: https://libre.space/ +[8]: https://upsat.gr/ +[9]: https://en.wikipedia.org/wiki/Kardashev_scale +[10]: https://en.wikipedia.org/wiki/Dyson_sphere +[11]: https://kurzgesagt.org/ From 3fb162fd6b70fb2e20f2009a549c1c48c6786218 Mon Sep 17 00:00:00 2001 From: way-ww <40491614+way-ww@users.noreply.github.com> Date: Sun, 20 Oct 2019 14:28:14 +0800 Subject: [PATCH 07/10] Delete 20191003 How to Run the Top Command in Batch Mode.md --- ...ow to Run the Top Command in Batch Mode.md | 335 ------------------ 1 file changed, 335 deletions(-) delete mode 100644 sources/tech/20191003 How to Run the Top Command in Batch Mode.md diff --git a/sources/tech/20191003 How to Run the Top Command in Batch Mode.md b/sources/tech/20191003 How to Run the Top Command in Batch Mode.md deleted file mode 100644 index 4516e08387..0000000000 --- a/sources/tech/20191003 How to Run the Top Command in Batch Mode.md +++ /dev/null @@ -1,335 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (way-ww) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to Run the Top Command in Batch Mode) -[#]: via: (https://www.2daygeek.com/linux-run-execute-top-command-in-batch-mode/) -[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) - -How to Run the Top Command in Batch Mode -====== - -The **[Linux Top command][1]** is the best and most well known command that everyone uses to **[monitor Linux system performance][2]**. - -You probably already know most of the options available, except for a few options, and if I’m not wrong, “batch more” is one of the options. - -Most script writer and developers know this because this option is mainly used when writing the script. - -If you’re not sure about this, don’t worry we’re here to explain this. - -### What is “Batch Mode” in the Top Command - -The “Batch Mode” option allows you to send top command output to other programs or to a file. - -In this mode, top will not accept input and runs until the iterations limit you’ve set with the “-n” command-line option. - -If you want to fix any performance issues on the Linux server, you need to **[understand the top command output][3]** correctly. - -### 1) How to Run the Top Command in Batch Mode - -By default, the top command sort the results based on CPU usage, so when you run the below top command in batch mode, it does the same and prints the first 35 lines. - -``` -# top -bc | head -35 - -top - 06:41:14 up 8 days, 20:24, 1 user, load average: 0.87, 0.77, 0.81 -Tasks: 139 total, 1 running, 136 sleeping, 0 stopped, 2 zombie -%Cpu(s): 0.0 us, 3.2 sy, 0.0 ni, 96.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st -KiB Mem : 3880940 total, 1595932 free, 886736 used, 1398272 buff/cache -KiB Swap: 1048572 total, 514640 free, 533932 used. 2648472 avail Mem - -PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - 1 root 20 0 191144 2800 1596 S 0.0 0.1 5:43.63 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 - 2 root 20 0 0 0 0 S 0.0 0.0 0:00.32 [kthreadd] - 3 root 20 0 0 0 0 S 0.0 0.0 0:28.10 [ksoftirqd/0] - 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:0H] - 7 root rt 0 0 0 0 S 0.0 0.0 0:33.96 [migration/0] - 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [rcu_bh] - 9 root 20 0 0 0 0 S 0.0 0.0 63:05.12 [rcu_sched] - 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [lru-add-drain] - 11 root rt 0 0 0 0 S 0.0 0.0 0:08.79 [watchdog/0] - 12 root rt 0 0 0 0 S 0.0 0.0 0:08.82 [watchdog/1] - 13 root rt 0 0 0 0 S 0.0 0.0 0:44.27 [migration/1] - 14 root 20 0 0 0 0 S 0.0 0.0 1:22.45 [ksoftirqd/1] - 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/1:0H] - 18 root 20 0 0 0 0 S 0.0 0.0 0:00.01 [kdevtmpfs] - 19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [netns] - 20 root 20 0 0 0 0 S 0.0 0.0 0:01.35 [khungtaskd] - 21 root 0 -20 0 0 0 S 0.0 0.0 0:00.02 [writeback] - 22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kintegrityd] - 23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [bioset] - 24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kblockd] - 25 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [md] - 26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [edac-poller] - 33 root 20 0 0 0 0 S 0.0 0.0 1:19.07 [kswapd0] - 34 root 25 5 0 0 0 S 0.0 0.0 0:00.00 [ksmd] - 35 root 39 19 0 0 0 S 0.0 0.0 0:12.80 [khugepaged] - 36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [crypto] - 44 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kthrotld] - 46 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kmpath_rdacd] -``` - -### 2) How to Run the Top Command in Batch Mode and Sort the Output Based on Memory Usage - -Run the below top command to sort the results based on memory usage in batch mode. - -``` -# top -bc -o +%MEM | head -n 20 - -top - 06:42:00 up 8 days, 20:25, 1 user, load average: 0.66, 0.74, 0.80 -Tasks: 146 total, 1 running, 145 sleeping, 0 stopped, 0 zombie -%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st -KiB Mem : 3880940 total, 1422044 free, 1059176 used, 1399720 buff/cache -KiB Swap: 1048572 total, 514640 free, 533932 used. 2475984 avail Mem - - PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - 18105 mysql 20 0 1453900 156096 8816 S 0.0 4.0 2:12.98 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid - 1841 root 20 0 228980 107036 5360 S 0.0 2.8 0:05.56 /usr/local/cpanel/3rdparty/perl/528/bin/perl -T -w /usr/local/cpanel/3rdparty/bin/spamd --max-children=3 --max-spare=1 --allowed-ips=127.0.0.+ - 4301 root 20 0 230208 104608 1816 S 0.0 2.7 0:03.77 spamd child - 8139 nobody 20 0 257000 27108 3408 S 0.0 0.7 0:00.04 /usr/sbin/httpd -k start - 7961 nobody 20 0 256988 26912 3160 S 0.0 0.7 0:00.05 /usr/sbin/httpd -k start - 8190 nobody 20 0 256976 26812 3140 S 0.0 0.7 0:00.05 /usr/sbin/httpd -k start - 8353 nobody 20 0 256976 26812 3144 S 0.0 0.7 0:00.04 /usr/sbin/httpd -k start - 8629 nobody 20 0 256856 26736 3108 S 0.0 0.7 0:00.02 /usr/sbin/httpd -k start - 8636 nobody 20 0 256856 26712 3100 S 0.0 0.7 0:00.03 /usr/sbin/httpd -k start - 8611 nobody 20 0 256844 25764 2228 S 0.0 0.7 0:00.01 /usr/sbin/httpd -k start - 8451 nobody 20 0 256844 25760 2220 S 0.0 0.7 0:00.04 /usr/sbin/httpd -k start - 8610 nobody 20 0 256844 25748 2224 S 0.0 0.7 0:00.01 /usr/sbin/httpd -k start - 8632 nobody 20 0 256844 25744 2216 S 0.0 0.7 0:00.03 /usr/sbin/httpd -k start -``` - -**Details of the above command:** - - * **-b :** Batch mode operation - * **-c :** To print the absolute path of the running process - * **-o :** To specify fields for sorting processes - * **head :** Output the first part of files - * **-n :** To print the first “n” lines - - - -### 3) How to Run the Top Command in Batch Mode and Sort the Output Based on a Specific User Process - -If you want to sort results based on a specific user, run the below top command. - -``` -# top -bc -u mysql | head -n 10 - -top - 06:44:58 up 8 days, 20:27, 1 user, load average: 0.99, 0.87, 0.84 -Tasks: 140 total, 1 running, 137 sleeping, 0 stopped, 2 zombie -%Cpu(s): 13.3 us, 3.3 sy, 0.0 ni, 83.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st -KiB Mem : 3880940 total, 1589832 free, 885648 used, 1405460 buff/cache -KiB Swap: 1048572 total, 514640 free, 533932 used. 2649412 avail Mem - - PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - 18105 mysql 20 0 1453900 156888 8816 S 0.0 4.0 2:16.42 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid -``` - -### 4) How to Run the Top Command in Batch Mode and Sort the Output Based on the Process Age - -Use the below top command to sort the results based on the age of the process in batch mode. It shows the total CPU time the task has used since it started. - -But if you want to check how long a process has been running on Linux, go to the following article. - - * **[Five Ways to Check How Long a Process Has Been Running in Linux][4]** - - - -``` -# top -bc -o TIME+ | head -n 20 - -top - 06:45:56 up 8 days, 20:28, 1 user, load average: 0.56, 0.77, 0.81 -Tasks: 148 total, 1 running, 146 sleeping, 0 stopped, 1 zombie -%Cpu(s): 0.0 us, 3.1 sy, 0.0 ni, 96.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st -KiB Mem : 3880940 total, 1378664 free, 1094876 used, 1407400 buff/cache -KiB Swap: 1048572 total, 514640 free, 533932 used. 2440332 avail Mem - - PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - 9 root 20 0 0 0 0 S 0.0 0.0 63:05.70 [rcu_sched] - 272 root 20 0 0 0 0 S 0.0 0.0 16:12.13 [xfsaild/vda1] - 3882 root 20 0 229832 6212 1220 S 0.0 0.2 9:00.84 /usr/sbin/httpd -k start - 1 root 20 0 191144 2800 1596 S 0.0 0.1 5:43.75 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 - 3761 root 20 0 68784 9820 2048 S 0.0 0.3 5:09.67 tailwatchd - 3529 root 20 0 404380 3472 2604 S 0.0 0.1 3:24.98 /usr/sbin/rsyslogd -n - 3520 root 20 0 574208 572 164 S 0.0 0.0 3:07.74 /usr/bin/python2 -Es /usr/sbin/tuned -l -P - 444 dbus 20 0 58444 1144 612 S 0.0 0.0 2:23.90 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation - 18105 mysql 20 0 1453900 157152 8816 S 0.0 4.0 2:17.29 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid - 249 root 0 -20 0 0 0 S 0.0 0.0 1:28.83 [kworker/0:1H] - 14 root 20 0 0 0 0 S 0.0 0.0 1:22.46 [ksoftirqd/1] - 33 root 20 0 0 0 0 S 0.0 0.0 1:19.07 [kswapd0] - 342 root 20 0 39472 2940 2752 S 0.0 0.1 1:18.17 /usr/lib/systemd/systemd-journald -``` - -### 5) How to Run the Top Command in Batch Mode and Save the Output to a File - -If you want to share the output of the top command to someone for troubleshooting purposes, redirect the output to a file using the following command. - -``` -# top -bc | head -35 > top-report.txt - -# cat top-report.txt - -top - 06:47:11 up 8 days, 20:30, 1 user, load average: 0.67, 0.77, 0.81 -Tasks: 133 total, 4 running, 129 sleeping, 0 stopped, 0 zombie -%Cpu(s): 59.4 us, 12.5 sy, 0.0 ni, 28.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st -KiB Mem : 3880940 total, 1596268 free, 843284 used, 1441388 buff/cache -KiB Swap: 1048572 total, 514640 free, 533932 used. 2659084 avail Mem - - PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND - 9686 daygeekc 20 0 406132 62184 43448 R 94.1 1.6 0:00.34 /opt/cpanel/ea-php56/root/usr/bin/php-cgi - 9689 nobody 20 0 256588 24428 1184 S 5.9 0.6 0:00.01 /usr/sbin/httpd -k start - 1 root 20 0 191144 2800 1596 S 0.0 0.1 5:43.79 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 - 2 root 20 0 0 0 0 S 0.0 0.0 0:00.32 [kthreadd] - 3 root 20 0 0 0 0 S 0.0 0.0 0:28.11 [ksoftirqd/0] - 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:0H] - 7 root rt 0 0 0 0 S 0.0 0.0 0:33.96 [migration/0] - 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [rcu_bh] - 9 root 20 0 0 0 0 R 0.0 0.0 63:05.82 [rcu_sched] - 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [lru-add-drain] - 11 root rt 0 0 0 0 S 0.0 0.0 0:08.79 [watchdog/0] - 12 root rt 0 0 0 0 S 0.0 0.0 0:08.82 [watchdog/1] - 13 root rt 0 0 0 0 S 0.0 0.0 0:44.28 [migration/1] - 14 root 20 0 0 0 0 S 0.0 0.0 1:22.46 [ksoftirqd/1] - 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/1:0H] - 18 root 20 0 0 0 0 S 0.0 0.0 0:00.01 [kdevtmpfs] - 19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [netns] - 20 root 20 0 0 0 0 S 0.0 0.0 0:01.35 [khungtaskd] - 21 root 0 -20 0 0 0 S 0.0 0.0 0:00.02 [writeback] - 22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kintegrityd] - 23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [bioset] - 24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kblockd] - 25 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [md] - 26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [edac-poller] - 33 root 20 0 0 0 0 S 0.0 0.0 1:19.07 [kswapd0] - 34 root 25 5 0 0 0 S 0.0 0.0 0:00.00 [ksmd] - 35 root 39 19 0 0 0 S 0.0 0.0 0:12.80 [khugepaged] - 36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [crypto] -``` - -### How to Sort Output Based on Specific Fields - -In the latest version of the top command release, press the **“f”** key to sort the fields via the field letter. - -To sort with a new field, use the **“up/down”** arrow to select the correct selection, and then press **“s”** to sort it. Finally press **“q”** to exit from this window. - -``` -Fields Management for window 1:Def, whose current sort field is %CPU - Navigate with Up/Dn, Right selects for move then or Left commits, - 'd' or toggles display, 's' sets sort. Use 'q' or to end! - PID = Process Id nsUTS = UTS namespace Inode - USER = Effective User Name LXC = LXC container name - PR = Priority RSan = RES Anonymous (KiB) - NI = Nice Value RSfd = RES File-based (KiB) - VIRT = Virtual Image (KiB) RSlk = RES Locked (KiB) - RES = Resident Size (KiB) RSsh = RES Shared (KiB) - SHR = Shared Memory (KiB) CGNAME = Control Group name - S = Process Status NU = Last Used NUMA node - %CPU = CPU Usage - %MEM = Memory Usage (RES) - TIME+ = CPU Time, hundredths - COMMAND = Command Name/Line - PPID = Parent Process pid - UID = Effective User Id - RUID = Real User Id - RUSER = Real User Name - SUID = Saved User Id - SUSER = Saved User Name - GID = Group Id - GROUP = Group Name - PGRP = Process Group Id - TTY = Controlling Tty - TPGID = Tty Process Grp Id - SID = Session Id - nTH = Number of Threads - P = Last Used Cpu (SMP) - TIME = CPU Time - SWAP = Swapped Size (KiB) - CODE = Code Size (KiB) - DATA = Data+Stack (KiB) - nMaj = Major Page Faults - nMin = Minor Page Faults - nDRT = Dirty Pages Count - WCHAN = Sleeping in Function - Flags = Task Flags - CGROUPS = Control Groups - SUPGIDS = Supp Groups IDs - SUPGRPS = Supp Groups Names - TGID = Thread Group Id - OOMa = OOMEM Adjustment - OOMs = OOMEM Score current - ENVIRON = Environment vars - vMj = Major Faults delta - vMn = Minor Faults delta - USED = Res+Swap Size (KiB) - nsIPC = IPC namespace Inode - nsMNT = MNT namespace Inode - nsNET = NET namespace Inode - nsPID = PID namespace Inode - nsUSER = USER namespace Inode -``` - -For older version of the top command, press the **“shift+f”** or **“shift+o”** key to sort the fields via the field letter. - -To sort with a new field, select the corresponding sort **field letter**, and then press **“Enter”** to sort it. - -``` -Current Sort Field: N for window 1:Def - Select sort field via field letter, type any other key to return - a: PID = Process Id - b: PPID = Parent Process Pid - c: RUSER = Real user name - d: UID = User Id - e: USER = User Name - f: GROUP = Group Name - g: TTY = Controlling Tty - h: PR = Priority - i: NI = Nice value - j: P = Last used cpu (SMP) - k: %CPU = CPU usage - l: TIME = CPU Time - m: TIME+ = CPU Time, hundredths -* N: %MEM = Memory usage (RES) - o: VIRT = Virtual Image (kb) - p: SWAP = Swapped size (kb) - q: RES = Resident size (kb) - r: CODE = Code size (kb) - s: DATA = Data+Stack size (kb) - t: SHR = Shared Mem size (kb) - u: nFLT = Page Fault count - v: nDRT = Dirty Pages count - w: S = Process Status - x: COMMAND = Command name/line - y: WCHAN = Sleeping in Function - z: Flags = Task Flags - Note1: - If a selected sort field can't be - shown due to screen width or your - field order, the '<' and '>' keys - will be unavailable until a field - within viewable range is chosen. - Note2: - Field sorting uses internal values, - not those in column display. Thus, - the TTY & WCHAN fields will violate - strict ASCII collating sequence. - (shame on you if WCHAN is chosen) -``` - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/linux-run-execute-top-command-in-batch-mode/ - -作者:[Magesh Maruthamuthu][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://www.2daygeek.com/author/magesh/ -[b]: https://github.com/lujun9972 -[1]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ -[2]: https://www.2daygeek.com/category/system-monitoring/ -[3]: https://www.2daygeek.com/understanding-linux-top-command-output-usage/ -[4]: https://www.2daygeek.com/how-to-check-how-long-a-process-has-been-running-in-linux/ From 7fb9665c9eb501290cdc833eaf3bf8b8ef8a5181 Mon Sep 17 00:00:00 2001 From: way-ww <40491614+way-ww@users.noreply.github.com> Date: Sun, 20 Oct 2019 14:31:35 +0800 Subject: [PATCH 08/10] Create 20191003 How to Run the Top Command in Batch Mode.md --- ...ow to Run the Top Command in Batch Mode.md | 335 ++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 translated/tech/20191003 How to Run the Top Command in Batch Mode.md diff --git a/translated/tech/20191003 How to Run the Top Command in Batch Mode.md b/translated/tech/20191003 How to Run the Top Command in Batch Mode.md new file mode 100644 index 0000000000..7c575c5bb7 --- /dev/null +++ b/translated/tech/20191003 How to Run the Top Command in Batch Mode.md @@ -0,0 +1,335 @@ +[#]: collector: "lujun9972" +[#]: translator: "way-ww" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " +[#]: subject: "How to Run the Top Command in Batch Mode" +[#]: via: "https://www.2daygeek.com/linux-run-execute-top-command-in-batch-mode/" +[#]: author: "Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/" + +如何在批处理模式下运行 Top 命令 +====== + +**[Top 命令][1]** 是每个人都在使用的用于 **[监控 Linux 系统性能][2]** 的最好的命令。 + +除了很少的几个操作, 你可能已经知道 top 命令的绝大部分操作, 如果我没错的话, 批处理模式就是其中之一。 + +大部分的脚本编写者和开发人员都知道这个, 因为这个操作主要就是用来编写脚本。 + +如果你不了解这个, 不用担心,我们将在这里介绍它。 + +### 什么是 Top 命令的批处理模式 + +批处理模式允许你将 top 命令的输出发送至其他程序或者文件中。 + +在这个模式中, top 命令将不会接收输入并且持续运行直到迭代次数达到你用 “-n” 选项指定的次数为止。 + +如果你想解决 Linux 服务器上的任何性能问题, 你需要正确的 **[理解 top 命令的输出][3]** 。 + +### 1) 如何在批处理模式下运行 top 命令 + +默认地, top 命令按照 CPU 的使用率来排序输出结果, 所以当你在批处理模式中运行以下命令时, 它会执行同样的操作并打印前 35 行。 + +``` +# top -bc | head -35 + +top - 06:41:14 up 8 days, 20:24, 1 user, load average: 0.87, 0.77, 0.81 +Tasks: 139 total, 1 running, 136 sleeping, 0 stopped, 2 zombie +%Cpu(s): 0.0 us, 3.2 sy, 0.0 ni, 96.8 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +KiB Mem : 3880940 total, 1595932 free, 886736 used, 1398272 buff/cache +KiB Swap: 1048572 total, 514640 free, 533932 used. 2648472 avail Mem + +PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 1 root 20 0 191144 2800 1596 S 0.0 0.1 5:43.63 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 + 2 root 20 0 0 0 0 S 0.0 0.0 0:00.32 [kthreadd] + 3 root 20 0 0 0 0 S 0.0 0.0 0:28.10 [ksoftirqd/0] + 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:0H] + 7 root rt 0 0 0 0 S 0.0 0.0 0:33.96 [migration/0] + 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [rcu_bh] + 9 root 20 0 0 0 0 S 0.0 0.0 63:05.12 [rcu_sched] + 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [lru-add-drain] + 11 root rt 0 0 0 0 S 0.0 0.0 0:08.79 [watchdog/0] + 12 root rt 0 0 0 0 S 0.0 0.0 0:08.82 [watchdog/1] + 13 root rt 0 0 0 0 S 0.0 0.0 0:44.27 [migration/1] + 14 root 20 0 0 0 0 S 0.0 0.0 1:22.45 [ksoftirqd/1] + 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/1:0H] + 18 root 20 0 0 0 0 S 0.0 0.0 0:00.01 [kdevtmpfs] + 19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [netns] + 20 root 20 0 0 0 0 S 0.0 0.0 0:01.35 [khungtaskd] + 21 root 0 -20 0 0 0 S 0.0 0.0 0:00.02 [writeback] + 22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kintegrityd] + 23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [bioset] + 24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kblockd] + 25 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [md] + 26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [edac-poller] + 33 root 20 0 0 0 0 S 0.0 0.0 1:19.07 [kswapd0] + 34 root 25 5 0 0 0 S 0.0 0.0 0:00.00 [ksmd] + 35 root 39 19 0 0 0 S 0.0 0.0 0:12.80 [khugepaged] + 36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [crypto] + 44 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kthrotld] + 46 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kmpath_rdacd] +``` + +### 2) 如何在批处理模式下运行 top 命令并按内存使用率排序结果 + +在批处理模式中运行以下命令按内存使用率对结果进行排序 + +``` +# top -bc -o +%MEM | head -n 20 + +top - 06:42:00 up 8 days, 20:25, 1 user, load average: 0.66, 0.74, 0.80 +Tasks: 146 total, 1 running, 145 sleeping, 0 stopped, 0 zombie +%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +KiB Mem : 3880940 total, 1422044 free, 1059176 used, 1399720 buff/cache +KiB Swap: 1048572 total, 514640 free, 533932 used. 2475984 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 18105 mysql 20 0 1453900 156096 8816 S 0.0 4.0 2:12.98 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid + 1841 root 20 0 228980 107036 5360 S 0.0 2.8 0:05.56 /usr/local/cpanel/3rdparty/perl/528/bin/perl -T -w /usr/local/cpanel/3rdparty/bin/spamd --max-children=3 --max-spare=1 --allowed-ips=127.0.0.+ + 4301 root 20 0 230208 104608 1816 S 0.0 2.7 0:03.77 spamd child + 8139 nobody 20 0 257000 27108 3408 S 0.0 0.7 0:00.04 /usr/sbin/httpd -k start + 7961 nobody 20 0 256988 26912 3160 S 0.0 0.7 0:00.05 /usr/sbin/httpd -k start + 8190 nobody 20 0 256976 26812 3140 S 0.0 0.7 0:00.05 /usr/sbin/httpd -k start + 8353 nobody 20 0 256976 26812 3144 S 0.0 0.7 0:00.04 /usr/sbin/httpd -k start + 8629 nobody 20 0 256856 26736 3108 S 0.0 0.7 0:00.02 /usr/sbin/httpd -k start + 8636 nobody 20 0 256856 26712 3100 S 0.0 0.7 0:00.03 /usr/sbin/httpd -k start + 8611 nobody 20 0 256844 25764 2228 S 0.0 0.7 0:00.01 /usr/sbin/httpd -k start + 8451 nobody 20 0 256844 25760 2220 S 0.0 0.7 0:00.04 /usr/sbin/httpd -k start + 8610 nobody 20 0 256844 25748 2224 S 0.0 0.7 0:00.01 /usr/sbin/httpd -k start + 8632 nobody 20 0 256844 25744 2216 S 0.0 0.7 0:00.03 /usr/sbin/httpd -k start +``` + +**上面命令的详细信息:** + + * **-b :** 批处理模式选项 + * **-c :** 打印运行中的进程的绝对路径 + * **-o :** 指定进行排序的字段 + * **head :** 输出文件的第一部分 + * **-n :** 打印前 n 行 + + + +### 3) 如何在批处理模式下运行 top 命令并按照指定的用户进程对结果进行排序 + +如果你想要按照指定用户进程对结果进行排序请运行以下命令 + +``` +# top -bc -u mysql | head -n 10 + +top - 06:44:58 up 8 days, 20:27, 1 user, load average: 0.99, 0.87, 0.84 +Tasks: 140 total, 1 running, 137 sleeping, 0 stopped, 2 zombie +%Cpu(s): 13.3 us, 3.3 sy, 0.0 ni, 83.3 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +KiB Mem : 3880940 total, 1589832 free, 885648 used, 1405460 buff/cache +KiB Swap: 1048572 total, 514640 free, 533932 used. 2649412 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 18105 mysql 20 0 1453900 156888 8816 S 0.0 4.0 2:16.42 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid +``` + +### 4) 如何在批处理模式下运行 top 命令并按照处理时间进行排序 + +在批处理模式中使用以下 top 命令按照处理时间对结果进行排序。 这展示了任务从启动以来已使用的总 CPU 时间 + +但是如果你想要检查一个进程在 Linux 上运行了多长时间请看接下来的文章。 + + * **[检查 Linux 中进程运行时间的五种方法][4]** + + + +``` +# top -bc -o TIME+ | head -n 20 + +top - 06:45:56 up 8 days, 20:28, 1 user, load average: 0.56, 0.77, 0.81 +Tasks: 148 total, 1 running, 146 sleeping, 0 stopped, 1 zombie +%Cpu(s): 0.0 us, 3.1 sy, 0.0 ni, 96.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +KiB Mem : 3880940 total, 1378664 free, 1094876 used, 1407400 buff/cache +KiB Swap: 1048572 total, 514640 free, 533932 used. 2440332 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 9 root 20 0 0 0 0 S 0.0 0.0 63:05.70 [rcu_sched] + 272 root 20 0 0 0 0 S 0.0 0.0 16:12.13 [xfsaild/vda1] + 3882 root 20 0 229832 6212 1220 S 0.0 0.2 9:00.84 /usr/sbin/httpd -k start + 1 root 20 0 191144 2800 1596 S 0.0 0.1 5:43.75 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 + 3761 root 20 0 68784 9820 2048 S 0.0 0.3 5:09.67 tailwatchd + 3529 root 20 0 404380 3472 2604 S 0.0 0.1 3:24.98 /usr/sbin/rsyslogd -n + 3520 root 20 0 574208 572 164 S 0.0 0.0 3:07.74 /usr/bin/python2 -Es /usr/sbin/tuned -l -P + 444 dbus 20 0 58444 1144 612 S 0.0 0.0 2:23.90 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation + 18105 mysql 20 0 1453900 157152 8816 S 0.0 4.0 2:17.29 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid + 249 root 0 -20 0 0 0 S 0.0 0.0 1:28.83 [kworker/0:1H] + 14 root 20 0 0 0 0 S 0.0 0.0 1:22.46 [ksoftirqd/1] + 33 root 20 0 0 0 0 S 0.0 0.0 1:19.07 [kswapd0] + 342 root 20 0 39472 2940 2752 S 0.0 0.1 1:18.17 /usr/lib/systemd/systemd-journald +``` + +### 5) 如何在批处理模式下运行 top 命令并将结果保存到文件中 + +如果出于解决问题的目的, 你想要和别人分享 top 命令的输出, 请使用以下命令重定向输出到文件中 + +``` +# top -bc | head -35 > top-report.txt + +# cat top-report.txt + +top - 06:47:11 up 8 days, 20:30, 1 user, load average: 0.67, 0.77, 0.81 +Tasks: 133 total, 4 running, 129 sleeping, 0 stopped, 0 zombie +%Cpu(s): 59.4 us, 12.5 sy, 0.0 ni, 28.1 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +KiB Mem : 3880940 total, 1596268 free, 843284 used, 1441388 buff/cache +KiB Swap: 1048572 total, 514640 free, 533932 used. 2659084 avail Mem + + PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND + 9686 daygeekc 20 0 406132 62184 43448 R 94.1 1.6 0:00.34 /opt/cpanel/ea-php56/root/usr/bin/php-cgi + 9689 nobody 20 0 256588 24428 1184 S 5.9 0.6 0:00.01 /usr/sbin/httpd -k start + 1 root 20 0 191144 2800 1596 S 0.0 0.1 5:43.79 /usr/lib/systemd/systemd --switched-root --system --deserialize 22 + 2 root 20 0 0 0 0 S 0.0 0.0 0:00.32 [kthreadd] + 3 root 20 0 0 0 0 S 0.0 0.0 0:28.11 [ksoftirqd/0] + 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/0:0H] + 7 root rt 0 0 0 0 S 0.0 0.0 0:33.96 [migration/0] + 8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 [rcu_bh] + 9 root 20 0 0 0 0 R 0.0 0.0 63:05.82 [rcu_sched] + 10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [lru-add-drain] + 11 root rt 0 0 0 0 S 0.0 0.0 0:08.79 [watchdog/0] + 12 root rt 0 0 0 0 S 0.0 0.0 0:08.82 [watchdog/1] + 13 root rt 0 0 0 0 S 0.0 0.0 0:44.28 [migration/1] + 14 root 20 0 0 0 0 S 0.0 0.0 1:22.46 [ksoftirqd/1] + 16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kworker/1:0H] + 18 root 20 0 0 0 0 S 0.0 0.0 0:00.01 [kdevtmpfs] + 19 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [netns] + 20 root 20 0 0 0 0 S 0.0 0.0 0:01.35 [khungtaskd] + 21 root 0 -20 0 0 0 S 0.0 0.0 0:00.02 [writeback] + 22 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kintegrityd] + 23 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [bioset] + 24 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [kblockd] + 25 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [md] + 26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [edac-poller] + 33 root 20 0 0 0 0 S 0.0 0.0 1:19.07 [kswapd0] + 34 root 25 5 0 0 0 S 0.0 0.0 0:00.00 [ksmd] + 35 root 39 19 0 0 0 S 0.0 0.0 0:12.80 [khugepaged] + 36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 [crypto] +``` + +### 如何按照指定字段对结果进行排序 + +在 top 命令的最新版本中, 按下 **“f”** 键进入字段管理界面。 + +要使用新字段进行排序, 请使用 **“up/down”** 箭头选择正确的选项, 然后再按下 **“s”** 键进行排序。 最后按 **“q”** 键退出此窗口。 + +``` +Fields Management for window 1:Def, whose current sort field is %CPU + Navigate with Up/Dn, Right selects for move then or Left commits, + 'd' or toggles display, 's' sets sort. Use 'q' or to end! + PID = Process Id nsUTS = UTS namespace Inode + USER = Effective User Name LXC = LXC container name + PR = Priority RSan = RES Anonymous (KiB) + NI = Nice Value RSfd = RES File-based (KiB) + VIRT = Virtual Image (KiB) RSlk = RES Locked (KiB) + RES = Resident Size (KiB) RSsh = RES Shared (KiB) + SHR = Shared Memory (KiB) CGNAME = Control Group name + S = Process Status NU = Last Used NUMA node + %CPU = CPU Usage + %MEM = Memory Usage (RES) + TIME+ = CPU Time, hundredths + COMMAND = Command Name/Line + PPID = Parent Process pid + UID = Effective User Id + RUID = Real User Id + RUSER = Real User Name + SUID = Saved User Id + SUSER = Saved User Name + GID = Group Id + GROUP = Group Name + PGRP = Process Group Id + TTY = Controlling Tty + TPGID = Tty Process Grp Id + SID = Session Id + nTH = Number of Threads + P = Last Used Cpu (SMP) + TIME = CPU Time + SWAP = Swapped Size (KiB) + CODE = Code Size (KiB) + DATA = Data+Stack (KiB) + nMaj = Major Page Faults + nMin = Minor Page Faults + nDRT = Dirty Pages Count + WCHAN = Sleeping in Function + Flags = Task Flags + CGROUPS = Control Groups + SUPGIDS = Supp Groups IDs + SUPGRPS = Supp Groups Names + TGID = Thread Group Id + OOMa = OOMEM Adjustment + OOMs = OOMEM Score current + ENVIRON = Environment vars + vMj = Major Faults delta + vMn = Minor Faults delta + USED = Res+Swap Size (KiB) + nsIPC = IPC namespace Inode + nsMNT = MNT namespace Inode + nsNET = NET namespace Inode + nsPID = PID namespace Inode + nsUSER = USER namespace Inode +``` + +对 top 命令的旧版本, 请按 **“shift+f”** 或 **“shift+o”** 键进入字段管理界面进行排序。 + +要使用新字段进行排序, 请选择相应的排序字段字母, 然后按下 **“Enter”** 排序。 + +``` +Current Sort Field: N for window 1:Def + Select sort field via field letter, type any other key to return + a: PID = Process Id + b: PPID = Parent Process Pid + c: RUSER = Real user name + d: UID = User Id + e: USER = User Name + f: GROUP = Group Name + g: TTY = Controlling Tty + h: PR = Priority + i: NI = Nice value + j: P = Last used cpu (SMP) + k: %CPU = CPU usage + l: TIME = CPU Time + m: TIME+ = CPU Time, hundredths +* N: %MEM = Memory usage (RES) + o: VIRT = Virtual Image (kb) + p: SWAP = Swapped size (kb) + q: RES = Resident size (kb) + r: CODE = Code size (kb) + s: DATA = Data+Stack size (kb) + t: SHR = Shared Mem size (kb) + u: nFLT = Page Fault count + v: nDRT = Dirty Pages count + w: S = Process Status + x: COMMAND = Command name/line + y: WCHAN = Sleeping in Function + z: Flags = Task Flags + Note1: + If a selected sort field can't be + shown due to screen width or your + field order, the '<' and '>' keys + will be unavailable until a field + within viewable range is chosen. + Note2: + Field sorting uses internal values, + not those in column display. Thus, + the TTY & WCHAN fields will violate + strict ASCII collating sequence. + (shame on you if WCHAN is chosen) +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-run-execute-top-command-in-batch-mode/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[way-ww](https://github.com/way-ww) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ +[2]: https://www.2daygeek.com/category/system-monitoring/ +[3]: https://www.2daygeek.com/understanding-linux-top-command-output-usage/ +[4]: https://www.2daygeek.com/how-to-check-how-long-a-process-has-been-running-in-linux/ From 1156e68d0fd8630e4c26e4d17ad6ca5a81a10012 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 Oct 2019 15:00:50 +0800 Subject: [PATCH 09/10] Rename sources/tech/20191019 To space and beyond with open source.md to sources/talk/20191019 To space and beyond with open source.md --- .../20191019 To space and beyond with open source.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sources/{tech => talk}/20191019 To space and beyond with open source.md (100%) diff --git a/sources/tech/20191019 To space and beyond with open source.md b/sources/talk/20191019 To space and beyond with open source.md similarity index 100% rename from sources/tech/20191019 To space and beyond with open source.md rename to sources/talk/20191019 To space and beyond with open source.md From 0c9d729dd1c58d41da3b3765308ffba653c188ac Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 20 Oct 2019 15:01:48 +0800 Subject: [PATCH 10/10] Rename sources/tech/20191020 Project Trident Ditches BSD for Linux.md to sources/talk/20191020 Project Trident Ditches BSD for Linux.md --- .../20191020 Project Trident Ditches BSD for Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sources/{tech => talk}/20191020 Project Trident Ditches BSD for Linux.md (100%) diff --git a/sources/tech/20191020 Project Trident Ditches BSD for Linux.md b/sources/talk/20191020 Project Trident Ditches BSD for Linux.md similarity index 100% rename from sources/tech/20191020 Project Trident Ditches BSD for Linux.md rename to sources/talk/20191020 Project Trident Ditches BSD for Linux.md