Solaris Operating Systems in CL136

This web page will guide you through the fundamentals that you need to perform your lab and class assignments.

If you need help during the week, you are welcome to go to CL119 during Office Hours posted for lab instructors.

What is Solaris?

Solaris is a UNIX based operating system designed by Sun Microsystems. It is a popular operating system for higher-end computers such as workstations or Web servers. It is an alternative to other operating systems, like Windows and Mac OS. Solaris is not a program like Microsoft Word or a set of programs like an Microsoft Office suite. It is a UNIX Operating System.

The computers in CL136 are running Solaris 9 Operating System.

Login to Solaris in CL136

To login to the Solaris system in CL136, you can use your Hercules username and password. If you don't have a Hercules account, contact your lab instructor in the lab or in CL119 during Office Hours.

When you login to Solaris computer, you will see your home folder on the desktop. This is where you store your files, such as your C++ programs.

You will see something similar to the following image. It is called the Front Panel.

The Front Panel is your “dashboard” or control area for the CDE desktop. It gives you point-and-click and drag-and-drop access to the majority of applications on your system; it allows you to switch workspaces; and it displays information such as time and date, printer status, and so on. You can customize your Front Panel to include your favorite applications, and you can move or minimize the Front Panel.
The Front Panel comprises the Main Panel (displayed by default) and several subpanels that roll-up when you click their tab on the main panel.

Web Browser in Solaris

There are many Web browsers available for Solaris. The one we are going to use is Netscape. It is the globe icon on the Main Panel.

To start, simply click on the icon. The default Webpage should be the CS Department Homepage.

If it is not, to set the default webpage to CS110 online material, go Edit--> Preferences, then type     in the Location field box.

Make sure there are no mistakes, then press OK. Now when you click on the Home button, you will see the CS110 lab home page.

Open Terminal

Terminal is where you
  1. write, compile and run your C++ programs,
  2. capture your program output, and
  3. print your C++ programs.
When you use the Terminal, the operations are performed by Solaris, but your files are stored on Hercules.

To start a terminal from File Manager, you need to click the File Manager control on the Main Panel.

The File Manager window appears. Choose Open Terminal from the File Manager File menu.

Manipulating Files

Unix Commands

You need to learn a few basic Unix commands in order to manipulate your files and control your working environment. Solaris is a Unix type operating system, so generally the same commands will work on both systems.
Be sure to look in the following list for the cp , ls and script commands. List of Unix commands

For more information refer to: UNIX Tutorial for Beginners

Another very important command is:
 ssh hercules
This allows you to work directly on Hercules, rather that working on a Solaris machine and using the Hercules disk space. This is important if you want to access Hercules at home or in other labs on campus. When you enter the ssh hercules you are logging on to that computer and will have to enter your password again. You will see a different prompt on your Terminal when you are connected.

Copying files

This semester you will need to obtain C++ sample programs for your labs and class. There are three methods you can use to copy these files to your Hercules account.
  1. The Unix cp command.
    You need to know the path i.e. the location of the file to be copied from the CS Department's server to use this command. We will always give you the complete path. For example the path to the file hello.cpp is: /net/data/ftp/pub/class/110/ftp/cpp so to copy the file, you would use this cp command:
      cp /net/data/ftp/pub/class/110/ftp/cpp/hello.cpp  hello.cpp
  2. Use the mouse to copy and paste the contents of the file.
    This works if the file is displayed on a web page such as in this link to hello.cpp. When you have the program displayed you can "copy" and "paste" it into the edit program you are using. Your lab instructor will demonstrate this process when explaining how to use the text editor pico.

  3. Use the FTP program to perform the copy. Follow the instructions in this How to use FTP link to download the sample program: hello.cpp.

Editing Files

To write your C++ programs, you need to use a text editor. Because we are not in MicroSoft Windows, we can't use Word, or Notepad. One text editor in Solaris or UNIX is called pico.

The Pico Editor is a user-friendly text editor on Solaris and UNIX computers. It can be used for creating or editing files. The most common commands are listed at the bottom of the pico screen.

To open a file in the pico text editor type:

pico filename

For example, if you have the hello.cpp program in your account, type the following command:

pico hello.cpp

Pico text editor screen with hello.cpp file displaying:

In pico, you can move up, down, left or right using the arrows on your keyboard. You cannot use your mouse!

To edit, you can backspace over text and then enter new text. You can also delete an entire row of text at once time using Ctrl k.

To exit from pico, Ctrl^X will do.

Creating a New File:
To create a new file using the pico editor, type at the command prompt:

pico newfilename.cpp
A blank pico editor session will display. Add C++ code to create a new program. When you save the file, it will be given the filename that you entered in the command above.

Compiling and Printing your C++ Programs

Compiling your C++ program.

The command to compile your C++ program on Solaris is:

CC program_name -o executable filename 
For example, to compile your hello.cpp program, you enter
CC hello.cpp -o hello
To run the program, type
If you have entered ssh Hercules to work directly on Hercules, the compile and run commands are the same. Using the hello.cpp example again, here are the commands to compile and run directly on Hercules, or from home or from another computer on campus.
CC hello.cpp -o hello

Print from Solaris in CL136

The command to print files in ClassRoom 136 is

lpr -Pcl136 filename
For example,
lpr -Pcl136 hello.cpp
In the next lab, you will see how to print from other labs on campus and at home.

Copyright: Department of Computer Science, University of Regina.