Welcome guest


Add/Attach

When you type a command at the eos% prompt, a program called the "shell" actually interprets your command and tries to do what you ask. The first thing the shell does is try to determine if the command that you typed is a real command. If it is, then it tries to determine if the pathname you gave the command is valid. If that also is valid, then the command will execute. If it is not, you will get an error message, and your command will not execute.

In determining whether your command is valid, the shell has several places (pathnames) that it searches through in order to find commands and filenames. This list of pathnames is called the path variable, which is assigned to point to several default paths when you log in. If you want to see what pathnames and directories your shell looks through when you type commands, type the following at an eos% prompt.

eos% printenv PATH

printenv is a command that stands for "print environment variable," and in this case you want to know about the PATH variable. Notice that PATH is in all capital letters.

There is a special directory on the file tree under the root directory called "ncsu." That is, "/ncsu." This directory can be thought of as "floating" in space and not really connected directly to the file tree. The reason this directory is special is that pathnames to certain directories may be "attached" to it. The "/ncsu" directory is one of the places your PATH variable points to, so if you attach a path to the "/ncsu" directory then the shell can find it.

Add and attach are two special UNIX commands that let you attach pathnames to the "/ncsu" directory.

Attach

The attach command lets you connect a locker or a directory to the "/ncsu" directory so that you can cd to that location by typing cd /ncsu/lockername or cd /ncsu/directoryname instead of its full path. A handy shortcut.

The syntax to use the attach command is:

eos% attach locationname

where locationname is the name of the locker or the directory that you are attaching.

You can then get into the locker or directory by typing:

eos% cd /ncsu/locationame

This is much shorter than having to type in the full pathname. For example, here's how you would attach the E115 locker, e115

eos% attach e115
eos% cd /ncsu/e115


instead of:

eos% cd /afs/eos.ncsu.edu/courses/e/e115/

Add

The add command will also let you change directory to a location by using the "/ncsu" directory, but it will also do one important thing that you need to know about. The add command will let you run a program that is located in the locker you have added by simply typing its filename. Add actually appends your PATH statement so the shell can find programs that are located in the directory you have added.

Add does this through a file called .environment in the locker (or directory) that you are adding. The .environment file is basically a series of commands that you might normally type at the eos% prompt. When you add the locker, the commands in the .environment file get executed, just as if you were typing them in one by one. This means that any permissions you have, the .environment file also has. For lockers this is not a problem. However, this could have disastrous results if you add a users directory and they have a .environment file. They could issue a series of commands that would give them access to all your files, after which they could delete all of your files. Basically, whatever you could do to mess up your account, they could also do.

You should NEVER add another user's directory. Attaching it is fine. That does not run the .environment file. Only class lockers should be added.

With many commands on Eos/Unity, if you type just the command without any options or filenames at the prompt, you will get a message telling you how the command is used. The add command deviates from this "standard." If you enter the add command on the command-line by itself it will print out a list of all the software packages on the Eos/Unity system that can be added.

Notes to Remember About Add and Attach

  • Add and attach let you use the "/ncsu" directory to quickly change directory to a locker you've attached.
  • Add lets you run a program that is located in a directory that you have added.
  • If you add or attach a directory, it is only added or attached in that Terminal. It is not automatically attached or added in any other Terminals you have open.
  • If you add or attach a directory, it is only added or attached until you logout (or exit that Terminal).
  • You should never add a users directory. Only use attach.
  • If you type:
    eos% add

    it will list all the software packages that can be added.