1

I'm newbie here and unknowingly i added some un necessary paths (like 2 times java ) to

$PATH

I tried many solution but they remove until i'm active. If i reboot last path comes again. /usr/lib/jvm/java-13-oracle/db/bin

Here is my output

/home/nikhil/anaconda3/bin:/home/nikhil/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-13-oracle/bin:/usr/lib/jvm/java-13-oracle/db/bin

How to remove that permanently. Even i log out or reboot or shut down. I'm on ubuntu 18.04.

This is my etc/env...

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"

  • There are many places you could have added it - it's hard for us to guess which file(s) you edited (`/etc/environment/`? `/etc/profile`? `~/.bashrc`?) – steeldriver Feb 25 '20 at 15:37
  • @steeldriver I have checked all above. None of these seems wrong. – Nikhil Badyal Feb 25 '20 at 15:45
  • Create new user: `sudo adduser user`, login as it using `sudo user` command and `echo $PATH` from it in your question. – Gryu Feb 25 '20 at 15:49
  • @Gryu I did as you said. But i got same output. 2 times in new user. – Nikhil Badyal Feb 25 '20 at 15:57
  • @Gryu 1st path was not there(anaconda) only java was there in new user. – Nikhil Badyal Feb 25 '20 at 15:59
  • @NikhilSharma Ok, this means, you've changed something in your system's environment. What is at the end of your bash.bashrc `cat /etc/bash.bashrc `? – Gryu Feb 25 '20 at 16:00
  • @Gryu See updated post – Nikhil Badyal Feb 25 '20 at 16:03
  • Ok, there's nothing. You could remove it from question as it is not messed up. You could also check what is in your crontab: `crontab -e` and `sudo crontab -e` – Gryu Feb 25 '20 at 16:08
  • Another place to check is any `.sh` files that might have been sourced from the `/etc/profile.d` directory ex. `grep -w 'PATH' /etc/profile.d/*.sh` – steeldriver Feb 25 '20 at 16:10
  • @Gryu Just comments(begining with #). Nothing else. – Nikhil Badyal Feb 25 '20 at 16:13
  • @steeldriver After running above command i got this `# Expand $PATH to include the directory where snappy applications go. /etc/profile.d/apps-bin-path.sh:if [ -n "${PATH##*${snap_bin_path}}" -a -n "${PATH##*${snap_bin_path}:*}" ]; then /etc/profile.d/apps-bin-path.sh: export PATH=$PATH:${snap_bin_path} /etc/profile.d/jdk.sh:export PATH=$PATH:/usr/lib/jvm/java-13-oracle/bin:/usr/lib/jvm/java-13-oracle/db/bin` – Nikhil Badyal Feb 25 '20 at 16:15
  • Right - so it's in the `/etc/profile.d/jdk.sh` file – steeldriver Feb 25 '20 at 16:31
  • @steeldriver What next ? – Nikhil Badyal Feb 25 '20 at 16:42
  • Any of (1) edit the file and comment out or delete the erroneous assignment (2) rename the file with a different extension such as `.ignore` or (3) delete the file. Which one is right for your situation is for you to decide. – steeldriver Feb 25 '20 at 16:45
  • @steeldriver Unable to any of these. Delete and rename option not available. Cant open it so no edit – Nikhil Badyal Feb 25 '20 at 17:02
  • @NikhilSharma [How do I get permissions to edit system configuration files?](https://askubuntu.com/questions/92379/how-do-i-get-permissions-to-edit-system-configuration-files) – steeldriver Feb 25 '20 at 17:05
  • @steeldriver Even after doing as you said. Nothing happened. :-( – Nikhil Badyal Feb 25 '20 at 18:14
  • @Gryu I did something and found that on creating new user. Java path is not in path. It means that is not in enviornment. What i should do now ? – Nikhil Badyal Feb 25 '20 at 18:30
  • @NikhilSharma after changing files in `/etc/profile.d`, you will need to log out or at least start a new login session (ex. `su -l username`) for the changes to take effect – steeldriver Feb 25 '20 at 19:39

1 Answers1

0

To find all files with /usr/lib/jvm/java-13-oracle/bin text in your / directory, execute the next command:

sudo grep -rl "/usr/lib/jvm/java-13-oracle/bin" /

To reduce searching time, you could replace / by /etc, then by /home/youruserfolder

Then you could check suspicious files, trying to comment those, where export PATH=$PATH:/usr/lib/jvm/java-13-oracle/bin or something similar is present.

Gryu
  • 7,279
  • 9
  • 31
  • 52