Where is the bin?

python

#1

I’m trying to add a file named jel.py to my PATH so I don’t have to type ./jel.py -help whenever I want to run a jel command. How would I do this?


#2

I like to create a bin folder in my home directory for local executables. You can also place files in /usr/local/bin. You may need to use sudo to add your file there.


#3

echo $PATH
Will show all current paths to bins, you can place your script in any of those.

The better option would be to run this
export PATH=$PATH:$HOME/bin

And place your scripts in ~/bin


#4

@vasilenko93 Should I create a folder called ~/bin or just bin?


#5

mkdir ~/bin should work just fine.


#6

Ok, I put the bin folder in mkdir ~ and then tried to execute jel -help and it didn’t work. It gave me: bash: jel: command not found


#7

Hmm, does your path show up in echo $PATH? If it does, than check permissions are set correctly. Plus isn’t your file called jel.py not jel?


#8
bjskistad:~/workspace (master) $ echo $PATH
/home/ubuntu/.nvm/versions/node/v4.4.0/bin:/usr/local/rvm/gems/ruby-2.3.0/bin:/usr/local/rvm/gems/ruby-2.3.0@global/bin:/usr/local/rvm/rubies/ruby-2.3.0/bin:/mnt/shared/bin:/home/ubuntu/workspace/node_modules/.bin:/home/ubuntu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/mnt/shared/sbin:/opt/gitl:/opt/go/bin:/mnt/shared/c9/app.nw/bin:/usr/local/rvm/bin

Ran that. Nope. Not there. (And yes, my file is jel.py) Do I need to run chmod +x jel.py?


#9

Strange, I just followed the following steps and I was able to run a script that is inside ~/bin

  1. Create new folder in home directory called bin: mkdir ~/bin
  2. Update my PATH variable: export PATH=$PATH:$HOME/bin
  3. Create a script and move it to bin: mv script.sh ~/bin/script.sh
  4. Give the script executable permissions: chmod 755 ~/bin/script.sh or chmod +x ~/bin/script.sh
  5. Run script from anywhere script.sh

#10
bjskistad:~/workspace (master) $ mv jel.py ~/bin/jel.py
mv: cannot move ‘jel.py’ to ‘/home/ubuntu/bin/jel.py’: No such file or directory

#11

@vasilenko93 I solved it. I used sudo.