內容選單標籤

2021年12月15日 星期三

CentOS8 指令練習與網路管理


system information
------------------------------------------------------

//uname - print system information
# uname -a
Linux centos.kk 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Tue Nov 16 14:42:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux



# cat /etc/redhat-release
CentOS Linux release 8.5.2111



# cat /proc/version
Linux version 4.18.0-348.2.1.el8_5.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)) #1 SMP Tue Nov 16 14:42:35 UTC 2021







------------------------------------------------------
[root@centos ~]#
root:使用者
centos:主機名
~ :使用者家目錄
# :最高權限管理者



[kk1@centos ~]$
$:一班使用者


// show who is logged on
# who
root     pts/0        2021-12-16 08:21 (172.31.147.33)



//  Show who is logged on and what they are doing
# w
 08:22:27 up 32 min,  1 user,  load average: 0.09, 0.07, 0.02
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    172.31.147.33    08:21    0.00s  0.01s  0.00s w




// 關機馬上 halt
# shutdown -h now

// 關機10分鐘後
# shutdown -h 10

//重開機 reboot
# shutdown -r

#reboot


//list directory contents
// 列出 檔案系統 根目錄 下
# ls /
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr


// print name of current/working directory
# pwd
/root


// .. 上一層目錄,目前在 /root
# ls ..
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var


# ls ../
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var boot  etc  lib   media  opt  root  sbin  sys  usr


// . 目前所在目錄,目前在 /root ,同 # ls
# ls .
 anaconda-ks.cfg

# ls ./
 anaconda-ks.cfg



//Change  the current directory to dir
# cd /
# pwd
/
# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var




# date
四 12月 16 08:51:36 CST 2021



# echo $LANG
zh_TW.UTF-8




//取得語區資料特定的資訊
# locale --help

# locale
LANG=zh_TW.UTF-8
LC_CTYPE="zh_TW.UTF-8"
LC_NUMERIC="zh_TW.UTF-8"
LC_TIME="zh_TW.UTF-8"
LC_COLLATE="zh_TW.UTF-8"
LC_MONETARY="zh_TW.UTF-8"
LC_MESSAGES="zh_TW.UTF-8"
LC_PAPER="zh_TW.UTF-8"
LC_NAME="zh_TW.UTF-8"
LC_ADDRESS="zh_TW.UTF-8"
LC_TELEPHONE="zh_TW.UTF-8"
LC_MEASUREMENT="zh_TW.UTF-8"
LC_IDENTIFICATION="zh_TW.UTF-8"
LC_ALL=




# vi /etc/hostname
centos.kk


# hostnamectl set-hostname centos85.kk

# hostnamectl
   Static hostname: centos85.kk
         Icon name: computer-vm
           Chassis: vm
        Machine ID: d9fabbd997c54e8f8c8520cd37b792e1
           Boot ID: 79aaab2bf6d6447dbad2d71295dfb97c
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-348.2.1.el8_5.x86_64
      Architecture: x86-64




------------------------------------------------------cp, mv, rm
# pwd
/root

# ls ./
 anaconda-ks.cfg


# ls /etc/yum.conf
/etc/yum.conf


//copy files and directories
# cp /etc/yum.conf ./

# ls
 anaconda-ks.cfg  yum.conf



//--recursive 可用複製資料夾
# cp -r /etc/ssh ./
# ls ./
 anaconda-ks.cfg ssh  yum.conf



// move (rename) files
# mv yum.conf aa.conf
# ls
aa.conf  anaconda-ks.cfg  ssh


//remove files or directories
# rm aa.conf
rm:是否移除普通檔案'aa.conf'? y
# ls
anaconda-ks.cfg  ssh


// --recursive   --force
# rm -rf ssh
# ls
anaconda-ks.cfg







------------------------------------------------------ touch, cat, more, less, head, tail
// concatenate files and print on the standard output
//--number
# cat /etc/yum.conf
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=True
skip_if_unavailable=False

# cat -n /etc/yum.conf
     1  [main]
     2  gpgcheck=1
     3  installonly_limit=3
     4  clean_requirements_on_remove=True
     5  best=True
     6  skip_if_unavailable=False



// 產生 test.txt , > 將輸入文字寫入 test.txt 中
# cat>test.txt
I love linux !            //輸入完成按 Ctrl+D

# ls
anaconda-ks.cfg  test.txt

# cat test.txt
I love linux !



//SPACE     Display next k lines of text.  Defaults to current screen size.
//RETURN    Display next k lines of text.  Defaults  to  1    
// more - file perusal filter for crt viewing
# more anaconda-ks.cfg



//less - opposite of more
# less anaconda-ks.cfg


//head - output the first part of files
//預設10 列
# head anaconda-ks.cfg


//tail - output the last part of files
// 指定3列
# tail -3 anaconda-ks.cfg


// ----follow 持續監控記錄檔,有新資料馬上顯示    ^C 中斷
# tail -f anaconda-ks.cfg



//產生空白檔案
# touch kk1.txt
# ls -l
總計 4
-rw-------. 1 root root 1167 10月 15 19:05 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 12月 16 09:38 kk1.txt


//change file timestamps
# touch anaconda-ks.cfg
# ls -l
總計 4
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
-rw-r--r--. 1 root root    0 12月 16 09:38 kk1.txt






------------------------------------------------------mkdir, rmdir
// make directories
# mkdir dir1
# ls -l
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
drwxr-xr-x. 2 root root    6 12月 20 13:36 dir1

# touch dir1/file1.text

// remove empty directories
// -f, --force   -r, -R, --recursive
# rm -r dir1
rm: descend into directory 'dir1'? y
rm:是否移除普通空白檔案'dir1/file1.text'? y
rm:是否移除目錄'dir1'? y

# ls -l
總計 4
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg







------------------------------------------------------link

++++++++++++++++++++++softLink
# echo "Hello" > data.text

// -i, --inode
# ls -li
34576503 -rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
33576578 -rw-r--r--. 1 root root    6 12月 20 13:42 data.text

//-s, --symbolic make symbolic links instead of hard links
# ln -s data.text softLink

# ls -li
34576503 -rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
33576578 -rw-r--r--. 1 root root    6 12月 20 13:42 data.text
33577152 lrwxrwxrwx. 1 root root    9 12月 20 13:44 softLink -> data.text

// l: link    rwx: link 沒自己權限,視真實檔案為主
//2個 inode 編號不同

# cat softLink
Hello


# rm -f data.text
# ls -l softLink
lrwxrwxrwx. 1 root root 9 12月 20 13:44 softLink -> data.text

// slink 變成紅色警戒,表連結無效
//刪除 真實檔案的檔名
//符號連結 symbolic link 就無法取得真實檔案的 inode 資訊內的 Block 區塊位置

# cat softLink
cat: softLink: 沒有此一檔案或目錄


# rm softLink
rm:是否移除符號連結'softLink'? y
# ls -li
34576503 -rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg





++++++++++++++++++++++hardLink
# echo "World" >data2.text
# ls -l
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
-rw-r--r--. 1 root root    6 12月 20 14:05 data2.text

# ln data2.text hardLink
# ls -li
34576503 -rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
33576578 -rw-r--r--. 2 root root    6 12月 20 14:05 data2.text
33576578 -rw-r--r--. 2 root root    6 12月 20 14:05 hardLink

//2個 inode 編號相同

# rm -f data2.text
# ls -li
34576503 -rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
33576578 -rw-r--r--. 1 root root    6 12月 20 14:05 hardLink

# cat hardLink
World

// 硬連結 hard link 複製真實檔案的 inode 資訊,所以刪除 真實檔案的檔名
//硬連結仍可以取得真實檔案的 inode 資訊內的 Block 區塊位置 


symbolic link(軟)       可跨越分割區       支援目錄   刪除真實檔案後成無效連結   無法自訂權限
hard         link(硬)   不可跨越分割區   不支援目錄   刪除真實檔案後仍有效連結   可以自訂權限




------------------------------------------------------執行檔

//執行檔的絕對路徑
# ls /usr/bin/du
/usr/bin/du
#  /usr/bin/du
44      .


//環境變數 PATH 設定 自動搜尋目錄裡的執行檔
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
# du
44      .



# echo "HelloWorld!!" > runMe
# ls -l
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
-rw-r--r--. 1 root root   13 12月 20 14:21 runMe

# chmod u+x runMe
# ls -l
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
-rwxr--r--. 1 root root   13 12月 20 14:21 runMe

# runMe
-bash: runMe:命令找不到


//執行目前所在目錄下的執行檔
# ./runMe
./runMe: 列 1: HelloWorlddu:命令找不到







------------------------------------------------------硬碟空間使用情形

//report file system disk space usage 各分割區使用情況
//-h, --human-readable
# df -h
檔案系統                     容量  已用  可用 已用% 掛載點
devtmpfs                     886M     0  886M    0% /dev
tmpfs                        904M     0  904M    0% /dev/shm
tmpfs                        904M  8.7M  895M    1% /run
tmpfs                        904M     0  904M    0% /sys/fs/cgroup
/dev/mapper/cl_centos8-root  6.2G  1.4G  4.9G   23% /
/dev/sda1                    976M  136M  774M   15% /boot
tmpfs                        181M     0  181M    0% /run/user/0



//estimate file space usage 目前目錄下( 含子目錄)已用空間
 # du -h
32K     .


# ls /
bin   dev  home  lib64  mnt  proc  run   srv  tmp  var
boot  etc  lib   media  opt  root  sbin  sys  usr

 //-s, --summarize
# du -sh /var/
115M    /var/
# du -sh /var/*
0       /var/adm
24M     /var/cache
0       /var/crash
...







------------------------------------------------------重導輸出 redirect ,重導輸入
//若導向到的檔案已經存在,則會被覆蓋
# echo "this is old data" > myfile
# cat myfile
this is old data

//  >> 新增至尾端
# echo "this is new data" >> myfile
# cat myfile
this is old data
this is new data



# ls
anaconda-ks.cfg 
# ls kk1.txt
ls: 無法存取 'kk1.txt': 沒有此一檔案或目錄

// stdin:0   stdout:1   stderr:2
# ls kk1.txt 2> myError

# ls
anaconda-ks.cfg  myError

# cat myError
ls: 無法存取 'kk1.txt': 沒有此一檔案或目錄




# echo "電腦使用筆記,記錄相關重點" > myData
# cat myData
電腦使用筆記,記錄相關重點


// wc - print newline, word, and byte counts for each file
//行數   字數   byte數
# wc < myData
 1  1 40

# ls -l
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg
-rw-r--r--. 1 root root   40 12月 20 14:49 myData



# ls -l
-rw-------. 1 root root 1167 12月 16 09:39 anaconda-ks.cfg


//  -l, --lines       print the newline counts
// -w, --words   print the word counts
//  -c, --bytes    print the byte counts
# wc -lwc anaconda-ks.cfg
  47  103 1167 anaconda-ks.cfg








------------------------------------------------------迴路介面 loopback interface
//ifconfig 替換為 ip addr
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 2001:288:8241:1::276/128 scope global dynamic noprefixroute
       valid_lft 603954sec preferred_lft 603954sec
    inet6 2001:288:8241:1:20c:29ff:fea9:bcb0/64 scope global dynamic noprefixroute
       valid_lft 2591946sec preferred_lft 604746sec
    inet6 fe80::20c:29ff:fea9:bcb0/64 scope link noprefixroute
       valid_lft forever preferred_lft forever



# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

# ping localhost
PING localhost(localhost (::1)) 56 data bytes
64 bytes from localhost (::1): icmp_seq=1 ttl=64 time=0.048 ms
64 bytes from localhost (::1): icmp_seq=2 ttl=64 time=0.097 ms
64 bytes from localhost (::1): icmp_seq=3 ttl=64 time=0.091 ms
^C
--- localhost ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2071ms
rtt min/avg/max/mdev = 0.048/0.078/0.097/0.024 ms




------------------------------------------------------nmcli 設定IP 相關

//nmcli - command-line tool for controlling NetworkManager

# nmcli device status
DEVICE  TYPE      STATE     CONNECTION
ens33   ethernet  已連線    ens33
lo      loopback  不受管理  --


# nmcli device show ens33
GENERAL.DEVICE:                         ens33
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         00:0C:29:A9:BC:B0
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (已連線)
GENERAL.CONNECTION:                     ens33
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveCon>
WIRED-PROPERTIES.CARRIER:               開
IP4.ADDRESS[1]:                         172.31.147.99/24
IP4.GATEWAY:                            172.31.147.254
IP4.ROUTE[1]:                           dst = 172.31.147.0/24, nh = 0.0.0.0, mt =>
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 172.31.147.254, mt >
IP4.DNS[1]:                             163.28.136.21
IP4.SEARCHES[1]:                        168.95.1.1
IP6.ADDRESS[1]:                         2001:288:8241:1:20c:29ff:fea9:bcb0/64
IP6.ADDRESS[2]:                         2001:288:8241:1::276/128
IP6.ADDRESS[3]:                         fe80::20c:29ff:fea9:bcb0/64
IP6.GATEWAY:                            fe80::ea1c:baff:fec9:968
IP6.ROUTE[1]:                           dst = 2001:288:8241:1::/64, nh = ::, mt =>
IP6.ROUTE[2]:                           dst = ::/0, nh = fe80::ea1c:baff:fec9:968>
IP6.ROUTE[3]:                           dst = fe80::/64, nh = ::, mt = 100
lines 1-21...skipping...



# nmcli connection modify ens33 ipv4.address 192.168.2.103/24
# nmcli connection modify ens33 ipv4.gateway 192.168.2.1
# nmcli connection modify ens33 ipv4.dns 192.168.2.1


# nmcli device connect ens33
裝置「ens33」已成功以「9cb77588-c78e-40b0-acbe-3be164c3e385」啟用。
# nmcli device disconnect ens33


# nmcli connection up ens33
連線已成功啟用(D-Bus 啟用路徑:/org/freedesktop/NetworkManager/ActiveConnection/3)
# nmcli connection down ens33





//CLI 下的圖形設計工具
# nmtui edit ens33

# systemctl restart NetworkManager.service









------------------------------ ip 工具  由命令所做的設定,不會存至系統組態檔,所只適合測試用。

# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
...




//顯示特定設備的統計資料
// -s, -stats, -statistics
# ip -s link show ens33
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode                                     DEFAULT group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    RX: bytes  packets  errors  dropped missed  mcast
    13869549   13640    0       42      0       0
    TX: bytes  packets  errors  dropped carrier collsns
    409974     4014     0       0       0       0


# ip addr add 172.31.147.90/24 brd + dev ens33
# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group                                     default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet 172.31.147.90/24 brd 172.31.147.255 scope global secondary ens33
       valid_lft forever preferred_lft forever
...


# ping 172.31.147.99
PING 172.31.147.99 (172.31.147.99) 56(84) bytes of data.
64 bytes from 172.31.147.99: icmp_seq=1 ttl=64 time=0.051 ms
^C
--- 172.31.147.99 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2068ms
rtt min/avg/max/mdev = 0.051/0.098/0.152/0.042 ms

# ping 172.31.147.90
PING 172.31.147.90 (172.31.147.90) 56(84) bytes of data.
64 bytes from 172.31.147.90: icmp_seq=1 ttl=64 time=0.043 ms
^C
--- 172.31.147.90 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2031ms
rtt min/avg/max/mdev = 0.043/0.067/0.094/0.022 ms



若 Host is Wondows7 無法 ping :
 控制台\系統及安全性\Windows 防火牆 --> 進階設定 --> 輸入規則 --> 檔案及印表機共用 (回應要求 - ICMPv4-In) --> 私人,公用 --> 已啟用 --> 是




# ip addr del 172.31.147.90/24 dev ens33

# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group                                     default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
...



//啟用
# ip link set ens33 up

//停用
# ip link set ens33 down






------------------------------------------------------NetworkManager 工具

# systemctl status NetworkManager
● NetworkManager.service - Network Manager
   Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendo>
   Active: active (running) since Thu 2021-12-23 11:05:35 CST; 34min ago
     Docs: man:NetworkManager(8)
 Main PID: 1760 (NetworkManager)
    Tasks: 3 (limit: 36804)
   Memory: 3.1M
   CGroup: /system.slice/NetworkManager.service
           └─1760 /usr/sbin/NetworkManager --no-daemon

12月 23 11:05:35 centos85.kk NetworkManager[1760]: <info>  [1640228735.2369] devi>
12月 23 11:05:35 centos85.kk NetworkManager[1760]: <info>  [1640228735.2371] mana>
...




# ls /usr/lib/systemd/system
...
NetworkManager.service 
...





# ls /etc/sysconfig/network-scripts/
ifcfg-ens33

# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none                //是否自動取的IP;若是,dhcp 。若否,static 或 none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=faff608e-1af3-4d6d-a3f8-85123c116ffd
DEVICE=ens33
ONBOOT=yes                //開機是否啟用此網路卡
IPADDR=172.31.147.99
PREFIX=24
GATEWAY=172.31.147.254
DNS1=163.28.136.21
DOMAIN=168.95.1.1
IPV6_PRIVACY=no



# systemctl restart NetworkManager.service









------------------------------------------------------網路測試工具

//hostnamectl 取替 hostname
# hostnamectl
   Static hostname: centos85.kk
         Icon name: computer-vm
           Chassis: vm
        Machine ID: d9fabbd997c54e8f8c8520cd37b792e1
           Boot ID: 2b7aaf930d3c44f3be99ecf65cf7c62e
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-348.2.1.el8_5.x86_64
      Architecture: x86-64

# hostnamectl set-hostname centos8.kk

# hostnamectl
   Static hostname: centos8.kk
         Icon name: computer-vm
           Chassis: vm
        Machine ID: d9fabbd997c54e8f8c8520cd37b792e1
           Boot ID: 2b7aaf930d3c44f3be99ecf65cf7c62e
    Virtualization: vmware
  Operating System: CentOS Linux 8
       CPE OS Name: cpe:/o:centos:centos:8
            Kernel: Linux 4.18.0-348.2.1.el8_5.x86_64
      Architecture: x86-64





//測試主機回應 Hinet 的 DNS
# ping 168.95.1.1
PING 168.95.1.1 (168.95.1.1) 56(84) bytes of data.
64 bytes from 168.95.1.1: icmp_seq=1 ttl=244 time=3.49 ms
^C
--- 168.95.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2008ms
rtt min/avg/max/mdev = 3.488/3.695/3.818/0.155 ms




//ss is used to dump socket statistics. It allows showing information similar to netstat.  It can display more TCP  and  state  information  than other tools.

//ss 取替 netstat
//t:tcp協定   u:udp協定   n:不用名稱以port顯示   p:連線由哪個行程處理   l:在傾聽的連線

# ss -tunpl
Netid     State      Recv-Q     Send-Q                             Local Address:Port           Peer Address:Port     Process
udp       UNCONN     0          0                                      127.0.0.1:323                 0.0.0.0:*         users:(("chronyd",pid=918,fd=6))
udp       UNCONN     0          0                                          [::1]:323                    [::]:*         users:(("chronyd",pid=918,fd=7))
udp       UNCONN     0          0               [fe80::20c:29ff:fea9:bcb0]%ens33:546                    [::]:*         users:(("NetworkManager",pid=990,fd=25))
tcp       LISTEN     0          128                                      0.0.0.0:22                  0.0.0.0:*         users:(("sshd",pid=1007,fd=5))
tcp       LISTEN     0          32                                             *:21                        *:*         users:(("vsftpd",pid=1247,fd=4))
tcp       LISTEN     0          128                                         [::]:22                     [::]:*         users:(("sshd",pid=1007,fd=7))



//檢視tcp連線
# ss -t
State       Recv-Q       Send-Q              Local Address:Port                Peer Address:Port        Process
ESTAB       0            52                  172.31.147.99:ssh                172.31.147.29:59484




//  -u, --udp   Display UDP sockets.
# ss -u
Recv-Q         Send-Q                  Local Address:Port                   Peer A




//tracepath, tracepath6 - traces path to a network host discovering MTU along this path
//tracepath 取替  traceroute/traceroute6
# tracepath 168.95.1.1
 1?: [LOCALHOST]                      pmtu 1500
 1:  _gateway                                              0.905ms
 1:  _gateway                                              0.933ms
 2:  10.241.3.153                                          1.653ms
 3:  192.192.69.248                                        7.524ms
 4:  192.192.69.242                                        4.005ms
 5:  no reply
 6:  skc1-3311.hinet.net                                   9.962ms asymm  9
...




//route  - routing table entry.
//ip route 取替  route
# ip route show | column -t
default                  via     172.31.147.254    dev    ens33   proto  static  metric  100
172.31.147.0/24   dev     ens33                   proto  kernel  scope  link    src       172.31.147.99  metric  100


# ip -6 route show | column -t > kkRouteTable.text
# cat kkRouteTable.text
::1                   dev  lo                        proto  kernel  metric  256  pref    medium
2001:288:8241:1::276  dev  ens33                     proto  kernel  metric  100  pref    medium
2001:288:8241:1::/64  dev  ens33                     proto  ra      metric  100  pref    medium
fe80::/64             dev  ens33                     proto  kernel  metric  100  pref    medium
default               via  fe80::ea1c:baff:fec9:968  dev    ens33   proto   ra   metric  100     pref  medium







# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 2001:288:8241:1::276/128 scope global dynamic noprefixroute
       valid_lft 602717sec preferred_lft 602717sec
    inet6 2001:288:8241:1:20c:29ff:fea9:bcb0/64 scope global dynamic noprefixroute
       valid_lft 2591950sec preferred_lft 604750sec
    inet6 fe80::20c:29ff:fea9:bcb0/64 scope link noprefixroute
       valid_lft forever preferred_lft forever



# ip addr add 10.150.15.88/24 brd + dev ens33

# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet 10.150.15.88/24 brd 10.150.15.255 scope global ens33
       valid_lft forever preferred_lft forever
   ...


# ip route show
default via 172.31.147.254 dev ens33 proto static metric 100
10.150.15.0/24 dev ens33 proto kernel scope link src 10.150.15.88         // 靜態路由 
172.31.147.0/24 dev ens33 proto kernel scope link src 172.31.147.99 metric 100

# ping 10.150.15.88
PING 10.150.15.88 (10.150.15.88) 56(84) bytes of data.
64 bytes from 10.150.15.88: icmp_seq=2 ttl=64 time=0.145 ms
^C




//直接刪除ip addr
# ip addr del 10.150.15.88/24 dev ens33
# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever




或者

# ip addr add 10.150.15.77/24 brd + dev ens33

# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet 10.150.15.77/24 brd 10.150.15.255 scope global ens33
       valid_lft forever preferred_lft forever
    ...



# ip route show
default via 172.31.147.254 dev ens33 proto static metric 100
10.150.15.0/24 dev ens33 proto kernel scope link src 10.150.15.77
172.31.147.0/24 dev ens33 proto kernel scope link src 172.31.147.99 metric 100

# ping 10.150.15.77
PING 10.150.15.77 (10.150.15.77) 56(84) bytes of data.
64 bytes from 10.150.15.77: icmp_seq=1 ttl=64 time=0.042 ms
^C


//只刪除路由
# ip route del 10.150.15.0/24


//ip addr 還在
# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet 10.150.15.77/24 brd 10.150.15.255 scope global ens33
       valid_lft forever preferred_lft forever
   ...



# ip route show
default via 172.31.147.254 dev ens33 proto static metric 100
172.31.147.0/24 dev ens33 proto kernel scope link src 172.31.147.99 metric 100


//沒有靜態路由,還可ping
# ping 10.150.15.77
PING 10.150.15.77 (10.150.15.77) 56(84) bytes of data.
64 bytes from 10.150.15.77: icmp_seq=1 ttl=64 time=0.041 ms
^C


# ip addr del 10.150.15.77/24 dev ens33

# ip addr show
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:a9:bc:b0 brd ff:ff:ff:ff:ff:ff
    inet 172.31.147.99/24 brd 172.31.147.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever

















------------------------------------------------------ARP 、RARP
//ARP 
//Address Resolution Protocol 位址解析協定,由已知的 IP 位址查問其相對應的網路實體位址MAC
 //RARP 
//Reverse Address Resolution Protocol 反向位址解析協定,由已知的網路實體位址(MAC 位址)查詢其相對應的 IP 位址

//ip neighbor 取替  arp

# ip neighbor show
172.31.147.29 dev ens33 lladdr 00:e0:4c:27:08:5b REACHABLE
172.31.147.254 dev ens33 lladdr e8:1c:ba:c9:09:68 STALE
fe80::ea1c:baff:fec9:968 dev ens33 lladdr e8:1c:ba:c9:09:68 router STALE



////
被淘汰的工具只是不在預設安裝所包含的,所以是可以利用 yum 把他安裝回來
Note:在 yum 中不知道套件的名稱,可以用 provides 和 list 直接搜尋 package 裡面的工具
////



//DNF  is the next upcoming major version of YUM
# dnf provides */ifconfig
上次中介資料過期檢查:0:00:34 前,時間點為西元2021年12月24日 (週五) 12時02分18秒。
net-tools-2.0-0.52.20160912git.el8.x86_64 : Basic networking tools
軟體庫  :baseos
符合來源:
檔案名稱:/usr/sbin/ifconfig

# dnf list */ifconfig
上次中介資料過期檢查:0:00:48 前,時間點為西元2021年12月24日 (週五) 12時02分18秒。
可用的軟體包
net-tools.x86_64                             2.0-0.52.20160912git.el8  



# ifconfig
-bash: ifconfig:命令找不到

# dnf -y install net-tools

# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.31.147.99  netmask 255.255.255.0  broadcast 172.31.147.255
        inet6 2001:288:8241:1::276  prefixlen 128  scopeid 0x0<global>
        inet6 2001:288:8241:1:20c:29ff:fea9:bcb0  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::20c:29ff:fea9:bcb0  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:a9:bc:b0  txqueuelen 1000  (Ethernet)
        RX packets 29601  bytes 3163995 (3.0 MiB)
        RX errors 0  dropped 329  overruns 0  frame 0
        TX packets 4474  bytes 590794 (576.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 38  bytes 3192 (3.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 38  bytes 3192 (3.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0



# dnf provides */netstat
上次中介資料過期檢查:0:28:28 前,時間點為西元2021年12月24日 (週五) 12時02分18秒。
net-tools-2.0-0.52.20160912git.el8.x86_64 : Basic networking tools
軟體庫  :@System
符合來源:
檔案名稱:/usr/bin/netstat

net-tools-2.0-0.52.20160912git.el8.x86_64 : Basic networking tools
軟體庫  :baseos
符合來源:
檔案名稱:/usr/bin/netstat


# netstat -r | column -t
Kernel        IP        routing        table
Destination   Gateway   Genmask        Flags  MSS  Window  irtt  Iface
default       _gateway  0.0.0.0        UG     0    0       0     ens33
172.31.147.0  0.0.0.0   255.255.255.0  U      0    0       0     ens33


# dnf provides */dig
上次中介資料過期檢查:0:30:23 前,時間點為西元2021年12月24日 (週五) 12時02分18秒。
bind-utils-32:9.11.26-6.el8.x86_64 : Utilities for querying DNS name servers
軟體庫  :appstream
符合來源:
檔案名稱:/usr/bin/dig

kernel-debug-devel-4.18.0-348.el8.x86_64 : Development package for building kernel modules to match the
                                         : debug kernel
軟體庫  :baseos
符合來源:
檔案名稱:/usr/src/kernels/4.18.0-348.el8.x86_64+debug/arch/ia64/dig

kernel-debug-devel-4.18.0-348.2.1.el8_5.x86_64 : Development package for building kernel modules to
                                               : match the debug kernel
軟體庫  :baseos
符合來源:
檔案名稱:/usr/src/kernels/4.18.0-348.2.1.el8_5.x86_64+debug/arch/ia64/dig

kernel-devel-4.18.0-348.el8.x86_64 : Development package for building kernel modules to match the kernel
軟體庫  :baseos
符合來源:
檔案名稱:/usr/src/kernels/4.18.0-348.el8.x86_64/arch/ia64/dig

kernel-devel-4.18.0-348.2.1.el8_5.x86_64 : Development package for building kernel modules to match the
                                         : kernel
軟體庫  :baseos
符合來源:
檔案名稱:/usr/src/kernels/4.18.0-348.2.1.el8_5.x86_64/arch/ia64/dig




# dnf -y install bind-utils

# dig 168.95.1.1

; <<>> DiG 9.11.26-RedHat-9.11.26-6.el8 <<>> 168.95.1.1
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 63268
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: a9f575096485cf010f37025261c54ddc525b72fcbab80909 (good)
;; QUESTION SECTION:
;168.95.1.1.                    IN      A

;; AUTHORITY SECTION:
.                       10800   IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2021122301 1800 900 604800 86400

;; Query time: 11 msec
;; SERVER: 163.28.136.21#53(163.28.136.21)
;; WHEN: 五 12月 24 12:34:36 CST 2021
;; MSG SIZE  rcvd: 142





# dnf provides */traceroute
上次中介資料過期檢查:0:33:14 前,時間點為西元2021年12月24日 (週五) 12時02分18秒。
traceroute-3:2.1.0-6.el8.x86_64 : Traces the route taken by packets over an IPv4/IPv6 network
軟體庫  :baseos
符合來源:
檔案名稱:/bin/traceroute
檔案名稱:/usr/share/doc/traceroute



# dnf -y install traceroute


# traceroute www.google.com.tw
traceroute to www.google.com.tw (142.251.42.227), 30 hops max, 60 byte packets
 1  _gateway (172.31.147.254)  1.011 ms  0.932 ms  0.885 ms
 2  10.241.3.153 (10.241.3.153)  4.345 ms  4.283 ms  0.938 ms
...





------------------------------------------------------Firewalld

//查詢啟用狀態
# firewall-cmd --state
running

# firewall-cmd --get-zones
block dmz drop external home internal nm-shared public trusted work

# ls /usr/lib/firewalld/zones
block.xml  drop.xml      home.xml      nm-shared.xml  trusted.xml
dmz.xml    external.xml  internal.xml  public.xml     work.xml


# firewall-cmd --get-active-zone
public
  interfaces: ens33





//了解目前zone的詳細設定
# firewall-cmd --zone=public --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: cockpit dhcpv6-client ftp ssh
  ports:
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:




// 名稱 vsfpt 、vsftpd 都不是
# firewall-cmd --get-services | grep ftp
RH-Satellite-6 RH-Satellite-6-capsule amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bb bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc bittorrent-lsd ceph ceph-mon cfengine cockpit collectd condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns dns-over-tls docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server finger foreman foreman-proxy freeipa-4 freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp galera ganglia-client ganglia-master git grafana gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kdeconnect kerberos kibana klogin kpasswd kprop kshell kube-apiserver ldap ldaps libvirt libvirt-tls lightning-network llmnr managesieve matrix mdns memcache minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nbd nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy prometheus proxy-dhcp ptp pulseaudio puppetmaster quassel radius rdp redis redis-sentinel rpc-bind rquotad rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync spotify-sync squid ssdp ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tentacle tftp tftp-client tile38 tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server


# ls /usr/lib/firewalld/services | grep ftp
ftp.xml
tftp-client.xml
tftp.xml




//將服務加入規則

# firewall-cmd --zone=public --add-service=ftp
success

# firewall-cmd --zone=public --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: cockpit dhcpv6-client ftp ssh
  ports:
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:




//將埠口加入規則

# firewall-cmd --zone=public --add-port=8080/tcp
success

# firewall-cmd --zone=public --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: cockpit dhcpv6-client ftp ssh
  ports: 8080/tcp
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:







//將服務與埠口移除

# firewall-cmd --zone=public --remove-port=8080/tcp
success

# firewall-cmd --zone=public --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: cockpit dhcpv6-client ftp ssh
  ports:
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:







# firewall-cmd --zone=public --remove-service=ftp
success

# firewall-cmd --zone=public --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources:
  services: cockpit dhcpv6-client ssh
  ports:
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:







// firewalld.service 開機是否啟動

# systemctl is-enabled firewalld.service
enabled

# systemctl disable firewalld.service
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

# systemctl is-enabled firewalld.service
disabled

# systemctl enable firewalld.service
Created symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service → /usr/lib/systemd/system/firewalld.service.
Created symlink /etc/systemd/system/multi-user.target.wants/firewalld.service → /usr/lib/systemd/system/firewalld.service.

# systemctl is-enabled firewalld.service
enabled







# ls /usr/lib/systemd/system | grep firewall
firewalld.service







//停止FirewallD服務

# systemctl start firewalld.service
# systemctl is-active firewalld.service
active

# systemctl stop firewalld.service
# systemctl is-active firewalld.service
inactive

# systemctl start firewalld.service




# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-12-27 14:15:19 CST; 3min 26s ago
     Docs: man:firewalld(1)
 Main PID: 1892 (firewalld)
    Tasks: 2 (limit: 36804)
   Memory: 23.8M
   CGroup: /system.slice/firewalld.service
           └─1892 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid
...




------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







------------------------------------------------------







 

2021年12月1日 星期三

HTML5+CSS(二)

 參考資料:佳魁陸淩牛王者歸來HTML5與CSS3權威指南


CSS3屬性選擇器
----------------------------------------------------------

HTML
~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=
    , initial-scale=1.0">
    <title>Document</title>
    <style>
        /* ^開頭字元有 */
        [id^=session] {
            background-color: #ccc;
        }
        /*    * 有包含 */
        [id*=session1] {
            background-color: #fae;
        }
        /* $ 結尾字元 */
        [id$=\-1] {
            background-color: #f00;
        }
    </style>
</head>

<body>
    <div id="session">
        <div id="session0">AAA</div>
        <div id="session1">BBB</div>
        <div id="session1-1">BBB1</div>
        <div id="session1-2">BBB2</div>
        <div id="session2">CCC</div>
        <div id="session2-1">CCC1</div>
        <div id="session2-3">CCC2</div>
    </div>
</body>

</html>




----------------------------------------------------------


~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        a[href$=\/]:after,
        a[href$=htm]:after,
        a[href$=html]:after {
            content: "WEB網頁";
            color: #f00;
        }

        a[href$=jpg]:after {
            content: "JPEG影像檔";
            color: #0f0;
        }
    </style>
</head>

<body>
    <ul>
        <li>
            <a href="https://#/">權威指南</a>
        </li>
        <li>
            <a href="https://#/01.html">新的特性</a>
        </li>
        <li>
            <a href="#pic.jpg">影像素材</a>
        </li>



    </ul>
</body>

</html>








類別選取器
<p class="left">Lorem ipsum dolor sit amet consectetur adipisicing elit. Distinctio, tenetur!</p>
可以隨便命名。
虛擬類別選取器是CSS中已經定義好的選取器,不能隨便命名。CSS最常使用的虛擬類別選取器是使用在a元素上的選擇器:
a:link{}
a:visited{}
a:hover{}
a:active{}


虛擬元素選取器
針對CSS中已定義好的虛擬元素使用選擇器。
選擇器: 虛擬元素{屬性:值}
也可搭類別使用
選擇器 類別: 虛擬元素{屬性:值}

CSS中主要有四個虛擬元素選擇器:
first-line   用於某元素中的第一行文字使用樣式
first-letter 用於某元素中文字的字首使用樣式
before       用於某元素之前插入一些內容
after          用於某元素之後插入一些內容

----------------------------------------------------------

~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        p:first-line {
            background-color: rgb(169, 228, 33);
            ;
        }

        p:first-letter {
            color: #f00;
        }

        li:before {
            content: "**";
        }

        li:after {
            content: "(僅用於測試...)";
            font-size: 12px;
            color: #f00;
        }
    </style>
</head>

<body>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. <br>Voluptatem dolorum soluta quia in! Modi molestiae
        earum dolorem. Nulla temporibus dolor nostrum eum fugit illo nemo natus perspiciatis possimus, provident
        dignissimos?</p>

    <!-- ul>li{列表項目$}*4 -->
    <ul>
        <li>列表項目1</li>
        <li>列表項目2</li>
        <li>列表項目3</li>
        <li>列表項目4</li>
    </ul>
</body>

</html>








結構性虛擬類別選擇器
root、not、empty、target

root 頁面根項目。即整個頁面<html>
not 排除某結構下面的子結構元素
empty元素內容空白時使用的樣式
target
----------------------------------------------------------


~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=
    , initial-scale=1.0">
    <title>Document</title>
    <style>
        :root {
            background-color: #cc0;
        }

        body *:not(h1) {
            background-color: #fcc;
        }

        :empty {
            background-color: #ccc;
        }
    </style>
</head>

<body>
    <h1>root選擇器</h1>
    <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptate nam perspiciatis quas dicta iste earum unde
        tempora. Quos consequuntur et maiores. Consequatur, est sit! Rerum eum perspiciatis tenetur. Magni, ipsa.</p>

    <!-- table>(tr>td*3)*2 -->
    <table>
        <tr>
            <td>AA</td>
            <td>BB</td>
            <td>CC</td>
        </tr>
        <tr>
            <td>DD</td>
            <td>EE</td>
            <td></td>
        </tr>
    </table>
</body>

</html>







target
點擊頁面中超連結,且跳躍到target元素後起作用
----------------------------------------------------------

HTML
~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=
    , initial-scale=1.0">
    <title>Document</title>
    <style>
        :target {
            background-color: #adff2f;
        }
    </style>
</head>

<body>

    <!-- p[id="menu"]>(a[href="text$"]{"範例文字$"})*5 -->
    <p id="menu">
        <a href="#text1">範例文字1</a> |
        <a href="#text2">範例文字2</a> |
        <a href="#text3">範例文字3</a> |
        <a href="#text4">範例文字4</a> |
        <a href="#text5">範例文字5</a>
    </p>


    <!-- (div[id="text$"]>h2{範例文字$}>p>lorem)*5 -->
    <div id="text1">
        <h2>範例文字1
            <p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Animi dolor perferendis voluptate error facere
                iusto eveniet tempore, perspiciatis, cupiditate totam nostrum porro. Laboriosam sint, harum enim facilis
                deleniti omnis minus!</p>
        </h2>
    </div>
    <div id="text2">
        <h2>範例文字2
            <p>Voluptates quis libero dicta tempora! Velit ab laboriosam eum pariatur non, cupiditate quis iusto
                nesciunt et recusandae. Iusto, sunt. Accusantium architecto aut error et dolor. In cumque temporibus
                praesentium ratione.</p>
        </h2>
    </div>
    <div id="text3">
        <h2>範例文字3
            <p>Quibusdam veritatis eum deleniti doloribus! Quas sed quasi id provident perspiciatis, consequatur
                aspernatur! Ea, aliquam? Consequatur, aliquam. Sapiente ea quaerat rem ullam illum voluptatum.
                Dignissimos distinctio explicabo adipisci natus cupiditate?</p>
        </h2>
    </div>
    <div id="text4">
        <h2>範例文字4
            <p>Odio culpa inventore nostrum, sunt aspernatur architecto quaerat necessitatibus nemo sint cumque velit
                doloribus vitae est similique esse ex! Ipsa iste hic sint incidunt dicta sed dolorum aspernatur
                consequuntur laborum.</p>
        </h2>
    </div>
    <div id="text5">
        <h2>範例文字5
            <p>Sed fuga voluptates inventore! Necessitatibus unde labore maiores? Nesciunt quisquam, distinctio magnam
                ex accusantium neque. Commodi fuga sit iure labore hic, perspiciatis ex minima dolorem, deleniti aliquid
                quia rem dignissimos.</p>
        </h2>
    </div>
</body>

</html>






文字陰影
text-shadow: length1 length2 length3 color 
length1 陰影離開文字橫向距離
length2 陰影離開文字縱向距離
length3 陰影的模糊半徑
color     陰影的顏色
----------------------------------------------------------

HTML
~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            font-size: 50px;
            font-weight: bold;
            color: #fff;
            text-shadow: 2px 2px 5px #ff0000;
        }
    </style>
</head>

<body>
    <div>
        較大為您回憶
    </div>
</body>

</html>





方塊陰影+圓角邊框
box-shadow: length1 length2 length3 color 
length1 陰影離開方塊橫向距離
length2 陰影離開方塊縱向距離
length3 陰影的模糊半徑
color     陰影的顏色

border-radius: length
length 圓角半徑
----------------------------------------------------------


HTML
~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            font-size: 50px;
            font-weight: bold;
            text-align: center;
            border: 1px solid #dcdcdc;
            border-radius: 10px;
            box-shadow: 2px 2px 5px #808080;
        }
    </style>
</head>

<body>
    <div>
        方塊陰影
    </div>
</body>

</html>








box-sizing
----------------------------------------------------------

HTML
~~~~~~~~~
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 300px;
            padding: 30px;
            border: solid 5px #fa0;
            background-color: #ff0;
            margin: 10px;
        }

        #d0 {
            /*             預設
            box-sizing: content-box; */
        }

        #d1 {
            box-sizing: content-box;
            /*          元素總寬度=內容+padding*2+border*2+margin*2
            元素總寬度=300+30*2+5*2+10*2 */

        }

        #d2 {
            /*          內容=元素可見總寬度-padding*2-border*2
            元素總寬度=300-30*2-5*2 */
            box-sizing: border-box;
        }
    </style>
</head>

<body>
    <div id="d0">
        習慣當時雲林義務起來一把德國逐步到底,適當進行同學沒有什麼這個為此常見歌曲,範圍內一份是怎麼閲讀說著處理住房教師總部外貿名單打算,一流充滿一項一台治理,刷新正是谷歌面前仍然你不圍繞,演唱醫生某種這個問題,註冊看看,最佳臉上沒有任何,身上反。
    </div>
    <div id="d1">
        習慣當時雲林義務起來一把德國逐步到底,適當進行同學沒有什麼這個為此常見歌曲,範圍內一份是怎麼閲讀說著處理住房教師總部外貿名單打算,一流充滿一項一台治理,刷新正是谷歌面前仍然你不圍繞,演唱醫生某種這個問題,註冊看看,最佳臉上沒有任何,身上反。
    </div>
    <div id="d2">
        習慣當時雲林義務起來一把德國逐步到底,適當進行同學沒有什麼這個為此常見歌曲,範圍內一份是怎麼閲讀說著處理住房教師總部外貿名單打算,一流充滿一項一台治理,刷新正是谷歌面前仍然你不圍繞,演唱醫生某種這個問題,註冊看看,最佳臉上沒有任何,身上反。
    </div>
</body>

</html>





----------------------------------------------------------



HTML
~~~~~~~~~






----------------------------------------------------------



HTML
~~~~~~~~~






----------------------------------------------------------



HTML
~~~~~~~~~






----------------------------------------------------------



HTML
~~~~~~~~~