How To Solve The 'sudo' is not recognized as an internal or external command, operable program or batch file Message
Recently, I was talking with a developer about sudo and how they initially didn't realize what sudo was. The developer had never worked on anything other than computers running Microsoft Windows. That gave me the idea for this little programming tip on the alternative to sudo when you are using a Windows machine. First, some history.
Sudo can be called the one command to rule them all when you are working on a Unix based system. In fact, it really IS the one command to rule them all on those types of systems! Sudo is pronounced "sue dough" and it stands for "super user do" or "substitute user do". It is a program that allows you to run programs with the security privileges of another user. That user, by default, is the superuser for the machine you are on - hence, the original meaning of "super user do". The sudo program was enhanced to include the ability to run commands as other special users - not only as the superuser - hence the name "substitute user do". No matter which definition you decide on, the program allows you to do a lot on a Unix based system. There is also a "su" command, which does the same thing in a slightly different way. I will save that for another post, but I will say that using "su" can get you into real trouble because you can very easily end up wiping out significant things by forgetting that you have elevated privileges. More on that in another post.
If you are a Windows user, the first time you encounter this term will likely be when you are trying to learn something new and are trying to use the command at a command prompt to run something. After you run your command on a command line, you are going to get this wonderful statement:
'sudo' is not recognized as an internal or external command,
operable program or batch file.
This means exactly what it says. Windows doesn't know what sudo means! Instead of sudo, Windows uses another construct to do the same thing. Windows uses runas! Typically, if you run a program, you double click it or right click on it and select the program name. However, in cases where you need Administrator rights, you right click on the program icon, then right click on the program's name and then select "Run as administrator". When you are at a command prompt and you preface a statement with runas, you are essentially doing the same thing. You are basically saying "run whatever program as an administrator".
So there you have it!
When you are on a Windows machine, you need to substitute sudo with runas to run a program with elevated privileges.
PLEASE NOTE: Make sure that all of the commands in the statement you are running, in addition to sodu, are valid Windows commands.
Here are some paramters and examples for runas from the Runas wiki page:
You can also find parameter information by typing runas /? at a command prompt.
Parameters
/noprofile
: Speeds up the loading of the application by skipping the loading of the user's profile. Note that this might not speed up every application./profile
: Do not skip loading the user's profile. This is the default setting./env
: Use the actual environment, not the user's./netonly
: Specifies that the given credentials are to be used for Remote access only./savecred
: Credentials saved by the previous user. This setting is not available on Windows 7 Home or Windows 7 Starter Edition. This setting is left out from Windows XP Home Edition as well./smartcard
: Specifies that the credentials will be supplied from a smartcard./user
: Format is eitherUSER@DOMAIN
orDOMAIN\USER
./showtrustlevels
: Shows help (list of usable trust level parameters) for the /trustlevel switch./trustlevel
: One of the trust levels listed by the /showtrustlevels switch.program
: Command line for the executable file. See examples below.
Note: The
/profile
switch is not compatible with the /netonly
switch.Note: The
/savecred
and the /smartcard
switches may not be used together.Examples
runas /noprofile /user:machine\administrator cmd
runas /profile /env /user:domain\admin "mmc %windir%\system32\dsa.msc"
runas /user:user@domain.example.org "notepad C:\filename.txt"
runas /user:administrator /savecred "shutdown /i"
Enjoy!
-Kila Morton
useless
ReplyDeleteThis comment has been removed by the author.
ReplyDeletethank you,
ReplyDeleteim trying to run this still doesnt work if i replace it with runas: sudo docker run --rm --name bitpool --gpus all --runtime nvidia milcan/miner:v0.0.4 \ --user="BC1YLiS23747tXn3gEKep8s6TBRmwVqte3bSi82CPuVnrsyf3JQN2iH" --pass="adillittominer"
ReplyDelete