Linux system optimization

Source: Internet
Author: User
Tags i18n iptables

Add user set Password switch user

1.1 What version of your system is it?
CentOS 6.9
[Email protected] ~]# cat/etc/redhat-release
CentOS Release 6.9 (Final)
[Email protected] ~]# uname-r
2.6.32-696.el6.x86_64
[Email protected] ~]# uname-m
x86_64
1.2. Add Users
[Email protected] ~]# Useradd Oldboy
[[email protected] ~]# ID Oldboy
uid=500 (Oldboy) gid=500 (Oldboy) groups=500 (Oldboy)
[[email protected] ~]# ID Lilaoshi
Id:lilaoshi:No such user
1.3 Setting a password
[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.
1.4 Switch User Switch to Oldboy
[Email protected] ~]# Su-oldboy
[Email protected] ~]$ WhoAmI
Oldboy
1.4.1 Su and Su-difference
The most essential difference between the SU command and the Su-command is that the former only switches the root identity, but the shell environment is still a normal user's shell

#退出当前用户
#ctrl + D
Logout

1.5 What is a variable
variable = = Book Name
$ = = = Read the contents of reading books

Variable name ====== Sutra Court martial arts cheats name sunflower Treasure book = = = BAO
View the contents of a variable = = Reading = Read = Echo $BAO
Modify the contents of a variable = = add experience = = bao= Success
If you want to practice this work, you will succeed in your own palace.

1.5.1 Environment variables
1. Uppercase
2. Can be used in every part of the system

[Email protected] ~]# echo $PS 1
[\[email protected]\h \w]\$

#PS1存放的是 the command line looks like

Ps1= "[\[email protected]\h \w \t]\$"

Iptables and SELinux off

2.1. modify file permanent-the contract becomes effective after restarting Linux
Ls-l/etc/selinux/config

Selinux=enforcing #修改SELinux的状态
#enforcing SELinux has been turned on
#permissive SELinux temporarily shuts down, warning message will be prompted
#disabled SELinux shut down completely

[[email protected] ~]# grep "selinux="/etc/selinux/config
Selinux= can take one of these three values
Selinux=disabled

2.2 Command Line Temp--failed after restarting Linux

[Email protected] ~]# #查看selinux状态
[Email protected] ~]# Getenforce
Enforcing
[Email protected] ~]# #当前SElinux状态
[Email protected] ~]#
#setenforce 1 ======= Open SELinux
0 ======= temporarily closed SELinux
[Email protected] ~]# Setenforce 0
[Email protected] ~]# Getenforce
Permissive

Don't give yourself any leverage to restart the server

Summary:
1. Temporary closure of Selinux-getenforce Setenforce
2. Permanently close the Selinux/etc/selinux/config
Vim
Sed
3. Check

2.3. Firewall iptables
Firewall-Look at the gate

When to use a firewall (security)
1. Server does not have a public IP, iptables off high concurrency
2. The server has a public IP (external network), iptables Open

Just getting started-iptables off

2.3.1 Temporarily closed iptables

[[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.

2.3.2 permanently closed iptables

#不让防火墙iptables start automatically on boot
#chkconfig managing Linux under the software can be powered on from boot
# #查看iptables状态 is self-booting

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

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

2.3.3 Check
/etc/init.d/iptables status
Chkconfig |grep IPT

Summary:
Https://www.processon.com/view/link/59e96ce1e4b00842bddfb5aa

See garbled characters in Chinese

3.1 How to solve the Chinese characters in Linux?

3.1.1 Preparation Posture
Method of character set identifying text symbol

UTF-8 Universal Code linux default character set

GBK

Why garbled characters appear
The Remote Connection tool (Xshell) character set differs from the system's character set

3.2 How to change the character set of a system
3.2.1 1th Milestone-View the character set used by the system
#LANG环境变量-The system's character set and voice are stored
[Email protected] ~]# $LANG
-bash:en_us. UTF-8: Command not found
[Email protected] ~]# echo $LANG
en_US. UTF-8
Language-Character Set
3.2.2 2nd Milestone-Modified character set-temporary-after re-login
[Email protected] ~]# export LANG=ZH_CN. UTF-8
[Email protected] ~]# echo $LANG
Zh_cn. UTF-8

3.2.3 3rd Milestone-Permanent Entry
[Email protected] ~]# cat/etc/sysconfig/i18n
Lang= "en_US. UTF-8 "
Sysfont= "Latarcyrheb-sun16"

source/etc/sysconfig/i18n

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.