Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to set system default environment variables in Alpine linux?

I know, with Ubuntu, you can set default values for environment variables in /etc/environment; I do not see that file in Alpine linux. Is there a different location for setting system-wide defaults?

like image 895
1ijk Avatar asked Feb 10 '16 21:02

1ijk


People also ask

Where do we set environment variables in Linux?

These variable are set and configured in /etc/environment, /etc/profile, /etc/profile. d/, /etc/bash.

Where do we set environment variables?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.

How do I set environment variables permanently in Linux?

You can set an environment variable permanently by placing an export command in your Bash shell's startup script " ~/. bashrc " (or "~/. bash_profile ", or " ~/. profile ") of your home directory; or " /etc/profile " for system-wide operations.

What are default environment variables in Linux?

Most Common Environment VariablesPWD – Current working directory. HOME – The user's home directory location. SHELL – Current shell (bash, zsh, etc.). LOGNAME – Name of the user.


1 Answers

It seems that /etc/profile is the best place I could find. At least, some environment variables are set there:

export CHARSET=UTF-8 export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin export PAGER=less export PS1='\h:\w\$ '  umask 022  for script in /etc/profile.d/*.sh ; do         if [ -r $script ] ; then                 . $script         fi done 

According to the contents of /etc/profile, you can create a file with .sh extension in /etc/profile.d/ and you have to pass --login every time to load the env variables e.g docker exec -it container sh --login.

like image 118
Vlad Frolov Avatar answered Sep 19 '22 01:09

Vlad Frolov