Merge pull request #4 from LCTT/master

Update from LCTT
This commit is contained in:
Xingyu.Wang 2018-12-17 13:08:34 +08:00 committed by GitHub
commit 6a00bb1ec3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 421 additions and 444 deletions

View File

@ -15,30 +15,26 @@
LCTT 已经拥有几百名活跃成员,并欢迎更多的 Linux 志愿者加入我们的团队。
![logo](https://linux.cn/static/image/common/lctt_logo.png)
![LCTT](https://lctt.github.io/wiki/images/lctt_logo.png)
LCTT 的组成
-------------------------------
**选题**,负责选择合适的内容,并将原文转换为 markdown 格式,提交到 LCTT 的 [TranslateProject](https://github.com/LCTT/TranslateProject) 库中。
**译者**,负责从选题中选择内容进行翻译。
**校对**,负责将初译的文章进行文字润色、技术校对等工作。
**发布**,负责将校对后的文章,排版进行发布。
- LCTT 官网: [https://linux.cn/lctt/](https://linux.cn/lctt/)
- LCTT 状态: [https://lctt.github.io/](https://lctt.github.io/)
加入我们
-------------------------------
请首先加入翻译组的 QQ 群,群号是:**198889102**,加群时请说明是“*志愿者*”。加入后记得修改您的群名片为您的 GitHub 的 ID。
请首先加入翻译组的 QQ 群,群号是:**198889102**,加群时请说明是“*志愿者*”。
加入的成员,请先阅读 [WIKI 如何开始](https://github.com/LCTT/TranslateProject/wiki/01-如何开始)。
加入的成员,请:
1. 修改你的 QQ 群名片为“译者-您的_GitHub_ID”。
2. 阅读 [WIKI](http://lctt.github.io/wiki) 了解如何开始。
3. 遇到不解之处,请在群内发问。
如何开始
-------------------------------
请阅读 [WIKI](https://github.com/LCTT/TranslateProject/wiki)。如需要协助,请在群内发问。
请阅读 [WIKI](http://lctt.github.io/wiki)。如需要协助,请在群内发问。
历史
-------------------------------

View File

@ -1,22 +1,24 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: subject: (A Free Guide for Setting Your Open Source Strategy)
[#]: via: (https://www.linux.com/blog/2018/11/free-guide-setting-your-open-source-strategy)
[#]: author: ([Amber Ankerholz](https://www.linux.com/users/aankerholz)
[#]: url: ( )
[#]: url: (https://linux.cn/article-10354-1.html)
制定开源战略的免费指南
======
> 了解如何使用 TODO Group 的成熟实践,使您的组织的开源软件目标与您的业务目标保持一致。
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/os-strategy.jpg?itok=hSmtdJdK)
大多数使用开源的公司都了解其商业价值,但他们可能缺乏战略性地实施开源计划和获得全部回报的工具。根据 [The New Stack][1] 最近的一项调查“开源计划的三大好处是1提高了对开源的认识2提高了开发周期的速度和灵活性以及 3更好的许可证合规性
大多数使用开源的公司都了解其商业价值,但他们可能缺乏战略性地实施开源计划和获得全部回报的工具。根据 [The New Stack][1] 最近的一项调查,“开源计划的三大好处是 1提高了对开源的认识2提高了开发周期的速度和灵活性以及 3更好的许可证合规性。
营开源计划办公点涉及创建策略来帮助你定义和实施你的方法,并衡量你的进度。由 Linux 基金会与 TODO 集团合作开发的[企业开源指南][2]基于多年的经验和实践提供了专业开源知识。
作一个开源计划办公室涉及到创建策略来帮助你定义和实施你的方法,并衡量你的进度。由 Linux 基金会与 TODO Group 合作开发的[企业开源指南][2]基于多年的经验和实践提供了专业开源知识。
最新的指南中,[设置开源战略][3]详细介绍了制定战略和确保成功之路的基本步骤。根据该指南,“你的开源战略将管理、参与和创建开源软件的计划与计划所服务的业务目标联系起来。这可以开辟许多机会并促进创新。该指南涵盖以下主题:
最新的指南中,[设置开源战略][3]详细介绍了制定战略和确保成功之路的基本步骤。根据该指南,“你的开源战略将管理、参与和创建开源软件的计划与计划所服务的业务目标联系起来。这可以开辟许多机会并促进创新。该指南涵盖以下主题:
1. 为什么制定战略?
2. 你的战略文件
@ -26,9 +28,7 @@
6. 确定投资回报率
7. 投资目标
这里关键的第一步是创建和记录你的开源策略,该策略将“帮助你最大限度地提高组织从开源中获得的利益。”同时,你详细的策略可以帮助你避免因错误而导致的困难,例如:选择错误的许可证或不正确地维护代码。根据指南,该文件还可以:
这里关键的第一步是创建和将你的开源策略形成文字,该策略将“帮助你最大限度地提高组织从开源中获得的利益。”同时,你详细的策略可以帮助你避免因错误而导致的困难,例如:选择错误的许可证或不正确地维护代码。根据指南,该文件还可以:
* 让领导者感到兴奋并参与
* 帮助在公司内获得支持
@ -37,15 +37,13 @@
* 解释贵公司的开源方式和对其使用的支持
* 明确贵公司在社区驱动的外部研发中投资的地方,以及贵公司将重点放在增值差异化的地方
Salesforce 的软件架构师兼本指南的撰稿人 Ian Varley 说:“在 Salesforce 内,我们有内部文件,我们将这些围绕开源战略指导和鼓励的文件分发给我们的工程团队。其中鼓励创建和使用开源,这让他们毫不含糊地知道公司的战略领导者完全支持它。此外,如果有某些我们不希望工程师使用的许可证或有其他开源指南,我们的内部文档需要明确。”
Salesforce 的软件架构师兼指南的撰稿人 Ian Varley 说:“在 Salesforce 内,我们有内部文件,我们将这些围绕开源战略指导和鼓励的文件分发给我们的工程团队。其中鼓励创建和使用开源,这让他们毫不含糊地知道公司的战略领导者完全支持它。此外,如果有某些我们不希望工程师使用的许可证或有其他开源指南,我们的内部文档需要明确。“
开源计划有助于促进企业文化,使企业更高效,并且根据指南,强有力的战略文档可以“帮助你的团队了解开源计划背后的业务目标,确保更好的决策,并最大限度地降低风险“。
开源计划有助于促进企业文化,使企业更高效,并且根据指南,强有力的战略文档可以“帮助你的团队了解开源计划背后的业务目标,确保更好的决策,并最大限度地降低风险。”
了解如何使用[设置开源策略][3]新指南中的提示和经过验证的实践,将管理和创建开源软件的目标与组织的业务目标保持一致。然后,查看所有 12 个[企业开源指南][2],了解有关使用开源获得成功的更多信息。
本文最初发表在 [Linux基金会][4]
本文最初发表在 [Linux基金会][4]
--------------------------------------------------------------------------------
@ -54,7 +52,7 @@ via: https://www.linux.com/blog/2018/11/free-guide-setting-your-open-source-stra
作者:[Amber Ankerholz][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/) 荣誉推出
@ -63,4 +61,4 @@ via: https://www.linux.com/blog/2018/11/free-guide-setting-your-open-source-stra
[1]: https://thenewstack.io/open-source-culture-starts-with-programs-and-policies/
[2]: https://www.linuxfoundation.org/resources/open-source-guides/
[3]: https://www.linuxfoundation.org/resources/open-source-guides/setting-an-open-source-strategy/
[4]: https://www.linuxfoundation.org/blog/2018/11/a-free-guide-for-setting-your-open-source-strategy/
[4]: https://www.linuxfoundation.org/blog/2018/11/a-free-guide-for-setting-your-open-source-strategy/

View File

@ -1,32 +1,34 @@
[#]: collector: (lujun9972)
[#]: translator: (jrglinux )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: translator: (jrglinux)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: subject: (Boxing yourself in on the Linux command line)
[#]: via: (https://opensource.com/article/18/12/linux-toy-boxes)
[#]: author: (Jason Baker https://opensource.com/users/jason-baker)
[#]: url: ( )
[#]: url: (https://linux.cn/article-10352-1.html)
神奇的 Linux 命令行字符形状工具 boxes
======
本文将教你如何在 Linux 命令行终端中使用 boxes 工具绘制字符形状图形来包装你的文字让其更突出。
> 本文将教你如何在 Linux 命令行终端中使用 boxes 工具绘制字符形状图形来包装你的文字让其更突出。
![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-boxes.png?itok=Rii6nT5P)
现在正值假期,每个 Linux 终端用户都该得到一点礼物。无论你是庆祝圣诞节还是庆祝其他节日,或者什么节日也没有,都没有关系。我将在接下来的几周内介绍 24 个 Linux 命令行小玩具,供你把玩或者与朋友分享。让我们享受乐趣,让这个月过得快乐一点,因为对于北半球来说,这个月有点冷并且沉闷。
对于我要讲述的内容,可能你之前就有些了解。但是,我还是希望我们都有机会学到一些新的东西(我做了一点研究,确保可以分享 24 个小玩具)。
24 个 Linux 终端小玩具中的第一个是叫做 boxes 的小程序。为何从 boxes 说起呢?因为在没有它的情况下很难将所有其他命令礼物包装起来!
24 个 Linux 终端小玩具中的第一个是叫做 `boxes` 的小程序。为何从 `boxes` 说起呢?因为在没有它的情况下很难将所有其他命令礼物包装起来!
在我的 Fedora 机器上,默认没有安装 boxes 程序,但它在我的普通仓库中可以获取到,所以用如下命令就可安装:
在我的 Fedora 机器上,默认没有安装 `boxes` 程序,但它在我的普通仓库中可以获取到,所以用如下命令就可安装:
```
$ sudo dnf install boxes -y
```
如果你在使用其他 Linux 发行版,一般也都可以在默认仓库中找到 boxes。
如果你在使用其他 Linux 发行版,一般也都可以在默认仓库中找到 `boxes`
Boxes 是我真正希望在高中和大学计算机课程中就使用的实用程序,因为善意的老师要求我在每个源文件、函数、代码块等开头添加一些具体的评论信息。
`boxes` 是我真正希望在高中和大学计算机课程中就使用的实用程序,因为善意的老师要求我在每个源文件、函数、代码块等开头添加一些特定外观的备注信息。
```
/***************/
@ -34,7 +36,7 @@ Boxes 是我真正希望在高中和大学计算机课程中就使用的实用
/***************/
```
事实证明,一旦你需要在框内添加几行文字,并且格式化的将它们统一风格就会变得很乏味。而 boxes 是一个简单实用程序,它使用 ASCII 艺术风格的字符形状框来包围文本。其字符形状默认风格是源代码注释风格,但也提供了一些其他选项。
事实证明,一旦你需要在框内添加几行文字,并且格式化的将它们统一风格就会变得很乏味。而 `boxes` 是一个简单实用程序,它使用 ASCII 艺术风格的字符形状框来包围文本。其字符形状默认风格是源代码注释风格,但也提供了一些其他选项。
它真的很容易使用。使用管道,便可以将一个简短问候语塞进字符形状盒子里。
@ -86,7 +88,7 @@ echo "I am a dog" | boxes -d dog -a c
'---------------------------------------'
```
Boxes 程序提供了[很多选项][1] 用于填充、定位甚至处理正则表达式。你可以在其 [项目主页][2] 上了解更多有关 boxes 的信息,或者转到 [GitHub][3] 去下载源代码或者贡献你自己的盒子形状。说到此,如果你正在寻找贡献的好点子,我已经有了一个想法:为什么不贡献一个节日礼物盒子?
`boxes` 程序提供了[很多选项][1] 用于填充、定位甚至处理正则表达式。你可以在其 [项目主页][2] 上了解更多有关 `boxes` 的信息,或者转到 [GitHub][3] 去下载源代码或者贡献你自己的盒子形状。说到此,如果你想给你的提交找个好点子,我已经有了一个想法:为什么不能是一个节日礼物盒子?
```
         _  _
@ -100,11 +102,11 @@ Boxes 程序提供了[很多选项][1] 用于填充、定位甚至处理正则
|____________________|
```
Boxes 是基于 GPLv2 许可证的开源项目。
`boxes` 是基于 GPLv2 许可证的开源项目。
你有特别喜欢的命令行小玩具需要我介绍的吗?这个系列要介绍的小玩具大部分已经有了落实,但还预留了几个空位置。如果你有特别想了解的可以评论留言,我会查看的。如果还有空位置,我会考虑介绍它的。即使要介绍的小玩具已经有 24 个了,但如果我得到了一些很好的意见,我会在最后做一些有价值的提及。
你有特别喜欢的命令行小玩具需要我介绍的吗?这个系列要介绍的小玩具大部分已经落实,但还预留了几个空位置。如果你有特别想了解的可以评论留言,我会查看的。如果还有空位置,我会考虑介绍它的。即使要介绍的小玩具已经有 24 个了,但如果我得到了一些很好的意见,我会在最后做一些有价值的提及。
你可以通过[ Drive a locomotive through your Linux terminal][4] 来查看明天会介绍的命令行小玩具。
你可以通过 [Drive a locomotive through your Linux terminal][4] 来查看明天会介绍的命令行小玩具。
--------------------------------------------------------------------------------
@ -113,7 +115,7 @@ via: https://opensource.com/article/18/12/linux-toy-boxes
作者:[Jason Baker][a]
选题:[lujun9972][b]
译者:[jrg](https://github.com/jrglinux)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,101 +1,99 @@
[#]: collector: (lujun9972)
[#]: translator: ( dianbanjiu )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: translator: (dianbanjiu)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-10353-1.html)
[#]: subject: (5 Ways To Check Laptop Battery Status And Level From Linux Terminal)
[#]: via: (https://www.2daygeek.com/check-laptop-battery-status-and-charging-state-in-linux-terminal/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
从 Linux 终端查看笔记本电池状态等级的 5 个方法
从 Linux 终端查看笔记本电池状态等级的 5 个方法
======
我们可以轻松地通过图形化界面查看当前电量百分比、是否在充电以及当前电量还可以使用多长时间等电池状态,但是却无法查看电池健康度等相关信息。
在这篇文章就是为了解决这些问题。
在 Linux 上有很多实用工具可以用命令行进行使用。
在 Linux 上有很多这样的实用工具,而且可以在命令行使用。
这篇文章今天就要探讨这个主题,我会尽我所能的覆盖尽可能多的信息。
每月检查一次你的电池健康度是一个很好的想法。它可以帮你检查你当前遇到的问题是否与电池或者充电相关。
同时,我们也可以查看电池模组名称、电源、出售商以及电池规格等。
同时,我们也可以查看电池模组名称、电源、商以及电池规格等。
电源管理是在非活跃状态时关闭电源或者切换系统的组件到低耗模式的一种功能。
电源管理是在不使用时关闭电源或者切换系统的组件到低耗模式的一种功能。
### 几种在 Linux 下检查电池状态的实用工具
* `upower`: upower 是一个提供了接口来罗列系统中电源的命令行工具。
* `acpi`: acpi显示来自 /proc 或者 /sys 文件中的一些信息,例如电池状态或者热量信息
* `batstat`: batstat 是一个为 Linux 打印电池状态的命令行工具。
* `tlp`: TLP 可以为你带来更高级的电源管理,而无需修改任何配置。
* `class file`: 这个文件系统是一个提供了内核数据结构接口的伪文件系统。
* `upower`:是一个命令行工具,其提供了罗列系统中电源的接口。
* `acpi`:显示来自 `/proc` 或者 `/sys` 文件系统中的一些信息,例如电池状态或者热量信息。
* `batstat`:是一个为 Linux 打印电池状态的命令行工具。
* `tlp`:可以为你带来更高级的电源管理,而无需修改任何配置。
* `class file`:这个 sysfs 文件系统是一个提供了内核数据结构接口的伪文件系统。
### 如何使用 upower 命令检查笔记本电池状态
[upower][1] 是一个提供了接口来罗列系统中电源的命令行工具。它在你的电脑上可以控制不同操作的延迟,这可以为你节省很大一部分电量。
[upower][1] 是一个命令行工具,其提供了罗列系统中电源的接口。它在你的电脑上可以控制不同操作的延迟,这可以为你节省很大一部分电量。
只需要在 Linux 中运行以下命令获取电池以及它所依赖的其他信息。
```
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
native-path: BAT0
vendor: SMP
model: L14M4P23
serial: 756
power supply: yes
updated: Monday 03 December 2018 07:56:18 PM IST (95 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
warning-level: none
energy: 28.23 Wh
energy-empty: 0 Wh
energy-full: 52.26 Wh
energy-full-design: 60 Wh
energy-rate: 10.714 W
voltage: 14.819 V
time to empty: 2.6 hours
percentage: 54%
capacity: 87.1%
technology: lithium-ion
icon-name: 'battery-good-symbolic'
History (charge):
1543847178 54.000 discharging
History (rate):
1543847178 10.714 discharging
native-path: BAT0
vendor: SMP
model: L14M4P23
serial: 756
power supply: yes
updated: Monday 03 December 2018 07:56:18 PM IST (95 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
warning-level: none
energy: 28.23 Wh
energy-empty: 0 Wh
energy-full: 52.26 Wh
energy-full-design: 60 Wh
energy-rate: 10.714 W
voltage: 14.819 V
time to empty: 2.6 hours
percentage: 54%
capacity: 87.1%
technology: lithium-ion
icon-name: 'battery-good-symbolic'
History (charge):
1543847178 54.000 discharging
History (rate):
1543847178 10.714 discharging
```
使用下面的格式检查电池的特定信息。
```
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -i "state\|percentage\|time to empty"
state: discharging
time to empty: 2.1 hours
percentage: 43%
state: discharging
time to empty: 2.1 hours
percentage: 43%
```
这个类似于上面的那个,但是充电线缆的插入就相当于一个令牌,这也就是为什么下面会显示正在充电状态的原因。
这个类似于上面的那个,但是是在充电线缆的插入后运行,这也就是为什么下面会显示正在充电状态的原因。
```
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -i "state\|percentage\|time to empty"
state: charging
percentage: 41%
state: charging
percentage: 41%
```
### 如何使用 TLP 命令检查笔记本电池状态
TLP 是一个自由开源多功能的命令行工具,它可以优化笔记本电池而无需修改任何配置。
TLP 是一个自由开源多功能的命令行工具,它可以优化笔记本电池而无需修改任何配置。
TLP 可以为你的 Linux 带来更高级的电源管理而无需理解任何技术细节。TLP 默认附带了一个已经为你的电池优化好的配置,所以你可以安装好后就不再管它了。尽管 TLP 是一个可以根据你的需求高度可定制的工具。
TLP 在绝大多数 Linux 发行版,例如 Arch、Debian、Fedora、Gentoo、openSUSE等的官方库中都可用。使用你的 Linux 发行版的包管理安装 TLP 即可。
TLP 在绝大多数 Linux 发行版,例如 Arch、Debian、Fedora、Gentoo、openSUSE 等的官方库中都可用。使用你的 Linux 发行版的包管理安装 TLP 即可。
只需要在 Linux 中运行以下命令获取电池以及其他所依赖的信息。
@ -104,17 +102,17 @@ $ sudo tlp-stat -b
--- TLP 1.1 --------------------------------------------
+++ Battery Status
/sys/class/power_supply/BAT0/manufacturer = SMP
/sys/class/power_supply/BAT0/model_name = L14M4P23
/sys/class/power_supply/BAT0/cycle_count = (not supported)
/sys/class/power_supply/BAT0/energy_full_design = 60000 [mWh]
/sys/class/power_supply/BAT0/energy_full = 52260 [mWh]
/sys/class/power_supply/BAT0/energy_now = 21950 [mWh]
/sys/class/power_supply/BAT0/power_now = 10923 [mW]
/sys/class/power_supply/BAT0/status = Discharging
/sys/class/power_supply/BAT0/manufacturer = SMP
/sys/class/power_supply/BAT0/model_name = L14M4P23
/sys/class/power_supply/BAT0/cycle_count = (not supported)
/sys/class/power_supply/BAT0/energy_full_design = 60000 [mWh]
/sys/class/power_supply/BAT0/energy_full = 52260 [mWh]
/sys/class/power_supply/BAT0/energy_now = 21950 [mWh]
/sys/class/power_supply/BAT0/power_now = 10923 [mW]
/sys/class/power_supply/BAT0/status = Discharging
Charge = 42.0 [%]
Capacity = 87.1 [%]
Charge = 42.0 [%]
Capacity = 87.1 [%]
```
也可以查看其他的信息。
@ -124,24 +122,23 @@ $ sudo tlp-stat -s
--- TLP 1.1 --------------------------------------------
+++ System Info
System = LENOVO Lenovo ideapad Y700-15ISK 80NV
BIOS = CDCN35WW
Release = "Manjaro Linux"
Kernel = 4.19.6-1-MANJARO #1 SMP PREEMPT Sat Dec 1 12:21:26 UTC 2018 x86_64
/proc/cmdline = BOOT_IMAGE=/boot/vmlinuz-4.19-x86_64 root=UUID=69d9dd18-36be-4631-9ebb-78f05fe3217f rw quiet resume=UUID=a2092b92-af29-4760-8e68-7a201922573b
Init system = systemd
Boot mode = BIOS (CSM, Legacy)
System = LENOVO Lenovo ideapad Y700-15ISK 80NV
BIOS = CDCN35WW
Release = "Manjaro Linux"
Kernel = 4.19.6-1-MANJARO #1 SMP PREEMPT Sat Dec 1 12:21:26 UTC 2018 x86_64
/proc/cmdline = BOOT_IMAGE=/boot/vmlinuz-4.19-x86_64 root=UUID=69d9dd18-36be-4631-9ebb-78f05fe3217f rw quiet resume=UUID=a2092b92-af29-4760-8e68-7a201922573b
Init system = systemd
Boot mode = BIOS (CSM, Legacy)
+++ TLP Status
State = enabled
Last run = 07:16:12 IST, 4362 sec(s) ago
Mode = battery
Power source = battery
```
State = enabled
Last run = 07:16:12 IST, 4362 sec(s) ago
Mode = battery
Power source = battery```
### 如何使用 ACPI 命令检查电池状态
ACPI 代表高级配置和电源接口模块,它们是不同 ACPI 部件的内核模块。它们启用特殊的 ACPI 函数向 /proc 或者 /sys 中添加信息。这些信息可以通过事件或者其他监控程序的 acpid 进行解析。
ACPI 代表<ruby>高级配置和电源接口<rt>Advanced Configuration and Power Interface</rt></ruby>模块,它们是不同 ACPI 部件的内核模块。它们启用特殊的 ACPI 函数向 `/proc` 或者 `/sys` 中添加信息。这些信息可以通过事件或者其他监控程序的 acpid 进行解析。
```
$ acpi
@ -179,25 +176,25 @@ Cooling 11: Processor 0 of 10
### 如何使用 Batstat 命令查看笔记本电池状态
batstat 是一个在 Linux 终端打印电池信息的命令行工具。
`batstat` 是一个在 Linux 终端打印电池信息的命令行工具。
```
Status: Charging
Max energy: 50.00 Wh
Energy left: 24.50 Wh
Power Consumption: 26.40 W
Percentage left: 49.00%
Average power Consumption: 0.00 W
Time elapsed: 0: 0:12 since 49.00%
= Time ======== Percent ============================================
0: 0: 0 49.00%
Status: Charging
Max energy: 50.00 Wh
Energy left: 24.50 Wh
Power Consumption: 26.40 W
Percentage left: 49.00%
Average power Consumption: 0.00 W
Time elapsed: 0: 0:12 since 49.00%
= Time ======== Percent ============================================
0: 0: 0 49.00%
```
### 如何使用 sysfs 文件系统查看笔记本电池状态
sysfs 文件系统是一个提供了内核数据结构接口的伪文件系统。sysfs 下的文件提供有关设备、内核模块、文件系统和其他内核组件的信息。
sysfs 文件系统通常挂载在 /sys。通常来说它会被系统自动挂载但是也可以使用例如 `mount -t sysfs sysfs /sys` 命令进行手动挂载。
sysfs 文件系统通常挂载在 `/sys`。通常来说,它会被系统自动挂载,但是也可以使用例如 `mount -t sysfs sysfs /sys` 命令进行手动挂载。
在 sysfs 文件系统中的很多文件都是只读的,但也有一些是可写的,允许更改内核变量。为了避免冗余,符号链接被大量用于连接文件系统数中的条目。
@ -216,7 +213,7 @@ L14M4P23
cat: /sys/class/power_supply/BAT0/power: Is a directory
27656000
1
756
756
Charging
cat: /sys/class/power_supply/BAT0/subsystem: Is a directory
Li-ion
@ -236,7 +233,7 @@ POWER_SUPPLY_CAPACITY=51
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=L14M4P23
POWER_SUPPLY_MANUFACTURER=SMP
POWER_SUPPLY_SERIAL_NUMBER= 756
POWER_SUPPLY_SERIAL_NUMBER= 756
14800000
15840000
```
@ -248,7 +245,7 @@ via: https://www.2daygeek.com/check-laptop-battery-status-and-charging-state-in-
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[dianbanjiu](https://github.com/dianbanjiu)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,155 +0,0 @@
Translating by MjSeven
Users, Groups, and Other Linux Beasts
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/flamingo-2458782_1920.jpg?itok=_gkzGGx5)
Having reached this stage, [after seeing how to manipulate folders/directories][1], but before flinging ourselves headlong into fiddling with files, we have to brush up on the matter of _permissions_ , _users_ and _groups_. Luckily, [there is already an excellent and comprehensive tutorial on this site that covers permissions][2], so you should go and read that right now. In a nutshell: you use permissions to establish who can do stuff to files and directories and what they can do with each file and directory -- read from it, write to it, move it, erase it, etc.
To try everything this tutorial covers, you'll need to create a new user on your system. Let's be practical and make a user for anybody who needs to borrow your computer, that is, what we call a _guest account_.
**WARNING:** _Creating and especially deleting users, along with home directories, can seriously damage your system if, for example, you remove your own user and files by mistake. You may want to practice on another machine which is not your main work machine or on a virtual machine. Regardless of whether you want to play it safe, or not, it is always a good idea to back up your stuff frequently, check the backups have worked correctly, and save yourself a lot of gnashing of teeth later on._
### A New User
You can create a new user with the `useradd` command. Run `useradd` with superuser/root privileges, that is using `sudo` or `su`, depending on your system, you can do:
```
sudo useradd -m guest
```
... and input your password. Or do:
```
su -c "useradd -m guest"
```
... and input the password of root/the superuser.
( _For the sake of brevity, we'll assume from now on that you get superuser/root privileges by using`sudo`_ ).
By including the `-m` argument, `useradd` will create a home directory for the new user. You can see its contents by listing _/home/guest_.
Next you can set up a password for the new user with
```
sudo passwd guest
```
Or you could also use `adduser`, which is interactive and asks you a bunch of questions, including what shell you want to assign the user (yes, there are more than one), where you want their home directory to be, what groups you want them to belong to (more about that in a second) and so on. At the end of running `adduser`, you get to set the password. Note that `adduser` is not installed by default on many distributions, while `useradd` is.
Incidentally, you can get rid of a user with `userdel`:
```
sudo userdel -r guest
```
With the `-r` option, `userdel` not only removes the _guest_ user, but also deletes their home directory and removes their entry in the mailing spool, if they had one.
### Skeletons at Home
Talking of users' home directories, depending on what distro you're on, you may have noticed that when you use the `-m` option, `useradd` populates a user's directory with subdirectories for music, documents, and whatnot as well as an assortment of hidden files. To see everything in you guest's home directory run `sudo ls -la /home/guest`.
What goes into a new user's directory is determined by a skeleton directory which is usually _/etc/skel_. Sometimes it may be a different directory, though. To check which directory is being used, run:
```
useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no
```
This gives you some extra interesting information, but what you're interested in right now is the `SKEL=/etc/skel` line. In this case, and as is customary, it is pointing to _/etc/skel/_.
As everything is customizable in Linux, you can, of course, change what gets put into a newly created user directory. Try this: Create a new directory in _/etc/skel/_ :
```
sudo mkdir /etc/skel/Documents
```
And create a file containing a welcome text and copy it over:
```
sudo cp welcome.txt /etc/skel/Documents
```
Now delete the guest account:
```
sudo userdel -r guest
```
And create it again:
```
sudo useradd -m guest
```
Hey presto! Your _Documents/_ directory and _welcome.txt_ file magically appear in the guest's home directory.
You can also modify other things when you create a user by editing _/etc/default/useradd_. Mine looks like this:
```
GROUP=users
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no
```
Most of these options are self-explanatory, but let's take a closer look at the `GROUP` option.
### Herd Mentality
Instead of assigning permissions and privileges to users one by one, Linux and other Unix-like operating systems rely on _groups_. A group is a what you imagine it to be: a bunch of users that are related in some way. On your system you may have a group of users that are allowed to use the printer. They would belong to the _lp_ (for " _line printer_ ") group. The members of the _wheel_ group were traditionally the only ones who could become superuser/root by using _su_. The _network_ group of users can bring up and power down the network. And so on and so forth.
Different distributions have different groups and groups with the same or similar names have different privileges also depending on the distribution you are using. So don't be surprised if what you read in the prior paragraph doesn't match what is going on in your system.
Either way, to see which groups are on your system you can use:
```
getent group
```
The `getent` command lists the contents of some of the system's databases.
To find out which groups your current user belongs to, try:
```
groups
```
When you create a new user with `useradd`, unless you specify otherwise, the user will only belong to one group: their own. A _guest_ user will belong to a _guest_ group and the group gives the user the power to administer their own stuff and that is about it.
You can create new groups and then add users to them at will with the `groupadd` command:
```
sudo groupadd photos
```
will create the _photos_ group, for example. Next time, well use this to build a shared directory all members of the group can read from and write to, and we'll learn even more about permissions and privileges. Stay tuned!
Learn more about Linux through the free ["Introduction to Linux" ][3]course from The Linux Foundation and edX.
--------------------------------------------------------------------------------
via: https://www.linux.com/learn/intro-to-linux/2018/7/users-groups-and-other-linux-beasts
作者:[Paul Brown][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linux.com/users/bro66
[1]:https://www.linux.com/blog/learn/2018/5/manipulating-directories-linux
[2]:https://www.linux.com/learn/understanding-linux-file-permissions
[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux

View File

@ -1,153 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Four Easy Ways to Search Or Find Files And Folders in Linux)
[#]: via: (https://www.2daygeek.com/four-easy-ways-to-search-or-find-files-and-folders-in-linux/)
[#]: author: (Prakash Subramanian https://www.2daygeek.com/author/prakash/)
Four Easy Ways to Search Or Find Files And Folders in Linux
======
Linux admins cant able to leave a day without performing a file search as this one of the activity for their routine.
Its good to know all the file search stuffs because it would help you in many ways when you are working on headless server.
These commands are not complicate to remember because these are using a standard syntax.
This can be performed through Four Linux commands and each command has their own unique feature.
### Method-1: Search Files And Folders in Linux Using find Command
Find command is widely used and very famous command to search files and folders in Linux. It searches given files in the current directory and recursively through its sub-directories based on the search criteria.
It allow users to perform all kind of file searches based on the criteria lie by size, name, owner, group, type, permissions, date, and other criteria.
Run the following command to find a given file in system.
```
# find / -iname "sshd_config"
/etc/ssh/sshd_config
```
Run the following command to find a given folder in system. To search a folder in Linux we need to use `-type` parameter.
```
# find / -type d -iname "ssh"
/usr/lib/ssh
/usr/lib/go/src/cmd/vendor/golang.org/x/crypto/ssh
/usr/lib/go/pkg/linux_amd64/cmd/vendor/golang.org/x/crypto/ssh
/etc/ssh
```
Use wildcard option to search set of files on your system. We are going to search all files available in the system with `.config` extension.
```
# find / -name "*.config"
/usr/lib/mono/gac/avahi-sharp/1.0.0.0__4d116c78973743f5/avahi-sharp.dll.config
/usr/lib/mono/gac/avahi-ui-sharp/0.0.0.0__4d116c78973743f5/avahi-ui-sharp.dll.config
/usr/lib/python2.7/config/Setup.config
/usr/share/git/mw-to-git/t/test.config
/var/lib/lightdm/.config
/home/daygeek/.config
/root/.config
/etc/skel/.config
```
Use the following command format to find an empty files and folders in system.
```
# find / -empty
```
Use the following command combination to find all files containing specific text on Linux.
```
# find / -type f -exec grep "Port 22" '{}' \; -print
# find / -type f -print | xargs grep "Port 22"
# find / -type f | xargs grep 'Port 22'
# find / -type f -exec grep -H 'Port 22' {} \;
```
### Method-2: Search Files And Folders in Linux Using locate command
locate command works faster than the find command because it uses updatedb database, whereas the find command searches in the real system.
It uses a database rather than hunting individual directory paths to get a given file.
locate command doesnt pre-installed in most of the distributions so, use your distribution package manager to install it.
The database is updated regularly through cron, however we can manually update it by running the following command.
```
$ sudo updatedb
```
Simply run the following command to list the given file or folder. There is no specific options need to be specified in locate command to print file or folder.
To search `ssh` folder in system.
```
# locate --basename '\ssh'
/etc/ssh
/usr/bin/ssh
/usr/lib/ssh
/usr/lib/go/pkg/linux_amd64/cmd/vendor/golang.org/x/crypto/ssh
/usr/lib/go/src/cmd/go/testdata/failssh/ssh
/usr/lib/go/src/cmd/vendor/golang.org/x/crypto/ssh
```
To search `ssh_config` file in system.
```
# locate --basename '\sshd_config'
/etc/ssh/sshd_config
```
### Method-3: Search Files in Linux Using which command
TThe which command returns the full path of the executable that would have been executed when the command had been entered in terminal.
Its very useful when you want to create a desktop shortcut or symbolic link for executable files.
Which command searches the directories listed in the current users PATH environment variable not for all the users. I mean, when you are logged in your own account and you cant able to search for root user file or directory.
Run the following command to print the full path of the vim executable file location.
```
# which vi
/usr/bin/vi
```
Alternatively, its allowing user to perform multiple file search in one shot.
```
# which -a vi sudo
/usr/bin/vi
/bin/vi
/usr/bin/sudo
/bin/sudo
```
### Method-4: Search Files in Linux Using whereis command
The whereis command used to search the binary, source, and man page files for a given command.
```
# whereis vi
vi: /usr/bin/vi /usr/share/man/man1/vi.1p.gz /usr/share/man/man1/vi.1.gz
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/four-easy-ways-to-search-or-find-files-and-folders-in-linux/
作者:[Prakash Subramanian][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/prakash/
[b]: https://github.com/lujun9972

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (HankChow)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -0,0 +1,139 @@
用户,组和其他 Linux 用户
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/flamingo-2458782_1920.jpg?itok=_gkzGGx5)
到这个阶段,[在看到如何操作目录或文件夹之后][1],但在让自己一头扎进文件之前,我们必须重新审视 _权限_, _users__group_。幸运的是,[有一个网站上已经有了一个优秀而全面的教程,包括了权限][2],所以你应该去立刻阅读它。简而言之,你使用权限来确定谁可以对文件和目录执行操作,以及他们可以对每个文件和目录执行什么操作 -- 从中读取,写入,擦除等等。
要尝试本教程涵盖的所有内容,你需要在系统上创建新用户。让我们实践起来,为每一个需要借用你电脑的人创建一个用户,我们称之为 _guest 账户_
**警告:** _例如如果你错误地删除了自己的用户和目录那么创建特别是删除用户以及主目录会严重损坏系统。你可能不想在你日常的工作机中练习那么请在另一台机器或者虚拟机上练习。无论你是否想要安全地练习经常备份你的东西总是一个好主意。检查备份是否正常工作为你自己以后避免很多咬牙切齿的事情。_
### 一个新用户
你可以使用 `useradd` 命令来创建一个新用户。使用超级用户或 root 权限运行 `useradd`,即使用 `sudo``su`,这具体取决于你的系统,你可以:
```
sudo useradd -m guest
```
然后输入你的密码。或者也可以这样:
```
su -c "useradd -m guest"
```
然后输入 root 或超级用户的密码。
_为了简洁起见我们将从现在开始假设你使用 `sudo` 获得超级用户或 root 权限。_
通过使用 `-m` 参数,`useradd` 将为新用户创建一个主目录。你可以通过列出 _/home/guest_ 来查看其内容。
然后你可以使用以下命令来为新用户设置密码:
```
sudo passwd guest
```
或者你也可以使用 `adduser`,这是一个交互式的命令,它会询问你一些问题,包括你要为用户分配的 shell是的不止一个你希望其主目录在哪里你希望他们属于哪些组有关这点稍后会讲到等等。在运行 `adduser` 结束时,你可以设置密码。注意,默认情况下,在许多发行版中都没有安装 `adduser`,但安装了 `useradd`
顺便说一下,你可以使用 `userdel` 来移除一个用户:
```
sudo userdel -r guest
```
使用 `-r` 选项,`userdel` 不仅删除了 _guest_ 用户,还删除了他们的主目录和邮件中的条目(如果有的话)。
### home 中的内容
谈到用户的主目录,它依赖于你所使用的发行版。你可能已经注意到,当你使用 `-m` 选项时,`useradd` 使用子目录填充用户的目录,包括音乐,文档和诸如此类的内容以及各种各样的隐藏文件。要查看 guest 主目录中的所有内容,运行 `sudo ls -la /home/guest`
进入新用户目录的内容通常是由 _/etc/skel_ 架构目录确定的。有时它可能是一个不同的目录。要检查正在使用的目录,运行:
```
useradd -D
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no
```
这给你一些额外的有趣信息,但你现在感兴趣的是 `SKEL=/etc/skel` 这一行,在这种情况下,按照惯例,它指向 _/etc/skel/_
由于 Linux 中的所有东西都是可定制的,因此你可以更改那些放入新创建的用户目录的内容。试试这样做:在 _/etc/skel/_ 中创建一个新目录:
```
sudo mkdir /etc/skel/Documents
```
然后创建一个包含欢迎消息的文件,并将其复制过来:
```
sudo cp welcome.txt /etc/skel/Documents
```
现在删除 guest 账户:
```
sudo userdel -r guest
```
再次创建:
```
sudo useradd -m guest
```
嘿 presto(to 校正:这个 presto 是什么?)你的 _Documents/_ 目录和 _welcome.txt_ 文件神奇地出现在了 guest 的主目录中。
你还可以在创建用户时通过编辑 _/etc/default/useradd_ 来修改其他内容。我的看起来像这样:
```
GROUP=users
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=no
```
这些选项大多数都是不言自明的,但让我们仔细看看 `GROUP` 选项。
### 群组心态
Linux 和其他类 Unix 操作系统依赖于 _groups_,而不是逐个为用户分配权限和特权。一个组就是你想象的那样:一群在某种程度上相关的用户。在你的系统上可能有一组允许使用打印机的用户,他们属于 _lp_(即 "_line printer_")组。传统上 _wheel_ 组的成员是唯一可以通过使用 _su_ 成为超级用户或 root 的成员。_network_ 用户组可以启动或关闭网络。还有许多诸如此类的。
不同的发行版有不同的组,具有相同或相似名称的组具有不同的权限,这也取决于你使用的发行版。因此,如果你在前一段中读到的内容与你系统中的内容不匹配,不要感到惊讶。
不管怎样g要查看系统中有哪些组你可以使用
```
getent group
```
`getent` 命令列出了某些系统数据库的内容。
要查找当前用户所属的组,尝试:
```
groups
```
当你使用 `useradd` 创建新用户时,除非你另行指定,否则用户讲只属于一个组:他们自己。一个 _guest_ 用户属于 _guest_ 组。组使用户有权管理自己的东西,仅此而已。
你可以使用 `groupadd` 命令创建新组,然后添加用户:
```
sudo groupadd photos
```
例如,这将创建 _photos_ 组。下一次,我们将使用它来构建一个共享目录,该组的所有成员都可以读取和写入,我们将更多地了解权限和特权。敬请关注!
--------------------------------------------------------------------------------
via: https://www.linux.com/learn/intro-to-linux/2018/7/users-groups-and-other-linux-beasts
作者:[Paul Brown][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[MjSeven](https://github.com/MjSeven)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linux.com/users/bro66
[1]:https://www.linux.com/blog/learn/2018/5/manipulating-directories-linux
[2]:https://www.linux.com/learn/understanding-linux-file-permissions
[3]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux

View File

@ -0,0 +1,153 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Four Easy Ways to Search Or Find Files And Folders in Linux)
[#]: via: (https://www.2daygeek.com/four-easy-ways-to-search-or-find-files-and-folders-in-linux/)
[#]: author: (Prakash Subramanian https://www.2daygeek.com/author/prakash/)
四种简单的方法来搜索或查找 Linux 中的文件和文件夹
======
Linux 管理员一天都不能离开搜索文件,因为这是他们的日常活动。
了解一些搜索的东西是不错的,因为这能帮助你在命令行服务器中工作。
这些命令记忆起来不复杂,因为它们使用的是标准语法。
这里执行四个 Linux 命令,每个命令都有自己独特的功能。
### 方法 1使用 find 命令在 Linux 中搜索文件和文件夹
find 命令被广泛使用,并且是非常著名的在 Linux 中搜索文件和文件夹的命令。它搜索当前目录中的给定文件,并根据搜索条件递归遍历其子目录。
它允许用户根据大小、名称、所有者、组、类型、权限、日期和其他条件执行所有类型的文件搜索。
运行以下命令以在系统中查找给定文件。
```
# find / -iname "sshd_config"
/etc/ssh/sshd_config
```
运行以下命令以查找系统中的给定文件夹。要在 Linux 中搜索文件夹,我们需要使用 `-type` 参数。
```
# find / -type d -iname "ssh"
/usr/lib/ssh
/usr/lib/go/src/cmd/vendor/golang.org/x/crypto/ssh
/usr/lib/go/pkg/linux_amd64/cmd/vendor/golang.org/x/crypto/ssh
/etc/ssh
```
使用通配符搜索系统上的所有文件。我们将搜索系统中所有以 `.config` 为扩展名的文件。
```
# find / -name "*.config"
/usr/lib/mono/gac/avahi-sharp/1.0.0.0__4d116c78973743f5/avahi-sharp.dll.config
/usr/lib/mono/gac/avahi-ui-sharp/0.0.0.0__4d116c78973743f5/avahi-ui-sharp.dll.config
/usr/lib/python2.7/config/Setup.config
/usr/share/git/mw-to-git/t/test.config
/var/lib/lightdm/.config
/home/daygeek/.config
/root/.config
/etc/skel/.config
```
使用以下命令格式在系统中查找空文件和文件夹。
```
# find / -empty
```
使用以下命令组合查找 Linux 上包含特定文本的所有文件。
```
# find / -type f -exec grep "Port 22" '{}' \; -print
# find / -type f -print | xargs grep "Port 22"
# find / -type f | xargs grep 'Port 22'
# find / -type f -exec grep -H 'Port 22' {} \;
```
### 方法 2使用 locate 命令在 Linux 中搜索文件和文件夹
locate 命令比 find 命令运行得更快,因为它使用 updatedb 数据库,而 find 命令在真实系统中搜索。
它使用数据库而不是搜索单个目录路径来获取给定文件。
locate 命令未在大多数发行版中预安装,因此,请使用你的包管理器进行安装。
数据库通过 cron 定期更新,但我们可以通过运行以下命令手动更新它。
```
$ sudo updatedb
```
只需运行以下命令即可列出给定的文件或文件夹。在 locate 命令中不需要指定特定选项来打印文件或文件夹。
在系统中搜索 `ssh` 文件夹。
```
# locate --basename '\ssh'
/etc/ssh
/usr/bin/ssh
/usr/lib/ssh
/usr/lib/go/pkg/linux_amd64/cmd/vendor/golang.org/x/crypto/ssh
/usr/lib/go/src/cmd/go/testdata/failssh/ssh
/usr/lib/go/src/cmd/vendor/golang.org/x/crypto/ssh
```
在系统中搜索 `ssh_config` 文件。
```
# locate --basename '\sshd_config'
/etc/ssh/sshd_config
```
### 方法 3在 Linux 中搜索文件使用 which 命令
which 返回在终端输入命令时执行的可执行文件的完整路径。
当你想要为可执行文件创建桌面快捷方式或符号链接时,它非常有用。
which 命令搜索当前用户而不是所有用户的 PATH 环境变量中列出的目录。我的意思是,当你登录自己的帐户时,你无法搜索 root 用户文件或目录。
运行以下命令以打印 vim 可执行文件的完整路径。
```
# which vi
/usr/bin/vi
```
或者,它允许用户一次执行多个文件搜索。
```
# which -a vi sudo
/usr/bin/vi
/bin/vi
/usr/bin/sudo
/bin/sudo
```
### 方法 4使用 whereis 命令在 Linux 中搜索文件
whereis 命令用于搜索给定命令的二进制、源码和手册页文件。
```
# whereis vi
vi: /usr/bin/vi /usr/share/man/man1/vi.1p.gz /usr/share/man/man1/vi.1.gz
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/four-easy-ways-to-search-or-find-files-and-folders-in-linux/
作者:[Prakash Subramanian][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.2daygeek.com/author/prakash/
[b]: https://github.com/lujun9972