|
|
|
While the ILL's neutron source has remained essentially unchanged during the lifetime of the Institute, the ILL's instruments and their components have been continually developed and improved to increase their effectiveness.

Commands 050 - Sophomore seminarCommand completionOne of the features of tcsh, the default shell, is command completion. Command completion allows you to type the beginning of a command and hit "TAB" to try and complete it for you. This also works for file names. The command completion feature searches for files beginning with the specified characters and extends it until it can no longer find a unique name. For example: There is file with a very long name (say, netscape-v3.0.1-solaris.2.5.1.tar.gz) in the directory /tmp that I want to copy to my directory. I could enter "cp /tmp/net[TAB] ." and it would complete net... unless there was another file with a similar name in /tmp. If there was another file named netscape-v3.0.1-sunos.4.3.1. tar.gz in /tmp, then "cp /tmp/net[TAB]" would complete to "cp /tmp/ netscape-v3.0.1-s". At this point, I could type "o" and it would complete the entire name with ...solaris... unless there was another conflict. This can save a lot of time when typing long file names. Another feature of command completion is the Ctrl-D key. "Ctrl-D" will list all of the commands or programs that begin with the characters entered so far. So if I enter "net[Ctrl-D]", it will list "netgold netscape netscape2 netscape3 netstat" as possible completions. This is useful if you remember how a command begins, but not how it ends. Control keysHere are some of the control key sequences that work in UNIX: Ctrl-B: Go back a character. In Solaris, this is like the left arrow for scrolling. telnet (host) These commands allow you to login into another computer. 'telnet' without a [host] puts you in a command mode. Type "?" at the 'telnet>' prompt for more help. 'rlogin' has no command mode and requires a [host]. On the SACL system, if you 'rlogin' to any of the computers on the SACL network, you will be logged in without having to enter your username or password. Both 'telnet' and 'rlogin' open the new session in the window in which the command was issued. 'xrlogin' opens a new window for the new session. On the SACL system, just typing "[host]" is aliased as a shortcut to 'rlogin [host]'. xhost +(host)Allows [host] to send windows and displays to your terminal. If no host is specified ("xhost +"), then all other machines can send windows to your screen. If you wish to run a program on another computer that needs to open a window, such as xv, then you need to first run 'xhost +' on the local terminal. setenv [variable] [setting] Sets and unsets environment variable settings. The three most important environment variables are: PATH, TERM, and DISPLAY (remember kids, case is important). 'setenv' by itself will display all of the currently defined environment variables. The PATH variable determines where the system will look for files. There should be little reason to change this with 'setenv'. If the need should arise, contact a system administrator for help. TERM tells the system what type of terminal you are using. The screens in the SACL lab are of the type 'sun-cmd', so if the TERM variable is set wrong for some reason, enter "setenv TERM sun-cmd". When you rlogin or telnet to another machine outside of the SACL lab, that machine will try to set its TERM variable to 'sun-cmd', but it may not exist. The safest alternatives are the terminal types 'xterm' and 'vt100'. The DISPLAY variable is the most useful one. It tells the computer where to direct any windows. So, to run a program that opens a window on one machine, but display that window on another, you need to the following: Say you wish to run Netscape on ply, but you're sitting at isogrid. 1) On isogrid, type "xhost +" or "xhost +ply". ftp (hostname)'ftp' stands for 'file transfer protocol'. It is the easiest way to transfer files over the Internet. Without specifying a hostname, 'ftp' puts you into a command mode, like 'telnet'. Enter "help" at the 'ftp>' prompt for help. Once you have 'ftp'ed to a site, the commands 'cd' and 'dir' commands work the same. In addition, you can 'get' and 'put' files. Be sure to use the right mode. "bin" puts you in binary mode and "asc" puts you in ASCII mode. When in doubt, use the binary mode. Here are some of the commands that work in ftp: cd [directory]: Change directory on the remote machine To use anonymous ftp, simply 'ftp' to a host, enter "anonymous" as the username and your email address as the password. If the host supports anonymous ftp, you will get access to the public areas. [command] &Adding '&' to the end of a command runs it in the background. This will not work for programs that need interactive user input in the working window, for example, Matlab. However, it will work for any batch jobs and any programs that open a window, such as emacs. Thus, to run emacs in the background, you would enter "emacs &". Running a job in the background keep the command window free for other uses. If you start a job, for example 'mailtool', and forget to add '&', then it will run in the foreground. To send it to run in the background, hit "Ctrl-Z", then type "bg". ps (-aux) {SunOS} Displays information about active processes. Use 'ps' to get the process ID (pid) number for a job. You will need the pid to kill a job. -a displays information about all processes including ones that are owned by other users -e displays information about all processes 'ps -au' on a SunOS machine is essentially the same as 'ps -ef' on a Solaris machine. topDisplays the processes running on a computer in the order of highest resource use to lowest. The job using the most CPU power is displayed at the top. The process ids and nice levels are also shown. Hit "q" to quit 'top' and "i" to toggle the display of idle processes. Use 'top' to see if there are any jobs slowing down the computer. Lists all of the jobs running the background. The number in [ ] is the job number, NOT the process id. 'jo' is an SACL alias for 'jobs'. -l shows the jobs' process IDs, as well as job number. bg %[job number] Sends jobs to the foreground or background. Jobs must be identified by the job number (found with 'jobs'). Without any arguments, both 'fg' and 'bg' send the current job to the foreground or background, `respectively. The 'bg' command is most useful for sending a job to the background if you forget to add '&' to some command when running it. On the SACL system, you don't need to type '%' with the 'fg' command. POWER TIP: If you are running something interactively in one window and need some information from another file, you don't have to open another window. Just hit "Ctrl-Z" to suspend the current job, get the information you need, and then hit "fg" to resume the program from where you left off. kill (-signal) [pid]Ends the life of a poor, hard-working process. Use this command to ruthlessly slaughter innocent jobs. This can be useful if a job goes out of control or gets stuck in an infinite loop. The pid can be found from the 'ps' output. -signal can be used to kill jobs that just won't die. If plain old "kill [pid]" doesn't work, then try "kill -15 [pid]" and if that doesn't work, try "kill -9 [pid]". 'kill -9' should kill virtually any job. Please do it in this order. What if the job had a wife and kids? renice [priority] [pid]Resets the nice level of a job. You can only renice jobs that you own. The priority levels are the same as for 'nice' with higher numbered jobs getting lower priority. Use this command if you forgot to 'nice' a job when it was run. remove [file-list] {SACL}This is an SACL alias for 'rm -i' without the `trashcan` feature. It will verify if you wish to delete the files in [file-list], but once they're gone. For good. However, this is the easiest way to delete links (see 'ln'). Use with caution. passwdThis command allows you to change your password. You should do this every so often, just to be safe. For your security and the system's, the password should be at least five characters long, shouldn't be a word in the dictionary, and must have at least one non-alphanumeric character in it. This is for your protection and to stimulate your creativity. sacl {SACL}Shows you who is on each computer in the SACL network, where they are logged in from, and how long they've been on. finger (-l) (username)(@hostname) 'finger' with no arguments shows you who is on the local machine and how long they've been on. 'finger @[hostname]' shows you who is at [hostname] and how long they've been on. 'finger [username]@[hostname]' will give you information about [username]@[hostname]. In some cases, this will only show you if that person is logged in and if so, where. In other cases, it will show you detailed information about that person, including the .project and .plan files. To force the long output, use the -l option. 'f' is an SACL alias for 'finger'. POWER TIP: 'finger' can be a useful way to check if you have any unread mail. Just 'finger -l' your account and you will see if and when new mail arrived. Displays information about the users on the current machine. 'w' gives more detailed information than 'who'. whoamiDisplays who is currently logged into the window in which the command is issued. This is useful in case someone leaves the terminal and you need to find out if you can log him or her out without getting beat over the head with a wet rag. whois (-h) [identifier] These are cousins of the 'finger' command. 'whois' searches a database like the Yellow Pages and finds information that corresponds to the [identifier] which may be a username or a real name, or some other keyword. In general, you will need to specify a host to search a specific database. 'suwhois' is an SACL alias that specifies the host leland.stanford.edu. Enter "suwhois help" for more information about searching the Stanford University whois database. -h[host] specifies host machine to search on cat [file-list] Displays the files [file-list] to the screen one after the other, without pausing at the end of each page. In reality, 'cat' stands for concatenate. It actually attaches the files in [file-list] to one another and then 'attaches' all of them to the screen. If the output of this commands is redirected (see > below), you can connect files and save them in another file. 'list' is an SACL system alias for 'cat'. tail (+-) [file]By default, 'tail' displays the last ten lines of a file. Use the options to change this. +[number] starts displaying [number] lines from the top of the file head (-) [file]The converse of 'tail', 'head' displays the top ten lines of a file, by default. -[number] displays the top [number] lines of the file alias (aliasname) (definition) Defines, what else, aliases. These are basically your own custom shortcuts to commands. Without any arguments, 'alias' gives you a list of the currently defined aliases. 'alias [aliasname]' shows you what [aliasname] is currently defined as. 'alias [aliasname] [definition]' sets [aliasname] to do [definition]. The [definition] can be any single command with whatever options. If the definition includes a space, then the whole definition should be enclosed in single quotes ('). 'a' is just an SACL-defined shortcut that shows all current aliases page by page. There are three major uses for this. First, you can redefine some very common commands to something shorter. Perhaps you use Netscape a lot and would rather just type "n". Then, just enter "alias n netscape" and voila! Just to be safe, it is usually wise to verify that the alias doesn't exist by entering "alias n". Second, there may be a command that you prefer with certain options. For example, I like 'enscript -2rG' and have it aliased to just 'enscript'. This is done with "alias enscript 'enscript -2rG'". Third, aliases can be used to get rid of long paths. While most applications should be in the path, one way or another, you may find one that's not. In this case, you can define an alias to include the path. For example, there may be a code that's run with '/apps/unsupported/foo/bin/sun4/foo' and it can't be found in the path. You can alias it to just 'foo' with "alias foo /apps/unsupported/foo/bin/sun4/foo". Note that aliases defined from the command line only live as long as that login session is open. To make aliases that are defined every time you login, add them to your ~/.aliases file. unalias [aliasname]Undefines the previously defined alias, [aliasname]. zip (-dklrx) [zipfile] [file-list]{SunOS} These are compression utilities. 'zip' and 'unzip' are compatible with PKZIP on DOS systems. 'zip' compress all of the files in the [file-list] into [zipfile]; 'unzip' uncompresses [file-list] out of [zipfile]. There are lots and lots of options for these commands. I will explain a couple of them, see the man pages or type "zip/unzip -h" for more help. zip: unzip: gzip (-adr) [file-list] These are like 'zip' but makes a separate compressed file for each file in [file-list]. The new files have the same names as before with '.gz' added to the end. Like 'zip' and 'unzip', there are many options. I am only including a couple here. See the man pages or type "gzip/gunzip -h" for more information. -a converts UNIX text files into DOS text files and back mtools {SunOS}This is a useful package of tools for reading the floppy disk on SunOS machines. It only works with DOS disks, not Mac disks. Just put your disk into the drive and execute any of the following commands just like in DOS. The drive is specified as a: and patterns are matched as in UNIX, not DOS, so '*' specifies all files, instead of '*.*'. Use '/' to indicate subdirectories and be careful of long filenames that may be invalid in DOS. It also seems that wildcards do not work with mcopy. copydos {SACL}: an alias for 'mcopy' that converts text files from DOS to UNIX and back Be careful with text files since DOS and UNIX store end-of-line markers differently. Be sure to use 'mcopy -t' or 'doscopy' with text files. On Solaris machines, insert your floppy into the drive, type "volcheck" and then do whatever you wish with standard UNIX commands like 'copy' or 'delete'. The floppy disk is the directory '/floppy/floppy0'. chmod [permission level] [file-list]OK, this one requires a little more explanation. Each file has three levels of permissions set on it and each level has three types of protection. When you "dir", you see these permissions in the first ten columns. A typical line from a 'dir' output might look like: <tt>-rwxrw-r-- 1 jcjai users 1453 Jul 9 09:36 diskuse</tt> This means that the file named 'diskuse', was created on July 29, at 9:36, the owner is jcjai and it belongs to the group users. This information will be useful in the next section. The size of the file is 1453 bytes. For the 'chmod' command, it's the first ten characters that's important. The first column will have a 'd' in it if the item is a directory and an 'l' if it's a link. The next nine represent the read, write, and execute permissions for the user, the group, and the rest of the world, respectively. So in the example, the file diskuse can be read, edited, and executed by jcjai. It can be read and edited by the group users and it can be read by everyone else. To change these file permissions, use the 'chmod' command. There are two ways to use 'chmod'. The first has the form: chmod (ugoa)(+-=) (rwx) [file-list]. In this form, u stands for user, g stands for group, o stands for other, and a stands for all three (ugo). + means to add the permission, - means to remove the permission, and = means to set only that permission and remove all others. r is for read permission, w is for write permission, and x is for execute permission. So, to remove group and global write permission for the file diskuse, I would enter "chmod go-w diskuse". There are also two related system-wide aliases, '+rx [file-list]' and '+x [file-list]. The first is the same as 'chmod a+rx [file-list]' and the second is the same as 'chmod a+x [filename]'. The other method sets a file permission for all three levels at the same time, overwriting any previously set permissions. In this method, each level of permission has a number from 0-7 associated with it. The number is the sum of 1 for execute permission, 2 for write permission and 4 for read permission. Thus, 6 is read and write permission and no execute permission. Three of these numbers form the entire file permission, the first for user, the second for group, and the third for others. So, 644 would be read and write for the user, and read for the group and all others. Thus, to change diskuse to be readable, writable and executable for me, readable for the group and nothing for everyone else, I would enter "chmod 740 diskuse". echo <list>Displays <list> to the screen. This command is useful for displaying environment variables. For example, "echo $PATH" will show the current path variable on the screen. unitsA cool little unit conversion program. Just type "units" and it will ask what units you want to convert to what units and then tell you what the conversion factor is. I'm not sure what units it recognizes, but I think it knows a lot of them. Play with it! |