Astronomy 421
We’ll be using an operating system called “Linux” on the computers used for this course. Linux is a form of UNIX, a multi-user multi-tasking operating system. For the purposes of this class, we won’t delve deeply into the details of the operating system, but you should feel free to take the opportunity to acquire a deeper working knowledge of Linux as the quarter progresses.
Executive Summary for Computer Pros
(Don’t worry if this does not make a lot of sense to you… it’s meant to provide instant gratification to system pros.)
The machines in Room B356 of PAB (and the A-wing of the PAB building) are Intel boxes running Red Hat Linux. There are about a dozen machines. All home directories are hosted on a common disk farm, so you always land in the same home directory, but running on the processor you logged on to. Note that you can access these machines and their contents ONLY via ssh and scp, and only from other machines on the astro subnet, not from the outside world.
If the preceding was intelligible to you, then kindly pitch in and help bring your classmates up to speed with the very basics of Linux.
The first step in using the computers at our disposal is to log in. If you pre-registered for the class, an account has most likely already been established for you. The username on the account is (in general) the same as the name you use to receive email at u.washington.edu.
The first step in today’s exercise is to log in and then change your password.
Log into one of the consoles. Type your username and then a carriage return, followed by your temporary password. You will be dropped into the “KDE” windows manager, under the Linux operating system.
Along the bottom tool bar you’ll find a number of icons. Clicking on the one with the shell symbol will bring up a terminal window.
Computer security is an issue of ever-increasing importance. The UW Astronomy Department is under a constant barrage of attacks from people who presumably think we have the truth about alien abductions, etc. This is more than a nuisance. Our ability to conduct our teaching and research programs depends upon reliable and secure connections between our system and computers across the globe. You are expected to help us keep our shared systems stable and secure.
Individuals who compromise system integrity will have their computer accounts deleted.
Linux passwords should be at least 8 characters in length, and it’s essential that you not use any words that appear in a dictionary, or simple substitutions of one or two letters in a word. An ideal password is a combination of characters and punctuation symbols, with some upper case letters thrown in for good measure. That said, pick something you can remember!
Use the command passwd to change your password. It will prompt you for the old and new passwords, and will not echo what you type. You’ll be asked to confirm the new password a second time, to prevent inadvertent typos.
Figure out how to move, resize, iconize, and kill the shell window you opened up. It’s pretty intuitive. Move the window around by dragging the top bar. Try double-left-clicking on the top blue bar. What happens? Use the mouse to drag the lower corners of the window to resize it. Click on the "Red Hat" and see the menu that appears. Customize it if you'd like.
You can open up a second window from the current terminal by typing
xterm &
at the prompt. It should open up a new window that will also accept commands. You can kill the window by typing exit.
At the bottom of the screen is a set of gray boxes. You should imagine that there are 4 distinct virtual consoles, and you can select between them by clicking on the relevant gray box. This increases the effective screen size you have available, although only one is accessible at any given time.
You can log out by right-clicking on the background.
The next task is to customize the way the mouse interacts with the active windows on your desktop. First, open up two active shell windows on the desktop. For the programs we’ll be using, we want the position of the mouse to determine which window is active. Test this by hitting some carriage returns with the mouse over one window, then position it over the second one and hit a few more carriage returns. The active window should be determined by the mouse location, without your having to click to activate the window.
If your window manager behaves differently (and even if it works properly, just for practice…), left click on the Red Hat symbol at the bottom left of the screen. Hold down the mouse button, and select
Preferences
Look and Feel
Window Behavior
The directory architecture used by Linux is a hierarchical tree structure, much like what you’re accustomed to in a Windows or MAC environment. When you first log onto a Linux system, you land in your “home” directory. You can navigate through the directory structure by “changing directories”, using the command cd. (Note that Linux is case sensitive, i.e. CD won’t work, it has to be lower case.) To indicate the present working directory, you can type pwd. To help you keep straight on where you are, the prompt shows the working directory.
The Linux directory structure is a tree architecture, in which a number of directories can reside below the directory you’re in, but there is at most one directory “above” the present working directory.
The top of the tree is the “root” directory, designated with a slash sign. Directory names build on the root directory, with a slash designating a new branch in the directory structure. The direction of the slash sign is the opposite of what is used in Windows/DOS systems. For example, your personal directory for this class is located under /homes/yourusrname . If you were to simply type cd, you would go directly to this directory. When you sign on, you are in that directory. Now type in ls, you would see any files or sub-directories. [See instructions below for more moving about directories.] Directories can have relative path names, which are interpreted as starting from the present working directory.
You can tell where you are in the directory structure by typing
pwd
which is an abbreviation for “print working directory”.
The cd command moves you around in the directory structure, and takes an argument that is the desired destination directory. The argument can be either a relative or an absolute pathname. If you are already in your directory and want to move into the directory called “ENV” (for example), simply type
cd ENV
and the system would move your current working directory to /homes/yourusrname/ENV. If I wanted to move to this directory from somewhere other than the directory right above it (also called the parent directory) I could use an absolute pathname by typing
cd /homes/yourusrname/ENV
[Note: the last "/" is usually optional when moving between directories.] Linux provides some useful shortcuts for navigating directories. A single dot, “.”, always refers to the current directory. Double dots, “..” refer to the directory just above the one you are in. To move up two levels in the directory structure, you would type
cd ../..
You can always get back to your home directory by typing cd with no arguments.
The command ls is used to list the contents of a directory. Under Linux, files, directories and even devices are treated as philosophically equal, so a directory could contain any one of these types of items. The ls command can be invoked with a variety of options, which modify its action. Under Linux, command options are preceded by a hyphen. A few of the more useful forms of ls include:
ls –l generates a full listing, including dates, sizes, etc.
ls –p distinguishes between directories and regular files
ls –a lists all files, including those that begin with a “.”, which are otherwise hidden files.
ls –t lists contents by date of their creation, latest first.
You can combine them, so for example
ls –apt
is perfectly valid.
Files in the current working directory can be referred to simply by their filename. In general, however, the name of a file includes its full pathname, such as
/homes/yourusrname/idl/myidlprogram.pro
where the last element, myidlprogram.pro, is the file name.
Linux allows you to select a subset of the objects of interest, using wildcards and range restrictions. For example, to obtain a listing of all files that end in “.pro”, you would type
ls *.pro
The command cp is used to copy files. The syntax of this command conforms to the (almost) general UNIX standard of
command source destination,
so for example I could make a backup copy of a file called foo.txt by typing
cp foo.txt foo.bak
You can create a new directory just below the current working directory by using the command mkdir name, where name is the name of the directory you want to create. No spaces in directory names! Actually, let this be stated more strongly: do not use spaces in directory or file names under Linux. It is probably a good idea, now that you are in your directory within /homes/yourusrname/ to set up some subdirectories.
Directories are deleted with the rmdir command.
The tasks less file, more file, and cat file print the contents of a simple text file to the screen. The less task allows you to page through the file, using the spacebar to move one screenful and the Enter key to move down one line at a time. The task more operates similarly to "less." The cat task scrolls the entire thing past with no pauses.
One of the most useful aspects of Linux is the ability to redirect streams of information, input and output to and from files and processes. The symbols >, < and >> are used to accomplish this. For example, to send the listing of all the files in the current directory into a file called foo, one would type
ls –a > foo
This has the feature that if a file called foo existed already, it would be overwritten with the new information. You could instead append the directory listing to a pre-existing file called foo by using
ls –a >> foo
The on-line documentation for Linux can be accessed through “man pages”, short for manual. If you remember the relevant work, you can type
man –k keyword
Which will produce a listing of all the man pages that pertain to that topic. You can then type
man foo
to get specific information on the topic foo.
Red Hat Linux comes with a number of editors: emacs, gedit, vi, plus a suite of office-type formatting editors. I prefer gedit as it seems to be the simplest of them all. Click on the Red Hat, and accessories. Right-clicking on the gray bar at the bottom of the screen brings up a menu that will let you dictate what icons appear on your screen.