Linux 基礎學習訓練教材 - CentOS 8.x

課程問題參考解答

單純提供一個相對的解答,並不是標準答案!

最近更新時間: 2020/06/11

單純就是個解答的參考,寫完之後再來這邊查查看答案跟你想的一樣不一樣!?

第 13 堂課

  • 例題 13.1.1-1:
    # A. 使用 ps 這個指令,列出系統全部程序的『 pid, nice值, pri值, command 』資訊
    [root@station200 ~]# ps -eo pid,ni,pri,comm
      PID  NI PRI COMMAND
        1   0  19 systemd
        2   0  19 kthreadd
        3 -20  39 rcu_gp
    .......
    
    # B. 找出系統內程序執行檔名為 sshd 的 PID
    [root@station200 ~]# ps -eo pid,ni,pri,comm | grep sshd
     1214   0  19 sshd
    [root@station200 ~]# pstree -p | grep sshd
               |-sshd(1214)
    # 上面兩個方法都可以!
    
    # C. 將上述的 PID 給予 signal 1 的方式為何?
    [root@station200 ~]# kill -1 1214
    [root@station200 ~]# killall -1 sshd
    # 上面兩個方法都可以!
    
    # D. 觀察一下 /var/log/secure 的內容是否正確的輸出相關的程序行為?
    [root@station200 ~]# journalctl -u sshd -n 10
     5月 26 17:25:13 station200.centos sshd[1214]: Received SIGHUP; restarting.
     5月 26 17:25:13 station200.centos sshd[1214]: Server listening on 0.0.0.0 port 22.
     5月 26 17:25:13 station200.centos sshd[1214]: Server listening on :: port 22.
    
    # E. 如何將系統上所有的 bash 程序通通刪除?
    [root@station200 ~]# killall bash
    [root@station200 ~]# killall -9 bash
    # 第一個方法,只會殺掉別人的 bash,自己保留,第二個方法,連同自己的通通刪除!
    
  • 例題 13.1.2-1:
    # A. 透過 ps 找出 systemd 這個執行檔的完整路徑
    [root@station200 ~]# ps -eo pid,ni,pri,args | grep 'systemd '
        1   0  19 /usr/lib/systemd/systemd --switched-root --system --deserialize 17
     2167   0  19 /usr/lib/systemd/systemd --user
     2621   0  19 /usr/lib/systemd/systemd --user
    32630   0  19 /usr/lib/systemd/systemd --user
    32754   0  19 grep --color=auto systemd
    
    # B. 上述的指令是由那一個軟體所提供?
    [root@station200 ~]# rpm -qf /usr/lib/systemd/systemd
    systemd-239-18.el8_1.5.x86_64
    
    # C. 該軟體提供的全部檔名如何查詢?
    [root@station200 ~]# rpm -ql systemd
    
  • 例題 13.1.3-1:
    # A. 查詢系統有沒有 cupsd 這個指令?
    [root@station200 ~]# type -a cupsd
    cupsd 是 /usr/sbin/cupsd
    # 是有的,位置就在 /usr/sbin/cupsd 這裡
    
    # B. 使用 rpm 查詢該指令屬於哪個軟體?
    [root@station200 ~]# rpm -qf /usr/sbin/cupsd
    cups-2.2.6-28.el8.x86_64
    
    # C. 使用 rpm 查詢該軟體的功能為何?
    [root@station200 ~]# rpm -qi cups
    Name        : cups
    Epoch       : 1
    Version     : 2.2.6
    Release     : 28.el8
    Architecture: x86_64
    ......
    URL         : http://www.cups.org/
    Summary     : CUPS printing system
    Description :
    CUPS printing system provides a portable printing layer for
    UNIX® operating systems. It has been developed by Apple Inc.
    to promote a standard printing solution for all UNIX vendors and users.
    CUPS provides the System V and Berkeley command-line interfaces.
    # 看起來似乎是一個可攜式列印層級的列印系統喔!專給 UNix 系統使用的
    
    # D. 請觀察 cups 這個服務目前是啟動或關閉?開機時會不會啟動這個服務?
    [root@station200 ~]# systemctl status cups
    ● cups.service - CUPS Scheduler
       Loaded: loaded (/usr/lib/systemd/system/cups.service; enabled; vendor preset: enabled)
       Active: active (running) since Tue 2020-05-26 15:29:58 CST; 6h ago
         Docs: man:cupsd(8)
     Main PID: 1215 (cupsd)
       Status: "Scheduler is running..."
        Tasks: 1 (limit: 11486)
       Memory: 2.0M
       CGroup: /system.slice/cups.service
               └─1215 /usr/sbin/cupsd -l
    
    # E. 請將 cups 關閉,且下次開機還是會關閉
    [root@station200 ~]# systemctl stop cups.[tab][tab]
    cups.path     cups.service  cups.socket
    [root@station200 ~]# systemctl stop cups.path cups.socket cups.service
    [root@station200 ~]# systemctl disable cups.path cups.socket cups.service
    Removed /etc/systemd/system/multi-user.target.wants/cups.path.
    Removed /etc/systemd/system/sockets.target.wants/cups.socket.
    Removed /etc/systemd/system/printer.target.wants/cups.service.
    # 其實 cups 共用到 3 種類型的服務資料,都要關閉才能完整關閉!
    
    # F. 再次觀察 cups 這個服務。
    [root@station200 ~]# systemctl status cups
    ● cups.service - CUPS Scheduler
       Loaded: loaded (/usr/lib/systemd/system/cups.service; disabled; vendor preset: enabled)
       Active: inactive (dead)
         Docs: man:cupsd(8)
    
    # G. 觀察登錄檔有沒有記錄 cups 這個服務的相關資料?
    [root@station200 ~]# journalctl -u cups
    .....
     5月 26 21:52:09 station200.centos systemd[1]: Stopping CUPS Scheduler...
     5月 26 21:52:09 station200.centos systemd[1]: Stopped CUPS Scheduler.
    
  • 例題 13.1.4-1:
    # A. 找出系統中以 ksm 為開頭的所有的服務名稱,並觀察其狀態
    [root@station200 ~]# systemctl list-units | grep '^ksm'
    ksm.service         loaded active exited    Kernel Samepage Merging
    ksmtuned.service    loaded active running   Kernel Samepage Merging (KSM) Tuning Daemon
    
    [root@station200 ~]# systemctl status ksm ksmtuned
    ● ksm.service - Kernel Samepage Merging
       Loaded: loaded (/usr/lib/systemd/system/ksm.service; enabled; vendor preset: enabled)
       Active: active (exited) since Tue 2020-05-26 15:29:56 CST; 7h ago
     Main PID: 1051 (code=exited, status=0/SUCCESS)
        Tasks: 0 (limit: 11486)
       Memory: 0B
       CGroup: /system.slice/ksm.service
    
    ● ksmtuned.service - Kernel Samepage Merging (KSM) Tuning Daemon
       Loaded: loaded (/usr/lib/systemd/system/ksmtuned.service; enabled; vendor preset: enab>
       Active: active (running) since Tue 2020-05-26 15:29:56 CST; 7h ago
     Main PID: 1076 (ksmtuned)
        Tasks: 2 (limit: 11486)
       Memory: 11.3M
       CGroup: /system.slice/ksmtuned.service
               ├─1076 /bin/bash /usr/sbin/ksmtuned
               └─1541 sleep 60
    # 兩個都是 enabled 且 active 喔!
    
    # B. 將該服務設定為『開機不啟動』且『目前立刻關閉』的情況
    [root@station200 ~]# systemctl disable ksm ksmtuned
    Removed /etc/systemd/system/multi-user.target.wants/ksm.service.
    Removed /etc/systemd/system/multi-user.target.wants/ksmtuned.service.
    [root@station200 ~]# systemctl stop ksm ksmtuned
    
  • 例題 13.1.5-1:
    # A. 使用 netstat -tlunp 查看一下系統的網路監聽埠口
    [root@station200 ~]# systemctl get-default
    multi-user.target
    [root@station200 ~]# systemctl isolate multi-user.target
    [root@station200 ~]# netstat -tlunp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address      Foreign Address   State   PID/Program name
    tcp        0      0 0.0.0.0:111        0.0.0.0:*         LISTEN  1/systemd
    tcp        0      0 192.168.122.1:53   0.0.0.0:*         LISTEN  2136/dnsmasq
    tcp        0      0 0.0.0.0:22         0.0.0.0:*         LISTEN  1214/sshd
    tcp        0      0 127.0.0.1:25       0.0.0.0:*         LISTEN  1582/master
    tcp6       0      0 :::111             :::*              LISTEN  1/systemd
    tcp6       0      0 :::22              :::*              LISTEN  1214/sshd
    tcp6       0      0 ::1:25             :::*              LISTEN  1582/master
    udp        0      0 0.0.0.0:44961      0.0.0.0:*                 1769/rsyslogd
    udp        0      0 192.168.122.1:53   0.0.0.0:*                 2136/dnsmasq
    udp        0      0 0.0.0.0:67         0.0.0.0:*                 2136/dnsmasq
    udp        0      0 0.0.0.0:111        0.0.0.0:*                 1/systemd
    udp        0      0 0.0.0.0:5353       0.0.0.0:*                 1070/avahi-daemon:
    udp        0      0 127.0.0.1:323      0.0.0.0:*                 1073/chronyd
    udp        0      0 0.0.0.0:514        0.0.0.0:*                 1769/rsyslogd
    udp        0      0 0.0.0.0:60999      0.0.0.0:*                 1070/avahi-daemon:
    udp6       0      0 :::50088           :::*                      1070/avahi-daemon:
    udp6       0      0 :::111             :::*                      1/systemd
    udp6       0      0 :::5353            :::*                      1070/avahi-daemon:
    udp6       0      0 ::1:323            :::*                      1073/chronyd
    udp6       0      0 :::514             :::*                      1769/rsyslogd
    # 確認在一般純文字界面就會有很多常駐程式在系統中!
    
    # B. 請在本機目前的狀態下,將操作界面模式更改為 rescue.target 這個救援模式
    [root@station200 ~]# systemctl isolate rescue.target
    
    # C. 使用 netstat -tlunp 查看一下系統的網路監聽埠口是否有變少?
    [root@station200 ~]# netstat -tlunp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      2136/dnsmasq
    udp        0      0 192.168.122.1:53        0.0.0.0:*                           2136/dnsmasq
    udp        0      0 0.0.0.0:67              0.0.0.0:*                           2136/dnsmasq
    # 救援模式本來就是在救援,所以不會有太多的網路服務被啟動!
    
    # D. 將環境改為原本的操作界面 (預設為圖形、變更為 GUI)
    [root@station200 ~]# systemctl isolate graphical.target
    [root@station200 ~]# systemctl set-default graphical.target
    Removed /etc/systemd/system/default.target.
    Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target.
    
  • 例題 13.1.6-1:
    # A. 安裝:WWW 網路服務是由 httpd 這個軟體所提供的,請先安裝該軟體
    [root@station200 ~]# yum install httpd
    
    # B. 啟動:啟動該服務,並且查詢該服務啟動的埠口為何
    [root@station200 ~]# systemctl start httpd
    [root@station200 ~]# netstat -tlunp | grep httpd
    tcp6       0      0 :::80                   :::*                    LISTEN      5829/httpd     
    # 所以,啟動的埠口當然就是預設的 80 port 了!
    
    # C. 開機啟動:設定為預設啟動該服務,並查詢該服務的狀態是否正確
    [root@station200 ~]# systemctl enable httpd
    Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service 
        → /usr/lib/systemd/system/httpd.service.
    
    [root@station200 ~]# systemctl status httpd
    ● httpd.service - The Apache HTTP Server
       Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
       Active: active (running) since Wed 2020-05-27 09:10:54 CST; 36s ago
         Docs: man:httpd.service(8)
     Main PID: 5829 (httpd)
       Status: "Running, listening on: port 80"
        Tasks: 213 (limit: 11486)
       Memory: 46.6M
       CGroup: /system.slice/httpd.service
               ├─5829 /usr/sbin/httpd -DFOREGROUND
               ├─5830 /usr/sbin/httpd -DFOREGROUND
               ├─5831 /usr/sbin/httpd -DFOREGROUND
               ├─5832 /usr/sbin/httpd -DFOREGROUND
               └─5833 /usr/sbin/httpd -DFOREGROUND
    
    # D. 防火牆:將 http 服務的防火牆埠口放行
    [root@station200 ~]# firewall-cmd --list-all
    public (active)
      target: default
      icmp-block-inversion: no
      interfaces: ens3
      sources:
      services: ftp http https ssh syslog
      ports:
      protocols:
      masquerade: no
      forward-ports:
      source-ports:
      icmp-blocks:
      rich rules:
            rule family="ipv4" source address="172.16.100.254" accept
            rule family="ipv4" source address="172.16.0.0/16" service name="ssh" accept
    # 前幾個小節就已經放行過,所以這裡查閱一下 double check 即可!
    
    # E. 測試:使用瀏覽器查詢本機 WWW 服務是否正確啟動了。
    #     請直接到虛擬機器啟動瀏覽器輸入『 http://localhost 』或
    #    『 http://172.16.60.XX 』去看自己與他人的環境!
    
  • 例題 13.2.1-1:
    1. 找尋與 local 比較有相關的 unit 或 unit file
      [root@station200 ~]# systemctl list-units --all  | grep local
      ● cloud-init-local.service  not-found inactive dead      cloud-init-local.service 
         rc-local.service          loaded    inactive dead      /etc/rc.d/rc.local Compatibility
         local-fs-pre.target       loaded    active   active    Local File Systems (Pre)
         local-fs.target           loaded    active   active    Local File Systems
      
      [root@station200 ~]# systemctl list-unit-files | grep local
      dbus-org.freedesktop.locale1.service       static
      halt-local.service                         static
      rc-local.service                           static
      systemd-localed.service                    static
      local-fs-pre.target                        static
      local-fs.target                            static
      # 看起來應該是有需要的時候,這個服務才會被啟動!因此,目前是 inactive 的!
      
      [root@station200 ~]# systemctl show rc-local.service
      Type=forking
      Restart=no
      .....
      ExecStart={ path=/etc/rc.d/rc.local ; argv[]=/etc/rc.d/rc.local start ; >
      .....
      
      最終看起來,應該是與 /etc/rc.d/rc.local 有關喔!
    2. 開始測試一下,看看 rc.local 能夠順利運作的解決方案:
      [root@station200 ~]# cat /etc/rc.d/rc.local
      #!/bin/bash
      # THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
      .....
      #
      # Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
      # that this script will be executed during boot.
      .....
      # 看起來得要處理成為可執行檔才行喔!
      
      [root@station200 ~]# chmod a+x /etc/rc.d/rc.local
      [root@station200 ~]# ll /etc/rc.d/rc.local
      -rwxr-xr-x. 1 root root 474  4月 10 05:52 /etc/rc.d/rc.local
      
      [root@station200 ~]# systemctl daemon-reload
      
      [root@station200 ~]# systemctl status rc-local
      ● rc-local.service - /etc/rc.d/rc.local Compatibility
         Loaded: loaded (/usr/lib/systemd/system/rc-local.service; enabled-runtime;>
         Active: inactive (dead)
           Docs: man:systemd-rc-local-generator(8)
      
  • 例題 13.2.2-1:
    # A. 在核心模組的目錄下,使用 find 找出系統有沒有 fat 關鍵字的模組?
    [root@station200 ~]# uname -r
    4.18.0-147.8.1.el8_1.x86_64
    [root@station200 ~]# find /lib/modules/4.18.0-147.8.1.el8_1.x86_64/ | grep fat
    /lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/fs/fat
    /lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/fs/fat/fat.ko.xz
    /lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/fs/fat/msdos.ko.xz
    /lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/fs/fat/vfat.ko.xz
    
    # B. 是否已經有載入 fat 相關的模組了?若無,請載入該模組,再次檢查是否載入成功
    [root@station200 ~]# lsmod | grep fat
    [root@station200 ~]# modprobe fat
    [root@station200 ~]# lsmod | egrep 'Module|fat'
    Module                  Size  Used by
    fat                    81920  0
    
    # C. 再次檢查有無 cifs 模組,若無,請載入,並查詢該模組的功能為何?
    [root@station200 ~]# find /lib/modules/4.18.0-147.8.1.el8_1.x86_64/ | grep cifs
    /lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/fs/cifs
    /lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/fs/cifs/cifs.ko.xz
    
    [root@station200 ~]# modprobe cifs
    [root@station200 ~]# modinfo cifs
    filename:       /lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/fs/cifs/cifs.ko.xz
    softdep:        pre: ccm
    .....
    version:        2.19
    description:    VFS to access SMB3 servers e.g. Samba, Macs, Azure and Windows 
                    (and also older servers complying with the SNIA CIFS Specification)
    license:        GPL
    .....
    # 在描述的地方,看起來就是 windows / Linux 的檔案系統存取模組喔!
    
    # D. 卸載 cifs 模組。
    [root@station200 ~]# lsmod | egrep 'Module|cifs'
    Module                  Size  Used by
    cifs                 1073152  0
    dns_resolver           16384  1 cifs
    [root@station200 ~]# modprobe -r cifs    <==卸載指令在此
    [root@station200 ~]# lsmod | egrep 'Module|cifs'
    Module                  Size  Used by
    
    # E. 在核心模組的目錄下,有沒有 ntfs 的關鍵字?
    [root@station200 ~]# find /lib/modules/4.18.0-147.8.1.el8_1.x86_64/ | grep ntfs
    # 所以,並沒有 ntfs 的關鍵字喔!
    
    # F. 在 yum 的使用上,啟用 epel 軟體庫,搜尋 ntfs 這個關鍵字軟體
    [root@station200 ~]# yum --enablerepo=epel search ntfs
    ================================= Name & Summary 符合: ntfs ==================================
    ntfs-3g.x86_64 : Linux NTFS userspace driver
    ntfsprogs.x86_64 : NTFS filesystem libraries and utilities
    ntfs-3g-devel.x86_64 : Development files and libraries for ntfs-3g
    ntfs-3g-system-compression.x86_64 : NTFS-3G plugin for reading "system compressed" files
    
    # G. 嘗試安裝上述找到的軟體名稱
    [root@station200 ~]# yum --enablerepo=epel install ntfs-3g
    [root@station200 ~]# rpm -qi ntfs-3g
    ......
    Summary     : Linux NTFS userspace driver
    Description :
    NTFS-3G is a stable, open source, GPL licensed, POSIX, read/write NTFS
    driver for Linux and many other operating systems. It provides safe
    handling of the Windows XP, Windows Server 2003, Windows 2000, Windows
    Vista, Windows Server 2008 and Windows 7 NTFS file systems. NTFS-3G can
    create, remove, rename, move files, directories, hard links, and streams;
    it can read and write normal and transparently compressed files, including
    streams and sparse files; it can handle special files like symbolic links,
    devices, and FIFOs, ACL, extended attributes; moreover it provides full
    file access right and ownership support.
    # 原來就是 NTFS 檔案系統的支援模組!
    
  • 例題 13.2.2-2:
    [root@station200 ~]# vim /etc/sysctl.d/mycentos.conf
    net.ipv4.icmp_echo_ignore_all = 0
    net.ipv4.ip_forward = 1
    dev.raid.speed_limit_min = 40000
    dev.raid.speed_limit_max = 50000
    
    [root@station200 ~]# sysctl -p /etc/sysctl.d/mycentos.conf
    
  • 例題 13.2.5-1:
    # A. 觀察你的系統內的核心版本
    [root@station200 ~]# ll /lib/modules
    drwxr-xr-x. 7 root root 4096  5月 25 21:31 4.18.0-147.8.1.el8_1.x86_64
    drwxr-xr-x. 6 root root 4096  5月 25 21:31 4.18.0-147.el8.x86_64
    
    [root@station200 ~]# uname -r
    4.18.0-147.8.1.el8_1.x86_64
    # 如上所示,我們有兩個核心,因為系統預設都會使用新核心開機,所以會看到目前是新核心。
    
    # B. 重新開機後,使用舊版核心開機,並確認確實為舊版核心
    [root@station200 ~]# reboot
    # 開機過程中,要在選單的環境中,選擇舊版核心才行!不能讓系統自己一直開機!
    
    [root@station200 ~]# uname -r
    4.18.0-147.el8.x86_64
    # 這時就會使用舊核心了!也就模擬了新核心無法開機時使用舊核心開機的機制!
    
    # C. 前往 /boot 目錄,將新版的 initramfs 暫時更名為其他檔案
    [root@station200 ~]# cd /boot
    [root@station200 boot]# ls initramfs-*
    initramfs-0-rescue-502dbaaf2a074134909a59ef9ab651c1.img  initramfs-4.18.0-147.el8.x86_64.img
    initramfs-4.18.0-147.8.1.el8_1.x86_64.img                initramfs-4.18.0-147.el8.x86_64kdump.img
    initramfs-4.18.0-147.8.1.el8_1.x86_64kdump.img
    
    [root@station200 boot]# mv initramfs-4.18.0-147.8.1.el8_1.x86_64.img initramfs-4.18.0-147.8.1.el8_1.x86_64.img.raw
    
    # D. 使用 dracut 重新建置該新版核心的 initramfs,加入 ixbge 這個網路卡模組
    [root@station200 boot]# dracut -v --add-drivers ixbge initramfs-4.18.0-147.8.1.el8_1.x86_64.img 4.18.0-147.8.1.el8_1.x86_64
    [root@station200 boot]# lsinitrd initramfs-4.18.0-147.8.1.el8_1.x86_64.img | grep -i ixgbe
    Arguments: -v --add-drivers 'ixgbe'
    drwxr-xr-x   2 root     root            0 Jan  4 02:12 usr/lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/drivers/net/ethernet/intel/ixgbe
    -rw-r--r--   1 root     root       146276 Jan  4 02:12 usr/lib/modules/4.18.0-147.8.1.el8_1.x86_64/kernel/drivers/net/ethernet/intel/ixgbe/ixgbe.ko.xz
    
    # E. 重新開機之後,選擇新核心開機,看看是否可以順利開機進入系統
    # 直接以新核心開機測試一下,基本上應該是可以順利開機沒啥大問題才對!
    
  • 例題 13.3 課後練習
    1. 想出並執行兩種重新載入 (reload) atd 的方法
      [root@station200 ~]# pstree -p | grep atd
                 |-atd(1543)
      [root@station200 ~]# kill -1 1543
      
      [root@station200 ~]# systemctl reload atd
      Failed to reload atd.service: Job type reload is not applicable for unit atd.service.
      
      [root@station200 ~]# systemctl restart atd
      [root@station200 ~]# pstree -p | grep atd
                 |-atd(2652)
      
      看起來 systemctl 控制底下的 atd 只能重啟,不能重新載入!所以改成 restart 重啟。要注意的是,使用 kill -1 不會改變原有程序的 PID, 但是 restart 會改變喔!因為 restart 是關閉後啟動的意思,與 reload 載入設定檔並不相同。
    2. 預設文字界面的設定方式:
      [root@station200 ~]# systemctl get-default
      graphical.target
      
      [root@station200 ~]# systemctl set-default multi-user.target
      Removed /etc/systemd/system/default.target.
      Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/multi-user.target.
      
      [root@station200 ~]# systemctl get-default
      multi-user.target
      
      [root@station200 ~]# systemctl isolate graphical.target
      
    3. 記得設計網路服務需要五個步驟喔:
      # A. 安裝
      [root@station200 ~]# yum install vsftpd
      
      [root@station200 ~]# rpm -ql vsftpd | grep systemd
      /usr/lib/systemd/system-generators/vsftpd-generator
      /usr/lib/systemd/system/vsftpd.service
      /usr/lib/systemd/system/vsftpd.target
      /usr/lib/systemd/system/vsftpd@.service
      
      # B. 啟動
      [root@station200 ~]# systemctl start vsftpd
      [root@station200 ~]# netstat -tlunp | grep vsftpd
      tcp6       0      0 :::21      :::*          LISTEN      2839/vsftpd        
      
      # C. 開機啟動
      [root@station200 ~]# systemctl enable vsftpd
      Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /usr/lib/systemd/system/vsftpd.service.
      
      [root@station200 ~]# systemctl status vsftpd
      ● vsftpd.service - Vsftpd ftp daemon
         Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
         Active: active (running) since Thu 2020-05-28 10:25:26 CST; 1min 31s ago
       Main PID: 2839 (vsftpd)
          Tasks: 1 (limit: 11484)
         Memory: 604.0K
         CGroup: /system.slice/vsftpd.service
                 └─2839 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
      
      # D. 防火牆
      [root@station200 ~]# firewall-cmd --permanent --add-service=ftp
      [root@station200 ~]# systemctl restart firewalld.service
      [root@station200 ~]# firewall-cmd --list-services
      ftp http https ssh syslog
      
      # E. 測試
      # 透過一些簡易的方法檢查~例如透過瀏覽器輸入網址列『 ftp://localhost 』即可!
      
    4. 強迫使用自己想要的優化環境,不用系統預設建議值:
      [root@station200 ~]# tuned-adm profile network-latency
      [root@station200 ~]# tuned-adm active
      Current active profile: network-latency
      
    5. 增加某些自己需要的系統優化條件方式:
      [root@station200 ~]# vim /etc/sysctl.d/mycentos.conf
      net.ipv4.icmp_echo_ignore_all = 0
      net.ipv4.ip_forward = 1
      dev.raid.speed_limit_min = 40000
      dev.raid.speed_limit_max = 50000
      vm.dirty_ratio = 40
      vm.dirty_background_ratio = 5
      vm.swappiness = 10
      
      [root@station200 ~]# sysctl -p /etc/sysctl.d/mycentos.conf
      
    6. 以最新的核心 (每學期做都會不一樣喔!所以要自己找出新核心!) 做圖形界面開機
      # 1. 找出新核心版本
      [root@station200 ~]# ll /lib/modules
      drwxr-xr-x. 7 root root 4096  5月 25 21:31 4.18.0-147.8.1.el8_1.x86_64
      drwxr-xr-x. 6 root root 4096  5月 25 21:31 4.18.0-147.el8.x86_64
      
      # 2. 開始跑到 /boot/loader/entries 製作新選單
      [root@station200 entries]# ls *4.18.0-147.8.1.el8_1.x86_64*
      502dbaaf2a074134909a59ef9ab651c1-4.18.0-147.8.1.el8_1.x86_64.conf
      [root@station200 entries]# cp 502dbaaf2a074134909a59ef9ab651c1-4.18.0-147.8.1.el8_1.x86_64.conf 502dbaaf2a074134909a59ef9ab651c1-4.18.0-147.8.1.el8_1.x86_64-gui.conf
      [root@station200 entries]# vim 502dbaaf2a074134909a59ef9ab651c1-4.18.0-147.8.1.el8_1.x86_64-gui.conf
      title CentOS Linux (4.18.0-147.8.1.el8_1.x86_64) 8 (Core) - GUI mode
      version 4.18.0-147.8.1.el8_1.x86_64
      linux /vmlinuz-4.18.0-147.8.1.el8_1.x86_64
      initrd /initramfs-4.18.0-147.8.1.el8_1.x86_64.img $tuned_initrd
      options $kernelopts $tuned_params systemd.unit=graphical.target
      id mygui
      grub_users $grub_users
      grub_arg --unrestricted
      grub_class kernel
      
      # 3. 設定預設開機選單的 id 為 mygui 即可!
      [root@station200 entries]# vim /etc/default/grub
      .....
      GRUB_DEFAULT=mygui
      .....
      
      # 4. 重新建置 grub.cfg 檔案內容,並測試開機
      [root@station200 entries]# grub2-mkconfig -o /boot/grub2/grub.cfg
      [root@station200 entries]# reboot
      
修改歷史:
  • 2020/02/25:嘗試直接在課程中加入解答,讓大家有個參考依據。不過,沒事不要來看啊!
  • 2020/03/10:加入了第三章的後課練習部份。
2020/03/02 以來統計人數
計數器
其他連結
環境工程模式篇
鳥園討論區
鳥哥舊站

今日 人數統計
昨日 人數統計
本月 人數統計
上月 人數統計