且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

$ PATH相对于别名的优势

更新时间:2022-12-23 20:57:09

在路径中放入 python3 是在文件系统中可能发现的任何地方调用它的正确方法.符号链接是将命令更改为 python 并保持脚本不受版本依赖的***方法(您可以运行依赖于python的脚本使用符号链接,而需要使用python 3.0的脚本专门使用python3,即使它们在您的计算机上是一样的).符号链接仍然是您文件系统中的文件,因此它们仍然需要在您的路径中.

Putting python3 in your path is the correct way to invoke it anywhere you might find yourself in your filesystem. A symbolic link is the best way to change that command to python and keep your scripts non version dependent (you can run a script that depends on python use the symbolic link and a script that needs python 3.0 specifically use python3, even though on your computer they are the same thing). Symbolic links are still files in your filesystem, so they still need to be in your path.

当您尝试创建与命令行实用程序的默认行为不同的行为时,我只会看到别名.例如, ls 的别名会默默地添加-a.

I only see aliases used when you are trying to create some kind of behavior that is different than the default behavior for a command line utility like an alias for ls that adds -a silently.

符号链接也存储在文件系统中,因此一旦创建,符号链接就会存在于所有其他登录用户中,而别名仅适用于已定义它们的登录用户.他们还可以对其应用文件权限.

Also symbolic links are stored in the filesystem so once created they exist for all other users who log in, while aliases only apply to the logged in user who has defined them. They can also have file permissions applied to them.

这是有趣的文章您可以通过 .bash_profile (包括一些很好的别名)对终端执行的操作.

Here is a fun article about things you can do to your terminal through your .bash_profile including some great aliases.