Problem with exportation of environmental variable

whiteduke

New Member
Joined
Jan 9, 2024
Messages
17
Reaction score
0
Credits
147
please i am learning how to use environmental variable like PS1 and HISTSIZE on kali linux. I successfully change the variable in my current working terminal but when i export it using "export" command and open an d another terminal to verify nothing has change i don't know what to do i need help
 


If you set an environment variable in a terminal, then that setting will only apply to that terminal which will pass on the environment variable value to the child processes to which that terminal is the parent. In this case, the environment variable will not apply to any other terminal.

If you want to set an environment variable to apply to all terminals, then the usual way is to set it in the user's .bashrc file so that at the next boot up, all terminals will use the settings in that .bashrc.

If you wish to apply the environment variable to a new terminal without rebooting, then once the environment variable is set in the .bashrc file, you can source that in a new terminal with the command in the new terminal thus:
Code:
source .bashrc
which will have the terminal reset it's environment to that specified in the current .bashrc file, and the newly set environment variable will then apply to that new terminal.
 
Thanks for this respond. Please what is the use of of the export command ? If it doesn’t export change variable to whole system
 
Thanks for this respond. Please what is the use of of the export command ? If it doesn’t export change variable to whole system
As implied in post #2, environment variables pass their values from parent to child processes. That's useful in that it provides a fine grained control of environment variables for the user. Exporting the environment variable is simply controlling it to apply to all child processes.

To see exported environment variables which apply system wide, one can inspect such variables set in many of the configuration files in the /etc directory. You can check some out in the /etc/bash.bashrc file (or similar in your distro), or in /etc/profile, among others.

To see the environment variables set for the system from a range of configuration files, run the command: env.

The user can export system wide environment variables by inserting the relevant code, as root, in the /etc/environment file. They will become active on rebooting.

It's possible to add environment variables, or alter them in the system files that are found in the /etc directory, but one needs to know what they are doing, and updates can overwrite them.
 
Last edited:
For global variable settings. You can use /etc/environment
Anything in this file will will exported globally.
 
As implied in post #2, environment variables pass their values from parent to child processes. That's useful in that it provides a fine grained control of environment variables for the user. Exporting the environment variable is simply controlling it to apply to all child processes.

To see exported environment variables which apply system wide, one can inspect such variables set in many of the configuration files in the /etc directory. You can check some out in the /etc/bash.bashrc file (or similar in your distro), or in /etc/profile, among others.

To see the environment variables set for the system from a range of configuration files, run the command: env.

The user can export system wide environment variables by inserting the relevant code, as root, in the /etc/environment file. They will become active on rebooting.

It's possible to add environment variables, or alter them in the system files that are found in the /etc directory, but one needs to know what they are doing, and updates can overwrite them.
thanks so much
 
I installed Kali Linux on my VM virtual box, but I had no wireless out of the box. Ethernet works fine, and I can connect to wireless networks normally from Windows running on the same machine.

I found this video on Google which suggested I install the compatible wireless driver. I downloaded it from kernel.org, extracted it to ~/Desktop and ran the following commands:

$ cd desktop
$ cd filenameofthatextracted folder
$ make unload
$ make load

After these commands, my wireless NIC seems to be recognized (see iwconfig output below), but I can't see any available wireless networks. Also, the driver disappears after restarting, and I have to run the commands again and reinstall to get the NIC to show up in iwconfig again.

Relevant information:

root@Light:~# iwconfig

wlan1 IEEE 802.11abgn ESSID:eek:ff/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr:eek:ff Fragment thr:eek:ff
Encryption key:eek:ff
Power Management:eek:ff

eth0 no wireless extensions.

lo no wireless extensions.

wlan0 IEEE 802.11abgn ESSID:eek:ff/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
Retry short limit:7 RTS thr:eek:ff Fragment thr:eek:ff
Encryption key:eek:ff
Power Management:eek:ff

hwsim0 no wireless extensions.
 


Top