Chapter -7.2 : Navigating Directories, Locating Apps, and Essential Commands

Executable programs and scripts should live in the "/bin" or "/usr/bin" or "/sbin" or '/usr/sbin" or "/opt" or /usr/local/bin and /usr/local/sbin. To know more about some well-known top-level Linux directory list and their purposes refer to the given image:

Locating Applications :

One way to locate program is to employ the which utility. Exaple - To find out where the diff program resides on the file system you can do :

which diff

"whereis" is a good alternative to the above command. For example -

whereis firefox

Accessing Directories :

When you first login into a system or open a terminal the default directory should be your home directory. To print the exacy path :

echo $HOME

Some essential commands :

pwd : Displays the present working directory .

cd ~ : Change to your home directory(~ is called tilde).

cd .. : change to parent directory.

cd - : change to previous directory.

another way is to use pushd and popd. Example:

pushd /tmp : changes to tmp directory.

popd /home : returns to home directory.

There are two ways to identify paths :

  • Absolute Path : Follows the root directory (Starts with slash)

  • Relative Path : Follows the present working directory (does not starts with a slash).Relative path is convinient to use.

. is for present directory

.. is for parent directory

~ is for your home directory

Exploring the Filesystem :

The tree command is good for a bird eye view as traversing up and down of a filesystem can be tedious.

tree : Displays a tree view of the filesystem.