Dr. Mark Humphrys

School of Computing. Dublin City University.

Online coding site: Ancient Brain

coders   JavaScript worlds

Search:

Free AI exercises


How to change the PATH

  
Motivation:

To put $HOME/bin in PATH, put this line:

   export PATH=$PATH:$HOME/bin 
in this file:
   $HOME/.profile 
To test it:
  source $HOME/.profile
  echo $PATH
Or just logout and login again.
  

Notes

  


OS programs and your programs

You type the names of OS programs and your programs.
So some issues arise: Discussion:

Recommended:



Optional experiment: "." in the PATH can be security risk

This is an advanced optional experiment to show that "." in the PATH can be a security risk.
Only advanced users should attempt this.
Do the following experiment with a friend:
  1. Put "." at the start of your PATH.
  2. Get your friend to make their home directory "r-x" for group.
  3. Get your friend to make a program called "ls" in their home directory. The program is:

    echo "You have been hacked."
    echo "I will now rm your files."
    

  4. "cd" to your friend's home directory and type "ls"
  5. Now you see the problem?

  6. "cd" to my home directory, which is "--x" for you, and type "ls".
  7. That is odd too. Why?

Cleanup:

  1. Get your friend to set their home directory back to normal "---" for group.
  2. Remove "." from your PATH or put it at the end.


ancientbrain.com      w2mind.org      humphrysfamilytree.com

On the Internet since 1987.      New 250 G VPS server.

Note: Links on this site to user-generated content like Wikipedia are highlighted in red as possibly unreliable. My view is that such links are highly useful but flawed.