I have my own shell script files and I want to run them in terminal, keeping them in /usr/bin folder. But my question is: which directory is best for keeping files of my own script? I want to use this files when I call my script in Terminal. /opt, /usr/local, e.t.c. Which is the best choise?


$HOME/bin is probably a good place if you want to call them without directory prefix. That folder is in your path so you can run your scripts like if they were installed in /usr/bin for example.

But you can place them wherever you want, to keep your directory structure organised and optionally add those folders to PATH aswell.

  • yes, I know, my script files are in /usr/bin. I want to know where I must keep my necessary files/folders which my script works on them? – Ziyaddin Sadigov May 5 '13 at 9:51
  • 2
    @ZiyaddinSadigov You can use ~/.config/myfiles for those files and access them in your script with $XDG_CONFIG_HOME/myfiles. – Basharat Sialvi May 5 '13 at 9:57
  • 2
    For system-wide scripts I'd recommend /usr/local/bin (user) or /usr/local/sbin (root only). It would be a pain to link/copy them in all user's home directories. – gertvdijk May 5 '13 at 10:17
  • @gertvdijk thanks, nice comment! You say that further files I can keep in /usr/local/bin? Script will work with files in /usr/local/bin? – Ziyaddin Sadigov May 5 '13 at 10:34
  • 1
    @ZiyaddinSadigov See your path (execute echo $PATH) and you'll see. – gertvdijk May 5 '13 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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