[Click here for just this document]

Basic Commands


change directories

Your account is organized like an upside-down tree - or like the root system of a tree.  When you open a new terminal window, you're at ground level (this is called your home directory).  All of your other directories are stored "underground," under your home directory.  Some of them are at a very shallow level -- directly under my home directory I have a directory called "Research," and another one called "Courses."  There are also some mysterious technical directories that I don't mess with, like "Network Trash Folder" and "TheVolumeSettingsFolder."
(How do I know that these various directories are buried directly beneath my home directory?  I open a terminal window to my home directory and list what's in there .)
Now, say I'm interested in looking at some of my coursework. To move into my Courses directory, I type the following command:
cd Courses
This stands for "change directories to Courses."
I have directories under Courses for the various courses I've taken, and each of those might have subdirectories for "TEX" and "MATLAB." From my home directory I can move down several levels all at once, if I know where I'm going:
cd Courses/mat229b/MATLAB

list what's in there

Unlike windows, there's no picture to show you what's inside each directory. But there is a command to tell you what's in there. If you just want to list all the subdirectories and files that live directly in/under your current location, the command is just:
ls
You can list everything that lives in subdirectory, too. Say I'm sitting at my home directory, and I have the same files as I did in the cd example. Then to see all the files in my MATLAB subdirectory of my mat229b subdirectory of my courses directory, I use the command:
ls Courses/mat229b/MATLAB

A few more variations you might want to use:

make a new directory

To make a new, empty directory or "folder" named "mydirname," type the following command:
mkdir mydirname
Of course you'll want to use a different name than "mydirname." Try to use something descriptive and short; capital letters are different than lowercase. The new, empty directory will sit right under wherever you're sitting when you use mkdir (see cd for more info about directory organization).

delete (remove) a file

From the directory where your file lives, use:
rm filename
To delete a whole directory, you can use:
rmdir dirname
but the directory has to be empty. Another option for removing a directory and its contents is:
rm -R dirname
The -R stands for recursive.
Linux has no "undo" command, so be careful!

move or rename a file

In Linux, the command to rename a file is the same as the command to move it. Here, "move" means "move without making a copy."
mv oldfilename newfilename
To move a file into a directory:
mv filename dirname

copy a file or a directory

To make a copy of a file (with a new name) that sits right next to the original file (in the same directory), use:
cp oldfilename newfilename
You'd do this if you were making big changes to a document and wanted to hold on to an old draft "just in case."

Utilities


tar and gzip

The "tar" command works as if you're using tar to stick together a bunch of separate files, so that they become a single tar ball. If you want to zip up files to save space (a very good idea if you're going to e-mail several files to someone) you can tar them together and then zip all in one step. This will result in using less total memory than if you zipped files individually, and it's quicker and there are fewer things that could go wrong.

If you want to tar and zip up an entire directory:

If you want to unzip and untar a tar.gz file:

If you just want to zip and unzip without tarring:


convert

Convert can be used to change image format (e.g. jpg to gif or tif or bmp) and size. The first filename that appears in the command is the old verson, and the second filename is the new version. Here are some examples of the usage:
convert pic.gif pic.jpg

This one changes size using pixels:
convert -geometry 300x200 pic_old.jpg pic_new.jpg

This one changes size using percentage of the original size:
convert -geometry 50%x50% pic_old.jpg pic_new.jpg

You can combine the format change and resize ideas:
convert -geometry 300x200 pic.gif pic.jpg

Other Stuff


the terminal window

The terminal window, also known as the "shell," is how you communicate with the computer. Windows used to have something called the "file manager" program, and the shell does similar tasks (moving files around, renaming them, making new directories, etc.) but it also does a lot more. You can launch a program from the terminal window by typing its name (e.g. matlab), and there are many mini-programs (or utilities) that live in the shell and don't get opened in a new window when they are implemented (e.g. pine, convert, etc.)
If there is an icon on your desk that looks like a little computer monitor, you can click that once to get a new terminal window. It's fine (and very standard) to have many terminal windows open at once. If there's no icon, you can right-click anywhere on the empty desktop, and choose something like "new terminal."

MathSciNet

MathSciNet is probably the first search engine you will want to use whenever you're looking up a math research paper. The web address is www.ams.org/mathscinet. It's very straightfoward to search for a paper by author, title, subject, etc. Many papers (especially those from the mid-1990s forward) are available for download straight to your computer.

Downloading Files from the Internet

To download means to get a copy of a file from the world at large and put it on your personal computer or math account. (The opposite, to upload, means to take a file that belongs to you and post or submit it somewhere in the wider world.) To download, you will usually only need your mouse. There are two slightly different methods for downloading a paper.

The first method: in the results of your search on MathSciNet, you should see "buttons" that say "Linked PDF." Click (once) on this button, and you will be asked whether you want to open the file or save it to disk. Choose to save it, and you will be asked to navigate around, windows-style, to the directory you want to save the file in, and you can give your download the name you want to give it.

The second method: When you see a link to a paper you want, or if there is an image you want to grab, RIGHT-click on it, and from the menu that appears choose the item most like "save link target as..."

send an e-mail attachment (using Pine)

In a terminal window, open your e-mail account (type "pine"), and compose a new message. Between the "To" line and the "Subject" line in the header, there is a line labeled "Attchmnt." Put your cursor there, and then look at the menu of commands that always appears at the bottom of the pine window. There's one for "To Files"-- use it. You'll now be navigating around in your account, looking for the file you want to attach. To get "into" a directory (an item labled "(dir)") to look for your file, put the cursor on it and hit enter. When you find your file, put the cursor on it and hit enter. To attach more than one file, just repeat the process - a whole list of attachments will form. To decide against an attachment, use Ctrl-k to delete it from your e-mail.

receive an e-mail attachment (using Pine)

You will know that you received an e-mail attachment when, after the subject line, there is a line called "Parts/Attachments." To save the attachment, use the ">" command to view a list of the attachments, and then "S" to save each attachment as you highlight it with your cursor. Pine will ask if it's okay to save the attachment in your home directory. If you want it somewhere else, use the "^T" command to search for the right directory.

use the emacs text editor

Linux comes with a variety of text editors, and emacs is a good one. It can do very simple things, like just make a small text file where you can jot notes to yourself; it can also do sophisticated things like recognize when you're writing a computer program and act as the interface to the compiler/debugger/etc.

To run a program in Linux, you just type its name at the command line in the terminal window. Sometimes you have to guess the special abbreviated version of the name, but in the case of emacs, it's easy. Just type:
emacs

If you want to still be able to use the command line (e.g. to launch other programs or search around in your account while you use emacs), instead type:
emacs &

If you have a document that you want to open with emacs, you could use:
emacs filename &