This might be a repeated question, but I couldn't relate to any previous answer. I basically want to run my shell-script from anywhere in ubuntu 16.04 (whether I'm inside the directory where the shell-script is placed or not).
I know the first method which is to place the shell-script inside the /home/user/bin
directory (that is already set in the $PATH
), change the shell-script permission mode and, finally, reset the bash by re-starting the terminal. This way everything worked fine.
But, since I want to learn how to set the environment myself, instead of using /home/user/bin
I would like to use my own created directory.
So, I placed my shell-script inside a newly created /home/workspace/myproject/bin
directory and, of course, I changed its mode. Then run the following command:
echo $PATH
Then, amended the $PATH
variable as follow:
PATH="/echo/command/result:/home/workspace/myproject/bin"
Then, set the environment:
source /etc/environment && export PATH
But it doesn't work !
UPDATE
I know I could also do it through editing the ~/.profile
file. But my aim is to do it directly from the terminal without having to open and edit a file. And you can see why, using only two commands in a row, immediately after finishing writing the shell-script, is much faster, right ?
To be clear: I want to know why resetting of the /etc/environment
didn't work?
PATH
statement is incorrect ?! – McLan Feb 14 '19 at 13:57PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
. Much easier to edit ~/.profile once, than typing this in multiple times, as per my answer. – heynnema Feb 14 '19 at 14:13