大數據

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系統調優linux系統調優

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
以上就是常用的優化步驟!

Leave a Reply

Your email address will not be published. Required fields are marked *