Ví dụ đại lý snmp python

Mở rộng phần "9. 7. Tự động làm mới cơ sở dữ liệu gói và tải xuống các bản cập nhật bằng Yum-cron" Thu gọn phần "9. 7. Tự động làm mới cơ sở dữ liệu gói và tải xuống các bản cập nhật với Yum-cron"
  1. 9. 7. 1. Kích hoạt cài đặt tự động cập nhật
  2. 9. 7. 2. Thiết lập thông báo email tùy chọn
  3. 9. 7. 3. Kích hoạt hoặc vô hiệu hóa các kho lưu trữ cụ thể
  4. 9. 7. 4. Kiểm tra cài đặt Yum-cron
  5. 9. 7. 5. Vô hiệu hóa tin nhắn Yum-cron
  6. 9. 7. 6. Tự động làm sạch các gói
  • 9. 8. Tài nguyên bổ sung
  • IV. Dịch vụ cơ sở hạ tầng Mở rộng phần "IV. Dịch vụ cơ sở hạ tầng" Thu gọn phần "IV. Dịch vụ cơ sở hạ tầng"
    1. 10. Quản lý dịch vụ với systemd Mở rộng phần "10. Quản lý dịch vụ với systemd" Thu gọn phần "10. Quản lý dịch vụ với systemd"
      1. 10. 1. Giới thiệu về systemd Mở rộng phần "10. 1. Giới thiệu về systemd" Thu gọn phần "10. 1. Giới thiệu về systemd"
        1. 10. 1. 1. Những đặc điểm chính
        2. 10. 1. 2. Thay đổi tương thích
      2. 10. 2. Quản lý dịch vụ hệ thống Mở rộng phần "10. 2. Quản lý dịch vụ hệ thống" Thu gọn phần "10. 2. Quản lý dịch vụ hệ thống"
        1. 10. 2. 1. Listing Services
        2. 10. 2. 2. Displaying Service Status
        3. 10. 2. 3. Starting a Service
        4. 10. 2. 4. Stopping a Service
        5. 10. 2. 5. Restarting a Service
        6. 10. 2. 6. Enabling a Service
        7. 10. 2. 7. Disabling a Service
        8. 10. 2. 8. Starting a Conflicting Service
      3. 10. 3. Working with systemd Targets Expand section "10. 3. Working with systemd Targets" Collapse section "10. 3. Working with systemd Targets"
        1. 10. 3. 1. Viewing the Default Target
        2. 10. 3. 2. Viewing the Current Target
        3. 10. 3. 3. Changing the Default Target
        4. 10. 3. 4. Changing the Current Target
        5. 10. 3. 5. Changing to Rescue Mode
        6. 10. 3. 6. Thay đổi sang Chế độ Khẩn cấp
      4. 10. 4. Shutting Down, Suspending, and Hibernating the System Expand section "10. 4. Shutting Down, Suspending, and Hibernating the System" Collapse section "10. 4. Shutting Down, Suspending, and Hibernating the System"
        1. 10. 4. 1. Shutting Down the System
        2. 10. 4. 2. Restarting the System
        3. 10. 4. 3. Suspending the System
        4. 10. 4. 4. Hibernating the System
      5. 10. 5. Controlling systemd on a Remote Machine
      6. 10. 6. Creating and Modifying systemd Unit Files Expand section "10. 6. Creating and Modifying systemd Unit Files" Collapse section "10. 6. Creating and Modifying systemd Unit Files"
        1. 10. 6. 1. Understanding the Unit File Structure
        2. 10. 6. 2. Creating Custom Unit Files
        3. 10. 6. 3. Converting SysV Init Scripts to Unit Files
        4. 10. 6. 4. Modifying Existing Unit Files
        5. 10. 6. 5. Working with Instantiated Units
      7. 10. 7. Additional Considerations While Managing Services
      8. 10. 8. Additional Resources
    2. 11. Configuring a System for Accessibility Expand section "11. Configuring a System for Accessibility" Collapse section "11. Configuring a System for Accessibility"
      1. 11. 1. Configuring the brltty Service
      2. 11. 2. Switch On Always Show Universal Access Menu
      3. 11. 3. Enabling the Festival Speech Synthesis System
    3. 12. OpenSSH Expand section "12. OpenSSH" Thu gọn phần "12. OpenSSH"
      1. 12. 1. Giao thức SSH Mở rộng phần "12. 1. Giao thức SSH" Thu gọn phần "12. 1. Giao thức SSH"
        1. 12. 1. 1. Tại sao nên sử dụng SSH?
        2. 12. 1. 2. Những đặc điểm chính
        3. 12. 1. 3. Phiên bản giao thức
        4. 12. 1. 4. Chuỗi sự kiện của kết nối SSH Mở rộng phần "12. 1. 4. Chuỗi sự kiện của kết nối SSH" Thu gọn phần "12. 1. 4. Chuỗi sự kiện của kết nối SSH"
          1. 12. 1. 4. 1. Lớp vận chuyển
          2. 12. 1. 4. 2. xác thực
          3. 12. 1. 4. 3. Channels
      2. 12. 2. Configuring OpenSSH Expand section "12. 2. Configuring OpenSSH" Collapse section "12. 2. Định cấu hình OpenSSH"
        1. 12. 2. 1. Configuration Files
        2. 12. 2. 2. Bắt đầu một máy chủ OpenSSH
        3. 12. 2. 3. Requiring SSH for Remote Connections
        4. 12. 2. 4. Using Key-based Authentication Expand section "12. 2. 4. Using Key-based Authentication" Collapse section "12. 2. 4. Using Key-based Authentication"
          1. 12. 2. 4. 1. Generating Key Pairs
          2. 12. 2. 4. 2. Configuring ssh-agent
      3. 12. 3. OpenSSH Clients Expand section "12. 3. OpenSSH Clients" Collapse section "12. 3. OpenSSH Clients"
        1. 12. 3. 1. Using the ssh Utility
        2. 12. 3. 2. Using the scp Utility
        3. 12. 3. 3. Using the sftp Utility
      4. 12. 4. More Than a Secure Shell Expand section "12. 4. More Than a Secure Shell" Collapse section "12. 4. More Than a Secure Shell"
        1. 12. 4. 1. X11 Forwarding
        2. 12. 4. 2. Port Forwarding
      5. 12. 5. Additional Resources
    4. 13. TigerVNC Expand section "13. TigerVNC" Collapse section "13. TigerVNC"
      1. 13. 1. VNC Server Expand section "13. 1. VNC Server" Collapse section "13. 1. VNC Server"
        1. 13. 1. 1. Cài đặt máy chủ VNC
        2. 13. 1. 2. Configuring VNC Server Expand section "13. 1. 2. Configuring VNC Server" Collapse section "13. 1. 2. Configuring VNC Server"
          1. 13. 1. 2. 1. Configuring VNC Server for Two Users
        3. 13. 1. 3. Starting VNC Server Expand section "13. 1. 3. Starting VNC Server" Collapse section "13. 1. 3. Starting VNC Server"
          1. 13. 1. 3. 1. Configuring VNC Server for Two Users and Two Different Displays
        4. 13. 1. 4. VNC setup based on xinetd with XDMCP for GDM
        5. 13. 1. 5. Terminating a VNC Session
      2. 13. 2. Sharing an Existing Desktop
      3. 13. 3. VNC Viewer Expand section "13. 3. VNC Viewer" Collapse section "13. 3. VNC Viewer"
        1. 13. 3. 1. Installing VNC Viewer
        2. 13. 3. 2. Connecting to VNC Server Expand section "13. 3. 2. Connecting to VNC Server" Collapse section "13. 3. 2. Connecting to VNC Server"
          1. 13. 3. 2. 1. Configuring the Firewall for VNC
        3. 13. 3. 3. Connecting to VNC Server Using SSH
      4. 13. 4. Additional Resources
  • V. Servers Expand section "V. Servers" Collapse section "V. Servers"
    1. 14. Web Servers Expand section "14. Web Servers" Collapse section "14. Web Servers"
      1. 14. 1. The Apache HTTP Server Expand section "14. 1. The Apache HTTP Server" Collapse section "14. 1. The Apache HTTP Server"
        1. 14. 1. 1. Notable Changes
        2. 14. 1. 2. Updating the Configuration
        3. 14. 1. 3. Running the httpd Service Expand section "14. 1. 3. Running the httpd Service" Collapse section "14. 1. 3. Running the httpd Service"
          1. 14. 1. 3. 1. Starting the Service
          2. 14. 1. 3. 2. Stopping the Service
          3. 14. 1. 3. 3. Restarting the Service
          4. 14. 1. 3. 4. Verifying the Service Status
        4. 14. 1. 4. Chỉnh sửa tệp cấu hình
        5. 14. 1. 5. Làm việc với Mô-đun Mở rộng phần "14. 1. 5. Làm việc với các mô-đun" Thu gọn phần "14. 1. 5. Làm việc với các mô-đun"
          1. 14. 1. 5. 1. Đang tải một mô-đun
          2. 14. 1. 5. 2. Writing a Module
        6. 14. 1. 6. Setting Up Virtual Hosts
        7. 14. 1. 7. Setting Up an SSL Server Expand section "14. 1. 7. Setting Up an SSL Server" Collapse section "14. 1. 7. Setting Up an SSL Server"
          1. 14. 1. 7. 1. An Overview of Certificates and Security
        8. 14. 1. 8. Enabling the mod_ssl Module Expand section "14. 1. 8. Enabling the mod_ssl Module" Collapse section "14. 1. 8. Enabling the mod_ssl Module"
          1. 14. 1. 8. 1. Enabling and Disabling SSL and TLS in mod_ssl
        9. 14. 1. 9. Enabling the mod_nss Module Expand section "14. 1. 9. Enabling the mod_nss Module" Collapse section "14. 1. 9. Enabling the mod_nss Module"
          1. 14. 1. 9. 1. Enabling and Disabling SSL and TLS in mod_nss
        10. 14. 1. 10. Using an Existing Key and Certificate
        11. 14. 1. 11. Generating a New Key and Certificate
        12. 14. 1. 12. Configure the Firewall for HTTP and HTTPS Using the Command Line Expand section "14. 1. 12. Configure the Firewall for HTTP and HTTPS Using the Command Line" Collapse section "14. 1. 12. Configure the Firewall for HTTP and HTTPS Using the Command Line"
          1. 14. 1. 12. 1. Checking Network Access for Incoming HTTPS and HTTPS Using the Command Line
        13. 14. 1. 13. Additional Resources
    2. 15. Mail Servers Expand section "15. Mail Servers" Collapse section "15. Mail Servers"
      1. 15. 1. Email Protocols Expand section "15. 1. Email Protocols" Collapse section "15. 1. Email Protocols"
        1. 15. 1. 1. Mail Transport Protocols Expand section "15. 1. 1. Mail Transport Protocols" Collapse section "15. 1. 1. Mail Transport Protocols"
          1. 15. 1. 1. 1. SMTP
        2. 15. 1. 2. Mail Access Protocols Expand section "15. 1. 2. Mail Access Protocols" Collapse section "15. 1. 2. Mail Access Protocols"
          1. 15. 1. 2. 1. NHẠC POP
          2. 15. 1. 2. 2. IMAP
          3. 15. 1. 2. 3. Dovecot
      2. 15. 2. Email Program Classifications Expand section "15. 2. Email Program Classifications" Collapse section "15. 2. Email Program Classifications"
        1. 15. 2. 1. Mail Transport Agent
        2. 15. 2. 2. Mail Delivery Agent
        3. 15. 2. 3. Mail User Agent
      3. 15. 3. Mail Transport Agents Expand section "15. 3. Mail Transport Agents" Collapse section "15. 3. Mail Transport Agents"
        1. 15. 3. 1. Postfix Expand section "15. 3. 1. Postfix" Collapse section "15. 3. 1. Postfix"
          1. 15. 3. 1. 1. The Default Postfix Installation
          2. 15. 3. 1. 2. Upgrading From a Previous Release
          3. 15. 3. 1. 3. Basic Postfix Configuration
          4. 15. 3. 1. 4. Using Postfix with LDAP Expand section "15. 3. 1. 4. Sử dụng Postfix với LDAP" Thu gọn phần "15. 3. 1. 4. Using Postfix with LDAP"
            1. 15. 3. 1. 4. 1. The /etc/aliases lookup example
        2. 15. 3. 2. Sendmail Expand section "15. 3. 2. Sendmail" Collapse section "15. 3. 2. Sendmail"
          1. 15. 3. 2. 1. Mục đích và Hạn chế
          2. 15. 3. 2. 2. The Default Sendmail Installation
          3. 15. 3. 2. 3. Common Sendmail Configuration Changes
          4. 15. 3. 2. 4. Masquerading
          5. 15. 3. 2. 5. Stopping Spam
          6. 15. 3. 2. 6. Using Sendmail with LDAP
        3. 15. 3. 3. Fetchmail Expand section "15. 3. 3. Fetchmail" Collapse section "15. 3. 3. Fetchmail"
          1. 15. 3. 3. 1. Fetchmail Configuration Options
          2. 15. 3. 3. 2. Global Options
          3. 15. 3. 3. 3. Server Options
          4. 15. 3. 3. 4. User Options
          5. 15. 3. 3. 5. Fetchmail Command Options
          6. 15. 3. 3. 6. Informational or Debugging Options
          7. 15. 3. 3. 7. Special Options
        4. 15. 3. 4. Mail Transport Agent [MTA] Configuration
      4. 15. 4. Mail Delivery Agents Expand section "15. 4. Mail Delivery Agents" Collapse section "15. 4. Mail Delivery Agents"
        1. 15. 4. 1. Procmail Configuration
        2. 15. 4. 2. Procmail Recipes Expand section "15. 4. 2. Procmail Recipes" Collapse section "15. 4. 2. Procmail Recipes"
          1. 15. 4. 2. 1. Delivering vs. Non-Delivering Recipes
          2. 15. 4. 2. 2. Flags
          3. 15. 4. 2. 3. Specifying a Local Lockfile
          4. 15. 4. 2. 4. Special Conditions and Actions
          5. 15. 4. 2. 5. Recipe Examples
          6. 15. 4. 2. 6. Spam Filters
      5. 15. 5. Mail User Agents Expand section "15. 5. Mail User Agents" Collapse section "15. 5. Mail User Agents"
        1. 15. 5. 1. Securing Communication Expand section "15. 5. 1. Securing Communication" Collapse section "15. 5. 1. Securing Communication"
          1. 15. 5. 1. 1. Secure Email Clients
          2. 15. 5. 1. 2. Securing Email Client Communications
      6. 15. 6. Configuring Mail Server with Antispam and Antivirus Expand section "15. 6. Configuring Mail Server with Antispam and Antivirus" Collapse section "15. 6. Configuring Mail Server with Antispam and Antivirus"
        1. 15. 6. 1. Configuring Spam Filtering for Mail Transport Agent or Mail Delivery Agent Expand section "15. 6. 1. Configuring Spam Filtering for Mail Transport Agent or Mail Delivery Agent" Collapse section "15. 6. 1. Configuring Spam Filtering for Mail Transport Agent or Mail Delivery Agent"
          1. 15. 6. 1. 1. Configuring Spam Filtering in a Mail Transport Agent
          2. 15. 6. 1. 2. Configuring Spam Filtering in a Mail Delivery Agent
        2. 15. 6. 2. Configuring Antivirus Protection
        3. 15. 6. 3. Using the EPEL Repository to install Antispam and Antivirus Software
      7. 15. 7. Additional Resources Expand section "15. 7. Additional Resources" Collapse section "15. 7. Additional Resources"
        1. 15. 7. 1. Installed Documentation
        2. 15. 7. 2. Online Documentation
        3. 15. 7. 3. Related Books
    3. 16. File and Print Servers Expand section "16. File and Print Servers" Collapse section "16. File and Print Servers"
      1. 16. 1. Samba Expand section "16. 1. Samba" Collapse section "16. 1. Samba"
        1. 16. 1. 1. The Samba Services
        2. 16. 1. 2. Verifying the smb. conf File by Using the testparm Utility
        3. 16. 1. 3. Understanding the Samba Security Modes
        4. 16. 1. 4. Setting up Samba as a Standalone Server Expand section "16. 1. 4. Setting up Samba as a Standalone Server" Collapse section "16. 1. 4. Setting up Samba as a Standalone Server"
          1. 16. 1. 4. 1. Setting up the Server Configuration for the Standalone Server
          2. 16. 1. 4. 2. Creating and Enabling Local User Accounts
        5. 16. 1. 5. Setting up Samba as a Domain Member Expand section "16. 1. 5. Setting up Samba as a Domain Member" Collapse section "16. 1. 5. Setting up Samba as a Domain Member"
          1. 16. 1. 5. 1. Joining a Domain
          2. 16. 1. 5. 2. Verifying That Samba Was Correctly Joined As a Domain Member
          3. 16. 1. 5. 3. Understanding ID Mapping Expand section "16. 1. 5. 3. Understanding ID Mapping" Collapse section "16. 1. 5. 3. Understanding ID Mapping"
            1. 16. 1. 5. 3. 1. Planning ID Ranges
            2. 16. 1. 5. 3. 2. The * Default Domain
          4. 16. 1. 5. 4. The Different ID Mapping Back Ends Expand section "16. 1. 5. 4. The Different ID Mapping Back Ends" Collapse section "16. 1. 5. 4. The Different ID Mapping Back Ends"
            1. 16. 1. 5. 4. 1. Using the tdb ID Mapping Back End
            2. 16. 1. 5. 4. 2. Using the ad ID Mapping Back End
            3. 16. 1. 5. 4. 3. Using the rid ID Mapping Back End
            4. 16. 1. 5. 4. 4. Using the autorid ID Mapping Back End
        6. 16. 1. 6. Configuring File Shares on a Samba Server Expand section "16. 1. 6. Configuring File Shares on a Samba Server" Collapse section "16. 1. 6. Configuring File Shares on a Samba Server"
          1. 16. 1. 6. 1. Setting up a Share That Uses POSIX ACLs Expand section "16. 1. 6. 1. Setting up a Share That Uses POSIX ACLs" Collapse section "16. 1. 6. 1. Setting up a Share That Uses POSIX ACLs"
            1. 16. 1. 6. 1. 1. Adding a Share That Uses POSIX ACLs
            2. 16. 1. 6. 1. 2. Đặt ACL
            3. 16. 1. 6. 1. 3. Setting Permissions on a Share
          2. 16. 1. 6. 2. Setting up a Share That Uses Windows ACLs Expand section "16. 1. 6. 2. Setting up a Share That Uses Windows ACLs" Collapse section "16. 1. 6. 2. Setting up a Share That Uses Windows ACLs"
            1. 16. 1. 6. 2. 1. Granting the SeDiskOperatorPrivilege Privilege
            2. 16. 1. 6. 2. 2. Enabling Windows ACL Support
            3. 16. 1. 6. 2. 3. Adding a Share That Uses Windows ACLs
            4. 16. 1. 6. 2. 4. Managing Share Permissions and File System ACLs of a Share That Uses Windows ACLs
          3. 16. 1. 6. 3. Managing ACLs on an SMB Share Using smbcacls Expand section "16. 1. 6. 3. Managing ACLs on an SMB Share Using smbcacls" Collapse section "16. 1. 6. 3. Managing ACLs on an SMB Share Using smbcacls"
            1. 16. 1. 6. 3. 1. Understanding Access Control Entries
            2. 16. 1. 6. 3. 2. Displaying ACLs Using smbcacls
            3. 16. 1. 6. 3. 3. Calculating an ACE Mask
            4. 16. 1. 6. 3. 4. Adding, Updating, And Removing an ACL Using smbcacls
          4. 16. 1. 6. 4. Enabling Users to Share Directories on a Samba Server Expand section "16. 1. 6. 4. Enabling Users to Share Directories on a Samba Server" Collapse section "16. 1. 6. 4. Enabling Users to Share Directories on a Samba Server"
            1. 16. 1. 6. 4. 1. Enabling the User Shares Feature
            2. 16. 1. 6. 4. 2. Adding a User Share
            3. 16. 1. 6. 4. 3. Updating Settings of a User Share
            4. 16. 1. 6. 4. 4. Displaying Information About Existing User Shares
            5. 16. 1. 6. 4. 5. Listing User Shares
            6. 16. 1. 6. 4. 6. Deleting a User Share
          5. 16. 1. 6. 5. Enabling Guest Access to a Share
        7. 16. 1. 7. Setting up a Samba Print Server Expand section "16. 1. 7. Setting up a Samba Print Server" Collapse section "16. 1. 7. Setting up a Samba Print Server"
          1. 16. 1. 7. 1. The Samba spoolssd Service
          2. 16. 1. 7. 2. Enabling Print Server Support in Samba
          3. 16. 1. 7. 3. Manually Sharing Specific Printers
          4. 16. 1. 7. 4. Thiết lập tải xuống trình điều khiển máy in tự động cho ứng dụng khách Windows Mở rộng phần "16. 1. 7. 4. Thiết lập tải xuống trình điều khiển máy in tự động cho máy khách Windows" Thu gọn phần "16. 1. 7. 4. Setting up Automatic Printer Driver Downloads for Windows Clients"
            1. 16. 1. 7. 4. 1. Basic Information about Printer Drivers
            2. 16. 1. 7. 4. 2. Enabling Users to Upload and Preconfigure Drivers
            3. 16. 1. 7. 4. 3. Setting up the print$ Share
            4. 16. 1. 7. 4. 4. Creating a GPO to Enable Clients to Trust the Samba Print Server
            5. 16. 1. 7. 4. 5. Uploading Drivers and Preconfiguring Printers
        8. 16. 1. 8. Tuning the Performance of a Samba Server Expand section "16. 1. 8. Tuning the Performance of a Samba Server" Collapse section "16. 1. 8. Tuning the Performance of a Samba Server"
          1. 16. 1. 8. 1. Setting the SMB Protocol Version
          2. 16. 1. 8. 2. Tuning Shares with Directories That Contain a Large Number of Files
          3. 16. 1. 8. 3. Cài đặt có thể có tác động tiêu cực đến hiệu suất
        9. 16. 1. 9. Frequently Used Samba Command-line Utilities Expand section "16. 1. 9. Frequently Used Samba Command-line Utilities" Collapse section "16. 1. 9. Frequently Used Samba Command-line Utilities"
          1. 16. 1. 9. 1. Using the net Utility Expand section "16. 1. 9. 1. Using the net Utility" Collapse section "16. 1. 9. 1. Using the net Utility"
            1. 16. 1. 9. 1. 1. Using the net ads join and net rpc join Commands
            2. 16. 1. 9. 1. 2. Using the net rpc rights Command
            3. 16. 1. 9. 1. 3. Using the net rpc share Command
            4. 16. 1. 9. 1. 4. Using the net user Command
            5. 16. 1. 9. 1. 5. Using the net usershare Command
          2. 16. 1. 9. 2. Using the rpcclient Utility
          3. 16. 1. 9. 3. Using the samba-regedit Application
          4. 16. 1. 9. 4. Using the smbcacls Utility
          5. 16. 1. 9. 5. Using the smbclient Utility Expand section "16. 1. 9. 5. Using the smbclient Utility" Collapse section "16. 1. 9. 5. Using the smbclient Utility"
            1. 16. 1. 9. 5. 1. Using smbclient in Interactive Mode
            2. 16. 1. 9. 5. 2. Using smbclient in Scripting Mode
          6. 16. 1. 9. 6. Using the smbcontrol Utility
          7. 16. 1. 9. 7. Using the smbpasswd Utility
          8. 16. 1. 9. 8. Using the smbstatus Utility
          9. 16. 1. 9. 9. Using the smbtar Utility
          10. 16. 1. 9. 10. Using the testparm Utility
          11. 16. 1. 9. 11. Using the wbinfo Utility
        10. 16. 1. 10. Additional Resources
      2. 16. 2. FTP Expand section "16. 2. FTP" Collapse section "16. 2. FTP"
        1. 16. 2. 1. The File Transfer Protocol
        2. 16. 2. 2. The vsftpd Server Expand section "16. 2. 2. The vsftpd Server" Collapse section "16. 2. 2. The vsftpd Server"
          1. 16. 2. 2. 1. Starting and Stopping vsftpd
          2. 16. 2. 2. 2. Starting Multiple Copies of vsftpd
          3. 16. 2. 2. 3. Encrypting vsftpd Connections Using TLS
          4. 16. 2. 2. 4. SELinux Policy for vsftpd
        3. 16. 2. 3. Additional Resources Expand section "16. 2. 3. Additional Resources" Collapse section "16. 2. 3. Additional Resources"
          1. 16. 2. 3. 1. Installed Documentation
          2. 16. 2. 3. 2. Online Documentation
      3. 16. 3. Print Settings Expand section "16. 3. Print Settings" Collapse section "16. 3. Print Settings"
        1. 16. 3. 1. Starting the Print Settings Configuration Tool
        2. 16. 3. 2. Starting Printer Setup
        3. 16. 3. 3. Adding a Local Printer
        4. 16. 3. 4. Adding an AppSocket/HP JetDirect printer
        5. 16. 3. 5. Thêm một máy in IPP
        6. 16. 3. 6. Adding an LPD/LPR Host or Printer
        7. 16. 3. 7. Adding a Samba [SMB] printer
        8. 16. 3. 8. Selecting the Printer Model and Finishing
        9. 16. 3. 9. Printing a Test Page
        10. 16. 3. 10. Modifying Existing Printers Expand section "16. 3. 10. Modifying Existing Printers" Collapse section "16. 3. 10. Modifying Existing Printers"
          1. 16. 3. 10. 1. The Settings Page
          2. 16. 3. 10. 2. The Policies Page Expand section "16. 3. 10. 2. The Policies Page" Collapse section "16. 3. 10. 2. The Policies Page"
            1. 16. 3. 10. 2. 1. Sharing Printers
            2. 16. 3. 10. 2. 2. The Access Control Page
            3. 16. 3. 10. 2. 3. The Printer Options Page
            4. 16. 3. 10. 2. 4. Job Options Page
            5. 16. 3. 10. 2. 5. Ink/Toner Levels Page
          3. 16. 3. 10. 3. Managing Print Jobs
        11. 16. 3. 11. Additional Resources
    4. 17. Database Servers Expand section "17. Database Servers" Collapse section "17. Database Servers"
      1. 17. 1. MariaDB Expand section "17. 1. MariaDB" Collapse section "17. 1. MariaDB"
        1. 17. 1. 1. Installing the MariaDB server Expand section "17. 1. 1. Installing the MariaDB server" Collapse section "17. 1. 1. Installing the MariaDB server"
          1. 17. 1. 1. 1. Improving MariaDB installation security
        2. 17. 1. 2. Configuring the MariaDB server for networking
        3. 17. 1. 3. Backing up MariaDB data Expand section "17. 1. 3. Backing up MariaDB data" Collapse section "17. 1. 3. Backing up MariaDB data"
          1. 17. 1. 3. 1. Logical back up
          2. 17. 1. 3. 2. Physical back up
    5. 18. Configuring NTP Using the chrony Suite Expand section "18. Configuring NTP Using the chrony Suite" Collapse section "18. Configuring NTP Using the chrony Suite"
      1. 18. 1. Introduction to the chrony Suite Expand section "18. 1. Introduction to the chrony Suite" Collapse section "18. 1. Introduction to the chrony Suite"
        1. 18. 1. 1. Differences Between ntpd and chronyd
        2. 18. 1. 2. Choosing Between NTP Daemons
      2. 18. 2. Understanding chrony and Its Configuration Expand section "18. 2. Understanding chrony and Its Configuration" Collapse section "18. 2. Understanding chrony and Its Configuration"
        1. 18. 2. 1. Understanding chronyd and chronyc
        2. 18. 2. 2. Understanding the chrony Configuration Commands
        3. 18. 2. 3. Security with chronyc
      3. 18. 3. Using chrony Expand section "18. 3. Using chrony" Collapse section "18. 3. Using chrony"
        1. 18. 3. 1. Installing chrony
        2. 18. 3. 2. Checking the Status of chronyd
        3. 18. 3. 3. Starting chronyd
        4. 18. 3. 4. Stopping chronyd
        5. 18. 3. 5. Checking if chrony is Synchronized Expand section "18. 3. 5. Checking if chrony is Synchronized" Collapse section "18. 3. 5. Kiểm tra xem thời gian có được Đồng bộ hóa hay không"
          1. 18. 3. 5. 1. Checking chrony Tracking
          2. 18. 3. 5. 2. Checking chrony Sources
          3. 18. 3. 5. 3. Checking chrony Source Statistics
        6. 18. 3. 6. Manually Adjusting the System Clock
      4. 18. 4. Setting Up chrony for Different Environments Expand section "18. 4. Setting Up chrony for Different Environments" Collapse section "18. 4. Setting Up chrony for Different Environments"
        1. 18. 4. 1. Thiết lập đồng hồ bấm giờ cho Hệ thống trong Mạng biệt lập
      5. 18. 5. Using chronyc Expand section "18. 5. Using chronyc" Collapse section "18. 5. Using chronyc"
        1. 18. 5. 1. Using chronyc to Control chronyd
      6. 18. 6. Chrony with HW timestamping Expand section "18. 6. Chrony with HW timestamping" Collapse section "18. 6. Chrony with HW timestamping"
        1. 18. 6. 1. Understanding Hardware Timestamping
        2. 18. 6. 2. Verifying Support for Hardware Timestamping
        3. 18. 6. 3. Enabling Hardware Timestamping
        4. 18. 6. 4. Configuring Client Polling Interval
        5. 18. 6. 5. Enabling Interleaved Mode
        6. 18. 6. 6. Configuring Server for Large Number of Clients
        7. 18. 6. 7. Verifying Hardware Timestamping
        8. 18. 6. 8. Configuring PTP-NTP bridge
      7. 18. 7. Additional Resources Expand section "18. 7. Additional Resources" Collapse section "18. 7. Additional Resources"
        1. 18. 7. 1. Installed Documentation
        2. 18. 7. 2. Tài liệu trực tuyến
    6. 19. Configuring NTP Using ntpd Expand section "19. Configuring NTP Using ntpd" Collapse section "19. Định cấu hình NTP bằng ntpd"
      1. 19. 1. Giới thiệu về NTP
      2. 19. 2. NTP Strata
      3. 19. 3. Understanding NTP
      4. 19. 4. Understanding the Drift File
      5. 19. 5. UTC, Timezones, and DST
      6. 19. 6. Authentication Options for NTP
      7. 19. 7. Managing the Time on Virtual Machines
      8. 19. 8. Understanding Leap Seconds
      9. 19. 9. Understanding the ntpd Configuration File
      10. 19. 10. Understanding the ntpd Sysconfig File
      11. 19. 11. Disabling chrony
      12. 19. 12. Checking if the NTP Daemon is Installed
      13. 19. 13. Installing the NTP Daemon [ntpd]
      14. 19. 14. Checking the Status of NTP
      15. 19. 15. Configure the Firewall to Allow Incoming NTP Packets Expand section "19. 15. Configure the Firewall to Allow Incoming NTP Packets" Collapse section "19. 15. Configure the Firewall to Allow Incoming NTP Packets"
        1. 19. 15. 1. Change the Firewall Settings
        2. 19. 15. 2. Open Ports in the Firewall for NTP Packets
      16. 19. 16. Configure ntpdate Servers
      17. 19. 17. Configure NTP Expand section "19. 17. Định cấu hình NTP" Thu gọn phần "19. 17. Định cấu hình NTP"
        1. 19. 17. 1. Định cấu hình Kiểm soát truy cập cho Dịch vụ NTP
        2. 19. 17. 2. Định cấu hình quyền truy cập giới hạn tốc độ vào dịch vụ NTP
        3. 19. 17. 3. Adding a Peer Address
        4. 19. 17. 4. Thêm địa chỉ máy chủ
        5. 19. 17. 5. Thêm địa chỉ máy chủ phát sóng hoặc phát đa hướng
        6. 19. 17. 6. Adding a Manycast Client Address
        7. 19. 17. 7. Adding a Broadcast Client Address
        8. 19. 17. 8. Adding a Manycast Server Address
        9. 19. 17. 9. Adding a Multicast Client Address
        10. 19. 17. 10. Configuring the Burst Option
        11. 19. 17. 11. Configuring the iburst Option
        12. 19. 17. 12. Configuring Symmetric Authentication Using a Key
        13. 19. 17. 13. Configuring the Poll Interval
        14. 19. 17. 14. Configuring Server Preference
        15. 19. 17. 15. Configuring the Time-to-Live for NTP Packets
        16. 19. 17. 16. Configuring the NTP Version to Use
      18. 19. 18. Configuring the Hardware Clock Update
      19. 19. 19. Configuring Clock Sources
      20. 19. 20. Additional Resources Expand section "19. 20. Additional Resources" Collapse section "19. 20. Additional Resources"
        1. 19. 20. 1. Installed Documentation
        2. 19. 20. 2. Useful Websites
    7. 20. Configuring PTP Using ptp4l Expand section "20. Configuring PTP Using ptp4l" Collapse section "20. Configuring PTP Using ptp4l"
      1. 20. 1. Introduction to PTP Expand section "20. 1. Introduction to PTP" Collapse section "20. 1. Introduction to PTP"
        1. 20. 1. 1. Understanding PTP
        2. 20. 1. 2. Advantages of PTP
      2. 20. 2. Using PTP Expand section "20. 2. Using PTP" Collapse section "20. 2. Using PTP"
        1. 20. 2. 1. Checking for Driver and Hardware Support
        2. 20. 2. 2. Installing PTP
        3. 20. 2. 3. Starting ptp4l Expand section "20. 2. 3. Starting ptp4l" Collapse section "20. 2. 3. Starting ptp4l"
          1. 20. 2. 3. 1. Selecting a Delay Measurement Mechanism
      3. 20. 3. Using PTP with Multiple Interfaces
      4. 20. 4. Chỉ định tệp cấu hình
      5. 20. 5. Using the PTP Management Client
      6. 20. 6. Synchronizing the Clocks
      7. 20. 7. Verifying Time Synchronization
      8. 20. 8. Serving PTP Time with NTP
      9. 20. 9. Serving NTP Time with PTP
      10. 20. 10. Synchronize to PTP or NTP Time Using timemaster Expand section "20. 10. Synchronize to PTP or NTP Time Using timemaster" Collapse section "20. 10. Synchronize to PTP or NTP Time Using timemaster"
        1. 20. 10. 1. Starting timemaster as a Service
        2. 20. 10. 2. Understanding the timemaster Configuration File
        3. 20. 10. 3. Configuring timemaster Options
      11. 20. 11. Improving Accuracy
      12. 20. 12. Additional Resources Expand section "20. 12. Additional Resources" Collapse section "20. 12. Additional Resources"
        1. 20. 12. 1. Installed Documentation
        2. 20. 12. 2. Useful Websites
  • VI. Monitoring and Automation Expand section "VI. Monitoring and Automation" Collapse section "VI. Monitoring and Automation"
    1. 21. Công cụ giám sát hệ thống Mở rộng phần "21. System Monitoring Tools" Collapse section "21. System Monitoring Tools"
      1. 21. 1. Viewing System Processes Expand section "21. 1. Viewing System Processes" Collapse section "21. 1. Viewing System Processes"
        1. 21. 1. 1. Using the ps Command
        2. 21. 1. 2. Using the top Command
        3. 21. 1. 3. Using the System Monitor Tool
      2. 21. 2. Viewing Memory Usage Expand section "21. 2. Viewing Memory Usage" Collapse section "21. 2. Viewing Memory Usage"
        1. 21. 2. 1. Using the free Command
        2. 21. 2. 2. Using the System Monitor Tool
      3. 21. 3. Viewing CPU Usage Expand section "21. 3. Viewing CPU Usage" Collapse section "21. 3. Viewing CPU Usage"
        1. 21. 3. 1. Using the System Monitor Tool
      4. 21. 4. Viewing Block Devices and File Systems Expand section "21. 4. Viewing Block Devices and File Systems" Collapse section "21. 4. Viewing Block Devices and File Systems"
        1. 21. 4. 1. Using the lsblk Command
        2. 21. 4. 2. Using the blkid Command
        3. 21. 4. 3. Using the findmnt Command
        4. 21. 4. 4. Using the df Command
        5. 21. 4. 5. Using the du Command
        6. 21. 4. 6. Using the System Monitor Tool
      5. 21. 5. Viewing Hardware Information Expand section "21. 5. Viewing Hardware Information" Collapse section "21. 5. Viewing Hardware Information"
        1. 21. 5. 1. Using the lspci Command
        2. 21. 5. 2. Using the lsusb Command
        3. 21. 5. 3. Using the lscpu Command
      6. 21. 6. Kiểm tra lỗi phần cứng
      7. 21. 7. Monitoring Performance with Net-SNMP Expand section "21. 7. Monitoring Performance with Net-SNMP" Collapse section "21. 7. Monitoring Performance with Net-SNMP"
        1. 21. 7. 1. Installing Net-SNMP
        2. 21. 7. 2. Running the Net-SNMP Daemon Expand section "21. 7. 2. Running the Net-SNMP Daemon" Collapse section "21. 7. 2. Running the Net-SNMP Daemon"
          1. 21. 7. 2. 1. Starting the Service
          2. 21. 7. 2. 2. Stopping the Service
          3. 21. 7. 2. 3. Restarting the Service
        3. 21. 7. 3. Định cấu hình Net-SNMP Mở rộng phần "21. 7. 3. Configuring Net-SNMP" Collapse section "21. 7. 3. Configuring Net-SNMP"
          1. 21. 7. 3. 1. Setting System Information
          2. 21. 7. 3. 2. Configuring Authentication
        4. 21. 7. 4. Retrieving Performance Data over SNMP Expand section "21. 7. 4. Retrieving Performance Data over SNMP" Collapse section "21. 7. 4. Retrieving Performance Data over SNMP"
          1. 21. 7. 4. 1. Hardware Configuration
          2. 21. 7. 4. 2. CPU and Memory Information
          3. 21. 7. 4. 3. File System and Disk Information
          4. 21. 7. 4. 4. Network Information
        5. 21. 7. 5. Extending Net-SNMP Expand section "21. 7. 5. Extending Net-SNMP" Collapse section "21. 7. 5. Extending Net-SNMP"
          1. 21. 7. 5. 1. Extending Net-SNMP with Shell Scripts
          2. 21. 7. 5. 2. Extending Net-SNMP with Perl
      8. 21. 8. Additional Resources Expand section "21. 8. Additional Resources" Collapse section "21. 8. Additional Resources"
        1. 21. 8. 1. Installed Documentation
    2. 22. OpenLMI Expand section "22. OpenLMI" Collapse section "22. OpenLMI"
      1. 22. 1. About OpenLMI Expand section "22. 1. About OpenLMI" Collapse section "22. 1. About OpenLMI"
        1. 22. 1. 1. Main Features
        2. 22. 1. 2. Management Capabilities
      2. 22. 2. Installing OpenLMI Expand section "22. 2. Installing OpenLMI" Collapse section "22. 2. Installing OpenLMI"
        1. 22. 2. 1. Installing OpenLMI on a Managed System
        2. 22. 2. 2. Installing OpenLMI on a Client System
      3. 22. 3. Configuring SSL Certificates for OpenPegasus Expand section "22. 3. Configuring SSL Certificates for OpenPegasus" Collapse section "22. 3. Configuring SSL Certificates for OpenPegasus"
        1. 22. 3. 1. Managing Self-signed Certificates
        2. 22. 3. 2. Managing Authority-signed Certificates with Identity Management [Recommended]
        3. 22. 3. 3. Managing Authority-signed Certificates Manually
      4. 22. 4. Using LMIShell Expand section "22. 4. Using LMIShell" Collapse section "22. 4. Using LMIShell"
        1. 22. 4. 1. Starting, Using, and Exiting LMIShell
        2. 22. 4. 2. Connecting to a CIMOM
        3. 22. 4. 3. Working with Namespaces
        4. 22. 4. 4. Working with Classes
        5. 22. 4. 5. Working with Instances
        6. 22. 4. 6. Working with Instance Names
        7. 22. 4. 7. Working with Associated Objects
        8. 22. 4. 8. Working with Association Objects
        9. 22. 4. 9. Working with Indications
        10. 22. 4. 10. Example Usage
      5. 22. 5. Using OpenLMI Scripts
      6. 22. 6. Tài nguyên bổ sung
    3. 23. Viewing and Managing Log Files Expand section "23. Viewing and Managing Log Files" Collapse section "23. Viewing and Managing Log Files"
      1. 23. 1. Locating Log Files
      2. 23. 2. Basic Configuration of Rsyslog Expand section "23. 2. Basic Configuration of Rsyslog" Collapse section "23. 2. Basic Configuration of Rsyslog"
        1. 23. 2. 1. Filters
        2. 23. 2. 2. Actions
        3. 23. 2. 3. mẫu
        4. 23. 2. 4. Global Directives
        5. 23. 2. 5. Log Rotation
        6. 23. 2. 6. Increasing the Limit of Open Files
      3. 23. 3. Sử dụng Định dạng Cấu hình Mới Mở rộng phần "23. 3. Using the New Configuration Format" Collapse section "23. 3. Using the New Configuration Format"
        1. 23. 3. 1. Rulesets
        2. 23. 3. 2. Compatibility with sysklogd
      4. 23. 4. Working with Queues in Rsyslog Expand section "23. 4. Working with Queues in Rsyslog" Collapse section "23. 4. Làm việc với Hàng đợi trong Rsyslog"
        1. 23. 4. 1. Defining Queues
        2. 23. 4. 2. Tạo một thư mục mới cho tệp nhật ký rsyslog
        3. 23. 4. 3. Quản lý hàng đợi
        4. 23. 4. 4. Using the New Syntax for rsyslog queues
      5. 23. 5. Định cấu hình rsyslog trên Máy chủ ghi nhật ký Mở rộng phần "23. 5. Định cấu hình rsyslog trên Máy chủ ghi nhật ký" Thu gọn phần "23. 5. Định cấu hình rsyslog trên Máy chủ ghi nhật ký"
        1. 23. 5. 1. Using The New Template Syntax on a Logging Server
      6. 23. 6. Using Rsyslog Modules Expand section "23. 6. Using Rsyslog Modules" Collapse section "23. 6. Sử dụng Mô-đun Rsyslog"
        1. 23. 6. 1. Importing Text Files
        2. 23. 6. 2. Exporting Messages to a Database
        3. 23. 6. 3. Enabling Encrypted Transport
        4. 23. 6. 4. Using RELP
      7. 23. 7. Interaction of Rsyslog and Journal
      8. 23. 8. Structured Logging with Rsyslog Expand section "23. 8. Structured Logging with Rsyslog" Collapse section "23. 8. Structured Logging with Rsyslog"
        1. 23. 8. 1. Importing Data from Journal
        2. 23. 8. 2. Filtering Structured Messages
        3. 23. 8. 3. Parsing JSON
        4. 23. 8. 4. Storing Messages in the MongoDB
      9. 23. 9. Debugging Rsyslog
      10. 23. 10. Using the Journal Expand section "23. 10. Using the Journal" Collapse section "23. 10. Using the Journal"
        1. 23. 10. 1. Viewing Log Files
        2. 23. 10. 2. Access Control
        3. 23. 10. 3. Sử dụng Chế độ xem trực tiếp
        4. 23. 10. 4. Filtering Messages
        5. 23. 10. 5. Kích hoạt lưu trữ liên tục
      11. 23. 11. Quản lý tệp nhật ký trong môi trường đồ họa Mở rộng phần "23. 11. Managing Log Files in a Graphical Environment" Collapse section "23. 11. Managing Log Files in a Graphical Environment"
        1. 23. 11. 1. Viewing Log Files
        2. 23. 11. 2. Thêm tệp nhật ký
        3. 23. 11. 3. Giám sát tệp nhật ký
      12. 23. 12. Additional Resources
    4. 24. Automating System Tasks Expand section "24. Automating System Tasks" Collapse section "24. Automating System Tasks"
      1. 24. 1. Scheduling a Recurring Job Using Cron Expand section "24. 1. Scheduling a Recurring Job Using Cron" Collapse section "24. 1. Scheduling a Recurring Job Using Cron"
        1. 24. 1. 1. Prerequisites for Cron Jobs
        2. 24. 1. 2. Scheduling a Cron Job
      2. 24. 2. Scheduling a Recurring Asynchronous Job Using Anacron Expand section "24. 2. Scheduling a Recurring Asynchronous Job Using Anacron" Collapse section "24. 2. Scheduling a Recurring Asynchronous Job Using Anacron"
        1. 24. 2. 1. Prerequisites for Anacrob Jobs
        2. 24. 2. 2. Scheduling an Anacron Job
      3. 24. 3. Scheduling a Job to Run at a Specific Time Using at Expand section "24. 3. Scheduling a Job to Run at a Specific Time Using at" Collapse section "24. 3. Scheduling a Job to Run at a Specific Time Using at"
        1. 24. 3. 1. Prerequisites for At Jobs
        2. 24. 3. 2. Scheduling an At Job Expand section "24. 3. 2. Scheduling an At Job" Collapse section "24. 3. 2. Lên lịch cho một công việc"
          1. 24. 3. 2. 1. Controlling Access to At and Batch
      4. 24. 4. Scheduling a Job to Run on System Load Drop Using batch Expand section "24. 4. Scheduling a Job to Run on System Load Drop Using batch" Collapse section "24. 4. Scheduling a Job to Run on System Load Drop Using batch"
        1. 24. 4. 1. Prerequisites for Batch Jobs
        2. 24. 4. 2. Scheduling a Batch Job
      5. 24. 5. Scheduling a Job to Run on Next Boot Using a systemd Unit File
      6. 24. 6. Additional Resources
    5. 25. Automatic Bug Reporting Tool [ABRT] Expand section "25. Automatic Bug Reporting Tool [ABRT]" Collapse section "25. Automatic Bug Reporting Tool [ABRT]"
      1. 25. 1. Introduction to ABRT
      2. 25. 2. Installing ABRT and Starting its Services Expand section "25. 2. Installing ABRT and Starting its Services" Collapse section "25. 2. Installing ABRT and Starting its Services"
        1. 25. 2. 1. Installing the ABRT GUI
        2. 25. 2. 2. Installing ABRT for the Command Line
        3. 25. 2. 3. Installing Supplementary ABRT Tools
        4. 25. 2. 4. Starting the ABRT Services
        5. 25. 2. 5. Testing ABRT Crash Detection
      3. 25. 3. Configuring ABRT Expand section "25. 3. Configuring ABRT" Collapse section "25. 3. Configuring ABRT"
        1. 25. 3. 1. Configuring Events
        2. 25. 3. 2. Creating Custom Events
        3. 25. 3. 3. Setting Up Automatic Reporting
      4. 25. 4. Detecting Software Problems Expand section "25. 4. Detecting Software Problems" Collapse section "25. 4. Detecting Software Problems"
        1. 25. 4. 1. Detecting C and C++ Crashes
        2. 25. 4. 2. Detecting Python Exceptions
        3. 25. 4. 3. Detecting Ruby Exceptions
        4. 25. 4. 4. Detecting Java Exceptions
        5. 25. 4. 5. Detecting X. Org Crashes
        6. 25. 4. 6. Detecting Kernel Oopses and Panics
      5. 25. 5. Handling Detected Problems Expand section "25. 5. Xử lý sự cố đã phát hiện" Thu gọn phần "25. 5. Xử lý sự cố đã phát hiện"
        1. 25. 5. 1. Using the Command Line Tool
        2. 25. 5. 2. Using the GUI
      6. 25. 6. Additional Resources
  • VII. Kernel Customization with Bootloader Expand section "VII. Kernel Customization with Bootloader" Collapse section "VII. Kernel Customization with Bootloader"
    1. 26. Working with GRUB 2 Expand section "26. Working with GRUB 2" Collapse section "26. Working with GRUB 2"
      1. 26. 1. Introduction to GRUB 2
      2. 26. 2. Configuring GRUB 2
      3. 26. 3. Making Temporary Changes to a GRUB 2 Menu
      4. 26. 4. Making Persistent Changes to a GRUB 2 Menu Using the grubby Tool
      5. 26. 5. Customizing the GRUB 2 Configuration File Expand section "26. 5. Customizing the GRUB 2 Configuration File" Collapse section "26. 5. Customizing the GRUB 2 Configuration File"
        1. 26. 5. 1. Changing the Default Boot Entry
        2. 26. 5. 2. Editing a Menu Entry
        3. 26. 5. 3. Adding a new Entry
        4. 26. 5. 4. Creating a Custom Menu
      6. 26. 6. Protecting GRUB 2 with a Password
      7. 26. 7. Reinstalling GRUB 2 Expand section "26. 7. Reinstalling GRUB 2" Collapse section "26. 7. Reinstalling GRUB 2"
        1. 26. 7. 1. Reinstalling GRUB 2 on BIOS-Based Machines
        2. 26. 7. 2. Reinstalling GRUB 2 on UEFI-Based Machines
        3. 26. 7. 3. Resetting and Reinstalling GRUB 2
      8. 26. 8. Upgrading from GRUB Legacy to GRUB 2
      9. 26. 9. GRUB 2 over a Serial Console Expand section "26. 9. GRUB 2 over a Serial Console" Collapse section "26. 9. GRUB 2 over a Serial Console"
        1. 26. 9. 1. Configuring GRUB 2 for a single boot
        2. 26. 9. 2. Configuring GRUB 2 for a persistent change
        3. 26. 9. 3. Configuring a new GRUB 2 file
        4. 26. 9. 4. Using screen to Connect to the Serial Console
      10. 26. 10. Terminal Menu Editing During Boot Expand section "26. 10. Terminal Menu Editing During Boot" Collapse section "26. 10. Terminal Menu Editing During Boot"
        1. 26. 10. 1. Booting to Rescue Mode
        2. 26. 10. 2. Booting to Emergency Mode
        3. 26. 10. 3. Booting to the Debug Shell
        4. 26. 10. 4. Changing and Resetting the Root Password
      11. 26. 11. Khởi động an toàn Giao diện phần sụn mở rộng hợp nhất [UEFI] Mở rộng phần "26. 11. Unified Extensible Firmware Interface [UEFI] Secure Boot" Collapse section "26. 11. Unified Extensible Firmware Interface [UEFI] Secure Boot"
        1. 26. 11. 1. UEFI Secure Boot Support in Red Hat Enterprise Linux 7
      12. 26. 12. Additional Resources
  • VIII. System Backup and Recovery Expand section "VIII. System Backup and Recovery" Collapse section "VIII. System Backup and Recovery"
    1. 27. Relax-and-Recover [ReaR] Expand section "27. Relax-and-Recover [ReaR]" Collapse section "27. Relax-and-Recover [ReaR]"
      1. 27. 1. Basic ReaR Usage Expand section "27. 1. Basic ReaR Usage" Collapse section "27. 1. Basic ReaR Usage"
        1. 27. 1. 1. Installing ReaR
        2. 27. 1. 2. Configuring ReaR
        3. 27. 1. 3. Creating a Rescue System
        4. 27. 1. 4. Scheduling ReaR
        5. 27. 1. 5. Performing a System Rescue
      2. 27. 2. Integrating ReaR with Backup Software Expand section "27. 2. Integrating ReaR with Backup Software" Collapse section "27. 2. Integrating ReaR with Backup Software"
        1. 27. 2. 1. The Built-in Backup Method Expand section "27. 2. 1. The Built-in Backup Method" Collapse section "27. 2. 1. The Built-in Backup Method"
          1. 27. 2. 1. 1. Configuring the Internal Backup Method
          2. 27. 2. 1. 2. Creating a Backup Using the Internal Backup Method
        2. 27. 2. 2. Supported Backup Methods
        3. 27. 2. 3. Unsupported Backup Methods
        4. 27. 2. 4. Creating Multiple Backups
    2. 28. Choosing Suitable Red Hat Product
    3. 29. Red Hat Customer Portal Labs Relevant to System Administration
    4. 30. Revision History Expand section "30. Revision History" Collapse section "30. Revision History"
      1. 30. 1. Acknowledgments
  • Settings Đóng
    • Language. Language
      • 日本語
      • 简体中文
      • English
      • Français
    • Format. Format
      • Multi-page
      • Single-page
      • PDF
      • ePub

    Language and Page Formatting Options

    • Language. Language
      • 日本語
      • 简体中文
      • English
      • Français
    • Format. Format
      • Multi-page
      • Single-page
      • PDF
      • ePub

    Red Hat Training

    A Red Hat training course is available for Red Hat Enterprise Linux

    Chapter 10. Managing Services with systemd

    10. 1.  Introduction to systemd

    Systemd là trình quản lý dịch vụ và hệ thống dành cho hệ điều hành Linux. It is designed to be backwards compatible with SysV init scripts, and provides a number of features such as parallel startup of system services at boot time, on-demand activation of daemons, or dependency-based service control logic. In Red Hat Enterprise Linux 7, systemd replaces Upstart as the default init system.

    Systemd introduces the concept of systemd units . These units are represented by unit configuration files located in one of the directories listed in Table 10. 2, “Systemd Unit Files Locations”, and encapsulate information about system services, listening sockets, and other objects that are relevant to the init system. For a complete list of available systemd unit types, see Table 10. 1, “Các loại đơn vị systemd có sẵn”.

    Table 10. 1.  Available systemd Unit Types

    Unit TypeFile ExtensionDescription

    Service unit

    ~]# systemctl stop nfs-server.service
    08

    A system service

    Target unit

    ~]# systemctl stop nfs-server.service
    09

    A group of systemd units

    Automount unit

    ~]# systemctl stop nfs-server.service
    10

    A file system automount point

    Device unit

    ~]# systemctl stop nfs-server.service
    11

    A device file recognized by the kernel

    Mount unit

    ~]# systemctl stop nfs-server.service
    12

    A file system mount point

    Path unit

    ~]# systemctl stop nfs-server.service
    13

    A file or directory in a file system

    Scope unit

    ~]# systemctl stop nfs-server.service
    14

    An externally created process

    Slice unit

    ~]# systemctl stop nfs-server.service
    15

    A group of hierarchically organized units that manage system processes

    Snapshot unit

    ~]# systemctl stop nfs-server.service
    16

    A saved state of the systemd manager

    Socket unit

    ~]# systemctl stop nfs-server.service
    17

    An inter-process communication socket

    Swap unit

    ~]# systemctl stop nfs-server.service
    18

    A swap device or a swap file

    Timer unit

    ~]# systemctl stop nfs-server.service
    19

    A systemd timer

    Table 10. 2.  Systemd Unit Files Locations

    DirectoryDescription

    ~]# systemctl stop nfs-server.service
    20

    Systemd unit files distributed with installed RPM packages

    ~]# systemctl stop nfs-server.service
    21

    Systemd unit files created at run time. This directory takes precedence over the directory with installed service unit files

    ~]# systemctl stop nfs-server.service
    22

    Systemd unit files created by

    ~]# systemctl stop nfs-server.service
    23 as well as unit files added for extending a service. This directory takes precedence over the directory with runtime unit files

    Overriding the Default systemd Configuration Using system. conf

    The default configuration of systemd is defined during the compilation and it can be found in systemd configuration file at

    ~]# systemctl stop nfs-server.service
    24. Use this file if you want to deviate from those defaults and override selected default values for systemd units globally

    For example, to override the default value of the timeout limit, which is set to 90 seconds, use the

    ~]# systemctl stop nfs-server.service
    25 parameter to input the required value in seconds

    ~]# systemctl stop nfs-server.service
    8

    See also Example 10. 21, “Changing the timeout limit”

    10. 1. 1.  Main Features

    In Red Hat Enterprise Linux 7, the systemd system and service manager provides the following main features

    • Socket-based activation — At boot time, systemd creates listening sockets for all system services that support this type of activation, and passes the sockets to these services as soon as they are started. Điều này không chỉ cho phép systemd bắt đầu các dịch vụ song song mà còn cho phép khởi động lại một dịch vụ mà không làm mất bất kỳ tin nhắn nào được gửi tới nó khi nó không khả dụng. the corresponding socket remains accessible and all messages are queued.

      Systemd uses socket units for socket-based activation.

    • Bus-based activation — System services that use D-Bus for inter-process communication can be started on-demand the first time a client application attempts to communicate with them. Systemd uses D-Bus service files for bus-based activation.
    • Device-based activation — System services that support device-based activation can be started on-demand when a particular type of hardware is plugged in or becomes available. Systemd uses device units for device-based activation.
    • Path-based activation — System services that support path-based activation can be started on-demand when a particular file or directory changes its state. Systemd uses path units for path-based activation.
    • Mount and automount point management — Systemd monitors and manages mount and automount points. Systemd uses mount units for mount points and automount units for automount points.
    • Aggressive parallelization — Because of the use of socket-based activation, systemd can start system services in parallel as soon as all listening sockets are in place. In combination with system services that support on-demand activation, parallel activation significantly reduces the time required to boot the system.
    • Transactional unit activation logic — Before activating or deactivating a unit, systemd calculates its dependencies, creates a temporary transaction, and verifies that this transaction is consistent. If a transaction is inconsistent, systemd automatically attempts to correct it and remove non-essential jobs from it before reporting an error.
    • Backwards compatibility with SysV init — Systemd supports SysV init scripts as described in the Linux Standard Base Core Specification , which eases the upgrade path to systemd service units.

    10. 1. 2.  Compatibility Changes

    The systemd system and service manager is designed to be mostly compatible with SysV init and Upstart. The following are the most notable compatibility changes with regards to the previous major release of the Red Hat Enterprise Linux system

    • Systemd has only limited support for runlevels. It provides a number of target units that can be directly mapped to these runlevels and for compatibility reasons, it is also distributed with the earlier

      ~]# systemctl stop nfs-server.service
      26 command. Not all systemd targets can be directly mapped to runlevels, however, and as a consequence, this command might return
      ~]# systemctl stop nfs-server.service
      27 to indicate an unknown runlevel. It is recommended that you avoid using the
      ~]# systemctl stop nfs-server.service
      26 command if possible

      For more information about systemd targets and their comparison with runlevels, see Section 10. 3, “Working with systemd Targets”

    • The

      ~]# systemctl stop nfs-server.service
      29 utility does not support custom commands. In addition to standard commands such as
      ~]# systemctl stop nfs-server.service
      30,
      ~]# systemctl stop nfs-server.service
      31, and
      ~]# systemctl stop nfs-server.service
      32, authors of SysV init scripts could implement support for any number of arbitrary commands in order to provide additional functionality. For example, the init script for
      ~]# systemctl stop nfs-server.service
      33 in Red Hat Enterprise Linux 6 could be executed with the
      ~]# systemctl stop nfs-server.service
      34 command, which immediately enabled panic mode and reconfigured the system to start dropping all incoming and outgoing packets. This is not supported in systemd and the
      ~]# systemctl stop nfs-server.service
      29 only accepts documented commands

      For more information about the

      ~]# systemctl stop nfs-server.service
      29 utility and its comparison with the earlier
      ~]# systemctl stop nfs-server.service
      37 utility, see Section 10. 2, “Managing System Services”

    • The
      ~]# systemctl stop nfs-server.service
      29 utility does not communicate with services that have not been started by systemd. When systemd starts a system service, it stores the ID of its main process in order to keep track of it. The
      ~]# systemctl stop nfs-server.service
      29 utility then uses this PID to query and manage the service. Consequently, if a user starts a particular daemon directly on the command line,
      ~]# systemctl stop nfs-server.service
      29 is unable to determine its current status or stop it
    • Systemd stops only running services. Previously, when the shutdown sequence was initiated, Red Hat Enterprise Linux 6 and earlier releases of the system used symbolic links located in the
      ~]# systemctl stop nfs-server.service
      41 directory to stop all available system services regardless of their status. With systemd, only running services are stopped on shutdown
    • System services are unable to read from the standard input stream. When systemd starts a service, it connects its standard input to
      ~]# systemctl stop nfs-server.service
      42 to prevent any interaction with the user
    • System services do not inherit any context [such as the
      ~]# systemctl stop nfs-server.service
      43 and
      ~]# systemctl stop nfs-server.service
      44 environment variables] from the invoking user and their session. Each service runs in a clean execution context
    • When loading a SysV init script, systemd reads dependency information encoded in the Linux Standard Base [LSB] header and interprets it at run time
    • Tất cả các hoạt động trên các đơn vị dịch vụ phải tuân theo thời gian chờ mặc định là 5 phút để ngăn dịch vụ bị trục trặc đóng băng hệ thống. Giá trị này được mã hóa cứng cho các dịch vụ được tạo từ initscripts và không thể thay đổi. However, individual configuration files can be used to specify a longer timeout value per service, see Example 10. 21, “Changing the timeout limit”

    For a detailed list of compatibility changes introduced with systemd, see the Migration Planning Guide for Red Hat Enterprise Linux 7

    10. 2.  Managing System Services

    Note

    To expand your expertise, you might also be interested in the Red Hat System Administration II [RH134] training course

    Previous versions of Red Hat Enterprise Linux, which were distributed with SysV init or Upstart, used init scripts located in the

    ~]# systemctl stop nfs-server.service
    45 directory. These init scripts were typically written in Bash, and allowed the system administrator to control the state of services and daemons in their system. In Red Hat Enterprise Linux 7, these init scripts have been replaced with service units .

    Service units end with the

    ~]# systemctl stop nfs-server.service
    08 file extension and serve a similar purpose as init scripts. To view, start, stop, restart, enable, or disable system services, use the
    ~]# systemctl stop nfs-server.service
    29 command as described in Table 10. 3, “Comparison of the service Utility with systemctl”, Table 10. 4, “Comparison of the chkconfig Utility with systemctl”, and further in this section. The
    ~]# systemctl stop nfs-server.service
    37 and
    ~]# systemctl stop nfs-server.service
    49 commands are still available in the system and work as expected, but are only included for compatibility reasons and should be avoided

    Table 10. 3.  Comparison of the service Utility with systemctl

    servicesystemctlDescription

    ~]# systemctl stop nfs-server.service
    50

    ~]# systemctl stop nfs-server.service
    51

    Starts a service

    ~]# systemctl stop nfs-server.service
    52

    ~]# systemctl stop nfs-server.service
    53

    Stops a service

    ~]# systemctl stop nfs-server.service
    54

    ~]# systemctl stop nfs-server.service
    55

    Restarts a service

    ~]# systemctl stop nfs-server.service
    56

    ~]# systemctl stop nfs-server.service
    57

    Restarts a service only if it is running

    ~]# systemctl stop nfs-server.service
    58

    ~]# systemctl stop nfs-server.service
    59

    Reloads configuration

    ~]# systemctl stop nfs-server.service
    60

    ~]# systemctl stop nfs-server.service
    61

    ~]# systemctl stop nfs-server.service
    62

    Checks if a service is running

    ~]# systemctl stop nfs-server.service
    63

    ~]# systemctl stop nfs-server.service
    64

    Displays the status of all services

    Table 10. 4.  Comparison of the chkconfig Utility with systemctl

    chkconfigsystemctlDescription

    ~]# systemctl stop nfs-server.service
    65

    ~]# systemctl stop nfs-server.service
    66

    Enables a service

    ~]# systemctl stop nfs-server.service
    67

    ~]# systemctl stop nfs-server.service
    68

    Disables a service

    ~]# systemctl stop nfs-server.service
    69

    ~]# systemctl stop nfs-server.service
    61

    ~]# systemctl stop nfs-server.service
    71

    Checks if a service is enabled

    ~]# systemctl stop nfs-server.service
    72

    ~]# systemctl stop nfs-server.service
    73

    Lists all services and checks if they are enabled

    ~]# systemctl stop nfs-server.service
    72

    ~]# systemctl stop nfs-server.service
    75

    Lists services that are ordered to start before the specified unit

    ~]# systemctl stop nfs-server.service
    72

    ~]# systemctl stop nfs-server.service
    77

    Lists services that are ordered to start after the specified unit

    Specifying Service Units

    For clarity, all command examples in the rest of this section use full unit names with the

    ~]# systemctl stop nfs-server.service
    08 file extension, for example

    ~]# systemctl stop nfs-server.service

    However, the file extension can be omitted, in which case the

    ~]# systemctl stop nfs-server.service
    29 utility assumes the argument is a service unit. The following command is equivalent to the one above

    ~]# systemctl stop nfs-server.service
    4

    Additionally, some units have alias names. Those names can have shorter names than units, which can be used instead of the actual unit names. To find all aliases that can be used for a particular unit, use

    ~]# systemctl stop nfs-server.service
    5

    Behavior of systemctl in a chroot Environment

    If you change the root directory using the

    ~]# systemctl stop nfs-server.service
    80 command, most
    ~]# systemctl stop nfs-server.service
    29 commands refuse to perform any action. The reason for this is that the
    ~]# systemctl stop nfs-server.service
    82 process and the user that used the
    ~]# systemctl stop nfs-server.service
    80 command do not have the same view of the filesystem. This happens, for example, when
    ~]# systemctl stop nfs-server.service
    29 is invoked from a
    ~]# systemctl stop nfs-server.service
    85 file

    The exception to this are unit file commands such as the

    ~]# systemctl stop nfs-server.service
    23 and
    ~]# systemctl stop nfs-server.service
    87 commands. These commands do not need a running system and do not affect running processes, but they do affect unit files. Therefore, you can run these commands even in
    ~]# systemctl stop nfs-server.service
    80 environment. For example, to enable the
    ~]# systemctl stop nfs-server.service
    89 service on a system under the
    ~]# systemctl stop nfs-server.service
    90 directory

    ~]# systemctl stop nfs-server.service
    7

    10. 2. 1.  Listing Services

    To list all currently loaded service units, type the following at a shell prompt

    ~]# systemctl stop nfs-server.service
    8

    Đối với mỗi tệp đơn vị dịch vụ, lệnh này hiển thị tên đầy đủ của nó [

    ~]# systemctl stop nfs-server.service
    91] theo sau là ghi chú liệu tệp đơn vị đã được tải chưa [
    ~]# systemctl stop nfs-server.service
    92], trạng thái kích hoạt tệp đơn vị cấp cao [
    ~]# systemctl stop nfs-server.service
    93] và cấp thấp [
    ~]# systemctl stop nfs-server.service
    94] và

    By default, the

    ~]# systemctl stop nfs-server.service
    96 command displays only active units. If you want to list all loaded units regardless of their state, run this command with the
    ~]# systemctl stop nfs-server.service
    97 or
    ~]# systemctl stop nfs-server.service
    98 command line option

    ~]# systemctl stop nfs-server.service
    7

    You can also list all available service units to see if they are enabled. To do so, type

    ~]# systemctl stop nfs-server.service
    8

    For each service unit, this command displays its full name [

    ~]# systemctl stop nfs-server.service
    99] followed by information whether the service unit is enabled or not [
    ~]# systemctl stop nfs-server.service
    400]. For information on how to determine the status of individual service units, see Section 10. 2. 2, “Displaying Service Status”

    Example 10. 1.  Listing Services

    To list all currently loaded service units, run the following command

    ~]# systemctl stop nfs-server.service
    01

    To list all installed service unit files to determine if they are enabled, type

    ~]# systemctl stop nfs-server.service
    02

    10. 2. 2.  Displaying Service Status

    To display detailed information about a service unit that corresponds to a system service, type the following at a shell prompt

    ~]# systemctl stop nfs-server.service
    0

    Replace name with the name of the service unit you want to inspect [for example,

    ~]# systemctl stop nfs-server.service
    401]. This command displays the name of the selected service unit followed by its short description, one or more fields described in Table 10. 5, “Available Service Unit Information”, and if it is executed by the
    ~]# systemctl stop nfs-server.service
    402 user, also the most recent log entries.

    Table 10. 5.  Available Service Unit Information

    FieldDescription

    ~]# systemctl stop nfs-server.service
    403

    Information whether the service unit has been loaded, the absolute path to the unit file, and a note whether the unit is enabled

    ~]# systemctl stop nfs-server.service
    404

    Information whether the service unit is running followed by a time stamp

    ~]# systemctl stop nfs-server.service
    405

    The PID of the corresponding system service followed by its name

    ~]# systemctl stop nfs-server.service
    406

    Additional information about the corresponding system service

    ~]# systemctl stop nfs-server.service
    407

    Additional information about related processes

    ~]# systemctl stop nfs-server.service
    408

    Additional information about related Control Groups [cgroups]

    To only verify that a particular service unit is running, run the following command

    ~]# systemctl stop nfs-server.service
    1

    Similarly, to determine whether a particular service unit is enabled, type

    ~]# systemctl stop nfs-server.service
    2

    Note that both

    ~]# systemctl stop nfs-server.service
    409 and
    ~]# systemctl stop nfs-server.service
    410 return an exit status of
    ~]# systemctl stop nfs-server.service
    411 if the specified service unit is running or enabled. For information on how to list all currently loaded service units, see Section 10. 2. 1, “Listing Services”

    Example 10. 2.  Displaying Service Status

    The service unit for the GNOME Display Manager is named

    ~]# systemctl stop nfs-server.service
    412. To determine the current status of this service unit, type the following at a shell prompt

    ~]# systemctl stop nfs-server.service
    3

    Example 10. 3.  Displaying Services Ordered to Start Before a Service

    To determine what services are ordered to start before the specified service, type the following at a shell prompt

    ~]# systemctl stop nfs-server.service
    4

    Example 10. 4.  Displaying Services Ordered to Start After a Service

    To determine what services are ordered to start after the specified service, type the following at a shell prompt

    ~]# systemctl stop nfs-server.service
    5

    10. 2. 3.  Starting a Service

    To start a service unit that corresponds to a system service, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    6

    Replace name with the name of the service unit you want to start [for example,

    ~]# systemctl stop nfs-server.service
    401]. This command starts the selected service unit in the current session. For information on how to enable a service unit to be started at boot time, see Section 10. 2. 6, “Enabling a Service”. Để biết thông tin về cách xác định trạng thái của một đơn vị dịch vụ nhất định, hãy xem Phần 10. 2. 2, “Displaying Service Status”.

    Example 10. 5.  Starting a Service

    The service unit for the Apache HTTP Server is named

    ~]# systemctl stop nfs-server.service
    415. To activate this service unit and start the
    ~]# systemctl stop nfs-server.service
    89 daemon in the current session, run the following command as
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    7

    10. 2. 4.  Stopping a Service

    To stop a service unit that corresponds to a system service, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    8

    Replace name with the name of the service unit you want to stop [for example,

    ~]# systemctl stop nfs-server.service
    419]. This command stops the selected service unit in the current session. For information on how to disable a service unit and prevent it from being started at boot time, see Section 10. 2. 7, “Disabling a Service”. For information on how to determine the status of a certain service unit, see Section 10. 2. 2, “Displaying Service Status”.

    Example 10. 6.  Stopping a Service

    The service unit for the

    ~]# systemctl stop nfs-server.service
    420 daemon is named
    ~]# systemctl stop nfs-server.service
    421. To deactivate this service unit and stop the
    ~]# systemctl stop nfs-server.service
    420 daemon in the current session, run the following command as
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    9

    10. 2. 5.  Restarting a Service

    To restart a service unit that corresponds to a system service, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    40

    Replace name with the name of the service unit you want to restart [for example,

    ~]# systemctl stop nfs-server.service
    89]. This command stops the selected service unit in the current session and immediately starts it again. Importantly, if the selected service unit is not running, this command starts it too. To tell systemd to restart a service unit only if the corresponding service is already running, run the following command as
    ~]# systemctl stop nfs-server.service
    402.

    ~]# systemctl stop nfs-server.service
    41

    Certain system services also allow you to reload their configuration without interrupting their execution. To do so, type as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    42

    Note that system services that do not support this feature ignore this command altogether. For convenience, the

    ~]# systemctl stop nfs-server.service
    29 command also supports the
    ~]# systemctl stop nfs-server.service
    429 and
    ~]# systemctl stop nfs-server.service
    430 commands that restart such services instead. For information on how to determine the status of a certain service unit, see Section 10. 2. 2, “Displaying Service Status”

    Example 10. 7.  Restarting a Service

    In order to prevent users from encountering unnecessary error messages or partially rendered web pages, the Apache HTTP Server allows you to edit and reload its configuration without the need to restart it and interrupt actively processed requests. To do so, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    43

    10. 2. 6.  Enabling a Service

    To configure a service unit that corresponds to a system service to be automatically started at boot time, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    44

    Replace name with the name of the service unit you want to enable [for example,

    ~]# systemctl stop nfs-server.service
    89]. This command reads the
    ~]# systemctl stop nfs-server.service
    434 section of the selected service unit and creates appropriate symbolic links to the
    ~]# systemctl stop nfs-server.service
    435 file in the
    ~]# systemctl stop nfs-server.service
    22 directory and its subdirectories. This command does not, however, rewrite links that already exist. If you want to ensure that the symbolic links are re-created, use the following command as
    ~]# systemctl stop nfs-server.service
    402.

    ~]# systemctl stop nfs-server.service
    45

    This command disables the selected service unit and immediately enables it again. For information on how to determine whether a certain service unit is enabled to start at boot time, see Section 10. 2. 2, “Hiển thị trạng thái dịch vụ”. For information on how to start a service in the current session, see Section 10. 2. 3, “Starting a Service”

    Example 10. 8.  Enabling a Service

    To configure the Apache HTTP Server to start automatically at boot time, run the following command as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    46

    10. 2. 7.  Disabling a Service

    To prevent a service unit that corresponds to a system service from being automatically started at boot time, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    47

    Replace name with the name of the service unit you want to disable [for example,

    ~]# systemctl stop nfs-server.service
    419]. This command reads the
    ~]# systemctl stop nfs-server.service
    434 section of the selected service unit and removes appropriate symbolic links to the
    ~]# systemctl stop nfs-server.service
    435 file from the
    ~]# systemctl stop nfs-server.service
    22 directory and its subdirectories. In addition, you can mask any service unit to prevent it from being started manually or by another service. To do so, run the following command as
    ~]# systemctl stop nfs-server.service
    402.

    ~]# systemctl stop nfs-server.service
    48

    This command replaces the

    ~]# systemctl stop nfs-server.service
    445 file with a symbolic link to
    ~]# systemctl stop nfs-server.service
    42, rendering the actual unit file inaccessible to systemd. To revert this action and unmask a service unit, type as
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    49

    For information on how to determine whether a certain service unit is enabled to start at boot time, see Section 10. 2. 2, “Displaying Service Status”. For information on how to stop a service in the current session, see Section 10. 2. 4, “Stopping a Service”

    Example 10. 9.  Disabling a Service

    Example 10. 6, “Stopping a Service” illustrates how to stop the

    ~]# systemctl stop nfs-server.service
    421 unit in the current session. To prevent this service unit from starting at boot time, type the following at a shell prompt as
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    50

    10. 2. 8.  Starting a Conflicting Service

    In systemd , positive and negative dependencies between services exist. Starting particular service may require starting one or more other services [positive dependency] or stopping one or more services [negative dependency].

    When you attempt to start a new service, systemd resolves all dependencies automatically. Note that this is done without explicit notification to the user. If you are already running a service, and you attempt to start another service with a negative dependency, the first service is automatically stopped.

    For example, if you are running the

    ~]# systemctl stop nfs-server.service
    450 service, and you try to start the
    ~]# systemctl stop nfs-server.service
    451 service, systemd first automatically stops
    ~]# systemctl stop nfs-server.service
    450, because these two services are conflicting and cannot run on the same port.

    10. 3.  Working with systemd Targets

    Previous versions of Red Hat Enterprise Linux, which were distributed with SysV init or Upstart, implemented a predefined set of runlevels that represented specific modes of operation. These runlevels were numbered from 0 to 6 and were defined by a selection of system services to be run when a particular runlevel was enabled by the system administrator. In Red Hat Enterprise Linux 7, the concept of runlevels has been replaced with systemd targets .

    Systemd targets are represented by target units . Target units end with the

    ~]# systemctl stop nfs-server.service
    09 file extension and their only purpose is to group together other systemd units through a chain of dependencies. For example, the
    ~]# systemctl stop nfs-server.service
    454 unit, which is used to start a graphical session, starts system services such as the GNOME Display Manager [
    ~]# systemctl stop nfs-server.service
    412] or Accounts Service [
    ~]# systemctl stop nfs-server.service
    456] and also activates the
    ~]# systemctl stop nfs-server.service
    457 unit. Similarly, the
    ~]# systemctl stop nfs-server.service
    457 unit starts other essential system services such as NetworkManager [
    ~]# systemctl stop nfs-server.service
    459] or D-Bus [
    ~]# systemctl stop nfs-server.service
    460] and activates another target unit named
    ~]# systemctl stop nfs-server.service
    461.

    Red Hat Enterprise Linux 7 is distributed with a number of predefined targets that are more or less similar to the standard set of runlevels from the previous releases of this system. For compatibility reasons, it also provides aliases for these targets that directly map them to SysV runlevels. Table 10. 6, “Comparison of SysV Runlevels with systemd Targets” provides a complete list of SysV runlevels and their corresponding systemd targets

    Table 10. 6.  Comparison of SysV Runlevels with systemd Targets

    RunlevelTarget UnitsDescription

    ~]# systemctl stop nfs-server.service
    411

    ~]# systemctl stop nfs-server.service
    463,
    ~]# systemctl stop nfs-server.service
    464

    Shut down and power off the system

    ~]# systemctl stop nfs-server.service
    465

    ~]# systemctl stop nfs-server.service
    466,
    ~]# systemctl stop nfs-server.service
    467

    Set up a rescue shell

    ~]# systemctl stop nfs-server.service
    468

    ~]# systemctl stop nfs-server.service
    469,
    ~]# systemctl stop nfs-server.service
    457

    Set up a non-graphical multi-user system

    ~]# systemctl stop nfs-server.service
    471

    ~]# systemctl stop nfs-server.service
    472,
    ~]# systemctl stop nfs-server.service
    457

    Set up a non-graphical multi-user system

    ~]# systemctl stop nfs-server.service
    474

    ~]# systemctl stop nfs-server.service
    475,
    ~]# systemctl stop nfs-server.service
    457

    Set up a non-graphical multi-user system

    ~]# systemctl stop nfs-server.service
    477

    ~]# systemctl stop nfs-server.service
    478,
    ~]# systemctl stop nfs-server.service
    454

    Set up a graphical multi-user system

    ~]# systemctl stop nfs-server.service
    480

    ~]# systemctl stop nfs-server.service
    481,
    ~]# systemctl stop nfs-server.service
    482

    Shut down and reboot the system

    To view, change, or configure systemd targets, use the

    ~]# systemctl stop nfs-server.service
    29 utility as described in Table 10. 7, “Comparison of SysV init Commands with systemctl” and in the sections below. The
    ~]# systemctl stop nfs-server.service
    26 and
    ~]# systemctl stop nfs-server.service
    485 commands are still available in the system and work as expected, but are only included for compatibility reasons and should be avoided

    Table 10. 7.  Comparison of SysV init Commands with systemctl

    Old CommandNew CommandDescription

    ~]# systemctl stop nfs-server.service
    26

    ~]# systemctl stop nfs-server.service
    487

    Lists currently loaded target units

    ~]# systemctl stop nfs-server.service
    488

    ~]# systemctl stop nfs-server.service
    489

    Changes the current target

    10. 3. 1.  Viewing the Default Target

    To determine which target unit is used by default, run the following command

    ~]# systemctl stop nfs-server.service
    51

    This command resolves the symbolic link located at

    ~]# systemctl stop nfs-server.service
    490 and displays the result. For information on how to change the default target, see Section 10. 3. 3, “Changing the Default Target”. For information on how to list all currently loaded target units, see Section 10. 3. 2, “Viewing the Current Target”

    Example 10. 10.  Viewing the Default Target

    To display the default target unit, type

    ~]# systemctl stop nfs-server.service
    52

    10. 3. 2.  Viewing the Current Target

    To list all currently loaded target units, type the following command at a shell prompt

    ~]# systemctl stop nfs-server.service
    53

    For each target unit, this commands displays its full name [

    ~]# systemctl stop nfs-server.service
    91] followed by a note whether the unit has been loaded [
    ~]# systemctl stop nfs-server.service
    92], its high-level [
    ~]# systemctl stop nfs-server.service
    93] and low-level [
    ~]# systemctl stop nfs-server.service
    94] unit activation state, and a short description [
    ~]# systemctl stop nfs-server.service
    95]

    By default, the

    ~]# systemctl stop nfs-server.service
    96 command displays only active units. If you want to list all loaded units regardless of their state, run this command with the
    ~]# systemctl stop nfs-server.service
    97 or
    ~]# systemctl stop nfs-server.service
    98 command line option

    ~]# systemctl stop nfs-server.service
    54

    See Section 10. 3. 1, “Viewing the Default Target” for information on how to display the default target. For information on how to change the current target, see Section 10. 3. 4, “Changing the Current Target”

    Ví dụ 10. 11.  Viewing the Current Target

    To list all currently loaded target units, run the following command

    ~]# systemctl stop nfs-server.service
    55

    10. 3. 3.  Changing the Default Target

    To configure the system to use a different target unit by default, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    56

    Replace name with the name of the target unit you want to use by default [for example,

    ~]# systemctl stop nfs-server.service
    500]. This command replaces the
    ~]# systemctl stop nfs-server.service
    490 file with a symbolic link to
    ~]# systemctl stop nfs-server.service
    502, where name is the name of the target unit you want to use. For information on how to change the current target, see Section 10. 3. 4, “Changing the Current Target”. For information on how to list all currently loaded target units, see Section 10. 3. 2, “Viewing the Current Target”.

    Example 10. 12.  Changing the Default Target

    To configure the system to use the

    ~]# systemctl stop nfs-server.service
    457 unit by default, run the following command as
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    57

    10. 3. 4.  Changing the Current Target

    To change to a different target unit in the current session, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    58

    Replace name with the name of the target unit you want to use [for example,

    ~]# systemctl stop nfs-server.service
    500]. This command starts the target unit named name and all dependent units, and immediately stops all others. For information on how to change the default target, see Section 10. 3. 3, “Changing the Default Target”. For information on how to list all currently loaded target units, see Section 10. 3. 2, “Viewing the Current Target”.

    Example 10. 13.  Changing the Current Target

    To turn off the graphical user interface and change to the

    ~]# systemctl stop nfs-server.service
    457 unit in the current session, run the following command as
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    59

    10. 3. 5.  Changing to Rescue Mode

    Rescue mode provides a convenient single-user environment and allows you to repair your system in situations when it is unable to complete a regular booting process. In rescue mode, the system attempts to mount all local file systems and start some important system services, but it does not activate network interfaces or allow more users to be logged into the system at the same time. In Red Hat Enterprise Linux 7, rescue mode is equivalent to single user mode and requires the root password.

    To change the current target and enter rescue mode in the current session, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    70

    This command is similar to

    ~]# systemctl stop nfs-server.service
    510, but it also sends an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run this command with the
    ~]# systemctl stop nfs-server.service
    511 command line option

    ~]# systemctl stop nfs-server.service
    71

    For information on how to enter emergency mode, see Section 10. 3. 6, “Changing to Emergency Mode”

    Example 10. 14.  Changing to Rescue Mode

    To enter rescue mode in the current session, run the following command as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    72

    10. 3. 6.  Changing to Emergency Mode

    Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode. Ở chế độ khẩn cấp, hệ thống chỉ gắn hệ thống tệp gốc để đọc, không cố gắn bất kỳ hệ thống tệp cục bộ nào khác, không kích hoạt giao diện mạng và chỉ bắt đầu một vài dịch vụ thiết yếu. In Red Hat Enterprise Linux 7, emergency mode requires the root password.

    To change the current target and enter emergency mode, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    73

    This command is similar to

    ~]# systemctl stop nfs-server.service
    514, but it also sends an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run this command with the
    ~]# systemctl stop nfs-server.service
    511 command line option

    ~]# systemctl stop nfs-server.service
    74

    For information on how to enter rescue mode, see Section 10. 3. 5, “Changing to Rescue Mode”

    Ví dụ 10. 15.  Changing to Emergency Mode

    To enter emergency mode without sending a message to all users that are currently logged into the system, run the following command as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    75

    10. 4.  Shutting Down, Suspending, and Hibernating the System

    In Red Hat Enterprise Linux 7, the

    ~]# systemctl stop nfs-server.service
    29 utility replaces a number of power management commands used in previous versions of the Red Hat Enterprise Linux system. The commands listed in Table 10. 8, “So sánh các lệnh quản lý năng lượng với systemctl” vẫn có sẵn trong hệ thống vì lý do tương thích, nhưng bạn nên sử dụng
    ~]# systemctl stop nfs-server.service
    29 khi có thể

    Bảng 10. 8.  Comparison of Power Management Commands with systemctl

    Old CommandNew CommandDescription

    ~]# systemctl stop nfs-server.service
    519

    ~]# systemctl stop nfs-server.service
    520

    Halts the system

    ~]# systemctl stop nfs-server.service
    521

    ~]# systemctl stop nfs-server.service
    522

    Powers off the system

    ~]# systemctl stop nfs-server.service
    523

    ~]# systemctl stop nfs-server.service
    524

    Khởi động lại hệ thống

    ~]# systemctl stop nfs-server.service
    525

    ~]# systemctl stop nfs-server.service
    526

    Suspends the system

    ~]# systemctl stop nfs-server.service
    527

    ~]# systemctl stop nfs-server.service
    528

    Hibernates the system

    ~]# systemctl stop nfs-server.service
    529

    ~]# systemctl stop nfs-server.service
    530

    Hibernates and suspends the system

    10. 4. 1.  Shutting Down the System

    The

    ~]# systemctl stop nfs-server.service
    29 utility provides commands for shutting down the system, however the traditional
    ~]# systemctl stop nfs-server.service
    532 command is also supported. Although the
    ~]# systemctl stop nfs-server.service
    532 command will call the
    ~]# systemctl stop nfs-server.service
    29 utility to perform the shutdown, it has an advantage in that it also supports a time argument. This is particularly useful for scheduled maintenance and to allow more time for users to react to the warning that a system shutdown has been scheduled. The option to cancel the shutdown can also be an advantage

    Using systemctl Commands

    To shut down the system and power off the machine, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    76

    Để tắt và tạm dừng hệ thống mà không cần tắt nguồn máy, hãy chạy lệnh sau là

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    77

    By default, running either of these commands causes systemd to send an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run the selected command with the

    ~]# systemctl stop nfs-server.service
    511 command line option, for example

    ~]# systemctl stop nfs-server.service
    78Using the shutdown Command

    To shut down the system and power off the machine at a certain time, use a command in the following format as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    79

    Where hh. mm is the time in 24 hour clock format. The

    ~]# systemctl stop nfs-server.service
    539 file is created 5 minutes before system shutdown to prevent new logins. When a time argument is used, an optional message, the wall message , can be appended to the command.

    To shut down and halt the system after a delay, without powering off the machine, use a command in the following format as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    80

    Ở đâu +m là thời gian trễ tính bằng phút. The

    ~]# systemctl stop nfs-server.service
    541 keyword is an alias for
    ~]# systemctl stop nfs-server.service
    542.

    A pending shutdown can be canceled by the

    ~]# systemctl stop nfs-server.service
    402 user as follows

    ~]# systemctl stop nfs-server.service
    81

    See the

    ~]# systemctl stop nfs-server.service
    544 manual page for further command options

    10. 4. 2.  Restarting the System

    To restart the system, run the following command as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    82

    By default, this command causes systemd to send an informative message to all users that are currently logged into the system. To prevent systemd from sending this message, run this command with the

    ~]# systemctl stop nfs-server.service
    511 command line option

    ~]# systemctl stop nfs-server.service
    83

    10. 4. 3.  Suspending the System

    To suspend the system, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    84

    This command saves the system state in RAM and with the exception of the RAM module, powers off most of the devices in the machine. When you turn the machine back on, the system then restores its state from RAM without having to boot again. Because the system state is saved in RAM and not on the hard disk, restoring the system from suspend mode is significantly faster than restoring it from hibernation, but as a consequence, a suspended system state is also vulnerable to power outages

    For information on how to hibernate the system, see Section 10. 4. 4, “Hibernating the System”

    10. 4. 4.  Hibernating the System

    To hibernate the system, type the following at a shell prompt as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    85

    This command saves the system state on the hard disk drive and powers off the machine. When you turn the machine back on, the system then restores its state from the saved data without having to boot again. Because the system state is saved on the hard disk and not in RAM, the machine does not have to maintain electrical power to the RAM module, but as a consequence, restoring the system from hibernation is significantly slower than restoring it from suspend mode

    To hibernate and suspend the system, run the following command as

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    86

    For information on how to suspend the system, see Section 10. 4. 3, “Suspending the System”

    10. 5.  Controlling systemd on a Remote Machine

    In addition to controlling the systemd system and service manager locally, the

    ~]# systemctl stop nfs-server.service
    29 utility also allows you to interact with systemd running on a remote machine over the SSH protocol. Provided that the
    ~]# systemctl stop nfs-server.service
    551 service on the remote machine is running, you can connect to this machine by running the
    ~]# systemctl stop nfs-server.service
    29 command with the
    ~]# systemctl stop nfs-server.service
    553 or
    ~]# systemctl stop nfs-server.service
    554 command line option

    ~]# systemctl stop nfs-server.service
    87

    Replace user_name with the name of the remote user, host_name with the machine’s host name, and

    ~]# systemctl stop nfs-server.service
    555 with any of the
    ~]# systemctl stop nfs-server.service
    29 commands described above. Lưu ý rằng máy từ xa phải được định cấu hình để cho phép người dùng được chọn truy cập từ xa qua giao thức SSH. For more information on how to configure an SSH server, see Chapter 12, OpenSSH.

    Example 10. 16.  Remote Management

    To log in to a remote machine named

    ~]# systemctl stop nfs-server.service
    557 as the
    ~]# systemctl stop nfs-server.service
    402 user and determine the current status of the
    ~]# systemctl stop nfs-server.service
    415 unit, type the following at a shell prompt

    ~]# systemctl stop nfs-server.service
    88

    10. 6.  Creating and Modifying systemd Unit Files

    A unit file contains configuration directives that describe the unit and define its behavior. Several

    ~]# systemctl stop nfs-server.service
    29 commands work with unit files in the background. To make finer adjustments, system administrator must edit or create unit files manually. Table 10. 2, “Systemd Unit Files Locations” lists three main directories where unit files are stored on the system, the
    ~]# systemctl stop nfs-server.service
    22 directory is reserved for unit files created or customized by the system administrator

    Unit file names take the following form

    ~]# systemctl stop nfs-server.service
    89

    Here, unit_name stands for the name of the unit and type_extension identifies the unit type, see Table 10. 1, “Available systemd Unit Types” for a complete list of unit types. For example, there usually is

    ~]# systemctl stop nfs-server.service
    562 as well as
    ~]# systemctl stop nfs-server.service
    563 unit present on your system.

    Unit files can be supplemented with a directory for additional configuration files. For example, to add custom configuration options to

    ~]# systemctl stop nfs-server.service
    562, create the
    ~]# systemctl stop nfs-server.service
    565 file and insert additional directives there. For more information on configuration directories, see Section 10. 6. 4, “Modifying Existing Unit Files”

    Also, the

    ~]# systemctl stop nfs-server.service
    566 and
    ~]# systemctl stop nfs-server.service
    567 directories can be created. These directories contain symbolic links to unit files that are dependencies of the
    ~]# systemctl stop nfs-server.service
    551 service. The symbolic links are automatically created either during installation according to [Install] unit file options [see Table 10. 11, “Important [Install] Section Options”] or at runtime based on [Unit] options [see Table 10. 9, “Important [Unit] Section Options”]. It is also possible to create these directories and symbolic links manually

    Many unit file options can be set using the so called unit specifiers – wildcard strings that are dynamically replaced with unit parameters when the unit file is loaded. This enables creation of generic unit files that serve as templates for generating instantiated units. See Section 10. 6. 5, “Working with Instantiated Units” for details.

    10. 6. 1.  Understanding the Unit File Structure

    Unit files typically consist of three sections

    • [Unit] — contains generic options that are not dependent on the type of the unit. These options provide unit description, specify the unit’s behavior, and set dependencies to other units. For a list of most frequently used [Unit] options, see Table 10. 9, “Important [Unit] Section Options”
    • [ unit type ] — if a unit has type-specific directives, these are grouped under a section named after the unit type. For example, service unit files contain the [Service] section, see Table 10. 10, “Important [Service] Section Options” for most frequently used [Service] options.
    • [Install] — contains information about unit installation used by
      ~]# systemctl stop nfs-server.service
      23 and
      ~]# systemctl stop nfs-server.service
      570 commands, see Table 10. 11, “Important [Install] Section Options” for a list of [Install] options

    Table 10. 9.  Important [Unit] Section Options

    Option[a] section, see the

    ~]# systemctl stop nfs-server.service
    571 manual page. ]Description

    ~]# systemctl stop nfs-server.service
    572

    A meaningful description of the unit. This text is displayed for example in the output of the

    ~]# systemctl stop nfs-server.service
    573 command

    ~]# systemctl stop nfs-server.service
    574

    Provides a list of URIs referencing documentation for the unit

    ~]# systemctl stop nfs-server.service
    575[b]

    Defines the order in which units are started. The unit starts only after the units specified in

    ~]# systemctl stop nfs-server.service
    575 are active. Unlike
    ~]# systemctl stop nfs-server.service
    577,
    ~]# systemctl stop nfs-server.service
    575 does not explicitly activate the specified units. The
    ~]# systemctl stop nfs-server.service
    579 option has the opposite functionality to
    ~]# systemctl stop nfs-server.service
    575

    ~]# systemctl stop nfs-server.service
    577

    Configures dependencies on other units. The units listed in

    ~]# systemctl stop nfs-server.service
    577 are activated together with the unit. If any of the required units fail to start, the unit is not activated

    ~]# systemctl stop nfs-server.service
    583

    Configures weaker dependencies than

    ~]# systemctl stop nfs-server.service
    577. If any of the listed units does not start successfully, it has no impact on the unit activation. This is the recommended way to establish custom unit dependencies

    ~]# systemctl stop nfs-server.service
    585

    Configures negative dependencies, an opposite to

    ~]# systemctl stop nfs-server.service
    577

    [a] For a complete list of options configurable in the [Unit

    [b] In most cases, it is sufficient to set only the ordering dependencies with

    ~]# systemctl stop nfs-server.service
    575 and
    ~]# systemctl stop nfs-server.service
    579 unit file options. If you also set a requirement dependency with
    ~]# systemctl stop nfs-server.service
    583 [recommended] or
    ~]# systemctl stop nfs-server.service
    577, the ordering dependency still needs to be specified. That is because ordering and requirement dependencies work independently from each other

    Table 10. 10.  Important [Service] Section Options

    Option[a] section, see the

    ~]# systemctl stop nfs-server.service
    591 manual page. ]Description

    ~]# systemctl stop nfs-server.service
    592

    Configures the unit process startup type that affects the functionality of

    ~]# systemctl stop nfs-server.service
    593 and related options. Một trong

    *

    ~]# systemctl stop nfs-server.service
    594 – The default value. The process started with
    ~]# systemctl stop nfs-server.service
    593 is the main process of the service

    *

    ~]# systemctl stop nfs-server.service
    596 – The process started with
    ~]# systemctl stop nfs-server.service
    593 spawns a child process that becomes the main process of the service. The parent process exits when the startup is complete

    *

    ~]# systemctl stop nfs-server.service
    598 – This type is similar to
    ~]# systemctl stop nfs-server.service
    594, but the process exits before starting consequent units

    *

    ~]# systemctl stop nfs-server.service
    700 – This type is similar to
    ~]# systemctl stop nfs-server.service
    594, but consequent units are started only after the main process gains a D-Bus name

    *

    ~]# systemctl stop nfs-server.service
    702 – This type is similar to
    ~]# systemctl stop nfs-server.service
    594, but consequent units are started only after a notification message is sent via the sd_notify[] function

    *

    ~]# systemctl stop nfs-server.service
    704 – similar to
    ~]# systemctl stop nfs-server.service
    594, the actual execution of the service binary is delayed until all jobs are finished, which avoids mixing the status output with shell output of services

    ~]# systemctl stop nfs-server.service
    593

    Specifies commands or scripts to be executed when the unit is started.

    ~]# systemctl stop nfs-server.service
    707 and
    ~]# systemctl stop nfs-server.service
    708 specify custom commands to be executed before and after
    ~]# systemctl stop nfs-server.service
    593.
    ~]# systemctl stop nfs-server.service
    710 enables specifying multiple custom commands that are then executed sequentially

    ~]# systemctl stop nfs-server.service
    711

    Specifies commands or scripts to be executed when the unit is stopped

    ~]# systemctl stop nfs-server.service
    712

    Specifies commands or scripts to be executed when the unit is reloaded

    ~]# systemctl stop nfs-server.service
    713

    With this option enabled, the service is restarted after its process exits, with the exception of a clean stop by the

    ~]# systemctl stop nfs-server.service
    29 command

    ~]# systemctl stop nfs-server.service
    715

    If set to True, the service is considered active even when all its processes exited. Default value is False. This option is especially useful if

    ~]# systemctl stop nfs-server.service
    710 is configured

    [a] For a complete list of options configurable in the [Service

    Table 10. 11.  Important [Install] Section Options

    Option[a] section, see the

    ~]# systemctl stop nfs-server.service
    571 manual page. ]Description

    ~]# systemctl stop nfs-server.service
    718

    Provides a space-separated list of additional names for the unit. Most

    ~]# systemctl stop nfs-server.service
    29 commands, excluding
    ~]# systemctl stop nfs-server.service
    23, can use aliases instead of the actual unit name

    ~]# systemctl stop nfs-server.service
    721

    A list of units that depend on the unit. When this unit is enabled, the units listed in

    ~]# systemctl stop nfs-server.service
    721 gain a
    ~]# systemctl stop nfs-server.service
    723 dependency on the unit

    ~]# systemctl stop nfs-server.service
    724

    A list of units that weakly depend on the unit. Khi thiết bị này được bật, các thiết bị được liệt kê trong

    ~]# systemctl stop nfs-server.service
    724 sẽ nhận được sự phụ thuộc của
    ~]# systemctl stop nfs-server.service
    726 vào thiết bị

    ~]# systemctl stop nfs-server.service
    727

    Specifies a list of units to be installed or uninstalled along with the unit

    ~]# systemctl stop nfs-server.service
    728

    Limited to instantiated units, this option specifies the default instance for which the unit is enabled. See Section 10. 6. 5, “Working with Instantiated Units”

    [a] For a complete list of options configurable in the [Install

    A whole range of options that can be used to fine tune the unit configuration, Example 10. 17, “postfix. service Unit File” shows an example of a service unit installed on the system. Moreover, unit file options can be defined in a way that enables dynamic creation of units as described in Section 10. 6. 5, “Working with Instantiated Units”

    Example 10. 17.  postfix. service Unit File

    What follows is the content of the

    ~]# systemctl stop nfs-server.service
    729 unit file as currently provided by the postfix package.

    ~]# systemctl stop nfs-server.service
    70

    The [Unit] section describes the service, specifies the ordering dependencies, as well as conflicting units. In [Service], a sequence of custom scripts is specified to be executed during unit activation, on stop, and on reload.

    ~]# systemctl stop nfs-server.service
    730 points to the location where environment variables for the service are defined,
    ~]# systemctl stop nfs-server.service
    731 specifies a stable PID for the main process of the service. Finally, the [Install] section lists units that depend on the service

    10. 6. 2.  Creating Custom Unit Files

    There are several use cases for creating unit files from scratch. you could run a custom daemon, create a second instance of some existing service [as in Example 10. 19, “Creating a second instance of the sshd service”], or import a SysV init script [more in Section 10. 6. 3, “Converting SysV Init Scripts to Unit Files”]. On the other hand, if you intend just to modify or extend the behavior of an existing unit, use the instructions from Section 10. 6. 4, “Modifying Existing Unit Files”. The following procedure describes the general process of creating a custom service

    1. Prepare the executable file with the custom service. This can be a custom-created script, or an executable delivered by a software provider. If required, prepare a PID file to hold a constant PID for the main process of the custom service. It is also possible to include environment files to store shell variables for the service. Make sure the source script is executable [by executing the
      ~]# systemctl stop nfs-server.service
      732] and is not interactive
    2. Create a unit file in the

      ~]# systemctl stop nfs-server.service
      22 directory and make sure it has correct file permissions. Execute as
      ~]# systemctl stop nfs-server.service
      402

      ~]# systemctl stop nfs-server.service
      71

      Replace name with a name of the service to be created. Note that file does not need to be executable.

    3. Open the

      ~]# systemctl stop nfs-server.service
      735 file created in the previous step, and add the service configuration options. There is a variety of options that can be used depending on the type of service you wish to create, see Section 10. 6. 1, “Understanding the Unit File Structure”. The following is an example unit configuration for a network-related service

      ~]# systemctl stop nfs-server.service
      72

      Where

      • service_description is an informative description that is displayed in journal log files and in the output of the
        ~]# systemctl stop nfs-server.service
        573 command.
      • the
        ~]# systemctl stop nfs-server.service
        575 setting ensures that the service is started only after the network is running. Add a space-separated list of other relevant services or targets
      • path_to_executable stands for the path to the actual service executable.
      • ~]# systemctl stop nfs-server.service
        738 được sử dụng cho các daemon thực hiện lệnh gọi hệ thống fork. The main process of the service is created with the PID specified in path_to_pidfile . Find other startup types in Table 10. 10, “Important [Service] Section Options”.
      • ~]# systemctl stop nfs-server.service
        724 states the target or targets that the service should be started under. Think of these targets as of a replacement of the older concept of runlevels, see Section 10. 3, “Working with systemd Targets” for details

    4. Notify systemd that a new

      ~]# systemctl stop nfs-server.service
      735 file exists by executing the following command as
      ~]# systemctl stop nfs-server.service
      402

      ~]# systemctl stop nfs-server.service
      73

      Warning

      Always run the

      ~]# systemctl stop nfs-server.service
      742 command after creating new unit files or modifying existing unit files. Otherwise, the
      ~]# systemctl stop nfs-server.service
      743 or
      ~]# systemctl stop nfs-server.service
      23 commands could fail due to a mismatch between states of systemd and actual service unit files on disk

      The name . service unit can now be managed as any other system service with commands described in Section 10. 2, “Managing System Services”.

    Example 10. 18.  Creating the emacs. service File

    When using the Emacs text editor, it is often faster and more convenient to have it running in the background instead of starting a new instance of the program whenever editing a file. The following steps show how to create a unit file for Emacs, so that it can be handled like a service.

    1. Create a unit file in the

      ~]# systemctl stop nfs-server.service
      22 directory and make sure it has the correct file permissions. Execute as
      ~]# systemctl stop nfs-server.service
      402

      ~]# systemctl stop nfs-server.service
      74
    2. Add the following content to the file

      ~]# systemctl stop nfs-server.service
      75

      With the above configuration, the

      ~]# systemctl stop nfs-server.service
      747 executable is started in daemon mode on service start. The SSH_AUTH_SOCK environment variable is set using the "%t" unit specifier that stands for the runtime directory. The service also restarts the emacs process if it exits unexpectedly

    3. Execute the following commands to reload the configuration and start the custom service

      ~]# systemctl stop nfs-server.service
      76

    As the editor is now registered as a systemd service, you can use all standard

    ~]# systemctl stop nfs-server.service
    29 commands. For example, run
    ~]# systemctl stop nfs-server.service
    749 to display the editor’s status or
    ~]# systemctl stop nfs-server.service
    750 to make the editor start automatically on system boot

    Example 10. 19.  Creating a second instance of the sshd service

    System Administrators often need to configure and run multiple instances of a service. This is done by creating copies of the original service configuration files and modifying certain parameters to avoid conflicts with the primary instance of the service. The following procedure shows how to create a second instance of the

    ~]# systemctl stop nfs-server.service
    551 service

    1. Create a copy of the

      ~]# systemctl stop nfs-server.service
      752 file that will be used by the second daemon

      ~]# systemctl stop nfs-server.service
      77
    2. Edit the

      ~]# systemctl stop nfs-server.service
      753 file created in the previous step to assign a different port number and PID file to the second daemon

      ~]# systemctl stop nfs-server.service
      78

      See the

      ~]# systemctl stop nfs-server.service
      752[5] manual page for more information on
      ~]# systemctl stop nfs-server.service
      755 and
      ~]# systemctl stop nfs-server.service
      756 options. Make sure the port you choose is not in use by any other service. The PID file does not have to exist before running the service, it is generated automatically on service start

    3. Tạo một bản sao của tệp đơn vị systemd cho dịch vụ

      ~]# systemctl stop nfs-server.service
      551

      ~]# systemctl stop nfs-server.service
      79
    4. Alter the

      ~]# systemctl stop nfs-server.service
      758 created in the previous step as follows

      1. Modify the

        ~]# systemctl stop nfs-server.service
        572 option

        ~]# systemctl stop nfs-server.service
        80
      2. Add sshd. service to services specified in the

        ~]# systemctl stop nfs-server.service
        575 option, so that the second instance starts only after the first one has already started

        ~]# systemctl stop nfs-server.service
        81
      3. The first instance of sshd includes key generation, therefore remove the ExecStartPre=/usr/sbin/sshd-keygen line.
      4. Add the

        ~]# systemctl stop nfs-server.service
        761 parameter to the
        ~]# systemctl stop nfs-server.service
        551 command, so that the alternative configuration file is used

        ~]# systemctl stop nfs-server.service
        82
      5. After the above modifications, the sshd-second. service should look as follows

        ~]# systemctl stop nfs-server.service
        83

    5. If using SELinux, add the port for the second instance of sshd to SSH ports, otherwise the second instance of sshd will be rejected to bind to the port

      ~]# systemctl stop nfs-server.service
      84
    6. Enable sshd-second. service, so that it starts automatically upon boot

      ~]# systemctl stop nfs-server.service
      85

      Verify if the sshd-second. service is running by using the

      ~]# systemctl stop nfs-server.service
      573 command. Also, verify if the port is enabled correctly by connecting to the service

      ~]# systemctl stop nfs-server.service
      86

      If the firewall is in use, make sure that it is configured appropriately in order to allow connections to the second instance of sshd

    To learn how to properly choose a target for ordering and dependencies of your custom unit files, see the following articles

    • How to write a service unit file which enforces that particular services have to be started
    • How to decide what dependencies a systemd service unit definition should have

    Additional information with some real-world examples of cases triggered by the ordering and dependencies in a unit file is available in the following article. Is there any useful information about writing unit files?

    If you want to set limits for services started by

    ~]# systemctl stop nfs-server.service
    82, see the Red Hat Knowledgebase article How to set limits for services in RHEL 7 and systemd. These limits need to be set in the service’s unit file. Note that
    ~]# systemctl stop nfs-server.service
    82 ignores limits set in the
    ~]# systemctl stop nfs-server.service
    766 and
    ~]# systemctl stop nfs-server.service
    767 configuration files. The limits defined in these files are set by PAM when starting a login session, but daemons started by
    ~]# systemctl stop nfs-server.service
    82 do not use PAM login sessions

    10. 6. 3.  Converting SysV Init Scripts to Unit Files

    Before taking time to convert a SysV init script to a unit file, make sure that the conversion was not already done elsewhere. All core services installed on Red Hat Enterprise Linux 7 come with default unit files, and the same applies for many third-party software packages

    Converting an init script to a unit file requires analyzing the script and extracting the necessary information from it. Based on this data you can create a unit file as described in Section 10. 6. 2, “Creating Custom Unit Files”. As init scripts can vary greatly depending on the type of the service, you might need to employ more configuration options for translation than outlined in this chapter. Note that some levels of customization that were available with init scripts are no longer supported by systemd units, see Section 10. 1. 2, “Compatibility Changes”

    The majority of information needed for conversion is provided in the script’s header. The following example shows the opening section of the init script used to start the

    ~]# systemctl stop nfs-server.service
    450 service on Red Hat Enterprise Linux 6

    ~]# systemctl stop nfs-server.service
    87

    In the above example, only lines starting with # chkconfig and # description are mandatory, so you might not find the rest in different init files. The text enclosed between the # BEGIN INIT INFO and # END INIT INFO lines is called Linux Standard Base [LSB] header . If specified, LSB headers contain directives defining the service description, dependencies, and default runlevels. What follows is an overview of analytic tasks aiming to collect the data needed for a new unit file. The postfix init script is used as an example, see the resulting postfix unit file in Example 10. 17, “postfix. service Unit File”.

    Finding the Service Description

    Find descriptive information about the script on the line starting with #description . Use this description together with the service name in the

    ~]# systemctl stop nfs-server.service
    572 option in the [Unit] section of the unit file. The LSB header might contain similar data on the #Short-Description and #Description lines.

    Finding Service Dependencies

    The LSB header might contain several directives that form dependencies between services. Most of them are translatable to systemd unit options, see Table 10. 12, “Dependency Options from the LSB Header”

    Table 10. 12.  Dependency Options from the LSB Header

    LSB OptionDescriptionUnit File Equivalent

    ~]# systemctl stop nfs-server.service
    771

    Specifies the boot facility name of the service, that can be referenced in other init scripts [with the "$" prefix]. This is no longer needed as unit files refer to other units by their file names

    ~]# systemctl stop nfs-server.service
    772

    Contains boot facility names of required services. This is translated as an ordering dependency, boot facility names are replaced with unit file names of corresponding services or targets they belong to. For example, in case of

    ~]# systemctl stop nfs-server.service
    450, the Required-Start dependency on $network was translated to the After dependency on network. target

    ~]# systemctl stop nfs-server.service
    575,
    ~]# systemctl stop nfs-server.service
    579

    ~]# systemctl stop nfs-server.service
    776

    Constitutes weaker dependencies than Required-Start. Failed Should-Start dependencies do not affect the service startup

    ~]# systemctl stop nfs-server.service
    575,
    ~]# systemctl stop nfs-server.service
    579

    ~]# systemctl stop nfs-server.service
    779,
    ~]# systemctl stop nfs-server.service
    780

    Constitute negative dependencies

    ~]# systemctl stop nfs-server.service
    585

    Finding Default Targets of the Service

    The line starting with #chkconfig contains three numerical values. Điều quan trọng nhất là số đầu tiên đại diện cho mức chạy mặc định trong đó dịch vụ được bắt đầu. Use Table 10. 6, “Comparison of SysV Runlevels with systemd Targets” to map these runlevels to equivalent systemd targets. Then list these targets in the

    ~]# systemctl stop nfs-server.service
    724 option in the [Install] section of the unit file. For example,
    ~]# systemctl stop nfs-server.service
    450 was previously started in runlevels 2, 3, 4, and 5, which translates to multi-user. target and graphical. target on Red Hat Enterprise Linux 7. Note that the graphical. target depends on multiuser. target, therefore it is not necessary to specify both, as in Example 10. 17, “postfix. service Unit File”. You might find information on default and forbidden runlevels also at #Default-Start and #Default-Stop lines in the LSB header.

    The other two values specified on the #chkconfig line represent startup and shutdown priorities of the init script. These values are interpreted by systemd if it loads the init script, but there is no unit file equivalent

    Finding Files Used by the Service

    Init scripts require loading a function library from a dedicated directory and allow importing configuration, environment, and PID files. Environment variables are specified on the line starting with #config in the init script header, which translates to the

    ~]# systemctl stop nfs-server.service
    730 unit file option. The PID file specified on the #pidfile init script line is imported to the unit file with the
    ~]# systemctl stop nfs-server.service
    731 option.

    The key information that is not included in the init script header is the path to the service executable, and potentially some other files required by the service. In previous versions of Red Hat Enterprise Linux, init scripts used a Bash case statement to define the behavior of the service on default actions, such as start , stop , or restart , as well as custom-defined actions. The following excerpt from the

    ~]# systemctl stop nfs-server.service
    450 init script shows the block of code to be executed at service start.

    ~]# systemctl stop nfs-server.service
    88

    The extensibility of the init script allowed specifying two custom functions,

    ~]# systemctl stop nfs-server.service
    787 and
    ~]# systemctl stop nfs-server.service
    788, that are called from the
    ~]# systemctl stop nfs-server.service
    789 function block. On closer look, several external files and directories are mentioned in the above code. the main service executable
    ~]# systemctl stop nfs-server.service
    790, the
    ~]# systemctl stop nfs-server.service
    791 and
    ~]# systemctl stop nfs-server.service
    792 configuration directories, as well as the
    ~]# systemctl stop nfs-server.service
    793 directory

    Systemd supports only the predefined actions, but enables executing custom executables with

    ~]# systemctl stop nfs-server.service
    593,
    ~]# systemctl stop nfs-server.service
    707,
    ~]# systemctl stop nfs-server.service
    708,
    ~]# systemctl stop nfs-server.service
    711, and
    ~]# systemctl stop nfs-server.service
    712 options. In case of
    ~]# systemctl stop nfs-server.service
    450 on Red Hat Enterprise Linux 7, the
    ~]# systemctl stop nfs-server.service
    790 together with supporting scripts are executed on service start. Consult the
    ~]# systemctl stop nfs-server.service
    450 unit file at Example 10. 17, “postfix. dịch vụ Tập tin đơn vị”

    Chuyển đổi các tập lệnh init phức tạp đòi hỏi phải hiểu mục đích của mọi câu lệnh trong tập lệnh. Một số câu lệnh dành riêng cho phiên bản hệ điều hành, do đó bạn không cần phải dịch chúng. Mặt khác, một số điều chỉnh có thể cần thiết trong môi trường mới, cả trong tệp đơn vị cũng như trong các tệp hỗ trợ và thực thi dịch vụ

    10. 6. 4. Sửa đổi tập tin đơn vị hiện có

    Các dịch vụ được cài đặt trên hệ thống đi kèm với các tệp đơn vị mặc định được lưu trữ trong thư mục

    ~]# systemctl stop nfs-server.service
    20. Quản trị viên hệ thống không nên trực tiếp sửa đổi các tệp này, do đó mọi tùy chỉnh phải được giới hạn trong các tệp cấu hình trong thư mục
    ~]# systemctl stop nfs-server.service
    22. Tùy thuộc vào mức độ thay đổi cần thiết, hãy chọn một trong các phương pháp sau

    • Tạo một thư mục cho các tệp cấu hình bổ sung tại
      ~]# systemctl stop nfs-server.service
      804. Phương pháp này được khuyến nghị cho hầu hết các trường hợp sử dụng. Nó cho phép mở rộng cấu hình mặc định với chức năng bổ sung, trong khi vẫn tham chiếu đến tệp đơn vị gốc. Do đó, các thay đổi đối với đơn vị mặc định được giới thiệu khi nâng cấp gói được áp dụng tự động. Xem phần có tên “Mở rộng Cấu hình Đơn vị Mặc định” để biết thêm thông tin
    • Create a copy of the original unit file
      ~]# systemctl stop nfs-server.service
      20 in
      ~]# systemctl stop nfs-server.service
      22 and make changes there. Bản sao sẽ ghi đè tệp gốc, do đó, những thay đổi được đưa ra với bản cập nhật gói không được áp dụng. Phương pháp này hữu ích để thực hiện các thay đổi đơn vị quan trọng sẽ tồn tại bất kể các bản cập nhật gói. Xem phần có tên “Ghi đè Cấu hình Đơn vị Mặc định” để biết chi tiết

    Để quay lại cấu hình mặc định của thiết bị, chỉ cần xóa các tệp cấu hình được tạo tùy chỉnh trong

    ~]# systemctl stop nfs-server.service
    22. Để áp dụng các thay đổi cho các tệp đơn vị mà không cần khởi động lại hệ thống, hãy thực thi

    ~]# systemctl stop nfs-server.service
    89

    Tùy chọn

    ~]# systemctl stop nfs-server.service
    808 tải lại tất cả các tệp đơn vị và tạo lại toàn bộ cây phụ thuộc, cần thiết để áp dụng ngay bất kỳ thay đổi nào đối với tệp đơn vị. Thay vào đó, bạn có thể đạt được kết quả tương tự bằng lệnh sau

    ~]# systemctl stop nfs-server.service
    010

    Ngoài ra, nếu tệp đơn vị đã sửa đổi thuộc về một dịch vụ đang chạy, dịch vụ này phải được khởi động lại để chấp nhận cài đặt mới

    ~]# systemctl stop nfs-server.service
    40

    Quan trọng

    Để sửa đổi các thuộc tính, chẳng hạn như phần phụ thuộc hoặc thời gian chờ, của một dịch vụ được xử lý bởi bản initscript SysV, không sửa đổi chính bản initscript đó. Thay vào đó, hãy tạo tệp cấu hình thả xuống

    ~]# systemctl stop nfs-server.service
    82 cho dịch vụ như được mô tả trong phần có tên “Mở rộng cấu hình đơn vị mặc định” và phần có tên “Ghi đè cấu hình đơn vị mặc định”. Sau đó, quản lý dịch vụ này giống như dịch vụ
    ~]# systemctl stop nfs-server.service
    82 bình thường

    Ví dụ: để mở rộng cấu hình của dịch vụ

    ~]# systemctl stop nfs-server.service
    811, không sửa đổi tệp initscript
    ~]# systemctl stop nfs-server.service
    812. Thay vào đó, hãy tạo thư mục mới
    ~]# systemctl stop nfs-server.service
    813 và tệp thả xuống
    ~]# systemctl stop nfs-server.service
    82
    ~]# systemctl stop nfs-server.service
    815. Sau đó, đặt các giá trị đã sửa đổi vào tệp thả vào. Ghi chú.
    ~]# systemctl stop nfs-server.service
    82 biết dịch vụ
    ~]# systemctl stop nfs-server.service
    811 là
    ~]# systemctl stop nfs-server.service
    818, đó là lý do tại sao thư mục được tạo phải được gọi là
    ~]# systemctl stop nfs-server.service
    819

    Mở rộng cấu hình đơn vị mặc định

    Để mở rộng tệp đơn vị mặc định với các tùy chọn cấu hình bổ sung, trước tiên hãy tạo một thư mục cấu hình trong

    ~]# systemctl stop nfs-server.service
    22. If extending a service unit, execute the following command as
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    012

    Thay thế tên bằng tên của dịch vụ bạn muốn gia hạn. Cú pháp trên áp dụng cho tất cả các loại đơn vị.

    Tạo tệp cấu hình trong thư mục đã tạo ở bước trước. Lưu ý rằng tên tệp phải kết thúc bằng . conf hậu tố. Loại hình.

    ~]# systemctl stop nfs-server.service
    013

    Thay thế config_name bằng tên của tệp cấu hình. Tệp này tuân thủ cấu trúc tệp đơn vị bình thường, do đó, tất cả các lệnh phải được chỉ định trong các phần thích hợp, hãy xem Phần 10. 6. 1, “Tìm hiểu cấu trúc tệp đơn vị”.

    Ví dụ: để thêm phụ thuộc tùy chỉnh, hãy tạo tệp cấu hình với nội dung sau

    ~]# systemctl stop nfs-server.service
    014

    Ở đâu phần phụ thuộc mới là viết tắt của đơn vị được đánh dấu là phần phụ thuộc. Một ví dụ khác là tệp cấu hình khởi động lại dịch vụ sau khi quá trình chính của nó đã thoát, với độ trễ là 30 giây.

    ~]# systemctl stop nfs-server.service
    015

    Nên tạo các tệp cấu hình nhỏ chỉ tập trung vào một tác vụ. Các tệp như vậy có thể dễ dàng di chuyển hoặc liên kết với các thư mục cấu hình của các dịch vụ khác

    Để áp dụng các thay đổi được thực hiện cho đơn vị, hãy thực hiện như

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    016

    Ví dụ 10. 20. Mở rộng httpd. cấu hình dịch vụ

    Để sửa đổi httpd. đơn vị dịch vụ để tập lệnh shell tùy chỉnh được thực thi tự động khi khởi động dịch vụ Apache, hãy thực hiện các bước sau. Đầu tiên, tạo một thư mục và tệp cấu hình tùy chỉnh

    ~]# systemctl stop nfs-server.service
    017

    Với điều kiện là tập lệnh bạn muốn bắt đầu tự động với Apache được đặt tại

    ~]# systemctl stop nfs-server.service
    823, hãy chèn văn bản sau vào tệp
    ~]# systemctl stop nfs-server.service
    824

    ~]# systemctl stop nfs-server.service
    018

    Để áp dụng các thay đổi đơn vị, hãy thực hiện

    ~]# systemctl stop nfs-server.service
    019

    Note

    Các tệp cấu hình từ các thư mục cấu hình trong

    ~]# systemctl stop nfs-server.service
    22 được ưu tiên hơn các tệp đơn vị trong
    ~]# systemctl stop nfs-server.service
    20. Do đó, nếu các tệp cấu hình chứa một tùy chọn chỉ có thể được chỉ định một lần, chẳng hạn như
    ~]# systemctl stop nfs-server.service
    572 hoặc
    ~]# systemctl stop nfs-server.service
    593, thì giá trị mặc định của tùy chọn này sẽ bị ghi đè. Lưu ý rằng trong đầu ra của lệnh
    ~]# systemctl stop nfs-server.service
    829, được mô tả trong phần có tên "Đơn vị được ghi đè theo dõi", các đơn vị đó luôn được đánh dấu là [ĐÃ MỞ RỘNG], mặc dù về tổng thể, một số tùy chọn nhất định thực sự bị ghi đè

    Overriding the Default Unit Configuration

    Để thực hiện các thay đổi sẽ tồn tại sau khi cập nhật gói cung cấp tệp đơn vị, trước tiên hãy sao chép tệp vào thư mục

    ~]# systemctl stop nfs-server.service
    22. Để làm như vậy, hãy thực hiện lệnh sau như
    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    020

    Ở đâu tên là tên của đơn vị dịch vụ mà bạn muốn sửa đổi. Cú pháp trên áp dụng cho tất cả các loại đơn vị.

    Mở tệp đã sao chép bằng trình soạn thảo văn bản và thực hiện các thay đổi mong muốn. Để áp dụng các thay đổi đơn vị, hãy thực hiện như

    ~]# systemctl stop nfs-server.service
    402

    ~]# systemctl stop nfs-server.service
    016

    Ví dụ 10. 21. Thay đổi giới hạn thời gian chờ

    Bạn có thể chỉ định giá trị thời gian chờ cho mỗi dịch vụ để ngăn dịch vụ bị trục trặc đóng băng hệ thống. Mặt khác, thời gian chờ được đặt theo mặc định là 90 giây đối với các dịch vụ thông thường và 300 giây đối với các dịch vụ tương thích với SysV

    Ví dụ: để mở rộng giới hạn thời gian chờ cho dịch vụ

    ~]# systemctl stop nfs-server.service
    89

    1. Sao chép tệp đơn vị

      ~]# systemctl stop nfs-server.service
      89 vào thư mục
      ~]# systemctl stop nfs-server.service
      22

      ~]# systemctl stop nfs-server.service
      022
    2. Mở tệp

      ~]# systemctl stop nfs-server.service
      836 và chỉ định giá trị
      ~]# systemctl stop nfs-server.service
      837 trong phần
      ~]# systemctl stop nfs-server.service
      838

      ~]# systemctl stop nfs-server.service
      023
    3. Tải lại trình nền

      ~]# systemctl stop nfs-server.service
      82

      ~]# systemctl stop nfs-server.service
      89
    4. Tùy chọn. Xác minh giá trị thời gian chờ mới.

      ~]# systemctl stop nfs-server.service
      025

    Note

    Để thay đổi giới hạn thời gian chờ trên toàn cầu, hãy nhập

    ~]# systemctl stop nfs-server.service
    25 vào tệp
    ~]# systemctl stop nfs-server.service
    24. Xem Phần 10. 1, “Giới thiệu về systemd”

    Giám sát các đơn vị bị ghi đè

    To display an overview of overridden or modified unit files, use the following command

    ~]# systemctl stop nfs-server.service
    026

    Ví dụ: đầu ra của lệnh trên có thể trông như sau

    ~]# systemctl stop nfs-server.service
    027

    Bảng 10. 13, “Các loại khác biệt systemd-delta” liệt kê các loại ghi đè có thể xuất hiện trong đầu ra của

    ~]# systemctl stop nfs-server.service
    829. Lưu ý rằng nếu một tệp bị ghi đè, theo mặc định,
    ~]# systemctl stop nfs-server.service
    829 sẽ hiển thị tóm tắt các thay đổi tương tự như đầu ra của lệnh
    ~]# systemctl stop nfs-server.service
    844

    Bảng 10. 13. Các loại khác biệt systemd-delta

    TypeDescription

    [CHE MẶT]

    Masked unit files, see Section 10. 2. 7, “Disabling a Service” for description of unit masking

    [TƯƠNG ĐƯƠNG]

    Các bản sao chưa sửa đổi ghi đè lên các tệp gốc nhưng không khác về nội dung, thường là các liên kết tượng trưng

    [REDIRECTED]

    Files that are redirected to another file

    [OVERRIDEN]

    Overridden and changed files

    [EXTENDED]

    Files that are extended with . conf files in the

    ~]# systemctl stop nfs-server.service
    804 directory

    [UNCHANGED]

    Unmodified files are displayed only when the

    ~]# systemctl stop nfs-server.service
    846 option is used

    It is good practice to run

    ~]# systemctl stop nfs-server.service
    829 after system update to check if there are any updates to the default units that are currently overridden by custom configuration. It is also possible to limit the output only to a certain difference type. For example, to view just the overridden units, execute

    ~]# systemctl stop nfs-server.service
    028

    10. 6. 5.  Working with Instantiated Units

    It is possible to instantiate multiple units from a single template configuration file at runtime. The "@" character is used to mark the template and to associate units with it. Instantiated units can be started from another unit file [using

    ~]# systemctl stop nfs-server.service
    577 or
    ~]# systemctl stop nfs-server.service
    583 options], or with the
    ~]# systemctl stop nfs-server.service
    743 command. Instantiated service units are named the following way

    ~]# systemctl stop nfs-server.service
    029

    Where template_name stands for the name of the template configuration file. Replace instance_name with the name for the unit instance. Một số phiên bản có thể trỏ đến cùng một tệp mẫu với các tùy chọn cấu hình phổ biến cho tất cả các phiên bản của đơn vị. Template unit name has the form of.

    ~]# systemctl stop nfs-server.service
    00

    For example, the following

    ~]# systemctl stop nfs-server.service
    583 setting in a unit file

    ~]# systemctl stop nfs-server.service
    01

    first makes systemd search for given service units. Nếu không tìm thấy đơn vị nào như vậy, phần giữa "@" và hậu tố loại sẽ bị bỏ qua và systemd tìm kiếm tệp

    ~]# systemctl stop nfs-server.service
    852, đọc cấu hình từ tệp đó và khởi động dịch vụ

    Wildcard characters, called unit specifiers , can be used in any unit configuration file. Bộ xác định đơn vị thay thế các tham số đơn vị nhất định và được giải thích trong thời gian chạy. Table 10. 14, “Important Unit Specifiers” lists unit specifiers that are particularly useful for template units.

    Table 10. 14.  Important Unit Specifiers

    Unit SpecifierMeaningDescription

    ~]# systemctl stop nfs-server.service
    853

    Full unit name

    Stands for the full unit name including the type suffix.

    ~]# systemctl stop nfs-server.service
    854 có ý nghĩa tương tự nhưng cũng thay thế các ký tự bị cấm bằng mã ASCII

    ~]# systemctl stop nfs-server.service
    855

    Prefix name

    Stands for a unit name with type suffix removed. Đối với các đơn vị được khởi tạo %p là viết tắt của phần tên đơn vị trước ký tự "@"

    ~]# systemctl stop nfs-server.service
    856

    Tên trường hợp

    Is the part of the instantiated unit name between the "@" character and the type suffix.

    ~]# systemctl stop nfs-server.service
    857 has the same meaning but also replaces the forbidden characters for ASCII codes

    ~]# systemctl stop nfs-server.service
    858

    Host name

    Viết tắt của tên máy chủ của hệ thống đang chạy tại thời điểm cấu hình đơn vị được tải

    ~]# systemctl stop nfs-server.service
    859

    thư mục thời gian chạy

    Represents the runtime directory, which is either

    ~]# systemctl stop nfs-server.service
    860 for the
    ~]# systemctl stop nfs-server.service
    402 user, or the value of the XDG_RUNTIME_DIR variable for unprivileged users

    For a complete list of unit specifiers, see the

    ~]# systemctl stop nfs-server.service
    571 manual page

    Ví dụ: mẫu

    ~]# systemctl stop nfs-server.service
    852 chứa các lệnh sau

    ~]# systemctl stop nfs-server.service
    02

    Khi getty@ttyA. service and getty@ttyB. service are instantiated form the above template,

    ~]# systemctl stop nfs-server.service
    572= is resolved as Getty on ttyA and Getty on ttyB .

    10. 7.  Additional Considerations While Managing Services

    Trong quá trình hoạt động bình thường, systemd duy trì mối liên hệ giữa trừu tượng hóa đơn vị và các quy trình cơ bản đang hoạt động trên hệ thống

    From.

    ~]# systemctl stop nfs-server.service
    865

    ~]# systemctl stop nfs-server.service
    03

    The cgroup hierarchy is critical to systemd’s view of process and service health. Khi một tiến trình tự phân nhánh, nó sẽ kế thừa cgroup của tiến trình tạo. With this being the case, all processes associated with a given unit can be verified by reading the contents of the applicable cgroup. tập tin procs, chẳng hạn như

    ~]# systemctl stop nfs-server.service
    04

    The output matches the CGroup information returned during a

    ~]# systemctl stop nfs-server.service
    866 operation.

    ~]# systemctl stop nfs-server.service
    05

    To directly view these groupings of processes system-wide, the

    ~]# systemctl stop nfs-server.service
    867 utility can be used

    ~]# systemctl stop nfs-server.service
    06

    In order for systemd to function properly, the service must be started or stopped through the systemd system to maintain the correct process to unit grouping. Bất kỳ thao tác nào thực hiện hành động bên ngoài đều dẫn đến cấu trúc cgroup cần thiết không được tạo. This happens because systemd is not aware of the special nature of the processes being started

    Như một ví dụ về ràng buộc trên, việc dừng dịch vụ

    ~]# systemctl stop nfs-server.service
    89 và sau đó phát hành trực tiếp
    ~]# systemctl stop nfs-server.service
    869 dẫn đến kết quả sau

    ~]# systemctl stop nfs-server.service
    07

    Note that the

    ~]# systemctl stop nfs-server.service
    89 process is now visible under the user-0. slice and a session-168. phạm vi. Dịch vụ này được coi là quy trình do người dùng bắt đầu, trái ngược với dịch vụ hệ thống, systemd đó sẽ giám sát và quản lý trực tiếp. Một số lỗi có thể xảy ra do sự sai lệch này bao gồm, nhưng không giới hạn ở

    • Services are not properly shutdown during system shutdown or restart events
    • Các tín hiệu không mong muốn được gửi trong quá trình đăng xuất của người dùng như SIGHUP và SIGTERM
    • Các quy trình không thành công sẽ không tự động khởi động lại mặc dù có chỉ thị
      ~]# systemctl stop nfs-server.service
      871

    Note

    Các sự kiện tắt ứng dụng không linh hoạt có thể dẫn đến một số lượng lớn các lỗi ứng dụng tiếp theo, chẳng hạn như lỗi phía máy khách, mất dữ liệu và hỏng trên đĩa

    10. 8. Tài nguyên bổ sung

    Để biết thêm thông tin về systemd và cách sử dụng nó trên Red Hat Enterprise Linux 7, hãy xem các tài nguyên được liệt kê bên dưới

    Chủ Đề