Sunday, July 01, 2007

Supercomputing Course: Introduction to Unix, Part II

Typically on a Unix or Linux machine, you have both a GUI (graphical user interface) and a command line mode. When you remotely log in to a machine, such as a supercomputer, from the comfort of your home or office, you will open a terminal session with that machine. The way to do it is using ssh (secure shell authentication, pronounced by spelling out the three letters). ssh sends your password and all your data encrypted, whereas telnet does not. Back in the day we used to use telnet but it is just not safe anymore, so instead you connect in the following manner: ssh userid@machinename . So if my userid is rebecca and my machine is called fred.fictitious.com, then I would do ssh rebecca@fred.fictitious.com . If you've never logged in to that machine from the one you're on right now, it will ask you to confirm the validity of it, which you confirm by typing yes and pressing enter. Then you'll be asked for your password, which you will of course type in correctly, and then you're logged in. (To log out, just type exit or logout and then press enter.)

If anyone reading this is ancient enough to have used DOS, *nix is a lot like that, with some caveats. First of all, the file name separator is the forward slash (/) rather than the backward slash (\). Secondly, *nix is case-sensitive, meaning that myfile, myFile, and MyFiLe are three different file names.

The man command is one of the most useful commands ever. Type in man man to find out why. (You use man to access the manual entry for any command. So doing man ls will tell you what ls does, along with give you an idea of all the different options that can be used with ls, e.g. ls -l, ls -t, etc.)

Another important concept has to do with the | character, which is called a "pipe." (On my keyboard, | is made by pressing shift and the key just above enter that makes the backslash.) Basically the pipe takes any command that you do before it, and makes that command be the input for the command that follows. A common use of the pipe is when you want to list the contents of your directory, but you want to see it one screen at a time. If you have a lot of files, they will all just scroll past really quickly and you won't get a chance to look at the whole list if you don't use this command. So you do ls | more . What that does is the following: ls lists the directory contents, as we already know. The more command is usually used with files, for example more myfile will display the file myfile in screen-sized chunks that you can scroll through by pressing the spacebar or the up and down keys. Pipe takes the output of ls and turns it into the input for more, so that you then have a listing of your directory in screen-sized chunks that you can scroll through. Make sense?

I will leave you with some links to some good tutorials.
Unix Tutorial for Beginners
DOS to UNIX Translation
UNIX Command Summary

Up next: a history of editors leading to the vi editor.

8 comments:

lost clown said...

Wow. I am never going into computer science. Good thing there are other mathy things I can do.

I am amazed by what you do.

Anonymous said...

I am totally going to be able to super-compute by the end of this course! I can just tell!

(Actually, have been contemplating getting trained as an auto-mechanic, based on the amount of interest I've had in engines, last several days. That's just creepy...)

Doctor Pion said...

Very nice. The way you talk about "man man" makes me wonder if you once saw a copy of a tutorial I wrote ages ago. e-me if you think that might be the case.

I'm looking forward to your comments about editors, because I thought long and hard about trying to make a list of every editor I once knew how to use when you tagged me. Will have to do that, and will defend your choice of vi over emacs to the last beer.

Rebecca said...

Lost clown, developing computing skills will be helpful for a career in math, particularly in applied math or any of the more lucrative areas of the field. :) You don't have to become a computer scientist, but knowing how to program and how to operate a Linux box is very handy.

Rach, you are definitely going to be a supercomputing wunderkind by the end of this course. You should totally become an auto mechanic. I would drive thousands of miles just to take my car to you!

Doctor Pion, I'm glad that you are a fellow vi aficionado.

lost clown said...

I was thinking about doing applied mathematics in conjunction with physics (there's a nice PhD program at Durham U in England that combines these). So I guess a question I have is: should I take Mathematica or C++ (I'm only required to take one for my degree). What do you think, oh computer guru you? ;)

Rebecca said...

Lost clown, I would vote for C++. It's going to be very useful in the applied math/physics field, because most people in the field these days program in either C, C++, or FORTRAN. It's also more complicated than Mathematica, and taking a class in it would force you to learn it while at the same time give you a chance to talk to somebody when you have questions.

Plus, I imagine that you will probably learn more than simply the language: probably some stuff about algorithm design, good programming practices, etc.

I can't stress enough how useful having the ability to write computer programs is. While it's not particularly glamorous or flashy, programming pays the bills and it pays them quite well. Even though I am in a math department at a national laboratory, the thing that wins us the grants is promising a software product. Uncle Sam wants software in addition to papers.

You don't have to become a code monkey, but you do have to be able to put your ideas into implementation.

Doctor Pion said...

Definitely C++, although C++ (being built on C) is not as fully structured as Java. Java is a much better first language, and either one will make learning Maple or Mathematica etc fairly easy. However, some theory areas only require symbolic math tools, not programming skills, so talk to a mentor or two about this choice. Ask them what they use in research. The answer might be Fortran 99+.

The important thing is algorithms, so you learn how Mathematica is doing X for you. Check around, since that might be in a programming 2 class or require taking a basic num.anal. methods class that applies your programming skill.

lost clown said...

Thank you. The physics dept requires C++ so I was leaning more towards that. Any math prof I talk to says Mathematica, but I think they're biased. I am becoming more computer literate as my friend taught me how to use terminal in OSX and I've been steadly learning how to do more and more with it.