Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
12-28-2007, 11:31 AM
|
#1
|
|
LQ Newbie
Registered: Aug 2006
Posts: 7
Rep:
|
Where (in which directory) to store shell scripts ?
Hello everyone,
I am trying to transition from Windows to Linux, and I have to start by changing my habits one by one.
For my various day to day tasks, I wrote a few scripts (backup, archiving, etc.) and I was wondering if there is a preferred directory where I should store them.
Right now, they are all sitting in /home/bob/script. I was wondering, should I rather store them in /usr/bin , or is this only used for binaries ?
Thanks in advance,
BN
|
|
|
|
12-28-2007, 11:46 AM
|
#2
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,558
|
The beauty of unix is the idea that you can put just about anything anywhere. But naturally there are a lot of traditional arrangements for the file system. As long as you're only using the scripts as a single user, your current location is just fine. But if you want them to be accessible system-wide, then somewhere in the /usr directory is probably best. /usr/bin is mostly for the distro-installed stuff, and /usr/local/bin is where the stuff you write or compile yourself usually goes (most source packages default to installing there, for example).
Wherever you decide to put them though, you can add the directory to your PATH environment variable so they'll be easily accessable by the system (i.e. you won't have to type the entire path to the script in order to run it).
|
|
|
|
12-28-2007, 12:51 PM
|
#3
|
|
Member
Registered: Jun 2007
Location: Munich, Germany
Distribution: RHEL, CentOS, Fedora, SLES (...)
Posts: 399
Rep:
|
It is right that you can put your scripts nearly everywhere in Linux. You can accustom anything. However it makes sense to abide to existing standards like the File Hierarchy Standard [1]. Therefor I would recommend /home/username/bin , /usr/bin or /opt/scriptfunction/
[1] http://www.pathname.com/fhs/pub/fhs-2.3.html
|
|
|
|
12-28-2007, 01:07 PM
|
#4
|
|
Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Squeeze, Fedora 14
Posts: 7,268
Rep:
|
I recommend that you store your scripts somewhere in /home/user as this makes life easier when you upgrade your operating system.
--------------------
Steve Stites
|
|
|
|
12-28-2007, 01:37 PM
|
#5
|
|
LQ Newbie
Registered: Aug 2006
Posts: 7
Original Poster
Rep:
|
Thanks for all the replies.
I was mostly looking for a "best practices" type of approach.
They are going to remain in /home/bob/script then.
|
|
|
|
12-31-2007, 08:46 AM
|
#6
|
|
Member
Registered: Jun 2006
Location: Delaware
Distribution: Redhat, Fedora
Posts: 43
Rep:
|
/usr/local/bin
|
|
|
|
12-31-2007, 09:08 AM
|
#7
|
|
Senior Member
Registered: Aug 2006
Posts: 2,695
|
Quote:
Originally Posted by jeepescu
Thanks for all the replies.
I was mostly looking for a "best practices" type of approach.
They are going to remain in /home/bob/script then.
|
Not advisable in general. If you leave the company and forgot to tell your successor that your scripts are stored there, he might remove your account and all files inside (just an example, but who knows, right).
Just some recommendations:
In your environment, you should set up a designated place in your production system to store your files. For example, for data files, you can create partitions or folders and name it data (up to you)
eg
/production/data
then under this folder/partition, you can create other folders for various systems in your environment that needs to generate data for storage of further processing.
eg
/production/data/financial
For storing scripts that are run in cron job, you can, for example, create partition/folders and name it
eg
/production/binaries
Then create subdirectories for each systems and put your scripts there
eg
/production/binaries/financial
I won't advise putting into /usr also, simply because you might forget(or someone else) and then you wipe your OS for upgrade.
You should probably discuss with your superiors about all these and how to go about organizing your servers.
Last edited by ghostdog74; 12-31-2007 at 09:14 AM.
|
|
|
|
12-31-2007, 10:05 AM
|
#8
|
|
Guru
Registered: Jan 2001
Posts: 24,128
Rep: 
|
/usr/local/bin was created for such things. /usr/bin is a default for binary programs and installs. Put your own scripts in /usr/local/bin. Usually this is already in your default PATH as well.
|
|
|
|
12-31-2007, 11:22 AM
|
#9
|
|
Senior Member
Registered: Aug 2006
Posts: 2,695
|
Quote:
Originally Posted by trickykid
Put your own scripts in /usr/local/bin.
|
IMO, own written scripts for production should have a place of its own, for better management and not confusing them with those in /usr/local/bin.
/usr/local/bin are usually for third party installation packages.
|
|
|
|
01-01-2008, 07:56 AM
|
#10
|
|
Member
Registered: Jun 2007
Location: Munich, Germany
Distribution: RHEL, CentOS, Fedora, SLES (...)
Posts: 399
Rep:
|
Ideally scripts for production are embedded in a package like deb or rpm so that no one forgets about them ;-)
|
|
|
|
01-01-2008, 08:01 AM
|
#11
|
|
Guru
Registered: Jan 2001
Posts: 24,128
Rep: 
|
Quote:
Originally Posted by ghostdog74
IMO, own written scripts for production should have a place of its own, for better management and not confusing them with those in /usr/local/bin.
/usr/local/bin are usually for third party installation packages.
|
Just depends where you install 3rd party applications, most of the time those go in /usr/bin for me. It's all a matter of opinion and preference. There is no wrong answer, except the /home directory, that's for users own files, not files to be used by everyone.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 05:54 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|