Wednesday, September 25, 2013

Solaris Basics

Restart

If you would restart your box like this in linux:

shutdown -r now

Then you restart your box like this in solaris:

reboot

Shell

If you're used to the uparrow and tab key being useful in the linux console and they are horrible on your solaris console, it's probably because you're in sh instead of bash. Just type bash to get into bash. You can see what you're in by echo $SHELL

Since that can get annoying, here's how to change root's default shell to bash.

usermod -s /usr/bin/bash root

linuxquestions.org claims that this won't effect the shell used to run rc scripts, so hopefully it won't cause any OS-update issues as suggested by thepacketmaster. Note that the usermod command hasn't changed the contents of /etc/profile

But sure enough, next time you login, you'll be in bash. You probably want to customize your prompt and map some keys, so you need the bash startup script. This is defined as .bash_profile in the $HOME directory which for root on solaris is / so you must create /.bash_profile and add any commands you want.

For example, I minimize my prompt:

PS1="# "

Also, taking advice from freebsd.org, I correctly map my HOME, END, DEL keys.

bind '"\e[1~": beginning-of-line'
bind '"\e[4~": end-of-line'
bind '"\e[3~": delete-char'

Here are some others you might want

bind '"\e[5~": beginning-of-history'
bind '"\e[6~": end-of-history'
bind '"\e[2~": quoted-insert'
bind '"\e[5C": forward-word'
bind '"\e[5D": backward-word'

Shares

If you would mount NFS like this in linux:

vi /etc/fstab
your.box.com:/folder /localAlreadyExists nfs hard,rw 0 0

Then you mount NFS like this in solaris:

vi /etc/vfstab
your.box.com:/folder - /localAlreadyExists nfs no yes -

The list of currently mounted file systems is recorded at /etc/mnttab

more /etc/mnttab

If you want to see shares from windows, they're probably using samba, which is shipped with solaris 10, but isn't on the default path. Once you've setup your .bash_profile above, you'll want to add the following to it.

PATH=$PATH:/usr/sfw/bin:/usr/sfw/sbin

Once that's on your path, you can use the samba client to see what shares are available to you. It'll prompt you for your password.

smbclient -L yourWindowsBox -U yourLoginDomain/yourLoginName
Domain=[yourLoginDomain] OS=[Windows 7 Enterprise 7601 Service Pack 1] Server=[Windows 7 Enterprise 6.1]

        Sharename       Type      Comment
        ---------       ----      -------
        ADMIN$          Disk      Remote Admin
        C$              Disk      Default share
        D$              Disk      Default share
        E$              Disk      Default share
        shared          Disk
Domain=[yourLoginDomain] OS=[Windows 7 Enterprise 7601 Service Pack 1] Server=[Windows 7 Enterprise 6.1]

        Server               Comment
        ---------            -------

        Workgroup            Master
        ---------            -------

The first time I used smbclient it gave a huge warning which I resolved by creating /etc/sfw/smb.conf as an empty file owned by root.

Unfortunately smbclient doesn't let you mount a share. After reading forums.oracle.com, obdev.at, wikipedia, obdev.at, it seems clear that the only way to mount an smb share from solaris10 is to use sharity which is a pay program with built in trial that limits you to one installation, one mounted share and one user.

Sharity

Works like a charm. At first I installed the wrong architecture, which I discovered as follows.

# bash
# sharity
-bash: /usr/bin/sharity: Invalid argument

# sh
# sharity
sharity: cannot execute

# ldd /usr/local/sharity3/bin/sharity
ldd: /usr/local/sharity3/bin/sharity: has wrong class or data encoding

So be sure you know which download to select from their list.

#uname -a
SunOS yourBox 5.10 Generic_142909-17 sun4v sparc SUNW,SPARC-Enterprise-T5120

Here's a simple install and use-case.

cd /tmp
wget http://www.obdev.at/downloads/sharity3/sharity.3.9.solaris-sun4.tar.gz
gzip -dc sharity.3.9.solaris-sun4.tar.gz | tar xf -
cd sharity.3.9.solaris-sun4
./setup
 [enter]    english
 [enter]    start install
 [enter]    /usr/local/sharity3
 /usr/bin   location for sharity symlinks
 none       don't install network browser
 yourDomain default windows domain, edit later via /usr/local/sharity3/var/user.cfg
 [enter]    don't know about WINS server
 [enter]    confirm answers
 password   for internal keychain
 password   confirm
# sharity
Usage: sharity <command> [<options>]
Type sharity -h for a list of commands

# sharity man mount
SYNOPSIS
    sharity mount <url> <mountpoint> [<options>]
    -U <user>   If a login is required, use this remote name.
    -D <domain> If a login is required, use this domain.

# sharity mount smb://yourBox/yourFolder /localAlreadyExists -U yourName -D yourDomain

# sharity umount -a

By default, sharity won't support symlinks, but it can fake them by creating regular files that it treats specially as described here and here.

Unfortunately all they say about it is that you must enable the feature in their config GUI, but if you're like me then you're on a headless box, so you'll have to edit the config files manually. Have a look at these.

vi /usr/local/sharity3/etc/config/main.cfg

/* This is the generic configuration file for Sharity. Please do not edit this
 * file since all changes are lost with the next upgrade. Put permanent changes
 * into var/local.cfg instead.
 */

vi /usr/local/sharity3/etc/config/cifs.cfg

/* This is the CIFS configuration file for Sharity. Please do not edit this
 * file since all changes are lost with the next upgrade. Put permanent changes
 * into var/local.cfg instead.
 */

cifs.cfg gave me enough info to make the following edit.

vi /usr/local/sharity3/var/local.cfg

cifs = {
        servers = {
                ".default" = {
                        emulateSymlinks = "yes";
                }
        }
};

At first that had no effect, but after reboot and remount, I'm now able to create and follow symlinks.

ln -s /whereMyLinkPoints /myMountPoint/someRemoteFolder/newFileName

The above creates newFileName on the remote server and sharity treats it as if it was whereMyLinkPoints

Compilers

Heres the best I could deduce from oracle.com

Product                  Runs on SPARC   Compiler  Year
Sun Studio 12 update 1              10       5.10  2009
Sun Studio 12                     9,10       5.9   2007
Sun Studio 11                   8,9,10       5.8   2005
Sun Studio 10                   8,9,10       5.7   2005
Sun Studio  9                   8,9,10       5.6   2004
Sun Studio  8                 7,8,9,10       5.5   2004
Sun ONE Studio 8              7,8,9,10       5.5   2003
Sun ONE Studio 7              7,8,9          5.4   2002
Sun WorkShop 6 update 2   2.6,7.8.9          5.3   2001

Thus I interpret the following as "Sun WorkShop 6 update 2", i.e. a patch of the 5.3 compiler.

# uname -a
SunOS yourbox 5.8 Generic_117350-60 sun4u sparc SUNW,Sun-Fire-V210

# /isv/sw6.0_u2p/SUNWspro/bin/CC -V
CC: Sun WorkShop 6 update 2 C++ 5.3 Patch 111685-06 2002/03/09

And I interpret the following as "Sun Studio 12 update 1", i.e. a patch of the 5.10 compiler.

# uname -a
SunOS yourbox 5.10 Generic_142909-17 sun4v sparc SUNW,SPARC-Enterprise-T5120

# /usr/bin/CC -V
CC: Sun C++ 5.10 SunOS_sparc 128228-09 2010/06/24
{ "loggedin": false, "owner": false, "avatar": "", "render": "nothing", "trackingID": "UA-36983794-1", "description": "", "page": { "blogIds": [ 453 ] }, "domain": "holtstrom.com", "base": "\/michael", "url": "https:\/\/holtstrom.com\/michael\/", "frameworkFiles": "https:\/\/holtstrom.com\/michael\/_framework\/_files.4\/", "commonFiles": "https:\/\/holtstrom.com\/michael\/_common\/_files.3\/", "mediaFiles": "https:\/\/holtstrom.com\/michael\/media\/_files.3\/", "tmdbUrl": "http:\/\/www.themoviedb.org\/", "tmdbPoster": "http:\/\/image.tmdb.org\/t\/p\/w342" }