ln -s和别名有什么区别? [英] What's the difference between ln -s and alias?

查看:640
本文介绍了ln -s和别名有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现了问题的解决方法,我使用了 subl 命令为Sublime Text 3时,安装MacPorts版本的python。指令说要在/ bin中的命令行应用程序中放置一个软链接 ln-s 。这不工作,所以我只是打开我的〜/ .profile并添加了一个别名:
alias subl =/ Applications / path / to / subl
但是,这为我提出了一个新的问题。这两个有什么区别:别名和软链接?

I just found a workaround for a problem I was having with the subl command for Sublime Text 3 when the MacPorts version of python is installed. The instructions say to put a soft link, ln-s to the command line app in your /bin. That didn't work, so I just opened my ~/.profile and added an alias: alias subl="/Applications/path/to/subl". But that begs a new question for me. What is the difference between these two: alias and soft links?

推荐答案

它们是完全不同的东西,可用于类似目的。

They're entirely different things, though in this case they can be used for similar purposes.

这:

alias subl="/Applications/path/to/subl"

创建一个别名, $ c> subl 作为shell命令等效于键入 / Applications / path / to / subl

creates an alias, so that typing subl as a shell command is equivalent to typing /Applications/path/to/subl.

在bash中,函数通常优先于别名,因为它们更加灵活和强大。

In bash, functions are generally preferred to aliases, because they're much more flexible and powerful.

subl() { /Applications/path/to/subl ; }

这些都是特定于shell的;它们使shell将 sub1 扩展到指定的命令。

Both these things are specific to the shell; they cause the shell to expand sub1 to a specified command.

ln -s ,另一方面,在文件系统中创建一个符号链接。符号链接是对另一个文件的引用,在大多数情况下,它可以被视为文件本身。它适用于任何访问它的任何东西,而不仅仅是对shell,它立即对系统上运行的所有进程可见,并且它一直持续到被移除。 (符号链接实现为包含目标文件名称的小型特殊文件。)

ln -s, on the other hand, creates a symbolic link in the file system. A symbolic link is a reference to another file, and for most purposes it can be treated as if it were the file itself. It applies to anything that accesses it, not just to the shell, it's immediately visible to all processes running on the system, and it persists until it's removed. (A symbolic link is implemented as a small special file containing the name of the target file.)

这篇关于ln -s和别名有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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