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

This commit is contained in:
geekpi 2022-08-16 08:28:35 +08:00
commit c949ef833f
13 changed files with 1643 additions and 281 deletions

View File

@ -0,0 +1,189 @@
[#]: subject: "Linux tips for using cron to schedule tasks"
[#]: via: "https://opensource.com/article/21/11/cron-linux"
[#]: author: "Seth Kenlon https://opensource.com/users/seth"
[#]: collector: "lujun9972"
[#]: translator: "Veryzzj"
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-14932-1.html"
使用 cron 定时任务的小技巧
======
> 通过使用这个简单而强大的 Linux 命令行工具,来安排备份、文件清理以及其他任务。
![](https://img.linux.net.cn/data/attachment/album/202208/15/151143fjdses6bdj2nj1j5.jpg)
在计算机上让任务按照有规律并且可预测的时间表运行很重要。作为人类,我们有时会因为分心、脑子里想太多,或是度假而记不住要做的事情。计算机真的很擅长按计划做事,但在计算机采取行动之前,人类必须对计算机进行编程。
在某种程度上cron 系统是编程的初级简单入门。通过编辑一个文件就可以让计算机做你想让它做的事。你甚至不需要知道文件保存在哪里。只需键入一个简单的命令,输入你希望电脑遵循的 “配方”,并保存。从那时起,计算机会在指定时间执行你的指令,直到被告知停止。
从设计上来看cron 不是一个复杂的系统。这里有一些你需要了解的内容。
### cron 是什么?
cron 命令在 Linux 和 Unix 中无处不在,而且它经常被模仿和重塑,以至于它几乎成了按计划发生的事情的一个通用术语。它是自动化的一种形式,尽管有不同的实现方式(比如 Dillon's cron、Vixie's cron、chrony 和其他),以及像 anacron 和 systemd 定时器这样的变化,但其语法和工作流程几十年来一直保持着基本一致。
cron 在一个 “<ruby>假脱机<rt>spool</rt></ruby>” 系统上工作,像打印机和电子邮件一样。如果不你知道打印机和电子邮件使用假脱机也没关系,因为假脱机文件的意义在于,你不需要想太多。在 Linux 系统中,`/var/spool` 目录被设计为重要但低级的文件的中心枢纽,用户不需要直接与之交互。 在 `/var/spool` 中管理的一个假脱机是 cron 表(简称为 “crontab”。 包括你在内的每个用户在 Linux 系统中都有一个 crontab。用户可以编辑、查看和删除自己的 crontab。除此之外用户可以使用 crontab 来安排任务。cron 系统监控 crontab并确保一个 crontab 中列出的任何工作都能在其指定时间执行。
### 编辑 cron 设置
你可以使用 `crontab` 命令和 `-e`(代表“编辑”)选项来编辑你的 crontab。默认情况下大多数系统会调用 `vim` 文本编辑器。如果你和我一样,不使用 Vim那么你可以在 `~/.bashrc` 文件中为自己设置一个不同的编辑器。我把我的设置为 Emacs但你也可以试试 [Nano][4]、[Kate][5],或者任何你喜欢的编辑器。`EDITOR` 环境变量定义了你在终端使用的文本编辑器,而 `VISUAL` 变量定义了你在图形模式下使用的编辑器:
```
export EDITOR=nano
export VISUAL=kate
```
更新设置后刷新你的 shell 会话:
```
$ source ~/.bashrc
```
现在你可以用喜欢的编辑器编辑 crontab
```
$ crontab -e
```
#### 为任务执行安排时间
cron 系统本质上是一个日历系统。可以通过五个不同的属性告诉 cron 需要让一个任务多长时间运行一次:分、时、日、月、星期。这些属性的顺序是固定的,并且不一定是直观的,你可以把它们看作是过滤器或掩码。默认情况下,你可以理解为所有东西都被设置为“总是”或者“每一个”。此命令将在全年的每一天每小时每分钟运行 `touch /tmp/hello`
```
* * * * * touch /tmp/hello
```
可以通过设置每个属性的具体定义来限制这个包罗万象的时间安排表。使任务在每个小时的 30 分钟时运行,将分钟设置为 `30`
```
30 * * * * touch /tmp/hello
```
可以通过一个具体的小时来进一步约束这个指令。使任务在每个凌晨 3:30 运行:
```
30 3 * * * touch /tmp/hello
```
你也可以让这个任务只在每个月的第一天运行:
```
30 3 1 * * touch /tmp/hello
```
你可以用 `1``12` 表示 1 至 12 月来设置月份,用 `0``6` 表示周日至周六来设置星期。这项任务在 4 月份的周一的 3:15 运行:
```
15 3 * 4 1 touch /tmp/hello
```
### 设置增量
所有这些设置都与一个固定时间 _完全_ 匹配。使用 cron 符号设置可以在特定时间段后运行任务,例如,每 15 分钟运行一个任务:
```
*/15 * * * * touch /tmp/hello
```
每三天在上午 10 点运行任务:
```
* 10 */3 * * touch /tmp/hello
```
每 6 小时运行一次任务:
```
* */6 * * * touch /tmp/hello
```
### Cron 速记符
现代的 cron 实现已经为常见的时间安排表添加了方便的速记符,包括:
* `@hourly`:每小时
* `@daily`:每天
* `@weekly`:每周
* `@monthly`:每月
* `@yearly``@annually`:每年
### 列出 cron 任务
使用 `crontab` 命令,查看计划中的 cron 任务列表:
```
$ crontab -l
15 3 * 4 1 touch /tmp/hello
```
### 删除一个 crontab
当一个 crontab 任务不需要时,可以使用 `-r` 选项来删除它:
```
$ crontab -r -i
```
`-i` 选项代表 _交互式_。它在删除文件之前会提示你进行确认。
### Cron 可以做什么
知道如何使用 cron 是一回事,但但知道它的用途是另一回事。经典用例就是备份计划。如果你的电脑一天中大部分时间都是开着的,或者整天整夜地开着,那么可以为重要分区进行例行备份。我会在每天凌晨 3 点在主要数据分区上运行一个名为 `rdiff-backup` 的备份程序:
```
$ crontab -l | grep rdiff
* 3 * * * rdiff-backup /data/ /vault/
```
另一个常见的用途是系统维护。在我的 Slackware 桌面上,每周五下午会更新本地版本库目录:
```
$ crontab -l | grep slack
* 14 * * 5 sudo slackpkg update
```
我还会每 3 天在 15:00 运行一个 Ansible 脚本来 [清理我的下载文件夹][6]
```
$ crontab -l | grep ansible
* 15 */3 * * ansible-playbook /home/seth/Ansible/cleanup.yaml
```
有一些重复数据删除脚本、文件大小和 `/tmp` 目录的监视器、照片调整器、文件移动工具以及很多琐碎的任务,你可以安排在后台运行,以帮助保持系统不受干扰。有了 cron计算机可以以我希望我的实体公寓能够做到的方式来照顾自己。
### 记住 cron 的设置
除了想明白你为什么需要 cron 之外根据我的经验cron 最难的事情是记住它的语法。重复这句话给自己听,反反复复,直到你记牢它:
> 分、时、日、月、星
>
> 分、时、日、月、星
>
> 分、时、日、月、星
更好的做法是,去 [下载我们免费的速查表][7] ,这样当你最需要它时,它触手可及!
> **[Cron 速查表][7]**
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/11/cron-linux
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[Veryzzj](https://github.com/Veryzzj)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_keyboard_desktop.png?itok=I2nGw78_ "Linux keys on the keyboard for a desktop computer"
[2]: https://opensource.com/article/21/2/linux-automation
[3]: https://opensource.com/article/20/7/systemd-timers
[4]: https://opensource.com/article/20/12/gnu-nano
[5]: https://opensource.com/article/20/12/kate-text-editor
[6]: https://opensource.com/article/21/9/keep-folders-tidy-ansible
[7]: https://opensource.com/downloads/linux-cron-cheat-sheet

View File

@ -0,0 +1,96 @@
[#]: subject: "Kali Linux 2022.3 Introduces a Test Lab Environment and New VirtualBox Image"
[#]: via: "https://news.itsfoss.com/kali-linux-2022-3-release/"
[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/"
[#]: collector: "lujun9972"
[#]: translator: "wxy"
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-14933-1.html"
Kali Linux 2022.3 发布
======
> Kali Linux 2022.3 在引入了新的 VirtualBox 镜像格式的同时,也使测试变得更加方便。不要忘了试试新的工具!
![](https://news.itsfoss.com/wp-content/uploads/2022/08/kali-2022-3.jpg)
Kali Linux 在 2022 年的第三次升级中带着激动人心的新内容回来了。
像往常一样,你可以期待新的工具和全面的改进。此外,还有一些关键的亮点,包括新的 **测试实验室环境****VirtualBox 镜像**
在这里,让我给你介绍一下这个版本的细节。
### Kali Linux 2022.3 有什么新内容?
Kali Linux 2022.3 的发布标志着他们开始启用了 **新的 Discord 服务器**,使社区能够聚集在一起,谈论关于 Kali Linux 的事情。
除了社区有了 Discord 服务器之外,应该引起你对升级的关注的事情包括:
* 一个便于测试的新测试实验室环境
* 开放 kali-tools 资源库,以供社区提交
* NetHunter 商店中的新软件
* 一个新的 VirtualBox 镜像格式
* 大量的新工具
### 测试实验室环境
Kali Linux 是为安全研究人员量身定做的可以用于测试和学习。但是为了增强体验使任何人都能毫不费力地建立一个测试实验室Kali Linux 现在增加了易于安装的软件包,如 [DVWA][1] 和 [Juice Shop][2]。
开发者还提到,在不久的将来会有更多的软件包。
### 新工具
新的升级包括了五个有趣的工具,它们是:
* BruteShark网络分析工具
* DefectDojo开源的应用程序漏洞工具
* phpsploit隐蔽的破解后应用框架
* shellfire利用命令注入漏洞
* SprayingToolkit密码攻击
你可以探索这些工具以了解更多信息。
### 增强的 VirtualBox 支持
虽然 Kali Linux 已经可以用于 VMware 和 VirtualBox但现在为 VirtualBox 用户提供了一种新的镜像格式。
你现在可以下载用于 VirtualBox 的 VDI 磁盘镜像和 .vbox 元数据文件。它是原生的 VirtualBox 镜像格式,具有更好的压缩率,下载速度更快。
对于希望使用最新和最先进工具的用户Kali Linux 提供了按周构建的虚拟机镜像,构建自其滚动分支。
此外如果你需要构建你的自定义虚拟机镜像Kali Linux 已经在 [GitLab][3] 上提供了一些脚本。
### 其他改进
Kali Linux 2022.3 增加了几个重要的升级。其中包括:
* 针对树莓派设备的 Linux 内核 5.15 更新。
* 针对 ARM 设备的技术改进。
* 文档更新,有一些新页面。
* 网络存储库的维护工作。
* NetHunter 商店的大量更新,以及对即将到来的 Android 12 支持。
### 下载 Kali Linux 2022.3
你可以在其 [官方下载页面][4] 找到最新的 Kali Linux 2022.3 ISO以及新的 VirtualBox 镜像文件和每周更新包。
> **[Kali Linux 2022.3][5]**
--------------------------------------------------------------------------------
via: https://news.itsfoss.com/kali-linux-2022-3-release/
作者:[Ankush Das][a]
选题:[lujun9972][b]
译者:[wxy](https://github.com/wxy)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://news.itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://www.kali.org/tools/dvwa/
[2]: https://www.kali.org/tools/juice-shop/
[3]: https://gitlab.com/kalilinux/build-scripts/kali-vm
[4]: https://www.kali.org/get-kali/
[5]: https://www.kali.org/get-kali/#kali-platforms

View File

@ -1,98 +0,0 @@
[#]: subject: "Kali Linux 2022.3 Introduces a Test Lab Environment and New VirtualBox Image"
[#]: via: "https://news.itsfoss.com/kali-linux-2022-3-release/"
[#]: author: "Ankush Das https://news.itsfoss.com/author/ankush/"
[#]: collector: "lujun9972"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Kali Linux 2022.3 Introduces a Test Lab Environment and New VirtualBox Image
======
Kali Linux is back with exciting additions for its third upgrade in 2022.
As usual, you can expect new tools and refinements across the board. In addition, there are a few key highlights, including a **new test lab environment** and a **VirtualBox image**.
Here, let me give you more details on the release.
### Kali Linux 2022.3: Whats New?
Kali Linux 2022.3 release marks the start of their **new Discord server**, allowing the community to get together and chat all about Kali Linux.
Along with the community getting a Discord server, things that should grab your attention for the upgrade include:
* **A new test lab environment for easy testing.**
* **Opening kali-tools repository for community submissions.**
* **New releases in NetHunter store.**
* **A new VirtualBox image format.**
* **Bunch of new tools.**
### Test Lab Environment
Kali Linux is tailored for security researchers to test and learn. But, to enhance the experience and make it effortless for anyone to build a test lab, Kali Linux now adds easy-to-install packages like [DVWA][1], and [Juice Shop][2].
The developers also mention that there will be more packages available in the near future.
### New Tools
The new upgrade includes five interesting tools, they are:
* **BruteShark** (Network Analysis Tool)
* **DefectDojo** (Open-source application vulnerability)
* **phpsploit** (Stealth post-exploitation framework)
* **shellfire** (Exploiting command injection vulnerabilities)
* **SprayingToolkit** (Password attacks)
You can explore the tools to learn more about it.
### Enhanced VirtualBox Support
While Kali Linux was already available for VMware and VirtualBox, we now have a new image format for VirtualBox users.
You can now download a **VDI** disk image and a **.vbox** metadata file for VirtualBox. It is the native format for VirtualBox images, and faster to download, considering a better compression ratio.
For users looking to be on the latest and greatest, Kali Linux has made **weekly builds of VM images available**, built from its rolling branch.
Additionally, if you need to build your custom VM images, Kali Linux has made some scripts available on [GitLab][3].
### Other Improvements
Kali Linux 2022.3 adds several significant upgrades to the table. Some include:
* Linux Kernel 5.15 update for Raspberry Pi devices.
* Technical improvements for ARM devices.
* Documentation updates with new pages.
* Maintenance work for network repository.
* Numerous updates to the NetHunter store along with imminent Android 12 support.
### Download Kali Linux 2022.3
You can find the latest Kali Linux 2022.3 ISO on its [official download page][4], along with the new VirtualBox image file and weekly update packages.
[Kali Linux 2022.3][5]
--------------------------------------------------------------------------------
via: https://news.itsfoss.com/kali-linux-2022-3-release/
作者:[Ankush Das][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://news.itsfoss.com/author/ankush/
[b]: https://github.com/lujun9972
[1]: https://www.kali.org/tools/dvwa/
[2]: https://www.kali.org/tools/juice-shop/
[3]: https://gitlab.com/kalilinux/build-scripts/kali-vm
[4]: https://www.kali.org/get-kali/
[5]: https://www.kali.org/get-kali/#kali-platforms

View File

@ -0,0 +1,65 @@
[#]: subject: "Best 5 Alternatives to Microsoft Office [Compared]"
[#]: via: "https://www.debugpoint.com/best-alternatives-microsoft-office-2022/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Best 5 Alternatives to Microsoft Office [Compared]
======
Here we give you the five best alternatives to Microsoft Office. We compare them based on features, are easy to use and provide you with a guide to choosing the one you need.
We all agree that Microsoft Office is one of the best software developed by Mircosoft. It has a presence almost everywhere in the entire world in nearly every business. It is a fine piece of software that evolved over a few decades.
And obviously, it doesnt have a Linux native installer and comes with a significant price. The current Microsoft Office 365 subscription pricing is a little higher if you are a business owner or a personal user. And not everyone can afford that price bucket for a longer time.
Then what are the alternatives? You can try other options that relatively get the job done for most users or businesses.
This article gives you the five best alternatives to Microsoft Office.
### Best Alternatives to Microsoft Office
### 1. LibreOffice
![LibreOffice][1]
The first alternative we highlight here is [LibreOffice][2]. The Document Foundation develops and manages the entire LibreOffice free and open-source office suite, available for Linux, macOS and Windows.
Firstly, it comes with a spreadsheet ([Calc][3]), word processor (Writer), presentation (Impress), drawing (Draw) and a database program (Base).
Secondly, this project is actively developed, and compatibility with Microsoft Office documents is improved in every release iteration. If appropriately used, LibreOffice can effectively do all the work that a Mircosoft office program does. In addition, a massive set of documentation and communities can help you adopt LibreOffice in no time.
You dont need to pay for the software if you are a small or large corporation. But paid deployment and support are also available at minimal cost if you require them for your critical work.
However, LibreOffice does not come with an Outlook-like email program. This might be one of the minor drawbacks, but you can access emails from web browsers today for all email service providers.
**More details about LibreOffice**
* [Home page][4]
* [For Business][5]
* [Download for general-purpose personal use][6]
* [Help and Documentation][7]
* [Official support forum][8]
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/best-alternatives-microsoft-office-2022/
作者:[Arindam][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed
[1]: https://www.debugpoint.com/wp-content/uploads/2022/03/LibreOffice.jpg
[2]: https://www.libreoffice.org/discover/libreoffice/
[3]: https://www.debugpoint.com/category/libreoffice/libreoffice-calc/
[4]: https://www.libreoffice.org/discover/libreoffice/
[5]: https://www.libreoffice.org/download/libreoffice-in-business/
[6]: https://www.libreoffice.org/download/download/
[7]: https://help.libreoffice.org/latest/en-US/text/shared/05/new_help.html

View File

@ -0,0 +1,107 @@
[#]: subject: "Create Your Own Custom Light and Dark Wallpaper for GNOME"
[#]: via: "https://www.debugpoint.com/custom-light-dark-wallpaper-gnome/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Create Your Own Custom Light and Dark Wallpaper for GNOME
======
An easy guide on creating your custom light and dark wallpaper for the GNOME desktop.
[GNOME 42][1]introduces the much-awaited light and dark theme to GNOME Desktop. It also brings the light and dark version of wallpaper, which automatically changes when you switch between light and dark themes.
So, by default, GNOME gives you a few sets of pre-configured light and dark wallpapers.
But what if you want a different wallpaper that changes automatically when the theme changes?
Heres how to configure and create your custom wallpaper for light and dark themes in GNOME.
### How to create custom light and dark wallpaper for GNOME
Firstly, make sure you have two versions of wallpaper handy with you. In general, they should be standard PNG or JPG images. For example, we used below two wallpapers for this demo.
![Sample light and dark wallpaper for demo][2]
But if you do not have proper light and dark wallpaper and looking for more, I will let you know how to get them or prepare your own at the end of this guide.
Stay with me.
Second, we need to create a schema file for our own. The automatic changing of wallpaper is handled by an XML file called adwaita.xml, which defines specific light and dark background tags. So, we will create our XML file for the wallpapers.
To do that, copy the contents of adwaita.xml from GitLab and create a new XML file (the link is down below). You should see two tags inside this file “filename” and “filename-dark”. These two XML tags contain the fully qualified path of both wallpapers. Add the path to your images under these two tags, as shown below.
[Download the XML file from here (adwaita.xml.in)][3]
![Change the XML file][4]
Third, save this file to **/home/your_name/.local/share/gnome-background-properties** with any name you want. If the “gnome-background-properties” are not there, create them. For this example, I used my_cool_backgrounds.xml.
![Save the file][5]
And you are all set. Finally, open the settings and go to the Appearance tab, and you should see the new wallpapers visible as an option.
Select your custom light and dark wallpaper and enjoy.
![The appearance tab now has your custom light and dark wallpaper][6]
### How to download or make your dynamic wallpaper
You must think, “who has the time to find and create both day and night versions of wallpaper”? Several websites give you dynamic wallpapers ready-made that you can easily download and install.
One website I would recommend is [dynamicwallpaper.club][7] which has some excellent high-quality wallpapers up to 6K for macOS. And you can easily download them.
Additionally, if you plan to download from the above website, remember that the sites images are in [heic format][8]because the website is for macOS. The High-Efficiency Video Coding (HEIC) is Apples proprietary version of the HEIF or High-Efficiency Image File format.
You need a driver to view and convert the dynamic heic images in Ubuntu or Fedora Linux. So, how do you convert them to Linux systems? Open a terminal and run the below commands to install the driver.
**Ubuntu** **users**
```
sudo apt install heif-gdk-pixbuf
```
Fedora users
```
sudo dnf install libheif
```
**For Fedora/Ubuntu with KDE Plasma Only** (without this plugin, Plasma apps cant open heic images)
```
sudo apt install qt-heif-image-pluginsudo dnf install qt-heif-image-plugin
```
Finally, open the heic image with your favourite image viewer and save it as JPG/PNG.
![Custom Light and Dark wallpaper in GNOME transition][9]
Lastly, dont forget to let me know below in the comment section whether you can create your own custom dark and light wallpaper for GNOME.
Cheers.
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/custom-light-dark-wallpaper-gnome/
作者:[Arindam][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed
[1]: https://www.debugpoint.com/2022/03/gnome-42-release/
[2]: https://www.debugpoint.com/wp-content/uploads/2022/04/Sample-light-and-dark-wallpaper-for-demo.jpg
[3]: https://gitlab.gnome.org/GNOME/gnome-backgrounds/-/tree/main/backgrounds
[4]: https://www.debugpoint.com/?attachment_id=9376
[5]: https://www.debugpoint.com/?attachment_id=9375
[6]: https://www.debugpoint.com/?attachment_id=9374
[7]: https://dynamicwallpaper.club
[8]: https://en.wikipedia.org/wiki/High_Efficiency_Image_File_Format
[9]: https://www.debugpoint.com/wp-content/uploads/2022/04/Custom-Light-and-Dark-wallpaper-in-GNOME-transition.gif

View File

@ -0,0 +1,126 @@
[#]: subject: "How to Monitor Log Files in Real Time in Linux [Desktop and Server]"
[#]: via: "https://www.debugpoint.com/monitor-log-files-real-time/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How to Monitor Log Files in Real Time in Linux [Desktop and Server]
======
This tutorial explains how you can monitor Linux log files (desktop, server or applications) in real-time for diagnosis and troubleshooting purposes.
When you run into problems in your Linux desktop, server or any application, you first look into the separate log files. The log files are generally a text stream and messages from applications with a timestamp. It helps you to narrow down specific instances and enables you to find the cause of any problem. It can also help to get assistance from the web as well.
In general, all log files are located in `/var/log`. This directory contains log files with extensions `.log` for specific applications and services, and it also contains separate other directories which contain their log files.
![log files in var-log][1]
So, if you want to monitor a bunch of log files Or a specific one, here are some ways you can do it.
### Monitor Log Files in real-time Linux
#### Using tail command
The `tail` command is the most basic way of following a log file in real time. Especially if you are in a server with only a terminal and no GUI. This is very helpful.
Examples:
**Basic Syntax**
```
tail /path/to/log/file
```
**Usage**
![Monitoring multiple log files via tail][2]
Use the switch `-f` to follow the log file, which updates in real-time. For example, if you want to follow syslog, you can use the following command.
```
tail -f /var/log/syslog
```
You can monitor multiple log files using a single command using
```
tail -f /var/log/syslog /var/log/dmesg
```
If you want to monitor HTTP or sftp or any server, you can use their respective log files in this command.
Remember, the above commands require admin privileges.
#### Using lnav (The Logfile Navigator)
![lnav Running][3]
The lnav is an excellent utility which you can use to monitor log files in a more structured way with colour-coded messages. This is not installed by default in Linux systems. You can install it using the below command:
```
sudo apt install lnav (Ubuntu)sudo dnf install lnav (Fedora)
```
The good thing about lnav is that if you do not want to install it, you can download its pre-compiled executable and run it anywhere, even from a USB stick. No setup is required, plus loaded with features. Using lnav you can query the log files via SQL, among other cool features you can learn on its [official website][4].
Once installed, you can run lnav from a terminal with admin privilege, and it will show all the logs from `/var/log` by default and start monitoring in real-time.
#### A note about journalctl of systemd
All modern Linux distributions today use systemd, mostly. The systemd provides a basic framework and components which runs Linux operating system in general. The systemd provides journal services via journalctl, which helps to manage logs from all systemd services. You can also monitor respective systemd services and logs in real-time using the following command.
```
journalctl -f
```
Here are some specific journalctl commands you can use for several cases. You can combine these with the -f switch above to start monitoring in real-time.
* For emergency system messages, use:
```
journalctl -p 0
```
* Show errors with explanations:
```
journalctl -xb -p 3
```
* Use time controls to filter out:
```
journalctl --since "2022-12-04 06:00:00"
journalctl --since "2022-12-03" --until "2022-12-05 03:00:00"
journalctl --since yesterday
journalctl --since 09:00 --until "1 hour ago"
```
If you want to learn more about and find out details about journalctl I have written a [guide here][5].
### Closing Notes
I hope these commands and tricks help you find the root cause of your problem/errors in your desktop or servers. For more details, you can always refer to the man pages and play around with various switches. Let me know if you have any comments or thoughts about this article using the comment box below.
Cheers.
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/monitor-log-files-real-time/
作者:[Arindam][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed
[1]: https://www.debugpoint.com/wp-content/uploads/2021/08/log-files-in-var-log-1024x312.jpeg
[2]: https://www.debugpoint.com/wp-content/uploads/2021/08/Monitoring-multiple-log-files-via-tail.jpeg
[3]: https://www.debugpoint.com/wp-content/uploads/2021/08/lnav-Running.jpeg
[4]: https://lnav.org/features
[5]: https://www.debugpoint.com/2020/12/systemd-journalctl/

View File

@ -0,0 +1,131 @@
[#]: subject: "How to Record Audio in Linux With Audacity (and Reduce Noise)"
[#]: via: "https://itsfoss.com/audacity-recording/"
[#]: author: "Anuj Sharma https://itsfoss.com/author/anuj/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How to Record Audio in Linux With Audacity (and Reduce Noise)
======
[Audacity][1] is a free and open source cross-platform [audio editor][2]. Professionals use it for the tone of features it provides in such a small package.
You dont have to be a professional and use all of its features. You can use it to record audio from your microphone and do some basics like background noise removal.
I will show you how to do that in this tutorial.
### Installing Audacity on Linux
Installing Audacity on Linux is quite a straightforward process. Because of its popularity, it is available in the official repositories of most Linux distributions.
You can search for it in your distributions software center or package manager.
As a terminal fan, let me share the commands for the common distros.
For Debian or Ubuntu-based distributions:
```
sudo apt install audacity
```
For RHEL or Fedora-based distributions:
```
sudo dnf install audacity
```
If you use an Arch-based distribution:
```
sudo pacman -Syu audacity
```
**Note** that installing via the official repositories may not give you the [latest version][3]. To get the latest version, you may use the AppImage, or Flatpak/Snap packages.
### Recording audio using Audacity
Once Audacity is installed, open it from the application menu or launch it from the terminal. You will be greeted with something like this:
![Audacity Interface][4]
It is easy to start recording by clicking on the **record** button (the red dot). When you are done, click on the **stop** button (square icon) to finish. You also get a waveform preview of your recording, as shown below:
![record audio with audacity][5]
Then, you can check what was recorded by clicking the **play** button (the green icon).
In case you do not see any waveform it indicates that nothing has been recorded. Probably, you have not set up your input correctly. Ensure that you have selected the correct microphone and it is not muted in the **system settings**. You can also access this from the Audacity interface.
The recordings are not saved automatically as MP3 or other formats. **To save the recording**, you can go to File → Export and select **Export as MP3** (or any other preferred format).
### Reducing background noise with Audacity
There is another fantastic feature available in Audacity which you can use to reduce white noise in recorded audio.
The best practice would be to not say anything for the first five seconds when you start recording with Audacity. This should give you desired background noise.
On the waveform of your audio recording, select the part you think is the background noise.
![Background noise][6]
With the noise part selected, go to **Effects → Noise Reduction** from the top file menu.
It will open a pop-up window like this. Click on the “**Get Noise Profile**” here.
![Noise Reduction Effect Popup Window][7]
Now, you have got the noise profile set. Now you have to use it to reduce it from the recording.
Press Ctrl + A shortcut key to select the entire recording. You may also select part of it, noise will be reduced from the selected portion only.
With the audio track selected, again go to **Effect → Noise Reduction**.
**Dont click** on Get Noise Profile this time. This time, you should be able to press the **OK** button.
Just press the OK button and this will apply the noise reduction effect to your recording, which gets reflected on the waveform as shown below:
![Audio Waveform after Noise Reduction][8]
Now the recorded audio will have less noise as compared. You can fine-tune the noise filtering while selecting the Noise Reduction effect.
To summarize:
* Select the noise part, go to Effect->Noise Reduction and then click “Get Noise Profile”
* Press Ctrl+A to select entire audio recording, go to Effect->Noise Reduction and press OK this time
Note that you cannot remove every type of noise, but this should help nonetheless.
### Audacity can do a lot more
Recording audio with Audacity may not seem as easy as using GNOME Sound Recorder, but its not overly complicated. The noise reduction feature comes in handy if you are recording voiceovers.
Audacity has a lot more features, and it is not possible to cover all of them in a single tutorial. This is why Ill keep this short and simple.
If you have a problem with [Audacitys privacy policy adjustments][9] (in 2021), try out some of the available forks.
I hope this little tutorial helps you use Audacity for audio recording. Let me know if you have questions or suggestions.
--------------------------------------------------------------------------------
via: https://itsfoss.com/audacity-recording/
作者:[Anuj Sharma][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/anuj/
[b]: https://github.com/lkxed
[1]: https://github.com/audacity/audacity
[2]: https://itsfoss.com/best-audio-editors-linux/
[3]: https://github.com/audacity/audacity/releases
[4]: https://itsfoss.com/wp-content/uploads/2022/08/audacity-interface.png
[5]: https://itsfoss.com/wp-content/uploads/2022/08/record-audio-with-audacity.png
[6]: https://itsfoss.com/wp-content/uploads/2022/08/audacity-noise-reduction.png
[7]: https://itsfoss.com/wp-content/uploads/2022/08/audacity-noise-steps.png
[8]: https://itsfoss.com/wp-content/uploads/2022/08/audacity-noise-reduced.png
[9]: https://news.itsfoss.com/audacity-fiasco-fork/

View File

@ -0,0 +1,148 @@
[#]: subject: "New GNOME Text Editor Everything You Need to Know"
[#]: via: "https://www.debugpoint.com/gnome-text-editor/"
[#]: author: "Arindam https://www.debugpoint.com/author/admin1/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
New GNOME Text Editor Everything You Need to Know
======
We give you details about GNOMEs new default text editor the Gnome Text Editor.
A text editor is an essential tool for any Linux distribution or desktop. You use it almost daily for small to complex tasks while working, studying, etc.
Most mainstream Linux desktops have a text editor that integrates well. For example, KDE has Kate or KWrite, and GNOME has Gedit.
### So, Why a new Text Editor for GNOME?
GNOME 42 version onwards, Gedit is replaced with a new editor Gnome Text Editor. So the distributions which are based on GNOME should not have the new editor. The old Gedit may co-exist with this new editor until users are comfortable.
You might ask why.
What is wrong with Gedit? Gedit is a mighty text editor that supports many advanced functionalities other than being a simple text editor. Nothing is wrong in that sense. We covered some cool features of Gedit [here][1]; you might want to look.
The primary reason for putting effort into creating another text editor is the libadwaita library adaptation necessary for GNOME Shell. The libadwaita and associated libhandy library provide advanced GUI features such as animation, UI widgets, built-in dark mode, responsive UI and others.
Adapting libadwaita and its features to an existing application running for decades is a complex process. It is more cost-effective to develop a brand-new application with the latest libraries than to debug and change an old one.
The Gedit is a two-decade-old application, with its first release in Feb 1999. Now you can comprehend what kind of complexity is built already inside its code base.
### GNOME Text Editor
At first look, [GNOMEs new text editor][2] looks the same. See the image below.
![GNOME Text Editor][3]
The first difference you would see in the looks. The title bar, action buttons and fonts are different. And they look neat overall. There is a slight gradient of the logo in the title bar itself, which you may notice. That is cool, indeed.
The Open menu has a search bar with an option to open the open file dialog. The title bar has the line and column numbers at the top, unlike in Gedit, where it was at the bottom.
When you start modifying a file, it gives you a dot instead of an Asterix indicator showing that it has been changed.
In the editor itself, the line numbers are shown on the left side. The context menu is almost the same as Gedits.
At the top right, there is no Save button like in Gedit. However, you have two options. The first view button gives you detailed settings about the Margin, Indentation, Wrapping and other options.
![Menu 1][4]
The main difference is in the hamburger menu and its preference dialog.
The hamburger menu provides the dark and light mode out-of-the-box, which is accessible from this menu itself. Thanks to the libadwaita library, you can experience it with its default installation without any additional plugins.
![GNOME Text Editor - Hamburger Menu][5]
![GNOME Text Editor in Dark Mode][6]
The preference dialog is entirely new. The new text editor provides the following themes preloaded
* Adwaita
* Kate
* Tango
* Classic
* Solarized Light
![Preference Window][7]
Also, new features such as Grid pattern in the entire editor window, highlighting current lines and overview map are excellent additions to this editor.
A built-in session restoration behaviour is bound to help you when you work in this text editor.
One of the nifty features is the save as dialog box. It gives you a nice little list of unsaved files with an option to select which ones you want to save. This is, indeed, next-level UI design.
![New Save Changes Popup][8]
### Comparison to Gedit
If you compare this new editor to Gedit, there are many differences from the feature standpoint. The default Gedit was powerful because of its Plugins. It had plugins for grammar and spelling check, a built-in Python compiler and many others and they are part of the default installation.
As this editor is still in a very early stage of writing this guide, I hope more features drop in. Plugin support is welcome; if existing Gedit plugins can be used, nothing like it.
So, thats about its features. Heres how you can install it.
### How to Install
#### Using Flatpak
Set up your system to use Flatpack and use the following command to install.
```
flatpak install flathub org.gnome.TextEditor
```
#### Using apt (for Ubuntu, Linux Mint and others)
You can also install it using the apt package manager as the below command.
```
sudo apt install gnome-text-editor
```
#### For Fedora and related distros using dnf
```
sudo dnf install gnome-text-editor
```
#### Usage
Remember those commands which you used to run using gedit? For example:
```
sudo gedit somefile.txt
```
Now that you have a new editor. You should start using it. And the above command looks like the one below.
```
sudo gnome-text-editor somefile.txt
```
### Closing Notes
I hope Gedit and GNOME Text Editor can co-exist as default packaging in future GNOME releases. A new editor is acceptable regarding look and feel, but how often do you care about how an app looks right? Because many users have already established their workflow with Gedit and its plugins.
So, do you like the new Text Editor of GNOME? Let me know in the comment box below.
--------------------------------------------------------------------------------
via: https://www.debugpoint.com/gnome-text-editor/
作者:[Arindam][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.debugpoint.com/author/admin1/
[b]: https://github.com/lkxed
[1]: https://www.debugpoint.com/2021/04/gedit-features/
[2]: https://gitlab.gnome.org/GNOME/gnome-text-editor
[3]: https://www.debugpoint.com/wp-content/uploads/2021/12/GNOME-Text-Editor-1024x576.jpg
[4]: https://www.debugpoint.com/wp-content/uploads/2021/12/Menu-1.jpg
[5]: https://www.debugpoint.com/wp-content/uploads/2021/12/GNOME-Text-Editor-Hamburger-Menu.jpg
[6]: https://www.debugpoint.com/wp-content/uploads/2021/12/GNOME-Text-Editor-in-Dark-Mode.jpg
[7]: https://www.debugpoint.com/wp-content/uploads/2021/12/Preference-Window.jpg
[8]: https://www.debugpoint.com/wp-content/uploads/2021/12/New-Save-Changes-Popup.jpg

View File

@ -0,0 +1,256 @@
[#]: subject: "Handling “apt-key is deprecated. Manage keyring files in trusted.gpg.d instead” in Ubuntu Linux"
[#]: via: "https://itsfoss.com/apt-key-deprecated/"
[#]: author: "Abhishek Prakash https://itsfoss.com/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Handling “apt-key is deprecated. Manage keyring files in trusted.gpg.d instead” in Ubuntu Linux
======
Installing a package from an [external repository in Ubuntu][1] consists of three steps:
* Adding the repositorys GPG key to the system
* Adding the external repository to the system
* Installing the package from this external repository
But lately, you would notice a message about apt-key being deprecated when you try installing packages from third-party repositories.
Take the [installation of Spotify on Ubuntu][2] for example. When I add the GPG key to the system, it complains.
```
curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | sudo apt-key add -
[sudo] password for abhishek:
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK
```
Its a warning, not an error. It doesnt stop the process. The GPG key is added to your system and you can continue adding the external repository.
However, it will create further warnings (again, not errors). In the example here, if I continue adding the external repository, it shows me this message.
```
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
W: http://repository.spotify.com/dists/stable/InRelease: Key is stored in legacy trusted.gpg keyring (/etc/apt/trusted.gpg), see the DEPRECATION section in apt-key(8) for details.
```
It doesnt stop the installation of the package, though. In the example, I was able to install the spotify-client package afterward.
If its not an error, do you need to be worried about it? Probably not. Not now, at least. However, it would be better to understand future changes coming to this external repo mechanism.
### Understanding the apt-key deprecation and trusted.gpg issue
There are two parts to this message:
* apt-key is deprecated
* Manage keyring files in trusted.gpg.d
Ill come to both points in a moment.
When you add the keys (.gpg or .asc) of a repository, your system trusts the packages (signed with that key) coming from the repository. If you dont add the key of a repository, your system wont allow installing packages from it.
For a long time, the apt-key command line tool has been used for managing the repository keys to Debian and other distros using apt package management. You can add, list, update, and remove the keys with this command.
#### Problem with the way apt-key works
It works by adding the keys to the /etc/apt/trusted.gpg file. The apt package manager trusts the keys inside this file.
Sounds good, right? However, it was discovered to be a potential security issue. Your system trusts those keys completely, not just for the packages you added them for.
Imagine that you added keys to repository A to get package AA and to repo B to get package BB. Your system will gladly accept package BB signed by the key of repo A. It cannot relate the keys to their respective packages.
Now, its easier said than done because there are other factors in play like apt policy and preferences but it opens an attack surface.
This is the reason why apt-key is being deprecated. Thats the first part of the warning message.
#### Ubuntu wants you to separate GPG keys
Coming to the second part of the warning message; “Manage keyring files in trusted.gpg.d”.
Ubuntu doesnt want you to add all the signature keys in the single /etc/apt/trusted.gpg file. It suggests using a separate file that are located in the /etc/apt/trusted.gpg.d directory.
Its the same mechanism it uses for the sources list where external repository sources are listed in their own file under /etc/apt/sources.list.d instead of keeping everything under the /etc/apt/sources.list file. It makes managing the external repos a bit easier.
This means that instead of using the apt-key in this fashion:
```
curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | sudo apt-key add -
```
You should use it like this:
```
curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/spotify.gpg
```
Which is basically adding the key to its dedicated file under /etc/apt/trusted.d directory. Ubuntu wont complain anymore.
Although this doesnt fix the original concern of cross-signing the packages. The [proper way][3] to fix is to add the key location to the sources list file of the repository. Ill discuss both methods in the next section.
### Solution 1: Adding the GPG keys to the system to keep Ubuntu happy (relatively easier but not proper way)
Unfortunately, there is no easy way around this. Youll have to use the command line and you should figure out correct parameters. There is no run this and you are done thing here.
The idea here is to add the GPG key under its dedicated file in /etc/apt/trusted.gpg.d.
There are couple of scenarios here.
#### You have already added the key in /etc/apt/trusted.gpg file
In this case, list the keys with this command:
```
sudo apt-key list
```
There should be a way to identify the repository. You should have its name or developers name.
In my case, I am handling the Spotify repository:
```
[email protected]:~$ sudo apt-key list
[sudo] password for abhishek:
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
/etc/apt/trusted.gpg
--------------------
pub rsa4096 2021-10-27 [SC] [expires: 2023-01-20]
F9A2 1197 6ED6 62F0 0E59 361E 5E3C 45D7 B312 C643
uid [ unknown] Spotify Public Repository Signing Key <[email protected]>
```
Copy the last 8 characters of the second line under pub. In my case, it is `B312 C643`. Youll have to remove the space between the numbers and use it like this:
```
sudo apt-key export B312C643 | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/spotify.gpg
```
The output file could be named anything but it is better to use a name that is associated with the package or repository.
The `gpg --dearmour` part is important because the mechanism expects you to have the keys in binary format.
#### You havent added the external keys yet
Well, in that case, get the keys and add it to your trsuted.gpg.d directory.
If only it was that simple. The keys can be in several file formats like .asc, .gpg etc. And then those keys can be [armored][4].
An armored GPG file is encrypted but shows random text instead of being in binary format. An armored GPG key starts with:
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
```
But your GPG key should not be armored. It should be in binary format (if you try to read it, it shows gibberish).
```
ay`<60><><EFBFBD><EFBFBD><EFBFBD>?o;<3B><><EFBFBD>Lh<4C><68><EFBFBD><EFBFBD>҇<EFBFBD>^j?<3F>,4<>@8<>Xh<58>]<5D>j<EFBFBD>F<EFBFBD><46>Q<EFBFBD><51>W<EFBFBD>ă|,%C<>n<EFBFBD><6E>nG<6E>t<EFBFBD><74><EFBFBD>׺<EFBFBD><D7BA><EFBFBD>b%/Ka<4B><61><EFBFBD><EFBFBD>i<EFBFBD><69><EFBFBD>
```
This is why it is important to use `sudo gpg --dearmour` while handling the keys. If the added keys are not in the binary format, youll start seeing this message in the output of apt update command:
```
The key(s) in the keyring /etc/apt/trusted.gpg.d/spotify.gpg are ignored as the file has an unsupported filetype.
```
You may also [use the file command][5] to check if the key is armored or not.
```
file repo-key.gpg
```
and if the output is like PGP public key block, it is armored file and needs to be converted to binary.
```
[email protected]:~$ file /etc/apt/trusted.gpg.d/spotify.gpg
/etc/apt/trusted.gpg.d/spotify.gpg: PGP public key block Public-Key (old)
```
So, the steps here involve:
* Downloading the keys and checking if it is armored or not
* If the file is armored, it needs to be dearmored in binary format
* And then the dearmored key is added to its own file under /etc/apt/trusted.gpg.d directory
You may combine all in one single command like this given that you know that it is an armored key.
```
curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/spotify.gpg
```
As I mentioned earlier, this is relatively easier but not the proper way. Whats the proper way? Lets discuss that.
### Solution 2: Adding the GPG keys to the system to the proper way
This is similar to what you have seen in the previous section but it has one more step of adding the keys location to the repositorys sources list file.
* Downloading the keys and checking if it is armored or not
* If the file is armored, it needs to be dearmored in binary format
* And then the dearmored key is added to its own file under /usr/share/keyrings directory
* The location of the key file is added to the sources list file of the repository
In the same example, lets add the key of the Spotify repository in /usr/share/keyrings directory.
```
curl -sS https://download.spotify.com/debian/pubkey_5E3C45D7B312C643.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/spotify.gpg
```
Now, comes the next part. Normally, the content of the sources list file are like this:
```
deb URL_of_the_repo stable non-free
```
You should edit it and add the location of the key file like this:
```
deb [signed-by=/usr/share/keyrings/key-file.gpg] URL_of_the_repo stable non-free
```
This way, you are linking the package to a specific key. Now, this key cannot be used to download any other package. No more cross-signing.
In the Spotify example, I modified the command this way so that the sources list also contains the signed by information.
```
echo "deb [signed-by=/usr/share/keyrings/spotify.gpg] http://repository.spotify.com stable non-free" | sudo tee /etc/apt/sources.list.d/spotify.list
```
### What next?
As you can see, there is no easy-to-use mechanism in place to replace the apt-key command. It requires a lot of manual effort and it should not be like this.
Since it is the transitioning phase, the apt-key is deprecated message is a warning but things could be more strict in future versions of Ubuntu.
For now, even if you ignore this warning, you can continue using the external repository.
In my opinion, the onus lies on the external repository provider. They should be the one providing the correct way of adding their repository.
I see that [Brave browser provides the correct, moder][6][n][7][instructions][8] but many others, like Spotify, dont do it. The change should come from developers side. The user should not be fiddling around the warning and error messages.
Its not one of my best articles as it has too many moving points and it leaves a lot of things for you figure out. I have a feeling that the article may not clear all things. If thats the case, please leave your questions and suggestions in the comment section and Ill try explaining it further.
--------------------------------------------------------------------------------
via: https://itsfoss.com/apt-key-deprecated/
作者:[Abhishek Prakash][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/
[b]: https://github.com/lkxed
[1]: https://itsfoss.com/adding-external-repositories-ubuntu/
[2]: https://itsfoss.com/install-spotify-ubuntu-linux/
[3]: https://wiki.debian.org/DebianRepository/UseThirdParty
[4]: https://www.techopedia.com/definition/23150/ascii-armor
[5]: https://linuxhandbook.com/file-command/
[6]: https://brave.com/linux/
[7]: https://brave.com/linux/
[8]: https://brave.com/linux/

View File

@ -0,0 +1,117 @@
[#]: subject: "How ODT files are structured"
[#]: via: "https://opensource.com/article/22/8/odt-files"
[#]: author: "Jim Hall https://opensource.com/users/jim-hall"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How ODT files are structured
======
Because OpenDocument Format (ODF) are based on open standards, you can use other tools to examine them and even extract data from them. You just need to know where to start.
Word processing files used to be closed, proprietary formats. In some older word processors, the document file was essentially a memory dump from the word processor. While this made for faster loading of the document into the word processor, it also made the document file format an opaque mess.
Around 2005, the Organization for the Advancement of Structured Information Standards (OASIS) group defined an open format for office documents of all types, the Open Document Format for Office Applications (ODF). You may also see ODF referred to as simply "OpenDocument Format" because it is an open standard based on the [OpenOffice.org's][4] XML file specification. ODF includes several file types, including ODT for OpenDocument Text documents. There's a lot to explore in an ODT file, and it starts with a zip file.
### Zip structure
Like all ODF files, ODT is actually an XML document and other files wrapped in a zip file container. Using zip means files take less room on disk, but it also means you can use standard zip tools to examine an ODF file.
I have an article about IT leadership called "Nibbled to death by ducks" that I saved as an ODT file. Since this is an ODF file, which is a zip file container, you can use unzip from the command line to examine it:
```
$ unzip -l 'Nibbled to death by ducks.odt'
Archive: Nibbled to death by ducks.odt
Length Date Time Name
39 07-15-2022 22:18 mimetype
12713 07-15-2022 22:18 Thumbnails/thumbnail.png
915001 07-15-2022 22:18 Pictures/10000201000004500000026DBF6636B0B9352031.png
10879 07-15-2022 22:18 content.xml
20048 07-15-2022 22:18 styles.xml
9576 07-15-2022 22:18 settings.xml
757 07-15-2022 22:18 meta.xml
260 07-15-2022 22:18 manifest.rdf
0 07-15-2022 22:18 Configurations2/accelerator/
0 07-15-2022 22:18 Configurations2/toolpanel/
0 07-15-2022 22:18 Configurations2/statusbar/
0 07-15-2022 22:18 Configurations2/progressbar/
0 07-15-2022 22:18 Configurations2/toolbar/
0 07-15-2022 22:18 Configurations2/popupmenu/
0 07-15-2022 22:18 Configurations2/floater/
0 07-15-2022 22:18 Configurations2/menubar/
1192 07-15-2022 22:18 META-INF/manifest.xml
970465 17 files
```
I want to highlight a few elements of the zip file structure:
1. The `mimetype` file contains a single line that defines the ODF document. Programs that process ODT files, such as a word processor, can use this file to verify the `MIME` type of the document. For an ODT file, this should always be:
```
application/vnd.oasis.opendocument.text
```
1. The `META-INF` directory has a single `manifest.xml` file in it. This file contains all the information about where to find other components of the ODT file. Any program that reads ODT files starts with this file to locate everything else. For example, the `manifest.xml` file for my ODT document contains this line that defines where to find the main content:
```
<manifest:file-entry manifest:full-path="content.xml" manifest:media-type="text/xml"/>
```
1. The `content.xml` file contains the actual content of the document.
2. My document includes a single screenshot, which is contained in the `Pictures` directory.
### Extracting files from an ODT file
Because the ODT document is just a zip file with a specific structure to it, you can extract files from it. You can start by unzipping the entire ODT file, such as with this unzip command:
```
$ unzip -q 'Nibbled to death by ducks.odt' -d Nibbled
```
A colleague recently asked for a copy of the image that I included in my article. I was able to locate the exact location of any embedded image by looking in the `META-INF/manifest.xml` file. The `grep` command can display any lines that describe an image:
```
$ cd Nibbled
$ grep image META-INF/manifest.xml
<manifest:file-entry manifest:full-path="Thumbnails/thumbnail.png" manifest:media-type="image/png"/>
<manifest:file-entry manifest:full-path="Pictures/10000201000004500000026DBF6636B0B9352031.png" manifest:media-type=" image/png/>
```
The image I'm looking for is saved in the `Pictures` folder. You can verify that by listing the contents of the directory:
```
$ ls -F
Configurations2/ manifest.rdf meta.xml Pictures/ styles.xml
content.xml META-INF/ mimetype settings.xml Thumbnails/
```
And here it is:
![Image of rubber ducks in two bowls][5]
Image by: (Jim Hall, CC BY-SA 40)
### OpenDocument Format
OpenDocument Format (ODF) files are an open file format that can describe word processing files (ODT), spreadsheet files (ODS), presentations (ODP), and other file types. Because ODF files are based on open standards, you can use other tools to examine them and even extract data from them. You just need to know where to start. All ODF files start with the `META-INF/manifest.xml` file, which is the "root" or "bootstrap" file for the rest of the ODF file format. Once you know where to look, you can find the rest of the content.
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/8/odt-files
作者:[Jim Hall][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/jim-hall
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/coffee_tea_laptop_computer_work_desk.png
[2]: https://unsplash.com/@jonasleupe?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[3]: https://unsplash.com/s/photos/tea-cup-computer?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText
[4]: http://OpenOffice.org
[5]: https://opensource.com/sites/default/files/2022-07/ducks.png

View File

@ -0,0 +1,220 @@
[#]: subject: "How To Check Disk Space Usage In Linux Using Ncdu"
[#]: via: "https://ostechnix.com/check-disk-space-usage-linux-using-ncdu/"
[#]: author: "sk https://ostechnix.com/author/sk/"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
How To Check Disk Space Usage In Linux Using Ncdu
======
Ncdu - A disk usage analyzer with an ncurses interface.
This guide explains what is **Ncdu**, how to install Ncdu in various Linux distributions and how to **use Ncdu to check disk space usage in Linux and Unix** operating systems with examples.
### What Is Ncdu?
Ncdu, acronym of **NC**urses  **D**isk **U**sage, is a curses-based version of the well-known du command. It provides a fast way to see what directories are using the disk space.
Even though there are plenty of tools and ways to analyze the disk usage in Linux, the developer of Ncdu utility is not satisfied with all of them. So, he developed Ncdu using **C** programming language with an ncurses interface.
Ncdu is simple and fast disk usage analyzer which is used to find which directories or files are taking up more space either on a local or remote systems.
Without further ado, let us go ahead and see how to install Ncdu in Linux and learn commonly used Ncdu commands with examples to check disk usage in Linux and Unix-like operating systems.
### Install Ncdu In Linux
**Ncdu** is available in the default repositories of most Linux distributions. So, you can install it using the distribution's default package manager.
To install Ncdu in Alpine Linux:
```
$ sudo apk add ncdu
```
To install Ncdu in Arch Linux, EndevourOS, Manjaro Linux, run::
```
$ sudo pacman -S ncdu
```
To install Ncdu on Fedora, RHEL, CentOS, AlmaLinux, Rocky Linux:
```
$ sudo dnf install ncdu
```
In older RHEL-based systems, use `yum` instead `dnf` :
```
$ sudo yum install ncdu
```
To install Ncdu on SUSE, openSUSE:
```
$ sudo zypper in ncdu
```
To install Ncdu in Debian, Ubuntu, Linux Mint, Pop OS:
```
$ sudo apt install ncdu
```
### Check Disk Space Usage In Linux Using Ncdu
Once installed, run Ncdu command without any options to analyze the disk space usage of your $HOME directory in your Linux box.
```
$ ncdu
```
This command will analyze your HOME directory. After analyzing, it will show you disk usage report, sorted in descending order. Larger items will be displayed on top.
**Sample output:**
![Check Disk Space Usage With Ncdu][1]
Use UP/DOWN arrows (Or **k** and **j** in the keyboard) to move between items.
Press **"i"** to view the details of the selected item.
![Show Information About Selected Item][2]
Press "i" again to close this window.
To view the items inside the selected directory, press **"Right"** arrow or **ENTER** key. It will display the list of files and directories inside the selected directory.
![View Items Inside A Directory][3]
To go back to the parent directory, press **"Left"** arrow.
#### Display Directory Size
As I stated already, when we run Ncdu without any flags, it will show us the disk space usage of the HOME directory. We can also display size of a particular directory by specifying its actual path like below.
```
$ ncdu Downloads/
```
To analyze entire root (/) file system, run:
```
$ sudo ncdu -x /
```
Here, **-x** indicates that only count files and directories on the same filesystem as the directory being scanned. It will avoid scanning the mounted devices.
#### Run Ncdu In Quiet Mode
By default, ncdu will update the output screen **10 times a second** while scanning the directory. This might consume more bandwidth if you are analyzing the disk usage of a remote system.
Fortunately, this will be decreased to once every 2 seconds in **quiet mode**. We can use this feature to save bandwidth over remote connections.
To run the ncdu in quiet mode, use **-q** flag as shown below.
```
$ ncdu -q
```
#### Save Results In A File
Some times, you might want to save the the scanning report and view it later. In such cases, scan a directory and export the results in any archive format for later viewing like below.
```
$ ncdu -1xo- / | gzip >export.gz
```
This command will scan the HOME directory and save the scanning report in a file called **export.gz**.
**Sample output:**
```
/usr/lib/locale/zh_CN.gbk/LC_MESSAGES/SYS_LC_MESSAGES 188375 files
```
You can view it later by running the following command:
```
$ zcat export.gz | ncdu -f-
```
It is also possible to export to a file and browse it once scanning is done:
```
$ ncdu -o- | tee export.file | ncdu -f-
```
#### Analyze Disk Usage Of Remote Linux Systems
To scan a remote system, but browse through the files locally, run:
```
$ ssh -C ostechnix@192.168.1.60 ncdu -o- / | ncdu -f-
```
Here,
* ostechnix is the user name of my remote system.
* 192.168.1.60 is the remote system's IP address.
* -C switch enables compression.
To quit ncdu, press **q**.
### Ncdu Keybindings
Here is the list of available key options in ncdu utility.
* up, k  - Move cursor up.
* down, j  - Move cursor down.
* Right arrow, ENTER key - Open selected directory.
* Left arrow, <, h  - Open parent directory.
* n - Sort by name (ascending/descending).
* s - Sort by size (ascending/descending).
* C - Sort by items (ascending/descending).
* d - Delete selected file or directory.
* t - Toggle dirs before files when sorting.
* g - Show percentage and/or graph.
* a - Toggle between apparent size and disk usage.
* c - Toggle display of child item counts.
* e - Show/hide hidden or excluded files.
* i - Show information about selected item.
* r - Recalculate the current directory.
* b - Spawn shell in current directory.
* q - Quit ncdu.
For more details, read the man pages.
```
$ man ncdu
```
### Conclusion
Now, you know how to analyze and track the disk space usage in Linux using Ncdu. Ncdu is a quite fast utility to check which directories are occupying most in space in your Linux system.
If you find certain directory or file is consuming more space on your hard drive, you can delete or move them safely to another drive to free up the disk space.
**Resource:**
* [Ncdu website][4]
--------------------------------------------------------------------------------
via: https://ostechnix.com/check-disk-space-usage-linux-using-ncdu/
作者:[sk][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://ostechnix.com/author/sk/
[b]: https://github.com/lkxed
[1]: https://ostechnix.com/wp-content/uploads/2022/08/Check-Disk-Space-Usage-With-Ncdu.png
[2]: https://ostechnix.com/wp-content/uploads/2022/08/Show-Information-About-Selected-Item.png
[3]: https://ostechnix.com/wp-content/uploads/2022/08/View-Items-Inside-A-Directory.png
[4]: https://dev.yorhel.nl/ncdu

View File

@ -0,0 +1,188 @@
[#]: subject: "Try Asciidoc instead of Markdown"
[#]: via: "https://opensource.com/article/22/8/drop-markdown-asciidoc"
[#]: author: "Seth Kenlon https://opensource.com/users/seth"
[#]: collector: "lkxed"
[#]: translator: " "
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
Try Asciidoc instead of Markdown
======
Next time you write, use Asciidoc and Asciidoctor as alternatives to Markdown.
![Person using a laptop][1]
I'm a happy user of the XML-based [Docbook][2] markup language. To me, it's a precise, explicit, and detailed system that allows me to have contextual and domain-specific metadata in what I write. Best of all, though, it can be transformed (that's what XML users call it when XML is converted into another format) into nearly any format, including HTML, EPUB, FO for PDF, plain text, and more. With great power comes a lot of typing, though, and sometimes Docbook feels like it's surplus to requirements. Luckily, there's [Asciidoc][3], a system of writing plain text with the same markup-less feel of Markdown, but that transforms to Docbook to take advantage of its precision and flexibility.
### Asciidoc rules
Like Markdown, one of the goals of Asciidoc is that you don't really have to *learn* it. Instead, it aims to be intuitive and natural. You may well have written snippets of valid Asciidoc without realizing it if you've ever added a little style to a plain text document for readability. For instance, if you habitually separate paragraphs with a blank line, then you've written the equivalent of the HTML `<p>` or Docbook `<para>` tag. It seems obvious, and yet in academia separating paragraphs with blank lines isn't generally done, so even this simple convention is technically markup.
Here's the most common syntax.
#### Text styles
Text styles include the basics such as bold, italics, and code font. Most of the notation is relatively intuitive, with the possible exception of italics.
***Bold***
*_Italics_*
**_Bold and italic_**
``Monospace or code``
#### Code
Code is marked with backticks or by explicit declaration of a code block.
``Monospace or code``
```
[source,python]
----
print('a whole code block')
----
```
#### Headlines
Headings are marked with leading equal signs (`=` ):
= Heading 1 (`<h1>` )
== Heading 2 (`<h2>` )
=== Heading 3 (`<h3>` )
==== Heading 4 (`<h4>` )
===== Heading 5 (`<h5>` )
====== Heading 6 (`<h6>` )
#### Links
Hyperlinks favor the link first, followed by the word or phrase used to "disguise" the link as text.
This is a [http://example.com[hyperlink][4]] that leads to the example.com site.
I don't find this as elegant as Markdown's link notation, but then it's a lot more flexible. For instance, you can add attributes in Asciidoc links:
This is a [https://example.com[link,role=external,window=_blank][5]] with the `target="_blank"` attribute set.
#### Lots more
Asciidoc also features internal links so you can link from one section to another, a standard for document headers, automatic table of content generation, the ability to include other documents within another, and much much more.
But best of all, Asciidoc is actually *standardized*. Not everyone knows it, but the term "Markdown" doesn't refer to one markup-light language. Different organizations and groups regularly customize and alter Markdown for their own use, so when you use Markdown you really ought to verify *which* markdown you're meant to use. Many of the conventions you might have learned from one website using Markdown don't carry over to another site using Markdown. There's essentially no standard for Markdown, and that's resulted in such confusion that the [Commonmark.org][6] project has been formed in an attempt to assemble a standardized definition.
Asciidoc was designed from the start with a standard definition, so the tool or website that claims to parse Asciidoc actually does parse all valid Asciidoc, because there's only one valid Asciidoc.
### Asciidoc to anything
The point of writing in a markup-light language like Asciidoc is to ensure predictability and consistency when text is parsed. You want a person to write a script, or to run an application someone else has written, to be able to transform your plain text into whatever format works best for them. Sometimes that's HTML (incidentally Markdown's native output format, and fallback language when there's something missing from its own syntax.) Other times it's an EPUB, or a PDF for printing, Docbook, a LibreOffice document, or any number of possible output formats.
There are several tools to help you transform Asciidoc to another format. A popular command is [Asciidoctor][7], which you can install using your package manager. For instance, on Fedora, CentOS, or RHEL:
```
$ sudo dnf install asciidoctor
```
On Debian-based systems:
```
$ sudo apt install asciidoctor
```
Alternately, you can install it on any OS with Ruby:
```
$ gem install asciidoctor
```
Here's a simple example of an Asciidoc document, which you can create using any or even a word processor (like ) as long as you save the file as plain text. Most applications expect a plain text document to use the extension `.txt`, and while it's a convention use the extension `.adoc` for Asciidoc, it's not necessary. Asciidoctor doesn't require any special extension.
```
= This is my example document
It's not written in _Markdown_, nor _reStructured Text_.
This is *Asciidoc*.
It can be transformed into nearly any format using the tool `Asciidoctor` and other similar parsers.
Try it for yourself!
```
To transform an Asciidoc document to HTML, run `asciidoctor` :
```
$ asciidoctor example.adoc
```
The file `example.adoc` is transformed into HTML5 by default, but you can use different backends to gain access to more formats.
### From Asciidoc to XML
My favourite is the Docbook backend, because it transforms my Asciidoc to Docbook XML, allowing me to use my existing Docbook toolchain (custom Makefiles, Apache FOP, `xsltproc`, `xmlto`, and so on) to complete my work:
```
$ asciidoctor --backend docbook5 example.adoc
```
This outputs Docbook XML. The final two built-in backends are `xhtml5` and `manpage`.
### From Asciidoc to EPUB
If you want to turn your writing into an ebook, you can install the EPUB3 backend:
```
$ gem install asciidoctor-epub3
```
Transform your Asciidoc into EPUB:
```
$ asciidoctor-epub3 example.adoc
```
### From Asciidoc to PDF
You can transform Asciidoc directly to PDF, too:
```
$ gem install asciidoctor-pdf
$ asciidoctor-pdf example.adoc
```
![Asciidoctor-pdf][8]
Image by:
(Seth Kenlon, CC BY-SA 4.0)
### Who should use Asciidoc
Asciidoc is excellent for technical writers and writers who have precise requirements for how they want text to be organized and parsed. It's a clear and strictly defined markup format that eliminates the confusion of competing Markdown formats, and it transforms to all the major formats. Asciidoc is admittedly more verbose and possibly less intuitive than Markdown, but it's still just plain text so you can author on anything, and Asciidoctor makes processing easy. Next time you write a document for any purpose, consider trying Asciidoc.
--------------------------------------------------------------------------------
via: https://opensource.com/article/22/8/drop-markdown-asciidoc
作者:[Seth Kenlon][a]
选题:[lkxed][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lkxed
[1]: https://opensource.com/sites/default/files/lead-images/laptop_screen_desk_work_chat_text.png
[2]: https://opensource.com/article/17/9/docbook
[3]: http://asciidoc.org
[4]: http://example.com[hyperlink
[5]: https://example.com[link,role=external,window=_blank
[6]: http://commonmark.org
[7]: https://asciidoctor.org
[8]: https://opensource.com/sites/default/files/2022-08/asciidoc-pdf.webp

View File

@ -1,183 +0,0 @@
[#]: subject: "Linux tips for using cron to schedule tasks"
[#]: via: "https://opensource.com/article/21/11/cron-linux"
[#]: author: "Seth Kenlon https://opensource.com/users/seth"
[#]: collector: "lujun9972"
[#]: translator: "Veryzzj"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
使用 cron 定时任务的 Linux 小技巧
======
通过使用这个简单而强大的 Linux 命令行工具,来安排备份、文件清理以及其他任务。下载我们新版 cron 速查表。
![Linux keys on the keyboard for a desktop computer][1]
在计算机上让任务按照有规律并且可预测的时间表运行很重要。作为人类,我们有时会因为分心、脑子里想太多或是度假而记不住要做的事情。计算机真的很擅长按计划做事,但在计算机采取行动之前,人类必须对计算机进行编程。
在某种程度上,`cron`系统是编程的初级简单入门。通过编辑一个文件就可以让计算机做你想让它做的事。你甚至不需要知道文件保存在哪里。只需键入一个简单的命令,输入你希望电脑遵循的 “recipe”并保存。从那时起计算机会在指定时间执行你的指令直到被告知停止。
从设计上来看,`cron`不是一个复杂的系统。这里有一些你需要了解的内容。
### cron 是什么?
Cron 在一个 ”假脱机“系统上工作,像打印机和电子邮件一样。如果不你知道打印机和电子邮件使用假脱机也没关系,因为假脱机文件的意义在于,你不需要想太多。在 Linux 系统中,`/var/spool`目录被设计为重要但低级的文件的中心枢纽,用户不需要直接与之交互。 在`/var/spool`中管理的一个假脱机是 `cron`表或简称“crontab”。 包括你在内的每个用户在 Linux 系统中都有一个 crontab。用户可以编辑、查看和删除自己的 crontab。除此之外用户可以使用 crontab 来安排任务。`cron`系统监控 crontabs并确保一个 crontab 中列出的任何工作都能在其指定时间执行。
### 编辑 cron 设置
你可以使用`crontab`命令和`-e`代表_edit_选项来编辑你的 contab。默认情况下大多数系统会调用`vim`文本编辑器。 如果你和我一样不使用Vim那么你可以在`~/.bashrc`文件中为自己设置一个不同的编辑器。我把我的设置为Emacs但你也可以试试[Nano][4]、[Kate][5],或者任何你喜欢的编辑器。**EDITOR**环境变量定义了你在终端使用的文本编辑器,而**VISUAL**变量定义了你在图形模式下使用的编辑器:
```
export EDITOR=nano
export VISUAL=kate
```
更新设置后刷新你的shell会话
```
`$ source ~/.bashrc`
```
现在你可以用喜欢的编辑器编辑 crontab
```
`$ crontab -e`
```
#### 为任务执行安排时间
`cron`系统本质上是一个日历系统。可以通过五个不同的属性告诉`cron` 需要让一个任务多长时间运行一次分、时、日、月、工作日。这些属性的顺序是固定的并且不一定是直观的你可以把它们看作是过滤器或掩码。默认情况下你可以理解为所有东西都被设置为_always_或者_every_。此命令将在全年的每一天每小时每分钟运行`touch /tmp/hello`
```
`* * * * * touch /tmp/hello`
```
You can restrict this all-encompassing schedule by setting specific definitions for each attribute.可以通过设置每个属性的具体定义来限制这个包罗万象的时间安排表。使任务在每个小时的30分钟标志运行将分钟设置为**30**
```
`30 * * * * touch /tmp/hello`
```
You can further constrain this instruction with a specific hour. This job runs at 3:30 AM every morning: 可以通过一个具体的小时来进一步约束这个指令。使任务在每个凌晨3:30运行
```
`30 3 * * * touch /tmp/hello`
```
你也可以让这个任务只在每个月的第一天运行:
```
`30 3 1 * * touch /tmp/hello`
```
你可以用1至12表示1至12月来设置月份用0至6表示周日至周六来设置日。这项任务在4月份的周一的3:15运行
```
`15 3 * 4 1 touch /tmp/hello`
```
### 设置增量
所有这些设置都与一个固定时间_完全_匹配。使用 `cron` 符号设置在特定时间段后运行任务例如每15分钟运行一个任务
```
`*/15 * * * * touch /tmp/hello`
```
每三天在上午10点运行任务
```
`* 10 */3 * * touch /tmp/hello`
```
每六小时运行一次任务:
```
`* */6 * * * touch /tmp/hello`
```
### Cron 速记
现代的 `cron`实现已经为常见的时间安排表添加了方便的速记,包括:
* `@hourly`
* `@daily`
* `@weekly`
* `@monthly`
* `@yearly or @annually`
### 列表中的 cron 任务
使用`crontab`命令,查看计划中的`cron`任务列表:
```
$ crontab -l
15 3 * 4 1 touch /tmp/hello
```
### 删除一个 crontab
当用完一个crontab后可以使用`-r`选项来删除它:
```
`$ crontab -r -i`
```
`-i`选项代表_交互式_。它在删除文件之前会提示你进行确认。
### Cron 可以做什么
知道如何使用 `cron`是一回事但但知道它的用途是另一回事。经典用例就是备份计划。如果你的电脑一天中大部分时间都是开着的或者整天整夜地开着那么可以为重要分区进行例行备份。我会在每天凌晨3点在主要数据分区上运行一个名为`rdiff-backup`的备份程序:
```
$ crontab -l | grep rdiff
* 3 * * * rdiff-backup /data/ /vault/
```
另一个常见的用途是系统维护。在我的 Slackware 桌面上,每周五下午会更新本地版本库目录:
```
$ crontab -l | grep slack
* 14 * * 5 sudo slackpkg update
```
我还会每三天在15:00运行一个Ansible脚本来 [清理我的下载文件夹][6]
```
$ crontab -l | grep ansible
* 15 */3 * * ansible-playbook /home/seth/Ansible/cleanup.yaml
```
有一些重复数据删除脚本、文件大小和`/tmp`目录监视器、照片调整器、文件移动器以及很多琐碎的任务,你可以安排在后台运行,以帮助保持系统不受干扰。有了 `cron`,计算机就能以我只希望我的公寓能达到的程度进行自我管理。
### 记住 cron 的设置
除了想明白你为什么需要 `cron`之外,根据我的经验, `cron`最难的事情是记住它的语法。重复这句话给自己听,反反复复,直到你记牢它:
_Minutes, hours, date, month, weekday._
_Minutes, hours, date, month, weekday._
_Minutes, hours, date, month, weekday._
更好的做法是,去 [下载我们免费的速查表][7] ,这样当你最需要它时,它触手可及!
--------------------------------------------------------------------------------
via: https://opensource.com/article/21/11/cron-linux
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[Veryzzj](https://github.com/Veryzzj)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux_keyboard_desktop.png?itok=I2nGw78_ "Linux keys on the keyboard for a desktop computer"
[2]: https://opensource.com/article/21/2/linux-automation
[3]: https://opensource.com/article/20/7/systemd-timers
[4]: https://opensource.com/article/20/12/gnu-nano
[5]: https://opensource.com/article/20/12/kate-text-editor
[6]: https://opensource.com/article/21/9/keep-folders-tidy-ansible
[7]: https://opensource.com/downloads/linux-cron-cheat-sheet