windows 在 Cygwin 上找不到 sudo 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22527668/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
sudo command not found on Cygwin
提问by Adam
I am currently trying to install and update a few packages on a Windows OS. The only matter is that I am using Cygwin in order to type the commands through a terminal (as I'm aware, I can type in Linux type commands such as cd, ls etc. on Cygwin - I may be wrong). However, when I try to install a package like:
我目前正在尝试在 Windows 操作系统上安装和更新一些软件包。唯一的问题是我使用 Cygwin 以便通过终端输入命令(据我所知,我可以在 Cygwin 上输入 Linux 类型的命令,例如 cd、ls 等 - 我可能错了)。但是,当我尝试安装如下软件包时:
sudo apt-get install paparazzi-dev
I get the reply:
我得到答复:
-sh: sudo: command not found.
Does anyone have an idea as to how I can fix this problem?
有没有人知道我如何解决这个问题?
采纳答案by Caleb
Cygwin is not a full Linux distribution. Therefore you don't have sudo or the Debian/Ubuntu package manager apt-get. There is a number of packages available from the Cygwin repository: http://cygwin.com/packages/You have to chose these packages during setup.
Cygwin 不是完整的 Linux 发行版。因此,您没有 sudo 或 Debian/Ubuntu 软件包管理器 apt-get。Cygwin 存储库中提供了许多软件包:http://cygwin.com/packages/您必须在安装过程中选择这些软件包。
回答by Aimal
Run cygwin as administrator.. then you wouldn't need any sudo command.
以管理员身份运行 cygwin .. 那么你就不需要任何 sudo 命令了。
回答by PurkkaKoodari
Windows does not have sudo, apt, or almost any Linux commands to be exact. Cygwin may allow some, but as programs are not installed on Windows as packages apt-get will not work. Windows programs have installers as .exe or .msi instead.
Windows 没有 sudo、apt 或几乎任何 Linux 命令。Cygwin 可能允许一些,但由于程序未安装在 Windows 上,因此 apt-get 包将不起作用。Windows 程序的安装程序为 .exe 或 .msi。
The Windows version of sudo is called runas in case you need to run something as another user. Or, you can run Cygwin as administrator.
sudo 的 Windows 版本称为 runas,以防您需要以其他用户身份运行某些内容。或者,您可以以管理员身份运行 Cygwin。
If you have to use the packages you need Linux. You can install it directly to replace Windows, dual-boot or use a virtualization software like VMware VirtualBox.
如果你必须使用你需要 Linux 的软件包。您可以直接安装它来替换 Windows、双启动或使用像 VMware VirtualBox 这样的虚拟化软件。
回答by veer7
Making out an explanatory answer from answer here by @Aimal as it worked for me.
从@Aimal 的回答中找出一个解释性的答案,因为它对我有用。
Cygwin
may not get permissions to create folders and files
when run by clicking Cygwin
icon that's in normal mode.
Cygwin
permissions to create folders and files
通过单击Cygwin
处于正常模式的图标运行时可能无法获得。
Cygwin
gets the right authorization only when right click -> "run as adminitrator"
on cygwin icon
because of that it gets permissions to create folders and files
.
Cygwin
只有在right click -> "run as adminitrator"
打开时才能获得正确的授权,cygwin icon
因为它会获得permissions to create folders and files
.
回答by unforgettableidSupportsMonica
Cygwin lets you run certain commands, such as cd, ls, or mv; but it doesn't let you run other commands, such as sudo or apt-get.
Cygwin 允许您运行某些命令,例如 cd、ls 或 mv;但它不允许您运行其他命令,例如 sudo 或 apt-get。
If you're trying to add a package to your Cygwin installation, rerun Cygwin Setup. It may still be in your "Downloads" folder. Go through all the steps again. The Cygwin installer will automatically download and install the package you want, and add it to your Cygwin installation. (I think it will probably also upgrade all your other installed Cygwin packages to the latest available versions.)
If your desired package isn't on the Cygwin package listbut is on the Cygwin Ports package list, follow the Cygwin Ports installation instructions. Note that Cygwin Ports is separate from Cygwin. Please do notsend messages about Cygwin Ports packages to the cygwin.com mailing lists.
If you have years of Linux experience, you may be able to compile the software you want inside Cygwin. This can be challenging.
Perhaps an option simpler than "compile it yourself" is this: You can install VirtualBox, then install your favorite Linux distribution inside the virtual machine, then install your desired package inside Linux. (I like Ubuntu Linux, which has more than 27,000 packages in its "Universe" repository.) Now you can run Linux and Windows at the same time.
如果您尝试向 Cygwin 安装添加包,请重新运行 Cygwin 安装程序。它可能仍在您的“下载”文件夹中。再次执行所有步骤。Cygwin 安装程序将自动下载并安装您想要的软件包,并将其添加到您的 Cygwin 安装中。(我认为它可能还会将所有其他已安装的 Cygwin 软件包升级到最新的可用版本。)
如果所需的软件包不在Cygwin 软件包列表中,但在Cygwin Ports 软件包列表中,请按照Cygwin Ports 安装说明进行操作。请注意,Cygwin 端口与 Cygwin 是分开的。请不要不约Cygwin的港口软件包到cygwin.com邮件列表发送消息。
如果你有多年的 Linux 经验,你或许可以在 Cygwin 中编译你想要的软件。这可能具有挑战性。
也许比“自己编译”更简单的选项是:您可以安装 VirtualBox,然后在虚拟机中安装您最喜欢的 Linux 发行版,然后在 Linux 中安装您想要的包。(我喜欢 Ubuntu Linux,它的“Universe”存储库中有 27,000 多个软件包。)现在您可以同时运行 Linux 和 Windows。
回答by Pawan Gangwani
I think I tried steps below after doing some research & succeeded (on windows)
我想我在做了一些研究后尝试了以下步骤并成功(在 Windows 上)
1.Install scoop using powershell 3 (iex (new-object net.webclient).downloadstring('https://get.scoop.sh')) 2. do scoop install --global sudo 3. make sure paths (C:\Users\\scoop\shims & C:\ProgramData\scoop\shims) added in environmental path variable.
1. 使用 powershell 3 安装 scoop (iex (new-object net.webclient).downloadstring(' https://get.scoop.sh')) 2. do scoop install --global sudo 3. 确保路径 (C: \Users\\scoop\shims & C:\ProgramData\scoop\shims) 添加到环境路径变量中。
回答by Leung Ying Ying
In my case, I wanted to install curl, but could not create directory /usr/local/curl/lib when running command "make install", because of permission deny. so i need to change /usr/local permission. when i run sudo chmod 755 /usr/local, sudo command not found.
就我而言,我想安装 curl,但在运行命令“make install”时无法创建目录 /usr/local/curl/lib,因为权限被拒绝。所以我需要更改 /usr/local 权限。当我运行 sudo chmod 755 /usr/local 时,找不到 sudo 命令。
after searching a few solution, found that sudo is not installed by default in Cygwin. But I tried the solution that Aimal gave which is to run Cygwin as administrator. I finally can change the folder permission. Thanks Aimal.
搜索了几个解决方案,发现Cygwin默认没有安装sudo。但是我尝试了 Aimal 提供的解决方案,即以管理员身份运行 Cygwin。我终于可以更改文件夹权限了。谢谢艾马尔。