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).
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.
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.
If you don't want to mix your own scripts with scripts placed in ~/bin by installed packages and programs, you can store your scripts in a directory of your choice and bind it to ~/bin. Your scripts will be visible in ~/bin and you will be able to run them from a terminal with a simple name without having to specify a path.
For one time use you can run this command (effect will disappear after reboot):
sudo mount --bind ~/path-to-your-scripts-directory ~/bin
You can create a new script with this command and run it automatically at login to remount this binding after a reboot.
Or
To bind permanently, add these lines to fstab:
# bind my scripts to ~/bin
/home/myaccount/path-to-your-scripts-directory /home/myaccount/bin none bind 0 0
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 insbin
, while scripts intended to help ordinary users go inbin
), rolled out via configuration management to ensure that all machines that need them have them (and the latest versions, too).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.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.
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.
I use ~/.bin
The folder is hidden for file managers and
ls
: i rarely modify anything inside, so let it be :)If you don't want to mix your own scripts with scripts placed in
~/bin
by installed packages and programs, you can store your scripts in a directory of your choice and bind it to~/bin
. Your scripts will be visible in~/bin
and you will be able to run them from a terminal with a simple name without having to specify a path.For one time use you can run this command (effect will disappear after reboot):
You can create a new script with this command and run it automatically at login to remount this binding after a reboot.
Or
To bind permanently, add these lines to
fstab
: