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 backgroundCodePudding user response: