Sunday, March 31, 2013

Learning unix basics on OpenSolaris 2009 part2




You can also use Ctrl +R to search (backward) through the history.

You can capture the output from a c ommand in a n e nv ironment variable using back-ticks:
$ TIME =`date`

$ echo $TIME

Sun Mar 31 21:56:03 IST 2013


As on most UNIX-like systems, each user on OpenSolaris has a home directory. Your home
directory path is stored in the HOME environment variable. You can also use the tilde character
(~) to navigate to your home directory or to another user’s home directory. The tilde alone
implies the current user’s home directory. The following code shows how to navigate to home
directories:

$ cd ~
$ pwd
/export/home/sourav
$ cd ~sougata
$ pwd
/export/home/sougata

This example also demonstrates that the pwd command shows your current working directory.


Wednesday, March 27, 2013

Learning unix basics on OpenSolaris 2009


If you end a command line with a backslash, bash lets you continue the command on the next
line. This feature is useful for entering lengthy commands:

$ touch \

> file1

ctrl+a to take the cursor to the beginning of the line

ctrl+e to take the cursor at the end of the line

Alt+F and Alt+B move forward 

and backward, respectively, on a word-by-word, instead of character-by-character.

from the beginning of the line Ctrl+K will cut the line and at the end of the line Ctrl+Y to 
paste are the same line as in emacs .

to get a list of all the commands in your path
that start with ‘‘fil,’’ type fil and press Tab twice:
$ file

bash first completed the word up to file (because there were no commands starting with fil
that didn’t have an e next), and then provided a list of possibilities with the second Tab.


file file-roller filesync
$ file


$ history

1ls

2ls-a

3 pwd

4 whoami

5 touch testfile

6 which gcc

7 which cc

8 rm testfile

9 history

history an integer argument to see only that number of previous commands:

$ history 2

12 date

13 history 2

To Execute a command in the history, use ! . To execute the previous com-
d, use the !! shortcut:

$ !4

whoami

test

$ date

Thu Mar 28 00:08:13 IST 2013


$ !!

date

Thu Mar 28 00:08:13 IST 2013

you can see the environment variables by the command

declare

or you can use the command

set


You can print the values of the environment variables using the echo or printf commands,
accessing the value of the variable by prefixing it with the usual $ character:

$ echo $SHELL

/bin/bash

$ printf ’’$PATH \n’’

/usr/bin

Set the value of an environment variable with an assignment statement. The following example
sets the shell history size to 1,000:

$ echo $HISTSIZE

500

$ HISTSIZE =1000

$ echo $HISTSIZE

1000

Use the which command to see which version of a command you are executing
based on your path:

$ which grep
/usr/gnu/bin/grep
$ which xterm
/usr/X11/bin/xterm
$ which which
/usr/gnu/bin/which

The user created by the installer is set up with the following path:

$ echo $PATH

/usr/gnu/bin:/usr/bin:/usr/X11/bin:/usr/sbin:/sbin


Directory Description

/usr/bin The default directory for commands; contains utilities such as grep and
tr , a pplications such as firefox and thunderbird , shells such as
bash and zsh , and myriad other commands

/usr/ccs/bin Traditionally System V development tools, but these have mostly moved
to /usr/bin

/usr/gnu/bin The GNU versions of commands; slightly different versions of many of
them are also found in /usr/bin

/usr/sbin The system tools, commands, and daemons, such as zfs , dumpadm ,
in.routed , and others. These are generally privileged commands.

/usr/sfw/bin Traditionally the Sun Freeware (mostly GNU) tools, but almost all of
these have been moved to /usr/bin , with symlinks left here; or
symlinks have been added to /usr/bin

/usr/ucb Traditiona lly the BSD tools, but these have been moved to / usr/bin ,
with only a few symlinks left here

/usr/X11/bin X11 commands, such as xterm , xhost , and others
/usr/openwin/bin;
/usr/X/bin;
/usr/X11R6/bin
Aliases for /usr/X11/bin
/usr/xpg4/bin Ve rsions of some of the tools that adhere to the POSIX standard, where
the versions in /usr/bin don’t

/bin Alias for /usr/bin

/sbin System tools and utilities required for booting and possibly recovering
the system if /usr is not mounted. These are generally privileged
commands.


Add a location to your path

$ PATH =$PATH:/export/home/sourav/personal/data
$ echo $PATH

this folder /export/home/sourav/personal/data will be show and any executable file there can be 

invoked directly,the executable permission has to be set though


Install Vmware Tools in OpenSolaris 2009


To install vmware tools successfully

you need to copy the vmware-solaris-tools.tar.gz in a directory(for me it is /tmp/sourav)

then 

cd /tmp/sourav

gunzip -dc vmware-solaris-tools.tar.gz | tar xvf - 

or

Decompress the file using gunzip command. For example:

# gunzip vmware-solaris-tools.tar.gz


Extract the contents of the tar file with the command:

# tar xvf vmware-solaris-tools.tar 

then 

 cd vmware-tools-distrib


To install VMware Tools, run this command from the directory you changed to in step 7:

 ./vmware-install.pl


Check if VMware tools service is running with the command:

 /etc/init.d/vmware-tools status

The output is similar to:

vmtoolsd is running

Add vmware-toolbox to the list of startup commands of your desktop.



for my opensolaris(2009)

it is in 

Preference-Sessions

Click Startup Programs tab and add these entries:

/ usr/bin/vmware-user

/usr/bin/vmware-toolbox 

source:http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1023956 



Things to do after installing OpenSolaris part 1



To see the installation log

nano /var/sadm/system/logs/install_log

To update system software database

pkg refresh

pkg list -a

to install software

pkg install softwarename such as gcc

to search a software in both locally installed software and package repositories

pkg search -lr gcc

to update broken or limited repositories

pkg rebuild-index

you will find the grub confirutation file

nano /rpool/boot/grub/menu.list

Tuesday, March 26, 2013

OpenSolaris issue DNS not working solved


I manually configured Open Solaris(2009 edition),however the DNS is not working,here how it worked out for me

Nslookup resolves the name to an ip, but pinging doesn’t make it to the box…


Static IP address

Assigning a static IP address on OpenSolaris is accomplished by editing the hostname files in the directory /etc. For example, assign a static IP address to interface bge0 by editing /etc/hostname.bge0:

192.168.0.123

Set the netmask by editing the file /etc/inet/netmasks:

192.168.0.0 255.255.255.0

Set the default gateway by editing the file /etc/defaultrouter:

192.168.0.1

Note: in this solution makes sure you have fill the DNS in the GUI mode, System > Administration > Network > DNS

and make sure file /etc/resolv.conf contain the same DNS as you fill in the GUI mode

This is exactly my problems :

Successfully Resolving DNS

 nslookup http://www.yahoo.com
Server:        202.138.224.2
Address:    202.138.224.2#53

Non-authoritative answer:
http://www.yahoo.com    canonical name = http://www.wa1.b.yahoo.com.
http://www.wa1.b.yahoo.com    canonical name = www-real.wa1.b.yahoo.com.
Name:    www-real.wa1.b.yahoo.com
Address: 209.131.36.158

Pinging IP address successfully

 ping 209.131.36.158
209.131.36.158 is alive

BUT failed to ping hostname

 ping -l http://www.yahoo.com
ping: unknown host http://www.yahoo.com

So the fix is

Open your terminal and switch to root user, then edit your /etc/nsswitch.conf file and add the word “dns“ to the hosts and ipnodes lines

This is my nsswitch.conf file snippet:



passwd:     files
group:      files
hosts:      dns
ipnodes:    dns
networks:   files
protocols:  files
rpc:        files


There is default backup of /etc/nsswitch.conf file you can also just copy /etc/nsswitch.dns over it…

 cp /etc/nsswitch.dns /etc/nsswitch.conf

You may also want to check that auto-magic mode has been disabled when setting up your networking manually;

svcs -a | grep nwam

If it is enabled type;

svcadm disable svc:/network/physical:nwam

And you are done!!!


source:http://dxzstudioz.wordpress.com/2009/11/28/opensolaris-dns-resolving-problem-when-using-static-ip/

source: http://www.jansipke.nl/network-configuration-on-opensolaris/

Tuesday, March 12, 2013

Connecting Oracle 10g express using PHP and Apche on Scientific Linux 6.2


Installed Oracle 10g Express on Scientific Linux 6.2 before

http://wowmoron.blogspot.in/2012/12/install-oracle-10g-express-on.html


Ok installed PHP and Apache on Scientific Linux 6.2 before

http://wowmoron.blogspot.in/2012/11/install-apachemysqlphp-lamp-on-centos.html

Now connecting Oracle 10g express using PHP

all we have to do basically installing zend server community edition

so the steps are

create a file

/etc/yum.repos.d/zend.repo



[Zend]
name=zend-server
baseurl=http://repos.zend.com/zend-server/6.0/rpm/$basearch
enabled=1
gpgcheck=1
gpgkey=http://repos.zend.com/zend.key

[Zend_noarch]
name=zend-server - noarch
baseurl=http://repos.zend.com/zend-server/6.0/rpm/noarch
enabled=1
gpgcheck=1
gpgkey=http://repos.zend.com/zend.key

save the file and close


yum install zend-server-php-5.3



after this

nano /var/www/html/database.php


  
&lt?php

    $conn = oci_connect("hr", "your_hr_password", "127.0.0.1/XE");

    $stid = oci_parse($conn, "select last_name, salary from employees");
    oci_execute($stid);

    $nrows = oci_fetch_all($stid, $results);

    echo "&lthtml>&lthead>&lttitle>Oracle PHP Test&lt/title>&lt/head>&ltbody>";
    echo "&ltcenter>&lth2>Oracle PHP Test&lt/h2>&ltbr>";
    echo "&lttable border=1 cellspacing='0' width='50%'>\n&lttr>\n";
    echo "&lttd>&ltb>Name&lt/b>&lt/td>\n&lttd>&ltb>Salary&lt/b>&lt/td>\n&lt/tr>\n";

    for ($i = 0; $i &lt $nrows; $i++ ) {
      echo "&lttr>\n";
      echo "&lttd>" . $results["LAST_NAME"][$i] . "&lt/td>";
      echo "&lttd>$" . number_format($results["SALARY"][$i], 2). "&lt/td>";
      echo "&lt/tr>\n";
    }

    echo "&lttr>&lttd colspan='2'> Number of Rows: $nrows&lt/td>&lt/tr>&lt/table>";
    echo "&ltbr>&ltem>If you see data, then it works!&lt/em>&ltbr>&lt/center>&lt/body>&lt/html>\n";

  ?>

(ok as I can not use opening tag and closing tag in this blog I used > and < instead)

save the file and close

open your browser

localhost/database.php

you should see data and you are done



Sunday, March 10, 2013

Install and configure JDK and Tomcat in Scientific Linux 6 for the first time


download jdk rpm and install by rpm -ivh command

download tomcat package

tar -zxvf apache-tomcat-7.0.37.tar.gz -C /opt

sh -c 'echo export sourav_home=/opt/apache-tomcat-7.0.37 > /etc/profile.d/tomcat.sh'

source /etc/profile.d/tomcat.sh

to start tomcat

$sourav_home/bin/startup.sh

now open browser and go to

http://192.168.163.201:8080

and you will see the tomcat web interface

to shutdown tomcat

$sourav_home/bin/shutdown.sh

Now go to /opt/apache-tomcat-7.0.37/webapps/ and create a folder named sourav

create a.jsp there with some sample jsp code like this

<br>

go to browser and put this url

http://192.168.163.201:8080/ch01/a.jsp

and you are done!




Saturday, March 9, 2013

Static route and persistent route in server 2008


Add a static route 

by command line

route add 192.168.163.0 mask 255.255.255.0 192.168.163.2

we can see this route by the command

route print

but this route will be temporary as after restart it will be gone

so delete the route by

route delete 192.168.163.0

now add the route as a persistent route

route -p add 192.168.163.0 mask 255.255.255.0 192.168.163.2

or go to server manager,roles,network policy ..,routing and remote..,ipv4,static routes and add a route 

static route works much better than a default gateway,you can make the default gateway blank and use static routing  

Enable ping and remotely managing the firewall of server 2008 core


to enable ping(icmp) reply on server 2008 core

netsh firewall set icmpsetting 8

and then you should be able to ping  server 2008 from a remote machine

to enable remote firewall administration in server core

netsh advfirewall set currentprofile settings remotemanagement enable

then go to the remote machine

mmc-add remove snap in-windows firewall with advanced security-manage another computer,put the ip address of server 2008 core there and you will see all the firewall option like inbound rule etc there 




Install and configure DHCP server on server 2008 core


start /w ocsetup DHCPServerCore

sc config dhcpserver start= auto

net start dhcpserver

(because the dhcp service will be started automatically from next time)

to authorize dhcp server

netsh dhcp add server servercore.sourav.com 192.168.10.60

to show the dhcp servers on the network

netsh dhcp show server

now we can manage the dhcp server on server 2008 core remotely from a GUI

to do that we have to first restart the server 2008 core (otherwise it didn't work for me at least)

now we can go a different pc,mmc-add remove snap in,dhcp.add server,put the ip of server 2008 core and then you can configure the scope etc... 

Tuesday, March 5, 2013

How to join server 2008 core to a domain





netdom join %computername% /domain:sourav.com /userd:administrator@sourav.com /passwordd:*** /reboot:60

How to rename server 2008 core

netdom renamecomputer %computername% /newname servercore

Set static ip address and dnsserver in server 2008 core

netsh interface ipv4 set address name="Local Area Connection" source=static address=192.168.10.60 mask=255.255.255.0 gateway=192.168.10.101


set dnsserver by

netsh interface ipv4 add dnsserver name="Local Area Connection" address=8.8.8.8 index=1   (index1 for primary,add secondary by index=2)   and you are done!!!

Configure dhcp on server 2008 core

netsh interface ipv4 set address "Local Area Connection" dhcp

ipconfig /renew

and you are done!!!