ТОП просматриваемых книг сайта:
Linux Bible. Christopher Negus
Читать онлайн.Название Linux Bible
Год выпуска 0
isbn 9781118999882
Автор произведения Christopher Negus
Жанр Зарубежная образовательная литература
Издательство John Wiley & Sons Limited
date
command from the /bin
directory by typing
Of course, this can be inconvenient, especially if the command resides in a directory with a long pathname. The better way is to have commands stored in well-known directories and then add those directories to your shell's PATH
environment variable. The path consists of a list of directories that are checked sequentially for the commands you enter. To see your current path, type the following:
The results show a common default path for a regular Linux user. Directories in the path list are separated by colons. Most user commands that come with Linux are stored in the /bin
, /usr/bin
, or /usr/local/bin
directories. The /sbin
and /usr/sbin
directories contain administrative commands (some Linux systems don't put those directories in regular users' paths). The last directory shown is the bin
directory in the user's home
directory (/home/chris/bin
).
TIP
If you want to add your own commands or shell scripts, place them in the bin
directory in your home directory (such as /home/chris/bin
for the user named chris
). This directory is automatically added to your path in some Linux systems, although you may need to create that directory or add it to your PATH
on other Linux systems. So, as long as you add the command to your bin
with execute permission, you can begin using it by simply typing the command name at your shell prompt. To make commands available to all users, add them to /usr/local/bin
.
Unlike some other operating systems, Linux does not, by default, check the current directory for an executable before searching the path. It immediately begins searching the path, and executables in the current directory are run only if they are in the PATH
variable or you give their absolute (such as /home/chris/scriptx.sh
) or relative (for example, ./scriptx.sh
) address.
The path directory order is important. Directories are checked from left to right. So, in this example, if there is a command called foo
located in both the /bin
and /usr/bin
directories, the one in /bin
is executed. To have the other foo
command run, you either type the full path to the command or change your PATH
variable. (Changing your PATH
and adding directories to it are described later in this chapter.)
Not all the commands you run are located in directories in your PATH
variable. Some commands are built into the shell. Other commands can be overridden by creating aliases that define any commands and options that you want the command to run. There are also ways of defining a function that consists of a stored series of commands. Here is the order in which the shell checks for the commands you type:
Конец ознакомительного фрагмента.
Текст предоставлен ООО «ЛитРес».
Прочитайте эту книгу целиком, купив полную легальную версию на ЛитРес.
Безопасно оплатить книгу можно банковской картой Visa, MasterCard, Maestro, со счета мобильного телефона, с платежного терминала, в салоне МТС или Связной, через PayPal, WebMoney, Яндекс.Деньги, QIWI Кошелек, бонусными картами или другим удобным Вам способом.