mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
b26dabf384
202
published/20190627 How to use Tig to browse Git logs.md
Normal file
202
published/20190627 How to use Tig to browse Git logs.md
Normal file
@ -0,0 +1,202 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11069-1.html)
|
||||
[#]: subject: (How to use Tig to browse Git logs)
|
||||
[#]: via: (https://opensource.com/article/19/6/what-tig)
|
||||
[#]: author: (Olaf Alders https://opensource.com/users/oalders/users/mbbroberg/users/marcobravo)
|
||||
|
||||
如何使用 Tig 浏览 Git 日志
|
||||
======
|
||||
|
||||
> Tig 可不仅仅是 Git 的文本界面。以下是它如何增强你的日常工作流程。
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/201907/07/111847v1zx3qk5qqhklyjp.png)
|
||||
|
||||
如果你使用 Git 作为你的版本控制系统,你可能已经让自己接受了 Git 是一个复杂的野兽的事实。它是一个很棒的工具,但浏览 Git 仓库可能很麻烦。因此像 [Tig][2] 这样的工具出现了。
|
||||
|
||||
来自 [Tig 手册页][3]:
|
||||
|
||||
> Tig 是 `git`(1) 的基于 ncurses 的文本界面。它主要用作 Git 仓库浏览器,但也有助于在块级别暂存提交更改,并作为各种 Git 命令的输出分页器。
|
||||
|
||||
这基本上意味着 Tig 提供了一个可以在终端中运行的基于文本的用户界面。Tig 可以让你轻松浏览你的 Git 日志,但它可以做的远不止让你从最后的提交跳到前一个提交。
|
||||
|
||||
![Tig screenshot][4]
|
||||
|
||||
这篇快速入门的 Tig 中的许多例子都是直接从其出色的手册页中拿出来的。我强烈建议你阅读它以了解更多信息。
|
||||
|
||||
### 安装 Tig
|
||||
|
||||
* Fedora 和 RHEL: `sudo dnf install tig`
|
||||
* Ubuntu 和 Debian: `sudo apt install tig`
|
||||
* MacOS: `:brew install tig`
|
||||
|
||||
有关更多方式,请参阅官方[安装说明][5]。
|
||||
|
||||
### 浏览当前分支中的提交
|
||||
|
||||
如果要浏览分支中的最新提交,请输入:
|
||||
|
||||
```
|
||||
tig
|
||||
```
|
||||
|
||||
就是这样。这个三字符命令将启动一个浏览器,你可以在其中浏览当前分支中的提交。你可以将其视为 `git log` 的封装器。
|
||||
|
||||
要浏览这些输出,可以使用向上和向下箭头键从一个提交移动到另一个提交。按回车键将会垂直分割窗口,右侧包含所选提交的内容。你可以继续在左侧的提交历史记录中上下浏览,你的更改将显示在右侧。使用 `k` 和 `j` 可以逐行上下浏览,`-` 和空格键可以在右侧上下翻页。使用 `q` 退出右侧窗格。
|
||||
|
||||
搜索 `tig` 输出也很简单。使用 `/` (向前)或 `?` (向后)在左右窗格中搜索。
|
||||
|
||||
![Searching Tig][6]
|
||||
|
||||
这些就足以让你浏览你的提交信息了。这里有很多的键绑定,但单击 `h` 将显示“帮助”菜单,你可以在其中发现其导航和命令选项。你还可以使用 `/` 和 `?` 来搜索“帮助”菜单。使用 `q` 退出帮助。
|
||||
|
||||
![Tig Help][7]
|
||||
|
||||
### 浏览单个文件的修改
|
||||
|
||||
由于 Tig 是 `git log` 的封装器,它可以方便地接受可以传递给 `git log` 的相同参数。例如,要浏览单个文件的提交历史记录,请输入:
|
||||
|
||||
```
|
||||
tig README.md
|
||||
```
|
||||
|
||||
将其与被封装的 Git 命令的输出进行比较,以便更清楚地了解 Tig 如何增强输出。
|
||||
|
||||
```
|
||||
git log README.md
|
||||
```
|
||||
|
||||
要在原始 Git 输出中包含补丁,你可以添加 `-p` 选项:
|
||||
|
||||
```
|
||||
git log -p README.md
|
||||
```
|
||||
|
||||
如果要将提交范围缩小到特定日期范围,请尝试以下操作:
|
||||
|
||||
```
|
||||
tig --after="2017-01-01" --before="2018-05-16" -- README.md
|
||||
```
|
||||
|
||||
再一次,你可以将其与原始的 Git 版本进行比较:
|
||||
|
||||
|
||||
```
|
||||
git log --after="2017-01-01" --before="2018-05-16" -- README.md
|
||||
```
|
||||
|
||||
### 浏览谁更改了文件
|
||||
|
||||
有时你想知道谁对文件进行了更改以及原因。命令:
|
||||
|
||||
```
|
||||
tig blame README.md
|
||||
```
|
||||
|
||||
器本质上是 `git blame` 的封装。正如你所期望的那样,它允许你查看谁是编辑指定行的最后一人,它还允许你查看到引入该行的提交。这有点像 vim 的 `vim-fugitive` 插件提供的 `:Gblame` 命令。
|
||||
|
||||
### 浏览你的暂存区
|
||||
|
||||
如果你像我一样,你可能会在你的暂存区做了许多修改。你很容易忘记它们。你可以通过以下方式查看暂存处中的最新项目:
|
||||
|
||||
```
|
||||
git stash show -p stash@{0}
|
||||
```
|
||||
|
||||
你可以通过以下方式找到第二个最新项目:
|
||||
|
||||
```
|
||||
git stash show -p stash@{1}
|
||||
```
|
||||
|
||||
以此类推。如果你在需要它们时调用这些命令,那么你会有比我更清晰的记忆。
|
||||
|
||||
与上面的 Git 命令一样,Tig 可以通过简单的调用轻松增强你的 Git 输出:
|
||||
|
||||
```
|
||||
tig stash
|
||||
```
|
||||
|
||||
尝试在有暂存的仓库中执行此命令。你将能够浏览*并搜索*你的暂存项,快速浏览你的那些修改。
|
||||
|
||||
### 浏览你的引用
|
||||
|
||||
Git ref 是指你提交的东西的哈希值。这包括文件和分支。使用 `tig refs` 命令可以浏览所有的 ref 并深入查看特定提交。
|
||||
|
||||
```
|
||||
tig refs
|
||||
```
|
||||
|
||||
完成后,使用 `q` 回到前面的菜单。
|
||||
|
||||
### 浏览 git 状态
|
||||
|
||||
如果要查看哪些文件已被暂存,哪些文件未被跟踪,请使用 `tig status`,它是 `git status` 的封装。
|
||||
|
||||
![Tig status][8]
|
||||
|
||||
### 浏览 git grep
|
||||
|
||||
你可以使用 `grep` 命令在文本文件中搜索表达式。命令 `tig grep` 允许你浏览 `git grep` 的输出。例如:
|
||||
|
||||
```
|
||||
tig grep -i foo lib/Bar
|
||||
```
|
||||
|
||||
它会让你浏览 `lib/Bar` 目录中以大小写敏感的方式搜索 `foo` 的输出。
|
||||
|
||||
### 通过标准输入管道输出给 Tig
|
||||
|
||||
如果要将提交 ID 列表传递给 Tig,那么必须使用 `--stdin` 标志,以便 `tig show` 从标准输入读取。否则,`tig show` 会在没有输入的情况下启动(出现空白屏幕)。
|
||||
|
||||
```
|
||||
git rev-list --author=olaf HEAD | tig show --stdin
|
||||
```
|
||||
|
||||
### 添加自定义绑定
|
||||
|
||||
你可以使用 [rc][9] 文件自定义 Tig。以下是如何根据自己的喜好添加一些有用的自定义键绑定的示例。
|
||||
|
||||
在主目录中创建一个名为 `.tigrc` 的文件。在你喜欢的编辑器中打开 `~/.tigrc` 并添加:
|
||||
|
||||
```
|
||||
# 应用选定的暂存内容
|
||||
bind stash a !?git stash apply %(stash)
|
||||
|
||||
# 丢弃选定的暂存内容
|
||||
bind stash x !?git stash drop %(stash)
|
||||
```
|
||||
|
||||
如上所述,运行 `tig stash` 以浏览你的暂存。但是,通过这些绑定,你可以按 `a` 将暂存中的项目应用到仓库,并按 `x` 从暂存中删除项目。请记住,你要在浏览暂存*列表*时,才能执行这些命令。如果你正在浏览暂存*项*,请输入 `q` 退出该视图,然后按 `a` 或 `x` 以获得所需效果。
|
||||
|
||||
有关更多信息,你可以阅读有关 [Tig 键绑定][10]。
|
||||
|
||||
### 总结
|
||||
|
||||
我希望这有助于演示 Tig 如何增强你的日常工作流程。Tig 可以做更强大的事情(比如暂存代码行),但这超出了这篇介绍性文章的范围。这里有足够的让你置身于危险的信息,但还有更多值得探索的地方。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/6/what-tig
|
||||
|
||||
作者:[Olaf Alders][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/oalders/users/mbbroberg/users/marcobravo
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming)
|
||||
[2]: https://jonas.github.io/tig/
|
||||
[3]: http://manpages.ubuntu.com/manpages/bionic/man1/tig.1.html
|
||||
[4]: https://opensource.com/sites/default/files/uploads/tig.jpg (Tig screenshot)
|
||||
[5]: https://jonas.github.io/tig/INSTALL.html
|
||||
[6]: https://opensource.com/sites/default/files/uploads/tig-search.png (Searching Tig)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/tig-help.png (Tig Help)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/tig-status.png (Tig status)
|
||||
[9]: https://en.wikipedia.org/wiki/Run_commands
|
||||
[10]: https://github.com/jonas/tig/wiki/Bindings
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (chen-ni)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
@ -0,0 +1,262 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Newsboat – A Command line RSS/Atom Feed Reader For Text Consoles)
|
||||
[#]: via: (https://www.ostechnix.com/newsbeuter-command-line-rssatom-feed-reader-unix-like-systems/)
|
||||
[#]: author: (sk https://www.ostechnix.com/author/sk/)
|
||||
|
||||
Newsboat – A Command line RSS/Atom Feed Reader For Text Consoles
|
||||
======
|
||||
|
||||
![Newsboat RSS/Atom Feed reader][1]
|
||||
|
||||
**Newsboat** , a fork of Newsbeuter, is a free, open source RSS/Atom feed reader for text consoles. It supports GNU/Linux, FreeBSD, Mac OS X, and other Unix-like operating systems. Compared to other slow and huge amount of memory consumed RSS feed readers, Newsboat is the best choice for anyone who are looking for a simple, slick and fast feed reader that can be completely managed via keyboard.
|
||||
|
||||
Concerning about the features, we can list the following:
|
||||
|
||||
* Subscribe to RSS 0.9x, 1.0, 2.0 and Atom feeds.
|
||||
* Download podcasts.
|
||||
* Configure your keyboard shortcuts as per your wish.
|
||||
* Search through all downloaded articles.
|
||||
* Categorize and query your subscriptions with a flexible tag system.
|
||||
* Integrate any data source through a flexible filter and plugin system.
|
||||
* Automatically remove unwanted articles through a “killfile”.
|
||||
* Define “meta feeds” using a powerful query language.
|
||||
* Synchronize newsboatr with your bloglines.com account.
|
||||
* Import and exporting your subscriptions with the widely used OPML format.
|
||||
* Customize the look and feel of Newsboat as per your liking.
|
||||
* Keep all your feeds in sync with Google Reader.
|
||||
* And many.
|
||||
|
||||
|
||||
|
||||
In this brief guide, let us see how to install and use Newsboat in Linux.
|
||||
|
||||
### Newsboat – A Command line RSS/Atom Feed Reader
|
||||
|
||||
##### Installation
|
||||
|
||||
**On Arch Linux and derivatives:**
|
||||
|
||||
Newsboat is available in the [Community] repository of Arch Linux. So, you can install it using [**Pacman**][2] command as shown below.
|
||||
|
||||
```
|
||||
$ sudo pacman -S newsboat
|
||||
```
|
||||
|
||||
**On Debian, Ubuntu, Linux Mint:**
|
||||
|
||||
It is also available in the default repositories of DEB based systems such as Ubuntu, Linux Mint. To install it, run the following command:
|
||||
|
||||
```
|
||||
$ sudo apt-get install newsboat
|
||||
```
|
||||
|
||||
**On Fedora:**
|
||||
|
||||
Newsboat is available in the official repositories of Fedora. To install it, run:
|
||||
|
||||
```
|
||||
$ sudo dnf install newsboat
|
||||
```
|
||||
|
||||
Newsboat is also available as [**Snap**][3], so you can install it using command:
|
||||
|
||||
```
|
||||
$ sudo snap install newsboat
|
||||
```
|
||||
|
||||
Once installed, launch it using command:
|
||||
|
||||
```
|
||||
$ newsboat
|
||||
```
|
||||
|
||||
**Sample output:**
|
||||
|
||||
```
|
||||
Starting newsboat 2.10.2...
|
||||
Loading configuration...done.
|
||||
Opening cache...done.
|
||||
Loading URLs from /home/sk/.newsboat/urls...done.
|
||||
Error: no URLs configured. Please fill the file /home/sk/.newsboat/urls with RSS feed URLs or import an OPML file.
|
||||
|
||||
newsboat 2.10.2
|
||||
usage: newsboat [-i <file>|-e] [-u <urlfile>] [-c <cachefile>] [-x <command> ...] [-h]
|
||||
-e, --export-to-opml export OPML feed to stdout
|
||||
-r, --refresh-on-start refresh feeds on start
|
||||
-i, --import-from-opml=<file> import OPML file
|
||||
-u, --url-file=<urlfile> read RSS feed URLs from <urlfile>
|
||||
-c, --cache-file=<cachefile> use <cachefile> as cache file
|
||||
-C, --config-file=<configfile> read configuration from <configfile>
|
||||
-X, --vacuum compact the cache
|
||||
-x, --execute=<command>... execute list of commands
|
||||
-q, --quiet quiet startup
|
||||
-v, --version get version information
|
||||
-l, --log-level=<loglevel> write a log with a certain loglevel (valid values: 1 to 6)
|
||||
-d, --log-file=<logfile> use <logfile> as output log file
|
||||
-E, --export-to-file=<file> export list of read articles to <file>
|
||||
-I, --import-from-file=<file> import list of read articles from <file>
|
||||
-h, --help this help
|
||||
```
|
||||
|
||||
As you see in the above screenshot, we haven’t added any URLs yet in Newsboat.
|
||||
|
||||
##### Managing Feeds
|
||||
|
||||
We can add, edit, tag, and delete feeds by editing the **urls** file. The default urls file is **~/.newsboat/urls**. If it is not available, just create it.
|
||||
|
||||
**Add feeds**
|
||||
|
||||
To add a feed, edit this file
|
||||
|
||||
```
|
||||
$ vi ~/.newsboat/urls
|
||||
```
|
||||
|
||||
Then, add the feed URLs one by one.
|
||||
|
||||
```
|
||||
http://feeds.feedburner.com/Ostechnix
|
||||
```
|
||||
|
||||
If the feed URL has protected with user name and password, you need to mention the username and password as shown below.
|
||||
|
||||
```
|
||||
http://username:[email protected]/feed.rss
|
||||
```
|
||||
|
||||
After adding all urls, save and close the file.
|
||||
|
||||
**Add tags to the feeds**
|
||||
|
||||
You can add one or more tags to categorize the feeds as per your liking. Specify the tags separated by space if you want to add more than one tags to a single feed. If you want to specify a single tag that contains a space, just mention it within double quotes like below.
|
||||
|
||||
```
|
||||
http://feeds.feedburner.com/Ostechnix "All Linux news"
|
||||
https://www.archlinux.org/feeds/packages/ "Only Arch Linux related news"
|
||||
```
|
||||
|
||||
**Read feeds**
|
||||
|
||||
To read feeds, just launch the Newsboat utility from the Terminal using command:
|
||||
|
||||
```
|
||||
$ newsboat
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
![][4]
|
||||
|
||||
Newsboat Rss feed reader
|
||||
|
||||
As you see in the above screenshot, I have added two RSS feeds. You can now start downloading the feeds, either by pressing **“R”** to download all feeds, or by pressing **“r”** to download the currently selected feed.
|
||||
|
||||
Now, you will see the list of recent items in each feed.
|
||||
|
||||
![][5]
|
||||
|
||||
Alternatively, you can run the following command to refresh feeds on start:
|
||||
|
||||
```
|
||||
$ newsboat -r
|
||||
```
|
||||
|
||||
Use **Up/Down** arrows to choose a feed and hit **ENTER** key to open the currently selected feed.
|
||||
|
||||
![][6]
|
||||
|
||||
Press ENTER key to open the selected entry:
|
||||
|
||||
![][7]
|
||||
|
||||
To open the entry in your default web browser, simply press **o**.
|
||||
|
||||
Here is the list of keyboard controls to manage your feeds.
|
||||
|
||||
* Press **n** to go the next unread entry.
|
||||
* Press **o** to open the selected entry in default web browser.
|
||||
* Press **r** (small letter) to reload the currently selected feed.
|
||||
* Press **R** (capital) to reload all feeds.
|
||||
* Press **A** to mark as read.
|
||||
* Press **/** to search for a specific entry.
|
||||
* Press **s** to save single entry or all entries.
|
||||
* Press **e** to enqueue.
|
||||
* Press **?** (question mark) to open the help window at any time.
|
||||
* And press **q** to go back and exit.
|
||||
|
||||
|
||||
|
||||
**Remove feeds**
|
||||
|
||||
To remove the feeds, just delete the URL in the urls file.
|
||||
|
||||
**Useful tip for Arch Linux users**
|
||||
|
||||
If you’re using a Arch based Linux distribution, I know a good way to read the Arch news page before updating your system. The reason for doing this is you can read the Arch news about current updating issues before actually updating your Arch Linux.
|
||||
|
||||
Add the Arch news link in **~/.newsboat/urls** file:
|
||||
|
||||
```
|
||||
$ https://www.archlinux.org/feeds/news/
|
||||
```
|
||||
|
||||
Open your **~/.bashrc** file and add the following line:
|
||||
|
||||
```
|
||||
alias update='newsboat -r && sudo pacman -Syu'
|
||||
```
|
||||
|
||||
Replace ‘update’ with any alias name of your choice.
|
||||
|
||||
Now, run the following command to update your Arch Linux system.
|
||||
|
||||
```
|
||||
$ update
|
||||
```
|
||||
|
||||
Whenever you run the above command, it will load the Arch news feed in your Terminal. You can simply read about current issues and then update the Arch Linux system.
|
||||
|
||||
For more details, refer the Newsboat help section using command:
|
||||
|
||||
```
|
||||
$ newsboat -h
|
||||
```
|
||||
|
||||
Also, refer the [**official documentation**][8] page for more detailed information.
|
||||
|
||||
And, that’s all. Hope this helps. I will be soon here with another useful guide. If you find this article helpful, please take a moment to share it on your social, professional networks and support OSTechNix.
|
||||
|
||||
**Resources:**
|
||||
|
||||
* [**Newsboat website**][9]
|
||||
* [**Newsboat GtiHub Repository**][10]
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/newsbeuter-command-line-rssatom-feed-reader-unix-like-systems/
|
||||
|
||||
作者:[sk][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.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/wp-content/uploads/2017/07/Newsboat-RSS-Atom-Feed-reader-720x340.png
|
||||
[2]: https://www.ostechnix.com/getting-started-pacman/
|
||||
[3]: https://www.ostechnix.com/introduction-ubuntus-snap-packages/
|
||||
[4]: https://www.ostechnix.com/wp-content/uploads/2017/07/Newsboat.png
|
||||
[5]: https://www.ostechnix.com/wp-content/uploads/2017/07/Load-new-feeds.png
|
||||
[6]: https://www.ostechnix.com/wp-content/uploads/2017/07/Newboat1.png
|
||||
[7]: https://www.ostechnix.com/wp-content/uploads/2017/07/Open-Rss-feed-entry.png
|
||||
[8]: https://newsboat.org/releases/2.16.1/docs/newsboat.html
|
||||
[9]: https://newsboat.org/
|
||||
[10]: https://github.com/newsboat/newsboat
|
@ -0,0 +1,134 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How To Delete A Repository And GPG Key In Ubuntu)
|
||||
[#]: via: (https://www.ostechnix.com/how-to-delete-a-repository-and-gpg-key-in-ubuntu/)
|
||||
[#]: author: (sk https://www.ostechnix.com/author/sk/)
|
||||
|
||||
How To Delete A Repository And GPG Key In Ubuntu
|
||||
======
|
||||
|
||||
![Delete A Repository And GPG Key In Ubuntu][1]
|
||||
|
||||
The other day we discussed how to [**list the installed repositories**][2] in RPM and DEB-based systems. Today, we are going to learn how to delete a repository along with its GPG key in Ubuntu. For those wondering, a repository (shortly **repo** ) is a central place where the developers keep the software packages. The packages in the repositories are thoroughly tested and built specifically for each version by Ubuntu developers. The users can download and install these packages on their Ubuntu system using **Apt** **package manager**. Ubuntu has four official repositories namely **Main** , **Universe** , **Restricted** and **Multiverse**.
|
||||
|
||||
Apart from the official repositories, there are many unofficial repositories maintained by developers (or package maintainers). The unofficial repositories usually have the packages which are not available in the official repositories. All packages are signed with pair of keys, a public and private key, by the package maintainer. As you already know, the public key is given out to the users and the private must be kept secret. Whenever you add a new repository in the sources list, you should also add the repository key if Apt package manager wants to trust the newly added repository. Using the repository keys, you can ensure that you’re getting the packages from the right person. Hope you got a basic idea about software repositories and repository keys. Now let us go ahead and see how to delete the repository and its key if it is no longer necessary in Ubuntu systems.
|
||||
|
||||
### Delete A Repository In Ubuntu
|
||||
|
||||
Whenever you add a repository using “add-apt-repository” command, it will be stored in **/etc/apt/sources.list** file.
|
||||
|
||||
To delete a software repository from Ubuntu and its derivatives, just open the /etc/apt/sources.list file and look for the repository entry and delete it.
|
||||
|
||||
```
|
||||
$ sudo nano /etc/apt/sources.list
|
||||
```
|
||||
|
||||
As you can see in the below screenshot, I have added [**Oracle Virtualbox**][3] repository in my Ubuntu system.
|
||||
|
||||
![][4]
|
||||
|
||||
virtualbox repository
|
||||
|
||||
To delete this repository, simply remove the entry. Save and close the file.
|
||||
|
||||
If you have added PPA repositories, look into **/etc/apt/sources.list.d/** directory and delete the respective entry.
|
||||
|
||||
Alternatively, you can delete the repository using “add-apt-repository” command. For example, I am deleting the [**Systemback**][5] repository like below.
|
||||
|
||||
```
|
||||
$ sudo add-apt-repository -r ppa:nemh/systemback
|
||||
```
|
||||
|
||||
Finally, update the software sources list using command:
|
||||
|
||||
```
|
||||
$ sudo apt update
|
||||
```
|
||||
|
||||
### Delete Repository keys
|
||||
|
||||
We use “apt-key” command to add the repository keys. First, let us list the added keys using command:
|
||||
|
||||
```
|
||||
$ sudo apt-key list
|
||||
```
|
||||
|
||||
This command will list all added repository keys.
|
||||
|
||||
```
|
||||
/etc/apt/trusted.gpg
|
||||
--------------------
|
||||
pub rsa1024 2010-10-31 [SC]
|
||||
3820 03C2 C8B7 B4AB 813E 915B 14E4 9429 73C6 2A1B
|
||||
uid [ unknown] Launchpad PPA for Kendek
|
||||
|
||||
pub rsa4096 2016-04-22 [SC]
|
||||
B9F8 D658 297A F3EF C18D 5CDF A2F6 83C5 2980 AECF
|
||||
uid [ unknown] Oracle Corporation (VirtualBox archive signing key) <[email protected]>
|
||||
sub rsa4096 2016-04-22 [E]
|
||||
|
||||
/etc/apt/trusted.gpg.d/ubuntu-keyring-2012-archive.gpg
|
||||
------------------------------------------------------
|
||||
pub rsa4096 2012-05-11 [SC]
|
||||
790B C727 7767 219C 42C8 6F93 3B4F E6AC C0B2 1F32
|
||||
uid [ unknown] Ubuntu Archive Automatic Signing Key (2012) <[email protected]>
|
||||
|
||||
/etc/apt/trusted.gpg.d/ubuntu-keyring-2012-cdimage.gpg
|
||||
------------------------------------------------------
|
||||
pub rsa4096 2012-05-11 [SC]
|
||||
8439 38DF 228D 22F7 B374 2BC0 D94A A3F0 EFE2 1092
|
||||
uid [ unknown] Ubuntu CD Image Automatic Signing Key (2012) <[email protected]>
|
||||
|
||||
/etc/apt/trusted.gpg.d/ubuntu-keyring-2018-archive.gpg
|
||||
------------------------------------------------------
|
||||
pub rsa4096 2018-09-17 [SC]
|
||||
F6EC B376 2474 EDA9 D21B 7022 8719 20D1 991B C93C
|
||||
uid [ unknown] Ubuntu Archive Automatic Signing Key (2018) <[email protected]>
|
||||
```
|
||||
|
||||
As you can see in the above output, the long (40 characters) hex value is the repository key. If you want APT package manager to stop trusting the key, simply delete it using command:
|
||||
|
||||
```
|
||||
$ sudo apt-key del "3820 03C2 C8B7 B4AB 813E 915B 14E4 9429 73C6 2A1B"
|
||||
```
|
||||
|
||||
Or, specify the last 8 characters only:
|
||||
|
||||
```
|
||||
$ sudo apt-key del 73C62A1B
|
||||
```
|
||||
|
||||
Done! The repository key has been deleted. Run the following command to update the repository lists:
|
||||
|
||||
```
|
||||
$ sudo apt update
|
||||
```
|
||||
|
||||
**Resource:**
|
||||
|
||||
* [**Software repositories – Ubuntu Community Wiki**][6]
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/how-to-delete-a-repository-and-gpg-key-in-ubuntu/
|
||||
|
||||
作者:[sk][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.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/wp-content/uploads/2019/07/Delete-a-repository-in-ubuntu-720x340.png
|
||||
[2]: https://www.ostechnix.com/find-list-installed-repositories-commandline-linux/
|
||||
[3]: https://www.ostechnix.com/install-oracle-virtualbox-ubuntu-16-04-headless-server/
|
||||
[4]: https://www.ostechnix.com/wp-content/uploads/2019/07/virtualbox-repository.png
|
||||
[5]: https://www.ostechnix.com/systemback-restore-ubuntu-desktop-and-server-to-previous-state/
|
||||
[6]: https://help.ubuntu.com/community/Repositories/Ubuntu
|
@ -0,0 +1,446 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Youtube-dl Tutorial With Examples For Beginners)
|
||||
[#]: via: (https://www.ostechnix.com/youtube-dl-tutorial-with-examples-for-beginners/)
|
||||
[#]: author: (sk https://www.ostechnix.com/author/sk/)
|
||||
|
||||
Youtube-dl Tutorial With Examples For Beginners
|
||||
======
|
||||
|
||||
![Youtube-dl Tutorial With Examples For Beginners][1]
|
||||
|
||||
There are numerous applications available to Download Youtube videos. We have covered such applications, namely [**ClipGrab**][2], and [**Mps-youtube**][3] etc., in the past. Today, we are going to learn about yet another Youtube downloader called **Youtube-dl**. Like Mps-youtube, Youtube-dl is also a command line program to download videos from Youtube and a lot of other websites listed [**here**][4]. Youtube-dl can be able to download a single track or entire playlist in one go. It is a free and open source command line program written in **Python**. It supports GNU/Linux, Mac OS X and Microsoft Windows.
|
||||
|
||||
### Installing Youtube-dl
|
||||
|
||||
The easiest and officially recommended way to install Youtube-dl is just download it, save it in your PATH, make it executable and start using it right away.
|
||||
|
||||
```
|
||||
$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
|
||||
```
|
||||
|
||||
If you don’t have curl, use **wget** instead:
|
||||
|
||||
```
|
||||
$ sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
|
||||
|
||||
$ sudo chmod a+rx /usr/local/bin/youtube-dl
|
||||
```
|
||||
|
||||
Alternatively, you can install it using [**Pip**][5] as shown below.
|
||||
|
||||
```
|
||||
$ sudo -H pip install --upgrade youtube-dl
|
||||
```
|
||||
|
||||
Youtube-dl is also available in the official repositories of some Linux distributions. For example, you can install it in Arch Linux using command:
|
||||
|
||||
```
|
||||
$ sudo pacman -S youtube-dl
|
||||
```
|
||||
|
||||
On Debian, Ubuntu, Linux mint:
|
||||
|
||||
```
|
||||
$ sudo apt install youtube-dl
|
||||
```
|
||||
|
||||
On Fedora:
|
||||
|
||||
```
|
||||
$ sudo dnf install youtube-dl
|
||||
```
|
||||
|
||||
FFmpeg is also required to download 720p videos from YouTube and convert videos to other formats. To install FFmpeg, refer the following guide.
|
||||
|
||||
* [**How to install FFmpeg on Linux**][6]
|
||||
|
||||
|
||||
|
||||
### Update Youtube-dl
|
||||
|
||||
If you’ve manually installed Youtube-dl using curl or wget, run the following command to update it:
|
||||
|
||||
```
|
||||
$ sudo youtube-dl -U
|
||||
```
|
||||
|
||||
If you installed it using pip, do:
|
||||
|
||||
```
|
||||
$ sudo pip install -U youtube-dl
|
||||
```
|
||||
|
||||
Those who installed Youtube-dl using the distribution’s package manager, just use the appropriate update command. For example, on Arch Linux, you can update Youtube-dl by simply running the following command:
|
||||
|
||||
```
|
||||
$ sudo pacman -Syu
|
||||
```
|
||||
|
||||
On Debian, Ubuntu:
|
||||
|
||||
```
|
||||
$ sudo apt update
|
||||
```
|
||||
|
||||
Now, let us see some examples to learn to use Youtube-dl.
|
||||
|
||||
### Youtube-dl Tutorial With Examples
|
||||
|
||||
Here, I have compiled most commonly used Youtube-dl commands to download a video or playlist from youtube.
|
||||
|
||||
####### **1\. Download video or playlist**
|
||||
|
||||
To download a video or the entire playlist from Youtube, just mention the URL like below:
|
||||
|
||||
```
|
||||
$ youtube-dl https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
If you want to download video or playlist with a custom name of your choice, the command would be:
|
||||
|
||||
```
|
||||
$ youtube-dl -o 'abdul kalam inspirational speech' https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Replace “abdul kalam inspirational speech” with your own name.
|
||||
|
||||
You can also include additional details, such as the title, the uploader name (channel name) and upload date etc., in the file name by using the following command:
|
||||
|
||||
```
|
||||
$ youtube-dl -o '%(title)s by %(uploader)s on %(upload_date)s in %(playlist)s.%(ext)s' https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
####### **2\. Download multiple videos**
|
||||
|
||||
Sometimes, you might want to download multiple videos from or any other site. If so, just mention the URL of the videos with space-separated like below:
|
||||
|
||||
```
|
||||
$ youtube-dl <url1> <url2>
|
||||
```
|
||||
|
||||
Alternatively, you can put them all in a text file and pass it to Youtube-dl as an argument like below.
|
||||
|
||||
```
|
||||
$ youtube-dl -a url.txt
|
||||
```
|
||||
|
||||
This command will download all videos mentioned in the url.txt file.
|
||||
|
||||
####### **3\. Download audio-only from a video**
|
||||
|
||||
Youtube-dl allows us to download audio only from a Youtube video. If you ever been in a situation to download only the audio, run:
|
||||
|
||||
```
|
||||
$ youtube-dl -x https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
By default, Youtube-dl will save the audio in **Ogg** (opus) format.
|
||||
|
||||
If you prefer to download any other formats, for example **mp3** , run:
|
||||
|
||||
```
|
||||
$ youtube-dl -x --audio-format mp3 https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
This command will download the audio from the given video/playlist, convert it to an MP3 and save it in the current directory. Please note that you should install either [**ffmpeg**][7] or **avconv** to convert the file to mp3 format.
|
||||
|
||||
####### **4\. Download video with description, metadata, annotations, subtitles and thumbnail**
|
||||
|
||||
To download a video along with its other details such as description, metadata, annotations, subtitles, and thumbnail etc., use the following command:
|
||||
|
||||
```
|
||||
$ youtube-dl --write-description --write-info-json --write-annotations --write-sub --write-thumbnail https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
####### **5\. List all available formats of video or playlist**
|
||||
|
||||
To list all available formats that a video or playlist is available in, use the following command:
|
||||
|
||||
```
|
||||
$ youtube-dl --list-formats https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Or
|
||||
|
||||
```
|
||||
$ youtube-dl -F https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Sample output:
|
||||
|
||||
![][8]
|
||||
|
||||
List all available formats of a youtube video using youtube-dl
|
||||
|
||||
As you can see in the above screenshot, Youtube-dl lists all available formats of the given video. From left to right, it displays the video format code, extension and resolution note of the respective video. This can be helpful when you want to download a video at a specific quality or format.
|
||||
|
||||
####### **6\. Download videos in certain quality and/or format**
|
||||
|
||||
By default, Youtube-dl will download the best available quality video. However, it is also possible to download a video or playlist at a specific quality or format.
|
||||
|
||||
Youtube is capable of downloading videos in the following qualities:
|
||||
|
||||
* **best** – Select the best quality format of the given file with video and audio.
|
||||
* **worst** – Select the worst quality format (both video and audio).
|
||||
* **bestvideo** – Select the best quality video-only format (e.g. DASH video). Please note that it may not be available.
|
||||
* **worstvideo** – Select the worst quality video-only format. May not be available.
|
||||
* **bestaudio** – Select the best quality audio only-format. May not be available.
|
||||
* **worstaudio** – Select the worst quality audio only-format. May not be available.
|
||||
|
||||
|
||||
|
||||
For example, if you want to download **best quality** format (both audio and video), just use the following command:
|
||||
|
||||
```
|
||||
$ youtube-dl -f best https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Similarly, to download audio-only with best quality:
|
||||
|
||||
```
|
||||
$ youtube-dl -f bestaudio https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
To download worst quality video-only format, use the following command:
|
||||
|
||||
```
|
||||
$ youtube-dl -f worstvideo https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
You also combine different format options like below.
|
||||
|
||||
```
|
||||
$ youtube-dl -f bestvideo+bestaudio https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
The above command will download best quality video-only and best quality audio-only formats and merge them together with ffmpeg or avconv. Make sure you have installed any one of these tools on your system.
|
||||
|
||||
If you don’t want to merge, replace **+** (plus) operator with **,** (comma) like below:
|
||||
|
||||
```
|
||||
$ youtube-dl -f 'bestvideo,bestaudio' https://www.youtube.com/watch?v=7E-cwdnsiow -o '%(title)s.f%(format_id)s.%(ext)s'
|
||||
```
|
||||
|
||||
This command will download best quality video and best quality audio and **will not mix them**. In this case, you will get two files, one is audio and another is video. In this example, an output template ( **-o** option) is recommended as bestvideo and bestaudio may have the same file name.
|
||||
|
||||
We can even download a video or playlist at a specific quality with **specific resolution**.
|
||||
|
||||
For instance, the following command will download the **best quality** video in **480 pixel resolution** (less than or equal to 480p).
|
||||
|
||||
```
|
||||
$ youtube-dl -f "best[height<=480]" https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Like already said, we can group the format selectors to get a specific quality video. The following command will download best format available(both audio and video) but **no better than 480p**.
|
||||
|
||||
```
|
||||
$ youtube-dl -f 'bestvideo[height<=480]+bestaudio/best[height<=480]' https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
####### **7. Download videos using format code
|
||||
|
||||
**
|
||||
|
||||
All videos have format codes which we can use to download a video at specific quality. To find the format code, just list the available formats using any one of the following commands:
|
||||
|
||||
```
|
||||
$ youtube-dl --list-formats https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Or
|
||||
|
||||
```
|
||||
$ youtube-dl -F https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
![][9]
|
||||
|
||||
As you can see in the above screenshot, all format codes of the given video are listed in the first column. The best quality format is given at the end (the format code is **22** ). So, the command to download best quality format is:
|
||||
|
||||
```
|
||||
$ youtube-dl -f 22 https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Some videos may not have the same formats available while you download videos from playlist. In such cases, you can specify multiple format codes in any preferred order of your choice. Take a look at the following example:
|
||||
|
||||
```
|
||||
$ youtube-dl -f 22/17/18 <playlist_url>
|
||||
```
|
||||
|
||||
As per the above example, Youtube-dl will download the videos in format 22 if it is available. If the format 22 is not available, it will then download format 17 if it is available. If both 22 and 17 formats are not available, it will finally try to download format 18. If none of the specified formats are available, Youtube-dl will complain that no suitable formats are available for download.
|
||||
|
||||
Please note that that slash is left-associative, i.e. formats on the left hand side are preferred.
|
||||
|
||||
####### **8. Download videos by file extension
|
||||
|
||||
**
|
||||
|
||||
Download video(s) in your preferred format, say for example MP4, just run:
|
||||
|
||||
```
|
||||
$ youtube-dl --format mp4 https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Or,
|
||||
|
||||
```
|
||||
$ youtube-dl -f mp4 https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
Like I already mentioned in the previous section, some videos may not available in your preferred formats. In such cases, Youtube-dl will download any other best available formats. For instance, this command will download best quality MP4 format file. If MP4 format is not available, then it will download any other best available format.
|
||||
|
||||
```
|
||||
$ youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
If you want to download them with custom filename, do:
|
||||
|
||||
```
|
||||
$ youtube-dl -f mp4 -o '%(title)s.f%(format_id)s.%(ext)s' https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
####### **9. Set size limit for videos
|
||||
|
||||
**
|
||||
|
||||
When you download multiple videos from a playlist, you might want to download videos within a certain size only.
|
||||
|
||||
For example, this command will not download any videos smaller than the given size, say **100MB** :
|
||||
|
||||
```
|
||||
$ youtube-dl --min-filesize 100M <playlist_url>
|
||||
```
|
||||
|
||||
If you don’t want to download videos larger than the given size, do:
|
||||
|
||||
```
|
||||
$ youtube-dl --max-filesize 100M <playlist_url>
|
||||
```
|
||||
|
||||
We can also combine format selection operators to download certain size videos.
|
||||
|
||||
The following command will download best video-only format but **not bigger than 100 MB**.
|
||||
|
||||
```
|
||||
$ youtube-dl -f 'best[filesize<100M]' https://www.youtube.com/watch?v=7E-cwdnsiow
|
||||
```
|
||||
|
||||
####### **10. Download videos by date-wise
|
||||
|
||||
**
|
||||
|
||||
Youtube-dl allows us to filter and download video or playlist by their upload date. This will be very helpful when you want to download videos from a playlist that contains 100s of videos.
|
||||
|
||||
For instance, to download videos uploaded at an exact date, for example October 01, 2018, the command would be:
|
||||
|
||||
```
|
||||
$ youtube-dl --date 20181001 <URL>
|
||||
```
|
||||
|
||||
Download videos uploaded on or before a specific date:
|
||||
|
||||
```
|
||||
$ youtube-dl --datebefore 20180101 <URL>
|
||||
```
|
||||
|
||||
Download videos uploaded on or after a specific date:
|
||||
|
||||
```
|
||||
$ youtube-dl --dateafter 20180101 <URL>
|
||||
```
|
||||
|
||||
Download only the videos uploaded in the last 6 months:
|
||||
|
||||
```
|
||||
$ youtube-dl --dateafter now-6months <URL>
|
||||
```
|
||||
|
||||
To download videos between a specific date, for example January 01, 2018 to January 01, 2019, use the following command:
|
||||
|
||||
```
|
||||
$ youtube-dl --dateafter 20180101 --datebefore 20190101 <URL>
|
||||
```
|
||||
|
||||
####### **11. Download specific videos from playlist
|
||||
|
||||
**
|
||||
|
||||
This is yet another useful feature of Youtube-dl. It allows us to download a specific song(s) from a playlist that contains 100s of songs.
|
||||
|
||||
For example, to download the 10th file from a playlist, run:
|
||||
|
||||
```
|
||||
$ youtube-dl --playlist-items 10 <playlist_url>
|
||||
```
|
||||
|
||||
Similarly, to download multiple random files, just specify indices of the videos in the playlist separated by commas like below::
|
||||
|
||||
```
|
||||
$ youtube-dl --playlist-items 2,3,7,10 <playlist_url>
|
||||
```
|
||||
|
||||
You can also specify the range of songs. To download a video playlist starting from a certain video, say 10, to end:
|
||||
|
||||
```
|
||||
$ youtube-dl --playlist-start 10 <playlist_url>
|
||||
```
|
||||
|
||||
To download only the files starting from 2nd to 5th in a playlist, use:
|
||||
|
||||
```
|
||||
$ youtube-dl --playlist-start 2 --playlist-end 5 <playlist_url>
|
||||
```
|
||||
|
||||
####### 12\. Download only videos suitable for specific age
|
||||
|
||||
This is another notable feature of Youtube-dl. It allows us to download only videos suitable for the given age.
|
||||
|
||||
Say for example, to download all “Let’s Play” videos that aren’t marked “NSFW” or age-restricted for 7 year-olds from a playlist, run:
|
||||
|
||||
```
|
||||
$ youtube-dl --match-title "let's play" --age-limit 7 --reject-title "nsfw" <playlist_url>
|
||||
```
|
||||
|
||||
Youtube-dl has a lot more options. I guess these 12 examples are just enough to use Youtube-dl to download videos from online. For more details, refer Youtube-dl help section.
|
||||
|
||||
```
|
||||
$ youtube-dl --help
|
||||
```
|
||||
|
||||
**Resources:**
|
||||
|
||||
* [**Youtube-dl website**][10]
|
||||
* [**Youtube-dl GitHub Repository**][11]
|
||||
* [**https://jonlabelle.com/snippets/view/shell/youtube-dl-command**][12]
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/youtube-dl-tutorial-with-examples-for-beginners/
|
||||
|
||||
作者:[sk][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.ostechnix.com/author/sk/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.ostechnix.com/wp-content/uploads/2019/06/youtube-dl-720x340.png
|
||||
[2]: https://www.ostechnix.com/clipgrab-youtube-downloader-converter/
|
||||
[3]: https://www.ostechnix.com/mps-youtube-commandline-youtube-player-downloader/
|
||||
[4]: https://ytdl-org.github.io/youtube-dl/supportedsites.html
|
||||
[5]: https://www.ostechnix.com/manage-python-packages-using-pip/
|
||||
[6]: https://www.ostechnix.com/install-ffmpeg-linux/
|
||||
[7]: https://www.ostechnix.com/20-ffmpeg-commands-beginners/
|
||||
[8]: https://www.ostechnix.com/wp-content/uploads/2019/06/List-all-available-formats-youtube-dl.png
|
||||
[9]: https://www.ostechnix.com/wp-content/uploads/2019/06/List-all-available-formats-youtube-dl-1.png
|
||||
[10]: https://ytdl-org.github.io/youtube-dl/index.html
|
||||
[11]: https://github.com/ytdl-org/youtube-dl
|
||||
[12]: https://jonlabelle.com/snippets/view/shell/youtube-dl-command
|
@ -7,24 +7,24 @@
|
||||
[#]: via: (https://www.networkworld.com/article/3391362/looking-into-linux-modules.html#tk.rss_all)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
Looking into Linux modules
|
||||
深入学习 Linux 内核模块
|
||||
======
|
||||
The lsmod command can tell you which kernel modules are currently loaded on your system, along with some interesting details about their use.
|
||||
lsmod 命令能够告诉你当前系统上加载了哪些内核模块,以及关于使用它们的一些有趣的细节。
|
||||
![Rob Oo \(CC BY 2.0\)][1]
|
||||
|
||||
### What are Linux modules?
|
||||
### 什么是 Linux 内核模块?
|
||||
|
||||
Kernel modules are chunks of code that are loaded and unloaded into the kernel as needed, thus extending the functionality of the kernel without requiring a reboot. In fact, unless users inquire about modules using commands like **lsmod** , they won't likely know that anything has changed.
|
||||
内核模块是根据需要加载到内核中或从内核中卸载的代码块,因此无需重启就可以扩展内核的功能。事实上,除非用户使用类似 **lsmod** 这样的命令来查询模块信息,否则用户不太可能知道内核发生的任何变化。
|
||||
|
||||
One important thing to understand is that there are _lots_ of modules that will be in use on your Linux system at all times and that a lot of details are available if you're tempted to dive into the details.
|
||||
需要知道的重要一点是,在你的 Linux 系统上总会有*很多*可用的模块,并且如果你想深入了解细节,那么可以获得很多细节。
|
||||
|
||||
One of the prime ways that lsmod is used is to examine modules when a system isn't working properly. However, most of the time, modules load as needed and users don't need to be aware of how they are working.
|
||||
lsmod 的主要用途之一是在系统不能正常工作时检查模块。然而,大多数情况下,模块会根据需要加载的,而且用户不需要知道它们如何运作。
|
||||
|
||||
**[ Also see:[Must-know Linux Commands][2] ]**
|
||||
**[ 扩展阅读:[必知的 Linux 命令][2] ]**
|
||||
|
||||
### Listing modules
|
||||
### 显示内核模块
|
||||
|
||||
The easiest way to list modules is with the **lsmod** command. While this command provides a lot of detail, this is the most user-friendly output.
|
||||
显示内核模块最简单的方法是使用 **lsmod** 命令。虽然这个命令包含了很多细节,但输出却是非常用户友好。
|
||||
|
||||
```
|
||||
$ lsmod
|
||||
@ -103,44 +103,44 @@ e1000e 245760 0
|
||||
floppy 81920 0
|
||||
```
|
||||
|
||||
In the output above:
|
||||
在上面的输出中:
|
||||
|
||||
* "Module" shows the name of each module
|
||||
* "Size" shows the module size (not how much memory it is using)
|
||||
* "Used by" shows each module's usage count and the referring modules
|
||||
* “Module”显示每个模块的名称
|
||||
* “Size”显示每个模块的大小(并不是它们使占的内存大小)
|
||||
* “Used by”显示每个模块的被使用的计数和使用它们的模块
|
||||
|
||||
|
||||
|
||||
Clearly, that's a _lot_ of modules. The number of modules loaded will depend on your system and distribution and what's running. We can count them like this:
|
||||
显然,这里有*很多*模块。加载的模块数量取决于你的系统和版本以及正在运行的内容。我们可以这样计数:
|
||||
|
||||
```
|
||||
$ lsmod | wc -l
|
||||
67
|
||||
```
|
||||
|
||||
To see the number of modules available on the system (not just running), try this command:
|
||||
要查看系统中可用的模块数(不止运行当中的),试试这个命令:
|
||||
|
||||
```
|
||||
$ modprobe -c | wc -l
|
||||
41272
|
||||
```
|
||||
|
||||
### Other commands for examining modules
|
||||
### 与内核模块相关的其他命令
|
||||
|
||||
Linux provides several commands for listing, loading and unloading, examining, and checking the status of modules.
|
||||
Linux 提供了几条用于罗列,加载及卸载,测试,以及检查模块状态的命令。
|
||||
|
||||
* depmod -- generates modules.dep and map files
|
||||
* insmod -- a simple program to insert a module into the Linux Kernel
|
||||
* lsmod -- show the status of modules in the Linux Kernel
|
||||
* modinfo -- show information about a Linux Kernel module
|
||||
* modprobe -- add and remove modules from the Linux Kernel
|
||||
* rmmod -- a simple program to remove a module from the Linux Kernel
|
||||
* depmod —— 生成 modules.dep 和映射文件
|
||||
* insmod —— 一个往 Linux 内核插入模块的程序
|
||||
* lsmod —— 显示 Linux 内核中模块状态
|
||||
* modinfo —— 显示 Linux 内核模块信息
|
||||
* modprobe —— 添加或移除 Linux 内核模块
|
||||
* rmmod —— 一个从 Linux 内核移除模块的程序
|
||||
|
||||
|
||||
|
||||
### Listing modules that are built in
|
||||
### 显示内置的内核模块
|
||||
|
||||
As mentioned above, the **lsmod** command is the most convenient command for listing modules. There are, however, other ways to examine them. The modules.builtin file lists all modules that are built into the kernel and is used by modprobe when trying to load one of these modules. Note that **$(uname -r)** in the commands below provides the name of the kernel release.
|
||||
正如前文所说,**lsmod** 命令是显示内核模块最方便的命令。然而,也有其他方式可以显示它们。modules.builtin 文件中列出了所有构建在内核中的模块,并被 modprobe 命令尝试添加文件中的模块时使用。注意,以下命令中的 **$(uname -r)** 提供了内核版本的名称。
|
||||
|
||||
```
|
||||
$ more /lib/modules/$(uname -r)/modules.builtin | head -10
|
||||
@ -156,7 +156,7 @@ kernel/fs/configfs/configfs.ko
|
||||
kernel/fs/crypto/fscrypto.ko
|
||||
```
|
||||
|
||||
You can get some additional detail on a module by using the **modinfo** command, though nothing that qualifies as an easy explanation of what service the module provides. The omitted details from the output below include a lengthy signature.
|
||||
你可以使用 **modinfo** 获得一个模块的更多细节,虽然没有对模块提供的服务的简单说明。下面输出内容中省略了冗长的签名。
|
||||
|
||||
```
|
||||
$ modinfo floppy | head -16
|
||||
@ -178,26 +178,26 @@ sig_key:
|
||||
sig_hashalgo: md4
|
||||
```
|
||||
|
||||
You can load or unload a module using the **modprobe** command. Using a command like the one below, you can locate the kernel object associated with a particular module:
|
||||
你可以使用 **modprobe** 命令加载或卸载模块。使用下面这条命令,你可以找到特定模块关联的内核对象:
|
||||
|
||||
```
|
||||
$ find /lib/modules/$(uname -r) -name floppy*
|
||||
/lib/modules/5.0.0-13-generic/kernel/drivers/block/floppy.ko
|
||||
```
|
||||
|
||||
If you needed to load the module, you could use a command like this one:
|
||||
如果你想要加载模块,你可以使用这个命令:
|
||||
|
||||
```
|
||||
$ sudo modprobe floppy
|
||||
```
|
||||
|
||||
### Wrap-up
|
||||
### 总结一下
|
||||
|
||||
Clearly the loading and unloading of modules is a big deal. It makes Linux systems considerably more flexible and efficient than if they ran with a one-size-fits-all kernel. It also means you can make significant changes — including adding hardware — without rebooting.
|
||||
很明显,内核模块的加载和卸载非常重要。它使得 Linux 系统比使用通用内核运行时更加灵活和高效。这同样意味着你可以进行重大更改而无需重启,例如添加硬件。
|
||||
|
||||
**[ Two-Minute Linux Tips:[Learn how to master a host of Linux commands in these 2-minute video tutorials][3] ]**
|
||||
**[ 两分钟学 Linux:[在这些两分钟视频教程中掌握大量 Linux 命令][3] ]**
|
||||
|
||||
Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind.
|
||||
在 [Facebook][4] 和 [LinkedIn][5] 上关注我们并添加评论。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -205,7 +205,7 @@ via: https://www.networkworld.com/article/3391362/looking-into-linux-modules.htm
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[LazyWolfLin](https://github.com/LazyWolfLin)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
@ -7,35 +7,34 @@
|
||||
[#]: via: (https://opensource.com/article/19/6/virtual-environments-python-macos)
|
||||
[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg/users/moshez/users/mbbroberg/users/moshez)
|
||||
|
||||
How to set up virtual environments for Python on MacOS
|
||||
MacOS 系统中如何设置 Python 虚拟环境
|
||||
======
|
||||
Save yourself a lot of confusion by managing your virtual environments
|
||||
with pyenv and virtualwrapper.
|
||||
使用 pyenv 和 virtualwrapper 来管理你的虚拟环境,可以避免很多困惑。
|
||||
![][1]
|
||||
|
||||
If you're a Python developer and a MacOS user, one of your first tasks upon getting a new computer is to set up your Python development environment. Here is the best way to do it (although we have written about [other ways to manage Python environments on MacOS][2]).
|
||||
作为 Python 开发者和 MacOS 用户,拿到新机器首先要做的就是设置 Python 开发环境。下面是最佳实践(虽然我们已经写过 [在 MacOS 上管理 Python 的其它方法][2])。
|
||||
|
||||
### Preparation
|
||||
### 预备
|
||||
|
||||
First, open a terminal and enter **xcode-select --install** at its cold, uncaring prompt. Click to confirm, and you'll be all set with a basic development environment. This step is required on MacOS to set up local development utilities, including "many commonly used tools, utilities, and compilers, including make, GCC, clang, perl, svn, git, size, strip, strings, libtool, cpp, what, and many other useful commands that are usually found in default Linux installations," according to [OS X Daily][3].
|
||||
首先,打开终端,在其冰冷毫无提示的窗口输入 **xcode-select --install** 命令。点击确认后,基本的开发环境就会被配置上。MacOS 上需要此步骤来设置本地开发实用工具库,根据 [OS X Daily][3] 的说法,其包括 ”许多常用的工具、实用程序和编译器,如 make、GCC、clang、perl、svn、git、size、strip、strings、libtool、cpp、what 及许多在 Linux 中系统默认安装的有用命令“。
|
||||
|
||||
Next, install [Homebrew][4] by executing the following Ruby script from the internet:
|
||||
接下来,安装 [Homebrew][4], 执行如下的 Ruby 脚本。
|
||||
|
||||
|
||||
```
|
||||
`ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"`
|
||||
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
```
|
||||
|
||||
If you, like me, have trust issues with arbitrarily running scripts from the internet, click on the script above and take a longer look to see what it does.
|
||||
如果你像我一样,对随意就运行的来源于 internet 的脚本心存顾虑的话,可以点击上面的脚本去仔细看看其具体功能。
|
||||
|
||||
Once this is done, congratulations, you have an excellent package management tool in Homebrew. Naively, you might think that you next **brew install python** or something. No, haha. Homebrew will give you a version of Python, but the version you get will be out of your control if you let the tool manage your environment for you. You want [pyenv][5], "a tool for simple Python version management," that can be installed on [many operating systems][6]. Run:
|
||||
一旦安装完成后,就恭喜了,你拥有了一个优秀的包管理工具。自然的,你可能接下来会执行 **brew install python** 或其他的命令。不要这样,哈哈!Homebrew 是为我们提供了一个 Python 的管理版本,但让此工具来管理我们的 Python 环境话,很快会失控的。我们需要 [pyenv][5],一款简单的 Python 版本管理工具,它可以安装运行在 [许多操作系统][6] 上。运行如下命令:
|
||||
|
||||
|
||||
```
|
||||
`$ brew install pyenv`
|
||||
$ brew install pyenv
|
||||
```
|
||||
|
||||
You want pyenv to run every time you open your prompt, so include the following in your configuration files (by default on MacOS, this is **.bash_profile** in your home directory):
|
||||
想要每次打开命令提示框时 pyenv 都会运行的话,需要把下面的内容加入你的配置文件中(MacOS 中默认为 **.bash_profile**,位于家目录下):
|
||||
|
||||
|
||||
```
|
||||
@ -43,16 +42,16 @@ $ cd ~/
|
||||
$ echo 'eval "$(pyenv init -)"' >> .bash_profile
|
||||
```
|
||||
|
||||
By adding this line, every new terminal will initiate pyenv to manage the **PATH** environment variable in your terminal and insert the version of Python you want to run (as opposed to the first one that shows up in the environment. For more information, read "[How to set your $PATH variable in Linux][7].") Open a new terminal for the updated **.bash_profile** to take effect.
|
||||
添加此行内容后,每个终端都会启动 pyenv 来管理其 **PATH** 环境变量,并插入你想要运行的 Python 版本(而不是在环境变量里面设置的初始版本。更详细的信息,请阅读 “[如何给 Linux 系统设置 PATH 变量][7]”)。打开新的终端以使修改的 **.bash_profile** 文件生效。
|
||||
|
||||
Before installing your favorite version of Python, you'll want to install a couple of helpful tools:
|
||||
在安装你中意的 Python 版本前,需要先安装一些有用的工具,如下示:
|
||||
|
||||
|
||||
```
|
||||
`$ brew install zlib sqlite`
|
||||
$ brew install zlib sqlite
|
||||
```
|
||||
|
||||
The [zlib][8] compression algorithm and the [SQLite][9] database are dependencies for pyenv and often [cause build problems][10] when not configured correctly. Add these exports to your current terminal window to ensure the installation completes:
|
||||
Pyenv 依赖于 [zlib][8] 压缩算法和 [SQLite][9] 数据库,如果未正确配置,往往会[导致构建问题][10]。将这些导出配置命令加入当前的终端窗口执行,确保它们安装完成。
|
||||
|
||||
|
||||
```
|
||||
@ -60,18 +59,18 @@ $ export LDFLAGS="-L/usr/local/opt/zlib/lib -L/usr/local/opt/sqlite/lib"
|
||||
$ export CPPFLAGS="-I/usr/local/opt/zlib/include -I/usr/local/opt/sqlite/include"
|
||||
```
|
||||
|
||||
Now that the preliminaries are done, it's time to install a version of Python that is fit for a modern person in the modern age:
|
||||
现在准备工作已经完成,是时候安装一个适合于现代人的 Python 版本了:
|
||||
|
||||
|
||||
```
|
||||
`$ pyenv install 3.7.3`
|
||||
$ pyenv install 3.7.3
|
||||
```
|
||||
|
||||
Go have a cup of coffee. From beans you hand-roast. After you pick them. What I'm saying here is it's going to take some time.
|
||||
去喝杯咖啡吧,挑些豆类,亲自烧烤,然后品尝。说这些的意思是上面的安装过程需要一段时间。
|
||||
|
||||
### Adding virtual environments
|
||||
### 添加虚拟环境
|
||||
|
||||
Once it's finished, it's time to make your virtual environments pleasant to use. Without this next step, you will effectively be sharing one Python development environment for every project you work on. Using virtual environments to isolate dependency management on a per-project basis will give us more certainty and reproducibility than Python offers out of the box. For these reasons, install **virtualenvwrapper** into the Python environment:
|
||||
一旦完成,就可以愉快地使用虚拟环境了。如没有接下来的步骤的话,你只能在你所有的工作项目中共享同一个 Python 开发环境。使用虚拟环境来隔离每个项目的依赖关系的管理方式,比起 Python 自身提供的开箱即用功能来说,更加清晰明确和更具有重用性。基于这些原因,把 **virtualenvwrapper** 安装到 Python 环境中吧:
|
||||
|
||||
|
||||
```
|
||||
@ -80,7 +79,7 @@ $ pyenv global 3.7.3
|
||||
$ $(pyenv which python3) -m pip install virtualenvwrapper
|
||||
```
|
||||
|
||||
Open your **.bash_profile** again and add the following to be sure it works each time you open a new terminal:
|
||||
再次打开 **.bash_profile** 文件,把下面内容添加进去,使得每次打开新终端时它都有效:
|
||||
|
||||
|
||||
```
|
||||
@ -94,7 +93,7 @@ $ echo 'mkdir -p $WORKON_HOME' >> .bash_profile
|
||||
$ echo '. ~/.pyenv/versions/3.7.3/bin/virtualenvwrapper.sh' >> .bash_profile
|
||||
```
|
||||
|
||||
Close the terminal and open a new one (or run **exec /bin/bash -l** to refresh the current terminal session), and you'll see **virtualenvwrapper** initializing the environment:
|
||||
关掉终端再重新打开(或者运行 **exec /bin/bash -l** 来刷新当前的终端会话),你会看到 **virtualenvwrapper** 正在初始化环境配置:
|
||||
|
||||
|
||||
```
|
||||
@ -113,7 +112,7 @@ virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/postactivate
|
||||
virtualenvwrapper.user_scripts creating /Users/moshe/.virtualenvs/get_env_details
|
||||
```
|
||||
|
||||
From now on, all your work should be in a virtual environment, allowing you to use temporary environments to play around with development safely. With this toolchain, you can set up multiple projects and switch between them, depending upon what you're working on at that moment:
|
||||
从此刻开始,你的所有工作都是在虚拟环境中的,其允许你使用临时环境来安全地开发。使用此工具链,你可以根据工作所需,设置多个项目并在它们之间切换:
|
||||
|
||||
|
||||
```
|
||||
@ -149,11 +148,11 @@ postmkproject premkproject
|
||||
(test1)$
|
||||
```
|
||||
|
||||
The **deactivate** command exits you from the current environment.
|
||||
此处, **deactivate** 命令可以退出当前环境。
|
||||
|
||||
### Recommended practices
|
||||
### 推荐实践
|
||||
|
||||
You may already set up your long-term projects in a directory like **~/src**. When you start working on a new project, go into this directory, add a subdirectory for the project, then use the power of Bash interpretation to name the virtual environment based on your directory name. For example, for a project named "pyfun":
|
||||
你可能已经在比如 **~/src** 这样的目录中添加了长期的项目。当要开始了一个新项目时,进入此目录,为此项目增加子文件夹,然后使用强大的 Bash 解释程序自动根据你的目录名来命令虚拟环境。例如,名称为 “pyfun” 的项目:
|
||||
|
||||
|
||||
```
|
||||
@ -168,7 +167,7 @@ test2
|
||||
$
|
||||
```
|
||||
|
||||
Whenever you want to work on this project, go back to that directory and reconnect to the virtual environment by entering:
|
||||
当需要处理此项目时,只要进入该目录,输入如下命令重新连接虚拟环境:
|
||||
|
||||
|
||||
```
|
||||
@ -176,7 +175,7 @@ $ cd ~/src/pyfun
|
||||
(pyfun)$ workon .
|
||||
```
|
||||
|
||||
Since initializing a virtual environment means taking a point-in-time copy of your Python version and the modules that are loaded, you will occasionally want to refresh the project's virtual environment, as dependencies can change dramatically. You can do this safely by deleting the virtual environment because the source code will remain unscathed:
|
||||
初始化虚拟环境意味着对 Python 版本和所加载的模块的时间点的拷贝。由于依赖关系会发生很大的改变,所以偶尔需要刷新项目的虚拟环境。这种情况,你可以通过删除虚拟环境来安全的执行此操作,源代码是不受影响的,如下所示:
|
||||
|
||||
|
||||
```
|
||||
@ -185,9 +184,9 @@ $ rmvirtualenv $(basename $(pwd))
|
||||
$ mkvirtualenv $(basename $(pwd))
|
||||
```
|
||||
|
||||
This method of managing virtual environments with pyenv and virtualwrapper will save you from uncertainty about which version of Python you are running as you develop code locally. This is the simplest way to avoid confusion—especially when you're working with a larger team.
|
||||
这种使用 pyenv 和 virtualwrapper 管理虚拟环境的方法可以避免开发环境和运行环境中 Python 版本的不一致出现的苦恼。这是避免混淆的最简单方法 - 尤其是你工作的团队很大的时候。
|
||||
|
||||
If you are just beginning to configure your Python environment, read up on how to use [Python 3 on MacOS][2]. Do you have other beginner or intermediate Python questions? Leave a comment and we will consider them for the next article.
|
||||
如果你是初学者,正准备配置 Python 环境,可以阅读下 [MacOS 中使用 Python 3][2] 文章。 你们有关于 Python 相关的问题吗,不管是初学者的还是中级使用者的?给我们留下评论信息,我们在下篇文章中会考虑讲解。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
@ -7,25 +7,25 @@
|
||||
[#]: via: (https://www.linuxtechi.com/set-ulimit-file-descriptors-limit-linux-servers/)
|
||||
[#]: author: (Shashidhar Soppin https://www.linuxtechi.com/author/shashidhar/)
|
||||
|
||||
How to set ulimit and file descriptors limit on Linux Servers
|
||||
如何在 Linux 服务器上设置 ulimit 和文件描述符数限制
|
||||
======
|
||||
|
||||
**Introduction: ** Challenges like number of open files in any of the production environment has become common now a day. Since many applications which are Java based and Apache based, are getting installed and configured, which may lead to too many open files, file descriptors etc. If this exceeds the default limit that is set, then one may face access control problems and file opening challenges. Many production environments come to standstill kind of situations because of this.
|
||||
**简介**:如今每天(遇到的)像是打开文件数这类的挑战在任何生产环境已经变得司空见惯了。因为许多基于 Java 和 Apache 的应用程序的正在安装和配置,可能会导致打开过多的文件、文件描述符等。如果(文件描述符等)超过默认设置限制,就可能会面临访问控制问题和打开文件的挑战。许多生产环境因此而陷入停滞状态。
|
||||
|
||||
<https://www.linuxtechi.com/wp-content/uploads/2019/06/ulimit-number-openfiles-linux-server.jpg>
|
||||
|
||||
Luckily, we have “ **ulimit** ” command in any of the Linux based server, by which one can see/set/get number of files open status/configuration details. This command is equipped with many options and with this combination one can set number of open files. Following are step-by-step commands with examples explained in detail.
|
||||
幸运的是,在任何基于 Linux 的服务器上,都有 “**ulimit**”命令,通过它可以查看/设置/获取文件打开的状态/配置详情的数量。此命令配备了许多选项,通过此组合可以设置打开文件的数量。下面是分步命令,并用示例详细说明。
|
||||
|
||||
### To see what is the present open file limit in any Linux System
|
||||
|
||||
To get open file limit on any Linux server, execute the following command,
|
||||
### 查看任何 Linux 系统中当前打开文件数的限制
|
||||
|
||||
要在任何 Linux 服务器上获得打开文件数限制,请执行以下命令,
|
||||
|
||||
```
|
||||
[root@linuxtechi ~]# cat /proc/sys/fs/file-max
|
||||
146013
|
||||
```
|
||||
|
||||
The above number shows that user can open ‘146013’ file per user login session.
|
||||
上面的数字表明用户可以在每个用户登录会话中打开 ‘146013’ 个文件。
|
||||
|
||||
```
|
||||
[root@linuxtechi ~]# cat /proc/sys/fs/file-max
|
||||
@ -34,13 +34,14 @@ The above number shows that user can open ‘146013’ file per user login sessi
|
||||
73906
|
||||
```
|
||||
|
||||
This clearly indicates that individual Linux operating systems have different number of open files. This is based on dependencies and applications which are running in respective systems.
|
||||
这清楚地表明,各个 Linux 操作系统具有不同数量的打开文件。这基于各自系统中运行的依赖关系和应用程序。
|
||||
|
||||
### ulimit command :
|
||||
### ulimit 命令 :
|
||||
|
||||
As the name suggests, ulimit (user limit) is used to display and set resources limit for logged in user.When we run ulimit command with -a option then it will print all resources’ limit for the logged in user. Now let’s run “ **ulimit -a** ” on Ubuntu / Debian and CentOS systems,
|
||||
顾名思义,ulimit(用户限制)用于显示和设置登录用户的资源限制。当我们使用 -a 选项运行 ulimit 命令时,它将打印登录用户的所有资源限制。现在让我们在Ubuntu/Debian 和 CentOS 系统上运行 “**ulimit -a**”,
|
||||
|
||||
**Ubuntu / Debian System** ,
|
||||
|
||||
**Ubuntu / Debian 系统** ,
|
||||
|
||||
```
|
||||
root@linuxtechi ~}$ ulimit -a
|
||||
@ -62,7 +63,7 @@ virtual memory (kbytes, -v) unlimited
|
||||
file locks (-x) unlimited
|
||||
```
|
||||
|
||||
**CentOS System**
|
||||
**CentOS 系统**
|
||||
|
||||
```
|
||||
root@linuxtechi ~}$ ulimit -a
|
||||
@ -84,9 +85,9 @@ virtual memory (kbytes, -v) unlimited
|
||||
file locks (-x) unlimited
|
||||
```
|
||||
|
||||
As we can be seen here different OS have different limits set. All these limits can be configured/changed using “ulimit” command.
|
||||
正如我们可以在这里看到的,不同的操作系统有不同的限制设置。所有这些限制都可以使用 “ulimit” 命令进行配置/更改。
|
||||
|
||||
To display the individual resource limit then pass the individual parameter in ulimit command, some of parameters are listed below:
|
||||
要显示单个资源限制可以在 ulimit 命令中传递特定的参数,下面列出了一些参数:
|
||||
|
||||
* ulimit -n –> It will display number of open files limit
|
||||
* ulimit -c –> It display the size of core file
|
||||
@ -96,8 +97,7 @@ To display the individual resource limit then pass the individual parameter in u
|
||||
* ulimit -v –> It will display the maximum memory size limit
|
||||
|
||||
|
||||
|
||||
Use below commands check hard and soft limits for number of open file for the logged in user
|
||||
使用以下命令检查登录用户打开文件数量的硬限制和软限制
|
||||
|
||||
```
|
||||
root@linuxtechi ~}$ ulimit -Hn
|
||||
@ -106,53 +106,54 @@ root@linuxtechi ~}$ ulimit -Sn
|
||||
1024
|
||||
```
|
||||
|
||||
### How to fix the problem when limit on number of Maximum Files was reached ?
|
||||
### 如何修复达到最大文件数限制的问题 ?
|
||||
|
||||
Let’s assume our Linux server has reached the limit of maximum number of open files and want to extend that limit system wide, for example we want to set 100000 as limit of number of open files.
|
||||
|
||||
Use sysctl command to pass fs.file-max parameter to kernel on the fly, execute beneath command as root user,
|
||||
让我们假设我们的 Linux 服务器已经达到了打开文件的最大数量限制,并希望将该限制扩展到整个系统,例如,我们希望将 100000 设置为打开文件数量的限制。
|
||||
|
||||
```
|
||||
root@linuxtechi~]# sysctl -w fs.file-max=100000
|
||||
fs.file-max = 100000
|
||||
```
|
||||
|
||||
Above changes will be active until the next reboot, so to make these changes persistent across the reboot, edit the file **/etc/sysctl.conf** and add same parameter,
|
||||
上述更改只会在下次重启之前有效,因此要使这些更改在重启后仍存在,请编辑文件 **/etc/sysctl.conf** 并添加相同的参数,
|
||||
|
||||
```
|
||||
root@linuxtechi~]# vi /etc/sysctl.conf
|
||||
fs.file-max = 100000
|
||||
```
|
||||
|
||||
save and exit file,
|
||||
保存并推出文件
|
||||
|
||||
Run the beneath command to make above changes into effect immediately without logout and reboot.
|
||||
运行下面命令,使上述更改立即生效,而无需注销和重新启动。
|
||||
|
||||
```
|
||||
root@linuxtechi~]# sysctl -p
|
||||
```
|
||||
|
||||
Now verify whether new changes are in effect or not.
|
||||
|
||||
现在验证新的更改是否生效。
|
||||
|
||||
```
|
||||
root@linuxtechi~]# cat /proc/sys/fs/file-max
|
||||
100000
|
||||
```
|
||||
|
||||
Use below command to find out how many file descriptors are currently being utilized:
|
||||
|
||||
使用以下命令找出当前正在使用的文件描述符数量:
|
||||
|
||||
```
|
||||
[root@linuxtechi ~]# more /proc/sys/fs/file-nr
|
||||
1216 0 100000
|
||||
```
|
||||
|
||||
Note:- Command “ **sysctl -p** ” is used to commit the changes without reboot and logout.
|
||||
注意:-命令 “**sysctl-p**” 用于在不重新启动和注销的情况下提交更改。
|
||||
### 通过 limit.conf 文件设置用户级资源限制
|
||||
|
||||
### Set User level resource limit via limit.conf file
|
||||
“**/etc/sysctl.conf**” 文件用于设置系统范围的资源限制,但如果要为 Oracle、MariaDB 和 Apache 等特定用户设置资源限制,则可以通过 “**/etc/security/limits.conf**” 文件去实现。
|
||||
|
||||
“ **/etc/sysctl.conf** ” file is used to set resource limit system wide but if you want to set resource limit for specific user like Oracle, MariaDB and Apache then this can be achieved via “ **/etc/security/limits.conf** ” file.
|
||||
|
||||
Sample Limit.conf is shown below,
|
||||
示例 Limit.conf 如下所示,
|
||||
|
||||
```
|
||||
root@linuxtechi~]# cat /proc/sys/fs/file-max
|
||||
@ -162,7 +163,7 @@ root@linuxtechi~]# cat /proc/sys/fs/file-max
|
||||
|
||||
![Limits-conf-linux-part2][2]
|
||||
|
||||
Let’s assume we want to set hard and soft limit on number of open files for linuxtechi user and for oracle user set hard and soft limit on number of open process, edit the file “/etc/security/limits.conf” and add the following lines
|
||||
假设我们要为 linuxtechi 用户设置打开文件数量的硬限制和软限制,而对于 oracle 用户设置打开进程数量的硬限制和软限制,编辑文件 “/etc/security/limits.conf” 并添加以下行
|
||||
|
||||
```
|
||||
# hard limit for max opened files for linuxtechi user
|
||||
@ -176,9 +177,9 @@ oracle hard nproc 8096
|
||||
oracle soft nproc 4096
|
||||
```
|
||||
|
||||
Save & exit the file.
|
||||
保存并退出文件
|
||||
|
||||
**Note:** In case you want to put resource limit on a group instead of users, then it can also be possible via limit.conf file, in place of user name , type **@ <Group_Name>** and rest of the items will be same, example is shown below,
|
||||
**注意:** 如果你想对一个组而不是用户进行资源限制,那么也可以通过limit.conf文件,输入 **@<Group_name>** 代替用户名,其余项都是相同的,示例如下,
|
||||
|
||||
```
|
||||
# hard limit for max opened files for sysadmin group
|
||||
@ -187,7 +188,7 @@ Save & exit the file.
|
||||
@sysadmin soft nofile 1024
|
||||
```
|
||||
|
||||
Verify whether new changes are in effect or not,
|
||||
验证新的更改是否生效
|
||||
|
||||
```
|
||||
~]# su - linuxtechi
|
||||
@ -203,11 +204,11 @@ Verify whether new changes are in effect or not,
|
||||
4096
|
||||
```
|
||||
|
||||
Note: Other majorly used command is “[ **lsof**][3]” which is used for finding out “how many files are opened currently”. This command is very helpful for admins.
|
||||
注:其他主要使用的命令是 “[ **lsof**][3]” 用于找出“当前打开了多少个文件”,这命令对管理员非常有帮助。
|
||||
|
||||
**Conclusion:**
|
||||
**结尾:**
|
||||
|
||||
As mentioned in the introduction section “ulimit” command is very powerful and helps one to configure and make sure application installations are smoother without any bottlenecks. This command helps in fixing many of the number of file limitations in Linux based servers.
|
||||
正如在介绍部分提到的,“ulimit” 命令非常强大,可以帮助用户配置并确保应用程序安装更加流畅,没有任何瓶颈。此命令有助于修复基于 Linux 的服务器中的(打开)大量文件的限制。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -215,7 +216,7 @@ via: https://www.linuxtechi.com/set-ulimit-file-descriptors-limit-linux-servers/
|
||||
|
||||
作者:[Shashidhar Soppin][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[zgj1024](https://github.com/zgj1024)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
@ -1,216 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to use Tig to browse Git logs)
|
||||
[#]: via: (https://opensource.com/article/19/6/what-tig)
|
||||
[#]: author: (Olaf Alders https://opensource.com/users/oalders/users/mbbroberg/users/marcobravo)
|
||||
|
||||
如何使用 Tig 浏览 Git 日志
|
||||
======
|
||||
Tig不仅仅是 Git 的文本界面。以下是它如何增强你的日常工作流程。
|
||||
![A person programming][1]
|
||||
|
||||
如果你使用 Git 作为你的版本控制系统,你可能已经让自己接受 Git 是一个复杂的野兽。它是一个很棒的工具,但在 Git 仓库查找可能很麻烦。因此像 [Tig][2] 这样的工具出现了。
|
||||
|
||||
来自 [Tig 手册页][3]:
|
||||
|
||||
> Tig 是 git(1) 的基于 ncurses 的文本界面。它主要用作 Git 仓库浏览器,但也有助于在块级别暂存提交更改,并显示各种 Git 命令的输出。
|
||||
|
||||
这基本上意味着 Tig 提供了一个可以在终端中运行的基于文本的用户界面。Tig 可以让你轻松浏览你的 Git 日志,但它可以做的远不止让你从最后的提交跳到前一个提交。
|
||||
|
||||
![Tig screenshot][4]
|
||||
|
||||
这篇快速入门的 Tig 中的许多例子都是直接从其出色的手册页中拿出来的。我强烈建议你阅读它以了解更多信息。
|
||||
|
||||
### 安装 Tig
|
||||
|
||||
* Fedora 和 RHEL: **sudo dnf install tig**
|
||||
* Ubuntu 和 Debian: **sudo apt install tig**
|
||||
* MacOS:**:brew install tig**
|
||||
|
||||
|
||||
|
||||
有关更多选项,请参阅官方[安装说明][5]。
|
||||
|
||||
### 浏览当前分支中的提交
|
||||
|
||||
如果要浏览分支中的最新提交,请输入:
|
||||
|
||||
|
||||
```
|
||||
`tig`
|
||||
```
|
||||
|
||||
这是这样。这个三字符命令将启动一个浏览器,你可以在其中导航当前分支中的提交。你可以将其视为 **git log** 的封装器。
|
||||
|
||||
要浏览输出,可以使用向上和向下箭头键从一个提交移动到另一个提交。按回车键将会垂直分割窗口,右侧包含所选提交的内容。你可以继续在左侧的提交历史记录中上下浏览,你的更改将显示在右侧。使用 **k** 和 **j** 逐行上下浏览,**-** 和空格键在右侧上下翻页。使用 **q** 退出右侧窗格。
|
||||
|
||||
搜索 **tig** 输出也很简单。使用 **/** 向前搜索,使用 **?** 在左右窗格中向后搜索。
|
||||
|
||||
![Searching Tig][6]
|
||||
|
||||
这足以让你开始浏览你的提交。这里有很多的键绑定,但单击 **h** 将显示“帮助”菜单,你可以在其中发现其导航和命令选项。你还可以使用 **/** 和 **?** 来搜索“帮助”菜单。使用 **q** 退出帮助。
|
||||
|
||||
![Tig Help][7]
|
||||
|
||||
### 浏览单个文件的修改
|
||||
|
||||
由于 Tig 是 **git log** 的封装器,它可以方便地接受可以传递给 **git log** 的相同参数。例如,要浏览单个文件的提交历史记录,请输入:
|
||||
|
||||
|
||||
```
|
||||
`tig README.md`
|
||||
```
|
||||
|
||||
将其与被封装的 Git 命令的输出进行比较,以便更清楚地了解 Tig 如何增强输出。
|
||||
|
||||
|
||||
```
|
||||
`git log README.md`
|
||||
```
|
||||
|
||||
要在原始 Git 输出中包含补丁,你可以添加 **-p** 选项:
|
||||
|
||||
|
||||
```
|
||||
`git log -p README.md`
|
||||
```
|
||||
|
||||
如果要将提交范围缩小到特定日期范围,请尝试以下操作:
|
||||
|
||||
|
||||
```
|
||||
`tig --after="2017-01-01" --before="2018-05-16" -- README.md`
|
||||
```
|
||||
|
||||
再一次,你可以将其与原始的 Git 版本进行比较:
|
||||
|
||||
|
||||
```
|
||||
`git log --after="2017-01-01" --before="2018-05-16" -- README.md`
|
||||
```
|
||||
|
||||
### 浏览谁更改了文件
|
||||
|
||||
有时你想知道谁对文件进行了更改以及原因。命令:
|
||||
|
||||
|
||||
```
|
||||
`tig blame README.md`
|
||||
```
|
||||
|
||||
本质上是 **git blame** 的封装。正如你 所期望的那样,它允许你查看谁是编辑指定行的最后一人,它还允许你查看到引入该行的提交。这有点像 vim 的 **vim-fugitive**插件提供的**:Gblame**命令。
|
||||
|
||||
### 浏览你的暂存
|
||||
|
||||
如果你像我一样,你可能会在你的暂存处有许多编辑。你很容易忘记它们。你可以通过以下方式查看暂存处中的最新项目:
|
||||
|
||||
|
||||
```
|
||||
`git stash show -p stash@{0}`
|
||||
```
|
||||
|
||||
你可以通过以下方式找到第二个最新项目:
|
||||
|
||||
|
||||
```
|
||||
`git stash show -p stash@{1}`
|
||||
```
|
||||
|
||||
以此类推。如果你在需要它们时调用这些命令,那么你会有比我更清晰的内存。
|
||||
|
||||
|
||||
与上面的 Git 命令一样,Tig 可以通过简单的调用轻松增强你的 Git 输出:
|
||||
|
||||
|
||||
```
|
||||
`tig stash`
|
||||
```
|
||||
|
||||
尝试在有暂存的仓库中执行此命令。你将能够浏览_并搜索_你的暂存项,快速浏览你的那些修改。
|
||||
|
||||
### 浏览你的引用
|
||||
|
||||
git ref 是你提交的东西的哈希值。这包括文件和分支。使用 **tig refs** 命令可以浏览所有引用并深入查看特定提交。
|
||||
|
||||
|
||||
```
|
||||
`tig refs`
|
||||
```
|
||||
|
||||
完成后,使用 **q** 回到前面的菜单。
|
||||
|
||||
### 浏览 git 状态
|
||||
|
||||
如果要查看哪些文件已被暂存,哪些文件未被跟踪,请使用 **tig status**,它是 **git status** 的封装。
|
||||
|
||||
![Tig status][8]
|
||||
|
||||
### 浏览 git grep
|
||||
|
||||
你可以使用 **grep** 命令在文本文件中搜索表达式。命令 **tig grep** 允许你导览 **git grep** 的输出。例如:
|
||||
|
||||
|
||||
```
|
||||
`tig grep -i foo lib/Bar`
|
||||
```
|
||||
|
||||
它会导览 **lib/Bar** 目录中以大小写敏感的方式搜索 **foo** 的输出。
|
||||
|
||||
### 通过标准输入管道输出给 Tig
|
||||
|
||||
如果要将提交 ID 列表传递给 Tig,那么必须使用 **\--stdin** 标志,以便 **tig show** 从标准输入读取。否则,**tig show** 会在没有输入的情况下启动(出现空白屏幕)。
|
||||
|
||||
|
||||
```
|
||||
`git rev-list --author=olaf HEAD | tig show --stdin`
|
||||
```
|
||||
|
||||
### 添加自定义绑定
|
||||
|
||||
你可以使用 [rc][9] 文件自定义 Tig。以下是如何根据自己的喜好添加一些有用的自定义键绑定的示例。
|
||||
|
||||
在主目录中创建一个名为 **.tigrc** 的文件。在你喜欢的编辑器中打开 **~/.tigrc** 并添加:
|
||||
|
||||
|
||||
```
|
||||
# Apply the selected stash
|
||||
bind stash a !?git stash apply %(stash)
|
||||
|
||||
# Drop the selected stash item
|
||||
bind stash x !?git stash drop %(stash)
|
||||
```
|
||||
|
||||
如上所述,运行 **tig stash** 以浏览你的暂存。但是,通过这些绑定,你可以按 **a**将暂存中的项目应用到仓库,并按 **x** 从暂存中删除项目。请记住,你要在浏览暂存_列表_时,才能执行这些命令。如果你正在浏览暂存_项_,请输入 **q** 退出该视图,然后按 **a** 或 **x** 以获得所需效果。
|
||||
|
||||
有关更多信息,你可以阅读有关 [Tig 键绑定][10]。
|
||||
|
||||
### 总结
|
||||
|
||||
我希望这有助于演示 Tig 如何增强你的日常工作流程。Tig 可以做更强大的事情(比如暂存代码行),但这超出了这篇介绍性文章的范围。这里有足够的让你危险的信息,但还有更多值得探索的地方。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/6/what-tig
|
||||
|
||||
作者:[Olaf Alders][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://opensource.com/users/oalders/users/mbbroberg/users/marcobravo
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming)
|
||||
[2]: https://jonas.github.io/tig/
|
||||
[3]: http://manpages.ubuntu.com/manpages/bionic/man1/tig.1.html
|
||||
[4]: https://opensource.com/sites/default/files/uploads/tig.jpg (Tig screenshot)
|
||||
[5]: https://jonas.github.io/tig/INSTALL.html
|
||||
[6]: https://opensource.com/sites/default/files/uploads/tig-search.png (Searching Tig)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/tig-help.png (Tig Help)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/tig-status.png (Tig status)
|
||||
[9]: https://en.wikipedia.org/wiki/Run_commands
|
||||
[10]: https://github.com/jonas/tig/wiki/Bindings
|
Loading…
Reference in New Issue
Block a user