配置 centos7 ip地址:

vi /etc/sysconfig/network-scripts/ifcfg-ens33
    BOOTPROTO=static
    ONBOOT=yes
    NM_CONTROLLED=no
    IPADDR=
    NATMASK=
    GATEWAY=
    DNS1=
    DNS2=

 

安装ifconfig:

  ifconfig 不可使用,检查 cd /sbin 目录 ls | grep ifconfig,如果没有则

    yum search ifconfig



[root@localhost ~]# yum search ifconfig
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.shu.edu.cn
========================================= 匹配:ifconfig ==========================================
net-tools.x86_64 : Basic networking tools


yum install -y net-tools.x86_64

安装vim:



[root@localhost ~]# yum search vim
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.cn99.com
 * updates: mirrors.shu.edu.cn
======================================== N/S matched: vim =========================================
protobuf-vim.x86_64 : Vim syntax highlighting for Google Protocol Buffers descriptions
vim-X11.x86_64 : The VIM version of the vi editor for the X Window System
vim-common.x86_64 : The common files needed by any version of the VIM editor
vim-enhanced.x86_64 : A version of the VIM editor which includes recent enhancements
vim-filesystem.x86_64 : VIM filesystem layout
vim-minimal.x86_64 : A minimal version of the VIM editor

  名称和简介匹配 only,使用“search all”试试。
[root@localhost ~]# yum install -y vim-enhanced.x86_64



  yum install -y vim-enhanced.x86_64

 

配置centos7 hostname:

  同时修改三个状态主机名:静态、瞬态和灵活主机名:

hostnamectl set-hostname 主机名

    hostnamectl --static
    hostnamectl --transient
    hostnamectl --pretty

就像上面展示的那样,在修改静态/瞬态主机名时,任何特殊字符或空白字符会被移除,而提供的参数中的任何大写字母会自动转化为小写。一旦修改了静态主机名,/etc/hostname 将被自动更新。然而,/etc/hosts 不会更新以保存所做的修改,所以你每次在修改主机名后一定要手动更新/etc/hosts,之后再重启CentOS 7。否则系统再启动时会很慢。

手动更新/etc/hosts
    vim /etc/hosts
    127.0.0.1    主机名
    #127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain
    ::1        localhost localhost.localdomain localhost6 localhost6.localdomai 安装wget:
  yum install -y wget
配置yum源:
  cd /etc/yum.repos.d/
  mv CentOS-Base.repo CentOS-Base.repo.bak



[root@centos7-12 yum.repos.d]# ll
总用量 32
-rw-r--r--. 1 root root 1664 4月  29 00:35 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 4月  29 00:35 CentOS-CR.repo
-rw-r--r--. 1 root root  649 4月  29 00:35 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 4月  29 00:35 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 4月  29 00:35 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月  29 00:35 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 4月  29 00:35 CentOS-Vault.repo
[root@centos7-12 yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[root@centos7-12 yum.repos.d]# ll
总用量 32
-rw-r--r--. 1 root root 1664 4月  29 00:35 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 4月  29 00:35 CentOS-CR.repo
-rw-r--r--. 1 root root  649 4月  29 00:35 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 4月  29 00:35 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 4月  29 00:35 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月  29 00:35 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 4月  29 00:35 CentOS-Vault.repo



wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo



[root@centos7-12 yum.repos.d]# ll
总用量 36
-rw-r--r--. 1 root root 2523 6月  16 06:22 CentOS-Base.repo
-rw-r--r--. 1 root root 1664 4月  29 00:35 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 4月  29 00:35 CentOS-CR.repo
-rw-r--r--. 1 root root  649 4月  29 00:35 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 4月  29 00:35 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 4月  29 00:35 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 4月  29 00:35 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 4月  29 00:35 CentOS-Vault.repo
[root@centos7-12 yum.repos.d]#



   yum clean all

   yum makecache

 

按照该文件所说的,runlevels被targets所取代,即CentOS7采用加载target的方式来替代之前的启动级别。其中有两个重要的target:multi-user.target与graphical.target。它们分别表示运行级别中的3与5级别。

  通过systemctl get-default可获得默认启动的target

  通过systemctl set-default设置默认启动的target

  那么,想修改为多用户状态只需执行:

systemctl set-default multi-user.target

  修改为图形界面执行:systemctl set-default graphical.target

修改时区:

timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海
timedatectl list-timezones # 列出所有时区 
timedatectl set-local-rtc 1 # 将硬件时钟调整为与本地时钟一致, 
0 为设置为 UTC 时间 
timedatectl set-timezone Asia/Shanghai # 设置系统时区为上海 
其实不考虑各个发行版的差异化, 从更底层出发的话, 修改时间时区比想象中要简单: 
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
1.  安装ntpdate工具
 
  
 
# yum -y install ntp ntpdate
 
  
 
2.  设置系统时间与网络时间同步
 
  
 
# ntpdate cn.pool.ntp.org
vim /etc/crontab
 */5 *  *  *  * root    ntpdate cn.pool.ntp.org 
 
3.  将系统时间写入硬件时间
 
  
 
# hwclock --systohc
 
  
 
4.强制系统时间写入CMOS中防止重启失效
 
  
 
# hwclock -w 
 
  
 
或# clock -w