Liunx basic Optimization Configuration and liunx Optimization Configuration

Source: Internet
Author: User
Tags i18n

Liunx basic Optimization Configuration and liunx Optimization Configuration
1: add operation users to the system and grant sudo Permissions

[Root @ localhost ~] # Groupadd cai [root @ localhost ~] # Useradd cai-g cai [root @ localhost ~] # Passwd cai change the password of user cai. New Password: Invalid password: Too simple/too systematic invalid password: Too simple re-enter the new password: passwd: All authentication tokens have been updated successfully. [Root @ localhost ~] # Su-cai

The sudo configuration file is under/etc/sudoers, but is a read-only file. Use the "mongodo" command.

The specific command of the terminal that the user name can log on to (use the absolute path and view it by which)

Cairui ALL = (ALL)/usr/sbin/useradd

 

2: configure the Yum source as a domestic source (I have an introduction to my other blogs, but I will not write it here)

 

3: Disable firewall (iptables) and Selinux

(1) because the firewall and selinux settings are troublesome and require a lot of time, simply turn them off.

Temporarily close the firewall: (you can view the status, restart, close, and open it)

[root@localhost ~]# /etc/init.d/iptables Usage: iptables {start|stop|reload|restart|condrestart|status|panic|save}

Permanently disable the firewall: (disable auto-start upon startup)

[root@localhost ~]# chkconfig iptables off

View the iptables boot status:

[Root @ localhost ~] # Chkconfig -- list | grep iptablesiptables 0: Close 1: Close 2: Close 3: Close 4: Close 5: Close 6: Close

(2) Disable selinux

[Root @ localhost ~] # Vim/etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX = can take one of these three values: # enforcing-SELinux security policy is enforced. # permissive-SELinux prints warnings instead of enforcing. # disabled-No SELinux policy is loaded. # modify SELINUX = enforcingSELINUX = disabled to disabled # SELINUXTYPE = can take one of these two values: # targeted-Targeted processes are protected, # mls-Multi Level Security protection. SELINUXTYPE = targeted

 

4. Modify the default configuration of the ssh service.

Back up the default configuration before modification:

[root@localhost ~]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.backup

Modify again

[Root @ localhost ~] # Vim/etc/ssh/sshd_config # $ OpenBSD: sshd_config, v 1.80 2008/07/02 02:24:18 djm Exp $ # This is the sshd server system-wide configuration file. see # sshd_config (5) for more information. # This sshd was compiled with PATH =/usr/local/bin: /usr/bin # The strategy used for options in the default sshd_config shipped with # OpenSSH is to specify options with their default value where # possible, but leav E them commented. uncommented options change a # default value. # Port 22 Port 52000 modify the default Linux connection Port # AddressFamily any # ListenAddress 0.0.0.0 # ListenAddress: # Disable legacy (protocol version 1) support in the server for new # installations. in future the default will change to require explicit # activation of protocol 1 Protocol 2 # HostKey for protocol version 1 # HostKey/etc/ssh/ssh_host_key # HostKeys Protocol version 2 # HostKey/etc/ssh/ssh_host_rsa_key # HostKey/etc/ssh/secrets # Lifetime and size of ephemeral version 1 server key # KeyRegenerationInterval 1 h # ServerKeyBits 1024 # Logging # obsoletes quietMode and FascistLogging # SyslogFacility AUTHSyslogFacility AUTHPRIV # LogLevel INFO # Authentication: # LoginGraceTime 2 m # PermitRootLogin yesPermitRootLogin no # root users are not allowed to log on (because everyone knows that root users can log on) # Str IctModes yes # MaxAuthTries 6 # MaxSessions 10 # RSAAuthentication yes # PubkeyAuthentication yes # AuthorizedKeysFile. ssh/authorized_keys # AuthorizedKeysCommand none # Your nobody # For this to work you will also need host keys in/etc/ssh/logs # RhostsRSAAuthentication no # similar for protocol version 2 # HostbasedAuthentication no # change to yes if you don't trust ~ /. Ssh/known_hosts for # RhostsRSAAuthentication and HostbasedAuthentication # IgnoreUserKnownHosts no # Don't read the user's ~ /. Rhosts and ~ /. Shosts files # IgnoreRhosts yes # To disable tunneled clear text passwords, change to no here! # PasswordAuthentication yes # define noPasswordAuthentication yes # Change to no to disable s/key passwords # encrypt encrypted no # Kerberos options # encrypt encrypted uthentication no # merge yes # encrypt osticketcleanup yes # encrypt osgetafstoken no # merge yes # GSSAPI options # GSSAPIAuthentication noGSSAPIAuthentication yes # invalid authentication yes # GSSAPIStrictAcceptorCheck yes # GSSAPIKeyExchange no # Set this to 'yes' to enable PAM authentication, account processing, # and session processing. if this is enabled, PAM authentication will # be allowed through the ChallengeResponseAuthentication and # PasswordAuthentication. depending on your PAM configuration, # PAM authentication via ChallengeResponseAuthentication may bypass # the setting of "PermitRootLogin without-password ". # If you just want the PAM account and session checks to run without # PAM authentication, then enable this but set PasswordAuthentication # and ChallengeResponseAuthentication to 'no '. # UsePAM noUsePAM yes # Accept locale-related environment when LANG implements LC_NUMERIC LC_TIME when using LC_PAPER LC_NAME LC_ADDRESS when using LC_ALL using XMODIFIERS # When yes # When wayports no # When Using yes # X11DisplayOffset 10 # define yes # PrintMotd yes # PrintLastLog yes # TCPKeepAlive yes # UseLogin no # adjust yes # adjust no # Compression delayed # ClientAliveInterval 0 # Prepare 3 # ShowPatchLevel no # UseDNS yesuseno # Do not use DNS # PidFile/var/run/sshd. pid # MaxStartups :30:100 # PermitTunnel no # ChrootDirectory none # no default banner path # Banner none # override default of no subsystemsSubsystem sftp/usr/libexec/openssh/sftp-server # Example of overriding settings on a per-user basis # Match User anoncvs # X11Forwarding no # AllowTcpForwarding no # ForceCommand cvs server

Restart after modification:

[Root @ localhost ~] #/Etc/init. d/sshd usage:/etc/init. d/sshd {start | stop | restart | reload | force-reload | condrestart | try-restart | status}

 

5: system kernel Optimization
[Root @ localhost ~] # Cat/etc/sysctl. conf # Kernel sysctl configuration file for Red Hat Linux # For binary values, 0 is disabled, 1 is enabled. see sysctl (8) and # sysctl. conf (5) for more details. # Use '/sbin/sysctl-a' to list all possible parameters. # Controls IP packet forwardingnet. ipv4.ip _ forward = 0 # Controls source route verificationnet. ipv4.conf. default. rp_filter = 1 # Do not accept source routingnet. ipv4.conf. default. accept_source_route = 0 # Controls the System Request debugging functionality of the kernelkernel. sysrq = 0 # Controls whether core dumps will append the PID to the core filename. # Useful for debugging multi-threaded applications. kernel. core_uses_pid = 1 # Controls the use of TCP syncookiesnet. ipv4.tcp _ syncookies = 1 # Controls the default maxmimum size of a mesage queuekernel. msgmnb = 65536 # Controls the maximum size of a message, in byteskernel. msgmax = 65536 # Controls the maximum shared segment size, in byteskernel. shmmax = 68719476736 # Controls the maximum number of shared memory segments, in pageskernel. shmall = 4294967296 # The following is the Kernel Tuning Parameter net. ipv4.tcp _ syn_retries = 1net. ipv4.tcp _ synack_retries = 1net. ipv4.tcp _ keepalive_time = 600net. ipv4.tcp _ keepalive_probes = 3net. ipv4.tcp _ keepalive_intvl = 15net. ipv4.tcp _ retries2 = 5net. ipv4.tcp _ fin_timeout = 2net. ipv4.tcp _ max_tw_buckets = 36000net. ipv4.tcp _ tw_recycle = 1net. ipv4.tcp _ tw_reuse = 1net. ipv4.tcp _ max_orphans = 32768net. ipv4.tcp _ syncookies = 1net. ipv4.tcp _ max_syn_backlog = 16384net. ipv4.tcp _ wmem = 8192 131072 16777216net. ipv4.tcp _ rmem = 32768 131072 16777216net. ipv4.tcp _ mem = 786432 1048576 1572864net. ipv4.ip _ local_port_range = 1024 65000net. ipv4.ip _ conntrack_max = 65536net. ipv4.netfilter. ip_conntrack_max = 65536net. ipv4.netfilter. ip_conntrack_tcp_timeout_established = 180net. core. somaxconn = 16384net. core. netdev_max_backlog = 16384
[Root @ localhost ~] # Sysctl-p # The configuration takes effect. net. ipv4.ip _ forward = 0net. ipv4.conf. default. rp_filter = 1net. ipv4.conf. default. accept_source_route = 0kernel. sysrq = 0kernel. core_uses_pid = 1net. ipv4.tcp _ syncookies = 1kernel. msgmnb = 65536kernel. msgmax = 65536kernel. shmmax = 68719476736kernel. shmall = 4294967296net. ipv4.tcp _ syn_retries = 1net. ipv4.tcp _ synack_retries = 1net. ipv4.tcp _ keepalive_time = 600net. ipv4.tcp _ keepalive_probes = 3net. ipv4.tcp _ keepalive_intvl = 15net. ipv4.tcp _ retries2 = 5net. ipv4.tcp _ fin_timeout = 2net. ipv4.tcp _ max_tw_buckets = 36000net. ipv4.tcp _ tw_recycle = 1net. ipv4.tcp _ tw_reuse = 1net. ipv4.tcp _ max_orphans = 32768net. ipv4.tcp _ syncookies = 1net. ipv4.tcp _ max_syn_backlog = 16384net. ipv4.tcp _ wmem = 8192 131072 16777216net. ipv4.tcp _ rmem = 32768 131072 16777216net. ipv4.tcp _ mem = 786432 1048576 1572864net. ipv4.ip _ local_port_range = 1024 65000 error: "net. ipv4.ip _ conntrack_max "is an unknown keyerror:" net. ipv4.netfilter. ip_conntrack_max "is an unknown keyerror:" net. ipv4.netfilter. ip_conntrack_tcp_timeout_established "is an unknown keynet. core. somaxconn = 16384net. core. netdev_max_backlog = 16384

 

6: timeout settings (timeout)

For system security, set no operation timeout to automatically exit Logon Settings

Temporary effect:

[root@centos6 ~]# export TMOUT=5[root@centos6 ~]# timed out waiting for input: auto-logout

Permanent configuration takes effect:

[Root @ centos6 ~] # Echo "export TMOUT = 300">/etc/profile: 5 minutes in the actual production environment [root @ centos6 ~] # Source/etc/profile

 

7. Increase the file descriptor.

The file descriptor is a handle represented by an unsigned integer (generally in the range of 0 ~ 65535), the process uses it to identify the opened file. Object descriptors are associated with objects that contain relevant information (such as the file opening mode, file location type, and initial file type). These information is called the file context.

For the kernel, all opened files are referenced by file descriptors. When an existing file is opened or a new file is created, the kernel returns a file descriptor to the process.

By convention, the UNIX System shell uses 0-standard input, 1-standard output, and 2-standard errors.

View the system's default file descriptor size: [root @ centos6 ~] # Ulimit-n1024 [root @ centos6 ~] # Echo "*-nofile 65535">/etc/security/limits. conf: log out and log on again. [root @ centos6 ~] # Ulimit-n65535

 

8: Hide System Version messages
[Cairui @ localhost ~] $ Cat/etc/issueCentOS release 6.8 (Final) Kernel \ r on an \ m [cairui @ localhost ~] $ Cat/etc/issue.net CentOS release 6.8 (Final) Kernel \ r on an \ m

You only need to clear the above file content to hide the information.

 

9: Add password protection to the grub boot menu (because grub can access and see the root password)
[Root @ localhost ~] #/Sbin/grub-md5-crypt Password: Retype password: $1 $ kpiKh/$ .. jTvOdnHGnMsqqs5OWlM/[root @ localhost ~] # Vi/etc/grub. conf [root @ localhost ~] # Cat/etc/grub. conf # grub. conf generated by anaconda # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a/boot partition. this means that # all kernel and initrd paths are relative to/boot/, eg. # root (hd0, 0) # kernel/vmlinuz-version ro root =/dev/sda3 # initrd/initrd-[generic-] version. img # boot =/dev/sdadefault = 0 timeout = 5 splashimage = (hd0, 0) /grub/splash.xpm.gz hiddenmenu password -- md5 $1 $ hv58gkgk9G995885/JG0orl4m # The title CentOS 6 (2.6.32-642. el6.x86 _ 64) root (hd0, 0) kernel/vmlinuz-2.6.32-642.el6.x86_64 ro root = UUID = export rd_NO_LUKS KEYBOARDTYPE = pc KEYTABLE = us rd_NO_MD crashkernel = auto LANG = zh_CN.UTF-8 export rd_NO_DM rhgb quiet initrd/initramfs-2.6.32-642.el6.x86_64.img

 

10: Adjust Character Set
[root@centos6 ssh]# echo $LANGen_US.UTF-8[root@centos6 ssh]# cat /etc/sysconfig/i18nLANG="en_US.UTF-8"SYSFONT="latarcyrheb-sun16"[root@centos6 ssh]# cp /etc/sysconfig/i18n /etc/sysconfig/i18n.2016.12.21[root@centos6 ssh]# sed -i 's#LANG="en_US.UTF-8"#LANG="zh_CN.UTF-8"#g' /etc/sysconfig/i18n[root@centos6 ssh]# source /etc/sysconfig/i18n[root@centos6 ssh]# echo $LANGzh_CN.UTF-8

 

 

 

Related Article

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.