Sudo for Windows - How to Enable it, and How to Use it

Поділитися
Вставка
  • Опубліковано 18 лют 2024
  • Microsoft has launched 'sudo' for Windows. It allows you to to execute a command as the administrator, with elevated privileges. It is akin to the 'sudo' command on Linux. In this video I show you how to enable it, and how to use it.
    ---
    The Secret Superpowers of SUDO: • The Secret Superpowers...
    #garyexplains
  • Наука та технологія

КОМЕНТАРІ • 122

  • @skolarii
    @skolarii 3 місяці тому +58

    i am CONVINCED that Microsoft devs have hour long meetings to discuss how to make their software as difficult to use as possible

    • @c1ph3rpunk
      @c1ph3rpunk 3 місяці тому +2

      No. They’re hour(s) long, multiple many’s and lots.

    • @jort93z
      @jort93z 3 місяці тому +2

      I don't see how this is more difficult than previously.

    • @drescherjm
      @drescherjm 3 місяці тому +5

      When the video started I hoped that Microsoft added a useful feature that they should have had in Windows 7 however after watching all the popup dialogs they did it in the most Microsoft way. WoW! what a pain. And for those who have not used sudo on linux, it remembers your password for 15 minutes so subsequent execution of sudo somecommand does not prompt you inside of the time window.

    • @John.0z
      @John.0z 3 місяці тому +1

      @@drescherjm That is being hopeful. They do not even require the person invoking the elevated privileges to enter a password.
      I was always hoping that M$ would place some serious security into their mess. I have given up at Win10 - which IMHO has one of the least sensible and easy to use GUIs placed into an operating system. If M$ had left things mostly alone with the W7 interface I might not be as critical.

    • @robina.jensen6114
      @robina.jensen6114 3 місяці тому

      And even more time, to ensure you never find the settings you want to change!
      On my Window 10 there is 2 different control panels. I don't get it!

  • @maxhax4243
    @maxhax4243 3 місяці тому +3

    The forceNewWindow setting also has another important implication it seems: It started a new CMD running from the SYSTEM32 directory, and showed you that directory listing output. While the inline version shows what you'd expect it would show: your homedir from where you launched the command!
    And that is VERY important - because when you'd create a new directory with mkdir like in your other example, it would just create that under the system32 directory OR in c:\program files, depending on the sudo configuration - lol. So to make this work universally, we'd always need to use something like : mkdir "C:\program files\zob"

  • @drbowater
    @drbowater 3 місяці тому +11

    I much prefer the Linux implementation of sudo. Is there an advantage of using sudo in PowerShell over running PowerShell as administrator?

    • @GaryExplains
      @GaryExplains  3 місяці тому +11

      Running PowerShell as administrator for more than one specific task (i.e you open it, do the thing, and close it) is not recommended as mistake are easy to make and you can get yourself into all kinds of trouble. Similarly on Linux it is not recommended that you logon as root or su to root.

    • @WoodyWilliams
      @WoodyWilliams 3 місяці тому

      @@GaryExplains Instead of mimicking GNULinux, how do we get more of them to try GNULinux again?

    • @GaryExplains
      @GaryExplains  3 місяці тому +9

      @WoodyWilliams Technically sudo was created under BSD4.1, so it is really Windows mimicking Linux mimicking BSD 😜

    • @AnthonyManzio
      @AnthonyManzio 3 місяці тому

      @@GaryExplains I can't delete windows.old after upgrading to windows 10?

    • @darrenpardoe
      @darrenpardoe 3 місяці тому +1

      @@AnthonyManzio use disk clean-up, its a windows program

  • @RPG_ash
    @RPG_ash 3 місяці тому +2

    Thanks for sharing Gary. Also, were you logged into Windows with a local admin account? Looks like you were from the UAC prompt. What happens if the local account is a standard user? I'm assuming you are promoted for a password?

  • @paulbarnett227
    @paulbarnett227 3 місяці тому

    This will be really useful. There have been times I have wanted to run a powershell as another user and as admin. You can't do both at the same time. This will fix that.

  • @trparky
    @trparky 3 місяці тому +2

    I've been using something called GSUDO for some time just for this very reason, because I needed a way to elevate stuff at the command line. GSUDO is much more capable than what Microsoft is putting out so I'm going to continue using GSUDO instead.

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Microsoft actually links to gsudo in its announcement and recommends it for those that need more than their sudo.

  • @MatthewHarrold
    @MatthewHarrold 3 місяці тому +10

    I always thought sudo was pronounced su-doe. I stand corrected Gary (it makes sense the way you explained it). Cheers. $0.02

    • @Nick-yx9kv
      @Nick-yx9kv 3 місяці тому +2

      I'm not alone

    • @drbowater
      @drbowater 3 місяці тому

      I also pronounce it as su-doe but I have heard others say it as Su-doo. I think either is fine.

    • @GaryExplains
      @GaryExplains  3 місяці тому +6

      @drbowater As it says on the official sudo.ws site, it stands for su “do”, and so pronouncing it su-doo is correct.

    • @c1ph3rpunk
      @c1ph3rpunk 3 місяці тому +2

      @@drbowaterno. It’s pronounced “soo doo”, all others are incorrect.

    • @MatthewHarrold
      @MatthewHarrold 3 місяці тому

      @@GaryExplains I assumed that Sudo was like Judo, some high powered Fu.

  • @iodreamify
    @iodreamify 3 місяці тому +5

    Does Windows not remember the granted credentials at least for a while? Because on Linux sudo will remember the password for at least 15 minutes for the given session and you don't need to be prompted every time
    otherwise a welcome change, albeit weird to see :p

    • @robina.jensen6114
      @robina.jensen6114 3 місяці тому

      That must depend on the distro. RPi don't remember password. Every time you make a new sudo and it needs the password it ask for it.

    • @iodreamify
      @iodreamify 3 місяці тому

      @@robina.jensen6114 yeah, it can be easily configured in the sudoers file

  • @WoodyWilliams
    @WoodyWilliams 3 місяці тому +4

    Did you look deeper into why it seems to be displaying *different* directory listing whether you run [Window's] sudo outputting to a new window or not?

    • @GaryExplains
      @GaryExplains  3 місяці тому +4

      It displays a different directory because it starts a new window under the Administrator account and the home directory for that account is c:\windows\system32

    • @alanwilson7792
      @alanwilson7792 3 місяці тому +6

      @@GaryExplains That's gonna be fun when someone tries to delete everything in the "current" directory with a sudo...

    • @GaryExplains
      @GaryExplains  3 місяці тому +4

      That is a very good point. Ouch.

  • @paulmilligan3007
    @paulmilligan3007 3 місяці тому +2

    I wonder, can you do “sudo cmd.exe” to get an elevated shell where you don’t have to keep answering the elevated command dialog?

    • @GaryExplains
      @GaryExplains  3 місяці тому +1

      You can do sudo powershell, I have tested that. I guess sudo cmd.exe will work as well.

  • @kazems
    @kazems 3 місяці тому +4

    What’s the point if you have the “Run as administrator” option?

    • @GaryExplains
      @GaryExplains  3 місяці тому +4

      What is the point of sudo on Linux if you can login as root?

    • @wcarlin
      @wcarlin 3 місяці тому

      You beat me to it. How is this any different from the Windows RunAs.exe command. Don't get me wrong, Windows sudo looks useful for working on personal hardware. However, in an enterprise environment where you may need to authenticate with a smart card, etoken, OPT, or Radius; it looks useless.

  • @ferencvigvari5793
    @ferencvigvari5793 Місяць тому

    And whats the point? How is it different than opening a cmd as admin then insert your command? I thought it will run the command without asking for a graphical confirm (uac clicking) - now it is pointless. If you have to click on OK i run it in elevated, you can also right click on cmd and run as admin or you write cmd in the run window and ctrl+shift+enter it will open as admin instantly and no further questions. I dont get the benefit for this command yet.

  • @BrianG61UK
    @BrianG61UK 3 місяці тому

    I was using a third party tool called elevate to do sudo like things in Windows. I doesn't do the inline thing though.

  • @technolus5742
    @technolus5742 3 місяці тому +4

    Powershell makes me sad
    Sometimes you just want to execute a quick command to output a grep of something.
    PS usually makes these commands lengthy, convoluted and dissimilar from bash.
    I end up feeling like I need an IDE just to do simple stuff that I could easily do on the fly in bash

    • @micdev42
      @micdev42 2 місяці тому

      I suppose that's where WSL 2 (Windows Subsystem for Linux) comes in...

  • @Steve-Richter
    @Steve-Richter 3 місяці тому +2

    Is there a technical reason for the confirm pop up? You already typed “sudo”, so no practical reason to have to confirm.

    • @GaryExplains
      @GaryExplains  3 місяці тому +3

      The technical reason is that any program that wants to gain elevated privileges must ask Windows, Windows responds with the pop up. It is the same if your try to run PowerShell "as administrator".

    • @Steve-Richter
      @Steve-Richter 3 місяці тому +1

      @@GaryExplains When you start powershell "as admin", Windows prompts with the elevate privileges popup. Then you get the powershell prompt. Every powershell command entered runs as admin, without a prompt on each command. Not to ask an unanswerable question, but why does sudo prompt for each command but powershell running as admin does not? The charm of sudo on linux is it prompts for the admin password one time, and the user remains elevated. Microsoft should do the same.

    • @GaryExplains
      @GaryExplains  3 місяці тому +1

      Because PowerShell asks for elevated privileges and get it and then runs all the time with elevated privileges. With sudo, you only get elevated privileges when you run a command with sudo, it asks for elevated privileges then, runs, and exits. The next invocation starts from fresh as the previous sudo (at elevate privileges) ran and completed. Just like if you run PowerShell as admin, ran a command, and then exited PowerShell, the next time you run PowerShell with elevate privileges you will still need to give permission.

  • @Garythefireman66
    @Garythefireman66 3 місяці тому

    Do you sudo? Thanks professor 👍🏻

  • @fire_stick
    @fire_stick 3 місяці тому

    sudo !! work also ?

  • @arijarmala2037
    @arijarmala2037 3 місяці тому

    Windows is becoming Linux now... Thank you very much, Microsoft.
    And please, arrange that the normal users do not have administrative (super user) privileges by default. That would make Windows much safer to run.

  • @bbbl67
    @bbbl67 3 місяці тому

    will it be available in Windows 10?

    • @GaryExplains
      @GaryExplains  3 місяці тому +1

      I don't think so, but you might want to look at gsudo - github.com/gerardog/gsudo

  • @vasudevmenon2496
    @vasudevmenon2496 3 місяці тому

    I used NSudo from dism++ team few years ago. It would be better if power shell had auto complete via tab key for command line args just like Linux

    • @GaryExplains
      @GaryExplains  3 місяці тому

      It does has autocomplete for files and folders.

    • @vasudevmenon2496
      @vasudevmenon2496 3 місяці тому

      @@GaryExplains that's present. Even the windows terminal behaves the same. The problem occurs when you switch between a work PC with Linux and a Personal PC with windows hitting spamming the tab key to auto complete is a muscle memory

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Just use WSL on your personal PC or install Linux on it, like your work PC. 😜

    • @vasudevmenon2496
      @vasudevmenon2496 3 місяці тому

      @@GaryExplains yeah used to have Linux and thanks to nvidia driver causing black screen after auto kernel updates i dumped Ubuntu.

  • @he98508
    @he98508 3 місяці тому

    When it can do sudo apt update instead of waiting around for hours for Windows Update then there'll actually be an improvement

  • @synen
    @synen 3 місяці тому

    The window that pops is horrible, why can’t it be admin pw as an option?

    • @alanwilson7792
      @alanwilson7792 3 місяці тому +1

      With unix sudo you don't provide admin password when asked, you provide your user password. To work the same way you would just provide your login password. Also, you only need your password once per session, not every single damn time you run a command :( On some of my boxes I don't have a password, so it should just work or as an alternative, only work from accounts that have a password. Also, there should be user management of sudo-ers. Way to balls up a useful command Microsoft.

    • @synen
      @synen 3 місяці тому

      @@alanwilson7792 yes thats what I meant, was assuming user had admin rights else could not run sudo

  • @johnduncan5117
    @johnduncan5117 3 місяці тому

    Ok this is interesting. It's interesting because having watched the video I still have zero idea what this sudo thing is for. I mean you could already run the command line as admin and then anything you run within is run as the admin user.
    Really not understanding this.

    • @GaryExplains
      @GaryExplains  3 місяці тому +1

      Because running PowerShell as admin for anything more than just one command (i.e start PowerShell, run command, and then exit) is a really bad idea from a security point of view.

    • @johnduncan5117
      @johnduncan5117 3 місяці тому

      @@GaryExplains thanks for the explanation

    • @John.0z
      @John.0z 3 місяці тому

      @@GaryExplains Sorry Gary, but from a strict security point of view, not requiring an admin password or something similar to perform admin tasks is a pretty huge problem.
      I was always taught that the first and most basic security step was physical security; once that is breached a Windows machine is totally open.
      There are lots of on-line measures taken, but if a person with evil intent gets to your keyboard (for instance in an office), then what is left?

  • @richmahogany1710
    @richmahogany1710 3 місяці тому

    now i want a su command also so I don't have to exit and re-launch powershell if I want to do stuff as admin.

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Try: sudo powershell

    • @richmahogany1710
      @richmahogany1710 3 місяці тому

      @@GaryExplains Dear god...

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Why? What is wrong with that? If you have sudo set to inline then it acts exactly like su.

    • @richmahogany1710
      @richmahogany1710 3 місяці тому +1

      @@GaryExplains Sorry I meant it like "dear god that's incredible." Not "dear god this man doesn't know what he's doing" lol. Thanks for the tip mate.

    • @alanwilson7792
      @alanwilson7792 3 місяці тому

      I don't have a windows box open at the moment - how about "sudo cmd.exe"??

  • @1____-____1
    @1____-____1 3 місяці тому +1

    Windows just needs to adopt the Linux kernel.

    • @GaryExplains
      @GaryExplains  3 місяці тому +1

      How would that help? You think the Windows kernel is a problem?

    • @gug1970
      @gug1970 3 місяці тому

      and then userland, and then get rid of the windows stuff. Windows is just a platform for advertising delivery to unwilling people. Dumped it years ago for anything important.

  • @Haider5c
    @Haider5c 3 місяці тому

    why not asking you inside the terminal ? and why its asking you every time while you are in the same window????!!!!!!!

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Asking for what exactly inside the terminal? If you mean the password then remember that asking for the password is part of the Linux security subsystem, kit something particular to sudo. The Windows security subsystem is different.

  • @eddrake5290
    @eddrake5290 3 місяці тому

    So they broke sudo. essentially MS need to improve the cmd shell before they try get any fancier.

  • @Ghfvhvfg
    @Ghfvhvfg 3 місяці тому

    Pop up window why terminal password prompt is way more practial

    • @GaryExplains
      @GaryExplains  3 місяці тому

      That is how Window's security system works. Different to Linux.

  • @nathanwilliams8902
    @nathanwilliams8902 3 місяці тому

    If Microsoft wanted you to take control of your own system, they would not have built Windows11

  • @robina.jensen6114
    @robina.jensen6114 3 місяці тому

    Am i the only one, who only uses cmd line tool in Linux and never on a Windows? 🤔
    Only if i'm forced to do it because the guide says it. Otherwise i'll just click around in the windows.

  • @kennethmadsen6474
    @kennethmadsen6474 3 місяці тому

    OMG all the windows...

  • @user-tk7sc4gz2v
    @user-tk7sc4gz2v 3 місяці тому +1

    windows is full of lagacy bloat and yet they keep adding new things without clearing existing bloat

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Any examples of legacy bloat that you would like to see removed?

    • @user-tk7sc4gz2v
      @user-tk7sc4gz2v 3 місяці тому +1

      @@GaryExplains They can start with having consistency in UI across the OS. Font scaling is so bad that some UI would show blurred fonts. Control panel elements have two or sometimes three different views for the same settings. Then they can aim to have one shell across the OS where you know that a given command would work(without thinking if its powershell, cmd or anything else). There are a lot of unnecessary processes and services running just to support legacy components, we don't feel the lag because of modern processors but the moment you use windows on low grade hardware, it crawls. Then they can start limiting the processor use to maybe just 1-2% for background telemetry and windows update download processes. I'd ideally like to have telemetry stopped all together by default but I don't think its gonna happen.

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Font and UI issues aren't "legacy bloat" they are font and UI issues.

    • @user-tk7sc4gz2v
      @user-tk7sc4gz2v 3 місяці тому

      @@GaryExplainsThe issue happens because they left the legacy font rendering in some components and use new font rendering in some other components. Nomenclature for these issues could be better instead of using 'Legacy bloat' but I guess you get the point :)

  • @nmjerry
    @nmjerry 3 місяці тому

    Sudo for windows just loads LSW.

  • @QuikRay
    @QuikRay 3 місяці тому

    There is only one performance tip windows needs ..it's called Linux.

  • @metalhead2476
    @metalhead2476 3 місяці тому

    Why is w11 so damn bloated? 300+ processes for what? In w10 I have barely 150.

  • @JanWillemMoltzer
    @JanWillemMoltzer 3 місяці тому

    sudo apt remove windows 11, sudo apt install linux, sudo apt update, sudo apt upgrade.....

  • @jonbly
    @jonbly 3 місяці тому

    This is the thing that gets me a sandwich, right?

  • @theremixsong.4712
    @theremixsong.4712 2 місяці тому

    Let linux user switch to windows 😂😂😂

  • @mercster
    @mercster 3 місяці тому

    Hah... goofy.

  • @VassilisPerantzakis
    @VassilisPerantzakis 3 місяці тому

    Microsoft screws up sudo!!! It should ask for a password.

    • @GaryExplains
      @GaryExplains  3 місяці тому

      But that isn't how security works on Windows, is it? If you launch PowerShell with admin rights it doesn't ask you for a password, does it?

    • @VassilisPerantzakis
      @VassilisPerantzakis 3 місяці тому

      @@GaryExplains no it doesn't. But if microsoft's goal is to bring sudo to the windows, it should bring sudo. How does it handle this if the user is not admin however?

    • @GaryExplains
      @GaryExplains  3 місяці тому

      The only reason sudo asks for a password on Linux is because that is the security model, not by the design of sudo itself. Sudo isn't sudo because it asks for a password.

  • @SirHackaL0t.
    @SirHackaL0t. 3 місяці тому

    Trust msft to make it work badly. Lol

  • @freaker126
    @freaker126 3 місяці тому

    that pop up is irritating

    • @ernstoud
      @ernstoud 3 місяці тому

      Because security.

  • @Martin-lc1sk
    @Martin-lc1sk 3 місяці тому

    Seems poorly implemented and faffy. Doesn't even ask for a password so a security risk.
    Su-doh 🤦

    • @GaryExplains
      @GaryExplains  3 місяці тому

      Windows doesn't ask for a password when elevating privileges. If you start powershell as admin, it doesn't ask for a password. sudo is just following the security model of Windows.

  • @danmarius
    @danmarius 3 місяці тому

    Sudo delete Windows.

  • @raduboboc
    @raduboboc 3 місяці тому +4

    The mix between cmd and gui is stupid.
    When You actually want to automate things you use the command line unattended, but nooo now you need to interact with it defeating the purpose.
    I can already imagine the meme with the guy in the Microsoft building trying to suggest something simple and with sense being thrown out the window while a bunch of leftists are trying to push the most devilish way of torturing us 😢

    • @GaryExplains
      @GaryExplains  3 місяці тому +5

      What has someone's political views got to do with command lines?

    • @Rood67
      @Rood67 3 місяці тому

      @@GaryExplainshistorically those of the left side of the political spectrum come up with strenuous regulations. Saving the environment good, saving idiots from achieving their Darwin Award bad.
      In the U.S. those on the left want to push EVs with massive restrictions on electric production. Well, one cannot charge an EV without electricity. So, @raduboboc is correct in their statement, from the point of view that here is a new tool and fifty-eight ways to make it laboriously difficult to use.

    • @raduboboc
      @raduboboc 3 місяці тому

      That's a good question that will be very hard to answer here.
      I've notice that the leftists have a certain type of thinking that is usually against the norm and against the common sense.
      A normal programmer will try to do things clear, easy to understand, with a good enough logic, while "they" will do things the opposite way, with the most ilogical things you can imagine, trying to torture your soul.
      Microsoft and its products have shifted in thst direction for many years now and they are pushing me an others closer and closer to linux and totally rejecting windows as an OS.
      Actually I should thank them because I turned out to be a linux engineer after a long windows fanboy carieer.
      Trust me there is a leftits way of doing things and it is not good for human kind, but let's not do politics here on this channel, let's keep it technical and fun.
      Sorry for the deviation

  • @ronny332
    @ronny332 3 місяці тому +1

    M$ is at a level where they don't know any shame and no respect for anything. In my eyes they are desperate and trying to catch every leaf to get people more confused what's now Windows or Linux/Unix. They took their own way, why not staying on it and trying to create a constant path without taking ideas and structures of other OS's. in my eyes awkward from a windows user's point of view and ridiculous from a *nix user's point of view.
    the craziest part for me is: there is no Super User at windows. It is and always was the administrator. so why picking a "Super User DO" (sudo) command on board, which is short, but out of the normal naming scheme.

  • @MandoRick1978
    @MandoRick1978 3 місяці тому

    Not interested in Windows 11. Maybe they will get things right with Win 12. Microsoft does have a pattern after all. Not to mention that consoles are exactly why we avoid Linux. Why did we invent the Graphical User Interface? Certainly not to get stuck in a bloody console. If that is what people wanted, Linux would be way more popular than it is. Nah, I will leave it for the console jockeys.

    • @Shocker99
      @Shocker99 3 місяці тому

      There isn't that much different between Win10 and Win11. To me Win11 is just a slightly reskinned version of Win10.

    • @MandoRick1978
      @MandoRick1978 3 місяці тому

      @@Shocker99just to begin with: Windows 11 will only run on 64-bit PCs and requires TPM 2.0 chip and UEFI firmware with Secure Boot capability. Reskin huh?

    • @Shocker99
      @Shocker99 3 місяці тому

      @@MandoRick1978 Yes.

  • @elanehayduk7255
    @elanehayduk7255 2 місяці тому

    😱 'Promo SM'