Path(1).pdf

(48 KB) Pobierz
PATH HOWTO
PATH HOWTO
PATH HOWTO
Table of Contents
PATH HOWTO ..................................................................................................................................................1
Esa Turtiainen etu@dna.fi. ......................................................................................................................1
1. Introduction. .........................................................................................................................................1
2. Copyright. ............................................................................................................................................1
3. General. ................................................................................................................................................1
4. Init. .......................................................................................................................................................1
5. Login. ...................................................................................................................................................1
6. Shells. ...................................................................................................................................................1
7. Changing user ID. ................................................................................................................................1
8. Network servers. ..................................................................................................................................1
9. XFree86.. ..............................................................................................................................................1
10. Delayed commands cron and at. ........................................................................................................1
11. Some examples. .................................................................................................................................2
12. Security concerns. ..............................................................................................................................2
13. How to debug problems?. ..................................................................................................................2
14. Some strategies to get the same path for all the users.. ......................................................................2
15. Acknowledgements. ...........................................................................................................................2
1. Introduction. .........................................................................................................................................2
2. Copyright. ............................................................................................................................................2
3. General. ................................................................................................................................................2
4. Init. .......................................................................................................................................................4
5. Login. ...................................................................................................................................................4
6. Shells. ...................................................................................................................................................5
6.1 bash. ...................................................................................................................................................5
6.2 tcsh. ....................................................................................................................................................5
7. Changing user ID. ................................................................................................................................6
7.1 su. .......................................................................................................................................................6
7.2 sudo. ...................................................................................................................................................6
8. Network servers. ..................................................................................................................................6
8.1 inetd. ..................................................................................................................................................6
8.2 rsh. ......................................................................................................................................................7
8.3 rlogin. .................................................................................................................................................7
8.4 telne. ..................................................................................................................................................7
8.5 ssh. .....................................................................................................................................................7
9. XFree86.. ..............................................................................................................................................8
9.1 XDM. .................................................................................................................................................8
9.2 xterm −ls. ...........................................................................................................................................8
9.3 Window manager menus and buttons. ...............................................................................................8
10. Delayed commands cron and at. ........................................................................................................9
10.1 cron. .................................................................................................................................................9
10.2 a. ......................................................................................................................................................9
11. Some examples. .................................................................................................................................9
11.1 magicfilter. .......................................................................................................................................9
11.2 Printing from X applications. .........................................................................................................10
12. Security concerns. ............................................................................................................................10
13. How to debug problems?. ................................................................................................................10
14. Some strategies to get the same path for all the users.. ....................................................................11
15. Acknowledgements. .........................................................................................................................12
i
184431896.001.png
PATH HOWTO
·
This document describes common tricks and problems with Unix / Linux environment variables, especially
with PATH variable. PATH is a list of directories where commands are looked for. The details apply for
Debian Linux 1.3 distribution.
Note! This document is in beta release status. Please send comments and corrections.
This documentation is free documentation; you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this documentation; if not,
write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
All the Unix processes contain an "environment". This is a list of variables that contain name and value, both
just strings that can contain most characters. All Unix processes have a parent process − the process that
created this process as child. Child processes inherit environment from parent process. They can make some
modifications to the environment before passing it in turn to their child processes.
One important environment variable is PATH, a list of directories separated by colons (':'). These directories
are searched through to find commands. If you try to invoke command 'foo', all the directories in PATH (in
11. Some examples
2
184431896.003.png
PATH HOWTO
that order) are searched for an executable file 'foo' (one with x−bit on). If a file is found, it is executed.
In this howto, I use term 'command' to refer executable program that is meant to be called with short names,
using the path mechanism.
In Linux, even the low level operating system calls to start processes (the exec family of calls) searches
through directories in the PATH variable: you can use the path mechanism anywhere where you try to
execute a command. If exec operating system call gets a file name that does not contain '/', it evaluates the
PATH environment variable. Even if there is no variable PATH in the environment, at least directories /bin
and /usr/bin are looked for suitable commands.
In sh you use export command to set environment, in csh you use setenv command. For example:
sh:
PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:.
csh:
setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:.
C−programs can use setenv() library call to change environment. Perl has environment in an associative array
%ENV, you can set PATH as $ENV{PATH}="/bin".
env command is the basic way of asking the current environment variables. It can be used to modify it as
well.
More information of the basic environment mechanism can be found from manual pages 'environ', 'execl',
'setenv', info file 'env' and documentation of shells.
When Linux boots up, the first normal process that starts is the init process. It is a special process because it
does not have parent. However, it is the ancestor of all the other processes. Init environment will remain as
environment of all the processes if they do not touch it explicitly. Most processes do touch.
Init starts a group of processes. File /etc/inittab tells what processes the system starts. These processes work
in the environment that is directly inherited from init − typically they are processes like 'getty', the program
that writes 'login:' to console. If you start PPP connections here, you must remember that you are working in
the init environment. The system initialization is often a script that is started here. In Debian 1.3 initialization
script /etc/init.d/rc and it calls other initialization scripts in turn.
The system contains many running servers (daemons) that may or may not use the default environment. Most
servers are started from the initialization scripts and thus they have the init environment.
When user logs in to the system, the environment is affected by the settings that are compiled into the
programs, system wide initialization scripts and user initialization scripts. This is pretty complicated and the
current situation is not completely satisfactory. It is totally different if user logs in from text console, XDM or
from network.
11. Some examples
3
Zgłoś jeśli naruszono regulamin