Полезная информация

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 4.1 What? Me, Organized? Chapter 4
Organizing Your Home Directory
Next: 4.3 Organizing Nonexecutable Scripts

4.2 A bin Directory for Your Programs and Scripts

If you compile programs (52.8) or write shell scripts (1.5), it's good to put them in one directory. This can be a subdirectory of your home directory. Or, if several people want to use these programs, you could pick any other directory - as long as you have write access to it. Usually, the directory's name is something like bin-though I name mine .bin (with a leading dot) (1.15) to keep it from cluttering my ls listings.

  1. For instance, to make a bin under your home directory, type:

    % cd
    % mkdir bin

  2. Once you have a directory for storing programs, be sure that the shell can find the programs in it. Type the command echo $PATH and look for the directory's pathname. For instance, if your directory is called /u/walt/bin, you should see:

    % echo $PATH

    If the directory isn't in your PATH, add it (8.7).

  3. Finally, if other people are sharing the directory, use a command like chmod go+rx bin (22.7) to give them access.

When you add a new program to your bin directory, if you use the C shell, you need to use the shell's rehash command. That's because the C shell doesn't search your path directly but instead uses a hash table to find the commands more quickly.

- JP

Previous: 4.1 What? Me, Organized? UNIX Power ToolsNext: 4.3 Organizing Nonexecutable Scripts
4.1 What? Me, Organized? Book Index4.3 Organizing Nonexecutable Scripts

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System