简体   繁体   English

删除`/usr/local/bin`是否安全?

[英]Is it safe to delete `/usr/local/bin`?

I previously used Node installed from the website, and I've recently started using nvm .我以前使用从网站安装的 Node,最近开始使用nvm I deleted /usr/local/lib/node_modules , and was about the delete /usr/local/bin as well, but noticed there were a bunch of modules in it that I didn't recognize.我删除了/usr/local/lib/node_modules ,并且也删除了/usr/local/bin ,但注意到其中有一堆我不认识的模块。

What I Want To Know: Does /usr/loca/bin contain anything other than modules installed via npm i -g ?我想知道的: /usr/loca/bin是否包含通过npm i -g安装的模块以外的任何内容? In other words, if I delete /usr/local/bin and just start re-installing all the global modules that I need via npm i -g , are there any risks to that?换句话说,如果我删除/usr/local/bin并开始通过npm i -g重新安装我需要的所有全局模块,那有什么风险吗? When I install global modules now, they get saved in ~/.nvm/versions/node/v14.15.4/lib .当我现在安装全局模块时,它们会保存在~/.nvm/versions/node/v14.15.4/lib中。

Is it safe to delete /usr/local/bin ?删除/usr/local/bin是否安全?

Absolutely not.绝对不。 It will destroy other applications you installed on your machine as well.它也会破坏您安装在机器上的其他应用程序。 It's the install path for all binaries that should survive operating system changes/upgrades.它是所有应在操作系统更改/升级后幸存下来的二进制文件的安装路径。 (It's a bit like asking "Is it safe to delete C:\Program Files ?" in Windows.) (这有点像在 Windows 中询问“删除C:\Program Files是否安全?”)

You should delete only /usr/local/bin/node and all of the now-broken symlinks into /usr/local/lib/node_modules (since you deleted the folder - symlinks such as npm but possibly others as well if you globally installed any packages that provide CLIs).您应该只删除/usr/local/bin/node和所有现在损坏的符号链接到/usr/local/lib/node_modules (因为您删除了文件夹 - 符号链接,例如npm但可能还有其他符号链接,如果您全局安装了任何提供 CLI 的软件包)。 I'm assuming you have GNU find , then you can use the -xtype l option to find broken links:我假设您有 GNU find ,那么您可以使用-xtype l选项来查找损坏的链接:

sudo rm /usr/local/bin/node
sudo find /usr/local/bin -xtype l -delete

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM