if you run airoscript too much you’ll be left with mon0, mon1, mon2… etc
To remove them all you can do:
ifconfig -a | grep -i mon | awk ‘{ print $1 }’ | while read i;do airmon-ng stop $i;done
43/433
Month: January 2011
Test nics to see if we’re on the desired vlan
You want to know if one of your nics is in the vlan you need it to be? Quite tedious if you want to do it manually.
check this small script to config the ip, ping and unconfig
for i in 1 2 3 4 5 6 7 8 9 10 11;do set -x;ifconfig eth$i inet 10.203.102.102 netmask 255.255.254.0 up; ping -c
5 10.203.102.1; ifconfig eth$i down; done
25/433
mysql “load data infile”
Say you want to know which users are in a remote server… and you have access to mysql on that server.
# mysql -h remote server;
mysql> show databases;
+————+
| Database |
+————+
| ixx |
| mysql |
| phpmyadmin |
| test |
| video |
| x10 |
| zm |
+————+
mysql > use ixx;
Database changed
mysql> show tables;
+—————-+
| Tables_in_issy |
+—————-+
| ccs |
| fss |
| p |
| prop |
+—————-+
4 rows in set (0.00 sec)
mysql> CREATE TABLE `p` ( `p` TEXT NOT NULL
) TYPE = MYISAM;
mysql> load data infile ‘/etc/passwd’ into table p;
mysql> select kraftek.html POSTS rescue rescued.html rescued.txt x y z from p;
+———————————————————–+
| p |
+———————————————————–+
| root:x:0:0::/root:/bin/bash |
| bin:x:1:1:bin: /bin: |
| daemon:x:2:2:daemon:/sbin: |
| adm:x:3:4:adm: /var/log: |
| lp:x:4:7:lp:/var/spool/lpd: |
| sync:x:5:0:sync:/sbin:/bin/sync |
| shutdown:x:6:0:shutdown:/sbin: /sbin/shutdown |
| halt:x:7:0:halt:/sbin:/sbin/halt |
129/433
| mail:x:8:12:mail:/: |
| news:x:9:13:news:/usr/lib/news: |
| uucp:x:10:14:uucp:/var/spool/uucppublic: |
| operator:x:11: 0:operator:/root:/bin/bash |
| games:x:12:100:games:/usr/games: |
| ftp:x:14:50::/home/ftp: |
| smmsp:x:25:25: smmsp:/var/spool/clientmqueue: |
| mysql:x:27:27: MySQL:/var/lib/mysql:/bin/bash |
| rpc:x:32:32:RPC portmap user:/:/bin/false |
| sshd:x:33:33:sshd:/: |
| gdm:x:42:42:GDM:/var/state/gdm:/bin/bash |
| pop:x:90:90:POP:/: |
| nobody:x:99:99:nobody:/: |
| apache:x:1000: 102::/home/apache:/bin/bash |
| iceuser:x:1001:104::/usr/local/icecast2: |
| vvb:x:1002:100::/home/vvb: |
| ixx:x:1003:100:invitado,1,58252323,:/home/ixx: /bin/bash |
| dvd:x:1004:100:Dvd,,,:/home/dvd:/bin/bash |
+———————————————————–+
26 rows in set (0.00 sec)
You maybe can guess a password for one of these users and get access to the box
130/433
swap in solaris
You want to know how much swap isconfigured in your server in gb.
swap -l tells us 512byte blocks, if you have more than one swap chunk then you need to sum and convert
bash-3.00# swap -l
swapfile dev swaplo blocks free
/dev/md/dsk/d1 85,1 16 16780208 16627776
/dev/md/dsk/d2 86,1 16 26780208 16111111
You can calculate it in gb with:
swap -l |awk ‘{ b+=$4 } END { print b*512/1024/1024/1024 }’
Calculate all your interfaces’ netmasks
This script for Solaris prints these values,
1- the interface name
2- MAC Address
3- IPMP Group (if any)
4- IP
5- netmask in hex
6- netmask in decimal
7- netmask length
bash-3.00$ ./netmask.ksh
lo0,,,127.0.0.1, ff000000,255.0.0.0,8
ce0,0:3:ba:84:dd:a5,management,198.148.129.96,ffffffc0,255.255.255.192,26
ce0:1,,,198.148.129.110,ffffffc0,255.255.255.192,26
ce0:2,,,198.148.129.98,ffffffc0,255.255.255.192,26
ce3,0:3:ba:84:dd:a8,,192.168.5.11,ffffff00,255.255.255.0,24
ce3:1,,,192.168.130.254,fffff000,255.255.240.0,20
qfe0,0:3:ba:4:45:4,management,198.148.129.97,ffffffc0,255.255.255.192,26
qfe3,0:3:ba:4:45:7,,192.168.132.254,fffff000,255.255.240.0,20
This is the code for netmask.ksh, notice that we also have an unused funcion, Len2Mask, which is very
useful to calculate a netmask in decimal when you’re given the netmask lenght, like “24”, or “16”:
#!/bin/ksh
IFCONFIG=/usr/sbin/ifconfig
ECHO=/usr/ucb/echo
integer G=0
raiseP(){
x=$1
y=$2
integer total=1
integer j=0
while ((j < y));
do
(( total*=x ))
(( j = j + 1 ))
done
$ECHO $total
return $total
}
L2M(){
integer nmask=$1
if [ nmask -lt 1 ];then
$ECHO -n “0”
return “0”
fi
110/433
integer ncalc=0
integer x=7
while [ $x -ge 0 ];do
integer P=`raiseP 2 $x`
(( ncalc= ncalc + P ));
(( nmask=nmask – 1 ));
G=$nmask
if [ $nmask -lt 1 ];then
$ECHO -n $ncalc
return $ncalc
fi
(( x= x – 1 ));
done
$ECHO -n $ncalc
return $ncalc
}
Len2Mask(){
L=$1
if [ $L -lt 0 -o $L -gt 32 ];then
$ECHO “Your mask length can only be 0 – 32”
break
fi
L2M $L
$ECHO -n “.”
L2M $G
$ECHO -n “.”
L2M $G
$ECHO -n “.”
L2M $G
}
Mask2Len(){
M=$1
m[0]=`$ECHO $M | awk -F”.” ‘{ print $1 }’`
m[1]=`$ECHO $M | awk -F”.” ‘{ print $2 }’`
m[2]=`$ECHO $M | awk -F”.” ‘{ print $3 }’`
m[3]=`$ECHO $M | awk -F”.” ‘{ print $4 }’`
loop=0
mask=0
while [ $loop -lt 4 ];do
div=256
while [ $div -gt 1 ];do
let “div=$div / 2”
let “test=${m[$loop]} – div”
if [ ! $test -lt 0 ];then
let “mask=$mask +1”
m[$loop]=$test
else
break
fi
done
let “loop=$loop+1”
done
$ECHO “$mask”
111/433
}
$IFCONFIG -a| grep “:” |egrep -v “ether” | awk ‘{ print $1 }’ | sed ‘s/(.*):/1/’ | while read i; do
F=/tmp/${i}.$$
$IFCONFIG $i > $F
I=`cat $F | egrep -v “:|group” | awk ‘{ print $2 }’`
E=`cat $F | egrep “ether” | awk ‘{ print $2 }’`
GP=`cat $F | egrep “groupname” | awk ‘{ print $2 }’`
NMH=`cat $F | grep -v “:” | awk ‘{ print $4 }’`
rm $F
TMP=`$ECHO $NMH | sed ‘s/../ 0x&/g’`
NMD=`printf “%d.%d.%d.%dn” $TMP`
M2L=`Mask2Len $NMD`
$ECHO “$i,$E,$GP,$I,$NMH,$NMD,$M2L”
done
112/433
live upgrade to solaris 10
These are the steps to upgrade a Netra t1 with two identical disks from solaris 9 to solaris 10, using liveupgrade with a
Solaris 10 image from a standard jumpstart directory. This procedure is good because it needs no downtime, and the
configurarion you have in your original system is preserved (/etc,/export/home).
If you have a jumpstart server, make a nfs share of the install directory for your new release, in this case
solaris10. We have the solaris10 sparc jumpstart directory in a linux machine, so we edited the /etc/exports to
include:
/200gb/jumpstart (ro)
Where /200gb/jumpstart/sol10 contains:
bash-3.00# uname -a
Linux linuxy 2.4.31 #6 Sun Jun 5 19:04:47 PDT 2005 i686 unknown unknown GNU/Linux
bash-3.00# ls -la /200gb/jumpstart/sol10
total 491
drwxr-xr-x 4 root root 432 2006-03-11 12:12 .
drwxr-xr-x 4 root root 136 2006-08-23 09:14 ..
-r–r–r– 1 root root 93 2005-11-15 12:36 .cdtoc
drwxr-xr-x 5 root root 184 2005-12-07 10:32 .install
lrwxrwxrwx 1 root root 33 2006-08-23 09:10 .install_config -> ./Solaris_10/Misc/.install_config
-r–r–r– 1 root root 472 2006-03-11 12:12 .slicemapfile
-r–r–r– 1 root root 21 2005-11-15 12:36 .volume.inf
-r–r–r– 1 root root 23 2005-12-07 09:53 .volume.inf.2
-r–r–r– 1 root root 23 2005-12-07 09:53 .volume.inf.3
-r–r–r– 1 root root 23 2005-12-07 09:54 .volume.inf.4
-r–r–r– 1 root root 6604 2005-11-16 13:14 Copyright
-r–r–r– 1 root root 459760 2005-11-15 12:36 JDS-THIRDPARTYLICENSEREADME
drwxr-xr-x 9 root root 232 2005-12-07 10:32 Solaris_10
-rwxr-xr-x 1 root root 257 2005-12-07 09:54 installer
Back at the Netra machine (the one to upgrade), verify what disks do we have
bash-2.05# uname -a
SunOS netra 5.9 Generic_118558-28 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
bash-2.05# format </dev/null
Searching for disks…done
AVAILABLE DISK SELECTIONS:
0. c0t0d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>
/pci@1f,0/pci@1,1/scsi@2/sd@0,0
1. c0t1d0 <SUN18G cyl 7506 alt 2 hd 19 sec 248>
/pci@1f,0/pci@1,1/scsi@2/sd@1,0
Partition the second disk identically as the first one.
231/433
bash-2.05# /usr/sbin/prtvtoc /dev/rdsk/c0t0d0s2 | /usr/sbin/fmthard -s – /dev/rdsk/c0t1d0s2
It is a requirement that if you upgrade a system from solaris 9 to solaris 10, you MUST install the live upgrade
pakages for the target version in the old version. So, we install SUNWluu and SUNWlur getting it from the
solaris10 install nfs export
bash-2.05# uname -a
SunOS netra 5.9 Generic_118558-28 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
bash-2.0.5# mkdir /jstart
bash-2.0.5# mount 172.16.1.50:/200gb/jumpstart /jstart
bash-2.0.5# cd /jstart/sol10/Solaris_10/Product
bash-2.0.5# pkgadd -d . SUNWluu
bash-2.0.5# pkgadd -d . SUNWlur
We now create the live upgrade environment for solaris10, along with the current solaris9 environment, in this
case we only have /, no /opt,/var,/export/home, so we only define that we have to copy /.
bash-2.05# lucreate -c “sol9” -m /:/dev/dsk/c0t1d0s0:ufs -n “sol10”
Discovering physical storage devices
Discovering logical storage devices
Cross referencing storage devices with boot environment configurations
Determining types of file systems supported
Validating file system requests
Preparing logical storage devices
Preparing physical storage devices
Configuring physical storage devices
Configuring logical storage devices
Analyzing system configuration.
No name for current boot environment.
Current boot environment is named <sol9>.
Creating initial configuration for primary boot environment <sol9>.
The device </dev/dsk/c0t0d0s0> is not a root device for any boot environment.
PBE configuration successful: PBE name <sol9> PBE Boot Device </dev/dsk/c0t0d0s0>.
Comparing source boot environment <sol9> file systems with the file
system(s) you specified for the new boot environment. Determining which
file systems should be in the new boot environment.
Updating boot environment description database on all BEs.
Searching /dev for possible boot environment filesystem devices
Updating system configuration files.
The device </dev/dsk/c0t1d0s0> is not a root device for any boot environment.
Creating configuration for boot environment <sol10>.
Source boot environment is <sol9>.
Creating boot environment <sol10>.
Creating file systems on boot environment <sol10>.
Creating <ufs> file system for </> on </dev/dsk/c0t1d0s0>.
Mounting file systems for boot environment <sol10>.
Calculating required sizes of file systems for boot environment <sol10>.
Populating file systems on boot environment <sol10>.
Checking selection integrity.
Integrity check OK.
Populating contents of mount point </>.
232/433
Copying.
Creating shared file system mount points.
Creating compare databases for boot environment <sol10>.
Creating compare database for file system </>.
Updating compare databases on boot environment <sol10>.
Making boot environment <sol10> bootable.
Population of boot environment <sol10> successful.
Creation of boot environment <sol10> successful.
Go on and upgrade the sol10 boot environmet from the jumpstart image, nfs mounted, this step will install the
solaris 10 packages needed over the solaris 9 image copied to c0t1d0
bash-2.05# luupgrade -u -n sol10 -s /jstart/sol10
Validating the contents of the media </jstart/sol10>.
The media is a standard Solaris media.
The media contains an operating system upgrade image.
The media contains <Solaris> version <10>.
Constructing upgrade profile to use.
Locating the operating system upgrade program.
Checking for existence of previously scheduled Live Upgrade requests.
Creating upgrade profile for BE <sol10>.
Determining packages to install or upgrade for BE <sol10>.
Performing the operating system upgrade of the BE <sol10>.
CAUTION: Interrupting this process may leave the boot environment unstable
or unbootable.
Upgrading Solaris: 100% completed
Installation of the packages from this media is complete.
Updating package information on boot environment <sol10>.
Package information successfully updated on boot environment <sol10>.
Adding operating system patches to the BE <sol10>.
The operating system patch installation is complete.
INFORMATION: The file </var/sadm/system/logs/upgrade_log> on boot
environment <sol10> contains a log of the upgrade operation.
INFORMATION: The file </var/sadm/system/data/upgrade_cleanup> on boot
environment <sol10> contains a log of cleanup operations required.
INFORMATION: Review the files listed above. Remember that all of the files
are located on boot environment <sol10>. Before you activate boot
environment <sol10>, determine if any additional system maintenance is
required or if additional media of the software distribution must be
installed.
The Solaris upgrade of the boot environment <sol10> is complete.
Now we activate the solaris 10 boot environment:
bash-2.05# luactivate sol10
kraftek.html POSTS rescue rescued.html rescued.txt x y z
The target boot environment has been activated. It will be used when you
reboot. NOTE: You MUST NOT USE the reboot, halt, or uadmin commands. You
MUST USE either the init or the shutdown command when you reboot. If you
do not use either init or shutdown, the system will not boot using the
target BE.
kraftek.html POSTS rescue rescued.html rescued.txt x y z
233/433
In case of a failure while booting to the target BE, the following process
needs to be followed to fallback to the currently working boot environment:
1. Enter the PROM monitor (ok prompt).
2. Change the boot device back to the original boot environment by typing:
setenv boot-device disk:a
3. Boot to the original boot environment by typing:
boot
kraftek.html POSTS rescue rescued.html rescued.txt x y z
Activation of boot environment <sol10> successful.
Bounce the system…
bash-2.05# init 6
INIT: New run level: 6
The system is coming down. Please wait.
System services are now being stopped.
Live Upgrade: Deactivating current boot environment <sol9>.
Live Upgrade: Executing Stop procedures for boot environment <sol9>.
Live Upgrade: Current boot environment is <sol9>.
Live Upgrade: New boot environment will be <sol10>.
Live Upgrade: Activating boot environment <sol10>.
Live Upgrade: The boot device for boot environment <sol10> is
</dev/dsk/c0t1d0 s0>.
Live Upgrade: Activation of boot environment <sol10> completed.
The system is down.
syncing file systems… done
rebooting…
Resetting …
Netra t1 (UltraSPARC-IIi 440MHz), No Keyboard
OpenBoot 3.10.27 ME, 256 MB memory installed, Serial #14270360.
Ethernet address 8:0:20:d9:bf:98, Host ID: 80d9bf98.
Executing last command: boot
Boot device: disk1:a File and args:
SunOS Release 5.10 Version Generic_118822-25 64-bit
Copyright 1983-2005 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
WARNING: No major number for driver mpt in class scsi
Hostname: netra
Configuring devices.
Loading smf(5) service descriptions: 121/121
Aug 25 14:38:13 svc.startd[7]: svc:/system/mdmonitor:default: Method “/lib/svc/method/svc.
Aug 25 14:38:14 svc.startd[7]: svc:/system/mdmonitor:default: Method “/lib/svc/method/svc.
Aug 25 14:38:14 svc.startd[7]: svc:/system/mdmonitor:default: Method “/lib/svc/method/svc.
[ system/mdmonitor:default failed (see ‘svcs -x’ for details) ]
This system is configured with NFS version 4, which uses a domain
name that is automatically derived from the system’s name services.
The derived domain name is sufficient for most configurations. In a
few cases, mounts that cross different domains might cause files to
be owned by “nobody” due to the lack of a common domain name.
Do you need to override the system’s default NFS version 4 domain
name (yes/no) x y z [no] : no
For more information about how the NFS version 4 default domain
234/433
name is derived and its impact, refer to the man pages for nfs(4)
and nfsmapid(1m), and the System Administration Guide: Network
Services.
netra console login: root
bash-3.00# uname -a
SunOS netra 5.10 Generic_118822-25 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
Solaris 10 is now installed on the second disk.
To bounce it back to our first disk on solaris 9, you can activate the boot environment and reboot.
bash-3.00# uname -a
SunOS netra 5.10 Generic_118822-25 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
bash-3.00# luactivate sol9
bash-3.00# init 6
solaris patchadd return codes
0. No error
1. Usage error
2. Attempt to apply a patch that’s already been applied
3. Effective UID is not root
4. Attempt to save original files failed
5. pkgadd failed
6. Patch is obsoleted
7. Invalid package directory
8. Attempting to patch a package that is not installed
9. Cannot access /usr/sbin/pkgadd (client problem)
10. Package validation errors
11. Error adding patch to root template
12. Patch script terminated due to signal
13. Symbolic link included in patch
14. NOT USED
15. The prepatch script had a return code other than 0.
16. The postpatch script had a return code other than 0.
17. Mismatch of the -d option between a previous patch install and the current one.
18. Not enough space in the file systems that are targets of the patch.
19. $SOFTINFO/INST_RELEASE file not found
20. A direct instance patch was required but not found
21. The required patches have not been installed on the manager
22. A progressive instance patch was required but not found
23. A restricted patch is already applied to the package
24. An incompatible patch is applied
25. A required patch is not applied
26. The user specified backout data can’t be found
27. The relative directory supplied can’t be found
28. A pkginfo file is corrupt or missing
235/433
29. Bad patch ID format
30. Dryrun failure(s)
31. Path given for -C option is invalid
32. Must be running Solaris 2.6 or greater
33. Bad formatted patch file or patch file not found
34. Incorrect patch spool directory
35. Later revision already installed
236/433
Unresponsive keyboard on vnc with gnome sessions on Solaris
You might get a problem when using a gnome session on Solaris with vnc where keyboard is unresponsive….
According to http://sunsolve.sun.com/search/document.do?assetkey=1-9-81175-1 :
To work around this issue, touch the following file:
/etc/gconf/gconf.xml.defaults/apps/gnome_settings_daemon/keybindings/%gconf.xml
and edit the file with:
<?xml version=”1.0″?>
<gconf>
<entry name=”volume_up” mtime=”1110896708″ type=”string”>
<stringvalue></stringvalue>
</entry>
<entry name=”volume_mute” mtime=”1110896705″ type=”string”>
<stringvalue></stringvalue>
</entry>
<entry name=”volume_down” mtime=”1110896702″ type=”string”>
<stringvalue></stringvalue>
</entry>
<entry name=”help” mtime=”1110896698″ type=”string”>
<stringvalue></stringvalue>
</entry>
</gconf>
Then just stop and start your vnc server
243/433
tsm incremental backup (101)
Learning tsm too…
In order to do an incremental backup on a server….
#nohup dsmc incremental
In order to stop and start the tsm client acceptor….
#/etc/init.d/dsmc stop
#/etc/init.d/dsmc start
i’m learning….
257/433
up2date usage for new package install
If you want to use up2date to install new packages that are not installed in your system, you can search by doing:
# up2date –showall
andgrep for your desired package, then you can install by doing:
# up2date <packagename>
33/433
Use hpasmcli to diagnose your HP hardware
To check your hardware for failures, if you have hpasm installed:
# hpasmcli -s “help show”
USAGE: SHOW [ ASR | BOOT | DIMM | F1 | FANS | HT | IML | IPL | NAME | PORTMAP | POWERSUPPLY |
PXE | SERIAL | SERVER | TEMP | UID | WOL ]
# hpasmcli -s “show dimm”
# hpasmcli -s “show fans”
# hpasmcli -s “show iml”
# hpasmcli -s “show powersupply”
# hpasmcli -s “show server”
# hpasmcli -s “show temp”
If you want to use the web interface use http://thehost:2301
Thanks to Justin Lim
Using OMSA cli to diagnose DELL Hardware
If you have omsa installed in your OS, you can do:
# omreport system -?
# omreport system alertlog
# omreport system events
# omreport system alertaction
# omreport system postlog
# omreport system shutdown
# omreport system summary
# omreport system pedestinations
# omreport system recovery
# omreport system platformevents
# omreport system esmlog
87/433
You may use the web interface by browsing https://hostname:1311
OMSA can be obtained by browsing http://ftp.us.dell.com/sysman/
to start it you can run:
srvadmin-services.sh start
Thanks to Justin Lim
88/433