用于放置自定义可执行文件或脚本的 Unix 标准目录? [英] Unix standard directory to put custom executables or scripts?

查看:29
本文介绍了用于放置自定义可执行文件或脚本的 Unix 标准目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个自定义的 shell 脚本或程序,是我自己创建的或从网上下载的,并且我希望能够从 CLI 执行它,是否有将它放在 Linux/Unix 目录结构中的标准位置?

If I have a custom shell script or programs, that I created myself or downloaded from the web, and I want to be able to execute this from the CLI, is there the standard location to put this in Linux/Unix directory structure?

/usr/bin ?
/usr/local/bin ?
/usr/lib ?
/usr/sbin ?
/bin ?
/sbin ?
/var ?

我通常把它放在我的~/bin文件夹下并放在PATH中,但它看起来并不干净.而且每次下载一个新的程序,都得重新放到PATH中.

I usually put it under my ~/bin folder and put it in PATH, but it doesn't seem clean. And everytime I downloaded a new program, I have to put it in the PATH again.

推荐答案

/usr/local/bin 正是为此目的而存在的,用于系统范围的安装.对于您自己的私人使用,~/bin 是事实上的标准.

/usr/local/bin exists precisely for this purpose, for system-wide installation. For your own private use, ~/bin is the de facto standard.

如果您想将每个二进制文件保存在其自己的子目录中,您可以这样做,并将符号链接添加到您的 PATH 中已有的目录.所以,例如

If you want to keep each binary in its own subdirectory, you can do that, and add a symlink to a directory already in your PATH. So, for example

curl -o $HOME/downloads/fnord http://fnord.example.com/script.exe
ln -s $HOME/downloads/fnord $HOME/bin/

提供的 $HOME/bin 在您的 PATH 中.(有像 stow 这样的工具可以在给你的场景.)

provided $HOME/bin is in your PATH. (There are tools like stow which do this -- and much more -- behind the scenes for you.)

这篇关于用于放置自定义可执行文件或脚本的 Unix 标准目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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