-
系統(tǒng)yum源優(yōu)化(base、epel)
-
系統(tǒng)安全優(yōu)化(防火墻、selinux)
-
系統(tǒng)字符集優(yōu)化
-
系統(tǒng)時(shí)間和時(shí)區(qū)修改方法
-
一些快捷鍵的使用
1.系統(tǒng)yum源優(yōu)化
?yum倉(cāng)庫(kù):匯總保存多個(gè)軟件包的服務(wù)器
?yum源路徑:/etc/yum.repos.d(配置好yum源文件闷愤,便于找到指定的yum倉(cāng)庫(kù))
[root@oldboy63 ~]# ll /etc/yum.repos.d/
total 36
-rw-r--r--. 1 root root 2523 Jul 15 16:09 CentOS-Base.repo -----這個(gè)是聯(lián)網(wǎng)后基礎(chǔ)的源,一般都用這個(gè)
-rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo -----debug包尤其和內(nèi)核相關(guān)的更新和軟件安裝
-rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo -----這個(gè)是使用光盤掛載后調(diào)用的文件
-rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo -----這個(gè)是最近新版本的加入的老版本的yum源配置
?優(yōu)化基礎(chǔ)源(base)
[root@oldboy63 /etc/yum.repos.d]# cat CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo ----依賴阿里源
優(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 ----執(zhí)行不成時(shí)安裝wget
yum install -y wget
[root@oldboy63 /etc/yum.repos.d]# ll
total 36
-rw-r--r--. 1 root root 2523 Jul 15 16:09 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Nov 23 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Nov 23 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Nov 23 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Nov 23 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Nov 23 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 5701 Nov 23 2018 CentOS-Vault.repo
-rw-r--r--. 1 root root 664 May 11 2018 epel.repo
?一些軟件安裝
yum install -y vim -----vi升級(jí)版
??nc 、nmap、net-tools ---和網(wǎng)絡(luò)有關(guān)的命令
??sl咸包、cowsay ---搞笑的軟件包
??bash-completion ---對(duì)一些命令參數(shù)進(jìn)行補(bǔ)全
PS:解決軟件無(wú)法正常yum下載的思路:
1.網(wǎng)絡(luò)配置不正確 ---ping baidu.com
2.yum源是否更新
3.yum緩存需要清除 ----yum clean all
查看一些軟件是否安裝:
如:rpm -qa cowsay
查看軟件都安裝哪些信息:
如:rpm -ql cowsay
查詢一個(gè)命令出自哪個(gè)軟件包:
第一種方式:已經(jīng)安裝了該軟件
[root@oldboy63 ~]# which animalsay ---顯示命令對(duì)應(yīng)文件所在路徑
/usr/bin/animalsay
[root@oldboy63 ~]# rpm -qf /usr/bin/animalsay
cowsay-3.04-4.el7.noarch
執(zhí)行原理:animalsay ---PATH---/usr/bin/animalsay
第二種方式:未安裝該軟件
yum provides animalsay
2.系統(tǒng)安全有關(guān)的優(yōu)化
?防火墻優(yōu)化:需要關(guān)閉
centos6:
臨時(shí)關(guān)閉:
/etc/init.d/iptables stop
/etc/init.d/iptables status ----關(guān)閉后查看狀態(tài)
永久關(guān)閉:
chkconfig iptables off
chkconfig iptables on ----開啟
查看是否開啟狀態(tài):
chkconfig --list|grep iptables
chkconfig --list iptables
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)閉或開啟
⑵.selinux:
一種針對(duì)Linux的安全加強(qiáng)系統(tǒng)
centos7:
臨時(shí)關(guān)閉:
setenforce 0
Enforcing / 1 ------selinux處于開始狀態(tài)
Permissive / 0 ------selinux處于臨時(shí)關(guān)閉狀態(tài)
getenforce --- 查看selinux狀態(tài)
永久關(guān)閉:
/etc/selinux/config
# enforcing - SELinux security policy is enforced.
selinux安全策略是開啟狀態(tài)
# permissive - SELinux prints warnings instead of enforcing.
selinux顯示警告信息代替開啟狀態(tài) == 臨時(shí)關(guān)閉
# disabled - No SELinux policy is loaded.
禁止selinux策略加載
SELINUX=disabled
修改文件信息:
方法一:vi編輯
方法二:底行模式替換:7s#enforcing#disabled#g
方法三:sed -i '7s#enforcing#disabled#g' /etc/selinux/config
3.系統(tǒng)字符編碼優(yōu)化
作用:1.避免中文出現(xiàn)亂碼
??????2.部分信息顯示中文
查看與修改系統(tǒng)字符編碼:
查看:
[root@oldboy63 ~]# echo $LANG
en_US.UTF-8
修改:
centos6:
臨時(shí)修改:export LANG="en_US.UTF-8"
永久修改:vim /etc/sysconfig/i18n
如:LANG="en_US.GBK"
centos7:
臨時(shí)修改:export LANG="en_US.UTF-8"
永久修改:vim /etc/locale.conf
如:LANG="en_US.GBK"
source /etc/locale.conf
既臨時(shí)又永久(設(shè)置為中文):
localectl set-locale LANG="zh_CN.UTF-8"
4.系統(tǒng)時(shí)間和時(shí)區(qū)優(yōu)化
查看時(shí)間和時(shí)區(qū)信息:
[root@oldboy63 ~]# timedatectl
Local time: Tue 2019-07-16 09:13:58 CST
Universal time: Tue 2019-07-16 01:13:58 UTC
RTC time: Tue 2019-07-16 01:13:59
Time zone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a
timedatectl set-time 時(shí)間 ----設(shè)置時(shí)間信息
timedatectl set-timezone 時(shí)區(qū)(如:Asia/Shanghai) ---設(shè)置時(shí)區(qū)信息
timedatectl list-timezones ---顯示時(shí)區(qū)信息
timedatectl set -local-rtc BOOL ---設(shè)置RTC功能是否開啟
RTC:是否修改硬件主板時(shí)間
timedatectl set -ntp BOOL ---設(shè)置NTP功能是否開啟
會(huì)通過(guò)網(wǎng)絡(luò)自動(dòng)同步時(shí)間
手動(dòng)同步時(shí)間的方法:
yum install -y ntpdate
ntpdate "ntp1.aliyun.com"
[root@oldboy63 ~]# ntpdate "ntp1.aliyun.com"
16 Jul 09:59:13 ntpdate[78106]: adjust time server 120.25.115.20 offset -0.005130 sec
PS:timedatectl命令操作不了:
第一個(gè)里程:安裝同步時(shí)間軟件
yum install -y chrony
開始服務(wù):systemctl start chronyd
第二個(gè)里程:修改同步方式
timedatectl set-ntp 1
擴(kuò)展:
優(yōu)化SSH遠(yuǎn)程連接慢
第一個(gè)優(yōu)化:修改/etc/hosts文件
?? 10.0.0.200 oldboy63.com
第二個(gè)優(yōu)化:修改/etc/ssh/sshd_config
79 GSSAPIAuthentication yes ---> GSSAPIAuthentication no --- 關(guān)閉GSSAPI認(rèn)證功能
115 #UseDNS yes ---> UseDNS no --- 關(guān)閉了DNS反向解析功能
系統(tǒng)快捷鍵
ctrl+a -----將光標(biāo)移動(dòng)到命令行頭部
ctrl+e -----將光標(biāo)移動(dòng)到命令行尾部
ctrl+u -----刪除光標(biāo)以前所有的內(nèi)容(剪切)
ctrl+k -----刪除光標(biāo)以后所有的內(nèi)容(剪切)
ctrl+s -----使xshell進(jìn)入鎖定狀態(tài)(不能代替鎖屏)
ctrl+q -----退出xshell鎖定狀態(tài)