User Tools

Site Tools


This is an old revision of the document!

Linux Tutorial

This tutorial is intended to be a practical and brisk tutorial of many of the basics of using Linux for people who have never used it before. As much as possible, discussion of theory has been omitted. Setting up a website, compiling LaTeX, firing up MatLAB, and other typical tasks math grads would want from the department computers are covered quickly.

By using SSH and the related tools mentioned here, you can do things such as modify your webpage, retrieve/send files, turn LaTeX files into PDFs, and all other tasks you can do on the department computers from where ever you have internet access!

How this tutorial is organized

Only sections 1 and 2 are strictly necessary. Sections 3 and 4 will give you access to some useful features.
  1. Connecting using SSH has links to the software and tells you how to connect to the department Linux computers.
  2. After you're connected: Some basics gives a fairly minimal list of commands that will help you feel comfortable using text-based Linux.
  3. Transferring files has links to software that makes transferring files back and forth between your computers and the Linux servers easy.
  4. Using X Windows explains how to set up your computer to use graphical programs like Maple, MatLAB, and Mathematica.
  5. After you're connected: More advanced stuff describes some minor conveniences.
  6. Additional resources has links to other stuff where you can learn more!

1. Connecting using SSH

Just as you need a web browser (like Firefox) to connect to a web server (like, you need an SSH client to connect to an SSH server. To connect, you need your username (in the examples we use egalois), your password, and the name of the SSH server you wish to connect to (such as or

For Windows, download PuTTY, a free SSH client. On the opening window, you only type your username the SSH server name. You enter the password after clicking to connect. (NOTE: As of Spring 2007, several PuTTY users have reported trouble in trying to SSH to After entering your username and password, PuTTY disappears. Try logging in to a specific server such as instead of

For Mac, an SSH client is provided. Start the Mac program "Terminal" and type ssh, then press Enter. Then the Mac asks you for your password.

2. After you're connected: Some basics

Once you successfully connect, you are given a prompt where you can type commands. This section is devoted to introducing everyday commands. In what follows, when in doubt, Linux is typically case-sensitive!

The folder system and your home directory

Like on your own computer, Linux has a folder (sometimes called a directory) structure. Any folder can contain any number of files. A folder can also have any number of folders called subfolders (and these folders can in turn have the same kind of content). When you log in, you are brought to your what is called your "home directory". Your home directory is a subfolder of some other folder (called its parent directory).

Some special directories have special symbols. The current directory is given the symbol ., the parent directory of the current directory is given the symbol .., and your home directory is given the tilde symbol ~.

Navigating directories

To see what directory you're in at a given moment, you can type pwd and press Enter. This tells you your "present working directory". You can see a listing of the contents in the present directory by typing the command ls and pressing Enter. (You might have colors set up automatically, in which case folders in the listing are shown in blue.)

To move to a different directory, use the command cd with an additional parameter. For example, to go to the parent directory of the current directory, type cd .. and press Enter. You can try this again and again to get all the way to the top-level directory, the unique directory with no parent. All along the way, you can check where you are with the command pwd.

To get back to your home directory, use cd ~ or the shortcut cd.

Creating, deleting, moving, and renaming directories

In your home directory, suppose you want to create a subdirectory (to store, for example, the scratch work of the rest of this tutorial). If you wish to make a directory called learnlinux in the current directory, type mkdir learnlinux. Now you can use cd learnlinux to get into it and cd .. to get back.

To delete the directory learnlinux, type rmdir learnlinux. As a safety feature, rmdir learnlinux only works if the folder you wish to delete has nothing in it.

Now try creating two folders, one called test1 and one called test2. You can move test1 into test2 by typing mv test1 test2. Now, test1 is a subfolder of test2. You can rename test2 to test3 by typing mv test2 test3.

Creating, deleting, moving, and renaming files

To create a blank file called myfile.txt in the current directory, type touch myfile.txt. Similarly, to create a blank text file called mytheorem.tex, you'd type touch mytheorem.tex. You can move this file into the folder test3 by typing mv myfile.txt test3.

If you've followed along exactly, the folder test3 should have in it one folder and one file. Change into test3. To rename the text file, type mv myfile.txt renamed-file.txt. To delete the file that is now called renamed-file.txt, type rm renamed-file.txt.

Editing text files directly

You have two basic ways of modify files. One option is to use the tools mentioned in the section "Transferring Files". This is good for when you want to make large changes and prefer the interface of your own computer, or you know that you won't have access to the internet (and thus SSH) for a while. You copy over the files you plan to modify, do the changes on your own computer, and then replace the files on the SSH server with your updated ones.

Your other basic way to modify files is directly using a text-based text editor. This makes sense for quick and minor edits. It also may help you keep your files in order, because you only have one version of a file floating around.

The three most-popular text editors on Linux are called "pico", "vi", and "emacs". You just have to pick one and stick with it. Here, we mention the basics of pico, because it is by far the easiest of the three. Later, you may want to try vi and/or emacs because they are much more powerful (though much more difficult to use). You may find that you like "gedit", the graphical text-editor. This is nice to use in the department, and there is a way to use it via SSH (see the section on X Windows), but it may run slowly over a slow Internet connection, and for this reason alone, it may be useful to learn how to open, edit, and save a file in pico.

To edit a file in the present directory called myfile.txt with pico, type pico myfile.txt. Even if no file by the name myfile.txt exists in the current directory, this will work. In other words, you do not have to first run touch myfile.txt, though you can if you want.

The text editor pico starts and shows you the contents of the file, with some cheat info at the bottom. You can use the arrow keys to move around the cursor and start typing. In pico, saving is called "WriteOut", so to save, the cheat tells us to hit Control and "O". To quit, use Control and "X".

You can see the contents of a file without the hassle of running pico. To see all of the text in myfile.txt run cat myfile.txt. You might see too much stuff run by because there are too many lines in the file. If the scroll bar doesn't work (these things are sometimes buggy), you can run more myfile.txt, which will show you a page at a time (scroll along by hitting the space bar).

Using LaTeX

Suppose you have a valid LaTeX file called mytheorem.tex in the present working directory. To make a PDF, you can run pdflatex mytheorem.tex. If you want to make a PostScript file instead, run latex mytheorem.tex to make a DVI file and then run dvips mytheorem.dvi to convert the DVI into a PS file.

If your LaTeX file is invalid, you will not reach the normal prompt and instead be given a question mark. You can type a capital X to quit. After fixing your file using pico, emacs, vi, or re-uploading your file using the method described in "Transferring Files", you can try to recompile.

A word on file permissions

Type ls -l to see all the files in the present directory along with their permissions. To fill in later...

Setting up a webpage

To setup a website with the main address, create a subfolder in your home directory called public_html (note, that is an underscore character). In the folder public_html, you can create a file called index.html and edit it using pico or any other text editor. For the content, follow along in the HTML/Webpage tutorial.

Note: You will need to make sure that public_html and all its subdirectories are world-executable and all files are world-readable (or else visitors to your website will see a "403 Forbidden" error). See the previous section on file permissions.

3. Transferring files

If you wish to transfer files between your computer and the math department machines, you could always attach files and send them to your personal e-mail address. This will clog up your e-mail address. The better alternative is to use a nice mouse-based tool.

For Windows, use WinSCP. For Macintosh, use Fugu.

4. Using X Windows

Up until now, the tutorial has focused on running text-based programs. However, one can use all of the graphical programs via X Windows. Some of the programs you can use once you set up X Windows include: MatLAB, Maple, Mathematica, gedit, and a nicer version of the Emacs text editor.

Using Cygwin/X on Windows

You will need to download and install Cygwin. After downloading and installing, you have to install Cygwin/X. According to, Cygwin/X is installed via Cygwin's setup.exe : After running setp.exe, select the "xinit" package from the "X11" category.

To start Cygwin/X, run Cygwin and run the command startx.

Using X Windows on the Mac

Install X11 from the Apple Mac installation CD. Start up your X Windows software by running the application X11 from the Dock.

Using X Windows

In your SSH Client (whether PuTTY or something else), you must enable tunneling of X connections. On the Mac, instead of the normal ssh command, you need to run ssh -CY The use of the "Y" specifies that you wish to tunnel X11 connections.

Once you've started your X Windows software and connected via SSH, you can run xclock to test your connection. A new window will appear with a clock that is not text-based. If this works, you can close xclock and try xmaple, matlab, emacs, gedit, evince, and so on.

Using the ampersand to retain the command line

When you run something like xclock, you will lose the ability to use the SSH window until you close xclock. You can start a new SSH connection, but this is annoying. If you have an X-based program that you will be running for a while, you can use the ampersand to keep your SSH window working. For example, if you knew you want to keep the clock running for a while, you can type xclock &.

5. After you're connected: More advanced stuff

This section is filled with several odds and ends. Nothing beyond this point in the tutorial is absolutely necessary, but each thing here has been suggested by one or more math graduate student. Once you are comfortable with the other stuff, you can come back to this section to learn one tidbit at a time that will further speed up your Linux use.

Tab completion

To fill in later...

Checking mail

Use pine, which is easy to use and based on the text editor pico. The main disadvantage in pine is the poor searching features. For this, mutt is a better e-mail program, but harder to use. Please ensure that your WebMail is not up when running either of these programs.

Setting up e-mail forwarding

To fill in later...

Downloading web content

Use wget. To fill in later...

Command history

In BASH, you can use Ctrl-R. In general, you can also type history.

Using SCP and SFTP

The commands scp and sftp are text-based tools you can use to transfer files. They are an alternative to using WinSCP or Fugu.

6. Additional resources

Getting more help

In the section on file permissions, we introduced ls -l, which is just one of many ways to use the ls command. To view a complete manual of ls, run man ls. Similarly, for a manual of mv, run man mv.

Suppose you are looking for a command related to calendars, but you can't remember the exact name of what you're looking for. You can search on all of the command manual headline texts using "apropos". Run apropos calendar. Among this list, you see that "cal" displays calendars. Then, you can run man cal to get full details on how to run cal.

Links to other tutorials

linux.1455642923.txt.gz · Last modified: 2016/02/16 09:15 by jasnyder