Category: Fedora/CentOS/RedHat

Rename git branch

Use git command line (with git bash on Windows) to change the branch name.

1 – Be sure you are on the right branch

Firstly, you should be on your current branch (the branch you want to rename) with git checkout.

2 – Change the name of the branch locally

Secondly, you should rename the branch with the following command:

git branch -m <the_new_branch_name>

The new branch name should be valid, with no space. If you use special characters you should use quotes like:

git branch -m “let’s-put-a-complicated-name”

3 – Change the name of the branch remotely

You can now change the name of the branch remotely so it’s also changed on github / gitlab / bitbucket etc.
To do push it use:

git push origin HEAD:<old_branch_name>

If it’s a complicated name you can still use the quotes:
git push origin HEAD:”it’s-an-old-branch-name”

Kill Node.JS service by port / Arrêter un service Node.JS avec son port

🇬🇧Dear all, is it possible you want to kill a Node.JS service with your linux machine, that is running on a specific port

Il est possible que vous voulez arrêter un processus Node.JS sur un port précis sur votre machine linux🇫🇷

Here is the magic command to find and kill the Node.JS process

Voici la commande magique qui permet de trouver et arrêter de processus avec son port

netstat -pluton
It looks like the name of the famous planet / Moyen mémo-technique on pense à cette p’tite planete

Then you should be able to find the process (PID) with the port associated

Vous devriez avec cette commande trouver le nom du processus (PID) avec le port associé

PORT 4000:

Renew automatically HTTPS SSL certificates with cron and Certbot

Use the command crontab -e to edit the crontab (recurring tasks), and insert the following line:

0 0 1 * * /usr/bin/certbot renew --pre-hook “service nginx stop” --post-hook “service nginx start” --quiet > /etc/letsencrypt/renewals.log

It will renew all the certificates, the 1st of each month (0 0 1 * *), and will stop nginx before the renewal and start nginx after the renewal so it can works.
It will work on all the linux servers.

Use Crontab for automating recurring tasks on Fedora/CentOS

You can use a tool that is called “Crontab” for recurring tasks automation. It is available for all the Linux systems and still the most used solution.

Edit the crontab configuration file

crontab -e

This will open vi, the default linux editor, that will allow you to edit the recurring tasks for a specific date and time.

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  *  user command to be executed

In vi the main commands used are:
– The escape key (:x! to save OR :q! to quit)
– a to append text
– i to insert text
– dd to remove the line
– x to delete the current selected character

Verify the date and time zone

You can verify the date and the time zone (most of the cloud machines are using the UTC time zone). you can use the following command “date”:

# date
Wed Aug  4 01:10:10 UTC 2021

Install MariaDB on a Fedora/CentOS/RedHat server

If you have your own server, the first thing you may want to do with your backend shoud be to install a database server on it.

Here is step by step how to install a MySQL/MariaDB (almost the same) database on your server:
Install the MariaDB service:

yum install mariadb mariadb-server

Create your user access – change the username and password you want:

mysql
CREATE USER username@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' ;
flush privileges;

Verify the user has been created:

SELECT User FROM mysql.user;

You should be able to login on your database from you app and remotely.