Becoming familiar with your file system layout is all part of becoming a competent user - any time you spend with that aim in mind is not time wasted. However, with that said, you can indeed make it easier to move around the file system. Note that in Linux/UNIX, the file system is presented as a single tree, no matter how many devices make up your storage, unlike in Windows where each "drive" (physical or logical, depending on your configuration) is represented, in the default configuration, by an independent tree.
There are numerous ways you can approach this problem. It is certainly possible to set up a bunch of shell variables that each point to a different directory. Issuing cd $SomeDir
will cause the shell to expand the variable $SomeDir
and substitute it in the command line, so that when it finally runs, cd
receives the name of the directory stored in the variable. This is probably the simplest approach, and if you populate your shell variables with absolute paths, it should work from anywhere in the file system.
You could also use symbolic links to target directories (hard links to directories are not supported in most UNIXs). However, for this to be effective, you'd still need to give sufficient information in the path argument to allow the kernel to resolve the symlink. That is, you'd need to provide the absolute path to the symlink, or enough of a relative path to allow the kernel to find the link, so it could then follow it.
A further approach, which may or not be available, depending on your shell, is to use the shell's cdpath
feature. This is supported in bash
, zsh
, tcsh
and undoudtedly others. With this technique, you set the environment variable CDPATH
to a colon-separated list of directory names, which is searched when you run cd
. If one of the directories on $CDPATH
contains a subdirectory whose name matches that passed to cd
, the shell changes its current working directory. For example, if CDPATH
contains /usr/local
, and if your system has a directory /usr/local/www
, issuing cd www
will look up the contents of $CDPATH
, try to find a subirectory of /usr/local
called www
, and if it exists, will change its current working directory to /usr/local/www
. Note that the shell searches the directories in $CDPATH
in the order they are specified, so if $CDPATH
contains multiple directories that contain the subdirectory you pass as argument to cd
, the first match wins. This has caught me out often enough that I no longer us cdpath
.