The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 391,407β€…    Votes:  47β€…
Tags: command-line   filesystem   scripts   directory   system  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

URL: https://askubuntu.com/q/1045759
Title: Differences between /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin
ID: /2018/06/11/Differences-between-_bin_-_sbin_-_usr_bin_-_usr_sbin_-_usr_local_bin_-_usr_local_sbin
Created: June 11, 2018    Edited:  June 12, 2020
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


I had a similar question myself a year+ ago: Best directory to place my bash scripts?

System directories for binaries

man hier (hierarchy) lists all the directories. To get the ones just for binaries use:

$ man hier | grep -E 'bin$|sbin$|^.{7}(/bin)|^.{7}(/sbin)' -A2

       /bin   This directory contains executable programs which are needed in single user
              mode and to bring the system up or repair it.

--
       /sbin  Like  /bin,  this  directory  holds commands needed to boot the system, but
              which are usually not executed by normal users.

--
       /usr/X11R6/bin
              Binaries  which  belong  to the X-Window system; often, there is a symbolic
              link from the more traditional /usr/bin/X11 to here.
--
       /usr/bin
              This  is the primary directory for executable programs.  Most programs exe‐
              cuted by normal users which are not needed for booting or for repairing the
--
       /usr/local/bin
              Binaries for programs local to the site.

--
       /usr/local/sbin
              Locally installed programs for system administration.

--
       /usr/sbin
              This directory contains program binaries for  system  administration  which
              are  not  essential  for the boot process, for mounting /usr, or for system

Where to put your own scripts?

For all users to access your scripts you can put them in /usr/local/bin. Keep in mind you need sudo access to add / change files here. See: Is there a standard place for placing custom Linux scripts?

For your own user ID scripts put them in /home/YOUR_NAME/bin. Keep in mind you have to create this directory first and relaunch the terminal to get the path automatically setup by ~/.profile. See: How to add /home/username/bin to $PATH?


What I know I don’t know

I’m contemplating taking some of my more complex bash scripts in Ask Ubuntu and setting them up with install scripts on github. Here are few examples:

I think the scripts should be installed in /usr/bin which is in the $PATH, but I’m not sure on the appropriate place yet.

⇧ How to disable automatic brightness adjustment in Ubuntu 14.04? I cannot use MySql as normal user in Ubuntu 18.04  β‡©