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, ...


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 ...


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 ...


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....


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

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 ...


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


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.


Only top voted, non community-wiki answers of a minimum length are eligible