L in u X ba sics for h acke rs g e t t I n g s t a r t e d w I t h


Making Variable Value Changes Permanent


Download 7.3 Mb.
Pdf ko'rish
bet80/115
Sana27.10.2023
Hajmi7.3 Mb.
#1728481
1   ...   76   77   78   79   80   81   82   83   ...   115
Bog'liq
linuxbasicsforhackers

Making Variable Value Changes Permanent
When you change an environment variable, that change only occurs in that 
particular environment; in this case, that environment is the bash shell 
session. This means that when you close the terminal, any changes you 
made are lost, with values set back to their defaults. If you want to make the 
changes permanent, you need to use the 
export
command. This command 
will export the new value from your current environment (the bash shell) to 
any new forked child processes. This allows the new process to inherit the 
exported variables.
Variables are strings, so if you run on the cautious side, it isn’t a bad 
idea to save the contents of a variable to a text file before you modify it. 
For example, since we’re about to change the 
PS1
variable, which controls 
the information you display in the prompt, first run the following com-
mand to save the existing values to a text file in the current user’s home 
directory:
kali >echo $HISTSIZE> ~/valueofHISTSIZE.txt
This way, you can always undo your changes. If you want to be even 
more cautious and create a text file with all the current settings, you can 
save the output of the 
set
command to a text file with a command like 
this one:
kali >set> ~/valueofALLon01012019.txt
After you’ve changed a variable, as we did in Listing 7-1, you can make 
the change permanent by entering 
export
and then the name of the variable 
you changed, as shown here:
kali >export HISTSIZE
Now the 
HISTSIZE
variable will still be set to 0 in this environment and 
will no longer store your commands. If you want to reset the 
HISTSIZE
vari-
able to 1,000, simply enter this:
kali >HISTSIZE=1000
kali >export HISTSIZE
This code snippet will set your 
HISTSIZE
variable’s value to 1,000 and 
export it to all your environments.


Managing User Environment Variables

Download 7.3 Mb.

Do'stlaringiz bilan baham:
1   ...   76   77   78   79   80   81   82   83   ...   115




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling