How to Install And Configure WildFly (JBoss) on Ubuntu 16.04 or 18.04

install wildfly ubuntu4

This post will guide you how to install and configure the latest WildFly application on your Ubuntu Linux 18.04 or 16.04 or Debian Linux. How do I install WildFly (JBoss) Application Server on my Ubuntu system.

install wildfly ubuntu4

What is WildFly?


WildFly is a flexible, lightweight, managed application runtime that helps you build amazing applications. Currently, the latest version is WildFly 17.01. WildFly can be run on multiple platforms including windows and Linux.

WildFly, formaly know as JBoss is an application server written in Java language, and it is developed by Red Hat. It is one of the most popular open source Java server applications. WildFly implements the latest in enterprise Java standards. WildFly takes an aggressive approach to memory management.

WildFly offers two modes: a traditional, single JVM, standalone mode, and a multi-JVM option, domain mode, which synchronizes configuration across any number of processes and hosts.

WildFly supports the latest standards for web development. Web Socket support allows your applications the ability to use optimized custom protocols and full-duplex communication with your backend infrastructure.

Prerequisites


You need to have a non-root user with sudo privileges so that you can install necessary packages on your Ubuntu system.

Step1: Installing JAVA


As the WildFly Application is written in Java language, so you need to install Java Development kit on your Ubuntu system. You can install either OpenJDK or Java SE Development Kit on you system. The OpenJDK is already available on the default Ubuntu APT repository, so the easiest way of installing java ENV is installing OpenJDK with the following command on your Ubuntu or Debian system.

Firstly, you need to update your system to make sure that your Ubuntu server OS packages are fully up-to-date with the following two commands:

$ sudo apt update
$ sudo apt upgrade

Then you can begin to install OpenJDK with the below apt command:

$ sudo apt install default-jdk -y

Outputs:

devops@devops:~$ sudo apt install default-jdk

[sudo] password for devops:

Reading package lists... Done

Building dependency tree

Reading state information... Done

The following additional packages will be installed:

  default-jdk-headless default-jre default-jre-headless openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless

Suggested packages:

  openjdk-11-demo openjdk-11-source visualvm fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei | fonts-wqy-zenhei

The following NEW packages will be installed:

  default-jdk default-jdk-headless default-jre default-jre-headless openjdk-11-jdk openjdk-11-jdk-headless openjdk-11-jre openjdk-11-jre-headless

0 upgraded, 8 newly installed, 0 to remove and 76 not upgraded.

Need to get 225 MB of archives.

After this operation, 367 MB of additional disk space will be used.

Do you want to continue? [Y/n]

……

update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jhsdb to provide /usr/bin/jhsdb (jhsdb) in auto mode

Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...

Processing triggers for hicolor-icon-theme (0.17-2) ...

Setting up default-jre-headless (2:1.11-68ubuntu1~18.04.1) ...

Setting up default-jdk-headless (2:1.11-68ubuntu1~18.04.1) ...

Setting up openjdk-11-jre:amd64 (11.0.3+7-1ubuntu2~18.04.1) ...

Setting up default-jre (2:1.11-68ubuntu1~18.04.1) ...

Setting up openjdk-11-jdk:amd64 (11.0.3+7-1ubuntu2~18.04.1) ...

update-alternatives: using /usr/lib/jvm/java-11-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode

Setting up default-jdk (2:1.11-68ubuntu1~18.04.1) ...

The JDK should be installed on your Ubuntu system, you can test the installation by checking the JAVA version with the following command:

$ java –version

Outputs:

devops@devops:~$ java --version

openjdk 11.0.3 2019-04-16

OpenJDK Runtime Environment (build 11.0.3+7-Ubuntu-1ubuntu218.04.1)

OpenJDK 64-Bit Server VM (build 11.0.3+7-Ubuntu-1ubuntu218.04.1, mixed mode, sharing)

From the above output, you would see that the current version of Java is 11.03.

Step2: Downloading WildFly


You need to go the official download page of WildFly application to get the latest version. As of writing this post, the latest release version of WildFly (JBoss) is 17.01. you can download the WildFly archive file using the following wget command:

$ wget https://download.jboss.org/wildfly/17.0.1.Final/wildfly-17.0.1.Final.tar.gz

Outputs:

devops@devops:~$ wget https://download.jboss.org/wildfly/17.0.1.Final/wildfly-17.0.1.Final.tar.gz

--2019-07-11 06:18:05--  https://download.jboss.org/wildfly/17.0.1.Final/wildfly-17.0.1.Final.tar.gz

Resolving download.jboss.org (download.jboss.org)... 23.42.94.23

Connecting to download.jboss.org (download.jboss.org)|23.42.94.23|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 183598392 (175M) [application/x-gzip]

Saving to: ‘wildfly-17.0.1.Final.tar.gz’

wildfly-17.0.1.Final.tar.gz              100%[=================================================================================>] 175.09M  4.07MB/s    in 40s

2019-07-11 06:18:46 (4.42 MB/s) - ‘wildfly-17.0.1.Final.tar.gz’ saved [183598392/183598392]

Step3: Installing WildFly


Once the WildFly archive file is downloaded in your local disk. And you need to extract all files into /opt/wildfly directory.

Firstly, extract the archive file with the below tar command:

$ tar -xvf wildfly-17.0.1.Final.tar.gz

Then, move all files to /opt/wildfly directory, type:

$ sudo mv wildfly-17.0.1.Final /opt/wildfly

Step4: Creating a User for WildFly


Now you need to create a new system user and group called wildfly with home directory /opt/wildfly, it will be used to run the WildFly daemon on your Ubuntu system. Just issue the following two command to create a new system user and system group:

$ sudo groupadd --system wildfly

$ sudo useradd -s /sbin/nologin  --system -d /opt/wildfly -g wildfly wildfly

Checking if wildfly is created correctly with the following command:

$ id wildfly

Outputs:

devops@devops:~$ id wildfly

uid=999(wildfly) gid=999(wildfly) groups=999(wildfly)

Step5: Configuring Systemd for WildFly


You can create a systemd service for WildFly application, just do the following steps:

#1 create a configuration directory for WildFly under /etc directory with the below command:

$ sudo mkdir /etc/wildfly

#2 Copy configuration file of WildFly from /opt/wildfly to /etc/wildfily with the following command:

$ sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.conf  /etc/wildfly/

#3 Copy systemd service file of WildFly from /opt/wildfly to /etc/system/system/ directory, type:

$ sudo cp /opt/wildfly/docs/contrib/scripts/systemd/wildfly.service /etc/systemd/system/

#4 copy start script templates from /opt/wildfly to /opt/wildfly/bin/ directory, type:

$ sudo cp /opt/wildfly/docs/contrib/scripts/systemd/launch.sh /opt/wildfly/bin/

#5 adding executable permission for launch.sh file, type:

$ chmod u+x /opt/wildfly/bin/launch.sh

#6 you need to notify systemd that you created a new daemon file, just using the following command:

$ sudo systemctl daemon-reload

#7 then you can start the WildFly service by executing the following command:

$ sudo systemctl start wildfly

$ sudo systemctl enable wildfly

$ sudo systemctl status wildfly

Outputs:

root@devops:/opt/wildfly# systemctl status wildfly
wildfly.service - The WildFly Application Server
   Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: enabled)

   Active: active (running) since Thu 2019-07-11 08:24:53 EDT; 2s ago

 Main PID: 451 (launch.sh)

    Tasks: 15 (limit: 1129)

   CGroup: /system.slice/wildfly.service

           ├─451 /bin/bash /opt/wildfly/bin/launch.sh standalone standalone.xml 0.0.0.0

           ├─452 /bin/sh /opt/wildfly/bin/standalone.sh -c standalone.xml -b 0.0.0.0

           └─546 java -D[Standalone] -server -Xms64m -Xmx512m -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -

Jul 11 08:24:53 devops systemd[1]: Started The WildFly Application Server.

Step6: Add a User to Access Management Console


Now the WildFly application is installed on your ubuntu system, and if you want to connect to WildFly Management console, you still need to create a user who can access WildFly console. WildFly has provided a script for adding user to WildFly application server. Just executing the following command:

$ sudo /opt/wildfly/bin/add-user.sh

You need to ask what type of user do you want to add, just type letter a to select the first type to add a Management User, then press Enter key on your keyboard.

Outputs:

devops@devops:~$ sudo /opt/wildfly/bin/add-user.sh

[sudo] password for devops:

What type of user do you wish to add?
a) Management User (mgmt-users.properties)
b) Application User (application-users.properties)
(a): a

Then you need to type a username for user, and set password for that user, press Enter key.

Enter the details of the new user to add.

Using realm 'ManagementRealm' as discovered from the existing property files.

Username : osetc

Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.

 - The password should be different from the username

 - The password should not be one of the following restricted values {root, admin, administrator}

 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)

Password :

WFLYDM0098: The password should be different from the username

Are you sure you want to use the password entered yes/no? yes

Re-enter Password :

Next, you need to enter and agree to the others prompts to finish the user creation.

What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:

About to add user 'osetc' for realm 'ManagementRealm'

Is this correct yes/no? yes

Added user 'osetc' to file '/opt/wildfly/standalone/configuration/mgmt-users.properties'

Added user 'osetc' to file '/opt/wildfly/domain/configuration/mgmt-users.properties'

Added user 'osetc' with groups  to file '/opt/wildfly/standalone/configuration/mgmt-groups.properties'

Added user 'osetc' with groups  to file '/opt/wildfly/domain/configuration/mgmt-groups.properties'

Is this new user going to be used for one AS process to connect to another AS process?

e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server EJB calls.

yes/no? yes

To represent the user add the following to the server-identities definition <secret value="b3NldGM=" />

 From the above outputs, you should see that the new user will be added to file ‘/opt/wildfly/domain/configuration/mgmt-users.properties‘.

Step7: Accessing WildFly Management Console


If you want to WildFly Management Console, you can open your browser and type the following URL:

http://localhost:9990

install wildfly ubuntu2

then you need to type the username and password created in the above step for authentication. Then the Winldfly console will be shown.

install wildfly ubuntu3

Step8: Accessing WildFly Console


If you want to access the default WildFly web page, just open your web browser and type the below link:

http://127.0.0.1:8080

if the WildFly service is running normally, you should see the below screen:

wildfly

Conclusion


You should know that how to install and configure WildFly(JBoss) Application Server on your Ubuntu or Debian Linux. If you want to see more detailed information about WildFly, you can directly go to its official web site.

How to Install Slack on Ubuntu 16.04 or 18.04

install latest slack4

This post will guide you how to install Slack on your Ubuntu Linux 18.04 or 16.04. How do I install Slack tool on your Ubuntu Linux system via Snap tool.

install latest slack4

What is Slack?


Slack is one of the most popular team communication and collaboration platform in the world. You can create a channel for every conversation, and the channel can be divvied up by team, project, client or whatever else is relevant to your organization. And team members can join and leave channels as needed. It also can share channels with companies and business you regularly work with, like clients, vendors and partners.

The Slack also integrate file sharing, you can easily drag and drop PDFs, images, videos and other files directly into it.

Prerequisites


You need to have a non-root user with sudo privileges so that you can install necessary packages on your Ubuntu system.

Step1: Downloading Slack


You can download the Slack Deb package from its official download page with Wget command, like below:

$ wget https://downloads.slack-edge.com/linux_releases/slack-desktop-3.4.2-amd64.deb

Outputs:

devops@devops:~$ wget https://downloads.slack-edge.com/linux_releases/slack-desktop-3.4.2-amd64.deb

--2019-07-10 07:29:47--  https://downloads.slack-edge.com/linux_releases/slack-desktop-3.4.2-amd64.deb

Resolving downloads.slack-edge.com (downloads.slack-edge.com)... 151.101.228.106

Connecting to downloads.slack-edge.com (downloads.slack-edge.com)|151.101.228.106|:443... connected.

HTTP request sent, awaiting response... 200 OK

Length: 62724122 (60M) [application/octet-stream]

Saving to: ‘slack-desktop-3.4.2-amd64.deb’

slack-desktop-3.4.2-amd64.deb                 100%[===============================================================================================>]  59.82M  7.36MB/s    in 7.8s

2019-07-10 07:29:55 (7.69 MB/s) - ‘slack-desktop-3.4.2-amd64.deb’ saved [62724122/62724122]

If you are working in Ubuntu Desktop, just click the DOWNLOAD.DEB(64-BIT) from the download page, then it will download and save the file to your desktop.

install latest slack1

Step2: Installing Slack with DEB Package


Once the installation package of Slack is downloaded on your local disk, you can begin to install it on your Ubuntu terminal with the following dpkg command:

$ sudo dpkg -i slack-desktop-3.4.2-amd64.deb

Or

$ sudo apt install slack-desktop-3.4.2-amd64.deb

Outputs:

devops@devops:~$ sudo dpkg -i slack-desktop-3.4.2-amd64.deb

(Reading database ... 175917 files and directories currently installed.)

Preparing to unpack slack-desktop-3.4.2-amd64.deb ...

Unpacking slack-desktop (3.4.2) over (3.4.2) ...

Setting up slack-desktop (3.4.2) ...

Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...

Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...

Processing triggers for mime-support (3.60ubuntu1) ...

devops@devops:~$

Then the Slack should be installed on your ubuntu system.

Step3: Starting Slack


You can start Slack either from the command line by running slack command or by click on the Slack icon by searching slack keyword from Activities page.

install latest slack3

install latest slack2

Then you can sign in to your workspace or you can also create a new workspace and start collaborating with your colleagues or partners.

Installing Slack with Snap Tool


There is another way to install Slack tool via Ubuntu Snap package management. And you do not need to download Slack package from official download page, just using snap command to install it. So to install Slack via Snap tool on your Ubuntu system, just run the following command:

$ sudo apt install snapd

$ sudo apt install slack –classic

Conclusion


You should know that how to install Slack tool on your Ubuntu or Debian Linux. If you want to see more detailed information about Slack, you can directly go to its official web site.

How to Configure Network Static IP Address on Ubuntu 16.04 or 18.04

ubuntu logo

This post will guide you how to configure Network Static IP address on Ubuntu Linux 18.04 or 16.04. How do I change the IP address from the default DHCP mode to Static on Ubuntu system.

ubuntu logo

When you installed one Ubuntu system on your machine, the default network setting is to configure your server to get its IP address via DHCP server. And if you want to change your ubuntu server network from DHCP to static settings, or you want to setup a static IP address for your network interface, you can do it by the following methods.

Method1: Configuring Static IP Using DHCP


Normally, Your Ubuntu system will use DHCP server to obtain its networking IP address. And you will get a dynamic IP address. And If you want to get a static IP address, you need to configure you DHCP server to set a static IP address to your system based on its Mac address. Then DHCP server will distribute a static IP address to your machine.

Method2: Configuring Static IP Using Netplan


If you are using Ubuntu 17.10 or above version, you can use a newly network management tools called netplan to configure your network settings on your ubuntu system. Netplan tool will use configuration files with YAML syntax to replace the configuration file /etc/network/interfaces that had previously been used to configure the network on Ubuntu system.

To configure a static IP address on your Ubuntu system, you need to modify a netplan network configuration file located in /etc/netplan/ directory. You need to find the default netplan configuration file called 01-network-manager-all.yaml or others, if the file file does not exist, you can generate the configuration file with the following command:

$ sudo netplan generate

If you want to set your network interface enp0s3 to a static IP address 192.168.3.46 with gateway 192.168.3.1, just modify the default netplan configuration fiile with vim text editor:

$ sudo vim /etc/netplan/01-network-manager-all.yaml

Add the following lines:

ethernets:
    enp0s3:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.3.46/24,]
      gateway4: 192.168.3.1

configure static ip with netplan1

save and close the file. And run the following command to apply changes:

$ sudo netplan apply

If you hit some error message while running the above command, you can pass –debug option to netplan command for debugging, type:

$ sudo netplan --debug apply

Note: if you want to set dynamic DHCP IP address for your network interface with netplan tool, just changing dhcp4 variable as yes in the default netplan configuration file.

Now you have assigned a static IP address for a network interface on your Ubuntu system.

If you get more information for netplan tool, you can check it man page of netplan with the following command:

$ man netplan

Method3: Configuring Static Ip Via Command Line


You can also change Ubuntu network settings via command line on your Ubuntu system. And this method is mostly used in environments where there is only command line. To change the network settings for a network interface from DHCP mode to Static via command line interface on Ubuntu system, just do the following steps:

Step1: modify the default network interface configuration file called /etc/network/interfaces with vim text editor:

$ sudo vim /etc/network /interfaces

Step2: appending the following lines for enp0s3 network interface.

auto enp0s3
iface enp0s3 inet static
address 192.168.3.46
netmask 255.255.255.0
gateway 192.168.3.1
broadcast 192.168.3.255

configure static ip with netplan2

Step3: save and close the above file, then reboot the system.

Step4: once system rebooted, you can check if the ip address is configured with the following command:

$ ifconfig

Or

$ ip addr show dev enp0s3

Outputs:

devops@devops:/etc/netplan$ ip addr show dev enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:1d:33:d0 brd ff:ff:ff:ff:ff:ff
inet 192.168.3.46/24 brd 192.168.3.255 scope global noprefixroute enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe1d:33d0/64 scope link
valid_lft forever preferred_lft forever

devops@devops:/etc/netplan$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.3.46 netmask 255.255.255.0 broadcast 192.168.3.255
inet6 fe80::a00:27ff:fe1d:33d0 prefixlen 64 scopeid 0x20 ether 08:00:27:1d:33:d0 txqueuelen 1000 (Ethernet)
RX packets 35531 bytes 45038695 (45.0 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16291 bytes 1546837 (1.5 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Method4: Configuring Static IP Using Ubuntu Desktop


You can also setup static IP address for a network interface using Ubuntu desktop. Just do the following steps:
Step1: search for “network” in the Activities screen, and then click on Network icon.

configure static ip with netplan3
Step2: click on the gear box icon next to your network connection that you want to configure.

configure static ip with netplan4

Step3: click IPv4 tab, then choose Manual option, enter your static IP address, Netmask, Gateway. Then click Apply button .

configure static ip with netplan5

Step4: restart you network by click ON/OFF switch.

configure static ip with netplan6

Conclusion


You should know that how to configure static IP address for an specified network interface on your Ubuntu or Debian Linux.

How to Install and Configure the Latest PrestaShop on Ubuntu 16.04 or 18.04

prestashop logo

This post will guide you how to install and configure latest PrestaShop on your Ubuntu Linux 18.04 or 16.04 or your dedicated server. And this guide you will show you the following steps to install PrestaShop on an Ubuntu Linux server.

prestashop logo

What is PrestaShop?


PrestaShop is a free open-source shopping cart software that you can use to run an e-commerce website. It is published under the Open software License. And it is written in the PHP programming language with support for the MySQL or MariaDB database management system. This website framework also provide lots of beautiful themes and premium plugins.

PrestaShop is also support many different payment gateway systems, like PayPal, Google Checkout, etc. And you can easily change the theme of the shop without changing its content. And it is also support add-on modules that extend the software’s built-in functionalities.

If you want to open an online store, and PrestaShop solution may be a best choice for you. As it is free and open source and it is wide support from developers, and also it is a comprehensive ecommerce solution used by thousands of merchants around the world.

Prerequisites


  • A running Ubuntu Linux system or VM
  • You need to have a non-root user with sudo privileges
  • A FQDN Domain name that point to your IP address. Such as: mytest.com

Step1: Installing Apache


Before you begin to install packages on your Ubuntu system, you need to make sure that your system is up to date, so you need to run yum update command to update the APT index and upgrade all packages that can be updated.

$ sudo apt update
$ sudo apt upgrade

Then you can begin to install the Apache package with the following command:

$ sudo apt-get install apache2 libapache2-mod-php

Outputs:

devops@devops:~$ sudo apt-get install apache2 libapache2-mod-php
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic
linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic
linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
apache2-bin apache2-data apache2-utils
Suggested packages:
apache2-doc apache2-suexec-pristine | apache2-suexec-custom
The following NEW packages will be installed:
libapache2-mod-php
The following packages will be upgraded:
apache2 apache2-bin apache2-data apache2-utils
4 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 1,413 kB of archives.
After this operation, 16.4 kB of additional disk space will be used.
Do you want to continue? [Y/n]
…..

Setting up libapache2-mod-php (1:7.2+60ubuntu1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Setting up apache2-utils (2.4.29-1ubuntu4.7) ...
Setting up apache2-bin (2.4.29-1ubuntu4.7) ...
Setting up apache2-data (2.4.29-1ubuntu4.7) ...
Processing triggers for systemd (237-3ubuntu10.23) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up apache2 (2.4.29-1ubuntu4.7) ...

Step2: Configuring Apache


Once Apache package is installed on your system, you need to create a basic configuration file for Apache, and it will set DocumentRoot variable to specify the location of your website files and set ServerName variable to specify what you domain name is. And you can create it by copying a default config file, and then modify it. Just do the following steps:

1# Run the following command to copy the default config file to use it as a template.

$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mytest.com.conf

2# edit the configuration file mytest.com.conf with vim text editor, and uncomment the ServerName line, and replace example.com with you domain name, and then update the remain lines as below:

install prestashop on ubuntu1

$ sudo vim /etc/apache2/sites-available/mytest.com.conf
ServerName mytest.com
ServerAdmin test@mytest.com
Documentroot /var/www/html/mytest.com

<Directory /var/www/html/mytest.com>
    AllowOverride All
</Directory>

3# you need to create the directory to store your website files with the following mkdir command:

$ sudo mkdir /var/www/html/mytest.com

4# you need to disable the default configuration file and enable the newly created one, mytest.com.conf, run the below command:

$ sudo a2dissite 000-default.conf
$ sudo a2ensite mytest.com.conf

Outputs:

devops@devops:~$ sudo a2dissite 000-default.conf
Site 000-default disabled.
To activate the new configuration, you need to run:
systemctl reload apache2

devops@devops:~$ sudo a2ensite mytest.com.conf
Enabling site mytest.com.
To activate the new configuration, you need to run:
systemctl reload apache2

5# you also need to enable the mod_rewrite Apache module for PrestaShop with the following command:

$ sudo a2enmod rewrite

6# need to restart Apache service with the following command:

$ sudo systemctl restart apache2.service

Step3: Installing PHP


You need to install php package on your Ubuntu system for PrestaShop software. Just run the following command to install it:

$ sudo apt install php libapache2-mod-php

Ouputs:

devops@devops:~$ sudo apt install php libapache2-mod-php
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libapache2-mod-php is already the newest version (1:7.2+60ubuntu1).
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
php
0 upgraded, 1 newly installed, 0 to remove and 56 not upgraded.
Need to get 3,084 B of archives.
After this operation, 12.3 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.aliyun.com/ubuntu bionic/main amd64 php all 1:7.2+60ubuntu1 [3,084 B]
Fetched 3,084 B in 0s (14.6 kB/s)
Selecting previously unselected package php.
(Reading database ... 210189 files and directories currently installed.)
Preparing to unpack .../php_1%3a7.2+60ubuntu1_all.deb ...
Unpacking php (1:7.2+60ubuntu1) ...
Setting up php (1:7.2+60ubuntu1) ...

Then you still need to install other required PHP modules with the following command:

$ sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap

Outputs:

devops@devops:~$ sudo apt install php7.2-common php7.2-cli php7.2-fpm php7.2-opcache php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-xsl php7.2-mbstring php7.2-zip php7.2-bcmath php7.2-soap
Reading package lists... Done
Building dependency tree
Reading state information... Done
php7.2-cli is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-common is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-common set to manually installed.
php7.2-curl is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-gd is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-mysql is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-opcache is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-intl is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-mbstring is already the newest version (7.2.19-0ubuntu0.18.04.1).
php7.2-zip is already the newest version (7.2.19-0ubuntu0.18.04.1).
The following packages were automatically installed and are no longer required:
linux-headers-4.18.0-22 linux-headers-4.18.0-22-generic linux-image-4.18.0-22-generic linux-modules-4.18.0-22-generic linux-modules-extra-4.18.0-22-generic
Use 'sudo apt autoremove' to remove them.
Suggested packages:
php-pear
The following NEW packages will be installed:
php7.2-bcmath php7.2-fpm php7.2-soap php7.2-xsl
0 upgraded, 4 newly installed, 0 to remove and 56 not upgraded.
Need to get 1,550 kB of archives.
After this operation, 5,456 kB of additional disk space will be used.
Do you want to continue? [Y/n]

Step4: Installing MySQL or MariaDB


Now you can begin to install MySQL database management or MariaDB database to store data for your PrestaShop. Just run the following command to install it:

$ sudo apt install mariadb-server

Or

$ sudo apt install mysql-server mysql-client

Once the installation is completed, you’d better to run mysq_secure_installation script to secure your MySQL or MariaDB installation by running the following command:

$ sudo mysql_secure_installation

Step5: Creating Database and User


Once the Database installation is completed, and you need to create a database for your PrestaShop site, and create one mysql user.

Firstly, you need to log in to your MySQl shell by issue the following command:

$ sudo mysql -u root -p

Then run the following SQL statement to create a new database called myprestashop in the MySQL Shell prompt:

Mysql> create database myprestashop;

Outputs:

mysql> create database myprestashop;
Query OK, 1 row affected (0.00 sec)

Next, you need to create a MySQL username called mypres and you also need to grant the necessary permissions to this user account, just issue the following MySQL commands:

Mysq> create user 'mypres'@'localhost' identified by 'password';
Mysql> grant all on myprestashop.* to 'mypres'@'localhost';
Mysql> flush privileges;
Mysql> exit;

Outputs:

mysql> create user 'mypres'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all on myprestashop.* to 'mypres'@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

Step6: Downloading the Latest PrestaShop Package


Now you can download the latest version of PrestaShop package (1.7.5.2) from its official website. You’d better download the package on the /var/www/html/mytest.com directory with wget command:

$ cd /var/www/html/mytest.com
$ sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip

Outputs:

devops@devops:/var/www/html/mytest.com$ sudo wget https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip
--2019-07-05 06:38:53-- https://download.prestashop.com/download/releases/prestashop_1.7.5.2.zip
Resolving download.prestashop.com (download.prestashop.com)... 184.28.14.204
Connecting to download.prestashop.com (download.prestashop.com)|184.28.14.204|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 71376003 (68M) [application/zip]
Saving to: ‘prestashop_1.7.5.2.zip’

prestashop_1.7.5.2.zip 100%[=================================================================================>] 68.07M 961KB/s in 52s

2019-07-05 06:39:46 (1.30 MB/s) - ‘prestashop_1.7.5.2.zip’ saved [71376003/71376003]

When the download is complete, you need to extract the PrestaShp archive file to your current directory, run:

$ unzip prestashop_1.7.5.2.zip

Outputs:

devops@devops:/var/www/html/mytest.com$ sudo unzip prestashop_1.7.5.2.zip
Archive: prestashop_1.7.5.2.zip
inflating: prestashop.zip
inflating: index.php
inflating: Install_PrestaShop.html

Step7: Installing PrestaShop


Before you install PrestaShop, you still need to assign the right directory ownership for /var/www/html/mytest.com directory, so that the Apache web server can have full access to your website’s files and directories, issue the following command:

$ sudo chown www-data: /var/www/html/mytest.com/
$ sudo chmod -R 755 /var/www/html/mytest.com/

Then you can begin to install PrestaShop through the web interface, you just need to open your browser, and type your domain name or IP address, you should get a screen similar to the below screenshot:

install prestashop on ubuntu2
Choose your language, then click Next button to continue the installation.

install prestashop on ubuntu3
Select “I agree to the above terms and conditions” option, click next button to continue.

install prestashop on ubuntu4

The installation script will check PrestaShop compatibility with your system environment.

install prestashop on ubuntu5
Next, you need to enter your shop detail, such as: Shop name, username, password, etc. click Next button to continue.

install prestashop on ubuntu6
Enter the database details that you created in the above step, such as: database name, database username, password, then click next button. The installation will start now.

install prestashop on ubuntu7

install prestashop on ubuntu8Once your installation is completed, and it will show the following page. And it indicates that the PrestaShop has been installed on your ubuntu server.

install prestashop on ubuntu9
If you want to your PrestaShop administrative dashboard, just click on the Manage your store button. And you need to enter your username and password for authentication.

install prestashop on ubuntu10

Conclusion


You should know that how to install and use PrestaShop on your Ubuntu or Debian Linux. If you want to see more detailed information about PrestaShop, you can directly go to its official web site.

Yum Issue: Failed to Set Locale, defaulting to C

yum logo

If you get a error or warning message “Failed to set locale, defaulting to C” when using yum command in CentOS or RHEL Linux system, how to fix this problem or how do I avoid getting this warning message.

yum logo

Form the warning message, you should know that the locale variable do not correctly setup on your Linux system. And you need to set the current locale value into your environment variables.

You just need to add the following locale relating setting into the file /etc/profile.d/lang.sh with vim text editor:

$ vim /etc/profile.d/lang.sh
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_COLLATE=C
export LC_CTYPE=en_US.UTF-8

 

save and close the file. And run this file with source command to make changes to take effect.

$ source /etc/profile.d/lang.sh

Then you can check the current locale value for you language with the following command:

$ locate

Outputs:

[root@devops ~]# locale

LANG=en_US.UTF-8

LC_CTYPE="en_US.UTF-8"

LC_NUMERIC="en_US.UTF-8"

LC_TIME="en_US.UTF-8"

LC_COLLATE="en_US.UTF-8"

LC_MONETARY="en_US.UTF-8"

LC_MESSAGES="en_US.UTF-8"

LC_PAPER="en_US.UTF-8"

LC_NAME="en_US.UTF-8"

LC_ADDRESS="en_US.UTF-8"

LC_TELEPHONE="en_US.UTF-8"

LC_MEASUREMENT="en_US.UTF-8"

LC_IDENTIFICATION="en_US.UTF-8"

LC_ALL=

 

 

 

How to Install and Use LXD Container on Ubuntu 16.04 or 18.04 Linux

install lxc container2

This post will guide you how to install and use LXD container to create your first Virtual Machine on your Ubuntu Linux 18.04 or 16.04. How do I setup and launch a LXD Container on ubuntu system.

install lxc container2

What is LXD Container?


LXD is a next generation system container manager. It offers a user experience similar to virtual machines but using Linux containers instead. It’s image based with pre-made images available for a wide number of Linux distributions and is built around a very powerful, yet pretty simple, REST API.

LXD is a Container hypervisor providing a REST API to mange LXC containers under you Linux system. LXD is an enhancement of the LXC Container hypervisor, it support for cross-host container and image transfer.

Requirements


  • You need to have a non-root user with sudo privileges so that you can install necessary packages on your Ubuntu system.
  • You need to have an Ubuntu 16.04 or 18.04 installation and also can connect to internet for downloading imaging files.
  • The host can be either a physical or virtual machine.

Step1: Installing LXD Container


The LXD package is already available in the default Ubuntu APT repository. So you can directly install it with the APT command. Just issue the below simple command to install it:

$ sudo apt update
$ sudo apt install lxd

Outputs:

root@devops:/home/devops# apt install lxd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ebtables liblxc-common liblxc1 libuv1 lxcfs lxd-client uidmap xdelta3
Suggested packages:
criu lxd-tools
The following NEW packages will be installed:
ebtables liblxc-common liblxc1 libuv1 lxcfs lxd lxd-client uidmap xdelta3
0 upgraded, 9 newly installed, 0 to remove and 64 not upgraded.
Need to get 9,246 kB of archives.
After this operation, 35.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 ebtables amd64 2.0.10.4-3.5ubuntu2.18.04.3 [79.9 kB]
Get:2 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 liblxc1 amd64 3.0.3-0ubuntu1~18.04.1 [264 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 liblxc-common amd64 3.0.3-0ubuntu1~18.04.1 [438 kB]
Get:4 http://mirrors.aliyun.com/ubuntu bionic/main amd64 libuv1 amd64 1.18.0-3 [64.4 kB]
Get:5 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 lxcfs amd64 3.0.3-0ubuntu1~18.04.1 [38.9 kB]
Get:6 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 lxd-client amd64 3.0.3-0ubuntu1~18.04.1 [3,027 kB]
Get:7 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 uidmap amd64 1:4.5-1ubuntu2 [65.7 kB]
Get:8 http://mirrors.aliyun.com/ubuntu bionic/main amd64 xdelta3 amd64 3.0.11-dfsg-1ubuntu1 [68.9 kB]
Get:9 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 lxd amd64 3.0.3-0ubuntu1~18.04.1 [5,199 kB]
Fetched 9,246 kB in 1s (6,359 kB/s)
Selecting previously unselected package ebtables.
(Reading database ... 174925 files and directories currently installed.)
Preparing to unpack .../0-ebtables_2.0.10.4-3.5ubuntu2.18.04.3_amd64.deb ...
Unpacking ebtables (2.0.10.4-3.5ubuntu2.18.04.3) ...
Selecting previously unselected package liblxc1.
Preparing to unpack .../1-liblxc1_3.0.3-0ubuntu1~18.04.1_amd64.deb ...
Unpacking liblxc1 (3.0.3-0ubuntu1~18.04.1) ...
Selecting previously unselected package liblxc-common.
Preparing to unpack .../2-liblxc-common_3.0.3-0ubuntu1~18.04.1_amd64.deb ...
Unpacking liblxc-common (3.0.3-0ubuntu1~18.04.1) ...
Selecting previously unselected package libuv1:amd64.
Preparing to unpack .../3-libuv1_1.18.0-3_amd64.deb ...
Unpacking libuv1:amd64 (1.18.0-3) ...
Selecting previously unselected package lxcfs.
Preparing to unpack .../4-lxcfs_3.0.3-0ubuntu1~18.04.1_amd64.deb ...
Unpacking lxcfs (3.0.3-0ubuntu1~18.04.1) ...
Selecting previously unselected package lxd-client.
Preparing to unpack .../5-lxd-client_3.0.3-0ubuntu1~18.04.1_amd64.deb ...
Unpacking lxd-client (3.0.3-0ubuntu1~18.04.1) ...
Selecting previously unselected package uidmap.
Preparing to unpack .../6-uidmap_1%3a4.5-1ubuntu2_amd64.deb ...
Unpacking uidmap (1:4.5-1ubuntu2) ...
Selecting previously unselected package xdelta3.
Preparing to unpack .../7-xdelta3_3.0.11-dfsg-1ubuntu1_amd64.deb ...
Unpacking xdelta3 (3.0.11-dfsg-1ubuntu1) ...
Selecting previously unselected package lxd.
Preparing to unpack .../8-lxd_3.0.3-0ubuntu1~18.04.1_amd64.deb ...
Adding system user `lxd' (UID 124) ...
Adding new user `lxd' (UID 124) with group `nogroup' ...
Creating home directory `/var/lib/lxd/' ...
Adding group `lxd' (GID 128) ...
Done.
Unpacking lxd (3.0.3-0ubuntu1~18.04.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
Setting up libuv1:amd64 (1.18.0-3) ...
Setting up uidmap (1:4.5-1ubuntu2) ...
Setting up lxd-client (3.0.3-0ubuntu1~18.04.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.23) ...
Setting up ebtables (2.0.10.4-3.5ubuntu2.18.04.3) ...######################################..............................]
Created symlink /etc/systemd/system/multi-user.target.wants/ebtables.service → /lib/systemd/system/ebtables.service.
update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults
Setting up lxcfs (3.0.3-0ubuntu1~18.04.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/lxcfs.service → /lib/systemd/system/lxcfs.service.
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up xdelta3 (3.0.11-dfsg-1ubuntu1) ...
Setting up liblxc1 (3.0.3-0ubuntu1~18.04.1) ...
Setting up liblxc-common (3.0.3-0ubuntu1~18.04.1) ...
Setting up lxd (3.0.3-0ubuntu1~18.04.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/lxd-containers.service → /lib/systemd/system/lxd-containers.service.
Created symlink /etc/systemd/system/sockets.target.wants/lxd.socket → /lib/systemd/system/lxd.socket.
Setting up lxd dnsmasq configuration.
To go through the initial LXD configuration, run: lxd init
Processing triggers for systemd (237-3ubuntu10.23) ...
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

Step2: Installing ZFS Tools


You can setup LXD using ZFS storage backend. And this file system can provide a copy-on-write functionality and it allow you to use the advanced LXD features, like disk quotas, instant container creation from an image, etc.
To install ZFS tools, just issue the following command in terminal:

$ sudo apt install zfsutils-linux

Outputs:

root@devops:/home/devops# sudo apt install zfsutils-linux
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-zed
Suggested packages:
nfs-kernel-server samba-common-bin zfs-initramfs | zfs-dracut
The following NEW packages will be installed:
libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-zed zfsutils-linux
0 upgraded, 6 newly installed, 0 to remove and 64 not upgraded.
Need to get 1,168 kB of archives.
After this operation, 4,259 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
……
zfs-import-scan.service is a disabled or a static unit, not starting it.
Setting up zfs-zed (0.7.5-1ubuntu16.6) ...
Created symlink /etc/systemd/system/zed.service → /lib/systemd/system/zfs-zed.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-zed.service → /lib/systemd/system/zfs-zed.service.
Processing triggers for libc-bin (2.27-3ubuntu1) ...

Step3: Setting Up LXD Container


Once LXD package is installed successfully on your system, you can proceed to setup the LXD daemon. It will also set up both storage and networking options, just run the below command:

$ sudo lxd init

Outputs:

root@devops:/home/devops# lxd init

Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]: LxdDirectory
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
Would you like LXD to be available over the network? (yes/no) [default=no]:
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:

Note: it will ask a series of questions on how to configure the LXD daemon.
Once installed on your Ubuntu system, you need to make sure that your current user is part of the lxd group.

For example, if you current logging user is devops, you need to add this user to lxd group so that this user can access the LXD daemon locally. If not, just type the following command:

$ sudo adduser devops lxd

The new group will be effective at the next login session, to apply it to the current shell, you still need to run the following command for lxd group:

$ newgrp lxd

Step4: Launching LXD Container


Now you can start to use the LXD to create your first LXD container.
Firstly, you need to check if the client can connect to the LXD daemon with the following command:

$ lxc list

Outputs:

root@devops:/home/devops# lxc list
+------+-------+------+------+------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+------+-------+------+------+------+-----------+

Before launching LXD Container, you can list all available images from remote server, just type:

$ lxc image list iamges:

This command will list all images that you can use, see below screenshot.

install lxc container1
Assuming that you want to launch you first Alpine Linux system in LXD container, just use the following command:

$ lxc launch images:alpine/3.9  myalpineContainer

Outputs:

devops@devops:~$ lxc launch images:alpine/3.9  myalpineContainer
Creating myalpineContainer
Starting myalpineContainer

Note: alpine/3.9 is the image name and myalpineContainer is your container name. If you do not provide the container name, it will generate a random name.

This command will download the official Alpine 3.9  x86_64 image and then launch it.

List All Existing LXD Containers

If you want to list all existing LXD containers in your Ubuntu server, just use the following command:

$ lxc list

Outputs:

devops@devops:~$ lxc list
+-------------------+---------+----------------------+-----------------------------------------------+------------+-----------+
|       NAME        |  STATE  |         IPV4         |                     IPV6                      |    TYPE    | SNAPSHOTS |
+-------------------+---------+----------------------+-----------------------------------------------+------------+-----------+
| myalpineContainer | RUNNING | 10.128.138.16 (eth0) | fd42:841b:d3e7:7c96:216:3eff:fe5d:887c (eth0) | PERSISTENT | 0         |
+-------------------+---------+----------------------+-----------------------------------------------+------------+-----------+

Step5: Managing LXD Container


Executing command in the Container

If you want to execute commands in the specified container, you can use lxc exec command on your Ubuntu server.

For example, you want to execute “ls -a /” command on your first CentOS container, just issue the following command:

$ lxc exec myalpineContainer – ls -la /

Outputs:

devops@devops:~$ lxc exec myalpineContainer -- ls -la /
total 60
drwxr-xr-x   19 root     root          4096 Jul  2 13:00 .
drwxr-xr-x   19 root     root          4096 Jul  2 13:00 ..
drwxr-xr-x    2 root     root          4096 Jul  2 13:00 bin
drwxr-xr-x    7 root     root           420 Jul  3 13:36 dev
drwxr-xr-x   19 root     root          4096 Jul  3 13:36 etc
drwxr-xr-x    2 root     root          4096 Jan 29 20:53 home
drwxr-xr-x    6 root     root          4096 Jul  2 13:00 lib

Login and Get Bash Shell in a Specified Container

If you want to login and get a sh shell from a given LXD container, just run:

$ lxc exec myalpineContainer sh

Then you run Linux command on your CentOS container, such as:

$ ifconfig
$  hostname

outputs:

devops@devops:~$ sudo lxc exec myalpineContainer sh
~ # hostname
myalpineContainer
~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3E:5D:88:7C
inet addr:10.128.138.16  Bcast:10.128.138.255  Mask:255.255.255.0
inet6 addr: fd42:841b:d3e7:7c96:216:3eff:fe5d:887c/64 Scope:Global
inet6 addr: fe80::216:3eff:fe5d:887c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:54 errors:0 dropped:0 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7054 (6.8 KiB)  TX bytes:2079 (2.0 KiB)

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:65536  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Stop LXD Container

If you want to stop a running LXD Container, just type:

$ lxc stop myalpineContainer

Start LXD Container

If you want to start a stopped LXD Container, just type:

$ lxc start myalpineContainer

Restart LXD Container

If you want to restart you running containers, just type:

$ lxc restart myalpineContainer

Delete LXD Container

If you want to delete an unwanted LXD container from your system, just type:

$ lxc delete myalpineContainer

Get Information of a LXD Container

If you want to get more detailed information about a given LXD container, such as: IP address, Memory usage, Network Usage, etc. just type:

$ lxc info myalpineContainer

Outputs:

devops@devops:~$ lxc info myalpineContainer
Name: myalpineContainer
Remote: unix://
Architecture: x86_64
Created: 2019/07/03 13:36 UTC
Status: Running
Type: persistent
Profiles: default
Pid: 5822
Ips:
  eth0: inet    10.128.138.16   vethTDVTP0
  eth0: inet6   fd42:841b:d3e7:7c96:216:3eff:fe5d:887c  vethTDVTP0
  eth0: inet6   fe80::216:3eff:fe5d:887c        vethTDVTP0
  lo:   inet    127.0.0.1
  lo:   inet6   ::1
Resources:
  Processes: 5
  CPU usage:
    CPU usage (in seconds): 0
  Memory usage:
    Memory (current): 1.55MB
    Memory (peak): 3.73MB
  Network usage:
    eth0:
      Bytes received: 7.37kB
      Bytes sent: 2.08kB
      Packets received: 57
      Packets sent: 16
    lo:
      Bytes received: 0B
      Bytes sent: 0B
      Packets received: 0
      Packets sent: 0

Conclusion


You should know that how to install and use LXD to create your first Container on your Ubuntu or Debian Linux. If you want to see more detailed information about LXD, you can directly go to its official web site.

How to Save and Quit vi/vim Text Editor

save and exit vi vim text editor5

This post will guide you how to launch vim or vi Text editor to open a new file under Linux operating system. How do I save a file and quit from the current vi or vim text editor in Linux.

What is vi or Vim Test Editor


save and exit vi vim text editor5Vim or vi is a text editor for Unix or Linux system, and it is also designed for both from a command line interface and as a standalone application in a graphical user interface. And vi or Vim is a free and open-source software. You can use this text editor to create new files or edit configuration file under Linux system.

Vim is a highly configurable text editor for efficiently creating and changing any kind of text. It is included as “vi” with most UNIX systems and with Apple OS X.

Launch vi/vim Text Editor


For a vi or vim text editor user, if you want to create a new file under Linux terminal, and you can use vi or vim command with your file name, just type the following command:

$ sudo vi filename
$ sudo vim filename

save and exit vi vim text editor1

Exit without Saving Changes


If you have created a new file with vi or vim text editor, and you want to exit vi or vim text editor without saving any changes, you need to do the following steps in your current vim or vi text editor:

Step1: press the Esc key to quit the insert mode to command mode.

Step2: type :q! in command mode

save and exit vi vim text editor2

Step3: press Enter key on your keyboard. Then it will quit your current text editor and discard any changes you made before.

Exit with Saving Changes


If you want to save and quit the current vi or vim text editor with saving any changes under Linux terminal, you can do the following steps:

Step1: if you are in the Insert mode, then you need to press Esc key on your keyboard to back to command mode.

save and exit vi vim text editor3

Step2:  press colon character (:) in the command mode, and then enter the x! or wq, then press Enter key to quit the current text editor, and all changes in your file should be saved.

save and exit vi vim text editor4

Conclusion


You should know that how to create or save files with vi or vim text editor and exit the text editor under Linux operating system. If you want to see more detailed information about vi or vim text editor , you can directly go to its official web site.

How to Exit or Quit Top Command in Linux or Unix Terminal

This post will guide you how to exit from top command without closing my Linux terminal. For a Linux user, if you want to check the usage or information about all process in your current Linux operating system, you can use top command to get it.

The top command will display a dynamic real-time view of a running system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel.

To display Linux processes, type the following command in your Linux terminal:

$ top

Outputs:

top - 20:19:37 up 1:37, 1 user, load average: 0.00, 0.01, 0.05
Tasks: 160 total, 1 running, 159 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.3 us, 0.7 sy, 0.0 ni, 99.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 1014972 total, 69732 free, 558076 used, 387164 buff/cache
KiB Swap: 2097148 total, 2097148 free, 0 used. 243328 avail Mem

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5204 root 20 0 162012 2284 1588 R 0.7 0.2 0:00.04 top
5068 root 20 0 0 0 0 S 0.3 0.0 0:00.52 kworker/0:2
1 root 20 0 128284 6856 4176 S 0.0 0.7 0:01.62 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.16 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
6 root 20 0 0 0 0 S 0.0 0.0 0:00.12 kworker/u2:0
7 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:00.76 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-dra+
11 root rt 0 0 0 0 S 0.0 0.0 0:00.08 watchdog/0
13 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
14 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns

When you are in interactive mode of top command, you can send signals to processes. And if you want to quit the current top command, you just press q key on your keyboard to exit from top command session.

And if you get more help in the interactive mode of top, you can press ? or h key to accomplish the result.

For example, when you press h key, it would display the below similar outputs:

Help for Interactive Commands - procps-ng version 3.3.10
Window 1:Def: Cumulative mode Off. System: Delay 3.0 secs; Secure mode Off.

Z,B,E,e Global: 'Z' colors; 'B' bold; 'E'/'e' summary/task memory scale
l,t,m Toggle Summary: 'l' load avg; 't' task/cpu stats; 'm' memory info
0,1,2,3,I Toggle: '0' zeros; '1/2/3' cpus or numa node views; 'I' Irix mode
f,F,X Fields: 'f'/'F' add/remove/order/sort; 'X' increase fixed-width

L,&,<,> . Locate: 'L'/'&' find/again; Move sort column: '<'/'>' left/right
R,H,V,J . Toggle: 'R' Sort; 'H' Threads; 'V' Forest view; 'J' Num justify
c,i,S,j . Toggle: 'c' Cmd name/line; 'i' Idle; 'S' Time; 'j' Str justify
x,y . Toggle highlights: 'x' sort field; 'y' running tasks
z,b . Toggle: 'z' color/mono; 'b' bold/reverse (only if 'x' or 'y')
u,U,o,O . Filter by: 'u'/'U' effective/any user; 'o'/'O' other criteria
n,#,^O . Set: 'n'/'#' max tasks displayed; Show: Ctrl+'O' other filter(s)
C,... . Toggle scroll coordinates msg for: up,down,left,right,home,end

k,r Manipulate tasks: 'k' kill; 'r' renice
d or s Set update interval
W,Y Write configuration file 'W'; Inspect other output 'Y'
q Quit
( commands shown with '.' require a visible task display window )
Press 'h' or '?' for help with Windows,
Type 'q' or to continue

That’s it!

 

How to Reset or Change Password for MySQL/MariaDB User

This post will guide you how to create, change or reset MySQL or MariaDB user password under Linux operating system terminal. For a Linux new user or MySQL new user, how to reset a password for a normal user in the MySQL server.

mysql

MySQL is an open-source relational database management system. Its name is a combination of “My”, the name of co-founder Michael Widenius’s daughter, and “SQL”, the abbreviation for Structured Query Language.

Creating New MySQL User


Assuming that you have installed MySQL server package on your current Linux operating system. And then you want to create your first normal MySQL User, just do the following steps:

Step1: login to the MySQL server with the following command in the Linux terminal:

$ mysql -u root -p

Then you need to type the password of root for authentication.

Outputs:

root@devops:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.26-0ubuntu0.18.04.1-log (Ubuntu)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

Step2: switch to the MySQL database, type the following SQL statements at the mysql> prompt to create a new user called “Jeffery“.

Mysql> user mysql;
Mysql> create user 'jeffery'@'localhost' identified by 'password';

Outputs:

mysql> create user 'jeffery'@'localhost' identified by 'password';
Query OK, 0 rows affected (0.01 sec)

Note:

  • Jeffery is the user name that you want to create new MySQL user.
  • Localhost: this user can only allow to connect to this MySQL server from localhost, if you want to allow remote host to connect to this MySQL server, just change localhost to a pattern character %.
  • Password is the password of your new MySQL user.

Step3: you can run the following select statement to check if “Jeffery” user is created or not.

Mysql> select user from mysql.user

Outputs:

mysql> select user from mysql.user;
+------------------+
| user |
+------------------+
| replica |
| debian-sys-maint |
| jeffery |
| joomlauser |
| mysql.session |
| mysql.sys |
| root |
+------------------+
7 rows in set (0.00 sec)

You would see that “Jeffery” user is created.

Granting Privilege for New MySQL User


If you want to grant more privileges for your newly created MySQL user “Jeffery”, you can use the following SQL statement syntax:

Grant privileges on database.tablename to ‘username’@’host’ indentified by ‘password’;

Note:

  • Privileges: containing select, insert, update privileges, if you want to grant all privileges for user, just using “ALL” keyword.
  • Databasename: can only operate this specified database.
  • Tablename: can only operate this specified table in the above database.

For example, if you want to grant all privileges for all databases, just execute the following SQL statement:

Mysql> grant all on *.* to 'jeffery'@'%' identified by 'password';

Outputs:

mysql> grant all on *.* to 'jeffery'@'%' identified by 'password';
Query OK, 0 rows affected, 1 warning (0.00 sec)

Then you still need to flush privileges with the following command:

Mysql> flush privileges;

Changing or Reset Password for MySQL User


If you want to change or reset password for a MySQL User called “Jeffery”, just use the following SQL statement:

Mysql> set password for 'jeffery'@'localhost' = PASSWORD('newpassword');

And if you want to change the current logging user, you can also use another simple SQL statement:

Mysql> set password=PASSWORD(“newpassword”);

Recover Your MySQL Password


If you forgot your MySQL root user password, how to recover the password, just do the following these steps:

Step1:  you need to update mysqld.cnf configuration file located in /etc/mysql/mysql.conf.d/ directory with vim text editor, and then add the following lines under [mysqld] section.

 

$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
skip-grant-tables

save and close the file.

Step2: restart the MySQL server with the following command :

$ sudo systemctl restart mysql

Step3: login to the MySQL server, press Enter key on your keyboard, it will not prompt for a password. type:

$ mysql -u root -p

Step4: you need to run the following MySQL commands to reset the root password:

Mysql> use mysql;
Mysql> update user set authentication_string=password('NEWPASSWORD') where user='root';
Mysql> flush privileges;

Delete Your MySQL User


If you want to remove a normal user called “Jeffery” from your MySQL server, you can use the following MySQL command:

Mysql> drop user Jeffery;

Outputs:

mysql> drop user jeffery;
Query OK, 0 rows affected (0.01 sec)

Then you can run the select command to check if it is deleted.

Mysql> select user from mysql.user;

Outputs:

mysql> select user from mysql.user;
+------------------+
| user |
+------------------+
| replica |
| debian-sys-maint |
| joomlauser |
| mysql.session |
| mysql.sys |
| root |
+------------------+
6 rows in set (0.00 sec)

Conclusion


You should know that how to create MySQL user, grant privileges for MySQL user, or recovery password for root user under Linux system.

How to Setup PF Firewall on FreeBSD

freebsd

This post will guide you how to setup PF (Packet Filter) firewall to secure your FreeBSD server. How do I configure PF firewall on my FreeBSD server to protect my Web server.

freebsd

PF is a BSD licensed stateful packet filter, a central piece of software for firewalling. It is comparable to netfilter, ipfw, and ipfilter. PF was developed for OpenBSD, but has been ported to many other operating systems.

Setup PF Firewall


If you want to configure PF firewall on your FreeBSD server, just do the following steps:

Step1: you need to create a configuration file called pf.conf to define your PF rules with vim text editor:

$ sudo vim /etc/pf.conf
ext_if = "fxp0"
int_if = "dc0"
lan_net = "192.168.0.0/24"

# scrub incoming packets
scrub in all

# setup a default deny policy
block in all
block out all

# pass traffic on the loopback interface in either direction
pass quick on lo0 all

# activate spoofing protection for the internal interface.
antispoof quick for $int_if inet

# only allow ssh connections from the local network if it‘s from the
# trusted computer, 192.168.0.15. use "block return" so that a TCP RST is
# sent to close blocked connections right away. use "quick" so that this
# rule is not overridden by the "pass" rules below.
block return in quick on $int_if proto tcp from ! 192.168.0.15 \
to $int_if port ssh flags S/SA

# pass all traffic to and from the local network
pass in on $int_if from $lan_net to any
pass out on $int_if from any to $lan_net

# pass tcp, udp, and icmp out on the external (Internet) interface.
# keep state on udp and icmp and modulate state on tcp.
pass out on $ext_if proto tcp all modulate state flags S/SA
pass out on $ext_if proto { udp, icmp } all keep state

# allow ssh connections in on the external interface as long as they‘re
# NOT destined for the firewall (i.e., they‘re destined for a machine on
# the local network). log the initial packet so that we can later tell
# who is trying to connect. use the tcp syn proxy to proxy the connection.
pass in log on $ext_if proto tcp from any to { !$ext_if, !$int_if } \
port ssh flags S/SA synproxy state

Step2: you need to change /etc/rc.conf file to add the following lines:

pf_enable="YES"
pf_rules="/etc/pf.conf"
pflog_enable="YES"
pflog_logfile="/var/log/pf.log"

save and close the file.

Note:
• pf_enable -turn on/off PF service
• pf_rules – contain PF rules
• pflog_enable – turn on/off the logging support for PF firewall
• pflog_logfile – specified the log file for pflogd service

Step3: you need to start the pf service with the following command:

# service pf start

Or you can also reboot the system:

# reboot

You can use tcpdump command to check who is trying to connect to your FreeBSD server in real-time with the following command:

# tcpdump -n -e -ttt -I pflog0

Conclusion


You should know that how to setup PF firewall on FreeBSD. If you want to see more detailed information about PF, you can directly go to its official web site.