Not everything is open source, even on Linux so assuming the source code isn't available to you for some reason, perhaps just because you don't want to bother with searching the source code and downloading it or viewing it online, you might find clues by looking for strings in the command binary file.
The strings
command is precisely designed to extract readable strings from a binary file.
For example, you now the the ls
command is accepting the -T <tabsize>
option, so assuming it is using getopt
to parse its arguments, the sequence of characters T:
should be in the getopt
option list.
This is indeed the case:
$ strings /bin/ls | grep T:
abcdfghiklmnopqrstuvw:xABCDFGHI:LNQRST:UXZ1
All the letters are options so you can then verify if all are documented or not.
You might also look for long options but unless you have already a clue about what the hidden option names might be, it is more complex as you need to have a look to all the strings.
Should you already know one of the long options, you might limit your search to the strings appearing close to them.
Staying with the ls
case, you'll find all these strings around the tabsize
option:
$ strings /bin/ls | less
...
no-group
hide-control-chars
reverse
almost-all
ignore-backups
classify
file-type
dereference-command-line
hide
ignore
dereference
literal
quote-name
recursive
show-control-chars
tabsize
time-style
block-size
context
author
help