- Как добавить каталог в PATH в Linux
- How to Add a Directory to PATH in Linux
- В этой статье показано, как добавить каталоги в ваши $PATH системы Linux.
- Что есть $PATH в Linux
- Добавление каталога в ваш $PATH
- Вывод
- Как добавить каталог в PATH в Linux
- Что такое $PATH в Linux
- Добавление каталога в ваш $PATH
- Выводы
- How to add directory to system path in Linux
- Setting PATH for your current shell session
- Using export to pass the PATH environment variable to child processes
- Setting the PATH variable for every new shell session
- Add Folder To Path Linux Search
- How to add a directory to $PATH on Linux — …
- Search
- How to Add a Directory to PATH in Linux Linuxize
- Search
- Add directory to path in Linux – William’s blog
- Search
- Adding any current directory ‘./’ to the search path in …
- Search
- How to add directory to system path in Linux
- Search
- How to Add Directory to $PATH Variable in Linux
- Search
- How to find a folder in Linux using the command line
- Search
- How can I set all subdirectories of a directory into …
- Search
- Linux 101: How to add directories to your Linux $PATH
- Search
- environment variables — How to add a directory to the …
- Search
- How to Add a Directory to PATH on CentOS 8
- Search
- How to Add Directory to PATH in Linux — TecNStuff
- Search
- Adding a Path to the Linux PATH Variable Baeldung …
- Search
- configuration — Adding a directory to $PATH in CentOS
- Search
- How to add directories to your $PATH in Linux — …
- Search
- [SOLVED] Add folder to $PATH — Linux Mint Forums
- Search
- Add folders to search path — MATLAB addpath
- Search
- Add a directory to PATH in ZSH — Koen Woortman
- Search
- command line — Adding a directory to the PATH …
- Search
- Understanding file paths and how to use them in Linux
- Search
- Find Files and Directories on Linux Easily – devconnected
- Search
- TCSH / CSH Shell Set PATH Variable — nixCraft
- Search
- How to add shared libraries to Linux’s system library path
- Search
- Find Path of a Command with whereis — Linux Hint
- Search
- environment variables — Add bash script folder to path
- Search
- shell — adding programs to path — Unix & Linux Stack …
- Search
- How to set your $PATH variable in Linux …
- Search
- How to find path of any folder or file using locate and
- Search
- Setting your search path — Linux Migration
- Search
- How to Set the $PATH Variable in Linux — MUO
- Search
- How do I add /usr/local/bin to path — Arch Linux …
- Search
- Add A Directory To A PATH Environment Variable On …
- Search
- Linux — Library Path (LD_LIBRARY_PATH, LIBPATH, …
- Search
- How to set the PATH variable in Linux — Putorius
- Search
- Add Folders to the MATLAB Search Path at Startup — …
- Search
- Linux path environment variable — Linux Tutorials — …
- Search
- How To Find a File In Linux From the Command Line — …
- Search
- How to Access Windows Shared Folder from Linux — …
- Search
- Search
Как добавить каталог в PATH в Linux
How to Add a Directory to PATH in Linux
В этой статье показано, как добавить каталоги в ваши $PATH системы Linux.
Когда вы вводите команду в командной строке, вы в основном говорите оболочке запустить исполняемый файл с заданным именем. В Linux эти исполняемые программы , такие как ls , find , file и другие, как правило , живут внутри несколько различных каталогов в вашей системе. Любой файл с разрешением на выполнение, хранящийся в этих каталогах, может быть запущен из любого места. Наиболее распространенные каталоги , которые содержат исполняемые программы /bin , /sbin , /usr/sbin , /usr/local/bin и /usr/local/sbin .
Но как оболочка узнает, в каких каталогах искать исполняемые программы или оболочка выполняет поиск по всей файловой системе?
Ответ прост. Когда вы вводите команду, оболочка ищет во всех каталогах, указанных в пользовательской $PATH переменной, исполняемый файл с таким именем.
Что есть $PATH в Linux
$PATH Переменная окружающей среды является двоеточиями список каталогов, сообщает оболочке , какие каталоги для поиска исполняемых файлов.
Чтобы проверить, какие каталоги у вас есть $PATH , вы можете использовать команду printenv или echo :
Вывод будет выглядеть примерно так:
Если у вас есть два исполняемых файла с одинаковым именем, расположенные в двух разных каталогах, оболочка запустит файл, который находится в каталоге, который стоит первым в $PATH .
Добавление каталога в ваш $PATH
Есть ситуации, когда вы можете захотеть добавить другие каталоги в $PATH переменную. Например, некоторые программы могут быть установлены в разных местах, или вы можете захотеть иметь выделенный каталог для ваших личных записей, но сможете запускать их без указания абсолютного пути к исполняемым файлам. Для этого вам просто нужно добавить каталог в свой $PATH .
Допустим, у вас есть каталог с именем, bin расположенный в вашем домашнем каталоге, в котором вы храните свои сценарии оболочки. Чтобы добавить каталог к вашему $PATH типу в:
Команда export экспортирует измененную переменную в дочерние среды процессов оболочки.
Теперь вы можете запускать свои скрипты, просто набрав имя исполняемого скрипта без указания полного пути к исполняемому файлу.
Однако это изменение носит временный характер и действует только в текущем сеансе оболочки.
Чтобы сделать изменение постоянным, вам нужно определить $PATH переменную в файлах конфигурации оболочки. В большинстве дистрибутивов Linux при запуске нового сеанса переменные среды считываются из следующих файлов:
Конфигурационные файлы глобальной оболочки, такие как /etc/environment и /etc/profile . Используйте этот файл, если вы хотите, чтобы новый каталог был добавлен всем системным пользователям $PATH .
Конфигурационные файлы для отдельных пользовательских оболочек. Например, если вы используете Bash, вы можете установить $PATH переменную в
/.bashrc файле, а если вы используете Zsh — имя файла
В этом примере мы установим переменную в
/.bashrc файле. Откройте файл в текстовом редакторе и добавьте в конце следующую строку:
Чтобы подтвердить, что каталог был успешно добавлен, напечатайте его значение $PATH , набрав:
Вывод
Добавить новые каталоги в вашу пользовательскую или глобальную $PATH переменную довольно просто. Это позволяет выполнять команды и сценарии, хранящиеся в нестандартных местах, без необходимости вводить полный путь к исполняемому файлу.
Те же инструкции применимы для любого дистрибутива Linux, включая Ubuntu, CentOS, RHEL, Debian и Linux Mint.
Источник
Как добавить каталог в PATH в Linux
Когда вы вводите команду в командной строке, вы в основном говорите оболочке запустить исполняемый файл с заданным именем. В Linux эти исполняемые программы, такие как ls , find , file и другие, обычно find в нескольких разных каталогах вашей системы. Любой файл с исполняемыми разрешениями, хранящийся в этих каталогах, может быть запущен из любого места. Наиболее распространенные каталоги, содержащие исполняемые программы, — это /bin , /sbin , /usr/sbin , /usr/local/bin и /usr/local/sbin .
Но как оболочка узнает, в каких каталогах искать исполняемые программы? Оболочка выполняет поиск по всей файловой системе?
Ответ прост. Когда вы вводите команду, оболочка просматривает все каталоги, указанные в $PATH пользователя, в поисках исполняемого файла с таким именем.
В этой статье показано, как добавить каталоги в $PATH в системах Linux.
Что такое $PATH в Linux
Переменная среды $PATH представляет собой список каталогов, разделенных двоеточиями, который сообщает оболочке, в каких каталогах следует искать исполняемые файлы.
Чтобы проверить, какие каталоги находятся в вашем $PATH , вы можете использовать команду printenv или echo :
Результат будет выглядеть примерно так:
Если у вас есть два исполняемых файла с одинаковым именем, расположенных в двух разных каталогах, оболочка запустит файл, который находится в каталоге, который идет первым в $PATH .
Добавление каталога в ваш $PATH
Бывают ситуации, когда вы можете захотеть добавить другие каталоги в $PATH . Например, некоторые программы могут быть установлены в разных местах или вы можете захотеть иметь специальный каталог для ваших личных сценариев, но иметь возможность запускать их, не указывая абсолютный путь к исполняемым файлам. Для этого вам просто нужно добавить каталог в ваш $PATH .
Допустим, у вас есть каталог bin расположенный в вашем домашнем каталоге, в котором вы храните сценарии оболочки. Чтобы добавить каталог в ваш $PATH введите:
Команда export экспортирует измененную переменную в среду дочернего процесса оболочки.
Теперь вы можете запускать свои сценарии, вводя имя исполняемого сценария без необходимости указывать полный путь к файлу.
Однако это изменение носит временный характер и действует только в текущем сеансе оболочки.
Чтобы сделать изменение постоянным, вам необходимо определить $PATH в файлах конфигурации оболочки. В большинстве дистрибутивов Linux при запуске нового сеанса переменные среды считываются из следующих файлов:
Глобальные файлы конфигурации оболочки, такие как /etc/environment и /etc/profile . Используйте этот файл, если хотите, чтобы новый каталог был добавлен всем пользователям системы $PATH .
Файлы конфигурации для конкретной оболочки пользователя. Например, если вы используете Bash, вы можете установить $PATH в файле
/.bashrc . Если вы используете Zsh, имя файла
В этом примере мы установим переменную в файле
/.bashrc . Откройте файл в текстовом редакторе и добавьте в конец следующую строку:
Сохраните файл и загрузите новый $PATH в текущий сеанс оболочки с помощью source команды:
Чтобы убедиться, что каталог был успешно добавлен, распечатайте значение вашего $PATH , набрав:
Выводы
Добавить новые каталоги к вашему пользователю или глобальной $PATH довольно просто. Это позволяет выполнять команды и сценарии, хранящиеся в нестандартных местах, без необходимости вводить полный путь к исполняемому файлу.
Те же инструкции применимы для любого дистрибутива Linux, включая Ubuntu, CentOS, RHEL, Debian и Linux Mint.
Не стесняйтесь оставлять комментарии, если у вас есть вопросы.
Источник
How to add directory to system path in Linux
In Linux, the PATH environment variable stores the names of paths that will be searched for the executable files of any commands typed in the command line. The value of the PATH environment variable is a string containing a series of pathnames, each delimited by a colon. For instance, the default PATH on a typical system might look like this:
When you type a command such as cat and press Enter , the shell searches each of these directories for an executable file named cat. The first one it finds is the one it runs.
To view the current value of your PATH environment variable, you can use the echo command. As with all variables in the shell, when referring to the value you need to put a dollar sign before the variable name:
In the above example, the current value of path return you to the command prompt.
Setting PATH for your current shell session
You can set the value of PATH as you would any other shell variable, with the form NAME=VALUE, like this:
The problem with this command is that it will completely overwrite the values you had before, which you probably don’t want. If you want to add a new value in addition to the old ones. You can accomplish this by referring to PATH in the new definition, like this:
Using the command above adds your new path to the current value of PATH. Since the pathnames are searched in order, you probably want to add your new path at the end of the variable as we’ve done here. Instead, if you typed:
Your new path would be searched before, not after, the default system paths.
Using export to pass the PATH environment variable to child processes
This type of PATH definition sets the environment variable for your current shell session, but any new programs you run might not see the new path you’ve added. That’s because your shell lets you control the environment by requiring you to manually declare what environment variables are passed on to other programs and processes. You can accomplished this with the export command. If you run:
Any processes you run until you log out use the current value of PATH.
If you prefer, you can combine these two commands into a single line, for convenience. Put a semicolon between them so that the shell knows they’re separate commands:
If any of your pathnames have spaces in them, enclose the variable definition in quotation marks, to be safe.
Setting the PATH variable for every new shell session
The methods we’ve used so far only sets the environment variable for your current shell session; when you logout or close the terminal window, your changes will be forgotten. If you want to set PATH to a certain value every time you log in or start a new shell session, add it to your bash startup script. Every time you start an interactive shell session, bash reads the following files in order (if they exist), and executes the commands inside of them:
The first file, /etc/profile, is the default startup script for every user on the system. One or more of the remaining three files are located in the home directory of every user. Any of those three can be used, but it’s important to know that they will be searched for in this order.
You can edit these files and manually change any lines containing PATH= definitions. Be careful if you do so, because these are the directories used to locate important operating system files.
If you want to add a path for your current user only, you can leave the other PATH= lines untouched. Add a line like this to the end of the file:
If you add this to the end of the .bash_profile file in your home directory, it takes effect every time your user starts a new shell session. If you add this to /etc/profile, it takes effect for every user on the system. Note that you need administrator privileges if you want to edit /etc/profile, so you can use sudo (or be logged in as root) to do so.
Источник
Add Folder To Path Linux Search
How to add a directory to $PATH on Linux — …
Search
› Verified 2 days ago
How to Add a Directory to PATH in Linux Linuxize
Search
› Verified 4 days ago
Add directory to path in Linux – William’s blog
Search
› Verified 8 days ago
Adding any current directory ‘./’ to the search path in …
Search
› Verified 1 days ago
How to add directory to system path in Linux
Search
› Verified 8 days ago
How to Add Directory to $PATH Variable in Linux
Search
› Verified 3 days ago
How to find a folder in Linux using the command line
Search
› Verified 3 days ago
How can I set all subdirectories of a directory into …
Search
/scripts), so their security is the same. – MestreLion Dec 31 ’15 at 12:14
› Verified 4 days ago
Linux 101: How to add directories to your Linux $PATH
Search
› Verified 9 days ago
environment variables — How to add a directory to the …
Search
› Verified 2 days ago
How to Add a Directory to PATH on CentOS 8
Search
› Verified 8 days ago
How to Add Directory to PATH in Linux — TecNStuff
Search
› Verified Just Now
Adding a Path to the Linux PATH Variable Baeldung …
Search
› Verified 4 days ago
configuration — Adding a directory to $PATH in CentOS
Search
› Verified 7 days ago
How to add directories to your $PATH in Linux — …
Search
› Verified 2 days ago
[SOLVED] Add folder to $PATH — Linux Mint Forums
Search
› Verified 9 days ago
Add folders to search path — MATLAB addpath
Search
› Verified 4 days ago
Add a directory to PATH in ZSH — Koen Woortman
Search
› Verified 1 days ago
command line — Adding a directory to the PATH …
Search
› Verified 6 days ago
Understanding file paths and how to use them in Linux
Search
› Verified 6 days ago
Find Files and Directories on Linux Easily – devconnected
Search
As a reminder, here is how file permissions work on Linux. To find all files that have full permissions (a 777 given the binary notation), you can run the following command
› Verified 8 days ago
TCSH / CSH Shell Set PATH Variable — nixCraft
Search
› Verified Just Now
How to add shared libraries to Linux’s system library path
Search
› Verified 1 days ago
Find Path of a Command with whereis — Linux Hint
Search
› Verified 8 days ago
environment variables — Add bash script folder to path
Search
› Verified 8 days ago
shell — adding programs to path — Unix & Linux Stack …
Search
› Verified 1 days ago
How to set your $PATH variable in Linux …
Search
› Verified Just Now
How to find path of any folder or file using locate and
Search
› Verified 3 days ago
Setting your search path — Linux Migration
Search
› Verified 3 days ago
How to Set the $PATH Variable in Linux — MUO
Search
› Verified 3 days ago
How do I add /usr/local/bin to path — Arch Linux …
Search
› Verified 8 days ago
Add A Directory To A PATH Environment Variable On …
Search
› Verified 7 days ago
Linux — Library Path (LD_LIBRARY_PATH, LIBPATH, …
Search
› Verified 8 days ago
How to set the PATH variable in Linux — Putorius
Search
/.bash_profile file. This file is read every time you login, so the PATH variable will be set and ready. NOTE: The tilde (
) is a special function meaning your home directory.
› Verified 3 days ago
Add Folders to the MATLAB Search Path at Startup — …
Search
› Verified 8 days ago
Linux path environment variable — Linux Tutorials — …
Search
› Verified 5 days ago
How To Find a File In Linux From the Command Line — …
Search
› Verified 2 days ago
How to Access Windows Shared Folder from Linux — …
Search
› Verified 9 days ago
/.local/share/fonts to search path for linux · Issue
Search
/.local/share/fonts/, which according to the arch linux wiki is the recommended path for user fonts:. To install fonts system-wide (available for all users), move the folder to the /usr/share/fonts/ directory. . The files need to be readable by
Источник