1. 修改网卡名:
    1. 修改网卡配置文件:
      vi /etc/sysconfig/network-scripts/ifcfg-ens33
      TYPE=Ethernet
      BOOTPROTO=static
      DEFROUTE=yes
      PEERDNS=yes
      PEERROUTES=yes
      IPV4_FAILURE_FATAL=no
      IPV6INIT=yes
      IPV6_AUTOCONF=yes
      IPV6_DEFROUTE=yes
      IPV6_PEERDNS=yes
      IPV6_PEERROUTES=yes
      IPV6_FAILURE_FATAL=no
      NAME=eth0
      DEVICE=eth0
      ONBOOT=yes
      IPADDR=192.168.8.81
      NETMASK=255.255.255.0
      GATEWAY=192.168.8.1
      DNS1=8.8.8.8
      DNS2=114.114.114.114
    2. 改名:
      mv /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-eth0
    3. 修改引导文件配置:
      vi /etc/default/grub
      GRUB_TIMEOUT=5
      GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
      GRUB_DEFAULT=saved
      GRUB_DISABLE_SUBMENU=true
      GRUB_TERMINAL_OUTPUT="console"
      GRUB_CMDLINE_LINUX="rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet net.ifnames=0 biosdevname=0"
      GRUB_DISABLE_RECOVERY="true"
    4. 更新内核:
      grub2-mkconfig -o /boot/grub2/grub.cfg
    5. 重启:
      reboot
    6. 查看网络配置:
      ip a
  2. 添加网卡:
    1. 添加新网卡:


    2. 添加新网卡的配置文件:
      cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
      TYPE=Ethernet
      BOOTPROTO=static
      DEFROUTE=yes
      PEERDNS=yes
      PEERROUTES=yes
      IPV4_FAILURE_FATAL=no
      IPV6INIT=yes
      IPV6_AUTOCONF=yes
      IPV6_DEFROUTE=yes
      IPV6_PEERDNS=yes
      IPV6_PEERROUTES=yes
      IPV6_FAILURE_FATAL=no
      NAME=eth1
      DEVICE=eth1
      ONBOOT=yes
      IPADDR=192.168.8.201
      NETMASK=255.255.255.0
      GATEWAY=192.168.8.1
      DNS1=8.8.8.8
      DNS2=114.114.114.114
    3. 重启网络:
      systemctl restart network
    4. 测试:
      ip a
  3. 修改系统时间:
    1. 自动同步:
      1. 修改时区:
        \cp -a /usr/share/zoneinfo/PRC /etc/localtime
      2. 安装ntpdate(端口:udp 123):
        yum -y install ntp
      3. 同步时间命令:
        /usr/sbin/ntpdate us.pool.ntp.org
      4. 加入计划任务(每10分钟同步一次):
        */10 * * * * /usr/sbin/ntpdate  us.pool.ntp.org(国外)
        */10 * * * * /usr/sbin/ntpdate  cn.pool.ntp.org(国内)
    2. 手动修改:
      1. 更改系统时间:
        date -s "2017-12-18 09:40:00"
      2. 写入系统时间:
        hwclock -w
  4. 修改主机名:
    1. 永久修改:
      vi /etc/hostname
    2. 临时修改:
      hostname lee
    3. 查看:
      hostname
  5. 修改系统语言:
    1. 永久:
      vi /etc/profile,添加
      export  LANG="zh_CN.UTF-8"export  LANG="en_US.UTF-8"
    2. 临时:
      命令行下
      LANG="zh_CN.UTF-8"
  6. 别名设置:
    1. 添加:
      alias ll='ls -lah --color'
    2. 删除:
      unalias ll
  7. 配置yum源:
    1. 删除旧的源:
      yum  -y  install  wget
      rm  -rf  /etc/yum.repos.d/*
    2. 下载.repo文件:
      wget  -O  /etc/yum.repos.d/centos7.repo  http://mirrors.aliyun.com/repo/Centos-7.repo
      wget  -O  /etc/yum.repos.d/centos7-epel.repo  http://mirrors.aliyun.com/repo/epel-7.repo
    3. 生成缓存:
      yum clean all
      yum makecache
    4. 下载epel-release:
      yum -y install epel-release
  8. 配置自己的yum源:
    1. 安装软件:
      yum -y install createrepo yum-utils
    2. 设置yum源为阿里的镜像:
      wget  -O  /etc/yum.repo.d/ali.repo  http://mirrors.aliyun.com/repo/Centos-7.repo
      wget  -O  /etc/yum.repo.d/epel.repo  http://mirrors.aliyun.com/repo/epel-7.repo
    3. 同步阿里的镜像到本地:
      1. 创建文件夹:
        mkdir -p /home/lee/local
      2. 同步阿里的rpm包:
        nohup reposync -p /home/lee/
      3. 将所有的rpm包移动到/home/lee/local中:
        mv  /home/lee/base/Pachage/*  /home/lee/local/
        mv  /home/lee/update/Pachage/*  /home/lee/local/
        mv  /home/lee/epel/Pachage/*  /home/lee/local/
        mv  /home/lee/extra/Pachage/*  /home/lee/local/
      4. 用createrepo创建本地yum源:
        createrepo /home/lee/ #注意,不是local
    4. 更改yum源为自己的镜像:
      vim /etc/yum.repo.d/local.repo,添加:
      [local]
      name=local repo
      baseurl=file:///home/lee/
      gpgcheck=1
      gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
      enabled=1
  9. vim配置:
    1. 配置:
      vim ~/.vimrc
      set nocompatible
      set number
      set ruler
      set nowrap
      set showcmd
      set history=1000
      set nobackup
      set noswapfile
      "set cursorline
      "set cursorcolumn
      set showmatch
      set autoindent
      set cindent
      syntax enable
      syntax on
      set t_Co=256
      set ignorecase
      "set mouse=a
      set tabstop=4
      set shiftwidth=4
      set softtabstop=4
      set smarttab
      set expandtab
      set encoding=utf-8
      set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
      set ff=unix
      filetype on
      filetype indent on
      filetype plugin on
      filetype plugin indent on
    2. 修改默认编辑器:
      vim /etc/profile
      export EDITOR=/usr/bin/vim
  10. 安装网络工具:
    1. 网卡诊断:
      yum -y install net-tools
    2. 路由诊断:
      yum -y install bind-utils
  11. 安装开发者工具:
    yum -y groupinstall "development tools"
  12. 关闭selinux:
    1. 修改配置文件:
      vim /etc/selinux/config
      将
      SELINUX=enforcing
      改为
      SELINUX=disabled
    2. 临时生效:
      setenforce 0
  13. 移除firewalld、添加iptables:
    1. 移除firewalld:
      yum -y remove firewalld
    2. 添加iptables:
      yum -y install iptables iptables-services
    3. 启用iptables:
      systemctl enable iptables
  14. 修改ssh端口:
    1. 打开配置文件:
      vim /etc/ssh/sshd_config
    2. 找到port:
      Port 22
  15. 修改欢迎语:
    vim /etc/motd
    Happy codding!!!
  16. 查看 linux 发型版本:
    lsb_release -a
文档更新时间: 2020-08-07 18:49   作者:lee