Я следовал многим руководствам и книгам для понимания PATH
переменное понятие, но ни один из них не объясняет "полностью", как это работает в Linux.
Например, если я установил Путь как следующее в Bash:
export PATH="$VIRTUALENVWRAPPER_PYTHON:/home/ujjval/anaconda2/bin/python:/bin:/usr/bin"
Это устанавливает путь названной переменной VIRTUALENVWRAPPER_PYTHON
как каталоги, данные право?
После этого, например, если я делаю
export PATH="/usr/bin:bin:PATH"
Предыдущее значение ПУТИ будет перезаписано? Кроме того, что делает :PATH
в средствах конца?
Кроме этого, если я пишу в моем ./bashrc
файл
export PATH="$VIRTUALENVWRAPPER_PYTHON:/home/ujjval/anaconda2/bin/python:/bin:/usr/bin"
действительно ли это отличается от вышеупомянутых двух методов устанавливания пути?
export PATH="$VIRTUALENVWRAPPER_PYTHON:/home/ujjval/anaconda2/bin/python:/bin:/usr/bin"
Наборы PATH
для Вашей текущей оболочки, с помощью значения $VIRTUALENVWRAPPER_PYTHON
в то время.
export PATH="/usr/bin:bin:PATH"
повреждения Ваш PATH
(где bin
? Что PATH
). это должно быть:
export PATH="/usr/bin:/bin:$PATH"
для использования предыдущего значения [1 110].
И да, последующие присвоения на [1 111] предыдущие значения перезаписи.
PATH="$VIRTUALENVWRAPPER_PYTHON:/home/ujjval/anaconda2/bin/python:/bin:/usr/bin"
наборы Ваш PATH
к текущему значению [1 113], возможный единственный файл (то, которое является неправильным - [действительно ли 1114], является файлом или каталогом? Это должно быть /home/ujjval/anaconda2/bin
?), и два из системных каталогов, игнорируя предыдущее значение [1 116].
Игнорирование предыдущего PATH
небезопасно. Например, Ubuntu добавила /snap/bin
к значению по умолчанию PATH
, когда Поспешная поддержка началась. (см. /etc/profile.d/apps-bin-path.sh
). Ваши методы потеряют след этого каталога.
Вот то, как PATH
(двоеточие разделило список каталогов) работы (от [1 122]:
COMMAND EXECUTION
After a command has been split into words, if it results in a simple command and an
optional list of arguments, the following actions are taken.
If the command name contains no slashes, the shell attempts to locate it. If there exists
a shell function by that name, that function is invoked as described above in FUNCTIONS.
If the name does not match a function, the shell searches for it in the list of shell
builtins. If a match is found, that builtin is invoked.
If the name is neither a shell function nor a builtin, and contains no slashes, bash
searches each element of the PATH for a directory containing an executable file by that
name. Bash uses a hash table to remember the full pathnames of executable files (see hash
under SHELL BUILTIN COMMANDS below). A full search of the directories in PATH is
performed only if the command is not found in the hash table. If the search is
unsuccessful, the shell searches for a defined shell function named
command_not_found_handle. If that function exists, it is invoked with the original
command and the original command's arguments as its arguments, and the function's exit
status becomes the exit status of the shell. If that function is not defined, the shell
prints an error message and returns an exit status of 127.
If the search is successful, or if the command name contains one or more slashes, the
shell executes the named program in a separate execution environment. Argument 0 is set
to the name given, and the remaining arguments to the command are set to the arguments
given, if any.
If this execution fails because the file is not in executable format, and the file is not
a directory, it is assumed to be a shell script, a file containing shell commands. A
subshell is spawned to execute it. This subshell reinitializes itself, so that the effect
is as if a new shell had been invoked to handle the script, with the exception that the
locations of commands remembered by the parent (see hash below under SHELL BUILTIN
COMMANDS) are retained by the child.
If the program is a file beginning with #!, the remainder of the first line specifies an
interpreter for the program. The shell executes the specified interpreter on operating
systems that do not handle this executable format themselves. The arguments to the
interpreter consist of a single optional argument following the interpreter name on the
first line of the program, followed by the name of the program, followed by the command
arguments, if any