UNIX - a quick tutorial

Christopher Bailey

When you're fooling about with the SGI machines, you can work in two basic enviroments: the GUI or Desktop enviroment, and the UNIX enviroment. Before you can accomplish anything on the computer, you should understand how to get around in these two enviroments. They complement each other, and are both ultimately necessary.

I'll begin by providing a brief description of each:

UNIX: In the old days, the only way to use/communicate with your machine was through a screen that contained no friendly windows, icons, pictures, or any other graphical or ornamental aids we have become used to in today's personal computers. Back then, you just used a screen that displayed only text. This kind of interaction with a machine was, and still is, scary at first to many people, but you will soon discover that it is more intuitive than you might think, and for some tasks, a lot faster than navigating a GUI.

GUI: The GUI does a lot of things UNIX does, but in a very user-friendly, picture-oriented way that is highly intuitive to the user. It stands for Graphic User Interface. If you are doing most types of basic operations, using the GUI to do what you want to do is probably going to be quicker than doing the same things with UNIX, typed-in, commands. However, for very repetitive or somewhat complex operations, UNIX can be faster. As you use the computer more and more, you will probably find yourself getting sick of clicking through endless window/menu hierarchies, to accomplish what are often simple tasks.

The GUI is what you're "in" when you first log in. Most of you will be familiar with the look of it from working on Macintosh or Windows machines. The screen is usually filled with icons or menus which you can click on to activate. One menu item you can activate is UNIX shell. You should learn how to find this guy: first click on Desktop in the upper left corner of the screen, a sub-menu pops up, and you move the mouse to Open UNIX shell, then release the clicker. This will cause a UNIX shell to appear on the screen. A UNIX shell is a window on the screen, in which you can type text commands to UNIX--in other words it's like having one of those old-fashioned monitors right "virtually" there for your use. And, what's more, you can have as many of these windows on-screen as you like.

Most people use a combination of GUI and UNIX shells to do their work/play.

But UNIX is not just an interaction system, it also defines the way data (meaning sounds, programs, scores, papers, email, etc.; i.e. anything you use.) is stored and accessed by both GUI processes, and text-typed UNIX processes. All data is organized in a (for the most part, fairly intuitive) way, in what is called



the FILESYSTEM:

All computers these days have a hierarchical filesystem. A file is basically a bunch of numbers, stored in memory or on disk: what these numbers mean depends on the type of file. Some files contain data, like sound (called sound-files) or text, or some other kind of data; other files are called applications, these are computer programs like Mix, RT, Ceres, etc. that allow you to do stuff. Every file has a filename. (Filenames can be, basically, numbers or letters, no spaces, of 200 or less characters.)

The files are stored in directories (also called "folders" on the Macintosh, or other window-based machines). These directories are often nested several times over: there are directories within directories within directories. For example, the "high"-est directory (meaning the one directory that includes all the others) on any of our machines is called root; in root there is a directory, among many others, called sndgr, a directory which happens to contain everything on growl's (growl is the name of the SGI machine in Room 324 Prentis) sound disk, sndgr is the "name" you use to refer to growl's sound disk (likewise, howl, in 803B Dodge, has a sound disk labeled sndh, and similarly for the other machines); in sndgr, there is a sub-directory called chris, which contains all of my (Chris's) soundfiles; in chris, there might be a sub-directory, which I can easily make (indeed, anyone can make a sub-directory in one of their own directories easily, thus enabling us all to organize our stuff carefully and conscientiously) called, let's say, 5thmvmt, which contains the sounds used in the 5th movement of a piece I'm composing.

Any directory is reffered to in UNIX (by "in UNIX" I mean "when you're typing text commands in a UNIX shell", as opposed to using the GUI "point- and-click" system of interaction) by a pathname, which tells the computer how to "get" to that directory from where it is. These pathnames consist of /'s and directory names. An example will illustrate most rapidly how pathnames work:

/sndgr/chris/5thmvmnt

The initial slash means: start at the root directory; the sndgr sends you to the sndgr directory, then a slash separates that from the second name, chris, which sends you to the chris directory, inside sndgr; then another slash separates that name from the next, again, which is 5thmvmt, which sends you to the 5thmvmt directory, inside chris.

It's important to become familiar, and to have a kind of mental construct/idea in your head about how the filesystem, generally speaking, is organized at the CMC. This will help you to know where to put or find different files. (A rudimentary map of our filesystem is shown below.) Nobody would want to remember all of the files that make up a system, but you should know the function of the basic divisions of our filesystem:

Users: This big directory contains all of the User directories; that is, everyone who has an account and works here has their own private directory. You can put anything here (in your particular sub-directory of the Users directory, known as your "home" directory, and named after your login name (my login name is chris, so my home directory is called. . . chris) like text, scripts, etc.; but not sound, sound goes in the

snd disks: Because files that store sound take up huge amounts of memory space (44,000 bytes (44K) per second of sound!!), sound files are stored on a separate bunch of disks called sound disks. These disks are labeled according to the computer they are attached to (like sndgr attached to growl, etc., see above), but you can access any sound disk from any machine in the studio.

IMPORTANT: Whenever you do anything with sounds, we ask that you save them to a sound disk; saving sound-files to your home directory will fill up disks extremely rapidly and cause machines to function slowly, lock up, and/or "crash."

LocalApps: This directory contains most of the programs, applications, etc. ("Apps") that you will need to to run.

musr/cmix: In this directory are all of the programs, their source codes, and some examples (which you can copy and use as templates for your own work), of the CMIX sound processing package, which we use heavily at the CMC for all kinds of music/sonic activity. In other words, this directory is kind of like a big, specialized LocalApps, specialized for CMIX apps.

The Wondrous SGI Browser: We recommend you spend a few moments wandering through the directory hierarchy here at the CMC. One way to do this is to use the SGIs' GUI browser. You can get to this by clicking on Desktop (as described above for bringing up a UNIX shell), and selecting "Home Directory." A window will pop up displaying the contents of your home directory as icons. Now, click on the bar directly above the first "/" in the directory name. Now, you are looking at the contents of the "root" directory. At this point, drag one of the folders below, into the "folder" icon in the upper-left corner of the window. This will open that folder. (Or you could double-click on the new folder, opening a new window.) (Or, you could type the name of a new directory in the directory-name area.) Anyway, after fooling around a bit, you'll get the idea. Now, use these methods to explore the system---opening folders, and folders within folders---especially those mentioned above.





tips on GUI use:

For the most part, using the GUI is an intuitive, point-and-click process, which probably all of us are familiar with if we have used computers at all. Here are some tips I might point out, though:

1. On SGIs: A window needn't be "on top" or "in front of" other windows to type in it: simply moving the mouse-pointer into a window enables it for typing. (Of course, if that window is "behind" others, you might not see what you're typing.) Remember: the mouse-pointer must be pointing IN the window you want to type in, in order for what you're typing to appear there. I've seen people type whole novels, (practically), and then look up, and none of it's on screen or anywhere, because they didn't remember this.

2. To put a window "on top" of the others, move the pointer to the bar at the top of the window. Click, hold, release. (You can also move the window around during the holding period.)

3. Minimizing: If your screen is cluttered with windows, you can minimize some of them. Click on the upper right corner of the window, in the square with the little teeny box in it. Your window will disappear: but, don't despair, the program isn't quit, it's just being temporarily put out of sight into the little icon that appears near the upper left, labeled with the application's (program's) name. (To bring it back, click on that icon.)

UsingUNIX

Typing UNIX commands:

Mostly, typing a UNIX command follows this general format: the command- name, (followed by a space), then 1 or more parameters, followed by 1 or more file-names (each item being separated by spaces).

As I mentioned earlier, these commands are more intuitive than you might think; for example, to list the files in the current-working-directory, you simply type

ls

Remember to type the <return> or <enter> key after any command to run or activate the command.

(for list files). We can type just ls, for a simple list of names, or we may specify in addition that we would like to see not only the names of the files, but a lot more information on them, so we can use a parameter, -l.

ls -l

The minus sign indicates a letter or a couple of letters will follow directly, specifying the type of parameters. Sometimes the parameters will be followed by a number, which means something depending on the command and/or the parameter:

winterm -fg 0 -bg 12

Many commands require a filename, or pathname to a file or directory. For example, the command to remove a file, rm:

rm squig.snd

will remove squig.snd from the current directory. If squig.snd is in sndgr/chris, and you're not "in" sndgr/chris, then you have to type the full pathname :

rm /sndgr/chris/squig.snd


A WORD ON NETWORKING: One point of confusion for some neophytes is the difference between what directory you're "in", what machine you're "on", the sound disks "attached" to different machines, etc. Because of the way things are networked, life is very flexible here at the CMC: When you log into any machine, you can "see" the disks of any other machine as if they were right there connected directly to that machine you're "in" or "on." For all practical purposes, you can work as if they are so connected. If you log in to Squawk, you can play a soundfile bang.snd on Growl's sound disk (sndgr) just by typing

play /sndgr/bang.snd

All home directories are accessible from any machine.

There is also the matter of what directory you're currently "in."- - that is, which directory is the current working directory for a given UNIX shell (remember, each UNIX shell is like its own little computer terminal. you can have more than one on the screen at one time, and switch 'twixt them at will): if you type commands with filenames, but without a pathname (like play bang.snd as opposed to play /sndgr/bang.snd) UNIX will automatically look for the files in the current working directory. If you want to stay in your current working directory, but you want to access a file elsewhere, you have to use the full path-name to reference that file (If you're in /Users/chris but you want to play the file bang.snd, (in chris in sndgr), then you'd have to type play /sndgr/chris/bang.snd; OR, you could say cd /sndgr/chris, (change directory to /sndgr/chris) and then type play bang.snd.)

When you first log in, or open up a new UNIX shell, you are automatically placed in your home directory, whose pathname is /Users/your-log-in-name . My login name is chris, my home directory is /Users/chris.

So the network is largely transparent: you can do anything anywhere from any machine. There are 2 exceptions to this which you should know about:

1) speed: If you're doing stuff with sounds, like playing a MIX file, you will find it is faster to use the machine whose sound disk contains your sounds. In other words, you can play with sounds on sndh (howl's sound disk) when you're "on" growl, but it might be faster (depending on what you're doing) to use howl (that is, to log into and work on howl) to play with them.

2) speed over distance: Since our studios are divided in two, with a center at 803 Dodge, and one at Prentis, this can compound the speed issues mentioned above. Again, theoretically, anything can be done to anything from anywhere within the network, but if you are working in one location (for example 803 Dodge) with sounds from the other location (Prentis), information will probably not be flowing fast enough to satisfy your needs. For instance, trying to play a sound in this situation will result in playback accompanied by annoying stuttering. So, keep all of your sounds for each piece in one place, and try to work in that location.

Oft-used UNIX commands:

passwd :change your password. use words like

?whAt? or Boom#5!!! or EyELuvU2 (capitals, numbers, !$@#%@s, complex passwords are best for maximum security.) You will be guided through this command, so just type it, and follow the instructions.

ls : lists files in current directory

ls -l : lists files + l for Lots of infomation. Typical output:

drwxr-xr-x 2 chris 1024 Aug 6 23:43 CRAP/
drwxr-xr-x 2 chris 1024 Aug 6 23:43 EXPORTS/
drwxr-xr-x 4 chris 1024 Aug 9 22:22 Library/
-rw-r--r-- 1 chris 22621 Apr 10 14:22 gliss1.sco
-rw-r--r-- 1 chris 259 Apr 10 14:33 hey.sco
-rw-r--r-- 1 chris 500 Nov 1 1996 interv.algo
-rw-r--r-- 1 chris 1566 Apr 1 16:16 movtmp
-rw-r--r-- 1 chris 1550 Apr 1 16:16 plctmp

Ignore the first two columns. The third shows the name of the owner of the file. Fourth column shows the size of the file in bytes. This is important: If you're in your home (Users) directory, and you see a file with a size like 43485473 (or generally, anything larger than 1000000, 1 million, known as 1 "megabyte" or "meg" for short) then chances are it's a file that doesn't belong there (it's too big.) If you don't know what it is, (for example, if it has the name "core") delete it. If it's a sound of yours, move it to a snd directory.

The next columns detail date and time of creation of the file. Finally, the name is listed last. Notice that some of these "files" are really sub-directories (they've got that old "/" symbol to remind you of that).

cd path : change directory to path

Example:

cd /Users/than/CLASS99

will put you "in" the CLASS99 directory, which is in the than directory, which is in Users, which is in / (root). CLASS99 will now be your "current directory." Now you can type filenames without the /Users/than/CLASS99 stuff before them, but only if they are in CLASS99.

Important note on the use of the / : If the slash, / , appears at the beginning of a pathname, that tells the computer "go to the top of the directory tree and start from there". If you don't have the / at the beginning (I'm only talking about using it at the beginning of the pathname here; you always use it between names), then you're telling the computer "start where you are and look for the following sub-directory."

Let's take a simple example: you are currently working in the chris directory in /sndgr. You want to get into the concrete sub-directory of that directory. There are two commands that would work:

cd /sndgr/chris/concrete

or

cd concrete

The first, starting with the / , says "go to the top of the tree, and look for sndgr. . ok. . . .now go into chris. . . .ok . . . now go into concrete . . . "

Everything's fine.

The second, not starting with a /, says "start where you are (in this case /sndgr/chris) and look for concrete. . . . ok."

This

cd sndgr/chris/concrete

will not work. Why? It says, (not starting with a / ), "start where you are (/sndgr/chris) and look for sndgr . . ." but it won't find an sndgr there, in chris.

Other variation s of the basic cd command include:

cd ..

This means "go up one rung on the directory tree", that is, to the directory that includes the current one.

cd ~bob

This means, "go to the home directory of bob," in other words, whatever name follows the ~ sign will be the person whose home directory you go to.

cd

A plain old cd with nothing after it, simply lands you back in your home directory.

rm <filename(s)> : remove files, if more than one, separate with spaces.

Always think twice before you enter this one!! You can't get files back once they're gone!!! Repeat: You can't get files back once they're gone!!!!!!!!!!!!

mv <path/fileame> <path/filename> :move a file from one location on the

disk hierarchy to another. You can also change the name of a file this way. For exampe:

mv squishee.snd squashee.snd

moves the file to another file with a different name--in other words it changes the name.

cp <path/filename> <path/filename> :copy a file, retain original.

pwd : print the current working directory, i.e.--where you "are."

mkdir <directoryname> : make a directory in the current directory

rmdir <directoryname> :remove a directory in the current directory. The directory to be removed must be empty.

df or diskspace: both of these tell you about how much diskspace is being used, and how much is available.

whoami : obvious. (This exists in case you find a machine with someone who's logged in, and you're not sure who.)

play <path/soundfilename> : This is a quick way of playing a soundfile. You'll find it's much quicker than loading SoundEditor, changing to a sound directory, loading the sound, etc. etc. etc. etc. etc. . . . . .

SGIrshuf <SndFileName>: This is a quick normalize routine for SGI machines. Running this command from a UNIX shell is much faster than trying to normalize in SoundEditor.

sfconvert <InputSndFile> <OutputSndFile> rate <NewSamplingRate>: convert the input soundfile to the output soundfile with a new sampling rate.

man <name-of-UNIX-command> :display a full description/instructions on how to use a particular UNIX command.

cat <filename> :print the contents of a text file to the screen

telnet, rlogin: These commands allow you to log into machines from each other, from elsewhere on campus, or even from off-campus. Examples illustrate:

telnet roar.music.columbia.edu

rlogin roar.music.columbia.edu

telnet roar

rlogin roar

All these commands do the same thing: allow you to log in remotely, via a UNIX shell, to roar. (The last two commands listed above can only be used on other CMC machines, the first 2 can be used from anywhere in the world that's on the Internet!!) When you log in this way, the GUI resources will unfortunately not be available to you, you will only be able to comunicate via a text-oriented UNIX shell; this means you can still transfer files and run CMIX scripts, etc., but you can't run MIX, Ceres, RT, . . .

telnet cunix

This allows you to log in to CUNIX from the CMC, where you can check your email, and do all those other little CUNIX things.

CONTROL + C --- press these keys to stop a command currently in operation

mmm --- mmm causes the machine to "memorize" the current directory; later, after changing directories, you can come back to the "memorized" directory, simply by typing bbb. The command b all by itself, will take you to the last directory you were in before the current one.

sfinfo <soundfilename> --- This command will give a list-out of info on the soundfile specifie; info like duration , size, type, # of channels, etc.

repeat <# of times> <command> --- This will do the operation specified by <command> over and over, <# of times> times.

h --- History. This gives a list of commands that you've previously typed in, each command will be numbered. You can repeat the numbered commands by typing !<#> or do other stuff to them.

other tips

MAKING DIRECTORIES: Remember you can make a subdirectory for your use on any of the sound disks, or in your home (Users) directory. Do this by using the cd command to go to a sound disk, let's say squawk's, (thus the command is cd /sndsq); then, type mkdir your-log-in-name (I would type mkdir chris). Now your new sound directory is created. Go into it by cd /sndsq/your-log-in-name.

Cop-eesh?

"PERMISSIONS": Our system is set up so that anyone can read anyone else's data, but only you can modify data or write new data in your subdirectories.

EXPLORE !!: It's a good and fun idea to explore the systems: look for programs or Apps that might be useful to you: check out different sound editors, soundfile-format librarians, etc. Two good ways to do this are: click on Find and then on Media Tools, Desktop Tools, Web Tools, etc. on the SGI. Also, use UNIX to check out /LocalApps and see what's there (using cd and ls.) Remember, most Apps can be run simply by typing their name as a command.

TYPES OF SOUNDFILES: Usually soundfiles are labeled with a .aiff ending; however, you can name them whatever you like, they will still work correctly. aiff (Audio Interchange File Format) is the standard used by SGI and Macintosh machines, the ones we use here. The other form of audio you may encounter is wav, which is used on Windows systems. All can be easily inter-converted using programs like soundfiler on the SGI machines. (You can find it in the Media Tools directory mentioned above.)

speedy commands in UNIX:

* -- this symbol means, simply put, "everything". Hence the command

rm *

(don't type this too often, or you may lose something valuable!) means "remove all files in the current directory." But it can be a bit more flexible:

rm bang*

will remove all files that begin with the characters "bang" . Hence if your directory has

wad.snd
hello.1.snd
hello.2.snd
flip.txt
bang1.snd
bang2.snd
bangme
bang3.snd
band
doobee.snd

The result of rm bang* , followed by ls, will be

wad.snd
hello.1.snd
hello.2.snd
flip.txt
band
doobee.snd

Or if, you wanted to find out how many bytes of memory the "bangs" took up, you could go

ls -l bang*




!! --- 2 !!'s means "repeat the last command." This command is often referred to by computer duuds as "bang!" (don't ask me why--true, it's an exclamation point, but it's not that exciting. . . .)

thus

ls -l bang*

!!

The second of these commands will simply execute the first again, saving typing.

A simple extension:

!<character(s)> this will look for the last command that began with <character(s)>, and re-execute.

Example: Let's say that at some point you type the following commands:

sffc2 bang.snd
wavetable bang.sco
rshuf bang.snd
play bang.snd
rm bang.snd

After typing and executing these commands, you do some other stuff; then, later, you want to play bang.snd again. Just type:

!pl

And the machine will remember play bang.snd. If you type

!rsh

it will remember rshuf bang.snd.

<esc> --- the Escape key: Sometimes, you'll have a long filename, or even a mediu m one, and typing it in, especially if you're doing it a lot, becomes annoying. If you type the first few letters of the filename, then press the <esc> key twice, the computer will look in the current directory for a file beginning with those letters, and fill the rest in for you. This can be a real annoyance-saver.

<arrow keys> :If you press the <Up Arrow Key>, you can quickly peruse through the last few commands you typed into UNIX, and then modify them using the <backspace> and <right> and <left> arrow keys. This keystroke-trick comes in handy if you are typing the same basic kind of command over and over, with small modifications each time.

(For example, it would make the following sequence of commands much less tedious to type:

wavetable < gogo1.sco
wavetable < gogo2.sco
wavetable < gogo3.sco
wavetable < gogo4.sco

Our relationship to CUNIX:

Our system is not hooked in with CUNIX. You will not be able to access your CUNIX account directly. (You can access CUNIX by typing "telnet cunix" though). Your CUNIX files will not be available. Also, any email you recieve here, and/or in CUNIX, will not be shared.