当前位置: 首页 > Linux

linux系统调优

时间:2023-04-06 21:31:47 Linux

linux系统安装好之后,首先要做的就是系统调优,这会提高系统的运行效率。下面就为大家介绍一下linux系统调优方法。关闭selinux功能selinux是美国国家安全局实施的强制访问控制。这个功能很强大,但同时也很麻烦。大多数运维人员选择关闭它,并使用其他方法来增加安全性。该命令是永久关闭selinux,执行后重启系统生效。[root@chaoselinux]#sed-i's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/config开机自启动服务linux系统类似于windows系统,开机也会自动启动一些服务,没用服务占用资源,存在安全隐患。有必要启动必须运行的服务,并关闭其他服务。开机需要自动启动的服务:sshd、远程连接需要用到该服务rsyslog、日志相关软件networ、网络相关软件crond、定时任务相关软件sysstat数据分析软件查看当前开机启动的服务【root@chaoselinux]#systemctllist-unit-files|grepenabledabrt-ccpp.serviceenabledabrt-oops.serviceenabledabrt-vmcore.serviceenabledabrt-xorg.serviceenabledabrtd.serviceenabledatd.serviceenabledauditd.service已启用autovt@.service已启用chronyd.service已启用crond.service已启用dbus-org.fedoraproject.FirewallD1.service已启用dbus-org.freedesktop.ModemManager1.service已启用dbus-org.freedesktop.NetworkManager.service已启用dbus-org.freedesktop。nm-dispatcher.service启用dmraid-activation.service启用edfirewalld.serviceenabledgetty@.serviceenabledirqbalance.serviceenablediscsi.serviceenabledkdump.serviceenabledksm.serviceenabledksmtuned.serviceenabledlibstoragemgmt.serviceenabledlibvirtd.serviceenabled例如,如果你想关闭一个[root@chaoselinux]#systemctldisablepostfix.service删除了符号链接/etc/systemd/system/multi-user.target.wants/postfix.service。设置ssh服务编辑/etc/ssh/sshd_config文件修改默认端口为22222端口保存退出,重启服务!linux中文设置查看系统是否为zh_CN.UTF-8如果不是手动在该文件中添加一行[root@chaoetc]#catlocale.confLANG="zh_CN.UTF-8"setaccounttimeout[root@chao~]#echo'exportTMOUT=300'>>/etc/profile[root@chao~]#source/etc/profile[root@chao~]#env|grep-itmout[root@chao~]#vim/etc/profile[root@chao~]#source/etc/profile[root@chao~]#定时等待输入:自动注销连接关闭...套接字关闭。外部主机关闭连接。在11:01:36与远程主机(172.16.1.16)断开连接。键入“帮助”以了解如何使用Xshell提示符。设置将命令行历史记录数从5条改为10条[root@chao~]#sed-i's/^HISTSIZE=5/HISTSIZE=10/'/etc/profile[root@chao~]#source/etc/profile隐藏系统版本[root@chao~]#echoredflag5.9>/etc/issue[root@chao~]#cat/etc/issuedflag5.9锁定重要文件[root@chao~]#chattr-i/etc/passwd/etc/shoadow/etc/group/etc/gshadow/etc/inittab以上就是常用的优化步骤!