KSEB IT Help

Ajayakumar

  • Increase font size
  • Default font size
  • Decrease font size
linuxtips.com

DEBIAN ARTICLES

Quick notes for Creating LVM.

 Create partitions sdb1, sdc1, sdd1, sde1 with partition type as linux LVM  (code name 8e)          (using fdisk)

 1. create physical volume for LVM from these partitions

         #pvcreate /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

    physical volume can be removed with the command

         #pvremove /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

    created physical volue can be seen with the command

         #pvdisplay


 

2. create a volume group named fileserver containing above physical volumes.

               # vgcreate fileserver /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

    The newly created volume group can be seen with commands

               # vgdisplay

               # vgscan

    The volume group can be renamed to data with command

               # vgrename fileserver data

               # vgrename data fileserver

    The volume group can be removed with the command

               # vgremove fileserver


3. create  logical volumes share (40GB), backup (5GB), and media (1GB) in the volume group fileserver.

 

              # lvcreate --name share --size 40G fileserver

 

              # lvcreate --name backup --size  5G fileserver

 

              # lvcreate --name media  --size  1G fileserver

     Get overview of logical volume

              # lvdisplay

              # lvscan

    LV can be renamed (media is renamed to films)

              # lvrename fileserver media films

   LV can be removed 

              # lvremove /dev/fileserver/films

 

4. Change the size of LV media from 1GB to 1.5GB

                       # lvextend -L1.5G /dev/fileserver/media

      Again sheink it back to 1GB

            # lvreduce -L1G /dev/fileserver/media

      

5. Create an ext3 filesystem in share, an xfs filesystem in backup, and a reiserfs filesystem in media:

                    # mkfs.ext3 /dev/fileserver/share

                           # mkfs.xfs /dev/fileserver/backup

           # mkfs.reiserfs /dev/fileserver/media


6.  mount share in /var/sharebackup in /var/backup, and media in /var/media

          # mkdir /var/media /var/backup /var/share

          # mount /dev/fileserver/share /var/share

          # mount /dev/fileserver/backup /var/backup

          # mount /dev/fileserver/media /var/media



 

Change the ownership of a database and its objects


Login into the database using psql and...

db=> REASSIGN OWNED BY old_role [, ...] TO new_role;

All the ownership by the old_roles will be changed to new_role.


Find the pids of postgres process

$ ps -u postgres o pid=

sed – changes the pids to paths to smaps files and total the memory usage of postgres

# ps -u postgres o pid= | sed 's#.*#/proc/&/smaps#' | xargs grep ^Pss: | awk '{A+=$2} END{print A}'

Whiptail is a program that allows shell scripts to display dialog boxes to the user for informational purposes, or to get input from the user in a friendly way. Whiptail is included by default on Debian.

From the Linux Dictionary: whiptail is a "dialog" replacement using newt instead of ncurses.
From its README: whiptail is designed to be drop-in compatible with dialog(1), but has less features: some dialog boxes are not implemented, such as tailbox, timebox, calendarbox, etc.

Try using dialog to replace whiptail if you don't have whiptail: alias whiptail='dialog'

Note that there are also other dialog-compatible programs like xdialog (Displays X11 Windows) and zenity (aka gdialog, displays Gtk Windows). Reading dialog's manual page should be helpful. Always read the man pages or --help so you know in which way they're different from dialog.

Info box

A simple type of dialog box in Whiptail is the info box. This shows a dialog box containing text to the user.

whiptail --title "Example Dialog" --infobox "This is an example of an info box." 8 78 

In the example above, the value of --title is displayed at the top of the dialog box. The first argument to --infobox is the dialog box text which is shown beneath the title. The next two arguments specify the height and width of the dialog box. The width is set to 78 as most terminals will be at least 80 columns or more.

Message box

A message box is very similar to an info box, except that it waits for the user to hit the OK button. Usage is similar to the info box:

whiptail --title "Example Dialog" --msgbox "This is an example of a message box. You must hit OK to continue." 8 78 

Yes/no box

The simplest way to get input from the user is via a Yes/no box. This displays a dialog with two buttons labelled Yes and No.

# If you cannot understand this, read Bash_Shell_Scripting#if_statements again. if (whiptail --title "Example Dialog" --yesno "This is an example of a yes/no box." 8 78) then echo "User selected Yes, exit status was $?." else echo "User selected No, exit status was $?." fi 

Input box

A way to get free-form input from the user is via an input box. This displays a dialog with two buttons labelled Ok and Cancel.

COLOR=$(whiptail --inputbox "What is your favorite Color?" 8 78 Blue --title "Example Dialog" 3>&1 1>&2 2>&3) # A trick to swap stdout and stderr. # Again, you can pack this inside if, but it seems really long for some 80-col terminal users. exitstatus=$? if [ $exitstatus = 0 ]; then echo "User selected Ok and entered " $COLOR else echo "User selected Cancel." fi echo "(Exit status was $exitstatus)" 

Text box

A text box with contents of the given file inside.

echo "Welcome to Bash $BASH_VERSION" > test_textbox # filename height width whiptail --textbox test_textbox 12 80 

Menus

Whenever you want to present a list of options to the user, whiptail has several dialog types to choose from.

A menu should be used when you want the user to select one option from a list, such as for navigating a program.

whiptail --title "Menu example" --menu "Choose an option" 20 78 16 \ "<-- Back" "Return to the main menu." \ "Add User" "Add a user to the system." \ "Modify User" "Modify an existing user." \ "List Users" "List all users on the system." \ "Add Group" "Add a user group to the system." \ "Modify Group" "Modify a group and its list of members." \ "List Groups" "List all groups on the system." 

The values given to --menu are:

  • The text describing the menu ("Choose an option")
  • The height of the dialog (20)
  • The width of the dialog (78)
  • The height of the menu list (16)

The rest of the values are a list of menu options in the format tag item, where tag is the name of the option which is printed to stderr when selected, and item is the description of the menu option.

If you are presenting a very long menu and want to make best use of the available screen, you can calculate the best box size by.

eval `resize` whiptail ... $LINES $COLUMNS $(( $LINES - 8 )) ... 

Check list

At some point, you will want to present options to the user which would not be appropriate to place in a menu.

A check list allows a user to select one or more options from a list.

whiptail --title "Check list example" --checklist \ "Choose user's permissions" 20 78 4 \ "NET_OUTBOUND" "Allow connections to other hosts" ON \ "NET_INBOUND" "Allow connections from other hosts" OFF \ "LOCAL_MOUNT" "Allow mounting of local devices" OFF \ "REMOTE_MOUNT" "Allow mounting of remote devices" OFF 

When the user confirms their selections, a list of the choices is printed to stderr.

Radio list

A radio list is a dialog where the user can select one option from a list. The difference between a radio list and a menu is that the user selects an option (using the space bar in whiptail) and then confirms that choice by hitting OK.

 

Progress gauge

Syntax: whiptail --gauge <text> <height> <width> [<percent>]

Also reads percent from stdin:

#!/bin/bash { for ((i = 0 ; i <= 100 ; i+=5)); do sleep 0.1 echo $i done } | whiptail --gauge "Please wait while we are sleeping..." 6 50 0 




Tips

foobar=$(whiptail --inputbox "Enter some text" 10 30 3>&1 1>&2 2>&3)

Proxy setting to be done in a client for using with apt-get

Debian/Ubuntu

If you have internet connectivity through a proxy server and you want to apt-get install some packages

Adding following line to /etc/apt/apt.conf has solve the problem:



Acquire::http::proxy "http://10.1.3.1:8080/";


If file does not exist, create it. Do not confuse it with apt.conf.d directory.


CentOS/RedHAT/Fedora-core

 

The settings below enable yum to use the proxy server mycache.mydomain.com, connecting to port 3128, with the username yum-user and the password qwerty.

 

# The proxy server - proxy server:port number


Installing Debian-8 Beta-2

 

changed /etc/network/interfaces
changed /etc/apt/sources.list
deb http://security.debian.org/ testing/updates main contrib non-free
deb http://apt.postgresql.org/pub/repos/apt/ jessie-pgdg main
----------------------------------------
set proxy for better internet speed

created file /etc/apt/apt.conf with following entry

Acquire::http::proxy "http://172.17.204.10:80/";

------------------------------------------
apt-get update

apt-get install sudo

usermod -a -G sudo <username>

reboot

-------------------------------------------
sudo apt-get install xfce4 xfce4-goodies

startx

reboot

aptitude install lightdm

sudo apt-get install synaptic apt-xapian-index gdebi gksu menu
apt-get install firmware-linux-nonfree
apt-get install firmware-linux
apt-get install firmware-realtek
apt-get install amd64-microcode

apt-get install ttf-freefont ttf-mscorefonts-installer ttf-bitstream-vera ttf-dejavu ttf-liberation
apt-get install flashplugin-nonfree
apt-get install pepperflashplugin-nonfree

postgresql apahe2 php5 pgadmin3 php5-pgsql libphp-adodb
gigolo gvfs-backends gvfs-fuse  --for connect to the server

apt-get install file-roller evince parcellite qalculate clementine vlc bleachbit gimp shotwell gparted gnome-disk-utility libreoffice-writer libreoffice-calc libreoffice-impress chromium

Install Synapse in Ubuntu

Synapse is a fast search tool for accessing ubuntu applications.

$ sudo apt-add-repository ppa:synapse-core/testing

$ sudo aapt-get update

$ sudo apt-get install synapse

Database size of KSEB apps

 as on 13-1-2015

Sl No Application Size in GB
1 HRIS 16 GB
2 SARAS 15 GB
3 SCM 4 GB
4 Enrgise 16 GB
5 OrumaNet 286 GB


 

OpenVZ is container-based virtualization for Linux. OpenVZ creates multiple secure, isolated Linux containers (otherwise known as VEs or VPSs) on a single physical server enabling better server utilization and ensuring that applications do not conflict. Each container performs and executes exactly like a stand-alone server; a container can be rebooted independently and have root access, users, IP addresses, memory, processes, files, applications, system libraries and configuration files.

OpenVZ Official Website openvz.org

About install CentOS please reference to Install CentOS 6.4 in Text Mode

Installation can be divided into two ways, the first is more complex, use the rpm installation, you need to manually download and install the package; second relatively simple, is through YUM to install. Here is through YUM to install.

Host Operating System: CentOS Release 6.4 Final
Kernel Version: 2.6.32-358.e16.x86_64

Install OpenVZ
Configuration YUM source
Download openvz.repo file to /etc/yum.repos.d/ directory, use the following command to complete

1
2
3
$ cd /etc/yum.repos.d
$ sudo wget http://download.openvz.org/openvz.repo
$ sudo rpm --import  http://download.openvz.org/RPM-GPG-Key-OpenVZ

Install OpenVZ Kernel and vzctl, vzquota
Note: For RHEL6 or CentOS6 or later, use vzkernel, for other versions ovzkernel

1
2
$ sudo yum install vzkernel
$ sudo yum install vzctl vzquota

Configuration CentOS kernel parameters and SELinux properties
Configure the OS kernel parameters, enter /etc/sysctl.conf file, modify the following two parameters

1
2
3
$ sudo vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
kernel.sysrq = 1

SELinux is the 2.6 version of the Linux kernel provides mandatory access control system, install OpenVZ need to disable it, enter /etc/sysconfig/selinux file, in accordance with the following settings

1
2
$ sudo vi /etc/sysconfig/selinux
SELINUX=disabled

Reboot System
Start OpenVZ
Before starting OpenVZ can first check the service status

1
2
$ service vz status
$ service vz start

VE Template Installation
Download a template needs to be installed to /vz/template/cache directory (If the host is Debain, you need to download to /var/lib/vz/template/cache/ directory), Install VC needs according to their different requirements of the VE will vary. We can go to http://download.openvz.org/template/precreated/ download already installed templates, there centos, debian, ubuntu, fedora, suse, etc. you can choose several templates.

1
2
cd /vz/template/cache
$ sudo  wget http://download.openvz.org/template/precreated/centos-6-x86.tar.gz

Create an ID of 1 Virtual Environment (VE)

1
2
3
4
5
6
7
8
9
10
$ sudo vzctl create 1 --ostemplate ubuntu-10.04-x86
 
$ sudo vzctl set 1 --onboot yes --save
$ sudo vzctl set 1 --ipadd 172.16.82.129 --save
$ sudo vzctl set 1 --nameserver 8.8.8.8 --save
$ sudo vzctl set 1 --hostname vps01.vpsee.com --save
$ sudo vzctl set 1 --diskspace 10G:10G --save
 
$ sudo vzctl start 1
$ sudo vzctl exec 1 passwd

Start, restart, shutdown and power off ID 1 VE/VPS

1
2
3
4
$ sudo vzctl start 1
$ sudo vzctl restart 1
$ sudo vzctl stop 1
$ sudo vzctl destroy 1

View the running VE/VPS

1
$ sudo vzlist

Computing ID 1 VE/VPS resources used

1
$ sudo vzcalc -v 1

Enter and Exit the Guest

VE can enter the system after successful startup, the equivalent of the xen xm console, command exit to exit the guest.

1
2
$ sudo vzctl enter 1
$ sudo exit

 

Install CentOS 6.4 in Text Mode

 

CentOS (“Community Enterprise Operating System”) is a Linux distribution which attempts to provide a free enterprise class computing platform which has 100% binary compatibility with its upstream source, Red Hat Enterprise Linux (RHEL). As of version 6.4, it officially supports x86 and x86-64 architecture with Physical Address Extension, while a beta is expected to be available for PowerPC.
The first CentOS was based upon RHEL version 2.1AS, and was numbered as CentOS version 2.
Official Website www.centos.org
Installation Process

Install CentOS 6.4 in Text Mode

centos-2

centos-3

centos-4

centos-5

centos-6

centos-7

centos-8

centos-9

centos-10

centos-11

centos-12

centos-13

Install VMware Tools
If you install CentOS in a VMware virtual machine.

1
2
3
4
5
6
7
8
$ su
# mount /dev/cdrom  /mnt/
# cp /mnt/VMwareTools-9.6.1-1378637.tar.gz /tmp/
# cd /tmp/
# tar -xvzf VMwareTools-9.6.1-1378637.tar.gz
# cd vmware-tools-distrib/
# chmod 777 vmware-install.pl
# ./vmware-install.pl

Afer install

1
# umount /dev/cdrom  /mnt/

login with root account, and reate a new user.

1
2
3
# useradd username
# passwd username
# echo 'username ALL=(ALL) ALL' >> /etc/sudoers

Open SSH Service

1
# /etc/init.d/sshd start

If you want to allow external network connected to the server, please close the iptables

1
# /etc/init.d/iptables stop

check SSH whether the run level is set to boot

1
2
3
$ sudo chkconfig --list sshd
$ sudo chkconfig --level 2345 sshd on
$ sudo service sshd restart

Update

1
$ sudo yum update

How To Find IP Conflicts In Linux


If you’re having connectivity issues and suspect it is due to IP conflict you can use a tool called arp-scan to detect them.

This tool sends ARP (Address Resolution Protocol) packets on local network to collect the addresses. If there is multiple MAC addresses claiming the same IP address, then there is conflict.

To install arp-scan on Ubuntu or Debian type:

$ sudo apt-get install arp-scan

For Fedora, CentOS or Redhat:

$ sudo yum install arp-scan

To detect IP conflicts, run the following:

$ sudo arp-scan –I eth0 -l    (scan in the local network)

$ sudo arp-scan 192.168.1.50-192.168.1.100 -I eth0 (scan this range of ip's only)
$ sudo arp-scan 192.168.1.0/24 -I eth0 (scan the ip's from 192.168.1.1 to 192.168.1.254)

An output example:

192.168.1.10 00:1b:a9:63:a2:4c BROTHER INDUSTRIES, LTD. 192.168.1.30 00:1e:8f:58:ec:49 CANON INC. 192.168.1.33 00:25:4b:1b:10:20 Apple, Inc 192.168.1.37 10:9a:dd:55:d7:95 Apple Inc 192.168.1.38 20:c9:d0:27:8d:56 (Unknown) 192.168.1.39 d4:85:64:4d:35:be Hewlett Packard 192.168.1.39 00:0b:46:e4:8e:6d Cisco (DUP: 2) 192.168.1.40 90:2b:34:18:59:c0 (Unknown)

In this instance, the 19.168.1.39 IP is in conflict since it appears twice.


  • LVM

    Wednesday, 21 May 2014 01:29
  • Postgresql Tips and Tricks-2

    Thursday, 22 May 2014 11:54
  • Whiptail for Dialog

    Wednesday, 24 September 2014 06:54
  • Proxy setting for apt

    Tuesday, 23 December 2014 07:34
  • How to install Debian-8 testing

    Thursday, 01 January 2015 09:05
  • Install synapse in ubuntu 14.04

    Thursday, 01 January 2015 09:09
  • Database size

    Wednesday, 14 January 2015 10:11
  • Install OpenVZ in centos 6.4

    Saturday, 17 January 2015 00:21
  • Install CentOS 6.4 in text mode

    Saturday, 17 January 2015 00:28
  • IP conflict scanner

    Friday, 23 January 2015 01:36

 


  Ubuntu articles

Warning: Division by zero in /var/www/linuxhelp/modules/mod_xpertcontents/tmpl/default.php on line 40 Warning: Division by zero in /var/www/linuxhelp/modules/mod_xpertcontents/tmpl/default.php on line 44

Install synapse in ubuntu 14.04

Install Synapse in Ubuntu Synapse is a fast search tool for accessing ubuntu applications. $ sudo apt-add-repository ppa:synapse-core/testing$ sudo aapt-get update$ sudo apt-get install synapse

Read more: %s

Convert a VOB file to avi

Converting VOB file from DVD to avi using mencoder Install mencoder   (sudo apt-get install mencoder) Issue the following command in a terminal mencoder sourcefile.VOB -alang English -info srcform="<" -oac mp3lame -lameopts abr:br=128 -ovc xvid -xvidencopts bitrate=4999:chroma_opt:vhq=4:bvhq=1:quant_type=mpeg -vf pp=de,crop=0:0:0:0,scale=480:-2 -o "outputfilename.avi"

Read more: %s

Installing Virtual box in ubuntu

Installing Virtual Box in Ubuntu Install dkms       using sudo apt-get install dkms Download Virtual box deb package from this site https://www.virtualbox.org/wiki/Downloads install it by double clicking (will be opened in ubuntu software center) After installation the current user must be added to the group virtualboxusers To do this find out the goups the current user is att..

Read more: %s

Install cvsd server in ubuntu

Installing CVS Server on Ubuntu 11.04 1. Install required packages sudo apt-get install cvsd   When asked    enter     /demo:/project1 2. Adjust daemon parameters Open the configuration file: sudo vi /etc/cvsd/cvsd.conf Most likely, you gonna need to change these lines: # This..

Read more: %s

 

Atheros network card installation in Debian6

Aheros Network card installation in Debian6 Ubuntu10.04 etc.


      Atheros network card driver is not available in Linux 2.6.32.

      So this driver has to be compiled and added as aloadable module in the kernel.

 

Read more...
 

Adding repository in CentOS

To install softwares from EPEL repository.


Repository entries can be done with apropriate rpm packages.

The rpm package for epel repository can be found here

Read more...
 
Banner