OneDayOpenSolarisTraining

1-Day OpenSolaris Training

Welcome to the OpenSolaris training!

Sun has released the OpenSolaris 2008.05 distribution which is a brand new way of distributing Solaris using a live CD with even more software available on network repositories. During this training you will learn how to get started with OpenSolaris and get a good understanding of its benefits. You'll have a unique hands-on experience with many of the advanced technologies which come with OpenSolaris. We will use VirtualBox, a desktop virtualization software, to run OpenSolaris - a pre-installed & pre-configured image is available for you to save time with installing and configuring OpenSolaris.

The first and last presentations are lectures, but the rest of the sessions are hands-on and you're required to participate by following the hands-on-labs. This training is ment to be very interactive so if you have any questions or issues please let the instructor know. So let's get started!

I am in process of uploading the VirtualBox image for the training due to frequent requests - a download link will be added shortly. In meanwhile you can install all necessary software by installing OpenSolaris 2008.05 and installing packages which are listed on the bottom of this wiki page.

Hardware Requirements

In order to run VirtualBox on your machine, you need:

  • Processor: Reasonably powerful x86 or x64 hardware. Any recent Intel or AMD processor should do.
  • Memory: 1 GB Minimum. Basically, you will need whatever your host operating system needs to run comfortably, plus the amount that OpenSolaris needs, which is 512 MB minimum, preferably 1 GB or more. So, in order to run OpenSolaris on Windows XP, you probably won't enjoy the experience much with less than 1 GB of RAM.
  • Hard disk space: 10 GB. While VirtualBox itself is very lean (a typical installation will only need about 30 MB of hard disk space), OpenSolaris will require 10 GB.
  • A supported host operating system: Presently, Windows (primarily XP), Mac OS X, Solaris, OpenSolaris and many Linux distributions on 32-bit hosts and on 64-bit hosts.

Agenda:

1. What makes OpenSolaris interesting? (presentation, 30 min)
2. OpenSolaris basics - getting started, users & roles, desktop, SMF, IPS (hands-on-lab, 60 min)
3. ZFS - revolution in file systems (hands-on-lab, 60 min)

Break

4. Extreme observability with DTrace (hands-on-lab, 60 min)
5. Developing on OpenSolaris - Sun Studio, AMP stack, NetBeans (hands-on-lab, 30 min)
6. Useful command line tools in OpenSolaris (hands-on-lab, 60 min)

1. What makes OpenSolaris interesting?

This part of the training is just a presentation - there are no exercises. Slides available here and here.

2. OpenSolaris basics - getting started, users & roles, desktop, IPS, SMF

Slides for this section available here.

Task 2.1 Getting started with VirtualBox

VirtualBox is an opensource desktop virtualization software developed by Sun Microsystems. We have prepared a VirtualBox image (a .vdi file) with OpenSolaris pre-installed including software we will use for the training.

  • Run VirtualBox (it is installed on your lab computer and should have an icon on the desktop).
  • Click New to create a new virtual machine. Click Next.
  • Type OpenSolaris as name and choose OpenSolaris as OS type.
  • Choose 1 GB as available memory size. In case your system has only 1 GB of memory or less, allocated approx. 2/3 of the memory space for VirtualBox.
  • Search for an existing VirtualBox image. Click Add to locate the existing image. The instructor will tell you location of the image on your lab computer. The image's extension is .vdi. Once mounted you will see it in the list of available hard disks. Click Select to confirm the selection.
  • Click Finish to finish the wizard.
  • You should now see the virtual machine in the list. Click Start to start the virtual machine.
  • OpenSolaris should start booting. When you see boot options, press Enter to confirm the default boot option (OpenSolaris). Wait until the graphical login screen comes up.
  • Login as user guest, password guest.
  • Press Right-Ctrl-F to switch to full screen (focus needs to be inside of VirtualBox).

Task 2.2 Desktop & Terminal

  • Get acquainted with the desktop. Go to the main menu and start some applications (e.g. Firefox, Gimp, Calculator, etc.). Click on the right bottom part of the screen to move to different virtual desktops.
  • Start OpenOffice (Applications | Office | OpenOffice Writer) and try to write a simple document and save it to your disk.
  • We'll use the system terminal a lot for the training. Go to Applications | System Tools | Terminal. Right click on Terminal and choose "Add this launcher to desktop". A new Terminal icon should appear on the desktop.
  • Double click on the Terminal icon to open terminal.
  • Type whoami to find out which user is logged in.
  • Type date to see current date and time.
  • If you prefer different terminal look and feel, go to Edit | Profiles and change terminal colors and/or font size.

Task 2.3 Pfexec, managing users, changing password, switching users

In this section we'll learn about useful commands for user management. But first we need to learn about pfexec which lets you run applications under root privileges (similar to sudo but doesn't require password in default configuration). You can simply run pfexec command to run the command in privileged mode.

  • Add a new user by running pfexec useradd username. Choose any username you like (e.g. your name).
  • Change password for the new user by running pfexec passwd username. Username should be the username you chose in last step. Specify some password (twice).
  • Switch to the new user by running pfexec su username.
  • Check which user you are by running whoami.
  • Press Ctrl-D to log off from your current session.
  • Check which user you are by running whoami.
  • You can also become the superuser (root) by running pfexec su. The password for root is opensolaris.
  • Check which user you are by running whoami.
  • Now you can run privileged commands without pfexec. Let's take a look at the user configuration file. Type cat /etc/passwd.
  • Let's take a look at user attributes configuration. Type cat /etc/user_attr.
  • Delete the user you created before by running userdel username.
  • You can also use a GUI tool to work with users. Try to add a new user and delete it with System | Administration | Users and groups application.

Task 2.4 Installing VirtualBox guest editions

VirtualBox guest additions can be installed to improve the desktop experience with VirtualBox (e.g. better resolutions, mouse control, copy & paste between host and guest and more).

  • Switch VirtualBox to windowed mode if you are in fullscreen mode (press Right-Ctrl-F).
  • Run Devices | Install Guest Additions from VirtualBox main menu.
  • A new window should open with the guest additions CD.
  • Drag & drop the Solaris package on desktop (VBoxSolarisAdditions.pkg).
  • Open terminal.
  • Run pfexec pkgadd -d Desktop/VBoxSolarisAdditions.pkg. Confirm all questions. The package gets installed.
  • Run pfexec reboot to reboot the virtual machine. Guest additions will start to work now. Check by copy & paste from host to guest. Notice new mouse cursor behavior.

Task 2.5 Managing services with SMF

SMF is a replacement for rc.d scripts with many advantages over rc.d scripts.

  • List available services by running svsc.
  • Check if any services failed by running svsc -x.
  • Look for the inetd service - svcs | grep inetd. You'll get the FMRI: svc:/network/inetd:default
  • Find all processes related to this service - svcs -p inetd. Get the process ID.
  • Kill the inetd process by running pfexec kill ID, where the ID is the number you got in previous step.
  • The process will be restarted automatically. Check if it's running by svcs -p inetd. There should be a new process ID.
  • Get more info about the service by running svcs -x inetd. You should see the location of the log file.
  • Find out more about what happened by running tail logfile where logfile is the name of the logfile from previous step.
  • Check that the ssh service is running by executing svcs | grep ssh.
  • Stop the ssh service by running svcadm disable ssh.
  • Check that the ssh service has been stopped by running svcs | grep ssh.
  • Start the service by running svcadm enable ssh.
  • Check that the ssh service is running again by executing svcs | grep ssh.
  • There is also a simple GUI for managing services. Try it by running System | Administration | Services.

Task 2.6 Getting on the network

  • You should be able to access the network. Verify that by running Firefox and visiting e.g. www.google.com.
  • Network connection is managed by the NWAM daemon. Shut it down by running svcadm disable nwam.
  • Check whether you can access the network now.
  • Start nwam again by running svcadm enable nwam.
  • Wait for about 20 seconds and you should get a confirmation message with your IP address.
  • Check whether you can access the network now.
  • Network interfaces are managed by ifconfig. You can see the list of all interfaces by running ifconfig -a. Here you can find your interface name, IP address and other details. You can use ifconfig for low level management of the network.

Task 2.7 Getting documentation

Manual pages are the unix way of providing documentation for individual commands.

Task 2.8 Installing additional software

In this section we'll look at how to install software from the default package repository and other repositories.

  • Try running curl. The command shouldn't be found. We'll try to install this application (it is used for HTTP testing).
  • Let's search for curl. Run pfexec pkg search -r curl.
  • You'll get a list of packages with fully qualified names. To install the right one for your OpenSolaris version one run pfexec pkg install SUNWcurl.
  • After a while Curl and dependent packages get downloaded and installed. Verify it by running curl www.opensolaris.com.
  • Check package contents by running pkg contents SUNWcurl.
  • Uninstall Curl by running pfexec pkg uninstall SUNWcurl
  • Let's repeat the steps with the package manager GUI application. Run System | Administration | Package Manager and search for curl, install it and then uninstall it.
  • There are many different repositories you can use. One of the popular ones is Sun Freeware. Add it by running pfexec pkg set-authority -O http://pkg.sunfreeware.com:9000 sunfreeware.
  • Run pfexec pkg refresh to refresh the package cache.
  • You can also browse the repository using Firefox (open http://pkg.sunfreeware.com:9000).
  • Search for lynx and install it using command line or GUI. Verify that the package was installed by running /opt/sfw/bin/lynx.
  • List all installed packages by running pkg list.
  • Verify installed packages by running pfexec pkg verify.

Task 2.9 OpenSolaris basics minitest

Let's check whether you learned something during this class

Test 2A

  • Add a new user - username:test, password: test.
  • Switch to user test and verify that your current session is running under user test.
  • Switch back to your original account.
  • Delete user test.

Test 2B

  • Start the telnet server using SMF.
  • Verify that telnet is running by running telnet localhost. Login with your username and password.
  • Disable the telnet service.

Test 2C

  • Find out what is your current IP address.

Test 2D

  • Search for text editor joe and install it. Verify successful installation by running it.
  • Remove package for text editor joe and verify that the editor is no longer available.

3. ZFS - revolution in file systems

Presentation slides are here. Please follow the instructor. For more training on ZFS see the ZFS tutorial.

This section of the training is under construction and will be updated in upcoming weeks.

4. Extreme observability with DTrace

Please follow the instructor. For more hands-on training download the Java One hands on lab from here.

This section of the training is under construction and will be updated in upcoming weeks.

5. Developing on OpenSolaris - Sun Studio, AMP stack, NetBeans

Slides for this section available here.

Task 5.1 Getting started with Sun Studio

  • Start Sun Studio by running /opt/SunStudioExpress/bin/sunstudio
  • Open file Welcome.cc using project explorer and look at the source code.
  • Run the main project using Run | Run main project. Specify a parameter in the opened console.
  • Add a breakpoint on line 51 and run the debugger using Run | Debug main project.
  • Look at variables using the Variables tab in debugger
  • Add a watch for variable i. Press continue and observe the changes of the variable.
  • Go to terminal and switch directory by running cd ~/SunStudioProjects/Welcome/dist/Debug
  • Run ./welcome
  • Run ./welcome 1 2 3
  • Go back to Sun Studio. Choose Release in the combo box above the editor to switch the current configuration to release.
  • Rebuild the project.
  • Go back to the terminal and go to cd ~/SunStudioProjects/Welcome/dist.
  • Run ls to see available configurations.
  • Run ls -la Debug Release. Notice differences in file sizes.

Task 5.2 Running the AMP stack

  • Start the Apache and MySQL services using Applications | Developer Tools | Web Stack Admin | Start Apache2/MySQL servers.
  • Open Firefox and go to *http://localhost*. You should see a web page loaded.
  • Open terminal and go to /var/apache2/2.2/htdocs.
  • Run pfexec gedit index.html.
  • Change the text to Hello World and save the file.
  • Reload the page in your browser, it should get updated.

Task 5.3 PHP development with NetBeans

  • Start NetBeans PHP version (not the Java version!).
  • Create a New Project. You can leave the name PHPProject1, but choose to put the metadata in a separate directory (use default directory). In last step just click Finish.
  • Modify index.php with following source code: <?php echo "Hello world!"; ?>
  • Run the project using Project | Run Main Project.
  • You should see the application running in a web browser.
  • Let's connect to MySQL by running /usr/mysql/bin/mysql -uroot
  • List databases by running show databases.
  • Switch to database test by running /u test.
  • Create a table: create table test (id int);
  • Insert a row: insert into test values (1);
  • Insert a row: insert into test values (2);
  • Insert a row: insert into test values (3);
  • Show table contents: select * from test;
  • Back to NetBeans IDE.
  • Use following code:
     
           <?php
            $c = mysql_connect("localhost", "root");
            mysql_select_db("test");
            $r = mysql_query("select * from test");
            for ($i=0; $i<mysql_num_rows($r); $i++) {
                echo mysql_result($r, $i)." ";
            }
            ?>
    
  • Run the application in web browser using Run | Run Main Project.

6. Useful command line tools in OpenSolaris

Slides for this section available here.

Task 6.1 Process-related commands

  • List all processes by running ps -ef.
  • Find the process ID of Xorg by running ps -ef | grep Xorg. Notice you get 2 lines (why?).
  • Prstat is unix version of "top". Run it using prstat.
  • Keep prstat running and run OpenOffice Writer. Check how the CPU load changes. Press space anytime for refresh.
  • Kill is used for killing processes. Run: pfexec snoop. Open a new terminal. Find out process ID by running ps -ef | grep snoop. Run pfexec kill process_id where process_id is the id of the snoop process you found out using ps.
  • You can also kill a process according to it's name. Run: pfexec snoop. Open a new terminal. Run pfexec pkill snoop.

Task 6.2 Disk devices

  • Find available disk devices using format. Run pfexec format.
  • Run fdisk on the device you found using format. E.g. if format returned c4d0 the proper fdisk command is fdisk /dev/rdsk/c4d0p0. Quit fdisk.
  • Find out more details about devices by running iostat -En.

Task 6.3 File-related commands

  • Find can be used to locate files on disk. Search the /opt directory for all files or directories containing word "java" by running pfexec find /opt -name "java"
  • Which can be used to find out which file will be executed. Run which tar to see which tar will be executed if you type just "tar*. Note that there are more versions of tar on your disk - you can verify that by running find /usr -name "tar".
  • You can view all files in current directory by running ls. For more detailed list run ls -la.
  • You can print contents of a file using cat. Try for example cat /var/log/syslog.
  • You can count the number of lines by running cat /var/log/syslog | wc.
  • Cd changes a directory. Pwd shows current directory. Try: cd /etc and pwd.
  • Grep prints lines matching a pattern. Try: cat /var/log/Xorg.0.log | grep Mouse.
  • Head shows top of a file. Try: head /var/log/Xorg.0.log.
  • Tail shows end of a file. Try: tail /var/log/Xorg.0.log.
  • Less can be used to browse a file interactively. Try: less /var/log/Xorg.0.log. Press space to move through the file.
  • Mkdir creates directories, run mkdir /tmp/test.
  • Touch can create a file. Run: touch /tmp/test/file1.txt. Verify that the file exists by running: ls -la /tmp/test.
  • Cp copies files. Run: cp /tmp/test/file1.txt /tmp/test/file2.txt. Verify by running: ls -la /tmp/test.
  • Mv moves files. Run: mv /tmp/test/file2.txt /tmp/test/file3.txt. Verify by running: ls -la /tmp/test.
  • Rm removes files. Run rm /tmp/test/file3.txt. Verify by running: ls -la /tmp/test.
  • Rm can be used to delete directories. Run rm -rf /tmp/test.

Task 6.4 Command line tools minitest

Test 6A

  • Find the log file for ssh daemon and count the number of times that ssh was started according to the log file.

Test 6B

  • Find the process IDs for all bash shells.

Test 6C

  • Find the controller number for your hard disk and for your CD/DVD drive.

Test 6D

  • What is the number of all files and directories under /usr/bin?

End of training. Time to go for beer!

List of required software to be installed on lab computers:

  • VirtualBox (recent stable release, download here)
  • .vdi image for the training (not available at this moment)

List of software that has been installed inside of the image (already done for the .vdi file referenced above):

  • openoffice
  • ss-dev
  • webstackui
  • SUNWphp524-mysql
  • PostgreSQL (from NV, IPS package is old)
  • NetBeans 6.5 beta Java SE version (from netbeans.org, no IPS package)
  • NetBeans 6.5 beta PHP version (from netbeans.org, no IPS package)

Extra topics to be covered in the extended training:

  • Types of files, symlinks
  • Access rights & chmod
  • More information about shells
  • More about user home and using ~
  • Using wildcards on files
  • Foreground and background processes
  • Signals and IPC
  • df, du, gzip, tar, file, diff
  • Make, configure, etc.
  • Environmental variables
  • NFS, CIFS
  • P-tools
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Sign up or Log in to add a comment or watch this page.


The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact