找回密码
 立即注册
Qt开源社区 门户 查看内容

PATH Definition in Linux

2019-9-14 07:33| 发布者: admin| 查看: 667| 评论: 0

摘要: PATH is an environment variable in Linux and other Unix-like operating system, responsible for searching executable files in pre-defined directory.For example: 'ls' command will execute 'ls' in the pa ...
PATH is an environment variable in Linux and other Unix-like operating system, responsible for searching executable files in pre-defined directory.

For example: 'ls' command will execute 'ls' in the path '/bin/ls'.

To see all your environmental variables, type:

> env

If you just want to show PATH in your environmental settings, type:

> env | grep PATH

or,

> echo $PATH

The dollar sign tells echo to repeat the value of the variable PATH rather than its name.

When a new system is installed, there are normally two users: a root and a ordinary public user.

The root user has more directory in PATH than ordinary user, for example, it has:

'/sbin' and '/usr/sbin' with the former storing system booting info and latter storing executable files.

To add path to PATH, use  command,

> PATH="directory:$PATH" , or 

> export PATH=$PATH:/usr/sbin

For example, to add '/usr/sbin' in the PATH, we do,

> PATH="/usr/sbin:$PATH"

To add it permanently, we need to specify that in '.bash_profile' existing in your home directory. To open it, use command,

> vi .bash_profile

Then you will see something like:



If you want to add a path '/usr/test' to PATH, change the third line to:

PATH=$PATH:$HOME/bin:/usr/test


REFERENCE:

1. http://www.linfo.org/path_env_var.html


----------------------------------------------------------------------------------------------------------------------
我们尊重原创,也注重分享,文章来源于微信公众号:科技前沿追踪,建议关注公众号查看原文。如若侵权请联系qter@qter.org。
----------------------------------------------------------------------------------------------------------------------

鲜花

握手

雷人

路过

鸡蛋

公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满) 我知道了