I'm currently learning the foundations of Linux with Ubuntu and there is a little activity where I need to find information about environment variables. I already found 6/7 info but just can't find SUDO_COMMAND
. this is how the list goes:
SHELL=/bin/bash
USER=student
SUDO_COMMAND=
PWD=/home
HOME=/home/student
LOGNAME=student
OLDPWD=/home/student
I noticed that the information comes in order and the SUDO_COMMAND
is between user and pwd. did I make a mistake somewhere?
Best Answer
SUDO_COMMAND
is an environment variable set bysudo
only in the environment of the process started by it (and inherited by any child processes). If you runsudo some-command arg1 arg2
, thenSUDO_COMMAND
will contain the absolute path tosome-command
, andarg1 arg2
. If you ransudo -s
orsudo -i
, then the variable will be set to the shell that was started. In any case, you probably won't see it outside of a process tree started bysudo
.For example:
Or:
I don't know which command you're using, but you cannot rely on the output of
set
,declare
,env
orprintenv
to be in some order.