Skip to main content

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 either USER@DOMAIN or DOMAIN\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: Only type in the user's password, when the system asks for it.
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


Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. im 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

Post a Comment

Popular posts from this blog

How To Solve Connection attempt failed with "EAI_NONAME - Neither Nodename Nor Servname Provided, Or Not Known

If you have ever tried to import a file into FileZilla from your domain host only to find that using the supplied settings produced the, Connection-attempt-failed-with-EAI_NONAME---Neither-nodename-nor-servname-provided-or-not-known".   error, you are in luck. I am going to show you a quick way to take care of this issue. When you are using an FTP client to connect to your site, you typically have a setup that looks something like this. (Note - if you are using FileZilla, your screen looks EXACTLY like this, since this is the ftp client I am using here.) Notice the area I have highlighted in Yellow. This is the problem child in this scenario. Although your hosting company may have stated that you should use ftp.YourWebsite.com, that is often NOT the correct thing for you to use to gain remote ftp access to your site. The error means that the program cannot resolve the dns entry for your site. Instead of using ftp.YourWebsite.com, you need to replace the host ftp.YourWeb...

How To Reset Your Entry Processes Or How To Clear Your Entry Processes In A Shared Hosting Environment Using CPanel

One of the most frustrating things is to wake up one morning and discover that your website is down (a 508 error) and you don't have a tool to get it back up and, instead, have to contact your hosting company to reset things for you. Sometimes, if you are using a content management system, the issue may be something as simple as a plugin. Do you really want to have to reach out to your host every time you have an issue? If you don't, I am going to show you one way to get your account back up and running. This will not work for everyone, but if you are using certain technologies, it will work for you. What you will need: Access to your cPanel. An account running PHP ISSUE: You have used up all of your allocated server resources and your site is now experiencing a 503 or 508 error and is not allowing any traffic to reach your site. SOLUTION: Log into your cPanel account. If you do not have a cPanel account, this won't work for you. Search for Select PHP Versi...