How to Configure kiosk on Ubuntu 14.04 and Chrome

Prerequisites

Step 1: Install Ubuntu Server with LTE

Step 2: Install apache2 on Ubuntu

Step 3: Set user login without password authentication

# vim /etc/sudoers
%sudo ALL=(ALL) NOPASSWD: ALL

Step 4: Install Packages

# sudo apt update
# sudo apt install --no-install-recommends xorg openbox google-chrome-stable pulseaudio

Step 5: Set user in audio group

# usermod -a -G audio $USER

Step 6: Create a kiosk file

# vim /opt/kiosk.sh

#!/bin/bash

xset -dpms
xset s off
openbox-session &
start-pulseaudio-x11

while true; do
rm -rf ~/.{config,cache}/google-chrome/
google-chrome --kiosk --no-first-run  'http://Website URL'
done

Step 7: Set execute permission

# chmod +x /opt/kiosk.sh

Step 8: Set Configurations

# vim /etc/init/kiosk.conf

start on (filesystem and stopped udevtrigger)
stop on runlevel [06]

console output
emits starting-x

respawn

exec sudo -u USERNAME startx /etc/X11/Xsession /opt/kiosk.sh --

Step 9: Start X Server

# dpkg-reconfigure x11-common
After screen appears select "Anybody" and press "OK"

Step 10: Start kiosk service

# cd /etc/init/
# start kiosk

Step 11: Set the service in grub configuration

# vim /etc/default/grub

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

Step 12: Update grub by executing command

# update-grub

Step 13: Install lightdm service

# apt-get install lightdm

Step 14: Disable Desktop by lightdm

# echo manual | sudo tee /etc/init/lightdm.override

Step 15: Start lightdm service

# start lightdm

Step 16: Create /etc/lightdm/lightdm.conf File

Create a file /etc/lightdm/lightdm.conf and add the following content:

# vim /etc/lightdm/lightdm.conf
[SeatDefaults]
autologin-user=<YOUR USER>
autologin-user-timeout=0
user-session=ubuntu
greeter-session=unity-greeter

Step 17: Add service in startup script

# vim /etc/init.d/kisok
# service kisok start

4 ways to check size of physical memory in Linux

Introduction

In this article we will see basic commands to check the physical memory on the server under Linux. Many beginners struggle to know their system well in the context of resources such as CPU, Memory, Disks, etc. So I decided to write this small item pointing command to check the RAM on the Linux server. These commands will work in different flavors of Linux like Red Hat, CentOS, Suse, Ubuntu, Fedora, Debian etc.

1) Using free command

This command is mainly used to check the RAM and SWAP on the system. Using a different change, you can change the output byte format. Like -b for bytes, -k for kilobytes, -m for megabytes, and -g for gigabytes.

# free -b
              total        used        free      shared  buff/cache   available
Mem:     3976634368  3096838144   187990016    51572736   691806208   540106752
Swap:    4001361920     8826880  3992535040
# free -k
              total        used        free      shared  buff/cache   available
Mem:        3883432     3024204      183600       50364      675628      527488
Swap:       3907580        8620     3898960
# free -m
              total        used        free      shared  buff/cache   available
Mem:           3792        2953         179          49         659         515
Swap:          3815           8        3807
# free -g
              total        used        free      shared  buff/cache   available
Mem:              3           2           0           0           0           0
Swap:             3           0           3

2) Using /proc/meminfo file

# cat /proc/meminfo |grep Mem
MemTotal:        3883432 kB
MemFree:          183268 kB
MemAvailable:     527276 kB

3) Using top command

# top
top - 12:36:36 up 8 days,  2:58,  2 users,  load average: 0.14, 0.14, 0.08
Tasks: 213 total,   1 running, 212 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.2 us,  0.7 sy,  0.0 ni, 99.0 id,  0.2 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  3883432 total,   182356 free,  3025080 used,   675996 buff/cache
KiB Swap:  3907580 total,  3898960 free,     8620 used.   526608 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                            
 2303 root      20   0 2378464 541076   7692 S   1.0 13.9 417:16.56 OpsCenterDBd   

4) Using vmstat

[root@opscenter ~]# vmstat -s
      3883432 K total memory
      3025552 K used memory
      2439780 K active memory
       870348 K inactive memory
       181812 K free memory
       138712 K buffer memory
       537356 K swap cache
      3907580 K total swap
         8620 K used swap
      3898960 K free swap
      2323674 non-nice user cpu ticks
         2978 nice user cpu ticks
       944914 system cpu ticks
    135133743 idle cpu ticks
       692582 IO-wait cpu ticks
          121 IRQ cpu ticks
        49623 softirq cpu ticks
            0 stolen cpu ticks
      1931906 pages paged in
     23034525 pages paged out
          377 pages swapped in
         2353 pages swapped out
    956323695 interrupts
   2040196891 CPU context switches
   1505191059 boot time
       849343 forks

How to Install locate in Linux

Locate is very useful command to find the location of file/folder in linux.
Install mlocate package

# yum install mlocate

Update database by executing updatedb command

# updatedb

Now, locate any file/folder using “locate” command

# locate httpd

/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
/etc/httpd/conf.modules.d
/etc/httpd/logs
/etc/httpd/modules
/etc/httpd/run
/etc/httpd/conf/httpd.conf
/etc/httpd/conf/magic
/etc/httpd/conf.d/README
/usr/sbin/httpd
/usr/share/httpd
/usr/share/doc/httpd-2.4.6
/usr/share/doc/httpd-tools-2.4.6
/var/cache/httpd
/var/cache/httpd/proxy
/var/log/httpd
/var/log/httpd/access_log
/var/log/httpd/error_log

How to check Database size in Linux

We can check all the sizes of databases through execute a simple query in mysql server

Step 1: Login with mysql server

Login to mysql server by putting the mysql server credentials

# mysql -u username -p
Enter Password: 

Step 2: Execute the Query

Execute the mysql query in mysql server.

mysql> SELECT table_schema "Data Base Name",
    -> sum( data_length + index_length ) / 1024 / 1024 "Data Base Size in MB",
    -> sum( data_free )/ 1024 / 1024 "Free Space in MB"
    -> FROM information_schema.TABLES
    -> GROUP BY table_schema ;

 +---------------------------------+----------------------+------------------+
 | Data Base Name | Data Base Size in MB | Free Space in MB |
 +---------------------------------+----------------------+------------------+ 
 | about_demo_conf | 0.11203384 | 0.02596664 |
 | appstore | 0.02434349 | 0.00234127 |
 | cacti | 0.95234585 | 0.00552368 |
 | growingfeet | 0.10937500 | 11765.00000000 |
 | information_schema | 0.00781250 | 0.00000000 |
 | lotus_to_mysql | 0.47713852 | 0.00000000 |
 | moderapp_log | 0.00230408 | 0.00000000 |
 | moedeogeventmessen | 0.13060379 | 0.00000000 |
 | mysql | 0.66061878 | 0.00000000 |
 | vsftpd | 0.00310898 | 0.00000000 |
 | what2do | 0.03068542 | 0.00035095 | 
+---------------------------------+----------------------+------------------+

WiFi Router Security breaches

Introduction

Wifi security breaches when the research and development team scanned 32 WiFi router firmware firmware products offered by more than 10 of the most popular home, SMB and enterprise wireless routers in the US, Europe and Asia Manufacturer: Asus, Belkin, Buffalo, Cisco, D-Link, EFM, Huawei, Linksys, Netis and TP-Link.

Severity Level

The firmware of the WiFi router sold by the top vendors included versions of open source components with vulnerabilities specified in the binary scans. The firmware of most models contained security holes “Severity High” and “Severity Middle”. This means that deployed products and firmware updates remain vulnerable to potential security threats.

Results

The entire firmware uses Busybox and Samba by default, as the report shows. More than 60 percent used OpenSSL. Significant security issues arise from OpenSSL. This should prompt vendors to consistently use the latest patches or use the version of the software that contains the fix, the researchers said. Much of the firmware did not use the correct, most recent versions of OSS components available, the study found.

How to Add Date & Time with History in Linux

Introduction

The command history allows the use of words from previous command lines at the command prompt type. This simplifies spelling corrections and the repetition of complicated commands or arguments.

History Command

# history
  850  useradd admin
  851  passwd admin
  852  cd /home/admin/
  853  ls -l
  854  ls -la
  855  top

Edit the file /etc/bashrc add the entry at the end of the file /etc/bashrc

# vi /etc/bashrc
export HISTTIMEFORMAT="%h/%d - %H:%M:%S "

OR
You can also directly execute the following command:

# export HISTTIMEFORMAT="%h/%d - %H:%M:%S "

Now again check the “history” command:

# history
  850  31/08/15 07:22:21 useradd admin
  851  31/08/15 07:22:21 passwd admin
  852  31/08/15 07:22:21 cd /home/admin/
  853  31/08/15 07:22:21 ls -l
  854  31/08/15 07:22:21 ls -la
  855  31/08/15 07:22:21 top

Teams – Red Hat and Fedora Welcome Ubuntu to GNOME and Wayland with Open Arms

Canonical’s Mark Shuttleworth revealed nothing about Ubuntu’s development team that worked with the GNOME Devs, but until more details were revealed, it looks like the Red Hat Desktop and Fedora teams have taken the first step in welcoming Ubuntu and Canonical to the GNOME- And Wayland projects, hoping that they will have a fruitful long-term cooperation for the coming years.

“As most of you probably know that Mark Shuttleworth just announced that they would switch back to GNOME 3 and Wayland for Ubuntu, so I would like to welcome them on behalf of the Red Hat desktop and Fedora teams and say that We are looking forward to working to work with large canonical and Ubuntu people like Allison Lortie and Robert Ancell on projects of common interest around GNOME, Wayland and hopefully Flatpak, “said Christian Schaller in his recent blog post.

We do not know about Flatpak because Canonical will not give up its Snappy technologies, which seem to be very popular with the IoT (Internet of Things) manufacturers, but support for the next generation Wayland display server could be implemented Ubuntu 18.04 LTS operating system along with the GNOME shell interface. We can not wait to see how things stand out. Ubuntu as a GNU / Linux distribution will also be very popular without Unity.

How to Install PHP in nginx

Prerequisites

Install nginx web server

Step 1: Install PHP & PHP-FPM

Install packages php & php-fpm package on server using epel repository.

# yum --enablerepo=epel -y install php php-mbstring php-pear php-fpm

Step 2: Configure PHP-FPM

Modify user and group name in php-fpm configuration file.

# vi /etc/php-fpm.d/www.conf

user = nginx
group = nginx

Step 3: Start Service

Start php-fpm service.

# /etc/rc.d/init.d/php-fpm start

Starting php-fpm: [ OK ]
# chkconfig php-fpm on

Step 4: Configure default.conf file

Modify default.conf file.

# vi /etc/nginx/conf.d/default.conf
    # add follows in a "server" section

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        /etc/nginx/fastcgi_params;
    }

Step 5: Restart Service

Restart nginx server to execute the latest configurations.

# /etc/rc.d/init.d/nginx restart

Stopping nginx: [ OK ]
Starting nginx: [ OK ]

Step 6: Create a PHP Page

Create a PHP test page and save the file.

# echo "" > /usr/share/nginx/html/info.php

Open Your favorite browser and hit the URL: http://Your-IP-Address/info.php
phpinfo

How to reset root password in Linux

Introduction

If you forgot your root password, then it’s not a big deal. Below are the methods to reset root password in different linux distributions.

Step 1: Power on Redat/CentOS 7 Server

First power on your Redhat/CentOS 7 server. At the boot menu, select the Kernel you want to boot up and press e to edit the selected boot entry.

Password1

Find the line rhgb quiet :

password2

and replace it with init=/bin/bash

Password3

 

Then press CTRL+X to enter into single user mode.

Step 2: Mount / partition

# mount -o remount,rw /

Step 3: Change root password

# passwd root

Step 4: Create File

# touch /.autorelabel

Step 5: Execute Command

# exec /sbin/init

How to Configure MySQL Master-Master Replication

Step 1: Install MySQL Server

Install MySQL Server on both machines.

# apt-get update
# apt-get install mysql-server mysql-client

Step 2: Configure MySQL Servers

Edit the /etc/mysql/my.cnf file on both machines. Add or modify the following values:

Server 1:

# vi /etc/mysql/my.cnf
        server_id           = 1
        log_bin             = /var/log/mysql/mysql-bin.log
        log_bin_index       = /var/log/mysql/mysql-bin.log.index
        relay_log           = /var/log/mysql/mysql-relay-bin
        relay_log_index     = /var/log/mysql/mysql-relay-bin.index
        expire_logs_days    = 10
        max_binlog_size     = 100M
        log_slave_updates   = 1
        auto-increment-increment = 2
        auto-increment-offset = 1

Server 2:

# vi /etc/mysql/my.cnf
        server_id           = 2
        log_bin             = /var/log/mysql/mysql-bin.log
        log_bin_index       = /var/log/mysql/mysql-bin.log.index
        relay_log           = /var/log/mysql/mysql-relay-bin
        relay_log_index     = /var/log/mysql/mysql-relay-bin.index
        expire_logs_days    = 10
        max_binlog_size     = 100M
        log_slave_updates   = 1
        auto-increment-increment = 2
        auto-increment-offset = 2

Step 3: Modify my.cnf file with bind-address

Edit or add bind-address in my.cnf

# vi /etc/mysql/my.cnf    	
        bind-address    = x.x.x.x

Step 4: Restart MySQL Server

After inserting the above entries restart mysql server.

# service mysqld restart

Step 5: Create Replication Users

Connect with mysql server as root

# mysql -u root -p

Configure the replication users on each Linode. Replace x.x.x.x with the private IP address of the opposing Linode, and password with a strong password:

mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'x.x.x.x' IDENTIFIED BY 'password';

Run the following command to test the configuration. Use the private IP address of the opposing Linode:

 mysql -ureplication -p -h x.x.x.x -P 3306

Step 6: Configure Database Replication

Server 1:

While logged into MySQL on Server 1, query the master status:

mysql> SHOW MASTER STATUS;
    +------------------+----------+--------------+------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +------------------+----------+--------------+------------------+
    | mysql-bin.000001 |      120 |              |                  |
    +------------------+----------+--------------+------------------+
    1 row in set (0.00 sec)

Server 2:

On Server 2 at the MySQL prompt, set up the slave functionality for that database. Replace x.x.x.x with the private IP from the first server. Also replace the value for master_log_file with the file value from the previous step, and the value for master_log_pos with the position value.

mysql> SLAVE STOP;
mysql> CHANGE MASTER TO master_host='x.x.x.x', master_port=3306, master_user='replication', master_password='password', master_log_file='mysql-bin.000001', master_log_pos=106;
mysql> SLAVE START;

Step 7: Configure Database Replication Vice Versa

Server 2:

On Server 2, query the master status. Again note the file and position values.

mysql> SHOW MASTER STATUS;
    +------------------+----------+--------------+------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    +------------------+----------+--------------+------------------+
    | mysql-bin.000001 |      160 |              |                  |
    +------------------+----------+--------------+------------------+
    1 row in set (0.00 sec)

Server 1:

Set the slave database status on Server 1, replacing the same values swapped in step 2 with those from the Server 2.

mysql> SLAVE STOP;
mysql> CHANGE MASTER TO master_host='x.x.x.x', master_port=3306, master_user='replication', master_password='password', master_log_file='mysql-bin.000001', master_log_pos=160;
mysql> SLAVE START;

Step 8: Create Database

Test by creating a database and inserting a row:

Server 1:

mysql> create database test;
mysql> create table test.books (`id` varchar(10));

Server 2:

mysql> show tables in test;