0

If I run bash with a clean environment, I'd expect the PATH to be empty, however:

odin ~ 210$ env -i bash --norc --noprofile 
bash-4.4$ echo $PATH
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.
bash-4.4$ uname -a
Linux odin 4.10.0-42-generic #46-Ubuntu SMP Mon Dec 4 14:38:01 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
bash-4.4$ 

The PATH is not empty.

I've been through the documentation a couple of times, but perhaps I missed something.

My question: where is this documented?

Thanks.

-E

  • I've found a couple of clues in man bash. (1) In the documentation of the PATH variable, The search path for commands. ... The default path is system-dependent, and is set by the administrator who installs bash. A common value is "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin". (2) In command [-pVv] command [arg ...] documentation, Run command with args suppressing the normal shell function lookup. ... If the -p option is given, the search for command is performed using a default value for PATH that is guaranteed to find all of the standard utilities. .... – AFH Mar 26 '19 at 14:59
  • Splendid! Thanks! I was reading the info documentation since it is usually more complete. Shows what I know. If you put it in an answer, I'll mark it as answered. – Erik Bennett Mar 26 '19 at 15:45
3

I've found a couple of clues in man bash.

(1) In the documentation of the PATH variable:-

PATH The search path for commands. It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION below). A zero-length (null) directory name in the value of PATH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon. The default path is system-dependent, and is set by the administrator who installs bash. A common value is ``/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin''.

(2) In the documentation of command:-

command [-pVv] command [arg ...] Run command with args suppressing the normal shell function lookup. Only builtin commands or commands found in the PATH are executed. If the -p option is given, the search for command is performed using a default value for PATH that is guaranteed to find all of the standard utilities. ...

On Ubuntu 18.04.2 I get the same PATH variable. I noted two things:-

  1. This PATH includes ., but this is generally ill-advised.
  2. In the new bash instance, declare -p PATH shows that PATH is not exported, as in the normal configuration, so env does not show PATH in its environment list.
| improve this answer | |
  • "Where is it documented?" The man page. Duh. In my defense, most GNU commands say, "Full documentation ... available locally via: info" The bash manual does not say this. – Erik Bennett Mar 26 '19 at 18:23
  • 1
    Most info pages contain the man information, with additions sometimes. I've not looked at info bash before, but quite a lot is missing from the man pages. I learned Linux on System V, so man is what I first think of. – AFH Mar 26 '19 at 18:39

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.