Where do you normally keep your UNIX/Linux scripts?

12,697

Solution 1

Personal ones for my account, ~/bin. System-wide ones go in /usr/local/bin or /usr/local/sbin as appropriate (scripts which should only be run as root go in sbin, while scripts intended to help ordinary users go in bin), rolled out via configuration management to ensure that all machines that need them have them (and the latest versions, too).

Solution 2

For more complex stuff, especially something that could be shared between multiple machines I tend to make distribution packages, Debian in my case. I use /usr/bin, and give scripts some common prefix. That way it's easier to deploy and keep track of them. For my personal stuff, ~/bin is good enough.

Solution 3

At the moment I use ~/bin for my personal (quick and dirty :P) scripts and /usr/local/bin (or sbin) for system wide ones

Both directories are under revision control via git.

Solution 4

I currently use /usr/local/$company/scripts for system-wide scripts, and ~/bin for personal. I also have a ~/code folder that contains work-in-progress stuff.

Solution 5

I use ~/.bin
The folder is hidden for file managers and ls: i rarely modify anything inside, so let it be :)

Share:
12,697

Related videos on Youtube

AB.S
Author by

AB.S

learning...

Updated on September 17, 2022

Comments

  • AB.S
    AB.S almost 2 years

    There are numerous scripts that I have written for my server. Some of them are in my ~/scripts and some of them are in application directories.

    I am just wondering is there a directory that you would normally use to keep your shell scripts?

  • David Pashley
    David Pashley almost 15 years
    +1 This is exactly what I do.
  • Dan Carley
    Dan Carley almost 15 years
    You should explain the appropriateness of bin versus sbin :)
  • wazoox
    wazoox almost 15 years
    sbin is meant for "Superuser BINaries", programs that usually need root access to run properly. "bin" is for all the rest.
  • kmarsh
    kmarsh almost 15 years
    The origin of sbin came from "Statically-linked BINaries". When /usr (and its shared libraries) were mounted outside of single-user mode, it was found necessary to keep around some statically linked programs (sh, tar) that always worked. Since only the SysAdmin was interested in these binaries, the misnomer began.
  • Admin
    Admin almost 15 years
    I wondered about that too, I fear none of my scripts are worthy of the distinction :)
  • Return_Of_The_Archons
    Return_Of_The_Archons almost 15 years
    Is there a good guide somewhere for packaging (for Debian) simple scripts?
  • cas
    cas almost 15 years
    i do the same, except s/git/svn/
  • David Gardner
    David Gardner almost 15 years
    I do the same thing but with an extra level of directory for $ARCH -- so ~/pub/$ARCH/{bin,man,share} to allow for i386, x86_64 and any other architectures you have binaries for (I used to use SGI machines and various Sparcs, so this was more useful then :)