Home > Operation and Maintenance > CentOS > What is the difference between the commands of centos7 and 6?

What is the difference between the commands of centos7 and 6?

青灯夜游
Release: 2022-03-07 15:53:31
Original
3445 people have browsed it

Difference: 1. Centos7 uses systemd instead of init; 2. Modify the host name. Centos6 needs to modify "/etc/sysconfig/network", while 7 needs to modify "/etc/hostname"; 3. Centos7 uses the chrony command To synchronize time, use ntp.

What is the difference between the commands of centos7 and 6?

#The operating environment of this tutorial: centos7 system, thinkpad t480 computer.

I have recently been using CentOS 7 and found that many commands are different from CentOS 6, so they are listed here for reference.

1. Commonly used systemctl commands

CentOS 7 began to use systemd to replace the init system parent process, so it is necessary to be proficient in systemctl.

##systemctl enable sshd.servicechkconfig --level 3 sshd onStart the ssh service automatically after booting systemctl disable sshd.servicechkconfig --level 3 sshd offDisable starting the ssh service at bootsystemctl list-unit-files --type=servicechkconfig --listList all service statussystemctl list -unitschkconfig --list,ntsysvList allowed service unitssystemctl is-active sshd.servicechkconfig --list sshdCheck whether the ssh service is runningsystemctl mask sshd.serviceShield (cannot Enable) ssh servicesystemctl unmask sshd.serviceliberation shield ssh servicesystemctl show sshd.serviceShow configuration information of SSH servicesystemctl get-default Get the currently used runlevelsystemctl set-default runlevel3.targetvi /etc/inittabModify the default runlevelsystemctl isolate runlevel3.targetinit 3Enable runlevel 3
CentOS 7 CentOS 6 Function
systemctl start sshd.service service sshd start Start ssh service
systemctl stop sshd.service service sshd stop Stop ssh service
systemctl restart sshd.service service sshd restart restart ssh service
systemctl status sshd.service service sshd status  View ssh service status
systemctl reload sshd.service service sshd reload Reload the ssh service

2. Configuration file

1. Startup configuration

centos6: Modify /etc/inittab

centos7: systemctl set-default runlevel3.target

2. Modify the host name

centos6: Modify /etc/sysconfig/network

centos7: Modify /etc/hostname

3. Open the startup file /etc/rc. d/rc.local

centos6: No modification required

centos7: chmod x /etc/rc.d/rc.local

4. Default firewall

centos6: iptables

centos7: firewall

5. Start the service in file mode

centos6:/etc/rc.d/rc3.d/ Modify the ones starting with K The file is S

centos7: Make a soft connection to a service under /usr/lib/systemd/system/ to the /etc/systemd/system directory

6, routing forwarding

centos6: Edit /etc/sysctl.conf and add net.ipv4.ip_forward = 1 or echo “1” > /proc/sys/net/ipv4/ip_forward

centos7: Edit /etc/sysctl .conf Add net.ipv4.ip_forward = 1 or echo “1” > /proc/sys/net/ipv4/ip_forward

Edit /usr/lib/sysctl.d/50-default.conf Add net .ipv4.ip_forward = 1

7. Language setting

centos6: vim /etc/sysconfig/i18n modification LANG="zh_CN.UTF-8"

centos7: localectl set-locale.UTF-8

8, time synchronization

CentOS6


$ ntp
$ ntpq -p
Copy after login

CentOS7

$ chrony
$ chronyc sources
Copy after login

9, modification time

CentOS6

$ vim /etc/sysconfig/clock
ZONE="Asia/Tokyo"
UTC=fales
$ sudo ln -s /usr/share/zoneinfo/Asia/Tokyo /etc/localtime
Copy after login

CentOS7

$ timedatectl set-timezone Asia/Tokyo
$ timedatectl status
Copy after login

Recommended: "

centos usage tutorial"

The above is the detailed content of What is the difference between the commands of centos7 and 6?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template