Updating Ubuntu 14.04 to 16.04

Before updating I recommend to make a backup copy of the important information.

Update the system to the current state:

sudo apt-get update
sudo apt-get upgrade

Restart:

sudo reboot

Let’s see the current version:

lsb_release -a

We are ready to upgrade to version 16.04:

sudo update-manager -d

Or so:

sudo do-release-upgrade

After the update is complete, you will need to reboot.
I will note that many packages will also be updated, for example PHP5 will be updated to PHP7, etc., so you need to be ready for this.
How to downgrade the PHP version I described in this article – How to install PHP 5.6 in Ubuntu 16
Or how to upgrade here – Upgrading PHP Version on Ubuntu 14.04

Connect to SSH using the keys

To connect to SSH without entering a password, you can generate public and private keys on the local north, then copy it to a remote machine, then the password will not be asked when connecting to it.

On the local machine, generate the keys:

sudo ssh-keygen -t rsa

Copy the public key to the remote server:

sudo ssh-copy-id -i ~/.ssh/id_rsa.pub -p PORT USER@HOST

If an error occurs while copying the key, you can manually copy the line from id_rsa.pub to the remote server in the authorized_keys file.

The specified commands must be executed from the user from whom the connection will be made.
For example, if from root, then you need to execute the following command before the two commands:

sudo -i

You can remove the host by:

ssh-keygen -f "/home/user/.ssh/known_hosts" -R [HOST]:22

See also:
Installing and Configuring SSH

How do I enable the Universe repository in Ubuntu?

I once wanted to install some utilities on the running LiveCD with Ubuntu Desktop, the same MC, etc., which did not want to be installed.

To solve this problem, you need to include the “Universe” repository.

And so, add it:

sudo add-apt-repository universe

In older versions of Ubuntu, you might have to add another command:

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"

If desired, you can include all the repositories:

sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe multiverse restricted"

And update the list of packages:

sudo apt-get update

After that, everything was install successfully.

Above $(lsb_release -sc) specifies the version of Ubuntu and inserts it into the link.

You can also manually check the version by running the command:

lsb_release -sc

Installing Open-AudIT on Linux

Open-Audit — a system for collecting information about existing equipment and creating reports.

On an example I will describe the installation process in Linux Ubuntu:

1) Download the latest version from the official site
https://www.open-audit.org/downloads.php

2) Switch to the root user, make the downloaded file with Open-AudIT executable and run it:

sudo -i
chmod u+x ./OAE-Linux-x86_64-release_1.12.10.1.run
sh ./OAE-Linux-x86_64-release_1.12.10.1.run

In the installation process, follow the instructions, agreeing with the questions pressing “y” or “Enter“.
Additional components such as apache2, mysql-server, etc. will be automatically installed.

3) Open in the browser web-interface Open-AudIT by reference http://HOST/omk/oae/
Standard login and password – admin/password

Done.

Setting the default mail address in cPanel

Suppose you want all mail that arrives at nonexistent mailboxes in your domain to be delivered to a specific mailbox.

For this:

1) On the cPanel main page, in the “Email” section, select “Default Address

2) In the window that opens, select the domain (if there are several), select “Forward to Email Address” and specify which address to forward.

Instead of sending it, you can also choose to delete emails, forward to a system mail account, or send to a script.

Done.

SMS sending script via Goip4 gateway

Here is an example of a script written in PHP, for sending SMS messages through the Goip4 gateway.
The script receives data from the SQL database with a query and alternately sends SMS to each number, and also writes an entry about sending it to a special sms table.
Continue reading “SMS sending script via Goip4 gateway”

How to connect Google Drive to Linux using Grive

Grive – the console client allows you to synchronize data with Google Drive.

Install the necessary components:

sudo apt-get install git cmake build-essential libgcrypt11-dev libyajl-dev \
libboost-all-dev libcurl4-openssl-dev libexpat1-dev libcppunit-dev binutils-dev

Tried to install the command apt-get install grive, but in this case I have an old version installed, which is no longer workable.
So create a directory and clone the latest Grive source files from the official source:

mkdir grive
cd grive/
sudo git clone https://github.com/Grive/grive.git
cd grive/

Let’s build Grive from the source files:

sudo dpkg-buildpackage -j4

If desired, you can build manually:

mkdir build
cd build
sudo cmake ..
sudo make -j4
sudo make install

The installation of Grive is complete, now we will create and move to any directory where Google Drive will be synchronized:

mkdir ~/GoogleDrive
cd ~/GoogleDrive

Request an authorization token from Google:

grive -a

After the startup, a link will be generated that will need to go to the browser, login to the account, allow access, copy the response code and enter it in the terminal, then synchronization will begin.

In the future, for synchronization, go to the directory and run Grive:

cd ~/GoogleDrive
grive

You can save the synchronization report to a file:

grive -l ~/log.txt

To view the current version of Grive, use the command:

sudo grive -v

Installing and Configuring Bacula

Bacula – a set of client-server programs for managing backups.
It consists of the components of Director Daemon (DD), Storage Daemon (SD), File Daemon (FD) and Bacula Console (BC).

To install in Ubuntu/Debian, perform:

sudo apt-get install bacula

During the installation process, the MySQL user’s root password will be requested and a database created, and Postfix installed.

Create directories and set permissions:

sudo mkdir -p /bacula/backup /bacula/restore
sudo chown -R bacula:bacula /bacula
sudo chmod -R 700 /bacula

Open the configuration file DD, for example, in the text editor nano:

sudo nano /etc/bacula/bacula-dir.conf

Let’s find “Standard Restore template” and there where “Where” we change the path:

Job {
Name = "RestoreFiles"
Type = Restore
Client=Blank-fd
FileSet="Full Set"
Storage = File
Pool = Default
Messages = Standard
Where = /bacula/restore
}

Further we find “List of files to be backed up” and a little bit lower where “File =” we specify that it is necessary to copy in a backup copy.

Unnecessary directories can be deleted by adding for example:

Exclude {
File = /bacula
File = /proc
File = /tmp
}

Open the configuration file SD:

sudo nano /etc/bacula/bacula-sd.conf

Let’s find “Devices supported by this Storage daemon” and specify in “Archive Device =” where to store backup copies, for example:

Archive Device = /bacula/backup

We test the correctness of the configuration:

sudo bacula-dir -tc /etc/bacula/bacula-dir.conf
sudo bacula-sd -tc /etc/bacula/bacula-sd.conf

If the command did not say anything, then everything is fine and there are no errors.

Restart bacula services to apply configuration changes:

sudo service bacula-sd restart
sudo service bacula-director restart

Let’s check if all three services are running:

netstat -nlpt | grep [b]acula

Open the console bacula:

sudo bconsole

Check status:

status

We type the command:

label

and specify the name of the backup, then specify 2 that this file.

Run our configured backup process (select 1 and yes):

run

View successful completion messages:

messages

Leave the console bacula:

quit

A backup file should appear in the /bacula/backup directory.

See also:
How to install Bacula-web

How to install Bacula-web

Bacula-Web – a web-based tool for creating reports and monitoring Bacula.

Install the necessary components:

sudo apt-get install apache2 libapache2-mod-php5 php5-mysql php5-gd
sudo a2enmod php5
sudo a2enmod rewrite

Open the PHP configuration file in the editor and specify the time zone:

sudo nano /etc/php5/apache2/php.ini
date.timezone = Europe/Kiev

And also for the directory with Bacula-Web we specify the option:

sudo nano /etc/apache2/sites-enabled/000-default.conf
<Directory /var/www/html/bacula-web>
AllowOverride All
</Directory>

Restart apache2 to apply the changes:

sudo service apache2 restart

Let’s go to the web server directory, download the archive with the latest version of Bacula-web and unpack it:

cd /var/www/html
curl -O http://www.bacula-web.org/files/bacula-web.org/downloads/bacula-web-latest.tgz
mkdir -v /var/www/html/bacula-web
tar -xzf bacula-web-latest.tgz -C /var/www/html/bacula-web

Make a copy of the sample configuration file and open it for example in the text editor nano:

cd /var/www/html/bacula-web/application/config
cp -v config.php.sample config.php
sudo nano /var/www/html/bacula-web/application/config/config.php

Uncomment and configure MySQL parameters:

$config[0]['label'] = 'Backup Server';
$config[0]['host'] = 'localhost';
$config[0]['login'] = 'bacula';
$config[0]['password'] = 'test';
$config[0]['db_name'] = 'bacula';
$config[0]['db_type'] = 'mysql';
$config[0]['db_port'] = '3306';

Since some commands were executed through sudo, we will specify the correct owner of the files:

sudo chown -R www-data:www-data /var/www/html/bacula-web

This completes the installation, you can open the Bacula-Web from the http://SERVER/bacula-web link, and also it is advisable to look at the http://SERVER/bacula-web/test.php test page that will tell you whether all the necessary components are installed and configured.

See also:
Installing and Configuring Bacula