In this article we’ll cover the basic steps required to install a clean Linux CentOS 8 from scratch and initial server setup.
What’s New in CentOS 8?
The 8th version of CentOS was released on September 24, 2019. CentOS is a Linux distribution based on the commercial Red Hat Enterprise distro by Red Hat and compatible with it.
Let’s see the main changes in the CentOS 8 release:
- The Linux kernel 4.18 is used;
- Transition from yum package manager to dnf. Currently yum exists as a symlink to dnf;
- The main repository has been divided into 2 ones — BaseOS and AppStream. It has been done in order a user can install different package versions. BaseOS is working as usual;
- All software has been updated, including the kernel. Now you can install php 7.2 from the basic repository (Finally!);
- Iptables have been replaced with nftables;
- Network-scripts are not used by default to configure the network settings. Network Manager should be used to manage a network;
- By default, the cockpit server management web interface is installed (convenient for newbies);
- Podman (instead of docker or mobdy) is used to manage containers;
- A new version of TCP/IP 4.16 stack has appeared to provide higher performance and BBR & NV control algorithm support;
- New distribution versions.
How to Install CentOS 8 from an ISO Image
Since I installed the CentOS on a KVM virtual machine, I had downloaded an installation ISO image from one of the official mirrors (https://www.centos.org/download/mirrors/) in advance and mounted it to install the OS on a virtual server. (If you want to install CentOS on a physical server, write the installation ISO image on a USB stick.) I will say that the CentOS 8 installation process does not differ from that of the previous version, and this article is intended as a guide for the users who do it for the first time.
The recommended minimum requirements for CentOS 8 installation are at least 10GB of disk space and 712MB RAM per CPU core.
Boot your computer or virtual machine from CentOS install image. In the first step you will be prompted to select further actions. Since we need the installation, select the first item in the menu:
Install CentOS Linux 8.0.1905
After selecting it, the installation process starts:
While the necessary software is being loaded, you can just watch the process and do not need to do anything.
When the black screen changes to an interactive one with CentOS logo, keep your keyboard and mouse at hand.
On the welcome screen, you will be prompted to select the language that will be during the installation process. Then click Continue. In the next menu you will select the basic CentOS installation settings.
To start the installation, you are required to configure only one item: Installation Destination. There you select the disk partition layout, but I prefer to configure network, time and date at this stage.
Select your settings depending on your time zone.
To configure your network, click Network & Host Name.
Specify your server name in the Host Name field, and click Configure to configure the network interfaces.
In the General tab, check the box Automatically connect to this network when it is available to automatically start this network interface.
Go to the IPv4 Settings tab (or IPv6 if you are using this protocol) to set the IP address, netmask, gateway and DNS servers:
To enter the specific IP address, select Manual method and click Add. After saving the changes, go back to the initial network configuration screen.
As you can see in the screenshot, the IP address has been added and the network interface is working (status: Connected).
In the next step, we’ll go to the partitioning of the disk:
Just to show the installation process, I used automatic storage configuration by CentOS developers. If you want to partition a disk in some other way, select Custom here.
Since a guest OS had been installed on my virtual machine earlier, the installation saw it. I removed the partitions of the previous operating system in the next menus that appeared:
You can remove the partitions by clicking Delete all. Then you will have to click Reclaim space to update the size of the available disk space.
The list of packages for the installation is selected in Software Selection. If you are going to use CentOS 8 as a server, it is enough to choose Minimal Install, as well as Standard and Guest Agents (if you install a guest OS on a virtual machine).
After doing that, you can start the installation by clicking Begin Installation.
During unpacking and installing the required components, you will be prompted to enter a password for the root user. You can also create another user, but it is optional.
Click Root Password, enter the password and confirm it. Then click Done to get back to the installation:
The CentOS 8 installation has taken about 5-7 minutes. When you see Reboot button on the installation screen, it means that the installation is over, and you must restart your server.
So the CentOS 8 installation is complete.
Configuring CentOS 8 Basic Settings after Installation
Basic CentOS 8 post-install configuration is almost similar to that of CentOS 7, and I configure the same basic settings on all servers.
Install Updates & Administrator Tools on CentOS
As mentioned earlier, dnf has replaced yum in CentOS 8.
The first thing I do on a newly installed server is updating the system:
# dnf update -y
If the image is up-to-date, it is likely that there will be no packages to update, like in my case:
Dependencies resolved. Nothing to do. Complete!
If there are any updates, install them.
In the next step, enable the EPEL repository and install the tools for convenient server administration:
# dnf install epel-release -y
# dnf install mc wget screen nano net-tools bind-utils curl lsof vim -y
These utilities are enough for me, but you can install those you got used to.
I do not use automatic system update, since I always install the updates I need manually. If you want to configure automatic updates, install the dnf-automatic package:
# dnf install -y dnf-automatic
To check the active system update tasks, enter this command:
# systemctl list-timers *dnf-*
How to Disable SELinux on CentOS?
At the initial server setup stage, I always disable SELinux (to apply the changes, you will have to reboot your server):
# nano /etc/sysconfig/selinux
# reboot
You can disable SELinux on-the-fly using this command:
setenforce 0
Configuring Network Settings on CentOS 8
Since I configured my network setting during the OS installation, I do not need to do it now (see a detailed article on network configuration in CentOS here). I just want to say that in CentOS 8 you can manage your network using only Network Manager and nmcl. Network-scripts are not supported by default. Frankly speaking, earlier I always disabled NM and did not use it, for it is not convenient for me, but now I will have to learn it.
Here is how to check the network status:
# systemctl status NetworkManager
● NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-06-29 08:23:11 NY; 3h 37min ago Docs: man:NetworkManager(8) Main PID: 870 (NetworkManager) Tasks: 3 (limit: 5060) Memory: 4.7M CGroup: /system.slice/NetworkManager.service └─870 /usr/sbin/NetworkManager --no-daemon
How to Change a Hostname on CentOS 8?
If you have not set a correct server hostname during the CentOS installation or just want to change it, you can do it in some ways. Edit it in the file /etc/hostname or change using the following command:
# hostnamectl set-hostname mycentos8server
Configure Firewalld on CentOS 8
Add the services you will need (SSH and HTTP/HTTPS) to the list of trusted zones in firewalld
:
firewall-cmd –-add-service=ssh
firewall-cmd --permanent –-add-service=http
firewall-cmd --permanent –-add-service=https
Changing the time and TimeZone on CentOS
To view the current time and timezone on CentOS, enter the date command:
# date
We set the time-zone during our system installation, so we are having NY time. To change the time-zone, use the corresponding command:
# timedatectl set-timezone America/Toronto
# timedatectl list-timezones
To synchronize time, chronyd is used, we’ll enable it and add it to autostart using systemctl:
# systemctl start chronyd
# systemctl enable chronyd
# systemctl status chronyd
● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2020-06-29 16:13:48 +06; 9s ago Docs: man:chronyd(8) man:chrony.conf(5) Main PID: 31700 (chronyd) Tasks: 1 (limit: 5060) Memory: 1.1M CGroup: /system.slice/chronyd.service └─31700 /usr/sbin/chronyd
Configure Bash History
To view the bash command history in a more convenient way, I always add a couple of lines to .bashrc to easily get the command history info I need.
With the default settings, the history output is shown like this:
# history
1 dnf repolist 2 dnf install epel-release
It means we can what commands were executed on the server, but do not see the time and date. It is critical for me. So let’s make the history view more convenient. Open /root/.bashrc and add some lines to it:
# nano /root/.bashrc
export HISTSIZE=10000
export HISTTIMEFORMAT="%d/%d/%y - %H:%M:%S "
Then when you view the history, you will see the exact time and date when a command was run:
# history
1 Jun/06/29 - 16:16:29 dnf repolist 2 Jun/06/29 - 16:16:29 dnf install epel-release
Cockpit: Server Management Web Interface on CentOS 8
As we have already mentioned, CentOS 8 has the cockpit server management web interface preinstalled. You can also manage in using systemctl. You can run it and add it to startup:
# systemctl enable cockpit.socket
# systemctl start cockpit.socket
By default, Cockpit web server listens on Port TCP/9090. Add the port to the allowed ones in firewalld:
# firewall-cmd --get-active-zones
# firewall-cmd --add-port=9090/tcp --zone=MY_ACTIVE_ZONE --permanent
# firewall-cmd --reload
To access Cockpit web interface, open this URL: https://Your-CentOS8-IP:9090
in your browser and authenticate.
Using Cockpit, you can view the load of your server, manage networks, storages and containers or view the logs.
The typical CentOS server configuration is over, then I usually make further configuration according to my project statement, and the requirements may vary.