Linux
<h2><a href="http://hwj80.cf/" title="KodExplorer">KodExplorer</a></h2>
<h3><a href="https://tool.lu/c/developer/">实用在线开发工具</a></h3>
<h4><a href="#aria2安装">aria2 安装</a></h4>
<h4><a href="#BBR加速器安装">BBR 加速器安装</a></h4>
<h4><a href="#DNS配置">DNS 配置</a></h4>
<h4><a href="#IP地址设置">IP 地址设置</a></h4>
<h4><a href="#Linux开机启动服务添加">Linux 开机启动服务添加</a></h4>
<h4><a href="#yum离线安装包下载">yum 离线安装包下载</a></h4>
<h4><a href="#CentOs最好用的YUM源">最好用的YUM源</a></h4>
<p>[========]</p>
<h4>时区设置</h4>
<pre><code>ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
grep "CST-8" /etc/profile||echo export TZ=\'CST-8\'>>/etc/profile;source /etc/profile</code></pre>
<p>[=======]</p>
<h4>aria2安装</h4>
<pre><code class="language-sh">wget http://ftp.tu-chemnitz.de/pub/linux/dag/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum -y install aria2</code></pre>
<p>[========]</p>
<h4>BBR加速器安装</h4>
<p><code>无效则参考如下教程</code>
<a href="https://www.centos.bz/2018/01/centos-7%E5%AE%89%E8%A3%85bbr%E6%95%99%E7%A8%8B/">BBR安装</a></p>
<pre><code class="language-shell">wget -O- http://soft.wellphp.com/scripts/install_bbr_centos.sh | bash</code></pre>
<pre><code>sysctl -a|grep congestion_control
sysctl net.ipv4.tcp_congestion_controlnet.core.default_qdisc</code></pre>
<p>重新启动之后,输入 lsmod | grep bbr 如果看到 tcp_bbr 就说明 BBR 已经启动了。</p>
<p>[========]</p>
<h4>DNS配置</h4>
<pre><code class="language-shell">vim /etc/sysconfig/network-scripts/ifcfg-eth0</code></pre>
<p>添加如下内容</p>
<pre><code>DNS1=8.8.8.8
DNS2=1.2.4.8</code></pre>
<p>DNS 查询</p>
<pre><code>cat /etc/resolv.conf</code></pre>
<p>[========]</p>
<h4>IP地址设置</h4>
<pre><code>vim /etc/sysconfig/network-scripts/ifcfg-eth0</code></pre>
<p>重启网络服务</p>
<pre><code>service network restart</code></pre>
<h4>Linux开机启动服务添加</h4>
<p><code>vim /etc/init.d/v2ray</code></p>
<pre><code class="language-sh">#!/bin/sh
# chkconfig: 2345 10 90
# description: v2rayserver
nohup /root/v2ray/v2ray -config /root/v2ray/config.json &
nohup /usr/local/v2ray/v2ray -config /usr/local/v2ray/config.json >/dev/null 2>&1 &
</code></pre>
<pre><code class="language-sh">chmod +x /etc/init.d/v2ray
chkconfig --add v2ray
chkconfig --level 2345 v2ray on</code></pre>
<p>[========]</p>
<table>
<thead>
<tr>
<th>代表意义</th>
<th>分钟</th>
<th>小时</th>
<th>日期</th>
<th>月份</th>
<th>周</th>
<th>命令</th>
</tr>
</thead>
<tbody>
<tr>
<td>数字范围</td>
<td>0~59</td>
<td>0~23</td>
<td>1~31</td>
<td>1~12</td>
<td>0~7</td>
<td>就命令啊</td>
</tr>
</tbody>
</table>
<h5>周的数字为0或7时,都代表“星期天”的意思。另外,还有一些辅助的字符,大概有下面这些:</h5>
<table>
<thead>
<tr>
<th>特殊字符</th>
<th>代表意义</th>
</tr>
</thead>
<tbody>
<tr>
<td>*(星号)</td>
<td>代表任何时刻都接受的意思。举例来说,范例一内那个日、月、周都是*,就代表着不论何月、何日的礼拜几的12:00都执行后续命令的意思。</td>
</tr>
<tr>
<td>,(逗号)</td>
<td>代表分隔时段的意思。举例来说,如果要执行的工作是3:00与6:00时,就会是:0 3,6 <em> </em> * command 时间还是有五列,不过第二列是 3,6 ,代表3与6都适用</td>
</tr>
<tr>
<td>-(减号)</td>
<td>代表一段时间范围内,举例来说,8点到12点之间的每小时的20分都进行一项工作:20 8-12 <em> </em> * command仔细看到第二列变成8-12.代表 8,9,10,11,12 都适用的意思</td>
</tr>
<tr>
<td>/n(斜线)</td>
<td>那个n代表数字,即是每隔n单位间隔的意思,例如每五分钟进行一次,则:<em>/5 </em> <em> </em> <em> command用</em>与/5来搭配,也可以写成0-59/5,意思相同</td>
</tr>
</tbody>
</table>
<p>cron文件语法:</p>
<pre><code>分 小时 日 月 星期 命令
0-59 0-23 1-31 1-12 0-6 command (取值范围,0表示周日一般一行对应一个任务)</code></pre>
<h5>记住几个特殊符号的含义:</h5>
<blockquote>
<p>“*”代表取值范围内的数字,
“/”代表”每”,
“-”代表从某个数字到某个数字,
“,”分开几个离散的数字</p>
</blockquote>
<h3>mail配置</h3>
<p>1、安装mailx</p>
<pre><code>yum install mailx</code></pre>
<p>2、编辑配置文件,新增如下内容</p>
<pre><code>vim /etc/mail.rc</code></pre>
<pre><code>set from=Code@paxsz.com
set smtp=mail.paxsz.com</code></pre>
<p>3、发送测试</p>
<pre><code>echo "代码同步失败,请及时检查..."|mail -s "代码同步监控" huangwj@paxsz.com</code></pre>
<h4>CentOs最好用的YUM源</h4>
<p>CentOS 系列的服务器系统有一个毛病,就是官方自带的源的软件比较古老,并且很多的软件都没有。因为他们的首要任务是保证服务器的稳定,而不是追求最新。但是太过于保守了,一般来说,我们会给服务器添加一个 epel-release 这个源。这个源里包含了例如 nginx 之类的我们需要的软件,使用起来比较方便。</p>
<pre><code>#服务器系统以及软件升级命令
yum -y update
#安装 epel-release
yum install epel-release -y
#通过上面的命令进行安装。确认是否安装成功,可以用下面的命令检测一下
yum search nginx</code></pre>
<p><a href="https://opsx.alibaba.com/mirror">阿里巴巴开源镜像</a></p>
<pre><code>cd /etc/yum.repos.d/
yum -y install wget
mv -f CentOS-Base.repo CentOS-Base.repo.bak
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O CentOS-Base.repo
yum clean all
yum makecache
yum update
</code></pre>
<h3>yum离线安装包下载</h3>
<p>安装yum-plugin-downloadonly插件</p>
<pre><code>yum install -y yum-plugin-downloadonly</code></pre>
<p>下载对应的软件包,我们以mysql为例,终端输入如下命令</p>
<pre><code>yum install -y --downloadonly --downloaddir=/soft/mysql mysql</code></pre>
<p>--downloaddir用来指定下载的路径</p>
<p>下载的mysql软件包</p>
<p>通过--downloadonly参数也会同时将所依赖的rpm一起下载下来,通过rpm -ivh命令或者yum localinstall可以在没有网的情况下方便的安装。</p>
<p>修改centos7系统语言
查看系当前语言包</p>
<pre><code>locale</code></pre>
<p>查看系统拥有语言包</p>
<pre><code>locale -a|grep zh</code></pre>
<p>(zh_CN.UTF-8是简体中文,如果没有zh_CN.UTF-8,就安装语言包,如果存在可以直接设置)</p>
<p>安装简体中文语言包</p>
<pre><code>yum install kde-l10n-Chinese</code></pre>
<p>设置为中文
临时修改,重启服务器之后就会还原之前的设置
LANG="zh_CN.UTF-8" #修改为中文
LANG="en_US.UTF-8" #修改为英文
永久修改就要把配置写入文件里面</p>
<p>方法(一)</p>
<pre><code>vim /etc/locale.conf
#加下面内容到第一行,设置中文
LANG=zh_CN.UTF8</code></pre>
<p>方法(二)</p>
<pre><code>localectl set-locale LANG=zh_CN.UTF8</code></pre>