/bin vs. /usr/bin vs. /usr/local/bin: Difference?

Here’s everything about the differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, and /usr/local/sbin:

All of these folders hold binary files on a Linux-based system.

The various designations in the folder name denote whether or not the binaries can load before a user is mounted.

They also distinguish between locally installed binaries and more fundamental systems, but each folder is focused on binary files.

So if you want to learn all about how /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, and /usr/local/sbin differ, then this article is for you.

Let’s get right to it!

/bin vs. /usr/bin vs. /usr/local/bin: Difference? (+ /sbin)

What Is /bin? (3 Things)

Business woman working in office

If you want to get deep into the differences between these folders and directories, we’re going to have to explore some fundamental concepts in Linux.

I’m going to start with /bin, but I’ll have to circle back around in order to explain some core ideas so that everything will make sense.

With enough background, I’ll be able to go through each of the different “bin” locations and cover the primary differences between them.

So, starting with /bin, this is where you will find binaries for all users on a Linux system.

That means that /bin is filled with executable files, and this is a good place to find common commands like

  • cat
  • cp
  • cd
  • ls
  • and so on

Since these commands are very basic and essential to Linux controls and systems, you could say that /bin is a place in the file system that holds some of the most fundamental executable commands that you can use in Linux.

#1 Linux

Woman looks at laptop screen with surprise while watching online lecture or webinar

Of course, that explanation will only make sense to people who are already deeply familiar with Linux.

For anyone else, we need to back up a bit.

What is Linux?

It’s an operating system.

That means it’s similar to Windows, iOS, Android, macOS, and any other operating system.

An operating system is the software that is installed on a computer system that allows you to work with it.

The operating system is what loads when you power on the computer, and any specific program or application you want to run on that computer ultimately works via the operating system.

It’s the essential set of information and control functions that allow the software to communicate with a device’s hardware.

In the case of Linux, it’s an open-source operating system.

That means you don’t have to pay for it, anyone can make changes to it, and there’s a large collaborating community that works to improve it.

Linux has actually been around since 1991, and there are many, many versions.

Not all variations of Linux will be identical in all ways, but they are made from the same skeleton, so to speak.

That means that in any Linux system, you should be able to find /bin and the rest of the folders and directories I’ll be discussing today.

#2 Linux File Basics

Successful caucasian business woman does her work in late time

While we’re on that topic, it’s worth explaining a little bit about the Linux file system as well.

Any operating system needs a file system in order to keep information organized.

Any data on the computer or any programs that you want to run are stored as files, and they are organized according to the file system.

In Linux, any file location is placed in a hierarchy, and each segment of the hierarchy is denoted by a forward slash (/).

This is as opposed to Windows which uses a backslash (\).

What that means is that “/bin” is a hierarchical designation.

You could potentially have things before or after “/bin” (more on that later) and it would give more clarity to the designation.

If nothing comes before the first forward slash, then it means you are looking at a root directory.

That’s another way to say that there is nothing more basic in the hierarchy.

Knowing that you can see that “/bin” is at the root level. 

#3 Binary

Side view close up of adult man using laptop while enjoying work in office

When I explained “/bin,” I mentioned something about holding binaries.

Now is a good time to explain what that means.

A binary in a computer system is a file that is written in binary language.

In other words, it’s already in the language of the machine.

Other kinds of files might be written in a human language so that users can read them.

Such files have to be translated into the machine language before the computer can work with them.

Binary files are already in the computer language, and that has a few implications.

First, it means that binary files can execute easily.

It’s possible to make binary files that give the computer commands (this is probably the primary use for such files).

Binary executables (files that tell the computer to carry out tasks) don’t require extra software in order to run.

The computer can get right to it.

Because of this simplicity, you can make binary files that are not editable.

You make the file, and then it can never be changed, and this is one of the important aspects of a binary file.

Some of your most basic computer functions exist as binary functions.

If you’re using a command shell to give direct instructions to a Linux computer, any function you type in there is likely a binary file.

As an example, changing directories in the shell uses the function “cd.”

The “cd” function is a binary.

Ultimately, binaries cover a wide range of Linux files.

The ones we’re going to discuss today largely revolve around executables.

What Is /sbin?

Female freelancer working at home using her laptop

With all of that background covered, we can get back to the directories in question.

We know what /bin is, so let’s move on to the next one.

What is /sbin?

The name gives away the answer if you know how to read it.

As you might have figured out by now, “bin” refers to binary files.

So, any directory with “bin” in it is likely going to house binary files.

In this case, we have bin plus an extra s.

The s in this case refers to the superuser.

In Linux, a superuser has absolute control over everything on the computer.

Important system files that you don’t want to be easily accessed are often locked to all but a superuser.

So, /sbin is a place that houses system-level binary files.

Basically, this is a folder for system administration utilities.

These are files that enable the computer to boot, restore, recover, and carry out other extremely essential tasks.

More specifically, /sbin is the root-level folder for system binary files.

That means it houses the most fundamental utilities for a Linux system.

There are other sbin folders, as you’ll soon see, and they house different utilities according to the larger directory names.

What Is /usr/bin?

Female freelancer working at home using her laptop

Looking at /usr/bin is a great chance to learn a little more about the Linux file path naming conventions.

This is still a folder for binary files, but it’s no longer on the root level.

Instead, it’s under the /usr heading, and that tells us something too.

This directory holds user programs and files.

That means that you cannot run binary files in this directory until after you log into the system with a user account (or designate a user within the shell).

Now, this does not mean that only one user on the device can make use of files in /usr/bin.

It only means that /usr must be mounted before /usr/bin is accessible.

In other words, a specific user has to be logged in.

As long as the logged in user has permission, any user can access the files in /usr/bin. 

In fact, this directory still holds important executables that help essential systems run.

They’re just not at the most fundamental level anymore.

A good example is the “find” command.

This is a binary executable that can help you find specific files in the system.

It’s available to all users, but you need to load a user before it really makes sense to want to search for anything specific.

What Is /usr/sbin?

Woman working with her computer

Next on the list is /usr/sbin.

This looks a lot like the directory we just discussed with a one-letter difference.

But, that one letter is an s, and as we’ve already learned, the s in a path name can be pretty important.

In this case, we’re looking at the location for system binaries that only execute after mounting a user.

That explanation is combining everything we’ve learned so far today.

Since it’s in the /usr directory, we know we need a user to access the files in there.

Since it’s an sbin folder, we know that it specifically houses system binaries, which are usually administrative utilities.

What Is /usr/local/bin?

Shot of a young businesswoman working on a computer in an office. Portrait of an successful young creative businesswoman using PC at her workplace in the modern office

Second to last, we get to introduce another common directory path.

This time, we’re learning about /local.

This is a designator for things that you add to the system as a user.

That can include anything from pictures to advanced software.

It doesn’t really matter.

If you install it locally, then it goes into one of the /local directories.

In this case, the /usr/local path name is telling us that the local stuff is only available after loading in a user.

That makes sense considering these are things you have to add to the computer yourself.

Lastly, the /bin part of the name is still telling us that this folder houses binary files.

For the most part, binary files that you install yourself will go into this folder.

There is an exception in the next part, but this folder is going to house a lot of third-party executables and other files.

What Is /usr/local/sbin? 

Close-up shot of man's hand with watch on his wrist. using keybo

Lastly, we have /usr/local/sbin.

Everything in this file path name is the same as the above with the addition of that single s.

So, this folder is still housing locally installed binary files that are accessible after signing in with a user account.

That all makes sense.

But, this particular folder holds binary files that are restricted to superuser access.

Basically, this is where third-party software holds executables that can install or otherwise change the software itself.

If you have a program that needs a software repair, the function to carry out that repair might be superuser restricted.

It makes it harder to accidentally run functions that have the ability to break things on your computer when they aren’t used correctly.

Author

  • Theresa McDonough

    Tech entrepreneur and founder of Tech Medic, who has become a prominent advocate for the Right to Repair movement. She has testified before the US Federal Trade Commission and been featured on CBS Sunday Morning, helping influence change within the tech industry.