Merge pull request #1 from LCTT/master

更新至2015年8月2日
This commit is contained in:
struggling 2015-08-02 16:12:40 +08:00
commit 7485819c2d
65 changed files with 749 additions and 745 deletions

View File

@ -0,0 +1,183 @@
如何分析 Linux 日志
==============================================================================
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Linux-Copy@2x1.png)
日志中有大量的信息需要你处理,尽管有时候想要提取并非想象中的容易。在这篇文章中我们会介绍一些你现在就能做的基本日志分析例子(只需要搜索即可)。我们还将涉及一些更高级的分析,但这些需要你前期努力做出适当的设置,后期就能节省很多时间。对数据进行高级分析的例子包括生成汇总计数、对有效值进行过滤,等等。
我们首先会向你展示如何在命令行中使用多个不同的工具,然后展示了一个日志管理工具如何能自动完成大部分繁重工作从而使得日志分析变得简单。
### 用 Grep 搜索 ###
搜索文本是查找信息最基本的方式。搜索文本最常用的工具是 [grep][1]。这个命令行工具在大部分 Linux 发行版中都有,它允许你用正则表达式搜索日志。正则表达式是一种用特殊的语言写的、能识别匹配文本的模式。最简单的模式就是用引号把你想要查找的字符串括起来。
#### 正则表达式 ####
这是一个在 Ubuntu 系统的认证日志中查找 “user hoover” 的例子:
$ grep "user hoover" /var/log/auth.log
Accepted password for hoover from 10.0.2.2 port 4792 ssh2
pam_unix(sshd:session): session opened for user hoover by (uid=0)
pam_unix(sshd:session): session closed for user hoover
构建精确的正则表达式可能很难。例如,如果我们想要搜索一个类似端口 “4792” 的数字它可能也会匹配时间戳、URL 以及其它不需要的数据。Ubuntu 中下面的例子,它匹配了一个我们不想要的 Apache 日志。
$ grep "4792" /var/log/auth.log
Accepted password for hoover from 10.0.2.2 port 4792 ssh2
74.91.21.46 - - [31/Mar/2015:19:44:32 +0000] "GET /scripts/samples/search?q=4972 HTTP/1.0" 404 545 "-" "-”
#### 环绕搜索 ####
另一个有用的小技巧是你可以用 grep 做环绕搜索。这会向你展示一个匹配前面或后面几行是什么。它能帮助你调试导致错误或问题的东西。`B` 选项展示前面几行,`A` 选项展示后面几行。举个例子,我们知道当一个人以管理员员身份登录失败时,同时他们的 IP 也没有反向解析,也就意味着他们可能没有有效的域名。这非常可疑!
$ grep -B 3 -A 2 'Invalid user' /var/log/auth.log
Apr 28 17:06:20 ip-172-31-11-241 sshd[12545]: reverse mapping checking getaddrinfo for 216-19-2-8.commspeed.net [216.19.2.8] failed - POSSIBLE BREAK-IN ATTEMPT!
Apr 28 17:06:20 ip-172-31-11-241 sshd[12545]: Received disconnect from 216.19.2.8: 11: Bye Bye [preauth]
Apr 28 17:06:20 ip-172-31-11-241 sshd[12547]: Invalid user admin from 216.19.2.8
Apr 28 17:06:20 ip-172-31-11-241 sshd[12547]: input_userauth_request: invalid user admin [preauth]
Apr 28 17:06:20 ip-172-31-11-241 sshd[12547]: Received disconnect from 216.19.2.8: 11: Bye Bye [preauth]
#### Tail ####
你也可以把 grep 和 [tail][2] 结合使用来获取一个文件的最后几行,或者跟踪日志并实时打印。这在你做交互式更改的时候非常有用,例如启动服务器或者测试代码更改。
$ tail -f /var/log/auth.log | grep 'Invalid user'
Apr 30 19:49:48 ip-172-31-11-241 sshd[6512]: Invalid user ubnt from 219.140.64.136
Apr 30 19:49:49 ip-172-31-11-241 sshd[6514]: Invalid user admin from 219.140.64.136
关于 grep 和正则表达式的详细介绍并不在本指南的范围,但 [Ryans Tutorials][3] 有更深入的介绍。
日志管理系统有更高的性能和更强大的搜索能力。它们通常会索引数据并进行并行查询,因此你可以很快的在几秒内就能搜索 GB 或 TB 的日志。相比之下grep 就需要几分钟,在极端情况下可能甚至几小时。日志管理系统也使用类似 [Lucene][4] 的查询语言,它提供更简单的语法来检索数字、域以及其它。
### 用 Cut、 AWK、 和 Grok 解析 ###
#### 命令行工具 ####
Linux 提供了多个命令行工具用于文本解析和分析。当你想要快速解析少量数据时非常有用,但处理大量数据时可能需要很长时间。
#### Cut ####
[cut][5] 命令允许你从有分隔符的日志解析字段。分隔符是指能分开字段或键值对的等号或逗号等。
假设我们想从下面的日志中解析出用户:
pam_unix(su:auth): authentication failure; logname=hoover uid=1000 euid=0 tty=/dev/pts/0 ruser=hoover rhost= user=root
我们可以像下面这样用 cut 命令获取用等号分割后的第八个字段的文本。这是一个 Ubuntu 系统上的例子:
$ grep "authentication failure" /var/log/auth.log | cut -d '=' -f 8
root
hoover
root
nagios
nagios
#### AWK ####
另外,你也可以使用 [awk][6],它能提供更强大的解析字段功能。它提供了一个脚本语言,你可以过滤出几乎任何不相干的东西。
例如,假设在 Ubuntu 系统中我们有下面的一行日志,我们想要提取登录失败的用户名称:
Mar 24 08:28:18 ip-172-31-11-241 sshd[32701]: input_userauth_request: invalid user guest [preauth]
你可以像下面这样使用 awk 命令。首先,用一个正则表达式 /sshd.*invalid user/ 来匹配 sshd invalid user 行。然后用 { print $9 } 根据默认的分隔符空格打印第九个字段。这样就输出了用户名。
$ awk '/sshd.*invalid user/ { print $9 }' /var/log/auth.log
guest
admin
info
test
ubnt
你可以在 [Awk 用户指南][7] 中阅读更多关于如何使用正则表达式和输出字段的信息。
#### 日志管理系统 ####
日志管理系统使得解析变得更加简单,使用户能快速的分析很多的日志文件。他们能自动解析标准的日志格式,比如常见的 Linux 日志和 Web 服务器日志。这能节省很多时间,因为当处理系统问题的时候你不需要考虑自己写解析逻辑。
下面是一个 sshd 日志消息的例子,解析出了每个 remoteHost 和 user。这是 Loggly 中的一张截图,它是一个基于云的日志管理服务。
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.25.09-AM.png)
你也可以对非标准格式自定义解析。一个常用的工具是 [Grok][8],它用一个常见正则表达式库,可以解析原始文本为结构化 JSON。下面是一个 Grok 在 Logstash 中解析内核日志文件的事例配置:
filter{
grok {
match => {"message" => "%{CISCOTIMESTAMP:timestamp} %{HOST:host} %{WORD:program}%{NOTSPACE} %{NOTSPACE}%{NUMBER:duration}%{NOTSPACE} %{GREEDYDATA:kernel_logs}"
}
}
下图是 Grok 解析后输出的结果:
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.30.37-AM.png)
### 用 Rsyslog 和 AWK 过滤 ###
过滤使得你能检索一个特定的字段值而不是进行全文检索。这使你的日志分析更加准确,因为它会忽略来自其它部分日志信息不需要的匹配。为了对一个字段值进行搜索,你首先需要解析日志或者至少有对事件结构进行检索的方式。
#### 如何对应用进行过滤 ####
通常,你可能只想看一个应用的日志。如果你的应用把记录都保存到一个文件中就会很容易。如果你需要在一个聚集或集中式日志中过滤一个应用就会比较复杂。下面有几种方法来实现:
1. 用 rsyslog 守护进程解析和过滤日志。下面的例子将 sshd 应用的日志写入一个名为 sshd-message 的文件,然后丢弃事件以便它不会在其它地方重复出现。你可以将它添加到你的 rsyslog.conf 文件中测试这个例子。
:programname, isequal, “sshd” /var/log/sshd-messages
&~
2. 用类似 awk 的命令行工具提取特定字段的值,例如 sshd 用户名。下面是 Ubuntu 系统中的一个例子。
$ awk '/sshd.*invalid user/ { print $9 }' /var/log/auth.log
guest
admin
info
test
ubnt
3. 用日志管理系统自动解析日志,然后在需要的应用名称上点击过滤。下面是在 Loggly 日志管理服务中提取 syslog 域的截图。我们对应用名称 “sshd” 进行过滤,如维恩图图标所示。
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.05.02-AM.png)
#### 如何过滤错误 ####
一个人最希望看到日志中的错误。不幸的是,默认的 syslog 配置不直接输出错误的严重性,也就使得难以过滤它们。
这里有两个解决该问题的方法。首先,你可以修改你的 rsyslog 配置,在日志文件中输出错误的严重性,使得便于查看和检索。在你的 rsyslog 配置中你可以用 pri-text 添加一个 [模板][9],像下面这样:
"<%pri-text%> : %timegenerated%,%HOSTNAME%,%syslogtag%,%msg%n"
这个例子会按照下面的格式输出。你可以看到该信息中指示错误的 err。
<authpriv.err> : Mar 11 18:18:00,hoover-VirtualBox,su[5026]:, pam_authenticate: Authentication failure
你可以用 awk 或者 grep 检索错误信息。在 Ubuntu 中,对这个例子,我们可以用一些语法特征,例如 . 和 >,它们只会匹配这个域。
$ grep '.err>' /var/log/auth.log
<authpriv.err> : Mar 11 18:18:00,hoover-VirtualBox,su[5026]:, pam_authenticate: Authentication failure
你的第二个选择是使用日志管理系统。好的日志管理系统能自动解析 syslog 消息并抽取错误域。它们也允许你用简单的点击过滤日志消息中的特定错误。
下面是 Loggly 中一个截图,显示了高亮错误严重性的 syslog 域,表示我们正在过滤错误:
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.00.36-AM.png)
--------------------------------------------------------------------------------
via: http://www.loggly.com/ultimate-guide/logging/analyzing-linux-logs/
作者:[Jason Skowronski][a],[Amy Echeverri][b],[ Sadequl Hussain][c]
译者:[ictlyh](https://github.com/ictlyh)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linkedin.com/in/jasonskowronski
[b]:https://www.linkedin.com/in/amyecheverri
[c]:https://www.linkedin.com/pub/sadequl-hussain/14/711/1a7
[1]:http://linux.die.net/man/1/grep
[2]:http://linux.die.net/man/1/tail
[3]:http://ryanstutorials.net/linuxtutorial/grep.php
[4]:https://lucene.apache.org/core/2_9_4/queryparsersyntax.html
[5]:http://linux.die.net/man/1/cut
[6]:http://linux.die.net/man/1/awk
[7]:http://www.delorie.com/gnu/docs/gawk/gawk_26.html#IDX155
[8]:http://logstash.net/docs/1.4.2/filters/grok
[9]:http://www.rsyslog.com/doc/v8-stable/configuration/templates.html

View File

@ -1,18 +1,18 @@
Ubuntu 15.04上配置OpenVPN服务器-客户端
在 Ubuntu 15.04 上配置 OpenVPN 服务器和客户端
================================================================================
虚拟专用网VPN是几种用于建立与其它网络连接的网络技术中常见的一个名称。它被称为虚拟网,因为各个节点的连接不是通过物理线路实现的。而由于没有网络所有者的正确授权是不能通过公共线路访问到网络,所以它是专用的
虚拟专用网VPN常指几种通过其它网络建立连接技术。它之所以被称为“虚拟”,是因为各个节点间的连接不是通过物理线路实现的,而“专用”是指如果没有网络所有者的正确授权是不能被公开访问到
![](http://blog.linoxide.com/wp-content/uploads/2015/05/vpn_custom_illustration.jpg)
[OpenVPN][1]软件通过TUN/TAP驱动的帮助使用TCP和UDP协议来传输数据。UDP协议和TUN驱动允许NAT后的用户建立到OpenVPN服务器的连接。此外OpenVPN允许指定自定义端口。它提额外提供了灵活配置,可以帮助你避免防火墙限制。
[OpenVPN][1]软件借助TUN/TAP驱动使用TCP和UDP协议来传输数据。UDP协议和TUN驱动允许NAT后的用户建立到OpenVPN服务器的连接。此外OpenVPN允许指定自定义端口。它提供了更多的灵活配置,可以帮助你避免防火墙限制。
OpenVPN中由OpenSSL库和传输层安全协议TLS提供了安全和加密。TLS是SSL协议的一个改进版本。
OpenSSL提供了两种加密方法对称和非对称。下面我们展示了如何配置OpenVPN的服务器端以及如何预备使用带有公共密钥非对称加密和TLS协议基础结构PKI
OpenSSL提供了两种加密方法对称和非对称。下面我们展示了如何配置OpenVPN的服务器端以及如何配置使用带有公共密钥基础结构PKI的非对称加密和TLS协议
### 服务器端配置 ###
首先我们必须安装OpenVPN。在Ubuntu 15.04和其它带有apt管理器的Unix系统中可以通过如下命令安装
首先我们必须安装OpenVPN软件。在Ubuntu 15.04和其它带有apt管理器的Unix系统中可以通过如下命令安装
sudo apt-get install openvpn
@ -20,7 +20,7 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
sudo apt-get unstall easy-rsa
**注意** 所有接下来的命令要以超级用户权限执行,如在“sudo -i”命令后此外你可以使用“sudo -E”作为接下来所有命令的前缀。
**注意** 所有接下来的命令要以超级用户权限执行,如在使用`sudo -i`命令后执行,或者你可以使用`sudo -E`作为接下来所有命令的前缀。
开始之前我们需要拷贝“easy-rsa”到openvpn文件夹。
@ -32,15 +32,15 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
cd /etc/openvpn/easy-rsa/2.0
这里,我们开启了一个密钥生成进程。
这里,我们开密钥生成进程。
首先我们编辑一个“var”文件。为了简化生成过程我们需要在里面指定数据。这里是“var”文件的一个样例
首先我们编辑一个“vars”文件。为了简化生成过程我们需要在里面指定数据。这里是“vars”文件的一个样例:
export KEY_COUNTRY="US"
export KEY_PROVINCE="CA"
export KEY_CITY="SanFrancisco"
export KEY_ORG="Fort-Funston"
export KEY_EMAIL="my@myhost.mydomain"
export KEY_COUNTRY="CN"
export KEY_PROVINCE="BJ"
export KEY_CITY="Beijing"
export KEY_ORG="Linux.CN"
export KEY_EMAIL="open@vpn.linux.cn"
export KEY_OU=server
希望这些字段名称对你而言已经很清楚,不需要进一步说明了。
@ -61,7 +61,7 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
./build-ca
在对话中我们可以看到默认的变量这些变量是我们先前在“vars”中指定的。我们可以检查下,如有必要进行编辑,然后按回车几次。对话如下
在对话中我们可以看到默认的变量这些变量是我们先前在“vars”中指定的。我们可以检查下,如有必要进行编辑,然后按回车几次。对话如下
Generating a 2048 bit RSA private key
.............................................+++
@ -75,14 +75,14 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [US]:
State or Province Name (full name) [CA]:
Locality Name (eg, city) [SanFrancisco]:
Organization Name (eg, company) [Fort-Funston]:
Organizational Unit Name (eg, section) [MyOrganizationalUnit]:
Common Name (eg, your name or your server's hostname) [Fort-Funston CA]:
Country Name (2 letter code) [CN]:
State or Province Name (full name) [BJ]:
Locality Name (eg, city) [Beijing]:
Organization Name (eg, company) [Linux.CN]:
Organizational Unit Name (eg, section) [Tech]:
Common Name (eg, your name or your server's hostname) [Linux.CN CA]:
Name [EasyRSA]:
Email Address [me@myhost.mydomain]:
Email Address [open@vpn.linux.cn]:
接下来,我们需要生成一个服务器密钥
@ -102,14 +102,14 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [US]:
State or Province Name (full name) [CA]:
Locality Name (eg, city) [SanFrancisco]:
Organization Name (eg, company) [Fort-Funston]:
Organizational Unit Name (eg, section) [MyOrganizationalUnit]:
Common Name (eg, your name or your server's hostname) [server]:
Country Name (2 letter code) [CN]:
State or Province Name (full name) [BJ]:
Locality Name (eg, city) [Beijing]:
Organization Name (eg, company) [Linux.CN]:
Organizational Unit Name (eg, section) [Tech]:
Common Name (eg, your name or your server's hostname) [Linux.CN server]:
Name [EasyRSA]:
Email Address [me@myhost.mydomain]:
Email Address [open@vpn.linux.cn]:
Please enter the following 'extra' attributes
to be sent with your certificate request
@ -119,14 +119,14 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName :PRINTABLE:'US'
stateOrProvinceName :PRINTABLE:'CA'
localityName :PRINTABLE:'SanFrancisco'
organizationName :PRINTABLE:'Fort-Funston'
organizationalUnitName:PRINTABLE:'MyOrganizationalUnit'
commonName :PRINTABLE:'server'
countryName :PRINTABLE:'CN'
stateOrProvinceName :PRINTABLE:'BJ'
localityName :PRINTABLE:'Beijing'
organizationName :PRINTABLE:'Linux.CN'
organizationalUnitName:PRINTABLE:'Tech'
commonName :PRINTABLE:'Linux.CN server'
name :PRINTABLE:'EasyRSA'
emailAddress :IA5STRING:'me@myhost.mydomain'
emailAddress :IA5STRING:'open@vpn.linux.cn'
Certificate is to be certified until May 22 19:00:25 2025 GMT (3650 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
@ -143,7 +143,7 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
Generating DH parameters, 2048 bit long safe prime, generator 2
This is going to take a long time
................................+................<and many many dots>
................................+................<许多的点>
在漫长的等待之后我们可以继续生成最后的密钥了该密钥用于TLS验证。命令如下
@ -176,7 +176,7 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
### Unix的客户端配置 ###
假定我们有一台装有类Unix操作系统的设备比如Ubuntu 15.04并安装有OpenVPN。我们想要从先前的部分连接到OpenVPN服务器。首先我们需要为客户端生成密钥。为了生成该密钥请转到服务器上的目录中
假定我们有一台装有类Unix操作系统的设备比如Ubuntu 15.04并安装有OpenVPN。我们想要连接到前面建立的OpenVPN服务器。首先我们需要为客户端生成密钥。为了生成该密钥请转到服务器上的对应目录中:
cd /etc/openvpn/easy-rsa/2.0
@ -211,7 +211,7 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
dev tun
proto udp
# IP and Port of remote host with OpenVPN server
# 远程 OpenVPN 服务器的 IP 和 端口号
remote 111.222.333.444 1194
resolv-retry infinite
@ -243,7 +243,7 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
安卓设备上的OpenVPN配置和Unix系统上的十分类似我们需要一个含有配置文件、密钥和证书的包。文件列表如下
- configuration file (.ovpn),
- 配置文件 (扩展名 .ovpn),
- ca.crt,
- dh2048.pem,
- client.crt,
@ -257,7 +257,7 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
dev tun
proto udp
# IP and Port of remote host with OpenVPN server
# 远程 OpenVPN 服务器的 IP 和 端口号
remote 111.222.333.444 1194
resolv-retry infinite
@ -274,21 +274,21 @@ OpenSSL提供了两种加密方法对称和非对称。下面我们展示
所有这些文件我们必须移动我们设备的SD卡上。
然后,我们需要安装[OpenVPN连接][2]
然后,我们需要安装一个[OpenVPN Connect][2] 应用
接下来,配置过程很是简单:
open setting of OpenVPN and select Import options
select Import Profile from SD card option
in opened window go to folder with prepared files and select .ovpn file
application offered us to create a new profile
tap on the Connect button and wait a second
- 打开 OpenVPN 并选择“Import”选项
- 选择“Import Profile from SD card”
- 在打开的窗口中导航到我们放置好文件的目录,并选择那个 .ovpn 文件
- 应用会要求我们创建一个新的配置文件
- 点击“Connect”按钮并稍等一下
搞定。现在我们的安卓设备已经通过安全的VPN连接连接到我们的专用网。
### 尾声 ###
虽然OpenVPN初始配置花费不少时间但是简易客户端配置为我们弥补了时间上的损失也提供了从任何设备连接的能力。此外OpenVPN提供了一个很高的安全等级以及从不同地方连接的能力包括位于NAT后面的客户端。因此OpenVPN可以同时在家和企业中使用。
虽然OpenVPN初始配置花费不少时间但是简易客户端配置为我们弥补了时间上的损失也提供了从任何设备连接的能力。此外OpenVPN提供了一个很高的安全等级以及从不同地方连接的能力包括位于NAT后面的客户端。因此OpenVPN可以同时在家和企业中使用。
--------------------------------------------------------------------------------
@ -296,7 +296,7 @@ via: http://linoxide.com/ubuntu-how-to/configure-openvpn-server-client-ubuntu-15
作者:[Ivan Zabrovskiy][a]
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,101 @@
FreeBSD 和 Linux 有什么不同?
================================================================================
![](https://1102047360.rsc.cdn77.org/wp-content/uploads/2015/03/FreeBSD-790x494.jpg)
### 简介 ###
BSD最初从UNIX继承而来目前有许多的类Unix操作系统是基于BSD的。FreeBSD是使用最广泛的开源的伯克利软件发行版即 BSD 发行版。就像它隐含的意思一样它是一个自由开源的类Unix操作系统并且是公共服务器平台。FreeBSD源代码通常以宽松的BSD许可证发布。它与Linux有很多相似的地方但我们得承认它们在很多方面仍有不同。
本文的其余部分组织如下FreeBSD的描述在第一部分FreeBSD和Linux的相似点在第二部分它们的区别将在第三部分讨论对他们功能的讨论和总结在最后一节。
### FreeBSD描述 ###
#### 历史 ####
- FreeBSD的第一个版本发布于1993年它的第一张CD-ROM是FreeBSD1.0发行于1993年12月。接下来FreeBSD 2.1.0在1995年发布并且获得了所有用户的青睐。实际上许多IT公司都使用FreeBSD并且很满意我们可以列出其中的一些IBM、Nokia、NetApp和Juniper Network。
#### 许可证 ####
- 关于它的许可证FreeBSD以多种开源许可证进行发布它的名为Kernel的最新代码以两句版BSD许可证进行了发布给予使用和重新发布FreeBSD的绝对自由。其它的代码则以三句版或四句版BSD许可证进行发布有些是以GPL和CDDL的许可证发布的。
LCTT 译注BSD 许可证与 GPL 许可证相比相当简短最初只有四句规则1999年应 RMS 请求,删除了第三句,新的许可证称作“新 BSD”或三句版BSD原来的 BSD 许可证称作“旧 BSD”、“修订的 BSD”或四句版BSD也有一种删除了第三、第四两句的版本称之为两句版 BSD等价于 MIT 许可证。)
#### 用户 ####
- FreeBSD的重要特点之一就是它的用户多样性。实际上FreeBSD可以作为邮件服务器、Web 服务器、FTP 服务器以及路由器等您只需要在它上运行服务相关的软件即可。而且FreeBSD还支持ARM、PowerPC、MIPS、x86、x86-64架构。
### FreeBSD和Linux的相似处 ###
FreeBSD和Linux是两个自由开源的软件。实际上它们的用户可以很容易的检查并修改源代码用户拥有绝对的自由。而且FreeBSD和Linux都是类Unix系统它们的内核、内部组件、库程序都使用从历史上的AT&T Unix继承来的算法。FreeBSD从根基上更像Unix系统而Linux是作为自由的类Unix系统发布的。许多工具应用都可以在FreeBSD和Linux中找到实际上他们几乎有同样的功能。
此外FreeBSD能够运行大量的Linux应用。它可以安装一个Linux的兼容层这个兼容层可以在编译FreeBSD时加入AAC Compact Linux得到或通过下载已编译了Linux兼容层的FreeBSD系统其中会包括兼容程序aac_linux.ko。不同于FreeBSD的是Linux无法运行FreeBSD的软件。
最后,我们注意到虽然二者有同样的目标,但二者还是有一些不同之处,我们在下一节中列出。
### FreeBSD和Linux的区别 ###
目前对于大多数用户来说并没有一个选择FreeBSD还是Linux的明确的准则。因为他们有着很多同样的应用程序因为他们都被称作类Unix系统。
在这一章,我们将列出这两种系统的一些重要的不同之处。
#### 许可证 ####
- 两个系统的区别首先在于它们的许可证。Linux以GPL许可证发行它为用户提供阅读、发行和修改源代码的自由GPL许可证帮助用户避免仅仅发行二进制。而FreeBSD以BSD许可证发布BSD许可证比GPL更宽容因为其衍生著作不需要仍以该许可证发布。这意味着任何用户能够使用、发布、修改代码并且不需要维持之前的许可证。
- 您可以依据您的需求在两种许可证中选择一种。首先是BSD许可证由于其特殊的条款它更受用户青睐。实际上这个许可证使用户在保证源代码的封闭性的同时可以售卖以该许可证发布的软件。再说说GPL它需要每个使用以该许可证发布的软件的用户多加注意。
- 如果想在以不同许可证发布的两种软件中做出选择,您需要了解他们各自的许可证,以及他们开发中的方法论,从而能了解他们特性的区别,来选择更适合自己需求的。
#### 控制 ####
- 由于FreeBSD和Linux是以不同的许可证发布的Linus Torvalds控制着Linux的内核而FreeBSD却与Linux不同它并未被控制。我个人更倾向于使用FreeBSD而不是Linux这是因为FreeBSD才是绝对自由的软件没有任何控制许可证的存在。Linux和FreeBSD还有其他的不同之处我建议您先不急着做出选择等读完本文后再做出您的选择。
#### 操作系统 ####
- Linux主要指内核系统这与FreeBSD不同FreeBSD的整个系统都被维护着。FreeBSD的内核和一组由FreeBSD团队开发的软件被作为一个整体进行维护。实际上FreeBSD开发人员能够远程且高效的管理核心操作系统。
- 而Linux方面在管理系统方面有一些困难。由于不同的组件由不同的源维护Linux开发者需要将它们汇集起来才能达到同样的功能。
- FreeBSD和Linux都给了用户大量的可选软件和发行版但他们管理的方式不同。FreeBSD是统一的管理方式而Linux需要被分别维护。
#### 硬件支持 ####
- 说到硬件支持Linux比FreeBSD做的更好。但这不意味着FreeBSD没有像Linux那样支持硬件的能力。他们只是在管理的方式不同这通常还依赖于您的需求。因此如果您在寻找最新的解决方案FreeBSD更适应您但如果您在寻找更多的普适性那最好使用Linux。
#### 原生FreeBSD Vs 原生Linux ####
- 两者的原生系统的区别又有不同。就像我之前说的Linux是一个Unix的替代系统由Linux Torvalds编写并由网络上的许多极客一起协助实现的。Linux有一个现代系统所需要的全部功能诸如虚拟内存、共享库、动态加载、优秀的内存管理等。它以GPL许可证发布。
- FreeBSD也继承了Unix的许多重要的特性。FreeBSD作为在加州大学开发的BSD的一种发行版。开发BSD的最重要的原因是用一个开源的系统来替代AT&T操作系统从而给用户无需AT&T许可证便可使用的能力。
- 许可证的问题是开发者们最关心的问题。他们试图提供一个最大化克隆Unix的开源系统。这影响了用户的选择由于FreeBSD使用BSD许可证进行发布因而相比Linux更加自由。
#### 支持的软件包 ####
- 从用户的角度来看另一个二者不同的地方便是软件包以及从源码安装的软件的可用性和支持。Linux只提供了预编译的二进制包这与FreeBSD不同它不但提供预编译的包而且还提供从源码编译和安装的构建系统。使用它的 ports 工具FreeBSD给了您选择使用预编译的软件包默认和在编译时定制您软件的能力。LCTT 译注此处说明有误。Linux 也提供了源代码方式的包,并支持自己构建。)
- 这些 ports 允许您构建所有支持FreeBSD的软件。而且它们的管理还是层次化的您可以在/usr/ports下找到源文件的地址以及一些正确使用FreeBSD的文档。
- 这些提到的 ports给予你产生不同软件包版本的可能性。FreeBSD给了您通过源代码构建以及预编译的两种软件而不是像Linux一样只有预编译的软件包。您可以使用两种安装方式管理您的系统。
#### FreeBSD 和 Linux 常用工具比较 ####
- 有大量的常用工具在FreeBSD上可用并且有趣的是他们由FreeBSD的团队所拥有。相反的Linux工具来自GNU这就是为什么在使用中有一些限制。LCTT 译注:这也是 Linux 正式的名称被称作“GNU/Linux”的原因因为本质上 Linux 其实只是指内核。)
- 实际上FreeBSD采用的BSD许可证非常有益且有用。因此您有能力维护核心操作系统控制这些应用程序的开发。有一些工具类似于它们的祖先 - BSD和Unix的工具但不同于GNU的套件GNU套件只想做到最小的向后兼容。
#### 标准 Shell ####
- FreeBSD默认使用tcsh。它是csh的评估版由于FreeBSD以BSD许可证发行因此不建议您在其中使用GNU的组件 bash shell。bash和tcsh的区别仅仅在于tcsh的脚本功能。实际上我们更推荐在FreeBSD中使用sh shell因为它更加可靠可以避免一些使用tcsh和csh时出现的脚本问题。
#### 一个更加层次化的文件系统 ####
- 像之前提到的一样使用FreeBSD时基础操作系统以及可选组件可以被很容易的区别开来。这导致了一些管理它们的标准。在Linux下/bin/sbin/usr/bin或者/usr/sbin都是存放可执行文件的目录。FreeBSD不同它有一些附加的对其进行组织的规范。基础操作系统被放在/usr/local/bin或者/usr/local/sbin目录下。这种方法可以帮助管理和区分基础操作系统和可选组件。
### 结论 ###
FreeBSD和Linux都是自由且开源的系统他们有相似点也有不同点。上面列出的内容并不能说哪个系统比另一个更好。实际上FreeBSD和Linux都有自己的特点和技术规格这使它们与别的系统区别开来。那么您有什么看法呢您已经有在使用它们中的某个系统了么如果答案为是的话请给我们您的反馈如果答案是否的话在读完我们的描述后您怎么看请在留言处发表您的观点。
--------------------------------------------------------------------------------
via: http://www.unixmen.com/comparative-introduction-freebsd-linux-users/
作者:[anismaj][a]
译者:[wwy-hust](https://github.com/wwy-hust)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:https://www.unixmen.com/author/anis/

View File

@ -1,20 +1,18 @@
如何在 Ubuntu/CentOS7.1/Fedora22 上安装 Plex Media Server
如何在 Ubuntu/CentOS7.1/Fedora22 上安装 Plex Media Server
================================================================================
在本文中我们将会向你展示如何容易地在主流的最新发布的Linux发行版上安装Plex Home Media Server。在Plex安装成功后你将可以使用你的中式家庭媒体播放系统该系统能让多个Plex播放器App共享它的媒体资源并且该系统允许你设置你的环境通过增加你的设备以及设置一个可以一起使用Plex的用户组。让我们首先在Ubuntu15.04上开始Plex的安装。
在本文中我们将会向你展示如何容易地在主流的最新Linux发行版上安装Plex Media Server。在Plex安装成功后你将可以使用你的中式家庭媒体播放系统该系统能让多个Plex播放器App共享它的媒体资源并且该系统允许你设置你的环境增加你的设备以及设置一个可以一起使用Plex的用户组。让我们首先在Ubuntu15.04上开始Plex的安装。
### 基本的系统资源 ###
系统资源主要取决于你打算用来连接服务的设备类型和数量, 所以根据我们的需求我们将会在一个单独的服务器上使用以下系统资源。
注:表格
<table width="666" style="height: 181px;">
<tbody>
<tr>
<td width="670" colspan="2"><b>Plex Home Media Server</b></td>
<td width="670" colspan="2"><b>Plex Media Server</b></td>
</tr>
<tr>
<td width="236"><b>Base Operating System</b></td>
<td width="236"><b>基础操作系统</b></td>
<td width="425">Ubuntu 15.04 / CentOS 7.1 / Fedora 22 Work Station</td>
</tr>
<tr>
@ -22,11 +20,11 @@
<td width="425">Version 0.9.12.3.1173-937aac3</td>
</tr>
<tr>
<td width="236"><b>RAM and CPU</b></td>
<td width="236"><b>RAM CPU</b></td>
<td width="425">1 GB&nbsp; , 2.0 GHZ</td>
</tr>
<tr>
<td width="236"><b>Hard Disk</b></td>
<td width="236"><b>硬盘</b></td>
<td width="425">30 GB</td>
</tr>
</tbody>
@ -38,13 +36,13 @@
#### 步骤 1: 系统更新 ####
用root权限登你的服务器。确保你的系统是最新的,如果不是就使用下面的命令。
用root权限登你的服务器。确保你的系统是最新的,如果不是就使用下面的命令。
root@ubuntu-15:~#apt-get update
#### 步骤 2: 下载最新的Plex Media Server包 ####
创建一个新目录用wget命令从Plex官网下载为Ubuntu提供的.deb包并放入该目录中。
创建一个新目录用wget命令从[Plex官网](https://plex.tv/)下载为Ubuntu提供的.deb包并放入该目录中。
root@ubuntu-15:~# cd /plex/
root@ubuntu-15:/plex#
@ -52,7 +50,7 @@
#### 步骤 3: 安装Plex Media Server的Debian包 ####
现在在相同的目录下执行下面的命令来开始debian包的安装 然后检查plexmediaserver(译者注: 原文plekmediaserver 明显笔误)的状态。
现在在相同的目录下执行下面的命令来开始debian包的安装 然后检查plexmediaserver服务的状态。
root@ubuntu-15:/plex# dpkg -i plexmediaserver_0.9.12.3.1173-937aac3_amd64.deb
@ -62,41 +60,41 @@
![Plexmediaserver Service](http://blog.linoxide.com/wp-content/uploads/2015/06/plex-status.png)
### 在Ubuntu 15.04上设置Plex Home Media Web应用 ###
### 在Ubuntu 15.04上设置Plex Media Web应用 ###
让我们在你的本地网络主机中打开web浏览器 并用你的本地主机IP以及端口32400来打开Web界面并完成以下步骤来配置Plex。
让我们在你的本地网络主机中打开web浏览器 并用你的本地主机IP以及端口32400来打开Web界面并完成以下步骤来配置Plex。
http://172.25.10.179:32400/web
http://localhost:32400/web
#### 步骤 1: 登前先注册 ####
#### 步骤 1: 登前先注册 ####
在你访问到Plex Media Server的Web界面之后(译者注: 原文是Plesk, 应该是笔误), 确保注册并填上你的用户名(译者注: 原文username email ID感觉怪怪:))和密码来登陆
在你访问到Plex Media Server的Web界面之后 确保注册并填上你的用户名和密码来登录
![Plex Sign In](http://blog.linoxide.com/wp-content/uploads/2015/06/PMS-Login.png)
#### 输入你的PIN码来保护你的Plex Home Media用户(译者注: 原文Plex Media Home, 个人觉得专业称谓应该保持一致) ####
#### 输入你的PIN码来保护你的Plex Media用户####
![Plex User Pin](http://blog.linoxide.com/wp-content/uploads/2015/06/333.png)
现在你已经成功的在Plex Home Media下配置你的用户。
现在你已经成功的在Plex Media下配置你的用户。
![Welcome To Plex](http://blog.linoxide.com/wp-content/uploads/2015/06/3333.png)
### 在设备上而不是本地服务器上打开Plex Web应用 ###
正如我们在Plex Media主页看到的表明"你没有权限访问这个服务"。 这是因为我们跟服务器计算机不在同个网络。
如我们在Plex Media主页看到的提示“你没有权限访问这个服务”。 这说明我们跟服务器计算机不在同个网络。
![Plex Server Permissions](http://blog.linoxide.com/wp-content/uploads/2015/06/33.png)
现在我们需要解决这个权限问题以便我们通过设备访问服务器而不是通过托管服务器(Plex服务器) 通过完成下面的步骤
现在我们需要解决这个权限问题,以便我们通过设备访问服务器而不是只能在服务器上访问。通过完成下面的步骤完成
### 设置SSH隧道使Windows系统访问到Linux服务器 ###
### 设置SSH隧道使Windows系统可以访问到Linux服务器 ###
首先我们需要建立一条SSH隧道以便我们访问远程服务器资源就好像资源在本地一样。 这仅仅是必要的初始设置。
如果你正在使用Windows作为你的本地系统Linux作为服务器那么我们可以参照下图通过Putty来设置SSH隧道。
(译注: 首先要在Putty的Session中用Plex服务器IP配置一个SSH的会话才能进行下面的隧道转发规则配置。
LCTT译注: 首先要在Putty的Session中用Plex服务器IP配置一个SSH的会话才能进行下面的隧道转发规则配置。
然后点击“Open”输入远端服务器用户名密码 来保持SSH会话连接。
![Plex SSH Tunnel](http://blog.linoxide.com/wp-content/uploads/2015/06/ssh-tunnel.png)
@ -111,13 +109,13 @@
![Agree to Plex term](http://blog.linoxide.com/wp-content/uploads/2015/06/5.png)
现在一个功能齐全的Plex Home Media Server已经准备好添加新的媒体库、频道、播放列表等资源。
现在一个功能齐全的Plex Media Server已经准备好添加新的媒体库、频道、播放列表等资源。
![PMS Settings](http://blog.linoxide.com/wp-content/uploads/2015/06/8.png)
### 在CentOS 7.1上安装Plex Media Server 0.9.12.3 ###
我们将会按照上述在Ubuntu15.04上安装Plex Home Media Server的步骤来将Plex安装到CentOS 7.1上。
我们将会按照上述在Ubuntu15.04上安装Plex Media Server的步骤来将Plex安装到CentOS 7.1上。
让我们从安装Plex Media Server开始。
@ -144,9 +142,9 @@
[root@linux-tutorials plex]# systemctl enable plexmediaserver.service
[root@linux-tutorials plex]# systemctl status plexmediaserver.service
### 在CentOS-7.1上设置Plex Home Media Web应用 ###
### 在CentOS-7.1上设置Plex Media Web应用 ###
现在我们只需要重复在Ubuntu上设置Plex Web应用的所有步骤就可以了。 让我们在Web浏览器上打开一个新窗口并用localhost或者Plex服务器的IP(译者注: 原文为or your Plex server, 明显的笔误)来访问Plex Home Media Web应用(译者注:称谓一致)
现在我们只需要重复在Ubuntu上设置Plex Web应用的所有步骤就可以了。 让我们在Web浏览器上打开一个新窗口并用localhost或者Plex服务器的IP来访问Plex Media Web应用。
http://172.20.3.174:32400/web
http://localhost:32400/web
@ -157,25 +155,25 @@
### 在Fedora 22工作站上安装Plex Media Server 0.9.12.3 ###
基本的下载和安装Plex Media Server步骤跟在CentOS 7.1上安装的步骤一致。我们只需要下载对应的rpm包然后用rpm命令来安装它。
下载和安装Plex Media Server步骤基本跟在CentOS 7.1上安装的步骤一致。我们只需要下载对应的rpm包然后用rpm命令来安装它。
![PMS Installation](http://blog.linoxide.com/wp-content/uploads/2015/06/plex-on-fedora.png)
### 在Fedora 22工作站上配置Plex Home Media Web应用 ###
### 在Fedora 22工作站上配置Plex Media Web应用 ###
我们在与Plex服务器相同的主机上配置Plex Media Server因此不需要设置SSH隧道。只要在你的Fedora 22工作站上用Plex Home Media Server的默认端口号32400打开Web浏览器并同意Plex的服务条款即可。
我们在与Plex服务器相同的主机上配置Plex Media Server因此不需要设置SSH隧道。只要在你的Fedora 22工作站上用Plex Media Server的默认端口号32400打开Web浏览器并同意Plex的服务条款即可。
![Plex Agreement](http://blog.linoxide.com/wp-content/uploads/2015/06/Plex-Terms.png)
**欢迎来到Fedora 22工作站上的Plex Home Media Server**
*欢迎来到Fedora 22工作站上的Plex Media Server*
让我们用你的Plex账户登,并且开始将你喜欢的电影频道添加到媒体库、创建你的播放列表、添加你的图片以及享用更多其他的特性。
让我们用你的Plex账户登,并且开始将你喜欢的电影频道添加到媒体库、创建你的播放列表、添加你的图片以及享用更多其他的特性。
![Plex Add Libraries](http://blog.linoxide.com/wp-content/uploads/2015/06/create-library.png)
### 总结 ###
我们已经成功完成Plex Media Server在主流Linux发行版上安装和配置。Plex Home Media Server永远都是媒体管理的最佳选择。 它在跨平台上的设置是如此的简单就像我们在Ubuntu,CentOS以及Fedora上的设置一样。它简化了你组织媒体内容的工作并将媒体内容“流”向其他计算机以及设备以便你跟你的朋友分享媒体内容。
我们已经成功完成Plex Media Server在主流Linux发行版上安装和配置。Plex Media Server永远都是媒体管理的最佳选择。 它在跨平台上的设置是如此的简单就像我们在Ubuntu,CentOS以及Fedora上的设置一样。它简化了你组织媒体内容的工作并将媒体内容“流”向其他计算机以及设备以便你跟你的朋友分享媒体内容。
--------------------------------------------------------------------------------
@ -183,7 +181,7 @@ via: http://linoxide.com/tools/install-plex-media-server-ubuntu-centos-7-1-fedor
作者:[Kashif Siddique][a]
译者:[dingdongnigetou](https://github.com/dingdongnigetou)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,3 +1,4 @@
ictlyh Translating
How to access a Linux server behind NAT via reverse SSH tunnel
================================================================================
You are running a Linux server at home, which is behind a NAT router or restrictive firewall. Now you want to SSH to the home server while you are away from home. How would you set that up? SSH port forwarding will certainly be an option. However, port forwarding can become tricky if you are dealing with multiple nested NAT environment. Besides, it can be interfered with under various ISP-specific conditions, such as restrictive ISP firewalls which block forwarded ports, or carrier-grade NAT which shares IPv4 addresses among users.

View File

@ -1,182 +0,0 @@
ictlyh Translating
Analyzing Linux Logs
================================================================================
Theres a great deal of information waiting for you within your logs, although its not always as easy as youd like to extract it. In this section we will cover some examples of basic analysis you can do with your logs right away (just search whats there). Well also cover more advanced analysis that may take some upfront effort to set up properly, but will save you time on the back end. Examples of advanced analysis you can do on parsed data include generating summary counts, filtering on field values, and more.
Well show you first how to do this yourself on the command line using several different tools and then show you how a log management tool can automate much of the grunt work and make this so much more streamlined.
### Searching with Grep ###
Searching for text is the most basic way to find what youre looking for. The most common tool for searching text is [grep][1]. This command line tool, available on most Linux distributions, allows you to search your logs using regular expressions. A regular expression is a pattern written in a special language that can identify matching text. The simplest pattern is to put the string youre searching for surrounded by quotes
#### Regular Expressions ####
Heres an example to find authentication logs for “user hoover” on an Ubuntu system:
$ grep "user hoover" /var/log/auth.log
Accepted password for hoover from 10.0.2.2 port 4792 ssh2
pam_unix(sshd:session): session opened for user hoover by (uid=0)
pam_unix(sshd:session): session closed for user hoover
It can be hard to construct regular expressions that are accurate. For example, if we searched for a number like the port “4792” it could also match timestamps, URLs, and other undesired data. In the below example for Ubuntu, it matched an Apache log that we didnt want.
$ grep "4792" /var/log/auth.log
Accepted password for hoover from 10.0.2.2 port 4792 ssh2
74.91.21.46 - - [31/Mar/2015:19:44:32 +0000] "GET /scripts/samples/search?q=4972HTTP/1.0" 404 545 "-" "-”
#### Surround Search ####
Another useful tip is that you can do surround search with grep. This will show you what happened a few lines before or after a match. It can help you debug what lead up to a particular error or problem. The B flag gives you lines before, and A gives you lines after. For example, we can see that when someone failed to login as an admin, they also failed the reverse mapping which means they might not have a valid domain name. This is very suspicious!
$ grep -B 3 -A 2 'Invalid user' /var/log/auth.log
Apr 28 17:06:20 ip-172-31-11-241 sshd[12545]: reverse mapping checking getaddrinfo for 216-19-2-8.commspeed.net [216.19.2.8] failed - POSSIBLE BREAK-IN ATTEMPT!
Apr 28 17:06:20 ip-172-31-11-241 sshd[12545]: Received disconnect from 216.19.2.8: 11: Bye Bye [preauth]
Apr 28 17:06:20 ip-172-31-11-241 sshd[12547]: Invalid user admin from 216.19.2.8
Apr 28 17:06:20 ip-172-31-11-241 sshd[12547]: input_userauth_request: invalid user admin [preauth]
Apr 28 17:06:20 ip-172-31-11-241 sshd[12547]: Received disconnect from 216.19.2.8: 11: Bye Bye [preauth]
#### Tail ####
You can also pair grep with [tail][2] to get the last few lines of a file, or to follow the logs and print them in real time. This is useful if you are making interactive changes like starting a server or testing a code change.
$ tail -f /var/log/auth.log | grep 'Invalid user'
Apr 30 19:49:48 ip-172-31-11-241 sshd[6512]: Invalid user ubnt from 219.140.64.136
Apr 30 19:49:49 ip-172-31-11-241 sshd[6514]: Invalid user admin from 219.140.64.136
A full introduction on grep and regular expressions is outside the scope of this guide, but [Ryans Tutorials][3] include more in-depth information.
Log management systems have higher performance and more powerful searching abilities. They often index their data and parallelize queries so you can quickly search gigabytes or terabytes of logs in seconds. In contrast, this would take minutes or in extreme cases hours with grep. Log management systems also use query languages like [Lucene][4] which offer an easier syntax for searching on numbers, fields, and more.
### Parsing with Cut, AWK, and Grok ###
#### Command Line Tools ####
Linux offers several command line tools for text parsing and analysis. They are great if you want to quickly parse a small amount of data but can take a long time to process large volumes of data
#### Cut ####
The [cut][5] command allows you to parse fields from delimited logs. Delimiters are characters like equal signs or commas that break up fields or key value pairs.
Lets say we want to parse the user from this log:
pam_unix(su:auth): authentication failure; logname=hoover uid=1000 euid=0 tty=/dev/pts/0 ruser=hoover rhost= user=root
We can use the cut command like this to get the text after the eighth equal sign. This example is on an Ubuntu system:
$ grep "authentication failure" /var/log/auth.log | cut -d '=' -f 8
root
hoover
root
nagios
nagios
#### AWK ####
Alternately, you can use [awk][6], which offers more powerful features to parse out fields. It offers a scripting language so you can filter out nearly everything thats not relevant.
For example, lets say we have the following log line on an Ubuntu system and we want to extract the username that failed to login:
Mar 24 08:28:18 ip-172-31-11-241 sshd[32701]: input_userauth_request: invalid user guest [preauth]
Heres how you can use the awk command. First, put a regular expression /sshd.*invalid user/ to match the sshd invalid user lines. Then print the ninth field using the default delimiter of space using { print $9 }. This outputs the usernames.
$ awk '/sshd.*invalid user/ { print $9 }' /var/log/auth.log
guest
admin
info
test
ubnt
You can read more about how to use regular expressions and print fields in the [Awk Users Guide][7].
#### Log Management Systems ####
Log management systems make parsing easier and enable users to quickly analyze large collections of log files. They can automatically parse standard log formats like common Linux logs or web server logs. This saves a lot of time because you dont have to think about writing your own parsing logic when troubleshooting a system problem.
Here you can see an example log message from sshd which has each of the fields remoteHost and user parsed out. This is a screenshot from Loggly, a cloud-based log management service.
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.25.09-AM.png)
You can also do custom parsing for non-standard formats. A common tool to use is [Grok][8] which uses a library of common regular expressions to parse raw text into structured JSON. Here is an example configuration for Grok to parse kernel log files inside Logstash:
filter{
grok {
match => {"message" => "%{CISCOTIMESTAMP:timestamp} %{HOST:host} %{WORD:program}%{NOTSPACE} %{NOTSPACE}%{NUMBER:duration}%{NOTSPACE} %{GREEDYDATA:kernel_logs}"
}
}
And here is what the parsed output looks like from Grok:
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.30.37-AM.png)
### Filtering with Rsyslog and AWK ###
Filtering allows you to search on a specific field value instead of doing a full text search. This makes your log analysis more accurate because it will ignore undesired matches from other parts of the log message. In order to search on a field value, you need to parse your logs first or at least have a way of searching based on the event structure.
#### How to Filter on One App ####
Often, you just want to see the logs from just one application. This is easy if your application always logs to a single file. Its more complicated if you need to filter one application among many in an aggregated or centralized log. Here are several ways to do this:
1. Use the rsyslog daemon to parse and filter logs. This example writes logs from the sshd application to a file named sshd-messages, then discards the event so its not repeated elsewhere. You can try this example by adding it to your rsyslog.conf file.
:programname, isequal, “sshd” /var/log/sshd-messages
&~
2. Use command line tools like awk to extract the values of a particular field like the sshd username. This example is from an Ubuntu system.
$ awk '/sshd.*invalid user/ { print $9 }' /var/log/auth.log
guest
admin
info
test
ubnt
3. Use a log management system that automatically parses your logs, then click to filter on the desired application name. Here is a screenshot showing the syslog fields in a log management service called Loggly. We are filtering on the appName “sshd” as indicated by the Venn diagram icon.
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.05.02-AM.png)
#### How to Filter on Errors ####
One of the most common thing people want to see in their logs is errors. Unfortunately, the default syslog configuration doesnt output the severity of errors directly, making it difficult to filter on them.
There are two ways you can solve this problem. First, you can modify your rsyslog configuration to output the severity in the log file to make it easier to read and search. In your rsyslog configuration you can add a [template][9] with pri-text such as the following:
"<%pri-text%> : %timegenerated%,%HOSTNAME%,%syslogtag%,%msg%n"
This example gives you output in the following format. You can see that the severity in this message is err.
<authpriv.err> : Mar 11 18:18:00,hoover-VirtualBox,su[5026]:, pam_authenticate: Authentication failure
You can use awk or grep to search for just the error messages. In this example for Ubuntu, were including some surrounding syntax like the . and the > which match only this field.
$ grep '.err>' /var/log/auth.log
<authpriv.err> : Mar 11 18:18:00,hoover-VirtualBox,su[5026]:, pam_authenticate: Authentication failure
Your second option is to use a log management system. Good log management systems automatically parse syslog messages and extract the severity field. They also allow you to filter on log messages of a certain severity with a single click.
Here is a screenshot from Loggly showing the syslog fields with the error severity highlighted to show we are filtering for errors:
![](http://www.loggly.com/ultimate-guide/wp-content/uploads/2015/05/Screen-Shot-2015-03-12-at-11.00.36-AM.png)
--------------------------------------------------------------------------------
via: http://www.loggly.com/ultimate-guide/logging/analyzing-linux-logs/
作者:[Jason Skowronski][a] [Amy Echeverri][b] [ Sadequl Hussain][c]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linkedin.com/in/jasonskowronski
[b]:https://www.linkedin.com/in/amyecheverri
[c]:https://www.linkedin.com/pub/sadequl-hussain/14/711/1a7
[1]:http://linux.die.net/man/1/grep
[2]:http://linux.die.net/man/1/tail
[3]:http://ryanstutorials.net/linuxtutorial/grep.php
[4]:https://lucene.apache.org/core/2_9_4/queryparsersyntax.html
[5]:http://linux.die.net/man/1/cut
[6]:http://linux.die.net/man/1/awk
[7]:http://www.delorie.com/gnu/docs/gawk/gawk_26.html#IDX155
[8]:http://logstash.net/docs/1.4.2/filters/grok
[9]:http://www.rsyslog.com/doc/v8-stable/configuration/templates.html

View File

@ -1,127 +0,0 @@
How to Update Linux Kernel for Improved System Performance
================================================================================
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/update-linux-kernel-644x373.jpg?2c3c1f)
The rate of development for [the Linux kernel][1] is unprecedented, with a new major release approximately every two to three months. Each release offers several new features and improvements that a lot of people could take advantage of to make their computing experience faster, more efficient, or better in other ways.
The problem, however, is that you usually cant take advantage of these new kernel releases as soon as they come out — you have to wait until your distribution comes out with a new release that packs a newer kernel with it. Weve previously laid out [the benefits for regularly updating your kernel][2], and you dont have to wait to get your hands on them. Well show you how.
> Disclaimer: As some of our literature may have mentioned before, updating your kernel does carry a (small) risk of breaking your system. If this is the case, its usually easy to pick an older kernel at boot time that works, but something may always go wrong. Therefore, were not responsible for any damage to your system — use at your own risk!
### Prep Work ###
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/linux_kernel_arch.jpg?2c3c1f)
To update your kernel, youll first need to determine whether youre using a 32-bit or 64-bit system. Open up a terminal window and run
uname -a
Then check to see if the output says x86_64 or i686. If its x86_64, then youre running the 64-bit version; otherwise, youre running the 32-bit version. Remember this, because it will be important.
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/kernel_latest_version.jpg?2c3c1f)
Next, visit the [official Linux kernel website][3]. This will tell you what the current stable version of the kernel is. You can try out release candidates if youd like, but they are a lot less tested than the stable releases. Stick with the stable kernel unless you are certain you need a release candidate version.
### Ubuntu Instructions ###
Its quite easy for Ubuntu and Ubuntu-derivative users to update their kernel, thanks to the Ubuntu Mainline Kernel PPA. Although its officially called a PPA, you cannot use it like other PPAs by adding them to your software sources list and expecting it to automatically update the kernel for you. Instead, its simply a webpage you navigate through to download the kernel you want.
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/ubuntu_new_kernels.jpg?2c3c1f)
Now, visit the [kernel PPA webpage][4] and scroll all the way to the bottom. The absolute bottom of the list will probably contain some release candidate versions (which you can see by the “rc” in the name), but just above them should be the latest stable kernel (to make this easier to explain, at the time of writing the stable version was 4.1.2). Click on that, and youll be presented with several options. Youll need to grab three files and save them in their own folder (within the Downloads folder if youd like) so that theyre isolated from all other files:
- The “generic” header file for your architecture (in my case, 64-bit or “amd64″)
- The header file in the middle that has “all” towards the end of the filename
- The “generic” kernel file for your architecture (again, I would pick “amd64″ but if you use 32-bit youll need “i686″)
Youll notice that there are also “lowlatency” files available to download, but its fine to ignore this. These files are relatively unstable and are only made available for people who need their low-latency benefits if the general files dont suffice for tasks such as audio recording. Again, the recommendation is to always use generic first and only try lowlatency if your performance isnt good enough for certain tasks. No, gaming or Internet browsing arent excuses to try lowlatency.
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/ubuntu_install_kernel.jpg?2c3c1f)
You put these files into their own folder, right? Now open up the Terminal, use the
cd
command to go to your newly-created folder, such as
cd /home/user/Downloads/Kernel
and then run:
sudo dpkg -i *.deb
This command marks all .deb files within the folder as “to be installed” and then performs the installation. This is the recommended way to install these files because otherwise its easy to pick one file to install and itll complain about dependency issues. This approach avoids that problem. If youre not sure what cd or sudo are, get a quick crash course on [essential Linux commands][5].
Once the installation is complete, **Restart** your system and you should be running the just-installed kernel! You can check this by running uname -a in the Terminal and checking the output.
### Fedora Instructions ###
If you use Fedora or one of its derivatives, the process is very similar to Ubuntu. Theres just a different location to grab different files, and a different command to install them.
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/fedora_new_kernels.jpg?2c3c1f)
VIew the list of the most [recent kernel builds for Fedora][6]. Pick the latest stable version out of the list, and then scroll down to either the i686 or x86_64 section, depending on your systems architecture. In this section, youll need to grab the following files and save them in their own folder (such as “Kernel” within your Downloads folder, as an example):
- kernel
- kernel-core
- kernel-headers
- kernel-modules
- kernel-modules-extra
- kernel-tools
- perf and python-perf (optional)
If your system is i686 (32-bit) and you have 4GB of RAM or more, youll need to grab the PAE version of all of these files where available. PAE is an address extension technique used for 32-bit system to allow them to use more than 3GB of RAM.
Now, use the
cd
command to go to that folder, such as
cd /home/user/Downloads/Kernel
and then run the following command to install all the files:
yum --nogpgcheck localinstall *.rpm
Finally **Restart** your computer and you should be running a new kernel!
### Using Rawhide ###
Alternatively, Fedora users can also simply [switch to Rawhide][7] and itll automatically update every package to the latest version, including the kernel. However, Rawhide is known to break quite often (especially early on in the development cycle) and should **not** be used on a system that you need to rely on.
### Arch Instructions ###
[Arch users][8] should always have the latest and greatest stable kernel available (or one pretty close to it). If you want to get even closer to the latest-released stable kernel, you can enable the testing repo which will give you access to major new releases roughly two to four weeks early.
To do this, open the file located at
/etc/pacman.conf
with sudo permissions in [your favorite terminal text editor][9], and then uncomment (delete the pound symbols from the front of each line) the three lines associated with testing. If you have the multilib repository enabled, then do the same for the multilib-testing repository. See [this Arch Linux wiki page][10] if you need more information.
Upgrading your kernel isnt easy (done so intentionally), but it can give you a lot of benefits. So long as your new kernel didnt break anything, you can now enjoy improved performance, better efficiency, support for more hardware, and potential new features. Especially if youre running relatively new hardware, upgrading the kernel can really help out.
**How has upgraded the kernel helped you? Do you think your favorite distributions policy on kernel releases is what it should be?** Let us know in the comments!
--------------------------------------------------------------------------------
via: http://www.makeuseof.com/tag/update-linux-kernel-improved-system-performance/
作者:[Danny Stieben][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.makeuseof.com/tag/author/danny/
[1]:http://www.makeuseof.com/tag/linux-kernel-explanation-laymans-terms/
[2]:http://www.makeuseof.com/tag/5-reasons-update-kernel-linux/
[3]:http://www.kernel.org/
[4]:http://kernel.ubuntu.com/~kernel-ppa/mainline/
[5]:http://www.makeuseof.com/tag/an-a-z-of-linux-40-essential-commands-you-should-know/
[6]:http://koji.fedoraproject.org/koji/packageinfo?packageID=8
[7]:http://www.makeuseof.com/tag/bleeding-edge-linux-fedora-rawhide/
[8]:http://www.makeuseof.com/tag/arch-linux-letting-you-build-your-linux-system-from-scratch/
[9]:http://www.makeuseof.com/tag/nano-vs-vim-terminal-text-editors-compared/
[10]:https://wiki.archlinux.org/index.php/Pacman#Repositories

View File

@ -1,72 +0,0 @@
What is Logical Volume Management and How Do You Enable It in Ubuntu?
================================================================================
> Logical Volume Management (LVM) is a disk management option that every major Linux distribution includes. Whether you need to set up storage pools or just need to dynamically create partitions, LVM is probably what you are looking for.
### What is LVM? ###
Logical Volume Manager allows for a layer of abstraction between your operating system and the disks/partitions it uses. In traditional disk management your operating system looks for what disks are available (/dev/sda, /dev/sdb, etc.) and then looks at what partitions are available on those disks (/dev/sda1, /dev/sda2, etc.).
With LVM, disks and partitions can be abstracted to contain multiple disks and partitions into one device. Your operating systems will never know the difference because LVM will only show the OS the volume groups (disks) and logical volumes (partitions) that you have set up.
Because volume groups and logical volumes arent physically tied to a hard drive, it makes it easy to dynamically resize and create new disks and partitions. In addition, LVM can give you features that your file system is not capable of doing. For example, Ext3 does not have support for live snapshots, but if youre using LVM you have the ability to take a snapshot of your logical volumes without unmounting the disk.
### When Should You Use LVM? ###
The first thing your should consider before setting up LVM is what you want to accomplish with your disks and partitions. Some distributions, like Fedora, install with LVM by default.
If you are using Ubuntu on a laptop with only one internal hard drive and you dont need extended features like live snapshots, then you may not need LVM. If you need easy expansion or want to combine multiple hard drives into a single pool of storage then LVM may be what you have been looking for.
### Setting up LVM in Ubuntu ###
First thing to know about using LVM is there is no easy way to convert your existing traditional partitions to logical volumes. It is possible to move to a new partition that uses LVM, but that wont be something that we will cover in this article; instead we are going to take the approach of setting up LVM on a fresh installation of Ubuntu 10.10.
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/ubuntu-10-banner.png)
To install Ubuntu using LVM you need to use the alternate install CD. Download it from the link below and burn a CD or [use unetbootin to create a USB drive][1].
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/download-web.png)
Boot your computer from the alternate install disk and select your options up until the partition disks screen and select guided use entire disk and set up LVM.
*Note: This will format your entire hard drive so if you are trying to dual boot or have another installation select manual instead.*
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/setup-1.png)
Select the main disk you want to use, typically your largest drive, and then go to the next step.
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/setup-2.png)
You will immediately need to write the changes to disk so make sure you selected the right disk and then write the changes.
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/setup-3.png)
Select the size you want the first logical volume to be and then continue.
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/setup-4.png)
Confirm your disk partitions and continue with the installation.
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/setup-5.png)
The final step will write the GRUB bootloader to the hard drive. It is important to note that GRUB cannot be on an LVM partition because computer BIOSes cannot directly read from a logical volume. Ubuntu will automatically create a 255 MB ext2 partition for your bootloader.
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/setup-6.png)
After the installation is complete, reboot the machine and boot into Ubuntu as normal. There should be no perceivable difference between using LVM or traditional disk management with this type of installation.
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/disk-manager.png)
To use LVM to its full potential, stay tuned for our upcoming article on managing your LVM installation.
--------------------------------------------------------------------------------
via: http://www.howtogeek.com/howto/36568/what-is-logical-volume-management-and-how-do-you-enable-it-in-ubuntu/
作者:[How-To Geek][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://plus.google.com/+howtogeek?prsrc=5
[1]:http://www.howtogeek.com/howto/13379/create-a-bootable-ubuntu-9.10-usb-flash-drive/

View File

@ -1,186 +0,0 @@
Translating by GOLinux!
Must-Know Linux Commands For New Users
================================================================================
![Manage system updates via the command line with dnf on Fedora.](http://www.linux.com/images/stories/41373/fedora-cli.png)
Manage system updates via the command line with dnf on Fedora.
One of the beauties of Linux-based systems is that you can manage your entire system right from the terminal using the command line. The advantage of using the command line is that you can use the same knowledge and skills to manage any Linux distribution.
This is not possible through the graphical user interface (GUI) as each distro, and desktop environment (DE), offers its own user interfaces. To be clear, there are cases in which you will need different commands to perform certain tasks on different distributions, but more or less the concept and ideas remain the same.
In this article, we are going to talk about some of the basic commands that a new Linux user should know. I will show you how to update your system, manage software, manipulate files and switch to root using the command line on three major distributions: Ubuntu (which also includes its flavors and derivatives, and Debian), openSUSE and Fedora.
*Let's get started!*
### Keep your system safe and up-to-date ###
Linux is secure by design, but the fact is that all software has bugs and there could be security holes. So it's very important to keep your system updated. Think of it this way: Running an out-of-date operating system is like being in an armored tank with the doors unlocked. Will the armor protect you? Anyone can enter through the open doors and cause harm. Similarly there can be un-patched holes in your OS which can compromise your systems. Open source communities, unlike the proprietary world, are extremely quick at patching holes, so if you keep your system updated you'll stay safe.
Keep an eye on news sites to be aware of security vulnerabilities. If there is a hole discovered, read about it and update your system as soon as a patch is out. Either way you must make it a practice to run the update commands at least once a week on production machines. If you are running a complicated server then be extra careful and go through the changelog to ensure updates won't break your customization.
**Ubuntu**: Bear one thing in mind: you must always refresh repositories (aka repos) before upgrading the system or installing any software. On Ubuntu, you can update your system with the following commands. The first command refreshes repositories:
sudo apt-get update
Once the repos are updated you can now run the system update command:
sudo apt-get upgrade
However this command doesn't update the kernel and some other packages, so you must also run this command:
sudo apt-get dist-upgrade
**openSUSE**: If you are on openSUSE, you can update the system using these commands (as usual, the first command is meant to update repos)
sudo zypper refresh
sudo zypper up
**Fedora**: If you are on Fedora, you can use the 'dnf' command which is 'kind' of equivalent to zypper and apt-get:
sudo dnf update
sudo dnf upgrade
### Software installation and removal ###
You can install only those packages which are available in the repositories enabled on your system. Every distro comes with some official or third-party repos enabled by default.
**Ubuntu**: To install any package on Ubuntu, first update the repo and then use this syntax:
sudo apt-get install [package_name]
Example:
sudo apt-get install gimp
**openSUSE**: The commands would be:
sudo zypper install [package_name]
**Fedora**: Fedora has dropped 'yum' and now uses 'dnf' so the command would be:
sudo dnf install [package_name]
The procedure to remove the software is the same, just exchange 'install' with 'remove'.
**Ubuntu**:
sudo apt-get remove [package_name]
**openSUSE**:
sudo zypper remove [package_name]
**Fedora**:
sudo dnf remove [package_name]
### How to manage third party software? ###
There is a huge community of developers who offer their software to users. Different distributions use different mechanisms to make third party software available to their users. It also depends on how a developer offers their software to users; some offer binaries and others offer it through repositories.
Ubuntu heavily relies on PPAs (personal package archives) but, unfortunately, there is no built-in tool which can assist a user in searching PPAs. You will need to Google the PPA and then add the repository manually before installing the software. This is how you would add any PPA to your system:
sudo add-apt-repository ppa:<repository-name>
Example: Let's say I want to add LibreOffice PPA to my system. I would Google the PPA and then acquire the repo name from Launchpad, which in this case is "libreoffice/ppa". Then add the ppa using the following command:
sudo add-apt-repository ppa:libreoffice/ppa
It will ask you to hit the Enter key in order to import the keys. Once it's done, refresh the repos with the 'update' command and then install the package.
openSUSE has an elegant solution for third-party apps. You can visit software.opensuse.org, search for the package and install it with one click. It will automatically add the repo to your system. If you want to add any repo manually, use this command:.
sudo zypper ar -f url_of_the_repo name_of_repo
sudo zypper ar -f http://download.opensuse.org/repositories/LibreOffice:Factory/openSUSE_13.2/LibreOffice:Factory.repo LOF
Then refresh the repo and install software:
sudo zypper refresh
sudo zypper install libreoffice
Fedora users can simply add RPMFusion (both free and non-free repos) which contain a majority of applications. In case you do need to add a repo, this is the command:
dnf config-manager --add-repo http://www.example.com/example.repo
### Some basic commands ###
I have written a few [articles][1] on how to manage files on your system using the CLI, here are some of the basic commands which are common across all distributions.
Copy files or directories to a new location:
cp path_of_file_1 path_of_the_directory_where_you_want_to_copy/
Copy all files from a directory to a new location (notice the slash and asterisk, which implies all files within that directory):
cp path_of_files/* path_of_the_directory_where_you_want_to_copy/
Move a file from one location to another (the trailing slash means inside that directory):
mv path_of_file_1 path_of_the_directory_where_you_want_to_move/
Move all file from one location to another:
mv path_of_directory_where_files_are/* path_of_the_directory_where_you_want_to_move/
Delete a file:
rm path_of_file
Delete a directory:
rm -r path_of_directory
Remove all content from the directory, leaving the directory folder intact:
rm -r path_of_directory/*
### Create new directory ###
To create a new directory, first enter the location where you want to create a directory. Let's say you want to create a 'foundation' folder inside your Documents directory. Let's change the directory using the cd (aka change directory) command:
cd /home/swapnil/Documents
(exchange 'swapnil with the user on your system)
Then create the directory with mkdir command:
mkdir foundation
You can also create a directory from anywhere, by giving the path of the directory. For example:
mdkir /home/swapnil/Documents/foundation
If you want to create parent-child directories, which means directories within other directories then use the -p option. It will create all directories in the given path:
mdkir -p /home/swapnil/Documents/linux/foundation
### Become root ###
You either need to be root or the user should have sudo powers to perform some administrative tasks such as managing packages or making changes to the root directories or files. An example would be to edit the 'fstab' file which keeps a record of mounted hard drives. It's inside the 'etc' directory which is within the root directory. You can make changes to this file only as a super user. In most distros you can become root by 'switching user'. Let's say on openSUSE I want to become root as I am going to work inside the root directory. You can use either command:
sudo su -
Or
su -
That will ask for the password and then you will have root privileges. Keep one point in mind: never run your system as root user unless you know what you are doing. Another important point to note is that the files or directories you modify as root also change ownership of those files from that user or specific service to root. You may have to revert the ownership of those files otherwise the services or users won't be able to to access or write to those files. To change users, this is the command:
sudo chown -R user:user /path_of_file_or_directory
You may often need this when you have partitions from other distros mounted on the system. When you try to access files on such partitions, you may come across a permission denied error. You can simply change the ownership of such partitions to access them. Just be extra careful, don't change permissions or ownership of root directories.
These are the basic commands any new Linux user needs. If you have any questions or if you want us to cover a specific topic, please mention them in the comments below.
--------------------------------------------------------------------------------
via: http://www.linux.com/learn/tutorials/842251-must-know-linux-commands-for-new-users
作者:[Swapnil Bhartiya][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.linux.com/community/forums/person/61003
[1]:http://www.linux.com/learn/tutorials/828027-how-to-manage-your-files-from-the-command-line

View File

@ -1,98 +0,0 @@
以比较的方式向Linux用户介绍FreeBSD
================================================================================
![](https://1102047360.rsc.cdn77.org/wp-content/uploads/2015/03/FreeBSD-790x494.jpg)
### 简介 ###
BSD最初从UNIX继承而来目前有许多的类Unix操作系统是基于BSD的。FreeBSD是使用最广泛的开源伯克利软件发行版BSD发行版。就像它隐含的意思一样它是一个免费开源的类Unix操作系统并且是公共服务器的平台。FreeBSD源代码通常以宽松的BSD许可证发布。它与Linux有很多相似的地方但我们得承认它们在很多方面仍有不同。
本文的其余部分组织如下FreeBSD的描述在第一部分FreeBSD和Linux的相似点在第二部分它们的区别将在第三部分讨论对他们功能的讨论和总结在最后一节。
### FreeBSD描述 ###
#### 历史 ####
- FreeBSD的第一个版本发布于1993年它的第一张CD-ROM是FreeBSD1.0也发行于1993年。接下来FreeBSD 2.1.0在1995年发布并且获得了所有用户的青睐。实际上许多IT公司都使用FreeBSD并且很满意我们可以列出其中的一些IBM、Nokia、NetApp和Juniper Network。
#### 许可证 ####
- 关于它的许可证FreeBSD以多种开源许可证进行发布它最新的名为Kernel的代码以两种子BSD许可证进行了发布给予使用和重新发布FreeBSD的绝对自由。其它的代码则以三、四种子BSD许可证进行发布有些是以GPL和CDDL的许可证发布的。
#### 用户 ####
- FreeBSD的重要特点之一就是它多样的用户。实际上FreeBSD可以作为邮件服务器、Web Server、FTP服务器以及路由器等您只需要在它上运行服务相关的软件即可。而且FreeBSD还支持ARM、PowerPC、MIPS、x86、x86-64架构。
### FreeBSD和Linux的相似处 ###
FreeBSD和Linux是两个免费开源的软件。实际上它们的用户可以很容易的检查并修改源代码用户拥有绝对的自由。而且FreeBSD和Linux都是类Unix系统它们的内核、内部组件、库程序都使用从历史上的AT&T Unix处继承的算法。FreeBSD从根基上更像Unix系统而Linux是作为免费的类Unix系统发布的。许多工具应用都可以在FreeBSD和Linux中找到实际上他们几乎有同样的功能。
此外FreeBSD能够运行大量的Linux应用。它可以安装一个Linux的兼容层这个兼容层可以在编译FreeBSD时加入AAC Compact Linux得到或通过下载已编译了Linux兼容层的FreeBSD系统其中会包括兼容程序aac_linux.ko。不同于FreeBSD的是Linux无法运行FreeBSD的软件。
最后,我们注意到虽然二者有同样的目标,但二者还是有一些不同之处,我们在下一节中列出。
### FreeBSD和Linux的区别 ###
目前对于大多数用户来说并没有一个选择FreeBSD还是Linux的清楚的准则。因为他们有着很多同样的应用程序因为他们都被称作类Unix系统。
在这一章,我们将列出这两种系统的一些重要的不同之处。
#### 许可证 ####
- 两个系统的区别首先在于它们的许可证。Linux以GPL许可证发行它为用户提供阅读、发行和修改源代码的自由GPL许可证帮助用户避免仅仅发行二进制。而FreeBSD以BSD许可证发布BSD许可证比GPL更宽容因为其衍生著作不需要仍以该许可证发布。这意味着任何用户能够使用、发布、修改代码并且不需要维持之前的许可证。
- 您可以依据您的需求在两种许可证中选择一种。首先是BSD许可证由于其特殊的条款它更受用户青睐。实际上这个许可证使用户在保证源代码的封闭性的同时可以售卖以该许可证发布的软件。再说说GPL它需要每个使用以该许可证发布的软件的用户多加注意。
- 如果想在以不同许可证发布的两种软件中做出选择,您需要了解他们各自的许可证,以及他们开发中的方法论,从而能了解他们特性的区别,来选择更适合自己需求的。
#### 控制 ####
- 由于FreeBSD和Linux是以不同的许可证发布的Linus Torvalds控制着Linux的内核而FreeBSD却与Linux不同它并未被控制。我个人更倾向于使用FreeBSD而不是Linux这是因为FreeBSD才是绝对自由的软件没有任何控制许可的存在。Linux和FreeBSD还有其他的不同之处我建议您先不急着做出选择等读完本文后再做出您的选择。
#### 操作系统 ####
- Linux聚焦于内核系统这与FreeBSD不同FreeBSD的整个系统都被维护着。FreeBSD的内核和一组由FreeBSD团队开发的软件被作为一个整体进行维护。实际上FreeBSD开发人员能够远程且高效的管理核心操作系统。
- 而Linux方面在管理系统方面有一些困难。由于不同的组件由不同的源维护Linux开发者需要将它们汇集起来才能达到同样的功能。
- FreeBSD和Linux都给了用户大量的可选软件和发行版但他们管理的方式不同。FreeBSD是统一的管理方式而Linux需要被分别维护。
#### 硬件支持 ####
- 说到硬件支持Linux比FreeBSD做的更好。但这不意味着FreeBSD没有像Linux那样支持硬件的能力。他们只是在管理的方式不同这通常还依赖于您的需求。因此如果您在寻找最新的解决方案FreeBSD更适应您但如果您在寻找一幅宏大的画卷那最好使用Linux。
#### 原生FreeBSD Vs 原生Linux ####
- 两者的原生系统的区别又有不同。就像我之前说的Linux是一个Unix的替代系统由Linux Torvalds编写并由网络上的许多极客一起协助实现的。Linux有一个现代系统所需要的全部功能诸如虚拟内存、共享库、动态加载、优秀的内存管理等。它以GPL许可证发布。
- FreeBSD也继承了Unix的许多重要的特性。FreeBSD作为在加州大学开发的BSD的一种发行版。开发BSD的最重要的原因是用一个开源的系统来替代AT&T操作系统从而给用户无需AT&T证书便可使用的能力。
- 许可证的问题是开发者们最关心的问题。他们试图提供一个最大化克隆Unix的开源系统。这影响了用户的选择由于FreeBSD相比Linux使用BSD许可证进行发布因而更加自由。
#### 支持的软件包 ####
- 从用户的角度来看另一个二者不同的地方便是软件包以及对源码安装的软件的可用性和支持。Linux只提供了预编译的二进制包这与FreeBSD不同它不但提供预编译的包而且还提供从源码编译和安装的构建系统。由于这样的移植FreeBSD给了您选择使用预编译的软件包默认和在编译时定制您软件的能力。
- 这些可选组件允许您用FreeBSD构建所有的软件。而且它们的管理还是层次化的您可以在/usr/ports下找到源文件的地址以及一些正确使用FreeBSD的文档。
- 这些提到的可选组件给予了产生不同软件包版本的可能性。FreeBSD给了您通过源代码构建以及预编译的两种软件而不是像Linux一样只有预编译的软件包。您可以使用两种安装方式管理您的系统。
#### FreeBSD 和 Linux 常用工具比较 ####
- 有大量的常用工具在FreeBSD上可用并且有趣的是他们由FreeBSD的团队所拥有。相反的Linux工具来自GNU这就是为什么在使用中有一些限制。
- 实际上FreeBSD采用的BSD许可证非常有益且有用。因此您有能力维护核心操作系统控制这些应用程序的开发。有一些工具类似于它们的祖先 - BSD和Unix的工具但不同于GNU的套件GNU套件只想做到最小的向后兼容。
#### 标准 Shell ####
- FreeBSD默认使用tcsh。它是csh的评估版由于FreeBSD以BSD许可证发行因此不建议您在其中使用GNU的组件 bash shell。bash和tcsh的区别仅仅在于tcsh的脚本功能。实际上我们更推荐在FreeBSD中使用sh shell因为它更加可靠可以避免一些使用tcsh和csh时出现的脚本问题。
#### 一个更加层次化的文件系统 ####
- 像之前提到的一样使用FreeBSD时基础操作系统以及可选组件可以被很容易的区别开来。这导致了一些管理它们的标准。在Linux下/bin/sbin/usr/bin或者/usr/sbin都是存放可执行文件的目录。FreeBSD不同它有一些附加的对其进行组织的规范。基础操作系统被放在/usr/local/bin或者/usr/local/sbin目录下。这种方法可以帮助管理和区分基础操作系统和可选组件。
### 结论 ###
FreeBSD和Linux都是免费且开源的系统他们有相似点也有不同点。上面列出的内容并不能说哪个系统比另一个更好。实际上FreeBSD和Linux都有自己的特点和技术规格这使它们与别的系统区别开来。那么您有什么看法呢您已经有在使用它们中的某个系统了么如果答案为是的话请给我们您的反馈如果答案是否的话在读完我们的描述后您怎么看请在留言处发表您的观点。
--------------------------------------------------------------------------------
via: https://www.unixmen.com/comparative-introduction-freebsd-linux-users/
作者:[anismaj][a]
译者:[wwy-hust](https://github.com/wwy-hust)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:https://www.unixmen.com/author/anis/

View File

@ -0,0 +1,129 @@
如何更新Linux内核提升系统性能
================================================================================
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/update-linux-kernel-644x373.jpg?2c3c1f)
[Linux内核][1]内核的开发速度目前是空前大概每2到3个月就会有一个主要的版本发布。每个发布都带来让很多人的计算更加快、更加有效率、或者更好的功能和提升。
问题是你不能在这些内核发布的时候就用它们-你要等到你的发行版带来新内核的发布。我们先前发布了[定期更新内核的好处][2],你不必等到那时。我们会向你展示该怎么做。
> 免责声明: 我们先前的一些文章已经提到过,升级内核会带来(很小的)破坏你系统的风险。在这种情况下,通常可以通过旧内核来使系统工作,但是有时还是不行。因此我们对系统的任何损坏都不负责-你自己承担风险!
### 预备工作 ###
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/linux_kernel_arch.jpg?2c3c1f)
要更新你的内核你首先要确定你使用的是32位还是64位的系统。打开终端并运行
uname -a
检查一下输出的是x86_64还是i686。如果是x86_64你就运行64位的版本否则就运行32位的版本。记住这个因为这个很重要。
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/kernel_latest_version.jpg?2c3c1f)
接下来,访问[官方Linux内核网站][3],它会告诉你目前稳定内核的版本。如果你喜欢你可以尝试发布预选版,但是这比稳定版少了很多测试。除非你确定想要用发布预选版否则就用稳定内核。
### Ubuntu指导 ###
对Ubuntu及其衍生版的用户而言升级内核非常简单这要感谢Ubuntu主线内核PPA。虽然官方称为一个PPA。但是你不能像其他PPA一样用来添加它到你软件源列表中并指望它自动升级你的内核。而它只是一个简单的网页你可以下载到你想要的内核。
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/ubuntu_new_kernels.jpg?2c3c1f)
现在,访问[内核PPA网页][4]并滚到底部。列表的最下面会含有最新发布的预选版本你可以在名字中看到“rc”字样但是这上面就可以看到最新的稳定版为了更容易地解释这个这时最新的稳定版是4.1.2。点击它你会看到几个选项。你需要下载3个文件并保存到各自的文件夹中如果你喜欢的话可以在下载文件夹中这样就可以将它们相互隔离了:
- 针对架构的含“generic”的头文件我这里是64位或者“amd64”
- 中间的头文件在文件名末尾有“all”
- 针对架构的含“generic”内核文件再说一次我会用“amd64”但是你如果用32位的你需要使用“i686”
你会看到还有含有“lowlatency”的文件可以下面。但最好忽略它们。这些文件相对不稳定并且只为那些通用文件不能满足像录音这类任务想要低延迟的人准备的。再说一次首选通用版除非你特定的任务需求不能很好地满足。一般的游戏和网络浏览不是使用低延时版的借口。
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/ubuntu_install_kernel.jpg?2c3c1f)
你把它们放在各自的文件夹下,对么?现在打开终端,使用
cd
命令到新创建的文件夹下,像
cd /home/user/Downloads/Kernel
接着运行:
sudo dpkg -i *.deb
这个命令会标记所有文件夹的“.deb”文件为“待安装”接着执行安装。这是推荐的安装放大因为除非可以很简单地选择一个文件安装它总会报出依赖问题。这个方法可以避免这个问题。如果你不清楚cd和sudo是什么。快速地看一下[Linux基本命令][5]这篇文章。
安装完成后,**重启**你的系统这时应该就会运行刚安装的内核了你可以在命令行中使用uname -a来检查输出。
### Fedora指导 ###
如果你使用的是Fedora或者它的衍生版过程跟Ubuntu很类似。不同的是文件获取的位置不同安装的命令也不同。
![](http://cdn.makeuseof.com/wp-content/uploads/2015/07/fedora_new_kernels.jpg?2c3c1f)
查看[Fedora最新内核编译][6]列表。选取列表中最新的稳定版并滚到下面选择i686或者x86_64版。这依赖于你的系统架构。这时你需要下载下面这些文件并保存到它们对应的目录下比如“Kernel”到下载目录下
- kernel
- kernel-core
- kernel-headers
- kernel-modules
- kernel-modules-extra
- kernel-tools
- perf and python-perf (optional)
如果你的系统是i68632位同时你有4GB或者更大的内存你需要下载所有这些文件的PAE版本。PAE是用于32位的地址扩展技术上它允许你使用3GB的内存。
现在使用
cd
命令进入文件夹,像这样
cd /home/user/Downloads/Kernel
and then run the following command to install all the files:
接着运行下面的命令来安装所有的文件
yum --nogpgcheck localinstall *.rpm
最后**重启**你的系统,这样你就可以运行新的内核了!
### 使用 Rawhide ###
另外一个方案是Fedora用户也可以[切换到Rawhide][7]它会自动更新所有的包到最新版本包括内核。然而Rawhide经常会破坏系统尤其是在早期的开发版中它**不应该**在你日常使用的系统中用。
### Arch指导 ###
[Arch][8]应该总是使用的是最新和最棒的稳定版或者相当接近的版本。如果你想要更接近最新发布的稳定版你可以启用测试库提前2到3周获取到主要的更新。
要这么做,用[你喜欢的编辑器][9]以sudo权限打开下面的文件
/etc/pacman.conf
接着取消注释带有testing的三行删除行前面的井号。如果你想要启用multilib仓库就把multilib-testing也做相同的事情。如果想要了解更多参考[这个Arch的wiki界面][10]。
升级内核并不简单(有意这么做),但是这会给你带来很多好处。只要你的新内核不会破坏任何东西,你可以享受它带来的性能提升,更好的效率,支持更多的硬件和潜在的新特性。尤其是你正在使用相对更新的硬件,升级内核可以帮助到它。
**怎么升级内核这篇文章帮助到你了么?你认为你所喜欢的发行版对内核的发布策略应该是怎样的?**。在评论栏让我们知道!
--------------------------------------------------------------------------------
via: http://www.makeuseof.com/tag/update-linux-kernel-improved-system-performance/
作者:[Danny Stieben][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.makeuseof.com/tag/author/danny/
[1]:http://www.makeuseof.com/tag/linux-kernel-explanation-laymans-terms/
[2]:http://www.makeuseof.com/tag/5-reasons-update-kernel-linux/
[3]:http://www.kernel.org/
[4]:http://kernel.ubuntu.com/~kernel-ppa/mainline/
[5]:http://www.makeuseof.com/tag/an-a-z-of-linux-40-essential-commands-you-should-know/
[6]:http://koji.fedoraproject.org/koji/packageinfo?packageID=8
[7]:http://www.makeuseof.com/tag/bleeding-edge-linux-fedora-rawhide/
[8]:http://www.makeuseof.com/tag/arch-linux-letting-you-build-your-linux-system-from-scratch/
[9]:http://www.makeuseof.com/tag/nano-vs-vim-terminal-text-editors-compared/
[10]:https://wiki.archlinux.org/index.php/Pacman#Repositories

View File

@ -0,0 +1,72 @@
什么是逻辑分区管理工具它怎么在Ubuntu启用
================================================================================
> 逻辑分区管理LVM是每一个主流Linux发行版都含有的磁盘管理选项。无论你是否需要设置存储池或者只需要动态创建分区LVM就是你正在寻找的。
### 什么是 LVM? ###
逻辑分区管理是一个存在于磁盘/分区和操作系统之间的一个抽象层。在传统的磁盘管理中,你的操作系统寻找有哪些磁盘可用(/dev/sda、/dev/sdb等等接着这些磁盘有哪些可用的分区如/dev/sda1、/dev/sda2等等
在LVM下磁盘和分区可以抽象成一个设备中含有多个磁盘和分区。你的操作系统将不会知道这些区别因为LVM只会给操作系统展示你设置的卷组磁盘和逻辑卷分区
因此可以很容易地动态调整和创建新的磁盘和分区。除此之外LVM带来你的文件系统不具备的功能。比如ext3不支持实时快照但是如果你正在使用LVM你可以不卸载磁盘的情况下做一个逻辑卷的快照。
### 你什么时候该使用LVM ###
在使用LVM之前首先得考虑的一件事是你要用你的磁盘和分区完成什么。一些发行版如Fedora已经默认安装了LVM。
如果你使用的是一台只有一块磁盘的Ubuntu笔记本电脑并且你不需要像实时快照这样的扩展功能那么你或许不需要LVM。如果I想要轻松地扩展或者想要将多块磁盘组成一个存储池那么LVM或许正式你郑寻找的。
### 在Ubuntu中设置LVM ###
使用LVM首先要了解的一件事是没有简单的方法将已经存在传统的分区转换成逻辑分区。可以将它移到一个使用LVM的新分区下但是这并不会在本篇中提到反之我们将全新安装一台Ubuntu 10.10来设置LVM
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/ubuntu-10-banner.png)
要使用LVM安装Ubuntu你需要使用另外的安装CD。从下面的链接中下载并烧录到CD中或者[使用unetbootin创建一个USB盘][1]。
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/download-web.png)
从安装盘启动你的电脑并在磁盘选择界面选择整个磁盘并设置LVM。
*注意:这会格式化你的整个磁盘,因此如果正在尝试双启动或者其他的安装选择,选择手动。*
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/setup-1.png)
选择你想用的主磁盘,最典型的是使用你最大的磁盘,接着进入下一步。
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/setup-2.png)
你马上会将改变写入磁盘所以确保此时你选择的是正确的磁盘接着才写入设置。
![](http://cdn3.howtogeek.com/wp-content/uploads/2010/12/setup-3.png)
选择第一个逻辑卷的大小并继续。
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/setup-4.png)
确认你的磁盘分区并继续安装。
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/setup-5.png)
最后一步将GRUB的bootloader写到磁盘中。重点注意的是GRUB不能作为一个LVM分区因为计算机BIOS不能直接从逻辑卷中读取数据。Ubuntu将自动创建一个255MB的ext2分区用于bootloder。
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/setup-6.png)
安装完成之后。重启电脑并如往常一样进入Ubuntu。使用这种方式安装之后应该就感受不到LVM和传统磁盘管理之间的区别了。
![](http://cdn3.howtogeek.com/wp-content/uploads/2011/01/disk-manager.png)
要使用LVM的全部功能静待我们的下篇关于管理LVM的文章。
--------------------------------------------------------------------------------
via: http://www.howtogeek.com/howto/36568/what-is-logical-volume-management-and-how-do-you-enable-it-in-ubuntu/
作者:[How-To Geek][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://plus.google.com/+howtogeek?prsrc=5
[1]:http://www.howtogeek.com/howto/13379/create-a-bootable-ubuntu-9.10-usb-flash-drive/

View File

@ -0,0 +1,185 @@
新手应知应会的Linux命令
================================================================================
![Manage system updates via the command line with dnf on Fedora.](http://www.linux.com/images/stories/41373/fedora-cli.png)
在Fedora上通过命令行使用dnf来管理系统更新
基于Linux的系统的优点之一就是你可以通过终端中使用命令该ing来管理整个系统。使用命令行的优势在于你可以使用相同的知识和技能来管理随便哪个Linux发行版。
对于各个发行版以及桌面环境DE而言要一致地使用图形化用户界面GUI却几乎是不可能的因为它们都提供了各自的用户界面。要明确的是有那么些情况你需要在不同的发行版上使用不同的命令来部署某些特定的任务但是或多或少它们的概念和意图却仍然是一致的。
在本文中我们打算讨论Linux用户应当掌握的一些基本命令。我将给大家演示怎样使用命令行来更新系统、管理软件、操作文件以及切换到root这些操作将在三个主要发行版上进行Ubuntu也包括其定制版和衍生版还有DebianopenSUSE以及Fedora。
*让我们开始吧!*
### 保持系统安全和最新 ###
Linux是基于安全设计的但事实上是任何软件都有缺陷会导致安全漏洞。所以保持你的系统更新到最新是十分重要的。这么想吧运行过时的操作系统就像是你坐在全副武装的坦克里头而门却没有锁。武器会保护你吗任何人都可以进入开放的大门对你造成伤害。同样在你的系统中也有没有打补丁的漏洞这些漏洞会危害到你的系统。开源社区不像专利世界在漏洞补丁方面反应是相当快的所以如果你保持系统最新你也获得了安全保证。
留意新闻站点,了解安全漏洞。如果发现了一个漏洞,请阅读之,然后在补丁出来的第一时间更新。不管怎样,在生产机器上,你每星期必须至少运行一次更新命令。如果你运行这一台复杂的服务器,那么就要额外当心了。仔细阅读变更日志,以确保更新不会搞坏你的自定义服务。
**Ubuntu**牢记一点你在升级系统或安装不管什么软件之前都必须要刷新仓库也就是repos。在Ubuntu上你可以使用下面的命令来更新系统第一个命令用于刷新仓库
sudo apt-get update
仓库更新后,现在你可以运行系统更新命令了:
sudo apt-get upgrade
然而,这个命令不会更新内核和其它一些包,所以你也必须要运行下面这个命令:
sudo apt-get dist-upgrade
**openSUSE**如果你是在openSUSE上你可以使用以下命令来更新系统照例第一个命令的意思是更新仓库
sudo zypper refresh
sudo zypper up
**Fedora**如果你是在Fedora上你可以使用'dnf'命令它是zypper和apt-get的'同类'
sudo dnf update
sudo dnf upgrade
### 软件安装与移除 ###
你只可以安装那些你系统上启用的仓库中可用的包,各个发行版默认都附带有并启用了一些官方或者第三方仓库。
**Ubuntu**: To install any package on Ubuntu, first update the repo and then use this syntax:
**Ubuntu**要在Ubuntu上安装包首先更新仓库然后使用下面的语句
sudo apt-get install [package_name]
样例:
sudo apt-get install gimp
**openSUSE**:命令是这样的:
sudo zypper install [package_name]
**Fedora**Fedora已经丢弃了'yum',现在换成了'dnf',所以命令是这样的:
sudo dnf install [package_name]
移除软件的过程也一样,只要把'install'改成'remove'。
**Ubuntu**
sudo apt-get remove [package_name]
**openSUSE**
sudo zypper remove [package_name]
**Fedora**
sudo dnf remove [package_name]
### 如何管理第三方软件? ###
在一个庞大的开发者社区中,这些开发者们为用户提供了许多的软件。不同的发行版有不同的机制来使用这些第三方软件,将它们提供给用户。同时也取决于开发者怎样将这些软件提供给用户,有些开发者会提供二进制包,而另外一些开发者则将软件发布到仓库中。
Ubuntu严重依赖于PPA个人包归档但是不幸的是它却没有提供一个内建工具来帮助用于搜索这些PPA仓库。在安装软件前你将需要通过Google搜索PPA然后手工添加该仓库。下面就是添加PPA到系统的方法
sudo add-apt-repository ppa:<repository-name>
样例比如说我想要添加LibreOffice PPA到我的系统中。我应该Google该PPA然后从Launchpad获得该仓库的名称在本例中它是"libreoffice/ppa"。然后使用下面的命令来添加该PPA
sudo add-apt-repository ppa:libreoffice/ppa
它会要你按下回车键来导入秘钥。完成后,使用'update'命令来刷新仓库,然后安装该包。
openSUSE拥有一个针对第三方应用的优雅的解决方案。你可以访问software.opensuse.org一键点击搜索并安装相应包它会自动将对应的仓库添加到你的系统中。如果你想要手工添加仓库可以使用该命令
sudo zypper ar -f url_of_the_repo name_of_repo
sudo zypper ar -f http://download.opensuse.org/repositories/LibreOffice:Factory/openSUSE_13.2/LibreOffice:Factory.repo LOF
然后,刷新仓库并安装软件:
sudo zypper refresh
sudo zypper install libreoffice
Fedora用户只需要添加RPMFusionfree和non-free仓库一起该仓库包含了大量的应用。如果你需要添加仓库命令如下
dnf config-manager --add-repo http://www.example.com/example.repo
### 一些基本命令 ###
我已经写了一些关于使用CLI来管理你系统上的文件的[文章][1]下面介绍一些基本米ing令这些命令在所有发行版上都经常会用到。
拷贝文件或目录到一个新的位置:
cp path_of_file_1 path_of_the_directory_where_you_want_to_copy/
将某个目录中的所有文件拷贝到一个新的位置(注意斜线和星号,它指的是该目录下的所有文件):
cp path_of_files/* path_of_the_directory_where_you_want_to_copy/
将一个文件从某个位置移动到另一个位置(尾斜杠是说在该目录中):
mv path_of_file_1 path_of_the_directory_where_you_want_to_move/
将所有文件从一个位置移动到另一个位置:
mv path_of_directory_where_files_are/* path_of_the_directory_where_you_want_to_move/
删除一个文件:
rm path_of_file
删除一个目录:
rm -r path_of_directory
移除目录中所有内容,完整保留目录文件夹:
rm -r path_of_directory/*
### 创建新目录 ###
要创建一个新目录首先输入你要创建的目录的位置。比如说你想要在你的Documents目录中创建一个名为'foundation'的文件夹。让我们使用 cd 即change directory改变目录命令来改变目录
cd /home/swapnil/Documents
(替换'swapnil'为你系统中的用户)
然后,使用 mkdir 命令来创建该目录:
mkdir foundation
你也可以从任何地方创建一个目录,通过指定该目录的路径即可。例如:
mdkir /home/swapnil/Documents/foundation
如果你想要创建父-子目录,那是指目录中的目录,那么可以使用 -p 选项。它会在指定路径中创建所有目录:
mdkir -p /home/swapnil/Documents/linux/foundation
### 成为root ###
你或许需要成为root或者具有sudo权力的用户来实施一些管理任务如管理软件包或者对根目录或其下的文件进行一些修改。其中一个例子就是编辑'fstab'文件,该文件记录了挂载的硬件驱动器。它在'etc'目录中,而该目录又在根目录中,你只能作为超级用户来修改该文件。在大多数的发行版中,你可以通过'切换用户'来成为root。比如说在openSUSE上我想要成为root因为我要在根目录中工作你可以使用下面的命令之一
sudo su -
su -
该命令会要求输入密码然后你就具有root特权了。记住一点千万不要以root用户来运行系统除非你知道你正在做什么。另外重要的一点需要注意的是你以root什么对目录或文件进行修改后会将它们的拥有关系从该用户或特定的服务改变为root。你必须恢复这些文件的拥有关系否则该服务或用户就不能访问或写入到那些文件。要改变用户命令如下
sudo chown -R user:user /path_of_file_or_directory
当你将其它发行版上的分区挂载到系统中时,你可能经常需要该操作。当你试着访问这些分区上的文件时,你可能会碰到权限拒绝错误,你只需要改变这些分区的拥有关系就可以访问它们了。需要额外当心的是,不要改变根目录的权限或者拥有关系。
这些就是Linux新手们需要的基本命令。如果你有任何问题或者如果你想要我们涵盖一个特定的话题请在下面的评论中告诉我们吧。
--------------------------------------------------------------------------------
via: http://www.linux.com/learn/tutorials/842251-must-know-linux-commands-for-new-users
作者:[Swapnil Bhartiya][a]
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.linux.com/community/forums/person/61003
[1]:http://www.linux.com/learn/tutorials/828027-how-to-manage-your-files-from-the-command-line