壹  安装Linux系统后调优及安全设置:

1 关闭SELinux功能:

[root@localhost data]# sed 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config  (先用sed命令修改输出内容,再加-i修改文件内容,生产环境中也是要这样操作的)

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

[root@localhost data]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config    (确认改输出成功后,再加-i执行改文件内容)
[root@localhost data]# grep "SELINUX=disabled" /etc/selinux/config       (再用grep命令检测一下)
SELINUX=disabled

*以上只是修改配置文件,还需重启才能生效,但生产环境是不允许服务器重启的,影响客户访问,这时就需要另一个命令。

 [root@localhost data]# getenforce   (查看SElinux状态的)
Enforcing
[root@localhost data]# setenforce (设置状态)
usage: setenforce [ Enforcing | Permissive | | ] (Enforcing是1 ,Permissive是0的意思)
[root@localhost data]# setenforce
[root@localhost data]# getenforce
Permissive

·这样作:重启前是Permissive,但之前配置文件是改成disabled,一旦重启就是disabled,但因是实际不允许重启,所以配置文件和命令行都改,而disabled和Permissive都是不影响的状态。

贰:Linux的7种运行级别,及对应作用。

·企业场景面试题:Linux的7种运行级别,及对应作用。(要牢记)
·企业场景面试题:要把Linux的运营级别从3改成5,要修改哪个文件?
答案:/etc/inittab

Default runlevel.The runlevels used are:
-halt(Do NOT set initdefault to this)      关机。
-Single user mode          单用户状态,需要维护服务器时用,比如密码丢失。
-Multiuser,without NFS(The same as 3,if you not have networking)   多用户模式。
-Full multiuser mode      完整多用户模式,命令行模式.工作环境一般用3级别。
-unused     没有使用,保留的。
-Xll        带桌面的模式。
-reboot (Do NOT set initdefault to this)   重启。

查看当前Linux运行模式:
[root@localhost ~]# runlevel
N 5
运行级别是可以切换的:
[root@localhost ~]# init 输入数字0-6,就切换到你要的模式。

·runlevel:查看当前系统运行级别。
·init:切换运行级别,后面接对应级别的数字,例如init 6就是重启linux服务器。

叁:关机重启命令和防火墙设置:

· shutdown   #关机。 halt,init0 也是关机的命令。
               关机:shutdown -h now(或指定时间)。
· rboot      #重启。init6也是重启。
               重启:shutdowm -r now

关闭防火墙命令:[root@localhost ~]# /etc/init.d/iptables stop   临时关闭
永久关闭防火墙:[root@localhost ~]# chkconfig iptables off      下次开机也不会自动启动。
查看防火墙命令:[root@localhost ~]# /etc/init.d/iptables status

CentOS 7默认使用的是firewall作为防火墙
# service firewalld status; #查看防火墙状态
(disabled 表明 已经禁止开启启动 enable 表示开机自启,inactive 表示防火墙关闭状态 activated(running)表示为开启状态)
# service firewalld start;  或者 #systemctl start firewalld.service;#开启防火墙
# service firewalld stop;  或者 #systemctl stop firewalld.service;#关闭防火墙
# service firewalld restart;  或者 #systemctl restart firewalld.service;  #重启防火墙
# systemctl disable firewalld.service#禁止防火墙开启自启

# systemctl enable firewalld#设置防火墙开机启动
#yum remove firewalld#卸载firewall

肆  Linux中文显示设置:
此项优化为可选项,即调整Linux系统的字符集设置。
字符集就是一套文字符号及其编码。目前Linux下常用的字符集有:
·GBKL:定长,双字节,不是国际标准,支持的系统不少,实际企业用的不多。
·UTF-8:非定长,1-4字节,广泛支持,MYSQL也使用UTF-8,企业广泛使用。

在CentOS 7以前的版本下,默认的字符集的路径一般保存在/etc/sysconfig/i18n文件中。
但是在CentOS 7版本中,字符集配置文件位于/etc/locale.conf。

下面演示在Centos7中使Linux中文显示:

 [root@localhost ~]# cat /etc/locale.conf  (查看字符集配置文件)
LANG="en_US.UTF-8"
[root@localhost ~]# cp //etc/locale.conf /etc/locale.conf.ori (最好备份)
[root@localhost ~]# echo 'LANG="zh_CN.UTF-8"' >/etc/locale.conf (使用echo命令追加输出,替换内容)
[root@localhost ~]# cat /etc/locale.conf (查看字符集配置文件)
LANG="zh_CN.UTF-8"
[root@localhost ~]# echo $LANG (查看字符集配置文件)
en_US.UTF-
[root@localhost ~]# . /etc/locale.conf (还需要使用. 或者source命令使修改生效)
[root@localhost ~]# echo $LANG (查看变量$LANG)
zh_CN.UTF-
[root@localhost ~]# source /etc/locale.conf
[root@localhost ~]# echo $LANG
zh_CN.UTF-

最后还要再此虚拟机的属性-外观里把字符编码改成UTF-8,重新连接,这样使服务器端和客户端对应,就确保对话字符一致。

 [root@localhost ~]# echo $LANG
zh_CN.UTF-
[root@localhost ~]# cat /etc/locale.conf
LANG="zh_CN.UTF-8"
[root@localhost ~]# touch 老男孩。txt
[root@localhost ~]# ls
anaconda-ks.cfg initial-setup-ks.cfg oldboy.txt 老男孩。txt
[root@localhost ~]#

注意:不要在Linux系统里使用任何中文信息。

伍  设置闲置账号超时时间的命令,仅临时生效:
[root@localhost ~]#  export TMOUT=5
[root@localhost ~]# timed out waiting for input: auto-logout

陆  清空所有历史命令:
[root@localhost ~]# history -c
删除指定的一个命令:
[root@localhost ~]# history -d 数字(要删的那一行的数字)

[root@localhost ~]# export HISTSIZE=5设置命令行记录显示数
[root@localhost ~]# cat ~/.bash_bash_history (但还是可以从命令行文件看到所有历史命令)
[root@localhost ~]# export HISTFILESIZE=5 (设置命令行文件历史记录数量)

history    #查看及清理历史记录。-c 清空所有,-d删除指定历史记录。

     export HISTORY=    命令行历史记录数量。(Linux特殊变量)。
export HISTFILESIZE= 命令行文件历史记录数量。
cat ~/.bash_bash_history 查看命令行文件历史记录

把上述命令放入配置文件,使其可以永久生效:

 [root@localhost ~]# echo 'export TMOUT=300' >>/etc/profile
[root@localhost ~]# echo 'export HISTSIZE=5' >>/etc/profile
[root@localhost ~]# echo 'export HISTFILESIZE=5' >>/etc/profile
[root@localhost ~]# tail - /etc/profile
export TMOUT=
export HISTSIZE=
export HISTFILESIZE=
[root@localhost ~]# source /etc/profile (使配置文件生效)

柒   隐藏Linux版本信息显示:

 [root@localhost ~]# cat /etc/issue  查看版本信息
\S
Kernel \r on an \m
[root@localhost ~]# cat /etc/issue.net
\S
Kernel \r on an \m
[root@localhost ~]# > /etc/issue 用>把信息清掉
[root@localhost ~]# > /etc/issue。net

NO13 Linux的基础优化-关闭SELinux功能-Linux的7种运行级别-防火墙设置-中文显示设置的更多相关文章

  1. 运维 07 Linux系统基础优化及常用命令

    Linux系统基础优化及常用命令   Linux基础系统优化 引言没有,只有一张图. Linux的网络功能相当强悍,一时之间我们无法了解所有的网络命令,在配置服务器基础环境时,先了解下网络参数设定命令 ...

  2. Linux实战教学笔记06:Linux系统基础优化

    第六节 Linux系统基础优化 标签(空格分隔):Linux实战教学笔记-陈思齐 第1章 基础环境 第2章 使用网易163镜像做yum源 默认国外的yum源速度很慢,所以换成国内的. 第一步:先备份 ...

  3. Linu之linux系统基础优化和基本命令

    Linux系统基础优化和基本命令 网络参数设定命令 ifconfig: 查询,设置网卡和ip等参数 ifup,ifdown: 脚本命令,更简单的方式 ip: 符合指令,直接修改上述功能 编辑网卡配置文 ...

  4. Linux 系统基础优化和常用命令

    目录 Linux 系统基础优化和常用命令 软连接 tar解压命令 gzip命令 netstart命令 ps命令 kill命令 killall命令 SELinux功能 iptables防火墙 Linux ...

  5. Linux内核基础优化

    Linux内核基础优化 net.ipv4.ip_forward = 1 #开启网络转发 net.ipv4.conf.default.rp_filter = 0 #开启代理功能 net.ipv4.con ...

  6. Linux的运行级别和设置开机启动服务的方式

    Linux的运行级别 什么是运行级别呢?简单点来说,运行级别就是操作系统当前正在运行的功能级别.级别是从0到6,具有不同的功能.这些级别定义在/ect/inittab文件中.这个文件是init程序寻找 ...

  7. Linux系统基础优化及常用命令

    Linux基础系统优化 引言没有,只有一张图. Linux的网络功能相当强悍,一时之间我们无法了解所有的网络命令,在配置服务器基础环境时,先了解下网络参数设定命令. ifconfig 查询.设置网卡和 ...

  8. 8,Linux系统基础优化及常用命令

    Linux基础系统优化 引言没有,只有一张图. Linux的网络功能相当强悍,一时之间我们无法了解所有的网络命令,在配置服务器基础环境时,先了解下网络参数设定命令. ifconfig 查询.设置网卡和 ...

  9. linux系统基础优化及高级操作命令

    Linux基础系统优化 引言没有,只有一张图. Linux的网络功能相当强悍,一时之间我们无法了解所有的网络命令,在配置服务器基础环境时,先了解下网络参数设定命令. ifconfig 查询.设置网卡和 ...

随机推荐

  1. frp 配置

    前言 对于没有公网 IP 的内网用户来说,远程管理或在外网访问内网机器上的服务是一个问题. 今天给大家介绍一款好用内网穿透工具 FRP,FRP 全名:Fast Reverse Proxy.FRP 是一 ...

  2. StringBuilder为什么线程不安全(面试必问)

    文章转载自:https://juejin.im/post/5d6228046fb9a06add4e37fe 作者:千山qianshan 1.引言 周五去面试又被面试的一个问题问哑巴了 面试官:Stri ...

  3. Linux centosVMware apache 限定某个目录禁止解析php、限制user_agent、php相关配置

    一.限定某个目录禁止解析php 核心配置文件内容 vim /usr/local/apache2.4/conf/extra/httpd-vhosts.conf 先创建.编辑一个php 配置 vim /u ...

  4. js加密(九)hr.bibibi md5

    1. 寻找加密js: 2. 结果: 3. execjs调用js即可.

  5. 数组NSArray与NSMutableArray的常用方法

    数组中可以放任何类型的数据,并且一个数组中的元素类型可以不一致.只要是(id类型)对象. NSArray 1.初始化 NSArray *array = @[]; 2.初始化,最后需要以nil结尾 NS ...

  6. Python中from scipy.misc import imread报错的原因?

    from scipy.misc import imread 报错 查询后其原因是from scipy.misc import imread,imwrite 等方法已经被弃用,Python已经将imre ...

  7. HTML<head></head>中标签的含义

    我们都知道,HTML的标签可以分为很多种,head 里面的我们称为元信息类标签,诸如title.meta.style.link.base.script这些,他们用来描述文档的一些基本信息. 1. ti ...

  8. 用于云计算的自我更新、自我修补的Linux版本已发布!

    自动化是 IT 行业的增长趋势,其目的是消除重复任务中的手动干扰.Oracle 通过推出 Oracle Autonomous Linux 向自动化世界迈出了又一步,这无疑将使 IoT 和云计算行业受益 ...

  9. Day8 - C - Largest Rectangle in a Histogram HDU - 1506

    A histogram is a polygon composed of a sequence of rectangles aligned at a common base line. The rec ...

  10. 车林通购车之家--购车计算器模块js实现

    //jsq-nav.twig <ul class="switch-nav db-tags bgfff clearfix"> <li id="qk&quo ...