Google Search

Google

What is the most suitable distro to use as a server?

Visit Us!

Google Groups
Kuantan Linux User Group
Visit this group

Threat Resource Center | Trend Micro

Monday, June 7, 2010

MSC Malaysia Open Source Conference 2010

MSC Malaysia Open Source Conference

INVITATION TO PARTICIPATE IN MSC MALAYSIA OPEN SOURCE CONFERENCE 2010

Date: 29 June - 1 July, 2010
Venue: Berjaya Times Square

Come join us at the MSC Malaysia Open Source Conference 2010! You'll be pleasantly surprised...

Who should attend?

  • Business executives from local and foreign companies
  • Open Source developers, communities, inventors, evangelist, researchers, strategist
  • Government officers
  • Students, general public

Why you should attend?

  1. Provide exposure and knowledge on the importance of Open Source in enhancing competitiveness by giving freedom of choice in software usage with lower total cost of ownership, hence benefiting businesses and society at large. Over 30 session tracks are made available.
  2. Share amongst the open source community on new directions and latest innovations by the subject matter experts, thought leaders and industry gurus.
  3. Provide a platform for conference participants to actively interact, share and exchange views, ideas, and tools on the latest trends and issues of Open Source.
  4. Networking, learning and having great fun!

Click here for more details!

Saturday, May 1, 2010

HP-UX : Managing Disc Basic

To check available disk space and file system, type bdf

[hpa50-12]/ >bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 204800 70848 132960 35% /
/dev/vg00/lvol1 295024 26616 238904 10% /stand
/dev/vg00/lvol8 1560576 273496 1277096 18% /var
/dev/vg00/lvol7 909312 858128 50848 94% /usr
/dev/vg00/lvol4 204800 2800 200496 1% /tmp
/dev/vg00/lvol6 929792 695864 232144 75% /opt
/dev/vg00/lvol5 20480 2320 18024 11% /home

** The bdf command displays the amount of free disk space available


To check physical volume of disk, type ioscan -funC disk

[hpa50-12]/ >ioscan -funC disk
Class I H/W Path Driver S/W State H/W Type Description
======================================================================
disk 0 0/0/1/1.15.0 sdisk CLAIMED DEVICE HP

18.2GST318406LC
/dev/dsk/c1t15d0 /dev/rdsk/c1t15d0
disk 1 0/0/2/1.15.0 sdisk CLAIMED DEVICE HP

18.2GMAN3184MC
/dev/dsk/c3t15d0 /dev/rdsk/c3t15d0

** Ioscan scans system hardware, usable I/O system devices, or kernel I/O system data structures as appropriate, and lists the results.



To check further information of physical volume type, pvdisplay /Physical/volumes/path

[hpa50-12]/ >pvdisplay /dev/dsk/c1t15d0
--- Physical volumes ---
PV Name /dev/dsk/c1t15d0
VG Name /dev/vg00
PV Status available
Allocatable yes
VGDA 2
Cur LV 8
PE Size (Mbytes) 4
Total PE 4340
Free PE 3074
Allocated PE 1266
Stale PE 0
IO Timeout (Seconds) default
Autoswitch On

** pvdisplay - display information about physical volumes within LVM volume group


To check Volume Group (VG), look at the output of the bdf command and see at the Filesystem field, /dev/vg00 <-- vg00 is the Volume Group (VG). Then type command, vgdisplay

volumegr0up [hpa50-12]/ >vgdisplay vg00
--- Volume groups ---
VG Name /dev/vg00
VG Write Access read/write
VG Status available
Max LV 255
Cur LV 8
Open LV 8
Max PV 16
Cur PV 1
Act PV 1
Max PE per PV 4350
VGDA 2
PE Size (Mbytes) 4
Total PE 4340
Alloc PE 1266
Free PE 3074
Total PVG 0
Total Spare PVs 0
Total Spare PVs in use 0


To scan the existing volume group, type vgscan

[hpa50-12]/ >vgscan
vgscan: The physical volume "/dev/dsk/c1t15d0" is already recorded in the

"/etc/lvmtab" file.
Physical Volume "/dev/dsk/c3t15d0" contains no LVM information

** vgdisplay - display information about LVM volume groups



To check Logical Volume, look at the output of the bdf command and see at the Filesystem field, /dev/vg00/lvol3, /dev/vg00/lvol1 and /dev/vg00/lvol8. lvol3, lvol1 and lvol8 are the logical volume. To getthe information of logical volume type, lvdisplay /dev/vg00/logicalVolume


=========
Example1
=========

[hpa50-12]/ >lvdisplay /dev/vg00/lvol3
--- Logical volumes ---
LV Name /dev/vg00/lvol3
VG Name /dev/vg00
LV Permission read/write
LV Status available/syncd
Mirror copies 0
Consistency Recovery MWC
Schedule parallel
LV Size (Mbytes) 200
Current LE 50
Allocated PE 50
Stripes 0
Stripe Size (Kbytes) 0
Bad block off
Allocation strict/contiguous
IO Timeout (Seconds) default


=========
Example2
=========

[hpa50-12]/ >lvdisplay /dev/vg00/lvol1
--- Logical volumes ---
LV Name /dev/vg00/lvol1
VG Name /dev/vg00
LV Permission read/write
LV Status available/syncd
Mirror copies 0
Consistency Recovery MWC
Schedule parallel
LV Size (Mbytes) 300
Current LE 75
Allocated PE 75
Stripes 0
Stripe Size (Kbytes) 0
Bad block off
Allocation strict/contiguous
IO Timeout (Seconds) default


=========
Example3
=========

[hpa50-12]/ >lvdisplay /dev/vg00/lvol8
--- Logical volumes ---
LV Name /dev/vg00/lvol8
VG Name /dev/vg00
LV Permission read/write
LV Status available/syncd
Mirror copies 0
Consistency Recovery MWC
Schedule parallel
LV Size (Mbytes) 1524
Current LE 381
Allocated PE 381
Stripes 0
Stripe Size (Kbytes) 0
Bad block on
Allocation strict
IO Timeout (Seconds) default


[hpa50-12]/ >ioscan -kfC ext_bus
Class I H/W Path Driver S/W State H/W Type Description
=================================================================
ext_bus 0 0/0/1/0 c720 CLAIMED INTERFACE SCSI C896 Ultra Wide

LVD
ext_bus 1 0/0/1/1 c720 CLAIMED INTERFACE SCSI C896 Ultra Wide

Single-Ended
ext_bus 2 0/0/2/0 c720 CLAIMED INTERFACE SCSI C87x Fast Wide

Single-Ended
ext_bus 3 0/0/2/1 c720 CLAIMED INTERFACE SCSI C87x Ultra Wide

Single-Ended



To get information of what disk and filesystem that currently mount type, mount

[hpa50-12]/ >mount
/ on /dev/vg00/lvol3 log on Fri Apr 30 17:28:38 2010
/stand on /dev/vg00/lvol1 defaults on Fri Apr 30 17:28:38 2010
/var on /dev/vg00/lvol8 delaylog,nodatainlog on Fri Apr 30 17:28:42 2010
/usr on /dev/vg00/lvol7 delaylog,nodatainlog on Fri Apr 30 17:28:42 2010
/tmp on /dev/vg00/lvol4 delaylog,nodatainlog on Fri Apr 30 17:28:42 2010
/opt on /dev/vg00/lvol6 delaylog,nodatainlog on Fri Apr 30 17:28:42 2010
/home on /dev/vg00/lvol5 delaylog,nodatainlog on Fri Apr 30 17:28:43 2010

[hpa50-12]/ >bdf
Filesystem kbytes used avail %used Mounted on
/dev/vg00/lvol3 204800 70848 132960 35% /
/dev/vg00/lvol1 295024 26616 238904 10% /stand
/dev/vg00/lvol8 1560576 273496 1277096 18% /var
/dev/vg00/lvol7 909312 858128 50848 94% /usr
/dev/vg00/lvol4 204800 2800 200496 1% /tmp
/dev/vg00/lvol6 929792 695864 232144 75% /opt
/dev/vg00/lvol5 20480 2320 18024 11% /home

Sunday, April 18, 2010

Use Variables with Scripts

Using an editor or the cat command, write a script that uses a variable. Note that this script uses the bash shell on LINUX, but you can also use the ksh shell with UNIX.


1) Set a value for the variable first using typeset then check it using set.

[root@vmpc_rh804 root]# typeset first=you
[root@vmpc_rh804 root]# set | more
BASH=/bin/bash
BASH_ENV=/root/.bashrc
BASH_VERSINFO=([0]="2" [1]="05b" [2]="0" [3]="1" [4]="release" [5]="i686-pc-linu
x-gnu")
BASH_VERSION='2.05b.0(1)-release'
COLORS=/etc/DIR_COLORS
.
.
.
first=you
hi=hello
langfile=/root/.i18n


2) Write a short Welcome script that uses a variable.

[root@vmpc_rh804 root]# cat > Welcome.bash
#!/bin/bash
#
first=Student
echo "Welcome to Linux $first"
Ctrl/D


3) Execute your script using the shell interpreter.

$ bash Welcome.bash
Welcome to Linux Student

Invoke a Script

Use various methods to invoke a script, and determine when it runs in your shell, and when a subshell is created.


1) Using an editor or the cat command, write a korn or bash script that:
* Executes the ps command.
* Echos the value of the shell variable hi.

[root@vmpc_rh804 root]# cat > do-ps.bash
#!/bin/bash
# This script displays active processes
#
ps
echo $hi


2) Set the value of hi to hello in your current command line shell.

[root@vmpc_rh804 root]# hi=hello


3) Execute your script using the shell interpreter.

[root@vmpc_rh804 root]# bash do-ps.bash
PID TTY TIME CMD
1311 pts/4 00:00:00 bash
1358 pts/4 00:00:00 bash
1365 pts/4 00:00:00 ps

** Note that it doesn't recognize the hi variable. This is because the variable is local to the shell in which it was defined. When this script is executed, a new shell is started that is outside your local shell. **


4) Add execute privilege to the script file and run it as a command from the current directory.

[root@vmpc_rh804 root]# chmod +x do-ps.bash
[root@vmpc_rh804 root]# ./do-ps.bash
PID TTY TIME CMD
1311 pts/4 00:00:00 bash
1367 pts/4 00:00:00 do-ps.bash
1374 pts/4 00:00:00 ps


5) Use the built-in source command to execute the commands in the script file.

[root@vmpc_rh804 root]# source do-ps.bash
PID TTY TIME CMD
1311 pts/4 00:00:00 bash
1375 pts/4 00:00:00 ps
hello
[root@vmpc_rh804 root]#


** Note that it is able to recognize the hi variable. This is because the source command runs this script in the local shell. **

How to write a simple shell script in Linux

Below are the simple steps to write a simple shell script in Linux machine. Before this I don't have any experience to write a script. Thanks to HP's Virtual Lab. Its really make my day ;-)


===========
Exercise 1
===========

1) Find what shells are available on your system.

[root@vmpc_rh804 root]# more /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/bash2
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh


2) Using an editor or the cat command, write a korn or bash script that:

* Comments what the script will do.
* Shows your current directory.
* Shows who is currently logged on.
* Prints the current date and time.

[root@vmpc_rh804 root]# cat > myscript
#! /bin/bash
#
# This script shows current directory
# then shows who is on the system
# then prints the date and time
#
pwd
who
date
Ctrl/D


3) Run the script by calling up the shell interpreter.

[root@vmpc_rh804 root]# bash myscript
/root
root :0 Apr 11 06:25
root pts/0 Apr 11 06:26
root pts/1 Apr 11 06:26
root pts/2 Apr 11 06:26
root pts/3 Apr 11 06:26
root pts/5 Apr 11 06:27
root pts/4 Mar 30 00:25 (16.158.13.22)
Tue Mar 30 00:55:01 EST 2010


4) Show how the script cannot be run as a command unless the file has execute privileges.

[root@vmpc_rh804 root]# ./myscript
-bash: ./myscript: Permission denied


5) Add execute privilege to the script file and try running it again.

[root@vmpc_rh804 root]# chmod +x myscript
[root@vmpc_rh804 root]# ./myscript
/root
root :0 Apr 11 06:25
root pts/0 Apr 11 06:26
root pts/1 Apr 11 06:26
root pts/2 Apr 11 06:26
root pts/3 Apr 11 06:26
root pts/5 Apr 11 06:27
root pts/4 Mar 30 00:25 (16.158.13.22)
Tue Mar 30 01:04:14 EST 2010




============
Exercise 2
============


1) [root@vmpc_rh804 root]# more /etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/bash2
/bin/ash
/bin/bsh
/bin/tcsh
/bin/csh

[root@vmpc_rh804 root]# cat > myscript1
#!/bin/bash
#
#
ifconfig eth0
netstat -i


2) [root@vmpc_rh804 root]# bash myscript1
eth0 Link encap:Ethernet HWaddr 00:50:56:03:04:40
inet addr:172.16.0.40 Bcast:172.16.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:168 (168.0 b)
Interrupt:10 Base address:0x10a0

Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 0 0 0 0 4 0 0 0 BMRU
eth1 1500 0 1335 0 0 0 1351 0 0 0 BMRU
lo 16436 0 98 0 0 0 98 0 0 0 LRU


3) [root@vmpc_rh804 root]# ./myscript1
-bash: ./myscript1: Permission denied


4) [root@vmpc_rh804 root]# chmod +x myscript1


5) [root@vmpc_rh804 root]# ./myscript1
eth0 Link encap:Ethernet HWaddr 00:50:56:03:04:40
inet addr:172.16.0.40 Bcast:172.16.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:168 (168.0 b)
Interrupt:10 Base address:0x10a0

Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 0 0 0 0 4 0 0 0 BMRU
eth1 1500 0 1397 0 0 0 1395 0 0 0 BMRU
lo 16436 0 98 0 0 0 98 0 0 0 LRU

Linux News Of The Day!

Powered By
widgetmate.com
Sponsored By
Credit Card Forum