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)
Asked
Active
Viewed 1.8k times
2
ir-g
- 1,254
4 Answers
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:
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:
- Create the private
bindirectory. Either via the nautilus GUI or via issuing the commandmkdir ~/binin the terminal. - Reload the
~/.profilefile. You do this by typing executing the terminal commandsource ~/.profile. - Copy and paste your executable into the
~/bindirectory or create a link to your executable into the~/bindirectory.
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
/bin, it must have the executable bit set. (e.g. withchmod +x <file>) – Alex R. Jan 16 '14 at 17:36chmod +x <file>, something much easier. – ir-g Jan 16 '14 at 18:03