Linux system optimization

Source: Internet
Author: User

1 minimized installation (custom package: most basic: Bash; Compatibillty librarles;debugging tools;development Tools)

Minimize Startup:

For Oldboy in ' Chkconfig--list | grep "3:on" |awk ' {print $} ' | Grep-ve "crond|network|sshd|rsyslog|xinetd" ';d o chkconfig $oldboy off;done

2 Ulimit:

Ulimit-n if the system process is more than the default number of open files, then the resources are not enough.

Temporary change: ULIMIT-HSN 65535 permanent change: echo "*-Nofile 65535" >/etc/security/limits.conf

3 TCP/IP:

After the client has established a TCP/IP connection with the server, the port status of the server-side connection is time_wait, such as the discovery of a large number of time_wait states of the system connection, by adjusting the kernel parameters to resolve, vim/etc/ sysctl.conf Edit the file, add the following: Net.ipv4.tcp_syncookies = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_ Fin_timeout = 30 Then execute/sbin/sysctl-p to let the parameters take effect. That is, the TCP/IP designer was originally designed so that there are two main reasons 1. Prevent packets from the last connection, get lost and re-appear, affect the new connection (after 2MSL, all duplicates in the last connection will disappear) 2. A reliable shutdown of the TCP connection on the active shutdown sends the last ACK (FIN), which may be lost, when the passive side will re-send fin, if the active side in the CLOSED state, will respond to the RST instead of ACK. So the active side should be in the TIME_WAIT state, but not CLOSED. Time_wait does not occupy a significant amount of resources unless it is under attack.

4 Character Set Optimization:

cat/etc/sysconfig/i18n Character Set configuration file path Sed-i ' s/lang= ' en_US. UTF-8 "/lang=" zh_cn.gb18030 "/g" i18n

5 SSH Login Optimizations:

Vim/etc/ssh/sshd_config42 permitrootlogin no allow root login permitemptypasswords no allow null password login-gssapiauthentication No sshp122 usedns No DNS search to close the SSH service X11 forwarding function #vi/etc/ssh/sshd_config settings below is nox11forwarding no

6 history, host wait Time

Echo ' histsize=5 ' >>/etc/profileecho ' tmout=300 ' >>/etc/profile

7 Chattr Secure Directory Lock

Chattr +i/etc/passwd/etc/shadow/etc/group/etc/gshadow/etc/inittab hidden directory hackers come not to go to ssh, so it is necessary to chattr-i/etc/pas Swd/etc/shadow/etc/group/etc/gshadow/etc/inittab Unlocking lsattr/etc/passwd/etc/shadow/etc/group/etc/gshadow/etc/ Inittab View lock mv/usr/bin/chattr/usr/bin/oldboy1 Rename the command

8 Hiding the system version

Cat/dev/null >/etc/issue

9 optimize Ctrl+alt+del shortcut key Restart server

Sed-i "S/ca::ctrlaltdel:/sbin/shutdown-t3-r now/#ca:(www.111cn.net): Ctrlaltdel:/sbin/shutdown-t3-r now/g" '/etc/ Inittab ' from:http://www.111cn.net/sys/linux/59969.htm

SELinux off

View SELinux Status: 1,/usr/sbin/sestatus-v # #如果SELinux The status parameter is enabled is on, SELinux status:enabled2, Getenforce # # You can also use this command to check the shutdown selinux:1, temporarily shut down (without restarting the machine): Setenforce 0 # #设置SELinux become permissive Mode # #setenforce 1 set SELinux to become enforcing mode 2, Modifying the configuration file requires restarting the machine: Modify the/etc/selinux/config file to change the selinux=enforcing to selinux=disabled restart the machine

11 LAN Yum source configuration, LAN NTP configuration

12 self-packaged RPM package, LAN internal use

This article from the "Clear Sky" blog, declined reprint!

Linux system optimization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.