Welcome to the
Computer Systems Lab Unix Orientation. This short introduction is intended to
acclimate new and novice users the Unix computing
environment at the Computer Sciences Department. In this tutorial, you will learn how to use
Gnome, execute commands, navigate the file system via the shell, and use some
of the CSL supported software.
Unix uses what is called the “X Windows system” and a “window manager” to
provide a graphic user interface (GUI). The default CSL supported window
manager is GNOME (the GNU Network Object Model Environment), a
powerful, easy-to-use, fully-featured window manager. It is similar in many
respects to the window managers and interfaces used by Windows and Mac OS.
Users familiar with these operating systems and interfaces may find GNOME very
familiar and intuitive. In addition to
the following information about GNOME, there is a wealth of information
available on the Web and in its manual page (in a terminal, type, man gnome).
Once you have logged in you should see your desktop. There should be three icons on the desktop;
Computer, which will open up a file browser, your home, which will open a file
browser of your home directory, and Trash, where files deleted via the file
browser go.
At the top and bottom of your screen are
“panels” which can contain menus, program launchers, and a host of other
goodies. By default, the top panel
contains the Applications and Actions menus, which allow you to access commonly
used programs, change certain settings, log out, and do many other useful
things. To the right of these are program launchers, which run the CSL
supported web browser, email client, and office software when clicked. On the
far right side of the top panel lie a clock and an icon for volume control.
The bottom panel contains a list of currently
open programs. Clicking on any of these icons will bring that program's window
to the top and make it the primary focus of the window manager. On the right
side of the bottom panel is the “Workspace Switcher”. This allows you to have
windows open on multiple desktops. For instance, if you wanted to open your
email on one desktop, a web browser in another, your programming projects in
yet another, and other random programs in the last one, you can click on the
small “screens” on the right side of the bottom panel to switch between your desktops, launch these programs, and change between them.
·
Title Bar: On the top center of
windows in X you will find an area with a small amount of text. This is called
the Title Bar. It serves to remind you what the window contains, usually the
name of the program which is running. By clicking and dragging the title bar
with the left mouse button, you can move the window around the desktop.
Double-clicking the window will maximize the window, or restore it to its
original size if it was already maximized.
·
Window Menu: In the upper left
corner of each window is a button with a small “v” or picture of a window in
it. By clicking your left mouse button on this, a menu is displayed. This menu
is called the Window Menu. It has options for managing the size, location, and
focus of the window, or simply to close the window.
·
Min/Max/Close Buttons: In the upper
right corner of each window is a set of three buttons. Clicking the button with
the underscore (“_”) will minimize the window and hide it, placing is in the
bottom panel. Click on its respective entry in the bottom panel to restore it.
Clicking the button with the box will maximize the window so it takes up the
entire desktop. Click this button again to restore the window to its original
size. Clicking on the button with the “x” will close the window.
·
Window Frame/Border: The top (just
above the title bar), bottom, sides, and corners of a window can be used to
resize the window. Simply put your mouse
cursor over these parts of the window (also called the window's “frame” or “border”)
until the mouse cursor turns into a double-ended arrow. Then, click and drag
with the left mouse button until the window is the size you want.
·
The Window: The window itself
contains a number of different things needed to run the program, including text
prompts, menus, and additional buttons. These vary from program to program.
Clicking anywhere within the window or on its frame or title bar will raise it
to the front and give focus to it.
By clicking on
the desktop (anywhere there's not a window) with the right mouse button, you will bring up a menu
that can perform various actions,
from opening a shell terminal to changing your desktop background.
·
Open Terminal: Opens a text-based shell terminal to run other programs and commands (see
the Shell).
·
Create
Folder/Launcher/Document: Creates
a folder/directory, program
launcher (which will run a program when double-clicked), or document/file on your desktop. These objects
will be placed in the “Desktop” folder in
your home directory.
·
Miscellaneous: The other root-menu options will organize
your desktop or change your
desktop background. Right-clicking in a window will likely bring up a different menu.
Right-clicking on the title bar or frame of the window will bring up the window menu.
After 20 minutes of inactivity, a screen
saver will activate. This will also lock the computer. In order to use the
computer again, you will need to re-enter your password at the prompt.
Be aware that you are not allowed to have an
instructional computer locked, intentionally or otherwise, for more than 10
minutes unless you are physically sitting at the computer. Repeat offenses may
result in your account being suspended because of potential problems related to
cheating.
To log out (end your session), click the
“Action”' menu in the top panel and select “Log out”. Click OK to log yourself
out. Please wait until the orientation ends before trying this. Note that
selecting “Shut Down” or “Restart” from this command will simply log you out
and spit an error message at you, so please only use logout.
NOTE: The
more files, launchers, and folders that are on your desktop,
and the more you add to your panels and environment, the slower GNOME will
become, especially for logins. These also count against your disk quota.
In the CS Unix environment, a text-based shell is used inside of the X windows GUI. The shell is another user interface to the Unix operating system. It is a program that takes input from you, the user, and translates it into commands that the operating system can understand. It then conveys the operating system’s output back to you. Remember that neither the shell nor X windows are themselves Unix, just user interfaces to Unix.
Specifically, the CSL default supported shell is bash (the GNU Bourne-Again SHell). There are various types of user interfaces. Shells such as bash belong to the category known as text-based interfaces. These interfaces accept lines of textual commands that the user types in and usually produce text-based output. Another type of interface is the Graphic User Interface, or GUI, which adds the ability to display graphics and to accept input from mice and other devices.
NOTE: where you see text like this it is showing you what to type at the shell prompt, or the output from the command you just typed. Many commands take command line options/arguments.
[bbadger@demo] (1)$ ls (“ls” lists files in the current
directory.)
Desktop/ mail@ private/
public/
[bbadger@demo] (2)$ ls -l (This
will give you a listing of the files, along with some other useful information,
including the size of the file. This is an example of using command line options.)
total 7
drwxr-x--- 2 bbadger bbadger 2048 Jun 2 13:21
Desktop/
lrwxr-xr-x 1 bbadger root 12 Jun 1 17:36 mail ->
private/mail/
drwx------ 4 bbadger bbadger 2048 Jun 1 17:36
private/
drwxr-xr-x 3 bbadger bbadger
2048 Jun 1 17:36 public/
[bbadger@demo] (3)$ cd private (“cd”
takes you into another directory, in this case your “private” directory)
[bbadger@demo]
(4)$ ls
[bbadger@demo]
(5)$ cp /etc/motd . (“cp”
copies a file from one place [source = /etc/motd] to
another
[target = the local directory]. Don’t forget the “.” at the end, it tells cp
to copy the file to the current directory.)
[bbadger@demo]
(6)$ ls
motd
[bbadger@demo] (7)$ mv motd myfile (“mv” can be used
to rename a file from <source> to <target>)
[bbadger@demo]
(8)$ ls
myfile
[bbadger@demo] (9)$ mkdir project1 (“mkdir” creates a
new directory)
[bbadger@demo]
(10)$ ls
myfile project1/
[bbadger@demo]
(11)$ mv myfile project1 (“mv”
can also move files to another directory)
[bbadger@demo]
(12)$ cd project1
[bbadger@demo] (13)$ pwd (“pwd” prints the “working directory”, which is the path to
directory you are
currently in. It’s useful in case you forget where you are
and need to get
your bearings in the shell. Note that /u/b/b/bbadger will be replaced by your
path and login.)
/afs/cs.wisc.edu/u/b/b/bbadger/private/project1
[bbadger@demo]
(14)$ ls
myfile
[bbadger@demo] (15)$ cat myfile (“cat” prints the whole file all at
once into the terminal)
.
.
.
[bbadger@demo] (16)$ less myfile (“less” prints the file one page at a
time, allowing you to scroll using the
arrow keys – uses ‘q’ to quit and ‘/’ to search for text)
.
.
.
[bbadger@demo] (17)$ rm myfile (“rm” permanently removes a file. This does
not use Trash folder and cannot
be un-deleted.)
[bbadger@demo] (18)$ ls
[bbadger@demo] (19)$ cd .. (Remember
that “..” refers to the parent directory of the
directory you are in,
“private” in this case.)
[bbadger@demo] (20)$ ls
project1/
[bbadger@demo] (21)$ rmdir project1 (“rmdir” removes a directory, but only if it is empty.)
[bbadger@demo] (22)$ ls
[bbadger@demo] (23)$ cd (“cd”
alone takes you to your home directory.)
[bbadger@demo] (24)$ ls
Desktop/ mail@ private/ public/
Useful Abbreviations:
. Your current directory
.. The parent of your current directory
˜ Your home directory
˜bbadger bbadger’s home directory
In order to remotely work on your projects or to upload files, SSH (Secure SHell) is available. Linux has a command line version installed. Graphical SSH clients available for Windows or Macs covered in the CSL FAQs.
[bbadger@demo] (25)$ ssh <machine> (Look
to your left or right during orientation – use the name of the machine
next to you.)
[bbadger@demo2]
(1)$ w (See
who else is logged in to the machine.)
.
.
[bbadger@demo2]
(2)$ exit
Type man bash in the terminal and search the shell man page to learn about the file name completion and command history mechanisms available in the shell. Also read the man pages on the commands “ls”, “cd”, “cp”, “mv”, “mkdir”, “pwd”, “cat”, “less”, “rm”, “rmdir”, “ssh” and “w”.
Now that you know how to get around using the shell and simple commands, we will now illustrate how you might use them to do your coursework or work on a project. We will copy files from a project directory, edit them, compile them into a program, and run the program.
Your instructor will, in some cases, provide you with some partially finished files that you will need to complete, or some extra files needed to run your projects that you do not need to edit. Your instructor may tell you to copy the files from a specific directory. We’re going to set up a project directory, and copy the files into that directory.
[bbadger@demo] (26)$ cd ~/private (Go to your private directory, recall
that “˜” refers to your home directory.)
[bbadger@demo] (27)$ mkdir project1 (Create the project directory.)
[bbadger@demo] (28)$ cd project1
[bbadger@demo] (29)$ cp /p/lab/unix-orientation/project1/*.java
. (Copy the project files to your own
project directory. “*” is a “wildcard” which matches any
number of
characters. In this case, you will copy all the files ending
in “.java” to your
current directory.)
[bbadger@demo] (30)$ ls
TestProgram.java TestClass.java
You now have the files, but they won’t compile as they are. You need to edit one of them to actually work. One way to do this is to run the “Emacs” text editor and load TestClass.java into it. See the Emacs section below for more details, and please pay attention to what changes need to be made to the file.
[bbadger@demo]
(31)$ emacs TestClass.java
You might be used to compiling and running your home-made programs using a graphical-based environment such as Eclipse. However, you can also compile and run them using the shell.
[bbadger@demo] (32)$ javac *.java (javac is the Java compiler program. Using the ‘*’ wildcard compiles all
files in the current directory ending in .java.
If javac produced
any
errors, you should fix them before proceeding to run java.)
[bbadger@demo] (33)$ java TestProgram (java is the command in linux to
run Java programs)
Hello, world!
Congratulations! You just ran your Java program using the shell. If this was a real project, you would now test and debug your program until it was just perfect. But since this is just a simple test project, you can end here.
Mozilla is a powerful collection of free software. In the CSL, we make use of its web browser and email client.
Mozilla’s web browser, “Firefox”, was originally based on Netscape source code. Today, the features and functionality of Firefox (and Mozilla before it) as a web-browser has surpassed that of Internet Explorer. For instance, it has integrated search by default, a wide-array of plugins, and tabbed browsing (which IE did not have prior to IE 7). You can start Firefox by clicking on the Internet icon (the globe with the mouse) in the top panel or by typing firefox at a shell prompt. Thunderbird is already configured to check your CS email when you get your CS account.
Mozilla’s email client, “Thunderbird”, is a powerful, easy-to-use email client quite similar to other graphical clients like Microsoft Outlook. You can start Thunderbird by clicking on the Email icon in the top panel (the envelope) or by typing thunderbird at the shell prompt.
By default your e-mail is stored in IMAP format. This means you can use multiple clients from multiple locations to view your e-mail messages. For example, at home you could use Microsoft Outlook or your own copy of Thunderbird to connect to your CS mail. Instructions on how to set this up are available online on the CSL’s documentation webpage. For more information, please see the “Firefox and Thunderbird FAQs” page in the CSL documentation.
GNU Emacs is a very powerful and free text editor. It has a lot of bells and whistles to make programming easier. Emacs uses a windowing system. You can have several different files (also known as buffers) open at any given time. Keys are “bound” to certain events.
M-x = press x while holding down the Alt key
C-x = press x while holding down the control (Ctrl) key
ESC-x = press and release escape (Esc), then press the x key
For example, pressing C-p will move the cursor up one line (the Up arrow key does this as well). This binding is called “previous-line”. If there is a command that you would like to use and you don’t know the key combination you can type in ESC-x followed by the command name. The Tab key does name completion. When you are unsure of a filename or of a command name, type in the first couple of characters of that command. When you press tab, another menu will appear with all of the possible choices.
A quick example:
1. Start up emacs from the “Programming” menu under the “Applications” menu in the top panel or by typing emacs at the shell prompt. Select the pull down menu “File”, then select “Open...”. This will bring up a prompt at the bottom of the screen where you can specify the filename. For this example, type in “foo” and press return.
START HERE FOR JAVA TUTORIAL:
2. You are now able to edit the file. Go ahead and type in something, your full name for instance. Press return after you have finished.
3. Insert a file by selecting “File” from the top menu, then “Insert File...”. In the lower menu, press the backspace key until the cursor stops moving, then type in “/etc/motd” followed by return.
4. You can move around the file with the cursor keys. You can also use key combinations so you don’t have to take your hands off the keyboard. Hold down Ctrl and press the “p” key. This will move you up one line. C-n will move you down one line, C-f will move you forward one character and C-b will move you back one character.
5. Do a search for the word “the”. To start a search, select “Edit” from the top menu, then select “Search...”. You will see the cursor is at the bottom of the screen now. Type in the word “the” followed by the return key.
6. Highlight an area of text (any area will do). Place your mouse cursor over a different part of the text and click the middle mouse button (scroll wheel in most cases). This pastes the text that was just highlighted. This is how most programs under Unix choose to implement copy-paste. Keep in mind that anytime you highlight a new region of text, it will overwrite whatever was previously copied.
7. To save this file, select the pull down menu “File”, then “Save (current buffer)”.
8. To quit emacs, select “File”, then “Exit Emacs”
9. Use the shell “rm” command to remove the file foo.
For More Information, start the emacs tutorial. Select the “Help” menu, then select “Emacs Tutorial”.
Over the years, Unix programmers and users have put together manuals for the operating system and pieces of software. The man command allows you to read these manuals and get specific information regarding these commands, programs, and operating system material. Simply type man followed by the command in question to bring up the command’s manual page. You can even type man man to get more information on the man command.
Keep in mind that these are manuals and not tutorials. They give very specific, detailed information about functionality, but sometimes they do not teach you how to do specific tasks. Consider consulting another source of information, especially online tutorials.
[bbadger@demo]
(33)$ man ls
NAME
ls - list directory contents
SYNOPSIS
ls
[-CFRacdilqrtu1][-H | -L ][-fgmnopsx][file...]
DESCRIPTION
For each
operand that names a file of a type other than directory or symbolic link to a
directory, ls shall write the name of the file as well
as any requested, associated information. For each operand that
.
.
.
[bbadger@demo]
(34)$ man -k editor (Search man pages for terms)
vim(1) in
std-14 - Vi IMproved, a programmers text editor
ed,red(1) in sys
- text editor
ex(1) in sys -
text editor
sed(1) in sys -
stream editor
vi(1) in sys -
screen-oriented (visual) display editor
.
.
.
The Computer Sciences Department and the Computer Systems Lab are using the internet for most of our documentation. We encourage you to become familiar with the Department, Systems Lab and course web pages early.
·
UW Home Page: http://www.wisc.edu/
·
CS Department Homepage: http://www.cs.wisc.edu/
· Current Semester Class Home Pages: http://www.cs.wisc.edu/classes.html
· Computer Systems Lab Homepage: http://www.cs.wisc.edu/CSDocs/
· Computer Systems Lab Authenticated Web Forms: https://www-auth.cs.wisc.edu/forms/
· Google: http://www.google.com
Often other students working in the student instructional labs are good sources of help. In addition, there may be UNIX Consultants in the labs or in the printer room. Finally, you can visit the Computer Systems Lab in room 2350 CS, or send mail to lab@cs.wisc.edu for additional assistance. For programming, class, and project-related questions, you should ask your TA or professor. The Computer Systems Lab does not provide consulting services. Please make sure that you direct your questions to the appropriate places.
Feel free to ask questions about anything you are not clear on, or topics that were not covered. We will do our best to answer any questions you may have. Remember that nobody learns Unix in a day. This orientation has only scratched the surface of the features and nuts and bolts of Unix. Fret not, gentle newbie, for Unix, like anything worthwhile, takes time to learn and even the most experienced users and hackers still have gaps in their knowledge. Be patient, have fun, and seek out help and answers where you can. Good luck this semester, and thank you for your time.
emacs edit
files using emacs
oofice opens
the Open Office suite
pico edit
files using pico
vim edit files with vim
chmod change
the permissions mode of a file
chown change
the owner and/or group of a file
cp copy a file
mv move
or rename a file
rm remove
a file
lpr send
a file to the default printer
lprm remove
your last print job from the queue
lpq check
the status of print jobs
lpquota show
your current paper usage
acroread opens
pdf files for viewing
cat display one or more files
diff display differences between
pairs of text files
head display the first few lines of a
file
less browse a text file
more display a text file
tail display the end of a file
cd change the
working directory
ls list the
contents of a directory
mkdir make a
directory
pwd display the working
directory pathname
rmdir remove a
directory
date print
the date and time
exit terminate
a process
find find
a file by name or by other information
fs listquota show
your current disk usage
grep search
a file for a specific text string
kill terminate
or send a signal to a process
man display
a reference manual page
passwd create or change
your CSL password
ps display the
status of a process
recover retrieve
a file from last midnight’s backups
ssh connect to a
remote system
w lists
users and system information
firefox open the
Mozilla Firefox web browser
gnome-calculator open
gnome’s calculator
thunderbird open
Mozilla Thunderbird email client
xterm start an
X Window terminal emulator
Open Ctrl-X,
Ctrl-F
Save Ctrl-X,
Ctrl-S
Save As Ctrl-X,
Ctrl-W
Save All Ctrl-X,
S
Revert to File Ctrl-X, Ctrl-V
Revert Buffer Meta-X,
revert-buffer
Close Window/Buffer Ctrl-X, K
Quit Ctrl-X,
Ctrl-C
Close Ctrl-X,
K
Next Window Ctrl-X,
B
Choose Window Ctrl-X, Ctrl-B
Maximize Ctrl-X,
1
Split Horizontal Ctrl-X, 2
Split Vertical Ctrl-X, 3
Switch Focus Between
Windows Ctrl-X, O
Activate Menu Bar Meta-`
FORWARD BACKWARD
Word Meta-F Meta-B
Line Ctrl-A Ctrl-E
Paragraph Meta-{ Meta-}
Page Ctrl-V Meta-V
Document Meta-< Meta->
C Function Meta-Ctrl-A Meta-Control-E
Start Recording Ctrl-X, (
Stop Recording Ctrl-X, )
Play Macro Ctrl-X,
E
Undo Ctrl-_
Begin Selection Ctrl-SPC
Cancel Selection Ctrl-G
Cut Selection Ctrl-W
Cut Line Ctrl-K
Paste Ctrl-Y
Copy Selection to Numbered Clipboard Ctrl-X R S [#]
Paste from Numbered Clipboard Ctrl-X R I [#]
Delete DEL
Fwd Delete Ctrl-D
Delete Word Meta-DEL
Fwd Delete Word Meta-D
Delete Line Ctrl-K
Incremental Search Ctrl-S
Incremental Search Reverse Ctrl-R
Regexp Inc Search Meta-Ctrl-S
Regexp Inc Search Reverse Meta-Ctrl-R
Interactive Search and Replace Meta-%
Goto Line Number Meta-X
goto-line
Previous Matching Bracket Meta-Ctrl-B (or ESC Ctrl-B)
Next Matching Bracket Meta-Ctrl-F (or ESC Ctrl-F)
M-x or Meta-x = press x while holding
down the Alt key C-x
or Ctrl-X = press x while holding down the control (Ctrl) key