DEV Community

Cover image for How to use Sudo in Windows 10 Powershell
Ashraf Mehdaly
Ashraf Mehdaly

Posted on

How to use Sudo in Windows 10 Powershell

Many of us may face a small problem with windows terminal (command line) when going to execute some commands that require an admin privilege while the shell is opened in normal user privilege, so we have to restart the shell using Run As Administrator in order to proceed, whilst in Linux we simply use sudo command to execute whatever we want as a root user.
Here we have solution for this issue in Windows, just follow the following steps:
1- Using PowerShell terminal execute the following command line to install scoop package installer:

C:\>iwr -useb get.scoop.sh | iex
Enter fullscreen mode Exit fullscreen mode

2- Then after installing "scoop" in your system install "sudo" package:

C:\>scoop install sudo
Enter fullscreen mode Exit fullscreen mode

Now you will be able to use sudo command same as in Linux, for example in order to install npm package globally we have to run npm install in a privilege mode:

C:\>sudo npm install –g bootstrap
Enter fullscreen mode Exit fullscreen mode

As well as having a sudo option in Windows, we will have the ability to install packages in Windows using "scoop" similar to apt & apt-get in Linux.
For more information how to use scoop visit :

  1. https://scoop.sh/
  2. https://github.com/lukesampson/scoop/wiki

Top comments (2)

Collapse
 
narayanbhat166 profile image
Narayanbhat166

Very much useful. Thanks for this information

Collapse
 
kkkkkccccc profile image
Keemchard Tamio

thanks