O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

which, whereis, file, whatis, and loadavg explained

This recipe aims to explain a few commands we come across. Understanding these commands is helpful for users.

How to do it...

Let's go through each of the commands and their usage examples.

  • which

    The which command is used to find the location of a command. We type commands in the terminal without knowing the location where the executable file is stored.

    When we type a command, the terminal looks for the command in a set of locations and executes the executable file if found at the location. This set of locations is specified using an environment variable PATH. For example:

    $ echo $PATH
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    

    We can export PATH and can add our own locations ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required