壹  安装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. Java--API解读之Method Summary

    参考来源:Java 中静态方法 实例方法 具体方法区别与联系 JAVA Method Summary网页 * Static Method :"静态方法",直接引用,无需创建对象: ...

  2. mybatis利用generator自动生成的代码

    /** * 排序规则 */ protected String orderByClause; /** * 去重规则 */ protected boolean distinct; /** * where条 ...

  3. Using Watch Mode

    官方文档地址:https://webpack.js.org/guides/development/#using-watch-mode You can instruct webpack to " ...

  4. 2.分析Ajax请求并抓取今日头条街拍美图

    import requests from urllib.parse import urlencode # 引入异常类 from requests.exceptions import RequestEx ...

  5. UniGUI之Login窗口(10)

    在UniGUI的CHM帮助里读到的. 一定要新建一个其他空白的工程,然后再添加LoginForm LoginForm 是另一种特殊的表单类型, 仅用于登录目的. 此操作将创建一个与常规窗体外观相同的空 ...

  6. 通过修改select的value值

    1 <input type="button" id="btn" value="按钮"/> 2 <select name=& ...

  7. 多进程之multiprocessing模块、守护进程、互斥锁

    目录 1. multiprocessing 模块介绍 2. Process类的介绍 3. Process类的使用 4. 守护进程 5. 进程同步(锁) 1. multiprocessing 模块介绍 ...

  8. js对象无法当成参数传递 解决方法

    思路:把对象转换为字符串进行传递 function test(){ var objParam = {"key":"value"}; var strObj = J ...

  9. c++ char* 与LPCTSTR相互转化

    ] = "wo shi ni baba"; , , ch, -, NULL, ); wchar_t *wide = new wchar_t[num]; MultiByteToWid ...

  10. Codeforces 598D:Igor In the Museum

    D. Igor In the Museum time limit per test 1 second memory limit per test 256 megabytes input standar ...