Linux System Foundation Optimization

Source: Internet
Author: User
Tags i18n

#查看centos系统版本:

[Email protected] ~]# cat/etc/redhat-release
CentOS Release 6.9 (Final)

#查看linux内核版本:
[Email protected] ~]# uname-r
2.6.32-696.el6.x86_64

#查看系统是32位和64位:
[Email protected] ~]# uname-m
x86_64


#创建用户:
[Email protected] ~]# Useradd Oldboy

#为用户oldboy创建密码:
[Email protected] ~]# passwd Oldboy
Changing password for user Oldboy.
New Password:
Bad Password:it is too simplistic/systematic
Bad Password:is too simple
Retype new Password:
Passwd:all authentication tokens updated successfully.

#切换用户 su = = Switch User
[Email protected] ~]# Su-oldboy
[Email protected] ~]$ WhoAmI
Oldboy

#退出当前用户
[Email protected] ~]$ WhoAmI
Oldboy
[Email protected] ~]$ Logout
[Email protected] ~]#
or use CTRL + D

#环境变量
1. Uppercase letters
2. Free to use in most parts of the system
3. The system is created well

#查看环境变量的内容
[Email protected] ~]# echo $PS 1
[\[email protected]\h \w]\$

PS1 environment variable Control linux command line structure
[\[email protected]\h \w]\$
Notes \DAY05\PS1 environment variables. png
Environment variable Modification Export
[Email protected] ~]# echo $PS 1
[\[email protected]\h \w]\$
[[email protected] ~]# export ps1= ' [\[email protected]\h \w\t]\$ '
[Email protected] ~17:36:50]#
################################################################################
#关闭SElinux

Permanent shutdown-------takes effect after restarting the server

# Enforcing-selinux security policy is enforced. SELinux is running start
# Permissive-selinux Prints warnings instead of enforcing. SELinux off display warning message
# disabled-no SELinux policy is loaded. SELinux shut down completely


Temporary shutdown------Restart server failure
[[Email protected] ~] #查看当前selinux运行状态
[[Email protected] ~] #getenforce
Enforcing
[Email Protected]wangjin ~] #setenforce
Usage:setenforce [Enforcing | Permissive | 1 | 0]
[[Email protected] ~] #setenforce 0
[[Email protected] ~] #getenforce
Permissive
Summary:
Turn off SELinux
1. Temporary--setenforce
2. Permanently modify the configuration file
/etc/selinux/config
Pre-operation backup, post-operation check

############################################################################
#iptables Firewall
Production environment Firewall use
1. The server has a public IP address to open the firewall
2. Server does not have a public network IP does not need to open the fire protection device
3. The website does not need to turn on the firewall when high concurrency

How to turn off Iptables firewall


Temporary shutdown-------------------------failed after restarting the server

/etc/init.d/iptables stop
Firewall status Query
/etc/init.d/iptables status
[Email protected] ~]#/etc/init.d/iptables status
Table:filter
Chain INPUT (Policy ACCEPT)
Num Target prot opt source destination
1 ACCEPT All – 0.0.0.0/0 0.0.0.0/0 State related,established
2 ACCEPT ICMP--0.0.0.0/0 0.0.0.0/0
3 ACCEPT All--0.0.0.0/0 0.0.0.0/0
4 ACCEPT TCP--0.0.0.0/0 0.0.0.0/0 state NEW TCP dpt:22
5 REJECT All--0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain FORWARD (Policy ACCEPT)
Num Target prot opt source destination
1 REJECT All--0.0.0.0/0 0.0.0.0/0 reject-with icmp-host-prohibited

Chain OUTPUT (Policy ACCEPT)
Num Target prot opt source destination

[[email protected] ~]#/etc/init.d/iptables stop
Iptables:setting chains to Policy Accept:filter [OK]
iptables:flushing firewall rules: [OK]
iptables:unloading modules: [OK]
[[email protected] ~]#/etc/init.d/iptables stop
[Email protected] ~]#/etc/init.d/iptables status
Iptables:firewall is not running.

Permanent shutdown----------------------------takes effect after restarting the server
[[Email protected] ~] #chkconfig #管理开机启动

[[Email protected] ~] #chkconfig |grep iptables
Iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[Email protected] ~] #chkconfig iptables off
[[Email protected] ~] #chkconfig |grep iptables
Iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Summary
How to turn off iptables
1. Temporary closure
2. Permanently closed
3. Check

#####################################################################################
Linux Chinese display settings (how to avoid displaying Chinese garbled characters)
Pre-Knowledge:
Character
#LANG language
How to modify and view the character set used by the system

Solve the problem of garbled Chinese display
The character set used by Linux and the character set of the remote Connection tool
Troubleshooting process:
Solve
Modifying the Xshell Character set
Modifying the Linux system character set

#########################
View the character set used by the current system
[[Email protected] ~] #echo $LANG
en_US. UTF-8

Modify to Chinese Character set < temporary >
[[Email protected] ~] #echo $LANG
en_US. UTF-8
[[Email protected] ~] #export lang=zh_cn. UTF-8

Modified to Chinese Character set < permanent > < re-login takes effect, or with the source command >
[[Email protected] ~] #cat/etc/sysconfig/i18n
Lang= "en_US. UTF-8 "
Sysfont= "Latarcyrheb-sun16"
Modify/etc/sysconfig/i18n
#生效
[[Email protected] ~] #source/etc/sysconfig/i18n
##############
Please change the system character set to en_US. UTF-8
Environment Construction:
[[Email protected] ~] #source/etc/sysconfig/i18n
[[Email protected] ~] #export lang=zh_cn. UTF-8
[[Email protected] ~] #sed-i ' s#lang=.*$ #LANG =zh_cn. Utf-8#g '/etc/sysconfig/i18n
[[Email protected] ~] #logout
Output echo $LANG
cat/etc/sysconfig/i18n
——————————————

[Email protected] ~]# export Lang=en_us. UTF-8
[Email protected] ~]# cat/etc/sysconfig/i18n
Lang=zh_cn. UTF-8
Sysfont= "Latarcyrheb-sun16"

[Email protected] ~]# sed ' s#zh_cn. Utf-8#zh_cn. Utf-8#g '/etc/sysconfig/i18n
Lang=zh_cn. UTF-8
Sysfont= "Latarcyrheb-sun16"
[Email protected] ~]# Sed-i.bak ' S#ZH_CN. Utf-8#zh_cn. Utf-8#g '/etc/sysconfig/i18n
[Email protected] ~]# #备份i180文件再修改
[[Email protected] ~] #source/etc/sysconfig/i18n

############################################################
Vim operation

C caps The contents of the cursor to the end of the line to delete and enter the edit mode
[email protected] ~] #chkconfig #管理开机启动

Reboot restarting the server
Shutdown Shutdown/Restart
-R Restart
-H shutdown
-C Cancel current shutdown and restart


ESC + .< Point > Use Previous command




Summarize:
1. Display system version add switch user settings password
2. Turn off SELinux iptables
< temporary permanent inspection >
3. Environment variable PS1 LANG
4. How to modify the character set
5.linux garbled Troubleshooting process

Linux System Foundation Optimization

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.