Swapnil Chaudhari
Swapnil Chaudhari

Reputation: 203

sudo/apt-get command not found in git bash

I am using Windows 10 in my machine, and currently installed git bash on it.

I wanted to install node and npm for my application.

when i tried :

apt-get install nodejs

"apt-get" command not found,

I tried google and got

sudo install nodejs

"sudo" command not found.

How to use sudo and apt-get command on my git bash.

Upvotes: 9

Views: 86253

Answers (3)

vnj
vnj

Reputation: 74

Git for Windows comes with a Windows port of Bash and a collection of few more common *nix command-line tools that have been compiled for Windows, it does not provide a complete *nix environment. Hence you cannot use tools like sudo and apt-get which modify the *nix operating system.

However, there are other tools, programs if you like, available.

Try to install node " the windows way ".

Upvotes: 4

SherylHohman
SherylHohman

Reputation: 17890

win-sudo package adds sudo to windows.

kafaior at Super User suggests:

A working sudo replacement for Cygwin's mintty terminal would be to place the following script in user's PATH:

$!/bin/bash
cygstart --action=runas mintty -e `which bash` -lc \"$@\"

Maximus mentions how to add sudo (well, csudo) via cmder.

Super User has a similar question here.
It looks like there is a command runas or elevate commands. These might be for PowerShell, rather than git bash. I'm not sure.

I found your this while looking for a way to add rsync to Git Bash. So below I included info that may or may not work for sudo or apt-get. If they do not work directly for specific commands the OP is asking about, they may inspire a solution that does work. Also this could help others who arrived here as I did.

rsync is another unix command not available in the standard installation of git bash.
However, you can download and install the Git for Windows SDK (scroll to the bottom of the page for the link). This will allow you to create a version of the Git for Windows installer that does include additional *nx commands.

Install the Git for Windows SDK according to the instructions. Part 2 is where you add the packages you want, that aren't included in the standard git bash installation. Part 3 is where you create a Git installer, which will include the additional packages. If you skipped step 2, this should produce an installer similar to the standard installer.. There is a good discussion as to why they cannot include these commands in the general distribution.

It is also possible to just grab rsync filehere or here and unpack it directly within your Git installation, and it works. I dunno if it is also possible to do something similar for sudo or apt-get.

Finally, it looks like there is a way to get *nix commands available within the Git Bash shell via cmder. Here are the instructions.

Upvotes: 2

mikey
mikey

Reputation: 171

Installing applications in git bash does not sound right to me. I would suggest you either use the native Windows installer (https://nodejs.org/) or, if you prefer a package manager, use Chocolatey (https://chocolatey.org/) to install nodejs with:

choco install nodejs

Upvotes: 1

Related Questions