mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-19 22:51:41 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
ae618da1ca
@ -1,20 +1,22 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11008-1.html)
|
||||
[#]: subject: (Exploring /run on Linux)
|
||||
[#]: via: (https://www.networkworld.com/article/3403023/exploring-run-on-linux.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
Exploring /run on Linux
|
||||
探索 Linux 上的 /run
|
||||
======
|
||||
There's been a small but significant change in how Linux systems work with respect to runtime data.
|
||||
![Sandra Henry-Stocker][1]
|
||||
|
||||
If you haven’t been paying close attention, you might not have noticed a small but significant change in how Linux systems work with respect to runtime data. A re-arrangement of how and where it’s accessible in the file system started taking hold about eight years ago. And while this change might not have been big enough of a splash to wet your socks, it provides some additional consistency in the Linux file system and is worthy of some exploration.
|
||||
> Linux 系统在运行时数据方面的工作方式发生了微小但重大的变化。
|
||||
|
||||
To get started, cd your way over to /run. If you use df to check it out, you’ll see something like this:
|
||||
![](https://img.linux.net.cn/data/attachment/album/201906/23/092816aqczi984w30j8k12.jpg)
|
||||
|
||||
如果你没有密切关注,你可能没有注意到 Linux 系统在运行时数据方面的工作方式有一些小但重大的变化。 它重新组织了文件系统中可访问的方式和位置,而这个变化在大约八年前就开始了。虽然这种变化可能不足以让你的袜子变湿,但它在 Linux 文件系统中提供了更多一致性,值得进行一些探索。
|
||||
|
||||
要开始,请转到 `/run`。如果你使用 `df` 来检查它,你会看到这样的输出:
|
||||
|
||||
```
|
||||
$ df -k .
|
||||
@ -22,18 +24,16 @@ Filesystem 1K-blocks Used Available Use% Mounted on
|
||||
tmpfs 609984 2604 607380 1% /run
|
||||
```
|
||||
|
||||
Identified as a “tmpfs” (temporary file system), we know that the files and directories in /run are not stored on disk but only in volatile memory. They represent data kept in memory (or disk-based swap) that takes on the appearance of a mounted file system to allow it to be more accessible and easier to manage.
|
||||
它被识别为 “tmpfs”(临时文件系统),因此我们知道 `/run` 中的文件和目录没有存储在磁盘上,而只存储在内存中。它们表示保存在内存(或基于磁盘的交换空间)中的数据,它看起来像是一个已挂载的文件系统,这个可以使其更易于访问和管理。
|
||||
|
||||
**[ Two-Minute Linux Tips:[Learn how to master a host of Linux commands in these 2-minute video tutorials][2] ]**
|
||||
|
||||
/run is home to a wide assortment of data. For example, if you take a look at /run/user, you will notice a group of directories with numeric names.
|
||||
`/run` 是各种各样数据的家园。例如,如果你查看 `/run/user`,你会注意到一组带有数字名称的目录。
|
||||
|
||||
```
|
||||
$ ls /run/user
|
||||
1000 1002 121
|
||||
```
|
||||
|
||||
A long file listing will clarify the significance of these numbers.
|
||||
使用长文件列表可以发现这些数字的重要性。
|
||||
|
||||
```
|
||||
$ ls -l
|
||||
@ -43,9 +43,9 @@ drwx------ 5 dory dory 120 Jun 16 16:14 1002
|
||||
drwx------ 8 gdm gdm 220 Jun 14 12:18 121
|
||||
```
|
||||
|
||||
This allows us to see that each directory is related to a user who is currently logged in or to the display manager, gdm. The numbers represent their UIDs. The content of each of these directories are files that are used by running processes.
|
||||
我们看到每个目录与当前登录的用户或显示管理器 gdm 相关。数字代表他们的 UID。每个目录的内容都是运行中的进程所使用的文件。
|
||||
|
||||
The /run/user files represent only a very small portion of what you’ll find in /run. There are lots of other files, as well. A handful contain the process IDs for various system processes.
|
||||
`/run/user` 文件只是你在 `/run` 中找到的一小部分。还有很多其他文件。有一些文件包含了各种系统进程的进程 ID。
|
||||
|
||||
```
|
||||
$ ls *.pid
|
||||
@ -53,7 +53,7 @@ acpid.pid atopacctd.pid crond.pid rsyslogd.pid
|
||||
atd.pid atop.pid gdm3.pid sshd.pid
|
||||
```
|
||||
|
||||
As shown below, that sshd.pid file listed above contains the process ID for the ssh daemon (sshd).
|
||||
如下所示,上面列出的 `sshd.pid` 文件包含 ssh 守护程序(`sshd`)的进程 ID。
|
||||
|
||||
```
|
||||
$ cat sshd.pid
|
||||
@ -67,7 +67,7 @@ dory 18232 18109 0 16:14 ? 00:00:00 sshd: dory@pts/1
|
||||
shs 19276 10923 0 16:50 pts/0 00:00:00 grep --color=auto sshd
|
||||
```
|
||||
|
||||
Some of the subdirectories within /run can only be accessed with root authority such as /run/sudo. Running as root, for example, we can see some files related to real or attempted sudo usage:
|
||||
`/run` 中的某些子目录只能使用 root 权限访问,例如 `/run/sudo`。例如,以 root 身份运行我们可以看到一些与真实或尝试使用 `sudo` 相关的文件:
|
||||
|
||||
```
|
||||
/run/sudo/ts# ls -l
|
||||
@ -76,7 +76,7 @@ total 8
|
||||
-rw------- 1 root shs 168 Jun 17 08:33 shs
|
||||
```
|
||||
|
||||
In keeping with the shift to using /run, some of the old locations for runtime data are now symbolic links. /var/run is now a pointer to /run and /var/lock a pointer to /run/lock, allowing old references to work as expected.
|
||||
为了与 `/run` 的变化保持一致,一些运行时数据的旧位置现在是符号链接。`/var/run` 现在是指向 `/run` 的指针,`/var/lock` 指向 `/run/lock` 的指针,可以保证旧的引用按预期工作。
|
||||
|
||||
```
|
||||
$ ls -l /var
|
||||
@ -98,11 +98,7 @@ drwxrwxrwt 8 root root 4096 Jun 17 00:00 tmp
|
||||
drwxr-xr-x 3 root root 4096 Jan 19 12:14 www
|
||||
```
|
||||
|
||||
While minor as far as technical changes go, the transition to using /run simply allows for a better organization of runtime data in the Linux file system.
|
||||
|
||||
**[ Now read this:[Invaluable tips and tricks for troubleshooting Linux][3] ]**
|
||||
|
||||
Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind.
|
||||
虽然技术上的变化很小,但转换到使用 `/run` 只是为了在 Linux 文件系统中更好地组织运行时数据。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -110,8 +106,8 @@ via: https://www.networkworld.com/article/3403023/exploring-run-on-linux.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,15 +1,17 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (wxy)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11007-1.html)
|
||||
[#]: subject: (Bash Script to Monitor Memory Usage on Linux)
|
||||
[#]: via: (https://www.2daygeek.com/linux-bash-script-to-monitor-memory-utilization-usage-and-send-email/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
在 Linux 上用 Bash 脚本监控内存使用情况
|
||||
用 Bash 脚本监控 Linux 上的内存使用情况
|
||||
======
|
||||
|
||||
![](https://img.linux.net.cn/data/attachment/album/201906/23/085446setqkshf5zk0tn2x.jpg)
|
||||
|
||||
目前市场上有许多开源监控工具可用于监控 Linux 系统的性能。当系统达到指定的阈值限制时,它可以发送电子邮件警报。它可以监视 CPU 利用率、内存利用率、交换利用率、磁盘空间利用率等所有内容。
|
||||
|
||||
如果你只有很少的系统并且想要监视它们,那么编写一个小的 shell 脚本可以使你的任务变得非常简单。
|
||||
@ -20,7 +22,7 @@
|
||||
|
||||
如果只想在系统达到给定阈值时通过邮件获取当前内存利用率百分比,请使用以下脚本。
|
||||
|
||||
这是非常简单直接的单行脚本。在大多数情况下,我更喜欢使用这种方法。
|
||||
这是个非常简单直接的单行脚本。在大多数情况下,我更喜欢使用这种方法。
|
||||
|
||||
当你的系统达到内存利用率的 80% 时,它将触发一封电子邮件。
|
||||
|
||||
@ -28,7 +30,7 @@
|
||||
*/5 * * * * /usr/bin/free | awk '/Mem/{printf("RAM Usage: %.2f%\n"), $3/$2*100}' | awk '{print $3}' | awk '{ if($1 > 80) print $0;}' | mail -s "High Memory Alert" 2daygeek@gmail.com
|
||||
```
|
||||
|
||||
**注意:**你需要更改电子邮件地址而不是我们的电子邮件地址。此外,你可以根据你的要求更改内存利用率阈值。
|
||||
**注意:**你需要更改电子邮件地址而不是使用我们的电子邮件地址。此外,你可以根据你的要求更改内存利用率阈值。
|
||||
|
||||
**输出:**你将收到类似下面的电子邮件提醒。
|
||||
|
||||
@ -42,15 +44,13 @@ High Memory Alert: 80.40%
|
||||
|
||||
### 方法-2:用 Linux Bash 脚本监视内存利用率并发送电子邮件
|
||||
|
||||
如果要在邮件警报中获取有关内存利用率的更多信息。
|
||||
|
||||
使用以下脚本,其中包括基于 `top` 命令和 `ps` 命令的最高内存利用率进程详细信息。
|
||||
如果要在邮件警报中获取有关内存利用率的更多信息。使用以下脚本,其中包括基于 `top` 命令和 `ps` 命令的最高内存利用率和进程详细信息。
|
||||
|
||||
这将立即让你了解系统的运行情况。
|
||||
|
||||
当你的系统达到内存利用率的 “80%” 时,它将触发一封电子邮件。
|
||||
|
||||
**注意:**你需要更改电子邮件地址而不是我们的电子邮件地址。 此外,你可以根据你的要求更改内存利用率阈值。
|
||||
**注意:**你需要更改电子邮件地址而不是使用我们的电子邮件地址。此外,你可以根据你的要求更改内存利用率阈值。
|
||||
|
||||
```
|
||||
# vi /opt/scripts/memory-alert.sh
|
||||
@ -86,9 +86,9 @@ fi
|
||||
*/5 * * * * /bin/bash /opt/scripts/memory-alert.sh
|
||||
```
|
||||
|
||||
**注意:**由于脚本计划每 5 分钟运行一次,因此你将在 5 分钟后收到电子邮件提醒(但不是 5 分钟,而是取决于具体时间)。
|
||||
**注意:**由于脚本计划每 5 分钟运行一次,因此你将在最多 5 分钟后收到电子邮件提醒(但不是 5 分钟,取决于具体时间)。
|
||||
|
||||
比如说。 如果你的系统达到 8.25 的给定限制,那么你将在再过 5 分钟收到电子邮件警报。 希望现在说清楚了。
|
||||
比如说,如果你的系统达到 8.25 的给定限制,那么你将在 5 分钟内收到电子邮件警报。希望现在说清楚了。
|
||||
|
||||
**输出:**你将收到类似下面的电子邮件提醒。
|
||||
|
||||
@ -141,7 +141,7 @@ via: https://www.2daygeek.com/linux-bash-script-to-monitor-memory-utilization-us
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -1,63 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (ninifly )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Edge computing is in most industries’ future)
|
||||
[#]: via: (https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html#tk.rss_all)
|
||||
[#]: author: (Anne Taylor https://www.networkworld.com/author/Anne-Taylor/)
|
||||
|
||||
Edge computing is in most industries’ future
|
||||
======
|
||||
Nearly every industry can take advantage of edge computing in the journey to speed digital transformation efforts
|
||||
![iStock][1]
|
||||
|
||||
The growth of edge computing is about to take a huge leap. Right now, companies are generating about 10% of their data outside a traditional data center or cloud. But within the next six years, that will increase to 75%, [according to Gartner][2].
|
||||
|
||||
That’s largely down to the need to process data emanating from devices, such as Internet of Things (IoT) sensors. Early adopters include:
|
||||
|
||||
* **Manufacturers:** Devices and sensors seem endemic to this industry, so it’s no surprise to see the need to find faster processing methods for the data produced. A recent [_Automation World_][3] survey found that 43% of manufacturers have deployed edge projects. Most popular use cases have included production/manufacturing data analysis and equipment data analytics.
|
||||
|
||||
* **Retailers** : Like most industries deeply affected by the need to digitize operations, retailers are being forced to innovate their customer experiences. To that end, these organizations are “investing aggressively in compute power located closer to the buyer,” [writes Dave Johnson][4], executive vice president of the IT division at Schneider Electric. He cites examples such as augmented-reality mirrors in fitting rooms that offer different clothing options without the consumer having to try on the items, and beacon-based heat maps that show in-store traffic.
|
||||
|
||||
|
||||
|
||||
* **Healthcare organizations** : As healthcare costs continue to escalate, this industry is ripe for innovation that improves productivity and cost efficiencies. Management consulting firm [McKinsey & Co. has identified][5] at least 11 healthcare use cases that benefit patients, the facility, or both. Two examples: tracking mobile medical devices for nursing efficiency as well as optimization of equipment, and wearable devices that track user exercise and offer wellness advice.
|
||||
|
||||
|
||||
|
||||
While these are strong use cases, as the edge computing market grows, so too will the number of industries adopting it.
|
||||
|
||||
**Getting the edge on digital transformation**
|
||||
|
||||
Faster processing at the edge fits perfectly into the objectives and goals of digital transformation — improving efficiencies, productivity, speed to market, and the customer experience. Here are just a few of the potential applications and industries that will be changed by edge computing:
|
||||
|
||||
**Agriculture:** Farmers and organizations already use drones to transmit field and climate conditions to watering equipment. Other applications might include monitoring and location tracking of workers, livestock, and equipment to improve productivity, efficiencies, and costs.
|
||||
|
||||
**Energy** : There are multiple potential applications in this sector that could benefit both consumers and providers. For example, smart meters help homeowners better manage energy use while reducing grid operators’ need for manual meter reading. Similarly, sensors on water pipes would detect leaks, while providing real-time consumption data.
|
||||
|
||||
**Financial services** : Banks are adopting interactive ATMs that quickly process data to provide better customer experiences. At the organizational level, transactional data can be more quickly analyzed for fraudulent activity.
|
||||
|
||||
**Logistics** : As consumers demand faster delivery of goods and services, logistics companies will need to transform mapping and routing capabilities to get real-time data, especially in terms of last-mile planning and tracking. That could involve street-, package-, and car-based sensors transmitting data for processing.
|
||||
|
||||
All industries have the potential for transformation, thanks to edge computing. But it will depend on how they address their computing infrastructure. Discover how to overcome any IT obstacles at [APC.com][6].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html#tk.rss_all
|
||||
|
||||
作者:[Anne Taylor][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.networkworld.com/author/Anne-Taylor/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2019/04/istock-1019389496-100794424-large.jpg
|
||||
[2]: https://www.gartner.com/smarterwithgartner/what-edge-computing-means-for-infrastructure-and-operations-leaders/
|
||||
[3]: https://www.automationworld.com/article/technologies/cloud-computing/its-not-edge-vs-cloud-its-both
|
||||
[4]: https://blog.schneider-electric.com/datacenter/2018/07/10/why-brick-and-mortar-retail-quickly-establishing-leadership-edge-computing/
|
||||
[5]: https://www.mckinsey.com/industries/high-tech/our-insights/new-demand-new-markets-what-edge-computing-means-for-hardware-companies
|
||||
[6]: https://www.apc.com/us/en/solutions/business-solutions/edge-computing.jsp
|
@ -1,141 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How To Check Whether The Given Package Is Installed Or Not On Debian/Ubuntu System?)
|
||||
[#]: via: (https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
How To Check Whether The Given Package Is Installed Or Not On Debian/Ubuntu System?
|
||||
======
|
||||
|
||||
We have recently published an article about bulk package installation.
|
||||
|
||||
While doing that, i was struggled to get the installed package information and did a small google search and found few methods about it.
|
||||
|
||||
I would like to share it in our website so, that it will be helpful for others too.
|
||||
|
||||
There are numerous ways we can achieve this.
|
||||
|
||||
I have add seven ways to achieve this. However, you can choose the preferred method for you.
|
||||
|
||||
Those methods are listed below.
|
||||
|
||||
* **`apt-cache Command:`** apt-cache command is used to query the APT cache or package metadata.
|
||||
* **`apt Command:`** APT is a powerful command-line tool for installing, downloading, removing, searching and managing packages on Debian based systems.
|
||||
* **`dpkg-query Command:`** dpkg-query is a tool to query the dpkg database.
|
||||
* **`dpkg Command:`** dpkg is a package manager for Debian based systems.
|
||||
* **`which Command:`** The which command returns the full path of the executable that would have been executed when the command had been entered in terminal.
|
||||
* **`whereis Command:`** The whereis command used to search the binary, source, and man page files for a given command.
|
||||
* **`locate Command:`** locate command works faster than the find command because it uses updatedb database, whereas the find command searches in the real system.
|
||||
|
||||
|
||||
|
||||
### Method-1 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using apt-cache Command?
|
||||
|
||||
apt-cache command is used to query the APT cache or package metadata from APT’s internal database.
|
||||
|
||||
It will search and display an information about the given package. It shows whether the package is installed or not, installed package version, source repository information.
|
||||
|
||||
The below output clearly showing that `nano` package has already installed in the system. Since installed part is showing the installed version of nano package.
|
||||
|
||||
```
|
||||
# apt-cache policy nano
|
||||
nano:
|
||||
Installed: 2.9.3-2
|
||||
Candidate: 2.9.3-2
|
||||
Version table:
|
||||
*** 2.9.3-2 500
|
||||
500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
|
||||
100 /var/lib/dpkg/status
|
||||
```
|
||||
|
||||
### Method-2 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using apt Command?
|
||||
|
||||
APT is a powerful command-line tool for installing, downloading, removing, searching and managing as well as querying information about packages as a low-level access to all features of the libapt-pkg library. It’s contains some less used command-line utilities related to package management.
|
||||
|
||||
```
|
||||
# apt -qq list nano
|
||||
nano/bionic,now 2.9.3-2 amd64 [installed]
|
||||
```
|
||||
|
||||
### Method-3 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using dpkg-query Command?
|
||||
|
||||
dpkg-query is a tool to show information about packages listed in the dpkg database.
|
||||
|
||||
In the below output first column showing `ii`. It means, the given package has already installed in the system.
|
||||
|
||||
```
|
||||
# dpkg-query --list | grep -i nano
|
||||
ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico
|
||||
```
|
||||
|
||||
### Method-4 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using dpkg Command?
|
||||
|
||||
DPKG stands for Debian Package is a tool to install, build, remove and manage Debian packages, but unlike other package management systems, it cannot automatically download and install packages or their dependencies.
|
||||
|
||||
In the below output first column showing `ii`. It means, the given package has already installed in the system.
|
||||
|
||||
```
|
||||
# dpkg -l | grep -i nano
|
||||
ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico
|
||||
```
|
||||
|
||||
### Method-5 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using which Command?
|
||||
|
||||
The which command returns the full path of the executable that would have been executed when the command had been entered in terminal.
|
||||
|
||||
It’s very useful when you want to create a desktop shortcut or symbolic link for executable files.
|
||||
|
||||
Which command searches the directories listed in the current user’s PATH environment variable not for all the users. I mean, when you are logged in your own account and you can’t able to search for root user file or directory.
|
||||
|
||||
If the following output shows the given package binary or executable file location then the given package has already installed in the system. If not, the package is not installed in system.
|
||||
|
||||
```
|
||||
# which nano
|
||||
/bin/nano
|
||||
```
|
||||
|
||||
### Method-6 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using whereis Command?
|
||||
|
||||
The whereis command used to search the binary, source, and man page files for a given command.
|
||||
|
||||
If the following output shows the given package binary or executable file location then the given package has already installed in the system. If not, the package is not installed in system.
|
||||
|
||||
```
|
||||
# whereis nano
|
||||
nano: /bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz /usr/share/info/nano.info.gz
|
||||
```
|
||||
|
||||
### Method-7 : How To Check Whether The Given Package Is Installed Or Not On Ubuntu System Using locate Command?
|
||||
|
||||
locate command works faster than the find command because it uses updatedb database, whereas the find command searches in the real system.
|
||||
|
||||
It uses a database rather than hunting individual directory paths to get a given file.
|
||||
|
||||
locate command doesn’t pre-installed in most of the distributions so, use your distribution package manager to install it.
|
||||
|
||||
The database is updated regularly through cron. Even, we can update it manually.
|
||||
|
||||
If the following output shows the given package binary or executable file location then the given package has already installed in the system. If not, the package is not installed in system.
|
||||
|
||||
```
|
||||
# locate --basename '\nano'
|
||||
/usr/bin/nano
|
||||
/usr/share/nano
|
||||
/usr/share/doc/nano
|
||||
```
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.2daygeek.com/author/magesh/
|
||||
[b]: https://github.com/lujun9972
|
@ -1,171 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Modrisco)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to send email from the Linux command line)
|
||||
[#]: via: (https://www.networkworld.com/article/3402027/how-to-send-email-from-the-linux-command-line.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
How to send email from the Linux command line
|
||||
======
|
||||
Linux offers several commands that allow you to send email from the command line. Here's look at some that offer interesting options.
|
||||
![Molnia/iStock][1]
|
||||
|
||||
There are several ways to send email from the Linux command line. Some are very simple and others more complicated, but offer some very useful features. The choice depends on what you want to do -– whether you want to get a quick message off to a co-worker or send a more complicated message with an attachment to a large group of people. Here's a look at some of the options:
|
||||
|
||||
### mail
|
||||
|
||||
The easiest way to send a simple message from the Linux command line is to use the **mail** command. Maybe you need to remind your boss that you're leaving a little early that day. You could use a command like this one:
|
||||
|
||||
```
|
||||
$ echo "Reminder: Leaving at 4 PM today" | mail -s "early departure" myboss
|
||||
```
|
||||
|
||||
**[ Two-Minute Linux Tips:[Learn how to master a host of Linux commands in these 2-minute video tutorials][2] ]**
|
||||
|
||||
Another option is to grab your message text from a file that contains the content you want to send:
|
||||
|
||||
```
|
||||
$ mail -s "Reminder:Leaving early" myboss < reason4leaving
|
||||
```
|
||||
|
||||
In both cases, the -s options allows you to provide a subject line for your message.
|
||||
|
||||
### sendmail
|
||||
|
||||
Using **sendmail** , you can send a quick message (with no subject) using a command like this (replacing "recip" with your intended recipient:
|
||||
|
||||
```
|
||||
$ echo "leaving now" | sendmail recip
|
||||
```
|
||||
|
||||
You can send just a subject line (with no message content) with a command like this:
|
||||
|
||||
```
|
||||
$ echo "Subject: leaving now" | sendmail recip
|
||||
```
|
||||
|
||||
You can also use sendmail on the command line to send a message complete with a subject line. However, when using this approach, you would add your subject line to the file you intend to send as in this example file:
|
||||
|
||||
```
|
||||
Subject: Requested lyrics
|
||||
I would just like to say that, in my opinion, longer hair and other flamboyant
|
||||
affectations of appearance are nothing more ...
|
||||
```
|
||||
|
||||
Then you would send the file like this (where the lyrics file contains your subject line and text):
|
||||
|
||||
```
|
||||
$ sendmail recip < lyrics
|
||||
```
|
||||
|
||||
Sendmail can be quite verbose in its output. If you're desperately curious and want to see the interchange between the sending and receiving systems, add the -v (verbose) option:
|
||||
|
||||
```
|
||||
$ sendmail -v recip@emailsite.com < lyrics
|
||||
```
|
||||
|
||||
### mutt
|
||||
|
||||
An especially nice tool for command line emailing is the **mutt** command, though you will likely have to install it first. Mutt has a convenient advantage in that it can allow you to include attachments.
|
||||
|
||||
To use mutt to send a quick messsage:
|
||||
|
||||
```
|
||||
$ echo "Please check last night's backups" | mutt -s "backup check" recip
|
||||
```
|
||||
|
||||
To get content from a file:
|
||||
|
||||
```
|
||||
$ mutt -s "Agenda" recip < agenda
|
||||
```
|
||||
|
||||
To add an attachment with mutt, use the -a option. You can even add more than one – as shown in this command:
|
||||
|
||||
```
|
||||
$ mutt -s "Agenda" recip -a agenda -a speakers < msg
|
||||
```
|
||||
|
||||
In the command above, the "msg" file includes content for the email. If you don't have any additional content to provide, you can do this instead:
|
||||
|
||||
```
|
||||
$ echo "" | mutt -s "Agenda" recip -a agenda -a speakers
|
||||
```
|
||||
|
||||
The other useful option that you have with mutt is that it provides a way to send carbon copies (using the -c option) and blind carbon copies (using the -b option).
|
||||
|
||||
```
|
||||
$ mutt -s "Minutes from last meeting" recip@somesite.com -c myboss < mins
|
||||
```
|
||||
|
||||
### telnet
|
||||
|
||||
If you want to get deep into the details of sending email, you can use **telnet** to carry on the email exchange operation, but you'll need to, as they say, "learn the lingo." Mail servers expect a sequence of commands that include things like introducing yourself ( **EHLO** command), providing the email sender ( **MAIL FROM** command), specifying the email recipient ( **RCPT TO** command), and then adding the message ( **DATA** ) and ending the message with a "." as the only character on the line. Not every email server will respond to these requests. This approach is generally used only for troubleshooting.
|
||||
|
||||
```
|
||||
$ telnet emailsite.org 25
|
||||
Trying 192.168.0.12...
|
||||
Connected to emailsite.
|
||||
Escape character is '^]'.
|
||||
220 localhost ESMTP Sendmail 8.15.2/8.15.2/Debian-12; Wed, 12 Jun 2019 16:32:13 -0400; (No UCE/UBE) logging access from: mysite(OK)-mysite [192.168.0.12]
|
||||
EHLO mysite.org <== introduce yourself
|
||||
250-localhost Hello mysite [127.0.0.1], pleased to meet you
|
||||
250-ENHANCEDSTATUSCODES
|
||||
250-PIPELINING
|
||||
250-EXPN
|
||||
250-VERB
|
||||
250-8BITMIME
|
||||
250-SIZE
|
||||
250-DSN
|
||||
250-ETRN
|
||||
250-AUTH DIGEST-MD5 CRAM-MD5
|
||||
250-DELIVERBY
|
||||
250 HELP
|
||||
MAIL FROM: me@mysite.org <== specify sender
|
||||
250 2.1.0 shs@mysite.org... Sender ok
|
||||
RCPT TO: recip <== specify recipient
|
||||
250 2.1.5 recip... Recipient ok
|
||||
DATA <== start message
|
||||
354 Enter mail, end with "." on a line by itself
|
||||
This is a test message. Please deliver it for me.
|
||||
. <== end message
|
||||
250 2.0.0 x5CKWDds029287 Message accepted for delivery
|
||||
quit <== end exchange
|
||||
```
|
||||
|
||||
### Sending email to multiple recipients
|
||||
|
||||
If you want to send email from the Linux command line to a large group of recipients, you can always use a loop to make the job easier as in this example using mutt.
|
||||
|
||||
```
|
||||
$ for recip in `cat recips`
|
||||
do
|
||||
mutt -s "Minutes from May meeting" $recip < May_minutes
|
||||
done
|
||||
```
|
||||
|
||||
### Wrap-up
|
||||
|
||||
There are quite a few ways to send email from the Linux command line. Some tools provide quite a few options.
|
||||
|
||||
Join the Network World communities on [Facebook][3] and [LinkedIn][4] to comment on topics that are top of mind.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3402027/how-to-send-email-from-the-linux-command-line.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/Modrisco)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2017/08/email_image_blue-100732096-large.jpg
|
||||
[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua
|
||||
[3]: https://www.facebook.com/NetworkWorld/
|
||||
[4]: https://www.linkedin.com/company/network-world
|
@ -0,0 +1,64 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (ninifly )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Edge computing is in most industries’ future)
|
||||
[#]: via: (https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html#tk.rss_all)
|
||||
[#]: author: (Anne Taylor https://www.networkworld.com/author/Anne-Taylor/)
|
||||
|
||||
边缘计算是大多数行业的未来
|
||||
======
|
||||
几乎每个行业都能够在加速数字化转型的进程中利用边缘计算的优势。
|
||||
![iStock][1]
|
||||
|
||||
边缘计算的发展将取得一次巨大的飞跃。现在,公司在传统数据中心或云之外生成了10%的数据。但在未来六年内,这一比例将升至75%。
|
||||
[according to Gartner][2].
|
||||
|
||||
这很大程度上取决于处理来自设备数据的需要,比如物联网数据传感器。
|
||||
早起采用这一方法的人包括:
|
||||
|
||||
* **制造商:** 设备与传感器在这个行业似乎是特有的,因此需要为生产数据找到更快速的方法也就不足为奇。最近 [_Automation World_][3]研究发现43%的制造商已经部署了边缘计算。最流行的事例包括了生产数据分析与设备数据分析。
|
||||
|
||||
* **零售商** : 与大多数深受数字化运营需求影响的产业一样,零售商被迫革新其客户体验。为了达到那一目的,这些组织“正在积极投资靠近买家的计算能力”[writes Dave Johns on][4], 施耐德电气公司IT部门执行副总裁说。他列举了一些例子,例如在试衣间的增强现实镜,给提供了不同的服装选择,而不用顾客试用这些服装。又如用于显示店内交通的基于信标的热图。
|
||||
|
||||
|
||||
|
||||
* **医疗保健机构** : 随着医疗成本的不断上升,这一行业已经在具备在提高生产能力与成本效率方面的创新能力。管理咨询公司已经确定,[McKinsey & Co. has identified][5] 至少有11个有益于患者、医疗机构或者两者都有的医疗保健用例。举两个例子:跟踪移动医疗设备提高护理效率,同时也有助于优化设备;可穿戴设备跟踪用户锻炼并提供健康的建议。
|
||||
|
||||
|
||||
|
||||
虽然以上这些是明显的用例,随着边缘计算市场的扩大,使用它的行业也会增加。
|
||||
|
||||
**数字化转型的优势**
|
||||
|
||||
随着边缘计算的快速处理能力完全符合数字化转型的提高效率、生产能力和市场发展速度和客户体验。以下是一些有潜力的应用及将被边缘计算改变的行业:
|
||||
|
||||
**农业** :农名和组织已经使用无人机将农田和气候环境传给灌溉设备。其他的应用可能包括了工人、牲畜和设备的监测与位置跟踪从而改善生产能力、效率和成本。
|
||||
**能源** : 在这一领域有许多的潜在的应用,可以使消费者与供应商都受益。例如,智能电表有助于业主更好地管理能源使用,同时减少电网运营商对手动抄表的需求。 同样的,水管上的传感器能够监测到泄露,同时提供实时漏水数据。
|
||||
|
||||
**金融服务** : 银行正在采取交互式ATM机,这种交互式ATM机能够快速地处理数据以提供更好的用户体验。在管理层次,可以更快速地分析交易数据中的欺诈行为。
|
||||
|
||||
**物流** : 由于消费者需要更快速地提供商品和服务,物流公司将需要转换映射和路由功能以获取实时数据,尤其在最后一公里计划和轨迹方面。这可能涉及到街道、数据包及汽车基于传感器的数据传输过程。
|
||||
|
||||
得益于边缘计算,所有行业都有转型的潜力。但是,这将取决于他们如何处理计算机基础设施。在APC.com发现如何克服任何IT阻碍。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3391016/edge-computing-is-in-most-industries-future.html#tk.rss_all
|
||||
|
||||
作者:[Anne Taylor][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.networkworld.com/author/Anne-Taylor/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2019/04/istock-1019389496-100794424-large.jpg
|
||||
[2]: https://www.gartner.com/smarterwithgartner/what-edge-computing-means-for-infrastructure-and-operations-leaders/
|
||||
[3]: https://www.automationworld.com/article/technologies/cloud-computing/its-not-edge-vs-cloud-its-both
|
||||
[4]: https://blog.schneider-electric.com/datacenter/2018/07/10/why-brick-and-mortar-retail-quickly-establishing-leadership-edge-computing/
|
||||
[5]: https://www.mckinsey.com/industries/high-tech/our-insights/new-demand-new-markets-what-edge-computing-means-for-hardware-companies
|
||||
[6]: https://www.apc.com/us/en/solutions/business-solutions/edge-computing.jsp
|
@ -0,0 +1,137 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (yizhuoyan)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (如何在Debian/Ubuntu系统中检查程序包是否安装?)
|
||||
[#]: via: (https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
|
||||
如何在Debian/Ubuntu系统中检查程序包是否安装?
|
||||
======
|
||||
|
||||
我们近期发布了一篇关于批量程序包安装的文章。在此同时,关于如何获取系统上已安装了的程序包信息,我也做了些调查然后找到了些方法。我会把这些方法分享在我们的网站上,希望能帮助到其他人。
|
||||
|
||||
有很多种方法可以检查程序包是否已安装,我找到了7种命令,您可以从中选择您喜欢的使用。
|
||||
|
||||
如下:
|
||||
|
||||
* **`apt-cache :`** 可用于查询APT缓存或程序包的元数据。
|
||||
* **`apt :`** 在基于Debian的系统中是安装,下载,删除,搜索和管理包的强有力的工具。
|
||||
* **`dpkg-query :`** 一个查询dpkg数据库的工具。
|
||||
* **`dpkg :`** Debian系统的包管理工具
|
||||
* **`which :`** 返回在终端中输入命令时执行的可执行文件的全路径
|
||||
* **`whereis :`** 可用于搜索指定命令的二进制文件,源码文件和帮助文件。
|
||||
* **`locate :`** locate命令比find命令快,因为其使用updatedb数据库搜索,而find命令在实际系统中搜索。
|
||||
|
||||
|
||||
|
||||
## 方法一、使用`apt-cache `命令
|
||||
|
||||
`apt-cache `命令用于从APT的内部数据库中查询**APT缓存**和**包元数据**,将会搜索和显示指定包的信息,包括是否安装,程序包版本,源码仓库信息等。
|
||||
|
||||
下面的示例清楚的显示`nano`包已经在系统中安装了以及对应安装的版本号。
|
||||
|
||||
```
|
||||
# apt-cache policy nano
|
||||
nano:
|
||||
Installed: 2.9.3-2
|
||||
Candidate: 2.9.3-2
|
||||
Version table:
|
||||
*** 2.9.3-2 500
|
||||
500 http://in.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
|
||||
100 /var/lib/dpkg/status
|
||||
```
|
||||
|
||||
### 方法二、使用`apt`命令
|
||||
|
||||
|
||||
|
||||
`apt`是一个功能强大的命令行工具,可用于安装,下载,删除,搜索,管理程序包以及查询关于程序包的信息,类似对于`libapt-pkg`库的所有功能的底层访问。其包含一些与包管理相关的但很少用到的命令行功能。
|
||||
|
||||
```
|
||||
# apt -qq list nano
|
||||
nano/bionic,now 2.9.3-2 amd64 [installed]
|
||||
```
|
||||
|
||||
### 方法三、使用`dpkg-query`命令
|
||||
|
||||
`dpkg-query` 是显示`dpkg`数据库中程序包信息列表的一个工具。
|
||||
|
||||
下面示例中的输出的第一列`ii`,表示查询的程序包已安装了。
|
||||
|
||||
```
|
||||
# dpkg-query --list | grep -i nano
|
||||
ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico
|
||||
```
|
||||
|
||||
### 方法四、使用`dpkg`命令
|
||||
|
||||
`dpkg`(**d**ebian **p**ac**k**a**g**e)是一个安装,构建,删除和管理Debian包的工具,但和其他包管理系统不同的是,其不能自动下载和安装包或包依赖。
|
||||
|
||||
下面示例中的输出的第一列`ii`,表示查询的包已安装了。
|
||||
|
||||
```
|
||||
# dpkg -l | grep -i nano
|
||||
ii nano 2.9.3-2 amd64 small, friendly text editor inspired by Pico
|
||||
```
|
||||
|
||||
### 方法五、使用`which`命令
|
||||
|
||||
|
||||
|
||||
`which`命令返回在终端中输入命令时执行的可执行文件的全路径。这对于你想要给可执行文件创建桌面快捷方式或符号链接时非常有用。
|
||||
|
||||
`which`命令仅在当前用户`PATH`环境变量配置的目录列表中搜索,而不是在所有用户的目录中搜索。意思是当你登入你自己账号时 ,其不会在`root`用户文件或目录中搜索。
|
||||
|
||||
如果对于指定的程序包或可执行文件路径有如下输出,则表示已安装了,否则没有。
|
||||
|
||||
```
|
||||
# which nano
|
||||
/bin/nano
|
||||
```
|
||||
|
||||
### 方法六、使用`whereis`命令
|
||||
|
||||
`whereis`命令用于针对指定命令搜索对应的程序二进制文件,源码文件以及帮助文件等。
|
||||
|
||||
如果对于指定的程序包或可执行文件路径有如下输出,则表示已安装了,否则没有。
|
||||
|
||||
```
|
||||
# whereis nano
|
||||
nano: /bin/nano /usr/share/nano /usr/share/man/man1/nano.1.gz /usr/share/info/nano.info.gz
|
||||
```
|
||||
|
||||
### 方法七、使用`locate`命令
|
||||
|
||||
`locate`命令比`find`命令快,因为其在**updatedb**数据库中搜索,而find命令在实际系统中进行搜索。
|
||||
|
||||
对于获取指定文件,其使用数据库而不是在特定目录路径中搜索。
|
||||
|
||||
`locate`命令不会预安装在大多数系统中,需要手动安装。
|
||||
|
||||
`locate`使用的数据库会根据定时任务定期更新。当然,我们也可以手动更新。
|
||||
|
||||
如果对于指定的程序包或可执行文件路径有如下输出,则表示已安装了,否则没有。
|
||||
|
||||
```
|
||||
# locate --basename '\nano'
|
||||
/usr/bin/nano
|
||||
/usr/share/nano
|
||||
/usr/share/doc/nano
|
||||
```
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.2daygeek.com/how-to-check-whether-the-given-package-is-installed-or-not-on-ubuntu-debian-system/
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[yizhuoyan][translator]
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.2daygeek.com/author/magesh/
|
||||
[b]: https://github.com/lujun9972
|
||||
[translator]:https://github.com/yizhuoyan
|
@ -0,0 +1,168 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (Modrisco)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to send email from the Linux command line)
|
||||
[#]: via: (https://www.networkworld.com/article/3402027/how-to-send-email-from-the-linux-command-line.html)
|
||||
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
|
||||
|
||||
如何用 Linux 命令行发电子邮件
|
||||
======
|
||||
Linux 提供了几种命令允许您通过终端发送电子邮件,下面来展示一些有趣的方法。
|
||||
|
||||
![Molnia/iStock][1]
|
||||
|
||||
Linux 可以用多种方式通过命令行发送电子邮件。有一些方法十分简单,有一些相对会复杂一些,不过仍旧提供了很多有用的特性。选择哪一种方式取决于你想要什么 —— 向同事快速发送消息,还是向一批人群发带有附件的更复杂的信息。接下来看一看几种可行方案:
|
||||
|
||||
### mail
|
||||
|
||||
发送一条简单消息最便捷的 Linux 命令是 `mail`。假设你需要提醒老板你今天得早点走,你可以使用这样的一条命令:
|
||||
|
||||
```
|
||||
$ echo "Reminder: Leaving at 4 PM today" | mail -s "early departure" myboss
|
||||
```
|
||||
|
||||
另一种方式是从一个文件中提取出你想要发送的文本信息:
|
||||
|
||||
```
|
||||
$ mail -s "Reminder:Leaving early" myboss < reason4leaving
|
||||
```
|
||||
|
||||
在以上两种情况中,你都可以通过 -s 来为邮件添加标题。
|
||||
|
||||
### sendmail
|
||||
|
||||
使用 `sendmail` 命令可以发送一封不包含标题的快信。(用目标收件人替换 `recip`):
|
||||
|
||||
```
|
||||
$ echo "leaving now" | sendmail recip
|
||||
```
|
||||
|
||||
你可以用这条命令发送一条只有标题,没有内容的信息:
|
||||
|
||||
```
|
||||
$ echo "Subject: leaving now" | sendmail recip
|
||||
```
|
||||
|
||||
你也可以用 `sendmail` 发送一条包含一条标题行的完整信息。不过使用这个方法时,你的标题行会被添加到要发送的文件中,如下例所示:
|
||||
|
||||
```
|
||||
Subject: Requested lyrics
|
||||
I would just like to say that, in my opinion, longer hair and other flamboyant
|
||||
affectations of appearance are nothing more ...
|
||||
```
|
||||
|
||||
你也可以发送这样的文件(lyric 文件包含标题和正文):
|
||||
|
||||
```
|
||||
$ sendmail recip < lyrics
|
||||
```
|
||||
|
||||
`sendmain` 的输出可能会很冗长。如果你感到好奇并希望查看发送系统和接收系统之间的交互,请添加 `-v` (verbose)选项。
|
||||
|
||||
```
|
||||
$ sendmail -v recip@emailsite.com < lyrics
|
||||
```
|
||||
|
||||
### mutt
|
||||
|
||||
`mutt` 是通过命令行发送邮件的一个很好的工具,在使用前你需要安装它。 `mutt` 的一个很方便的优势就是它允许你在邮件中添加附件。
|
||||
|
||||
使用 `mutt` 发送一条快速信息:
|
||||
|
||||
```
|
||||
$ echo "Please check last night's backups" | mutt -s "backup check" recip
|
||||
```
|
||||
|
||||
从文件中获取内容:
|
||||
|
||||
```
|
||||
$ mutt -s "Agenda" recip < agenda
|
||||
```
|
||||
|
||||
使用 `-a` 选项在 `mutt` 中添加附件。你甚至可以添加不止一个附件 —— 如下一条命令所示:
|
||||
|
||||
```
|
||||
$ mutt -s "Agenda" recip -a agenda -a speakers < msg
|
||||
```
|
||||
|
||||
在以上的命令中,`msg` 文件包含了邮件中的正文。如果你没有其他补充的内容,你可以这样来代替之前的命令:
|
||||
|
||||
```
|
||||
$ echo "" | mutt -s "Agenda" recip -a agenda -a speakers
|
||||
```
|
||||
|
||||
`mutt` 另一个有用的功能是可以添加抄送(`-c`)和密送(`-b`)。
|
||||
|
||||
```
|
||||
$ mutt -s "Minutes from last meeting" recip@somesite.com -c myboss < mins
|
||||
```
|
||||
|
||||
### telnet
|
||||
|
||||
如果你想深入了解发送电子邮件的细节,你可以使用 `telnet` 来进行电子邮件交互操作。但正如所说的那样,你需要“学习术语”。邮件服务器期望一系列命令,其中包括自我介绍(`EHLO` 命令)、提供发件人(`MAIL FROM` 命令)、指定收件人(`RCPT TO` 命令),然后添加消息(`DATA`)并以 `.` 结束消息。并不是所有的电子邮件服务器都会响应这些请求。此方法通常仅用于故障排除。
|
||||
|
||||
```
|
||||
$ telnet emailsite.org 25
|
||||
Trying 192.168.0.12...
|
||||
Connected to emailsite.
|
||||
Escape character is '^]'.
|
||||
220 localhost ESMTP Sendmail 8.15.2/8.15.2/Debian-12; Wed, 12 Jun 2019 16:32:13 -0400; (No UCE/UBE) logging access from: mysite(OK)-mysite [192.168.0.12]
|
||||
EHLO mysite.org <== introduce yourself
|
||||
250-localhost Hello mysite [127.0.0.1], pleased to meet you
|
||||
250-ENHANCEDSTATUSCODES
|
||||
250-PIPELINING
|
||||
250-EXPN
|
||||
250-VERB
|
||||
250-8BITMIME
|
||||
250-SIZE
|
||||
250-DSN
|
||||
250-ETRN
|
||||
250-AUTH DIGEST-MD5 CRAM-MD5
|
||||
250-DELIVERBY
|
||||
250 HELP
|
||||
MAIL FROM: me@mysite.org <== specify sender
|
||||
250 2.1.0 shs@mysite.org... Sender ok
|
||||
RCPT TO: recip <== specify recipient
|
||||
250 2.1.5 recip... Recipient ok
|
||||
DATA <== start message
|
||||
354 Enter mail, end with "." on a line by itself
|
||||
This is a test message. Please deliver it for me.
|
||||
. <== end message
|
||||
250 2.0.0 x5CKWDds029287 Message accepted for delivery
|
||||
quit <== end exchange
|
||||
```
|
||||
|
||||
### 向多个收件人发送电子邮件
|
||||
|
||||
如果你希望通过 Linux 命令行向一大组收件人发送电子邮件,你可以使用一个循环来帮助你完成任务,如下面应用在 `mutt` 中的例子:
|
||||
|
||||
```
|
||||
$ for recip in `cat recips`
|
||||
do
|
||||
mutt -s "Minutes from May meeting" $recip < May_minutes
|
||||
done
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
有很多方法可以从 Linux 命令行发送电子邮件。有些工具提供了相当多的选项。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.networkworld.com/article/3402027/how-to-send-email-from-the-linux-command-line.html
|
||||
|
||||
作者:[Sandra Henry-Stocker][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[Modrisco](https://github.com/Modrisco)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://images.idgesg.net/images/article/2017/08/email_image_blue-100732096-large.jpg
|
||||
[2]: https://www.youtube.com/playlist?list=PL7D2RMSmRO9J8OTpjFECi8DJiTQdd4hua
|
||||
[3]: https://www.facebook.com/NetworkWorld/
|
||||
[4]: https://www.linkedin.com/company/network-world
|
Loading…
Reference in New Issue
Block a user