天天看點

Linux系統調優

linux系統安裝完畢後,首先要做的就是系統調優,這樣會提高系統的使用效率,接下來為大家介紹一下linux系統調優方法。

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

[email protected] 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

[email protected] 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 ~]# 等待輸入逾時:自動登出

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 ~]# 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

以上就是常用的優化步驟!