Programmer's Blog

Programmer's reference

Category Archives: Soalris

[Soalris] cron log

/var/cron/log

[Linux] Reverse all lines in vi/vim

:g/^/m0

[Solaris] Changing hostid

1. Change your desired hostId into decimal, then to ASCII characters code

2. add the following line to /etc/rc2.d/S20syssetup

echo "hw_serial/v 32 32 33 31 34 36 32 30 36 32 00 00" | mdb -kw

where there should be 12 blocks with padding trailing 00s

3. run ./S20syssetup

4. to back to original, just revert the steps

[Solaris] Recursive grep

#find. | xargs grep 'search terms'

[Solaris] du –maxdepth=1 equivilant for Solaris

#>du -sh *

[Linux] Crontab Settings

#crontab –e

0 30 * * * * /root/runcorn.sh > /dev/null 2>&1

//format of the cron time
# Minute   Hour   Day of Month       Month          Day of Week        Command    
# (0-59)  (0-23)     (1-31)    (1-12 or Jan-Dec)  (0-6 or Sun-Sat)                
    0        2          12             *                *            /usr/bin/find

[solaris] Recursive grep

find . | xargs grep 'words you want to find'

[Solaris] enable usr/sfw/bin

There are many programs in solaris are installed but not added to the path

e.g. cc, gcc, to include, just include the path of the following to the /etc/profile

PATH="$PATH:$HOME/bin:/usr/sbin:/usr/bin:/root/bin:/usr/bin:/usr/sbin:/usr/local
/bin:/usr/local/sbin:/bin:/sbin:/opt/csw/bin:/opt/csw/sbin:/opt/csw/gcc3/bin:/us
r/sfw/sbin:/usr/sfw/bin:/opt/csw/mysql5/bin"

For gcc, you shall add a symbolic link to the /usr/sfw/sbin/ folder

[Solaris] using tar in solaris

1. for archive without .gz
# tar -cvf example.tar example
# tar -xvf example.tar

2. for archive including gz
# tar cvf - file | gzip > file.tar.gz
# gunzip -c file.tar.gz | tar xvf -

[Solaris] Static network configuration

1. To determine installed network card
# dladm show-link

2. To switch on the network card and assign ip (netmask optional)
# ifconfig <interface> plumb up
# ifconfig <interface> 10.0.0.1 netmask + 255.0.0.0