日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

网络yum源 自定义yum仓库 zip备份 编译安装

發布時間:2025/3/21 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 网络yum源 自定义yum仓库 zip备份 编译安装 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Top

NSD SERVICES DAY01

  • 案例1:補充應用技巧
  • 案例2:軟連接與硬連接
  • 案例3:man手冊、zip備份
  • 案例4:自定義yum軟件倉庫
  • 案例5:發布及測試yum倉庫
  • 案例6:vim效率操作
  • 案例7:編譯安裝軟件包
  • 案例8:使用systemctl工具
  • 1 案例1:補充應用技巧

    1.1 問題

    本例要求掌握在運維中比較常用的一些擴展命令技巧的使用,完成下列小技巧操作:

  • 采用數值形式將目錄/root的權限調整為 rwx------
  • 將記錄的歷史命令條數更改為 200 條
  • 統計 /boot、/etc/pki 目錄占用的空間大小
  • 以格式“yyyy-mm-dd HH:MM” 顯示系統時間
  • 1.2 方案

    date日期時間工具:

    • 顯示日期時間:date、date +"%Y-%m-%d %H:%M:%S"
    • 調整日期時間:date -s "yyyy-mm-dd HH:MM:SS"
    • 恢復為硬件時間:hwclock -s

    1.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:采用數值形式將目錄/root的權限調整為 rwx------

    1)查看原來的權限

  • [root@svr7 ~]# ls -ld /root/
  • dr-xr-x---. 22 root root 4096 3月 26 14:59 /root/
  • 2)修改為新權限

  • [root@svr7 ~]# chmod 700 /root/
  • 3)確認權限設置結果

  • [root@svr7 ~]# ls -ld /root/
  • drwx------. 22 root root 4096 3月 26 14:59 /root/
  • 步驟二:將記錄的歷史命令條數更改為 200 條

    1)調整記錄條數

    修改配置文件/etc/profile,找到HISTSIZE行,將此變量的值修改為200:

  • [root@svr7 ~]# vim /etc/profile
  • .. ..
  • HISTSIZE = 200
  • 2)確認設置結果

    所有用戶重新登錄以后即可生效:

  • [root@svr7 ~]# su - root
  • [root@svr7 ~]# echo $HISTSIZE
  • 200
  • 步驟三:統計 /boot、/etc/pki 目錄占用的空間大小

    1)分別統計結果

  • [root@svr7 ~]# du -sh /boot/ /etc/pki/
  • 130M ????/boot/
  • 1.5M????/etc/pki/
  • 2)比較du與ls查看文件大小的差異(默認塊大小4096字節):

  • [root@svr7 ~]# ls -lh /etc/inittab ????????????????????//數據大小511字節
  • -rw-r--r--. 1 root root 511 Sep 16 2015 /etc/inittab
  • [root@svr7 ~]# du -sh /etc/inittab ????????????????????//實際占用4KB磁盤空間
  • 4.0K????/etc/inittab
  • 步驟四:以格式“yyyy-mm-dd HH:MM” 顯示系統時間

  • [root@svr7 ~]# date +"%F %R"
  • 2016-12-26 16:23
  • 2 案例2:軟連接與硬連接

    2.1 問題

    本例要求理解軟連接與硬連接的基本差異,完成下列操作:

  • 新建文件 file1,內容為 AAAA
  • 為 file1 建立軟連接 file1-s,對比兩文件內容
  • 為 file1 建立硬連接 file1-h,對比兩文件內容
  • 對比上述 3 個文件的 i 節點編號
  • 刪除文件 file1 ,再查看文件 file1-s、file1-h 內容
  • 2.2 方案

    軟連接與硬連接:

    • 軟連接:指向原始文件的路徑,若原始文件被刪除,連接文件將失效;原始文件可以是目錄;原始文件與連接文件可以在不同的分區/文件系統
    • 硬連接:指向原始文件的i節點檔案,若原始文件被刪除,連接文件仍然有效;原始文件不能是目錄;原始文件與連接文件必須在同一個分區/文件系統

    2.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:使用ln命令為文檔/目錄建立連接

    1)新建一個測試文件

  • [root@svr7 ~]# vim file1
  • AAAA
  • 2)為文件file1建立軟連接file1-s并測試

  • [root@svr7 ~]# ln -s file1 file1-s
  • [root@svr7 ~]# cat file1-s
  • linux.tedu.cn
  • 3)為文件file1建立硬連接file1-h并測試

  • [root@svr7 ~]# ln file1 file1-h
  • [root@svr7 ~]# cat file1-h
  • linux.tedu.cn
  • 4)對比原始文件、軟連接、硬連接的屬性

    可以發現軟連接只是一個快捷方式,而硬連接與原始文件的i節點編號相同,其實對應同一塊磁盤存儲:

  • [root@svr7 ~]# ls -li /root/f0*.txt
  • 204645793 -rw-r--r--. 2 root root 14 Jan 6 12:14 file1-h
  • 201628464 lrwxrwxrwx. 1 root root 12 Jan 6 12:16 file1-s -> file1
  • 204645793 -rw-r--r--. 2 root root 14 Jan 6 12:14 file1
  • 步驟二:原始文件刪除測試

    1)當原始文件被刪除時,軟連接將會失效,而硬連接仍然可訪問文件數據

  • [root@svr7 ~]# rm -rf file1
  • [root@svr7 ~]# cat file1-s
  • cat: file1-s: No such file or directory
  • [root@svr7 ~]# cat file1-h
  • linux.tedu.cn
  • 2)如果已知原始文件和硬連接的路徑,當原始文件丟失時,可以快速重建

  • [root@svr7 ~]# ln file1-h file1
  • [root@svr7 ~]# ls -li /root/f0*.txt
  • 204645793 -rw-r--r--. 2 root root 14 Jan 6 12:14 file1-h
  • 201628464 lrwxrwxrwx. 1 root root 12 Jan 6 12:16 file1-s -> file1
  • 204645793 -rw-r--r--. 2 root root 14 Jan 6 12:14 file1
  • 3)不支持為目錄創建硬連接,但可以為目錄建立軟連接

  • [root@svr7 ~]# ln /etc/sysconfig/network-scripts/ /etc/network
  • ln: '/etc/sysconfig/network-scripts/': hard link not allowed for directory
  • [root@svr7 ~]# ln -s /etc/sysconfig/network-scripts/ /etc/interface
  • [root@svr7 ~]# ls -l /etc/interface
  • lrwxrwxrwx. 1 root root 31 Jan 6 12:28 /etc/interface -> /etc/sysconfig/network-scripts/
  • 3 案例3:man手冊、zip備份

    3.1 問題

    本例要求掌握man幫助手冊的使用,以及zip壓縮/解壓縮的操作,完成下列任務:

  • 查閱passwd命令、/etc/passwd配置文件的手冊頁
  • 使用zip打包/usr/share/doc/qemu-kvm/目錄
  • 3.2 方案

    zip/unzip壓縮與解壓縮:

    • 制作zip壓縮包:zip [-r] 備份文件.zip 被歸檔的文檔...
    • 釋放zip壓縮包:unzip 備份文件.zip [-d 目標文件夾]

    3.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:使用man手冊頁獲取幫助

    1)查看passwd命令的手冊頁

  • [root@svr7 ~]# man passwd
  • PASSWD(1) User utilities PASSWD(1)
  • NAME
  • passwd - update user's authentication tokens
  • SYNOPSIS
  • passwd [-k] [-l] [-u [-f]] [-d] [-e] [-n mindays] [-x maxdays] [-w
  • warndays] [-i inactivedays] [-S] [--stdin] [username]
  • DESCRIPTION
  • The passwd utility is used to update user's authentication token(s).
  • This task is achieved through calls to the Linux-PAM and Libuser API.
  • Essentially, it initializes itself as a "passwd" service with Linux-
  • PAM and utilizes configured password modules to authenticate and then
  • update a user's password.
  • .. ..
  • 2)查看/etc/passwd配置文件的手冊頁

  • [root@svr7 ~]# man 2 passwd
  • PASSWD(5) Linux Programmer's Manual PASSWD(5)
  • NAME
  • passwd - password file
  • DESCRIPTION
  • The /etc/passwd file is a text file that describes user login
  • accounts for the system. It should have read permission allowed for
  • all users (many utilities, like ls(1) use it to map user IDs to user‐
  • names), but write access only for the superuser.
  • In the good old days there was no great problem with this general
  • read permission. Everybody could read the encrypted passwords, but
  • the hardware was too slow to crack a well-chosen password, and more‐
  • over the basic assumption used to be that of a friendly user-commu‐
  • nity. These days many people run some version of the shadow password
  • suite, where /etc/passwd has an 'x' character in the password
  • .. ..
  • 步驟二:使用zip命令制作壓縮包

    1)將目錄/usr/share/doc/qemu-kvm/備份為/root/qemu-kvm.zip

  • [root@svr7 ~]# zip -r /root/qemu-kvm.zip /usr/share/doc/qemu-kvm/
  • adding: usr/share/doc/qemu-kvm/ (stored 0%)
  • adding: usr/share/doc/qemu-kvm/COPYING (deflated 62%)
  • adding: usr/share/doc/qemu-kvm/COPYING.LIB (deflated 65%)
  • adding: usr/share/doc/qemu-kvm/Changelog (deflated 61%)
  • adding: usr/share/doc/qemu-kvm/LICENSE (deflated 45%)
  • adding: usr/share/doc/qemu-kvm/README (deflated 4%)
  • 2)恢復測試

    刪除目標文件夾并確認結果:

  • [root@svr7 ~]# rm -rf /usr/share/doc/qemu-kvm/
  • [root@svr7 ~]# ls /usr/share/doc/qemu-kvm/
  • ls: cannot access /usr/share/doc/qemu-kvm/: No such file or directory
  • 恢復目標文件夾并確認結果:

  • [root@svr7 ~]# unzip /root/qemu-kvm.zip -d /
  • Archive: /root/qemu-kvm.zip
  • creating: /usr/share/doc/qemu-kvm/
  • inflating: /usr/share/doc/qemu-kvm/COPYING
  • inflating: /usr/share/doc/qemu-kvm/COPYING.LIB
  • inflating: /usr/share/doc/qemu-kvm/Changelog
  • .. ..
  • [root@svr7 ~]# ls /usr/share/doc/qemu-kvm/
  • COPYING README qemu-tech.html
  • COPYING.LIB README.rhel6-gpxe-source qmp-commands.txt
  • Changelog README.systemtap qmp-events.txt
  • LICENSE qemu-doc.html qmp-spec.txt
  • 4 案例4:自定義yum軟件倉庫

    4.1 問題

    本例要求在CentOS真機上利用RHEL7的光盤鏡像文件準備一個軟件倉庫目錄,完成下列任務:

  • 創建目錄 /var/www/html/rh7dvd
  • 掛載 rhel-server-7.2-x86_64-dvd.iso 到上述目錄
  • 另外,利用收集的一些第三方RPM軟件包文件,配置為可發布的yum倉庫目錄,相關任務如下:

  • 掛載RHEL7光盤鏡像文件到 /var/www/html/ 目錄
  • 下載 LibreOffice 辦公軟件的 rpm 集合版文件
  • 將其中的內容釋放到 /opt/libreoffice/ 目錄
  • 為 /opt/libreoffice/ 目錄建立倉庫檔案
  • 4.2 方案

    作為yum軟件源的目錄需要準備的內容:

    • 大量的 .rpm 軟件安裝包文件
    • 針對這些軟件包的 repodata/ 倉庫檔案

    repodata/ 倉庫檔案提供的數據:

    • filelists.xml.gz:提供所有軟件包的文件安裝清單
    • primary.xml.gz:提供所有軟件包的基本/主要信息
    • other.xml.gz:提供所有軟件包的其他信息
    • repomd.xml:提供上述檔案數據文件.xml.gz的下載和校驗信息

    4.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:準備 /var/www/html/rh7dvd 倉庫目錄

    1)創建目錄 /var/www/html/rh7dvd

  • [root@room9pc13 ~]# mkdir /var/www/html/rh7dvd
  • 2)掛載 rhel-server-7.2-x86_64-dvd.iso 到上述目錄

  • [root@room9pc13 ~]# vim /etc/fstab
  • .. ..
  • /ISO/rhel-server-7.2-x86_64-dvd.iso /var/www/html/rh7dvd iso9660 loop,ro 0 0
  • [root@room9pc13 ~]# mount -a
  • 3)確認部署結果

  • [root@room9pc13 ~]# ls /var/www/html/rh7dvd/
  • addons images Packages RPM-GPG-KEY-redhat-release
  • EFI isolinux release-notes TRANS.TBL
  • EULA LiveOS repodata
  • GPL media.repo RPM-GPG-KEY-redhat-beta
  • 步驟二:準備 /opt/libreoffice/ 倉庫目錄

    1)將獲取的LibreOffice軟件集合包釋放到指定目錄

  • [root@room9pc13 ~]# ls LibreOffice_5.1.6.2_Linux_x86-64_rpm.zip
  • LibreOffice_5.1.6.2_Linux_x86-64_rpm.zip
  • [root@room9pc13 ~]# unzip LibreOffice_5.1*.zip -d /opt/libreoffice
  • Archive: LibreOffice_5.1.6.2_Linux_x86-64_rpm.zip
  • inflating: /opt/libreoffice/install
  • creating: /opt/libreoffice/langpack_zh-CN/
  • creating: /opt/libreoffice/langpack_zh-CN/RPMS/
  • .. .. ????????????????????????????????????????//釋放到 /opt/libreoffice 目錄
  • 2)使用createrepo建立檔案

  • [root@room9pc13 ~]# createrepo /opt/libreoffice/
  • Spawning worker 0 with 53 pkgs
  • Workers Finished
  • Saving Primary metadata
  • Saving file lists metadata
  • Saving other metadata
  • Generating sqlite DBs
  • Sqlite DBs complete
  • 3)確認repodata/檔案資料

  • [root@room9pc13 ~]# ls /opt/libreoffice/repodata
  • 1a5d8311268f33ad2cbf91382110e1ef9875aeea366897253a5d27fd42f9e317-other.xml.gz
  • 2cd176f0b00492c0c13e0a659eda7dedeb1ab526dec5fd7c9bac7758558770d2-filelists.xml.gz
  • 6ecab3585a93a917202e177b9569046238332af449a6492fcace96ea79374668-filelists.sqlite.bz2
  • b09a1f838262e0b67a5ab0d6be516bd921a914afd89864e09650f95662a20371-primary.sqlite.bz2
  • b6fcf4a24de5dc08585bf52bd34be50d7df376d5fbcf50903bfd3c1dfdf160bf-other.sqlite.bz2
  • f57724cf309cc102b2ee25596bf8fb39db3c23880404209ac1e379f7b9fd5c49-primary.xml.gz
  • repomd.xml
  • 5 案例5:發布及測試yum倉庫

    5.1 問題

    沿用案例5,本例要求掌握發布及測試yum倉庫的方法,方便在網絡內提供集中的yum源服務器,主要完成下列任務:

  • 在CentOS真機 上發布yum源,包括:rhel7 系統的光盤目錄倉庫、LibreOffice 的rpm軟件包倉庫
  • 在主機 pc207 上使用上述yum源
  • 5.2 方案

    通過網絡發布yum軟件源時,只需要配置HTTP或FTP資源服務器,然后將提前準備好的yum倉庫目錄部署到可訪問的資源位置即可。

    在訪問網絡yum軟件源時,注意客戶端的baseurl地址必須與資源提供方式一致:

    • baseurl = htp://服務器地址/目錄名 ==》 /var/www/html/目錄名
    • baseurl = ftp://服務器地址/目錄位置 ==》 /var/ftp/目錄名

    5.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:在CentOS真機上發布yum倉庫

    1)快速搭建httpd服務器(若已建好,此步可跳過)

  • [root@room9pc13 ~]# yum -y install httpd ????????????????//裝包
  • [root@room9pc13 ~]# systemctl restart httpd ????????????????//起服務
  • [root@room9pc13 ~]# systemctl enable httpd ????????????????//設置開機自啟
  • 2)確認前一步已經部署到Web網站目錄的RHEL7光盤數據:

  • [root@room9pc13 ~]# du -sh /var/www/html/rh7dvd/ ????????????????//檢查部署結果
  • 3.9G????/var/www/html/rh7dvd/
  • 3)將準備好的LibreOffice倉庫目錄部署到Web網頁目錄

  • [root@room9pc13 ~]# mv /opt/libreoffice/ /var/www/html/
  • [root@room9pc13 ~]# du -sh /var/www/html/llibreoffice/ ????????//檢查部署結果
  • 234M????/var/www/html/libreoffice
  • 步驟二:在pc207上訪問yum倉庫

    1)添加新的yum倉庫設置

  • [root@pc207 ~]# vim /etc/yum.repos.d/new.repo
  • [rh7dvd]
  • name = RHEL 7.2 Server
  • baseurl = http://192.168.4.254/rh7dvd
  • gpgcheck = 0
  • [libreoffice]
  • name = LibreOffice 5
  • baseurl=http://192.168.4.254/libreoffice
  • gpgcheck = 0
  • 2)測試新的yum倉庫

  • [root@pc207 ~]# yum repolist
  • .. ..
  • repo id repo name status
  • libreoffice LibreOffice 5 53
  • rh7dvd RHEL 7.2 Server 4620
  • .. ..
  • 6 案例6:vim效率操作

    6.1 問題

    本例要求掌握使用vim文本編輯器時能夠提高操作效率的一些常用技巧和方法,完成下列任務:

  • 將文件 /etc/passwd 復制為 /opt/nsd.txt,然后打開 /opt/nsd.txt 文件,練習命令模式下的切換/復制/刪除/查找操作
  • 將文件 /etc/man_db.conf 復制到 /opt 目錄下,然后打開 /opt/man_db.conf 文件,將第50~100行內的“man”替換為“MAN”,在 vim 中設置顯示行號查看效果
  • 6.2 方案

    命令模式常用操作:

    • 1G 或 gg ,跳轉到文件的首行
    • G ,跳轉到文件的末尾行
    • yy、#yy ,復制光標處的一行、#行
    • p、P ,粘貼到光標處之后、之前
    • x 或 Delete鍵 ,刪除光標處的單個字符
    • dd、#dd ,刪除光標處的一行、#行
    • d^、d$ ,從光標處之前刪除至行首/行尾
    • /word 向后查找字符串“word”,再按n/N跳至后/前一個結果
    • u ,撤銷最近的一次操作
    • U ,撤銷對當前行的所有修改
    • Ctrl + r 取消前一次撤銷操作
    • ZZ 保存修改并退出

    末行模式常用操作:

    • :s/old/new ,替換當前行第一個“old”
    • :s/old/new/g ,替換當前行所有的“old”
    • :n,m s/old/new/g ,替換第n-m行所有的“old”
    • :% s/old/new/g ,替換文件內所有的“old”
    • :w /root/newfile ,另存為其它文件
    • :r /etc/filesystems ,讀入其他文件內容
    • :set nu|nonu ,顯示/不顯示行號
    • :set ai|noai ,啟用/關閉自動縮進

    6.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:vim命令模式下的切換/復制/刪除/查找

    1)建立練習文件

    將文件 /etc/passwd 復制為 /opt/nsd.txt:

  • [root@svr7 ~]# cp /etc/passwd /opt/nsd.txt
  • 2)使用vim打開練習文件,默認處于命令模式

  • [root@svr7 ~]# vim /opt/nsd.txt
  • .. ..
  • 3)在命令模式下完成下列操作

    切換操作:G 最后一行,5G 第5行,gg 第一行。

    復制操作:按2yy復制2行,7G移動到第7行,p 粘貼。

    刪除操作:25G 移動到第25行,200dd 從此行開始刪除200行(不夠就剩下全刪)。

    查找操作:gg 第一行,/adm 查找關鍵詞adm,n 跳轉到下一個結果。

    4)保存并退出編輯器

    ZZ 保存退出。

    步驟二:vim末行模式下的替換/設置操作

    1)建立練習文件

    將文件 /etc/man_db.conf 復制到 /opt/ 目錄下:

  • [root@svr7 ~]# cp /etc/man_db.conf /opt/
  • 2)使用vim打開練習文件,輸入:切換到末行模式

  • [root@svr7 ~]# vim /opt/man_db.conf
  • .. ..
  • :
  • 3)在末行模式下完成下列操作

    輸入 :set nu ,確認后顯示行號。

    輸入 :50,100 s/man/MAN/g ,確認將第50~100行內的“man”替換為“MAN”。

    4)保存并退出編輯器

    輸入 :wq ,確認后保存并退出編輯器。

    7 案例7:編譯安裝軟件包

    7.1 問題

    本例要求掌握常規源代碼應用的安裝過程,通過編譯的方式安裝inotify-tools 軟件工具,完成下列任務:

  • 釋放 inotify-tools-3.13.tar.gz 源碼包
  • 配置 ./configure
  • 編譯 make、安裝 make install
  • 測試inotifywait監控工具的用法及用途
  • 7.2 方案

    對于標準源碼發布的C/C++軟件包,編譯安裝一般包括以下過程:

  • 解包:使用tar命令,將下載的源代碼釋放至指定目錄
  • 配置:執行源碼目錄內的 ./configure 腳本,指定安裝目錄/功能模塊等選項
  • 編譯:在源碼目錄下執行 make 操作,根據配置清單Makefile生成可執行的二進制程序文件
  • 安裝:在源碼目錄下執行make install 操作,將編譯好的程序及相關文件復制到安裝目錄
  • 7.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:確認已配置好編譯環境

  • [root@svr7 ~]# yum -y install gcc gcc-c++ make
  • .. ..
  • [root@svr7 ~]# gcc --version
  • gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-4)
  • Copyright (C) 2015 Free Software Foundation, Inc.
  • This is free software; see the source for copying conditions. There is NO
  • warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  • 步驟二:編譯安裝inotify-tools軟件包

    1)解包inotify-tools-3.13.tar.gz文件

  • [root@svr7 ~]# ls inotify-tools-3.13.tar.gz
  • inotify-tools-3.13.tar.gz
  • [root@svr7 ~]# tar xf inotify-tools-3.13.tar.gz -C /usr/src/
  • 2)配置 ./configure,安裝目錄默認(/usr/local/*/)

  • [root@svr7 ~]# cd /usr/src/inotify-tools-3.13/ ????????//進入源碼目錄
  • [root@svr7 inotify-tools-3.13]# ./configure ????????????//配置操作
  • checking for a BSD-compatible install... /usr/bin/install -c
  • checking whether build environment is sane... yes
  • checking for gawk... gawk
  • .. ..
  • configure: creating ./config.status
  • config.status: creating Makefile
  • .. ..
  • [root@svr7 inotify-tools-3.13]# ls Makefile ????????????//檢查配置結果
  • Makefile
  • 3)編譯 make

  • [root@svr7 inotify-tools-3.13]# make
  • .. ..
  • Making all in src
  • make[2]: Entering directory `/usr/src/inotify-tools-3.13/src'
  • make[3]: Entering directory `/usr/src/inotify-tools-3.13'
  • make[3]: Leaving directory `/usr/src/inotify-tools-3.13'
  • .. ..
  • 4)安裝 make install

  • [root@svr7 inotify-tools-3.13]# make install
  • .. ..
  • /usr/bin/install -c .libs/inotifywait /usr/local/bin/inotifywait
  • /bin/sh ../libtool --mode=install /usr/bin/install -c 'inotifywatch' '/usr/local/bin/inotifywatch'
  • .. ..
  • [root@svr7 inotify-tools-3.13]# find /usr/local/ -name "inotify*"
  • /usr/local/bin/inotifywait ????????????????????????????//確認安裝結果
  • /usr/local/bin/inotifywatch
  • /usr/local/include/inotifytools
  • /usr/local/include/inotifytools/inotifytools.h
  • 步驟三:測試inotify-tools軟件程序

    軟件包inotify-tools提供了一個主要程序inotifywait,可以用來監控指定目錄或文檔的變化,并及時給出通知。

    1)開啟對/opt目錄的事件監控

  • [root@svr7 ~]# inotifywait -mrq /opt & ????????????????//開啟監控
  • [1] 15568
  • 2)修改/opt/目錄內容,觀察屏幕輸出信息

  • [root@svr7 ~]# touch /opt/a.txt ????????????????????????//新建文件a.txt
  • /opt/ CREATE a.txt
  • /opt/ OPEN a.txt
  • /opt/ ATTRIB a.txt
  • /opt/ CLOSE_WRITE,CLOSE a.txt
  • [root@svr7 ~]# mv /opt/a.txt /opt/b.txt ????????????????//將文件改名
  • /opt/ MOVED_FROM a.txt
  • /opt/ MOVED_TO b.txt
  • 3)結束inotifywait監控

    殺死當前用戶的第一個后臺任務:

  • [root@svr7 ~]# kill -9 %1
  • [1]+ Killed inotifywait -mrq /opt
  • 8 案例8:使用systemctl工具

    8.1 問題

    本例要求掌握systemctl控制工具的基本操作,完成下列任務:

  • 重啟 httpd、crond、bluetooth 服務,查看狀態
  • 禁止 bluetooth 服務開機自啟,并停用此服務
  • 設置默認級別為 multi-user.target 并確認
  • 8.2 方案

    systemd是一個更高效的系統&服務管理器,其相關特性如下:

    • 開機服務并行啟動,各系統服務間的精確依賴
    • 配置目錄:/etc/systemd/system/
    • 服務目錄:/lib/systemd/system/

    systemctl是systemd的管理工具,將相關資源組織為unit配置單元進行管理。

    不同的unit決定了一組相關的啟動任務,service和target是最常用的配置單元:

    • service:后臺獨立服務
    • target:一套配置單元的組合,類似于傳統“運行級別”

    8.3 步驟

    實現此案例需要按照如下步驟進行。

    步驟一:重啟 httpd、crond、bluetooth 服務,查看狀態

    1)重啟系統服務httpd、crond、bluetooth

  • [root@svr7 ~]# systemctl restart httpd crond bluetooth
  • 2)查看上述服務的狀態

  • [root@svr7 ~]# systemctl status httpd crond bluetooth
  • * httpd.service - The Apache HTTP Server
  • Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
  • Active: active (running) since Fri 2017-01-06 18:18:20 CST; 18s ago
  • .. ..
  • * crond.service - Command Scheduler
  • Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
  • Active: active (running) since Fri 2017-01-06 18:18:19 CST; 19s ago
  • .. ..
  • * bluetooth.service - Bluetooth service
  • Loaded: loaded (/usr/lib/systemd/system/bluetooth.service; enabled; vendor preset: enabled)
  • Active: active (running) since Fri 2017-01-06 18:18:19 CST; 19s ago
  • .. ..
  • 步驟二:禁止 bluetooth 服務開機自啟,并停用此服務

    1)停用bluetooth服務

  • [root@svr7 ~]# systemctl stop bluetooth
  • 2)禁止bluetooth服務開機自啟

  • [root@svr7 ~]# systemctl disable bluetooth
  • Removed symlink /etc/systemd/system/dbus-org.bluez.service.
  • Removed symlink /etc/systemd/system/bluetooth.target.wants/bluetooth.service.
  • [root@svr7 ~]# systemctl is-enabled Bluetooth ????????????//檢查結果
  • disabled
  • 步驟三:設置默認級別為 multi-user.target 并確認

    1)查看默認運行級別

  • [root@svr7 ~]# systemctl get-default
  • graphical.target
  • 2)將默認運行級別設置為multi-user.target

  • [root@svr7 ~]# systemctl set-default multi-user.target
  • Removed symlink /etc/systemd/system/default.target.
  • Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
  • 3)確認配置結果

  • [root@svr7 ~]# systemctl get-default
  • multi-user.target
  • 根據此處的設置,重啟此虛擬機后圖形桌面將不再可用。

    轉載于:https://www.cnblogs.com/tiki/p/10783215.html

    總結

    以上是生活随笔為你收集整理的网络yum源 自定义yum仓库 zip备份 编译安装的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。