Organize common centos7 documents

Source: Internet
Author: User

Organize common centos7 documents

1. enable iptables firewall in Centos 7.0

CentOS 7.0 uses firewall as the firewall by default. Here, it is changed to iptables firewall.
Disable firewall:
Systemctl stop firewalld. service # stop firewall
Systemctl disable firewalld. service # disable firewall startup

Install iptables Firewall:
Yum install iptables-services # Installation
Vi/etc/sysconfig/iptables # edit the firewall configuration file
Systemctl restart iptables. service # restart the firewall to make the configuration take effect.
Systemctl enable iptables. service # Set firewall startup

2. Centos 7.0 does not contain ifconfig and netstat by default.

Centos7 canceled ifconfig and used ip addr to view ip Address

By installing the net-tools Package, you can use ifconfig and netstat

Yuminstall net-tools

3. CentOS7 Services use systemd instead of sysvinit for management

Systemctl is the main tool that integrates the functions of the previous service and chkconfig. You can use it to enable or disable services permanently or only in the current session.

Systemctl can list the running service status

Systemd-cgls lists running processes in a tree. It recursively displays control group content.

Start/disable, enable/disable services:

Start a service: systemctl start postfix. service
Disable a service: systemctl stop postfix. service
Restart a service: systemctl restart postfix. service
Displays the status of a service: systemctl status postfix. service
Enable a service at startup: systemctl enable postfix. service
Disable a service at startup: systemctl disable postfix. service
Check if the service is started: systemctl is-enabled postfix. service; echo $?
View the list of started services: systemctl list-unit-files | grep enabled

(Enable the service is in the current "runlevel" configuration file directory/etc/systemd/system/multi-user.target.wants, create a soft link corresponding to the service configuration file in/usr/lib/systemd/system. If the service is disabled, the soft link is deleted.

Modify the system running level

Systemd uses a more free target alternative than sysvinit. The 3rd class is replaced by multi user.tar get. Use graphical.tar get to replace the 5th class. Runlevel3.targetand runlevel5.tar get are symbolic links to multi user.targetand graphical.tar get respectively.
You can use the following command to switch to "running level 3 ":
Systemctl isolate multi-user.target or systemctl isolate runlevel3.target
You can use the following command to switch to "running level 5 ":
Systemctl isolate graphical.tar get or systemctl isolate runlevel5.target

How to change the default running level
Systemd uses links to point to the default running level. Before creating a new link, run the following command to delete the existing link: rm/etc/systemd/system/default.tar get
Default start Level 3:
Ln-sf/lib/systemd/system/multi-user.target/etc/systemd/system/default.tar get
Default startup running level 5:
Ln-sf/lib/systemd/system/graphical.tar get/etc/systemd/system/default.tar get
Systemd does not use the/etc/inittab file.

How to view the current running level
The old runlevel command can still be used in systemd. You can continue to use it, although systemd uses the 'target' concept (multiple 'targets' can be activated at the same time) to replace the runlevel of the previous system.
The equivalent systemd command is systemctl list-units-type = target.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.