Working Within the Shell


As a Unix user, you will find yourself working within the shell almost all the time. As you do, you will undoubtedly run into common issues and problems. One of the common problems was mentioned before: While working within Unix, make sure your Caps Lock button is not selected, because Unix commands are case sensitive and will not function properly if entered in the wrong case. In some situations, you could select the wrong command by using improper capitalization. Another common problem is not having the command's location listed within the PATH environment variable (covered in Lesson 16, "Modifying Your Environment").

Follow the Path To easily understand the PATH environment variable in Unix, compare it to the PATH statement in Windows. By typing PATH at the Windows DOS or command prompt, you can see the same information. For example, if you want to run a calculator in Windows, typing calc at the command prompt will do it. This happens because calc.exe is located in one of the directories listed within that PATH statement. The layout of Unix is similar.


Another issue you may have to contend with at the command prompt is what appears to be a hung process, which in reality (if it isn't a hung process) is really nothing more than a program that has been started and left running and that appears to be unresponsive. An example of this can be seen in Figure 1.1.

  • Here, I have run the vi editor, which is nothing more than a Unix-based word processor. The vi editor, once launched, seems to hang the Unix session for the user and gives the unknowledgeable user the feeling of being completely trapped. In this situation, some users who don't know how to fix this will power off the system and reboot. Others will try common Windows commands that will in fact work in some cases.

  • To break out of the vi editor, I selected a series of keys that, when pressed in sequence, help stop the running program and return me to the normal shell prompt. The command sequence I used in this example was pressing the Ctrl key and holding it and then selecting the z key. This interrupted the program and returned me to the shell prompt. Some helpful commands are as follows:

    • [Ctrl+d] This tells the computer that you are done sending input to a command. This is useful if you've accidentally started a program and can't get out.

    • [Ctrl+c] This is the Unix break character. This usually kills any program that is currently running and returns you to a command prompt.

    • [Ctrl+z] This command suspends the process you are currently running and returns you to a command prompt. This is the keystroke sequence I used to break out of the vi editor in the previous example.

Figure 1.1. The terminal is unresponsive because a program is running in the foreground.


Now that you are more familiar with your current environment, let's recap what we've learned about shells. Shells are important, but if you know one, you can usually perform the same commands from shell to shell and have the same functionality with little variance. This book's content is based on the fact that you may not be able to select your shell, so most if not all of the content will apply to any Unix system you may be working with. Remember, as you become a more advanced user, shell selection will become more important.



    SAMS Teach Yourself Unix in 10 Minutes
    Sams Teach Yourself Unix in 10 Minutes (2nd Edition)
    ISBN: 0672327643
    EAN: 2147483647
    Year: 2005
    Pages: 170

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net