You are not logged in.
Pages: 1
I thought I had understood environment variables, I don't think I have. For example I thought to change the default location of
gnupgto a new directory in my home I thought this would be the correct syntax:
export GNUPGHOME="${GNUPGHOME}:/home/muj/newdirectory
GNUPGHOMEbeing the variable and
/home/muj/newdirectorybeing the value. I haven't changed the location of
Gnupgas someone told me it's not necessary but I thought that was the correct syntax.
I've read the pages on the wiki about nano, sudo and environment variables.
I wanted to change the default vi editor to nano when using commands such as
visudoI've added what I thought could be the correct syntax for the command to
~/.bash_profileand also to
~/.bashrcand every time after editing the files I've run either
$ source .bash_profileor
$ source .bashrcbut every time I run
sudo visudoit opens up with vi.
the environment variable seems like it has the value as well within it so I tried different things such as:
export VISUAL=nano="${VISUAL=nano}:/home/muj/bin"export EDITOR=nano="${EDITOR=nano}:/home/muj/bin"export VISUAL=nano="${VISUAL=nano}:/usr/bin/nano"export EDITOR=nano="${EDITOR=nano}:/usr/bin/nano"export VISUAL=nano="${VISUAL=nano}:/usr/bin/visudo"export EDITOR=nano="${EDITOR=nano}:/usr/bin/visudo"export VISUAL=nano="${VISUAL=nano}:/nano"export EDITOR=nano="${EDITOR=nano}:/visudo"export VISUAL=nanoexport EDITOR=nanoCould someone please help me get some clarity on this issue?
Last edited by Straight-path (2020-10-28 16:44:50)
Offline
Which issue do you want help with? Your first example with GNUPGHOME is missing at least a closing quote (which may have just been a typo on the forum). It also may not have the intended result if GNUPGHOME is not already set as it will then be set to start with a colon - and while I'm not familiar with setting this variable, I do not see anything in the documentation suggesting it can / should be set to a colon-separated list. GNUPGHOME should be set to a directory, that's it. So I believe what you want is the following:
export GNUPGHOME=/home/muj/newdirectoryIn the many examples you gave for EDITOR and VISUAL, I'm not even sure what you are trying to do - all but the last two are gibberish and will not work at all. The last two properly set the environment variables - though sudo has many restrictions on whether it will actually use these environment variables. With the stock arch configuration, it will not. You'd be better off setting the editor in your sudoers file (edited with visudo) to include the following:
Defaults editor=/usr/bin/nanoLast edited by Trilby (2020-10-28 16:10:09)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
To know which environments are known to your current environment/shell run the printenv command.
The usecase with sudo has a sudo specific speciality. https://wiki.archlinux.org/index.php/Su … _variables
a normal sudo invocation will strip most variables before the relevant command being executed, so if you want to test whether you've set EDITOR correctly try
sudo -E visudoor rather add the EDITOR variable to the variables that sudo should keep.
Edit: Fuck, why do I keep forgetting the preview button
Last edited by V1del (2020-10-28 16:17:31)
Offline
lol, yes it was anectdotal, I speak my mind too much.
That's great, and thank you. There always seems to be just that one extra thing that I'm missing and can't find.
Just to ask the
In simple terms, it is a variable with a name and a value
are these all environment variables with their values:
export EDITOR=nanoand
VISUAL=nanoand
GNUPGHOME
QT_AUTO_SCREEN_SCALE_FACTOR=0
QT_SCALE_FACTORIf they are all environment variables with their values whats with the part after the colon such as
export GNUPGHOME="${GNUPGHOME}:/home/muj/newdirectorylol, Inspector parrot. you made me laugh "gibberish".
all the ways I tried to set the environment variable came from me trying and obviously failing to understand what the wiki said.
You do not always want to define an environment variable globally. For instance, you might want to add /home/my_user/bin to the PATH variable but do not want all other users on your system to have that in their PATH too. Local environment variables can be defined in many different files:
~/.pam_environment is the user specific equivalent of /etc/security/pam_env.conf [1], used by pam_env module. See pam_env(8) and pam_env.conf(5) for details.
User configuration files of your shell, for example Bash#Configuration files or Zsh#Startup/Shutdown files.
systemd will load environment variables from ~/.config/environment.d/*.conf see environment.d(5) and https://wiki.gnome.org/Initiatives/Wayland/SessionStart.
To add a directory to the PATH for local usage, put following in ~/.bash_profile:export PATH="${PATH}:/home/my_user/bin"
To update the variable, re-login or source the file: $ source ~/.bash_profile.
I obviously didn't read the whole sudo page on the wiki. I thought I had all I needed to try to set the variable.
I am pretty sure I get it now.
Thank you both for your time and help.
Last edited by Straight-path (2020-10-28 16:43:47)
Offline
The ${ENV}:path syntax has nothing to do with environment variables per se. There are just certain variables that have a "list" of things and it's simply a convention that : is the seperator. If you do not have a variable that expects a list of things and you don't want to reuse any existing contents already present in the variable there's no reason for the ${ENV}: part.
Offline
Thank you very much V1del. You understood my misunderstanding.
I suppose the anecdotal part was me trying to highlight my thinking and understanding holistically so as to get the help where I needed it (lol which I didn't know myself the parts I needed help on).
I don't know if its just me, but I feel like the wiki was written for people who already know these concepts and just need a reminder.
I meant no offence Trilby when I called you inspector parrot (that's the only name I saw). I just seem to rush a lot when I get help as I know I'm using someone else's time.
You'd be better off setting the editor in your sudoers file (edited with visudo) to include the following:
Defaults editor=/usr/bin/nanoI did see the above when I was reading the wiki but I wanted to use environment variables.
Thank you.
Last edited by Straight-path (2020-10-28 18:27:41)
Offline
I don't know if its just me, but I feel like the wiki was written for people who already know these concepts and just need a reminder.
It is, to a certain degree, Arch wiki on user centrality
Whereas many GNU/Linux distributions attempt to be more user-friendly, Arch Linux has always been, and shall always remain user-centric. The distribution is intended to fill the needs of those contributing to it, rather than trying to appeal to as many users as possible. It is targeted at the proficient GNU/Linux user, or anyone with a do-it-yourself attitude who is willing to read the documentation, and solve their own problems.
Which is why we did recommend you to try the waters on an easier distribution in an earlier thread that doesn't make it necessary to know about the lower level bits and pieces right away. However as far as newbies go I do think you have the generally right attitude. You do show what you've tried and where your misunderstandings lie and don't blame the system as a whole for issues that are due to your lack of understanding, that's a good mindset to have and helps us help you.
Offline
Yes I have read, lol and understood that section of the wiki. But I don't want to let my lack of knowledge hinder me in using Arch. Linux and the Arch distribution are both amazing.
I've always been of the mindset of throwing oneself into the deep end and learning to swim. And I have learnt so much which I wouldn't have even come across if I was using ubuntu. I would like you to know that I strive my utmost for many hours trying to work things out from the wiki and then google before posting as I appreciate the fact that you or anyone else are not obliged to help me and sort my issues out. I also want to be capable of reading a learning from the wiki on my own.
Your advice I take on board so let me know if I make a mistake or shouldn't be asking whatever etc. I don't want to be an annoyance, I would just like to be able to get help after I've done my best to understand first on my own.
Last edited by Straight-path (2020-10-28 18:44:47)
Offline
Pages: 1