where can I find the description/details of the custom commands. In my linux server there is a custom command named qsubm that I need to check, but I don't know where it is written.

| improve this question | | | | |

If you're using bash, the best way to find out is

type -a qsubm

Whether it's a shell function, an alias, or an executable, this will tell you.

Let's pretend for a moment that you get the answer "qsubm is /usr/bin/local/qsubm". The next thing you should do is check what file type that is:

file /usr/bin/local/qsubm

If it's a binary executable, you're done. You can't look at it directly and your best bet is to check around on your system or on the internet for related man pages or for source code.

However, if it is "POSIX shell script executable" or "Bourne shell script" or similar, you can inspect the text file directly with less:

less /usr/bin/local/qsubm

Use the space bar (or f) to go forward, and b to go back. Press q to quit.

For alternatives to type and more history than you probably ever wanted to read, check out:

| improve this answer | | | | |
  • To forestall inevitable corrections: Yes, I know you can inspect a binary executable directly. But for most people (unless you know machine code), that won't be useful. This is a beginner-level answer. – Wildcard Aug 9 '16 at 17:28
  • 1
    even if you do know machine code, modern C compiler optimizations make it pretty hard to do. Not to mention modern amd64 architecture CPUs have about four gazillion instructions. – Wyatt8740 Aug 9 '16 at 19:07

You can always look for command thanks to "whereis" command and check it. If you find nothing, then this command is not a binary but rather alias. Try also write a qsubm --help or man qsubm

By the way is qsubm this http://gridscheduler.sourceforge.net/htmlman/htmlman1/qsub.html ?

| improve this answer | | | | |

Also locate is a great tool to find files. It's part of the mlocate package if you're on a linux flavor. You'll have to make sure your locate database is up to date. I use /usr/libexec/updatedb to do it but updatedb might just be in your path. Then just execute:

$ locate qsubm

| improve this answer | | | | |

To amplify Wildcard's excellent answer, command -v qsubm is the POSIX-standard way to print the full pathname to an executable. That works in almost all Bourne shells nowadays, including bash. command -V qsubm produces a more verbose report if implemented, and will usually show alias definitions.

You want to use a shell built-in. The shell you're using has its own logic for executing commands, and is the best reference for what it will do. External commands such as locate and whereis do not have access to that logic, and can only make educated guesses based on common conventions.

| improve this answer | | | | |
  • locate indexes the entire filesystem and shows where the filename matches are without having to deal with $PATH. – jbrahy Aug 9 '16 at 23:14

Depends on what you mean by custom commands.

Sometimes I make custom commands by writing new bash/sh functions:

example ()
    enter custom code here

You can retrieve the code, after the fact, with declare -f example.

Hope that helps.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.