理解PATH变量和软链接

理解PATH变量和软链接

请帮助我理解my-ls -l ~/bin/my-ls正在尝试做什么?我在 Linux 系统上运行了以下命令:

$ ln -s $(which ls) ~/bin/my-ls   # symlink
$ which my-ls
/home/user/bin/my-ls
$ my-ls -l ~/bin/my-ls
lrwxrwxrwx 1 user user 7 2010-10-27 18:56 my-ls -> /bin/ls
$ my-ls          # lookup through $PATH
bin  desktop  documents  downloads  examples.desktop  music
$ ~/bin/my-ls    # doesn't use $PATH to lookup
bin  desktop  documents  downloads  examples.desktop  music

答案1

它列出了第一个命令创建的符号链接的属性ln -s $(which ls) ~/bin/my-ls

它还证明您可以为通过符号链接调用的命令提供参数,并且参数根本不会改变:实际上,my-ls -l ~/bin/my-ls运行/bin/ls -l ~/bin/my-ls

相关内容