/media/bill/PROJECTS/System_maintenance/Linux/env - environment variables notes.txt www.BillHowell.ca 09Oct2019 initial +----+ env - display exported environment variables To get Howell's directories : $ env | grep "d_" +-----+ bash global variables (see end of this file for details, manual setting) - have been a real pain in the ass!! - It's in ~/.bashrc !!?? *********************************** ******** 11Sep2020 Revert to USB d_PROJECTS drive (named Samsung G4) +-----+ 1. d_PROJECTS is currently in list of env variable for ALL computers! +--+ # for all my Linux machines : export d_PROJECTS="$d_home""PROJECTS/" ; export d_bin="$d_PROJECTS""bin/" ; export p_log="$d_PROJECTS""bin/standard log.txt" ; export d_SysMaint="$d_PROJECTS""System_maintenance/" ; export d_Qroot="$d_PROJECTS""Qnial/" ; export d_Qndfs="$d_Qroot""MY_NDFS/" ; export d_Qtests="$d_Qroot""code develop_test/" ; export d_Lucas="$d_PROJECTS""Lucas - Universal Force/" ; export d_LucaSym="$d_Lucas""symbol tables/" ; export d_MindCode="$d_Qndfs""MindCode/" ; export d_References="$d_PROJECTS""References/" ; export d_SAMSUNG_G4="$d_meda""SAMSUNG_G4/" ; export d_calc="libreoffice" +--+ change to (remove d_PROJECTS) : +--+ # for all my Linux machines : export d_bin="$d_PROJECTS""bin/" ; export p_log="$d_PROJECTS""bin/standard log.txt" ; export d_SysMaint="$d_PROJECTS""System_maintenance/" ; export d_Qroot="$d_PROJECTS""Qnial/" ; export d_Qndfs="$d_Qroot""MY_NDFS/" ; export d_Qtests="$d_Qroot""code develop_test/" ; export d_Lucas="$d_PROJECTS""Lucas - Universal Force/" ; export d_LucaSym="$d_Lucas""symbol tables/" ; export d_MindCode="$d_Qndfs""MindCode/" ; export d_References="$d_PROJECTS""References/" ; export d_calc="libreoffice" +--+ +-----+ +-----+ Now add d_PROJECTS to computer-specific env variable setups : +-----+ # LMDE-specific : +-----+ # Suse-specific : +--+ # Suse-specific : sudo mkdir /mnt/ramdisk sudo mount -t tmpfs -o size=5120m ramdisk /mnt/ramdisk sudo df -h export d_home="/home/bill/" ; d_meda="/run/media/bill/" ; export d_temp="/mnt/ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_home""SWAPPER/" ; export d_HOWELL_BASE="$d_home""HOWELL_BASE/" ; d_txted="kwrite" +--+ change to : +--+ sudo mkdir /mnt/ramdisk sudo mount -t tmpfs -o size=5120m ramdisk /mnt/ramdisk sudo df -h export d_home="/home/bill/" ; d_meda="/run/media/bill/" ; export d_temp="/mnt/ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_PROJECTS="$d_meda""PROJECTS/" ; export d_SWAPPER="$d_meda""SWAPPER/" ; export d_HOWELL_BASE="$d_meda""HOWELL_BASE/" ; export d_txted="kwrite" +--+ ******** 28Jun2020 Suse Bash global variables done as below, seems to work! ********** 09Apr2020 Retry : Bash global variables have been a real pain in the ass!! THIS WORKED!!! (see end of note - ~/.bashrc) ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. $ find "/home/bill/" -name "*.sh" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "HOWELL_computer" "FILE" >"/media/bill/ramdisk/grepper.txt" $ cat "/media/bill/ramdisk/grepper.txt" | grep --invert-match "Is a directory" from "Howell_global_vars.sh" # Linux and how do I make environmental variables permanent? # https://googleweblight.com/?lite_url=https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-environment-variables-in-linux/&ei=FIFcvP21&lc=en-CA&geid=1040&s=1&m=240&host=www.google.com&f=1&gl=ca&ts=1579906882&sig=ACgcqhpl7JrHS-2OQBHV7843wht4aV6V0g&sa=X&ved=2ahUKEwi4rcfjq53nAhUOsJ4KHbnxB58QFnoECAoQAg # Open the current user’s profile into a text editor # vi ~/.bash_profile # Add the export command for every environment variable you want to persist. # export JAVA_HOME=/opt/openjdk11 # Save your changes. #Adding the environment variable to a user’s bash profile alone will not export it automatically. However, the variable will be exported the next time the user logs in. #To immediately apply all changes to bash_profile, use the source command. # source ~/.bash_profile # >> on Raspi : source ~/.profile Hah! finally? It's in ~/.bashrc !!?? I addded : +-----+ export HOWELL_computer="LMDE2" # for LMDE : export d_txted="geany -i" ; export d_home="/home/bill/" ; export d_meda="/media/bill/" ; export d_temp="$d_meda""ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_meda""SWAPPER/" ; export d_HOWELL_BASE="$d_meda""HOWELL_BASE/" ; # for Suse # (04Jan2020 run only export line : I didn't need to set up the ramdisk, it was there from cold boot) : # 04Mar2020 >>properly mount ramdisk or scripts won't work if they use ramdisk $ sudo mkdir /mnt/ramdisk $ sudo mount -t tmpfs -o size=5120m ramdisk /mnt/ramdisk $ sudo df -h $ export d_home="/home/bill/" ; d_meda="/run/media/bill/" ; export d_temp="/mnt/ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_home""SWAPPER/" ; export d_HOWELL_BASE="$d_home""HOWELL_BASE/" ; # for RaspPi : $ export d_home="/home/bill/" ; export d_meda="/media/bill/" ; export d_temp="$d_meda""RaspPi_ext4_32Gb/temp/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_home""SWAPPER/" ; export d_HOWELL_BASE="$d_home""HOWELL_BASE/" ; # for Lenovo : $ export d_home="/home/bill/" ; export d_meda="/media/bill/" ; export d_temp=""$d_meda""ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_home""SWAPPER/" ; export d_HOWELL_BASE="$d_home""HOWELL_BASE/" ; # for all : export d_PROJECTS="$d_home""PROJECTS/" ; export d_bin="$d_PROJECTS""bin/" ; export p_log="$d_PROJECTS""bin/standard log.txt" ; export d_SysMaint="$d_PROJECTS""System_maintenance/" ; export d_Qroot="$d_PROJECTS""Qnial/" ; export d_Qndfs="$d_Qroot""MY_NDFS/" ; export d_Qtests="$d_Qroot""code develop_test/" ; export d_Lucas="$d_PROJECTS""Lucas - Universal Force/" ; export d_LucaSym="$d_Lucas""symbol tables/" ; export d_MindCode="$d_Qndfs""MindCode/" ; export d_References="$d_PROJECTS""References/" ; export d_SAMSUNG_G4="$d_meda""SAMSUNG_G4/" ; export d_calc="libreoffice" # to check : $ env | grep "d_" ********** 09Apr2020 Bash global variables have been a real pain in the ass!! DIDN'T work!!! -> 1. get rid of old shit that didn't work : $ sudo mv "/etc/profile.d/Howell_global_vars.sh" "/home/bill/PROJECTS/System_maintenance/Linux/z_Archive/" $ sudo mv "/etc/profile.d/lmde.sh" "/home/bill/PROJECTS/System_maintenance/Linux/z_Archive/" 2. Change "/home/bill/.profile" +-----+ # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package. # the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then export PATH="$HOME/bin:$PATH" fi export HOWELL_computer="LMDE2" +-----+ To : +-----+ # ~/.profile: executed by the command interpreter for login shells. # This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login # exists. # see /usr/share/doc/bash/examples/startup-files for examples. # the files are located in the bash-doc package. # the default umask is set in /etc/profile; for setting the umask # for ssh logins, install and configure the libpam-umask package. #umask 022 # if running bash if [ -n "$BASH_VERSION" ]; then # include .bashrc if it exists if [ -f "$HOME/.bashrc" ]; then . "$HOME/.bashrc" fi fi # set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then export PATH="$HOME/bin:$PATH" fi export HOWELL_computer="LMDE2" # for LMDE : export d_txted="geany -i" ; export d_home="/home/bill/" ; export d_meda="/media/bill/" ; export d_temp="$d_meda""ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_meda""SWAPPER/" ; export d_HOWELL_BASE="$d_meda""HOWELL_BASE/" ; # for Suse # (04Jan2020 run only export line : I didn't need to set up the ramdisk, it was there from cold boot) : # 04Mar2020 >>properly mount ramdisk or scripts won't work if they use ramdisk $ sudo mkdir /mnt/ramdisk $ sudo mount -t tmpfs -o size=5120m ramdisk /mnt/ramdisk $ sudo df -h $ export d_home="/home/bill/" ; d_meda="/run/media/bill/" ; export d_temp="/mnt/ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_home""SWAPPER/" ; export d_HOWELL_BASE="$d_home""HOWELL_BASE/" ; # for RaspPi : $ export d_home="/home/bill/" ; export d_meda="/media/bill/" ; export d_temp="$d_meda""RaspPi_ext4_32Gb/temp/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_home""SWAPPER/" ; export d_HOWELL_BASE="$d_home""HOWELL_BASE/" ; # for Lenovo : $ export d_home="/home/bill/" ; export d_meda="/media/bill/" ; export d_temp=""$d_meda""ramdisk/" ; export d_travel="$d_meda""SAMSUNG_G4/" ; export d_SWAPPER="$d_home""SWAPPER/" ; export d_HOWELL_BASE="$d_home""HOWELL_BASE/" ; # for all : export d_PROJECTS="$d_home""PROJECTS/" ; export d_bin="$d_PROJECTS""bin/" ; export p_log="$d_PROJECTS""bin/standard log.txt" ; export d_SysMaint="$d_PROJECTS""System_maintenance/" ; export d_Qroot="$d_PROJECTS""Qnial/" ; export d_Qndfs="$d_Qroot""MY_NDFS/" ; export d_Qtests="$d_Qroot""code develop_test/" ; export d_Lucas="$d_PROJECTS""Lucas - Universal Force/" ; export d_LucaSym="$d_Lucas""symbol tables/" ; export d_MindCode="$d_Qndfs""MindCode/" ; export d_References="$d_PROJECTS""References/" ; export d_SAMSUNG_G4="$d_meda""SAMSUNG_G4/" ; export d_calc="libreoffice" # to check : $ env | grep "d_" +-----+ ****** 12Jan2020 show exported environment or run program in a modified environment see : https://www.cyberciti.biz/faq/linux-list-all-environment-variables-env-command/ A note about env/set command The env will only display a list of environment variables that have been exported and it will not show all bash variables. The set command allows you to change the values of shell options and set the positional parameters, or to display the names and values of shell variables. If no options or arguments are supplied, set displays the names and values of all shell variables and functions, sorted according to the current locale, in a format that may be reused as input for setting or resetting the currently-set variables. Hence, I recommend that you use printenv command to dump the list of all shell variables on screen. To save the list of all shell environment variables to a file, enter: printenv > env.txt cat env.txt Use the grep command to search for particular variable: printenv | grep foo printenv | grep HOME ************** 06Jan2020 LMDE #!/bin/sh # sudo emacs "/etc/profile.d/Howell_global_vars.sh" # www.BillHowell.ca 11Jan2018 initial, 01Apr2018 port to LMDE2 on Dell64 # 06Jan2020 It's hard to edit root files, even with sudo -i, etc # Instead : copy to local, then edit, then copy over original : # $ cp "/etc/profile.d/Howell_global_vars.sh" "/media/bill/PROJECTS/bin/Howell_global_vars.sh" # $ emacs "/media/bill/PROJECTS/bin/Howell_global_vars.sh" # $ sudo cp "/media/bill/PROJECTS/bin/Howell_global_vars.sh" "/etc/profile.d/Howell_global_vars.sh" # This doesn't work!! ?? export PS1="\w\n\$ " # choice of [LMDE2,Ubuntu,Lenovo,RaspPi] export HOWELL_computer="LMDE2" export d_meda="/media/bill/" export d_temp="$d_meda""ramdisk/" export d_PROJECTS="$d_meda""PROJECTS/" export d_bin="$d_meda""PROJECTS/bin/" export p_log="$d_meda""PROJECTS/bin/standard log.txt" export d_SysMaint="$d_PROJECTS/System_maintenance" export d_Qroot="$d_meda""PROJECTS/Qnial/" export d_Qndfs="$d_Qroot""MY_NDFS/" export d_Qtests="$d_Qroot""code develop_test/" export d_Lucas="$d_meda""PROJECTS/Lucas - Universal Force/" export d_LucaSym="$d_Lucas""symbol tables/" export d_SWAPPER="$d_meda""SWAPPER/" # enddoc *************** 09Oct2019 how to set HOWELL_computer search "linux how to set environment variables" https://askubuntu.com/questions/643585/how-to-set-a-permanent-environment-variable Add the following to the /etc/profile file (for system wide change) or to ~/.profile for local user. export CATALINA_HOME=/opt/apache-tomcat-8.0.23 edited Jun 24 '16 at 20:29, muru answered Jul 2 '15 at 13:32, 7171u https://www.linuxquestions.org/questions/linux-newbie-8/setting-environment-variables-on-suse-permanently-4175427044/ 09-13-2012, 07:10 AM #2, pan64, LQ Guru see /etc/profile, man bash or this thread: http://www.linuxquestions.org/questi...bashrc-273992/ https://www.linuxquestions.org/questions/linux-general-1/etc-profile-v-s-etc-bashrc-273992/ 01-11-2005, 10:26 PM #2, IBall, Senior Member From "man bash" Quote: When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. Quote: When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. In other words, /etc/profile is run when a user logs in. ~/.bashrc is run for other shells (Ie opening an xterm) I hope this helps --Ian >> see # /etc/profile.local for SUSE Linux #www.BillHowell.ca for Suse Linux on ThinkPad 09Oct2019 initial # also - see "/run/media/bill/PROJECTS/System_maintenance/Linux/environment variables, permanent.txt" # $ sudo cp "/run/media/bill/PROJECTS/System_maintenance/Linux/environment variables, permanent.txt" "/etc/profile.local" # # PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes # will be lost during system upgrades. Instead use /etc/profile.local for # your local settings, favourite global aliases, VISUAL and EDITOR # variables, etc ... export HOWELL_computer="ThinkPad" ************** 09Oct2019 # /etc/profile.local for SUSE Linux #www.BillHowell.ca for Suse Linux on ThinkPad 09Oct2019 initial # also - see "/run/media/bill/PROJECTS/System_maintenance/Linux/environment variables, permanent.txt" # $ sudo cp "/run/media/bill/PROJECTS/System_maintenance/Linux/environment variables, permanent.txt" "/etc/profile.local" # # PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes # will be lost during system upgrades. Instead use /etc/profile.local for # your local settings, favourite global aliases, VISUAL and EDITOR # variables, etc ... export HOWELL_computer="ThinkPad" # enddoc