Generate csr file for ssl certificate

Run below command to generate key file:

openssl genrsa -out yourkey_filename.key 2048



Run below command to generate csr:


openssl req -new -key yourprivatekey_filename.key -out yourcsr_filename.csr


After this enter all input and generate csr.

Npm install with sudo safe perm

sudo npm install -g eslint --unsafe-perm=true --allow-root

Change mysql root password

Setting MySQL Root Password

To reset MySQL root password, logon to the Ubuntu server and run the commands below to stop MySQL database service
sudo /etc/init.d/mysql stop
Then run the commands below to create a new mysqld directory
sudo mkdir /var/run/mysqld/
and give mysql user access to it.
sudo chown mysql /var/run/mysqld/
After that, run the commands below to start MySQL in safe mode by bypassing the standard authentication process..
sudo mysqld_safe --skip-grant-tables &
You should see something like this… you may have to press the Enter key
richard@ubuntu1710:~$ 2017-12-25T16:49:30.551520Z mysqld_safe Logging to syslog.
2017-12-25T16:49:30.554646Z mysqld_safe Logging to '/var/log/mysql/error.log'.
2017-12-25T16:49:30.578079Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
2017-12-25T16:49:32.568746Z mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

[1]+  Done                    sudo mysqld_safe --skip-grant-tables
Next, run the commands below to logon to the database server with the root account without typing a password… you’re given root access to the database without entering the password…
sudo mysql -u root
Once logged into the database, run the SQL command statement below to use the default mysql database… this database holds the settings for root user and other server settings…
use mysql;
The output should look like the one below:
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
Finally, run the SQL statement below to change the root password
update user set authentication_string=PASSWORD("New_Passwore_Here")where User='root';
Save the change by running the commands below
flush privileges;
exit;
Finally, stop MySQL safe_mode and start MySQL default service
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
If you did everything as described above, you should be able to log back onto MySQL database using the root new password.
sudo mysql -u root -p
Enjoy!
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.20-0ubuntu0.17.10.1 (Ubuntu)

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

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

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
This is how one resets MySQL root user.

Ubuntu java service wrapper

This is a simple wrapper to run a Java program as service. You need to be a root user. In this example SYSTEMD is used instead of init.d because it's becoming obsolete


Instructions:
  1. Create a file under  /etc/systemd/system/   with nano or vi and paste the example script below. eg.  sudo vi /etc/systemd/system/MyService.service
  2. Paste the code below in your new file:



  • Create a file with under /usr/local/bin/ eg. sudo vi /usr/local/bin/MyService.sh
  • Paste the Code example below
  • Modify the SERVICE_NAME, PATH_TO_JAR, and choose a PID_PATH_NAME for the file you are going to use to store your service ID.
  • Write the file and give execution permisions ex. sudo chmod +x /usr/local/bin/MyService.sh
  • Test that it runs ex. /usr/local/bin/./MyService.sh start
  • Test that it stops ex. /usr/local/bin/./MyService.sh stop
  • Test that it restarts ex. /usr/local/bin/./MyService.sh restart
  • Enable the service with the command sudo systemctl enable MyService
  • To run the service sudo systemctl start MyService.service
  • To stop the service sudo systemctl stop MyService.service
Copy the code example: