您的位置:首页 > 其它

FreeBSD学习笔记03-默认搜索路径

2008-06-12 14:53 295 查看
Default Search Path

When you type a command at the command prompt, FreeBSD looks in a list of directories for the name of the command you entered and runs the program if a match is found. This list of directories is called the default search path or path environment variable.

The order in which FreeBSD searches this path is important when installing third-party software, which this book concentrates on. Most third-party program files are put into subdirectories of /usr/local. The default position of the /usr/local directory is near the end of the path statement. If a command that is part of a third-party application has the same name as a command that is part of the base FreeBSD command set, it will never run because the FreeBSD command will be found first and always take precedence. Since we'll be installing third-party applications to extend and/or update FreeBSD's base system, it is beneficial to invert the order of the search path. Let's change the order of the default search path for the root user using Easy Editor:

# cd /root  # ee .cshrc


We'll comment out (disable) the default set path statement and enter our own customized one. Scroll down to the set path) to disable it, then add the alternative path below so that your third-party programs will run even if they have the same names as native FreeBSD commands. The set path statement should now appear as follows:

#set path = (/sbin /bin /usr/sbin /usr/bin /usr/games   /usr/local/sbin /usr/local/bin /usr/X11R6/bin)    set path = (/usr/local/sbin /usr/local/bin /usr/sbin   /usr/bin /sbin /bin $HOME/bin)


Note: The text is wrapped above but each set path statement should only occupy a single line in the .cshrc file.

Save, exit, log out, and log in. You can display the current search path with this command:

# echo $path


By default, non-root users use the sh shell (interface), and root defaults to the tcsh shell. The default search path can be modified for non-root users in the same way. The sh shell stores this setting in the .profile file of each user's home directory.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: