Change Hostname in CentOS 6.5/7

Change Hostname in CentOS 6.5/7

CentOS 6.5

[1] Change hostname with a commnad (but if rebooting, it will be back).

[root@vpsmate ~]# hostname              # show current hostname
srv1.vpsmate.net
[root@vpsmate ~]# hostname srv2.vpsmate.net         # change hostname
[root@vpsmate ~]# hostname
srv2.vpsmate.net
[2] Change hostname permanently.

[root@vpsmate ~]# vi /etc/sysconfig/network     # change
HOSTNAME=srv2.vpsmate.net
[root@vpsmate ~]# exit
CentOS release 6.5
Kernel xxx
srv2.vpsmate.net login:                 # changed

CentOS 7

[1]Change hostname with a commnad (but if rebooting, it will be back).

[root@vpsmate ~]# hostname                  # show current hostname
srv1.vpsmate.net
[root@vpsmate ~]# hostname srv2.vpsmate.net         # change hostname
[root@vpsmate ~]# hostname
srv2.vpsmate.net
[2] Change hostname permanently.

view source
[root@vpsmate ~]# vi /etc/hostname          # change
srv1.vpsmate.net
[root@vpsmate ~]# exit
CentOS Linux 7
Kernel 3.10.0-123.4.2.el7.x86_64 on an x86_64
srv1 login:                         # just changed
 

CentOS 多网卡配置,网卡重命名

CentOS 多网卡配置
1:添加一块或多块网卡     
2:cd /etc/udev/rules.d/
3:cat 70-persistent-net.rules  #查看网卡的名称 NAME="eth1",并记录MAC等信息。
4:cd /etc/sysconfig/network-scripts
5:cp ifcfg-eth0 ifcfg-eth1
6:vi ifcfg-eth1
7:修改DEVICE=eth0 ,修改HWADDR
8:nmcli con  查看网卡UUID,并修改原来的,或者注释掉UUID  (#UUID)
9:reboot


CentOS 网卡重命名
eth0 rename4

1:cd /etc/sysconfig/network-scripts
2:vi ifcfg-eth1
3:修改DEVICE=eth1
4:cd /etc/udev/rules.d/
5:70-persistent-net.rules  #存储网卡标识
6:vi 70-persistent-net.rules  #编辑
7:reboot

CentOS ETH (1)

CentOS ETH (2)

CentOS ETH (3)

CentOS ETH (4)

NGINX 配置404错误页面

NGINX 配置404错误页面

1、创建自己的404.html页面 

2、编辑nginx.conf在http定义区域加入:fastcgi_intercept_errors on; 

3、编辑nginx.conf或虚拟主机的域名.conf在server 区域加入:

error_page 404 /404.html;

4、测试nginx.conf正确性:

#/usr/local/nginx/sbin/nginx -t

the configuration file /opt/nginx/conf/nginx.conf syntax is ok 
configuration file /opt/nginx/conf/nginx.conf test is successful

5、重启nginx生效

#/usr/local/nginx/sbin/nginx -s reload

6、502 等错误可以用同样的方法来配置。  

error_page  500 502 503 504  /50x.html; 

Nginx 404 (1)

Nginx 404 (2)

Linux安装中文的man包

Linux安装中文的man包

#wget http://manpages-zh.googlecode.com/files/manpages-zh-1.5.1.tar.gz
#tar zxvf manpages-zh-1.5.1.tar.gz     
#cd manpages-zh-1.5.1
#./configure --prefix=/usr/local/zhman --disable-zhtw             
#make
#make install
#cd ~  (回到当前用户主目录)
#vi .bashrc (在.bashrc中增加:alias cman='man -M /usr/local/zhman/share/man/zh_CN',保存)         
#source .bashrc          (使刚刚添加的alias生效)
(系统默认语言与编码要修改为LANG="zh_CN.UTF-8,不然cman会显示乱码)
修改系统默认语言与编码(中文)
#vi /etc/sysconfig/i18n
  1 LANG="en_US.UTF-8"
  2 SYSFONT="latarcyrheb-sun16"
将LANG="en_US.UTF-8" 修改成 LANG="zh_CN.UTF-8"
ESC退出编辑,:wq或输入两次大写字母ZZ,保存并退出vi。

#reboot
(可以用自带的man,还可以用安装的中文cman)
#cman shutdown
#man shutdown
ctrl+b  (向上翻屏)
ctrl+f  (向下翻屏)
#q  (退出手册)

cman man

CentOS安装nmap端口查看工具

nmap即(Network Mapper),是linux系统中一个常用的网络管理工具,可以扫描端口、嗅探主机所在的网络环境等。
一、安装nmap
#yum -y install nmap
二、使用nmap
#nmap localhost    #查看主机当前开放的端口
#nmap -p 20-65535 localhost    #查看主机端口(20-65535)中开放的端口
#nmap -PS 107.161.19.25       #探测目标主机开放的端口
#nmap --help  #更多nmap参数请查询帮助信息
三、关闭或者打开主机端口
1、nmap localhost    #查看主机当前开放端口
2、ntsysv            #打开系统服务器管理器(需要先安装yum install ntsysv),选择要关闭或者打开的服务

中文参考指南:http://nmap.org/man/zh/

NMAP

Linux network no find eth0

Linux network no find eth0
适用于:
1:Red Hat Linux
2:CentOS
#/etc/sysconfig/network-scripts
#vi ifcfg-eth0
#将ONBOOT=no,设置为ONBOOT=yes。
#service network restart

eth0 (1) eth0 (2) eth0 (3) eth0 (4) eth0 (5) eth0 (6) eth0 (7) eth0 (8)