I got an executable file(edit_envir
) in /home/pshizh/Desktop/
directory. I updated /etc/environment
file to make /home/pshizh/Desktop
included in PATH
. Then I ran command edit_envir
in terminal, but it said "dit_envir command not found
. However, after I copied file edit_envir
to /usr/bin/
and ran command edit_envir
in terminal again, it worked. Why? I'd really appreciate your help.

- 169,590

- 23
2 Answers
Don't edit the /etc/environment
file!!! revert the changes and put it back as it originally were. Your system is supposed to work with multiple users. Imagine you create another user, say johndoe
. Then what will happen when he logs in? he'll have, in his PATH
variable your directory /home/pshizd/Desktop
. I'm sure he doesn't care about that!
Instead, modify the PATH
variable from within your own personal .bashrc
file: add this snippet at the end of your .bashrc
file:
PATH=/home/pshizd/Desktop:$PATH
Now wait, your own scripts are not supposed to be located on your Desktop. Instead, create a bin
directory in your home directory, put your scripts there, and instead of the previous command in your .bashrc
file, put this:
PATH=$HOME/bin:$PATH
If you modify the file .bashrc
, the changes will only take effect in new terminals.
Now, if you want this script to be available to all users (e.g., you'll want johndoe
to be able to execute it, yet he should not have access to your personal directory), the best place is to put the script in /usr/local/bin
. This directory should already exist (create it if necessary), and should already be in every user's PATH
. Check that by inspecting the /etc/profile
file (but do not modify this file!); you could also grep
PATH
in there, as so (with some contextual lines):
grep -C4 PATH /etc/profile
you should see that /usr/local/bin
is added to the user's PATH
.
By the way, do not put your own commands in /usr/bin
! This place is for your distribution's binaries, not your personal ones.
Regarding why it didn't work after modifying /etc/environment
: you need to open a new terminal for changes to take effect.

- 5,843
After you edit /etc/environment
file, if you want the change to take effect, you need to log out and log back in or to source that file in terminal as follow:
source /etc/environment
Anyway, this is not an indicated method to add a directory to the PATH. See the following post in this sense:

- 169,590
-
The confusion may be that
/etc/environment
is recommended here: https://help.ubuntu.com/community/EnvironmentVariables#System-wide_environment_variables Other methods are also advised against at that link. – kiri Nov 03 '13 at 12:52 -
The question you link is nice, but some information is outdated. Actually it's a messy post with good and bad things, and I guess it's better for the OP if we answer specifically his question here. Cheers
:)
. – gniourf_gniourf Nov 03 '13 at 12:57 -
@gniourf_gniourf If you feel this, then add your new answer there. There is no problem to answer to old questions. – Radu Rădeanu Nov 03 '13 at 13:03
/etc/environment
, the PATH doesn't change? – Radu Rădeanu Nov 03 '13 at 12:49;)
. – gniourf_gniourf Nov 03 '13 at 12:54