You are not logged in.

#1 2023-01-06 01:16:26

ulaska
Member
Registered: 2023-01-06
Posts: 5

Could not find env file

Hi pros,

A new newbie just landed in this Newbie Corner.

Could I please have some assistance on finding my env file?

----------------------------
Now I am using zsh and installed Maven successfully. Then I add Maven into the Environment variable like this:

export M2_HOME=/usr/local/apache-maven/apache-maven-3.8.4
export M2=$M2_HOME/bin
export MAVEN_OPTS=-Xms256m -Xmx512m
export PATH=$M2:$PATH

It is successful too. Now I can run "mvn -version".

Then I checked those paths by using "printenv". They are all there. For example, the Maven is like:

PATH=/usr/local/apache-maven/apache-maven-3.8.7/

Then I tried to find where I add those Paths to. I tried the following:

/etc/environment
~/.bashrc
~/.pam_environment 
~/.xprofile 
~/.zshrc

However, I could not find "PATH=/usr/local/apache-maven/apache-maven-3.8.7/" in any of above.

So where could it be stored in? Where is the exact env file storing these paths?

Thanks in advance!

Offline

#2 2023-01-06 01:19:36

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Could not find env file

Exporting works for the current shell. You have to edit the relevant file and add it yourself. See: https://wiki.archlinux.org/title/Zsh#St … down_files


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2023-01-06 01:22:36

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: Could not find env file

Do you mean which file should you put those in?  That can depend on how you start and use your session (e.g., display manager, startx, or direct compositor running for graphical sessions).  Or are you literally asking where they are stored after you enter those commands in an interactive shell?  In the case of the latter, they are not stored in any file, only in memory.

They can be found in a pseudo-files like /proc/$PPID/environ, but I highly doubt that's what you are asking about.

Last edited by Trilby (2023-01-06 01:23:39)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2023-01-06 01:38:17

ulaska
Member
Registered: 2023-01-06
Posts: 5

Re: Could not find env file

Trilby wrote:

Do you mean which file should you put those in?  That can depend on how you start and use your session (e.g., display manager, startx, or direct compositor running for graphical sessions).  Or are you literally asking where they are stored after you enter those commands in an interactive shell?  In the case of the latter, they are not stored in any file, only in memory.

They can be found in a pseudo-files like /proc/$PPID/environ, but I highly doubt that's what you are asking about.


Hi Trilby,

Thanks for replying!

Let me clarify, if I use command "printenv" it will print out something including:

...

PATH=/home/myusername/.pyenv/shims:/home/myusername/.autojump/bin:/home/myusername/.pyenv/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/var/lib/flatpak/exports/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/usr/lib/jvm/default/bin:/home/myusername/.local/bin

...

Is this PATH stored in a specific file so we can edit it? I thought it should be a file like

~/.bashrc
~/.pam_environment
~/.xprofile
~/.zshrc

But it's not. So is there such a file to store this path?

Offline

#5 2023-01-06 01:41:04

ulaska
Member
Registered: 2023-01-06
Posts: 5

Re: Could not find env file

jasonwryan wrote:

Exporting works for the current shell. You have to edit the relevant file and add it yourself. See: https://wiki.archlinux.org/title/Zsh#St … down_files

Thank you jasonwryan!

I am currently using Tabby and zsh. So how can I find the relevant file so I can edit it?

Offline

#6 2023-01-06 01:49:27

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,260

Re: Could not find env file

There's a whole list of them under that link.

What's your end goal, do you want these only exported in your interactive shell or globally everywhere for every tool you might reasonably use as soon as you log in? The default PATH get's built by /etc/profile which is generally read/initialized by most utilities. And since like trilby I'm not entirely sure what you are asking, if you run these export commands in your current shell they are that exact shell session and will be gone if you close the terminal window/exit the shell and need to be reexported, if you want the setup by default you need to adjust one of the various environment files appropriately - "the file somewhere" is the process memory in your RAM of the shell where you ran the exports in, which is what printenv prints.

Last edited by V1del (2023-01-06 01:53:57)

Offline

#7 2023-01-06 01:59:48

ulaska
Member
Registered: 2023-01-06
Posts: 5

Re: Could not find env file

V1del wrote:

There's a whole list of them under that link.

What's your end goal, do you want these only exported in your interactive shell or globally everywhere for every tool you might reasonably use as soon as you log in? The default PATH get's built by /etc/profile which is generally read/initialized by most utilities. And since like trilby I'm not entirely sure what you are asking, if you run these export commands in your current shell they are that exact shell session and will be gone if you close the terminal window/exit the shell and need to be reexported, if you want the setup by default you need to adjust one of the various environment files appropriately - "the file somewhere" is the process memory in your RAM of the shell where you ran the exports in, which is what printenv prints.

Thank mate,

What I was trying to achieve is to edit the file in the future, in case I want to delete/edit the path today I just added. Or maybe I was just out of my Curiosity.

Offline

#8 2023-01-06 02:06:56

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,260

Re: Could not find env file

As said the path you added today is invalid as soon as you run exit in that shell. If you want to persist it see one of the other links

Offline

#9 2023-01-06 02:12:29

ulaska
Member
Registered: 2023-01-06
Posts: 5

Re: Could not find env file

I see. Thank you guys each of you!

I think all of your answer points to the same direction, like if I want to change the $PATH, I just change it like:

export PATH=anything I need.

Similar issue and answer also found here:
https://stackoverflow.com/questions/116 … h-variable

Again, thank you all for the inspiration!

Offline

Board footer

Powered by FluxBB