X-Windows
Welcome to X-Windows on Solaris. Today you will sit at a workstation, log in, and explore X-Windows as well as a number of UNIX commands.On the Suns you are presented with a login window which includes the ability to choose a desktop environment. Make a selection -- I usually use KDE (because it is similar to what I use under Linux), but others like CDE. OpenWindows is ok, too, and xfce is a lightweight environment. Choose any, and you can choose a different one later. In fact, I encourage you to try additional environments (after completing the lab exercises).
Window Managers. Once you have logged in, explore the interface. Notice that these window managers treat application windows differently. Buttons to minimize, close, resize, etc. are all functionst that can be mapped by the window manager. If your window manager didn't automatically open a shell console or terminal window, look for the tool that will do so and open it. You'll need it for the rest of this lab. Once you have one open, you can open additional ones the same way, or start one or more xterms from the one shell that is running.
Copying and Pasting. X-Windows provides a simple and intuitive way to copy and paste using a mouse. Whenever you highlight text (anywhere) using the left mouse button, that text is available for pasting. Pasting is performed by clicking on the middle mouse button (or both buttons together on a two-button mouse).
Web Browsers. While some window managers have icons and links to web browsers (e.g., Konquerer), most likely they are for old browsers. However, from your shell you can type netscape to run Netscape 7, which is reasonbly modern.
Editors. Similarly, some window managers may have a link to editors, but probably not for vi or emacs. You can type them at the shell. If you run emacs, you'll get the X-windows interface automatically whenever it can run (unless you specify the -nw option to prevent it).
Office Applications. Some windowing environments will include menu items for office applications such as word processors and spreadsheets. An additional one that might be of interest is OpenOffice and Sun's version, called StarOffice. StarOffice 7 is free for educational use, is available for many platforms, cincluding Solaris, Linux, and Windows, and can read and write Microsoft Office compatible files. If you want to be able to run StarOffice, you must first run a setup program (found in /apps/staroffice7/setup). Then, to actually run the office package, type /apps/staroffice7/soffice.
Remote Execution. One thing that makes X-Windows great is the ability to log into a machine remotely, and then have a program use your local display. You can do this too -- just ssh from your machine to another (that is, type something similar to ssh <newhost>), and then run a program (that uses windows) on the other machine and see it show up on your screen. This separation of display and execution makes it easy to use high-powered, centralized servers, even though you might not be able to sit in front of them. Lehigh provides a number of such computational servers (such as rigel.cc.lehigh.edu which has 32 processors and 32GB of RAM and runs IRIX, a version of UNIX from SGI).
UNIX
During the following, don't forget how to learn about the commands described. There is not room here to explain all aspects of a command, and in some cases, enough information is not provided here to know how to do something.
Exercise 1: In class we used ls -l to list files in a long format (size, permissions, etc.). What option to ls will show files that start with a period?
Exercise 2: Sometimes there are more than one version of a program installed. traceroute, for example, is a program that sends out packets, attempting to identify every host on the route to the destination. However, there are two versions of traceroute installed on the Suns, and the one that is run when you type traceroute doesn't work unless you are root!
The whereis command will look for programs in a bunch of standard places. Use whereis to find the two locations for traceroute.
But which one is being run when you type traceroute? Use the which command to find out. You can always specify the complete (or relative) path of a program to override the automatic one. Use the working traceroute to count the number of hops to get to www.openoffice.org.
Now use whereis to find out where gcc is installed. Compare that result to the location returned by which for gcc. Something is fishy, right?
So how does UNIX decide what programs you can run, just by typing their name? It uses your path, which is an environment variable (i.e., something that you can change) called PATH. Type env to see all your environment variables. Your shell will look in each directory in the order specified in your path to see if there is a program with the name you entered. One of those directories should match the directory in which gcc is found (which you saw earlier with whereis).
Wildcards and Escapes
Instead of specifying a filename or directory (as a parameter to a program), you can use wildcards (instead of tab completion).io:~/cse271.051% ls
Note that in the next examples, ls is showing the contents of the directory (or directories) passed as paramters to ls.
hw1/io:~/cse271.051% ls *
In reality, the shell expanded the wildcards to instead be the list of filenames that match, so that the program that is called never sees the wildcards -- it just sees the parameters as if the user had typed them.
DONEio:~/cse271.051% ls ?w?
Arguments to commands are separated by whitespace, so spaces and other special characters must be escaped or quoted, as in:
DONE
io:~/cse271.051%io:~% touch "this is a test"
touch is a program that will create a new (empty) file if one does not exist, and will change the last-modification-time of an existing file.
io:~% touch this\ is\ a\ test
io:~% ls th*
this is a testCopy and Move UNIX Files
cp and mv work more or less the same. You give them a list of source files and a destination. mv is also used to rename files.Examples:
Copy mozilla180.jpg to the images directory
% cp mozilla180.jpg images/
Copy this_dir and all its subdirectories to /tmp
% cp -r this_dir/ /tmp
Move Makefile and all .c and .h files to the cse213 directory
% mv Makefile *.c *.h cse213/
Move a file from /tmp to the current directory
% mv /tmp/d4x-2.02-2.i386.rpm .
Rename a file
% mv foo.c rename.cCreating and Removing Directories
mkdir and rmdir are the usual programs, but sometimes using rm is easier.io:~% mkdir test1
io:~% mkdir test2
io:~% touch test1/hello
io:~% rmdir test1
rmdir: directory "test1": Directory not empty
io:~% rmdir test2
io:~% rm -rf test1
io:~%
Displaying Files
You can always open a text file in emacs to view it. However, there are other ways -- cat, less, and more are typical choices.tritan 2% cat -n test.c
less and more are called pagers -- they display a large file, one page (screenful) at a time.
1 int a;
2 int main (sdfsdf a)
3 {
4 int b;
5 }
tritan 2%
Printing
Often you will want to print a file. UNIX printing systems are typically configured to handle (print) plain text files and PostScript files. There are two major approaches to printing under UNIX: the System V and BSD command interfaces. Both work on our Sun installation.What printers are available?
Exercise 3: What are the names of the two printers in this room (not named 'pl122')?
- Use lpstat -v to see what printers are available
To print a file to printer pl122:
The printing subsystem will convert a text or postscript file to the appropriate printer language if necessary. For example, you can usually print a postscript file to a dot matrix printer.
- Using SysV-style: lp -d pl122 <filename>
- Using BSD-style: lpr -Ppl122 <filename>
To see what documents are currently queued for printer pl122:
Removing a queued document 42:
- SysV: lpstat -o pl122
- BSD: lpq -Ppl22
- SysV: cancel 42 pl122
- BSD: lprm -Ppl22 42
Text-based Web browsing
Sometimes it is helpful to be able to browse the web from the machine to are connected to, rather than the one you are sitting in front of. For example, some websites are restricted to users within some domain (such as .lehigh.edu). Fortunately, most UNIX installations have one or more text-based web browwsers installed. The most common is called lynx. Use lynx to visit your favorite web page and see whether the page is still useful (since it won't show graphics or javascript, etc.).Exercise 4: Use emacs to create a text file with your name and the answers to the questions in exercises 1-3. Print it out and show the TA or the instructor.
Okay, that's it. Now you can try out some of the other windowing systems.