2

Is it possible to create a folder E.G.~/bin which contains executables, and once a file is added to this folder, it is executable from command line. (Just like an executable in /bin)

ir-g
  • 1,254
  • A file isn't exectuable from the fact that it's located in /bin, it must have the executable bit set. (e.g. with chmod +x <file>) – Alex R. Jan 16 '14 at 17:36
  • @AlexR. I am looking for the ability to run executables without path, regardless of my current working directory. Not chmod +x <file>, something much easier. – ir-g Jan 16 '14 at 18:03

4 Answers4

3

Just create a folder ~/bin. Add the following line in your ~/.bashrc,

export PATH=/home/$USER/bin:$PATH

Source ~/.bashrc from terminal as,

. ~/.bashrc

Put files with execution permission inside ~/bin.

sourav c.
  • 44,715
2

I'm assuming you want to be able to call these executables without typing out the full path each time. Am I right?

Add your folder to the default path, and that'll do it:

http://www.cyberciti.biz/faq/unix-linux-adding-path/

Xavier J
  • 531
  • 2
  • 8
0

In Ubuntu 20.04, a user's ~/.profile file by defaut contains the statement:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

Hence all a user has to do is to:

  1. Create the private bin directory. Either via the nautilus GUI or via issuing the command mkdir ~/bin in the terminal.
  2. Reload the ~/.profile file. You do this by typing executing the terminal command source ~/.profile.
  3. Copy and paste your executable into the ~/bin directory or create a link to your executable into the ~/bin directory.
Sun Bear
  • 2,302
0

Just create the folder and insure that you have the following in ~/.profile

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
Elder Geek
  • 36,023
  • 25
  • 98
  • 183