What is the Difference Between /opt and /usr/local?

Many users often mix the “/opt” and “/usr/local” directories in Linux because the concept of both is a little bit the same. Both directories contain installation files but do not belong to the same set of files. The “/opt” directory contains the package/software installation files that do not belong to the system or, in simple words, third-party applications. On the other hand, the “/usr/local” directory contains installation files built by the system administrator. 

This post will briefly describe the “/opt” and “/usr/local” directories in Linux.

  • What is the “/opt” Directory in Linux?
  • What is the “/usr/local” Directory in Linux?
  • Comparison of “/opt” and “/usr/local” Directories

What is the “/opt” Directory in Linux?

In Linux, the “/opt” directory is reserved for the installation of “add-on” software/packages (external or third-party software). Each package installed in the “/opt” contains binaries, libraries, and configuration files in a single directory. The “/opt” directory facilitates the user to deploy applications on the server by copying the particular application directory. 

First, navigate to the “opt” directory using the “cd /opt” command and check the files present in the “/opt” directory using the  “ls” command as provided:

$ ls

The “/opt” directory contains the “google” directory (third-party app).

Note: You can also use the “ls /opt” command to do the same. 

What is the “/usr/local” Directory in Linux?

In Linux, the “usr/local” directory is reserved for the applications installed system administrator that belongs to the operating system. The “/usr” directory has permission to read-only while the “/usr/local/bin” has read-write permission for the successful execution of software. 

Check the files present in the “/usr/local” directory using the  “ls” command as provided:

$ ls /usr/local

The above-given directories contain the installation files of the application that belongs to the operating system.

Difference Between “/opt” and “/usr/local” Directories

The comparison between the “/opt” and “/usr/local” directories are shown in the following table: 

The “/opt” DirectoryThe “/usr/local” Directory
The “/opt” directory contains the installation files of the third-party software.The “/usr/local” directory contains the installation files built by the system administrator, usually via the “make” command.
All installation files (binaries, configuration, and libraries) are in a single directory.The installation files are divided into the sub-directories, such as for binaries, the directory is “/usr/bin,” and libraries are in the “/usr/local/lib.”

Conclusion

In Linux, the “/opt” directory is particularly for third-party applications, while the “/usr/local/” is for the software built by system administrators. In “/opt,” all files such as binaries, configuration, and :libraries: are in a single directory, while in “/usr/local,” all files are divided into subdirectories.

This write-up has illustrated the difference between “/opt” and ”usr/local” directories in Linux.