The exception to UNIX case sensitivity is the use of "Ctrl" cmds. To both illustrate this and give you some important "Ctrl" cmds, consider these: "Ctrl-c" or "Ctrl-C" cancels a job in the foreground (see Section 6 Foreground discussion below); "Ctrl-z" or "Ctrl-Z" suspends a foreground job; and "Ctrl-d" or "Ctrl-D" logs you out when at the "$" UNIX prompt.
Other "Ctrl" cmds of note are "Ctrl-s" or "Ctrl-s" to freeze your terminal display (may be necessary when not displaying with "MORE" paging) and "Ctrl-q" or "Ctrl-Q" to unfreeze.
ls -lFEven more information can be obtained with the "-a" all file flag exemplified as follows:
ls -lFa
which now include hidden files in the list; hidden files are prefixed with a "." such as the ".profile" file which you can optionally use to over ride/supplement your default profile. See example use of ".profile" in Section 4 below, where it talks about using it to automatically execute the "alias" command upon login. Your default profile can be seen via this "cat" cmd:
cat /etc./profile
The "cat" cmd generally has this format
cat filename
and simply displays the contents of file "filename" (we discuss "filename" next)
2. Filenames (GoBack)
UNIX filenames are unlike DOS PC files in that they can be virtually any length and as mention above are case sensitive (the latter illustrated by the UNIX filenames"myprog.lst", "MYPROG.lst", and "MYPROG.LST" being totally different files).UNIX files have no system recognized "extensions" or "file types" to further identify them; for the current directory, files are recognized by filenames alone. Note, however, that software on UNIX may recognize and require these identifying elements (e.g., on Stats Fortran source files must have the extension "f" or "for" before Fortran will compile them).
UNIX filenames are probably best kept to alphanumeric characters and periods ("."), since several special characters are interpreted by UNIX for other purposes. You can use any number of "."s; for example, "my.prog.in.f" is just as valid as "myprog.f"; however, filenames with leading "."s are hidden (e.g., ".profile") and, as mentioned in 1. above do not list with the "ls" command unless you include the "-a" option (e.g., "ls -la" to long list all files and better yet, recommended, "l -lFa" to also include the file identifiers: trailing "/"s, "*"s, @"s, etc. to mark respectively directory files, executable files, link files, etc.).
This "alias" command will automatically execute when you log into Stats so that you have the alternate "r" cmd to remove files; when you use "r" to remove files, Stats automatically asks permission to delete the specified files; thus, instead of you using "rm -i" to remove files with permission, just "r" does it more conveniently; for example, this "r" cmd:
r *.lst
asks permission to delete each "*.lst" file, one at a time. For more about the ".profile" file, see the latter part of Section 1 above where it discusses the "ls -lFa" cmd.
The "ls -l" cmd displays a file's protection status at the beginning of the line that describes the file (a "w" as the 3rd char in the line means write privileges; else the file is write protected from the user); however, because "H:" files at W & M share with files on Stats, the default permission codes for new files do not show correctly on Stats. On Stats the permission codes show as "rwxrwxrwx" for a new file, permission for both owner and other users to do anything with the files (full access); this is not true. So please ignore this information.
Note: because you can easily remove a lot of files with the "rm" command without even knowing it -- for example the cmd "rm *" can removes most files from your current directory, nothing said -- we request that you be careful with the "rm" cmd (again recommend including this cmd: alias "r=rm -1" in your ".profile" file so that the "r" cmd does it asking for permission with each file). If you need to restore removed files, you can request restored them with backup copies via E-mailing to this address:
support.wm.edu
Final Note: you can directly protect files from accidental deletion by preceding their names with a ".", classifying them as hidden; that way even "rm *" will not remove them ("rm .*" will, but here you tell it to remove all hidden files and should be aware of it).
To create a sub directory of "HOME" (on Stats a sub directory of specifically "/home/your-user-id"), you type this when "HOME" is the current directory:
where "new-dir" is the name of your new sub directory. For example, to make sub directory "mysubdir", you enter To make "mysubdir" the current directory, key To make "HOME" the current directory (again automatically when you 1st login), you can enter any one of the following: Or of course, more conventionally, more directly, you can use this to make "HOME" current:cd /home/your-user-idTo remove a directory, for example, "mysubdir", you do this:
rmdir mysubdir
This will remove "rmdir" if and only if you have removed all files and subdirectories from "mysubdir".
6. Running a UNIX Job: in Foreground/ Background/ Suspension (GoBack)
When you execute a cmd at the Stats cmd line, you create a foreground job; for example, if you execute "ls", you run a foreground job to list files in your current directory. Or to run, for example, your Fortran or C program (compiled and stored in file "myprog.out") in the foreground, you execute this:
./myprog.out
at the Stats cmd line. Note that the "./" tells Stats to specifically run file "myprog.out" located in the current directory; otherwise Stats will not know where to find the file, as it normally just looks in the Stats system directories (which is why a standard UNIX cmd like "ls" requires no directory spec because "ls" is a system cmd). Here the "myprog.out" job remains a job until completion or you either cancel it with "Ctrl-c" or suspend it with "Ctrl-z"; if the latter you can resume with the "fg" foreground cmd, run it in the background with the "bg" background cmd (further discussed below), or you can kill it with the "Kill" cmd.
To run "myprog.out" in the background to begin with (so you can do other things at the Stats cmd line), you can use the "bg" foreground cmd (or alternately leave out "bg" and just end the all with an "&", the more popular way) as follows:
bg ./myprog.out
or ./myprog.out &
This works Ok if "myprog.out" does no interactive I/O; that is, all I/O comes from/goes to files(s).. Assuming, however, that "myprog.out" does all I/O interactively at the Stats cmd line (receives input from the cmd line, display output starting at the cmd line). you need to redirect the I/O as follows when you background the job::
bg ./myprog.out < myprog.dat > myprog.lst
or alternately this:
./myprog.out < myprog.dat > myprog.lst &
where "<" says accept the input from file "myprog.dat" (instead of at the cmd line) and ">" directs the output to file "myprog.lst" instead of to the monitor.
You can display the status of any job (foreground. background, or suspended) by keying (or alternately typing "ps -l" to display more job information such as time; note other processes/jobs list; just ignore).You can kill any suspended or background job by entering
You can also run an X-Windows application in the background, allowing you to access the Stats cmd line to do other things (such as file management), while returning you any time to the X-Windows application, still in the background; consider this detail example: if you run X-Windows SAS with this cmd:
sas&
you open the X-Windows SAS Display Manager as a background job; since the Stats's cmd line remains open when only background jobs run, you can now, for example, list your files, possibly even display some searching for the SAS program file to process; having found the file, you return to the SAS Display Manager by clicking on the appropriate SAS sub window or sub window icon on the Task Bar ( the one for the SAS Editor), access the file (open the SAS program file in the Editor), and process it. Of course if you run X-Windows SAS before you know you need to check your files for the SAS program, you can type "Ctrl-z" to suspend, "bg" to background SAS, check out your files at the Stats cmd line, return to SAS, now running in the background,etc.
You can also process a SAS program independent of the SAS Display Manager and also Stats being in X-Windows mode (necessary to access the SAS Display Manager); for example to do this with statements in text file myprog.sas, execute this at the Stats cmd line:
sas myprog.sas
and as with the example Fortran program above, if you want to do this in the background so you can do other things at the same time, you add on the background operator "&" as follows:
sas myprog.sas &
7. How to Continue Running a Job after Exiting Stats GoBack)
There maybe times that you prefer logging out of Stats while one of your job continues to run; for example, if it is a number crunch er and may take a long time; you can do this by running it with the "no hang up" command using this format:
nohup "command-to-run-the job" &
where "command ..." is is what you normally type to create/run the job and "&" runs it in the background; as mentioned above the latter lets you get back to the Stats command line to exit or if you wish, do other things, and exit later. For example this job using "nohup":
nohup sas myprog.sas &
runs the SAS statements in text file "myprog.sas" (assume they take a very long time to process); because of the optional "&" this job runs in the background so that when you log out of Stats the statement processing continues. Specifically what you do after running "nohup" as above is press the Enter key to return to the Stats command line; then anytime afterwards you can log out (exit) if you wish with again the "SAS program' job continuing its execution. When you log back into Stats, you can check the status of this job by executing this "ps" process command (a process being being jobs that Stats runs to support your log in plus those you start including your "nohup" job):
ps -ef|grep your-id
where "|" is the vertical bar character known as the pipe command in Stats and "your-id" is your Stats id (also your W & M id); "ps ef" by itself lists all current processes for all users Stats for all users; by including the "|" command, you pipe all listed processes to the "grep your-id" command which retains only those listed with "your id" and thus lists only your processes (again including any of your "nohup" jobs). In our SAS program example, the process associated with the above "nohup" command has "sas myprog.sas" trailing its listing; this identifies the "nohup" program (job) as still executing; it also gives its "process id" as the second number in the list; you can use the "process id" to kill the process (job) with this command:
kill "nohup process id"
Of course if your "nohup" doesn't list to begin with, then your program has finished execution.
8. Getting Help on UNIX (GoBack) On Stats you can help via the "man" (manual) command. For help with a specific Stats command, you enter
man lsFor help via key words, you enter
man -k keywordThus, this "man" command:
man -k fileslists/describes commands for doing file work; from here you can get more help with a listed command via the "man cmd-name" format.
cat myprog.lst
which displays file "myprog.lst" (again assumed here to be text type and <= 8 pages); then you select what you wish to print, click your Stats File menu item, then Print, etc.
If your printout exceeds the approximated 8 page limit, you can bring up the text UNIX file in almost any PC's Editor (NotePad being the exception) and print from there. You can readily do this if your PC is mapped to the "H:" drive at W & M (automatically done in the W & M labs at log in time); if this is your own PC and you are connected to the W & M campus network (which it should be if in a W & M office/resident hall), you should be able to map to "H:" via the following:
Open Windows Explorer, then Tools, then Map Network Drive, and in the emerging window, do the following:If this works, you should see "H:" listed in your Windows Explorer left sub window.Select "H:" from the Drive pull down
Enter the following in the Folder text box:\\netstore\your-user-id$and press ENTER
If you can not map to "H:", you can print a Stats's text file still another way on your PC. If you SFTP to Stats (PACLab Tips, Appendix D, for how in the labs), you get a list of your Stats's home directory (folder) files; then all you have to do is find the file to print in this list (either at the root of your home dir or within a sub directory); then click the file name, and drag and drop to your PC hard drive; from there print to your local PC printer (e.g., by opening the file in Microsoft Word and printing it. This is of course desirable if you want to print more copies latter as a copy is now on your own PC.
If your Stats output file is binary (an image file supporting graphics work, for example) and you have "H:" access, all you have to do is bring it up in any PC graphics editor and print from there; if "H:" is not accessible, you take the SFTP route mentioned above. and bring up the image file from your hard drive, etc.