Custom Search
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Friday, August 22, 2014

How To Use expect with bash script

#!/bin/bash

username="saju"
password="saju"


expect -c "
        ##Enable debug mode
        #exp_internal 1
        #set timeout 20
        spawn ssh $username@192.168.56.101
        expect "?assword:"
        send \"$password\r\"

        ##To Get console after SSH
        interact"






Howto Debug Expect Script


#!/usr/bin/expect -f

#Enable debug mode
exp_internal 1

set timeout 20

spawn ssh saju@192.168.56.101
expect "password"
send "saju\n"


##To Get console after SSH
interact











Expect Script Example for SSH


#!/usr/bin/expect -f

#Enable debug mode
#exp_internal 1

set timeout 20

spawn ssh saju@192.168.56.101
expect "password"
send "saju\n"


##To Get console after SSH
interact







Friday, July 11, 2014

Awk Introduction


#keystone tenant-list

#keystone tenant-list | awk '{print $2}'

#keystone tenant-list | awk '/demo/ {print $2}'

#keystone tenant-list | awk '/. +demo/ {print $2}'




Thursday, July 10, 2014

Howto passwordless SSH to Virtual Machine using ssh-keygen

1)
In your Host Machine generate SSH public and private key or use your existing SSH public and private key in the "~./ssh" folder.
#ssh-keygen -t rsa

* This command will create "id_rsa" and "id_rsa.pub" in "~./ssh" folder.

2)
2a)

SSH to your Remote Virtual Machine with username and password.
Example : #saju@192.168.56.192

2b)
* Goto "~./ssh" folder.
* Create a file named "authorized_keys"
* Copy the content in the "id_rsa.pub" fle from your Host Machine to "authorized_keys" file.

Example:
#cd ~./ssh
#touch authorized_keys
#echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCzXy5baXmVnfFoBKbLbkhWY8iNJp6ZqFYorQNUwLtHHOXo0mcFjQDQAUpcim+mGxcJkq1b4VmPhtts3jg9p08XMfh3nxNEYsOXAyiwxaN6rmMiPQAubuwloBAE
WdRXmd+166NR6A9tn2U/kKq1pTQi81P8LNkI9O74ZJ6jK6AOg+Qzvl2Dd9rUQ7wnL2GYK923Ckpj68Si3rh7F8hSU2HfyJrFUUsWV0dfszAheXt44Pw51gPSgyJhZd1Ja+omdtzpHGa2SyTV6d/uPd/ISS2mY5sISL1Ywvwk
tNbkC9VmqWP8ZrmN/qd5PgqPVVIhs8TEtj3AWdBhfcW1e5YC1Gn7 saju@ubuntu" > authorized_keys


3)
Goto your Host Machine and SSH to your Virtual Machine without password like
#ssh saju@192.168.56.192
OR
#ssh -i id_rsa saju@192.168.56.192

Thursday, July 3, 2014

Howto Linux Split Terminal Window Easily with Terminator

1)
Install terminator

#sudo apt-get install terminator

2)
Open terminator


3)
* Split Horizontally

Ctrl + Shift + o

* Split Vertically
Ctrl + Shift + e

Friday, April 18, 2014

SOLVED:ERROR nova.openstack.common.threadgroup [-] internal error Cannot find suitable emulator for x86_64

Error:
====
https://bugs.launchpad.net/heat/+bug/1308959/comments/3

I can see following error in nova-compute (n-cpu*) and its not running. I am using libvirtd (libvirt) 0.9.8 + Ubuntu 12,04 lts
=========================
2014-04-17 19:43:34.497 ERROR nova.openstack.common.threadgroup [-] internal error Cannot find suitable emulator for x86_64
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup Traceback (most recent call last):
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/openstack/common/threadgroup.py", line 117, in wait
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup x.wait()
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/openstack/common/threadgroup.py", line 49, in wait
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup return self.thread.wait()
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/dist-packages/eventlet/greenthread.py", line 168, in wait
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup return self._exit_event.wait()
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/dist-packages/eventlet/event.py", line 116, in wait
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup return hubs.get_hub().switch()
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/dist-packages/eventlet/hubs/hub.py", line 187, in switch
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup return self.greenlet.switch()
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/usr/lib/python2.7/dist-packages/eventlet/greenthread.py", line 194, in main
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup result = function(*args, **kwargs)
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/openstack/common/service.py", line 65, in run_service
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup service.start()
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/service.py", line 164, in start
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup self.manager.pre_start_hook()
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/compute/manager.py", line 803, in pre_start_hook
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup self.update_available_resource(nova.context.get_admin_context())
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/compute/manager.py", line 4893, in update_available_resource
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup nodenames = set(self.driver.get_available_nodes())
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/virt/driver.py", line 963, in get_available_nodes
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup stats = self.get_host_stats(refresh=refresh)
2014-04-17 19:43:34.497 TRACE nova.openstack.common.threadgroup File "/opt/stack/nova/nova/virt/libvirt/driver.py"...

Fix: 
====
#sudo apt-get install qemu-system
 

#sudo apt-get install qemu-kvm
 

#sudo service libvirt-bin restart

===========

stackuser@mypc:~/openstack/devstack$ sudo apt-get install qemu-system
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following packages were automatically installed and are no longer required:
  sharutils librbd1 libnss3 libaio1 librados2 libboost-thread1.46.1 libnspr4
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  kvm-ipxe libasound2 libasyncns0 libbluetooth3 libbrlapi0.5 libcaca0 libfdt1 libflac8 libjson0 libogg0 libpulse0 libsdl1.2debian libsndfile1
  libvde0 libvdeplug2 libvorbis0a libvorbisenc2 qemu-common qemu-keymaps seabios vde2 vgabios
Suggested packages:
  libasound2-plugins libasound2-python pulseaudio mol-drivers-macosx openbios-sparc ubuntu-vm-builder uml-utilities samba vde2-cryptcab qemu
Recommended packages:
  qemu-kvm
The following packages will be REMOVED:
  qemu-utils
The following NEW packages will be installed:
  kvm-ipxe libasound2 libasyncns0 libbluetooth3 libbrlapi0.5 libcaca0 libfdt1 libflac8 libjson0 libogg0 libpulse0 libsdl1.2debian libsndfile1
  libvde0 libvdeplug2 libvorbis0a libvorbisenc2 qemu-common qemu-keymaps qemu-system seabios vde2 vgabios
0 upgraded, 23 newly installed, 1 to remove and 24 not upgraded.
Need to get 19.4 MB of archives.
After this operation, 60.1 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
WARNING: The following packages cannot be authenticated!
  libasound2 libasyncns0 libbluetooth3 libcaca0 libogg0 libflac8 libjson0 libvorbis0a libvorbisenc2 libsndfile1 libpulse0 libsdl1.2debian kvm-ipxe
  libvde0 libvdeplug2 seabios vgabios qemu-common qemu-keymaps libbrlapi0.5 libfdt1 qemu-system vde2
Authentication warning overridden.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libasound2 amd64 1.0.25-1ubuntu10.2 [428 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/main libasyncns0 amd64 0.8-4 [13.2 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libbluetooth3 amd64 4.98-2ubuntu7.1 [63.3 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ precise/main libcaca0 amd64 0.99.beta17-2.1ubuntu2 [246 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ precise/main libogg0 amd64 1.2.2~dfsg-1ubuntu1 [17.2 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ precise/main libflac8 amd64 1.2.1-6 [144 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ precise/main libjson0 amd64 0.9-1ubuntu1 [16.3 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ precise/main libvorbis0a amd64 1.3.2-1ubuntu3 [103 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu/ precise/main libvorbisenc2 amd64 1.3.2-1ubuntu3 [136 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu/ precise/main libsndfile1 amd64 1.0.25-4 [163 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libpulse0 amd64 1:1.1-0ubuntu15.4 [289 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu/ precise/main libsdl1.2debian amd64 1.2.14-6.4ubuntu3 [197 kB]                                         
Get:13 http://us.archive.ubuntu.com/ubuntu/ precise/main kvm-ipxe all 1.0.0+git-3.55f6c88-0ubuntu1 [327 kB]                                       
Get:14 http://us.archive.ubuntu.com/ubuntu/ precise/universe libvde0 amd64 2.2.3-3build2 [28.1 kB]                                                
Get:15 http://us.archive.ubuntu.com/ubuntu/ precise/universe libvdeplug2 amd64 2.2.3-3build2 [12.4 kB]                                            
Get:16 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main seabios all 0.6.2-0ubuntu2.1 [70.5 kB]                                           
Get:17 http://us.archive.ubuntu.com/ubuntu/ precise/main vgabios all 0.6c-2ubuntu3 [164 kB]                                                       
Get:18 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main qemu-common all 1.0+noroms-0ubuntu14.13 [22.4 kB]                                
Get:19 http://us.archive.ubuntu.com/ubuntu/ precise-updates/universe qemu-keymaps all 1.0.50-2012.03-0ubuntu2.1 [19.1 kB]                         
Get:20 http://us.archive.ubuntu.com/ubuntu/ precise/main libbrlapi0.5 amd64 4.3-1ubuntu5 [24.1 kB]                                                
Get:21 http://us.archive.ubuntu.com/ubuntu/ precise/main libfdt1 amd64 1.3.0-2 [16.5 kB]                                                          
Get:22 http://us.archive.ubuntu.com/ubuntu/ precise-updates/universe qemu-system amd64 1.0.50-2012.03-0ubuntu2.1 [16.7 MB]                        
Get:23 http://us.archive.ubuntu.com/ubuntu/ precise/universe vde2 amd64 2.2.3-3build2 [220 kB]                                                    
Fetched 19.4 MB in 15s (1,280 kB/s)                                                                                                               
(Reading database ... 102732 files and directories currently installed.)
Removing qemu-utils ...
Processing triggers for man-db ...
Selecting previously unselected package libasound2.
(Reading database ... 102716 files and directories currently installed.)
Unpacking libasound2 (from .../libasound2_1.0.25-1ubuntu10.2_amd64.deb) ...
Selecting previously unselected package libasyncns0.
Unpacking libasyncns0 (from .../libasyncns0_0.8-4_amd64.deb) ...
Selecting previously unselected package libbluetooth3.
Unpacking libbluetooth3 (from .../libbluetooth3_4.98-2ubuntu7.1_amd64.deb) ...
Selecting previously unselected package libcaca0.
Unpacking libcaca0 (from .../libcaca0_0.99.beta17-2.1ubuntu2_amd64.deb) ...
Selecting previously unselected package libogg0.
Unpacking libogg0 (from .../libogg0_1.2.2~dfsg-1ubuntu1_amd64.deb) ...
Selecting previously unselected package libflac8.
Unpacking libflac8 (from .../libflac8_1.2.1-6_amd64.deb) ...
Selecting previously unselected package libjson0.
Unpacking libjson0 (from .../libjson0_0.9-1ubuntu1_amd64.deb) ...
Selecting previously unselected package libvorbis0a.
Unpacking libvorbis0a (from .../libvorbis0a_1.3.2-1ubuntu3_amd64.deb) ...
Selecting previously unselected package libvorbisenc2.
Unpacking libvorbisenc2 (from .../libvorbisenc2_1.3.2-1ubuntu3_amd64.deb) ...
Selecting previously unselected package libsndfile1.
Unpacking libsndfile1 (from .../libsndfile1_1.0.25-4_amd64.deb) ...
Selecting previously unselected package libpulse0.
Unpacking libpulse0 (from .../libpulse0_1%3a1.1-0ubuntu15.4_amd64.deb) ...
Selecting previously unselected package libsdl1.2debian.
Unpacking libsdl1.2debian (from .../libsdl1.2debian_1.2.14-6.4ubuntu3_amd64.deb) ...
Selecting previously unselected package kvm-ipxe.
Unpacking kvm-ipxe (from .../kvm-ipxe_1.0.0+git-3.55f6c88-0ubuntu1_all.deb) ...
Selecting previously unselected package libvde0.
Unpacking libvde0 (from .../libvde0_2.2.3-3build2_amd64.deb) ...
Selecting previously unselected package libvdeplug2.
Unpacking libvdeplug2 (from .../libvdeplug2_2.2.3-3build2_amd64.deb) ...
Selecting previously unselected package seabios.
Unpacking seabios (from .../seabios_0.6.2-0ubuntu2.1_all.deb) ...
Selecting previously unselected package vgabios.
Unpacking vgabios (from .../vgabios_0.6c-2ubuntu3_all.deb) ...
Selecting previously unselected package qemu-common.
Unpacking qemu-common (from .../qemu-common_1.0+noroms-0ubuntu14.13_all.deb) ...
Selecting previously unselected package qemu-keymaps.
Unpacking qemu-keymaps (from .../qemu-keymaps_1.0.50-2012.03-0ubuntu2.1_all.deb) ...
Selecting previously unselected package libbrlapi0.5.
Unpacking libbrlapi0.5 (from .../libbrlapi0.5_4.3-1ubuntu5_amd64.deb) ...
Selecting previously unselected package libfdt1.
Unpacking libfdt1 (from .../libfdt1_1.3.0-2_amd64.deb) ...
Selecting previously unselected package qemu-system.
Unpacking qemu-system (from .../qemu-system_1.0.50-2012.03-0ubuntu2.1_amd64.deb) ...
Selecting previously unselected package vde2.
Unpacking vde2 (from .../vde2_2.2.3-3build2_amd64.deb) ...
Processing triggers for man-db ...
Setting up libasound2 (1.0.25-1ubuntu10.2) ...
Setting up libasyncns0 (0.8-4) ...
Setting up libbluetooth3 (4.98-2ubuntu7.1) ...
Setting up libcaca0 (0.99.beta17-2.1ubuntu2) ...
Setting up libogg0 (1.2.2~dfsg-1ubuntu1) ...
Setting up libflac8 (1.2.1-6) ...
Setting up libjson0 (0.9-1ubuntu1) ...
Setting up libvorbis0a (1.3.2-1ubuntu3) ...
Setting up libvorbisenc2 (1.3.2-1ubuntu3) ...
Setting up libsndfile1 (1.0.25-4) ...
Setting up libpulse0 (1:1.1-0ubuntu15.4) ...
Setting up libsdl1.2debian (1.2.14-6.4ubuntu3) ...
Setting up kvm-ipxe (1.0.0+git-3.55f6c88-0ubuntu1) ...
Setting up libvde0 (2.2.3-3build2) ...
Setting up libvdeplug2 (2.2.3-3build2) ...
Setting up seabios (0.6.2-0ubuntu2.1) ...
Setting up vgabios (0.6c-2ubuntu3) ...
Setting up qemu-common (1.0+noroms-0ubuntu14.13) ...
Setting up qemu-keymaps (1.0.50-2012.03-0ubuntu2.1) ...
Setting up libbrlapi0.5 (4.3-1ubuntu5) ...
Setting up libfdt1 (1.3.0-2) ...
Setting up qemu-system (1.0.50-2012.03-0ubuntu2.1) ...
Setting up vde2 (2.2.3-3build2) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$ sudo service libvirt-bin restart
libvirt-bin stop/waiting
libvirt-bin start/running, process 499
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$ qemu-system-x86_64
The program 'qemu-system-x86_64' is currently not installed.  You can install it by typing:
sudo apt-get install qemu-kvm


stackuser@mypc:~/openstack/devstack$ sudo apt-get install qemu-kvm
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following package was automatically installed and is no longer required:
  sharutils
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  acl qemu-utils
The following NEW packages will be installed:
  acl qemu-kvm qemu-utils
0 upgraded, 3 newly installed, 0 to remove and 24 not upgraded.
Need to get 3,914 kB of archives.
After this operation, 14.3 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
WARNING: The following packages cannot be authenticated!
  acl qemu-utils qemu-kvm
Authentication warning overridden.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main acl amd64 2.2.51-5ubuntu1 [43.2 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main qemu-utils amd64 1.0+noroms-0ubuntu14.13 [354 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main qemu-kvm amd64 1.0+noroms-0ubuntu14.13 [3,517 kB]
Fetched 3,914 kB in 5s (705 kB/s)    
Selecting previously unselected package acl.
(Reading database ... 103185 files and directories currently installed.)
Unpacking acl (from .../acl_2.2.51-5ubuntu1_amd64.deb) ...
Selecting previously unselected package qemu-utils.
Unpacking qemu-utils (from .../qemu-utils_1.0+noroms-0ubuntu14.13_amd64.deb) ...
Selecting previously unselected package qemu-kvm.
Unpacking qemu-kvm (from .../qemu-kvm_1.0+noroms-0ubuntu14.13_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up acl (2.2.51-5ubuntu1) ...
Setting up qemu-utils (1.0+noroms-0ubuntu14.13) ...
Setting up qemu-kvm (1.0+noroms-0ubuntu14.13) ...
qemu-kvm start/running
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$ qemu-
qemu-ga                 qemu-io                 qemu-system-m68k        qemu-system-mipsel      qemu-system-sh4eb      
qemu-i386               qemu-nbd                qemu-system-microblaze  qemu-system-ppc         qemu-system-sparc      
qemu-ifdown             qemu-system-arm         qemu-system-mips        qemu-system-ppc64       qemu-system-sparc64    
qemu-ifup               qemu-system-cris        qemu-system-mips64      qemu-system-ppcemb      qemu-system-x86_64     
qemu-img                qemu-system-i386        qemu-system-mips64el    qemu-system-sh4         qemu-x86_64            

stackuser@mypc:~/openstack/devstack$
stackuser@mypc:~/openstack/devstack$

SOLVED:configure: error: libnl-devel >= 1.1 is required for macvtap support

Please Install latest libvirt, libvirt-1.2.3

1)
sudo mkdir -p /opt/libvirt
sudo chmod 00755 /opt/libvirt
sudo chown root:root /opt/libvirt

2)
sudo chmod a+w /opt/libvirt
cd /opt/libvirt
wget http://libvirt.org/sources/libvirt-1.2.3.tar.gz
tar xzvf libvirt-1.2.3.tar.gz
mv libvirt-1.2.3 libvirt
cd libvirt

3)
sudo apt-get install libdevmapper-dev
sudo apt-get install libnl-dev
sudo apt-get install libpciaccess-dev
sudo apt-get install make

4)
./configure \
    --prefix=/usr \
    --localstatedir=/var \
    --sysconfdir=/etc

5)
make -j

6)
sudo make install

7)
$ libvirtd --version
libvirtd (libvirt) 1.2.3

8)
Restart libvirt
sudo service libvirt-bin restart

9)
Ref
https://github.com/stackforge/inception/blob/master/bin/pre_install_libvirt.sh

10)
Remove
cd /opt/libvirt/libvirt
make uninstall

Thursday, February 20, 2014

GNOME Terminal How to Open new tab with working directory Ubuntu

1)
Open  ~/.bashrc and add following lines
#vim ~/.bashrc
[[ -s "/etc/profile.d/vte.sh" ]] && . "/etc/profile.d/vte.sh"



2)
Close all GNOME Terminals, Then Open and Test. :)

Monday, February 10, 2014

Linux Terminal cowsay Funny Tool Commands Ubuntu Fedora

1)
#sudo apt-get install cowsay

2)
#ls /usr/share/cowsay/cows
apt.cow                ghostbusters.cow  sheep.cow
beavis.zen.cow         gnu.cow           skeleton.cow
bong.cow               head-in.cow       snowman.cow
bud-frogs.cow          hellokitty.cow    sodomized-sheep.cow
bunny.cow              kiss.cow          stegosaurus.cow
calvin.cow             kitty.cow         stimpy.cow
cheese.cow             koala.cow         suse.cow
cock.cow               kosh.cow          three-eyes.cow
cower.cow              luke-koala.cow    turkey.cow
daemon.cow             mech-and-cow.cow  turtle.cow
default.cow            meow.cow          tux.cow
dragon-and-cow.cow     milk.cow          unipony.cow
dragon.cow             moofasa.cow       unipony-smaller.cow
duck.cow               moose.cow         vader.cow
elephant.cow           mutilated.cow     vader-koala.cow
elephant-in-snake.cow  pony.cow          www.cow
eyes.cow               pony-smaller.cow
flaming-sheep.cow      ren.cow



3)
#cowsay -f moose "Hello,How are you"
 ___________________
< Hello,How are you >
 -------------------
  \
   \   \_\_    _/_/
    \      \__/
           (oo)\_______
           (__)\       )\/\
               ||----w |
               ||     ||

Thursday, October 24, 2013

How to execute powershell command remotely from linux using Python

1)
Install freeSSHd on your Windows System
http://fosshelp.blogspot.in/2013/10/how-to-ssh-to-windows-from-linux-using.html

2)
Execute following Python script From Your Linux System
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print "\nConnecting"
ssh.connect('192.168.1.7', username='saju', password='saju')
print "\nConnected"
##Supported -OutputFormat Text, XML, none
cmd = "powershell -InputFormat none -OutputFormat TEXT Get-VMHost"
stdin, stdout, stderr = ssh.exec_command(cmd)
print stdout.readlines()



3)
Text Output


4)
XML OUTPUT


5)
Output from Powershell



How to SSH to Windows Machine from Linux Machine using freeSSHd




Monday, March 25, 2013

Linux How to remove all permissions on a file or directory and protect it

Linux How to remove all permissions on a file or directory and protect it

##Remove all permissions on directory perm_tes of Owner(u), Group(g), others(o) and all(a)
chmod 000 perm_test
or
chmod 0 perm_test
or
chmod a=--- perm_test
or
chmod a=- perm_test


##Open Read permission of Owner on directory perm_tes
chmod 400 perm_test
or
chmod u=r perm_test

##Open Read Write permission of Owner on directory perm_tes
chmod 600 perm_test
or
chmod u=rw perm_test

##Open Read Write Exec permission of Owner on directory perm_tes

chmod 700 perm_test
or
chmod u=rwx perm_test

##Open Read Write Exec permission of Owner on directory perm_tes and its all sub directories and files
chmod 700 perm_test
or
chmod u=rwx perm_test

-------------------

##Remove all permissions on file perm_test/address.txt of Owner
chmod  u=- perm_test/address.txt

##Open Read permission of Owner on file address.txt
chmod  u=r perm_test/address.txt

##Open Read Write permission of Owner on file address.txt
chmod  u=rw perm_test/address.txt

-----------------

##Remove all permissions on file perm_test/address.txt of group
chmod  g=- perm_test/address.txt

##Open Read permission of group on file address.txt
chmod  g=r perm_test/address.txt

##Open Read Write permission of group on file address.txt
chmod  g=rw perm_test/address.txt

-----------------

##Remove all permissions on file perm_test/address.txt of others
chmod  o=- perm_test/address.txt

##Open Read permission of others on file address.txt
chmod  o=r perm_test/address.txt

##Open Read Write permission of others on file address.txt
chmod  o=rw perm_test/address.txt

-----------------

##Remove all permissions on file perm_test/address.txt of owner and group
chmod  ug=- perm_test/address.txt

##Remove all permissions on file perm_test/address.txt of owner,group and others
chmod  ugo=- perm_test/address.txt

##Add Write permissions on file perm_test/address.txt for owner
chmod  u+w perm_test/address.txt

##Add Write permissions on file perm_test/address.txt for owner and group
chmod  ug+w perm_test/address.txt

##Add Read Write permissions on file perm_test/address.txt for owner and group
chmod  ug+rw perm_test/address.txt

##Remove Write permissions on file perm_test/address.txt for owner
chmod  u+w perm_test/address.txt

##Remove write permissions on file perm_test/address.txt for owner and group
chmod  ug-w perm_test/address.txt

##Remove Read Write permissions on file perm_test/address.txt for owner and group

chmod  ug-rw perm_test/address.txt

-----------------

##Add Read Write permissions on file perm_test/address.txt for all (owner,group and others)
chmod  a+rw perm_test/address.txt

##Remove Read Write permissions on file perm_test/address.txt for all (owner,group and others)
chmod  a-rw perm_test/address.txt

-----------------

How to understand and set file permissions on Linux

$ ls -l
drwx------  3 saju saju   4096 Mar 25 12:37 appliance_store
-rw-rw-r--  1 saju saju 223253 Mar 25 15:47 squid.log

The very first column, shows the file type and permissions.The second column shows the number of links (directory entries that refer to the file), the third one shows the owner of the file, and the fourth one shows the group the file belongs to. The other columns show the file's size in bytes, date and time of last modification, and the file name.

The first column, is organized into four separate groups.
The first group consists of only one character, and it shows the file's type.
For example, The first character can be any of these:

d = directory
- = regular file
l = symbolic link
s = Unix domain socket
p = named pipe
c = character device file
b = block device file

The next nine characters show the file's permissions, divided into three groups, each consisting of three characters. The first group of three characters shows the read, write, and execute permissions for user, the owner of the file. The next group shows the read, write, and execute permissions for the group of the file. Similarly, the last group of three characters shows the permissions for other, everyone else. In each group, the first character means the read permission, the second one write permission, and the third one execute permission.

The characters are pretty easy to remember.

r = read permission
w = write permission
x = execute permission
- = no permission


How to set file permissions - symbolic mode
===============================


Which user?
u     user/owner
g     group
o     other
a     all


What to do?
+     add this permission
-     remove this permission
=     set exactly this permission


Which permissions?
r     read
w     write
x     execute


How to set file permissions - numeric mode
===============================


4 = read (r)
2 = write (w)
1 = execute (x)
0 = no permission (-)


Which number?
0     ---
1     --x
2     -w-
3     -wx
4     r--
5     r-x
6     rw-
7     rwx

Friday, March 8, 2013

SOLVED:configure: error: You must install the YAJL development package in order to compile libvirt

configure: error: You must install the YAJL development package in order to compile libvirt


Install libyajl-dev
#sudo apt-get install libyajl-dev

SOLVED:configure: error: libnl-devel >= 1.1 is required for macvtap support


configure: error: libnl-devel >= 1.1 is required for macvtap support

Install libnl-dev
#sudo apt-get install libnl-dev

SOLVED:configure: error: You must install the Xen development package to compile Xen driver with -lxenstore


configure: error: You must install the Xen development package to compile Xen driver with -lxenstore

Install libxen-dev
#sudo apt-get install libxen-dev

SOLVED:configure: error: You must install the pciaccess module to build with udev

configure: error: You must install the pciaccess module to build with udev

Install libpciaccess-dev
#sudo apt-get install libpciaccess-dev

Sunday, February 10, 2013

How to Install VMware Player 5.0.1 in Ubuntu

1) Download
https://my.vmware.com/web/vmware/free#desktop_end_user_computing/vmware_player/5_0

2) Install
# sudo sh VMware-Player-5.0.1-894247.x86_64.bundle