Configuring Time Synchronization and Timezone on CentOS 8

To simplify server management across multiple timezones, Cloud Servers default to the universal timezone UTC. In this article we’ll cover how to change your timezone and ensure synchronization is working properly.

In most modern Linux based Operating Systems, the timedatectl command is used to manage time regardless of whether your using ntp, chrony, or systemd-timesyncd. To see the current time, timezone, and time synchronization status, run the timedatectl command with no arguments.

timedatectl

You’ll see your time and timezone in the Local time field:

Local time: Mon 2020-03-01 19:11:29 UTC

You can see that time synchronization is working in the System clock synchronized field:

System clock synchronized: yes

Update timezone

If you need to update your timezone, timedatectl makes it very simple. First, list timezones:

timedatectl list-timezones

Set new timezone:

sudo timedatectl set-timezone America/Chicago

Verify the change with timedatectl:

timedatectl

You’ll see in the Local time field the timezone has been updated:

Local time: Mon 2020-03-02 13:31:16 CST

Defining the Different Cloud Computing Mentalities

Cloud computing has become a broad term to describe a wide variety of services and products.  From infrastructure services to data storage services, and even the photo storage on your phone are all referred to as ‘clouds’.  So, what really is a cloud, and how do we categorize different types of clouds?

Defining a ‘cloud’

Cloud computing is a service that provides rapid and configurable computing resources to be assigned and released with minimal effort.  This follows the NIST (National Institute of Standards and Technology) definition of cloud.  While the full description of the cloud is fairly long, here is an excerpt from the NIST description:

`Cloud computing` is a model for enabling ubiquitous, convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, servers,  storage, applications, and services) that can be rapidly provisioned and released with minimal management effort or service provider interaction.

This breaks down to mean that any user can provision resources rapidly and with ease.  These resources are part of a larger shared pool and can be released back to the pool just as quickly and easily.

There are a couple of other items in the NIST definition that are considered required to define a cloud:

  • Quick provisioning: Resources can be scaled to meet demand rapidly and without long lead times typically categorized by IT scale-outs
  • Easy Access: Users should be able to access the service easily and via standard means (laptop, phone, etc)
  • Self-service: The service should allow end-users to provision new resources or remove existing ones without the need to interact with another human
  • Metered billing: The service should only charge for resources as they are used.  Think utility-style billing such as for your electric or water bill.

Almost all cloud solutions will fit the items we have defined above.  There are cases where one or more of these items is missing but the service is generally still considered a cloud. However, the variety of products and services that fit the above definition is vast so we can further define these services into a few categories, Software as a Service (SaaS), Platform as a Service (PaaS), and Infrastructure as a Service (IaaS).  Let’s explore the definition and differences between these different cloud categories.

Software as a Service

Software as a Service or SaaS describes a subset of cloud environments in which an application is presented over the internet as an on-demand, pay-as-you-go service.  This type of service has become commonplace these days even if you had not previously realized.  Email, for instance, has become one of the most common examples of a SaaS system.

SaaS does not necessarily require these, but the following is a list of common features of a SaaS system:

  • Web access to a commercial software or software suite
  • Software served from a centralized infrastructure
  • Software is delivered in a ‘one-to-many’ model from this infrastructure
  • Upgrades, patches, and maintenance of the software and infrastructure is not required to be performed by the user.

SaaS is extremely useful for standard solutions such as email, and solutions which require high availability such as a mobile sales application.  SaaS can be used for more short term solutions, such as the deployment of project management software for a development project.

SaaS is not ideal for all applications or software however.  Generally SaaS is run from a centralized infrastructure which processes all requests for the application being presented.  As such, high compute intensity and real-time data processing applications may bog down or not work properly when utilized as a SaaS.

Platform as a Service

Platform as a service (PaaS) is a subset of the cloud where instead of presenting an application as SaaS does, instead PaaS presents an environment to develop, test, and host a custom application from.  Generally, this also means the cost of any development or hosting software is taken care of by the provider, meaning you simply pay for the PaaS and start developing.

While not required, the following is a list of common features of a PaaS:

  • A full development suite.  This includes ways to test, deploy, host, and maintain your custom application.
  • Multitenant architecture.  This allows multiple developers to be working on the same code base at the same time.
  • Built-in scalable architecture for any deployed applications.  This often also includes redundant features like load-balancing and failover systems.
  • UI creation tools.  These assist the creation and testing of different UI possibilities for the application.
  • Project management software.  While not always included, some PaaS services come packaged with version management or collaboration management software.

PaaS strikes a bit of a middle ground between SaaS and IaaS.  Where SaaS allows the consumption of an application over the internet, PaaS may contain one or more SaaS’s under its umbrella in order to achieve its goal of presenting a development environment over the internet.  Similarly, PaaS may contain items that are more accurately described as IaaS on their own, but contribute to creating the desired development environment a PaaS is achieving.

Infrastructure as a Service

Infrastructure as a service presents computing resources directly as opposed to packaging them with existing software (SaaS) or with a development environment (PaaS).  This can encompass more than just servers, and may also include network, storage, or other resources.  As an example, this allows an end-user to provision and have a server in minutes instead of finding and purchasing a server, finding and procuring data center space, and then waiting for the shipping and installation of the device in the data center.

IaaS almost always can be categorized by the following:

  • Rapid resource allocation provided as a service
  • Generally multitenant environment
  • Rapid and dynamic scaling options

IaaS is the ‘lowest’ form of cloud in that it gets as close to the base hardware as possible.  This also makes it the most flexible form of cloud in that you can basically do anything you could do on a regular hardware deploy.  However, this also means less convenience than SaaS and PaaS provide. 

In practice, most cloud providers provide a mix of products and services that encompass multiple concepts we have covered here.  Additionally, new products in this sector are continually blurring the lines between these three main concepts.

Cloud computing as we have seen now, is a very broad term in what it can encompass.  Users should be aware of at least the basic concepts that cloud computing can break down into.  This lets users make informed choices on what products and services they should pursue for their application.

How to Install cPanel on CentOS 7

Cpanel is a web based server control center used to simplify server management. In this article, you’ll learn how to install cPanel on a CentOS 7 server.

Prerequisites

cPanel account
Fresh CentOS 7 server

Prepare the server

First thing we want to do is make sure the server is fully up to date.

yum update -y

Next, create a fully qualified host name. Be sure to replace the “example.com” portion with your own domain.

hostnamectl set-hostname server.example.com

The installation script can take a long time so cPanel recommends using screen as precaution against disconnects. We’ll install it with the command below.

yum install screen -y

Start screen:

screen

Once screen is running, if you loose connection to your server, just ssh back in and run screen -r to get back to your session.

Installing cPanel

This command will download and run the installation script. cPanel says this can take up to three hours to run. So grab some lunch and be patient.

cd /home && curl -o latest -L https://securedownloads.cpanel.net/latest && sh latest

Once the installation has finished, navigate to https://ipaddress:2087 to log in.

Understanding Systemd Unit Files

If you’ve worked with Linux for very long, you likely have used Systemd when managing your server. If you’ve worked with Linux even longer, you’ll likely remember familiarizing yourself with Systemd basics when the change was made from SysVinit. If you’re just starting out and need an introduction to Systemd, I’d recommend you start with the community article here.

In this documentation, we’ll be taking a closer look at the Systemd unit files. A ‘unit’ refers to a resource which the system knows how to operate and manage. These resources are further defined using configuration files known as unit files.

Unit files can be found in three main directories which may differ slightly depending on your OS. These directories also determine the order in which Unit files are acted upon. As soon as Systemd finds a specific unit file for a unit, it no longer searches for it. So, if you wished to supercede a unit file in /run/systemd/system, you could place the file in /etc/systemd/system:

/etc/systemd/system – Local configuration

/run/systemd/system – Runtime units

/usr/lib/systemd/system – Units of installed packages

Within the directories, unit file names take on the following form:

unit_name.type_extension

unit_name identifies the name of the unit, and type_extension identifies the type of unit. For example we might have sshd.service. There are a number of different unit types, the table below gives an overview of these:

Unit Type File Extension Description
Service unit .service A system service.
Target unit .target A group of systemd units.
Automount unit .automount A file system automount point.
Device unit .device A device file recognized by the kernel.
Mount unit .mount A file system mount point.
Path unit .path A file or directory in a file system.
Scope unit .scope An externally created process.
Slice unit .slice A group of hierarchically organized units that manage system processes.
Snapshot unit .snapshot A saved state of the systemd manager.
Socket unit .socket An inter-process communication socket.
Swap unit .swap A swap device or a swap file.
Timer unit .timer A systemd timer.

Unit File Structure

A unit file will usually consist of three sections:

  • [Unit] — This is the informational section. It will contains generic options that are not dependent on the type of the unit. Here you’re likely to find a description of the service, as well as what other services it depends on before it can start.

  • [Service] — This section contains the commands and environment variables required to run the service. It may also contain a command which gracefully shuts down the service.

  • [Install] — This section will tell the service which target requires this service. This section can also be used to define aliases for the service.

Let’s take a look at the sshd.service file as an example. Commentary describing each line is provided in italic:

# cat sshd.service
[Unit]
Description=OpenSSH server daemon #Describes what this service is
Documentation=man:sshd(8) man:sshd_config(5) #Provides URIs for unit's documentation
After=network.target sshd-keygen.service #Indicates this unit starts only after these services
Wants=sshd-keygen.service #Indicates what is known as a weak dependency, it will not prevent our unit from starting, but identifies recommended dependencies.

[Service]
Type=notify #This specifies the unit process start type which affects functionality of the ExecStart options. 
EnvironmentFile=/etc/sysconfig/sshd #EnvironmentFile dictates an exact path to a file where Systemd reads the environment variables from. It's also possible to replace this with Environment= and include the variables directly in the unit file
ExecStart=/usr/sbin/sshd -D $OPTIONS #This specifies the script or command executed when the unit is started. 
ExecReload=/bin/kill -HUP $MAINPID #This specifies the script or command to execute when the unit is reloaded.
KillMode=process #Specifies how processes of this unit shall be killed. One of control-group, process, mixed, none.
Restart=on-failure #With this, systemd will automatically restart the unit if it exits without a directive from systemctl.
RestartSec=42s #With Restart enabled, this dictates the time between when the unit has stopped, and when it will attempt to restart.

[Install]
WantedBy=multi-user.target #With WantedBy=multi-user.target enabled, a directory called multi-user.target.wants will be created within /etc/systemd/system and a symbolic link to the current unit will be placed within, creating a dependency.

Conclusion

Understanding units and unit files will help in administration of the server. Thanks to the UnitFiles, you do not need to understand script or code to determine much of what a unit/services requires in order to operate. Further understanding of unit files will also allow a user to create their own unit files for units, giving them further flexibility.

For extensive information around Units and Unit Files in Systemd, you can run the following command to open up the man page on units and unit configuration:

# man systemd.unit

How to set python-pip3 as default on Ubuntu 16.04

PIP is a tool that manages Python packages that you will be using for your projects. In this article, we will cover setting PIP3 as default on your machine local or virtual. 

 

First, make sure that the correct you need is installed on your machine 

sudo pip --version

 

You should see something like

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

 

If you don’t have pip installed, install it using the following command

sudo apt install python3-pip

 

Next, edit ~/.bash_aliases

echo "alias pip=pip3" >> ~/.bash_aliases

 

Finally, source or reload ~/.bash_aliases 

source ~/.bash_aliases

How to set python-pip3 as default on Ubuntu 19.04

PIP is a tool that manages Python packages that you will be using for your projects. In this article, we will cover setting PIP3 as default on your machine local or virtual. 

 

First, make sure that the correct you need is installed on your machine 

sudo pip --version

 

You should see something like

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

 

If you don’t have pip installed, install it using the following command

sudo apt install python3-pip

 

Next, edit ~/.bash_aliases

echo "alias pip=pip3" >> ~/.bash_aliases

 

Finally, source or reload ~/.bash_aliases 

source ~/.bash_aliases

How to set python-pip3 as default on Ubuntu 20.04

PIP is a tool that manages Python packages that you will be using for your projects. In this article, we will cover setting PIP3 as default on your machine local or virtual. 

 

First, make sure that the correct you need is installed on your machine 

sudo pip --version

 

You should see something like

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

 

If you don’t have pip installed, install it using the following command

sudo apt install python3-pip

 

Next, edit ~/.bash_aliases

echo "alias pip=pip3" >> ~/.bash_aliases

 

Finally, source or reload ~/.bash_aliases 

source ~/.bash_aliases

How to set python-pip3 as default on Ubuntu 18.04

PIP is a tool that manages Python packages that you will be using for your projects. In this article, we will cover setting PIP3 as default on your machine local or virtual. 

 

First, make sure that the correct you need is installed on your machine 

sudo pip --version

 

You should see something like

pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

 

If you don’t have pip installed, install it using the following command

sudo apt install python3-pip

 

Next, edit ~/.bash_aliases

echo "alias pip=pip3" >> ~/.bash_aliases

 

Finally, source or reload ~/.bash_aliases 

source ~/.bash_aliases

How to set python-pip3 as default on CentOS 6

PIP is a tool that manages Python packages that you will be using for your projects. In this article, we will cover setting PIP3 as default on your machine local or virtual. 

 

First, make sure that the correct you need is installed on your machine 

sudo pip --version

 

You should see something like

pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

 

If you don’t have pip installed, install it using the following command

sudo yum install python34-pip

 

You will also need to install development tools along with PIP.

sudo yum install python-devel
sudo yum groupinstall 'development tools'

 

Next, edit /home/.bashrc. I use vi, but use whichever text editor you are comfortable with. 

alias pip="/usr/bin/pip3"

 

Finally, source or reload /home/.bashrc

source /home/.bashrc

How to set python-pip3 as default on CentOS 7

PIP is a tool that manages Python packages that you will be using for your projects. In this article, we will cover setting PIP3 as default on your machine local or virtual. 

 

First, make sure that the correct you need is installed on your machine 

sudo pip --version

 

You should see something like

pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7)

 

If you don’t have pip installed, install it using the following command

sudo yum install python34-pip

 

You will also need to install development tools along with PIP.

sudo yum install python-deve
sudo yum groupinstall 'development tools'

 

Next, edit /home/.bashrc. I use vi, but use whichever text editor you are comfortable with. 

alias pip="/usr/bin/pip3"

 

Finally, source or reload /home/.bashrc

source /home/.bashrc