SunOS 5.10: Quick Notes


Where are programs like make, gcc, python, etc?

They are all under /usr/ccs/bin and /usr/sfw/bin.

Utilities like whoami are under /usr/ucb

You should set them in your PATH.


Setting up the default gateway under SunOS

Run route add default x.x.x.x and also add the IP to the /etc/defaultrouter file such that it will survive a reboot

This is analogous to route add default gw x.x.x.x under linux.


Extracting a .tar.gz archive

Run gzip -dc File.tar.gz | tar xf - to extract File.tar.gz

This is analogous to tar -xzf File.tar.gz under linux.

What does the linux ‘top’ CPU fields stand for?

The first few lines of the top command looks similar to this:

Tasks: 137 total, 1 running, 136 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.0%us, 4.2%sy, 90.0%ni, 0.0%id, 0.0%wa, 0.0%hi, 0.0%si, 5.8%st
Mem: 786432k total, 715152k used, 71280k free, 61012k buffers
Swap: 2096472k total, 18304k used, 2078168k free, 168068k cached

The fields on the second line breaks down the CPU usage into 8 categories.

us: user CPU used by user processes
sy: system CPU used by system/kernel processes
ni: nice CPU used by processes that were reniced
id: idle CPU not used
wa: io wait Essentially idle CPU waiting on IO devices
hi: hardware irq CPU used to service hardware IRQs
si: software irq CPU used to service soft IRQs
st: steal time CPU time which the hypervisor dedicated (or ‘stole’) for other guests in the system.

RRDTool yum dependencies on CentOS

If you are trying to compile RRDTool (at the time of writing, 1.4.5) on CentOS 5.x, you will need install the following packages on yum:

yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel

Then, just compile rrdtool as usual:

wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gz
tar -xzf rrdtool-1.4.5.tar.gz
cd rrdtool*
./configure --prefix=/opt/rrdtool
make
make install

Redirecting / Merging stdout and stderr streams

To merge the standard out and standard error streams from a program, use 2>&1.

Example: umount /adsf/asdf 2>&1 will output the errors into standard out instead of standard error as usual.

Note that:

  • 2 is the file descriptor for stderr.
  • 1 is the file descriptor for stdout.
  • & accepts a file descriptor which can then be treated as a file.

Thus, 2>&1 in turns ‘writes data’ from stderr into stdout.

Reset MySQL Root Password

Here’s a quick way to reset your mysql root password. Replace ‘NewRootPass’ with your new root password and run the following as root.

/etc/init.d/mysql stop
mysqld --skip-grant-tables --user mysql &
mysql -u root -e "UPDATE mysql.user SET Password=PASSWORD('NewRootPass') WHERE User='root'"
/etc/init.d/mysql restart

Note: This was done on CentOS. You might need to adjust the path to mysql’s startup scripts accordingly.

Restarting Services in Solaris

To restart a service under solaris, run the scripts under

/lib/svc/method/

This is more or less equivalent to the startup scripts in /etc/init.d/ under linux.

For instance, to restart SSH, run:

/lib/svc/method/sshd restart

You may also want to take a look at svcadm. To restart SSH, you can run

svcadm restart ssh

or

svcadm restart svc:/network/ssh

How to create a linux user with an empty/blank password

I had a need to create a ‘guest’ account in one of my linux installs which allows anonymous users within a trusted intranet to login to a specially crafted script. One of the issues that I was faced with was with passwd refusing to accept a blank password. To let empty password logins, we must manually change the account password.

When we look at /etc/shadow, we will see something similar to:

username:$1$ADUODeAy$gRz7rO6P5lFcPpYwqd7Eb0:14929:0:99999:7:::

The underlined part is the password hash. The hash is delimited by $. Things to know:

  1. first $1 means the hash is a md5 hash
  2. second $ADUODeAy is the salt
  3. third $gRz7rO6P5lFcPpYwqd7Eb0 is the actual password hash

To generate this hash manually, we can use openssl:

# openssl passwd -1 -salt ADUODeAy
Password: [enter]
$1$ADUODeAy$eCJ1lPSxhSGmSvrmWxjLC1

Note that the first parameter, -1, tells openssl to use md5 to generate the hash. This is the same 1 from the original hash above.

Replace the existing hash in /etc/shadow with the hash generated by openssl. The account now essentially has an empty password.

Notes:

  • You will need to temporarily change the permission of /etc/shadow in order to write to it.
  • You will need to enable ‘PermitEmptyPasswords’ in /etc/ssh/sshd_config for empty password logins to work
  • This can easily be a security risk to your machine! Ensure the account and server is locked down or use SSH keys for passwordless logins! Remember, by default, users can SSH tunnel through this guest account. You must consider the implications of enabling such an account on your machine.

XEN Windows Server install causes “stop: 0x0000005d”

When attempting to install Windows Server 2008 R2 under XEN, after loading from the disc, the installer will blue screen with the error:

STOP: 0x0000005D (<4 hex values, last 3 being 0x0000000000000000>)

To resolve this, try to enable pae in your XEN configuration file. ie, add the following line:

pae = 1

I am currently using the following configuration under XEN 3.12. Hopefully this will help.

kernel = '/usr/lib/xen/boot/hvmloader'
builder = 'hvm'
device_model = '/usr/lib64/xen/bin/qemu-dm'
maxmem = 4096
memory = 1024
vcpus=1
pae = 1
acpi=1
apic=1

name = "xenwin"

vif = [ 'type=ioemu' ]

disk = [ 'phy:/dev/VolGroup00/winserv08r2_disk,ioemu:hda,w',
         'file:/vm/iso/win2008server-r2.iso,ioemu:hdc:cdrom,r' ]

# Boot from the CD 
boot='d'

vnc=1
vncconsole=1
vncpasswd=''
sdl=0

stdvga=0 
serial='pty'
ne2000 = '0'
usbdevice='tablet'

on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

Sun v60x – Benchmark

Tested a school lab Sun v60x server with CentOS 5.5 loaded. It is a 1u full rack server and thus, uncomfortably loud.

Specs:
2x Xeon @ 3.06GHz
2GB Memory
2x 36GB 10k Disks

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.2)

   System: server: GNU/Linux
   OS: GNU/Linux -- 2.6.18-194.el5 -- #1 SMP Fri Apr 2 14:58:35 EDT 2010
   Machine: i686 (i386)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Xeon(TM) CPU 3.06GHz (6113.9 bogomips)
          Hyper-Threading, MMX, Physical Address Ext
   CPU 1: Intel(R) Xeon(TM) CPU 3.06GHz (6112.7 bogomips)
          Hyper-Threading, MMX, Physical Address Ext
   CPU 2: Intel(R) Xeon(TM) CPU 3.06GHz (6112.8 bogomips)
          Hyper-Threading, MMX, Physical Address Ext
   CPU 3: Intel(R) Xeon(TM) CPU 3.06GHz (6112.8 bogomips)
          Hyper-Threading, MMX, Physical Address Ext
   08:16:31 up  2:58,  9 users,  load average: 0.02, 0.66, 0.73; runlevel

------------------------------------------------------------------------
Benchmark Run: Tue Oct 19 2010 08:16:31 - 08:44:46
4 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables        5016443.2 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     1193.4 MWIPS (10.6 s, 7 samples)
Execl Throughput                               1798.0 lps   (29.8 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        182385.5 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           52532.0 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        491880.2 KBps  (30.1 s, 2 samples)
Pipe Throughput                              328327.0 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                  71385.9 lps   (10.0 s, 7 samples)
Process Creation                               6120.4 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   3269.1 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    767.9 lpm   (60.0 s, 2 samples)
System Call Overhead                         410651.3 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0    5016443.2    429.9
Double-Precision Whetstone                       55.0       1193.4    217.0
Execl Throughput                                 43.0       1798.0    418.1
File Copy 1024 bufsize 2000 maxblocks          3960.0     182385.5    460.6
File Copy 256 bufsize 500 maxblocks            1655.0      52532.0    317.4
File Copy 4096 bufsize 8000 maxblocks          5800.0     491880.2    848.1
Pipe Throughput                               12440.0     328327.0    263.9
Pipe-based Context Switching                   4000.0      71385.9    178.5
Process Creation                                126.0       6120.4    485.7
Shell Scripts (1 concurrent)                     42.4       3269.1    771.0
Shell Scripts (8 concurrent)                      6.0        767.9   1279.8
System Call Overhead                          15000.0     410651.3    273.8
                                                                   ========
System Benchmarks Index Score                                         419.7

------------------------------------------------------------------------
Benchmark Run: Tue Oct 19 2010 08:44:46 - 09:13:05
4 CPUs in system; running 4 parallel copies of tests

Dhrystone 2 using register variables       10913892.7 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     3875.1 MWIPS (10.4 s, 7 samples)
Execl Throughput                               4163.8 lps   (29.8 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks        119217.0 KBps  (30.1 s, 2 samples)
File Copy 256 bufsize 500 maxblocks           32092.8 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks        364708.0 KBps  (30.1 s, 2 samples)
Pipe Throughput                              877013.1 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 251983.1 lps   (10.0 s, 7 samples)
Process Creation                              13102.1 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   5817.9 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                    820.7 lpm   (60.2 s, 2 samples)
System Call Overhead                        1060775.7 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   10913892.7    935.2
Double-Precision Whetstone                       55.0       3875.1    704.6
Execl Throughput                                 43.0       4163.8    968.3
File Copy 1024 bufsize 2000 maxblocks          3960.0     119217.0    301.1
File Copy 256 bufsize 500 maxblocks            1655.0      32092.8    193.9
File Copy 4096 bufsize 8000 maxblocks          5800.0     364708.0    628.8
Pipe Throughput                               12440.0     877013.1    705.0
Pipe-based Context Switching                   4000.0     251983.1    630.0
Process Creation                                126.0      13102.1   1039.9
Shell Scripts (1 concurrent)                     42.4       5817.9   1372.2
Shell Scripts (8 concurrent)                      6.0        820.7   1367.8
System Call Overhead                          15000.0    1060775.7    707.2
                                                                   ========
System Benchmarks Index Score                                         702.1