Linux系统的基础优化

1.关闭selinux的方法:

修改配置文件

第一种方法:[root@centos ~]# vi /etc/selinux/config  将文件中的SELINUX=enforcing更改为disabled

第二种方法:[root@centos ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config  注意修改之前最好先备份,例cp /etc/selinux/config /etc/selinux/config.ori

这两种方法修改完成后,需要重启。

2.临时关闭SElinux

[root@centos ~]# setenforce

usage:  setenforce [ Enforcing | Permissive | 1 | 0 ]  数字0表示 Permissive,即给出警告提示,但不会阻止操作,相当于disabled。数字1表示Enforcing,即表示SELinux为开启状态。

[root@centos ~]# setenforce 0  <<==临时将SElinux设置成Permissive

状态

[root@centos ~]# getenforce    <<==查看SElinux当前状态

Permissive

 

Linux的7个运行级别

[root@centos ~]# cat /etc/inittab  linux运行级别配置文件

# Default runlevel. The runlevels used are:

#   0 - halt (Do NOT set initdefault to this)  关机

#   1 - Single user mode  单用户模式,只有root用户可以进入

#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)  不能使用NFS(Net File System)的多用户模式

#   3 - Full multiuser mode  完全多用户模式

#   4 - 备用

#   5 - X11  图形化界面

#   6 - reboot (Do NOT set initdefault to this) 重启

命令说明:

runlevel:查看当前系统运行级别。

init:切换运行级别,后面接对应级别的数字,例:init 0 关闭linux服务器

 

 

关闭防火墙

[root@centos ~]# /etc/init.d/iptables stop  临时关闭防火墙

[root@centos ~]# /etc/init.d/iptables status  查看防火墙状态

iptables: Firewall is not running.   表示防火墙已经关闭

[root@centos ~]# chkconfig iptables off  永久关闭防火墙(开机不自启动)

 

 

Linux的中文显示设置(调整Linux的字符集设置)

第一步: [root@centos ~]# cp /etc/sysconfig/i18n /etc/sysconfig/i18n.ori

第二步:[root@centos ~]# echo 'LANG="zh_CN.UTF-8"' >/etc/sysconfig/i18n

 

设置Linux连接的超时时间 [root@centos ~]# export TMOUNT=600

设置Linux的命令行历史记录数

[root@centos /]# export HISTSIZE=5  修改命令行历史记录数量

[root@centos ~]# export HISTFILESIZE=5  命令行命令对应文件的记录数 ~/.bash_history

永久生效:修改/etc/profile

echo ‘export TMOUNT=600’ >>/etc/profile

echo ‘export HISTSIZE=5’ >>/etc/profile

echo ‘export HISTFILESIZE=5’ >>/etc/profile

sourec /etc/profile  让配置文件生效

 

隐藏Linux版本信息显示

[root@centos ~]# >/etc/issue.net

[root@centos ~]# >/etc/issue

[root@centos ~]# cat /etc/issue.net

[root@centos ~]# cat /etc/issue

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值