From 650126abe466aac76d2aacd1eb2f5929c3db3e67 Mon Sep 17 00:00:00 2001 From: Xingyu Wang Date: Tue, 1 Nov 2022 16:03:55 +0800 Subject: [PATCH] RP @qfzy1233 https://linux.cn/article-15200-1.html --- ...⭐️ Use open source commands in Powershell.md | 88 ++++++++++++++++++ ...⭐️ Use open source commands in Powershell.md | 93 ------------------- 2 files changed, 88 insertions(+), 93 deletions(-) create mode 100644 published/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md delete mode 100644 translated/tech/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md diff --git a/published/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md b/published/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md new file mode 100644 index 0000000000..74e9bd07e9 --- /dev/null +++ b/published/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md @@ -0,0 +1,88 @@ +[#]: subject: "Use open source commands in Powershell" +[#]: via: "https://opensource.com/article/22/10/set-path-powershell" +[#]: author: "Alan Smithee https://opensource.com/users/alansmithee" +[#]: collector: "lkxed" +[#]: translator: "qfzy1233" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-15200-1.html" + +设置路径在 Powershell 中使用开源命令 +====== + +![](https://img.linux.net.cn/data/attachment/album/202211/01/160141i03e33e8pp5xp3vs.jpg) + +> 在 Windows 上设置你的路径,这样你就可以使用开源的命令。 + +当你在操作系统上启动应用程序时,操作系统需要使用某些代码库和实用程序来运行该应用程序。你的操作系统知道如何找到这些库和实用程序,因为它有一个 _系统路径_,这是一个通往许多应用程序需要的共同共享数据的地图。所有操作系统都有这一点,但用户通常不会意识到这一点,因为他们通常不需要在意它。然而,当你需要编程或使用特殊的网络实用程序或命令时,你可能需要关心你自己的 `PATH` 变量配置。 + +`PATH` 变量使你可以将命令保存到一致的位置,并使用命令提示符或更强大(而开源的)[Powershell][1] 从系统上的任何位置调用它们。 + +例如,假设你想安装开源应用程序 `pscp.exe`,它是 Windows 上著名的 PuTTY OpenSSH 客户端的命令行界面。你可以将它下载到你的硬盘,但是你的命令行如何知道它的存在呢?其实一开始,它并不知道: + +``` +PS> pscp + pscp: 命令 “pscp” 不能被识别为 cmdlet、脚本文件或可操作程序的名称。 + 检查名称的拼写,或者如果包含了路径,则检查路径是否正确,然后再试一次。 +``` + +如果你正在使用一个开源命令行,例如 Powershell 或 [Cmder][2],那么你将得到一个有用的错误提示,提示这可能是你的路径有问题(或缺少路径)。下面是解决这个问题的方法。 + +### 设置 PATH + +首先,在桌面上创建一个名为 `App` 的文件夹。 + +接下来,右键单击屏幕左下角的 Windows 菜单,然后选择 “系统System”。 + +![Image of the Windows menu system.][3] + +在弹出的 “系统System” 窗口中,单击窗口左侧的 “高级系统设置Advanced system settings” 链接。 + +在出现的 “系统属性System properties” 窗口中,单击窗口底部的 “环境变量Environment variables” 按钮。 + +![Image Windows system enviroment variables.][4] + +在 “环境变量Environment variables” 窗口中,单击 “用户变量User variables” 面板下的 “新建New” 按钮。 + +![Image of new Windows enviroment variables.][5] + +在弹出的对话框中,为 “变量名Variable name” 字段输入 `PATH`,为 “变量值Variable value” 字段输入 `%USERPROFILE\Desktop\App` 。单击 “确定OK” 按钮保存更改。 + +![Image of Windows path set.][6] + +在 `Desktop/Apps` 中放置你想从命令提示符中访问的命令和应用程序,Powershell、Cmder 甚至 Cmd 都能找到它们。 + + +``` +PS> pscp –version + pscp: Release 0.XY + Build platform: 64-bit x86 Windows + PS> +``` + +### 自动设置路径 + +许多应用程序会在安装过程中自动添加到系统路径中。然而,并不是所有的程序都如此,要么是因为你在安装过程中遗漏了一个复选框,要么是因为应用程序开发人员希望你自己添加它。当自动路径失败时,你现在知道如何自己设置路径。 + +*(图像来自:Alan Smithee, CC BY-SA 4.0)* + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/22/10/set-path-powershell + +作者:[Alan Smithee][a] +选题:[lkxed][b] +译者:[qfzy1222](https://github.com/qfzy1233) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alansmithee +[b]: https://github.com/lkxed +[1]: https://opensource.com/article/18/2/powershell-people +[2]: http://cmder.app/ +[3]: https://opensource.com/sites/default/files/2022-10/windows-menu-system.png +[4]: https://opensource.com/sites/default/files/2022-10/windows-system-environment-variables.png +[5]: https://opensource.com/sites/default/files/2022-10/windows-environment-variables-new.png +[6]: https://opensource.com/sites/default/files/2022-10/windows-path-set.png diff --git a/translated/tech/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md b/translated/tech/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md deleted file mode 100644 index 59d165394d..0000000000 --- a/translated/tech/20221022.3 ⭐️⭐️ Use open source commands in Powershell.md +++ /dev/null @@ -1,93 +0,0 @@ -[#]: subject: "Use open source commands in Powershell" -[#]: via: "https://opensource.com/article/22/10/set-path-powershell" -[#]: author: "Alan Smithee https://opensource.com/users/alansmithee" -[#]: collector: "lkxed" -[#]: translator: "qfzy1233" -[#]: reviewer: " " -[#]: publisher: " " -[#]: url: " " - -在Powershell 中使用开源命令 -====== - -当你在操作系统上启动应用程序时,操作系统需要使用某些代码库和实用程序来运行该应用程序。你的操作系统知道如何找到这些库和实用程序,因为它有一个_系统路径_,一个到许多应用程序都需要用到的公共共享数据的映射。所有操作系统都有这一点,但用户通常不会意识到这一点,因为他们通常不需要在意它。然而,当你需要编程或使用特殊的网络实用程序或命令时,你可能需要关心你自己的PATH变量配置。 - -PATH变量使你可以将命令保存到一致的位置,并使用命令提示符或更强大(也是开源的)[Powershell][1]从系统上的任何位置调用它们。 - -例如,假设你想安装开源应用程序“pscp.exe”,它是Windows上著名的PuTTY OpenSSH客户端的命令行界面。你可以将它下载到你的硬盘,但是你的命令行如何知道它的存在呢?实时一开始,它并不知道: - -``` -PS> pscp - pscp: 命令“pscp”不能被识别为cmdlet、脚本文件或可操作程序的名称。检查名称的拼写,或者如果包含了路径,则检查路径是否正确,然后再试一次。 -``` - -如果你正在使用一个开源命令行,例如Powershell或[Cmder][2],那么你将得到一个有用的错误提示,提示这可能是你的路径有问题(或没有问题)。下面是解决这个问题的方法。 - -### 设置 PATH - -- 首先,在桌面上创建一个名为`App`的文件夹。 -- 接下来,右键单击屏幕左下角的Windows菜单,然后选择 **系统**. - -![Image of the Windows menu system.][3] - -Image by: - -(Alan Smithee, CC BY-SA 4.0) - -- 在弹出的“**系统**”窗口中,单击窗口左侧的“**高级系统设置**”链接。 -- 在出现的**系统属性**窗口中,单击窗口底部的**环境变量**按钮。 - -![Image Windows system enviroment variables.][4] - -Image by: - -(Alan Smithee, CC BY-SA 4.0) - -- 在**环境变量**窗口中,单击**用户变量**面板下的**新建**按钮。 - -![Image of new Windows enviroment variables.][5] - -Image by: - -(Alan Smithee, CC BY-SA 4.0) - -- 在弹出的对话框中,为**变量名**字段输入`PATH`,为**变量值**字段输入 `%USERPROFILE\Desktop\App` 。单击**OK**按钮保存更改。 - -![Image of Windows path set.][6] - -Image by: - -(Alan Smithee, CC BY-SA 4.0) - -将那些你希望从命令提示符在`Desktop\Apps`和Powershell, Cmder,Cmd中调用的命令和应用程序放置于`Desktop\Apps`路径下: - -``` -PS> pscp –version - pscp: Release 0.XY - Build platform: 64-bit x86 Windows - PS> -``` - -### PATH路径自动设置 - -许多应用程序会在安装过程中自动添加到系统路径中。然而,并不是所有的程序都如此,要么是因为你在安装过程中遗漏了一个复选框,要么是因为应用程序开发人员希望你自己添加它。当自动路径失败时,你现在知道如何自己设置路径。 - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/22/10/set-path-powershell - -作者:[Alan Smithee][a] -选题:[lkxed][b] -译者:[qfzy1222](https://github.com/qfzy1233) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/alansmithee -[b]: https://github.com/lkxed -[1]: https://opensource.com/article/18/2/powershell-people -[2]: http://cmder.app/ -[3]: https://opensource.com/sites/default/files/2022-10/windows-menu-system.png -[4]: https://opensource.com/sites/default/files/2022-10/windows-system-environment-variables.png -[5]: https://opensource.com/sites/default/files/2022-10/windows-environment-variables-new.png -[6]: https://opensource.com/sites/default/files/2022-10/windows-path-set.png