If you ever used Linux or know someone using Linux, then you probably heard about the sudo command. The command is a critical component for almost all Linux distributions and what it does is allow you to execute a command as a different user, especially the user raz. On certain Linux distributions, you can log in as root user using the command its, but this is considered highly risky and nobody does.
Actually, it is so dangerous that it is disabled by default in Linux distributions such as Ubuntu. Instead, you must use the command sudo if you want to execute a command as root user. So what about Windows? Well, unfortunately, most people log in to Windows as administrators, which is the same as a root user in Linux. However, Microsoft has tried to reduce the dangerous effects of logging in as Administrator by enabling User Account Control or UAC.
That way, even if the user has administrative privileges, applications running under that account will not inherit those privileges unless the user manually authorizes it. This helps prevent malware and spyware from infecting a Windows user who has logged on as an administrator.
So, while Linux users have the sudo command, what do Windows users have? Are there alternatives that Windows users can use to execute commands with elevated privileges? Is there a sudo command for Windows? In this article, talk about five alternatives to the sudo command for Windows users.
Note : Some of these tools are quite old now, so they may or may not work with the latest versions of Windows.
Windows Runes Command
Windows has the command runes, which is the direct counterpart of sudo in Linux. Using the runas command, you can execute a script, program or command as a different user or as an administrator. The complete syntax for the runes command is:
runas (/ profile) (/ env) (/ netonly) (/ smartcard) (/ showtrustlevels) (/ trustlevel) / user: programa UserAccountName
If you want to open an administrative command prompt, you can type the following:
runas / noprofile / user: Administrator cmd
/ noprofile does not load the current user profile. You can eliminate that if you need to access the user environment variables. If you want to open a text file with Notepad with administrator privileges, you can use this command:
runas / usuario: Administrador "notepad my_file.txt"
You can check the Technet page in runes for more information on how to use it.
Note that when using the runes command, if you install a program or make changes to the configuration, etc., the changes will be made to the user account in which you are executing the command. For example, suppose you have an X user who is a normal user and a Y user, who is an administrator. If you log in to X and then run with the administrator credentials, changes will be made to the administrator settings, not the user X.
Therefore, if you install an application by right-clicking on the EXE file and selecting Run as administrator, it will be installed in the user profile Built-in Administrator, not the one you started. If you want true elevated privileges such as sudo without profile problems, see the following alternative below.
Sudo for Windows – Sourceforge
Sudo for Windows is a free program that you can install and give you the same experience as the sudo command in Linux for Windows. The only difference is that Sudo for Windows "retains the user's profile and ownership of the created objects" as established by the developer. This is really useful if you want to use elevated permissions to install applications or make changes to user locations such as My Documents, etc.
Give you administrative privileges, but keep all changes in the current profile instead of the account you are using to execute the command. The program requires .NET version 2.0, which cannot be downloaded individually. To get 2.0, you must install .NET Framework 3.5, which includes 2.0.
Once you install Sudo for Windows, you must add the user accounts that allow you to have elevated privileges to a specific group created by the program called S udoers . Right click on My Computer or This PC and click Manage . Then expand Users and Groups and click Groups . You should see one called Sudoers .
Double click Sudoers and click on the button Add .
In the following dialog box, click on the button Advanced and then click on Search now . This will show a list of all users and groups in the system. Double click on the user you want to add.
Repeat this step for all the users you want to add. Then click OK and you should see the members listed in the list box Members that are show above. Click OK and now you should be able to use the GUI and the sudo command. If you right-click on a program, see the option Sudo .
You can also open a command prompt and type sudo to execute the command with elevated permissions.
In general, it is quite ingenious and works very well. However, keep in mind that this particular program is really useful for Start programs or processes either by clicking with the right button or through the command prompt, but it is not intended to run command line applications. For example, if you want to do sudo mkdir "c: Program Files new", this will not work using Sudo for Windows. For that functionality, there is another program called the same, but by a different developer. Read below.
Sudo for Windows – Luke Sampson
There is another developer who wrote another Sudo for Windows that also allows you to run command line applications. So let's go back to the example on how to create a new folder in C: Program Files. You can't really do this by default.
Previously I am using PowerShell, but you will also get the same error when using the command prompt. However, once you install Sudo for Windows, simply add the word sudo to the front of the command and it works perfectly without errors!
To install it, you need to open PowerShell and then type the following commands in order:
iex (new-object net.webclient) .downloadstring ('// get.scoop.sh') set -ecutionpolicy sin restricciones -s cu -f scoop install sudo
If everything works fine, you should see the following result in PowerShell after each command:
That's! Now you can start typing commands and add sudo to the front. The only annoying thing about this program is that the UAC window keeps appearing and you have to click on S to make it work. Even with that slight discomfort, the benefits are worth it.
Elevate is a program that works with UAC and does not work exactly as sudo. With Elevate, change the running user to Administrator as the runes command does. However, it is useful for working on the command line or with batch files.
The main purpose of elevating is not to move through UAC, but to start a process in an elevated state from a non-elevated shell and then continue normally even after the command has been completed. Elevate is useful for scripts because you don't have to worry about trying to make a script with the entire right mouse button and run a command prompt as an Administrator process.
Lifting PowerToys for Windows
For those of you who work a lot on the command line or work with scripts and batch files, then the Elevation PowerToys for Windows page has plenty of useful tools and scripts.
The scripting power elevation toys were created to overcome the frustrating aspects of UAC by trying to raise a program from the command line or run scripts as administrators.
Hopefully, there are enough tools and programs to make you feel like you are using sudo in Windows. There is no perfect replacement for him, but there are quite a few options that come close. If you use something else to raise programs, commands or scripts in Windows, let us know in the comments. Enjoy!