Home > OS >  Turn to god: why the root in the shell to switch to the lower right account, history is redirected t
Turn to god: why the root in the shell to switch to the lower right account, history is redirected t

Time:11-19

# judgment terminal several ordinary users, each user to output the history record,
Why the root switch to low power account in the shell, the history is redirected to the file, no history records in a file??

USERS="$(last | awk '{print $1}' | sort -u | egrep - v ^ $|" root ") "
1
# using a for loop to switch to a different user to knock the history is redirected to the file
1
For the USER in the ${USERS}
Do
Su - ${USER} & lt;
The history & gt;>/home/${USER}/${USER} _history. TXT
# \ exit# ordinary users perform back to the root user, use \ exit
!
The done
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
` su - user - c "history & gt;> File. TXT "file. Why are there no content into TXT ` file? This method tried not
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Copyright statement: this article to CSDN blogger (family) of the original article, follow the CC BY 4.0 - SA the copyright agreement, reproduced and this statement, please attach the original source link
The original link: https://blog.csdn.net/qinzhikun2956929/article/details/106392343

CodePudding user response:

Speculation, when you su - your shell is the user's devices tty1, shell script would not be in the background

CodePudding user response:

flocculant by reference 1 floor response:
speculate that when you su - your devices tty1 shell is made of the user, this shell script would not be in the background now

History is interactive and non-interactive script implementation, so does not support record output, only on the interface instructions will be redirected to the file
  • Related