打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Setting your search path

Setting your search path

The basics of the search path

(Since the notion of the search path is critical for your working environment, we're going to spend a few pages discussing it. You'll thank me for this some day. Really.)

Just as it does in the Windows world, the PATH shell variable represents your command search path -- an ordered, colon-separated list of directories that are searched, left to right, for every command that you execute. Each user has the freedom to define their own personal search path, which you can display as shown below (which also shows a fairly typical example of a search path):

$ echo $PATH/bin:/usr/bin:/usr/X11R6/bin:/home/username/bin:.

 

Typically, the search path begins with a small number of standard system directories such as /bin, /usr/bin and /usr/X11R6/bin, possibly some extra directories for third-party or locally-installed software such as /usr/local/bin and, finally, perhaps a few personally-chosen directories of your own at the end. And who decides what your search path will eventually look like? Your personal search path is typically the end result of piece-by-piece construction by a number of programs and login-time configuration files such as:

  • /bin/login
  • /etc/profile
  • /etc/profile.d/*.sh
  • ~/.bash_profile

The sample list above just emphasizes how many files and programs may have a hand in building the final search path, but it's important to note that you, the user, have the final say since it's your personal .bash_profile startup file that is consulted last.

If, at any time, you want to extend your search path temporarily just for the duration of the rest of this login session, you can add a new entry to the end at the command prompt with (for example):

$ PATH=$PATH:/usr/games

 

If, however, you want to make a permanent change, you should do this in your personal .bash_profile, and your new path will take effect at the next login.

Tip

If you want to execute a program from a directory that is currently not in your search path, there's no need to add that directory to the path. Just type the fully-qualified name of the executable, as in:

$ /usr/games/fortune            

 

Tip

Regardless of what anyone else tells you, there is little value in exporting your PATH variable. This variable is used primarily for locating executable commands, not for passing any useful information to them. It probably won't hurt to export PATH, but it's unlikely to have any benefit.

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
Setting your Path
Linux的Bash Shell详解
How to Setup Android Build Environment on OS X 10.9 Mavericks – Guide
Ubuntu中root用户没有办法使用命令
Loops in Bash
A list of the commonly used variables in Linux
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服