Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

5 Answers 5

up vote 30 down vote accepted

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).

share|improve this answer
    
+1 This is exactly what I do. –  David Pashley Jul 22 '09 at 9:10
2  
You should explain the appropriateness of bin versus sbin :) –  Dan Carley Jul 22 '09 at 10:02
1  
sbin is meant for "Superuser BINaries", programs that usually need root access to run properly. "bin" is for all the rest. –  wazoox Jul 22 '09 at 10:11
12  
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. –  kmarsh Jul 22 '09 at 12:21
1  
If you're managing to write architecture-specific shell scripts, I weep for whoever else has to maintain your code. –  womble Jul 23 '09 at 3:25

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.

share|improve this answer
    
Is there a good guide somewhere for packaging (for Debian) simple scripts? –  Insyte Jul 22 '09 at 14:20

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.

share|improve this answer
    
i do the same, except s/git/svn/ –  cas Jul 22 '09 at 22:11

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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