Linux 2 學習筆記
資工三 李易 111010512
WinSCP
上課影片,資料的FTP Server
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
第一週
Overview
- yum
- df dd du wc tr ssh scp
- shell script
- network related commands
- scheduling
- www server
- mysql
- php
domain server
…servers
Command
hostname
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
修改主機名稱
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
第二台主機
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
rpm
查詢
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
刪除 & 安裝
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
systemctl
active (running)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
inactive (dead)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
disable
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
enable
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Settings
Wired
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
DNS
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
NAT
前往 CentOS 在 VirtualBox 底下的網路卡設定,在介面卡1
啟動NAT
網路卡,在介面卡2
啟動僅限主機介面卡
,並選擇VirtualBox Host-Only Ethernet Adapter
。如果找不到該介面卡,就前往檔案 > 工具 > Network Manager
自行新增,且新增時要勾選DHCP Server
。
Connection
ping
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
ssh
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
第二週
快捷鍵
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
NAT 設定
VirtualBox
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
VMware
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
連線
ssh
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
PuTTY
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
無密碼登入 (必考)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
scp
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
rpm
https://www.twblogs.net/a/5c361a28bd9eee35b3a5791a
套件查詢 (必考)
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
第三週
如果伺服器不能跑
- 使用 super user
- getenforce -> Disabled
- systemctl status firewalld —> inactive
- netstat -tunlp | grep xxx 檢查開啟的 port
架設網頁伺服器
查詢

安裝

啟動

檢查

預設centos 7 下httpd的家目錄是在/var/www/html下

連線


目前架設的www server只能運作在內部網路…外部網路internet是無法存取的
作業
寫一個有圖片跟文字的 htm

用 WinSCP 傳到虛擬機


把檔案移動到 /var/www/html 下

打開網頁檢查

ngrok
https://ngrok.com/



wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz --no-check-certificate


./ngrok config add-authtoken 2VvJAgRK2RrjqPSlctKkR2Ids50_3Q7h4MdQNjZB932rnfFds



repo

https://www.cnblogs.com/yaoyaojcy/p/17139639.html

htop
https://src.fedoraproject.org/lookaside/extras/htop/htop-2.2.0.tar.gz/sha512/ec1335bf0e3e0387e5e50acbc508d0effad19c4bc1ac312419dc97b82901f4819600d6f87a91668f39d429536d17304d4b14634426a06bec2ecd09df24adc62e/








Command
du
.
此目錄 ..
上一層目錄



df



第四週
NFS
https://qizhanming.com/blog/2018/08/08/how-to-install-nfs-on-centos-7











客戶端操作





Command
df

dd

wc





tr
https://wangchujiang.com/linux-command/c/tr.html











cat


ssh
https://nqucsie.myqnapcloud.com/smallko/sdn/sshtunnel.htm
seq


bc

作業
算這個網頁有多少個字:
https://nqucsie.myqnapcloud.com/smallko/sdn/frp.htm
第五週
Samba
https://josephjsf2.github.io/linux/2019/11/01/share_centos_folder_with_windows.html
https://github.com/stereomp3/note/blob/main/linux/111semester01/3-SAMBA.md#SAMBA
Samba vs NFS

檢查連線


selinux要是disabled


基礎設定
















作業
把 Samba 跟 NFS 綁定在同一個資料夾

切換使用者
新增帳號前要確保帳號不存在







sort
ascii code











sort : -g -r -k -t (預設是小排到大)
作業
把下列內容從大排到小
031,111:3
2,555:6
1345:222,5
001,666,4
014,444,2

uniq

cut




dd

split

diff


hostname

mail


第六週
IPv6


ping -6 2001:b400:e785:5b37:20c:29ff:fea3:f136
VMware Setting

Edit->virtual Network editor


VirtualBox Setting


ping
windows: ping -6
linux: ping6

PuTTY


Website

Free Dynamic DNS
https://dynv6.com/


Command
cp

echo

雙引號會進行替換, 單引號不會 (考試重點)



sh


other



Setting
如果是自己的配置,修改檔案室自身目錄下的.bashrc
如果希望套用到整個系統的使用者,修改的檔案是/etc/profile,記得要用root

當中的設定會套用到所有使用者
第七週
Command Variable



必考 (雙引號會替換, 單引號不會)



return value



;
vs &&


連接多個指令可以用 ;
&&
||

>
就是清空內容


這裡要留空白




數值比較



數字比較不要用=,>=,<=,等符號

shell script


參數

判斷

迴圈


括號

https://blog.csdn.net/new_delete_/article/details/121160836
要有空格


執行
https://blog.csdn.net/jiushiggg/article/details/123166505
第八週
VPN
https://cc.nqu.edu.tw/p/404-1009-1326.php?Lang=zh-tw


金門大學vpn server:60.248.63.195
port:443
PPTP VPN
https://github.com/stereomp3/note/blob/main/linux/111semester01/7-VPN.md#pptpd
https://help.aliyun.com/zh/ecs/how-do-i-configure-a-connection-between-a-pptp-vpn-server-and-a-pptp-vpn-client-on-a-centos-7-instance
記得要先打:
yum install -y epel-release
VMware Setting







VirtualBox Setting




Other Setting

在設定windows的vpn時
如果是用vmware, ip填的是centos7 第一張網卡的ip
如果是用virtual box, ip填寫的是centos7 第二張網卡host only ip


第九週
Bash Script
https://medium.com/vswe/bash-shell-script-cheat-sheet-15ce3cb1b2c7
取得部分字串/字元數

字串長度

兩者一樣

取代部分字串

腳本
for i in {1..10}; do
if ((i%2==0)); then
continue
fi
if ((i==7)); then
break
fi
echo "${i}" # print 1, 3, 5
done
多重判斷 (AND, OR)

if 的括號

正則表達式


陣列

整數運算

小數運算

建議數字比較一律用 ((…))
,字串比較再用 [[ ... ]]
Net
NetworkManager vs Network

管理網路介面卡

清除網路設定

調整 MTU (Maximum transmission unit)

改網路卡卡號

設定 IP

新增介面卡邏輯分身

新 ip 指令
ip address show = ip addr show = ip a s

在介面卡新增 IP

在介面卡移除 IP

路由表

手動新增路由 – 內定路由

必考
取消 NM 改用 network 服務
- 輸入
systemctl stop NetworkManager
,把 NetworkManger 關掉。
- 輸入
ifconfig
,查看 NAT 介面卡 (enp0s3) 的 IP 位址及 MAC 位址。(10.0.2.15 / 08:00:27:4d:62:da)
- 輸入
route -n
查看內定路由及網路遮罩。(10.0.2.2 / 255.255.255.0)
- 前往
/etc/sysconfig/network-scripts/
,刪掉除了 ifcfg-lo
以外的 ifcfg
設定檔案。(ifcfg-enp0s3
、ifcfg-enp0s8
、ifcfg-Wired_connection_1
)
- 新增
ifcfg-enp0s3
,並寫入下列配置:
TYPE=Ethernet
DEVICE=enp0s3 // NAT 介面卡
ONBOOT=yes
IPADDR=10.0.2.15 // 剛剛查看的 IP 位址
HWADDR=08:00:27:4d:62:da // 剛剛查看的 MAC 位址
NETMASK=255.255.255.0 // 剛剛查看的網路遮罩
GATEWAY=10.0.2.2 // 剛剛查看的內定路由
- 輸入
systemctl restart network
,然後就大功告成。
第十週
Net
DNS (重要)

netstat 參數

System
linux系統中process id =1,這隻行程叫做systemd


sshd 配置檔 (幫你呼叫systemctl)

Echo Server (必考)
https://blog.gtwang.org/linux/linux-create-systemd-service-unit-for-python-echo-server-tutorial-examples/
(用 PuTTY 傳程式)
Telnet (必考)
https://cloud.tencent.com/developer/article/2274078





(用 PuTTY 連連看)
第十一週
LAMP (必考)
https://github.com/stereomp3/note/blob/main/linux/111semester01/13-.md
https://www.fooish.com/sql/create-table.html







Apache (httpd)
UserDir
https://www.ltsplus.com/apache/rhel-centos-7-enable-userdir

- vim /etc/httpd/conf.d/userdir.conf
- UserDir disabled -> enabled
取消註解 UserDir public_html
- mkdir /home/user/public_html
- vim /home/user/public_html/index.html
- chmod 777 /home/user
- systemctl restart httpd
http://192.168.56.100/~user/index.html
kill

Alias
(可能要調整 /data 的權限) (chmod 777 /data)

- vim /etc/httpd/conf/httpd.conf
-
Alias /abc /data
<Directory /data>
Require all granted
<Directory>
- mkdir /data
- vim /data/hi.htm
http://192.168.56.100/abc/hi.htm
grep
過濾出空白行還有#行

第十二週
IPv6 HTTPS
https://yowlab.idv.tw/wordpress/?p=1390










allow, deny

AllowOverride
課本 15-29 必考


第十三週
AllowOverride





抓 IP

驗證登入






FTP
Install




Login




多檔案傳輸
bin: Switching to binary mode

prompt: Interactive mode off

umask
