How to Install and Use Wine on Ubuntu 16.04 or 18.04

This post will guide you how to install and use Wine on your Ubuntu Linux 16.04 or 18.04. How do I install the latest Wine Tool from the Default official Wine repository on your Ubuntu system. How to uninstall wine from your Ubuntu system.

install and use wine on ubuntu12

What is Wine?


Wine is a free and open source compatibility layer that can be used to run Microsoft Windows program on Unix-like operating system, such as: Linux, Unix, or FreeBSD systems.

Wine is also provide a software library, called Winelib, it can be used to help developers to port Windows applications to Unix-like systems.

Wine is not an Emulator of Unix-like system, it is a interface that used to translate windows system calls into equivalent POSIX calls used by Unix-like system.

So far, Wine tool can support thousands of windows applications to be run on Unix-like system normally.

At the time of writing this post, the stable version of Wine is 4.0. It is announced on January 22, 2019. You can download its source code from its official site of WineHQ. You can also use the APT Tool to install Wine on Ubuntu system. And the latest development version of Wine 4.7 is released. And Wine team has announced the latest wine development release 4.7 on April 26, 2019.

What is New in Wine 4.7?


The key changes that comes with Wine 4.7 as stated in its official announcement are as below:

  • Support for built-in libraries in PE format even on Unix.
  • Updated version of the Mono engine.
  • More implementation of the Debug Engine DLL.
  • Support for the Command Link standard control.
  • Improved Edit control sizing in CJK locales.
  • Various bug fixes.

You can get the source package of Wine 4.7 from here.

Installing Wine From Default APT Repository


The Wine is already available on the default Ubuntu repositories. But it may be not the latest version. If you want to install Wine 3.0 on your Ubuntu system, you can directly install it from the Ubuntu default APT repository, just use the following command to install wine 3.0:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install wine64

Outputs:

devops@ubuntu:~$ sudo apt install wine64
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
......
ocl-icd-libopencl1:i386 wine-stable wine32:i386 zlib1g:i386
Suggested packages:
......
libwine-gecko-2.47:i386 wine32-preloader:i386 libwine-gecko-2.47
wine64-preloader
The following NEW packages will be installed:
......
ocl-icd-libopencl1
ocl-icd-libopencl1:i386 wine-stable wine32:i386 wine64 zlib1g:i386
0 upgraded, 169 newly installed, 0 to remove and 22 not upgraded.
Need to get 104 MB of archives.
After this operation, 752 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

You need to press y key when you are prompted with a Y/n prompt for installation of Wine. After installed, the Wine Application should be installed and ready for use on your Ubuntu system.

If you are using 32-bit Ubuntu system, you need to use the following apt install command to install wine, type:

$ sudo apt install wine32

You can check the installation of Wine by verifying the version of Wine with the following command:

$ wine --version

Outputs:

$ wine --version
wine-3.0 (Ubuntu 3.0-1ubuntu1)

Installing Wine from Default Wine Official Repository


If you want to install the latest stable version of Wine application, you should be better to install it from wineHQ repository. And the current latest stable version is Wine 4.0. Just do the following steps:

#1 Enable 32-bit architecture firstly, if your system is 64 bit, type:

$ sudo dpkg --add-architecture i386

#2 Download and add the repository key to your system, using the following commands:

$ wget -nc https://dl.winehq.org/wine-builds/winehq.key
$ sudo apt-key add winehq.key

Outputs:

devops@ubuntu:~$ wget -nc https://dl.winehq.org/wine-builds/winehq.key
--2019-05-05 02:34:19-- https://dl.winehq.org/wine-builds/winehq.key
Resolving dl.winehq.org (dl.winehq.org)... 151.101.110.217
Connecting to dl.winehq.org (dl.winehq.org)|151.101.110.217|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 3220 (3.1K) [application/pgp-keys]
Saving to: ‘winehq.key’

winehq.key 100%[=========================>] 3.14K --.-KB/s in 0s

2019-05-05 02:34:21 (20.9 MB/s) - ‘winehq.key’ saved [3220/3220]

devops@ubuntu:~$ sudo apt-key add winehq.key
OK

#3 Add the WineHQ repository in your system based on your Ubuntu system and version.

For Ubuntu 19.04,type:

$ sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ disco main'

For Ubuntu 18.10, type:

$ sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ cosmic main'

For Ubuntu 18.04, type:

$ sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'

For Ubuntu 16.04, type:

$ sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'

Outputs:

devops@ubuntu:~$ sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ bionic main'
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Hit:2 http://mirrors.aliyun.com/ubuntu bionic-security InRelease
Hit:3 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease
Hit:4 http://mirrors.aliyun.com/ubuntu bionic-proposed InRelease
Hit:5 http://mirrors.aliyun.com/ubuntu bionic-backports InRelease
Get:6 https://dl.winehq.org/wine-builds/ubuntu bionic InRelease [6,257 B]
Get:7 https://dl.winehq.org/wine-builds/ubuntu bionic/main i386 Packages [382 kB]
Get:8 https://dl.winehq.org/wine-builds/ubuntu bionic/main amd64 Packages [364 kB]
Fetched 752 kB in 2s (447 kB/s)
Reading package lists... Done

#4 install the latest Wine from the APT repository with the following command:

$ sudo apt update
$ sudo apt install --install-recommends winehq-stable

Outputs:

devops@ubuntu:~$ sudo apt-get install --install-recommends winehq-stable
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
......
ocl-icd-libopencl1:i386 wine-stable wine-stable-amd64 wine-stable-i386:i386
zlib1g:i386
Suggested packages:
......
ocl-icd-libopencl1:i386 wine-stable wine-stable-amd64 wine-stable-i386:i386
winehq-stable zlib1g:i386
0 upgraded, 172 newly installed, 0 to remove and 0 not upgraded.
Need to get 112 MB of archives.
After this operation, 813 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
......
Setting up libsdl2-2.0-0:i386 (2.0.8+dfsg1-1ubuntu1.18.04.3) ...
Setting up libsane1:i386 (1.0.27-1~experimental3ubuntu2) ...
Setting up libtheora0:i386 (1.1.1+dfsg.1-14) ...
Setting up libglx0:i386 (1.0.0-2ubuntu2.2) ...
Setting up gstreamer1.0-plugins-base:i386 (1.14.1-1ubuntu1~ubuntu18.04.2) ...
Setting up wine-stable-i386:i386 (4.0~bionic) ...
Setting up libgl1:i386 (1.0.0-2ubuntu2.2) ...
Setting up libglu1-mesa:i386 (9.0.0-2.1build1) ...
Setting up wine-stable (4.0~bionic) ...
Setting up libgl1-mesa-glx:i386 (18.2.8-0ubuntu0~18.04.2) ...
Setting up winehq-stable (4.0~bionic) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...

Note: if you have previously installed a Wine package from another repository, you need to remove it and any packages that depend it. Before attempting to install the WineHQ packages, as they may cause dependency conflicts.

There are three options about which release of Wine you want to install: Stable version, Development version, and Staging version.

If you want to install the latest development version of Wine, just using the following apt command:

$ sudo apt install --install-recommends winehq-devel

If you want to install the latest staging version of Wine, just using the following apt command:

$ sudo apt install --install-recommends winehq-staging

If you also got the unmet dependencies error during installation of Wine from the WineHQ default repository as following error messages:

The following packages have unmet dependencies:
winehq-stable : Depends: wine-stable (= 4.0~cosmic) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

You can use the following command to install the stable version of WineHQ with aptitude tool, type:

$ sudo apt install aptitude
$ sudo aptitude install winehq-stable

After installed Wine Packge, you can verify the Wine installation by checking the version of Wine, type:

$ wine --version

Outputs:

devops@ubuntu:~$ wine --version
wine-4.0

Configuring Wine


Once Wine installed on your system, you can start to configure your Wine Application by running the following command:

$ wincfg

Then application will prompt you to install Mono and Gecko to be used to set up your Wine environment. The Wine Mono Installer dialog box will appear. You just need to click Install button.

install and use wine on ubuntu1

Then the Wine Mono tool should be downloaded and installed it on your system.

install and use wine on ubuntu2

Next, the Wine Gecko Installer dialog box will appear, click Install button. And the Gecko should be installed.

install and use wine on ubuntu3

Last, the Wine Configuration window box will appear. You can try to configure various Wine settings, such as: Audio, Graphics, Libraries, Drives, etc.

install and use wine on ubuntu4

install and use wine on ubuntu5

Installing or Launching Windows Application using Wine


After configured Wine Environment, you can try to install or start a windows application on your Ubuntu Linux system.

At this post, we will show you how to start a Putty.exe windows application on your system. Firstly, you need to launch your Firefox browser to download the Putty.exe program from the Putty official web page.

install and use wine on ubuntu6

Then go the download directory on your system to find your putty.exe file, and right click on it, select Open With Other Application from the pop-up menu list, and then select Wine Windows Program Loader option from the Recommended Applications list box. click Select button.

install and use wine on ubuntu11

install and use wine on ubuntu9

Putty application will be launched on your Ubuntu system.

install and use wine on ubuntu10

Uninstalling Wine


If you want to remove Wine from your system, you can execute the following apt command in your Ubuntu terminal, type:

$ sudo apt purge winehq-stable

Outputs:

devops@ubuntu:~$ sudo apt purge winehq-stable
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
winehq-stable*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 73.7 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 171318 files and directories currently installed.)
Removing winehq-stable (4.0~bionic) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...

Conclusion


You should know that how to install and use Wine on your Ubuntu 16.04 or 18.04 or Debian Linux. You also should know that how to start a Windows Application under Wine environment on Ubuntu system.

How to Install Tor Browser on Ubuntu 16.04 or 18.04

This post will guide you how to install and use Tor Browser on your Ubuntu Linux 16.04 or 18.04. How do I install and use Tor Browser for encrypting web traffic through the Tor network on Ubuntu system.

install tor browser ubuntu4

What is Tor Browser?


Tor Browser is free and open source software for enabling anonymous communication. it can be used to make all users look the same making it difficult for you to be fingerprinted based on your browser and device information.

Tor browser is to protect your onLine privacy, it routes your all web traffic through its own Tor network (a distributed network of relays run by volunteers all around the world). It can prevent somebody to watch your connection data from learning what sites you have visited. It also can prevent the website you visit from learning your location.

When you use Tor Browser to access one website, all of contents you watched are encrypted and protected from Tor network.

Installing Tor Browser with APT Repositories


Tor Browser package is already available on the default Ubuntu APT repository, so you just need to open up Ubuntu terminal and execute the following apt command to install it:

$ sudo apt install torbrowser-launcher

Outputs:

devops@devops:~$ sudo apt install torbrowser-launcher
[sudo] password for devops:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
python-attr python-automat python-cairo python-click python-colorama python-constantly python-gobject-2 python-gtk2
python-hyperlink python-incremental python-lzma python-openssl python-pam python-parsley python-psutil python-pyasn1
python-pyasn1-modules python-serial python-service-identity python-twisted python-twisted-bin python-twisted-core
python-txsocksx python-zope.interface tor tor-geoipdb torsocks
Suggested packages:
python-attr-doc python-gobject-2-dbg python-gtk2-doc python-openssl-doc python-openssl-dbg python-pam-dbg
python-psutil-doc python-wxgtk3.0 | python-wxgtk python-twisted-bin-dbg python-tk python-glade2 python-qt3
python-wxgtk3.0 mixmaster tor-arm apparmor-utils obfs4proxy python-pygame
The following NEW packages will be installed:
python-attr python-automat python-cairo python-click python-colorama python-constantly python-gobject-2 python-gtk2
python-hyperlink python-incremental python-lzma python-openssl python-pam python-parsley python-psutil python-pyasn1
python-pyasn1-modules python-serial python-service-identity python-twisted python-twisted-bin python-twisted-core
python-txsocksx python-zope.interface tor tor-geoipdb torbrowser-launcher torsocks
0 upgraded, 28 newly installed, 0 to remove and 45 not upgraded.
Need to get 5,953 kB of archives.
After this operation, 34.2 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Get:25 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 python-txsocksx all 1.15.0.2-1 [17.1 kB]
Get:26 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 torbrowser-launcher amd64 0.2.9-2 [215 kB]
Get:27 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 torsocks amd64 2.2.0-2 [59.1 kB]
Get:28 http://mirrors.aliyun.com/ubuntu bionic/universe amd64 tor-geoipdb all 0.3.2.10-1 [793 kB]
Fetched 5,953 kB in 3s (1,977 kB/s)
Setting up python-txsocksx (1.15.0.2-1) ...
Setting up torbrowser-launcher (0.2.9-2) ...
Processing triggers for ureadahead (0.100.0-20) ...

Once Tor Browser is intalled on your Ubuntu system, you can start it directly by executing the following command:

$ torbrowser-launcher

Installing Tor Browser Through Archive File


At the time of writing this post, the latest version of Tor Browser is 8.0.2. You can do the following steps to install Tor Browser with Archive package:

#1 You can download it from GitHub. Just type the following wget command:

$ sudo wget https://github.com/TheTorProject/gettorbrowser/releases/download/v8.0.2/tor-browser-linux64-8.0.2_en-US.tar.xz

Outputs:

devops@ubuntu:~$ wget https://github.com/TheTorProject/gettorbrowser/releases/download/v8.0.2/tor-browser-linux64-8.0.2_en-US.tar.xz
--2019-04-25 07:08:37-- https://github.com/TheTorProject/gettorbrowser/releases/download/v8.0.2/tor-browser-linux64-8.0.2_en-US.tar.xz
Resolving github.com (github.com)... 52.74.223.119, 13.250.177.223, 13.229.188.59
Connecting to github.com (github.com)|52.74.223.119|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/51808714/8bf0c080-d1ef-11e8-969a-64c6a6e30905?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190425%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190425T140839Z&X-Amz-Expires=300&X-Amz-Signature=aaeb6852508fd320bc3381ef1f88ab4c95fc906c445aa77bff8bb88c5f76187b&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dtor-browser-linux64-8.0.2_en-US.tar.xz&response-content-type=application%2Foctet-stream [following]
--2019-04-25 07:08:39-- https://github-production-release-asset-2e65be.s3.amazonaws.com/51808714/8bf0c080-d1ef-11e8-969a-64c6a6e30905?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190425%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190425T140839Z&X-Amz-Expires=300&X-Amz-Signature=aaeb6852508fd320bc3381ef1f88ab4c95fc906c445aa77bff8bb88c5f76187b&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dtor-browser-linux64-8.0.2_en-US.tar.xz&response-content-type=application%2Foctet-stream
Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.178.123
Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.178.123|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 74913044 (71M) [application/octet-stream]
Saving to: ‘tor-browser-linux64-8.0.2_en-US.tar.xz’

tor-bro 100%[=============================> ] 71M 41.4KB/s eta 2m 10s
......

#2 After Torbrowser-laucher package is downloaded, and you need to extract it with the following command:

$ tar xJpf tor-browser-linux64-8.0.2_en-US.tar.xz

#3 changing the current working directory to tor-browser_en-US, type:

$ cd torbrowser-launcher-0.3.1

#4 start tor browser with the following command:

$ ./start-tor-browser.desktop

install tor browser ubuntu1

#5 click Connect button to connect to a Tor network for the Tor Browser.

#6 wait while it will establish a connection to the Tor network. it may take several minutes.

install tor browser ubuntu2

#7 you can click Test Tor Network Settings link to peform Tor Browser test.

install tor browser ubuntu3

Installing Tor Browser via PPA


If you want to always have the latest version of the torbrowser-launcher package before your distribution gets it, you can use the below PPA to install it:

$ sudo add-apt-repository ppa:micahflee/ppa
$ sudo apt-get update
$ sudo apt-get install torbrowser-launcher

Updating Tor Browser


When a new version of Tor browser is released, you can update it through your Ubuntu Software Center or you can also run the following apt command to update it.type:

$ sudo apt udpate

$ sudo apt upgrade

Uninstalling Tor Browser


If you want to uninstall Tor Browser from your Ubuntu system, you can use apt remove command to uninstall it, type:

$ sudo apt remove torbrowser-launcher

If Tor Browser is installed by Tor Archive package, you just need to delete those archive files directly.

Conclusion


You should know that how to install and use Tor Browser on your Ubuntu 16.04 or 18.04 or Debian Linux.

How to Install and Configure Elasticsearch on Ubuntu 16.04 or 18.04

This post will guide you how to install, configure, secure, and use an Elasticsearch server on your Ubuntu Linux 16.04 or 18.04. How do I install one of the most popular text indexing and search engine, Elasticsearch on Ubuntu system.

install elasticsearch2

What is ElasticSearch?


Elasticsearch is an open source search engine based on the Lucene library. And it provides a distributed, multitenant-capable full-text search engine with an HTTP web interface (RESTful) and schema-free JSON documents. So you can use HTTP methods (GET, POST, PUT, DELETE, etc.) in combination with an HTTP URI to operate your data.

Elasticsearch is the most popular enterprise search engine followed by Apache Solr, also based on Lucene. And it can be used to search for all kind of text documents or analyzing big volumes of data in real time.

Elasticsearch is also one of the most popular NoSQL databases which is used to store and search for text based data.

Elasticsearch is developed in JAVA. It is freely available under the Apache 2 license, so it provide the most flexibility.

Prerequisites


You need to install the latest JDK version on your Ubuntu Linux, because Elasticsearch is developed in JAVA program language, and it need to have a JAVA Runtime Environment.

You will need to be logged in as a user with sudo privileges, so that you can install packages with dpkg or apt command on your Ubuntu system.

Step1: Installing JAVA


As we talked above, you need to firstly install JDK 8 package or high version on your Ubuntu system for JAVA Runtime Environment (JRE). You can install either the Oracle JAVA Standard Edition 8 or OpenJDK 8 on the system.

The OpenJDK 8 is already available in the default Ubuntu APT repository. So we try to install the OpenJDK 8 on this guide, just type the following command to update the packages index and installing OpenJDK 8:

$ sudo apt update
$ sudo apt install openjdk-8-jdk

Outputs:

devops@devops:~$ sudo apt install openjdk-8-jdk
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ca-certificates-java libxt-dev openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless
Suggested packages:
libxt-doc openjdk-8-demo openjdk-8-source visualvm icedtea-8-plugin fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei fonts-wqy-zenhei
The following NEW packages will be installed:
ca-certificates-java libxt-dev openjdk-8-jdk openjdk-8-jdk-headless openjdk-8-jre openjdk-8-jre-headless
0 upgraded, 6 newly installed, 0 to remove and 45 not upgraded.
Need to get 37.5 MB/37.5 MB of archives.
After this operation, 143 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y

After JDK package is installed, you can check the installation of JDK package by print the version of JDK installed, type:

$ java -version

Outputs:

devops@devops:~$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

From the above outputs, you would see that the OpenJDK Runtime Environment is available. You can also install Oracle JDK 8 to set up JRE.

Note: If you want to install the Oracle JAVA 8 on your Ubuntu system, just issue the following commands:

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt update
$ sudo apt install oracle-java8-installer –y

Step2: Downloading Elasticsearch Package


Once JAVA is installed on your system, and then you can download installation package of Elasticsearch to your local disk.

You can download the latest Elasticsearch archive file from official download page of elastic. Or you can also download directly Deb package of Elasticsearch from the official download page for your Ubuntu system.

Using one of the following command to get the Elasticsearch package, type:

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz

Or

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-amd64.deb .

Outputs:

[devops@devops ~]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
--2019-04-23 06:41:12-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
Resolving artifacts.elastic.co (artifacts.elastic.co)... 151.101.110.222, 2a04:4e42:1a::734
Connecting to artifacts.elastic.co (artifacts.elastic.co)|151.101.110.222|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 346760090 (331M) [application/x-gzip]
Saving to: ‘elasticsearch-7.0.0-linux-x86_64.tar.gz’

100%[======================================================================================================================>] 346,760,090 6.35MB/s in 58s

2019-04-23 06:42:11 (5.72 MB/s) - ‘elasticsearch-7.0.0-linux-x86_64.tar.gz’ saved [346760090/346760090]
devops@devops:~$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-amd64.deb .
--2019-04-24 17:53:39-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-amd64.deb
Resolving artifacts.elastic.co (artifacts.elastic.co)... 151.101.110.222, 2a04:4e42:1a::734
Connecting to artifacts.elastic.co (artifacts.elastic.co)|151.101.110.222|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 346791426 (331M) [application/octet-stream]
Saving to: ‘elasticsearch-7.0.0-amd64.deb’

elasticsearch-7.0.0-amd64.deb 100%[==========================================================================>] 330.73M 3.06MB/s in 77s

2019-04-24 17:54:57 (4.31 MB/s) - ‘elasticsearch-7.0.0-amd64.deb’ saved [346791426/346791426]

--2019-04-24 17:54:57-- http://./
Resolving . (.)... failed: Name or service not known.
wget: unable to resolve host address ‘.’
FINISHED --2019-04-24 17:54:57--
Total wall clock time: 1m 18s
Downloaded: 1 files, 331M in 1m 17s (4.31 MB/s)

devops@devops:~$ ls elasticsearch-7.0.0-amd64.deb
elasticsearch-7.0.0-amd64.deb

Note: At the time of writing this post, the latest version of Elasticsearch is 7.0.

Step3: Installing Elasticsearch


You can install Elasticsearch through either archive file or deb package downloaded in the above step. For Ubuntu, it is best to use the deb package which will install everything you need to run Elasticsearch.

For Elasticsearch archive file, you just need to extract it on your system with the following command:

$ tar -zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz

For Elasticsearch Deb package, you can install it with dpkg command, type:

$ sudo dpkg –i elasticsearch-7.0.0-amd64.deb

Ouputs:

devops@devops:~$ sudo dpkg -i elasticsearch-7.0.0-amd64.deb
[sudo] password for devops:
Selecting previously unselected package elasticsearch.
(Reading database ... 322964 files and directories currently installed.)
Preparing to unpack elasticsearch-7.0.0-amd64.deb ...
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Unpacking elasticsearch (7.0.0) ...
Setting up elasticsearch (7.0.0) ...
Created elasticsearch keystore in /etc/elasticsearch
Processing triggers for systemd (237-3ubuntu10.19) ...
Processing triggers for ureadahead (0.100.0-20) ...

Elasticsearch will be installed in /usr/share/elasticsearch directory, and its configuration files locates in /etc/elasticsearch directory. And its init script is added into /etc/init.d/ directory.
Once the installation process is complete, you need to start and enable elaticsearch service by the following command:

$ sudo systemctl start elasticsearch.service
$ sudo systemctl enable elasticsearch.service

Outputs:

devops@devops:~$ sudo systemctl start elasticsearch.service
devops@devops:~$ sudo systemctl enable elasticsearch.service
Synchronizing state of elasticsearch.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable elasticsearch

Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.

Then you can send an HTTP GET request to the default port 9200 of Elasticsearch service using Curl command, type:

$ curl -X GET "localhost:9200/"

Outputs:

devops@devops:~$ curl -X GET "localhost:9200/"
{
"name" : "devops",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "sGNB30MGRCKvJnKKaREKXg",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

If you get the output similar to the above, it indicates that Elasticsearch server is successfully installed on your Ubuntu or Debian Linux.

Step4: Configuring Elasticsearch


Now that Elasticsearch and its Java dependencies have been installed. So you can try to configure Elasticsearch, such as: changing node.name or cluster.name through modifying the Elasticsearch configuration files elasticsearch.yml located in /etc/elasticsearch/ directory.

If you do not change those two variables (node.name and cluster.name), node.name will be assigned automatically with the default hostname. And the cluster.name variable will be automatically set to the name of default cluster as “elasticsearch”.

To start editing the main elasticsearch.yml configuration file with vi/vim text editor to change node.name as osetcnode, and changing cluster name as osetccluster:

$ sudo vim /etc/elasticsearch/elasticsearch.yml

You need to remove the # character at the beginning of the lines for cluster.name and node.name variables to uncomment them, and then update their values as you need. Like as below:

cluster.name: osetccluster
node.name: osetcnode

Save and close the file. And then restart the elasticsearch service by the following command:

$ sudo systemctl restart elasticsearch.service

Then you can test it again by sending a HTTP GET request with curl command to check if those two variables are changed, type:

$ curl -X GET 'http://localhost:9200'

Outputs:

devops@devops:~$ curl -X GET "localhost:9200/"
{
"name" : "osetcnode",
"cluster_name" : "osetccluster",
"cluster_uuid" : "sGNB30MGRCKvJnKKaREKXg",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "deb",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

From the above outputs, you would see that node name and cluster name have been changed.

Note: the elasticsearch service will take at least 5 seconds to fully start. So if you see the following error message: curl: (7) Failed connect to localhost:9200; Connection refused, and you just wait a few seconds and try it again.

Step5: Securing Elasticsearch with UFW Tool


As Elasticsearch do not provide any security, so it can be accessed by anyone who can access the HTTP API. So if you want to allow the specified remote hosts to access your Elasticsearch server, you need to change network.host variable so that Elasticsearch service can only be accessed from those remote hosts.

Using vi/vim text editor or your favorite text editor to edit elasticsearch.yml configuration file, and finding the line that contains network.host, and uncomment it by removing the # character at the beginning of the line, and change its value as IP address of your remote host.

network.host: 192.168.3.29 #listening on specified remote host

Note: if you want Elasticsearch listens on all interfaces and bound IPs, you just need to specify 0.0.0.0 value for network.host variable.

Save and close the file, restart the Elasticsearch service for the changes to take effect, type:

$ sudo systemctl restart elasticsearc.service

You still need to allow access the default port 9200 from the trusted clients, so you need to add the trusted hosts into your firewall policy with Ubuntu’s default firewall, UFW (Uncomplicated Firewall).

By default, UFW firewall is already installed on your Ubuntu system, but it is not enabled. Before enabling the UFW firewall, you need to firstly create a rule to allow any needed services, such as: ssh service.

To allow incoming SSH connections, you need to add port 22 into whitelist. Type:

$ sudo ufw allow 22

Outputs:

devops@devops:~$ sudo ufw allow 22
[sudo] password for devops:
Rules updated
Rules updated (v6)

Then you need to create another new rule to allow access to the default service port of Elasticsearch 9200 for the trusted remote host (assuming that the ip address is 192.168.3.22 ), running the following command:

$ sudo ufw allow from 192.168.3.22 to any port 9200

Outputs:

devops@devops:~$ sudo ufw allow from 192.168.3.22 to any port 9200
Rules updated

Enable UFW with the following command:

$ sudo ufw enable

Outputs:

devops@devops:~$ sudo ufw enable
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

Finally, you can try to check the status of UFW to see if those new rules take effect, type:

$ sudo ufw status

Outputs:

devops@devops:~$ sudo ufw status
Status: active

To Action From
-- ------ ----
22 ALLOW Anywhere
9200 ALLOW 192.168.3.22
22 (v6) ALLOW Anywhere (v6)

From the above outputs, you would see that the trusted remote host 192.168.3.22 to access port 9200 is in the Allow action list.

Step6: Using Elasticsearch


So far, Elasticsearch should be running on default port 9200 successfully. And You can try to add, read,delete or update the data to your Elasticsearch server using RESTful API with Curl command.

Adding Data to Elasticsearch server

You can run the following Curl command to add your first data into Elasticsearch server, type:

$ curl -H "Content-Type: application/json" -X POST 'http://localhost:9200/osetc/howto/1' -d '{
"Title" : "Installing Elasticsearch",
"Date" : "Jan 2020",
"Tag" : "server,CentOS,Linux"
}'

Outputs:

devops@devops:~$ curl -H "Content-Type: application/json" -X POST 'http://localhost:9200/osetc/howto/1' -d '{
> "Title" : "Installing Elasticsearch",
> "Date" : "Jan 2020",
> "Tag" : "server,CentOS,Linux"
> }'
{"_index":"osetc","_type":"howto","_id":"1","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":1}

The URI of the request was /osetc/howto/1 with several parameters:

  • Osetc is the index of the data in Elasticsearch server.
  • Howto is the type.
  • 1 is the id of entry under the above index and type.

Reading Data from Elasticsearch

You can try to retrieve the above entry with an HTTP GET request using Curl command, type:

$ curl -X GET 'http://localhost:9200/osetc/howto/1’

Outputs:

devops@devops:~$ curl -X GET 'http://localhost:9200/osetc/howto/1'
{"_index":"osetc","_type":"howto","_id":"1","_version":1,"_seq_no":0,"_primary_term":1,"found":true,"_source":{
"Title" : "Installing Elasticsearch",
"Date" : "Jan 2020",
"Tag" : "server,CentOS,Linux"
}}

Removing Data from Elasticsearch

If you want to remove above data entry from Elasticsearch, just type the following curl command:

$ curl -X DELETE 'http://localhost:9200/osetc/howto/1'

Outputs:

devops@devops:~$ curl -X DELETE 'http://localhost:9200/osetc/howto/1'
{"_index":"osetc","_type":"howto","_id":"1","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}

Conclusion


You should know that how to install and configure ElasticSearch to set up a distributed search engine on your Ubuntu 16.04 or 18.04 or Debian Linux. If you want to get more detail document about Elasticsearch, you can directly go to its official web site.

See Also:

How to Install and Configure ElasticSearch on CentOS or RHEL 7

This post will guide you how to install and configure an ElasticSearch server on your CentOS or RHEL Linux 7 system. How do I set up a distributed real-time search and analytics by set up an Elasticsearch server on CentOS Linux.

install elasticsearch 1

What is ElasticSearch?


Elasticsearch is an open source search engine based on the Lucene library. And it provides a distributed, multitenant-capable full-text search engine with an HTTP web interface (RESTful) and schema-free JSON documents. So you can use HTTP methods in combination with an HTTP URI to operate your data.

Elasticsearch is the most popular enterprise search engine followed by Apache Solr, also based on Lucene. And it can be use to search for all kind of text documents or analyzing big volumes of data in real time.

Elasticsearch is developed in JAVA. It is freely available under the Apache 2 license, so it provide the most flexibility.

Prerequisites


As Elasticsearch is developed in Java, so you need to have the latest JDK installed on your current CentOS or RHEL system.

The logging user also need to have sudo privileges so that you can install packages.

Step1: Installing JAVA


You need to have a JAVA Runtime Environment (JRE) on your Elsticsearch server, As Elasticsearch is developed in the JAVA programming language. So you can install the OpenJDK package from the default CentOS or RHEL repository with the following command:

$ sudo yum install java-1.8.0-openjdk.x86_64

Outputs:

[devops@devops ~]$ sudo yum install java-1.8.0-openjdk.x86_64
[sudo] password for devops:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.yun-idc.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.212.b04-0.el7_6 will be installed
--> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.212.b04-0.el7_6 for package: 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64
.....
---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================
Package Arch Version Repository Size
====================================================================================================================
Installing:
java-1.8.0-openjdk x86_64 1:1.8.0.212.b04-0.el7_6 updates 270 k
Installing for dependencies:
......
Transaction Summary
====================================================================================================================
Install 1 Package (+16 Dependent packages)

Total download size: 34 M
Installed size: 109 M
Is this ok [y/d/N]: y
Total 4.0 MB/s | 34 MB 00:00:08
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing :
Installing : 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64 16/17
Installing : 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64 17/17
Verifying :
Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.212.b04-0.el7_6.x86_64 14/17
Verifying : 1:java-1.8.0-openjdk-1.8.0.212.b04-0.el7_6.x86_64 15/17
Installed:
java-1.8.0-openjdk.x86_64 1:1.8.0.212.b04-0.el7_6
Complete!

After JDK package is installed, you can check the installation of JDK package by print the version of JDK installed, type:

$ java -version

Outputs:

[devops@devops ~]$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)

From the above outputs, you would see that the OpenJDK Runtime Environment is available. You can also install Oracle JDK 8 to set up JRE.

Step2: Downloading ElasticSearch


Once JAVA is installed on your system, and then you can download installation package of Elasticsearch to your local disk.

You can download the latest Elasticsearch archive file from official download page of elastic.  And you can also download directly rpm package of Elasticsearch from the official download page. Use one of the following command to get the Elasticsearch package, type:

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz

Or

$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm

Ouptuts:

[devops@devops ~]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
--2019-04-23 06:41:12-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
Resolving artifacts.elastic.co (artifacts.elastic.co)... 151.101.110.222, 2a04:4e42:1a::734
Connecting to artifacts.elastic.co (artifacts.elastic.co)|151.101.110.222|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 346760090 (331M) [application/x-gzip]
Saving to: ‘elasticsearch-7.0.0-linux-x86_64.tar.gz’

100%[======================================================================================================================>] 346,760,090 6.35MB/s in 58s

2019-04-23 06:42:11 (5.72 MB/s) - ‘elasticsearch-7.0.0-linux-x86_64.tar.gz’ saved [346760090/346760090]

[devops@devops ~]$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm
--2019-04-23 06:43:37-- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-x86_64.rpm
Resolving artifacts.elastic.co (artifacts.elastic.co)... 151.101.230.222, 2a04:4e42:36::734
Connecting to artifacts.elastic.co (artifacts.elastic.co)|151.101.230.222|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 346827255 (331M) [application/octet-stream]
Saving to: ‘elasticsearch-7.0.0-x86_64.rpm’

100%[======================================================================================================================>] 346,827,255 6.03MB/s in 57s

2019-04-23 06:44:35 (5.77 MB/s) - ‘elasticsearch-7.0.0-x86_64.rpm’ saved [346827255/346827255]

Note: At the time of writing this post, the latest version of Elasticsearch is 7.0.

Step3: Installing ElasticSearch


If you downloaded Elasticsearch Archive file, you just need to extract it on your system, type:

$ tar -zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz

If you downloaded the native rpm package of Elasticsearch on your system, you can install it with rpm or yum install command, type:

$ rpm -ivh elasticsearch-7.0.0-x86_64.rpm

Or

$ yum install elasticsearch-7.0.0-x86_64.rpm

Outputs:

[devops@devops ~]$ sudo yum install elasticsearch-7.0.0-x86_64.rpm
[sudo] password for devops:
Loaded plugins: fastestmirror
Examining elasticsearch-7.0.0-x86_64.rpm: elasticsearch-7.0.0-1.x86_64
Marking elasticsearch-7.0.0-x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package elasticsearch.x86_64 0:7.0.0-1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================
Installing:
elasticsearch x86_64 7.0.0-1 /elasticsearch-7.0.0-x86_64 545 M

Transaction Summary
================================================================================================================================================================
Install 1 Package

Total size: 545 M
Installed size: 545 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Installing : elasticsearch-7.0.0-1.x86_64 1/1
### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
### You can start elasticsearch service by executing
sudo systemctl start elasticsearch.service
Created elasticsearch keystore in /etc/elasticsearch
Verifying : elasticsearch-7.0.0-1.x86_64 1/1

Installed:
elasticsearch.x86_64 0:7.0.0-1

Complete!

Elasticsearch will be installed in /usr/share/elasticsearch directory, and its configuration files locates in /etc/elasticsearch directory. And its init script is added into /etc/init.d/ directory.

Once the installation process is complete, you need to start and enable elaticsearch service by the following command:

$ sudo systemctl start elasticsearch.service
$ sudo systemctl enable elasticsearch.service

Outputs:

[devops@devops ~]$ sudo systemctl start elasticsearch.service
[sudo] password for devops:
[devops@devops ~]$ sudo systemctl enable elasticsearch.service
Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

Then you can use curl command to send an HTTP request to the default port 9200 of Elasticsearch service, type:

$ curl -X GET "localhost:9200/"

Outputs:

[devops@devops ~]$ curl -X GET "localhost:9200/"
{
"name" : "devops",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "xsMDZ1XrR3ytwWlQXvh3sA",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

If you get the output similar to the above, it indicates that Elasticsearch server is successfully installed on your CentOS or RHEL Linux.

Step4: Configuring ElasticSearch


After Elasticsarch is installed, you can go to the configuration directory /etc/elasticsearch/ direcotry to edit the elasticsearch.yml configuration file.

You can change node.name and cluster.name as you need in the elasticsearch.yml file. If you do not change these name variables, node.name will be assigned automatically with the default hostname. And the cluster.name will be automatically set to the name of the default cluster as “elasticsearch“.

$ sudo vim /etc/elasticsearch/elasticsearch.yml

Then you need to remove the # character at the begainning of the lines for node.name and cluster.name to uncomment them. And then change their values as you need.

For example, changing node.name as osetcnode, and changing cluster.name as osetccluster:

node.name: "osetcnode"
cluster.name: "osetccluster"

Save and close the file. and restart the elasticsearch service by the following command:

$ sudo systemctl restart elasticsearch.service

Then you can test it again by sending a HTTP GET request with curl command, type:

$ curl -X GET 'http://localhost:9200'

Outputs:

[devops@devops ~]$ curl -X GET "localhost:9200/"
curl: (7) Failed connect to localhost:9200; Connection refused

[devops@devops ~]$ curl -X GET "localhost:9200/"
{
"name" : "osetcnode",
"cluster_name" : "osetccluster",
"cluster_uuid" : "xsMDZ1XrR3ytwWlQXvh3sA",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

Note: the elasticsearch service will take at least 5 seconds to fully start. So if you see the following error message: curl: (7) Failed connect to localhost:9200; Connection refused, and you just wait a few seconds and try it again.

Step5: Securing ElasticSearch


As Elasticsearch do not provide any security, so it can be accessed by anyone who can access the HTTP API. So if you want to allow the specified remote hosts to access your Elasticsearch server, you need to change network.host variable so that Elasticsearch service can only be accessed from those remote hosts.

Editing elasticsearch.yml configuration file, and finding the line that contains network.host, and uncomment it by removing the # character at the beginning of the line, and change its value as IP address of your remote host.

network.host: 192.168.3.29 #listening on specified remote host

Save and close the file, restart the Elasticsearch service for the changes to take effect, type:

$ sudo systemctl restart elasticsearc.service

You still need to allow access the default port 9200 from the trusted clients, so you need to add the trusted hosts into your firewall policy, type the following command:

$ sudo firewall-cmd --new-zone=elastic --permanent
$ sudo firewall-cmd --reload
$ sudo firewall-cmd --zone=elastic --add-source=192.168.3.29/32 --permanent
$ sudo firewall-cmd --zone=elastic --add-port=9200/tcp --permanent
$ sudo firewall-cmd --reload

Step6: Installing ElasticSearch Head Plugin


You can also install a web front-end plugin called elasticsearc-head. it can be used to browse and interact with an Elasticsearach cluster. Just do the following steps:

#1 try to git ElasticSearch-head files into to your local disk, type:

$ git clone git://github.com/mobz/elasticsearch-head.git

Outputs:

[devops@devops ~]$ git clone git://github.com/mobz/elasticsearch-head.git
Cloning into 'elasticsearch-head'...
remote: Enumerating objects: 32, done.
remote: Counting objects: 100% (32/32), done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 4260 (delta 8), reused 32 (delta 8), pack-reused 4228
Receiving objects: 100% (4260/4260), 2.21 MiB | 73.00 KiB/s, done.
Resolving deltas: 100% (2337/2337), done.

#2 change the current directory to elasticsearch-head, type:

$ cd elasticsearch-head

#3 if your system do not install npm tool ,install it with the following command:

$ yum install npm -y

#4 install and start elasticsearch-head, type:

$ npm install
$ npm run start

Outputs:

[devops@devops elasticsearch-head]$ npm run start

> elasticsearch-head@0.0.0 start /home/devops/elasticsearch-head
> grunt server

Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100

Then you can open http://localhost:9100 to access front end web server on your web browser.

Note: if you want to access web frond end from remote host, you still need to allow port 9100 for the trusted remote host, type:

$ sudo firewall-cmd --zone=elastic --add-port=9100/tcp --permanent
$ sudo firewall-cmd --reload

Step7: Using ElasticSearch


You can add data to your elasticsearch server using a RESTful API with Curl command. Or you can also read, delete or update the data using API.

Let’s try to add your first data into Elasticsearch server, type:

$ curl -H "Content-Type: application/json" -X POST 'http://localhost:9200/osetc/howto/' -d '{
"Title" : "Installing Elasticsearch",
"Date" : "Jan 2020",
"Tag" : "server,CentOS,Linux"
}'

Outputs:

[root@devops ~]# curl -H "Content-Type: application/json" -X POST 'http://localhost:9200/osetc/howto/' -d '{
> "Title" : "Installing Elasticsearch",
> "Date" : "Jan 2020",
> "Tag" : "server,CentOS,Linux"
> }'
{"_index":"osetc","_type":"howto","_id":"2BmcSmoB1ug0pWDkkxaV","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":0,"_primary_term":2}

If you want to query the data on Elasticsearch, just type:

$ curl -X GET 'http://localhost:9200/osetc/howto/2BmcSmoB1ug0pWDkkxaV'

Outputs:

[root@devops ~]# curl -X GET 'http://localhost:9200/osetc/howto/2BmcSmoB1ug0pWDkkxaV'
{"_index":"osetc","_type":"howto","_id":"2BmcSmoB1ug0pWDkkxaV","_version":1,"_seq_no":0,"_primary_term":2,"found":true,"_source":{
"Title" : "Installing Elasticsearch",
"Date" : "Jan 2020",
"Tag" : "server,CentOS,Linux"
}}

If you want to remove data, just type:

$ curl -X DELETE 'http://localhost:9200/osetc/howto/2BmcSmoB1ug0pWDkkxaV'

Outputs:

[root@devops ~]# curl -X DELETE 'http://localhost:9200/osetc/howto/2BmcSmoB1ug0pWDkkxaV'
{"_index":"osetc","_type":"howto","_id":"2BmcSmoB1ug0pWDkkxaV","_version":2,"result":"deleted","_shards":{"total":2,"successful":1,"failed":0},"_seq_no":1,"_primary_term":2}

Conclusion


You should know that how to install and configure ElasticSearch to set up a distributed search engine on your CentOS or RHEL Linux 6/7. If you want to get more detail document about Elasticsearch, you can directly go to its official web site.

How to Modify Your Hosts File in Linux

This post will guide you set up local DNS using /etc/hosts file in your Linux system. How do I modify your hosts file to resolve your hostname to ip address on Linux operating system.

What is Host File


The Hosts file is used to resolve domain name or Hostname to IP addresses. When you access a website using it domain name in your web browser, you system will check the resolution of domain name from your hosts file locally to get the corresponding IP address, and then download the web page. If there is no any entry for the domain name, and it will query the configured DNS servers to resolve the specified domain name.

All operating systems have a hosts file to translate hostnames to IP addresses, such as: windows, Mac and Linux.

The hosts file also can be used to test your website, and if you do not want to change your domain DNS settings.

Modify Host File to Configure DNS Locally


If you want to add one Domain name resolution into hosts file, you just edit the hosts text file located at /etc/hosts with a sudo user using vi or vim text editor.

You need to follow the following format to add DNS entries into your /etc/hosts configuration file:

IPADDRESS DomainName [ShortName]

Note: the IP address and the domain name should be separated by at least one space character. If you do not want ignore one hosts entry, just add # to comment it.

For example, add domain name osetc.com and ip address 192.168.3.22 to your hosts file, type:

$ vim /etc/hosts

192.168.3.22 osetc.com

Save and close the file. Let’s try to ping your server with domain name, type:

$ ping osetc.com

Outputs:

[devops@devops ~]$ ping osetc.com
PING osetc.com (192.168.3.22) 56(84) bytes of data.
64 bytes from osetc.com (192.168.3.22): icmp_seq=1 ttl=64 time=0.034 ms
64 bytes from osetc.com (192.168.3.22): icmp_seq=2 ttl=64 time=0.038 ms
64 bytes from osetc.com (192.168.3.22): icmp_seq=3 ttl=64 time=0.038 ms
64 bytes from osetc.com (192.168.3.22): icmp_seq=4 ttl=64 time=0.040 ms
^C
--- osetc.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2999ms

Block Domain Name with Modifying Host File


You can use hosts file to block one domain name by redirecting it to the ip of your localhost.

For example, if you want to block domain name bing.com, you can add the following DNS entry into your hosts file with vim text editor:

127.0.0.1 bing.com

or

0.0.0.0 bing.com

Save and close the file. when you try to access bing.com site, it will translate bing.com domain to ip address of your localhost. And you will get error message as “Unable to connect to bing.com

Conclusion


You should know that how to list shell variables and environmental variables in your shell session on your CentOS or RHEL Linux 6/7.

How to List and Set Environment Variables or Shell Variables in Linux

This post will guide you how to list all environment variables using bash shell on CentOS or RHEL Linux server. How do I list all shell variables through command line on CentOS or RHEL Linux 6/7. How to create shell variable or environmental variable through shell command on Linux system.

list and set shell variable1

What is Shell Variable and Environment Variable


Standard UNIX variables are split into two categories, environment variables and shell variables. A shell variable is a variable that is available only to the current shell. An environment variable is available system wide and can be used by other applications on the system.

List All Environment Variables


You should know that each shell session keeps track of its own shell and environmental variables. And if you want to list all environment variables in your current shell session, you can use one of the following commands:

$ printenv

or

$ env

Outputs:

[devops@devops ~]$ printenv
XDG_SESSION_ID=2
HOSTNAME=devops
SELINUX_ROLE_REQUESTED=
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
SSH_CLIENT=192.168.3.29 1914 22
CONDA_SHLVL=1
SELINUX_USE_CURRENT_RANGE=
CONDA_PROMPT_MODIFIER=(base)
SSH_TTY=/dev/pts/0
USER=devops
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg= 30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4= 01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01 ;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01 ;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz= 01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*. xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01 ;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wm v=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.x wd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36: *.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01; 36:*.xspf=01;36:
CONDA_EXE=/root/anaconda3/bin/conda
PATH=/root/anaconda3/bin:/root/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
MAIL=/var/spool/mail/root
CONDA_PREFIX=/root/anaconda3
PWD=/home/devops
LANG=en_US.UTF-8
SELINUX_LEVEL_REQUESTED=
HISTCONTROL=ignoredups
HOME=/home/devops
SHLVL=2
LOGNAME=devops
CONDA_PYTHON_EXE=/root/anaconda3/bin/python
SSH_CONNECTION=192.168.3.29 1914 192.168.3.22 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
CONDA_DEFAULT_ENV=base
XDG_RUNTIME_DIR=/run/user/0
OLDPWD=/root
_=/usr/bin/printenv

Note:
The env command allows you to print all exported environment variables or you can also use it to run a program in a modified environment.

The printenv command can be used to print all of environment variables or the specified environment variables.

If you want to display the value of a specified environment variable, you can run the following command:

$ print HOME

Outputs:

[devops@devops ~]$ printenv HOME
/home/devops

List All Shell Variables


If you want to list all shell variables in your current shell session, you can use set command without any additional parameters, then it will list all shell variables, environment variables, local variables, and shell functions, type:

$ set

Outputs:

[devops@devops ~]$ set
BASH=/usr/bin/bash
BASHOPTS=checkwinsize:cmdhist:expand_aliases:extquote:force_fignore:histappend:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="2" [2]="46" [3]="2" [4]="release" [5]="x86_64-redhat-linux-gnu")
BASH_VERSION='4.2.46(2)-release'
COLUMNS=161
CONDA_DEFAULT_ENV=base
CONDA_EXE=/root/anaconda3/bin/conda
CONDA_PREFIX=/root/anaconda3
CONDA_PROMPT_MODIFIER='(base) '
CONDA_PYTHON_EXE=/root/anaconda3/bin/python
CONDA_SHLVL=1
DIRSTACK=()
EUID=1002
GROUPS=()
HISTCONTROL=ignoredups
HISTFILE=/home/devops/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/home/devops
HOSTNAME=devops
HOSTTYPE=x86_64
ID=1002
IFS=$' \t\n'
LANG=en_US.UTF-8
LESSOPEN='||/usr/bin/lesspipe.sh %s'
LINES=54
LOGNAME=devops

Note: The set command can be used to create or unset shell variables in your current shell session. If you do not follow any arguments, it will print a list of all variables.

Common Environmental and Shell Variables


Here are some common environment variables that you may be want to know:
SHELL: his describes the shell that will be interpreting any commands you type in.
TERM: This specifies the type of terminal to emulate when running the shell.
USER: The current logging user
HOSTNAME: The hostname of your system
PWD: the current working directory
PATH: a list of directories that the system will check when searching for commands.
HOME: the current user’s home directory
DISPLAY: set X dispaly name
LANG: the current language and localization settings.
MAIL: the path to the current user’s mailbox.

Creating Shell Variables and Environmental variables


If you want to create you own shell variable in your current shell session, you just need to specify a name and a value.

For example, you wish to define a new shell vairable named “test“, and set its value as “this is a variable“, just type the following line in your shell:

$ test="this is a variable"

Then you should create a shell variable. And this variable is only available in your current session, and it won’t to pass down to child processes or other shell session.

You can use set command with grep command to check if it is created successfully, type:

$ set | grep test

Outputs:

[devops@devops ~]$ set | grep test
test='this is a variable'

You can also use echo command to print the value of any shell or environment variables, type:

$ echo $test

Outputs:

[devops@devops ~]$ echo $test
this is a variable

If you want to trun your shell variable into an environment variable, you just need to use export command to export it, just type:

$ export test

then you can use printenv command in combination with grep command to check if it is in environment list, type:

$ printenv | grep test

Outputs:

[devops@devops ~]$ printenv | grep test
test=this is a variable

Conclusion


You should know that how to list shell variables and environmental variables in your shell session on your CentOS or RHEL Linux 6/7.

How to Install Apache CouchDB on CentOS or RHEL 6/7

This post will guide you how to install Apache CouchDB on CentOS or RHEL Linux 6/7. How do I Configure Apache CouchDB HTTP Server on your CentOS Linux system. How do I configure the admin user, create an CouchDB database on your CouchDB server in CentOS Linux. You also learn some basic usage of CouchDB through RESTful API using the Curl command utility.

apache couchdb login page5

What is Apache CouchDB?


CouchDB was first released in 2005 and later became an Apache Software Foundation project in 2008.

Apache CouchDB is an open source NoSQL database software, it means that it does not have any tables, rows or index, etc. And it uses JSON for data storage, JavaScript for MapReduce indexes, and regular HTTP for its API. You can also access and manage Apache CouchDB from a web browser via HTTP or API. or You can also read, create, edit and delete database documents through RESTful HTTP API.

CouchDB database management system can be work with all IT environments, distributed server clusters, the latest web browsers and mobile applications. And it is compatible with Couch Replication Protocol inlucdes PouchDB, Cloudant and Couchbase Lite.

CouchDB has a document that oriented NoSQL database architecture and is implemented in the concurrency that oriented language Erlang.

Enabling Apache CouchDB Repository


If you want to install Apache CouchDB package on your CentOS or RHEL distribution Linux, you need to install and enable EPEL (Extra Package for Enterprise Linux) repository and update your current system software packages to the latest version available. You can use the following command to do that, type:

$ sudo yum update -y
$ sudo yum install epel-release -y

Outputs:

[root@devops ~]# sudo yum update -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror.premi.st
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
....

[root@devops ~]# sudo yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
epel-release noarch 7-11 extras 15 k

Transaction Summary
================================================================================================
Install 1 Package

Total download size: 15 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-11.noarch.rpm | 15 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : epel-release-7-11.noarch 1/1
Verifying : epel-release-7-11.noarch 1/1

Installed:
epel-release.noarch 0:7-11

Complete!

Once the EPEL repository has been installed, you can add Apache CouchDB repository to your repo file, just do the following steps:

#1 go to the /etc/yum.repos.d/ directory and create a new repo file named apache-couchdb.repo with the folllowing command:

$ sudo cd /etc/yum.repos.d
$ sudo vim apache-couchdb.repo

#2 add the following lines into the file.

[apache-couchdb-repo]
name=apache-couchdb-repo
baseurl=http://apache.bintray.com/couchdb-rpm/el$releasever/$basearch/
gpgcheck=0
repo_gpgcheck=0
enabled=1

#3 save and close the repo.
#4 checking if apache couchdb repo is added to the current repository by running the following command:

$ yum repolist

Outputs:

[devops@devops yum.repos.d]$ yum repolist
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors.aliyun.com
* epel: fedora.cs.nctu.edu.tw
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
apache-couchdb-repo 10/10
repo id repo name status
apache-couchdb-repo/7/x86_64 apache-couchdb-repo 10
base/7/x86_64 CentOS-7 - Base - mirrors.aliyun.com 10,019
docker-ce-stable/x86_64 Docker CE Stable - x86_64 41
epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 13,068
extras/7/x86_64 CentOS-7 - Extras - mirrors.aliyun.com 386
updates/7/x86_64 CentOS-7 - Updates - mirrors.aliyun.com 1,573
repolist: 25,097

From the above outputs, you would see that apache-couchdb-repo has been added into your current public yum repositories.

Installing Apache CouchDB


Once EPEL and Apache CouchDB repositories are enable, you can start to install the Apache CouchDB packages using the following yum command, and it will also install all dependencies on your CentOS system.

$ sudo yum install couchdb

Outputs:

[devops@devops yum.repos.d]$ sudo yum install couchdb
[sudo] password for devops:
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirror.premi.st
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package couchdb.x86_64 0:2.3.1-1.el7 will be installed
--> Processing Dependency: couch-js = 1:1.8.5 for package: couchdb-2.3.1-1.el7.x86_64
--> Processing Dependency: python-requests for package: couchdb-2.3.1-1.el7.x86_64
--> Processing Dependency: python-progressbar for package: couchdb-2.3.1-1.el7.x86_64
--> Processing Dependency: libmozjs185.so.1.0()(64bit) for package: couchdb-2.3.1-1.el7.x86_64
--> Running transaction check
---> Package couch-js.x86_64 1:1.8.5-21.el7 will be installed
---> Package python-progressbar.noarch 0:2.3-4.el7 will be installed
---> Package python-requests.noarch 0:2.6.0-1.el7_1 will be installed
--> Processing Dependency: python-urllib3 >= 1.10.2-1 for package: python-requests-2.6.0-1.el7_1.noarch
--> Running transaction check
---> Package python-urllib3.noarch 0:1.10.2-5.el7 will be installed
--> Processing Dependency: python-six for package: python-urllib3-1.10.2-5.el7.noarch
--> Running transaction check
---> Package python-six.noarch 0:1.9.0-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
couchdb x86_64 2.3.1-1.el7 apache-couchdb-repo 19 M
Installing for dependencies:
couch-js x86_64 1:1.8.5-21.el7 apache-couchdb-repo 2.0 M
python-progressbar noarch 2.3-4.el7 epel 20 k
python-requests noarch 2.6.0-1.el7_1 base 94 k
python-six noarch 1.9.0-2.el7 base 29 k
python-urllib3 noarch 1.10.2-5.el7 base 102 k

Transaction Summary
================================================================================================
Install 1 Package (+5 Dependent packages)

Total download size: 21 M
Installed size: 48 M
Is this ok [y/d/N]: y
Downloading packages:
(1/6): python-six-1.9.0-2.el7.noarch.rpm | 29 kB 00:00:00
(2/6): python-progressbar-2.3-4.el7.noarch.rpm | 20 kB 00:00:00
(3/6): python-requests-2.6.0-1.el7_1.noarch.rpm | 94 kB 00:00:00
(4/6): python-urllib3-1.10.2-5.el7.noarch.rpm | 102 kB 00:00:00
(5/6): couch-js-1.8.5-21.el7.x86_64.rpm | 2.0 MB 00:00:03
(6/6): couchdb-2.3.1-1.el7.x86_64.rpm | 19 MB 00:00:10
------------------------------------------------------------------------------------------------
Total 2.0 MB/s | 21 MB 00:00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:couch-js-1.8.5-21.el7.x86_64 1/6
Installing : python-progressbar-2.3-4.el7.noarch 2/6
Installing : python-six-1.9.0-2.el7.noarch 3/6
Installing : python-urllib3-1.10.2-5.el7.noarch 4/6
Installing : couchdb-2.3.1-1.el7.x86_64 6/6
Verifying : python-requests-2.6.0-1.el7_1.noarch 1/6
Verifying : couchdb-2.3.1-1.el7.x86_64 2/6
Verifying : python-six-1.9.0-2.el7.noarch 3/6
Verifying : python-progressbar-2.3-4.el7.noarch 4/6
Verifying : 1:couch-js-1.8.5-21.el7.x86_64 5/6
Verifying : python-urllib3-1.10.2-5.el7.noarch 6/6

Installed:
couchdb.x86_64 0:2.3.1-1.el7

Dependency Installed:
couch-js.x86_64 1:1.8.5-21.el7 python-progressbar.noarch 0:2.3-4.el7
python-requests.noarch 0:2.6.0-1.el7_1 python-six.noarch 0:1.9.0-2.el7
Complete!

After the installation of CouchDB is completed, you need to start the couchdb service and enable it to run at the system boot. Type:

$ sudo systemctl start couchdb
$ sudo systemctl enable couchdb

Outputs:

[devops@devops yum.repos.d]$ sudo systemctl start couchdb
[devops@devops yum.repos.d]$ sudo systemctl enable couchdb
Created symlink from /etc/systemd/system/multi-user.target.wants/couchdb.service to /usr/lib/systemd/system/couchdb.service.

If you want to verify if CouchDB service is running or not, just using the following command:

$ sudo systemctl status couchdb

Outputs:

[devops@devops yum.repos.d]$ sudo systemctl status couchdb
● couchdb.service - Apache CouchDB
Loaded: loaded (/usr/lib/systemd/system/couchdb.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2019-04-21 06:36:57 EDT; 1min 5s ago
Main PID: 3847 (beam.smp)
CGroup: /system.slice/couchdb.service
├─3847 /opt/couchdb/bin/../erts-8.3.5/bin/beam.smp -K true -A 16 -Bd -- -root /opt...
├─3856 /opt/couchdb/bin/../erts-8.3.5/bin/epmd -daemon
├─3874 erl_child_setup 1024
├─3879 sh -s disksup
├─3880 /opt/couchdb/bin/../lib/os_mon-2.4.2/priv/bin/memsup
└─3881 /opt/couchdb/bin/../lib/os_mon-2.4.2/priv/bin/cpu_sup
Apr 21 06:36:57 devops systemd[1]: Started Apache CouchDB

If you get the Active state from the outputs, it indicates that Apache CouchDB service has been installed and started on your CentOS or RHEL Linux server.

You can also check on which server ports the Apache CouchDB communication is established on your system. To verify this, you need to use netstat tool to check it. To use this command, you need to install net-tools package firstly, type the following command:

$ sudo yum install net-tools

Then you can run the following command to check the default service port 5984 if it is listened. type:

$ sudo netstat -plntu

Outputs:

[devops@devops yum.repos.d]$ sudo netstat -plntu
[sudo] password for devops:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:40620 0.0.0.0:* LISTEN 3847/beam.smp
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 3856/epmd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 3010/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3100/master
tcp 0 0 127.0.0.1:5984 0.0.0.0:* LISTEN 3847/beam.smp
tcp 0 0 127.0.0.1:5986 0.0.0.0:* LISTEN 3847/beam.smp
tcp6 0 0 :::80 :::* LISTEN 3004/httpd
tcp6 0 0 :::4369 :::* LISTEN 3856/epmd
tcp6 0 0 :::22 :::* LISTEN 3010/sshd
tcp6 0 0 ::1:25 :::* LISTEN 3100/master
udp 0 0 0.0.0.0:68 0.0.0.0:* 2820/dhclient
udp 0 0 0.0.0.0:35445 0.0.0.0:* 2491/avahi-daemon:
udp 0 0 0.0.0.0:5353 0.0.0.0:* 2491/avahi-daemon:

From the above outputs, you would see that the port 5984 is being listened.

Configuring Apache CouchDB


Apache CouchDB has a web-based interface called Fauxton, if you want to enable this pane for administrator access with the default server port 5984, you need to go to the Apache CouchDB installation directory /opt/couchdb/etc/, and modify its configuration file called local.ini with vi or vim text editor. Type:

$ sudo vim /opt/couchdb/etc/local.ini

Then you need to navigate to chttpd section and change the bind_address value with your server’s IP address. so you need to change the settings under chttpd section as shown below:

[chttpd]
port = 5984
bind_address = 192.168.3.22

Then you stil need to go to the end of the file to find admins section, set the admin user and its password as shown:

[admins]
admin = test123456

Save and close the file. Restart the Apache CouchDB service using the following systemctl command:

$ sudo systemctl restart couchdb.service

To verify Apache CouchDB HTTP server, you need to check if your firewall service is running or not, if it is running, you need to enable the Apache CouchDB server port in your firewall policy by executing the following command:

$ sudo firewall-cmd --add-port=5984/tcp --permanent
$ sudo firewall-cmd --reload

Then you can go to a web browser and enter the following URL to access Apache CouchDB web pane.

http://192.168.3.22:5984/_utils/

apache couchdb login page1

You need to enter your username and password to log in to CouchDB server. Then click Log in button.

apache couchdb login page2

You can also execute the following curl command to verify whether the Apache CouchDB server runs normally. type:

$ curl http://192.168.3.22:5984/

Outputs:

[devops@devops yum.repos.d]$ curl http://192.168.3.22:5984/
{"couchdb":"Welcome","version":"2.3.1","git_sha":"c298091a4","uuid":"78d6b359ff0e26c6f86b0909665fe67e","features":["pluggable-storage-engines","scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
[devops@devops yum.repos.d]$

Configuring Admin Account in Apache CouchDB


Before a server admin is configured, all clients have admin privileges. This is fine when HTTP access is restricted to trusted users. If end-users will be accessing this CouchDB, you must create an admin account to prevent accidental (or malicious) data loss.

Server admins can create and destroy databases, install and update _design documents, run the test suite, and edit all aspects of CouchDB configuration.

You can add an administrator user through Apache CouchDB web Gui, click Your Account menu, and then click Create Server Admin tab, type your username and password, then click Create Admin button.

apache couchdb login page3

Now new admin user(osetc) for CouchDB has been created.

Creating Database in CouchDB


To create a new database in your CouchDB server, you can use Curl command with PUT subcommand and –X option. Or you can directly go to Web GUI of CouchDB to create new database.

For example, you wish to create a new database called testdb, just type:

$ curl -X PUT http://osetc:123456@192.168.3.22:5984/testdb

Outputs:

[devops@devops yum.repos.d]$ curl -X PUT http://osetc:123456@192.168.3.22:5984/testdb
{"ok":true}

From GUI:

apache couchdb login page4

Listing All Databases in CouchDB


If you want to list all databases in your current CouchDB server, just use curl command with GET subcommand and -X option to get it, type:

$ curl -X GET http://osetc:123456@192.168.3.22:5984/_all_dbs

Outputs:

[devops@devops yum.repos.d]$ curl -X GET http://osetc:123456@192.168.3.22:5984/_all_dbs
["mydata","testdb"]

If you want to get information about a given database that have created already in your CouchDB server, For example, get all information about testdb database, just type the following command:

$ curl -X GET http://osetc:123456@192.168.3.22:5984/testdb

Outputs:

[devops@devops yum.repos.d]$ curl -X GET http://osetc:123456@192.168.3.22:5984/testdb
{"db_name":"testdb","purge_seq":"0-g1AAAAFTeJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMeC5BkeACk_gNBViIDQbUHIGrvE6N2AUTtfmLUNkDUzsevNikBSCbVE3RrkgNIXTxhdQogdfYE1SUyJMlDFGUBAD9sXo4","update_seq":"0-g1AAAAFTeJzLYWBg4MhgTmEQTM4vTc5ISXIwNDLXMwBCwxygFFMiQ5L8____sxIZ8ChKUgCSSfaE1TmA1MUTVpcAUldPUF0eC5BkaABSQKXziVG7AKJ2PzFqD0DU3idG7QOIWpB7swBegl6O","sizes":{"file":33992,"external":0,"active":0},"other":{"data_size":0},"doc_del_count":0,"doc_count":0,"disk_size":33992,"disk_format_version":7,"data_size":0,"compact_running":false,"cluster":{"q":8,"n":1,"w":1,"r":1},"instance_start_time":"0"}

Deleting Database in CouchDB


If you want to delete a database in CouchDB server, you can directory delete it from CouchDB web Gui, or you can also delete it through CURL command line tool, just use Curl command with DELETE subcommand and -x option, type:

$ curl -X DELETE http://osetc:123456@192.168.3.22:5984/testdb

Outputs:

[devops@devops yum.repos.d]$ curl -X DELETE http://osetc:123456@192.168.3.22:5984/testdb
{"ok":true}

[devops@devops yum.repos.d]$ curl -X GET http://osetc:123456@192.168.3.22:5984/_all_dbs
["mydata"]

Conclusion


You should know that how to install and Configure Apache CouchDB on your CentOS or RHEL Linux 6/7. If you want to see more information about CouchDB, you can go the official web page of Apache CouchDB directly.

How to Install and Manage RPM Packages on CentOS or RHEL Linux

This post will guide you how to install RPM packages with RPM tool on CentOS or RHEL Linux. How do I uninstall a RPM Package with RPM or YUM tool on CentOS 7 or RHEL 7 Linux. How to List all installed packages on your CentOS or RHEL Linux system. This post will introduce two methods of how to install/uninstall RPM packages on CentOS 7.

If you are working in CentOS or RHEL Linux, you may have see downloadable files with the .rpm extension. The .rpm format is the default installable package type for RHEL, Fedora, CentOS, Oracle Linux and Scientific Linux as well. And If you want to install a new application, you need to look for RPM packages that are specifically built for CentOS or RHEL system.

centos and redhat log1

What is RPM Package


RPM is the abbreviation for Red Hat Package Manager. You can use this tool to manage all application on your CentOS or RHEL or Fedora Linux. There are two package management tools under CentOS or RHEL Linux, one is a low-level RPM Tool and another is high-level YUM Tool.

RPM Package Manager is also a free and open source package management system for CentOS or RHEL Linux system, and it can be used to install, uninstall and manage all software packages in your Linux system.

The default official CentOS or RHEL repositories contain thousands of RPM packages which can be installed using the YUM tool on your Linux system. If the packages are not included in the default repository, you have to download it form the third download web page where you can download and install the packages. And the extension of downloaded package file should be .rpm.

Downloading RPM Installation File


Firstly, you need to find a suitable RPM package that you want to install on your CentOS system. When you look for RPM package, you also need to make sure that you choose the correct package according to your system’s architecture and CentOS or RHEL version. It means, if your system arch is x86_64 and Linux version is CetnOS 7 or RHEL 7 version, you need to download the corresponding el7.x86_64 package.

Normally, you need to locate and download a rpm file through a web browser. However, if your browser is not available on your Linux system or your are working on terminal mode, you can still download a file if you know where it is located.

For example, you want to download a rpm file for a package called wget, you can use curl command to download it to your local disk.

Type the following command:

$ sudo curl -O https://mirrors.aliyun.com/centos/7.6.1810/os/x86_64/Packages/wget-1.14-18.el7.x86_64.rpm

Outputs:

[root@devops ~]# curl -O https://mirrors.aliyun.com/centos/7.6.1810/os/x86_64/Packages/wget-1.14-18.el7.x86_64.rpm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 547k 100 547k 0 0 1250k 0 --:--:-- --:--:-- --:--:-- 1251k

[root@devops ~]# ls wget*
wget-1.14-18.el7.x86_64.rpm

You should see that the curl command will reach out to the website and download the file to your current working directory.

Installing RPM Packages with RPM


Once wget package downloaded on your local disk, and you can install .rpm file by rpm command with -ivh option. And the -i option will tell RPM package manager you want to install the specified file. Type:

$ sudo rpm -ivh wget-1.14-18.el7.x86_64.rpm

Outputs:

[root@devops ~]# sudo rpm -ivh wget-1.14-18.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:wget-1.14-18.el7 ################################# [100%]

If the installed package depends on other packages that you do not have installed on your system, and rpm tool will list all dependencies and exit the installation process. At this time, you have to download and install all dependency packages firstly by manually, then re-install that package.

You can also check the .rpm file for dependencies firstly using the following command:

$ sudo rpm -qpR wget-1.14-18.el7.x86_64.rpm

Then rpm should list all the dependencies.

-q option will tell RMM to query the file
-p option will allow you specify one target package to be queried
-R option will tall RPM to list all requirements for the queried package

Note: To install RPM Packages on your system, you need to make sure that you have logged in as a user with sudo privileges.

If you want to update a package that have installed already on your system, and you can use -U option, type:

$ sudo rpm -Uvh wget-1.14-18.el7.x86_64.rpm

Uninstalling RPM Packages with RPM


If you don’t need a package you installed before, and you can directly remove it from your CentOS or RHEL Linux system. You can still use RPM command to uninstall it. just use a different option, -e. It will instructs RPM Package Manager that you want to erase the software.

Before remove the package, you need to get the file name of that package that you want to uninstall with the -qa option to rpm command, type:

$ sudo rpm -qa | grep wget

Outputs:

[root@devops ~]# rpm -qa | grep wget
wget-1.14-18.el7.x86_64

Then you can use rpm command with -e option to remove it, type:

$ sudo rpm -e wget-1.14-18.el7.x86_64

After removed the package, you can list all installed packages to see that there is no package called wget any more. type:

[devops@devops ~]$ sudo rpm -e wget-1.14-18.el7.x86_64
[sudo] password for devops:
[devops@devops ~]$ rpm -qa | grep wget
[devops@devops ~]$

Installing RPM Packages with YUM


As YUM is the default Package Manager tool on CentOS or RHEL Linux 6/7, so you can also use yum command to install a downloaded rpm file. or you can use yum to install packages directly from the default YUM repositories. Just using yum command with localinstall subcommand to install rpm package file, type:

$ sudo yum localinstall wget-1.14-18.el7.x86_64.rpm

Outputs:

[devops@devops ~]$ sudo yum localinstall wget-1.14-18.el7.x86_64.rpm
[sudo] password for devops:
Loaded plugins: fastestmirror
Examining wget-1.14-18.el7.x86_64.rpm: wget-1.14-18.el7.x86_64
Marking wget-1.14-18.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================
Installing:
wget x86_64 1.14-18.el7 /wget-1.14-18.el7.x86_64 2.0 M

Transaction Summary
================================================================================================================================
Install 1 Package

Total size: 2.0 M
Installed size: 2.0 M
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : wget-1.14-18.el7.x86_64 1/1
Verifying : wget-1.14-18.el7.x86_64 1/1

Installed:
wget.x86_64 0:1.14-18.el7

Complete!

The localinstall subcommand will instructs YUM Package Manager to look at your current working directory for your specified rpm package file. And you need to press y key for confirmation so that the installation can be completed.

YUM Tool should download and install all dependencies required for the package.

Uninstalling RPM Packages with YUM


If you are no longer need a package you installed before, you can also uninstall it by running the following yum command with remove subcommand, type:

$ sudo yum remove wget-1.14-18.el7.x86_64

Outputs:

[devops@devops ~]$ sudo yum remove wget-1.14-18.el7.x86_64
[sudo] password for devops:
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================
Removing:
wget x86_64 1.14-18.el7 installed 2.0 M

Transaction Summary
================================================================================================================================
Remove 1 Package

Installed size: 2.0 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Erasing : wget-1.14-18.el7.x86_64 1/1
Verifying : wget-1.14-18.el7.x86_64 1/1

Removed:
wget.x86_64 0:1.14-18.el7

Complete!
[devops@devops ~]$ rpm -qa | grep wget
[devops@devops ~]$

Note: you also need to press y key when Yum prompt you for confirmation. Then the RPM package will be erased from your system.

Downloading RPM Packages From the Default YUM Repository


There is a exciting command of the YUM Package Manager called yumdownloader, it can be used to download .rpm file directly from the default YUM repository.

For example, you want to download wget rpm package from YUM repository, just using yumdownloader command:

$ sudo yumdownloader wget

Outputs:

[devops@devops ~]$ sudo yumdownloader wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.njupt.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
wget-1.14-18.el7.x86_64.rpm | 547 kB 00:00:00

[devops@devops ~]$ ls
wget-1.14-18.el7.x86_64.rpm

You would see that wget package has been downloaded in your current working directory.

Listing Installed PRM Packages


If you want to check if the package is installed on your system, you can use rpm command with -qa option to list all installed rpm packages.

You still need to combine with grep command to filter out the results to only show your queried package, type:

$ rpm -qa | grep wget

Outputs:

[root@devops ~]# rpm -qa | grep wget
wget-1.14-18.el7.x86_64

Offline Installation of RPM Packages


If you have the correct download link of a rpm package, and you do not want to download it with command line tool curl or wget. You can use rpm command with -i option to install it from a remote location, using the following command:

$ sudo rpm -i https://mirrors.aliyun.com/centos/7.6.1810/os/x86_64/Packages/wget-1.14-18.el7.x86_64.rpm

Or you can also use yum install command with downloaded link of rom package, type:

$ sudo yum install https://mirrors.aliyun.com/centos/7.6.1810/os/x86_64/Packages/wget-1.14-18.el7.x86_64.rpm

Outputs:

[devops@devops ~]$ sudo yum install https://mirrors.aliyun.com/centos/7.6.1810/os/x86_64/Packages/wget-1.14-18.el7.x86_64.rpm
[sudo] password for devops:
Loaded plugins: fastestmirror
wget-1.14-18.el7.x86_64.rpm | 547 kB 00:00:00
Examining /var/tmp/yum-root-Hc2w6I/wget-1.14-18.el7.x86_64.rpm: wget-1.14-18.el7.x86_64
Marking /var/tmp/yum-root-Hc2w6I/wget-1.14-18.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================
Installing:
wget x86_64 1.14-18.el7 /wget-1.14-18.el7.x86_64 2.0 M

Transaction Summary
================================================================================================================================
Install 1 Package

Total size: 2.0 M
Installed size: 2.0 M
Is this ok [y/d/N]: y

Listing RPM Package files


After installed a rpm package on your system, you maybe want to list all the files that are installed with that package, you can use rpm command with -ql option to list package files, type:

$ rpm -ql wget

Outputs:

[devops@devops ~]$ rpm -ql wget
/etc/wgetrc
/usr/bin/wget
/usr/share/doc/wget-1.14
/usr/share/doc/wget-1.14/AUTHORS
/usr/share/doc/wget-1.14/COPYING
/usr/share/doc/wget-1.14/MAILING-LIST
/usr/share/doc/wget-1.14/NEWS
/usr/share/doc/wget-1.14/README
/usr/share/doc/wget-1.14/sample.wgetrc
/usr/share/info/wget.info.gz
/usr/share/locale/be/LC_MESSAGES/wget.mo
/usr/share/locale/bg/LC_MESSAGES/wget.mo
/usr/share/locale/ca/LC_MESSAGES/wget.mo
......

Get RPM Package Information


If you want to get more information about the installed package like package version, package release version, install Date, others. You can use rpm command with -qi option and then followed by an installed package name.

For example, you want to get more information about a installed package called wget, just using the following command:

$ rpm -qi wget

Outputs:

[devops@devops ~]$ rpm -qi wget
Name : wget
Version : 1.14
Release : 18.el7
Architecture: x86_64
Install Date: Sat 20 Apr 2019 06:15:16 AM EDT
Group : Applications/Internet
Size : 2055557
License : GPLv3+
Signature : RSA/SHA256, Mon 12 Nov 2018 09:49:08 AM EST, Key ID 24c6a8a7f4a80eb5
Source RPM : wget-1.14-18.el7.src.rpm
Build Date : Tue 30 Oct 2018 12:54:41 PM EDT
Build Host : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager : CentOS BuildSystem <http://bugs.centos.org>
Vendor : CentOS
URL : http://www.gnu.org/software/wget/
Summary : A utility for retrieving files using the HTTP or FTP protocols
Description :
GNU Wget is a file retrieval utility which can use either the HTTP or
FTP protocols. Wget features include the ability to work in the
background while you are logged out, recursive retrieval of
directories, file name wildcard matching, remote file timestamp
storage and comparison, use of Rest with FTP servers and Range with
HTTP servers to retrieve files over slow or unstable connections,
support for Proxy servers, and configurability.

If you want to get more information about a rpm package file whatever it is installed or not, you can use -qip option to rpm command.

$ rpm -qip wget-1.14-18.el7.x86_64.rpm

Conclusion


You should know that how to install/uninstall a rpm file through command line tool like rpm or yum on your CentOS or RHEL Linux 6/7.

How to Install VLC Media Player on Ubuntu Linux 16.04 or 18.04

This post will guide you how to  install VLC Media Player on your Ubuntu Linux 16.04 or 18.04. How do I install the latest VLC Player through command line on Ubuntu 18.04 LTS. This guide will talk several methods for you to install the Media player depending on whether you choose the command line or GUI of your Ubuntu system.

What is VLC Media Player?


VLC is a free and open source cross-platform multimedia player and framework that plays most multimedia files as well as DVDs, Audio CDs, VCDs and various streaming protocols.

VLC Media Player is also available for Desktop operating systems and mobile platforms, such as: Window phone, Android, IOS and Tizen.

Installing VLC Media Player Using Snap Tool


If you want to install the latest version of VLC Media Player on your Ubuntu 18.04, you can use the snap packaging system to install VLC Player. You can use Snappy packaging system to install the latest major VLC version. So you just need to open your Ubuntu terminal, and executing the following command to install VLC:

$ sudo snap install vlc

Outputs:

devops@devops:~$ sudo snap install vlc
[sudo] password for devops:
vlc 3.0.6 from VideoLAN✓ installed
devops@devops:~$

Note: if your Ubuntu system do not install snap tool, you can use the following command to install it, type:

$ sudo apt install snapd

After installed VLC package, you can use the following command to launch VLC Media Player through the terminal, type:

$ vlc

Outputs:

devops@devops:~$ vlc
VLC media player 3.0.4 Vetinari (revision 3.0.4-0-gf615db6332)
[000055cbba7a4640] main libvlc: Running vlc with the default interface. Use ‘cvlc’ to use vlc without interface.

If you want to launch vlc without interface, you can use the following command:

$ cvlc

vlc media player on ubunt1

Uninstalling VLC Using Snap

If you want to uninstall VLC package through the command line, you can use the following snap command in Ubuntu terminal, type:

$ sudo snap remove vlc

Outputs:

devops@devops:~$ sudo snap remove vlc
Disconnect vlc:opengl from core:opengl
vlc removed

Installing VLC Media Player Using APT


VLC Package is available on the default Ubuntu APT repository, so you can also use Advanced Package Tool or APT tool to install VLC. You need to refresh the software repository cache firstly with the following command:

$ sudo apt update

Then you can run the following command to install VLC Media Player, type:

$ sudo apt install vlc

Outputs:

devops@devops:~$ sudo apt install vlc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
vlc
0 upgraded, 1 newly installed, 0 to remove and 46 not upgraded.
Need to get 0 B/33.7 kB of archives.
After this operation, 224 kB of additional disk space will be used.
Selecting previously unselected package vlc.
(Reading database ... 322608 files and directories currently installed.)
Preparing to unpack .../vlc_3.0.4-1ubuntu0.2_amd64.deb ...
Unpacking vlc (3.0.4-1ubuntu0.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Setting up vlc (3.0.4-1ubuntu0.2) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...

After VLC package is successfully installed, you can verify the installation by checking the version of VLC that you installed, type:

$ vlc –version

Outupts:

devops@devops:~$ vlc --version
VLC media player 3.0.4 Vetinari (revision 3.0.4-0-gf615db6332)
VLC version 3.0.4 Vetinari (3.0.4-0-gf615db6332)
Compiled by buildd on lcy01-amd64-027.buildd (Oct 7 2018 01:20:32)
Compiler: gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04)
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute it under the terms of the GNU General Public License;
see the file named COPYING for details.
Written by the VideoLAN team; see the AUTHORS file.

To launch the VLC Media Player on your Ubuntu system, just type the following command in Ubuntu terminal:

$ vlc

Uninstall VLC Media Player Using Apt Command

If you have installed VLC Player via the default Ubuntu APT repository, and you can use the following apt command to uninstall VLC, type:

$ sudo apt remove vlc

Outputs:

devops@devops:~$ sudo apt remove vlc
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
vlc
0 upgraded, 0 newly installed, 1 to remove and 46 not upgraded.
After this operation, 224 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 322623 files and directories currently installed.)
Removing vlc (3.0.4-1ubuntu0.2) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Processing triggers for bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) ...
Rebuilding /usr/share/applications/bamf-2.index...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...

Installing VLC Media Player Using Ubuntu Software Center


The VLC Media Player is also available in the list of Ubuntu Software Center, so you can install it through the graphical interface on your Ubuntu system. Just do the following steps:

#1 click on the Show Applications button.
#2 click Ubuntu Software button.

vlc media player on ubunt2
#3 click the search button on the top right and type searching word “VLC”, press Enter key to locate VLC.

vlc media player on ubunt3

vlc media player on ubunt4

#4 Click on Install button and then authorize it with your password. You need to enter the password for a privileged user, and then click the Authenticate button.

vlc media player on ubunt5

vlc media player on ubunt6

#5 VLC will download and install on your Ubuntu system.

#6 after installed, click Launch button to launch VLC Player.

vlc media player on ubunt7 vlc media player on ubunt8

Note: if you want to uninstall VLC through GUI, just click Remove button.

Set VLC Media Player as the Default Media Player


The Default Media Player is RhythmBox utility. So if you want to change VLC Media Player as the default player, just do the following steps:

#1 open the Activities screen, and enter searching word “default applications ”, then click on it. The Default Application window will open.

vlc media player on ubunt9

#2 select VLC Media Player from the drop down list of Music.

vlc media player on ubunt10

Conclusion


You should know that how to install/uninstall VLC Media Player through command line or graphical interface on your Ubuntu 16.04 or 18.04.

How to Create a Self-Signed SSL Certificate on CentOS or Ubuntu Linux

This post will guide you how to create a self-signed SSL certificate on CentOS or Ubuntu Linux. How do I create a self-signed SSL Certificate using the Openssl tool on Linux system. How to create a self-signed SSL Certificate for your own Apache server.

openssl1

What is Self-Signed SSL Certificate?


A self-signed certificate used to encrypt communication between your server and any clients. because it is not signed by any of the trusted certificate authorities included with web browsers, users cannot use the certificate to validate the identity of your server automatically.

You can use OpenSSL tool to generate self-signed certificates which can be used for testing purposes or internal usage. And it also can be used to generate an RSA Private key.

Create Self-Signed SSL Certificate


Before creating self-signed SSL Certificate, you should make sure that the OpenSSL tool is installed on your Linux system. You can verify the version of OpenSSL by running the following command:

$ openssl version

Outputs:

devops@devops-osetc:~$ openssl version
OpenSSL 1.1.1 11 Sep 2018

If OpenSSL package is not install on your Linux system, you can ru n the following command to install it:

For CentOS or RHEL Linux:

Type the following command:

$ sudo yum install openssl -y

For Ubuntu or Debian Linux:

Type the following command:

$ sudo apt install openssl -y

Then you can use openssl command to create a self-signed certificate key, type:

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt

Outputs:

devops@devops-osetc:~$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/apache-selfsigned.key -out /etc/ssl/certs/apache-selfsigned.crt
[sudo] password for devops:
Can't load /home/devops/.rnd into RNG
140155030204864:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/home/devops/.rnd
Generating a RSA private key
.............+++++
...............................+++++
writing new private key to '/etc/ssl/private/apache-selfsigned.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:NewYork
Locality Name (eg, city) []:city
Organization Name (eg, company) [Internet Widgits Pty Ltd]:osetc
Organizational Unit Name (eg, section) []:IT
Common Name (e.g. server FQDN or YOUR name) []:osetc.com
Email Address []:mymail@osetc.com
devops@devops-osetc:~$

Note:
openssl: it is a basic command lien tool for createing or managing OpenSSL Certificates, keys or other files.
req: it is a sub command of openssl command, it is used to create certificate signing request.
-x509: create X.509 certificate.
-nodes: it will tell OpenSSL to skip the option to secure out certificate with a passphrase.
-days 365: This option sets the length of time that the certificate will be considered valid.
-newkey rsa:2048: create a new certificate request and 2048 bit RSA key.
-keyout: it tell OpenSSL where to place the generated private key file that you are creating.
-out: this tells OpenSSL where to place the certificate that you are creating.

Let’s check if the certificate and private keys are created, type:

devops@devops-osetc:~$ sudo ls /etc/ssl/private/apache-selfsigned.key
/etc/ssl/private/apache-selfsigned.key

devops@devops-osetc:~$ sudo ls /etc/ssl/certs/apache-selfsigned.crt
/etc/ssl/certs/apache-selfsigned.crt

Conclusion


You should know that how to create a self-signed certificate on your CentOS or Ubuntu Linux server with OpenSSL tool. And you can try to modify your Apache configuration to take advantage of those certificate files you are created.