Set Time Zone on CentOS 7

Checking the Current Timezone

In CentOS and other modern Linux distros, you can use the timedatectl command to display and set the current system’s time and timezone.

timedatectl

The output below shows that the system’s timezone is set to UTC:

Local time: Wed 2019-02-06 22:43:42 UTC
Universal time: Wed 2019-02-06 22:43:42 UTC
RTC time: Wed 2019-02-06 22:43:42
Time zone: Etc/UTC (UTC, +0000)
NTP enabled: no
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

The system timezone is configured by symlinking /etc/localtime to a binary timezone identifier in the /usr/share/zoneinfo directory. So, another option to check the timezone is to show the path the symlink points to using the ls command:

ls -l /etc/localtime
lrwxrwxrwx. 1 root root 29 Dec 11 09:25 /etc/localtime -> ../usr/share/zoneinfo/Etc/UTC

Changing Timezone in CentOS

Before changing the timezone, you’ll need to find out the long name for the timezone you want to use. The timezone naming convention usually uses a “Region/City” format.

To list all available time zones, you can either list the files in the /usr/share/zoneinfo directory or use the timedatectl command.

timedatectl list-timezones
...
America/Tijuana
America/Toronto
America/Tortola
America/Vancouver
America/Whitehorse
America/Winnipeg
...

Once you identify which time zone is accurate to your location, run the following command as sudo user:

Read more

Share

Reinstall VirtualBox on Ubuntu & CentOS

For Ubuntu

To remove virtualbox

sudo dpkg --list virtualbox-*
sudo apt autoremove --purge virtualbox*
dpkg -l virtualbox* | grep ^i

Remove all PPAs from sources.list and source.list.d directory

mkdir ~/apt-tmp
sudo mv /etc/apt/sources.list.d/* ~/apt-tmp

Make sure there is nothing except official repositories sources in /etc/sources.list. And update your sources:

sudo apt update

Now we can search to see which versions are available to install:

apt-cache madison virtualbox | grep -iv sources

Which produces an output like this:

virtualbox | 5.0.32-dfsg-0ubuntu1.16.04.2 | http://mirrors.kernel.org/ubuntu xenial-updates/multiverse amd64 Packages
virtualbox | 5.0.18-dfsg-2build1 | http://mirrors.kernel.org/ubuntu xenial/multiverse amd64 Packages

Then I would install the last version mentioned in xenial-updates:

Read more

Share

Install ZFS on CentOS 7

Installing ZFS File System

ZFS File System support is not enabled by default on CentOS 7. That is not the only problem. ZFS is not available in the official package repository of CentOS 7. You have to install it from the official package repository of ZFS. I am installing this on a server running Centos 7.6. You may take a look at https://github.com/zfsonlinux/zfs/wiki/RHEL-and-CentOS for more details.

First check what version of CentOS 7 you’re using with the following command:

$ cat /etc/redhat-release

As you can see, I am using Centos 7.6

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

Now you have to add the official repository of ZFS on CentOS 7 with the following command:

yum install http://download.zfsonlinux.org/epel/zfs-release.el7_6.noarch.rpm

ZFS repository should be added.

There are two ways ZFS module can be loaded to the kernel, DKMS and kABI. The difference between these is that if you install DKMS based ZFS module, and then for some reason you update the kernel of your operating system, the ZFS kernel module must be recompiled again. Otherwise it won’t work. But the kABI based ZFS module has the upper hand in that it doesn’t require recompilation if the kernel of the operating system is updated.

Read more

Share

Disable FirewallD and Enable Iptables on CentOS 7

Download and Install the Iptables Service

To begin your server’s transition, you need to download and install the iptables-service package from the CentOS repositories. Download and install the service files by typing:

sudo yum install iptables-services

This will download and install the systemd scripts used to manage the iptables service. It will also write some default iptables and ip6tables configuration files to the /etc/sysconfig directory.

Construct your Iptables Firewall Rules

Next, you need to construct your iptables firewall rules by modifying the /etc/sysconfig/iptables and /etc/sysconfig/ip6tables files. These files hold the rules that will be read and applied when we start the iptables service.

How you construct your firewall rules depends on whether the system-config-firewall process is installed and being used to manage these files. Check the top of the /etc/sysconfig/iptables file to see whether it recommends against manual editing or not:

sudo head -2 /etc/sysconfig/iptables

If the output looks like this, feel free to manually edit the /etc/sysconfig/iptables and /etc/sysconfig/ip6tables files to implement the policies for your iptables firewall:

output
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall

Open and edit the files with sudo privileges to add your rules:

sudo nano /etc/sysconfig/iptables
sudo nano /etc/sysconfig/ip6tables

After you’ve made your rules, you can test your IPv4 and IPv6 rules using these commands:

sudo sh -c 'iptables-restore -t < /etc/sysconfig/iptables'
sudo sh -c 'ip6tables-restore -t < /etc/sysconfig/ip6tables'

If, on the other hand, the output from examining the /etc/sysconfig/iptables file looks like this, you should not manually edit the file:

Read more

Share

Endian Installation USB Flash Drive

This lesson describes how to create an installation USB drive for image files provided by Endian and to verify the integrity of the image file. The procedure applies to Windows users with XP, Vista, or Windows7 systems.

Requirements

You need the following to complete this lesson:

  • .iso or .img image of an Endian Appliance.
  • md5sum of the image.
  • An USB Stick.

Warning
Some USB sticks may not work with Endian devices. In particular, some Endian hardware device might fail to recognise USB Sticks with size bigger the 2Gb. so you should try with one USB stick with smaller size.

Note: ISO image files
Starting with release 5.0, Endian releases installation images as .iso file, rather than .img. However, the following procedure and suggested software can be used also with .iso files.

It is assumed that you have an Endian image file and its correspondent md5sum checksum on your computer. This lesson takes as example an image of an edge 3.0 and its correspondent md5sum file saved in C:\:

In order to create the Endian installation USB flash drive you need to download an application that allows to burn img and iso images to USB flash drives disks, like win32 Disk Imager.

Read more

Share

Install Qemu Guest Agent on Proxmox

The qemu-guest-agent is a helper daemon, which is installed in the guest. It is used to exchange information between the host and guest, and to execute command in the guest.

In Proxmox VE, the qemu-guest-agent is used for mainly two things:

  • To properly shutdown the guest, instead of relying on ACPI commands or windows policies
  • To freeze the guest file system when making a backup (on windows, use the volume shadow copy service VSS).

Installation Host
You have to enable the guest-agent per VM, either set it in the GUI to “Yes” under options (see screenshot):

or via CLI:

qm set VMID --agent 1

Guest Linux
On Linux you have to simply install the qemu-guest-agent, please refer to the documentation of your system.

We show here the commands for Debian/Ubuntu and Redhat based systems:

Read more

Share

Install Observium CentOS 7/Ubuntu 16.04/ Debian 9

Observium is an open source, low-maintenance, auto-discovering network monitoring tool for operating systems and network hardware. It supports Linux and Windows operating systems and network hardware like Cisco, Juniper, Brocade, Foundry, HP.

Observium is based on AMP (Apache, MySQL, and PHP) stack and it collects the monitoring metrics via SNMP protocol. It uses RRDtool to make a graph of metrics collected from SNMP. Observium can also collect data using CDP, FDP, LLDP, OSPF, BGP, and ARP protocols.

Observium comes with a simple yet powerful interface to monitor devices, and it’s alerting system can be highly customized to receive alerts over an email, IRC, slack and more.

This tutorial covers the installation of Observium on CentOS 7 / Ubuntu 16.04 / Debian 9 and collecting usage metrics from Linux machines via SNMP protocol.

Prerequisites

Log-in as the root user or switch to root user as commands we run during the installation process requires root privilege.

su -

OR

sudo su -

We first install Webtatic, OpenNMS, and EPEL repositories on CentOS 7 / RHEL 7.

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -ivh http://yum.opennms.org/repofiles/opennms-repo-stable-rhel7.noarch.rpm

Install and Configure MySQL / MariaDB
Observium needs AMP stack, so install MariaDB as a database server, a fork of MySQL.

Read more

Share

Zimbra 8.8 on CentOS 7

Before we proceed with Zimbra Collaboration Suite installation process, first login to your server console with root privileges and install the following packages:

# yum -y install unzip net-tools sysstat openssh-clients perl-core libaio nmap-ncat libstdc++.so.6 perl perl-core ntpl nmap sudo libidn gmp libaio libstdc++ unzip sqlite dnsmasq

Next, issue getenforce command to check if Selinux in enabled on your machine. In case the policy is set to Enforced disable it by issuing the below commands:

# getenforce
# setenforce 0
# getenforce

To completely disable Selinux on CentOS, open /etc/selinux/config file with a text editor and set the line SELINUX to disabled.

Assure that wget system utility is also installed on your system by issuing the following command:

# yum install wget

In order for Zimbra to function correctly you must set the local machine hostname and FQDN to point to your server IP Address by running the below commands from root account:

# hostnamectl set-hostname mail
# echo "192.168.0.14 mail.centos7.lan mail " >> /etc/hosts
# cat /etc/hosts

Replace the system hostname and FQDN values accordingly in order to match your own domain settings. Test the hostname and FQDN values by issuing the ping command against both records.

Read more

Share

Add a New Disk Larger Than 2TB to An Existing Linux

I am using fdisk and parted utilities to do this configuration.

First list the current partition details using fdisk command as shown.

# fdisk -l
List Linux Partition Table
List Linux Partition Table

For the purpose of this article, I am attaching a hard disk of 20GB capacity, which can be followed for disk larger than 2TB as well. Once you added a disk, verify the partition table using same fdisk command as shown.

Read more

Share

Install PHP 7.2 on Debian 9

Before you start with the installation of PHP 7.2 on your Debian VPS, make sure that you have full root access to it. Connect to the server via SSH and upgrade all the system software to the latest version available. You can do this by running the following commands in the terminal:

sudo apt-get update 
sudo apt-get upgrade

This will update the package index and will update the software currently installed on the server to the latest version.

Once your system is fully up to date, you can proceed to the next step, which is installing PHP 7.2.

Import the signing key and enable the PPA for PHP 7.2 by using the following commands:

wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list

Once you are done with this, run the package index update once again using the command below:

sudo apt-get update

In case you get an error like the one below:

Reading package lists... Done
E: The method driver /usr/lib/apt/methods/https could not be found.
N: Is the package apt-transport-https installed?
E: Failed to fetch https://packages.sury.org/php/dists/stretch/InRelease
E: Some index files failed to download. They have been ignored, or old ones used instead.

It means there are some missing packages that you need to install first. Install the required packages by running the following command:

sudo apt-get install ca-certificates apt-transport-https

The run the update command again.

Finally, install PHP 7.2 on your Debian 9 VPS including some of the commonly used extensions using the command below:

sudo apt-get install php7.2 php7.2-cli php7.2-common php7.2-opcache php7.2-curl php7.2-mbstring php7.2-mysql php7.2-zip php7.2-xml

To verify the installation is completed run the following command:

php -v

The output should be very similar to the one below:

# php -v
PHP 7.2.9-1+0~20180901081133.4+stretch~1.gbpdaac35 (cli) (built: Sep 1 2018 08:11:34) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.9-1+0~20180901081133.4+stretch~1.gbpdaac35, Copyright (c) 1999-2018, by Zend Technologies

Change/Customize PHP 7.2 settings on a Debian VPS
Next thing you may want to complete is to customize the PHP 7.2 settings to meet your requirements. You can do so by editing the php.ini file. To find the path to this file, you can use the command below:

php --ini | grep "Loaded Configuration File"

It will return the path to the php.ini file which is currently loaded.

# php --ini | grep "Loaded Configuration File"

Loaded Configuration File: /etc/php/7.2/cli/php.ini

Edit the file using a text editor of your choice. We will use nano in this example.

nano /etc/php/7.2/cli/php.ini

Once you change the settings, save and close the file. If you are using Apache as a web server, you need to restart it for the new configuration to be loaded and for the changes to take effect. If you are using Nginx and PHP-FPM, you should restart the PHP-FPM service.

You can also create a sample info.php and see if the PHP files and executed on the server.

To create the file:

nano /var/www/html/info.php

and paste the following:

<?php phpinfo(); ?>

Save and close the file, then open you favorite web browser and access the file by using your server IP address in the URL followed by the name of the file.

http://IP-ADDRESS/info.php
Share