ลงทะเบียน
ใกล้กัน ช่วยให้คุณแชร์เรื่องราวต่างๆ กับผู้คนมากมาย

คำสั่งที่ใช้บ่อยบน CentOS 7

คำสั่งที่ใช้บ่อยบน CentOS 7

โพสต์ใน: ระบบ / - โดย - May 29, 2022

การเปิด Service ตอนบูตเข้า CentOS 7 มีข้อดีคือทำให้โปรแกรมทำงาน และพร้อมใช้ทันที ในบทคความนี้จะแสดงวิธีเปิดหรือปิดใช้งานบริการหรือเรียกว ่า Services เมื่อเริ่มต้นบูตเข้าระบบ RHEL 7 หรือ CentOS 7

 

ตรวจสอบว่า Services เริ่มทำงานตอนบูตหรือไม่ 

เราจะใช้คำสั่ง systemctl ซึ่งเป็นตัวจัดการระบบหรือเรียกว่า systemd ในตัวอย่างเราจะตรวจสอบ httpd เป็น Service ของ Apache ซึ่งทำหน้าที่เป็นตัวเริ่มต้นการทำงานของเว็บไซต์

$ systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)

 

การปิด Service ไม่ให้โหลดขึ้นมาตอนบูตเข้าระบบ

เราจะใช้คำสั่ง systemctl disable ตามด้วยชื่อ Service

$ systemctl disable httpd
rm '/etc/systemd/system/multi-user.target.wants/httpd.service'

$ systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)

 

การเปิด Service ตอนบูตเข้า CentOS 7

เราจะใช้คำสั่ง systemctl enable ตามด้วยชื่อ Service

$ systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'

$ systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)

 

ตรวจสอบว่าบริการใดไม่สามารถเริ่มต้นตอนบูตเข้า CentOS 7

สุดท้ายสิ่งที่ควรทำ เพื่อทำการแก้ไขหรือปิดไม่ให้สูญเสียทรัพยากร

เราจะใช้คำสั่ง systemctl --failed

$ systemctl --failed
UNIT            LOAD   ACTIVE SUB    DESCRIPTION
kdump.service   loaded failed failed Crash recovery kernel arming
php-fpm.service loaded failed failed The PHP FastCGI Process Manager

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

 

 ในตัวอย่างข้างต้น บริการ kdump และ php-fpm ไม่สามารถเริ่มทำงานตอนบูตได้

 

LINUX

User not write anything about he.
Captcha Challenge
ลองรูปภาพใหม่
Type in the verification code above

ลองอ่านดูน่าสนใจ: