关于linux:Linux系统调优

10次阅读

共计 2036 个字符,预计需要花费 6 分钟才能阅读完成。

linux 零碎装置结束后,首先要做的就是零碎调优,这样会进步零碎的应用效率,接下来为大家介绍一下 linux 零碎调优办法。

敞开 selinux 性能

selinux 是美国国家安全局对于强制访问控制的实现,这个性能很弱小,同时又很麻烦,大多是运维人员都抉择将其敞开,利用其它路径减少安全性。

此命令是永恒敞开 selinux,执行后重启零碎失效。

[root@chao selinux]# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/’ /etc/selinux/config

开机自启服务

linux 零碎和 windows 零碎相似,开机也会自启一些服务,没用的服务即会占用资源又有安全隐患,须要把必须运行的服务开机自启,其余的敞开。

须要开机自启的服务:

  • sshd, 近程连贯须要应用此服务
  • rsyslog, 日志无关的软件
  • networ,网络相干的软件
  • crond, 定时工作相干软件
  • sysstat 数据分析的软件

查看目前开机自启的服务

[root@chao selinux]# systemctl list-unit-files|grep enabled
abrt-ccpp.service enabled
abrt-oops.service enabled
abrt-vmcore.service enabled
abrt-xorg.service enabled
abrtd.service enabled
atd.service enabled
auditd.service enabled
autovt@.service enabled
chronyd.service enabled
crond.service enabled
dbus-org.fedoraproject.FirewallD1.service enabled
dbus-org.freedesktop.ModemManager1.service enabled
dbus-org.freedesktop.NetworkManager.service enabled
dbus-org.freedesktop.nm-dispatcher.service enabled
dmraid-activation.service enabled
firewalld.service enabled
getty@.service enabled
irqbalance.service enabled
iscsi.service enabled
kdump.service enabled
ksm.service enabled
ksmtuned.service enabled
libstoragemgmt.service enabled
libvirtd.service enabled

例如想敞开一个

[root@chao selinux]# systemctl disable postfix.service
Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.

设置 ssh 服务

编辑 /etc/ssh/sshd_config 文件 更改默认端口为 Port 22222 保留退出, 重启服务!

linux 中文设置

查看零碎是否是 zh_CN.UTF-8 如果不是手动增加一行到此文件。

[root@chao etc]# cat locale.conf
LANG=”zh_CN.UTF-8″

设置账户超时工夫

[root@chao ~]# echo ‘export TMOUT=300’ >>/etc/profile
[root@chao ~]# source /etc/profile
[root@chao ~]# env |grep -i tmout
[root@chao ~]# vim /etc/profile
[root@chao ~]# source /etc/profile
[root@chao ~]# 期待输出超时:主动登出
Connection closing…Socket close.

Connection closed by foreign host.

Disconnected from remote host(172.16.1.16) at 11:01:36.

Type `help’ to learn how to use Xshell prompt.

设置命令行历史记录数

将原来的 5 条改成 10 条

[root@chao ~]# sed -i ‘s/^HISTSIZE=5/HISTSIZE=10/’ /etc/profile
[root@chao ~]# source /etc/profile

暗藏零碎版本

[root@chao ~]# echo redflag 5.9 >/etc/issue
[root@chao ~]# cat /etc/issue
redflag 5.9

锁定重要文件

[root@chao ~]# chattr -i /etc/passwd /etc/shoadow /etc/group /etc/gshadow /etc/inittab

以上就是罕用的优化步骤!

正文完
 0