P
P
Pinkman2021-03-24 15:22:57
linux
Pinkman, 2021-03-24 15:22:57

How to get a list of all Linux programs?

Good afternoon! I write shell. You need to make an addition (hints when you press the tab). But I do not know where to get the list of commands / programs.
Somewhere there is probably a folder or file with the name of the programs. Where can I get such a list from a program written in C?
Maybe I'm looking in the wrong direction and there's a better way to implement additions. If that's the case, then I'd love some advice.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Denis Yuriev, 2021-03-24
@famousman204

echo $PATH
/root/.cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

a list of directories with binaries, separated by a colon, that are available in the bash without specifying a direct path
on your system may (even cannot, but definitely) a different list, may differ within one system for different users

S
Saboteur, 2021-03-24
@saboteur_kiev

If you're writing a POSIX-compliant shell, you can just include bash-completion or see how it's organized.
And so - auto-completion is done not according to a specific list, but according to what is in the directories listed in the PATH variable

A
Adamos, 2021-03-24
@Adamos

Tip: take the source of the shell that is taken as a sample and see how it is done in it.

A
aleks-th, 2021-03-24
@aleks-th

But the current that is set by handles may not be present in this list))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question