This page was generated from 04.home.mth.

This page is part of the course work for CS360: Systems Tools course offered by the Computer Science Department at CalState, San Bernardino, California, USA. It was generated by Dr. Dick Botting.

Contents


    Make Yourself a Home

    cs360/notes/04.home

    Why

    1. You need to able to find data and programs quickly and easily.

    2. You don't want to
      1. lose things,
      2. share private things,
      3. list irrelevant things,
      4. execute bad things,
      5. look untidy
      6. ...

    3. It doesn't take much time to do and it makes your life much easier.

    . . . . . . . . . ( end of section Why) <<Contents | End>>

    Sections


    (why): 4.01
    (exam): 4.02, 4.06, 4.09
    (useful): 4.02, 4.05, 4.06, 4.07, 4.09
    (perhaps): 4.03
    (skip): 4.04, 4.08, 4.10

    Facts

    In UNIX you are given a directory and you can make directories in it, and inside them as well.(4.01).

    Chapter 4 is full of things you should as soon as possible... see [ Exercises ]

    It also has some things that you may want to do later or only if you need them: 4.03, 4.04

    If you write programs, put your source code in directories called 'src'. This is universally pronounced 'sors'. Also use the normal rules for suffices: [ What do I name files in CS_FAQ ]

    You need to think about the names of files - read 4.06.

    Here is another trick I have invented. Suppose you are writing a term paper for a certain class with five parts called

        what
        correct
        good
        bad
        interesting
    These need to be in that order. Obviously, you make a directory called 'paper' for the class. You also (obviously) have 5 files, one for each part, but if you use the obvious names UNIX lists them in the wrong order:
        bad
        correct
        good
        interesting
        what
    So number the parts:
        1.what
        2.correct
        3.good
        4.bad
        5.interesting
    As a result, UNIX lists them in the right order. MORE.... A wild card (*) will expand into the files in the right order as well:
     echo cs360/paper/*
    becomes
     echo cs360/paper/1.what cs360/paper/2.correct cs360/paper/3....
    But there is even more.... Because the numbers are unique you don't need to type in the whole file name...
     echo cs360/paper/1.*
    is only one file.

    If you have more than 9 files that need numbering -- use two digits: 01,02,03,... then you won't get this sequence 1, 10, 11, 2, 3.... If you have more than 99 files, start to think about some subdirectories(4.07).

    I also keep appointments and "to do"s in a special 'todo' directory. The name is an encoded date:

             19991004
    (october 4th 1999). This means that the directory is in the right sequence, that wild cards can select a year (1997.*.*) or a month (1997.10.*) for me. I've even written a script called
                  today
    that gives me the file name for today... and another script that shows me all due reminders....

    You can customize 'vi' by creating a ".exrc" file. Why is it called ".exrc"??? Because: (1) "vi" is an alternate name for "ex" the extended editor, and "rc" stands for "run commands".

    You'll see a lot of "rc" files in UNIX: ".cshrc", ".newsrc", ".mailrc",... By the way, the "rc" convention goes back to the Honewell computer company! (4.09)


    (4.09): My Q/quickie command can be used to set up .exrc for you. [ Exercises ]

    Finding commands: which, whereis (4.10). The Korn shell has 'whence', and on some of our systems I have written 'Whereis' that ransacks the system for files. On some systems I've written my own 'whence' and 'whereis' anyway. So if the commands don't work on a machine look for

  1. .As_is ~dick/bin/whereis
  2. .As_is ~dick/bin/whence I think Linux and Bash has there own versions of whence.... but I forget what its called! There are some [ Exercises ] that tried these out.

    List of Standard Directory Names

    Standard directory names:
     wrk     working files
     tmp     temporary files that can be removed once used
     bin     binary files and executable scripts
     src     source code for programs
     lib     libraries: data for other programs to use
     adm     Administrative files
     etc     for UNIX system data files
     misc    miscellaneous files
     include header files to be included in C & C++ program
     News    Used by tin and other newsreaders
     Mail    Used by elm for handling mail
     mail    Used by pine for mail messages

    Standard names of directories higher up the tree

     usr     Files need by users but owned by the system
     u  where we put home directories
     var     various variable administrative and temporary files
     sbin    shared binaries
     share   shared directories
     mail    for mail
     local   Things we put on the system
     spool   for things waiting to be processed

    Definitions

  3. mkdir::command, make_a_new_directory, make_a_new_path.
  4. cd::command, change_to_directory.

  5. make_a_new_directory(D)::=mkdir D.
  6. make_a_new_path(P)::=mkdir -p P.

  7. change_to_directory(D)::= cd D. Before D must be an executable directory. Afterwards the CWD is D.

  8. md::DOS_command=UNIX(mkdir).

  9. CWD::=current working directory, -- but not in the Bourne Shell.

  10. rc::convention="run commands" -- last two letters in a file of commands executed when a program starts up.

    See also

    Adding a directory to your PATH: [ 08.shell.html ] [ 08.shell.html ]

    Exercises

    1. Make a 'bin' directory(4.02) and add it (if needed) to your PATH: [ 08.shell.html ] [ 08.shell.html ]

    2. Make a private directory and change its mode so that only you (and superuser) can read it (4.05). You can then make your home directory public with some safety( chmod 755 HOME ). Call the directory anything you like.

    3. Make a private directory for this class: cs360 Move any CS360 files into this directory:
       mv foo cs360/foo

    4. Change directory to cs360
       cd cs360

    5. Return to your home directory:
       cd

    6. Make a short .plan, .signature files and a one line .project file.
       .project     Your role at work or in life
       .plan   Name, other Email addresses, numbers, schedule or motto.
       .signature   Names and addresses, ....

    7. You can also quickly add a a ".exrc" file(4.09) with Q/quickie. You have a choice:
       quickie novice
      or
       quickie setup
      depending on whether you have used "vi" before or not.

      Find a machine/system that will execute the

               whence cat
      and then ask it
               whence whence
      and
    8. .As_is whence rubbish

    . . . . . . . . . ( end of section Exercises) <<Contents | End>>

    Questions

      Note

      Explain (below) does not mean list what is on your computer! It means you have to think about what might be true in general, as well as in the actual case. "Explain what is a coffee pot" does not mean that you measure the amount of coffee pot and report the amount! Don't list all the stains or count the grains. No! To explain a coffee pot say that it is a container usually with coffee in it!

      Explain whose each of these is and what each of them should contain:


      1. /u/faculty/dick/bin ?
      2. /u/faculty/dick/src ?
      3. /dick/cs360/notes
      4. /dick/cs360/notes ?
      5. /u/faculty/dick/lib/cookies ?
      6. /u/faculty/dick/lib ?
      7. /bin ?
      8. /usr/local/bin ?

    . . . . . . . . . ( end of section Questions) <<Contents | End>>

    Submit Your Notes Here

    To earn credit for completing this part of the course you need to send me a short list of things you have learned. A simple way to do this is to follow this [click here [socket symbol] if you can fill this hole] link and fill in the form using.

End