linux命令小結

查看IP  ip a  php

測試ip   ping 10.0.0.128html

測試端口   telnet 10.0.0.128  22  # telnet + ip + 端口python

 

Linux - CentOS 7.4
基礎命令
系統優化+定時任務
nginx
nginx+py搭建網站linux

Linux
vmware fusion(mac) vmware workstation 12.0 (windows)
8.0
遠程鏈接工具:xshell (windows) mac(iterm2)
android juiceSSH
IOS termius android

Linux
Fedora
Red Hat Enterprise Linux RHEL 7.5
CentOS 紅帽收費去掉,logo去掉nginx

Debian
Ubuntu
SUSE OpenSUSEweb


https://mirrors.aliyun.com/centos/redis


F1
F2
F10
F12shell

intel virtual technology disabled(關閉)
enabled(開啓)
intel vtvim


網卡名稱 : eth0
ensxxx


vmware相關服務 要開啓
win+r 輸入 services.msc

VMware Authorization Service 正在運行/已啓動 自動
VMware DHCP Service 正在運行/已啓動 自動
VMware NAT Service 正在運行/已啓動 自動


遠程鏈接服務器 : 10.0.0.128
Xshell 免費
SecureCRT
putty

屌絲去洗浴中心之路

1.道路是否通暢 你到服務器之間
本地Shell-CMD-windows

2.是否有人劫財劫色

3.是否提供特殊服務

1.道路是否通暢 你到服務器之間
本地Shell-CMD-windows

[d:\~]$ ping 10.0.0.128

正在 Ping 10.0.0.128 具備 32 字節的數據:
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64

10.0.0.128 的 Ping 統計信息:
數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),
往返行程的估計時間(以毫秒爲單位):
最短 = 0ms,最長 = 0ms,平均 = 0ms

[d:\~]$ ping 10.0.0.130

正在 Ping 10.0.0.130 具備 32 字節的數據:
來自 10.0.0.1 的回覆: 沒法訪問目標主機。
請求超時。
請求超時。
請求超時。

10.0.0.130 的 Ping 統計信息:
數據包: 已發送 = 4,已接收 = 1,丟失 = 3 (75% 丟失),

 

2.是否有人劫財劫色
SeLinux
防火牆

3.

服務名稱 搓澡 按摩 特殊服務
暗號(端口號) 80 443 22

遠程鏈接服務 sshd 22
telnet 10.0.0.128 22
[d:\~]$ telnet 10.0.0.128 22

Connecting to 10.0.0.128:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
SSH-2.0-OpenSSH_7.4

Protocol mismatch.

Connection closed by foreign host.

Disconnected from remote host(10.0.0.128:22) at 12:17:03.

Type `help' to learn how to use Xshell prompt.
[d:\~]$ telnet 10.0.0.128 25


Connecting to 10.0.0.128:25...
Could not connect to '10.0.0.128' (port 25): Connection failed.

Type `help' to learn how to use Xshell prompt.

 

 

 


道路不通排查過程
1.ip地址
2.vmware 編輯-虛擬網絡編輯器
3.windows 服務
vmware相關服務 要開啓
win+r 輸入 services.msc

VMware Authorization Service 正在運行/已啓動 自動
VMware DHCP Service 正在運行/已啓動 自動
VMware NAT Service 正在運行/已啓動 自動

4.個人電腦/此電腦/文件夾 輸入 網絡鏈接

經過安裝包修復

CCleaner 把vmware相關信息 清理掉 從新安裝


總結:
1.建立虛擬機-部署CentOS 7.4
2.配置VMware虛擬網絡編輯器
3.經過Xshell鏈接虛擬機
4.沒法鏈接服務器排查過程(屌絲去洗浴中心之路)
5.xshell優化


下午:
操做與命令


空格和tab鍵

 


[root@oldboyedu-s8 ~]# #mkdir make directory
[root@oldboyedu-s8 ~]# mkdir /data
[root@oldboyedu-s8 ~]# #顯示目錄的內容
[root@oldboyedu-s8 ~]# #ls list
[root@oldboyedu-s8 ~]# ls /data/
[root@oldboyedu-s8 ~]# ls -l /data/
total 0

相對路徑與絕對路徑:
絕對路徑:從根開始的路徑(位置) /data etc/hosts
從根開始的路徑就是絕對路徑。

 


[root@oldboyedu-s8 data]# touch /data/oldboy.txt
[root@oldboyedu-s8 data]# ls -l /data/
total 0
-rw-r--r--. 1 root root 0 Apr 25 15:16 oldboy.txt


第1個里程碑-打開文件
vi /data/oldboy.txt

第2個里程碑-編輯文件
按i 進入到編輯模式

第3個里程碑-退出編輯模式
按esc退出編輯模式

第4個里程碑-保存退出
:wq write quit
#保存退出
:q!
#強制退出不保存


第5個里程碑-顯示文件內容
[root@oldboyedu-s8 data]# cat /data/oldboy.txt
I am studying linux.

vi/vim 快捷鍵
複製 yy
粘貼 p
刪除、剪切 dd
撤銷 u
把光標所在行到文件最後一行刪除 dG

移動光標
把光標移動到文件的最後一行 G
把光標移動到文件的第一行 gg

 

#I am studying linux.I am studying linux.I am studying linux.
#I am studying linux.I am studying linux.I am studying linux.
#I am studying linux.I am studying linux.I am studying linux.
#I am studying linux.I am studying linux.I am studying linux.

批量刪除

第1個里程碑-按ctrl + v 進入批量編輯模式

第2個里程碑-選擇

第3個里程碑-刪除 d

 

[root@oldboyedu-s8 data]# #copy cp
[root@oldboyedu-s8 data]#
[root@oldboyedu-s8 data]# cp /data/oldboy.txt /tmp/
[root@oldboyedu-s8 data]# ls -l /tmp/
total 8
-rwx------. 1 root root 836 Apr 25 11:03 ks-script-6cg4Xy
-rw-r--r--. 1 root root 183 Apr 25 15:56 oldboy.txt
drwx------. 3 root root 17 Apr 25 11:18 systemd-private-241350d318404b8eb4e0324ead618b12-chronyd.service-tG7NpS
drwx------. 3 root root 17 Apr 25 11:18 systemd-private-241350d318404b8eb4e0324ead618b12-vgauthd.service-bhBRbW
drwx------. 3 root root 17 Apr 25 11:18 systemd-private-241350d318404b8eb4e0324ead618b12-vmtoolsd.service-mHP4YZ
-rw-------. 1 root root 0 Apr 25 10:58 yum.log

 


2.5 把 /data 移動到 /root目錄下面

move mv

[root@oldboyedu-s8 data]# mv /data/ /root/
[root@oldboyedu-s8 data]# ls -l /data
ls: cannot access /data: No such file or directory
[root@oldboyedu-s8 data]# ls -l /r
root/ run/
[root@oldboyedu-s8 data]# ls -l /root/
total 4
-rw-------. 1 root root 1233 Apr 25 11:03 anaconda-ks.cfg
drwxr-xr-x. 2 root root 46 Apr 25 16:00 data

進入/root目錄下的data目錄,刪除oldboy.txt文件
remove
rm

[root@oldboyedu-s8 tmp]# cd /root/
[root@oldboyedu-s8 ~]# ls -l
total 4
-rw-------. 1 root root 1233 Apr 25 11:03 anaconda-ks.cfg
drwxr-xr-x. 2 root root 28 Apr 25 16:32 data
[root@oldboyedu-s8 ~]# pwd
/root
[root@oldboyedu-s8 ~]# rm -f data
rm: cannot remove ‘data’: Is a directory
[root@oldboyedu-s8 ~]# ls -l
total 4
-rw-------. 1 root root 1233 Apr 25 11:03 anaconda-ks.cfg
drwxr-xr-x. 2 root root 28 Apr 25 16:32 data
[root@oldboyedu-s8 ~]# rm -r data
rm: descend into directory ‘data’? y
rm: remove regular file ‘data/oldboy.txt.bak’? n
rm: remove directory ‘data’? n
[root@oldboyedu-s8 ~]# rm -rf data

 

[root@oldboyedu-s8 ~]# find /root/ -type f -name "oldboy.txt"
/root/oldboy.txt
[root@oldboyedu-s8 ~]#
[root@oldboyedu-s8 ~]#
[root@oldboyedu-s8 ~]#
[root@oldboyedu-s8 ~]# find /root/ -type f -name "*.txt"
/root/oldboy.txt
#*.txt 以.txt 結尾的文件

#find /root/ -type f -name "*.txt"
# 在哪裏找 -什麼類型 f(file)
# d(dir)

在/etc 找出以eth0結尾的文件


http://blog.51cto.com/lidao/1927347

老男孩教育每日一題-2017年5月18日-說說|(管道)與|xargs(管道xargs)的區別

 

[root@oldboyedu-s8 ~]# find /root/ -type f -name "*.txt"
/root/oldboy.txt
/root/alex.txt
[root@oldboyedu-s8 ~]# find /root/ -type f -name "*.txt" |xargs ls -l
-rw-r--r--. 1 root root 0 Apr 25 17:01 /root/alex.txt
-rw-r--r--. 1 root root 0 Apr 25 17:01 /root/oldboy.txt

# .. 當前目錄的上一級目錄
# . 當前目錄
[root@oldboyedu-s8 sysconfig]# cd /etc/sysconfig/network-scripts/
[root@oldboyedu-s8 network-scripts]# cd ../../../../../../../../../

[root@oldboyedu-s8 ~]# cat /data/test.txt
test
liyao
oldboy
[root@oldboyedu-s8 ~]# #在文件中過濾
[root@oldboyedu-s8 ~]# #顯示出文件中 你想要的或不想要的內容
[root@oldboyedu-s8 ~]# grep "oldboy" /data/test.txt
oldboy
[root@oldboyedu-s8 ~]# grep -v "oldboy" /data/test.txt
test
liyao
[root@oldboyedu-s8 ~]# head -2 /data/test.txt
test
liyao


2.10 已知/tmp下已經存在test.txt文件,如何執行命令才能把/mnt/test.txt拷貝到/tmp下覆蓋掉/tmp/test.txt,而讓系統不提示是否覆蓋(root權限下)。

\cp /tmp/test.txt /mnt/

#cp cp -i
#別名
[root@oldboyedu-s8 ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
#\cp 臨時取消cp命令的別名
#別名至關於給命令設置了 暱稱 或 快捷鍵

2.11 只查看ett.txt文件(共100行)內第20到第30行的內容

seq 40 > /oldboy/ett.txt
cat /oldboy/ett.txt

#sed默認輸出文件的每一行
[root@oldboyedu-s8 oldboy]# sed -n '20p' ett.txt
20
#-n 取消默認輸出
[root@oldboyedu-s8 oldboy]#
[root@oldboyedu-s8 oldboy]# sed -n '20,30p' ett.txt
20
21
22
23
24
25
26
27
28
29
30

 

2.12 把/oldboy目錄及其子目錄下全部以擴展名 .sh結尾的文件中,文件包含./hostlists.txt(oldboy)的字符串所有替換爲../idctest_iplist(oldgirl)
[root@oldboyedu-s8 oldboy]# find /oldboy/ -type f -name "*.sh"
/oldboy/test/del.sh
/oldboy/test.sh
/oldboy/t.sh
[root@oldboyedu-s8 oldboy]# #把一個文件的oldboy替換爲 oldgirl
[root@oldboyedu-s8 oldboy]# #替換
[root@oldboyedu-s8 oldboy]# sed 's#oldboy#oldgirl#g' /oldboy/t.sh
oldgirl
[root@oldboyedu-s8 oldboy]# cat /oldboy/t.sh
[root@oldboyedu-s8 oldboy]# cat /oldboy/t.sh
oldboy
[root@oldboyedu-s8 oldboy]# sed 's#oldboy#oldgirl#g' /oldboy/t.sh
oldgirl


第1個里程碑-找出想要的文件
find /oldboy/ -type f -name "*.sh"
第2個里程碑-替換1個文件的內容
sed 's#oldboy#oldgirl#g' /oldboy/t.sh
第3個里程碑-把find命令找出的文件交給sed
find /oldboy/ -type f -name "*.sh" |xargs sed 's#oldboy#oldgirl#g'


[root@oldboyedu-s8 oldboy]# find /oldboy/ -type f -name "*.sh"
/oldboy/test/del.sh
/oldboy/test.sh
/oldboy/t.sh
[root@oldboyedu-s8 oldboy]# sed 's#oldboy#oldgirl#g' /oldboy/t.sh
oldgirl
[root@oldboyedu-s8 oldboy]# find /oldboy/ -type f -name "*.sh" |xargs sed 's#oldboy#oldgirl#g'
oldgirl
oldgirl
oldgirl
[root@oldboyedu-s8 oldboy]# cat /oldboy/t.sh
oldboy
[root@oldboyedu-s8 oldboy]# find /oldboy/ -type f -name "*.sh" |xargs sed -i 's#oldboy#oldgirl#g'
[root@oldboyedu-s8 oldboy]# find /oldboy/ -type f -name "*.sh" |xargs cat
oldgirl
oldgirl
oldgirl

 

 


[root@oldboyedu-s8 network-scripts]# cd /etc/sysconfig/network-scripts/
[root@oldboyedu-s8 network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@oldboyedu-s8 network-scripts]# cd /tmp/
[root@oldboyedu-s8 tmp]# cd -
/etc/sysconfig/network-scripts
[root@oldboyedu-s8 network-scripts]# #cd - 快速進入你上一次的位置 從哪裏來回哪裏去
[root@oldboyedu-s8 network-scripts]# cd -
/tmp

 

[root@oldboyedu-s8 tmp]# cat -n /root/oldboy.txt
1 oldboy
2 oldboy
3 oldboy
4 oldboy
5 oldboy

vi/vim
nu==== number
:set nu 顯示行號
:set nonu 取消顯示行號


windows 建立壓縮包
linux 打包壓縮

建立一個壓縮包
tar zcf /tmp/etc.tar.gz /etc

z=== 經過gzip軟件進行壓縮
c=== create 建立
f=== file 指定壓縮包


[root@oldboyedu-s8 tmp]# tar zcf /tmp/etc.tar.gz /etc/
tar: Removing leading `/' from member names
[root@oldboyedu-s8 tmp]# ll /tmp/etc.tar.gz
-rw-r--r--. 1 root root 9916889 Apr 25 19:20 /tmp/etc.tar.gz

查看壓縮包內容
tar tf /tmp/etc.tar.gz
t === list 顯示壓縮包內容

解壓
[root@oldboyedu-s8 tmp]# cd /tmp/
[root@oldboyedu-s8 tmp]# tar xf etc.tar.gz

解壓到指定位置
[root@oldboyedu-s8 tmp]# tar xf etc.tar.gz -C /mnt/
[root@oldboyedu-s8 tmp]# ls -l /mnt/
total 12
drwxr-xr-x. 80 root root 8192 Apr 25 16:30 etc
-rw-r--r--. 1 root root 0 Apr 25 18:06 test.txt

總結:
1.建立虛擬機-部署CentOS 7.4
2.配置VMware虛擬網絡編輯器
3.經過Xshell鏈接虛擬機
4.沒法鏈接服務器排查過程(屌絲去洗浴中心之路)
5.xshell優化
6.必知必會命令 根據題目練習
7.find命令
8.打包壓縮
9.三劍客 grep sed

預習:
0.ping baidu.com
1.單引號 雙引號 區別
2.linux啓動過程 運行級別
3.如何關閉Selinux和防火牆
4.定時任務 同步系統時間
5.nginx

 

 

老男孩教育-python全棧8期-Linux運維基礎
李老師
QQ:918391635


1.mkdir
-p 建立多層目錄
2.ls list
-l 顯示詳細信息

3.cd change directory 進入到目錄中

4.pwd print working directory 顯示當前所在位置

5.touch 摸 建立文件 修改文件的時間戳

6.vi 編輯文件

7.cat 顯示文件內容

8.cp copy 複製

9.man 查詢命令的幫助

10. mv move 移動

11. rm remove 刪除文件或目錄
-f 強制刪除不提示

-r 遞歸刪除目錄

12. find 查找
-type f(file)
d(dir)
-name 名字

13. grep 三劍客老三 擅長 過濾
-v 排除

14. head 顯示文件的前幾行 默認顯示文件的前10行
-n2 === -2 顯示文件的前2行

15. tail 顯示文件的最後幾行 默認顯示文件的後10行
-n1 === -1 顯示文件的最後1行
-f 實時顯示文件的更新


16. sed 三劍客老二 擅長取行
-n 取消默認輸出
-i 修改文件的內容

-n '20p'
-n '20,30p'

's#oldboy#oldgirl#g'
's@oldboy@oldgirl@g'


17. tar 建立解壓查看壓縮包
zcf
tf
xf
-C

 



特殊符號:
1. * 任何 全部 *.log *.txt
2. .. 當前目錄的上一級目錄
3. . 當前目錄
4. | 管道
find + |xargs
5. > 重定向符號 先清空文件的內容 而後追加
6. >> 追加 把信息追加到文件的結尾

 

 

Linux - CentOS 7.4
基礎命令
系統優化+定時任務
nginx
nginx+py搭建網站

Linux
vmware fusion(mac) vmware workstation 12.0 (windows)
8.0
遠程鏈接工具:xshell (windows) mac(iterm2)
android juiceSSH
IOS termius

Linux
Fedora
Red Hat Enterprise Linux RHEL 7.5
CentOS 紅帽收費去掉,logo去掉

Debian
Ubuntu
SUSE OpenSUSE


https://mirrors.aliyun.com/centos/


F1
F2
F10
F12

intel virtual technology disabled(關閉)
enabled(開啓)
intel vt


網卡名稱 : eth0
ensxxx


vmware相關服務 要開啓
win+r 輸入 services.msc

VMware Authorization Service 正在運行/已啓動 自動
VMware DHCP Service 正在運行/已啓動 自動
VMware NAT Service 正在運行/已啓動 自動


遠程鏈接服務器 : 10.0.0.128
Xshell 免費
SecureCRT
putty

屌絲去洗浴中心之路

1.道路是否通暢 你到服務器之間
本地Shell-CMD-windows

2.是否有人劫財劫色

3.是否提供特殊服務

1.道路是否通暢 你到服務器之間
本地Shell-CMD-windows

[d:\~]$ ping 10.0.0.128

正在 Ping 10.0.0.128 具備 32 字節的數據:
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64
來自 10.0.0.128 的回覆: 字節=32 時間<1ms TTL=64

10.0.0.128 的 Ping 統計信息:
數據包: 已發送 = 4,已接收 = 4,丟失 = 0 (0% 丟失),
往返行程的估計時間(以毫秒爲單位):
最短 = 0ms,最長 = 0ms,平均 = 0ms

[d:\~]$ ping 10.0.0.130

正在 Ping 10.0.0.130 具備 32 字節的數據:
來自 10.0.0.1 的回覆: 沒法訪問目標主機。
請求超時。
請求超時。
請求超時。

10.0.0.130 的 Ping 統計信息:
數據包: 已發送 = 4,已接收 = 1,丟失 = 3 (75% 丟失),

 

2.是否有人劫財劫色
SeLinux
防火牆

3.

服務名稱 搓澡 按摩 特殊服務
暗號(端口號) 80 443 22

遠程鏈接服務 sshd 22
telnet 10.0.0.128 22
[d:\~]$ telnet 10.0.0.128 22

Connecting to 10.0.0.128:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.
SSH-2.0-OpenSSH_7.4

Protocol mismatch.

Connection closed by foreign host.

Disconnected from remote host(10.0.0.128:22) at 12:17:03.

Type `help' to learn how to use Xshell prompt.
[d:\~]$ telnet 10.0.0.128 25


Connecting to 10.0.0.128:25...
Could not connect to '10.0.0.128' (port 25): Connection failed.

Type `help' to learn how to use Xshell prompt.

 

 

 


道路不通排查過程
1.ip地址
2.vmware 編輯-虛擬網絡編輯器
3.windows 服務
vmware相關服務 要開啓
win+r 輸入 services.msc

VMware Authorization Service 正在運行/已啓動 自動
VMware DHCP Service 正在運行/已啓動 自動
VMware NAT Service 正在運行/已啓動 自動

4.個人電腦/此電腦/文件夾 輸入 網絡鏈接

經過安裝包修復

CCleaner 把vmware相關信息 清理掉 從新安裝


總結:
1.建立虛擬機-部署CentOS 7.4
2.配置VMware虛擬網絡編輯器
3.經過Xshell鏈接虛擬機
4.沒法鏈接服務器排查過程(屌絲去洗浴中心之路)
5.xshell優化


下午:
操做與命令


空格和tab鍵

 


[root@oldboyedu-s8 ~]# #mkdir make directory
[root@oldboyedu-s8 ~]# mkdir /data
[root@oldboyedu-s8 ~]# #顯示目錄的內容
[root@oldboyedu-s8 ~]# #ls list
[root@oldboyedu-s8 ~]# ls /data/
[root@oldboyedu-s8 ~]# ls -l /d
data/ dev/
[root@oldboyedu-s8 ~]# ls -l /data/
total 0

 

 

老男孩教育-python全棧8期-Linux運維基礎
李老師
QQ:918391635

Linux - CentOS 7.4
基礎命令
系統優化+定時任務
nginx


1.虛擬機能夠聯網
ping baidu.com


2.linux下面安裝軟件

1)經過yum安裝軟件 須要你聯網


2) 更改系統的yum源 阿里雲
#https://opsx.alibaba.com/mirror 來源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3)安裝經常使用軟件

yum install -y tree bash-completion wget vim

 

 

Linux沒法上網排查過程
1. 查看是否能上網
[root@bigdata ~]# ping baidu.com
connect: 網絡不可達

2. 驗證是否DNS 域名解析 域名---->ip地址
[root@bigdata ~]# ping 223.5.5.5
connect: 網絡不可達

3. 網關-驗證你的網絡配置(網卡 虛擬機vmwarexxx)是否有問題
ip r
[root@bigdata ~]# ping 10.0.0.2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=128 time=0.206 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=128 time=0.170 ms
^C
--- 10.0.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.170/0.188/0.206/0.018 ms

 

使用CentOS7.4 光盤鏡像

1.把光盤插入到系統

2.在linux使用光盤
[root@oldboyedu-s8 ~]# mount /dev/cdrom /mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@oldboyedu-s8 ~]# #mount 給/dev/cdrom 建立一個入口 /mnt
[root@oldboyedu-s8 ~]# cd /mnt/
[root@oldboyedu-s8 mnt]# ls -l
total 664
-rw-rw-r--. 3 root root 14 Sep 5 2017 CentOS_BuildTag
drwxr-xr-x. 3 root root 2048 Sep 5 2017 EFI
-rw-rw-r--. 3 root root 227 Aug 30 2017 EULA
-rw-rw-r--. 3 root root 18009 Dec 10 2015 GPL
drwxr-xr-x. 3 root root 2048 Sep 5 2017 images
drwxr-xr-x. 2 root root 2048 Sep 5 2017 isolinux
drwxr-xr-x. 2 root root 2048 Sep 5 2017 LiveOS
drwxrwxr-x. 2 root root 641024 Sep 5 2017 Packages
drwxr-xr-x. 2 root root 4096 Sep 5 2017 repodata
-rw-rw-r--. 3 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-7
-rw-rw-r--. 3 root root 1690 Dec 10 2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root 2883 Sep 6 2017 TRANS.TBL

[root@oldboyedu-s8 mnt]# ls -l /mnt/Packages/
Display all 3895 possibilities? (y or n)
[root@oldboyedu-s8 mnt]# ls -l /mnt/Packages/bash-completion-2.1-6.el7.noarch.rpm
-rw-rw-r--. 2 root root 87272 Jul 4 2014 /mnt/Packages/bash-completion-2.1-6.el7.noarch.rpm
[root@oldboyedu-s8 mnt]# rpm -ivh /mnt/Packages/bash-completion-2.1-6.el7.noarch.rpm
Preparing... ################################# [100%]
package bash-completion-1:2.1-6.el7.noarch is already installed
[root@oldboyedu-s8 mnt]# ll /mnt/Packages/telnet-
telnet-0.17-64.el7.x86_64.rpm telnet-server-0.17-64.el7.x86_64.rpm
[root@oldboyedu-s8 mnt]# ll /mnt/Packages/telnet-0.17-64.el7.x86_64.rpm
-rw-rw-r--. 2 root root 65632 Aug 11 2017 /mnt/Packages/telnet-0.17-64.el7.x86_64.rpm


1.Linux下面安裝軟件: yum 經過光盤安裝

yum
yum install

rpm -ivh

編譯安裝
三部曲: 備菜切菜 作菜 上菜
nginx ./configure make make install

2.如何使用光盤安裝軟件

3.Linux沒法上網排查過程

系統優化+定時任務
1.更改系統的yum源
#阿里雲 mirrors.aliyun.com
https://opsx.alibaba.com/mirror

#清華
https://mirrors.tuna.tsinghua.edu.cn/help/centos/

#網易
http://mirrors.163.com/.help/centos.html

雲服務 物理服務器

2.關閉SElinux
rpm -qa
#-qa query all
rpm -qa

1#永久 修改配置文件 重啓服務器以後生效

# enforcing - 已開啓 正在運行
# permissive - selinux關閉 警告提示
# disabled - 完全關閉
SELINUX=enforcing
|

SELINUX=disabled

cp /etc/selinux/config /etc/selinux/config.bak
#快捷鍵:esc + .(點) 使用上一個命令的最後一個東西(參數)

sed 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
[root@oldboyedu-s8 ~]# cat /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.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

2#臨時 重啓服務器以後失效
[root@oldboyedu-s8 ~]# getenforce
Enforcing
[root@oldboyedu-s8 ~]# #顯示當前selinux
[root@oldboyedu-s8 ~]# #顯示當前selinux的運行狀態
[root@oldboyedu-s8 ~]# setenforce
usage: setenforce [ Enforcing | Permissive | 1 | 0 ]
[root@oldboyedu-s8 ~]# setenforce 0
[root@oldboyedu-s8 ~]# getenforce
Permissive

小結:
selinux關閉
0.操做前備份操做後檢查
1.修改配置文件
2.命令行

防火牆

iptables
firewalld

[root@oldboyedu-s8 ~]# rpm -qa bash-completion
bash-completion-2.1-6.el7.noarch
#查詢防火牆狀態
systemctl status firewalld.service

#當前正在運行的防火牆 --- 臨時
systemctl stop firewalld.service

#讓防火牆不會開機自啓動 --- 永久
systemctl disable firewalld.service

#systemctl is-active firewalld.service
#is-active 是否正在運行 是否健在
#systemctl is-enabled firewalld.service
#is-enabled 是否開機自啓動
[root@oldboyedu-s8 ~]#
[root@oldboyedu-s8 ~]# systemctl is-active firewalld.service
unknown
[root@oldboyedu-s8 ~]# systemctl is-active crond.service
active
[root@oldboyedu-s8 ~]# systemctl is-enabled firewalld.service
disabled


[root@oldboyedu-s8 ~]# systemctl start firewalld.service
[root@oldboyedu-s8 ~]# systemctl is-active firewalld.service
active
[root@oldboyedu-s8 ~]#
[root@oldboyedu-s8 ~]# systemctl enable firewalld.service
Created symlink from /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service to /usr/lib/systemd/system/firewalld.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/firewalld.service to /usr/lib/systemd/system/firewalld.service.
[root@oldboyedu-s8 ~]# systemctl is-enabled firewalld.service
enabled

小結:
systemctl 管理服務
如何關閉防火牆
systemctl stop firewalld
systemctl disable firewalld

systemctl status firewalld
systemctl is-active firewalld
systemctl is-enabled firewalld

systemctl enable firewalld.service

crond 定時任務
同步系統時間 √
備份


檢查crond狀態
[root@oldboyedu-s8 ~]# rpm -qa cronie
cronie-1.4.11-17.el7.x86_64
[root@oldboyedu-s8 ~]# systemctl is-active crond.service
active
[root@oldboyedu-s8 ~]# systemctl is-enabled crond.service
enabled

#定時任務管理命令
[root@oldboyedu-s8 ~]# crontab -l
no crontab for root

[root@oldboyedu-s8 ~]# crontab -e
#oldboyedu.com

#-e edit
#-l list

定時任務格式


天天的早上8:30到學校上車(go to school)
30 08 * * * go to school

天天的晚上12點整回家本身開車(go to bed)
00 00 * * * go to bed


如何修改系統時間
[root@oldboyedu-s8 ~]# date
Thu Apr 26 12:13:53 CST 2018
[root@oldboyedu-s8 ~]# date -s "20180101 01:01:01"
Mon Jan 1 01:01:01 CST 2018
[root@oldboyedu-s8 ~]# date
Mon Jan 1 01:01:05 CST 2018

讓系統自動同步時間
yum install ntpdate -y
[root@oldboyedu-s8 ~]# ntpdate ntp1.aliyun.com
26 Apr 12:19:53 ntpdate[18819]: step time server 182.92.12.11 offset 9976502.795919 sec
[root@oldboyedu-s8 ~]# date
Thu Apr 26 12:20:24 CST 2018


ntpdate ntp1.aliyun.com
ntpdate ntp2.aliyun.com
ntpdate ntp3.aliyun.com
ntpdate ntp4.aliyun.com
ntpdate ntp5.aliyun.com
ntpdate ntp6.aliyun.com
ntpdate ntp7.aliyun.com


#顯示命令的絕對路徑
[root@oldboyedu-s8 ~]# which ntpdate
/usr/sbin/ntpdate
[root@oldboyedu-s8 ~]# find / -type f -name "ntpdate"
/etc/sysconfig/ntpdate
/usr/sbin/ntpdate

#每2分鐘同步一次系統時間

###1.命令行測試
[root@oldboyedu-s8 ~]# /usr/sbin/ntpdate ntp1.aliyun.com
26 Apr 12:28:11 ntpdate[19018]: adjust time server 182.92.12.11 offset 0.000723 sec

###2.命令寫入定時任務
[root@oldboyedu-s8 ~]# crontab -l
#sync time
*/2 * * * * /usr/sbin/ntpdate ntp1.aliyun.com

###3.進行檢查與測試
[root@oldboyedu-s8 ~]# date -s "20190101"
Tue Jan 1 00:00:00 CST 2019
[root@oldboyedu-s8 ~]# date
Tue Jan 1 00:00:01 CST 2019
[root@oldboyedu-s8 ~]# date
Thu Apr 26 12:31:25 CST 2018


總結:
1.安裝經常使用軟件
yum rpm 編譯安裝
2.linux優化
1)yum源配置
增長經常使用yum源 :
epel源
yum install wget -y
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
yum repolist
yum install sl cowsay -y


2)關閉selinux和防火牆
3.定時任務 執行命令

下午:
nginx

做用:
1.web網站
2.nginx+其餘fastcgi(php)/ uwsgi(python)

部署nginx
1#下載nginx

wget http://nginx.org/download/nginx-1.12.2.tar.gz

yum install pcre-devel openssl-devel -y

#編譯安裝三部曲 : ./configure make make install

tar xf nginx-1.12.2.tar.gz
cd nginx-1.12.2

./configure --prefix=/application/nginx-1.12.2 --with-http_stub_status_module --with-http_ssl_module
make
make install


故障1:
error: the HTTP rewrite module requires the PCRE library.
yum install pcre-devel -y


[root@oldboyedu-s8 nginx-1.12.2]# ll /application/nginx-1.12.2/
total 4
drwxr-xr-x. 2 root root 4096 Apr 26 15:55 conf #configure nginx配置文件
drwxr-xr-x. 2 root root 40 Apr 26 15:55 html #站點目錄 網站根目錄
drwxr-xr-x. 2 root root 6 Apr 26 15:55 logs #日誌
drwxr-xr-x. 2 root root 19 Apr 26 15:55 sbin #nginx管理命令

#檢查語法
/application/nginx-1.12.2/sbin/nginx -t

#啓動nginx
/application/nginx-1.12.2/sbin/nginx


/application/nginx-1.12.2/sbin/nginx -s reload


#nginx配置說明

nginx.conf #nginx配置文件
nginx.conf.default #

#對比兩個文件區別
diff conf/nginx.conf conf/nginx.conf.default

egrep -v "#|^$" /application/nginx-1.12.2/conf/nginx.conf.default >/application/nginx-1.12.2/conf/nginx.conf


1 worker_processes 1;
2 events {
3 worker_connections 1024;
4 }
5 http {
6 include mime.types; #媒體類型
7 default_type application/octet-stream;
8 sendfile on; #開啓高效的傳輸模式
9 keepalive_timeout 65; #超時時間
10 server { #一個server至關因而一個網站 虛擬主機
11 listen 80; #監聽的端口
12 server_name www.etiantian.org; #網站名字 域名
13 location / {
14 root html; #根 站點的根目錄
15 index index.html index.htm; #首頁文件
16 }
21 }
22 }

 

總結:
1.nginx部署 配置
2.定時任務
3.系統優化 配置和增長yum源 關閉selinux和防火牆
4.安裝軟件方法
5.linux下面如何使用光盤

再約:1.redis2.lnmp(python)

相關文章
相關標籤/搜索