有两种风格netcat:netcat-openbsd和netcat-traditional。
如何知道我使用的是哪种口味的 netcat?我试过了,man nc但它没有说它是什么味道。
首先,您可以在您的机器中安装多种口味。因此,答案取决于您安装了多少风格以及您键入的命令。
netcat-traditional并且netcat-openbsd可以通过aptUbuntu 中的包管理器安装。就我而言,我还GNU netcat通过此官方网站从源代码构建到安装风味。
对于“openbsd”风格,您可以使用dpkg -L<package-name>找出位置二进制名称(自行搜索以查找等效于dpkg Lif yor package manager is not apt):
$ dpkg -L netcat-openbsd | 格雷普/斌 /bin /bin/ nc.openbsd
然后用于type -a确认二进制名称nc.openbsd可在其中搜索$PATH并解释为命令:
$ type -a nc.openbsd
nc.openbsd is /bin/nc.openbsd
nc.openbsd is /bin/nc.openbsd
Run Code Online (Sandbox Code Playgroud)
对于“传统”风味是相同的:
$ dpkg -L netcat-traditional | grep /bin
/bin
/bin/nc.traditional
$ type -a nc.traditional
nc.traditional is /bin/nc.traditional
nc.traditional is /bin/nc.traditional
Run Code Online (Sandbox Code Playgroud)
这意味着我可以发出命令nc.openbsd运行netcat-openbsd工具,也命令nc.traditional运行netcat-traditional工具。(可能会混淆命令包含 '.' 但包名包含 '-' )
似乎可以通过apt以下方式安装 3 种风格:
$ apt-cache search netcat --names-only
netcat-openbsd - TCP/IP swiss army knife
netcat - TCP/IP swiss army knife -- transitional package
netcat-traditional - TCP/IP swiss army knife
Run Code Online (Sandbox Code Playgroud)
但实际上netcat只是虚拟包:
$ apt-cache show netcat | grep Description-en -A 2
Description-en: TCP/IP swiss army knife -- transitional package
This is a "dummy" package that depends on lenny's default version of
netcat, to ease upgrades. It may be safely removed.
Run Code Online (Sandbox Code Playgroud)
因此,您只能根据需要安装netcat-openbsd和netcat-traditional通过apt:
sudo apt-get install netcat-openbsd
sudo apt-get install netcat-traditional
Run Code Online (Sandbox Code Playgroud)
命令nc和netcat怎么样?它们可以与可搜索的多种风格相关联,$PATH如果您键入nc或,其中一个路径将运行netcat。同样,您可以使用type -a来检查,而优先级是第一行(如下粗体):
$ type -a nc nc 是 /usr/local/bin/nc nc 是 /bin/nc nc 是 /usr/local/bin/nc nc 是 /bin/nc $ type -a netcat netcat 是 /usr/local/bin/netcat netcat 是 /bin/netcat netcat 是 /usr/local/bin/netcat netcat 是 /bin/netcat
您可以realpath用来找出它们的解析路径:
$ realpath /usr/local/bin/netcat /usr/local/bin/netcat $ realpath /bin/netcat /bin/nc.openbsd $ realpath /usr/local/bin/nc /usr/local/bin/netcat $真实路径/bin/nc /bin/nc.openbsd
其中 4 个只有 2 个路径在我的系统中是唯一的,一个是“GNU”,另一个是“openbsd”:
$ /usr/local/bin/netcat --version | head -1
netcat (The GNU Netcat) 0.7.1
$ /bin/nc.openbsd -h |& head -1
OpenBSD netcat (Debian patchlevel 1.130-3)
Run Code Online (Sandbox Code Playgroud)
这意味着如果我输入ncOR netcat,它将执行/usr/local/bin/netcat“GNU Netcat”。
您可以尝试update-alternatives调整已解析的符号链接路径:
$ realpath /bin/nc
/bin/nc.openbsd
$ realpath /bin/netcat
/bin/nc.openbsd
$ sudo update-alternatives --config nc
There are 2 choices for the alternative nc (providing /bin/nc).
Selection Path Priority Status
------------------------------------------------------------
0 /bin/nc.openbsd 50 auto mode
* 1 /bin/nc.openbsd 50 manual mode
2 /bin/nc.traditional 10 manual mode
Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /bin/nc.traditional to provide /bin/nc (nc) in manual mode
$ realpath /bin/nc
/bin/nc.traditional
$ realpath /bin/netcat
/bin/nc.traditional
Run Code Online (Sandbox Code Playgroud)
它改变了两者/bin/nc并将/bin/netcat符号链接¹解析为/bin/nc.traditional,但如果我输入ncOR ,它仍然不会改变风格,netcat因为在我的 中/usr/local/bin/仍然具有更高的优先级:/bin$PATH
$ /bin/nc -h |& head -1
[v1.10-41]
$ nc -h |& head -1
GNU netcat 0.7.1, a rewrite of the famous networking tool.
$ type -a nc | head -1
nc is /usr/local/bin/nc
Run Code Online (Sandbox Code Playgroud)
请注意,netcat 有更多种类,例如ncat、socat、sbd、netcat6、pnetcat和cryptcat。
¹更新的实际符号链接是/etc/alternatives/ncand /etc/alternatives/netcat,其中/bin/nc和/bin/netcat已经分别符号链接到/etc/alternatives/nc和/etc/alternatives/netcat。
当我跑步时nc --version,我得到:
netcat (The GNU Netcat) 0.7.1
Copyright (C) 2002 - 2003 Giovanni Giacobbi
This program comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of this program under the terms of
the GNU General Public License.
For more information about these matters, see the file named COPYING.
Original idea and design by Avian Research <hobbit@avian.org>,
Written by Giovanni Giacobbi <giovanni@giacobbi.net>.
Run Code Online (Sandbox Code Playgroud)
也许BSD版本也会具体说。
| 归档时间: |
|
| 查看次数: |
9762 次 |
| 最近记录: |