LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-27-2007, 05:12 PM   #1
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Rep: Reputation: 30
where do i put my written scripts


hi
i have written a few scripts i want to be able to run them from any user and any directory
i have changed the permissions i just cant remember where to put the script so i can run it like any normal command for example
when you run
$ls
i want to run my script like that from anywhere
 
Old 11-27-2007, 05:33 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
When you write your own scripts, you want to put them in a directory that's added to your $PATH environment variable. To see which directories are included in your $PATH, type
Code:
$ echo $PATH
at the CLI (Command Line Interface); the directories in the list are separated by colons ':'.

Note, to copy a script over to any of the directories listed in your $PATH, you more than likely need to be root;
Code:
$ su
Password: [type in your root password]
# cp -v myscript /copy/to/dir/
If you want to limit who can run the scripts to just you, create a directory in your home dir, and let's call it "bin":
Code:
$ mkdir ~/bin
Now, you have to add this directory to $PATH so that bash (assuming you're using bash) will know to look there:
Code:
$ echo "export PATH=$PATH:/home/user/bin" >> ~/.bashrc"


PS. In case you're wondering, the '>>' means append whatever is on the left of it, to the file to the right of the sign.
 
Old 11-27-2007, 05:42 PM   #3
Poetics
Senior Member
 
Registered: Jun 2003
Location: California
Distribution: Slackware
Posts: 1,181

Rep: Reputation: 49
Most users have access to /usr/local/bin which exists for local binaries and related files -- I generally throw my systemwide scripts there.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to put scripts in the startup..? balavignesh Linux - Software 1 08-28-2006 10:43 AM
Where do I put my cgi-bin scripts? BrianK Linux - Software 2 10-12-2005 10:59 PM
Where to put mldonkey scripts? Aioth Slackware 2 06-19-2004 08:29 AM
put my scripts to PATH Boby Linux - Newbie 1 06-14-2004 12:01 PM
Where to put protected scripts in Apache GoTrolling Linux - Software 4 01-16-2004 01:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration