Differences between Ubuntu and CentOS and common parts

Here is a summary of the differences between Ubuntu and CentOS. It's good to be able to work with both.

Shell shebang "/ bin / sh"

In CentOS, "/ bin / sh" has a symbolic link in "/ bin / bash", so it will be executed in bash.

On Ubuntu it runs in "/ bin / sh". The implementation is in a shell called "dash".

If you write the shebang as follows, it will be executed by "/ bin / sh" on Ubuntu, while it will be executed by bash on CentOS.

#! / bin / sh

And when using the bash grammar, a grammar error occurs as follows.

./morbo: 10: ./morbo: Syntax error: "(" unexpected

Linux To have inter-portability, explicitly write bash and shebang.

#! / bin / bash

If you want to have portability between Unixes, you will need to rewrite it with sh syntax.

You can write portable programs between Unix / Linux by writing Perl.

Package management

There is a difference between apt in the package management tool Ubuntu and yum in CentOS.

Starting with CentOS 8, dnf replaces yum. yum is an alias for dnf.

The package name is also different. It seems that package management cannot be standardized at this time.


For Ubuntu, sudo is available by default.

To allow sudo, Ubuntu adds the user to the sudo group.

#Allow sudo on Ubuntu
gpasswd -a myapp sudo

Sudo is not enabled on CentOS. Make settings to enable sudo with visudo. (For CentOS 7)

Uncomment "%wheel ALL = (ALL) ALL".

## Allows people in group wheel to run all commands
#%wheel ALL = (ALL) ALL
%wheel ALL = (ALL) ALL

To allow sudo, add the user to the wheel group.

#Allow sudo on CentOS
gpasswd -a myapp wheel



Apache has a different name. In CentOS it is httpd, but in Ubuntu it is apache2.

The location of the configuration file and the name when executing the systemctl command are different.

The configuration of the configuration file is also different between CentOS and Ubuntu.

Apache on Ubuntu has configuration file enable commands such as a2ensite, a2enmod, a2enconf.

In Ubuntu, it is easier to enable / disable the configuration file using commands.


The firewall is ufw for Ubuntu and firewalld for CentOS.

Firewalls are very confusing to set up on the command line, and I have a strong feeling that I don't want to do it.

VPS and cloud services usually have a firewall setting, so if you set it with that, you do not have to be aware of the firewall of Linux itself. There is a part that controls packets in the network settings.

In case of on-premises, firewall management is performed by command.


For Ubuntu, cron is installed by default, which is a normal cron. You can use cron naturally.

For CentOS, the default cron is anacron. If you want a regular cron, you need to uninstall anacron and install a regular cron.


In case of Ubuntu, the function corresponding to SeLinux of CentOS is off by default.

For CentOS, SeLinux is on by default. This function causes a proxy error when connecting with a reverse proxy, so you need to disable SeLinux or set it to allow reverse proxy.

SSL certificate by Let's Encrypt

On Ubuntu, certbot can be installed from apt.

On CentOS, install certbot as follows.

# Cent OS 7
yum install epel-release
yum install --enablerepo = epel certbot

If the certbot is not included in the epel repository, such as when a new Cent OS version is just out, you will need to install it from source code. Also, certbot is named certbot-auto.

What is common to Ubuntu and CentOS

CentOS and Ubuntu have recently become common.


In both CentOS and Ubuntu, services (those who start as a server) are now managed by systemd, and the management command is also systemctl.

From CentOS 7, you can use the systemctl command in common with Ubuntu.


For systemd log management, journalctl can be used for both Ubuntu and CentOS.

From CentOS 7, you can use the journalctl command in common with Ubuntu.


Perl is installed by default in a typical Ubuntu configuration.

Perl is often not installed by default in a typical CentOS configuration. In addition, Perl's core modules are separate from the perl package.

#Install Perl on CentOS
yum install perl
yum install perl-core

Server state after package installation

If you installed the server application, it will be launched for Ubuntu.

If you installed the server application, it is not started for CentOS.

Standard package type

Ubuntu provides a Let's Encrypt client, certbot, and a Redis server as standard packages.

For CentOS (for CentOS 7), the above is not provided. It is available by installing the Expansion Package (EPEL) repository for Linux.

sudo yum -y install epel-release

The magnitude of change between versions

Ubuntu is as compatible as possible, despite changes, and I feel that there are few major changes.

The change is bigger in CentOS. The difference between the versions feels big. There are many changes in CentOS 5, 6, 7, 8.

Associated Information