30

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:

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?

Søren Debois
  • 5,598
  • 26
  • 48
Adam
  • 862
  • 2
  • 8
  • 12
  • 1
    First result from Google, from SO : http://stackoverflow.com/questions/4090301/root-user-sudo-equivalent-in-cygwin – Losiowaty Mar 20 '14 at 08:50

7 Answers7

38

Run cygwin as administrator.. then you wouldn't need any sudo command.

Aimal
  • 621
  • 1
  • 7
  • 13
  • 3
    it also doesn't solve the problem of needing to be a specific user for windows authentication purposes, either. – stu Oct 20 '14 at 16:36
  • 2
    This worked for me. Cygwin gets the right authorization only when right click -> "run as adminitrator" on cygwin icon because of that we it gets permissions to create folders, users and files. – veer7 Apr 09 '16 at 19:02
  • It doesn't work. Same error, says you don't have permission to write to the directory. – felwithe Sep 17 '19 at 21:39
15

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.

Caleb
  • 343
  • 4
  • 7
  • 13
    Care to tell us which package that might be? – Ben Mar 14 '15 at 18:08
  • 3
    @Ben that would totally depend on what package you are trying to install. There is not a package for sudo. You don't install software on Cygwin with sudo or with apt-get. You can search packages for a particular file with http://www.trueblade.com/knowledge/finding-which-cygwin-package-contains-a-particular-file – skiphoppy Apr 04 '16 at 19:32
  • 3
    What he's saying is that `sudo` is a file permissions utility exclusive to Linux, and that Windows has its own equivalents of this. Therefore making it available to Cygwin would be pointless. – Hashim Aziz Jan 31 '17 at 00:41
1

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.

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.

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.

PurkkaKoodari
  • 6,703
  • 6
  • 37
  • 58
  • Do you think it would be possible to install packages through Cygwin using runas and to later copy them into a Linux machine? The problem is that my linux machine doesn't have an internet connection, and I don't furhtermore have the adminstrative rights for that machine either. – Adam Mar 20 '14 at 08:58
  • @Mahmoud No, as Windows doesn't have the commands to install packages. Also, installing packages on computer A and copying the resulting files onto computer B can often result in misconfiguration. – PurkkaKoodari Mar 20 '14 at 09:02
  • Thank you. That's what I thought. – Adam Mar 20 '14 at 09:10
1

Making out an explanatory answer from answer here by @Aimal as it worked for me.

Cygwin may not get permissions to create folders and files when run by clicking Cygwin icon that's in normal mode.

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.

veer7
  • 20,074
  • 9
  • 46
  • 74
1

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.

  • 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 list but is on the Cygwin Ports package list, follow the Cygwin Ports installation instructions. Note that Cygwin Ports is separate from Cygwin. Please do not send 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.

0

I think I tried steps below after doing some research & succeeded (on 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.

-3

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.

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.

Leung Ying Ying
  • 836
  • 1
  • 7
  • 5