Allow SSH root login on Ubuntu 18.04

By default Ubuntu 18.04 installation comes with unset root password. To set root password open up terminal and execute the following linux command:

$ sudo passwd
[sudo] password for user: 
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully

Edit SSH configuration file: /etc/ssh/sshd_config and set property PermitRootLogin to yes:

Save configuration file and restart ssh service by command:

sudo service ssh restart

Gitlab – create and restore backup

To create backup enter command:

sudo gitlab-rake gitlab:backup:create

First we need to make sure that the backup tar file is in the backup directory described in the gitlab.rb configuration (Default is /var/opt/gitlab/backups). Next, we need gitlab running for restoring backup on ominbus installations. If it’s not up, start with,

sudo gitlab-ctl start

and we need to have services that are connected to database in stopped state,

sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq

Copy files from backup folder (/var/opt/gitlab/backups) to external hard drive, also copy files:

/etc/gitlab/gitlab-secrets.json
/etc/gitlab/gitlab.rb

Now execute the following command to restore the backup on server,

sudo gitlab-rake gitlab:backup:restore BACKUP=1393157476_2018_03_11_9.1.0

here, 1393157476_2018_03_11_9.1.0 is the name of the backup file that will be restored. Once the backup has been restored, we need to restart the gitlab services,

sudo gitlab-ctl restart

We now have successfully restored gitlab from the backup file.

Turn off clamav for email in VestaCP

You should edit /etc/exim4/exim.conf

#CLAMD =  yes
CLAMD =  no

edit /usr/local/vesta/conf/vesta.conf and comment / remove clamav

#ANTIVIRUS_SYSTEM='clamav'
ANTIVIRUS_SYSTEM=''

than disable and stop the service

systemctl disable clamd
systemctl stop clamd
systemctl restart exim

Test exim (send and receive email)
watch your log

How to install multiple PHP versions on VestaCP

First download and start manager php from Github:

git clone https://github.com/petranikin/mgrvphp.git
cd mgrvphp
bash mgrvphp

Then enter version of PHP You need to install (remember that you need to enter fool version: 7.1.4). All versions of PHP You can see on site: http://php.net/releases

Install packages and dependencies: Yes

Create links in /usr/bin : Yes

Create template in VestaCP: Yes

Then wait when script install PHP on Your server (it took me more than 30 minutes)

Once the installation is complete, you can go to the panel to install the desired template:

How to check PHP version on server and site?

Create the file phpinfo.php. Open it with a text editor and enter the following:

‹?php
phpinfo();
?›

Upload the file to the root of the site → open the file in the browser and look at the installed version of php:

Best php open source projects

1. Laravel

This is the best php-framework for new projects, web-sites, internet stores and other network projects.

The GitHub page of Laravel from where you can download and see the project code is: https://github.com/laravel/laravel

2. Symfony

Another PHP framework for web applications is Symfony. It is used by thousands of web applications (including BlaBlaCar.com and Spotify.com) and most of the popular PHP projects (including Drupal and Magento).GitHub Stars: 17.8k+

The GitHub page of Symfony from where you can download and see the project code is: https://github.com/symfony/symfony

3. Composer

Composer helps you declare, manage, and install dependencies of PHP projects.

GitHub Stars: 14.9k+

The GitHub page of Composer from where you can download and see the project code is: https://github.com/composer/composer

4. PHPMailer

PHPMailer is the best php library for sending email. Supports many mail servers including Gmail.

The GitHub page of PHPMailer from where you can download and see the project code is: https://github.com/PHPMailer/PHPMailer

How to view information about ONU on BDCOM OLT

I’ll give you an example of viewing information about ONT (ONU) on EPON OLT BDCOM P3310C, on other models is essentially the same.

Connect to OLT and go into configuration mode:

enable
config

To view the ONU list, use the commands:

show epon onu-information
show epon active-onu
show epon inactive-onu

Example of viewing MAC addresses on a port or ONU:

show mac address-table interface EPON0/1
show mac address-table interface EPON0/1:5
show mac address-table brief

Viewing the optical power of all ONUs on the first port and a specific ONU:

show epon optical-transceiver-diagnosis interface EPON 0/1
show epon interface ePON 0/1:4 onu ctc optical-transceiver-diagnosis

View ONU models and firmware versions:

show epon onu-software-version
show epon onu-software-version interface EPON 0/1

View description and status of interfaces:

show interface brief

ONU ethernet port status and viewing statistics:

show epon interface epON 0/1:1 onu port 1 state
show epon interface epON 0/1:1 onu port 1 statistics
show epon interface epON 0/1:1 onu mac address-table

Also you can see in the saved and active OLT configuration which ONUs are registered:

show configuration
show running-config

ONU reboot example:

epon reboot onu interface ePON 0/1:1

How to change MAC address on Mikrotik Routerboard

By default changing MAC address of ethernet interface in Mikrotik Winbox is disabled:

But You can very simple change MAC in terminal.
In left side menu select New Terminal:

Then enter command:

/interface ethernet set ether1 mac-address=XX:XX:XX:XX:XX:XX

Where ether1 is required interface and XX:XX:XX:XX:XX:XX is new MAC address of your device.

Thats all.

Create Shortcut for Windows program in Ubuntu

  1. Download png icon of your program from Internet.
  2. Create file name.desktop and insert next code:
[Desktop Entry]
Name=ProgramName
Exec=wine "/home/user/Programs/ProgramName/ProgramName.exe"
Icon=/home/user/Programs/ProgramName/ProgramName.png
Type=Application
Categories=Wine;
Name[en_US]=ProgramName

Change text “ProgramName” to name of your program.

Finally change permission for execution this file. That’s all. See the video:

Create React js application with Yarn

Very simple way to create new application on React JS using Yarn.

First of all install LTS version of Node.js on your computer from official site: https://nodejs.org/en/download/

Then also install stable version of Yarn from official site: https://yarnpkg.com/en/docs/install. (You can read here how to install Yarn in Ubuntu).

Next lets create new folder “react-app” with files of our application. In this folder create two empty files: index.html, package.json, and subfolder src such as on screenshot:

File index.html will have basic html markup:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>React App</title>
</head>
<body>
    <noscript>
        You need to enable JavaScript to run this app.
    </noscript>

    <div id="root"></div>

    <!-- Bundle -->
    <script src="./src/index.js"></script>
</body>
</html>

In subfolder src create file index.js, it will be main file of our react application:

Source code of index.js file:

import React from 'react';
import ReactDOM from 'react-dom';

const App = () => (
    <div>
        React App
    </div>
);
ReactDOM.render(<App />, document.getElementById('root'))

In file package.json write next code:

{
    "name": "ReactApp",
    "author": "Author Name",
    "license": "License Name",
    "homepage": "Author Website",
    "email": "Author Email",
    "version": "1.0.0",
    "scripts": {
      "start": "cross-env NODE_ENV=development parcel index.html --no-cache -d build/dev",
      "build": "cross-env NODE_ENV=production parcel build index.html --no-cache -d build/production"
    },
    "dependencies": {
      "@hot-loader/react-dom": "^16.8.4",
      "cross-env": "^5.2.0",
      "parcel-bundler": "latest",
      "react": "^16.8.4",
      "react-dom": "^16.8.4"
    },
    "devDependencies": {
      "babel-core": "^6.26.3",
      "babel-plugin-import": "^1.11.0",
      "babel-preset-react-app": "^7.0.1"
    }
  }

This file contains information about your project and all outsiders packages, used in your application.

That’s all, our simple react application ready. Now lets run it. Open your command line and go to your project folder:

To compose your application write command:

yarn

Yarn will download all packages and compose your application:

To run your program just enter command:

yarn start

This command builds your react application and start local server http://localhost:1234

Enter on this address in your browser and you will see your application:

Now if you change any source code in your project, it will be automatic changed in browser:

That’s all, finally look in folder build. There You will find compiled JavaScript code with your application which you can use in production.

React it’s simple! Good luck 😉