Most astronomers using PC computers use the Linux operating
system for data reduction and analysis.
While not (quite) as user friendly as Windows, Linux offers the user
more "hands on" control of what the computer is doing, and much of
the software that astronomers need runs under Linux.
We will use Linux computers for A451. This guide is designed
to help you become familiar with the Linux operating system and make the
transition from Windows to Linux. Many
of the basic functions of Windows (word processing, spreadsheets, browsers,
etc.) are also available under Linux, and many of them operate in the same
basic way.
Technically, Linux
refers to the operating system and/or its philosophy. The user interface in Linux is called a shell
because it separates you from the inner guts of the system. Mostly, the shell just runs the programs you
tell it to run. Almost all the commands
you will use are just regular programs -- the shell doesn't
care if it's a program you wrote or one that came with the system.
We carry out tasks on Linux computers using two different
types of interfaces. These are the text based interface and the graphical interface. Each has advantages and disadvantages. You should choose the interface most suitable
to the job you need to do. The command
line interface is more suited to complex tasks where presenting the work
visually is impractical. On the other
hand, the graphical interface works well for problems that are strongly visual or can be presented in a menu format. In this class, you will need to be able to
work with both interfaces.
We will use the Gnome graphical interface. It is one of several choices available, but
all are rather similar and if you are familiar with one you will be able to
find your way around the others.
Logging in and out
To login in, type: your username
Enter the password: (nothing will appear as you type this)
On a Linux workstation, you will need to start the window
system after you log in. The window
system has two modes: a high resolution mode and a low
resolution mode. Most of the time you
will want the high resolution mode, so you should type
startx
In the top left corner of the screen
you will find icons for your home directory and the trashcan. Double click on the home directory icon to see
the contents of your home directory or other directories in graphical format. Files that you remove using the graphical
interface tool will appear in the trashcan. Remember
that files you remove while using the shell are
gone forever and will not appear in the trashcan – you should be very
careful about deleting files.

In the bottom left corner, you will find buttons for
accessing applications. The buttons are:
When you are ready to log out, click on the red hat, then
choose “Log Out”. A window will pop up to confirm that you want
to log out. Choose “OK”. You will be returned
to the terminal. Type
logout
to log out from the terminal. The login prompt will appear again. Always
remember to log out completely when you are finished!
Command Line
Window Applications
In the graphical interface, you can run a program by
pressing ALT+F2. A dialog box will
appear, and you may type the command you would like to run. You may also use a shell terminal such as XGTerm or XTerm. These applications will provide you with a
terminal inside a window. The button at
the bottom left corner of the screen allows you to open XGTerm,
or you can type “xterm” or “xgterm”
into the run dialog. You can also run XTerm from the program menu.
In XGTerm, the font size should be
set to “huge” by default. If you prefer
a different size, you can change it by pressing and holding control and
clicking the middle mouse button. When you do this, a
menu will appear offering you a choice of sizes.
You can use the XTerm and XGTerm in just the way you would if you weren’t
using the windowing system, and you can also run graphical applications from an
XTerm or XGTerm window. When you run a graphical application this way,
it’s usually a good idea to run the program “in the
background” so that you can continue to use the terminal window. To run a program in the
background, type an ampersand (&) after the command. For example,
xterm &
Directories
Linux "folders" are called
directories. The top-level, root directory is called /.
Your home directory is /home/username. From anywhere you can get back there by
typing simply
cd
The short-hand name for the directory you happen to be in at
any time is called "." and
the directory in which the current directory resides is called "..". Typing "cd .." will
move you to the next higher level directory.
Several useful commands for directories are listed
below.
|
Command |
Function |
Examples |
|
cd |
Change directory |
cd,
cd ..,
cd /home/catyp |
|
pwd |
Print working directory |
pwd |
|
mkdir |
Make a new subdirectory |
mkdir
newdirectory |
|
rmdir |
Remove a directory |
rmdir emptydirectory |
|
ls |
List files in a directory |
ls, ls –l |
Files:
Files reside in directories.
Use the ls
command (or ls -l for more information) to see all
the files in a directory. Useful
commands for manipulating files include:
|
Command |
Function |
Examples |
|
ls |
List files |
ls,
ls -l, ls dirname |
|
mv |
Rename (move) a file |
mv
oldname newname |
|
cp |
Copy a file |
cp oldname newname cp oldname dirname/ |
|
rm |
Delete (remove) a file |
rm filename rm file1 file2 file3 rm -r dirname |
|
cat |
Output the contents of a file to the screen |
cat filename |
|
file |
Identify the type of file |
file filename |
Editing Files
You will frequently need to edit text files when you are
working in Linux. There are a number of
editors to choose from. You can open the editor simply by typing its
name on the command prompt.
When working in the windowing system, you can use GEdit, a simple graphical editor. To use GEdit, type
gedit &
at the command line or click the
notepad icon at the bottom left corner of the screen. A window will appear with an interface similar
to Windows Notepad. Open and save your
work using the buttons above the command line. You can also type
gedit filename &
to open a file in GEdit.
Many other editors are available, including EMACS, Pico, and
vi, that are sometimes useful in other applications. Documentation for these editors is available
in room 311.
Printing
You can send a plain text file, a postscript format file, or
a PDF file to the printer by typing
lpr filename
To print other types of files, you will need to view them with the appropriate
application and print them from there.
Shortcuts
Cutting and Pasting:
In the windowing system and on the text interface, it is
possible to cut and paste text. First, select
the text with the mouse. Once you select
the text, it will automatically be copied to the
clipboard. You can now paste the text
elsewhere by clicking the middle mouse button. A duplicate of the text will now appear at the
text cursor position.
Some Linux applications also have a Windows style clipboard
available. To copy to this clipboard,
press CTRL+C. Then, select your paste
location and press CTRL+V.
Wildcards:
If you need to refer to a list of multiple files, you can
use wildcards. These are characters that
have a special meaning to the shell. The
two most important wildcards are the asterisk (*) and question mark (?). An asterisk will match any string of zero or
more characters in a file name, while the question mark will match any single
character in a file name. For example:
|
The
pattern… |
Will
match… |
But not… |
|
f* |
f1, f2, f3, fruit.txt |
somefile.txt, 1f |
|
*.txt |
somefile.txt, pasta.txt |
pasta.txt.bak, somefile |
|
f?.txt |
f1.txt, f2.txt, fz.txt |
f1, f1.txt.bak, f.txt |
|
*.* |
fruit.txt, pasta.txt, pasta.txt.bak |
f1, somefile |
Linux
"help"
If you don’t know how to do something, Linux has a built-in help system that you can use. The most important tools are listed below.
|
man command |
Display the manual page for a command. |
|
apropos keyword |
Print a list of commands apropos to a keyword with a
one-line explanation for each command. |
|
whatis command |
Print the one-line explanation for a command. |