|
|
Because the system uses symbolic links extensively, you may encounter problems in identifying your current working directory. For example, suppose you create a symbolic link to a directory, then change directory using the new link, as follows:
$ ln -s /u/workgrp/tasks/projects mydata $ pwdIn this example, you create a symbolic link called mydata, pointing to /u/workgrp/tasks/projects. However, if you change directory via the link mydata, you actually see yourself as being in /u/people/mike/mydata. This is the logical present working directory; that is, the path the user traversed to reach the directory. The directory also has a physical path, that is, the actual pathname of the current directory, relative to the top of the filesystem./u/people/mike
$ cd mydata $ pwd/u/people/mike/mydata
$
Now you are in /u/workgrp/tasks/projects. Suppose you create another symbolic link and change directory into it:
$ ln -s /u/people people $ pwdWhen you change directory into people, you are following a link to /u/people. This is higher in the directory tree than your original starting point, but because you are traversing another symbolic link, your logical present working directory is another level down the tree./u/people/mike/mydata
$ cd people $ pwd/u/people/mike/mydata/people
$
If you then type cd .. (to go up a directory), where you end up depends on your shell. If you are running the Korn shell, the cd .. command goes up a level in your logical directory path: /u/people/mike/mydata becomes your present working directory. If you are running any other shell, the cd .. command goes up a level in your physical directory path: /u becomes the present working directory.
Despite the apparent complexity, it is possible to determine your physical working directory in a directory tree populated with symbolic links. There are two techniques, for Korn shell users and for others:
The equivalent commands, in any other shell, always apply to the physical working directory.