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

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 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

How to Install, Delete, Update packages in RedHat/Fedora/CentOS

Introduction

RPM (Red Hat Package Manager) is an open source package management utility for RHEL, CentOS and Fedora based systems and is used for following purposes:

  • Install
  • Delete
  • Update
  • Query
  • List
  • Verify

Syntax

RPM filename contains four parts Package Name, Version, Release & Architecture Name

vsftpd-2.2.2-14.el6.i686.rpm

Package Name – vsftpd
Version – 2.2.2-14
Release – el6
Architecture – i686

1) Install an RPM Package

To install an RPM Package on linux machine use the following command.

# rpm -ivh vsftpd-2.2.2-14.el6.i686.rpm

Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

where
-i : install
-v : verbose
-h: print hash marks

2) Delete an RPM Package

To remove a package use -e option in order to delete an RPM package.

# rpm -e vsftpd

3) Update an RPM Package

Use -U option to update/upgrade an RPM package.

# rpm -Uvh vsftpd-2.2.2-14.el6.i686.rpm
Preparing... ########################################### [100%]
1:vsftpd ########################################### [100%]

4) Query an RPM Package

To query specific package use -qa option

# rpm -qa|grep vsftpd
vsftpd-2.2.2-14.el6.i686

-q : Query a package

5) List an RPM Package

To view the package list use -ql option

# rpm -ql vsftpd-2.2.2-14.el6.i686.rpm

6) Verify an RPM Package

In order to verify RPM package use the following command

# rpm -Va

Note: There is another easiest method to install,delete,update packages in RedHat/Fedora/CentOS based machine through YUM commands.

How to Create Alias in Linux

The alias command can be used if you want to create a ‘shortcut’ to a shell command.

Syntax

# alias name='command'

Configuration

There are some frequently used commands, so in order to create the shortcuts we create the aliases for them in ~/.bashrc or /etc/bash.bashrc file.

# vi ~/.bashrc

alias search='grep'
alias v='vdir'
alias vdir='/bin/ls $LS_OPTIONS --format=long'
alias which='type -path'
alias wtf='watch -n 1 w -hs'
alias wth='ps -uxa | more'
alias cd..='cd ..'
alias cp='cp -i'
alias d='ls'
alias df='df -h -x supermount'
alias du='du -h'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
alias grep='grep --color'
alias ls='ls -F --color=auto'
alias l='ls'
alias la='ls -a'
alias ll='ls -l'
alias lsd='ls -d */'
alias md='mkdir'
alias mv='mv -i'
alias p='cd -'
alias rd='rmdir'
alias rm='rm -i'

Save the file and enjoy shortcuts 🙂

TCP/UDP Ports

Fatal error YUM: Thread died in Berkeley DB library

I got an error while upgrading my CentOS server

# yum update
rpmdb: Thread/process 29212/3077682880 failed: Thread died in Berkeley DB library
error: db3 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db3 -  (-30974)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed

Step 1: Delete Databases

Remove database files from location /var/lib/rpm/

# rm /var/lib/rpm/__db*
rm: remove regular file `/var/lib/rpm/__db.001'? y
rm: remove regular file `/var/lib/rpm/__db.002'? y
rm: remove regular file `/var/lib/rpm/__db.003'? y
rm: remove regular file `/var/lib/rpm/__db.004'? y

Step 2: Run updates

Now execute the yum update command.

# yum update
Loaded plugins: fastestmirror, security
Setting up Update Process
Loading mirror speeds from cached hostfile
 * base: mirror.fysik.dtu.dk
 * epel: ftp.crc.dk
 * extras: mirror.fysik.dtu.dk
 * updates: mirror.fysik.dtu.dk
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction first to finish them.
--> Running transaction check
---> Package bind.i686 32:9.8.2-0.30.rc1.el6_6.1 will be updated
---> Package bind.i686 32:9.8.2-0.30.rc1.el6_6.3 will be an update
---> Package bind-chroot.i686 32:9.8.2-0.30.rc1.el6_6.1 will be updated
---> Package bind-chroot.i686 32:9.8.2-0.30.rc1.el6_6.3 will be an update
---> Package bind-devel.i686 32:9.8.2-0.30.rc1.el6_6.1 will be updated
---> Package bind-devel.i686 32:9.8.2-0.30.rc1.el6_6.3 will be an update
---> Package bind-libs.i686 32:9.8.2-0.30.rc1.el6_6.1 will be updated
---> Package bind-libs.i686 32:9.8.2-0.30.rc1.el6_6.3 will be an update
---> Package bind-sdb.i686 32:9.8.2-0.30.rc1.el6_6.1 will be updated
---> Package bind-sdb.i686 32:9.8.2-0.30.rc1.el6_6.3 will be an update
---> Package bind-utils.i686 32:9.8.2-0.30.rc1.el6_6.1 will be updated
---> Package bind-utils.i686 32:9.8.2-0.30.rc1.el6_6.3 will be an update
---> Package busybox.i686 1:1.15.1-20.el6 will be updated
---> Package busybox.i686 1:1.15.1-21.el6_6 will be an update

Redirect Error Output To File in Linux

In Bash shell or other advance shell there are three file descriptors and these are:

  • stdin (0)
  • stdout (1)
  • stderr (2)

Redirect all error to file

# command 2> stderr.txt

Redirect output & errors to different files

# tecdistro > stdout.txt 2> stderr.txt

Redirect output and errors to same file

# tecdistro > allout.txt 2>&1

RunLevels in Linux

0 Halt the system.
1 Single-user mode
2 Local Multiuser with Networking but without network service
3 Full Multiuser with Networking
4 For Testing Purpose
5 Full Multiuser with Networking and X Windows
6 Reboot

How to Find Out Current Run Level Command

There are 7 run levels in linux as listed above, To check the current Run Level use the command:

# who -r
run-level 3  2015-01-03 08:10   

OR

# cat /etc/inittab
id:3:initdefault:

How to Change Run Level Command

In order to change the run level in linux use init command:

# init 1