- The Galois Group
- The Graduate Program
- Other Advice
- Student-run Seminars
- Technical Tutorials
- About Davis
- External Links
This is an old revision of the document!
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!
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 math.ucdavis.edu. After entering your username and password, PuTTY disappears. Try logging in to a specific server such as round.math.ucdavis.edu instead of math.ucdavis.edu.)
For Mac, an SSH client is provided. Start the Mac program "Terminal" and type ssh firstname.lastname@example.org, then press Enter. Then the Mac asks you for your password.
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 ~.
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.
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.
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.
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).
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 mytheorem.ps 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.
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.
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.
You will need to download and install Cygwin. After downloading and installing, you have to install Cygwin/X. According to http://x.cygwin.com, 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.
Install X11 from the Apple Mac installation CD. Start up your X Windows software by running the application X11 from the Dock.
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 email@example.com. 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.
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 &.
To fill in later...
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.
To fill in later...
Use wget. To fill in later...
In BASH, you can use Ctrl-R. In general, you can also type history.
The commands scp and sftp are text-based tools you can use to transfer files. They are an alternative to using WinSCP or Fugu.
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.