如何修改我的用户PROFILE文件,以将创建的脚本文件夹附加到PATH变量的末尾? [英] How do I modify my user PROFILE file to append a scripts folder i created to the end of my PATH variable?

查看:378
本文介绍了如何修改我的用户PROFILE文件,以将创建的脚本文件夹附加到PATH变量的末尾?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何修改我的用户PROFILE文件,以将我创建的脚本文件夹附加到PATH变量的末尾?
我不太确定这是什么意思.谁能解释.
谢谢:)

How do I modify my user PROFILE file to append a scripts folder i created to the end of my PATH variable?
I am not totally sure what this means. Can anyone explain.
Thanks :)

推荐答案

在unix/linux系统中,您有一个用户ID('john')和一个主目录('/home/john').主目录的缩写波浪号:〜(在目录路径的开头)表示与主目录("/home/john")相同.

In unix/linux systems, you have a user id ('john') and a home directory ('/home/john'). The home directory has an abbreviation, the tilde: ~ (at the start of a directory path) means the same as your home directory ("/home/john").

主目录中有几个以句点开头的文件(又名是点文件,因为它们以点开头,即句点).登录时,开始向您提供命令行的外壳程序(即键入命令时处理命令行的程序)会查找并读取这些文件,并使用它们的内容来初始化您的外壳程序环境.您可以通过在命令行中输入以下命令来查看这些文件(如果存在):

In the home directory are several files that begin with a period (aka dot files because they start with a dot, i.e., a period). When you log in, the shell (i.e., the program that processes the command line when you type commands) that is started to supply you a command line looks for these files and reads them, using their content to initialize your shell environment. You can see these files (if they exist) by entering these commands at the command line:

cd
ls -a

没有参数的cd意味着'将当前目录更改为我的HOME目录. ls命令列出目录中的文件(除其他外); -a选项显示显示隐藏文件".隐藏文件是指以句点开头的文件-这是unix/linux中用于隐藏"文件的约定.

The cd with no args means 'change the current directory to be my HOME directory. The ls command lists files in a directory (among other things); the -a option says 'show hidden files'. Hidden files are those that start with a period - this is the convention used in unix/linux to 'hide' files.

.profile文件(大声说它通常被称为".dot profile")是一种用于初始化环境的文件.

The .profile (said out loud it's often pronounced 'dot profile') file is one such dot file used for initializing your environment.

shell使用PATH环境变量来搜索可执行文件(程序).

The PATH environment variable is used by the shell to search for executable files (programs).

您可以在Google上搜索如何更新个人资料中的PATH"以及类似信息,以了解有关该主题的更多信息.

You can google for 'how to update PATH in profile' and similar to learn more about the topic.

这是在.profile文件中找到的典型代码段;其目的是允许您运行存储在目录/usr/mypackage/bin中的程序.

Here is a typical snippet found in a .profile file; its purpose is to allow you to run programs that are stored in the directory /usr/mypackage/bin.

PATH="/usr/mypackage/bin:$PATH"
export PATH

在PATH上放置目录可以使您只键入程序名称('myprogram')来代替较长的格式('/usr/mypackage/bin/myprogram').

Putting a directory on the PATH allows you to type just a program name ('myprogram') in place of the longer form ('/usr/mypackage/bin/myprogram').

您可以使用echo $PATH查看此代码段的效果;它将显示PATH变量的整个值.该值应该是用冒号分隔的路径(目录)列表.一个简单的例子:

You can see the effect of this snippet using echo $PATH; it will show the entire value of the PATH variable. The value should be a list of paths (directories) separated by colon. A simple example:

echo $PATH
/usr/mypackage/bin:/usr/bin:/bin

这应该给您立足点,开始调查细节.尝试搜索如何设置linux/unix登录名",.profile文件是什么"等主题,以了解更多信息.

That should give you a foothold to begin investigating the details. Trying searching for topics like 'how do I set up my linux/unix login', 'what is .profile file', etc., to learn more.

在设置PATH的值时,建议使用双引号将所有可能包含在路径名称中的常用"字符封装起来.单引号不适合此操作,因为它们会阻止对$ PATH的求值(这是定义新路径值时提供现有路径的原因).有关报价的更多信息,请此处是有关单引号与双引号的讨论

It's advisable to use double-quotes when setting the value of PATH to encapsulate any 'usual' characters that may be in the names of the items in the path. Single quotes are not suitable for this as they will prevent the evaluation of $PATH (which is what supplies your existing path when defining your new path value). For more on quotes, here is one discussion of single vs double quotes

这篇关于如何修改我的用户PROFILE文件,以将创建的脚本文件夹附加到PATH变量的末尾?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆