答:使用环境变量USER即可
如在脚本中打印当前用户名;
#!/bin/sh echo "user name = ${USER}"
如何在shell脚本中获取当前用户名?
原文:https://www.cnblogs.com/dakewei/p/username.html