Redhat 6 vs Redhat 7 distribution Commands

Introduction

Red Hat Enterprise Linux (RHEL) 6 and RHEL 7 use different service management, networking, firewall, hostname, and system configuration commands.

This guide provides a practical comparison of commonly used commands in Red Hat 6 and Red Hat 7. It can be useful when managing or troubleshooting servers running different RHEL versions.

Prerequisites

Before using the commands in this guide:

  • You should have access to a Red Hat 6 or Red Hat 7 server.
  • Root or sudo privileges are required for most service and system configuration tasks.
  • Make sure you use the commands appropriate for your RHEL version.

Implementation

List All Services

Red Hat 6

chkconfig --list
ls /etc/init.d

Red Hat 7

systemctl -at service
ls /etc/systemd/system/*.service

Start and Stop a Service

Red Hat 6

Start a service:

service name start

Stop a service:

service name stop

Red Hat 7

Start a service:

systemctl start name.service

Stop a service:

systemctl stop name.service

Enable and Disable a Service

Red Hat 6

Enable a service at boot:

chkconfig name on

Disable a service at boot:

chkconfig name off

Red Hat 7

Enable a service at boot:

systemctl enable name.service

Disable a service at boot:

systemctl disable name.service

Verify Service Status

Red Hat 6

service name status

Red Hat 7

systemctl status name.service

Check Whether a Service Is Enabled

Red Hat 6

chkconfig name

Red Hat 7

systemctl is-enabled name

Create or Reload a New Service

Red Hat 6

chkconfig --add

Red Hat 7

After creating or modifying a systemd service file, reload the systemd configuration:

systemctl daemon-reload

View the Run Level

Red Hat 6

runlevel

Red Hat 7

systemctl get-default

Shutdown the System

Red Hat 6

shutdown

Red Hat 7

systemctl shutdown

Power Off the System

Red Hat 6

poweroff

Red Hat 7

systemctl poweroff

Reboot the Machine

Red Hat 6

reboot

Red Hat 7

systemctl reboot

Get the Run Level

Red Hat 6

cat /etc/inittab

Red Hat 7

systemctl get-default

Set the Run Level

Red Hat 6

Edit /etc/inittab:

vi /etc/inittab

Change the appropriate run-level configuration.

Red Hat 7

Use:

systemctl set-default name.target

Replace name.target with the required target.

To view the available target units:

systemctl list-units --type target --all

GRUB Loader Configuration

Red Hat 6

The GRUB configuration file is:

/boot/grub/grub.conf

Red Hat 7

The GRUB configuration file is:

/etc/default/grub

Configure the Firewall

Red Hat 6

Red Hat 6 commonly uses iptables.

To view the current rules:

iptables -nL

Red Hat 7

Red Hat 7 commonly uses firewalld.

To view the firewall configuration:

firewall-cmd --list-all

Set the Hostname

Red Hat 6

Open the network configuration file:

vi /etc/sysconfig/network

Add or modify the hostname:

HOSTNAME=hostname.domain.tld

Restart the network service:

service network restart

Red Hat 7

To check the current hostname:

hostnamectl status

To set a new hostname:

hostnamectl set-hostname hostname.domain.tld

View Network Interfaces

Red Hat 6

ifconfig

Red Hat 7

ip addr

View Ports and Network Sockets

Red Hat 6

netstat -plan

Red Hat 7

ss -tlp

Quick Command Comparison

TaskRed Hat 6Red Hat 7
List serviceschkconfig --listsystemctl -at service
Start serviceservice name startsystemctl start name.service
Stop serviceservice name stopsystemctl stop name.service
Enable servicechkconfig name onsystemctl enable name.service
Disable servicechkconfig name offsystemctl disable name.service
Service statusservice name statussystemctl status name.service
Check enabledchkconfig namesystemctl is-enabled name
Reload service configurationchkconfig --addsystemctl daemon-reload
Check run levelrunlevelsystemctl get-default
Power offpoweroffsystemctl poweroff
Rebootrebootsystemctl reboot
Firewalliptablesfirewalld
Hostname/etc/sysconfig/networkhostnamectl
Network interfacesifconfigip addr
Network socketsnetstat -planss -tlp
GRUB configuration/boot/grub/grub.conf/etc/default/grub

Conclusion

Red Hat 6 and Red Hat 7 differ significantly in the way system services, networking, firewall rules, hostnames, and boot configuration are managed.

The most important change is the transition from the traditional SysV init and service commands in RHEL 6 to systemd and systemctl in RHEL 7. Knowing these command differences makes it easier to administer and troubleshoot servers across both versions.

FAQs

1. What is the main difference between Red Hat 6 and Red Hat 7 commands?

The major difference is service management. Red Hat 6 uses traditional SysV tools such as service and chkconfig, while Red Hat 7 uses systemctl and systemd.

2. How do I restart a service in Red Hat 6?

Use:

service name restart

3. How do I restart a service in Red Hat 7?

Use:

systemctl restart name.service

4. How can I check the network interfaces in Red Hat 7?

Use:

ip addr

5. What command is used to check open listening ports in Red Hat 7?

Use:

ss -tlp

Install Apache2, PHP 7, and MySQL on Red Hat 7 Server

Learn how to install and configure Apache, PHP, and MySQL on a Red Hat 7 server.

Talk to our experts

Looking for the right technology solution for your business? Our team of experts can help you with development, cloud, DevOps, design, and a wide range of other technology needs. Get in touch with our team here.

admin

Writes about Security at Pheonix Solutions.

Leave a Reply

Scroll to Top