Unix标准目录放置自定义可执行文件或脚本? [英] Unix standard directory to put custom executables or scripts?
问题描述
如果我有一个自定义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,看起来干净。
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.
推荐答案
/
在它自己的子目录中,可以这样做,并添加一个符号链接到 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/
c $ c> $ 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屋!