D
D
Dmitry2015-12-07 11:43:48
linux
Dmitry, 2015-12-07 11:43:48

Where in Linux are the basic commands available without the PATH environment variable defined?

After overwriting the PATH variable, I thought /bin was checked by default.
As it turned out, the echo and pwd commands (both in /bin) remain available, but cat, which is also located in /bin, becomes unavailable
How sh finds echo and pwd without specifying the full path to them with an empty PATH environment variable and where you can see the full list commands available under this condition?
PS If there are any links to more advanced books / sources on the topic, I will also be grateful.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Saboteur, 2015-12-07
@Liro

Linux does not look for any commands if PATH is empty. The search for external executable files is ONLY in the directories that are registered in the PATH.
In Windows, the current directory is always checked beforehand, in addition, there are a lot of aliases through like dosset and the registry
in Linux, commands can be:
built into the shell (pwd, echo)
alias, which can refer to an external program
External files that are in folders specified in PATH
you can find out which command is internal or external using the type command or which:
$ type type
type is a shell builtin
$ type which
which is /usr/bin/which

R
romy4, 2015-12-07
@romy4

echo and pwd are shell commands

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question