Add & Delete Route on CentOS 7

route in centos7

Viewing the existing routing table

Before we embark on adding or deleting routes, it’s prudent to check the existing default routes on a system. To do so, simply launch your terminal and issue the command:

ip route show 


ip route list

Similar statistics can be displayed using route command,

 route -n

Also, you can use the good old netstat command, which is usually used for printing interface statistics as well as the routing table to achieve the same result.

sudo netstat -nr

With the default routing statistics in mind, let’s now move a step further and add some routes to our system.

Adding a static route using IP command

Suppose you want to take a backup of a Linux machine and push the backup file to another backup server in the subnet However, for one reason or the other, you cannot reach the backup server  via the default gateway. In this case, you will have to create a new route for backup server subnet via another IP, say via the interface enp0s3.

The command for this will be

sudo ip route add via dev enp0s3
  •      ->             is the network you want to connect to
  • /24              ->             is the subnet mask
  • ->    is the IP through which we will reach the server
  • enp0s3       ->            is the network interface

You can confirm whether new static route add been in route table using “ip route show” command.

sudo ip route show 

To add the specific IP of the backup server, say run the command:

sudo ip route add via dev enp0s3

Once again, you can check the routing changes to see if the changes exist using the ip route show command:

ip route show
route -n

Permanently adding static route (RHEL, Fedora, CentOS)

The routes we have just added are temporary and will not survive a reboot. To make the routes persistent, you need to manually add them.

In the /etc/sysconfig/network-scripts/directory, create an interface file route-interface where the interface attribute is your network interface name. In our case, this will be route-enp0s3.

vim /etc/sysconfig/network-scripts/route-enps03

Next, we will add  the routes as shown: via via

Save the file and exit. Then restart NetworkManager Service

sudo systemctl restart NetworkManager

Permanently adding static route (Ubuntu / Debian)

For Debian distributions, edit the file /etc/network/interfaces

$ sudo vim /etc/network/interfaces

Append the following line:

up route add -net netmask gw dev enp0s3

Save and exit the file. Finally, for the changes to come into effect, run below commands

$ sudo ifdown enp0s3 && sudo ifup enp0s3

Deleting a static route

To delete a specific route, use the ip route del command.

For example, to remove the route address we just added, run the command:

$ sudo ip route del via dev enp0s3

To delete a single IP route in a subnet run the command

$ sudo ip route del via dev enp0s3

To delete default route run:

$ sudo ip route del default
To add a default route run below ‘ip route add’ command,
$ sudo ip route add default via <ip-address> dev interface
For example:
$ sudo ip route add default via dev eth0

We hope that this tutorial was informative and provided you with insights into how you can go about adding and deleting static route in Linux.

read more

Back Up & Restore A MySQL Database

Back Up & Restore A MySQL Database

Back Up & Restore A MySQL Database | It is very essential to make regular backups of all data to prevent data loss. Has your MySQL database has been lost, and you’re scrambling to restore a copy from your last backup? Read these step below carefully to Back Up & Restore A MySQL Database using mysqldump & phpMyAdmin.

Back Up MySQL Database Using mysqldump

The mysqldump client utility can dump a database including the SQL statements required to rebuild the database.

By default, the dump file includes the SQL commands to restore the tables and data.

Here is the syntax of mysqldump to backup MySQL Database

sudo mysqldump -u [user] -p [database_name] > [filename].sql


  • Replace [user] with your username and password (if needed).
  • The [database_name] is the path and filename of the database.
  • The command specifies the output.
  • [filename] is the path and filename you want to save the dump file as.


Backup of an entire Database Management System:

mysqldump --all-databases --single-transaction --quick --lock-tables=false > full-backup-$(date +%F).sql -u root -p

You include more than one database in the backup dump file:

sudo mysqldump -u [user] -p [database_1] [database_2] [database_etc] > [filename].sql

Restore MySQL Using mysqldump

Step 1: Create New Database

On the system that hosts the database, use MySQL to create a new database.

Make sure you’ve named it the same as the database you lost. This creates the foundation file that mysqldump will import the data into. Since the dump file has the commands to rebuild the database, you only need to create the empty database.

Step 2: Restore MySQL Dump

To restore a MySQL backup:

mysql -u [user] -p [database_name] < [filename].sql


Make sure to include [database_name] and [filename] in the path.

It’s likely that on the host machine, [database_name] can be in a root directory, so you may not need to add the path. Make sure that you specify the exact path for the dump file you’re restoring, including server name (if needed).

How to Install Percona 8 in CentOS 7

Back Up & Restore A MySQL Database Using phpMyAdmin

Step 1: Create a MySQL Database Backup

1. Open phpMyAdmin. On the directory tree on the left, click the database you want to back up.

This should open the directory structure in the right-hand window. You’ll also notice that, in the directory tree on the left, all the assets under the main database are highlighted.

2. Click Export on the menu across the top of the display.

You’ll see a section called “Export Method.” Use Quick to save a copy of the whole database. Choose Custom to select individual tables or other special options.

Leave the Format field set to SQL, unless you have a good reason to change it.

3. Click Go. If you select Quick, your web browser will download a copy of the database into your specified downloads folder. You can copy that to a safe location.

Step 2: Clear the Old Database Information

It’s important to clear out old data before restoring a backup. If there’s any old data, it isn’t overwritten when you restore. This can create duplicate tables, causing errors and conflicts.

1. Open phpMyAdmin, on the navigation pane on the left, choose the database you want to restore.

2. Click the check all box near the bottom. Then, use the drop-down menu labeled With selected to select Drop.

3. The tool should prompt you to confirm that you want to go forward. Click yes.

This will get rid of all the existing data, clearing the way for your restoration.

Install MariaDB 10.4 on CentOS 7 : Easy Steps

Step 3: Restore Your Backed up MySQL Database

In phpMyAdmin, the Import tool is used to restore a database.

1. On the menu across the top, click Import.

2. The first section is labeled File to import. A couple of lines down, there’s a line that starts with “Browse your computer,” with a button labeled Choose File. Click that button.

3. Use the dialog box to navigate to the location where you’ve saved the export file that you want to restore. Leave all the options set to default. (If you created your backup with different options, you can select those here.)

4. Click Go.

read more

Configure FirewallD for Mail Server in Centos 7

Configure FirewallD for Mail Server

Configure FirewallD for Mail Server in Centos 7A mail server (or email server) is a computer system that sends and receives email. In many cases, web servers and mail servers are combined in a single machine. However, large ISPs and public email services (such as Gmail and Hotmail) may use dedicated hardware for sending and receiving email. In order for a computer system to function as a mail server, it must include mail server software. This software allows the system administrator to create and manage email accounts for any domains hosted on the server

Configure FirewallD for Mail Server

Check if firewalld is installed:

# which firewalld
/usr/bin/which: no firewalld in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

If not installed, install firewalld:

# yum install firewalld

Ensure that firewalld is running:

# systemctl start firewalld

List allowed services:

# firewall-cmd --list-service
dhcpv6-client ssh

How to Install Percona 8 in CentOS 7

Add required services: HTTPS, SMTP, IMAP, POP3, DAV, DHCP(May be required in a testing environment).

# firewall-cmd --zone=public --add-service=smtp --add-service=smtps --add-service=imap --add-service=imaps --add-service=pop3 --add-service=pop3s --add-service=https --add-service=dhcp --permanent
# firewall-cmd --zone=public --add-port=587/tcp --add-port=8443/tcp --permanent

Reload firewalld

# firewall-cmd --reload

List allowed services and ports. Check for previously added additions firewalld list rules

# firewall-cmd --list-all | grep 'services\|ports' | head -n 2
services: dhcpv6-client https imap imaps pop3 pop3s smtp smtps ssh
ports: 8443/tcp 587/tcp

Enable DNS over HTTPS (DoH) on Mikrotik

read more

Vim Keyboard Shortcut (or Vi) You Should Memorize


Vim Keyboard Shortcut – The Vim editor is a command-line based tool that’s an enhanced version of the venerable vi editor. Despite the abundance of graphical rich text editors, familiarity with Vim will help every Linux user – from an experienced system administrator to a newbie Raspberry Pi user.

One important thing to note when using Vim, is that the function of a key depends on the “mode” the editor is in. For example, pressing the alphabet “j” will move the cursor down one line in the “command mode”. You’ll have to switch to the “insert mode” to make the keys input the character they represent.

Shortcut Keys Function
Escape key Gets out of the current mode into the “command mode”. All keys are bound of commands.
i “Insert mode” for inserting text. Keys behave as expected.
: “Last-line mode” where Vim expects you to enter a command such as to save the document.
Navigation keys
h moves the cursor one character to the left.
j or Ctrl + J moves the cursor down one line.
k or Ctrl + P moves the cursor up one line.
l moves the cursor one character to the right.
0 moves the cursor to the beginning of the line.
$ moves the cursor to the end of the line.
^ moves the cursor to the first non-empty character of the line
w move forward one word (next alphanumeric word)
W move forward one word (delimited by a white space)
5w move forward five words
b move backward one word (previous alphanumeric word)
B move backward one word (delimited by a white space)
5b move backward five words
G move to the end of the file
gg move to the beginning of the file.
Navigate around the document
( jumps to the previous sentence
) jumps to the next sentence
{ jumps to the previous paragraph
} jumps to the next paragraph
[[ jumps to the previous section
]] jumps to the next section
[] jump to the end of the previous section
][ jump to the end of the next section
Insert text
a Insert text after the cursor
A Insert text at the end of the line
i Insert text before the cursor
o Begin a new line below the cursor
O Begin a new line above the cursor
Special inserts
:r [filename] Insert the file [filename] below the cursor
:r ![command] Execute [command] and insert its output below the cursor
Delete text
x delete character at cursor
dw delete a word.
d0 delete to the beginning of a line.
d$ delete to the end of a line.
d) delete to the end of sentence.
dgg delete to the beginning of the file.
dG delete to the end of the file.
dd delete line
3dd delete three lines
Simple replace text
r{text} Replace the character under the cursor with {text}
R Replace characters instead of inserting them
Copy/Paste text
yy copy current line into storage buffer
[“x]yy Copy the current lines into register x
p paste storage buffer after current line
P paste storage buffer before current line
[“x]p paste from register x after current line
[“x]P paste from register x before current line
Undo/Redo operation
u undo the last operation.
Ctrl+r redo the last undo.
Search and Replace keys
/search_text search document for search_text going forward
?search_text search document for search_text going backward
n move to the next instance of the result from the search
N move to the previous instance of the result
:%s/original/replacement Search for the first occurrence of the string “original” and replace it with “replacement”
:%s/original/replacement/g Search and replace all occurrences of the string “original” with “replacement”
:%s/original/replacement/gc Search for all occurrences of the string “original” but ask for confirmation before replacing them with “replacement”
m {a-z A-Z} Set bookmark {a-z A-Z} at the current cursor position
:marks List all bookmarks
`{a-z A-Z} Jumps to the bookmark {a-z A-Z}
Select text
v Enter visual mode per character
V Enter visual mode per line
Esc Exit visual mode
Modify selected text
~ Switch case
d delete a word.
c change
y yank
> shift right
< shift left
! filter through an external command
Save and quit
:q Quits Vim but fails when file has been changed
:w Save the file
:w new_name Save the file with the new_name filename
:wq Save the file and quit Vim.
:q! Quit Vim without saving the changes to the file.
ZZ Write file, if modified, and quit Vim
ZQ Same as :q! Quits Vim without writing changes

That’s the shortcut you can learn on Vim. So Let’s memorize all the Vim Keyboard Shortcut !!

read more

Semanage : Command Not Found in CentOS 7


Semanage is an SELinux (Security-Enhanced Linux) management tool that is used to configure specific elements without making any adjustments to or reassembling from policy sources. If you found semanage error (command not found), here’s how to overcome it.

Enter the following package that will provide this command

 yum provides /usr/sbin/semanage


yum whatprovides /usr/sbin/semanage

Install the policycoreutils-phyton by typing the following command

yum install policycoreutils-python

That’s it, how to fix semanage command not found in CentOS 7

read more

Install Nextcloud on CentOS 7 + Setting Let’s Encrypt SSL


Install Nextcloud on CentOS 7 – This guide will walk you through the installation of Nextcloud on CentOS 7 with PHP 7.3, Apache and MariaDB 10.4. You can optionally configure SSL encryption with Let’s Encrypt to ensure that access and data is being transferred through a secure tunnel. Nextcloud is an open-source seft-hosted syncing and file sharing server forked from ownCloud. It is written in PHP and JavaScript and has support for MySQL, PostgreSQL, SQLite and Oracle Database.

Install Nextcloud on CentOS 7 + Setting Let’s Encrypt SSL

Disable SELinux or Put in in Permissive mode

Disabling SELinux for smooth operations:

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Install PHP and httpd

sudo yum -y install epel-release yum-utils
sudo yum -y install

Disable default PHP 5.x enabled repository and enable one for PHP 7.3:

sudo yum-config-manager --disable remi-php54
sudo yum-config-manager --enable remi-php73

Install and Configure MariaDB / MySQL

Install MariaDB / MySQL database server on CentOS 7 using our previous guides. Choose one, recommended is MariaDB.

Read this : Install MariaDB 10.4 on CentOS 7 : Easy Steps

After the installation, login as a root user to MySQL console and create a new database for Nextcloud.

$ mysql -u root -p
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY "StrongPassword";
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';

Download and Install Nextcloud on CentOS 7

sudo yum -y install wget unzip

Unzip the downloaded file & remove source file:

rm -f

Move the resulting nextcloud folder to /var/www/html directory

sudo mv nextcloud/ /var/www/html/

Create data directory to store Nextcloud uploaded files. This can be any path e.g NFS mount point, SAN mount point e.t.c.

sudo mkdir /var/www/html/nextcloud/data
sudo chown apache:apache -R /var/www/html/nextcloud/data

Give apache user and group the ownership of nextcloud folder.

sudo chown apache:apache -R /var/www/html/nextcloud

Configure Apache VirtualHost – Without SSL

Create an Apache configuration file for Nextcloud

sudo vim /etc/httpd/conf.d/nextcloud.conf

Paste code below to file

<VirtualHost *:80>
  ServerAdmin [email protected]
  DocumentRoot /var/www/html/nextcloud
  <directory /var/www/html/nextcloud>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews
    SetEnv HOME /var/www/html/nextcloud
    SetEnv HTTP_HOME /var/www/html/nextcloud

Set correct ServerName and change other settings to suit your use.

When done, save the file and start httpd service.

sudo systemctl enable --now httpd
sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/html(/.*)?"
sudo sudo restorecon -Rv /var/www/html

If you have an active firewalld service, allow http and https ports.

sudo firewall-cmd --add-service={http,https} --permanent
sudo firewall-cmd --reload

Configure Apache With Let’s Encrypt SSL

To use Let’s Encrypt SSL certificate, first install certbot

chmod a+x certbot-auto
sudo mv certbot-auto /usr/local/bin

Then request for SSL certificate.

export DOMAIN=""
export EMAIL="[email protected]"
certbot-auto certonly --standalone -d $DOMAIN --preferred-challenges http --agree-tos -n -m $EMAIL --keep-until-expiring

Don’t forget to change domain name & email above with yours

Modify your VirtualHost configuration file to look like below.

<VirtualHost *:80>
   ServerAdmin [email protected]
   RewriteEngine On
   RewriteCond %{HTTPS} off
   RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

<IfModule mod_ssl.c>
   <VirtualHost *:443>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/nextcloud
     <directory /var/www/html/nextcloud>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews
        SetEnv HOME /var/www/html/nextcloud
        SetEnv HTTP_HOME /var/www/html/nextcloud
     SSLEngine on
     SSLCertificateFile /etc/letsencrypt/live/
     SSLCertificateKeyFile /etc/letsencrypt/live/

Access Nextcloud UI and finish installation

Open your nextcloud server URL as configured on Apache:

Setup admin password

Setup Database, don’t forget to using MariaDB and set credentials

When done click the “Finish Setup” button. You should get the Files dashboard of Nextcloud. Now install Nextcloud Agent on your end device to start syncing files.

Thanks for using our guide to install Nextcloud on CentOS 7.

read more

Install MariaDB 10.4 on CentOS 7 : Easy Steps


Install MariaDB 10.4 on CentOS 7 – In this page, we will guide you how to setup MariaDB 10.4 on CentOS 7. As of this writing, the latest stable release of MariaDB is 10.4.  The default version of MariaDB installed on CentOS 7 is 5.5. This versions are available on OS upstream repositories.

Note that before you can setup MariaDB 10.4, you may need to uninstall the current version of MariaDB server. You can ignore this if upgrading.  On Ubuntu, run:

sudo yum remove mariadb-server

Add MariaDB YUM repository to CentOS 7 server:

cat <<EOF | sudo tee /etc/yum.repos.d/MariaDB.repo
name = MariaDB
baseurl =

Clean yum cache index:

sudo yum makecache fast

Install MariaDB 10.4 on CentOS 7:

sudo yum -y install MariaDB-server MariaDB-client

Start and enable MariaDB service:

sudo systemctl enable --now mariadb

Secure MariaDB by running mysql_secure_installation

sudo mysql_secure_installation 


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Log in and check MariaDB version:

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.4.6-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> select version();
| version()      |
| 10.4.6-MariaDB |
1 row in set (0.000 sec)

Or, You can also check version using:

# mysql -V


Those are steps how to Install MariaDB 10.4 on CentOS 7

IF you have any question, please write down below in comments

read more

How to Install Percona 8 in CentOS 7

How to Install Percona 8 in Centos 7 – Percona Server for MySQL® is a free, fully compatible, enhanced and open source drop-in replacement for any MySQL database. It provides superior performance, scalability and instrumentation.

Percona Server for MySQL is trusted by thousands of enterprises to provide better performance and concurrency for their most demanding workloads, and delivers greater value to MySQL server users with optimized performance, greater performance scalability and availability, enhanced backups and increased visibility.

So essentially, yes. It is MySQL with some (very interesting) tweaks. You should use it when it solves a particular problem that you’re having. The list of differences are available at the product documentation page (linked above), but here’s a short list of what I believe are among the most compelling features:

– Improved Buffer Pool Scalability
– HandlerSocket included by default
– InnoDB Data Dictionary Size Limit
– Dynamic Row Format Memory Tables
– Extra slow query log statistics and configuration options

Follow these steps to Install Percona 8 in CentOS 7


yum install

Enable percona server 8.0 repo

percona-release setup ps80

Install percona server

sudo yum install percona-server-server

Start mysql Server

service mysql start

Find the temporary password and login to mysql

sudo grep "temporary password" /var/log/mysqld.log

Run mysql_secure_installation


Change the password, answer “yes” every question

Those are the article How to Install Percona 8 in CentOS 7, Keep going..

read more

How to Set Nano as Default Editor on CentOS 7

How to Set Default Editor to Nano on CentOS 7 – Not everyone is familiar with the “vim” text editor. Its many shortcuts are also not easy to memorize. One of the most commonly used text editors is nano, but in the CentOS 7 standard installation, nano is not yet a standard text editor. Therefore, follow the steps below to make nano as a standard text editor, so that it will be easier for us to do editing, for example, to edit crontab

Install nano

Execute command below to install nano

yum -y install nano

Disable Word Wrap

Nano by default enables word wrap. While nice in a normal document, this is generally undesirable in a configuration file

echo "set nowrap" >>/etc/nanorc

Set System Default Editor

During login, a number of scripts are run to setup the environment. In CentOS, a file for each subject is used. These are stored in a system profile directory, /etc/profile.d/. There are two environment variables that control which editor to use.

cat <>/etc/profile.d/
export VISUAL="nano"
export EDITOR="nano"

Set Per User Default

If a user wishes to set the default editor for themselves, it can be, instead, be done in the user’s bash profile.

cat <>~/.bash_profile
export VISUAL="nano"
export EDITOR="nano"


Try by opening crontab. execute commnad below

crontab -e

If it opened in nano, so, those steps is right..Try to logout and then login again if still fail

Thats is steps to Set Nano as Default Editor on CentOS 7, if you want to install Percona on Centos 7, please follow this link

read more
We would like to show you notifications for the latest news and updates.
Allow Notifications