zoukankan      html  css  js  c++  java
  • 02.CentOS Linux 7.7 系统配置文档

    一、系统服务配置

    1.1.网卡配置修改

    [root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

    DEVICE=ens33

    ONBOOT=yes

    TYPE=Ethernet

    NM_CONTROLLED=yes

    BOOTPROTO=Static

    IPADDR=192.168.10.11

    NETMASK=255.255.255.0

    GATEWAY=192.168.10.254

    DNS1=202.106.0.20

    DNS2=114.114.114.114

    [root@localhost ~]# systemctl restart network

    1.2.SElinux配置修改

    [root@localhost ~]# vim /etc/sysconfig/selinux

    #配置文件

    SELINUX=enforcing    修改为     SELINUX=disabled

    1.3.本地YUM源配置修改

    [root@localhost ~]# mkdir /media/cdrom

    [root@localhost ~]# mount /dev/sr0 /media/cdrom/

    [root@localhost ~]# cd /etc/yum.repos.d/

    [root@localhost ~]# vim /etc/yum.repos.d/CentOS-7.7.repo

    #配置文件

    [CentOS_Server]

    name=CentOS repo

    baseurl=file:///media/cdrom

    enabled=1

    gpgcheck=0

    #gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

    1.1.1.设置开机自动挂载

    [root@localhost ~]# vim /etc/fstab

    #配置文件

    /dev/cdrom    /media/cdrom      iso9660    defaults     0 0

    [root@localhost ~]# yum clean all                  /*清理*/

    [root@localhost ~]# yum list all                     /*加载*/

    [root@localhost ~]# yum makecache             /*缓存*/

    二、系统安全配置

    2.1.SSH配置修改

    [root@localhost ~]# vim /etc/ssh/sshd_config

    #配置文件(关闭root用户SSH登陆)

    PermitRootLogin yes     修改为    PermitRootLogin no

    [root@localhost ~]# systemctl restart sshd

    2.2.Sudo权限修改

    [root@localhost ~]# vim /etc/sudoers

    [root@localhost ~]# visudo

    #配置文件

    ## Allow root to run any commands anywhere

    root    ALL=(ALL)       ALL

    #添加下列一行

    user   ALL=NOPASSWD:ALL,!/usr/bin/passwd root,!/sbin/visudo,!/bin/bash,!/bin/sh,!/bin/tcsh,!/bin/su

    #注释%wheel一行

    ## Allows people in group wheel to run all commands

    #%wheel   ALL=(ALL)       ALL

    2.3.Firewalld配置修改

    2.3.1.常规操作

    *关闭和禁用防火墙

    [root@localhost ~]# systemctl stop firewalld

    [root@localhost ~]# systemctl disable firewalld

    *指定开放端口

    #添加命令

    firewall-cmd --zone=public --add-port=80/tcp --permanent

    *注释:(--permanent永久生效,没有此参数重启后失效)

    #重新载入命令

    firewall-cmd -reload

    #查看命令

    firewall-cmd --zone= public --query-port=80/tcp

    #删除命令

    firewall-cmd --zone= public --remove-port=80/tcp --permanent

    2.3.2.Firewalld的基本使用

    启动服务: systemctl start firewalld

    关闭服务: systemctl stop firewalld

    查看状态: systemctl status firewalld

    开机禁用 : systemctl disable firewalld

    开机启用 : systemctl enable firewalld

    2.3.3.Systemct是CentOS7的服务管理工具中主要的工具,它融合之前Service和Chkconfig的功能于一体。

    启动一个服务:systemctl start firewalld.service

    关闭一个服务:systemctl stop firewalld.service

    重启一个服务:systemctl restart firewalld.service

    显示一个服务的状态:systemctl status firewalld.service

    在开机时启用一个服务:systemctl enable firewalld.service

    在开机时禁用一个服务:systemctl disable firewalld.service

    查看服务是否开机启动:systemctl is-enabled firewalld.service

    查看已启动的服务列表:systemctl list-unit-files|grep enabled

    查看启动失败的服务列表:systemctl --failed

    2.3.4.Firewalld-cmd操作使用

    查看版本: firewall-cmd –version

    查看帮助: firewall-cmd –help

    显示状态: firewall-cmd –state

    查看所有打开的端口: firewall-cmd --zone=public --list-ports

    更新防火墙规则: firewall-cmd –reload

    查看区域信息: firewall-cmd --get-active-zones

    查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0

    拒绝所有包:firewall-cmd --panic-on

    取消拒绝状态: firewall-cmd --panic-off

    查看是否拒绝: firewall-cmd --query-panic

    三、重启系统检测

    [root@localhost ~]# reboot

    3.1.检测SSH登陆情况

    #提示拒绝root用户访问链接,则正常

     

    3.2.检测sudo权限情况

    #提示user用户没有权限执行,则正常

    3.3.检测本地yum挂在情况

    #使用以下命令查看是否挂载,出现此路径,则正常

    [user@localhost ~]$ sudo mount

    3.4.检测防火墙是否启用情况

    #使用以下命令进行查看,未运行,则正常

    [user@localhost ~]$ sudo systemctl status firewalld.service

    3.5.检测SElinux是否关闭情况

    #使用以下命令进行查看,SELINUX是“disabled”,则正常

    [user@localhost ~]$ sudo more /etc/sysconfig/selinux

  • 相关阅读:
    Leetcode Plus One
    Leetcode Swap Nodes in Pairs
    Leetcode Remove Nth Node From End of List
    leetcode Remove Duplicates from Sorted Array
    leetcode Remove Element
    leetcode Container With Most Water
    leetcode String to Integer (atoi)
    leetcode Palindrome Number
    leetcode Roman to Integer
    leetcode ZigZag Conversion
  • 原文地址:https://www.cnblogs.com/lanwenzhu/p/13925622.html
Copyright © 2011-2022 走看看