在这里,我创建了一个 linux shell 脚本来执行一个程序来回显“用户以 root 身份登录”。但它不会显示任何东西。如果我给出“退出”,那么它将显示“用户以 root 身份登录”。请帮我解决这个问题。
#!/bin/bash
logged_user=`whoami`
if [ $logged_user != root ]
then echo "You are not logged as root!"
echo "Enter root password if root password is set"
su #here it will ask to enter root password
echo "user logged as root" #this line is not working...
fi