6.1 Directory and File Management Using the Command Line
6.1.1 Using control characters
Knowledge of file and directory management using commands is very important in building a solid foundation for further study of the UNIX operating system. Power UNIX users and system administrators must have a working knowledge of command line capabilities and syntax. Many operating system management and device configuration tasks require an understanding of UNIX commands, and in some cases, the command line is the only tool available. Power users and administrators frequently create executable script files, which are powerful tools for automating certain tasks such as backing up files or creating new user accounts. Script files are a series of UNIX commands and are similar to batch files used with other network operating systems.

Control characters are used to perform specific tasks such as stopping and starting screen output and others as listed in Figure . There are two control keys on most PC keyboards. They are normally labeled Ctrl and found in the lower left and right corners of the keyboard. On a Sun workstation, there is one control key in the lower left of the keyboard which is labeled Control. When displayed on the screen, the Control key is represented by the caret (^) symbol.

To enter a control character sequence, hold down the Control key and press the appropriate character on the keyboard. Control-c is a common control character sequence and is frequently used to interrupt or cancel a process. The actual character in the shell appears as ^C, even though you press the Control key and the c key at the same time. The following control characters can be used:

  • Control-s - Stops screen output. The Control-s and Control-q characters were originally needed by teletype operators and are rarely used today. An example of when you might use the Control-s is when viewing a large file with the cat command (covered later).
  • Control-q - Resumes screen output stopped by Control-s and is not used frequently.
  • Control-c - Interrupts the current activity and is frequently used to abort processes or long display outputs resulting from the man, cat or ls commands. If you do a man page on a command and want to stop the remaining display of the man output, you can press Control-c to interrupt the output and return to a command prompt.
    Control-c is also helpful in restoring the shell prompt if an unrecognized command line (i.e.,
    $ls " ) is typed and the secondary prompt (>) in the Korn shell is received.
  • Control-d - Indicates end-of-file or exit. Control-d is used to exit some UNIX utilities (bc, write, and several others), exit a terminal window, and to log out of a terminal session or command line login session. As a general rule, when stuck or if Control-c does not work, try Control-d.
  • Control-u - Erases the entire command line. This can be used as a quick way to erase a command line that you decided not to execute or in cases where you are logged into a remote system and the backspace key does not work.
    It can also be used to ensure that you are starting with a fresh user id and password entry when logging in. Because passwords cannot be seen when they are typed, use Control-u to erase the password and start over when an incorrect character(s) has been typed.
  • Control-w - Erases the last word on the command line. This can be used as a quick way to erase the last argument (i.e., a pathname or file name) on the command line that you decided not to use or in cases where you are logged into a remote system and the backspace key does not work.
Interactive Media Activity (Flash, 88 kB)
  Control Characters. 

In this media activity, you will execute a UNIX utility called bc (basic calculator) from a terminal window. You will use the Control-d command to exit the utility.
Note: Be sure to press enter after each one. Click on step 1 to begin.