It does not matter what directory you are in. Typing lsof requires that the full path for this command is one of the paths shown in $PATH. If not, the command will not be found. If lsof is actually installed on your system, start with the common locations:
find /usr/local /usr/contrib /opt -name lsof
Then you type the fullpath to the command:
/usr/local/bin/lsof
Or you change the file: /etc/PATH to add /usr/local/bin (or whatever is needed) so that the fullpath can be found.
Bill Hassell, sysadmin