Directory
The UNIX concept of a directory is just like the Mac concept of a folder. Directories hold files and other directories. The UNIX system contains lots of directories in a nested structure.

Subdirectory
A subdirectory is simply a directory that is inside another directory. Since UNIX only has one top level directory, called the root directory, every other directory can technically be called a subdirectory.

Root directory
The top of the directory hierarchy on any UNIX system. It is represented by the directory named with just a slash, as in /.

Current or Present working directory
The current or present working directory is the default directory for UNIX commands. For example, using ls by itself lists files in the current directory. If you want to access files other than in the current directory, you have to use either a relative pathname or a full (absolute) pathname.

Home directory
When you log in, your current directory is your home directory. In the home directory are all your files and subdirectories. For example, the home folder for the user cecmi is
    /home/cecmi
which means that cecmi's home directory is under the home directory, which is under the root directory /.

Path or Pathname
A path or pathname is simply the set of directories that have to be traversed to get to a file. In other words, it is a way of giving an address for the location of a file, like a mailing address for a letter. An example path would be:

Example 1. Example of a pathname:
        homework/ch2/prog1.cpp

which refers to a file called prog1.cpp in the directory ch2, under the directory homework under whatever your current directory is. Note the use of the slash (/) to separate the pieces.

Full or Absolute pathname
A full pathname is just a path that starts at the root directory, i.e., begins with the slash (/) character:

Example 2. Example of an absolute pathname:
        /usr/bin/man

which is the location of the man command.

Example 3. Another example wth an absolute pathname:
     /home/cecmi/homework/ch2/prog1.cpp

Relative pathname
A relative pathname is just a path that starts from your current directory, and thus, doesn't start with a slash (/) character.

Example 4. Example with a relative pathname:
         homework/test1

which refers to the file test1 in the subdirectory homework under your current directory.

Ultima modificare: marți, 2 mai 2023, 17:03