25

Is there an equivalent to bin for Windows? If so, how can I access it from the command prompt?

12
  • 6
    You need to elaborate a bit more... What are you looking for and trying to achieve?
    – Eric F
    Oct 6 '15 at 20:22
  • 8
    bin is not special, it is just listed in the PATH environment valuable. Microsoft's Windows also has this variable. Only difference is that it uses ; instead of :, and there is an implied . at the begging for added insecurity. So have a look in this variable. You can also edit it to add a bin directory. Oct 6 '15 at 20:23
  • Amazing what a good edit can achieve. :P Oct 6 '15 at 20:32
  • 1
    @MichaelFrank Especially when you make assumptions and add things the OP didn't ask about (ie: "can it be created in Windows"). We should be careful of that. Oct 6 '15 at 20:36
  • 2
    Or making the title ambiguous by removing a keyword like "directory". At first I thought the topic was about a file type.
    – sawdust
    Oct 6 '15 at 20:41
34

There's nothing actually special about /bin on Unix/Linux at all. It's just the location where executable files (including scripts, which aren't actually binary files) are placed by convention, and it is included in the PATH environment variable by default for all users. As Ryan says, the \Windows\System32 directory on Windows is also in PATH for all Windows users (and, even if it isn't, Windows' program loader will search there anyhow).

You can easily create your own equivalent of /bin on Windows. To make it system-wide, place it somewhere like the root of the file system (as in C:\bin) or under an already-restricted location like \Windows\System32\bin), and add it to the PATH environment variable for all users. For a per-user location, create the directory in your own profile (%USERPROFILE%\bin) and add it to your account's PATH environment variable. Windows combines the per-user and system-wide PATH environment variables, so anything in the machine PATH variable is also added to any user's PATH, but not the other way around.

Of course, you'll have to add files / scripts / shortcuts / symlinks to your bin directory yourself. Windows installers don't expect such a thing, and won't put files there automatically the way that Linux installers will usually do.

7
  • 12
    I wouldn't put a bin-like directory inside System32. That's the OS' domains. Better put it elsewhere, like your suggested c:\bin, and recreate the ACLs. Doing so shouldn't take more than a minute or two if you know your way around the ACL interface; slightly longer otherwise, but still not a long time.
    – user
    Oct 7 '15 at 7:14
  • 1
    I would add, that the standard way to get user-installed CLI tools accessible from the command prompt is adding their installation directory (Likely in %ProgramFiles%) to the PATH.
    – Jens
    Oct 7 '15 at 14:06
  • Windows does not combine environment variables with the same name -- normally user-level environment variables override system-level ones. PATH is a special case and AFAIK the only one treated that way by Windows.
    – afrazier
    Oct 7 '15 at 15:22
  • 1
    The OP never asked about creating a bin directory or environment variables... talk about off-topic. Aug 13 '16 at 17:19
  • 1
    With all due respect, asking about "an equivalent to bin for Windows" is asking about nothing except environment variables, because that is all that /bin is, a folder in the PATH environment variable. There are user conventions around how you use folders like /bin (or %WINDIR%, or %WINDIR%\System32), but the system does not know or care about them; all it cares about (in this context) is the PATH environment variable.
    – CBHacking
    Aug 14 '16 at 6:50
8

The bin directory in Unix-like systems contains the programs of the system and the installed ones, but in Windows, system programs are located in C:\Windows\System32 and installed ones are likely located in C:\Program Files.

6

If you're referring to bin, like in Unix/Linux, not quite. Windows doesn't use the FHS as shared by different Unix variants. Though Windows does keep stuff all over the place, just like Unix does.

The closest thing to /bin might be c:\windows\system32

cd c:\windows\system32
3
  • 1
    Neither Windows nor Linux (or the FHS) "keeps stuff all over the place". Windows uses primarily the System32 directory and the (nowadays two) Program Files directories to keep things reasonably orderly. In Linux (and many other Unix-like systems) you have bin (common user tools) and sbin (conventionally, system administration tools) under each of the root directory, /usr and possibly /usr/local, depending on system importance of the tool. (Both /usr and /usr/local can be separate from the root file system.) Windows doesn't have as clear separation in the file system between types of tools.
    – user
    Oct 7 '15 at 7:18
  • 1
    I think you just proved my point, there are many places where executables are stored. It is not random, if you think that's what I meant. My Linux desktop has 479 directories below /usr alone that contain executable files of some sort. If I picked through it, I guess some files would be inappropriately marked as executable, but you get the idea. The FHS specifies 7 standard parent directories that can be used for executable storage, many of which can have sub directories. Windows is similar, as it stores executables in several places under c:\windows and in c:\Program Files. Oct 7 '15 at 11:59
  • There are 6 entries in the PATH variable by default on Ubuntu systems. Oct 7 '15 at 12:02
2

As others have said, it's not clear exactly you mean by "equivalent", but many of the commands commonly used on the command line are either built into cmd.exe (dir, copy, type, mkdir, etc) even when the Unix equivalent would be in /bin, and others (findstr, net, mountvol, shutdown, tasklist, etc) are mostly located in (typically) C:\Windows\System32 (32-bit versions on 64-bit systems in c:\Windows\SysWOW64).

A list of commands can be shown with the help command, this includes some that are built-in to cmd.exe and some that are external programs.

0
1

I have been maintaining servers for almost 30 years both windows and Linux. For some reason at the beginning I started creating a bin folder in the root of c: and I always put all my scripts and utilities that I use to maintain the server. Sometimes I added to the Path but not always. Guess I always like the idea of a folder called bin on both systems to put my scripts in.

But yeah, nothing magical about it you can do something different on each system.

thanks,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.