|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Unix Subtopics in this Guide
Unix Overview (main) Command Summary (in Guide, PDF) Working on UNIX (in Guide, PDF)
|
A few of the following suggestions will save you time and make working on Eos/Unity easier. Most are just available on Unix and Linux. Copying and Pasting between Windows One of the most useful functions is the ability to copy and paste information
from one windowed application to another. On Unix, all you have to do
is point, hold down the left mouse button, and drag over the information
you want to copy to select it. Then point into the application where you
want the information to be copied and click the middle mouse button to
place it there. The text is not cut from the Completing Command Entry without Typing You can also use the TAB key to save you time in typing commands, pathnames, or data. For example, if you issue a command that affects the file unixsoftwarelist.txt, you do not need to type all the characters in this long filename. You can type the first characters in the name, until it is distinguished from all other files in the directory, and then press the TAB key to let the system finish the typing for you. For example, if unixsoftwarelist.txt is the only file that begins with the letter u in the directory, then the u and TAB keys are all you would have to type to enter this filename on the command line, e.g., % more u[ TAB] This shortcut is also very useful when typing in long pathnames, which on Eos/Unity is something you have to get used to doing frequently. You can simply type a part of a directory's name and then press the TAB key. Repeating Commands without Typing To repeat a command that you have typed previously in a session, press the up-arrow cursor key until you find the command again. To execute the command after you have found it, simply press the Return or Enter key. If you want to modify the command before executing it, use the right and left cursor keys to position the cursor and then type in or delete characters as appropriate. The history command also displays the last commands you typed in a session up to whatever number is specified in the shell environment (type set to see the setting for savehist). If the savehist variable is set to 100, then your last 100 commands have been recorded and can be displayed with the history command. The commands are numbered in the order you typed them. If you want to execute the last command you typed, type two exclamations marks (!!) at the prompt, or use the up-arrow key as described above. % !! If you want to execute an earlier command in the list, type an exclamation mark ! (sometimes called a "bang" or a "shriek") followed by the line number of the command, line 34 for example. % !34 Aliases (alias) Often, you find yourself typing the same commands, files, and paths over and over. If you wish, you can create substitutions or aliases for these, using something shorter and easier to remember. For example, if you want to use the shorter command md instead of mkdir to make a directory, type % alias md mkdir The command alias is followed by the substitution you want to use and then the original path, filename, or command (or a combination of these) that you want the alias to replace. If you have aliases that you want to use all the time, put them in your ~/. mycshrc file. To take out an alias, use the unalias command. For example, to undo the md alias you created for the Unix mkdir command, type % unalias md Useful Key Combinations Individual keys and key combinations will perform particular operations and functions that can help you or save you time. When you see instructions that tell you to press some kind of "CTRL+ character" combination, it means to hold down the Control key (or the CTRL key on some keyboards), and press the character key indicated. The action is similar to holding down the Shift key and pressing a key to make an uppercase letter. For example, Control z will suspend a process and Control c will cancel or abort it (see also Background and Foreground Processes). Wildcards and Metacharacters Wildcards are special characters designed to work in place of other characters and strings of characters in command arguments. They save you time when you are trying to work with a number of files at once. The asterisk * (called a star) can be used in place of any string of characters, even a string with no characters in it. For example, if you want to list (command ls) only the files in a directory with the extension .doc, then you can type ls *. doc You can use the wildcard with any command that operates on files: cp, rm, lpr, etc. Thus, you do not have to work with files individually but can manage them as groups. The * by itself stands for all files. As a result, if you type rm *, you will remove all the files in a directory. Be careful with wildcards, and use the -i option with commands like rm. This option asks the user for confirmation before removing each file. The question mark ? represents a single character. For example, typing % ls essay? lists all the files you named essay followed by a single character, such as, essay1 essay2 essay3 essay4 Or, you can use a series of question marks to stand for two characters or more. The command ls essay?? picks up essay10 essay11, etc. Redirection of Input and Output The keyboard and terminal screen are Unix's standard input and output devices, respectively. Unix expects input from the keyboard and always sends output to the screen, unless told to do otherwise. Redirection is the process of changing the source and destination of input and output. To Unix, your screen is just another file. When a command generates output, the shell writes it to a standard output (abbreviated stdout) file, which puts the data on your screen. However, you can redirect this output if you wish, sending it to another file instead. For example, if you want a directory listing sent to a file rather than to your screen, type % ls -al > myfile where myfile is the name of the file that receives the directory-listing output. The right-angle bracket (>) tells the shell to perform the redirection. If the file myfile does not exist, it will be created. If it does exist, its contents will be overwritten by the new data. To append the data to the contents of a file rather than overwriting them, use two right-angle brackets instead of one. The following command places the directory listing at the end of any data already in the myfile file. % ls -al >> myfile Redirecting input is a similar procedure. Using the left angle bracket (<), you can specify input from a source other than the standard keyboard input device. For example, if you want to use the contents of the myfile file as input to the pine mail program, you type % pine jqpublic < myfile This command uses the contents of the myfile file as input to pine, which sends these contents as a mail message to the user, jqpublic. To merge the contents of files together, that is, concatenate them, use the cat command and redirection. For example, cat file1 file2 > file3 will merge file1 and file2 into a new file called file3. The right angle bracket tells the system to send the result of the concatenation to file3 (see Files for more on cat). Pipes and Pipelines The process of piping sends output to a command or a series of commands. A series of commands is called a pipeline. You pipe data from one command to another by entering the commands on a single line with a vertical bar between them. In this way, the output of one command becomes the input to another command. For example, when you enter a command and its output is too large to fit on one screen, you may want to cancel the output (type Control c) and type the command again, this time "piping" the output through more so it will be displayed in a format that you can move through more easily. Say you have a directory with many files in it, so many that they scroll off the screen before you can read them when you do a directory listing. You can pipe the ls command through more instead, e.g., % ls -l | more See also Files and Commands and Managing Directories. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Information
Technology and Engineering Computer Services (ITECS) |
|||
|
|
This support page is for students,
faculty, and |
||