Most of the Solaris utilities (eg. find, grep, awk, sed) are sort of crippled when compared to their GNU counterparts. The GNU versions of the utilities are relatively flexible, in the sense that they most often support additional useful features.
Some GNU related hacks include:
1 2 |
# print yesterday's date $ date --date="yesterday" |
1 2 |
# any permission matching in find $ find . -perm /222 |
So, how to get the GNU utilities installed on a Solaris system? On Solaris 11, you can find some of the common GNU utilities installed under the /usr/gnu/bin
directory. The GNU utilities have soft links in /usr/bin
that starts with a ‘g’ prefix. So for /usr/gnu/bin/find
, there is soft link at /usr/bin/gfind
.
1 2 |
$ ls -l $(which gfind) lrwxrwxrwx 1 root root 15 Dec 21 15:59 /usr/bin/gfind -> ../gnu/bin/find |
If you need some other GNU utilities or other open source packages, you can either download and compile the source packages yourself or choose to install the binary packages maintained at OpenCSW instead. Previously, Sunfreeware and Blastwave.org offered open source Solaris packages for download. But the support for packages at Sunfreeware has been discontinued and they are moving towards a paid subscription service. As for Blastwave.org, they have ceased operation. In this article, we will explore installing the packages from OpenCSW – a community project with a lot of popular open source software.
Install OpenCSW Solaris Packages
OpenCSW packages are managed using pkgutil
. First, install pkgutil
using pkgadd
– Solaris default package manager. OpenCSW packages work best with Solaris 10. If you are on Solaris 8 or Solaris 9, consider upgrading.
1 |
$ sudo pkgadd -d http://get.opencsw.org/now |
The above command will install pkgutil
to /opt/csw/bin
. Once installed, update the catalog or package list.
1 |
$ sudo /opt/csw/bin/pkgutil -U |
Once the catalog package list has been updated, install the core recommended packages.
1 |
$ sudo /opt/csw/bin/pkgutil -i -y coreutils wget gzip vim |
Once done, you can now use pkgutil
to install additional packages. To list all the available packages for download, use the following syntax.
1 |
$ sudo /opt/csw/bin/pkgutil -a |
Now, let’s say that you want to download the GNU awk
utility. First, get the list of available packages for awk
.
1 2 3 4 |
$ sudo /opt/csw/bin/pkgutil -a awk common package catalog size gawk CSWgawk 4.1.0,REV=2013.10.08 1.3 MB mawk CSWmawk 1.3.4,REV=2010.05.26 72.2 KB |
Next, install the package. You can either specify the common name found on the first column or the package name in the 2nd column, both seem to work. pkgutil
will also install all dependencies.
1 |
$ sudo /opt/csw/bin/pkgutil -i -y awk |
OpenCSW binaries will be available under /opt/csw/bin
and /opt/csw/gnu
directories. Binaries under the /opt/csw/bin
directory will have a ‘g’ prefix for all the binary names. So, you will find files named as gbasename
, gcat
, gfind
, gls
under /opt/csw/bin
. This is to prevent any clashes with binaries in /usr/bin
.
To upgrade packages, simply run pkgutil using the below syntax.
1 |
$ sudo pkgutil -U -u -y |
To make your life easiser, you can consider adding /opt/csw/bin
to your PATH
and /opt/csw/man
to your MANPATH
. MANPATH
is no longer required in Solaris 11, if I am not wrong.