We changed our privacy policy. Read more.

New answers tagged

3

Building on the other answers here, some commands that parallel export but for other categories of variables are set (which works for e.g. VARIABLE=value then set | grep VARIABLE) and env Each of these three commands, when given no arguments, prints a list of variables; which variables they will print has to do with the kinds of variables the command manages....


4

echo and export are very different commands in the first place. echo will display text. In echo $JAVA_HOME, the shell will substitute $JAVA_HOME with the contents of the shell variable JAVA_HOME it it is defined. Otherwise, $JAVA_HOME will return an empty string. export provides the "export" attribute to the shell variable. export JAVA_HOME will ...


11

The issue here is not really the difference between echo and export, but rather the difference between an environment variable and a simple shell variable (and also about how the /etc/environment file is normally used). In particular, although /etc/environment happens to contain lines of the form name=value that are valid as POSIX shell variable assignments, ...


0

echo is a command for printing text and variables to stdout (or redirect). export lists the current exported variables in the shell. This thread explains why you would use export much better than I can: https://stackoverflow.com/questions/7411455/what-does-export-do-in-shell-programming ... it does a great job explaining what export is fo


0

Before setting a PATH variable, you need to understand why you are setting the PATH variable. The Path variable is where the system tries to search when you issue some command in your terminal. Example: whereis ls command shows ls is there inside /bin. The ls command only works if /bin is registered in the path variable. echo $PATH gives the currently ...


0

In LXQt, a good place to set environment variables for programs you will launch from the menu is in the session settings; these are located in the INI-style file ~/.config/lxqt/session.conf, in the [Environment] section. You can also configure them in the GUI under Preferences -> LXQt Settings -> Session Settings, where you will find the list in the ...


1

There are a few comments worth noting. "... the gpg passphrase (which is set by a script)". I take it you didn't write the script. Please post the script. Are there any instructions to use it? passphrase="my!pass". This doesn't mean "use ! as part of the string". !pass means "read history, and get the last command starting ...


8

Scripts that are executed for a login shell (systemwide /etc/profile, any script in /etc/profile.d, your local ~/.profile and the other files you list) define the environment of your current user - since you logged in. Any non-login shell that you subsequently open, will at least inherit the environment of your login shell. That is why you (already) have ...


0

export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")


1

The output of the following commands should convince you that you can modify your environment variables. $ grep PATH ~/.profile # set PATH so it includes user's private bin if it exists PATH=~/bin:"${PATH}" PATH="$PATH:/usr/games" $ ls -l ~/.profile -rw-r--r-- 1 sudodus sudodus 632 dec 10 2010 /home/sudodus/.profile In other words,...


1

Use ~/.profile. It's sourced by the display manager and alters PATH for the whole session.


1

Every *.desktop file has Exec= field. This field may include: executable name which is already in $PATH; full path to executable which is not in $PATH; full path to user/system-created script which does what is needed. Documentation to read: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#exec-variables . ...


1

Replace the shortcut's command with a pointer to a bash script, set up your environment in the script, then call the shortcut's command.


0

I solved the issue. I don't exactly why, but after several restarts (not after just one) the path got set instantly instead of me having to manually source it. Kr, Yannick


2

You need to put double quotes around $PROJECTPATH in your alias definition. Also, I recommend against backslashes in your variable definition. It's less readable and isn't needed in this case: PROJECTPATH='/mnt/c/Users/name/Dropbox/My PC (Laptop...)/Desktop/Studies/Python' alias prjct='cd "$PROJECTPATH"'


1

Add export JAVA_HOME=/opt/path/to/jdk export PATH=${PATH}:/opt/path/to/jdk/bin to your ~/.bashrc. After that, either reboot or apply these changes to your current shell with source ~/.bashrc


-2

I have tried a lot of ways of setting environment but the export only seems to work and to run a bunch exports everytime it reboots you run a shell script in a cron job. Adding systemd Environment Variable https://www.freedesktop.org/software/systemd/man/systemd.exec.html#EnvironmentFile= this shows how it is done in the environment file which can only be ...


0

The canonical location seems to vary across distributions. With Debian 10, the system-default PATH is defined in /etc/login.defs. The default PATH for normal users is its ENV_PATH variable and the default for super-users is ENV_SUPATH. These will be used for sessions that don't spawn shells (e.g. cron jobs) Other defaults may be defined by the per-shell ...


Top 50 recent answers are included