系統(tǒng)優(yōu)化
1.系統(tǒng)用戶優(yōu)化 (一次創(chuàng)建多個(gè)用戶)
腳本如何創(chuàng)建多個(gè)用戶
#!/bin/bash --- 編寫腳本固定格式
for i in {1..10}
do
useradd stui
done
- 命令提示符優(yōu)化
命令提示符信息組成:PS1
設(shè)置命令提示符顏色
PS1='[\e[32;1m][\u@\h \W]\[\e[0m] 信息添加顏色開始 添加顏色信息 信息添加顏色結(jié)束
- 系統(tǒng)yum源優(yōu)化
yum倉庫: 匯總保存多個(gè)軟件包 yum源: /etc/yum.repos.d 配置好yum源文件,便于找到指定的yum倉庫
yum可以解決軟件的依賴的服務(wù)器
(1) 優(yōu)化基礎(chǔ)yum(base)
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
(2) 優(yōu)化擴(kuò)展yum(epel -- Extra Packages for Enterprise Linux)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
2.軟件無法正常yum下載的原因
(1)網(wǎng)絡(luò)配置不正確 ping 外網(wǎng)測試一下
如:ping www.baidu.com
(2) yum 源是否更新
(3) yum 緩存需要清除 yum clean all
查看軟件是否安裝:
rpm -qa + 軟件名
查看軟件都安裝哪些信息:
rpm -ql +軟件名
系統(tǒng)安全有關(guān)的優(yōu)化
netstat -lntup --- 查看網(wǎng)絡(luò)服務(wù)端口號(hào)碼信息
防火墻的優(yōu)化:關(guān)閉
centos7
臨時(shí)關(guān)閉:
systemctl stop firewalld.service systemctl start firewalld.service (臨時(shí)開啟)
永久關(guān)閉:
systemctl disable firewalld.service systemctl enable firewalld.service(永久開啟)
查看狀態(tài):
systemctl status firewalld.service
systemctl is-active firewalld.service --- 檢查服務(wù)是否臨時(shí)關(guān)閉或開啟
systemctl is-enabled firewalld.service --- 檢查服務(wù)是否永久關(guān)閉或開啟
centos6
臨時(shí)關(guān)閉:
/etc/init.d/iptables stop
/etc/init.d/iptables status
永久關(guān)閉:
chkconfig iptable off
chkconfig iptables on
chkconfig --list|grep iptables
chkconfig --list iptables
selinux: 企業(yè)中都會(huì)關(guān)閉(安全程序和root權(quán)限有關(guān)) --- 關(guān)閉
centos7:
臨時(shí)關(guān)閉:
setenforce 0
getenforce --- 查看selinux狀態(tài)
Enforcing /1 --- selinux處于開啟狀態(tài)
Permissive /0 --- selinux處于臨時(shí)關(guān)閉
永久關(guān)閉:
/etc/selinux/config
(1) enforcing - SELinux security policy is enforced.
selinux安全策略是開啟狀態(tài)
(2) permissive - SELinux prints warnings instead of enforcing.
selinux顯示警告信息代替開啟狀態(tài) == 臨時(shí)關(guān)閉
(3) disabled - No SELinux policy is loaded.
禁止selinux策略加載
SELINUX=disabled
修改文件信息的方法:1. vi
2.替換 如:用vi 編輯底行模式 :7s#原內(nèi)容#替換內(nèi)容#g
3. 使用 sed sed -i '7s#enforcing#disabled#g' /etc/selinux/config
-
系統(tǒng)字符編碼優(yōu)化
作用:1.避免出出現(xiàn)亂碼 2. 部分信息顯示中文
查看系統(tǒng)字符編碼:echoLANG
zh_CN.UTF-8
修改字符編碼:
centos6
臨時(shí)調(diào)整:
export LANG="en_US.UTF-8"
永久調(diào)整:
vim /etc/sysconfig/i18n
LANG="en_US.GBK"
centos7:
臨時(shí)調(diào)整:
export LANG="en_US.UTF-8"
永久調(diào)整:
vim /etc/locale.conf
LANG="en_US.GBK"
source /etc/locale.conf
localectl set-locale LANG="en_US.UTF-8"設(shè)置系統(tǒng)提示信息為中文: localectl set-locale LANG="zh_CN.UTF-8"
-
系統(tǒng)時(shí)間和時(shí)區(qū)優(yōu)化
查看時(shí)間和時(shí)區(qū)信息
timedatectl
[root@www ~]# timedatectl
Local time: Tue 2019-07-16 10:12:30 CST
Universal time: Tue 2019-07-16 02:12:30 UTC
RTC time: Tue 2019-07-16 02:12:30
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/atimedatectl set-time 18:49 --- 設(shè)置時(shí)間信息 timedatectl set-timezone Asia/Shanghai --- 設(shè)置時(shí)區(qū)信息 ****** timedatectl list-timezones --- 顯示時(shí)區(qū)信息 set-local-rtc BOOL --- 設(shè)置RTC功能是否開啟 BOOL(數(shù)據(jù)布爾型--0/1 false/true) RTC是否修改硬件主板時(shí)間 set-ntp BOOL --- 設(shè)置NTP功能是否開啟 會(huì)通過網(wǎng)絡(luò)自動(dòng)同步時(shí)間 手動(dòng)同步時(shí)間方法: yum install -y ntpdate ntpdate "ntp1.aliyun.com" timedatectl命令操作不了: 第一個(gè)里程: 安裝時(shí)間同步軟件 yum install -y chrony systemctl start chronyd 第二個(gè)里程: 修改同步方式 timedatectl set-ntp 1