Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2019-09-20 11:02:37 +08:00
commit 54bb58e012
4 changed files with 97 additions and 106 deletions

View File

@ -1,8 +1,8 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11362-1.html)
[#]: subject: (Bash Script to Send a Mail About New User Account Creation)
[#]: via: (https://www.2daygeek.com/linux-shell-script-to-monitor-user-creation-send-email/)
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
@ -10,37 +10,27 @@
用 Bash 脚本发送新用户帐户创建的邮件
======
出于某些原因,你可能需要跟踪 Linux 上的新用户创建信息。
![](https://img.linux.net.cn/data/attachment/album/201909/20/093308a615tcuiopctvp5t.jpg)
同时,你可能需要通过邮件发送详细信息。
这或许是审计目标的一部分,或者安全团队出于跟踪目的可能希望对此进行监控。
出于某些原因,你可能需要跟踪 Linux 上的新用户创建信息。同时,你可能需要通过邮件发送详细信息。这或许是审计目标的一部分,或者安全团队出于跟踪目的可能希望对此进行监控。
我们可以通过其他方式进行此操作,正如我们在上一篇文章中已经描述的那样。
* **[在系统中创建新用户帐户时发送邮件的 Bash 脚本][1]**
* [在系统中创建新用户帐户时发送邮件的 Bash 脚本][1]
Linux 有许多开源监控工具可以使用。
但我不认为他们有办法跟踪新用户创建过程,并在发生时提醒管理员。
Linux 有许多开源监控工具可以使用。但我不认为他们有办法跟踪新用户创建过程,并在发生时提醒管理员。
那么我们怎样才能做到这一点?
我们可以编写自己的 Bash 脚本来实现这一目标。
我们过去写过许多有用的 shell 脚本。如果你想了解,请进入下面的链接。
* **[如何使用 shell 脚本自动化日常活动?][2]**
我们可以编写自己的 Bash 脚本来实现这一目标。我们过去写过许多有用的 shell 脚本。如果你想了解,请进入下面的链接。
* [如何使用 shell 脚本自动化日常活动?][2]
### 这个脚本做了什么?
这将每天两次(一天的开始和结束)备份 “/etc/passwd” 文件,这将使你能够获取指定日期的新用户创建详细信息。
这将每天两次(一天的开始和结束)备份 `/etc/passwd` 文件,这将使你能够获取指定日期的新用户创建详细信息。
我们需要添加以下两个 cron 任务来复制 “/etc/passwd” 文件。
我们需要添加以下两个 cron 任务来复制 `/etc/passwd` 文件。
```
# crontab -e
@ -49,7 +39,7 @@ Linux 有许多开源监控工具可以使用。
59 23 * * * cp /etc/passwd /opt/scripts/passwd-end-$(date +"%Y-%m-%d")
```
它使用 “difference” 命令来检测文件之间的差异,如果发现与昨日有任何差异,脚本将向指定 email 发送新用户详细信息。
它使用 `diff` 命令来检测文件之间的差异,如果发现与昨日有任何差异,脚本将向指定 email 发送新用户详细信息。
我们不用经常运行此脚本,因为用户创建不经常发生。但是,我们计划每天运行一次此脚本。
@ -66,21 +56,21 @@ mv /opt/scripts/passwd-end-$(date --date='yesterday' '+%Y-%m-%d') /opt/scripts/p
ucount=$(diff /opt/scripts/passwd-start /opt/scripts/passwd-end | grep ">" | cut -d":" -f6 | cut -d"/" -f3 | wc -l)
if [ $ucount -gt 0 ]
then
SUBJECT="ATTENTION: New User Account is created on server : `date --date='yesterday' '+%b %e'`"
MESSAGE="/tmp/new-user-logs.txt"
TO="[email protected]"
echo "Hostname: `hostname`" >> $MESSAGE
echo -e "\n" >> $MESSAGE
echo "The New User Details are below." >> $MESSAGE
echo "+------------------------------+" >> $MESSAGE
diff /opt/scripts/passwd-start /opt/scripts/passwd-end | grep ">" | cut -d":" -f6 | cut -d"/" -f3 >> $MESSAGE
echo "+------------------------------+" >> $MESSAGE
mail -s "$SUBJECT" "$TO" < $MESSAGE
rm $MESSAGE
fi
SUBJECT="ATTENTION: New User Account is created on server : `date --date='yesterday' '+%b %e'`"
MESSAGE="/tmp/new-user-logs.txt"
TO="2daygeek@gmail.com"
echo "Hostname: `hostname`" >> $MESSAGE
echo -e "\n" >> $MESSAGE
echo "The New User Details are below." >> $MESSAGE
echo "+------------------------------+" >> $MESSAGE
diff /opt/scripts/passwd-start /opt/scripts/passwd-end | grep ">" | cut -d":" -f6 | cut -d"/" -f3 >> $MESSAGE
echo "+------------------------------+" >> $MESSAGE
mail -s "$SUBJECT" "$TO" < $MESSAGE
rm $MESSAGE
fi
```
“new-user-detail.sh” 文件添加可执行权限。
`new-user-detail.sh` 文件添加可执行权限。
```
$ chmod +x /opt/scripts/new-user-detail.sh
@ -116,7 +106,7 @@ via: https://www.2daygeek.com/linux-shell-script-to-monitor-user-creation-send-e
作者:[Magesh Maruthamuthu][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,69 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to put an HTML page on the internet)
[#]: via: (https://jvns.ca/blog/2019/09/06/how-to-put-an-html-page-on-the-internet/)
[#]: author: (Julia Evans https://jvns.ca/)
How to put an HTML page on the internet
======
One thing I love about the internet is that its SO EASY to put static HTML websites on the internet. Someone asked me today how to do it, so I thought Id write down how really quickly!
### just an HTML page
All of my sites are just static HTML and CSS. My web design skills are relatively minimal (<https://wizardzines.com> is the most complicated site Ive developed on my own), so keeping all my internet sites relatively simple means that I have some hope of being able to make changes / fix things without spending a billion hours on it.
So were going to take as minimal of an approach as possible in this blog post just one HTML page.
### the HTML page
The website were going to put on the internet is just one file, called `index.html`. You can find it at <https://github.com/jvns/website-example>, which is a Github repository with exactly one file in it.
The HTML file has some CSS in it to make it look a little less boring, which is partly copied from <https://example.com>.
### how to put the HTML page on the internet
Here are the steps:
1. sign up for a [Neocities][1] account
2. copy the index.html into the index.html in your neocities site
3. done
The index.html page above is on the internet at [julia-example-website.neocities.com][2], if you view source youll see that its the same HTML as in the github repo.
I think this is probably the simplest way to put an HTML page on the internet (and its a throwback to Geocities, which is how I made my first website in 2003) :). I also like that Neocities (like [glitch][3], which I also love) is about experimentation and learning and having fun..
### other options
This is definitely not the only easy way Github pages and Gitlab pages and Netlify will all automatically publish a site when you push to a Git repository, and theyre all very easy to use (just connect them to your github repository and youre done). I personally use the Git repository approach because not having things in Git makes me nervous I like to know what changes to my website Im actually pushing. But I think if you just want to put an HTML site on the internet for the first time and play around with HTML/CSS, Neocities is a really nice way to do it.
If you want to actually use your website for a Real Thing and not just to play around you probably want to buy a domain and link it to your website so that you can change hosting providers in the future, but that is a bit less simple.
### this is a good possible jumping off point for learning HTML
If you are a person who is comfortable editing files in a Git repository but wants to practice HTML/CSS, I think this is a fun way to put a website on the internet and play around! I really like the simplicity of it theres literally just one file, so theres no fancy extra magic to get in the way of understanding whats going on.
There are also a bunch of ways to complicate/extend this, like this blog is actually generated with [Hugo][4] which generates a bunch of HTML files which then go on the internet, but its always nice to start with the basics.
--------------------------------------------------------------------------------
via: https://jvns.ca/blog/2019/09/06/how-to-put-an-html-page-on-the-internet/
作者:[Julia Evans][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://jvns.ca/
[b]: https://github.com/lujun9972
[1]: https://neocities.org/
[2]: https://julia-example-website.neocities.org/
[3]: https://glitch.com
[4]: https://gohugo.io/

View File

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

View File

@ -0,0 +1,70 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to put an HTML page on the internet)
[#]: via: (https://jvns.ca/blog/2019/09/06/how-to-put-an-html-page-on-the-internet/)
[#]: author: (Julia Evans https://jvns.ca/)
如何在互联网放置 HTML 页面
======
我喜欢互联网的一点是在互联网放置静态页面是如此简单。今天有人问我该怎么做,所以我想我会快速地写下来!
### 只是一个 HTML 页面
我的所有网站都只是静态 HTML 和 CSS。我的网页设计技巧相对不高<https://wizardzines.com>是我自己开发的最复杂的网站),因此保持我所有的网站相对简单意味着我可以做一些改变/修复,而不会花费大量时间。
因此,我们将在此文章中采用尽可能简单的方式 - 只需一个 HTML 页面。
### HTML 页面
我们要放在互联网上的网站只是一个名为 `index.html` 的文件。你可以在 <https://github.com/jvns/website-example> 找到它,它是一个 Github 仓库,其中只包含一个文件。
HTML 文件中包含一些 CSS使其看起来不那么无聊部分复制自< https://example.com>
### 如何将 HTML 页面放在互联网上
有以下几步:
1. 注册 [Neocities][1] 帐户
2. 将 index.html 复制到你自己 neocities 站点的 index.html 中
3. 完成
上面的 index.html 页面位于 [julia-example-website.neocities.com][2] 中,如果你查看源代码,你将看到它与 github 仓库中的 HTML 相同。
我认为这可能是将 HTML 页面放在互联网上的最简单的方法(这是一次回归 Geocities它是我在 2003 年制作我的第一个网站的方式):)。我也喜欢 Neocities (像 [glitch][3],我也喜欢)它能实验、学习,并有乐趣。
### 其他选择
这绝不是唯一简单的方式 - 在你推送 Git 仓库时Github pages 和 Gitlab pages 以及 Netlify 都将会自动发布站点,并且它们都非常易于使用(只需将它们连接到你的 github 仓库即可)。我个人使用 Git 仓库的方式,因为 Git 没有东西让我感到紧张 - 我想知道我实际推送的页面发生了什么更改。但我想你如果第一次只想将 HTML/CSS 制作的站点放到互联网上,那么 Neocities 就是一个非常好的方法。
如果你不只是玩,而是要将网站用于真实用途,那么你或许会需要买一个域名,以便你将来可以更改托管服务提供商,但这有点不那么简单。
### 这是学习 HTML 的一个很好的起点
如果你熟悉在 Git 中编辑文件,同时想练习 HTML/CSS 的话,我认为将它放在网站中是一个有趣的方式!我真的很喜欢它的简单性 - 实际上这只有一个文件,所以没有其他花哨的东西需要去理解。
还有很多方法可以复杂化/扩展它,比如这个博客实际上是用 [Hugo][4] 生成的,它生成了一堆 HTML 文件并放在网络中,但从基础开始总是不错的。
--------------------------------------------------------------------------------
via: https://jvns.ca/blog/2019/09/06/how-to-put-an-html-page-on-the-internet/
作者:[Julia Evans][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://jvns.ca/
[b]: https://github.com/lujun9972
[1]: https://neocities.org/
[2]: https://julia-example-website.neocities.org/
[3]: https://glitch.com
[4]: https://gohugo.io/